r3f-frame-profiler 1.0.1 → 1.0.3
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/cjs/index.js +1 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +7 -12485
- package/dist/esm/index.js.map +1 -1
- package/dist/index-D_LaF0YP.cjs +2 -0
- package/dist/index-D_LaF0YP.cjs.map +1 -0
- package/dist/index-o5zvhDta.js +4406 -0
- package/dist/index-o5zvhDta.js.map +1 -0
- package/dist/report-generator-BCq_enQo.js +283 -0
- package/dist/report-generator-BCq_enQo.js.map +1 -0
- package/dist/report-generator-BsoP53qp.cjs +61 -0
- package/dist/report-generator-BsoP53qp.cjs.map +1 -0
- package/dist/types/FrameProfiler.d.ts +2 -0
- package/dist/types/FrameProfiler.d.ts.map +1 -0
- package/dist/types/collectors/frame-time-collector.d.ts +41 -0
- package/dist/types/collectors/frame-time-collector.d.ts.map +1 -0
- package/dist/types/collectors/gpu-collector.d.ts +32 -0
- package/dist/types/collectors/gpu-collector.d.ts.map +1 -0
- package/dist/types/collectors/hot-path-detector.d.ts +42 -0
- package/dist/types/collectors/hot-path-detector.d.ts.map +1 -0
- package/dist/types/collectors/index.d.ts +7 -0
- package/dist/types/collectors/index.d.ts.map +1 -0
- package/dist/types/collectors/memory-collector.d.ts +49 -0
- package/dist/types/collectors/memory-collector.d.ts.map +1 -0
- package/dist/types/collectors/scene-collector.d.ts +47 -0
- package/dist/types/collectors/scene-collector.d.ts.map +1 -0
- package/dist/types/components/ReactProfiler.d.ts +12 -0
- package/dist/types/components/ReactProfiler.d.ts.map +1 -0
- package/dist/types/core/alert-system.d.ts +37 -0
- package/dist/types/core/alert-system.d.ts.map +1 -0
- package/dist/types/core/auto-instrumentation.d.ts +33 -0
- package/dist/types/core/auto-instrumentation.d.ts.map +1 -0
- package/dist/types/core/budget-manager.d.ts +78 -0
- package/dist/types/core/budget-manager.d.ts.map +1 -0
- package/dist/types/core/data-export.d.ts +24 -0
- package/dist/types/core/data-export.d.ts.map +1 -0
- package/dist/types/core/index.d.ts +4 -0
- package/dist/types/core/index.d.ts.map +1 -0
- package/dist/types/core/monitor-state.d.ts +21 -0
- package/dist/types/core/monitor-state.d.ts.map +1 -0
- package/dist/types/core/profiler.d.ts +83 -0
- package/dist/types/core/profiler.d.ts.map +1 -0
- package/dist/types/core/react-monitor.d.ts +51 -0
- package/dist/types/core/react-monitor.d.ts.map +1 -0
- package/dist/types/core/report-generator.d.ts +83 -0
- package/dist/types/core/report-generator.d.ts.map +1 -0
- package/dist/types/hooks/index.d.ts +17 -0
- package/dist/types/hooks/index.d.ts.map +1 -0
- package/dist/types/hooks/useAlerts.d.ts +11 -0
- package/dist/types/hooks/useAlerts.d.ts.map +1 -0
- package/dist/types/hooks/useBudgetChecker.d.ts +6 -0
- package/dist/types/hooks/useBudgetChecker.d.ts.map +1 -0
- package/dist/types/hooks/useFrameHistory.d.ts +2 -0
- package/dist/types/hooks/useFrameHistory.d.ts.map +1 -0
- package/dist/types/hooks/useFrameTime.d.ts +3 -0
- package/dist/types/hooks/useFrameTime.d.ts.map +1 -0
- package/dist/types/hooks/useGPUStats.d.ts +3 -0
- package/dist/types/hooks/useGPUStats.d.ts.map +1 -0
- package/dist/types/hooks/useHotPath.d.ts +3 -0
- package/dist/types/hooks/useHotPath.d.ts.map +1 -0
- package/dist/types/hooks/useMemoryHistory.d.ts +5 -0
- package/dist/types/hooks/useMemoryHistory.d.ts.map +1 -0
- package/dist/types/hooks/useMemoryStats.d.ts +3 -0
- package/dist/types/hooks/useMemoryStats.d.ts.map +1 -0
- package/dist/types/hooks/useMetricsCollector.d.ts +31 -0
- package/dist/types/hooks/useMetricsCollector.d.ts.map +1 -0
- package/dist/types/hooks/usePerformanceBudget.d.ts +20 -0
- package/dist/types/hooks/usePerformanceBudget.d.ts.map +1 -0
- package/dist/types/hooks/useProfiler.d.ts +5 -0
- package/dist/types/hooks/useProfiler.d.ts.map +1 -0
- package/dist/types/hooks/useR3FProfiler.d.ts +2 -0
- package/dist/types/hooks/useR3FProfiler.d.ts.map +1 -0
- package/dist/types/hooks/useR3FProfilerCollector.d.ts +2 -0
- package/dist/types/hooks/useR3FProfilerCollector.d.ts.map +1 -0
- package/dist/types/hooks/useR3FStatsCollector.d.ts +2 -0
- package/dist/types/hooks/useR3FStatsCollector.d.ts.map +1 -0
- package/dist/types/hooks/useReactProfiler.d.ts +3 -0
- package/dist/types/hooks/useReactProfiler.d.ts.map +1 -0
- package/dist/types/hooks/useReportMetric.d.ts +19 -0
- package/dist/types/hooks/useReportMetric.d.ts.map +1 -0
- package/dist/types/hooks/useSceneStats.d.ts +3 -0
- package/dist/types/hooks/useSceneStats.d.ts.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/ui/PerformanceMonitor.d.ts +7 -0
- package/dist/types/ui/PerformanceMonitor.d.ts.map +1 -0
- package/dist/types/ui/components/AlertBadge.d.ts +9 -0
- package/dist/types/ui/components/AlertBadge.d.ts.map +1 -0
- package/dist/types/ui/components/MetricCard.d.ts +14 -0
- package/dist/types/ui/components/MetricCard.d.ts.map +1 -0
- package/dist/types/ui/components/SimpleChart.d.ts +13 -0
- package/dist/types/ui/components/SimpleChart.d.ts.map +1 -0
- package/dist/types/ui/components/Tabs.d.ts +15 -0
- package/dist/types/ui/components/Tabs.d.ts.map +1 -0
- package/dist/types/ui/components/index.d.ts +5 -0
- package/dist/types/ui/components/index.d.ts.map +1 -0
- package/dist/types/ui/panels/BudgetPanel.d.ts +2 -0
- package/dist/types/ui/panels/BudgetPanel.d.ts.map +1 -0
- package/dist/types/ui/panels/FramePanel.d.ts +2 -0
- package/dist/types/ui/panels/FramePanel.d.ts.map +1 -0
- package/dist/types/ui/panels/FrameTimePanel.d.ts +2 -0
- package/dist/types/ui/panels/FrameTimePanel.d.ts.map +1 -0
- package/dist/types/ui/panels/GPUPanel.d.ts +2 -0
- package/dist/types/ui/panels/GPUPanel.d.ts.map +1 -0
- package/dist/types/ui/panels/HotPathPanel.d.ts +2 -0
- package/dist/types/ui/panels/HotPathPanel.d.ts.map +1 -0
- package/dist/types/ui/panels/MemoryPanel.d.ts +2 -0
- package/dist/types/ui/panels/MemoryPanel.d.ts.map +1 -0
- package/dist/types/ui/panels/ReactPanel.d.ts +2 -0
- package/dist/types/ui/panels/ReactPanel.d.ts.map +1 -0
- package/dist/types/ui/panels/ScenePanel.d.ts +2 -0
- package/dist/types/ui/panels/ScenePanel.d.ts.map +1 -0
- package/dist/types/ui/panels/index.d.ts +9 -0
- package/dist/types/ui/panels/index.d.ts.map +1 -0
- package/dist/types/ui/styles/theme.d.ts +76 -0
- package/dist/types/ui/styles/theme.d.ts.map +1 -0
- package/dist/types/ui/visualizations/FrameGraph.d.ts +10 -0
- package/dist/types/ui/visualizations/FrameGraph.d.ts.map +1 -0
- package/dist/types/ui/visualizations/MemoryChart.d.ts +10 -0
- package/dist/types/ui/visualizations/MemoryChart.d.ts.map +1 -0
- package/dist/types/ui/visualizations/PerformanceChart.d.ts +16 -0
- package/dist/types/ui/visualizations/PerformanceChart.d.ts.map +1 -0
- package/dist/types/ui/visualizations/TimelineView.d.ts +7 -0
- package/dist/types/ui/visualizations/TimelineView.d.ts.map +1 -0
- package/dist/types/ui/visualizations/index.d.ts +5 -0
- package/dist/types/ui/visualizations/index.d.ts.map +1 -0
- package/package.json +14 -7
- package/README.md +0 -60
package/dist/cjs/index.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
"use strict";Object.
|
|
2
|
-
`);for(let s=3;s<Math.min(e.length,15);s++){const r=e[s].match(/\s+at\s+(\w+)/);if(r&&r[1]){const o=r[1];if(o!=="useProfiledFrame"&&o!=="useFrame"&&o!=="Object"&&o!=="getComponentName"&&!o.startsWith("_")&&o.length>1)return o}}}catch{}return"Unknown"}const ei=()=>{const c=z.useRef(performance.now());return ve.useFrame(()=>{if(I.isEnabled()){const t=performance.now(),e=t-c.current;c.current=t,I.record("Frame",e),I.notify()}else c.current=performance.now()}),null};class si{renderer=null;lastStats=null;frameStartTime=0;setRenderer(t){this.renderer=t}getStats(){if(!this.renderer)return null;const t=this.renderer.info,e=t.memory,s=t.render,i="points"in s?s.points:0,r="lines"in s?s.lines:0;let o=0,a=0;if(e.textures&&this.renderer)try{o=e.textures*2*1024*1024}catch{o=e.textures*1024*1024}if(e.geometries&&this.renderer)try{a=(this.renderer.info.render.triangles||0)*100,a+=e.geometries*10*1024}catch{a=e.geometries*100*1024}const h={drawCalls:s.calls||0,triangles:s.triangles||0,points:i||0,lines:r||0,textures:e.textures||0,geometries:e.geometries||0,programs:t.programs?.length||0,memory:{textures:o,geometries:a,programs:0,total:o+a},frameTime:performance.now()-this.frameStartTime,timestamp:performance.now()};return this.lastStats=h,h}startFrame(){this.frameStartTime=performance.now()}endFrame(){}getLastStats(){return this.lastStats}reset(){this.lastStats=null}}const Gt=new si;const Ps="182",Xe=0,ii=1,es=1,ss=100,is=204,rs=205,ns=3,ri=0,Es=300,os=1e3,oe=1001,as=1002,ni=1006,oi=1008,ai=1009,li=1015,hi=1023,Ds="",tt="srgb",ls="srgb-linear",hs="linear",Fe="srgb",_t=7680,cs=519,ds=35044,Xt=2e3,us=2001;function ci(c){for(let t=c.length-1;t>=0;--t)if(c[t]>=65535)return!0;return!1}function ms(c){return document.createElementNS("http://www.w3.org/1999/xhtml",c)}const ps={};function H(...c){const t="THREE."+c.shift();console.warn(t,...c)}function Ft(...c){const t="THREE."+c.shift();console.error(t,...c)}function fs(...c){const t=c.join(" ");t in ps||(ps[t]=!0,H(...c))}class Ae{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const s=this._listeners;s[t]===void 0&&(s[t]=[]),s[t].indexOf(e)===-1&&s[t].push(e)}hasEventListener(t,e){const s=this._listeners;return s===void 0?!1:s[t]!==void 0&&s[t].indexOf(e)!==-1}removeEventListener(t,e){const s=this._listeners;if(s===void 0)return;const i=s[t];if(i!==void 0){const r=i.indexOf(e);r!==-1&&i.splice(r,1)}}dispatchEvent(t){const e=this._listeners;if(e===void 0)return;const s=e[t.type];if(s!==void 0){t.target=this;const i=s.slice(0);for(let r=0,o=i.length;r<o;r++)i[r].call(this,t);t.target=null}}}const O=["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"];function Jt(){const c=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(O[c&255]+O[c>>8&255]+O[c>>16&255]+O[c>>24&255]+"-"+O[t&255]+O[t>>8&255]+"-"+O[t>>16&15|64]+O[t>>24&255]+"-"+O[e&63|128]+O[e>>8&255]+"-"+O[e>>16&255]+O[e>>24&255]+O[s&255]+O[s>>8&255]+O[s>>16&255]+O[s>>24&255]).toLowerCase()}function k(c,t,e){return Math.max(t,Math.min(e,c))}function di(c,t){return(c%t+t)%t}function Te(c,t,e){return(1-e)*c+e*t}function Ht(c,t){switch(t.constructor){case Float32Array:return c;case Uint32Array:return c/4294967295;case Uint16Array:return c/65535;case Uint8Array:return c/255;case Int32Array:return Math.max(c/2147483647,-1);case Int16Array:return Math.max(c/32767,-1);case Int8Array:return Math.max(c/127,-1);default:throw new Error("Invalid component type.")}}function N(c,t){switch(t.constructor){case Float32Array:return c;case Uint32Array:return Math.round(c*4294967295);case Uint16Array:return Math.round(c*65535);case Uint8Array:return Math.round(c*255);case Int32Array:return Math.round(c*2147483647);case Int16Array:return Math.round(c*32767);case Int8Array:return Math.round(c*127);default:throw new Error("Invalid component type.")}}class st{constructor(t=0,e=0){st.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,s=this.y,i=t.elements;return this.x=i[0]*e+i[3]*s+i[6],this.y=i[1]*e+i[4]*s+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=k(this.x,t.x,e.x),this.y=k(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=k(this.x,t,e),this.y=k(this.y,t,e),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(k(s,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const s=this.dot(t)/e;return Math.acos(k(s,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y;return e*e+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const s=Math.cos(e),i=Math.sin(e),r=this.x-t.x,o=this.y-t.y;return this.x=r*s-o*i+t.x,this.y=r*i+o*s+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Zt{constructor(t=0,e=0,s=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=s,this._w=i}static slerpFlat(t,e,s,i,r,o,a){let h=s[i+0],n=s[i+1],d=s[i+2],m=s[i+3],u=r[o+0],p=r[o+1],f=r[o+2],x=r[o+3];if(a<=0){t[e+0]=h,t[e+1]=n,t[e+2]=d,t[e+3]=m;return}if(a>=1){t[e+0]=u,t[e+1]=p,t[e+2]=f,t[e+3]=x;return}if(m!==x||h!==u||n!==p||d!==f){let g=h*u+n*p+d*f+m*x;g<0&&(u=-u,p=-p,f=-f,x=-x,g=-g);let y=1-a;if(g<.9995){const w=Math.acos(g),M=Math.sin(w);y=Math.sin(y*w)/M,a=Math.sin(a*w)/M,h=h*y+u*a,n=n*y+p*a,d=d*y+f*a,m=m*y+x*a}else{h=h*y+u*a,n=n*y+p*a,d=d*y+f*a,m=m*y+x*a;const w=1/Math.sqrt(h*h+n*n+d*d+m*m);h*=w,n*=w,d*=w,m*=w}}t[e]=h,t[e+1]=n,t[e+2]=d,t[e+3]=m}static multiplyQuaternionsFlat(t,e,s,i,r,o){const a=s[i],h=s[i+1],n=s[i+2],d=s[i+3],m=r[o],u=r[o+1],p=r[o+2],f=r[o+3];return t[e]=a*f+d*m+h*p-n*u,t[e+1]=h*f+d*u+n*m-a*p,t[e+2]=n*f+d*p+a*u-h*m,t[e+3]=d*f-a*m-h*u-n*p,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,s,i){return this._x=t,this._y=e,this._z=s,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const s=t._x,i=t._y,r=t._z,o=t._order,a=Math.cos,h=Math.sin,n=a(s/2),d=a(i/2),m=a(r/2),u=h(s/2),p=h(i/2),f=h(r/2);switch(o){case"XYZ":this._x=u*d*m+n*p*f,this._y=n*p*m-u*d*f,this._z=n*d*f+u*p*m,this._w=n*d*m-u*p*f;break;case"YXZ":this._x=u*d*m+n*p*f,this._y=n*p*m-u*d*f,this._z=n*d*f-u*p*m,this._w=n*d*m+u*p*f;break;case"ZXY":this._x=u*d*m-n*p*f,this._y=n*p*m+u*d*f,this._z=n*d*f+u*p*m,this._w=n*d*m-u*p*f;break;case"ZYX":this._x=u*d*m-n*p*f,this._y=n*p*m+u*d*f,this._z=n*d*f-u*p*m,this._w=n*d*m+u*p*f;break;case"YZX":this._x=u*d*m+n*p*f,this._y=n*p*m+u*d*f,this._z=n*d*f-u*p*m,this._w=n*d*m-u*p*f;break;case"XZY":this._x=u*d*m-n*p*f,this._y=n*p*m-u*d*f,this._z=n*d*f+u*p*m,this._w=n*d*m+u*p*f;break;default:H("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const s=e/2,i=Math.sin(s);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(s),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,s=e[0],i=e[4],r=e[8],o=e[1],a=e[5],h=e[9],n=e[2],d=e[6],m=e[10],u=s+a+m;if(u>0){const p=.5/Math.sqrt(u+1);this._w=.25/p,this._x=(d-h)*p,this._y=(r-n)*p,this._z=(o-i)*p}else if(s>a&&s>m){const p=2*Math.sqrt(1+s-a-m);this._w=(d-h)/p,this._x=.25*p,this._y=(i+o)/p,this._z=(r+n)/p}else if(a>m){const p=2*Math.sqrt(1+a-s-m);this._w=(r-n)/p,this._x=(i+o)/p,this._y=.25*p,this._z=(h+d)/p}else{const p=2*Math.sqrt(1+m-s-a);this._w=(o-i)/p,this._x=(r+n)/p,this._y=(h+d)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let s=t.dot(e)+1;return s<1e-8?(s=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=s):(this._x=0,this._y=-t.z,this._z=t.y,this._w=s)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=s),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(k(this.dot(t),-1,1)))}rotateTowards(t,e){const s=this.angleTo(t);if(s===0)return this;const i=Math.min(1,e/s);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const s=t._x,i=t._y,r=t._z,o=t._w,a=e._x,h=e._y,n=e._z,d=e._w;return this._x=s*d+o*a+i*n-r*h,this._y=i*d+o*h+r*a-s*n,this._z=r*d+o*n+s*h-i*a,this._w=o*d-s*a-i*h-r*n,this._onChangeCallback(),this}slerp(t,e){if(e<=0)return this;if(e>=1)return this.copy(t);let s=t._x,i=t._y,r=t._z,o=t._w,a=this.dot(t);a<0&&(s=-s,i=-i,r=-r,o=-o,a=-a);let h=1-e;if(a<.9995){const n=Math.acos(a),d=Math.sin(n);h=Math.sin(h*n)/d,e=Math.sin(e*n)/d,this._x=this._x*h+s*e,this._y=this._y*h+i*e,this._z=this._z*h+r*e,this._w=this._w*h+o*e,this._onChangeCallback()}else this._x=this._x*h+s*e,this._y=this._y*h+i*e,this._z=this._z*h+r*e,this._w=this._w*h+o*e,this.normalize();return this}slerpQuaternions(t,e,s){return this.copy(t).slerp(e,s)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),s=Math.random(),i=Math.sqrt(1-s),r=Math.sqrt(s);return this.set(i*Math.sin(t),i*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class S{constructor(t=0,e=0,s=0){S.prototype.isVector3=!0,this.x=t,this.y=e,this.z=s}set(t,e,s){return s===void 0&&(s=this.z),this.x=t,this.y=e,this.z=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(gs.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(gs.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,s=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[3]*s+r[6]*i,this.y=r[1]*e+r[4]*s+r[7]*i,this.z=r[2]*e+r[5]*s+r[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,s=this.y,i=this.z,r=t.elements,o=1/(r[3]*e+r[7]*s+r[11]*i+r[15]);return this.x=(r[0]*e+r[4]*s+r[8]*i+r[12])*o,this.y=(r[1]*e+r[5]*s+r[9]*i+r[13])*o,this.z=(r[2]*e+r[6]*s+r[10]*i+r[14])*o,this}applyQuaternion(t){const e=this.x,s=this.y,i=this.z,r=t.x,o=t.y,a=t.z,h=t.w,n=2*(o*i-a*s),d=2*(a*e-r*i),m=2*(r*s-o*e);return this.x=e+h*n+o*m-a*d,this.y=s+h*d+a*n-r*m,this.z=i+h*m+r*d-o*n,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,s=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[4]*s+r[8]*i,this.y=r[1]*e+r[5]*s+r[9]*i,this.z=r[2]*e+r[6]*s+r[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=k(this.x,t.x,e.x),this.y=k(this.y,t.y,e.y),this.z=k(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=k(this.x,t,e),this.y=k(this.y,t,e),this.z=k(this.z,t,e),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(k(s,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const s=t.x,i=t.y,r=t.z,o=e.x,a=e.y,h=e.z;return this.x=i*h-r*a,this.y=r*o-s*h,this.z=s*a-i*o,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const s=t.dot(this)/e;return this.copy(t).multiplyScalar(s)}projectOnPlane(t){return _e.copy(this).projectOnVector(t),this.sub(_e)}reflect(t){return this.sub(_e.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const s=this.dot(t)/e;return Math.acos(k(s,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y,i=this.z-t.z;return e*e+s*s+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,s){const i=Math.sin(e)*t;return this.x=i*Math.sin(s),this.y=Math.cos(e)*t,this.z=i*Math.cos(s),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,s){return this.x=t*Math.sin(e),this.y=s,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),s=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=s,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,s=Math.sqrt(1-e*e);return this.x=s*Math.cos(t),this.y=e,this.z=s*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const _e=new S,gs=new Zt;class Mt{constructor(t,e,s,i,r,o,a,h,n){Mt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,s,i,r,o,a,h,n)}set(t,e,s,i,r,o,a,h,n){const d=this.elements;return d[0]=t,d[1]=i,d[2]=a,d[3]=e,d[4]=r,d[5]=h,d[6]=s,d[7]=o,d[8]=n,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],this}extractBasis(t,e,s){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,i=e.elements,r=this.elements,o=s[0],a=s[3],h=s[6],n=s[1],d=s[4],m=s[7],u=s[2],p=s[5],f=s[8],x=i[0],g=i[3],y=i[6],w=i[1],M=i[4],b=i[7],v=i[2],F=i[5],A=i[8];return r[0]=o*x+a*w+h*v,r[3]=o*g+a*M+h*F,r[6]=o*y+a*b+h*A,r[1]=n*x+d*w+m*v,r[4]=n*g+d*M+m*F,r[7]=n*y+d*b+m*A,r[2]=u*x+p*w+f*v,r[5]=u*g+p*M+f*F,r[8]=u*y+p*b+f*A,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],s=t[1],i=t[2],r=t[3],o=t[4],a=t[5],h=t[6],n=t[7],d=t[8];return e*o*d-e*a*n-s*r*d+s*a*h+i*r*n-i*o*h}invert(){const t=this.elements,e=t[0],s=t[1],i=t[2],r=t[3],o=t[4],a=t[5],h=t[6],n=t[7],d=t[8],m=d*o-a*n,u=a*h-d*r,p=n*r-o*h,f=e*m+s*u+i*p;if(f===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/f;return t[0]=m*x,t[1]=(i*n-d*s)*x,t[2]=(a*s-i*o)*x,t[3]=u*x,t[4]=(d*e-i*h)*x,t[5]=(i*r-a*e)*x,t[6]=p*x,t[7]=(s*h-n*e)*x,t[8]=(o*e-s*r)*x,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,s,i,r,o,a){const h=Math.cos(r),n=Math.sin(r);return this.set(s*h,s*n,-s*(h*o+n*a)+o+t,-i*n,i*h,-i*(-n*o+h*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(je.makeScale(t,e)),this}rotate(t){return this.premultiply(je.makeRotation(-t)),this}translate(t,e){return this.premultiply(je.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,s,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,s=t.elements;for(let i=0;i<9;i++)if(e[i]!==s[i])return!1;return!0}fromArray(t,e=0){for(let s=0;s<9;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const je=new Mt,ys=new Mt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),xs=new Mt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function ui(){const c={enabled:!0,workingColorSpace:ls,spaces:{},convert:function(i,r,o){return this.enabled===!1||r===o||!r||!o||(this.spaces[r].transfer===Fe&&(i.r=dt(i.r),i.g=dt(i.g),i.b=dt(i.b)),this.spaces[r].primaries!==this.spaces[o].primaries&&(i.applyMatrix3(this.spaces[r].toXYZ),i.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===Fe&&(i.r=Wt(i.r),i.g=Wt(i.g),i.b=Wt(i.b))),i},workingToColorSpace:function(i,r){return this.convert(i,this.workingColorSpace,r)},colorSpaceToWorking:function(i,r){return this.convert(i,r,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===Ds?hs:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,r=this.workingColorSpace){return i.fromArray(this.spaces[r].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,r,o){return i.copy(this.spaces[r].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,r){return fs("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),c.workingToColorSpace(i,r)},toWorkingColorSpace:function(i,r){return fs("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),c.colorSpaceToWorking(i,r)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],s=[.3127,.329];return c.define({[ls]:{primaries:t,whitePoint:s,transfer:hs,toXYZ:ys,fromXYZ:xs,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:tt},outputColorSpaceConfig:{drawingBufferColorSpace:tt}},[tt]:{primaries:t,whitePoint:s,transfer:Fe,toXYZ:ys,fromXYZ:xs,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:tt}}}),c}const J=ui();function dt(c){return c<.04045?c*.0773993808:Math.pow(c*.9478672986+.0521327014,2.4)}function Wt(c){return c<.0031308?c*12.92:1.055*Math.pow(c,.41666)-.055}let jt;class mi{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let s;if(t instanceof HTMLCanvasElement)s=t;else{jt===void 0&&(jt=ms("canvas")),jt.width=t.width,jt.height=t.height;const i=jt.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),s=jt}return s.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=ms("canvas");e.width=t.width,e.height=t.height;const s=e.getContext("2d");s.drawImage(t,0,0,t.width,t.height);const i=s.getImageData(0,0,t.width,t.height),r=i.data;for(let o=0;o<r.length;o++)r[o]=dt(r[o]/255)*255;return s.putImageData(i,0,0),e}else if(t.data){const e=t.data.slice(0);for(let s=0;s<e.length;s++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[s]=Math.floor(dt(e[s]/255)*255):e[s]=dt(e[s]);return{data:e,width:t.width,height:t.height}}else return H("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let pi=0;class fi{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:pi++}),this.uuid=Jt(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):typeof VideoFrame<"u"&&e instanceof VideoFrame?t.set(e.displayHeight,e.displayWidth,0):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const s={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let o=0,a=i.length;o<a;o++)i[o].isDataTexture?r.push(Re(i[o].image)):r.push(Re(i[o]))}else r=Re(i);s.url=r}return e||(t.images[this.uuid]=s),s}}function Re(c){return typeof HTMLImageElement<"u"&&c instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&c instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&c instanceof ImageBitmap?mi.getDataURL(c):c.data?{data:Array.from(c.data),width:c.width,height:c.height,type:c.data.constructor.name}:(H("Texture: Unable to serialize Texture."),{})}let gi=0;const Be=new S;class ut extends Ae{constructor(t=ut.DEFAULT_IMAGE,e=ut.DEFAULT_MAPPING,s=oe,i=oe,r=ni,o=oi,a=hi,h=ai,n=ut.DEFAULT_ANISOTROPY,d=Ds){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:gi++}),this.uuid=Jt(),this.name="",this.source=new fi(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=s,this.wrapT=i,this.magFilter=r,this.minFilter=o,this.anisotropy=n,this.format=a,this.internalFormat=null,this.type=h,this.offset=new st(0,0),this.repeat=new st(1,1),this.center=new st(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Mt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=d,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(Be).x}get height(){return this.source.getSize(Be).y}get depth(){return this.source.getSize(Be).z}get image(){return this.source.data}set image(t=null){this.source.data=t}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(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(const e in t){const s=t[e];if(s===void 0){H(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const i=this[e];if(i===void 0){H(`Texture.setValues(): property '${e}' does not exist.`);continue}i&&s&&i.isVector2&&s.isVector2||i&&s&&i.isVector3&&s.isVector3||i&&s&&i.isMatrix3&&s.isMatrix3?i.copy(s):this[e]=s}}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const s={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).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&&(s.userData=this.userData),e||(t.textures[this.uuid]=s),s}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==Es)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case os:t.x=t.x-Math.floor(t.x);break;case oe:t.x=t.x<0?0:1;break;case as:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case os:t.y=t.y-Math.floor(t.y);break;case oe:t.y=t.y<0?0:1;break;case as:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}ut.DEFAULT_IMAGE=null;ut.DEFAULT_MAPPING=Es;ut.DEFAULT_ANISOTROPY=1;class Qt{constructor(t=0,e=0,s=0,i=1){Qt.prototype.isVector4=!0,this.x=t,this.y=e,this.z=s,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,s,i){return this.x=t,this.y=e,this.z=s,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,s=this.y,i=this.z,r=this.w,o=t.elements;return this.x=o[0]*e+o[4]*s+o[8]*i+o[12]*r,this.y=o[1]*e+o[5]*s+o[9]*i+o[13]*r,this.z=o[2]*e+o[6]*s+o[10]*i+o[14]*r,this.w=o[3]*e+o[7]*s+o[11]*i+o[15]*r,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,s,i,r;const h=t.elements,n=h[0],d=h[4],m=h[8],u=h[1],p=h[5],f=h[9],x=h[2],g=h[6],y=h[10];if(Math.abs(d-u)<.01&&Math.abs(m-x)<.01&&Math.abs(f-g)<.01){if(Math.abs(d+u)<.1&&Math.abs(m+x)<.1&&Math.abs(f+g)<.1&&Math.abs(n+p+y-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const M=(n+1)/2,b=(p+1)/2,v=(y+1)/2,F=(d+u)/4,A=(m+x)/4,R=(f+g)/4;return M>b&&M>v?M<.01?(s=0,i=.707106781,r=.707106781):(s=Math.sqrt(M),i=F/s,r=A/s):b>v?b<.01?(s=.707106781,i=0,r=.707106781):(i=Math.sqrt(b),s=F/i,r=R/i):v<.01?(s=.707106781,i=.707106781,r=0):(r=Math.sqrt(v),s=A/r,i=R/r),this.set(s,i,r,e),this}let w=Math.sqrt((g-f)*(g-f)+(m-x)*(m-x)+(u-d)*(u-d));return Math.abs(w)<.001&&(w=1),this.x=(g-f)/w,this.y=(m-x)/w,this.z=(u-d)/w,this.w=Math.acos((n+p+y-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=k(this.x,t.x,e.x),this.y=k(this.y,t.y,e.y),this.z=k(this.z,t.z,e.z),this.w=k(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=k(this.x,t,e),this.y=k(this.y,t,e),this.z=k(this.z,t,e),this.w=k(this.w,t,e),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(k(s,t,e))}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(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this.w=t.w+(e.w-t.w)*s,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),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}}class Kt{constructor(t=new S(1/0,1/0,1/0),e=new S(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e+=3)this.expandByPoint(Z.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,s=t.count;e<s;e++)this.expandByPoint(Z.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const s=Z.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(s),this.max.copy(t).add(s),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const s=t.geometry;if(s!==void 0){const r=s.getAttribute("position");if(e===!0&&r!==void 0&&t.isInstancedMesh!==!0)for(let o=0,a=r.count;o<a;o++)t.isMesh===!0?t.getVertexPosition(o,Z):Z.fromBufferAttribute(r,o),Z.applyMatrix4(t.matrixWorld),this.expandByPoint(Z);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),ae.copy(t.boundingBox)):(s.boundingBox===null&&s.computeBoundingBox(),ae.copy(s.boundingBox)),ae.applyMatrix4(t.matrixWorld),this.union(ae)}const i=t.children;for(let r=0,o=i.length;r<o;r++)this.expandByObject(i[r],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,Z),Z.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,s;return t.normal.x>0?(e=t.normal.x*this.min.x,s=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,s=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,s+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,s+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,s+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,s+=t.normal.z*this.min.z),e<=-t.constant&&s>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Nt),le.subVectors(this.max,Nt),Rt.subVectors(t.a,Nt),Bt.subVectors(t.b,Nt),kt.subVectors(t.c,Nt),ft.subVectors(Bt,Rt),gt.subVectors(kt,Bt),vt.subVectors(Rt,kt);let e=[0,-ft.z,ft.y,0,-gt.z,gt.y,0,-vt.z,vt.y,ft.z,0,-ft.x,gt.z,0,-gt.x,vt.z,0,-vt.x,-ft.y,ft.x,0,-gt.y,gt.x,0,-vt.y,vt.x,0];return!ke(e,Rt,Bt,kt,le)||(e=[1,0,0,0,1,0,0,0,1],!ke(e,Rt,Bt,kt,le))?!1:(he.crossVectors(ft,gt),e=[he.x,he.y,he.z],ke(e,Rt,Bt,kt,le))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Z).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(Z).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(ot[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),ot[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),ot[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),ot[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),ot[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),ot[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),ot[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),ot[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(ot),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}}const ot=[new S,new S,new S,new S,new S,new S,new S,new S],Z=new S,ae=new Kt,Rt=new S,Bt=new S,kt=new S,ft=new S,gt=new S,vt=new S,Nt=new S,le=new S,he=new S,Ct=new S;function ke(c,t,e,s,i){for(let r=0,o=c.length-3;r<=o;r+=3){Ct.fromArray(c,r);const a=i.x*Math.abs(Ct.x)+i.y*Math.abs(Ct.y)+i.z*Math.abs(Ct.z),h=t.dot(Ct),n=e.dot(Ct),d=s.dot(Ct);if(Math.max(-Math.max(h,n,d),Math.min(h,n,d))>a)return!1}return!0}const yi=new Kt,qt=new S,Pe=new S;class Is{constructor(t=new S,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const s=this.center;e!==void 0?s.copy(e):yi.setFromPoints(t).getCenter(s);let i=0;for(let r=0,o=t.length;r<o;r++)i=Math.max(i,s.distanceToSquared(t[r]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const s=this.center.distanceToSquared(t);return e.copy(t),s>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;qt.subVectors(t,this.center);const e=qt.lengthSq();if(e>this.radius*this.radius){const s=Math.sqrt(e),i=(s-this.radius)*.5;this.center.addScaledVector(qt,i/s),this.radius+=i}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(Pe.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(qt.copy(t.center).add(Pe)),this.expandByPoint(qt.copy(t.center).sub(Pe))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}}const at=new S,Ee=new S,ce=new S,yt=new S,De=new S,de=new S,Ie=new S;class xi{constructor(t=new S,e=new S(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,at)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const s=e.dot(this.direction);return s<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,s)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=at.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(at.copy(this.origin).addScaledVector(this.direction,e),at.distanceToSquared(t))}distanceSqToSegment(t,e,s,i){Ee.copy(t).add(e).multiplyScalar(.5),ce.copy(e).sub(t).normalize(),yt.copy(this.origin).sub(Ee);const r=t.distanceTo(e)*.5,o=-this.direction.dot(ce),a=yt.dot(this.direction),h=-yt.dot(ce),n=yt.lengthSq(),d=Math.abs(1-o*o);let m,u,p,f;if(d>0)if(m=o*h-a,u=o*a-h,f=r*d,m>=0)if(u>=-f)if(u<=f){const x=1/d;m*=x,u*=x,p=m*(m+o*u+2*a)+u*(o*m+u+2*h)+n}else u=r,m=Math.max(0,-(o*u+a)),p=-m*m+u*(u+2*h)+n;else u=-r,m=Math.max(0,-(o*u+a)),p=-m*m+u*(u+2*h)+n;else u<=-f?(m=Math.max(0,-(-o*r+a)),u=m>0?-r:Math.min(Math.max(-r,-h),r),p=-m*m+u*(u+2*h)+n):u<=f?(m=0,u=Math.min(Math.max(-r,-h),r),p=u*(u+2*h)+n):(m=Math.max(0,-(o*r+a)),u=m>0?r:Math.min(Math.max(-r,-h),r),p=-m*m+u*(u+2*h)+n);else u=o>0?-r:r,m=Math.max(0,-(o*u+a)),p=-m*m+u*(u+2*h)+n;return s&&s.copy(this.origin).addScaledVector(this.direction,m),i&&i.copy(Ee).addScaledVector(ce,u),p}intersectSphere(t,e){at.subVectors(t.center,this.origin);const s=at.dot(this.direction),i=at.dot(at)-s*s,r=t.radius*t.radius;if(i>r)return null;const o=Math.sqrt(r-i),a=s-o,h=s+o;return h<0?null:a<0?this.at(h,e):this.at(a,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const s=-(this.origin.dot(t.normal)+t.constant)/e;return s>=0?s:null}intersectPlane(t,e){const s=this.distanceToPlane(t);return s===null?null:this.at(s,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let s,i,r,o,a,h;const n=1/this.direction.x,d=1/this.direction.y,m=1/this.direction.z,u=this.origin;return n>=0?(s=(t.min.x-u.x)*n,i=(t.max.x-u.x)*n):(s=(t.max.x-u.x)*n,i=(t.min.x-u.x)*n),d>=0?(r=(t.min.y-u.y)*d,o=(t.max.y-u.y)*d):(r=(t.max.y-u.y)*d,o=(t.min.y-u.y)*d),s>o||r>i||((r>s||isNaN(s))&&(s=r),(o<i||isNaN(i))&&(i=o),m>=0?(a=(t.min.z-u.z)*m,h=(t.max.z-u.z)*m):(a=(t.max.z-u.z)*m,h=(t.min.z-u.z)*m),s>h||a>i)||((a>s||s!==s)&&(s=a),(h<i||i!==i)&&(i=h),i<0)?null:this.at(s>=0?s:i,e)}intersectsBox(t){return this.intersectBox(t,at)!==null}intersectTriangle(t,e,s,i,r){De.subVectors(e,t),de.subVectors(s,t),Ie.crossVectors(De,de);let o=this.direction.dot(Ie),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;yt.subVectors(this.origin,t);const h=a*this.direction.dot(de.crossVectors(yt,de));if(h<0)return null;const n=a*this.direction.dot(De.cross(yt));if(n<0||h+n>o)return null;const d=-a*yt.dot(Ie);return d<0?null:this.at(d/o,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class U{constructor(t,e,s,i,r,o,a,h,n,d,m,u,p,f,x,g){U.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,s,i,r,o,a,h,n,d,m,u,p,f,x,g)}set(t,e,s,i,r,o,a,h,n,d,m,u,p,f,x,g){const y=this.elements;return y[0]=t,y[4]=e,y[8]=s,y[12]=i,y[1]=r,y[5]=o,y[9]=a,y[13]=h,y[2]=n,y[6]=d,y[10]=m,y[14]=u,y[3]=p,y[7]=f,y[11]=x,y[15]=g,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 U().fromArray(this.elements)}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],e[9]=s[9],e[10]=s[10],e[11]=s[11],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],this}copyPosition(t){const e=this.elements,s=t.elements;return e[12]=s[12],e[13]=s[13],e[14]=s[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,s){return this.determinant()===0?(t.set(1,0,0),e.set(0,1,0),s.set(0,0,1),this):(t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this)}makeBasis(t,e,s){return this.set(t.x,e.x,s.x,0,t.y,e.y,s.y,0,t.z,e.z,s.z,0,0,0,0,1),this}extractRotation(t){if(t.determinant()===0)return this.identity();const e=this.elements,s=t.elements,i=1/Pt.setFromMatrixColumn(t,0).length(),r=1/Pt.setFromMatrixColumn(t,1).length(),o=1/Pt.setFromMatrixColumn(t,2).length();return e[0]=s[0]*i,e[1]=s[1]*i,e[2]=s[2]*i,e[3]=0,e[4]=s[4]*r,e[5]=s[5]*r,e[6]=s[6]*r,e[7]=0,e[8]=s[8]*o,e[9]=s[9]*o,e[10]=s[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,s=t.x,i=t.y,r=t.z,o=Math.cos(s),a=Math.sin(s),h=Math.cos(i),n=Math.sin(i),d=Math.cos(r),m=Math.sin(r);if(t.order==="XYZ"){const u=o*d,p=o*m,f=a*d,x=a*m;e[0]=h*d,e[4]=-h*m,e[8]=n,e[1]=p+f*n,e[5]=u-x*n,e[9]=-a*h,e[2]=x-u*n,e[6]=f+p*n,e[10]=o*h}else if(t.order==="YXZ"){const u=h*d,p=h*m,f=n*d,x=n*m;e[0]=u+x*a,e[4]=f*a-p,e[8]=o*n,e[1]=o*m,e[5]=o*d,e[9]=-a,e[2]=p*a-f,e[6]=x+u*a,e[10]=o*h}else if(t.order==="ZXY"){const u=h*d,p=h*m,f=n*d,x=n*m;e[0]=u-x*a,e[4]=-o*m,e[8]=f+p*a,e[1]=p+f*a,e[5]=o*d,e[9]=x-u*a,e[2]=-o*n,e[6]=a,e[10]=o*h}else if(t.order==="ZYX"){const u=o*d,p=o*m,f=a*d,x=a*m;e[0]=h*d,e[4]=f*n-p,e[8]=u*n+x,e[1]=h*m,e[5]=x*n+u,e[9]=p*n-f,e[2]=-n,e[6]=a*h,e[10]=o*h}else if(t.order==="YZX"){const u=o*h,p=o*n,f=a*h,x=a*n;e[0]=h*d,e[4]=x-u*m,e[8]=f*m+p,e[1]=m,e[5]=o*d,e[9]=-a*d,e[2]=-n*d,e[6]=p*m+f,e[10]=u-x*m}else if(t.order==="XZY"){const u=o*h,p=o*n,f=a*h,x=a*n;e[0]=h*d,e[4]=-m,e[8]=n*d,e[1]=u*m+x,e[5]=o*d,e[9]=p*m-f,e[2]=f*m-p,e[6]=a*d,e[10]=x*m+u}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(bi,t,Si)}lookAt(t,e,s){const i=this.elements;return Y.subVectors(t,e),Y.lengthSq()===0&&(Y.z=1),Y.normalize(),xt.crossVectors(s,Y),xt.lengthSq()===0&&(Math.abs(s.z)===1?Y.x+=1e-4:Y.z+=1e-4,Y.normalize(),xt.crossVectors(s,Y)),xt.normalize(),ue.crossVectors(Y,xt),i[0]=xt.x,i[4]=ue.x,i[8]=Y.x,i[1]=xt.y,i[5]=ue.y,i[9]=Y.y,i[2]=xt.z,i[6]=ue.z,i[10]=Y.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,i=e.elements,r=this.elements,o=s[0],a=s[4],h=s[8],n=s[12],d=s[1],m=s[5],u=s[9],p=s[13],f=s[2],x=s[6],g=s[10],y=s[14],w=s[3],M=s[7],b=s[11],v=s[15],F=i[0],A=i[4],R=i[8],C=i[12],T=i[1],B=i[5],W=i[9],D=i[13],rt=i[2],Tt=i[6],mt=i[10],pt=i[14],zt=i[3],ie=i[7],re=i[11],ne=i[15];return r[0]=o*F+a*T+h*rt+n*zt,r[4]=o*A+a*B+h*Tt+n*ie,r[8]=o*R+a*W+h*mt+n*re,r[12]=o*C+a*D+h*pt+n*ne,r[1]=d*F+m*T+u*rt+p*zt,r[5]=d*A+m*B+u*Tt+p*ie,r[9]=d*R+m*W+u*mt+p*re,r[13]=d*C+m*D+u*pt+p*ne,r[2]=f*F+x*T+g*rt+y*zt,r[6]=f*A+x*B+g*Tt+y*ie,r[10]=f*R+x*W+g*mt+y*re,r[14]=f*C+x*D+g*pt+y*ne,r[3]=w*F+M*T+b*rt+v*zt,r[7]=w*A+M*B+b*Tt+v*ie,r[11]=w*R+M*W+b*mt+v*re,r[15]=w*C+M*D+b*pt+v*ne,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],s=t[4],i=t[8],r=t[12],o=t[1],a=t[5],h=t[9],n=t[13],d=t[2],m=t[6],u=t[10],p=t[14],f=t[3],x=t[7],g=t[11],y=t[15],w=h*p-n*u,M=a*p-n*m,b=a*u-h*m,v=o*p-n*d,F=o*u-h*d,A=o*m-a*d;return e*(x*w-g*M+y*b)-s*(f*w-g*v+y*F)+i*(f*M-x*v+y*A)-r*(f*b-x*F+g*A)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,s){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=s),this}invert(){const t=this.elements,e=t[0],s=t[1],i=t[2],r=t[3],o=t[4],a=t[5],h=t[6],n=t[7],d=t[8],m=t[9],u=t[10],p=t[11],f=t[12],x=t[13],g=t[14],y=t[15],w=m*g*n-x*u*n+x*h*p-a*g*p-m*h*y+a*u*y,M=f*u*n-d*g*n-f*h*p+o*g*p+d*h*y-o*u*y,b=d*x*n-f*m*n+f*a*p-o*x*p-d*a*y+o*m*y,v=f*m*h-d*x*h-f*a*u+o*x*u+d*a*g-o*m*g,F=e*w+s*M+i*b+r*v;if(F===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const A=1/F;return t[0]=w*A,t[1]=(x*u*r-m*g*r-x*i*p+s*g*p+m*i*y-s*u*y)*A,t[2]=(a*g*r-x*h*r+x*i*n-s*g*n-a*i*y+s*h*y)*A,t[3]=(m*h*r-a*u*r-m*i*n+s*u*n+a*i*p-s*h*p)*A,t[4]=M*A,t[5]=(d*g*r-f*u*r+f*i*p-e*g*p-d*i*y+e*u*y)*A,t[6]=(f*h*r-o*g*r-f*i*n+e*g*n+o*i*y-e*h*y)*A,t[7]=(o*u*r-d*h*r+d*i*n-e*u*n-o*i*p+e*h*p)*A,t[8]=b*A,t[9]=(f*m*r-d*x*r-f*s*p+e*x*p+d*s*y-e*m*y)*A,t[10]=(o*x*r-f*a*r+f*s*n-e*x*n-o*s*y+e*a*y)*A,t[11]=(d*a*r-o*m*r-d*s*n+e*m*n+o*s*p-e*a*p)*A,t[12]=v*A,t[13]=(d*x*i-f*m*i+f*s*u-e*x*u-d*s*g+e*m*g)*A,t[14]=(f*a*i-o*x*i-f*s*h+e*x*h+o*s*g-e*a*g)*A,t[15]=(o*m*i-d*a*i+d*s*h-e*m*h-o*s*u+e*a*u)*A,this}scale(t){const e=this.elements,s=t.x,i=t.y,r=t.z;return e[0]*=s,e[4]*=i,e[8]*=r,e[1]*=s,e[5]*=i,e[9]*=r,e[2]*=s,e[6]*=i,e[10]*=r,e[3]*=s,e[7]*=i,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],s=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,s,i))}makeTranslation(t,e,s){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,s,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),s=Math.sin(t);return this.set(1,0,0,0,0,e,-s,0,0,s,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,0,s,0,0,1,0,0,-s,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,0,s,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const s=Math.cos(e),i=Math.sin(e),r=1-s,o=t.x,a=t.y,h=t.z,n=r*o,d=r*a;return this.set(n*o+s,n*a-i*h,n*h+i*a,0,n*a+i*h,d*a+s,d*h-i*o,0,n*h-i*a,d*h+i*o,r*h*h+s,0,0,0,0,1),this}makeScale(t,e,s){return this.set(t,0,0,0,0,e,0,0,0,0,s,0,0,0,0,1),this}makeShear(t,e,s,i,r,o){return this.set(1,s,r,0,t,1,o,0,e,i,1,0,0,0,0,1),this}compose(t,e,s){const i=this.elements,r=e._x,o=e._y,a=e._z,h=e._w,n=r+r,d=o+o,m=a+a,u=r*n,p=r*d,f=r*m,x=o*d,g=o*m,y=a*m,w=h*n,M=h*d,b=h*m,v=s.x,F=s.y,A=s.z;return i[0]=(1-(x+y))*v,i[1]=(p+b)*v,i[2]=(f-M)*v,i[3]=0,i[4]=(p-b)*F,i[5]=(1-(u+y))*F,i[6]=(g+w)*F,i[7]=0,i[8]=(f+M)*A,i[9]=(g-w)*A,i[10]=(1-(u+x))*A,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,s){const i=this.elements;if(t.x=i[12],t.y=i[13],t.z=i[14],this.determinant()===0)return s.set(1,1,1),e.identity(),this;let r=Pt.set(i[0],i[1],i[2]).length();const o=Pt.set(i[4],i[5],i[6]).length(),a=Pt.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),Q.copy(this);const n=1/r,d=1/o,m=1/a;return Q.elements[0]*=n,Q.elements[1]*=n,Q.elements[2]*=n,Q.elements[4]*=d,Q.elements[5]*=d,Q.elements[6]*=d,Q.elements[8]*=m,Q.elements[9]*=m,Q.elements[10]*=m,e.setFromRotationMatrix(Q),s.x=r,s.y=o,s.z=a,this}makePerspective(t,e,s,i,r,o,a=Xt,h=!1){const n=this.elements,d=2*r/(e-t),m=2*r/(s-i),u=(e+t)/(e-t),p=(s+i)/(s-i);let f,x;if(h)f=r/(o-r),x=o*r/(o-r);else if(a===Xt)f=-(o+r)/(o-r),x=-2*o*r/(o-r);else if(a===us)f=-o/(o-r),x=-o*r/(o-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return n[0]=d,n[4]=0,n[8]=u,n[12]=0,n[1]=0,n[5]=m,n[9]=p,n[13]=0,n[2]=0,n[6]=0,n[10]=f,n[14]=x,n[3]=0,n[7]=0,n[11]=-1,n[15]=0,this}makeOrthographic(t,e,s,i,r,o,a=Xt,h=!1){const n=this.elements,d=2/(e-t),m=2/(s-i),u=-(e+t)/(e-t),p=-(s+i)/(s-i);let f,x;if(h)f=1/(o-r),x=o/(o-r);else if(a===Xt)f=-2/(o-r),x=-(o+r)/(o-r);else if(a===us)f=-1/(o-r),x=-r/(o-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return n[0]=d,n[4]=0,n[8]=0,n[12]=u,n[1]=0,n[5]=m,n[9]=0,n[13]=p,n[2]=0,n[6]=0,n[10]=f,n[14]=x,n[3]=0,n[7]=0,n[11]=0,n[15]=1,this}equals(t){const e=this.elements,s=t.elements;for(let i=0;i<16;i++)if(e[i]!==s[i])return!1;return!0}fromArray(t,e=0){for(let s=0;s<16;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t[e+9]=s[9],t[e+10]=s[10],t[e+11]=s[11],t[e+12]=s[12],t[e+13]=s[13],t[e+14]=s[14],t[e+15]=s[15],t}}const Pt=new S,Q=new U,bi=new S(0,0,0),Si=new S(1,1,1),xt=new S,ue=new S,Y=new S,bs=new U,Ss=new Zt;class te{constructor(t=0,e=0,s=0,i=te.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=s,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,s,i=this._order){return this._x=t,this._y=e,this._z=s,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,s=!0){const i=t.elements,r=i[0],o=i[4],a=i[8],h=i[1],n=i[5],d=i[9],m=i[2],u=i[6],p=i[10];switch(e){case"XYZ":this._y=Math.asin(k(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-d,p),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(u,n),this._z=0);break;case"YXZ":this._x=Math.asin(-k(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(a,p),this._z=Math.atan2(h,n)):(this._y=Math.atan2(-m,r),this._z=0);break;case"ZXY":this._x=Math.asin(k(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-m,p),this._z=Math.atan2(-o,n)):(this._y=0,this._z=Math.atan2(h,r));break;case"ZYX":this._y=Math.asin(-k(m,-1,1)),Math.abs(m)<.9999999?(this._x=Math.atan2(u,p),this._z=Math.atan2(h,r)):(this._x=0,this._z=Math.atan2(-o,n));break;case"YZX":this._z=Math.asin(k(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(-d,n),this._y=Math.atan2(-m,r)):(this._x=0,this._y=Math.atan2(a,p));break;case"XZY":this._z=Math.asin(-k(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(u,n),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-d,p),this._y=0);break;default:H("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,s===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,s){return bs.makeRotationFromQuaternion(t),this.setFromRotationMatrix(bs,e,s)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Ss.setFromEuler(this),this.setFromQuaternion(Ss,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}te.DEFAULT_ORDER="XYZ";class wi{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let Mi=0;const ws=new S,Et=new Zt,lt=new U,me=new S,Ut=new S,zi=new S,vi=new Zt,Ms=new S(1,0,0),zs=new S(0,1,0),vs=new S(0,0,1),Cs={type:"added"},Ci={type:"removed"},Dt={type:"childadded",child:null},$e={type:"childremoved",child:null};class it extends Ae{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Mi++}),this.uuid=Jt(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=it.DEFAULT_UP.clone();const t=new S,e=new te,s=new Zt,i=new S(1,1,1);function r(){s.setFromEuler(e,!1)}function o(){e.setFromQuaternion(s,void 0,!1)}e._onChange(r),s._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:s},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new U},normalMatrix:{value:new Mt}}),this.matrix=new U,this.matrixWorld=new U,this.matrixAutoUpdate=it.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=it.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new wi,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.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return Et.setFromAxisAngle(t,e),this.quaternion.multiply(Et),this}rotateOnWorldAxis(t,e){return Et.setFromAxisAngle(t,e),this.quaternion.premultiply(Et),this}rotateX(t){return this.rotateOnAxis(Ms,t)}rotateY(t){return this.rotateOnAxis(zs,t)}rotateZ(t){return this.rotateOnAxis(vs,t)}translateOnAxis(t,e){return ws.copy(t).applyQuaternion(this.quaternion),this.position.add(ws.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Ms,t)}translateY(t){return this.translateOnAxis(zs,t)}translateZ(t){return this.translateOnAxis(vs,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(lt.copy(this.matrixWorld).invert())}lookAt(t,e,s){t.isVector3?me.copy(t):me.set(t,e,s);const i=this.parent;this.updateWorldMatrix(!0,!1),Ut.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?lt.lookAt(Ut,me,this.up):lt.lookAt(me,Ut,this.up),this.quaternion.setFromRotationMatrix(lt),i&&(lt.extractRotation(i.matrixWorld),Et.setFromRotationMatrix(lt),this.quaternion.premultiply(Et.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(Ft("Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(Cs),Dt.child=t,this.dispatchEvent(Dt),Dt.child=null):Ft("Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let s=0;s<arguments.length;s++)this.remove(arguments[s]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Ci),$e.child=t,this.dispatchEvent($e),$e.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),lt.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),lt.multiply(t.parent.matrixWorld)),t.applyMatrix4(lt),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Cs),Dt.child=t,this.dispatchEvent(Dt),Dt.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let s=0,i=this.children.length;s<i;s++){const o=this.children[s].getObjectByProperty(t,e);if(o!==void 0)return o}}getObjectsByProperty(t,e,s=[]){this[t]===e&&s.push(this);const i=this.children;for(let r=0,o=i.length;r<o;r++)i[r].getObjectsByProperty(t,e,s);return s}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ut,t,zi),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ut,vi,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let s=0,i=e.length;s<i;s++)e[s].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let s=0,i=e.length;s<i;s++)e[s].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let s=0,i=e.length;s<i;s++)e[s].updateMatrixWorld(t)}updateWorldMatrix(t,e){const s=this.parent;if(t===!0&&s!==null&&s.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)),e===!0){const i=this.children;for(let r=0,o=i.length;r<o;r++)i[r].updateWorldMatrix(!1,!0)}}toJSON(t){const e=t===void 0||typeof t=="string",s={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},s.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),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.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),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(t),i.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function r(a,h){return a[h.uuid]===void 0&&(a[h.uuid]=h.toJSON(t)),h.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(t.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const h=a.shapes;if(Array.isArray(h))for(let n=0,d=h.length;n<d;n++){const m=h[n];r(t.shapes,m)}else r(t.shapes,h)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let h=0,n=this.material.length;h<n;h++)a.push(r(t.materials,this.material[h]));i.material=a}else i.material=r(t.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(t).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){const h=this.animations[a];i.animations.push(r(t.animations,h))}}if(e){const a=o(t.geometries),h=o(t.materials),n=o(t.textures),d=o(t.images),m=o(t.shapes),u=o(t.skeletons),p=o(t.animations),f=o(t.nodes);a.length>0&&(s.geometries=a),h.length>0&&(s.materials=h),n.length>0&&(s.textures=n),d.length>0&&(s.images=d),m.length>0&&(s.shapes=m),u.length>0&&(s.skeletons=u),p.length>0&&(s.animations=p),f.length>0&&(s.nodes=f)}return s.object=i,s;function o(a){const h=[];for(const n in a){const d=a[n];delete d.metadata,h.push(d)}return h}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let s=0;s<t.children.length;s++){const i=t.children[s];this.add(i.clone())}return this}}it.DEFAULT_UP=new S(0,1,0);it.DEFAULT_MATRIX_AUTO_UPDATE=!0;it.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const K=new S,ht=new S,Le=new S,ct=new S,It=new S,$t=new S,As=new S,We=new S,Oe=new S,Ve=new S,He=new Qt,Ne=new Qt,qe=new Qt;class et{constructor(t=new S,e=new S,s=new S){this.a=t,this.b=e,this.c=s}static getNormal(t,e,s,i){i.subVectors(s,e),K.subVectors(t,e),i.cross(K);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(t,e,s,i,r){K.subVectors(i,e),ht.subVectors(s,e),Le.subVectors(t,e);const o=K.dot(K),a=K.dot(ht),h=K.dot(Le),n=ht.dot(ht),d=ht.dot(Le),m=o*n-a*a;if(m===0)return r.set(0,0,0),null;const u=1/m,p=(n*h-a*d)*u,f=(o*d-a*h)*u;return r.set(1-p-f,f,p)}static containsPoint(t,e,s,i){return this.getBarycoord(t,e,s,i,ct)===null?!1:ct.x>=0&&ct.y>=0&&ct.x+ct.y<=1}static getInterpolation(t,e,s,i,r,o,a,h){return this.getBarycoord(t,e,s,i,ct)===null?(h.x=0,h.y=0,"z"in h&&(h.z=0),"w"in h&&(h.w=0),null):(h.setScalar(0),h.addScaledVector(r,ct.x),h.addScaledVector(o,ct.y),h.addScaledVector(a,ct.z),h)}static getInterpolatedAttribute(t,e,s,i,r,o){return He.setScalar(0),Ne.setScalar(0),qe.setScalar(0),He.fromBufferAttribute(t,e),Ne.fromBufferAttribute(t,s),qe.fromBufferAttribute(t,i),o.setScalar(0),o.addScaledVector(He,r.x),o.addScaledVector(Ne,r.y),o.addScaledVector(qe,r.z),o}static isFrontFacing(t,e,s,i){return K.subVectors(s,e),ht.subVectors(t,e),K.cross(ht).dot(i)<0}set(t,e,s){return this.a.copy(t),this.b.copy(e),this.c.copy(s),this}setFromPointsAndIndices(t,e,s,i){return this.a.copy(t[e]),this.b.copy(t[s]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,s,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,s),this.c.fromBufferAttribute(t,i),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return K.subVectors(this.c,this.b),ht.subVectors(this.a,this.b),K.cross(ht).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return et.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return et.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,s,i,r){return et.getInterpolation(t,this.a,this.b,this.c,e,s,i,r)}containsPoint(t){return et.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return et.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const s=this.a,i=this.b,r=this.c;let o,a;It.subVectors(i,s),$t.subVectors(r,s),We.subVectors(t,s);const h=It.dot(We),n=$t.dot(We);if(h<=0&&n<=0)return e.copy(s);Oe.subVectors(t,i);const d=It.dot(Oe),m=$t.dot(Oe);if(d>=0&&m<=d)return e.copy(i);const u=h*m-d*n;if(u<=0&&h>=0&&d<=0)return o=h/(h-d),e.copy(s).addScaledVector(It,o);Ve.subVectors(t,r);const p=It.dot(Ve),f=$t.dot(Ve);if(f>=0&&p<=f)return e.copy(r);const x=p*n-h*f;if(x<=0&&n>=0&&f<=0)return a=n/(n-f),e.copy(s).addScaledVector($t,a);const g=d*f-p*m;if(g<=0&&m-d>=0&&p-f>=0)return As.subVectors(r,i),a=(m-d)/(m-d+(p-f)),e.copy(i).addScaledVector(As,a);const y=1/(g+x+u);return o=x*y,a=u*y,e.copy(s).addScaledVector(It,o).addScaledVector($t,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const $s={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},bt={h:0,s:0,l:0},pe={h:0,s:0,l:0};function Ue(c,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?c+(t-c)*6*e:e<1/2?t:e<2/3?c+(t-c)*6*(2/3-e):c}class ee{constructor(t,e,s){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,s)}set(t,e,s){if(e===void 0&&s===void 0){const i=t;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(t,e,s);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=tt){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,J.colorSpaceToWorking(this,e),this}setRGB(t,e,s,i=J.workingColorSpace){return this.r=t,this.g=e,this.b=s,J.colorSpaceToWorking(this,i),this}setHSL(t,e,s,i=J.workingColorSpace){if(t=di(t,1),e=k(e,0,1),s=k(s,0,1),e===0)this.r=this.g=this.b=s;else{const r=s<=.5?s*(1+e):s+e-s*e,o=2*s-r;this.r=Ue(o,r,t+1/3),this.g=Ue(o,r,t),this.b=Ue(o,r,t-1/3)}return J.colorSpaceToWorking(this,i),this}setStyle(t,e=tt){function s(r){r!==void 0&&parseFloat(r)<1&&H("Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return s(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return s(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return s(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:H("Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const r=i[1],o=r.length;if(o===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,e);if(o===6)return this.setHex(parseInt(r,16),e);H("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=tt){const s=$s[t.toLowerCase()];return s!==void 0?this.setHex(s,e):H("Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=dt(t.r),this.g=dt(t.g),this.b=dt(t.b),this}copyLinearToSRGB(t){return this.r=Wt(t.r),this.g=Wt(t.g),this.b=Wt(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=tt){return J.workingToColorSpace(V.copy(this),t),Math.round(k(V.r*255,0,255))*65536+Math.round(k(V.g*255,0,255))*256+Math.round(k(V.b*255,0,255))}getHexString(t=tt){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=J.workingColorSpace){J.workingToColorSpace(V.copy(this),e);const s=V.r,i=V.g,r=V.b,o=Math.max(s,i,r),a=Math.min(s,i,r);let h,n;const d=(a+o)/2;if(a===o)h=0,n=0;else{const m=o-a;switch(n=d<=.5?m/(o+a):m/(2-o-a),o){case s:h=(i-r)/m+(i<r?6:0);break;case i:h=(r-s)/m+2;break;case r:h=(s-i)/m+4;break}h/=6}return t.h=h,t.s=n,t.l=d,t}getRGB(t,e=J.workingColorSpace){return J.workingToColorSpace(V.copy(this),e),t.r=V.r,t.g=V.g,t.b=V.b,t}getStyle(t=tt){J.workingToColorSpace(V.copy(this),t);const e=V.r,s=V.g,i=V.b;return t!==tt?`color(${t} ${e.toFixed(3)} ${s.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(s*255)},${Math.round(i*255)})`}offsetHSL(t,e,s){return this.getHSL(bt),this.setHSL(bt.h+t,bt.s+e,bt.l+s)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,s){return this.r=t.r+(e.r-t.r)*s,this.g=t.g+(e.g-t.g)*s,this.b=t.b+(e.b-t.b)*s,this}lerpHSL(t,e){this.getHSL(bt),t.getHSL(pe);const s=Te(bt.h,pe.h,e),i=Te(bt.s,pe.s,e),r=Te(bt.l,pe.l,e);return this.setHSL(s,i,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,s=this.g,i=this.b,r=t.elements;return this.r=r[0]*e+r[3]*s+r[6]*i,this.g=r[1]*e+r[4]*s+r[7]*i,this.b=r[2]*e+r[5]*s+r[8]*i,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const V=new ee;ee.NAMES=$s;let Ai=0;class Fi extends Ae{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Ai++}),this.uuid=Jt(),this.name="",this.type="Material",this.blending=es,this.side=Xe,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=is,this.blendDst=rs,this.blendEquation=ss,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ee(0,0,0),this.blendAlpha=0,this.depthFunc=ns,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=cs,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=_t,this.stencilZFail=_t,this.stencilZPass=_t,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(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const s=t[e];if(s===void 0){H(`Material: parameter '${e}' has value of undefined.`);continue}const i=this[e];if(i===void 0){H(`Material: '${e}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(s):i&&i.isVector3&&s&&s.isVector3?i.copy(s):this[e]=s}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const s={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.color&&this.color.isColor&&(s.color=this.color.getHex()),this.roughness!==void 0&&(s.roughness=this.roughness),this.metalness!==void 0&&(s.metalness=this.metalness),this.sheen!==void 0&&(s.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(s.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(s.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(s.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(s.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(s.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(s.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(s.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(s.shininess=this.shininess),this.clearcoat!==void 0&&(s.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(s.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(s.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(s.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(s.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,s.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(s.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(s.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),this.dispersion!==void 0&&(s.dispersion=this.dispersion),this.iridescence!==void 0&&(s.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(s.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(s.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(s.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(s.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(s.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(s.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(s.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(s.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(s.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(s.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(s.lightMap=this.lightMap.toJSON(t).uuid,s.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(s.aoMap=this.aoMap.toJSON(t).uuid,s.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(s.bumpMap=this.bumpMap.toJSON(t).uuid,s.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(s.normalMap=this.normalMap.toJSON(t).uuid,s.normalMapType=this.normalMapType,s.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(s.displacementMap=this.displacementMap.toJSON(t).uuid,s.displacementScale=this.displacementScale,s.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(s.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(s.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(s.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(s.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(s.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(s.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(s.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(s.combine=this.combine)),this.envMapRotation!==void 0&&(s.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(s.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(s.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(s.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(s.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(s.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(s.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(s.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(s.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(s.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(s.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(s.size=this.size),this.shadowSide!==null&&(s.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(s.sizeAttenuation=this.sizeAttenuation),this.blending!==es&&(s.blending=this.blending),this.side!==Xe&&(s.side=this.side),this.vertexColors===!0&&(s.vertexColors=!0),this.opacity<1&&(s.opacity=this.opacity),this.transparent===!0&&(s.transparent=!0),this.blendSrc!==is&&(s.blendSrc=this.blendSrc),this.blendDst!==rs&&(s.blendDst=this.blendDst),this.blendEquation!==ss&&(s.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(s.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(s.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(s.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(s.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(s.blendAlpha=this.blendAlpha),this.depthFunc!==ns&&(s.depthFunc=this.depthFunc),this.depthTest===!1&&(s.depthTest=this.depthTest),this.depthWrite===!1&&(s.depthWrite=this.depthWrite),this.colorWrite===!1&&(s.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(s.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==cs&&(s.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(s.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(s.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==_t&&(s.stencilFail=this.stencilFail),this.stencilZFail!==_t&&(s.stencilZFail=this.stencilZFail),this.stencilZPass!==_t&&(s.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(s.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(s.rotation=this.rotation),this.polygonOffset===!0&&(s.polygonOffset=!0),this.polygonOffsetFactor!==0&&(s.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(s.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(s.linewidth=this.linewidth),this.dashSize!==void 0&&(s.dashSize=this.dashSize),this.gapSize!==void 0&&(s.gapSize=this.gapSize),this.scale!==void 0&&(s.scale=this.scale),this.dithering===!0&&(s.dithering=!0),this.alphaTest>0&&(s.alphaTest=this.alphaTest),this.alphaHash===!0&&(s.alphaHash=!0),this.alphaToCoverage===!0&&(s.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(s.premultipliedAlpha=!0),this.forceSinglePass===!0&&(s.forceSinglePass=!0),this.allowOverride===!1&&(s.allowOverride=!1),this.wireframe===!0&&(s.wireframe=!0),this.wireframeLinewidth>1&&(s.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(s.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(s.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(s.flatShading=!0),this.visible===!1&&(s.visible=!1),this.toneMapped===!1&&(s.toneMapped=!1),this.fog===!1&&(s.fog=!1),Object.keys(this.userData).length>0&&(s.userData=this.userData);function i(r){const o=[];for(const a in r){const h=r[a];delete h.metadata,o.push(h)}return o}if(e){const r=i(t.textures),o=i(t.images);r.length>0&&(s.textures=r),o.length>0&&(s.images=o)}return s}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let s=null;if(e!==null){const i=e.length;s=new Array(i);for(let r=0;r!==i;++r)s[r]=e[r].clone()}return this.clippingPlanes=s,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.allowOverride=t.allowOverride,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}}class Ti extends Fi{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ee(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 te,this.combine=ri,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const E=new S,fe=new st;let _i=0;class Ot{constructor(t,e,s=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:_i++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=s,this.usage=ds,this.updateRanges=[],this.gpuType=li,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,s){t*=this.itemSize,s*=e.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[t+i]=e.array[s+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,s=this.count;e<s;e++)fe.fromBufferAttribute(this,e),fe.applyMatrix3(t),this.setXY(e,fe.x,fe.y);else if(this.itemSize===3)for(let e=0,s=this.count;e<s;e++)E.fromBufferAttribute(this,e),E.applyMatrix3(t),this.setXYZ(e,E.x,E.y,E.z);return this}applyMatrix4(t){for(let e=0,s=this.count;e<s;e++)E.fromBufferAttribute(this,e),E.applyMatrix4(t),this.setXYZ(e,E.x,E.y,E.z);return this}applyNormalMatrix(t){for(let e=0,s=this.count;e<s;e++)E.fromBufferAttribute(this,e),E.applyNormalMatrix(t),this.setXYZ(e,E.x,E.y,E.z);return this}transformDirection(t){for(let e=0,s=this.count;e<s;e++)E.fromBufferAttribute(this,e),E.transformDirection(t),this.setXYZ(e,E.x,E.y,E.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let s=this.array[t*this.itemSize+e];return this.normalized&&(s=Ht(s,this.array)),s}setComponent(t,e,s){return this.normalized&&(s=N(s,this.array)),this.array[t*this.itemSize+e]=s,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Ht(e,this.array)),e}setX(t,e){return this.normalized&&(e=N(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Ht(e,this.array)),e}setY(t,e){return this.normalized&&(e=N(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=Ht(e,this.array)),e}setZ(t,e){return this.normalized&&(e=N(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=Ht(e,this.array)),e}setW(t,e){return this.normalized&&(e=N(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,s){return t*=this.itemSize,this.normalized&&(e=N(e,this.array),s=N(s,this.array)),this.array[t+0]=e,this.array[t+1]=s,this}setXYZ(t,e,s,i){return t*=this.itemSize,this.normalized&&(e=N(e,this.array),s=N(s,this.array),i=N(i,this.array)),this.array[t+0]=e,this.array[t+1]=s,this.array[t+2]=i,this}setXYZW(t,e,s,i,r){return t*=this.itemSize,this.normalized&&(e=N(e,this.array),s=N(s,this.array),i=N(i,this.array),r=N(r,this.array)),this.array[t+0]=e,this.array[t+1]=s,this.array[t+2]=i,this.array[t+3]=r,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==ds&&(t.usage=this.usage),t}}class ji extends Ot{constructor(t,e,s){super(new Uint16Array(t),e,s)}}class Ri extends Ot{constructor(t,e,s){super(new Uint32Array(t),e,s)}}class Bi extends Ot{constructor(t,e,s){super(new Float32Array(t),e,s)}}let ki=0;const X=new U,Ye=new it,Lt=new S,G=new Kt,Yt=new Kt,L=new S;class Ze extends Ae{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:ki++}),this.uuid=Jt(),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(t){return Array.isArray(t)?this.index=new(ci(t)?Ri:ji)(t,1):this.index=t,this}setIndirect(t,e=0){return this.indirect=t,this.indirectOffset=e,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,s=0){this.groups.push({start:t,count:e,materialIndex:s})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const s=this.attributes.normal;if(s!==void 0){const r=new Mt().getNormalMatrix(t);s.applyNormalMatrix(r),s.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(t),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return X.makeRotationFromQuaternion(t),this.applyMatrix4(X),this}rotateX(t){return X.makeRotationX(t),this.applyMatrix4(X),this}rotateY(t){return X.makeRotationY(t),this.applyMatrix4(X),this}rotateZ(t){return X.makeRotationZ(t),this.applyMatrix4(X),this}translate(t,e,s){return X.makeTranslation(t,e,s),this.applyMatrix4(X),this}scale(t,e,s){return X.makeScale(t,e,s),this.applyMatrix4(X),this}lookAt(t){return Ye.lookAt(t),Ye.updateMatrix(),this.applyMatrix4(Ye.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Lt).negate(),this.translate(Lt.x,Lt.y,Lt.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const s=[];for(let i=0,r=t.length;i<r;i++){const o=t[i];s.push(o.x,o.y,o.z||0)}this.setAttribute("position",new Bi(s,3))}else{const s=Math.min(t.length,e.count);for(let i=0;i<s;i++){const r=t[i];e.setXYZ(i,r.x,r.y,r.z||0)}t.length>e.count&&H("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Kt);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Ft("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new S(-1/0,-1/0,-1/0),new S(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let s=0,i=e.length;s<i;s++){const r=e[s];G.setFromBufferAttribute(r),this.morphTargetsRelative?(L.addVectors(this.boundingBox.min,G.min),this.boundingBox.expandByPoint(L),L.addVectors(this.boundingBox.max,G.max),this.boundingBox.expandByPoint(L)):(this.boundingBox.expandByPoint(G.min),this.boundingBox.expandByPoint(G.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Ft('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 Is);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Ft("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new S,1/0);return}if(t){const s=this.boundingSphere.center;if(G.setFromBufferAttribute(t),e)for(let r=0,o=e.length;r<o;r++){const a=e[r];Yt.setFromBufferAttribute(a),this.morphTargetsRelative?(L.addVectors(G.min,Yt.min),G.expandByPoint(L),L.addVectors(G.max,Yt.max),G.expandByPoint(L)):(G.expandByPoint(Yt.min),G.expandByPoint(Yt.max))}G.getCenter(s);let i=0;for(let r=0,o=t.count;r<o;r++)L.fromBufferAttribute(t,r),i=Math.max(i,s.distanceToSquared(L));if(e)for(let r=0,o=e.length;r<o;r++){const a=e[r],h=this.morphTargetsRelative;for(let n=0,d=a.count;n<d;n++)L.fromBufferAttribute(a,n),h&&(Lt.fromBufferAttribute(t,n),L.add(Lt)),i=Math.max(i,s.distanceToSquared(L))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&Ft('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){Ft("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const s=e.position,i=e.normal,r=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Ot(new Float32Array(4*s.count),4));const o=this.getAttribute("tangent"),a=[],h=[];for(let R=0;R<s.count;R++)a[R]=new S,h[R]=new S;const n=new S,d=new S,m=new S,u=new st,p=new st,f=new st,x=new S,g=new S;function y(R,C,T){n.fromBufferAttribute(s,R),d.fromBufferAttribute(s,C),m.fromBufferAttribute(s,T),u.fromBufferAttribute(r,R),p.fromBufferAttribute(r,C),f.fromBufferAttribute(r,T),d.sub(n),m.sub(n),p.sub(u),f.sub(u);const B=1/(p.x*f.y-f.x*p.y);isFinite(B)&&(x.copy(d).multiplyScalar(f.y).addScaledVector(m,-p.y).multiplyScalar(B),g.copy(m).multiplyScalar(p.x).addScaledVector(d,-f.x).multiplyScalar(B),a[R].add(x),a[C].add(x),a[T].add(x),h[R].add(g),h[C].add(g),h[T].add(g))}let w=this.groups;w.length===0&&(w=[{start:0,count:t.count}]);for(let R=0,C=w.length;R<C;++R){const T=w[R],B=T.start,W=T.count;for(let D=B,rt=B+W;D<rt;D+=3)y(t.getX(D+0),t.getX(D+1),t.getX(D+2))}const M=new S,b=new S,v=new S,F=new S;function A(R){v.fromBufferAttribute(i,R),F.copy(v);const C=a[R];M.copy(C),M.sub(v.multiplyScalar(v.dot(C))).normalize(),b.crossVectors(F,C);const B=b.dot(h[R])<0?-1:1;o.setXYZW(R,M.x,M.y,M.z,B)}for(let R=0,C=w.length;R<C;++R){const T=w[R],B=T.start,W=T.count;for(let D=B,rt=B+W;D<rt;D+=3)A(t.getX(D+0)),A(t.getX(D+1)),A(t.getX(D+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let s=this.getAttribute("normal");if(s===void 0)s=new Ot(new Float32Array(e.count*3),3),this.setAttribute("normal",s);else for(let u=0,p=s.count;u<p;u++)s.setXYZ(u,0,0,0);const i=new S,r=new S,o=new S,a=new S,h=new S,n=new S,d=new S,m=new S;if(t)for(let u=0,p=t.count;u<p;u+=3){const f=t.getX(u+0),x=t.getX(u+1),g=t.getX(u+2);i.fromBufferAttribute(e,f),r.fromBufferAttribute(e,x),o.fromBufferAttribute(e,g),d.subVectors(o,r),m.subVectors(i,r),d.cross(m),a.fromBufferAttribute(s,f),h.fromBufferAttribute(s,x),n.fromBufferAttribute(s,g),a.add(d),h.add(d),n.add(d),s.setXYZ(f,a.x,a.y,a.z),s.setXYZ(x,h.x,h.y,h.z),s.setXYZ(g,n.x,n.y,n.z)}else for(let u=0,p=e.count;u<p;u+=3)i.fromBufferAttribute(e,u+0),r.fromBufferAttribute(e,u+1),o.fromBufferAttribute(e,u+2),d.subVectors(o,r),m.subVectors(i,r),d.cross(m),s.setXYZ(u+0,d.x,d.y,d.z),s.setXYZ(u+1,d.x,d.y,d.z),s.setXYZ(u+2,d.x,d.y,d.z);this.normalizeNormals(),s.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,s=t.count;e<s;e++)L.fromBufferAttribute(t,e),L.normalize(),t.setXYZ(e,L.x,L.y,L.z)}toNonIndexed(){function t(a,h){const n=a.array,d=a.itemSize,m=a.normalized,u=new n.constructor(h.length*d);let p=0,f=0;for(let x=0,g=h.length;x<g;x++){a.isInterleavedBufferAttribute?p=h[x]*a.data.stride+a.offset:p=h[x]*d;for(let y=0;y<d;y++)u[f++]=n[p++]}return new Ot(u,d,m)}if(this.index===null)return H("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new Ze,s=this.index.array,i=this.attributes;for(const a in i){const h=i[a],n=t(h,s);e.setAttribute(a,n)}const r=this.morphAttributes;for(const a in r){const h=[],n=r[a];for(let d=0,m=n.length;d<m;d++){const u=n[d],p=t(u,s);h.push(p)}e.morphAttributes[a]=h}e.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,h=o.length;a<h;a++){const n=o[a];e.addGroup(n.start,n.count,n.materialIndex)}return e}toJSON(){const t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){const h=this.parameters;for(const n in h)h[n]!==void 0&&(t[n]=h[n]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const s=this.attributes;for(const h in s){const n=s[h];t.data.attributes[h]=n.toJSON(t.data)}const i={};let r=!1;for(const h in this.morphAttributes){const n=this.morphAttributes[h],d=[];for(let m=0,u=n.length;m<u;m++){const p=n[m];d.push(p.toJSON(t.data))}d.length>0&&(i[h]=d,r=!0)}r&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(t.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(t.data.boundingSphere=a.toJSON()),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const s=t.index;s!==null&&this.setIndex(s.clone());const i=t.attributes;for(const n in i){const d=i[n];this.setAttribute(n,d.clone(e))}const r=t.morphAttributes;for(const n in r){const d=[],m=r[n];for(let u=0,p=m.length;u<p;u++)d.push(m[u].clone(e));this.morphAttributes[n]=d}this.morphTargetsRelative=t.morphTargetsRelative;const o=t.groups;for(let n=0,d=o.length;n<d;n++){const m=o[n];this.addGroup(m.start,m.count,m.materialIndex)}const a=t.boundingBox;a!==null&&(this.boundingBox=a.clone());const h=t.boundingSphere;return h!==null&&(this.boundingSphere=h.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Fs=new U,At=new xi,ge=new Is,Ts=new S,ye=new S,xe=new S,be=new S,Ge=new S,Se=new S,_s=new S,we=new S;class js extends it{constructor(t=new Ze,e=new Ti){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,s=Object.keys(e);if(s.length>0){const i=e[s[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;r<o;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}getVertexPosition(t,e){const s=this.geometry,i=s.attributes.position,r=s.morphAttributes.position,o=s.morphTargetsRelative;e.fromBufferAttribute(i,t);const a=this.morphTargetInfluences;if(r&&a){Se.set(0,0,0);for(let h=0,n=r.length;h<n;h++){const d=a[h],m=r[h];d!==0&&(Ge.fromBufferAttribute(m,t),o?Se.addScaledVector(Ge,d):Se.addScaledVector(Ge.sub(e),d))}e.add(Se)}return e}raycast(t,e){const s=this.geometry,i=this.material,r=this.matrixWorld;i!==void 0&&(s.boundingSphere===null&&s.computeBoundingSphere(),ge.copy(s.boundingSphere),ge.applyMatrix4(r),At.copy(t.ray).recast(t.near),!(ge.containsPoint(At.origin)===!1&&(At.intersectSphere(ge,Ts)===null||At.origin.distanceToSquared(Ts)>(t.far-t.near)**2))&&(Fs.copy(r).invert(),At.copy(t.ray).applyMatrix4(Fs),!(s.boundingBox!==null&&At.intersectsBox(s.boundingBox)===!1)&&this._computeIntersections(t,e,At)))}_computeIntersections(t,e,s){let i;const r=this.geometry,o=this.material,a=r.index,h=r.attributes.position,n=r.attributes.uv,d=r.attributes.uv1,m=r.attributes.normal,u=r.groups,p=r.drawRange;if(a!==null)if(Array.isArray(o))for(let f=0,x=u.length;f<x;f++){const g=u[f],y=o[g.materialIndex],w=Math.max(g.start,p.start),M=Math.min(a.count,Math.min(g.start+g.count,p.start+p.count));for(let b=w,v=M;b<v;b+=3){const F=a.getX(b),A=a.getX(b+1),R=a.getX(b+2);i=Me(this,y,t,s,n,d,m,F,A,R),i&&(i.faceIndex=Math.floor(b/3),i.face.materialIndex=g.materialIndex,e.push(i))}}else{const f=Math.max(0,p.start),x=Math.min(a.count,p.start+p.count);for(let g=f,y=x;g<y;g+=3){const w=a.getX(g),M=a.getX(g+1),b=a.getX(g+2);i=Me(this,o,t,s,n,d,m,w,M,b),i&&(i.faceIndex=Math.floor(g/3),e.push(i))}}else if(h!==void 0)if(Array.isArray(o))for(let f=0,x=u.length;f<x;f++){const g=u[f],y=o[g.materialIndex],w=Math.max(g.start,p.start),M=Math.min(h.count,Math.min(g.start+g.count,p.start+p.count));for(let b=w,v=M;b<v;b+=3){const F=b,A=b+1,R=b+2;i=Me(this,y,t,s,n,d,m,F,A,R),i&&(i.faceIndex=Math.floor(b/3),i.face.materialIndex=g.materialIndex,e.push(i))}}else{const f=Math.max(0,p.start),x=Math.min(h.count,p.start+p.count);for(let g=f,y=x;g<y;g+=3){const w=g,M=g+1,b=g+2;i=Me(this,o,t,s,n,d,m,w,M,b),i&&(i.faceIndex=Math.floor(g/3),e.push(i))}}}}function Pi(c,t,e,s,i,r,o,a){let h;if(t.side===ii?h=s.intersectTriangle(o,r,i,!0,a):h=s.intersectTriangle(i,r,o,t.side===Xe,a),h===null)return null;we.copy(a),we.applyMatrix4(c.matrixWorld);const n=e.ray.origin.distanceTo(we);return n<e.near||n>e.far?null:{distance:n,point:we.clone(),object:c}}function Me(c,t,e,s,i,r,o,a,h,n){c.getVertexPosition(a,ye),c.getVertexPosition(h,xe),c.getVertexPosition(n,be);const d=Pi(c,t,e,s,ye,xe,be,_s);if(d){const m=new S;et.getBarycoord(_s,ye,xe,be,m),i&&(d.uv=et.getInterpolatedAttribute(i,a,h,n,m,new st)),r&&(d.uv1=et.getInterpolatedAttribute(r,a,h,n,m,new st)),o&&(d.normal=et.getInterpolatedAttribute(o,a,h,n,m,new S),d.normal.dot(s.direction)>0&&d.normal.multiplyScalar(-1));const u={a,b:h,c:n,normal:new S,materialIndex:0};et.getNormal(ye,xe,be,u.normal),d.face=u,d.barycoord=m}return d}class Ei extends it{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new U,this.projectionMatrix=new U,this.projectionMatrixInverse=new U,this.coordinateSystem=Xt,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}class Rs extends it{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new ee(t),this.intensity=e}dispose(){this.dispatchEvent({type:"dispose"})}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,e}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Ps}}));typeof window<"u"&&(window.__THREE__?H("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Ps);class Di{scene=null;setScene(t){this.scene=t}getStats(){if(!this.scene)return null;const t={total:0,meshes:0,lights:0,cameras:0,groups:0,other:0},e={total:0,byType:{}},s={total:0,totalSize:0,byFormat:{},environment:0,system:0},i={total:0,vertices:0,faces:0},r={meshes:0,total:0},o=new Set,a=new Set,h=new Set,n=new Set,d=g=>{if(!g||g.userData&&(g.userData.rapier||g.userData.physics||g.userData.type==="RigidBody"||g.userData.__r3f||g.userData.__reactInternalInstance||g.userData.internal===!0||g.userData.helper===!0))return!0;if(g.name){const y=g.name.toLowerCase();if(y.includes("__rapier")||y.includes("__physics")||y.includes("__r3f")||y.includes("__internal")||y.startsWith("_helper")||y.startsWith("_internal")||y.includes("__internal")||y.startsWith("_")||y.includes("collider")||y.includes("rigidbody")||y.includes("helper")||y.includes("debug"))return!0}return!!(g.type==="RigidBody"||g.isRigidBody||g.type&&g.type.includes("Helper"))},m=g=>{if(!(g instanceof js||g.isMesh))return!1;const y=g;return!(!y.geometry||!y.material||d(g))},u=g=>!(!(g instanceof Rs||g.isLight)||d(g)||g.type&&g.type.includes("Helper")),p=(g,y=0,w=!1)=>{if(!g)return;const M=d(g)||w;if(g instanceof js||g.isMesh){const b=g;if(m(g)&&!n.has(b)){if(n.add(b),t.meshes++,g.visible&&r.meshes++,M||(t.total++,g.visible&&r.total++),b.geometry&&!h.has(b.geometry)){h.add(b.geometry),i.total++;const v=b.geometry;if(v.attributes&&v.attributes.position){const F=v.attributes.position.count||0;i.vertices+=F,v.index?i.faces+=Math.floor(v.index.count/3):i.faces+=Math.floor(F/3)}}b.material&&(Array.isArray(b.material)?b.material:[b.material]).forEach(F=>{if(F&&!o.has(F)){o.add(F),e.total++;const A=F.type||F.constructor.name||"Unknown";e.byType[A]=(e.byType[A]||0)+1,["map","normalMap","roughnessMap","metalnessMap","aoMap","emissiveMap","bumpMap","displacementMap","alphaMap","envMap","lightMap","specularMap","clearcoatMap","clearcoatNormalMap","clearcoatRoughnessMap","sheenColorMap","sheenRoughnessMap","transmissionMap","thicknessMap","iridescenceMap","iridescenceThicknessMap"].forEach(C=>{const T=F[C];if(T&&T instanceof ut&&!a.has(T)){a.add(T),s.total++;const B=this.estimateTextureSize(T);s.totalSize+=B;const W=T.format?.toString()||"unknown";s.byFormat[W]=(s.byFormat[W]||0)+1,(C==="envMap"||T.name?.toLowerCase().includes("env")||T.name?.toLowerCase().includes("environment"))&&s.environment++,(C==="lightMap"||T.name?.toLowerCase().includes("lightmap")||T.name?.toLowerCase().includes("system"))&&s.system++}}),Object.keys(F).forEach(C=>{const T=F[C];if(T&&T instanceof ut&&!a.has(T)){a.add(T),s.total++;const B=this.estimateTextureSize(T);s.totalSize+=B;const W=T.format?.toString()||"unknown";s.byFormat[W]=(s.byFormat[W]||0)+1,(C==="envMap"||T.name?.toLowerCase().includes("env")||T.name?.toLowerCase().includes("environment"))&&s.environment++,(C==="lightMap"||T.name?.toLowerCase().includes("lightmap")||T.name?.toLowerCase().includes("system"))&&s.system++}})}})}}else g instanceof Rs||g.isLight?u(g)&&t.lights++:g instanceof Ei||g.isCamera?!M&&!g.type?.includes("Helper")&&t.cameras++:g.type==="Group"||g.isGroup?M||t.groups++:M||t.other++;y<20&&g.children&&g.children.length>0&&g.children.forEach(b=>{b&&p(b,y+1,M)})};this.scene.children.forEach(g=>{g&&p(g,0,!1)});const f=t.meshes>0?i.vertices/t.meshes:0,x=t.meshes>0?i.faces/t.meshes:0;return{objects:t,materials:e,textures:s,geometries:i,visible:r,complexity:{averageVerticesPerMesh:f,averageFacesPerMesh:x,totalDrawCalls:t.meshes},timestamp:performance.now()}}estimateTextureSize(t){if(!t.image)return 0;const e=t.image;if(!e)return 0;const s=e.width||1,i=e.height||1;let r=4;try{const o=Number(t.format);isNaN(o)||(o===1022&&(r=3),o===1021&&(r=1),o===1020&&(r=1))}catch{}return s*i*r}reset(){}}const Ls=new Di;class Ii{renderer=null;lastStats=null;history=[];historySize=60;startTime=0;warmupPeriod=1e4;setRenderer(t){this.renderer=t,this.startTime===0&&(this.startTime=performance.now())}getStats(){const t=this.getJSHeapStats(),e=this.getGPUMemoryStats(),s=this.detectLeaks();if(!t&&!e)return null;const i={jsHeap:t||{used:0,total:0,limit:0,percentage:0},gpuMemory:e||{textures:0,geometries:0,total:0},leaks:s,timestamp:performance.now()};return this.lastStats=i,i}getJSHeapStats(){if(typeof performance>"u"||!performance.memory)return null;const t=performance.memory,e=t.usedJSHeapSize,s=t.totalJSHeapSize,i=t.jsHeapSizeLimit,r=i>0?e/i*100:0;return this.addToHistory(e),{used:e,total:s,limit:i,percentage:Math.min(100,Math.max(0,r))}}getGPUMemoryStats(){if(!this.renderer)return null;const t=this.renderer.info,e=t.memory,s=t.render;let i=0,r=0;if(e.textures&&this.renderer)try{i=e.textures*2*1024*1024}catch{i=e.textures*1024*1024}if(e.geometries&&this.renderer)try{r=(s.triangles||0)*100,r+=e.geometries*10*1024}catch{r=e.geometries*100*1024}return{textures:i,geometries:r,total:i+r}}addToHistory(t){const e=performance.now();this.history.push({timestamp:e,used:t}),this.history.length>this.historySize&&this.history.shift()}detectLeaks(){if(performance.now()-this.startTime<this.warmupPeriod)return{detected:!1,growthRate:0,trend:"stable"};if(this.history.length<20)return{detected:!1,growthRate:0,trend:"stable"};const e=this.history.slice(-10),s=this.history.slice(-30),i=e[0],r=e[e.length-1],o=(r.timestamp-i.timestamp)/1e3,a=r.used-i.used,h=o>0?a/o:0,n=s[0],d=s[s.length-1],m=(d.timestamp-n.timestamp)/1e3,u=d.used-n.used,p=m>0?u/m:0,f=(h+p)/2,x=33*1024,g=h>0&&p>0,y=f>x&&g;let w="stable";return Math.abs(f)<2048?w="stable":f>0?w="increasing":w="decreasing",{detected:y,growthRate:f,trend:w}}getLastStats(){return this.lastStats}reset(){this.lastStats=null,this.history=[],this.startTime=0}}const Ce=new Ii;class $i{phases=new Map;timeline=[];frameStartTime=0;lastBreakdown=null;maxTimelineEntries=100;startFrame(){this.frameStartTime=performance.now(),this.phases.clear(),this.timeline=[]}startPhase(t){const e=performance.now();this.phases.set(t,{start:e})}endPhase(t){const e=this.phases.get(t);if(!e)return;const s=performance.now();e.end=s;const i=s-e.start;this.timeline.push({name:t,start:e.start,end:s,duration:i})}endFrame(){const e=performance.now()-this.frameStartTime,s={react:this.getPhaseDuration("react"),update:this.getPhaseDuration("update"),physics:this.getPhaseDuration("physics"),render:this.getPhaseDuration("render"),postProcess:this.getPhaseDuration("postProcess"),other:0},i=Object.values(s).reduce((o,a)=>o+a,0);s.other=Math.max(0,e-i);const r={total:e,phases:s,timeline:[...this.timeline].slice(-this.maxTimelineEntries),timestamp:this.frameStartTime};return this.lastBreakdown=r,r}getPhaseDuration(t){const e=this.phases.get(t);return!e||e.end===void 0?0:e.end-e.start}measure(t,e){this.startPhase(t);try{return e()}finally{this.endPhase(t)}}async measureAsync(t,e){this.startPhase(t);try{return await e()}finally{this.endPhase(t)}}getLastBreakdown(){return this.lastBreakdown}reset(){this.phases.clear(),this.timeline=[],this.lastBreakdown=null}}const q=new $i;class Li{enabled=!1;reactPhaseStart=0;isReactRendering=!1;isUpdating=!1;isPhysicsRunning=!1;isRendering=!1;mutationObserver=null;enable(){this.enabled||(this.enabled=!0,this.setupReactInstrumentation(),this.setupThreeJSInstrumentation(),this.setupPhysicsInstrumentation())}disable(){this.enabled&&(this.enabled=!1,this.cleanup())}setupReactInstrumentation(){if(typeof window>"u")return;const t=document.getElementById("root")||document.body;if(t&&(this.mutationObserver=new MutationObserver(()=>{this.isReactRendering||this.startReactPhase()}),this.mutationObserver.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeOldValue:!1})),performance.mark){const e=performance.mark;performance.mark=((s,i)=>((s.includes("react")||s.includes("React"))&&(this.isReactRendering||this.startReactPhase()),e.call(performance,s,i)))}}setupThreeJSInstrumentation(){}setupPhysicsInstrumentation(){}startFrame(){this.enabled&&q.startFrame()}startReactPhase(){!this.enabled||this.isReactRendering||(this.isReactRendering=!0,this.reactPhaseStart=performance.now(),q.startPhase("react"))}endReactPhase(){!this.enabled||!this.isReactRendering||(this.isReactRendering=!1,q.endPhase("react"))}onReactRender(t){this.enabled&&(this.isReactRendering||this.startReactPhase(),setTimeout(()=>{this.isReactRendering&&performance.now()-this.reactPhaseStart>t&&this.endReactPhase()},0))}startUpdatePhase(){!this.enabled||this.isUpdating||(this.isUpdating=!0,q.startPhase("update"))}endUpdatePhase(){!this.enabled||!this.isUpdating||(this.isUpdating=!1,q.endPhase("update"))}startPhysicsPhase(){!this.enabled||this.isPhysicsRunning||(this.isPhysicsRunning=!0,q.startPhase("physics"))}endPhysicsPhase(){!this.enabled||!this.isPhysicsRunning||(this.isPhysicsRunning=!1,q.endPhase("physics"))}startRenderPhase(){!this.enabled||this.isRendering||(this.isRendering=!0,q.startPhase("render"))}endRenderPhase(){!this.enabled||!this.isRendering||(this.isRendering=!1,q.endPhase("render"),q.endFrame())}cleanup(){this.isReactRendering=!1,this.isUpdating=!1,this.isPhysicsRunning=!1,this.isRendering=!1,this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null)}isActive(){return this.enabled}}const St=new Li,Wi=()=>{const{gl:c,scene:t}=ve.useThree();return z.useEffect(()=>{c&&(Gt.setRenderer(c),Ce.setRenderer(c))},[c]),z.useEffect(()=>{t&&Ls.setScene(t)},[t]),z.useEffect(()=>(St.enable(),()=>{St.disable()}),[]),ve.useFrame(()=>{c&&!P.getPaused()&&(St.isActive()||q.startFrame(),St.startUpdatePhase(),St.endUpdatePhase(),St.startRenderPhase(),Gt.startFrame(),requestAnimationFrame(()=>{P.getPaused()||(St.endRenderPhase(),q.endFrame(),Gt.endFrame(),Gt.getStats(),Ce.getStats())}))}),null},Oi={colors:{background:"rgba(15, 15, 15, 0.95)",surface:"rgba(26, 26, 26, 0.98)",surfaceElevated:"rgba(35, 35, 35, 0.98)",text:"#ffffff",textSecondary:"rgba(255, 255, 255, 0.7)",textTertiary:"rgba(255, 255, 255, 0.5)",border:"rgba(255, 255, 255, 0.1)",borderLight:"rgba(255, 255, 255, 0.05)",primary:"#3b82f6",primaryHover:"#2563eb",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4",accent:"#8b5cf6"},shadows:{md:"0 4px 6px rgba(0, 0, 0, 0.4)",xl:"0 20px 25px rgba(0, 0, 0, 0.6)"},borderRadius:{sm:"4px",md:"8px",lg:"12px"},spacing:{xs:"4px",sm:"8px",md:"16px",lg:"24px"},typography:{fontFamilyMono:'"SF Mono", "Monaco", "Inconsolata", "Roboto Mono", "Source Code Pro", monospace',fontSize:{xs:"10px",sm:"12px",md:"14px",lg:"16px"}},transitions:{fast:"150ms ease",normal:"250ms ease"},zIndex:{base:1e4}},$=Oi;function Bs(c,t){return c<=t.good?$.colors.success:c<=t.warning?$.colors.warning:$.colors.error}function j(c,t=2){return c.toFixed(t)}const _=({label:c,value:t,unit:e,trend:s,status:i,color:r,icon:o,onClick:a,className:h=""})=>{const n=$;let d=r;!d&&i&&(d=i==="good"?n.colors.success:i==="warning"?n.colors.warning:n.colors.error);const m=typeof t=="number"?t.toLocaleString():t,u=e?` ${e}`:"";return l.jsxs("div",{onClick:a,className:h,style:{backgroundColor:n.colors.surface,border:`1px solid ${n.colors.border}`,borderRadius:n.borderRadius.md,padding:n.spacing.md,cursor:a?"pointer":"default",transition:n.transitions.fast,position:"relative",overflow:"hidden"},onMouseEnter:p=>{a&&(p.currentTarget.style.backgroundColor=n.colors.surfaceElevated,p.currentTarget.style.transform="translateY(-2px)",p.currentTarget.style.boxShadow=n.shadows.md)},onMouseLeave:p=>{a&&(p.currentTarget.style.backgroundColor=n.colors.surface,p.currentTarget.style.transform="translateY(0)",p.currentTarget.style.boxShadow="none")},children:[o&&l.jsx("div",{style:{position:"absolute",top:n.spacing.sm,right:n.spacing.sm,opacity:.3},children:o}),l.jsx("div",{style:{fontSize:n.typography.fontSize.sm,color:n.colors.textSecondary,marginBottom:n.spacing.xs,fontWeight:500},children:c}),l.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:n.spacing.xs},children:[l.jsx("div",{style:{fontSize:n.typography.fontSize.lg,fontWeight:"bold",color:d||n.colors.text,fontFamily:n.typography.fontFamilyMono},children:m}),e&&l.jsx("div",{style:{fontSize:n.typography.fontSize.sm,color:n.colors.textTertiary},children:u}),s&&l.jsx("div",{style:{fontSize:n.typography.fontSize.xs,color:s==="up"?n.colors.error:s==="down"?n.colors.success:n.colors.textTertiary,marginLeft:"auto"},children:s==="up"?"↑":s==="down"?"↓":"→"})]}),d&&l.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"2px",backgroundColor:d}})]})},Vi=({tabs:c,activeTab:t,onTabChange:e,className:s=""})=>{const i=$;return l.jsx("div",{className:s,style:{position:"relative"},children:l.jsx("div",{style:{display:"flex",gap:i.spacing.xs,borderBottom:`1px solid ${i.colors.border}`,paddingBottom:i.spacing.xs},children:c.map(r=>{const o=r.id===t;return l.jsxs("button",{onClick:()=>e(r.id),style:{display:"flex",alignItems:"center",gap:i.spacing.xs,padding:`${i.spacing.sm} ${i.spacing.md}`,backgroundColor:"transparent",border:"none",color:o?i.colors.primary:i.colors.textSecondary,fontSize:i.typography.fontSize.sm,fontWeight:o?600:400,cursor:"pointer",position:"relative",transition:i.transitions.fast,borderRadius:`${i.borderRadius.sm} ${i.borderRadius.sm} 0 0`},onMouseEnter:a=>{o||(a.currentTarget.style.color=i.colors.text,a.currentTarget.style.backgroundColor=i.colors.surfaceElevated)},onMouseLeave:a=>{o||(a.currentTarget.style.color=i.colors.textSecondary,a.currentTarget.style.backgroundColor="transparent")},children:[r.icon&&l.jsx("span",{style:{display:"flex",alignItems:"center"},children:r.icon}),l.jsx("span",{children:r.label}),r.badge!==void 0&&l.jsx("span",{style:{backgroundColor:o?i.colors.primary:i.colors.surfaceElevated,color:o?i.colors.text:i.colors.textSecondary,borderRadius:i.borderRadius.sm,padding:`2px ${i.spacing.xs}`,fontSize:i.typography.fontSize.xs,fontWeight:600,minWidth:"18px",textAlign:"center"},children:r.badge}),o&&l.jsx("div",{style:{position:"absolute",bottom:-1,left:0,right:0,height:"2px",backgroundColor:i.colors.primary}})]},r.id)})})})},wt=({severity:c,count:t,children:e,onClick:s})=>{const i=$,o={info:i.colors.info,warning:i.colors.warning,error:i.colors.error}[c];return l.jsxs("div",{onClick:s,style:{display:"inline-flex",alignItems:"center",gap:i.spacing.xs,padding:`${i.spacing.xs} ${i.spacing.sm}`,backgroundColor:`${o}20`,color:o,borderRadius:i.borderRadius.md,fontSize:i.typography.fontSize.xs,fontWeight:600,cursor:s?"pointer":"default",border:`1px solid ${o}40`,transition:i.transitions.fast},onMouseEnter:a=>{s&&(a.currentTarget.style.backgroundColor=`${o}30`)},onMouseLeave:a=>{s&&(a.currentTarget.style.backgroundColor=`${o}20`)},children:[l.jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:o}}),t!==void 0&&t>0&&l.jsx("span",{children:t}),e]})},ze=120;function se(){const c=Vt(),[t,e]=z.useState([]),s=z.useRef(0),i=z.useRef(null);return z.useEffect(()=>{if(!c||c.frames===0){e([]),s.current=0;return}const r=()=>{if(P.getPaused())return;const a=q.getLastBreakdown();if(a&&a.total>0){e(h=>{const n=h.length>0?h[h.length-1]:null;if(n===null||Math.abs(a.total-n)>.1){const d=[...h,a.total];return d.length>ze?d.slice(-ze):d}return h});return}if(c&&c.frames>0){const h=c.totalTime/c.frames;if(c.frames>s.current){const n=c.frames-s.current;s.current=c.frames,e(d=>{const m=[...d],u=Math.min(n,10);for(let p=0;p<u;p++)m.push(h);return m.length>ze?m.slice(-ze):m})}}};i.current=window.setInterval(r,16);const o=P.subscribe(a=>{!a&&c&&c.frames>0&&r()});return()=>{i.current!==null&&clearInterval(i.current),o()}},[c]),t}const Hi=({width:c=600,height:t=200,showGrid:e=!0,showLabels:s=!0,maxValue:i,minValue:r})=>{const o=se(),a=$,h=typeof c=="string"&&c.includes("%"),n=h?"100%":typeof c=="number"?c:600,{normalizedData:d,chartMax:m,chartMin:u}=z.useMemo(()=>{if(o.length===0)return{normalizedData:[],chartMax:0,chartMin:0};const b=i??Math.max(...o),v=r??Math.min(...o),F=b-v||1;return{normalizedData:o.map(R=>{const C=(R-v)/F*t;return Math.max(0,Math.min(t,C))}),chartMax:b,chartMin:v}},[o,i,r,t]);if(o.length===0)return l.jsx("div",{style:{width:n,height:t,display:"flex",alignItems:"center",justifyContent:"center",color:a.colors.textTertiary,fontSize:a.typography.fontSize.sm,border:`1px solid ${a.colors.border}`,borderRadius:a.borderRadius.md},children:"No frame data available"});const p=h?600:typeof n=="number"?n:600,f=p/(o.length-1||1),x=d.map((b,v)=>{const F=v*f;return`${v===0?"M":"L"} ${F} ${t-b}`}).join(" "),g=`${x} L ${c} ${t} L 0 ${t} Z`,w=t-(16.67-u)/(m-u||1)*t,M=h?"100%":n;return l.jsx("div",{style:{position:"relative",width:n},children:l.jsxs("svg",{width:M,height:t,style:{display:"block"},viewBox:h?`0 0 600 ${t}`:void 0,preserveAspectRatio:h?"none":void 0,children:[e&&l.jsx("g",{opacity:.2,children:[0,.25,.5,.75,1].map(b=>{const v=t*b;return l.jsx("line",{x1:0,y1:v,x2:p,y2:v,stroke:a.colors.border,strokeWidth:1},b)})}),w>=0&&w<=t&&l.jsx("line",{x1:0,y1:w,x2:p,y2:w,stroke:a.colors.success,strokeWidth:2,strokeDasharray:"4 4",opacity:.5}),l.jsx("path",{d:g,fill:a.colors.primary,fillOpacity:.2}),l.jsx("path",{d:x,fill:"none",stroke:a.colors.primary,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),d.map((b,v)=>{const A=o[v]>16.67;return l.jsx("circle",{cx:v*f,cy:t-b,r:A?3:2,fill:A?a.colors.error:a.colors.primary},v)}),s&&l.jsxs("g",{children:[l.jsxs("text",{x:p-4,y:12,fill:a.colors.textSecondary,fontSize:a.typography.fontSize.xs,textAnchor:"end",children:[j(m,2),"ms"]}),l.jsxs("text",{x:p-4,y:t-4,fill:a.colors.textSecondary,fontSize:a.typography.fontSize.xs,textAnchor:"end",children:[j(u,2),"ms"]}),w>=0&&w<=t&&l.jsx("text",{x:4,y:w-4,fill:a.colors.success,fontSize:a.typography.fontSize.xs,fontWeight:600,children:"60 FPS"})]})]})})},Ni=({width:c=800,height:t=300,timeWindow:e=10})=>{const s=se(),i=$,r=typeof c=="string"&&c.includes("%"),o=r?"100%":typeof c=="number"?c:800,a=z.useMemo(()=>{const w=performance.now(),M=s.slice(-Math.floor(e*60));return M.map((v,F)=>({timestamp:w-(M.length-F)*16.666666666666668,frameTime:v,fps:v>0?1e3/v:0}))},[s,e]);if(a.length===0)return l.jsx("div",{style:{width:o,height:t,display:"flex",alignItems:"center",justifyContent:"center",color:i.colors.textTertiary,fontSize:i.typography.fontSize.sm,border:`1px solid ${i.colors.border}`,borderRadius:i.borderRadius.md,backgroundColor:i.colors.surface},children:"No timeline data available"});const h=Math.max(...a.map(w=>w.frameTime),50),n=Math.min(...a.map(w=>w.frameTime),0),d=Math.max(...a.map(w=>w.fps),60),m=Math.min(...a.map(w=>w.fps),0),u=t/2,p=r?800:typeof o=="number"?o:800,f=p/(a.length-1||1),x=a.map((w,M)=>{const b=u-(w.frameTime-n)/(h-n||1)*u,v=M*f;return`${M===0?"M":"L"} ${v} ${b}`}).join(" "),g=a.map((w,M)=>{const b=u-(w.fps-m)/(d-m||1)*u,v=M*f;return`${M===0?"M":"L"} ${v} ${b+u}`}).join(" "),y=r?"100%":o;return l.jsxs("div",{style:{width:o,height:t,backgroundColor:"transparent",borderRadius:i.borderRadius.md},children:[l.jsxs("div",{style:{fontSize:i.typography.fontSize.sm,fontWeight:600,color:i.colors.text,marginBottom:i.spacing.sm},children:["Timeline (",e,"s window)"]}),l.jsx("div",{style:{width:"100%",height:t,position:"relative",overflow:"hidden"},children:l.jsxs("svg",{width:y,height:t,style:{display:"block"},viewBox:r?`0 0 800 ${t}`:void 0,preserveAspectRatio:r?"none":void 0,children:[l.jsx("g",{opacity:.1,children:[0,.25,.5,.75,1].map(w=>{const M=t*w;return l.jsx("line",{x1:0,y1:M,x2:p,y2:M,stroke:i.colors.border,strokeWidth:1},w)})}),l.jsx("line",{x1:0,y1:u,x2:c,y2:u,stroke:i.colors.border,strokeWidth:2}),l.jsxs("g",{children:[l.jsx("text",{x:4,y:12,fill:i.colors.textSecondary,fontSize:i.typography.fontSize.xs,fontWeight:600,children:"Frame Time (ms)"}),l.jsx("path",{d:x,fill:"none",stroke:i.colors.error,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("line",{x1:0,y1:u-(16.67-n)/(h-n||1)*u,x2:p,y2:u-(16.67-n)/(h-n||1)*u,stroke:i.colors.success,strokeWidth:1,strokeDasharray:"2 2",opacity:.5})]}),l.jsxs("g",{children:[l.jsx("text",{x:4,y:u+12,fill:i.colors.textSecondary,fontSize:i.typography.fontSize.xs,fontWeight:600,children:"FPS"}),l.jsx("path",{d:g,fill:"none",stroke:i.colors.success,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("line",{x1:0,y1:u+u-(60-m)/(d-m||1)*u,x2:p,y2:u+u-(60-m)/(d-m||1)*u,stroke:i.colors.success,strokeWidth:1,strokeDasharray:"2 2",opacity:.5})]}),l.jsxs("g",{children:[l.jsxs("text",{x:p-4,y:12,fill:i.colors.textTertiary,fontSize:i.typography.fontSize.xs,textAnchor:"end",children:[j(h,1),"ms"]}),l.jsxs("text",{x:p-4,y:u-4,fill:i.colors.textTertiary,fontSize:i.typography.fontSize.xs,textAnchor:"end",children:[j(n,1),"ms"]}),l.jsxs("text",{x:p-4,y:u+12,fill:i.colors.textTertiary,fontSize:i.typography.fontSize.xs,textAnchor:"end",children:[j(d,0)," FPS"]}),l.jsxs("text",{x:p-4,y:t-4,fill:i.colors.textTertiary,fontSize:i.typography.fontSize.xs,textAnchor:"end",children:[j(m,0)," FPS"]})]})]})})]})};function qi(){const[c,t]=z.useState([]);return z.useEffect(()=>{const e=()=>{if(!P.getPaused()){const r=Ce.getStats();r&&t(o=>[...o,{...r,time:Date.now()}].slice(-120))}};e();const s=setInterval(e,1e3),i=P.subscribe(r=>{r||e()});return()=>{clearInterval(s),i()}},[]),c}const Ui=({width:c="100%",height:t=200,showGrid:e=!0,showLabels:s=!0,timeWindow:i=60,metric:r="both"})=>{const o=qi(),a=$,h=z.useMemo(()=>{const g=Date.now()-i*1e3,y=o.filter(A=>A.time>=g);if(y.length===0)return{jsHeapData:[],gpuMemoryData:[],maxValue:0,minValue:0};const w=y.map(A=>A.jsHeap.used),M=y.map(A=>A.gpuMemory.total),b=[...w,...M].filter(A=>A>0),v=b.length>0?Math.max(...b):0,F=b.length>0?Math.min(...b):0;return{jsHeapData:w,gpuMemoryData:M,maxValue:v||1,minValue:F}},[o,i]);if(h.jsHeapData.length===0&&h.gpuMemoryData.length===0)return l.jsx("div",{style:{width:c,height:t,display:"flex",alignItems:"center",justifyContent:"center",color:a.colors.textTertiary,fontSize:a.typography.fontSize.sm,border:`1px solid ${a.colors.border}`,borderRadius:a.borderRadius.md,backgroundColor:a.colors.surface},children:"No memory data available"});const n=800,d=n/(Math.max(h.jsHeapData.length,h.gpuMemoryData.length)-1||1),m=h.maxValue-h.minValue||1,u=h.jsHeapData.map((x,g)=>{const y=t-(x-h.minValue)/m*t,w=g*d;return`${g===0?"M":"L"} ${w} ${y}`}).join(" "),p=h.gpuMemoryData.map((x,g)=>{const y=t-(x-h.minValue)/m*t,w=g*d;return`${g===0?"M":"L"} ${w} ${y}`}).join(" "),f=x=>x<1024?`${j(x,0)} B`:x<1024*1024?`${j(x/1024,1)} KB`:x<1024*1024*1024?`${j(x/(1024*1024),1)} MB`:`${j(x/(1024*1024*1024),2)} GB`;return l.jsx("div",{style:{position:"relative",width:c,height:t},children:l.jsxs("svg",{width:"100%",height:t,viewBox:`0 0 ${n} ${t}`,preserveAspectRatio:"none",style:{display:"block"},children:[e&&l.jsx("g",{opacity:.2,children:[0,.25,.5,.75,1].map(x=>{const g=t*x;return l.jsx("line",{x1:0,y1:g,x2:n,y2:g,stroke:a.colors.border,strokeWidth:1},x)})}),r==="jsHeap"||r==="both"?l.jsxs(l.Fragment,{children:[l.jsx("path",{d:`${u} L ${n} ${t} L 0 ${t} Z`,fill:a.colors.primary,fillOpacity:.1}),l.jsx("path",{d:u,fill:"none",stroke:a.colors.primary,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})]}):null,r==="gpuMemory"||r==="both"?l.jsxs(l.Fragment,{children:[l.jsx("path",{d:`${p} L ${n} ${t} L 0 ${t} Z`,fill:a.colors.accent,fillOpacity:.1}),l.jsx("path",{d:p,fill:"none",stroke:a.colors.accent,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})]}):null,s&&l.jsxs("g",{children:[l.jsx("text",{x:n-4,y:12,fill:a.colors.textSecondary,fontSize:a.typography.fontSize.xs,textAnchor:"end",children:f(h.maxValue)}),l.jsx("text",{x:n-4,y:t-4,fill:a.colors.textSecondary,fontSize:a.typography.fontSize.xs,textAnchor:"end",children:f(h.minValue)}),r==="both"&&l.jsxs(l.Fragment,{children:[l.jsx("text",{x:4,y:12,fill:a.colors.primary,fontSize:a.typography.fontSize.xs,children:"JS Heap"}),l.jsx("text",{x:4,y:t-4,fill:a.colors.accent,fontSize:a.typography.fontSize.xs,children:"GPU Memory"})]})]})]})})},Yi=()=>{const c=Vt(),t=se(),e=$,s=z.useMemo(()=>!c||!c.entries?[]:[...c.entries].sort((n,d)=>d.total-n.total),[c]),i=z.useMemo(()=>!c||!c.totalTime||c.frames===0?0:1e3/(c.totalTime/c.frames),[c]),r=z.useMemo(()=>{if(!c||!c.totalTime||c.frames===0)return"neutral";const n=c.totalTime/c.frames;return n<=16.67?"good":n<=33.33?"warning":"error"},[c]),o=z.useMemo(()=>!c||c.frames===0?0:c.totalTime/c.frames,[c]),a=z.useMemo(()=>t.length>0?t:o>0?[o]:[],[t,o]),h=z.useMemo(()=>a.length===0?50:Math.max(...a,50),[a]);return!c||c.entries.length===0?l.jsx("div",{style:{padding:e.spacing.lg,textAlign:"center",color:e.colors.textSecondary,fontSize:e.typography.fontSize.sm},children:"Aucune donnée profilée pour le moment."}):l.jsxs("div",{style:{padding:e.spacing.md},children:[l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(150px, 1fr))",gap:e.spacing.md,marginBottom:e.spacing.lg},children:[l.jsx(_,{label:"FPS",value:j(i,1),status:i>=60?"good":i>=30?"warning":"error"}),l.jsx(_,{label:"Frame Time",value:j(o,2),unit:"ms",status:r}),l.jsx(_,{label:"Total Time",value:j(c.totalTime,2),unit:"ms"}),l.jsx(_,{label:"Frames",value:c.frames})]}),l.jsxs("div",{style:{backgroundColor:e.colors.surface,borderRadius:e.borderRadius.md,padding:e.spacing.md,marginBottom:e.spacing.lg,border:`1px solid ${e.colors.border}`,overflow:"hidden"},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:e.spacing.sm},children:[l.jsx("div",{style:{fontSize:e.typography.fontSize.sm,fontWeight:600,color:e.colors.text},children:"Frame Time History"}),l.jsxs("div",{style:{fontSize:e.typography.fontSize.xs,color:e.colors.textSecondary,fontFamily:e.typography.fontFamilyMono},children:[a.length," frames"]})]}),l.jsx(Hi,{width:"100%",height:100,showGrid:!0,showLabels:!0,maxValue:h}),l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:e.spacing.xs,fontSize:e.typography.fontSize.xs,color:e.colors.textTertiary},children:[l.jsx("div",{children:"Target: <16.67ms (60 FPS)"}),l.jsxs("div",{style:{color:Bs(o,{good:16.67,warning:33.33})},children:["Current: ",j(o,2),"ms"]})]})]}),l.jsx("div",{style:{backgroundColor:e.colors.surface,borderRadius:e.borderRadius.md,padding:e.spacing.md,marginBottom:e.spacing.lg,border:`1px solid ${e.colors.border}`,overflow:"hidden"},children:l.jsx(Ni,{width:"100%",height:200,timeWindow:10})}),l.jsx("div",{style:{backgroundColor:e.colors.surface,borderRadius:e.borderRadius.md,border:`1px solid ${e.colors.border}`,overflow:"hidden"},children:l.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[l.jsx("thead",{children:l.jsxs("tr",{style:{backgroundColor:e.colors.surfaceElevated,borderBottom:`1px solid ${e.colors.border}`},children:[l.jsx("th",{style:{textAlign:"left",padding:e.spacing.md,color:e.colors.textSecondary,fontSize:e.typography.fontSize.sm,fontWeight:600},children:"Hook"}),l.jsx("th",{style:{textAlign:"right",padding:e.spacing.md,color:e.colors.textSecondary,fontSize:e.typography.fontSize.sm,fontWeight:600},children:"Total (ms)"}),l.jsx("th",{style:{textAlign:"right",padding:e.spacing.md,color:e.colors.textSecondary,fontSize:e.typography.fontSize.sm,fontWeight:600},children:"Avg (ms)"}),l.jsx("th",{style:{textAlign:"right",padding:e.spacing.md,color:e.colors.textSecondary,fontSize:e.typography.fontSize.sm,fontWeight:600},children:"Max (ms)"}),l.jsx("th",{style:{textAlign:"right",padding:e.spacing.md,color:e.colors.textSecondary,fontSize:e.typography.fontSize.sm,fontWeight:600},children:"%"})]})}),l.jsx("tbody",{children:s.map((n,d)=>{const m=Bs(n.avg,{good:5,warning:10});return l.jsxs("tr",{style:{borderBottom:d<s.length-1?`1px solid ${e.colors.borderLight}`:"none",transition:e.transitions.fast},onMouseEnter:u=>{u.currentTarget.style.backgroundColor=e.colors.surfaceElevated},onMouseLeave:u=>{u.currentTarget.style.backgroundColor="transparent"},children:[l.jsx("td",{style:{padding:e.spacing.md,color:e.colors.text,fontFamily:e.typography.fontFamilyMono,fontSize:e.typography.fontSize.sm},children:n.name}),l.jsx("td",{style:{textAlign:"right",padding:e.spacing.md,color:e.colors.text,fontFamily:e.typography.fontFamilyMono,fontSize:e.typography.fontSize.sm},children:j(n.total,2)}),l.jsx("td",{style:{textAlign:"right",padding:e.spacing.md,color:m,fontFamily:e.typography.fontFamilyMono,fontSize:e.typography.fontSize.sm,fontWeight:600},children:j(n.avg,3)}),l.jsx("td",{style:{textAlign:"right",padding:e.spacing.md,color:e.colors.text,fontFamily:e.typography.fontFamilyMono,fontSize:e.typography.fontSize.sm},children:j(n.max,3)}),l.jsxs("td",{style:{textAlign:"right",padding:e.spacing.md,color:e.colors.textSecondary,fontFamily:e.typography.fontFamilyMono,fontSize:e.typography.fontSize.sm},children:[j(n.percentage,1),"%"]})]},n.name)})})]})})]})};function Qe(){const[c,t]=z.useState(null),e=z.useRef(null);return z.useEffect(()=>{const s=()=>{if(!P.getPaused()){const r=Gt.getStats();r&&t(r)}};s(),e.current=window.setInterval(s,100);const i=P.subscribe(r=>{r||s()});return()=>{e.current!==null&&clearInterval(e.current),i()}},[]),c}const Gi=()=>{const c=Qe(),t=$,e=z.useMemo(()=>c?c.drawCalls<=100?"good":c.drawCalls<=500?"warning":"error":"neutral",[c]),s=z.useMemo(()=>c?c.triangles<=1e5?"good":c.triangles<=5e5?"warning":"error":"neutral",[c]);if(!c)return l.jsx("div",{style:{padding:t.spacing.lg,textAlign:"center",color:t.colors.textSecondary,fontSize:t.typography.fontSize.sm},children:"Aucune donnée GPU disponible. Assurez-vous que le composant est à l'intérieur d'un Canvas R3F."});const i=r=>r===0?"0 B":r<1024?`${j(r,0)} B`:r<1024*1024?`${j(r/1024,2)} KB`:`${j(r/(1024*1024),2)} MB`;return l.jsxs("div",{style:{padding:t.spacing.md},children:[l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(150px, 1fr))",gap:t.spacing.md,marginBottom:t.spacing.lg},children:[l.jsx(_,{label:"Draw Calls",value:c.drawCalls.toLocaleString(),status:e}),l.jsx(_,{label:"Triangles",value:c.triangles.toLocaleString(),status:s}),l.jsx(_,{label:"Points",value:c.points.toLocaleString()}),l.jsx(_,{label:"Lines",value:c.lines.toLocaleString()})]}),l.jsxs("div",{style:{backgroundColor:t.colors.surface,borderRadius:t.borderRadius.md,padding:t.spacing.md,marginBottom:t.spacing.lg,border:`1px solid ${t.colors.border}`},children:[l.jsx("div",{style:{fontSize:t.typography.fontSize.md,fontWeight:600,color:t.colors.text,marginBottom:t.spacing.md},children:"GPU Memory"}),l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(120px, 1fr))",gap:t.spacing.md},children:[l.jsx(_,{label:"Textures",value:i(c.memory.textures)}),l.jsx(_,{label:"Geometries",value:i(c.memory.geometries)}),l.jsx(_,{label:"Programs",value:i(c.memory.programs)}),l.jsx(_,{label:"Total",value:i(c.memory.total),color:c.memory.total>100*1024*1024?t.colors.warning:t.colors.success})]})]}),l.jsxs("div",{style:{backgroundColor:t.colors.surface,borderRadius:t.borderRadius.md,padding:t.spacing.md,border:`1px solid ${t.colors.border}`},children:[l.jsx("div",{style:{fontSize:t.typography.fontSize.md,fontWeight:600,color:t.colors.text,marginBottom:t.spacing.md},children:"Resources"}),l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(120px, 1fr))",gap:t.spacing.md},children:[l.jsx(_,{label:"Textures",value:c.textures}),l.jsx(_,{label:"Geometries",value:c.geometries}),l.jsx(_,{label:"Programs",value:c.programs})]})]})]})};function Xi(){const[c,t]=z.useState(null),e=z.useRef(null);return z.useEffect(()=>{const s=()=>{if(!P.getPaused()){const r=Ls.getStats();r&&t(r)}};s(),e.current=window.setInterval(s,500);const i=P.subscribe(r=>{r||s()});return()=>{e.current!==null&&clearInterval(e.current),i()}},[]),c}const Ji=()=>{const c=Xi(),t=$;if(!c)return l.jsx("div",{style:{padding:t.spacing.lg,textAlign:"center",color:t.colors.textSecondary,fontSize:t.typography.fontSize.sm},children:"Aucune donnée de scène disponible. Assurez-vous que le composant est à l'intérieur d'un Canvas R3F."});const e=s=>s<1024?`${j(s,0)} B`:s<1024*1024?`${j(s/1024,2)} KB`:`${j(s/(1024*1024),2)} MB`;return l.jsxs("div",{style:{padding:t.spacing.md},children:[l.jsxs("div",{style:{backgroundColor:t.colors.surface,borderRadius:t.borderRadius.md,padding:t.spacing.md,marginBottom:t.spacing.lg,border:`1px solid ${t.colors.border}`},children:[l.jsx("div",{style:{fontSize:t.typography.fontSize.md,fontWeight:600,color:t.colors.text,marginBottom:t.spacing.md},children:"Objects"}),l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(120px, 1fr))",gap:t.spacing.md},children:[l.jsx(_,{label:"Total",value:c.objects.total.toLocaleString()}),l.jsx(_,{label:"Meshes",value:c.objects.meshes.toLocaleString()}),l.jsx(_,{label:"Lights",value:c.objects.lights.toLocaleString()}),l.jsx(_,{label:"Cameras",value:c.objects.cameras.toLocaleString()}),l.jsx(_,{label:"Groups",value:c.objects.groups.toLocaleString()}),l.jsx(_,{label:"Visible",value:c.visible.total.toLocaleString(),color:c.visible.total===c.objects.total?t.colors.success:t.colors.warning})]})]}),l.jsxs("div",{style:{backgroundColor:t.colors.surface,borderRadius:t.borderRadius.md,padding:t.spacing.md,marginBottom:t.spacing.lg,border:`1px solid ${t.colors.border}`},children:[l.jsxs("div",{style:{fontSize:t.typography.fontSize.md,fontWeight:600,color:t.colors.text,marginBottom:t.spacing.md},children:["Materials (",c.materials.total,")"]}),l.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:t.spacing.sm},children:Object.entries(c.materials.byType).map(([s,i])=>l.jsxs("div",{style:{backgroundColor:t.colors.surfaceElevated,padding:`${t.spacing.xs} ${t.spacing.sm}`,borderRadius:t.borderRadius.sm,fontSize:t.typography.fontSize.xs,color:t.colors.textSecondary,fontFamily:t.typography.fontFamilyMono},children:[s,": ",i]},s))})]}),c.textures.total>0&&l.jsxs("div",{style:{backgroundColor:t.colors.surface,borderRadius:t.borderRadius.md,padding:t.spacing.md,marginBottom:t.spacing.lg,border:`1px solid ${t.colors.border}`},children:[l.jsx("div",{style:{fontSize:t.typography.fontSize.md,fontWeight:600,color:t.colors.text,marginBottom:t.spacing.md},children:"Textures"}),l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(150px, 1fr))",gap:t.spacing.md},children:[l.jsx(_,{label:"Total",value:c.textures.total.toLocaleString()}),l.jsx(_,{label:"Total Size",value:e(c.textures.totalSize)}),c.textures.environment>0&&l.jsx(_,{label:"Environment",value:c.textures.environment.toLocaleString(),color:t.colors.info}),c.textures.system>0&&l.jsx(_,{label:"System",value:c.textures.system.toLocaleString(),color:t.colors.warning})]})]}),l.jsxs("div",{style:{backgroundColor:t.colors.surface,borderRadius:t.borderRadius.md,padding:t.spacing.md,marginBottom:t.spacing.lg,border:`1px solid ${t.colors.border}`},children:[l.jsx("div",{style:{fontSize:t.typography.fontSize.md,fontWeight:600,color:t.colors.text,marginBottom:t.spacing.md},children:"Geometries"}),l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(150px, 1fr))",gap:t.spacing.md},children:[l.jsx(_,{label:"Total",value:c.geometries.total.toLocaleString()}),l.jsx(_,{label:"Vertices",value:c.geometries.vertices.toLocaleString()}),l.jsx(_,{label:"Faces",value:c.geometries.faces.toLocaleString()})]})]}),l.jsxs("div",{style:{backgroundColor:t.colors.surface,borderRadius:t.borderRadius.md,padding:t.spacing.md,border:`1px solid ${t.colors.border}`},children:[l.jsx("div",{style:{fontSize:t.typography.fontSize.md,fontWeight:600,color:t.colors.text,marginBottom:t.spacing.md},children:"Complexity"}),l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(150px, 1fr))",gap:t.spacing.md},children:[l.jsx(_,{label:"Avg Vertices/Mesh",value:j(c.complexity.averageVerticesPerMesh,0)}),l.jsx(_,{label:"Avg Faces/Mesh",value:j(c.complexity.averageFacesPerMesh,0)}),l.jsx(_,{label:"Est. Draw Calls",value:c.complexity.totalDrawCalls.toLocaleString()})]})]})]})};function Ke(){const[c,t]=z.useState(null),e=z.useRef(null);return z.useEffect(()=>{const s=()=>{if(!P.getPaused()){const r=Ce.getStats();r&&t(r)}};s(),e.current=window.setInterval(s,1e3);const i=P.subscribe(r=>{r||s()});return()=>{e.current!==null&&clearInterval(e.current),i()}},[]),c}const Zi=()=>{const c=Ke(),t=$,e=r=>r===0?"0 B":r<1024?`${j(r,0)} B`:r<1024*1024?`${j(r/1024,2)} KB`:r<1024*1024*1024?`${j(r/(1024*1024),2)} MB`:`${j(r/(1024*1024*1024),2)} GB`,s=z.useMemo(()=>{if(!c)return"neutral";const r=c.jsHeap.percentage;return r<50?"good":r<80?"warning":"error"},[c]),i=z.useMemo(()=>c?c.leaks.detected?"error":"good":"neutral",[c]);return c?l.jsxs("div",{style:{padding:t.spacing.md},children:[c.jsHeap.limit>0&&l.jsxs("div",{style:{backgroundColor:t.colors.surface,borderRadius:t.borderRadius.md,padding:t.spacing.md,marginBottom:t.spacing.lg,border:`1px solid ${t.colors.border}`},children:[l.jsx("div",{style:{fontSize:t.typography.fontSize.sm,fontWeight:600,color:t.colors.text,marginBottom:t.spacing.sm},children:"JavaScript Heap Memory"}),l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(150px, 1fr))",gap:t.spacing.md,marginBottom:t.spacing.md},children:[l.jsx(_,{label:"Used",value:e(c.jsHeap.used),status:s}),l.jsx(_,{label:"Total",value:e(c.jsHeap.total)}),l.jsx(_,{label:"Limit",value:e(c.jsHeap.limit)}),l.jsx(_,{label:"Usage",value:`${j(c.jsHeap.percentage,1)}%`,status:s})]}),l.jsx("div",{style:{width:"100%",height:"8px",backgroundColor:t.colors.border,borderRadius:t.borderRadius.sm,overflow:"hidden",marginTop:t.spacing.sm},children:l.jsx("div",{style:{width:`${Math.min(100,c.jsHeap.percentage)}%`,height:"100%",backgroundColor:c.jsHeap.percentage<=50?t.colors.success:c.jsHeap.percentage<=80?t.colors.warning:t.colors.error,transition:t.transitions.normal}})})]}),c.gpuMemory.total>0&&l.jsxs("div",{style:{backgroundColor:t.colors.surface,borderRadius:t.borderRadius.md,padding:t.spacing.md,marginBottom:t.spacing.lg,border:`1px solid ${t.colors.border}`},children:[l.jsx("div",{style:{fontSize:t.typography.fontSize.sm,fontWeight:600,color:t.colors.text,marginBottom:t.spacing.sm},children:"GPU Memory (Estimated)"}),l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(120px, 1fr))",gap:t.spacing.sm},children:[l.jsx(_,{label:"Textures",value:e(c.gpuMemory.textures)}),l.jsx(_,{label:"Geometries",value:e(c.gpuMemory.geometries)}),l.jsx(_,{label:"Total",value:e(c.gpuMemory.total)})]}),l.jsx("div",{style:{fontSize:t.typography.fontSize.xs,color:t.colors.textTertiary,marginTop:t.spacing.sm},children:"Note: GPU memory is an estimation based on resource counts. Actual usage may vary."})]}),l.jsxs("div",{style:{backgroundColor:t.colors.surface,borderRadius:t.borderRadius.md,padding:t.spacing.md,marginBottom:t.spacing.lg,border:`1px solid ${t.colors.border}`,overflow:"hidden"},children:[l.jsx("div",{style:{fontSize:t.typography.fontSize.sm,fontWeight:600,color:t.colors.text,marginBottom:t.spacing.sm},children:"Memory Evolution (Last 60s)"}),l.jsx(Ui,{width:"100%",height:150,timeWindow:60,metric:"both",showGrid:!0,showLabels:!0})]}),l.jsxs("div",{style:{backgroundColor:t.colors.surface,borderRadius:t.borderRadius.md,padding:t.spacing.md,border:`1px solid ${t.colors.border}`},children:[l.jsx("div",{style:{fontSize:t.typography.fontSize.sm,fontWeight:600,color:t.colors.text,marginBottom:t.spacing.sm},children:"Memory Leak Detection"}),l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:t.spacing.sm,marginBottom:t.spacing.sm},children:[l.jsx("div",{style:{width:"12px",height:"12px",borderRadius:"50%",backgroundColor:i==="good"?t.colors.success:t.colors.error}}),l.jsx("div",{style:{color:t.colors.text,fontSize:t.typography.fontSize.sm},children:c.leaks.detected?"Potential leak detected":"No leaks detected"})]}),l.jsxs("div",{style:{fontSize:t.typography.fontSize.xs,color:t.colors.textSecondary,fontFamily:t.typography.fontFamilyMono},children:[l.jsxs("div",{children:["Growth Rate: ",e(Math.abs(c.leaks.growthRate)),"/s"]}),l.jsxs("div",{children:["Trend: ",c.leaks.trend]})]})]})]}):l.jsx("div",{style:{padding:t.spacing.lg,textAlign:"center",color:t.colors.textSecondary,fontSize:t.typography.fontSize.sm},children:"Aucune donnée de mémoire disponible. Les stats de mémoire JS nécessitent Chrome."})};function Qi(){const[c,t]=z.useState(null),e=z.useRef(null);return z.useEffect(()=>{const s=()=>{if(!P.getPaused()){const r=q.getLastBreakdown();r&&t(r)}};s(),e.current=window.setInterval(s,100);const i=P.subscribe(r=>{r||s()});return()=>{e.current!==null&&clearInterval(e.current),i()}},[]),c}const Ki=()=>{const c=Qi(),t=$,e=a=>a<.1?`${j(a*1e3,0)} μs`:a<1?`${j(a,2)} ms`:`${j(a,2)} ms`,s=(a,h)=>h===0?"0%":`${j(a/h*100,1)}%`,i=z.useMemo(()=>c?c.total<=16.67?"good":c.total<=33.33?"warning":"error":"neutral",[c]);if(!c)return l.jsx("div",{style:{padding:t.spacing.lg,textAlign:"center",color:t.colors.textSecondary,fontSize:t.typography.fontSize.sm},children:"Aucune donnée de breakdown de frame disponible. Le frame breakdown nécessite une instrumentation du code."});const r=[{name:"React",value:c.phases.react,color:t.colors.primary},{name:"Update",value:c.phases.update,color:t.colors.info},{name:"Physics",value:c.phases.physics,color:t.colors.warning},{name:"Render",value:c.phases.render,color:t.colors.success},{name:"Post-Process",value:c.phases.postProcess,color:t.colors.accent},{name:"Other",value:c.phases.other,color:t.colors.textSecondary}].filter(a=>a.value>0),o=Math.max(...r.map(a=>a.value),c.total);return l.jsxs("div",{style:{padding:t.spacing.md},children:[l.jsxs("div",{style:{backgroundColor:t.colors.surface,borderRadius:t.borderRadius.md,padding:t.spacing.md,marginBottom:t.spacing.lg,border:`1px solid ${t.colors.border}`},children:[l.jsx("div",{style:{fontSize:t.typography.fontSize.sm,fontWeight:600,color:t.colors.text,marginBottom:t.spacing.sm},children:"Total Frame Time"}),l.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:t.spacing.sm,marginBottom:t.spacing.sm},children:[l.jsx(_,{label:"Frame Time",value:e(c.total),status:i}),l.jsxs("div",{style:{fontSize:t.typography.fontSize.xs,color:t.colors.textSecondary},children:["(",j(1e3/c.total,1)," FPS)"]})]})]}),l.jsxs("div",{style:{backgroundColor:t.colors.surface,borderRadius:t.borderRadius.md,padding:t.spacing.md,marginBottom:t.spacing.lg,border:`1px solid ${t.colors.border}`},children:[l.jsx("div",{style:{fontSize:t.typography.fontSize.sm,fontWeight:600,color:t.colors.text,marginBottom:t.spacing.sm},children:"Phase Breakdown"}),l.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(120px, 1fr))",gap:t.spacing.sm,marginBottom:t.spacing.md},children:r.map(a=>l.jsx(_,{label:a.name,value:e(a.value)},a.name))}),l.jsxs("div",{style:{marginTop:t.spacing.md},children:[l.jsx("div",{style:{fontSize:t.typography.fontSize.xs,color:t.colors.textSecondary,marginBottom:t.spacing.sm},children:"Timeline (Waterfall)"}),l.jsx("div",{style:{position:"relative",height:"200px",backgroundColor:t.colors.background,borderRadius:t.borderRadius.sm,border:`1px solid ${t.colors.border}`,padding:t.spacing.xs},children:r.map((a,h)=>{const n=a.value/o*100,d=r.slice(0,h).reduce((m,u)=>m+u.value/o*100,0);return l.jsx("div",{style:{position:"absolute",left:`${d}%`,width:`${n}%`,height:"30px",backgroundColor:a.color,borderRadius:t.borderRadius.sm,display:"flex",alignItems:"center",justifyContent:"center",fontSize:t.typography.fontSize.xs,color:t.colors.background,fontWeight:600,marginTop:`${h*35}px`,opacity:.8,border:`1px solid ${t.colors.border}`},title:`${a.name}: ${e(a.value)} (${s(a.value,c.total)})`,children:n>5&&`${a.name}: ${e(a.value)}`},a.name)})})]})]}),c.timeline.length>0&&l.jsxs("div",{style:{backgroundColor:t.colors.surface,borderRadius:t.borderRadius.md,padding:t.spacing.md,border:`1px solid ${t.colors.border}`},children:[l.jsx("div",{style:{fontSize:t.typography.fontSize.sm,fontWeight:600,color:t.colors.text,marginBottom:t.spacing.sm},children:"Timeline Details"}),l.jsx("div",{style:{maxHeight:"200px",overflowY:"auto",fontSize:t.typography.fontSize.xs,fontFamily:t.typography.fontFamilyMono,color:t.colors.textSecondary},children:c.timeline.slice(-20).reverse().map((a,h)=>l.jsxs("div",{style:{padding:t.spacing.xs,borderBottom:`1px solid ${t.colors.border}`,display:"flex",justifyContent:"space-between"},children:[l.jsx("span",{children:a.name}),l.jsx("span",{children:e(a.duration)})]},h))})]})]})};class tr{budget=null;violations=[];maxHistorySize=100;listeners=new Set;STORAGE_KEY="r3f-profiler-budget";constructor(){this.loadBudget()}loadBudget(){try{const t=localStorage.getItem(this.STORAGE_KEY);if(t){const e=JSON.parse(t);this.isValidBudget(e)&&(this.budget=e)}}catch(t){console.warn("Failed to load saved budget from localStorage:",t)}}saveBudget(){try{this.budget?localStorage.setItem(this.STORAGE_KEY,JSON.stringify(this.budget)):localStorage.removeItem(this.STORAGE_KEY)}catch(t){console.warn("Failed to save budget to localStorage:",t)}}isValidBudget(t){return!t||typeof t!="object"?!1:t.fps&&typeof t.fps.min=="number"||t.frameTime&&typeof t.frameTime.max=="number"||t.memory&&(typeof t.memory.max=="number"||t.memory.jsHeap)||t.gpu&&(t.gpu.drawCalls||t.gpu.triangles)}setBudget(t){!t||!t.fps&&!t.frameTime&&!t.memory&&!t.gpu?this.budget=null:this.budget=t,this.violations=[],this.saveBudget(),this.notifyListeners()}getBudget(){return this.budget}checkBudget(t){if(!this.budget)return[];const e=[];return this.budget.fps?.min!==void 0&&t.fps!==void 0&&t.fps<this.budget.fps.min&&e.push({id:`fps-${Date.now()}-${Math.random()}`,metric:"fps",current:t.fps,budget:this.budget.fps.min,severity:t.fps<this.budget.fps.min*.7?"error":"warning",timestamp:performance.now(),message:`FPS is ${t.fps.toFixed(1)} (budget: ${this.budget.fps.min} FPS)`}),this.budget.frameTime?.max!==void 0&&t.frameTime!==void 0&&t.frameTime>this.budget.frameTime.max&&e.push({id:`frameTime-${Date.now()}-${Math.random()}`,metric:"frameTime",current:t.frameTime,budget:this.budget.frameTime.max,severity:t.frameTime>this.budget.frameTime.max*1.5?"error":"warning",timestamp:performance.now(),message:`Frame time is ${t.frameTime.toFixed(2)}ms (budget: ${this.budget.frameTime.max}ms)`}),this.budget.memory&&(this.budget.memory.max!==void 0&&t.memory?.used!==void 0&&t.memory.used>this.budget.memory.max&&e.push({id:`memory-${Date.now()}-${Math.random()}`,metric:"memory",current:t.memory.used,budget:this.budget.memory.max,severity:t.memory.used>this.budget.memory.max*1.2?"error":"warning",timestamp:performance.now(),message:`Memory usage is ${(t.memory.used/(1024*1024)).toFixed(2)}MB (budget: ${(this.budget.memory.max/(1024*1024)).toFixed(2)}MB)`}),this.budget.memory.jsHeap?.maxPercentage!==void 0&&t.memory?.jsHeapPercentage!==void 0&&t.memory.jsHeapPercentage>this.budget.memory.jsHeap.maxPercentage&&e.push({id:`jsHeap-${Date.now()}-${Math.random()}`,metric:"jsHeap",current:t.memory.jsHeapPercentage,budget:this.budget.memory.jsHeap.maxPercentage,severity:t.memory.jsHeapPercentage>this.budget.memory.jsHeap.maxPercentage*1.1?"error":"warning",timestamp:performance.now(),message:`JS Heap usage is ${t.memory.jsHeapPercentage.toFixed(1)}% (budget: ${this.budget.memory.jsHeap.maxPercentage}%)`})),this.budget.gpu&&(this.budget.gpu.drawCalls?.max!==void 0&&t.gpu?.drawCalls!==void 0&&t.gpu.drawCalls>this.budget.gpu.drawCalls.max&&e.push({id:`drawCalls-${Date.now()}-${Math.random()}`,metric:"drawCalls",current:t.gpu.drawCalls,budget:this.budget.gpu.drawCalls.max,severity:t.gpu.drawCalls>this.budget.gpu.drawCalls.max*1.5?"error":"warning",timestamp:performance.now(),message:`Draw calls: ${t.gpu.drawCalls} (budget: ${this.budget.gpu.drawCalls.max})`}),this.budget.gpu.triangles?.max!==void 0&&t.gpu?.triangles!==void 0&&t.gpu.triangles>this.budget.gpu.triangles.max&&e.push({id:`triangles-${Date.now()}-${Math.random()}`,metric:"triangles",current:t.gpu.triangles,budget:this.budget.gpu.triangles.max,severity:t.gpu.triangles>this.budget.gpu.triangles.max*1.5?"error":"warning",timestamp:performance.now(),message:`Triangles: ${t.gpu.triangles.toLocaleString()} (budget: ${this.budget.gpu.triangles.max.toLocaleString()})`})),e.length>0&&(this.violations.push(...e),this.violations.length>this.maxHistorySize&&(this.violations=this.violations.slice(-this.maxHistorySize)),this.notifyListeners()),e}getViolations(){return[...this.violations]}getRecentViolations(t=60){const e=performance.now()-t*1e3;return this.violations.filter(s=>s.timestamp>=e)}getViolationsByMetric(t){return this.violations.filter(e=>e.metric===t)}clearViolations(){this.violations=[],this.notifyListeners()}getRecommendedBudget(t){const e={};return t.fps!==void 0&&(e.fps={min:Math.max(30,Math.floor(t.fps*.9))}),t.frameTime!==void 0&&(e.frameTime={max:Math.ceil(t.frameTime*1.1)}),t.memory?.used!==void 0&&(e.memory={max:Math.ceil(t.memory.used*1.2),jsHeap:{maxPercentage:80}}),t.gpu&&(e.gpu={},t.gpu.drawCalls!==void 0&&(e.gpu.drawCalls={max:Math.ceil(t.gpu.drawCalls*1.2)}),t.gpu.triangles!==void 0&&(e.gpu.triangles={max:Math.ceil(t.gpu.triangles*1.2)})),e}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}notifyListeners(){const t=this.getRecentViolations(60);this.listeners.forEach(e=>{try{e(t)}catch(s){console.error("Error in budget violation listener:",s)}})}reset(){this.budget=null,this.violations=[],this.listeners.clear(),localStorage.removeItem(this.STORAGE_KEY)}}const nt=new tr;function er(){const[c,t]=z.useState(null),[e,s]=z.useState([]);return z.useEffect(()=>{t(nt.getBudget()),s(nt.getRecentViolations(60));const h=nt.subscribe(n=>{s(n),t(nt.getBudget())});return()=>{h()}},[]),{budget:c,violations:e,setBudget:h=>{nt.setBudget(h),t(h),s([])},clearViolations:()=>{nt.clearViolations(),s([])},clearBudget:()=>{nt.setBudget({}),t(null),s([])},getRecommendedBudget:h=>nt.getRecommendedBudget(h)}}class sr{alerts=[];maxAlerts=50;listeners=new Set;soundEnabled=!1;createFromViolation(t){return{id:`alert-${t.id}`,type:"budget",severity:t.severity,title:`Budget Violation: ${t.metric}`,message:t.message,timestamp:t.timestamp,dismissed:!1,data:{violation:t}}}createAlert(t,e,s,i,r){const o={id:`alert-${Date.now()}-${Math.random()}`,type:t,severity:e,title:s,message:i,timestamp:performance.now(),dismissed:!1,data:r};return this.addAlert(o),o}addAlert(t){if(t.type==="budget"&&t.data?.violation){const e=t.data.violation;this.alerts=this.alerts.filter(s=>!(s.type==="budget"&&s.data?.violation&&s.data.violation.metric===e.metric))}this.alerts.push(t),this.alerts.length>this.maxAlerts&&(this.alerts=this.alerts.slice(-this.maxAlerts)),this.soundEnabled&&t.severity==="error"&&this.playAlertSound(),this.notifyListeners()}getAlerts(t=!1){return t?[...this.alerts]:this.alerts.filter(e=>!e.dismissed)}getActiveAlerts(){return this.alerts.filter(t=>!t.dismissed)}getAlertsBySeverity(t){return this.alerts.filter(e=>!e.dismissed&&e.severity===t)}getAlertsByType(t){return this.alerts.filter(e=>!e.dismissed&&e.type===t)}dismissAlert(t){const e=this.alerts.find(s=>s.id===t);e&&(e.dismissed=!0,this.notifyListeners())}dismissAll(){this.alerts.forEach(t=>{t.dismissed=!0}),this.notifyListeners()}removeAlert(t){this.alerts=this.alerts.filter(e=>e.id!==t),this.notifyListeners()}clearAlerts(){this.alerts=[],this.notifyListeners()}setSoundEnabled(t){this.soundEnabled=t}isSoundEnabled(){return this.soundEnabled}playAlertSound(){try{const t=new(window.AudioContext||window.webkitAudioContext),e=t.createOscillator(),s=t.createGain();e.connect(s),s.connect(t.destination),e.frequency.value=800,e.type="sine",s.gain.setValueAtTime(.3,t.currentTime),s.gain.exponentialRampToValueAtTime(.01,t.currentTime+.1),e.start(t.currentTime),e.stop(t.currentTime+.1)}catch(t){console.debug("Could not play alert sound:",t)}}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}notifyListeners(){const t=this.getActiveAlerts();this.listeners.forEach(e=>{try{e(t)}catch(s){console.error("Error in alert listener:",s)}})}reset(){this.alerts=[],this.listeners.clear(),this.soundEnabled=!1}}const ks=new sr;function ir(){const c=se(),t=Vt(),e=Qe(),s=Ke(),i=z.useRef(null);z.useEffect(()=>{const r=()=>{if(!nt.getBudget())return;let a=0,h=0;t&&t.totalTime>0&&t.frames>0?(h=t.totalTime/t.frames,a=1e3/h):c.length>0?(h=c.reduce((m,u)=>m+u,0)/c.length,a=h>0?1e3/h:0):e&&e.frameTime>0&&(h=e.frameTime,a=h>0?1e3/h:0);const n={fps:a,frameTime:h,memory:s?{used:s.jsHeap.used,jsHeapPercentage:s.jsHeap.percentage}:void 0,gpu:e?{drawCalls:e.drawCalls,triangles:e.triangles}:void 0};nt.checkBudget(n).forEach(m=>{ks.getAlerts().find(p=>p.type==="budget"&&p.data?.violation&&p.data.violation.id===m.id)||ks.createFromViolation(m)})};return i.current=window.setInterval(r,1e3),r(),()=>{i.current!==null&&clearInterval(i.current)}},[c,t,e,s])}const rr=()=>{const{budget:c,violations:t,setBudget:e,clearViolations:s,clearBudget:i,getRecommendedBudget:r}=er(),o=se(),a=Qe(),h=Ke(),n=$;ir();const[d,m]=z.useState(!1),[u,p]=z.useState(c||{}),f=z.useMemo(()=>{const b=o.length>0?o.reduce((F,A)=>F+A,0)/o.length:0;return{fps:b>0?1e3/b:0,frameTime:b,memory:h?{used:h.jsHeap.used,jsHeapPercentage:h.jsHeap.percentage}:void 0,gpu:a?{drawCalls:a.drawCalls,triangles:a.triangles}:void 0}},[o,a,h]),x=b=>b===0?"0 B":b<1024?`${j(b,0)} B`:b<1024*1024?`${j(b/1024,2)} KB`:b<1024*1024*1024?`${j(b/(1024*1024),2)} MB`:`${j(b/(1024*1024*1024),2)} GB`,g=()=>{e(u),m(!1)},y=()=>{const b=r(f);p(b),e(b),m(!1)},w=()=>{p(c||{}),m(!1)},M=z.useMemo(()=>{const b=t.filter(F=>F.severity==="error").length,v=t.filter(F=>F.severity==="warning").length;return{errors:b,warnings:v}},[t]);return l.jsxs("div",{style:{padding:n.spacing.md},children:[l.jsxs("div",{style:{backgroundColor:n.colors.surface,borderRadius:n.borderRadius.md,padding:n.spacing.md,marginBottom:n.spacing.lg,border:`1px solid ${n.colors.border}`},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:n.spacing.md},children:[l.jsx("div",{style:{fontSize:n.typography.fontSize.sm,fontWeight:600,color:n.colors.text},children:"Budget Status"}),l.jsxs("div",{style:{display:"flex",gap:n.spacing.sm,alignItems:"center"},children:[M.errors>0&&l.jsx(wt,{severity:"error",count:M.errors}),M.warnings>0&&l.jsx(wt,{severity:"warning",count:M.warnings}),!c&&l.jsx("div",{style:{fontSize:n.typography.fontSize.xs,color:n.colors.textSecondary},children:"No budget configured"})]})]}),c?l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(150px, 1fr))",gap:n.spacing.sm},children:[c.fps&&l.jsx(_,{label:"FPS Min",value:c.fps.min,unit:"FPS"}),c.frameTime&&l.jsx(_,{label:"Frame Time Max",value:`${c.frameTime.max.toFixed(2)}ms`}),c.memory?.max&&l.jsx(_,{label:"Memory Max",value:x(c.memory.max)}),c.gpu?.drawCalls?.max&&l.jsx(_,{label:"Draw Calls Max",value:c.gpu.drawCalls.max.toLocaleString()}),c.gpu?.triangles?.max&&l.jsx(_,{label:"Triangles Max",value:c.gpu.triangles.max.toLocaleString()})]}):l.jsx("div",{style:{padding:n.spacing.md,textAlign:"center",color:n.colors.textSecondary,fontSize:n.typography.fontSize.sm},children:"Configure a budget to start monitoring performance thresholds"})]}),l.jsxs("div",{style:{backgroundColor:n.colors.surface,borderRadius:n.borderRadius.md,padding:n.spacing.md,marginBottom:n.spacing.lg,border:`1px solid ${n.colors.border}`},children:[l.jsx("div",{style:{fontSize:n.typography.fontSize.sm,fontWeight:600,color:n.colors.text,marginBottom:n.spacing.md},children:"Budget Configuration"}),d?l.jsxs("div",{children:[l.jsxs("div",{style:{display:"grid",gap:n.spacing.sm,marginBottom:n.spacing.md},children:[l.jsxs("div",{children:[l.jsx("label",{style:{display:"block",fontSize:n.typography.fontSize.xs,color:n.colors.textSecondary,marginBottom:n.spacing.xs},children:"FPS Minimum"}),l.jsx("input",{type:"number",value:u.fps?.min||"",onChange:b=>p({...u,fps:{min:parseInt(b.target.value)||0}}),placeholder:"60",style:{width:"100%",padding:n.spacing.sm,backgroundColor:n.colors.background,border:`1px solid ${n.colors.border}`,borderRadius:n.borderRadius.sm,color:n.colors.text,fontSize:n.typography.fontSize.sm}})]}),l.jsxs("div",{children:[l.jsx("label",{style:{display:"block",fontSize:n.typography.fontSize.xs,color:n.colors.textSecondary,marginBottom:n.spacing.xs},children:"Frame Time Maximum (ms)"}),l.jsx("input",{type:"number",value:u.frameTime?.max||"",onChange:b=>p({...u,frameTime:{max:parseFloat(b.target.value)||0}}),placeholder:"16.67",step:"0.1",style:{width:"100%",padding:n.spacing.sm,backgroundColor:n.colors.background,border:`1px solid ${n.colors.border}`,borderRadius:n.borderRadius.sm,color:n.colors.text,fontSize:n.typography.fontSize.sm}})]}),l.jsxs("div",{children:[l.jsx("label",{style:{display:"block",fontSize:n.typography.fontSize.xs,color:n.colors.textSecondary,marginBottom:n.spacing.xs},children:"Memory Maximum (MB)"}),l.jsx("input",{type:"number",value:u.memory?.max?u.memory.max/(1024*1024):"",onChange:b=>p({...u,memory:{...u.memory,max:(parseFloat(b.target.value)||0)*1024*1024}}),placeholder:"512",step:"1",style:{width:"100%",padding:n.spacing.sm,backgroundColor:n.colors.background,border:`1px solid ${n.colors.border}`,borderRadius:n.borderRadius.sm,color:n.colors.text,fontSize:n.typography.fontSize.sm}})]}),l.jsxs("div",{children:[l.jsx("label",{style:{display:"block",fontSize:n.typography.fontSize.xs,color:n.colors.textSecondary,marginBottom:n.spacing.xs},children:"Draw Calls Maximum"}),l.jsx("input",{type:"number",value:u.gpu?.drawCalls?.max||"",onChange:b=>p({...u,gpu:{...u.gpu,drawCalls:{max:parseInt(b.target.value)||0}}}),placeholder:"100",style:{width:"100%",padding:n.spacing.sm,backgroundColor:n.colors.background,border:`1px solid ${n.colors.border}`,borderRadius:n.borderRadius.sm,color:n.colors.text,fontSize:n.typography.fontSize.sm}})]}),l.jsxs("div",{children:[l.jsx("label",{style:{display:"block",fontSize:n.typography.fontSize.xs,color:n.colors.textSecondary,marginBottom:n.spacing.xs},children:"Triangles Maximum"}),l.jsx("input",{type:"number",value:u.gpu?.triangles?.max||"",onChange:b=>p({...u,gpu:{...u.gpu,triangles:{max:parseInt(b.target.value)||0}}}),placeholder:"100000",style:{width:"100%",padding:n.spacing.sm,backgroundColor:n.colors.background,border:`1px solid ${n.colors.border}`,borderRadius:n.borderRadius.sm,color:n.colors.text,fontSize:n.typography.fontSize.sm}})]})]}),l.jsxs("div",{style:{display:"flex",gap:n.spacing.sm},children:[l.jsx("button",{onClick:g,style:{padding:`${n.spacing.sm} ${n.spacing.md}`,backgroundColor:n.colors.success,color:n.colors.background,border:"none",borderRadius:n.borderRadius.sm,cursor:"pointer",fontSize:n.typography.fontSize.sm,fontWeight:600},children:"Save"}),l.jsx("button",{onClick:w,style:{padding:`${n.spacing.sm} ${n.spacing.md}`,backgroundColor:"transparent",color:n.colors.textSecondary,border:`1px solid ${n.colors.border}`,borderRadius:n.borderRadius.sm,cursor:"pointer",fontSize:n.typography.fontSize.sm,fontWeight:600},children:"Cancel"})]})]}):l.jsxs("div",{style:{display:"flex",gap:n.spacing.sm,flexWrap:"wrap"},children:[l.jsx("button",{onClick:()=>m(!0),style:{padding:`${n.spacing.sm} ${n.spacing.md}`,backgroundColor:n.colors.primary,color:n.colors.background,border:"none",borderRadius:n.borderRadius.sm,cursor:"pointer",fontSize:n.typography.fontSize.sm,fontWeight:600,transition:n.transitions.fast},onMouseEnter:b=>{b.currentTarget.style.backgroundColor=n.colors.primaryHover},onMouseLeave:b=>{b.currentTarget.style.backgroundColor=n.colors.primary},children:c?"Edit Budget":"Set Budget"}),!c&&l.jsx("button",{onClick:y,style:{padding:`${n.spacing.sm} ${n.spacing.md}`,backgroundColor:"transparent",color:n.colors.primary,border:`1px solid ${n.colors.primary}`,borderRadius:n.borderRadius.sm,cursor:"pointer",fontSize:n.typography.fontSize.sm,fontWeight:600,transition:n.transitions.fast},onMouseEnter:b=>{b.currentTarget.style.backgroundColor=`${n.colors.primary}20`},onMouseLeave:b=>{b.currentTarget.style.backgroundColor="transparent"},children:"Use Recommended"}),c&&l.jsx("button",{onClick:()=>{window.confirm("Are you sure you want to delete the current budget?")&&i()},style:{padding:`${n.spacing.sm} ${n.spacing.md}`,backgroundColor:"transparent",color:n.colors.error,border:`1px solid ${n.colors.error}`,borderRadius:n.borderRadius.sm,cursor:"pointer",fontSize:n.typography.fontSize.sm,fontWeight:600,transition:n.transitions.fast},onMouseEnter:b=>{b.currentTarget.style.backgroundColor=`${n.colors.error}20`},onMouseLeave:b=>{b.currentTarget.style.backgroundColor="transparent"},children:"Delete Budget"})]})]}),t.length>0&&l.jsxs("div",{style:{backgroundColor:n.colors.surface,borderRadius:n.borderRadius.md,padding:n.spacing.md,border:`1px solid ${n.colors.border}`},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:n.spacing.md},children:[l.jsxs("div",{style:{fontSize:n.typography.fontSize.sm,fontWeight:600,color:n.colors.text},children:["Recent Violations (",t.length,")"]}),l.jsx("button",{onClick:s,style:{padding:`${n.spacing.xs} ${n.spacing.sm}`,backgroundColor:"transparent",color:n.colors.textSecondary,border:"none",cursor:"pointer",fontSize:n.typography.fontSize.xs},children:"Clear"})]}),l.jsx("div",{style:{maxHeight:"200px",overflowY:"auto",fontSize:n.typography.fontSize.xs,fontFamily:n.typography.fontFamilyMono},children:t.slice(-10).reverse().map(b=>l.jsxs("div",{style:{padding:n.spacing.sm,borderBottom:`1px solid ${n.colors.border}`,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[l.jsxs("div",{children:[l.jsx("div",{style:{color:b.severity==="error"?n.colors.error:n.colors.warning,fontWeight:600},children:b.metric}),l.jsx("div",{style:{color:n.colors.textSecondary,marginTop:n.spacing.xs},children:b.message})]}),l.jsx(wt,{severity:b.severity})]},b.id))})]})]})};class nr{componentStats=new Map;recentRenders=[];totalRenders=0;maxRecentRenders=100;slowThreshold=16;frequentThreshold=10;onRenderCallback=(t,e,s,i,r,o)=>{const a=this.getComponentName(t),h=performance.now(),n={id:t,name:a,phase:e,actualDuration:s,baseDuration:i,startTime:r,commitTime:o,timestamp:h};this.recentRenders.push(n),this.recentRenders.length>this.maxRecentRenders&&this.recentRenders.shift(),this.updateComponentStats(a,n),St.onReactRender(s),this.totalRenders++};getComponentName(t){return t.split(":")[0]||t}updateComponentStats(t,e){let s=this.componentStats.get(t);s||(s={name:t,renderCount:0,totalDuration:0,averageDuration:0,maxDuration:0,minDuration:1/0,lastRenderTime:0,phases:{mount:0,update:0}},this.componentStats.set(t,s)),s.renderCount++,s.totalDuration+=e.actualDuration,s.averageDuration=s.totalDuration/s.renderCount,s.maxDuration=Math.max(s.maxDuration,e.actualDuration),s.minDuration=Math.min(s.minDuration,e.actualDuration),s.lastRenderTime=e.timestamp,e.phase==="mount"?s.phases.mount++:s.phases.update++}getPerformanceData(){const t=new Map(this.componentStats),e=Array.from(t.values()).filter(o=>o.averageDuration>this.slowThreshold).sort((o,a)=>a.averageDuration-o.averageDuration),s=performance.now(),i=1e3,r=Array.from(t.values()).filter(o=>s-o.lastRenderTime>i?!1:o.renderCount/(i/1e3)>this.frequentThreshold).sort((o,a)=>a.renderCount-o.renderCount);return{components:t,recentRenders:[...this.recentRenders],totalRenders:this.totalRenders,slowComponents:e,frequentRenders:r,timestamp:performance.now()}}getComponentStats(t){return this.componentStats.get(t)||null}getSlowComponents(){return this.getPerformanceData().slowComponents}getFrequentRenders(){return this.getPerformanceData().frequentRenders}reset(){this.componentStats.clear(),this.recentRenders=[],this.totalRenders=0}}const Ws=new nr;function or(){const[c,t]=z.useState(null);return z.useEffect(()=>{const e=()=>{if(!P.getPaused()){const r=Ws.getPerformanceData();t(r)}};e();const s=setInterval(e,500),i=P.subscribe(r=>{r||e()});return()=>{clearInterval(s),i()}},[]),c}const ar=()=>{const c=or(),t=$,e=i=>i<.1?`${j(i*1e3,0)} μs`:i<1?`${j(i,2)} ms`:`${j(i,2)} ms`,s=z.useMemo(()=>c?Array.from(c.components.values()).sort((i,r)=>r.totalDuration-i.totalDuration):[],[c]);return c?l.jsxs("div",{style:{padding:t.spacing.md},children:[l.jsxs("div",{style:{backgroundColor:t.colors.surface,borderRadius:t.borderRadius.md,padding:t.spacing.md,marginBottom:t.spacing.lg,border:`1px solid ${t.colors.border}`},children:[l.jsx("div",{style:{fontSize:t.typography.fontSize.sm,fontWeight:600,color:t.colors.text,marginBottom:t.spacing.sm},children:"Overview"}),l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(120px, 1fr))",gap:t.spacing.sm},children:[l.jsx(_,{label:"Total Renders",value:c.totalRenders.toLocaleString()}),l.jsx(_,{label:"Components",value:c.components.size.toLocaleString()}),l.jsx(_,{label:"Slow Components",value:c.slowComponents.length.toLocaleString(),status:c.slowComponents.length>0?"warning":"good"}),l.jsx(_,{label:"Frequent Renders",value:c.frequentRenders.length.toLocaleString(),status:c.frequentRenders.length>0?"warning":"good"})]})]}),c.slowComponents.length>0&&l.jsxs("div",{style:{backgroundColor:t.colors.surface,borderRadius:t.borderRadius.md,padding:t.spacing.md,marginBottom:t.spacing.lg,border:`1px solid ${t.colors.warning}40`},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:t.spacing.sm,marginBottom:t.spacing.sm},children:[l.jsx(wt,{severity:"warning",count:c.slowComponents.length}),l.jsx("div",{style:{fontSize:t.typography.fontSize.sm,fontWeight:600,color:t.colors.text},children:"Slow Components (avg > 16ms)"})]}),l.jsx("div",{style:{fontSize:t.typography.fontSize.xs,color:t.colors.textSecondary,fontFamily:t.typography.fontFamilyMono},children:c.slowComponents.slice(0,5).map(i=>l.jsxs("div",{style:{marginBottom:t.spacing.xs},children:[i.name,": ",e(i.averageDuration)," avg (",i.renderCount," renders)"]},i.name))})]}),c.frequentRenders.length>0&&l.jsxs("div",{style:{backgroundColor:t.colors.surface,borderRadius:t.borderRadius.md,padding:t.spacing.md,marginBottom:t.spacing.lg,border:`1px solid ${t.colors.warning}40`},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:t.spacing.sm,marginBottom:t.spacing.sm},children:[l.jsx(wt,{severity:"warning",count:c.frequentRenders.length}),l.jsx("div",{style:{fontSize:t.typography.fontSize.sm,fontWeight:600,color:t.colors.text},children:"Frequent Renders (> 10 renders/sec)"})]}),l.jsx("div",{style:{fontSize:t.typography.fontSize.xs,color:t.colors.textSecondary,fontFamily:t.typography.fontFamilyMono},children:c.frequentRenders.slice(0,5).map(i=>l.jsxs("div",{style:{marginBottom:t.spacing.xs},children:[i.name,": ",i.renderCount," renders"]},i.name))})]}),l.jsxs("div",{style:{backgroundColor:t.colors.surface,borderRadius:t.borderRadius.md,padding:t.spacing.md,border:`1px solid ${t.colors.border}`},children:[l.jsxs("div",{style:{fontSize:t.typography.fontSize.sm,fontWeight:600,color:t.colors.text,marginBottom:t.spacing.sm},children:["Components (",s.length,")"]}),l.jsx("div",{style:{maxHeight:"400px",overflowY:"auto"},children:s.length===0?l.jsx("div",{style:{padding:t.spacing.md,textAlign:"center",color:t.colors.textSecondary,fontSize:t.typography.fontSize.sm},children:"No components profiled yet"}):l.jsx(lr,{components:s,formatTime:e})})]})]}):l.jsx("div",{style:{padding:t.spacing.lg,textAlign:"center",color:t.colors.textSecondary,fontSize:t.typography.fontSize.sm},children:"Aucune donnée React disponible. Enveloppez vos composants avec <ReactProfiler> pour commencer le monitoring."})},lr=({components:c,formatTime:t})=>{const e=$;return l.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:e.typography.fontSize.xs,fontFamily:e.typography.fontFamilyMono},children:[l.jsx("thead",{children:l.jsxs("tr",{style:{borderBottom:`1px solid ${e.colors.border}`},children:[l.jsx("th",{style:{textAlign:"left",padding:e.spacing.sm,color:e.colors.textSecondary,fontWeight:600},children:"Component"}),l.jsx("th",{style:{textAlign:"right",padding:e.spacing.sm,color:e.colors.textSecondary,fontWeight:600},children:"Renders"}),l.jsx("th",{style:{textAlign:"right",padding:e.spacing.sm,color:e.colors.textSecondary,fontWeight:600},children:"Avg Time"}),l.jsx("th",{style:{textAlign:"right",padding:e.spacing.sm,color:e.colors.textSecondary,fontWeight:600},children:"Max Time"}),l.jsx("th",{style:{textAlign:"right",padding:e.spacing.sm,color:e.colors.textSecondary,fontWeight:600},children:"Total Time"})]})}),l.jsx("tbody",{children:c.map(s=>{const i=s.averageDuration>16,r=s.renderCount>10;return l.jsxs("tr",{style:{borderBottom:`1px solid ${e.colors.border}`,backgroundColor:i||r?`${e.colors.warning}10`:"transparent"},children:[l.jsx("td",{style:{padding:e.spacing.sm,color:e.colors.text,fontWeight:i||r?600:400},children:s.name}),l.jsx("td",{style:{textAlign:"right",padding:e.spacing.sm,color:e.colors.textSecondary},children:s.renderCount.toLocaleString()}),l.jsx("td",{style:{textAlign:"right",padding:e.spacing.sm,color:i?e.colors.warning:e.colors.textSecondary,fontWeight:i?600:400},children:t(s.averageDuration)}),l.jsx("td",{style:{textAlign:"right",padding:e.spacing.sm,color:e.colors.textSecondary},children:t(s.maxDuration)}),l.jsx("td",{style:{textAlign:"right",padding:e.spacing.sm,color:e.colors.textSecondary},children:t(s.totalDuration)})]},s.name)})})]})};class hr{functionCalls=new Map;callHistory=[];maxHistorySize=1e3;hotPathThreshold=5;frequencyThreshold=10;recordCall(t,e,s){const i=performance.now();let r=this.functionCalls.get(t);r||(r={name:t,duration:0,timestamp:i,callCount:0,averageDuration:0,maxDuration:0,stack:s||[]},this.functionCalls.set(t,r)),r.callCount++,r.duration+=e,r.averageDuration=r.duration/r.callCount,r.maxDuration=Math.max(r.maxDuration,e),r.timestamp=i,this.callHistory.push({name:t,duration:e,timestamp:i}),this.callHistory.length>this.maxHistorySize&&this.callHistory.shift()}analyze(t){const e=performance.now(),s=5e3,i=e-s,r=this.callHistory.filter(u=>u.timestamp>=i),o=new Map;r.forEach(u=>{const p=o.get(u.name)||0;o.set(u.name,p+1)});const a=new Map;o.forEach((u,p)=>{a.set(p,u/s*1e3)});const h=[],n=[],d=[];this.functionCalls.forEach((u,p)=>{const f=a.get(p)||0,x=u.averageDuration>this.hotPathThreshold,g=f>this.frequencyThreshold;if(x||g){const w=u.averageDuration>16?"high":u.averageDuration>8?"medium":"low",M=[];x&&M.push(`Optimize ${p} - average duration: ${u.averageDuration.toFixed(2)}ms`),g&&M.push(`Reduce calls to ${p} - ${f.toFixed(1)} calls/sec`),u.maxDuration>u.averageDuration*2&&M.push(`Investigate performance spikes in ${p} - max: ${u.maxDuration.toFixed(2)}ms`);const b={id:`hotpath-${p}-${Date.now()}`,path:[p],totalDuration:u.duration,averageDuration:u.averageDuration,callCount:u.callCount,frequency:f,impact:w,recommendations:M};h.push(b),x&&d.push(b)}n.push(u)}),n.sort((u,p)=>p.duration-u.duration);const m=[];return d.length>0&&m.push(`Found ${d.length} performance bottlenecks`),h.length>5&&m.push("Consider optimizing multiple hot paths simultaneously"),t&&t.forEach(u=>{u.avg>this.hotPathThreshold&&m.push(`Hook "${u.name}" takes ${u.avg.toFixed(2)}ms on average`)}),{hotPaths:h.sort((u,p)=>p.averageDuration-u.averageDuration),topFunctions:n.slice(0,10),bottlenecks:d.sort((u,p)=>p.averageDuration-u.averageDuration),recommendations:m,timestamp:e}}detectCallChain(t){const e=new Map;this.callHistory.forEach(i=>{const r=i.name;let o=e.get(r);o||(o={path:[i.name],duration:0,count:0},e.set(r,o)),o.duration+=i.duration,o.count++});const s=[];return e.forEach((i,r)=>{const o=i.duration/i.count;o>this.hotPathThreshold&&s.push({id:`chain-${r}-${Date.now()}`,path:i.path,totalDuration:i.duration,averageDuration:o,callCount:i.count,frequency:i.count/5,impact:o>16?"high":o>8?"medium":"low",recommendations:[`Optimize call chain: ${i.path.join(" -> ")}`]})}),s}reset(){this.functionCalls.clear(),this.callHistory=[]}getTopFunctions(t=10){return Array.from(this.functionCalls.values()).sort((e,s)=>s.duration-e.duration).slice(0,t)}}const ts=new hr,cr=Object.freeze(Object.defineProperty({__proto__:null,hotPathDetector:ts},Symbol.toStringTag,{value:"Module"}));function dr(){const[c,t]=z.useState(null),e=Vt();return z.useEffect(()=>{const s=()=>{if(!P.getPaused()){const o=ts.analyze(e?.entries);t(o)}};s();const i=setInterval(s,2e3),r=P.subscribe(o=>{o||s()});return()=>{clearInterval(i),r()}},[e]),c}const ur=()=>{const c=dr(),t=$,e=i=>i<.1?`${j(i*1e3,0)} μs`:i<1?`${j(i,2)} ms`:`${j(i,2)} ms`,s={high:t.colors.error,medium:t.colors.warning,low:t.colors.info};return c?l.jsxs("div",{style:{padding:t.spacing.md},children:[l.jsxs("div",{style:{backgroundColor:t.colors.surface,borderRadius:t.borderRadius.md,padding:t.spacing.md,marginBottom:t.spacing.lg,border:`1px solid ${t.colors.border}`},children:[l.jsx("div",{style:{fontSize:t.typography.fontSize.sm,fontWeight:600,color:t.colors.text,marginBottom:t.spacing.sm},children:"Overview"}),l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(120px, 1fr))",gap:t.spacing.sm},children:[l.jsx(_,{label:"Hot Paths",value:c.hotPaths.length.toLocaleString(),status:c.hotPaths.length>0?"warning":"good"}),l.jsx(_,{label:"Bottlenecks",value:c.bottlenecks.length.toLocaleString(),status:c.bottlenecks.length>0?"error":"good"}),l.jsx(_,{label:"Top Functions",value:c.topFunctions.length.toLocaleString()})]})]}),c.recommendations.length>0&&l.jsxs("div",{style:{backgroundColor:t.colors.surface,borderRadius:t.borderRadius.md,padding:t.spacing.md,marginBottom:t.spacing.lg,border:`1px solid ${t.colors.warning}40`},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:t.spacing.sm,marginBottom:t.spacing.sm},children:[l.jsx(wt,{severity:"warning"}),l.jsx("div",{style:{fontSize:t.typography.fontSize.sm,fontWeight:600,color:t.colors.text},children:"Recommendations"})]}),l.jsx("div",{style:{fontSize:t.typography.fontSize.xs,color:t.colors.textSecondary,fontFamily:t.typography.fontFamilyMono},children:c.recommendations.map((i,r)=>l.jsxs("div",{style:{marginBottom:t.spacing.xs},children:["• ",i]},r))})]}),c.bottlenecks.length>0&&l.jsxs("div",{style:{backgroundColor:t.colors.surface,borderRadius:t.borderRadius.md,padding:t.spacing.md,marginBottom:t.spacing.lg,border:`1px solid ${t.colors.error}40`},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:t.spacing.sm,marginBottom:t.spacing.sm},children:[l.jsx(wt,{severity:"error",count:c.bottlenecks.length}),l.jsx("div",{style:{fontSize:t.typography.fontSize.sm,fontWeight:600,color:t.colors.text},children:"Performance Bottlenecks"})]}),l.jsx("div",{style:{maxHeight:"300px",overflowY:"auto"},children:c.bottlenecks.map(i=>l.jsxs("div",{style:{padding:t.spacing.sm,borderBottom:`1px solid ${t.colors.border}`,backgroundColor:`${s[i.impact]}10`},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:t.spacing.xs},children:[l.jsx("div",{style:{fontSize:t.typography.fontSize.sm,fontWeight:600,color:s[i.impact],fontFamily:t.typography.fontFamilyMono},children:i.path.join(" -> ")}),l.jsxs("div",{style:{fontSize:t.typography.fontSize.xs,color:t.colors.textSecondary},children:[e(i.averageDuration)," avg"]})]}),l.jsxs("div",{style:{fontSize:t.typography.fontSize.xs,color:t.colors.textSecondary,marginBottom:t.spacing.xs},children:[i.callCount.toLocaleString()," calls • ",i.frequency.toFixed(1)," calls/sec"]}),i.recommendations.length>0&&l.jsx("div",{style:{fontSize:t.typography.fontSize.xs,color:t.colors.textTertiary,fontStyle:"italic"},children:i.recommendations[0]})]},i.id))})]}),c.hotPaths.length>0&&l.jsxs("div",{style:{backgroundColor:t.colors.surface,borderRadius:t.borderRadius.md,padding:t.spacing.md,marginBottom:t.spacing.lg,border:`1px solid ${t.colors.border}`},children:[l.jsxs("div",{style:{fontSize:t.typography.fontSize.sm,fontWeight:600,color:t.colors.text,marginBottom:t.spacing.sm},children:["Hot Paths (",c.hotPaths.length,")"]}),l.jsx("div",{style:{maxHeight:"400px",overflowY:"auto"},children:l.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:t.typography.fontSize.xs,fontFamily:t.typography.fontFamilyMono},children:[l.jsx("thead",{children:l.jsxs("tr",{style:{borderBottom:`1px solid ${t.colors.border}`},children:[l.jsx("th",{style:{textAlign:"left",padding:t.spacing.sm,color:t.colors.textSecondary,fontWeight:600},children:"Path"}),l.jsx("th",{style:{textAlign:"right",padding:t.spacing.sm,color:t.colors.textSecondary,fontWeight:600},children:"Avg Time"}),l.jsx("th",{style:{textAlign:"right",padding:t.spacing.sm,color:t.colors.textSecondary,fontWeight:600},children:"Calls"}),l.jsx("th",{style:{textAlign:"right",padding:t.spacing.sm,color:t.colors.textSecondary,fontWeight:600},children:"Freq/sec"}),l.jsx("th",{style:{textAlign:"center",padding:t.spacing.sm,color:t.colors.textSecondary,fontWeight:600},children:"Impact"})]})}),l.jsx("tbody",{children:c.hotPaths.map(i=>l.jsxs("tr",{style:{borderBottom:`1px solid ${t.colors.border}`,backgroundColor:`${s[i.impact]}10`},children:[l.jsx("td",{style:{padding:t.spacing.sm,color:t.colors.text},children:i.path.join(" -> ")}),l.jsx("td",{style:{textAlign:"right",padding:t.spacing.sm,color:s[i.impact],fontWeight:600},children:e(i.averageDuration)}),l.jsx("td",{style:{textAlign:"right",padding:t.spacing.sm,color:t.colors.textSecondary},children:i.callCount.toLocaleString()}),l.jsx("td",{style:{textAlign:"right",padding:t.spacing.sm,color:t.colors.textSecondary},children:j(i.frequency,1)}),l.jsx("td",{style:{textAlign:"center",padding:t.spacing.sm},children:l.jsx(wt,{severity:i.impact==="high"?"error":i.impact==="medium"?"warning":"info"})})]},i.id))})]})})]}),c.topFunctions.length>0&&l.jsxs("div",{style:{backgroundColor:t.colors.surface,borderRadius:t.borderRadius.md,padding:t.spacing.md,border:`1px solid ${t.colors.border}`},children:[l.jsx("div",{style:{fontSize:t.typography.fontSize.sm,fontWeight:600,color:t.colors.text,marginBottom:t.spacing.sm},children:"Top Functions (by total duration)"}),l.jsx("div",{style:{maxHeight:"300px",overflowY:"auto",fontSize:t.typography.fontSize.xs,fontFamily:t.typography.fontFamilyMono,color:t.colors.textSecondary},children:c.topFunctions.map((i,r)=>l.jsxs("div",{style:{padding:t.spacing.sm,borderBottom:`1px solid ${t.colors.border}`,display:"flex",justifyContent:"space-between"},children:[l.jsxs("span",{children:[r+1,". ",i.name]}),l.jsxs("span",{children:[e(i.averageDuration)," avg (",i.callCount.toLocaleString()," calls)"]})]},i.name))})]})]}):l.jsx("div",{style:{padding:t.spacing.lg,textAlign:"center",color:t.colors.textSecondary,fontSize:t.typography.fontSize.sm},children:"Aucune analyse de hot path disponible. Les hot paths sont détectés automatiquement à partir des données du profiler."})},mr=({position:c="top-right",defaultTab:t="frames",collapsed:e=!1})=>{const[s,i]=z.useState(!1),[r,o]=z.useState(t),[a,h]=z.useState(e),[n,d]=z.useState(P.getPaused()),[m,u]=z.useState(!1),[p,f]=z.useState(null),x=z.useRef(null),g=z.useRef(null),y=$,w="r3f-profiler-state";z.useEffect(()=>{const C=localStorage.getItem(w);if(C)try{const B=JSON.parse(C);B.position&&typeof B.position.x=="number"&&typeof B.position.y=="number"&&f({x:B.position.x,y:B.position.y}),typeof B.collapsed=="boolean"&&h(B.collapsed),typeof B.activeTab=="string"&&B.activeTab&&o(B.activeTab)}catch(B){console.warn("Failed to load saved profiler state:",B)}const T=P.subscribe(B=>{d(B)});return()=>{T()}},[]);const M=z.useCallback(C=>{try{const T=localStorage.getItem(w),W={...T?JSON.parse(T):{},...C};localStorage.setItem(w,JSON.stringify(W))}catch(T){console.warn("Failed to save profiler state:",T)}},[]),b=z.useCallback((C,T)=>{M({position:{x:C,y:T}})},[M]),v=z.useCallback(C=>{if(!C.target.closest("button")&&(u(!0),g.current)){const T=g.current.getBoundingClientRect();x.current={x:C.clientX-T.left,y:C.clientY-T.top}}},[]);if(z.useEffect(()=>{if(!m)return;const C=B=>{if(!x.current||!g.current)return;const D=g.current.getBoundingClientRect(),rt=window.innerWidth,Tt=window.innerHeight;let mt=B.clientX-x.current.x,pt=B.clientY-x.current.y;mt=Math.max(0,Math.min(mt,rt-D.width)),pt=Math.max(0,Math.min(pt,Tt-D.height));const zt={x:mt,y:pt};f(zt),M({position:zt})},T=()=>{u(!1),x.current=null};return window.addEventListener("mousemove",C),window.addEventListener("mouseup",T),()=>{window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",T)}},[m,b]),z.useEffect(()=>{const C=()=>Je();i(C());const T=()=>{i(C())};return window.addEventListener("storage",T),()=>{window.removeEventListener("storage",T)}},[]),!s)return null;const F=[{id:"frames",label:"Frames"},{id:"gpu",label:"GPU"},{id:"scene",label:"Scene"},{id:"memory",label:"Memory"},{id:"frame-time",label:"Frame Time"},{id:"budget",label:"Budget"},{id:"react",label:"React"},{id:"hot-path",label:"Hot Path"}],R=p?{left:`${p.x}px`,top:`${p.y}px`,right:"auto",bottom:"auto"}:{"top-left":{top:y.spacing.md,left:y.spacing.md,right:"auto",bottom:"auto"},"top-right":{top:y.spacing.md,right:y.spacing.md,left:"auto",bottom:"auto"},"bottom-left":{bottom:y.spacing.md,left:y.spacing.md,right:"auto",top:"auto"},"bottom-right":{bottom:y.spacing.md,right:y.spacing.md,left:"auto",top:"auto"}}[c];return l.jsxs("div",{ref:g,style:{position:"fixed",...R,width:a?"auto":"600px",maxWidth:a?"auto":"90vw",maxHeight:"80vh",backgroundColor:y.colors.background,backdropFilter:"blur(10px)",borderRadius:y.borderRadius.lg,boxShadow:y.shadows.xl,border:`1px solid ${y.colors.border}`,zIndex:y.zIndex.base,display:"flex",flexDirection:"column",overflow:"hidden",transition:m?"none":y.transitions.normal,userSelect:m?"none":"auto"},children:[l.jsxs("div",{onMouseDown:v,style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:y.spacing.md,borderBottom:`1px solid ${y.colors.border}`,backgroundColor:y.colors.surface,cursor:m?"grabbing":"grab",userSelect:"none"},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:y.spacing.sm,flex:1},children:[l.jsx("div",{style:{display:"flex",alignItems:"center",gap:y.spacing.xs,color:y.colors.textTertiary,fontSize:y.typography.fontSize.xs},children:l.jsx("span",{children:"⋮⋮"})}),l.jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:y.colors.success,boxShadow:`0 0 8px ${y.colors.success}`}}),l.jsx("h2",{style:{margin:0,fontSize:y.typography.fontSize.lg,fontWeight:600,color:y.colors.text},children:"Performance Monitor"})]}),l.jsxs("div",{style:{display:"flex",gap:y.spacing.xs,alignItems:"center"},children:[n&&l.jsx("div",{style:{fontSize:y.typography.fontSize.xs,color:y.colors.warning,fontFamily:y.typography.fontFamilyMono,padding:`0 ${y.spacing.xs}`},children:"PAUSED"}),l.jsx("button",{onClick:()=>{P.toggle()},style:{background:"transparent",border:"none",color:n?y.colors.warning:y.colors.textSecondary,cursor:"pointer",padding:y.spacing.xs,borderRadius:y.borderRadius.sm,transition:y.transitions.fast,display:"flex",alignItems:"center",justifyContent:"center"},onMouseEnter:C=>{C.currentTarget.style.backgroundColor=y.colors.surfaceElevated,C.currentTarget.style.color=n?y.colors.warning:y.colors.text},onMouseLeave:C=>{C.currentTarget.style.backgroundColor="transparent",C.currentTarget.style.color=n?y.colors.warning:y.colors.textSecondary},title:n?"Resume":"Pause",children:n?"▶":"⏸"}),l.jsx("button",{onClick:()=>{const C=!a;h(C),M({collapsed:C})},style:{background:"transparent",border:"none",color:y.colors.textSecondary,cursor:"pointer",padding:y.spacing.xs,borderRadius:y.borderRadius.sm,transition:y.transitions.fast,display:"flex",alignItems:"center",justifyContent:"center"},onMouseEnter:C=>{C.currentTarget.style.backgroundColor=y.colors.surfaceElevated,C.currentTarget.style.color=y.colors.text},onMouseLeave:C=>{C.currentTarget.style.backgroundColor="transparent",C.currentTarget.style.color=y.colors.textSecondary},title:a?"Expand":"Collapse",children:a?"◀":"▼"})]})]}),!a&&l.jsxs(l.Fragment,{children:[l.jsx("div",{style:{padding:`0 ${y.spacing.md}`,backgroundColor:y.colors.surface},children:l.jsx(Vi,{tabs:F,activeTab:r,onTabChange:C=>{o(C),M({activeTab:C})}})}),l.jsxs("div",{style:{flex:1,overflow:"auto",backgroundColor:y.colors.background},children:[r==="frames"&&l.jsx(Yi,{}),r==="gpu"&&l.jsx(Gi,{}),r==="scene"&&l.jsx(Ji,{}),r==="memory"&&l.jsx(Zi,{}),r==="frame-time"&&l.jsx(Ki,{}),r==="budget"&&l.jsx(rr,{}),r==="react"&&l.jsx(ar,{}),r==="hot-path"&&l.jsx(ur,{})]})]})]})},Os=()=>{const c=Vt(),[t,e]=z.useState(!1);if(z.useEffect(()=>{const i=()=>Je();e(i());const r=()=>{e(i())};return window.addEventListener("storage",r),()=>{window.removeEventListener("storage",r)}},[]),t){if(!c||c.entries.length===0)return l.jsxs("div",{style:{position:"fixed",top:"20px",right:"20px",backgroundColor:"#1a1a1a",color:"#ffffff",padding:"16px",borderRadius:"8px",fontFamily:"monospace",fontSize:"12px",zIndex:1e4,boxShadow:"0 4px 6px rgba(0, 0, 0, 0.3)",minWidth:"300px"},children:[l.jsx("div",{style:{fontSize:"14px",fontWeight:"bold",marginBottom:"12px",borderBottom:"1px solid #333",paddingBottom:"8px"},children:"Frame Profiler"}),l.jsx("div",{style:{color:"#aaa",fontSize:"11px"},children:"Aucune donnée profilée pour le moment."})]})}else return null;const s=[...c.entries].sort((i,r)=>r.total-i.total);return l.jsxs("div",{style:{position:"fixed",top:"20px",right:"20px",backgroundColor:"#1a1a1a",color:"#ffffff",padding:"16px",borderRadius:"8px",fontFamily:"monospace",fontSize:"12px",zIndex:1e4,boxShadow:"0 4px 6px rgba(0, 0, 0, 0.3)",minWidth:"400px",maxWidth:"600px"},children:[l.jsx("div",{style:{fontSize:"14px",fontWeight:"bold",marginBottom:"12px",borderBottom:"1px solid #333",paddingBottom:"8px"},children:"Frame Profiler"}),l.jsxs("div",{style:{marginBottom:"12px",color:"#aaa",fontSize:"11px",lineHeight:"1.6"},children:[l.jsxs("div",{children:[l.jsx("strong",{children:"Total:"})," ",c.totalTime.toFixed(2),"ms"]}),l.jsxs("div",{children:[l.jsx("strong",{children:"Calls:"})," ",c.calls]}),l.jsxs("div",{children:[l.jsx("strong",{children:"Frames:"})," ",c.frames]})]}),l.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",marginTop:"12px"},children:[l.jsx("thead",{children:l.jsxs("tr",{style:{borderBottom:"1px solid #333"},children:[l.jsx("th",{style:{textAlign:"left",padding:"4px 8px",color:"#aaa"},children:"Hook"}),l.jsx("th",{style:{textAlign:"right",padding:"4px 8px",color:"#aaa"},children:"Total (ms)"}),l.jsx("th",{style:{textAlign:"right",padding:"4px 8px",color:"#aaa"},children:"Avg (ms)"}),l.jsx("th",{style:{textAlign:"right",padding:"4px 8px",color:"#aaa"},children:"Max (ms)"}),l.jsx("th",{style:{textAlign:"right",padding:"4px 8px",color:"#aaa"},children:"%"})]})}),l.jsx("tbody",{children:s.map(i=>l.jsxs("tr",{style:{borderBottom:"1px solid #222"},children:[l.jsx("td",{style:{padding:"6px 8px",color:"#fff",fontFamily:"monospace"},children:i.name}),l.jsx("td",{style:{textAlign:"right",padding:"6px 8px",color:"#fff",fontFamily:"monospace"},children:i.total.toFixed(2)}),l.jsx("td",{style:{textAlign:"right",padding:"6px 8px",color:"#fff",fontFamily:"monospace"},children:i.avg.toFixed(3)}),l.jsx("td",{style:{textAlign:"right",padding:"6px 8px",color:"#fff",fontFamily:"monospace"},children:i.max.toFixed(3)}),l.jsxs("td",{style:{textAlign:"right",padding:"6px 8px",color:"#fff",fontFamily:"monospace"},children:[i.percentage.toFixed(1),"%"]})]},i.name))})]})]})},pr=({id:c,children:t,onRender:e})=>{const s=(i,r,o,a,h,n)=>{Ws.onRenderCallback(i,r,o,a,h,n),e&&e(i,r,o,a,h,n)};return l.jsx(z.Profiler,{id:c,onRender:s,children:t})};exports.FrameProfiler=Os;exports.PerformanceMonitor=mr;exports.ProfilerDataCollector=ei;exports.R3FStatsCollector=Wi;exports.ReactProfiler=pr;exports.default=Os;exports.getProfilerData=Gs;exports.hotPathDetector=ts;exports.isProfilerEnabled=Je;exports.profile=Hs;exports.profileAsync=Ns;exports.profiler=I;exports.record=qs;exports.resetProfiler=Xs;exports.useProfiled=Zs;exports.useProfiledAsync=Qs;exports.useProfiledFrame=Ks;exports.useProfilerData=Vt;exports.wrap=Us;exports.wrapAsync=Ys;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../index-D_LaF0YP.cjs");exports.PerformanceMonitor=r.PerformanceMonitor;exports.ProfilerDataCollector=r.ProfilerDataCollector;exports.R3FStatsCollector=r.R3FStatsCollector;exports.isProfilerEnabled=r.isProfilerEnabled;exports.profile=r.profile;exports.reportMetric=r.reportMetric;
|
|
3
2
|
//# sourceMappingURL=index.js.map
|