@tomorrowevening/hermes 0.0.130 → 0.0.132

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("three"),O=require("react"),ps=require("framer-motion"),Ct=()=>{},sn=()=>{};function bt(s){return s.substring(0,1).toUpperCase()+s.substring(1)}function ms(s){const e=JSON.stringify(s);return navigator.clipboard.writeText(e),e}function fs(){return Math.round(Math.random()*1e6).toString()}function gs(s){return s.r!==void 0&&s.g!==void 0&&s.b!==void 0}function ui(s){const e=Math.round(s.r*255),t=Math.round(s.g*255),i=Math.round(s.b*255),n=h=>{const c=h.toString(16);return c.length===1?"0"+c:c},r=n(e),a=n(t),l=n(i);return"#"+r+a+l}function Kt(s,e,t,i){return new(t||(t=Promise))(function(n,r){function a(c){try{h(i.next(c))}catch(u){r(u)}}function l(c){try{h(i.throw(c))}catch(u){r(u)}}function h(c){var u;c.done?n(c.value):(u=c.value,u instanceof t?u:new t(function(m){m(u)})).then(a,l)}h((i=i.apply(s,e||[])).next())})}const nn=["geforce 320m","geforce 8600","geforce 8600m gt","geforce 8800 gs","geforce 8800 gt","geforce 9400","geforce 9400m g","geforce 9400m","geforce 9600m gt","geforce 9600m","geforce fx go5200","geforce gt 120","geforce gt 130","geforce gt 330m","geforce gtx 285","google swiftshader","intel g41","intel g45","intel gma 4500mhd","intel gma x3100","intel hd 3000","intel q45","legacy","mali-2","mali-3","mali-4","quadro fx 1500","quadro fx 4","quadro fx 5","radeon hd 2400","radeon hd 2600","radeon hd 4670","radeon hd 4850","radeon hd 4870","radeon hd 5670","radeon hd 5750","radeon hd 6290","radeon hd 6300","radeon hd 6310","radeon hd 6320","radeon hd 6490m","radeon hd 6630m","radeon hd 6750m","radeon hd 6770m","radeon hd 6970m","sgx 543","sgx543"];function Ni(s){return s=s.toLowerCase().replace(/.*angle ?\((.+)\)(?: on vulkan [0-9.]+)?$/i,"$1").replace(/\s(\d{1,2}gb|direct3d.+$)|\(r\)| \([^)]+\)$/g,"").replace(/(?:vulkan|opengl) \d+\.\d+(?:\.\d+)?(?: \((.*)\))?/,"$1")}const _s=typeof window>"u",Te=(()=>{if(_s)return;const{userAgent:s,platform:e,maxTouchPoints:t}=window.navigator,i=/(iphone|ipod|ipad)/i.test(s),n=e==="iPad"||e==="MacIntel"&&t>0&&!window.MSStream;return{isIpad:n,isMobile:/android/i.test(s)||i||n,isSafari12:/Version\/12.+Safari/.test(s),isFirefox:/Firefox/.test(s)}})();function an(s,e,t){if(!t)return[e];const i=function(c){const u=`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("three"),O=require("react"),ms=require("framer-motion"),Ct=()=>{},nn=()=>{};function bt(i){return i.substring(0,1).toUpperCase()+i.substring(1)}function fs(i){const e=JSON.stringify(i);return navigator.clipboard.writeText(e),e}function gs(){return Math.round(Math.random()*1e6).toString()}function _s(i){return i.r!==void 0&&i.g!==void 0&&i.b!==void 0}function ui(i){const e=Math.round(i.r*255),t=Math.round(i.g*255),s=Math.round(i.b*255),n=h=>{const c=h.toString(16);return c.length===1?"0"+c:c},a=n(e),r=n(t),l=n(s);return"#"+a+r+l}function Kt(i,e,t,s){return new(t||(t=Promise))(function(n,a){function r(c){try{h(s.next(c))}catch(u){a(u)}}function l(c){try{h(s.throw(c))}catch(u){a(u)}}function h(c){var u;c.done?n(c.value):(u=c.value,u instanceof t?u:new t(function(m){m(u)})).then(r,l)}h((s=s.apply(i,e||[])).next())})}const an=["geforce 320m","geforce 8600","geforce 8600m gt","geforce 8800 gs","geforce 8800 gt","geforce 9400","geforce 9400m g","geforce 9400m","geforce 9600m gt","geforce 9600m","geforce fx go5200","geforce gt 120","geforce gt 130","geforce gt 330m","geforce gtx 285","google swiftshader","intel g41","intel g45","intel gma 4500mhd","intel gma x3100","intel hd 3000","intel q45","legacy","mali-2","mali-3","mali-4","quadro fx 1500","quadro fx 4","quadro fx 5","radeon hd 2400","radeon hd 2600","radeon hd 4670","radeon hd 4850","radeon hd 4870","radeon hd 5670","radeon hd 5750","radeon hd 6290","radeon hd 6300","radeon hd 6310","radeon hd 6320","radeon hd 6490m","radeon hd 6630m","radeon hd 6750m","radeon hd 6770m","radeon hd 6970m","sgx 543","sgx543"];function Fi(i){return i=i.toLowerCase().replace(/.*angle ?\((.+)\)(?: on vulkan [0-9.]+)?$/i,"$1").replace(/\s(\d{1,2}gb|direct3d.+$)|\(r\)| \([^)]+\)$/g,"").replace(/(?:vulkan|opengl) \d+\.\d+(?:\.\d+)?(?: \((.*)\))?/,"$1")}const vs=typeof window>"u",Te=(()=>{if(vs)return;const{userAgent:i,platform:e,maxTouchPoints:t}=window.navigator,s=/(iphone|ipod|ipad)/i.test(i),n=e==="iPad"||e==="MacIntel"&&t>0&&!window.MSStream;return{isIpad:n,isMobile:/android/i.test(i)||s||n,isSafari12:/Version\/12.+Safari/.test(i),isFirefox:/Firefox/.test(i)}})();function rn(i,e,t){if(!t)return[e];const s=function(c){const u=`
2
2
  precision highp float;
3
3
  attribute vec3 aPosition;
4
4
  varying float vvv;
@@ -15,7 +15,7 @@
15
15
  enc -= enc.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);
16
16
  gl_FragColor = enc;
17
17
  }
18
- `,f=c.createShader(35633),g=c.createShader(35632),x=c.createProgram();if(!(g&&f&&x))return;c.shaderSource(f,u),c.shaderSource(g,m),c.compileShader(f),c.compileShader(g),c.attachShader(x,f),c.attachShader(x,g),c.linkProgram(x),c.detachShader(x,f),c.detachShader(x,g),c.deleteShader(f),c.deleteShader(g),c.useProgram(x);const y=c.createBuffer();c.bindBuffer(34962,y),c.bufferData(34962,new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),35044);const T=c.getAttribLocation(x,"aPosition");c.vertexAttribPointer(T,3,5126,!1,0,0),c.enableVertexAttribArray(T),c.clearColor(1,1,1,1),c.clear(16384),c.viewport(0,0,1,1),c.drawArrays(4,0,3);const _=new Uint8Array(4);return c.readPixels(0,0,1,1,6408,5121,_),c.deleteProgram(x),c.deleteBuffer(y),_.join("")}(s),n="801621810",r="8016218135",a="80162181161",l=Te?.isIpad?[["a7",a,12],["a8",r,15],["a8x",r,15],["a9",r,15],["a9x",r,15],["a10",r,15],["a10x",r,15],["a12",n,15],["a12x",n,15],["a12z",n,15],["a14",n,15],["a15",n,15],["m1",n,15],["m2",n,15]]:[["a7",a,12],["a8",r,12],["a9",r,15],["a10",r,15],["a11",n,15],["a12",n,15],["a13",n,15],["a14",n,15],["a15",n,15],["a16",n,15],["a17",n,15]];let h;return i==="80162181255"?h=l.filter(([,,c])=>c>=14):(h=l.filter(([,c])=>c===i),h.length||(h=l)),h.map(([c])=>`apple ${c} gpu`)}class Fi extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}const $t=[],zi=[];function rn(s,e){if(s===e)return 0;const t=s;s.length>e.length&&(s=e,e=t);let i=s.length,n=e.length;for(;i>0&&s.charCodeAt(~-i)===e.charCodeAt(~-n);)i--,n--;let r,a=0;for(;a<i&&s.charCodeAt(a)===e.charCodeAt(a);)a++;if(i-=a,n-=a,i===0)return n;let l,h,c=0,u=0,m=0;for(;u<i;)zi[u]=s.charCodeAt(a+u),$t[u]=++u;for(;m<n;)for(r=e.charCodeAt(a+m),l=m++,c=m,u=0;u<i;u++)h=r===zi[u]?l:l+1,l=$t[u],c=$t[u]=l>c?h>c?c+1:h:h>l?l+1:h;return c}function on(s){return s!=null}const ln=({mobileTiers:s=[0,15,30,60],desktopTiers:e=[0,15,30,60],override:t={},glContext:i,failIfMajorPerformanceCaveat:n=!1,benchmarksURL:r="https://unpkg.com/detect-gpu@5.0.57/dist/benchmarks"}={})=>Kt(void 0,void 0,void 0,function*(){const a={};if(_s)return{tier:0,type:"SSR"};const{isIpad:l=!!Te?.isIpad,isMobile:h=!!Te?.isMobile,screenSize:c=window.screen,loadBenchmarks:u=w=>Kt(void 0,void 0,void 0,function*(){const M=yield fetch(`${r}/${w}`).then(I=>I.json());if(parseInt(M.shift().split(".")[0],10)<4)throw new Fi("Detect GPU benchmark data is out of date. Please update to version 4x");return M})}=t;let{renderer:m}=t;const f=(w,M,I,U,D)=>({device:D,fps:U,gpu:I,isMobile:h,tier:w,type:M});let g,x="";if(m)m=Ni(m),g=[m];else{const w=i||function(I,U=!1){const D={alpha:!1,antialias:!1,depth:!1,failIfMajorPerformanceCaveat:U,powerPreference:"high-performance",stencil:!1};I&&delete D.powerPreference;const B=window.document.createElement("canvas"),_e=B.getContext("webgl",D)||B.getContext("experimental-webgl",D);return _e??void 0}(Te?.isSafari12,n);if(!w)return f(0,"WEBGL_UNSUPPORTED");const M=Te?.isFirefox?null:w.getExtension("WEBGL_debug_renderer_info");if(m=M?w.getParameter(M.UNMASKED_RENDERER_WEBGL):w.getParameter(w.RENDERER),!m)return f(1,"FALLBACK");x=m,m=Ni(m),g=function(I,U,D){return U==="apple gpu"?an(I,U,D):[U]}(w,m,h)}const y=(yield Promise.all(g.map(function(w){var M;return Kt(this,void 0,void 0,function*(){const I=(G=>{const re=h?["adreno","apple","mali-t","mali","nvidia","powervr","samsung"]:["intel","apple","amd","radeon","nvidia","geforce","adreno"];for(const Ee of re)if(G.includes(Ee))return Ee})(w);if(!I)return;const U=`${h?"m":"d"}-${I}${l?"-ipad":""}.json`,D=a[U]=(M=a[U])!==null&&M!==void 0?M:u(U);let B;try{B=yield D}catch(G){if(G instanceof Fi)throw G;return}const _e=function(G){var re;const Ee=(G=G.replace(/\([^)]+\)/,"")).match(/\d+/)||G.match(/(\W|^)([A-Za-z]{1,3})(\W|$)/g);return(re=Ee?.join("").replace(/\W|amd/g,""))!==null&&re!==void 0?re:""}(w);let pe=B.filter(([,G])=>G===_e);pe.length||(pe=B.filter(([G])=>G.includes(w)));const ne=pe.length;if(ne===0)return;const Q=w.split(/[.,()\[\]/\s]/g).sort().filter((G,re,Ee)=>re===0||G!==Ee[re-1]).join(" ");let X,[Ae,,,,ce]=ne>1?pe.map(G=>[G,rn(Q,G[2])]).sort(([,G],[,re])=>G-re)[0][0]:pe[0],ge=Number.MAX_VALUE;const{devicePixelRatio:ie}=window,Re=c.width*ie*c.height*ie;for(const G of ce){const[re,Ee]=G,st=re*Ee,Ye=Math.abs(Re-st);Ye<ge&&(ge=Ye,X=G)}if(!X)return;const[,,De,Ie]=X;return[ge,De,Ae,Ie]})}))).filter(on).sort(([w=Number.MAX_VALUE,M],[I=Number.MAX_VALUE,U])=>w===I?M-U:w-I);if(!y.length){const w=nn.find(M=>m.includes(M));return w?f(0,"BLOCKLISTED",w):f(1,"FALLBACK",`${m} (${x})`)}const[,T,_,C]=y[0];if(T===-1)return f(0,"BLOCKLISTED",_,T,C);const E=h?s:e;let S=0;for(let w=0;w<E.length;w++)T>=E[w]&&(S=w);return f(S,"BENCHMARK",_,T,C)});var vs=(s=>(s[s.High=0]="High",s[s.Medium=1]="Medium",s[s.Low=2]="Low",s))(vs||{});function cn(s){return new Promise(e=>{ln().then(t=>{let i=!1;const n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);if(i="transferControlToOffscreen"in s,n){const a=navigator.userAgent.match(/version\/(\d+)/i);i=(a?parseInt(a[1]):0)>=17}const r={dpr:devicePixelRatio,fps:t.fps!==void 0?t.fps:30,width:innerWidth,height:innerHeight,mobile:t.isMobile!==void 0?t.isMobile:!1,supportOffScreenCanvas:i,quality:2};t.tier===3?r.quality=0:t.tier===2&&(r.quality=1),e(r)})})}function je(s,e,t){return Math.min(e,Math.max(s,t))}function Ft(s,e,t){return(t-s)/(e-s)}function it(s,e,t){return s*(1-t)+e*t}function hn(s,e,t,i,n){return it(t,i,Ft(s,e,n))}function dn(s,e){const t=s-e;return Math.sqrt(t*t)}function Ce(s,e=1){return Number(s.toFixed(e))}function un(s,e,t,i){return it(s,e,1-Math.exp(-t*i))}function pn(s,e=1){return Number(s.toFixed(e))}function mn(s,e,t,i){return s===e&&t===i}function fn(s,e,t,i){return 1/(3*e*s*s+2*t*s+i)}function gn(s,e,t,i,n){return e*(s*s*s)+t*(s*s)+i*s+n}function _n(s,e,t,i,n){const r=s*s;return e*(r*s)+t*r+i*s+n}function vn(s,e,t,i,n){if(s<=0)return 0;if(s>=1)return 1;if(mn(e,t,i,n))return s;const r=0,a=0,l=e,h=t,c=i,u=n,m=1,f=1,g=m-3*c+3*l-r,x=3*c-6*l+3*r,y=3*l-3*r,T=r,_=f-3*u+3*h-a,C=3*u-6*h+3*a,E=3*h-3*a,S=a;let w=s;for(let M=0;M<5;M++){const I=gn(w,g,x,y,T);let U=fn(w,g,x,y);U===1/0&&(U=s),w-=(I-s)*U,w=Math.min(Math.max(w,0),1)}return _n(w,_,C,E,S)}const yn=s=>{s?.dispose()},ys=s=>{s&&(Array.isArray(s)?s.forEach(e=>e.dispose()):s.dispose())},Pe=s=>{if(s){for(;s.children.length>0;){const e=s.children[0];e.type==="Audio"?(e.pause(),e.parent&&e.parent.remove(e)):Pe(e)}if(s.parent&&s.parent.remove(s),s.isMesh){const e=s;e.geometry?.dispose(),ys(e.material)}s.dispose!==void 0&&s.dispose()}};exports.totalThreeObjects=0;const pi=()=>{exports.totalThreeObjects=0},zt=s=>{if(!s)return;let e=s.name.replaceAll(" ","").replaceAll("/",".");if(e.length===0&&(e=`obj_${exports.totalThreeObjects}`,exports.totalThreeObjects++),s.parent!==null&&s.parent.uuid.length>0&&(e=`${s.parent.uuid}.${e}`),s.uuid=e,s.isMesh!==void 0){const t=s;if(Array.isArray(t.material))t.material.forEach((i,n)=>{i.uuid=`${e}.material.${n}`});else{const i=t.material;i.uuid=`${e}.material`}}s.children.forEach(t=>zt(t))};class yt{static renderer;static canvas;static context=null;static scene=null;static camera=null;static material=null;static inited=!1;static width=100;static height=100;static init(){this.inited||(this.canvas=document.createElement("canvas"),this.canvas.width=this.width,this.canvas.height=this.height,this.context=this.canvas.getContext("2d"),this.inited=!0)}static renderToBlob(e){this.init();const t=e.repeat.clone(),i=e.offset.clone();if(e.repeat.set(1,1),e.offset.set(0,0),this.context!==null){this.context.clearRect(0,0,this.width,this.height);const n=e.image;if(n!=null&&n.width>0){this.canvas.title=e.sourceFile;const r=this.canvas.width/n.width,a=this.renderToCanvas(e);this.context.drawImage(a,0,0,n.width*r,n.height*r)}}return e.repeat.copy(t),e.offset.copy(i),this.canvas.toDataURL("image/png")}static renderToCanvas(e){if(this.material===null){this.camera=new o.OrthographicCamera(-.5,.5,.5,-.5,0,100),this.scene=new o.Scene,this.material=new o.MeshBasicMaterial;const t=new o.BufferGeometry;t.setAttribute("position",new o.Float32BufferAttribute([-.5,-.5,0,1.5,-.5,0,-.5,1.5,0],3)),t.setAttribute("normal",new o.Float32BufferAttribute([0,0,1,0,0,1],3)),t.setAttribute("uv",new o.Float32BufferAttribute([0,0,2,0,0,2],2));const i=new o.Mesh(t,this.material);this.scene.add(i)}if(e.isRenderTargetTexture)this.material.map=e,this.renderer.render(this.scene,this.camera);else{const t=this.renderer.outputColorSpace,i=e.colorSpace;this.renderer.outputColorSpace=o.LinearSRGBColorSpace,e.colorSpace=o.LinearSRGBColorSpace,this.material.map=e,this.renderer.render(this.scene,this.camera),this.renderer.outputColorSpace=t,e.colorSpace=i}return this.renderer.domElement}}function Cn(s){return new Promise(e=>{const t=new o.ObjectLoader;t.parseAsync(s.scene).then(i=>{const n=new o.AnimationMixer(i);if(s.animations.length>0){const a=s.animations.map(h=>o.AnimationClip.parse(h));n.clipAction(a[0]).play(),n.getRoot().animations=s.animations,n.getRoot().mixer=n}const r=[];s.cameras&&s.cameras.length>0&&s.cameras.forEach(a=>{const l=t.parse(a);r.push(l)}),e({animations:s.animations,model:i,mixer:n,cameras:r})})})}const We=Ci(["ctrlKey","metaKey","shiftKey","button","pointerId","pointerType","clientX","clientY","pageX","pageY"]),bn=Ci(["clientX","clientY","deltaX","deltaY","deltaMode"]),En=Ci(["ctrlKey","metaKey","shiftKey","keyCode"]);function Sn(s,e){s.preventDefault(),bn(s,e)}function wn(s){s.preventDefault()}function xn(s,e,t){for(const i of e)t[i]=s[i]}function Ci(s){return function(t,i){const n={type:t.type};xn(t,s,n),i(n)}}function Jt(s,e){const t=[],i={type:s.type,touches:t};for(let n=0;n<s.touches.length;++n){const r=s.touches[n];t.push({pageX:r.pageX,pageY:r.pageY})}e(i)}const On={37:!0,38:!0,39:!0,40:!0};function Tn(s,e){const{keyCode:t}=s;On[t]&&(s.preventDefault(),En(s,e))}const Mn={contextmenu:wn,mousedown:We,mousemove:We,mouseup:We,pointerdown:We,pointermove:We,pointerup:We,touchstart:Jt,touchmove:Jt,touchend:Jt,wheel:Sn,keydown:Tn};let Pn=0;class An{id;worker;constructor(e,t,i){this.id=Pn++,this.worker=t;const n=a=>{this.worker.postMessage({type:"event",id:this.id,data:a})};t.postMessage({type:"makeProxy",id:this.id});for(const[a,l]of Object.entries(i))e.addEventListener(a,h=>{l(h,n)});function r(){n({type:"resize",left:0,top:0,width:innerWidth,height:innerHeight})}window.addEventListener("resize",r),r()}}class Cs extends o.EventDispatcher{style={};left=0;top=0;width=0;height=0;ownerDocument=void 0;constructor(){super(),this.ownerDocument=this}get clientWidth(){return this.width}set clientWidth(e){this.width=e}get clientHeight(){return this.height}set clientHeight(e){this.height=e}setPointerCapture(){}releasePointerCapture(){}getBoundingClientRect(){return{x:this.left,y:this.top,left:this.left,top:this.top,width:this.width,height:this.height,right:this.left+this.width,bottom:this.top+this.height,toJSON:()=>({})}}handleEvent(e){if(e.type==="size"){this.left=e.left,this.top=e.top,this.width=e.width,this.height=e.height;return}e.preventDefault=Ct,e.stopPropagation=Ct,this.dispatchEvent(e)}focus(){}getRootNode(){return this}}class Rn{targets={};constructor(){this.handleEvent=this.handleEvent.bind(this)}makeProxy(e){const{id:t}=e,i=new Cs;this.targets[t]=i}getProxy(e){return this.targets[e]}handleEvent(e){this.targets[e.id]?.handleEvent(e.data)}}class Dn{components=new Map;listen;_appID="";_debugEnabled;_broadcastChannel=void 0;_webSocket=void 0;_mode="app";_connected=!1;_useBC=!1;constructor(e,t,i=!0){this._appID=e,this._debugEnabled=t,t&&(this._useBC=i,i?(this._broadcastChannel=new BroadcastChannel(e),this._broadcastChannel.addEventListener("message",this.messageHandler)):(this._webSocket=new WebSocket(e),this._webSocket.addEventListener("open",this.openHandler),this._webSocket.addEventListener("close",this.closeHandler),this._webSocket.addEventListener("message",this.messageHandler)))}addComponent(e,t){this.components.set(e,t)}dispose(){this._broadcastChannel!==void 0&&this._broadcastChannel.removeEventListener("message",this.messageHandler),this._webSocket!==void 0&&(this._webSocket.removeEventListener("open",this.openHandler),this._webSocket.removeEventListener("close",this.closeHandler),this._webSocket.removeEventListener("message",this.messageHandler)),this.components.forEach(e=>{e.dispose()}),this.components.clear()}send(e){this._mode!==e.target&&(this._useBC?this._broadcastChannel?.postMessage(e):this._connected&&this._webSocket?.send(JSON.stringify(e)))}messageHandler=e=>{this.listen!==void 0&&(this._useBC?this.listen(e.data):this.listen(JSON.parse(e.data)))};openHandler=()=>{this._connected=!0};closeHandler=()=>{this._connected=!1};get appID(){return this._appID}get connected(){return this._connected}get debugEnabled(){return this._debugEnabled}get mode(){return this._mode}get isApp(){return this._mode==="app"}get editor(){return this._mode==="editor"}set editor(e){e&&(this._mode="editor")}}var A=(s=>(s.CUSTOM="ToolEvents::custom",s.SELECT_DROPDOWN="ToolEvents::selectDropdown",s.DRAG_UPDATE="ToolEvents::dragUpdate",s.ADD_SCENE="ToolEvents::addScene",s.REFRESH_SCENE="ToolEvents::refreshScene",s.REMOVE_SCENE="ToolEvents::removeScene",s.SET_SCENE="ToolEvents::setScene",s.GET_OBJECT="ToolEvents::getObject",s.SET_OBJECT="ToolEvents::setObject",s.UPDATE_OBJECT="ToolEvents::updateObject",s.CREATE_TEXTURE="ToolEvents::createTexture",s.REQUEST_METHOD="ToolEvents::requestMethod",s.ADD_CAMERA="ToolEvents::addCamera",s.REMOVE_CAMERA="ToolEvents::removeCamera",s.ADD_GROUP="ToolEvents::addGroup",s.REMOVE_GROUP="ToolEvents::removeGroup",s.ADD_SPLINE="ToolEvents::addSpline",s.ADD_RENDERER="ToolEvents::addRenderer",s.UPDATE_RENDERER="ToolEvents::updateRenderer",s))(A||{});const R=new o.EventDispatcher;class Vt{app;constructor(e){this.app=e}dispose(){}handleApp(e,t,i){}handleEditor(e,t,i){}}class In extends Vt{selectDropdown(e,t){this.app.send({event:"selectComponent",target:"app",data:{dropdown:e,value:t}})}updateDropdown(e,t){this.app.send({event:"draggableListUpdate",target:"app",data:{dropdown:e,value:t}})}handleApp(e,t,i){switch(i.event){case"selectComponent":R.dispatchEvent({type:A.SELECT_DROPDOWN,value:i.data});break;case"draggableListUpdate":R.dispatchEvent({type:A.DRAG_UPDATE,value:i.data});break}}}function Ln(s,e,t){if(s.editor){t.ui.restore(),t.onSelectionChange(a=>{a.length<1||a.forEach(l=>{let h=l.address.sheetId,c="setSheet",u={};switch(l.type){case"Theatre_Sheet_PublicAPI":c="setSheet",u={sheet:l.address.sheetId},e.activeSheet=e.sheets.get(l.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":c="setSheetObject",h+=`_${l.address.objectKey}`,u={id:h,sheet:l.address.sheetId,key:l.address.objectKey},e.activeSheet=e.sheets.get(l.address.sheetId);break}s.send({event:c,target:"app",data:u})})});let i=-1;const n=()=>{if(e.activeSheet!==void 0&&i!==e.activeSheet.sequence.position){i=e.activeSheet.sequence.position;const a=e.activeSheet;s.send({event:"updateTimeline",target:"app",data:{position:i,sheet:a.address.sheetId}})}},r=()=>{n(),requestAnimationFrame(r)};n(),r()}else t.ui.hide()}function kn(){setTimeout(()=>{const s=document.getElementById("theatrejs-studio-root");if(s===null||s.shadowRoot===null)return;const e=s.shadowRoot.getElementById("pointer-root");if(e===null)return;const t=e.children[0];if(t===null)return;const i=t.children[1];i.style.justifyContent="left";try{const n=i.children[1];for(n.style.transform="translateX(10px)";n.children.length>1;)n.removeChild(n.children[0])}catch{}try{const n=t.children[3];n.style.top="0",n.style.right="300px"}catch{}},1e3)}function Un(s,e,t,i,n){const r=1-s;return r*r*r*e+3*r*r*s*t+3*r*s*s*i+s*s*s*n}function jn(s,e,t){if(s.type!=="bezier"||s.handles.length!==4)throw new Error("Invalid keyframe data for Bézier interpolation.");const[i,n]=s.handles,r=(t-s.position)/(e.position-s.position);return Un(r,s.value,s.value+i,e.value+n,e.value)}class Nn extends Vt{project;sheets=new Map;sheetObjects=new Map;sheetObjectCBs=new Map;sheetObjectUnsubscribe=new Map;activeSheet;studio=void 0;dispose(){this.project=void 0,this.sheets=new Map,this.sheetObjects=new Map,this.sheetObjectCBs=new Map,this.sheetObjectUnsubscribe=new Map}getSheetInstance(e,t){return t!==void 0?`${e}-${t}`:e}sheet(e,t){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const i=this.getSheetInstance(e,t);let n=this.sheets.get(i);return n!==void 0||(n=this.project?.sheet(e,t),this.sheets.set(i,n)),n}playSheet(e,t,i){return new Promise(n=>{const r=t!==void 0?{...t}:{};this.sheet(e,i)?.sequence.play(r).then(a=>n(a)),this.app.send({event:"playSheet",target:"editor",data:{sheet:e,instance:i,value:t}})})}pauseSheet(e,t){this.sheet(e,t)?.sequence.pause(),this.app.send({event:"pauseSheet",target:"editor",data:{sheet:e,instance:t}})}clearSheetObjects(e){this.sheetObjects.forEach((t,i)=>{i.search(`${e}_`)>-1&&this.unsubscribe(t)})}sheetObject(e,t,i,n,r){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const a=this.sheet(e,r);if(a===void 0)return;const h=`${this.getSheetInstance(e,r)}_${t}`;let c=this.sheetObjects.get(h),u=i;c!==void 0&&(u={...i,...c.value}),c=a.object(t,u),this.sheetObjects.set(h,c),this.sheetObjectCBs.set(h,n!==void 0?n:Ct);const m=c.onValuesChange(f=>{if(this.app.editor){for(const x in f){const y=f[x];typeof y=="object"&&gs(y)&&(f[x]={r:y.r,g:y.g,b:y.b,a:y.a})}this.app.send({event:"updateSheetObject",target:"app",data:{sheet:e,sheetObject:h,values:f}})}const g=this.sheetObjectCBs.get(h);g!==void 0&&g(f)});return this.sheetObjectUnsubscribe.set(h,m),c}getSheetObjectKeyframes(e,t,i){const n=this.sheet(e);if(n===void 0)return[];const r=`${e}_${t}`,a=this.sheetObjects.get(r);return a===void 0?[]:n.sequence.__experimental_getKeyframes(a.props[i])}getSheetObjectVectors(e,t){const i=this.sheet(e);if(i===void 0)return[];const n=`${e}_${t}`,r=this.sheetObjects.get(n);if(r===void 0)return[];const a=[],l=i.sequence.__experimental_getKeyframes(r.props.x),h=i.sequence.__experimental_getKeyframes(r.props.y),c=i.sequence.__experimental_getKeyframes(r.props.z),u=new Set;return l.forEach(f=>u.add(f.position)),h.forEach(f=>u.add(f.position)),c.forEach(f=>u.add(f.position)),Array.from(u).sort((f,g)=>f-g).forEach(f=>{const g=(x,y)=>{const T=x.find((E,S)=>E.position<=y&&(x[S+1]?.position||1/0)>y),_=x.find(E=>E.position>y);if(!T)return _?.value||0;if(!_||T.position===y)return T.value;if(T.type==="bezier")return jn(T,_,y);const C=(y-T.position)/(_.position-T.position);return T.value+C*(_.value-T.value)};a.push({position:f,x:g(l,f),y:g(h,f),z:g(c,f)})}),a}unsubscribe(e){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const t=e.address.sheetId,i=e.address.objectKey;this.sheets.get(t)?.detachObject(i);const r=`${t}_${i}`,a=this.sheetObjectUnsubscribe.get(r);a!==void 0&&(this.sheetObjects.delete(r),this.sheetObjectCBs.delete(r),this.sheetObjectUnsubscribe.delete(r),a())}handleApp(e,t,i){const n=t;let r;switch(i.event){case"setSheet":r=n.sheets.get(i.data.sheet),r!==void 0&&(n.activeSheet=r,this.studio?.setSelection([r]));break;case"setSheetObject":r=n.sheetObjects.get(`${i.data.sheet}_${i.data.key}`),r!==void 0&&this.studio?.setSelection([r]);break;case"updateSheetObject":r=n.sheets.get(i.data.sheet),r!==void 0&&r.sequence.pause(),r=n.sheetObjectCBs.get(i.data.sheetObject),r!==void 0&&r(i.data.values);break;case"updateTimeline":r=n.sheets.get(i.data.sheet),n.activeSheet!==void 0&&(n.activeSheet.sequence.position=i.data.position);break}}handleEditor(e,t,i){if(e.editor){const n=t;switch(i.event){case"playSheet":n.sheet(i.data.sheet,i.data.instance)?.sequence.play(i.data.value);break;case"pauseSheet":n.sheet(i.data.sheet,i.data.instance)?.sequence.pause();break}}}handleEditorApp(e,t){if(e.editor){this.studio?.ui.restore(),this.studio?.onSelectionChange(a=>{a.length<1||a.forEach(l=>{let h=l.address.sheetId,c="setSheet",u={};switch(l.type){case"Theatre_Sheet_PublicAPI":c="setSheet",u={sheet:l.address.sheetId},t.activeSheet=t.sheets.get(l.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":c="setSheetObject",h+=`_${l.address.objectKey}`,u={id:h,sheet:l.address.sheetId,key:l.address.objectKey},t.activeSheet=t.sheets.get(l.address.sheetId);break}e.send({event:c,target:"app",data:u})})});let i=-1;const n=()=>{if(t.activeSheet!==void 0&&i!==t.activeSheet.sequence.position){i=t.activeSheet.sequence.position;const a=t.activeSheet;e.send({event:"updateTimeline",target:"app",data:{position:i,sheet:a.address.sheetId}})}},r=()=>{n(),requestAnimationFrame(r)};n(),r()}else this.studio?.ui.hide()}}function Fn(s){if(s.name==="cameras")return"camera";if(s.name==="interactive")return"interactive";if(s.name==="lights")return"light";if(s.name==="ui")return"ui";if(s.name==="utils")return"utils";const e=s.type;return e.search("Helper")>-1?"icon_utils":e.search("Camera")>-1?"camera":e.search("Light")>-1?"light":"obj3D"}function tt(s){const e={name:s.name,type:s.type,uuid:s.uuid,children:[]};return s.children.forEach(t=>{e.children.push(tt(t))}),e}function zn(s){const e={};for(const t in s){const i=s[t].value;e[t]={value:i},i===null?e[t].value={src:"",offset:[0,0],repeat:[1,1]}:i!==void 0&&i.isTexture&&(e[t].value={src:i.image.src,offset:[i.offset.x,i.offset.y],repeat:[i.repeat.x,i.repeat.y]})}return e}function Hn(s){switch(s){case"blendSrcAlpha":case"blendDstAlpha":case"blendEquationAlpha":case"clippingPlanes":case"shadowSide":case"precision":return!0}return!1}function Xe(s){const e={};for(const t in s){if(t.substring(0,1)==="_"||t.substring(0,2)==="is"||Hn(t))continue;const i=typeof s[t],n=s[t];switch(i){case"boolean":case"number":case"string":e[t]=n;break;case"object":n!==null?(e[t]=n,n.isTexture?e[t]={src:yt.renderToBlob(n),offset:[n.offset.x,n.offset.y],repeat:[n.repeat.x,n.repeat.y]}:t==="uniforms"&&(e[t]=zn(e[t]))):t==="glslVersion"?e[t]="":e[t]={src:"",offset:[0,0],repeat:[1,1]};break}}return s.anisotropy!==void 0&&(e.anisotropy=s.anisotropy),s.clearcoat!==void 0&&(e.clearcoat=s.clearcoat),s.iridescence!==void 0&&(e.iridescence=s.iridescence),s.dispersion!==void 0&&(e.dispersion=s.dispersion),s.sheen!==void 0&&(e.sheen=s.sheen),s.transmission!==void 0&&(e.transmission=s.transmission),s.transmission!==void 0&&(e.transmission=s.transmission),e}function ei(s){s.updateMatrix();const e={name:s.name,type:s.type,uuid:s.uuid,visible:s.visible,matrix:s.matrix.elements,animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0,children:[]};s.animations.forEach(i=>{e.animations.push({name:i.name,duration:i.duration,blendMode:i.blendMode})});const t=s.type.toLowerCase();if(t.search("mesh")>-1){const i=s;if(Array.isArray(i.material)){const n=[];i.material.forEach(r=>{n.push(Xe(r))}),e.material=n}else e.material=Xe(i.material)}else if(t.search("points")>-1){const i=s;if(Array.isArray(i.material)){const n=[];i.material.forEach(r=>{n.push(Xe(r))}),e.material=n}else e.material=Xe(i.material)}else if(t.search("line")>-1){const i=s;if(Array.isArray(i.material)){const n=[];i.material.forEach(r=>{n.push(Xe(r))}),e.material=n}else e.material=Xe(i.material)}else t.search("camera")>-1?s.type==="PerspectiveCamera"?e.perspectiveCameraInfo={fov:s.fov,zoom:s.zoom,near:s.near,far:s.far,focus:s.focus,aspect:s.aspect,filmGauge:s.filmGauge,filmOffset:s.filmOffset}:s.type==="OrthographicCamera"&&(e.orthographicCameraInfo={zoom:s.zoom,near:s.near,far:s.far,left:s.left,right:s.right,top:s.top,bottom:s.bottom}):t.search("light")>-1&&(e.lightInfo={color:s.color,intensity:s.intensity,decay:s.decay,distance:s.distance,angle:s.angle,penumbra:s.penumbra,groundColor:s.groundColor,width:s.width,height:s.height});return e}function Vn(s,e){const t=e.split(".");switch(t.length){case 1:return s[t[0]];case 2:return s[t[0]][t[1]];case 3:return s[t[0]][t[1]][t[2]];case 4:return s[t[0]][t[1]][t[2]][t[3]];case 5:return s[t[0]][t[1]][t[2]][t[3]][t[4]];case 6:return s[t[0]][t[1]][t[2]][t[3]][t[4]][t[5]]}}function Bn(s,e){for(const t in e)s[t]=e[t]}function te(s,e,t){if(s===void 0)return;const i=e.split("."),n=i.length;if(typeof t!="object")switch(n){case 1:s[i[0]]=t;break;case 2:s[i[0]][i[1]]=t;break;case 3:s[i[0]][i[1]][i[2]]=t;break;case 4:s[i[0]][i[1]][i[2]][i[3]]=t;break;case 5:s[i[0]][i[1]][i[2]][i[3]][i[4]]=t;break}else{let a;switch(n){case 1:a=s[i[0]];break;case 2:a=s[i[0]][i[1]];break;case 3:a=s[i[0]][i[1]][i[2]];break;case 4:a=s[i[0]][i[1]][i[2]][i[3]];break;case 5:a=s[i[0]][i[1]][i[2]][i[3]][i[4]];break}a!=null&&Bn(a,t)}}function bs(s){return new Promise((e,t)=>{const i=new Image;i.onload=()=>{const n=new o.Texture(i);n.wrapS=o.RepeatWrapping,n.wrapT=o.RepeatWrapping,n.needsUpdate=!0,e(n)},i.onerror=t,i.src=s})}class Yn extends Vt{canvas=null;inputElement=null;scene=void 0;scenes=new Map;renderer=void 0;renderTargets=new Map;groups=new Map;dispose(){this.scenes.forEach(e=>{Pe(e)}),this.scenes.clear(),this.scene&&Pe(this.scene),this.renderTargets.forEach(e=>{e.dispose()}),this.renderTargets.clear(),this.renderer?.dispose()}getObject(e){this.app.debugEnabled&&(this.renderer!==void 0&&(yt.renderer=this.renderer),this.app.send({event:"getObject",target:"app",data:e}))}setObject(e){this.renderer!==void 0&&(yt.renderer=this.renderer);const t=ei(e);this.app.send({event:"setObject",target:"editor",data:t})}requestMethod(e,t,i,n){this.app.send({event:"requestMethod",target:"app",data:{uuid:e,key:t,value:i,subitem:n}})}updateObject(e,t,i){this.app.send({event:"updateObject",target:"app",data:{uuid:e,key:t,value:i}})}createTexture(e,t,i){this.app.send({event:"createTexture",target:"app",data:{uuid:e,key:t,value:i}})}addGroup(e){this.groups.get(e.title)===void 0&&(this.groups.set(e.title,{title:e.title,onUpdate:e.onUpdate}),this.app.send({event:"addGroup",target:"editor",data:JSON.stringify(e)}))}removeGroup(e){this.groups.get(e)!==void 0&&(this.groups.delete(e),this.app.send({event:"removeGroup",target:"editor",data:e}))}updateGroup(e,t,i){this.app.send({event:"updateGroup",target:"app",data:JSON.stringify({group:e,prop:t,value:i})})}removeAllGroups(){this.groups.forEach(e=>{const t=e.title;this.groups.delete(t),this.app.send({event:"removeGroup",target:"editor",data:t})}),this.groups.clear()}addSpline(e){setTimeout(()=>{this.app.send({event:"addSpline",target:"editor",data:JSON.stringify(e.toJSON())})},1)}setRenderer(e,t=null){if(this.renderer=e,this.canvas=e.domElement,this.inputElement=t!==null?t:this.canvas,!this.app.debugEnabled)return;const i=`#${e.getClearColor(new o.Color).getHexString()}`;this.app.send({event:"addRenderer",target:"editor",data:{autoClear:e.autoClear,autoClearColor:e.autoClearColor,autoClearDepth:e.autoClearDepth,autoClearStencil:e.autoClearStencil,outputColorSpace:e.outputColorSpace,localClippingEnabled:e.localClippingEnabled,clearColor:i,clearAlpha:e.getClearAlpha(),colorManagement:o.ColorManagement.enabled,toneMapping:e.toneMapping,toneMappingExposure:e.toneMappingExposure}})}updateRenderer(e){this.app.send({event:"updateRenderer",target:"app",data:e})}addScene(e){if(e===void 0||(this.scenes.set(e.name,e),!this.app.debugEnabled))return;pi(),zt(e);const t=tt(e);this.app.send({event:"addScene",target:"editor",data:t})}refreshScene(e){if(!this.app.debugEnabled)return;const t=this.scenes.get(e);if(t!==void 0){const i=tt(t);this.app.send({event:"refreshScene",target:"app",data:i})}}removeScene(e){if(e===void 0||(this.scenes.delete(e.name),!this.app.debugEnabled))return;const t=tt(e);this.app.send({event:"removeScene",target:"editor",data:t})}removeAllScenes(){this.scenes.forEach(e=>this.removeScene(e))}getScene(e){let t=null;return this.scenes.forEach((i,n)=>{e.search(n)>-1&&(t=i)}),t}setScene(e){if(e===void 0||(this.scene=e,!this.app.debugEnabled))return;this.renderer!==void 0&&(yt.renderer=this.renderer),pi(),zt(e);const t=tt(e);this.app.send({event:"setScene",target:"editor",data:t})}addCamera(e){if(!this.app.debugEnabled)return;const t=ei(e);this.app.send({event:"addCamera",target:"editor",data:t})}removeCamera(e){if(!this.app.debugEnabled)return;const t=ei(e);this.app.send({event:"removeCamera",target:"editor",data:t})}handleApp(e,t,i){const n=t;switch(i.event){case"getObject":R.dispatchEvent({type:A.GET_OBJECT,value:i.data});break;case"updateObject":R.dispatchEvent({type:A.UPDATE_OBJECT,value:i.data});break;case"createTexture":R.dispatchEvent({type:A.CREATE_TEXTURE,value:i.data});break;case"requestMethod":R.dispatchEvent({type:A.REQUEST_METHOD,value:i.data});break;case"refreshScene":e.send({event:"refreshScene",target:"editor",data:tt(n.scenes.get(i.data.name))});break;case"updateRenderer":n.renderer&&(n.renderer.autoClear=i.data.autoClear,n.renderer.autoClearColor=i.data.autoClearColor,n.renderer.autoClearDepth=i.data.autoClearDepth,n.renderer.autoClearStencil=i.data.autoClearStencil,n.renderer.outputColorSpace=i.data.outputColorSpace,n.renderer.localClippingEnabled=i.data.localClippingEnabled,n.renderer.setClearColor(i.data.clearColor,i.data.clearAlpha),n.renderer.toneMapping=i.data.toneMapping,n.renderer.toneMappingExposure=i.data.toneMappingExposure,o.ColorManagement.enabled=i.data.colorManagement);break}if(i.event==="updateGroup"){const r=JSON.parse(i.data);n.groups.get(r.group)?.onUpdate(r.prop,r.value)}}handleEditor(e,t,i){switch(i.event){case"setObject":R.dispatchEvent({type:A.SET_OBJECT,value:i.data});break;case"addScene":R.dispatchEvent({type:A.ADD_SCENE,value:i.data});break;case"refreshScene":R.dispatchEvent({type:A.REFRESH_SCENE,value:i.data});break;case"removeScene":R.dispatchEvent({type:A.REMOVE_SCENE,value:i.data});break;case"setScene":R.dispatchEvent({type:A.SET_SCENE,value:i.data});break;case"addCamera":R.dispatchEvent({type:A.ADD_CAMERA,value:i.data});break;case"removeCamera":R.dispatchEvent({type:A.REMOVE_CAMERA,value:i.data});break;case"addGroup":R.dispatchEvent({type:A.ADD_GROUP,value:i.data});break;case"removeGroup":R.dispatchEvent({type:A.REMOVE_GROUP,value:i.data});break;case"addSpline":R.dispatchEvent({type:A.ADD_SPLINE,value:i.data});break;case"addRenderer":R.dispatchEvent({type:A.ADD_RENDERER,value:i.data})}}addRT(e,t){const i=new o.WebGLRenderTarget(32,32,t);i.texture.name=e,this.renderTargets.set(e,i)}resize(e,t){const i=this.dpr;this.renderTargets.forEach(r=>{r.setSize(e*i,t*i)});const n=!(this.renderer?.domElement instanceof OffscreenCanvas);this.renderer?.setSize(e,t,n)}set dpr(e){this.renderer?.setPixelRatio(je(1,2,e))}get dpr(){return this.renderer!==void 0?this.renderer?.getPixelRatio():1}get width(){return this.renderer!==void 0?this.renderer.domElement.width/this.dpr:0}get height(){return this.renderer!==void 0?this.renderer.domElement.height/this.dpr:0}}var mi={exports:{}},at={};/**
18
+ `,f=c.createShader(35633),g=c.createShader(35632),x=c.createProgram();if(!(g&&f&&x))return;c.shaderSource(f,u),c.shaderSource(g,m),c.compileShader(f),c.compileShader(g),c.attachShader(x,f),c.attachShader(x,g),c.linkProgram(x),c.detachShader(x,f),c.detachShader(x,g),c.deleteShader(f),c.deleteShader(g),c.useProgram(x);const y=c.createBuffer();c.bindBuffer(34962,y),c.bufferData(34962,new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),35044);const T=c.getAttribLocation(x,"aPosition");c.vertexAttribPointer(T,3,5126,!1,0,0),c.enableVertexAttribArray(T),c.clearColor(1,1,1,1),c.clear(16384),c.viewport(0,0,1,1),c.drawArrays(4,0,3);const _=new Uint8Array(4);return c.readPixels(0,0,1,1,6408,5121,_),c.deleteProgram(x),c.deleteBuffer(y),_.join("")}(i),n="801621810",a="8016218135",r="80162181161",l=Te?.isIpad?[["a7",r,12],["a8",a,15],["a8x",a,15],["a9",a,15],["a9x",a,15],["a10",a,15],["a10x",a,15],["a12",n,15],["a12x",n,15],["a12z",n,15],["a14",n,15],["a15",n,15],["m1",n,15],["m2",n,15]]:[["a7",r,12],["a8",a,12],["a9",a,15],["a10",a,15],["a11",n,15],["a12",n,15],["a13",n,15],["a14",n,15],["a15",n,15],["a16",n,15],["a17",n,15]];let h;return s==="80162181255"?h=l.filter(([,,c])=>c>=14):(h=l.filter(([,c])=>c===s),h.length||(h=l)),h.map(([c])=>`apple ${c} gpu`)}class zi extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}const $t=[],Hi=[];function on(i,e){if(i===e)return 0;const t=i;i.length>e.length&&(i=e,e=t);let s=i.length,n=e.length;for(;s>0&&i.charCodeAt(~-s)===e.charCodeAt(~-n);)s--,n--;let a,r=0;for(;r<s&&i.charCodeAt(r)===e.charCodeAt(r);)r++;if(s-=r,n-=r,s===0)return n;let l,h,c=0,u=0,m=0;for(;u<s;)Hi[u]=i.charCodeAt(r+u),$t[u]=++u;for(;m<n;)for(a=e.charCodeAt(r+m),l=m++,c=m,u=0;u<s;u++)h=a===Hi[u]?l:l+1,l=$t[u],c=$t[u]=l>c?h>c?c+1:h:h>l?l+1:h;return c}function ln(i){return i!=null}const cn=({mobileTiers:i=[0,15,30,60],desktopTiers:e=[0,15,30,60],override:t={},glContext:s,failIfMajorPerformanceCaveat:n=!1,benchmarksURL:a="https://unpkg.com/detect-gpu@5.0.57/dist/benchmarks"}={})=>Kt(void 0,void 0,void 0,function*(){const r={};if(vs)return{tier:0,type:"SSR"};const{isIpad:l=!!Te?.isIpad,isMobile:h=!!Te?.isMobile,screenSize:c=window.screen,loadBenchmarks:u=w=>Kt(void 0,void 0,void 0,function*(){const M=yield fetch(`${a}/${w}`).then(I=>I.json());if(parseInt(M.shift().split(".")[0],10)<4)throw new zi("Detect GPU benchmark data is out of date. Please update to version 4x");return M})}=t;let{renderer:m}=t;const f=(w,M,I,U,D)=>({device:D,fps:U,gpu:I,isMobile:h,tier:w,type:M});let g,x="";if(m)m=Fi(m),g=[m];else{const w=s||function(I,U=!1){const D={alpha:!1,antialias:!1,depth:!1,failIfMajorPerformanceCaveat:U,powerPreference:"high-performance",stencil:!1};I&&delete D.powerPreference;const B=window.document.createElement("canvas"),_e=B.getContext("webgl",D)||B.getContext("experimental-webgl",D);return _e??void 0}(Te?.isSafari12,n);if(!w)return f(0,"WEBGL_UNSUPPORTED");const M=Te?.isFirefox?null:w.getExtension("WEBGL_debug_renderer_info");if(m=M?w.getParameter(M.UNMASKED_RENDERER_WEBGL):w.getParameter(w.RENDERER),!m)return f(1,"FALLBACK");x=m,m=Fi(m),g=function(I,U,D){return U==="apple gpu"?rn(I,U,D):[U]}(w,m,h)}const y=(yield Promise.all(g.map(function(w){var M;return Kt(this,void 0,void 0,function*(){const I=(G=>{const re=h?["adreno","apple","mali-t","mali","nvidia","powervr","samsung"]:["intel","apple","amd","radeon","nvidia","geforce","adreno"];for(const Ee of re)if(G.includes(Ee))return Ee})(w);if(!I)return;const U=`${h?"m":"d"}-${I}${l?"-ipad":""}.json`,D=r[U]=(M=r[U])!==null&&M!==void 0?M:u(U);let B;try{B=yield D}catch(G){if(G instanceof zi)throw G;return}const _e=function(G){var re;const Ee=(G=G.replace(/\([^)]+\)/,"")).match(/\d+/)||G.match(/(\W|^)([A-Za-z]{1,3})(\W|$)/g);return(re=Ee?.join("").replace(/\W|amd/g,""))!==null&&re!==void 0?re:""}(w);let pe=B.filter(([,G])=>G===_e);pe.length||(pe=B.filter(([G])=>G.includes(w)));const ne=pe.length;if(ne===0)return;const Q=w.split(/[.,()\[\]/\s]/g).sort().filter((G,re,Ee)=>re===0||G!==Ee[re-1]).join(" ");let X,[Pe,,,,ce]=ne>1?pe.map(G=>[G,on(Q,G[2])]).sort(([,G],[,re])=>G-re)[0][0]:pe[0],ge=Number.MAX_VALUE;const{devicePixelRatio:ie}=window,Re=c.width*ie*c.height*ie;for(const G of ce){const[re,Ee]=G,st=re*Ee,Ye=Math.abs(Re-st);Ye<ge&&(ge=Ye,X=G)}if(!X)return;const[,,De,Ie]=X;return[ge,De,Pe,Ie]})}))).filter(ln).sort(([w=Number.MAX_VALUE,M],[I=Number.MAX_VALUE,U])=>w===I?M-U:w-I);if(!y.length){const w=an.find(M=>m.includes(M));return w?f(0,"BLOCKLISTED",w):f(1,"FALLBACK",`${m} (${x})`)}const[,T,_,C]=y[0];if(T===-1)return f(0,"BLOCKLISTED",_,T,C);const E=h?i:e;let S=0;for(let w=0;w<E.length;w++)T>=E[w]&&(S=w);return f(S,"BENCHMARK",_,T,C)});var ys=(i=>(i[i.High=0]="High",i[i.Medium=1]="Medium",i[i.Low=2]="Low",i))(ys||{});function hn(i){return new Promise(e=>{cn().then(t=>{let s=!1;const n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);if(s="transferControlToOffscreen"in i,n){const r=navigator.userAgent.match(/version\/(\d+)/i);s=(r?parseInt(r[1]):0)>=17}const a={dpr:devicePixelRatio,fps:t.fps!==void 0?t.fps:30,width:innerWidth,height:innerHeight,mobile:t.isMobile!==void 0?t.isMobile:!1,supportOffScreenCanvas:s,quality:2};t.tier===3?a.quality=0:t.tier===2&&(a.quality=1),e(a)})})}function je(i,e,t){return Math.min(e,Math.max(i,t))}function Ft(i,e,t){return(t-i)/(e-i)}function it(i,e,t){return i*(1-t)+e*t}function dn(i,e,t,s,n){return it(t,s,Ft(i,e,n))}function un(i,e){const t=i-e;return Math.sqrt(t*t)}function Ce(i,e=1){return Number(i.toFixed(e))}function pn(i,e,t,s){return it(i,e,1-Math.exp(-t*s))}function mn(i,e=1){return Number(i.toFixed(e))}function fn(i,e,t,s){return i===e&&t===s}function gn(i,e,t,s){return 1/(3*e*i*i+2*t*i+s)}function _n(i,e,t,s,n){return e*(i*i*i)+t*(i*i)+s*i+n}function vn(i,e,t,s,n){const a=i*i;return e*(a*i)+t*a+s*i+n}function yn(i,e,t,s,n){if(i<=0)return 0;if(i>=1)return 1;if(fn(e,t,s,n))return i;const a=0,r=0,l=e,h=t,c=s,u=n,m=1,f=1,g=m-3*c+3*l-a,x=3*c-6*l+3*a,y=3*l-3*a,T=a,_=f-3*u+3*h-r,C=3*u-6*h+3*r,E=3*h-3*r,S=r;let w=i;for(let M=0;M<5;M++){const I=_n(w,g,x,y,T);let U=gn(w,g,x,y);U===1/0&&(U=i),w-=(I-i)*U,w=Math.min(Math.max(w,0),1)}return vn(w,_,C,E,S)}const pi=i=>{i?.dispose()},Cs=i=>{if(i)if(Array.isArray(i))i.forEach(e=>e.dispose());else{for(const e in i){const t=i[e];t!==null&&t instanceof o.Texture&&pi(t)}if(i.isShaderMaterial===!0){const e=i;for(const t in e.uniforms){const s=e.uniforms[t];s.value!==null&&s.value instanceof o.Texture&&pi(s.value)}}i.dispose()}},Ae=i=>{if(i){for(;i.children.length>0;){const e=i.children[0];e.type==="Audio"?(e.pause(),e.parent&&e.parent.remove(e)):Ae(e)}if(i.parent&&i.parent.remove(i),i.isMesh){const e=i;e.geometry?.dispose(),Cs(e.material)}i.dispose!==void 0&&i.dispose()}};exports.totalThreeObjects=0;const mi=()=>{exports.totalThreeObjects=0},zt=i=>{if(!i)return;let e=i.name.replaceAll(" ","").replaceAll("/",".");if(e.length===0&&(e=`obj_${exports.totalThreeObjects}`,exports.totalThreeObjects++),i.parent!==null&&i.parent.uuid.length>0&&(e=`${i.parent.uuid}.${e}`),i.uuid=e,i.isMesh!==void 0){const t=i;if(Array.isArray(t.material))t.material.forEach((s,n)=>{s.uuid=`${e}.material.${n}`});else{const s=t.material;s.uuid=`${e}.material`}}i.children.forEach(t=>zt(t))};class yt{static renderer;static canvas;static context=null;static scene=null;static camera=null;static material=null;static inited=!1;static width=100;static height=100;static init(){this.inited||(this.canvas=document.createElement("canvas"),this.canvas.width=this.width,this.canvas.height=this.height,this.context=this.canvas.getContext("2d"),this.inited=!0)}static renderToBlob(e){this.init();const t=e.repeat.clone(),s=e.offset.clone();if(e.repeat.set(1,1),e.offset.set(0,0),this.context!==null){this.context.clearRect(0,0,this.width,this.height);const n=e.image;if(n!=null&&n.width>0){this.canvas.title=e.sourceFile;const a=this.canvas.width/n.width,r=this.renderToCanvas(e);this.context.drawImage(r,0,0,n.width*a,n.height*a)}}return e.repeat.copy(t),e.offset.copy(s),this.canvas.toDataURL("image/png")}static renderToCanvas(e){if(this.material===null){this.camera=new o.OrthographicCamera(-.5,.5,.5,-.5,0,100),this.scene=new o.Scene,this.material=new o.MeshBasicMaterial;const t=new o.BufferGeometry;t.setAttribute("position",new o.Float32BufferAttribute([-.5,-.5,0,1.5,-.5,0,-.5,1.5,0],3)),t.setAttribute("normal",new o.Float32BufferAttribute([0,0,1,0,0,1],3)),t.setAttribute("uv",new o.Float32BufferAttribute([0,0,2,0,0,2],2));const s=new o.Mesh(t,this.material);this.scene.add(s)}if(e.isRenderTargetTexture)this.material.map=e,this.renderer.render(this.scene,this.camera);else{const t=this.renderer.outputColorSpace,s=e.colorSpace;this.renderer.outputColorSpace=o.LinearSRGBColorSpace,e.colorSpace=o.LinearSRGBColorSpace,this.material.map=e,this.renderer.render(this.scene,this.camera),this.renderer.outputColorSpace=t,e.colorSpace=s}return this.renderer.domElement}}function Cn(i){return new Promise(e=>{const t=new o.ObjectLoader;t.parseAsync(i.scene).then(s=>{const n=new o.AnimationMixer(s);if(i.animations.length>0){const r=i.animations.map(h=>o.AnimationClip.parse(h));n.clipAction(r[0]).play(),n.getRoot().animations=i.animations,n.getRoot().mixer=n}const a=[];i.cameras&&i.cameras.length>0&&i.cameras.forEach(r=>{const l=t.parse(r);a.push(l)}),e({animations:i.animations,model:s,mixer:n,cameras:a})})})}const We=bi(["ctrlKey","metaKey","shiftKey","button","pointerId","pointerType","clientX","clientY","pageX","pageY"]),bn=bi(["clientX","clientY","deltaX","deltaY","deltaMode"]),En=bi(["ctrlKey","metaKey","shiftKey","keyCode"]);function Sn(i,e){i.preventDefault(),bn(i,e)}function wn(i){i.preventDefault()}function xn(i,e,t){for(const s of e)t[s]=i[s]}function bi(i){return function(t,s){const n={type:t.type};xn(t,i,n),s(n)}}function Jt(i,e){const t=[],s={type:i.type,touches:t};for(let n=0;n<i.touches.length;++n){const a=i.touches[n];t.push({pageX:a.pageX,pageY:a.pageY})}e(s)}const On={37:!0,38:!0,39:!0,40:!0};function Tn(i,e){const{keyCode:t}=i;On[t]&&(i.preventDefault(),En(i,e))}const Mn={contextmenu:wn,mousedown:We,mousemove:We,mouseup:We,pointerdown:We,pointermove:We,pointerup:We,touchstart:Jt,touchmove:Jt,touchend:Jt,wheel:Sn,keydown:Tn};let An=0;class Pn{id;worker;constructor(e,t,s){this.id=An++,this.worker=t;const n=r=>{this.worker.postMessage({type:"event",id:this.id,data:r})};t.postMessage({type:"makeProxy",id:this.id});for(const[r,l]of Object.entries(s))e.addEventListener(r,h=>{l(h,n)});function a(){n({type:"resize",left:0,top:0,width:innerWidth,height:innerHeight})}window.addEventListener("resize",a),a()}}class bs extends o.EventDispatcher{style={};left=0;top=0;width=0;height=0;ownerDocument=void 0;constructor(){super(),this.ownerDocument=this}get clientWidth(){return this.width}set clientWidth(e){this.width=e}get clientHeight(){return this.height}set clientHeight(e){this.height=e}setPointerCapture(){}releasePointerCapture(){}getBoundingClientRect(){return{x:this.left,y:this.top,left:this.left,top:this.top,width:this.width,height:this.height,right:this.left+this.width,bottom:this.top+this.height,toJSON:()=>({})}}handleEvent(e){if(e.type==="size"){this.left=e.left,this.top=e.top,this.width=e.width,this.height=e.height;return}e.preventDefault=Ct,e.stopPropagation=Ct,this.dispatchEvent(e)}focus(){}getRootNode(){return this}}class Rn{targets={};constructor(){this.handleEvent=this.handleEvent.bind(this)}makeProxy(e){const{id:t}=e,s=new bs;this.targets[t]=s}getProxy(e){return this.targets[e]}handleEvent(e){this.targets[e.id]?.handleEvent(e.data)}}class Dn{components=new Map;listen;_appID="";_debugEnabled;_broadcastChannel=void 0;_webSocket=void 0;_mode="app";_connected=!1;_useBC=!1;constructor(e,t,s=!0){this._appID=e,this._debugEnabled=t,t&&(this._useBC=s,s?(this._broadcastChannel=new BroadcastChannel(e),this._broadcastChannel.addEventListener("message",this.messageHandler)):(this._webSocket=new WebSocket(e),this._webSocket.addEventListener("open",this.openHandler),this._webSocket.addEventListener("close",this.closeHandler),this._webSocket.addEventListener("message",this.messageHandler)))}addComponent(e,t){this.components.set(e,t)}dispose(){this._broadcastChannel!==void 0&&this._broadcastChannel.removeEventListener("message",this.messageHandler),this._webSocket!==void 0&&(this._webSocket.removeEventListener("open",this.openHandler),this._webSocket.removeEventListener("close",this.closeHandler),this._webSocket.removeEventListener("message",this.messageHandler)),this.components.forEach(e=>{e.dispose()}),this.components.clear()}send(e){this._mode!==e.target&&(this._useBC?this._broadcastChannel?.postMessage(e):this._connected&&this._webSocket?.send(JSON.stringify(e)))}messageHandler=e=>{this.listen!==void 0&&(this._useBC?this.listen(e.data):this.listen(JSON.parse(e.data)))};openHandler=()=>{this._connected=!0};closeHandler=()=>{this._connected=!1};get appID(){return this._appID}get connected(){return this._connected}get debugEnabled(){return this._debugEnabled}get mode(){return this._mode}get isApp(){return this._mode==="app"}get editor(){return this._mode==="editor"}set editor(e){e&&(this._mode="editor")}}var P=(i=>(i.CUSTOM="ToolEvents::custom",i.SELECT_DROPDOWN="ToolEvents::selectDropdown",i.DRAG_UPDATE="ToolEvents::dragUpdate",i.ADD_SCENE="ToolEvents::addScene",i.REFRESH_SCENE="ToolEvents::refreshScene",i.REMOVE_SCENE="ToolEvents::removeScene",i.SET_SCENE="ToolEvents::setScene",i.GET_OBJECT="ToolEvents::getObject",i.SET_OBJECT="ToolEvents::setObject",i.UPDATE_OBJECT="ToolEvents::updateObject",i.CREATE_TEXTURE="ToolEvents::createTexture",i.REQUEST_METHOD="ToolEvents::requestMethod",i.ADD_CAMERA="ToolEvents::addCamera",i.REMOVE_CAMERA="ToolEvents::removeCamera",i.ADD_GROUP="ToolEvents::addGroup",i.REMOVE_GROUP="ToolEvents::removeGroup",i.ADD_SPLINE="ToolEvents::addSpline",i.ADD_RENDERER="ToolEvents::addRenderer",i.UPDATE_RENDERER="ToolEvents::updateRenderer",i))(P||{});const R=new o.EventDispatcher;class Vt{app;constructor(e){this.app=e}dispose(){}handleApp(e,t,s){}handleEditor(e,t,s){}}class In extends Vt{selectDropdown(e,t){this.app.send({event:"selectComponent",target:"app",data:{dropdown:e,value:t}})}updateDropdown(e,t){this.app.send({event:"draggableListUpdate",target:"app",data:{dropdown:e,value:t}})}handleApp(e,t,s){switch(s.event){case"selectComponent":R.dispatchEvent({type:P.SELECT_DROPDOWN,value:s.data});break;case"draggableListUpdate":R.dispatchEvent({type:P.DRAG_UPDATE,value:s.data});break}}}function Ln(i,e,t){if(i.editor){t.ui.restore(),t.onSelectionChange(r=>{r.length<1||r.forEach(l=>{let h=l.address.sheetId,c="setSheet",u={};switch(l.type){case"Theatre_Sheet_PublicAPI":c="setSheet",u={sheet:l.address.sheetId},e.activeSheet=e.sheets.get(l.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":c="setSheetObject",h+=`_${l.address.objectKey}`,u={id:h,sheet:l.address.sheetId,key:l.address.objectKey},e.activeSheet=e.sheets.get(l.address.sheetId);break}i.send({event:c,target:"app",data:u})})});let s=-1;const n=()=>{if(e.activeSheet!==void 0&&s!==e.activeSheet.sequence.position){s=e.activeSheet.sequence.position;const r=e.activeSheet;i.send({event:"updateTimeline",target:"app",data:{position:s,sheet:r.address.sheetId}})}},a=()=>{n(),requestAnimationFrame(a)};n(),a()}else t.ui.hide()}function kn(){setTimeout(()=>{const i=document.getElementById("theatrejs-studio-root");if(i===null||i.shadowRoot===null)return;const e=i.shadowRoot.getElementById("pointer-root");if(e===null)return;const t=e.children[0];if(t===null)return;const s=t.children[1];s.style.justifyContent="left";try{const n=s.children[1];for(n.style.transform="translateX(10px)";n.children.length>1;)n.removeChild(n.children[0])}catch{}try{const n=t.children[3];n.style.top="0",n.style.right="300px"}catch{}},1e3)}function Un(i,e,t,s,n){const a=1-i;return a*a*a*e+3*a*a*i*t+3*a*i*i*s+i*i*i*n}function jn(i,e,t){if(i.type!=="bezier"||i.handles.length!==4)throw new Error("Invalid keyframe data for Bézier interpolation.");const[s,n]=i.handles,a=(t-i.position)/(e.position-i.position);return Un(a,i.value,i.value+s,e.value+n,e.value)}class Nn extends Vt{project;sheets=new Map;sheetObjects=new Map;sheetObjectCBs=new Map;sheetObjectUnsubscribe=new Map;activeSheet;studio=void 0;dispose(){this.project=void 0,this.sheets=new Map,this.sheetObjects=new Map,this.sheetObjectCBs=new Map,this.sheetObjectUnsubscribe=new Map}getSheetInstance(e,t){return t!==void 0?`${e}-${t}`:e}sheet(e,t){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const s=this.getSheetInstance(e,t);let n=this.sheets.get(s);return n!==void 0||(n=this.project?.sheet(e,t),this.sheets.set(s,n)),n}playSheet(e,t,s){return new Promise(n=>{const a=t!==void 0?{...t}:{};this.sheet(e,s)?.sequence.play(a).then(r=>n(r)),this.app.send({event:"playSheet",target:"editor",data:{sheet:e,instance:s,value:t}})})}pauseSheet(e,t){this.sheet(e,t)?.sequence.pause(),this.app.send({event:"pauseSheet",target:"editor",data:{sheet:e,instance:t}})}clearSheetObjects(e){this.sheetObjects.forEach((t,s)=>{s.search(`${e}_`)>-1&&this.unsubscribe(t)})}sheetObject(e,t,s,n,a){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const r=this.sheet(e,a);if(r===void 0)return;const h=`${this.getSheetInstance(e,a)}_${t}`;let c=this.sheetObjects.get(h),u=s;c!==void 0&&(u={...s,...c.value}),c=r.object(t,u),this.sheetObjects.set(h,c),this.sheetObjectCBs.set(h,n!==void 0?n:Ct);const m=c.onValuesChange(f=>{if(this.app.editor){for(const x in f){const y=f[x];typeof y=="object"&&_s(y)&&(f[x]={r:y.r,g:y.g,b:y.b,a:y.a})}this.app.send({event:"updateSheetObject",target:"app",data:{sheet:e,sheetObject:h,values:f}})}const g=this.sheetObjectCBs.get(h);g!==void 0&&g(f)});return this.sheetObjectUnsubscribe.set(h,m),c}getSheetObjectKeyframes(e,t,s){const n=this.sheet(e);if(n===void 0)return[];const a=`${e}_${t}`,r=this.sheetObjects.get(a);return r===void 0?[]:n.sequence.__experimental_getKeyframes(r.props[s])}getSheetObjectVectors(e,t){const s=this.sheet(e);if(s===void 0)return[];const n=`${e}_${t}`,a=this.sheetObjects.get(n);if(a===void 0)return[];const r=[],l=s.sequence.__experimental_getKeyframes(a.props.x),h=s.sequence.__experimental_getKeyframes(a.props.y),c=s.sequence.__experimental_getKeyframes(a.props.z),u=new Set;return l.forEach(f=>u.add(f.position)),h.forEach(f=>u.add(f.position)),c.forEach(f=>u.add(f.position)),Array.from(u).sort((f,g)=>f-g).forEach(f=>{const g=(x,y)=>{const T=x.find((E,S)=>E.position<=y&&(x[S+1]?.position||1/0)>y),_=x.find(E=>E.position>y);if(!T)return _?.value||0;if(!_||T.position===y)return T.value;if(T.type==="bezier")return jn(T,_,y);const C=(y-T.position)/(_.position-T.position);return T.value+C*(_.value-T.value)};r.push({position:f,x:g(l,f),y:g(h,f),z:g(c,f)})}),r}unsubscribe(e){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const t=e.address.sheetId,s=e.address.objectKey;this.sheets.get(t)?.detachObject(s);const a=`${t}_${s}`,r=this.sheetObjectUnsubscribe.get(a);r!==void 0&&(this.sheetObjects.delete(a),this.sheetObjectCBs.delete(a),this.sheetObjectUnsubscribe.delete(a),r())}handleApp(e,t,s){const n=t;let a;switch(s.event){case"setSheet":a=n.sheets.get(s.data.sheet),a!==void 0&&(n.activeSheet=a,this.studio?.setSelection([a]));break;case"setSheetObject":a=n.sheetObjects.get(`${s.data.sheet}_${s.data.key}`),a!==void 0&&this.studio?.setSelection([a]);break;case"updateSheetObject":a=n.sheets.get(s.data.sheet),a!==void 0&&a.sequence.pause(),a=n.sheetObjectCBs.get(s.data.sheetObject),a!==void 0&&a(s.data.values);break;case"updateTimeline":a=n.sheets.get(s.data.sheet),n.activeSheet!==void 0&&(n.activeSheet.sequence.position=s.data.position);break}}handleEditor(e,t,s){if(e.editor){const n=t;switch(s.event){case"playSheet":n.sheet(s.data.sheet,s.data.instance)?.sequence.play(s.data.value);break;case"pauseSheet":n.sheet(s.data.sheet,s.data.instance)?.sequence.pause();break}}}handleEditorApp(e,t){if(e.editor){this.studio?.ui.restore(),this.studio?.onSelectionChange(r=>{r.length<1||r.forEach(l=>{let h=l.address.sheetId,c="setSheet",u={};switch(l.type){case"Theatre_Sheet_PublicAPI":c="setSheet",u={sheet:l.address.sheetId},t.activeSheet=t.sheets.get(l.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":c="setSheetObject",h+=`_${l.address.objectKey}`,u={id:h,sheet:l.address.sheetId,key:l.address.objectKey},t.activeSheet=t.sheets.get(l.address.sheetId);break}e.send({event:c,target:"app",data:u})})});let s=-1;const n=()=>{if(t.activeSheet!==void 0&&s!==t.activeSheet.sequence.position){s=t.activeSheet.sequence.position;const r=t.activeSheet;e.send({event:"updateTimeline",target:"app",data:{position:s,sheet:r.address.sheetId}})}},a=()=>{n(),requestAnimationFrame(a)};n(),a()}else this.studio?.ui.hide()}}function Fn(i){if(i.name==="cameras")return"camera";if(i.name==="interactive")return"interactive";if(i.name==="lights")return"light";if(i.name==="ui")return"ui";if(i.name==="utils")return"utils";const e=i.type;return e.search("Helper")>-1?"icon_utils":e.search("Camera")>-1?"camera":e.search("Light")>-1?"light":"obj3D"}function tt(i){const e={name:i.name,type:i.type,uuid:i.uuid,children:[]};return i.children.forEach(t=>{e.children.push(tt(t))}),e}function zn(i){const e={};for(const t in i){const s=i[t].value;e[t]={value:s},s===null?e[t].value={src:"",offset:[0,0],repeat:[1,1]}:s!==void 0&&s.isTexture&&(e[t].value={src:s.image.src,offset:[s.offset.x,s.offset.y],repeat:[s.repeat.x,s.repeat.y]})}return e}function Hn(i){switch(i){case"blendSrcAlpha":case"blendDstAlpha":case"blendEquationAlpha":case"clippingPlanes":case"shadowSide":case"precision":return!0}return!1}function Xe(i){const e={};for(const t in i){if(t.substring(0,1)==="_"||t.substring(0,2)==="is"||Hn(t))continue;const s=typeof i[t],n=i[t];switch(s){case"boolean":case"number":case"string":e[t]=n;break;case"object":n!==null?(e[t]=n,n.isTexture?e[t]={src:yt.renderToBlob(n),offset:[n.offset.x,n.offset.y],repeat:[n.repeat.x,n.repeat.y]}:t==="uniforms"&&(e[t]=zn(e[t]))):t==="glslVersion"?e[t]="":e[t]={src:"",offset:[0,0],repeat:[1,1]};break}}return i.anisotropy!==void 0&&(e.anisotropy=i.anisotropy),i.clearcoat!==void 0&&(e.clearcoat=i.clearcoat),i.iridescence!==void 0&&(e.iridescence=i.iridescence),i.dispersion!==void 0&&(e.dispersion=i.dispersion),i.sheen!==void 0&&(e.sheen=i.sheen),i.transmission!==void 0&&(e.transmission=i.transmission),i.transmission!==void 0&&(e.transmission=i.transmission),e}function ei(i){i.updateMatrix();const e={name:i.name,type:i.type,uuid:i.uuid,visible:i.visible,matrix:i.matrix.elements,animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0,children:[]};i.animations.forEach(s=>{e.animations.push({name:s.name,duration:s.duration,blendMode:s.blendMode})});const t=i.type.toLowerCase();if(t.search("mesh")>-1){const s=i;if(Array.isArray(s.material)){const n=[];s.material.forEach(a=>{n.push(Xe(a))}),e.material=n}else e.material=Xe(s.material)}else if(t.search("points")>-1){const s=i;if(Array.isArray(s.material)){const n=[];s.material.forEach(a=>{n.push(Xe(a))}),e.material=n}else e.material=Xe(s.material)}else if(t.search("line")>-1){const s=i;if(Array.isArray(s.material)){const n=[];s.material.forEach(a=>{n.push(Xe(a))}),e.material=n}else e.material=Xe(s.material)}else t.search("camera")>-1?i.type==="PerspectiveCamera"?e.perspectiveCameraInfo={fov:i.fov,zoom:i.zoom,near:i.near,far:i.far,focus:i.focus,aspect:i.aspect,filmGauge:i.filmGauge,filmOffset:i.filmOffset}:i.type==="OrthographicCamera"&&(e.orthographicCameraInfo={zoom:i.zoom,near:i.near,far:i.far,left:i.left,right:i.right,top:i.top,bottom:i.bottom}):t.search("light")>-1&&(e.lightInfo={color:i.color,intensity:i.intensity,decay:i.decay,distance:i.distance,angle:i.angle,penumbra:i.penumbra,groundColor:i.groundColor,width:i.width,height:i.height});return e}function Vn(i,e){const t=e.split(".");switch(t.length){case 1:return i[t[0]];case 2:return i[t[0]][t[1]];case 3:return i[t[0]][t[1]][t[2]];case 4:return i[t[0]][t[1]][t[2]][t[3]];case 5:return i[t[0]][t[1]][t[2]][t[3]][t[4]];case 6:return i[t[0]][t[1]][t[2]][t[3]][t[4]][t[5]]}}function Bn(i,e){for(const t in e)i[t]=e[t]}function te(i,e,t){if(i===void 0)return;const s=e.split("."),n=s.length;if(typeof t!="object")switch(n){case 1:i[s[0]]=t;break;case 2:i[s[0]][s[1]]=t;break;case 3:i[s[0]][s[1]][s[2]]=t;break;case 4:i[s[0]][s[1]][s[2]][s[3]]=t;break;case 5:i[s[0]][s[1]][s[2]][s[3]][s[4]]=t;break}else{let r;switch(n){case 1:r=i[s[0]];break;case 2:r=i[s[0]][s[1]];break;case 3:r=i[s[0]][s[1]][s[2]];break;case 4:r=i[s[0]][s[1]][s[2]][s[3]];break;case 5:r=i[s[0]][s[1]][s[2]][s[3]][s[4]];break}r!=null&&Bn(r,t)}}function Es(i){return new Promise((e,t)=>{const s=new Image;s.onload=()=>{const n=new o.Texture(s);n.wrapS=o.RepeatWrapping,n.wrapT=o.RepeatWrapping,n.needsUpdate=!0,e(n)},s.onerror=t,s.src=i})}class Yn extends Vt{canvas=null;inputElement=null;scene=void 0;scenes=new Map;renderer=void 0;renderTargets=new Map;groups=new Map;dispose(){this.scenes.forEach(e=>{Ae(e)}),this.scenes.clear(),this.scene&&Ae(this.scene),this.renderTargets.forEach(e=>{e.dispose()}),this.renderTargets.clear(),this.renderer?.dispose()}getObject(e){this.app.debugEnabled&&(this.renderer!==void 0&&(yt.renderer=this.renderer),this.app.send({event:"getObject",target:"app",data:e}))}setObject(e){this.renderer!==void 0&&(yt.renderer=this.renderer);const t=ei(e);this.app.send({event:"setObject",target:"editor",data:t})}requestMethod(e,t,s,n){this.app.send({event:"requestMethod",target:"app",data:{uuid:e,key:t,value:s,subitem:n}})}updateObject(e,t,s){this.app.send({event:"updateObject",target:"app",data:{uuid:e,key:t,value:s}})}createTexture(e,t,s){this.app.send({event:"createTexture",target:"app",data:{uuid:e,key:t,value:s}})}addGroup(e){this.groups.get(e.title)===void 0&&(this.groups.set(e.title,{title:e.title,onUpdate:e.onUpdate}),this.app.send({event:"addGroup",target:"editor",data:JSON.stringify(e)}))}removeGroup(e){this.groups.get(e)!==void 0&&(this.groups.delete(e),this.app.send({event:"removeGroup",target:"editor",data:e}))}updateGroup(e,t,s){this.app.send({event:"updateGroup",target:"app",data:JSON.stringify({group:e,prop:t,value:s})})}removeAllGroups(){this.groups.forEach(e=>{const t=e.title;this.groups.delete(t),this.app.send({event:"removeGroup",target:"editor",data:t})}),this.groups.clear()}addSpline(e){setTimeout(()=>{this.app.send({event:"addSpline",target:"editor",data:JSON.stringify(e.toJSON())})},1)}setRenderer(e,t=null){if(this.renderer=e,this.canvas=e.domElement,this.inputElement=t!==null?t:this.canvas,!this.app.debugEnabled)return;const s=`#${e.getClearColor(new o.Color).getHexString()}`;this.app.send({event:"addRenderer",target:"editor",data:{autoClear:e.autoClear,autoClearColor:e.autoClearColor,autoClearDepth:e.autoClearDepth,autoClearStencil:e.autoClearStencil,outputColorSpace:e.outputColorSpace,localClippingEnabled:e.localClippingEnabled,clearColor:s,clearAlpha:e.getClearAlpha(),colorManagement:o.ColorManagement.enabled,toneMapping:e.toneMapping,toneMappingExposure:e.toneMappingExposure}})}updateRenderer(e){this.app.send({event:"updateRenderer",target:"app",data:e})}addScene(e){if(e===void 0||(this.scenes.set(e.name,e),!this.app.debugEnabled))return;mi(),zt(e);const t=tt(e);this.app.send({event:"addScene",target:"editor",data:t})}refreshScene(e){if(!this.app.debugEnabled)return;const t=this.scenes.get(e);if(t!==void 0){const s=tt(t);this.app.send({event:"refreshScene",target:"app",data:s})}}removeScene(e){if(e===void 0||(this.scenes.delete(e.name),!this.app.debugEnabled))return;const t=tt(e);this.app.send({event:"removeScene",target:"editor",data:t})}removeAllScenes(){this.scenes.forEach(e=>this.removeScene(e))}getScene(e){let t=null;return this.scenes.forEach((s,n)=>{e.search(n)>-1&&(t=s)}),t}setScene(e){if(e===void 0||(this.scene=e,!this.app.debugEnabled))return;this.renderer!==void 0&&(yt.renderer=this.renderer),mi(),zt(e);const t=tt(e);this.app.send({event:"setScene",target:"editor",data:t})}addCamera(e){if(!this.app.debugEnabled)return;const t=ei(e);this.app.send({event:"addCamera",target:"editor",data:t})}removeCamera(e){if(!this.app.debugEnabled)return;const t=ei(e);this.app.send({event:"removeCamera",target:"editor",data:t})}handleApp(e,t,s){const n=t;switch(s.event){case"getObject":R.dispatchEvent({type:P.GET_OBJECT,value:s.data});break;case"updateObject":R.dispatchEvent({type:P.UPDATE_OBJECT,value:s.data});break;case"createTexture":R.dispatchEvent({type:P.CREATE_TEXTURE,value:s.data});break;case"requestMethod":R.dispatchEvent({type:P.REQUEST_METHOD,value:s.data});break;case"refreshScene":e.send({event:"refreshScene",target:"editor",data:tt(n.scenes.get(s.data.name))});break;case"updateRenderer":n.renderer&&(n.renderer.autoClear=s.data.autoClear,n.renderer.autoClearColor=s.data.autoClearColor,n.renderer.autoClearDepth=s.data.autoClearDepth,n.renderer.autoClearStencil=s.data.autoClearStencil,n.renderer.outputColorSpace=s.data.outputColorSpace,n.renderer.localClippingEnabled=s.data.localClippingEnabled,n.renderer.setClearColor(s.data.clearColor,s.data.clearAlpha),n.renderer.toneMapping=s.data.toneMapping,n.renderer.toneMappingExposure=s.data.toneMappingExposure,o.ColorManagement.enabled=s.data.colorManagement);break}if(s.event==="updateGroup"){const a=JSON.parse(s.data);n.groups.get(a.group)?.onUpdate(a.prop,a.value)}}handleEditor(e,t,s){switch(s.event){case"setObject":R.dispatchEvent({type:P.SET_OBJECT,value:s.data});break;case"addScene":R.dispatchEvent({type:P.ADD_SCENE,value:s.data});break;case"refreshScene":R.dispatchEvent({type:P.REFRESH_SCENE,value:s.data});break;case"removeScene":R.dispatchEvent({type:P.REMOVE_SCENE,value:s.data});break;case"setScene":R.dispatchEvent({type:P.SET_SCENE,value:s.data});break;case"addCamera":R.dispatchEvent({type:P.ADD_CAMERA,value:s.data});break;case"removeCamera":R.dispatchEvent({type:P.REMOVE_CAMERA,value:s.data});break;case"addGroup":R.dispatchEvent({type:P.ADD_GROUP,value:s.data});break;case"removeGroup":R.dispatchEvent({type:P.REMOVE_GROUP,value:s.data});break;case"addSpline":R.dispatchEvent({type:P.ADD_SPLINE,value:s.data});break;case"addRenderer":R.dispatchEvent({type:P.ADD_RENDERER,value:s.data})}}addRT(e,t){const s=new o.WebGLRenderTarget(32,32,t);s.texture.name=e,this.renderTargets.set(e,s)}resize(e,t){const s=this.dpr;this.renderTargets.forEach(a=>{a.setSize(e*s,t*s)});const n=!(this.renderer?.domElement instanceof OffscreenCanvas);this.renderer?.setSize(e,t,n)}set dpr(e){this.renderer?.setPixelRatio(je(1,2,e))}get dpr(){return this.renderer!==void 0?this.renderer?.getPixelRatio():1}get width(){return this.renderer!==void 0?this.renderer.domElement.width/this.dpr:0}get height(){return this.renderer!==void 0?this.renderer.domElement.height/this.dpr:0}}var fi={exports:{}},at={};/**
19
19
  * @license React
20
20
  * react-jsx-runtime.production.min.js
21
21
  *
@@ -23,7 +23,7 @@
23
23
  *
24
24
  * This source code is licensed under the MIT license found in the
25
25
  * LICENSE file in the root directory of this source tree.
26
- */var Hi;function Gn(){if(Hi)return at;Hi=1;var s=O,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,n=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function a(l,h,c){var u,m={},f=null,g=null;c!==void 0&&(f=""+c),h.key!==void 0&&(f=""+h.key),h.ref!==void 0&&(g=h.ref);for(u in h)i.call(h,u)&&!r.hasOwnProperty(u)&&(m[u]=h[u]);if(l&&l.defaultProps)for(u in h=l.defaultProps,h)m[u]===void 0&&(m[u]=h[u]);return{$$typeof:e,type:l,key:f,ref:g,props:m,_owner:n.current}}return at.Fragment=t,at.jsx=a,at.jsxs=a,at}var rt={};/**
26
+ */var Vi;function Gn(){if(Vi)return at;Vi=1;var i=O,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,n=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function r(l,h,c){var u,m={},f=null,g=null;c!==void 0&&(f=""+c),h.key!==void 0&&(f=""+h.key),h.ref!==void 0&&(g=h.ref);for(u in h)s.call(h,u)&&!a.hasOwnProperty(u)&&(m[u]=h[u]);if(l&&l.defaultProps)for(u in h=l.defaultProps,h)m[u]===void 0&&(m[u]=h[u]);return{$$typeof:e,type:l,key:f,ref:g,props:m,_owner:n.current}}return at.Fragment=t,at.jsx=r,at.jsxs=r,at}var rt={};/**
27
27
  * @license React
28
28
  * react-jsx-runtime.development.js
29
29
  *
@@ -31,25 +31,25 @@
31
31
  *
32
32
  * This source code is licensed under the MIT license found in the
33
33
  * LICENSE file in the root directory of this source tree.
34
- */var Vi;function Zn(){return Vi||(Vi=1,process.env.NODE_ENV!=="production"&&function(){var s=O,e=Symbol.for("react.element"),t=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),l=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),g=Symbol.for("react.offscreen"),x=Symbol.iterator,y="@@iterator";function T(d){if(d===null||typeof d!="object")return null;var b=x&&d[x]||d[y];return typeof b=="function"?b:null}var _=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function C(d){{for(var b=arguments.length,P=new Array(b>1?b-1:0),k=1;k<b;k++)P[k-1]=arguments[k];E("error",d,P)}}function E(d,b,P){{var k=_.ReactDebugCurrentFrame,H=k.getStackAddendum();H!==""&&(b+="%s",P=P.concat([H]));var Z=P.map(function(F){return String(F)});Z.unshift("Warning: "+b),Function.prototype.apply.call(console[d],console,Z)}}var S=!1,w=!1,M=!1,I=!1,U=!1,D;D=Symbol.for("react.module.reference");function B(d){return!!(typeof d=="string"||typeof d=="function"||d===i||d===r||U||d===n||d===c||d===u||I||d===g||S||w||M||typeof d=="object"&&d!==null&&(d.$$typeof===f||d.$$typeof===m||d.$$typeof===a||d.$$typeof===l||d.$$typeof===h||d.$$typeof===D||d.getModuleId!==void 0))}function _e(d,b,P){var k=d.displayName;if(k)return k;var H=b.displayName||b.name||"";return H!==""?P+"("+H+")":P}function pe(d){return d.displayName||"Context"}function ne(d){if(d==null)return null;if(typeof d.tag=="number"&&C("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof d=="function")return d.displayName||d.name||null;if(typeof d=="string")return d;switch(d){case i:return"Fragment";case t:return"Portal";case r:return"Profiler";case n:return"StrictMode";case c:return"Suspense";case u:return"SuspenseList"}if(typeof d=="object")switch(d.$$typeof){case l:var b=d;return pe(b)+".Consumer";case a:var P=d;return pe(P._context)+".Provider";case h:return _e(d,d.render,"ForwardRef");case m:var k=d.displayName||null;return k!==null?k:ne(d.type)||"Memo";case f:{var H=d,Z=H._payload,F=H._init;try{return ne(F(Z))}catch{return null}}}return null}var Q=Object.assign,X=0,Ae,ce,ge,ie,Re,De,Ie;function G(){}G.__reactDisabledLog=!0;function re(){{if(X===0){Ae=console.log,ce=console.info,ge=console.warn,ie=console.error,Re=console.group,De=console.groupCollapsed,Ie=console.groupEnd;var d={configurable:!0,enumerable:!0,value:G,writable:!0};Object.defineProperties(console,{info:d,log:d,warn:d,error:d,group:d,groupCollapsed:d,groupEnd:d})}X++}}function Ee(){{if(X--,X===0){var d={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:Q({},d,{value:Ae}),info:Q({},d,{value:ce}),warn:Q({},d,{value:ge}),error:Q({},d,{value:ie}),group:Q({},d,{value:Re}),groupCollapsed:Q({},d,{value:De}),groupEnd:Q({},d,{value:Ie})})}X<0&&C("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var st=_.ReactCurrentDispatcher,Ye;function St(d,b,P){{if(Ye===void 0)try{throw Error()}catch(H){var k=H.stack.trim().match(/\n( *(at )?)/);Ye=k&&k[1]||""}return`
35
- `+Ye+d}}var Gt=!1,wt;{var Is=typeof WeakMap=="function"?WeakMap:Map;wt=new Is}function wi(d,b){if(!d||Gt)return"";{var P=wt.get(d);if(P!==void 0)return P}var k;Gt=!0;var H=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Z;Z=st.current,st.current=null,re();try{if(b){var F=function(){throw Error()};if(Object.defineProperty(F.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(F,[])}catch(Le){k=Le}Reflect.construct(d,[],F)}else{try{F.call()}catch(Le){k=Le}d.call(F.prototype)}}else{try{throw Error()}catch(Le){k=Le}d()}}catch(Le){if(Le&&k&&typeof Le.stack=="string"){for(var N=Le.stack.split(`
34
+ */var Bi;function Zn(){return Bi||(Bi=1,process.env.NODE_ENV!=="production"&&function(){var i=O,e=Symbol.for("react.element"),t=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),r=Symbol.for("react.provider"),l=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),g=Symbol.for("react.offscreen"),x=Symbol.iterator,y="@@iterator";function T(d){if(d===null||typeof d!="object")return null;var b=x&&d[x]||d[y];return typeof b=="function"?b:null}var _=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function C(d){{for(var b=arguments.length,A=new Array(b>1?b-1:0),k=1;k<b;k++)A[k-1]=arguments[k];E("error",d,A)}}function E(d,b,A){{var k=_.ReactDebugCurrentFrame,H=k.getStackAddendum();H!==""&&(b+="%s",A=A.concat([H]));var Z=A.map(function(F){return String(F)});Z.unshift("Warning: "+b),Function.prototype.apply.call(console[d],console,Z)}}var S=!1,w=!1,M=!1,I=!1,U=!1,D;D=Symbol.for("react.module.reference");function B(d){return!!(typeof d=="string"||typeof d=="function"||d===s||d===a||U||d===n||d===c||d===u||I||d===g||S||w||M||typeof d=="object"&&d!==null&&(d.$$typeof===f||d.$$typeof===m||d.$$typeof===r||d.$$typeof===l||d.$$typeof===h||d.$$typeof===D||d.getModuleId!==void 0))}function _e(d,b,A){var k=d.displayName;if(k)return k;var H=b.displayName||b.name||"";return H!==""?A+"("+H+")":A}function pe(d){return d.displayName||"Context"}function ne(d){if(d==null)return null;if(typeof d.tag=="number"&&C("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof d=="function")return d.displayName||d.name||null;if(typeof d=="string")return d;switch(d){case s:return"Fragment";case t:return"Portal";case a:return"Profiler";case n:return"StrictMode";case c:return"Suspense";case u:return"SuspenseList"}if(typeof d=="object")switch(d.$$typeof){case l:var b=d;return pe(b)+".Consumer";case r:var A=d;return pe(A._context)+".Provider";case h:return _e(d,d.render,"ForwardRef");case m:var k=d.displayName||null;return k!==null?k:ne(d.type)||"Memo";case f:{var H=d,Z=H._payload,F=H._init;try{return ne(F(Z))}catch{return null}}}return null}var Q=Object.assign,X=0,Pe,ce,ge,ie,Re,De,Ie;function G(){}G.__reactDisabledLog=!0;function re(){{if(X===0){Pe=console.log,ce=console.info,ge=console.warn,ie=console.error,Re=console.group,De=console.groupCollapsed,Ie=console.groupEnd;var d={configurable:!0,enumerable:!0,value:G,writable:!0};Object.defineProperties(console,{info:d,log:d,warn:d,error:d,group:d,groupCollapsed:d,groupEnd:d})}X++}}function Ee(){{if(X--,X===0){var d={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:Q({},d,{value:Pe}),info:Q({},d,{value:ce}),warn:Q({},d,{value:ge}),error:Q({},d,{value:ie}),group:Q({},d,{value:Re}),groupCollapsed:Q({},d,{value:De}),groupEnd:Q({},d,{value:Ie})})}X<0&&C("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var st=_.ReactCurrentDispatcher,Ye;function St(d,b,A){{if(Ye===void 0)try{throw Error()}catch(H){var k=H.stack.trim().match(/\n( *(at )?)/);Ye=k&&k[1]||""}return`
35
+ `+Ye+d}}var Gt=!1,wt;{var Ls=typeof WeakMap=="function"?WeakMap:Map;wt=new Ls}function xi(d,b){if(!d||Gt)return"";{var A=wt.get(d);if(A!==void 0)return A}var k;Gt=!0;var H=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Z;Z=st.current,st.current=null,re();try{if(b){var F=function(){throw Error()};if(Object.defineProperty(F.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(F,[])}catch(Le){k=Le}Reflect.construct(d,[],F)}else{try{F.call()}catch(Le){k=Le}d.call(F.prototype)}}else{try{throw Error()}catch(Le){k=Le}d()}}catch(Le){if(Le&&k&&typeof Le.stack=="string"){for(var N=Le.stack.split(`
36
36
  `),ue=k.stack.split(`
37
37
  `),ee=N.length-1,se=ue.length-1;ee>=1&&se>=0&&N[ee]!==ue[se];)se--;for(;ee>=1&&se>=0;ee--,se--)if(N[ee]!==ue[se]){if(ee!==1||se!==1)do if(ee--,se--,se<0||N[ee]!==ue[se]){var ve=`
38
- `+N[ee].replace(" at new "," at ");return d.displayName&&ve.includes("<anonymous>")&&(ve=ve.replace("<anonymous>",d.displayName)),typeof d=="function"&&wt.set(d,ve),ve}while(ee>=1&&se>=0);break}}}finally{Gt=!1,st.current=Z,Ee(),Error.prepareStackTrace=H}var Ze=d?d.displayName||d.name:"",ji=Ze?St(Ze):"";return typeof d=="function"&&wt.set(d,ji),ji}function Ls(d,b,P){return wi(d,!1)}function ks(d){var b=d.prototype;return!!(b&&b.isReactComponent)}function xt(d,b,P){if(d==null)return"";if(typeof d=="function")return wi(d,ks(d));if(typeof d=="string")return St(d);switch(d){case c:return St("Suspense");case u:return St("SuspenseList")}if(typeof d=="object")switch(d.$$typeof){case h:return Ls(d.render);case m:return xt(d.type,b,P);case f:{var k=d,H=k._payload,Z=k._init;try{return xt(Z(H),b,P)}catch{}}}return""}var Ot=Object.prototype.hasOwnProperty,xi={},Oi=_.ReactDebugCurrentFrame;function Tt(d){if(d){var b=d._owner,P=xt(d.type,d._source,b?b.type:null);Oi.setExtraStackFrame(P)}else Oi.setExtraStackFrame(null)}function Us(d,b,P,k,H){{var Z=Function.call.bind(Ot);for(var F in d)if(Z(d,F)){var N=void 0;try{if(typeof d[F]!="function"){var ue=Error((k||"React class")+": "+P+" type `"+F+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof d[F]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw ue.name="Invariant Violation",ue}N=d[F](b,F,k,P,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(ee){N=ee}N&&!(N instanceof Error)&&(Tt(H),C("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",k||"React class",P,F,typeof N),Tt(null)),N instanceof Error&&!(N.message in xi)&&(xi[N.message]=!0,Tt(H),C("Failed %s type: %s",P,N.message),Tt(null))}}}var js=Array.isArray;function Zt(d){return js(d)}function Ns(d){{var b=typeof Symbol=="function"&&Symbol.toStringTag,P=b&&d[Symbol.toStringTag]||d.constructor.name||"Object";return P}}function Fs(d){try{return Ti(d),!1}catch{return!0}}function Ti(d){return""+d}function Mi(d){if(Fs(d))return C("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Ns(d)),Ti(d)}var nt=_.ReactCurrentOwner,zs={key:!0,ref:!0,__self:!0,__source:!0},Pi,Ai,Wt;Wt={};function Hs(d){if(Ot.call(d,"ref")){var b=Object.getOwnPropertyDescriptor(d,"ref").get;if(b&&b.isReactWarning)return!1}return d.ref!==void 0}function Vs(d){if(Ot.call(d,"key")){var b=Object.getOwnPropertyDescriptor(d,"key").get;if(b&&b.isReactWarning)return!1}return d.key!==void 0}function Bs(d,b){if(typeof d.ref=="string"&&nt.current&&b&&nt.current.stateNode!==b){var P=ne(nt.current.type);Wt[P]||(C('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',ne(nt.current.type),d.ref),Wt[P]=!0)}}function Ys(d,b){{var P=function(){Pi||(Pi=!0,C("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",b))};P.isReactWarning=!0,Object.defineProperty(d,"key",{get:P,configurable:!0})}}function Gs(d,b){{var P=function(){Ai||(Ai=!0,C("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",b))};P.isReactWarning=!0,Object.defineProperty(d,"ref",{get:P,configurable:!0})}}var Zs=function(d,b,P,k,H,Z,F){var N={$$typeof:e,type:d,key:b,ref:P,props:F,_owner:Z};return N._store={},Object.defineProperty(N._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(N,"_self",{configurable:!1,enumerable:!1,writable:!1,value:k}),Object.defineProperty(N,"_source",{configurable:!1,enumerable:!1,writable:!1,value:H}),Object.freeze&&(Object.freeze(N.props),Object.freeze(N)),N};function Ws(d,b,P,k,H){{var Z,F={},N=null,ue=null;P!==void 0&&(Mi(P),N=""+P),Vs(b)&&(Mi(b.key),N=""+b.key),Hs(b)&&(ue=b.ref,Bs(b,H));for(Z in b)Ot.call(b,Z)&&!zs.hasOwnProperty(Z)&&(F[Z]=b[Z]);if(d&&d.defaultProps){var ee=d.defaultProps;for(Z in ee)F[Z]===void 0&&(F[Z]=ee[Z])}if(N||ue){var se=typeof d=="function"?d.displayName||d.name||"Unknown":d;N&&Ys(F,se),ue&&Gs(F,se)}return Zs(d,N,ue,H,k,nt.current,F)}}var Xt=_.ReactCurrentOwner,Ri=_.ReactDebugCurrentFrame;function Ge(d){if(d){var b=d._owner,P=xt(d.type,d._source,b?b.type:null);Ri.setExtraStackFrame(P)}else Ri.setExtraStackFrame(null)}var qt;qt=!1;function Qt(d){return typeof d=="object"&&d!==null&&d.$$typeof===e}function Di(){{if(Xt.current){var d=ne(Xt.current.type);if(d)return`
38
+ `+N[ee].replace(" at new "," at ");return d.displayName&&ve.includes("<anonymous>")&&(ve=ve.replace("<anonymous>",d.displayName)),typeof d=="function"&&wt.set(d,ve),ve}while(ee>=1&&se>=0);break}}}finally{Gt=!1,st.current=Z,Ee(),Error.prepareStackTrace=H}var Ze=d?d.displayName||d.name:"",Ni=Ze?St(Ze):"";return typeof d=="function"&&wt.set(d,Ni),Ni}function ks(d,b,A){return xi(d,!1)}function Us(d){var b=d.prototype;return!!(b&&b.isReactComponent)}function xt(d,b,A){if(d==null)return"";if(typeof d=="function")return xi(d,Us(d));if(typeof d=="string")return St(d);switch(d){case c:return St("Suspense");case u:return St("SuspenseList")}if(typeof d=="object")switch(d.$$typeof){case h:return ks(d.render);case m:return xt(d.type,b,A);case f:{var k=d,H=k._payload,Z=k._init;try{return xt(Z(H),b,A)}catch{}}}return""}var Ot=Object.prototype.hasOwnProperty,Oi={},Ti=_.ReactDebugCurrentFrame;function Tt(d){if(d){var b=d._owner,A=xt(d.type,d._source,b?b.type:null);Ti.setExtraStackFrame(A)}else Ti.setExtraStackFrame(null)}function js(d,b,A,k,H){{var Z=Function.call.bind(Ot);for(var F in d)if(Z(d,F)){var N=void 0;try{if(typeof d[F]!="function"){var ue=Error((k||"React class")+": "+A+" type `"+F+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof d[F]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw ue.name="Invariant Violation",ue}N=d[F](b,F,k,A,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(ee){N=ee}N&&!(N instanceof Error)&&(Tt(H),C("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",k||"React class",A,F,typeof N),Tt(null)),N instanceof Error&&!(N.message in Oi)&&(Oi[N.message]=!0,Tt(H),C("Failed %s type: %s",A,N.message),Tt(null))}}}var Ns=Array.isArray;function Zt(d){return Ns(d)}function Fs(d){{var b=typeof Symbol=="function"&&Symbol.toStringTag,A=b&&d[Symbol.toStringTag]||d.constructor.name||"Object";return A}}function zs(d){try{return Mi(d),!1}catch{return!0}}function Mi(d){return""+d}function Ai(d){if(zs(d))return C("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Fs(d)),Mi(d)}var nt=_.ReactCurrentOwner,Hs={key:!0,ref:!0,__self:!0,__source:!0},Pi,Ri,Wt;Wt={};function Vs(d){if(Ot.call(d,"ref")){var b=Object.getOwnPropertyDescriptor(d,"ref").get;if(b&&b.isReactWarning)return!1}return d.ref!==void 0}function Bs(d){if(Ot.call(d,"key")){var b=Object.getOwnPropertyDescriptor(d,"key").get;if(b&&b.isReactWarning)return!1}return d.key!==void 0}function Ys(d,b){if(typeof d.ref=="string"&&nt.current&&b&&nt.current.stateNode!==b){var A=ne(nt.current.type);Wt[A]||(C('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',ne(nt.current.type),d.ref),Wt[A]=!0)}}function Gs(d,b){{var A=function(){Pi||(Pi=!0,C("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",b))};A.isReactWarning=!0,Object.defineProperty(d,"key",{get:A,configurable:!0})}}function Zs(d,b){{var A=function(){Ri||(Ri=!0,C("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",b))};A.isReactWarning=!0,Object.defineProperty(d,"ref",{get:A,configurable:!0})}}var Ws=function(d,b,A,k,H,Z,F){var N={$$typeof:e,type:d,key:b,ref:A,props:F,_owner:Z};return N._store={},Object.defineProperty(N._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(N,"_self",{configurable:!1,enumerable:!1,writable:!1,value:k}),Object.defineProperty(N,"_source",{configurable:!1,enumerable:!1,writable:!1,value:H}),Object.freeze&&(Object.freeze(N.props),Object.freeze(N)),N};function Xs(d,b,A,k,H){{var Z,F={},N=null,ue=null;A!==void 0&&(Ai(A),N=""+A),Bs(b)&&(Ai(b.key),N=""+b.key),Vs(b)&&(ue=b.ref,Ys(b,H));for(Z in b)Ot.call(b,Z)&&!Hs.hasOwnProperty(Z)&&(F[Z]=b[Z]);if(d&&d.defaultProps){var ee=d.defaultProps;for(Z in ee)F[Z]===void 0&&(F[Z]=ee[Z])}if(N||ue){var se=typeof d=="function"?d.displayName||d.name||"Unknown":d;N&&Gs(F,se),ue&&Zs(F,se)}return Ws(d,N,ue,H,k,nt.current,F)}}var Xt=_.ReactCurrentOwner,Di=_.ReactDebugCurrentFrame;function Ge(d){if(d){var b=d._owner,A=xt(d.type,d._source,b?b.type:null);Di.setExtraStackFrame(A)}else Di.setExtraStackFrame(null)}var qt;qt=!1;function Qt(d){return typeof d=="object"&&d!==null&&d.$$typeof===e}function Ii(){{if(Xt.current){var d=ne(Xt.current.type);if(d)return`
39
39
 
40
- Check the render method of \``+d+"`."}return""}}function Xs(d){{if(d!==void 0){var b=d.fileName.replace(/^.*[\\\/]/,""),P=d.lineNumber;return`
40
+ Check the render method of \``+d+"`."}return""}}function qs(d){{if(d!==void 0){var b=d.fileName.replace(/^.*[\\\/]/,""),A=d.lineNumber;return`
41
41
 
42
- Check your code at `+b+":"+P+"."}return""}}var Ii={};function qs(d){{var b=Di();if(!b){var P=typeof d=="string"?d:d.displayName||d.name;P&&(b=`
42
+ Check your code at `+b+":"+A+"."}return""}}var Li={};function Qs(d){{var b=Ii();if(!b){var A=typeof d=="string"?d:d.displayName||d.name;A&&(b=`
43
43
 
44
- Check the top-level render call using <`+P+">.")}return b}}function Li(d,b){{if(!d._store||d._store.validated||d.key!=null)return;d._store.validated=!0;var P=qs(b);if(Ii[P])return;Ii[P]=!0;var k="";d&&d._owner&&d._owner!==Xt.current&&(k=" It was passed a child from "+ne(d._owner.type)+"."),Ge(d),C('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',P,k),Ge(null)}}function ki(d,b){{if(typeof d!="object")return;if(Zt(d))for(var P=0;P<d.length;P++){var k=d[P];Qt(k)&&Li(k,b)}else if(Qt(d))d._store&&(d._store.validated=!0);else if(d){var H=T(d);if(typeof H=="function"&&H!==d.entries)for(var Z=H.call(d),F;!(F=Z.next()).done;)Qt(F.value)&&Li(F.value,b)}}}function Qs(d){{var b=d.type;if(b==null||typeof b=="string")return;var P;if(typeof b=="function")P=b.propTypes;else if(typeof b=="object"&&(b.$$typeof===h||b.$$typeof===m))P=b.propTypes;else return;if(P){var k=ne(b);Us(P,d.props,"prop",k,d)}else if(b.PropTypes!==void 0&&!qt){qt=!0;var H=ne(b);C("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",H||"Unknown")}typeof b.getDefaultProps=="function"&&!b.getDefaultProps.isReactClassApproved&&C("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Ks(d){{for(var b=Object.keys(d.props),P=0;P<b.length;P++){var k=b[P];if(k!=="children"&&k!=="key"){Ge(d),C("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",k),Ge(null);break}}d.ref!==null&&(Ge(d),C("Invalid attribute `ref` supplied to `React.Fragment`."),Ge(null))}}function Ui(d,b,P,k,H,Z){{var F=B(d);if(!F){var N="";(d===void 0||typeof d=="object"&&d!==null&&Object.keys(d).length===0)&&(N+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var ue=Xs(H);ue?N+=ue:N+=Di();var ee;d===null?ee="null":Zt(d)?ee="array":d!==void 0&&d.$$typeof===e?(ee="<"+(ne(d.type)||"Unknown")+" />",N=" Did you accidentally export a JSX literal instead of a component?"):ee=typeof d,C("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",ee,N)}var se=Ws(d,b,P,H,Z);if(se==null)return se;if(F){var ve=b.children;if(ve!==void 0)if(k)if(Zt(ve)){for(var Ze=0;Ze<ve.length;Ze++)ki(ve[Ze],d);Object.freeze&&Object.freeze(ve)}else C("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else ki(ve,d)}return d===i?Ks(se):Qs(se),se}}function $s(d,b,P){return Ui(d,b,P,!0)}function Js(d,b,P){return Ui(d,b,P,!1)}var en=Js,tn=$s;rt.Fragment=i,rt.jsx=en,rt.jsxs=tn}()),rt}process.env.NODE_ENV==="production"?mi.exports=Gn():mi.exports=Zn();var p=mi.exports;function bi(s){return s.title.search("<")>-1?p.jsx("button",{className:"svg",dangerouslySetInnerHTML:{__html:s.title}}):p.jsx("button",{children:s.title})}const Wn=p.jsxs("svg",{className:"closeIcon",width:"14",height:"14",fill:"none",stroke:"#666666",strokeMiterlimit:"10",children:[p.jsx("circle",{cx:"7",cy:"7",r:"6"}),p.jsx("line",{x1:"4",y1:"4",x2:"10",y2:"10"}),p.jsx("line",{x1:"4",y1:"10",x2:"10",y2:"4"})]}),Xn=p.jsx("svg",{className:"dragIcon",width:"14",height:"14",fill:"#666666",stroke:"none",children:p.jsx("path",{d:`M10.43,4H3.57C3.26,4,3,4.22,3,4.5v1C3,5.78,3.26,6,3.57,6h6.86C10.74,6,11,5.78,11,5.5v-1\r
44
+ Check the top-level render call using <`+A+">.")}return b}}function ki(d,b){{if(!d._store||d._store.validated||d.key!=null)return;d._store.validated=!0;var A=Qs(b);if(Li[A])return;Li[A]=!0;var k="";d&&d._owner&&d._owner!==Xt.current&&(k=" It was passed a child from "+ne(d._owner.type)+"."),Ge(d),C('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',A,k),Ge(null)}}function Ui(d,b){{if(typeof d!="object")return;if(Zt(d))for(var A=0;A<d.length;A++){var k=d[A];Qt(k)&&ki(k,b)}else if(Qt(d))d._store&&(d._store.validated=!0);else if(d){var H=T(d);if(typeof H=="function"&&H!==d.entries)for(var Z=H.call(d),F;!(F=Z.next()).done;)Qt(F.value)&&ki(F.value,b)}}}function Ks(d){{var b=d.type;if(b==null||typeof b=="string")return;var A;if(typeof b=="function")A=b.propTypes;else if(typeof b=="object"&&(b.$$typeof===h||b.$$typeof===m))A=b.propTypes;else return;if(A){var k=ne(b);js(A,d.props,"prop",k,d)}else if(b.PropTypes!==void 0&&!qt){qt=!0;var H=ne(b);C("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",H||"Unknown")}typeof b.getDefaultProps=="function"&&!b.getDefaultProps.isReactClassApproved&&C("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function $s(d){{for(var b=Object.keys(d.props),A=0;A<b.length;A++){var k=b[A];if(k!=="children"&&k!=="key"){Ge(d),C("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",k),Ge(null);break}}d.ref!==null&&(Ge(d),C("Invalid attribute `ref` supplied to `React.Fragment`."),Ge(null))}}function ji(d,b,A,k,H,Z){{var F=B(d);if(!F){var N="";(d===void 0||typeof d=="object"&&d!==null&&Object.keys(d).length===0)&&(N+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var ue=qs(H);ue?N+=ue:N+=Ii();var ee;d===null?ee="null":Zt(d)?ee="array":d!==void 0&&d.$$typeof===e?(ee="<"+(ne(d.type)||"Unknown")+" />",N=" Did you accidentally export a JSX literal instead of a component?"):ee=typeof d,C("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",ee,N)}var se=Xs(d,b,A,H,Z);if(se==null)return se;if(F){var ve=b.children;if(ve!==void 0)if(k)if(Zt(ve)){for(var Ze=0;Ze<ve.length;Ze++)Ui(ve[Ze],d);Object.freeze&&Object.freeze(ve)}else C("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Ui(ve,d)}return d===s?$s(se):Ks(se),se}}function Js(d,b,A){return ji(d,b,A,!0)}function en(d,b,A){return ji(d,b,A,!1)}var tn=en,sn=Js;rt.Fragment=s,rt.jsx=tn,rt.jsxs=sn}()),rt}process.env.NODE_ENV==="production"?fi.exports=Gn():fi.exports=Zn();var p=fi.exports;function Ei(i){return i.title.search("<")>-1?p.jsx("button",{className:"svg",dangerouslySetInnerHTML:{__html:i.title}}):p.jsx("button",{children:i.title})}const Wn=p.jsxs("svg",{className:"closeIcon",width:"14",height:"14",fill:"none",stroke:"#666666",strokeMiterlimit:"10",children:[p.jsx("circle",{cx:"7",cy:"7",r:"6"}),p.jsx("line",{x1:"4",y1:"4",x2:"10",y2:"10"}),p.jsx("line",{x1:"4",y1:"10",x2:"10",y2:"4"})]}),Xn=p.jsx("svg",{className:"dragIcon",width:"14",height:"14",fill:"#666666",stroke:"none",children:p.jsx("path",{d:`M10.43,4H3.57C3.26,4,3,4.22,3,4.5v1C3,5.78,3.26,6,3.57,6h6.86C10.74,6,11,5.78,11,5.5v-1\r
45
45
  C11,4.22,10.74,4,10.43,4z M10.43,8H3.57C3.26,8,3,8.22,3,8.5v1C3,9.78,3.26,10,3.57,10h6.86C10.74,10,11,9.78,11,9.5v-1\r
46
- C11,8.22,10.74,8,10.43,8z`})});function Es(s){return p.jsx(ps.Reorder.Item,{value:s.title,children:p.jsxs("div",{children:[Xn,p.jsx("span",{children:s.title}),p.jsx("button",{className:"closeIcon",onClick:()=>{s.onDelete(s.index)},children:Wn})]})},s.title)}function Ss(s){const[e,t]=O.useState(!1),[i,n]=O.useState(s.options),r=c=>{s.onDragComplete(c),n(c)},a=c=>{const u=[...i];u.splice(c,1),r(u)},l=[];i.forEach((c,u)=>{l.push(p.jsx(Es,{index:u,title:c,onDelete:a},c))});let h="dropdown draggable";return s.subdropdown&&(h+=" subdropdown"),p.jsxs("div",{className:h,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[p.jsx(bi,{title:s.title}),p.jsx(ps.Reorder.Group,{axis:"y",values:i,onReorder:r,style:{visibility:e?"visible":"hidden"},children:l})]})}function ws(s){const[e,t]=O.useState(!1),i=[];s.options.map((r,a)=>{s.onSelect!==void 0&&(r.onSelect=s.onSelect),i.push(p.jsx(xs,{option:r},a))});let n="dropdown";return s.subdropdown&&(n+=" subdropdown"),p.jsxs("div",{className:n,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[p.jsx(bi,{title:s.title}),p.jsx("ul",{style:{visibility:e?"visible":"hidden"},children:i})]})}function xs(s){const{option:e}=s,[t,i]=O.useState("");let n;switch(e.type){case"draggable":n=p.jsx(Ss,{title:e.title,options:e.value,onDragComplete:r=>{e.onDragComplete!==void 0&&e.onDragComplete(r)},subdropdown:!0});break;case"dropdown":n=p.jsx(ws,{title:e.title,options:e.value,onSelect:e.onSelect,subdropdown:!0});break;case"option":n=p.jsx("button",{onClick:()=>{e.onSelect!==void 0&&e.onSelect(e.value),e.selectable&&(t!==e.title?i(e.title):i(""))},children:e.title});break}return p.jsx("li",{className:t===e.title?"selected":"",children:n},fs())}function qn(s,e,t){function i(r){switch(e.forEach(a=>{a.callback(s,a.remote,r)}),r.event){case"custom":R.dispatchEvent({type:A.CUSTOM,value:r.data});break}}function n(r){switch(t.forEach(a=>{a.callback(s,a.remote,r)}),r.event){case"custom":R.dispatchEvent({type:A.CUSTOM,value:r.data});break}}s.listen=r=>{r.target==="editor"?n(r):i(r)}}function Et(s){const[e,t]=O.useState(s.open!==void 0?s.open:!0),i=!e||s.children===void 0,n=()=>{R.dispatchEvent({type:A.REMOVE_SCENE,value:s.scene})};return p.jsxs("div",{className:`accordion ${i?"hide":""}`,children:[p.jsxs("button",{className:"toggle",onClick:()=>{const r=!e;s.onToggle!==void 0&&s.onToggle(r),t(r)},children:[p.jsx("p",{className:`status ${e?"open":""}`,children:"Toggle"}),p.jsx("p",{className:"label",children:bt(s.label)})]}),s.onRefresh?p.jsxs(p.Fragment,{children:[p.jsx("button",{className:"refresh",onClick:s.onRefresh}),p.jsx("button",{className:"remove",onClick:n})]}):null,s.button,p.jsx("div",{className:e?"open":"",children:p.jsx("div",{children:s.children})},Math.random())]})}function Ei(s){const e=O.useRef(null),[t,i]=O.useState(!1),n=s.child!==void 0&&s.child.children.length>0,r=[];return s.child!==void 0&&s.child.children.length>0&&s.child.children.map((a,l)=>{r.push(p.jsx(Ei,{child:a,three:s.three},l))}),O.useEffect(()=>{if(s.child){const a=s.three.getScene(s.child.uuid);if(a!==null){const l=a.getObjectByProperty("uuid",s.child.uuid);l!==void 0&&(e.current.style.opacity=l.visible?"1":"0.25")}}},[t]),p.jsx(p.Fragment,{children:s.child!==void 0&&p.jsxs("div",{className:"childObject",children:[p.jsxs("div",{className:"child",children:[n?p.jsx("button",{className:"status",style:{backgroundPositionX:t?"-14px":"2px"},onClick:()=>{i(!t)}}):null,p.jsx("button",{className:"name",style:{left:n?"20px":"5px"},onClick:()=>{s.child!==void 0&&(s.three.getObject(s.child.uuid),t||i(!0))},children:s.child.name.length>0?`${s.child.name} (${s.child.type})`:`${s.child.type}::${s.child.uuid}`}),p.jsx("button",{className:"visibility",ref:e,onClick:()=>{if(s.child){const a=s.three.getScene(s.child.uuid);if(a!==null){const l=a.getObjectByProperty("uuid",s.child.uuid);if(l!==void 0){const h="visible",c=!l.visible;e.current.style.opacity=c?"1":"0.25",s.three.updateObject(s.child.uuid,h,c),te(l,h,c)}}}}}),p.jsx("div",{className:`icon ${Fn(s.child)}`})]}),p.jsx("div",{className:t?"open":"",children:p.jsx("div",{className:"container",children:r})})]},Math.random())})}function fi(s){const e=[];return s.child?.children.map((t,i)=>{e.push(p.jsx(Ei,{child:t,scene:s.scene,three:s.three},i))}),p.jsx("div",{className:`scene ${s.class!==void 0?s.class:""}`,children:e})}function ft(s){const[e,t]=O.useState(s.defaultValue);return O.useEffect(()=>{let i=!1,n=-1,r=0,a=s.defaultValue,l=!1;const h=g=>{l=g.ctrlKey},c=g=>{i=!0,r=Number(s.input.current?.value),n=g.clientX,document.addEventListener("mouseup",m,!1),document.addEventListener("mousemove",u,!1),document.addEventListener("contextmenu",m,!1)},u=g=>{if(!i)return;const x=s.step!==void 0?s.step:1,y=(g.clientX-n)*x*(l?10:1);a=Number((r+y).toFixed(4)),s.min!==void 0&&(a=Math.max(a,s.min)),s.max!==void 0&&(a=Math.min(a,s.max)),s.onChange!==void 0&&s.onChange(a),t(a)},m=()=>{i=!1,document.removeEventListener("mouseup",m),document.removeEventListener("mousemove",u),document.removeEventListener("contextmenu",m)},f=g=>{const x=Number(g.target.value);s.onChange!==void 0&&s.onChange(x),t(x)};return s.label.current?.addEventListener("mousedown",c,!1),s.sliderRef!==void 0&&s.sliderRef.current?.addEventListener("input",f),document.addEventListener("keydown",h,!1),document.addEventListener("keyup",h,!1),()=>{s.label.current?.removeEventListener("mousedown",c),s.sliderRef!==void 0&&s.sliderRef.current?.removeEventListener("input",f),document.removeEventListener("mouseup",m),document.removeEventListener("mousemove",u),document.removeEventListener("contextmenu",m),document.removeEventListener("keydown",h),document.addEventListener("keyup",h,!1)}},[]),e}function Be(s){const e=O.useRef(null),t=O.useRef(null),[i,n]=O.useState(s.value);return ft({label:s.labelRef,input:e,sliderRef:t,defaultValue:i,min:s.min,max:s.max,step:s.step,onChange:r=>{n(r),s.onChange!==void 0&&s.onChange(s.prop,r)}}),p.jsxs(p.Fragment,{children:[s.type==="number"&&p.jsx("input",{alt:s.alt,className:s.className,ref:e,type:"number",value:i,min:s.min,max:s.max,step:s.step,disabled:s.disabled,onChange:r=>{if(n(r.target.value),r.target.value.length===0)return;const a=Number(r.target.value);isNaN(a)||s.onChange!==void 0&&s.onChange(s.prop,a)}}),s.type==="range"&&p.jsxs(p.Fragment,{children:[p.jsx("input",{type:"text",value:i.toString(),disabled:s.disabled,ref:e,className:"min",onChange:r=>{if(r.target.value.length===0)return;const a=Number(r.target.value);isNaN(a)||s.onChange!==void 0&&s.onChange(s.prop,a)}}),p.jsx("input",{disabled:s.disabled,type:"range",value:i,min:s.min,max:s.max,step:s.step,ref:t,onChange:Ct})]})]})}function Qn(s){const e=O.useRef(null),t=O.useRef(null),i=O.useRef(null),n=O.useRef(null),r=O.useRef(null),a=O.useRef(null),l=O.useRef(null),h=O.useRef(null),c=O.useRef(null),u=O.useRef(null),[m,f]=O.useState(s.value.x),[g,x]=O.useState(s.value.y),[y,T]=O.useState({min:Math.min(s.min,Math.min(s.value.x,s.value.y)),max:Math.max(s.max,Math.max(s.value.x,s.value.y))}),[_,C]=O.useState(!1);ft({label:l,input:e,defaultValue:m,min:y.min,max:y.max,step:.01,onChange:D=>{f(D),s.onChange({target:{value:{x:D,y:g}}})}}),ft({label:h,input:t,defaultValue:g,min:y.min,max:y.max,step:.01,onChange:D=>{x(D),s.onChange({target:{value:{x:m,y:D}}})}}),ft({label:c,input:i,defaultValue:y.min,min:y.min-1,max:y.max+1,step:.01,onChange:D=>{T({min:D,max:y.max})}}),ft({label:u,input:n,defaultValue:y.max,min:y.min-1,max:y.max+1,step:.01,onChange:D=>{T({min:y.min,max:D})}});function E(){_||(window.addEventListener("mousemove",w),window.addEventListener("mouseup",S),C(!0))}function S(){window.removeEventListener("mousemove",w),window.removeEventListener("mouseup",S),C(!1)}function w(D){const B=r.current.getBoundingClientRect(),_e=je(0,99,D.clientX-B.left)/99,pe=1-je(0,99,D.clientY-B.top)/99,ne=Ce(it(y.min,y.max,_e),3),Q=Ce(it(y.min,y.max,pe),3);s.onChange({target:{value:{x:ne,y:Q}}}),f(ne),x(Q)}function M(){const D=Number(i.current.value);T({min:D,max:y.max}),m<D&&f(je(D,y.max,m)),g<D&&x(je(D,y.max,g))}function I(){const D=Number(n.current.value);T({min:y.min,max:D}),m>D&&f(je(y.min,D,m)),g>D&&x(je(y.min,D,g))}O.useEffect(()=>{a.current.style.left=`${Ft(y.min,y.max,m)*100}%`,a.current.style.top=`${(1-Ft(y.min,y.max,g))*100}%`},[y,m,g]);const U=s.step!==void 0?s.step:.01;return p.jsxs("div",{className:"vector2",children:[p.jsxs("div",{className:"fields",children:[p.jsxs("div",{children:[p.jsx("label",{ref:l,children:"X"}),p.jsx("input",{ref:e,type:"number",value:m,min:y.min,max:y.max,step:U,onChange:D=>{if(f(D.target.value),D.target.value.length===0)return;const B=Number(D.target.value);isNaN(B)||(s.onChange({target:{value:{x:B,y:g}}}),B<y.min&&T({min:B,max:y.max}))}})]}),p.jsxs("div",{children:[p.jsx("label",{ref:h,children:"Y"}),p.jsx("input",{ref:t,type:"number",value:g,min:y.min,max:y.max,step:U,onChange:D=>{if(x(D.target.value),D.target.value.length===0)return;const B=Number(D.target.value);isNaN(B)||(s.onChange({target:{value:{x:m,y:B}}}),B>y.max&&T({min:y.min,max:B}))}})]}),p.jsxs("div",{children:[p.jsx("label",{ref:c,children:"Min"}),p.jsx("input",{ref:i,type:"number",value:y.min,step:U,onChange:M})]}),p.jsxs("div",{children:[p.jsx("label",{ref:u,children:"Max"}),p.jsx("input",{ref:n,type:"number",value:y.max,step:U,onChange:I})]})]}),p.jsxs("div",{className:"input",ref:r,onMouseDown:E,onMouseUp:S,children:[p.jsx("div",{className:"x"}),p.jsx("div",{className:"y"}),p.jsx("div",{className:"pt",ref:a})]})]})}const Kn=Math.PI/180,$n=180/Math.PI;function qe(s,e,t,i,n){return i+(s-e)*(n-i)/(t-e)}function Qe(s,e,t){return(1-t)*s+t*e}function gi(s){return s*Kn}function Jn(s){return s*$n}function Bi(s){const e=s.value.x!==void 0&&s.value.y!==void 0&&s.value.z!==void 0,t=s.value.isEuler!==void 0,i=s.value.elements!==void 0,n=s.step!==void 0?s.step:.01,r=[];if(t){const a=O.useMemo(()=>s.value,[]);["_x","_y","_z"].forEach(h=>{const c=O.useRef(null);r.push(p.jsxs("div",{children:[p.jsx("label",{ref:c,children:h.substring(1).toUpperCase()}),p.jsx(Be,{value:Jn(a[h]),type:"number",prop:h,step:.1,labelRef:c,onChange:(u,m)=>{a[u]=gi(m),s.onChange({target:{value:a}})}})]},h))})}else if(e){const a=O.useMemo(()=>s.value,[]),l=(c,u)=>{a[c]=u,s.onChange({target:{value:a}})};["x","y","z"].forEach(c=>{const u=O.useRef(null);r.push(p.jsxs("div",{children:[p.jsx("label",{ref:u,children:c.toUpperCase()}),p.jsx(Be,{value:a[c],type:"number",prop:c,step:n,labelRef:u,onChange:l})]},c))})}else if(i){const a=O.useMemo(()=>s.value,[]),l=(h,c)=>{const u=Number(h);a.elements[u]=c,s.onChange({target:{value:a}})};for(let h=0;h<9;h++){const c=O.useRef(null);r.push(p.jsxs("div",{children:[p.jsx("label",{ref:c,children:h+1}),p.jsx(Be,{value:a.elements[h],type:"number",prop:h.toString(),step:n,labelRef:c,onChange:l})]},h.toString()))}}return p.jsx("div",{className:"grid3",children:r},Math.random().toString())}function ea(s){const e=s.value.x!==void 0,t=s.step!==void 0?s.step:.01,i=[];if(e){const n=O.useMemo(()=>s.value,[]),r=(l,h)=>{n[l]=h,s.onChange({target:{value:n}})};["x","y","z","w"].forEach(l=>{const h=O.useRef(null);i.push(p.jsxs("div",{children:[p.jsx("label",{ref:h,children:l.toUpperCase()}),p.jsx(Be,{value:n[l],type:"number",prop:l,step:t,labelRef:h,onChange:r})]},l))})}else{const n=O.useMemo(()=>s.value,[]),r=(a,l)=>{const h=Number(a);n.elements[h]=l,s.onChange({target:{value:n}})};for(let a=0;a<16;a++){const l=O.useRef(null);i.push(p.jsxs("div",{children:[p.jsx("label",{ref:l,children:a+1}),p.jsx(Be,{value:n.elements[a],type:"number",prop:a.toString(),step:t,labelRef:l,onChange:r})]},a.toString()))}}return p.jsx("div",{className:"grid4",children:i})}function ta(s){return!(s==="defaultAttributeValues"||s==="forceSinglePass"||s==="linecap"||s==="linejoin"||s==="linewidth"||s==="normalMapType"||s==="precision"||s==="shadowSide"||s==="uniformsGroups"||s==="uniformsNeedUpdate"||s==="userData"||s==="version"||s==="wireframeLinecap"||s==="wireframeLinejoin"||s==="wireframeLinewidth"||s.slice(0,4)==="clip"||s.slice(0,7)==="polygon"||s.slice(0,7)==="stencil"||s.slice(0,2)==="is")}function ia(s){switch(s){case"Alpha Map":return"alphaMap";case"Anisotropy Map":return"anisotropyMap";case"AO Map":return"aoMap";case"Bump Map":return"bumpMap";case"Clearcoat Map":return"clearcoatMap";case"Clearcoat Normal Map":return"clearcoatNormalMap";case"Clearcoat Roughness Map":return"clearcoatRoughnessMap";case"Displacement Map":return"displacementMap";case"Emissive Map":return"emissiveMap";case"Gradient Map":return"gradientMap";case"Iridescence Map":return"iridescenceMap";case"Iridescence Thickness Map":return"iridescenceThicknessMap";case"Map":return"map";case"Matcap":return"matcap";case"Normal Map":return"normalMap";case"Roughness Map":return"roughnessMap";case"Sheen Color Map":return"sheenColorMap";case"Sheen Roughness Map":return"sheenRoughnessMap";case"Specular Color Map":return"specularColorMap";case"Specular Map Intensity":return"specularIntensityMap";case"Thickness Map":return"thicknessMap";case"Transmission Map":return"transmissionMap"}return s}function Bt(s){switch(s){case"alphaHash":return"Alpha Hash";case"alphaMap":return"Alpha Map";case"alphaToCoverage":return"Alpha To Coverage";case"anisotropy":return"Anisotropy";case"anisotropyMap":return"Anisotropy Map";case"anisotropyRotation":return"Anisotropy Rotation";case"aoMap":return"AO Map";case"aoMapIntensity":return"AO Map Intensity";case"attenuationColor":return"Attenuation Color";case"attenuationDistance":return"Attenuation Distance";case"blendAlpha":return"Blend Alpha";case"blendColor":return"Blend Color";case"blendDst":return"Blend Dst";case"blendDstAlpha":return"Blend Dst Alha";case"blendEquation":return"Blend Equation";case"blendEquationAlpha":return"Blend Equation Alpha";case"blending":return"Blending";case"blendSrc":return"Blend Src";case"blendSrcAlpha":return"Blend Src Alpha";case"bumpMap":return"Bump Map";case"bumpScale":return"Bump Scale";case"clearcoat":return"Clearcoat";case"clearcoatMap":return"Clearcoat Map";case"clearcoatNormalMap":return"Clearcoat Normal Map";case"clearcoatNormalScale":return"Clearcoat Normal Scale";case"clearcoatRoughness":return"Clearcoat Roughness";case"clearcoatRoughnessMap":return"Clearcoat Roughness Map";case"color":return"Color";case"colorWrite":return"Color Write";case"defines":return"Defines";case"depthFunc":return"Depth Func";case"depthTest":return"Depth Test";case"depthWrite":return"Depth Write";case"dispersion":return"Dispersion";case"displacementBias":return"Displacement Bias";case"displacementMap":return"Displacement Map";case"displacementScale":return"Displacement Scale";case"dithering":return"Dithering";case"emissive":return"Emissive";case"emissiveMap":return"Emissive Map";case"emissiveIntensity":return"Emissive Intensity";case"envMap":return"Environment Map";case"envMapIntensity":return"Environment Map Intensity";case"envMapRotation":return"Environment Map Rotation";case"extensions":return"Extensions";case"flatShading":return"Flat Shading";case"fragmentShader":return"Fragment Shader";case"fog":return"Fog";case"glslVersion":return"GLSL Version";case"gradientMap":return"Gradient Map";case"ior":return"IOR";case"iridescence":return"Iridescence";case"iridescenceIOR":return"Iridescence IOR";case"iridescenceMap":return"Iridescence Map";case"iridescenceThicknessMap":return"Iridescence Thickness Map";case"iridescenceThicknessRange":return"Iridescence Thickness Range";case"lights":return"Lights";case"lightMap":return"Light Map";case"lightMapIntensity":return"Light Map Intensity";case"map":return"Map";case"matcap":return"Matcap";case"metalness":return"Metalness";case"metalnessMap":return"Metalness Map";case"name":return"Name";case"normalMap":return"Normal Map";case"normalScale":return"Normal Scale";case"premultipliedAlpha":return"Premultiplied Alpha";case"opacity":return"Opacity";case"reflectivity":return"Reflectivity";case"refractionRatio":return"Refraction Ratio";case"roughness":return"Roughness";case"roughnessMap":return"Roughness Map";case"sheen":return"Sheen";case"sheenColor":return"Sheen Color";case"sheenColorMap":return"Sheen Color Map";case"sheenRoughness":return"Sheen Roughness";case"sheenRoughnessMap":return"Sheen Roughness Map";case"shininess":return"Shininess";case"side":return"Side";case"size":return"Size";case"sizeAttenuation":return"Size Attenuation";case"specular":return"Specular";case"specularColor":return"Specular Color";case"specularColorMap":return"Specular Color Map";case"specularIntensity":return"Specular Intensity";case"specularIntensityMap":return"Specular Map Intensity";case"thickness":return"Thickness";case"thicknessMap":return"Thickness Map";case"toneMapped":return"Tone Mapped";case"transmission":return"Transmission";case"transmissionMap":return"Transmission Map";case"transparent":return"Transparent";case"type":return"Type";case"uuid":return"UUID";case"uniforms":return"Uniforms";case"vertexColors":return"Vertex Colors";case"vertexShader":return"Vertex Shader";case"visible":return"Visible";case"wireframe":return"Wireframe"}return s}function Os(s){const e=s.toLowerCase();return e.search("intensity")>-1||e==="anisotropyrotation"||e==="blendalpha"||e==="bumpscale"||e==="clearcoatroughness"||e==="displacementbias"||e==="displacementscale"||e==="metalness"||e==="opacity"||e==="reflectivity"||e==="refractionratio"||e==="roughness"||e==="sheenroughness"}function sa(){const s=document.createElement("input");return s.type="file",new Promise((e,t)=>{s.addEventListener("change",function(){if(s.files===null)t();else{const i=s.files[0],n=new FileReader;n.onload=function(r){e(r.target.result)},n.readAsDataURL(i)}}),s.click()})}const na=[{title:"Front",value:o.FrontSide},{title:"Back",value:o.BackSide},{title:"Double",value:o.DoubleSide}],aa=[{title:"No Blending",value:o.NoBlending},{title:"Normal",value:o.NormalBlending},{title:"Additive",value:o.AdditiveBlending},{title:"Subtractive",value:o.SubtractiveBlending},{title:"Multiply",value:o.MultiplyBlending},{title:"Custom",value:o.CustomBlending}],ra=[{title:"Add",value:o.AddEquation},{title:"Subtract",value:o.SubtractEquation},{title:"Reverse Subtract",value:o.ReverseSubtractEquation},{title:"Min",value:o.MinEquation},{title:"Max",value:o.MaxEquation}],oa=[{title:"Zero",value:o.ZeroFactor},{title:"One",value:o.OneFactor},{title:"Src Color",value:o.SrcColorFactor},{title:"One Minus Src Color",value:o.OneMinusSrcColorFactor},{title:"Src Alpha",value:o.SrcAlphaFactor},{title:"One Minus Src Alpha",value:o.OneMinusSrcAlphaFactor},{title:"Dst Alpha",value:o.DstAlphaFactor},{title:"One Minus Dst Alpha",value:o.OneMinusDstAlphaFactor},{title:"Dst Color",value:o.DstColorFactor},{title:"One Minus Dst Color",value:o.OneMinusDstColorFactor},{title:"Src Alpha Saturate",value:o.SrcAlphaSaturateFactor},{title:"Constant Color",value:o.ConstantColorFactor},{title:"One Minus Constant Color",value:o.OneMinusConstantColorFactor},{title:"Constant Alpha",value:o.ConstantAlphaFactor},{title:"One Minus Constant Alpha",value:o.OneMinusConstantAlphaFactor}],la=[{title:"Zero",value:o.ZeroFactor},{title:"One",value:o.OneFactor},{title:"Src Color",value:o.SrcColorFactor},{title:"One Minus Src Color",value:o.OneMinusSrcColorFactor},{title:"Src Alpha",value:o.SrcAlphaFactor},{title:"One Minus Src Alpha",value:o.OneMinusSrcAlphaFactor},{title:"Dst Alpha",value:o.DstAlphaFactor},{title:"One Minus Dst Alpha",value:o.OneMinusDstAlphaFactor},{title:"Dst Color",value:o.DstColorFactor},{title:"One Minus Dst Color",value:o.OneMinusDstColorFactor},{title:"Constant Color",value:o.ConstantColorFactor},{title:"One Minus Constant Color",value:o.OneMinusConstantColorFactor},{title:"Constant Alpha",value:o.ConstantAlphaFactor},{title:"One Minus Constant Alpha",value:o.OneMinusConstantAlphaFactor}];function ot(s,e){s.needsUpdate=!0,s.type="option",s.options=e}function ca(s,e,t,i){return{type:"boolean",title:Bt(s),prop:s,value:e,needsUpdate:!0,onChange:(n,r)=>{i.updateObject(t.uuid,`material.${s}`,r),i.updateObject(t.uuid,"material.needsUpdate",!0);const a=i.getScene(t.uuid);if(a!==null){const l=a.getObjectByProperty("uuid",t.uuid);te(l,`material.${s}`,r)}}}}function ha(s,e,t,i){const n={type:"number",title:Bt(s),prop:s,value:e,min:void 0,max:void 0,step:.01,needsUpdate:!0,onChange:(r,a)=>{i.updateObject(t.uuid,`material.${s}`,a),i.updateObject(t.uuid,"material.needsUpdate",!0);const l=i.getScene(t.uuid);if(l!==null){const h=l.getObjectByProperty("uuid",t.uuid);te(h,`material.${s}`,a)}}};switch(s){case"blending":ot(n,aa);break;case"blendDst":ot(n,la);break;case"blendEquation":ot(n,ra);break;case"blendSrc":ot(n,oa);break;case"side":ot(n,na);break}return Os(s)&&(n.value=Number(e),n.type="range",n.min=Math.min(0,n.value),n.max=Math.max(1,n.value),n.step=.01),n}function da(s,e,t,i){const n={type:"string",title:Bt(s),prop:s,value:e,needsUpdate:!0,onChange:(a,l)=>{i.updateObject(t.uuid,`material.${s}`,l),i.updateObject(t.uuid,"material.needsUpdate",!0);const h=i.getScene(t.uuid);if(h!==null){const c=h.getObjectByProperty("uuid",t.uuid);te(c,`material.${s}`,l)}},onKeyDown:a=>{}};return(s==="vertexShader"||s==="fragmentShader")&&(n.disabled=!1,n.latest=n.value,n.onChange=(a,l)=>{n.latest=l,i.updateObject(t.uuid,`material.${s}`,l);const h=i.getScene(t.uuid);if(h!==null){const c=h.getObjectByProperty("uuid",t.uuid);te(c,`material.${s}`,l)}},n.onKeyDown=a=>{if(a.key==="Enter"&&(a.altKey||a.metaKey)){i.updateObject(t.uuid,"material.needsUpdate",!0);const l=i.getScene(t.uuid);if(l!==null){const h=l.getObjectByProperty("uuid",t.uuid);te(h,"material.needsUpdate",!0)}}}),n}function ua(s){return s.x!==void 0&&s.y!==void 0&&s.z===void 0}function pa(s){return s.x!==void 0&&s.y!==void 0&&s.z!==void 0&&s.w===void 0}function ma(s){return s.x!==void 0&&s.y!==void 0&&s.z!==void 0&&s.w!==void 0}function _i(s){s.sort((e,t)=>e.title<t.title?-1:e.title>t.title?1:0)}function gt(s,e,t,i,n="",r=!1){const a=Bt(s).split(".")[0].replaceAll("[","").replaceAll("]",""),l=n.length>0?`${n}.${s}`:s,h=typeof e;if(h==="boolean"||h==="string")return{title:a,prop:l,type:h,value:e,disabled:r,onChange:(c,u)=>{i.updateObject(t.uuid,`material.${l}`,u);const m=i.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);te(f,`material.${l}`,u)}}};if(h==="number"){const c={title:a,prop:l,type:"number",value:e,step:.01,disabled:r,onChange:(u,m)=>{i.updateObject(t.uuid,`material.${l}`,m);const f=i.getScene(t.uuid);if(f!==null){const g=f.getObjectByProperty("uuid",t.uuid);te(g,`material.${l}`,m)}}};return Os(a)&&(c.type="range",c.min=0,c.max=1),c}else{if(e.isColor)return{title:a,prop:l,type:"color",value:e,disabled:r,onChange:(c,u)=>{const m=new o.Color(u);i.updateObject(t.uuid,`material.${l}`,m);const f=i.getScene(t.uuid);if(f!==null){const g=f.getObjectByProperty("uuid",t.uuid);te(g,`material.${l}`,m)}}};if(Array.isArray(e)){const c=[];for(const u in e){const m=e[u],f=`[${u.toString()}]`;if(m.value!==void 0){const g=gt(`${f}.value`,m.value,t,i,l,r);g!==void 0&&c.push(g)}else{const g=gt(f,m,t,i,l,r);g!==void 0&&c.push(g)}}if(c.length>0)return _i(c),{title:a,items:c}}else{if(ua(e))return{title:a,prop:l,type:"vector2",value:e,disabled:r,onChange:(c,u)=>{i.updateObject(t.uuid,`material.${l}`,u);const m=i.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);te(f,`material.${l}`,u)}}};if(pa(e))return{title:a,prop:l,type:"grid3",value:e,disabled:r,onChange:(c,u)=>{i.updateObject(t.uuid,`material.${l}`,u);const m=i.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);te(f,`material.${l}`,u)}}};if(ma(e))return{title:a,prop:l,type:"grid4",value:e,disabled:r,onChange:(c,u)=>{i.updateObject(t.uuid,`material.${l}`,u);const m=i.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);te(f,`material.${l}`,u)}}};if(e.isEuler)return{title:a,prop:l,type:"euler",value:e,disabled:r,onChange:(c,u)=>{i.updateObject(t.uuid,`material.${l}`,u);const m=i.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);te(f,`material.${l}`,u)}}};if(e.src!==void 0)return{title:a,type:"image",value:e,disabled:r,onChange:(c,u)=>{const m=ia(s),f=n.length>0?`${n}.${m}`:m;i.createTexture(t.uuid,`material.${f}`,u);const g=i.getScene(t.uuid);if(g!==null){const x=g.getObjectByProperty("uuid",t.uuid);if(x!==void 0){const y=T=>{const _=x.material,C=f.split(".");switch(C.length){case 1:_[C[0]]=T;break;case 2:_[C[0]][C[1]]=T;break;case 3:_[C[0]][C[1]][C[2]]=T;break;case 4:_[C[0]][C[1]][C[2]][C[3]]=T;break;case 5:_[C[0]][C[1]][C[2]][C[3]][C[4]]=T;break}_.needsUpdate=!0};u.src.length>0?bs(u.src).then(T=>{T.offset.set(u.offset[0],u.offset[1]),T.repeat.set(u.repeat[0],u.repeat[1]),y(T)}):y(null)}}}};if(e.elements!==void 0)return{title:a,prop:l,type:e.elements.length>9?"grid4":"grid3",value:e,disabled:r,onChange:(c,u)=>{i.updateObject(t.uuid,`material.${l}`,u);const m=i.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);te(f,`material.${l}`,u)}}};{const c=[],u=s==="defines"||s==="extensions";try{for(const m in e){const f=e[m];if(f!==void 0)if(f.value!==void 0){const g=gt(`${m}.value`,f.value,t,i,l,u);g!==void 0&&c.push(g)}else{const g=gt(m,f,t,i,l,u);g!==void 0&&c.push(g)}}}catch{console.log("Issue cycling through material object:",s,e)}if(c.length>0)return _i(c),{title:a,items:c}}}}}function Yi(s,e,t){const i=[];for(const n in s){if(!ta(n))continue;const r=typeof s[n],a=s[n];if(r==="boolean")i.push(ca(n,a,e,t));else if(r==="number")i.push(ha(n,a,e,t));else if(r==="string")i.push(da(n,a,e,t));else if(r==="object"){const l=gt(n,a,e,t);l!==void 0&&i.push(l)}else a!==void 0&&console.log("other:",n,r,a)}return _i(i),i.push({title:"Update Material",type:"button",onChange:()=>{t.updateObject(e.uuid,"material.needsUpdate",!0);const n=t.getScene(e.uuid);if(n!==null){const r=n.getObjectByProperty("uuid",e.uuid);te(r,"material.needsUpdate",!0)}}}),i}function fa(s,e){function t(){return`${e.app.appID}_material`}const i=localStorage.getItem(t()),n=i!==null?i==="open":!1;function r(l){localStorage.setItem(t(),l?"open":"closed")}const a=s.material;if(Array.isArray(a)){const l=[],h=a.length;for(let c=0;c<h;c++)l.push(p.jsx(be,{title:`Material ${c}`,items:Yi(a[c],s,e)},`Material ${c}`));return p.jsx(p.Fragment,{children:l})}else return p.jsx(be,{title:"Material",items:Yi(a,s,e),expanded:n,onToggle:l=>{r(l)}})}const Gi="data:image/gif;base64,R0lGODlhDgFkAIAAAP///wAAACH/C1hNUCBEYXRhWE1QPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgOS4xLWMwMDIgNzkuZGJhM2RhM2I1LCAyMDIzLzEyLzE1LTEwOjQyOjM3ICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdFJlZj0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgMjUuNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDoyMDk3M0NEODAxQjQxMUVGODVGNENDMkUyMUExNDk1NSIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDoyMDk3M0NEOTAxQjQxMUVGODVGNENDMkUyMUExNDk1NSI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkE4ODc3Qzg5MDFCMzExRUY4NUY0Q0MyRTIxQTE0OTU1IiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkE4ODc3QzhBMDFCMzExRUY4NUY0Q0MyRTIxQTE0OTU1Ii8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+Af/+/fz7+vn49/b19PPy8fDv7u3s6+rp6Ofm5eTj4uHg397d3Nva2djX1tXU09LR0M/OzczLysnIx8bFxMPCwcC/vr28u7q5uLe2tbSzsrGwr66trKuqqainpqWko6KhoJ+enZybmpmYl5aVlJOSkZCPjo2Mi4qJiIeGhYSDgoGAf359fHt6eXh3dnV0c3JxcG9ubWxramloZ2ZlZGNiYWBfXl1cW1pZWFdWVVRTUlFQT05NTEtKSUhHRkVEQ0JBQD8+PTw7Ojk4NzY1NDMyMTAvLi0sKyopKCcmJSQjIiEgHx4dHBsaGRgXFhUUExIREA8ODQwLCgkIBwYFBAMCAQAAIfkEAAAAAAAsAAAAAA4BZAAAAv+Mj6nL7Q+jnLTai7PevPsPhuJIluaJpurKtu4Lx/JM1/aN5/rO9/4PDAqHxKLxiEwql8ym8wmNSqfUqvWKzWq33K73Cw6Lx+Sy+YxOq9fstvsNj8vn9Lr9js/r9/y+/w8YKDhIWGh4iJiouMjY6PgIGSk5SVlpeYmZqTkJAGDQ+dnpuekmGgAKejpKuiZqmprKqoZKGyrbOlqrejub6xvLGyw8TFzcprurGuvqybxq7ETbrItsCz0l7Zpc+6p9/cS967w9/S2FTF0u/mzehK4Oqz3eTl9vf4+fr7/P3+//DzCgwIEECxo8iDChwoUMGzp8CDGixIkUK1q8iDGjxo0XHDt6/AgypMiRJEuaPIkypcqVLFt+KwAAOw==";function ga(s){const e=s.step!==void 0?s.step:.01,t=O.useRef(null),i=O.useRef(null),n=O.useRef(null),r=O.useRef(null),a=O.useRef(null),[l]=O.useState(s.value),[h,c]=O.useState(s.value.offset[0]),[u,m]=O.useState(s.value.offset[1]),[f,g]=O.useState(s.value.repeat[0]),[x,y]=O.useState(s.value.repeat[1]);function T(C,E,S,w,M){if(s.onChange!==void 0){const I=s.prop!==void 0?s.prop:s.title;s.onChange(I,{src:C,offset:[E,S],repeat:[w,M]})}}function _(C){const E=t.current.src,S=C.target.value;switch(C.target){case i.current:c(S),T(E,S,u,f,x);break;case n.current:m(S),T(E,h,S,f,x);break;case r.current:g(S),T(E,h,u,S,x);break;case a.current:y(S),T(E,h,u,f,S);break}}return p.jsxs("div",{className:"imageField",children:[p.jsx("img",{alt:s.title,ref:t,onClick:()=>{sa().then(C=>{t.current.src=C,T(C,h,u,f,x)})},src:l.src.length>0?l.src:Gi}),p.jsxs("div",{className:"fields",children:[p.jsxs("div",{children:[p.jsx("label",{children:"Offset:"}),p.jsx("input",{ref:i,type:"number",value:h,step:e,onChange:_}),p.jsx("input",{ref:n,type:"number",value:u,step:e,onChange:_})]}),p.jsxs("div",{children:[p.jsx("label",{children:"Repeat:"}),p.jsx("input",{ref:r,type:"number",value:f,step:e,onChange:_}),p.jsx("input",{ref:a,type:"number",value:x,step:e,onChange:_})]}),p.jsx("button",{onClick:()=>{T("",h,u,f,x),t.current.src=Gi},children:"Clear"})]})]})}function jt(s){let e=s.value;e!==void 0&&(e.isColor!==void 0?e=ui(s.value):s.type==="color"&&(e=ui(new o.Color().setStyle(s.value,o.LinearSRGBColorSpace))));const[t,i]=O.useState(e),n=O.useRef(null),r=c=>{let u=c.target.value;if(s.type==="boolean")u=c.target.checked;else if(s.type==="option"&&(typeof s.value=="number"?u=Number(u):typeof s.value=="boolean"?u=!!u:typeof s.value=="object"&&(u=JSON.parse(u)),s.options!==void 0)){const m=s.options.length;for(let f=0;f<m&&s.options[f].value!==u;f++);}i(u),s.onChange!==void 0&&s.onChange(s.prop!==void 0?s.prop:s.title,u)},a={};s.disabled&&(a.opacity=.8);const l=s.type==="string"&&(t.length>100||t.search(`
47
- `)>-1),h=l||s.type==="image"||s.type==="vector2";return p.jsxs("div",{className:`field ${h?"block":""}`,style:a,children:[s.type!=="button"&&p.jsx("label",{ref:n,children:bt(s.title)},"fieldLabel"),s.type==="string"&&!l&&p.jsx("input",{type:"text",disabled:s.disabled,onChange:r,value:t}),s.type==="string"&&l&&p.jsx("textarea",{cols:50,rows:10,disabled:s.disabled!==void 0?s.disabled:!0,onChange:r,onKeyDown:c=>{s.onKeyDown!==void 0&&s.onKeyDown(c)},value:t}),s.type==="boolean"&&p.jsx("input",{type:"checkbox",disabled:s.disabled,onChange:r,checked:t}),s.type==="number"&&p.jsx(Be,{value:t,type:s.type,prop:s.prop!==void 0?s.prop:s.title,min:s.min,max:s.max,step:s.step,disabled:s.disabled,labelRef:n,onChange:s.onChange}),s.type==="range"&&p.jsx(Be,{value:t,type:s.type,prop:s.prop!==void 0?s.prop:s.title,min:s.min,max:s.max,step:s.step,disabled:s.disabled,labelRef:n,onChange:s.onChange}),s.type==="color"&&p.jsxs(p.Fragment,{children:[p.jsx("input",{type:"text",value:t.toString(),onChange:r,disabled:s.disabled,className:"color"}),p.jsx("input",{type:"color",value:t,onChange:r,disabled:s.disabled})]}),s.type==="button"&&p.jsx("button",{disabled:s.disabled,onClick:()=>{s.onChange!==void 0&&s.onChange(s.prop!==void 0?s.prop:s.title,!0)},children:s.title}),s.type==="image"&&p.jsx(ga,{title:s.title,prop:s.prop,value:s.value,onChange:s.onChange}),s.type==="option"&&p.jsx(p.Fragment,{children:p.jsx("select",{onChange:r,disabled:s.disabled,defaultValue:s.value,children:s.options?.map((c,u)=>p.jsx("option",{value:c.value,children:bt(c.title)},u))})}),s.type==="vector2"&&p.jsx(Qn,{step:s.step,value:t,min:0,max:1,onChange:r}),s.type==="grid3"&&p.jsx(Bi,{step:s.step,value:t,onChange:r}),s.type==="grid4"&&p.jsx(ea,{step:s.step,value:t,onChange:r}),s.type==="euler"&&p.jsx(Bi,{step:s.step,value:t,onChange:r})]})}function _a(s){return"items"in s}class be extends O.Component{subgroupNames=[];subgroupElements=[];valueOverrides=new Map;constructor(e){super(e),this.state={lastUpdated:Date.now()}}addGroup(e){const t=[];e.items.forEach(r=>{t.push({type:r.type,prop:r.prop,title:r.title!==void 0?r.title:r.prop,value:r.value,min:r.min,max:r.max,step:r.step,options:r.options,disabled:r.disabled,onChange:(a,l)=>{e.onUpdate(a,l)}})});const i=O.createRef(),n=p.jsx(be,{ref:i,title:e.title,items:t},Math.random());return this.subgroupNames.push(e.title),this.subgroupElements.push(n),this.setState({lastUpdated:Date.now()}),i}removeGroup(e){const t=this.subgroupNames.length;for(let i=0;i<t;i++){const n=this.subgroupNames[i];if(e===n){this.subgroupNames.splice(i,1),this.subgroupElements.splice(i,1),this.setState({lastUpdated:Date.now()});return}}}setField(e,t){this.valueOverrides.set(e,t),this.setState({lastUpdated:Date.now()})}render(){const e=[];return this.props.items.forEach(t=>{if(_a(t))e.push(p.jsx(be,{title:bt(t.title),items:t.items},Math.random()));else{const i=this.valueOverrides.get(t.title),n=i!==void 0?i:t.value;e.push(p.jsx(jt,{title:t.title,prop:t.prop,value:n,type:t.type,min:t.min,max:t.max,step:t.step,disabled:t.disabled,options:t.options,onChange:(r,a)=>{t.onChange!==void 0&&(this.valueOverrides.delete(t.title),t.onChange(r,a))},onKeyDown:r=>{t.onKeyDown!==void 0&&t.onKeyDown(r)}},Math.random()))}}),this.subgroupElements.forEach(t=>e.push(t)),p.jsx(Et,{label:this.props.title,open:this.props.expanded===!0,onToggle:t=>{this.props.onToggle&&this.props?.onToggle(t)},children:e})}}class J extends O.Component{static instance;static groups=[];static groupsRefs=[];static groupTitles=[];constructor(e){super(e),this.state={lastUpdate:Date.now()},J.instance=this,R.addEventListener(A.ADD_GROUP,this.addGroup),R.addEventListener(A.REMOVE_GROUP,this.removeGroup)}componentWillUnmount(){R.removeEventListener(A.ADD_GROUP,this.addGroup),R.removeEventListener(A.REMOVE_GROUP,this.removeGroup)}render(){return p.jsx("div",{className:"customGroups",children:J.groups},this.state.lastUpdate)}addGroup=e=>{const t=JSON.parse(e.value),i=[];t.items.forEach(n=>{i.push({type:n.type,prop:n.prop,title:n.title!==void 0?n.title:n.prop,value:n.value,min:n.min,max:n.max,step:n.step,options:n.options,disabled:n.disabled,onChange:(r,a)=>{this.props.three.updateGroup(t.title,r,a)}})}),J.groups.push(p.jsx(be,{title:t.title,items:i},Math.random())),J.groupTitles.push(t.title),this.setState({lastUpdate:Date.now()})};removeGroup=e=>{const t=e.value,i=J.groupTitles.length;for(let n=0;n<i;n++)if(t===J.groupTitles[n]){J.groups.splice(n,1),J.groupTitles.splice(n,1),this.setState({lastUpdate:Date.now()});return}};static addEditorGroup(e){const t=[];e.items.forEach(r=>{t.push({type:r.type,prop:r.prop,title:r.title!==void 0?r.title:r.prop,value:r.value,min:r.min,max:r.max,step:r.step,options:r.options,disabled:r.disabled,onChange:(a,l)=>{e.onUpdate(a,l)}})});const i=O.createRef(),n=p.jsx(be,{ref:i,title:e.title,items:t},Math.random());return J.groups.push(n),J.groupsRefs.push(i),J.groupTitles.push(e.title),i}static removeEditorGroup(e){const t=J.groupTitles.length;for(let i=0;i<t;i++)if(e===J.groupTitles[i]){J.groups.splice(i,1),J.groupTitles.splice(i,1),J.instance.setState({lastUpdate:Date.now()});return}}}function Zi(s){switch(s){case"fov":return"FOV";case"zoom":return"Zoom";case"near":return"Near";case"far":return"Far";case"focus":return"Focus";case"aspect":return"Aspect";case"filmGauge":return"Film Gauge";case"filmOffset":return"Film Offset";case"left":return"Left";case"right":return"Right";case"top":return"Top";case"bottom":return"Bottom"}return s}function va(s,e){function t(){return`${e.app.appID}_camera`}const i=localStorage.getItem(t()),n=i!==null?i==="open":!1;function r(l){localStorage.setItem(t(),l?"open":"closed")}const a=[];if(s.perspectiveCameraInfo!==void 0)for(const l in s.perspectiveCameraInfo)a.push({title:Zi(l),prop:l,type:"number",step:.01,value:s.perspectiveCameraInfo[l],onChange:(h,c)=>{e.updateObject(s.uuid,h,c),e.requestMethod(s.uuid,"updateProjectionMatrix");const u=e.getScene(s.uuid);if(u!==null){const m=u.getObjectByProperty("uuid",s.uuid);m!==void 0&&(te(m,h,c),m.updateProjectionMatrix())}}});else if(s.orthographicCameraInfo!==void 0)for(const l in s.orthographicCameraInfo)a.push({title:Zi(l),prop:l,type:"number",step:.01,value:s.perspectiveCameraInfo[l],onChange:(h,c)=>{e.updateObject(s.uuid,h,c),e.requestMethod(s.uuid,"updateProjectionMatrix");const u=e.getScene(s.uuid);if(u!==null){const m=u.getObjectByProperty("uuid",s.uuid);m!==void 0&&(te(m,h,c),m.updateProjectionMatrix())}}});return p.jsx(be,{title:"Camera",items:a,expanded:n,onToggle:l=>{r(l)}})}class ya extends o.Line{constructor(e,t){const i=[1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],n=new o.BufferGeometry;n.setAttribute("position",new o.Float32BufferAttribute(i,3)),n.computeBoundingSphere();const r=new o.LineBasicMaterial({fog:!1});super(n,r),this.light=e,this.color=t,this.type="RectAreaLightHelper";const a=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],l=new o.BufferGeometry;l.setAttribute("position",new o.Float32BufferAttribute(a,3)),l.computeBoundingSphere(),this.add(new o.Mesh(l,new o.MeshBasicMaterial({side:o.BackSide,fog:!1})))}updateMatrixWorld(){if(this.scale.set(.5*this.light.width,.5*this.light.height,1),this.color!==void 0)this.material.color.set(this.color),this.children[0].material.color.set(this.color);else{this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);const e=this.material.color,t=Math.max(e.r,e.g,e.b);t>1&&e.multiplyScalar(1/t),this.children[0].material.color.copy(this.material.color)}this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld),this.children[0].matrixWorld.copy(this.matrixWorld)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const Wi={type:"change"},Si={type:"start"},Ts={type:"end"},Mt=new o.Ray,Xi=new o.Plane,Ca=Math.cos(70*o.MathUtils.DEG2RAD),ae=new o.Vector3,me=2*Math.PI,Y={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},ti=1e-6;class ba extends o.Controls{constructor(e,t=null){super(e,t),this.state=Y.NONE,this.enabled=!0,this.target=new o.Vector3,this.cursor=new o.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:o.MOUSE.ROTATE,MIDDLE:o.MOUSE.DOLLY,RIGHT:o.MOUSE.PAN},this.touches={ONE:o.TOUCH.ROTATE,TWO:o.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new o.Vector3,this._lastQuaternion=new o.Quaternion,this._lastTargetPosition=new o.Vector3,this._quat=new o.Quaternion().setFromUnitVectors(e.up,new o.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new o.Spherical,this._sphericalDelta=new o.Spherical,this._scale=1,this._panOffset=new o.Vector3,this._rotateStart=new o.Vector2,this._rotateEnd=new o.Vector2,this._rotateDelta=new o.Vector2,this._panStart=new o.Vector2,this._panEnd=new o.Vector2,this._panDelta=new o.Vector2,this._dollyStart=new o.Vector2,this._dollyEnd=new o.Vector2,this._dollyDelta=new o.Vector2,this._dollyDirection=new o.Vector3,this._mouse=new o.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Sa.bind(this),this._onPointerDown=Ea.bind(this),this._onPointerUp=wa.bind(this),this._onContextMenu=Ra.bind(this),this._onMouseWheel=Ta.bind(this),this._onKeyDown=Ma.bind(this),this._onTouchStart=Pa.bind(this),this._onTouchMove=Aa.bind(this),this._onMouseDown=xa.bind(this),this._onMouseMove=Oa.bind(this),this._interceptControlDown=Da.bind(this),this._interceptControlUp=Ia.bind(this),this.domElement!==null&&this.connect(),this.update()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Wi),this.update(),this.state=Y.NONE}update(e=null){const t=this.object.position;ae.copy(t).sub(this.target),ae.applyQuaternion(this._quat),this._spherical.setFromVector3(ae),this.autoRotate&&this.state===Y.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let i=this.minAzimuthAngle,n=this.maxAzimuthAngle;isFinite(i)&&isFinite(n)&&(i<-Math.PI?i+=me:i>Math.PI&&(i-=me),n<-Math.PI?n+=me:n>Math.PI&&(n-=me),i<=n?this._spherical.theta=Math.max(i,Math.min(n,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+n)/2?Math.max(i,this._spherical.theta):Math.min(n,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=a!=this._spherical.radius}if(ae.setFromSpherical(this._spherical),ae.applyQuaternion(this._quatInverse),t.copy(this.target).add(ae),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const l=ae.length();a=this._clampDistance(l*this._scale);const h=l-a;this.object.position.addScaledVector(this._dollyDirection,h),this.object.updateMatrixWorld(),r=!!h}else if(this.object.isOrthographicCamera){const l=new o.Vector3(this._mouse.x,this._mouse.y,0);l.unproject(this.object);const h=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=h!==this.object.zoom;const c=new o.Vector3(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(l),this.object.updateMatrixWorld(),a=ae.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(Mt.origin.copy(this.object.position),Mt.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Mt.direction))<Ca?this.object.lookAt(this.target):(Xi.setFromNormalAndCoplanarPoint(this.object.up,this.target),Mt.intersectPlane(Xi,this.target))))}else if(this.object.isOrthographicCamera){const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>ti||8*(1-this._lastQuaternion.dot(this.object.quaternion))>ti||this._lastTargetPosition.distanceToSquared(this.target)>ti?(this.dispatchEvent(Wi),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?me/60*this.autoRotateSpeed*e:me/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){ae.setFromMatrixColumn(t,0),ae.multiplyScalar(-e),this._panOffset.add(ae)}_panUp(e,t){this.screenSpacePanning===!0?ae.setFromMatrixColumn(t,1):(ae.setFromMatrixColumn(t,0),ae.crossVectors(this.object.up,ae)),ae.multiplyScalar(e),this._panOffset.add(ae)}_pan(e,t){const i=this.domElement;if(this.object.isPerspectiveCamera){const n=this.object.position;ae.copy(n).sub(this.target);let r=ae.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/i.clientHeight,this.object.matrix),this._panUp(2*t*r/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),n=e-i.left,r=t-i.top,a=i.width,l=i.height;this._mouse.x=n/a*2-1,this._mouse.y=-(r/l)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(me*this._rotateDelta.x/t.clientHeight),this._rotateUp(me*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateUp(me*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateUp(-me*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateLeft(me*this.rotateSpeed/this.domElement.clientHeight):this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateLeft(-me*this.rotateSpeed/this.domElement.clientHeight):this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._rotateStart.set(i,n)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panStart.set(i,n)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,n=e.pageY-t.y,r=Math.sqrt(i*i+n*n);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const i=this._getSecondPointerPosition(e),n=.5*(e.pageX+i.x),r=.5*(e.pageY+i.y);this._rotateEnd.set(n,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(me*this._rotateDelta.x/t.clientHeight),this._rotateUp(me*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panEnd.set(i,n)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,n=e.pageY-t.y,r=Math.sqrt(i*i+n*n);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,l=(e.pageY+t.y)*.5;this._updateZoomParameters(a,l)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new o.Vector2,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,i={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:i.deltaY*=16;break;case 2:i.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(i.deltaY*=10),i}}function Ea(s){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(s.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(s)&&(this._addPointer(s),s.pointerType==="touch"?this._onTouchStart(s):this._onMouseDown(s)))}function Sa(s){this.enabled!==!1&&(s.pointerType==="touch"?this._onTouchMove(s):this._onMouseMove(s))}function wa(s){switch(this._removePointer(s),this._pointers.length){case 0:this.domElement.releasePointerCapture(s.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Ts),this.state=Y.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function xa(s){let e;switch(s.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case o.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(s),this.state=Y.DOLLY;break;case o.MOUSE.ROTATE:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=Y.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=Y.ROTATE}break;case o.MOUSE.PAN:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=Y.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=Y.PAN}break;default:this.state=Y.NONE}this.state!==Y.NONE&&this.dispatchEvent(Si)}function Oa(s){switch(this.state){case Y.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(s);break;case Y.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(s);break;case Y.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(s);break}}function Ta(s){this.enabled===!1||this.enableZoom===!1||this.state!==Y.NONE||(s.preventDefault(),this.dispatchEvent(Si),this._handleMouseWheel(this._customWheelEvent(s)),this.dispatchEvent(Ts))}function Ma(s){this.enabled===!1||this.enablePan===!1||this._handleKeyDown(s)}function Pa(s){switch(this._trackPointer(s),this._pointers.length){case 1:switch(this.touches.ONE){case o.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(s),this.state=Y.TOUCH_ROTATE;break;case o.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(s),this.state=Y.TOUCH_PAN;break;default:this.state=Y.NONE}break;case 2:switch(this.touches.TWO){case o.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(s),this.state=Y.TOUCH_DOLLY_PAN;break;case o.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(s),this.state=Y.TOUCH_DOLLY_ROTATE;break;default:this.state=Y.NONE}break;default:this.state=Y.NONE}this.state!==Y.NONE&&this.dispatchEvent(Si)}function Aa(s){switch(this._trackPointer(s),this.state){case Y.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(s),this.update();break;case Y.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(s),this.update();break;case Y.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(s),this.update();break;case Y.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(s),this.update();break;default:this.state=Y.NONE}}function Ra(s){this.enabled!==!1&&s.preventDefault()}function Da(s){s.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Ia(s){s.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}/*!
46
+ C11,8.22,10.74,8,10.43,8z`})});function Ss(i){return p.jsx(ms.Reorder.Item,{value:i.title,children:p.jsxs("div",{children:[Xn,p.jsx("span",{children:i.title}),p.jsx("button",{className:"closeIcon",onClick:()=>{i.onDelete(i.index)},children:Wn})]})},i.title)}function ws(i){const[e,t]=O.useState(!1),[s,n]=O.useState(i.options),a=c=>{i.onDragComplete(c),n(c)},r=c=>{const u=[...s];u.splice(c,1),a(u)},l=[];s.forEach((c,u)=>{l.push(p.jsx(Ss,{index:u,title:c,onDelete:r},c))});let h="dropdown draggable";return i.subdropdown&&(h+=" subdropdown"),p.jsxs("div",{className:h,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[p.jsx(Ei,{title:i.title}),p.jsx(ms.Reorder.Group,{axis:"y",values:s,onReorder:a,style:{visibility:e?"visible":"hidden"},children:l})]})}function xs(i){const[e,t]=O.useState(!1),s=[];i.options.map((a,r)=>{i.onSelect!==void 0&&(a.onSelect=i.onSelect),s.push(p.jsx(Os,{option:a},r))});let n="dropdown";return i.subdropdown&&(n+=" subdropdown"),p.jsxs("div",{className:n,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[p.jsx(Ei,{title:i.title}),p.jsx("ul",{style:{visibility:e?"visible":"hidden"},children:s})]})}function Os(i){const{option:e}=i,[t,s]=O.useState("");let n;switch(e.type){case"draggable":n=p.jsx(ws,{title:e.title,options:e.value,onDragComplete:a=>{e.onDragComplete!==void 0&&e.onDragComplete(a)},subdropdown:!0});break;case"dropdown":n=p.jsx(xs,{title:e.title,options:e.value,onSelect:e.onSelect,subdropdown:!0});break;case"option":n=p.jsx("button",{onClick:()=>{e.onSelect!==void 0&&e.onSelect(e.value),e.selectable&&(t!==e.title?s(e.title):s(""))},children:e.title});break}return p.jsx("li",{className:t===e.title?"selected":"",children:n},gs())}function qn(i,e,t){function s(a){switch(e.forEach(r=>{r.callback(i,r.remote,a)}),a.event){case"custom":R.dispatchEvent({type:P.CUSTOM,value:a.data});break}}function n(a){switch(t.forEach(r=>{r.callback(i,r.remote,a)}),a.event){case"custom":R.dispatchEvent({type:P.CUSTOM,value:a.data});break}}i.listen=a=>{a.target==="editor"?n(a):s(a)}}function Et(i){const[e,t]=O.useState(i.open!==void 0?i.open:!0),s=!e||i.children===void 0,n=()=>{R.dispatchEvent({type:P.REMOVE_SCENE,value:i.scene})};return p.jsxs("div",{className:`accordion ${s?"hide":""}`,children:[p.jsxs("button",{className:"toggle",onClick:()=>{const a=!e;i.onToggle!==void 0&&i.onToggle(a),t(a)},children:[p.jsx("p",{className:`status ${e?"open":""}`,children:"Toggle"}),p.jsx("p",{className:"label",children:bt(i.label)})]}),i.onRefresh?p.jsxs(p.Fragment,{children:[p.jsx("button",{className:"refresh",onClick:i.onRefresh}),p.jsx("button",{className:"remove",onClick:n})]}):null,i.button,p.jsx("div",{className:e?"open":"",children:p.jsx("div",{children:i.children})},Math.random())]})}function Si(i){const e=O.useRef(null),[t,s]=O.useState(!1),n=i.child!==void 0&&i.child.children.length>0,a=[];return i.child!==void 0&&i.child.children.length>0&&i.child.children.map((r,l)=>{a.push(p.jsx(Si,{child:r,three:i.three},l))}),O.useEffect(()=>{if(i.child){const r=i.three.getScene(i.child.uuid);if(r!==null){const l=r.getObjectByProperty("uuid",i.child.uuid);l!==void 0&&(e.current.style.opacity=l.visible?"1":"0.25")}}},[t]),p.jsx(p.Fragment,{children:i.child!==void 0&&p.jsxs("div",{className:"childObject",children:[p.jsxs("div",{className:"child",children:[n?p.jsx("button",{className:"status",style:{backgroundPositionX:t?"-14px":"2px"},onClick:()=>{s(!t)}}):null,p.jsx("button",{className:"name",style:{left:n?"20px":"5px"},onClick:()=>{i.child!==void 0&&(i.three.getObject(i.child.uuid),t||s(!0))},children:i.child.name.length>0?`${i.child.name} (${i.child.type})`:`${i.child.type}::${i.child.uuid}`}),p.jsx("button",{className:"visibility",ref:e,onClick:()=>{if(i.child){const r=i.three.getScene(i.child.uuid);if(r!==null){const l=r.getObjectByProperty("uuid",i.child.uuid);if(l!==void 0){const h="visible",c=!l.visible;e.current.style.opacity=c?"1":"0.25",i.three.updateObject(i.child.uuid,h,c),te(l,h,c)}}}}}),p.jsx("div",{className:`icon ${Fn(i.child)}`})]}),p.jsx("div",{className:t?"open":"",children:p.jsx("div",{className:"container",children:a})})]},Math.random())})}function gi(i){const e=[];return i.child?.children.map((t,s)=>{e.push(p.jsx(Si,{child:t,scene:i.scene,three:i.three},s))}),p.jsx("div",{className:`scene ${i.class!==void 0?i.class:""}`,children:e})}function ft(i){const[e,t]=O.useState(i.defaultValue);return O.useEffect(()=>{let s=!1,n=-1,a=0,r=i.defaultValue,l=!1;const h=g=>{l=g.ctrlKey},c=g=>{s=!0,a=Number(i.input.current?.value),n=g.clientX,document.addEventListener("mouseup",m,!1),document.addEventListener("mousemove",u,!1),document.addEventListener("contextmenu",m,!1)},u=g=>{if(!s)return;const x=i.step!==void 0?i.step:1,y=(g.clientX-n)*x*(l?10:1);r=Number((a+y).toFixed(4)),i.min!==void 0&&(r=Math.max(r,i.min)),i.max!==void 0&&(r=Math.min(r,i.max)),i.onChange!==void 0&&i.onChange(r),t(r)},m=()=>{s=!1,document.removeEventListener("mouseup",m),document.removeEventListener("mousemove",u),document.removeEventListener("contextmenu",m)},f=g=>{const x=Number(g.target.value);i.onChange!==void 0&&i.onChange(x),t(x)};return i.label.current?.addEventListener("mousedown",c,!1),i.sliderRef!==void 0&&i.sliderRef.current?.addEventListener("input",f),document.addEventListener("keydown",h,!1),document.addEventListener("keyup",h,!1),()=>{i.label.current?.removeEventListener("mousedown",c),i.sliderRef!==void 0&&i.sliderRef.current?.removeEventListener("input",f),document.removeEventListener("mouseup",m),document.removeEventListener("mousemove",u),document.removeEventListener("contextmenu",m),document.removeEventListener("keydown",h),document.addEventListener("keyup",h,!1)}},[]),e}function Be(i){const e=O.useRef(null),t=O.useRef(null),[s,n]=O.useState(i.value);return ft({label:i.labelRef,input:e,sliderRef:t,defaultValue:s,min:i.min,max:i.max,step:i.step,onChange:a=>{n(a),i.onChange!==void 0&&i.onChange(i.prop,a)}}),p.jsxs(p.Fragment,{children:[i.type==="number"&&p.jsx("input",{alt:i.alt,className:i.className,ref:e,type:"number",value:s,min:i.min,max:i.max,step:i.step,disabled:i.disabled,onChange:a=>{if(n(a.target.value),a.target.value.length===0)return;const r=Number(a.target.value);isNaN(r)||i.onChange!==void 0&&i.onChange(i.prop,r)}}),i.type==="range"&&p.jsxs(p.Fragment,{children:[p.jsx("input",{type:"text",value:s.toString(),disabled:i.disabled,ref:e,className:"min",onChange:a=>{if(a.target.value.length===0)return;const r=Number(a.target.value);isNaN(r)||i.onChange!==void 0&&i.onChange(i.prop,r)}}),p.jsx("input",{disabled:i.disabled,type:"range",value:s,min:i.min,max:i.max,step:i.step,ref:t,onChange:Ct})]})]})}function Qn(i){const e=O.useRef(null),t=O.useRef(null),s=O.useRef(null),n=O.useRef(null),a=O.useRef(null),r=O.useRef(null),l=O.useRef(null),h=O.useRef(null),c=O.useRef(null),u=O.useRef(null),[m,f]=O.useState(i.value.x),[g,x]=O.useState(i.value.y),[y,T]=O.useState({min:Math.min(i.min,Math.min(i.value.x,i.value.y)),max:Math.max(i.max,Math.max(i.value.x,i.value.y))}),[_,C]=O.useState(!1);ft({label:l,input:e,defaultValue:m,min:y.min,max:y.max,step:.01,onChange:D=>{f(D),i.onChange({target:{value:{x:D,y:g}}})}}),ft({label:h,input:t,defaultValue:g,min:y.min,max:y.max,step:.01,onChange:D=>{x(D),i.onChange({target:{value:{x:m,y:D}}})}}),ft({label:c,input:s,defaultValue:y.min,min:y.min-1,max:y.max+1,step:.01,onChange:D=>{T({min:D,max:y.max})}}),ft({label:u,input:n,defaultValue:y.max,min:y.min-1,max:y.max+1,step:.01,onChange:D=>{T({min:y.min,max:D})}});function E(){_||(window.addEventListener("mousemove",w),window.addEventListener("mouseup",S),C(!0))}function S(){window.removeEventListener("mousemove",w),window.removeEventListener("mouseup",S),C(!1)}function w(D){const B=a.current.getBoundingClientRect(),_e=je(0,99,D.clientX-B.left)/99,pe=1-je(0,99,D.clientY-B.top)/99,ne=Ce(it(y.min,y.max,_e),3),Q=Ce(it(y.min,y.max,pe),3);i.onChange({target:{value:{x:ne,y:Q}}}),f(ne),x(Q)}function M(){const D=Number(s.current.value);T({min:D,max:y.max}),m<D&&f(je(D,y.max,m)),g<D&&x(je(D,y.max,g))}function I(){const D=Number(n.current.value);T({min:y.min,max:D}),m>D&&f(je(y.min,D,m)),g>D&&x(je(y.min,D,g))}O.useEffect(()=>{r.current.style.left=`${Ft(y.min,y.max,m)*100}%`,r.current.style.top=`${(1-Ft(y.min,y.max,g))*100}%`},[y,m,g]);const U=i.step!==void 0?i.step:.01;return p.jsxs("div",{className:"vector2",children:[p.jsxs("div",{className:"fields",children:[p.jsxs("div",{children:[p.jsx("label",{ref:l,children:"X"}),p.jsx("input",{ref:e,type:"number",value:m,min:y.min,max:y.max,step:U,onChange:D=>{if(f(D.target.value),D.target.value.length===0)return;const B=Number(D.target.value);isNaN(B)||(i.onChange({target:{value:{x:B,y:g}}}),B<y.min&&T({min:B,max:y.max}))}})]}),p.jsxs("div",{children:[p.jsx("label",{ref:h,children:"Y"}),p.jsx("input",{ref:t,type:"number",value:g,min:y.min,max:y.max,step:U,onChange:D=>{if(x(D.target.value),D.target.value.length===0)return;const B=Number(D.target.value);isNaN(B)||(i.onChange({target:{value:{x:m,y:B}}}),B>y.max&&T({min:y.min,max:B}))}})]}),p.jsxs("div",{children:[p.jsx("label",{ref:c,children:"Min"}),p.jsx("input",{ref:s,type:"number",value:y.min,step:U,onChange:M})]}),p.jsxs("div",{children:[p.jsx("label",{ref:u,children:"Max"}),p.jsx("input",{ref:n,type:"number",value:y.max,step:U,onChange:I})]})]}),p.jsxs("div",{className:"input",ref:a,onMouseDown:E,onMouseUp:S,children:[p.jsx("div",{className:"x"}),p.jsx("div",{className:"y"}),p.jsx("div",{className:"pt",ref:r})]})]})}const Kn=Math.PI/180,$n=180/Math.PI;function qe(i,e,t,s,n){return s+(i-e)*(n-s)/(t-e)}function Qe(i,e,t){return(1-t)*i+t*e}function _i(i){return i*Kn}function Jn(i){return i*$n}function Yi(i){const e=i.value.x!==void 0&&i.value.y!==void 0&&i.value.z!==void 0,t=i.value.isEuler!==void 0,s=i.value.elements!==void 0,n=i.step!==void 0?i.step:.01,a=[];if(t){const r=O.useMemo(()=>i.value,[]);["_x","_y","_z"].forEach(h=>{const c=O.useRef(null);a.push(p.jsxs("div",{children:[p.jsx("label",{ref:c,children:h.substring(1).toUpperCase()}),p.jsx(Be,{value:Jn(r[h]),type:"number",prop:h,step:.1,labelRef:c,onChange:(u,m)=>{r[u]=_i(m),i.onChange({target:{value:r}})}})]},h))})}else if(e){const r=O.useMemo(()=>i.value,[]),l=(c,u)=>{r[c]=u,i.onChange({target:{value:r}})};["x","y","z"].forEach(c=>{const u=O.useRef(null);a.push(p.jsxs("div",{children:[p.jsx("label",{ref:u,children:c.toUpperCase()}),p.jsx(Be,{value:r[c],type:"number",prop:c,step:n,labelRef:u,onChange:l})]},c))})}else if(s){const r=O.useMemo(()=>i.value,[]),l=(h,c)=>{const u=Number(h);r.elements[u]=c,i.onChange({target:{value:r}})};for(let h=0;h<9;h++){const c=O.useRef(null);a.push(p.jsxs("div",{children:[p.jsx("label",{ref:c,children:h+1}),p.jsx(Be,{value:r.elements[h],type:"number",prop:h.toString(),step:n,labelRef:c,onChange:l})]},h.toString()))}}return p.jsx("div",{className:"grid3",children:a},Math.random().toString())}function ea(i){const e=i.value.x!==void 0,t=i.step!==void 0?i.step:.01,s=[];if(e){const n=O.useMemo(()=>i.value,[]),a=(l,h)=>{n[l]=h,i.onChange({target:{value:n}})};["x","y","z","w"].forEach(l=>{const h=O.useRef(null);s.push(p.jsxs("div",{children:[p.jsx("label",{ref:h,children:l.toUpperCase()}),p.jsx(Be,{value:n[l],type:"number",prop:l,step:t,labelRef:h,onChange:a})]},l))})}else{const n=O.useMemo(()=>i.value,[]),a=(r,l)=>{const h=Number(r);n.elements[h]=l,i.onChange({target:{value:n}})};for(let r=0;r<16;r++){const l=O.useRef(null);s.push(p.jsxs("div",{children:[p.jsx("label",{ref:l,children:r+1}),p.jsx(Be,{value:n.elements[r],type:"number",prop:r.toString(),step:t,labelRef:l,onChange:a})]},r.toString()))}}return p.jsx("div",{className:"grid4",children:s})}function ta(i){return!(i==="defaultAttributeValues"||i==="forceSinglePass"||i==="linecap"||i==="linejoin"||i==="linewidth"||i==="normalMapType"||i==="precision"||i==="shadowSide"||i==="uniformsGroups"||i==="uniformsNeedUpdate"||i==="userData"||i==="version"||i==="wireframeLinecap"||i==="wireframeLinejoin"||i==="wireframeLinewidth"||i.slice(0,4)==="clip"||i.slice(0,7)==="polygon"||i.slice(0,7)==="stencil"||i.slice(0,2)==="is")}function ia(i){switch(i){case"Alpha Map":return"alphaMap";case"Anisotropy Map":return"anisotropyMap";case"AO Map":return"aoMap";case"Bump Map":return"bumpMap";case"Clearcoat Map":return"clearcoatMap";case"Clearcoat Normal Map":return"clearcoatNormalMap";case"Clearcoat Roughness Map":return"clearcoatRoughnessMap";case"Displacement Map":return"displacementMap";case"Emissive Map":return"emissiveMap";case"Gradient Map":return"gradientMap";case"Iridescence Map":return"iridescenceMap";case"Iridescence Thickness Map":return"iridescenceThicknessMap";case"Map":return"map";case"Matcap":return"matcap";case"Normal Map":return"normalMap";case"Roughness Map":return"roughnessMap";case"Sheen Color Map":return"sheenColorMap";case"Sheen Roughness Map":return"sheenRoughnessMap";case"Specular Color Map":return"specularColorMap";case"Specular Map Intensity":return"specularIntensityMap";case"Thickness Map":return"thicknessMap";case"Transmission Map":return"transmissionMap"}return i}function Bt(i){switch(i){case"alphaHash":return"Alpha Hash";case"alphaMap":return"Alpha Map";case"alphaToCoverage":return"Alpha To Coverage";case"anisotropy":return"Anisotropy";case"anisotropyMap":return"Anisotropy Map";case"anisotropyRotation":return"Anisotropy Rotation";case"aoMap":return"AO Map";case"aoMapIntensity":return"AO Map Intensity";case"attenuationColor":return"Attenuation Color";case"attenuationDistance":return"Attenuation Distance";case"blendAlpha":return"Blend Alpha";case"blendColor":return"Blend Color";case"blendDst":return"Blend Dst";case"blendDstAlpha":return"Blend Dst Alha";case"blendEquation":return"Blend Equation";case"blendEquationAlpha":return"Blend Equation Alpha";case"blending":return"Blending";case"blendSrc":return"Blend Src";case"blendSrcAlpha":return"Blend Src Alpha";case"bumpMap":return"Bump Map";case"bumpScale":return"Bump Scale";case"clearcoat":return"Clearcoat";case"clearcoatMap":return"Clearcoat Map";case"clearcoatNormalMap":return"Clearcoat Normal Map";case"clearcoatNormalScale":return"Clearcoat Normal Scale";case"clearcoatRoughness":return"Clearcoat Roughness";case"clearcoatRoughnessMap":return"Clearcoat Roughness Map";case"color":return"Color";case"colorWrite":return"Color Write";case"defines":return"Defines";case"depthFunc":return"Depth Func";case"depthTest":return"Depth Test";case"depthWrite":return"Depth Write";case"dispersion":return"Dispersion";case"displacementBias":return"Displacement Bias";case"displacementMap":return"Displacement Map";case"displacementScale":return"Displacement Scale";case"dithering":return"Dithering";case"emissive":return"Emissive";case"emissiveMap":return"Emissive Map";case"emissiveIntensity":return"Emissive Intensity";case"envMap":return"Environment Map";case"envMapIntensity":return"Environment Map Intensity";case"envMapRotation":return"Environment Map Rotation";case"extensions":return"Extensions";case"flatShading":return"Flat Shading";case"fragmentShader":return"Fragment Shader";case"fog":return"Fog";case"glslVersion":return"GLSL Version";case"gradientMap":return"Gradient Map";case"ior":return"IOR";case"iridescence":return"Iridescence";case"iridescenceIOR":return"Iridescence IOR";case"iridescenceMap":return"Iridescence Map";case"iridescenceThicknessMap":return"Iridescence Thickness Map";case"iridescenceThicknessRange":return"Iridescence Thickness Range";case"lights":return"Lights";case"lightMap":return"Light Map";case"lightMapIntensity":return"Light Map Intensity";case"map":return"Map";case"matcap":return"Matcap";case"metalness":return"Metalness";case"metalnessMap":return"Metalness Map";case"name":return"Name";case"normalMap":return"Normal Map";case"normalScale":return"Normal Scale";case"premultipliedAlpha":return"Premultiplied Alpha";case"opacity":return"Opacity";case"reflectivity":return"Reflectivity";case"refractionRatio":return"Refraction Ratio";case"roughness":return"Roughness";case"roughnessMap":return"Roughness Map";case"sheen":return"Sheen";case"sheenColor":return"Sheen Color";case"sheenColorMap":return"Sheen Color Map";case"sheenRoughness":return"Sheen Roughness";case"sheenRoughnessMap":return"Sheen Roughness Map";case"shininess":return"Shininess";case"side":return"Side";case"size":return"Size";case"sizeAttenuation":return"Size Attenuation";case"specular":return"Specular";case"specularColor":return"Specular Color";case"specularColorMap":return"Specular Color Map";case"specularIntensity":return"Specular Intensity";case"specularIntensityMap":return"Specular Map Intensity";case"thickness":return"Thickness";case"thicknessMap":return"Thickness Map";case"toneMapped":return"Tone Mapped";case"transmission":return"Transmission";case"transmissionMap":return"Transmission Map";case"transparent":return"Transparent";case"type":return"Type";case"uuid":return"UUID";case"uniforms":return"Uniforms";case"vertexColors":return"Vertex Colors";case"vertexShader":return"Vertex Shader";case"visible":return"Visible";case"wireframe":return"Wireframe"}return i}function Ts(i){const e=i.toLowerCase();return e.search("intensity")>-1||e==="anisotropyrotation"||e==="blendalpha"||e==="bumpscale"||e==="clearcoatroughness"||e==="displacementbias"||e==="displacementscale"||e==="metalness"||e==="opacity"||e==="reflectivity"||e==="refractionratio"||e==="roughness"||e==="sheenroughness"}function sa(){const i=document.createElement("input");return i.type="file",new Promise((e,t)=>{i.addEventListener("change",function(){if(i.files===null)t();else{const s=i.files[0],n=new FileReader;n.onload=function(a){e(a.target.result)},n.readAsDataURL(s)}}),i.click()})}const na=[{title:"Front",value:o.FrontSide},{title:"Back",value:o.BackSide},{title:"Double",value:o.DoubleSide}],aa=[{title:"No Blending",value:o.NoBlending},{title:"Normal",value:o.NormalBlending},{title:"Additive",value:o.AdditiveBlending},{title:"Subtractive",value:o.SubtractiveBlending},{title:"Multiply",value:o.MultiplyBlending},{title:"Custom",value:o.CustomBlending}],ra=[{title:"Add",value:o.AddEquation},{title:"Subtract",value:o.SubtractEquation},{title:"Reverse Subtract",value:o.ReverseSubtractEquation},{title:"Min",value:o.MinEquation},{title:"Max",value:o.MaxEquation}],oa=[{title:"Zero",value:o.ZeroFactor},{title:"One",value:o.OneFactor},{title:"Src Color",value:o.SrcColorFactor},{title:"One Minus Src Color",value:o.OneMinusSrcColorFactor},{title:"Src Alpha",value:o.SrcAlphaFactor},{title:"One Minus Src Alpha",value:o.OneMinusSrcAlphaFactor},{title:"Dst Alpha",value:o.DstAlphaFactor},{title:"One Minus Dst Alpha",value:o.OneMinusDstAlphaFactor},{title:"Dst Color",value:o.DstColorFactor},{title:"One Minus Dst Color",value:o.OneMinusDstColorFactor},{title:"Src Alpha Saturate",value:o.SrcAlphaSaturateFactor},{title:"Constant Color",value:o.ConstantColorFactor},{title:"One Minus Constant Color",value:o.OneMinusConstantColorFactor},{title:"Constant Alpha",value:o.ConstantAlphaFactor},{title:"One Minus Constant Alpha",value:o.OneMinusConstantAlphaFactor}],la=[{title:"Zero",value:o.ZeroFactor},{title:"One",value:o.OneFactor},{title:"Src Color",value:o.SrcColorFactor},{title:"One Minus Src Color",value:o.OneMinusSrcColorFactor},{title:"Src Alpha",value:o.SrcAlphaFactor},{title:"One Minus Src Alpha",value:o.OneMinusSrcAlphaFactor},{title:"Dst Alpha",value:o.DstAlphaFactor},{title:"One Minus Dst Alpha",value:o.OneMinusDstAlphaFactor},{title:"Dst Color",value:o.DstColorFactor},{title:"One Minus Dst Color",value:o.OneMinusDstColorFactor},{title:"Constant Color",value:o.ConstantColorFactor},{title:"One Minus Constant Color",value:o.OneMinusConstantColorFactor},{title:"Constant Alpha",value:o.ConstantAlphaFactor},{title:"One Minus Constant Alpha",value:o.OneMinusConstantAlphaFactor}];function ot(i,e){i.needsUpdate=!0,i.type="option",i.options=e}function ca(i,e,t,s){return{type:"boolean",title:Bt(i),prop:i,value:e,needsUpdate:!0,onChange:(n,a)=>{s.updateObject(t.uuid,`material.${i}`,a),s.updateObject(t.uuid,"material.needsUpdate",!0);const r=s.getScene(t.uuid);if(r!==null){const l=r.getObjectByProperty("uuid",t.uuid);te(l,`material.${i}`,a)}}}}function ha(i,e,t,s){const n={type:"number",title:Bt(i),prop:i,value:e,min:void 0,max:void 0,step:.01,needsUpdate:!0,onChange:(a,r)=>{s.updateObject(t.uuid,`material.${i}`,r),s.updateObject(t.uuid,"material.needsUpdate",!0);const l=s.getScene(t.uuid);if(l!==null){const h=l.getObjectByProperty("uuid",t.uuid);te(h,`material.${i}`,r)}}};switch(i){case"blending":ot(n,aa);break;case"blendDst":ot(n,la);break;case"blendEquation":ot(n,ra);break;case"blendSrc":ot(n,oa);break;case"side":ot(n,na);break}return Ts(i)&&(n.value=Number(e),n.type="range",n.min=Math.min(0,n.value),n.max=Math.max(1,n.value),n.step=.01),n}function da(i,e,t,s){const n={type:"string",title:Bt(i),prop:i,value:e,needsUpdate:!0,onChange:(r,l)=>{s.updateObject(t.uuid,`material.${i}`,l),s.updateObject(t.uuid,"material.needsUpdate",!0);const h=s.getScene(t.uuid);if(h!==null){const c=h.getObjectByProperty("uuid",t.uuid);te(c,`material.${i}`,l)}},onKeyDown:r=>{}};return(i==="vertexShader"||i==="fragmentShader")&&(n.disabled=!1,n.latest=n.value,n.onChange=(r,l)=>{n.latest=l,s.updateObject(t.uuid,`material.${i}`,l);const h=s.getScene(t.uuid);if(h!==null){const c=h.getObjectByProperty("uuid",t.uuid);te(c,`material.${i}`,l)}},n.onKeyDown=r=>{if(r.key==="Enter"&&(r.altKey||r.metaKey)){s.updateObject(t.uuid,"material.needsUpdate",!0);const l=s.getScene(t.uuid);if(l!==null){const h=l.getObjectByProperty("uuid",t.uuid);te(h,"material.needsUpdate",!0)}}}),n}function ua(i){return i.x!==void 0&&i.y!==void 0&&i.z===void 0}function pa(i){return i.x!==void 0&&i.y!==void 0&&i.z!==void 0&&i.w===void 0}function ma(i){return i.x!==void 0&&i.y!==void 0&&i.z!==void 0&&i.w!==void 0}function vi(i){i.sort((e,t)=>e.title<t.title?-1:e.title>t.title?1:0)}function gt(i,e,t,s,n="",a=!1){const r=Bt(i).split(".")[0].replaceAll("[","").replaceAll("]",""),l=n.length>0?`${n}.${i}`:i,h=typeof e;if(h==="boolean"||h==="string")return{title:r,prop:l,type:h,value:e,disabled:a,onChange:(c,u)=>{s.updateObject(t.uuid,`material.${l}`,u);const m=s.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);te(f,`material.${l}`,u)}}};if(h==="number"){const c={title:r,prop:l,type:"number",value:e,step:.01,disabled:a,onChange:(u,m)=>{s.updateObject(t.uuid,`material.${l}`,m);const f=s.getScene(t.uuid);if(f!==null){const g=f.getObjectByProperty("uuid",t.uuid);te(g,`material.${l}`,m)}}};return Ts(r)&&(c.type="range",c.min=0,c.max=1),c}else{if(e.isColor)return{title:r,prop:l,type:"color",value:e,disabled:a,onChange:(c,u)=>{const m=new o.Color(u);s.updateObject(t.uuid,`material.${l}`,m);const f=s.getScene(t.uuid);if(f!==null){const g=f.getObjectByProperty("uuid",t.uuid);te(g,`material.${l}`,m)}}};if(Array.isArray(e)){const c=[];for(const u in e){const m=e[u],f=`[${u.toString()}]`;if(m.value!==void 0){const g=gt(`${f}.value`,m.value,t,s,l,a);g!==void 0&&c.push(g)}else{const g=gt(f,m,t,s,l,a);g!==void 0&&c.push(g)}}if(c.length>0)return vi(c),{title:r,items:c}}else{if(ua(e))return{title:r,prop:l,type:"vector2",value:e,disabled:a,onChange:(c,u)=>{s.updateObject(t.uuid,`material.${l}`,u);const m=s.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);te(f,`material.${l}`,u)}}};if(pa(e))return{title:r,prop:l,type:"grid3",value:e,disabled:a,onChange:(c,u)=>{s.updateObject(t.uuid,`material.${l}`,u);const m=s.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);te(f,`material.${l}`,u)}}};if(ma(e))return{title:r,prop:l,type:"grid4",value:e,disabled:a,onChange:(c,u)=>{s.updateObject(t.uuid,`material.${l}`,u);const m=s.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);te(f,`material.${l}`,u)}}};if(e.isEuler)return{title:r,prop:l,type:"euler",value:e,disabled:a,onChange:(c,u)=>{s.updateObject(t.uuid,`material.${l}`,u);const m=s.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);te(f,`material.${l}`,u)}}};if(e.src!==void 0)return{title:r,type:"image",value:e,disabled:a,onChange:(c,u)=>{const m=ia(i),f=n.length>0?`${n}.${m}`:m;s.createTexture(t.uuid,`material.${f}`,u);const g=s.getScene(t.uuid);if(g!==null){const x=g.getObjectByProperty("uuid",t.uuid);if(x!==void 0){const y=T=>{const _=x.material,C=f.split(".");switch(C.length){case 1:_[C[0]]=T;break;case 2:_[C[0]][C[1]]=T;break;case 3:_[C[0]][C[1]][C[2]]=T;break;case 4:_[C[0]][C[1]][C[2]][C[3]]=T;break;case 5:_[C[0]][C[1]][C[2]][C[3]][C[4]]=T;break}_.needsUpdate=!0};u.src.length>0?Es(u.src).then(T=>{T.offset.set(u.offset[0],u.offset[1]),T.repeat.set(u.repeat[0],u.repeat[1]),y(T)}):y(null)}}}};if(e.elements!==void 0)return{title:r,prop:l,type:e.elements.length>9?"grid4":"grid3",value:e,disabled:a,onChange:(c,u)=>{s.updateObject(t.uuid,`material.${l}`,u);const m=s.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);te(f,`material.${l}`,u)}}};{const c=[],u=i==="defines"||i==="extensions";try{for(const m in e){const f=e[m];if(f!==void 0)if(f.value!==void 0){const g=gt(`${m}.value`,f.value,t,s,l,u);g!==void 0&&c.push(g)}else{const g=gt(m,f,t,s,l,u);g!==void 0&&c.push(g)}}}catch{console.log("Issue cycling through material object:",i,e)}if(c.length>0)return vi(c),{title:r,items:c}}}}}function Gi(i,e,t){const s=[];for(const n in i){if(!ta(n))continue;const a=typeof i[n],r=i[n];if(a==="boolean")s.push(ca(n,r,e,t));else if(a==="number")s.push(ha(n,r,e,t));else if(a==="string")s.push(da(n,r,e,t));else if(a==="object"){const l=gt(n,r,e,t);l!==void 0&&s.push(l)}else r!==void 0&&console.log("other:",n,a,r)}return vi(s),s.push({title:"Update Material",type:"button",onChange:()=>{t.updateObject(e.uuid,"material.needsUpdate",!0);const n=t.getScene(e.uuid);if(n!==null){const a=n.getObjectByProperty("uuid",e.uuid);te(a,"material.needsUpdate",!0)}}}),s}function fa(i,e){function t(){return`${e.app.appID}_material`}const s=localStorage.getItem(t()),n=s!==null?s==="open":!1;function a(l){localStorage.setItem(t(),l?"open":"closed")}const r=i.material;if(Array.isArray(r)){const l=[],h=r.length;for(let c=0;c<h;c++)l.push(p.jsx(be,{title:`Material ${c}`,items:Gi(r[c],i,e)},`Material ${c}`));return p.jsx(p.Fragment,{children:l})}else return p.jsx(be,{title:"Material",items:Gi(r,i,e),expanded:n,onToggle:l=>{a(l)}})}const Zi="data:image/gif;base64,R0lGODlhDgFkAIAAAP///wAAACH/C1hNUCBEYXRhWE1QPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgOS4xLWMwMDIgNzkuZGJhM2RhM2I1LCAyMDIzLzEyLzE1LTEwOjQyOjM3ICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdFJlZj0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgMjUuNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDoyMDk3M0NEODAxQjQxMUVGODVGNENDMkUyMUExNDk1NSIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDoyMDk3M0NEOTAxQjQxMUVGODVGNENDMkUyMUExNDk1NSI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkE4ODc3Qzg5MDFCMzExRUY4NUY0Q0MyRTIxQTE0OTU1IiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkE4ODc3QzhBMDFCMzExRUY4NUY0Q0MyRTIxQTE0OTU1Ii8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+Af/+/fz7+vn49/b19PPy8fDv7u3s6+rp6Ofm5eTj4uHg397d3Nva2djX1tXU09LR0M/OzczLysnIx8bFxMPCwcC/vr28u7q5uLe2tbSzsrGwr66trKuqqainpqWko6KhoJ+enZybmpmYl5aVlJOSkZCPjo2Mi4qJiIeGhYSDgoGAf359fHt6eXh3dnV0c3JxcG9ubWxramloZ2ZlZGNiYWBfXl1cW1pZWFdWVVRTUlFQT05NTEtKSUhHRkVEQ0JBQD8+PTw7Ojk4NzY1NDMyMTAvLi0sKyopKCcmJSQjIiEgHx4dHBsaGRgXFhUUExIREA8ODQwLCgkIBwYFBAMCAQAAIfkEAAAAAAAsAAAAAA4BZAAAAv+Mj6nL7Q+jnLTai7PevPsPhuJIluaJpurKtu4Lx/JM1/aN5/rO9/4PDAqHxKLxiEwql8ym8wmNSqfUqvWKzWq33K73Cw6Lx+Sy+YxOq9fstvsNj8vn9Lr9js/r9/y+/w8YKDhIWGh4iJiouMjY6PgIGSk5SVlpeYmZqTkJAGDQ+dnpuekmGgAKejpKuiZqmprKqoZKGyrbOlqrejub6xvLGyw8TFzcprurGuvqybxq7ETbrItsCz0l7Zpc+6p9/cS967w9/S2FTF0u/mzehK4Oqz3eTl9vf4+fr7/P3+//DzCgwIEECxo8iDChwoUMGzp8CDGixIkUK1q8iDGjxo0XHDt6/AgypMiRJEuaPIkypcqVLFt+KwAAOw==";function ga(i){const e=i.step!==void 0?i.step:.01,t=O.useRef(null),s=O.useRef(null),n=O.useRef(null),a=O.useRef(null),r=O.useRef(null),[l]=O.useState(i.value),[h,c]=O.useState(i.value.offset[0]),[u,m]=O.useState(i.value.offset[1]),[f,g]=O.useState(i.value.repeat[0]),[x,y]=O.useState(i.value.repeat[1]);function T(C,E,S,w,M){if(i.onChange!==void 0){const I=i.prop!==void 0?i.prop:i.title;i.onChange(I,{src:C,offset:[E,S],repeat:[w,M]})}}function _(C){const E=t.current.src,S=C.target.value;switch(C.target){case s.current:c(S),T(E,S,u,f,x);break;case n.current:m(S),T(E,h,S,f,x);break;case a.current:g(S),T(E,h,u,S,x);break;case r.current:y(S),T(E,h,u,f,S);break}}return p.jsxs("div",{className:"imageField",children:[p.jsx("img",{alt:i.title,ref:t,onClick:()=>{sa().then(C=>{t.current.src=C,T(C,h,u,f,x)})},src:l.src.length>0?l.src:Zi}),p.jsxs("div",{className:"fields",children:[p.jsxs("div",{children:[p.jsx("label",{children:"Offset:"}),p.jsx("input",{ref:s,type:"number",value:h,step:e,onChange:_}),p.jsx("input",{ref:n,type:"number",value:u,step:e,onChange:_})]}),p.jsxs("div",{children:[p.jsx("label",{children:"Repeat:"}),p.jsx("input",{ref:a,type:"number",value:f,step:e,onChange:_}),p.jsx("input",{ref:r,type:"number",value:x,step:e,onChange:_})]}),p.jsx("button",{onClick:()=>{T("",h,u,f,x),t.current.src=Zi},children:"Clear"})]})]})}function jt(i){let e=i.value;e!==void 0&&(e.isColor!==void 0?e=ui(i.value):i.type==="color"&&(e=ui(new o.Color().setStyle(i.value,o.LinearSRGBColorSpace))));const[t,s]=O.useState(e),n=O.useRef(null),a=c=>{let u=c.target.value;if(i.type==="boolean")u=c.target.checked;else if(i.type==="option"&&(typeof i.value=="number"?u=Number(u):typeof i.value=="boolean"?u=!!u:typeof i.value=="object"&&(u=JSON.parse(u)),i.options!==void 0)){const m=i.options.length;for(let f=0;f<m&&i.options[f].value!==u;f++);}s(u),i.onChange!==void 0&&i.onChange(i.prop!==void 0?i.prop:i.title,u)},r={};i.disabled&&(r.opacity=.8);const l=i.type==="string"&&(t.length>100||t.search(`
47
+ `)>-1),h=l||i.type==="image"||i.type==="vector2";return p.jsxs("div",{className:`field ${h?"block":""}`,style:r,children:[i.type!=="button"&&p.jsx("label",{ref:n,children:bt(i.title)},"fieldLabel"),i.type==="string"&&!l&&p.jsx("input",{type:"text",disabled:i.disabled,onChange:a,value:t}),i.type==="string"&&l&&p.jsx("textarea",{cols:50,rows:10,disabled:i.disabled!==void 0?i.disabled:!0,onChange:a,onKeyDown:c=>{i.onKeyDown!==void 0&&i.onKeyDown(c)},value:t}),i.type==="boolean"&&p.jsx("input",{type:"checkbox",disabled:i.disabled,onChange:a,checked:t}),i.type==="number"&&p.jsx(Be,{value:t,type:i.type,prop:i.prop!==void 0?i.prop:i.title,min:i.min,max:i.max,step:i.step,disabled:i.disabled,labelRef:n,onChange:i.onChange}),i.type==="range"&&p.jsx(Be,{value:t,type:i.type,prop:i.prop!==void 0?i.prop:i.title,min:i.min,max:i.max,step:i.step,disabled:i.disabled,labelRef:n,onChange:i.onChange}),i.type==="color"&&p.jsxs(p.Fragment,{children:[p.jsx("input",{type:"text",value:t.toString(),onChange:a,disabled:i.disabled,className:"color"}),p.jsx("input",{type:"color",value:t,onChange:a,disabled:i.disabled})]}),i.type==="button"&&p.jsx("button",{disabled:i.disabled,onClick:()=>{i.onChange!==void 0&&i.onChange(i.prop!==void 0?i.prop:i.title,!0)},children:i.title}),i.type==="image"&&p.jsx(ga,{title:i.title,prop:i.prop,value:i.value,onChange:i.onChange}),i.type==="option"&&p.jsx(p.Fragment,{children:p.jsx("select",{onChange:a,disabled:i.disabled,defaultValue:i.value,children:i.options?.map((c,u)=>p.jsx("option",{value:c.value,children:bt(c.title)},u))})}),i.type==="vector2"&&p.jsx(Qn,{step:i.step,value:t,min:0,max:1,onChange:a}),i.type==="grid3"&&p.jsx(Yi,{step:i.step,value:t,onChange:a}),i.type==="grid4"&&p.jsx(ea,{step:i.step,value:t,onChange:a}),i.type==="euler"&&p.jsx(Yi,{step:i.step,value:t,onChange:a})]})}function _a(i){return"items"in i}class be extends O.Component{subgroupNames=[];subgroupElements=[];valueOverrides=new Map;constructor(e){super(e),this.state={lastUpdated:Date.now()}}addGroup(e){const t=[];e.items.forEach(a=>{t.push({type:a.type,prop:a.prop,title:a.title!==void 0?a.title:a.prop,value:a.value,min:a.min,max:a.max,step:a.step,options:a.options,disabled:a.disabled,onChange:(r,l)=>{e.onUpdate(r,l)}})});const s=O.createRef(),n=p.jsx(be,{ref:s,title:e.title,items:t},Math.random());return this.subgroupNames.push(e.title),this.subgroupElements.push(n),this.setState({lastUpdated:Date.now()}),s}removeGroup(e){const t=this.subgroupNames.length;for(let s=0;s<t;s++){const n=this.subgroupNames[s];if(e===n){this.subgroupNames.splice(s,1),this.subgroupElements.splice(s,1),this.setState({lastUpdated:Date.now()});return}}}setField(e,t){this.valueOverrides.set(e,t),this.setState({lastUpdated:Date.now()})}render(){const e=[];return this.props.items.forEach(t=>{if(_a(t))e.push(p.jsx(be,{title:bt(t.title),items:t.items},Math.random()));else{const s=this.valueOverrides.get(t.title),n=s!==void 0?s:t.value;e.push(p.jsx(jt,{title:t.title,prop:t.prop,value:n,type:t.type,min:t.min,max:t.max,step:t.step,disabled:t.disabled,options:t.options,onChange:(a,r)=>{t.onChange!==void 0&&(this.valueOverrides.delete(t.title),t.onChange(a,r))},onKeyDown:a=>{t.onKeyDown!==void 0&&t.onKeyDown(a)}},Math.random()))}}),this.subgroupElements.forEach(t=>e.push(t)),p.jsx(Et,{label:this.props.title,open:this.props.expanded===!0,onToggle:t=>{this.props.onToggle&&this.props?.onToggle(t)},children:e})}}class J extends O.Component{static instance;static groups=[];static groupsRefs=[];static groupTitles=[];constructor(e){super(e),this.state={lastUpdate:Date.now()},J.instance=this,R.addEventListener(P.ADD_GROUP,this.addGroup),R.addEventListener(P.REMOVE_GROUP,this.removeGroup)}componentWillUnmount(){R.removeEventListener(P.ADD_GROUP,this.addGroup),R.removeEventListener(P.REMOVE_GROUP,this.removeGroup)}render(){return p.jsx("div",{className:"customGroups",children:J.groups},this.state.lastUpdate)}addGroup=e=>{const t=JSON.parse(e.value),s=[];t.items.forEach(n=>{s.push({type:n.type,prop:n.prop,title:n.title!==void 0?n.title:n.prop,value:n.value,min:n.min,max:n.max,step:n.step,options:n.options,disabled:n.disabled,onChange:(a,r)=>{this.props.three.updateGroup(t.title,a,r)}})}),J.groups.push(p.jsx(be,{title:t.title,items:s},Math.random())),J.groupTitles.push(t.title),this.setState({lastUpdate:Date.now()})};removeGroup=e=>{const t=e.value,s=J.groupTitles.length;for(let n=0;n<s;n++)if(t===J.groupTitles[n]){J.groups.splice(n,1),J.groupTitles.splice(n,1),this.setState({lastUpdate:Date.now()});return}};static addEditorGroup(e){const t=[];e.items.forEach(a=>{t.push({type:a.type,prop:a.prop,title:a.title!==void 0?a.title:a.prop,value:a.value,min:a.min,max:a.max,step:a.step,options:a.options,disabled:a.disabled,onChange:(r,l)=>{e.onUpdate(r,l)}})});const s=O.createRef(),n=p.jsx(be,{ref:s,title:e.title,items:t},Math.random());return J.groups.push(n),J.groupsRefs.push(s),J.groupTitles.push(e.title),s}static removeEditorGroup(e){const t=J.groupTitles.length;for(let s=0;s<t;s++)if(e===J.groupTitles[s]){J.groups.splice(s,1),J.groupTitles.splice(s,1),J.instance.setState({lastUpdate:Date.now()});return}}}function Wi(i){switch(i){case"fov":return"FOV";case"zoom":return"Zoom";case"near":return"Near";case"far":return"Far";case"focus":return"Focus";case"aspect":return"Aspect";case"filmGauge":return"Film Gauge";case"filmOffset":return"Film Offset";case"left":return"Left";case"right":return"Right";case"top":return"Top";case"bottom":return"Bottom"}return i}function va(i,e){function t(){return`${e.app.appID}_camera`}const s=localStorage.getItem(t()),n=s!==null?s==="open":!1;function a(l){localStorage.setItem(t(),l?"open":"closed")}const r=[];if(i.perspectiveCameraInfo!==void 0)for(const l in i.perspectiveCameraInfo)r.push({title:Wi(l),prop:l,type:"number",step:.01,value:i.perspectiveCameraInfo[l],onChange:(h,c)=>{e.updateObject(i.uuid,h,c),e.requestMethod(i.uuid,"updateProjectionMatrix");const u=e.getScene(i.uuid);if(u!==null){const m=u.getObjectByProperty("uuid",i.uuid);m!==void 0&&(te(m,h,c),m.updateProjectionMatrix())}}});else if(i.orthographicCameraInfo!==void 0)for(const l in i.orthographicCameraInfo)r.push({title:Wi(l),prop:l,type:"number",step:.01,value:i.orthographicCameraInfo[l],onChange:(h,c)=>{e.updateObject(i.uuid,h,c),e.requestMethod(i.uuid,"updateProjectionMatrix");const u=e.getScene(i.uuid);if(u!==null){const m=u.getObjectByProperty("uuid",i.uuid);m!==void 0&&(te(m,h,c),m.updateProjectionMatrix())}}});return p.jsx(be,{title:"Camera",items:r,expanded:n,onToggle:l=>{a(l)}})}class ya extends o.Line{constructor(e,t){const s=[1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],n=new o.BufferGeometry;n.setAttribute("position",new o.Float32BufferAttribute(s,3)),n.computeBoundingSphere();const a=new o.LineBasicMaterial({fog:!1});super(n,a),this.light=e,this.color=t,this.type="RectAreaLightHelper";const r=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],l=new o.BufferGeometry;l.setAttribute("position",new o.Float32BufferAttribute(r,3)),l.computeBoundingSphere(),this.add(new o.Mesh(l,new o.MeshBasicMaterial({side:o.BackSide,fog:!1})))}updateMatrixWorld(){if(this.scale.set(.5*this.light.width,.5*this.light.height,1),this.color!==void 0)this.material.color.set(this.color),this.children[0].material.color.set(this.color);else{this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);const e=this.material.color,t=Math.max(e.r,e.g,e.b);t>1&&e.multiplyScalar(1/t),this.children[0].material.color.copy(this.material.color)}this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld),this.children[0].matrixWorld.copy(this.matrixWorld)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const Xi={type:"change"},wi={type:"start"},Ms={type:"end"},Mt=new o.Ray,qi=new o.Plane,Ca=Math.cos(70*o.MathUtils.DEG2RAD),ae=new o.Vector3,me=2*Math.PI,Y={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},ti=1e-6;class ba extends o.Controls{constructor(e,t=null){super(e,t),this.state=Y.NONE,this.enabled=!0,this.target=new o.Vector3,this.cursor=new o.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:o.MOUSE.ROTATE,MIDDLE:o.MOUSE.DOLLY,RIGHT:o.MOUSE.PAN},this.touches={ONE:o.TOUCH.ROTATE,TWO:o.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new o.Vector3,this._lastQuaternion=new o.Quaternion,this._lastTargetPosition=new o.Vector3,this._quat=new o.Quaternion().setFromUnitVectors(e.up,new o.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new o.Spherical,this._sphericalDelta=new o.Spherical,this._scale=1,this._panOffset=new o.Vector3,this._rotateStart=new o.Vector2,this._rotateEnd=new o.Vector2,this._rotateDelta=new o.Vector2,this._panStart=new o.Vector2,this._panEnd=new o.Vector2,this._panDelta=new o.Vector2,this._dollyStart=new o.Vector2,this._dollyEnd=new o.Vector2,this._dollyDelta=new o.Vector2,this._dollyDirection=new o.Vector3,this._mouse=new o.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Sa.bind(this),this._onPointerDown=Ea.bind(this),this._onPointerUp=wa.bind(this),this._onContextMenu=Ra.bind(this),this._onMouseWheel=Ta.bind(this),this._onKeyDown=Ma.bind(this),this._onTouchStart=Aa.bind(this),this._onTouchMove=Pa.bind(this),this._onMouseDown=xa.bind(this),this._onMouseMove=Oa.bind(this),this._interceptControlDown=Da.bind(this),this._interceptControlUp=Ia.bind(this),this.domElement!==null&&this.connect(),this.update()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Xi),this.update(),this.state=Y.NONE}update(e=null){const t=this.object.position;ae.copy(t).sub(this.target),ae.applyQuaternion(this._quat),this._spherical.setFromVector3(ae),this.autoRotate&&this.state===Y.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let s=this.minAzimuthAngle,n=this.maxAzimuthAngle;isFinite(s)&&isFinite(n)&&(s<-Math.PI?s+=me:s>Math.PI&&(s-=me),n<-Math.PI?n+=me:n>Math.PI&&(n-=me),s<=n?this._spherical.theta=Math.max(s,Math.min(n,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(s+n)/2?Math.max(s,this._spherical.theta):Math.min(n,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let a=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const r=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),a=r!=this._spherical.radius}if(ae.setFromSpherical(this._spherical),ae.applyQuaternion(this._quatInverse),t.copy(this.target).add(ae),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let r=null;if(this.object.isPerspectiveCamera){const l=ae.length();r=this._clampDistance(l*this._scale);const h=l-r;this.object.position.addScaledVector(this._dollyDirection,h),this.object.updateMatrixWorld(),a=!!h}else if(this.object.isOrthographicCamera){const l=new o.Vector3(this._mouse.x,this._mouse.y,0);l.unproject(this.object);const h=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),a=h!==this.object.zoom;const c=new o.Vector3(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(l),this.object.updateMatrixWorld(),r=ae.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;r!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(r).add(this.object.position):(Mt.origin.copy(this.object.position),Mt.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Mt.direction))<Ca?this.object.lookAt(this.target):(qi.setFromNormalAndCoplanarPoint(this.object.up,this.target),Mt.intersectPlane(qi,this.target))))}else if(this.object.isOrthographicCamera){const r=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),r!==this.object.zoom&&(this.object.updateProjectionMatrix(),a=!0)}return this._scale=1,this._performCursorZoom=!1,a||this._lastPosition.distanceToSquared(this.object.position)>ti||8*(1-this._lastQuaternion.dot(this.object.quaternion))>ti||this._lastTargetPosition.distanceToSquared(this.target)>ti?(this.dispatchEvent(Xi),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?me/60*this.autoRotateSpeed*e:me/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){ae.setFromMatrixColumn(t,0),ae.multiplyScalar(-e),this._panOffset.add(ae)}_panUp(e,t){this.screenSpacePanning===!0?ae.setFromMatrixColumn(t,1):(ae.setFromMatrixColumn(t,0),ae.crossVectors(this.object.up,ae)),ae.multiplyScalar(e),this._panOffset.add(ae)}_pan(e,t){const s=this.domElement;if(this.object.isPerspectiveCamera){const n=this.object.position;ae.copy(n).sub(this.target);let a=ae.length();a*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*a/s.clientHeight,this.object.matrix),this._panUp(2*t*a/s.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/s.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/s.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const s=this.domElement.getBoundingClientRect(),n=e-s.left,a=t-s.top,r=s.width,l=s.height;this._mouse.x=n/r*2-1,this._mouse.y=-(a/l)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(me*this._rotateDelta.x/t.clientHeight),this._rotateUp(me*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateUp(me*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateUp(-me*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateLeft(me*this.rotateSpeed/this.domElement.clientHeight):this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateLeft(-me*this.rotateSpeed/this.domElement.clientHeight):this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._rotateStart.set(s,n)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panStart.set(s,n)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),s=e.pageX-t.x,n=e.pageY-t.y,a=Math.sqrt(s*s+n*n);this._dollyStart.set(0,a)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const s=this._getSecondPointerPosition(e),n=.5*(e.pageX+s.x),a=.5*(e.pageY+s.y);this._rotateEnd.set(n,a)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(me*this._rotateDelta.x/t.clientHeight),this._rotateUp(me*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panEnd.set(s,n)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),s=e.pageX-t.x,n=e.pageY-t.y,a=Math.sqrt(s*s+n*n);this._dollyEnd.set(0,a),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const r=(e.pageX+t.x)*.5,l=(e.pageY+t.y)*.5;this._updateZoomParameters(r,l)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new o.Vector2,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,s={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:s.deltaY*=16;break;case 2:s.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(s.deltaY*=10),s}}function Ea(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i)))}function Sa(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function wa(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Ms),this.state=Y.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function xa(i){let e;switch(i.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case o.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=Y.DOLLY;break;case o.MOUSE.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=Y.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=Y.ROTATE}break;case o.MOUSE.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=Y.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=Y.PAN}break;default:this.state=Y.NONE}this.state!==Y.NONE&&this.dispatchEvent(wi)}function Oa(i){switch(this.state){case Y.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case Y.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case Y.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function Ta(i){this.enabled===!1||this.enableZoom===!1||this.state!==Y.NONE||(i.preventDefault(),this.dispatchEvent(wi),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(Ms))}function Ma(i){this.enabled===!1||this.enablePan===!1||this._handleKeyDown(i)}function Aa(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case o.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=Y.TOUCH_ROTATE;break;case o.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=Y.TOUCH_PAN;break;default:this.state=Y.NONE}break;case 2:switch(this.touches.TWO){case o.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=Y.TOUCH_DOLLY_PAN;break;case o.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=Y.TOUCH_DOLLY_ROTATE;break;default:this.state=Y.NONE}break;default:this.state=Y.NONE}this.state!==Y.NONE&&this.dispatchEvent(wi)}function Pa(i){switch(this._trackPointer(i),this.state){case Y.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case Y.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case Y.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case Y.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=Y.NONE}}function Ra(i){this.enabled!==!1&&i.preventDefault()}function Da(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Ia(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}/*!
48
48
  * camera-controls
49
49
  * https://github.com/yomotsu/camera-controls
50
50
  * (c) 2017 @yomotsu
51
51
  * Released under the MIT License.
52
- */const $={LEFT:1,RIGHT:2,MIDDLE:4},v=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,OFFSET:4,DOLLY:8,ZOOM:16,TOUCH_ROTATE:32,TOUCH_TRUCK:64,TOUCH_OFFSET:128,TOUCH_DOLLY:256,TOUCH_ZOOM:512,TOUCH_DOLLY_TRUCK:1024,TOUCH_DOLLY_OFFSET:2048,TOUCH_DOLLY_ROTATE:4096,TOUCH_ZOOM_TRUCK:8192,TOUCH_ZOOM_OFFSET:16384,TOUCH_ZOOM_ROTATE:32768}),Ke={NONE:0,IN:1,OUT:-1};function Ne(s){return s.isPerspectiveCamera}function Ue(s){return s.isOrthographicCamera}const $e=Math.PI*2,qi=Math.PI/2,Ms=1e-5,lt=Math.PI/180;function Se(s,e,t){return Math.max(e,Math.min(t,s))}function q(s,e=Ms){return Math.abs(s)<e}function V(s,e,t=Ms){return q(s-e,t)}function Qi(s,e){return Math.round(s/e)*e}function ct(s){return isFinite(s)?s:s<0?-Number.MAX_VALUE:Number.MAX_VALUE}function ht(s){return Math.abs(s)<Number.MAX_VALUE?s:s*(1/0)}function Pt(s,e,t,i,n=1/0,r){i=Math.max(1e-4,i);const a=2/i,l=a*r,h=1/(1+l+.48*l*l+.235*l*l*l);let c=s-e;const u=e,m=n*i;c=Se(c,-m,m),e=s-c;const f=(t.value+a*c)*r;t.value=(t.value-a*f)*h;let g=e+(c+f)*h;return u-s>0==g>u&&(g=u,t.value=(g-u)/r),g}function Ki(s,e,t,i,n=1/0,r,a){i=Math.max(1e-4,i);const l=2/i,h=l*r,c=1/(1+h+.48*h*h+.235*h*h*h);let u=e.x,m=e.y,f=e.z,g=s.x-u,x=s.y-m,y=s.z-f;const T=u,_=m,C=f,E=n*i,S=E*E,w=g*g+x*x+y*y;if(w>S){const X=Math.sqrt(w);g=g/X*E,x=x/X*E,y=y/X*E}u=s.x-g,m=s.y-x,f=s.z-y;const M=(t.x+l*g)*r,I=(t.y+l*x)*r,U=(t.z+l*y)*r;t.x=(t.x-l*M)*c,t.y=(t.y-l*I)*c,t.z=(t.z-l*U)*c,a.x=u+(g+M)*c,a.y=m+(x+I)*c,a.z=f+(y+U)*c;const D=T-s.x,B=_-s.y,_e=C-s.z,pe=a.x-T,ne=a.y-_,Q=a.z-C;return D*pe+B*ne+_e*Q>0&&(a.x=T,a.y=_,a.z=C,t.x=(a.x-T)/r,t.y=(a.y-_)/r,t.z=(a.z-C)/r),a}function ii(s,e){e.set(0,0),s.forEach(t=>{e.x+=t.clientX,e.y+=t.clientY}),e.x/=s.length,e.y/=s.length}function si(s,e){return Ue(s)?(console.warn(`${e} is not supported in OrthographicCamera`),!0):!1}class La{constructor(){this._listeners={}}addEventListener(e,t){const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners[e];if(n!==void 0){const r=n.indexOf(t);r!==-1&&n.splice(r,1)}}removeAllEventListeners(e){if(!e){this._listeners={};return}Array.isArray(this._listeners[e])&&(this._listeners[e].length=0)}dispatchEvent(e){const i=this._listeners[e.type];if(i!==void 0){e.target=this;const n=i.slice(0);for(let r=0,a=n.length;r<a;r++)n[r].call(this,e)}}}var ni;const ka="2.9.0",At=1/8,Ua=/Mac/.test((ni=globalThis?.navigator)===null||ni===void 0?void 0:ni.platform);let L,$i,Rt,ai,fe,j,z,Je,dt,we,xe,Fe,Ji,es,ye,ut,et,ts,ri,is,oi,li,Dt;class Me extends La{static install(e){L=e.THREE,$i=Object.freeze(new L.Vector3(0,0,0)),Rt=Object.freeze(new L.Vector3(0,1,0)),ai=Object.freeze(new L.Vector3(0,0,1)),fe=new L.Vector2,j=new L.Vector3,z=new L.Vector3,Je=new L.Vector3,dt=new L.Vector3,we=new L.Vector3,xe=new L.Vector3,Fe=new L.Vector3,Ji=new L.Vector3,es=new L.Vector3,ye=new L.Spherical,ut=new L.Spherical,et=new L.Box3,ts=new L.Box3,ri=new L.Sphere,is=new L.Quaternion,oi=new L.Quaternion,li=new L.Matrix4,Dt=new L.Raycaster}static get ACTION(){return v}constructor(e,t){super(),this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.minDistance=Number.EPSILON,this.maxDistance=1/0,this.infinityDolly=!1,this.minZoom=.01,this.maxZoom=1/0,this.smoothTime=.25,this.draggingSmoothTime=.125,this.maxSpeed=1/0,this.azimuthRotateSpeed=1,this.polarRotateSpeed=1,this.dollySpeed=1,this.dollyDragInverted=!1,this.truckSpeed=2,this.dollyToCursor=!1,this.dragToOffset=!1,this.verticalDragToForward=!1,this.boundaryFriction=0,this.restThreshold=.01,this.colliderMeshes=[],this.cancel=()=>{},this._enabled=!0,this._state=v.NONE,this._viewport=null,this._changedDolly=0,this._changedZoom=0,this._hasRested=!0,this._boundaryEnclosesCamera=!1,this._needsUpdate=!0,this._updatedLastTime=!1,this._elementRect=new DOMRect,this._isDragging=!1,this._dragNeedsUpdate=!0,this._activePointers=[],this._lockedPointer=null,this._interactiveArea=new DOMRect(0,0,1,1),this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._isUserControllingOffset=!1,this._isUserControllingZoom=!1,this._lastDollyDirection=Ke.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new L.Vector3,this._focalOffsetVelocity=new L.Vector3,this._zoomVelocity={value:0},this._truckInternal=(_,C,E)=>{let S,w;if(Ne(this._camera)){const M=j.copy(this._camera.position).sub(this._target),I=this._camera.getEffectiveFOV()*lt,U=M.length()*Math.tan(I*.5);S=this.truckSpeed*_*U/this._elementRect.height,w=this.truckSpeed*C*U/this._elementRect.height}else if(Ue(this._camera)){const M=this._camera;S=_*(M.right-M.left)/M.zoom/this._elementRect.width,w=C*(M.top-M.bottom)/M.zoom/this._elementRect.height}else return;this.verticalDragToForward?(E?this.setFocalOffset(this._focalOffsetEnd.x+S,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(S,0,!0),this.forward(-w,!0)):E?this.setFocalOffset(this._focalOffsetEnd.x+S,this._focalOffsetEnd.y+w,this._focalOffsetEnd.z,!0):this.truck(S,w,!0)},this._rotateInternal=(_,C)=>{const E=$e*this.azimuthRotateSpeed*_/this._elementRect.height,S=$e*this.polarRotateSpeed*C/this._elementRect.height;this.rotate(E,S,!0)},this._dollyInternal=(_,C,E)=>{const S=Math.pow(.95,-_*this.dollySpeed),w=this._sphericalEnd.radius,M=this._sphericalEnd.radius*S,I=Se(M,this.minDistance,this.maxDistance),U=I-M;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(M,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(U,!0),this._dollyToNoClamp(I,!0)):this._dollyToNoClamp(I,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?M:I)-w,this._dollyControlCoord.set(C,E)),this._lastDollyDirection=Math.sign(-_)},this._zoomInternal=(_,C,E)=>{const S=Math.pow(.95,_*this.dollySpeed),w=this._zoom,M=this._zoom*S;this.zoomTo(M,!0),this.dollyToCursor&&(this._changedZoom+=M-w,this._dollyControlCoord.set(C,E))},typeof L>"u"&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=e,this._yAxisUpSpace=new L.Quaternion().setFromUnitVectors(this._camera.up,Rt),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=v.NONE,this._target=new L.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new L.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new L.Spherical().setFromVector3(j.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._lastDistance=this._spherical.radius,this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._lastZoom=this._zoom,this._nearPlaneCorners=[new L.Vector3,new L.Vector3,new L.Vector3,new L.Vector3],this._updateNearPlaneCorners(),this._boundary=new L.Box3(new L.Vector3(-1/0,-1/0,-1/0),new L.Vector3(1/0,1/0,1/0)),this._cameraUp0=this._camera.up.clone(),this._target0=this._target.clone(),this._position0=this._camera.position.clone(),this._zoom0=this._zoom,this._focalOffset0=this._focalOffset.clone(),this._dollyControlCoord=new L.Vector2,this.mouseButtons={left:v.ROTATE,middle:v.DOLLY,right:v.TRUCK,wheel:Ne(this._camera)?v.DOLLY:Ue(this._camera)?v.ZOOM:v.NONE},this.touches={one:v.TOUCH_ROTATE,two:Ne(this._camera)?v.TOUCH_DOLLY_TRUCK:Ue(this._camera)?v.TOUCH_ZOOM_TRUCK:v.NONE,three:v.TOUCH_TRUCK};const i=new L.Vector2,n=new L.Vector2,r=new L.Vector2,a=_=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const S=this._domElement.getBoundingClientRect(),w=_.clientX/S.width,M=_.clientY/S.height;if(w<this._interactiveArea.left||w>this._interactiveArea.right||M<this._interactiveArea.top||M>this._interactiveArea.bottom)return}const C=_.pointerType!=="mouse"?null:(_.buttons&$.LEFT)===$.LEFT?$.LEFT:(_.buttons&$.MIDDLE)===$.MIDDLE?$.MIDDLE:(_.buttons&$.RIGHT)===$.RIGHT?$.RIGHT:null;if(C!==null){const S=this._findPointerByMouseButton(C);S&&this._disposePointer(S)}if((_.buttons&$.LEFT)===$.LEFT&&this._lockedPointer)return;const E={pointerId:_.pointerId,clientX:_.clientX,clientY:_.clientY,deltaX:0,deltaY:0,mouseButton:C};this._activePointers.push(E),this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.ownerDocument.addEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",h),this._isDragging=!0,f(_)},l=_=>{_.cancelable&&_.preventDefault();const C=_.pointerId,E=this._lockedPointer||this._findPointerById(C);if(E){if(E.clientX=_.clientX,E.clientY=_.clientY,E.deltaX=_.movementX,E.deltaY=_.movementY,this._state=0,_.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else(!this._isDragging&&this._lockedPointer||this._isDragging&&(_.buttons&$.LEFT)===$.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(_.buttons&$.MIDDLE)===$.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(_.buttons&$.RIGHT)===$.RIGHT&&(this._state=this._state|this.mouseButtons.right);g()}},h=_=>{const C=this._findPointerById(_.pointerId);if(!(C&&C===this._lockedPointer)){if(C&&this._disposePointer(C),_.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=v.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else this._state=v.NONE;x()}};let c=-1;const u=_=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===v.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const M=this._domElement.getBoundingClientRect(),I=_.clientX/M.width,U=_.clientY/M.height;if(I<this._interactiveArea.left||I>this._interactiveArea.right||U<this._interactiveArea.top||U>this._interactiveArea.bottom)return}if(_.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===v.ROTATE||this.mouseButtons.wheel===v.TRUCK){const M=performance.now();c-M<1e3&&this._getClientRect(this._elementRect),c=M}const C=Ua?-1:-3,E=_.deltaMode===1?_.deltaY/C:_.deltaY/(C*10),S=this.dollyToCursor?(_.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,w=this.dollyToCursor?(_.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case v.ROTATE:{this._rotateInternal(_.deltaX,_.deltaY),this._isUserControllingRotate=!0;break}case v.TRUCK:{this._truckInternal(_.deltaX,_.deltaY,!1),this._isUserControllingTruck=!0;break}case v.OFFSET:{this._truckInternal(_.deltaX,_.deltaY,!0),this._isUserControllingOffset=!0;break}case v.DOLLY:{this._dollyInternal(-E,S,w),this._isUserControllingDolly=!0;break}case v.ZOOM:{this._zoomInternal(-E,S,w),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},m=_=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===Me.ACTION.NONE){const C=_ instanceof PointerEvent?_.pointerId:0,E=this._findPointerById(C);E&&this._disposePointer(E),this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h);return}_.preventDefault()}},f=_=>{if(!this._enabled)return;if(ii(this._activePointers,fe),this._getClientRect(this._elementRect),i.copy(fe),n.copy(fe),this._activePointers.length>=2){const E=fe.x-this._activePointers[1].clientX,S=fe.y-this._activePointers[1].clientY,w=Math.sqrt(E*E+S*S);r.set(0,w);const M=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,I=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;n.set(M,I)}if(this._state=0,!_)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in _&&_.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else!this._lockedPointer&&(_.buttons&$.LEFT)===$.LEFT&&(this._state=this._state|this.mouseButtons.left),(_.buttons&$.MIDDLE)===$.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(_.buttons&$.RIGHT)===$.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&v.ROTATE)===v.ROTATE||(this._state&v.TOUCH_ROTATE)===v.TOUCH_ROTATE||(this._state&v.TOUCH_DOLLY_ROTATE)===v.TOUCH_DOLLY_ROTATE||(this._state&v.TOUCH_ZOOM_ROTATE)===v.TOUCH_ZOOM_ROTATE)&&(this._sphericalEnd.theta=this._spherical.theta,this._sphericalEnd.phi=this._spherical.phi,this._thetaVelocity.value=0,this._phiVelocity.value=0),((this._state&v.TRUCK)===v.TRUCK||(this._state&v.TOUCH_TRUCK)===v.TOUCH_TRUCK||(this._state&v.TOUCH_DOLLY_TRUCK)===v.TOUCH_DOLLY_TRUCK||(this._state&v.TOUCH_ZOOM_TRUCK)===v.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&v.DOLLY)===v.DOLLY||(this._state&v.TOUCH_DOLLY)===v.TOUCH_DOLLY||(this._state&v.TOUCH_DOLLY_TRUCK)===v.TOUCH_DOLLY_TRUCK||(this._state&v.TOUCH_DOLLY_OFFSET)===v.TOUCH_DOLLY_OFFSET||(this._state&v.TOUCH_DOLLY_ROTATE)===v.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&v.ZOOM)===v.ZOOM||(this._state&v.TOUCH_ZOOM)===v.TOUCH_ZOOM||(this._state&v.TOUCH_ZOOM_TRUCK)===v.TOUCH_ZOOM_TRUCK||(this._state&v.TOUCH_ZOOM_OFFSET)===v.TOUCH_ZOOM_OFFSET||(this._state&v.TOUCH_ZOOM_ROTATE)===v.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&v.OFFSET)===v.OFFSET||(this._state&v.TOUCH_OFFSET)===v.TOUCH_OFFSET||(this._state&v.TOUCH_DOLLY_OFFSET)===v.TOUCH_DOLLY_OFFSET||(this._state&v.TOUCH_ZOOM_OFFSET)===v.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},g=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,ii(this._activePointers,fe);const C=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,E=C?-C.deltaX:n.x-fe.x,S=C?-C.deltaY:n.y-fe.y;if(n.copy(fe),((this._state&v.ROTATE)===v.ROTATE||(this._state&v.TOUCH_ROTATE)===v.TOUCH_ROTATE||(this._state&v.TOUCH_DOLLY_ROTATE)===v.TOUCH_DOLLY_ROTATE||(this._state&v.TOUCH_ZOOM_ROTATE)===v.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(E,S),this._isUserControllingRotate=!0),(this._state&v.DOLLY)===v.DOLLY||(this._state&v.ZOOM)===v.ZOOM){const w=this.dollyToCursor?(i.x-this._elementRect.x)/this._elementRect.width*2-1:0,M=this.dollyToCursor?(i.y-this._elementRect.y)/this._elementRect.height*-2+1:0,I=this.dollyDragInverted?-1:1;(this._state&v.DOLLY)===v.DOLLY?(this._dollyInternal(I*S*At,w,M),this._isUserControllingDolly=!0):(this._zoomInternal(I*S*At,w,M),this._isUserControllingZoom=!0)}if((this._state&v.TOUCH_DOLLY)===v.TOUCH_DOLLY||(this._state&v.TOUCH_ZOOM)===v.TOUCH_ZOOM||(this._state&v.TOUCH_DOLLY_TRUCK)===v.TOUCH_DOLLY_TRUCK||(this._state&v.TOUCH_ZOOM_TRUCK)===v.TOUCH_ZOOM_TRUCK||(this._state&v.TOUCH_DOLLY_OFFSET)===v.TOUCH_DOLLY_OFFSET||(this._state&v.TOUCH_ZOOM_OFFSET)===v.TOUCH_ZOOM_OFFSET||(this._state&v.TOUCH_DOLLY_ROTATE)===v.TOUCH_DOLLY_ROTATE||(this._state&v.TOUCH_ZOOM_ROTATE)===v.TOUCH_ZOOM_ROTATE){const w=fe.x-this._activePointers[1].clientX,M=fe.y-this._activePointers[1].clientY,I=Math.sqrt(w*w+M*M),U=r.y-I;r.set(0,I);const D=this.dollyToCursor?(n.x-this._elementRect.x)/this._elementRect.width*2-1:0,B=this.dollyToCursor?(n.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&v.TOUCH_DOLLY)===v.TOUCH_DOLLY||(this._state&v.TOUCH_DOLLY_ROTATE)===v.TOUCH_DOLLY_ROTATE||(this._state&v.TOUCH_DOLLY_TRUCK)===v.TOUCH_DOLLY_TRUCK||(this._state&v.TOUCH_DOLLY_OFFSET)===v.TOUCH_DOLLY_OFFSET?(this._dollyInternal(U*At,D,B),this._isUserControllingDolly=!0):(this._zoomInternal(U*At,D,B),this._isUserControllingZoom=!0)}((this._state&v.TRUCK)===v.TRUCK||(this._state&v.TOUCH_TRUCK)===v.TOUCH_TRUCK||(this._state&v.TOUCH_DOLLY_TRUCK)===v.TOUCH_DOLLY_TRUCK||(this._state&v.TOUCH_ZOOM_TRUCK)===v.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(E,S,!1),this._isUserControllingTruck=!0),((this._state&v.OFFSET)===v.OFFSET||(this._state&v.TOUCH_OFFSET)===v.TOUCH_OFFSET||(this._state&v.TOUCH_DOLLY_OFFSET)===v.TOUCH_DOLLY_OFFSET||(this._state&v.TOUCH_ZOOM_OFFSET)===v.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(E,S,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},x=()=>{ii(this._activePointers,fe),n.copy(fe),this._dragNeedsUpdate=!1,(this._activePointers.length===0||this._activePointers.length===1&&this._activePointers[0]===this._lockedPointer)&&(this._isDragging=!1),this._activePointers.length===0&&this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h),this.dispatchEvent({type:"controlend"}))};this.lockPointer=()=>{!this._enabled||!this._domElement||(this.cancel(),this._lockedPointer={pointerId:-1,clientX:0,clientY:0,deltaX:0,deltaY:0,mouseButton:null},this._activePointers.push(this._lockedPointer),this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",y),this._domElement.ownerDocument.addEventListener("pointerlockerror",T),this._domElement.ownerDocument.addEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",h),f())},this.unlockPointer=()=>{var _,C,E;this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),(_=this._domElement)===null||_===void 0||_.ownerDocument.exitPointerLock(),(C=this._domElement)===null||C===void 0||C.ownerDocument.removeEventListener("pointerlockchange",y),(E=this._domElement)===null||E===void 0||E.ownerDocument.removeEventListener("pointerlockerror",T),this.cancel()};const y=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},T=()=>{this.unlockPointer()};this._addAllEventListeners=_=>{this._domElement=_,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",a),this._domElement.addEventListener("pointercancel",h),this._domElement.addEventListener("wheel",u,{passive:!1}),this._domElement.addEventListener("contextmenu",m)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",a),this._domElement.removeEventListener("pointercancel",h),this._domElement.removeEventListener("wheel",u,{passive:!1}),this._domElement.removeEventListener("contextmenu",m),this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.ownerDocument.removeEventListener("pointerlockchange",y),this._domElement.ownerDocument.removeEventListener("pointerlockerror",T))},this.cancel=()=>{this._state!==v.NONE&&(this._state=v.NONE,this._activePointers.length=0,x())},t&&this.connect(t),this.update(0)}get camera(){return this._camera}set camera(e){this._camera=e,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this._domElement&&(e?(this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none"):(this.cancel(),this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect=""))}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(e){this._spherical.radius===e&&this._sphericalEnd.radius===e||(this._spherical.radius=e,this._sphericalEnd.radius=e,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(e){this._spherical.theta===e&&this._sphericalEnd.theta===e||(this._spherical.theta=e,this._sphericalEnd.theta=e,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(e){this._spherical.phi===e&&this._sphericalEnd.phi===e||(this._spherical.phi=e,this._sphericalEnd.phi=e,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(e){this._boundaryEnclosesCamera=e,this._needsUpdate=!0}set interactiveArea(e){this._interactiveArea.width=Se(e.width,0,1),this._interactiveArea.height=Se(e.height,0,1),this._interactiveArea.x=Se(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=Se(e.y,0,1-this._interactiveArea.height)}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}rotate(e,t,i=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+t,i)}rotateAzimuthTo(e,t=!1){return this.rotateTo(e,this._sphericalEnd.phi,t)}rotatePolarTo(e,t=!1){return this.rotateTo(this._sphericalEnd.theta,e,t)}rotateTo(e,t,i=!1){this._isUserControllingRotate=!1;const n=Se(e,this.minAzimuthAngle,this.maxAzimuthAngle),r=Se(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=n,this._sphericalEnd.phi=r,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,i||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const a=!i||V(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&V(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(a)}dolly(e,t=!1){return this.dollyTo(this._sphericalEnd.radius-e,t)}dollyTo(e,t=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=Ke.NONE,this._changedDolly=0,this._dollyToNoClamp(Se(e,this.minDistance,this.maxDistance),t)}_dollyToNoClamp(e,t=!1){const i=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const a=this._collisionTest(),l=V(a,this._spherical.radius);if(!(i>e)&&l)return Promise.resolve();this._sphericalEnd.radius=Math.min(e,a)}else this._sphericalEnd.radius=e;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);const r=!t||V(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(r)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(dt).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const i=!t||V(this._target.x,this._targetEnd.x,this.restThreshold)&&V(this._target.y,this._targetEnd.y,this.restThreshold)&&V(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(i)}zoom(e,t=!1){return this.zoomTo(this._zoomEnd+e,t)}zoomTo(e,t=!1){this._isUserControllingZoom=!1,this._zoomEnd=Se(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const i=!t||V(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(i)}pan(e,t,i=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,t,i)}truck(e,t,i=!1){this._camera.updateMatrix(),we.setFromMatrixColumn(this._camera.matrix,0),xe.setFromMatrixColumn(this._camera.matrix,1),we.multiplyScalar(e),xe.multiplyScalar(-t);const n=j.copy(we).add(xe),r=z.copy(this._targetEnd).add(n);return this.moveTo(r.x,r.y,r.z,i)}forward(e,t=!1){j.setFromMatrixColumn(this._camera.matrix,0),j.crossVectors(this._camera.up,j),j.multiplyScalar(e);const i=z.copy(this._targetEnd).add(j);return this.moveTo(i.x,i.y,i.z,t)}elevate(e,t=!1){return j.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+j.x,this._targetEnd.y+j.y,this._targetEnd.z+j.z,t)}moveTo(e,t,i,n=!1){this._isUserControllingTruck=!1;const r=j.set(e,t,i).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,r,this.boundaryFriction),this._needsUpdate=!0,n||this._target.copy(this._targetEnd);const a=!n||V(this._target.x,this._targetEnd.x,this.restThreshold)&&V(this._target.y,this._targetEnd.y,this.restThreshold)&&V(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(a)}lookInDirectionOf(e,t,i,n=!1){const l=j.set(e,t,i).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);return this.setPosition(l.x,l.y,l.z,n)}fitToBox(e,t,{cover:i=!1,paddingLeft:n=0,paddingRight:r=0,paddingBottom:a=0,paddingTop:l=0}={}){const h=[],c=e.isBox3?et.copy(e):et.setFromObject(e);c.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const u=Qi(this._sphericalEnd.theta,qi),m=Qi(this._sphericalEnd.phi,qi);h.push(this.rotateTo(u,m,t));const f=j.setFromSpherical(this._sphericalEnd).normalize(),g=is.setFromUnitVectors(f,ai),x=V(Math.abs(f.y),1);x&&g.multiply(oi.setFromAxisAngle(Rt,u)),g.multiply(this._yAxisUpSpaceInverse);const y=ts.makeEmpty();z.copy(c.min).applyQuaternion(g),y.expandByPoint(z),z.copy(c.min).setX(c.max.x).applyQuaternion(g),y.expandByPoint(z),z.copy(c.min).setY(c.max.y).applyQuaternion(g),y.expandByPoint(z),z.copy(c.max).setZ(c.min.z).applyQuaternion(g),y.expandByPoint(z),z.copy(c.min).setZ(c.max.z).applyQuaternion(g),y.expandByPoint(z),z.copy(c.max).setY(c.min.y).applyQuaternion(g),y.expandByPoint(z),z.copy(c.max).setX(c.min.x).applyQuaternion(g),y.expandByPoint(z),z.copy(c.max).applyQuaternion(g),y.expandByPoint(z),y.min.x-=n,y.min.y-=a,y.max.x+=r,y.max.y+=l,g.setFromUnitVectors(ai,f),x&&g.premultiply(oi.invert()),g.premultiply(this._yAxisUpSpace);const T=y.getSize(j),_=y.getCenter(z).applyQuaternion(g);if(Ne(this._camera)){const C=this.getDistanceToFitBox(T.x,T.y,T.z,i);h.push(this.moveTo(_.x,_.y,_.z,t)),h.push(this.dollyTo(C,t)),h.push(this.setFocalOffset(0,0,0,t))}else if(Ue(this._camera)){const C=this._camera,E=C.right-C.left,S=C.top-C.bottom,w=i?Math.max(E/T.x,S/T.y):Math.min(E/T.x,S/T.y);h.push(this.moveTo(_.x,_.y,_.z,t)),h.push(this.zoomTo(w,t)),h.push(this.setFocalOffset(0,0,0,t))}return Promise.all(h)}fitToSphere(e,t){const i=[],r="isObject3D"in e?Me.createBoundingSphere(e,ri):ri.copy(e);if(i.push(this.moveTo(r.center.x,r.center.y,r.center.z,t)),Ne(this._camera)){const a=this.getDistanceToFitSphere(r.radius);i.push(this.dollyTo(a,t))}else if(Ue(this._camera)){const a=this._camera.right-this._camera.left,l=this._camera.top-this._camera.bottom,h=2*r.radius,c=Math.min(a/h,l/h);i.push(this.zoomTo(c,t))}return i.push(this.setFocalOffset(0,0,0,t)),Promise.all(i)}setLookAt(e,t,i,n,r,a,l=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Ke.NONE,this._changedDolly=0;const h=z.set(n,r,a),c=j.set(e,t,i);this._targetEnd.copy(h),this._sphericalEnd.setFromVector3(c.sub(h).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,l||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const u=!l||V(this._target.x,this._targetEnd.x,this.restThreshold)&&V(this._target.y,this._targetEnd.y,this.restThreshold)&&V(this._target.z,this._targetEnd.z,this.restThreshold)&&V(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&V(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&V(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(u)}lerpLookAt(e,t,i,n,r,a,l,h,c,u,m,f,g,x=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Ke.NONE,this._changedDolly=0;const y=j.set(n,r,a),T=z.set(e,t,i);ye.setFromVector3(T.sub(y).applyQuaternion(this._yAxisUpSpace));const _=Je.set(u,m,f),C=z.set(l,h,c);ut.setFromVector3(C.sub(_).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(y.lerp(_,g));const E=ut.theta-ye.theta,S=ut.phi-ye.phi,w=ut.radius-ye.radius;this._sphericalEnd.set(ye.radius+w*g,ye.phi+S*g,ye.theta+E*g),this.normalizeRotations(),this._needsUpdate=!0,x||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const M=!x||V(this._target.x,this._targetEnd.x,this.restThreshold)&&V(this._target.y,this._targetEnd.y,this.restThreshold)&&V(this._target.z,this._targetEnd.z,this.restThreshold)&&V(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&V(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&V(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(M)}setPosition(e,t,i,n=!1){return this.setLookAt(e,t,i,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,n)}setTarget(e,t,i,n=!1){const r=this.getPosition(j),a=this.setLookAt(r.x,r.y,r.z,e,t,i,n);return this._sphericalEnd.phi=Se(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),a}setFocalOffset(e,t,i,n=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,t,i),this._needsUpdate=!0,n||this._focalOffset.copy(this._focalOffsetEnd);const r=!n||V(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&V(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&V(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(r)}setOrbitPoint(e,t,i){this._camera.updateMatrixWorld(),we.setFromMatrixColumn(this._camera.matrixWorldInverse,0),xe.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Fe.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const n=j.set(e,t,i),r=n.distanceTo(this._camera.position),a=n.sub(this._camera.position);we.multiplyScalar(a.x),xe.multiplyScalar(a.y),Fe.multiplyScalar(a.z),j.copy(we).add(xe).add(Fe),j.z=j.z+r,this.dollyTo(r,!1),this.setFocalOffset(-j.x,j.y,-j.z,!1),this.moveTo(e,t,i,!1)}setBoundary(e){if(!e){this._boundary.min.set(-1/0,-1/0,-1/0),this._boundary.max.set(1/0,1/0,1/0),this._needsUpdate=!0;return}this._boundary.copy(e),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(e,t,i,n){if(e===null){this._viewport=null;return}this._viewport=this._viewport||new L.Vector4,typeof e=="number"?this._viewport.set(e,t,i,n):this._viewport.copy(e)}getDistanceToFitBox(e,t,i,n=!1){if(si(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const r=e/t,a=this._camera.getEffectiveFOV()*lt,l=this._camera.aspect;return((n?r>l:r<l)?t:e/l)*.5/Math.tan(a*.5)+i*.5}getDistanceToFitSphere(e){if(si(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*lt,i=Math.atan(Math.tan(t*.5)*this._camera.aspect)*2,n=1<this._camera.aspect?t:i;return e/Math.sin(n*.5)}getTarget(e,t=!0){return(e&&e.isVector3?e:new L.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new L.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e||new L.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new L.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%$e,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=$e),this._spherical.theta+=$e*Math.round((this._sphericalEnd.theta-this._spherical.theta)/$e)}stop(){this._focalOffset.copy(this._focalOffsetEnd),this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd),this._zoom=this._zoomEnd}reset(e=!1){if(!V(this._camera.up.x,this._cameraUp0.x)||!V(this._camera.up.y,this._cameraUp0.y)||!V(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const i=this.getPosition(j);this.updateCameraUp(),this.setPosition(i.x,i.y,i.z)}const t=[this.setLookAt(this._position0.x,this._position0.y,this._position0.z,this._target0.x,this._target0.y,this._target0.z,e),this.setFocalOffset(this._focalOffset0.x,this._focalOffset0.y,this._focalOffset0.z,e),this.zoomTo(this._zoom0,e)];return Promise.all(t)}saveState(){this._cameraUp0.copy(this._camera.up),this.getTarget(this._target0),this.getPosition(this._position0),this._zoom0=this._zoom,this._focalOffset0.copy(this._focalOffset)}updateCameraUp(){this._yAxisUpSpace.setFromUnitVectors(this._camera.up,Rt),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const e=j.subVectors(this._target,this._camera.position).normalize(),t=z.crossVectors(e,this._camera.up);this._camera.up.crossVectors(t,e).normalize(),this._camera.updateMatrixWorld();const i=this.getPosition(j);this.updateCameraUp(),this.setPosition(i.x,i.y,i.z)}update(e){const t=this._sphericalEnd.theta-this._spherical.theta,i=this._sphericalEnd.phi-this._spherical.phi,n=this._sphericalEnd.radius-this._spherical.radius,r=Ji.subVectors(this._targetEnd,this._target),a=es.subVectors(this._focalOffsetEnd,this._focalOffset),l=this._zoomEnd-this._zoom;if(q(t))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const m=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=Pt(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,m,1/0,e),this._needsUpdate=!0}if(q(i))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const m=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=Pt(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,m,1/0,e),this._needsUpdate=!0}if(q(n))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const m=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=Pt(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,m,this.maxSpeed,e),this._needsUpdate=!0}if(q(r.x)&&q(r.y)&&q(r.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const m=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;Ki(this._target,this._targetEnd,this._targetVelocity,m,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(q(a.x)&&q(a.y)&&q(a.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const m=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;Ki(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,m,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(q(l))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const m=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=Pt(this._zoom,this._zoomEnd,this._zoomVelocity,m,1/0,e)}if(this.dollyToCursor){if(Ne(this._camera)&&this._changedDolly!==0){const m=this._spherical.radius-this._lastDistance,f=this._camera,g=this._getCameraDirection(dt),x=j.copy(g).cross(f.up).normalize();x.lengthSq()===0&&(x.x=1);const y=z.crossVectors(x,g),T=this._sphericalEnd.radius*Math.tan(f.getEffectiveFOV()*lt*.5),C=(this._sphericalEnd.radius-m-this._sphericalEnd.radius)/this._sphericalEnd.radius,E=Je.copy(this._targetEnd).add(x.multiplyScalar(this._dollyControlCoord.x*T*f.aspect)).add(y.multiplyScalar(this._dollyControlCoord.y*T)),S=j.copy(this._targetEnd).lerp(E,C),w=this._lastDollyDirection===Ke.IN&&this._spherical.radius<=this.minDistance,M=this._lastDollyDirection===Ke.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(w||M)){this._sphericalEnd.radius-=m,this._spherical.radius-=m;const U=z.copy(g).multiplyScalar(-m);S.add(U)}this._boundary.clampPoint(S,S);const I=z.subVectors(S,this._targetEnd);this._targetEnd.copy(S),this._target.add(I),this._changedDolly-=m,q(this._changedDolly)&&(this._changedDolly=0)}else if(Ue(this._camera)&&this._changedZoom!==0){const m=this._zoom-this._lastZoom,f=this._camera,g=j.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(f.near+f.far)/(f.near-f.far)).unproject(f),x=z.set(0,0,-1).applyQuaternion(f.quaternion),y=Je.copy(g).add(x.multiplyScalar(-g.dot(f.up))),_=-(this._zoom-m-this._zoom)/this._zoom,C=this._getCameraDirection(dt),E=this._targetEnd.dot(C),S=j.copy(this._targetEnd).lerp(y,_),w=S.dot(C),M=C.multiplyScalar(w-E);S.sub(M),this._boundary.clampPoint(S,S);const I=z.subVectors(S,this._targetEnd);this._targetEnd.copy(S),this._target.add(I),this._changedZoom-=m,q(this._changedZoom)&&(this._changedZoom=0)}}this._camera.zoom!==this._zoom&&(this._camera.zoom=this._zoom,this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0),this._dragNeedsUpdate=!0;const h=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,h),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!q(this._focalOffset.x)||!q(this._focalOffset.y)||!q(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),we.setFromMatrixColumn(this._camera.matrix,0),xe.setFromMatrixColumn(this._camera.matrix,1),Fe.setFromMatrixColumn(this._camera.matrix,2),we.multiplyScalar(this._focalOffset.x),xe.multiplyScalar(-this._focalOffset.y),Fe.multiplyScalar(this._focalOffset.z),j.copy(we).add(xe).add(Fe),this._camera.position.add(j)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),j.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const u=this._needsUpdate;return u&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):u?(this.dispatchEvent({type:"update"}),q(t,this.restThreshold)&&q(i,this.restThreshold)&&q(n,this.restThreshold)&&q(r.x,this.restThreshold)&&q(r.y,this.restThreshold)&&q(r.z,this.restThreshold)&&q(a.x,this.restThreshold)&&q(a.y,this.restThreshold)&&q(a.z,this.restThreshold)&&q(l,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!u&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=u,this._needsUpdate=!1,u}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:ct(this.maxDistance),minZoom:this.minZoom,maxZoom:ct(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:ct(this.maxPolarAngle),minAzimuthAngle:ct(this.minAzimuthAngle),maxAzimuthAngle:ct(this.maxAzimuthAngle),smoothTime:this.smoothTime,draggingSmoothTime:this.draggingSmoothTime,dollySpeed:this.dollySpeed,truckSpeed:this.truckSpeed,dollyToCursor:this.dollyToCursor,verticalDragToForward:this.verticalDragToForward,target:this._targetEnd.toArray(),position:j.setFromSpherical(this._sphericalEnd).add(this._targetEnd).toArray(),zoom:this._zoomEnd,focalOffset:this._focalOffsetEnd.toArray(),target0:this._target0.toArray(),position0:this._position0.toArray(),zoom0:this._zoom0,focalOffset0:this._focalOffset0.toArray()})}fromJSON(e,t=!1){const i=JSON.parse(e);this.enabled=i.enabled,this.minDistance=i.minDistance,this.maxDistance=ht(i.maxDistance),this.minZoom=i.minZoom,this.maxZoom=ht(i.maxZoom),this.minPolarAngle=i.minPolarAngle,this.maxPolarAngle=ht(i.maxPolarAngle),this.minAzimuthAngle=ht(i.minAzimuthAngle),this.maxAzimuthAngle=ht(i.maxAzimuthAngle),this.smoothTime=i.smoothTime,this.draggingSmoothTime=i.draggingSmoothTime,this.dollySpeed=i.dollySpeed,this.truckSpeed=i.truckSpeed,this.dollyToCursor=i.dollyToCursor,this.verticalDragToForward=i.verticalDragToForward,this._target0.fromArray(i.target0),this._position0.fromArray(i.position0),this._zoom0=i.zoom0,this._focalOffset0.fromArray(i.focalOffset0),this.moveTo(i.target[0],i.target[1],i.target[2],t),ye.setFromVector3(j.fromArray(i.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(ye.theta,ye.phi,t),this.dollyTo(ye.radius,t),this.zoomTo(i.zoom,t),this.setFocalOffset(i.focalOffset[0],i.focalOffset[1],i.focalOffset[2],t),this._needsUpdate=!0}connect(e){if(this._domElement){console.warn("camera-controls is already connected.");return}e.setAttribute("data-camera-controls-version",ka),this._addAllEventListeners(e),this._getClientRect(this._elementRect)}disconnect(){this.cancel(),this._removeAllEventListeners(),this._domElement&&(this._domElement.removeAttribute("data-camera-controls-version"),this._domElement=void 0)}dispose(){this.removeAllEventListeners(),this.disconnect()}_getTargetDirection(e){return e.setFromSpherical(this._spherical).divideScalar(this._spherical.radius).applyQuaternion(this._yAxisUpSpaceInverse)}_getCameraDirection(e){return this._getTargetDirection(e).negate()}_findPointerById(e){return this._activePointers.find(t=>t.pointerId===e)}_findPointerByMouseButton(e){return this._activePointers.find(t=>t.mouseButton===e)}_disposePointer(e){this._activePointers.splice(this._activePointers.indexOf(e),1)}_encloseToBoundary(e,t,i){const n=t.lengthSq();if(n===0)return e;const r=z.copy(t).add(e),l=this._boundary.clampPoint(r,Je).sub(r),h=l.lengthSq();if(h===0)return e.add(t);if(h===n)return e;if(i===0)return e.add(t).add(l);{const c=1+i*h/t.dot(l);return e.add(z.copy(t).multiplyScalar(c)).add(l.multiplyScalar(1-i))}}_updateNearPlaneCorners(){if(Ne(this._camera)){const e=this._camera,t=e.near,i=e.getEffectiveFOV()*lt,n=Math.tan(i*.5)*t,r=n*e.aspect;this._nearPlaneCorners[0].set(-r,-n,0),this._nearPlaneCorners[1].set(r,-n,0),this._nearPlaneCorners[2].set(r,n,0),this._nearPlaneCorners[3].set(-r,n,0)}else if(Ue(this._camera)){const e=this._camera,t=1/e.zoom,i=e.left*t,n=e.right*t,r=e.top*t,a=e.bottom*t;this._nearPlaneCorners[0].set(i,r,0),this._nearPlaneCorners[1].set(n,r,0),this._nearPlaneCorners[2].set(n,a,0),this._nearPlaneCorners[3].set(i,a,0)}}_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||si(this._camera,"_collisionTest"))return e;const i=this._getTargetDirection(dt);li.lookAt($i,i,this._camera.up);for(let n=0;n<4;n++){const r=z.copy(this._nearPlaneCorners[n]);r.applyMatrix4(li);const a=Je.addVectors(this._target,r);Dt.set(a,i),Dt.far=this._spherical.radius+1;const l=Dt.intersectObjects(this.colliderMeshes);l.length!==0&&l[0].distance<e&&(e=l[0].distance)}return e}_getClientRect(e){if(!this._domElement)return;const t=this._domElement.getBoundingClientRect();return e.x=t.left,e.y=t.top,this._viewport?(e.x+=this._viewport.x,e.y+=t.height-this._viewport.w-this._viewport.y,e.width=this._viewport.z,e.height=this._viewport.w):(e.width=t.width,e.height=t.height),e}_createOnRestPromise(e){return e?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:"transitionstart"}),new Promise(t=>{const i=()=>{this.removeEventListener("rest",i),t()};this.addEventListener("rest",i)}))}_addAllEventListeners(e){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(e){console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead.")}get draggingDampingFactor(){return console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead."),0}set draggingDampingFactor(e){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(e,t=new L.Sphere){const i=t,n=i.center;et.makeEmpty(),e.traverseVisible(a=>{a.isMesh&&et.expandByObject(a)}),et.getCenter(n);let r=0;return e.traverseVisible(a=>{if(!a.isMesh)return;const l=a,h=l.geometry.clone();h.applyMatrix4(l.matrixWorld);const u=h.attributes.position;for(let m=0,f=u.count;m<f;m++)j.fromBufferAttribute(u,m),r=Math.max(r,n.distanceToSquared(j))}),i.radius=Math.sqrt(r),i}}const Ht=s=>{const[e,t]=O.useState(s.options[s.index]),i=()=>{s.onToggle(!s.open)},n=r=>{r!==e&&(s.onSelect(r),t(r)),s.onToggle(!1)};return p.jsxs("div",{className:`dropdown ${s.up===!0?"up":""}`,children:[p.jsx("div",{className:"dropdown-toggle",onClick:i,children:`${s.title}: ${e}`}),s.open&&p.jsx("ul",{className:"dropdown-menu",children:s.options.map(r=>p.jsx("li",{onClick:()=>n(r),children:r},r))})]})},ze=O.forwardRef(function(e,t){const i=["Renderer","Depth","Normals","UVs","Wireframe"],[n,r]=O.useState("Renderer"),[a,l]=O.useState(!1),[h,c]=O.useState(!1),[u,m]=O.useState(!1);return p.jsxs("div",{className:`CameraWindow ${e.name}`,children:[p.jsx("div",{ref:t,className:"clickable",onClick:()=>{u&&m(!1)}}),p.jsxs("div",{className:"options",children:[e.camera!==null&&p.jsx(Ht,{title:"Camera",index:e.options.indexOf(e.camera.name),open:u,options:e.options,onSelect:e.onSelectCamera,onToggle:f=>{m(f)},up:!0}),p.jsx(Ht,{title:"Mode",index:i.indexOf(n),open:h,options:i,onSelect:f=>{if(f===n)return;const g=f;e.onSelectRenderMode(g),r(g)},onToggle:f=>{a&&l(!1),c(f)},up:!0})]})]})}),ja=`out vec3 worldPosition;
52
+ */const $={LEFT:1,RIGHT:2,MIDDLE:4},v=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,OFFSET:4,DOLLY:8,ZOOM:16,TOUCH_ROTATE:32,TOUCH_TRUCK:64,TOUCH_OFFSET:128,TOUCH_DOLLY:256,TOUCH_ZOOM:512,TOUCH_DOLLY_TRUCK:1024,TOUCH_DOLLY_OFFSET:2048,TOUCH_DOLLY_ROTATE:4096,TOUCH_ZOOM_TRUCK:8192,TOUCH_ZOOM_OFFSET:16384,TOUCH_ZOOM_ROTATE:32768}),Ke={NONE:0,IN:1,OUT:-1};function Ne(i){return i.isPerspectiveCamera}function Ue(i){return i.isOrthographicCamera}const $e=Math.PI*2,Qi=Math.PI/2,As=1e-5,lt=Math.PI/180;function Se(i,e,t){return Math.max(e,Math.min(t,i))}function q(i,e=As){return Math.abs(i)<e}function V(i,e,t=As){return q(i-e,t)}function Ki(i,e){return Math.round(i/e)*e}function ct(i){return isFinite(i)?i:i<0?-Number.MAX_VALUE:Number.MAX_VALUE}function ht(i){return Math.abs(i)<Number.MAX_VALUE?i:i*(1/0)}function At(i,e,t,s,n=1/0,a){s=Math.max(1e-4,s);const r=2/s,l=r*a,h=1/(1+l+.48*l*l+.235*l*l*l);let c=i-e;const u=e,m=n*s;c=Se(c,-m,m),e=i-c;const f=(t.value+r*c)*a;t.value=(t.value-r*f)*h;let g=e+(c+f)*h;return u-i>0==g>u&&(g=u,t.value=(g-u)/a),g}function $i(i,e,t,s,n=1/0,a,r){s=Math.max(1e-4,s);const l=2/s,h=l*a,c=1/(1+h+.48*h*h+.235*h*h*h);let u=e.x,m=e.y,f=e.z,g=i.x-u,x=i.y-m,y=i.z-f;const T=u,_=m,C=f,E=n*s,S=E*E,w=g*g+x*x+y*y;if(w>S){const X=Math.sqrt(w);g=g/X*E,x=x/X*E,y=y/X*E}u=i.x-g,m=i.y-x,f=i.z-y;const M=(t.x+l*g)*a,I=(t.y+l*x)*a,U=(t.z+l*y)*a;t.x=(t.x-l*M)*c,t.y=(t.y-l*I)*c,t.z=(t.z-l*U)*c,r.x=u+(g+M)*c,r.y=m+(x+I)*c,r.z=f+(y+U)*c;const D=T-i.x,B=_-i.y,_e=C-i.z,pe=r.x-T,ne=r.y-_,Q=r.z-C;return D*pe+B*ne+_e*Q>0&&(r.x=T,r.y=_,r.z=C,t.x=(r.x-T)/a,t.y=(r.y-_)/a,t.z=(r.z-C)/a),r}function ii(i,e){e.set(0,0),i.forEach(t=>{e.x+=t.clientX,e.y+=t.clientY}),e.x/=i.length,e.y/=i.length}function si(i,e){return Ue(i)?(console.warn(`${e} is not supported in OrthographicCamera`),!0):!1}class La{constructor(){this._listeners={}}addEventListener(e,t){const s=this._listeners;s[e]===void 0&&(s[e]=[]),s[e].indexOf(t)===-1&&s[e].push(t)}hasEventListener(e,t){const s=this._listeners;return s[e]!==void 0&&s[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners[e];if(n!==void 0){const a=n.indexOf(t);a!==-1&&n.splice(a,1)}}removeAllEventListeners(e){if(!e){this._listeners={};return}Array.isArray(this._listeners[e])&&(this._listeners[e].length=0)}dispatchEvent(e){const s=this._listeners[e.type];if(s!==void 0){e.target=this;const n=s.slice(0);for(let a=0,r=n.length;a<r;a++)n[a].call(this,e)}}}var ni;const ka="2.9.0",Pt=1/8,Ua=/Mac/.test((ni=globalThis?.navigator)===null||ni===void 0?void 0:ni.platform);let L,Ji,Rt,ai,fe,j,z,Je,dt,we,xe,Fe,es,ts,ye,ut,et,is,ri,ss,oi,li,Dt;class Me extends La{static install(e){L=e.THREE,Ji=Object.freeze(new L.Vector3(0,0,0)),Rt=Object.freeze(new L.Vector3(0,1,0)),ai=Object.freeze(new L.Vector3(0,0,1)),fe=new L.Vector2,j=new L.Vector3,z=new L.Vector3,Je=new L.Vector3,dt=new L.Vector3,we=new L.Vector3,xe=new L.Vector3,Fe=new L.Vector3,es=new L.Vector3,ts=new L.Vector3,ye=new L.Spherical,ut=new L.Spherical,et=new L.Box3,is=new L.Box3,ri=new L.Sphere,ss=new L.Quaternion,oi=new L.Quaternion,li=new L.Matrix4,Dt=new L.Raycaster}static get ACTION(){return v}constructor(e,t){super(),this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.minDistance=Number.EPSILON,this.maxDistance=1/0,this.infinityDolly=!1,this.minZoom=.01,this.maxZoom=1/0,this.smoothTime=.25,this.draggingSmoothTime=.125,this.maxSpeed=1/0,this.azimuthRotateSpeed=1,this.polarRotateSpeed=1,this.dollySpeed=1,this.dollyDragInverted=!1,this.truckSpeed=2,this.dollyToCursor=!1,this.dragToOffset=!1,this.verticalDragToForward=!1,this.boundaryFriction=0,this.restThreshold=.01,this.colliderMeshes=[],this.cancel=()=>{},this._enabled=!0,this._state=v.NONE,this._viewport=null,this._changedDolly=0,this._changedZoom=0,this._hasRested=!0,this._boundaryEnclosesCamera=!1,this._needsUpdate=!0,this._updatedLastTime=!1,this._elementRect=new DOMRect,this._isDragging=!1,this._dragNeedsUpdate=!0,this._activePointers=[],this._lockedPointer=null,this._interactiveArea=new DOMRect(0,0,1,1),this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._isUserControllingOffset=!1,this._isUserControllingZoom=!1,this._lastDollyDirection=Ke.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new L.Vector3,this._focalOffsetVelocity=new L.Vector3,this._zoomVelocity={value:0},this._truckInternal=(_,C,E)=>{let S,w;if(Ne(this._camera)){const M=j.copy(this._camera.position).sub(this._target),I=this._camera.getEffectiveFOV()*lt,U=M.length()*Math.tan(I*.5);S=this.truckSpeed*_*U/this._elementRect.height,w=this.truckSpeed*C*U/this._elementRect.height}else if(Ue(this._camera)){const M=this._camera;S=_*(M.right-M.left)/M.zoom/this._elementRect.width,w=C*(M.top-M.bottom)/M.zoom/this._elementRect.height}else return;this.verticalDragToForward?(E?this.setFocalOffset(this._focalOffsetEnd.x+S,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(S,0,!0),this.forward(-w,!0)):E?this.setFocalOffset(this._focalOffsetEnd.x+S,this._focalOffsetEnd.y+w,this._focalOffsetEnd.z,!0):this.truck(S,w,!0)},this._rotateInternal=(_,C)=>{const E=$e*this.azimuthRotateSpeed*_/this._elementRect.height,S=$e*this.polarRotateSpeed*C/this._elementRect.height;this.rotate(E,S,!0)},this._dollyInternal=(_,C,E)=>{const S=Math.pow(.95,-_*this.dollySpeed),w=this._sphericalEnd.radius,M=this._sphericalEnd.radius*S,I=Se(M,this.minDistance,this.maxDistance),U=I-M;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(M,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(U,!0),this._dollyToNoClamp(I,!0)):this._dollyToNoClamp(I,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?M:I)-w,this._dollyControlCoord.set(C,E)),this._lastDollyDirection=Math.sign(-_)},this._zoomInternal=(_,C,E)=>{const S=Math.pow(.95,_*this.dollySpeed),w=this._zoom,M=this._zoom*S;this.zoomTo(M,!0),this.dollyToCursor&&(this._changedZoom+=M-w,this._dollyControlCoord.set(C,E))},typeof L>"u"&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=e,this._yAxisUpSpace=new L.Quaternion().setFromUnitVectors(this._camera.up,Rt),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=v.NONE,this._target=new L.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new L.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new L.Spherical().setFromVector3(j.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._lastDistance=this._spherical.radius,this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._lastZoom=this._zoom,this._nearPlaneCorners=[new L.Vector3,new L.Vector3,new L.Vector3,new L.Vector3],this._updateNearPlaneCorners(),this._boundary=new L.Box3(new L.Vector3(-1/0,-1/0,-1/0),new L.Vector3(1/0,1/0,1/0)),this._cameraUp0=this._camera.up.clone(),this._target0=this._target.clone(),this._position0=this._camera.position.clone(),this._zoom0=this._zoom,this._focalOffset0=this._focalOffset.clone(),this._dollyControlCoord=new L.Vector2,this.mouseButtons={left:v.ROTATE,middle:v.DOLLY,right:v.TRUCK,wheel:Ne(this._camera)?v.DOLLY:Ue(this._camera)?v.ZOOM:v.NONE},this.touches={one:v.TOUCH_ROTATE,two:Ne(this._camera)?v.TOUCH_DOLLY_TRUCK:Ue(this._camera)?v.TOUCH_ZOOM_TRUCK:v.NONE,three:v.TOUCH_TRUCK};const s=new L.Vector2,n=new L.Vector2,a=new L.Vector2,r=_=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const S=this._domElement.getBoundingClientRect(),w=_.clientX/S.width,M=_.clientY/S.height;if(w<this._interactiveArea.left||w>this._interactiveArea.right||M<this._interactiveArea.top||M>this._interactiveArea.bottom)return}const C=_.pointerType!=="mouse"?null:(_.buttons&$.LEFT)===$.LEFT?$.LEFT:(_.buttons&$.MIDDLE)===$.MIDDLE?$.MIDDLE:(_.buttons&$.RIGHT)===$.RIGHT?$.RIGHT:null;if(C!==null){const S=this._findPointerByMouseButton(C);S&&this._disposePointer(S)}if((_.buttons&$.LEFT)===$.LEFT&&this._lockedPointer)return;const E={pointerId:_.pointerId,clientX:_.clientX,clientY:_.clientY,deltaX:0,deltaY:0,mouseButton:C};this._activePointers.push(E),this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.ownerDocument.addEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",h),this._isDragging=!0,f(_)},l=_=>{_.cancelable&&_.preventDefault();const C=_.pointerId,E=this._lockedPointer||this._findPointerById(C);if(E){if(E.clientX=_.clientX,E.clientY=_.clientY,E.deltaX=_.movementX,E.deltaY=_.movementY,this._state=0,_.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else(!this._isDragging&&this._lockedPointer||this._isDragging&&(_.buttons&$.LEFT)===$.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(_.buttons&$.MIDDLE)===$.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(_.buttons&$.RIGHT)===$.RIGHT&&(this._state=this._state|this.mouseButtons.right);g()}},h=_=>{const C=this._findPointerById(_.pointerId);if(!(C&&C===this._lockedPointer)){if(C&&this._disposePointer(C),_.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=v.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else this._state=v.NONE;x()}};let c=-1;const u=_=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===v.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const M=this._domElement.getBoundingClientRect(),I=_.clientX/M.width,U=_.clientY/M.height;if(I<this._interactiveArea.left||I>this._interactiveArea.right||U<this._interactiveArea.top||U>this._interactiveArea.bottom)return}if(_.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===v.ROTATE||this.mouseButtons.wheel===v.TRUCK){const M=performance.now();c-M<1e3&&this._getClientRect(this._elementRect),c=M}const C=Ua?-1:-3,E=_.deltaMode===1?_.deltaY/C:_.deltaY/(C*10),S=this.dollyToCursor?(_.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,w=this.dollyToCursor?(_.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case v.ROTATE:{this._rotateInternal(_.deltaX,_.deltaY),this._isUserControllingRotate=!0;break}case v.TRUCK:{this._truckInternal(_.deltaX,_.deltaY,!1),this._isUserControllingTruck=!0;break}case v.OFFSET:{this._truckInternal(_.deltaX,_.deltaY,!0),this._isUserControllingOffset=!0;break}case v.DOLLY:{this._dollyInternal(-E,S,w),this._isUserControllingDolly=!0;break}case v.ZOOM:{this._zoomInternal(-E,S,w),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},m=_=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===Me.ACTION.NONE){const C=_ instanceof PointerEvent?_.pointerId:0,E=this._findPointerById(C);E&&this._disposePointer(E),this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h);return}_.preventDefault()}},f=_=>{if(!this._enabled)return;if(ii(this._activePointers,fe),this._getClientRect(this._elementRect),s.copy(fe),n.copy(fe),this._activePointers.length>=2){const E=fe.x-this._activePointers[1].clientX,S=fe.y-this._activePointers[1].clientY,w=Math.sqrt(E*E+S*S);a.set(0,w);const M=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,I=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;n.set(M,I)}if(this._state=0,!_)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in _&&_.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else!this._lockedPointer&&(_.buttons&$.LEFT)===$.LEFT&&(this._state=this._state|this.mouseButtons.left),(_.buttons&$.MIDDLE)===$.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(_.buttons&$.RIGHT)===$.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&v.ROTATE)===v.ROTATE||(this._state&v.TOUCH_ROTATE)===v.TOUCH_ROTATE||(this._state&v.TOUCH_DOLLY_ROTATE)===v.TOUCH_DOLLY_ROTATE||(this._state&v.TOUCH_ZOOM_ROTATE)===v.TOUCH_ZOOM_ROTATE)&&(this._sphericalEnd.theta=this._spherical.theta,this._sphericalEnd.phi=this._spherical.phi,this._thetaVelocity.value=0,this._phiVelocity.value=0),((this._state&v.TRUCK)===v.TRUCK||(this._state&v.TOUCH_TRUCK)===v.TOUCH_TRUCK||(this._state&v.TOUCH_DOLLY_TRUCK)===v.TOUCH_DOLLY_TRUCK||(this._state&v.TOUCH_ZOOM_TRUCK)===v.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&v.DOLLY)===v.DOLLY||(this._state&v.TOUCH_DOLLY)===v.TOUCH_DOLLY||(this._state&v.TOUCH_DOLLY_TRUCK)===v.TOUCH_DOLLY_TRUCK||(this._state&v.TOUCH_DOLLY_OFFSET)===v.TOUCH_DOLLY_OFFSET||(this._state&v.TOUCH_DOLLY_ROTATE)===v.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&v.ZOOM)===v.ZOOM||(this._state&v.TOUCH_ZOOM)===v.TOUCH_ZOOM||(this._state&v.TOUCH_ZOOM_TRUCK)===v.TOUCH_ZOOM_TRUCK||(this._state&v.TOUCH_ZOOM_OFFSET)===v.TOUCH_ZOOM_OFFSET||(this._state&v.TOUCH_ZOOM_ROTATE)===v.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&v.OFFSET)===v.OFFSET||(this._state&v.TOUCH_OFFSET)===v.TOUCH_OFFSET||(this._state&v.TOUCH_DOLLY_OFFSET)===v.TOUCH_DOLLY_OFFSET||(this._state&v.TOUCH_ZOOM_OFFSET)===v.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},g=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,ii(this._activePointers,fe);const C=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,E=C?-C.deltaX:n.x-fe.x,S=C?-C.deltaY:n.y-fe.y;if(n.copy(fe),((this._state&v.ROTATE)===v.ROTATE||(this._state&v.TOUCH_ROTATE)===v.TOUCH_ROTATE||(this._state&v.TOUCH_DOLLY_ROTATE)===v.TOUCH_DOLLY_ROTATE||(this._state&v.TOUCH_ZOOM_ROTATE)===v.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(E,S),this._isUserControllingRotate=!0),(this._state&v.DOLLY)===v.DOLLY||(this._state&v.ZOOM)===v.ZOOM){const w=this.dollyToCursor?(s.x-this._elementRect.x)/this._elementRect.width*2-1:0,M=this.dollyToCursor?(s.y-this._elementRect.y)/this._elementRect.height*-2+1:0,I=this.dollyDragInverted?-1:1;(this._state&v.DOLLY)===v.DOLLY?(this._dollyInternal(I*S*Pt,w,M),this._isUserControllingDolly=!0):(this._zoomInternal(I*S*Pt,w,M),this._isUserControllingZoom=!0)}if((this._state&v.TOUCH_DOLLY)===v.TOUCH_DOLLY||(this._state&v.TOUCH_ZOOM)===v.TOUCH_ZOOM||(this._state&v.TOUCH_DOLLY_TRUCK)===v.TOUCH_DOLLY_TRUCK||(this._state&v.TOUCH_ZOOM_TRUCK)===v.TOUCH_ZOOM_TRUCK||(this._state&v.TOUCH_DOLLY_OFFSET)===v.TOUCH_DOLLY_OFFSET||(this._state&v.TOUCH_ZOOM_OFFSET)===v.TOUCH_ZOOM_OFFSET||(this._state&v.TOUCH_DOLLY_ROTATE)===v.TOUCH_DOLLY_ROTATE||(this._state&v.TOUCH_ZOOM_ROTATE)===v.TOUCH_ZOOM_ROTATE){const w=fe.x-this._activePointers[1].clientX,M=fe.y-this._activePointers[1].clientY,I=Math.sqrt(w*w+M*M),U=a.y-I;a.set(0,I);const D=this.dollyToCursor?(n.x-this._elementRect.x)/this._elementRect.width*2-1:0,B=this.dollyToCursor?(n.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&v.TOUCH_DOLLY)===v.TOUCH_DOLLY||(this._state&v.TOUCH_DOLLY_ROTATE)===v.TOUCH_DOLLY_ROTATE||(this._state&v.TOUCH_DOLLY_TRUCK)===v.TOUCH_DOLLY_TRUCK||(this._state&v.TOUCH_DOLLY_OFFSET)===v.TOUCH_DOLLY_OFFSET?(this._dollyInternal(U*Pt,D,B),this._isUserControllingDolly=!0):(this._zoomInternal(U*Pt,D,B),this._isUserControllingZoom=!0)}((this._state&v.TRUCK)===v.TRUCK||(this._state&v.TOUCH_TRUCK)===v.TOUCH_TRUCK||(this._state&v.TOUCH_DOLLY_TRUCK)===v.TOUCH_DOLLY_TRUCK||(this._state&v.TOUCH_ZOOM_TRUCK)===v.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(E,S,!1),this._isUserControllingTruck=!0),((this._state&v.OFFSET)===v.OFFSET||(this._state&v.TOUCH_OFFSET)===v.TOUCH_OFFSET||(this._state&v.TOUCH_DOLLY_OFFSET)===v.TOUCH_DOLLY_OFFSET||(this._state&v.TOUCH_ZOOM_OFFSET)===v.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(E,S,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},x=()=>{ii(this._activePointers,fe),n.copy(fe),this._dragNeedsUpdate=!1,(this._activePointers.length===0||this._activePointers.length===1&&this._activePointers[0]===this._lockedPointer)&&(this._isDragging=!1),this._activePointers.length===0&&this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h),this.dispatchEvent({type:"controlend"}))};this.lockPointer=()=>{!this._enabled||!this._domElement||(this.cancel(),this._lockedPointer={pointerId:-1,clientX:0,clientY:0,deltaX:0,deltaY:0,mouseButton:null},this._activePointers.push(this._lockedPointer),this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",y),this._domElement.ownerDocument.addEventListener("pointerlockerror",T),this._domElement.ownerDocument.addEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",h),f())},this.unlockPointer=()=>{var _,C,E;this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),(_=this._domElement)===null||_===void 0||_.ownerDocument.exitPointerLock(),(C=this._domElement)===null||C===void 0||C.ownerDocument.removeEventListener("pointerlockchange",y),(E=this._domElement)===null||E===void 0||E.ownerDocument.removeEventListener("pointerlockerror",T),this.cancel()};const y=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},T=()=>{this.unlockPointer()};this._addAllEventListeners=_=>{this._domElement=_,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",r),this._domElement.addEventListener("pointercancel",h),this._domElement.addEventListener("wheel",u,{passive:!1}),this._domElement.addEventListener("contextmenu",m)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",r),this._domElement.removeEventListener("pointercancel",h),this._domElement.removeEventListener("wheel",u,{passive:!1}),this._domElement.removeEventListener("contextmenu",m),this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.ownerDocument.removeEventListener("pointerlockchange",y),this._domElement.ownerDocument.removeEventListener("pointerlockerror",T))},this.cancel=()=>{this._state!==v.NONE&&(this._state=v.NONE,this._activePointers.length=0,x())},t&&this.connect(t),this.update(0)}get camera(){return this._camera}set camera(e){this._camera=e,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this._domElement&&(e?(this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none"):(this.cancel(),this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect=""))}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(e){this._spherical.radius===e&&this._sphericalEnd.radius===e||(this._spherical.radius=e,this._sphericalEnd.radius=e,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(e){this._spherical.theta===e&&this._sphericalEnd.theta===e||(this._spherical.theta=e,this._sphericalEnd.theta=e,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(e){this._spherical.phi===e&&this._sphericalEnd.phi===e||(this._spherical.phi=e,this._sphericalEnd.phi=e,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(e){this._boundaryEnclosesCamera=e,this._needsUpdate=!0}set interactiveArea(e){this._interactiveArea.width=Se(e.width,0,1),this._interactiveArea.height=Se(e.height,0,1),this._interactiveArea.x=Se(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=Se(e.y,0,1-this._interactiveArea.height)}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}rotate(e,t,s=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+t,s)}rotateAzimuthTo(e,t=!1){return this.rotateTo(e,this._sphericalEnd.phi,t)}rotatePolarTo(e,t=!1){return this.rotateTo(this._sphericalEnd.theta,e,t)}rotateTo(e,t,s=!1){this._isUserControllingRotate=!1;const n=Se(e,this.minAzimuthAngle,this.maxAzimuthAngle),a=Se(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=n,this._sphericalEnd.phi=a,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,s||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const r=!s||V(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&V(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(r)}dolly(e,t=!1){return this.dollyTo(this._sphericalEnd.radius-e,t)}dollyTo(e,t=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=Ke.NONE,this._changedDolly=0,this._dollyToNoClamp(Se(e,this.minDistance,this.maxDistance),t)}_dollyToNoClamp(e,t=!1){const s=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const r=this._collisionTest(),l=V(r,this._spherical.radius);if(!(s>e)&&l)return Promise.resolve();this._sphericalEnd.radius=Math.min(e,r)}else this._sphericalEnd.radius=e;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);const a=!t||V(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(a)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(dt).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const s=!t||V(this._target.x,this._targetEnd.x,this.restThreshold)&&V(this._target.y,this._targetEnd.y,this.restThreshold)&&V(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(s)}zoom(e,t=!1){return this.zoomTo(this._zoomEnd+e,t)}zoomTo(e,t=!1){this._isUserControllingZoom=!1,this._zoomEnd=Se(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const s=!t||V(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(s)}pan(e,t,s=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,t,s)}truck(e,t,s=!1){this._camera.updateMatrix(),we.setFromMatrixColumn(this._camera.matrix,0),xe.setFromMatrixColumn(this._camera.matrix,1),we.multiplyScalar(e),xe.multiplyScalar(-t);const n=j.copy(we).add(xe),a=z.copy(this._targetEnd).add(n);return this.moveTo(a.x,a.y,a.z,s)}forward(e,t=!1){j.setFromMatrixColumn(this._camera.matrix,0),j.crossVectors(this._camera.up,j),j.multiplyScalar(e);const s=z.copy(this._targetEnd).add(j);return this.moveTo(s.x,s.y,s.z,t)}elevate(e,t=!1){return j.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+j.x,this._targetEnd.y+j.y,this._targetEnd.z+j.z,t)}moveTo(e,t,s,n=!1){this._isUserControllingTruck=!1;const a=j.set(e,t,s).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,a,this.boundaryFriction),this._needsUpdate=!0,n||this._target.copy(this._targetEnd);const r=!n||V(this._target.x,this._targetEnd.x,this.restThreshold)&&V(this._target.y,this._targetEnd.y,this.restThreshold)&&V(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(r)}lookInDirectionOf(e,t,s,n=!1){const l=j.set(e,t,s).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);return this.setPosition(l.x,l.y,l.z,n)}fitToBox(e,t,{cover:s=!1,paddingLeft:n=0,paddingRight:a=0,paddingBottom:r=0,paddingTop:l=0}={}){const h=[],c=e.isBox3?et.copy(e):et.setFromObject(e);c.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const u=Ki(this._sphericalEnd.theta,Qi),m=Ki(this._sphericalEnd.phi,Qi);h.push(this.rotateTo(u,m,t));const f=j.setFromSpherical(this._sphericalEnd).normalize(),g=ss.setFromUnitVectors(f,ai),x=V(Math.abs(f.y),1);x&&g.multiply(oi.setFromAxisAngle(Rt,u)),g.multiply(this._yAxisUpSpaceInverse);const y=is.makeEmpty();z.copy(c.min).applyQuaternion(g),y.expandByPoint(z),z.copy(c.min).setX(c.max.x).applyQuaternion(g),y.expandByPoint(z),z.copy(c.min).setY(c.max.y).applyQuaternion(g),y.expandByPoint(z),z.copy(c.max).setZ(c.min.z).applyQuaternion(g),y.expandByPoint(z),z.copy(c.min).setZ(c.max.z).applyQuaternion(g),y.expandByPoint(z),z.copy(c.max).setY(c.min.y).applyQuaternion(g),y.expandByPoint(z),z.copy(c.max).setX(c.min.x).applyQuaternion(g),y.expandByPoint(z),z.copy(c.max).applyQuaternion(g),y.expandByPoint(z),y.min.x-=n,y.min.y-=r,y.max.x+=a,y.max.y+=l,g.setFromUnitVectors(ai,f),x&&g.premultiply(oi.invert()),g.premultiply(this._yAxisUpSpace);const T=y.getSize(j),_=y.getCenter(z).applyQuaternion(g);if(Ne(this._camera)){const C=this.getDistanceToFitBox(T.x,T.y,T.z,s);h.push(this.moveTo(_.x,_.y,_.z,t)),h.push(this.dollyTo(C,t)),h.push(this.setFocalOffset(0,0,0,t))}else if(Ue(this._camera)){const C=this._camera,E=C.right-C.left,S=C.top-C.bottom,w=s?Math.max(E/T.x,S/T.y):Math.min(E/T.x,S/T.y);h.push(this.moveTo(_.x,_.y,_.z,t)),h.push(this.zoomTo(w,t)),h.push(this.setFocalOffset(0,0,0,t))}return Promise.all(h)}fitToSphere(e,t){const s=[],a="isObject3D"in e?Me.createBoundingSphere(e,ri):ri.copy(e);if(s.push(this.moveTo(a.center.x,a.center.y,a.center.z,t)),Ne(this._camera)){const r=this.getDistanceToFitSphere(a.radius);s.push(this.dollyTo(r,t))}else if(Ue(this._camera)){const r=this._camera.right-this._camera.left,l=this._camera.top-this._camera.bottom,h=2*a.radius,c=Math.min(r/h,l/h);s.push(this.zoomTo(c,t))}return s.push(this.setFocalOffset(0,0,0,t)),Promise.all(s)}setLookAt(e,t,s,n,a,r,l=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Ke.NONE,this._changedDolly=0;const h=z.set(n,a,r),c=j.set(e,t,s);this._targetEnd.copy(h),this._sphericalEnd.setFromVector3(c.sub(h).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,l||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const u=!l||V(this._target.x,this._targetEnd.x,this.restThreshold)&&V(this._target.y,this._targetEnd.y,this.restThreshold)&&V(this._target.z,this._targetEnd.z,this.restThreshold)&&V(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&V(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&V(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(u)}lerpLookAt(e,t,s,n,a,r,l,h,c,u,m,f,g,x=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Ke.NONE,this._changedDolly=0;const y=j.set(n,a,r),T=z.set(e,t,s);ye.setFromVector3(T.sub(y).applyQuaternion(this._yAxisUpSpace));const _=Je.set(u,m,f),C=z.set(l,h,c);ut.setFromVector3(C.sub(_).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(y.lerp(_,g));const E=ut.theta-ye.theta,S=ut.phi-ye.phi,w=ut.radius-ye.radius;this._sphericalEnd.set(ye.radius+w*g,ye.phi+S*g,ye.theta+E*g),this.normalizeRotations(),this._needsUpdate=!0,x||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const M=!x||V(this._target.x,this._targetEnd.x,this.restThreshold)&&V(this._target.y,this._targetEnd.y,this.restThreshold)&&V(this._target.z,this._targetEnd.z,this.restThreshold)&&V(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&V(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&V(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(M)}setPosition(e,t,s,n=!1){return this.setLookAt(e,t,s,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,n)}setTarget(e,t,s,n=!1){const a=this.getPosition(j),r=this.setLookAt(a.x,a.y,a.z,e,t,s,n);return this._sphericalEnd.phi=Se(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),r}setFocalOffset(e,t,s,n=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,t,s),this._needsUpdate=!0,n||this._focalOffset.copy(this._focalOffsetEnd);const a=!n||V(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&V(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&V(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(a)}setOrbitPoint(e,t,s){this._camera.updateMatrixWorld(),we.setFromMatrixColumn(this._camera.matrixWorldInverse,0),xe.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Fe.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const n=j.set(e,t,s),a=n.distanceTo(this._camera.position),r=n.sub(this._camera.position);we.multiplyScalar(r.x),xe.multiplyScalar(r.y),Fe.multiplyScalar(r.z),j.copy(we).add(xe).add(Fe),j.z=j.z+a,this.dollyTo(a,!1),this.setFocalOffset(-j.x,j.y,-j.z,!1),this.moveTo(e,t,s,!1)}setBoundary(e){if(!e){this._boundary.min.set(-1/0,-1/0,-1/0),this._boundary.max.set(1/0,1/0,1/0),this._needsUpdate=!0;return}this._boundary.copy(e),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(e,t,s,n){if(e===null){this._viewport=null;return}this._viewport=this._viewport||new L.Vector4,typeof e=="number"?this._viewport.set(e,t,s,n):this._viewport.copy(e)}getDistanceToFitBox(e,t,s,n=!1){if(si(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const a=e/t,r=this._camera.getEffectiveFOV()*lt,l=this._camera.aspect;return((n?a>l:a<l)?t:e/l)*.5/Math.tan(r*.5)+s*.5}getDistanceToFitSphere(e){if(si(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*lt,s=Math.atan(Math.tan(t*.5)*this._camera.aspect)*2,n=1<this._camera.aspect?t:s;return e/Math.sin(n*.5)}getTarget(e,t=!0){return(e&&e.isVector3?e:new L.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new L.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e||new L.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new L.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%$e,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=$e),this._spherical.theta+=$e*Math.round((this._sphericalEnd.theta-this._spherical.theta)/$e)}stop(){this._focalOffset.copy(this._focalOffsetEnd),this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd),this._zoom=this._zoomEnd}reset(e=!1){if(!V(this._camera.up.x,this._cameraUp0.x)||!V(this._camera.up.y,this._cameraUp0.y)||!V(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const s=this.getPosition(j);this.updateCameraUp(),this.setPosition(s.x,s.y,s.z)}const t=[this.setLookAt(this._position0.x,this._position0.y,this._position0.z,this._target0.x,this._target0.y,this._target0.z,e),this.setFocalOffset(this._focalOffset0.x,this._focalOffset0.y,this._focalOffset0.z,e),this.zoomTo(this._zoom0,e)];return Promise.all(t)}saveState(){this._cameraUp0.copy(this._camera.up),this.getTarget(this._target0),this.getPosition(this._position0),this._zoom0=this._zoom,this._focalOffset0.copy(this._focalOffset)}updateCameraUp(){this._yAxisUpSpace.setFromUnitVectors(this._camera.up,Rt),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const e=j.subVectors(this._target,this._camera.position).normalize(),t=z.crossVectors(e,this._camera.up);this._camera.up.crossVectors(t,e).normalize(),this._camera.updateMatrixWorld();const s=this.getPosition(j);this.updateCameraUp(),this.setPosition(s.x,s.y,s.z)}update(e){const t=this._sphericalEnd.theta-this._spherical.theta,s=this._sphericalEnd.phi-this._spherical.phi,n=this._sphericalEnd.radius-this._spherical.radius,a=es.subVectors(this._targetEnd,this._target),r=ts.subVectors(this._focalOffsetEnd,this._focalOffset),l=this._zoomEnd-this._zoom;if(q(t))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const m=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=At(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,m,1/0,e),this._needsUpdate=!0}if(q(s))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const m=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=At(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,m,1/0,e),this._needsUpdate=!0}if(q(n))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const m=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=At(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,m,this.maxSpeed,e),this._needsUpdate=!0}if(q(a.x)&&q(a.y)&&q(a.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const m=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;$i(this._target,this._targetEnd,this._targetVelocity,m,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(q(r.x)&&q(r.y)&&q(r.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const m=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;$i(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,m,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(q(l))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const m=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=At(this._zoom,this._zoomEnd,this._zoomVelocity,m,1/0,e)}if(this.dollyToCursor){if(Ne(this._camera)&&this._changedDolly!==0){const m=this._spherical.radius-this._lastDistance,f=this._camera,g=this._getCameraDirection(dt),x=j.copy(g).cross(f.up).normalize();x.lengthSq()===0&&(x.x=1);const y=z.crossVectors(x,g),T=this._sphericalEnd.radius*Math.tan(f.getEffectiveFOV()*lt*.5),C=(this._sphericalEnd.radius-m-this._sphericalEnd.radius)/this._sphericalEnd.radius,E=Je.copy(this._targetEnd).add(x.multiplyScalar(this._dollyControlCoord.x*T*f.aspect)).add(y.multiplyScalar(this._dollyControlCoord.y*T)),S=j.copy(this._targetEnd).lerp(E,C),w=this._lastDollyDirection===Ke.IN&&this._spherical.radius<=this.minDistance,M=this._lastDollyDirection===Ke.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(w||M)){this._sphericalEnd.radius-=m,this._spherical.radius-=m;const U=z.copy(g).multiplyScalar(-m);S.add(U)}this._boundary.clampPoint(S,S);const I=z.subVectors(S,this._targetEnd);this._targetEnd.copy(S),this._target.add(I),this._changedDolly-=m,q(this._changedDolly)&&(this._changedDolly=0)}else if(Ue(this._camera)&&this._changedZoom!==0){const m=this._zoom-this._lastZoom,f=this._camera,g=j.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(f.near+f.far)/(f.near-f.far)).unproject(f),x=z.set(0,0,-1).applyQuaternion(f.quaternion),y=Je.copy(g).add(x.multiplyScalar(-g.dot(f.up))),_=-(this._zoom-m-this._zoom)/this._zoom,C=this._getCameraDirection(dt),E=this._targetEnd.dot(C),S=j.copy(this._targetEnd).lerp(y,_),w=S.dot(C),M=C.multiplyScalar(w-E);S.sub(M),this._boundary.clampPoint(S,S);const I=z.subVectors(S,this._targetEnd);this._targetEnd.copy(S),this._target.add(I),this._changedZoom-=m,q(this._changedZoom)&&(this._changedZoom=0)}}this._camera.zoom!==this._zoom&&(this._camera.zoom=this._zoom,this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0),this._dragNeedsUpdate=!0;const h=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,h),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!q(this._focalOffset.x)||!q(this._focalOffset.y)||!q(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),we.setFromMatrixColumn(this._camera.matrix,0),xe.setFromMatrixColumn(this._camera.matrix,1),Fe.setFromMatrixColumn(this._camera.matrix,2),we.multiplyScalar(this._focalOffset.x),xe.multiplyScalar(-this._focalOffset.y),Fe.multiplyScalar(this._focalOffset.z),j.copy(we).add(xe).add(Fe),this._camera.position.add(j)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),j.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const u=this._needsUpdate;return u&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):u?(this.dispatchEvent({type:"update"}),q(t,this.restThreshold)&&q(s,this.restThreshold)&&q(n,this.restThreshold)&&q(a.x,this.restThreshold)&&q(a.y,this.restThreshold)&&q(a.z,this.restThreshold)&&q(r.x,this.restThreshold)&&q(r.y,this.restThreshold)&&q(r.z,this.restThreshold)&&q(l,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!u&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=u,this._needsUpdate=!1,u}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:ct(this.maxDistance),minZoom:this.minZoom,maxZoom:ct(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:ct(this.maxPolarAngle),minAzimuthAngle:ct(this.minAzimuthAngle),maxAzimuthAngle:ct(this.maxAzimuthAngle),smoothTime:this.smoothTime,draggingSmoothTime:this.draggingSmoothTime,dollySpeed:this.dollySpeed,truckSpeed:this.truckSpeed,dollyToCursor:this.dollyToCursor,verticalDragToForward:this.verticalDragToForward,target:this._targetEnd.toArray(),position:j.setFromSpherical(this._sphericalEnd).add(this._targetEnd).toArray(),zoom:this._zoomEnd,focalOffset:this._focalOffsetEnd.toArray(),target0:this._target0.toArray(),position0:this._position0.toArray(),zoom0:this._zoom0,focalOffset0:this._focalOffset0.toArray()})}fromJSON(e,t=!1){const s=JSON.parse(e);this.enabled=s.enabled,this.minDistance=s.minDistance,this.maxDistance=ht(s.maxDistance),this.minZoom=s.minZoom,this.maxZoom=ht(s.maxZoom),this.minPolarAngle=s.minPolarAngle,this.maxPolarAngle=ht(s.maxPolarAngle),this.minAzimuthAngle=ht(s.minAzimuthAngle),this.maxAzimuthAngle=ht(s.maxAzimuthAngle),this.smoothTime=s.smoothTime,this.draggingSmoothTime=s.draggingSmoothTime,this.dollySpeed=s.dollySpeed,this.truckSpeed=s.truckSpeed,this.dollyToCursor=s.dollyToCursor,this.verticalDragToForward=s.verticalDragToForward,this._target0.fromArray(s.target0),this._position0.fromArray(s.position0),this._zoom0=s.zoom0,this._focalOffset0.fromArray(s.focalOffset0),this.moveTo(s.target[0],s.target[1],s.target[2],t),ye.setFromVector3(j.fromArray(s.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(ye.theta,ye.phi,t),this.dollyTo(ye.radius,t),this.zoomTo(s.zoom,t),this.setFocalOffset(s.focalOffset[0],s.focalOffset[1],s.focalOffset[2],t),this._needsUpdate=!0}connect(e){if(this._domElement){console.warn("camera-controls is already connected.");return}e.setAttribute("data-camera-controls-version",ka),this._addAllEventListeners(e),this._getClientRect(this._elementRect)}disconnect(){this.cancel(),this._removeAllEventListeners(),this._domElement&&(this._domElement.removeAttribute("data-camera-controls-version"),this._domElement=void 0)}dispose(){this.removeAllEventListeners(),this.disconnect()}_getTargetDirection(e){return e.setFromSpherical(this._spherical).divideScalar(this._spherical.radius).applyQuaternion(this._yAxisUpSpaceInverse)}_getCameraDirection(e){return this._getTargetDirection(e).negate()}_findPointerById(e){return this._activePointers.find(t=>t.pointerId===e)}_findPointerByMouseButton(e){return this._activePointers.find(t=>t.mouseButton===e)}_disposePointer(e){this._activePointers.splice(this._activePointers.indexOf(e),1)}_encloseToBoundary(e,t,s){const n=t.lengthSq();if(n===0)return e;const a=z.copy(t).add(e),l=this._boundary.clampPoint(a,Je).sub(a),h=l.lengthSq();if(h===0)return e.add(t);if(h===n)return e;if(s===0)return e.add(t).add(l);{const c=1+s*h/t.dot(l);return e.add(z.copy(t).multiplyScalar(c)).add(l.multiplyScalar(1-s))}}_updateNearPlaneCorners(){if(Ne(this._camera)){const e=this._camera,t=e.near,s=e.getEffectiveFOV()*lt,n=Math.tan(s*.5)*t,a=n*e.aspect;this._nearPlaneCorners[0].set(-a,-n,0),this._nearPlaneCorners[1].set(a,-n,0),this._nearPlaneCorners[2].set(a,n,0),this._nearPlaneCorners[3].set(-a,n,0)}else if(Ue(this._camera)){const e=this._camera,t=1/e.zoom,s=e.left*t,n=e.right*t,a=e.top*t,r=e.bottom*t;this._nearPlaneCorners[0].set(s,a,0),this._nearPlaneCorners[1].set(n,a,0),this._nearPlaneCorners[2].set(n,r,0),this._nearPlaneCorners[3].set(s,r,0)}}_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||si(this._camera,"_collisionTest"))return e;const s=this._getTargetDirection(dt);li.lookAt(Ji,s,this._camera.up);for(let n=0;n<4;n++){const a=z.copy(this._nearPlaneCorners[n]);a.applyMatrix4(li);const r=Je.addVectors(this._target,a);Dt.set(r,s),Dt.far=this._spherical.radius+1;const l=Dt.intersectObjects(this.colliderMeshes);l.length!==0&&l[0].distance<e&&(e=l[0].distance)}return e}_getClientRect(e){if(!this._domElement)return;const t=this._domElement.getBoundingClientRect();return e.x=t.left,e.y=t.top,this._viewport?(e.x+=this._viewport.x,e.y+=t.height-this._viewport.w-this._viewport.y,e.width=this._viewport.z,e.height=this._viewport.w):(e.width=t.width,e.height=t.height),e}_createOnRestPromise(e){return e?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:"transitionstart"}),new Promise(t=>{const s=()=>{this.removeEventListener("rest",s),t()};this.addEventListener("rest",s)}))}_addAllEventListeners(e){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(e){console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead.")}get draggingDampingFactor(){return console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead."),0}set draggingDampingFactor(e){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(e,t=new L.Sphere){const s=t,n=s.center;et.makeEmpty(),e.traverseVisible(r=>{r.isMesh&&et.expandByObject(r)}),et.getCenter(n);let a=0;return e.traverseVisible(r=>{if(!r.isMesh)return;const l=r,h=l.geometry.clone();h.applyMatrix4(l.matrixWorld);const u=h.attributes.position;for(let m=0,f=u.count;m<f;m++)j.fromBufferAttribute(u,m),a=Math.max(a,n.distanceToSquared(j))}),s.radius=Math.sqrt(a),s}}const Ht=i=>{const[e,t]=O.useState(i.options[i.index]),s=()=>{i.onToggle(!i.open)},n=a=>{a!==e&&(i.onSelect(a),t(a)),i.onToggle(!1)};return p.jsxs("div",{className:`dropdown ${i.up===!0?"up":""}`,children:[p.jsx("div",{className:"dropdown-toggle",onClick:s,children:`${i.title}: ${e}`}),i.open&&p.jsx("ul",{className:"dropdown-menu",children:i.options.map(a=>p.jsx("li",{onClick:()=>n(a),children:a},a))})]})},ze=O.forwardRef(function(e,t){const s=["Renderer","Depth","Normals","UVs","Wireframe"],[n,a]=O.useState("Renderer"),[r,l]=O.useState(!1),[h,c]=O.useState(!1),[u,m]=O.useState(!1);return p.jsxs("div",{className:`CameraWindow ${e.name}`,children:[p.jsx("div",{ref:t,className:"clickable",onClick:()=>{u&&m(!1)}}),p.jsxs("div",{className:"options",children:[e.camera!==null&&p.jsx(Ht,{title:"Camera",index:e.options.indexOf(e.camera.name),open:u,options:e.options,onSelect:e.onSelectCamera,onToggle:f=>{m(f)},up:!0}),p.jsx(Ht,{title:"Mode",index:s.indexOf(n),open:h,options:s,onSelect:f=>{if(f===n)return;const g=f;e.onSelectRenderMode(g),a(g)},onToggle:f=>{r&&l(!1),c(f)},up:!0})]})]})}),ja=`out vec3 worldPosition;
53
53
  uniform float uDistance;
54
54
 
55
55
  void main() {
@@ -124,7 +124,7 @@ void main() {
124
124
  fragColor.a = mix(fragColor.a, baseOpacity * uGridOpacity, nextGrid);
125
125
 
126
126
  if (fragColor.a <= 0.0) discard;
127
- }`;class Fa extends o.ShaderMaterial{constructor(e){super({extensions:{derivatives:!0},uniforms:{uScale:{value:e?.scale!==void 0?e?.scale:.1},uDivisions:{value:e?.divisions!==void 0?e?.divisions:10},uColor:{value:e?.color!==void 0?e?.color:new o.Color(16777215)},uDistance:{value:e?.distance!==void 0?e?.distance:1e4},uSubgridOpacity:{value:e?.subgridOpacity!==void 0?e?.subgridOpacity:.15},uGridOpacity:{value:e?.gridOpacity!==void 0?e?.gridOpacity:.25}},glslVersion:o.GLSL3,side:o.DoubleSide,transparent:!0,name:"InfiniteGrid",depthTest:!1,depthWrite:!1,vertexShader:ja,fragmentShader:Na})}}class za extends o.Mesh{gridMaterial;constructor(e){const t=new Fa(e);super(new o.PlaneGeometry,t),this.gridMaterial=t,this.frustumCulled=!1,this.name="InfiniteGridHelper"}update(){this.gridMaterial.needsUpdate=!0}}function ss(s){const[e,t]=O.useState(s.selected),i="toggle"+(e?" selected":"");return p.jsx("button",{className:i,onClick:()=>{const n=!e;t(n),s.onClick(n)},style:{backgroundImage:`url(${s.icon})`,backgroundPositionY:`${s.top}px`,backgroundSize:`26px ${s.height}px`}},s.name)}const Ha=`#include <common>
127
+ }`;class Fa extends o.ShaderMaterial{constructor(e){super({extensions:{derivatives:!0},uniforms:{uScale:{value:e?.scale!==void 0?e?.scale:.1},uDivisions:{value:e?.divisions!==void 0?e?.divisions:10},uColor:{value:e?.color!==void 0?e?.color:new o.Color(16777215)},uDistance:{value:e?.distance!==void 0?e?.distance:1e4},uSubgridOpacity:{value:e?.subgridOpacity!==void 0?e?.subgridOpacity:.15},uGridOpacity:{value:e?.gridOpacity!==void 0?e?.gridOpacity:.25}},glslVersion:o.GLSL3,side:o.DoubleSide,transparent:!0,name:"InfiniteGrid",depthTest:!1,depthWrite:!1,vertexShader:ja,fragmentShader:Na})}}class za extends o.Mesh{gridMaterial;constructor(e){const t=new Fa(e);super(new o.PlaneGeometry,t),this.gridMaterial=t,this.frustumCulled=!1,this.name="InfiniteGridHelper"}update(){this.gridMaterial.needsUpdate=!0}}function ns(i){const[e,t]=O.useState(i.selected),s="toggle"+(e?" selected":"");return p.jsx("button",{className:s,onClick:()=>{const n=!e;t(n),i.onClick(n)},style:{backgroundImage:`url(${i.icon})`,backgroundPositionY:`${i.top}px`,backgroundSize:`26px ${i.height}px`}},i.name)}const Ha=`#include <common>
128
128
  #include <batching_pars_vertex>
129
129
  #include <uv_pars_vertex>
130
130
  #include <color_pars_vertex>
@@ -162,4 +162,4 @@ void main() {
162
162
  void main() {
163
163
  #include <clipping_planes_fragment>
164
164
  gl_FragColor = vec4(vec3(vUv, 0.0), 1.0);
165
- }`;class Ba extends o.ShaderMaterial{constructor(){super({defines:{USE_UV:""},vertexShader:Ha,fragmentShader:Va})}}const He=new o.Raycaster,he=new o.Vector3,ke=new o.Vector3,K=new o.Quaternion,ns={X:new o.Vector3(1,0,0),Y:new o.Vector3(0,1,0),Z:new o.Vector3(0,0,1)},ci={type:"change"},as={type:"mouseDown",mode:null},rs={type:"mouseUp",mode:null},os={type:"objectChange"};class Ya extends o.Controls{constructor(e,t=null){super(void 0,t);const i=new Qa(this);this._root=i;const n=new Ka;this._gizmo=n,i.add(n);const r=new $a;this._plane=r,i.add(r);const a=this;function l(E,S){let w=S;Object.defineProperty(a,E,{get:function(){return w!==void 0?w:S},set:function(M){w!==M&&(w=M,r[E]=M,n[E]=M,a.dispatchEvent({type:E+"-changed",value:M}),a.dispatchEvent(ci))}}),a[E]=S,r[E]=S,n[E]=S}l("camera",e),l("object",void 0),l("enabled",!0),l("axis",null),l("mode","translate"),l("translationSnap",null),l("rotationSnap",null),l("scaleSnap",null),l("space","world"),l("size",1),l("dragging",!1),l("showX",!0),l("showY",!0),l("showZ",!0);const h=new o.Vector3,c=new o.Vector3,u=new o.Quaternion,m=new o.Quaternion,f=new o.Vector3,g=new o.Quaternion,x=new o.Vector3,y=new o.Vector3,T=new o.Vector3,_=0,C=new o.Vector3;l("worldPosition",h),l("worldPositionStart",c),l("worldQuaternion",u),l("worldQuaternionStart",m),l("cameraPosition",f),l("cameraQuaternion",g),l("pointStart",x),l("pointEnd",y),l("rotationAxis",T),l("rotationAngle",_),l("eye",C),this._offset=new o.Vector3,this._startNorm=new o.Vector3,this._endNorm=new o.Vector3,this._cameraScale=new o.Vector3,this._parentPosition=new o.Vector3,this._parentQuaternion=new o.Quaternion,this._parentQuaternionInv=new o.Quaternion,this._parentScale=new o.Vector3,this._worldScaleStart=new o.Vector3,this._worldQuaternionInv=new o.Quaternion,this._worldScale=new o.Vector3,this._positionStart=new o.Vector3,this._quaternionStart=new o.Quaternion,this._scaleStart=new o.Vector3,this._getPointer=Ga.bind(this),this._onPointerDown=Wa.bind(this),this._onPointerHover=Za.bind(this),this._onPointerMove=Xa.bind(this),this._onPointerUp=qa.bind(this),t!==null&&this.connect()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&He.setFromCamera(e,this.camera);const t=hi(this._gizmo.picker[this.mode],He);t?this.axis=t.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&He.setFromCamera(e,this.camera);const t=hi(this._plane,He,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,as.mode=this.mode,this.dispatchEvent(as)}}pointerMove(e){const t=this.axis,i=this.mode,n=this.object;let r=this.space;if(i==="scale"?r="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(r="world"),n===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&He.setFromCamera(e,this.camera);const a=hi(this._plane,He,!0);if(a){if(this.pointEnd.copy(a.point).sub(this.worldPositionStart),i==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),r==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),r==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),n.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(r==="local"&&(n.position.applyQuaternion(K.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.position.applyQuaternion(this._quaternionStart)),r==="world"&&(n.parent&&n.position.add(he.setFromMatrixPosition(n.parent.matrixWorld)),t.search("X")!==-1&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.parent&&n.position.sub(he.setFromMatrixPosition(n.parent.matrixWorld))));else if(i==="scale"){if(t.search("XYZ")!==-1){let l=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(l*=-1),ke.set(l,l,l)}else he.copy(this.pointStart),ke.copy(this.pointEnd),he.applyQuaternion(this._worldQuaternionInv),ke.applyQuaternion(this._worldQuaternionInv),ke.divide(he),t.search("X")===-1&&(ke.x=1),t.search("Y")===-1&&(ke.y=1),t.search("Z")===-1&&(ke.z=1);n.scale.copy(this._scaleStart).multiply(ke),this.scaleSnap&&(t.search("X")!==-1&&(n.scale.x=Math.round(n.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(n.scale.y=Math.round(n.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(n.scale.z=Math.round(n.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(i==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const l=20/this.worldPosition.distanceTo(he.setFromMatrixPosition(this.camera.matrixWorld));let h=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(he.copy(this.rotationAxis).cross(this.eye))*l):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(ns[t]),he.copy(ns[t]),r==="local"&&he.applyQuaternion(this.worldQuaternion),he.cross(this.eye),he.length()===0?h=!0:this.rotationAngle=this._offset.dot(he.normalize())*l),(t==="E"||h)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),r==="local"&&t!=="E"&&t!=="XYZE"?(n.quaternion.copy(this._quaternionStart),n.quaternion.multiply(K.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),n.quaternion.copy(K.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(ci),this.dispatchEvent(os)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(rs.mode=this.mode,this.dispatchEvent(rs)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}attach(e){return this.object=e,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(ci),this.dispatchEvent(os),this.pointStart.copy(this.pointEnd))}getRaycaster(){return He}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}}function Ga(s){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:s.button};{const e=this.domElement.getBoundingClientRect();return{x:(s.clientX-e.left)/e.width*2-1,y:-(s.clientY-e.top)/e.height*2+1,button:s.button}}}function Za(s){if(this.enabled)switch(s.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(s));break}}function Wa(s){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(s.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(s)),this.pointerDown(this._getPointer(s)))}function Xa(s){this.enabled&&this.pointerMove(this._getPointer(s))}function qa(s){this.enabled&&(this.domElement.releasePointerCapture(s.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(s)))}function hi(s,e,t){const i=e.intersectObject(s,!0);for(let n=0;n<i.length;n++)if(i[n].object.visible||t)return i[n];return!1}const It=new o.Euler,W=new o.Vector3(0,1,0),ls=new o.Vector3(0,0,0),cs=new o.Matrix4,Lt=new o.Quaternion,Nt=new o.Quaternion,Oe=new o.Vector3,hs=new o.Matrix4,_t=new o.Vector3(1,0,0),Ve=new o.Vector3(0,1,0),vt=new o.Vector3(0,0,1),kt=new o.Vector3,pt=new o.Vector3,mt=new o.Vector3;class Qa extends o.Object3D{constructor(e){super(),this.isTransformControlsRoot=!0,this.controls=e,this.visible=!1}updateMatrixWorld(e){const t=this.controls;t.object!==void 0&&(t.object.updateMatrixWorld(),t.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):t.object.parent.matrixWorld.decompose(t._parentPosition,t._parentQuaternion,t._parentScale),t.object.matrixWorld.decompose(t.worldPosition,t.worldQuaternion,t._worldScale),t._parentQuaternionInv.copy(t._parentQuaternion).invert(),t._worldQuaternionInv.copy(t.worldQuaternion).invert()),t.camera.updateMatrixWorld(),t.camera.matrixWorld.decompose(t.cameraPosition,t.cameraQuaternion,t._cameraScale),t.camera.isOrthographicCamera?t.camera.getWorldDirection(t.eye).negate():t.eye.copy(t.cameraPosition).sub(t.worldPosition).normalize(),super.updateMatrixWorld(e)}}class Ka extends o.Object3D{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new o.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new o.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=e.clone();i.opacity=.15;const n=t.clone();n.opacity=.5;const r=e.clone();r.color.setHex(16711680);const a=e.clone();a.color.setHex(65280);const l=e.clone();l.color.setHex(255);const h=e.clone();h.color.setHex(16711680),h.opacity=.5;const c=e.clone();c.color.setHex(65280),c.opacity=.5;const u=e.clone();u.color.setHex(255),u.opacity=.5;const m=e.clone();m.opacity=.25;const f=e.clone();f.color.setHex(16776960),f.opacity=.25,e.clone().color.setHex(16776960);const x=e.clone();x.color.setHex(7895160);const y=new o.CylinderGeometry(0,.04,.1,12);y.translate(0,.05,0);const T=new o.BoxGeometry(.08,.08,.08);T.translate(0,.04,0);const _=new o.BufferGeometry;_.setAttribute("position",new o.Float32BufferAttribute([0,0,0,1,0,0],3));const C=new o.CylinderGeometry(.0075,.0075,.5,3);C.translate(0,.25,0);function E(X,Ae){const ce=new o.TorusGeometry(X,.0075,3,64,Ae*Math.PI*2);return ce.rotateY(Math.PI/2),ce.rotateX(Math.PI/2),ce}function S(){const X=new o.BufferGeometry;return X.setAttribute("position",new o.Float32BufferAttribute([0,0,0,1,1,1],3)),X}const w={X:[[new o.Mesh(y,r),[.5,0,0],[0,0,-Math.PI/2]],[new o.Mesh(y,r),[-.5,0,0],[0,0,Math.PI/2]],[new o.Mesh(C,r),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new o.Mesh(y,a),[0,.5,0]],[new o.Mesh(y,a),[0,-.5,0],[Math.PI,0,0]],[new o.Mesh(C,a)]],Z:[[new o.Mesh(y,l),[0,0,.5],[Math.PI/2,0,0]],[new o.Mesh(y,l),[0,0,-.5],[-Math.PI/2,0,0]],[new o.Mesh(C,l),null,[Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.OctahedronGeometry(.1,0),m.clone()),[0,0,0]]],XY:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),u.clone()),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),h.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),c.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},M={X:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,.3,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.OctahedronGeometry(.2,0),i)]],XY:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},I={START:[[new o.Mesh(new o.OctahedronGeometry(.01,2),n),null,null,null,"helper"]],END:[[new o.Mesh(new o.OctahedronGeometry(.01,2),n),null,null,null,"helper"]],DELTA:[[new o.Line(S(),n),null,null,null,"helper"]],X:[[new o.Line(_,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new o.Line(_,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new o.Line(_,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},U={XYZE:[[new o.Mesh(E(.5,1),x),null,[0,Math.PI/2,0]]],X:[[new o.Mesh(E(.5,.5),r)]],Y:[[new o.Mesh(E(.5,.5),a),null,[0,0,-Math.PI/2]]],Z:[[new o.Mesh(E(.5,.5),l),null,[0,Math.PI/2,0]]],E:[[new o.Mesh(E(.75,1),f),null,[0,Math.PI/2,0]]]},D={AXIS:[[new o.Line(_,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},B={XYZE:[[new o.Mesh(new o.SphereGeometry(.25,10,8),i)]],X:[[new o.Mesh(new o.TorusGeometry(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new o.Mesh(new o.TorusGeometry(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new o.Mesh(new o.TorusGeometry(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new o.Mesh(new o.TorusGeometry(.75,.1,2,24),i)]]},_e={X:[[new o.Mesh(T,r),[.5,0,0],[0,0,-Math.PI/2]],[new o.Mesh(C,r),[0,0,0],[0,0,-Math.PI/2]],[new o.Mesh(T,r),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new o.Mesh(T,a),[0,.5,0]],[new o.Mesh(C,a)],[new o.Mesh(T,a),[0,-.5,0],[0,0,Math.PI]]],Z:[[new o.Mesh(T,l),[0,0,.5],[Math.PI/2,0,0]],[new o.Mesh(C,l),[0,0,0],[Math.PI/2,0,0]],[new o.Mesh(T,l),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),u),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),h),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.BoxGeometry(.1,.1,.1),m.clone())]]},pe={X:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,.3,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.2),i),[0,0,0]]]},ne={X:[[new o.Line(_,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new o.Line(_,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new o.Line(_,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function Q(X){const Ae=new o.Object3D;for(const ce in X)for(let ge=X[ce].length;ge--;){const ie=X[ce][ge][0].clone(),Re=X[ce][ge][1],De=X[ce][ge][2],Ie=X[ce][ge][3],G=X[ce][ge][4];ie.name=ce,ie.tag=G,Re&&ie.position.set(Re[0],Re[1],Re[2]),De&&ie.rotation.set(De[0],De[1],De[2]),Ie&&ie.scale.set(Ie[0],Ie[1],Ie[2]),ie.updateMatrix();const re=ie.geometry.clone();re.applyMatrix4(ie.matrix),ie.geometry=re,ie.renderOrder=1/0,ie.position.set(0,0,0),ie.rotation.set(0,0,0),ie.scale.set(1,1,1),Ae.add(ie)}return Ae}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=Q(w)),this.add(this.gizmo.rotate=Q(U)),this.add(this.gizmo.scale=Q(_e)),this.add(this.picker.translate=Q(M)),this.add(this.picker.rotate=Q(B)),this.add(this.picker.scale=Q(pe)),this.add(this.helper.translate=Q(I)),this.add(this.helper.rotate=Q(D)),this.add(this.helper.scale=Q(ne)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const i=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:Nt;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let n=[];n=n.concat(this.picker[this.mode].children),n=n.concat(this.gizmo[this.mode].children),n=n.concat(this.helper[this.mode].children);for(let r=0;r<n.length;r++){const a=n[r];a.visible=!0,a.rotation.set(0,0,0),a.position.copy(this.worldPosition);let l;if(this.camera.isOrthographicCamera?l=(this.camera.top-this.camera.bottom)/this.camera.zoom:l=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),a.scale.set(1,1,1).multiplyScalar(l*this.size/4),a.tag==="helper"){a.visible=!1,a.name==="AXIS"?(a.visible=!!this.axis,this.axis==="X"&&(K.setFromEuler(It.set(0,0,0)),a.quaternion.copy(i).multiply(K),Math.abs(W.copy(_t).applyQuaternion(i).dot(this.eye))>.9&&(a.visible=!1)),this.axis==="Y"&&(K.setFromEuler(It.set(0,0,Math.PI/2)),a.quaternion.copy(i).multiply(K),Math.abs(W.copy(Ve).applyQuaternion(i).dot(this.eye))>.9&&(a.visible=!1)),this.axis==="Z"&&(K.setFromEuler(It.set(0,Math.PI/2,0)),a.quaternion.copy(i).multiply(K),Math.abs(W.copy(vt).applyQuaternion(i).dot(this.eye))>.9&&(a.visible=!1)),this.axis==="XYZE"&&(K.setFromEuler(It.set(0,Math.PI/2,0)),W.copy(this.rotationAxis),a.quaternion.setFromRotationMatrix(cs.lookAt(ls,W,Ve)),a.quaternion.multiply(K),a.visible=this.dragging),this.axis==="E"&&(a.visible=!1)):a.name==="START"?(a.position.copy(this.worldPositionStart),a.visible=this.dragging):a.name==="END"?(a.position.copy(this.worldPosition),a.visible=this.dragging):a.name==="DELTA"?(a.position.copy(this.worldPositionStart),a.quaternion.copy(this.worldQuaternionStart),he.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),he.applyQuaternion(this.worldQuaternionStart.clone().invert()),a.scale.copy(he),a.visible=this.dragging):(a.quaternion.copy(i),this.dragging?a.position.copy(this.worldPositionStart):a.position.copy(this.worldPosition),this.axis&&(a.visible=this.axis.search(a.name)!==-1));continue}a.quaternion.copy(i),this.mode==="translate"||this.mode==="scale"?(a.name==="X"&&Math.abs(W.copy(_t).applyQuaternion(i).dot(this.eye))>.99&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="Y"&&Math.abs(W.copy(Ve).applyQuaternion(i).dot(this.eye))>.99&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="Z"&&Math.abs(W.copy(vt).applyQuaternion(i).dot(this.eye))>.99&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="XY"&&Math.abs(W.copy(vt).applyQuaternion(i).dot(this.eye))<.2&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="YZ"&&Math.abs(W.copy(_t).applyQuaternion(i).dot(this.eye))<.2&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="XZ"&&Math.abs(W.copy(Ve).applyQuaternion(i).dot(this.eye))<.2&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1)):this.mode==="rotate"&&(Lt.copy(i),W.copy(this.eye).applyQuaternion(K.copy(i).invert()),a.name.search("E")!==-1&&a.quaternion.setFromRotationMatrix(cs.lookAt(this.eye,ls,Ve)),a.name==="X"&&(K.setFromAxisAngle(_t,Math.atan2(-W.y,W.z)),K.multiplyQuaternions(Lt,K),a.quaternion.copy(K)),a.name==="Y"&&(K.setFromAxisAngle(Ve,Math.atan2(W.x,W.z)),K.multiplyQuaternions(Lt,K),a.quaternion.copy(K)),a.name==="Z"&&(K.setFromAxisAngle(vt,Math.atan2(W.y,W.x)),K.multiplyQuaternions(Lt,K),a.quaternion.copy(K))),a.visible=a.visible&&(a.name.indexOf("X")===-1||this.showX),a.visible=a.visible&&(a.name.indexOf("Y")===-1||this.showY),a.visible=a.visible&&(a.name.indexOf("Z")===-1||this.showZ),a.visible=a.visible&&(a.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),a.material._color=a.material._color||a.material.color.clone(),a.material._opacity=a.material._opacity||a.material.opacity,a.material.color.copy(a.material._color),a.material.opacity=a.material._opacity,this.enabled&&this.axis&&(a.name===this.axis||this.axis.split("").some(function(h){return a.name===h}))&&(a.material.color.setHex(16776960),a.material.opacity=1)}super.updateMatrixWorld(e)}}class $a extends o.Mesh{constructor(){super(new o.PlaneGeometry(1e5,1e5,2,2),new o.MeshBasicMaterial({visible:!1,wireframe:!0,side:o.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),kt.copy(_t).applyQuaternion(t==="local"?this.worldQuaternion:Nt),pt.copy(Ve).applyQuaternion(t==="local"?this.worldQuaternion:Nt),mt.copy(vt).applyQuaternion(t==="local"?this.worldQuaternion:Nt),W.copy(pt),this.mode){case"translate":case"scale":switch(this.axis){case"X":W.copy(this.eye).cross(kt),Oe.copy(kt).cross(W);break;case"Y":W.copy(this.eye).cross(pt),Oe.copy(pt).cross(W);break;case"Z":W.copy(this.eye).cross(mt),Oe.copy(mt).cross(W);break;case"XY":Oe.copy(mt);break;case"YZ":Oe.copy(kt);break;case"XZ":W.copy(mt),Oe.copy(pt);break;case"XYZ":case"E":Oe.set(0,0,0);break}break;case"rotate":default:Oe.set(0,0,0)}Oe.length()===0?this.quaternion.copy(this.cameraQuaternion):(hs.lookAt(he.set(0,0,0),Oe,W),this.quaternion.setFromRotationMatrix(hs)),super.updateMatrixWorld(e)}}class de extends o.EventDispatcher{static DRAG_START="Transform::dragStart";static DRAG_END="Transform::dragEnd";static _instance;three;activeCamera;controls=new Map;visibility=new Map;constructor(){super(),R.addEventListener(A.SET_SCENE,this.setScene)}clear(){for(const e of this.controls.values()){e.detach(),e.disconnect();const t=e.getHelper();Pe(t)}this.controls=new Map,this.visibility=new Map}add(e){let t=this.controls.get(e);if(t===void 0){const i=document.querySelector(".clickable");t=new Ya(this.activeCamera,i),t.getHelper().name=e,t.setSpace("local"),this.controls.set(e,t),this.visibility.set(e,!0),t.addEventListener("mouseDown",()=>{this.dispatchEvent({type:de.DRAG_START})}),t.addEventListener("mouseUp",()=>{this.dispatchEvent({type:de.DRAG_END})}),t.addEventListener("dragging-changed",n=>{le.instance?.toggleOrbitControls(n.value)})}return t}get(e){return this.controls.get(e)}remove(e){const t=this.get(e);return t===void 0?!1:(t.detach(),t.disconnect(),Pe(t.getHelper()),this.controls.delete(e),!0)}enabled(e){this.controls.forEach(t=>{t.enabled=e})}updateCamera(e,t){this.activeCamera=e,this.controls.forEach(i=>{i.camera!==e&&(i.camera=e,e.getWorldPosition(i.cameraPosition),e.getWorldQuaternion(i.cameraQuaternion)),i.domElement!==t&&(i.disconnect(),i.domElement=t,i.connect())})}show(){this.controls.forEach(e=>{const t=e.getHelper(),i=this.visibility.get(t.name);i!==void 0&&(t.visible=i)})}hide(){this.controls.forEach(e=>{const t=e.getHelper();this.visibility.set(t.name,t.visible),t.visible=!1})}setScene=()=>{this.clear()};static get instance(){return de._instance||(de._instance=new de),de._instance}}const Ja=new o.BoxGeometry,di=new o.Vector2;class vi extends o.Object3D{curve=new o.CatmullRomCurve3;line;draggable;curvePos;tension=.5;closed=!1;subdivide=50;curveType;offset=1;lineMaterial;_camera;_curvePercentage=0;_draggableScale=10;_transform;raycaster;draggedMat=new o.MeshBasicMaterial;parentGroup;group;constructor(e,t){const i=new o.Color(Qe(.5,1,Math.random()),Qe(.5,1,Math.random()),Qe(.5,1,Math.random()));super(),this.name=e,this.lineMaterial=new o.LineBasicMaterial({color:i}),this.line=new o.Line(new o.BufferGeometry,this.lineMaterial),this.line.name="line",this.add(this.line),this._camera=t,this.curveType="catmullrom",this.draggedMat.color=i,this.draggable=new o.Object3D,this.draggable.name="draggablePoints",this.add(this.draggable),this.curvePos=new o.Mesh(new o.SphereGeometry(1.5),new o.MeshBasicMaterial({color:i})),this.curvePos.name="curvePos",this.curvePos.scale.setScalar(this._draggableScale),this.curvePos.visible=!1,this.add(this.curvePos),this.raycaster=new o.Raycaster,this.raycaster.params.Line.threshold=3,this.enable()}enable(){document.addEventListener("pointerdown",this.onMouseClick)}disable(){document.removeEventListener("pointerdown",this.onMouseClick)}dispose=()=>{this._transform&&(this._transform.removeEventListener("objectChange",this.updateSpline),de.instance.remove(this.name)),this.disable(),this.parentGroup.removeGroup(this.name)};hideTransform=()=>{this._transform?.detach()};exportSpline=()=>{const e=[];this.draggable.children.forEach(t=>{e.push([Ce(t.position.x,3),Ce(t.position.y,3),Ce(t.position.z,3)])}),ms({name:this.name,points:e,tension:this.tension,closed:this.closed,subdivide:this.subdivide,type:this.curveType}),console.log("Spline copied!")};showPoints=(e=!0)=>{this.draggable.visible=e};addPoints=(e=[])=>{if(e.length>0){const t=e.length-1;for(let i=0;i<t;i++)this.addPoint(e[i],!1);this.addPoint(e[t])}else this.addPoint(new o.Vector3(-50,0,0),!1),this.addPoint(new o.Vector3(50,0,0))};addPoint=(e,t=!0)=>{const i=this.draggable.children.length,n=new o.Mesh(Ja,this.draggedMat);return n.name=`point_${i}`,n.position.copy(e),n.scale.setScalar(this._draggableScale),this.draggable.add(n),t&&this.updateSpline(),n};addNextPt=()=>{const e=this.draggable.children.length,t=new o.Vector3(Qe(-this.offset,this.offset,Math.random()),Qe(-this.offset,this.offset,Math.random()),Qe(-this.offset,this.offset,Math.random()));e>0&&t.add(this.draggable.children[e-1].position);const i=this.addPoint(t);this._transform?.attach(i),this.group.current?.setField("Current Point",i.position)};removePoint=e=>{if(this._transform?.object===e){this._transform?.detach();const t=this.draggable.children[this.draggable.children.length-1];this._transform?.attach(t),this.group.current?.setField("Current Point",t.position)}Pe(e),this.updateSpline()};removePointAt=e=>{const t=this.draggable.children[e];this.removePoint(t)};removeSelectedPt=()=>{this._transform?.object!==void 0&&this.removePoint(this._transform?.object)};updateSpline=()=>{this.curve=new o.CatmullRomCurve3(this.points,this.closed,this.curveType,this.tension),this.line.geometry.setFromPoints(this.getPoints()),this.curvePos.position.copy(this.getPointAt(this._curvePercentage))};onMouseClick=e=>{if(!le.instance||this._transform&&!this._transform.getHelper().visible)return;const i=le.instance.currentWindow.current.getBoundingClientRect();di.x=(e.clientX-i.x)/i.width*2-1,di.y=-((e.clientY-i.y)/i.height)*2+1,this.raycaster.setFromCamera(di,this.camera);const n=this.raycaster.intersectObjects(this.draggable.children,!1);if(n.length>0){const r=n[0].object;r!==this._transform?.object&&(this._transform?.attach(r),this.group.current?.setField("Current Point",r.position))}};getPointAt(e){return this.curve.getPointAt(e)}getPoints(){return this.curve.getPoints(this.subdivide)}getTangentAt(e){return this.curve.getTangentAt(e)}get points(){const e=[];return this.draggable.children.forEach(t=>{e.push(t.position)}),e}get total(){return this.draggable.children.length}get draggableScale(){return this._draggableScale}set draggableScale(e){this._draggableScale=e,this.draggable.children.forEach(t=>t.scale.setScalar(e)),this.curvePos.scale.setScalar(e)}get camera(){return this._camera}set camera(e){this._camera=e,this._transform!==void 0&&(this._transform.camera=e)}get curvePercentage(){return this._curvePercentage}set curvePercentage(e){this._curvePercentage=e,this.curvePos.position.copy(this.getPointAt(e))}onUpdateTransform=()=>{if(this._transform?.object&&this.group){const e=this._transform?.object;e.name.search("point")>-1&&this.group.current?.setField("Current Point",e.position)}this.updateSpline()};initDebug(e){const t=this.draggable.children;this.parentGroup=e,this._transform=de.instance.add(this.name),this._transform.camera=this._camera,this._transform.addEventListener("objectChange",this.onUpdateTransform),this._transform.attach(t.length>0?t[t.length-1]:this),le.instance?.scene.add(this._transform.getHelper());const i=t.length>0?t[t.length-1].position:{x:0,y:0,z:0};this.group=e.addGroup({title:this.name,items:[{prop:"Closed",type:"boolean",value:this.closed},{prop:"Visible",type:"boolean",value:this.visible},{prop:"Show Position",type:"boolean",value:this.curvePos.visible},{prop:"Show Points",type:"boolean",value:this.draggable.visible},{prop:"Color",type:"color",value:`#${this.draggedMat.color.getHexString()}`},{prop:"Curve",type:"option",options:[{title:"Catmullrom",value:"catmullrom"},{title:"Centripetal",value:"centripetal"},{title:"Chordal",value:"chordal"}]},{prop:"Draggable Scale",type:"range",min:.01,max:100,step:.01,value:this._draggableScale},{prop:"Subdivide",type:"range",min:1,max:100,step:1,value:this.subdivide},{prop:"Tension",type:"range",min:0,max:1,step:.01,value:this.tension},{prop:"New Pt Offset",type:"range",min:0,max:10,value:this.offset},{prop:"Curve At",type:"range",min:0,max:1,step:.01,value:0},{prop:"Toggle Transform",type:"button"},{prop:"Add Point",type:"button"},{prop:"Remove Point",type:"button"},{prop:"Export",type:"button"},{prop:"Delete",type:"button"},{prop:"Current Point",type:"grid3",value:i}],onUpdate:(n,r)=>{switch(n){case"Closed":this.closed=r,this.updateSpline();break;case"Visible":this.visible=r;break;case"Color":this.lineMaterial.color.setStyle(r),this.draggedMat.color.setStyle(r);break;case"Curve":this.curveType=r,this.updateSpline();break;case"Draggable Scale":this.draggableScale=r;break;case"Subdivide":this.subdivide=r,this.updateSpline();break;case"Tension":this.tension=r,this.updateSpline();break;case"New Pt Offset":this.offset=r;break;case"Curve At":this.curvePos.position.copy(this.getPointAt(r));break;case"Show Position":this.curvePos.visible=r;break;case"Show Points":this.draggable.visible=r;break;case"Toggle Transform":this._transform&&(this._transform.getHelper().visible=!this._transform.getHelper().visible);break;case"Add Point":this.addNextPt();break;case"Remove Point":this.removeSelectedPt();break;case"Export":this.exportSpline();break;case"Delete":Pe(this);break;case"Current Point":if(this.group.current&&this._transform?.object){const a=this._transform?.object;a.name.search("point")>-1&&(a.position.copy(r),this.updateSpline())}break}}}),this.draggable.children.forEach(n=>{this.debugPoint(n)})}debugPoint=e=>{e.name,e.visible=this.draggable.visible}}let Ut=0;class Ps extends o.Object3D{defaultScale=10;_camera;group=null;constructor(e){super(),this.name="Spline Editor",this._camera=e,R.addEventListener(A.ADD_SPLINE,this.onAddSpline)}initDebug(){this.group=J.addEditorGroup({title:this.name,items:[{type:"button",prop:"New Spline"},{type:"boolean",prop:"Show Points",value:!0},{type:"boolean",prop:"Visible",value:this.visible},{type:"range",prop:"Default Scale",min:0,max:50,step:.01,value:this.defaultScale}],onUpdate:(e,t)=>{switch(e){case"New Spline":this.createSpline();break;case"Show Points":this.showPoints(t);break;case"Visible":this.visible=t;break;case"Default Scale":this.defaultScale=t;break}}})}dispose(){R.removeEventListener(A.ADD_SPLINE,this.onAddSpline),J.removeEditorGroup(this.name)}addSpline(e){e.draggableScale=this.defaultScale,e.hideTransform(),this.group?.current!==null&&e.initDebug(this.group.current),this.add(e)}createSpline=(e=[])=>{const t=`Spline ${Ut+1}`,i=new vi(t,this._camera);return i.addPoints(e),this.addSpline(i),Ut++,i};createSplineFromArray=e=>{const t=[];return e.forEach(i=>{t.push(new o.Vector3(i[0],i[1],i[2]))}),this.createSpline(t)};createSplineFromCatmullRom=e=>this.createSpline(e.points);createSplineFromJSON=e=>{const t=this.createSplineFromArray(e.points);return t.name=e.name,t.closed=e.closed,t.subdivide=e.subdivide,t.tension=e.tension,t.type=e.type,t.updateSpline(),t};showPoints=(e=!0)=>{this.children.forEach(t=>{t.showPoints(e)})};onAddSpline=e=>{const t=JSON.parse(e.value),i=`Spline ${Ut+1}`,n=[];t.points.forEach(a=>{n.push(new o.Vector3(a[0],a[1],a[2]))});const r=new vi(i,this.camera);r.addPoints(n),this.addSpline(r),Ut++};get camera(){return this._camera}set camera(e){this._camera=e,this.children.forEach(t=>{const i=t;i.camera=e})}}const ds=["Single","Side by Side","Stacked","Quad"],er="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAC60lEQVRYhe2YT4hNcRTHP48xpmYaNAvRyEQxEhnKQljYsRm9/EmSyJiMFAsMZWNhJYoNIUVJ2VGiyb9ZzIpMpkQSahbGv9GMYWrM+1rc2zjvzvvdd+99rzdvMd+6de75nd+5387vnN/v/G5KEuWMKRNNIB8mCRaKiiL5qQb2ApuBuUAV0Ad0AJeB3sSeJRX6LJbULTf6JTUn9Z+KWMUpPyp/Avoa4CNQZ3Sj/lNpdL/xottR7AjOkHRUUpekN5I6JbVLavDH75lIfZN0UFKTpCWS0pJem/HeJBEMG6yV1ONYtgFJbZJ+GF1jDh+zJb03NuliEuwMkMo4yErS2RA/LcbuYVyCrm1mA7Dal/8Cu4FG4JD/HsTTkCy6a+SVMTPQuc1sBKb78nHghi+/A+YBxwL2lbhRY+ThuARdEVxu5JdGFvACr0otdoZ8Y4+Rn0Sn5sFFsMvI6YB9MzA1YJ8mN8k1wAHzfj4uQVdyrpI0aJL7oqTtkq4FiqPLyCOSbktqlbRL0jlJQ2b8QdwCUZ4qvhRStZL0XFK1pMd57CRvq5mfhKBriRfiFUMY6oD7eOdwPlQAN4G10dfWg+uouwXsiOssAj4AC+JMcEWwvnAuOTEr7gTXPmg34zagOwkbIIOXAo9CbDYBrcBXYN+4UUdy2sRflyS5zVNlfPX7ugpJW5V9nI7mmh+lYU0lCZ2B3TOnAVuAk0BTwC5nuhWro46KauBOQJch5OpRaoIW34GreGf+YZdRqS9NAj4Bp4ClQDvwOWxCqSM4ADQEdKE5XvbXzlITrAVe4TW+M6NMKDXBFLAMuAD0ACfIc7pMZBXXA2cY3/xmodQRHAL2A2+NLtj8ZiEKwUL/z2WMPAJcAVYALWSf8dZuDFGWeBHwKxm3sWYhiGG8Tfo6sA2vSfiSy4GrH3wGrDcfKSSKKf6v1E9yF0XK9Q1XBPuMXMw8HXTonQFwETwNzMFr64v1jzgFHIk9ybHEZYPJo65QlD3Bf2/Q/eaHPiSWAAAAAElFTkSuQmCC",tr="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAETklEQVRYhe2YXYhVVRTHf3d0/JhyUrMpFbImM+whSa3Mynww+4AeIgiKoozooQ+KyMyXIAujF6OXqHyI6iEKKYgIP/owsjSFqCkprdDUTEcjbWZ0HHV+Pex1ucfb9Z57Z9REXHA4Z++99l7/s/ZZ/7X2KaiczNLwfwPIk9MA+yunNMAG4DHgV+BvoB3YFff2TPstYEyfrajVroI6Sr1GvahsbJC63HzZq04pmztSvU5tVRuqYRiYg78JeBR4HPg5ntdmxovz9wJfA3uAxuibDLQCA+IqynnAQuBuYCnwMLC1rx48U12U8cZqdWqMDcx4cI16qTpYbVKHqa+ovWUeHKsujn7VL9ULq2HI+wY7gVeBJdGeFu3J4ZUiy/cAXeHRRuAQsC/GC0B3eG4BcH/0tUV7czUAeVsMsBF4Kha9HZgCvAncAuwPnXHA0wFuGLANuDrGuoGDwFxgTqzzQ7RX5FrP2eLsdb76vnogtme6+nE8H1YPlQXHwbi3q9eqn0e7Tb25VrsF68vFY0lb1AGcDTwItGQ8tQM4AIwGmqP/EPAu8A0wElgJfFGzxTo8mKWXu9Rd4ZF96jvqjSbauEC9Sn1O3R463epLaku99voCsFXdkAH3kNpcQW+IiT/bQne3eufxBtioPqP2mKhioXpWzpxb1T8C5Ifh4ZptVoriRmAIKdrI3Lujf3bobAPeJpF0NVkKrAFuI9HTOBIxnxFrF4OgQKKr/dnJlQA+AcwABgOHA4zAamA5cE7orQL+zAEHiWI+A2bFC7aSguheYCgpqAphZz3wSB7AecCICv2TgH8oFRib4gVqka0k0h8CXAxMBW6ooDejFoCvA9OBQUAvKWM0kDz4XUZvNKXtyZMWUl7vBbaQXq457PeEziDgx/KJlQAuIPFdMcEXv5OdYWBP9M8k8VpnDQCvB4aTSrCNJB5cSdrW3tBpIJVnR0qdUTxAfdGUOVTnmwqEanNmqltC/9OgqePKg5eom8PgdvW+oJ9Kupera0O3U50TL3lcAaI+oHaF4R3qa6Z822wq0Saq89T1lmSxOrxeW/Xm4uGkiqQDmECKuKHxHW0HdpMiewSpvGqKeR8Ay0iBsYIjg6261PE2o9Q3Yqv+MqWxO9R1Hl12qs+q49Vlppy82pSr+5xJKsko4AXgHlJ0t5NIeg3wLXAlqZhtIUV8J6nmWwX8QiLjdhL5TwMWkY4R6/rrwYKlMr1Y321QZ/vfwBijPqm+rF4Wc7PjE9QllurGVeoV5gRNHsAm9fnMom3qrKPoTjKdMXaYyrFygEWQ72XWW24qhPu8xcUc2UU6O8wFPjmK7jhgPHAuMJGUGQ6U6WwE5sfzTXGvei7KA9hFOiR9D/wOfFVFt4dS2tpfRe83Ur7/CPiJakfOGgBCypubatArl2r8VfOax/LfzABKtePAzHO/5FgC7KBEzB2kOrDfUm8mOeFySv9+OyFyGmB/5aQH+C9BVKmVCNuMZgAAAABJRU5ErkJggg==";class le extends O.Component{static instance=null;scene=new o.Scene;renderer;currentScene;cameras=new Map;controls=new Map;currentCamera;currentWindow;cameraHelpers=new Map;lightHelpers=new Map;helpersContainer=new o.Group;grid=new za;interactionHelper=new o.AxesHelper(25);currentTransform;splineEditor;depthMaterial=new o.MeshDepthMaterial;normalsMaterial=new o.MeshNormalMaterial;uvMaterial=new Ba;wireframeMaterial=new o.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0});playing=!1;rafID=-1;cameraControlsRafID=-1;width=0;height=0;sceneSet=!1;tlCam=null;trCam=null;blCam=null;brCam=null;tlRender="Renderer";trRender="Renderer";blRender="Renderer";brRender="Renderer";cameraVisibility=!0;lightVisibility=!0;selectedItem=void 0;debugCamera;raycaster=new o.Raycaster;pointer=new o.Vector2;cameraControls=void 0;canvasRef;containerRef;tlWindow;trWindow;blWindow;brWindow;constructor(e){super(e),this.canvasRef=O.createRef(),this.containerRef=O.createRef(),this.tlWindow=O.createRef(),this.trWindow=O.createRef(),this.blWindow=O.createRef(),this.brWindow=O.createRef();const t=e.three.app.appID,i=localStorage,n=i.getItem(`${t}_mode`);this.state={mode:n!==null?n:"Single",modeOpen:!1,renderModeOpen:!1,interactionMode:"Orbit",interactionModeOpen:!1,lastUpdate:Date.now()},i.setItem(`${t}_mode`,this.state.mode),i.setItem(`${t}_tlCam`,i.getItem(`${t}_tlCam`)!==null?i.getItem(`${t}_tlCam`):"Debug"),i.setItem(`${t}_trCam`,i.getItem(`${t}_trCam`)!==null?i.getItem(`${t}_trCam`):"Orthographic"),i.setItem(`${t}_blCam`,i.getItem(`${t}_blCam`)!==null?i.getItem(`${t}_blCam`):"Front"),i.setItem(`${t}_brCam`,i.getItem(`${t}_brCam`)!==null?i.getItem(`${t}_brCam`):"Top"),i.setItem(`${t}_tlRender`,i.getItem(`${t}_tlRender`)!==null?i.getItem(`${t}_tlRender`):"Renderer"),i.setItem(`${t}_trRender`,i.getItem(`${t}_trRender`)!==null?i.getItem(`${t}_trRender`):"Renderer"),i.setItem(`${t}_blRender`,i.getItem(`${t}_blRender`)!==null?i.getItem(`${t}_blRender`):"Renderer"),i.setItem(`${t}_brRender`,i.getItem(`${t}_brRender`)!==null?i.getItem(`${t}_brRender`):"Renderer");const r={Vector2:o.Vector2,Vector3:o.Vector3,Vector4:o.Vector4,Quaternion:o.Quaternion,Matrix4:o.Matrix4,Spherical:o.Spherical,Box3:o.Box3,Sphere:o.Sphere,Raycaster:o.Raycaster};Me.install({THREE:r}),this.setupScene(),this.setupTools();const a=localStorage.getItem(this.expandedCameraVisibility);this.cameraVisibility=a!==null?a==="open":!1,this.saveExpandedCameraVisibility();const l=localStorage.getItem(this.expandedLightVisibility);this.lightVisibility=l!==null?l==="open":!1,this.saveExpandedLightVisibility(),le.instance=this}componentDidMount(){this.setupRenderer(),this.enable(),this.assignControls(),this.resize(),this.play(),de.instance.three=this.props.three,de.instance.activeCamera=this.debugCamera}componentDidUpdate(e,t,i){t.mode!==this.state.mode&&(this.assignControls(),this.resize())}componentWillUnmount(){this.disable(),J.removeEditorGroup("View Settings")}render(){const e=[];return this.cameras.forEach((t,i)=>{e.push(i)}),p.jsxs("div",{className:"multiview",children:[p.jsx("canvas",{ref:this.canvasRef}),p.jsxs("div",{className:`cameras ${this.state.mode==="Single"||this.state.mode==="Stacked"?"single":""}`,ref:this.containerRef,children:[this.state.mode==="Single"&&p.jsx(p.Fragment,{children:p.jsx(ze,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const i=this.cameras.get(t);i!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=i,localStorage.setItem(`${this.appID}_tlCam`,i.name),this.createControls(i,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}})}),(this.state.mode==="Side by Side"||this.state.mode==="Stacked")&&p.jsxs(p.Fragment,{children:[p.jsx(ze,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const i=this.cameras.get(t);i!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=i,localStorage.setItem(`${this.appID}_tlCam`,i.name),this.createControls(i,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}}),p.jsx(ze,{name:"tr",camera:this.trCam,options:e,ref:this.trWindow,onSelectCamera:t=>{this.controls.get(this.trCam.name)?.dispose();const i=this.cameras.get(t);i!==void 0&&(this.clearCamera(this.trCam),this.trCam=i,localStorage.setItem(`${this.appID}_trCam`,i.name),this.createControls(i,this.trWindow.current))},onSelectRenderMode:t=>{this.trRender=t,localStorage.setItem(`${this.appID}_trRender`,t)}})]}),this.state.mode==="Quad"&&p.jsxs(p.Fragment,{children:[p.jsx(ze,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const i=this.cameras.get(t);i!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=i,localStorage.setItem(`${this.appID}_tlCam`,i.name),this.createControls(i,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}}),p.jsx(ze,{name:"tr",camera:this.trCam,options:e,ref:this.trWindow,onSelectCamera:t=>{this.controls.get(this.trCam.name)?.dispose();const i=this.cameras.get(t);i!==void 0&&(this.clearCamera(this.trCam),this.trCam=i,localStorage.setItem(`${this.appID}_trCam`,i.name),this.createControls(i,this.trWindow.current))},onSelectRenderMode:t=>{this.trRender=t,localStorage.setItem(`${this.appID}_trRender`,t)}}),p.jsx(ze,{name:"bl",camera:this.blCam,options:e,ref:this.blWindow,onSelectCamera:t=>{this.controls.get(this.blCam.name)?.dispose();const i=this.cameras.get(t);i!==void 0&&(this.clearCamera(this.blCam),this.blCam=i,localStorage.setItem(`${this.appID}_blCam`,i.name),this.createControls(i,this.blWindow.current))},onSelectRenderMode:t=>{this.blRender=t,localStorage.setItem(`${this.appID}_blRender`,t)}}),p.jsx(ze,{name:"br",camera:this.brCam,options:e,ref:this.brWindow,onSelectCamera:t=>{this.controls.get(this.brCam.name)?.dispose();const i=this.cameras.get(t);i!==void 0&&(this.clearCamera(this.brCam),this.brCam=i,localStorage.setItem(`${this.appID}_brCam`,i.name),this.createControls(i,this.brWindow.current))},onSelectRenderMode:t=>{this.brRender=t,localStorage.setItem(`${this.appID}_brRender`,t)}})]})]}),p.jsxs("div",{className:"settings",children:[p.jsx(Ht,{title:"View",index:ds.indexOf(this.state.mode),options:ds,onSelect:t=>{t!==this.state.mode&&(this.killControls(),this.setState({mode:t}),localStorage.setItem(`${this.appID}_mode`,t))},open:this.state.modeOpen,onToggle:t=>{this.setState({modeOpen:t,renderModeOpen:!1,interactionModeOpen:!1})}}),p.jsx(Ht,{title:"Interact",index:this.state.interactionMode==="Orbit"?0:1,options:["Orbit Mode","Selection Mode"],onSelect:t=>{this.interactionHelper.visible=t==="Selection Mode",this.setState({interactionMode:this.interactionHelper.visible?"Selection":"Orbit"})},open:this.state.interactionModeOpen,onToggle:t=>{this.setState({modeOpen:!1,renderModeOpen:!1,interactionModeOpen:t})}}),p.jsx(ss,{name:"cameraHelper",icon:er,selected:this.cameraVisibility,height:24,top:2,onClick:t=>{if(this.cameraVisibility=t,this.saveExpandedCameraVisibility(),this.cameraHelpers.forEach(i=>{i.visible=t}),this.selectedItem!==void 0&&!t&&this.selectedItem instanceof o.PerspectiveCamera){const i=this.cameraHelpers.get(this.selectedItem.name);i!==void 0&&(i.visible=!0)}}}),p.jsx(ss,{name:"lightHelper",icon:tr,selected:this.lightVisibility,height:24,top:4,onClick:t=>{if(this.lightVisibility=t,this.saveExpandedLightVisibility(),this.lightHelpers.forEach(i=>{i.visible=t}),this.selectedItem!==void 0&&!t&&this.selectedItem.isLight===!0){const i=this.lightHelpers.get(this.selectedItem.name);i!==void 0&&(i.visible=!0)}}})]},this.state.lastUpdate)]})}setupRenderer(){this.renderer=new o.WebGLRenderer({canvas:this.canvasRef.current,stencil:!1}),this.renderer.autoClear=!1,this.renderer.shadowMap.enabled=!0,this.renderer.setPixelRatio(devicePixelRatio),this.renderer.setClearColor(0),this.props.three.renderer=this.renderer}setupScene(){this.scene.name="Debug Scene",this.scene.uuid="",this.helpersContainer.name="helpers",this.scene.add(this.helpersContainer),this.helpersContainer.add(this.grid),this.interactionHelper.name="interactionHelper",this.interactionHelper.visible=!1,this.helpersContainer.add(this.interactionHelper);const e=(r,a)=>{const l=new o.OrthographicCamera(-100,100,100,-100,0,3e3);return l.name=r,l.position.copy(a),l.lookAt(0,0,0),this.cameras.set(r,l),l},t=1e3;e("Top",new o.Vector3(0,t,0)),e("Bottom",new o.Vector3(0,-t,0)),e("Left",new o.Vector3(-t,0,0)),e("Right",new o.Vector3(t,0,0)),e("Front",new o.Vector3(0,0,t)),e("Back",new o.Vector3(0,0,-t)),e("Orthographic",new o.Vector3(t,t,t)),e("UI",new o.Vector3),this.debugCamera=new o.PerspectiveCamera(60,1,50,5e3),this.debugCamera.name="Debug",this.debugCamera.position.set(500,500,500),this.debugCamera.lookAt(0,0,0),this.cameras.set("Debug",this.debugCamera),this.currentCamera=this.debugCamera;const i=localStorage,n=this.props.three.app.appID;this.tlCam=this.cameras.get(i.getItem(`${n}_tlCam`)),this.trCam=this.cameras.get(i.getItem(`${n}_trCam`)),this.blCam=this.cameras.get(i.getItem(`${n}_blCam`)),this.brCam=this.cameras.get(i.getItem(`${n}_brCam`)),this.tlCam===void 0&&(this.tlCam=this.cameras.get("Debug")),this.trCam===void 0&&(this.trCam=this.cameras.get("Orthographic")),this.blCam===void 0&&(this.blCam=this.cameras.get("Front")),this.brCam===void 0&&(this.brCam=this.cameras.get("Top"))}setupTools(){J.addEditorGroup({title:"View Settings",items:[{type:"boolean",prop:"Show Grid",value:this.grid.visible}],onUpdate:(e,t)=>{switch(e){case"Show Grid":this.grid.visible=t;break}}}),this.splineEditor=new Ps(this.currentCamera),this.splineEditor.initDebug(),this.scene.add(this.splineEditor)}play(){this.playing=!0,this.onUpdate()}pause(){this.playing=!1,cancelAnimationFrame(this.rafID),this.rafID=-1}toggleOrbitControls(e){this.controls.forEach(t=>{t.enabled=!e})}update(){this.controls.forEach(e=>{e.update()}),this.cameraHelpers.forEach(e=>{e.update()}),this.lightHelpers.forEach(e=>{e.update!==void 0&&e.update()}),this.props.onSceneUpdate!==void 0&&this.sceneSet&&this.props.onSceneUpdate(this.currentScene)}draw(){switch(this.renderer?.clear(),this.state.mode){case"Single":this.drawSingle();break;case"Side by Side":case"Stacked":this.drawDouble();break;case"Quad":this.drawQuad();break}}onUpdate=()=>{this.playing&&(this.update(),this.draw(),this.rafID=requestAnimationFrame(this.onUpdate))};enable(){const e=this.containerRef.current;e.addEventListener("mousemove",this.onMouseMove),e.addEventListener("click",this.onClick),window.addEventListener("keydown",this.onKey),window.addEventListener("resize",this.resize),R.addEventListener(A.SET_SCENE,this.sceneUpdate),R.addEventListener(A.ADD_CAMERA,this.addCamera),R.addEventListener(A.REMOVE_CAMERA,this.removeCamera),R.addEventListener(A.SET_OBJECT,this.onSetSelectedItem)}disable(){const e=this.containerRef.current;e.removeEventListener("mousemove",this.onMouseMove),e.removeEventListener("click",this.onClick),window.removeEventListener("keydown",this.onKey),window.removeEventListener("resize",this.resize),R.removeEventListener(A.SET_SCENE,this.sceneUpdate),R.removeEventListener(A.ADD_CAMERA,this.addCamera),R.removeEventListener(A.REMOVE_CAMERA,this.removeCamera),R.removeEventListener(A.SET_OBJECT,this.onSetSelectedItem)}resize=()=>{this.width=window.innerWidth-300,this.height=window.innerHeight;const e=Math.floor(this.width/2),t=Math.floor(this.height/2);this.props.three.resize(this.width,this.height),this.props.onSceneResize!==void 0&&this.sceneSet&&this.currentScene!==void 0&&this.props.onSceneResize(this.currentScene,this.width,this.height);let i=this.width,n=this.height;switch(this.state.mode){case"Side by Side":i=e,n=this.height;break;case"Stacked":i=this.width,n=t;break;case"Quad":i=e,n=t;break}const r=i/n;this.cameras.forEach(a=>{a instanceof o.OrthographicCamera?(a.left=i/-2,a.right=i/2,a.top=n/2,a.bottom=n/-2,a.name==="UI"&&(a.position.x=this.width/2,a.position.y=this.height/-2,a.position.z=100),a.updateProjectionMatrix()):a instanceof o.PerspectiveCamera&&(a.aspect=r,a.updateProjectionMatrix(),this.cameraHelpers.get(a.name)?.update())})};sceneUpdate=e=>{this.clearLightHelpers(),this.scene.remove(this.currentScene),Pe(this.currentScene);const t=this.props.scenes.get(e.value.name);if(t!==void 0){const i=new t;this.props.onSceneSet!==void 0&&this.props.onSceneSet(i),this.currentScene=i,this.props.three.scene=this.currentScene,this.scene.add(this.currentScene),this.sceneSet=!0,this.addLightHelpers()}};addCamera=e=>{const t=e.value,i=this.props.three.scene?.getObjectByProperty("uuid",t.uuid);if(i!==void 0&&this.cameras.set(t.name,i),i instanceof o.PerspectiveCamera){const n=new o.CameraHelper(i);n.visible=this.cameraVisibility,this.cameraHelpers.set(i.name,n),this.scene.add(n)}this.setState({lastUpdate:Date.now()})};removeCamera=e=>{const t=this.cameraHelpers.get(e.value.name);t!==void 0&&(this.scene.remove(t),t.dispose()),this.cameras.delete(e.value.name),this.setState({lastUpdate:Date.now()})};onMouseMove=e=>{const t=new o.Vector2;this.renderer.getSize(t);const i=Math.min(e.clientX,t.x),n=Math.min(e.clientY,t.y);this.pointer.x=qe(i,0,t.x,-1,1),this.pointer.y=qe(n,0,t.y,1,-1);const r=t.x/2,a=t.y/2,l=()=>{i<r?this.pointer.x=qe(i,0,r,-1,1):this.pointer.x=qe(i,r,t.x,-1,1)},h=()=>{n<a?this.pointer.y=qe(n,0,a,1,-1):this.pointer.y=qe(n,a,t.y,1,-1)};switch(this.state.mode){case"Quad":l(),h();break;case"Side by Side":l();break;case"Stacked":h(),h();break}if(this.updateCamera(i,n,r,a),this.state.interactionMode==="Orbit")return;const c=this.raycaster.intersectObjects(this.currentScene.children);c.length>0&&this.interactionHelper.position.copy(c[0].point)};onClick=e=>{if(this.state.interactionMode==="Orbit")return;const t=new o.Vector2;if(this.renderer.getSize(t),e.clientX>=t.x)return;this.onMouseMove(e);const i=this.raycaster.intersectObjects(this.currentScene.children);i.length>0&&(this.props.three.getObject(i[0].object.uuid),this.interactionHelper.visible=!1,this.setState({interactionMode:"Orbit",lastUpdate:Date.now()}))};onKey=e=>{if(this.selectedItem!==void 0){if(e.ctrlKey){if(this.currentCamera.name==="UI")return;const t=this.controls.get(this.currentCamera.name);e.key==="0"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Me(this.currentCamera,this.currentWindow.current),this.selectedItem instanceof o.Mesh||this.selectedItem instanceof o.SkinnedMesh?(this.selectedItem.geometry.computeBoundingBox(),this.cameraControls.fitToBox(this.selectedItem.geometry.boundingBox,!0)):this.cameraControls.fitToSphere(this.selectedItem,!0),this.updateCameraControls(t,!0)):e.key==="1"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Me(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(0,Math.PI*.5,!0),this.cameraControls.moveTo(this.selectedItem.position.x,this.selectedItem.position.y,0,!0),this.updateCameraControls(t)):e.key==="2"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Me(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(0,0,!0),this.cameraControls.moveTo(this.selectedItem.position.x,0,this.selectedItem.position.z,!0),this.updateCameraControls(t)):e.key==="3"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Me(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Math.PI/2,Math.PI/2,!0),this.cameraControls.moveTo(0,this.selectedItem.position.y,this.selectedItem.position.z,!0),this.updateCameraControls(t)):e.key==="4"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Me(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Math.PI,Math.PI/2,!0),this.cameraControls.moveTo(this.selectedItem.position.x,this.selectedItem.position.y,0,!0),this.updateCameraControls(t)):e.key==="5"&&(e.preventDefault(),this.clearControls(),this.cameraControls=new Me(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(gi(45),gi(45),!0),this.updateCameraControls(t))}else if(this.currentTransform!==void 0)switch(e.key){case"r":this.currentTransform.setMode("rotate");break;case"s":this.currentTransform.setMode("scale");break;case"t":this.currentTransform.setMode("translate");break;case"q":this.currentTransform.setSpace(this.currentTransform.space==="local"?"world":"local");break}}};onSetSelectedItem=e=>{this.selectedItem!==void 0&&this.updateSelectedItemHelper(!1),this.selectedItem=this.currentScene.getObjectByProperty("uuid",e.value.uuid),this.selectedItem!==void 0&&(this.currentTransform!==void 0&&(this.currentTransform.removeEventListener("objectChange",this.onUpdateTransform),de.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=de.instance.add(e.value.name),this.currentTransform.attach(this.selectedItem),this.scene.add(this.currentTransform.getHelper()),this.currentTransform.addEventListener("objectChange",this.onUpdateTransform),this.updateSelectedItemHelper(!0))};updateSelectedItemHelper(e){if(this.selectedItem!==void 0){if(this.selectedItem instanceof o.PerspectiveCamera&&!this.cameraVisibility){const t=this.cameraHelpers.get(this.selectedItem.name);t!==void 0&&(t.visible=e)}else if(this.selectedItem.isLight===!0&&!this.lightVisibility){const t=this.lightHelpers.get(this.selectedItem.name);t!==void 0&&(t.visible=e)}}}onUpdateTransform=()=>{this.selectedItem!==void 0&&(this.props.three.updateObject(this.selectedItem.uuid,"position",this.selectedItem.position),this.props.three.updateObject(this.selectedItem.uuid,"rotation",{x:this.selectedItem.rotation.x,y:this.selectedItem.rotation.y,z:this.selectedItem.rotation.z}),this.props.three.updateObject(this.selectedItem.uuid,"scale",this.selectedItem.scale),Yt.instance.update())};clearLightHelpers=()=>{this.lightHelpers.forEach(e=>{this.helpersContainer.remove(e),e.dispose()}),this.lightHelpers.clear()};addLightHelpers=()=>{this.currentScene!==void 0&&this.currentScene.traverse(e=>{if(e.type.search("Light")>-1){let t;switch(e.type){case"DirectionalLight":t=new o.DirectionalLightHelper(e,100),t.name=`${e.name}Helper`,t.visible=this.lightVisibility,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"HemisphereLight":t=new o.HemisphereLightHelper(e,250),t.name=`${e.name}Helper`,t.visible=this.lightVisibility,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"RectAreaLight":t=new ya(e),t.name=`${e.name}Helper`,t.visible=this.lightVisibility,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"PointLight":t=new o.PointLightHelper(e,100),t.name=`${e.name}Helper`,t.visible=this.lightVisibility,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"SpotLight":t=new o.SpotLightHelper(e),t.name=`${e.name}Helper`,t.visible=this.lightVisibility,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break}}})};createControls(e,t){const i=this.controls.get(e.name);if(i!==void 0&&i.dispose(),this.controls.delete(e.name),e.name==="UI")return;const n=new ba(e,t);switch(n.enableDamping=!0,n.dampingFactor=.05,e.name){case"Top":case"Bottom":case"Left":case"Right":case"Front":case"Back":n.enableRotate=!1;break}this.controls.set(e.name,n)}clearCamera(e){const t=this.cameraHelpers.get(e.name);t!==void 0&&(this.scene.remove(t),t.dispose(),this.cameraHelpers.delete(e.name));const i=this.controls.get(e.name);i!==void 0&&(i.dispose(),this.controls.delete(e.name))}killControls(){this.controls.forEach((e,t)=>{e.dispose();const i=this.cameraHelpers.get(t);i!==void 0&&(this.scene.remove(i),i.dispose()),this.cameraHelpers.delete(t),this.controls.delete(t)}),this.controls.clear(),this.cameraHelpers.clear()}assignControls(){switch(this.state.mode){case"Single":this.createControls(this.tlCam,this.tlWindow.current);break;case"Side by Side":case"Stacked":this.createControls(this.tlCam,this.tlWindow.current),this.createControls(this.trCam,this.trWindow.current);break;case"Quad":this.createControls(this.tlCam,this.tlWindow.current),this.createControls(this.trCam,this.trWindow.current),this.createControls(this.blCam,this.blWindow.current),this.createControls(this.brCam,this.brWindow.current);break}}updateCamera=(e,t,i,n)=>{switch(this.state.mode){case"Quad":t<n?e<i?this.currentCamera=this.tlCam:this.currentCamera=this.trCam:e<i?this.currentCamera=this.blCam:this.currentCamera=this.brCam;break;case"Side by Side":e<i?this.currentCamera=this.tlCam:this.currentCamera=this.trCam;break;case"Single":this.currentCamera=this.tlCam;break;case"Stacked":t<n?this.currentCamera=this.tlCam:this.currentCamera=this.trCam;break}this.splineEditor.camera=this.currentCamera,this.raycaster.setFromCamera(this.pointer,this.currentCamera),this.currentCamera===this.tlCam?this.currentWindow=this.tlWindow:this.currentCamera===this.trCam?this.currentWindow=this.trWindow:this.currentCamera===this.blCam?this.currentWindow=this.blWindow:this.currentCamera===this.brCam&&(this.currentWindow=this.brWindow),de.instance.updateCamera(this.currentCamera,this.currentWindow.current)};updateCameraControls=(e,t=!1)=>{if(this.selectedItem===void 0)return;cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.cameraControls&&(this.cameraControls.smoothTime=.1);const i=.15,n=new o.Clock;n.start(),this.selectedItem.getWorldPosition(e.target0);const r=()=>{const a=n.getDelta();this.cameraControls&&this.cameraControls.update(a),t&&(e.target.lerp(e.target0,i),e.object.position.lerp(e.position0,i),e.object.zoom=it(e.object.zoom,e.zoom0,i),e.object.updateProjectionMatrix(),e.dispatchEvent({type:"change"})),n.getElapsedTime()>=.5?(cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.clearControls()):this.cameraControlsRafID=requestAnimationFrame(r)};r()};clearControls=()=>{this.cameraControls!==void 0&&(this.cameraControls.disconnect(),this.cameraControls.dispose(),this.cameraControls=void 0)};saveExpandedCameraVisibility(){localStorage.setItem(this.expandedCameraVisibility,this.cameraVisibility?"open":"closed")}saveExpandedLightVisibility(){localStorage.setItem(this.expandedLightVisibility,this.lightVisibility?"open":"closed")}getSceneOverride(e){switch(e){case"Depth":return this.depthMaterial;case"Normals":return this.normalsMaterial;case"Renderer":return null;case"UVs":return this.uvMaterial;case"Wireframe":return this.wireframeMaterial}return null}drawTo(e,t,i,n,r,a){switch(r.name){case"Left":case"Right":this.grid.rotation.z=Math.PI/2;break;case"Front":case"Back":this.grid.rotation.x=Math.PI/2;break}this.scene.overrideMaterial=a,this.renderer?.setViewport(e,t,i,n),this.renderer?.setScissor(e,t,i,n),this.renderer?.render(this.scene,r),this.grid.rotation.set(0,0,0)}drawSingle(){const e=this.getSceneOverride(this.tlRender);this.drawTo(0,0,this.width,this.height,this.tlCam,e)}drawDouble=()=>{const e=this.getSceneOverride(this.tlRender),t=this.getSceneOverride(this.trRender),i=Math.floor(this.width/2),n=Math.floor(this.height/2);if(this.state.mode==="Side by Side")this.drawTo(0,0,i,this.height,this.tlCam,e),this.drawTo(i,0,i,this.height,this.trCam,t);else{const r=this.height-n;this.drawTo(0,r,this.width,n,this.tlCam,e),this.drawTo(0,0,this.width,n,this.trCam,t)}};drawQuad=()=>{const e=this.getSceneOverride(this.tlRender),t=this.getSceneOverride(this.trRender),i=this.getSceneOverride(this.blRender),n=this.getSceneOverride(this.brRender),r=Math.floor(this.width/2),a=Math.floor(this.height/2);let l=0,h=0;h=this.height-a,l=0,this.drawTo(l,h,r,a,this.tlCam,e),l=r,this.drawTo(l,h,r,a,this.trCam,t),h=0,l=0,this.scene.overrideMaterial=i,this.drawTo(l,h,r,a,this.blCam,i),l=r,this.drawTo(l,h,r,a,this.brCam,n)};get appID(){return this.props.three.app.appID}get mode(){return this.state.mode}get three(){return this.props.three}get expandedCameraVisibility(){return`${this.appID}_multiviewCameraVisibility`}get expandedLightVisibility(){return`${this.appID}_multiviewLightVisibility`}}class Yt extends O.Component{static instance;matrix=new o.Matrix4;position=new o.Vector3;rotation=new o.Euler;scale=new o.Vector3;open=!1;constructor(e){super(e);const t=localStorage.getItem(this.expandedName),i=t!==null?t==="open":!1;this.open=i,this.saveExpanded(),this.state={lastUpdated:0,expanded:i},this.matrix.elements=e.object.matrix,e.object.uuid.length>0&&(this.position.setFromMatrixPosition(this.matrix),this.rotation.setFromRotationMatrix(this.matrix),this.scale.setFromMatrixScale(this.matrix)),Yt.instance=this}update(){if(le.instance){const e=le.instance.selectedItem;if(e===void 0)return;this.position.x=Ce(e.position.x,3),this.position.y=Ce(e.position.y,3),this.position.z=Ce(e.position.z,3),this.rotation.copy(e.rotation),this.scale.x=Ce(e.scale.x,3),this.scale.y=Ce(e.scale.y,3),this.scale.z=Ce(e.scale.z,3),this.setState({lastUpdated:Date.now()})}}render(){return p.jsx(be,{title:"Transform",expanded:this.open,items:[{title:"Position",prop:"position",type:"grid3",step:.1,value:this.position,onChange:this.updateTransform},{title:"Rotation",prop:"rotation",type:"euler",value:this.rotation,onChange:this.updateTransform},{title:"Scale",prop:"scale",type:"grid3",value:this.scale,onChange:this.updateTransform},{title:"Visible",prop:"visible",type:"boolean",value:this.props.object.visible,onChange:this.updateTransform}],onToggle:e=>{this.open=e,this.saveExpanded()}},this.state.lastUpdated)}updateTransform=(e,t)=>{const i=e==="rotation"?{x:t._x,y:t._y,z:t._z}:t;this.props.three.updateObject(this.props.object.uuid,e,i);const n=this.props.three.getScene(this.props.object.uuid);if(n){const r=n.getObjectByProperty("uuid",this.props.object.uuid);te(r,e,i)}};saveExpanded(){localStorage.setItem(this.expandedName,this.open?"open":"closed")}get expandedName(){return`${this.props.three.app.appID}_transform`}}function us(s){switch(s){case"color":return"Color";case"intensity":return"Intensity";case"decay":return"Decay";case"distance":return"Distance";case"angle":return"Angle";case"penumbra":return"Penumbra";case"groundColor":return"Ground Color";case"width":return"Width";case"height":return"Height"}return s}function ir(s,e){function t(){return`${e.app.appID}_light`}const i=localStorage.getItem(t()),n=i!==null?i==="open":!1;function r(l){localStorage.setItem(t(),l?"open":"closed")}const a=[];if(s.lightInfo!==void 0)for(const l in s.lightInfo){const h=s.lightInfo[l];h!==void 0&&(h.isColor!==void 0?a.push({title:us(l),prop:l,type:"color",value:h,onChange:(c,u)=>{const m=new o.Color(u);e.updateObject(s.uuid,c,m);const f=e.getScene(s.uuid);if(f!==null){const g=f.getObjectByProperty("uuid",s.uuid);te(g,c,m)}}}):a.push({title:us(l),prop:l,type:typeof h,value:h,step:typeof h=="number"?.01:void 0,onChange:(c,u)=>{e.updateObject(s.uuid,c,u);const m=e.getScene(s.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",s.uuid);te(f,c,u)}}}))}return p.jsx(be,{title:"Light",items:a,expanded:n,onToggle:l=>{r(l)}})}function sr(s){const e=s.object,t=s.three;function i(){return`${t.app.appID}_animation`}const n=localStorage.getItem(i()),r=n!==null?n==="open":!1;function a(f){localStorage.setItem(i(),f?"open":"closed")}const l=[],h=[];let c=0;e.animations.forEach(f=>{c=Math.max(c,f.duration),f.duration>0&&h.push({title:f.name,items:[{title:"Duration",type:"number",value:f.duration,disabled:!0},{title:"Blend Mode",type:"option",disabled:!0,options:[{title:"Normal",value:2500},{title:"Additive",value:2501}]}]})}),l.push({title:"Animations",items:h});let u;const m=t.getScene(e.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",e.uuid);if(f!==void 0){const g=f.mixer;if(g!==void 0){const y=[{title:"Time Scale",type:"range",value:g.timeScale,step:.01,min:-1,max:2,onChange:(T,_)=>{g.timeScale=_,t.updateObject(e.uuid,"mixer.timeScale",_)}}];y.push({title:"Stop All",type:"button",onChange:()=>{g.stopAllAction(),t.requestMethod(e.uuid,"stopAllAction",void 0,"mixer")}}),l.push({title:"Mixer",items:y}),u=new o.SkeletonHelper(f),le.instance?.scene.add(u)}}}return O.useEffect(()=>()=>{u!==void 0&&Pe(u)},[]),p.jsx(be,{title:"Animation",items:l,expanded:r,onToggle:f=>{a(f)}})}const yi={name:"",uuid:"",type:"",visible:!1,matrix:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0,children:[]};let oe={...yi};function As(s){const[e,t]=O.useState(-1);O.useEffect(()=>{function a(h){oe={...h.value},t(Date.now())}function l(){oe={...yi},t(Date.now())}return R.addEventListener(A.SET_SCENE,l),R.addEventListener(A.SET_OBJECT,a),()=>{R.removeEventListener(A.SET_SCENE,l),R.removeEventListener(A.SET_OBJECT,a)}},[]);const i=oe.type.toLowerCase(),n=oe.animations.length>0||oe.mixer!==void 0,r=i.search("mesh")>-1||i.search("line")>-1||i.search("points")>-1;return p.jsx(Et,{label:"Inspector",button:oe.uuid.length>0?p.jsx("button",{className:"remove",onClick:()=>{de.instance.remove(oe.name),oe={...yi},t(Date.now())}}):void 0,children:p.jsx("div",{id:"Inspector",className:s.class,children:oe.uuid.length>0&&p.jsxs(p.Fragment,{children:[p.jsxs(p.Fragment,{children:[p.jsx(jt,{type:"string",title:"Name",prop:"name",value:oe.name,disabled:!0}),p.jsx(jt,{type:"string",title:"Type",prop:"type",value:oe.type,disabled:!0}),p.jsx(jt,{type:"string",title:"UUID",prop:"uuid",value:oe.uuid,disabled:!0})]}),p.jsxs(p.Fragment,{children:[p.jsx(Yt,{object:oe,three:s.three}),n?p.jsx(sr,{object:oe,three:s.three}):null,i.search("camera")>-1?va(oe,s.three):null,i.search("light")>-1?ir(oe,s.three):null,r?fa(oe,s.three):null]})]})},e)},"Inspector")}class nr extends O.Component{autoClear=!0;autoClearColor=!0;autoClearDepth=!0;autoClearStencil=!0;outputColorSpace=o.SRGBColorSpace;localClippingEnabled=!1;clearColor=new o.Color(0);clearAlpha=1;toneMapping=o.NoToneMapping;toneMappingExposure=1;constructor(e){super(e);const t=localStorage.getItem(this.expandedName),i=t!==null?t==="open":!1;if(this.state={expanded:i,lastUpdated:Date.now()},this.saveExpanded(i),le.instance){const n=le.instance.renderer;n&&(this.autoClear=n.autoClear,this.autoClearColor=n.autoClearColor,this.autoClearDepth=n.autoClearDepth,this.autoClearStencil=n.autoClearStencil,this.outputColorSpace=n.outputColorSpace,this.localClippingEnabled=n.localClippingEnabled,this.clearAlpha=n.getClearAlpha(),this.toneMapping=n.toneMapping,this.toneMappingExposure=n.toneMappingExposure,n.getClearColor(this.clearColor))}R.addEventListener(A.ADD_RENDERER,this.onAddRenderer)}componentwillunmount(){R.removeEventListener(A.ADD_RENDERER,this.onAddRenderer)}onAddRenderer=e=>{const t=e.value;if(this.autoClear=t.autoClear,this.autoClearColor=t.autoClearColor,this.autoClearDepth=t.autoClearDepth,this.autoClearStencil=t.autoClearStencil,this.outputColorSpace=t.outputColorSpace,this.localClippingEnabled=t.localClippingEnabled,this.clearAlpha=t.clearAlpha,this.toneMapping=t.toneMapping,this.toneMappingExposure=t.toneMappingExposure,this.clearColor.setStyle(t.clearColor,o.LinearSRGBColorSpace),o.ColorManagement.enabled=t.colorManagement,le.instance){const i=le.instance.renderer;i&&(i.autoClear=this.autoClear,i.autoClearColor=this.autoClearColor,i.autoClearDepth=this.autoClearDepth,i.autoClearStencil=this.autoClearStencil,i.outputColorSpace=this.outputColorSpace,i.localClippingEnabled=this.localClippingEnabled,i.toneMapping=this.toneMapping,i.toneMappingExposure=this.toneMappingExposure,i.setClearColor(t.clearColor,this.clearAlpha))}this.setState({lastUpdated:Date.now()})};render(){const e=()=>{if(le.instance){const t=le.instance.renderer;t&&(t.autoClear=this.autoClear,t.autoClearColor=this.autoClearColor,t.autoClearDepth=this.autoClearDepth,t.autoClearStencil=this.autoClearStencil,t.outputColorSpace=this.outputColorSpace,t.localClippingEnabled=this.localClippingEnabled,t.toneMapping=this.toneMapping,t.toneMappingExposure=this.toneMappingExposure,t.setClearColor(this.clearColor.getStyle(),this.clearAlpha),this.props.three.updateRenderer({autoClear:this.autoClear,autoClearColor:this.autoClearColor,autoClearDepth:this.autoClearDepth,autoClearStencil:this.autoClearStencil,outputColorSpace:this.outputColorSpace,localClippingEnabled:this.localClippingEnabled,clearAlpha:this.clearAlpha,clearColor:this.clearColor.getStyle(),colorManagement:o.ColorManagement.enabled,toneMapping:this.toneMapping,toneMappingExposure:this.toneMappingExposure}))}};return p.jsx(be,{title:"Renderer",expanded:this.state.expanded,items:[{type:"boolean",title:"Auto Clear",value:this.autoClear,onChange:(t,i)=>{this.autoClear=i}},{type:"boolean",title:"Auto Clear Color",value:this.autoClearColor,onChange:(t,i)=>{this.autoClearColor=i,e()}},{type:"boolean",title:"Auto Clear Depth",value:this.autoClearDepth,onChange:(t,i)=>{this.autoClearDepth=i,e()}},{type:"boolean",title:"Auto Clear Stencil",value:this.autoClearStencil,onChange:(t,i)=>{this.autoClearStencil=i,e()}},{type:"boolean",title:"Local Clipping",value:this.localClippingEnabled,onChange:(t,i)=>{this.localClippingEnabled=i,e()}},{type:"color",title:"Clear Color",value:`#${this.clearColor.getHexString()}`,onChange:(t,i)=>{this.clearColor.setStyle(i),e()}},{type:"range",title:"Clear Alpha",min:0,max:1,step:.01,value:this.clearAlpha,onChange:(t,i)=>{this.clearAlpha=i,e()}},{type:"boolean",title:"Clear Management",value:o.ColorManagement.enabled,onChange:(t,i)=>{o.ColorManagement.enabled=i,e()}},{type:"option",title:"Color Space",value:this.outputColorSpace,options:[{title:"No Color Space",value:o.NoColorSpace},{title:"SRB Color Space",value:o.SRGBColorSpace},{title:"Linear SRB Color Space",value:o.LinearSRGBColorSpace}],onChange:(t,i)=>{this.outputColorSpace=i,e()}},{type:"option",title:"Tone Mapping",value:this.toneMapping,options:[{title:"None ",value:o.NoToneMapping},{title:"Linear ",value:o.LinearToneMapping},{title:"Reinhard",value:o.ReinhardToneMapping},{title:"Cineon ",value:o.CineonToneMapping},{title:"ACES Filmic",value:o.ACESFilmicToneMapping},{title:"AgX",value:o.AgXToneMapping},{title:"Neutral",value:o.NeutralToneMapping},{title:"Custom",value:o.CustomToneMapping}],onChange:(t,i)=>{this.toneMapping=i,e()}},{type:"range",title:"Tone Mapping Exposure",value:this.toneMappingExposure,min:0,max:2,step:.01,onChange:(t,i)=>{this.toneMappingExposure=i,e()}}],onToggle:t=>{this.setState({expanded:t}),this.saveExpanded(t)}},Math.random())}saveExpanded(e){localStorage.setItem(this.expandedName,e?"open":"closed")}get expandedName(){return`${this.props.three.app.appID}_renderer`}}function Rs(s){const[e]=O.useState([]),[t]=O.useState([]),[i,n]=O.useState(0),r=h=>{const c=h.value;e.push(c),t.push(p.jsx(Et,{label:`Scene: ${c.name}`,scene:c,open:!0,onRefresh:()=>{s.three.refreshScene(c.name)},children:p.jsx(fi,{child:c,scene:c,three:s.three})},Math.random())),n(Date.now())},a=h=>{const c=h.value;for(let u=0;u<e.length;u++)if(c.uuid===e[u].uuid){e[u]=c,t[u]=p.jsx(Et,{label:`Scene: ${c.name}`,scene:c,open:!0,onRefresh:()=>{s.three.refreshScene(c.name)},children:p.jsx(fi,{child:c,scene:c,three:s.three})},Math.random()),n(Date.now());return}},l=h=>{const c=h.value;for(let u=0;u<e.length;u++)if(c.uuid===e[u].uuid){e.splice(u,1),t.splice(u,1),n(Date.now());return}};return O.useEffect(()=>(R.addEventListener(A.ADD_SCENE,r),R.addEventListener(A.REFRESH_SCENE,a),R.addEventListener(A.REMOVE_SCENE,l),()=>{R.removeEventListener(A.ADD_SCENE,r),R.removeEventListener(A.REFRESH_SCENE,a),R.removeEventListener(A.REMOVE_SCENE,l)}),[]),p.jsxs("div",{id:"SidePanel",children:[p.jsx("div",{className:"scenes",children:t},i),p.jsx(As,{three:s.three}),p.jsx(nr,{three:s.three}),p.jsx(J,{three:s.three})]})}function ar(s){return O.useEffect(()=>{function e(l){let h=null;return s.three.scenes.forEach(c=>{l.search(c.uuid)>-1&&(h=c)}),h}const t=l=>{const h=l.value,u=e(h)?.getObjectByProperty("uuid",h);u!==void 0&&s.three.setObject(u)},i=(l,h,c)=>{const m=e(l)?.getObjectByProperty("uuid",l);m!==void 0&&te(m,h,c)},n=l=>{const h=l.value,{key:c,value:u,uuid:m}=h;i(m,c,u)},r=l=>{const h=l.value,u=e(h.uuid)?.getObjectByProperty("uuid",h.uuid);if(u!==void 0){const m=f=>{const g=h.key.split(".");switch(g.length){case 1:u[g[0]]=f;break;case 2:u[g[0]][g[1]]=f;break;case 3:u[g[0]][g[1]][g[2]]=f;break;case 4:u[g[0]][g[1]][g[2]][g[3]]=f;break;case 5:u[g[0]][g[1]][g[2]][g[3]][g[4]]=f;break}u.material.needsUpdate=!0};h.value.src.length>0?bs(h.value.src).then(f=>{f.offset.set(h.value.offset[0],h.value.offset[1]),f.repeat.set(h.value.repeat[0],h.value.repeat[1]),m(f)}):m(null)}},a=l=>{const{key:h,uuid:c,value:u,subitem:m}=l.value,g=e(c)?.getObjectByProperty("uuid",c);if(g!==void 0)try{m!==void 0?Vn(g,m)[h](u):g[h](u)}catch(x){console.log("Error requesting method:"),console.log(x),console.log(h),console.log(u)}};return R.addEventListener(A.GET_OBJECT,t),R.addEventListener(A.UPDATE_OBJECT,n),R.addEventListener(A.CREATE_TEXTURE,r),R.addEventListener(A.REQUEST_METHOD,a),()=>{R.removeEventListener(A.GET_OBJECT,t),R.removeEventListener(A.UPDATE_OBJECT,n),R.removeEventListener(A.CREATE_TEXTURE,r),R.removeEventListener(A.REQUEST_METHOD,a)}},[]),null}function Ds(s){return p.jsxs("div",{className:"editor",ref:s.ref,style:s.style,children:[p.jsx("div",{className:"header",children:s.header}),s.children,p.jsx("div",{className:"footer",children:s.footer})]})}function rr(s){return p.jsx(Ds,{children:p.jsxs(p.Fragment,{children:[p.jsx(le,{three:s.three,scenes:s.scenes,onSceneResize:s.onSceneResize,onSceneSet:s.onSceneSet,onSceneUpdate:s.onSceneUpdate}),p.jsx(Rs,{three:s.three})]})})}exports.Accordion=Et;exports.Application=Dn;exports.BaseRemote=Vt;exports.ChildObject=Ei;exports.ContainerObject=fi;exports.Draggable=Ss;exports.DraggableItem=Es;exports.Dropdown=ws;exports.DropdownItem=xs;exports.Editor=Ds;exports.ElementProxy=An;exports.ElementProxyReceiver=Cs;exports.ExportTexture=yt;exports.Inspector=As;exports.MultiView=le;exports.NavButton=bi;exports.ProxyManager=Rn;exports.QualityType=vs;exports.RemoteComponents=In;exports.RemoteController=qn;exports.RemoteTheatre=Nn;exports.RemoteThree=Yn;exports.SceneInspector=ar;exports.SidePanel=Rs;exports.Spline=vi;exports.SplineEditor=Ps;exports.ThreeEditor=rr;exports.ToolEvents=A;exports.Transform=de;exports.WebworkerEventHandlers=Mn;exports.capitalize=bt;exports.clamp=je;exports.colorToHex=ui;exports.copyToClipboard=ms;exports.cubicBezier=vn;exports.customizeTheatreElements=kn;exports.damp=un;exports.debugDispatcher=R;exports.defaultTheatreCallback=sn;exports.detectSettings=cn;exports.dispose=Pe;exports.disposeMaterial=ys;exports.disposeTexture=yn;exports.distance=dn;exports.hierarchyUUID=zt;exports.isColor=gs;exports.map=hn;exports.mix=it;exports.noop=Ct;exports.normalize=Ft;exports.parseModelLite=Cn;exports.randomID=fs;exports.resetThreeObjects=pi;exports.round=Ce;exports.roundTo=pn;exports.theatreEditorApp=Ln;
165
+ }`;class Ba extends o.ShaderMaterial{constructor(){super({defines:{USE_UV:""},vertexShader:Ha,fragmentShader:Va})}}const He=new o.Raycaster,he=new o.Vector3,ke=new o.Vector3,K=new o.Quaternion,as={X:new o.Vector3(1,0,0),Y:new o.Vector3(0,1,0),Z:new o.Vector3(0,0,1)},ci={type:"change"},rs={type:"mouseDown",mode:null},os={type:"mouseUp",mode:null},ls={type:"objectChange"};class Ya extends o.Controls{constructor(e,t=null){super(void 0,t);const s=new Qa(this);this._root=s;const n=new Ka;this._gizmo=n,s.add(n);const a=new $a;this._plane=a,s.add(a);const r=this;function l(E,S){let w=S;Object.defineProperty(r,E,{get:function(){return w!==void 0?w:S},set:function(M){w!==M&&(w=M,a[E]=M,n[E]=M,r.dispatchEvent({type:E+"-changed",value:M}),r.dispatchEvent(ci))}}),r[E]=S,a[E]=S,n[E]=S}l("camera",e),l("object",void 0),l("enabled",!0),l("axis",null),l("mode","translate"),l("translationSnap",null),l("rotationSnap",null),l("scaleSnap",null),l("space","world"),l("size",1),l("dragging",!1),l("showX",!0),l("showY",!0),l("showZ",!0);const h=new o.Vector3,c=new o.Vector3,u=new o.Quaternion,m=new o.Quaternion,f=new o.Vector3,g=new o.Quaternion,x=new o.Vector3,y=new o.Vector3,T=new o.Vector3,_=0,C=new o.Vector3;l("worldPosition",h),l("worldPositionStart",c),l("worldQuaternion",u),l("worldQuaternionStart",m),l("cameraPosition",f),l("cameraQuaternion",g),l("pointStart",x),l("pointEnd",y),l("rotationAxis",T),l("rotationAngle",_),l("eye",C),this._offset=new o.Vector3,this._startNorm=new o.Vector3,this._endNorm=new o.Vector3,this._cameraScale=new o.Vector3,this._parentPosition=new o.Vector3,this._parentQuaternion=new o.Quaternion,this._parentQuaternionInv=new o.Quaternion,this._parentScale=new o.Vector3,this._worldScaleStart=new o.Vector3,this._worldQuaternionInv=new o.Quaternion,this._worldScale=new o.Vector3,this._positionStart=new o.Vector3,this._quaternionStart=new o.Quaternion,this._scaleStart=new o.Vector3,this._getPointer=Ga.bind(this),this._onPointerDown=Wa.bind(this),this._onPointerHover=Za.bind(this),this._onPointerMove=Xa.bind(this),this._onPointerUp=qa.bind(this),t!==null&&this.connect()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&He.setFromCamera(e,this.camera);const t=hi(this._gizmo.picker[this.mode],He);t?this.axis=t.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&He.setFromCamera(e,this.camera);const t=hi(this._plane,He,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,rs.mode=this.mode,this.dispatchEvent(rs)}}pointerMove(e){const t=this.axis,s=this.mode,n=this.object;let a=this.space;if(s==="scale"?a="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(a="world"),n===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&He.setFromCamera(e,this.camera);const r=hi(this._plane,He,!0);if(r){if(this.pointEnd.copy(r.point).sub(this.worldPositionStart),s==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),a==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),a==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),n.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(a==="local"&&(n.position.applyQuaternion(K.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.position.applyQuaternion(this._quaternionStart)),a==="world"&&(n.parent&&n.position.add(he.setFromMatrixPosition(n.parent.matrixWorld)),t.search("X")!==-1&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.parent&&n.position.sub(he.setFromMatrixPosition(n.parent.matrixWorld))));else if(s==="scale"){if(t.search("XYZ")!==-1){let l=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(l*=-1),ke.set(l,l,l)}else he.copy(this.pointStart),ke.copy(this.pointEnd),he.applyQuaternion(this._worldQuaternionInv),ke.applyQuaternion(this._worldQuaternionInv),ke.divide(he),t.search("X")===-1&&(ke.x=1),t.search("Y")===-1&&(ke.y=1),t.search("Z")===-1&&(ke.z=1);n.scale.copy(this._scaleStart).multiply(ke),this.scaleSnap&&(t.search("X")!==-1&&(n.scale.x=Math.round(n.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(n.scale.y=Math.round(n.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(n.scale.z=Math.round(n.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(s==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const l=20/this.worldPosition.distanceTo(he.setFromMatrixPosition(this.camera.matrixWorld));let h=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(he.copy(this.rotationAxis).cross(this.eye))*l):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(as[t]),he.copy(as[t]),a==="local"&&he.applyQuaternion(this.worldQuaternion),he.cross(this.eye),he.length()===0?h=!0:this.rotationAngle=this._offset.dot(he.normalize())*l),(t==="E"||h)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),a==="local"&&t!=="E"&&t!=="XYZE"?(n.quaternion.copy(this._quaternionStart),n.quaternion.multiply(K.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),n.quaternion.copy(K.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(ci),this.dispatchEvent(ls)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(os.mode=this.mode,this.dispatchEvent(os)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}attach(e){return this.object=e,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(ci),this.dispatchEvent(ls),this.pointStart.copy(this.pointEnd))}getRaycaster(){return He}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}}function Ga(i){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:i.button};{const e=this.domElement.getBoundingClientRect();return{x:(i.clientX-e.left)/e.width*2-1,y:-(i.clientY-e.top)/e.height*2+1,button:i.button}}}function Za(i){if(this.enabled)switch(i.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(i));break}}function Wa(i){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(i)),this.pointerDown(this._getPointer(i)))}function Xa(i){this.enabled&&this.pointerMove(this._getPointer(i))}function qa(i){this.enabled&&(this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(i)))}function hi(i,e,t){const s=e.intersectObject(i,!0);for(let n=0;n<s.length;n++)if(s[n].object.visible||t)return s[n];return!1}const It=new o.Euler,W=new o.Vector3(0,1,0),cs=new o.Vector3(0,0,0),hs=new o.Matrix4,Lt=new o.Quaternion,Nt=new o.Quaternion,Oe=new o.Vector3,ds=new o.Matrix4,_t=new o.Vector3(1,0,0),Ve=new o.Vector3(0,1,0),vt=new o.Vector3(0,0,1),kt=new o.Vector3,pt=new o.Vector3,mt=new o.Vector3;class Qa extends o.Object3D{constructor(e){super(),this.isTransformControlsRoot=!0,this.controls=e,this.visible=!1}updateMatrixWorld(e){const t=this.controls;t.object!==void 0&&(t.object.updateMatrixWorld(),t.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):t.object.parent.matrixWorld.decompose(t._parentPosition,t._parentQuaternion,t._parentScale),t.object.matrixWorld.decompose(t.worldPosition,t.worldQuaternion,t._worldScale),t._parentQuaternionInv.copy(t._parentQuaternion).invert(),t._worldQuaternionInv.copy(t.worldQuaternion).invert()),t.camera.updateMatrixWorld(),t.camera.matrixWorld.decompose(t.cameraPosition,t.cameraQuaternion,t._cameraScale),t.camera.isOrthographicCamera?t.camera.getWorldDirection(t.eye).negate():t.eye.copy(t.cameraPosition).sub(t.worldPosition).normalize(),super.updateMatrixWorld(e)}}class Ka extends o.Object3D{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new o.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new o.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),s=e.clone();s.opacity=.15;const n=t.clone();n.opacity=.5;const a=e.clone();a.color.setHex(16711680);const r=e.clone();r.color.setHex(65280);const l=e.clone();l.color.setHex(255);const h=e.clone();h.color.setHex(16711680),h.opacity=.5;const c=e.clone();c.color.setHex(65280),c.opacity=.5;const u=e.clone();u.color.setHex(255),u.opacity=.5;const m=e.clone();m.opacity=.25;const f=e.clone();f.color.setHex(16776960),f.opacity=.25,e.clone().color.setHex(16776960);const x=e.clone();x.color.setHex(7895160);const y=new o.CylinderGeometry(0,.04,.1,12);y.translate(0,.05,0);const T=new o.BoxGeometry(.08,.08,.08);T.translate(0,.04,0);const _=new o.BufferGeometry;_.setAttribute("position",new o.Float32BufferAttribute([0,0,0,1,0,0],3));const C=new o.CylinderGeometry(.0075,.0075,.5,3);C.translate(0,.25,0);function E(X,Pe){const ce=new o.TorusGeometry(X,.0075,3,64,Pe*Math.PI*2);return ce.rotateY(Math.PI/2),ce.rotateX(Math.PI/2),ce}function S(){const X=new o.BufferGeometry;return X.setAttribute("position",new o.Float32BufferAttribute([0,0,0,1,1,1],3)),X}const w={X:[[new o.Mesh(y,a),[.5,0,0],[0,0,-Math.PI/2]],[new o.Mesh(y,a),[-.5,0,0],[0,0,Math.PI/2]],[new o.Mesh(C,a),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new o.Mesh(y,r),[0,.5,0]],[new o.Mesh(y,r),[0,-.5,0],[Math.PI,0,0]],[new o.Mesh(C,r)]],Z:[[new o.Mesh(y,l),[0,0,.5],[Math.PI/2,0,0]],[new o.Mesh(y,l),[0,0,-.5],[-Math.PI/2,0,0]],[new o.Mesh(C,l),null,[Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.OctahedronGeometry(.1,0),m.clone()),[0,0,0]]],XY:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),u.clone()),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),h.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),c.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},M={X:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[0,.3,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.OctahedronGeometry(.2,0),s)]],XY:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]]},I={START:[[new o.Mesh(new o.OctahedronGeometry(.01,2),n),null,null,null,"helper"]],END:[[new o.Mesh(new o.OctahedronGeometry(.01,2),n),null,null,null,"helper"]],DELTA:[[new o.Line(S(),n),null,null,null,"helper"]],X:[[new o.Line(_,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new o.Line(_,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new o.Line(_,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},U={XYZE:[[new o.Mesh(E(.5,1),x),null,[0,Math.PI/2,0]]],X:[[new o.Mesh(E(.5,.5),a)]],Y:[[new o.Mesh(E(.5,.5),r),null,[0,0,-Math.PI/2]]],Z:[[new o.Mesh(E(.5,.5),l),null,[0,Math.PI/2,0]]],E:[[new o.Mesh(E(.75,1),f),null,[0,Math.PI/2,0]]]},D={AXIS:[[new o.Line(_,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},B={XYZE:[[new o.Mesh(new o.SphereGeometry(.25,10,8),s)]],X:[[new o.Mesh(new o.TorusGeometry(.5,.1,4,24),s),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new o.Mesh(new o.TorusGeometry(.5,.1,4,24),s),[0,0,0],[Math.PI/2,0,0]]],Z:[[new o.Mesh(new o.TorusGeometry(.5,.1,4,24),s),[0,0,0],[0,0,-Math.PI/2]]],E:[[new o.Mesh(new o.TorusGeometry(.75,.1,2,24),s)]]},_e={X:[[new o.Mesh(T,a),[.5,0,0],[0,0,-Math.PI/2]],[new o.Mesh(C,a),[0,0,0],[0,0,-Math.PI/2]],[new o.Mesh(T,a),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new o.Mesh(T,r),[0,.5,0]],[new o.Mesh(C,r)],[new o.Mesh(T,r),[0,-.5,0],[0,0,Math.PI]]],Z:[[new o.Mesh(T,l),[0,0,.5],[Math.PI/2,0,0]],[new o.Mesh(C,l),[0,0,0],[Math.PI/2,0,0]],[new o.Mesh(T,l),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),u),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),h),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.BoxGeometry(.1,.1,.1),m.clone())]]},pe={X:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[0,.3,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.2),s),[0,0,0]]]},ne={X:[[new o.Line(_,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new o.Line(_,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new o.Line(_,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function Q(X){const Pe=new o.Object3D;for(const ce in X)for(let ge=X[ce].length;ge--;){const ie=X[ce][ge][0].clone(),Re=X[ce][ge][1],De=X[ce][ge][2],Ie=X[ce][ge][3],G=X[ce][ge][4];ie.name=ce,ie.tag=G,Re&&ie.position.set(Re[0],Re[1],Re[2]),De&&ie.rotation.set(De[0],De[1],De[2]),Ie&&ie.scale.set(Ie[0],Ie[1],Ie[2]),ie.updateMatrix();const re=ie.geometry.clone();re.applyMatrix4(ie.matrix),ie.geometry=re,ie.renderOrder=1/0,ie.position.set(0,0,0),ie.rotation.set(0,0,0),ie.scale.set(1,1,1),Pe.add(ie)}return Pe}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=Q(w)),this.add(this.gizmo.rotate=Q(U)),this.add(this.gizmo.scale=Q(_e)),this.add(this.picker.translate=Q(M)),this.add(this.picker.rotate=Q(B)),this.add(this.picker.scale=Q(pe)),this.add(this.helper.translate=Q(I)),this.add(this.helper.rotate=Q(D)),this.add(this.helper.scale=Q(ne)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const s=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:Nt;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let n=[];n=n.concat(this.picker[this.mode].children),n=n.concat(this.gizmo[this.mode].children),n=n.concat(this.helper[this.mode].children);for(let a=0;a<n.length;a++){const r=n[a];r.visible=!0,r.rotation.set(0,0,0),r.position.copy(this.worldPosition);let l;if(this.camera.isOrthographicCamera?l=(this.camera.top-this.camera.bottom)/this.camera.zoom:l=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),r.scale.set(1,1,1).multiplyScalar(l*this.size/4),r.tag==="helper"){r.visible=!1,r.name==="AXIS"?(r.visible=!!this.axis,this.axis==="X"&&(K.setFromEuler(It.set(0,0,0)),r.quaternion.copy(s).multiply(K),Math.abs(W.copy(_t).applyQuaternion(s).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Y"&&(K.setFromEuler(It.set(0,0,Math.PI/2)),r.quaternion.copy(s).multiply(K),Math.abs(W.copy(Ve).applyQuaternion(s).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Z"&&(K.setFromEuler(It.set(0,Math.PI/2,0)),r.quaternion.copy(s).multiply(K),Math.abs(W.copy(vt).applyQuaternion(s).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="XYZE"&&(K.setFromEuler(It.set(0,Math.PI/2,0)),W.copy(this.rotationAxis),r.quaternion.setFromRotationMatrix(hs.lookAt(cs,W,Ve)),r.quaternion.multiply(K),r.visible=this.dragging),this.axis==="E"&&(r.visible=!1)):r.name==="START"?(r.position.copy(this.worldPositionStart),r.visible=this.dragging):r.name==="END"?(r.position.copy(this.worldPosition),r.visible=this.dragging):r.name==="DELTA"?(r.position.copy(this.worldPositionStart),r.quaternion.copy(this.worldQuaternionStart),he.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),he.applyQuaternion(this.worldQuaternionStart.clone().invert()),r.scale.copy(he),r.visible=this.dragging):(r.quaternion.copy(s),this.dragging?r.position.copy(this.worldPositionStart):r.position.copy(this.worldPosition),this.axis&&(r.visible=this.axis.search(r.name)!==-1));continue}r.quaternion.copy(s),this.mode==="translate"||this.mode==="scale"?(r.name==="X"&&Math.abs(W.copy(_t).applyQuaternion(s).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Y"&&Math.abs(W.copy(Ve).applyQuaternion(s).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Z"&&Math.abs(W.copy(vt).applyQuaternion(s).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XY"&&Math.abs(W.copy(vt).applyQuaternion(s).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="YZ"&&Math.abs(W.copy(_t).applyQuaternion(s).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XZ"&&Math.abs(W.copy(Ve).applyQuaternion(s).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1)):this.mode==="rotate"&&(Lt.copy(s),W.copy(this.eye).applyQuaternion(K.copy(s).invert()),r.name.search("E")!==-1&&r.quaternion.setFromRotationMatrix(hs.lookAt(this.eye,cs,Ve)),r.name==="X"&&(K.setFromAxisAngle(_t,Math.atan2(-W.y,W.z)),K.multiplyQuaternions(Lt,K),r.quaternion.copy(K)),r.name==="Y"&&(K.setFromAxisAngle(Ve,Math.atan2(W.x,W.z)),K.multiplyQuaternions(Lt,K),r.quaternion.copy(K)),r.name==="Z"&&(K.setFromAxisAngle(vt,Math.atan2(W.y,W.x)),K.multiplyQuaternions(Lt,K),r.quaternion.copy(K))),r.visible=r.visible&&(r.name.indexOf("X")===-1||this.showX),r.visible=r.visible&&(r.name.indexOf("Y")===-1||this.showY),r.visible=r.visible&&(r.name.indexOf("Z")===-1||this.showZ),r.visible=r.visible&&(r.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),r.material._color=r.material._color||r.material.color.clone(),r.material._opacity=r.material._opacity||r.material.opacity,r.material.color.copy(r.material._color),r.material.opacity=r.material._opacity,this.enabled&&this.axis&&(r.name===this.axis||this.axis.split("").some(function(h){return r.name===h}))&&(r.material.color.setHex(16776960),r.material.opacity=1)}super.updateMatrixWorld(e)}}class $a extends o.Mesh{constructor(){super(new o.PlaneGeometry(1e5,1e5,2,2),new o.MeshBasicMaterial({visible:!1,wireframe:!0,side:o.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),kt.copy(_t).applyQuaternion(t==="local"?this.worldQuaternion:Nt),pt.copy(Ve).applyQuaternion(t==="local"?this.worldQuaternion:Nt),mt.copy(vt).applyQuaternion(t==="local"?this.worldQuaternion:Nt),W.copy(pt),this.mode){case"translate":case"scale":switch(this.axis){case"X":W.copy(this.eye).cross(kt),Oe.copy(kt).cross(W);break;case"Y":W.copy(this.eye).cross(pt),Oe.copy(pt).cross(W);break;case"Z":W.copy(this.eye).cross(mt),Oe.copy(mt).cross(W);break;case"XY":Oe.copy(mt);break;case"YZ":Oe.copy(kt);break;case"XZ":W.copy(mt),Oe.copy(pt);break;case"XYZ":case"E":Oe.set(0,0,0);break}break;case"rotate":default:Oe.set(0,0,0)}Oe.length()===0?this.quaternion.copy(this.cameraQuaternion):(ds.lookAt(he.set(0,0,0),Oe,W),this.quaternion.setFromRotationMatrix(ds)),super.updateMatrixWorld(e)}}class de extends o.EventDispatcher{static DRAG_START="Transform::dragStart";static DRAG_END="Transform::dragEnd";static _instance;three;activeCamera;controls=new Map;visibility=new Map;constructor(){super(),R.addEventListener(P.SET_SCENE,this.setScene)}clear(){for(const e of this.controls.values()){e.detach(),e.disconnect();const t=e.getHelper();Ae(t)}this.controls=new Map,this.visibility=new Map}add(e){let t=this.controls.get(e);if(t===void 0){const s=document.querySelector(".clickable");t=new Ya(this.activeCamera,s),t.getHelper().name=e,t.setSpace("local"),this.controls.set(e,t),this.visibility.set(e,!0),t.addEventListener("mouseDown",()=>{this.dispatchEvent({type:de.DRAG_START})}),t.addEventListener("mouseUp",()=>{this.dispatchEvent({type:de.DRAG_END})}),t.addEventListener("dragging-changed",n=>{le.instance?.toggleOrbitControls(n.value)})}return t}get(e){return this.controls.get(e)}remove(e){const t=this.get(e);return t===void 0?!1:(t.detach(),t.disconnect(),Ae(t.getHelper()),this.controls.delete(e),!0)}enabled(e){this.controls.forEach(t=>{t.enabled=e})}updateCamera(e,t){this.activeCamera=e,this.controls.forEach(s=>{s.camera!==e&&(s.camera=e,e.getWorldPosition(s.cameraPosition),e.getWorldQuaternion(s.cameraQuaternion)),s.domElement!==t&&(s.disconnect(),s.domElement=t,s.connect())})}show(){this.controls.forEach(e=>{const t=e.getHelper(),s=this.visibility.get(t.name);s!==void 0&&(t.visible=s)})}hide(){this.controls.forEach(e=>{const t=e.getHelper();this.visibility.set(t.name,t.visible),t.visible=!1})}setScene=()=>{this.clear()};static get instance(){return de._instance||(de._instance=new de),de._instance}}const Ja=new o.BoxGeometry,di=new o.Vector2;class yi extends o.Object3D{curve=new o.CatmullRomCurve3;line;draggable;curvePos;tension=.5;closed=!1;subdivide=50;curveType;offset=1;lineMaterial;_camera;_curvePercentage=0;_draggableScale=10;_transform;raycaster;draggedMat=new o.MeshBasicMaterial;parentGroup;group;constructor(e,t){const s=new o.Color(Qe(.5,1,Math.random()),Qe(.5,1,Math.random()),Qe(.5,1,Math.random()));super(),this.name=e,this.lineMaterial=new o.LineBasicMaterial({color:s}),this.line=new o.Line(new o.BufferGeometry,this.lineMaterial),this.line.name="line",this.add(this.line),this._camera=t,this.curveType="catmullrom",this.draggedMat.color=s,this.draggable=new o.Object3D,this.draggable.name="draggablePoints",this.add(this.draggable),this.curvePos=new o.Mesh(new o.SphereGeometry(1.5),new o.MeshBasicMaterial({color:s})),this.curvePos.name="curvePos",this.curvePos.scale.setScalar(this._draggableScale),this.curvePos.visible=!1,this.add(this.curvePos),this.raycaster=new o.Raycaster,this.raycaster.params.Line.threshold=3,this.enable()}enable(){document.addEventListener("pointerdown",this.onMouseClick)}disable(){document.removeEventListener("pointerdown",this.onMouseClick)}dispose=()=>{this._transform&&(this._transform.removeEventListener("objectChange",this.updateSpline),de.instance.remove(this.name)),this.disable(),this.parentGroup.removeGroup(this.name)};hideTransform=()=>{this._transform?.detach()};exportSpline=()=>{const e=[];this.draggable.children.forEach(t=>{e.push([Ce(t.position.x,3),Ce(t.position.y,3),Ce(t.position.z,3)])}),fs({name:this.name,points:e,tension:this.tension,closed:this.closed,subdivide:this.subdivide,type:this.curveType}),console.log("Spline copied!")};showPoints=(e=!0)=>{this.draggable.visible=e};addPoints=(e=[])=>{if(e.length>0){const t=e.length-1;for(let s=0;s<t;s++)this.addPoint(e[s],!1);this.addPoint(e[t])}else this.addPoint(new o.Vector3(-50,0,0),!1),this.addPoint(new o.Vector3(50,0,0))};addPoint=(e,t=!0)=>{const s=this.draggable.children.length,n=new o.Mesh(Ja,this.draggedMat);return n.name=`point_${s}`,n.position.copy(e),n.scale.setScalar(this._draggableScale),this.draggable.add(n),t&&this.updateSpline(),n};addNextPt=()=>{const e=this.draggable.children.length,t=new o.Vector3(Qe(-this.offset,this.offset,Math.random()),Qe(-this.offset,this.offset,Math.random()),Qe(-this.offset,this.offset,Math.random()));e>0&&t.add(this.draggable.children[e-1].position);const s=this.addPoint(t);this._transform?.attach(s),this.group.current?.setField("Current Point",s.position)};removePoint=e=>{if(this._transform?.object===e){this._transform?.detach();const t=this.draggable.children[this.draggable.children.length-1];this._transform?.attach(t),this.group.current?.setField("Current Point",t.position)}Ae(e),this.updateSpline()};removePointAt=e=>{const t=this.draggable.children[e];this.removePoint(t)};removeSelectedPt=()=>{this._transform?.object!==void 0&&this.removePoint(this._transform?.object)};updateSpline=()=>{this.curve=new o.CatmullRomCurve3(this.points,this.closed,this.curveType,this.tension),this.line.geometry.setFromPoints(this.getPoints()),this.curvePos.position.copy(this.getPointAt(this._curvePercentage))};onMouseClick=e=>{if(!le.instance||this._transform&&!this._transform.getHelper().visible)return;const s=le.instance.currentWindow.current.getBoundingClientRect();di.x=(e.clientX-s.x)/s.width*2-1,di.y=-((e.clientY-s.y)/s.height)*2+1,this.raycaster.setFromCamera(di,this.camera);const n=this.raycaster.intersectObjects(this.draggable.children,!1);if(n.length>0){const a=n[0].object;a!==this._transform?.object&&(this._transform?.attach(a),this.group.current?.setField("Current Point",a.position))}};getPointAt(e){return this.curve.getPointAt(e)}getPoints(){return this.curve.getPoints(this.subdivide)}getTangentAt(e){return this.curve.getTangentAt(e)}get points(){const e=[];return this.draggable.children.forEach(t=>{e.push(t.position)}),e}get total(){return this.draggable.children.length}get draggableScale(){return this._draggableScale}set draggableScale(e){this._draggableScale=e,this.draggable.children.forEach(t=>t.scale.setScalar(e)),this.curvePos.scale.setScalar(e)}get camera(){return this._camera}set camera(e){this._camera=e,this._transform!==void 0&&(this._transform.camera=e)}get curvePercentage(){return this._curvePercentage}set curvePercentage(e){this._curvePercentage=e,this.curvePos.position.copy(this.getPointAt(e))}onUpdateTransform=()=>{if(this._transform?.object&&this.group){const e=this._transform?.object;e.name.search("point")>-1&&this.group.current?.setField("Current Point",e.position)}this.updateSpline()};initDebug(e){const t=this.draggable.children;this.parentGroup=e,this._transform=de.instance.add(this.name),this._transform.camera=this._camera,this._transform.addEventListener("objectChange",this.onUpdateTransform),this._transform.attach(t.length>0?t[t.length-1]:this),le.instance?.scene.add(this._transform.getHelper());const s=t.length>0?t[t.length-1].position:{x:0,y:0,z:0};this.group=e.addGroup({title:this.name,items:[{prop:"Closed",type:"boolean",value:this.closed},{prop:"Visible",type:"boolean",value:this.visible},{prop:"Show Position",type:"boolean",value:this.curvePos.visible},{prop:"Show Points",type:"boolean",value:this.draggable.visible},{prop:"Color",type:"color",value:`#${this.draggedMat.color.getHexString()}`},{prop:"Curve",type:"option",options:[{title:"Catmullrom",value:"catmullrom"},{title:"Centripetal",value:"centripetal"},{title:"Chordal",value:"chordal"}]},{prop:"Draggable Scale",type:"range",min:.01,max:100,step:.01,value:this._draggableScale},{prop:"Subdivide",type:"range",min:1,max:100,step:1,value:this.subdivide},{prop:"Tension",type:"range",min:0,max:1,step:.01,value:this.tension},{prop:"New Pt Offset",type:"range",min:0,max:10,value:this.offset},{prop:"Curve At",type:"range",min:0,max:1,step:.01,value:0},{prop:"Toggle Transform",type:"button"},{prop:"Add Point",type:"button"},{prop:"Remove Point",type:"button"},{prop:"Export",type:"button"},{prop:"Delete",type:"button"},{prop:"Current Point",type:"grid3",value:s}],onUpdate:(n,a)=>{switch(n){case"Closed":this.closed=a,this.updateSpline();break;case"Visible":this.visible=a;break;case"Color":this.lineMaterial.color.setStyle(a),this.draggedMat.color.setStyle(a);break;case"Curve":this.curveType=a,this.updateSpline();break;case"Draggable Scale":this.draggableScale=a;break;case"Subdivide":this.subdivide=a,this.updateSpline();break;case"Tension":this.tension=a,this.updateSpline();break;case"New Pt Offset":this.offset=a;break;case"Curve At":this.curvePos.position.copy(this.getPointAt(a));break;case"Show Position":this.curvePos.visible=a;break;case"Show Points":this.draggable.visible=a;break;case"Toggle Transform":this._transform&&(this._transform.getHelper().visible=!this._transform.getHelper().visible);break;case"Add Point":this.addNextPt();break;case"Remove Point":this.removeSelectedPt();break;case"Export":this.exportSpline();break;case"Delete":Ae(this);break;case"Current Point":if(this.group.current&&this._transform?.object){const r=this._transform?.object;r.name.search("point")>-1&&(r.position.copy(a),this.updateSpline())}break}}}),this.draggable.children.forEach(n=>{this.debugPoint(n)})}debugPoint=e=>{e.name,e.visible=this.draggable.visible}}let Ut=0;class Ps extends o.Object3D{defaultScale=10;_camera;group=null;constructor(e){super(),this.name="Spline Editor",this._camera=e,R.addEventListener(P.ADD_SPLINE,this.onAddSpline)}initDebug(){this.group=J.addEditorGroup({title:this.name,items:[{type:"button",prop:"New Spline"},{type:"boolean",prop:"Show Points",value:!0},{type:"boolean",prop:"Visible",value:this.visible},{type:"range",prop:"Default Scale",min:0,max:50,step:.01,value:this.defaultScale}],onUpdate:(e,t)=>{switch(e){case"New Spline":this.createSpline();break;case"Show Points":this.showPoints(t);break;case"Visible":this.visible=t;break;case"Default Scale":this.defaultScale=t;break}}})}dispose(){R.removeEventListener(P.ADD_SPLINE,this.onAddSpline),J.removeEditorGroup(this.name)}addSpline(e){e.draggableScale=this.defaultScale,e.hideTransform(),this.group?.current!==null&&e.initDebug(this.group.current),this.add(e)}createSpline=(e=[])=>{const t=`Spline ${Ut+1}`,s=new yi(t,this._camera);return s.addPoints(e),this.addSpline(s),Ut++,s};createSplineFromArray=e=>{const t=[];return e.forEach(s=>{t.push(new o.Vector3(s[0],s[1],s[2]))}),this.createSpline(t)};createSplineFromCatmullRom=e=>this.createSpline(e.points);createSplineFromJSON=e=>{const t=this.createSplineFromArray(e.points);return t.name=e.name,t.closed=e.closed,t.subdivide=e.subdivide,t.tension=e.tension,t.type=e.type,t.updateSpline(),t};showPoints=(e=!0)=>{this.children.forEach(t=>{t.showPoints(e)})};onAddSpline=e=>{const t=JSON.parse(e.value),s=`Spline ${Ut+1}`,n=[];t.points.forEach(r=>{n.push(new o.Vector3(r[0],r[1],r[2]))});const a=new yi(s,this.camera);a.addPoints(n),this.addSpline(a),Ut++};get camera(){return this._camera}set camera(e){this._camera=e,this.children.forEach(t=>{const s=t;s.camera=e})}}const us=["Single","Side by Side","Stacked","Quad"],er="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAC60lEQVRYhe2YT4hNcRTHP48xpmYaNAvRyEQxEhnKQljYsRm9/EmSyJiMFAsMZWNhJYoNIUVJ2VGiyb9ZzIpMpkQSahbGv9GMYWrM+1rc2zjvzvvdd+99rzdvMd+6de75nd+5387vnN/v/G5KEuWMKRNNIB8mCRaKiiL5qQb2ApuBuUAV0Ad0AJeB3sSeJRX6LJbULTf6JTUn9Z+KWMUpPyp/Avoa4CNQZ3Sj/lNpdL/xottR7AjOkHRUUpekN5I6JbVLavDH75lIfZN0UFKTpCWS0pJem/HeJBEMG6yV1ONYtgFJbZJ+GF1jDh+zJb03NuliEuwMkMo4yErS2RA/LcbuYVyCrm1mA7Dal/8Cu4FG4JD/HsTTkCy6a+SVMTPQuc1sBKb78nHghi+/A+YBxwL2lbhRY+ThuARdEVxu5JdGFvACr0otdoZ8Y4+Rn0Sn5sFFsMvI6YB9MzA1YJ8mN8k1wAHzfj4uQVdyrpI0aJL7oqTtkq4FiqPLyCOSbktqlbRL0jlJQ2b8QdwCUZ4qvhRStZL0XFK1pMd57CRvq5mfhKBriRfiFUMY6oD7eOdwPlQAN4G10dfWg+uouwXsiOssAj4AC+JMcEWwvnAuOTEr7gTXPmg34zagOwkbIIOXAo9CbDYBrcBXYN+4UUdy2sRflyS5zVNlfPX7ugpJW5V9nI7mmh+lYU0lCZ2B3TOnAVuAk0BTwC5nuhWro46KauBOQJch5OpRaoIW34GreGf+YZdRqS9NAj4Bp4ClQDvwOWxCqSM4ADQEdKE5XvbXzlITrAVe4TW+M6NMKDXBFLAMuAD0ACfIc7pMZBXXA2cY3/xmodQRHAL2A2+NLtj8ZiEKwUL/z2WMPAJcAVYALWSf8dZuDFGWeBHwKxm3sWYhiGG8Tfo6sA2vSfiSy4GrH3wGrDcfKSSKKf6v1E9yF0XK9Q1XBPuMXMw8HXTonQFwETwNzMFr64v1jzgFHIk9ybHEZYPJo65QlD3Bf2/Q/eaHPiSWAAAAAElFTkSuQmCC",tr="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAETklEQVRYhe2YXYhVVRTHf3d0/JhyUrMpFbImM+whSa3Mynww+4AeIgiKoozooQ+KyMyXIAujF6OXqHyI6iEKKYgIP/owsjSFqCkprdDUTEcjbWZ0HHV+Pex1ucfb9Z57Z9REXHA4Z++99l7/s/ZZ/7X2KaiczNLwfwPIk9MA+yunNMAG4DHgV+BvoB3YFff2TPstYEyfrajVroI6Sr1GvahsbJC63HzZq04pmztSvU5tVRuqYRiYg78JeBR4HPg5ntdmxovz9wJfA3uAxuibDLQCA+IqynnAQuBuYCnwMLC1rx48U12U8cZqdWqMDcx4cI16qTpYbVKHqa+ovWUeHKsujn7VL9ULq2HI+wY7gVeBJdGeFu3J4ZUiy/cAXeHRRuAQsC/GC0B3eG4BcH/0tUV7czUAeVsMsBF4Kha9HZgCvAncAuwPnXHA0wFuGLANuDrGuoGDwFxgTqzzQ7RX5FrP2eLsdb76vnogtme6+nE8H1YPlQXHwbi3q9eqn0e7Tb25VrsF68vFY0lb1AGcDTwItGQ8tQM4AIwGmqP/EPAu8A0wElgJfFGzxTo8mKWXu9Rd4ZF96jvqjSbauEC9Sn1O3R463epLaku99voCsFXdkAH3kNpcQW+IiT/bQne3eufxBtioPqP2mKhioXpWzpxb1T8C5Ifh4ZptVoriRmAIKdrI3Lujf3bobAPeJpF0NVkKrAFuI9HTOBIxnxFrF4OgQKKr/dnJlQA+AcwABgOHA4zAamA5cE7orQL+zAEHiWI+A2bFC7aSguheYCgpqAphZz3wSB7AecCICv2TgH8oFRib4gVqka0k0h8CXAxMBW6ooDejFoCvA9OBQUAvKWM0kDz4XUZvNKXtyZMWUl7vBbaQXq457PeEziDgx/KJlQAuIPFdMcEXv5OdYWBP9M8k8VpnDQCvB4aTSrCNJB5cSdrW3tBpIJVnR0qdUTxAfdGUOVTnmwqEanNmqltC/9OgqePKg5eom8PgdvW+oJ9Kupera0O3U50TL3lcAaI+oHaF4R3qa6Z822wq0Saq89T1lmSxOrxeW/Xm4uGkiqQDmECKuKHxHW0HdpMiewSpvGqKeR8Ay0iBsYIjg6261PE2o9Q3Yqv+MqWxO9R1Hl12qs+q49Vlppy82pSr+5xJKsko4AXgHlJ0t5NIeg3wLXAlqZhtIUV8J6nmWwX8QiLjdhL5TwMWkY4R6/rrwYKlMr1Y321QZ/vfwBijPqm+rF4Wc7PjE9QllurGVeoV5gRNHsAm9fnMom3qrKPoTjKdMXaYyrFygEWQ72XWW24qhPu8xcUc2UU6O8wFPjmK7jhgPHAuMJGUGQ6U6WwE5sfzTXGvei7KA9hFOiR9D/wOfFVFt4dS2tpfRe83Ur7/CPiJakfOGgBCypubatArl2r8VfOax/LfzABKtePAzHO/5FgC7KBEzB2kOrDfUm8mOeFySv9+OyFyGmB/5aQH+C9BVKmVCNuMZgAAAABJRU5ErkJggg==";class le extends O.Component{static instance=null;scene=new o.Scene;renderer;currentScene;cameras=new Map;controls=new Map;currentCamera;currentWindow;cameraHelpers=new Map;lightHelpers=new Map;helpersContainer=new o.Group;grid=new za;interactionHelper=new o.AxesHelper(25);currentTransform;splineEditor;depthMaterial=new o.MeshDepthMaterial;normalsMaterial=new o.MeshNormalMaterial;uvMaterial=new Ba;wireframeMaterial=new o.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0});playing=!1;rafID=-1;cameraControlsRafID=-1;width=0;height=0;sceneSet=!1;tlCam=null;trCam=null;blCam=null;brCam=null;tlRender="Renderer";trRender="Renderer";blRender="Renderer";brRender="Renderer";cameraVisibility=!0;lightVisibility=!0;selectedItem=void 0;debugCamera;raycaster=new o.Raycaster;pointer=new o.Vector2;cameraControls=void 0;canvasRef;containerRef;tlWindow;trWindow;blWindow;brWindow;constructor(e){super(e),this.canvasRef=O.createRef(),this.containerRef=O.createRef(),this.tlWindow=O.createRef(),this.trWindow=O.createRef(),this.blWindow=O.createRef(),this.brWindow=O.createRef();const t=e.three.app.appID,s=localStorage,n=s.getItem(`${t}_mode`);this.state={mode:n!==null?n:"Single",modeOpen:!1,renderModeOpen:!1,interactionMode:"Orbit",interactionModeOpen:!1,lastUpdate:Date.now()},s.setItem(`${t}_mode`,this.state.mode),s.setItem(`${t}_tlCam`,s.getItem(`${t}_tlCam`)!==null?s.getItem(`${t}_tlCam`):"Debug"),s.setItem(`${t}_trCam`,s.getItem(`${t}_trCam`)!==null?s.getItem(`${t}_trCam`):"Orthographic"),s.setItem(`${t}_blCam`,s.getItem(`${t}_blCam`)!==null?s.getItem(`${t}_blCam`):"Front"),s.setItem(`${t}_brCam`,s.getItem(`${t}_brCam`)!==null?s.getItem(`${t}_brCam`):"Top"),s.setItem(`${t}_tlRender`,s.getItem(`${t}_tlRender`)!==null?s.getItem(`${t}_tlRender`):"Renderer"),s.setItem(`${t}_trRender`,s.getItem(`${t}_trRender`)!==null?s.getItem(`${t}_trRender`):"Renderer"),s.setItem(`${t}_blRender`,s.getItem(`${t}_blRender`)!==null?s.getItem(`${t}_blRender`):"Renderer"),s.setItem(`${t}_brRender`,s.getItem(`${t}_brRender`)!==null?s.getItem(`${t}_brRender`):"Renderer");const a={Vector2:o.Vector2,Vector3:o.Vector3,Vector4:o.Vector4,Quaternion:o.Quaternion,Matrix4:o.Matrix4,Spherical:o.Spherical,Box3:o.Box3,Sphere:o.Sphere,Raycaster:o.Raycaster};Me.install({THREE:a}),this.setupScene(),this.setupTools();const r=localStorage.getItem(this.expandedCameraVisibility);this.cameraVisibility=r!==null?r==="open":!1,this.saveExpandedCameraVisibility();const l=localStorage.getItem(this.expandedLightVisibility);this.lightVisibility=l!==null?l==="open":!1,this.saveExpandedLightVisibility(),le.instance=this}componentDidMount(){this.setupRenderer(),this.enable(),this.assignControls(),this.resize(),this.play(),de.instance.three=this.props.three,de.instance.activeCamera=this.debugCamera}componentDidUpdate(e,t,s){t.mode!==this.state.mode&&(this.assignControls(),this.resize())}componentWillUnmount(){this.disable(),J.removeEditorGroup("View Settings")}render(){const e=[];return this.cameras.forEach((t,s)=>{e.push(s)}),p.jsxs("div",{className:"multiview",children:[p.jsx("canvas",{ref:this.canvasRef}),p.jsxs("div",{className:`cameras ${this.state.mode==="Single"||this.state.mode==="Stacked"?"single":""}`,ref:this.containerRef,children:[this.state.mode==="Single"&&p.jsx(p.Fragment,{children:p.jsx(ze,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}})}),(this.state.mode==="Side by Side"||this.state.mode==="Stacked")&&p.jsxs(p.Fragment,{children:[p.jsx(ze,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}}),p.jsx(ze,{name:"tr",camera:this.trCam,options:e,ref:this.trWindow,onSelectCamera:t=>{this.controls.get(this.trCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.trCam),this.trCam=s,localStorage.setItem(`${this.appID}_trCam`,s.name),this.createControls(s,this.trWindow.current))},onSelectRenderMode:t=>{this.trRender=t,localStorage.setItem(`${this.appID}_trRender`,t)}})]}),this.state.mode==="Quad"&&p.jsxs(p.Fragment,{children:[p.jsx(ze,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}}),p.jsx(ze,{name:"tr",camera:this.trCam,options:e,ref:this.trWindow,onSelectCamera:t=>{this.controls.get(this.trCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.trCam),this.trCam=s,localStorage.setItem(`${this.appID}_trCam`,s.name),this.createControls(s,this.trWindow.current))},onSelectRenderMode:t=>{this.trRender=t,localStorage.setItem(`${this.appID}_trRender`,t)}}),p.jsx(ze,{name:"bl",camera:this.blCam,options:e,ref:this.blWindow,onSelectCamera:t=>{this.controls.get(this.blCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.blCam),this.blCam=s,localStorage.setItem(`${this.appID}_blCam`,s.name),this.createControls(s,this.blWindow.current))},onSelectRenderMode:t=>{this.blRender=t,localStorage.setItem(`${this.appID}_blRender`,t)}}),p.jsx(ze,{name:"br",camera:this.brCam,options:e,ref:this.brWindow,onSelectCamera:t=>{this.controls.get(this.brCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.brCam),this.brCam=s,localStorage.setItem(`${this.appID}_brCam`,s.name),this.createControls(s,this.brWindow.current))},onSelectRenderMode:t=>{this.brRender=t,localStorage.setItem(`${this.appID}_brRender`,t)}})]})]}),p.jsxs("div",{className:"settings",children:[p.jsx(Ht,{title:"View",index:us.indexOf(this.state.mode),options:us,onSelect:t=>{t!==this.state.mode&&(this.killControls(),this.setState({mode:t}),localStorage.setItem(`${this.appID}_mode`,t))},open:this.state.modeOpen,onToggle:t=>{this.setState({modeOpen:t,renderModeOpen:!1,interactionModeOpen:!1})}}),p.jsx(Ht,{title:"Interact",index:this.state.interactionMode==="Orbit"?0:1,options:["Orbit Mode","Selection Mode"],onSelect:t=>{this.interactionHelper.visible=t==="Selection Mode",this.setState({interactionMode:this.interactionHelper.visible?"Selection":"Orbit"})},open:this.state.interactionModeOpen,onToggle:t=>{this.setState({modeOpen:!1,renderModeOpen:!1,interactionModeOpen:t})}}),p.jsx(ns,{name:"cameraHelper",icon:er,selected:this.cameraVisibility,height:24,top:2,onClick:t=>{if(this.cameraVisibility=t,this.saveExpandedCameraVisibility(),this.cameraHelpers.forEach(s=>{s.visible=t}),this.selectedItem!==void 0&&!t){const s=this.cameraHelpers.get(this.selectedItem.name);s!==void 0&&(s.visible=!0)}}}),p.jsx(ns,{name:"lightHelper",icon:tr,selected:this.lightVisibility,height:24,top:4,onClick:t=>{if(this.lightVisibility=t,this.saveExpandedLightVisibility(),this.lightHelpers.forEach(s=>{s.visible=t}),this.selectedItem!==void 0&&!t&&this.selectedItem.isLight===!0){const s=this.lightHelpers.get(this.selectedItem.name);s!==void 0&&(s.visible=!0)}}})]},this.state.lastUpdate)]})}setupRenderer(){this.renderer=new o.WebGLRenderer({canvas:this.canvasRef.current,stencil:!1}),this.renderer.autoClear=!1,this.renderer.shadowMap.enabled=!0,this.renderer.setPixelRatio(devicePixelRatio),this.renderer.setClearColor(0),this.props.three.renderer=this.renderer}setupScene(){this.scene.name="Debug Scene",this.scene.uuid="",this.helpersContainer.name="helpers",this.scene.add(this.helpersContainer),this.helpersContainer.add(this.grid),this.interactionHelper.name="interactionHelper",this.interactionHelper.visible=!1,this.helpersContainer.add(this.interactionHelper);const e=(a,r)=>{const l=new o.OrthographicCamera(-100,100,100,-100,0,3e3);return l.name=a,l.position.copy(r),l.lookAt(0,0,0),this.cameras.set(a,l),l},t=1e3;e("Top",new o.Vector3(0,t,0)),e("Bottom",new o.Vector3(0,-t,0)),e("Left",new o.Vector3(-t,0,0)),e("Right",new o.Vector3(t,0,0)),e("Front",new o.Vector3(0,0,t)),e("Back",new o.Vector3(0,0,-t)),e("Orthographic",new o.Vector3(t,t,t)),e("UI",new o.Vector3),this.debugCamera=new o.PerspectiveCamera(60,1,50,5e3),this.debugCamera.name="Debug",this.debugCamera.position.set(500,500,500),this.debugCamera.lookAt(0,0,0),this.cameras.set("Debug",this.debugCamera),this.currentCamera=this.debugCamera;const s=localStorage,n=this.props.three.app.appID;this.tlCam=this.cameras.get(s.getItem(`${n}_tlCam`)),this.trCam=this.cameras.get(s.getItem(`${n}_trCam`)),this.blCam=this.cameras.get(s.getItem(`${n}_blCam`)),this.brCam=this.cameras.get(s.getItem(`${n}_brCam`)),this.tlCam===void 0&&(this.tlCam=this.cameras.get("Debug")),this.trCam===void 0&&(this.trCam=this.cameras.get("Orthographic")),this.blCam===void 0&&(this.blCam=this.cameras.get("Front")),this.brCam===void 0&&(this.brCam=this.cameras.get("Top"))}setupTools(){J.addEditorGroup({title:"View Settings",items:[{type:"boolean",prop:"Show Grid",value:this.grid.visible}],onUpdate:(e,t)=>{switch(e){case"Show Grid":this.grid.visible=t;break}}}),this.splineEditor=new Ps(this.currentCamera),this.splineEditor.initDebug(),this.scene.add(this.splineEditor)}play(){this.playing=!0,this.onUpdate()}pause(){this.playing=!1,cancelAnimationFrame(this.rafID),this.rafID=-1}toggleOrbitControls(e){this.controls.forEach(t=>{t.enabled=!e})}update(){this.controls.forEach(e=>e.update()),this.cameraHelpers.forEach(e=>e.update()),this.lightHelpers.forEach(e=>{e.update!==void 0&&e.update()}),this.props.onSceneUpdate!==void 0&&this.sceneSet&&this.props.onSceneUpdate(this.currentScene)}draw(){switch(this.renderer?.clear(),this.state.mode){case"Single":this.drawSingle();break;case"Side by Side":case"Stacked":this.drawDouble();break;case"Quad":this.drawQuad();break}}onUpdate=()=>{this.playing&&(this.update(),this.draw(),this.rafID=requestAnimationFrame(this.onUpdate))};enable(){const e=this.containerRef.current;e.addEventListener("mousemove",this.onMouseMove),e.addEventListener("click",this.onClick),window.addEventListener("keydown",this.onKey),window.addEventListener("resize",this.resize),R.addEventListener(P.SET_SCENE,this.sceneUpdate),R.addEventListener(P.ADD_CAMERA,this.addCamera),R.addEventListener(P.REMOVE_CAMERA,this.removeCamera),R.addEventListener(P.SET_OBJECT,this.onSetSelectedItem)}disable(){const e=this.containerRef.current;e.removeEventListener("mousemove",this.onMouseMove),e.removeEventListener("click",this.onClick),window.removeEventListener("keydown",this.onKey),window.removeEventListener("resize",this.resize),R.removeEventListener(P.SET_SCENE,this.sceneUpdate),R.removeEventListener(P.ADD_CAMERA,this.addCamera),R.removeEventListener(P.REMOVE_CAMERA,this.removeCamera),R.removeEventListener(P.SET_OBJECT,this.onSetSelectedItem)}resize=()=>{this.width=window.innerWidth-300,this.height=window.innerHeight;const e=Math.floor(this.width/2),t=Math.floor(this.height/2);this.props.three.resize(this.width,this.height),this.props.onSceneResize!==void 0&&this.sceneSet&&this.currentScene!==void 0&&this.props.onSceneResize(this.currentScene,this.width,this.height);let s=this.width,n=this.height;switch(this.state.mode){case"Side by Side":s=e,n=this.height;break;case"Stacked":s=this.width,n=t;break;case"Quad":s=e,n=t;break}const a=s/n;this.cameras.forEach(r=>{r instanceof o.OrthographicCamera?(r.left=s/-2,r.right=s/2,r.top=n/2,r.bottom=n/-2,r.name==="UI"&&(r.position.x=this.width/2,r.position.y=this.height/-2,r.position.z=100),r.updateProjectionMatrix()):r instanceof o.PerspectiveCamera&&(r.aspect=a,r.updateProjectionMatrix()),this.cameraHelpers.get(r.name)?.update()})};sceneUpdate=e=>{this.clearLightHelpers(),this.scene.remove(this.currentScene),Ae(this.currentScene);const t=this.props.scenes.get(e.value.name);if(t!==void 0){const s=new t;this.props.onSceneSet!==void 0&&this.props.onSceneSet(s),this.currentScene=s,this.props.three.scene=this.currentScene,this.scene.add(this.currentScene),this.sceneSet=!0,this.addLightHelpers()}};addCamera=e=>{const t=e.value,s=this.props.three.scene?.getObjectByProperty("uuid",t.uuid);if(s!==void 0){const n=s;this.cameras.set(t.name,n);const a=new o.CameraHelper(n);a.visible=this.cameraVisibility,this.cameraHelpers.set(n.name,a),this.scene.add(a),this.setState({lastUpdate:Date.now()})}};removeCamera=e=>{const t=this.cameraHelpers.get(e.value.name);t!==void 0&&(this.scene.remove(t),t.dispose()),this.cameras.delete(e.value.name),this.setState({lastUpdate:Date.now()})};onMouseMove=e=>{const t=new o.Vector2;this.renderer.getSize(t);const s=Math.min(e.clientX,t.x),n=Math.min(e.clientY,t.y);this.pointer.x=qe(s,0,t.x,-1,1),this.pointer.y=qe(n,0,t.y,1,-1);const a=t.x/2,r=t.y/2,l=()=>{s<a?this.pointer.x=qe(s,0,a,-1,1):this.pointer.x=qe(s,a,t.x,-1,1)},h=()=>{n<r?this.pointer.y=qe(n,0,r,1,-1):this.pointer.y=qe(n,r,t.y,1,-1)};switch(this.state.mode){case"Quad":l(),h();break;case"Side by Side":l();break;case"Stacked":h(),h();break}if(this.updateCamera(s,n,a,r),this.state.interactionMode==="Orbit")return;const c=this.raycaster.intersectObjects(this.currentScene.children);c.length>0&&this.interactionHelper.position.copy(c[0].point)};onClick=e=>{if(this.state.interactionMode==="Orbit")return;const t=new o.Vector2;if(this.renderer.getSize(t),e.clientX>=t.x)return;this.onMouseMove(e);const s=this.raycaster.intersectObjects(this.currentScene.children);s.length>0&&(this.props.three.getObject(s[0].object.uuid),this.interactionHelper.visible=!1,this.setState({interactionMode:"Orbit",lastUpdate:Date.now()}))};onKey=e=>{if(this.selectedItem!==void 0){if(e.ctrlKey){if(this.currentCamera.name==="UI")return;const t=this.controls.get(this.currentCamera.name);e.key==="0"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Me(this.currentCamera,this.currentWindow.current),this.selectedItem instanceof o.Mesh||this.selectedItem instanceof o.SkinnedMesh?(this.selectedItem.geometry.computeBoundingBox(),this.cameraControls.fitToBox(this.selectedItem.geometry.boundingBox,!0)):this.cameraControls.fitToSphere(this.selectedItem,!0),this.updateCameraControls(t,!0)):e.key==="1"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Me(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(0,Math.PI*.5,!0),this.cameraControls.moveTo(this.selectedItem.position.x,this.selectedItem.position.y,0,!0),this.updateCameraControls(t)):e.key==="2"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Me(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(0,0,!0),this.cameraControls.moveTo(this.selectedItem.position.x,0,this.selectedItem.position.z,!0),this.updateCameraControls(t)):e.key==="3"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Me(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Math.PI/2,Math.PI/2,!0),this.cameraControls.moveTo(0,this.selectedItem.position.y,this.selectedItem.position.z,!0),this.updateCameraControls(t)):e.key==="4"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Me(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Math.PI,Math.PI/2,!0),this.cameraControls.moveTo(this.selectedItem.position.x,this.selectedItem.position.y,0,!0),this.updateCameraControls(t)):e.key==="5"&&(e.preventDefault(),this.clearControls(),this.cameraControls=new Me(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(_i(45),_i(45),!0),this.updateCameraControls(t))}else if(this.currentTransform!==void 0)switch(e.key){case"r":this.currentTransform.setMode("rotate");break;case"s":this.currentTransform.setMode("scale");break;case"t":this.currentTransform.setMode("translate");break;case"q":this.currentTransform.setSpace(this.currentTransform.space==="local"?"world":"local");break}}};onSetSelectedItem=e=>{this.selectedItem!==void 0&&this.updateSelectedItemHelper(!1),this.selectedItem=this.currentScene.getObjectByProperty("uuid",e.value.uuid),this.selectedItem!==void 0&&(this.currentTransform!==void 0&&(this.currentTransform.removeEventListener("objectChange",this.onUpdateTransform),de.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=de.instance.add(e.value.name),this.currentTransform.attach(this.selectedItem),this.scene.add(this.currentTransform.getHelper()),this.currentTransform.addEventListener("objectChange",this.onUpdateTransform),this.updateSelectedItemHelper(!0))};updateSelectedItemHelper(e){if(this.selectedItem!==void 0)if(this.cameraVisibility){if(this.selectedItem.isLight===!0&&!this.lightVisibility){const t=this.lightHelpers.get(this.selectedItem.name);t!==void 0&&(t.visible=e)}}else{const t=this.cameraHelpers.get(this.selectedItem.name);t!==void 0&&(t.visible=e)}}onUpdateTransform=()=>{this.selectedItem!==void 0&&(this.props.three.updateObject(this.selectedItem.uuid,"position",this.selectedItem.position),this.props.three.updateObject(this.selectedItem.uuid,"rotation",{x:this.selectedItem.rotation.x,y:this.selectedItem.rotation.y,z:this.selectedItem.rotation.z}),this.props.three.updateObject(this.selectedItem.uuid,"scale",this.selectedItem.scale),Yt.instance.update())};clearLightHelpers=()=>{this.lightHelpers.forEach(e=>{this.helpersContainer.remove(e),e.dispose()}),this.lightHelpers.clear()};addLightHelpers=()=>{this.currentScene!==void 0&&this.currentScene.traverse(e=>{if(e.type.search("Light")>-1){let t;switch(e.type){case"DirectionalLight":t=new o.DirectionalLightHelper(e,100),t.name=`${e.name}Helper`,t.visible=this.lightVisibility,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"HemisphereLight":t=new o.HemisphereLightHelper(e,250),t.name=`${e.name}Helper`,t.visible=this.lightVisibility,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"RectAreaLight":t=new ya(e),t.name=`${e.name}Helper`,t.visible=this.lightVisibility,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"PointLight":t=new o.PointLightHelper(e,100),t.name=`${e.name}Helper`,t.visible=this.lightVisibility,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"SpotLight":t=new o.SpotLightHelper(e),t.name=`${e.name}Helper`,t.visible=this.lightVisibility,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break}}})};createControls(e,t){const s=this.controls.get(e.name);if(s!==void 0&&s.dispose(),this.controls.delete(e.name),e.name==="UI")return;const n=new ba(e,t);switch(n.enableDamping=!0,n.dampingFactor=.05,e.name){case"Top":case"Bottom":case"Left":case"Right":case"Front":case"Back":n.enableRotate=!1;break}this.controls.set(e.name,n)}clearCamera(e){const t=this.cameraHelpers.get(e.name);t!==void 0&&(this.scene.remove(t),t.dispose(),this.cameraHelpers.delete(e.name));const s=this.controls.get(e.name);s!==void 0&&(s.dispose(),this.controls.delete(e.name))}killControls(){this.controls.forEach((e,t)=>{e.dispose();const s=this.cameraHelpers.get(t);s!==void 0&&(this.scene.remove(s),s.dispose()),this.cameraHelpers.delete(t),this.controls.delete(t)}),this.controls.clear(),this.cameraHelpers.clear()}assignControls(){switch(this.state.mode){case"Single":this.createControls(this.tlCam,this.tlWindow.current);break;case"Side by Side":case"Stacked":this.createControls(this.tlCam,this.tlWindow.current),this.createControls(this.trCam,this.trWindow.current);break;case"Quad":this.createControls(this.tlCam,this.tlWindow.current),this.createControls(this.trCam,this.trWindow.current),this.createControls(this.blCam,this.blWindow.current),this.createControls(this.brCam,this.brWindow.current);break}}updateCamera=(e,t,s,n)=>{switch(this.state.mode){case"Quad":t<n?e<s?this.currentCamera=this.tlCam:this.currentCamera=this.trCam:e<s?this.currentCamera=this.blCam:this.currentCamera=this.brCam;break;case"Side by Side":e<s?this.currentCamera=this.tlCam:this.currentCamera=this.trCam;break;case"Single":this.currentCamera=this.tlCam;break;case"Stacked":t<n?this.currentCamera=this.tlCam:this.currentCamera=this.trCam;break}this.splineEditor.camera=this.currentCamera,this.raycaster.setFromCamera(this.pointer,this.currentCamera),this.currentCamera===this.tlCam?this.currentWindow=this.tlWindow:this.currentCamera===this.trCam?this.currentWindow=this.trWindow:this.currentCamera===this.blCam?this.currentWindow=this.blWindow:this.currentCamera===this.brCam&&(this.currentWindow=this.brWindow),de.instance.updateCamera(this.currentCamera,this.currentWindow.current)};updateCameraControls=(e,t=!1)=>{if(this.selectedItem===void 0)return;cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.cameraControls&&(this.cameraControls.smoothTime=.1);const s=.15,n=new o.Clock;n.start(),this.selectedItem.getWorldPosition(e.target0);const a=()=>{const r=n.getDelta();this.cameraControls&&this.cameraControls.update(r),t&&(e.target.lerp(e.target0,s),e.object.position.lerp(e.position0,s),e.object.zoom=it(e.object.zoom,e.zoom0,s),e.object.updateProjectionMatrix(),e.dispatchEvent({type:"change"})),n.getElapsedTime()>=.5?(cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.clearControls()):this.cameraControlsRafID=requestAnimationFrame(a)};a()};clearControls=()=>{this.cameraControls!==void 0&&(this.cameraControls.disconnect(),this.cameraControls.dispose(),this.cameraControls=void 0)};saveExpandedCameraVisibility(){localStorage.setItem(this.expandedCameraVisibility,this.cameraVisibility?"open":"closed")}saveExpandedLightVisibility(){localStorage.setItem(this.expandedLightVisibility,this.lightVisibility?"open":"closed")}getSceneOverride(e){switch(e){case"Depth":return this.depthMaterial;case"Normals":return this.normalsMaterial;case"Renderer":return null;case"UVs":return this.uvMaterial;case"Wireframe":return this.wireframeMaterial}return null}drawTo(e,t,s,n,a,r){switch(a.name){case"Left":case"Right":this.grid.rotation.z=Math.PI/2;break;case"Front":case"Back":this.grid.rotation.x=Math.PI/2;break}this.scene.overrideMaterial=r,this.renderer?.setViewport(e,t,s,n),this.renderer?.setScissor(e,t,s,n),this.renderer?.render(this.scene,a),this.grid.rotation.set(0,0,0)}drawSingle(){const e=this.getSceneOverride(this.tlRender);this.drawTo(0,0,this.width,this.height,this.tlCam,e)}drawDouble=()=>{const e=this.getSceneOverride(this.tlRender),t=this.getSceneOverride(this.trRender),s=Math.floor(this.width/2),n=Math.floor(this.height/2);if(this.state.mode==="Side by Side")this.drawTo(0,0,s,this.height,this.tlCam,e),this.drawTo(s,0,s,this.height,this.trCam,t);else{const a=this.height-n;this.drawTo(0,a,this.width,n,this.tlCam,e),this.drawTo(0,0,this.width,n,this.trCam,t)}};drawQuad=()=>{const e=this.getSceneOverride(this.tlRender),t=this.getSceneOverride(this.trRender),s=this.getSceneOverride(this.blRender),n=this.getSceneOverride(this.brRender),a=Math.floor(this.width/2),r=Math.floor(this.height/2);let l=0,h=0;h=this.height-r,l=0,this.drawTo(l,h,a,r,this.tlCam,e),l=a,this.drawTo(l,h,a,r,this.trCam,t),h=0,l=0,this.scene.overrideMaterial=s,this.drawTo(l,h,a,r,this.blCam,s),l=a,this.drawTo(l,h,a,r,this.brCam,n)};get appID(){return this.props.three.app.appID}get mode(){return this.state.mode}get three(){return this.props.three}get expandedCameraVisibility(){return`${this.appID}_multiviewCameraVisibility`}get expandedLightVisibility(){return`${this.appID}_multiviewLightVisibility`}}class Yt extends O.Component{static instance;matrix=new o.Matrix4;position=new o.Vector3;rotation=new o.Euler;scale=new o.Vector3;open=!1;constructor(e){super(e);const t=localStorage.getItem(this.expandedName),s=t!==null?t==="open":!1;this.open=s,this.saveExpanded(),this.state={lastUpdated:0,expanded:s},this.matrix.elements=e.object.matrix,e.object.uuid.length>0&&(this.position.setFromMatrixPosition(this.matrix),this.rotation.setFromRotationMatrix(this.matrix),this.scale.setFromMatrixScale(this.matrix)),Yt.instance=this}update(){if(le.instance){const e=le.instance.selectedItem;if(e===void 0)return;this.position.x=Ce(e.position.x,3),this.position.y=Ce(e.position.y,3),this.position.z=Ce(e.position.z,3),this.rotation.copy(e.rotation),this.scale.x=Ce(e.scale.x,3),this.scale.y=Ce(e.scale.y,3),this.scale.z=Ce(e.scale.z,3),this.setState({lastUpdated:Date.now()})}}render(){return p.jsx(be,{title:"Transform",expanded:this.open,items:[{title:"Position",prop:"position",type:"grid3",step:.1,value:this.position,onChange:this.updateTransform},{title:"Rotation",prop:"rotation",type:"euler",value:this.rotation,onChange:this.updateTransform},{title:"Scale",prop:"scale",type:"grid3",value:this.scale,onChange:this.updateTransform},{title:"Visible",prop:"visible",type:"boolean",value:this.props.object.visible,onChange:this.updateTransform}],onToggle:e=>{this.open=e,this.saveExpanded()}},this.state.lastUpdated)}updateTransform=(e,t)=>{const s=e==="rotation"?{x:t._x,y:t._y,z:t._z}:t;this.props.three.updateObject(this.props.object.uuid,e,s);const n=this.props.three.getScene(this.props.object.uuid);if(n){const a=n.getObjectByProperty("uuid",this.props.object.uuid);te(a,e,s)}};saveExpanded(){localStorage.setItem(this.expandedName,this.open?"open":"closed")}get expandedName(){return`${this.props.three.app.appID}_transform`}}function ps(i){switch(i){case"color":return"Color";case"intensity":return"Intensity";case"decay":return"Decay";case"distance":return"Distance";case"angle":return"Angle";case"penumbra":return"Penumbra";case"groundColor":return"Ground Color";case"width":return"Width";case"height":return"Height"}return i}function ir(i,e){function t(){return`${e.app.appID}_light`}const s=localStorage.getItem(t()),n=s!==null?s==="open":!1;function a(l){localStorage.setItem(t(),l?"open":"closed")}const r=[];if(i.lightInfo!==void 0)for(const l in i.lightInfo){const h=i.lightInfo[l];h!==void 0&&(h.isColor!==void 0?r.push({title:ps(l),prop:l,type:"color",value:h,onChange:(c,u)=>{const m=new o.Color(u);e.updateObject(i.uuid,c,m);const f=e.getScene(i.uuid);if(f!==null){const g=f.getObjectByProperty("uuid",i.uuid);te(g,c,m)}}}):r.push({title:ps(l),prop:l,type:typeof h,value:h,step:typeof h=="number"?.01:void 0,onChange:(c,u)=>{e.updateObject(i.uuid,c,u);const m=e.getScene(i.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",i.uuid);te(f,c,u)}}}))}return p.jsx(be,{title:"Light",items:r,expanded:n,onToggle:l=>{a(l)}})}function sr(i){const e=i.object,t=i.three;function s(){return`${t.app.appID}_animation`}const n=localStorage.getItem(s()),a=n!==null?n==="open":!1;function r(f){localStorage.setItem(s(),f?"open":"closed")}const l=[],h=[];let c=0;e.animations.forEach(f=>{c=Math.max(c,f.duration),f.duration>0&&h.push({title:f.name,items:[{title:"Duration",type:"number",value:f.duration,disabled:!0},{title:"Blend Mode",type:"option",disabled:!0,options:[{title:"Normal",value:2500},{title:"Additive",value:2501}]}]})}),l.push({title:"Animations",items:h});let u;const m=t.getScene(e.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",e.uuid);if(f!==void 0){const g=f.mixer;if(g!==void 0){const y=[{title:"Time Scale",type:"range",value:g.timeScale,step:.01,min:-1,max:2,onChange:(T,_)=>{g.timeScale=_,t.updateObject(e.uuid,"mixer.timeScale",_)}}];y.push({title:"Stop All",type:"button",onChange:()=>{g.stopAllAction(),t.requestMethod(e.uuid,"stopAllAction",void 0,"mixer")}}),l.push({title:"Mixer",items:y}),u=new o.SkeletonHelper(f),le.instance?.scene.add(u)}}}return O.useEffect(()=>()=>{u!==void 0&&Ae(u)},[]),p.jsx(be,{title:"Animation",items:l,expanded:a,onToggle:f=>{r(f)}})}const Ci={name:"",uuid:"",type:"",visible:!1,matrix:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0,children:[]};let oe={...Ci};function Rs(i){const[e,t]=O.useState(-1);O.useEffect(()=>{function r(h){oe={...h.value},t(Date.now())}function l(){oe={...Ci},t(Date.now())}return R.addEventListener(P.SET_SCENE,l),R.addEventListener(P.SET_OBJECT,r),()=>{R.removeEventListener(P.SET_SCENE,l),R.removeEventListener(P.SET_OBJECT,r)}},[]);const s=oe.type.toLowerCase(),n=oe.animations.length>0||oe.mixer!==void 0,a=s.search("mesh")>-1||s.search("line")>-1||s.search("points")>-1;return p.jsx(Et,{label:"Inspector",button:oe.uuid.length>0?p.jsx("button",{className:"remove",onClick:()=>{de.instance.remove(oe.name),oe={...Ci},t(Date.now())}}):void 0,children:p.jsx("div",{id:"Inspector",className:i.class,children:oe.uuid.length>0&&p.jsxs(p.Fragment,{children:[p.jsxs(p.Fragment,{children:[p.jsx(jt,{type:"string",title:"Name",prop:"name",value:oe.name,disabled:!0}),p.jsx(jt,{type:"string",title:"Type",prop:"type",value:oe.type,disabled:!0}),p.jsx(jt,{type:"string",title:"UUID",prop:"uuid",value:oe.uuid,disabled:!0})]}),p.jsxs(p.Fragment,{children:[p.jsx(Yt,{object:oe,three:i.three}),n?p.jsx(sr,{object:oe,three:i.three}):null,s.search("camera")>-1?va(oe,i.three):null,s.search("light")>-1?ir(oe,i.three):null,a?fa(oe,i.three):null]})]})},e)},"Inspector")}class nr extends O.Component{autoClear=!0;autoClearColor=!0;autoClearDepth=!0;autoClearStencil=!0;outputColorSpace=o.SRGBColorSpace;localClippingEnabled=!1;clearColor=new o.Color(0);clearAlpha=1;toneMapping=o.NoToneMapping;toneMappingExposure=1;constructor(e){super(e);const t=localStorage.getItem(this.expandedName),s=t!==null?t==="open":!1;if(this.state={expanded:s,lastUpdated:Date.now()},this.saveExpanded(s),le.instance){const n=le.instance.renderer;n&&(this.autoClear=n.autoClear,this.autoClearColor=n.autoClearColor,this.autoClearDepth=n.autoClearDepth,this.autoClearStencil=n.autoClearStencil,this.outputColorSpace=n.outputColorSpace,this.localClippingEnabled=n.localClippingEnabled,this.clearAlpha=n.getClearAlpha(),this.toneMapping=n.toneMapping,this.toneMappingExposure=n.toneMappingExposure,n.getClearColor(this.clearColor))}R.addEventListener(P.ADD_RENDERER,this.onAddRenderer)}componentwillunmount(){R.removeEventListener(P.ADD_RENDERER,this.onAddRenderer)}onAddRenderer=e=>{const t=e.value;if(this.autoClear=t.autoClear,this.autoClearColor=t.autoClearColor,this.autoClearDepth=t.autoClearDepth,this.autoClearStencil=t.autoClearStencil,this.outputColorSpace=t.outputColorSpace,this.localClippingEnabled=t.localClippingEnabled,this.clearAlpha=t.clearAlpha,this.toneMapping=t.toneMapping,this.toneMappingExposure=t.toneMappingExposure,this.clearColor.setStyle(t.clearColor,o.LinearSRGBColorSpace),o.ColorManagement.enabled=t.colorManagement,le.instance){const s=le.instance.renderer;s&&(s.autoClear=this.autoClear,s.autoClearColor=this.autoClearColor,s.autoClearDepth=this.autoClearDepth,s.autoClearStencil=this.autoClearStencil,s.outputColorSpace=this.outputColorSpace,s.localClippingEnabled=this.localClippingEnabled,s.toneMapping=this.toneMapping,s.toneMappingExposure=this.toneMappingExposure,s.setClearColor(t.clearColor,this.clearAlpha))}this.setState({lastUpdated:Date.now()})};render(){const e=()=>{if(le.instance){const t=le.instance.renderer;t&&(t.autoClear=this.autoClear,t.autoClearColor=this.autoClearColor,t.autoClearDepth=this.autoClearDepth,t.autoClearStencil=this.autoClearStencil,t.outputColorSpace=this.outputColorSpace,t.localClippingEnabled=this.localClippingEnabled,t.toneMapping=this.toneMapping,t.toneMappingExposure=this.toneMappingExposure,t.setClearColor(this.clearColor.getStyle(),this.clearAlpha),this.props.three.updateRenderer({autoClear:this.autoClear,autoClearColor:this.autoClearColor,autoClearDepth:this.autoClearDepth,autoClearStencil:this.autoClearStencil,outputColorSpace:this.outputColorSpace,localClippingEnabled:this.localClippingEnabled,clearAlpha:this.clearAlpha,clearColor:this.clearColor.getStyle(),colorManagement:o.ColorManagement.enabled,toneMapping:this.toneMapping,toneMappingExposure:this.toneMappingExposure}))}};return p.jsx(be,{title:"Renderer",expanded:this.state.expanded,items:[{type:"boolean",title:"Auto Clear",value:this.autoClear,onChange:(t,s)=>{this.autoClear=s}},{type:"boolean",title:"Auto Clear Color",value:this.autoClearColor,onChange:(t,s)=>{this.autoClearColor=s,e()}},{type:"boolean",title:"Auto Clear Depth",value:this.autoClearDepth,onChange:(t,s)=>{this.autoClearDepth=s,e()}},{type:"boolean",title:"Auto Clear Stencil",value:this.autoClearStencil,onChange:(t,s)=>{this.autoClearStencil=s,e()}},{type:"boolean",title:"Local Clipping",value:this.localClippingEnabled,onChange:(t,s)=>{this.localClippingEnabled=s,e()}},{type:"color",title:"Clear Color",value:`#${this.clearColor.getHexString()}`,onChange:(t,s)=>{this.clearColor.setStyle(s),e()}},{type:"range",title:"Clear Alpha",min:0,max:1,step:.01,value:this.clearAlpha,onChange:(t,s)=>{this.clearAlpha=s,e()}},{type:"boolean",title:"Clear Management",value:o.ColorManagement.enabled,onChange:(t,s)=>{o.ColorManagement.enabled=s,e()}},{type:"option",title:"Color Space",value:this.outputColorSpace,options:[{title:"No Color Space",value:o.NoColorSpace},{title:"SRB Color Space",value:o.SRGBColorSpace},{title:"Linear SRB Color Space",value:o.LinearSRGBColorSpace}],onChange:(t,s)=>{this.outputColorSpace=s,e()}},{type:"option",title:"Tone Mapping",value:this.toneMapping,options:[{title:"None ",value:o.NoToneMapping},{title:"Linear ",value:o.LinearToneMapping},{title:"Reinhard",value:o.ReinhardToneMapping},{title:"Cineon ",value:o.CineonToneMapping},{title:"ACES Filmic",value:o.ACESFilmicToneMapping},{title:"AgX",value:o.AgXToneMapping},{title:"Neutral",value:o.NeutralToneMapping},{title:"Custom",value:o.CustomToneMapping}],onChange:(t,s)=>{this.toneMapping=s,e()}},{type:"range",title:"Tone Mapping Exposure",value:this.toneMappingExposure,min:0,max:2,step:.01,onChange:(t,s)=>{this.toneMappingExposure=s,e()}}],onToggle:t=>{this.setState({expanded:t}),this.saveExpanded(t)}},Math.random())}saveExpanded(e){localStorage.setItem(this.expandedName,e?"open":"closed")}get expandedName(){return`${this.props.three.app.appID}_renderer`}}function Ds(i){const[e]=O.useState([]),[t]=O.useState([]),[s,n]=O.useState(0),a=h=>{const c=h.value;e.push(c),t.push(p.jsx(Et,{label:`Scene: ${c.name}`,scene:c,open:!0,onRefresh:()=>{i.three.refreshScene(c.name)},children:p.jsx(gi,{child:c,scene:c,three:i.three})},Math.random())),n(Date.now())},r=h=>{const c=h.value;for(let u=0;u<e.length;u++)if(c.uuid===e[u].uuid){e[u]=c,t[u]=p.jsx(Et,{label:`Scene: ${c.name}`,scene:c,open:!0,onRefresh:()=>{i.three.refreshScene(c.name)},children:p.jsx(gi,{child:c,scene:c,three:i.three})},Math.random()),n(Date.now());return}},l=h=>{const c=h.value;for(let u=0;u<e.length;u++)if(c.uuid===e[u].uuid){e.splice(u,1),t.splice(u,1),n(Date.now());return}};return O.useEffect(()=>(R.addEventListener(P.ADD_SCENE,a),R.addEventListener(P.REFRESH_SCENE,r),R.addEventListener(P.REMOVE_SCENE,l),()=>{R.removeEventListener(P.ADD_SCENE,a),R.removeEventListener(P.REFRESH_SCENE,r),R.removeEventListener(P.REMOVE_SCENE,l)}),[]),p.jsxs("div",{id:"SidePanel",children:[p.jsx("div",{className:"scenes",children:t},s),p.jsx(Rs,{three:i.three}),p.jsx(nr,{three:i.three}),p.jsx(J,{three:i.three})]})}function ar(i){return O.useEffect(()=>{function e(l){let h=null;return i.three.scenes.forEach(c=>{l.search(c.uuid)>-1&&(h=c)}),h}const t=l=>{const h=l.value,u=e(h)?.getObjectByProperty("uuid",h);u!==void 0&&i.three.setObject(u)},s=(l,h,c)=>{const m=e(l)?.getObjectByProperty("uuid",l);m!==void 0&&te(m,h,c)},n=l=>{const h=l.value,{key:c,value:u,uuid:m}=h;s(m,c,u)},a=l=>{const h=l.value,u=e(h.uuid)?.getObjectByProperty("uuid",h.uuid);if(u!==void 0){const m=f=>{const g=h.key.split(".");switch(g.length){case 1:u[g[0]]=f;break;case 2:u[g[0]][g[1]]=f;break;case 3:u[g[0]][g[1]][g[2]]=f;break;case 4:u[g[0]][g[1]][g[2]][g[3]]=f;break;case 5:u[g[0]][g[1]][g[2]][g[3]][g[4]]=f;break}u.material.needsUpdate=!0};h.value.src.length>0?Es(h.value.src).then(f=>{f.offset.set(h.value.offset[0],h.value.offset[1]),f.repeat.set(h.value.repeat[0],h.value.repeat[1]),m(f)}):m(null)}},r=l=>{const{key:h,uuid:c,value:u,subitem:m}=l.value,g=e(c)?.getObjectByProperty("uuid",c);if(g!==void 0)try{m!==void 0?Vn(g,m)[h](u):g[h](u)}catch(x){console.log("Error requesting method:"),console.log(x),console.log(h),console.log(u)}};return R.addEventListener(P.GET_OBJECT,t),R.addEventListener(P.UPDATE_OBJECT,n),R.addEventListener(P.CREATE_TEXTURE,a),R.addEventListener(P.REQUEST_METHOD,r),()=>{R.removeEventListener(P.GET_OBJECT,t),R.removeEventListener(P.UPDATE_OBJECT,n),R.removeEventListener(P.CREATE_TEXTURE,a),R.removeEventListener(P.REQUEST_METHOD,r)}},[]),null}function Is(i){return p.jsxs("div",{className:"editor",ref:i.ref,style:i.style,children:[p.jsx("div",{className:"header",children:i.header}),i.children,p.jsx("div",{className:"footer",children:i.footer})]})}function rr(i){return p.jsx(Is,{children:p.jsxs(p.Fragment,{children:[p.jsx(le,{three:i.three,scenes:i.scenes,onSceneResize:i.onSceneResize,onSceneSet:i.onSceneSet,onSceneUpdate:i.onSceneUpdate}),p.jsx(Ds,{three:i.three})]})})}exports.Accordion=Et;exports.Application=Dn;exports.BaseRemote=Vt;exports.ChildObject=Si;exports.ContainerObject=gi;exports.Draggable=ws;exports.DraggableItem=Ss;exports.Dropdown=xs;exports.DropdownItem=Os;exports.Editor=Is;exports.ElementProxy=Pn;exports.ElementProxyReceiver=bs;exports.ExportTexture=yt;exports.Inspector=Rs;exports.MultiView=le;exports.NavButton=Ei;exports.ProxyManager=Rn;exports.QualityType=ys;exports.RemoteComponents=In;exports.RemoteController=qn;exports.RemoteTheatre=Nn;exports.RemoteThree=Yn;exports.SceneInspector=ar;exports.SidePanel=Ds;exports.Spline=yi;exports.SplineEditor=Ps;exports.ThreeEditor=rr;exports.ToolEvents=P;exports.Transform=de;exports.WebworkerEventHandlers=Mn;exports.capitalize=bt;exports.clamp=je;exports.colorToHex=ui;exports.copyToClipboard=fs;exports.cubicBezier=yn;exports.customizeTheatreElements=kn;exports.damp=pn;exports.debugDispatcher=R;exports.defaultTheatreCallback=nn;exports.detectSettings=hn;exports.dispose=Ae;exports.disposeMaterial=Cs;exports.disposeTexture=pi;exports.distance=un;exports.hierarchyUUID=zt;exports.isColor=_s;exports.map=dn;exports.mix=it;exports.noop=Ct;exports.normalize=Ft;exports.parseModelLite=Cn;exports.randomID=gs;exports.resetThreeObjects=mi;exports.round=Ce;exports.roundTo=mn;exports.theatreEditorApp=Ln;