brep-io-kernel 1.0.177 → 1.0.178
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/about.html +3 -66
- package/dist/apiExamples/BREP_Booleans.html +2 -2
- package/dist/apiExamples/BREP_Export.html +2 -2
- package/dist/apiExamples/BREP_Primitives.html +2 -2
- package/dist/apiExamples/BREP_Transforms.html +2 -2
- package/dist/apiExamples/Embeded_2D_Sketcher.html +2 -2
- package/dist/apiExamples/Embeded_CAD.html +2 -2
- package/dist/apiExamples/Embeded_CAD_Integration_Test.html +2 -2
- package/dist/assembly-constraint-capture.html +5 -5
- package/dist/assets/{AnnotationRegistry-CyI5mmDu.js → AnnotationRegistry-QZj3o2R6.js} +1 -1
- package/dist/assets/{AssemblyConstraintRegistry-3P1cpGjG.js → AssemblyConstraintRegistry-DJV0rHvz.js} +1 -1
- package/dist/assets/{FeatureRegistry-Cd-GX-Bm.js → FeatureRegistry-C7MrfKHF.js} +3 -3
- package/dist/assets/{PartHistory-DxsRIXx4.js → PartHistory-CyUoWFuO.js} +1 -1
- package/dist/assets/{Tube-bO80ROeR.js → Tube-TKgrLSLm.js} +1 -1
- package/dist/assets/{annUtils-D9TT7tgs.js → annUtils-Cv2fgMTB.js} +1 -1
- package/dist/assets/{apiExample_BREP_Booleans-p7pplM2w.js → apiExample_BREP_Booleans-CVUu-3pI.js} +1 -1
- package/dist/assets/{apiExample_BREP_Export-DcEboCzN.js → apiExample_BREP_Export-D3YICePi.js} +1 -1
- package/dist/assets/{apiExample_BREP_Primitives-mwn27Zyf.js → apiExample_BREP_Primitives-CB9GlLIq.js} +1 -1
- package/dist/assets/{apiExample_BREP_Transforms-DoxqJ6cS.js → apiExample_BREP_Transforms-BTbdOuJd.js} +1 -1
- package/dist/assets/{apiExample_Embeded_2D_Sketcher-D0UY5aPj.js → apiExample_Embeded_2D_Sketcher-jli62c46.js} +1 -1
- package/dist/assets/{apiExample_Embeded_CAD-CGA1Zguy.js → apiExample_Embeded_CAD-BBzOAW8d.js} +1 -1
- package/dist/assets/{apiExample_Embeded_CAD_Integration_Test-CdZX2cCy.js → apiExample_Embeded_CAD_Integration_Test-Dla62MVj.js} +1 -1
- package/dist/assets/{assemblyConstraintDialogs-Qq5KEM_o.js → assemblyConstraintDialogs-7PwUshmv.js} +1 -1
- package/dist/assets/{brep-kernel-DRr4NDNQ.js → brep-kernel-B2gzJr_I.js} +3 -10
- package/dist/assets/{browserTests-DI1pWDf6.js → browserTests-Rma8zWcv.js} +1 -1
- package/dist/assets/{chamfer-DdXNz6lz.js → chamfer-jmLT1RTy.js} +1 -1
- package/dist/assets/{dialogCapturePageFactory-DGBZ6PkY.js → dialogCapturePageFactory-l1BkjONQ.js} +1 -1
- package/dist/assets/{featureDialogs-CUWi02Qp.js → featureDialogs-Bas0NDXF.js} +3 -3
- package/dist/assets/{featureDialogs-CJ9OA-vL.js → featureDialogs-zsfh_u_t.js} +1 -1
- package/dist/assets/{fillet-CJey7GJP.js → fillet-Bzd1Xae9.js} +1 -1
- package/dist/assets/{index.es-X1ZhwpCY.js → index.es-tZ6V_7py.js} +1 -1
- package/dist/assets/{javascript-CHFzcwro.js → javascript-DU8Xgp6c.js} +1 -1
- package/dist/assets/{main-cad-bbPyIDxb.js → main-cad-J2VK-edE.js} +6 -6
- package/dist/assets/{pmiDialogs-BFqEnCKw.js → pmiDialogs-DtSa0QaG.js} +1 -1
- package/dist/assets/{test-XEjDO9UE.js → test-D-0BGqtx.js} +3 -3
- package/dist/cad.html +10 -10
- package/dist/feature-dialog-capture.html +7 -7
- package/dist/help/index.html +3 -66
- package/dist/help/search-index.json +1 -1
- package/dist/pmi-dialog-capture.html +5 -5
- package/dist/test.html +1 -1
- package/dist/viewer.html +10 -10
- package/dist-kernel/brep-kernel.js +3 -10
- package/dist-kernel/help/index.html +3 -66
- package/dist-kernel/help/search-index.json +1 -1
- package/package.json +2 -3
- package/src/BREP/setupManifold.js +2 -7
- package/src/generated/licenseBundle.js +1 -1
- package/src/generated/manifoldSource.js +0 -1
- package/dist/assets/manifold-B8h_vZ5O.js +0 -16
- package/dist/assets/manifold-D9yvTBHx.wasm +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/manifold-Dgmk3x29.js","assets/preload-helper-ZNr0Qq7Q.js","assets/fillet-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/manifold-Dgmk3x29.js","assets/preload-helper-ZNr0Qq7Q.js","assets/fillet-Bzd1Xae9.js","assets/Tube-TKgrLSLm.js","assets/browserStorage-CvgF8ovw.js","assets/chamfer-jmLT1RTy.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
var ey=Object.defineProperty;var ty=r=>{throw TypeError(r)};var Vb=(r,e,t)=>e in r?ey(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var d=(r,e)=>ey(r,"name",{value:e,configurable:!0});var tt=(r,e,t)=>Vb(r,typeof e!="symbol"?e+"":e,t),Hb=(r,e,t)=>e.has(r)||ty("Cannot "+t);var ny=(r,e,t)=>e.has(r)?ty("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t);var $n=(r,e,t)=>(Hb(r,e,"access private method"),t);import{j as Gb,w as Wb,k as $b,W as Xb,e as qb}from"./browserStorage-CvgF8ovw.js";import{_ as is}from"./preload-helper-ZNr0Qq7Q.js";const Mh="183",Yb={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Zb={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},uv=0,Hf=1,hv=2,Kb=3,Jb=0,Do=1,fv=2,Dr=3,zn=0,gn=1,Bt=2,mi=0,Bs=1,Gf=2,Wf=3,$f=4,dv=5,jb=6,Ji=100,pv=101,mv=102,gv=103,_v=104,yv=200,xv=201,vv=202,bv=203,zc=204,kc=205,Sv=206,Mv=207,wv=208,Ev=209,Av=210,Tv=211,Cv=212,Iv=213,Rv=214,Vc=0,Hc=1,Gc=2,Ws=3,Wc=4,$c=5,Xc=6,qc=7,La=0,Pv=1,Nv=2,jn=0,Rp=1,Pp=2,Np=3,Dp=4,Fp=5,Lp=6,Op=7,Xf="attached",Dv="detached",wh=300,gi=301,ss=302,Fo=303,Lo=304,uo=306,Yo=1e3,Mn=1001,Zo=1002,Nt=1003,Up=1004,Qb=1004,Fr=1005,eS=1005,wt=1006,Oo=1007,tS=1007,fi=1008,nS=1008,Sn=1009,Bp=1010,zp=1011,$r=1012,Eh=1013,kn=1014,pn=1015,_i=1016,Ah=1017,Th=1018,Xr=1020,kp=35902,Vp=35899,Hp=1021,Gp=1022,mn=1023,yi=1026,ji=1027,Ch=1028,Oa=1029,$s=1030,Ih=1031,iS=1032,Rh=1033,Uo=33776,Bo=33777,zo=33778,ko=33779,Yc=35840,Zc=35841,Kc=35842,Jc=35843,jc=36196,Qc=37492,el=37496,tl=37488,nl=37489,il=37490,sl=37491,rl=37808,ol=37809,al=37810,cl=37811,ll=37812,ul=37813,hl=37814,fl=37815,dl=37816,pl=37817,ml=37818,gl=37819,_l=37820,yl=37821,xl=36492,vl=36494,bl=36495,Sl=36283,Ml=36284,wl=36285,El=36286,Fv=2200,Lv=2201,Ov=2202,Ko=2300,Al=2301,Bc=2302,qf=2303,Ds=2400,Fs=2401,Jo=2402,Ph=2500,Wp=2501,sS=0,rS=1,oS=2,Uv=3200,aS=3201,cS=3202,lS=3203,fs=0,Bv=1,Ai="",un="srgb",Xs="srgb-linear",jo="linear",gt="srgb",uS="",hS="rg",fS="ga",dS=0,Rs=7680,pS=7681,mS=7682,gS=7683,_S=34055,yS=34056,xS=5386,vS=512,bS=513,SS=514,MS=515,wS=516,ES=517,AS=518,Yf=519,zv=512,kv=513,Vv=514,Nh=515,Hv=516,Gv=517,Dh=518,Wv=519,Qo=35044,TS=35048,CS=35040,IS=35045,RS=35049,PS=35041,NS=35046,DS=35050,FS=35042,LS="100",Zf="300 es",Rn=2e3,qs=2001,OS={COMPUTE:"compute",RENDER:"render"},US={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},BS={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"},zS={TEXTURE_COMPARE:"depthTextureCompare"};function kS(r){for(let e=r.length-1;e>=0;--e)if(r[e]>=65535)return!0;return!1}d(kS,"arrayNeedsUint32");const VS={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Lr(r,e){return new VS[r](e)}d(Lr,"getTypedArray");function $v(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}d($v,"isTypedArray");function ea(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}d(ea,"createElementNS");function Xv(){const r=ea("canvas");return r.style.display="block",r}d(Xv,"createCanvasElement");const iy={};let rs=null;function HS(r){rs=r}d(HS,"setConsoleFunction");function GS(){return rs}d(GS,"getConsoleFunction");function ta(...r){const e="THREE."+r.shift();rs?rs("log",e,...r):console.log(e,...r)}d(ta,"log");function qv(r){const e=r[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=r[1];t&&t.isStackTrace?r[0]+=" "+t.getLocation():r[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return r}d(qv,"enhanceLogMessage");function Ue(...r){r=qv(r);const e="THREE."+r.shift();if(rs)rs("warn",e,...r);else{const t=r[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...r)}}d(Ue,"warn");function Ye(...r){r=qv(r);const e="THREE."+r.shift();if(rs)rs("error",e,...r);else{const t=r[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...r)}}d(Ye,"error");function na(...r){const e=r.join(" ");e in iy||(iy[e]=!0,Ue(...r))}d(na,"warnOnce");function WS(r,e,t){return new Promise(function(n,i){function s(){switch(r.clientWaitSync(e,r.SYNC_FLUSH_COMMANDS_BIT,0)){case r.WAIT_FAILED:i();break;case r.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:n()}}d(s,"probe"),setTimeout(s,t)})}d(WS,"probeAsync");const $S={[Vc]:Hc,[Gc]:Xc,[Wc]:qc,[Ws]:$c,[Hc]:Vc,[Xc]:Gc,[qc]:Wc,[$c]:Ws},rm=class rm{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const i=n[e];if(i!==void 0){const s=i.indexOf(t);s!==-1&&i.splice(s,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let s=0,o=i.length;s<o;s++)i[s].call(this,e);e.target=null}}};d(rm,"EventDispatcher");let Vn=rm;const Qt=["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 sy=1234567;const zs=Math.PI/180,qr=180/Math.PI;function Dn(){const r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Qt[r&255]+Qt[r>>8&255]+Qt[r>>16&255]+Qt[r>>24&255]+"-"+Qt[e&255]+Qt[e>>8&255]+"-"+Qt[e>>16&15|64]+Qt[e>>24&255]+"-"+Qt[t&63|128]+Qt[t>>8&255]+"-"+Qt[t>>16&255]+Qt[t>>24&255]+Qt[n&255]+Qt[n>>8&255]+Qt[n>>16&255]+Qt[n>>24&255]).toLowerCase()}d(Dn,"generateUUID");function je(r,e,t){return Math.max(e,Math.min(t,r))}d(je,"clamp$1");function $p(r,e){return(r%e+e)%e}d($p,"euclideanModulo");function XS(r,e,t,n,i){return n+(r-e)*(i-n)/(t-e)}d(XS,"mapLinear");function qS(r,e,t){return r!==e?(t-r)/(e-r):0}d(qS,"inverseLerp");function Vo(r,e,t){return(1-t)*r+t*e}d(Vo,"lerp");function YS(r,e,t,n){return Vo(r,e,1-Math.exp(-t*n))}d(YS,"damp");function ZS(r,e=1){return e-Math.abs($p(r,e*2)-e)}d(ZS,"pingpong");function KS(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}d(KS,"smoothstep");function JS(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}d(JS,"smootherstep");function jS(r,e){return r+Math.floor(Math.random()*(e-r+1))}d(jS,"randInt");function QS(r,e){return r+Math.random()*(e-r)}d(QS,"randFloat");function eM(r){return r*(.5-Math.random())}d(eM,"randFloatSpread");function tM(r){r!==void 0&&(sy=r);let e=sy+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}d(tM,"seededRandom");function nM(r){return r*zs}d(nM,"degToRad");function iM(r){return r*qr}d(iM,"radToDeg");function sM(r){return(r&r-1)===0&&r!==0}d(sM,"isPowerOfTwo");function rM(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}d(rM,"ceilPowerOfTwo");function oM(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}d(oM,"floorPowerOfTwo");function aM(r,e,t,n,i){const s=Math.cos,o=Math.sin,a=s(t/2),c=o(t/2),l=s((e+n)/2),u=o((e+n)/2),h=s((e-n)/2),f=o((e-n)/2),p=s((n-e)/2),m=o((n-e)/2);switch(i){case"XYX":r.set(a*u,c*h,c*f,a*l);break;case"YZY":r.set(c*f,a*u,c*h,a*l);break;case"ZXZ":r.set(c*h,c*f,a*u,a*l);break;case"XZX":r.set(a*u,c*m,c*p,a*l);break;case"YXY":r.set(c*p,a*u,c*m,a*l);break;case"ZYZ":r.set(c*m,c*p,a*u,a*l);break;default:Ue("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}d(aM,"setQuaternionFromProperEuler");function dn(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}d(dn,"denormalize");function st(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}d(st,"normalize");const Bn={DEG2RAD:zs,RAD2DEG:qr,generateUUID:Dn,clamp:je,euclideanModulo:$p,mapLinear:XS,inverseLerp:qS,lerp:Vo,damp:YS,pingpong:ZS,smoothstep:KS,smootherstep:JS,randInt:jS,randFloat:QS,randFloatSpread:eM,seededRandom:tM,degToRad:nM,radToDeg:iM,isPowerOfTwo:sM,ceilPowerOfTwo:rM,floorPowerOfTwo:oM,setQuaternionFromProperEuler:aM,normalize:st,denormalize:dn},Gu=class Gu{constructor(e=0,t=0){Gu.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(je(n,e,t))}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(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.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(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(je(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*n-o*i+e.x,this.y=s*i+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};d(Gu,"Vector2");let Ee=Gu;const om=class om{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,s,o,a){let c=n[i+0],l=n[i+1],u=n[i+2],h=n[i+3],f=s[o+0],p=s[o+1],m=s[o+2],y=s[o+3];if(h!==y||c!==f||l!==p||u!==m){let _=c*f+l*p+u*m+h*y;_<0&&(f=-f,p=-p,m=-m,y=-y,_=-_);let g=1-a;if(_<.9995){const v=Math.acos(_),M=Math.sin(v);g=Math.sin(g*v)/M,a=Math.sin(a*v)/M,c=c*g+f*a,l=l*g+p*a,u=u*g+m*a,h=h*g+y*a}else{c=c*g+f*a,l=l*g+p*a,u=u*g+m*a,h=h*g+y*a;const v=1/Math.sqrt(c*c+l*l+u*u+h*h);c*=v,l*=v,u*=v,h*=v}}e[t]=c,e[t+1]=l,e[t+2]=u,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,i,s,o){const a=n[i],c=n[i+1],l=n[i+2],u=n[i+3],h=s[o],f=s[o+1],p=s[o+2],m=s[o+3];return e[t]=a*m+u*h+c*p-l*f,e[t+1]=c*m+u*f+l*h-a*p,e[t+2]=l*m+u*p+a*f-c*h,e[t+3]=u*m-a*h-c*f-l*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,i=e._y,s=e._z,o=e._order,a=Math.cos,c=Math.sin,l=a(n/2),u=a(i/2),h=a(s/2),f=c(n/2),p=c(i/2),m=c(s/2);switch(o){case"XYZ":this._x=f*u*h+l*p*m,this._y=l*p*h-f*u*m,this._z=l*u*m+f*p*h,this._w=l*u*h-f*p*m;break;case"YXZ":this._x=f*u*h+l*p*m,this._y=l*p*h-f*u*m,this._z=l*u*m-f*p*h,this._w=l*u*h+f*p*m;break;case"ZXY":this._x=f*u*h-l*p*m,this._y=l*p*h+f*u*m,this._z=l*u*m+f*p*h,this._w=l*u*h-f*p*m;break;case"ZYX":this._x=f*u*h-l*p*m,this._y=l*p*h+f*u*m,this._z=l*u*m-f*p*h,this._w=l*u*h+f*p*m;break;case"YZX":this._x=f*u*h+l*p*m,this._y=l*p*h+f*u*m,this._z=l*u*m-f*p*h,this._w=l*u*h-f*p*m;break;case"XZY":this._x=f*u*h-l*p*m,this._y=l*p*h-f*u*m,this._z=l*u*m+f*p*h,this._w=l*u*h+f*p*m;break;default:Ue("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],s=t[8],o=t[1],a=t[5],c=t[9],l=t[2],u=t[6],h=t[10],f=n+a+h;if(f>0){const p=.5/Math.sqrt(f+1);this._w=.25/p,this._x=(u-c)*p,this._y=(s-l)*p,this._z=(o-i)*p}else if(n>a&&n>h){const p=2*Math.sqrt(1+n-a-h);this._w=(u-c)/p,this._x=.25*p,this._y=(i+o)/p,this._z=(s+l)/p}else if(a>h){const p=2*Math.sqrt(1+a-n-h);this._w=(s-l)/p,this._x=(i+o)/p,this._y=.25*p,this._z=(c+u)/p}else{const p=2*Math.sqrt(1+h-n-a);this._w=(o-i)/p,this._x=(s+l)/p,this._y=(c+u)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(je(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._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 e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,s=e._z,o=e._w,a=t._x,c=t._y,l=t._z,u=t._w;return this._x=n*u+o*a+i*l-s*c,this._y=i*u+o*c+s*a-n*l,this._z=s*u+o*l+n*c-i*a,this._w=o*u-n*a-i*c-s*l,this._onChangeCallback(),this}slerp(e,t){let n=e._x,i=e._y,s=e._z,o=e._w,a=this.dot(e);a<0&&(n=-n,i=-i,s=-s,o=-o,a=-a);let c=1-t;if(a<.9995){const l=Math.acos(a),u=Math.sin(l);c=Math.sin(c*l)/u,t=Math.sin(t*l)/u,this._x=this._x*c+n*t,this._y=this._y*c+i*t,this._z=this._z*c+s*t,this._w=this._w*c+o*t,this._onChangeCallback()}else this._x=this._x*c+n*t,this._y=this._y*c+i*t,this._z=this._z*c+s*t,this._w=this._w*c+o*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}};d(om,"Quaternion");let Mt=om;const Wu=class Wu{constructor(e=0,t=0,n=0){Wu.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(ry.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(ry.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*i,this.y=s[1]*t+s[4]*n+s[7]*i,this.z=s[2]*t+s[5]*n+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,s=e.elements,o=1/(s[3]*t+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*i+s[12])*o,this.y=(s[1]*t+s[5]*n+s[9]*i+s[13])*o,this.z=(s[2]*t+s[6]*n+s[10]*i+s[14])*o,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,s=e.x,o=e.y,a=e.z,c=e.w,l=2*(o*i-a*n),u=2*(a*t-s*i),h=2*(s*n-o*t);return this.x=t+c*l+o*h-a*u,this.y=n+c*u+a*l-s*h,this.z=i+c*h+s*u-o*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i,this.y=s[1]*t+s[5]*n+s[9]*i,this.z=s[2]*t+s[6]*n+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this.z=je(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this.z=je(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(je(n,e,t))}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(e){return this.x*e.x+this.y*e.y+this.z*e.z}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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,s=e.z,o=t.x,a=t.y,c=t.z;return this.x=i*c-s*a,this.y=s*o-n*c,this.z=n*a-i*o,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return kh.copy(this).projectOnVector(e),this.sub(kh)}reflect(e){return this.sub(kh.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(je(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};d(Wu,"Vector3");let U=Wu;const kh=new U,ry=new Mt,$u=class $u{constructor(e,t,n,i,s,o,a,c,l){$u.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,s,o,a,c,l)}set(e,t,n,i,s,o,a,c,l){const u=this.elements;return u[0]=e,u[1]=i,u[2]=a,u[3]=t,u[4]=s,u[5]=c,u[6]=n,u[7]=o,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,o=n[0],a=n[3],c=n[6],l=n[1],u=n[4],h=n[7],f=n[2],p=n[5],m=n[8],y=i[0],_=i[3],g=i[6],v=i[1],M=i[4],b=i[7],C=i[2],S=i[5],T=i[8];return s[0]=o*y+a*v+c*C,s[3]=o*_+a*M+c*S,s[6]=o*g+a*b+c*T,s[1]=l*y+u*v+h*C,s[4]=l*_+u*M+h*S,s[7]=l*g+u*b+h*T,s[2]=f*y+p*v+m*C,s[5]=f*_+p*M+m*S,s[8]=f*g+p*b+m*T,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8];return t*o*u-t*a*l-n*s*u+n*a*c+i*s*l-i*o*c}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],h=u*o-a*l,f=a*c-u*s,p=l*s-o*c,m=t*h+n*f+i*p;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/m;return e[0]=h*y,e[1]=(i*l-u*n)*y,e[2]=(a*n-i*o)*y,e[3]=f*y,e[4]=(u*t-i*c)*y,e[5]=(i*s-a*t)*y,e[6]=p*y,e[7]=(n*c-l*t)*y,e[8]=(o*t-n*s)*y,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,s,o,a){const c=Math.cos(s),l=Math.sin(s);return this.set(n*c,n*l,-n*(c*o+l*a)+o+e,-i*l,i*c,-i*(-l*o+c*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(Vh.makeScale(e,t)),this}rotate(e){return this.premultiply(Vh.makeRotation(-e)),this}translate(e,t){return this.premultiply(Vh.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}};d($u,"Matrix3");let nt=$u;const Vh=new nt,oy=new nt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),ay=new nt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function cM(){const r={enabled:!0,workingColorSpace:Xs,spaces:{},convert:d(function(i,s,o){return this.enabled===!1||s===o||!s||!o||(this.spaces[s].transfer===gt&&(i.r=Ci(i.r),i.g=Ci(i.g),i.b=Ci(i.b)),this.spaces[s].primaries!==this.spaces[o].primaries&&(i.applyMatrix3(this.spaces[s].toXYZ),i.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===gt&&(i.r=zr(i.r),i.g=zr(i.g),i.b=zr(i.b))),i},"convert"),workingToColorSpace:d(function(i,s){return this.convert(i,this.workingColorSpace,s)},"workingToColorSpace"),colorSpaceToWorking:d(function(i,s){return this.convert(i,s,this.workingColorSpace)},"colorSpaceToWorking"),getPrimaries:d(function(i){return this.spaces[i].primaries},"getPrimaries"),getTransfer:d(function(i){return i===Ai?jo:this.spaces[i].transfer},"getTransfer"),getToneMappingMode:d(function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},"getToneMappingMode"),getLuminanceCoefficients:d(function(i,s=this.workingColorSpace){return i.fromArray(this.spaces[s].luminanceCoefficients)},"getLuminanceCoefficients"),define:d(function(i){Object.assign(this.spaces,i)},"define"),_getMatrix:d(function(i,s,o){return i.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},"_getMatrix"),_getDrawingBufferColorSpace:d(function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},"_getDrawingBufferColorSpace"),_getUnpackColorSpace:d(function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},"_getUnpackColorSpace"),fromWorkingColorSpace:d(function(i,s){return na("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),r.workingToColorSpace(i,s)},"fromWorkingColorSpace"),toWorkingColorSpace:d(function(i,s){return na("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),r.colorSpaceToWorking(i,s)},"toWorkingColorSpace")},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return r.define({[Xs]:{primaries:e,whitePoint:n,transfer:jo,toXYZ:oy,fromXYZ:ay,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:un},outputColorSpaceConfig:{drawingBufferColorSpace:un}},[un]:{primaries:e,whitePoint:n,transfer:gt,toXYZ:oy,fromXYZ:ay,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:un}}}),r}d(cM,"createColorManagement");const lt=cM();function Ci(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}d(Ci,"SRGBToLinear");function zr(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}d(zr,"LinearToSRGB");let lr;const am=class am{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{lr===void 0&&(lr=ea("canvas")),lr.width=e.width,lr.height=e.height;const i=lr.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),n=lr}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=ea("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),s=i.data;for(let o=0;o<s.length;o++)s[o]=Ci(s[o]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(Ci(t[n]/255)*255):t[n]=Ci(t[n]);return{data:t,width:e.width,height:e.height}}else return Ue("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}};d(am,"ImageUtils");let Tl=am,lM=0;const cm=class cm{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:lM++}),this.uuid=Dn(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let o=0,a=i.length;o<a;o++)i[o].isDataTexture?s.push(Hh(i[o].image)):s.push(Hh(i[o]))}else s=Hh(i);n.url=s}return t||(e.images[this.uuid]=n),n}};d(cm,"Source");let di=cm;function Hh(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?Tl.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(Ue("Texture: Unable to serialize Texture."),{})}d(Hh,"serializeImage");let uM=0;const Gh=new U,Ur=class Ur extends Vn{constructor(e=Ur.DEFAULT_IMAGE,t=Ur.DEFAULT_MAPPING,n=Mn,i=Mn,s=wt,o=fi,a=mn,c=Sn,l=Ur.DEFAULT_ANISOTROPY,u=Ai){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:uM++}),this.uuid=Dn(),this.name="",this.source=new di(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=s,this.minFilter=o,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=c,this.offset=new Ee(0,0),this.repeat=new Ee(1,1),this.center=new Ee(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new nt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(Gh).x}get height(){return this.source.getSize(Gh).y}get depth(){return this.source.getSize(Gh).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const n=e[t];if(n===void 0){Ue(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){Ue(`Texture.setValues(): property '${t}' does not exist.`);continue}i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==wh)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Yo:e.x=e.x-Math.floor(e.x);break;case Mn:e.x=e.x<0?0:1;break;case Zo:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Yo:e.y=e.y-Math.floor(e.y);break;case Mn:e.y=e.y<0?0:1;break;case Zo:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};d(Ur,"Texture");let Ot=Ur;Ot.DEFAULT_IMAGE=null;Ot.DEFAULT_MAPPING=wh;Ot.DEFAULT_ANISOTROPY=1;const Xu=class Xu{constructor(e=0,t=0,n=0,i=1){Xu.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*i+o[12]*s,this.y=o[1]*t+o[5]*n+o[9]*i+o[13]*s,this.z=o[2]*t+o[6]*n+o[10]*i+o[14]*s,this.w=o[3]*t+o[7]*n+o[11]*i+o[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,s;const c=e.elements,l=c[0],u=c[4],h=c[8],f=c[1],p=c[5],m=c[9],y=c[2],_=c[6],g=c[10];if(Math.abs(u-f)<.01&&Math.abs(h-y)<.01&&Math.abs(m-_)<.01){if(Math.abs(u+f)<.1&&Math.abs(h+y)<.1&&Math.abs(m+_)<.1&&Math.abs(l+p+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const M=(l+1)/2,b=(p+1)/2,C=(g+1)/2,S=(u+f)/4,T=(h+y)/4,x=(m+_)/4;return M>b&&M>C?M<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(M),i=S/n,s=T/n):b>C?b<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(b),n=S/i,s=x/i):C<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(C),n=T/s,i=x/s),this.set(n,i,s,t),this}let v=Math.sqrt((_-m)*(_-m)+(h-y)*(h-y)+(f-u)*(f-u));return Math.abs(v)<.001&&(v=1),this.x=(_-m)/v,this.y=(h-y)/v,this.z=(f-u)/v,this.w=Math.acos((l+p+g-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this.z=je(this.z,e.z,t.z),this.w=je(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this.z=je(this.z,e,t),this.w=je(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(je(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.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)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};d(Xu,"Vector4");let pt=Xu;const lm=class lm extends Vn{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:wt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new pt(0,0,e,t),this.scissorTest=!1,this.viewport=new pt(0,0,e,t),this.textures=[];const i={width:e,height:t,depth:n.depth},s=new Ot(i),o=n.count;for(let a=0;a<o;a++)this.textures[a]=s.clone(),this.textures[a].isRenderTargetTexture=!0,this.textures[a].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){const t={minFilter:wt,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,s=this.textures.length;i<s;i++)this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const i=Object.assign({},e.textures[t].image);this.textures[t].source=new di(i)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}};d(lm,"RenderTarget");let ia=lm;const um=class um extends ia{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}};d(um,"WebGLRenderTarget");let _n=um;const hm=class hm extends Ot{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Nt,this.minFilter=Nt,this.wrapR=Mn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}};d(hm,"DataArrayTexture");let Yr=hm;const fm=class fm extends _n{constructor(e=1,t=1,n=1,i={}){super(e,t,i),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new Yr(null,e,t,n),this._setTextureOptions(i),this.texture.isRenderTargetTexture=!0}};d(fm,"WebGLArrayRenderTarget");let Kf=fm;const dm=class dm extends Ot{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Nt,this.minFilter=Nt,this.wrapR=Mn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};d(dm,"Data3DTexture");let Zr=dm;const pm=class pm extends _n{constructor(e=1,t=1,n=1,i={}){super(e,t,i),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new Zr(null,e,t,n),this._setTextureOptions(i),this.texture.isRenderTargetTexture=!0}};d(pm,"WebGL3DRenderTarget");let Jf=pm;const Xo=class Xo{constructor(e,t,n,i,s,o,a,c,l,u,h,f,p,m,y,_){Xo.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,i,s,o,a,c,l,u,h,f,p,m,y,_)}set(e,t,n,i,s,o,a,c,l,u,h,f,p,m,y,_){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=s,g[5]=o,g[9]=a,g[13]=c,g[2]=l,g[6]=u,g[10]=h,g[14]=f,g[3]=p,g[7]=m,g[11]=y,g[15]=_,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 Xo().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinant()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();const t=this.elements,n=e.elements,i=1/ur.setFromMatrixColumn(e,0).length(),s=1/ur.setFromMatrixColumn(e,1).length(),o=1/ur.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*o,t[9]=n[9]*o,t[10]=n[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,s=e.z,o=Math.cos(n),a=Math.sin(n),c=Math.cos(i),l=Math.sin(i),u=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){const f=o*u,p=o*h,m=a*u,y=a*h;t[0]=c*u,t[4]=-c*h,t[8]=l,t[1]=p+m*l,t[5]=f-y*l,t[9]=-a*c,t[2]=y-f*l,t[6]=m+p*l,t[10]=o*c}else if(e.order==="YXZ"){const f=c*u,p=c*h,m=l*u,y=l*h;t[0]=f+y*a,t[4]=m*a-p,t[8]=o*l,t[1]=o*h,t[5]=o*u,t[9]=-a,t[2]=p*a-m,t[6]=y+f*a,t[10]=o*c}else if(e.order==="ZXY"){const f=c*u,p=c*h,m=l*u,y=l*h;t[0]=f-y*a,t[4]=-o*h,t[8]=m+p*a,t[1]=p+m*a,t[5]=o*u,t[9]=y-f*a,t[2]=-o*l,t[6]=a,t[10]=o*c}else if(e.order==="ZYX"){const f=o*u,p=o*h,m=a*u,y=a*h;t[0]=c*u,t[4]=m*l-p,t[8]=f*l+y,t[1]=c*h,t[5]=y*l+f,t[9]=p*l-m,t[2]=-l,t[6]=a*c,t[10]=o*c}else if(e.order==="YZX"){const f=o*c,p=o*l,m=a*c,y=a*l;t[0]=c*u,t[4]=y-f*h,t[8]=m*h+p,t[1]=h,t[5]=o*u,t[9]=-a*u,t[2]=-l*u,t[6]=p*h+m,t[10]=f-y*h}else if(e.order==="XZY"){const f=o*c,p=o*l,m=a*c,y=a*l;t[0]=c*u,t[4]=-h,t[8]=l*u,t[1]=f*h+y,t[5]=o*u,t[9]=p*h-m,t[2]=m*h-p,t[6]=a*u,t[10]=y*h+f}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(hM,e,fM)}lookAt(e,t,n){const i=this.elements;return Cn.subVectors(e,t),Cn.lengthSq()===0&&(Cn.z=1),Cn.normalize(),zi.crossVectors(n,Cn),zi.lengthSq()===0&&(Math.abs(n.z)===1?Cn.x+=1e-4:Cn.z+=1e-4,Cn.normalize(),zi.crossVectors(n,Cn)),zi.normalize(),Va.crossVectors(Cn,zi),i[0]=zi.x,i[4]=Va.x,i[8]=Cn.x,i[1]=zi.y,i[5]=Va.y,i[9]=Cn.y,i[2]=zi.z,i[6]=Va.z,i[10]=Cn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,o=n[0],a=n[4],c=n[8],l=n[12],u=n[1],h=n[5],f=n[9],p=n[13],m=n[2],y=n[6],_=n[10],g=n[14],v=n[3],M=n[7],b=n[11],C=n[15],S=i[0],T=i[4],x=i[8],E=i[12],w=i[1],A=i[5],R=i[9],P=i[13],I=i[2],N=i[6],D=i[10],L=i[14],H=i[3],X=i[7],O=i[11],W=i[15];return s[0]=o*S+a*w+c*I+l*H,s[4]=o*T+a*A+c*N+l*X,s[8]=o*x+a*R+c*D+l*O,s[12]=o*E+a*P+c*L+l*W,s[1]=u*S+h*w+f*I+p*H,s[5]=u*T+h*A+f*N+p*X,s[9]=u*x+h*R+f*D+p*O,s[13]=u*E+h*P+f*L+p*W,s[2]=m*S+y*w+_*I+g*H,s[6]=m*T+y*A+_*N+g*X,s[10]=m*x+y*R+_*D+g*O,s[14]=m*E+y*P+_*L+g*W,s[3]=v*S+M*w+b*I+C*H,s[7]=v*T+M*A+b*N+C*X,s[11]=v*x+M*R+b*D+C*O,s[15]=v*E+M*P+b*L+C*W,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],s=e[12],o=e[1],a=e[5],c=e[9],l=e[13],u=e[2],h=e[6],f=e[10],p=e[14],m=e[3],y=e[7],_=e[11],g=e[15],v=c*p-l*f,M=a*p-l*h,b=a*f-c*h,C=o*p-l*u,S=o*f-c*u,T=o*h-a*u;return t*(y*v-_*M+g*b)-n*(m*v-_*C+g*S)+i*(m*M-y*C+g*T)-s*(m*b-y*S+_*T)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],h=e[9],f=e[10],p=e[11],m=e[12],y=e[13],_=e[14],g=e[15],v=t*a-n*o,M=t*c-i*o,b=t*l-s*o,C=n*c-i*a,S=n*l-s*a,T=i*l-s*c,x=u*y-h*m,E=u*_-f*m,w=u*g-p*m,A=h*_-f*y,R=h*g-p*y,P=f*g-p*_,I=v*P-M*R+b*A+C*w-S*E+T*x;if(I===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const N=1/I;return e[0]=(a*P-c*R+l*A)*N,e[1]=(i*R-n*P-s*A)*N,e[2]=(y*T-_*S+g*C)*N,e[3]=(f*S-h*T-p*C)*N,e[4]=(c*w-o*P-l*E)*N,e[5]=(t*P-i*w+s*E)*N,e[6]=(_*b-m*T-g*M)*N,e[7]=(u*T-f*b+p*M)*N,e[8]=(o*R-a*w+l*x)*N,e[9]=(n*w-t*R-s*x)*N,e[10]=(m*S-y*b+g*v)*N,e[11]=(h*b-u*S-p*v)*N,e[12]=(a*E-o*A-c*x)*N,e[13]=(t*A-n*E+i*x)*N,e[14]=(y*M-m*C-_*v)*N,e[15]=(u*C-h*M+f*v)*N,this}scale(e){const t=this.elements,n=e.x,i=e.y,s=e.z;return t[0]*=n,t[4]*=i,t[8]*=s,t[1]*=n,t[5]*=i,t[9]*=s,t[2]*=n,t[6]*=i,t[10]*=s,t[3]*=n,t[7]*=i,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),s=1-n,o=e.x,a=e.y,c=e.z,l=s*o,u=s*a;return this.set(l*o+n,l*a-i*c,l*c+i*a,0,l*a+i*c,u*a+n,u*c-i*o,0,l*c-i*a,u*c+i*o,s*c*c+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,s,o){return this.set(1,n,s,0,e,1,o,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,s=t._x,o=t._y,a=t._z,c=t._w,l=s+s,u=o+o,h=a+a,f=s*l,p=s*u,m=s*h,y=o*u,_=o*h,g=a*h,v=c*l,M=c*u,b=c*h,C=n.x,S=n.y,T=n.z;return i[0]=(1-(y+g))*C,i[1]=(p+b)*C,i[2]=(m-M)*C,i[3]=0,i[4]=(p-b)*S,i[5]=(1-(f+g))*S,i[6]=(_+v)*S,i[7]=0,i[8]=(m+M)*T,i[9]=(_-v)*T,i[10]=(1-(f+y))*T,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];const s=this.determinant();if(s===0)return n.set(1,1,1),t.identity(),this;let o=ur.set(i[0],i[1],i[2]).length();const a=ur.set(i[4],i[5],i[6]).length(),c=ur.set(i[8],i[9],i[10]).length();s<0&&(o=-o),Xn.copy(this);const l=1/o,u=1/a,h=1/c;return Xn.elements[0]*=l,Xn.elements[1]*=l,Xn.elements[2]*=l,Xn.elements[4]*=u,Xn.elements[5]*=u,Xn.elements[6]*=u,Xn.elements[8]*=h,Xn.elements[9]*=h,Xn.elements[10]*=h,t.setFromRotationMatrix(Xn),n.x=o,n.y=a,n.z=c,this}makePerspective(e,t,n,i,s,o,a=Rn,c=!1){const l=this.elements,u=2*s/(t-e),h=2*s/(n-i),f=(t+e)/(t-e),p=(n+i)/(n-i);let m,y;if(c)m=s/(o-s),y=o*s/(o-s);else if(a===Rn)m=-(o+s)/(o-s),y=-2*o*s/(o-s);else if(a===qs)m=-o/(o-s),y=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return l[0]=u,l[4]=0,l[8]=f,l[12]=0,l[1]=0,l[5]=h,l[9]=p,l[13]=0,l[2]=0,l[6]=0,l[10]=m,l[14]=y,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,i,s,o,a=Rn,c=!1){const l=this.elements,u=2/(t-e),h=2/(n-i),f=-(t+e)/(t-e),p=-(n+i)/(n-i);let m,y;if(c)m=1/(o-s),y=o/(o-s);else if(a===Rn)m=-2/(o-s),y=-(o+s)/(o-s);else if(a===qs)m=-1/(o-s),y=-s/(o-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return l[0]=u,l[4]=0,l[8]=0,l[12]=f,l[1]=0,l[5]=h,l[9]=0,l[13]=p,l[2]=0,l[6]=0,l[10]=m,l[14]=y,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}};d(Xo,"Matrix4");let Je=Xo;const ur=new U,Xn=new Je,hM=new U(0,0,0),fM=new U(1,1,1),zi=new U,Va=new U,Cn=new U,cy=new Je,ly=new Mt,qu=class qu{constructor(e=0,t=0,n=0,i=qu.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,s=i[0],o=i[4],a=i[8],c=i[1],l=i[5],u=i[9],h=i[2],f=i[6],p=i[10];switch(t){case"XYZ":this._y=Math.asin(je(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,p),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(f,l),this._z=0);break;case"YXZ":this._x=Math.asin(-je(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,p),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(je(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-h,p),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-je(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(f,p),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(je(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(a,p));break;case"XZY":this._z=Math.asin(-je(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(f,l),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-u,p),this._y=0);break;default:Ue("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return cy.makeRotationFromQuaternion(e),this.setFromRotationMatrix(cy,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return ly.setFromEuler(this),this.setFromQuaternion(ly,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};d(qu,"Euler");let rn=qu;rn.DEFAULT_ORDER="XYZ";const mm=class mm{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}};d(mm,"Layers");let Kr=mm,dM=0;const uy=new U,hr=new Mt,vi=new Je,Ha=new U,po=new U,pM=new U,mM=new Mt,hy=new U(1,0,0),fy=new U(0,1,0),dy=new U(0,0,1),py={type:"added"},gM={type:"removed"},fr={type:"childadded",child:null},Wh={type:"childremoved",child:null},Br=class Br extends Vn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:dM++}),this.uuid=Dn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Br.DEFAULT_UP.clone();const e=new U,t=new rn,n=new Mt,i=new U(1,1,1);function s(){n.setFromEuler(t,!1)}d(s,"onRotationChange");function o(){t.setFromQuaternion(n,void 0,!1)}d(o,"onQuaternionChange"),t._onChange(s),n._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Je},normalMatrix:{value:new nt}}),this.matrix=new Je,this.matrixWorld=new Je,this.matrixAutoUpdate=Br.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Br.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Kr,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return hr.setFromAxisAngle(e,t),this.quaternion.multiply(hr),this}rotateOnWorldAxis(e,t){return hr.setFromAxisAngle(e,t),this.quaternion.premultiply(hr),this}rotateX(e){return this.rotateOnAxis(hy,e)}rotateY(e){return this.rotateOnAxis(fy,e)}rotateZ(e){return this.rotateOnAxis(dy,e)}translateOnAxis(e,t){return uy.copy(e).applyQuaternion(this.quaternion),this.position.add(uy.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(hy,e)}translateY(e){return this.translateOnAxis(fy,e)}translateZ(e){return this.translateOnAxis(dy,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(vi.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Ha.copy(e):Ha.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),po.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?vi.lookAt(po,Ha,this.up):vi.lookAt(Ha,po,this.up),this.quaternion.setFromRotationMatrix(vi),i&&(vi.extractRotation(i.matrixWorld),hr.setFromRotationMatrix(vi),this.quaternion.premultiply(hr.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(Ye("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(py),fr.child=e,this.dispatchEvent(fr),fr.child=null):Ye("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(gM),Wh.child=e,this.dispatchEvent(Wh),Wh.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),vi.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),vi.multiply(e.parent.matrixWorld)),e.applyMatrix4(vi),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(py),fr.child=e,this.dispatchEvent(fr),fr.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){const o=this.children[n].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(po,e,pM),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(po,mM,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const e=this.pivot;if(e!==null){const t=e.x,n=e.y,i=e.z,s=this.matrix.elements;s[12]+=t-s[0]*t-s[4]*n-s[8]*i,s[13]+=n-s[1]*t-s[5]*n-s[9]*i,s[14]+=i-s[2]*t-s[6]*n-s[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),this.static!==!1&&(i.static=this.static),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null&&(i.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(i.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(a=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(a=>({...a})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function s(a,c){return a[c.uuid]===void 0&&(a[c.uuid]=c.toJSON(e)),c.uuid}if(d(s,"serialize"),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const c=a.shapes;if(Array.isArray(c))for(let l=0,u=c.length;l<u;l++){const h=c[l];s(e.shapes,h)}else s(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let c=0,l=this.material.length;c<l;c++)a.push(s(e.materials,this.material[c]));i.material=a}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){const c=this.animations[a];i.animations.push(s(e.animations,c))}}if(t){const a=o(e.geometries),c=o(e.materials),l=o(e.textures),u=o(e.images),h=o(e.shapes),f=o(e.skeletons),p=o(e.animations),m=o(e.nodes);a.length>0&&(n.geometries=a),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),u.length>0&&(n.images=u),h.length>0&&(n.shapes=h),f.length>0&&(n.skeletons=f),p.length>0&&(n.animations=p),m.length>0&&(n.nodes=m)}return n.object=i,n;function o(a){const c=[];for(const l in a){const u=a[l];delete u.metadata,c.push(u)}return c}d(o,"extractFromCache")}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),e.pivot!==null&&(this.pivot=e.pivot.clone()),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const i=e.children[n];this.add(i.clone())}return this}};d(Br,"Object3D");let ft=Br;ft.DEFAULT_UP=new U(0,1,0);ft.DEFAULT_MATRIX_AUTO_UPDATE=!0;ft.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const gm=class gm extends ft{constructor(){super(),this.isGroup=!0,this.type="Group"}};d(gm,"Group");let sn=gm;const _M={type:"move"},_m=class _m{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new sn,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new sn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new U,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new U),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new sn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new U,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new U),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let i=null,s=null,o=null;const a=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){o=!0;for(const y of e.hand.values()){const _=t.getJointPose(y,n),g=this._getHandJoint(l,y);_!==null&&(g.matrix.fromArray(_.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.matrixWorldNeedsUpdate=!0,g.jointRadius=_.radius),g.visible=_!==null}const u=l.joints["index-finger-tip"],h=l.joints["thumb-tip"],f=u.position.distanceTo(h.position),p=.02,m=.005;l.inputState.pinching&&f>p+m?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&f<=p-m&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));a!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&s!==null&&(i=s),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(_M)))}return a!==null&&(a.visible=i!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new sn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}};d(_m,"WebXRController");let kr=_m;const Yv={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},ki={h:0,s:0,l:0},Ga={h:0,s:0,l:0};function $h(r,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?r+(e-r)*6*t:t<1/2?e:t<2/3?r+(e-r)*6*(2/3-t):r}d($h,"hue2rgb");const ym=class ym{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=un){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,lt.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=lt.workingColorSpace){return this.r=e,this.g=t,this.b=n,lt.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=lt.workingColorSpace){if(e=$p(e,1),t=je(t,0,1),n=je(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,o=2*n-s;this.r=$h(o,s,e+1/3),this.g=$h(o,s,e),this.b=$h(o,s,e-1/3)}return lt.colorSpaceToWorking(this,i),this}setStyle(e,t=un){function n(s){s!==void 0&&parseFloat(s)<1&&Ue("Color: Alpha component of "+e+" will be ignored.")}d(n,"handleAlpha");let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:Ue("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(s,16),t);Ue("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=un){const n=Yv[e.toLowerCase()];return n!==void 0?this.setHex(n,t):Ue("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Ci(e.r),this.g=Ci(e.g),this.b=Ci(e.b),this}copyLinearToSRGB(e){return this.r=zr(e.r),this.g=zr(e.g),this.b=zr(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=un){return lt.workingToColorSpace(en.copy(this),e),Math.round(je(en.r*255,0,255))*65536+Math.round(je(en.g*255,0,255))*256+Math.round(je(en.b*255,0,255))}getHexString(e=un){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=lt.workingColorSpace){lt.workingToColorSpace(en.copy(this),t);const n=en.r,i=en.g,s=en.b,o=Math.max(n,i,s),a=Math.min(n,i,s);let c,l;const u=(a+o)/2;if(a===o)c=0,l=0;else{const h=o-a;switch(l=u<=.5?h/(o+a):h/(2-o-a),o){case n:c=(i-s)/h+(i<s?6:0);break;case i:c=(s-n)/h+2;break;case s:c=(n-i)/h+4;break}c/=6}return e.h=c,e.s=l,e.l=u,e}getRGB(e,t=lt.workingColorSpace){return lt.workingToColorSpace(en.copy(this),t),e.r=en.r,e.g=en.g,e.b=en.b,e}getStyle(e=un){lt.workingToColorSpace(en.copy(this),e);const t=en.r,n=en.g,i=en.b;return e!==un?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(ki),this.setHSL(ki.h+e,ki.s+t,ki.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(ki),e.getHSL(Ga);const n=Vo(ki.h,Ga.h,t),i=Vo(ki.s,Ga.s,t),s=Vo(ki.l,Ga.l,t);return this.setHSL(n,i,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,i=this.b,s=e.elements;return this.r=s[0]*t+s[3]*n+s[6]*i,this.g=s[1]*t+s[4]*n+s[7]*i,this.b=s[2]*t+s[5]*n+s[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};d(ym,"Color");let ke=ym;const en=new ke;ke.NAMES=Yv;const Yu=class Yu{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new ke(e),this.density=t}clone(){return new Yu(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}};d(Yu,"FogExp2");let Cl=Yu;const Zu=class Zu{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new ke(e),this.near=t,this.far=n}clone(){return new Zu(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}};d(Zu,"Fog");let Il=Zu;const xm=class xm extends ft{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new rn,this.environmentIntensity=1,this.environmentRotation=new rn,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}};d(xm,"Scene");let Rl=xm;const qn=new U,bi=new U,Xh=new U,Si=new U,dr=new U,pr=new U,my=new U,qh=new U,Yh=new U,Zh=new U,Kh=new pt,Jh=new pt,jh=new pt,Zi=class Zi{constructor(e=new U,t=new U,n=new U){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),qn.subVectors(e,t),i.cross(qn);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,t,n,i,s){qn.subVectors(i,t),bi.subVectors(n,t),Xh.subVectors(e,t);const o=qn.dot(qn),a=qn.dot(bi),c=qn.dot(Xh),l=bi.dot(bi),u=bi.dot(Xh),h=o*l-a*a;if(h===0)return s.set(0,0,0),null;const f=1/h,p=(l*c-a*u)*f,m=(o*u-a*c)*f;return s.set(1-p-m,m,p)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,Si)===null?!1:Si.x>=0&&Si.y>=0&&Si.x+Si.y<=1}static getInterpolation(e,t,n,i,s,o,a,c){return this.getBarycoord(e,t,n,i,Si)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(s,Si.x),c.addScaledVector(o,Si.y),c.addScaledVector(a,Si.z),c)}static getInterpolatedAttribute(e,t,n,i,s,o){return Kh.setScalar(0),Jh.setScalar(0),jh.setScalar(0),Kh.fromBufferAttribute(e,t),Jh.fromBufferAttribute(e,n),jh.fromBufferAttribute(e,i),o.setScalar(0),o.addScaledVector(Kh,s.x),o.addScaledVector(Jh,s.y),o.addScaledVector(jh,s.z),o}static isFrontFacing(e,t,n,i){return qn.subVectors(n,t),bi.subVectors(e,t),qn.cross(bi).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return qn.subVectors(this.c,this.b),bi.subVectors(this.a,this.b),qn.cross(bi).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Zi.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Zi.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,s){return Zi.getInterpolation(e,this.a,this.b,this.c,t,n,i,s)}containsPoint(e){return Zi.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Zi.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,s=this.c;let o,a;dr.subVectors(i,n),pr.subVectors(s,n),qh.subVectors(e,n);const c=dr.dot(qh),l=pr.dot(qh);if(c<=0&&l<=0)return t.copy(n);Yh.subVectors(e,i);const u=dr.dot(Yh),h=pr.dot(Yh);if(u>=0&&h<=u)return t.copy(i);const f=c*h-u*l;if(f<=0&&c>=0&&u<=0)return o=c/(c-u),t.copy(n).addScaledVector(dr,o);Zh.subVectors(e,s);const p=dr.dot(Zh),m=pr.dot(Zh);if(m>=0&&p<=m)return t.copy(s);const y=p*l-c*m;if(y<=0&&l>=0&&m<=0)return a=l/(l-m),t.copy(n).addScaledVector(pr,a);const _=u*m-p*h;if(_<=0&&h-u>=0&&p-m>=0)return my.subVectors(s,i),a=(h-u)/(h-u+(p-m)),t.copy(i).addScaledVector(my,a);const g=1/(_+y+f);return o=y*g,a=f*g,t.copy(n).addScaledVector(dr,o).addScaledVector(pr,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};d(Zi,"Triangle");let ui=Zi;const vm=class vm{constructor(e=new U(1/0,1/0,1/0),t=new U(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Yn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Yn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Yn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.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(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0){const s=n.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let o=0,a=s.count;o<a;o++)e.isMesh===!0?e.getVertexPosition(o,Yn):Yn.fromBufferAttribute(s,o),Yn.applyMatrix4(e.matrixWorld),this.expandByPoint(Yn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Wa.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Wa.copy(n.boundingBox)),Wa.applyMatrix4(e.matrixWorld),this.union(Wa)}const i=e.children;for(let s=0,o=i.length;s<o;s++)this.expandByObject(i[s],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Yn),Yn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(mo),$a.subVectors(this.max,mo),mr.subVectors(e.a,mo),gr.subVectors(e.b,mo),_r.subVectors(e.c,mo),Vi.subVectors(gr,mr),Hi.subVectors(_r,gr),gs.subVectors(mr,_r);let t=[0,-Vi.z,Vi.y,0,-Hi.z,Hi.y,0,-gs.z,gs.y,Vi.z,0,-Vi.x,Hi.z,0,-Hi.x,gs.z,0,-gs.x,-Vi.y,Vi.x,0,-Hi.y,Hi.x,0,-gs.y,gs.x,0];return!Qh(t,mr,gr,_r,$a)||(t=[1,0,0,0,1,0,0,0,1],!Qh(t,mr,gr,_r,$a))?!1:(Xa.crossVectors(Vi,Hi),t=[Xa.x,Xa.y,Xa.z],Qh(t,mr,gr,_r,$a))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Yn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Yn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Mi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Mi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Mi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Mi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Mi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Mi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Mi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Mi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Mi),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}};d(vm,"Box3");let Dt=vm;const Mi=[new U,new U,new U,new U,new U,new U,new U,new U],Yn=new U,Wa=new Dt,mr=new U,gr=new U,_r=new U,Vi=new U,Hi=new U,gs=new U,mo=new U,$a=new U,Xa=new U,_s=new U;function Qh(r,e,t,n,i){for(let s=0,o=r.length-3;s<=o;s+=3){_s.fromArray(r,s);const a=i.x*Math.abs(_s.x)+i.y*Math.abs(_s.y)+i.z*Math.abs(_s.z),c=e.dot(_s),l=t.dot(_s),u=n.dot(_s);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}d(Qh,"satForAxes");const Ti=yM();function yM(){const r=new ArrayBuffer(4),e=new Float32Array(r),t=new Uint32Array(r),n=new Uint32Array(512),i=new Uint32Array(512);for(let c=0;c<256;++c){const l=c-127;l<-27?(n[c]=0,n[c|256]=32768,i[c]=24,i[c|256]=24):l<-14?(n[c]=1024>>-l-14,n[c|256]=1024>>-l-14|32768,i[c]=-l-1,i[c|256]=-l-1):l<=15?(n[c]=l+15<<10,n[c|256]=l+15<<10|32768,i[c]=13,i[c|256]=13):l<128?(n[c]=31744,n[c|256]=64512,i[c]=24,i[c|256]=24):(n[c]=31744,n[c|256]=64512,i[c]=13,i[c|256]=13)}const s=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,u=0;for(;(l&8388608)===0;)l<<=1,u-=8388608;l&=-8388609,u+=947912704,s[c]=l|u}for(let c=1024;c<2048;++c)s[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)o[c]=c<<23;o[31]=1199570944,o[32]=2147483648;for(let c=33;c<63;++c)o[c]=2147483648+(c-32<<23);o[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(a[c]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:i,mantissaTable:s,exponentTable:o,offsetTable:a}}d(yM,"_generateTables");function vn(r){Math.abs(r)>65504&&Ue("DataUtils.toHalfFloat(): Value out of range."),r=je(r,-65504,65504),Ti.floatView[0]=r;const e=Ti.uint32View[0],t=e>>23&511;return Ti.baseTable[t]+((e&8388607)>>Ti.shiftTable[t])}d(vn,"toHalfFloat");function Io(r){const e=r>>10;return Ti.uint32View[0]=Ti.mantissaTable[Ti.offsetTable[e]+(r&1023)]+Ti.exponentTable[e],Ti.floatView[0]}d(Io,"fromHalfFloat");const bm=class bm{static toHalfFloat(e){return vn(e)}static fromHalfFloat(e){return Io(e)}};d(bm,"DataUtils");let jf=bm;const Lt=new U,qa=new Ee;let xM=0;const Sm=class Sm{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:xM++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Qo,this.updateRanges=[],this.gpuType=pn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)qa.fromBufferAttribute(this,t),qa.applyMatrix3(e),this.setXY(t,qa.x,qa.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Lt.fromBufferAttribute(this,t),Lt.applyMatrix3(e),this.setXYZ(t,Lt.x,Lt.y,Lt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Lt.fromBufferAttribute(this,t),Lt.applyMatrix4(e),this.setXYZ(t,Lt.x,Lt.y,Lt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Lt.fromBufferAttribute(this,t),Lt.applyNormalMatrix(e),this.setXYZ(t,Lt.x,Lt.y,Lt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Lt.fromBufferAttribute(this,t),Lt.transformDirection(e),this.setXYZ(t,Lt.x,Lt.y,Lt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=dn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=st(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=dn(t,this.array)),t}setX(e,t){return this.normalized&&(t=st(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=dn(t,this.array)),t}setY(e,t){return this.normalized&&(t=st(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=dn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=st(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=dn(t,this.array)),t}setW(e,t){return this.normalized&&(t=st(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=st(t,this.array),n=st(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=st(t,this.array),n=st(n,this.array),i=st(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,s){return e*=this.itemSize,this.normalized&&(t=st(t,this.array),n=st(n,this.array),i=st(i,this.array),s=st(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Qo&&(e.usage=this.usage),e}};d(Sm,"BufferAttribute");let mt=Sm;const Mm=class Mm extends mt{constructor(e,t,n){super(new Int8Array(e),t,n)}};d(Mm,"Int8BufferAttribute");let Qf=Mm;const wm=class wm extends mt{constructor(e,t,n){super(new Uint8Array(e),t,n)}};d(wm,"Uint8BufferAttribute");let ed=wm;const Em=class Em extends mt{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}};d(Em,"Uint8ClampedBufferAttribute");let td=Em;const Am=class Am extends mt{constructor(e,t,n){super(new Int16Array(e),t,n)}};d(Am,"Int16BufferAttribute");let nd=Am;const Tm=class Tm extends mt{constructor(e,t,n){super(new Uint16Array(e),t,n)}};d(Tm,"Uint16BufferAttribute");let sa=Tm;const Cm=class Cm extends mt{constructor(e,t,n){super(new Int32Array(e),t,n)}};d(Cm,"Int32BufferAttribute");let id=Cm;const Im=class Im extends mt{constructor(e,t,n){super(new Uint32Array(e),t,n)}};d(Im,"Uint32BufferAttribute");let ra=Im;const Rm=class Rm extends mt{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=Io(this.array[e*this.itemSize]);return this.normalized&&(t=dn(t,this.array)),t}setX(e,t){return this.normalized&&(t=st(t,this.array)),this.array[e*this.itemSize]=vn(t),this}getY(e){let t=Io(this.array[e*this.itemSize+1]);return this.normalized&&(t=dn(t,this.array)),t}setY(e,t){return this.normalized&&(t=st(t,this.array)),this.array[e*this.itemSize+1]=vn(t),this}getZ(e){let t=Io(this.array[e*this.itemSize+2]);return this.normalized&&(t=dn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=st(t,this.array)),this.array[e*this.itemSize+2]=vn(t),this}getW(e){let t=Io(this.array[e*this.itemSize+3]);return this.normalized&&(t=dn(t,this.array)),t}setW(e,t){return this.normalized&&(t=st(t,this.array)),this.array[e*this.itemSize+3]=vn(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=st(t,this.array),n=st(n,this.array)),this.array[e+0]=vn(t),this.array[e+1]=vn(n),this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=st(t,this.array),n=st(n,this.array),i=st(i,this.array)),this.array[e+0]=vn(t),this.array[e+1]=vn(n),this.array[e+2]=vn(i),this}setXYZW(e,t,n,i,s){return e*=this.itemSize,this.normalized&&(t=st(t,this.array),n=st(n,this.array),i=st(i,this.array),s=st(s,this.array)),this.array[e+0]=vn(t),this.array[e+1]=vn(n),this.array[e+2]=vn(i),this.array[e+3]=vn(s),this}};d(Rm,"Float16BufferAttribute");let sd=Rm;const Pm=class Pm extends mt{constructor(e,t,n){super(new Float32Array(e),t,n)}};d(Pm,"Float32BufferAttribute");let Ve=Pm;const vM=new Dt,go=new U,ef=new U,Nm=class Nm{constructor(e=new U,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):vM.setFromPoints(e).getCenter(n);let i=0;for(let s=0,o=e.length;s<o;s++)i=Math.max(i,n.distanceToSquared(e[s]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;go.subVectors(e,this.center);const t=go.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(go,i/n),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(ef.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(go.copy(e.center).add(ef)),this.expandByPoint(go.copy(e.center).sub(ef))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}};d(Nm,"Sphere");let Ft=Nm,bM=0;const On=new Je,tf=new ft,yr=new U,In=new Dt,_o=new Dt,Gt=new U,Ku=class Ku extends Vn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:bM++}),this.uuid=Dn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(kS(e)?ra:sa)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const s=new nt().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return On.makeRotationFromQuaternion(e),this.applyMatrix4(On),this}rotateX(e){return On.makeRotationX(e),this.applyMatrix4(On),this}rotateY(e){return On.makeRotationY(e),this.applyMatrix4(On),this}rotateZ(e){return On.makeRotationZ(e),this.applyMatrix4(On),this}translate(e,t,n){return On.makeTranslation(e,t,n),this.applyMatrix4(On),this}scale(e,t,n){return On.makeScale(e,t,n),this.applyMatrix4(On),this}lookAt(e){return tf.lookAt(e),tf.updateMatrix(),this.applyMatrix4(tf.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(yr).negate(),this.translate(yr.x,yr.y,yr.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let i=0,s=e.length;i<s;i++){const o=e[i];n.push(o.x,o.y,o.z||0)}this.setAttribute("position",new Ve(n,3))}else{const n=Math.min(e.length,t.count);for(let i=0;i<n;i++){const s=e[i];t.setXYZ(i,s.x,s.y,s.z||0)}e.length>t.count&&Ue("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Dt);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ye("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new U(-1/0,-1/0,-1/0),new U(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){const s=t[n];In.setFromBufferAttribute(s),this.morphTargetsRelative?(Gt.addVectors(this.boundingBox.min,In.min),this.boundingBox.expandByPoint(Gt),Gt.addVectors(this.boundingBox.max,In.max),this.boundingBox.expandByPoint(Gt)):(this.boundingBox.expandByPoint(In.min),this.boundingBox.expandByPoint(In.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Ye('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ft);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ye("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new U,1/0);return}if(e){const n=this.boundingSphere.center;if(In.setFromBufferAttribute(e),t)for(let s=0,o=t.length;s<o;s++){const a=t[s];_o.setFromBufferAttribute(a),this.morphTargetsRelative?(Gt.addVectors(In.min,_o.min),In.expandByPoint(Gt),Gt.addVectors(In.max,_o.max),In.expandByPoint(Gt)):(In.expandByPoint(_o.min),In.expandByPoint(_o.max))}In.getCenter(n);let i=0;for(let s=0,o=e.count;s<o;s++)Gt.fromBufferAttribute(e,s),i=Math.max(i,n.distanceToSquared(Gt));if(t)for(let s=0,o=t.length;s<o;s++){const a=t[s],c=this.morphTargetsRelative;for(let l=0,u=a.count;l<u;l++)Gt.fromBufferAttribute(a,l),c&&(yr.fromBufferAttribute(e,l),Gt.add(yr)),i=Math.max(i,n.distanceToSquared(Gt))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&Ye('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Ye("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,i=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new mt(new Float32Array(4*n.count),4));const o=this.getAttribute("tangent"),a=[],c=[];for(let x=0;x<n.count;x++)a[x]=new U,c[x]=new U;const l=new U,u=new U,h=new U,f=new Ee,p=new Ee,m=new Ee,y=new U,_=new U;function g(x,E,w){l.fromBufferAttribute(n,x),u.fromBufferAttribute(n,E),h.fromBufferAttribute(n,w),f.fromBufferAttribute(s,x),p.fromBufferAttribute(s,E),m.fromBufferAttribute(s,w),u.sub(l),h.sub(l),p.sub(f),m.sub(f);const A=1/(p.x*m.y-m.x*p.y);isFinite(A)&&(y.copy(u).multiplyScalar(m.y).addScaledVector(h,-p.y).multiplyScalar(A),_.copy(h).multiplyScalar(p.x).addScaledVector(u,-m.x).multiplyScalar(A),a[x].add(y),a[E].add(y),a[w].add(y),c[x].add(_),c[E].add(_),c[w].add(_))}d(g,"handleTriangle");let v=this.groups;v.length===0&&(v=[{start:0,count:e.count}]);for(let x=0,E=v.length;x<E;++x){const w=v[x],A=w.start,R=w.count;for(let P=A,I=A+R;P<I;P+=3)g(e.getX(P+0),e.getX(P+1),e.getX(P+2))}const M=new U,b=new U,C=new U,S=new U;function T(x){C.fromBufferAttribute(i,x),S.copy(C);const E=a[x];M.copy(E),M.sub(C.multiplyScalar(C.dot(E))).normalize(),b.crossVectors(S,E);const A=b.dot(c[x])<0?-1:1;o.setXYZW(x,M.x,M.y,M.z,A)}d(T,"handleVertex");for(let x=0,E=v.length;x<E;++x){const w=v[x],A=w.start,R=w.count;for(let P=A,I=A+R;P<I;P+=3)T(e.getX(P+0)),T(e.getX(P+1)),T(e.getX(P+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new mt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let f=0,p=n.count;f<p;f++)n.setXYZ(f,0,0,0);const i=new U,s=new U,o=new U,a=new U,c=new U,l=new U,u=new U,h=new U;if(e)for(let f=0,p=e.count;f<p;f+=3){const m=e.getX(f+0),y=e.getX(f+1),_=e.getX(f+2);i.fromBufferAttribute(t,m),s.fromBufferAttribute(t,y),o.fromBufferAttribute(t,_),u.subVectors(o,s),h.subVectors(i,s),u.cross(h),a.fromBufferAttribute(n,m),c.fromBufferAttribute(n,y),l.fromBufferAttribute(n,_),a.add(u),c.add(u),l.add(u),n.setXYZ(m,a.x,a.y,a.z),n.setXYZ(y,c.x,c.y,c.z),n.setXYZ(_,l.x,l.y,l.z)}else for(let f=0,p=t.count;f<p;f+=3)i.fromBufferAttribute(t,f+0),s.fromBufferAttribute(t,f+1),o.fromBufferAttribute(t,f+2),u.subVectors(o,s),h.subVectors(i,s),u.cross(h),n.setXYZ(f+0,u.x,u.y,u.z),n.setXYZ(f+1,u.x,u.y,u.z),n.setXYZ(f+2,u.x,u.y,u.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Gt.fromBufferAttribute(e,t),Gt.normalize(),e.setXYZ(t,Gt.x,Gt.y,Gt.z)}toNonIndexed(){function e(a,c){const l=a.array,u=a.itemSize,h=a.normalized,f=new l.constructor(c.length*u);let p=0,m=0;for(let y=0,_=c.length;y<_;y++){a.isInterleavedBufferAttribute?p=c[y]*a.data.stride+a.offset:p=c[y]*u;for(let g=0;g<u;g++)f[m++]=l[p++]}return new mt(f,u,h)}if(d(e,"convertBufferAttribute"),this.index===null)return Ue("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Ku,n=this.index.array,i=this.attributes;for(const a in i){const c=i[a],l=e(c,n);t.setAttribute(a,l)}const s=this.morphAttributes;for(const a in s){const c=[],l=s[a];for(let u=0,h=l.length;u<h;u++){const f=l[u],p=e(f,n);c.push(p)}t.morphAttributes[a]=c}t.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,c=o.length;a<c;a++){const l=o[a];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const c in n){const l=n[c];e.data.attributes[c]=l.toJSON(e.data)}const i={};let s=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],u=[];for(let h=0,f=l.length;h<f;h++){const p=l[h];u.push(p.toJSON(e.data))}u.length>0&&(i[c]=u,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(e.data.boundingSphere=a.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone());const i=e.attributes;for(const l in i){const u=i[l];this.setAttribute(l,u.clone(t))}const s=e.morphAttributes;for(const l in s){const u=[],h=s[l];for(let f=0,p=h.length;f<p;f++)u.push(h[f].clone(t));this.morphAttributes[l]=u}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let l=0,u=o.length;l<u;l++){const h=o[l];this.addGroup(h.start,h.count,h.materialIndex)}const a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}};d(Ku,"BufferGeometry");let Qe=Ku;const Dm=class Dm{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Qo,this.updateRanges=[],this.version=0,this.uuid=Dn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,s=this.stride;i<s;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Dn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Dn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}};d(Dm,"InterleavedBuffer");let Jr=Dm;const cn=new U,Ju=class Ju{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)cn.fromBufferAttribute(this,t),cn.applyMatrix4(e),this.setXYZ(t,cn.x,cn.y,cn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)cn.fromBufferAttribute(this,t),cn.applyNormalMatrix(e),this.setXYZ(t,cn.x,cn.y,cn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)cn.fromBufferAttribute(this,t),cn.transformDirection(e),this.setXYZ(t,cn.x,cn.y,cn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=dn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=st(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=st(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=st(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=st(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=st(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=dn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=dn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=dn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=dn(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=st(t,this.array),n=st(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=st(t,this.array),n=st(n,this.array),i=st(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=st(t,this.array),n=st(n,this.array),i=st(i,this.array),s=st(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=s,this}clone(e){if(e===void 0){ta("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return new mt(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Ju(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){ta("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}};d(Ju,"InterleavedBufferAttribute");let Pn=Ju,SM=0;const Fm=class Fm extends Vn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:SM++}),this.uuid=Dn(),this.name="",this.type="Material",this.blending=Bs,this.side=zn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=zc,this.blendDst=kc,this.blendEquation=Ji,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ke(0,0,0),this.blendAlpha=0,this.depthFunc=Ws,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Yf,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Rs,this.stencilZFail=Rs,this.stencilZPass=Rs,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){Ue(`Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){Ue(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Bs&&(n.blending=this.blending),this.side!==zn&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==zc&&(n.blendSrc=this.blendSrc),this.blendDst!==kc&&(n.blendDst=this.blendDst),this.blendEquation!==Ji&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Ws&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Yf&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Rs&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Rs&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Rs&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(s){const o=[];for(const a in s){const c=s[a];delete c.metadata,o.push(c)}return o}if(d(i,"extractFromCache"),t){const s=i(e.textures),o=i(e.images);s.length>0&&(n.textures=s),o.length>0&&(n.images=o)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const i=t.length;n=new Array(i);for(let s=0;s!==i;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}};d(Fm,"Material");let zt=Fm;const Lm=class Lm extends zt{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new ke(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}};d(Lm,"SpriteMaterial");let jr=Lm,xr;const yo=new U,vr=new U,br=new U,Sr=new Ee,xo=new Ee,Zv=new Je,Ya=new U,vo=new U,Za=new U,gy=new Ee,nf=new Ee,_y=new Ee,Om=class Om extends ft{constructor(e=new jr){if(super(),this.isSprite=!0,this.type="Sprite",xr===void 0){xr=new Qe;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new Jr(t,5);xr.setIndex([0,1,2,0,2,3]),xr.setAttribute("position",new Pn(n,3,0,!1)),xr.setAttribute("uv",new Pn(n,2,3,!1))}this.geometry=xr,this.material=e,this.center=new Ee(.5,.5),this.count=1}raycast(e,t){e.camera===null&&Ye('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),vr.setFromMatrixScale(this.matrixWorld),Zv.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),br.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&vr.multiplyScalar(-br.z);const n=this.material.rotation;let i,s;n!==0&&(s=Math.cos(n),i=Math.sin(n));const o=this.center;Ka(Ya.set(-.5,-.5,0),br,o,vr,i,s),Ka(vo.set(.5,-.5,0),br,o,vr,i,s),Ka(Za.set(.5,.5,0),br,o,vr,i,s),gy.set(0,0),nf.set(1,0),_y.set(1,1);let a=e.ray.intersectTriangle(Ya,vo,Za,!1,yo);if(a===null&&(Ka(vo.set(-.5,.5,0),br,o,vr,i,s),nf.set(0,1),a=e.ray.intersectTriangle(Ya,Za,vo,!1,yo),a===null))return;const c=e.ray.origin.distanceTo(yo);c<e.near||c>e.far||t.push({distance:c,point:yo.clone(),uv:ui.getInterpolation(yo,Ya,vo,Za,gy,nf,_y,new Ee),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}};d(Om,"Sprite");let oa=Om;function Ka(r,e,t,n,i,s){Sr.subVectors(r,t).addScalar(.5).multiply(n),i!==void 0?(xo.x=s*Sr.x-i*Sr.y,xo.y=i*Sr.x+s*Sr.y):xo.copy(Sr),r.copy(e),r.x+=xo.x,r.y+=xo.y,r.applyMatrix4(Zv)}d(Ka,"transformVertex");const Ja=new U,yy=new U,Um=class Um extends ft{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let n=0,i=t.length;n<i;n++){const s=t[n];this.addLevel(s.object.clone(),s.distance,s.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,n=0){t=Math.abs(t);const i=this.levels;let s;for(s=0;s<i.length&&!(t<i[s].distance);s++);return i.splice(s,0,{distance:t,hysteresis:n,object:e}),this.add(e),this}removeLevel(e){const t=this.levels;for(let n=0;n<t.length;n++)if(t[n].distance===e){const i=t.splice(n,1);return this.remove(i[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let n,i;for(n=1,i=t.length;n<i;n++){let s=t[n].distance;if(t[n].object.visible&&(s-=s*t[n].hysteresis),e<s)break}return t[n-1].object}return null}raycast(e,t){if(this.levels.length>0){Ja.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(Ja);this.getObjectForDistance(i).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Ja.setFromMatrixPosition(e.matrixWorld),yy.setFromMatrixPosition(this.matrixWorld);const n=Ja.distanceTo(yy)/e.zoom;t[0].object.visible=!0;let i,s;for(i=1,s=t.length;i<s;i++){let o=t[i].distance;if(t[i].object.visible&&(o-=o*t[i].hysteresis),n>=o)t[i-1].object.visible=!1,t[i].object.visible=!0;else break}for(this._currentLevel=i-1;i<s;i++)t[i].object.visible=!1}}toJSON(e){const t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];const n=this.levels;for(let i=0,s=n.length;i<s;i++){const o=n[i];t.object.levels.push({object:o.object.uuid,distance:o.distance,hysteresis:o.hysteresis})}return t}};d(Um,"LOD");let Pl=Um;const wi=new U,sf=new U,ja=new U,Gi=new U,rf=new U,Qa=new U,of=new U,Bm=class Bm{constructor(e=new U,t=new U(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,wi)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=wi.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(wi.copy(this.origin).addScaledVector(this.direction,t),wi.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){sf.copy(e).add(t).multiplyScalar(.5),ja.copy(t).sub(e).normalize(),Gi.copy(this.origin).sub(sf);const s=e.distanceTo(t)*.5,o=-this.direction.dot(ja),a=Gi.dot(this.direction),c=-Gi.dot(ja),l=Gi.lengthSq(),u=Math.abs(1-o*o);let h,f,p,m;if(u>0)if(h=o*c-a,f=o*a-c,m=s*u,h>=0)if(f>=-m)if(f<=m){const y=1/u;h*=y,f*=y,p=h*(h+o*f+2*a)+f*(o*h+f+2*c)+l}else f=s,h=Math.max(0,-(o*f+a)),p=-h*h+f*(f+2*c)+l;else f=-s,h=Math.max(0,-(o*f+a)),p=-h*h+f*(f+2*c)+l;else f<=-m?(h=Math.max(0,-(-o*s+a)),f=h>0?-s:Math.min(Math.max(-s,-c),s),p=-h*h+f*(f+2*c)+l):f<=m?(h=0,f=Math.min(Math.max(-s,-c),s),p=f*(f+2*c)+l):(h=Math.max(0,-(o*s+a)),f=h>0?s:Math.min(Math.max(-s,-c),s),p=-h*h+f*(f+2*c)+l);else f=o>0?-s:s,h=Math.max(0,-(o*f+a)),p=-h*h+f*(f+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(sf).addScaledVector(ja,f),p}intersectSphere(e,t){wi.subVectors(e.center,this.origin);const n=wi.dot(this.direction),i=wi.dot(wi)-n*n,s=e.radius*e.radius;if(i>s)return null;const o=Math.sqrt(s-i),a=n-o,c=n+o;return c<0?null:a<0?this.at(c,t):this.at(a,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,s,o,a,c;const l=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,f=this.origin;return l>=0?(n=(e.min.x-f.x)*l,i=(e.max.x-f.x)*l):(n=(e.max.x-f.x)*l,i=(e.min.x-f.x)*l),u>=0?(s=(e.min.y-f.y)*u,o=(e.max.y-f.y)*u):(s=(e.max.y-f.y)*u,o=(e.min.y-f.y)*u),n>o||s>i||((s>n||isNaN(n))&&(n=s),(o<i||isNaN(i))&&(i=o),h>=0?(a=(e.min.z-f.z)*h,c=(e.max.z-f.z)*h):(a=(e.max.z-f.z)*h,c=(e.min.z-f.z)*h),n>c||a>i)||((a>n||n!==n)&&(n=a),(c<i||i!==i)&&(i=c),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,wi)!==null}intersectTriangle(e,t,n,i,s){rf.subVectors(t,e),Qa.subVectors(n,e),of.crossVectors(rf,Qa);let o=this.direction.dot(of),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;Gi.subVectors(this.origin,e);const c=a*this.direction.dot(Qa.crossVectors(Gi,Qa));if(c<0)return null;const l=a*this.direction.dot(rf.cross(Gi));if(l<0||c+l>o)return null;const u=-a*Gi.dot(of);return u<0?null:this.at(u/o,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}};d(Bm,"Ray");let os=Bm;const zm=class zm extends zt{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ke(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new rn,this.combine=La,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}};d(zm,"MeshBasicMaterial");let Wt=zm;const xy=new Je,ys=new os,ec=new Ft,vy=new U,tc=new U,nc=new U,ic=new U,af=new U,sc=new U,by=new U,rc=new U,km=class km extends ft{constructor(e=new Qe,t=new Wt){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(e,t){const n=this.geometry,i=n.attributes.position,s=n.morphAttributes.position,o=n.morphTargetsRelative;t.fromBufferAttribute(i,e);const a=this.morphTargetInfluences;if(s&&a){sc.set(0,0,0);for(let c=0,l=s.length;c<l;c++){const u=a[c],h=s[c];u!==0&&(af.fromBufferAttribute(h,e),o?sc.addScaledVector(af,u):sc.addScaledVector(af.sub(t),u))}t.add(sc)}return t}raycast(e,t){const n=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),ec.copy(n.boundingSphere),ec.applyMatrix4(s),ys.copy(e.ray).recast(e.near),!(ec.containsPoint(ys.origin)===!1&&(ys.intersectSphere(ec,vy)===null||ys.origin.distanceToSquared(vy)>(e.far-e.near)**2))&&(xy.copy(s).invert(),ys.copy(e.ray).applyMatrix4(xy),!(n.boundingBox!==null&&ys.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,ys)))}_computeIntersections(e,t,n){let i;const s=this.geometry,o=this.material,a=s.index,c=s.attributes.position,l=s.attributes.uv,u=s.attributes.uv1,h=s.attributes.normal,f=s.groups,p=s.drawRange;if(a!==null)if(Array.isArray(o))for(let m=0,y=f.length;m<y;m++){const _=f[m],g=o[_.materialIndex],v=Math.max(_.start,p.start),M=Math.min(a.count,Math.min(_.start+_.count,p.start+p.count));for(let b=v,C=M;b<C;b+=3){const S=a.getX(b),T=a.getX(b+1),x=a.getX(b+2);i=oc(this,g,e,n,l,u,h,S,T,x),i&&(i.faceIndex=Math.floor(b/3),i.face.materialIndex=_.materialIndex,t.push(i))}}else{const m=Math.max(0,p.start),y=Math.min(a.count,p.start+p.count);for(let _=m,g=y;_<g;_+=3){const v=a.getX(_),M=a.getX(_+1),b=a.getX(_+2);i=oc(this,o,e,n,l,u,h,v,M,b),i&&(i.faceIndex=Math.floor(_/3),t.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let m=0,y=f.length;m<y;m++){const _=f[m],g=o[_.materialIndex],v=Math.max(_.start,p.start),M=Math.min(c.count,Math.min(_.start+_.count,p.start+p.count));for(let b=v,C=M;b<C;b+=3){const S=b,T=b+1,x=b+2;i=oc(this,g,e,n,l,u,h,S,T,x),i&&(i.faceIndex=Math.floor(b/3),i.face.materialIndex=_.materialIndex,t.push(i))}}else{const m=Math.max(0,p.start),y=Math.min(c.count,p.start+p.count);for(let _=m,g=y;_<g;_+=3){const v=_,M=_+1,b=_+2;i=oc(this,o,e,n,l,u,h,v,M,b),i&&(i.faceIndex=Math.floor(_/3),t.push(i))}}}};d(km,"Mesh");let yt=km;function MM(r,e,t,n,i,s,o,a){let c;if(e.side===gn?c=n.intersectTriangle(o,s,i,!0,a):c=n.intersectTriangle(i,s,o,e.side===zn,a),c===null)return null;rc.copy(a),rc.applyMatrix4(r.matrixWorld);const l=t.ray.origin.distanceTo(rc);return l<t.near||l>t.far?null:{distance:l,point:rc.clone(),object:r}}d(MM,"checkIntersection$1");function oc(r,e,t,n,i,s,o,a,c,l){r.getVertexPosition(a,tc),r.getVertexPosition(c,nc),r.getVertexPosition(l,ic);const u=MM(r,e,t,n,tc,nc,ic,by);if(u){const h=new U;ui.getBarycoord(by,tc,nc,ic,h),i&&(u.uv=ui.getInterpolatedAttribute(i,a,c,l,h,new Ee)),s&&(u.uv1=ui.getInterpolatedAttribute(s,a,c,l,h,new Ee)),o&&(u.normal=ui.getInterpolatedAttribute(o,a,c,l,h,new U),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));const f={a,b:c,c:l,normal:new U,materialIndex:0};ui.getNormal(tc,nc,ic,f.normal),u.face=f,u.barycoord=h}return u}d(oc,"checkGeometryIntersection");const Sy=new U,My=new pt,wy=new pt,wM=new U,Ey=new Je,ac=new U,cf=new Ft,Ay=new Je,lf=new os,Vm=class Vm extends yt{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Xf,this.bindMatrix=new Je,this.bindMatrixInverse=new Je,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Dt),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,ac),this.boundingBox.expandByPoint(ac)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Ft),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,ac),this.boundingSphere.expandByPoint(ac)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),cf.copy(this.boundingSphere),cf.applyMatrix4(i),e.ray.intersectsSphere(cf)!==!1&&(Ay.copy(i).invert(),lf.copy(e.ray).applyMatrix4(Ay),!(this.boundingBox!==null&&lf.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,lf)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new pt,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===Xf?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===Dv?this.bindMatrixInverse.copy(this.bindMatrix).invert():Ue("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,i=this.geometry;My.fromBufferAttribute(i.attributes.skinIndex,e),wy.fromBufferAttribute(i.attributes.skinWeight,e),Sy.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){const o=wy.getComponent(s);if(o!==0){const a=My.getComponent(s);Ey.multiplyMatrices(n.bones[a].matrixWorld,n.boneInverses[a]),t.addScaledVector(wM.copy(Sy).applyMatrix4(Ey),o)}}return t.applyMatrix4(this.bindMatrixInverse)}};d(Vm,"SkinnedMesh");let Nl=Vm;const Hm=class Hm extends ft{constructor(){super(),this.isBone=!0,this.type="Bone"}};d(Hm,"Bone");let aa=Hm;const Gm=class Gm extends Ot{constructor(e=null,t=1,n=1,i,s,o,a,c,l=Nt,u=Nt,h,f){super(null,o,a,c,l,u,i,s,h,f),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};d(Gm,"DataTexture");let Fn=Gm;const Ty=new Je,EM=new Je,ju=class ju{constructor(e=[],t=[]){this.uuid=Dn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.previousBoneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){Ue("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Je)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new Je;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let s=0,o=e.length;s<o;s++){const a=e[s]?e[s].matrixWorld:EM;Ty.multiplyMatrices(a,t[s]),Ty.toArray(n,s*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new ju(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new Fn(t,e,e,mn,pn);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const i=this.bones[t];if(i.name===e)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){const s=e.bones[n];let o=t[s];o===void 0&&(Ue("Skeleton: No bone found with UUID:",s),o=new aa),this.bones.push(o),this.boneInverses.push(new Je().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let i=0,s=t.length;i<s;i++){const o=t[i];e.bones.push(o.uuid);const a=n[i];e.boneInverses.push(a.toArray())}return e}};d(ju,"Skeleton");let Dl=ju;const Wm=class Wm extends mt{constructor(e,t,n,i=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}};d(Wm,"InstancedBufferAttribute");let as=Wm;const Mr=new Je,Cy=new Je,cc=[],Iy=new Dt,AM=new Je,bo=new yt,So=new Ft,$m=class $m extends yt{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new as(new Float32Array(n*16),16),this.previousInstanceMatrix=null,this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,AM)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Dt),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Mr),Iy.copy(e.boundingBox).applyMatrix4(Mr),this.boundingBox.union(Iy)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Ft),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Mr),So.copy(e.boundingSphere).applyMatrix4(Mr),this.boundingSphere.union(So)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.previousInstanceMatrix!==null&&(this.previousInstanceMatrix=e.previousInstanceMatrix.clone()),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,s=n.length+1,o=e*s+1;for(let a=0;a<n.length;a++)n[a]=i[o+a]}raycast(e,t){const n=this.matrixWorld,i=this.count;if(bo.geometry=this.geometry,bo.material=this.material,bo.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),So.copy(this.boundingSphere),So.applyMatrix4(n),e.ray.intersectsSphere(So)!==!1))for(let s=0;s<i;s++){this.getMatrixAt(s,Mr),Cy.multiplyMatrices(n,Mr),bo.matrixWorld=Cy,bo.raycast(e,cc);for(let o=0,a=cc.length;o<a;o++){const c=cc[o];c.instanceId=s,c.object=this,t.push(c)}cc.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new as(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const n=t.morphTargetInfluences,i=n.length+1;this.morphTexture===null&&(this.morphTexture=new Fn(new Float32Array(i*this.count),i,this.count,Ch,pn));const s=this.morphTexture.source.data.data;let o=0;for(let l=0;l<n.length;l++)o+=n[l];const a=this.geometry.morphTargetsRelative?1:1-o,c=i*e;s[c]=a,s.set(n,c+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}};d($m,"InstancedMesh");let Fl=$m;const uf=new U,TM=new U,CM=new nt,Xm=class Xm{constructor(e=new U(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=uf.subVectors(n,t).cross(TM.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(uf),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:t.copy(e.start).addScaledVector(n,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||CM.getNormalMatrix(e),i=this.coplanarPoint(uf).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}};d(Xm,"Plane");let Zn=Xm;const xs=new Ft,IM=new Ee(.5,.5),lc=new U,qm=class qm{constructor(e=new Zn,t=new Zn,n=new Zn,i=new Zn,s=new Zn,o=new Zn){this.planes=[e,t,n,i,s,o]}set(e,t,n,i,s,o){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(s),a[5].copy(o),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Rn,n=!1){const i=this.planes,s=e.elements,o=s[0],a=s[1],c=s[2],l=s[3],u=s[4],h=s[5],f=s[6],p=s[7],m=s[8],y=s[9],_=s[10],g=s[11],v=s[12],M=s[13],b=s[14],C=s[15];if(i[0].setComponents(l-o,p-u,g-m,C-v).normalize(),i[1].setComponents(l+o,p+u,g+m,C+v).normalize(),i[2].setComponents(l+a,p+h,g+y,C+M).normalize(),i[3].setComponents(l-a,p-h,g-y,C-M).normalize(),n)i[4].setComponents(c,f,_,b).normalize(),i[5].setComponents(l-c,p-f,g-_,C-b).normalize();else if(i[4].setComponents(l-c,p-f,g-_,C-b).normalize(),t===Rn)i[5].setComponents(l+c,p+f,g+_,C+b).normalize();else if(t===qs)i[5].setComponents(c,f,_,b).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),xs.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),xs.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(xs)}intersectsSprite(e){xs.center.set(0,0,0);const t=IM.distanceTo(e.center);return xs.radius=.7071067811865476+t,xs.applyMatrix4(e.matrixWorld),this.intersectsSphere(xs)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const i=t[n];if(lc.x=i.normal.x>0?e.max.x:e.min.x,lc.y=i.normal.y>0?e.max.y:e.min.y,lc.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(lc)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};d(qm,"Frustum");let cs=qm;const ni=new Je,ii=new cs,Qu=class Qu{constructor(){this.coordinateSystem=Rn}intersectsObject(e,t){if(!t.isArrayCamera||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const i=t.cameras[n];if(ni.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),ii.setFromProjectionMatrix(ni,i.coordinateSystem,i.reversedDepth),ii.intersectsObject(e))return!0}return!1}intersectsSprite(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const i=t.cameras[n];if(ni.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),ii.setFromProjectionMatrix(ni,i.coordinateSystem,i.reversedDepth),ii.intersectsSprite(e))return!0}return!1}intersectsSphere(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const i=t.cameras[n];if(ni.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),ii.setFromProjectionMatrix(ni,i.coordinateSystem,i.reversedDepth),ii.intersectsSphere(e))return!0}return!1}intersectsBox(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const i=t.cameras[n];if(ni.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),ii.setFromProjectionMatrix(ni,i.coordinateSystem,i.reversedDepth),ii.intersectsBox(e))return!0}return!1}containsPoint(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const i=t.cameras[n];if(ni.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),ii.setFromProjectionMatrix(ni,i.coordinateSystem,i.reversedDepth),ii.containsPoint(e))return!0}return!1}clone(){return new Qu}};d(Qu,"FrustumArray");let Ll=Qu;function hf(r,e){return r-e}d(hf,"ascIdSort");function RM(r,e){return r.z-e.z}d(RM,"sortOpaque");function PM(r,e){return e.z-r.z}d(PM,"sortTransparent");const Ym=class Ym{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,n,i){const s=this.pool,o=this.list;this.index>=s.length&&s.push({start:-1,count:-1,z:-1,index:-1});const a=s[this.index];o.push(a),this.index++,a.start=e,a.count=t,a.z=n,a.index=i}reset(){this.list.length=0,this.index=0}};d(Ym,"MultiDrawRenderList");let rd=Ym;const xn=new Je,NM=new ke(1,1,1),Ry=new cs,DM=new Ll,uc=new Dt,vs=new Ft,Mo=new U,Py=new U,FM=new U,ff=new rd,tn=new yt,hc=[];function LM(r,e,t=0){const n=e.itemSize;if(r.isInterleavedBufferAttribute||r.array.constructor!==e.array.constructor){const i=r.count;for(let s=0;s<i;s++)for(let o=0;o<n;o++)e.setComponent(s+t,o,r.getComponent(s,o))}else e.array.set(r.array,t*n);e.needsUpdate=!0}d(LM,"copyAttributeData");function bs(r,e){if(r.constructor!==e.constructor){const t=Math.min(r.length,e.length);for(let n=0;n<t;n++)e[n]=r[n]}else{const t=Math.min(r.length,e.length);e.set(new r.constructor(r.buffer,0,t))}}d(bs,"copyArrayContents");const Zm=class Zm extends yt{constructor(e,t,n=t*2,i){super(new Qe,i),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._instanceInfo=[],this._geometryInfo=[],this._availableInstanceIds=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._visibilityChanged=!0,this._geometryInitialized=!1,this._maxInstanceCount=e,this._maxVertexCount=t,this._maxIndexCount=n,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawInstances=null,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}get maxInstanceCount(){return this._maxInstanceCount}get instanceCount(){return this._instanceInfo.length-this._availableInstanceIds.length}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}_initMatricesTexture(){let e=Math.sqrt(this._maxInstanceCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4),n=new Fn(t,e,e,mn,pn);this._matricesTexture=n}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Uint32Array(e*e),n=new Fn(t,e,e,Oa,kn);this._indirectTexture=n}_initColorsTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Float32Array(e*e*4).fill(1),n=new Fn(t,e,e,mn,pn);n.colorSpace=lt.workingColorSpace,this._colorsTexture=n}_initializeGeometry(e){const t=this.geometry,n=this._maxVertexCount,i=this._maxIndexCount;if(this._geometryInitialized===!1){for(const s in e.attributes){const o=e.getAttribute(s),{array:a,itemSize:c,normalized:l}=o,u=new a.constructor(n*c),h=new mt(u,c,l);t.setAttribute(s,h)}if(e.getIndex()!==null){const s=n>65535?new Uint32Array(i):new Uint16Array(i);t.setIndex(new mt(s,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const n in t.attributes){if(!e.hasAttribute(n))throw new Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const i=e.getAttribute(n),s=t.getAttribute(n);if(i.itemSize!==s.itemSize||i.normalized!==s.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(e){const t=this._instanceInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){const t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Dt);const e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let n=0,i=t.length;n<i;n++){if(t[n].active===!1)continue;const s=t[n].geometryIndex;this.getMatrixAt(n,xn),this.getBoundingBoxAt(s,uc).applyMatrix4(xn),e.union(uc)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ft);const e=this.boundingSphere,t=this._instanceInfo;e.makeEmpty();for(let n=0,i=t.length;n<i;n++){if(t[n].active===!1)continue;const s=t[n].geometryIndex;this.getMatrixAt(n,xn),this.getBoundingSphereAt(s,vs).applyMatrix4(xn),e.union(vs)}}addInstance(e){if(this._instanceInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const n={visible:!0,active:!0,geometryIndex:e};let i=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(hf),i=this._availableInstanceIds.shift(),this._instanceInfo[i]=n):(i=this._instanceInfo.length,this._instanceInfo.push(n));const s=this._matricesTexture;xn.identity().toArray(s.image.data,i*16),s.needsUpdate=!0;const o=this._colorsTexture;return o&&(NM.toArray(o.image.data,i*4),o.needsUpdate=!0),this._visibilityChanged=!0,i}addGeometry(e,t=-1,n=-1){this._initializeGeometry(e),this._validateGeometry(e);const i={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},s=this._geometryInfo;i.vertexStart=this._nextVertexStart,i.reservedVertexCount=t===-1?e.getAttribute("position").count:t;const o=e.getIndex();if(o!==null&&(i.indexStart=this._nextIndexStart,i.reservedIndexCount=n===-1?o.count:n),i.indexStart!==-1&&i.indexStart+i.reservedIndexCount>this._maxIndexCount||i.vertexStart+i.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let c;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(hf),c=this._availableGeometryIds.shift(),s[c]=i):(c=this._geometryCount,this._geometryCount++,s.push(i)),this.setGeometryAt(c,e),this._nextIndexStart=i.indexStart+i.reservedIndexCount,this._nextVertexStart=i.vertexStart+i.reservedVertexCount,c}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const n=this.geometry,i=n.getIndex()!==null,s=n.getIndex(),o=t.getIndex(),a=this._geometryInfo[e];if(i&&o.count>a.reservedIndexCount||t.attributes.position.count>a.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const c=a.vertexStart,l=a.reservedVertexCount;a.vertexCount=t.getAttribute("position").count;for(const u in n.attributes){const h=t.getAttribute(u),f=n.getAttribute(u);LM(h,f,c);const p=h.itemSize;for(let m=h.count,y=l;m<y;m++){const _=c+m;for(let g=0;g<p;g++)f.setComponent(_,g,0)}f.needsUpdate=!0,f.addUpdateRange(c*p,l*p)}if(i){const u=a.indexStart,h=a.reservedIndexCount;a.indexCount=t.getIndex().count;for(let f=0;f<o.count;f++)s.setX(u+f,c+o.getX(f));for(let f=o.count,p=h;f<p;f++)s.setX(u+f,c);s.needsUpdate=!0,s.addUpdateRange(u,a.reservedIndexCount)}return a.start=i?a.indexStart:a.vertexStart,a.count=i?a.indexCount:a.vertexCount,a.boundingBox=null,t.boundingBox!==null&&(a.boundingBox=t.boundingBox.clone()),a.boundingSphere=null,t.boundingSphere!==null&&(a.boundingSphere=t.boundingSphere.clone()),this._visibilityChanged=!0,e}deleteGeometry(e){const t=this._geometryInfo;if(e>=t.length||t[e].active===!1)return this;const n=this._instanceInfo;for(let i=0,s=n.length;i<s;i++)n[i].active&&n[i].geometryIndex===e&&this.deleteInstance(i);return t[e].active=!1,this._availableGeometryIds.push(e),this._visibilityChanged=!0,this}deleteInstance(e){return this.validateInstanceId(e),this._instanceInfo[e].active=!1,this._availableInstanceIds.push(e),this._visibilityChanged=!0,this}optimize(){let e=0,t=0;const n=this._geometryInfo,i=n.map((o,a)=>a).sort((o,a)=>n[o].vertexStart-n[a].vertexStart),s=this.geometry;for(let o=0,a=n.length;o<a;o++){const c=i[o],l=n[c];if(l.active!==!1){if(s.index!==null){if(l.indexStart!==t){const{indexStart:u,vertexStart:h,reservedIndexCount:f}=l,p=s.index,m=p.array,y=e-h;for(let _=u;_<u+f;_++)m[_]=m[_]+y;p.array.copyWithin(t,u,u+f),p.addUpdateRange(t,f),p.needsUpdate=!0,l.indexStart=t}t+=l.reservedIndexCount}if(l.vertexStart!==e){const{vertexStart:u,reservedVertexCount:h}=l,f=s.attributes;for(const p in f){const m=f[p],{array:y,itemSize:_}=m;y.copyWithin(e*_,u*_,(u+h)*_),m.addUpdateRange(e*_,h*_),m.needsUpdate=!0}l.vertexStart=e}e+=l.reservedVertexCount,l.start=s.index?l.indexStart:l.vertexStart}}return this._nextIndexStart=t,this._nextVertexStart=e,this._visibilityChanged=!0,this}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[e];if(i.boundingBox===null){const s=new Dt,o=n.index,a=n.attributes.position;for(let c=i.start,l=i.start+i.count;c<l;c++){let u=c;o&&(u=o.getX(u)),s.expandByPoint(Mo.fromBufferAttribute(a,u))}i.boundingBox=s}return t.copy(i.boundingBox),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[e];if(i.boundingSphere===null){const s=new Ft;this.getBoundingBoxAt(e,uc),uc.getCenter(s.center);const o=n.index,a=n.attributes.position;let c=0;for(let l=i.start,u=i.start+i.count;l<u;l++){let h=l;o&&(h=o.getX(h)),Mo.fromBufferAttribute(a,h),c=Math.max(c,s.center.distanceToSquared(Mo))}s.radius=Math.sqrt(c),i.boundingSphere=s}return t.copy(i.boundingSphere),t}setMatrixAt(e,t){this.validateInstanceId(e);const n=this._matricesTexture,i=this._matricesTexture.image.data;return t.toArray(i,e*16),n.needsUpdate=!0,this}getMatrixAt(e,t){return this.validateInstanceId(e),t.fromArray(this._matricesTexture.image.data,e*16)}setColorAt(e,t){return this.validateInstanceId(e),this._colorsTexture===null&&this._initColorsTexture(),t.toArray(this._colorsTexture.image.data,e*4),this._colorsTexture.needsUpdate=!0,this}getColorAt(e,t){return this.validateInstanceId(e),t.fromArray(this._colorsTexture.image.data,e*4)}setVisibleAt(e,t){return this.validateInstanceId(e),this._instanceInfo[e].visible===t?this:(this._instanceInfo[e].visible=t,this._visibilityChanged=!0,this)}getVisibleAt(e){return this.validateInstanceId(e),this._instanceInfo[e].visible}setGeometryIdAt(e,t){return this.validateInstanceId(e),this.validateGeometryId(t),this._instanceInfo[e].geometryIndex=t,this}getGeometryIdAt(e){return this.validateInstanceId(e),this._instanceInfo[e].geometryIndex}getGeometryRangeAt(e,t={}){this.validateGeometryId(e);const n=this._geometryInfo[e];return t.vertexStart=n.vertexStart,t.vertexCount=n.vertexCount,t.reservedVertexCount=n.reservedVertexCount,t.indexStart=n.indexStart,t.indexCount=n.indexCount,t.reservedIndexCount=n.reservedIndexCount,t.start=n.start,t.count=n.count,t}setInstanceCount(e){const t=this._availableInstanceIds,n=this._instanceInfo;for(t.sort(hf);t[t.length-1]===n.length-1;)n.pop(),t.pop();if(e<n.length)throw new Error(`BatchedMesh: Instance ids outside the range ${e} are being used. Cannot shrink instance count.`);const i=new Int32Array(e),s=new Int32Array(e);bs(this._multiDrawCounts,i),bs(this._multiDrawStarts,s),this._multiDrawCounts=i,this._multiDrawStarts=s,this._maxInstanceCount=e;const o=this._indirectTexture,a=this._matricesTexture,c=this._colorsTexture;o.dispose(),this._initIndirectTexture(),bs(o.image.data,this._indirectTexture.image.data),a.dispose(),this._initMatricesTexture(),bs(a.image.data,this._matricesTexture.image.data),c&&(c.dispose(),this._initColorsTexture(),bs(c.image.data,this._colorsTexture.image.data))}setGeometrySize(e,t){const n=[...this._geometryInfo].filter(a=>a.active);if(Math.max(...n.map(a=>a.vertexStart+a.reservedVertexCount))>e)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map(c=>c.indexStart+c.reservedIndexCount))>t)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);const s=this.geometry;s.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Qe,this._initializeGeometry(s));const o=this.geometry;s.index&&bs(s.index.array,o.index.array);for(const a in s.attributes)bs(s.attributes[a].array,o.attributes[a].array)}raycast(e,t){const n=this._instanceInfo,i=this._geometryInfo,s=this.matrixWorld,o=this.geometry;tn.material=this.material,tn.geometry.index=o.index,tn.geometry.attributes=o.attributes,tn.geometry.boundingBox===null&&(tn.geometry.boundingBox=new Dt),tn.geometry.boundingSphere===null&&(tn.geometry.boundingSphere=new Ft);for(let a=0,c=n.length;a<c;a++){if(!n[a].visible||!n[a].active)continue;const l=n[a].geometryIndex,u=i[l];tn.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(a,tn.matrixWorld).premultiply(s),this.getBoundingBoxAt(l,tn.geometry.boundingBox),this.getBoundingSphereAt(l,tn.geometry.boundingSphere),tn.raycast(e,hc);for(let h=0,f=hc.length;h<f;h++){const p=hc[h];p.object=this,p.batchId=a,t.push(p)}hc.length=0}tn.material=null,tn.geometry.index=null,tn.geometry.attributes={},tn.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._geometryInfo=e._geometryInfo.map(t=>({...t,boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(t=>({...t})),this._availableInstanceIds=e._availableInstanceIds.slice(),this._availableGeometryIds=e._availableGeometryIds.slice(),this._nextIndexStart=e._nextIndexStart,this._nextVertexStart=e._nextVertexStart,this._geometryCount=e._geometryCount,this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._indirectTexture=e._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(e,t,n,i,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const o=i.getIndex();let a=o===null?1:o.array.BYTES_PER_ELEMENT,c=1;s.wireframe&&(c=2,a=i.attributes.position.count>65535?4:2);const l=this._instanceInfo,u=this._multiDrawStarts,h=this._multiDrawCounts,f=this._geometryInfo,p=this.perObjectFrustumCulled,m=this._indirectTexture,y=m.image.data,_=n.isArrayCamera?DM:Ry;p&&!n.isArrayCamera&&(xn.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),Ry.setFromProjectionMatrix(xn,n.coordinateSystem,n.reversedDepth));let g=0;if(this.sortObjects){xn.copy(this.matrixWorld).invert(),Mo.setFromMatrixPosition(n.matrixWorld).applyMatrix4(xn),Py.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(xn);for(let b=0,C=l.length;b<C;b++)if(l[b].visible&&l[b].active){const S=l[b].geometryIndex;this.getMatrixAt(b,xn),this.getBoundingSphereAt(S,vs).applyMatrix4(xn);let T=!1;if(p&&(T=!_.intersectsSphere(vs,n)),!T){const x=f[S],E=FM.subVectors(vs.center,Mo).dot(Py);ff.push(x.start,x.count,E,b)}}const v=ff.list,M=this.customSort;M===null?v.sort(s.transparent?PM:RM):M.call(this,v,n);for(let b=0,C=v.length;b<C;b++){const S=v[b];u[g]=S.start*a*c,h[g]=S.count*c,y[g]=S.index,g++}ff.reset()}else for(let v=0,M=l.length;v<M;v++)if(l[v].visible&&l[v].active){const b=l[v].geometryIndex;let C=!1;if(p&&(this.getMatrixAt(v,xn),this.getBoundingSphereAt(b,vs).applyMatrix4(xn),C=!_.intersectsSphere(vs,n)),!C){const S=f[b];u[g]=S.start*a*c,h[g]=S.count*c,y[g]=v,g++}}m.needsUpdate=!0,this._multiDrawCount=g,this._visibilityChanged=!1}onBeforeShadow(e,t,n,i,s,o){this.onBeforeRender(e,null,i,s,o)}};d(Zm,"BatchedMesh");let Ol=Zm;const Km=class Km extends zt{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new ke(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}};d(Km,"LineBasicMaterial");let It=Km;const Ul=new U,Bl=new U,Ny=new Je,wo=new os,fc=new Ft,df=new U,Dy=new U,Jm=class Jm extends ft{constructor(e=new Qe,t=new It){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let i=1,s=t.count;i<s;i++)Ul.fromBufferAttribute(t,i-1),Bl.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=Ul.distanceTo(Bl);e.setAttribute("lineDistance",new Ve(n,1))}else Ue("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),fc.copy(n.boundingSphere),fc.applyMatrix4(i),fc.radius+=s,e.ray.intersectsSphere(fc)===!1)return;Ny.copy(i).invert(),wo.copy(e.ray).applyMatrix4(Ny);const a=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=this.isLineSegments?2:1,u=n.index,f=n.attributes.position;if(u!==null){const p=Math.max(0,o.start),m=Math.min(u.count,o.start+o.count);for(let y=p,_=m-1;y<_;y+=l){const g=u.getX(y),v=u.getX(y+1),M=dc(this,e,wo,c,g,v,y);M&&t.push(M)}if(this.isLineLoop){const y=u.getX(m-1),_=u.getX(p),g=dc(this,e,wo,c,y,_,m-1);g&&t.push(g)}}else{const p=Math.max(0,o.start),m=Math.min(f.count,o.start+o.count);for(let y=p,_=m-1;y<_;y+=l){const g=dc(this,e,wo,c,y,y+1,y);g&&t.push(g)}if(this.isLineLoop){const y=dc(this,e,wo,c,m-1,p,m-1);y&&t.push(y)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}};d(Jm,"Line");let Qn=Jm;function dc(r,e,t,n,i,s,o){const a=r.geometry.attributes.position;if(Ul.fromBufferAttribute(a,i),Bl.fromBufferAttribute(a,s),t.distanceSqToSegment(Ul,Bl,df,Dy)>n)return;df.applyMatrix4(r.matrixWorld);const l=e.ray.origin.distanceTo(df);if(!(l<e.near||l>e.far))return{distance:l,point:Dy.clone().applyMatrix4(r.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:r}}d(dc,"checkIntersection");const Fy=new U,Ly=new U,jm=class jm extends Qn{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let i=0,s=t.count;i<s;i+=2)Fy.fromBufferAttribute(t,i),Ly.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+Fy.distanceTo(Ly);e.setAttribute("lineDistance",new Ve(n,1))}else Ue("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};d(jm,"LineSegments");let Hn=jm;const Qm=class Qm extends Qn{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}};d(Qm,"LineLoop");let zl=Qm;const eg=class eg extends zt{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new ke(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}};d(eg,"PointsMaterial");let Nn=eg;const Oy=new Je,od=new os,pc=new Ft,mc=new U,tg=class tg extends ft{constructor(e=new Qe,t=new Nn){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,s=e.params.Points.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),pc.copy(n.boundingSphere),pc.applyMatrix4(i),pc.radius+=s,e.ray.intersectsSphere(pc)===!1)return;Oy.copy(i).invert(),od.copy(e.ray).applyMatrix4(Oy);const a=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=n.index,h=n.attributes.position;if(l!==null){const f=Math.max(0,o.start),p=Math.min(l.count,o.start+o.count);for(let m=f,y=p;m<y;m++){const _=l.getX(m);mc.fromBufferAttribute(h,_),Uy(mc,_,c,i,e,t,this)}}else{const f=Math.max(0,o.start),p=Math.min(h.count,o.start+o.count);for(let m=f,y=p;m<y;m++)mc.fromBufferAttribute(h,m),Uy(mc,m,c,i,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}};d(tg,"Points");let Ys=tg;function Uy(r,e,t,n,i,s,o){const a=od.distanceSqToPoint(r);if(a<t){const c=new U;od.closestPointToPoint(r,c),c.applyMatrix4(n);const l=i.ray.origin.distanceTo(c);if(l<i.near||l>i.far)return;s.push({distance:l,distanceToRay:Math.sqrt(a),point:c,index:e,face:null,faceIndex:null,barycoord:null,object:o})}}d(Uy,"testPoint");const ng=class ng extends Ot{constructor(e,t,n,i,s=wt,o=wt,a,c,l){super(e,t,n,i,s,o,a,c,l),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const u=this;function h(){u.needsUpdate=!0,u._requestVideoFrameCallbackId=e.requestVideoFrameCallback(h)}d(h,"updateVideo"),"requestVideoFrameCallback"in e&&(this._requestVideoFrameCallbackId=e.requestVideoFrameCallback(h))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){this._requestVideoFrameCallbackId!==0&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}};d(ng,"VideoTexture");let kl=ng;const ig=class ig extends kl{constructor(e,t,n,i,s,o,a,c){super({},e,t,n,i,s,o,a,c),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}};d(ig,"VideoFrameTexture");let ad=ig;const sg=class sg extends Ot{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Nt,this.minFilter=Nt,this.generateMipmaps=!1,this.needsUpdate=!0}};d(sg,"FramebufferTexture");let cd=sg;const rg=class rg extends Ot{constructor(e,t,n,i,s,o,a,c,l,u,h,f){super(null,o,a,c,l,u,i,s,h,f),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}};d(rg,"CompressedTexture");let Qr=rg;const og=class og extends Qr{constructor(e,t,n,i,s,o){super(e,t,n,s,o),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=Mn,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}};d(og,"CompressedArrayTexture");let ld=og;const ag=class ag extends Qr{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,gi),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}};d(ag,"CompressedCubeTexture");let ud=ag;const cg=class cg extends Ot{constructor(e=[],t=gi,n,i,s,o,a,c,l,u){super(e,t,n,i,s,o,a,c,l,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}};d(cg,"CubeTexture");let Zs=cg;const lg=class lg extends Ot{constructor(e,t,n,i,s,o,a,c,l){super(e,t,n,i,s,o,a,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}};d(lg,"CanvasTexture");let Vl=lg;const ug=class ug extends Ot{constructor(e,t,n=kn,i,s,o,a=Nt,c=Nt,l,u=yi,h=1){if(u!==yi&&u!==ji)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const f={width:e,height:t,depth:h};super(f,i,s,o,a,c,u,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new di(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}};d(ug,"DepthTexture");let ls=ug;const hg=class hg extends ls{constructor(e,t=kn,n=gi,i,s,o=Nt,a=Nt,c,l=yi){const u={width:e,height:e,depth:1},h=[u,u,u,u,u,u];super(e,e,t,n,i,s,o,a,c,l),this.image=h,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}};d(hg,"CubeDepthTexture");let Hl=hg;const fg=class fg extends Ot{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}};d(fg,"ExternalTexture");let ca=fg;const eh=class eh extends Qe{constructor(e=1,t=1,n=1,i=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:s,depthSegments:o};const a=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o);const c=[],l=[],u=[],h=[];let f=0,p=0;m("z","y","x",-1,-1,n,t,e,o,s,0),m("z","y","x",1,-1,n,t,-e,o,s,1),m("x","z","y",1,1,e,n,t,i,o,2),m("x","z","y",1,-1,e,n,-t,i,o,3),m("x","y","z",1,-1,e,t,n,i,s,4),m("x","y","z",-1,-1,e,t,-n,i,s,5),this.setIndex(c),this.setAttribute("position",new Ve(l,3)),this.setAttribute("normal",new Ve(u,3)),this.setAttribute("uv",new Ve(h,2));function m(y,_,g,v,M,b,C,S,T,x,E){const w=b/T,A=C/x,R=b/2,P=C/2,I=S/2,N=T+1,D=x+1;let L=0,H=0;const X=new U;for(let O=0;O<D;O++){const W=O*A-P;for(let G=0;G<N;G++){const Q=G*w-R;X[y]=Q*v,X[_]=W*M,X[g]=I,l.push(X.x,X.y,X.z),X[y]=0,X[_]=0,X[g]=S>0?1:-1,u.push(X.x,X.y,X.z),h.push(G/T),h.push(1-O/x),L+=1}}for(let O=0;O<x;O++)for(let W=0;W<T;W++){const G=f+W+N*O,Q=f+W+N*(O+1),z=f+(W+1)+N*(O+1),Z=f+(W+1)+N*O;c.push(G,Q,Z),c.push(Q,z,Z),H+=6}a.addGroup(p,H,E),p+=H,f+=L}d(m,"buildPlane")}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new eh(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};d(eh,"BoxGeometry");let Ks=eh;const th=class th extends Qe{constructor(e=1,t=1,n=4,i=8,s=1){super(),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:n,radialSegments:i,heightSegments:s},t=Math.max(0,t),n=Math.max(1,Math.floor(n)),i=Math.max(3,Math.floor(i)),s=Math.max(1,Math.floor(s));const o=[],a=[],c=[],l=[],u=t/2,h=Math.PI/2*e,f=t,p=2*h+f,m=n*2+s,y=i+1,_=new U,g=new U;for(let v=0;v<=m;v++){let M=0,b=0,C=0,S=0;if(v<=n){const E=v/n,w=E*Math.PI/2;b=-u-e*Math.cos(w),C=e*Math.sin(w),S=-e*Math.cos(w),M=E*h}else if(v<=n+s){const E=(v-n)/s;b=-u+E*t,C=e,S=0,M=h+E*f}else{const E=(v-n-s)/n,w=E*Math.PI/2;b=u+e*Math.sin(w),C=e*Math.cos(w),S=e*Math.sin(w),M=h+f+E*h}const T=Math.max(0,Math.min(1,M/p));let x=0;v===0?x=.5/i:v===m&&(x=-.5/i);for(let E=0;E<=i;E++){const w=E/i,A=w*Math.PI*2,R=Math.sin(A),P=Math.cos(A);g.x=-C*P,g.y=b,g.z=C*R,a.push(g.x,g.y,g.z),_.set(-C*P,S,C*R),_.normalize(),c.push(_.x,_.y,_.z),l.push(w+x,T)}if(v>0){const E=(v-1)*y;for(let w=0;w<i;w++){const A=E+w,R=E+w+1,P=v*y+w,I=v*y+w+1;o.push(A,R,P),o.push(R,I,P)}}}this.setIndex(o),this.setAttribute("position",new Ve(a,3)),this.setAttribute("normal",new Ve(c,3)),this.setAttribute("uv",new Ve(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new th(e.radius,e.height,e.capSegments,e.radialSegments,e.heightSegments)}};d(th,"CapsuleGeometry");let Gl=th;const nh=class nh extends Qe{constructor(e=1,t=32,n=0,i=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},t=Math.max(3,t);const s=[],o=[],a=[],c=[],l=new U,u=new Ee;o.push(0,0,0),a.push(0,0,1),c.push(.5,.5);for(let h=0,f=3;h<=t;h++,f+=3){const p=n+h/t*i;l.x=e*Math.cos(p),l.y=e*Math.sin(p),o.push(l.x,l.y,l.z),a.push(0,0,1),u.x=(o[f]/e+1)/2,u.y=(o[f+1]/e+1)/2,c.push(u.x,u.y)}for(let h=1;h<=t;h++)s.push(h,h+1,0);this.setIndex(s),this.setAttribute("position",new Ve(o,3)),this.setAttribute("normal",new Ve(a,3)),this.setAttribute("uv",new Ve(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new nh(e.radius,e.segments,e.thetaStart,e.thetaLength)}};d(nh,"CircleGeometry");let Wl=nh;const ih=class ih extends Qe{constructor(e=1,t=1,n=1,i=32,s=1,o=!1,a=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:c};const l=this;i=Math.floor(i),s=Math.floor(s);const u=[],h=[],f=[],p=[];let m=0;const y=[],_=n/2;let g=0;v(),o===!1&&(e>0&&M(!0),t>0&&M(!1)),this.setIndex(u),this.setAttribute("position",new Ve(h,3)),this.setAttribute("normal",new Ve(f,3)),this.setAttribute("uv",new Ve(p,2));function v(){const b=new U,C=new U;let S=0;const T=(t-e)/n;for(let x=0;x<=s;x++){const E=[],w=x/s,A=w*(t-e)+e;for(let R=0;R<=i;R++){const P=R/i,I=P*c+a,N=Math.sin(I),D=Math.cos(I);C.x=A*N,C.y=-w*n+_,C.z=A*D,h.push(C.x,C.y,C.z),b.set(N,T,D).normalize(),f.push(b.x,b.y,b.z),p.push(P,1-w),E.push(m++)}y.push(E)}for(let x=0;x<i;x++)for(let E=0;E<s;E++){const w=y[E][x],A=y[E+1][x],R=y[E+1][x+1],P=y[E][x+1];(e>0||E!==0)&&(u.push(w,A,P),S+=3),(t>0||E!==s-1)&&(u.push(A,R,P),S+=3)}l.addGroup(g,S,0),g+=S}d(v,"generateTorso");function M(b){const C=m,S=new Ee,T=new U;let x=0;const E=b===!0?e:t,w=b===!0?1:-1;for(let R=1;R<=i;R++)h.push(0,_*w,0),f.push(0,w,0),p.push(.5,.5),m++;const A=m;for(let R=0;R<=i;R++){const I=R/i*c+a,N=Math.cos(I),D=Math.sin(I);T.x=E*D,T.y=_*w,T.z=E*N,h.push(T.x,T.y,T.z),f.push(0,w,0),S.x=N*.5+.5,S.y=D*.5*w+.5,p.push(S.x,S.y),m++}for(let R=0;R<i;R++){const P=C+R,I=A+R;b===!0?u.push(I,I+1,P):u.push(I+1,I,P),x+=3}l.addGroup(g,x,b===!0?1:2),g+=x}d(M,"generateCap")}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ih(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}};d(ih,"CylinderGeometry");let eo=ih;const sh=class sh extends eo{constructor(e=1,t=1,n=32,i=1,s=!1,o=0,a=Math.PI*2){super(0,e,t,n,i,s,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(e){return new sh(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}};d(sh,"ConeGeometry");let to=sh;const rh=class rh extends Qe{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};const s=[],o=[];a(i),l(n),u(),this.setAttribute("position",new Ve(s,3)),this.setAttribute("normal",new Ve(s.slice(),3)),this.setAttribute("uv",new Ve(o,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function a(v){const M=new U,b=new U,C=new U;for(let S=0;S<t.length;S+=3)p(t[S+0],M),p(t[S+1],b),p(t[S+2],C),c(M,b,C,v)}d(a,"subdivide");function c(v,M,b,C){const S=C+1,T=[];for(let x=0;x<=S;x++){T[x]=[];const E=v.clone().lerp(b,x/S),w=M.clone().lerp(b,x/S),A=S-x;for(let R=0;R<=A;R++)R===0&&x===S?T[x][R]=E:T[x][R]=E.clone().lerp(w,R/A)}for(let x=0;x<S;x++)for(let E=0;E<2*(S-x)-1;E++){const w=Math.floor(E/2);E%2===0?(f(T[x][w+1]),f(T[x+1][w]),f(T[x][w])):(f(T[x][w+1]),f(T[x+1][w+1]),f(T[x+1][w]))}}d(c,"subdivideFace");function l(v){const M=new U;for(let b=0;b<s.length;b+=3)M.x=s[b+0],M.y=s[b+1],M.z=s[b+2],M.normalize().multiplyScalar(v),s[b+0]=M.x,s[b+1]=M.y,s[b+2]=M.z}d(l,"applyRadius");function u(){const v=new U;for(let M=0;M<s.length;M+=3){v.x=s[M+0],v.y=s[M+1],v.z=s[M+2];const b=_(v)/2/Math.PI+.5,C=g(v)/Math.PI+.5;o.push(b,1-C)}m(),h()}d(u,"generateUVs");function h(){for(let v=0;v<o.length;v+=6){const M=o[v+0],b=o[v+2],C=o[v+4],S=Math.max(M,b,C),T=Math.min(M,b,C);S>.9&&T<.1&&(M<.2&&(o[v+0]+=1),b<.2&&(o[v+2]+=1),C<.2&&(o[v+4]+=1))}}d(h,"correctSeam");function f(v){s.push(v.x,v.y,v.z)}d(f,"pushVertex");function p(v,M){const b=v*3;M.x=e[b+0],M.y=e[b+1],M.z=e[b+2]}d(p,"getVertexByIndex");function m(){const v=new U,M=new U,b=new U,C=new U,S=new Ee,T=new Ee,x=new Ee;for(let E=0,w=0;E<s.length;E+=9,w+=6){v.set(s[E+0],s[E+1],s[E+2]),M.set(s[E+3],s[E+4],s[E+5]),b.set(s[E+6],s[E+7],s[E+8]),S.set(o[w+0],o[w+1]),T.set(o[w+2],o[w+3]),x.set(o[w+4],o[w+5]),C.copy(v).add(M).add(b).divideScalar(3);const A=_(C);y(S,w+0,v,A),y(T,w+2,M,A),y(x,w+4,b,A)}}d(m,"correctUVs");function y(v,M,b,C){C<0&&v.x===1&&(o[M]=v.x-1),b.x===0&&b.z===0&&(o[M]=C/2/Math.PI+.5)}d(y,"correctUV");function _(v){return Math.atan2(v.z,-v.x)}d(_,"azimuth");function g(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}d(g,"inclination")}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new rh(e.vertices,e.indices,e.radius,e.detail)}};d(rh,"PolyhedronGeometry");let us=rh;const oh=class oh extends us{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,i=1/n,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,o,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new oh(e.radius,e.detail)}};d(oh,"DodecahedronGeometry");let $l=oh;const gc=new U,_c=new U,pf=new U,yc=new ui,dg=class dg extends Qe{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const i=Math.pow(10,4),s=Math.cos(zs*t),o=e.getIndex(),a=e.getAttribute("position"),c=o?o.count:a.count,l=[0,0,0],u=["a","b","c"],h=new Array(3),f={},p=[];for(let m=0;m<c;m+=3){o?(l[0]=o.getX(m),l[1]=o.getX(m+1),l[2]=o.getX(m+2)):(l[0]=m,l[1]=m+1,l[2]=m+2);const{a:y,b:_,c:g}=yc;if(y.fromBufferAttribute(a,l[0]),_.fromBufferAttribute(a,l[1]),g.fromBufferAttribute(a,l[2]),yc.getNormal(pf),h[0]=`${Math.round(y.x*i)},${Math.round(y.y*i)},${Math.round(y.z*i)}`,h[1]=`${Math.round(_.x*i)},${Math.round(_.y*i)},${Math.round(_.z*i)}`,h[2]=`${Math.round(g.x*i)},${Math.round(g.y*i)},${Math.round(g.z*i)}`,!(h[0]===h[1]||h[1]===h[2]||h[2]===h[0]))for(let v=0;v<3;v++){const M=(v+1)%3,b=h[v],C=h[M],S=yc[u[v]],T=yc[u[M]],x=`${b}_${C}`,E=`${C}_${b}`;E in f&&f[E]?(pf.dot(f[E].normal)<=s&&(p.push(S.x,S.y,S.z),p.push(T.x,T.y,T.z)),f[E]=null):x in f||(f[x]={index0:l[v],index1:l[M],normal:pf.clone()})}}for(const m in f)if(f[m]){const{index0:y,index1:_}=f[m];gc.fromBufferAttribute(a,y),_c.fromBufferAttribute(a,_),p.push(gc.x,gc.y,gc.z),p.push(_c.x,_c.y,_c.z)}this.setAttribute("position",new Ve(p,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}};d(dg,"EdgesGeometry");let Xl=dg;const pg=class pg{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){Ue("Curve: .getPoint() not implemented.")}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)n=this.getPoint(o/e),s+=n.distanceTo(i),t.push(s),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){const n=this.getLengths();let i=0;const s=n.length;let o;t?o=t:o=e*n[s-1];let a=0,c=s-1,l;for(;a<=c;)if(i=Math.floor(a+(c-a)/2),l=n[i]-o,l<0)a=i+1;else if(l>0)c=i-1;else{c=i;break}if(i=c,n[i]===o)return i/(s-1);const u=n[i],f=n[i+1]-u,p=(o-u)/f;return(i+p)/(s-1)}getTangent(e,t){let i=e-1e-4,s=e+1e-4;i<0&&(i=0),s>1&&(s=1);const o=this.getPoint(i),a=this.getPoint(s),c=t||(o.isVector2?new Ee:new U);return c.copy(a).sub(o).normalize(),c}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){const n=new U,i=[],s=[],o=[],a=new U,c=new Je;for(let p=0;p<=e;p++){const m=p/e;i[p]=this.getTangentAt(m,new U)}s[0]=new U,o[0]=new U;let l=Number.MAX_VALUE;const u=Math.abs(i[0].x),h=Math.abs(i[0].y),f=Math.abs(i[0].z);u<=l&&(l=u,n.set(1,0,0)),h<=l&&(l=h,n.set(0,1,0)),f<=l&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let p=1;p<=e;p++){if(s[p]=s[p-1].clone(),o[p]=o[p-1].clone(),a.crossVectors(i[p-1],i[p]),a.length()>Number.EPSILON){a.normalize();const m=Math.acos(je(i[p-1].dot(i[p]),-1,1));s[p].applyMatrix4(c.makeRotationAxis(a,m))}o[p].crossVectors(i[p],s[p])}if(t===!0){let p=Math.acos(je(s[0].dot(s[e]),-1,1));p/=e,i[0].dot(a.crossVectors(s[0],s[e]))>0&&(p=-p);for(let m=1;m<=e;m++)s[m].applyMatrix4(c.makeRotationAxis(i[m],p*m)),o[m].crossVectors(i[m],s[m])}return{tangents:i,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}};d(pg,"Curve");let Ln=pg;const mg=class mg extends Ln{constructor(e=0,t=0,n=1,i=1,s=0,o=Math.PI*2,a=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=c}getPoint(e,t=new Ee){const n=t,i=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(o?s=0:s=i),this.aClockwise===!0&&!o&&(s===i?s=-i:s=s-i);const a=this.aStartAngle+e*s;let c=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){const u=Math.cos(this.aRotation),h=Math.sin(this.aRotation),f=c-this.aX,p=l-this.aY;c=f*u-p*h+this.aX,l=f*h+p*u+this.aY}return n.set(c,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}};d(mg,"EllipseCurve");let no=mg;const gg=class gg extends no{constructor(e,t,n,i,s,o){super(e,t,n,n,i,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};d(gg,"ArcCurve");let ql=gg;function Xp(){let r=0,e=0,t=0,n=0;function i(s,o,a,c){r=s,e=a,t=-3*s+3*o-2*a-c,n=2*s-2*o+a+c}return d(i,"init"),{initCatmullRom:d(function(s,o,a,c,l){i(o,a,l*(a-s),l*(c-o))},"initCatmullRom"),initNonuniformCatmullRom:d(function(s,o,a,c,l,u,h){let f=(o-s)/l-(a-s)/(l+u)+(a-o)/u,p=(a-o)/u-(c-o)/(u+h)+(c-a)/h;f*=u,p*=u,i(o,a,f,p)},"initNonuniformCatmullRom"),calc:d(function(s){const o=s*s,a=o*s;return r+e*s+t*o+n*a},"calc")}}d(Xp,"CubicPoly");const xc=new U,mf=new Xp,gf=new Xp,_f=new Xp,_g=class _g extends Ln{constructor(e=[],t=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=i}getPoint(e,t=new U){const n=t,i=this.points,s=i.length,o=(s-(this.closed?0:1))*e;let a=Math.floor(o),c=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:c===0&&a===s-1&&(a=s-2,c=1);let l,u;this.closed||a>0?l=i[(a-1)%s]:(xc.subVectors(i[0],i[1]).add(i[0]),l=xc);const h=i[a%s],f=i[(a+1)%s];if(this.closed||a+2<s?u=i[(a+2)%s]:(xc.subVectors(i[s-1],i[s-2]).add(i[s-1]),u=xc),this.curveType==="centripetal"||this.curveType==="chordal"){const p=this.curveType==="chordal"?.5:.25;let m=Math.pow(l.distanceToSquared(h),p),y=Math.pow(h.distanceToSquared(f),p),_=Math.pow(f.distanceToSquared(u),p);y<1e-4&&(y=1),m<1e-4&&(m=y),_<1e-4&&(_=y),mf.initNonuniformCatmullRom(l.x,h.x,f.x,u.x,m,y,_),gf.initNonuniformCatmullRom(l.y,h.y,f.y,u.y,m,y,_),_f.initNonuniformCatmullRom(l.z,h.z,f.z,u.z,m,y,_)}else this.curveType==="catmullrom"&&(mf.initCatmullRom(l.x,h.x,f.x,u.x,this.tension),gf.initCatmullRom(l.y,h.y,f.y,u.y,this.tension),_f.initCatmullRom(l.z,h.z,f.z,u.z,this.tension));return n.set(mf.calc(c),gf.calc(c),_f.calc(c)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(i.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const i=this.points[t];e.points.push(i.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(new U().fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};d(_g,"CatmullRomCurve3");let Yl=_g;function By(r,e,t,n,i){const s=(n-e)*.5,o=(i-t)*.5,a=r*r,c=r*a;return(2*t-2*n+s+o)*c+(-3*t+3*n-2*s-o)*a+s*r+t}d(By,"CatmullRom");function OM(r,e){const t=1-r;return t*t*e}d(OM,"QuadraticBezierP0");function UM(r,e){return 2*(1-r)*r*e}d(UM,"QuadraticBezierP1");function BM(r,e){return r*r*e}d(BM,"QuadraticBezierP2");function Ho(r,e,t,n){return OM(r,e)+UM(r,t)+BM(r,n)}d(Ho,"QuadraticBezier");function zM(r,e){const t=1-r;return t*t*t*e}d(zM,"CubicBezierP0");function kM(r,e){const t=1-r;return 3*t*t*r*e}d(kM,"CubicBezierP1");function VM(r,e){return 3*(1-r)*r*r*e}d(VM,"CubicBezierP2");function HM(r,e){return r*r*r*e}d(HM,"CubicBezierP3");function Go(r,e,t,n,i){return zM(r,e)+kM(r,t)+VM(r,n)+HM(r,i)}d(Go,"CubicBezier");const yg=class yg extends Ln{constructor(e=new Ee,t=new Ee,n=new Ee,i=new Ee){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new Ee){const n=t,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(Go(e,i.x,s.x,o.x,a.x),Go(e,i.y,s.y,o.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}};d(yg,"CubicBezierCurve");let la=yg;const xg=class xg extends Ln{constructor(e=new U,t=new U,n=new U,i=new U){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new U){const n=t,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(Go(e,i.x,s.x,o.x,a.x),Go(e,i.y,s.y,o.y,a.y),Go(e,i.z,s.z,o.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}};d(xg,"CubicBezierCurve3");let Zl=xg;const vg=class vg extends Ln{constructor(e=new Ee,t=new Ee){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new Ee){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new Ee){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}};d(vg,"LineCurve");let ua=vg;const bg=class bg extends Ln{constructor(e=new U,t=new U){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new U){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new U){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}};d(bg,"LineCurve3");let Kl=bg;const Sg=class Sg extends Ln{constructor(e=new Ee,t=new Ee,n=new Ee){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new Ee){const n=t,i=this.v0,s=this.v1,o=this.v2;return n.set(Ho(e,i.x,s.x,o.x),Ho(e,i.y,s.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}};d(Sg,"QuadraticBezierCurve");let ha=Sg;const Mg=class Mg extends Ln{constructor(e=new U,t=new U,n=new U){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new U){const n=t,i=this.v0,s=this.v1,o=this.v2;return n.set(Ho(e,i.x,s.x,o.x),Ho(e,i.y,s.y,o.y),Ho(e,i.z,s.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}};d(Mg,"QuadraticBezierCurve3");let fa=Mg;const wg=class wg extends Ln{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new Ee){const n=t,i=this.points,s=(i.length-1)*e,o=Math.floor(s),a=s-o,c=i[o===0?o:o-1],l=i[o],u=i[o>i.length-2?i.length-1:o+1],h=i[o>i.length-3?i.length-1:o+2];return n.set(By(a,c.x,l.x,u.x,h.x),By(a,c.y,l.y,u.y,h.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const i=this.points[t];e.points.push(i.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(new Ee().fromArray(i))}return this}};d(wg,"SplineCurve");let da=wg;var Jl=Object.freeze({__proto__:null,ArcCurve:ql,CatmullRomCurve3:Yl,CubicBezierCurve:la,CubicBezierCurve3:Zl,EllipseCurve:no,LineCurve:ua,LineCurve3:Kl,QuadraticBezierCurve:ha,QuadraticBezierCurve3:fa,SplineCurve:da});const Eg=class Eg extends Ln{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){const n=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new Jl[n](t,e))}return this}getPoint(e,t){const n=e*this.getLength(),i=this.getCurveLengths();let s=0;for(;s<i.length;){if(i[s]>=n){const o=i[s]-n,a=this.curves[s],c=a.getLength(),l=c===0?0:1-o/c;return a.getPointAt(l,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,i=this.curves.length;n<i;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let n;for(let i=0,s=this.curves;i<s.length;i++){const o=s[i],a=o.isEllipseCurve?e*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,c=o.getPoints(a);for(let l=0;l<c.length;l++){const u=c[l];n&&n.equals(u)||(t.push(u),n=u)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const i=e.curves[t];this.curves.push(i.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){const i=this.curves[t];e.curves.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const i=e.curves[t];this.curves.push(new Jl[i.type]().fromJSON(i))}return this}};d(Eg,"CurvePath");let jl=Eg;const Ag=class Ag extends jl{constructor(e){super(),this.type="Path",this.currentPoint=new Ee,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const n=new ua(this.currentPoint.clone(),new Ee(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,i){const s=new ha(this.currentPoint.clone(),new Ee(e,t),new Ee(n,i));return this.curves.push(s),this.currentPoint.set(n,i),this}bezierCurveTo(e,t,n,i,s,o){const a=new la(this.currentPoint.clone(),new Ee(e,t),new Ee(n,i),new Ee(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new da(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,i,s,o){const a=this.currentPoint.x,c=this.currentPoint.y;return this.absarc(e+a,t+c,n,i,s,o),this}absarc(e,t,n,i,s,o){return this.absellipse(e,t,n,n,i,s,o),this}ellipse(e,t,n,i,s,o,a,c){const l=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(e+l,t+u,n,i,s,o,a,c),this}absellipse(e,t,n,i,s,o,a,c){const l=new no(e,t,n,i,s,o,a,c);if(this.curves.length>0){const h=l.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(l);const u=l.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}};d(Ag,"Path");let io=Ag;const Tg=class Tg extends io{constructor(e){super(e),this.uuid=Dn(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,i=this.holes.length;n<i;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const i=e.holes[t];this.holes.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){const i=this.holes[t];e.holes.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const i=e.holes[t];this.holes.push(new io().fromJSON(i))}return this}};d(Tg,"Shape");let Ii=Tg;function GM(r,e,t=2){const n=e&&e.length,i=n?e[0]*t:r.length;let s=Kv(r,0,i,t,!0);const o=[];if(!s||s.next===s.prev)return o;let a,c,l;if(n&&(s=YM(r,e,s,t)),r.length>80*t){a=r[0],c=r[1];let u=a,h=c;for(let f=t;f<i;f+=t){const p=r[f],m=r[f+1];p<a&&(a=p),m<c&&(c=m),p>u&&(u=p),m>h&&(h=m)}l=Math.max(u-a,h-c),l=l!==0?32767/l:0}return pa(s,o,t,a,c,l,0),o}d(GM,"earcut");function Kv(r,e,t,n,i){let s;if(i===rw(r,e,t,n)>0)for(let o=e;o<t;o+=n)s=zy(o/n|0,r[o],r[o+1],s);else for(let o=t-n;o>=e;o-=n)s=zy(o/n|0,r[o],r[o+1],s);return s&&so(s,s.next)&&(ga(s),s=s.next),s}d(Kv,"linkedList");function Js(r,e){if(!r)return r;e||(e=r);let t=r,n;do if(n=!1,!t.steiner&&(so(t,t.next)||At(t.prev,t,t.next)===0)){if(ga(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}d(Js,"filterPoints");function pa(r,e,t,n,i,s,o){if(!r)return;!o&&s&&QM(r,n,i,s);let a=r;for(;r.prev!==r.next;){const c=r.prev,l=r.next;if(s?$M(r,n,i,s):WM(r)){e.push(c.i,r.i,l.i),ga(r),r=l.next,a=l.next;continue}if(r=l,r===a){o?o===1?(r=XM(Js(r),e),pa(r,e,t,n,i,s,2)):o===2&&qM(r,e,t,n,i,s):pa(Js(r),e,t,n,i,s,1);break}}}d(pa,"earcutLinked");function WM(r){const e=r.prev,t=r,n=r.next;if(At(e,t,n)>=0)return!1;const i=e.x,s=t.x,o=n.x,a=e.y,c=t.y,l=n.y,u=Math.min(i,s,o),h=Math.min(a,c,l),f=Math.max(i,s,o),p=Math.max(a,c,l);let m=n.next;for(;m!==e;){if(m.x>=u&&m.x<=f&&m.y>=h&&m.y<=p&&Ro(i,a,s,c,o,l,m.x,m.y)&&At(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}d(WM,"isEar");function $M(r,e,t,n){const i=r.prev,s=r,o=r.next;if(At(i,s,o)>=0)return!1;const a=i.x,c=s.x,l=o.x,u=i.y,h=s.y,f=o.y,p=Math.min(a,c,l),m=Math.min(u,h,f),y=Math.max(a,c,l),_=Math.max(u,h,f),g=hd(p,m,e,t,n),v=hd(y,_,e,t,n);let M=r.prevZ,b=r.nextZ;for(;M&&M.z>=g&&b&&b.z<=v;){if(M.x>=p&&M.x<=y&&M.y>=m&&M.y<=_&&M!==i&&M!==o&&Ro(a,u,c,h,l,f,M.x,M.y)&&At(M.prev,M,M.next)>=0||(M=M.prevZ,b.x>=p&&b.x<=y&&b.y>=m&&b.y<=_&&b!==i&&b!==o&&Ro(a,u,c,h,l,f,b.x,b.y)&&At(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;M&&M.z>=g;){if(M.x>=p&&M.x<=y&&M.y>=m&&M.y<=_&&M!==i&&M!==o&&Ro(a,u,c,h,l,f,M.x,M.y)&&At(M.prev,M,M.next)>=0)return!1;M=M.prevZ}for(;b&&b.z<=v;){if(b.x>=p&&b.x<=y&&b.y>=m&&b.y<=_&&b!==i&&b!==o&&Ro(a,u,c,h,l,f,b.x,b.y)&&At(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}d($M,"isEarHashed");function XM(r,e){let t=r;do{const n=t.prev,i=t.next.next;!so(n,i)&&jv(n,t,t.next,i)&&ma(n,i)&&ma(i,n)&&(e.push(n.i,t.i,i.i),ga(t),ga(t.next),t=r=i),t=t.next}while(t!==r);return Js(t)}d(XM,"cureLocalIntersections");function qM(r,e,t,n,i,s){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&nw(o,a)){let c=Qv(o,a);o=Js(o,o.next),c=Js(c,c.next),pa(o,e,t,n,i,s,0),pa(c,e,t,n,i,s,0);return}a=a.next}o=o.next}while(o!==r)}d(qM,"splitEarcut");function YM(r,e,t,n){const i=[];for(let s=0,o=e.length;s<o;s++){const a=e[s]*n,c=s<o-1?e[s+1]*n:r.length,l=Kv(r,a,c,n,!1);l===l.next&&(l.steiner=!0),i.push(tw(l))}i.sort(ZM);for(let s=0;s<i.length;s++)t=KM(i[s],t);return t}d(YM,"eliminateHoles");function ZM(r,e){let t=r.x-e.x;if(t===0&&(t=r.y-e.y,t===0)){const n=(r.next.y-r.y)/(r.next.x-r.x),i=(e.next.y-e.y)/(e.next.x-e.x);t=n-i}return t}d(ZM,"compareXYSlope");function KM(r,e){const t=JM(r,e);if(!t)return e;const n=Qv(t,r);return Js(n,n.next),Js(t,t.next)}d(KM,"eliminateHole");function JM(r,e){let t=e;const n=r.x,i=r.y;let s=-1/0,o;if(so(r,t))return t;do{if(so(r,t.next))return t.next;if(i<=t.y&&i>=t.next.y&&t.next.y!==t.y){const h=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(h<=n&&h>s&&(s=h,o=t.x<t.next.x?t:t.next,h===n))return o}t=t.next}while(t!==e);if(!o)return null;const a=o,c=o.x,l=o.y;let u=1/0;t=o;do{if(n>=t.x&&t.x>=c&&n!==t.x&&Jv(i<l?n:s,i,c,l,i<l?s:n,i,t.x,t.y)){const h=Math.abs(i-t.y)/(n-t.x);ma(t,r)&&(h<u||h===u&&(t.x>o.x||t.x===o.x&&jM(o,t)))&&(o=t,u=h)}t=t.next}while(t!==a);return o}d(JM,"findHoleBridge");function jM(r,e){return At(r.prev,r,e.prev)<0&&At(e.next,r,r.next)<0}d(jM,"sectorContainsSector");function QM(r,e,t,n){let i=r;do i.z===0&&(i.z=hd(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,ew(i)}d(QM,"indexCurve");function ew(r){let e,t=1;do{let n=r,i;r=null;let s=null;for(e=0;n;){e++;let o=n,a=0;for(let l=0;l<t&&(a++,o=o.nextZ,!!o);l++);let c=t;for(;a>0||c>0&&o;)a!==0&&(c===0||!o||n.z<=o.z)?(i=n,n=n.nextZ,a--):(i=o,o=o.nextZ,c--),s?s.nextZ=i:r=i,i.prevZ=s,s=i;n=o}s.nextZ=null,t*=2}while(e>1);return r}d(ew,"sortLinked");function hd(r,e,t,n,i){return r=(r-t)*i|0,e=(e-n)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r|e<<1}d(hd,"zOrder");function tw(r){let e=r,t=r;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==r);return t}d(tw,"getLeftmost");function Jv(r,e,t,n,i,s,o,a){return(i-o)*(e-a)>=(r-o)*(s-a)&&(r-o)*(n-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(i-o)*(n-a)}d(Jv,"pointInTriangle");function Ro(r,e,t,n,i,s,o,a){return!(r===o&&e===a)&&Jv(r,e,t,n,i,s,o,a)}d(Ro,"pointInTriangleExceptFirst");function nw(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!iw(r,e)&&(ma(r,e)&&ma(e,r)&&sw(r,e)&&(At(r.prev,r,e.prev)||At(r,e.prev,e))||so(r,e)&&At(r.prev,r,r.next)>0&&At(e.prev,e,e.next)>0)}d(nw,"isValidDiagonal");function At(r,e,t){return(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y)}d(At,"area");function so(r,e){return r.x===e.x&&r.y===e.y}d(so,"equals");function jv(r,e,t,n){const i=bc(At(r,e,t)),s=bc(At(r,e,n)),o=bc(At(t,n,r)),a=bc(At(t,n,e));return!!(i!==s&&o!==a||i===0&&vc(r,t,e)||s===0&&vc(r,n,e)||o===0&&vc(t,r,n)||a===0&&vc(t,e,n))}d(jv,"intersects");function vc(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}d(vc,"onSegment");function bc(r){return r>0?1:r<0?-1:0}d(bc,"sign");function iw(r,e){let t=r;do{if(t.i!==r.i&&t.next.i!==r.i&&t.i!==e.i&&t.next.i!==e.i&&jv(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}d(iw,"intersectsPolygon");function ma(r,e){return At(r.prev,r,r.next)<0?At(r,e,r.next)>=0&&At(r,r.prev,e)>=0:At(r,e,r.prev)<0||At(r,r.next,e)<0}d(ma,"locallyInside");function sw(r,e){let t=r,n=!1;const i=(r.x+e.x)/2,s=(r.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&i<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==r);return n}d(sw,"middleInside");function Qv(r,e){const t=fd(r.i,r.x,r.y),n=fd(e.i,e.x,e.y),i=r.next,s=e.prev;return r.next=e,e.prev=r,t.next=i,i.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}d(Qv,"splitPolygon");function zy(r,e,t,n){const i=fd(r,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}d(zy,"insertNode");function ga(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}d(ga,"removeNode");function fd(r,e,t){return{i:r,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}d(fd,"createNode");function rw(r,e,t,n){let i=0;for(let s=e,o=t-n;s<t;s+=n)i+=(r[o]-r[s])*(r[s+1]+r[o+1]),o=s;return i}d(rw,"signedArea");const Cg=class Cg{static triangulate(e,t,n=2){return GM(e,t,n)}};d(Cg,"Earcut");let dd=Cg;const ah=class ah{static area(e){const t=e.length;let n=0;for(let i=t-1,s=0;s<t;i=s++)n+=e[i].x*e[s].y-e[s].x*e[i].y;return n*.5}static isClockWise(e){return ah.area(e)<0}static triangulateShape(e,t){const n=[],i=[],s=[];ky(e),Vy(n,e);let o=e.length;t.forEach(ky);for(let c=0;c<t.length;c++)i.push(o),o+=t[c].length,Vy(n,t[c]);const a=dd.triangulate(n,i);for(let c=0;c<a.length;c+=3)s.push(a.slice(c,c+3));return s}};d(ah,"ShapeUtils");let Kn=ah;function ky(r){const e=r.length;e>2&&r[e-1].equals(r[0])&&r.pop()}d(ky,"removeDupEndPts");function Vy(r,e){for(let t=0;t<e.length;t++)r.push(e[t].x),r.push(e[t].y)}d(Vy,"addContour");const ch=class ch extends Qe{constructor(e=new Ii([new Ee(.5,.5),new Ee(-.5,.5),new Ee(-.5,-.5),new Ee(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,i=[],s=[];for(let a=0,c=e.length;a<c;a++){const l=e[a];o(l)}this.setAttribute("position",new Ve(i,3)),this.setAttribute("uv",new Ve(s,2)),this.computeVertexNormals();function o(a){const c=[],l=t.curveSegments!==void 0?t.curveSegments:12,u=t.steps!==void 0?t.steps:1,h=t.depth!==void 0?t.depth:1;let f=t.bevelEnabled!==void 0?t.bevelEnabled:!0,p=t.bevelThickness!==void 0?t.bevelThickness:.2,m=t.bevelSize!==void 0?t.bevelSize:p-.1,y=t.bevelOffset!==void 0?t.bevelOffset:0,_=t.bevelSegments!==void 0?t.bevelSegments:3;const g=t.extrudePath,v=t.UVGenerator!==void 0?t.UVGenerator:ow;let M,b=!1,C,S,T,x;if(g){M=g.getSpacedPoints(u),b=!0,f=!1;const ee=g.isCatmullRomCurve3?g.closed:!1;C=g.computeFrenetFrames(u,ee),S=new U,T=new U,x=new U}f||(_=0,p=0,m=0,y=0);const E=a.extractPoints(l);let w=E.shape;const A=E.holes;if(!Kn.isClockWise(w)){w=w.reverse();for(let ee=0,ne=A.length;ee<ne;ee++){const ie=A[ee];Kn.isClockWise(ie)&&(A[ee]=ie.reverse())}}function P(ee){const ie=10000000000000001e-36;let xe=ee[0];for(let $=1;$<=ee.length;$++){const be=$%ee.length,Ie=ee[be],Ne=Ie.x-xe.x,Ae=Ie.y-xe.y,V=Ne*Ne+Ae*Ae,F=Math.max(Math.abs(Ie.x),Math.abs(Ie.y),Math.abs(xe.x),Math.abs(xe.y)),j=ie*F*F;if(V<=j){ee.splice(be,1),$--;continue}xe=Ie}}d(P,"mergeOverlappingPoints"),P(w),A.forEach(P);const I=A.length,N=w;for(let ee=0;ee<I;ee++){const ne=A[ee];w=w.concat(ne)}function D(ee,ne,ie){return ne||Ye("ExtrudeGeometry: vec does not exist"),ee.clone().addScaledVector(ne,ie)}d(D,"scalePt2");const L=w.length;function H(ee,ne,ie){let xe,$,be;const Ie=ee.x-ne.x,Ne=ee.y-ne.y,Ae=ie.x-ee.x,V=ie.y-ee.y,F=Ie*Ie+Ne*Ne,j=Ie*V-Ne*Ae;if(Math.abs(j)>Number.EPSILON){const re=Math.sqrt(F),ge=Math.sqrt(Ae*Ae+V*V),ue=ne.x-Ne/re,Le=ne.y+Ie/re,Te=ie.x-V/ge,De=ie.y+Ae/ge,He=((Te-ue)*V-(De-Le)*Ae)/(Ie*V-Ne*Ae);xe=ue+Ie*He-ee.x,$=Le+Ne*He-ee.y;const de=xe*xe+$*$;if(de<=2)return new Ee(xe,$);be=Math.sqrt(de/2)}else{let re=!1;Ie>Number.EPSILON?Ae>Number.EPSILON&&(re=!0):Ie<-Number.EPSILON?Ae<-Number.EPSILON&&(re=!0):Math.sign(Ne)===Math.sign(V)&&(re=!0),re?(xe=-Ne,$=Ie,be=Math.sqrt(F)):(xe=Ie,$=Ne,be=Math.sqrt(F/2))}return new Ee(xe/be,$/be)}d(H,"getBevelVec");const X=[];for(let ee=0,ne=N.length,ie=ne-1,xe=ee+1;ee<ne;ee++,ie++,xe++)ie===ne&&(ie=0),xe===ne&&(xe=0),X[ee]=H(N[ee],N[ie],N[xe]);const O=[];let W,G=X.concat();for(let ee=0,ne=I;ee<ne;ee++){const ie=A[ee];W=[];for(let xe=0,$=ie.length,be=$-1,Ie=xe+1;xe<$;xe++,be++,Ie++)be===$&&(be=0),Ie===$&&(Ie=0),W[xe]=H(ie[xe],ie[be],ie[Ie]);O.push(W),G=G.concat(W)}let Q;if(_===0)Q=Kn.triangulateShape(N,A);else{const ee=[],ne=[];for(let ie=0;ie<_;ie++){const xe=ie/_,$=p*Math.cos(xe*Math.PI/2),be=m*Math.sin(xe*Math.PI/2)+y;for(let Ie=0,Ne=N.length;Ie<Ne;Ie++){const Ae=D(N[Ie],X[Ie],be);le(Ae.x,Ae.y,-$),xe===0&&ee.push(Ae)}for(let Ie=0,Ne=I;Ie<Ne;Ie++){const Ae=A[Ie];W=O[Ie];const V=[];for(let F=0,j=Ae.length;F<j;F++){const re=D(Ae[F],W[F],be);le(re.x,re.y,-$),xe===0&&V.push(re)}xe===0&&ne.push(V)}}Q=Kn.triangulateShape(ee,ne)}const z=Q.length,Z=m+y;for(let ee=0;ee<L;ee++){const ne=f?D(w[ee],G[ee],Z):w[ee];b?(T.copy(C.normals[0]).multiplyScalar(ne.x),S.copy(C.binormals[0]).multiplyScalar(ne.y),x.copy(M[0]).add(T).add(S),le(x.x,x.y,x.z)):le(ne.x,ne.y,0)}for(let ee=1;ee<=u;ee++)for(let ne=0;ne<L;ne++){const ie=f?D(w[ne],G[ne],Z):w[ne];b?(T.copy(C.normals[ee]).multiplyScalar(ie.x),S.copy(C.binormals[ee]).multiplyScalar(ie.y),x.copy(M[ee]).add(T).add(S),le(x.x,x.y,x.z)):le(ie.x,ie.y,h/u*ee)}for(let ee=_-1;ee>=0;ee--){const ne=ee/_,ie=p*Math.cos(ne*Math.PI/2),xe=m*Math.sin(ne*Math.PI/2)+y;for(let $=0,be=N.length;$<be;$++){const Ie=D(N[$],X[$],xe);le(Ie.x,Ie.y,h+ie)}for(let $=0,be=A.length;$<be;$++){const Ie=A[$];W=O[$];for(let Ne=0,Ae=Ie.length;Ne<Ae;Ne++){const V=D(Ie[Ne],W[Ne],xe);b?le(V.x,V.y+M[u-1].y,M[u-1].x+ie):le(V.x,V.y,h+ie)}}}q(),Y();function q(){const ee=i.length/3;if(f){let ne=0,ie=L*ne;for(let xe=0;xe<z;xe++){const $=Q[xe];ae($[2]+ie,$[1]+ie,$[0]+ie)}ne=u+_*2,ie=L*ne;for(let xe=0;xe<z;xe++){const $=Q[xe];ae($[0]+ie,$[1]+ie,$[2]+ie)}}else{for(let ne=0;ne<z;ne++){const ie=Q[ne];ae(ie[2],ie[1],ie[0])}for(let ne=0;ne<z;ne++){const ie=Q[ne];ae(ie[0]+L*u,ie[1]+L*u,ie[2]+L*u)}}n.addGroup(ee,i.length/3-ee,0)}d(q,"buildLidFaces");function Y(){const ee=i.length/3;let ne=0;K(N,ne),ne+=N.length;for(let ie=0,xe=A.length;ie<xe;ie++){const $=A[ie];K($,ne),ne+=$.length}n.addGroup(ee,i.length/3-ee,1)}d(Y,"buildSideFaces");function K(ee,ne){let ie=ee.length;for(;--ie>=0;){const xe=ie;let $=ie-1;$<0&&($=ee.length-1);for(let be=0,Ie=u+_*2;be<Ie;be++){const Ne=L*be,Ae=L*(be+1),V=ne+xe+Ne,F=ne+$+Ne,j=ne+$+Ae,re=ne+xe+Ae;me(V,F,j,re)}}}d(K,"sidewalls");function le(ee,ne,ie){c.push(ee),c.push(ne),c.push(ie)}d(le,"v");function ae(ee,ne,ie){ve(ee),ve(ne),ve(ie);const xe=i.length/3,$=v.generateTopUV(n,i,xe-3,xe-2,xe-1);he($[0]),he($[1]),he($[2])}d(ae,"f3");function me(ee,ne,ie,xe){ve(ee),ve(ne),ve(xe),ve(ne),ve(ie),ve(xe);const $=i.length/3,be=v.generateSideWallUV(n,i,$-6,$-3,$-2,$-1);he(be[0]),he(be[1]),he(be[3]),he(be[1]),he(be[2]),he(be[3])}d(me,"f4");function ve(ee){i.push(c[ee*3+0]),i.push(c[ee*3+1]),i.push(c[ee*3+2])}d(ve,"addVertex");function he(ee){s.push(ee.x),s.push(ee.y)}d(he,"addUV")}d(o,"addShape")}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options;return aw(t,n,e)}static fromJSON(e,t){const n=[];for(let s=0,o=e.shapes.length;s<o;s++){const a=t[e.shapes[s]];n.push(a)}const i=e.options.extrudePath;return i!==void 0&&(e.options.extrudePath=new Jl[i.type]().fromJSON(i)),new ch(n,e.options)}};d(ch,"ExtrudeGeometry");let Ql=ch;const ow={generateTopUV:d(function(r,e,t,n,i){const s=e[t*3],o=e[t*3+1],a=e[n*3],c=e[n*3+1],l=e[i*3],u=e[i*3+1];return[new Ee(s,o),new Ee(a,c),new Ee(l,u)]},"generateTopUV"),generateSideWallUV:d(function(r,e,t,n,i,s){const o=e[t*3],a=e[t*3+1],c=e[t*3+2],l=e[n*3],u=e[n*3+1],h=e[n*3+2],f=e[i*3],p=e[i*3+1],m=e[i*3+2],y=e[s*3],_=e[s*3+1],g=e[s*3+2];return Math.abs(a-u)<Math.abs(o-l)?[new Ee(o,1-c),new Ee(l,1-h),new Ee(f,1-m),new Ee(y,1-g)]:[new Ee(a,1-c),new Ee(u,1-h),new Ee(p,1-m),new Ee(_,1-g)]},"generateSideWallUV")};function aw(r,e,t){if(t.shapes=[],Array.isArray(r))for(let n=0,i=r.length;n<i;n++){const s=r[n];t.shapes.push(s.uuid)}else t.shapes.push(r.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}d(aw,"toJSON$1");const lh=class lh extends us{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,i=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(i,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new lh(e.radius,e.detail)}};d(lh,"IcosahedronGeometry");let eu=lh;const uh=class uh extends Qe{constructor(e=[new Ee(0,-.5),new Ee(.5,0),new Ee(0,.5)],t=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=je(i,0,Math.PI*2);const s=[],o=[],a=[],c=[],l=[],u=1/t,h=new U,f=new Ee,p=new U,m=new U,y=new U;let _=0,g=0;for(let v=0;v<=e.length-1;v++)switch(v){case 0:_=e[v+1].x-e[v].x,g=e[v+1].y-e[v].y,p.x=g*1,p.y=-_,p.z=g*0,y.copy(p),p.normalize(),c.push(p.x,p.y,p.z);break;case e.length-1:c.push(y.x,y.y,y.z);break;default:_=e[v+1].x-e[v].x,g=e[v+1].y-e[v].y,p.x=g*1,p.y=-_,p.z=g*0,m.copy(p),p.x+=y.x,p.y+=y.y,p.z+=y.z,p.normalize(),c.push(p.x,p.y,p.z),y.copy(m)}for(let v=0;v<=t;v++){const M=n+v*u*i,b=Math.sin(M),C=Math.cos(M);for(let S=0;S<=e.length-1;S++){h.x=e[S].x*b,h.y=e[S].y,h.z=e[S].x*C,o.push(h.x,h.y,h.z),f.x=v/t,f.y=S/(e.length-1),a.push(f.x,f.y);const T=c[3*S+0]*b,x=c[3*S+1],E=c[3*S+0]*C;l.push(T,x,E)}}for(let v=0;v<t;v++)for(let M=0;M<e.length-1;M++){const b=M+v*e.length,C=b,S=b+e.length,T=b+e.length+1,x=b+1;s.push(C,S,x),s.push(T,x,S)}this.setIndex(s),this.setAttribute("position",new Ve(o,3)),this.setAttribute("uv",new Ve(a,2)),this.setAttribute("normal",new Ve(l,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new uh(e.points,e.segments,e.phiStart,e.phiLength)}};d(uh,"LatheGeometry");let tu=uh;const hh=class hh extends us{constructor(e=1,t=0){const n=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],i=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(n,i,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new hh(e.radius,e.detail)}};d(hh,"OctahedronGeometry");let _a=hh;const fh=class fh extends Qe{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const s=e/2,o=t/2,a=Math.floor(n),c=Math.floor(i),l=a+1,u=c+1,h=e/a,f=t/c,p=[],m=[],y=[],_=[];for(let g=0;g<u;g++){const v=g*f-o;for(let M=0;M<l;M++){const b=M*h-s;m.push(b,-v,0),y.push(0,0,1),_.push(M/a),_.push(1-g/c)}}for(let g=0;g<c;g++)for(let v=0;v<a;v++){const M=v+l*g,b=v+l*(g+1),C=v+1+l*(g+1),S=v+1+l*g;p.push(M,b,S),p.push(b,C,S)}this.setIndex(p),this.setAttribute("position",new Ve(m,3)),this.setAttribute("normal",new Ve(y,3)),this.setAttribute("uv",new Ve(_,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new fh(e.width,e.height,e.widthSegments,e.heightSegments)}};d(fh,"PlaneGeometry");let ro=fh;const dh=class dh extends Qe{constructor(e=.5,t=1,n=32,i=1,s=0,o=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:i,thetaStart:s,thetaLength:o},n=Math.max(3,n),i=Math.max(1,i);const a=[],c=[],l=[],u=[];let h=e;const f=(t-e)/i,p=new U,m=new Ee;for(let y=0;y<=i;y++){for(let _=0;_<=n;_++){const g=s+_/n*o;p.x=h*Math.cos(g),p.y=h*Math.sin(g),c.push(p.x,p.y,p.z),l.push(0,0,1),m.x=(p.x/t+1)/2,m.y=(p.y/t+1)/2,u.push(m.x,m.y)}h+=f}for(let y=0;y<i;y++){const _=y*(n+1);for(let g=0;g<n;g++){const v=g+_,M=v,b=v+n+1,C=v+n+2,S=v+1;a.push(M,b,S),a.push(b,C,S)}}this.setIndex(a),this.setAttribute("position",new Ve(c,3)),this.setAttribute("normal",new Ve(l,3)),this.setAttribute("uv",new Ve(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new dh(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}};d(dh,"RingGeometry");let nu=dh;const ph=class ph extends Qe{constructor(e=new Ii([new Ee(0,.5),new Ee(-.5,-.5),new Ee(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const n=[],i=[],s=[],o=[];let a=0,c=0;if(Array.isArray(e)===!1)l(e);else for(let u=0;u<e.length;u++)l(e[u]),this.addGroup(a,c,u),a+=c,c=0;this.setIndex(n),this.setAttribute("position",new Ve(i,3)),this.setAttribute("normal",new Ve(s,3)),this.setAttribute("uv",new Ve(o,2));function l(u){const h=i.length/3,f=u.extractPoints(t);let p=f.shape;const m=f.holes;Kn.isClockWise(p)===!1&&(p=p.reverse());for(let _=0,g=m.length;_<g;_++){const v=m[_];Kn.isClockWise(v)===!0&&(m[_]=v.reverse())}const y=Kn.triangulateShape(p,m);for(let _=0,g=m.length;_<g;_++){const v=m[_];p=p.concat(v)}for(let _=0,g=p.length;_<g;_++){const v=p[_];i.push(v.x,v.y,0),s.push(0,0,1),o.push(v.x,v.y)}for(let _=0,g=y.length;_<g;_++){const v=y[_],M=v[0]+h,b=v[1]+h,C=v[2]+h;n.push(M,b,C),c+=3}}d(l,"addShape")}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return cw(t,e)}static fromJSON(e,t){const n=[];for(let i=0,s=e.shapes.length;i<s;i++){const o=t[e.shapes[i]];n.push(o)}return new ph(n,e.curveSegments)}};d(ph,"ShapeGeometry");let iu=ph;function cw(r,e){if(e.shapes=[],Array.isArray(r))for(let t=0,n=r.length;t<n;t++){const i=r[t];e.shapes.push(i.uuid)}else e.shapes.push(r.uuid);return e}d(cw,"toJSON");const mh=class mh extends Qe{constructor(e=1,t=32,n=16,i=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:s,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const c=Math.min(o+a,Math.PI);let l=0;const u=[],h=new U,f=new U,p=[],m=[],y=[],_=[];for(let g=0;g<=n;g++){const v=[],M=g/n;let b=0;g===0&&o===0?b=.5/t:g===n&&c===Math.PI&&(b=-.5/t);for(let C=0;C<=t;C++){const S=C/t;h.x=-e*Math.cos(i+S*s)*Math.sin(o+M*a),h.y=e*Math.cos(o+M*a),h.z=e*Math.sin(i+S*s)*Math.sin(o+M*a),m.push(h.x,h.y,h.z),f.copy(h).normalize(),y.push(f.x,f.y,f.z),_.push(S+b,1-M),v.push(l++)}u.push(v)}for(let g=0;g<n;g++)for(let v=0;v<t;v++){const M=u[g][v+1],b=u[g][v],C=u[g+1][v],S=u[g+1][v+1];(g!==0||o>0)&&p.push(M,b,S),(g!==n-1||c<Math.PI)&&p.push(b,C,S)}this.setIndex(p),this.setAttribute("position",new Ve(m,3)),this.setAttribute("normal",new Ve(y,3)),this.setAttribute("uv",new Ve(_,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new mh(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}};d(mh,"SphereGeometry");let js=mh;const gh=class gh extends us{constructor(e=1,t=0){const n=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],i=[2,1,0,0,3,2,1,3,0,2,3,1];super(n,i,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new gh(e.radius,e.detail)}};d(gh,"TetrahedronGeometry");let su=gh;const _h=class _h extends Qe{constructor(e=1,t=.4,n=12,i=48,s=Math.PI*2,o=0,a=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:i,arc:s,thetaStart:o,thetaLength:a},n=Math.floor(n),i=Math.floor(i);const c=[],l=[],u=[],h=[],f=new U,p=new U,m=new U;for(let y=0;y<=n;y++){const _=o+y/n*a;for(let g=0;g<=i;g++){const v=g/i*s;p.x=(e+t*Math.cos(_))*Math.cos(v),p.y=(e+t*Math.cos(_))*Math.sin(v),p.z=t*Math.sin(_),l.push(p.x,p.y,p.z),f.x=e*Math.cos(v),f.y=e*Math.sin(v),m.subVectors(p,f).normalize(),u.push(m.x,m.y,m.z),h.push(g/i),h.push(y/n)}}for(let y=1;y<=n;y++)for(let _=1;_<=i;_++){const g=(i+1)*y+_-1,v=(i+1)*(y-1)+_-1,M=(i+1)*(y-1)+_,b=(i+1)*y+_;c.push(g,v,b),c.push(v,M,b)}this.setIndex(c),this.setAttribute("position",new Ve(l,3)),this.setAttribute("normal",new Ve(u,3)),this.setAttribute("uv",new Ve(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new _h(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}};d(_h,"TorusGeometry");let ru=_h;const yh=class yh extends Qe{constructor(e=1,t=.4,n=64,i=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:i,p:s,q:o},n=Math.floor(n),i=Math.floor(i);const a=[],c=[],l=[],u=[],h=new U,f=new U,p=new U,m=new U,y=new U,_=new U,g=new U;for(let M=0;M<=n;++M){const b=M/n*s*Math.PI*2;v(b,s,o,e,p),v(b+.01,s,o,e,m),_.subVectors(m,p),g.addVectors(m,p),y.crossVectors(_,g),g.crossVectors(y,_),y.normalize(),g.normalize();for(let C=0;C<=i;++C){const S=C/i*Math.PI*2,T=-t*Math.cos(S),x=t*Math.sin(S);h.x=p.x+(T*g.x+x*y.x),h.y=p.y+(T*g.y+x*y.y),h.z=p.z+(T*g.z+x*y.z),c.push(h.x,h.y,h.z),f.subVectors(h,p).normalize(),l.push(f.x,f.y,f.z),u.push(M/n),u.push(C/i)}}for(let M=1;M<=n;M++)for(let b=1;b<=i;b++){const C=(i+1)*(M-1)+(b-1),S=(i+1)*M+(b-1),T=(i+1)*M+b,x=(i+1)*(M-1)+b;a.push(C,S,x),a.push(S,T,x)}this.setIndex(a),this.setAttribute("position",new Ve(c,3)),this.setAttribute("normal",new Ve(l,3)),this.setAttribute("uv",new Ve(u,2));function v(M,b,C,S,T){const x=Math.cos(M),E=Math.sin(M),w=C/b*M,A=Math.cos(w);T.x=S*(2+A)*.5*x,T.y=S*(2+A)*E*.5,T.z=S*Math.sin(w)*.5}d(v,"calculatePositionOnCurve")}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new yh(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}};d(yh,"TorusKnotGeometry");let ou=yh;const xh=class xh extends Qe{constructor(e=new fa(new U(-1,-1,0),new U(-1,1,0),new U(1,1,0)),t=64,n=1,i=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:i,closed:s};const o=e.computeFrenetFrames(t,s);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;const a=new U,c=new U,l=new Ee;let u=new U;const h=[],f=[],p=[],m=[];y(),this.setIndex(m),this.setAttribute("position",new Ve(h,3)),this.setAttribute("normal",new Ve(f,3)),this.setAttribute("uv",new Ve(p,2));function y(){for(let M=0;M<t;M++)_(M);_(s===!1?t:0),v(),g()}d(y,"generateBufferData");function _(M){u=e.getPointAt(M/t,u);const b=o.normals[M],C=o.binormals[M];for(let S=0;S<=i;S++){const T=S/i*Math.PI*2,x=Math.sin(T),E=-Math.cos(T);c.x=E*b.x+x*C.x,c.y=E*b.y+x*C.y,c.z=E*b.z+x*C.z,c.normalize(),f.push(c.x,c.y,c.z),a.x=u.x+n*c.x,a.y=u.y+n*c.y,a.z=u.z+n*c.z,h.push(a.x,a.y,a.z)}}d(_,"generateSegment");function g(){for(let M=1;M<=t;M++)for(let b=1;b<=i;b++){const C=(i+1)*(M-1)+(b-1),S=(i+1)*M+(b-1),T=(i+1)*M+b,x=(i+1)*(M-1)+b;m.push(C,S,x),m.push(S,T,x)}}d(g,"generateIndices");function v(){for(let M=0;M<=t;M++)for(let b=0;b<=i;b++)l.x=M/t,l.y=b/i,p.push(l.x,l.y)}d(v,"generateUVs")}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new xh(new Jl[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}};d(xh,"TubeGeometry");let au=xh;const Ig=class Ig extends Qe{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],n=new Set,i=new U,s=new U;if(e.index!==null){const o=e.attributes.position,a=e.index;let c=e.groups;c.length===0&&(c=[{start:0,count:a.count,materialIndex:0}]);for(let l=0,u=c.length;l<u;++l){const h=c[l],f=h.start,p=h.count;for(let m=f,y=f+p;m<y;m+=3)for(let _=0;_<3;_++){const g=a.getX(m+_),v=a.getX(m+(_+1)%3);i.fromBufferAttribute(o,g),s.fromBufferAttribute(o,v),Hy(i,s,n)===!0&&(t.push(i.x,i.y,i.z),t.push(s.x,s.y,s.z))}}}else{const o=e.attributes.position;for(let a=0,c=o.count/3;a<c;a++)for(let l=0;l<3;l++){const u=3*a+l,h=3*a+(l+1)%3;i.fromBufferAttribute(o,u),s.fromBufferAttribute(o,h),Hy(i,s,n)===!0&&(t.push(i.x,i.y,i.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new Ve(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}};d(Ig,"WireframeGeometry");let ya=Ig;function Hy(r,e,t){const n=`${r.x},${r.y},${r.z}-${e.x},${e.y},${e.z}`,i=`${e.x},${e.y},${e.z}-${r.x},${r.y},${r.z}`;return t.has(n)===!0||t.has(i)===!0?!1:(t.add(n),t.add(i),!0)}d(Hy,"isUniqueEdge");var Gy=Object.freeze({__proto__:null,BoxGeometry:Ks,CapsuleGeometry:Gl,CircleGeometry:Wl,ConeGeometry:to,CylinderGeometry:eo,DodecahedronGeometry:$l,EdgesGeometry:Xl,ExtrudeGeometry:Ql,IcosahedronGeometry:eu,LatheGeometry:tu,OctahedronGeometry:_a,PlaneGeometry:ro,PolyhedronGeometry:us,RingGeometry:nu,ShapeGeometry:iu,SphereGeometry:js,TetrahedronGeometry:su,TorusGeometry:ru,TorusKnotGeometry:ou,TubeGeometry:au,WireframeGeometry:ya});const Rg=class Rg extends zt{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new ke(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}};d(Rg,"ShadowMaterial");let cu=Rg;function oo(r){const e={};for(const t in r){e[t]={};for(const n in r[t]){const i=r[t][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(Ue("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=i.clone():Array.isArray(i)?e[t][n]=i.slice():e[t][n]=i}}return e}d(oo,"cloneUniforms");function ln(r){const e={};for(let t=0;t<r.length;t++){const n=oo(r[t]);for(const i in n)e[i]=n[i]}return e}d(ln,"mergeUniforms");function lw(r){const e=[];for(let t=0;t<r.length;t++)e.push(r[t].clone());return e}d(lw,"cloneUniformsGroups");function eb(r){const e=r.getRenderTarget();return e===null?r.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:lt.workingColorSpace}d(eb,"getUnlitUniformColorSpace");const Fh={clone:oo,merge:ln};var uw=`void main() {
|
|
3
3
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
4
4
|
}`,hw=`void main() {
|
|
@@ -4047,7 +4047,7 @@ void main() {
|
|
|
4047
4047
|
|
|
4048
4048
|
}
|
|
4049
4049
|
|
|
4050
|
-
}`,R_=class R_{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new ca(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new yn({vertexShader:pC,fragmentShader:mC,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new yt(new ro(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}};d(R_,"WebXRDepthSensing");let mp=R_;const P_=class P_ extends Vn{constructor(e,t){super();const n=this;let i=null,s=1,o=null,a="local-floor",c=1,l=null,u=null,h=null,f=null,p=null,m=null;const y=typeof XRWebGLBinding<"u",_=new mp,g={},v=t.getContextAttributes();let M=null,b=null;const C=[],S=[],T=new Ee;let x=null;const E=new Ut;E.viewport=new pt;const w=new Ut;w.viewport=new pt;const A=[E,w],R=new Cu;let P=null,I=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(q){let Y=C[q];return Y===void 0&&(Y=new kr,C[q]=Y),Y.getTargetRaySpace()},this.getControllerGrip=function(q){let Y=C[q];return Y===void 0&&(Y=new kr,C[q]=Y),Y.getGripSpace()},this.getHand=function(q){let Y=C[q];return Y===void 0&&(Y=new kr,C[q]=Y),Y.getHandSpace()};function N(q){const Y=S.indexOf(q.inputSource);if(Y===-1)return;const K=C[Y];K!==void 0&&(K.update(q.inputSource,q.frame,l||o),K.dispatchEvent({type:q.type,data:q.inputSource}))}d(N,"onSessionEvent");function D(){i.removeEventListener("select",N),i.removeEventListener("selectstart",N),i.removeEventListener("selectend",N),i.removeEventListener("squeeze",N),i.removeEventListener("squeezestart",N),i.removeEventListener("squeezeend",N),i.removeEventListener("end",D),i.removeEventListener("inputsourceschange",L);for(let q=0;q<C.length;q++){const Y=S[q];Y!==null&&(S[q]=null,C[q].disconnect(Y))}P=null,I=null,_.reset();for(const q in g)delete g[q];e.setRenderTarget(M),p=null,f=null,h=null,i=null,b=null,Z.stop(),n.isPresenting=!1,e.setPixelRatio(x),e.setSize(T.width,T.height,!1),n.dispatchEvent({type:"sessionend"})}d(D,"onSessionEnd"),this.setFramebufferScaleFactor=function(q){s=q,n.isPresenting===!0&&Ue("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(q){a=q,n.isPresenting===!0&&Ue("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(q){l=q},this.getBaseLayer=function(){return f!==null?f:p},this.getBinding=function(){return h===null&&y&&(h=new XRWebGLBinding(i,t)),h},this.getFrame=function(){return m},this.getSession=function(){return i},this.setSession=async function(q){if(i=q,i!==null){if(M=e.getRenderTarget(),i.addEventListener("select",N),i.addEventListener("selectstart",N),i.addEventListener("selectend",N),i.addEventListener("squeeze",N),i.addEventListener("squeezestart",N),i.addEventListener("squeezeend",N),i.addEventListener("end",D),i.addEventListener("inputsourceschange",L),v.xrCompatible!==!0&&await t.makeXRCompatible(),x=e.getPixelRatio(),e.getSize(T),y&&"createProjectionLayer"in XRWebGLBinding.prototype){let K=null,le=null,ae=null;v.depth&&(ae=v.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,K=v.stencil?ji:yi,le=v.stencil?Xr:kn);const me={colorFormat:t.RGBA8,depthFormat:ae,scaleFactor:s};h=this.getBinding(),f=h.createProjectionLayer(me),i.updateRenderState({layers:[f]}),e.setPixelRatio(1),e.setSize(f.textureWidth,f.textureHeight,!1),b=new _n(f.textureWidth,f.textureHeight,{format:mn,type:Sn,depthTexture:new ls(f.textureWidth,f.textureHeight,le,void 0,void 0,void 0,void 0,void 0,void 0,K),stencilBuffer:v.stencil,colorSpace:e.outputColorSpace,samples:v.antialias?4:0,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}else{const K={antialias:v.antialias,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:s};p=new XRWebGLLayer(i,t,K),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),b=new _n(p.framebufferWidth,p.framebufferHeight,{format:mn,type:Sn,colorSpace:e.outputColorSpace,stencilBuffer:v.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}b.isXRRenderTarget=!0,this.setFoveation(c),l=null,o=await i.requestReferenceSpace(a),Z.setContext(i),Z.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return _.getDepthTexture()};function L(q){for(let Y=0;Y<q.removed.length;Y++){const K=q.removed[Y],le=S.indexOf(K);le>=0&&(S[le]=null,C[le].disconnect(K))}for(let Y=0;Y<q.added.length;Y++){const K=q.added[Y];let le=S.indexOf(K);if(le===-1){for(let me=0;me<C.length;me++)if(me>=S.length){S.push(K),le=me;break}else if(S[me]===null){S[me]=K,le=me;break}if(le===-1)break}const ae=C[le];ae&&ae.connect(K)}}d(L,"onInputSourcesChange");const H=new U,X=new U;function O(q,Y,K){H.setFromMatrixPosition(Y.matrixWorld),X.setFromMatrixPosition(K.matrixWorld);const le=H.distanceTo(X),ae=Y.projectionMatrix.elements,me=K.projectionMatrix.elements,ve=ae[14]/(ae[10]-1),he=ae[14]/(ae[10]+1),ee=(ae[9]+1)/ae[5],ne=(ae[9]-1)/ae[5],ie=(ae[8]-1)/ae[0],xe=(me[8]+1)/me[0],$=ve*ie,be=ve*xe,Ie=le/(-ie+xe),Ne=Ie*-ie;if(Y.matrixWorld.decompose(q.position,q.quaternion,q.scale),q.translateX(Ne),q.translateZ(Ie),q.matrixWorld.compose(q.position,q.quaternion,q.scale),q.matrixWorldInverse.copy(q.matrixWorld).invert(),ae[10]===-1)q.projectionMatrix.copy(Y.projectionMatrix),q.projectionMatrixInverse.copy(Y.projectionMatrixInverse);else{const Ae=ve+Ie,V=he+Ie,F=$-Ne,j=be+(le-Ne),re=ee*he/V*Ae,ge=ne*he/V*Ae;q.projectionMatrix.makePerspective(F,j,re,ge,Ae,V),q.projectionMatrixInverse.copy(q.projectionMatrix).invert()}}d(O,"setProjectionFromUnion");function W(q,Y){Y===null?q.matrixWorld.copy(q.matrix):q.matrixWorld.multiplyMatrices(Y.matrixWorld,q.matrix),q.matrixWorldInverse.copy(q.matrixWorld).invert()}d(W,"updateCamera"),this.updateCamera=function(q){if(i===null)return;let Y=q.near,K=q.far;_.texture!==null&&(_.depthNear>0&&(Y=_.depthNear),_.depthFar>0&&(K=_.depthFar)),R.near=w.near=E.near=Y,R.far=w.far=E.far=K,(P!==R.near||I!==R.far)&&(i.updateRenderState({depthNear:R.near,depthFar:R.far}),P=R.near,I=R.far),R.layers.mask=q.layers.mask|6,E.layers.mask=R.layers.mask&-5,w.layers.mask=R.layers.mask&-3;const le=q.parent,ae=R.cameras;W(R,le);for(let me=0;me<ae.length;me++)W(ae[me],le);ae.length===2?O(R,E,w):R.projectionMatrix.copy(E.projectionMatrix),G(q,R,le)};function G(q,Y,K){K===null?q.matrix.copy(Y.matrixWorld):(q.matrix.copy(K.matrixWorld),q.matrix.invert(),q.matrix.multiply(Y.matrixWorld)),q.matrix.decompose(q.position,q.quaternion,q.scale),q.updateMatrixWorld(!0),q.projectionMatrix.copy(Y.projectionMatrix),q.projectionMatrixInverse.copy(Y.projectionMatrixInverse),q.isPerspectiveCamera&&(q.fov=qr*2*Math.atan(1/q.projectionMatrix.elements[5]),q.zoom=1)}d(G,"updateUserCamera"),this.getCamera=function(){return R},this.getFoveation=function(){if(!(f===null&&p===null))return c},this.setFoveation=function(q){c=q,f!==null&&(f.fixedFoveation=q),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=q)},this.hasDepthSensing=function(){return _.texture!==null},this.getDepthSensingMesh=function(){return _.getMesh(R)},this.getCameraTexture=function(q){return g[q]};let Q=null;function z(q,Y){if(u=Y.getViewerPose(l||o),m=Y,u!==null){const K=u.views;p!==null&&(e.setRenderTargetFramebuffer(b,p.framebuffer),e.setRenderTarget(b));let le=!1;K.length!==R.cameras.length&&(R.cameras.length=0,le=!0);for(let he=0;he<K.length;he++){const ee=K[he];let ne=null;if(p!==null)ne=p.getViewport(ee);else{const xe=h.getViewSubImage(f,ee);ne=xe.viewport,he===0&&(e.setRenderTargetTextures(b,xe.colorTexture,xe.depthStencilTexture),e.setRenderTarget(b))}let ie=A[he];ie===void 0&&(ie=new Ut,ie.layers.enable(he),ie.viewport=new pt,A[he]=ie),ie.matrix.fromArray(ee.transform.matrix),ie.matrix.decompose(ie.position,ie.quaternion,ie.scale),ie.projectionMatrix.fromArray(ee.projectionMatrix),ie.projectionMatrixInverse.copy(ie.projectionMatrix).invert(),ie.viewport.set(ne.x,ne.y,ne.width,ne.height),he===0&&(R.matrix.copy(ie.matrix),R.matrix.decompose(R.position,R.quaternion,R.scale)),le===!0&&R.cameras.push(ie)}const ae=i.enabledFeatures;if(ae&&ae.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&y){h=n.getBinding();const he=h.getDepthInformation(K[0]);he&&he.isValid&&he.texture&&_.init(he,i.renderState)}if(ae&&ae.includes("camera-access")&&y){e.state.unbindTexture(),h=n.getBinding();for(let he=0;he<K.length;he++){const ee=K[he].camera;if(ee){let ne=g[ee];ne||(ne=new ca,g[ee]=ne);const ie=h.getCameraImage(ee);ne.sourceTexture=ie}}}}for(let K=0;K<C.length;K++){const le=S[K],ae=C[K];le!==null&&ae!==void 0&&ae.update(le,Y,l||o)}Q&&Q(q,Y),Y.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:Y}),m=null}d(z,"onAnimationFrame");const Z=new sb;Z.setAnimationLoop(z),this.setAnimationLoop=function(q){Q=q},this.dispose=function(){}}};d(P_,"WebXRManager");let gp=P_;const Is=new rn,gC=new Je;function _C(r,e){function t(_,g){_.matrixAutoUpdate===!0&&_.updateMatrix(),g.value.copy(_.matrix)}d(t,"refreshTransformUniform");function n(_,g){g.color.getRGB(_.fogColor.value,eb(r)),g.isFog?(_.fogNear.value=g.near,_.fogFar.value=g.far):g.isFogExp2&&(_.fogDensity.value=g.density)}d(n,"refreshFogUniforms");function i(_,g,v,M,b){g.isMeshBasicMaterial?s(_,g):g.isMeshLambertMaterial?(s(_,g),g.envMap&&(_.envMapIntensity.value=g.envMapIntensity)):g.isMeshToonMaterial?(s(_,g),h(_,g)):g.isMeshPhongMaterial?(s(_,g),u(_,g),g.envMap&&(_.envMapIntensity.value=g.envMapIntensity)):g.isMeshStandardMaterial?(s(_,g),f(_,g),g.isMeshPhysicalMaterial&&p(_,g,b)):g.isMeshMatcapMaterial?(s(_,g),m(_,g)):g.isMeshDepthMaterial?s(_,g):g.isMeshDistanceMaterial?(s(_,g),y(_,g)):g.isMeshNormalMaterial?s(_,g):g.isLineBasicMaterial?(o(_,g),g.isLineDashedMaterial&&a(_,g)):g.isPointsMaterial?c(_,g,v,M):g.isSpriteMaterial?l(_,g):g.isShadowMaterial?(_.color.value.copy(g.color),_.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}d(i,"refreshMaterialUniforms");function s(_,g){_.opacity.value=g.opacity,g.color&&_.diffuse.value.copy(g.color),g.emissive&&_.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(_.map.value=g.map,t(g.map,_.mapTransform)),g.alphaMap&&(_.alphaMap.value=g.alphaMap,t(g.alphaMap,_.alphaMapTransform)),g.bumpMap&&(_.bumpMap.value=g.bumpMap,t(g.bumpMap,_.bumpMapTransform),_.bumpScale.value=g.bumpScale,g.side===gn&&(_.bumpScale.value*=-1)),g.normalMap&&(_.normalMap.value=g.normalMap,t(g.normalMap,_.normalMapTransform),_.normalScale.value.copy(g.normalScale),g.side===gn&&_.normalScale.value.negate()),g.displacementMap&&(_.displacementMap.value=g.displacementMap,t(g.displacementMap,_.displacementMapTransform),_.displacementScale.value=g.displacementScale,_.displacementBias.value=g.displacementBias),g.emissiveMap&&(_.emissiveMap.value=g.emissiveMap,t(g.emissiveMap,_.emissiveMapTransform)),g.specularMap&&(_.specularMap.value=g.specularMap,t(g.specularMap,_.specularMapTransform)),g.alphaTest>0&&(_.alphaTest.value=g.alphaTest);const v=e.get(g),M=v.envMap,b=v.envMapRotation;M&&(_.envMap.value=M,Is.copy(b),Is.x*=-1,Is.y*=-1,Is.z*=-1,M.isCubeTexture&&M.isRenderTargetTexture===!1&&(Is.y*=-1,Is.z*=-1),_.envMapRotation.value.setFromMatrix4(gC.makeRotationFromEuler(Is)),_.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,_.reflectivity.value=g.reflectivity,_.ior.value=g.ior,_.refractionRatio.value=g.refractionRatio),g.lightMap&&(_.lightMap.value=g.lightMap,_.lightMapIntensity.value=g.lightMapIntensity,t(g.lightMap,_.lightMapTransform)),g.aoMap&&(_.aoMap.value=g.aoMap,_.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,_.aoMapTransform))}d(s,"refreshUniformsCommon");function o(_,g){_.diffuse.value.copy(g.color),_.opacity.value=g.opacity,g.map&&(_.map.value=g.map,t(g.map,_.mapTransform))}d(o,"refreshUniformsLine");function a(_,g){_.dashSize.value=g.dashSize,_.totalSize.value=g.dashSize+g.gapSize,_.scale.value=g.scale}d(a,"refreshUniformsDash");function c(_,g,v,M){_.diffuse.value.copy(g.color),_.opacity.value=g.opacity,_.size.value=g.size*v,_.scale.value=M*.5,g.map&&(_.map.value=g.map,t(g.map,_.uvTransform)),g.alphaMap&&(_.alphaMap.value=g.alphaMap,t(g.alphaMap,_.alphaMapTransform)),g.alphaTest>0&&(_.alphaTest.value=g.alphaTest)}d(c,"refreshUniformsPoints");function l(_,g){_.diffuse.value.copy(g.color),_.opacity.value=g.opacity,_.rotation.value=g.rotation,g.map&&(_.map.value=g.map,t(g.map,_.mapTransform)),g.alphaMap&&(_.alphaMap.value=g.alphaMap,t(g.alphaMap,_.alphaMapTransform)),g.alphaTest>0&&(_.alphaTest.value=g.alphaTest)}d(l,"refreshUniformsSprites");function u(_,g){_.specular.value.copy(g.specular),_.shininess.value=Math.max(g.shininess,1e-4)}d(u,"refreshUniformsPhong");function h(_,g){g.gradientMap&&(_.gradientMap.value=g.gradientMap)}d(h,"refreshUniformsToon");function f(_,g){_.metalness.value=g.metalness,g.metalnessMap&&(_.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,_.metalnessMapTransform)),_.roughness.value=g.roughness,g.roughnessMap&&(_.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,_.roughnessMapTransform)),g.envMap&&(_.envMapIntensity.value=g.envMapIntensity)}d(f,"refreshUniformsStandard");function p(_,g,v){_.ior.value=g.ior,g.sheen>0&&(_.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),_.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(_.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,_.sheenColorMapTransform)),g.sheenRoughnessMap&&(_.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,_.sheenRoughnessMapTransform))),g.clearcoat>0&&(_.clearcoat.value=g.clearcoat,_.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(_.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,_.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(_.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,_.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(_.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,_.clearcoatNormalMapTransform),_.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===gn&&_.clearcoatNormalScale.value.negate())),g.dispersion>0&&(_.dispersion.value=g.dispersion),g.iridescence>0&&(_.iridescence.value=g.iridescence,_.iridescenceIOR.value=g.iridescenceIOR,_.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],_.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(_.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,_.iridescenceMapTransform)),g.iridescenceThicknessMap&&(_.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,_.iridescenceThicknessMapTransform))),g.transmission>0&&(_.transmission.value=g.transmission,_.transmissionSamplerMap.value=v.texture,_.transmissionSamplerSize.value.set(v.width,v.height),g.transmissionMap&&(_.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,_.transmissionMapTransform)),_.thickness.value=g.thickness,g.thicknessMap&&(_.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,_.thicknessMapTransform)),_.attenuationDistance.value=g.attenuationDistance,_.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(_.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(_.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,_.anisotropyMapTransform))),_.specularIntensity.value=g.specularIntensity,_.specularColor.value.copy(g.specularColor),g.specularColorMap&&(_.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,_.specularColorMapTransform)),g.specularIntensityMap&&(_.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,_.specularIntensityMapTransform))}d(p,"refreshUniformsPhysical");function m(_,g){g.matcap&&(_.matcap.value=g.matcap)}d(m,"refreshUniformsMatcap");function y(_,g){const v=e.get(g).light;_.referencePosition.value.setFromMatrixPosition(v.matrixWorld),_.nearDistance.value=v.shadow.camera.near,_.farDistance.value=v.shadow.camera.far}return d(y,"refreshUniformsDistance"),{refreshFogUniforms:n,refreshMaterialUniforms:i}}d(_C,"WebGLMaterials");function yC(r,e,t,n){let i={},s={},o=[];const a=r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS);function c(v,M){const b=M.program;n.uniformBlockBinding(v,b)}d(c,"bind");function l(v,M){let b=i[v.id];b===void 0&&(m(v),b=u(v),i[v.id]=b,v.addEventListener("dispose",_));const C=M.program;n.updateUBOMapping(v,C);const S=e.render.frame;s[v.id]!==S&&(f(v),s[v.id]=S)}d(l,"update");function u(v){const M=h();v.__bindingPointIndex=M;const b=r.createBuffer(),C=v.__size,S=v.usage;return r.bindBuffer(r.UNIFORM_BUFFER,b),r.bufferData(r.UNIFORM_BUFFER,C,S),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,M,b),b}d(u,"createBuffer");function h(){for(let v=0;v<a;v++)if(o.indexOf(v)===-1)return o.push(v),v;return Ye("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}d(h,"allocateBindingPointIndex");function f(v){const M=i[v.id],b=v.uniforms,C=v.__cache;r.bindBuffer(r.UNIFORM_BUFFER,M);for(let S=0,T=b.length;S<T;S++){const x=Array.isArray(b[S])?b[S]:[b[S]];for(let E=0,w=x.length;E<w;E++){const A=x[E];if(p(A,S,E,C)===!0){const R=A.__offset,P=Array.isArray(A.value)?A.value:[A.value];let I=0;for(let N=0;N<P.length;N++){const D=P[N],L=y(D);typeof D=="number"||typeof D=="boolean"?(A.__data[0]=D,r.bufferSubData(r.UNIFORM_BUFFER,R+I,A.__data)):D.isMatrix3?(A.__data[0]=D.elements[0],A.__data[1]=D.elements[1],A.__data[2]=D.elements[2],A.__data[3]=0,A.__data[4]=D.elements[3],A.__data[5]=D.elements[4],A.__data[6]=D.elements[5],A.__data[7]=0,A.__data[8]=D.elements[6],A.__data[9]=D.elements[7],A.__data[10]=D.elements[8],A.__data[11]=0):(D.toArray(A.__data,I),I+=L.storage/Float32Array.BYTES_PER_ELEMENT)}r.bufferSubData(r.UNIFORM_BUFFER,R,A.__data)}}}r.bindBuffer(r.UNIFORM_BUFFER,null)}d(f,"updateBufferData");function p(v,M,b,C){const S=v.value,T=M+"_"+b;if(C[T]===void 0)return typeof S=="number"||typeof S=="boolean"?C[T]=S:C[T]=S.clone(),!0;{const x=C[T];if(typeof S=="number"||typeof S=="boolean"){if(x!==S)return C[T]=S,!0}else if(x.equals(S)===!1)return x.copy(S),!0}return!1}d(p,"hasUniformChanged");function m(v){const M=v.uniforms;let b=0;const C=16;for(let T=0,x=M.length;T<x;T++){const E=Array.isArray(M[T])?M[T]:[M[T]];for(let w=0,A=E.length;w<A;w++){const R=E[w],P=Array.isArray(R.value)?R.value:[R.value];for(let I=0,N=P.length;I<N;I++){const D=P[I],L=y(D),H=b%C,X=H%L.boundary,O=H+X;b+=X,O!==0&&C-O<L.storage&&(b+=C-O),R.__data=new Float32Array(L.storage/Float32Array.BYTES_PER_ELEMENT),R.__offset=b,b+=L.storage}}}const S=b%C;return S>0&&(b+=C-S),v.__size=b,v.__cache={},this}d(m,"prepareUniformsGroup");function y(v){const M={boundary:0,storage:0};return typeof v=="number"||typeof v=="boolean"?(M.boundary=4,M.storage=4):v.isVector2?(M.boundary=8,M.storage=8):v.isVector3||v.isColor?(M.boundary=16,M.storage=12):v.isVector4?(M.boundary=16,M.storage=16):v.isMatrix3?(M.boundary=48,M.storage=48):v.isMatrix4?(M.boundary=64,M.storage=64):v.isTexture?Ue("WebGLRenderer: Texture samplers can not be part of an uniforms group."):Ue("WebGLRenderer: Unsupported uniform value type.",v),M}d(y,"getUniformSize");function _(v){const M=v.target;M.removeEventListener("dispose",_);const b=o.indexOf(M.__bindingPointIndex);o.splice(b,1),r.deleteBuffer(i[M.id]),delete i[M.id],delete s[M.id]}d(_,"onUniformsGroupsDispose");function g(){for(const v in i)r.deleteBuffer(i[v]);o=[],i={},s={}}return d(g,"dispose"),{bind:c,update:l,dispose:g}}d(yC,"WebGLUniformsGroups");const xC=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let ri=null;function vC(){return ri===null&&(ri=new Fn(xC,16,16,$s,_i),ri.name="DFG_LUT",ri.minFilter=wt,ri.magFilter=wt,ri.wrapS=Mn,ri.wrapT=Mn,ri.generateMipmaps=!1,ri.needsUpdate=!0),ri}d(vC,"getDFGLUT");const N_=class N_{constructor(e={}){const{canvas:t=Xv(),context:n=null,depth:i=!0,stencil:s=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1,reversedDepthBuffer:f=!1,outputBufferType:p=Sn}=e;this.isWebGLRenderer=!0;let m;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");m=n.getContextAttributes().alpha}else m=o;const y=p,_=new Set([Rh,Ih,Oa]),g=new Set([Sn,kn,$r,Xr,Ah,Th]),v=new Uint32Array(4),M=new Int32Array(4);let b=null,C=null;const S=[],T=[];let x=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=jn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const E=this;let w=!1;this._outputColorSpace=un;let A=0,R=0,P=null,I=-1,N=null;const D=new pt,L=new pt;let H=null;const X=new ke(0);let O=0,W=t.width,G=t.height,Q=1,z=null,Z=null;const q=new pt(0,0,W,G),Y=new pt(0,0,W,G);let K=!1;const le=new cs;let ae=!1,me=!1;const ve=new Je,he=new U,ee=new pt,ne={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ie=!1;function xe(){return P===null?Q:1}d(xe,"getTargetPixelRatio");let $=n;function be(B,te){return t.getContext(B,te)}d(be,"getContext");try{const B={alpha:!0,depth:i,stencil:s,antialias:a,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Mh}`),t.addEventListener("webglcontextlost",Pe,!1),t.addEventListener("webglcontextrestored",$e,!1),t.addEventListener("webglcontextcreationerror",at,!1),$===null){const te="webgl2";if($=be(te,B),$===null)throw be(te)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(B){throw Ye("WebGLRenderer: "+B.message),B}let Ie,Ne,Ae,V,F,j,re,ge,ue,Le,Te,De,He,de,Me,pe,Ce,we,Oe,J,_e,ye,Re;function Se(){Ie=new IA($),Ie.init(),_e=new lb($,Ie),Ne=new bA($,Ie,e,_e),Ae=new fC($,Ie),Ne.reversedDepthBuffer&&f&&Ae.buffers.depth.setReversed(!0),V=new NA($),F=new jT,j=new dC($,Ie,Ae,F,Ne,_e,V),re=new CA(E),ge=new Uw($),ye=new xA($,ge),ue=new RA($,ge,V,ye),Le=new FA($,ue,ge,ye,V),we=new DA($,Ne,j),Me=new SA(F),Te=new JT(E,re,Ie,Ne,ye,Me),De=new _C(E,F),He=new eC,de=new oC(Ie),Ce=new yA(E,re,Ae,Le,m,c),pe=new hC(E,Le,Ne),Re=new yC($,V,Ne,Ae),Oe=new vA($,Ie,V),J=new PA($,Ie,V),V.programs=Te.programs,E.capabilities=Ne,E.extensions=Ie,E.properties=F,E.renderLists=He,E.shadowMap=pe,E.state=Ae,E.info=V}d(Se,"initGLContext"),Se(),y!==Sn&&(x=new OA(y,t.width,t.height,i,s));const se=new gp(E,$);this.xr=se,this.getContext=function(){return $},this.getContextAttributes=function(){return $.getContextAttributes()},this.forceContextLoss=function(){const B=Ie.get("WEBGL_lose_context");B&&B.loseContext()},this.forceContextRestore=function(){const B=Ie.get("WEBGL_lose_context");B&&B.restoreContext()},this.getPixelRatio=function(){return Q},this.setPixelRatio=function(B){B!==void 0&&(Q=B,this.setSize(W,G,!1))},this.getSize=function(B){return B.set(W,G)},this.setSize=function(B,te,fe=!0){if(se.isPresenting){Ue("WebGLRenderer: Can't change size while VR device is presenting.");return}W=B,G=te,t.width=Math.floor(B*Q),t.height=Math.floor(te*Q),fe===!0&&(t.style.width=B+"px",t.style.height=te+"px"),x!==null&&x.setSize(t.width,t.height),this.setViewport(0,0,B,te)},this.getDrawingBufferSize=function(B){return B.set(W*Q,G*Q).floor()},this.setDrawingBufferSize=function(B,te,fe){W=B,G=te,Q=fe,t.width=Math.floor(B*fe),t.height=Math.floor(te*fe),this.setViewport(0,0,B,te)},this.setEffects=function(B){if(y===Sn){console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(B){for(let te=0;te<B.length;te++)if(B[te].isOutputPass===!0){console.warn("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}x.setEffects(B||[])},this.getCurrentViewport=function(B){return B.copy(D)},this.getViewport=function(B){return B.copy(q)},this.setViewport=function(B,te,fe,ce){B.isVector4?q.set(B.x,B.y,B.z,B.w):q.set(B,te,fe,ce),Ae.viewport(D.copy(q).multiplyScalar(Q).round())},this.getScissor=function(B){return B.copy(Y)},this.setScissor=function(B,te,fe,ce){B.isVector4?Y.set(B.x,B.y,B.z,B.w):Y.set(B,te,fe,ce),Ae.scissor(L.copy(Y).multiplyScalar(Q).round())},this.getScissorTest=function(){return K},this.setScissorTest=function(B){Ae.setScissorTest(K=B)},this.setOpaqueSort=function(B){z=B},this.setTransparentSort=function(B){Z=B},this.getClearColor=function(B){return B.copy(Ce.getClearColor())},this.setClearColor=function(){Ce.setClearColor(...arguments)},this.getClearAlpha=function(){return Ce.getClearAlpha()},this.setClearAlpha=function(){Ce.setClearAlpha(...arguments)},this.clear=function(B=!0,te=!0,fe=!0){let ce=0;if(B){let oe=!1;if(P!==null){const Be=P.texture.format;oe=_.has(Be)}if(oe){const Be=P.texture.type,Ge=g.has(Be),ze=Ce.getClearColor(),Xe=Ce.getClearAlpha(),Ze=ze.r,it=ze.g,ot=ze.b;Ge?(v[0]=Ze,v[1]=it,v[2]=ot,v[3]=Xe,$.clearBufferuiv($.COLOR,0,v)):(M[0]=Ze,M[1]=it,M[2]=ot,M[3]=Xe,$.clearBufferiv($.COLOR,0,M))}else ce|=$.COLOR_BUFFER_BIT}te&&(ce|=$.DEPTH_BUFFER_BIT),fe&&(ce|=$.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),ce!==0&&$.clear(ce)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Pe,!1),t.removeEventListener("webglcontextrestored",$e,!1),t.removeEventListener("webglcontextcreationerror",at,!1),Ce.dispose(),He.dispose(),de.dispose(),F.dispose(),re.dispose(),Le.dispose(),ye.dispose(),Re.dispose(),Te.dispose(),se.dispose(),se.removeEventListener("sessionstart",X_),se.removeEventListener("sessionend",q_),ps.stop()};function Pe(B){B.preventDefault(),ta("WebGLRenderer: Context Lost."),w=!0}d(Pe,"onContextLost");function $e(){ta("WebGLRenderer: Context Restored."),w=!1;const B=V.autoReset,te=pe.enabled,fe=pe.autoUpdate,ce=pe.needsUpdate,oe=pe.type;Se(),V.autoReset=B,pe.enabled=te,pe.autoUpdate=fe,pe.needsUpdate=ce,pe.type=oe}d($e,"onContextRestore");function at(B){Ye("WebGLRenderer: A WebGL context could not be created. Reason: ",B.statusMessage)}d(at,"onContextCreationError");function ct(B){const te=B.target;te.removeEventListener("dispose",ct),Gn(te)}d(ct,"onMaterialDispose");function Gn(B){an(B),F.remove(B)}d(Gn,"deallocateMaterial");function an(B){const te=F.get(B).programs;te!==void 0&&(te.forEach(function(fe){Te.releaseProgram(fe)}),B.isShaderMaterial&&Te.releaseShaderCache(B))}d(an,"releaseMaterialProgramReferences"),this.renderBufferDirect=function(B,te,fe,ce,oe,Be){te===null&&(te=ne);const Ge=oe.isMesh&&oe.matrixWorld.determinant()<0,ze=Lb(B,te,fe,ce,oe);Ae.setMaterial(ce,Ge);let Xe=fe.index,Ze=1;if(ce.wireframe===!0){if(Xe=ue.getWireframeAttribute(fe),Xe===void 0)return;Ze=2}const it=fe.drawRange,ot=fe.attributes.position;let Ke=it.start*Ze,xt=(it.start+it.count)*Ze;Be!==null&&(Ke=Math.max(Ke,Be.start*Ze),xt=Math.min(xt,(Be.start+Be.count)*Ze)),Xe!==null?(Ke=Math.max(Ke,0),xt=Math.min(xt,Xe.count)):ot!=null&&(Ke=Math.max(Ke,0),xt=Math.min(xt,ot.count));const Rt=xt-Ke;if(Rt<0||Rt===1/0)return;ye.setup(oe,ce,ze,fe,Xe);let Tt,vt=Oe;if(Xe!==null&&(Tt=ge.get(Xe),vt=J,vt.setIndex(Tt)),oe.isMesh)ce.wireframe===!0?(Ae.setLineWidth(ce.wireframeLinewidth*xe()),vt.setMode($.LINES)):vt.setMode($.TRIANGLES);else if(oe.isLine){let jt=ce.linewidth;jt===void 0&&(jt=1),Ae.setLineWidth(jt*xe()),oe.isLineSegments?vt.setMode($.LINES):oe.isLineLoop?vt.setMode($.LINE_LOOP):vt.setMode($.LINE_STRIP)}else oe.isPoints?vt.setMode($.POINTS):oe.isSprite&&vt.setMode($.TRIANGLES);if(oe.isBatchedMesh)if(oe._multiDrawInstances!==null)na("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),vt.renderMultiDrawInstances(oe._multiDrawStarts,oe._multiDrawCounts,oe._multiDrawCount,oe._multiDrawInstances);else if(Ie.get("WEBGL_multi_draw"))vt.renderMultiDraw(oe._multiDrawStarts,oe._multiDrawCounts,oe._multiDrawCount);else{const jt=oe._multiDrawStarts,qe=oe._multiDrawCounts,Tn=oe._multiDrawCount,dt=Xe?ge.get(Xe).bytesPerElement:1,Wn=F.get(ce).currentProgram.getUniforms();for(let ti=0;ti<Tn;ti++)Wn.setValue($,"_gl_DrawID",ti),vt.render(jt[ti]/dt,qe[ti])}else if(oe.isInstancedMesh)vt.renderInstances(Ke,Rt,oe.count);else if(fe.isInstancedBufferGeometry){const jt=fe._maxInstanceCount!==void 0?fe._maxInstanceCount:1/0,qe=Math.min(fe.instanceCount,jt);vt.renderInstances(Ke,Rt,qe)}else vt.render(Ke,Rt)};function Oi(B,te,fe){B.transparent===!0&&B.side===Bt&&B.forceSinglePass===!1?(B.side=gn,B.needsUpdate=!0,ka(B,te,fe),B.side=zn,B.needsUpdate=!0,ka(B,te,fe),B.side=Bt):ka(B,te,fe)}d(Oi,"prepareMaterial"),this.compile=function(B,te,fe=null){fe===null&&(fe=B),C=de.get(fe),C.init(te),T.push(C),fe.traverseVisible(function(oe){oe.isLight&&oe.layers.test(te.layers)&&(C.pushLight(oe),oe.castShadow&&C.pushShadow(oe))}),B!==fe&&B.traverseVisible(function(oe){oe.isLight&&oe.layers.test(te.layers)&&(C.pushLight(oe),oe.castShadow&&C.pushShadow(oe))}),C.setupLights();const ce=new Set;return B.traverse(function(oe){if(!(oe.isMesh||oe.isPoints||oe.isLine||oe.isSprite))return;const Be=oe.material;if(Be)if(Array.isArray(Be))for(let Ge=0;Ge<Be.length;Ge++){const ze=Be[Ge];Oi(ze,fe,oe),ce.add(ze)}else Oi(Be,fe,oe),ce.add(Be)}),C=T.pop(),ce},this.compileAsync=function(B,te,fe=null){const ce=this.compile(B,te,fe);return new Promise(oe=>{function Be(){if(ce.forEach(function(Ge){F.get(Ge).currentProgram.isReady()&&ce.delete(Ge)}),ce.size===0){oe(B);return}setTimeout(Be,10)}d(Be,"checkMaterialsReady"),Ie.get("KHR_parallel_shader_compile")!==null?Be():setTimeout(Be,10)})};let Bh=null;function Fb(B){Bh&&Bh(B)}d(Fb,"onAnimationFrame");function X_(){ps.stop()}d(X_,"onXRSessionStart");function q_(){ps.start()}d(q_,"onXRSessionEnd");const ps=new sb;ps.setAnimationLoop(Fb),typeof self<"u"&&ps.setContext(self),this.setAnimationLoop=function(B){Bh=B,se.setAnimationLoop(B),B===null?ps.stop():ps.start()},se.addEventListener("sessionstart",X_),se.addEventListener("sessionend",q_),this.render=function(B,te){if(te!==void 0&&te.isCamera!==!0){Ye("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(w===!0)return;const fe=se.enabled===!0&&se.isPresenting===!0,ce=x!==null&&(P===null||fe)&&x.begin(E,P);if(B.matrixWorldAutoUpdate===!0&&B.updateMatrixWorld(),te.parent===null&&te.matrixWorldAutoUpdate===!0&&te.updateMatrixWorld(),se.enabled===!0&&se.isPresenting===!0&&(x===null||x.isCompositing()===!1)&&(se.cameraAutoUpdate===!0&&se.updateCamera(te),te=se.getCamera()),B.isScene===!0&&B.onBeforeRender(E,B,te,P),C=de.get(B,T.length),C.init(te),T.push(C),ve.multiplyMatrices(te.projectionMatrix,te.matrixWorldInverse),le.setFromProjectionMatrix(ve,Rn,te.reversedDepth),me=this.localClippingEnabled,ae=Me.init(this.clippingPlanes,me),b=He.get(B,S.length),b.init(),S.push(b),se.enabled===!0&&se.isPresenting===!0){const Ge=E.xr.getDepthSensingMesh();Ge!==null&&zh(Ge,te,-1/0,E.sortObjects)}zh(B,te,0,E.sortObjects),b.finish(),E.sortObjects===!0&&b.sort(z,Z),ie=se.enabled===!1||se.isPresenting===!1||se.hasDepthSensing()===!1,ie&&Ce.addToRenderList(b,B),this.info.render.frame++,ae===!0&&Me.beginShadows();const oe=C.state.shadowsArray;if(pe.render(oe,B,te),ae===!0&&Me.endShadows(),this.info.autoReset===!0&&this.info.reset(),(ce&&x.hasRenderPass())===!1){const Ge=b.opaque,ze=b.transmissive;if(C.setupLights(),te.isArrayCamera){const Xe=te.cameras;if(ze.length>0)for(let Ze=0,it=Xe.length;Ze<it;Ze++){const ot=Xe[Ze];Z_(Ge,ze,B,ot)}ie&&Ce.render(B);for(let Ze=0,it=Xe.length;Ze<it;Ze++){const ot=Xe[Ze];Y_(b,B,ot,ot.viewport)}}else ze.length>0&&Z_(Ge,ze,B,te),ie&&Ce.render(B),Y_(b,B,te)}P!==null&&R===0&&(j.updateMultisampleRenderTarget(P),j.updateRenderTargetMipmap(P)),ce&&x.end(E),B.isScene===!0&&B.onAfterRender(E,B,te),ye.resetDefaultState(),I=-1,N=null,T.pop(),T.length>0?(C=T[T.length-1],ae===!0&&Me.setGlobalState(E.clippingPlanes,C.state.camera)):C=null,S.pop(),S.length>0?b=S[S.length-1]:b=null};function zh(B,te,fe,ce){if(B.visible===!1)return;if(B.layers.test(te.layers)){if(B.isGroup)fe=B.renderOrder;else if(B.isLOD)B.autoUpdate===!0&&B.update(te);else if(B.isLight)C.pushLight(B),B.castShadow&&C.pushShadow(B);else if(B.isSprite){if(!B.frustumCulled||le.intersectsSprite(B)){ce&&ee.setFromMatrixPosition(B.matrixWorld).applyMatrix4(ve);const Ge=Le.update(B),ze=B.material;ze.visible&&b.push(B,Ge,ze,fe,ee.z,null)}}else if((B.isMesh||B.isLine||B.isPoints)&&(!B.frustumCulled||le.intersectsObject(B))){const Ge=Le.update(B),ze=B.material;if(ce&&(B.boundingSphere!==void 0?(B.boundingSphere===null&&B.computeBoundingSphere(),ee.copy(B.boundingSphere.center)):(Ge.boundingSphere===null&&Ge.computeBoundingSphere(),ee.copy(Ge.boundingSphere.center)),ee.applyMatrix4(B.matrixWorld).applyMatrix4(ve)),Array.isArray(ze)){const Xe=Ge.groups;for(let Ze=0,it=Xe.length;Ze<it;Ze++){const ot=Xe[Ze],Ke=ze[ot.materialIndex];Ke&&Ke.visible&&b.push(B,Ge,Ke,fe,ee.z,ot)}}else ze.visible&&b.push(B,Ge,ze,fe,ee.z,null)}}const Be=B.children;for(let Ge=0,ze=Be.length;Ge<ze;Ge++)zh(Be[Ge],te,fe,ce)}d(zh,"projectObject");function Y_(B,te,fe,ce){const{opaque:oe,transmissive:Be,transparent:Ge}=B;C.setupLightsView(fe),ae===!0&&Me.setGlobalState(E.clippingPlanes,fe),ce&&Ae.viewport(D.copy(ce)),oe.length>0&&za(oe,te,fe),Be.length>0&&za(Be,te,fe),Ge.length>0&&za(Ge,te,fe),Ae.buffers.depth.setTest(!0),Ae.buffers.depth.setMask(!0),Ae.buffers.color.setMask(!0),Ae.setPolygonOffset(!1)}d(Y_,"renderScene");function Z_(B,te,fe,ce){if((fe.isScene===!0?fe.overrideMaterial:null)!==null)return;if(C.state.transmissionRenderTarget[ce.id]===void 0){const Ke=Ie.has("EXT_color_buffer_half_float")||Ie.has("EXT_color_buffer_float");C.state.transmissionRenderTarget[ce.id]=new _n(1,1,{generateMipmaps:!0,type:Ke?_i:Sn,minFilter:fi,samples:Math.max(4,Ne.samples),stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:lt.workingColorSpace})}const Be=C.state.transmissionRenderTarget[ce.id],Ge=ce.viewport||D;Be.setSize(Ge.z*E.transmissionResolutionScale,Ge.w*E.transmissionResolutionScale);const ze=E.getRenderTarget(),Xe=E.getActiveCubeFace(),Ze=E.getActiveMipmapLevel();E.setRenderTarget(Be),E.getClearColor(X),O=E.getClearAlpha(),O<1&&E.setClearColor(16777215,.5),E.clear(),ie&&Ce.render(fe);const it=E.toneMapping;E.toneMapping=jn;const ot=ce.viewport;if(ce.viewport!==void 0&&(ce.viewport=void 0),C.setupLightsView(ce),ae===!0&&Me.setGlobalState(E.clippingPlanes,ce),za(B,fe,ce),j.updateMultisampleRenderTarget(Be),j.updateRenderTargetMipmap(Be),Ie.has("WEBGL_multisampled_render_to_texture")===!1){let Ke=!1;for(let xt=0,Rt=te.length;xt<Rt;xt++){const Tt=te[xt],{object:vt,geometry:jt,material:qe,group:Tn}=Tt;if(qe.side===Bt&&vt.layers.test(ce.layers)){const dt=qe.side;qe.side=gn,qe.needsUpdate=!0,K_(vt,fe,ce,jt,qe,Tn),qe.side=dt,qe.needsUpdate=!0,Ke=!0}}Ke===!0&&(j.updateMultisampleRenderTarget(Be),j.updateRenderTargetMipmap(Be))}E.setRenderTarget(ze,Xe,Ze),E.setClearColor(X,O),ot!==void 0&&(ce.viewport=ot),E.toneMapping=it}d(Z_,"renderTransmissionPass");function za(B,te,fe){const ce=te.isScene===!0?te.overrideMaterial:null;for(let oe=0,Be=B.length;oe<Be;oe++){const Ge=B[oe],{object:ze,geometry:Xe,group:Ze}=Ge;let it=Ge.material;it.allowOverride===!0&&ce!==null&&(it=ce),ze.layers.test(fe.layers)&&K_(ze,te,fe,Xe,it,Ze)}}d(za,"renderObjects");function K_(B,te,fe,ce,oe,Be){B.onBeforeRender(E,te,fe,ce,oe,Be),B.modelViewMatrix.multiplyMatrices(fe.matrixWorldInverse,B.matrixWorld),B.normalMatrix.getNormalMatrix(B.modelViewMatrix),oe.onBeforeRender(E,te,fe,ce,B,Be),oe.transparent===!0&&oe.side===Bt&&oe.forceSinglePass===!1?(oe.side=gn,oe.needsUpdate=!0,E.renderBufferDirect(fe,te,ce,oe,B,Be),oe.side=zn,oe.needsUpdate=!0,E.renderBufferDirect(fe,te,ce,oe,B,Be),oe.side=Bt):E.renderBufferDirect(fe,te,ce,oe,B,Be),B.onAfterRender(E,te,fe,ce,oe,Be)}d(K_,"renderObject");function ka(B,te,fe){te.isScene!==!0&&(te=ne);const ce=F.get(B),oe=C.state.lights,Be=C.state.shadowsArray,Ge=oe.state.version,ze=Te.getParameters(B,oe.state,Be,te,fe),Xe=Te.getProgramCacheKey(ze);let Ze=ce.programs;ce.environment=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?te.environment:null,ce.fog=te.fog;const it=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap;ce.envMap=re.get(B.envMap||ce.environment,it),ce.envMapRotation=ce.environment!==null&&B.envMap===null?te.environmentRotation:B.envMapRotation,Ze===void 0&&(B.addEventListener("dispose",ct),Ze=new Map,ce.programs=Ze);let ot=Ze.get(Xe);if(ot!==void 0){if(ce.currentProgram===ot&&ce.lightsStateVersion===Ge)return j_(B,ze),ot}else ze.uniforms=Te.getUniforms(B),B.onBeforeCompile(ze,E),ot=Te.acquireProgram(ze,Xe),Ze.set(Xe,ot),ce.uniforms=ze.uniforms;const Ke=ce.uniforms;return(!B.isShaderMaterial&&!B.isRawShaderMaterial||B.clipping===!0)&&(Ke.clippingPlanes=Me.uniform),j_(B,ze),ce.needsLights=Ub(B),ce.lightsStateVersion=Ge,ce.needsLights&&(Ke.ambientLightColor.value=oe.state.ambient,Ke.lightProbe.value=oe.state.probe,Ke.directionalLights.value=oe.state.directional,Ke.directionalLightShadows.value=oe.state.directionalShadow,Ke.spotLights.value=oe.state.spot,Ke.spotLightShadows.value=oe.state.spotShadow,Ke.rectAreaLights.value=oe.state.rectArea,Ke.ltc_1.value=oe.state.rectAreaLTC1,Ke.ltc_2.value=oe.state.rectAreaLTC2,Ke.pointLights.value=oe.state.point,Ke.pointLightShadows.value=oe.state.pointShadow,Ke.hemisphereLights.value=oe.state.hemi,Ke.directionalShadowMatrix.value=oe.state.directionalShadowMatrix,Ke.spotLightMatrix.value=oe.state.spotLightMatrix,Ke.spotLightMap.value=oe.state.spotLightMap,Ke.pointShadowMatrix.value=oe.state.pointShadowMatrix),ce.currentProgram=ot,ce.uniformsList=null,ot}d(ka,"getProgram");function J_(B){if(B.uniformsList===null){const te=B.currentProgram.getUniforms();B.uniformsList=Vr.seqWithValue(te.seq,B.uniforms)}return B.uniformsList}d(J_,"getUniformList");function j_(B,te){const fe=F.get(B);fe.outputColorSpace=te.outputColorSpace,fe.batching=te.batching,fe.batchingColor=te.batchingColor,fe.instancing=te.instancing,fe.instancingColor=te.instancingColor,fe.instancingMorph=te.instancingMorph,fe.skinning=te.skinning,fe.morphTargets=te.morphTargets,fe.morphNormals=te.morphNormals,fe.morphColors=te.morphColors,fe.morphTargetsCount=te.morphTargetsCount,fe.numClippingPlanes=te.numClippingPlanes,fe.numIntersection=te.numClipIntersection,fe.vertexAlphas=te.vertexAlphas,fe.vertexTangents=te.vertexTangents,fe.toneMapping=te.toneMapping}d(j_,"updateCommonMaterialProperties");function Lb(B,te,fe,ce,oe){te.isScene!==!0&&(te=ne),j.resetTextureUnits();const Be=te.fog,Ge=ce.isMeshStandardMaterial||ce.isMeshLambertMaterial||ce.isMeshPhongMaterial?te.environment:null,ze=P===null?E.outputColorSpace:P.isXRRenderTarget===!0?P.texture.colorSpace:Xs,Xe=ce.isMeshStandardMaterial||ce.isMeshLambertMaterial&&!ce.envMap||ce.isMeshPhongMaterial&&!ce.envMap,Ze=re.get(ce.envMap||Ge,Xe),it=ce.vertexColors===!0&&!!fe.attributes.color&&fe.attributes.color.itemSize===4,ot=!!fe.attributes.tangent&&(!!ce.normalMap||ce.anisotropy>0),Ke=!!fe.morphAttributes.position,xt=!!fe.morphAttributes.normal,Rt=!!fe.morphAttributes.color;let Tt=jn;ce.toneMapped&&(P===null||P.isXRRenderTarget===!0)&&(Tt=E.toneMapping);const vt=fe.morphAttributes.position||fe.morphAttributes.normal||fe.morphAttributes.color,jt=vt!==void 0?vt.length:0,qe=F.get(ce),Tn=C.state.lights;if(ae===!0&&(me===!0||B!==N)){const Ht=B===N&&ce.id===I;Me.setState(ce,B,Ht)}let dt=!1;ce.version===qe.__version?(qe.needsLights&&qe.lightsStateVersion!==Tn.state.version||qe.outputColorSpace!==ze||oe.isBatchedMesh&&qe.batching===!1||!oe.isBatchedMesh&&qe.batching===!0||oe.isBatchedMesh&&qe.batchingColor===!0&&oe.colorTexture===null||oe.isBatchedMesh&&qe.batchingColor===!1&&oe.colorTexture!==null||oe.isInstancedMesh&&qe.instancing===!1||!oe.isInstancedMesh&&qe.instancing===!0||oe.isSkinnedMesh&&qe.skinning===!1||!oe.isSkinnedMesh&&qe.skinning===!0||oe.isInstancedMesh&&qe.instancingColor===!0&&oe.instanceColor===null||oe.isInstancedMesh&&qe.instancingColor===!1&&oe.instanceColor!==null||oe.isInstancedMesh&&qe.instancingMorph===!0&&oe.morphTexture===null||oe.isInstancedMesh&&qe.instancingMorph===!1&&oe.morphTexture!==null||qe.envMap!==Ze||ce.fog===!0&&qe.fog!==Be||qe.numClippingPlanes!==void 0&&(qe.numClippingPlanes!==Me.numPlanes||qe.numIntersection!==Me.numIntersection)||qe.vertexAlphas!==it||qe.vertexTangents!==ot||qe.morphTargets!==Ke||qe.morphNormals!==xt||qe.morphColors!==Rt||qe.toneMapping!==Tt||qe.morphTargetsCount!==jt)&&(dt=!0):(dt=!0,qe.__version=ce.version);let Wn=qe.currentProgram;dt===!0&&(Wn=ka(ce,te,oe));let ti=!1,ms=!1,ar=!1;const St=Wn.getUniforms(),$t=qe.uniforms;if(Ae.useProgram(Wn.program)&&(ti=!0,ms=!0,ar=!0),ce.id!==I&&(I=ce.id,ms=!0),ti||N!==B){Ae.buffers.depth.getReversed()&&B.reversedDepth!==!0&&(B._reversedDepth=!0,B.updateProjectionMatrix()),St.setValue($,"projectionMatrix",B.projectionMatrix),St.setValue($,"viewMatrix",B.matrixWorldInverse);const Bi=St.map.cameraPosition;Bi!==void 0&&Bi.setValue($,he.setFromMatrixPosition(B.matrixWorld)),Ne.logarithmicDepthBuffer&&St.setValue($,"logDepthBufFC",2/(Math.log(B.far+1)/Math.LN2)),(ce.isMeshPhongMaterial||ce.isMeshToonMaterial||ce.isMeshLambertMaterial||ce.isMeshBasicMaterial||ce.isMeshStandardMaterial||ce.isShaderMaterial)&&St.setValue($,"isOrthographic",B.isOrthographicCamera===!0),N!==B&&(N=B,ms=!0,ar=!0)}if(qe.needsLights&&(Tn.state.directionalShadowMap.length>0&&St.setValue($,"directionalShadowMap",Tn.state.directionalShadowMap,j),Tn.state.spotShadowMap.length>0&&St.setValue($,"spotShadowMap",Tn.state.spotShadowMap,j),Tn.state.pointShadowMap.length>0&&St.setValue($,"pointShadowMap",Tn.state.pointShadowMap,j)),oe.isSkinnedMesh){St.setOptional($,oe,"bindMatrix"),St.setOptional($,oe,"bindMatrixInverse");const Ht=oe.skeleton;Ht&&(Ht.boneTexture===null&&Ht.computeBoneTexture(),St.setValue($,"boneTexture",Ht.boneTexture,j))}oe.isBatchedMesh&&(St.setOptional($,oe,"batchingTexture"),St.setValue($,"batchingTexture",oe._matricesTexture,j),St.setOptional($,oe,"batchingIdTexture"),St.setValue($,"batchingIdTexture",oe._indirectTexture,j),St.setOptional($,oe,"batchingColorTexture"),oe._colorsTexture!==null&&St.setValue($,"batchingColorTexture",oe._colorsTexture,j));const Ui=fe.morphAttributes;if((Ui.position!==void 0||Ui.normal!==void 0||Ui.color!==void 0)&&we.update(oe,fe,Wn),(ms||qe.receiveShadow!==oe.receiveShadow)&&(qe.receiveShadow=oe.receiveShadow,St.setValue($,"receiveShadow",oe.receiveShadow)),(ce.isMeshStandardMaterial||ce.isMeshLambertMaterial||ce.isMeshPhongMaterial)&&ce.envMap===null&&te.environment!==null&&($t.envMapIntensity.value=te.environmentIntensity),$t.dfgLUT!==void 0&&($t.dfgLUT.value=vC()),ms&&(St.setValue($,"toneMappingExposure",E.toneMappingExposure),qe.needsLights&&Ob($t,ar),Be&&ce.fog===!0&&De.refreshFogUniforms($t,Be),De.refreshMaterialUniforms($t,ce,Q,G,C.state.transmissionRenderTarget[B.id]),Vr.upload($,J_(qe),$t,j)),ce.isShaderMaterial&&ce.uniformsNeedUpdate===!0&&(Vr.upload($,J_(qe),$t,j),ce.uniformsNeedUpdate=!1),ce.isSpriteMaterial&&St.setValue($,"center",oe.center),St.setValue($,"modelViewMatrix",oe.modelViewMatrix),St.setValue($,"normalMatrix",oe.normalMatrix),St.setValue($,"modelMatrix",oe.matrixWorld),ce.isShaderMaterial||ce.isRawShaderMaterial){const Ht=ce.uniformsGroups;for(let Bi=0,cr=Ht.length;Bi<cr;Bi++){const Q_=Ht[Bi];Re.update(Q_,Wn),Re.bind(Q_,Wn)}}return Wn}d(Lb,"setProgram");function Ob(B,te){B.ambientLightColor.needsUpdate=te,B.lightProbe.needsUpdate=te,B.directionalLights.needsUpdate=te,B.directionalLightShadows.needsUpdate=te,B.pointLights.needsUpdate=te,B.pointLightShadows.needsUpdate=te,B.spotLights.needsUpdate=te,B.spotLightShadows.needsUpdate=te,B.rectAreaLights.needsUpdate=te,B.hemisphereLights.needsUpdate=te}d(Ob,"markUniformsLightsNeedsUpdate");function Ub(B){return B.isMeshLambertMaterial||B.isMeshToonMaterial||B.isMeshPhongMaterial||B.isMeshStandardMaterial||B.isShadowMaterial||B.isShaderMaterial&&B.lights===!0}d(Ub,"materialNeedsLights"),this.getActiveCubeFace=function(){return A},this.getActiveMipmapLevel=function(){return R},this.getRenderTarget=function(){return P},this.setRenderTargetTextures=function(B,te,fe){const ce=F.get(B);ce.__autoAllocateDepthBuffer=B.resolveDepthBuffer===!1,ce.__autoAllocateDepthBuffer===!1&&(ce.__useRenderToTexture=!1),F.get(B.texture).__webglTexture=te,F.get(B.depthTexture).__webglTexture=ce.__autoAllocateDepthBuffer?void 0:fe,ce.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(B,te){const fe=F.get(B);fe.__webglFramebuffer=te,fe.__useDefaultFramebuffer=te===void 0};const Bb=$.createFramebuffer();this.setRenderTarget=function(B,te=0,fe=0){P=B,A=te,R=fe;let ce=null,oe=!1,Be=!1;if(B){const ze=F.get(B);if(ze.__useDefaultFramebuffer!==void 0){Ae.bindFramebuffer($.FRAMEBUFFER,ze.__webglFramebuffer),D.copy(B.viewport),L.copy(B.scissor),H=B.scissorTest,Ae.viewport(D),Ae.scissor(L),Ae.setScissorTest(H),I=-1;return}else if(ze.__webglFramebuffer===void 0)j.setupRenderTarget(B);else if(ze.__hasExternalTextures)j.rebindTextures(B,F.get(B.texture).__webglTexture,F.get(B.depthTexture).__webglTexture);else if(B.depthBuffer){const it=B.depthTexture;if(ze.__boundDepthTexture!==it){if(it!==null&&F.has(it)&&(B.width!==it.image.width||B.height!==it.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");j.setupDepthRenderbuffer(B)}}const Xe=B.texture;(Xe.isData3DTexture||Xe.isDataArrayTexture||Xe.isCompressedArrayTexture)&&(Be=!0);const Ze=F.get(B).__webglFramebuffer;B.isWebGLCubeRenderTarget?(Array.isArray(Ze[te])?ce=Ze[te][fe]:ce=Ze[te],oe=!0):B.samples>0&&j.useMultisampledRTT(B)===!1?ce=F.get(B).__webglMultisampledFramebuffer:Array.isArray(Ze)?ce=Ze[fe]:ce=Ze,D.copy(B.viewport),L.copy(B.scissor),H=B.scissorTest}else D.copy(q).multiplyScalar(Q).floor(),L.copy(Y).multiplyScalar(Q).floor(),H=K;if(fe!==0&&(ce=Bb),Ae.bindFramebuffer($.FRAMEBUFFER,ce)&&Ae.drawBuffers(B,ce),Ae.viewport(D),Ae.scissor(L),Ae.setScissorTest(H),oe){const ze=F.get(B.texture);$.framebufferTexture2D($.FRAMEBUFFER,$.COLOR_ATTACHMENT0,$.TEXTURE_CUBE_MAP_POSITIVE_X+te,ze.__webglTexture,fe)}else if(Be){const ze=te;for(let Xe=0;Xe<B.textures.length;Xe++){const Ze=F.get(B.textures[Xe]);$.framebufferTextureLayer($.FRAMEBUFFER,$.COLOR_ATTACHMENT0+Xe,Ze.__webglTexture,fe,ze)}}else if(B!==null&&fe!==0){const ze=F.get(B.texture);$.framebufferTexture2D($.FRAMEBUFFER,$.COLOR_ATTACHMENT0,$.TEXTURE_2D,ze.__webglTexture,fe)}I=-1},this.readRenderTargetPixels=function(B,te,fe,ce,oe,Be,Ge,ze=0){if(!(B&&B.isWebGLRenderTarget)){Ye("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Xe=F.get(B).__webglFramebuffer;if(B.isWebGLCubeRenderTarget&&Ge!==void 0&&(Xe=Xe[Ge]),Xe){Ae.bindFramebuffer($.FRAMEBUFFER,Xe);try{const Ze=B.textures[ze],it=Ze.format,ot=Ze.type;if(B.textures.length>1&&$.readBuffer($.COLOR_ATTACHMENT0+ze),!Ne.textureFormatReadable(it)){Ye("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Ne.textureTypeReadable(ot)){Ye("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}te>=0&&te<=B.width-ce&&fe>=0&&fe<=B.height-oe&&$.readPixels(te,fe,ce,oe,_e.convert(it),_e.convert(ot),Be)}finally{const Ze=P!==null?F.get(P).__webglFramebuffer:null;Ae.bindFramebuffer($.FRAMEBUFFER,Ze)}}},this.readRenderTargetPixelsAsync=async function(B,te,fe,ce,oe,Be,Ge,ze=0){if(!(B&&B.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Xe=F.get(B).__webglFramebuffer;if(B.isWebGLCubeRenderTarget&&Ge!==void 0&&(Xe=Xe[Ge]),Xe)if(te>=0&&te<=B.width-ce&&fe>=0&&fe<=B.height-oe){Ae.bindFramebuffer($.FRAMEBUFFER,Xe);const Ze=B.textures[ze],it=Ze.format,ot=Ze.type;if(B.textures.length>1&&$.readBuffer($.COLOR_ATTACHMENT0+ze),!Ne.textureFormatReadable(it))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Ne.textureTypeReadable(ot))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ke=$.createBuffer();$.bindBuffer($.PIXEL_PACK_BUFFER,Ke),$.bufferData($.PIXEL_PACK_BUFFER,Be.byteLength,$.STREAM_READ),$.readPixels(te,fe,ce,oe,_e.convert(it),_e.convert(ot),0);const xt=P!==null?F.get(P).__webglFramebuffer:null;Ae.bindFramebuffer($.FRAMEBUFFER,xt);const Rt=$.fenceSync($.SYNC_GPU_COMMANDS_COMPLETE,0);return $.flush(),await WS($,Rt,4),$.bindBuffer($.PIXEL_PACK_BUFFER,Ke),$.getBufferSubData($.PIXEL_PACK_BUFFER,0,Be),$.deleteBuffer(Ke),$.deleteSync(Rt),Be}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(B,te=null,fe=0){const ce=Math.pow(2,-fe),oe=Math.floor(B.image.width*ce),Be=Math.floor(B.image.height*ce),Ge=te!==null?te.x:0,ze=te!==null?te.y:0;j.setTexture2D(B,0),$.copyTexSubImage2D($.TEXTURE_2D,fe,0,0,Ge,ze,oe,Be),Ae.unbindTexture()};const zb=$.createFramebuffer(),kb=$.createFramebuffer();this.copyTextureToTexture=function(B,te,fe=null,ce=null,oe=0,Be=0){let Ge,ze,Xe,Ze,it,ot,Ke,xt,Rt;const Tt=B.isCompressedTexture?B.mipmaps[Be]:B.image;if(fe!==null)Ge=fe.max.x-fe.min.x,ze=fe.max.y-fe.min.y,Xe=fe.isBox3?fe.max.z-fe.min.z:1,Ze=fe.min.x,it=fe.min.y,ot=fe.isBox3?fe.min.z:0;else{const $t=Math.pow(2,-oe);Ge=Math.floor(Tt.width*$t),ze=Math.floor(Tt.height*$t),B.isDataArrayTexture?Xe=Tt.depth:B.isData3DTexture?Xe=Math.floor(Tt.depth*$t):Xe=1,Ze=0,it=0,ot=0}ce!==null?(Ke=ce.x,xt=ce.y,Rt=ce.z):(Ke=0,xt=0,Rt=0);const vt=_e.convert(te.format),jt=_e.convert(te.type);let qe;te.isData3DTexture?(j.setTexture3D(te,0),qe=$.TEXTURE_3D):te.isDataArrayTexture||te.isCompressedArrayTexture?(j.setTexture2DArray(te,0),qe=$.TEXTURE_2D_ARRAY):(j.setTexture2D(te,0),qe=$.TEXTURE_2D),$.pixelStorei($.UNPACK_FLIP_Y_WEBGL,te.flipY),$.pixelStorei($.UNPACK_PREMULTIPLY_ALPHA_WEBGL,te.premultiplyAlpha),$.pixelStorei($.UNPACK_ALIGNMENT,te.unpackAlignment);const Tn=$.getParameter($.UNPACK_ROW_LENGTH),dt=$.getParameter($.UNPACK_IMAGE_HEIGHT),Wn=$.getParameter($.UNPACK_SKIP_PIXELS),ti=$.getParameter($.UNPACK_SKIP_ROWS),ms=$.getParameter($.UNPACK_SKIP_IMAGES);$.pixelStorei($.UNPACK_ROW_LENGTH,Tt.width),$.pixelStorei($.UNPACK_IMAGE_HEIGHT,Tt.height),$.pixelStorei($.UNPACK_SKIP_PIXELS,Ze),$.pixelStorei($.UNPACK_SKIP_ROWS,it),$.pixelStorei($.UNPACK_SKIP_IMAGES,ot);const ar=B.isDataArrayTexture||B.isData3DTexture,St=te.isDataArrayTexture||te.isData3DTexture;if(B.isDepthTexture){const $t=F.get(B),Ui=F.get(te),Ht=F.get($t.__renderTarget),Bi=F.get(Ui.__renderTarget);Ae.bindFramebuffer($.READ_FRAMEBUFFER,Ht.__webglFramebuffer),Ae.bindFramebuffer($.DRAW_FRAMEBUFFER,Bi.__webglFramebuffer);for(let cr=0;cr<Xe;cr++)ar&&($.framebufferTextureLayer($.READ_FRAMEBUFFER,$.COLOR_ATTACHMENT0,F.get(B).__webglTexture,oe,ot+cr),$.framebufferTextureLayer($.DRAW_FRAMEBUFFER,$.COLOR_ATTACHMENT0,F.get(te).__webglTexture,Be,Rt+cr)),$.blitFramebuffer(Ze,it,Ge,ze,Ke,xt,Ge,ze,$.DEPTH_BUFFER_BIT,$.NEAREST);Ae.bindFramebuffer($.READ_FRAMEBUFFER,null),Ae.bindFramebuffer($.DRAW_FRAMEBUFFER,null)}else if(oe!==0||B.isRenderTargetTexture||F.has(B)){const $t=F.get(B),Ui=F.get(te);Ae.bindFramebuffer($.READ_FRAMEBUFFER,zb),Ae.bindFramebuffer($.DRAW_FRAMEBUFFER,kb);for(let Ht=0;Ht<Xe;Ht++)ar?$.framebufferTextureLayer($.READ_FRAMEBUFFER,$.COLOR_ATTACHMENT0,$t.__webglTexture,oe,ot+Ht):$.framebufferTexture2D($.READ_FRAMEBUFFER,$.COLOR_ATTACHMENT0,$.TEXTURE_2D,$t.__webglTexture,oe),St?$.framebufferTextureLayer($.DRAW_FRAMEBUFFER,$.COLOR_ATTACHMENT0,Ui.__webglTexture,Be,Rt+Ht):$.framebufferTexture2D($.DRAW_FRAMEBUFFER,$.COLOR_ATTACHMENT0,$.TEXTURE_2D,Ui.__webglTexture,Be),oe!==0?$.blitFramebuffer(Ze,it,Ge,ze,Ke,xt,Ge,ze,$.COLOR_BUFFER_BIT,$.NEAREST):St?$.copyTexSubImage3D(qe,Be,Ke,xt,Rt+Ht,Ze,it,Ge,ze):$.copyTexSubImage2D(qe,Be,Ke,xt,Ze,it,Ge,ze);Ae.bindFramebuffer($.READ_FRAMEBUFFER,null),Ae.bindFramebuffer($.DRAW_FRAMEBUFFER,null)}else St?B.isDataTexture||B.isData3DTexture?$.texSubImage3D(qe,Be,Ke,xt,Rt,Ge,ze,Xe,vt,jt,Tt.data):te.isCompressedArrayTexture?$.compressedTexSubImage3D(qe,Be,Ke,xt,Rt,Ge,ze,Xe,vt,Tt.data):$.texSubImage3D(qe,Be,Ke,xt,Rt,Ge,ze,Xe,vt,jt,Tt):B.isDataTexture?$.texSubImage2D($.TEXTURE_2D,Be,Ke,xt,Ge,ze,vt,jt,Tt.data):B.isCompressedTexture?$.compressedTexSubImage2D($.TEXTURE_2D,Be,Ke,xt,Tt.width,Tt.height,vt,Tt.data):$.texSubImage2D($.TEXTURE_2D,Be,Ke,xt,Ge,ze,vt,jt,Tt);$.pixelStorei($.UNPACK_ROW_LENGTH,Tn),$.pixelStorei($.UNPACK_IMAGE_HEIGHT,dt),$.pixelStorei($.UNPACK_SKIP_PIXELS,Wn),$.pixelStorei($.UNPACK_SKIP_ROWS,ti),$.pixelStorei($.UNPACK_SKIP_IMAGES,ms),Be===0&&te.generateMipmaps&&$.generateMipmap(qe),Ae.unbindTexture()},this.initRenderTarget=function(B){F.get(B).__webglFramebuffer===void 0&&j.setupRenderTarget(B)},this.initTexture=function(B){B.isCubeTexture?j.setTextureCube(B,0):B.isData3DTexture?j.setTexture3D(B,0):B.isDataArrayTexture||B.isCompressedArrayTexture?j.setTexture2DArray(B,0):j.setTexture2D(B,0),Ae.unbindTexture()},this.resetState=function(){A=0,R=0,P=null,Ae.reset(),ye.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Rn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=lt._getDrawingBufferColorSpace(e),t.unpackColorSpace=lt._getUnpackColorSpace()}};d(N_,"WebGLRenderer");let _p=N_;const An=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:Dp,AddEquation:Ji,AddOperation:Nv,AdditiveAnimationBlendMode:Wp,AdditiveBlending:Gf,AgXToneMapping:Lp,AlphaFormat:Hp,AlwaysCompare:Wv,AlwaysDepth:Hc,AlwaysStencilFunc:Yf,AmbientLight:Su,AnimationAction:Nu,AnimationClip:nr,AnimationLoader:_d,AnimationMixer:Fd,AnimationObjectGroup:Dd,AnimationUtils:md,ArcCurve:ql,ArrayCamera:Cu,ArrowHelper:np,AttachedBindMode:Xf,Audio:Ru,AudioAnalyser:Pd,AudioContext:Ia,AudioListener:Id,AudioLoader:Td,AxesHelper:ip,BackSide:gn,BasicDepthPacking:Uv,BasicShadowMap:Jb,BatchedMesh:Ol,BezierInterpolant:gu,Bone:aa,BooleanKeyframeTrack:Ni,Box2:Wd,Box3:Dt,Box3Helper:ep,BoxGeometry:Ks,BoxHelper:Qd,BufferAttribute:mt,BufferGeometry:Qe,BufferGeometryLoader:Au,ByteType:Bp,Cache:pi,Camera:ao,CameraHelper:jd,CanvasTexture:Vl,CapsuleGeometry:Gl,CatmullRomCurve3:Yl,CineonToneMapping:Np,CircleGeometry:Wl,ClampToEdgeWrapping:Mn,Clock:kd,Color:ke,ColorKeyframeTrack:Ma,ColorManagement:lt,Compatibility:zS,CompressedArrayTexture:ld,CompressedCubeTexture:ud,CompressedTexture:Qr,CompressedTextureLoader:yd,ConeGeometry:to,ConstantAlphaFactor:Iv,ConstantColorFactor:Tv,Controls:rp,CubeCamera:Tu,CubeDepthTexture:Hl,CubeReflectionMapping:gi,CubeRefractionMapping:ss,CubeTexture:Zs,CubeTextureLoader:xd,CubeUVReflectionMapping:uo,CubicBezierCurve:la,CubicBezierCurve3:Zl,CubicInterpolant:pu,CullFaceBack:Hf,CullFaceFront:hv,CullFaceFrontBack:Kb,CullFaceNone:uv,Curve:Ln,CurvePath:jl,CustomBlending:dv,CustomToneMapping:Fp,CylinderGeometry:eo,Cylindrical:Hd,Data3DTexture:Zr,DataArrayTexture:Yr,DataTexture:Fn,DataTextureLoader:vd,DataUtils:jf,DecrementStencilOp:gS,DecrementWrapStencilOp:yS,DefaultLoadingManager:nb,DepthFormat:yi,DepthStencilFormat:ji,DepthTexture:ls,DetachedBindMode:Dv,DirectionalLight:bu,DirectionalLightHelper:Jd,DiscreteInterpolant:mu,DodecahedronGeometry:$l,DoubleSide:Bt,DstAlphaFactor:Sv,DstColorFactor:wv,DynamicCopyUsage:DS,DynamicDrawUsage:TS,DynamicReadUsage:RS,EdgesGeometry:Xl,EllipseCurve:no,EqualCompare:Vv,EqualDepth:Wc,EqualStencilFunc:SS,EquirectangularReflectionMapping:Fo,EquirectangularRefractionMapping:Lo,Euler:rn,EventDispatcher:Vn,ExternalTexture:ca,ExtrudeGeometry:Ql,FileLoader:ei,Float16BufferAttribute:sd,Float32BufferAttribute:Ve,FloatType:pn,Fog:Il,FogExp2:Cl,FramebufferTexture:cd,FrontSide:zn,Frustum:cs,FrustumArray:Ll,GLBufferAttribute:Bd,GLSL1:LS,GLSL3:Zf,GreaterCompare:Hv,GreaterDepth:Xc,GreaterEqualCompare:Dh,GreaterEqualDepth:$c,GreaterEqualStencilFunc:AS,GreaterStencilFunc:wS,GridHelper:Zd,Group:sn,HalfFloatType:_i,HemisphereLight:yu,HemisphereLightHelper:Yd,IcosahedronGeometry:eu,ImageBitmapLoader:Ad,ImageLoader:ir,ImageUtils:Tl,IncrementStencilOp:mS,IncrementWrapStencilOp:_S,InstancedBufferAttribute:as,InstancedBufferGeometry:Ca,InstancedInterleavedBuffer:co,InstancedMesh:Fl,Int16BufferAttribute:nd,Int32BufferAttribute:id,Int8BufferAttribute:Qf,IntType:Eh,InterleavedBuffer:Jr,InterleavedBufferAttribute:Pn,Interpolant:hs,InterpolateBezier:qf,InterpolateDiscrete:Ko,InterpolateLinear:Al,InterpolateSmooth:Bc,InterpolationSamplingMode:BS,InterpolationSamplingType:US,InvertStencilOp:xS,KeepStencilOp:Rs,KeyframeTrack:En,LOD:Pl,LatheGeometry:tu,Layers:Kr,LessCompare:kv,LessDepth:Gc,LessEqualCompare:Nh,LessEqualDepth:Ws,LessEqualStencilFunc:MS,LessStencilFunc:bS,Light:xi,LightProbe:wu,Line:Qn,Line3:Fu,LineBasicMaterial:It,LineCurve:ua,LineCurve3:Kl,LineDashedMaterial:du,LineLoop:zl,LineSegments:Hn,LinearFilter:wt,LinearInterpolant:Sa,LinearMipMapLinearFilter:nS,LinearMipMapNearestFilter:tS,LinearMipmapLinearFilter:fi,LinearMipmapNearestFilter:Oo,LinearSRGBColorSpace:Xs,LinearToneMapping:Rp,LinearTransfer:jo,Loader:on,LoaderUtils:Ta,LoadingManager:wa,LoopOnce:Fv,LoopPingPong:Ov,LoopRepeat:Lv,MOUSE:Yb,Material:zt,MaterialBlending:jb,MaterialLoader:Eu,MathUtils:Bn,Matrix2:Gd,Matrix3:nt,Matrix4:Je,MaxEquation:_v,Mesh:yt,MeshBasicMaterial:Wt,MeshDepthMaterial:va,MeshDistanceMaterial:ba,MeshLambertMaterial:fu,MeshMatcapMaterial:es,MeshNormalMaterial:hu,MeshPhongMaterial:uu,MeshPhysicalMaterial:lu,MeshStandardMaterial:wn,MeshToonMaterial:Qi,MinEquation:gv,MirroredRepeatWrapping:Zo,MixOperation:Pv,MultiplyBlending:$f,MultiplyOperation:La,NearestFilter:Nt,NearestMipMapLinearFilter:eS,NearestMipMapNearestFilter:Qb,NearestMipmapLinearFilter:Fr,NearestMipmapNearestFilter:Up,NeutralToneMapping:Op,NeverCompare:zv,NeverDepth:Vc,NeverStencilFunc:vS,NoBlending:mi,NoColorSpace:Ai,NoNormalPacking:uS,NoToneMapping:jn,NormalAnimationBlendMode:Ph,NormalBlending:Bs,NormalGAPacking:fS,NormalRGPacking:hS,NotEqualCompare:Gv,NotEqualDepth:qc,NotEqualStencilFunc:ES,NumberKeyframeTrack:Qs,Object3D:ft,ObjectLoader:Ed,ObjectSpaceNormalMap:Bv,OctahedronGeometry:_a,OneFactor:xv,OneMinusConstantAlphaFactor:Rv,OneMinusConstantColorFactor:Cv,OneMinusDstAlphaFactor:Mv,OneMinusDstColorFactor:Ev,OneMinusSrcAlphaFactor:kc,OneMinusSrcColorFactor:bv,OrthographicCamera:sr,PCFShadowMap:Do,PCFSoftShadowMap:fv,PMREMGenerator:Ra,Path:io,PerspectiveCamera:Ut,Plane:Zn,PlaneGeometry:ro,PlaneHelper:tp,PointLight:vu,PointLightHelper:qd,Points:Ys,PointsMaterial:Nn,PolarGridHelper:Kd,PolyhedronGeometry:us,PositionalAudio:Rd,PropertyBinding:_t,PropertyMixer:Pu,QuadraticBezierCurve:ha,QuadraticBezierCurve3:fa,Quaternion:Mt,QuaternionKeyframeTrack:er,QuaternionLinearInterpolant:_u,R11_EAC_Format:tl,RED_GREEN_RGTC2_Format:wl,RED_RGTC1_Format:Sl,REVISION:Mh,RG11_EAC_Format:il,RGBADepthPacking:aS,RGBAFormat:mn,RGBAIntegerFormat:Rh,RGBA_ASTC_10x10_Format:gl,RGBA_ASTC_10x5_Format:dl,RGBA_ASTC_10x6_Format:pl,RGBA_ASTC_10x8_Format:ml,RGBA_ASTC_12x10_Format:_l,RGBA_ASTC_12x12_Format:yl,RGBA_ASTC_4x4_Format:rl,RGBA_ASTC_5x4_Format:ol,RGBA_ASTC_5x5_Format:al,RGBA_ASTC_6x5_Format:cl,RGBA_ASTC_6x6_Format:ll,RGBA_ASTC_8x5_Format:ul,RGBA_ASTC_8x6_Format:hl,RGBA_ASTC_8x8_Format:fl,RGBA_BPTC_Format:xl,RGBA_ETC2_EAC_Format:el,RGBA_PVRTC_2BPPV1_Format:Jc,RGBA_PVRTC_4BPPV1_Format:Kc,RGBA_S3TC_DXT1_Format:Bo,RGBA_S3TC_DXT3_Format:zo,RGBA_S3TC_DXT5_Format:ko,RGBDepthPacking:cS,RGBFormat:Gp,RGBIntegerFormat:iS,RGB_BPTC_SIGNED_Format:vl,RGB_BPTC_UNSIGNED_Format:bl,RGB_ETC1_Format:jc,RGB_ETC2_Format:Qc,RGB_PVRTC_2BPPV1_Format:Zc,RGB_PVRTC_4BPPV1_Format:Yc,RGB_S3TC_DXT1_Format:Uo,RGDepthPacking:lS,RGFormat:$s,RGIntegerFormat:Ih,RawShaderMaterial:xa,Ray:os,Raycaster:Du,RectAreaLight:Mu,RedFormat:Ch,RedIntegerFormat:Oa,ReinhardToneMapping:Pp,RenderTarget:ia,RenderTarget3D:Ld,RepeatWrapping:Yo,ReplaceStencilOp:pS,ReverseSubtractEquation:mv,RingGeometry:nu,SIGNED_R11_EAC_Format:nl,SIGNED_RED_GREEN_RGTC2_Format:El,SIGNED_RED_RGTC1_Format:Ml,SIGNED_RG11_EAC_Format:sl,SRGBColorSpace:un,SRGBTransfer:gt,Scene:Rl,ShaderChunk:rt,ShaderLib:hn,ShaderMaterial:yn,ShadowMaterial:cu,Shape:Ii,ShapeGeometry:iu,ShapePath:sp,ShapeUtils:Kn,ShortType:zp,Skeleton:Dl,SkeletonHelper:Xd,SkinnedMesh:Nl,Source:di,Sphere:Ft,SphereGeometry:js,Spherical:Vd,SphericalHarmonics3:Aa,SplineCurve:da,SpotLight:xu,SpotLightHelper:$d,Sprite:oa,SpriteMaterial:jr,SrcAlphaFactor:zc,SrcAlphaSaturateFactor:Av,SrcColorFactor:vv,StaticCopyUsage:NS,StaticDrawUsage:Qo,StaticReadUsage:IS,StereoCamera:Cd,StreamCopyUsage:FS,StreamDrawUsage:CS,StreamReadUsage:PS,StringKeyframeTrack:Di,SubtractEquation:pv,SubtractiveBlending:Wf,TOUCH:Zb,TangentSpaceNormalMap:fs,TetrahedronGeometry:su,Texture:Ot,TextureLoader:bd,TextureUtils:ap,Timer:Iu,TimestampQuery:OS,TorusGeometry:ru,TorusKnotGeometry:ou,Triangle:ui,TriangleFanDrawMode:oS,TriangleStripDrawMode:rS,TrianglesDrawMode:sS,TubeGeometry:au,UVMapping:wh,Uint16BufferAttribute:sa,Uint32BufferAttribute:ra,Uint8BufferAttribute:ed,Uint8ClampedBufferAttribute:td,Uniform:Od,UniformsGroup:Ud,UniformsLib:Fe,UniformsUtils:Fh,UnsignedByteType:Sn,UnsignedInt101111Type:Vp,UnsignedInt248Type:Xr,UnsignedInt5999Type:kp,UnsignedIntType:kn,UnsignedShort4444Type:Ah,UnsignedShort5551Type:Th,UnsignedShortType:$r,VSMShadowMap:Dr,Vector2:Ee,Vector3:U,Vector4:pt,VectorKeyframeTrack:tr,VideoFrameTexture:ad,VideoTexture:kl,WebGL3DRenderTarget:Jf,WebGLArrayRenderTarget:Kf,WebGLCoordinateSystem:Rn,WebGLCubeRenderTarget:Pa,WebGLRenderTarget:_n,WebGLRenderer:_p,WebGLUtils:lb,WebGPUCoordinateSystem:qs,WebXRController:kr,WireframeGeometry:ya,WrapAroundEnding:Jo,ZeroCurvatureEnding:Ds,ZeroFactor:yv,ZeroSlopeEnding:Fs,ZeroStencilOp:dS,createCanvasElement:Xv,error:Ye,getConsoleFunction:GS,log:ta,setConsoleFunction:HS,warn:Ue,warnOnce:na},Symbol.toStringTag,{value:"Module"}));function bC(){this._numProp=3,this._vertProperties=[],this._triVerts=[],this._triIDs=[],this._vertKeyToIndex=new Map,this._faceNameToID=new Map,this._idToFaceName=new Map,this._faceMetadata=new Map,this._edgeMetadata=new Map,this._dirty=!0,this._manifold=null,this._faceIndex=null,this._epsilon=0,this._freeTimer=null,this.type="SOLID",this.renderOrder=1,this._auxEdges=[]}d(bC,"constructorImpl");function SC(){const r=this.constructor,e=new r;e._numProp=this._numProp,e._vertProperties=this._vertProperties.slice(),e._triVerts=this._triVerts.slice(),e._triIDs=this._triIDs.slice(),e._vertKeyToIndex=new Map;for(let t=0;t<e._vertProperties.length;t+=3){const n=e._vertProperties[t],i=e._vertProperties[t+1],s=e._vertProperties[t+2];e._vertKeyToIndex.set(`${n},${i},${s}`,t/3|0)}try{e._idToFaceName=new Map(this._idToFaceName),e._faceNameToID=new Map(this._faceNameToID)}catch{}try{e._faceMetadata=new Map(this._faceMetadata)}catch{e._faceMetadata=new Map}try{e._edgeMetadata=new Map(this._edgeMetadata)}catch{e._edgeMetadata=new Map}try{e._auxEdges=Array.isArray(this._auxEdges)?this._auxEdges.map(t=>({name:t?.name,closedLoop:!!t?.closedLoop,polylineWorld:!!t?.polylineWorld,materialKey:t?.materialKey,centerline:!!t?.centerline,points:Array.isArray(t?.points)?t.points.map(n=>Array.isArray(n)?[n[0],n[1],n[2]]:n):[]})):[]}catch{e._auxEdges=[]}return e._dirty=!0,e._manifold=null,e._faceIndex=null,e.type="SOLID",e.renderOrder=this.renderOrder,e}d(SC,"clone");function MC(){try{try{this._freeTimer&&clearTimeout(this._freeTimer)}catch{}if(this._freeTimer=null,this._manifold){try{typeof this._manifold.delete=="function"&&this._manifold.delete()}catch{}this._manifold=null}this._dirty=!0,this._faceIndex=null}catch{}return this}d(MC,"free");const Nx=typeof globalThis.__MANIFOLD_WASM_BASE64__<"u"&&globalThis.__MANIFOLD_WASM_BASE64__,Lu=typeof window>"u"||!!globalThis?.process?.versions?.node,wC=d(async()=>{if(Lu)try{const{createRequire:r}=await is(async()=>{const{createRequire:i}=await import("./__vite-browser-external-BIHI7g3E.js");return{createRequire:i}},[]),t=r(import.meta.url)("node:url");if(t.__brepFileUrlPatched)return;const n=t.fileURLToPath;t.fileURLToPath=i=>{try{return n(i)}catch(s){const o=typeof i=="string"?i:i?.href;if(o&&(o.startsWith("data:")||o.startsWith("blob:")))return globalThis.process.cwd();throw s}},t.__brepFileUrlPatched=!0}catch{}},"patchFileURLToPathForDataUrl"),EC=d(async()=>{Lu&&await wC();const r=await is(()=>import("./manifold-Dgmk3x29.js"),__vite__mapDeps([0,1]));return r?.default??r},"loadModule"),AC=d(r=>{if(!r)return null;const e=r.includes("base64,")?r.slice(r.indexOf("base64,")+7):r;if(typeof globalThis.Buffer<"u")return new Uint8Array(globalThis.Buffer.from(e,"base64"));if(typeof atob=="function"){const t=atob(e),n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return n}throw new Error("No base64 decoder available for manifold wasm")},"decodeBase64ToUint8Array"),Rf=d(async r=>{const t=await(await EC())(r);return typeof t.setup=="function"&&await t.setup(),t},"initWasm"),lo=await(async()=>{if(Nx){const t=AC(Nx),n=await Rf({wasmBinary:t});return!Lu&&typeof window<"u"&&(window.manifold=n),n}if(Lu)return Rf();const{default:r}=await is(()=>import("./manifold-Demb-vkL.js"),[]),e=await Rf({locateFile:d(()=>r,"locateFile")});return typeof window<"u"&&(window.manifold=e),e})(),Fi=lo.Manifold,UR=lo.CrossSection,TC=lo.Mesh,BR=typeof lo.sum=="function",zR=d((r,e)=>{if(typeof lo.sum!="function")throw new Error("Custom manifold extensions are only available when using the local manifold build.");return lo.sum(r,e)},"manifoldPlusSum"),Dx=new Dt,Dc=new U,D_=class D_ extends Ca{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";const e=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],t=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],n=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];this.setIndex(n),this.setAttribute("position",new Ve(e,3)),this.setAttribute("uv",new Ve(t,2))}applyMatrix4(e){const t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new co(t,6,1);return this.setAttribute("instanceStart",new Pn(n,3,0)),this.setAttribute("instanceEnd",new Pn(n,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new co(t,6,1);return this.setAttribute("instanceColorStart",new Pn(n,3,0)),this.setAttribute("instanceColorEnd",new Pn(n,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new ya(e.geometry)),this}fromLineSegments(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Dt);const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),Dx.setFromBufferAttribute(t),this.boundingBox.union(Dx))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ft),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){const n=this.boundingSphere.center;this.boundingBox.getCenter(n);let i=0;for(let s=0,o=e.count;s<o;s++)Dc.fromBufferAttribute(e,s),i=Math.max(i,n.distanceToSquared(Dc)),Dc.fromBufferAttribute(t,s),i=Math.max(i,n.distanceToSquared(Dc));this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}};d(D_,"LineSegmentsGeometry");let Ou=D_;Fe.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new Ee(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}};hn.line={uniforms:Fh.merge([Fe.common,Fe.fog,Fe.line]),vertexShader:`
|
|
4050
|
+
}`,R_=class R_{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new ca(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new yn({vertexShader:pC,fragmentShader:mC,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new yt(new ro(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}};d(R_,"WebXRDepthSensing");let mp=R_;const P_=class P_ extends Vn{constructor(e,t){super();const n=this;let i=null,s=1,o=null,a="local-floor",c=1,l=null,u=null,h=null,f=null,p=null,m=null;const y=typeof XRWebGLBinding<"u",_=new mp,g={},v=t.getContextAttributes();let M=null,b=null;const C=[],S=[],T=new Ee;let x=null;const E=new Ut;E.viewport=new pt;const w=new Ut;w.viewport=new pt;const A=[E,w],R=new Cu;let P=null,I=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(q){let Y=C[q];return Y===void 0&&(Y=new kr,C[q]=Y),Y.getTargetRaySpace()},this.getControllerGrip=function(q){let Y=C[q];return Y===void 0&&(Y=new kr,C[q]=Y),Y.getGripSpace()},this.getHand=function(q){let Y=C[q];return Y===void 0&&(Y=new kr,C[q]=Y),Y.getHandSpace()};function N(q){const Y=S.indexOf(q.inputSource);if(Y===-1)return;const K=C[Y];K!==void 0&&(K.update(q.inputSource,q.frame,l||o),K.dispatchEvent({type:q.type,data:q.inputSource}))}d(N,"onSessionEvent");function D(){i.removeEventListener("select",N),i.removeEventListener("selectstart",N),i.removeEventListener("selectend",N),i.removeEventListener("squeeze",N),i.removeEventListener("squeezestart",N),i.removeEventListener("squeezeend",N),i.removeEventListener("end",D),i.removeEventListener("inputsourceschange",L);for(let q=0;q<C.length;q++){const Y=S[q];Y!==null&&(S[q]=null,C[q].disconnect(Y))}P=null,I=null,_.reset();for(const q in g)delete g[q];e.setRenderTarget(M),p=null,f=null,h=null,i=null,b=null,Z.stop(),n.isPresenting=!1,e.setPixelRatio(x),e.setSize(T.width,T.height,!1),n.dispatchEvent({type:"sessionend"})}d(D,"onSessionEnd"),this.setFramebufferScaleFactor=function(q){s=q,n.isPresenting===!0&&Ue("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(q){a=q,n.isPresenting===!0&&Ue("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(q){l=q},this.getBaseLayer=function(){return f!==null?f:p},this.getBinding=function(){return h===null&&y&&(h=new XRWebGLBinding(i,t)),h},this.getFrame=function(){return m},this.getSession=function(){return i},this.setSession=async function(q){if(i=q,i!==null){if(M=e.getRenderTarget(),i.addEventListener("select",N),i.addEventListener("selectstart",N),i.addEventListener("selectend",N),i.addEventListener("squeeze",N),i.addEventListener("squeezestart",N),i.addEventListener("squeezeend",N),i.addEventListener("end",D),i.addEventListener("inputsourceschange",L),v.xrCompatible!==!0&&await t.makeXRCompatible(),x=e.getPixelRatio(),e.getSize(T),y&&"createProjectionLayer"in XRWebGLBinding.prototype){let K=null,le=null,ae=null;v.depth&&(ae=v.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,K=v.stencil?ji:yi,le=v.stencil?Xr:kn);const me={colorFormat:t.RGBA8,depthFormat:ae,scaleFactor:s};h=this.getBinding(),f=h.createProjectionLayer(me),i.updateRenderState({layers:[f]}),e.setPixelRatio(1),e.setSize(f.textureWidth,f.textureHeight,!1),b=new _n(f.textureWidth,f.textureHeight,{format:mn,type:Sn,depthTexture:new ls(f.textureWidth,f.textureHeight,le,void 0,void 0,void 0,void 0,void 0,void 0,K),stencilBuffer:v.stencil,colorSpace:e.outputColorSpace,samples:v.antialias?4:0,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}else{const K={antialias:v.antialias,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:s};p=new XRWebGLLayer(i,t,K),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),b=new _n(p.framebufferWidth,p.framebufferHeight,{format:mn,type:Sn,colorSpace:e.outputColorSpace,stencilBuffer:v.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}b.isXRRenderTarget=!0,this.setFoveation(c),l=null,o=await i.requestReferenceSpace(a),Z.setContext(i),Z.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return _.getDepthTexture()};function L(q){for(let Y=0;Y<q.removed.length;Y++){const K=q.removed[Y],le=S.indexOf(K);le>=0&&(S[le]=null,C[le].disconnect(K))}for(let Y=0;Y<q.added.length;Y++){const K=q.added[Y];let le=S.indexOf(K);if(le===-1){for(let me=0;me<C.length;me++)if(me>=S.length){S.push(K),le=me;break}else if(S[me]===null){S[me]=K,le=me;break}if(le===-1)break}const ae=C[le];ae&&ae.connect(K)}}d(L,"onInputSourcesChange");const H=new U,X=new U;function O(q,Y,K){H.setFromMatrixPosition(Y.matrixWorld),X.setFromMatrixPosition(K.matrixWorld);const le=H.distanceTo(X),ae=Y.projectionMatrix.elements,me=K.projectionMatrix.elements,ve=ae[14]/(ae[10]-1),he=ae[14]/(ae[10]+1),ee=(ae[9]+1)/ae[5],ne=(ae[9]-1)/ae[5],ie=(ae[8]-1)/ae[0],xe=(me[8]+1)/me[0],$=ve*ie,be=ve*xe,Ie=le/(-ie+xe),Ne=Ie*-ie;if(Y.matrixWorld.decompose(q.position,q.quaternion,q.scale),q.translateX(Ne),q.translateZ(Ie),q.matrixWorld.compose(q.position,q.quaternion,q.scale),q.matrixWorldInverse.copy(q.matrixWorld).invert(),ae[10]===-1)q.projectionMatrix.copy(Y.projectionMatrix),q.projectionMatrixInverse.copy(Y.projectionMatrixInverse);else{const Ae=ve+Ie,V=he+Ie,F=$-Ne,j=be+(le-Ne),re=ee*he/V*Ae,ge=ne*he/V*Ae;q.projectionMatrix.makePerspective(F,j,re,ge,Ae,V),q.projectionMatrixInverse.copy(q.projectionMatrix).invert()}}d(O,"setProjectionFromUnion");function W(q,Y){Y===null?q.matrixWorld.copy(q.matrix):q.matrixWorld.multiplyMatrices(Y.matrixWorld,q.matrix),q.matrixWorldInverse.copy(q.matrixWorld).invert()}d(W,"updateCamera"),this.updateCamera=function(q){if(i===null)return;let Y=q.near,K=q.far;_.texture!==null&&(_.depthNear>0&&(Y=_.depthNear),_.depthFar>0&&(K=_.depthFar)),R.near=w.near=E.near=Y,R.far=w.far=E.far=K,(P!==R.near||I!==R.far)&&(i.updateRenderState({depthNear:R.near,depthFar:R.far}),P=R.near,I=R.far),R.layers.mask=q.layers.mask|6,E.layers.mask=R.layers.mask&-5,w.layers.mask=R.layers.mask&-3;const le=q.parent,ae=R.cameras;W(R,le);for(let me=0;me<ae.length;me++)W(ae[me],le);ae.length===2?O(R,E,w):R.projectionMatrix.copy(E.projectionMatrix),G(q,R,le)};function G(q,Y,K){K===null?q.matrix.copy(Y.matrixWorld):(q.matrix.copy(K.matrixWorld),q.matrix.invert(),q.matrix.multiply(Y.matrixWorld)),q.matrix.decompose(q.position,q.quaternion,q.scale),q.updateMatrixWorld(!0),q.projectionMatrix.copy(Y.projectionMatrix),q.projectionMatrixInverse.copy(Y.projectionMatrixInverse),q.isPerspectiveCamera&&(q.fov=qr*2*Math.atan(1/q.projectionMatrix.elements[5]),q.zoom=1)}d(G,"updateUserCamera"),this.getCamera=function(){return R},this.getFoveation=function(){if(!(f===null&&p===null))return c},this.setFoveation=function(q){c=q,f!==null&&(f.fixedFoveation=q),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=q)},this.hasDepthSensing=function(){return _.texture!==null},this.getDepthSensingMesh=function(){return _.getMesh(R)},this.getCameraTexture=function(q){return g[q]};let Q=null;function z(q,Y){if(u=Y.getViewerPose(l||o),m=Y,u!==null){const K=u.views;p!==null&&(e.setRenderTargetFramebuffer(b,p.framebuffer),e.setRenderTarget(b));let le=!1;K.length!==R.cameras.length&&(R.cameras.length=0,le=!0);for(let he=0;he<K.length;he++){const ee=K[he];let ne=null;if(p!==null)ne=p.getViewport(ee);else{const xe=h.getViewSubImage(f,ee);ne=xe.viewport,he===0&&(e.setRenderTargetTextures(b,xe.colorTexture,xe.depthStencilTexture),e.setRenderTarget(b))}let ie=A[he];ie===void 0&&(ie=new Ut,ie.layers.enable(he),ie.viewport=new pt,A[he]=ie),ie.matrix.fromArray(ee.transform.matrix),ie.matrix.decompose(ie.position,ie.quaternion,ie.scale),ie.projectionMatrix.fromArray(ee.projectionMatrix),ie.projectionMatrixInverse.copy(ie.projectionMatrix).invert(),ie.viewport.set(ne.x,ne.y,ne.width,ne.height),he===0&&(R.matrix.copy(ie.matrix),R.matrix.decompose(R.position,R.quaternion,R.scale)),le===!0&&R.cameras.push(ie)}const ae=i.enabledFeatures;if(ae&&ae.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&y){h=n.getBinding();const he=h.getDepthInformation(K[0]);he&&he.isValid&&he.texture&&_.init(he,i.renderState)}if(ae&&ae.includes("camera-access")&&y){e.state.unbindTexture(),h=n.getBinding();for(let he=0;he<K.length;he++){const ee=K[he].camera;if(ee){let ne=g[ee];ne||(ne=new ca,g[ee]=ne);const ie=h.getCameraImage(ee);ne.sourceTexture=ie}}}}for(let K=0;K<C.length;K++){const le=S[K],ae=C[K];le!==null&&ae!==void 0&&ae.update(le,Y,l||o)}Q&&Q(q,Y),Y.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:Y}),m=null}d(z,"onAnimationFrame");const Z=new sb;Z.setAnimationLoop(z),this.setAnimationLoop=function(q){Q=q},this.dispose=function(){}}};d(P_,"WebXRManager");let gp=P_;const Is=new rn,gC=new Je;function _C(r,e){function t(_,g){_.matrixAutoUpdate===!0&&_.updateMatrix(),g.value.copy(_.matrix)}d(t,"refreshTransformUniform");function n(_,g){g.color.getRGB(_.fogColor.value,eb(r)),g.isFog?(_.fogNear.value=g.near,_.fogFar.value=g.far):g.isFogExp2&&(_.fogDensity.value=g.density)}d(n,"refreshFogUniforms");function i(_,g,v,M,b){g.isMeshBasicMaterial?s(_,g):g.isMeshLambertMaterial?(s(_,g),g.envMap&&(_.envMapIntensity.value=g.envMapIntensity)):g.isMeshToonMaterial?(s(_,g),h(_,g)):g.isMeshPhongMaterial?(s(_,g),u(_,g),g.envMap&&(_.envMapIntensity.value=g.envMapIntensity)):g.isMeshStandardMaterial?(s(_,g),f(_,g),g.isMeshPhysicalMaterial&&p(_,g,b)):g.isMeshMatcapMaterial?(s(_,g),m(_,g)):g.isMeshDepthMaterial?s(_,g):g.isMeshDistanceMaterial?(s(_,g),y(_,g)):g.isMeshNormalMaterial?s(_,g):g.isLineBasicMaterial?(o(_,g),g.isLineDashedMaterial&&a(_,g)):g.isPointsMaterial?c(_,g,v,M):g.isSpriteMaterial?l(_,g):g.isShadowMaterial?(_.color.value.copy(g.color),_.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}d(i,"refreshMaterialUniforms");function s(_,g){_.opacity.value=g.opacity,g.color&&_.diffuse.value.copy(g.color),g.emissive&&_.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(_.map.value=g.map,t(g.map,_.mapTransform)),g.alphaMap&&(_.alphaMap.value=g.alphaMap,t(g.alphaMap,_.alphaMapTransform)),g.bumpMap&&(_.bumpMap.value=g.bumpMap,t(g.bumpMap,_.bumpMapTransform),_.bumpScale.value=g.bumpScale,g.side===gn&&(_.bumpScale.value*=-1)),g.normalMap&&(_.normalMap.value=g.normalMap,t(g.normalMap,_.normalMapTransform),_.normalScale.value.copy(g.normalScale),g.side===gn&&_.normalScale.value.negate()),g.displacementMap&&(_.displacementMap.value=g.displacementMap,t(g.displacementMap,_.displacementMapTransform),_.displacementScale.value=g.displacementScale,_.displacementBias.value=g.displacementBias),g.emissiveMap&&(_.emissiveMap.value=g.emissiveMap,t(g.emissiveMap,_.emissiveMapTransform)),g.specularMap&&(_.specularMap.value=g.specularMap,t(g.specularMap,_.specularMapTransform)),g.alphaTest>0&&(_.alphaTest.value=g.alphaTest);const v=e.get(g),M=v.envMap,b=v.envMapRotation;M&&(_.envMap.value=M,Is.copy(b),Is.x*=-1,Is.y*=-1,Is.z*=-1,M.isCubeTexture&&M.isRenderTargetTexture===!1&&(Is.y*=-1,Is.z*=-1),_.envMapRotation.value.setFromMatrix4(gC.makeRotationFromEuler(Is)),_.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,_.reflectivity.value=g.reflectivity,_.ior.value=g.ior,_.refractionRatio.value=g.refractionRatio),g.lightMap&&(_.lightMap.value=g.lightMap,_.lightMapIntensity.value=g.lightMapIntensity,t(g.lightMap,_.lightMapTransform)),g.aoMap&&(_.aoMap.value=g.aoMap,_.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,_.aoMapTransform))}d(s,"refreshUniformsCommon");function o(_,g){_.diffuse.value.copy(g.color),_.opacity.value=g.opacity,g.map&&(_.map.value=g.map,t(g.map,_.mapTransform))}d(o,"refreshUniformsLine");function a(_,g){_.dashSize.value=g.dashSize,_.totalSize.value=g.dashSize+g.gapSize,_.scale.value=g.scale}d(a,"refreshUniformsDash");function c(_,g,v,M){_.diffuse.value.copy(g.color),_.opacity.value=g.opacity,_.size.value=g.size*v,_.scale.value=M*.5,g.map&&(_.map.value=g.map,t(g.map,_.uvTransform)),g.alphaMap&&(_.alphaMap.value=g.alphaMap,t(g.alphaMap,_.alphaMapTransform)),g.alphaTest>0&&(_.alphaTest.value=g.alphaTest)}d(c,"refreshUniformsPoints");function l(_,g){_.diffuse.value.copy(g.color),_.opacity.value=g.opacity,_.rotation.value=g.rotation,g.map&&(_.map.value=g.map,t(g.map,_.mapTransform)),g.alphaMap&&(_.alphaMap.value=g.alphaMap,t(g.alphaMap,_.alphaMapTransform)),g.alphaTest>0&&(_.alphaTest.value=g.alphaTest)}d(l,"refreshUniformsSprites");function u(_,g){_.specular.value.copy(g.specular),_.shininess.value=Math.max(g.shininess,1e-4)}d(u,"refreshUniformsPhong");function h(_,g){g.gradientMap&&(_.gradientMap.value=g.gradientMap)}d(h,"refreshUniformsToon");function f(_,g){_.metalness.value=g.metalness,g.metalnessMap&&(_.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,_.metalnessMapTransform)),_.roughness.value=g.roughness,g.roughnessMap&&(_.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,_.roughnessMapTransform)),g.envMap&&(_.envMapIntensity.value=g.envMapIntensity)}d(f,"refreshUniformsStandard");function p(_,g,v){_.ior.value=g.ior,g.sheen>0&&(_.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),_.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(_.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,_.sheenColorMapTransform)),g.sheenRoughnessMap&&(_.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,_.sheenRoughnessMapTransform))),g.clearcoat>0&&(_.clearcoat.value=g.clearcoat,_.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(_.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,_.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(_.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,_.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(_.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,_.clearcoatNormalMapTransform),_.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===gn&&_.clearcoatNormalScale.value.negate())),g.dispersion>0&&(_.dispersion.value=g.dispersion),g.iridescence>0&&(_.iridescence.value=g.iridescence,_.iridescenceIOR.value=g.iridescenceIOR,_.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],_.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(_.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,_.iridescenceMapTransform)),g.iridescenceThicknessMap&&(_.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,_.iridescenceThicknessMapTransform))),g.transmission>0&&(_.transmission.value=g.transmission,_.transmissionSamplerMap.value=v.texture,_.transmissionSamplerSize.value.set(v.width,v.height),g.transmissionMap&&(_.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,_.transmissionMapTransform)),_.thickness.value=g.thickness,g.thicknessMap&&(_.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,_.thicknessMapTransform)),_.attenuationDistance.value=g.attenuationDistance,_.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(_.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(_.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,_.anisotropyMapTransform))),_.specularIntensity.value=g.specularIntensity,_.specularColor.value.copy(g.specularColor),g.specularColorMap&&(_.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,_.specularColorMapTransform)),g.specularIntensityMap&&(_.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,_.specularIntensityMapTransform))}d(p,"refreshUniformsPhysical");function m(_,g){g.matcap&&(_.matcap.value=g.matcap)}d(m,"refreshUniformsMatcap");function y(_,g){const v=e.get(g).light;_.referencePosition.value.setFromMatrixPosition(v.matrixWorld),_.nearDistance.value=v.shadow.camera.near,_.farDistance.value=v.shadow.camera.far}return d(y,"refreshUniformsDistance"),{refreshFogUniforms:n,refreshMaterialUniforms:i}}d(_C,"WebGLMaterials");function yC(r,e,t,n){let i={},s={},o=[];const a=r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS);function c(v,M){const b=M.program;n.uniformBlockBinding(v,b)}d(c,"bind");function l(v,M){let b=i[v.id];b===void 0&&(m(v),b=u(v),i[v.id]=b,v.addEventListener("dispose",_));const C=M.program;n.updateUBOMapping(v,C);const S=e.render.frame;s[v.id]!==S&&(f(v),s[v.id]=S)}d(l,"update");function u(v){const M=h();v.__bindingPointIndex=M;const b=r.createBuffer(),C=v.__size,S=v.usage;return r.bindBuffer(r.UNIFORM_BUFFER,b),r.bufferData(r.UNIFORM_BUFFER,C,S),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,M,b),b}d(u,"createBuffer");function h(){for(let v=0;v<a;v++)if(o.indexOf(v)===-1)return o.push(v),v;return Ye("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}d(h,"allocateBindingPointIndex");function f(v){const M=i[v.id],b=v.uniforms,C=v.__cache;r.bindBuffer(r.UNIFORM_BUFFER,M);for(let S=0,T=b.length;S<T;S++){const x=Array.isArray(b[S])?b[S]:[b[S]];for(let E=0,w=x.length;E<w;E++){const A=x[E];if(p(A,S,E,C)===!0){const R=A.__offset,P=Array.isArray(A.value)?A.value:[A.value];let I=0;for(let N=0;N<P.length;N++){const D=P[N],L=y(D);typeof D=="number"||typeof D=="boolean"?(A.__data[0]=D,r.bufferSubData(r.UNIFORM_BUFFER,R+I,A.__data)):D.isMatrix3?(A.__data[0]=D.elements[0],A.__data[1]=D.elements[1],A.__data[2]=D.elements[2],A.__data[3]=0,A.__data[4]=D.elements[3],A.__data[5]=D.elements[4],A.__data[6]=D.elements[5],A.__data[7]=0,A.__data[8]=D.elements[6],A.__data[9]=D.elements[7],A.__data[10]=D.elements[8],A.__data[11]=0):(D.toArray(A.__data,I),I+=L.storage/Float32Array.BYTES_PER_ELEMENT)}r.bufferSubData(r.UNIFORM_BUFFER,R,A.__data)}}}r.bindBuffer(r.UNIFORM_BUFFER,null)}d(f,"updateBufferData");function p(v,M,b,C){const S=v.value,T=M+"_"+b;if(C[T]===void 0)return typeof S=="number"||typeof S=="boolean"?C[T]=S:C[T]=S.clone(),!0;{const x=C[T];if(typeof S=="number"||typeof S=="boolean"){if(x!==S)return C[T]=S,!0}else if(x.equals(S)===!1)return x.copy(S),!0}return!1}d(p,"hasUniformChanged");function m(v){const M=v.uniforms;let b=0;const C=16;for(let T=0,x=M.length;T<x;T++){const E=Array.isArray(M[T])?M[T]:[M[T]];for(let w=0,A=E.length;w<A;w++){const R=E[w],P=Array.isArray(R.value)?R.value:[R.value];for(let I=0,N=P.length;I<N;I++){const D=P[I],L=y(D),H=b%C,X=H%L.boundary,O=H+X;b+=X,O!==0&&C-O<L.storage&&(b+=C-O),R.__data=new Float32Array(L.storage/Float32Array.BYTES_PER_ELEMENT),R.__offset=b,b+=L.storage}}}const S=b%C;return S>0&&(b+=C-S),v.__size=b,v.__cache={},this}d(m,"prepareUniformsGroup");function y(v){const M={boundary:0,storage:0};return typeof v=="number"||typeof v=="boolean"?(M.boundary=4,M.storage=4):v.isVector2?(M.boundary=8,M.storage=8):v.isVector3||v.isColor?(M.boundary=16,M.storage=12):v.isVector4?(M.boundary=16,M.storage=16):v.isMatrix3?(M.boundary=48,M.storage=48):v.isMatrix4?(M.boundary=64,M.storage=64):v.isTexture?Ue("WebGLRenderer: Texture samplers can not be part of an uniforms group."):Ue("WebGLRenderer: Unsupported uniform value type.",v),M}d(y,"getUniformSize");function _(v){const M=v.target;M.removeEventListener("dispose",_);const b=o.indexOf(M.__bindingPointIndex);o.splice(b,1),r.deleteBuffer(i[M.id]),delete i[M.id],delete s[M.id]}d(_,"onUniformsGroupsDispose");function g(){for(const v in i)r.deleteBuffer(i[v]);o=[],i={},s={}}return d(g,"dispose"),{bind:c,update:l,dispose:g}}d(yC,"WebGLUniformsGroups");const xC=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let ri=null;function vC(){return ri===null&&(ri=new Fn(xC,16,16,$s,_i),ri.name="DFG_LUT",ri.minFilter=wt,ri.magFilter=wt,ri.wrapS=Mn,ri.wrapT=Mn,ri.generateMipmaps=!1,ri.needsUpdate=!0),ri}d(vC,"getDFGLUT");const N_=class N_{constructor(e={}){const{canvas:t=Xv(),context:n=null,depth:i=!0,stencil:s=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1,reversedDepthBuffer:f=!1,outputBufferType:p=Sn}=e;this.isWebGLRenderer=!0;let m;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");m=n.getContextAttributes().alpha}else m=o;const y=p,_=new Set([Rh,Ih,Oa]),g=new Set([Sn,kn,$r,Xr,Ah,Th]),v=new Uint32Array(4),M=new Int32Array(4);let b=null,C=null;const S=[],T=[];let x=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=jn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const E=this;let w=!1;this._outputColorSpace=un;let A=0,R=0,P=null,I=-1,N=null;const D=new pt,L=new pt;let H=null;const X=new ke(0);let O=0,W=t.width,G=t.height,Q=1,z=null,Z=null;const q=new pt(0,0,W,G),Y=new pt(0,0,W,G);let K=!1;const le=new cs;let ae=!1,me=!1;const ve=new Je,he=new U,ee=new pt,ne={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ie=!1;function xe(){return P===null?Q:1}d(xe,"getTargetPixelRatio");let $=n;function be(B,te){return t.getContext(B,te)}d(be,"getContext");try{const B={alpha:!0,depth:i,stencil:s,antialias:a,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Mh}`),t.addEventListener("webglcontextlost",Pe,!1),t.addEventListener("webglcontextrestored",$e,!1),t.addEventListener("webglcontextcreationerror",at,!1),$===null){const te="webgl2";if($=be(te,B),$===null)throw be(te)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(B){throw Ye("WebGLRenderer: "+B.message),B}let Ie,Ne,Ae,V,F,j,re,ge,ue,Le,Te,De,He,de,Me,pe,Ce,we,Oe,J,_e,ye,Re;function Se(){Ie=new IA($),Ie.init(),_e=new lb($,Ie),Ne=new bA($,Ie,e,_e),Ae=new fC($,Ie),Ne.reversedDepthBuffer&&f&&Ae.buffers.depth.setReversed(!0),V=new NA($),F=new jT,j=new dC($,Ie,Ae,F,Ne,_e,V),re=new CA(E),ge=new Uw($),ye=new xA($,ge),ue=new RA($,ge,V,ye),Le=new FA($,ue,ge,ye,V),we=new DA($,Ne,j),Me=new SA(F),Te=new JT(E,re,Ie,Ne,ye,Me),De=new _C(E,F),He=new eC,de=new oC(Ie),Ce=new yA(E,re,Ae,Le,m,c),pe=new hC(E,Le,Ne),Re=new yC($,V,Ne,Ae),Oe=new vA($,Ie,V),J=new PA($,Ie,V),V.programs=Te.programs,E.capabilities=Ne,E.extensions=Ie,E.properties=F,E.renderLists=He,E.shadowMap=pe,E.state=Ae,E.info=V}d(Se,"initGLContext"),Se(),y!==Sn&&(x=new OA(y,t.width,t.height,i,s));const se=new gp(E,$);this.xr=se,this.getContext=function(){return $},this.getContextAttributes=function(){return $.getContextAttributes()},this.forceContextLoss=function(){const B=Ie.get("WEBGL_lose_context");B&&B.loseContext()},this.forceContextRestore=function(){const B=Ie.get("WEBGL_lose_context");B&&B.restoreContext()},this.getPixelRatio=function(){return Q},this.setPixelRatio=function(B){B!==void 0&&(Q=B,this.setSize(W,G,!1))},this.getSize=function(B){return B.set(W,G)},this.setSize=function(B,te,fe=!0){if(se.isPresenting){Ue("WebGLRenderer: Can't change size while VR device is presenting.");return}W=B,G=te,t.width=Math.floor(B*Q),t.height=Math.floor(te*Q),fe===!0&&(t.style.width=B+"px",t.style.height=te+"px"),x!==null&&x.setSize(t.width,t.height),this.setViewport(0,0,B,te)},this.getDrawingBufferSize=function(B){return B.set(W*Q,G*Q).floor()},this.setDrawingBufferSize=function(B,te,fe){W=B,G=te,Q=fe,t.width=Math.floor(B*fe),t.height=Math.floor(te*fe),this.setViewport(0,0,B,te)},this.setEffects=function(B){if(y===Sn){console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(B){for(let te=0;te<B.length;te++)if(B[te].isOutputPass===!0){console.warn("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}x.setEffects(B||[])},this.getCurrentViewport=function(B){return B.copy(D)},this.getViewport=function(B){return B.copy(q)},this.setViewport=function(B,te,fe,ce){B.isVector4?q.set(B.x,B.y,B.z,B.w):q.set(B,te,fe,ce),Ae.viewport(D.copy(q).multiplyScalar(Q).round())},this.getScissor=function(B){return B.copy(Y)},this.setScissor=function(B,te,fe,ce){B.isVector4?Y.set(B.x,B.y,B.z,B.w):Y.set(B,te,fe,ce),Ae.scissor(L.copy(Y).multiplyScalar(Q).round())},this.getScissorTest=function(){return K},this.setScissorTest=function(B){Ae.setScissorTest(K=B)},this.setOpaqueSort=function(B){z=B},this.setTransparentSort=function(B){Z=B},this.getClearColor=function(B){return B.copy(Ce.getClearColor())},this.setClearColor=function(){Ce.setClearColor(...arguments)},this.getClearAlpha=function(){return Ce.getClearAlpha()},this.setClearAlpha=function(){Ce.setClearAlpha(...arguments)},this.clear=function(B=!0,te=!0,fe=!0){let ce=0;if(B){let oe=!1;if(P!==null){const Be=P.texture.format;oe=_.has(Be)}if(oe){const Be=P.texture.type,Ge=g.has(Be),ze=Ce.getClearColor(),Xe=Ce.getClearAlpha(),Ze=ze.r,it=ze.g,ot=ze.b;Ge?(v[0]=Ze,v[1]=it,v[2]=ot,v[3]=Xe,$.clearBufferuiv($.COLOR,0,v)):(M[0]=Ze,M[1]=it,M[2]=ot,M[3]=Xe,$.clearBufferiv($.COLOR,0,M))}else ce|=$.COLOR_BUFFER_BIT}te&&(ce|=$.DEPTH_BUFFER_BIT),fe&&(ce|=$.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),ce!==0&&$.clear(ce)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Pe,!1),t.removeEventListener("webglcontextrestored",$e,!1),t.removeEventListener("webglcontextcreationerror",at,!1),Ce.dispose(),He.dispose(),de.dispose(),F.dispose(),re.dispose(),Le.dispose(),ye.dispose(),Re.dispose(),Te.dispose(),se.dispose(),se.removeEventListener("sessionstart",X_),se.removeEventListener("sessionend",q_),ps.stop()};function Pe(B){B.preventDefault(),ta("WebGLRenderer: Context Lost."),w=!0}d(Pe,"onContextLost");function $e(){ta("WebGLRenderer: Context Restored."),w=!1;const B=V.autoReset,te=pe.enabled,fe=pe.autoUpdate,ce=pe.needsUpdate,oe=pe.type;Se(),V.autoReset=B,pe.enabled=te,pe.autoUpdate=fe,pe.needsUpdate=ce,pe.type=oe}d($e,"onContextRestore");function at(B){Ye("WebGLRenderer: A WebGL context could not be created. Reason: ",B.statusMessage)}d(at,"onContextCreationError");function ct(B){const te=B.target;te.removeEventListener("dispose",ct),Gn(te)}d(ct,"onMaterialDispose");function Gn(B){an(B),F.remove(B)}d(Gn,"deallocateMaterial");function an(B){const te=F.get(B).programs;te!==void 0&&(te.forEach(function(fe){Te.releaseProgram(fe)}),B.isShaderMaterial&&Te.releaseShaderCache(B))}d(an,"releaseMaterialProgramReferences"),this.renderBufferDirect=function(B,te,fe,ce,oe,Be){te===null&&(te=ne);const Ge=oe.isMesh&&oe.matrixWorld.determinant()<0,ze=Lb(B,te,fe,ce,oe);Ae.setMaterial(ce,Ge);let Xe=fe.index,Ze=1;if(ce.wireframe===!0){if(Xe=ue.getWireframeAttribute(fe),Xe===void 0)return;Ze=2}const it=fe.drawRange,ot=fe.attributes.position;let Ke=it.start*Ze,xt=(it.start+it.count)*Ze;Be!==null&&(Ke=Math.max(Ke,Be.start*Ze),xt=Math.min(xt,(Be.start+Be.count)*Ze)),Xe!==null?(Ke=Math.max(Ke,0),xt=Math.min(xt,Xe.count)):ot!=null&&(Ke=Math.max(Ke,0),xt=Math.min(xt,ot.count));const Rt=xt-Ke;if(Rt<0||Rt===1/0)return;ye.setup(oe,ce,ze,fe,Xe);let Tt,vt=Oe;if(Xe!==null&&(Tt=ge.get(Xe),vt=J,vt.setIndex(Tt)),oe.isMesh)ce.wireframe===!0?(Ae.setLineWidth(ce.wireframeLinewidth*xe()),vt.setMode($.LINES)):vt.setMode($.TRIANGLES);else if(oe.isLine){let jt=ce.linewidth;jt===void 0&&(jt=1),Ae.setLineWidth(jt*xe()),oe.isLineSegments?vt.setMode($.LINES):oe.isLineLoop?vt.setMode($.LINE_LOOP):vt.setMode($.LINE_STRIP)}else oe.isPoints?vt.setMode($.POINTS):oe.isSprite&&vt.setMode($.TRIANGLES);if(oe.isBatchedMesh)if(oe._multiDrawInstances!==null)na("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),vt.renderMultiDrawInstances(oe._multiDrawStarts,oe._multiDrawCounts,oe._multiDrawCount,oe._multiDrawInstances);else if(Ie.get("WEBGL_multi_draw"))vt.renderMultiDraw(oe._multiDrawStarts,oe._multiDrawCounts,oe._multiDrawCount);else{const jt=oe._multiDrawStarts,qe=oe._multiDrawCounts,Tn=oe._multiDrawCount,dt=Xe?ge.get(Xe).bytesPerElement:1,Wn=F.get(ce).currentProgram.getUniforms();for(let ti=0;ti<Tn;ti++)Wn.setValue($,"_gl_DrawID",ti),vt.render(jt[ti]/dt,qe[ti])}else if(oe.isInstancedMesh)vt.renderInstances(Ke,Rt,oe.count);else if(fe.isInstancedBufferGeometry){const jt=fe._maxInstanceCount!==void 0?fe._maxInstanceCount:1/0,qe=Math.min(fe.instanceCount,jt);vt.renderInstances(Ke,Rt,qe)}else vt.render(Ke,Rt)};function Oi(B,te,fe){B.transparent===!0&&B.side===Bt&&B.forceSinglePass===!1?(B.side=gn,B.needsUpdate=!0,ka(B,te,fe),B.side=zn,B.needsUpdate=!0,ka(B,te,fe),B.side=Bt):ka(B,te,fe)}d(Oi,"prepareMaterial"),this.compile=function(B,te,fe=null){fe===null&&(fe=B),C=de.get(fe),C.init(te),T.push(C),fe.traverseVisible(function(oe){oe.isLight&&oe.layers.test(te.layers)&&(C.pushLight(oe),oe.castShadow&&C.pushShadow(oe))}),B!==fe&&B.traverseVisible(function(oe){oe.isLight&&oe.layers.test(te.layers)&&(C.pushLight(oe),oe.castShadow&&C.pushShadow(oe))}),C.setupLights();const ce=new Set;return B.traverse(function(oe){if(!(oe.isMesh||oe.isPoints||oe.isLine||oe.isSprite))return;const Be=oe.material;if(Be)if(Array.isArray(Be))for(let Ge=0;Ge<Be.length;Ge++){const ze=Be[Ge];Oi(ze,fe,oe),ce.add(ze)}else Oi(Be,fe,oe),ce.add(Be)}),C=T.pop(),ce},this.compileAsync=function(B,te,fe=null){const ce=this.compile(B,te,fe);return new Promise(oe=>{function Be(){if(ce.forEach(function(Ge){F.get(Ge).currentProgram.isReady()&&ce.delete(Ge)}),ce.size===0){oe(B);return}setTimeout(Be,10)}d(Be,"checkMaterialsReady"),Ie.get("KHR_parallel_shader_compile")!==null?Be():setTimeout(Be,10)})};let Bh=null;function Fb(B){Bh&&Bh(B)}d(Fb,"onAnimationFrame");function X_(){ps.stop()}d(X_,"onXRSessionStart");function q_(){ps.start()}d(q_,"onXRSessionEnd");const ps=new sb;ps.setAnimationLoop(Fb),typeof self<"u"&&ps.setContext(self),this.setAnimationLoop=function(B){Bh=B,se.setAnimationLoop(B),B===null?ps.stop():ps.start()},se.addEventListener("sessionstart",X_),se.addEventListener("sessionend",q_),this.render=function(B,te){if(te!==void 0&&te.isCamera!==!0){Ye("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(w===!0)return;const fe=se.enabled===!0&&se.isPresenting===!0,ce=x!==null&&(P===null||fe)&&x.begin(E,P);if(B.matrixWorldAutoUpdate===!0&&B.updateMatrixWorld(),te.parent===null&&te.matrixWorldAutoUpdate===!0&&te.updateMatrixWorld(),se.enabled===!0&&se.isPresenting===!0&&(x===null||x.isCompositing()===!1)&&(se.cameraAutoUpdate===!0&&se.updateCamera(te),te=se.getCamera()),B.isScene===!0&&B.onBeforeRender(E,B,te,P),C=de.get(B,T.length),C.init(te),T.push(C),ve.multiplyMatrices(te.projectionMatrix,te.matrixWorldInverse),le.setFromProjectionMatrix(ve,Rn,te.reversedDepth),me=this.localClippingEnabled,ae=Me.init(this.clippingPlanes,me),b=He.get(B,S.length),b.init(),S.push(b),se.enabled===!0&&se.isPresenting===!0){const Ge=E.xr.getDepthSensingMesh();Ge!==null&&zh(Ge,te,-1/0,E.sortObjects)}zh(B,te,0,E.sortObjects),b.finish(),E.sortObjects===!0&&b.sort(z,Z),ie=se.enabled===!1||se.isPresenting===!1||se.hasDepthSensing()===!1,ie&&Ce.addToRenderList(b,B),this.info.render.frame++,ae===!0&&Me.beginShadows();const oe=C.state.shadowsArray;if(pe.render(oe,B,te),ae===!0&&Me.endShadows(),this.info.autoReset===!0&&this.info.reset(),(ce&&x.hasRenderPass())===!1){const Ge=b.opaque,ze=b.transmissive;if(C.setupLights(),te.isArrayCamera){const Xe=te.cameras;if(ze.length>0)for(let Ze=0,it=Xe.length;Ze<it;Ze++){const ot=Xe[Ze];Z_(Ge,ze,B,ot)}ie&&Ce.render(B);for(let Ze=0,it=Xe.length;Ze<it;Ze++){const ot=Xe[Ze];Y_(b,B,ot,ot.viewport)}}else ze.length>0&&Z_(Ge,ze,B,te),ie&&Ce.render(B),Y_(b,B,te)}P!==null&&R===0&&(j.updateMultisampleRenderTarget(P),j.updateRenderTargetMipmap(P)),ce&&x.end(E),B.isScene===!0&&B.onAfterRender(E,B,te),ye.resetDefaultState(),I=-1,N=null,T.pop(),T.length>0?(C=T[T.length-1],ae===!0&&Me.setGlobalState(E.clippingPlanes,C.state.camera)):C=null,S.pop(),S.length>0?b=S[S.length-1]:b=null};function zh(B,te,fe,ce){if(B.visible===!1)return;if(B.layers.test(te.layers)){if(B.isGroup)fe=B.renderOrder;else if(B.isLOD)B.autoUpdate===!0&&B.update(te);else if(B.isLight)C.pushLight(B),B.castShadow&&C.pushShadow(B);else if(B.isSprite){if(!B.frustumCulled||le.intersectsSprite(B)){ce&&ee.setFromMatrixPosition(B.matrixWorld).applyMatrix4(ve);const Ge=Le.update(B),ze=B.material;ze.visible&&b.push(B,Ge,ze,fe,ee.z,null)}}else if((B.isMesh||B.isLine||B.isPoints)&&(!B.frustumCulled||le.intersectsObject(B))){const Ge=Le.update(B),ze=B.material;if(ce&&(B.boundingSphere!==void 0?(B.boundingSphere===null&&B.computeBoundingSphere(),ee.copy(B.boundingSphere.center)):(Ge.boundingSphere===null&&Ge.computeBoundingSphere(),ee.copy(Ge.boundingSphere.center)),ee.applyMatrix4(B.matrixWorld).applyMatrix4(ve)),Array.isArray(ze)){const Xe=Ge.groups;for(let Ze=0,it=Xe.length;Ze<it;Ze++){const ot=Xe[Ze],Ke=ze[ot.materialIndex];Ke&&Ke.visible&&b.push(B,Ge,Ke,fe,ee.z,ot)}}else ze.visible&&b.push(B,Ge,ze,fe,ee.z,null)}}const Be=B.children;for(let Ge=0,ze=Be.length;Ge<ze;Ge++)zh(Be[Ge],te,fe,ce)}d(zh,"projectObject");function Y_(B,te,fe,ce){const{opaque:oe,transmissive:Be,transparent:Ge}=B;C.setupLightsView(fe),ae===!0&&Me.setGlobalState(E.clippingPlanes,fe),ce&&Ae.viewport(D.copy(ce)),oe.length>0&&za(oe,te,fe),Be.length>0&&za(Be,te,fe),Ge.length>0&&za(Ge,te,fe),Ae.buffers.depth.setTest(!0),Ae.buffers.depth.setMask(!0),Ae.buffers.color.setMask(!0),Ae.setPolygonOffset(!1)}d(Y_,"renderScene");function Z_(B,te,fe,ce){if((fe.isScene===!0?fe.overrideMaterial:null)!==null)return;if(C.state.transmissionRenderTarget[ce.id]===void 0){const Ke=Ie.has("EXT_color_buffer_half_float")||Ie.has("EXT_color_buffer_float");C.state.transmissionRenderTarget[ce.id]=new _n(1,1,{generateMipmaps:!0,type:Ke?_i:Sn,minFilter:fi,samples:Math.max(4,Ne.samples),stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:lt.workingColorSpace})}const Be=C.state.transmissionRenderTarget[ce.id],Ge=ce.viewport||D;Be.setSize(Ge.z*E.transmissionResolutionScale,Ge.w*E.transmissionResolutionScale);const ze=E.getRenderTarget(),Xe=E.getActiveCubeFace(),Ze=E.getActiveMipmapLevel();E.setRenderTarget(Be),E.getClearColor(X),O=E.getClearAlpha(),O<1&&E.setClearColor(16777215,.5),E.clear(),ie&&Ce.render(fe);const it=E.toneMapping;E.toneMapping=jn;const ot=ce.viewport;if(ce.viewport!==void 0&&(ce.viewport=void 0),C.setupLightsView(ce),ae===!0&&Me.setGlobalState(E.clippingPlanes,ce),za(B,fe,ce),j.updateMultisampleRenderTarget(Be),j.updateRenderTargetMipmap(Be),Ie.has("WEBGL_multisampled_render_to_texture")===!1){let Ke=!1;for(let xt=0,Rt=te.length;xt<Rt;xt++){const Tt=te[xt],{object:vt,geometry:jt,material:qe,group:Tn}=Tt;if(qe.side===Bt&&vt.layers.test(ce.layers)){const dt=qe.side;qe.side=gn,qe.needsUpdate=!0,K_(vt,fe,ce,jt,qe,Tn),qe.side=dt,qe.needsUpdate=!0,Ke=!0}}Ke===!0&&(j.updateMultisampleRenderTarget(Be),j.updateRenderTargetMipmap(Be))}E.setRenderTarget(ze,Xe,Ze),E.setClearColor(X,O),ot!==void 0&&(ce.viewport=ot),E.toneMapping=it}d(Z_,"renderTransmissionPass");function za(B,te,fe){const ce=te.isScene===!0?te.overrideMaterial:null;for(let oe=0,Be=B.length;oe<Be;oe++){const Ge=B[oe],{object:ze,geometry:Xe,group:Ze}=Ge;let it=Ge.material;it.allowOverride===!0&&ce!==null&&(it=ce),ze.layers.test(fe.layers)&&K_(ze,te,fe,Xe,it,Ze)}}d(za,"renderObjects");function K_(B,te,fe,ce,oe,Be){B.onBeforeRender(E,te,fe,ce,oe,Be),B.modelViewMatrix.multiplyMatrices(fe.matrixWorldInverse,B.matrixWorld),B.normalMatrix.getNormalMatrix(B.modelViewMatrix),oe.onBeforeRender(E,te,fe,ce,B,Be),oe.transparent===!0&&oe.side===Bt&&oe.forceSinglePass===!1?(oe.side=gn,oe.needsUpdate=!0,E.renderBufferDirect(fe,te,ce,oe,B,Be),oe.side=zn,oe.needsUpdate=!0,E.renderBufferDirect(fe,te,ce,oe,B,Be),oe.side=Bt):E.renderBufferDirect(fe,te,ce,oe,B,Be),B.onAfterRender(E,te,fe,ce,oe,Be)}d(K_,"renderObject");function ka(B,te,fe){te.isScene!==!0&&(te=ne);const ce=F.get(B),oe=C.state.lights,Be=C.state.shadowsArray,Ge=oe.state.version,ze=Te.getParameters(B,oe.state,Be,te,fe),Xe=Te.getProgramCacheKey(ze);let Ze=ce.programs;ce.environment=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?te.environment:null,ce.fog=te.fog;const it=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap;ce.envMap=re.get(B.envMap||ce.environment,it),ce.envMapRotation=ce.environment!==null&&B.envMap===null?te.environmentRotation:B.envMapRotation,Ze===void 0&&(B.addEventListener("dispose",ct),Ze=new Map,ce.programs=Ze);let ot=Ze.get(Xe);if(ot!==void 0){if(ce.currentProgram===ot&&ce.lightsStateVersion===Ge)return j_(B,ze),ot}else ze.uniforms=Te.getUniforms(B),B.onBeforeCompile(ze,E),ot=Te.acquireProgram(ze,Xe),Ze.set(Xe,ot),ce.uniforms=ze.uniforms;const Ke=ce.uniforms;return(!B.isShaderMaterial&&!B.isRawShaderMaterial||B.clipping===!0)&&(Ke.clippingPlanes=Me.uniform),j_(B,ze),ce.needsLights=Ub(B),ce.lightsStateVersion=Ge,ce.needsLights&&(Ke.ambientLightColor.value=oe.state.ambient,Ke.lightProbe.value=oe.state.probe,Ke.directionalLights.value=oe.state.directional,Ke.directionalLightShadows.value=oe.state.directionalShadow,Ke.spotLights.value=oe.state.spot,Ke.spotLightShadows.value=oe.state.spotShadow,Ke.rectAreaLights.value=oe.state.rectArea,Ke.ltc_1.value=oe.state.rectAreaLTC1,Ke.ltc_2.value=oe.state.rectAreaLTC2,Ke.pointLights.value=oe.state.point,Ke.pointLightShadows.value=oe.state.pointShadow,Ke.hemisphereLights.value=oe.state.hemi,Ke.directionalShadowMatrix.value=oe.state.directionalShadowMatrix,Ke.spotLightMatrix.value=oe.state.spotLightMatrix,Ke.spotLightMap.value=oe.state.spotLightMap,Ke.pointShadowMatrix.value=oe.state.pointShadowMatrix),ce.currentProgram=ot,ce.uniformsList=null,ot}d(ka,"getProgram");function J_(B){if(B.uniformsList===null){const te=B.currentProgram.getUniforms();B.uniformsList=Vr.seqWithValue(te.seq,B.uniforms)}return B.uniformsList}d(J_,"getUniformList");function j_(B,te){const fe=F.get(B);fe.outputColorSpace=te.outputColorSpace,fe.batching=te.batching,fe.batchingColor=te.batchingColor,fe.instancing=te.instancing,fe.instancingColor=te.instancingColor,fe.instancingMorph=te.instancingMorph,fe.skinning=te.skinning,fe.morphTargets=te.morphTargets,fe.morphNormals=te.morphNormals,fe.morphColors=te.morphColors,fe.morphTargetsCount=te.morphTargetsCount,fe.numClippingPlanes=te.numClippingPlanes,fe.numIntersection=te.numClipIntersection,fe.vertexAlphas=te.vertexAlphas,fe.vertexTangents=te.vertexTangents,fe.toneMapping=te.toneMapping}d(j_,"updateCommonMaterialProperties");function Lb(B,te,fe,ce,oe){te.isScene!==!0&&(te=ne),j.resetTextureUnits();const Be=te.fog,Ge=ce.isMeshStandardMaterial||ce.isMeshLambertMaterial||ce.isMeshPhongMaterial?te.environment:null,ze=P===null?E.outputColorSpace:P.isXRRenderTarget===!0?P.texture.colorSpace:Xs,Xe=ce.isMeshStandardMaterial||ce.isMeshLambertMaterial&&!ce.envMap||ce.isMeshPhongMaterial&&!ce.envMap,Ze=re.get(ce.envMap||Ge,Xe),it=ce.vertexColors===!0&&!!fe.attributes.color&&fe.attributes.color.itemSize===4,ot=!!fe.attributes.tangent&&(!!ce.normalMap||ce.anisotropy>0),Ke=!!fe.morphAttributes.position,xt=!!fe.morphAttributes.normal,Rt=!!fe.morphAttributes.color;let Tt=jn;ce.toneMapped&&(P===null||P.isXRRenderTarget===!0)&&(Tt=E.toneMapping);const vt=fe.morphAttributes.position||fe.morphAttributes.normal||fe.morphAttributes.color,jt=vt!==void 0?vt.length:0,qe=F.get(ce),Tn=C.state.lights;if(ae===!0&&(me===!0||B!==N)){const Ht=B===N&&ce.id===I;Me.setState(ce,B,Ht)}let dt=!1;ce.version===qe.__version?(qe.needsLights&&qe.lightsStateVersion!==Tn.state.version||qe.outputColorSpace!==ze||oe.isBatchedMesh&&qe.batching===!1||!oe.isBatchedMesh&&qe.batching===!0||oe.isBatchedMesh&&qe.batchingColor===!0&&oe.colorTexture===null||oe.isBatchedMesh&&qe.batchingColor===!1&&oe.colorTexture!==null||oe.isInstancedMesh&&qe.instancing===!1||!oe.isInstancedMesh&&qe.instancing===!0||oe.isSkinnedMesh&&qe.skinning===!1||!oe.isSkinnedMesh&&qe.skinning===!0||oe.isInstancedMesh&&qe.instancingColor===!0&&oe.instanceColor===null||oe.isInstancedMesh&&qe.instancingColor===!1&&oe.instanceColor!==null||oe.isInstancedMesh&&qe.instancingMorph===!0&&oe.morphTexture===null||oe.isInstancedMesh&&qe.instancingMorph===!1&&oe.morphTexture!==null||qe.envMap!==Ze||ce.fog===!0&&qe.fog!==Be||qe.numClippingPlanes!==void 0&&(qe.numClippingPlanes!==Me.numPlanes||qe.numIntersection!==Me.numIntersection)||qe.vertexAlphas!==it||qe.vertexTangents!==ot||qe.morphTargets!==Ke||qe.morphNormals!==xt||qe.morphColors!==Rt||qe.toneMapping!==Tt||qe.morphTargetsCount!==jt)&&(dt=!0):(dt=!0,qe.__version=ce.version);let Wn=qe.currentProgram;dt===!0&&(Wn=ka(ce,te,oe));let ti=!1,ms=!1,ar=!1;const St=Wn.getUniforms(),$t=qe.uniforms;if(Ae.useProgram(Wn.program)&&(ti=!0,ms=!0,ar=!0),ce.id!==I&&(I=ce.id,ms=!0),ti||N!==B){Ae.buffers.depth.getReversed()&&B.reversedDepth!==!0&&(B._reversedDepth=!0,B.updateProjectionMatrix()),St.setValue($,"projectionMatrix",B.projectionMatrix),St.setValue($,"viewMatrix",B.matrixWorldInverse);const Bi=St.map.cameraPosition;Bi!==void 0&&Bi.setValue($,he.setFromMatrixPosition(B.matrixWorld)),Ne.logarithmicDepthBuffer&&St.setValue($,"logDepthBufFC",2/(Math.log(B.far+1)/Math.LN2)),(ce.isMeshPhongMaterial||ce.isMeshToonMaterial||ce.isMeshLambertMaterial||ce.isMeshBasicMaterial||ce.isMeshStandardMaterial||ce.isShaderMaterial)&&St.setValue($,"isOrthographic",B.isOrthographicCamera===!0),N!==B&&(N=B,ms=!0,ar=!0)}if(qe.needsLights&&(Tn.state.directionalShadowMap.length>0&&St.setValue($,"directionalShadowMap",Tn.state.directionalShadowMap,j),Tn.state.spotShadowMap.length>0&&St.setValue($,"spotShadowMap",Tn.state.spotShadowMap,j),Tn.state.pointShadowMap.length>0&&St.setValue($,"pointShadowMap",Tn.state.pointShadowMap,j)),oe.isSkinnedMesh){St.setOptional($,oe,"bindMatrix"),St.setOptional($,oe,"bindMatrixInverse");const Ht=oe.skeleton;Ht&&(Ht.boneTexture===null&&Ht.computeBoneTexture(),St.setValue($,"boneTexture",Ht.boneTexture,j))}oe.isBatchedMesh&&(St.setOptional($,oe,"batchingTexture"),St.setValue($,"batchingTexture",oe._matricesTexture,j),St.setOptional($,oe,"batchingIdTexture"),St.setValue($,"batchingIdTexture",oe._indirectTexture,j),St.setOptional($,oe,"batchingColorTexture"),oe._colorsTexture!==null&&St.setValue($,"batchingColorTexture",oe._colorsTexture,j));const Ui=fe.morphAttributes;if((Ui.position!==void 0||Ui.normal!==void 0||Ui.color!==void 0)&&we.update(oe,fe,Wn),(ms||qe.receiveShadow!==oe.receiveShadow)&&(qe.receiveShadow=oe.receiveShadow,St.setValue($,"receiveShadow",oe.receiveShadow)),(ce.isMeshStandardMaterial||ce.isMeshLambertMaterial||ce.isMeshPhongMaterial)&&ce.envMap===null&&te.environment!==null&&($t.envMapIntensity.value=te.environmentIntensity),$t.dfgLUT!==void 0&&($t.dfgLUT.value=vC()),ms&&(St.setValue($,"toneMappingExposure",E.toneMappingExposure),qe.needsLights&&Ob($t,ar),Be&&ce.fog===!0&&De.refreshFogUniforms($t,Be),De.refreshMaterialUniforms($t,ce,Q,G,C.state.transmissionRenderTarget[B.id]),Vr.upload($,J_(qe),$t,j)),ce.isShaderMaterial&&ce.uniformsNeedUpdate===!0&&(Vr.upload($,J_(qe),$t,j),ce.uniformsNeedUpdate=!1),ce.isSpriteMaterial&&St.setValue($,"center",oe.center),St.setValue($,"modelViewMatrix",oe.modelViewMatrix),St.setValue($,"normalMatrix",oe.normalMatrix),St.setValue($,"modelMatrix",oe.matrixWorld),ce.isShaderMaterial||ce.isRawShaderMaterial){const Ht=ce.uniformsGroups;for(let Bi=0,cr=Ht.length;Bi<cr;Bi++){const Q_=Ht[Bi];Re.update(Q_,Wn),Re.bind(Q_,Wn)}}return Wn}d(Lb,"setProgram");function Ob(B,te){B.ambientLightColor.needsUpdate=te,B.lightProbe.needsUpdate=te,B.directionalLights.needsUpdate=te,B.directionalLightShadows.needsUpdate=te,B.pointLights.needsUpdate=te,B.pointLightShadows.needsUpdate=te,B.spotLights.needsUpdate=te,B.spotLightShadows.needsUpdate=te,B.rectAreaLights.needsUpdate=te,B.hemisphereLights.needsUpdate=te}d(Ob,"markUniformsLightsNeedsUpdate");function Ub(B){return B.isMeshLambertMaterial||B.isMeshToonMaterial||B.isMeshPhongMaterial||B.isMeshStandardMaterial||B.isShadowMaterial||B.isShaderMaterial&&B.lights===!0}d(Ub,"materialNeedsLights"),this.getActiveCubeFace=function(){return A},this.getActiveMipmapLevel=function(){return R},this.getRenderTarget=function(){return P},this.setRenderTargetTextures=function(B,te,fe){const ce=F.get(B);ce.__autoAllocateDepthBuffer=B.resolveDepthBuffer===!1,ce.__autoAllocateDepthBuffer===!1&&(ce.__useRenderToTexture=!1),F.get(B.texture).__webglTexture=te,F.get(B.depthTexture).__webglTexture=ce.__autoAllocateDepthBuffer?void 0:fe,ce.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(B,te){const fe=F.get(B);fe.__webglFramebuffer=te,fe.__useDefaultFramebuffer=te===void 0};const Bb=$.createFramebuffer();this.setRenderTarget=function(B,te=0,fe=0){P=B,A=te,R=fe;let ce=null,oe=!1,Be=!1;if(B){const ze=F.get(B);if(ze.__useDefaultFramebuffer!==void 0){Ae.bindFramebuffer($.FRAMEBUFFER,ze.__webglFramebuffer),D.copy(B.viewport),L.copy(B.scissor),H=B.scissorTest,Ae.viewport(D),Ae.scissor(L),Ae.setScissorTest(H),I=-1;return}else if(ze.__webglFramebuffer===void 0)j.setupRenderTarget(B);else if(ze.__hasExternalTextures)j.rebindTextures(B,F.get(B.texture).__webglTexture,F.get(B.depthTexture).__webglTexture);else if(B.depthBuffer){const it=B.depthTexture;if(ze.__boundDepthTexture!==it){if(it!==null&&F.has(it)&&(B.width!==it.image.width||B.height!==it.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");j.setupDepthRenderbuffer(B)}}const Xe=B.texture;(Xe.isData3DTexture||Xe.isDataArrayTexture||Xe.isCompressedArrayTexture)&&(Be=!0);const Ze=F.get(B).__webglFramebuffer;B.isWebGLCubeRenderTarget?(Array.isArray(Ze[te])?ce=Ze[te][fe]:ce=Ze[te],oe=!0):B.samples>0&&j.useMultisampledRTT(B)===!1?ce=F.get(B).__webglMultisampledFramebuffer:Array.isArray(Ze)?ce=Ze[fe]:ce=Ze,D.copy(B.viewport),L.copy(B.scissor),H=B.scissorTest}else D.copy(q).multiplyScalar(Q).floor(),L.copy(Y).multiplyScalar(Q).floor(),H=K;if(fe!==0&&(ce=Bb),Ae.bindFramebuffer($.FRAMEBUFFER,ce)&&Ae.drawBuffers(B,ce),Ae.viewport(D),Ae.scissor(L),Ae.setScissorTest(H),oe){const ze=F.get(B.texture);$.framebufferTexture2D($.FRAMEBUFFER,$.COLOR_ATTACHMENT0,$.TEXTURE_CUBE_MAP_POSITIVE_X+te,ze.__webglTexture,fe)}else if(Be){const ze=te;for(let Xe=0;Xe<B.textures.length;Xe++){const Ze=F.get(B.textures[Xe]);$.framebufferTextureLayer($.FRAMEBUFFER,$.COLOR_ATTACHMENT0+Xe,Ze.__webglTexture,fe,ze)}}else if(B!==null&&fe!==0){const ze=F.get(B.texture);$.framebufferTexture2D($.FRAMEBUFFER,$.COLOR_ATTACHMENT0,$.TEXTURE_2D,ze.__webglTexture,fe)}I=-1},this.readRenderTargetPixels=function(B,te,fe,ce,oe,Be,Ge,ze=0){if(!(B&&B.isWebGLRenderTarget)){Ye("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Xe=F.get(B).__webglFramebuffer;if(B.isWebGLCubeRenderTarget&&Ge!==void 0&&(Xe=Xe[Ge]),Xe){Ae.bindFramebuffer($.FRAMEBUFFER,Xe);try{const Ze=B.textures[ze],it=Ze.format,ot=Ze.type;if(B.textures.length>1&&$.readBuffer($.COLOR_ATTACHMENT0+ze),!Ne.textureFormatReadable(it)){Ye("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Ne.textureTypeReadable(ot)){Ye("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}te>=0&&te<=B.width-ce&&fe>=0&&fe<=B.height-oe&&$.readPixels(te,fe,ce,oe,_e.convert(it),_e.convert(ot),Be)}finally{const Ze=P!==null?F.get(P).__webglFramebuffer:null;Ae.bindFramebuffer($.FRAMEBUFFER,Ze)}}},this.readRenderTargetPixelsAsync=async function(B,te,fe,ce,oe,Be,Ge,ze=0){if(!(B&&B.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Xe=F.get(B).__webglFramebuffer;if(B.isWebGLCubeRenderTarget&&Ge!==void 0&&(Xe=Xe[Ge]),Xe)if(te>=0&&te<=B.width-ce&&fe>=0&&fe<=B.height-oe){Ae.bindFramebuffer($.FRAMEBUFFER,Xe);const Ze=B.textures[ze],it=Ze.format,ot=Ze.type;if(B.textures.length>1&&$.readBuffer($.COLOR_ATTACHMENT0+ze),!Ne.textureFormatReadable(it))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Ne.textureTypeReadable(ot))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ke=$.createBuffer();$.bindBuffer($.PIXEL_PACK_BUFFER,Ke),$.bufferData($.PIXEL_PACK_BUFFER,Be.byteLength,$.STREAM_READ),$.readPixels(te,fe,ce,oe,_e.convert(it),_e.convert(ot),0);const xt=P!==null?F.get(P).__webglFramebuffer:null;Ae.bindFramebuffer($.FRAMEBUFFER,xt);const Rt=$.fenceSync($.SYNC_GPU_COMMANDS_COMPLETE,0);return $.flush(),await WS($,Rt,4),$.bindBuffer($.PIXEL_PACK_BUFFER,Ke),$.getBufferSubData($.PIXEL_PACK_BUFFER,0,Be),$.deleteBuffer(Ke),$.deleteSync(Rt),Be}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(B,te=null,fe=0){const ce=Math.pow(2,-fe),oe=Math.floor(B.image.width*ce),Be=Math.floor(B.image.height*ce),Ge=te!==null?te.x:0,ze=te!==null?te.y:0;j.setTexture2D(B,0),$.copyTexSubImage2D($.TEXTURE_2D,fe,0,0,Ge,ze,oe,Be),Ae.unbindTexture()};const zb=$.createFramebuffer(),kb=$.createFramebuffer();this.copyTextureToTexture=function(B,te,fe=null,ce=null,oe=0,Be=0){let Ge,ze,Xe,Ze,it,ot,Ke,xt,Rt;const Tt=B.isCompressedTexture?B.mipmaps[Be]:B.image;if(fe!==null)Ge=fe.max.x-fe.min.x,ze=fe.max.y-fe.min.y,Xe=fe.isBox3?fe.max.z-fe.min.z:1,Ze=fe.min.x,it=fe.min.y,ot=fe.isBox3?fe.min.z:0;else{const $t=Math.pow(2,-oe);Ge=Math.floor(Tt.width*$t),ze=Math.floor(Tt.height*$t),B.isDataArrayTexture?Xe=Tt.depth:B.isData3DTexture?Xe=Math.floor(Tt.depth*$t):Xe=1,Ze=0,it=0,ot=0}ce!==null?(Ke=ce.x,xt=ce.y,Rt=ce.z):(Ke=0,xt=0,Rt=0);const vt=_e.convert(te.format),jt=_e.convert(te.type);let qe;te.isData3DTexture?(j.setTexture3D(te,0),qe=$.TEXTURE_3D):te.isDataArrayTexture||te.isCompressedArrayTexture?(j.setTexture2DArray(te,0),qe=$.TEXTURE_2D_ARRAY):(j.setTexture2D(te,0),qe=$.TEXTURE_2D),$.pixelStorei($.UNPACK_FLIP_Y_WEBGL,te.flipY),$.pixelStorei($.UNPACK_PREMULTIPLY_ALPHA_WEBGL,te.premultiplyAlpha),$.pixelStorei($.UNPACK_ALIGNMENT,te.unpackAlignment);const Tn=$.getParameter($.UNPACK_ROW_LENGTH),dt=$.getParameter($.UNPACK_IMAGE_HEIGHT),Wn=$.getParameter($.UNPACK_SKIP_PIXELS),ti=$.getParameter($.UNPACK_SKIP_ROWS),ms=$.getParameter($.UNPACK_SKIP_IMAGES);$.pixelStorei($.UNPACK_ROW_LENGTH,Tt.width),$.pixelStorei($.UNPACK_IMAGE_HEIGHT,Tt.height),$.pixelStorei($.UNPACK_SKIP_PIXELS,Ze),$.pixelStorei($.UNPACK_SKIP_ROWS,it),$.pixelStorei($.UNPACK_SKIP_IMAGES,ot);const ar=B.isDataArrayTexture||B.isData3DTexture,St=te.isDataArrayTexture||te.isData3DTexture;if(B.isDepthTexture){const $t=F.get(B),Ui=F.get(te),Ht=F.get($t.__renderTarget),Bi=F.get(Ui.__renderTarget);Ae.bindFramebuffer($.READ_FRAMEBUFFER,Ht.__webglFramebuffer),Ae.bindFramebuffer($.DRAW_FRAMEBUFFER,Bi.__webglFramebuffer);for(let cr=0;cr<Xe;cr++)ar&&($.framebufferTextureLayer($.READ_FRAMEBUFFER,$.COLOR_ATTACHMENT0,F.get(B).__webglTexture,oe,ot+cr),$.framebufferTextureLayer($.DRAW_FRAMEBUFFER,$.COLOR_ATTACHMENT0,F.get(te).__webglTexture,Be,Rt+cr)),$.blitFramebuffer(Ze,it,Ge,ze,Ke,xt,Ge,ze,$.DEPTH_BUFFER_BIT,$.NEAREST);Ae.bindFramebuffer($.READ_FRAMEBUFFER,null),Ae.bindFramebuffer($.DRAW_FRAMEBUFFER,null)}else if(oe!==0||B.isRenderTargetTexture||F.has(B)){const $t=F.get(B),Ui=F.get(te);Ae.bindFramebuffer($.READ_FRAMEBUFFER,zb),Ae.bindFramebuffer($.DRAW_FRAMEBUFFER,kb);for(let Ht=0;Ht<Xe;Ht++)ar?$.framebufferTextureLayer($.READ_FRAMEBUFFER,$.COLOR_ATTACHMENT0,$t.__webglTexture,oe,ot+Ht):$.framebufferTexture2D($.READ_FRAMEBUFFER,$.COLOR_ATTACHMENT0,$.TEXTURE_2D,$t.__webglTexture,oe),St?$.framebufferTextureLayer($.DRAW_FRAMEBUFFER,$.COLOR_ATTACHMENT0,Ui.__webglTexture,Be,Rt+Ht):$.framebufferTexture2D($.DRAW_FRAMEBUFFER,$.COLOR_ATTACHMENT0,$.TEXTURE_2D,Ui.__webglTexture,Be),oe!==0?$.blitFramebuffer(Ze,it,Ge,ze,Ke,xt,Ge,ze,$.COLOR_BUFFER_BIT,$.NEAREST):St?$.copyTexSubImage3D(qe,Be,Ke,xt,Rt+Ht,Ze,it,Ge,ze):$.copyTexSubImage2D(qe,Be,Ke,xt,Ze,it,Ge,ze);Ae.bindFramebuffer($.READ_FRAMEBUFFER,null),Ae.bindFramebuffer($.DRAW_FRAMEBUFFER,null)}else St?B.isDataTexture||B.isData3DTexture?$.texSubImage3D(qe,Be,Ke,xt,Rt,Ge,ze,Xe,vt,jt,Tt.data):te.isCompressedArrayTexture?$.compressedTexSubImage3D(qe,Be,Ke,xt,Rt,Ge,ze,Xe,vt,Tt.data):$.texSubImage3D(qe,Be,Ke,xt,Rt,Ge,ze,Xe,vt,jt,Tt):B.isDataTexture?$.texSubImage2D($.TEXTURE_2D,Be,Ke,xt,Ge,ze,vt,jt,Tt.data):B.isCompressedTexture?$.compressedTexSubImage2D($.TEXTURE_2D,Be,Ke,xt,Tt.width,Tt.height,vt,Tt.data):$.texSubImage2D($.TEXTURE_2D,Be,Ke,xt,Ge,ze,vt,jt,Tt);$.pixelStorei($.UNPACK_ROW_LENGTH,Tn),$.pixelStorei($.UNPACK_IMAGE_HEIGHT,dt),$.pixelStorei($.UNPACK_SKIP_PIXELS,Wn),$.pixelStorei($.UNPACK_SKIP_ROWS,ti),$.pixelStorei($.UNPACK_SKIP_IMAGES,ms),Be===0&&te.generateMipmaps&&$.generateMipmap(qe),Ae.unbindTexture()},this.initRenderTarget=function(B){F.get(B).__webglFramebuffer===void 0&&j.setupRenderTarget(B)},this.initTexture=function(B){B.isCubeTexture?j.setTextureCube(B,0):B.isData3DTexture?j.setTexture3D(B,0):B.isDataArrayTexture||B.isCompressedArrayTexture?j.setTexture2DArray(B,0):j.setTexture2D(B,0),Ae.unbindTexture()},this.resetState=function(){A=0,R=0,P=null,Ae.reset(),ye.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Rn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=lt._getDrawingBufferColorSpace(e),t.unpackColorSpace=lt._getUnpackColorSpace()}};d(N_,"WebGLRenderer");let _p=N_;const An=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:Dp,AddEquation:Ji,AddOperation:Nv,AdditiveAnimationBlendMode:Wp,AdditiveBlending:Gf,AgXToneMapping:Lp,AlphaFormat:Hp,AlwaysCompare:Wv,AlwaysDepth:Hc,AlwaysStencilFunc:Yf,AmbientLight:Su,AnimationAction:Nu,AnimationClip:nr,AnimationLoader:_d,AnimationMixer:Fd,AnimationObjectGroup:Dd,AnimationUtils:md,ArcCurve:ql,ArrayCamera:Cu,ArrowHelper:np,AttachedBindMode:Xf,Audio:Ru,AudioAnalyser:Pd,AudioContext:Ia,AudioListener:Id,AudioLoader:Td,AxesHelper:ip,BackSide:gn,BasicDepthPacking:Uv,BasicShadowMap:Jb,BatchedMesh:Ol,BezierInterpolant:gu,Bone:aa,BooleanKeyframeTrack:Ni,Box2:Wd,Box3:Dt,Box3Helper:ep,BoxGeometry:Ks,BoxHelper:Qd,BufferAttribute:mt,BufferGeometry:Qe,BufferGeometryLoader:Au,ByteType:Bp,Cache:pi,Camera:ao,CameraHelper:jd,CanvasTexture:Vl,CapsuleGeometry:Gl,CatmullRomCurve3:Yl,CineonToneMapping:Np,CircleGeometry:Wl,ClampToEdgeWrapping:Mn,Clock:kd,Color:ke,ColorKeyframeTrack:Ma,ColorManagement:lt,Compatibility:zS,CompressedArrayTexture:ld,CompressedCubeTexture:ud,CompressedTexture:Qr,CompressedTextureLoader:yd,ConeGeometry:to,ConstantAlphaFactor:Iv,ConstantColorFactor:Tv,Controls:rp,CubeCamera:Tu,CubeDepthTexture:Hl,CubeReflectionMapping:gi,CubeRefractionMapping:ss,CubeTexture:Zs,CubeTextureLoader:xd,CubeUVReflectionMapping:uo,CubicBezierCurve:la,CubicBezierCurve3:Zl,CubicInterpolant:pu,CullFaceBack:Hf,CullFaceFront:hv,CullFaceFrontBack:Kb,CullFaceNone:uv,Curve:Ln,CurvePath:jl,CustomBlending:dv,CustomToneMapping:Fp,CylinderGeometry:eo,Cylindrical:Hd,Data3DTexture:Zr,DataArrayTexture:Yr,DataTexture:Fn,DataTextureLoader:vd,DataUtils:jf,DecrementStencilOp:gS,DecrementWrapStencilOp:yS,DefaultLoadingManager:nb,DepthFormat:yi,DepthStencilFormat:ji,DepthTexture:ls,DetachedBindMode:Dv,DirectionalLight:bu,DirectionalLightHelper:Jd,DiscreteInterpolant:mu,DodecahedronGeometry:$l,DoubleSide:Bt,DstAlphaFactor:Sv,DstColorFactor:wv,DynamicCopyUsage:DS,DynamicDrawUsage:TS,DynamicReadUsage:RS,EdgesGeometry:Xl,EllipseCurve:no,EqualCompare:Vv,EqualDepth:Wc,EqualStencilFunc:SS,EquirectangularReflectionMapping:Fo,EquirectangularRefractionMapping:Lo,Euler:rn,EventDispatcher:Vn,ExternalTexture:ca,ExtrudeGeometry:Ql,FileLoader:ei,Float16BufferAttribute:sd,Float32BufferAttribute:Ve,FloatType:pn,Fog:Il,FogExp2:Cl,FramebufferTexture:cd,FrontSide:zn,Frustum:cs,FrustumArray:Ll,GLBufferAttribute:Bd,GLSL1:LS,GLSL3:Zf,GreaterCompare:Hv,GreaterDepth:Xc,GreaterEqualCompare:Dh,GreaterEqualDepth:$c,GreaterEqualStencilFunc:AS,GreaterStencilFunc:wS,GridHelper:Zd,Group:sn,HalfFloatType:_i,HemisphereLight:yu,HemisphereLightHelper:Yd,IcosahedronGeometry:eu,ImageBitmapLoader:Ad,ImageLoader:ir,ImageUtils:Tl,IncrementStencilOp:mS,IncrementWrapStencilOp:_S,InstancedBufferAttribute:as,InstancedBufferGeometry:Ca,InstancedInterleavedBuffer:co,InstancedMesh:Fl,Int16BufferAttribute:nd,Int32BufferAttribute:id,Int8BufferAttribute:Qf,IntType:Eh,InterleavedBuffer:Jr,InterleavedBufferAttribute:Pn,Interpolant:hs,InterpolateBezier:qf,InterpolateDiscrete:Ko,InterpolateLinear:Al,InterpolateSmooth:Bc,InterpolationSamplingMode:BS,InterpolationSamplingType:US,InvertStencilOp:xS,KeepStencilOp:Rs,KeyframeTrack:En,LOD:Pl,LatheGeometry:tu,Layers:Kr,LessCompare:kv,LessDepth:Gc,LessEqualCompare:Nh,LessEqualDepth:Ws,LessEqualStencilFunc:MS,LessStencilFunc:bS,Light:xi,LightProbe:wu,Line:Qn,Line3:Fu,LineBasicMaterial:It,LineCurve:ua,LineCurve3:Kl,LineDashedMaterial:du,LineLoop:zl,LineSegments:Hn,LinearFilter:wt,LinearInterpolant:Sa,LinearMipMapLinearFilter:nS,LinearMipMapNearestFilter:tS,LinearMipmapLinearFilter:fi,LinearMipmapNearestFilter:Oo,LinearSRGBColorSpace:Xs,LinearToneMapping:Rp,LinearTransfer:jo,Loader:on,LoaderUtils:Ta,LoadingManager:wa,LoopOnce:Fv,LoopPingPong:Ov,LoopRepeat:Lv,MOUSE:Yb,Material:zt,MaterialBlending:jb,MaterialLoader:Eu,MathUtils:Bn,Matrix2:Gd,Matrix3:nt,Matrix4:Je,MaxEquation:_v,Mesh:yt,MeshBasicMaterial:Wt,MeshDepthMaterial:va,MeshDistanceMaterial:ba,MeshLambertMaterial:fu,MeshMatcapMaterial:es,MeshNormalMaterial:hu,MeshPhongMaterial:uu,MeshPhysicalMaterial:lu,MeshStandardMaterial:wn,MeshToonMaterial:Qi,MinEquation:gv,MirroredRepeatWrapping:Zo,MixOperation:Pv,MultiplyBlending:$f,MultiplyOperation:La,NearestFilter:Nt,NearestMipMapLinearFilter:eS,NearestMipMapNearestFilter:Qb,NearestMipmapLinearFilter:Fr,NearestMipmapNearestFilter:Up,NeutralToneMapping:Op,NeverCompare:zv,NeverDepth:Vc,NeverStencilFunc:vS,NoBlending:mi,NoColorSpace:Ai,NoNormalPacking:uS,NoToneMapping:jn,NormalAnimationBlendMode:Ph,NormalBlending:Bs,NormalGAPacking:fS,NormalRGPacking:hS,NotEqualCompare:Gv,NotEqualDepth:qc,NotEqualStencilFunc:ES,NumberKeyframeTrack:Qs,Object3D:ft,ObjectLoader:Ed,ObjectSpaceNormalMap:Bv,OctahedronGeometry:_a,OneFactor:xv,OneMinusConstantAlphaFactor:Rv,OneMinusConstantColorFactor:Cv,OneMinusDstAlphaFactor:Mv,OneMinusDstColorFactor:Ev,OneMinusSrcAlphaFactor:kc,OneMinusSrcColorFactor:bv,OrthographicCamera:sr,PCFShadowMap:Do,PCFSoftShadowMap:fv,PMREMGenerator:Ra,Path:io,PerspectiveCamera:Ut,Plane:Zn,PlaneGeometry:ro,PlaneHelper:tp,PointLight:vu,PointLightHelper:qd,Points:Ys,PointsMaterial:Nn,PolarGridHelper:Kd,PolyhedronGeometry:us,PositionalAudio:Rd,PropertyBinding:_t,PropertyMixer:Pu,QuadraticBezierCurve:ha,QuadraticBezierCurve3:fa,Quaternion:Mt,QuaternionKeyframeTrack:er,QuaternionLinearInterpolant:_u,R11_EAC_Format:tl,RED_GREEN_RGTC2_Format:wl,RED_RGTC1_Format:Sl,REVISION:Mh,RG11_EAC_Format:il,RGBADepthPacking:aS,RGBAFormat:mn,RGBAIntegerFormat:Rh,RGBA_ASTC_10x10_Format:gl,RGBA_ASTC_10x5_Format:dl,RGBA_ASTC_10x6_Format:pl,RGBA_ASTC_10x8_Format:ml,RGBA_ASTC_12x10_Format:_l,RGBA_ASTC_12x12_Format:yl,RGBA_ASTC_4x4_Format:rl,RGBA_ASTC_5x4_Format:ol,RGBA_ASTC_5x5_Format:al,RGBA_ASTC_6x5_Format:cl,RGBA_ASTC_6x6_Format:ll,RGBA_ASTC_8x5_Format:ul,RGBA_ASTC_8x6_Format:hl,RGBA_ASTC_8x8_Format:fl,RGBA_BPTC_Format:xl,RGBA_ETC2_EAC_Format:el,RGBA_PVRTC_2BPPV1_Format:Jc,RGBA_PVRTC_4BPPV1_Format:Kc,RGBA_S3TC_DXT1_Format:Bo,RGBA_S3TC_DXT3_Format:zo,RGBA_S3TC_DXT5_Format:ko,RGBDepthPacking:cS,RGBFormat:Gp,RGBIntegerFormat:iS,RGB_BPTC_SIGNED_Format:vl,RGB_BPTC_UNSIGNED_Format:bl,RGB_ETC1_Format:jc,RGB_ETC2_Format:Qc,RGB_PVRTC_2BPPV1_Format:Zc,RGB_PVRTC_4BPPV1_Format:Yc,RGB_S3TC_DXT1_Format:Uo,RGDepthPacking:lS,RGFormat:$s,RGIntegerFormat:Ih,RawShaderMaterial:xa,Ray:os,Raycaster:Du,RectAreaLight:Mu,RedFormat:Ch,RedIntegerFormat:Oa,ReinhardToneMapping:Pp,RenderTarget:ia,RenderTarget3D:Ld,RepeatWrapping:Yo,ReplaceStencilOp:pS,ReverseSubtractEquation:mv,RingGeometry:nu,SIGNED_R11_EAC_Format:nl,SIGNED_RED_GREEN_RGTC2_Format:El,SIGNED_RED_RGTC1_Format:Ml,SIGNED_RG11_EAC_Format:sl,SRGBColorSpace:un,SRGBTransfer:gt,Scene:Rl,ShaderChunk:rt,ShaderLib:hn,ShaderMaterial:yn,ShadowMaterial:cu,Shape:Ii,ShapeGeometry:iu,ShapePath:sp,ShapeUtils:Kn,ShortType:zp,Skeleton:Dl,SkeletonHelper:Xd,SkinnedMesh:Nl,Source:di,Sphere:Ft,SphereGeometry:js,Spherical:Vd,SphericalHarmonics3:Aa,SplineCurve:da,SpotLight:xu,SpotLightHelper:$d,Sprite:oa,SpriteMaterial:jr,SrcAlphaFactor:zc,SrcAlphaSaturateFactor:Av,SrcColorFactor:vv,StaticCopyUsage:NS,StaticDrawUsage:Qo,StaticReadUsage:IS,StereoCamera:Cd,StreamCopyUsage:FS,StreamDrawUsage:CS,StreamReadUsage:PS,StringKeyframeTrack:Di,SubtractEquation:pv,SubtractiveBlending:Wf,TOUCH:Zb,TangentSpaceNormalMap:fs,TetrahedronGeometry:su,Texture:Ot,TextureLoader:bd,TextureUtils:ap,Timer:Iu,TimestampQuery:OS,TorusGeometry:ru,TorusKnotGeometry:ou,Triangle:ui,TriangleFanDrawMode:oS,TriangleStripDrawMode:rS,TrianglesDrawMode:sS,TubeGeometry:au,UVMapping:wh,Uint16BufferAttribute:sa,Uint32BufferAttribute:ra,Uint8BufferAttribute:ed,Uint8ClampedBufferAttribute:td,Uniform:Od,UniformsGroup:Ud,UniformsLib:Fe,UniformsUtils:Fh,UnsignedByteType:Sn,UnsignedInt101111Type:Vp,UnsignedInt248Type:Xr,UnsignedInt5999Type:kp,UnsignedIntType:kn,UnsignedShort4444Type:Ah,UnsignedShort5551Type:Th,UnsignedShortType:$r,VSMShadowMap:Dr,Vector2:Ee,Vector3:U,Vector4:pt,VectorKeyframeTrack:tr,VideoFrameTexture:ad,VideoTexture:kl,WebGL3DRenderTarget:Jf,WebGLArrayRenderTarget:Kf,WebGLCoordinateSystem:Rn,WebGLCubeRenderTarget:Pa,WebGLRenderTarget:_n,WebGLRenderer:_p,WebGLUtils:lb,WebGPUCoordinateSystem:qs,WebXRController:kr,WireframeGeometry:ya,WrapAroundEnding:Jo,ZeroCurvatureEnding:Ds,ZeroFactor:yv,ZeroSlopeEnding:Fs,ZeroStencilOp:dS,createCanvasElement:Xv,error:Ye,getConsoleFunction:GS,log:ta,setConsoleFunction:HS,warn:Ue,warnOnce:na},Symbol.toStringTag,{value:"Module"}));function bC(){this._numProp=3,this._vertProperties=[],this._triVerts=[],this._triIDs=[],this._vertKeyToIndex=new Map,this._faceNameToID=new Map,this._idToFaceName=new Map,this._faceMetadata=new Map,this._edgeMetadata=new Map,this._dirty=!0,this._manifold=null,this._faceIndex=null,this._epsilon=0,this._freeTimer=null,this.type="SOLID",this.renderOrder=1,this._auxEdges=[]}d(bC,"constructorImpl");function SC(){const r=this.constructor,e=new r;e._numProp=this._numProp,e._vertProperties=this._vertProperties.slice(),e._triVerts=this._triVerts.slice(),e._triIDs=this._triIDs.slice(),e._vertKeyToIndex=new Map;for(let t=0;t<e._vertProperties.length;t+=3){const n=e._vertProperties[t],i=e._vertProperties[t+1],s=e._vertProperties[t+2];e._vertKeyToIndex.set(`${n},${i},${s}`,t/3|0)}try{e._idToFaceName=new Map(this._idToFaceName),e._faceNameToID=new Map(this._faceNameToID)}catch{}try{e._faceMetadata=new Map(this._faceMetadata)}catch{e._faceMetadata=new Map}try{e._edgeMetadata=new Map(this._edgeMetadata)}catch{e._edgeMetadata=new Map}try{e._auxEdges=Array.isArray(this._auxEdges)?this._auxEdges.map(t=>({name:t?.name,closedLoop:!!t?.closedLoop,polylineWorld:!!t?.polylineWorld,materialKey:t?.materialKey,centerline:!!t?.centerline,points:Array.isArray(t?.points)?t.points.map(n=>Array.isArray(n)?[n[0],n[1],n[2]]:n):[]})):[]}catch{e._auxEdges=[]}return e._dirty=!0,e._manifold=null,e._faceIndex=null,e.type="SOLID",e.renderOrder=this.renderOrder,e}d(SC,"clone");function MC(){try{try{this._freeTimer&&clearTimeout(this._freeTimer)}catch{}if(this._freeTimer=null,this._manifold){try{typeof this._manifold.delete=="function"&&this._manifold.delete()}catch{}this._manifold=null}this._dirty=!0,this._faceIndex=null}catch{}return this}d(MC,"free");const Nx=typeof globalThis.__MANIFOLD_WASM_BASE64__<"u"&&globalThis.__MANIFOLD_WASM_BASE64__,Lu=typeof window>"u"||!!globalThis?.process?.versions?.node,wC=d(async()=>{if(Lu)try{const{createRequire:r}=await is(async()=>{const{createRequire:i}=await import("./__vite-browser-external-BIHI7g3E.js");return{createRequire:i}},[]),t=r(import.meta.url)("node:url");if(t.__brepFileUrlPatched)return;const n=t.fileURLToPath;t.fileURLToPath=i=>{try{return n(i)}catch(s){const o=typeof i=="string"?i:i?.href;if(o&&(o.startsWith("data:")||o.startsWith("blob:")))return globalThis.process.cwd();throw s}},t.__brepFileUrlPatched=!0}catch{}},"patchFileURLToPathForDataUrl"),EC=d(async()=>{Lu&&await wC();const r=await is(()=>import("./manifold-Dgmk3x29.js"),__vite__mapDeps([0,1]));return r?.default??r},"loadModule"),AC=d(r=>{if(!r)return null;const e=r.includes("base64,")?r.slice(r.indexOf("base64,")+7):r;if(typeof globalThis.Buffer<"u")return new Uint8Array(globalThis.Buffer.from(e,"base64"));if(typeof atob=="function"){const t=atob(e),n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return n}throw new Error("No base64 decoder available for manifold wasm")},"decodeBase64ToUint8Array"),Rf=d(async r=>{const t=await(await EC())(r);return typeof t.setup=="function"&&await t.setup(),t},"initWasm"),lo=await(async()=>{if(Nx){const t=AC(Nx),n=await Rf({wasmBinary:t});return!Lu&&typeof window<"u"&&(window.manifold=n),n}if(Lu)return Rf();const{default:r}=await is(async()=>{const{default:t}=await import("./manifold-Demb-vkL.js");return{default:t}},[]),e=await Rf({locateFile:d(()=>r,"locateFile")});return typeof window<"u"&&(window.manifold=e),e})(),Fi=lo.Manifold,UR=lo.CrossSection,TC=lo.Mesh,BR=typeof lo.sum=="function",zR=d((r,e)=>{if(typeof lo.sum!="function")throw new Error("Custom manifold extensions are only available when using the local manifold build.");return lo.sum(r,e)},"manifoldPlusSum"),Dx=new Dt,Dc=new U,D_=class D_ extends Ca{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";const e=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],t=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],n=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];this.setIndex(n),this.setAttribute("position",new Ve(e,3)),this.setAttribute("uv",new Ve(t,2))}applyMatrix4(e){const t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new co(t,6,1);return this.setAttribute("instanceStart",new Pn(n,3,0)),this.setAttribute("instanceEnd",new Pn(n,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new co(t,6,1);return this.setAttribute("instanceColorStart",new Pn(n,3,0)),this.setAttribute("instanceColorEnd",new Pn(n,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new ya(e.geometry)),this}fromLineSegments(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Dt);const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),Dx.setFromBufferAttribute(t),this.boundingBox.union(Dx))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ft),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){const n=this.boundingSphere.center;this.boundingBox.getCenter(n);let i=0;for(let s=0,o=e.count;s<o;s++)Dc.fromBufferAttribute(e,s),i=Math.max(i,n.distanceToSquared(Dc)),Dc.fromBufferAttribute(t,s),i=Math.max(i,n.distanceToSquared(Dc));this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}};d(D_,"LineSegmentsGeometry");let Ou=D_;Fe.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new Ee(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}};hn.line={uniforms:Fh.merge([Fe.common,Fe.fog,Fe.line]),vertexShader:`
|
|
4051
4051
|
#include <common>
|
|
4052
4052
|
#include <color_pars_vertex>
|
|
4053
4053
|
#include <fog_pars_vertex>
|
|
@@ -4633,7 +4633,7 @@ ${h.lines.join(`
|
|
|
4633
4633
|
${G.join(`
|
|
4634
4634
|
`)}
|
|
4635
4635
|
`,exported:N.length,skipped:R}}d(e2,"generateSTEP");function t2(r="solid",e=6){const t=this.getMesh(),{vertProperties:n,triVerts:i}=t,s=d(c=>Number.isFinite(c)?c.toFixed(e):"0","fmt"),o=[];o.push(`solid ${r}`);const a=i.length/3|0;for(let c=0;c<a;c++){const l=i[c*3+0],u=i[c*3+1],h=i[c*3+2],f=[n[l*3+0],n[l*3+1],n[l*3+2]],p=[n[u*3+0],n[u*3+1],n[u*3+2]],m=[n[h*3+0],n[h*3+1],n[h*3+2]],y=p[0]-f[0],_=p[1]-f[1],g=p[2]-f[2],v=m[0]-f[0],M=m[1]-f[1],b=m[2]-f[2];let C=_*b-g*M,S=g*v-y*b,T=y*M-_*v;const x=Math.hypot(C,S,T)||1;C/=x,S/=x,T/=x,o.push(` facet normal ${s(C)} ${s(S)} ${s(T)}`),o.push(" outer loop"),o.push(` vertex ${s(f[0])} ${s(f[1])} ${s(f[2])}`),o.push(` vertex ${s(p[0])} ${s(p[1])} ${s(p[2])}`),o.push(` vertex ${s(m[0])} ${s(m[1])} ${s(m[2])}`),o.push(" endloop"),o.push(" endfacet")}o.push(`endsolid ${r}`);try{return o.join(`
|
|
4636
|
-
`)}finally{try{t&&typeof t.delete=="function"&&t.delete()}catch{}}}d(t2,"toSTL");async function n2(r,e="solid",t=6){if(typeof window<"u")throw new Error("writeSTL is only available in Node.js environments");const{writeFile:n}=await is(async()=>{const{writeFile:s}=await import("./__vite-browser-external-BIHI7g3E.js");return{writeFile:s}},[]),i=this.toSTL(e,t);return await n(r,i,"utf8"),r}d(n2,"writeSTL");function i2(r=void 0,e={}){const t=e&&typeof e=="object"?e:{},n=t.unit||"millimeter",i=Number.isFinite(t.precision)?t.precision:6,s=Number.isFinite(t.scale)?t.scale:1,o=t.applyWorldTransform!==!1,a=r||this?.name||"part",c={...t,name:a,unit:n,precision:i,scale:s,applyWorldTransform:o},{data:l}=e2([this],c);return l}d(i2,"toSTEP");async function s2(r,e=void 0,t={}){if(typeof window<"u")throw new Error("writeSTEP is only available in Node.js environments");const{writeFile:n}=await is(async()=>{const{writeFile:s}=await import("./__vite-browser-external-BIHI7g3E.js");return{writeFile:s}},[]),i=this.toSTEP(e,t);return await n(r,i,"utf8"),r}d(s2,"writeSTEP");function r2(){const r=this.getMesh();try{const e=r.vertProperties,t=r.triVerts;let n=0;for(let i=0;i<t.length;i+=3){const s=t[i]*3,o=t[i+1]*3,a=t[i+2]*3,c=e[s],l=e[s+1],u=e[s+2],h=e[o],f=e[o+1],p=e[o+2],m=e[a],y=e[a+1],_=e[a+2];n+=c*(f*_-p*y)-l*(h*_-p*m)+u*(h*y-f*m)}return Math.abs(n)/6}finally{try{r&&typeof r.delete=="function"&&r.delete()}catch{}}}d(r2,"volume");function o2(){const r=this.getMesh();try{const e=r.vertProperties,t=r.triVerts;let n=0;for(let i=0;i<t.length;i+=3){const s=t[i]*3,o=t[i+1]*3,a=t[i+2]*3,c=e[s],l=e[s+1],u=e[s+2],h=e[o],f=e[o+1],p=e[o+2],m=e[a],y=e[a+1],_=e[a+2];n+=bp(c,l,u,h,f,p,m,y,_)}return n}finally{try{r&&typeof r.delete=="function"&&r.delete()}catch{}}}d(o2,"surfaceArea");function a2(){const r=this.getMesh();try{return r.triVerts.length/3|0}finally{try{r&&typeof r.delete=="function"&&r.delete()}catch{}}}d(a2,"getTriangleCount");function c2(r={}){const e=[];for(let l=this.children.length-1;l>=0;l--){const u=this.children[l];if(this.remove(u),u?.userData?.filletDebug===!0){e.push(u);continue}u.geometry&&typeof u.geometry.dispose=="function"&&u.geometry.dispose();const h=u.material;h&&(Array.isArray(h)?h.forEach(f=>f&&f.dispose&&f.dispose()):typeof h.dispose=="function"&&h.dispose())}const{showEdges:t=!0,forceAuthoring:n=!1,authoringOnly:i=!1}=r;let s,o=!1;if(!n&&!i)try{s=this.getFaces(!1)}catch(l){console.warn("[Solid.visualize] getFaces failed, falling back to raw arrays:",l?.message||l),o=!0}else o=!0;if(o||!s){const l=this._vertProperties||[],u=this._triVerts||[],h=this._triIDs||[],f=d(y=>this._idToFaceName&&this._idToFaceName.get?this._idToFaceName.get(y):String(y),"nameOf"),p=new Map,m=u.length/3|0;for(let y=0;y<m;y++){const _=h[y],g=f(_);if(!g)continue;let v=p.get(g);v||(v=[],p.set(g,v));const M=u[y*3+0],b=u[y*3+1],C=u[y*3+2],S=[l[M*3+0],l[M*3+1],l[M*3+2]],T=[l[b*3+0],l[b*3+1],l[b*3+2]],x=[l[C*3+0],l[C*3+1],l[C*3+2]];v.push({faceName:g,indices:[M,b,C],p1:S,p2:T,p3:x})}s=[];for(const[y,_]of p.entries())s.push({faceName:y,triangles:_})}const a=new Map;for(const{faceName:l,triangles:u}of s){if(!u.length)continue;const h=new Float32Array(u.length*9);let f=0;for(let y=0;y<u.length;y++){const _=u[y],g=_.p1,v=_.p2,M=_.p3;h[f++]=g[0],h[f++]=g[1],h[f++]=g[2],h[f++]=v[0],h[f++]=v[1],h[f++]=v[2],h[f++]=M[0],h[f++]=M[1],h[f++]=M[2]}const p=new Qe;p.setAttribute("position",new mt(h,3)),p.computeVertexNormals(),p.computeBoundingBox(),p.computeBoundingSphere();const m=new Sp(p);m.name=l,m.userData.faceName=l,m.userData.__defaultMaterial=m.material;try{const y=typeof this.getFaceMetadata=="function"?this.getFaceMetadata(l):null;y&&typeof y=="object"&&(m.userData={...m.userData||{},...y})}catch{}m.parentSolid=this;try{m.owningFeatureID=this?.owningFeatureID||null}catch{}a.set(l,m),this.add(m)}if(t){if(!o){let l=[];try{l=this.getBoundaryEdgePolylines()||[]}catch{l=[]}if(!Array.isArray(l)||l.length===0)try{o=!0}catch{}for(const u of l){const h=new Float32Array(u.positions.length*3);let f=0;for(let g=0;g<u.positions.length;g++){const v=u.positions[g];h[f++]=v[0],h[f++]=v[1],h[f++]=v[2]}const p=new Ri;p.setPositions(Array.from(h));try{p.computeBoundingSphere()}catch{}const m=new Wo(p);m.name=u.name,m.closedLoop=!!u.closedLoop,m.userData={faceA:u.faceA,faceB:u.faceB,polylineLocal:u.positions,closedLoop:!!u.closedLoop},m.userData.__defaultMaterial=m.material,Yx(m,this),m.parentSolid=this;const y=a.get(u.faceA),_=a.get(u.faceB);y&&y.edges.push(m),_&&_.edges.push(m),y&&m.faces.push(y),_&&m.faces.push(_),this.add(m)}}if(o)try{const l=this._vertProperties||[],u=this._triVerts||[],h=this._triIDs||[],f=l.length/3|0,p=u.length/3|0,m=BigInt(Math.max(1,f)),y=d((b,C)=>{const S=BigInt(b),T=BigInt(C);return S<T?S*m+T:T*m+S},"ukey"),_=new Map;for(let b=0;b<p;b++){const C=h[b],S=b*3,T=u[S+0]>>>0,x=u[S+1]>>>0,E=u[S+2]>>>0,w=[[T,x],[x,E],[E,T]];for(let A=0;A<3;A++){const R=w[A][0],P=w[A][1],I=y(R,P);let N=_.get(I);N||(N=[],_.set(I,N)),N.push({id:C,a:R,b:P,tri:b})}}const g=d(b=>this._idToFaceName&&this._idToFaceName.get?this._idToFaceName.get(b):String(b),"nameOf"),v=new Map;for(const[,b]of _.entries()){if(b.length!==2)continue;const C=b[0],S=b[1];if(C.id===S.id)continue;const T=g(C.id),x=g(S.id),E=T<x?[T,x]:[x,T],w=JSON.stringify(E);let A=v.get(w);A||(A=[],v.set(w,A));const R=Math.min(C.a,C.b),P=Math.max(C.a,C.b);A.push([R,P])}const M=d((b,C,S)=>{const T=new Set,x=new Map,E=d((A,R)=>A<R?`${A},${R}`:`${R},${A}`,"ek");for(const[A,R]of S)x.has(A)||x.set(A,new Set),x.has(R)||x.set(R,new Set),x.get(A).add(R),x.get(R).add(A);const w=d(A=>[l[A*3+0],l[A*3+1],l[A*3+2]],"verts");for(const[A]of x.entries()){if([...x.get(A)].length!==1)continue;const R=[];let P=A,I=-1;for(;;){const N=[...x.get(P)];let D=N[0];if(D===I&&N.length>1&&(D=N[1]),D===void 0)break;const L=E(P,D);if(T.has(L)||(T.add(L),R.push(w(P)),I=P,P=D,!x.has(P)))break}if(R.push(w(P)),R.length>=2){const N=R.flat();if(N.some(W=>!isFinite(W))){console.error("Invalid coordinates detected in edge polyline:"),console.error("Poly coordinates:",R),console.error("Flat coordinates:",N),console.error("Face names:",b,"|",C);continue}const L=new Ri;L.setPositions(N);try{L.computeBoundingSphere()}catch{}const H=new Wo(L);H.name=`${b}|${C}`,H.closedLoop=!1,H.userData={faceA:b,faceB:C,polylineLocal:R,closedLoop:!1},H.userData.__defaultMaterial=H.material,Yx(H,this),H.parentSolid=this;const X=a.get(b),O=a.get(C);X&&X.edges.push(H),O&&O.edges.push(H),X&&H.faces.push(X),O&&H.faces.push(O);try{H.computeLineDistances()}catch{}this.add(H)}}},"addPolyline");for(const[b,C]of v.entries()){const[S,T]=JSON.parse(b);M(S,T,C)}}catch{}}try{if(Array.isArray(this._auxEdges)&&this._auxEdges.length)for(const l of this._auxEdges){const u=Array.isArray(l?.points)?l.points.filter(y=>Array.isArray(y)&&y.length===3):[];if(u.length<2)continue;const h=[];for(const y of u)h.push(y[0],y[1],y[2]);if(l?.closedLoop&&u.length>=2){const y=u[0],_=u[u.length-1],g=_[0]-y[0],v=_[1]-y[1],M=_[2]-y[2];(g!==0||v!==0||M!==0)&&h.push(y[0],y[1],y[2])}if(h.some(y=>!isFinite(y))){console.error("Invalid coordinates in auxiliary edge:",l?.name||"CENTERLINE"),console.error("Points:",u),console.error("Flat coordinates:",h);continue}const p=new Ri;p.setPositions(h);try{p.computeBoundingSphere()}catch{}const m=new Wo(p);m.name=l?.name||"CENTERLINE",m.closedLoop=!!l?.closedLoop,m.userData={...m.userData||{},polylineLocal:u,polylineWorld:!!l?.polylineWorld,centerline:!!l?.centerline,auxEdge:!0},m.parentSolid=this;try{const y=(l?.materialKey||"OVERLAY").toUpperCase(),_=Kt?.EDGE||{},g=_[y]||(y==="OVERLAY"?_.OVERLAY:null)||_.BASE;let v=g;if(g&&y!=="BASE"&&!(g.depthTest===!1&&g.depthWrite===!1)){const C=Object.values(_).includes(g);let S=!1;if(C&&typeof g.clone=="function"){try{v=g.clone(),S=!!v&&v!==g}catch{v=g,S=!1}if(S)try{g.resolution&&v.resolution&&typeof v.resolution.copy=="function"&&v.resolution.copy(g.resolution)}catch{}}if((S||!C)&&v){try{v.depthTest=!1}catch{}try{v.depthWrite=!1}catch{}}}v&&(m.material=v),v&&Zt.setBaseMaterial(m,v,{force:!1});try{m.computeLineDistances()}catch{}m.renderOrder=10020}catch{}m.userData||(m.userData={}),m.userData.__defaultMaterial=m.material,this.add(m)}}catch{}const c=d((l,u)=>!u||u.length===0?`VERTEX(${l[0]},${l[1]},${l[2]})`:`VERTEX[${[...u].sort().join("+")}]`,"generateVertexName");try{const l=new Map,u=new Map,h=new Set;for(const f of this.children){if(!f||f.type!=="EDGE")continue;const p=f.userData&&Array.isArray(f.userData.polylineLocal)?f.userData.polylineLocal:null;if(!p||p.length===0)continue;const m=f.name||"UNNAMED_EDGE",y=p[0],_=p[p.length-1],g=d(v=>{if(!v||v.length!==3)return;const M=`${v[0]},${v[1]},${v[2]}`;l.has(M)||l.set(M,v),u.has(M)||u.set(M,new Set),u.get(M).add(m)},"addEP");g(y),g(_)}if(l.size)for(const[f,p]of l.entries())try{const m=u.get(f);let y=c(p,m?Array.from(m):[]);if(h.has(y)){let _=1;for(;h.has(`${y}[${_}]`);)_++;y=`${y}[${_}]`}h.add(y),this.add(new vp(p,{name:y}))}catch{}}catch{}if(e.length)for(let l=e.length-1;l>=0;l--){const u=e[l];u&&this.add(u)}return this}d(c2,"visualize");function Yx(r,e){if(!r||!e)return;const t=r.name||null;if(!t)return;let n=null;try{n=typeof e.getEdgeMetadata=="function"?e.getEdgeMetadata(t):null}catch{n=null}n&&typeof n=="object"&&(r.userData={...r.userData||{},...n});const i=r.userData?.sheetMetalEdgeType;if(!(i&&i!=="AMBIGUOUS"))try{const s=Array.isArray(r.faces)?r.faces:[],o=new Set;let a=!1,c=!1;for(const l of s){const u=l2(l);u&&(a=!0),Bf(u)&&(o.add(u),c=!0)}if(!o.size&&r.userData){const l=[];r.userData.faceA&&l.push(r.userData.faceA),r.userData.faceB&&l.push(r.userData.faceB);for(const u of l){const f=(typeof e.getFaceMetadata=="function"?e.getFaceMetadata(u):null)?.sheetMetalFaceType;f&&(a=!0),Bf(f)&&(o.add(f),c=!0)}}if(o.size>=1){const l=[...o][0];r.userData={...r.userData||{},sheetMetalEdgeType:l},e&&typeof e.setEdgeMetadata=="function"&&e.setEdgeMetadata(t,{...e.getEdgeMetadata(t)||{},sheetMetalEdgeType:l})}else{const l=typeof t=="string"?t.split("|"):[];let u=null;for(const h of l){const p=(e&&typeof e.getFaceMetadata=="function"?e.getFaceMetadata(h):null)?.sheetMetalFaceType;if(p&&(a=!0),Bf(p)){c=!0,u=p;break}}u?(r.userData={...r.userData||{},sheetMetalEdgeType:u},e&&typeof e.setEdgeMetadata=="function"&&e.setEdgeMetadata(t,{...e.getEdgeMetadata(t)||{},sheetMetalEdgeType:u})):a&&c&&console.warn("[visualize] Edge has mixed or missing sheet metal face types",{edge:t,faceTypes:Array.from(o),faces:s.map(h=>h?.name||h?.userData?.faceName||"UNKNOWN")})}}catch{}}d(Yx,"annotateEdgeFromMetadata");function Ap(r){const e=String(r||"").trim().toUpperCase();return e==="A"||e==="B"?e:null}d(Ap,"normalizeSheetSurfaceType");function Bf(r){return Ap(r)!=null}d(Bf,"isSheetSurfaceType");function l2(r){if(!r||typeof r!="object")return null;const e=Ap(r?.userData?.sheetMetalFaceType);if(e)return e;const t=r?.parentSolid||r?.parent||null,n=r?.name||r?.userData?.faceName||null;if(!t||!n||typeof t.getFaceMetadata!="function")return null;try{return Ap(t.getFaceMetadata(n)?.sheetMetalFaceType)}catch{return null}}d(l2,"resolveSheetTypeFromFace");function Mb(r,{edgeNames:e,edges:t}={}){const n=[],i=Array.isArray(e)?Array.from(new Set(e.map(String))):[];if(i.length)for(const a of r?.children||[])a&&a.type==="EDGE"&&i.includes(a.name)&&(a.parentSolid===r||a.parent===r)&&n.push(a);if(Array.isArray(t))for(const a of t)a&&(a.parentSolid===r||a.parent===r)&&n.push(a);const s=[],o=new Set;for(const a of n)a&&!o.has(a)&&(o.add(a),s.push(a));return s}d(Mb,"resolveEdgesFromInputs");const u2=new U,h2=new U,f2=new U,d2=new U,p2=new U,m2=new U,jp=new U,Qp=new U,em=new U,g2=new U,wb=new U,_2=new U,Eb=new U;function y2(r,e=1e-12){return Math.max(e,e*Math.abs(r))}d(y2,"getScaleAdaptiveTolerance");function XR(r){return Math.max(1e-9,1e-6*Math.abs(r))}d(XR,"getDistanceTolerance");function qR(){return 1e-6}d(qR,"getAngleTolerance");const W_=class W_{constructor(e,t=null){if(this.triangleData=e||[],this.grid=new Map,!!this.triangleData.length){if(t==null){const n=this.triangleData.reduce((i,s)=>i+(s.rad||0),0)/this.triangleData.length;t=Math.max(n*2,1e-6)}this.cellSize=t,this.invCellSize=1/t;for(let n=0;n<this.triangleData.length;n++)for(const i of this.getTriangleCells(this.triangleData[n]))this.grid.has(i)||this.grid.set(i,[]),this.grid.get(i).push(n)}}cellKey(e,t,n){const i=Math.floor(e*this.invCellSize),s=Math.floor(t*this.invCellSize),o=Math.floor(n*this.invCellSize);return`${i},${s},${o}`}getTriangleCells({cx:e,cy:t,cz:n,rad:i}){const s=new Set,o=(e-i)*this.invCellSize,a=(e+i)*this.invCellSize,c=(t-i)*this.invCellSize,l=(t+i)*this.invCellSize,u=(n-i)*this.invCellSize,h=(n+i)*this.invCellSize;for(let f=Math.floor(o);f<=Math.floor(a);f++)for(let p=Math.floor(c);p<=Math.floor(l);p++)for(let m=Math.floor(u);m<=Math.floor(h);m++)s.add(`${f},${p},${m}`);return s}getNearbyTriangles(e,t=1/0){const n=this.cellKey(e.x,e.y,e.z),i=this.grid.get(n)||[];if(t===1/0||i.length)return i;const s=Math.ceil(t*this.invCellSize),o=Math.floor(e.x*this.invCellSize),a=Math.floor(e.y*this.invCellSize),c=Math.floor(e.z*this.invCellSize),l=new Set;for(let u=o-s;u<=o+s;u++)for(let h=a-s;h<=a+s;h++)for(let f=c-s;f<=c+s;f++){const p=this.grid.get(`${u},${h},${f}`);if(p)for(const m of p)l.add(m)}return Array.from(l)}};d(W_,"TriangleSpatialIndex");let Tp=W_;const Pr=new Map,Bu=new Map,x2=100;function rr(r,e=null){if(!Array.isArray(r)||r.length===0)return[];const t=e||r,n=Pr.get(t);if(n)return n;if(Pr.size>=x2){const h=Pr.keys().next().value;Pr.delete(h),Bu.delete(h)}const i=jp,s=Qp,o=em,a=g2,c=wb,l=_2,u=r.map(h=>{i.set(h.p1[0],h.p1[1],h.p1[2]),s.set(h.p2[0],h.p2[1],h.p2[2]),o.set(h.p3[0],h.p3[1],h.p3[2]);const f=(i.x+s.x+o.x)/3,p=(i.y+s.y+o.y)/3,m=(i.z+s.z+o.z)/3;a.subVectors(s,i),c.subVectors(o,i),l.crossVectors(a,c);const y=l.length();if(y<y2(1,1e-14))return null;l.multiplyScalar(1/y);const _=i.x-f,g=i.y-p,v=i.z-m,M=s.x-f,b=s.y-p,C=s.z-m,S=o.x-f,T=o.y-p,x=o.z-m,E=_*_+g*g+v*v,w=M*M+b*b+C*C,A=S*S+T*T+x*x,R=Math.sqrt(Math.max(E,w,A));return{cx:f,cy:p,cz:m,rad:R,normal:l.clone(),triangle:h}}).filter(Boolean);return Pr.set(t,u),u}d(rr,"getCachedFaceDataForTris");function tm(r,e=null){const t=e||r;let n=Bu.get(t);return!n&&Array.isArray(r)&&r.length&&(n=new Tp(r),Bu.set(t,n)),n}d(tm,"getCachedSpatialIndex");function YR(){Pr.clear(),Bu.clear()}d(YR,"clearFilletCaches");function ZR(r,e,t){return Math.max(e,Math.min(t,r))}d(ZR,"clamp");function KR(r){return Number.isFinite(r.x)&&Number.isFinite(r.y)&&Number.isFinite(r.z)}d(KR,"isFiniteVec3");function No(r,e,t,n,i){const s=u2.subVectors(t,e),o=h2.subVectors(n,e),a=f2.subVectors(r,e),c=s.dot(a),l=o.dot(a);if(c<=0&&l<=0)return i.copy(e),i;const u=d2.subVectors(r,t),h=s.dot(u),f=o.dot(u);if(h>=0&&f<=h)return i.copy(t),i;if(c*f-h*l<=0&&c>=0&&h<=0){const S=c/(c-h);return i.copy(e).addScaledVector(s,S),i}const m=p2.subVectors(r,n),y=s.dot(m),_=o.dot(m);if(_>=0&&y<=_)return i.copy(n),i;if(y*l-c*_<=0&&l>=0&&_<=0){const S=l/(l-_);return i.copy(e).addScaledVector(o,S),i}if(h*_-y*f<=0&&f-h>=0&&y-_>=0){const S=(f-h)/(f-h+(y-_));return i.copy(t).addScaledVector(m2.subVectors(n,t),S),i}const M=1/(s.dot(s)*o.dot(o)-Math.pow(s.dot(o),2)),b=(o.dot(o)*s.dot(a)-s.dot(o)*o.dot(a))*M,C=(s.dot(s)*o.dot(a)-s.dot(o)*s.dot(a))*M;return i.copy(e).addScaledVector(s,b).addScaledVector(o,C),i}d(No,"closestPointOnTriangleToOut");function v2(r,e,t=null,n=null){if(!Array.isArray(r)||r.length===0)return e.clone();const i=t&&Array.isArray(t)?t:rr(r,n);if(!i||!i.length)return e.clone();const s=tm(i,n);let o=null;const a=jp,c=Qp,l=em,u=Eb;if(s){const h=s.getNearbyTriangles(e);if(h.length){for(const f of h){if(f>=i.length)continue;const p=i[f].triangle;a.set(p.p1[0],p.p1[1],p.p1[2]),c.set(p.p2[0],p.p2[1],p.p2[2]),l.set(p.p3[0],p.p3[1],p.p3[2]),No(e,a,c,l,u);const m=u.distanceToSquared(e);(!o||m<o.d2)&&(o={d2:m,q:u.clone()})}if(o&&i.length>64){const f=Math.sqrt(o.d2),p=new Set(h);for(let m=0;m<i.length;m++){if(p.has(m))continue;const y=i[m],_=y.cx-e.x,g=y.cy-e.y,v=y.cz-e.z,M=_*_+g*g+v*v,b=y.rad||0,C=f+b;if(M>C*C)continue;const S=y.triangle;a.set(S.p1[0],S.p1[1],S.p1[2]),c.set(S.p2[0],S.p2[1],S.p2[2]),l.set(S.p3[0],S.p3[1],S.p3[2]),No(e,a,c,l,u);const T=u.distanceToSquared(e);T<o.d2&&(o={d2:T,q:u.clone()})}}}else{const f=i.map((m,y)=>({i:y,d2:(m.cx-e.x)**2+(m.cy-e.y)**2+(m.cz-e.z)**2}));f.sort((m,y)=>m.d2-y.d2);const p=Math.min(16,f.length);for(let m=0;m<p;m++){const y=i[f[m].i].triangle;a.set(y.p1[0],y.p1[1],y.p1[2]),c.set(y.p2[0],y.p2[1],y.p2[2]),l.set(y.p3[0],y.p3[1],y.p3[2]),No(e,a,c,l,u);const _=u.distanceToSquared(e);(!o||_<o.d2)&&(o={d2:_,q:u.clone()})}}}else{const h=Math.min(16,i.length),f=i.map((p,m)=>({i:m,d2:(p.cx-e.x)**2+(p.cy-e.y)**2+(p.cz-e.z)**2}));f.sort((p,m)=>p.d2-m.d2);for(let p=0;p<h;p++){const m=i[f[p].i].triangle;a.set(m.p1[0],m.p1[1],m.p1[2]),c.set(m.p2[0],m.p2[1],m.p2[2]),l.set(m.p3[0],m.p3[1],m.p3[2]),No(e,a,c,l,u);const y=u.distanceToSquared(e);(!o||y<o.d2)&&(o={d2:y,q:u.clone()})}}return o?o.q:e.clone()}d(v2,"projectPointOntoFaceTriangles");function JR(r,e,t=null,n=null){if(!Array.isArray(e)||!e.length)return[];if(!Array.isArray(r)||!r.length)return e.map(a=>a.clone());const i=t&&Array.isArray(t)?t:rr(r,n),s=tm(i,n),o=new Array(e.length);if(s){const a=new Map,c=s.invCellSize;for(let l=0;l<e.length;l++){const u=e[l],h=`${Math.floor(u.x*c)},${Math.floor(u.y*c)},${Math.floor(u.z*c)}`;let f=a.get(h);f||(f=[],a.set(h,f)),f.push(l)}for(const[l,u]of a.entries()){const[h,f,p]=l.split(",").map(Number),m=[];for(let _=-1;_<=1;_++)for(let g=-1;g<=1;g++)for(let v=-1;v<=1;v++){const M=`${h+_},${f+g},${p+v}`,b=s.grid.get(M);if(b)for(const C of b)m.push(C)}const y=Array.from(new Set(m));for(const _ of u){const g=e[_];let v=null;const M=jp,b=Qp,C=em,S=Eb;for(const T of y){const x=i[T];if(!x)continue;const E=x.triangle;M.set(E.p1[0],E.p1[1],E.p1[2]),b.set(E.p2[0],E.p2[1],E.p2[2]),C.set(E.p3[0],E.p3[1],E.p3[2]),No(g,M,b,C,S);const w=S.distanceToSquared(g);(!v||w<v.d2)&&(v={d2:w,q:S.clone()})}o[_]=v?v.q:g.clone()}}}else for(let a=0;a<e.length;a++)o[a]=v2(r,e[a],i,n);return o}d(JR,"batchProjectPointsOntoFace");function zu(r,e){const t=r.getFace(e);if(!t||!t.length)return new U(0,1,0);const n=new U,i=new U,s=new U,o=new U,a=new U,c=new U;for(const l of t)i.set(l.p1[0],l.p1[1],l.p1[2]),s.set(l.p2[0],l.p2[1],l.p2[2]),o.set(l.p3[0],l.p3[1],l.p3[2]),a.subVectors(s,i),c.subVectors(o,i),n.add(a.clone().cross(c));return n.lengthSq()===0?new U(0,1,0):n.normalize()}d(zu,"averageFaceNormalObjectSpace");function ku(r,e,t,n=null,i=null){const s=t&&typeof t.x=="number"?t:wb.set(t?.[0]||0,t?.[1]||0,t?.[2]||0);let o=Array.isArray(n)&&n.length?n:null;if(!o){const h=r?.getFace?r.getFace(e):null;if(!Array.isArray(h)||h.length===0)return null;o=rr(h,i||e)}if(!o||!o.length)return null;const a=tm(o,i||e||null);let c=null,l=1/0;const u=d(h=>{const f=o[h];if(!f)return;const p=s.x-f.cx,m=s.y-f.cy,y=s.z-f.cz,_=Math.abs(f.normal.x*p+f.normal.y*m+f.normal.z*y);_<l&&(l=_,c=f.normal)},"evalIdx");if(a){const h=Number.isFinite(a.cellSize)?a.cellSize*1.5:1/0,f=a.getNearbyTriangles(s,h);if(Array.isArray(f))for(const p of f)u(p)}if(!c){const h=Math.min(16,o.length),f=[];for(let p=0;p<o.length;p++){const m=o[p];if(!m)continue;const y=s.x-m.cx,_=s.y-m.cy,g=s.z-m.cz,v=y*y+_*_+g*g;f.length<h?(f.push({idx:p,d2:v}),f.length===h&&f.sort((M,b)=>M.d2-b.d2)):v<f[f.length-1].d2&&(f[f.length-1]={idx:p,d2:v},f.sort((M,b)=>M.d2-b.d2))}for(const p of f)u(p.idx)}return c||null}d(ku,"localFaceNormalAtPoint");function jR(r,e=1e-5){if(!Array.isArray(r)||r.length===0||e!==1e-5)return e;let t=1/0,n=1/0,i=1/0,s=-1/0,o=-1/0,a=-1/0;const c=[];for(const m of r)for(let y=0;y<m.length;y++){const _=m[y];if(_[0]<t&&(t=_[0]),_[0]>s&&(s=_[0]),_[1]<n&&(n=_[1]),_[1]>o&&(o=_[1]),_[2]<i&&(i=_[2]),_[2]>a&&(a=_[2]),y>0){const g=m[y-1],v=g[0]-_[0],M=g[1]-_[1],b=g[2]-_[2];c.push(Math.hypot(v,M,b))}}const l=s-t,u=o-n,h=a-i,f=Math.hypot(l,u,h)||1;c.sort((m,y)=>m-y);const p=c.length?c[c.length>>1]:f;return Math.min(Math.max(1e-5,f*.001),p*.1)}d(jR,"deriveTolerance");function b2(r){const e=r||1e-5;return{q:d(i=>[Math.round(i[0]/e)*e,Math.round(i[1]/e)*e,Math.round(i[2]/e)*e],"q"),k:d(i=>`${i[0]},${i[1]},${i[2]}`,"k")}}d(b2,"createQuantizer");function S2(r){if(!r)return null;const e=r._triVerts,t=r._vertProperties;if(!e||!t||typeof e.length!="number"||typeof t.length!="number")return null;const n=e.length/3|0;if(n===0||t.length<9)return null;let i=1/0,s=1/0,o=1/0,a=-1/0,c=-1/0,l=-1/0;for(let m=0;m<t.length;m+=3){const y=t[m],_=t[m+1],g=t[m+2];y<i&&(i=y),y>a&&(a=y),_<s&&(s=_),_>c&&(c=_),g<o&&(o=g),g>l&&(l=g)}const h=1e-6*(Math.hypot(a-i,c-s,l-o)||1),f=d((m,y,_,g,v,M,b,C,S,T,x,E,w,A,R)=>{const I=T-b,N=x-C,D=E-S,L=w-b,H=A-C,X=R-S,O=v*X-M*H,W=M*L-g*X,G=g*H-v*L,Q=I*O+N*W+D*G;if(Math.abs(Q)<1e-12)return null;const z=1/Q,Z=m-b,q=y-C,Y=_-S,K=(Z*O+q*W+Y*G)*z;if(K<-1e-12||K>1+1e-12)return null;const le=q*D-Y*N,ae=Y*I-Z*D,me=Z*N-q*I,ve=(g*le+v*ae+M*me)*z;if(ve<-1e-12||K+ve>1+1e-12)return null;const he=(L*le+H*ae+X*me)*z;return he>1e-10?he:null},"rayTri"),p=[[1,0,0],[0,1,0],[0,0,1]];return m=>{if(!m||!Number.isFinite(m.x)||!Number.isFinite(m.y)||!Number.isFinite(m.z))return!1;const y=m.x,_=m.y,g=m.z;let v=0;for(let M=0;M<p.length;M++){const b=p[M],C=y+(M+1)*h,S=_+(M+2)*h,T=g+(M+3)*h;let x=0;for(let E=0;E<n;E++){const w=E*3,A=(e[w+0]>>>0)*3,R=(e[w+1]>>>0)*3,P=(e[w+2]>>>0)*3;f(C,S,T,b[0],b[1],b[2],t[A+0],t[A+1],t[A+2],t[R+0],t[R+1],t[R+2],t[P+0],t[P+1],t[P+2])!==null&&x++}x%2===1&&v++}return v>=2}}d(S2,"buildPointInsideTester");const Zx=new Set;function Vs(r,e="face_name_mutation",t=!1){const n=String(r||"").trim();if(n&&t){const i=`${e}:${n}`;if(Zx.has(i))return;Zx.add(i)}}d(Vs,"breakOnFaceNameMutation");function M2(r){const e=new Map;let t=r?._faceIndex||null;return n=>{if(!r||typeof r.getFace!="function"||!n)return[];const i=r?._faceIndex||null;if(i!==t&&(e.clear(),t=i),e.has(n))return e.get(n);const s=r.getFace(n),o=Array.isArray(s)?s:[],a=r?._faceIndex||null;return a!==t&&(e.clear(),t=a),e.set(n,o),o}}d(M2,"createFaceTrianglesAccessor");function Ab(r){if(!r||typeof r.getFaceNames!="function")return[];const e=r.getFaceNames(),t=[];for(const n of e){if(typeof n!="string")continue;const i=typeof r.getFaceMetadata=="function"?r.getFaceMetadata(n):{};if(i&&(i.filletRoundFace||i.filletSourceArea||i.filletEndCap)){t.push(n);continue}(n.includes("_END_CAP")||n.includes("_CapStart")||n.includes("_CapEnd")||n.includes("_WEDGE_A")||n.includes("_WEDGE_B"))&&t.push(n)}return t}d(Ab,"getFilletMergeCandidateNames");function Tb(r,e){const t=r&&typeof r.getFaceNames=="function"?r.getFaceNames():[],n=t.find(i=>typeof i=="string"&&i.includes("_TUBE_Outer"));if(n)return n;if(e){const i=`${e}_TUBE_Outer`;return t.includes(i),i}return null}d(Tb,"guessRoundFaceName");function Cb(r,e=1e-5){const t=Array.isArray(r?._vertProperties)?r._vertProperties:null;if(!t||t.length<6)return e;let n=1/0,i=1/0,s=1/0,o=-1/0,a=-1/0,c=-1/0;for(let p=0;p<t.length;p+=3){const m=t[p+0],y=t[p+1],_=t[p+2];m<n&&(n=m),m>o&&(o=m),y<i&&(i=y),y>a&&(a=y),_<s&&(s=_),_>c&&(c=_)}const l=o-n,u=a-i,h=c-s,f=Math.hypot(l,u,h)||1;return Math.max(e,f*1e-6)}d(Cb,"deriveSolidToleranceFromVerts");function w2(r){const e=String(r||"AUTO").toUpperCase();return e==="INSET"||e==="OUTSET"||e==="AUTO"?e:"AUTO"}d(w2,"normalizeFilletDirectionMode");function Us(r,e){return!r||!e?NaN:Math.hypot(r.x-e.x,r.y-e.y,r.z-e.z)}d(Us,"distPoint3");function ns(r,e,t){if(!Array.isArray(r)||!e)return;const n=Number(e.x),i=Number(e.y),s=Number(e.z);if(!(!Number.isFinite(n)||!Number.isFinite(i)||!Number.isFinite(s))){for(const o of r){const a=n-o.x,c=i-o.y,l=s-o.z;if(a*a+c*c+l*l<=t)return}r.push({x:n,y:i,z:s})}}d(ns,"pushUniquePoint3");function Ib(r){const e=r?.faces?.[0]?.name||r?.userData?.faceA||null,t=r?.faces?.[1]?.name||r?.userData?.faceB||null;return{faceAName:e,faceBName:t}}d(Ib,"getEdgeFaceNames");function Rb(r){const e=r?.userData?.polylineLocal;return!Array.isArray(e)||e.length<2?null:e}d(Rb,"getEdgePolylineLocal");function E2(r,e){if(!Array.isArray(r)||r.length<2)return null;const t=Math.max(0,Math.min(1,Number(e))),n=r.length-1,i=t*n,s=Math.min(n-1,Math.floor(i)),o=i-s,a=r[s],c=r[s+1];return!Array.isArray(a)||!Array.isArray(c)||a.length<3||c.length<3?null:[a[0]+(c[0]-a[0])*o,a[1]+(c[1]-a[1])*o,a[2]+(c[2]-a[2])*o]}d(E2,"samplePolylineAt");function ht(r){if(Array.isArray(r)&&r.length>=3){const e=Number(r[0]),t=Number(r[1]),n=Number(r[2]);return Number.isFinite(e)&&Number.isFinite(t)&&Number.isFinite(n)?{x:e,y:t,z:n}:null}if(r&&typeof r=="object"){const e=Number(r.x),t=Number(r.y),n=Number(r.z);if(Number.isFinite(e)&&Number.isFinite(t)&&Number.isFinite(n))return{x:e,y:t,z:n}}return null}d(ht,"toPoint3Object");function Da(r,e){const t=ht(r),n=ht(e);if(!t||!n)return 1/0;const i=t.x-n.x,s=t.y-n.y,o=t.z-n.z;return i*i+s*s+o*o}d(Da,"point3DistanceSq");function Kx(r,e,t){const n=Math.hypot(r,e,t);return n>1e-12?[r/n,e/n,t/n]:null}d(Kx,"normalizePoint3Vector");function Jx(r,e,t=1e-6){if(!r||typeof r.getFace!="function"||!e)return[];const n=r.getFace(e);if(!Array.isArray(n)||n.length===0)return[];const i=[],s=Math.max(1e-16,Math.abs(Number(t)||0)**2);for(const o of n){const a=ht(o?.p1),c=ht(o?.p2),l=ht(o?.p3);a&&ns(i,a,s),c&&ns(i,c,s),l&&ns(i,l,s)}return i}d(Jx,"collectFaceUniquePoints");function jx(r){const e=Array.isArray(r)?r:[];if(e.length===0)return null;let t=0,n=0,i=0,s=0;for(const o of e){const a=ht(o);a&&(t+=a.x,n+=a.y,i+=a.z,s+=1)}return s>0?{x:t/s,y:n/s,z:i/s}:null}d(jx,"centroidOfPointSet");function Qx(r,e){const t=ht(e),n=Array.isArray(r)?r:[];if(!t||n.length===0)return NaN;const i=[];for(const s of n){const o=ht(s);if(!o)continue;const a=Math.hypot(o.x-t.x,o.y-t.y,o.z-t.z);a>1e-12&&i.push(a)}return i.length===0?NaN:(i.sort((s,o)=>s-o),i[i.length/2|0])}d(Qx,"estimatePointSetRadius");function A2(r){if(!r)return[];if(Array.isArray(r.edgePathPoints)&&r.edgePathPoints.length>=2)return r.edgePathPoints.map(ht).filter(Boolean);const e=Array.isArray(r.edgePolyline)?r.edgePolyline:null;if(e&&e.length>=2)return e.map(ht).filter(Boolean);const t=r.edgeObj;if(t&&typeof t.points=="function")try{const n=t.points(!1);if(Array.isArray(n)&&n.length>=2)return n.map(ht).filter(Boolean)}catch{}return[]}d(A2,"resolveEntryPathPoints");function ev(r){const e=A2(r);return e.length<2?null:{pathPoints:e,start:e[0],end:e[e.length-1]}}d(ev,"resolveEntryEndpoints");function tv(r,e,t=1e-10){const n=Array.isArray(r)?r:[];if(n.length<2)return null;const i=Math.max(1e-20,t*t);if((e|0)===0){const o=ht(n[0]);if(!o)return null;for(let a=1;a<n.length;a++){const c=ht(n[a]);if(c&&!(Da(o,c)<=i))return Kx(c.x-o.x,c.y-o.y,c.z-o.z)}return null}const s=ht(n[n.length-1]);if(!s)return null;for(let o=n.length-2;o>=0;o--){const a=ht(n[o]);if(a&&!(Da(s,a)<=i))return Kx(a.x-s.x,a.y-s.y,a.z-s.z)}return null}d(tv,"tangentAwayFromEndpoint");function Pb(r,e,t=1e-5){const n=ev(r),i=ev(e);if(!n||!i)return null;const s=[n.start,n.end],o=[i.start,i.end],a=Math.max(1e-20,t*t);let c=null;for(let m=0;m<s.length;m++)for(let y=0;y<o.length;y++){const _=s[m],g=o[y],v=Da(_,g);v<=a&&(!c||v<c.d2)&&(c={aEndIndex:m,bEndIndex:y,d2:v,pa:_,pb:g})}if(!c)return null;const l={x:(c.pa.x+c.pb.x)*.5,y:(c.pa.y+c.pb.y)*.5,z:(c.pa.z+c.pb.z)*.5},u=tv(n.pathPoints,c.aEndIndex,t*1e-4),h=tv(i.pathPoints,c.bEndIndex,t*1e-4);let f=NaN;Array.isArray(u)&&Array.isArray(h)&&(f=u[0]*h[0]+u[1]*h[1]+u[2]*h[2]);const p=Number.isFinite(f)?Math.min(1,Math.abs(f)):NaN;return{sharedPoint:l,aEndIndex:c.aEndIndex,bEndIndex:c.bEndIndex,distance:Math.sqrt(c.d2),tangentA:u,tangentB:h,tangentDot:f,absTangentDot:p}}d(Pb,"resolveSharedEndpointInfo");function T2(r){if(!r)return[];const e=Array.isArray(r.centerlinePathPoints)?r.centerlinePathPoints:Array.isArray(r.centerline)?r.centerline:null;return e&&e.length>=2?e.map(ht).filter(Boolean):[]}d(T2,"resolveEntryCenterlinePoints");function Vu(r,e,t=3,n=1e-10){const i=T2(r);if(i.length<2)return{endpoint:null,segments:[]};const s=(e|0)===0,o=[],a=Math.max(1e-20,Math.abs(Number(n)||0)**2),c=Math.max(1,Math.floor(Number(t)||1))+1;if(s)for(let u=0;u<i.length&&o.length<c;u++){const h=ht(i[u]);h&&(o.length>0&&Da(o[o.length-1],h)<=a||o.push(h))}else for(let u=i.length-1;u>=0&&o.length<c;u--){const h=ht(i[u]);h&&(o.length>0&&Da(o[o.length-1],h)<=a||o.push(h))}const l=[];for(let u=0;u<o.length-1;u++)l.push({a:o[u],b:o[u+1],index:u});return{endpoint:o[0]||null,segments:l}}d(Vu,"resolveCenterlineCornerSegments");function C2(r,e,t,n){const i=ht(r),s=ht(e),o=ht(t),a=ht(n);if(!i||!s||!o||!a)return null;const c=s.x-i.x,l=s.y-i.y,u=s.z-i.z,h=a.x-o.x,f=a.y-o.y,p=a.z-o.z,m=i.x-o.x,y=i.y-o.y,_=i.z-o.z,g=c*c+l*l+u*u,v=c*h+l*f+u*p,M=h*h+f*f+p*p,b=c*m+l*y+u*_,C=h*m+f*y+p*_,S=g*M-v*v,T=1e-14;let x,E=S,w,A=S;if(g<=T&&M<=T)return{distance:Us(i,o),s:0,t:0,pointA:i,pointB:o};g<=T?(x=0,E=1,w=C,A=M):M<=T?(w=0,A=1,x=-b,E=g):(x=v*C-M*b,w=g*C-v*b,x<0?(x=0,w=C,A=M):x>E&&(x=E,w=C+v,A=M)),w<0?(w=0,-b<0?x=0:-b>g?x=E:(x=-b,E=g)):w>A&&(w=A,-b+v<0?x=0:-b+v>g?x=E:(x=-b+v,E=g));const R=Math.abs(x)<=T?0:x/(Math.abs(E)<=T?1:E),P=Math.abs(w)<=T?0:w/(Math.abs(A)<=T?1:A),I=Math.max(0,Math.min(1,R)),N=Math.max(0,Math.min(1,P)),D={x:i.x+I*c,y:i.y+I*l,z:i.z+I*u},L={x:o.x+N*h,y:o.y+N*f,z:o.z+N*p};return{distance:Us(D,L),s:I,t:N,pointA:D,pointB:L}}d(C2,"closestPointsBetweenSegments3D");function I2(r,e,t,n={}){const i=t||{},s=Math.max(1e-10,Math.abs(Number(n.endpointTol)||0)),o=Math.max(s,Math.abs(Number(n.crossTolerance)||0)),a=Math.max(1e-4,Math.min(.2,Math.abs(Number(n.interiorParamEps)||.02))),c=Math.max(1,Math.floor(Number(n.maxSegments)||3)),l=Vu(r,i.aEndIndex,c,s*.001),u=Vu(e,i.bEndIndex,c,s*.001),h=Array.isArray(l?.segments)?l.segments:[],f=Array.isArray(u?.segments)?u.segments:[];if(h.length===0||f.length===0)return{crosses:!1,reason:"missing_centerline_segments",minDistance:1/0};let p=null;for(const m of h)for(const y of f){const _=C2(m?.a,m?.b,y?.a,y?.b);if(!(!_||!Number.isFinite(_.distance))&&((!p||_.distance<p.distance)&&(p={..._,segAIndex:Number(m?.index)||0,segBIndex:Number(y?.index)||0}),!(_.distance>o)&&!(_.s<=a||_.s>=1-a)&&!(_.t<=a||_.t>=1-a)))return{crosses:!0,reason:"interior_segment_cross",minDistance:_.distance,segAIndex:Number(m?.index)||0,segBIndex:Number(y?.index)||0,pointA:_.pointA,pointB:_.pointB}}return{crosses:!1,reason:"no_cross",minDistance:p?p.distance:1/0,segAIndex:p?p.segAIndex:null,segBIndex:p?p.segBIndex:null,pointA:p?p.pointA:null,pointB:p?p.pointB:null}}d(I2,"detectCenterlineCrossNearSharedCorner");function nv(r,e,t=1e-6){const n=r?.filletName;if(!n||typeof n!="string")return null;const i=(e|0)===0,s=`${n}_END_CAP_${i?1:2}`,o=`${n}_TUBE_${i?"CapStart":"CapEnd"}`,a=Jx(r?.wedgeSolid,s,t),c=i?r?.tubeCapPointsBeforeNudge?.start:r?.tubeCapPointsBeforeNudge?.end,l=Array.isArray(c)?c.map(ht).filter(Boolean):[],u=Jx(r?.tubeSolid,o,t),h=l.length>=3?l:u;return{wedgeFaceName:s,tubeFaceName:o,wedgePoints:a,tubePoints:h,tubePointsBeforeNudge:l,tubePointsAfterNudge:u,wedgeCenter:jx(a),tubeCenter:jx(h)}}d(nv,"resolveEntryEndCapData");function iv(r,e,t,n=1e-5,i=8){if(!Array.isArray(r)||r.length<2||!e||typeof e._fromManifold!="function")return null;const s=[],o=Math.max(1e-16,(Math.abs(Number(n)||1e-5)*.01)**2);for(const f of r){const p=ht(f);p&&ns(s,p,o)}if(s.length<2)return null;const a=Math.max(1e-6,Math.abs(Number(n)||0)),c=Math.max(6,Math.floor(Number(i)||8));let l=null,u=null;const h=[];try{l=Fi.sphere(a,c);for(const p of s)h.push(l.translate([p.x,p.y,p.z]));if(h.length===1?u=h[0]:u=Fi.hull(h),!u)return null;Vs(t||"CORNER_WEDGE_BRIDGE","createHullSolidFromPoints._fromManifold");const f=e._fromManifold(u,new Map([[0,t||"CORNER_WEDGE_BRIDGE"]]));try{f.name=t||"CORNER_WEDGE_BRIDGE"}catch{}return f}catch{if(u)try{typeof u.delete=="function"&&u.delete()}catch{}return null}finally{if(l)try{typeof l.delete=="function"&&l.delete()}catch{}for(const f of h)if(!(!f||f===u))try{typeof f.delete=="function"&&f.delete()}catch{}}}d(iv,"createHullSolidFromPoints");function R2(r,e=null){if(!r)return[];const t=typeof r.getFaceNames=="function"?r.getFaceNames():[],n=new Set((Array.isArray(t)?t:[]).filter(a=>typeof a=="string"&&a.length>0));if(n.size===0)return[];const i=[],s=d(a=>{!a||!n.has(a)||i.includes(a)||i.push(a)},"addCandidate"),o=typeof e=="string"&&e.length>0?e:null;o&&(s(`${o}_CapStart`),s(`${o}_CapEnd`),s(`${o}_END_CAP_1`),s(`${o}_END_CAP_2`));for(const a of n)(/_CapStart$/.test(a)||/_CapEnd$/.test(a)||/_END_CAP_[12]$/.test(a))&&s(a);return i}d(R2,"collectBridgeEndCapFaceNames");function sv(r,e=null,t=.001){if(!r||typeof r.pushFace!="function")return 0;const n=R2(r,e);if(n.length===0)return 0;const i=Number.isFinite(Number(t))?Number(t):.001;let s=0;for(const o of n)try{r.pushFace(o,i,{warnMissing:!1}),s+=1}catch{}return s}d(sv,"nudgeBridgeEndCapsOutward");function Gr(r=""){const e=String(r??"");let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}d(Gr,"stableStringHash32");function Hs(r,e="TOKEN"){const t=String(r??"").trim();return t&&t.replace(/\[\d+\]$/g,"").replace(/[^A-Za-z0-9]+/g,"_").replace(/^_+|_+$/g,"").replace(/_+/g,"_")||e}d(Hs,"sanitizeFaceNameToken");function Fa(r,e="EDGE"){const t=typeof r?.edgeObj?.name=="string"&&r.edgeObj.name.trim().length>0?r.edgeObj.name.trim():null;if(t)return t;const n=typeof r?.edgeName=="string"&&r.edgeName.trim().length>0?r.edgeName.trim():null;return n||(typeof r?.filletName=="string"&&r.filletName.trim().length>0?r.filletName.trim():"")||e}d(Fa,"resolveBridgeEntryEdgeName");function P2(r,e="FILLET"){const t=Fa(r,`${e}_EDGE`),n=Hs(t,"EDGE"),i=n.length>48?n.slice(0,48):n,s=Gr(t).toString(16).slice(-8).padStart(8,"0");return`${e}_FILLET_SIDEWALL_${i}_${s}`}d(P2,"buildEdgeDerivedSideWallFaceName");function N2(r,e=1e-5){const t=new Map,n=(Array.isArray(r)?r:[]).filter(i=>!!i&&!!i.edgeObj&&!!i.filletSolid&&!i.cornerBridge);for(const i of n)t.set(i,{start:!1,end:!1});for(let i=0;i<n.length;i++)for(let s=i+1;s<n.length;s++){const o=n[i],a=n[s],c=Pb(o,a,e);if(!c)continue;const l=t.get(o),u=t.get(a);l&&((c.aEndIndex|0)===0?l.start=!0:l.end=!0),u&&((c.bEndIndex|0)===0?u.start=!0:u.end=!0)}return t}d(N2,"computeFilletEntryEndpointAdjacency");function D2({entry:r=null,featureID:e="FILLET",includeStartCap:t=!1,includeEndCap:n=!1}={}){const i=r?.filletSolid,s=r?.filletName;if(!i||typeof i.getFaceNames!="function"||typeof i.renameFace!="function")return{mergedFaceName:null,mergedCount:0,mergedFaces:[]};if(!s||typeof s!="string")return{mergedFaceName:null,mergedCount:0,mergedFaces:[]};const o=i.getFaceNames(),a=new Set((Array.isArray(o)?o:[]).filter(m=>typeof m=="string")),c=[`${s}_SURFACE_CA`,`${s}_SURFACE_CB`,`${s}_FACE_A`,`${s}_FACE_B`,`${s}_WEDGE_A`,`${s}_WEDGE_B`,`${s}_SIDE_A`,`${s}_SIDE_B`];t&&c.push(`${s}_END_CAP_1`),n&&c.push(`${s}_END_CAP_2`);const l=c.filter(m=>a.has(m));if(l.length===0)return{mergedFaceName:null,mergedCount:0,mergedFaces:[]};const u=`${s}_TUBE_Outer`,h=a.has(u)?u:P2(r,e);a.has(h)&&!l.includes(h)&&l.unshift(h);const f=[];for(const m of l)!m||m===h||(Vs(h,"mergeEntrySideWallFaces.target",!0),Vs(m,"mergeEntrySideWallFaces.source"),i.renameFace(m,h),f.push(m));const p=Fa(r,`${e}_EDGE`);return i.setFaceMetadata(h,{filletMergedSideWall:!0,filletSideWall:!0,filletSideWallEdge:p,filletSideWallIncludesStartCap:!!t,filletSideWallIncludesEndCap:!!n}),{mergedFaceName:h,mergedCount:f.length+(a.has(h)?0:1),mergedFaces:f}}d(D2,"mergeEntrySideWallFaces");function F2({entries:r=[],featureID:e="FILLET",endpointTol:t=1e-5,debug:n=!1}={}){const i=(Array.isArray(r)?r:[]).filter(c=>!!c&&!!c.edgeObj&&!!c.filletSolid&&!c.cornerBridge);if(i.length===0)return{processedEntries:0,mergedEntries:0,mergedFaces:0};const s=N2(i,t);let o=0,a=0;for(const c of i){const l=s.get(c)||{start:!1,end:!1},u=D2({entry:c,featureID:e,includeStartCap:!!l.start,includeEndCap:!!l.end});u?.mergedFaceName&&(o+=1,a+=Number(u.mergedFaces?.length||0),c.sideWallFaceName=u.mergedFaceName,c.sideWallMergedFaces=Array.isArray(u.mergedFaces)?u.mergedFaces.slice():[],c.sideWallAdjacency={start:!!l.start,end:!!l.end},Array.isArray(c.mergeCandidates)&&!c.mergeCandidates.includes(u.mergedFaceName)&&c.mergeCandidates.push(u.mergedFaceName),n&&console.log("[Solid.fillet] Merged fillet side-wall faces.",{featureID:e,filletName:c.filletName,edge:Fa(c,null),sideWallFaceName:u.mergedFaceName,mergedFaces:u.mergedFaces,includeStartCap:!!l.start,includeEndCap:!!l.end}))}return{processedEntries:i.length,mergedEntries:o,mergedFaces:a}}d(F2,"mergeFilletEntrySideWallsByEdge");function L2(r,e,t,n="BRIDGE"){const i=String(e??"EDGE_A"),s=String(t??"EDGE_B"),o=[i,s].sort((p,m)=>p.localeCompare(m)),c=String(r??"FILLET").trim()||"FILLET",l=Hs(o[0],"EDGE_A"),u=Hs(o[1],"EDGE_B"),h=Gr(`${o[0]}|${o[1]}`).toString(16).padStart(8,"0"),f=Hs(n,"BRIDGE");return`${c}_${f}_${l}__${u}_${h}`}d(L2,"buildDeterministicBridgeName");function O2(r,e="FILLET_CORNER_BRIDGE"){if(!r)return null;const t=Array.isArray(r?._triVerts)?r._triVerts:null;if(!t||t.length<9)return null;const n=t.length/3|0,i=typeof e=="string"&&e.length>0?e:"FILLET_CORNER_BRIDGE",s=0,o={};if(r._faceMetadata instanceof Map&&r._faceMetadata.size>0)for(const a of r._faceMetadata.values())!a||typeof a!="object"||Object.assign(o,a);try{r._manifold&&typeof r._manifold.delete=="function"&&r._manifold.delete()}catch{}return Vs(i,"collapseSolidToSingleFaceName.unified"),r._manifold=null,r._triIDs=new Array(n).fill(s),r._idToFaceName=new Map([[s,i]]),r._faceNameToID=new Map([[i,s]]),r._faceMetadata=new Map([[i,o]]),r._faceIndex=null,r._dirty=!0,r}d(O2,"collapseSolidToSingleFaceName");function U2({solid:r=null,sourceFaceName:e="",desiredNames:t=[],anchorPoints:n=[]}={}){if(!r||typeof e!="string"||e.length===0)return{componentCount:0,names:[]};const i=Array.isArray(r?._triVerts)?r._triVerts:null,s=Array.isArray(r?._vertProperties)?r._vertProperties:null,o=Array.isArray(r?._triIDs)?r._triIDs:null,a=r?._faceNameToID instanceof Map?r._faceNameToID:null,c=r?._idToFaceName instanceof Map?r._idToFaceName:null;if(!i||!s||!o||!a||!c)return{componentCount:0,names:[]};const l=a.get(e);if(l===void 0)return{componentCount:0,names:[]};const u=Math.min(o.length,i.length/3|0);if(u<=0)return{componentCount:0,names:[]};const h=[];for(let A=0;A<u;A++)o[A]>>>0===l>>>0&&h.push(A);if(h.length===0)return{componentCount:0,names:[]};const f=d((A,R)=>A<R?`${A}|${R}`:`${R}|${A}`,"edgeKey"),p=new Map,m=new Map;for(const A of h)m.set(A,[]);for(const A of h){const R=A*3,P=i[R+0]>>>0,I=i[R+1]>>>0,N=i[R+2]>>>0,D=[[P,I],[I,N],[N,P]];for(const[L,H]of D){const X=f(L,H);let O=p.get(X);O||(O=[],p.set(X,O)),O.push(A)}}for(const A of p.values())if(!(!Array.isArray(A)||A.length<2))for(let R=0;R<A.length;R++)for(let P=R+1;P<A.length;P++){const I=A[R],N=A[P];!m.has(I)||!m.has(N)||(m.get(I).push(N),m.get(N).push(I))}const y=new Set,_=[],g=d((A=0,R=0,P=0)=>({x:A,y:R,z:P}),"toPoint"),v=d(A=>{const R=A*3,P=(i[R+0]>>>0)*3,I=(i[R+1]>>>0)*3,N=(i[R+2]>>>0)*3,D=Number(s[P+0])||0,L=Number(s[P+1])||0,H=Number(s[P+2])||0,X=Number(s[I+0])||0,O=Number(s[I+1])||0,W=Number(s[I+2])||0,G=Number(s[N+0])||0,Q=Number(s[N+1])||0,z=Number(s[N+2])||0;return g((D+X+G)/3,(L+O+Q)/3,(H+W+z)/3)},"triCentroid");for(const A of h){if(y.has(A))continue;const R=[A];y.add(A);const P=[];let I=A,N=0,D=0,L=0,H=0;for(;R.length>0;){const X=R.pop();P.push(X),X<I&&(I=X);const O=v(X);N+=O.x,D+=O.y,L+=O.z,H+=1;const W=m.get(X)||[];for(const G of W)y.has(G)||(y.add(G),R.push(G))}_.push({tris:P,minTri:I,center:H>0?g(N/H,D/H,L/H):g(0,0,0)})}if(_.length===0)return{componentCount:0,names:[]};_.sort((A,R)=>A.minTri-R.minTri);const M=(Array.isArray(n)?n:[]).map(A=>ht(A)).filter(Boolean);let b=Array.isArray(t)?t.map(A=>typeof A=="string"?A.trim():"").filter(A=>A.length>0):[];if(_.length===2&&b.length>=2&&M.length>=2){const A=_[0].center,R=_[1].center,P=M[0],I=M[1],N=(Us(A,P)||0)+(Us(R,I)||0),D=(Us(A,I)||0)+(Us(R,P)||0);Number.isFinite(D)&&D<N&&(b=[b[1],b[0],...b.slice(2)])}const C=new Set(a.keys());C.delete(e);const S=d((A,R)=>{const P=`${e}_PART_${R+1}`,I=typeof A=="string"&&A.length>0?A:P;let N=I,D=2;for(;C.has(N);)N=`${I}_${D}`,D+=1;return C.add(N),N},"makeUniqueName"),T=_.map((A,R)=>S(b[R],R));if(_.length===1){if(T[0]!==e){if(Vs(T[0],"relabelDisconnectedFaceComponents.single_component"),a.delete(e),a.set(T[0],l),c.set(l,T[0]),r._faceMetadata instanceof Map){const A=r._faceMetadata.get(e);A!==void 0&&r._faceMetadata.set(T[0],A),r._faceMetadata.delete(e)}r._faceIndex=null,r._dirty=!0}return{componentCount:1,names:T}}let x=0;for(const A of c.keys()){const R=Number(A);Number.isFinite(R)&&R>=x&&(x=R+1)}for(let A=0;A<u;A++){const R=Number(o[A]);Number.isFinite(R)&&R>=x&&(x=R+1)}const E=r._faceMetadata instanceof Map?r._faceMetadata:null,w=E?E.get(e):void 0;Vs(T[0],"relabelDisconnectedFaceComponents.primary_component"),a.delete(e),a.set(T[0],l),c.set(l,T[0]),E&&(w!==void 0&&E.set(T[0],w),E.delete(e));for(let A=1;A<_.length;A++){const R=_[A];for(;c.has(x);)x+=1;const P=x;x+=1;for(const I of R.tris)o[I]=P>>>0;Vs(T[A],"relabelDisconnectedFaceComponents.additional_component"),c.set(P,T[A]),a.set(T[A],P),E&&w!==void 0&&(w&&typeof w=="object"?E.set(T[A],{...w}):E.set(T[A],w))}return r._triIDs=o,r._faceNameToID=a,r._idToFaceName=c,r._faceIndex=null,r._dirty=!0,{componentCount:_.length,names:T}}d(U2,"relabelDisconnectedFaceComponents");function B2({filletEntries:r=[],featureID:e="FILLET",radius:t=1,resolution:n=32,SolidClass:i=null,TubeClass:s=null,debug:o=!1}={}){const a=Array.isArray(r)?r:[];if(!a.length||!i||typeof i._fromManifold!="function")return[];const c=Math.abs(Number(t)||0),l=Math.max(1e-6,c*1e-4),u=Math.max(1e-7,l*.5),h=.995,{q:f,k:p}=b2(Math.max(l,1e-6)),m=[],y=new Set;for(let _=0;_<a.length;_++){const g=a[_];if(!(!g||!g.filletSolid||!g.wedgeSolid||!g.tubeSolid))for(let v=_+1;v<a.length;v++){const M=a[v];if(!M||!M.filletSolid||!M.wedgeSolid||!M.tubeSolid)continue;const b=String(g?.edgeDirection||"INSET").toUpperCase(),C=String(M?.edgeDirection||"INSET").toUpperCase();if(b!==C)continue;const S=Pb(g,M,l);if(!S||Number.isFinite(S.absTangentDot)&&S.absTangentDot>=h)continue;const T=Fa(g,`${e}_EDGE_${_}`),x=Fa(M,`${e}_EDGE_${v}`),E=`${[T,x].sort().join("|")}:${p(f([S.sharedPoint.x,S.sharedPoint.y,S.sharedPoint.z]))}`;if(y.has(E))continue;y.add(E);const w=nv(g,S.aEndIndex,u),A=nv(M,S.bEndIndex,u);if(!w||!A||w.wedgePoints.length<3||A.wedgePoints.length<3)continue;const R=Vu(g,S.aEndIndex,4,u),P=Vu(M,S.bEndIndex,4,u),I=ht(R?.endpoint)||null,N=ht(P?.endpoint)||null,D=ht(w.tubeCenter)||ht(w.wedgeCenter)||null,L=ht(A.tubeCenter)||ht(A.wedgeCenter)||null,H=D||I||null,X=L||N||null,O=H&&X?Us(H,X):NaN,W=Qx(w.tubePoints,D||H),G=Qx(A.tubePoints,L||X);let Q=c;Number.isFinite(W)&&Number.isFinite(G)?Q=Math.min(W,G):Number.isFinite(W)?Q=W:Number.isFinite(G)&&(Q=G),Q=Math.max(1e-6,Q);const z=Math.max(l*2,u*4,1e-6);if(!Number.isFinite(O)||!(O>z)){o&&console.log("[Solid.fillet] Skipping non-tangent corner bridge: no measurable centerline gap.",{featureID:e,sourceFillets:[g?.filletName||null,M?.filletName||null],tubeDistance:Number.isFinite(O)?O:null,minBridgeGap:z});continue}const Z=I2(g,M,S,{endpointTol:l,crossTolerance:Math.max(z,Q*.001,5e-6),maxSegments:4,interiorParamEps:.02});if(Z?.crosses){o&&console.log("[Solid.fillet] Skipping non-tangent corner bridge: adjacent centerlines cross.",{featureID:e,sourceFillets:[g?.filletName||null,M?.filletName||null],crossInfo:Z,tubeDistance:O});continue}const q=[],Y=Math.max(1e-16,u*u);for(const pe of w.wedgePoints)ns(q,pe,Y);for(const pe of A.wedgePoints)ns(q,pe,Y);if(q.length<4)continue;const K=`${L2(e,T,x,"CORNER")}_${Gr(E).toString(16).padStart(8,"0")}`,le=`${K}_WEDGE_BRIDGE`,ae=`${K}_TUBE_BRIDGE`,me=Hs(T,`EDGE_${_}`),ve=Hs(x,`EDGE_${v}`),he=Gr(T).toString(16).slice(-6).padStart(6,"0"),ee=Gr(x).toString(16).slice(-6).padStart(6,"0"),ne=`${K}_WEDGE_BRIDGE_ON_${me}_${he}`,ie=`${K}_WEDGE_BRIDGE_ON_${ve}_${ee}`,xe=Math.max(1e-6,c*1e-4,u*.2),$=iv(q,i,le,xe,Math.max(6,Math.min(16,Math.floor(Number(n)/4)||8)));if(!$||!Array.isArray($?._triVerts)||$._triVerts.length<9)continue;let be=$;try{be.name=le}catch{}const Ie=[g?.tubeSolid,M?.tubeSolid].filter(pe=>pe&&Array.isArray(pe?._triVerts)&&pe._triVerts.length>=9);let Ne=0;if(Ie.length>0){for(let pe=0;pe<Ie.length;pe++){const Ce=Ie[pe];try{const we=be.subtract(Ce);if(!we||!Array.isArray(we?._triVerts)||we._triVerts.length<9){be=null;break}be=we,Ne+=1}catch{be=null;break}}if(!be)continue;try{be.name=le}catch{}}const Ae=[],V=Math.max(1e-16,u*u);for(const pe of w.tubePoints)ns(Ae,pe,V);for(const pe of A.tubePoints)ns(Ae,pe,V);const F=.01;let j=null,re="none";if(Ae.length>=4&&(j=iv(Ae,i,ae,Math.max(1e-6,Q*.001,u*.25),Math.max(6,Math.min(16,Math.floor(Number(n)/4)||8))),j&&(re="tube_cap_hull")),!j&&s&&H&&X&&Number.isFinite(O)&&O>z)try{j=new s({points:[[H.x,H.y,H.z],[X.x,X.y,X.z]],radius:Q,innerRadius:0,resolution:Math.max(8,Math.floor(Number(n)||32)),selfUnion:!0,name:ae}),!Array.isArray(j?._triVerts)||j._triVerts.length<9?j=null:re="tube_centerline_fallback"}catch{j=null}if(!j||!Array.isArray(j?._triVerts)||j._triVerts.length<9)continue;let ge=j;try{ge.name=ae}catch{}let ue=sv(ge,ae,F);if(ue<=0){const pe=sv(j,ae,F);pe>0&&(ue=pe)}const Le=`${ae}_SINGLE_FACE`,Te=O2(ge,Le);if(!Te)continue;let De=be;try{De=be.subtract(Te);try{De.name=`${K}_FINAL_FILLET`}catch{}}catch{continue}if(!De||!Array.isArray(De?._triVerts)||De._triVerts.length<9)continue;const He=U2({solid:De,sourceFaceName:le,desiredNames:[ne,ie],anchorPoints:[w.wedgeCenter,A.wedgeCenter]}),de=Array.isArray(He?.names)?He.names:[],Me=Ab(De);for(const pe of de)!pe||Me.includes(pe)||Me.push(pe);m.push({filletSolid:De,filletName:K,mergeCandidates:Me,roundFaceName:Tb(De,K),wedgeSolid:be,tubeSolid:Te,edgeDirection:b,directionReason:"corner_bridge_non_tangent",directionDetail:{sourceFillets:[g?.filletName||null,M?.filletName||null],sourceEdges:[T,x],sharedPoint:S.sharedPoint,tangentDot:Number.isFinite(S.tangentDot)?S.tangentDot:null,endpointDistance:S.distance,tubeCenterlineGap:Number.isFinite(O)?O:null,minBridgeGap:z,centerlineCrossCheck:Z||null,tubeBridgeMode:re,bridgeEndCapPushDistance:F,adjacentEdgeTubeCutters:Ie.length,adjacentEdgeTubeSubtractionsApplied:Ne,trimmedByAdjacentWedges:0,finalBridgeRetrimmedByAdjacentWedges:0,bridgeEndCapsPushed:ue,bridgeSingleFaceName:Le,bridgeTransitionFaceNames:de,bridgeTransitionFaceComponents:Number(He?.componentCount)||0},edgeObj:null,edgePolyline:null,edgePathPoints:[],cornerBridge:!0})}}return o&&m.length>0&&console.log("[Solid.fillet] Built non-tangent corner bridge entries.",{featureID:e,generatedCorners:m.length,endpointTolerance:l,tangentDotThreshold:h}),m}d(B2,"buildNonTangentCornerTransitionEntries");function z2(r,e,t,n,i=null){if(!r||typeof r.getBoundaryEdgePolylines!="function")return null;const s=Array.isArray(i)?i:r.getBoundaryEdgePolylines()||[],o=e?.name;if(o){const a=s.find(c=>c?.name===o);if(a)return a}return!t||!n?null:s.find(a=>{const c=a?.faceA,l=a?.faceB;return c===t&&l===n||c===n&&l===t})||null}d(z2,"findBoundaryPolylineForEdge");function k2(r,e,t,n){if(!r||!e||!Number.isInteger(t)||!Number.isInteger(n))return 0;const i=r?._faceNameToID instanceof Map?r._faceNameToID.get(e):void 0;if(i===void 0)return 0;const s=Array.isArray(r?._triVerts)?r._triVerts:null,o=Array.isArray(r?._triIDs)?r._triIDs:null;if(!s||!o||s.length!==o.length*3)return 0;for(let a=0;a<o.length;a++){if(o[a]>>>0!==i>>>0)continue;const c=a*3,l=s[c+0],u=s[c+1],h=s[c+2];if(l===t&&u===n||u===t&&h===n||h===t&&l===n)return 1;if(l===n&&u===t||u===n&&h===t||h===n&&l===t)return-1}return 0}d(k2,"findDirectedEdgeOrientationInFace");function V2(r,e,t){const n=Array.isArray(t?.indices)?t.indices:null,i=Array.isArray(r?._vertProperties)?r._vertProperties:null;if(!n||n.length<2||!i)return null;const s=[],o=(n.length-1)/2;for(let a=0;a<n.length-1;a++)s.push(a);s.sort((a,c)=>Math.abs(a-o)-Math.abs(c-o));for(const a of s){const c=Number(n[a]),l=Number(n[a+1]);if(!Number.isInteger(c)||!Number.isInteger(l)||c===l)continue;const u=k2(r,e,c,l);if(!u)continue;const h=c*3,f=l*3;if(h+2>=i.length||f+2>=i.length)continue;let p=i[f+0]-i[h+0],m=i[f+1]-i[h+1],y=i[f+2]-i[h+2];u<0&&(p=-p,m=-m,y=-y);const _=Math.hypot(p,m,y);if(_>1e-12)return p/=_,m/=_,y/=_,{tangent:[p,m,y],midpoint:[(i[h+0]+i[f+0])*.5,(i[h+1]+i[f+1])*.5,(i[h+2]+i[f+2])*.5],segmentIndex:a}}return null}d(V2,"resolveOrientedEdgeTangent");function H2(r,e,t="INSET",n=.2,i=null,s=null){const o=String(t||"INSET").toUpperCase()==="OUTSET"?"OUTSET":"INSET";if(!r||!e)return{direction:o,reason:"missing_context"};const{faceAName:a,faceBName:c}=Ib(e);if(!a||!c)return{direction:o,reason:"missing_faces"};const l=z2(r,e,a,c,i);if(!l)return{direction:o,reason:"missing_boundary_polyline"};const u=V2(r,a,l);if(!u)return{direction:o,reason:"missing_oriented_tangent"};const h=typeof s=="function"?s(a):typeof r.getFace=="function"?r.getFace(a):null,f=typeof s=="function"?s(c):typeof r.getFace=="function"?r.getFace(c):null;if(!Array.isArray(h)||!h.length||!Array.isArray(f)||!f.length)return{direction:o,reason:"missing_face_geometry"};const p=r?.uuid||r?.name||"SOLID",m=`${p}:${a}:AUTO_SIGNED`,y=`${p}:${c}:AUTO_SIGNED`,_=rr(h,m),g=rr(f,y),v=zu(r,a),M=zu(r,c),b={x:u.midpoint[0],y:u.midpoint[1],z:u.midpoint[2]},C=ku(r,a,b,_,m)||v,S=ku(r,c,b,g,y)||M;if(!C||!S)return{direction:o,reason:"missing_normals"};const T=Number(C.y)*Number(S.z)-Number(C.z)*Number(S.y),x=Number(C.z)*Number(S.x)-Number(C.x)*Number(S.z),E=Number(C.x)*Number(S.y)-Number(C.y)*Number(S.x),w=u.tangent[0],A=u.tangent[1],R=u.tangent[2],P=T*w+x*A+E*R;return Number.isFinite(P)?P>n?{direction:"INSET",reason:"signed_dihedral",signedDihedral:P}:P<-n?{direction:"OUTSET",reason:"signed_dihedral",signedDihedral:P}:{direction:o,reason:"signed_dihedral_ambiguous",signedDihedral:P}:{direction:o,reason:"invalid_signed_dihedral"}}d(H2,"classifyEdgeFilletDirectionBySignedDihedral");function G2(r,e,t,n=1,i="INSET",s=null,o=null){const a=String(i||"INSET").toUpperCase()==="OUTSET"?"OUTSET":"INSET";if(!r||!e)return{direction:a,reason:"missing_context"};const c=H2(r,e,i,.2,s,o);if(c?.reason==="signed_dihedral")return c;if(typeof t!="function")return{direction:a,reason:"missing_inside_tester",signedDihedral:c?.signedDihedral};const{faceAName:l,faceBName:u}=Ib(e);if(!l||!u)return{direction:a,reason:"missing_faces"};const h=Rb(e);if(!h)return{direction:a,reason:"missing_polyline"};const f=typeof o=="function"?o(l):typeof r.getFace=="function"?r.getFace(l):null,p=typeof o=="function"?o(u):typeof r.getFace=="function"?r.getFace(u):null;if(!Array.isArray(f)||f.length===0||!Array.isArray(p)||p.length===0)return{direction:a,reason:"missing_face_geometry"};const m=r?.uuid||r?.name||"SOLID",y=`${m}:${l}:AUTO_DIR`,_=`${m}:${u}:AUTO_DIR`,g=rr(f,y),v=rr(p,_),M=zu(r,l),b=zu(r,u),C=Math.max(Cb(r,1e-6)*8,Math.abs(Number(n)||0)*1e-4,1e-6),S=[.2,.5,.8];let T=0,x=0,E=0,w=0;for(const A of S){const R=E2(h,A);if(!R)continue;const P={x:R[0],y:R[1],z:R[2]};if(!Number.isFinite(P.x)||!Number.isFinite(P.y)||!Number.isFinite(P.z))continue;const I=ku(r,l,P,g,y)||M,N=ku(r,u,P,v,_)||b;if(!I||!N){E++;continue}let D=Number(I.x)+Number(N.x),L=Number(I.y)+Number(N.y),H=Number(I.z)+Number(N.z);const X=Math.hypot(D,L,H);if(!(X>1e-12)){E++;continue}D/=X,L/=X,H/=X;const O={x:P.x+D*C,y:P.y+L*C,z:P.z+H*C},W={x:P.x-D*C,y:P.y-L*C,z:P.z-H*C},G=!!t(O),Q=!!t(W);w++,Q&&!G?T++:G&&!Q?x++:E++}return T>x?{direction:"INSET",reason:"classified",insetVotes:T,outsetVotes:x,ambiguousSamples:E,usedSamples:w}:x>T?{direction:"OUTSET",reason:"classified",insetVotes:T,outsetVotes:x,ambiguousSamples:E,usedSamples:w}:{direction:a,reason:"ambiguous",insetVotes:T,outsetVotes:x,ambiguousSamples:E,usedSamples:w}}d(G2,"classifyEdgeFilletDirectionByInsideOutside");async function W2(r={}){const{filletSolid:e}=await is(async()=>{const{filletSolid:z}=await import("./fillet-CJey7GJP.js");return{filletSolid:z}},__vite__mapDeps([2,3,4,1])),{Tube:t}=await is(async()=>{const{Tube:z}=await import("./Tube-bO80ROeR.js");return{Tube:z}},__vite__mapDeps([3,4,1])),n=Number(r.radius);if(!Number.isFinite(n)||n<=0)throw new Error(`Solid.fillet: radius must be > 0, got ${r.radius}`);const i=w2(r.direction),s=i==="OUTSET"?"OUTSET":"INSET",o=i==="AUTO",a=Number.isFinite(r.inflate)?Number(r.inflate):.1,c=Number(r.nudgeFaceDistance),l=Number.isFinite(c)?c:1e-4,u=!!r.debug,h=Number(r.debugSolidsLevel),f=Number.isFinite(h)?Math.max(-1,Math.min(2,Math.floor(h))):0,p=!!r.debugShowCombinedBeforeTarget,m=Number(r.resolution),y=Number.isFinite(m)&&m>0?Math.max(8,Math.floor(m)):32,_=!!r.showTangentOverlays,g=r.featureID||"FILLET",v=Mb(this,{edges:r.edges});if(v.length===0){console.warn("[Solid.fillet] No edges resolved on target solid; returning clone.",{featureID:g,solid:this?.name});const z=this.clone();try{z.name=this.name}catch{}return z}const M=o&&typeof this.getBoundaryEdgePolylines=="function"?(()=>{try{return this.getBoundaryEdgePolylines()||[]}catch{return null}})():null,b=o?M2(this):null,C=[];let S=0;const T=[],x=d(z=>{if(!(!z||T.length===0))try{z.__debugAddedSolids=T}catch{}},"attachDebugSolids"),E=d(()=>{const z=this.clone();try{z.name=this.name}catch{}return x(z),z},"buildFallbackResult"),w=d((z,Z=!1)=>{!u&&!Z||!z||T.push(z)},"pushDebugSolid"),A=d((z,Z,q=!1)=>{if(!(!u||!z)&&!(q&&typeof z.clone!="function"))try{const Y=typeof z.clone=="function"?z.clone():z;try{Y.name=Z}catch{}T.push(Y)}catch{}},"pushNamedDebugSnapshot"),R=d(z=>{if(!(!u||!z)){try{z.tube&&w(z.tube)}catch{}try{z.wedge&&w(z.wedge)}catch{}}},"pushTubeAndWedgeDebug"),P=d((z,Z)=>{const q=(Array.isArray(z)?z:[]).map(K=>K?.filletSolid).filter(Boolean);if(q.length===0)return null;let Y=q[0];for(let K=1;K<q.length;K++){Y=Y.union(q[K]);try{Y.name=`${g}_COMBINED_FILLET_${Z}`}catch{}u&&f>=2&&Y&&typeof Y.clone=="function"&&A(Y,`${g}_COMBINED_${Z}_STEP_${K-1}`,!0)}try{Y.name=`${g}_COMBINED_FILLET_${Z}`}catch{}return Y},"combineFilletEntrySolids"),I=[{mode:"INSET",operation:"subtract",stepIndex:0,stepLabel:"SUBTRACT",entries:[],combinedSolid:null},{mode:"OUTSET",operation:"union",stepIndex:1,stepLabel:"UNION",entries:[],combinedSolid:null}],N=d(z=>String(z||"INSET").toUpperCase()==="OUTSET"?I[1]:I[0],"getBooleanGroupForDirection"),D=o?S2(this):null;let L=0;const H={mode:i,autoEnabled:o,fallbackDirection:s,totalEdges:v.length,insetEdges:0,outsetEdges:0,fallbackEdges:0,ambiguousEdges:0};for(const z of v){const Z=typeof z?.name=="string"&&z.name.trim().length>0?z.name.trim():`EDGE_${S}`,q=Hs(Z,`EDGE_${S}`),Y=q.length>48?q.slice(0,48):q,K=Gr(Z).toString(16).slice(-8).padStart(8,"0"),le=`${g}_FILLET_${Y}_${K}_${S++}`;let ae=s,me=o?"fallback":"explicit",ve=null;if(o){const be=G2(this,z,D,n,s,M,b);ae=be?.direction||s,me=be?.reason||"fallback",ve=be||null,me==="classified"||me==="signed_dihedral"||(H.fallbackEdges+=1,String(me||"").includes("ambiguous")&&(H.ambiguousEdges+=1))}ae==="OUTSET"?H.outsetEdges+=1:H.insetEdges+=1;const he=e({edgeToFillet:z,radius:n,sideMode:ae,inflate:a,nudgeFaceDistance:l,resolution:y,debug:u,name:le,showTangentOverlays:_})||{};if(he.error&&console.warn(`Fillet failed for edge ${z?.name||S}: ${he.error}`),!he.finalSolid){R(he),console.warn("[Solid.fillet] Fillet builder returned no finalSolid.",{featureID:g,edge:z?.name,error:he.error,hasTube:!!he.tube,hasWedge:!!he.wedge});continue}const ee=Ab(he.finalSolid),ne=Tb(he.finalSolid,le),ie=Rb(z),xe=Array.isArray(he?.centerline)&&he.centerline.length>=2?he.centerline.map(be=>ht(be)).filter(Boolean):[],$=Array.isArray(he?.edge)&&he.edge.length>=2?he.edge.map(be=>ht(be)).filter(Boolean):Array.isArray(ie)?ie.map(be=>ht(be)).filter(Boolean):[];C.push({filletSolid:he.finalSolid,filletName:le,mergeCandidates:ee,roundFaceName:ne,wedgeSolid:he.wedge||null,tubeSolid:he.tube||null,tubeCapPointsBeforeNudge:he.tubeCapPointsBeforeNudge||null,edgeDirection:ae,directionReason:me,directionDetail:ve,edgeObj:z||null,edgePolyline:ie,centerlinePathPoints:xe,edgePathPoints:$}),u&&f>=0&&(f===0?R(he):(f===1||R(he),w(he.finalSolid)))}try{const z=this?.constructor?.BaseSolid||this?.constructor||null,Z=B2({filletEntries:C,featureID:g,radius:n,resolution:y,SolidClass:z,TubeClass:t,debug:u});if(Z.length>0){L=Z.length;for(const q of Z)C.push(q);if(u&&f>=0)for(const q of Z)f===0?(q?.tubeSolid&&w(q.tubeSolid),q?.wedgeSolid&&w(q.wedgeSolid)):(f===1||(q?.tubeSolid&&w(q.tubeSolid),q?.wedgeSolid&&w(q.wedgeSolid)),q?.filletSolid&&w(q.filletSolid));console.log("[Solid.fillet] Added non-tangent corner transition fillets.",{featureID:g,addedCorners:Z.length})}}catch(z){console.warn("[Solid.fillet] Failed to build non-tangent corner transitions.",{featureID:g,error:z?.message||z})}if(o&&console.log("[Solid.fillet] AUTO direction classification complete.",{featureID:g,insetEdges:H.insetEdges,outsetEdges:H.outsetEdges,fallbackEdges:H.fallbackEdges,ambiguousEdges:H.ambiguousEdges}),C.length===0)return console.error("[Solid.fillet] All edge fillets failed; returning clone.",{featureID:g,edgeCount:v.length}),E();try{const z=Math.max(1e-6,Math.min(.001,Cb(this,1e-5))),Z=F2({entries:C,featureID:g,endpointTol:z,debug:u});u&&Z.mergedEntries>0&&console.log("[Solid.fillet] Merged per-edge fillet side walls.",{featureID:g,...Z})}catch(z){console.warn("[Solid.fillet] Failed to merge per-edge fillet side walls; continuing.",{featureID:g,error:z?.message||z})}for(const z of C)N(z?.edgeDirection).entries.push(z);const X=I[0].entries,O=I[1].entries;try{for(const z of I)z.combinedSolid=P(z.entries,z.mode);if(u&&p)for(const z of I)z.combinedSolid&&A(z.combinedSolid,`${g}_COMBINED_FILLET_${z.mode}_PRE_TARGET`,!1)}catch(z){return console.error("[Solid.fillet] Fillet combine failed; returning clone.",{featureID:g,error:z?.message||z}),E()}if(!I.some(z=>!!z.combinedSolid))return console.error("[Solid.fillet] No combined fillet solids available; returning clone.",{featureID:g,edgeCount:v.length}),E();let W=this;try{for(const z of I)z.combinedSolid&&(W=z.operation==="subtract"?W.subtract(z.combinedSolid):W.union(z.combinedSolid),u&&f>=2&&W&&typeof W.clone=="function"&&A(W,`${g}_TARGET_BOOLEAN_STEP_${z.stepIndex}_${z.stepLabel}`,!0));try{W.name=this.name}catch{}u&&typeof W?.visualize=="function"&&W.visualize()}catch(z){return console.error("[Solid.fillet] Fillet boolean failed; returning clone.",{featureID:g,error:z?.message||z}),E()}try{await W.collapseTinyTriangles(9e-4)}catch(z){console.warn("[Solid.fillet] collapseTinyTriangles failed",{featureID:g,error:z?.message||z})}x(W);try{W.__filletDirectionDecision={...H,insetEntries:X.length,outsetEntries:O.length,cornerBridgeEntries:L}}catch{}try{W.__filletCornerBridgeCount=L}catch{}try{await W.removeSmallIslands()}catch(z){console.warn("[Solid.fillet] simplify failed; continuing without simplification",{featureID:g,error:z?.message||z})}const G=Array.isArray(W?._triVerts)?W._triVerts.length/3:0,Q=Array.isArray(W?._vertProperties)?W._vertProperties.length/3:0;return(!W||G===0||Q===0)&&console.error("[Solid.fillet] Fillet result is empty or missing geometry.",{featureID:g,finalTriCount:G,finalVertCount:Q,edgeCount:v.length,direction:i,inflate:a}),W}d(W2,"fillet");async function $2(r={}){const{ChamferSolid:e}=await is(async()=>{const{ChamferSolid:m}=await import("./chamfer-DdXNz6lz.js");return{ChamferSolid:m}},__vite__mapDeps([5,4,1])),t=Number(r.distance);if(!Number.isFinite(t)||t<=0)throw new Error(`Solid.chamfer: distance must be > 0, got ${r.distance}`);const n=String(r.direction||"INSET").toUpperCase(),i=Number.isFinite(r.inflate)?Number(r.inflate):.1,s=n==="OUTSET"?-i:i,o=!!r.debug,a=r.featureID||"CHAMFER";console.log("[Solid.chamfer] Begin",{featureID:a,solid:this?.name,distance:t,direction:n,inflate:i,inflateApplied:s,debug:o,requestedEdgeNames:Array.isArray(r.edgeNames)?r.edgeNames:[],providedEdgeCount:Array.isArray(r.edges)?r.edges.length:0});const c=Mb(this,{edgeNames:r.edgeNames,edges:r.edges});if(c.length===0){console.warn("[Solid.chamfer] No edges resolved on target solid; returning clone.",{featureID:a,solid:this?.name});const m=this.clone();try{m.name=this.name}catch{}return m}const l=[];let u=0;for(const m of c){const y=`${a}_CHAMFER_${u++}`;try{const _=new e({edgeToChamfer:m,distance:t,direction:n,inflate:s,debug:o,sampleCount:r.sampleCount,snapSeamToEdge:r.snapSeamToEdge,sideStripSubdiv:r.sideStripSubdiv,seamInsetScale:r.seamInsetScale,flipSide:r.flipSide,debugStride:r.debugStride});try{_.name=y}catch{}l.push(_)}catch(_){console.warn("[Solid.chamfer] Failed to build chamfer solid for edge",{edge:m?.name,error:_?.message||_})}}if(l.length===0){console.error("[Solid.chamfer] All chamfer solids failed; returning clone.",{featureID:a,edgeCount:c.length});const m=this.clone();try{m.name=this.name}catch{}return m}console.log("[Solid.chamfer] Built chamfer solids for edges",l.length);let h=this;for(const m of l){const y=Array.isArray(h?._triVerts)?h._triVerts.length/3:0;h=n==="OUTSET"?h.union(m):h.subtract(m);const _=Array.isArray(h?._triVerts)?h._triVerts.length/3:0;console.log("[Solid.chamfer] Applied chamfer boolean",{featureID:a,operation:n==="OUTSET"?"union":"subtract",beforeTriangles:y,afterTriangles:_});try{h.name=this.name}catch{}}try{h.__debugChamferSolids=l}catch{}const f=Array.isArray(h?._triVerts)?h._triVerts.length/3:0,p=Array.isArray(h?._vertProperties)?h._vertProperties.length/3:0;return!h||f===0||p===0?console.error("[Solid.chamfer] Chamfer result is empty or missing geometry.",{featureID:a,finalTriCount:f,finalVertCount:p,edgeCount:c.length,direction:n,inflate:i}):console.log("[Solid.chamfer] Completed",{featureID:a,triangles:f,vertices:p}),h}d($2,"chamfer");const qo=class qo extends sn{constructor(){super(...arguments),bC.apply(this,arguments)}bakeTransform(...e){return oI.apply(this,arguments)}bakeTRS(...e){return aI.apply(this,arguments)}_key(...e){return qC.apply(this,arguments)}_getPointIndex(...e){return YC.apply(this,arguments)}_getOrCreateID(...e){return ZC.apply(this,arguments)}addTriangle(...e){return KC.apply(this,arguments)}addAuxEdge(...e){return JC.apply(this,arguments)}addCenterline(...e){return jC.apply(this,arguments)}setFaceMetadata(...e){return QC.apply(this,arguments)}getFaceMetadata(...e){return eI.apply(this,arguments)}renameFace(...e){return nI.apply(this,arguments)}setEdgeMetadata(...e){return iI.apply(this,arguments)}getEdgeMetadata(...e){return sI.apply(this,arguments)}remesh(...e){return bI.apply(this,arguments)}removeSmallIslands(...e){return _I.apply(this,arguments)}removeSmallInternalIslands(...e){return yI.apply(this,arguments)}removeOppositeSingleEdgeFaces(...e){return xI.apply(this,arguments)}mirrorAcrossPlane(...e){return lI.apply(this,arguments)}pushFace(...e){return uI.apply(this,arguments)}removeTinyBoundaryTriangles(...e){return vI.apply(this,arguments)}collapseTinyTriangles(...e){return SI.apply(this,arguments)}invertNormals(...e){return gI.apply(this,arguments)}fixTriangleWindingsByAdjacency(...e){return pI.apply(this,arguments)}_isCoherentlyOrientedManifold(...e){return mI.apply(this,arguments)}setEpsilon(...e){return fI.apply(this,arguments)}clone(...e){return SC.apply(this,arguments)}_weldVerticesByEpsilon(...e){return dI.apply(this,arguments)}_manifoldize(...e){return hI.apply(this,arguments)}getMesh(...e){return RI.apply(this,arguments)}free(...e){return MC.apply(this,arguments)}offsetFace(...e){return cI.apply(this,arguments)}_ensureFaceIndex(...e){return PI.apply(this,arguments)}getFace(...e){return NI.apply(this,arguments)}getFaceNames(...e){return tI.apply(this,arguments)}toSTL(...e){return t2.apply(this,arguments)}async writeSTL(...e){return n2.apply(this,arguments)}toSTEP(...e){return i2.apply(this,arguments)}async writeSTEP(...e){return s2.apply(this,arguments)}getFaces(...e){return DI.apply(this,arguments)}visualize(...e){return c2.apply(this,arguments)}getBoundaryEdgePolylines(...e){return FI.apply(this,arguments)}_combineIdMaps(...e){return LI.apply(this,arguments)}_combineFaceMetadata(...e){return rI.apply(this,arguments)}static _expandTriIDsFromMesh(...e){return WI.apply(this,arguments)}static _fromManifold(...e){return $I.apply(this,arguments)}union(...e){return BI.apply(this,arguments)}subtract(...e){return zI.apply(this,arguments)}intersect(...e){return kI.apply(this,arguments)}difference(...e){return VI.apply(this,arguments)}simplify(...e){return GI.apply(this,arguments)}setTolerance(...e){return HI.apply(this,arguments)}volume(...e){return r2.apply(this,arguments)}surfaceArea(...e){return o2.apply(this,arguments)}getTriangleCount(...e){return a2.apply(this,arguments)}splitSelfIntersectingTriangles(...e){return MI.apply(this,arguments)}removeDegenerateTriangles(...e){return wI.apply(this,arguments)}removeInternalTriangles(...e){return EI.apply(this,arguments)}removeInternalTrianglesByRaycast(...e){return AI.apply(this,arguments)}removeInternalTrianglesByWinding(e={}){return TI.apply(this,[e])}cleanupTinyFaceIslands(...e){return CI.apply(this,arguments)}mergeTinyFaces(...e){return II.apply(this,arguments)}chamfer(e={}){return $2.apply(this,[e])}fillet(e={}){return W2.apply(this,[e])}get faces(){return this.visualize(),this.children.filter(e=>e.type==="FACE")}};d(qo,"Solid"),tt(qo,"BaseSolid",qo);let Gs=qo;const X2=d(r=>{try{const e=r?.owningFeatureID??r?.ID??null;return e?` owningFeature=${e}`:""}catch{return""}},"__solidProfilingOwnerTag"),rv=1e3,q2=d((r,e,t,n)=>{const i=Math.round(n),s=`${r} ${e}`;switch(t){case"resolved":return`${s} resolved in ${i} ms`;case"rejected":return`${s} rejected in ${i} ms`;case"completed":return`${s} in ${i} ms`;case"threw":return`${s} threw in ${i} ms`;default:return null}},"__solidProfilingFormatMessage"),Y2=d((r,e,t,n)=>{const i=q2(r,e,t,n);if(i&&n>=rv){const s=`${i} (SLOW > ${rv} ms)`;try{if(typeof console<"u"){const o=typeof console.warn=="function"?console.warn:typeof console.log=="function"?console.log:null;o&&o.call(console,s)}}catch{}}},"__solidProfilingLogTiming");(()=>{try{if(Gs.__profiled)return;Gs.__profiled=!0;const r=d(()=>typeof performance<"u"&&performance?.now?performance.now():Date.now(),"nowMs"),e=new Set(["constructor","_manifoldize"]),t=Gs.prototype;for(const n of Object.getOwnPropertyNames(t)){if(e.has(n))continue;const i=Object.getOwnPropertyDescriptor(t,n);if(!i||typeof i.value!="function")continue;const s=i.value,o=d(function(...a){const c=`[Solid${X2(this)}]`,l=r(),u=d(h=>{const f=r()-l;Y2(c,n,h,f)},"logPhase");try{const h=s.apply(this,a);return h&&typeof h.then=="function"?h.then(f=>(u("resolved"),f),f=>{throw u("rejected"),f}):(u("completed"),h)}catch(h){throw u("threw"),h}},"wrapped");try{Object.defineProperty(o,"name",{value:n,configurable:!0})}catch{}Object.defineProperty(t,n,{...i,value:o})}}catch{}})();const Pi=1e-9;function zf(r,e=0){const t=Number(r);return Number.isFinite(t)?t:e}d(zf,"toFiniteNumber");function Wr(r,e=[0,0,0]){const t=Array.isArray(r)?r:e;return[zf(t?.[0],e[0]||0),zf(t?.[1],e[1]||0),zf(t?.[2],e[2]||0)]}d(Wr,"sanitizeVec3");function kf(r){if(r==null)return"";if(typeof r=="string")return r.trim();if(typeof r=="object"){const e=typeof r.name=="string"?r.name.trim():"";if(e)return e;const t=typeof r.id=="string"?r.id.trim():"";if(t)return t}return""}d(kf,"normalizeReferenceName$1");function Z2(r,e=An){const t=r.clone().normalize(),n=Math.abs(t.dot(new e.Vector3(0,0,1)))>.9?new e.Vector3(0,1,0):new e.Vector3(0,0,1),i=new e.Vector3().crossVectors(n,t).normalize();return i.lengthSq()<=Pi?new e.Vector3(0,1,0):i}d(Z2,"pickOrthogonalUnit");function K2(r){return r?.scene?.getObjectByName?r.scene:r?.partHistory?.scene?.getObjectByName?r.partHistory.scene:r?.viewer?.scene?.getObjectByName?r.viewer.scene:r?.getObjectByName?r:null}d(K2,"resolveScene");function Hu(r,e=An){const t=new e.Vector3;try{r?.getWorldPosition?.(t)}catch{}return t}d(Hu,"resolveWorldPosition");function J2(r,e=An){try{const t=r?.geometry||null;if(t){const n=t.boundingSphere||(t.computeBoundingSphere(),t.boundingSphere);if(n)return r.localToWorld(n.center.clone())}}catch{}return Hu(r,e)}d(J2,"resolveFaceCenter");function j2(r,e=An){let t=null;try{typeof r?.getAverageNormal=="function"&&(t=r.getAverageNormal()?.clone?.()||null)}catch{}if(!t||t.lengthSq()<=Pi){const n=new e.Quaternion;try{r?.getWorldQuaternion?.(n)}catch{}t=new e.Vector3(0,0,1).applyQuaternion(n)}return!t||t.lengthSq()<=Pi?new e.Vector3(1,0,0):t.normalize()}d(j2,"resolveFaceDirection");function Q2(r,e=An){try{if(typeof r?.points=="function")return(r.points(!0)||[]).filter(n=>n&&Number.isFinite(n.x)&&Number.isFinite(n.y)&&Number.isFinite(n.z)).map(n=>new e.Vector3(n.x,n.y,n.z))}catch{}return[]}d(Q2,"resolveEdgePolyline");function eR(r,e,t=An){const n=e?.clone?.();if(!n||!Array.isArray(r)||r.length<2)return null;let i=null,s=Number.POSITIVE_INFINITY;for(let o=0;o<r.length-1;o+=1){const a=r[o],l=r[o+1].clone().sub(a),u=l.lengthSq();if(u<=Pi)continue;const h=t.MathUtils.clamp(n.clone().sub(a).dot(l)/u,0,1),f=a.clone().addScaledVector(l,h),p=f.distanceToSquared(n);p<s&&(s=p,i={origin:f,direction:l.normalize()})}return i}d(eR,"resolveClosestPointOnEdge");function tR(r,e=null,t=An){const n=Q2(r,t);if(n.length>=2){if(e?.isVector3){const o=eR(n,e,t);if(o)return o}const i=[];let s=0;for(let o=0;o<n.length-1;o+=1){const a=n[o].distanceTo(n[o+1]);i.push(a),s+=a}if(s>Pi){const o=s*.5;let a=0;for(let c=0;c<i.length;c+=1){const l=i[c];if(a+l>=o){const u=t.MathUtils.clamp((o-a)/Math.max(l,Pi),0,1);return{origin:n[c].clone().lerp(n[c+1],u),direction:n[c+1].clone().sub(n[c]).normalize()}}a+=l}return{origin:n[n.length-1].clone(),direction:n[n.length-1].clone().sub(n[n.length-2]).normalize()}}}return{origin:e?.clone?.()||Hu(r,t),direction:new t.Vector3(1,0,0)}}d(tR,"resolveEdgeAnchor");function Rr(r,e,t=An){const n=e.clone().normalize(),i=Z2(n,t),s=new t.Vector3().crossVectors(n,i).normalize(),o=new t.Vector3().crossVectors(s,n).normalize(),a=new t.Matrix4().makeBasis(n,o,s),c=new t.Quaternion().setFromRotationMatrix(a);return{position:[r.x,r.y,r.z],quaternion:[c.x,c.y,c.z,c.w],scale:[1,1,1]}}d(Rr,"makeBasisTransform");function nm(r){if(r==null)return null;if(r?.isObject3D){const e=kf(r);return e?{name:e,type:String(r.type||"").toUpperCase()}:null}if(typeof r=="string"){const e=kf(r);return e||null}if(typeof r=="object"){const e=kf(r);if(!e)return null;const t={name:e},n=String(r.type||"").trim().toUpperCase();return n&&(t.type=n),Array.isArray(r.pickPoint)&&r.pickPoint.length>=3&&(t.pickPoint=Wr(r.pickPoint,[0,0,0])),Number.isFinite(Number(r.faceIndex))&&Number(r.faceIndex)>=0&&(t.faceIndex=Math.floor(Number(r.faceIndex))),t}return null}d(nm,"sanitizeTransformReference");function Nr(r){const e=nm(r);return typeof e=="string"?e:typeof e?.name=="string"?e.name:""}d(Nr,"resolveTransformReferenceName");function im(r){const e=r&&typeof r=="object"?r:{},t={position:Wr(e.position,[0,0,0]),rotationEuler:Wr(e.rotationEuler,[0,0,0]),scale:Wr(e.scale,[1,1,1])},n=nm(e.reference);return n&&(t.reference=n),t}d(im,"sanitizeTransformValue");function nR(r,e){if(r?.isObject3D)return r;const t=K2(e),n=Nr(r);if(!t||!n||typeof t.getObjectByName!="function")return null;try{return t.getObjectByName(n)||null}catch{return null}}d(nR,"resolveTransformReferenceObject");function Cp(r,e,t={},n=An){const i=new n.Vector3(...Wr(t?.fallbackDirection,[1,0,0]));i.lengthSq()<=Pi&&i.set(1,0,0),i.normalize();const s=new n.Vector3(...Wr(t?.fallbackOrigin,[0,0,0])),o=nm(r),a=Array.isArray(o?.pickPoint)?new n.Vector3(...o.pickPoint):null,c=nR(r,e),l=String(o?.type||c?.type||"").trim().toUpperCase();if(!c)return Rr(a||s,i,n);if(l==="FACE")return Rr(a||J2(c,n),j2(c,n),n);if(l==="EDGE"){const p=tR(c,a,n);return Rr(p.origin,p.direction,n)}if(l==="VERTEX")return Rr(a||Hu(c,n),i,n);const u=a||Hu(c,n);if(l==="PLANE"){const p=new n.Quaternion;try{c.getWorldQuaternion?.(p)}catch{}const m=new n.Vector3(0,0,1).applyQuaternion(p);return Rr(u,m.lengthSq()>Pi?m:i,n)}const h=new n.Quaternion;try{c.getWorldQuaternion?.(h)}catch{}const f=new n.Vector3(1,0,0).applyQuaternion(h);return Rr(u,f.lengthSq()>Pi?f:i,n)}d(Cp,"resolveTransformReferenceBase");function QR(r,e,t={},n=An){const i=im(r),s=Cp(i.reference,e,t,n);return vb(s,i,n)}d(QR,"composeReferencedTransformMatrix");function iR({ui:r,key:e,def:t,id:n}){const i=document.createElement("button");return i.type="button",i.id=n,i.className="btn",i.textContent=String(t.label||r._prettyLabel(e)),i.addEventListener("click",s=>{s.preventDefault(),r._stopActiveReferenceSelection();const o=r.params&&Object.prototype.hasOwnProperty.call(r.params,"featureID")?r.params.featureID:r.params?.id??null;let a=!1;try{if(t&&typeof t.actionFunction=="function"){const c={featureID:o,key:e,viewer:r.options?.viewer||null,partHistory:r.options?.partHistory||null,feature:r.options?.featureRef||null,params:r.params,schemaDef:t},l=t.actionFunction(c);a=!0}}catch{}if(!a)try{typeof r.options.onAction=="function"&&r.options.onAction(o,e)}catch{}}),{inputEl:i,activate(){i.focus()},readValue(){return null}}}d(iR,"renderButtonField");const sR=2,$_=class $_ extends ft{constructor(e,t){super(),this.type="CombinedTransformControls",this.camera=e,this.domElement=t,this.enabled=!0,this.dragging=!1,this.mode="translate",this.displayMode="transform",this.dimensionToggleEnabled=!1,this.showX=!0,this.showY=!0,this.showZ=!0,this.isTransformGizmo=!0,this._defaultSizeMultiplier=sR,this._sizeMultiplier=this._defaultSizeMultiplier,this.renderOrder=5e4,this.target=null,this._raycaster=new Du,this._pointer=new Ee,this._tmpV=new U,this._tmpV2=new U,this._tmpQ=new Mt,this._plane=new Zn,this.gizmo=this._buildGizmo(),this.add(this.gizmo.root),this._updateDisplayModeVisuals(),this._onPointerDown=this._handlePointerDown.bind(this),this._onPointerMove=this._handlePointerMove.bind(this),this._onPointerUp=this._handlePointerUp.bind(this),this.domElement&&(this.domElement.addEventListener("pointerdown",this._onPointerDown,{passive:!1}),window.addEventListener("pointermove",this._onPointerMove,{passive:!1}),window.addEventListener("pointerup",this._onPointerUp,{passive:!1,capture:!0}))}dispose(){try{this.domElement?.removeEventListener("pointerdown",this._onPointerDown)}catch{}try{window.removeEventListener("pointermove",this._onPointerMove)}catch{}try{window.removeEventListener("pointerup",this._onPointerUp,{capture:!0})}catch{}}getHelper(){return this}getMode(){return this.mode}setMode(e){this.mode=String(e||"translate")}getDisplayMode(){return this.displayMode}setDisplayMode(e){const t=String(e||"transform")==="dimensions"&&this.dimensionToggleEnabled?"dimensions":"transform",n=this.displayMode!==t;this.displayMode=t,this._updateDisplayModeVisuals(),n&&(this.dispatchEvent({type:"display-mode-changed",value:this.displayMode}),this.dispatchEvent({type:"change"}))}toggleDisplayMode(){if(!this.dimensionToggleEnabled)return this.displayMode;const e=this.displayMode==="dimensions"?"transform":"dimensions";return this.setDisplayMode(e),this.displayMode}setDimensionToggleEnabled(e){this.dimensionToggleEnabled=!!e,!this.dimensionToggleEnabled&&this.displayMode==="dimensions"&&(this.displayMode="transform"),this._updateDisplayModeVisuals()}setSize(e){this._sizeMultiplier=Number(e)||1,this.update()}resetSize(){this.setSize(this._defaultSizeMultiplier)}setCamera(e,{resetSize:t=!1,refresh:n=!0}={}){e&&(this.camera=e),t&&(this._sizeMultiplier=this._defaultSizeMultiplier),n&&this.update()}setDomElement(e){if(this.domElement!==e){try{this.domElement?.removeEventListener("pointerdown",this._onPointerDown)}catch{}this.domElement=e||null,this.domElement&&this.domElement.addEventListener("pointerdown",this._onPointerDown,{passive:!1})}}attach(e){if(this.target=e||null,this.target){try{this.target.updateMatrixWorld(!0)}catch{}this.position.copy(this.target.getWorldPosition(new U)),this.quaternion.copy(this.target.getWorldQuaternion(new Mt)),this.updateMatrixWorld(!0);try{this.update()}catch{}}}detach(){this.target=null}update(){const e=this._computeGizmoScale()*(this._sizeMultiplier||1);if(this.gizmo.root.scale.setScalar(e),this.gizmo&&this.gizmo.labels){const t=this.camera.quaternion;for(const n of this.gizmo.labels)n.quaternion.copy(t)}}_buildGizmo(){const e=new sn;e.name="HybridXformGizmoRoot",e.userData.excludeFromFit=!0,e.renderOrder=this.renderOrder;const t={translate:e,rotate:e},n=new Wt({color:12566463,toneMapped:!1,depthTest:!1,depthWrite:!1,transparent:!0}),i=new Wt({color:15909198,toneMapped:!1,depthTest:!1,depthWrite:!1,transparent:!0}),s=new Wt({color:15900236,toneMapped:!1,depthTest:!1,depthWrite:!1,transparent:!0}),o=new Wt({color:15909198,toneMapped:!1,depthTest:!1,depthWrite:!1,transparent:!0}),a=new eo(.03,.03,1,16),c=new to(.12,.4,20),l=new js(.12,16,12),u=new js(.16,18,14),h=[],f=d((_,g,v)=>{const M=new sn;M.renderOrder=this.renderOrder,M.name=`Axis${_}`;const b=new yt(a,n);b.renderOrder=this.renderOrder,b.position.y=.5,M.add(b);const C=new yt(c,i);C.renderOrder=this.renderOrder,C.position.y=1+.125,C.userData.handle={kind:"translate",axis:_},M.add(C),_==="X"&&(M.rotation.z=-Math.PI/2),_==="Z"&&(M.rotation.x=-Math.PI/2);const S=this._makeTextSprite(`${_}C`,g);S.position.set(0,1.3,0),M.add(S),e.add(M),h.push({group:M,spr:S})},"addAxis");f("X","#ff6666"),f("Y","#7ddc6f"),f("Z","#6aa9ff");const p={},m=d(_=>{const g=new sn;g.name=`Rotate${_}`,g.renderOrder=this.renderOrder;const v=.9,M=new Qe().setFromPoints(Array.from({length:33},(x,E)=>{const w=E/32*(Math.PI/2);return new U(Math.cos(w)*v,Math.sin(w)*v,0)})),b=new It({color:14737632,linewidth:2,toneMapped:!1,depthTest:!1,depthWrite:!1,transparent:!0}),C=new Qn(M,b);C.renderOrder=this.renderOrder,g.add(C);const S=Math.PI/4,T=new yt(l,s);T.position.set(Math.cos(S)*v,Math.sin(S)*v,0),T.renderOrder=this.renderOrder,T.userData.handle={kind:"rotate",axis:_},g.add(T),_==="X"&&(g.rotation.y=Math.PI/2),_==="Y"&&(g.rotation.x=-Math.PI/2),e.add(g),p[_]={group:g,dot:T,radius:v}},"addRotate");m("Z"),m("Y"),m("X");const y=new yt(u,o);return y.name="DisplayModeToggle",y.renderOrder=this.renderOrder,y.userData.handle={kind:"toggle-display-mode"},e.add(y),{root:e,picker:t,labels:h.map(_=>_.spr),rot:p,translateGroups:h.map(_=>_.group),rotateGroups:Object.values(p).map(_=>_.group),center:y,centerMaterial:o}}_makeTextSprite(e,t="#ffffff"){const i=document.createElement("canvas");i.width=i.height=256;const s=i.getContext("2d");s.clearRect(0,0,256,256),s.fillStyle="rgba(0,0,0,0)",s.fillRect(0,0,256,256),s.font='bold 64px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',s.textAlign="center",s.textBaseline="middle",s.fillStyle=t,s.fillText(String(e||""),256/2,256/2);const o=new Vl(i);o.colorSpace=un;const a=new jr({map:o,transparent:!0,depthTest:!1,depthWrite:!1}),c=new oa(a);return c.scale.setScalar(.6),c.renderOrder=this.renderOrder,c}_computeGizmoScale(){const e=this.camera;if(e&&e.isOrthographicCamera)return 1/Math.max(1e-4,e.zoom||1);const t=this.getWorldPosition(this._tmpV),n=this.camera.getWorldPosition(this._tmpV2),i=t.distanceTo(n),s=Math.tan((this.camera.fov||50)*Math.PI/360)*2;return i*s/10}_setPointerFromEvent(e){const t=this.domElement.getBoundingClientRect(),n=(e.clientX-t.left)/t.width*2-1,i=-((e.clientY-t.top)/t.height)*2+1;this._pointer.set(n,i)}_intersections(e){this._raycaster.setFromCamera(this._pointer,this.camera);const t=this._raycaster.ray;return this.camera.isOrthographicCamera?t.origin.add(t.direction.clone().multiplyScalar(-1e3)):this.camera.isPerspectiveCamera&&t.origin.copy(this.camera.position),this._raycaster.intersectObject(e,!0)||[]}_handlePointerDown(e){if(!this.enabled||!this.visible||!this.target)return;this._setPointerFromEvent(e);const t=this.gizmo,n=t.picker[this.mode]||t.root,i=this._intersections(n),s=Array.isArray(i)?i.find(a=>a?.object?.userData?.handle):null;if(!s)return;const o=s.object.userData.handle;if(!(!o||!o.kind)){if(o.kind==="toggle-display-mode"){e.preventDefault(),e.stopPropagation?.(),this.toggleDisplayMode();return}e.preventDefault(),e.stopPropagation?.(),this._drag=this._drag||{},this._drag.handle=o;try{this.updateMatrixWorld(!0)}catch{}if(this._drag.startPos=this.getWorldPosition(new U),this._drag.startQuat=this.getWorldQuaternion(new Mt),this._drag.axis=this._axisWorld(o.axis),o.kind==="translate"){const a=this.camera.getWorldDirection(new U);this._plane.setFromNormalAndCoplanarPoint(a,this._drag.startPos)}else o.kind==="rotate"&&this._plane.setFromNormalAndCoplanarPoint(this._drag.axis,this._drag.startPos);if(this._drag.startPoint=this._planeIntersect(),!this._drag.startPoint){this._drag=null;return}if(o.kind==="rotate"){this._drag.prevPoint=this._drag.startPoint.clone();const a=this.gizmo&&this.gizmo.rot?this.gizmo.rot[o.axis]:null;this._drag.rotVis=a||null}this.dragging=!0,this.dispatchEvent({type:"dragging-changed",value:!0})}}_handlePointerMove(e){if(!this.dragging||!this._drag)return;this._setPointerFromEvent(e);const t=this._planeIntersect();if(!t)return;const{handle:n,startPos:i,axis:s,startPoint:o}=this._drag;if(n.kind==="translate"){const c=this._tmpV.copy(t).sub(o).dot(s),l=this._tmpV2.copy(i).add(this._tmpV.copy(s).multiplyScalar(c));this.target.position.copy(l)}else if(n.kind==="rotate"){const a=this._drag.prevPoint||o,c=this._tmpV.copy(a).sub(i).normalize(),l=this._tmpV2.copy(t).sub(i).normalize(),u=new U().crossVectors(c,l),h=Bn.clamp(c.dot(l),-1,1),f=Math.atan2(u.dot(s),h),p=this._axisWorld(n.axis),m=new Mt().setFromAxisAngle(p,f);this.target.quaternion.multiplyQuaternions(m,this.target.quaternion),this._drag.prevPoint=t.clone();try{const y=this._drag.rotVis;if(y&&y.dot&&y.group&&n.axis){const _=y.radius||.9,g=Math.PI/4;y.dot.position.set(Math.cos(g)*_,Math.sin(g)*_,0)}}catch{}}this.position.copy(this.target.position),this.quaternion.copy(this.target.quaternion),this.updateMatrixWorld(!0),this.dispatchEvent({type:"change"})}_handlePointerUp(e){this.dragging&&(this.dragging=!1,this._drag=null,this.dispatchEvent({type:"dragging-changed",value:!1}),this.dispatchEvent({type:"objectChange"}))}_axisWorld(e){return new U(e==="X"?1:0,e==="Y"?1:0,e==="Z"?1:0).applyQuaternion(this.quaternion).normalize()}_planeIntersect(){this._raycaster.setFromCamera(this._pointer,this.camera);const e=this._raycaster.ray;this.camera.isOrthographicCamera?e.origin.add(e.direction.clone().multiplyScalar(-1e3)):this.camera.isPerspectiveCamera&&e.origin.copy(this.camera.position);const t=new U;return this._raycaster.ray.intersectPlane(this._plane,t)?t.clone():null}_updateDisplayModeVisuals(){const e=this.gizmo||null;if(!e)return;const t=!this.dimensionToggleEnabled||this.displayMode==="transform";for(const n of e.translateGroups||[])n&&(n.visible=t);for(const n of e.rotateGroups||[])n&&(n.visible=t);e.center&&(e.center.visible=this.dimensionToggleEnabled),e.centerMaterial?.color&&e.centerMaterial.color.setHex(this.displayMode==="dimensions"?5164484:15909198)}};d($_,"CombinedTransformControls");let Ip=$_;function rR({ui:r,key:e,def:t,id:n,controlWrap:i}){const s=document.createElement("div");s.className="number-input-wrap";const o=document.createElement("input");o.type="text",o.id=n,o.className="input number-input",o.dataset.forceText="true";try{t&&(typeof t.step=="number"||typeof t.step=="string"&&t.step.trim()!=="")&&(o.dataset.step=String(t.step)),t&&(typeof t.min=="number"||typeof t.min=="string"&&t.min!=="")&&(o.dataset.min=String(t.min)),t&&(typeof t.max=="number"||typeof t.max=="string"&&t.max!=="")&&(o.dataset.max=String(t.max))}catch{}const a=document.createElement("div");a.className="number-stepper";const c=document.createElement("button");c.type="button",c.className="number-stepper-btn number-stepper-up",c.setAttribute("aria-label","Increment");const l=document.createElement("button");l.type="button",l.className="number-stepper-btn number-stepper-down",l.setAttribute("aria-label","Decrement"),a.appendChild(c),a.appendChild(l),s.appendChild(o),s.appendChild(a),i&&i.appendChild(s),r._setInputValue(o,t.type,r._pickInitialValue(e,t));const u=d(()=>{r.params[e]=o.value,r._emitParamsChange(e,o.value)},"commitValue");o.addEventListener("change",u),o.addEventListener("focus",()=>{o.select(),r._stopActiveReferenceSelection()});const h=/^\s*[-+]?((\d+(?:\.\d*)?)|(\.\d+))(?:[eE][-+]?\d+)?\s*$/,f=d(E=>{const w=o.dataset?o.dataset[E]:null;if(w==null||w==="")return null;const A=Number(w);return Number.isFinite(A)?A:null},"readLimit"),p=d(()=>{const E=o.dataset?o.dataset.step:null,w=Number(E);return!Number.isFinite(w)||w===0?1:Math.abs(w)},"readStep"),m=d(()=>{const E=String(o.value||"").trim();if(!E){const A=f("min");return Number.isFinite(A)?A:0}if(!h.test(E))return null;const w=Number(E);return Number.isFinite(w)?w:null},"readBase"),y=d((E,w={})=>{const{commit:A=!0,focus:R=!0}=w,P=m();if(P==null)return!1;const I=p();let N=P+E*I;const D=f("min"),L=f("max");return Number.isFinite(D)&&(N=Math.max(D,N)),Number.isFinite(L)&&(N=Math.min(L,N)),r._setInputValue(o,"number",N),A&&u(),R&&(o.focus(),o.select()),!0},"applyStep"),_=d(E=>{E.preventDefault()},"preventBlur"),g={delay:350,interval:80};let v=null,M=null,b=null,C=!1,S=!1;const T=d(()=>{v&&clearTimeout(v),M&&clearInterval(M),v=null,M=null,C&&(u(),C=!1),S&&(b&&clearTimeout(b),b=setTimeout(()=>{S=!1},200))},"stopRepeat"),x=d(E=>{if(T(),C=y(E,{commit:!1,focus:!0}),!!C)return v=setTimeout(()=>{M=setInterval(()=>{y(E,{commit:!1,focus:!1})&&(C=!0)},g.interval)},g.delay),window.addEventListener("pointerup",T,{once:!0}),window.addEventListener("pointercancel",T,{once:!0}),!0},"startRepeat");return c.addEventListener("pointerdown",E=>{_(E),S=!!x(1)}),l.addEventListener("pointerdown",E=>{_(E),S=!!x(-1)}),c.addEventListener("click",()=>{if(S){S=!1,b&&clearTimeout(b);return}y(1)}),l.addEventListener("click",()=>{if(S){S=!1,b&&clearTimeout(b);return}y(-1)}),{inputEl:o,activate(){o.focus()},readValue(){return o.value}}}d(rR,"renderNumberField");function oR({ui:r,key:e,def:t,id:n}){const i=document.createElement("textarea");if(i.id=n,i.className="input textarea",t&&t.rows!=null){const s=parseInt(t.rows,10);Number.isFinite(s)&&s>0&&(i.rows=s)}return t&&typeof t.placeholder=="string"&&(i.placeholder=t.placeholder),r._setInputValue(i,"string",r._pickInitialValue(e,t)),i.addEventListener("change",()=>{r.params[e]=i.value,r._emitParamsChange(e,i.value)}),{inputEl:i,activate(){i.focus()},readValue(){return i.value}}}d(oR,"renderTextareaField");function bn(r){if(r==null)return null;if(typeof r=="string"){const t=r.trim();if(!t)return null;try{const n=JSON.parse(t);if(n&&typeof n=="object"){const i=typeof n.name=="string"?n.name.trim():"";if(i)return i;const s=typeof n.id=="string"?n.id.trim():"";if(s)return s}}catch{}return t}if(typeof r=="object"){if(typeof r.name=="string"&&r.name.trim())return r.name.trim();if(typeof r.id=="string"&&r.id.trim())return r.id.trim();if(Array.isArray(r.path)){const t=r.path.filter(Boolean).map(String).join(" › ");if(t)return t}}return String(r).trim()||null}d(bn,"normalizeReferenceName");function li(r){if(!Array.isArray(r))return[];const e=new Set,t=[];for(const n of r){const i=bn(n);!i||e.has(i)||(e.add(i),t.push(i))}return t}d(li,"normalizeReferenceList");function sm({ui:r,key:e,def:t,id:n,controlWrap:i,valueAdapter:s=null}){const o=document.createElement("input");o.type="hidden",o.id=n;try{o.dataset.key=String(e)}catch{}try{o.__refSelectionDef=t}catch{}const a=!!t.multiple;a&&(o.dataset.multiple="true");const c=d(S=>{const T=Number(S);if(!Number.isFinite(T))return null;const x=Math.max(0,Math.floor(T));return x>=0?x:null},"parseBound"),l=a?c(t.minSelections):null;let u=a?c(t.maxSelections):null;a&&u!==null&&l!==null&&u<l&&(u=l),a&&l!==null&&(o.dataset.minSelections=String(l)),a&&u!==null&&(o.dataset.maxSelections=String(u));const h=typeof t.placeholder=="string"&&t.placeholder.trim()?t.placeholder.trim():"Click then select in scene…",f=s&&typeof s=="object"?s:null,p=d(()=>{if(f&&typeof f.read=="function")try{return f.read()}catch{return null}return r._pickInitialValue(e,t)},"readRawValue"),m=d(S=>{if(f&&typeof f.write=="function")try{f.write(S);return}catch{return}r.params[e]=S},"writeRawValue"),y=d(S=>{if(f&&typeof f.emit=="function")try{f.emit(S);return}catch{return}r._emitParamsChange(e,S)},"emitChange"),_=d(()=>{const S=p();if(Array.isArray(S))return li(S);const T=bn(S);return T?[T]:[]},"resolveCurrentSelectionNames"),g=d(()=>{const S=r?.options?.partHistory?.scene||r?.options?.viewer?.partHistory?.scene||r?.options?.viewer?.scene||null,T=_();if(!S||typeof S.getObjectByName!="function")return[];const x=[];for(const E of T){if(!E)continue;const w=S.getObjectByName(E);w&&x.push(w)}return x},"resolveCurrentSelectionObjects");o.__validateReferenceSelection=(S,T={})=>{const x=t?.selectionValidator;if(typeof x!="function")return{allowed:!0,message:null};const E=r?.params&&Object.prototype.hasOwnProperty.call(r.params,"featureID")?r.params.featureID:r?.params?.id??null,w={ui:r,key:e,def:t,id:n,inputEl:o,params:r?.params||null,featureID:E,viewer:r?.options?.viewer||null,partHistory:r?.options?.partHistory||r?.options?.viewer?.partHistory||null,currentValue:p(),currentSelectionNames:_(),currentSelections:g(),pointerEvent:T?.pointerEvent,pickMeta:T?.pickMeta||null};let A=!0;try{A=x(S,w)!==!1}catch(I){console.warn("[ReferenceSelection] selectionValidator threw; blocking selection.",I),A=!1}if(A)return{allowed:!0,message:null};let R=null;const P=t?.selectionValidationMessage;if(typeof P=="function")try{const I=P(S,w);typeof I=="string"&&I.trim()&&(R=I.trim())}catch{}else typeof P=="string"&&P.trim()&&(R=P.trim());return{allowed:!1,message:R||"Selection not allowed for this field."}};const v=document.createElement("div");v.className=a?"ref-multi-wrap":"ref-single-wrap";let M=null;const b=d(S=>{if(!a)return;const T=li(Array.isArray(S)?S:[]);try{o.dataset.selectedCount=String(T.length)}catch{}try{o.dataset.selectedValues=JSON.stringify(T)}catch{}},"updateSelectionMetadata");if(a&&(o.__getSelectionList=()=>{try{const S=p();return Array.isArray(S)?li(S):[]}catch{return[]}},o.__updateSelectionMetadata=b),a){M=document.createElement("div"),M.className="ref-chips",M.addEventListener("click",()=>r._activateReferenceSelection(o,t)),v.appendChild(M);try{const S=p(),T=li(Array.isArray(S)?S:[]);m(T),r._renderChips(M,e,T),b(T)}catch{}}else{const S=document.createElement("button");S.type="button",S.className="ref-single-display",S.title=h,S.dataset.placeholder=h;const T=document.createElement("span");T.className="ref-single-label",S.appendChild(T);const x=document.createElement("span");x.className="ref-chip-remove",x.role="button",x.tabIndex=0,x.title="Clear selection",x.textContent="✕";const E=d(R=>{R.stopPropagation(),R.preventDefault?.(),m(null),o.value="";try{o.__lastReferenceSelectionMeta=null}catch{}w(null),y(null);try{r._syncActiveReferenceSelectionHighlight(o,t)}catch{}},"clearSelection");x.addEventListener("click",E),x.addEventListener("keydown",R=>{(R.key==="Enter"||R.key===" ")&&E(R)}),S.appendChild(x);const w=d(R=>{const P=bn(R);T.textContent=P||h,x.style.visibility=P?"visible":"hidden"},"updateSingleDisplay"),A=bn(p());m(A),w(A),o.value=A??"",S.addEventListener("click",()=>r._activateReferenceSelection(o,t)),S.addEventListener("mouseenter",()=>{const R=bn(o.value||p());if(R)try{r._hoverReferenceSelectionItem?.(o,t,R)}catch{}}),S.addEventListener("mouseleave",()=>{try{r._clearReferenceSelectionHover?.(o)}catch{}}),v.appendChild(S),o.addEventListener("change",()=>{w(o.value);const R=bn(o.value);let P=R;try{const I=o.__lastReferenceSelectionMeta;if(I&&typeof I=="object"){const N=bn(I);if(N&&N===R){const D={...I,name:N};Array.isArray(D.pickPoint)&&D.pickPoint.length>=3?D.pickPoint=[Number(D.pickPoint[0])||0,Number(D.pickPoint[1])||0,Number(D.pickPoint[2])||0]:delete D.pickPoint,Number.isFinite(D.faceIndex)&&Number(D.faceIndex)>=0?D.faceIndex=Math.floor(Number(D.faceIndex)):delete D.faceIndex,P=D}else o.__lastReferenceSelectionMeta=null}}catch{}m(P),y(P);try{r._syncActiveReferenceSelectionHighlight(o,t)}catch{}})}return r._setInputValue(o,t.type,p()),o.addEventListener("change",()=>{const S=o.value;if(a){if(o.dataset&&o.dataset.forceClear==="true"){m([]),M&&(r._renderChips(M,e,[]),b([])),o.value="",delete o.dataset.forceClear,y(f?p():[]);return}let T=[],x=!1;try{const P=JSON.parse(S);Array.isArray(P)&&(T=P,x=!0)}catch{}!x&&S!=null&&String(S).trim()!==""&&(T=[String(S).trim()]);const E=p(),A=(Array.isArray(E)?E:[]).slice();for(const P of T){const I=bn(P);I&&(A.includes(I)||A.push(I))}const R=li(A);a&&u!==null&&R.length>u&&(R.length=u),m(R),M&&(r._renderChips(M,e,R),b(R)),o.value="",y(f?p():R)}else{const T=bn(S);o.value=T??"",m(T),y(T);try{r._syncActiveReferenceSelectionHighlight(o,t)}catch{}}}),v.appendChild(o),i.appendChild(v),{inputEl:o,activate:d(()=>r._activateReferenceSelection(o,t),"activate"),readValue(){const S=p();return Array.isArray(S)?li(S):bn(S)}}}d(sm,"renderReferenceSelectionField");function aR({ui:r,key:e,def:t,id:n,controlWrap:i,valueAdapter:s=null}){const o=document.createElement("input");o.type="hidden",o.id=n;const a=document.createElement("div");a.className="transform-wrap";const c=s&&typeof s=="object"?s:null,l=c&&typeof c.activationKey=="string"?c.activationKey:e,u=d(I=>im(I),"sanitizeTRS"),h=d(()=>{if(c&&typeof c.get=="function")try{return u(c.get())}catch{return u(null)}return u(r._pickInitialValue(e,t))},"readTRS"),f=d(I=>{const N=u(I);if(c&&typeof c.set=="function")try{c.set({position:N.position.slice(0,3),rotationEuler:N.rotationEuler.slice(0,3),scale:N.scale.slice(0,3),...N.reference?{reference:N.reference}:{}})}catch{}else{const D={position:N.position.slice(0,3),rotationEuler:N.rotationEuler.slice(0,3),scale:N.scale.slice(0,3)};N.reference&&(D.reference=N.reference),r.params[e]=D}return N},"writeTRS"),p=d(I=>{if(c&&typeof c.emit=="function")try{c.emit(I);return}catch{return}r._emitParamsChange(l,I)},"emitChange"),m=document.createElement("button");m.type="button",m.className="btn",m.textContent=String(t.label||"Position in 3D…");const y=document.createElement("div");y.className="transform-info";const _=d(I=>{const N=Number(I);if(!Number.isFinite(N))return"0";const D=Math.abs(N),L=D>=100?0:D>=10?1:2;return String(N.toFixed(L))},"fmt"),g=d((I=null)=>{const N=I?u(I):h(),D=Array.isArray(N.position)?N.position:[0,0,0],L=Array.isArray(N.rotationEuler)?N.rotationEuler:[0,0,0],H=Nr(N.reference);y.textContent=`pos(${_(D[0])}, ${_(D[1])}, ${_(D[2])}) rot(${_(L[0])}, ${_(L[1])}, ${_(L[2])})${H?` ref(${H})`:""}`},"updateInfo");g();const v=document.createElement("div");v.className="transform-modes";const M=d(()=>h(),"getTRS"),b=d((I,N=!0,D={})=>{const{skipWrite:L=!1}=D,H=L?u(I):f(I);try{g(H)}catch{}try{const O=r._fieldsWrap.querySelector(`[data-key="${e}"]`)||a,W=[[".tf-pos-x",H.position[0]],[".tf-pos-y",H.position[1]],[".tf-pos-z",H.position[2]],[".tf-rot-x",H.rotationEuler[0]],[".tf-rot-y",H.rotationEuler[1]],[".tf-rot-z",H.rotationEuler[2]]];for(const[G,Q]of W){const z=O?O.querySelector(G):null;z&&r._setInputValue(z,"number",Q)}}catch{}if(N)try{const X=r.activeTransform;if(X&&X.inputEl===o&&X.target){const O=X.baseTransform||{position:[0,0,0],quaternion:[0,0,0,1],scale:[1,1,1]},W=vb(O,H,An),G=new U,Q=new Mt,z=new U;W.decompose(G,Q,z),X.target.position.copy(G),X.target.quaternion.copy(Q),X.target.scale.copy(z)}}catch{}return H},"setTRS"),C=document.createElement("div");C.className="transform-grid";const S=d((I,N,D)=>{const L=document.createElement("div");L.className="transform-row";const H=document.createElement("div");H.className="transform-label",H.textContent=I;const X=document.createElement("div");X.className="transform-inputs";const O=["x","y","z"];for(let W=0;W<3;W++){const G=document.createElement("input");G.className=`input transform-input tf-${N}-${O[W]}`,G.type="number",G.step="any",r._setInputValue(G,"number",D[W]??0);const Q=/^-?\d*\.?\d*$/,z=d(q=>q===""||q==null?!0:Q.test(String(q)),"isNumericLikeLocal"),Z=d(q=>{try{z(q.value)?q.type="number":q.type="text"}catch{}},"onFocusToggleTypeLocal");G.addEventListener("focus",()=>{Z(G),r._stopActiveReferenceSelection()}),G.addEventListener("beforeinput",q=>{try{const Y=String(G.value||"")+String(q.data||"");z(Y)?G.type!=="number"&&(G.type="number"):G.type!=="text"&&(G.type="text")}catch{}}),G.addEventListener("change",()=>{const q=M(),Y=G.value;N==="pos"?q.position[W]=Y:q.rotationEuler[W]=Y;const K=b(q,!0);p(K)}),X.appendChild(G)}L.appendChild(H),L.appendChild(X),C.appendChild(L)},"addRow"),T=M();S("Position","pos",T.position),S("Rotation (deg)","rot",T.rotationEuler);const x=document.createElement("button");x.type="button",x.className="btn btn-slim",x.textContent="Reset",x.title="Reset translation and rotation to 0",x.addEventListener("click",()=>{const I=M(),N={position:[0,0,0],rotationEuler:[0,0,0],scale:I.scale};I.reference&&(N.reference=I.reference);const D=b(N,!0);p(D);const L=r.params&&Object.prototype.hasOwnProperty.call(r.params,"featureID")?r.params.featureID:r.params?.id??null;typeof r.options.onChange=="function"&&r.options.onChange(L)}),v.appendChild(x);let E=null,w=null;const A=d(()=>{const I=r?.activeTransform;if(!I||I.inputEl!==o||typeof w!="function")return;try{w()}catch{return}const N=d(()=>{try{w()}catch{}},"reopen");typeof queueMicrotask=="function"?queueMicrotask(N):setTimeout(N,0)},"restartActiveTransform");E=d(()=>{if(!c)return null;const I={};return typeof c.stepId=="string"&&(I.stepId=c.stepId),I.get=()=>{if(typeof c.get=="function")try{return u(c.get())}catch{return h()}return h()},I.set=N=>{const D=u(N);if(typeof c.set=="function"){try{c.set(D)}catch{}b(D,!0,{skipWrite:!0})}else b(D,!0);p(D)},typeof c.getBase=="function"&&(I.getBase=()=>{try{return c.getBase()}catch{return null}}),I},"buildTransformAdapter")(),w=d(()=>r._activateTransformWidget({inputEl:o,wrapEl:a,key:l,def:t,valueAdapter:E}),"activate"),m.addEventListener("click",w),a.appendChild(m);const P=document.createElement("div");if(P.className="transform-details",P.appendChild(v),Array.isArray(t.referenceSelectionFilter)&&t.referenceSelectionFilter.length){const I=document.createElement("div");I.className="transform-reference-section";const N=document.createElement("div");N.className="transform-label",N.textContent=String(t.referenceLabel||"Reference"),I.appendChild(N);const D=document.createElement("div");D.className="transform-reference-control",I.appendChild(D);const L=d((X,O={})=>{const{shouldEmit:W=!1,shouldRestart:G=!1}=O,z={...M()};X?z.reference=X:delete z.reference;const Z=b(z,!0);W&&p(Z),G&&A()},"applyReferenceValue"),H={read:d(()=>h().reference||null,"read"),write:d(X=>{const O=h().reference||null,W=Nr(O),G=Nr(X);if(typeof X=="string"&&O&&typeof O=="object"&&W&&W===G){L(O);return}L(X)},"write"),emit:d(X=>{const O=h().reference||null,W=Nr(O),G=Nr(X);if(typeof X=="string"&&O&&typeof O=="object"&&W&&W===G){L(O,{shouldEmit:!0,shouldRestart:!0});return}L(X,{shouldEmit:!0,shouldRestart:!0})},"emit")};sm({ui:r,key:`${e}.reference`,def:{type:"reference_selection",label:String(t.referenceLabel||"Reference"),placeholder:String(t.referencePlaceholder||"Click then select in scene…"),selectionFilter:t.referenceSelectionFilter.slice(),multiple:!1,selectionValidator:t.referenceSelectionValidator,selectionValidationMessage:t.referenceSelectionValidationMessage},id:`${n}__reference`,controlWrap:D,valueAdapter:H}),P.appendChild(I)}return P.appendChild(C),P.appendChild(y),a.appendChild(P),a.appendChild(o),i.appendChild(a),{inputEl:o,activate:w,readValue(){return h()}}}d(aR,"renderTransformField");function cR({ui:r,key:e,def:t,controlWrap:n}){!r.params[e]||typeof r.params[e]!="object"?r.params[e]={targets:[],operation:"NONE",overlapConditioningEnabled:!0}:(Array.isArray(r.params[e].targets)||(r.params[e].targets=[]),r.params[e].operation||(r.params[e].operation="NONE"),typeof r.params[e].overlapConditioningEnabled!="boolean"&&(r.params[e].overlapConditioningEnabled=!0));const i=document.createElement("div");i.className="bool-op-wrap";const s=document.createElement("select");s.className="select",s.dataset.role="bool-op";const o=Array.isArray(t.options)&&t.options.length?t.options:["NONE","UNION","SUBTRACT","INTERSECT"];for(const m of o){const y=document.createElement("option");y.value=String(m),y.textContent=String(m),s.appendChild(y)}s.value=String(r.params[e].operation||"NONE"),s.addEventListener("change",()=>{(!r.params[e]||typeof r.params[e]!="object")&&(r.params[e]={targets:[],operation:"NONE",overlapConditioningEnabled:!0});const m=String(s.value||"NONE").toUpperCase();if(r.params[e].operation=m,r._emitParamsChange(e,r.params[e]),m==="NONE")return;const y=d(()=>{try{p?.activate?.()}catch{}},"activateTargets");typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>y()):setTimeout(y,0)}),i.appendChild(s);const a=document.createElement("label");a.style.display="flex",a.style.alignItems="center",a.style.gap="8px",a.style.margin="8px 0 6px",a.style.color="var(--text-color, #e6edf3)",a.style.fontSize="12px";const c=document.createElement("input");c.type="checkbox",c.checked=r.params[e].overlapConditioningEnabled!==!1,c.addEventListener("change",()=>{(!r.params[e]||typeof r.params[e]!="object")&&(r.params[e]={targets:[],operation:"NONE",overlapConditioningEnabled:!0}),r.params[e].overlapConditioningEnabled=c.checked,r._emitParamsChange(e,r.params[e])});const l=document.createElement("span");l.textContent="Condition touching coplanar faces",a.appendChild(c),a.appendChild(l),i.appendChild(a);const u=document.createElement("div"),h={type:"reference_selection",multiple:!0,selectionFilter:["SOLID"]},f={read:d(()=>{const m=r.params[e];return!m||typeof m!="object"?[]:Array.isArray(m.targets)?m.targets:[]},"read"),write:d(m=>{(!r.params[e]||typeof r.params[e]!="object")&&(r.params[e]={targets:[],operation:s.value||"NONE",overlapConditioningEnabled:c.checked}),r.params[e].targets=Array.isArray(m)?m:[]},"write"),emit:d(()=>{r._emitParamsChange(e,r.params[e])},"emit")},p=sm({ui:r,key:e,def:h,id:`${e}-targets`,controlWrap:u,valueAdapter:f});return i.appendChild(u),n.appendChild(i),{inputEl:p.inputEl,activate:p.activate,readValue(){const m=r.params[e];return!m||typeof m!="object"?{targets:[],operation:"NONE",overlapConditioningEnabled:!0}:{targets:Array.isArray(m.targets)?m.targets.slice():[],operation:m.operation||"NONE",overlapConditioningEnabled:m.overlapConditioningEnabled!==!1}}}}d(cR,"renderBooleanOperationField");function lR({ui:r,key:e,def:t,id:n}){const i=document.createElement("input");return i.type="text",i.id=n,i.className="input",r._setInputValue(i,t.type,r._pickInitialValue(e,t)),i.addEventListener("change",()=>{r.params[e]=i.value,r._emitParamsChange(e,i.value),r._stopActiveReferenceSelection()}),{inputEl:i,activate(){i.focus()},readValue(){return i.value}}}d(lR,"renderStringField");function uR({ui:r,key:e,def:t,id:n}){const i=document.createElement("input");return i.type="checkbox",i.id=n,i.className="checkbox",r._setInputValue(i,"boolean",r._pickInitialValue(e,t)),i.addEventListener("change",()=>{const s=!!i.checked;r.params[e]=s,r._emitParamsChange(e,s),r._stopActiveReferenceSelection()}),{inputEl:i,activate(){i.focus()},readValue(){return!!i.checked}}}d(uR,"renderBooleanField");function hR({ui:r,key:e,def:t,id:n}){const i=document.createElement("select");i.id=n,i.className="select";const s=Array.isArray(t.options)?t.options:[];for(let o=0;o<s.length;o++){const a=s[o],c=document.createElement("option");c.value=String(a),c.textContent=String(a),i.appendChild(c)}return r._setInputValue(i,"options",r._pickInitialValue(e,t)),i.addEventListener("change",()=>{const o=i.value;r.params[e]=o,r._emitParamsChange(e,o),r._stopActiveReferenceSelection()}),{inputEl:i,activate(){i.focus()},readValue(){return i.value}}}d(hR,"renderOptionsField");function fR({ui:r,key:e,def:t}){const n=document.createElement("div");n.className="transform-grid";const i=!!(t&&t.uniformToggle===!0);let s=!!(t&&t.uniformDefault===!0),o=null;if(i){const g=document.createElement("div");g.className="transform-row";const v=document.createElement("div");v.className="transform-label",v.textContent="";const M=document.createElement("div");M.className="transform-inputs";const b=document.createElement("label");b.style.display="inline-flex",b.style.alignItems="center",b.style.gap="6px",o=document.createElement("input"),o.type="checkbox",o.checked=s;const C=document.createElement("span");C.textContent=String(t.uniformLockLabel||"Uniform"),b.appendChild(o),b.appendChild(C),M.appendChild(b),g.appendChild(v),g.appendChild(M),n.appendChild(g)}const a=d(g=>{const v=document.createElement("div");v.className="transform-row";const M=document.createElement("div");M.className="transform-label",M.textContent=g;const b=document.createElement("div");return b.className="transform-inputs",v.appendChild(M),v.appendChild(b),{rowEl:v,inputsWrap:b}},"mkRow"),{rowEl:c,inputsWrap:l}=a("XYZ");n.appendChild(c);const u=(()=>{const g=r._pickInitialValue(e,t);return Array.isArray(g)?[g[0]??0,g[1]??0,g[2]??0]:g&&typeof g=="object"?[g.x??0,g.y??0,g.z??0]:[0,0,0]})(),h=t&&t.step!=null?String(t.step):"any",f=d(()=>{const v=Array.from(l.querySelectorAll("input")).map(M=>M.value);r.params[e]=[v[0],v[1],v[2]],r._emitParamsChange(e,r.params[e])},"setParamFromInputs"),p=[],m=/^-?\d*\.?\d*$/,y=d(g=>g===""||g==null?!0:m.test(String(g)),"isNumericLike"),_=d(g=>{try{y(g.value)?g.type="number":g.type="text"}catch{}},"toggleTypeForContent");for(let g=0;g<3;g++){const v=document.createElement("input");v.type="number",v.className="input transform-input",v.step=h,r._setInputValue(v,"number",u[g]??0),v.addEventListener("focus",()=>_(v)),v.addEventListener("beforeinput",M=>{try{const b=String(v.value||"")+String(M.data||"");y(b)?v.type!=="number"&&(v.type="number"):v.type!=="text"&&(v.type="text")}catch{}}),v.addEventListener("change",()=>{if(i&&o&&o.checked){const M=v.value;for(const b of l.querySelectorAll("input"))b.value=M}f()}),l.appendChild(v),p.push(v)}if(i&&o){const g=d(()=>{if(o.checked&&p.length){const v=p[0].value;for(let M=0;M<p.length;M++)p[M].value=String(v);f()}},"enforceUniformNow");o.addEventListener("change",()=>g()),s&&g()}return{inputEl:n,activate(){const g=n.querySelector("input");g&&g.focus()},readValue(){const g=r.params[e];return Array.isArray(g)?g.slice(0,3):g&&typeof g=="object"?[g.x??0,g.y??0,g.z??0]:[0,0,0]}}}d(fR,"renderVec3Field");function dR({ui:r,key:e,def:t,id:n,controlWrap:i}){const s=document.createElement("button");s.type="button",s.id=n,s.className="btn",s.textContent=String(t.label||"Choose File…");const o=document.createElement("div");o.className="file-info";const a=r._pickInitialValue(e,t);if(typeof a=="string"&&a.startsWith("data:")&&a.includes(";base64,")){const l=a.split(",")[1]||"",u=Math.floor(l.length*3/4);o.textContent=`Loaded (${u} bytes)`}else a&&String(a).length?o.textContent=`Loaded (${String(a).length} chars)`:o.textContent="No file selected";const c=document.createElement("input");return c.type="file",c.style.display="none",t&&t.accept&&c.setAttribute("accept",String(t.accept)),s.addEventListener("click",l=>{l.preventDefault(),c.click()}),c.addEventListener("change",async()=>{const l=c.files&&c.files[0];if(l)try{const u=await l.arrayBuffer(),h=new Uint8Array(u);let f="";const p=32768;for(let g=0;g<h.length;g+=p){const v=h.subarray(g,g+p);f+=String.fromCharCode.apply(null,v)}const m=typeof btoa=="function"?btoa(f):typeof globalThis.Buffer<"u"?globalThis.Buffer.from(h).toString("base64"):"",_=`data:${l.type&&l.type.length?l.type:"application/octet-stream"};base64,${m}`;r.params[e]=_,o.textContent=`${l.name} (${h.length} bytes)`,r._emitParamsChange(e,_)}catch(u){o.textContent=`Failed to read file: ${u?.message||u}`}}),i.appendChild(o),i.appendChild(c),{inputEl:s,activate(){c.click()},readValue(){return r.params[e]??null}}}d(dR,"renderFileField");function pR({ui:r,key:e,def:t,id:n}){const i=document.createElement("input");return i.type="text",i.id=n,i.className="input",r._setInputValue(i,"string",r._pickInitialValue(e,t)),i.addEventListener("change",()=>{r.params[e]=i.value,r._emitParamsChange(e,i.value)}),{inputEl:i,activate(){i.focus()},readValue(){return i.value}}}d(pR,"renderDefaultField");function mR(r){const e={},t=String(r?.source||"").trim().toLowerCase(),n=String(r?.repoFull||"").trim(),i=String(r?.branch||"").trim(),s=String(r?.path||r?.name||"").trim();return(t==="github"||t==="local")&&(e.source=t),n&&(e.repoFull=n),i&&(e.branch=i),s&&(e.path=s),e}d(mR,"buildScope");function gR({title:r="Select Component"}={}){return new Promise(e=>{let t=null,n=!1;const i=document.createElement("div");i.className="component-selector-overlay";const s=document.createElement("section");s.className="component-selector-panel";const o=document.createElement("div");o.className="cs-header",o.textContent=r;const a=document.createElement("div");a.className="cs-body";const c=document.createElement("div");c.className="cs-browser-mount",a.appendChild(c);const l=document.createElement("div");l.className="cs-footer";const u=document.createElement("button");u.type="button",u.className="cs-btn",u.textContent="Cancel",l.appendChild(u),s.appendChild(o),s.appendChild(a),s.appendChild(l),i.appendChild(s),document.body.appendChild(i);const h=d(p=>{if(!n){n=!0;try{t?.destroy?.()}catch{}try{document.removeEventListener("keydown",f,!0)}catch{}try{document.body.removeChild(i)}catch{}e(p??null)}},"cleanup"),f=d(p=>{p.key==="Escape"&&(p.preventDefault(),p.stopPropagation(),h(null))},"onKeyDown");document.addEventListener("keydown",f,!0),u.addEventListener("click",()=>h(null)),i.addEventListener("click",p=>{p.target===i&&h(null)}),t=new Xb({container:c,onPickFile:d(async p=>{const m=String(p?.path||p?.name||"").trim();if(!m)return;const y=await qb(m,mR(p));if(!y||!y.data3mf)throw new Error("Failed to load selected component");h(y)},"onPickFile"),scrollBody:!0}),t.reload()})}d(gR,"openComponentSelectorModal");d((function(){if(typeof document>"u"||document.getElementById("component-selector-styles"))return;const e=document.createElement("style");e.id="component-selector-styles",e.textContent=`
|
|
4636
|
+
`)}finally{try{t&&typeof t.delete=="function"&&t.delete()}catch{}}}d(t2,"toSTL");async function n2(r,e="solid",t=6){if(typeof window<"u")throw new Error("writeSTL is only available in Node.js environments");const{writeFile:n}=await is(async()=>{const{writeFile:s}=await import("./__vite-browser-external-BIHI7g3E.js");return{writeFile:s}},[]),i=this.toSTL(e,t);return await n(r,i,"utf8"),r}d(n2,"writeSTL");function i2(r=void 0,e={}){const t=e&&typeof e=="object"?e:{},n=t.unit||"millimeter",i=Number.isFinite(t.precision)?t.precision:6,s=Number.isFinite(t.scale)?t.scale:1,o=t.applyWorldTransform!==!1,a=r||this?.name||"part",c={...t,name:a,unit:n,precision:i,scale:s,applyWorldTransform:o},{data:l}=e2([this],c);return l}d(i2,"toSTEP");async function s2(r,e=void 0,t={}){if(typeof window<"u")throw new Error("writeSTEP is only available in Node.js environments");const{writeFile:n}=await is(async()=>{const{writeFile:s}=await import("./__vite-browser-external-BIHI7g3E.js");return{writeFile:s}},[]),i=this.toSTEP(e,t);return await n(r,i,"utf8"),r}d(s2,"writeSTEP");function r2(){const r=this.getMesh();try{const e=r.vertProperties,t=r.triVerts;let n=0;for(let i=0;i<t.length;i+=3){const s=t[i]*3,o=t[i+1]*3,a=t[i+2]*3,c=e[s],l=e[s+1],u=e[s+2],h=e[o],f=e[o+1],p=e[o+2],m=e[a],y=e[a+1],_=e[a+2];n+=c*(f*_-p*y)-l*(h*_-p*m)+u*(h*y-f*m)}return Math.abs(n)/6}finally{try{r&&typeof r.delete=="function"&&r.delete()}catch{}}}d(r2,"volume");function o2(){const r=this.getMesh();try{const e=r.vertProperties,t=r.triVerts;let n=0;for(let i=0;i<t.length;i+=3){const s=t[i]*3,o=t[i+1]*3,a=t[i+2]*3,c=e[s],l=e[s+1],u=e[s+2],h=e[o],f=e[o+1],p=e[o+2],m=e[a],y=e[a+1],_=e[a+2];n+=bp(c,l,u,h,f,p,m,y,_)}return n}finally{try{r&&typeof r.delete=="function"&&r.delete()}catch{}}}d(o2,"surfaceArea");function a2(){const r=this.getMesh();try{return r.triVerts.length/3|0}finally{try{r&&typeof r.delete=="function"&&r.delete()}catch{}}}d(a2,"getTriangleCount");function c2(r={}){const e=[];for(let l=this.children.length-1;l>=0;l--){const u=this.children[l];if(this.remove(u),u?.userData?.filletDebug===!0){e.push(u);continue}u.geometry&&typeof u.geometry.dispose=="function"&&u.geometry.dispose();const h=u.material;h&&(Array.isArray(h)?h.forEach(f=>f&&f.dispose&&f.dispose()):typeof h.dispose=="function"&&h.dispose())}const{showEdges:t=!0,forceAuthoring:n=!1,authoringOnly:i=!1}=r;let s,o=!1;if(!n&&!i)try{s=this.getFaces(!1)}catch(l){console.warn("[Solid.visualize] getFaces failed, falling back to raw arrays:",l?.message||l),o=!0}else o=!0;if(o||!s){const l=this._vertProperties||[],u=this._triVerts||[],h=this._triIDs||[],f=d(y=>this._idToFaceName&&this._idToFaceName.get?this._idToFaceName.get(y):String(y),"nameOf"),p=new Map,m=u.length/3|0;for(let y=0;y<m;y++){const _=h[y],g=f(_);if(!g)continue;let v=p.get(g);v||(v=[],p.set(g,v));const M=u[y*3+0],b=u[y*3+1],C=u[y*3+2],S=[l[M*3+0],l[M*3+1],l[M*3+2]],T=[l[b*3+0],l[b*3+1],l[b*3+2]],x=[l[C*3+0],l[C*3+1],l[C*3+2]];v.push({faceName:g,indices:[M,b,C],p1:S,p2:T,p3:x})}s=[];for(const[y,_]of p.entries())s.push({faceName:y,triangles:_})}const a=new Map;for(const{faceName:l,triangles:u}of s){if(!u.length)continue;const h=new Float32Array(u.length*9);let f=0;for(let y=0;y<u.length;y++){const _=u[y],g=_.p1,v=_.p2,M=_.p3;h[f++]=g[0],h[f++]=g[1],h[f++]=g[2],h[f++]=v[0],h[f++]=v[1],h[f++]=v[2],h[f++]=M[0],h[f++]=M[1],h[f++]=M[2]}const p=new Qe;p.setAttribute("position",new mt(h,3)),p.computeVertexNormals(),p.computeBoundingBox(),p.computeBoundingSphere();const m=new Sp(p);m.name=l,m.userData.faceName=l,m.userData.__defaultMaterial=m.material;try{const y=typeof this.getFaceMetadata=="function"?this.getFaceMetadata(l):null;y&&typeof y=="object"&&(m.userData={...m.userData||{},...y})}catch{}m.parentSolid=this;try{m.owningFeatureID=this?.owningFeatureID||null}catch{}a.set(l,m),this.add(m)}if(t){if(!o){let l=[];try{l=this.getBoundaryEdgePolylines()||[]}catch{l=[]}if(!Array.isArray(l)||l.length===0)try{o=!0}catch{}for(const u of l){const h=new Float32Array(u.positions.length*3);let f=0;for(let g=0;g<u.positions.length;g++){const v=u.positions[g];h[f++]=v[0],h[f++]=v[1],h[f++]=v[2]}const p=new Ri;p.setPositions(Array.from(h));try{p.computeBoundingSphere()}catch{}const m=new Wo(p);m.name=u.name,m.closedLoop=!!u.closedLoop,m.userData={faceA:u.faceA,faceB:u.faceB,polylineLocal:u.positions,closedLoop:!!u.closedLoop},m.userData.__defaultMaterial=m.material,Yx(m,this),m.parentSolid=this;const y=a.get(u.faceA),_=a.get(u.faceB);y&&y.edges.push(m),_&&_.edges.push(m),y&&m.faces.push(y),_&&m.faces.push(_),this.add(m)}}if(o)try{const l=this._vertProperties||[],u=this._triVerts||[],h=this._triIDs||[],f=l.length/3|0,p=u.length/3|0,m=BigInt(Math.max(1,f)),y=d((b,C)=>{const S=BigInt(b),T=BigInt(C);return S<T?S*m+T:T*m+S},"ukey"),_=new Map;for(let b=0;b<p;b++){const C=h[b],S=b*3,T=u[S+0]>>>0,x=u[S+1]>>>0,E=u[S+2]>>>0,w=[[T,x],[x,E],[E,T]];for(let A=0;A<3;A++){const R=w[A][0],P=w[A][1],I=y(R,P);let N=_.get(I);N||(N=[],_.set(I,N)),N.push({id:C,a:R,b:P,tri:b})}}const g=d(b=>this._idToFaceName&&this._idToFaceName.get?this._idToFaceName.get(b):String(b),"nameOf"),v=new Map;for(const[,b]of _.entries()){if(b.length!==2)continue;const C=b[0],S=b[1];if(C.id===S.id)continue;const T=g(C.id),x=g(S.id),E=T<x?[T,x]:[x,T],w=JSON.stringify(E);let A=v.get(w);A||(A=[],v.set(w,A));const R=Math.min(C.a,C.b),P=Math.max(C.a,C.b);A.push([R,P])}const M=d((b,C,S)=>{const T=new Set,x=new Map,E=d((A,R)=>A<R?`${A},${R}`:`${R},${A}`,"ek");for(const[A,R]of S)x.has(A)||x.set(A,new Set),x.has(R)||x.set(R,new Set),x.get(A).add(R),x.get(R).add(A);const w=d(A=>[l[A*3+0],l[A*3+1],l[A*3+2]],"verts");for(const[A]of x.entries()){if([...x.get(A)].length!==1)continue;const R=[];let P=A,I=-1;for(;;){const N=[...x.get(P)];let D=N[0];if(D===I&&N.length>1&&(D=N[1]),D===void 0)break;const L=E(P,D);if(T.has(L)||(T.add(L),R.push(w(P)),I=P,P=D,!x.has(P)))break}if(R.push(w(P)),R.length>=2){const N=R.flat();if(N.some(W=>!isFinite(W))){console.error("Invalid coordinates detected in edge polyline:"),console.error("Poly coordinates:",R),console.error("Flat coordinates:",N),console.error("Face names:",b,"|",C);continue}const L=new Ri;L.setPositions(N);try{L.computeBoundingSphere()}catch{}const H=new Wo(L);H.name=`${b}|${C}`,H.closedLoop=!1,H.userData={faceA:b,faceB:C,polylineLocal:R,closedLoop:!1},H.userData.__defaultMaterial=H.material,Yx(H,this),H.parentSolid=this;const X=a.get(b),O=a.get(C);X&&X.edges.push(H),O&&O.edges.push(H),X&&H.faces.push(X),O&&H.faces.push(O);try{H.computeLineDistances()}catch{}this.add(H)}}},"addPolyline");for(const[b,C]of v.entries()){const[S,T]=JSON.parse(b);M(S,T,C)}}catch{}}try{if(Array.isArray(this._auxEdges)&&this._auxEdges.length)for(const l of this._auxEdges){const u=Array.isArray(l?.points)?l.points.filter(y=>Array.isArray(y)&&y.length===3):[];if(u.length<2)continue;const h=[];for(const y of u)h.push(y[0],y[1],y[2]);if(l?.closedLoop&&u.length>=2){const y=u[0],_=u[u.length-1],g=_[0]-y[0],v=_[1]-y[1],M=_[2]-y[2];(g!==0||v!==0||M!==0)&&h.push(y[0],y[1],y[2])}if(h.some(y=>!isFinite(y))){console.error("Invalid coordinates in auxiliary edge:",l?.name||"CENTERLINE"),console.error("Points:",u),console.error("Flat coordinates:",h);continue}const p=new Ri;p.setPositions(h);try{p.computeBoundingSphere()}catch{}const m=new Wo(p);m.name=l?.name||"CENTERLINE",m.closedLoop=!!l?.closedLoop,m.userData={...m.userData||{},polylineLocal:u,polylineWorld:!!l?.polylineWorld,centerline:!!l?.centerline,auxEdge:!0},m.parentSolid=this;try{const y=(l?.materialKey||"OVERLAY").toUpperCase(),_=Kt?.EDGE||{},g=_[y]||(y==="OVERLAY"?_.OVERLAY:null)||_.BASE;let v=g;if(g&&y!=="BASE"&&!(g.depthTest===!1&&g.depthWrite===!1)){const C=Object.values(_).includes(g);let S=!1;if(C&&typeof g.clone=="function"){try{v=g.clone(),S=!!v&&v!==g}catch{v=g,S=!1}if(S)try{g.resolution&&v.resolution&&typeof v.resolution.copy=="function"&&v.resolution.copy(g.resolution)}catch{}}if((S||!C)&&v){try{v.depthTest=!1}catch{}try{v.depthWrite=!1}catch{}}}v&&(m.material=v),v&&Zt.setBaseMaterial(m,v,{force:!1});try{m.computeLineDistances()}catch{}m.renderOrder=10020}catch{}m.userData||(m.userData={}),m.userData.__defaultMaterial=m.material,this.add(m)}}catch{}const c=d((l,u)=>!u||u.length===0?`VERTEX(${l[0]},${l[1]},${l[2]})`:`VERTEX[${[...u].sort().join("+")}]`,"generateVertexName");try{const l=new Map,u=new Map,h=new Set;for(const f of this.children){if(!f||f.type!=="EDGE")continue;const p=f.userData&&Array.isArray(f.userData.polylineLocal)?f.userData.polylineLocal:null;if(!p||p.length===0)continue;const m=f.name||"UNNAMED_EDGE",y=p[0],_=p[p.length-1],g=d(v=>{if(!v||v.length!==3)return;const M=`${v[0]},${v[1]},${v[2]}`;l.has(M)||l.set(M,v),u.has(M)||u.set(M,new Set),u.get(M).add(m)},"addEP");g(y),g(_)}if(l.size)for(const[f,p]of l.entries())try{const m=u.get(f);let y=c(p,m?Array.from(m):[]);if(h.has(y)){let _=1;for(;h.has(`${y}[${_}]`);)_++;y=`${y}[${_}]`}h.add(y),this.add(new vp(p,{name:y}))}catch{}}catch{}if(e.length)for(let l=e.length-1;l>=0;l--){const u=e[l];u&&this.add(u)}return this}d(c2,"visualize");function Yx(r,e){if(!r||!e)return;const t=r.name||null;if(!t)return;let n=null;try{n=typeof e.getEdgeMetadata=="function"?e.getEdgeMetadata(t):null}catch{n=null}n&&typeof n=="object"&&(r.userData={...r.userData||{},...n});const i=r.userData?.sheetMetalEdgeType;if(!(i&&i!=="AMBIGUOUS"))try{const s=Array.isArray(r.faces)?r.faces:[],o=new Set;let a=!1,c=!1;for(const l of s){const u=l2(l);u&&(a=!0),Bf(u)&&(o.add(u),c=!0)}if(!o.size&&r.userData){const l=[];r.userData.faceA&&l.push(r.userData.faceA),r.userData.faceB&&l.push(r.userData.faceB);for(const u of l){const f=(typeof e.getFaceMetadata=="function"?e.getFaceMetadata(u):null)?.sheetMetalFaceType;f&&(a=!0),Bf(f)&&(o.add(f),c=!0)}}if(o.size>=1){const l=[...o][0];r.userData={...r.userData||{},sheetMetalEdgeType:l},e&&typeof e.setEdgeMetadata=="function"&&e.setEdgeMetadata(t,{...e.getEdgeMetadata(t)||{},sheetMetalEdgeType:l})}else{const l=typeof t=="string"?t.split("|"):[];let u=null;for(const h of l){const p=(e&&typeof e.getFaceMetadata=="function"?e.getFaceMetadata(h):null)?.sheetMetalFaceType;if(p&&(a=!0),Bf(p)){c=!0,u=p;break}}u?(r.userData={...r.userData||{},sheetMetalEdgeType:u},e&&typeof e.setEdgeMetadata=="function"&&e.setEdgeMetadata(t,{...e.getEdgeMetadata(t)||{},sheetMetalEdgeType:u})):a&&c&&console.warn("[visualize] Edge has mixed or missing sheet metal face types",{edge:t,faceTypes:Array.from(o),faces:s.map(h=>h?.name||h?.userData?.faceName||"UNKNOWN")})}}catch{}}d(Yx,"annotateEdgeFromMetadata");function Ap(r){const e=String(r||"").trim().toUpperCase();return e==="A"||e==="B"?e:null}d(Ap,"normalizeSheetSurfaceType");function Bf(r){return Ap(r)!=null}d(Bf,"isSheetSurfaceType");function l2(r){if(!r||typeof r!="object")return null;const e=Ap(r?.userData?.sheetMetalFaceType);if(e)return e;const t=r?.parentSolid||r?.parent||null,n=r?.name||r?.userData?.faceName||null;if(!t||!n||typeof t.getFaceMetadata!="function")return null;try{return Ap(t.getFaceMetadata(n)?.sheetMetalFaceType)}catch{return null}}d(l2,"resolveSheetTypeFromFace");function Mb(r,{edgeNames:e,edges:t}={}){const n=[],i=Array.isArray(e)?Array.from(new Set(e.map(String))):[];if(i.length)for(const a of r?.children||[])a&&a.type==="EDGE"&&i.includes(a.name)&&(a.parentSolid===r||a.parent===r)&&n.push(a);if(Array.isArray(t))for(const a of t)a&&(a.parentSolid===r||a.parent===r)&&n.push(a);const s=[],o=new Set;for(const a of n)a&&!o.has(a)&&(o.add(a),s.push(a));return s}d(Mb,"resolveEdgesFromInputs");const u2=new U,h2=new U,f2=new U,d2=new U,p2=new U,m2=new U,jp=new U,Qp=new U,em=new U,g2=new U,wb=new U,_2=new U,Eb=new U;function y2(r,e=1e-12){return Math.max(e,e*Math.abs(r))}d(y2,"getScaleAdaptiveTolerance");function XR(r){return Math.max(1e-9,1e-6*Math.abs(r))}d(XR,"getDistanceTolerance");function qR(){return 1e-6}d(qR,"getAngleTolerance");const W_=class W_{constructor(e,t=null){if(this.triangleData=e||[],this.grid=new Map,!!this.triangleData.length){if(t==null){const n=this.triangleData.reduce((i,s)=>i+(s.rad||0),0)/this.triangleData.length;t=Math.max(n*2,1e-6)}this.cellSize=t,this.invCellSize=1/t;for(let n=0;n<this.triangleData.length;n++)for(const i of this.getTriangleCells(this.triangleData[n]))this.grid.has(i)||this.grid.set(i,[]),this.grid.get(i).push(n)}}cellKey(e,t,n){const i=Math.floor(e*this.invCellSize),s=Math.floor(t*this.invCellSize),o=Math.floor(n*this.invCellSize);return`${i},${s},${o}`}getTriangleCells({cx:e,cy:t,cz:n,rad:i}){const s=new Set,o=(e-i)*this.invCellSize,a=(e+i)*this.invCellSize,c=(t-i)*this.invCellSize,l=(t+i)*this.invCellSize,u=(n-i)*this.invCellSize,h=(n+i)*this.invCellSize;for(let f=Math.floor(o);f<=Math.floor(a);f++)for(let p=Math.floor(c);p<=Math.floor(l);p++)for(let m=Math.floor(u);m<=Math.floor(h);m++)s.add(`${f},${p},${m}`);return s}getNearbyTriangles(e,t=1/0){const n=this.cellKey(e.x,e.y,e.z),i=this.grid.get(n)||[];if(t===1/0||i.length)return i;const s=Math.ceil(t*this.invCellSize),o=Math.floor(e.x*this.invCellSize),a=Math.floor(e.y*this.invCellSize),c=Math.floor(e.z*this.invCellSize),l=new Set;for(let u=o-s;u<=o+s;u++)for(let h=a-s;h<=a+s;h++)for(let f=c-s;f<=c+s;f++){const p=this.grid.get(`${u},${h},${f}`);if(p)for(const m of p)l.add(m)}return Array.from(l)}};d(W_,"TriangleSpatialIndex");let Tp=W_;const Pr=new Map,Bu=new Map,x2=100;function rr(r,e=null){if(!Array.isArray(r)||r.length===0)return[];const t=e||r,n=Pr.get(t);if(n)return n;if(Pr.size>=x2){const h=Pr.keys().next().value;Pr.delete(h),Bu.delete(h)}const i=jp,s=Qp,o=em,a=g2,c=wb,l=_2,u=r.map(h=>{i.set(h.p1[0],h.p1[1],h.p1[2]),s.set(h.p2[0],h.p2[1],h.p2[2]),o.set(h.p3[0],h.p3[1],h.p3[2]);const f=(i.x+s.x+o.x)/3,p=(i.y+s.y+o.y)/3,m=(i.z+s.z+o.z)/3;a.subVectors(s,i),c.subVectors(o,i),l.crossVectors(a,c);const y=l.length();if(y<y2(1,1e-14))return null;l.multiplyScalar(1/y);const _=i.x-f,g=i.y-p,v=i.z-m,M=s.x-f,b=s.y-p,C=s.z-m,S=o.x-f,T=o.y-p,x=o.z-m,E=_*_+g*g+v*v,w=M*M+b*b+C*C,A=S*S+T*T+x*x,R=Math.sqrt(Math.max(E,w,A));return{cx:f,cy:p,cz:m,rad:R,normal:l.clone(),triangle:h}}).filter(Boolean);return Pr.set(t,u),u}d(rr,"getCachedFaceDataForTris");function tm(r,e=null){const t=e||r;let n=Bu.get(t);return!n&&Array.isArray(r)&&r.length&&(n=new Tp(r),Bu.set(t,n)),n}d(tm,"getCachedSpatialIndex");function YR(){Pr.clear(),Bu.clear()}d(YR,"clearFilletCaches");function ZR(r,e,t){return Math.max(e,Math.min(t,r))}d(ZR,"clamp");function KR(r){return Number.isFinite(r.x)&&Number.isFinite(r.y)&&Number.isFinite(r.z)}d(KR,"isFiniteVec3");function No(r,e,t,n,i){const s=u2.subVectors(t,e),o=h2.subVectors(n,e),a=f2.subVectors(r,e),c=s.dot(a),l=o.dot(a);if(c<=0&&l<=0)return i.copy(e),i;const u=d2.subVectors(r,t),h=s.dot(u),f=o.dot(u);if(h>=0&&f<=h)return i.copy(t),i;if(c*f-h*l<=0&&c>=0&&h<=0){const S=c/(c-h);return i.copy(e).addScaledVector(s,S),i}const m=p2.subVectors(r,n),y=s.dot(m),_=o.dot(m);if(_>=0&&y<=_)return i.copy(n),i;if(y*l-c*_<=0&&l>=0&&_<=0){const S=l/(l-_);return i.copy(e).addScaledVector(o,S),i}if(h*_-y*f<=0&&f-h>=0&&y-_>=0){const S=(f-h)/(f-h+(y-_));return i.copy(t).addScaledVector(m2.subVectors(n,t),S),i}const M=1/(s.dot(s)*o.dot(o)-Math.pow(s.dot(o),2)),b=(o.dot(o)*s.dot(a)-s.dot(o)*o.dot(a))*M,C=(s.dot(s)*o.dot(a)-s.dot(o)*s.dot(a))*M;return i.copy(e).addScaledVector(s,b).addScaledVector(o,C),i}d(No,"closestPointOnTriangleToOut");function v2(r,e,t=null,n=null){if(!Array.isArray(r)||r.length===0)return e.clone();const i=t&&Array.isArray(t)?t:rr(r,n);if(!i||!i.length)return e.clone();const s=tm(i,n);let o=null;const a=jp,c=Qp,l=em,u=Eb;if(s){const h=s.getNearbyTriangles(e);if(h.length){for(const f of h){if(f>=i.length)continue;const p=i[f].triangle;a.set(p.p1[0],p.p1[1],p.p1[2]),c.set(p.p2[0],p.p2[1],p.p2[2]),l.set(p.p3[0],p.p3[1],p.p3[2]),No(e,a,c,l,u);const m=u.distanceToSquared(e);(!o||m<o.d2)&&(o={d2:m,q:u.clone()})}if(o&&i.length>64){const f=Math.sqrt(o.d2),p=new Set(h);for(let m=0;m<i.length;m++){if(p.has(m))continue;const y=i[m],_=y.cx-e.x,g=y.cy-e.y,v=y.cz-e.z,M=_*_+g*g+v*v,b=y.rad||0,C=f+b;if(M>C*C)continue;const S=y.triangle;a.set(S.p1[0],S.p1[1],S.p1[2]),c.set(S.p2[0],S.p2[1],S.p2[2]),l.set(S.p3[0],S.p3[1],S.p3[2]),No(e,a,c,l,u);const T=u.distanceToSquared(e);T<o.d2&&(o={d2:T,q:u.clone()})}}}else{const f=i.map((m,y)=>({i:y,d2:(m.cx-e.x)**2+(m.cy-e.y)**2+(m.cz-e.z)**2}));f.sort((m,y)=>m.d2-y.d2);const p=Math.min(16,f.length);for(let m=0;m<p;m++){const y=i[f[m].i].triangle;a.set(y.p1[0],y.p1[1],y.p1[2]),c.set(y.p2[0],y.p2[1],y.p2[2]),l.set(y.p3[0],y.p3[1],y.p3[2]),No(e,a,c,l,u);const _=u.distanceToSquared(e);(!o||_<o.d2)&&(o={d2:_,q:u.clone()})}}}else{const h=Math.min(16,i.length),f=i.map((p,m)=>({i:m,d2:(p.cx-e.x)**2+(p.cy-e.y)**2+(p.cz-e.z)**2}));f.sort((p,m)=>p.d2-m.d2);for(let p=0;p<h;p++){const m=i[f[p].i].triangle;a.set(m.p1[0],m.p1[1],m.p1[2]),c.set(m.p2[0],m.p2[1],m.p2[2]),l.set(m.p3[0],m.p3[1],m.p3[2]),No(e,a,c,l,u);const y=u.distanceToSquared(e);(!o||y<o.d2)&&(o={d2:y,q:u.clone()})}}return o?o.q:e.clone()}d(v2,"projectPointOntoFaceTriangles");function JR(r,e,t=null,n=null){if(!Array.isArray(e)||!e.length)return[];if(!Array.isArray(r)||!r.length)return e.map(a=>a.clone());const i=t&&Array.isArray(t)?t:rr(r,n),s=tm(i,n),o=new Array(e.length);if(s){const a=new Map,c=s.invCellSize;for(let l=0;l<e.length;l++){const u=e[l],h=`${Math.floor(u.x*c)},${Math.floor(u.y*c)},${Math.floor(u.z*c)}`;let f=a.get(h);f||(f=[],a.set(h,f)),f.push(l)}for(const[l,u]of a.entries()){const[h,f,p]=l.split(",").map(Number),m=[];for(let _=-1;_<=1;_++)for(let g=-1;g<=1;g++)for(let v=-1;v<=1;v++){const M=`${h+_},${f+g},${p+v}`,b=s.grid.get(M);if(b)for(const C of b)m.push(C)}const y=Array.from(new Set(m));for(const _ of u){const g=e[_];let v=null;const M=jp,b=Qp,C=em,S=Eb;for(const T of y){const x=i[T];if(!x)continue;const E=x.triangle;M.set(E.p1[0],E.p1[1],E.p1[2]),b.set(E.p2[0],E.p2[1],E.p2[2]),C.set(E.p3[0],E.p3[1],E.p3[2]),No(g,M,b,C,S);const w=S.distanceToSquared(g);(!v||w<v.d2)&&(v={d2:w,q:S.clone()})}o[_]=v?v.q:g.clone()}}}else for(let a=0;a<e.length;a++)o[a]=v2(r,e[a],i,n);return o}d(JR,"batchProjectPointsOntoFace");function zu(r,e){const t=r.getFace(e);if(!t||!t.length)return new U(0,1,0);const n=new U,i=new U,s=new U,o=new U,a=new U,c=new U;for(const l of t)i.set(l.p1[0],l.p1[1],l.p1[2]),s.set(l.p2[0],l.p2[1],l.p2[2]),o.set(l.p3[0],l.p3[1],l.p3[2]),a.subVectors(s,i),c.subVectors(o,i),n.add(a.clone().cross(c));return n.lengthSq()===0?new U(0,1,0):n.normalize()}d(zu,"averageFaceNormalObjectSpace");function ku(r,e,t,n=null,i=null){const s=t&&typeof t.x=="number"?t:wb.set(t?.[0]||0,t?.[1]||0,t?.[2]||0);let o=Array.isArray(n)&&n.length?n:null;if(!o){const h=r?.getFace?r.getFace(e):null;if(!Array.isArray(h)||h.length===0)return null;o=rr(h,i||e)}if(!o||!o.length)return null;const a=tm(o,i||e||null);let c=null,l=1/0;const u=d(h=>{const f=o[h];if(!f)return;const p=s.x-f.cx,m=s.y-f.cy,y=s.z-f.cz,_=Math.abs(f.normal.x*p+f.normal.y*m+f.normal.z*y);_<l&&(l=_,c=f.normal)},"evalIdx");if(a){const h=Number.isFinite(a.cellSize)?a.cellSize*1.5:1/0,f=a.getNearbyTriangles(s,h);if(Array.isArray(f))for(const p of f)u(p)}if(!c){const h=Math.min(16,o.length),f=[];for(let p=0;p<o.length;p++){const m=o[p];if(!m)continue;const y=s.x-m.cx,_=s.y-m.cy,g=s.z-m.cz,v=y*y+_*_+g*g;f.length<h?(f.push({idx:p,d2:v}),f.length===h&&f.sort((M,b)=>M.d2-b.d2)):v<f[f.length-1].d2&&(f[f.length-1]={idx:p,d2:v},f.sort((M,b)=>M.d2-b.d2))}for(const p of f)u(p.idx)}return c||null}d(ku,"localFaceNormalAtPoint");function jR(r,e=1e-5){if(!Array.isArray(r)||r.length===0||e!==1e-5)return e;let t=1/0,n=1/0,i=1/0,s=-1/0,o=-1/0,a=-1/0;const c=[];for(const m of r)for(let y=0;y<m.length;y++){const _=m[y];if(_[0]<t&&(t=_[0]),_[0]>s&&(s=_[0]),_[1]<n&&(n=_[1]),_[1]>o&&(o=_[1]),_[2]<i&&(i=_[2]),_[2]>a&&(a=_[2]),y>0){const g=m[y-1],v=g[0]-_[0],M=g[1]-_[1],b=g[2]-_[2];c.push(Math.hypot(v,M,b))}}const l=s-t,u=o-n,h=a-i,f=Math.hypot(l,u,h)||1;c.sort((m,y)=>m-y);const p=c.length?c[c.length>>1]:f;return Math.min(Math.max(1e-5,f*.001),p*.1)}d(jR,"deriveTolerance");function b2(r){const e=r||1e-5;return{q:d(i=>[Math.round(i[0]/e)*e,Math.round(i[1]/e)*e,Math.round(i[2]/e)*e],"q"),k:d(i=>`${i[0]},${i[1]},${i[2]}`,"k")}}d(b2,"createQuantizer");function S2(r){if(!r)return null;const e=r._triVerts,t=r._vertProperties;if(!e||!t||typeof e.length!="number"||typeof t.length!="number")return null;const n=e.length/3|0;if(n===0||t.length<9)return null;let i=1/0,s=1/0,o=1/0,a=-1/0,c=-1/0,l=-1/0;for(let m=0;m<t.length;m+=3){const y=t[m],_=t[m+1],g=t[m+2];y<i&&(i=y),y>a&&(a=y),_<s&&(s=_),_>c&&(c=_),g<o&&(o=g),g>l&&(l=g)}const h=1e-6*(Math.hypot(a-i,c-s,l-o)||1),f=d((m,y,_,g,v,M,b,C,S,T,x,E,w,A,R)=>{const I=T-b,N=x-C,D=E-S,L=w-b,H=A-C,X=R-S,O=v*X-M*H,W=M*L-g*X,G=g*H-v*L,Q=I*O+N*W+D*G;if(Math.abs(Q)<1e-12)return null;const z=1/Q,Z=m-b,q=y-C,Y=_-S,K=(Z*O+q*W+Y*G)*z;if(K<-1e-12||K>1+1e-12)return null;const le=q*D-Y*N,ae=Y*I-Z*D,me=Z*N-q*I,ve=(g*le+v*ae+M*me)*z;if(ve<-1e-12||K+ve>1+1e-12)return null;const he=(L*le+H*ae+X*me)*z;return he>1e-10?he:null},"rayTri"),p=[[1,0,0],[0,1,0],[0,0,1]];return m=>{if(!m||!Number.isFinite(m.x)||!Number.isFinite(m.y)||!Number.isFinite(m.z))return!1;const y=m.x,_=m.y,g=m.z;let v=0;for(let M=0;M<p.length;M++){const b=p[M],C=y+(M+1)*h,S=_+(M+2)*h,T=g+(M+3)*h;let x=0;for(let E=0;E<n;E++){const w=E*3,A=(e[w+0]>>>0)*3,R=(e[w+1]>>>0)*3,P=(e[w+2]>>>0)*3;f(C,S,T,b[0],b[1],b[2],t[A+0],t[A+1],t[A+2],t[R+0],t[R+1],t[R+2],t[P+0],t[P+1],t[P+2])!==null&&x++}x%2===1&&v++}return v>=2}}d(S2,"buildPointInsideTester");const Zx=new Set;function Vs(r,e="face_name_mutation",t=!1){const n=String(r||"").trim();if(n&&t){const i=`${e}:${n}`;if(Zx.has(i))return;Zx.add(i)}}d(Vs,"breakOnFaceNameMutation");function M2(r){const e=new Map;let t=r?._faceIndex||null;return n=>{if(!r||typeof r.getFace!="function"||!n)return[];const i=r?._faceIndex||null;if(i!==t&&(e.clear(),t=i),e.has(n))return e.get(n);const s=r.getFace(n),o=Array.isArray(s)?s:[],a=r?._faceIndex||null;return a!==t&&(e.clear(),t=a),e.set(n,o),o}}d(M2,"createFaceTrianglesAccessor");function Ab(r){if(!r||typeof r.getFaceNames!="function")return[];const e=r.getFaceNames(),t=[];for(const n of e){if(typeof n!="string")continue;const i=typeof r.getFaceMetadata=="function"?r.getFaceMetadata(n):{};if(i&&(i.filletRoundFace||i.filletSourceArea||i.filletEndCap)){t.push(n);continue}(n.includes("_END_CAP")||n.includes("_CapStart")||n.includes("_CapEnd")||n.includes("_WEDGE_A")||n.includes("_WEDGE_B"))&&t.push(n)}return t}d(Ab,"getFilletMergeCandidateNames");function Tb(r,e){const t=r&&typeof r.getFaceNames=="function"?r.getFaceNames():[],n=t.find(i=>typeof i=="string"&&i.includes("_TUBE_Outer"));if(n)return n;if(e){const i=`${e}_TUBE_Outer`;return t.includes(i),i}return null}d(Tb,"guessRoundFaceName");function Cb(r,e=1e-5){const t=Array.isArray(r?._vertProperties)?r._vertProperties:null;if(!t||t.length<6)return e;let n=1/0,i=1/0,s=1/0,o=-1/0,a=-1/0,c=-1/0;for(let p=0;p<t.length;p+=3){const m=t[p+0],y=t[p+1],_=t[p+2];m<n&&(n=m),m>o&&(o=m),y<i&&(i=y),y>a&&(a=y),_<s&&(s=_),_>c&&(c=_)}const l=o-n,u=a-i,h=c-s,f=Math.hypot(l,u,h)||1;return Math.max(e,f*1e-6)}d(Cb,"deriveSolidToleranceFromVerts");function w2(r){const e=String(r||"AUTO").toUpperCase();return e==="INSET"||e==="OUTSET"||e==="AUTO"?e:"AUTO"}d(w2,"normalizeFilletDirectionMode");function Us(r,e){return!r||!e?NaN:Math.hypot(r.x-e.x,r.y-e.y,r.z-e.z)}d(Us,"distPoint3");function ns(r,e,t){if(!Array.isArray(r)||!e)return;const n=Number(e.x),i=Number(e.y),s=Number(e.z);if(!(!Number.isFinite(n)||!Number.isFinite(i)||!Number.isFinite(s))){for(const o of r){const a=n-o.x,c=i-o.y,l=s-o.z;if(a*a+c*c+l*l<=t)return}r.push({x:n,y:i,z:s})}}d(ns,"pushUniquePoint3");function Ib(r){const e=r?.faces?.[0]?.name||r?.userData?.faceA||null,t=r?.faces?.[1]?.name||r?.userData?.faceB||null;return{faceAName:e,faceBName:t}}d(Ib,"getEdgeFaceNames");function Rb(r){const e=r?.userData?.polylineLocal;return!Array.isArray(e)||e.length<2?null:e}d(Rb,"getEdgePolylineLocal");function E2(r,e){if(!Array.isArray(r)||r.length<2)return null;const t=Math.max(0,Math.min(1,Number(e))),n=r.length-1,i=t*n,s=Math.min(n-1,Math.floor(i)),o=i-s,a=r[s],c=r[s+1];return!Array.isArray(a)||!Array.isArray(c)||a.length<3||c.length<3?null:[a[0]+(c[0]-a[0])*o,a[1]+(c[1]-a[1])*o,a[2]+(c[2]-a[2])*o]}d(E2,"samplePolylineAt");function ht(r){if(Array.isArray(r)&&r.length>=3){const e=Number(r[0]),t=Number(r[1]),n=Number(r[2]);return Number.isFinite(e)&&Number.isFinite(t)&&Number.isFinite(n)?{x:e,y:t,z:n}:null}if(r&&typeof r=="object"){const e=Number(r.x),t=Number(r.y),n=Number(r.z);if(Number.isFinite(e)&&Number.isFinite(t)&&Number.isFinite(n))return{x:e,y:t,z:n}}return null}d(ht,"toPoint3Object");function Da(r,e){const t=ht(r),n=ht(e);if(!t||!n)return 1/0;const i=t.x-n.x,s=t.y-n.y,o=t.z-n.z;return i*i+s*s+o*o}d(Da,"point3DistanceSq");function Kx(r,e,t){const n=Math.hypot(r,e,t);return n>1e-12?[r/n,e/n,t/n]:null}d(Kx,"normalizePoint3Vector");function Jx(r,e,t=1e-6){if(!r||typeof r.getFace!="function"||!e)return[];const n=r.getFace(e);if(!Array.isArray(n)||n.length===0)return[];const i=[],s=Math.max(1e-16,Math.abs(Number(t)||0)**2);for(const o of n){const a=ht(o?.p1),c=ht(o?.p2),l=ht(o?.p3);a&&ns(i,a,s),c&&ns(i,c,s),l&&ns(i,l,s)}return i}d(Jx,"collectFaceUniquePoints");function jx(r){const e=Array.isArray(r)?r:[];if(e.length===0)return null;let t=0,n=0,i=0,s=0;for(const o of e){const a=ht(o);a&&(t+=a.x,n+=a.y,i+=a.z,s+=1)}return s>0?{x:t/s,y:n/s,z:i/s}:null}d(jx,"centroidOfPointSet");function Qx(r,e){const t=ht(e),n=Array.isArray(r)?r:[];if(!t||n.length===0)return NaN;const i=[];for(const s of n){const o=ht(s);if(!o)continue;const a=Math.hypot(o.x-t.x,o.y-t.y,o.z-t.z);a>1e-12&&i.push(a)}return i.length===0?NaN:(i.sort((s,o)=>s-o),i[i.length/2|0])}d(Qx,"estimatePointSetRadius");function A2(r){if(!r)return[];if(Array.isArray(r.edgePathPoints)&&r.edgePathPoints.length>=2)return r.edgePathPoints.map(ht).filter(Boolean);const e=Array.isArray(r.edgePolyline)?r.edgePolyline:null;if(e&&e.length>=2)return e.map(ht).filter(Boolean);const t=r.edgeObj;if(t&&typeof t.points=="function")try{const n=t.points(!1);if(Array.isArray(n)&&n.length>=2)return n.map(ht).filter(Boolean)}catch{}return[]}d(A2,"resolveEntryPathPoints");function ev(r){const e=A2(r);return e.length<2?null:{pathPoints:e,start:e[0],end:e[e.length-1]}}d(ev,"resolveEntryEndpoints");function tv(r,e,t=1e-10){const n=Array.isArray(r)?r:[];if(n.length<2)return null;const i=Math.max(1e-20,t*t);if((e|0)===0){const o=ht(n[0]);if(!o)return null;for(let a=1;a<n.length;a++){const c=ht(n[a]);if(c&&!(Da(o,c)<=i))return Kx(c.x-o.x,c.y-o.y,c.z-o.z)}return null}const s=ht(n[n.length-1]);if(!s)return null;for(let o=n.length-2;o>=0;o--){const a=ht(n[o]);if(a&&!(Da(s,a)<=i))return Kx(a.x-s.x,a.y-s.y,a.z-s.z)}return null}d(tv,"tangentAwayFromEndpoint");function Pb(r,e,t=1e-5){const n=ev(r),i=ev(e);if(!n||!i)return null;const s=[n.start,n.end],o=[i.start,i.end],a=Math.max(1e-20,t*t);let c=null;for(let m=0;m<s.length;m++)for(let y=0;y<o.length;y++){const _=s[m],g=o[y],v=Da(_,g);v<=a&&(!c||v<c.d2)&&(c={aEndIndex:m,bEndIndex:y,d2:v,pa:_,pb:g})}if(!c)return null;const l={x:(c.pa.x+c.pb.x)*.5,y:(c.pa.y+c.pb.y)*.5,z:(c.pa.z+c.pb.z)*.5},u=tv(n.pathPoints,c.aEndIndex,t*1e-4),h=tv(i.pathPoints,c.bEndIndex,t*1e-4);let f=NaN;Array.isArray(u)&&Array.isArray(h)&&(f=u[0]*h[0]+u[1]*h[1]+u[2]*h[2]);const p=Number.isFinite(f)?Math.min(1,Math.abs(f)):NaN;return{sharedPoint:l,aEndIndex:c.aEndIndex,bEndIndex:c.bEndIndex,distance:Math.sqrt(c.d2),tangentA:u,tangentB:h,tangentDot:f,absTangentDot:p}}d(Pb,"resolveSharedEndpointInfo");function T2(r){if(!r)return[];const e=Array.isArray(r.centerlinePathPoints)?r.centerlinePathPoints:Array.isArray(r.centerline)?r.centerline:null;return e&&e.length>=2?e.map(ht).filter(Boolean):[]}d(T2,"resolveEntryCenterlinePoints");function Vu(r,e,t=3,n=1e-10){const i=T2(r);if(i.length<2)return{endpoint:null,segments:[]};const s=(e|0)===0,o=[],a=Math.max(1e-20,Math.abs(Number(n)||0)**2),c=Math.max(1,Math.floor(Number(t)||1))+1;if(s)for(let u=0;u<i.length&&o.length<c;u++){const h=ht(i[u]);h&&(o.length>0&&Da(o[o.length-1],h)<=a||o.push(h))}else for(let u=i.length-1;u>=0&&o.length<c;u--){const h=ht(i[u]);h&&(o.length>0&&Da(o[o.length-1],h)<=a||o.push(h))}const l=[];for(let u=0;u<o.length-1;u++)l.push({a:o[u],b:o[u+1],index:u});return{endpoint:o[0]||null,segments:l}}d(Vu,"resolveCenterlineCornerSegments");function C2(r,e,t,n){const i=ht(r),s=ht(e),o=ht(t),a=ht(n);if(!i||!s||!o||!a)return null;const c=s.x-i.x,l=s.y-i.y,u=s.z-i.z,h=a.x-o.x,f=a.y-o.y,p=a.z-o.z,m=i.x-o.x,y=i.y-o.y,_=i.z-o.z,g=c*c+l*l+u*u,v=c*h+l*f+u*p,M=h*h+f*f+p*p,b=c*m+l*y+u*_,C=h*m+f*y+p*_,S=g*M-v*v,T=1e-14;let x,E=S,w,A=S;if(g<=T&&M<=T)return{distance:Us(i,o),s:0,t:0,pointA:i,pointB:o};g<=T?(x=0,E=1,w=C,A=M):M<=T?(w=0,A=1,x=-b,E=g):(x=v*C-M*b,w=g*C-v*b,x<0?(x=0,w=C,A=M):x>E&&(x=E,w=C+v,A=M)),w<0?(w=0,-b<0?x=0:-b>g?x=E:(x=-b,E=g)):w>A&&(w=A,-b+v<0?x=0:-b+v>g?x=E:(x=-b+v,E=g));const R=Math.abs(x)<=T?0:x/(Math.abs(E)<=T?1:E),P=Math.abs(w)<=T?0:w/(Math.abs(A)<=T?1:A),I=Math.max(0,Math.min(1,R)),N=Math.max(0,Math.min(1,P)),D={x:i.x+I*c,y:i.y+I*l,z:i.z+I*u},L={x:o.x+N*h,y:o.y+N*f,z:o.z+N*p};return{distance:Us(D,L),s:I,t:N,pointA:D,pointB:L}}d(C2,"closestPointsBetweenSegments3D");function I2(r,e,t,n={}){const i=t||{},s=Math.max(1e-10,Math.abs(Number(n.endpointTol)||0)),o=Math.max(s,Math.abs(Number(n.crossTolerance)||0)),a=Math.max(1e-4,Math.min(.2,Math.abs(Number(n.interiorParamEps)||.02))),c=Math.max(1,Math.floor(Number(n.maxSegments)||3)),l=Vu(r,i.aEndIndex,c,s*.001),u=Vu(e,i.bEndIndex,c,s*.001),h=Array.isArray(l?.segments)?l.segments:[],f=Array.isArray(u?.segments)?u.segments:[];if(h.length===0||f.length===0)return{crosses:!1,reason:"missing_centerline_segments",minDistance:1/0};let p=null;for(const m of h)for(const y of f){const _=C2(m?.a,m?.b,y?.a,y?.b);if(!(!_||!Number.isFinite(_.distance))&&((!p||_.distance<p.distance)&&(p={..._,segAIndex:Number(m?.index)||0,segBIndex:Number(y?.index)||0}),!(_.distance>o)&&!(_.s<=a||_.s>=1-a)&&!(_.t<=a||_.t>=1-a)))return{crosses:!0,reason:"interior_segment_cross",minDistance:_.distance,segAIndex:Number(m?.index)||0,segBIndex:Number(y?.index)||0,pointA:_.pointA,pointB:_.pointB}}return{crosses:!1,reason:"no_cross",minDistance:p?p.distance:1/0,segAIndex:p?p.segAIndex:null,segBIndex:p?p.segBIndex:null,pointA:p?p.pointA:null,pointB:p?p.pointB:null}}d(I2,"detectCenterlineCrossNearSharedCorner");function nv(r,e,t=1e-6){const n=r?.filletName;if(!n||typeof n!="string")return null;const i=(e|0)===0,s=`${n}_END_CAP_${i?1:2}`,o=`${n}_TUBE_${i?"CapStart":"CapEnd"}`,a=Jx(r?.wedgeSolid,s,t),c=i?r?.tubeCapPointsBeforeNudge?.start:r?.tubeCapPointsBeforeNudge?.end,l=Array.isArray(c)?c.map(ht).filter(Boolean):[],u=Jx(r?.tubeSolid,o,t),h=l.length>=3?l:u;return{wedgeFaceName:s,tubeFaceName:o,wedgePoints:a,tubePoints:h,tubePointsBeforeNudge:l,tubePointsAfterNudge:u,wedgeCenter:jx(a),tubeCenter:jx(h)}}d(nv,"resolveEntryEndCapData");function iv(r,e,t,n=1e-5,i=8){if(!Array.isArray(r)||r.length<2||!e||typeof e._fromManifold!="function")return null;const s=[],o=Math.max(1e-16,(Math.abs(Number(n)||1e-5)*.01)**2);for(const f of r){const p=ht(f);p&&ns(s,p,o)}if(s.length<2)return null;const a=Math.max(1e-6,Math.abs(Number(n)||0)),c=Math.max(6,Math.floor(Number(i)||8));let l=null,u=null;const h=[];try{l=Fi.sphere(a,c);for(const p of s)h.push(l.translate([p.x,p.y,p.z]));if(h.length===1?u=h[0]:u=Fi.hull(h),!u)return null;Vs(t||"CORNER_WEDGE_BRIDGE","createHullSolidFromPoints._fromManifold");const f=e._fromManifold(u,new Map([[0,t||"CORNER_WEDGE_BRIDGE"]]));try{f.name=t||"CORNER_WEDGE_BRIDGE"}catch{}return f}catch{if(u)try{typeof u.delete=="function"&&u.delete()}catch{}return null}finally{if(l)try{typeof l.delete=="function"&&l.delete()}catch{}for(const f of h)if(!(!f||f===u))try{typeof f.delete=="function"&&f.delete()}catch{}}}d(iv,"createHullSolidFromPoints");function R2(r,e=null){if(!r)return[];const t=typeof r.getFaceNames=="function"?r.getFaceNames():[],n=new Set((Array.isArray(t)?t:[]).filter(a=>typeof a=="string"&&a.length>0));if(n.size===0)return[];const i=[],s=d(a=>{!a||!n.has(a)||i.includes(a)||i.push(a)},"addCandidate"),o=typeof e=="string"&&e.length>0?e:null;o&&(s(`${o}_CapStart`),s(`${o}_CapEnd`),s(`${o}_END_CAP_1`),s(`${o}_END_CAP_2`));for(const a of n)(/_CapStart$/.test(a)||/_CapEnd$/.test(a)||/_END_CAP_[12]$/.test(a))&&s(a);return i}d(R2,"collectBridgeEndCapFaceNames");function sv(r,e=null,t=.001){if(!r||typeof r.pushFace!="function")return 0;const n=R2(r,e);if(n.length===0)return 0;const i=Number.isFinite(Number(t))?Number(t):.001;let s=0;for(const o of n)try{r.pushFace(o,i,{warnMissing:!1}),s+=1}catch{}return s}d(sv,"nudgeBridgeEndCapsOutward");function Gr(r=""){const e=String(r??"");let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}d(Gr,"stableStringHash32");function Hs(r,e="TOKEN"){const t=String(r??"").trim();return t&&t.replace(/\[\d+\]$/g,"").replace(/[^A-Za-z0-9]+/g,"_").replace(/^_+|_+$/g,"").replace(/_+/g,"_")||e}d(Hs,"sanitizeFaceNameToken");function Fa(r,e="EDGE"){const t=typeof r?.edgeObj?.name=="string"&&r.edgeObj.name.trim().length>0?r.edgeObj.name.trim():null;if(t)return t;const n=typeof r?.edgeName=="string"&&r.edgeName.trim().length>0?r.edgeName.trim():null;return n||(typeof r?.filletName=="string"&&r.filletName.trim().length>0?r.filletName.trim():"")||e}d(Fa,"resolveBridgeEntryEdgeName");function P2(r,e="FILLET"){const t=Fa(r,`${e}_EDGE`),n=Hs(t,"EDGE"),i=n.length>48?n.slice(0,48):n,s=Gr(t).toString(16).slice(-8).padStart(8,"0");return`${e}_FILLET_SIDEWALL_${i}_${s}`}d(P2,"buildEdgeDerivedSideWallFaceName");function N2(r,e=1e-5){const t=new Map,n=(Array.isArray(r)?r:[]).filter(i=>!!i&&!!i.edgeObj&&!!i.filletSolid&&!i.cornerBridge);for(const i of n)t.set(i,{start:!1,end:!1});for(let i=0;i<n.length;i++)for(let s=i+1;s<n.length;s++){const o=n[i],a=n[s],c=Pb(o,a,e);if(!c)continue;const l=t.get(o),u=t.get(a);l&&((c.aEndIndex|0)===0?l.start=!0:l.end=!0),u&&((c.bEndIndex|0)===0?u.start=!0:u.end=!0)}return t}d(N2,"computeFilletEntryEndpointAdjacency");function D2({entry:r=null,featureID:e="FILLET",includeStartCap:t=!1,includeEndCap:n=!1}={}){const i=r?.filletSolid,s=r?.filletName;if(!i||typeof i.getFaceNames!="function"||typeof i.renameFace!="function")return{mergedFaceName:null,mergedCount:0,mergedFaces:[]};if(!s||typeof s!="string")return{mergedFaceName:null,mergedCount:0,mergedFaces:[]};const o=i.getFaceNames(),a=new Set((Array.isArray(o)?o:[]).filter(m=>typeof m=="string")),c=[`${s}_SURFACE_CA`,`${s}_SURFACE_CB`,`${s}_FACE_A`,`${s}_FACE_B`,`${s}_WEDGE_A`,`${s}_WEDGE_B`,`${s}_SIDE_A`,`${s}_SIDE_B`];t&&c.push(`${s}_END_CAP_1`),n&&c.push(`${s}_END_CAP_2`);const l=c.filter(m=>a.has(m));if(l.length===0)return{mergedFaceName:null,mergedCount:0,mergedFaces:[]};const u=`${s}_TUBE_Outer`,h=a.has(u)?u:P2(r,e);a.has(h)&&!l.includes(h)&&l.unshift(h);const f=[];for(const m of l)!m||m===h||(Vs(h,"mergeEntrySideWallFaces.target",!0),Vs(m,"mergeEntrySideWallFaces.source"),i.renameFace(m,h),f.push(m));const p=Fa(r,`${e}_EDGE`);return i.setFaceMetadata(h,{filletMergedSideWall:!0,filletSideWall:!0,filletSideWallEdge:p,filletSideWallIncludesStartCap:!!t,filletSideWallIncludesEndCap:!!n}),{mergedFaceName:h,mergedCount:f.length+(a.has(h)?0:1),mergedFaces:f}}d(D2,"mergeEntrySideWallFaces");function F2({entries:r=[],featureID:e="FILLET",endpointTol:t=1e-5,debug:n=!1}={}){const i=(Array.isArray(r)?r:[]).filter(c=>!!c&&!!c.edgeObj&&!!c.filletSolid&&!c.cornerBridge);if(i.length===0)return{processedEntries:0,mergedEntries:0,mergedFaces:0};const s=N2(i,t);let o=0,a=0;for(const c of i){const l=s.get(c)||{start:!1,end:!1},u=D2({entry:c,featureID:e,includeStartCap:!!l.start,includeEndCap:!!l.end});u?.mergedFaceName&&(o+=1,a+=Number(u.mergedFaces?.length||0),c.sideWallFaceName=u.mergedFaceName,c.sideWallMergedFaces=Array.isArray(u.mergedFaces)?u.mergedFaces.slice():[],c.sideWallAdjacency={start:!!l.start,end:!!l.end},Array.isArray(c.mergeCandidates)&&!c.mergeCandidates.includes(u.mergedFaceName)&&c.mergeCandidates.push(u.mergedFaceName),n&&console.log("[Solid.fillet] Merged fillet side-wall faces.",{featureID:e,filletName:c.filletName,edge:Fa(c,null),sideWallFaceName:u.mergedFaceName,mergedFaces:u.mergedFaces,includeStartCap:!!l.start,includeEndCap:!!l.end}))}return{processedEntries:i.length,mergedEntries:o,mergedFaces:a}}d(F2,"mergeFilletEntrySideWallsByEdge");function L2(r,e,t,n="BRIDGE"){const i=String(e??"EDGE_A"),s=String(t??"EDGE_B"),o=[i,s].sort((p,m)=>p.localeCompare(m)),c=String(r??"FILLET").trim()||"FILLET",l=Hs(o[0],"EDGE_A"),u=Hs(o[1],"EDGE_B"),h=Gr(`${o[0]}|${o[1]}`).toString(16).padStart(8,"0"),f=Hs(n,"BRIDGE");return`${c}_${f}_${l}__${u}_${h}`}d(L2,"buildDeterministicBridgeName");function O2(r,e="FILLET_CORNER_BRIDGE"){if(!r)return null;const t=Array.isArray(r?._triVerts)?r._triVerts:null;if(!t||t.length<9)return null;const n=t.length/3|0,i=typeof e=="string"&&e.length>0?e:"FILLET_CORNER_BRIDGE",s=0,o={};if(r._faceMetadata instanceof Map&&r._faceMetadata.size>0)for(const a of r._faceMetadata.values())!a||typeof a!="object"||Object.assign(o,a);try{r._manifold&&typeof r._manifold.delete=="function"&&r._manifold.delete()}catch{}return Vs(i,"collapseSolidToSingleFaceName.unified"),r._manifold=null,r._triIDs=new Array(n).fill(s),r._idToFaceName=new Map([[s,i]]),r._faceNameToID=new Map([[i,s]]),r._faceMetadata=new Map([[i,o]]),r._faceIndex=null,r._dirty=!0,r}d(O2,"collapseSolidToSingleFaceName");function U2({solid:r=null,sourceFaceName:e="",desiredNames:t=[],anchorPoints:n=[]}={}){if(!r||typeof e!="string"||e.length===0)return{componentCount:0,names:[]};const i=Array.isArray(r?._triVerts)?r._triVerts:null,s=Array.isArray(r?._vertProperties)?r._vertProperties:null,o=Array.isArray(r?._triIDs)?r._triIDs:null,a=r?._faceNameToID instanceof Map?r._faceNameToID:null,c=r?._idToFaceName instanceof Map?r._idToFaceName:null;if(!i||!s||!o||!a||!c)return{componentCount:0,names:[]};const l=a.get(e);if(l===void 0)return{componentCount:0,names:[]};const u=Math.min(o.length,i.length/3|0);if(u<=0)return{componentCount:0,names:[]};const h=[];for(let A=0;A<u;A++)o[A]>>>0===l>>>0&&h.push(A);if(h.length===0)return{componentCount:0,names:[]};const f=d((A,R)=>A<R?`${A}|${R}`:`${R}|${A}`,"edgeKey"),p=new Map,m=new Map;for(const A of h)m.set(A,[]);for(const A of h){const R=A*3,P=i[R+0]>>>0,I=i[R+1]>>>0,N=i[R+2]>>>0,D=[[P,I],[I,N],[N,P]];for(const[L,H]of D){const X=f(L,H);let O=p.get(X);O||(O=[],p.set(X,O)),O.push(A)}}for(const A of p.values())if(!(!Array.isArray(A)||A.length<2))for(let R=0;R<A.length;R++)for(let P=R+1;P<A.length;P++){const I=A[R],N=A[P];!m.has(I)||!m.has(N)||(m.get(I).push(N),m.get(N).push(I))}const y=new Set,_=[],g=d((A=0,R=0,P=0)=>({x:A,y:R,z:P}),"toPoint"),v=d(A=>{const R=A*3,P=(i[R+0]>>>0)*3,I=(i[R+1]>>>0)*3,N=(i[R+2]>>>0)*3,D=Number(s[P+0])||0,L=Number(s[P+1])||0,H=Number(s[P+2])||0,X=Number(s[I+0])||0,O=Number(s[I+1])||0,W=Number(s[I+2])||0,G=Number(s[N+0])||0,Q=Number(s[N+1])||0,z=Number(s[N+2])||0;return g((D+X+G)/3,(L+O+Q)/3,(H+W+z)/3)},"triCentroid");for(const A of h){if(y.has(A))continue;const R=[A];y.add(A);const P=[];let I=A,N=0,D=0,L=0,H=0;for(;R.length>0;){const X=R.pop();P.push(X),X<I&&(I=X);const O=v(X);N+=O.x,D+=O.y,L+=O.z,H+=1;const W=m.get(X)||[];for(const G of W)y.has(G)||(y.add(G),R.push(G))}_.push({tris:P,minTri:I,center:H>0?g(N/H,D/H,L/H):g(0,0,0)})}if(_.length===0)return{componentCount:0,names:[]};_.sort((A,R)=>A.minTri-R.minTri);const M=(Array.isArray(n)?n:[]).map(A=>ht(A)).filter(Boolean);let b=Array.isArray(t)?t.map(A=>typeof A=="string"?A.trim():"").filter(A=>A.length>0):[];if(_.length===2&&b.length>=2&&M.length>=2){const A=_[0].center,R=_[1].center,P=M[0],I=M[1],N=(Us(A,P)||0)+(Us(R,I)||0),D=(Us(A,I)||0)+(Us(R,P)||0);Number.isFinite(D)&&D<N&&(b=[b[1],b[0],...b.slice(2)])}const C=new Set(a.keys());C.delete(e);const S=d((A,R)=>{const P=`${e}_PART_${R+1}`,I=typeof A=="string"&&A.length>0?A:P;let N=I,D=2;for(;C.has(N);)N=`${I}_${D}`,D+=1;return C.add(N),N},"makeUniqueName"),T=_.map((A,R)=>S(b[R],R));if(_.length===1){if(T[0]!==e){if(Vs(T[0],"relabelDisconnectedFaceComponents.single_component"),a.delete(e),a.set(T[0],l),c.set(l,T[0]),r._faceMetadata instanceof Map){const A=r._faceMetadata.get(e);A!==void 0&&r._faceMetadata.set(T[0],A),r._faceMetadata.delete(e)}r._faceIndex=null,r._dirty=!0}return{componentCount:1,names:T}}let x=0;for(const A of c.keys()){const R=Number(A);Number.isFinite(R)&&R>=x&&(x=R+1)}for(let A=0;A<u;A++){const R=Number(o[A]);Number.isFinite(R)&&R>=x&&(x=R+1)}const E=r._faceMetadata instanceof Map?r._faceMetadata:null,w=E?E.get(e):void 0;Vs(T[0],"relabelDisconnectedFaceComponents.primary_component"),a.delete(e),a.set(T[0],l),c.set(l,T[0]),E&&(w!==void 0&&E.set(T[0],w),E.delete(e));for(let A=1;A<_.length;A++){const R=_[A];for(;c.has(x);)x+=1;const P=x;x+=1;for(const I of R.tris)o[I]=P>>>0;Vs(T[A],"relabelDisconnectedFaceComponents.additional_component"),c.set(P,T[A]),a.set(T[A],P),E&&w!==void 0&&(w&&typeof w=="object"?E.set(T[A],{...w}):E.set(T[A],w))}return r._triIDs=o,r._faceNameToID=a,r._idToFaceName=c,r._faceIndex=null,r._dirty=!0,{componentCount:_.length,names:T}}d(U2,"relabelDisconnectedFaceComponents");function B2({filletEntries:r=[],featureID:e="FILLET",radius:t=1,resolution:n=32,SolidClass:i=null,TubeClass:s=null,debug:o=!1}={}){const a=Array.isArray(r)?r:[];if(!a.length||!i||typeof i._fromManifold!="function")return[];const c=Math.abs(Number(t)||0),l=Math.max(1e-6,c*1e-4),u=Math.max(1e-7,l*.5),h=.995,{q:f,k:p}=b2(Math.max(l,1e-6)),m=[],y=new Set;for(let _=0;_<a.length;_++){const g=a[_];if(!(!g||!g.filletSolid||!g.wedgeSolid||!g.tubeSolid))for(let v=_+1;v<a.length;v++){const M=a[v];if(!M||!M.filletSolid||!M.wedgeSolid||!M.tubeSolid)continue;const b=String(g?.edgeDirection||"INSET").toUpperCase(),C=String(M?.edgeDirection||"INSET").toUpperCase();if(b!==C)continue;const S=Pb(g,M,l);if(!S||Number.isFinite(S.absTangentDot)&&S.absTangentDot>=h)continue;const T=Fa(g,`${e}_EDGE_${_}`),x=Fa(M,`${e}_EDGE_${v}`),E=`${[T,x].sort().join("|")}:${p(f([S.sharedPoint.x,S.sharedPoint.y,S.sharedPoint.z]))}`;if(y.has(E))continue;y.add(E);const w=nv(g,S.aEndIndex,u),A=nv(M,S.bEndIndex,u);if(!w||!A||w.wedgePoints.length<3||A.wedgePoints.length<3)continue;const R=Vu(g,S.aEndIndex,4,u),P=Vu(M,S.bEndIndex,4,u),I=ht(R?.endpoint)||null,N=ht(P?.endpoint)||null,D=ht(w.tubeCenter)||ht(w.wedgeCenter)||null,L=ht(A.tubeCenter)||ht(A.wedgeCenter)||null,H=D||I||null,X=L||N||null,O=H&&X?Us(H,X):NaN,W=Qx(w.tubePoints,D||H),G=Qx(A.tubePoints,L||X);let Q=c;Number.isFinite(W)&&Number.isFinite(G)?Q=Math.min(W,G):Number.isFinite(W)?Q=W:Number.isFinite(G)&&(Q=G),Q=Math.max(1e-6,Q);const z=Math.max(l*2,u*4,1e-6);if(!Number.isFinite(O)||!(O>z)){o&&console.log("[Solid.fillet] Skipping non-tangent corner bridge: no measurable centerline gap.",{featureID:e,sourceFillets:[g?.filletName||null,M?.filletName||null],tubeDistance:Number.isFinite(O)?O:null,minBridgeGap:z});continue}const Z=I2(g,M,S,{endpointTol:l,crossTolerance:Math.max(z,Q*.001,5e-6),maxSegments:4,interiorParamEps:.02});if(Z?.crosses){o&&console.log("[Solid.fillet] Skipping non-tangent corner bridge: adjacent centerlines cross.",{featureID:e,sourceFillets:[g?.filletName||null,M?.filletName||null],crossInfo:Z,tubeDistance:O});continue}const q=[],Y=Math.max(1e-16,u*u);for(const pe of w.wedgePoints)ns(q,pe,Y);for(const pe of A.wedgePoints)ns(q,pe,Y);if(q.length<4)continue;const K=`${L2(e,T,x,"CORNER")}_${Gr(E).toString(16).padStart(8,"0")}`,le=`${K}_WEDGE_BRIDGE`,ae=`${K}_TUBE_BRIDGE`,me=Hs(T,`EDGE_${_}`),ve=Hs(x,`EDGE_${v}`),he=Gr(T).toString(16).slice(-6).padStart(6,"0"),ee=Gr(x).toString(16).slice(-6).padStart(6,"0"),ne=`${K}_WEDGE_BRIDGE_ON_${me}_${he}`,ie=`${K}_WEDGE_BRIDGE_ON_${ve}_${ee}`,xe=Math.max(1e-6,c*1e-4,u*.2),$=iv(q,i,le,xe,Math.max(6,Math.min(16,Math.floor(Number(n)/4)||8)));if(!$||!Array.isArray($?._triVerts)||$._triVerts.length<9)continue;let be=$;try{be.name=le}catch{}const Ie=[g?.tubeSolid,M?.tubeSolid].filter(pe=>pe&&Array.isArray(pe?._triVerts)&&pe._triVerts.length>=9);let Ne=0;if(Ie.length>0){for(let pe=0;pe<Ie.length;pe++){const Ce=Ie[pe];try{const we=be.subtract(Ce);if(!we||!Array.isArray(we?._triVerts)||we._triVerts.length<9){be=null;break}be=we,Ne+=1}catch{be=null;break}}if(!be)continue;try{be.name=le}catch{}}const Ae=[],V=Math.max(1e-16,u*u);for(const pe of w.tubePoints)ns(Ae,pe,V);for(const pe of A.tubePoints)ns(Ae,pe,V);const F=.01;let j=null,re="none";if(Ae.length>=4&&(j=iv(Ae,i,ae,Math.max(1e-6,Q*.001,u*.25),Math.max(6,Math.min(16,Math.floor(Number(n)/4)||8))),j&&(re="tube_cap_hull")),!j&&s&&H&&X&&Number.isFinite(O)&&O>z)try{j=new s({points:[[H.x,H.y,H.z],[X.x,X.y,X.z]],radius:Q,innerRadius:0,resolution:Math.max(8,Math.floor(Number(n)||32)),selfUnion:!0,name:ae}),!Array.isArray(j?._triVerts)||j._triVerts.length<9?j=null:re="tube_centerline_fallback"}catch{j=null}if(!j||!Array.isArray(j?._triVerts)||j._triVerts.length<9)continue;let ge=j;try{ge.name=ae}catch{}let ue=sv(ge,ae,F);if(ue<=0){const pe=sv(j,ae,F);pe>0&&(ue=pe)}const Le=`${ae}_SINGLE_FACE`,Te=O2(ge,Le);if(!Te)continue;let De=be;try{De=be.subtract(Te);try{De.name=`${K}_FINAL_FILLET`}catch{}}catch{continue}if(!De||!Array.isArray(De?._triVerts)||De._triVerts.length<9)continue;const He=U2({solid:De,sourceFaceName:le,desiredNames:[ne,ie],anchorPoints:[w.wedgeCenter,A.wedgeCenter]}),de=Array.isArray(He?.names)?He.names:[],Me=Ab(De);for(const pe of de)!pe||Me.includes(pe)||Me.push(pe);m.push({filletSolid:De,filletName:K,mergeCandidates:Me,roundFaceName:Tb(De,K),wedgeSolid:be,tubeSolid:Te,edgeDirection:b,directionReason:"corner_bridge_non_tangent",directionDetail:{sourceFillets:[g?.filletName||null,M?.filletName||null],sourceEdges:[T,x],sharedPoint:S.sharedPoint,tangentDot:Number.isFinite(S.tangentDot)?S.tangentDot:null,endpointDistance:S.distance,tubeCenterlineGap:Number.isFinite(O)?O:null,minBridgeGap:z,centerlineCrossCheck:Z||null,tubeBridgeMode:re,bridgeEndCapPushDistance:F,adjacentEdgeTubeCutters:Ie.length,adjacentEdgeTubeSubtractionsApplied:Ne,trimmedByAdjacentWedges:0,finalBridgeRetrimmedByAdjacentWedges:0,bridgeEndCapsPushed:ue,bridgeSingleFaceName:Le,bridgeTransitionFaceNames:de,bridgeTransitionFaceComponents:Number(He?.componentCount)||0},edgeObj:null,edgePolyline:null,edgePathPoints:[],cornerBridge:!0})}}return o&&m.length>0&&console.log("[Solid.fillet] Built non-tangent corner bridge entries.",{featureID:e,generatedCorners:m.length,endpointTolerance:l,tangentDotThreshold:h}),m}d(B2,"buildNonTangentCornerTransitionEntries");function z2(r,e,t,n,i=null){if(!r||typeof r.getBoundaryEdgePolylines!="function")return null;const s=Array.isArray(i)?i:r.getBoundaryEdgePolylines()||[],o=e?.name;if(o){const a=s.find(c=>c?.name===o);if(a)return a}return!t||!n?null:s.find(a=>{const c=a?.faceA,l=a?.faceB;return c===t&&l===n||c===n&&l===t})||null}d(z2,"findBoundaryPolylineForEdge");function k2(r,e,t,n){if(!r||!e||!Number.isInteger(t)||!Number.isInteger(n))return 0;const i=r?._faceNameToID instanceof Map?r._faceNameToID.get(e):void 0;if(i===void 0)return 0;const s=Array.isArray(r?._triVerts)?r._triVerts:null,o=Array.isArray(r?._triIDs)?r._triIDs:null;if(!s||!o||s.length!==o.length*3)return 0;for(let a=0;a<o.length;a++){if(o[a]>>>0!==i>>>0)continue;const c=a*3,l=s[c+0],u=s[c+1],h=s[c+2];if(l===t&&u===n||u===t&&h===n||h===t&&l===n)return 1;if(l===n&&u===t||u===n&&h===t||h===n&&l===t)return-1}return 0}d(k2,"findDirectedEdgeOrientationInFace");function V2(r,e,t){const n=Array.isArray(t?.indices)?t.indices:null,i=Array.isArray(r?._vertProperties)?r._vertProperties:null;if(!n||n.length<2||!i)return null;const s=[],o=(n.length-1)/2;for(let a=0;a<n.length-1;a++)s.push(a);s.sort((a,c)=>Math.abs(a-o)-Math.abs(c-o));for(const a of s){const c=Number(n[a]),l=Number(n[a+1]);if(!Number.isInteger(c)||!Number.isInteger(l)||c===l)continue;const u=k2(r,e,c,l);if(!u)continue;const h=c*3,f=l*3;if(h+2>=i.length||f+2>=i.length)continue;let p=i[f+0]-i[h+0],m=i[f+1]-i[h+1],y=i[f+2]-i[h+2];u<0&&(p=-p,m=-m,y=-y);const _=Math.hypot(p,m,y);if(_>1e-12)return p/=_,m/=_,y/=_,{tangent:[p,m,y],midpoint:[(i[h+0]+i[f+0])*.5,(i[h+1]+i[f+1])*.5,(i[h+2]+i[f+2])*.5],segmentIndex:a}}return null}d(V2,"resolveOrientedEdgeTangent");function H2(r,e,t="INSET",n=.2,i=null,s=null){const o=String(t||"INSET").toUpperCase()==="OUTSET"?"OUTSET":"INSET";if(!r||!e)return{direction:o,reason:"missing_context"};const{faceAName:a,faceBName:c}=Ib(e);if(!a||!c)return{direction:o,reason:"missing_faces"};const l=z2(r,e,a,c,i);if(!l)return{direction:o,reason:"missing_boundary_polyline"};const u=V2(r,a,l);if(!u)return{direction:o,reason:"missing_oriented_tangent"};const h=typeof s=="function"?s(a):typeof r.getFace=="function"?r.getFace(a):null,f=typeof s=="function"?s(c):typeof r.getFace=="function"?r.getFace(c):null;if(!Array.isArray(h)||!h.length||!Array.isArray(f)||!f.length)return{direction:o,reason:"missing_face_geometry"};const p=r?.uuid||r?.name||"SOLID",m=`${p}:${a}:AUTO_SIGNED`,y=`${p}:${c}:AUTO_SIGNED`,_=rr(h,m),g=rr(f,y),v=zu(r,a),M=zu(r,c),b={x:u.midpoint[0],y:u.midpoint[1],z:u.midpoint[2]},C=ku(r,a,b,_,m)||v,S=ku(r,c,b,g,y)||M;if(!C||!S)return{direction:o,reason:"missing_normals"};const T=Number(C.y)*Number(S.z)-Number(C.z)*Number(S.y),x=Number(C.z)*Number(S.x)-Number(C.x)*Number(S.z),E=Number(C.x)*Number(S.y)-Number(C.y)*Number(S.x),w=u.tangent[0],A=u.tangent[1],R=u.tangent[2],P=T*w+x*A+E*R;return Number.isFinite(P)?P>n?{direction:"INSET",reason:"signed_dihedral",signedDihedral:P}:P<-n?{direction:"OUTSET",reason:"signed_dihedral",signedDihedral:P}:{direction:o,reason:"signed_dihedral_ambiguous",signedDihedral:P}:{direction:o,reason:"invalid_signed_dihedral"}}d(H2,"classifyEdgeFilletDirectionBySignedDihedral");function G2(r,e,t,n=1,i="INSET",s=null,o=null){const a=String(i||"INSET").toUpperCase()==="OUTSET"?"OUTSET":"INSET";if(!r||!e)return{direction:a,reason:"missing_context"};const c=H2(r,e,i,.2,s,o);if(c?.reason==="signed_dihedral")return c;if(typeof t!="function")return{direction:a,reason:"missing_inside_tester",signedDihedral:c?.signedDihedral};const{faceAName:l,faceBName:u}=Ib(e);if(!l||!u)return{direction:a,reason:"missing_faces"};const h=Rb(e);if(!h)return{direction:a,reason:"missing_polyline"};const f=typeof o=="function"?o(l):typeof r.getFace=="function"?r.getFace(l):null,p=typeof o=="function"?o(u):typeof r.getFace=="function"?r.getFace(u):null;if(!Array.isArray(f)||f.length===0||!Array.isArray(p)||p.length===0)return{direction:a,reason:"missing_face_geometry"};const m=r?.uuid||r?.name||"SOLID",y=`${m}:${l}:AUTO_DIR`,_=`${m}:${u}:AUTO_DIR`,g=rr(f,y),v=rr(p,_),M=zu(r,l),b=zu(r,u),C=Math.max(Cb(r,1e-6)*8,Math.abs(Number(n)||0)*1e-4,1e-6),S=[.2,.5,.8];let T=0,x=0,E=0,w=0;for(const A of S){const R=E2(h,A);if(!R)continue;const P={x:R[0],y:R[1],z:R[2]};if(!Number.isFinite(P.x)||!Number.isFinite(P.y)||!Number.isFinite(P.z))continue;const I=ku(r,l,P,g,y)||M,N=ku(r,u,P,v,_)||b;if(!I||!N){E++;continue}let D=Number(I.x)+Number(N.x),L=Number(I.y)+Number(N.y),H=Number(I.z)+Number(N.z);const X=Math.hypot(D,L,H);if(!(X>1e-12)){E++;continue}D/=X,L/=X,H/=X;const O={x:P.x+D*C,y:P.y+L*C,z:P.z+H*C},W={x:P.x-D*C,y:P.y-L*C,z:P.z-H*C},G=!!t(O),Q=!!t(W);w++,Q&&!G?T++:G&&!Q?x++:E++}return T>x?{direction:"INSET",reason:"classified",insetVotes:T,outsetVotes:x,ambiguousSamples:E,usedSamples:w}:x>T?{direction:"OUTSET",reason:"classified",insetVotes:T,outsetVotes:x,ambiguousSamples:E,usedSamples:w}:{direction:a,reason:"ambiguous",insetVotes:T,outsetVotes:x,ambiguousSamples:E,usedSamples:w}}d(G2,"classifyEdgeFilletDirectionByInsideOutside");async function W2(r={}){const{filletSolid:e}=await is(async()=>{const{filletSolid:z}=await import("./fillet-Bzd1Xae9.js");return{filletSolid:z}},__vite__mapDeps([2,3,4,1])),{Tube:t}=await is(async()=>{const{Tube:z}=await import("./Tube-TKgrLSLm.js");return{Tube:z}},__vite__mapDeps([3,4,1])),n=Number(r.radius);if(!Number.isFinite(n)||n<=0)throw new Error(`Solid.fillet: radius must be > 0, got ${r.radius}`);const i=w2(r.direction),s=i==="OUTSET"?"OUTSET":"INSET",o=i==="AUTO",a=Number.isFinite(r.inflate)?Number(r.inflate):.1,c=Number(r.nudgeFaceDistance),l=Number.isFinite(c)?c:1e-4,u=!!r.debug,h=Number(r.debugSolidsLevel),f=Number.isFinite(h)?Math.max(-1,Math.min(2,Math.floor(h))):0,p=!!r.debugShowCombinedBeforeTarget,m=Number(r.resolution),y=Number.isFinite(m)&&m>0?Math.max(8,Math.floor(m)):32,_=!!r.showTangentOverlays,g=r.featureID||"FILLET",v=Mb(this,{edges:r.edges});if(v.length===0){console.warn("[Solid.fillet] No edges resolved on target solid; returning clone.",{featureID:g,solid:this?.name});const z=this.clone();try{z.name=this.name}catch{}return z}const M=o&&typeof this.getBoundaryEdgePolylines=="function"?(()=>{try{return this.getBoundaryEdgePolylines()||[]}catch{return null}})():null,b=o?M2(this):null,C=[];let S=0;const T=[],x=d(z=>{if(!(!z||T.length===0))try{z.__debugAddedSolids=T}catch{}},"attachDebugSolids"),E=d(()=>{const z=this.clone();try{z.name=this.name}catch{}return x(z),z},"buildFallbackResult"),w=d((z,Z=!1)=>{!u&&!Z||!z||T.push(z)},"pushDebugSolid"),A=d((z,Z,q=!1)=>{if(!(!u||!z)&&!(q&&typeof z.clone!="function"))try{const Y=typeof z.clone=="function"?z.clone():z;try{Y.name=Z}catch{}T.push(Y)}catch{}},"pushNamedDebugSnapshot"),R=d(z=>{if(!(!u||!z)){try{z.tube&&w(z.tube)}catch{}try{z.wedge&&w(z.wedge)}catch{}}},"pushTubeAndWedgeDebug"),P=d((z,Z)=>{const q=(Array.isArray(z)?z:[]).map(K=>K?.filletSolid).filter(Boolean);if(q.length===0)return null;let Y=q[0];for(let K=1;K<q.length;K++){Y=Y.union(q[K]);try{Y.name=`${g}_COMBINED_FILLET_${Z}`}catch{}u&&f>=2&&Y&&typeof Y.clone=="function"&&A(Y,`${g}_COMBINED_${Z}_STEP_${K-1}`,!0)}try{Y.name=`${g}_COMBINED_FILLET_${Z}`}catch{}return Y},"combineFilletEntrySolids"),I=[{mode:"INSET",operation:"subtract",stepIndex:0,stepLabel:"SUBTRACT",entries:[],combinedSolid:null},{mode:"OUTSET",operation:"union",stepIndex:1,stepLabel:"UNION",entries:[],combinedSolid:null}],N=d(z=>String(z||"INSET").toUpperCase()==="OUTSET"?I[1]:I[0],"getBooleanGroupForDirection"),D=o?S2(this):null;let L=0;const H={mode:i,autoEnabled:o,fallbackDirection:s,totalEdges:v.length,insetEdges:0,outsetEdges:0,fallbackEdges:0,ambiguousEdges:0};for(const z of v){const Z=typeof z?.name=="string"&&z.name.trim().length>0?z.name.trim():`EDGE_${S}`,q=Hs(Z,`EDGE_${S}`),Y=q.length>48?q.slice(0,48):q,K=Gr(Z).toString(16).slice(-8).padStart(8,"0"),le=`${g}_FILLET_${Y}_${K}_${S++}`;let ae=s,me=o?"fallback":"explicit",ve=null;if(o){const be=G2(this,z,D,n,s,M,b);ae=be?.direction||s,me=be?.reason||"fallback",ve=be||null,me==="classified"||me==="signed_dihedral"||(H.fallbackEdges+=1,String(me||"").includes("ambiguous")&&(H.ambiguousEdges+=1))}ae==="OUTSET"?H.outsetEdges+=1:H.insetEdges+=1;const he=e({edgeToFillet:z,radius:n,sideMode:ae,inflate:a,nudgeFaceDistance:l,resolution:y,debug:u,name:le,showTangentOverlays:_})||{};if(he.error&&console.warn(`Fillet failed for edge ${z?.name||S}: ${he.error}`),!he.finalSolid){R(he),console.warn("[Solid.fillet] Fillet builder returned no finalSolid.",{featureID:g,edge:z?.name,error:he.error,hasTube:!!he.tube,hasWedge:!!he.wedge});continue}const ee=Ab(he.finalSolid),ne=Tb(he.finalSolid,le),ie=Rb(z),xe=Array.isArray(he?.centerline)&&he.centerline.length>=2?he.centerline.map(be=>ht(be)).filter(Boolean):[],$=Array.isArray(he?.edge)&&he.edge.length>=2?he.edge.map(be=>ht(be)).filter(Boolean):Array.isArray(ie)?ie.map(be=>ht(be)).filter(Boolean):[];C.push({filletSolid:he.finalSolid,filletName:le,mergeCandidates:ee,roundFaceName:ne,wedgeSolid:he.wedge||null,tubeSolid:he.tube||null,tubeCapPointsBeforeNudge:he.tubeCapPointsBeforeNudge||null,edgeDirection:ae,directionReason:me,directionDetail:ve,edgeObj:z||null,edgePolyline:ie,centerlinePathPoints:xe,edgePathPoints:$}),u&&f>=0&&(f===0?R(he):(f===1||R(he),w(he.finalSolid)))}try{const z=this?.constructor?.BaseSolid||this?.constructor||null,Z=B2({filletEntries:C,featureID:g,radius:n,resolution:y,SolidClass:z,TubeClass:t,debug:u});if(Z.length>0){L=Z.length;for(const q of Z)C.push(q);if(u&&f>=0)for(const q of Z)f===0?(q?.tubeSolid&&w(q.tubeSolid),q?.wedgeSolid&&w(q.wedgeSolid)):(f===1||(q?.tubeSolid&&w(q.tubeSolid),q?.wedgeSolid&&w(q.wedgeSolid)),q?.filletSolid&&w(q.filletSolid));console.log("[Solid.fillet] Added non-tangent corner transition fillets.",{featureID:g,addedCorners:Z.length})}}catch(z){console.warn("[Solid.fillet] Failed to build non-tangent corner transitions.",{featureID:g,error:z?.message||z})}if(o&&console.log("[Solid.fillet] AUTO direction classification complete.",{featureID:g,insetEdges:H.insetEdges,outsetEdges:H.outsetEdges,fallbackEdges:H.fallbackEdges,ambiguousEdges:H.ambiguousEdges}),C.length===0)return console.error("[Solid.fillet] All edge fillets failed; returning clone.",{featureID:g,edgeCount:v.length}),E();try{const z=Math.max(1e-6,Math.min(.001,Cb(this,1e-5))),Z=F2({entries:C,featureID:g,endpointTol:z,debug:u});u&&Z.mergedEntries>0&&console.log("[Solid.fillet] Merged per-edge fillet side walls.",{featureID:g,...Z})}catch(z){console.warn("[Solid.fillet] Failed to merge per-edge fillet side walls; continuing.",{featureID:g,error:z?.message||z})}for(const z of C)N(z?.edgeDirection).entries.push(z);const X=I[0].entries,O=I[1].entries;try{for(const z of I)z.combinedSolid=P(z.entries,z.mode);if(u&&p)for(const z of I)z.combinedSolid&&A(z.combinedSolid,`${g}_COMBINED_FILLET_${z.mode}_PRE_TARGET`,!1)}catch(z){return console.error("[Solid.fillet] Fillet combine failed; returning clone.",{featureID:g,error:z?.message||z}),E()}if(!I.some(z=>!!z.combinedSolid))return console.error("[Solid.fillet] No combined fillet solids available; returning clone.",{featureID:g,edgeCount:v.length}),E();let W=this;try{for(const z of I)z.combinedSolid&&(W=z.operation==="subtract"?W.subtract(z.combinedSolid):W.union(z.combinedSolid),u&&f>=2&&W&&typeof W.clone=="function"&&A(W,`${g}_TARGET_BOOLEAN_STEP_${z.stepIndex}_${z.stepLabel}`,!0));try{W.name=this.name}catch{}u&&typeof W?.visualize=="function"&&W.visualize()}catch(z){return console.error("[Solid.fillet] Fillet boolean failed; returning clone.",{featureID:g,error:z?.message||z}),E()}try{await W.collapseTinyTriangles(9e-4)}catch(z){console.warn("[Solid.fillet] collapseTinyTriangles failed",{featureID:g,error:z?.message||z})}x(W);try{W.__filletDirectionDecision={...H,insetEntries:X.length,outsetEntries:O.length,cornerBridgeEntries:L}}catch{}try{W.__filletCornerBridgeCount=L}catch{}try{await W.removeSmallIslands()}catch(z){console.warn("[Solid.fillet] simplify failed; continuing without simplification",{featureID:g,error:z?.message||z})}const G=Array.isArray(W?._triVerts)?W._triVerts.length/3:0,Q=Array.isArray(W?._vertProperties)?W._vertProperties.length/3:0;return(!W||G===0||Q===0)&&console.error("[Solid.fillet] Fillet result is empty or missing geometry.",{featureID:g,finalTriCount:G,finalVertCount:Q,edgeCount:v.length,direction:i,inflate:a}),W}d(W2,"fillet");async function $2(r={}){const{ChamferSolid:e}=await is(async()=>{const{ChamferSolid:m}=await import("./chamfer-jmLT1RTy.js");return{ChamferSolid:m}},__vite__mapDeps([5,4,1])),t=Number(r.distance);if(!Number.isFinite(t)||t<=0)throw new Error(`Solid.chamfer: distance must be > 0, got ${r.distance}`);const n=String(r.direction||"INSET").toUpperCase(),i=Number.isFinite(r.inflate)?Number(r.inflate):.1,s=n==="OUTSET"?-i:i,o=!!r.debug,a=r.featureID||"CHAMFER";console.log("[Solid.chamfer] Begin",{featureID:a,solid:this?.name,distance:t,direction:n,inflate:i,inflateApplied:s,debug:o,requestedEdgeNames:Array.isArray(r.edgeNames)?r.edgeNames:[],providedEdgeCount:Array.isArray(r.edges)?r.edges.length:0});const c=Mb(this,{edgeNames:r.edgeNames,edges:r.edges});if(c.length===0){console.warn("[Solid.chamfer] No edges resolved on target solid; returning clone.",{featureID:a,solid:this?.name});const m=this.clone();try{m.name=this.name}catch{}return m}const l=[];let u=0;for(const m of c){const y=`${a}_CHAMFER_${u++}`;try{const _=new e({edgeToChamfer:m,distance:t,direction:n,inflate:s,debug:o,sampleCount:r.sampleCount,snapSeamToEdge:r.snapSeamToEdge,sideStripSubdiv:r.sideStripSubdiv,seamInsetScale:r.seamInsetScale,flipSide:r.flipSide,debugStride:r.debugStride});try{_.name=y}catch{}l.push(_)}catch(_){console.warn("[Solid.chamfer] Failed to build chamfer solid for edge",{edge:m?.name,error:_?.message||_})}}if(l.length===0){console.error("[Solid.chamfer] All chamfer solids failed; returning clone.",{featureID:a,edgeCount:c.length});const m=this.clone();try{m.name=this.name}catch{}return m}console.log("[Solid.chamfer] Built chamfer solids for edges",l.length);let h=this;for(const m of l){const y=Array.isArray(h?._triVerts)?h._triVerts.length/3:0;h=n==="OUTSET"?h.union(m):h.subtract(m);const _=Array.isArray(h?._triVerts)?h._triVerts.length/3:0;console.log("[Solid.chamfer] Applied chamfer boolean",{featureID:a,operation:n==="OUTSET"?"union":"subtract",beforeTriangles:y,afterTriangles:_});try{h.name=this.name}catch{}}try{h.__debugChamferSolids=l}catch{}const f=Array.isArray(h?._triVerts)?h._triVerts.length/3:0,p=Array.isArray(h?._vertProperties)?h._vertProperties.length/3:0;return!h||f===0||p===0?console.error("[Solid.chamfer] Chamfer result is empty or missing geometry.",{featureID:a,finalTriCount:f,finalVertCount:p,edgeCount:c.length,direction:n,inflate:i}):console.log("[Solid.chamfer] Completed",{featureID:a,triangles:f,vertices:p}),h}d($2,"chamfer");const qo=class qo extends sn{constructor(){super(...arguments),bC.apply(this,arguments)}bakeTransform(...e){return oI.apply(this,arguments)}bakeTRS(...e){return aI.apply(this,arguments)}_key(...e){return qC.apply(this,arguments)}_getPointIndex(...e){return YC.apply(this,arguments)}_getOrCreateID(...e){return ZC.apply(this,arguments)}addTriangle(...e){return KC.apply(this,arguments)}addAuxEdge(...e){return JC.apply(this,arguments)}addCenterline(...e){return jC.apply(this,arguments)}setFaceMetadata(...e){return QC.apply(this,arguments)}getFaceMetadata(...e){return eI.apply(this,arguments)}renameFace(...e){return nI.apply(this,arguments)}setEdgeMetadata(...e){return iI.apply(this,arguments)}getEdgeMetadata(...e){return sI.apply(this,arguments)}remesh(...e){return bI.apply(this,arguments)}removeSmallIslands(...e){return _I.apply(this,arguments)}removeSmallInternalIslands(...e){return yI.apply(this,arguments)}removeOppositeSingleEdgeFaces(...e){return xI.apply(this,arguments)}mirrorAcrossPlane(...e){return lI.apply(this,arguments)}pushFace(...e){return uI.apply(this,arguments)}removeTinyBoundaryTriangles(...e){return vI.apply(this,arguments)}collapseTinyTriangles(...e){return SI.apply(this,arguments)}invertNormals(...e){return gI.apply(this,arguments)}fixTriangleWindingsByAdjacency(...e){return pI.apply(this,arguments)}_isCoherentlyOrientedManifold(...e){return mI.apply(this,arguments)}setEpsilon(...e){return fI.apply(this,arguments)}clone(...e){return SC.apply(this,arguments)}_weldVerticesByEpsilon(...e){return dI.apply(this,arguments)}_manifoldize(...e){return hI.apply(this,arguments)}getMesh(...e){return RI.apply(this,arguments)}free(...e){return MC.apply(this,arguments)}offsetFace(...e){return cI.apply(this,arguments)}_ensureFaceIndex(...e){return PI.apply(this,arguments)}getFace(...e){return NI.apply(this,arguments)}getFaceNames(...e){return tI.apply(this,arguments)}toSTL(...e){return t2.apply(this,arguments)}async writeSTL(...e){return n2.apply(this,arguments)}toSTEP(...e){return i2.apply(this,arguments)}async writeSTEP(...e){return s2.apply(this,arguments)}getFaces(...e){return DI.apply(this,arguments)}visualize(...e){return c2.apply(this,arguments)}getBoundaryEdgePolylines(...e){return FI.apply(this,arguments)}_combineIdMaps(...e){return LI.apply(this,arguments)}_combineFaceMetadata(...e){return rI.apply(this,arguments)}static _expandTriIDsFromMesh(...e){return WI.apply(this,arguments)}static _fromManifold(...e){return $I.apply(this,arguments)}union(...e){return BI.apply(this,arguments)}subtract(...e){return zI.apply(this,arguments)}intersect(...e){return kI.apply(this,arguments)}difference(...e){return VI.apply(this,arguments)}simplify(...e){return GI.apply(this,arguments)}setTolerance(...e){return HI.apply(this,arguments)}volume(...e){return r2.apply(this,arguments)}surfaceArea(...e){return o2.apply(this,arguments)}getTriangleCount(...e){return a2.apply(this,arguments)}splitSelfIntersectingTriangles(...e){return MI.apply(this,arguments)}removeDegenerateTriangles(...e){return wI.apply(this,arguments)}removeInternalTriangles(...e){return EI.apply(this,arguments)}removeInternalTrianglesByRaycast(...e){return AI.apply(this,arguments)}removeInternalTrianglesByWinding(e={}){return TI.apply(this,[e])}cleanupTinyFaceIslands(...e){return CI.apply(this,arguments)}mergeTinyFaces(...e){return II.apply(this,arguments)}chamfer(e={}){return $2.apply(this,[e])}fillet(e={}){return W2.apply(this,[e])}get faces(){return this.visualize(),this.children.filter(e=>e.type==="FACE")}};d(qo,"Solid"),tt(qo,"BaseSolid",qo);let Gs=qo;const X2=d(r=>{try{const e=r?.owningFeatureID??r?.ID??null;return e?` owningFeature=${e}`:""}catch{return""}},"__solidProfilingOwnerTag"),rv=1e3,q2=d((r,e,t,n)=>{const i=Math.round(n),s=`${r} ${e}`;switch(t){case"resolved":return`${s} resolved in ${i} ms`;case"rejected":return`${s} rejected in ${i} ms`;case"completed":return`${s} in ${i} ms`;case"threw":return`${s} threw in ${i} ms`;default:return null}},"__solidProfilingFormatMessage"),Y2=d((r,e,t,n)=>{const i=q2(r,e,t,n);if(i&&n>=rv){const s=`${i} (SLOW > ${rv} ms)`;try{if(typeof console<"u"){const o=typeof console.warn=="function"?console.warn:typeof console.log=="function"?console.log:null;o&&o.call(console,s)}}catch{}}},"__solidProfilingLogTiming");(()=>{try{if(Gs.__profiled)return;Gs.__profiled=!0;const r=d(()=>typeof performance<"u"&&performance?.now?performance.now():Date.now(),"nowMs"),e=new Set(["constructor","_manifoldize"]),t=Gs.prototype;for(const n of Object.getOwnPropertyNames(t)){if(e.has(n))continue;const i=Object.getOwnPropertyDescriptor(t,n);if(!i||typeof i.value!="function")continue;const s=i.value,o=d(function(...a){const c=`[Solid${X2(this)}]`,l=r(),u=d(h=>{const f=r()-l;Y2(c,n,h,f)},"logPhase");try{const h=s.apply(this,a);return h&&typeof h.then=="function"?h.then(f=>(u("resolved"),f),f=>{throw u("rejected"),f}):(u("completed"),h)}catch(h){throw u("threw"),h}},"wrapped");try{Object.defineProperty(o,"name",{value:n,configurable:!0})}catch{}Object.defineProperty(t,n,{...i,value:o})}}catch{}})();const Pi=1e-9;function zf(r,e=0){const t=Number(r);return Number.isFinite(t)?t:e}d(zf,"toFiniteNumber");function Wr(r,e=[0,0,0]){const t=Array.isArray(r)?r:e;return[zf(t?.[0],e[0]||0),zf(t?.[1],e[1]||0),zf(t?.[2],e[2]||0)]}d(Wr,"sanitizeVec3");function kf(r){if(r==null)return"";if(typeof r=="string")return r.trim();if(typeof r=="object"){const e=typeof r.name=="string"?r.name.trim():"";if(e)return e;const t=typeof r.id=="string"?r.id.trim():"";if(t)return t}return""}d(kf,"normalizeReferenceName$1");function Z2(r,e=An){const t=r.clone().normalize(),n=Math.abs(t.dot(new e.Vector3(0,0,1)))>.9?new e.Vector3(0,1,0):new e.Vector3(0,0,1),i=new e.Vector3().crossVectors(n,t).normalize();return i.lengthSq()<=Pi?new e.Vector3(0,1,0):i}d(Z2,"pickOrthogonalUnit");function K2(r){return r?.scene?.getObjectByName?r.scene:r?.partHistory?.scene?.getObjectByName?r.partHistory.scene:r?.viewer?.scene?.getObjectByName?r.viewer.scene:r?.getObjectByName?r:null}d(K2,"resolveScene");function Hu(r,e=An){const t=new e.Vector3;try{r?.getWorldPosition?.(t)}catch{}return t}d(Hu,"resolveWorldPosition");function J2(r,e=An){try{const t=r?.geometry||null;if(t){const n=t.boundingSphere||(t.computeBoundingSphere(),t.boundingSphere);if(n)return r.localToWorld(n.center.clone())}}catch{}return Hu(r,e)}d(J2,"resolveFaceCenter");function j2(r,e=An){let t=null;try{typeof r?.getAverageNormal=="function"&&(t=r.getAverageNormal()?.clone?.()||null)}catch{}if(!t||t.lengthSq()<=Pi){const n=new e.Quaternion;try{r?.getWorldQuaternion?.(n)}catch{}t=new e.Vector3(0,0,1).applyQuaternion(n)}return!t||t.lengthSq()<=Pi?new e.Vector3(1,0,0):t.normalize()}d(j2,"resolveFaceDirection");function Q2(r,e=An){try{if(typeof r?.points=="function")return(r.points(!0)||[]).filter(n=>n&&Number.isFinite(n.x)&&Number.isFinite(n.y)&&Number.isFinite(n.z)).map(n=>new e.Vector3(n.x,n.y,n.z))}catch{}return[]}d(Q2,"resolveEdgePolyline");function eR(r,e,t=An){const n=e?.clone?.();if(!n||!Array.isArray(r)||r.length<2)return null;let i=null,s=Number.POSITIVE_INFINITY;for(let o=0;o<r.length-1;o+=1){const a=r[o],l=r[o+1].clone().sub(a),u=l.lengthSq();if(u<=Pi)continue;const h=t.MathUtils.clamp(n.clone().sub(a).dot(l)/u,0,1),f=a.clone().addScaledVector(l,h),p=f.distanceToSquared(n);p<s&&(s=p,i={origin:f,direction:l.normalize()})}return i}d(eR,"resolveClosestPointOnEdge");function tR(r,e=null,t=An){const n=Q2(r,t);if(n.length>=2){if(e?.isVector3){const o=eR(n,e,t);if(o)return o}const i=[];let s=0;for(let o=0;o<n.length-1;o+=1){const a=n[o].distanceTo(n[o+1]);i.push(a),s+=a}if(s>Pi){const o=s*.5;let a=0;for(let c=0;c<i.length;c+=1){const l=i[c];if(a+l>=o){const u=t.MathUtils.clamp((o-a)/Math.max(l,Pi),0,1);return{origin:n[c].clone().lerp(n[c+1],u),direction:n[c+1].clone().sub(n[c]).normalize()}}a+=l}return{origin:n[n.length-1].clone(),direction:n[n.length-1].clone().sub(n[n.length-2]).normalize()}}}return{origin:e?.clone?.()||Hu(r,t),direction:new t.Vector3(1,0,0)}}d(tR,"resolveEdgeAnchor");function Rr(r,e,t=An){const n=e.clone().normalize(),i=Z2(n,t),s=new t.Vector3().crossVectors(n,i).normalize(),o=new t.Vector3().crossVectors(s,n).normalize(),a=new t.Matrix4().makeBasis(n,o,s),c=new t.Quaternion().setFromRotationMatrix(a);return{position:[r.x,r.y,r.z],quaternion:[c.x,c.y,c.z,c.w],scale:[1,1,1]}}d(Rr,"makeBasisTransform");function nm(r){if(r==null)return null;if(r?.isObject3D){const e=kf(r);return e?{name:e,type:String(r.type||"").toUpperCase()}:null}if(typeof r=="string"){const e=kf(r);return e||null}if(typeof r=="object"){const e=kf(r);if(!e)return null;const t={name:e},n=String(r.type||"").trim().toUpperCase();return n&&(t.type=n),Array.isArray(r.pickPoint)&&r.pickPoint.length>=3&&(t.pickPoint=Wr(r.pickPoint,[0,0,0])),Number.isFinite(Number(r.faceIndex))&&Number(r.faceIndex)>=0&&(t.faceIndex=Math.floor(Number(r.faceIndex))),t}return null}d(nm,"sanitizeTransformReference");function Nr(r){const e=nm(r);return typeof e=="string"?e:typeof e?.name=="string"?e.name:""}d(Nr,"resolveTransformReferenceName");function im(r){const e=r&&typeof r=="object"?r:{},t={position:Wr(e.position,[0,0,0]),rotationEuler:Wr(e.rotationEuler,[0,0,0]),scale:Wr(e.scale,[1,1,1])},n=nm(e.reference);return n&&(t.reference=n),t}d(im,"sanitizeTransformValue");function nR(r,e){if(r?.isObject3D)return r;const t=K2(e),n=Nr(r);if(!t||!n||typeof t.getObjectByName!="function")return null;try{return t.getObjectByName(n)||null}catch{return null}}d(nR,"resolveTransformReferenceObject");function Cp(r,e,t={},n=An){const i=new n.Vector3(...Wr(t?.fallbackDirection,[1,0,0]));i.lengthSq()<=Pi&&i.set(1,0,0),i.normalize();const s=new n.Vector3(...Wr(t?.fallbackOrigin,[0,0,0])),o=nm(r),a=Array.isArray(o?.pickPoint)?new n.Vector3(...o.pickPoint):null,c=nR(r,e),l=String(o?.type||c?.type||"").trim().toUpperCase();if(!c)return Rr(a||s,i,n);if(l==="FACE")return Rr(a||J2(c,n),j2(c,n),n);if(l==="EDGE"){const p=tR(c,a,n);return Rr(p.origin,p.direction,n)}if(l==="VERTEX")return Rr(a||Hu(c,n),i,n);const u=a||Hu(c,n);if(l==="PLANE"){const p=new n.Quaternion;try{c.getWorldQuaternion?.(p)}catch{}const m=new n.Vector3(0,0,1).applyQuaternion(p);return Rr(u,m.lengthSq()>Pi?m:i,n)}const h=new n.Quaternion;try{c.getWorldQuaternion?.(h)}catch{}const f=new n.Vector3(1,0,0).applyQuaternion(h);return Rr(u,f.lengthSq()>Pi?f:i,n)}d(Cp,"resolveTransformReferenceBase");function QR(r,e,t={},n=An){const i=im(r),s=Cp(i.reference,e,t,n);return vb(s,i,n)}d(QR,"composeReferencedTransformMatrix");function iR({ui:r,key:e,def:t,id:n}){const i=document.createElement("button");return i.type="button",i.id=n,i.className="btn",i.textContent=String(t.label||r._prettyLabel(e)),i.addEventListener("click",s=>{s.preventDefault(),r._stopActiveReferenceSelection();const o=r.params&&Object.prototype.hasOwnProperty.call(r.params,"featureID")?r.params.featureID:r.params?.id??null;let a=!1;try{if(t&&typeof t.actionFunction=="function"){const c={featureID:o,key:e,viewer:r.options?.viewer||null,partHistory:r.options?.partHistory||null,feature:r.options?.featureRef||null,params:r.params,schemaDef:t},l=t.actionFunction(c);a=!0}}catch{}if(!a)try{typeof r.options.onAction=="function"&&r.options.onAction(o,e)}catch{}}),{inputEl:i,activate(){i.focus()},readValue(){return null}}}d(iR,"renderButtonField");const sR=2,$_=class $_ extends ft{constructor(e,t){super(),this.type="CombinedTransformControls",this.camera=e,this.domElement=t,this.enabled=!0,this.dragging=!1,this.mode="translate",this.displayMode="transform",this.dimensionToggleEnabled=!1,this.showX=!0,this.showY=!0,this.showZ=!0,this.isTransformGizmo=!0,this._defaultSizeMultiplier=sR,this._sizeMultiplier=this._defaultSizeMultiplier,this.renderOrder=5e4,this.target=null,this._raycaster=new Du,this._pointer=new Ee,this._tmpV=new U,this._tmpV2=new U,this._tmpQ=new Mt,this._plane=new Zn,this.gizmo=this._buildGizmo(),this.add(this.gizmo.root),this._updateDisplayModeVisuals(),this._onPointerDown=this._handlePointerDown.bind(this),this._onPointerMove=this._handlePointerMove.bind(this),this._onPointerUp=this._handlePointerUp.bind(this),this.domElement&&(this.domElement.addEventListener("pointerdown",this._onPointerDown,{passive:!1}),window.addEventListener("pointermove",this._onPointerMove,{passive:!1}),window.addEventListener("pointerup",this._onPointerUp,{passive:!1,capture:!0}))}dispose(){try{this.domElement?.removeEventListener("pointerdown",this._onPointerDown)}catch{}try{window.removeEventListener("pointermove",this._onPointerMove)}catch{}try{window.removeEventListener("pointerup",this._onPointerUp,{capture:!0})}catch{}}getHelper(){return this}getMode(){return this.mode}setMode(e){this.mode=String(e||"translate")}getDisplayMode(){return this.displayMode}setDisplayMode(e){const t=String(e||"transform")==="dimensions"&&this.dimensionToggleEnabled?"dimensions":"transform",n=this.displayMode!==t;this.displayMode=t,this._updateDisplayModeVisuals(),n&&(this.dispatchEvent({type:"display-mode-changed",value:this.displayMode}),this.dispatchEvent({type:"change"}))}toggleDisplayMode(){if(!this.dimensionToggleEnabled)return this.displayMode;const e=this.displayMode==="dimensions"?"transform":"dimensions";return this.setDisplayMode(e),this.displayMode}setDimensionToggleEnabled(e){this.dimensionToggleEnabled=!!e,!this.dimensionToggleEnabled&&this.displayMode==="dimensions"&&(this.displayMode="transform"),this._updateDisplayModeVisuals()}setSize(e){this._sizeMultiplier=Number(e)||1,this.update()}resetSize(){this.setSize(this._defaultSizeMultiplier)}setCamera(e,{resetSize:t=!1,refresh:n=!0}={}){e&&(this.camera=e),t&&(this._sizeMultiplier=this._defaultSizeMultiplier),n&&this.update()}setDomElement(e){if(this.domElement!==e){try{this.domElement?.removeEventListener("pointerdown",this._onPointerDown)}catch{}this.domElement=e||null,this.domElement&&this.domElement.addEventListener("pointerdown",this._onPointerDown,{passive:!1})}}attach(e){if(this.target=e||null,this.target){try{this.target.updateMatrixWorld(!0)}catch{}this.position.copy(this.target.getWorldPosition(new U)),this.quaternion.copy(this.target.getWorldQuaternion(new Mt)),this.updateMatrixWorld(!0);try{this.update()}catch{}}}detach(){this.target=null}update(){const e=this._computeGizmoScale()*(this._sizeMultiplier||1);if(this.gizmo.root.scale.setScalar(e),this.gizmo&&this.gizmo.labels){const t=this.camera.quaternion;for(const n of this.gizmo.labels)n.quaternion.copy(t)}}_buildGizmo(){const e=new sn;e.name="HybridXformGizmoRoot",e.userData.excludeFromFit=!0,e.renderOrder=this.renderOrder;const t={translate:e,rotate:e},n=new Wt({color:12566463,toneMapped:!1,depthTest:!1,depthWrite:!1,transparent:!0}),i=new Wt({color:15909198,toneMapped:!1,depthTest:!1,depthWrite:!1,transparent:!0}),s=new Wt({color:15900236,toneMapped:!1,depthTest:!1,depthWrite:!1,transparent:!0}),o=new Wt({color:15909198,toneMapped:!1,depthTest:!1,depthWrite:!1,transparent:!0}),a=new eo(.03,.03,1,16),c=new to(.12,.4,20),l=new js(.12,16,12),u=new js(.16,18,14),h=[],f=d((_,g,v)=>{const M=new sn;M.renderOrder=this.renderOrder,M.name=`Axis${_}`;const b=new yt(a,n);b.renderOrder=this.renderOrder,b.position.y=.5,M.add(b);const C=new yt(c,i);C.renderOrder=this.renderOrder,C.position.y=1+.125,C.userData.handle={kind:"translate",axis:_},M.add(C),_==="X"&&(M.rotation.z=-Math.PI/2),_==="Z"&&(M.rotation.x=-Math.PI/2);const S=this._makeTextSprite(`${_}C`,g);S.position.set(0,1.3,0),M.add(S),e.add(M),h.push({group:M,spr:S})},"addAxis");f("X","#ff6666"),f("Y","#7ddc6f"),f("Z","#6aa9ff");const p={},m=d(_=>{const g=new sn;g.name=`Rotate${_}`,g.renderOrder=this.renderOrder;const v=.9,M=new Qe().setFromPoints(Array.from({length:33},(x,E)=>{const w=E/32*(Math.PI/2);return new U(Math.cos(w)*v,Math.sin(w)*v,0)})),b=new It({color:14737632,linewidth:2,toneMapped:!1,depthTest:!1,depthWrite:!1,transparent:!0}),C=new Qn(M,b);C.renderOrder=this.renderOrder,g.add(C);const S=Math.PI/4,T=new yt(l,s);T.position.set(Math.cos(S)*v,Math.sin(S)*v,0),T.renderOrder=this.renderOrder,T.userData.handle={kind:"rotate",axis:_},g.add(T),_==="X"&&(g.rotation.y=Math.PI/2),_==="Y"&&(g.rotation.x=-Math.PI/2),e.add(g),p[_]={group:g,dot:T,radius:v}},"addRotate");m("Z"),m("Y"),m("X");const y=new yt(u,o);return y.name="DisplayModeToggle",y.renderOrder=this.renderOrder,y.userData.handle={kind:"toggle-display-mode"},e.add(y),{root:e,picker:t,labels:h.map(_=>_.spr),rot:p,translateGroups:h.map(_=>_.group),rotateGroups:Object.values(p).map(_=>_.group),center:y,centerMaterial:o}}_makeTextSprite(e,t="#ffffff"){const i=document.createElement("canvas");i.width=i.height=256;const s=i.getContext("2d");s.clearRect(0,0,256,256),s.fillStyle="rgba(0,0,0,0)",s.fillRect(0,0,256,256),s.font='bold 64px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',s.textAlign="center",s.textBaseline="middle",s.fillStyle=t,s.fillText(String(e||""),256/2,256/2);const o=new Vl(i);o.colorSpace=un;const a=new jr({map:o,transparent:!0,depthTest:!1,depthWrite:!1}),c=new oa(a);return c.scale.setScalar(.6),c.renderOrder=this.renderOrder,c}_computeGizmoScale(){const e=this.camera;if(e&&e.isOrthographicCamera)return 1/Math.max(1e-4,e.zoom||1);const t=this.getWorldPosition(this._tmpV),n=this.camera.getWorldPosition(this._tmpV2),i=t.distanceTo(n),s=Math.tan((this.camera.fov||50)*Math.PI/360)*2;return i*s/10}_setPointerFromEvent(e){const t=this.domElement.getBoundingClientRect(),n=(e.clientX-t.left)/t.width*2-1,i=-((e.clientY-t.top)/t.height)*2+1;this._pointer.set(n,i)}_intersections(e){this._raycaster.setFromCamera(this._pointer,this.camera);const t=this._raycaster.ray;return this.camera.isOrthographicCamera?t.origin.add(t.direction.clone().multiplyScalar(-1e3)):this.camera.isPerspectiveCamera&&t.origin.copy(this.camera.position),this._raycaster.intersectObject(e,!0)||[]}_handlePointerDown(e){if(!this.enabled||!this.visible||!this.target)return;this._setPointerFromEvent(e);const t=this.gizmo,n=t.picker[this.mode]||t.root,i=this._intersections(n),s=Array.isArray(i)?i.find(a=>a?.object?.userData?.handle):null;if(!s)return;const o=s.object.userData.handle;if(!(!o||!o.kind)){if(o.kind==="toggle-display-mode"){e.preventDefault(),e.stopPropagation?.(),this.toggleDisplayMode();return}e.preventDefault(),e.stopPropagation?.(),this._drag=this._drag||{},this._drag.handle=o;try{this.updateMatrixWorld(!0)}catch{}if(this._drag.startPos=this.getWorldPosition(new U),this._drag.startQuat=this.getWorldQuaternion(new Mt),this._drag.axis=this._axisWorld(o.axis),o.kind==="translate"){const a=this.camera.getWorldDirection(new U);this._plane.setFromNormalAndCoplanarPoint(a,this._drag.startPos)}else o.kind==="rotate"&&this._plane.setFromNormalAndCoplanarPoint(this._drag.axis,this._drag.startPos);if(this._drag.startPoint=this._planeIntersect(),!this._drag.startPoint){this._drag=null;return}if(o.kind==="rotate"){this._drag.prevPoint=this._drag.startPoint.clone();const a=this.gizmo&&this.gizmo.rot?this.gizmo.rot[o.axis]:null;this._drag.rotVis=a||null}this.dragging=!0,this.dispatchEvent({type:"dragging-changed",value:!0})}}_handlePointerMove(e){if(!this.dragging||!this._drag)return;this._setPointerFromEvent(e);const t=this._planeIntersect();if(!t)return;const{handle:n,startPos:i,axis:s,startPoint:o}=this._drag;if(n.kind==="translate"){const c=this._tmpV.copy(t).sub(o).dot(s),l=this._tmpV2.copy(i).add(this._tmpV.copy(s).multiplyScalar(c));this.target.position.copy(l)}else if(n.kind==="rotate"){const a=this._drag.prevPoint||o,c=this._tmpV.copy(a).sub(i).normalize(),l=this._tmpV2.copy(t).sub(i).normalize(),u=new U().crossVectors(c,l),h=Bn.clamp(c.dot(l),-1,1),f=Math.atan2(u.dot(s),h),p=this._axisWorld(n.axis),m=new Mt().setFromAxisAngle(p,f);this.target.quaternion.multiplyQuaternions(m,this.target.quaternion),this._drag.prevPoint=t.clone();try{const y=this._drag.rotVis;if(y&&y.dot&&y.group&&n.axis){const _=y.radius||.9,g=Math.PI/4;y.dot.position.set(Math.cos(g)*_,Math.sin(g)*_,0)}}catch{}}this.position.copy(this.target.position),this.quaternion.copy(this.target.quaternion),this.updateMatrixWorld(!0),this.dispatchEvent({type:"change"})}_handlePointerUp(e){this.dragging&&(this.dragging=!1,this._drag=null,this.dispatchEvent({type:"dragging-changed",value:!1}),this.dispatchEvent({type:"objectChange"}))}_axisWorld(e){return new U(e==="X"?1:0,e==="Y"?1:0,e==="Z"?1:0).applyQuaternion(this.quaternion).normalize()}_planeIntersect(){this._raycaster.setFromCamera(this._pointer,this.camera);const e=this._raycaster.ray;this.camera.isOrthographicCamera?e.origin.add(e.direction.clone().multiplyScalar(-1e3)):this.camera.isPerspectiveCamera&&e.origin.copy(this.camera.position);const t=new U;return this._raycaster.ray.intersectPlane(this._plane,t)?t.clone():null}_updateDisplayModeVisuals(){const e=this.gizmo||null;if(!e)return;const t=!this.dimensionToggleEnabled||this.displayMode==="transform";for(const n of e.translateGroups||[])n&&(n.visible=t);for(const n of e.rotateGroups||[])n&&(n.visible=t);e.center&&(e.center.visible=this.dimensionToggleEnabled),e.centerMaterial?.color&&e.centerMaterial.color.setHex(this.displayMode==="dimensions"?5164484:15909198)}};d($_,"CombinedTransformControls");let Ip=$_;function rR({ui:r,key:e,def:t,id:n,controlWrap:i}){const s=document.createElement("div");s.className="number-input-wrap";const o=document.createElement("input");o.type="text",o.id=n,o.className="input number-input",o.dataset.forceText="true";try{t&&(typeof t.step=="number"||typeof t.step=="string"&&t.step.trim()!=="")&&(o.dataset.step=String(t.step)),t&&(typeof t.min=="number"||typeof t.min=="string"&&t.min!=="")&&(o.dataset.min=String(t.min)),t&&(typeof t.max=="number"||typeof t.max=="string"&&t.max!=="")&&(o.dataset.max=String(t.max))}catch{}const a=document.createElement("div");a.className="number-stepper";const c=document.createElement("button");c.type="button",c.className="number-stepper-btn number-stepper-up",c.setAttribute("aria-label","Increment");const l=document.createElement("button");l.type="button",l.className="number-stepper-btn number-stepper-down",l.setAttribute("aria-label","Decrement"),a.appendChild(c),a.appendChild(l),s.appendChild(o),s.appendChild(a),i&&i.appendChild(s),r._setInputValue(o,t.type,r._pickInitialValue(e,t));const u=d(()=>{r.params[e]=o.value,r._emitParamsChange(e,o.value)},"commitValue");o.addEventListener("change",u),o.addEventListener("focus",()=>{o.select(),r._stopActiveReferenceSelection()});const h=/^\s*[-+]?((\d+(?:\.\d*)?)|(\.\d+))(?:[eE][-+]?\d+)?\s*$/,f=d(E=>{const w=o.dataset?o.dataset[E]:null;if(w==null||w==="")return null;const A=Number(w);return Number.isFinite(A)?A:null},"readLimit"),p=d(()=>{const E=o.dataset?o.dataset.step:null,w=Number(E);return!Number.isFinite(w)||w===0?1:Math.abs(w)},"readStep"),m=d(()=>{const E=String(o.value||"").trim();if(!E){const A=f("min");return Number.isFinite(A)?A:0}if(!h.test(E))return null;const w=Number(E);return Number.isFinite(w)?w:null},"readBase"),y=d((E,w={})=>{const{commit:A=!0,focus:R=!0}=w,P=m();if(P==null)return!1;const I=p();let N=P+E*I;const D=f("min"),L=f("max");return Number.isFinite(D)&&(N=Math.max(D,N)),Number.isFinite(L)&&(N=Math.min(L,N)),r._setInputValue(o,"number",N),A&&u(),R&&(o.focus(),o.select()),!0},"applyStep"),_=d(E=>{E.preventDefault()},"preventBlur"),g={delay:350,interval:80};let v=null,M=null,b=null,C=!1,S=!1;const T=d(()=>{v&&clearTimeout(v),M&&clearInterval(M),v=null,M=null,C&&(u(),C=!1),S&&(b&&clearTimeout(b),b=setTimeout(()=>{S=!1},200))},"stopRepeat"),x=d(E=>{if(T(),C=y(E,{commit:!1,focus:!0}),!!C)return v=setTimeout(()=>{M=setInterval(()=>{y(E,{commit:!1,focus:!1})&&(C=!0)},g.interval)},g.delay),window.addEventListener("pointerup",T,{once:!0}),window.addEventListener("pointercancel",T,{once:!0}),!0},"startRepeat");return c.addEventListener("pointerdown",E=>{_(E),S=!!x(1)}),l.addEventListener("pointerdown",E=>{_(E),S=!!x(-1)}),c.addEventListener("click",()=>{if(S){S=!1,b&&clearTimeout(b);return}y(1)}),l.addEventListener("click",()=>{if(S){S=!1,b&&clearTimeout(b);return}y(-1)}),{inputEl:o,activate(){o.focus()},readValue(){return o.value}}}d(rR,"renderNumberField");function oR({ui:r,key:e,def:t,id:n}){const i=document.createElement("textarea");if(i.id=n,i.className="input textarea",t&&t.rows!=null){const s=parseInt(t.rows,10);Number.isFinite(s)&&s>0&&(i.rows=s)}return t&&typeof t.placeholder=="string"&&(i.placeholder=t.placeholder),r._setInputValue(i,"string",r._pickInitialValue(e,t)),i.addEventListener("change",()=>{r.params[e]=i.value,r._emitParamsChange(e,i.value)}),{inputEl:i,activate(){i.focus()},readValue(){return i.value}}}d(oR,"renderTextareaField");function bn(r){if(r==null)return null;if(typeof r=="string"){const t=r.trim();if(!t)return null;try{const n=JSON.parse(t);if(n&&typeof n=="object"){const i=typeof n.name=="string"?n.name.trim():"";if(i)return i;const s=typeof n.id=="string"?n.id.trim():"";if(s)return s}}catch{}return t}if(typeof r=="object"){if(typeof r.name=="string"&&r.name.trim())return r.name.trim();if(typeof r.id=="string"&&r.id.trim())return r.id.trim();if(Array.isArray(r.path)){const t=r.path.filter(Boolean).map(String).join(" › ");if(t)return t}}return String(r).trim()||null}d(bn,"normalizeReferenceName");function li(r){if(!Array.isArray(r))return[];const e=new Set,t=[];for(const n of r){const i=bn(n);!i||e.has(i)||(e.add(i),t.push(i))}return t}d(li,"normalizeReferenceList");function sm({ui:r,key:e,def:t,id:n,controlWrap:i,valueAdapter:s=null}){const o=document.createElement("input");o.type="hidden",o.id=n;try{o.dataset.key=String(e)}catch{}try{o.__refSelectionDef=t}catch{}const a=!!t.multiple;a&&(o.dataset.multiple="true");const c=d(S=>{const T=Number(S);if(!Number.isFinite(T))return null;const x=Math.max(0,Math.floor(T));return x>=0?x:null},"parseBound"),l=a?c(t.minSelections):null;let u=a?c(t.maxSelections):null;a&&u!==null&&l!==null&&u<l&&(u=l),a&&l!==null&&(o.dataset.minSelections=String(l)),a&&u!==null&&(o.dataset.maxSelections=String(u));const h=typeof t.placeholder=="string"&&t.placeholder.trim()?t.placeholder.trim():"Click then select in scene…",f=s&&typeof s=="object"?s:null,p=d(()=>{if(f&&typeof f.read=="function")try{return f.read()}catch{return null}return r._pickInitialValue(e,t)},"readRawValue"),m=d(S=>{if(f&&typeof f.write=="function")try{f.write(S);return}catch{return}r.params[e]=S},"writeRawValue"),y=d(S=>{if(f&&typeof f.emit=="function")try{f.emit(S);return}catch{return}r._emitParamsChange(e,S)},"emitChange"),_=d(()=>{const S=p();if(Array.isArray(S))return li(S);const T=bn(S);return T?[T]:[]},"resolveCurrentSelectionNames"),g=d(()=>{const S=r?.options?.partHistory?.scene||r?.options?.viewer?.partHistory?.scene||r?.options?.viewer?.scene||null,T=_();if(!S||typeof S.getObjectByName!="function")return[];const x=[];for(const E of T){if(!E)continue;const w=S.getObjectByName(E);w&&x.push(w)}return x},"resolveCurrentSelectionObjects");o.__validateReferenceSelection=(S,T={})=>{const x=t?.selectionValidator;if(typeof x!="function")return{allowed:!0,message:null};const E=r?.params&&Object.prototype.hasOwnProperty.call(r.params,"featureID")?r.params.featureID:r?.params?.id??null,w={ui:r,key:e,def:t,id:n,inputEl:o,params:r?.params||null,featureID:E,viewer:r?.options?.viewer||null,partHistory:r?.options?.partHistory||r?.options?.viewer?.partHistory||null,currentValue:p(),currentSelectionNames:_(),currentSelections:g(),pointerEvent:T?.pointerEvent,pickMeta:T?.pickMeta||null};let A=!0;try{A=x(S,w)!==!1}catch(I){console.warn("[ReferenceSelection] selectionValidator threw; blocking selection.",I),A=!1}if(A)return{allowed:!0,message:null};let R=null;const P=t?.selectionValidationMessage;if(typeof P=="function")try{const I=P(S,w);typeof I=="string"&&I.trim()&&(R=I.trim())}catch{}else typeof P=="string"&&P.trim()&&(R=P.trim());return{allowed:!1,message:R||"Selection not allowed for this field."}};const v=document.createElement("div");v.className=a?"ref-multi-wrap":"ref-single-wrap";let M=null;const b=d(S=>{if(!a)return;const T=li(Array.isArray(S)?S:[]);try{o.dataset.selectedCount=String(T.length)}catch{}try{o.dataset.selectedValues=JSON.stringify(T)}catch{}},"updateSelectionMetadata");if(a&&(o.__getSelectionList=()=>{try{const S=p();return Array.isArray(S)?li(S):[]}catch{return[]}},o.__updateSelectionMetadata=b),a){M=document.createElement("div"),M.className="ref-chips",M.addEventListener("click",()=>r._activateReferenceSelection(o,t)),v.appendChild(M);try{const S=p(),T=li(Array.isArray(S)?S:[]);m(T),r._renderChips(M,e,T),b(T)}catch{}}else{const S=document.createElement("button");S.type="button",S.className="ref-single-display",S.title=h,S.dataset.placeholder=h;const T=document.createElement("span");T.className="ref-single-label",S.appendChild(T);const x=document.createElement("span");x.className="ref-chip-remove",x.role="button",x.tabIndex=0,x.title="Clear selection",x.textContent="✕";const E=d(R=>{R.stopPropagation(),R.preventDefault?.(),m(null),o.value="";try{o.__lastReferenceSelectionMeta=null}catch{}w(null),y(null);try{r._syncActiveReferenceSelectionHighlight(o,t)}catch{}},"clearSelection");x.addEventListener("click",E),x.addEventListener("keydown",R=>{(R.key==="Enter"||R.key===" ")&&E(R)}),S.appendChild(x);const w=d(R=>{const P=bn(R);T.textContent=P||h,x.style.visibility=P?"visible":"hidden"},"updateSingleDisplay"),A=bn(p());m(A),w(A),o.value=A??"",S.addEventListener("click",()=>r._activateReferenceSelection(o,t)),S.addEventListener("mouseenter",()=>{const R=bn(o.value||p());if(R)try{r._hoverReferenceSelectionItem?.(o,t,R)}catch{}}),S.addEventListener("mouseleave",()=>{try{r._clearReferenceSelectionHover?.(o)}catch{}}),v.appendChild(S),o.addEventListener("change",()=>{w(o.value);const R=bn(o.value);let P=R;try{const I=o.__lastReferenceSelectionMeta;if(I&&typeof I=="object"){const N=bn(I);if(N&&N===R){const D={...I,name:N};Array.isArray(D.pickPoint)&&D.pickPoint.length>=3?D.pickPoint=[Number(D.pickPoint[0])||0,Number(D.pickPoint[1])||0,Number(D.pickPoint[2])||0]:delete D.pickPoint,Number.isFinite(D.faceIndex)&&Number(D.faceIndex)>=0?D.faceIndex=Math.floor(Number(D.faceIndex)):delete D.faceIndex,P=D}else o.__lastReferenceSelectionMeta=null}}catch{}m(P),y(P);try{r._syncActiveReferenceSelectionHighlight(o,t)}catch{}})}return r._setInputValue(o,t.type,p()),o.addEventListener("change",()=>{const S=o.value;if(a){if(o.dataset&&o.dataset.forceClear==="true"){m([]),M&&(r._renderChips(M,e,[]),b([])),o.value="",delete o.dataset.forceClear,y(f?p():[]);return}let T=[],x=!1;try{const P=JSON.parse(S);Array.isArray(P)&&(T=P,x=!0)}catch{}!x&&S!=null&&String(S).trim()!==""&&(T=[String(S).trim()]);const E=p(),A=(Array.isArray(E)?E:[]).slice();for(const P of T){const I=bn(P);I&&(A.includes(I)||A.push(I))}const R=li(A);a&&u!==null&&R.length>u&&(R.length=u),m(R),M&&(r._renderChips(M,e,R),b(R)),o.value="",y(f?p():R)}else{const T=bn(S);o.value=T??"",m(T),y(T);try{r._syncActiveReferenceSelectionHighlight(o,t)}catch{}}}),v.appendChild(o),i.appendChild(v),{inputEl:o,activate:d(()=>r._activateReferenceSelection(o,t),"activate"),readValue(){const S=p();return Array.isArray(S)?li(S):bn(S)}}}d(sm,"renderReferenceSelectionField");function aR({ui:r,key:e,def:t,id:n,controlWrap:i,valueAdapter:s=null}){const o=document.createElement("input");o.type="hidden",o.id=n;const a=document.createElement("div");a.className="transform-wrap";const c=s&&typeof s=="object"?s:null,l=c&&typeof c.activationKey=="string"?c.activationKey:e,u=d(I=>im(I),"sanitizeTRS"),h=d(()=>{if(c&&typeof c.get=="function")try{return u(c.get())}catch{return u(null)}return u(r._pickInitialValue(e,t))},"readTRS"),f=d(I=>{const N=u(I);if(c&&typeof c.set=="function")try{c.set({position:N.position.slice(0,3),rotationEuler:N.rotationEuler.slice(0,3),scale:N.scale.slice(0,3),...N.reference?{reference:N.reference}:{}})}catch{}else{const D={position:N.position.slice(0,3),rotationEuler:N.rotationEuler.slice(0,3),scale:N.scale.slice(0,3)};N.reference&&(D.reference=N.reference),r.params[e]=D}return N},"writeTRS"),p=d(I=>{if(c&&typeof c.emit=="function")try{c.emit(I);return}catch{return}r._emitParamsChange(l,I)},"emitChange"),m=document.createElement("button");m.type="button",m.className="btn",m.textContent=String(t.label||"Position in 3D…");const y=document.createElement("div");y.className="transform-info";const _=d(I=>{const N=Number(I);if(!Number.isFinite(N))return"0";const D=Math.abs(N),L=D>=100?0:D>=10?1:2;return String(N.toFixed(L))},"fmt"),g=d((I=null)=>{const N=I?u(I):h(),D=Array.isArray(N.position)?N.position:[0,0,0],L=Array.isArray(N.rotationEuler)?N.rotationEuler:[0,0,0],H=Nr(N.reference);y.textContent=`pos(${_(D[0])}, ${_(D[1])}, ${_(D[2])}) rot(${_(L[0])}, ${_(L[1])}, ${_(L[2])})${H?` ref(${H})`:""}`},"updateInfo");g();const v=document.createElement("div");v.className="transform-modes";const M=d(()=>h(),"getTRS"),b=d((I,N=!0,D={})=>{const{skipWrite:L=!1}=D,H=L?u(I):f(I);try{g(H)}catch{}try{const O=r._fieldsWrap.querySelector(`[data-key="${e}"]`)||a,W=[[".tf-pos-x",H.position[0]],[".tf-pos-y",H.position[1]],[".tf-pos-z",H.position[2]],[".tf-rot-x",H.rotationEuler[0]],[".tf-rot-y",H.rotationEuler[1]],[".tf-rot-z",H.rotationEuler[2]]];for(const[G,Q]of W){const z=O?O.querySelector(G):null;z&&r._setInputValue(z,"number",Q)}}catch{}if(N)try{const X=r.activeTransform;if(X&&X.inputEl===o&&X.target){const O=X.baseTransform||{position:[0,0,0],quaternion:[0,0,0,1],scale:[1,1,1]},W=vb(O,H,An),G=new U,Q=new Mt,z=new U;W.decompose(G,Q,z),X.target.position.copy(G),X.target.quaternion.copy(Q),X.target.scale.copy(z)}}catch{}return H},"setTRS"),C=document.createElement("div");C.className="transform-grid";const S=d((I,N,D)=>{const L=document.createElement("div");L.className="transform-row";const H=document.createElement("div");H.className="transform-label",H.textContent=I;const X=document.createElement("div");X.className="transform-inputs";const O=["x","y","z"];for(let W=0;W<3;W++){const G=document.createElement("input");G.className=`input transform-input tf-${N}-${O[W]}`,G.type="number",G.step="any",r._setInputValue(G,"number",D[W]??0);const Q=/^-?\d*\.?\d*$/,z=d(q=>q===""||q==null?!0:Q.test(String(q)),"isNumericLikeLocal"),Z=d(q=>{try{z(q.value)?q.type="number":q.type="text"}catch{}},"onFocusToggleTypeLocal");G.addEventListener("focus",()=>{Z(G),r._stopActiveReferenceSelection()}),G.addEventListener("beforeinput",q=>{try{const Y=String(G.value||"")+String(q.data||"");z(Y)?G.type!=="number"&&(G.type="number"):G.type!=="text"&&(G.type="text")}catch{}}),G.addEventListener("change",()=>{const q=M(),Y=G.value;N==="pos"?q.position[W]=Y:q.rotationEuler[W]=Y;const K=b(q,!0);p(K)}),X.appendChild(G)}L.appendChild(H),L.appendChild(X),C.appendChild(L)},"addRow"),T=M();S("Position","pos",T.position),S("Rotation (deg)","rot",T.rotationEuler);const x=document.createElement("button");x.type="button",x.className="btn btn-slim",x.textContent="Reset",x.title="Reset translation and rotation to 0",x.addEventListener("click",()=>{const I=M(),N={position:[0,0,0],rotationEuler:[0,0,0],scale:I.scale};I.reference&&(N.reference=I.reference);const D=b(N,!0);p(D);const L=r.params&&Object.prototype.hasOwnProperty.call(r.params,"featureID")?r.params.featureID:r.params?.id??null;typeof r.options.onChange=="function"&&r.options.onChange(L)}),v.appendChild(x);let E=null,w=null;const A=d(()=>{const I=r?.activeTransform;if(!I||I.inputEl!==o||typeof w!="function")return;try{w()}catch{return}const N=d(()=>{try{w()}catch{}},"reopen");typeof queueMicrotask=="function"?queueMicrotask(N):setTimeout(N,0)},"restartActiveTransform");E=d(()=>{if(!c)return null;const I={};return typeof c.stepId=="string"&&(I.stepId=c.stepId),I.get=()=>{if(typeof c.get=="function")try{return u(c.get())}catch{return h()}return h()},I.set=N=>{const D=u(N);if(typeof c.set=="function"){try{c.set(D)}catch{}b(D,!0,{skipWrite:!0})}else b(D,!0);p(D)},typeof c.getBase=="function"&&(I.getBase=()=>{try{return c.getBase()}catch{return null}}),I},"buildTransformAdapter")(),w=d(()=>r._activateTransformWidget({inputEl:o,wrapEl:a,key:l,def:t,valueAdapter:E}),"activate"),m.addEventListener("click",w),a.appendChild(m);const P=document.createElement("div");if(P.className="transform-details",P.appendChild(v),Array.isArray(t.referenceSelectionFilter)&&t.referenceSelectionFilter.length){const I=document.createElement("div");I.className="transform-reference-section";const N=document.createElement("div");N.className="transform-label",N.textContent=String(t.referenceLabel||"Reference"),I.appendChild(N);const D=document.createElement("div");D.className="transform-reference-control",I.appendChild(D);const L=d((X,O={})=>{const{shouldEmit:W=!1,shouldRestart:G=!1}=O,z={...M()};X?z.reference=X:delete z.reference;const Z=b(z,!0);W&&p(Z),G&&A()},"applyReferenceValue"),H={read:d(()=>h().reference||null,"read"),write:d(X=>{const O=h().reference||null,W=Nr(O),G=Nr(X);if(typeof X=="string"&&O&&typeof O=="object"&&W&&W===G){L(O);return}L(X)},"write"),emit:d(X=>{const O=h().reference||null,W=Nr(O),G=Nr(X);if(typeof X=="string"&&O&&typeof O=="object"&&W&&W===G){L(O,{shouldEmit:!0,shouldRestart:!0});return}L(X,{shouldEmit:!0,shouldRestart:!0})},"emit")};sm({ui:r,key:`${e}.reference`,def:{type:"reference_selection",label:String(t.referenceLabel||"Reference"),placeholder:String(t.referencePlaceholder||"Click then select in scene…"),selectionFilter:t.referenceSelectionFilter.slice(),multiple:!1,selectionValidator:t.referenceSelectionValidator,selectionValidationMessage:t.referenceSelectionValidationMessage},id:`${n}__reference`,controlWrap:D,valueAdapter:H}),P.appendChild(I)}return P.appendChild(C),P.appendChild(y),a.appendChild(P),a.appendChild(o),i.appendChild(a),{inputEl:o,activate:w,readValue(){return h()}}}d(aR,"renderTransformField");function cR({ui:r,key:e,def:t,controlWrap:n}){!r.params[e]||typeof r.params[e]!="object"?r.params[e]={targets:[],operation:"NONE",overlapConditioningEnabled:!0}:(Array.isArray(r.params[e].targets)||(r.params[e].targets=[]),r.params[e].operation||(r.params[e].operation="NONE"),typeof r.params[e].overlapConditioningEnabled!="boolean"&&(r.params[e].overlapConditioningEnabled=!0));const i=document.createElement("div");i.className="bool-op-wrap";const s=document.createElement("select");s.className="select",s.dataset.role="bool-op";const o=Array.isArray(t.options)&&t.options.length?t.options:["NONE","UNION","SUBTRACT","INTERSECT"];for(const m of o){const y=document.createElement("option");y.value=String(m),y.textContent=String(m),s.appendChild(y)}s.value=String(r.params[e].operation||"NONE"),s.addEventListener("change",()=>{(!r.params[e]||typeof r.params[e]!="object")&&(r.params[e]={targets:[],operation:"NONE",overlapConditioningEnabled:!0});const m=String(s.value||"NONE").toUpperCase();if(r.params[e].operation=m,r._emitParamsChange(e,r.params[e]),m==="NONE")return;const y=d(()=>{try{p?.activate?.()}catch{}},"activateTargets");typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>y()):setTimeout(y,0)}),i.appendChild(s);const a=document.createElement("label");a.style.display="flex",a.style.alignItems="center",a.style.gap="8px",a.style.margin="8px 0 6px",a.style.color="var(--text-color, #e6edf3)",a.style.fontSize="12px";const c=document.createElement("input");c.type="checkbox",c.checked=r.params[e].overlapConditioningEnabled!==!1,c.addEventListener("change",()=>{(!r.params[e]||typeof r.params[e]!="object")&&(r.params[e]={targets:[],operation:"NONE",overlapConditioningEnabled:!0}),r.params[e].overlapConditioningEnabled=c.checked,r._emitParamsChange(e,r.params[e])});const l=document.createElement("span");l.textContent="Condition touching coplanar faces",a.appendChild(c),a.appendChild(l),i.appendChild(a);const u=document.createElement("div"),h={type:"reference_selection",multiple:!0,selectionFilter:["SOLID"]},f={read:d(()=>{const m=r.params[e];return!m||typeof m!="object"?[]:Array.isArray(m.targets)?m.targets:[]},"read"),write:d(m=>{(!r.params[e]||typeof r.params[e]!="object")&&(r.params[e]={targets:[],operation:s.value||"NONE",overlapConditioningEnabled:c.checked}),r.params[e].targets=Array.isArray(m)?m:[]},"write"),emit:d(()=>{r._emitParamsChange(e,r.params[e])},"emit")},p=sm({ui:r,key:e,def:h,id:`${e}-targets`,controlWrap:u,valueAdapter:f});return i.appendChild(u),n.appendChild(i),{inputEl:p.inputEl,activate:p.activate,readValue(){const m=r.params[e];return!m||typeof m!="object"?{targets:[],operation:"NONE",overlapConditioningEnabled:!0}:{targets:Array.isArray(m.targets)?m.targets.slice():[],operation:m.operation||"NONE",overlapConditioningEnabled:m.overlapConditioningEnabled!==!1}}}}d(cR,"renderBooleanOperationField");function lR({ui:r,key:e,def:t,id:n}){const i=document.createElement("input");return i.type="text",i.id=n,i.className="input",r._setInputValue(i,t.type,r._pickInitialValue(e,t)),i.addEventListener("change",()=>{r.params[e]=i.value,r._emitParamsChange(e,i.value),r._stopActiveReferenceSelection()}),{inputEl:i,activate(){i.focus()},readValue(){return i.value}}}d(lR,"renderStringField");function uR({ui:r,key:e,def:t,id:n}){const i=document.createElement("input");return i.type="checkbox",i.id=n,i.className="checkbox",r._setInputValue(i,"boolean",r._pickInitialValue(e,t)),i.addEventListener("change",()=>{const s=!!i.checked;r.params[e]=s,r._emitParamsChange(e,s),r._stopActiveReferenceSelection()}),{inputEl:i,activate(){i.focus()},readValue(){return!!i.checked}}}d(uR,"renderBooleanField");function hR({ui:r,key:e,def:t,id:n}){const i=document.createElement("select");i.id=n,i.className="select";const s=Array.isArray(t.options)?t.options:[];for(let o=0;o<s.length;o++){const a=s[o],c=document.createElement("option");c.value=String(a),c.textContent=String(a),i.appendChild(c)}return r._setInputValue(i,"options",r._pickInitialValue(e,t)),i.addEventListener("change",()=>{const o=i.value;r.params[e]=o,r._emitParamsChange(e,o),r._stopActiveReferenceSelection()}),{inputEl:i,activate(){i.focus()},readValue(){return i.value}}}d(hR,"renderOptionsField");function fR({ui:r,key:e,def:t}){const n=document.createElement("div");n.className="transform-grid";const i=!!(t&&t.uniformToggle===!0);let s=!!(t&&t.uniformDefault===!0),o=null;if(i){const g=document.createElement("div");g.className="transform-row";const v=document.createElement("div");v.className="transform-label",v.textContent="";const M=document.createElement("div");M.className="transform-inputs";const b=document.createElement("label");b.style.display="inline-flex",b.style.alignItems="center",b.style.gap="6px",o=document.createElement("input"),o.type="checkbox",o.checked=s;const C=document.createElement("span");C.textContent=String(t.uniformLockLabel||"Uniform"),b.appendChild(o),b.appendChild(C),M.appendChild(b),g.appendChild(v),g.appendChild(M),n.appendChild(g)}const a=d(g=>{const v=document.createElement("div");v.className="transform-row";const M=document.createElement("div");M.className="transform-label",M.textContent=g;const b=document.createElement("div");return b.className="transform-inputs",v.appendChild(M),v.appendChild(b),{rowEl:v,inputsWrap:b}},"mkRow"),{rowEl:c,inputsWrap:l}=a("XYZ");n.appendChild(c);const u=(()=>{const g=r._pickInitialValue(e,t);return Array.isArray(g)?[g[0]??0,g[1]??0,g[2]??0]:g&&typeof g=="object"?[g.x??0,g.y??0,g.z??0]:[0,0,0]})(),h=t&&t.step!=null?String(t.step):"any",f=d(()=>{const v=Array.from(l.querySelectorAll("input")).map(M=>M.value);r.params[e]=[v[0],v[1],v[2]],r._emitParamsChange(e,r.params[e])},"setParamFromInputs"),p=[],m=/^-?\d*\.?\d*$/,y=d(g=>g===""||g==null?!0:m.test(String(g)),"isNumericLike"),_=d(g=>{try{y(g.value)?g.type="number":g.type="text"}catch{}},"toggleTypeForContent");for(let g=0;g<3;g++){const v=document.createElement("input");v.type="number",v.className="input transform-input",v.step=h,r._setInputValue(v,"number",u[g]??0),v.addEventListener("focus",()=>_(v)),v.addEventListener("beforeinput",M=>{try{const b=String(v.value||"")+String(M.data||"");y(b)?v.type!=="number"&&(v.type="number"):v.type!=="text"&&(v.type="text")}catch{}}),v.addEventListener("change",()=>{if(i&&o&&o.checked){const M=v.value;for(const b of l.querySelectorAll("input"))b.value=M}f()}),l.appendChild(v),p.push(v)}if(i&&o){const g=d(()=>{if(o.checked&&p.length){const v=p[0].value;for(let M=0;M<p.length;M++)p[M].value=String(v);f()}},"enforceUniformNow");o.addEventListener("change",()=>g()),s&&g()}return{inputEl:n,activate(){const g=n.querySelector("input");g&&g.focus()},readValue(){const g=r.params[e];return Array.isArray(g)?g.slice(0,3):g&&typeof g=="object"?[g.x??0,g.y??0,g.z??0]:[0,0,0]}}}d(fR,"renderVec3Field");function dR({ui:r,key:e,def:t,id:n,controlWrap:i}){const s=document.createElement("button");s.type="button",s.id=n,s.className="btn",s.textContent=String(t.label||"Choose File…");const o=document.createElement("div");o.className="file-info";const a=r._pickInitialValue(e,t);if(typeof a=="string"&&a.startsWith("data:")&&a.includes(";base64,")){const l=a.split(",")[1]||"",u=Math.floor(l.length*3/4);o.textContent=`Loaded (${u} bytes)`}else a&&String(a).length?o.textContent=`Loaded (${String(a).length} chars)`:o.textContent="No file selected";const c=document.createElement("input");return c.type="file",c.style.display="none",t&&t.accept&&c.setAttribute("accept",String(t.accept)),s.addEventListener("click",l=>{l.preventDefault(),c.click()}),c.addEventListener("change",async()=>{const l=c.files&&c.files[0];if(l)try{const u=await l.arrayBuffer(),h=new Uint8Array(u);let f="";const p=32768;for(let g=0;g<h.length;g+=p){const v=h.subarray(g,g+p);f+=String.fromCharCode.apply(null,v)}const m=typeof btoa=="function"?btoa(f):typeof globalThis.Buffer<"u"?globalThis.Buffer.from(h).toString("base64"):"",_=`data:${l.type&&l.type.length?l.type:"application/octet-stream"};base64,${m}`;r.params[e]=_,o.textContent=`${l.name} (${h.length} bytes)`,r._emitParamsChange(e,_)}catch(u){o.textContent=`Failed to read file: ${u?.message||u}`}}),i.appendChild(o),i.appendChild(c),{inputEl:s,activate(){c.click()},readValue(){return r.params[e]??null}}}d(dR,"renderFileField");function pR({ui:r,key:e,def:t,id:n}){const i=document.createElement("input");return i.type="text",i.id=n,i.className="input",r._setInputValue(i,"string",r._pickInitialValue(e,t)),i.addEventListener("change",()=>{r.params[e]=i.value,r._emitParamsChange(e,i.value)}),{inputEl:i,activate(){i.focus()},readValue(){return i.value}}}d(pR,"renderDefaultField");function mR(r){const e={},t=String(r?.source||"").trim().toLowerCase(),n=String(r?.repoFull||"").trim(),i=String(r?.branch||"").trim(),s=String(r?.path||r?.name||"").trim();return(t==="github"||t==="local")&&(e.source=t),n&&(e.repoFull=n),i&&(e.branch=i),s&&(e.path=s),e}d(mR,"buildScope");function gR({title:r="Select Component"}={}){return new Promise(e=>{let t=null,n=!1;const i=document.createElement("div");i.className="component-selector-overlay";const s=document.createElement("section");s.className="component-selector-panel";const o=document.createElement("div");o.className="cs-header",o.textContent=r;const a=document.createElement("div");a.className="cs-body";const c=document.createElement("div");c.className="cs-browser-mount",a.appendChild(c);const l=document.createElement("div");l.className="cs-footer";const u=document.createElement("button");u.type="button",u.className="cs-btn",u.textContent="Cancel",l.appendChild(u),s.appendChild(o),s.appendChild(a),s.appendChild(l),i.appendChild(s),document.body.appendChild(i);const h=d(p=>{if(!n){n=!0;try{t?.destroy?.()}catch{}try{document.removeEventListener("keydown",f,!0)}catch{}try{document.body.removeChild(i)}catch{}e(p??null)}},"cleanup"),f=d(p=>{p.key==="Escape"&&(p.preventDefault(),p.stopPropagation(),h(null))},"onKeyDown");document.addEventListener("keydown",f,!0),u.addEventListener("click",()=>h(null)),i.addEventListener("click",p=>{p.target===i&&h(null)}),t=new Xb({container:c,onPickFile:d(async p=>{const m=String(p?.path||p?.name||"").trim();if(!m)return;const y=await qb(m,mR(p));if(!y||!y.data3mf)throw new Error("Failed to load selected component");h(y)},"onPickFile"),scrollBody:!0}),t.reload()})}d(gR,"openComponentSelectorModal");d((function(){if(typeof document>"u"||document.getElementById("component-selector-styles"))return;const e=document.createElement("style");e.id="component-selector-styles",e.textContent=`
|
|
4637
4637
|
.component-selector-overlay {
|
|
4638
4638
|
position: fixed;
|
|
4639
4639
|
inset: 0;
|