zigbee2mqtt-windfront 1.3.1 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/About-DWd-FRHV.js +1 -0
- package/dist/assets/About-DWd-FRHV.js.br +0 -0
- package/dist/assets/{Availability-Dg28cVsy.js → Availability-BlHShukE.js} +1 -1
- package/dist/assets/Availability-BlHShukE.js.br +0 -0
- package/dist/assets/{Bind-Dj7BlJ9c.js → Bind--RRs-W5F.js} +1 -1
- package/dist/assets/Bind--RRs-W5F.js.br +0 -0
- package/dist/assets/{Bridge-Dg4Q3BhD.js → Bridge-D_vSQVtL.js} +1 -1
- package/dist/assets/Bridge-D_vSQVtL.js.br +0 -0
- package/dist/assets/{CheckboxField-BhwpagjA.js → CheckboxField-BnGINJ_L.js} +1 -1
- package/dist/assets/CheckboxField-BnGINJ_L.js.br +1 -0
- package/dist/assets/{ClusterSinglePicker-BavLYJxh.js → ClusterSinglePicker-Din9Za54.js} +1 -1
- package/dist/assets/ClusterSinglePicker-Din9Za54.js.br +0 -0
- package/dist/assets/{Clusters-PG0HopAK.js → Clusters-CZnvbLEQ.js} +1 -1
- package/dist/assets/Clusters-CZnvbLEQ.js.br +0 -0
- package/dist/assets/{Dashboard-D1wWXNU0.js → Dashboard-CJo-_W50.js} +1 -1
- package/dist/assets/Dashboard-CJo-_W50.js.br +0 -0
- package/dist/assets/DashboardFeatureWrapper-thmNrJlL.js +1 -0
- package/dist/assets/DashboardFeatureWrapper-thmNrJlL.js.br +0 -0
- package/dist/assets/{DebouncedInput-jeSVRz3c.js → DebouncedInput-BafFXiut.js} +1 -1
- package/dist/assets/DebouncedInput-BafFXiut.js.br +0 -0
- package/dist/assets/{DevConsole-CRKukHFU.js → DevConsole-CbIcjK1p.js} +1 -1
- package/dist/assets/DevConsole-CbIcjK1p.js.br +0 -0
- package/dist/assets/{DevConsole-DeRbEIDK.js → DevConsole-zGa1OLt0.js} +1 -1
- package/dist/assets/DevConsole-zGa1OLt0.js.br +0 -0
- package/dist/assets/DeviceCard-y50fP3L2.js +1 -0
- package/dist/assets/DeviceCard-y50fP3L2.js.br +0 -0
- package/dist/assets/{DeviceControlEditName-D6ss-GnK.js → DeviceControlEditName-DgKVKbXY.js} +1 -1
- package/dist/assets/DeviceControlEditName-DgKVKbXY.js.br +0 -0
- package/dist/assets/{DeviceImage-CGx5yo8m.js → DeviceImage-DpiYs_Yi.js} +1 -1
- package/dist/assets/DeviceImage-DpiYs_Yi.js.br +0 -0
- package/dist/assets/{DeviceInfo-Ll9Bxn4L.js → DeviceInfo-BKZFFZ7q.js} +1 -1
- package/dist/assets/DeviceInfo-BKZFFZ7q.js.br +0 -0
- package/dist/assets/{DevicePage-BTarwyEH.js → DevicePage-BGSFt320.js} +2 -2
- package/dist/assets/DevicePage-BGSFt320.js.br +0 -0
- package/dist/assets/{DevicePicker-DIWryjuN.js → DevicePicker-Cb2DK3_l.js} +1 -1
- package/dist/assets/DevicePicker-Cb2DK3_l.js.br +0 -0
- package/dist/assets/{DeviceSettings-B8rSL_p0.js → DeviceSettings-2b1hllC1.js} +1 -1
- package/dist/assets/DeviceSettings-2b1hllC1.js.br +0 -0
- package/dist/assets/{DeviceSpecificSettings-DRSJ44yr.js → DeviceSpecificSettings-DT4Z6MHt.js} +1 -1
- package/dist/assets/DeviceSpecificSettings-DT4Z6MHt.js.br +0 -0
- package/dist/assets/Devices-B9BgRuFP.js +1 -0
- package/dist/assets/Devices-B9BgRuFP.js.br +0 -0
- package/dist/assets/{DevicesPage-D4M96fmP.js → DevicesPage-CtnsvG66.js} +1 -1
- package/dist/assets/DevicesPage-CtnsvG66.js.br +0 -0
- package/dist/assets/{DisplayValue-y4u-p3TF.js → DisplayValue-tdl7RHar.js} +1 -1
- package/dist/assets/DisplayValue-tdl7RHar.js.br +0 -0
- package/dist/assets/{Donate-Ceq-2-mP.js → Donate-UTTky4SH.js} +1 -1
- package/dist/assets/Donate-UTTky4SH.js.br +0 -0
- package/dist/assets/{EndpointPicker-Cni8eLro.js → EndpointPicker-gxt1nGLJ.js} +1 -1
- package/dist/assets/EndpointPicker-gxt1nGLJ.js.br +0 -0
- package/dist/assets/{Exposes-CVaHXwu-.js → Exposes-5mTFG3Ef.js} +1 -1
- package/dist/assets/Exposes-5mTFG3Ef.js.br +0 -0
- package/dist/assets/Feature-DFOLPdqE.js +1 -0
- package/dist/assets/Feature-DFOLPdqE.js.br +0 -0
- package/dist/assets/{Frontend-Bw0vB4aZ.js → Frontend-DK8RSLa_.js} +1 -1
- package/dist/assets/Frontend-DK8RSLa_.js.br +0 -0
- package/dist/assets/{GroupPage-SyuMBjnt.js → GroupPage-D4R6f0Yk.js} +2 -2
- package/dist/assets/GroupPage-D4R6f0Yk.js.br +0 -0
- package/dist/assets/{GroupSettings-Wbczyt9u.js → GroupSettings-r9agM4_V.js} +1 -1
- package/dist/assets/GroupSettings-r9agM4_V.js.br +0 -0
- package/dist/assets/{Groups-C16FRyjr.js → Groups-BQsZM3BO.js} +1 -1
- package/dist/assets/Groups-BQsZM3BO.js.br +0 -0
- package/dist/assets/{GroupsPage-DZiiSPYf.js → GroupsPage-Dpc0zk1C.js} +1 -1
- package/dist/assets/GroupsPage-Dpc0zk1C.js.br +0 -0
- package/dist/assets/{Health-D0P1xz_-.js → Health-C6KCb66Y.js} +1 -1
- package/dist/assets/Health-C6KCb66Y.js.br +0 -0
- package/dist/assets/{HomePage-DG90gg1s.js → HomePage-Dvw_ePCt.js} +1 -1
- package/dist/assets/HomePage-Dvw_ePCt.js.br +0 -0
- package/dist/assets/{InputField-E2g5qJCn.js → InputField-B0_X2eEk.js} +1 -1
- package/dist/assets/InputField-B0_X2eEk.js.br +0 -0
- package/dist/assets/{LastSeen-Tt-X3bir.js → LastSeen-NjmmSvGg.js} +1 -1
- package/dist/assets/LastSeen-NjmmSvGg.js.br +0 -0
- package/dist/assets/{LogsPage-CWjf1H8Z.js → LogsPage-C9q_OeJt.js} +1 -1
- package/dist/assets/LogsPage-C9q_OeJt.js.br +0 -0
- package/dist/assets/{Lqi-Bexjv2VI.js → Lqi-DYhonPXp.js} +1 -1
- package/dist/assets/Lqi-DYhonPXp.js.br +0 -0
- package/dist/assets/{NetworkPage-a2O4oSwP.js → NetworkPage-DhUAonvd.js} +2 -2
- package/dist/assets/NetworkPage-DhUAonvd.js.br +0 -0
- package/dist/assets/{NumberField-CH6-YRbT.js → NumberField-BreLavc2.js} +1 -1
- package/dist/assets/NumberField-BreLavc2.js.br +0 -0
- package/dist/assets/OtaPage-D0wyi5bl.js +1 -0
- package/dist/assets/OtaPage-D0wyi5bl.js.br +0 -0
- package/dist/assets/{PowerSource-M8I2qqUm.js → PowerSource-CQr3yan7.js} +1 -1
- package/dist/assets/PowerSource-CQr3yan7.js.br +0 -0
- package/dist/assets/{RawNetworkData-ZdR_BdBV.js → RawNetworkData-DZzchkc5.js} +1 -1
- package/dist/assets/RawNetworkData-DZzchkc5.js.br +0 -0
- package/dist/assets/{RawNetworkMap-DIse-aug.js → RawNetworkMap-CYuhgIzz.js} +6 -6
- package/dist/assets/RawNetworkMap-CYuhgIzz.js.br +0 -0
- package/dist/assets/RecallRemove-DMAg3dfh.js +1 -0
- package/dist/assets/RecallRemove-DMAg3dfh.js.br +0 -0
- package/dist/assets/{Reporting-CUO_xgvP.js → Reporting-CsFn3lrN.js} +1 -1
- package/dist/assets/Reporting-CsFn3lrN.js.br +0 -0
- package/dist/assets/Scene-CBAIOsIU.js +1 -0
- package/dist/assets/Scene-CBAIOsIU.js.br +0 -0
- package/dist/assets/{SelectField-CgXiODUe.js → SelectField-BnBBz4eT.js} +1 -1
- package/dist/assets/SelectField-BnBBz4eT.js.br +0 -0
- package/dist/assets/{Settings-CwUeWW5z.js → Settings-oOf-PU-v.js} +1 -1
- package/dist/assets/Settings-oOf-PU-v.js.br +0 -0
- package/dist/assets/{SettingsList-wPZC4AYF.js → SettingsList-GhU74csM.js} +1 -1
- package/dist/assets/SettingsList-GhU74csM.js.br +0 -0
- package/dist/assets/{SettingsPage-DQqFAgM7.js → SettingsPage-Di5hpubc.js} +2 -2
- package/dist/assets/SettingsPage-Di5hpubc.js.br +0 -0
- package/dist/assets/{State-B0esCQUT.js → State-CjXeiihN.js} +1 -1
- package/dist/assets/State-CjXeiihN.js.br +0 -0
- package/dist/assets/{Table-CH7yonv3.js → Table-CEsZoDJr.js} +1 -1
- package/dist/assets/Table-CEsZoDJr.js.br +0 -0
- package/dist/assets/{TextareaField-DAyUngHz.js → TextareaField-CyY_oPqW.js} +1 -1
- package/dist/assets/TextareaField-CyY_oPqW.js.br +0 -0
- package/dist/assets/{Tools-BQ5g0Zg_.js → Tools-DQSEnJ2x.js} +1 -1
- package/dist/assets/Tools-DQSEnJ2x.js.br +0 -0
- package/dist/assets/{TouchlinkPage-gI3LcGdI.js → TouchlinkPage-CzENmLmI.js} +1 -1
- package/dist/assets/TouchlinkPage-CzENmLmI.js.br +0 -0
- package/dist/assets/{VendorLink-B_MZftSG.js → VendorLink-D2CzkjON.js} +1 -1
- package/dist/assets/VendorLink-D2CzkjON.js.br +0 -0
- package/dist/assets/{_createCompounder-HA4t3BbU.js → _createCompounder-BZl5m4SO.js} +1 -1
- package/dist/assets/_createCompounder-BZl5m4SO.js.br +0 -0
- package/dist/assets/{format-LeabZw87.js → format-CJ06xbdM.js} +1 -1
- package/dist/assets/format-CJ06xbdM.js.br +0 -0
- package/dist/assets/index-EQzdH3Y4.js +644 -0
- package/dist/assets/index-EQzdH3Y4.js.br +0 -0
- package/dist/assets/{index-CIWfMo3U.js → index-HxBDf2nL.js} +1 -1
- package/dist/assets/index-HxBDf2nL.js.br +2 -0
- package/dist/assets/{jszip.min-D01WTHXF.js → jszip.min-UiGIyTtl.js} +1 -1
- package/dist/assets/jszip.min-UiGIyTtl.js.br +0 -0
- package/dist/assets/snakeCase-BDJPMNX4.js +1 -0
- package/dist/assets/snakeCase-BDJPMNX4.js.br +0 -0
- package/dist/index.html +1 -1
- package/dist/index.html.br +0 -0
- package/package.json +9 -9
- package/dist/assets/About-Cd5G1nNd.js +0 -1
- package/dist/assets/About-Cd5G1nNd.js.br +0 -0
- package/dist/assets/Availability-Dg28cVsy.js.br +0 -0
- package/dist/assets/Bind-Dj7BlJ9c.js.br +0 -0
- package/dist/assets/Bridge-Dg4Q3BhD.js.br +0 -2
- package/dist/assets/CheckboxField-BhwpagjA.js.br +0 -0
- package/dist/assets/ClusterSinglePicker-BavLYJxh.js.br +0 -0
- package/dist/assets/Clusters-PG0HopAK.js.br +0 -0
- package/dist/assets/Dashboard-D1wWXNU0.js.br +0 -0
- package/dist/assets/DashboardFeatureWrapper-QO-XFtKk.js +0 -1
- package/dist/assets/DashboardFeatureWrapper-QO-XFtKk.js.br +0 -0
- package/dist/assets/DebouncedInput-jeSVRz3c.js.br +0 -0
- package/dist/assets/DevConsole-CRKukHFU.js.br +0 -0
- package/dist/assets/DevConsole-DeRbEIDK.js.br +0 -0
- package/dist/assets/DeviceCard-D2ifb9S1.js +0 -1
- package/dist/assets/DeviceCard-D2ifb9S1.js.br +0 -0
- package/dist/assets/DeviceControlEditName-D6ss-GnK.js.br +0 -0
- package/dist/assets/DeviceImage-CGx5yo8m.js.br +0 -0
- package/dist/assets/DeviceInfo-Ll9Bxn4L.js.br +0 -0
- package/dist/assets/DevicePage-BTarwyEH.js.br +0 -0
- package/dist/assets/DevicePicker-DIWryjuN.js.br +0 -0
- package/dist/assets/DeviceSettings-B8rSL_p0.js.br +0 -0
- package/dist/assets/DeviceSpecificSettings-DRSJ44yr.js.br +0 -0
- package/dist/assets/Devices-BXMoCKuc.js +0 -1
- package/dist/assets/Devices-BXMoCKuc.js.br +0 -0
- package/dist/assets/DevicesPage-D4M96fmP.js.br +0 -0
- package/dist/assets/DisplayValue-y4u-p3TF.js.br +0 -0
- package/dist/assets/Donate-Ceq-2-mP.js.br +0 -0
- package/dist/assets/EndpointPicker-Cni8eLro.js.br +0 -0
- package/dist/assets/Exposes-CVaHXwu-.js.br +0 -0
- package/dist/assets/Feature-B18PTY7Z.js +0 -1
- package/dist/assets/Feature-B18PTY7Z.js.br +0 -0
- package/dist/assets/Frontend-Bw0vB4aZ.js.br +0 -0
- package/dist/assets/GroupPage-SyuMBjnt.js.br +0 -0
- package/dist/assets/GroupSettings-Wbczyt9u.js.br +0 -0
- package/dist/assets/Groups-C16FRyjr.js.br +0 -0
- package/dist/assets/GroupsPage-DZiiSPYf.js.br +0 -0
- package/dist/assets/Health-D0P1xz_-.js.br +0 -0
- package/dist/assets/HomePage-DG90gg1s.js.br +0 -0
- package/dist/assets/InputField-E2g5qJCn.js.br +0 -0
- package/dist/assets/LastSeen-Tt-X3bir.js.br +0 -0
- package/dist/assets/LogsPage-CWjf1H8Z.js.br +0 -0
- package/dist/assets/Lqi-Bexjv2VI.js.br +0 -0
- package/dist/assets/NetworkPage-a2O4oSwP.js.br +0 -0
- package/dist/assets/NumberField-CH6-YRbT.js.br +0 -0
- package/dist/assets/OtaPage-j_Bw2-GQ.js +0 -1
- package/dist/assets/OtaPage-j_Bw2-GQ.js.br +0 -0
- package/dist/assets/PowerSource-M8I2qqUm.js.br +0 -0
- package/dist/assets/RawNetworkData-ZdR_BdBV.js.br +0 -0
- package/dist/assets/RawNetworkMap-DIse-aug.js.br +0 -0
- package/dist/assets/RecallRemove-BT61_xFm.js +0 -1
- package/dist/assets/RecallRemove-BT61_xFm.js.br +0 -0
- package/dist/assets/Reporting-CUO_xgvP.js.br +0 -0
- package/dist/assets/Scene-C7Y19gU0.js +0 -1
- package/dist/assets/Scene-C7Y19gU0.js.br +0 -0
- package/dist/assets/SelectField-CgXiODUe.js.br +0 -0
- package/dist/assets/Settings-CwUeWW5z.js.br +0 -0
- package/dist/assets/SettingsList-wPZC4AYF.js.br +0 -0
- package/dist/assets/SettingsPage-DQqFAgM7.js.br +0 -0
- package/dist/assets/State-B0esCQUT.js.br +0 -2
- package/dist/assets/Table-CH7yonv3.js.br +0 -0
- package/dist/assets/TextareaField-DAyUngHz.js.br +0 -0
- package/dist/assets/Tools-BQ5g0Zg_.js.br +0 -0
- package/dist/assets/TouchlinkPage-gI3LcGdI.js.br +0 -0
- package/dist/assets/VendorLink-B_MZftSG.js.br +0 -0
- package/dist/assets/_createCompounder-HA4t3BbU.js.br +0 -0
- package/dist/assets/format-LeabZw87.js.br +0 -0
- package/dist/assets/index-BeDhuS24.js +0 -635
- package/dist/assets/index-BeDhuS24.js.br +0 -0
- package/dist/assets/index-CIWfMo3U.js.br +0 -0
- package/dist/assets/jszip.min-D01WTHXF.js.br +0 -0
- package/dist/assets/snakeCase-DF3cbatb.js +0 -1
- package/dist/assets/snakeCase-DF3cbatb.js.br +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{aw as Lx,af as po,ax as lo,r as Q,j as he,ay as VU,b as bg,t as WU,F as ni,a1 as XU,B as ts,az as jU,aA as qU,aB as YU,aC as ZU,aD as KU,aE as JU,aF as QU,aG as $U,aH as eO,aI as Qc,aJ as tO,aK as nO,aL as iO,aM as Iv,s as qa,aN as VS,aO as WS,aP as XS,aQ as jS,at as rO}from"./index-
|
|
1
|
+
import{aw as Lx,af as po,ax as lo,r as Q,j as he,ay as VU,b as bg,t as WU,F as ni,a1 as XU,B as ts,az as jU,aA as qU,aB as YU,aC as ZU,aD as KU,aE as JU,aF as QU,aG as $U,aH as eO,aI as Qc,aJ as tO,aK as nO,aL as iO,aM as Iv,s as qa,aN as VS,aO as WS,aP as XS,aQ as jS,at as rO}from"./index-EQzdH3Y4.js";import{E as yl,Z as ti,N as nm,c as ah}from"./index-Bs7zcW7e.js";import"./envs-DFlyG_dH.js";/**
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2010-2025 Three.js Authors
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
@@ -41,7 +41,7 @@ import{aw as Lx,af as po,ax as lo,r as Q,j as he,ay as VU,b as bg,t as WU,F as n
|
|
|
41
41
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
42
42
|
|
|
43
43
|
}
|
|
44
|
-
`},r=new Ea(5,5,5),s=new ls({name:"CubemapFromEquirect",uniforms:uu(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:ki,blending:da});s.uniforms.tEquirect.value=t;const a=new pn(r,s),o=t.minFilter;return t.minFilter===Ms&&(t.minFilter=Pn),new v2(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,r=!0){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,r);e.setRenderTarget(s)}}class Zc extends Xt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const PL={type:"move"};class rm{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Zc,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Zc,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new J,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new J),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Zc,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new J,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new J),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,s=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const x of e.hand.values()){const _=t.getJointPose(x,n),g=this._getHandJoint(c,x);_!==null&&(g.matrix.fromArray(_.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.matrixWorldNeedsUpdate=!0,g.jointRadius=_.radius),g.visible=_!==null}const f=c.joints["index-finger-tip"],d=c.joints["thumb-tip"],p=f.position.distanceTo(d.position),m=.02,y=.005;c.inputState.pinching&&p>m+y?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&p<=m-y&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(PL)))}return o!==null&&(o.visible=r!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Zc;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class Ig{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new et(e),this.density=t}clone(){return new Ig(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class Pg{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new et(e),this.near=t,this.far=n}clone(){return new Pg(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class zg extends Xt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Ui,this.environmentIntensity=1,this.environmentRotation=new Ui,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class Fg{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=bf,this.updateRanges=[],this.version=0,this.uuid=vr()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=vr()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=vr()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Pi=new J;class Tl{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Pi.fromBufferAttribute(this,t),Pi.applyMatrix4(e),this.setXYZ(t,Pi.x,Pi.y,Pi.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Pi.fromBufferAttribute(this,t),Pi.applyNormalMatrix(e),this.setXYZ(t,Pi.x,Pi.y,Pi.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Pi.fromBufferAttribute(this,t),Pi.transformDirection(e),this.setXYZ(t,Pi.x,Pi.y,Pi.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=Fi(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Ut(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=Ut(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Ut(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Ut(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Ut(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Fi(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Fi(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Fi(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Fi(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=Ut(t,this.array),n=Ut(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Ut(t,this.array),n=Ut(n,this.array),r=Ut(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=Ut(t,this.array),n=Ut(n,this.array),r=Ut(r,this.array),s=Ut(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new en(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Tl(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class Jx extends Oi{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new et(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let Tc;const hh=new J,Ac=new J,Cc=new J,Rc=new Ge,fh=new Ge,_2=new bt,rp=new J,dh=new J,sp=new J,hE=new Ge,ny=new Ge,fE=new Ge;class x2 extends Xt{constructor(e=new Jx){if(super(),this.isSprite=!0,this.type="Sprite",Tc===void 0){Tc=new Ct;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new Fg(t,5);Tc.setIndex([0,1,2,0,2,3]),Tc.setAttribute("position",new Tl(n,3,0,!1)),Tc.setAttribute("uv",new Tl(n,2,3,!1))}this.geometry=Tc,this.material=e,this.center=new Ge(.5,.5),this.count=1}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Ac.setFromMatrixScale(this.matrixWorld),_2.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Cc.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Ac.multiplyScalar(-Cc.z);const n=this.material.rotation;let r,s;n!==0&&(s=Math.cos(n),r=Math.sin(n));const a=this.center;ap(rp.set(-.5,-.5,0),Cc,a,Ac,r,s),ap(dh.set(.5,-.5,0),Cc,a,Ac,r,s),ap(sp.set(.5,.5,0),Cc,a,Ac,r,s),hE.set(0,0),ny.set(1,0),fE.set(1,1);let o=e.ray.intersectTriangle(rp,dh,sp,!1,hh);if(o===null&&(ap(dh.set(-.5,.5,0),Cc,a,Ac,r,s),ny.set(0,1),o=e.ray.intersectTriangle(rp,sp,dh,!1,hh),o===null))return;const l=e.ray.origin.distanceTo(hh);l<e.near||l>e.far||t.push({distance:l,point:hh.clone(),uv:er.getInterpolation(hh,rp,dh,sp,hE,ny,fE,new Ge),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function ap(i,e,t,n,r,s){Rc.subVectors(i,t).addScalar(.5).multiply(n),r!==void 0?(fh.x=s*Rc.x-r*Rc.y,fh.y=r*Rc.x+s*Rc.y):fh.copy(Rc),i.copy(e),i.x+=fh.x,i.y+=fh.y,i.applyMatrix4(_2)}const op=new J,dE=new J;class b2 extends Xt{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let n=0,r=t.length;n<r;n++){const s=t[n];this.addLevel(s.object.clone(),s.distance,s.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,n=0){t=Math.abs(t);const r=this.levels;let s;for(s=0;s<r.length&&!(t<r[s].distance);s++);return r.splice(s,0,{distance:t,hysteresis:n,object:e}),this.add(e),this}removeLevel(e){const t=this.levels;for(let n=0;n<t.length;n++)if(t[n].distance===e){const r=t.splice(n,1);return this.remove(r[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let n,r;for(n=1,r=t.length;n<r;n++){let s=t[n].distance;if(t[n].object.visible&&(s-=s*t[n].hysteresis),e<s)break}return t[n-1].object}return null}raycast(e,t){if(this.levels.length>0){op.setFromMatrixPosition(this.matrixWorld);const r=e.ray.origin.distanceTo(op);this.getObjectForDistance(r).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){op.setFromMatrixPosition(e.matrixWorld),dE.setFromMatrixPosition(this.matrixWorld);const n=op.distanceTo(dE)/e.zoom;t[0].object.visible=!0;let r,s;for(r=1,s=t.length;r<s;r++){let a=t[r].distance;if(t[r].object.visible&&(a-=a*t[r].hysteresis),n>=a)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r<s;r++)t[r].object.visible=!1}}toJSON(e){const t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];const n=this.levels;for(let r=0,s=n.length;r<s;r++){const a=n[r];t.object.levels.push({object:a.object.uuid,distance:a.distance,hysteresis:a.hysteresis})}return t}}const pE=new J,mE=new kt,gE=new kt,zL=new J,vE=new bt,lp=new J,iy=new ri,yE=new bt,ry=new bu;class S2 extends pn{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=H_,this.bindMatrix=new bt,this.bindMatrixInverse=new bt,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Jn),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,lp),this.boundingBox.expandByPoint(lp)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new ri),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,lp),this.boundingSphere.expandByPoint(lp)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,r=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),iy.copy(this.boundingSphere),iy.applyMatrix4(r),e.ray.intersectsSphere(iy)!==!1&&(yE.copy(r).invert(),ry.copy(e.ray).applyMatrix4(yE),!(this.boundingBox!==null&&ry.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,ry)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new kt,t=this.geometry.attributes.skinWeight;for(let n=0,r=t.count;n<r;n++){e.fromBufferAttribute(t,n);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===H_?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===$A?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,r=this.geometry;mE.fromBufferAttribute(r.attributes.skinIndex,e),gE.fromBufferAttribute(r.attributes.skinWeight,e),pE.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){const a=gE.getComponent(s);if(a!==0){const o=mE.getComponent(s);vE.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(zL.copy(pE).applyMatrix4(vE),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class Qx extends Xt{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Ts extends An{constructor(e=null,t=1,n=1,r,s,a,o,l,c=yi,f=yi,d,p){super(null,a,o,l,c,f,r,s,d,p),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const _E=new bt,FL=new bt;class Bg{constructor(e=[],t=[]){this.uuid=vr(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,r=this.bones.length;n<r;n++)this.boneInverses.push(new bt)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new bt;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let s=0,a=e.length;s<a;s++){const o=e[s]?e[s].matrixWorld:FL;_E.multiplyMatrices(o,t[s]),_E.toArray(n,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new Bg(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new Ts(t,e,e,Di,tr);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,r=e.bones.length;n<r;n++){const s=e.bones[n];let a=t[s];a===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),a=new Qx),this.bones.push(a),this.boneInverses.push(new bt().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let r=0,s=t.length;r<s;r++){const a=t[r];e.bones.push(a.uuid);const o=n[r];e.boneInverses.push(o.toArray())}return e}}class Al extends en{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const Dc=new bt,xE=new bt,cp=[],bE=new Jn,BL=new bt,ph=new pn,mh=new ri;class E2 extends pn{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Al(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<n;r++)this.setMatrixAt(r,BL)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Jn),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Dc),bE.copy(e.boundingBox).applyMatrix4(Dc),this.boundingBox.union(bE)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new ri),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Dc),mh.copy(e.boundingSphere).applyMatrix4(Dc),this.boundingSphere.union(mh)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const n=t.morphTargetInfluences,r=this.morphTexture.source.data.data,s=n.length+1,a=e*s+1;for(let o=0;o<n.length;o++)n[o]=r[a+o]}raycast(e,t){const n=this.matrixWorld,r=this.count;if(ph.geometry=this.geometry,ph.material=this.material,ph.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),mh.copy(this.boundingSphere),mh.applyMatrix4(n),e.ray.intersectsSphere(mh)!==!1))for(let s=0;s<r;s++){this.getMatrixAt(s,Dc),xE.multiplyMatrices(n,Dc),ph.matrixWorld=xE,ph.raycast(e,cp);for(let a=0,o=cp.length;a<o;a++){const l=cp[a];l.instanceId=s,l.object=this,t.push(l)}cp.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Al(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const n=t.morphTargetInfluences,r=n.length+1;this.morphTexture===null&&(this.morphTexture=new Ts(new Float32Array(r*this.count),r,this.count,Cg,tr));const s=this.morphTexture.source.data.data;let a=0;for(let c=0;c<n.length;c++)a+=n[c];const o=this.geometry.morphTargetsRelative?1:1-a,l=r*e;s[l]=o,s.set(n,l+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const sy=new J,kL=new J,GL=new wt;class la{constructor(e=new J(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const r=sy.subVectors(n,t).cross(kL.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(sy),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(e.start).addScaledVector(n,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||GL.getNormalMatrix(e),r=this.coplanarPoint(sy).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Yo=new ri,up=new J;class Ll{constructor(e=new la,t=new la,n=new la,r=new la,s=new la,a=new la){this.planes=[e,t,n,r,s,a]}set(e,t,n,r,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(s),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Fr){const n=this.planes,r=e.elements,s=r[0],a=r[1],o=r[2],l=r[3],c=r[4],f=r[5],d=r[6],p=r[7],m=r[8],y=r[9],x=r[10],_=r[11],g=r[12],b=r[13],S=r[14],E=r[15];if(n[0].setComponents(l-s,p-c,_-m,E-g).normalize(),n[1].setComponents(l+s,p+c,_+m,E+g).normalize(),n[2].setComponents(l+a,p+f,_+y,E+b).normalize(),n[3].setComponents(l-a,p-f,_-y,E-b).normalize(),n[4].setComponents(l-o,p-d,_-x,E-S).normalize(),t===Fr)n[5].setComponents(l+o,p+d,_+x,E+S).normalize();else if(t===Sf)n[5].setComponents(o,d,x,S).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Yo.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Yo.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Yo)}intersectsSprite(e){return Yo.center.set(0,0,0),Yo.radius=.7071067811865476,Yo.applyMatrix4(e.matrixWorld),this.intersectsSphere(Yo)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const r=t[n];if(up.x=r.normal.x>0?e.max.x:e.min.x,up.y=r.normal.y>0?e.max.y:e.min.y,up.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(up)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}const vs=new bt,ys=new Ll;class kg{constructor(){this.coordinateSystem=Fr}intersectsObject(e,t){if(!t.isArrayCamera||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const r=t.cameras[n];if(vs.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),ys.setFromProjectionMatrix(vs,this.coordinateSystem),ys.intersectsObject(e))return!0}return!1}intersectsSprite(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const r=t.cameras[n];if(vs.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),ys.setFromProjectionMatrix(vs,this.coordinateSystem),ys.intersectsSprite(e))return!0}return!1}intersectsSphere(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const r=t.cameras[n];if(vs.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),ys.setFromProjectionMatrix(vs,this.coordinateSystem),ys.intersectsSphere(e))return!0}return!1}intersectsBox(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const r=t.cameras[n];if(vs.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),ys.setFromProjectionMatrix(vs,this.coordinateSystem),ys.intersectsBox(e))return!0}return!1}containsPoint(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const r=t.cameras[n];if(vs.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),ys.setFromProjectionMatrix(vs,this.coordinateSystem),ys.containsPoint(e))return!0}return!1}clone(){return new kg}}function ay(i,e){return i-e}function HL(i,e){return i.z-e.z}function VL(i,e){return e.z-i.z}class WL{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,n,r){const s=this.pool,a=this.list;this.index>=s.length&&s.push({start:-1,count:-1,z:-1,index:-1});const o=s[this.index];a.push(o),this.index++,o.start=e,o.count=t,o.z=n,o.index=r}reset(){this.list.length=0,this.index=0}}const Ki=new bt,XL=new et(1,1,1),SE=new Ll,jL=new kg,hp=new Jn,Zo=new ri,gh=new J,EE=new J,qL=new J,oy=new WL,Ci=new pn,fp=[];function YL(i,e,t=0){const n=e.itemSize;if(i.isInterleavedBufferAttribute||i.array.constructor!==e.array.constructor){const r=i.count;for(let s=0;s<r;s++)for(let a=0;a<n;a++)e.setComponent(s+t,a,i.getComponent(s,a))}else e.array.set(i.array,t*n);e.needsUpdate=!0}function Ko(i,e){if(i.constructor!==e.constructor){const t=Math.min(i.length,e.length);for(let n=0;n<t;n++)e[n]=i[n]}else{const t=Math.min(i.length,e.length);e.set(new i.constructor(i.buffer,0,t))}}class M2 extends pn{constructor(e,t,n=t*2,r){super(new Ct,r),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._instanceInfo=[],this._geometryInfo=[],this._availableInstanceIds=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._visibilityChanged=!0,this._geometryInitialized=!1,this._maxInstanceCount=e,this._maxVertexCount=t,this._maxIndexCount=n,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawInstances=null,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}get maxInstanceCount(){return this._maxInstanceCount}get instanceCount(){return this._instanceInfo.length-this._availableInstanceIds.length}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}_initMatricesTexture(){let e=Math.sqrt(this._maxInstanceCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4),n=new Ts(t,e,e,Di,tr);this._matricesTexture=n}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Uint32Array(e*e),n=new Ts(t,e,e,qf,_a);this._indirectTexture=n}_initColorsTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Float32Array(e*e*4).fill(1),n=new Ts(t,e,e,Di,tr);n.colorSpace=Gt.workingColorSpace,this._colorsTexture=n}_initializeGeometry(e){const t=this.geometry,n=this._maxVertexCount,r=this._maxIndexCount;if(this._geometryInitialized===!1){for(const s in e.attributes){const a=e.getAttribute(s),{array:o,itemSize:l,normalized:c}=a,f=new o.constructor(n*l),d=new en(f,l,c);t.setAttribute(s,d)}if(e.getIndex()!==null){const s=n>65535?new Uint32Array(r):new Uint16Array(r);t.setIndex(new en(s,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const n in t.attributes){if(!e.hasAttribute(n))throw new Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const r=e.getAttribute(n),s=t.getAttribute(n);if(r.itemSize!==s.itemSize||r.normalized!==s.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(e){const t=this._instanceInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){const t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Jn);const e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let n=0,r=t.length;n<r;n++){if(t[n].active===!1)continue;const s=t[n].geometryIndex;this.getMatrixAt(n,Ki),this.getBoundingBoxAt(s,hp).applyMatrix4(Ki),e.union(hp)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ri);const e=this.boundingSphere,t=this._instanceInfo;e.makeEmpty();for(let n=0,r=t.length;n<r;n++){if(t[n].active===!1)continue;const s=t[n].geometryIndex;this.getMatrixAt(n,Ki),this.getBoundingSphereAt(s,Zo).applyMatrix4(Ki),e.union(Zo)}}addInstance(e){if(this._instanceInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const n={visible:!0,active:!0,geometryIndex:e};let r=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(ay),r=this._availableInstanceIds.shift(),this._instanceInfo[r]=n):(r=this._instanceInfo.length,this._instanceInfo.push(n));const s=this._matricesTexture;Ki.identity().toArray(s.image.data,r*16),s.needsUpdate=!0;const a=this._colorsTexture;return a&&(XL.toArray(a.image.data,r*4),a.needsUpdate=!0),this._visibilityChanged=!0,r}addGeometry(e,t=-1,n=-1){this._initializeGeometry(e),this._validateGeometry(e);const r={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},s=this._geometryInfo;r.vertexStart=this._nextVertexStart,r.reservedVertexCount=t===-1?e.getAttribute("position").count:t;const a=e.getIndex();if(a!==null&&(r.indexStart=this._nextIndexStart,r.reservedIndexCount=n===-1?a.count:n),r.indexStart!==-1&&r.indexStart+r.reservedIndexCount>this._maxIndexCount||r.vertexStart+r.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let l;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(ay),l=this._availableGeometryIds.shift(),s[l]=r):(l=this._geometryCount,this._geometryCount++,s.push(r)),this.setGeometryAt(l,e),this._nextIndexStart=r.indexStart+r.reservedIndexCount,this._nextVertexStart=r.vertexStart+r.reservedVertexCount,l}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const n=this.geometry,r=n.getIndex()!==null,s=n.getIndex(),a=t.getIndex(),o=this._geometryInfo[e];if(r&&a.count>o.reservedIndexCount||t.attributes.position.count>o.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const l=o.vertexStart,c=o.reservedVertexCount;o.vertexCount=t.getAttribute("position").count;for(const f in n.attributes){const d=t.getAttribute(f),p=n.getAttribute(f);YL(d,p,l);const m=d.itemSize;for(let y=d.count,x=c;y<x;y++){const _=l+y;for(let g=0;g<m;g++)p.setComponent(_,g,0)}p.needsUpdate=!0,p.addUpdateRange(l*m,c*m)}if(r){const f=o.indexStart,d=o.reservedIndexCount;o.indexCount=t.getIndex().count;for(let p=0;p<a.count;p++)s.setX(f+p,l+a.getX(p));for(let p=a.count,m=d;p<m;p++)s.setX(f+p,l);s.needsUpdate=!0,s.addUpdateRange(f,o.reservedIndexCount)}return o.start=r?o.indexStart:o.vertexStart,o.count=r?o.indexCount:o.vertexCount,o.boundingBox=null,t.boundingBox!==null&&(o.boundingBox=t.boundingBox.clone()),o.boundingSphere=null,t.boundingSphere!==null&&(o.boundingSphere=t.boundingSphere.clone()),this._visibilityChanged=!0,e}deleteGeometry(e){const t=this._geometryInfo;if(e>=t.length||t[e].active===!1)return this;const n=this._instanceInfo;for(let r=0,s=n.length;r<s;r++)n[r].active&&n[r].geometryIndex===e&&this.deleteInstance(r);return t[e].active=!1,this._availableGeometryIds.push(e),this._visibilityChanged=!0,this}deleteInstance(e){return this.validateInstanceId(e),this._instanceInfo[e].active=!1,this._availableInstanceIds.push(e),this._visibilityChanged=!0,this}optimize(){let e=0,t=0;const n=this._geometryInfo,r=n.map((a,o)=>o).sort((a,o)=>n[a].vertexStart-n[o].vertexStart),s=this.geometry;for(let a=0,o=n.length;a<o;a++){const l=r[a],c=n[l];if(c.active!==!1){if(s.index!==null){if(c.indexStart!==t){const{indexStart:f,vertexStart:d,reservedIndexCount:p}=c,m=s.index,y=m.array,x=e-d;for(let _=f;_<f+p;_++)y[_]=y[_]+x;m.array.copyWithin(t,f,f+p),m.addUpdateRange(t,p),c.indexStart=t}t+=c.reservedIndexCount}if(c.vertexStart!==e){const{vertexStart:f,reservedVertexCount:d}=c,p=s.attributes;for(const m in p){const y=p[m],{array:x,itemSize:_}=y;x.copyWithin(e*_,f*_,(f+d)*_),y.addUpdateRange(e*_,d*_)}c.vertexStart=e}e+=c.reservedVertexCount,c.start=s.index?c.indexStart:c.vertexStart,this._nextIndexStart=s.index?c.indexStart+c.reservedIndexCount:0,this._nextVertexStart=c.vertexStart+c.reservedVertexCount}}return this}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;const n=this.geometry,r=this._geometryInfo[e];if(r.boundingBox===null){const s=new Jn,a=n.index,o=n.attributes.position;for(let l=r.start,c=r.start+r.count;l<c;l++){let f=l;a&&(f=a.getX(f)),s.expandByPoint(gh.fromBufferAttribute(o,f))}r.boundingBox=s}return t.copy(r.boundingBox),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;const n=this.geometry,r=this._geometryInfo[e];if(r.boundingSphere===null){const s=new ri;this.getBoundingBoxAt(e,hp),hp.getCenter(s.center);const a=n.index,o=n.attributes.position;let l=0;for(let c=r.start,f=r.start+r.count;c<f;c++){let d=c;a&&(d=a.getX(d)),gh.fromBufferAttribute(o,d),l=Math.max(l,s.center.distanceToSquared(gh))}s.radius=Math.sqrt(l),r.boundingSphere=s}return t.copy(r.boundingSphere),t}setMatrixAt(e,t){this.validateInstanceId(e);const n=this._matricesTexture,r=this._matricesTexture.image.data;return t.toArray(r,e*16),n.needsUpdate=!0,this}getMatrixAt(e,t){return this.validateInstanceId(e),t.fromArray(this._matricesTexture.image.data,e*16)}setColorAt(e,t){return this.validateInstanceId(e),this._colorsTexture===null&&this._initColorsTexture(),t.toArray(this._colorsTexture.image.data,e*4),this._colorsTexture.needsUpdate=!0,this}getColorAt(e,t){return this.validateInstanceId(e),t.fromArray(this._colorsTexture.image.data,e*4)}setVisibleAt(e,t){return this.validateInstanceId(e),this._instanceInfo[e].visible===t?this:(this._instanceInfo[e].visible=t,this._visibilityChanged=!0,this)}getVisibleAt(e){return this.validateInstanceId(e),this._instanceInfo[e].visible}setGeometryIdAt(e,t){return this.validateInstanceId(e),this.validateGeometryId(t),this._instanceInfo[e].geometryIndex=t,this}getGeometryIdAt(e){return this.validateInstanceId(e),this._instanceInfo[e].geometryIndex}getGeometryRangeAt(e,t={}){this.validateGeometryId(e);const n=this._geometryInfo[e];return t.vertexStart=n.vertexStart,t.vertexCount=n.vertexCount,t.reservedVertexCount=n.reservedVertexCount,t.indexStart=n.indexStart,t.indexCount=n.indexCount,t.reservedIndexCount=n.reservedIndexCount,t.start=n.start,t.count=n.count,t}setInstanceCount(e){const t=this._availableInstanceIds,n=this._instanceInfo;for(t.sort(ay);t[t.length-1]===n.length;)n.pop(),t.pop();if(e<n.length)throw new Error(`BatchedMesh: Instance ids outside the range ${e} are being used. Cannot shrink instance count.`);const r=new Int32Array(e),s=new Int32Array(e);Ko(this._multiDrawCounts,r),Ko(this._multiDrawStarts,s),this._multiDrawCounts=r,this._multiDrawStarts=s,this._maxInstanceCount=e;const a=this._indirectTexture,o=this._matricesTexture,l=this._colorsTexture;a.dispose(),this._initIndirectTexture(),Ko(a.image.data,this._indirectTexture.image.data),o.dispose(),this._initMatricesTexture(),Ko(o.image.data,this._matricesTexture.image.data),l&&(l.dispose(),this._initColorsTexture(),Ko(l.image.data,this._colorsTexture.image.data))}setGeometrySize(e,t){const n=[...this._geometryInfo].filter(o=>o.active);if(Math.max(...n.map(o=>o.vertexStart+o.reservedVertexCount))>e)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map(l=>l.indexStart+l.reservedIndexCount))>t)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);const s=this.geometry;s.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Ct,this._initializeGeometry(s));const a=this.geometry;s.index&&Ko(s.index.array,a.index.array);for(const o in s.attributes)Ko(s.attributes[o].array,a.attributes[o].array)}raycast(e,t){const n=this._instanceInfo,r=this._geometryInfo,s=this.matrixWorld,a=this.geometry;Ci.material=this.material,Ci.geometry.index=a.index,Ci.geometry.attributes=a.attributes,Ci.geometry.boundingBox===null&&(Ci.geometry.boundingBox=new Jn),Ci.geometry.boundingSphere===null&&(Ci.geometry.boundingSphere=new ri);for(let o=0,l=n.length;o<l;o++){if(!n[o].visible||!n[o].active)continue;const c=n[o].geometryIndex,f=r[c];Ci.geometry.setDrawRange(f.start,f.count),this.getMatrixAt(o,Ci.matrixWorld).premultiply(s),this.getBoundingBoxAt(c,Ci.geometry.boundingBox),this.getBoundingSphereAt(c,Ci.geometry.boundingSphere),Ci.raycast(e,fp);for(let d=0,p=fp.length;d<p;d++){const m=fp[d];m.object=this,m.batchId=o,t.push(m)}fp.length=0}Ci.material=null,Ci.geometry.index=null,Ci.geometry.attributes={},Ci.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._geometryInfo=e._geometryInfo.map(t=>({...t,boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(t=>({...t})),this._availableInstanceIds=e._availableInstanceIds.slice(),this._availableGeometryIds=e._availableGeometryIds.slice(),this._nextIndexStart=e._nextIndexStart,this._nextVertexStart=e._nextVertexStart,this._geometryCount=e._geometryCount,this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._indirectTexture=e._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(e,t,n,r,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const a=r.getIndex(),o=a===null?1:a.array.BYTES_PER_ELEMENT,l=this._instanceInfo,c=this._multiDrawStarts,f=this._multiDrawCounts,d=this._geometryInfo,p=this.perObjectFrustumCulled,m=this._indirectTexture,y=m.image.data,x=n.isArrayCamera?jL:SE;p&&!n.isArrayCamera&&(Ki.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),SE.setFromProjectionMatrix(Ki,e.coordinateSystem));let _=0;if(this.sortObjects){Ki.copy(this.matrixWorld).invert(),gh.setFromMatrixPosition(n.matrixWorld).applyMatrix4(Ki),EE.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(Ki);for(let S=0,E=l.length;S<E;S++)if(l[S].visible&&l[S].active){const w=l[S].geometryIndex;this.getMatrixAt(S,Ki),this.getBoundingSphereAt(w,Zo).applyMatrix4(Ki);let T=!1;if(p&&(T=!x.intersectsSphere(Zo,n)),!T){const R=d[w],U=qL.subVectors(Zo.center,gh).dot(EE);oy.push(R.start,R.count,U,S)}}const g=oy.list,b=this.customSort;b===null?g.sort(s.transparent?VL:HL):b.call(this,g,n);for(let S=0,E=g.length;S<E;S++){const w=g[S];c[_]=w.start*o,f[_]=w.count,y[_]=w.index,_++}oy.reset()}else for(let g=0,b=l.length;g<b;g++)if(l[g].visible&&l[g].active){const S=l[g].geometryIndex;let E=!1;if(p&&(this.getMatrixAt(g,Ki),this.getBoundingSphereAt(S,Zo).applyMatrix4(Ki),E=!x.intersectsSphere(Zo,n)),!E){const w=d[S];c[_]=w.start*o,f[_]=w.count,y[_]=g,_++}}m.needsUpdate=!0,this._multiDrawCount=_,this._visibilityChanged=!1}onBeforeShadow(e,t,n,r,s,a){this.onBeforeRender(e,null,r,s,a)}}class Gi extends Oi{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new et(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const Qm=new J,$m=new J,ME=new bt,vh=new bu,dp=new ri,ly=new J,wE=new J;let fo=class extends Xt{constructor(e=new Ct,t=new Gi){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let r=1,s=t.count;r<s;r++)Qm.fromBufferAttribute(t,r-1),$m.fromBufferAttribute(t,r),n[r]=n[r-1],n[r]+=Qm.distanceTo($m);e.setAttribute("lineDistance",new dt(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),dp.copy(n.boundingSphere),dp.applyMatrix4(r),dp.radius+=s,e.ray.intersectsSphere(dp)===!1)return;ME.copy(r).invert(),vh.copy(e.ray).applyMatrix4(ME);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,f=n.index,p=n.attributes.position;if(f!==null){const m=Math.max(0,a.start),y=Math.min(f.count,a.start+a.count);for(let x=m,_=y-1;x<_;x+=c){const g=f.getX(x),b=f.getX(x+1),S=pp(this,e,vh,l,g,b,x);S&&t.push(S)}if(this.isLineLoop){const x=f.getX(y-1),_=f.getX(m),g=pp(this,e,vh,l,x,_,y-1);g&&t.push(g)}}else{const m=Math.max(0,a.start),y=Math.min(p.count,a.start+a.count);for(let x=m,_=y-1;x<_;x+=c){const g=pp(this,e,vh,l,x,x+1,x);g&&t.push(g)}if(this.isLineLoop){const x=pp(this,e,vh,l,y-1,m,y-1);x&&t.push(x)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){const o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}};function pp(i,e,t,n,r,s,a){const o=i.geometry.attributes.position;if(Qm.fromBufferAttribute(o,r),$m.fromBufferAttribute(o,s),t.distanceSqToSegment(Qm,$m,ly,wE)>n)return;ly.applyMatrix4(i.matrixWorld);const c=e.ray.origin.distanceTo(ly);if(!(c<e.near||c>e.far))return{distance:c,point:wE.clone().applyMatrix4(i.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:i}}const TE=new J,AE=new J;class Ds extends fo{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let r=0,s=t.count;r<s;r+=2)TE.fromBufferAttribute(t,r),AE.fromBufferAttribute(t,r+1),n[r]=r===0?0:n[r-1],n[r+1]=n[r]+TE.distanceTo(AE);e.setAttribute("lineDistance",new dt(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class w2 extends fo{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class $x extends Oi{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new et(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const CE=new bt,X_=new bu,mp=new ri,gp=new J;class T2 extends Xt{constructor(e=new Ct,t=new $x){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,s=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),mp.copy(n.boundingSphere),mp.applyMatrix4(r),mp.radius+=s,e.ray.intersectsSphere(mp)===!1)return;CE.copy(r).invert(),X_.copy(e.ray).applyMatrix4(CE);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=n.index,d=n.attributes.position;if(c!==null){const p=Math.max(0,a.start),m=Math.min(c.count,a.start+a.count);for(let y=p,x=m;y<x;y++){const _=c.getX(y);gp.fromBufferAttribute(d,_),RE(gp,_,l,r,e,t,this)}}else{const p=Math.max(0,a.start),m=Math.min(d.count,a.start+a.count);for(let y=p,x=m;y<x;y++)gp.fromBufferAttribute(d,y),RE(gp,y,l,r,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){const o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function RE(i,e,t,n,r,s,a){const o=X_.distanceSqToPoint(i);if(o<t){const l=new J;X_.closestPointToPoint(i,l),l.applyMatrix4(n);const c=r.ray.origin.distanceTo(l);if(c<r.near||c>r.far)return;s.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class A2 extends An{constructor(e,t,n,r,s=Pn,a=Pn,o,l,c){super(e,t,n,r,s,a,o,l,c),this.isVideoTexture=!0,this.generateMipmaps=!1;const f=this;function d(){f.needsUpdate=!0,e.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(d)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class ZL extends A2{constructor(e,t,n,r,s,a,o,l){super({},e,t,n,r,s,a,o,l),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}}class KL extends An{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=yi,this.minFilter=yi,this.generateMipmaps=!1,this.needsUpdate=!0}}class Gg extends An{constructor(e,t,n,r,s,a,o,l,c,f,d,p){super(null,a,o,l,c,f,r,s,d,p),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class JL extends Gg{constructor(e,t,n,r,s,a){super(e,t,n,s,a),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=zr,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class QL extends Gg{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,ya),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class $L extends An{constructor(e,t,n,r,s,a,o,l,c){super(e,t,n,r,s,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class e1 extends An{constructor(e,t,n=_a,r,s,a,o=yi,l=yi,c,f=au,d=1){if(f!==au&&f!==ou)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const p={width:e,height:t,depth:d};super(p,r,s,a,o,l,f,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new so(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class Hg extends Ct{constructor(e=1,t=1,n=4,r=8,s=1){super(),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:n,radialSegments:r,heightSegments:s},t=Math.max(0,t),n=Math.max(1,Math.floor(n)),r=Math.max(3,Math.floor(r)),s=Math.max(1,Math.floor(s));const a=[],o=[],l=[],c=[],f=t/2,d=Math.PI/2*e,p=t,m=2*d+p,y=n*2+s,x=r+1,_=new J,g=new J;for(let b=0;b<=y;b++){let S=0,E=0,w=0,T=0;if(b<=n){const D=b/n,C=D*Math.PI/2;E=-f-e*Math.cos(C),w=e*Math.sin(C),T=-e*Math.cos(C),S=D*d}else if(b<=n+s){const D=(b-n)/s;E=-f+D*t,w=e,T=0,S=d+D*p}else{const D=(b-n-s)/n,C=D*Math.PI/2;E=f+e*Math.sin(C),w=e*Math.cos(C),T=e*Math.sin(C),S=d+p+D*d}const R=Math.max(0,Math.min(1,S/m));let U=0;b===0?U=.5/r:b===y&&(U=-.5/r);for(let D=0;D<=r;D++){const C=D/r,P=C*Math.PI*2,I=Math.sin(P),O=Math.cos(P);g.x=-w*O,g.y=E,g.z=w*I,o.push(g.x,g.y,g.z),_.set(-w*O,T,w*I),_.normalize(),l.push(_.x,_.y,_.z),c.push(C+U,R)}if(b>0){const D=(b-1)*x;for(let C=0;C<r;C++){const P=D+C,I=D+C+1,O=b*x+C,G=b*x+C+1;a.push(P,I,O),a.push(I,G,O)}}}this.setIndex(a),this.setAttribute("position",new dt(o,3)),this.setAttribute("normal",new dt(l,3)),this.setAttribute("uv",new dt(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Hg(e.radius,e.height,e.capSegments,e.radialSegments,e.heightSegments)}}class Vg extends Ct{constructor(e=1,t=32,n=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:r},t=Math.max(3,t);const s=[],a=[],o=[],l=[],c=new J,f=new Ge;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let d=0,p=3;d<=t;d++,p+=3){const m=n+d/t*r;c.x=e*Math.cos(m),c.y=e*Math.sin(m),a.push(c.x,c.y,c.z),o.push(0,0,1),f.x=(a[p]/e+1)/2,f.y=(a[p+1]/e+1)/2,l.push(f.x,f.y)}for(let d=1;d<=t;d++)s.push(d,d+1,0);this.setIndex(s),this.setAttribute("position",new dt(a,3)),this.setAttribute("normal",new dt(o,3)),this.setAttribute("uv",new dt(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Vg(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class Su extends Ct{constructor(e=1,t=1,n=1,r=32,s=1,a=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:s,openEnded:a,thetaStart:o,thetaLength:l};const c=this;r=Math.floor(r),s=Math.floor(s);const f=[],d=[],p=[],m=[];let y=0;const x=[],_=n/2;let g=0;b(),a===!1&&(e>0&&S(!0),t>0&&S(!1)),this.setIndex(f),this.setAttribute("position",new dt(d,3)),this.setAttribute("normal",new dt(p,3)),this.setAttribute("uv",new dt(m,2));function b(){const E=new J,w=new J;let T=0;const R=(t-e)/n;for(let U=0;U<=s;U++){const D=[],C=U/s,P=C*(t-e)+e;for(let I=0;I<=r;I++){const O=I/r,G=O*l+o,Z=Math.sin(G),z=Math.cos(G);w.x=P*Z,w.y=-C*n+_,w.z=P*z,d.push(w.x,w.y,w.z),E.set(Z,R,z).normalize(),p.push(E.x,E.y,E.z),m.push(O,1-C),D.push(y++)}x.push(D)}for(let U=0;U<r;U++)for(let D=0;D<s;D++){const C=x[D][U],P=x[D+1][U],I=x[D+1][U+1],O=x[D][U+1];(e>0||D!==0)&&(f.push(C,P,O),T+=3),(t>0||D!==s-1)&&(f.push(P,I,O),T+=3)}c.addGroup(g,T,0),g+=T}function S(E){const w=y,T=new Ge,R=new J;let U=0;const D=E===!0?e:t,C=E===!0?1:-1;for(let I=1;I<=r;I++)d.push(0,_*C,0),p.push(0,C,0),m.push(.5,.5),y++;const P=y;for(let I=0;I<=r;I++){const G=I/r*l+o,Z=Math.cos(G),z=Math.sin(G);R.x=D*z,R.y=_*C,R.z=D*Z,d.push(R.x,R.y,R.z),p.push(0,C,0),T.x=Z*.5+.5,T.y=z*.5*C+.5,m.push(T.x,T.y),y++}for(let I=0;I<r;I++){const O=w+I,G=P+I;E===!0?f.push(G,G+1,O):f.push(G+1,G,O),U+=3}c.addGroup(g,U,E===!0?1:2),g+=U}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Su(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Zf extends Su{constructor(e=1,t=1,n=32,r=1,s=!1,a=0,o=Math.PI*2){super(0,e,t,n,r,s,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:s,thetaStart:a,thetaLength:o}}static fromJSON(e){return new Zf(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class go extends Ct{constructor(e=[],t=[],n=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:r};const s=[],a=[];o(r),c(n),f(),this.setAttribute("position",new dt(s,3)),this.setAttribute("normal",new dt(s.slice(),3)),this.setAttribute("uv",new dt(a,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function o(b){const S=new J,E=new J,w=new J;for(let T=0;T<t.length;T+=3)m(t[T+0],S),m(t[T+1],E),m(t[T+2],w),l(S,E,w,b)}function l(b,S,E,w){const T=w+1,R=[];for(let U=0;U<=T;U++){R[U]=[];const D=b.clone().lerp(E,U/T),C=S.clone().lerp(E,U/T),P=T-U;for(let I=0;I<=P;I++)I===0&&U===T?R[U][I]=D:R[U][I]=D.clone().lerp(C,I/P)}for(let U=0;U<T;U++)for(let D=0;D<2*(T-U)-1;D++){const C=Math.floor(D/2);D%2===0?(p(R[U][C+1]),p(R[U+1][C]),p(R[U][C])):(p(R[U][C+1]),p(R[U+1][C+1]),p(R[U+1][C]))}}function c(b){const S=new J;for(let E=0;E<s.length;E+=3)S.x=s[E+0],S.y=s[E+1],S.z=s[E+2],S.normalize().multiplyScalar(b),s[E+0]=S.x,s[E+1]=S.y,s[E+2]=S.z}function f(){const b=new J;for(let S=0;S<s.length;S+=3){b.x=s[S+0],b.y=s[S+1],b.z=s[S+2];const E=_(b)/2/Math.PI+.5,w=g(b)/Math.PI+.5;a.push(E,1-w)}y(),d()}function d(){for(let b=0;b<a.length;b+=6){const S=a[b+0],E=a[b+2],w=a[b+4],T=Math.max(S,E,w),R=Math.min(S,E,w);T>.9&&R<.1&&(S<.2&&(a[b+0]+=1),E<.2&&(a[b+2]+=1),w<.2&&(a[b+4]+=1))}}function p(b){s.push(b.x,b.y,b.z)}function m(b,S){const E=b*3;S.x=e[E+0],S.y=e[E+1],S.z=e[E+2]}function y(){const b=new J,S=new J,E=new J,w=new J,T=new Ge,R=new Ge,U=new Ge;for(let D=0,C=0;D<s.length;D+=9,C+=6){b.set(s[D+0],s[D+1],s[D+2]),S.set(s[D+3],s[D+4],s[D+5]),E.set(s[D+6],s[D+7],s[D+8]),T.set(a[C+0],a[C+1]),R.set(a[C+2],a[C+3]),U.set(a[C+4],a[C+5]),w.copy(b).add(S).add(E).divideScalar(3);const P=_(w);x(T,C+0,b,P),x(R,C+2,S,P),x(U,C+4,E,P)}}function x(b,S,E,w){w<0&&b.x===1&&(a[S]=b.x-1),E.x===0&&E.z===0&&(a[S]=w/2/Math.PI+.5)}function _(b){return Math.atan2(b.z,-b.x)}function g(b){return Math.atan2(-b.y,Math.sqrt(b.x*b.x+b.z*b.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new go(e.vertices,e.indices,e.radius,e.details)}}class Wg extends go{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,r=1/n,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,a,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Wg(e.radius,e.detail)}}const vp=new J,yp=new J,cy=new J,_p=new er;class C2 extends Ct{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const r=Math.pow(10,4),s=Math.cos(xl*t),a=e.getIndex(),o=e.getAttribute("position"),l=a?a.count:o.count,c=[0,0,0],f=["a","b","c"],d=new Array(3),p={},m=[];for(let y=0;y<l;y+=3){a?(c[0]=a.getX(y),c[1]=a.getX(y+1),c[2]=a.getX(y+2)):(c[0]=y,c[1]=y+1,c[2]=y+2);const{a:x,b:_,c:g}=_p;if(x.fromBufferAttribute(o,c[0]),_.fromBufferAttribute(o,c[1]),g.fromBufferAttribute(o,c[2]),_p.getNormal(cy),d[0]=`${Math.round(x.x*r)},${Math.round(x.y*r)},${Math.round(x.z*r)}`,d[1]=`${Math.round(_.x*r)},${Math.round(_.y*r)},${Math.round(_.z*r)}`,d[2]=`${Math.round(g.x*r)},${Math.round(g.y*r)},${Math.round(g.z*r)}`,!(d[0]===d[1]||d[1]===d[2]||d[2]===d[0]))for(let b=0;b<3;b++){const S=(b+1)%3,E=d[b],w=d[S],T=_p[f[b]],R=_p[f[S]],U=`${E}_${w}`,D=`${w}_${E}`;D in p&&p[D]?(cy.dot(p[D].normal)<=s&&(m.push(T.x,T.y,T.z),m.push(R.x,R.y,R.z)),p[D]=null):U in p||(p[U]={index0:c[b],index1:c[S],normal:cy.clone()})}}for(const y in p)if(p[y]){const{index0:x,index1:_}=p[y];vp.fromBufferAttribute(o,x),yp.fromBufferAttribute(o,_),m.push(vp.x,vp.y,vp.z),m.push(yp.x,yp.y,yp.z)}this.setAttribute("position",new dt(m,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class us{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){console.warn("THREE.Curve: .getPoint() not implemented.")}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,r=this.getPoint(0),s=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),s+=n.distanceTo(r),t.push(s),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){const n=this.getLengths();let r=0;const s=n.length;let a;t?a=t:a=e*n[s-1];let o=0,l=s-1,c;for(;o<=l;)if(r=Math.floor(o+(l-o)/2),c=n[r]-a,c<0)o=r+1;else if(c>0)l=r-1;else{l=r;break}if(r=l,n[r]===a)return r/(s-1);const f=n[r],p=n[r+1]-f,m=(a-f)/p;return(r+m)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);const a=this.getPoint(r),o=this.getPoint(s),l=t||(a.isVector2?new Ge:new J);return l.copy(o).sub(a).normalize(),l}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){const n=new J,r=[],s=[],a=[],o=new J,l=new bt;for(let m=0;m<=e;m++){const y=m/e;r[m]=this.getTangentAt(y,new J)}s[0]=new J,a[0]=new J;let c=Number.MAX_VALUE;const f=Math.abs(r[0].x),d=Math.abs(r[0].y),p=Math.abs(r[0].z);f<=c&&(c=f,n.set(1,0,0)),d<=c&&(c=d,n.set(0,1,0)),p<=c&&n.set(0,0,1),o.crossVectors(r[0],n).normalize(),s[0].crossVectors(r[0],o),a[0].crossVectors(r[0],s[0]);for(let m=1;m<=e;m++){if(s[m]=s[m-1].clone(),a[m]=a[m-1].clone(),o.crossVectors(r[m-1],r[m]),o.length()>Number.EPSILON){o.normalize();const y=Math.acos(Tt(r[m-1].dot(r[m]),-1,1));s[m].applyMatrix4(l.makeRotationAxis(o,y))}a[m].crossVectors(r[m],s[m])}if(t===!0){let m=Math.acos(Tt(s[0].dot(s[e]),-1,1));m/=e,r[0].dot(o.crossVectors(s[0],s[e]))>0&&(m=-m);for(let y=1;y<=e;y++)s[y].applyMatrix4(l.makeRotationAxis(r[y],m*y)),a[y].crossVectors(r[y],s[y])}return{tangents:r,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Xg extends us{constructor(e=0,t=0,n=1,r=1,s=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t=new Ge){const n=t,r=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const a=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(a?s=0:s=r),this.aClockwise===!0&&!a&&(s===r?s=-r:s=s-r);const o=this.aStartAngle+e*s;let l=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){const f=Math.cos(this.aRotation),d=Math.sin(this.aRotation),p=l-this.aX,m=c-this.aY;l=p*f-m*d+this.aX,c=p*d+m*f+this.aY}return n.set(l,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class R2 extends Xg{constructor(e,t,n,r,s,a){super(e,t,n,n,r,s,a),this.isArcCurve=!0,this.type="ArcCurve"}}function t1(){let i=0,e=0,t=0,n=0;function r(s,a,o,l){i=s,e=o,t=-3*s+3*a-2*o-l,n=2*s-2*a+o+l}return{initCatmullRom:function(s,a,o,l,c){r(a,o,c*(o-s),c*(l-a))},initNonuniformCatmullRom:function(s,a,o,l,c,f,d){let p=(a-s)/c-(o-s)/(c+f)+(o-a)/f,m=(o-a)/f-(l-a)/(f+d)+(l-o)/d;p*=f,m*=f,r(a,o,p,m)},calc:function(s){const a=s*s,o=a*s;return i+e*s+t*a+n*o}}}const xp=new J,uy=new t1,hy=new t1,fy=new t1;class D2 extends us{constructor(e=[],t=!1,n="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=r}getPoint(e,t=new J){const n=t,r=this.points,s=r.length,a=(s-(this.closed?0:1))*e;let o=Math.floor(a),l=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/s)+1)*s:l===0&&o===s-1&&(o=s-2,l=1);let c,f;this.closed||o>0?c=r[(o-1)%s]:(xp.subVectors(r[0],r[1]).add(r[0]),c=xp);const d=r[o%s],p=r[(o+1)%s];if(this.closed||o+2<s?f=r[(o+2)%s]:(xp.subVectors(r[s-1],r[s-2]).add(r[s-1]),f=xp),this.curveType==="centripetal"||this.curveType==="chordal"){const m=this.curveType==="chordal"?.5:.25;let y=Math.pow(c.distanceToSquared(d),m),x=Math.pow(d.distanceToSquared(p),m),_=Math.pow(p.distanceToSquared(f),m);x<1e-4&&(x=1),y<1e-4&&(y=x),_<1e-4&&(_=x),uy.initNonuniformCatmullRom(c.x,d.x,p.x,f.x,y,x,_),hy.initNonuniformCatmullRom(c.y,d.y,p.y,f.y,y,x,_),fy.initNonuniformCatmullRom(c.z,d.z,p.z,f.z,y,x,_)}else this.curveType==="catmullrom"&&(uy.initCatmullRom(c.x,d.x,p.x,f.x,this.tension),hy.initCatmullRom(c.y,d.y,p.y,f.y,this.tension),fy.initCatmullRom(c.z,d.z,p.z,f.z,this.tension));return n.set(uy.calc(l),hy.calc(l),fy.calc(l)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const r=e.points[t];this.points.push(new J().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function DE(i,e,t,n,r){const s=(n-e)*.5,a=(r-t)*.5,o=i*i,l=i*o;return(2*t-2*n+s+a)*l+(-3*t+3*n-2*s-a)*o+s*i+t}function eN(i,e){const t=1-i;return t*t*e}function tN(i,e){return 2*(1-i)*i*e}function nN(i,e){return i*i*e}function sf(i,e,t,n){return eN(i,e)+tN(i,t)+nN(i,n)}function iN(i,e){const t=1-i;return t*t*t*e}function rN(i,e){const t=1-i;return 3*t*t*i*e}function sN(i,e){return 3*(1-i)*i*i*e}function aN(i,e){return i*i*i*e}function af(i,e,t,n,r){return iN(i,e)+rN(i,t)+sN(i,n)+aN(i,r)}class n1 extends us{constructor(e=new Ge,t=new Ge,n=new Ge,r=new Ge){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new Ge){const n=t,r=this.v0,s=this.v1,a=this.v2,o=this.v3;return n.set(af(e,r.x,s.x,a.x,o.x),af(e,r.y,s.y,a.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class U2 extends us{constructor(e=new J,t=new J,n=new J,r=new J){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new J){const n=t,r=this.v0,s=this.v1,a=this.v2,o=this.v3;return n.set(af(e,r.x,s.x,a.x,o.x),af(e,r.y,s.y,a.y,o.y),af(e,r.z,s.z,a.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class i1 extends us{constructor(e=new Ge,t=new Ge){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new Ge){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new Ge){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class r1 extends us{constructor(e=new J,t=new J){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new J){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new J){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class s1 extends us{constructor(e=new Ge,t=new Ge,n=new Ge){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new Ge){const n=t,r=this.v0,s=this.v1,a=this.v2;return n.set(sf(e,r.x,s.x,a.x),sf(e,r.y,s.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class jg extends us{constructor(e=new J,t=new J,n=new J){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new J){const n=t,r=this.v0,s=this.v1,a=this.v2;return n.set(sf(e,r.x,s.x,a.x),sf(e,r.y,s.y,a.y),sf(e,r.z,s.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class a1 extends us{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new Ge){const n=t,r=this.points,s=(r.length-1)*e,a=Math.floor(s),o=s-a,l=r[a===0?a:a-1],c=r[a],f=r[a>r.length-2?r.length-1:a+1],d=r[a>r.length-3?r.length-1:a+2];return n.set(DE(o,l.x,c.x,f.x,d.x),DE(o,l.y,c.y,f.y,d.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const r=e.points[t];this.points.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const r=e.points[t];this.points.push(new Ge().fromArray(r))}return this}}var eg=Object.freeze({__proto__:null,ArcCurve:R2,CatmullRomCurve3:D2,CubicBezierCurve:n1,CubicBezierCurve3:U2,EllipseCurve:Xg,LineCurve:i1,LineCurve3:r1,QuadraticBezierCurve:s1,QuadraticBezierCurve3:jg,SplineCurve:a1});class O2 extends us{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){const n=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new eg[n](t,e))}return this}getPoint(e,t){const n=e*this.getLength(),r=this.getCurveLengths();let s=0;for(;s<r.length;){if(r[s]>=n){const a=r[s]-n,o=this.curves[s],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,r=this.curves.length;n<r;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let n;for(let r=0,s=this.curves;r<s.length;r++){const a=s[r],o=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,l=a.getPoints(o);for(let c=0;c<l.length;c++){const f=l[c];n&&n.equals(f)||(t.push(f),n=f)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){const r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const r=e.curves[t];this.curves.push(new eg[r.type]().fromJSON(r))}return this}}class tg extends O2{constructor(e){super(),this.type="Path",this.currentPoint=new Ge,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const n=new i1(this.currentPoint.clone(),new Ge(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,r){const s=new s1(this.currentPoint.clone(),new Ge(e,t),new Ge(n,r));return this.curves.push(s),this.currentPoint.set(n,r),this}bezierCurveTo(e,t,n,r,s,a){const o=new n1(this.currentPoint.clone(),new Ge(e,t),new Ge(n,r),new Ge(s,a));return this.curves.push(o),this.currentPoint.set(s,a),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new a1(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,r,s,a){const o=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+o,t+l,n,r,s,a),this}absarc(e,t,n,r,s,a){return this.absellipse(e,t,n,n,r,s,a),this}ellipse(e,t,n,r,s,a,o,l){const c=this.currentPoint.x,f=this.currentPoint.y;return this.absellipse(e+c,t+f,n,r,s,a,o,l),this}absellipse(e,t,n,r,s,a,o,l){const c=new Xg(e,t,n,r,s,a,o,l);if(this.curves.length>0){const d=c.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(c);const f=c.getPoint(1);return this.currentPoint.copy(f),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class bl extends tg{constructor(e){super(e),this.uuid=vr(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,r=this.holes.length;n<r;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){const r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const r=e.holes[t];this.holes.push(new tg().fromJSON(r))}return this}}function oN(i,e,t=2){const n=e&&e.length,r=n?e[0]*t:i.length;let s=L2(i,0,r,t,!0);const a=[];if(!s||s.next===s.prev)return a;let o,l,c;if(n&&(s=fN(i,e,s,t)),i.length>80*t){o=1/0,l=1/0;let f=-1/0,d=-1/0;for(let p=t;p<r;p+=t){const m=i[p],y=i[p+1];m<o&&(o=m),y<l&&(l=y),m>f&&(f=m),y>d&&(d=y)}c=Math.max(f-o,d-l),c=c!==0?32767/c:0}return Mf(s,a,t,o,l,c,0),a}function L2(i,e,t,n,r){let s;if(r===EN(i,e,t,n)>0)for(let a=e;a<t;a+=n)s=UE(a/n|0,i[a],i[a+1],s);else for(let a=t-n;a>=e;a-=n)s=UE(a/n|0,i[a],i[a+1],s);return s&&hu(s,s.next)&&(Tf(s),s=s.next),s}function Cl(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(hu(t,t.next)||Mn(t.prev,t,t.next)===0)){if(Tf(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function Mf(i,e,t,n,r,s,a){if(!i)return;!a&&s&&vN(i,n,r,s);let o=i;for(;i.prev!==i.next;){const l=i.prev,c=i.next;if(s?cN(i,n,r,s):lN(i)){e.push(l.i,i.i,c.i),Tf(i),i=c.next,o=c.next;continue}if(i=c,i===o){a?a===1?(i=uN(Cl(i),e),Mf(i,e,t,n,r,s,2)):a===2&&hN(i,e,t,n,r,s):Mf(Cl(i),e,t,n,r,s,1);break}}}function lN(i){const e=i.prev,t=i,n=i.next;if(Mn(e,t,n)>=0)return!1;const r=e.x,s=t.x,a=n.x,o=e.y,l=t.y,c=n.y,f=Math.min(r,s,a),d=Math.min(o,l,c),p=Math.max(r,s,a),m=Math.max(o,l,c);let y=n.next;for(;y!==e;){if(y.x>=f&&y.x<=p&&y.y>=d&&y.y<=m&&Wh(r,o,s,l,a,c,y.x,y.y)&&Mn(y.prev,y,y.next)>=0)return!1;y=y.next}return!0}function cN(i,e,t,n){const r=i.prev,s=i,a=i.next;if(Mn(r,s,a)>=0)return!1;const o=r.x,l=s.x,c=a.x,f=r.y,d=s.y,p=a.y,m=Math.min(o,l,c),y=Math.min(f,d,p),x=Math.max(o,l,c),_=Math.max(f,d,p),g=j_(m,y,e,t,n),b=j_(x,_,e,t,n);let S=i.prevZ,E=i.nextZ;for(;S&&S.z>=g&&E&&E.z<=b;){if(S.x>=m&&S.x<=x&&S.y>=y&&S.y<=_&&S!==r&&S!==a&&Wh(o,f,l,d,c,p,S.x,S.y)&&Mn(S.prev,S,S.next)>=0||(S=S.prevZ,E.x>=m&&E.x<=x&&E.y>=y&&E.y<=_&&E!==r&&E!==a&&Wh(o,f,l,d,c,p,E.x,E.y)&&Mn(E.prev,E,E.next)>=0))return!1;E=E.nextZ}for(;S&&S.z>=g;){if(S.x>=m&&S.x<=x&&S.y>=y&&S.y<=_&&S!==r&&S!==a&&Wh(o,f,l,d,c,p,S.x,S.y)&&Mn(S.prev,S,S.next)>=0)return!1;S=S.prevZ}for(;E&&E.z<=b;){if(E.x>=m&&E.x<=x&&E.y>=y&&E.y<=_&&E!==r&&E!==a&&Wh(o,f,l,d,c,p,E.x,E.y)&&Mn(E.prev,E,E.next)>=0)return!1;E=E.nextZ}return!0}function uN(i,e){let t=i;do{const n=t.prev,r=t.next.next;!hu(n,r)&&I2(n,t,t.next,r)&&wf(n,r)&&wf(r,n)&&(e.push(n.i,t.i,r.i),Tf(t),Tf(t.next),t=i=r),t=t.next}while(t!==i);return Cl(t)}function hN(i,e,t,n,r,s){let a=i;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&xN(a,o)){let l=P2(a,o);a=Cl(a,a.next),l=Cl(l,l.next),Mf(a,e,t,n,r,s,0),Mf(l,e,t,n,r,s,0);return}o=o.next}a=a.next}while(a!==i)}function fN(i,e,t,n){const r=[];for(let s=0,a=e.length;s<a;s++){const o=e[s]*n,l=s<a-1?e[s+1]*n:i.length,c=L2(i,o,l,n,!1);c===c.next&&(c.steiner=!0),r.push(_N(c))}r.sort(dN);for(let s=0;s<r.length;s++)t=pN(r[s],t);return t}function dN(i,e){let t=i.x-e.x;if(t===0&&(t=i.y-e.y,t===0)){const n=(i.next.y-i.y)/(i.next.x-i.x),r=(e.next.y-e.y)/(e.next.x-e.x);t=n-r}return t}function pN(i,e){const t=mN(i,e);if(!t)return e;const n=P2(t,i);return Cl(n,n.next),Cl(t,t.next)}function mN(i,e){let t=e;const n=i.x,r=i.y;let s=-1/0,a;if(hu(i,t))return t;do{if(hu(i,t.next))return t.next;if(r<=t.y&&r>=t.next.y&&t.next.y!==t.y){const d=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=n&&d>s&&(s=d,a=t.x<t.next.x?t:t.next,d===n))return a}t=t.next}while(t!==e);if(!a)return null;const o=a,l=a.x,c=a.y;let f=1/0;t=a;do{if(n>=t.x&&t.x>=l&&n!==t.x&&N2(r<c?n:s,r,l,c,r<c?s:n,r,t.x,t.y)){const d=Math.abs(r-t.y)/(n-t.x);wf(t,i)&&(d<f||d===f&&(t.x>a.x||t.x===a.x&&gN(a,t)))&&(a=t,f=d)}t=t.next}while(t!==o);return a}function gN(i,e){return Mn(i.prev,i,e.prev)<0&&Mn(e.next,i,i.next)<0}function vN(i,e,t,n){let r=i;do r.z===0&&(r.z=j_(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,yN(r)}function yN(i){let e,t=1;do{let n=i,r;i=null;let s=null;for(e=0;n;){e++;let a=n,o=0;for(let c=0;c<t&&(o++,a=a.nextZ,!!a);c++);let l=t;for(;o>0||l>0&&a;)o!==0&&(l===0||!a||n.z<=a.z)?(r=n,n=n.nextZ,o--):(r=a,a=a.nextZ,l--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;n=a}s.nextZ=null,t*=2}while(e>1);return i}function j_(i,e,t,n,r){return i=(i-t)*r|0,e=(e-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function _N(i){let e=i,t=i;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==i);return t}function N2(i,e,t,n,r,s,a,o){return(r-a)*(e-o)>=(i-a)*(s-o)&&(i-a)*(n-o)>=(t-a)*(e-o)&&(t-a)*(s-o)>=(r-a)*(n-o)}function Wh(i,e,t,n,r,s,a,o){return!(i===a&&e===o)&&N2(i,e,t,n,r,s,a,o)}function xN(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!bN(i,e)&&(wf(i,e)&&wf(e,i)&&SN(i,e)&&(Mn(i.prev,i,e.prev)||Mn(i,e.prev,e))||hu(i,e)&&Mn(i.prev,i,i.next)>0&&Mn(e.prev,e,e.next)>0)}function Mn(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function hu(i,e){return i.x===e.x&&i.y===e.y}function I2(i,e,t,n){const r=Sp(Mn(i,e,t)),s=Sp(Mn(i,e,n)),a=Sp(Mn(t,n,i)),o=Sp(Mn(t,n,e));return!!(r!==s&&a!==o||r===0&&bp(i,t,e)||s===0&&bp(i,n,e)||a===0&&bp(t,i,n)||o===0&&bp(t,e,n))}function bp(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function Sp(i){return i>0?1:i<0?-1:0}function bN(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&I2(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function wf(i,e){return Mn(i.prev,i,i.next)<0?Mn(i,e,i.next)>=0&&Mn(i,i.prev,e)>=0:Mn(i,e,i.prev)<0||Mn(i,i.next,e)<0}function SN(i,e){let t=i,n=!1;const r=(i.x+e.x)/2,s=(i.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function P2(i,e){const t=q_(i.i,i.x,i.y),n=q_(e.i,e.x,e.y),r=i.next,s=e.prev;return i.next=e,e.prev=i,t.next=r,r.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function UE(i,e,t,n){const r=q_(i,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function Tf(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function q_(i,e,t){return{i,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function EN(i,e,t,n){let r=0;for(let s=e,a=t-n;s<t;s+=n)r+=(i[a]-i[s])*(i[s+1]+i[a+1]),a=s;return r}class MN{static triangulate(e,t,n=2){return oN(e,t,n)}}class as{static area(e){const t=e.length;let n=0;for(let r=t-1,s=0;s<t;r=s++)n+=e[r].x*e[s].y-e[s].x*e[r].y;return n*.5}static isClockWise(e){return as.area(e)<0}static triangulateShape(e,t){const n=[],r=[],s=[];OE(e),LE(n,e);let a=e.length;t.forEach(OE);for(let l=0;l<t.length;l++)r.push(a),a+=t[l].length,LE(n,t[l]);const o=MN.triangulate(n,r);for(let l=0;l<o.length;l+=3)s.push(o.slice(l,l+3));return s}}function OE(i){const e=i.length;e>2&&i[e-1].equals(i[0])&&i.pop()}function LE(i,e){for(let t=0;t<e.length;t++)i.push(e[t].x),i.push(e[t].y)}class qg extends Ct{constructor(e=new bl([new Ge(.5,.5),new Ge(-.5,.5),new Ge(-.5,-.5),new Ge(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,r=[],s=[];for(let o=0,l=e.length;o<l;o++){const c=e[o];a(c)}this.setAttribute("position",new dt(r,3)),this.setAttribute("uv",new dt(s,2)),this.computeVertexNormals();function a(o){const l=[],c=t.curveSegments!==void 0?t.curveSegments:12,f=t.steps!==void 0?t.steps:1,d=t.depth!==void 0?t.depth:1;let p=t.bevelEnabled!==void 0?t.bevelEnabled:!0,m=t.bevelThickness!==void 0?t.bevelThickness:.2,y=t.bevelSize!==void 0?t.bevelSize:m-.1,x=t.bevelOffset!==void 0?t.bevelOffset:0,_=t.bevelSegments!==void 0?t.bevelSegments:3;const g=t.extrudePath,b=t.UVGenerator!==void 0?t.UVGenerator:wN;let S,E=!1,w,T,R,U;g&&(S=g.getSpacedPoints(f),E=!0,p=!1,w=g.computeFrenetFrames(f,!1),T=new J,R=new J,U=new J),p||(_=0,m=0,y=0,x=0);const D=o.extractPoints(c);let C=D.shape;const P=D.holes;if(!as.isClockWise(C)){C=C.reverse();for(let V=0,se=P.length;V<se;V++){const te=P[V];as.isClockWise(te)&&(P[V]=te.reverse())}}function O(V){const te=10000000000000001e-36;let Ee=V[0];for(let ce=1;ce<=V.length;ce++){const De=ce%V.length,_e=V[De],re=_e.x-Ee.x,Ie=_e.y-Ee.y,X=re*re+Ie*Ie,F=Math.max(Math.abs(_e.x),Math.abs(_e.y),Math.abs(Ee.x),Math.abs(Ee.y)),ie=te*F*F;if(X<=ie){V.splice(De,1),ce--;continue}Ee=_e}}O(C),P.forEach(O);const G=P.length,Z=C;for(let V=0;V<G;V++){const se=P[V];C=C.concat(se)}function z(V,se,te){return se||console.error("THREE.ExtrudeGeometry: vec does not exist"),V.clone().addScaledVector(se,te)}const L=C.length;function B(V,se,te){let Ee,ce,De;const _e=V.x-se.x,re=V.y-se.y,Ie=te.x-V.x,X=te.y-V.y,F=_e*_e+re*re,ie=_e*X-re*Ie;if(Math.abs(ie)>Number.EPSILON){const Se=Math.sqrt(F),ve=Math.sqrt(Ie*Ie+X*X),ge=se.x-re/Se,Be=se.y+_e/Se,Pe=te.x-X/ve,je=te.y+Ie/ve,Ze=((Pe-ge)*X-(je-Be)*Ie)/(_e*X-re*Ie);Ee=ge+_e*Ze-V.x,ce=Be+re*Ze-V.y;const Ce=Ee*Ee+ce*ce;if(Ce<=2)return new Ge(Ee,ce);De=Math.sqrt(Ce/2)}else{let Se=!1;_e>Number.EPSILON?Ie>Number.EPSILON&&(Se=!0):_e<-Number.EPSILON?Ie<-Number.EPSILON&&(Se=!0):Math.sign(re)===Math.sign(X)&&(Se=!0),Se?(Ee=-re,ce=_e,De=Math.sqrt(F)):(Ee=_e,ce=re,De=Math.sqrt(F/2))}return new Ge(Ee/De,ce/De)}const H=[];for(let V=0,se=Z.length,te=se-1,Ee=V+1;V<se;V++,te++,Ee++)te===se&&(te=0),Ee===se&&(Ee=0),H[V]=B(Z[V],Z[te],Z[Ee]);const W=[];let k,K=H.concat();for(let V=0,se=G;V<se;V++){const te=P[V];k=[];for(let Ee=0,ce=te.length,De=ce-1,_e=Ee+1;Ee<ce;Ee++,De++,_e++)De===ce&&(De=0),_e===ce&&(_e=0),k[Ee]=B(te[Ee],te[De],te[_e]);W.push(k),K=K.concat(k)}let $;if(_===0)$=as.triangulateShape(Z,P);else{const V=[],se=[];for(let te=0;te<_;te++){const Ee=te/_,ce=m*Math.cos(Ee*Math.PI/2),De=y*Math.sin(Ee*Math.PI/2)+x;for(let _e=0,re=Z.length;_e<re;_e++){const Ie=z(Z[_e],H[_e],De);Le(Ie.x,Ie.y,-ce),Ee===0&&V.push(Ie)}for(let _e=0,re=G;_e<re;_e++){const Ie=P[_e];k=W[_e];const X=[];for(let F=0,ie=Ie.length;F<ie;F++){const Se=z(Ie[F],k[F],De);Le(Se.x,Se.y,-ce),Ee===0&&X.push(Se)}Ee===0&&se.push(X)}}$=as.triangulateShape(V,se)}const j=$.length,ee=y+x;for(let V=0;V<L;V++){const se=p?z(C[V],K[V],ee):C[V];E?(R.copy(w.normals[0]).multiplyScalar(se.x),T.copy(w.binormals[0]).multiplyScalar(se.y),U.copy(S[0]).add(R).add(T),Le(U.x,U.y,U.z)):Le(se.x,se.y,0)}for(let V=1;V<=f;V++)for(let se=0;se<L;se++){const te=p?z(C[se],K[se],ee):C[se];E?(R.copy(w.normals[V]).multiplyScalar(te.x),T.copy(w.binormals[V]).multiplyScalar(te.y),U.copy(S[V]).add(R).add(T),Le(U.x,U.y,U.z)):Le(te.x,te.y,d/f*V)}for(let V=_-1;V>=0;V--){const se=V/_,te=m*Math.cos(se*Math.PI/2),Ee=y*Math.sin(se*Math.PI/2)+x;for(let ce=0,De=Z.length;ce<De;ce++){const _e=z(Z[ce],H[ce],Ee);Le(_e.x,_e.y,d+te)}for(let ce=0,De=P.length;ce<De;ce++){const _e=P[ce];k=W[ce];for(let re=0,Ie=_e.length;re<Ie;re++){const X=z(_e[re],k[re],Ee);E?Le(X.x,X.y+S[f-1].y,S[f-1].x+te):Le(X.x,X.y,d+te)}}}de(),ae();function de(){const V=r.length/3;if(p){let se=0,te=L*se;for(let Ee=0;Ee<j;Ee++){const ce=$[Ee];xe(ce[2]+te,ce[1]+te,ce[0]+te)}se=f+_*2,te=L*se;for(let Ee=0;Ee<j;Ee++){const ce=$[Ee];xe(ce[0]+te,ce[1]+te,ce[2]+te)}}else{for(let se=0;se<j;se++){const te=$[se];xe(te[2],te[1],te[0])}for(let se=0;se<j;se++){const te=$[se];xe(te[0]+L*f,te[1]+L*f,te[2]+L*f)}}n.addGroup(V,r.length/3-V,0)}function ae(){const V=r.length/3;let se=0;pe(Z,se),se+=Z.length;for(let te=0,Ee=P.length;te<Ee;te++){const ce=P[te];pe(ce,se),se+=ce.length}n.addGroup(V,r.length/3-V,1)}function pe(V,se){let te=V.length;for(;--te>=0;){const Ee=te;let ce=te-1;ce<0&&(ce=V.length-1);for(let De=0,_e=f+_*2;De<_e;De++){const re=L*De,Ie=L*(De+1),X=se+Ee+re,F=se+ce+re,ie=se+ce+Ie,Se=se+Ee+Ie;me(X,F,ie,Se)}}}function Le(V,se,te){l.push(V),l.push(se),l.push(te)}function xe(V,se,te){ne(V),ne(se),ne(te);const Ee=r.length/3,ce=b.generateTopUV(n,r,Ee-3,Ee-2,Ee-1);Ue(ce[0]),Ue(ce[1]),Ue(ce[2])}function me(V,se,te,Ee){ne(V),ne(se),ne(Ee),ne(se),ne(te),ne(Ee);const ce=r.length/3,De=b.generateSideWallUV(n,r,ce-6,ce-3,ce-2,ce-1);Ue(De[0]),Ue(De[1]),Ue(De[3]),Ue(De[1]),Ue(De[2]),Ue(De[3])}function ne(V){r.push(l[V*3+0]),r.push(l[V*3+1]),r.push(l[V*3+2])}function Ue(V){s.push(V.x),s.push(V.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options;return TN(t,n,e)}static fromJSON(e,t){const n=[];for(let s=0,a=e.shapes.length;s<a;s++){const o=t[e.shapes[s]];n.push(o)}const r=e.options.extrudePath;return r!==void 0&&(e.options.extrudePath=new eg[r.type]().fromJSON(r)),new qg(n,e.options)}}const wN={generateTopUV:function(i,e,t,n,r){const s=e[t*3],a=e[t*3+1],o=e[n*3],l=e[n*3+1],c=e[r*3],f=e[r*3+1];return[new Ge(s,a),new Ge(o,l),new Ge(c,f)]},generateSideWallUV:function(i,e,t,n,r,s){const a=e[t*3],o=e[t*3+1],l=e[t*3+2],c=e[n*3],f=e[n*3+1],d=e[n*3+2],p=e[r*3],m=e[r*3+1],y=e[r*3+2],x=e[s*3],_=e[s*3+1],g=e[s*3+2];return Math.abs(o-f)<Math.abs(a-c)?[new Ge(a,1-l),new Ge(c,1-d),new Ge(p,1-y),new Ge(x,1-g)]:[new Ge(o,1-l),new Ge(f,1-d),new Ge(m,1-y),new Ge(_,1-g)]}};function TN(i,e,t){if(t.shapes=[],Array.isArray(i))for(let n=0,r=i.length;n<r;n++){const s=i[n];t.shapes.push(s.uuid)}else t.shapes.push(i.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class Yg extends go{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,r=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Yg(e.radius,e.detail)}}class Zg extends Ct{constructor(e=[new Ge(0,-.5),new Ge(.5,0),new Ge(0,.5)],t=12,n=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:r},t=Math.floor(t),r=Tt(r,0,Math.PI*2);const s=[],a=[],o=[],l=[],c=[],f=1/t,d=new J,p=new Ge,m=new J,y=new J,x=new J;let _=0,g=0;for(let b=0;b<=e.length-1;b++)switch(b){case 0:_=e[b+1].x-e[b].x,g=e[b+1].y-e[b].y,m.x=g*1,m.y=-_,m.z=g*0,x.copy(m),m.normalize(),l.push(m.x,m.y,m.z);break;case e.length-1:l.push(x.x,x.y,x.z);break;default:_=e[b+1].x-e[b].x,g=e[b+1].y-e[b].y,m.x=g*1,m.y=-_,m.z=g*0,y.copy(m),m.x+=x.x,m.y+=x.y,m.z+=x.z,m.normalize(),l.push(m.x,m.y,m.z),x.copy(y)}for(let b=0;b<=t;b++){const S=n+b*f*r,E=Math.sin(S),w=Math.cos(S);for(let T=0;T<=e.length-1;T++){d.x=e[T].x*E,d.y=e[T].y,d.z=e[T].x*w,a.push(d.x,d.y,d.z),p.x=b/t,p.y=T/(e.length-1),o.push(p.x,p.y);const R=l[3*T+0]*E,U=l[3*T+1],D=l[3*T+0]*w;c.push(R,U,D)}}for(let b=0;b<t;b++)for(let S=0;S<e.length-1;S++){const E=S+b*e.length,w=E,T=E+e.length,R=E+e.length+1,U=E+1;s.push(w,T,U),s.push(R,U,T)}this.setIndex(s),this.setAttribute("position",new dt(a,3)),this.setAttribute("uv",new dt(o,2)),this.setAttribute("normal",new dt(c,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Zg(e.points,e.segments,e.phiStart,e.phiLength)}}class Kf extends go{constructor(e=1,t=0){const n=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],r=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(n,r,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Kf(e.radius,e.detail)}}class Ma extends Ct{constructor(e=1,t=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};const s=e/2,a=t/2,o=Math.floor(n),l=Math.floor(r),c=o+1,f=l+1,d=e/o,p=t/l,m=[],y=[],x=[],_=[];for(let g=0;g<f;g++){const b=g*p-a;for(let S=0;S<c;S++){const E=S*d-s;y.push(E,-b,0),x.push(0,0,1),_.push(S/o),_.push(1-g/l)}}for(let g=0;g<l;g++)for(let b=0;b<o;b++){const S=b+c*g,E=b+c*(g+1),w=b+1+c*(g+1),T=b+1+c*g;m.push(S,E,T),m.push(E,w,T)}this.setIndex(m),this.setAttribute("position",new dt(y,3)),this.setAttribute("normal",new dt(x,3)),this.setAttribute("uv",new dt(_,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ma(e.width,e.height,e.widthSegments,e.heightSegments)}}class Kg extends Ct{constructor(e=.5,t=1,n=32,r=1,s=0,a=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:r,thetaStart:s,thetaLength:a},n=Math.max(3,n),r=Math.max(1,r);const o=[],l=[],c=[],f=[];let d=e;const p=(t-e)/r,m=new J,y=new Ge;for(let x=0;x<=r;x++){for(let _=0;_<=n;_++){const g=s+_/n*a;m.x=d*Math.cos(g),m.y=d*Math.sin(g),l.push(m.x,m.y,m.z),c.push(0,0,1),y.x=(m.x/t+1)/2,y.y=(m.y/t+1)/2,f.push(y.x,y.y)}d+=p}for(let x=0;x<r;x++){const _=x*(n+1);for(let g=0;g<n;g++){const b=g+_,S=b,E=b+n+1,w=b+n+2,T=b+1;o.push(S,E,T),o.push(E,w,T)}}this.setIndex(o),this.setAttribute("position",new dt(l,3)),this.setAttribute("normal",new dt(c,3)),this.setAttribute("uv",new dt(f,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Kg(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class Jg extends Ct{constructor(e=new bl([new Ge(0,.5),new Ge(-.5,-.5),new Ge(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const n=[],r=[],s=[],a=[];let o=0,l=0;if(Array.isArray(e)===!1)c(e);else for(let f=0;f<e.length;f++)c(e[f]),this.addGroup(o,l,f),o+=l,l=0;this.setIndex(n),this.setAttribute("position",new dt(r,3)),this.setAttribute("normal",new dt(s,3)),this.setAttribute("uv",new dt(a,2));function c(f){const d=r.length/3,p=f.extractPoints(t);let m=p.shape;const y=p.holes;as.isClockWise(m)===!1&&(m=m.reverse());for(let _=0,g=y.length;_<g;_++){const b=y[_];as.isClockWise(b)===!0&&(y[_]=b.reverse())}const x=as.triangulateShape(m,y);for(let _=0,g=y.length;_<g;_++){const b=y[_];m=m.concat(b)}for(let _=0,g=m.length;_<g;_++){const b=m[_];r.push(b.x,b.y,0),s.push(0,0,1),a.push(b.x,b.y)}for(let _=0,g=x.length;_<g;_++){const b=x[_],S=b[0]+d,E=b[1]+d,w=b[2]+d;n.push(S,E,w),l+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return AN(t,e)}static fromJSON(e,t){const n=[];for(let r=0,s=e.shapes.length;r<s;r++){const a=t[e.shapes[r]];n.push(a)}return new Jg(n,e.curveSegments)}}function AN(i,e){if(e.shapes=[],Array.isArray(i))for(let t=0,n=i.length;t<n;t++){const r=i[t];e.shapes.push(r.uuid)}else e.shapes.push(i.uuid);return e}class Jf extends Ct{constructor(e=1,t=32,n=16,r=0,s=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:r,phiLength:s,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const l=Math.min(a+o,Math.PI);let c=0;const f=[],d=new J,p=new J,m=[],y=[],x=[],_=[];for(let g=0;g<=n;g++){const b=[],S=g/n;let E=0;g===0&&a===0?E=.5/t:g===n&&l===Math.PI&&(E=-.5/t);for(let w=0;w<=t;w++){const T=w/t;d.x=-e*Math.cos(r+T*s)*Math.sin(a+S*o),d.y=e*Math.cos(a+S*o),d.z=e*Math.sin(r+T*s)*Math.sin(a+S*o),y.push(d.x,d.y,d.z),p.copy(d).normalize(),x.push(p.x,p.y,p.z),_.push(T+E,1-S),b.push(c++)}f.push(b)}for(let g=0;g<n;g++)for(let b=0;b<t;b++){const S=f[g][b+1],E=f[g][b],w=f[g+1][b],T=f[g+1][b+1];(g!==0||a>0)&&m.push(S,E,T),(g!==n-1||l<Math.PI)&&m.push(E,w,T)}this.setIndex(m),this.setAttribute("position",new dt(y,3)),this.setAttribute("normal",new dt(x,3)),this.setAttribute("uv",new dt(_,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Jf(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class Qg extends go{constructor(e=1,t=0){const n=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],r=[2,1,0,0,3,2,1,3,0,2,3,1];super(n,r,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Qg(e.radius,e.detail)}}class $g extends Ct{constructor(e=1,t=.4,n=12,r=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:r,arc:s},n=Math.floor(n),r=Math.floor(r);const a=[],o=[],l=[],c=[],f=new J,d=new J,p=new J;for(let m=0;m<=n;m++)for(let y=0;y<=r;y++){const x=y/r*s,_=m/n*Math.PI*2;d.x=(e+t*Math.cos(_))*Math.cos(x),d.y=(e+t*Math.cos(_))*Math.sin(x),d.z=t*Math.sin(_),o.push(d.x,d.y,d.z),f.x=e*Math.cos(x),f.y=e*Math.sin(x),p.subVectors(d,f).normalize(),l.push(p.x,p.y,p.z),c.push(y/r),c.push(m/n)}for(let m=1;m<=n;m++)for(let y=1;y<=r;y++){const x=(r+1)*m+y-1,_=(r+1)*(m-1)+y-1,g=(r+1)*(m-1)+y,b=(r+1)*m+y;a.push(x,_,b),a.push(_,g,b)}this.setIndex(a),this.setAttribute("position",new dt(o,3)),this.setAttribute("normal",new dt(l,3)),this.setAttribute("uv",new dt(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new $g(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class e0 extends Ct{constructor(e=1,t=.4,n=64,r=8,s=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:r,p:s,q:a},n=Math.floor(n),r=Math.floor(r);const o=[],l=[],c=[],f=[],d=new J,p=new J,m=new J,y=new J,x=new J,_=new J,g=new J;for(let S=0;S<=n;++S){const E=S/n*s*Math.PI*2;b(E,s,a,e,m),b(E+.01,s,a,e,y),_.subVectors(y,m),g.addVectors(y,m),x.crossVectors(_,g),g.crossVectors(x,_),x.normalize(),g.normalize();for(let w=0;w<=r;++w){const T=w/r*Math.PI*2,R=-t*Math.cos(T),U=t*Math.sin(T);d.x=m.x+(R*g.x+U*x.x),d.y=m.y+(R*g.y+U*x.y),d.z=m.z+(R*g.z+U*x.z),l.push(d.x,d.y,d.z),p.subVectors(d,m).normalize(),c.push(p.x,p.y,p.z),f.push(S/n),f.push(w/r)}}for(let S=1;S<=n;S++)for(let E=1;E<=r;E++){const w=(r+1)*(S-1)+(E-1),T=(r+1)*S+(E-1),R=(r+1)*S+E,U=(r+1)*(S-1)+E;o.push(w,T,U),o.push(T,R,U)}this.setIndex(o),this.setAttribute("position",new dt(l,3)),this.setAttribute("normal",new dt(c,3)),this.setAttribute("uv",new dt(f,2));function b(S,E,w,T,R){const U=Math.cos(S),D=Math.sin(S),C=w/E*S,P=Math.cos(C);R.x=T*(2+P)*.5*U,R.y=T*(2+P)*D*.5,R.z=T*Math.sin(C)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new e0(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class Rl extends Ct{constructor(e=new jg(new J(-1,-1,0),new J(-1,1,0),new J(1,1,0)),t=64,n=1,r=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:r,closed:s};const a=e.computeFrenetFrames(t,s);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;const o=new J,l=new J,c=new Ge;let f=new J;const d=[],p=[],m=[],y=[];x(),this.setIndex(y),this.setAttribute("position",new dt(d,3)),this.setAttribute("normal",new dt(p,3)),this.setAttribute("uv",new dt(m,2));function x(){for(let S=0;S<t;S++)_(S);_(s===!1?t:0),b(),g()}function _(S){f=e.getPointAt(S/t,f);const E=a.normals[S],w=a.binormals[S];for(let T=0;T<=r;T++){const R=T/r*Math.PI*2,U=Math.sin(R),D=-Math.cos(R);l.x=D*E.x+U*w.x,l.y=D*E.y+U*w.y,l.z=D*E.z+U*w.z,l.normalize(),p.push(l.x,l.y,l.z),o.x=f.x+n*l.x,o.y=f.y+n*l.y,o.z=f.z+n*l.z,d.push(o.x,o.y,o.z)}}function g(){for(let S=1;S<=t;S++)for(let E=1;E<=r;E++){const w=(r+1)*(S-1)+(E-1),T=(r+1)*S+(E-1),R=(r+1)*S+E,U=(r+1)*(S-1)+E;y.push(w,T,U),y.push(T,R,U)}}function b(){for(let S=0;S<=t;S++)for(let E=0;E<=r;E++)c.x=S/t,c.y=E/r,m.push(c.x,c.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new Rl(new eg[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class z2 extends Ct{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],n=new Set,r=new J,s=new J;if(e.index!==null){const a=e.attributes.position,o=e.index;let l=e.groups;l.length===0&&(l=[{start:0,count:o.count,materialIndex:0}]);for(let c=0,f=l.length;c<f;++c){const d=l[c],p=d.start,m=d.count;for(let y=p,x=p+m;y<x;y+=3)for(let _=0;_<3;_++){const g=o.getX(y+_),b=o.getX(y+(_+1)%3);r.fromBufferAttribute(a,g),s.fromBufferAttribute(a,b),NE(r,s,n)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}}else{const a=e.attributes.position;for(let o=0,l=a.count/3;o<l;o++)for(let c=0;c<3;c++){const f=3*o+c,d=3*o+(c+1)%3;r.fromBufferAttribute(a,f),s.fromBufferAttribute(a,d),NE(r,s,n)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new dt(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function NE(i,e,t){const n=`${i.x},${i.y},${i.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${i.x},${i.y},${i.z}`;return t.has(n)===!0||t.has(r)===!0?!1:(t.add(n),t.add(r),!0)}var IE=Object.freeze({__proto__:null,BoxGeometry:Ea,CapsuleGeometry:Hg,CircleGeometry:Vg,ConeGeometry:Zf,CylinderGeometry:Su,DodecahedronGeometry:Wg,EdgesGeometry:C2,ExtrudeGeometry:qg,IcosahedronGeometry:Yg,LatheGeometry:Zg,OctahedronGeometry:Kf,PlaneGeometry:Ma,PolyhedronGeometry:go,RingGeometry:Kg,ShapeGeometry:Jg,SphereGeometry:Jf,TetrahedronGeometry:Qg,TorusGeometry:$g,TorusKnotGeometry:e0,TubeGeometry:Rl,WireframeGeometry:z2});class F2 extends Oi{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new et(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}class B2 extends ls{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class o1 extends Oi{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new et(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new et(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=mo,this.normalScale=new Ge(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ui,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class k2 extends o1{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ge(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Tt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new et(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new et(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new et(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class G2 extends Oi{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new et(16777215),this.specular=new et(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new et(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=mo,this.normalScale=new Ge(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ui,this.combine=jf,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class H2 extends Oi{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new et(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new et(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=mo,this.normalScale=new Ge(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class V2 extends Oi{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=mo,this.normalScale=new Ge(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class W2 extends Oi{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new et(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new et(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=mo,this.normalScale=new Ge(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ui,this.combine=jf,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class t0 extends Oi{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=i2,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class n0 extends Oi{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class X2 extends Oi{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new et(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=mo,this.normalScale=new Ge(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class j2 extends Gi{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function gl(i,e){return!i||i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}function q2(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function Y2(i){function e(r,s){return i[r]-i[s]}const t=i.length,n=new Array(t);for(let r=0;r!==t;++r)n[r]=r;return n.sort(e),n}function Y_(i,e,t){const n=i.length,r=new i.constructor(n);for(let s=0,a=0;a!==n;++s){const o=t[s]*e;for(let l=0;l!==e;++l)r[a++]=i[o+l]}return r}function l1(i,e,t,n){let r=1,s=i[0];for(;s!==void 0&&s[n]===void 0;)s=i[r++];if(s===void 0)return;let a=s[n];if(a!==void 0)if(Array.isArray(a))do a=s[n],a!==void 0&&(e.push(s.time),t.push(...a)),s=i[r++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[n],a!==void 0&&(e.push(s.time),a.toArray(t,t.length)),s=i[r++];while(s!==void 0);else do a=s[n],a!==void 0&&(e.push(s.time),t.push(a)),s=i[r++];while(s!==void 0)}function CN(i,e,t,n,r=30){const s=i.clone();s.name=e;const a=[];for(let l=0;l<s.tracks.length;++l){const c=s.tracks[l],f=c.getValueSize(),d=[],p=[];for(let m=0;m<c.times.length;++m){const y=c.times[m]*r;if(!(y<t||y>=n)){d.push(c.times[m]);for(let x=0;x<f;++x)p.push(c.values[m*f+x])}}d.length!==0&&(c.times=gl(d,c.times.constructor),c.values=gl(p,c.values.constructor),a.push(c))}s.tracks=a;let o=1/0;for(let l=0;l<s.tracks.length;++l)o>s.tracks[l].times[0]&&(o=s.tracks[l].times[0]);for(let l=0;l<s.tracks.length;++l)s.tracks[l].shift(-1*o);return s.resetDuration(),s}function RN(i,e=0,t=i,n=30){n<=0&&(n=30);const r=t.tracks.length,s=e/n;for(let a=0;a<r;++a){const o=t.tracks[a],l=o.ValueTypeName;if(l==="bool"||l==="string")continue;const c=i.tracks.find(function(g){return g.name===o.name&&g.ValueTypeName===l});if(c===void 0)continue;let f=0;const d=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(f=d/3);let p=0;const m=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(p=m/3);const y=o.times.length-1;let x;if(s<=o.times[0]){const g=f,b=d-f;x=o.values.slice(g,b)}else if(s>=o.times[y]){const g=y*d+f,b=g+d-f;x=o.values.slice(g,b)}else{const g=o.createInterpolant(),b=f,S=d-f;g.evaluate(s),x=g.resultBuffer.slice(b,S)}l==="quaternion"&&new _i().fromArray(x).normalize().conjugate().toArray(x);const _=c.times.length;for(let g=0;g<_;++g){const b=g*m+p;if(l==="quaternion")_i.multiplyQuaternionsFlat(c.values,b,x,0,c.values,b);else{const S=m-p*2;for(let E=0;E<S;++E)c.values[b+E]-=x[E]}}}return i.blendMode=Vx,i}class DN{static convertArray(e,t){return gl(e,t)}static isTypedArray(e){return q2(e)}static getKeyframeOrder(e){return Y2(e)}static sortedArray(e,t,n){return Y_(e,t,n)}static flattenJSON(e,t,n,r){l1(e,t,n,r)}static subclip(e,t,n,r,s=30){return CN(e,t,n,r,s)}static makeClipAdditive(e,t=0,n=e,r=30){return RN(e,t,n,r)}}class Qf{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,r=t[n],s=t[n-1];e:{t:{let a;n:{i:if(!(e<r)){for(let o=n+2;;){if(r===void 0){if(e<s)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(s=r,r=t[++n],e<r)break t}a=t.length;break n}if(!(e>=s)){const o=t[1];e<o&&(n=2,s=o);for(let l=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(r=s,s=t[--n-1],e>=s)break t}a=n,n=0;break n}break e}for(;n<a;){const o=n+a>>>1;e<t[o]?a=o:n=o+1}if(r=t[n],s=t[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,r)}return this.interpolate_(n,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,s=e*r;for(let a=0;a!==r;++a)t[a]=n[s+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class Z2 extends Qf{constructor(e,t,n,r){super(e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:pl,endingEnd:pl}}intervalChanged_(e,t,n){const r=this.parameterPositions;let s=e-2,a=e+1,o=r[s],l=r[a];if(o===void 0)switch(this.getSettings_().endingStart){case ml:s=e,o=2*t-n;break;case _f:s=r.length-2,o=t+r[s]-r[s+1];break;default:s=e,o=n}if(l===void 0)switch(this.getSettings_().endingEnd){case ml:a=e,l=2*n-t;break;case _f:a=1,l=n+r[1]-r[0];break;default:a=e-1,l=t}const c=(n-t)*.5,f=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(l-n),this._offsetPrev=s*f,this._offsetNext=a*f}interpolate_(e,t,n,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,f=this._offsetPrev,d=this._offsetNext,p=this._weightPrev,m=this._weightNext,y=(n-t)/(r-t),x=y*y,_=x*y,g=-p*_+2*p*x-p*y,b=(1+p)*_+(-1.5-2*p)*x+(-.5+p)*y+1,S=(-1-m)*_+(1.5+m)*x+.5*y,E=m*_-m*x;for(let w=0;w!==o;++w)s[w]=g*a[f+w]+b*a[c+w]+S*a[l+w]+E*a[d+w];return s}}class c1 extends Qf{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,f=(n-t)/(r-t),d=1-f;for(let p=0;p!==o;++p)s[p]=a[c+p]*d+a[l+p]*f;return s}}class K2 extends Qf{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}}class Hr{constructor(e,t,n,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=gl(t,this.TimeBufferType),this.values=gl(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:gl(e.times,Array),values:gl(e.values,Array)};const r=e.getInterpolation();r!==e.DefaultInterpolation&&(n.interpolation=r)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new K2(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new c1(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Z2(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case yf:t=this.InterpolantFactoryMethodDiscrete;break;case Km:t=this.InterpolantFactoryMethodLinear;break;case im:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return yf;case this.InterpolantFactoryMethodLinear:return Km;case this.InterpolantFactoryMethodSmooth:return im}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e}return this}trim(e,t){const n=this.times,r=n.length;let s=0,a=r-1;for(;s!==r&&n[s]<e;)++s;for(;a!==-1&&n[a]>t;)--a;if(++a,s!==0||a!==r){s>=a&&(a=Math.max(a,1),s=a-1);const o=this.getValueSize();this.times=n.slice(s,a),this.values=this.values.slice(s*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,r=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==s;o++){const l=n[o];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(r!==void 0&&q2(r))for(let o=0,l=r.length;o!==l;++o){const c=r[o];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===im,s=e.length-1;let a=1;for(let o=1;o<s;++o){let l=!1;const c=e[o],f=e[o+1];if(c!==f&&(o!==1||c!==e[0]))if(r)l=!0;else{const d=o*n,p=d-n,m=d+n;for(let y=0;y!==n;++y){const x=t[d+y];if(x!==t[p+y]||x!==t[m+y]){l=!0;break}}}if(l){if(o!==a){e[a]=e[o];const d=o*n,p=a*n;for(let m=0;m!==n;++m)t[p+m]=t[d+m]}++a}}if(s>0){e[a]=e[s];for(let o=s*n,l=a*n,c=0;c!==n;++c)t[l+c]=t[o+c];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}Hr.prototype.ValueTypeName="";Hr.prototype.TimeBufferType=Float32Array;Hr.prototype.ValueBufferType=Float32Array;Hr.prototype.DefaultInterpolation=Km;class Nl extends Hr{constructor(e,t,n){super(e,t,n)}}Nl.prototype.ValueTypeName="bool";Nl.prototype.ValueBufferType=Array;Nl.prototype.DefaultInterpolation=yf;Nl.prototype.InterpolantFactoryMethodLinear=void 0;Nl.prototype.InterpolantFactoryMethodSmooth=void 0;class u1 extends Hr{constructor(e,t,n,r){super(e,t,n,r)}}u1.prototype.ValueTypeName="color";class Af extends Hr{constructor(e,t,n,r){super(e,t,n,r)}}Af.prototype.ValueTypeName="number";class J2 extends Qf{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(n-t)/(r-t);let c=e*o;for(let f=c+o;c!==f;c+=4)_i.slerpFlat(s,0,a,c-o,a,c,l);return s}}class $f extends Hr{constructor(e,t,n,r){super(e,t,n,r)}InterpolantFactoryMethodLinear(e){return new J2(this.times,this.values,this.getValueSize(),e)}}$f.prototype.ValueTypeName="quaternion";$f.prototype.InterpolantFactoryMethodSmooth=void 0;class Il extends Hr{constructor(e,t,n){super(e,t,n)}}Il.prototype.ValueTypeName="string";Il.prototype.ValueBufferType=Array;Il.prototype.DefaultInterpolation=yf;Il.prototype.InterpolantFactoryMethodLinear=void 0;Il.prototype.InterpolantFactoryMethodSmooth=void 0;class Cf extends Hr{constructor(e,t,n,r){super(e,t,n,r)}}Cf.prototype.ValueTypeName="vector";class Rf{constructor(e="",t=-1,n=[],r=Ug){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=vr(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,r=1/(e.fps||1);for(let a=0,o=n.length;a!==o;++a)t.push(ON(n[a]).scale(r));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,a=n.length;s!==a;++s)t.push(Hr.toJSON(n[s]));return r}static CreateFromMorphTargetSequence(e,t,n,r){const s=t.length,a=[];for(let o=0;o<s;o++){let l=[],c=[];l.push((o+s-1)%s,o,(o+1)%s),c.push(0,1,0);const f=Y2(l);l=Y_(l,1,f),c=Y_(c,1,f),!r&&l[0]===0&&(l.push(s),c.push(c[0])),a.push(new Af(".morphTargetInfluences["+t[o].name+"]",l,c).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const r=e;n=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<n.length;r++)if(n[r].name===t)return n[r];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const r={},s=/^([\w-]*?)([\d]+)$/;for(let o=0,l=e.length;o<l;o++){const c=e[o],f=c.name.match(s);if(f&&f.length>1){const d=f[1];let p=r[d];p||(r[d]=p=[]),p.push(c)}}const a=[];for(const o in r)a.push(this.CreateFromMorphTargetSequence(o,r[o],t,n));return a}static parseAnimation(e,t){if(console.warn("THREE.AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(d,p,m,y,x){if(m.length!==0){const _=[],g=[];l1(m,_,g,y),_.length!==0&&x.push(new d(p,_,g))}},r=[],s=e.name||"default",a=e.fps||30,o=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let d=0;d<c.length;d++){const p=c[d].keys;if(!(!p||p.length===0))if(p[0].morphTargets){const m={};let y;for(y=0;y<p.length;y++)if(p[y].morphTargets)for(let x=0;x<p[y].morphTargets.length;x++)m[p[y].morphTargets[x]]=-1;for(const x in m){const _=[],g=[];for(let b=0;b!==p[y].morphTargets.length;++b){const S=p[y];_.push(S.time),g.push(S.morphTarget===x?1:0)}r.push(new Af(".morphTargetInfluence["+x+"]",_,g))}l=m.length*a}else{const m=".bones["+t[d].name+"]";n(Cf,m+".position",p,"pos",r),n($f,m+".quaternion",p,"rot",r),n(Cf,m+".scale",p,"scl",r)}}return r.length===0?null:new this(s,l,r,o)}resetDuration(){const e=this.tracks;let t=0;for(let n=0,r=e.length;n!==r;++n){const s=this.tracks[n];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function UN(i){switch(i.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Af;case"vector":case"vector2":case"vector3":case"vector4":return Cf;case"color":return u1;case"quaternion":return $f;case"bool":case"boolean":return Nl;case"string":return Il}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+i)}function ON(i){if(i.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=UN(i.type);if(i.times===void 0){const t=[],n=[];l1(i.keys,t,n,"value"),i.times=t,i.values=n}return e.parse!==void 0?e.parse(i):new e(i.name,i.times,i.values,i.interpolation)}const fa={enabled:!1,files:{},add:function(i,e){this.enabled!==!1&&(this.files[i]=e)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};class h1{constructor(e,t,n){const r=this;let s=!1,a=0,o=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(f){o++,s===!1&&r.onStart!==void 0&&r.onStart(f,a,o),s=!0},this.itemEnd=function(f){a++,r.onProgress!==void 0&&r.onProgress(f,a,o),a===o&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(f){r.onError!==void 0&&r.onError(f)},this.resolveURL=function(f){return l?l(f):f},this.setURLModifier=function(f){return l=f,this},this.addHandler=function(f,d){return c.push(f,d),this},this.removeHandler=function(f){const d=c.indexOf(f);return d!==-1&&c.splice(d,2),this},this.getHandler=function(f){for(let d=0,p=c.length;d<p;d+=2){const m=c[d],y=c[d+1];if(m.global&&(m.lastIndex=0),m.test(f))return y}return null}}}const Q2=new h1;class ir{constructor(e){this.manager=e!==void 0?e:Q2,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise(function(r,s){n.load(e,r,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}ir.DEFAULT_MATERIAL_NAME="__DEFAULT";const ta={};class LN extends Error{constructor(e,t){super(e),this.response=t}}class xa extends ir{constructor(e){super(e),this.mimeType="",this.responseType=""}load(e,t,n,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=fa.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(ta[e]!==void 0){ta[e].push({onLoad:t,onProgress:n,onError:r});return}ta[e]=[],ta[e].push({onLoad:t,onProgress:n,onError:r});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const f=ta[e],d=c.body.getReader(),p=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),m=p?parseInt(p):0,y=m!==0;let x=0;const _=new ReadableStream({start(g){b();function b(){d.read().then(({done:S,value:E})=>{if(S)g.close();else{x+=E.byteLength;const w=new ProgressEvent("progress",{lengthComputable:y,loaded:x,total:m});for(let T=0,R=f.length;T<R;T++){const U=f[T];U.onProgress&&U.onProgress(w)}g.enqueue(E),b()}},S=>{g.error(S)})}}});return new Response(_)}else throw new LN(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(f=>new DOMParser().parseFromString(f,o));case"json":return c.json();default:if(o==="")return c.text();{const d=/charset="?([^;"\s]*)"?/i.exec(o),p=d&&d[1]?d[1].toLowerCase():void 0,m=new TextDecoder(p);return c.arrayBuffer().then(y=>m.decode(y))}}}).then(c=>{fa.add(e,c);const f=ta[e];delete ta[e];for(let d=0,p=f.length;d<p;d++){const m=f[d];m.onLoad&&m.onLoad(c)}}).catch(c=>{const f=ta[e];if(f===void 0)throw this.manager.itemError(e),c;delete ta[e];for(let d=0,p=f.length;d<p;d++){const m=f[d];m.onError&&m.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class NN extends ir{constructor(e){super(e)}load(e,t,n,r){const s=this,a=new xa(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},n,r)}parse(e){const t=[];for(let n=0;n<e.length;n++){const r=Rf.parse(e[n]);t.push(r)}return t}}class IN extends ir{constructor(e){super(e)}load(e,t,n,r){const s=this,a=[],o=new Gg,l=new xa(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(s.withCredentials);let c=0;function f(d){l.load(e[d],function(p){const m=s.parse(p,!0);a[d]={width:m.width,height:m.height,format:m.format,mipmaps:m.mipmaps},c+=1,c===6&&(m.mipmapCount===1&&(o.minFilter=Pn),o.image=a,o.format=m.format,o.needsUpdate=!0,t&&t(o))},n,r)}if(Array.isArray(e))for(let d=0,p=e.length;d<p;++d)f(d);else l.load(e,function(d){const p=s.parse(d,!0);if(p.isCubemap){const m=p.mipmaps.length/p.mipmapCount;for(let y=0;y<m;y++){a[y]={mipmaps:[]};for(let x=0;x<p.mipmapCount;x++)a[y].mipmaps.push(p.mipmaps[y*p.mipmapCount+x]),a[y].format=p.format,a[y].width=p.width,a[y].height=p.height}o.image=a}else o.image.width=p.width,o.image.height=p.height,o.mipmaps=p.mipmaps;p.mipmapCount===1&&(o.minFilter=Pn),o.format=p.format,o.needsUpdate=!0,t&&t(o)},n,r);return o}}class Df extends ir{constructor(e){super(e)}load(e,t,n,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=fa.get(e);if(a!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a;const o=Ef("img");function l(){f(),fa.add(e,this),t&&t(this),s.manager.itemEnd(e)}function c(d){f(),r&&r(d),s.manager.itemError(e),s.manager.itemEnd(e)}function f(){o.removeEventListener("load",l,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),s.manager.itemStart(e),o.src=e,o}}class PN extends ir{constructor(e){super(e)}load(e,t,n,r){const s=new Yf;s.colorSpace=Ri;const a=new Df(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let o=0;function l(c){a.load(e[c],function(f){s.images[c]=f,o++,o===6&&(s.needsUpdate=!0,t&&t(s))},void 0,r)}for(let c=0;c<e.length;++c)l(c);return s}}class zN extends ir{constructor(e){super(e)}load(e,t,n,r){const s=this,a=new Ts,o=new xa(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(s.withCredentials),o.load(e,function(l){let c;try{c=s.parse(l)}catch(f){if(r!==void 0)r(f);else{console.error(f);return}}c.image!==void 0?a.image=c.image:c.data!==void 0&&(a.image.width=c.width,a.image.height=c.height,a.image.data=c.data),a.wrapS=c.wrapS!==void 0?c.wrapS:zr,a.wrapT=c.wrapT!==void 0?c.wrapT:zr,a.magFilter=c.magFilter!==void 0?c.magFilter:Pn,a.minFilter=c.minFilter!==void 0?c.minFilter:Pn,a.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.colorSpace!==void 0&&(a.colorSpace=c.colorSpace),c.flipY!==void 0&&(a.flipY=c.flipY),c.format!==void 0&&(a.format=c.format),c.type!==void 0&&(a.type=c.type),c.mipmaps!==void 0&&(a.mipmaps=c.mipmaps,a.minFilter=Ms),c.mipmapCount===1&&(a.minFilter=Pn),c.generateMipmaps!==void 0&&(a.generateMipmaps=c.generateMipmaps),a.needsUpdate=!0,t&&t(a,c)},n,r),a}}class $2 extends ir{constructor(e){super(e)}load(e,t,n,r){const s=new An,a=new Df(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){s.image=o,s.needsUpdate=!0,t!==void 0&&t(s)},n,r),s}}class vo extends Xt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new et(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}class eC extends vo{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Xt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new et(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const dy=new bt,PE=new J,zE=new J;class f1{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ge(512,512),this.mapType=Gr,this.map=null,this.mapPass=null,this.matrix=new bt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Ll,this._frameExtents=new Ge(1,1),this._viewportCount=1,this._viewports=[new kt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;PE.setFromMatrixPosition(e.matrixWorld),t.position.copy(PE),zE.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(zE),t.updateMatrixWorld(),dy.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(dy),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(dy)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class FN extends f1{constructor(){super(new Zn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,n=lu*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height*this.aspect,s=e.distance||t.far;(n!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=n,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class tC extends vo{constructor(e,t,n=0,r=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Xt.DEFAULT_UP),this.updateMatrix(),this.target=new Xt,this.distance=n,this.angle=r,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new FN}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const FE=new bt,yh=new J,py=new J;class BN extends f1{constructor(){super(new Zn(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Ge(4,2),this._viewportCount=6,this._viewports=[new kt(2,1,1,1),new kt(0,1,1,1),new kt(3,1,1,1),new kt(1,1,1,1),new kt(3,0,1,1),new kt(1,0,1,1)],this._cubeDirections=[new J(1,0,0),new J(-1,0,0),new J(0,0,1),new J(0,0,-1),new J(0,1,0),new J(0,-1,0)],this._cubeUps=[new J(0,1,0),new J(0,1,0),new J(0,1,0),new J(0,1,0),new J(0,0,1),new J(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,r=this.matrix,s=e.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),yh.setFromMatrixPosition(e.matrixWorld),n.position.copy(yh),py.copy(n.position),py.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(py),n.updateMatrixWorld(),r.makeTranslation(-yh.x,-yh.y,-yh.z),FE.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(FE)}}class nC extends vo{constructor(e,t,n=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=r,this.shadow=new BN}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class Pl extends Ng{constructor(e=-1,t=1,n=1,r=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,s,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let s=n-e,a=n+e,o=r+t,l=r-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,f=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=f*this.view.offsetY,l=o-f*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class kN extends f1{constructor(){super(new Pl(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class iC extends vo{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Xt.DEFAULT_UP),this.updateMatrix(),this.target=new Xt,this.shadow=new kN}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class rC extends vo{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class sC extends vo{constructor(e,t,n=10,r=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=r}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class aC{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new J)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const n=e.x,r=e.y,s=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*r),t.addScaledVector(a[2],.488603*s),t.addScaledVector(a[3],.488603*n),t.addScaledVector(a[4],1.092548*(n*r)),t.addScaledVector(a[5],1.092548*(r*s)),t.addScaledVector(a[6],.315392*(3*s*s-1)),t.addScaledVector(a[7],1.092548*(n*s)),t.addScaledVector(a[8],.546274*(n*n-r*r)),t}getIrradianceAt(e,t){const n=e.x,r=e.y,s=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScaledVector(a[1],2*.511664*r),t.addScaledVector(a[2],2*.511664*s),t.addScaledVector(a[3],2*.511664*n),t.addScaledVector(a[4],2*.429043*n*r),t.addScaledVector(a[5],2*.429043*r*s),t.addScaledVector(a[6],.743125*s*s-.247708),t.addScaledVector(a[7],2*.429043*n*s),t.addScaledVector(a[8],.429043*(n*n-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){const n=this.coefficients;for(let r=0;r<9;r++)n[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){const n=this.coefficients;for(let r=0;r<9;r++)n[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){const n=e.x,r=e.y,s=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*s,t[3]=.488603*n,t[4]=1.092548*n*r,t[5]=1.092548*r*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*n*s,t[8]=.546274*(n*n-r*r)}}class oC extends vo{constructor(e=new aC,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class i0 extends ir{constructor(e){super(e),this.textures={}}load(e,t,n,r){const s=this,a=new xa(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},n,r)}parse(e){const t=this.textures;function n(s){return t[s]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",s),t[s]}const r=this.createMaterialFromType(e.type);if(e.uuid!==void 0&&(r.uuid=e.uuid),e.name!==void 0&&(r.name=e.name),e.color!==void 0&&r.color!==void 0&&r.color.setHex(e.color),e.roughness!==void 0&&(r.roughness=e.roughness),e.metalness!==void 0&&(r.metalness=e.metalness),e.sheen!==void 0&&(r.sheen=e.sheen),e.sheenColor!==void 0&&(r.sheenColor=new et().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(r.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&r.emissive!==void 0&&r.emissive.setHex(e.emissive),e.specular!==void 0&&r.specular!==void 0&&r.specular.setHex(e.specular),e.specularIntensity!==void 0&&(r.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&r.specularColor!==void 0&&r.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(r.shininess=e.shininess),e.clearcoat!==void 0&&(r.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(r.dispersion=e.dispersion),e.iridescence!==void 0&&(r.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(r.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(r.transmission=e.transmission),e.thickness!==void 0&&(r.thickness=e.thickness),e.attenuationDistance!==void 0&&(r.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&r.attenuationColor!==void 0&&r.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(r.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(r.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(r.fog=e.fog),e.flatShading!==void 0&&(r.flatShading=e.flatShading),e.blending!==void 0&&(r.blending=e.blending),e.combine!==void 0&&(r.combine=e.combine),e.side!==void 0&&(r.side=e.side),e.shadowSide!==void 0&&(r.shadowSide=e.shadowSide),e.opacity!==void 0&&(r.opacity=e.opacity),e.transparent!==void 0&&(r.transparent=e.transparent),e.alphaTest!==void 0&&(r.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(r.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(r.depthFunc=e.depthFunc),e.depthTest!==void 0&&(r.depthTest=e.depthTest),e.depthWrite!==void 0&&(r.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(r.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(r.blendSrc=e.blendSrc),e.blendDst!==void 0&&(r.blendDst=e.blendDst),e.blendEquation!==void 0&&(r.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(r.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(r.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(r.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&r.blendColor!==void 0&&r.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(r.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(r.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(r.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(r.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(r.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(r.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(r.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(r.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(r.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(r.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(r.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(r.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(r.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(r.rotation=e.rotation),e.linewidth!==void 0&&(r.linewidth=e.linewidth),e.dashSize!==void 0&&(r.dashSize=e.dashSize),e.gapSize!==void 0&&(r.gapSize=e.gapSize),e.scale!==void 0&&(r.scale=e.scale),e.polygonOffset!==void 0&&(r.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(r.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(r.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(r.dithering=e.dithering),e.alphaToCoverage!==void 0&&(r.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(r.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(r.forceSinglePass=e.forceSinglePass),e.visible!==void 0&&(r.visible=e.visible),e.toneMapped!==void 0&&(r.toneMapped=e.toneMapped),e.userData!==void 0&&(r.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?r.vertexColors=e.vertexColors>0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const s in e.uniforms){const a=e.uniforms[s];switch(r.uniforms[s]={},a.type){case"t":r.uniforms[s].value=n(a.value);break;case"c":r.uniforms[s].value=new et().setHex(a.value);break;case"v2":r.uniforms[s].value=new Ge().fromArray(a.value);break;case"v3":r.uniforms[s].value=new J().fromArray(a.value);break;case"v4":r.uniforms[s].value=new kt().fromArray(a.value);break;case"m3":r.uniforms[s].value=new wt().fromArray(a.value);break;case"m4":r.uniforms[s].value=new bt().fromArray(a.value);break;default:r.uniforms[s].value=a.value}}if(e.defines!==void 0&&(r.defines=e.defines),e.vertexShader!==void 0&&(r.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(r.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(r.glslVersion=e.glslVersion),e.extensions!==void 0)for(const s in e.extensions)r.extensions[s]=e.extensions[s];if(e.lights!==void 0&&(r.lights=e.lights),e.clipping!==void 0&&(r.clipping=e.clipping),e.size!==void 0&&(r.size=e.size),e.sizeAttenuation!==void 0&&(r.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(r.map=n(e.map)),e.matcap!==void 0&&(r.matcap=n(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=n(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=n(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=n(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),r.normalScale=new Ge().fromArray(s)}return e.displacementMap!==void 0&&(r.displacementMap=n(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=n(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=n(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=n(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=n(e.specularMap)),e.specularIntensityMap!==void 0&&(r.specularIntensityMap=n(e.specularIntensityMap)),e.specularColorMap!==void 0&&(r.specularColorMap=n(e.specularColorMap)),e.envMap!==void 0&&(r.envMap=n(e.envMap)),e.envMapRotation!==void 0&&r.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(r.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(r.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(r.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(r.lightMap=n(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=n(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=n(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=n(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=n(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new Ge().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(r.iridescenceMap=n(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(r.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(r.transmissionMap=n(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=n(e.thicknessMap)),e.anisotropyMap!==void 0&&(r.anisotropyMap=n(e.anisotropyMap)),e.sheenColorMap!==void 0&&(r.sheenColorMap=n(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(r.sheenRoughnessMap=n(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return i0.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:F2,SpriteMaterial:Jx,RawShaderMaterial:B2,ShaderMaterial:ls,PointsMaterial:$x,MeshPhysicalMaterial:k2,MeshStandardMaterial:o1,MeshPhongMaterial:G2,MeshToonMaterial:H2,MeshNormalMaterial:V2,MeshLambertMaterial:W2,MeshDepthMaterial:t0,MeshDistanceMaterial:n0,MeshBasicMaterial:Sa,MeshMatcapMaterial:X2,LineDashedMaterial:j2,LineBasicMaterial:Gi,Material:Oi};return new t[e]}}class Z_{static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class d1 extends Ct{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class lC extends ir{constructor(e){super(e)}load(e,t,n,r){const s=this,a=new xa(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},n,r)}parse(e){const t={},n={};function r(m,y){if(t[y]!==void 0)return t[y];const _=m.interleavedBuffers[y],g=s(m,_.buffer),b=Yc(_.type,g),S=new Fg(b,_.stride);return S.uuid=_.uuid,t[y]=S,S}function s(m,y){if(n[y]!==void 0)return n[y];const _=m.arrayBuffers[y],g=new Uint32Array(_).buffer;return n[y]=g,g}const a=e.isInstancedBufferGeometry?new d1:new Ct,o=e.data.index;if(o!==void 0){const m=Yc(o.type,o.array);a.setIndex(new en(m,1))}const l=e.data.attributes;for(const m in l){const y=l[m];let x;if(y.isInterleavedBufferAttribute){const _=r(e.data,y.data);x=new Tl(_,y.itemSize,y.offset,y.normalized)}else{const _=Yc(y.type,y.array),g=y.isInstancedBufferAttribute?Al:en;x=new g(_,y.itemSize,y.normalized)}y.name!==void 0&&(x.name=y.name),y.usage!==void 0&&x.setUsage(y.usage),a.setAttribute(m,x)}const c=e.data.morphAttributes;if(c)for(const m in c){const y=c[m],x=[];for(let _=0,g=y.length;_<g;_++){const b=y[_];let S;if(b.isInterleavedBufferAttribute){const E=r(e.data,b.data);S=new Tl(E,b.itemSize,b.offset,b.normalized)}else{const E=Yc(b.type,b.array);S=new en(E,b.itemSize,b.normalized)}b.name!==void 0&&(S.name=b.name),x.push(S)}a.morphAttributes[m]=x}e.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);const d=e.data.groups||e.data.drawcalls||e.data.offsets;if(d!==void 0)for(let m=0,y=d.length;m!==y;++m){const x=d[m];a.addGroup(x.start,x.count,x.materialIndex)}const p=e.data.boundingSphere;return p!==void 0&&(a.boundingSphere=new ri().fromJSON(p)),e.name&&(a.name=e.name),e.userData&&(a.userData=e.userData),a}}class GN extends ir{constructor(e){super(e)}load(e,t,n,r){const s=this,a=this.path===""?Z_.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||a;const o=new xa(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){let c=null;try{c=JSON.parse(l)}catch(d){r!==void 0&&r(d),console.error("THREE:ObjectLoader: Can't parse "+e+".",d.message);return}const f=c.metadata;if(f===void 0||f.type===void 0||f.type.toLowerCase()==="geometry"){r!==void 0&&r(new Error("THREE.ObjectLoader: Can't load "+e)),console.error("THREE.ObjectLoader: Can't load "+e);return}s.parse(c,t)},n,r)}async loadAsync(e,t){const n=this,r=this.path===""?Z_.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||r;const s=new xa(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials);const a=await s.loadAsync(e,t),o=JSON.parse(a),l=o.metadata;if(l===void 0||l.type===void 0||l.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await n.parseAsync(o)}parse(e,t){const n=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),s=this.parseGeometries(e.geometries,r),a=this.parseImages(e.images,function(){t!==void 0&&t(c)}),o=this.parseTextures(e.textures,a),l=this.parseMaterials(e.materials,o),c=this.parseObject(e.object,s,l,o,n),f=this.parseSkeletons(e.skeletons,c);if(this.bindSkeletons(c,f),this.bindLightTargets(c),t!==void 0){let d=!1;for(const p in a)if(a[p].data instanceof HTMLImageElement){d=!0;break}d===!1&&t(c)}return c}async parseAsync(e){const t=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,n),s=await this.parseImagesAsync(e.images),a=this.parseTextures(e.textures,s),o=this.parseMaterials(e.materials,a),l=this.parseObject(e.object,r,o,a,t),c=this.parseSkeletons(e.skeletons,l);return this.bindSkeletons(l,c),this.bindLightTargets(l),l}parseShapes(e){const t={};if(e!==void 0)for(let n=0,r=e.length;n<r;n++){const s=new bl().fromJSON(e[n]);t[s.uuid]=s}return t}parseSkeletons(e,t){const n={},r={};if(t.traverse(function(s){s.isBone&&(r[s.uuid]=s)}),e!==void 0)for(let s=0,a=e.length;s<a;s++){const o=new Bg().fromJSON(e[s],r);n[o.uuid]=o}return n}parseGeometries(e,t){const n={};if(e!==void 0){const r=new lC;for(let s=0,a=e.length;s<a;s++){let o;const l=e[s];switch(l.type){case"BufferGeometry":case"InstancedBufferGeometry":o=r.parse(l);break;default:l.type in IE?o=IE[l.type].fromJSON(l,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${l.type}"`)}o.uuid=l.uuid,l.name!==void 0&&(o.name=l.name),l.userData!==void 0&&(o.userData=l.userData),n[l.uuid]=o}}return n}parseMaterials(e,t){const n={},r={};if(e!==void 0){const s=new i0;s.setTextures(t);for(let a=0,o=e.length;a<o;a++){const l=e[a];n[l.uuid]===void 0&&(n[l.uuid]=s.parse(l)),r[l.uuid]=n[l.uuid]}}return r}parseAnimations(e){const t={};if(e!==void 0)for(let n=0;n<e.length;n++){const r=e[n],s=Rf.parse(r);t[s.uuid]=s}return t}parseImages(e,t){const n=this,r={};let s;function a(l){return n.manager.itemStart(l),s.load(l,function(){n.manager.itemEnd(l)},void 0,function(){n.manager.itemError(l),n.manager.itemEnd(l)})}function o(l){if(typeof l=="string"){const c=l,f=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(c)?c:n.resourcePath+c;return a(f)}else return l.data?{data:Yc(l.type,l.data),width:l.width,height:l.height}:null}if(e!==void 0&&e.length>0){const l=new h1(t);s=new Df(l),s.setCrossOrigin(this.crossOrigin);for(let c=0,f=e.length;c<f;c++){const d=e[c],p=d.url;if(Array.isArray(p)){const m=[];for(let y=0,x=p.length;y<x;y++){const _=p[y],g=o(_);g!==null&&(g instanceof HTMLImageElement?m.push(g):m.push(new Ts(g.data,g.width,g.height)))}r[d.uuid]=new so(m)}else{const m=o(d.url);r[d.uuid]=new so(m)}}}return r}async parseImagesAsync(e){const t=this,n={};let r;async function s(a){if(typeof a=="string"){const o=a,l=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(o)?o:t.resourcePath+o;return await r.loadAsync(l)}else return a.data?{data:Yc(a.type,a.data),width:a.width,height:a.height}:null}if(e!==void 0&&e.length>0){r=new Df(this.manager),r.setCrossOrigin(this.crossOrigin);for(let a=0,o=e.length;a<o;a++){const l=e[a],c=l.url;if(Array.isArray(c)){const f=[];for(let d=0,p=c.length;d<p;d++){const m=c[d],y=await s(m);y!==null&&(y instanceof HTMLImageElement?f.push(y):f.push(new Ts(y.data,y.width,y.height)))}n[l.uuid]=new so(f)}else{const f=await s(l.url);n[l.uuid]=new so(f)}}}return n}parseTextures(e,t){function n(s,a){return typeof s=="number"?s:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",s),a[s])}const r={};if(e!==void 0)for(let s=0,a=e.length;s<a;s++){const o=e[s];o.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',o.uuid),t[o.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",o.image);const l=t[o.image],c=l.data;let f;Array.isArray(c)?(f=new Yf,c.length===6&&(f.needsUpdate=!0)):(c&&c.data?f=new Ts:f=new An,c&&(f.needsUpdate=!0)),f.source=l,f.uuid=o.uuid,o.name!==void 0&&(f.name=o.name),o.mapping!==void 0&&(f.mapping=n(o.mapping,HN)),o.channel!==void 0&&(f.channel=o.channel),o.offset!==void 0&&f.offset.fromArray(o.offset),o.repeat!==void 0&&f.repeat.fromArray(o.repeat),o.center!==void 0&&f.center.fromArray(o.center),o.rotation!==void 0&&(f.rotation=o.rotation),o.wrap!==void 0&&(f.wrapS=n(o.wrap[0],BE),f.wrapT=n(o.wrap[1],BE)),o.format!==void 0&&(f.format=o.format),o.internalFormat!==void 0&&(f.internalFormat=o.internalFormat),o.type!==void 0&&(f.type=o.type),o.colorSpace!==void 0&&(f.colorSpace=o.colorSpace),o.minFilter!==void 0&&(f.minFilter=n(o.minFilter,kE)),o.magFilter!==void 0&&(f.magFilter=n(o.magFilter,kE)),o.anisotropy!==void 0&&(f.anisotropy=o.anisotropy),o.flipY!==void 0&&(f.flipY=o.flipY),o.generateMipmaps!==void 0&&(f.generateMipmaps=o.generateMipmaps),o.premultiplyAlpha!==void 0&&(f.premultiplyAlpha=o.premultiplyAlpha),o.unpackAlignment!==void 0&&(f.unpackAlignment=o.unpackAlignment),o.compareFunction!==void 0&&(f.compareFunction=o.compareFunction),o.userData!==void 0&&(f.userData=o.userData),r[o.uuid]=f}return r}parseObject(e,t,n,r,s){let a;function o(p){return t[p]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",p),t[p]}function l(p){if(p!==void 0){if(Array.isArray(p)){const m=[];for(let y=0,x=p.length;y<x;y++){const _=p[y];n[_]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",_),m.push(n[_])}return m}return n[p]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",p),n[p]}}function c(p){return r[p]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",p),r[p]}let f,d;switch(e.type){case"Scene":a=new zg,e.background!==void 0&&(Number.isInteger(e.background)?a.background=new et(e.background):a.background=c(e.background)),e.environment!==void 0&&(a.environment=c(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?a.fog=new Pg(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(a.fog=new Ig(e.fog.color,e.fog.density)),e.fog.name!==""&&(a.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(a.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(a.backgroundIntensity=e.backgroundIntensity),e.backgroundRotation!==void 0&&a.backgroundRotation.fromArray(e.backgroundRotation),e.environmentIntensity!==void 0&&(a.environmentIntensity=e.environmentIntensity),e.environmentRotation!==void 0&&a.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":a=new Zn(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(a.focus=e.focus),e.zoom!==void 0&&(a.zoom=e.zoom),e.filmGauge!==void 0&&(a.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(a.filmOffset=e.filmOffset),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case"OrthographicCamera":a=new Pl(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(a.zoom=e.zoom),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case"AmbientLight":a=new rC(e.color,e.intensity);break;case"DirectionalLight":a=new iC(e.color,e.intensity),a.target=e.target||"";break;case"PointLight":a=new nC(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":a=new sC(e.color,e.intensity,e.width,e.height);break;case"SpotLight":a=new tC(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),a.target=e.target||"";break;case"HemisphereLight":a=new eC(e.color,e.groundColor,e.intensity);break;case"LightProbe":a=new oC().fromJSON(e);break;case"SkinnedMesh":f=o(e.geometry),d=l(e.material),a=new S2(f,d),e.bindMode!==void 0&&(a.bindMode=e.bindMode),e.bindMatrix!==void 0&&a.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(a.skeleton=e.skeleton);break;case"Mesh":f=o(e.geometry),d=l(e.material),a=new pn(f,d);break;case"InstancedMesh":f=o(e.geometry),d=l(e.material);const p=e.count,m=e.instanceMatrix,y=e.instanceColor;a=new E2(f,d,p),a.instanceMatrix=new Al(new Float32Array(m.array),16),y!==void 0&&(a.instanceColor=new Al(new Float32Array(y.array),y.itemSize));break;case"BatchedMesh":f=o(e.geometry),d=l(e.material),a=new M2(e.maxInstanceCount,e.maxVertexCount,e.maxIndexCount,d),a.geometry=f,a.perObjectFrustumCulled=e.perObjectFrustumCulled,a.sortObjects=e.sortObjects,a._drawRanges=e.drawRanges,a._reservedRanges=e.reservedRanges,a._geometryInfo=e.geometryInfo.map(x=>{let _=null,g=null;return x.boundingBox!==void 0&&(_=new Jn().fromJSON(x.boundingBox)),x.boundingSphere!==void 0&&(g=new ri().fromJSON(x.boundingSphere)),{...x,boundingBox:_,boundingSphere:g}}),a._instanceInfo=e.instanceInfo,a._availableInstanceIds=e._availableInstanceIds,a._availableGeometryIds=e._availableGeometryIds,a._nextIndexStart=e.nextIndexStart,a._nextVertexStart=e.nextVertexStart,a._geometryCount=e.geometryCount,a._maxInstanceCount=e.maxInstanceCount,a._maxVertexCount=e.maxVertexCount,a._maxIndexCount=e.maxIndexCount,a._geometryInitialized=e.geometryInitialized,a._matricesTexture=c(e.matricesTexture.uuid),a._indirectTexture=c(e.indirectTexture.uuid),e.colorsTexture!==void 0&&(a._colorsTexture=c(e.colorsTexture.uuid)),e.boundingSphere!==void 0&&(a.boundingSphere=new ri().fromJSON(e.boundingSphere)),e.boundingBox!==void 0&&(a.boundingBox=new Jn().fromJSON(e.boundingBox));break;case"LOD":a=new b2;break;case"Line":a=new fo(o(e.geometry),l(e.material));break;case"LineLoop":a=new w2(o(e.geometry),l(e.material));break;case"LineSegments":a=new Ds(o(e.geometry),l(e.material));break;case"PointCloud":case"Points":a=new T2(o(e.geometry),l(e.material));break;case"Sprite":a=new x2(l(e.material));break;case"Group":a=new Zc;break;case"Bone":a=new Qx;break;default:a=new Xt}if(a.uuid=e.uuid,e.name!==void 0&&(a.name=e.name),e.matrix!==void 0?(a.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(e.position!==void 0&&a.position.fromArray(e.position),e.rotation!==void 0&&a.rotation.fromArray(e.rotation),e.quaternion!==void 0&&a.quaternion.fromArray(e.quaternion),e.scale!==void 0&&a.scale.fromArray(e.scale)),e.up!==void 0&&a.up.fromArray(e.up),e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(a.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(a.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(a.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(a.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&a.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(a.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(a.visible=e.visible),e.frustumCulled!==void 0&&(a.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(a.renderOrder=e.renderOrder),e.userData!==void 0&&(a.userData=e.userData),e.layers!==void 0&&(a.layers.mask=e.layers),e.children!==void 0){const p=e.children;for(let m=0;m<p.length;m++)a.add(this.parseObject(p[m],t,n,r,s))}if(e.animations!==void 0){const p=e.animations;for(let m=0;m<p.length;m++){const y=p[m];a.animations.push(s[y])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(a.autoUpdate=e.autoUpdate);const p=e.levels;for(let m=0;m<p.length;m++){const y=p[m],x=a.getObjectByProperty("uuid",y.object);x!==void 0&&a.addLevel(x,y.distance,y.hysteresis)}}return a}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(n){if(n.isSkinnedMesh===!0&&n.skeleton!==void 0){const r=t[n.skeleton];r===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",n.skeleton):n.bind(r,n.bindMatrix)}})}bindLightTargets(e){e.traverse(function(t){if(t.isDirectionalLight||t.isSpotLight){const n=t.target,r=e.getObjectByProperty("uuid",n);r!==void 0?t.target=r:t.target=new Xt}})}}const HN={UVMapping:Mg,CubeReflectionMapping:ya,CubeRefractionMapping:uo,EquirectangularReflectionMapping:pf,EquirectangularRefractionMapping:mf,CubeUVReflectionMapping:_u},BE={RepeatWrapping:gf,ClampToEdgeWrapping:zr,MirroredRepeatWrapping:vf},kE={NearestFilter:yi,NearestMipmapNearestFilter:Ix,NearestMipmapLinearFilter:qc,LinearFilter:Pn,LinearMipmapNearestFilter:Jh,LinearMipmapLinearFilter:Ms},my=new WeakMap;class VN extends ir{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=fa.get(e);if(a!==void 0){if(s.manager.itemStart(e),a.then){a.then(c=>{if(my.has(a)===!0)r&&r(my.get(a)),s.manager.itemError(e),s.manager.itemEnd(e);else return t&&t(c),s.manager.itemEnd(e),c});return}return setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader;const l=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){return fa.add(e,c),t&&t(c),s.manager.itemEnd(e),c}).catch(function(c){r&&r(c),my.set(l,c),fa.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});fa.add(e,l),s.manager.itemStart(e)}}let Ep;class p1{static getContext(){return Ep===void 0&&(Ep=new(window.AudioContext||window.webkitAudioContext)),Ep}static setContext(e){Ep=e}}class WN extends ir{constructor(e){super(e)}load(e,t,n,r){const s=this,a=new xa(this.manager);a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(l){try{const c=l.slice(0);p1.getContext().decodeAudioData(c,function(d){t(d)}).catch(o)}catch(c){o(c)}},n,r);function o(l){r?r(l):console.error(l),s.manager.itemError(e)}}}const GE=new bt,HE=new bt,Jo=new bt;class XN{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Zn,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Zn,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,Jo.copy(e.projectionMatrix);const r=t.eyeSep/2,s=r*t.near/t.focus,a=t.near*Math.tan(xl*t.fov*.5)/t.zoom;let o,l;HE.elements[12]=-r,GE.elements[12]=r,o=-a*t.aspect+s,l=a*t.aspect+s,Jo.elements[0]=2*t.near/(l-o),Jo.elements[8]=(l+o)/(l-o),this.cameraL.projectionMatrix.copy(Jo),o=-a*t.aspect-s,l=a*t.aspect-s,Jo.elements[0]=2*t.near/(l-o),Jo.elements[8]=(l+o)/(l-o),this.cameraR.projectionMatrix.copy(Jo)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(HE),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(GE)}}class cC extends Zn{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class m1{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=VE(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=VE();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function VE(){return performance.now()}const Qo=new J,gy=new _i,jN=new J,$o=new J,el=new J;class qN extends Xt{constructor(){super(),this.type="AudioListener",this.context=p1.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new m1}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Qo,gy,jN),$o.set(0,0,-1).applyQuaternion(gy),el.set(0,1,0).applyQuaternion(gy),t.positionX){const n=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Qo.x,n),t.positionY.linearRampToValueAtTime(Qo.y,n),t.positionZ.linearRampToValueAtTime(Qo.z,n),t.forwardX.linearRampToValueAtTime($o.x,n),t.forwardY.linearRampToValueAtTime($o.y,n),t.forwardZ.linearRampToValueAtTime($o.z,n),t.upX.linearRampToValueAtTime(el.x,n),t.upY.linearRampToValueAtTime(el.y,n),t.upZ.linearRampToValueAtTime(el.z,n)}else t.setPosition(Qo.x,Qo.y,Qo.z),t.setOrientation($o.x,$o.y,$o.z,el.x,el.y,el.z)}}class uC extends Xt{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(e=0){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,this.isPlaying===!0&&this.source.detune!==void 0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1,this._progress=0}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}copy(e,t){return super.copy(e,t),e.sourceType!=="buffer"?(console.warn("THREE.Audio: Audio source type cannot be copied."),this):(this.autoplay=e.autoplay,this.buffer=e.buffer,this.detune=e.detune,this.loop=e.loop,this.loopStart=e.loopStart,this.loopEnd=e.loopEnd,this.offset=e.offset,this.duration=e.duration,this.playbackRate=e.playbackRate,this.hasPlaybackControl=e.hasPlaybackControl,this.sourceType=e.sourceType,this.filters=e.filters.slice(),this)}clone(e){return new this.constructor(this.listener).copy(this,e)}}const tl=new J,WE=new _i,YN=new J,nl=new J;class ZN extends uC{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){return super.connect(),this.panner.connect(this.gain),this}disconnect(){return super.disconnect(),this.panner.disconnect(this.gain),this}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,n){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=n,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(tl,WE,YN),nl.set(0,0,1).applyQuaternion(WE);const t=this.panner;if(t.positionX){const n=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(tl.x,n),t.positionY.linearRampToValueAtTime(tl.y,n),t.positionZ.linearRampToValueAtTime(tl.z,n),t.orientationX.linearRampToValueAtTime(nl.x,n),t.orientationY.linearRampToValueAtTime(nl.y,n),t.orientationZ.linearRampToValueAtTime(nl.z,n)}else t.setPosition(tl.x,tl.y,tl.z),t.setOrientation(nl.x,nl.y,nl.z)}}class KN{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0;const t=this.getFrequencyData();for(let n=0;n<t.length;n++)e+=t[n];return e/t.length}}class hC{constructor(e,t,n){this.binding=e,this.valueSize=n;let r,s,a;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:r=this._lerp,s=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const n=this.buffer,r=this.valueSize,s=e*r+r;let a=this.cumulativeWeight;if(a===0){for(let o=0;o!==r;++o)n[s+o]=n[o];a=t}else{a+=t;const o=t/a;this._mixBufferRegion(n,s,0,o,r)}this.cumulativeWeight=a}accumulateAdditive(e){const t=this.buffer,n=this.valueSize,r=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,n=this.buffer,r=e*t+t,s=this.cumulativeWeight,a=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){const l=t*this._origIndex;this._mixBufferRegion(n,r,l,1-s,t)}a>0&&this._mixBufferRegionAdditive(n,r,this._addIndex*t,1,t);for(let l=t,c=t+t;l!==c;++l)if(n[l]!==n[l+t]){o.setValue(n,r);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,r=n*this._origIndex;e.getValue(t,r);for(let s=n,a=r;s!==a;++s)t[s]=t[r+s%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,r,s){if(r>=.5)for(let a=0;a!==s;++a)e[t+a]=e[n+a]}_slerp(e,t,n,r){_i.slerpFlat(e,t,e,t,e,n,r)}_slerpAdditive(e,t,n,r,s){const a=this._workIndex*s;_i.multiplyQuaternionsFlat(e,a,e,t,e,n),_i.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,n,r,s){const a=1-r;for(let o=0;o!==s;++o){const l=t+o;e[l]=e[l]*a+e[n+o]*r}}_lerpAdditive(e,t,n,r,s){for(let a=0;a!==s;++a){const o=t+a;e[o]=e[o]+e[n+a]*r}}}const g1="\\[\\]\\.:\\/",JN=new RegExp("["+g1+"]","g"),v1="[^"+g1+"]",QN="[^"+g1.replace("\\.","")+"]",$N=/((?:WC+[\/:])*)/.source.replace("WC",v1),eI=/(WCOD+)?/.source.replace("WCOD",QN),tI=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",v1),nI=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",v1),iI=new RegExp("^"+$N+eI+tI+nI+"$"),rI=["material","materials","bones","map"];class sI{constructor(e,t,n){const r=n||Wt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=n.length;r!==s;++r)n[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class Wt{constructor(e,t,n){this.path=t,this.parsedPath=n||Wt.parseTrackName(t),this.node=Wt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new Wt.Composite(e,t,n):new Wt(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(JN,"")}static parseTrackName(e){const t=iI.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){const s=n.nodeName.substring(r+1);rI.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(s){for(let a=0;a<s.length;a++){const o=s[a];if(o.name===t||o.uuid===t)return o;const l=n(o.children);if(l)return l}return null},r=n(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)e[t++]=n[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,r=t.propertyName;let s=t.propertyIndex;if(e||(e=Wt.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let f=0;f<e.length;f++)if(e[f].name===c){c=f;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const a=e[r];if(a===void 0){const c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+r+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=r;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Wt.Composite=sI;Wt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Wt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Wt.prototype.GetterByBindingType=[Wt.prototype._getValue_direct,Wt.prototype._getValue_array,Wt.prototype._getValue_arrayElement,Wt.prototype._getValue_toArray];Wt.prototype.SetterByBindingTypeAndVersioning=[[Wt.prototype._setValue_direct,Wt.prototype._setValue_direct_setNeedsUpdate,Wt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Wt.prototype._setValue_array,Wt.prototype._setValue_array_setNeedsUpdate,Wt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Wt.prototype._setValue_arrayElement,Wt.prototype._setValue_arrayElement_setNeedsUpdate,Wt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Wt.prototype._setValue_fromArray,Wt.prototype._setValue_fromArray_setNeedsUpdate,Wt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class aI{constructor(){this.isAnimationObjectGroup=!0,this.uuid=vr(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let n=0,r=arguments.length;n!==r;++n)e[arguments[n].uuid]=n;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){const e=this._objects,t=this._indicesByUUID,n=this._paths,r=this._parsedPaths,s=this._bindings,a=s.length;let o,l=e.length,c=this.nCachedObjects_;for(let f=0,d=arguments.length;f!==d;++f){const p=arguments[f],m=p.uuid;let y=t[m];if(y===void 0){y=l++,t[m]=y,e.push(p);for(let x=0,_=a;x!==_;++x)s[x].push(new Wt(p,n[x],r[x]))}else if(y<c){o=e[y];const x=--c,_=e[x];t[_.uuid]=y,e[y]=_,t[m]=x,e[x]=p;for(let g=0,b=a;g!==b;++g){const S=s[g],E=S[x];let w=S[y];S[y]=E,w===void 0&&(w=new Wt(p,n[g],r[g])),S[x]=w}}else e[y]!==o&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=c}remove(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,r=n.length;let s=this.nCachedObjects_;for(let a=0,o=arguments.length;a!==o;++a){const l=arguments[a],c=l.uuid,f=t[c];if(f!==void 0&&f>=s){const d=s++,p=e[d];t[p.uuid]=f,e[f]=p,t[c]=d,e[d]=l;for(let m=0,y=r;m!==y;++m){const x=n[m],_=x[d],g=x[f];x[f]=_,x[d]=g}}}this.nCachedObjects_=s}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,r=n.length;let s=this.nCachedObjects_,a=e.length;for(let o=0,l=arguments.length;o!==l;++o){const c=arguments[o],f=c.uuid,d=t[f];if(d!==void 0)if(delete t[f],d<s){const p=--s,m=e[p],y=--a,x=e[y];t[m.uuid]=d,e[d]=m,t[x.uuid]=p,e[p]=x,e.pop();for(let _=0,g=r;_!==g;++_){const b=n[_],S=b[p],E=b[y];b[d]=S,b[p]=E,b.pop()}}else{const p=--a,m=e[p];p>0&&(t[m.uuid]=d),e[d]=m,e.pop();for(let y=0,x=r;y!==x;++y){const _=n[y];_[d]=_[p],_.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){const n=this._bindingsIndicesByPath;let r=n[e];const s=this._bindings;if(r!==void 0)return s[r];const a=this._paths,o=this._parsedPaths,l=this._objects,c=l.length,f=this.nCachedObjects_,d=new Array(c);r=s.length,n[e]=r,a.push(e),o.push(t),s.push(d);for(let p=f,m=l.length;p!==m;++p){const y=l[p];d[p]=new Wt(y,e,t)}return d}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){const r=this._paths,s=this._parsedPaths,a=this._bindings,o=a.length-1,l=a[o],c=e[o];t[c]=n,a[n]=l,a.pop(),s[n]=s[o],s.pop(),r[n]=r[o],r.pop()}}}class fC{constructor(e,t,n=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=r;const s=t.tracks,a=s.length,o=new Array(a),l={endingStart:pl,endingEnd:pl};for(let c=0;c!==a;++c){const f=s[c].createInterpolant(null);o[c]=f,f.settings=l}this._interpolantSettings=l,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=t2,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n=!1){if(e.fadeOut(t),this.fadeIn(t),n===!0){const r=this._clip.duration,s=e._clip.duration,a=s/r,o=r/s;e.warp(1,a,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,n=!1){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const r=this._mixer,s=r.time,a=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=r._lendControlInterpolant(),this._timeScaleInterpolant=o);const l=o.parameterPositions,c=o.sampleValues;return l[0]=s,l[1]=s+n,c[0]=e/a,c[1]=t/a,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,r){if(!this.enabled){this._updateWeight(e);return}const s=this._startTime;if(s!==null){const l=(e-s)*n;l<0||n===0?t=0:(this._startTime=null,t=n*l)}t*=this._updateTimeScale(e);const a=this._updateTime(t),o=this._updateWeight(e);if(o>0){const l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case Vx:for(let f=0,d=l.length;f!==d;++f)l[f].evaluate(a),c[f].accumulateAdditive(o);break;case Ug:default:for(let f=0,d=l.length;f!==d;++f)l[f].evaluate(a),c[f].accumulate(r,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(n!==null){const r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;if(n!==null){const r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let r=this.time+e,s=this._loopCount;const a=n===n2;if(e===0)return s===-1?r:a&&(s&1)===1?t-r:r;if(n===e2){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),r>=t||r<0){const o=Math.floor(r/t);r-=t*o,s+=Math.abs(o);const l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){const c=e<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=r;if(a&&(s&1)===1)return t-r}return r}_setEndings(e,t,n){const r=this._interpolantSettings;n?(r.endingStart=ml,r.endingEnd=ml):(e?r.endingStart=this.zeroSlopeAtStart?ml:pl:r.endingStart=_f,t?r.endingEnd=this.zeroSlopeAtEnd?ml:pl:r.endingEnd=_f)}_scheduleFading(e,t,n){const r=this._mixer,s=r.time;let a=this._weightInterpolant;a===null&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=s,l[0]=t,o[1]=s+e,l[1]=n,this}}const oI=new Float32Array(1);class lI extends Rs{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,r=e._clip.tracks,s=r.length,a=e._propertyBindings,o=e._interpolants,l=n.uuid,c=this._bindingsByRootAndName;let f=c[l];f===void 0&&(f={},c[l]=f);for(let d=0;d!==s;++d){const p=r[d],m=p.name;let y=f[m];if(y!==void 0)++y.referenceCount,a[d]=y;else{if(y=a[d],y!==void 0){y._cacheIndex===null&&(++y.referenceCount,this._addInactiveBinding(y,l,m));continue}const x=t&&t._propertyBindings[d].binding.parsedPath;y=new hC(Wt.create(n,m,x),p.ValueTypeName,p.getValueSize()),++y.referenceCount,this._addInactiveBinding(y,l,m),a[d]=y}o[d].resultBuffer=y.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const n=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,n)}const t=e._propertyBindings;for(let n=0,r=t.length;n!==r;++n){const s=t[n];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let n=0,r=t.length;n!==r;++n){const s=t[n];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){const r=this._actions,s=this._actionsByClip;let a=s[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=a;else{const o=a.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=r.length,r.push(e),a.actionByRoot[n]=e}_removeInactiveAction(e){const t=this._actions,n=t[t.length-1],r=e._cacheIndex;n._cacheIndex=r,t[r]=n,t.pop(),e._cacheIndex=null;const s=e._clip.uuid,a=this._actionsByClip,o=a[s],l=o.knownActions,c=l[l.length-1],f=e._byClipCacheIndex;c._byClipCacheIndex=f,l[f]=c,l.pop(),e._byClipCacheIndex=null;const d=o.actionByRoot,p=(e._localRoot||this._root).uuid;delete d[p],l.length===0&&delete a[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let n=0,r=t.length;n!==r;++n){const s=t[n];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){const t=this._actions,n=e._cacheIndex,r=this._nActiveActions++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=n,t[n]=s}_takeBackAction(e){const t=this._actions,n=e._cacheIndex,r=--this._nActiveActions,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=n,t[n]=s}_addInactiveBinding(e,t,n){const r=this._bindingsByRootAndName,s=this._bindings;let a=r[t];a===void 0&&(a={},r[t]=a),a[n]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){const t=this._bindings,n=e.binding,r=n.rootNode.uuid,s=n.path,a=this._bindingsByRootAndName,o=a[r],l=t[t.length-1],c=e._cacheIndex;l._cacheIndex=c,t[c]=l,t.pop(),delete o[s],Object.keys(o).length===0&&delete a[r]}_lendBinding(e){const t=this._bindings,n=e._cacheIndex,r=this._nActiveBindings++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=n,t[n]=s}_takeBackBinding(e){const t=this._bindings,n=e._cacheIndex,r=--this._nActiveBindings,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=n,t[n]=s}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let n=e[t];return n===void 0&&(n=new c1(new Float32Array(2),new Float32Array(2),1,oI),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){const t=this._controlInterpolants,n=e.__cacheIndex,r=--this._nActiveControlInterpolants,s=t[r];e.__cacheIndex=r,t[r]=e,s.__cacheIndex=n,t[n]=s}clipAction(e,t,n){const r=t||this._root,s=r.uuid;let a=typeof e=="string"?Rf.findByName(r,e):e;const o=a!==null?a.uuid:e,l=this._actionsByClip[o];let c=null;if(n===void 0&&(a!==null?n=a.blendMode:n=Ug),l!==void 0){const d=l.actionByRoot[s];if(d!==void 0&&d.blendMode===n)return d;c=l.knownActions[0],a===null&&(a=c._clip)}if(a===null)return null;const f=new fC(this,a,t,n);return this._bindAction(f,c),this._addInactiveAction(f,o,s),f}existingAction(e,t){const n=t||this._root,r=n.uuid,s=typeof e=="string"?Rf.findByName(n,e):e,a=s?s.uuid:e,o=this._actionsByClip[a];return o!==void 0&&o.actionByRoot[r]||null}stopAllAction(){const e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,r=this.time+=e,s=Math.sign(e),a=this._accuIndex^=1;for(let c=0;c!==n;++c)t[c]._update(r,e,s,a);const o=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)o[c].apply(a);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,n=e.uuid,r=this._actionsByClip,s=r[n];if(s!==void 0){const a=s.knownActions;for(let o=0,l=a.length;o!==l;++o){const c=a[o];this._deactivateAction(c);const f=c._cacheIndex,d=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,d._cacheIndex=f,t[f]=d,t.pop(),this._removeInactiveBindingsForAction(c)}delete r[n]}}uncacheRoot(e){const t=e.uuid,n=this._actionsByClip;for(const a in n){const o=n[a].actionByRoot,l=o[t];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}const r=this._bindingsByRootAndName,s=r[t];if(s!==void 0)for(const a in s){const o=s[a];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){const n=this.existingAction(e,t);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}}class cI extends qx{constructor(e=1,t=1,n=1,r={}){super(e,t,r),this.isRenderTarget3D=!0,this.depth=n,this.texture=new Lg(null,e,t,n),this._setTextureOptions(r),this.texture.isRenderTargetTexture=!0}}class y1{constructor(e){this.value=e}clone(){return new y1(this.value.clone===void 0?this.value:this.value.clone())}}let uI=0;class hI extends Rs{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:uI++}),this.name="",this.usage=bf,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){this.dispatchEvent({type:"dispose"})}copy(e){this.name=e.name,this.usage=e.usage;const t=e.uniforms;this.uniforms.length=0;for(let n=0,r=t.length;n<r;n++){const s=Array.isArray(t[n])?t[n]:[t[n]];for(let a=0;a<s.length;a++)this.uniforms.push(s[a].clone())}return this}clone(){return new this.constructor().copy(this)}}class fI extends Fg{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}class dI{constructor(e,t,n,r,s){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=n,this.elementSize=r,this.count=s,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}}const XE=new bt;class _1{constructor(e,t,n=0,r=1/0){this.ray=new bu(e,t),this.near=n,this.far=r,this.camera=null,this.layers=new cu,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return XE.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(XE),this}intersectObject(e,t=!0,n=[]){return K_(e,this,n,t),n.sort(jE),n}intersectObjects(e,t=!0,n=[]){for(let r=0,s=e.length;r<s;r++)K_(e[r],this,n,t);return n.sort(jE),n}}function jE(i,e){return i.distance-e.distance}function K_(i,e,t,n){let r=!0;if(i.layers.test(e.layers)&&i.raycast(e,t)===!1&&(r=!1),r===!0&&n===!0){const s=i.children;for(let a=0,o=s.length;a<o;a++)K_(s[a],e,t,!0)}}class dC{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Tt(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(Tt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class pI{constructor(e=1,t=0,n=0){this.radius=e,this.theta=t,this.y=n}set(e,t,n){return this.radius=e,this.theta=t,this.y=n,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+n*n),this.theta=Math.atan2(e,n),this.y=t,this}clone(){return new this.constructor().copy(this)}}class x1{constructor(e,t,n,r){x1.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,r)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,r){const s=this.elements;return s[0]=e,s[2]=t,s[1]=n,s[3]=r,this}}const qE=new Ge;class mI{constructor(e=new Ge(1/0,1/0),t=new Ge(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=qE.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,qE).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const YE=new J,Mp=new J;class gI{constructor(e=new J,t=new J){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){YE.subVectors(e,this.start),Mp.subVectors(this.end,this.start);const n=Mp.dot(Mp);let s=Mp.dot(YE)/n;return t&&(s=Tt(s,0,1)),s}closestPointToPoint(e,t,n){const r=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const ZE=new J;class vI extends Xt{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const n=new Ct,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let a=0,o=1,l=32;a<l;a++,o++){const c=a/l*Math.PI*2,f=o/l*Math.PI*2;r.push(Math.cos(c),Math.sin(c),1,Math.cos(f),Math.sin(f),1)}n.setAttribute("position",new dt(r,3));const s=new Gi({fog:!1,toneMapped:!1});this.cone=new Ds(n,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);const e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),ZE.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(ZE),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const eo=new J,wp=new bt,vy=new bt;class yI extends Ds{constructor(e){const t=pC(e),n=new Ct,r=[],s=[],a=new et(0,0,1),o=new et(0,1,0);for(let c=0;c<t.length;c++){const f=t[c];f.parent&&f.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),s.push(a.r,a.g,a.b),s.push(o.r,o.g,o.b))}n.setAttribute("position",new dt(r,3)),n.setAttribute("color",new dt(s,3));const l=new Gi({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(n,l),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){const t=this.bones,n=this.geometry,r=n.getAttribute("position");vy.copy(this.root.matrixWorld).invert();for(let s=0,a=0;s<t.length;s++){const o=t[s];o.parent&&o.parent.isBone&&(wp.multiplyMatrices(vy,o.matrixWorld),eo.setFromMatrixPosition(wp),r.setXYZ(a,eo.x,eo.y,eo.z),wp.multiplyMatrices(vy,o.parent.matrixWorld),eo.setFromMatrixPosition(wp),r.setXYZ(a+1,eo.x,eo.y,eo.z),a+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}}function pC(i){const e=[];i.isBone===!0&&e.push(i);for(let t=0;t<i.children.length;t++)e.push(...pC(i.children[t]));return e}class _I extends pn{constructor(e,t,n){const r=new Jf(t,4,2),s=new Sa({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=e,this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const xI=new J,KE=new et,JE=new et;class bI extends Xt{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="HemisphereLightHelper";const r=new Kf(t);r.rotateY(Math.PI*.5),this.material=new Sa({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const s=r.getAttribute("position"),a=new Float32Array(s.count*3);r.setAttribute("color",new en(a,3)),this.add(new pn(r,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");KE.copy(this.light.color),JE.copy(this.light.groundColor);for(let n=0,r=t.count;n<r;n++){const s=n<r/2?KE:JE;t.setXYZ(n,s.r,s.g,s.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(xI.setFromMatrixPosition(this.light.matrixWorld).negate())}}class SI extends Ds{constructor(e=10,t=10,n=4473924,r=8947848){n=new et(n),r=new et(r);const s=t/2,a=e/t,o=e/2,l=[],c=[];for(let p=0,m=0,y=-o;p<=t;p++,y+=a){l.push(-o,0,y,o,0,y),l.push(y,0,-o,y,0,o);const x=p===s?n:r;x.toArray(c,m),m+=3,x.toArray(c,m),m+=3,x.toArray(c,m),m+=3,x.toArray(c,m),m+=3}const f=new Ct;f.setAttribute("position",new dt(l,3)),f.setAttribute("color",new dt(c,3));const d=new Gi({vertexColors:!0,toneMapped:!1});super(f,d),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class EI extends Ds{constructor(e=10,t=16,n=8,r=64,s=4473924,a=8947848){s=new et(s),a=new et(a);const o=[],l=[];if(t>1)for(let d=0;d<t;d++){const p=d/t*(Math.PI*2),m=Math.sin(p)*e,y=Math.cos(p)*e;o.push(0,0,0),o.push(m,0,y);const x=d&1?s:a;l.push(x.r,x.g,x.b),l.push(x.r,x.g,x.b)}for(let d=0;d<n;d++){const p=d&1?s:a,m=e-e/n*d;for(let y=0;y<r;y++){let x=y/r*(Math.PI*2),_=Math.sin(x)*m,g=Math.cos(x)*m;o.push(_,0,g),l.push(p.r,p.g,p.b),x=(y+1)/r*(Math.PI*2),_=Math.sin(x)*m,g=Math.cos(x)*m,o.push(_,0,g),l.push(p.r,p.g,p.b)}}const c=new Ct;c.setAttribute("position",new dt(o,3)),c.setAttribute("color",new dt(l,3));const f=new Gi({vertexColors:!0,toneMapped:!1});super(c,f),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const QE=new J,Tp=new J,$E=new J;class MI extends Xt{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new Ct;r.setAttribute("position",new dt([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const s=new Gi({fog:!1,toneMapped:!1});this.lightPlane=new fo(r,s),this.add(this.lightPlane),r=new Ct,r.setAttribute("position",new dt([0,0,0,0,0,1],3)),this.targetLine=new fo(r,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),QE.setFromMatrixPosition(this.light.matrixWorld),Tp.setFromMatrixPosition(this.light.target.matrixWorld),$E.subVectors(Tp,QE),this.lightPlane.lookAt(Tp),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(Tp),this.targetLine.scale.z=$E.length()}}const Ap=new J,Nn=new Ng;class wI extends Ds{constructor(e){const t=new Ct,n=new Gi({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],a={};o("n1","n2"),o("n2","n4"),o("n4","n3"),o("n3","n1"),o("f1","f2"),o("f2","f4"),o("f4","f3"),o("f3","f1"),o("n1","f1"),o("n2","f2"),o("n3","f3"),o("n4","f4"),o("p","n1"),o("p","n2"),o("p","n3"),o("p","n4"),o("u1","u2"),o("u2","u3"),o("u3","u1"),o("c","t"),o("p","c"),o("cn1","cn2"),o("cn3","cn4"),o("cf1","cf2"),o("cf3","cf4");function o(y,x){l(y),l(x)}function l(y){r.push(0,0,0),s.push(0,0,0),a[y]===void 0&&(a[y]=[]),a[y].push(r.length/3-1)}t.setAttribute("position",new dt(r,3)),t.setAttribute("color",new dt(s,3)),super(t,n),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update();const c=new et(16755200),f=new et(16711680),d=new et(43775),p=new et(16777215),m=new et(3355443);this.setColors(c,f,d,p,m)}setColors(e,t,n,r,s){const o=this.geometry.getAttribute("color");o.setXYZ(0,e.r,e.g,e.b),o.setXYZ(1,e.r,e.g,e.b),o.setXYZ(2,e.r,e.g,e.b),o.setXYZ(3,e.r,e.g,e.b),o.setXYZ(4,e.r,e.g,e.b),o.setXYZ(5,e.r,e.g,e.b),o.setXYZ(6,e.r,e.g,e.b),o.setXYZ(7,e.r,e.g,e.b),o.setXYZ(8,e.r,e.g,e.b),o.setXYZ(9,e.r,e.g,e.b),o.setXYZ(10,e.r,e.g,e.b),o.setXYZ(11,e.r,e.g,e.b),o.setXYZ(12,e.r,e.g,e.b),o.setXYZ(13,e.r,e.g,e.b),o.setXYZ(14,e.r,e.g,e.b),o.setXYZ(15,e.r,e.g,e.b),o.setXYZ(16,e.r,e.g,e.b),o.setXYZ(17,e.r,e.g,e.b),o.setXYZ(18,e.r,e.g,e.b),o.setXYZ(19,e.r,e.g,e.b),o.setXYZ(20,e.r,e.g,e.b),o.setXYZ(21,e.r,e.g,e.b),o.setXYZ(22,e.r,e.g,e.b),o.setXYZ(23,e.r,e.g,e.b),o.setXYZ(24,t.r,t.g,t.b),o.setXYZ(25,t.r,t.g,t.b),o.setXYZ(26,t.r,t.g,t.b),o.setXYZ(27,t.r,t.g,t.b),o.setXYZ(28,t.r,t.g,t.b),o.setXYZ(29,t.r,t.g,t.b),o.setXYZ(30,t.r,t.g,t.b),o.setXYZ(31,t.r,t.g,t.b),o.setXYZ(32,n.r,n.g,n.b),o.setXYZ(33,n.r,n.g,n.b),o.setXYZ(34,n.r,n.g,n.b),o.setXYZ(35,n.r,n.g,n.b),o.setXYZ(36,n.r,n.g,n.b),o.setXYZ(37,n.r,n.g,n.b),o.setXYZ(38,r.r,r.g,r.b),o.setXYZ(39,r.r,r.g,r.b),o.setXYZ(40,s.r,s.g,s.b),o.setXYZ(41,s.r,s.g,s.b),o.setXYZ(42,s.r,s.g,s.b),o.setXYZ(43,s.r,s.g,s.b),o.setXYZ(44,s.r,s.g,s.b),o.setXYZ(45,s.r,s.g,s.b),o.setXYZ(46,s.r,s.g,s.b),o.setXYZ(47,s.r,s.g,s.b),o.setXYZ(48,s.r,s.g,s.b),o.setXYZ(49,s.r,s.g,s.b),o.needsUpdate=!0}update(){const e=this.geometry,t=this.pointMap,n=1,r=1;Nn.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse);const s=this.camera.coordinateSystem===Fr?-1:0;Fn("c",t,e,Nn,0,0,s),Fn("t",t,e,Nn,0,0,1),Fn("n1",t,e,Nn,-1,-1,s),Fn("n2",t,e,Nn,n,-1,s),Fn("n3",t,e,Nn,-1,r,s),Fn("n4",t,e,Nn,n,r,s),Fn("f1",t,e,Nn,-1,-1,1),Fn("f2",t,e,Nn,n,-1,1),Fn("f3",t,e,Nn,-1,r,1),Fn("f4",t,e,Nn,n,r,1),Fn("u1",t,e,Nn,n*.7,r*1.1,s),Fn("u2",t,e,Nn,-1*.7,r*1.1,s),Fn("u3",t,e,Nn,0,r*2,s),Fn("cf1",t,e,Nn,-1,0,1),Fn("cf2",t,e,Nn,n,0,1),Fn("cf3",t,e,Nn,0,-1,1),Fn("cf4",t,e,Nn,0,r,1),Fn("cn1",t,e,Nn,-1,0,s),Fn("cn2",t,e,Nn,n,0,s),Fn("cn3",t,e,Nn,0,-1,s),Fn("cn4",t,e,Nn,0,r,s),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function Fn(i,e,t,n,r,s,a){Ap.set(r,s,a).unproject(n);const o=e[i];if(o!==void 0){const l=t.getAttribute("position");for(let c=0,f=o.length;c<f;c++)l.setXYZ(o[c],Ap.x,Ap.y,Ap.z)}}const Cp=new Jn;class TI extends Ds{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new Float32Array(8*3),s=new Ct;s.setIndex(new en(n,1)),s.setAttribute("position",new en(r,3)),super(s,new Gi({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(this.object!==void 0&&Cp.setFromObject(this.object),Cp.isEmpty())return;const e=Cp.min,t=Cp.max,n=this.geometry.attributes.position,r=n.array;r[0]=t.x,r[1]=t.y,r[2]=t.z,r[3]=e.x,r[4]=t.y,r[5]=t.z,r[6]=e.x,r[7]=e.y,r[8]=t.z,r[9]=t.x,r[10]=e.y,r[11]=t.z,r[12]=t.x,r[13]=t.y,r[14]=e.z,r[15]=e.x,r[16]=t.y,r[17]=e.z,r[18]=e.x,r[19]=e.y,r[20]=e.z,r[21]=t.x,r[22]=e.y,r[23]=e.z,n.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class AI extends Ds{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new Ct;s.setIndex(new en(n,1)),s.setAttribute("position",new dt(r,3)),super(s,new Gi({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}}class CI extends fo{constructor(e,t=1,n=16776960){const r=n,s=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],a=new Ct;a.setAttribute("position",new dt(s,3)),a.computeBoundingSphere(),super(a,new Gi({color:r,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const o=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],l=new Ct;l.setAttribute("position",new dt(o,3)),l.computeBoundingSphere(),this.add(new pn(l,new Sa({color:r,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const eM=new J;let Rp,yy;class RI extends Xt{constructor(e=new J(0,0,1),t=new J(0,0,0),n=1,r=16776960,s=n*.2,a=s*.2){super(),this.type="ArrowHelper",Rp===void 0&&(Rp=new Ct,Rp.setAttribute("position",new dt([0,0,0,0,1,0],3)),yy=new Zf(.5,1,5,1),yy.translate(0,-.5,0)),this.position.copy(t),this.line=new fo(Rp,new Gi({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new pn(yy,new Sa({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(n,s,a)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{eM.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(eM,t)}}setLength(e,t=e*.2,n=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class DI extends Ds{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new Ct;r.setAttribute("position",new dt(t,3)),r.setAttribute("color",new dt(n,3));const s=new Gi({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,n){const r=new et,s=this.geometry.attributes.color.array;return r.set(e),r.toArray(s,0),r.toArray(s,3),r.set(t),r.toArray(s,6),r.toArray(s,9),r.set(n),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class UI{constructor(){this.type="ShapePath",this.color=new et,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new tg,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,r){return this.currentPath.quadraticCurveTo(e,t,n,r),this}bezierCurveTo(e,t,n,r,s,a){return this.currentPath.bezierCurveTo(e,t,n,r,s,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(g){const b=[];for(let S=0,E=g.length;S<E;S++){const w=g[S],T=new bl;T.curves=w.curves,b.push(T)}return b}function n(g,b){const S=b.length;let E=!1;for(let w=S-1,T=0;T<S;w=T++){let R=b[w],U=b[T],D=U.x-R.x,C=U.y-R.y;if(Math.abs(C)>Number.EPSILON){if(C<0&&(R=b[T],D=-D,U=b[w],C=-C),g.y<R.y||g.y>U.y)continue;if(g.y===R.y){if(g.x===R.x)return!0}else{const P=C*(g.x-R.x)-D*(g.y-R.y);if(P===0)return!0;if(P<0)continue;E=!E}}else{if(g.y!==R.y)continue;if(U.x<=g.x&&g.x<=R.x||R.x<=g.x&&g.x<=U.x)return!0}}return E}const r=as.isClockWise,s=this.subPaths;if(s.length===0)return[];let a,o,l;const c=[];if(s.length===1)return o=s[0],l=new bl,l.curves=o.curves,c.push(l),c;let f=!r(s[0].getPoints());f=e?!f:f;const d=[],p=[];let m=[],y=0,x;p[y]=void 0,m[y]=[];for(let g=0,b=s.length;g<b;g++)o=s[g],x=o.getPoints(),a=r(x),a=e?!a:a,a?(!f&&p[y]&&y++,p[y]={s:new bl,p:x},p[y].s.curves=o.curves,f&&y++,m[y]=[]):m[y].push({h:o,p:x[0]});if(!p[0])return t(s);if(p.length>1){let g=!1,b=0;for(let S=0,E=p.length;S<E;S++)d[S]=[];for(let S=0,E=p.length;S<E;S++){const w=m[S];for(let T=0;T<w.length;T++){const R=w[T];let U=!0;for(let D=0;D<p.length;D++)n(R.p,p[D].p)&&(S!==D&&b++,U?(U=!1,d[D].push(R)):g=!0);U&&d[S].push(R)}}b>0&&g===!1&&(m=d)}let _;for(let g=0,b=p.length;g<b;g++){l=p[g].s,c.push(l),_=m[g];for(let S=0,E=_.length;S<E;S++)l.holes.push(_[S].h)}return c}}let OI=class extends Rs{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){console.warn("THREE.Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}};function LI(i,e){const t=i.image&&i.image.width?i.image.width/i.image.height:1;return t>e?(i.repeat.x=1,i.repeat.y=t/e,i.offset.x=0,i.offset.y=(1-i.repeat.y)/2):(i.repeat.x=e/t,i.repeat.y=1,i.offset.x=(1-i.repeat.x)/2,i.offset.y=0),i}function NI(i,e){const t=i.image&&i.image.width?i.image.width/i.image.height:1;return t>e?(i.repeat.x=e/t,i.repeat.y=1,i.offset.x=(1-i.repeat.x)/2,i.offset.y=0):(i.repeat.x=1,i.repeat.y=t/e,i.offset.x=0,i.offset.y=(1-i.repeat.y)/2),i}function II(i){return i.repeat.x=1,i.repeat.y=1,i.offset.x=0,i.offset.y=0,i}function J_(i,e,t,n){const r=PI(n);switch(t){case Bx:return i*e;case Cg:return i*e/r.components*r.byteLength;case qf:return i*e/r.components*r.byteLength;case Gx:return i*e*2/r.components*r.byteLength;case Rg:return i*e*2/r.components*r.byteLength;case kx:return i*e*3/r.components*r.byteLength;case Di:return i*e*4/r.components*r.byteLength;case Dg:return i*e*4/r.components*r.byteLength;case Qh:case $h:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case ef:case tf:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case wm:case Am:return Math.max(i,16)*Math.max(e,8)/4;case Mm:case Tm:return Math.max(i,8)*Math.max(e,8)/2;case Cm:case Rm:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Dm:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Um:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Om:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case Lm:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case Nm:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case Im:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case Pm:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case zm:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case Fm:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case Bm:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case km:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case Gm:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case Hm:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case Vm:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case Wm:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case nf:case Xm:case jm:return Math.ceil(i/4)*Math.ceil(e/4)*16;case Hx:case qm:return Math.ceil(i/4)*Math.ceil(e/4)*8;case Ym:case Zm:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function PI(i){switch(i){case Gr:case Px:return{byteLength:1,components:1};case ru:case zx:case xu:return{byteLength:2,components:1};case Tg:case Ag:return{byteLength:2,components:4};case _a:case wg:case tr:return{byteLength:4,components:1};case Fx:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}class zI{static contain(e,t){return LI(e,t)}static cover(e,t){return NI(e,t)}static fill(e){return II(e)}static getByteLength(e,t,n,r){return J_(e,t,n,r)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Sg}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Sg);/**
|
|
44
|
+
`},r=new Ea(5,5,5),s=new ls({name:"CubemapFromEquirect",uniforms:uu(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:ki,blending:da});s.uniforms.tEquirect.value=t;const a=new pn(r,s),o=t.minFilter;return t.minFilter===Ms&&(t.minFilter=Pn),new v2(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,r=!0){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,r);e.setRenderTarget(s)}}class Zc extends Xt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const PL={type:"move"};class rm{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Zc,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Zc,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new J,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new J),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Zc,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new J,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new J),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,s=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const x of e.hand.values()){const _=t.getJointPose(x,n),g=this._getHandJoint(c,x);_!==null&&(g.matrix.fromArray(_.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.matrixWorldNeedsUpdate=!0,g.jointRadius=_.radius),g.visible=_!==null}const f=c.joints["index-finger-tip"],d=c.joints["thumb-tip"],p=f.position.distanceTo(d.position),m=.02,y=.005;c.inputState.pinching&&p>m+y?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&p<=m-y&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(PL)))}return o!==null&&(o.visible=r!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Zc;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class Ig{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new et(e),this.density=t}clone(){return new Ig(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class Pg{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new et(e),this.near=t,this.far=n}clone(){return new Pg(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class zg extends Xt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Ui,this.environmentIntensity=1,this.environmentRotation=new Ui,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class Fg{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=bf,this.updateRanges=[],this.version=0,this.uuid=vr()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=vr()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=vr()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Pi=new J;class Tl{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Pi.fromBufferAttribute(this,t),Pi.applyMatrix4(e),this.setXYZ(t,Pi.x,Pi.y,Pi.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Pi.fromBufferAttribute(this,t),Pi.applyNormalMatrix(e),this.setXYZ(t,Pi.x,Pi.y,Pi.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Pi.fromBufferAttribute(this,t),Pi.transformDirection(e),this.setXYZ(t,Pi.x,Pi.y,Pi.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=Fi(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Ut(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=Ut(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Ut(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Ut(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Ut(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Fi(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Fi(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Fi(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Fi(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=Ut(t,this.array),n=Ut(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Ut(t,this.array),n=Ut(n,this.array),r=Ut(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=Ut(t,this.array),n=Ut(n,this.array),r=Ut(r,this.array),s=Ut(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new en(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Tl(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class Jx extends Oi{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new et(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let Tc;const hh=new J,Ac=new J,Cc=new J,Rc=new Ge,fh=new Ge,_2=new bt,rp=new J,dh=new J,sp=new J,hE=new Ge,ny=new Ge,fE=new Ge;class x2 extends Xt{constructor(e=new Jx){if(super(),this.isSprite=!0,this.type="Sprite",Tc===void 0){Tc=new Ct;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new Fg(t,5);Tc.setIndex([0,1,2,0,2,3]),Tc.setAttribute("position",new Tl(n,3,0,!1)),Tc.setAttribute("uv",new Tl(n,2,3,!1))}this.geometry=Tc,this.material=e,this.center=new Ge(.5,.5),this.count=1}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Ac.setFromMatrixScale(this.matrixWorld),_2.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Cc.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Ac.multiplyScalar(-Cc.z);const n=this.material.rotation;let r,s;n!==0&&(s=Math.cos(n),r=Math.sin(n));const a=this.center;ap(rp.set(-.5,-.5,0),Cc,a,Ac,r,s),ap(dh.set(.5,-.5,0),Cc,a,Ac,r,s),ap(sp.set(.5,.5,0),Cc,a,Ac,r,s),hE.set(0,0),ny.set(1,0),fE.set(1,1);let o=e.ray.intersectTriangle(rp,dh,sp,!1,hh);if(o===null&&(ap(dh.set(-.5,.5,0),Cc,a,Ac,r,s),ny.set(0,1),o=e.ray.intersectTriangle(rp,sp,dh,!1,hh),o===null))return;const l=e.ray.origin.distanceTo(hh);l<e.near||l>e.far||t.push({distance:l,point:hh.clone(),uv:er.getInterpolation(hh,rp,dh,sp,hE,ny,fE,new Ge),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function ap(i,e,t,n,r,s){Rc.subVectors(i,t).addScalar(.5).multiply(n),r!==void 0?(fh.x=s*Rc.x-r*Rc.y,fh.y=r*Rc.x+s*Rc.y):fh.copy(Rc),i.copy(e),i.x+=fh.x,i.y+=fh.y,i.applyMatrix4(_2)}const op=new J,dE=new J;class b2 extends Xt{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let n=0,r=t.length;n<r;n++){const s=t[n];this.addLevel(s.object.clone(),s.distance,s.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,n=0){t=Math.abs(t);const r=this.levels;let s;for(s=0;s<r.length&&!(t<r[s].distance);s++);return r.splice(s,0,{distance:t,hysteresis:n,object:e}),this.add(e),this}removeLevel(e){const t=this.levels;for(let n=0;n<t.length;n++)if(t[n].distance===e){const r=t.splice(n,1);return this.remove(r[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let n,r;for(n=1,r=t.length;n<r;n++){let s=t[n].distance;if(t[n].object.visible&&(s-=s*t[n].hysteresis),e<s)break}return t[n-1].object}return null}raycast(e,t){if(this.levels.length>0){op.setFromMatrixPosition(this.matrixWorld);const r=e.ray.origin.distanceTo(op);this.getObjectForDistance(r).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){op.setFromMatrixPosition(e.matrixWorld),dE.setFromMatrixPosition(this.matrixWorld);const n=op.distanceTo(dE)/e.zoom;t[0].object.visible=!0;let r,s;for(r=1,s=t.length;r<s;r++){let a=t[r].distance;if(t[r].object.visible&&(a-=a*t[r].hysteresis),n>=a)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r<s;r++)t[r].object.visible=!1}}toJSON(e){const t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];const n=this.levels;for(let r=0,s=n.length;r<s;r++){const a=n[r];t.object.levels.push({object:a.object.uuid,distance:a.distance,hysteresis:a.hysteresis})}return t}}const pE=new J,mE=new kt,gE=new kt,zL=new J,vE=new bt,lp=new J,iy=new ri,yE=new bt,ry=new bu;class S2 extends pn{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=H_,this.bindMatrix=new bt,this.bindMatrixInverse=new bt,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Jn),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,lp),this.boundingBox.expandByPoint(lp)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new ri),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,lp),this.boundingSphere.expandByPoint(lp)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,r=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),iy.copy(this.boundingSphere),iy.applyMatrix4(r),e.ray.intersectsSphere(iy)!==!1&&(yE.copy(r).invert(),ry.copy(e.ray).applyMatrix4(yE),!(this.boundingBox!==null&&ry.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,ry)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new kt,t=this.geometry.attributes.skinWeight;for(let n=0,r=t.count;n<r;n++){e.fromBufferAttribute(t,n);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===H_?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===$A?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,r=this.geometry;mE.fromBufferAttribute(r.attributes.skinIndex,e),gE.fromBufferAttribute(r.attributes.skinWeight,e),pE.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){const a=gE.getComponent(s);if(a!==0){const o=mE.getComponent(s);vE.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(zL.copy(pE).applyMatrix4(vE),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class Qx extends Xt{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Ts extends An{constructor(e=null,t=1,n=1,r,s,a,o,l,c=yi,f=yi,d,p){super(null,a,o,l,c,f,r,s,d,p),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const _E=new bt,FL=new bt;class Bg{constructor(e=[],t=[]){this.uuid=vr(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,r=this.bones.length;n<r;n++)this.boneInverses.push(new bt)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new bt;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let s=0,a=e.length;s<a;s++){const o=e[s]?e[s].matrixWorld:FL;_E.multiplyMatrices(o,t[s]),_E.toArray(n,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new Bg(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new Ts(t,e,e,Di,tr);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,r=e.bones.length;n<r;n++){const s=e.bones[n];let a=t[s];a===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),a=new Qx),this.bones.push(a),this.boneInverses.push(new bt().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let r=0,s=t.length;r<s;r++){const a=t[r];e.bones.push(a.uuid);const o=n[r];e.boneInverses.push(o.toArray())}return e}}class Al extends en{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const Dc=new bt,xE=new bt,cp=[],bE=new Jn,BL=new bt,ph=new pn,mh=new ri;class E2 extends pn{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Al(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<n;r++)this.setMatrixAt(r,BL)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Jn),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Dc),bE.copy(e.boundingBox).applyMatrix4(Dc),this.boundingBox.union(bE)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new ri),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Dc),mh.copy(e.boundingSphere).applyMatrix4(Dc),this.boundingSphere.union(mh)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const n=t.morphTargetInfluences,r=this.morphTexture.source.data.data,s=n.length+1,a=e*s+1;for(let o=0;o<n.length;o++)n[o]=r[a+o]}raycast(e,t){const n=this.matrixWorld,r=this.count;if(ph.geometry=this.geometry,ph.material=this.material,ph.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),mh.copy(this.boundingSphere),mh.applyMatrix4(n),e.ray.intersectsSphere(mh)!==!1))for(let s=0;s<r;s++){this.getMatrixAt(s,Dc),xE.multiplyMatrices(n,Dc),ph.matrixWorld=xE,ph.raycast(e,cp);for(let a=0,o=cp.length;a<o;a++){const l=cp[a];l.instanceId=s,l.object=this,t.push(l)}cp.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Al(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const n=t.morphTargetInfluences,r=n.length+1;this.morphTexture===null&&(this.morphTexture=new Ts(new Float32Array(r*this.count),r,this.count,Cg,tr));const s=this.morphTexture.source.data.data;let a=0;for(let c=0;c<n.length;c++)a+=n[c];const o=this.geometry.morphTargetsRelative?1:1-a,l=r*e;s[l]=o,s.set(n,l+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const sy=new J,kL=new J,GL=new wt;class la{constructor(e=new J(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const r=sy.subVectors(n,t).cross(kL.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(sy),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(e.start).addScaledVector(n,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||GL.getNormalMatrix(e),r=this.coplanarPoint(sy).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Yo=new ri,up=new J;class Ll{constructor(e=new la,t=new la,n=new la,r=new la,s=new la,a=new la){this.planes=[e,t,n,r,s,a]}set(e,t,n,r,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(s),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Fr){const n=this.planes,r=e.elements,s=r[0],a=r[1],o=r[2],l=r[3],c=r[4],f=r[5],d=r[6],p=r[7],m=r[8],y=r[9],x=r[10],_=r[11],g=r[12],b=r[13],S=r[14],E=r[15];if(n[0].setComponents(l-s,p-c,_-m,E-g).normalize(),n[1].setComponents(l+s,p+c,_+m,E+g).normalize(),n[2].setComponents(l+a,p+f,_+y,E+b).normalize(),n[3].setComponents(l-a,p-f,_-y,E-b).normalize(),n[4].setComponents(l-o,p-d,_-x,E-S).normalize(),t===Fr)n[5].setComponents(l+o,p+d,_+x,E+S).normalize();else if(t===Sf)n[5].setComponents(o,d,x,S).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Yo.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Yo.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Yo)}intersectsSprite(e){return Yo.center.set(0,0,0),Yo.radius=.7071067811865476,Yo.applyMatrix4(e.matrixWorld),this.intersectsSphere(Yo)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const r=t[n];if(up.x=r.normal.x>0?e.max.x:e.min.x,up.y=r.normal.y>0?e.max.y:e.min.y,up.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(up)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}const vs=new bt,ys=new Ll;class kg{constructor(){this.coordinateSystem=Fr}intersectsObject(e,t){if(!t.isArrayCamera||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const r=t.cameras[n];if(vs.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),ys.setFromProjectionMatrix(vs,this.coordinateSystem),ys.intersectsObject(e))return!0}return!1}intersectsSprite(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const r=t.cameras[n];if(vs.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),ys.setFromProjectionMatrix(vs,this.coordinateSystem),ys.intersectsSprite(e))return!0}return!1}intersectsSphere(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const r=t.cameras[n];if(vs.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),ys.setFromProjectionMatrix(vs,this.coordinateSystem),ys.intersectsSphere(e))return!0}return!1}intersectsBox(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const r=t.cameras[n];if(vs.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),ys.setFromProjectionMatrix(vs,this.coordinateSystem),ys.intersectsBox(e))return!0}return!1}containsPoint(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const r=t.cameras[n];if(vs.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),ys.setFromProjectionMatrix(vs,this.coordinateSystem),ys.containsPoint(e))return!0}return!1}clone(){return new kg}}function ay(i,e){return i-e}function HL(i,e){return i.z-e.z}function VL(i,e){return e.z-i.z}class WL{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,n,r){const s=this.pool,a=this.list;this.index>=s.length&&s.push({start:-1,count:-1,z:-1,index:-1});const o=s[this.index];a.push(o),this.index++,o.start=e,o.count=t,o.z=n,o.index=r}reset(){this.list.length=0,this.index=0}}const Ki=new bt,XL=new et(1,1,1),SE=new Ll,jL=new kg,hp=new Jn,Zo=new ri,gh=new J,EE=new J,qL=new J,oy=new WL,Ci=new pn,fp=[];function YL(i,e,t=0){const n=e.itemSize;if(i.isInterleavedBufferAttribute||i.array.constructor!==e.array.constructor){const r=i.count;for(let s=0;s<r;s++)for(let a=0;a<n;a++)e.setComponent(s+t,a,i.getComponent(s,a))}else e.array.set(i.array,t*n);e.needsUpdate=!0}function Ko(i,e){if(i.constructor!==e.constructor){const t=Math.min(i.length,e.length);for(let n=0;n<t;n++)e[n]=i[n]}else{const t=Math.min(i.length,e.length);e.set(new i.constructor(i.buffer,0,t))}}class M2 extends pn{constructor(e,t,n=t*2,r){super(new Ct,r),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._instanceInfo=[],this._geometryInfo=[],this._availableInstanceIds=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._visibilityChanged=!0,this._geometryInitialized=!1,this._maxInstanceCount=e,this._maxVertexCount=t,this._maxIndexCount=n,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawInstances=null,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}get maxInstanceCount(){return this._maxInstanceCount}get instanceCount(){return this._instanceInfo.length-this._availableInstanceIds.length}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}_initMatricesTexture(){let e=Math.sqrt(this._maxInstanceCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4),n=new Ts(t,e,e,Di,tr);this._matricesTexture=n}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Uint32Array(e*e),n=new Ts(t,e,e,qf,_a);this._indirectTexture=n}_initColorsTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Float32Array(e*e*4).fill(1),n=new Ts(t,e,e,Di,tr);n.colorSpace=Gt.workingColorSpace,this._colorsTexture=n}_initializeGeometry(e){const t=this.geometry,n=this._maxVertexCount,r=this._maxIndexCount;if(this._geometryInitialized===!1){for(const s in e.attributes){const a=e.getAttribute(s),{array:o,itemSize:l,normalized:c}=a,f=new o.constructor(n*l),d=new en(f,l,c);t.setAttribute(s,d)}if(e.getIndex()!==null){const s=n>65535?new Uint32Array(r):new Uint16Array(r);t.setIndex(new en(s,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const n in t.attributes){if(!e.hasAttribute(n))throw new Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const r=e.getAttribute(n),s=t.getAttribute(n);if(r.itemSize!==s.itemSize||r.normalized!==s.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(e){const t=this._instanceInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){const t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Jn);const e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let n=0,r=t.length;n<r;n++){if(t[n].active===!1)continue;const s=t[n].geometryIndex;this.getMatrixAt(n,Ki),this.getBoundingBoxAt(s,hp).applyMatrix4(Ki),e.union(hp)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ri);const e=this.boundingSphere,t=this._instanceInfo;e.makeEmpty();for(let n=0,r=t.length;n<r;n++){if(t[n].active===!1)continue;const s=t[n].geometryIndex;this.getMatrixAt(n,Ki),this.getBoundingSphereAt(s,Zo).applyMatrix4(Ki),e.union(Zo)}}addInstance(e){if(this._instanceInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const n={visible:!0,active:!0,geometryIndex:e};let r=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(ay),r=this._availableInstanceIds.shift(),this._instanceInfo[r]=n):(r=this._instanceInfo.length,this._instanceInfo.push(n));const s=this._matricesTexture;Ki.identity().toArray(s.image.data,r*16),s.needsUpdate=!0;const a=this._colorsTexture;return a&&(XL.toArray(a.image.data,r*4),a.needsUpdate=!0),this._visibilityChanged=!0,r}addGeometry(e,t=-1,n=-1){this._initializeGeometry(e),this._validateGeometry(e);const r={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},s=this._geometryInfo;r.vertexStart=this._nextVertexStart,r.reservedVertexCount=t===-1?e.getAttribute("position").count:t;const a=e.getIndex();if(a!==null&&(r.indexStart=this._nextIndexStart,r.reservedIndexCount=n===-1?a.count:n),r.indexStart!==-1&&r.indexStart+r.reservedIndexCount>this._maxIndexCount||r.vertexStart+r.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let l;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(ay),l=this._availableGeometryIds.shift(),s[l]=r):(l=this._geometryCount,this._geometryCount++,s.push(r)),this.setGeometryAt(l,e),this._nextIndexStart=r.indexStart+r.reservedIndexCount,this._nextVertexStart=r.vertexStart+r.reservedVertexCount,l}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const n=this.geometry,r=n.getIndex()!==null,s=n.getIndex(),a=t.getIndex(),o=this._geometryInfo[e];if(r&&a.count>o.reservedIndexCount||t.attributes.position.count>o.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const l=o.vertexStart,c=o.reservedVertexCount;o.vertexCount=t.getAttribute("position").count;for(const f in n.attributes){const d=t.getAttribute(f),p=n.getAttribute(f);YL(d,p,l);const m=d.itemSize;for(let y=d.count,x=c;y<x;y++){const _=l+y;for(let g=0;g<m;g++)p.setComponent(_,g,0)}p.needsUpdate=!0,p.addUpdateRange(l*m,c*m)}if(r){const f=o.indexStart,d=o.reservedIndexCount;o.indexCount=t.getIndex().count;for(let p=0;p<a.count;p++)s.setX(f+p,l+a.getX(p));for(let p=a.count,m=d;p<m;p++)s.setX(f+p,l);s.needsUpdate=!0,s.addUpdateRange(f,o.reservedIndexCount)}return o.start=r?o.indexStart:o.vertexStart,o.count=r?o.indexCount:o.vertexCount,o.boundingBox=null,t.boundingBox!==null&&(o.boundingBox=t.boundingBox.clone()),o.boundingSphere=null,t.boundingSphere!==null&&(o.boundingSphere=t.boundingSphere.clone()),this._visibilityChanged=!0,e}deleteGeometry(e){const t=this._geometryInfo;if(e>=t.length||t[e].active===!1)return this;const n=this._instanceInfo;for(let r=0,s=n.length;r<s;r++)n[r].active&&n[r].geometryIndex===e&&this.deleteInstance(r);return t[e].active=!1,this._availableGeometryIds.push(e),this._visibilityChanged=!0,this}deleteInstance(e){return this.validateInstanceId(e),this._instanceInfo[e].active=!1,this._availableInstanceIds.push(e),this._visibilityChanged=!0,this}optimize(){let e=0,t=0;const n=this._geometryInfo,r=n.map((a,o)=>o).sort((a,o)=>n[a].vertexStart-n[o].vertexStart),s=this.geometry;for(let a=0,o=n.length;a<o;a++){const l=r[a],c=n[l];if(c.active!==!1){if(s.index!==null){if(c.indexStart!==t){const{indexStart:f,vertexStart:d,reservedIndexCount:p}=c,m=s.index,y=m.array,x=e-d;for(let _=f;_<f+p;_++)y[_]=y[_]+x;m.array.copyWithin(t,f,f+p),m.addUpdateRange(t,p),c.indexStart=t}t+=c.reservedIndexCount}if(c.vertexStart!==e){const{vertexStart:f,reservedVertexCount:d}=c,p=s.attributes;for(const m in p){const y=p[m],{array:x,itemSize:_}=y;x.copyWithin(e*_,f*_,(f+d)*_),y.addUpdateRange(e*_,d*_)}c.vertexStart=e}e+=c.reservedVertexCount,c.start=s.index?c.indexStart:c.vertexStart,this._nextIndexStart=s.index?c.indexStart+c.reservedIndexCount:0,this._nextVertexStart=c.vertexStart+c.reservedVertexCount}}return this}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;const n=this.geometry,r=this._geometryInfo[e];if(r.boundingBox===null){const s=new Jn,a=n.index,o=n.attributes.position;for(let l=r.start,c=r.start+r.count;l<c;l++){let f=l;a&&(f=a.getX(f)),s.expandByPoint(gh.fromBufferAttribute(o,f))}r.boundingBox=s}return t.copy(r.boundingBox),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;const n=this.geometry,r=this._geometryInfo[e];if(r.boundingSphere===null){const s=new ri;this.getBoundingBoxAt(e,hp),hp.getCenter(s.center);const a=n.index,o=n.attributes.position;let l=0;for(let c=r.start,f=r.start+r.count;c<f;c++){let d=c;a&&(d=a.getX(d)),gh.fromBufferAttribute(o,d),l=Math.max(l,s.center.distanceToSquared(gh))}s.radius=Math.sqrt(l),r.boundingSphere=s}return t.copy(r.boundingSphere),t}setMatrixAt(e,t){this.validateInstanceId(e);const n=this._matricesTexture,r=this._matricesTexture.image.data;return t.toArray(r,e*16),n.needsUpdate=!0,this}getMatrixAt(e,t){return this.validateInstanceId(e),t.fromArray(this._matricesTexture.image.data,e*16)}setColorAt(e,t){return this.validateInstanceId(e),this._colorsTexture===null&&this._initColorsTexture(),t.toArray(this._colorsTexture.image.data,e*4),this._colorsTexture.needsUpdate=!0,this}getColorAt(e,t){return this.validateInstanceId(e),t.fromArray(this._colorsTexture.image.data,e*4)}setVisibleAt(e,t){return this.validateInstanceId(e),this._instanceInfo[e].visible===t?this:(this._instanceInfo[e].visible=t,this._visibilityChanged=!0,this)}getVisibleAt(e){return this.validateInstanceId(e),this._instanceInfo[e].visible}setGeometryIdAt(e,t){return this.validateInstanceId(e),this.validateGeometryId(t),this._instanceInfo[e].geometryIndex=t,this}getGeometryIdAt(e){return this.validateInstanceId(e),this._instanceInfo[e].geometryIndex}getGeometryRangeAt(e,t={}){this.validateGeometryId(e);const n=this._geometryInfo[e];return t.vertexStart=n.vertexStart,t.vertexCount=n.vertexCount,t.reservedVertexCount=n.reservedVertexCount,t.indexStart=n.indexStart,t.indexCount=n.indexCount,t.reservedIndexCount=n.reservedIndexCount,t.start=n.start,t.count=n.count,t}setInstanceCount(e){const t=this._availableInstanceIds,n=this._instanceInfo;for(t.sort(ay);t[t.length-1]===n.length;)n.pop(),t.pop();if(e<n.length)throw new Error(`BatchedMesh: Instance ids outside the range ${e} are being used. Cannot shrink instance count.`);const r=new Int32Array(e),s=new Int32Array(e);Ko(this._multiDrawCounts,r),Ko(this._multiDrawStarts,s),this._multiDrawCounts=r,this._multiDrawStarts=s,this._maxInstanceCount=e;const a=this._indirectTexture,o=this._matricesTexture,l=this._colorsTexture;a.dispose(),this._initIndirectTexture(),Ko(a.image.data,this._indirectTexture.image.data),o.dispose(),this._initMatricesTexture(),Ko(o.image.data,this._matricesTexture.image.data),l&&(l.dispose(),this._initColorsTexture(),Ko(l.image.data,this._colorsTexture.image.data))}setGeometrySize(e,t){const n=[...this._geometryInfo].filter(o=>o.active);if(Math.max(...n.map(o=>o.vertexStart+o.reservedVertexCount))>e)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map(l=>l.indexStart+l.reservedIndexCount))>t)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);const s=this.geometry;s.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Ct,this._initializeGeometry(s));const a=this.geometry;s.index&&Ko(s.index.array,a.index.array);for(const o in s.attributes)Ko(s.attributes[o].array,a.attributes[o].array)}raycast(e,t){const n=this._instanceInfo,r=this._geometryInfo,s=this.matrixWorld,a=this.geometry;Ci.material=this.material,Ci.geometry.index=a.index,Ci.geometry.attributes=a.attributes,Ci.geometry.boundingBox===null&&(Ci.geometry.boundingBox=new Jn),Ci.geometry.boundingSphere===null&&(Ci.geometry.boundingSphere=new ri);for(let o=0,l=n.length;o<l;o++){if(!n[o].visible||!n[o].active)continue;const c=n[o].geometryIndex,f=r[c];Ci.geometry.setDrawRange(f.start,f.count),this.getMatrixAt(o,Ci.matrixWorld).premultiply(s),this.getBoundingBoxAt(c,Ci.geometry.boundingBox),this.getBoundingSphereAt(c,Ci.geometry.boundingSphere),Ci.raycast(e,fp);for(let d=0,p=fp.length;d<p;d++){const m=fp[d];m.object=this,m.batchId=o,t.push(m)}fp.length=0}Ci.material=null,Ci.geometry.index=null,Ci.geometry.attributes={},Ci.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._geometryInfo=e._geometryInfo.map(t=>({...t,boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(t=>({...t})),this._availableInstanceIds=e._availableInstanceIds.slice(),this._availableGeometryIds=e._availableGeometryIds.slice(),this._nextIndexStart=e._nextIndexStart,this._nextVertexStart=e._nextVertexStart,this._geometryCount=e._geometryCount,this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._indirectTexture=e._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(e,t,n,r,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const a=r.getIndex(),o=a===null?1:a.array.BYTES_PER_ELEMENT,l=this._instanceInfo,c=this._multiDrawStarts,f=this._multiDrawCounts,d=this._geometryInfo,p=this.perObjectFrustumCulled,m=this._indirectTexture,y=m.image.data,x=n.isArrayCamera?jL:SE;p&&!n.isArrayCamera&&(Ki.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),SE.setFromProjectionMatrix(Ki,e.coordinateSystem));let _=0;if(this.sortObjects){Ki.copy(this.matrixWorld).invert(),gh.setFromMatrixPosition(n.matrixWorld).applyMatrix4(Ki),EE.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(Ki);for(let S=0,E=l.length;S<E;S++)if(l[S].visible&&l[S].active){const w=l[S].geometryIndex;this.getMatrixAt(S,Ki),this.getBoundingSphereAt(w,Zo).applyMatrix4(Ki);let T=!1;if(p&&(T=!x.intersectsSphere(Zo,n)),!T){const R=d[w],U=qL.subVectors(Zo.center,gh).dot(EE);oy.push(R.start,R.count,U,S)}}const g=oy.list,b=this.customSort;b===null?g.sort(s.transparent?VL:HL):b.call(this,g,n);for(let S=0,E=g.length;S<E;S++){const w=g[S];c[_]=w.start*o,f[_]=w.count,y[_]=w.index,_++}oy.reset()}else for(let g=0,b=l.length;g<b;g++)if(l[g].visible&&l[g].active){const S=l[g].geometryIndex;let E=!1;if(p&&(this.getMatrixAt(g,Ki),this.getBoundingSphereAt(S,Zo).applyMatrix4(Ki),E=!x.intersectsSphere(Zo,n)),!E){const w=d[S];c[_]=w.start*o,f[_]=w.count,y[_]=g,_++}}m.needsUpdate=!0,this._multiDrawCount=_,this._visibilityChanged=!1}onBeforeShadow(e,t,n,r,s,a){this.onBeforeRender(e,null,r,s,a)}}class Gi extends Oi{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new et(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const Qm=new J,$m=new J,ME=new bt,vh=new bu,dp=new ri,ly=new J,wE=new J;let fo=class extends Xt{constructor(e=new Ct,t=new Gi){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let r=1,s=t.count;r<s;r++)Qm.fromBufferAttribute(t,r-1),$m.fromBufferAttribute(t,r),n[r]=n[r-1],n[r]+=Qm.distanceTo($m);e.setAttribute("lineDistance",new dt(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),dp.copy(n.boundingSphere),dp.applyMatrix4(r),dp.radius+=s,e.ray.intersectsSphere(dp)===!1)return;ME.copy(r).invert(),vh.copy(e.ray).applyMatrix4(ME);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,f=n.index,p=n.attributes.position;if(f!==null){const m=Math.max(0,a.start),y=Math.min(f.count,a.start+a.count);for(let x=m,_=y-1;x<_;x+=c){const g=f.getX(x),b=f.getX(x+1),S=pp(this,e,vh,l,g,b,x);S&&t.push(S)}if(this.isLineLoop){const x=f.getX(y-1),_=f.getX(m),g=pp(this,e,vh,l,x,_,y-1);g&&t.push(g)}}else{const m=Math.max(0,a.start),y=Math.min(p.count,a.start+a.count);for(let x=m,_=y-1;x<_;x+=c){const g=pp(this,e,vh,l,x,x+1,x);g&&t.push(g)}if(this.isLineLoop){const x=pp(this,e,vh,l,y-1,m,y-1);x&&t.push(x)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){const o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}};function pp(i,e,t,n,r,s,a){const o=i.geometry.attributes.position;if(Qm.fromBufferAttribute(o,r),$m.fromBufferAttribute(o,s),t.distanceSqToSegment(Qm,$m,ly,wE)>n)return;ly.applyMatrix4(i.matrixWorld);const c=e.ray.origin.distanceTo(ly);if(!(c<e.near||c>e.far))return{distance:c,point:wE.clone().applyMatrix4(i.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:i}}const TE=new J,AE=new J;class Ds extends fo{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let r=0,s=t.count;r<s;r+=2)TE.fromBufferAttribute(t,r),AE.fromBufferAttribute(t,r+1),n[r]=r===0?0:n[r-1],n[r+1]=n[r]+TE.distanceTo(AE);e.setAttribute("lineDistance",new dt(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class w2 extends fo{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class $x extends Oi{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new et(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const CE=new bt,X_=new bu,mp=new ri,gp=new J;class T2 extends Xt{constructor(e=new Ct,t=new $x){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,s=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),mp.copy(n.boundingSphere),mp.applyMatrix4(r),mp.radius+=s,e.ray.intersectsSphere(mp)===!1)return;CE.copy(r).invert(),X_.copy(e.ray).applyMatrix4(CE);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=n.index,d=n.attributes.position;if(c!==null){const p=Math.max(0,a.start),m=Math.min(c.count,a.start+a.count);for(let y=p,x=m;y<x;y++){const _=c.getX(y);gp.fromBufferAttribute(d,_),RE(gp,_,l,r,e,t,this)}}else{const p=Math.max(0,a.start),m=Math.min(d.count,a.start+a.count);for(let y=p,x=m;y<x;y++)gp.fromBufferAttribute(d,y),RE(gp,y,l,r,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){const o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function RE(i,e,t,n,r,s,a){const o=X_.distanceSqToPoint(i);if(o<t){const l=new J;X_.closestPointToPoint(i,l),l.applyMatrix4(n);const c=r.ray.origin.distanceTo(l);if(c<r.near||c>r.far)return;s.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class A2 extends An{constructor(e,t,n,r,s=Pn,a=Pn,o,l,c){super(e,t,n,r,s,a,o,l,c),this.isVideoTexture=!0,this.generateMipmaps=!1;const f=this;function d(){f.needsUpdate=!0,e.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(d)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class ZL extends A2{constructor(e,t,n,r,s,a,o,l){super({},e,t,n,r,s,a,o,l),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}}class KL extends An{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=yi,this.minFilter=yi,this.generateMipmaps=!1,this.needsUpdate=!0}}class Gg extends An{constructor(e,t,n,r,s,a,o,l,c,f,d,p){super(null,a,o,l,c,f,r,s,d,p),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class JL extends Gg{constructor(e,t,n,r,s,a){super(e,t,n,s,a),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=zr,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class QL extends Gg{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,ya),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class $L extends An{constructor(e,t,n,r,s,a,o,l,c){super(e,t,n,r,s,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class e1 extends An{constructor(e,t,n=_a,r,s,a,o=yi,l=yi,c,f=au,d=1){if(f!==au&&f!==ou)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const p={width:e,height:t,depth:d};super(p,r,s,a,o,l,f,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new so(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class Hg extends Ct{constructor(e=1,t=1,n=4,r=8,s=1){super(),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:n,radialSegments:r,heightSegments:s},t=Math.max(0,t),n=Math.max(1,Math.floor(n)),r=Math.max(3,Math.floor(r)),s=Math.max(1,Math.floor(s));const a=[],o=[],l=[],c=[],f=t/2,d=Math.PI/2*e,p=t,m=2*d+p,y=n*2+s,x=r+1,_=new J,g=new J;for(let b=0;b<=y;b++){let S=0,E=0,w=0,T=0;if(b<=n){const D=b/n,C=D*Math.PI/2;E=-f-e*Math.cos(C),w=e*Math.sin(C),T=-e*Math.cos(C),S=D*d}else if(b<=n+s){const D=(b-n)/s;E=-f+D*t,w=e,T=0,S=d+D*p}else{const D=(b-n-s)/n,C=D*Math.PI/2;E=f+e*Math.sin(C),w=e*Math.cos(C),T=e*Math.sin(C),S=d+p+D*d}const R=Math.max(0,Math.min(1,S/m));let U=0;b===0?U=.5/r:b===y&&(U=-.5/r);for(let D=0;D<=r;D++){const C=D/r,P=C*Math.PI*2,I=Math.sin(P),O=Math.cos(P);g.x=-w*O,g.y=E,g.z=w*I,o.push(g.x,g.y,g.z),_.set(-w*O,T,w*I),_.normalize(),l.push(_.x,_.y,_.z),c.push(C+U,R)}if(b>0){const D=(b-1)*x;for(let C=0;C<r;C++){const P=D+C,I=D+C+1,O=b*x+C,G=b*x+C+1;a.push(P,I,O),a.push(I,G,O)}}}this.setIndex(a),this.setAttribute("position",new dt(o,3)),this.setAttribute("normal",new dt(l,3)),this.setAttribute("uv",new dt(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Hg(e.radius,e.height,e.capSegments,e.radialSegments,e.heightSegments)}}class Vg extends Ct{constructor(e=1,t=32,n=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:r},t=Math.max(3,t);const s=[],a=[],o=[],l=[],c=new J,f=new Ge;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let d=0,p=3;d<=t;d++,p+=3){const m=n+d/t*r;c.x=e*Math.cos(m),c.y=e*Math.sin(m),a.push(c.x,c.y,c.z),o.push(0,0,1),f.x=(a[p]/e+1)/2,f.y=(a[p+1]/e+1)/2,l.push(f.x,f.y)}for(let d=1;d<=t;d++)s.push(d,d+1,0);this.setIndex(s),this.setAttribute("position",new dt(a,3)),this.setAttribute("normal",new dt(o,3)),this.setAttribute("uv",new dt(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Vg(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class Su extends Ct{constructor(e=1,t=1,n=1,r=32,s=1,a=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:s,openEnded:a,thetaStart:o,thetaLength:l};const c=this;r=Math.floor(r),s=Math.floor(s);const f=[],d=[],p=[],m=[];let y=0;const x=[],_=n/2;let g=0;b(),a===!1&&(e>0&&S(!0),t>0&&S(!1)),this.setIndex(f),this.setAttribute("position",new dt(d,3)),this.setAttribute("normal",new dt(p,3)),this.setAttribute("uv",new dt(m,2));function b(){const E=new J,w=new J;let T=0;const R=(t-e)/n;for(let U=0;U<=s;U++){const D=[],C=U/s,P=C*(t-e)+e;for(let I=0;I<=r;I++){const O=I/r,G=O*l+o,Z=Math.sin(G),z=Math.cos(G);w.x=P*Z,w.y=-C*n+_,w.z=P*z,d.push(w.x,w.y,w.z),E.set(Z,R,z).normalize(),p.push(E.x,E.y,E.z),m.push(O,1-C),D.push(y++)}x.push(D)}for(let U=0;U<r;U++)for(let D=0;D<s;D++){const C=x[D][U],P=x[D+1][U],I=x[D+1][U+1],O=x[D][U+1];(e>0||D!==0)&&(f.push(C,P,O),T+=3),(t>0||D!==s-1)&&(f.push(P,I,O),T+=3)}c.addGroup(g,T,0),g+=T}function S(E){const w=y,T=new Ge,R=new J;let U=0;const D=E===!0?e:t,C=E===!0?1:-1;for(let I=1;I<=r;I++)d.push(0,_*C,0),p.push(0,C,0),m.push(.5,.5),y++;const P=y;for(let I=0;I<=r;I++){const G=I/r*l+o,Z=Math.cos(G),z=Math.sin(G);R.x=D*z,R.y=_*C,R.z=D*Z,d.push(R.x,R.y,R.z),p.push(0,C,0),T.x=Z*.5+.5,T.y=z*.5*C+.5,m.push(T.x,T.y),y++}for(let I=0;I<r;I++){const O=w+I,G=P+I;E===!0?f.push(G,G+1,O):f.push(G+1,G,O),U+=3}c.addGroup(g,U,E===!0?1:2),g+=U}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Su(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Zf extends Su{constructor(e=1,t=1,n=32,r=1,s=!1,a=0,o=Math.PI*2){super(0,e,t,n,r,s,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:s,thetaStart:a,thetaLength:o}}static fromJSON(e){return new Zf(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class go extends Ct{constructor(e=[],t=[],n=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:r};const s=[],a=[];o(r),c(n),f(),this.setAttribute("position",new dt(s,3)),this.setAttribute("normal",new dt(s.slice(),3)),this.setAttribute("uv",new dt(a,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function o(b){const S=new J,E=new J,w=new J;for(let T=0;T<t.length;T+=3)m(t[T+0],S),m(t[T+1],E),m(t[T+2],w),l(S,E,w,b)}function l(b,S,E,w){const T=w+1,R=[];for(let U=0;U<=T;U++){R[U]=[];const D=b.clone().lerp(E,U/T),C=S.clone().lerp(E,U/T),P=T-U;for(let I=0;I<=P;I++)I===0&&U===T?R[U][I]=D:R[U][I]=D.clone().lerp(C,I/P)}for(let U=0;U<T;U++)for(let D=0;D<2*(T-U)-1;D++){const C=Math.floor(D/2);D%2===0?(p(R[U][C+1]),p(R[U+1][C]),p(R[U][C])):(p(R[U][C+1]),p(R[U+1][C+1]),p(R[U+1][C]))}}function c(b){const S=new J;for(let E=0;E<s.length;E+=3)S.x=s[E+0],S.y=s[E+1],S.z=s[E+2],S.normalize().multiplyScalar(b),s[E+0]=S.x,s[E+1]=S.y,s[E+2]=S.z}function f(){const b=new J;for(let S=0;S<s.length;S+=3){b.x=s[S+0],b.y=s[S+1],b.z=s[S+2];const E=_(b)/2/Math.PI+.5,w=g(b)/Math.PI+.5;a.push(E,1-w)}y(),d()}function d(){for(let b=0;b<a.length;b+=6){const S=a[b+0],E=a[b+2],w=a[b+4],T=Math.max(S,E,w),R=Math.min(S,E,w);T>.9&&R<.1&&(S<.2&&(a[b+0]+=1),E<.2&&(a[b+2]+=1),w<.2&&(a[b+4]+=1))}}function p(b){s.push(b.x,b.y,b.z)}function m(b,S){const E=b*3;S.x=e[E+0],S.y=e[E+1],S.z=e[E+2]}function y(){const b=new J,S=new J,E=new J,w=new J,T=new Ge,R=new Ge,U=new Ge;for(let D=0,C=0;D<s.length;D+=9,C+=6){b.set(s[D+0],s[D+1],s[D+2]),S.set(s[D+3],s[D+4],s[D+5]),E.set(s[D+6],s[D+7],s[D+8]),T.set(a[C+0],a[C+1]),R.set(a[C+2],a[C+3]),U.set(a[C+4],a[C+5]),w.copy(b).add(S).add(E).divideScalar(3);const P=_(w);x(T,C+0,b,P),x(R,C+2,S,P),x(U,C+4,E,P)}}function x(b,S,E,w){w<0&&b.x===1&&(a[S]=b.x-1),E.x===0&&E.z===0&&(a[S]=w/2/Math.PI+.5)}function _(b){return Math.atan2(b.z,-b.x)}function g(b){return Math.atan2(-b.y,Math.sqrt(b.x*b.x+b.z*b.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new go(e.vertices,e.indices,e.radius,e.details)}}class Wg extends go{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,r=1/n,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,a,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Wg(e.radius,e.detail)}}const vp=new J,yp=new J,cy=new J,_p=new er;class C2 extends Ct{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const r=Math.pow(10,4),s=Math.cos(xl*t),a=e.getIndex(),o=e.getAttribute("position"),l=a?a.count:o.count,c=[0,0,0],f=["a","b","c"],d=new Array(3),p={},m=[];for(let y=0;y<l;y+=3){a?(c[0]=a.getX(y),c[1]=a.getX(y+1),c[2]=a.getX(y+2)):(c[0]=y,c[1]=y+1,c[2]=y+2);const{a:x,b:_,c:g}=_p;if(x.fromBufferAttribute(o,c[0]),_.fromBufferAttribute(o,c[1]),g.fromBufferAttribute(o,c[2]),_p.getNormal(cy),d[0]=`${Math.round(x.x*r)},${Math.round(x.y*r)},${Math.round(x.z*r)}`,d[1]=`${Math.round(_.x*r)},${Math.round(_.y*r)},${Math.round(_.z*r)}`,d[2]=`${Math.round(g.x*r)},${Math.round(g.y*r)},${Math.round(g.z*r)}`,!(d[0]===d[1]||d[1]===d[2]||d[2]===d[0]))for(let b=0;b<3;b++){const S=(b+1)%3,E=d[b],w=d[S],T=_p[f[b]],R=_p[f[S]],U=`${E}_${w}`,D=`${w}_${E}`;D in p&&p[D]?(cy.dot(p[D].normal)<=s&&(m.push(T.x,T.y,T.z),m.push(R.x,R.y,R.z)),p[D]=null):U in p||(p[U]={index0:c[b],index1:c[S],normal:cy.clone()})}}for(const y in p)if(p[y]){const{index0:x,index1:_}=p[y];vp.fromBufferAttribute(o,x),yp.fromBufferAttribute(o,_),m.push(vp.x,vp.y,vp.z),m.push(yp.x,yp.y,yp.z)}this.setAttribute("position",new dt(m,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class us{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){console.warn("THREE.Curve: .getPoint() not implemented.")}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,r=this.getPoint(0),s=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),s+=n.distanceTo(r),t.push(s),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){const n=this.getLengths();let r=0;const s=n.length;let a;t?a=t:a=e*n[s-1];let o=0,l=s-1,c;for(;o<=l;)if(r=Math.floor(o+(l-o)/2),c=n[r]-a,c<0)o=r+1;else if(c>0)l=r-1;else{l=r;break}if(r=l,n[r]===a)return r/(s-1);const f=n[r],p=n[r+1]-f,m=(a-f)/p;return(r+m)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);const a=this.getPoint(r),o=this.getPoint(s),l=t||(a.isVector2?new Ge:new J);return l.copy(o).sub(a).normalize(),l}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){const n=new J,r=[],s=[],a=[],o=new J,l=new bt;for(let m=0;m<=e;m++){const y=m/e;r[m]=this.getTangentAt(y,new J)}s[0]=new J,a[0]=new J;let c=Number.MAX_VALUE;const f=Math.abs(r[0].x),d=Math.abs(r[0].y),p=Math.abs(r[0].z);f<=c&&(c=f,n.set(1,0,0)),d<=c&&(c=d,n.set(0,1,0)),p<=c&&n.set(0,0,1),o.crossVectors(r[0],n).normalize(),s[0].crossVectors(r[0],o),a[0].crossVectors(r[0],s[0]);for(let m=1;m<=e;m++){if(s[m]=s[m-1].clone(),a[m]=a[m-1].clone(),o.crossVectors(r[m-1],r[m]),o.length()>Number.EPSILON){o.normalize();const y=Math.acos(Tt(r[m-1].dot(r[m]),-1,1));s[m].applyMatrix4(l.makeRotationAxis(o,y))}a[m].crossVectors(r[m],s[m])}if(t===!0){let m=Math.acos(Tt(s[0].dot(s[e]),-1,1));m/=e,r[0].dot(o.crossVectors(s[0],s[e]))>0&&(m=-m);for(let y=1;y<=e;y++)s[y].applyMatrix4(l.makeRotationAxis(r[y],m*y)),a[y].crossVectors(r[y],s[y])}return{tangents:r,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Xg extends us{constructor(e=0,t=0,n=1,r=1,s=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t=new Ge){const n=t,r=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const a=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(a?s=0:s=r),this.aClockwise===!0&&!a&&(s===r?s=-r:s=s-r);const o=this.aStartAngle+e*s;let l=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){const f=Math.cos(this.aRotation),d=Math.sin(this.aRotation),p=l-this.aX,m=c-this.aY;l=p*f-m*d+this.aX,c=p*d+m*f+this.aY}return n.set(l,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class R2 extends Xg{constructor(e,t,n,r,s,a){super(e,t,n,n,r,s,a),this.isArcCurve=!0,this.type="ArcCurve"}}function t1(){let i=0,e=0,t=0,n=0;function r(s,a,o,l){i=s,e=o,t=-3*s+3*a-2*o-l,n=2*s-2*a+o+l}return{initCatmullRom:function(s,a,o,l,c){r(a,o,c*(o-s),c*(l-a))},initNonuniformCatmullRom:function(s,a,o,l,c,f,d){let p=(a-s)/c-(o-s)/(c+f)+(o-a)/f,m=(o-a)/f-(l-a)/(f+d)+(l-o)/d;p*=f,m*=f,r(a,o,p,m)},calc:function(s){const a=s*s,o=a*s;return i+e*s+t*a+n*o}}}const xp=new J,uy=new t1,hy=new t1,fy=new t1;class D2 extends us{constructor(e=[],t=!1,n="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=r}getPoint(e,t=new J){const n=t,r=this.points,s=r.length,a=(s-(this.closed?0:1))*e;let o=Math.floor(a),l=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/s)+1)*s:l===0&&o===s-1&&(o=s-2,l=1);let c,f;this.closed||o>0?c=r[(o-1)%s]:(xp.subVectors(r[0],r[1]).add(r[0]),c=xp);const d=r[o%s],p=r[(o+1)%s];if(this.closed||o+2<s?f=r[(o+2)%s]:(xp.subVectors(r[s-1],r[s-2]).add(r[s-1]),f=xp),this.curveType==="centripetal"||this.curveType==="chordal"){const m=this.curveType==="chordal"?.5:.25;let y=Math.pow(c.distanceToSquared(d),m),x=Math.pow(d.distanceToSquared(p),m),_=Math.pow(p.distanceToSquared(f),m);x<1e-4&&(x=1),y<1e-4&&(y=x),_<1e-4&&(_=x),uy.initNonuniformCatmullRom(c.x,d.x,p.x,f.x,y,x,_),hy.initNonuniformCatmullRom(c.y,d.y,p.y,f.y,y,x,_),fy.initNonuniformCatmullRom(c.z,d.z,p.z,f.z,y,x,_)}else this.curveType==="catmullrom"&&(uy.initCatmullRom(c.x,d.x,p.x,f.x,this.tension),hy.initCatmullRom(c.y,d.y,p.y,f.y,this.tension),fy.initCatmullRom(c.z,d.z,p.z,f.z,this.tension));return n.set(uy.calc(l),hy.calc(l),fy.calc(l)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const r=e.points[t];this.points.push(new J().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function DE(i,e,t,n,r){const s=(n-e)*.5,a=(r-t)*.5,o=i*i,l=i*o;return(2*t-2*n+s+a)*l+(-3*t+3*n-2*s-a)*o+s*i+t}function eN(i,e){const t=1-i;return t*t*e}function tN(i,e){return 2*(1-i)*i*e}function nN(i,e){return i*i*e}function sf(i,e,t,n){return eN(i,e)+tN(i,t)+nN(i,n)}function iN(i,e){const t=1-i;return t*t*t*e}function rN(i,e){const t=1-i;return 3*t*t*i*e}function sN(i,e){return 3*(1-i)*i*i*e}function aN(i,e){return i*i*i*e}function af(i,e,t,n,r){return iN(i,e)+rN(i,t)+sN(i,n)+aN(i,r)}class n1 extends us{constructor(e=new Ge,t=new Ge,n=new Ge,r=new Ge){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new Ge){const n=t,r=this.v0,s=this.v1,a=this.v2,o=this.v3;return n.set(af(e,r.x,s.x,a.x,o.x),af(e,r.y,s.y,a.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class U2 extends us{constructor(e=new J,t=new J,n=new J,r=new J){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new J){const n=t,r=this.v0,s=this.v1,a=this.v2,o=this.v3;return n.set(af(e,r.x,s.x,a.x,o.x),af(e,r.y,s.y,a.y,o.y),af(e,r.z,s.z,a.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class i1 extends us{constructor(e=new Ge,t=new Ge){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new Ge){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new Ge){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class r1 extends us{constructor(e=new J,t=new J){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new J){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new J){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class s1 extends us{constructor(e=new Ge,t=new Ge,n=new Ge){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new Ge){const n=t,r=this.v0,s=this.v1,a=this.v2;return n.set(sf(e,r.x,s.x,a.x),sf(e,r.y,s.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class jg extends us{constructor(e=new J,t=new J,n=new J){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new J){const n=t,r=this.v0,s=this.v1,a=this.v2;return n.set(sf(e,r.x,s.x,a.x),sf(e,r.y,s.y,a.y),sf(e,r.z,s.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class a1 extends us{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new Ge){const n=t,r=this.points,s=(r.length-1)*e,a=Math.floor(s),o=s-a,l=r[a===0?a:a-1],c=r[a],f=r[a>r.length-2?r.length-1:a+1],d=r[a>r.length-3?r.length-1:a+2];return n.set(DE(o,l.x,c.x,f.x,d.x),DE(o,l.y,c.y,f.y,d.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const r=e.points[t];this.points.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const r=e.points[t];this.points.push(new Ge().fromArray(r))}return this}}var eg=Object.freeze({__proto__:null,ArcCurve:R2,CatmullRomCurve3:D2,CubicBezierCurve:n1,CubicBezierCurve3:U2,EllipseCurve:Xg,LineCurve:i1,LineCurve3:r1,QuadraticBezierCurve:s1,QuadraticBezierCurve3:jg,SplineCurve:a1});class O2 extends us{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){const n=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new eg[n](t,e))}return this}getPoint(e,t){const n=e*this.getLength(),r=this.getCurveLengths();let s=0;for(;s<r.length;){if(r[s]>=n){const a=r[s]-n,o=this.curves[s],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,r=this.curves.length;n<r;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let n;for(let r=0,s=this.curves;r<s.length;r++){const a=s[r],o=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,l=a.getPoints(o);for(let c=0;c<l.length;c++){const f=l[c];n&&n.equals(f)||(t.push(f),n=f)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){const r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const r=e.curves[t];this.curves.push(new eg[r.type]().fromJSON(r))}return this}}class tg extends O2{constructor(e){super(),this.type="Path",this.currentPoint=new Ge,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const n=new i1(this.currentPoint.clone(),new Ge(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,r){const s=new s1(this.currentPoint.clone(),new Ge(e,t),new Ge(n,r));return this.curves.push(s),this.currentPoint.set(n,r),this}bezierCurveTo(e,t,n,r,s,a){const o=new n1(this.currentPoint.clone(),new Ge(e,t),new Ge(n,r),new Ge(s,a));return this.curves.push(o),this.currentPoint.set(s,a),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new a1(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,r,s,a){const o=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+o,t+l,n,r,s,a),this}absarc(e,t,n,r,s,a){return this.absellipse(e,t,n,n,r,s,a),this}ellipse(e,t,n,r,s,a,o,l){const c=this.currentPoint.x,f=this.currentPoint.y;return this.absellipse(e+c,t+f,n,r,s,a,o,l),this}absellipse(e,t,n,r,s,a,o,l){const c=new Xg(e,t,n,r,s,a,o,l);if(this.curves.length>0){const d=c.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(c);const f=c.getPoint(1);return this.currentPoint.copy(f),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class bl extends tg{constructor(e){super(e),this.uuid=vr(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,r=this.holes.length;n<r;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){const r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const r=e.holes[t];this.holes.push(new tg().fromJSON(r))}return this}}function oN(i,e,t=2){const n=e&&e.length,r=n?e[0]*t:i.length;let s=L2(i,0,r,t,!0);const a=[];if(!s||s.next===s.prev)return a;let o,l,c;if(n&&(s=fN(i,e,s,t)),i.length>80*t){o=1/0,l=1/0;let f=-1/0,d=-1/0;for(let p=t;p<r;p+=t){const m=i[p],y=i[p+1];m<o&&(o=m),y<l&&(l=y),m>f&&(f=m),y>d&&(d=y)}c=Math.max(f-o,d-l),c=c!==0?32767/c:0}return Mf(s,a,t,o,l,c,0),a}function L2(i,e,t,n,r){let s;if(r===EN(i,e,t,n)>0)for(let a=e;a<t;a+=n)s=UE(a/n|0,i[a],i[a+1],s);else for(let a=t-n;a>=e;a-=n)s=UE(a/n|0,i[a],i[a+1],s);return s&&hu(s,s.next)&&(Tf(s),s=s.next),s}function Cl(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(hu(t,t.next)||Mn(t.prev,t,t.next)===0)){if(Tf(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function Mf(i,e,t,n,r,s,a){if(!i)return;!a&&s&&vN(i,n,r,s);let o=i;for(;i.prev!==i.next;){const l=i.prev,c=i.next;if(s?cN(i,n,r,s):lN(i)){e.push(l.i,i.i,c.i),Tf(i),i=c.next,o=c.next;continue}if(i=c,i===o){a?a===1?(i=uN(Cl(i),e),Mf(i,e,t,n,r,s,2)):a===2&&hN(i,e,t,n,r,s):Mf(Cl(i),e,t,n,r,s,1);break}}}function lN(i){const e=i.prev,t=i,n=i.next;if(Mn(e,t,n)>=0)return!1;const r=e.x,s=t.x,a=n.x,o=e.y,l=t.y,c=n.y,f=Math.min(r,s,a),d=Math.min(o,l,c),p=Math.max(r,s,a),m=Math.max(o,l,c);let y=n.next;for(;y!==e;){if(y.x>=f&&y.x<=p&&y.y>=d&&y.y<=m&&Wh(r,o,s,l,a,c,y.x,y.y)&&Mn(y.prev,y,y.next)>=0)return!1;y=y.next}return!0}function cN(i,e,t,n){const r=i.prev,s=i,a=i.next;if(Mn(r,s,a)>=0)return!1;const o=r.x,l=s.x,c=a.x,f=r.y,d=s.y,p=a.y,m=Math.min(o,l,c),y=Math.min(f,d,p),x=Math.max(o,l,c),_=Math.max(f,d,p),g=j_(m,y,e,t,n),b=j_(x,_,e,t,n);let S=i.prevZ,E=i.nextZ;for(;S&&S.z>=g&&E&&E.z<=b;){if(S.x>=m&&S.x<=x&&S.y>=y&&S.y<=_&&S!==r&&S!==a&&Wh(o,f,l,d,c,p,S.x,S.y)&&Mn(S.prev,S,S.next)>=0||(S=S.prevZ,E.x>=m&&E.x<=x&&E.y>=y&&E.y<=_&&E!==r&&E!==a&&Wh(o,f,l,d,c,p,E.x,E.y)&&Mn(E.prev,E,E.next)>=0))return!1;E=E.nextZ}for(;S&&S.z>=g;){if(S.x>=m&&S.x<=x&&S.y>=y&&S.y<=_&&S!==r&&S!==a&&Wh(o,f,l,d,c,p,S.x,S.y)&&Mn(S.prev,S,S.next)>=0)return!1;S=S.prevZ}for(;E&&E.z<=b;){if(E.x>=m&&E.x<=x&&E.y>=y&&E.y<=_&&E!==r&&E!==a&&Wh(o,f,l,d,c,p,E.x,E.y)&&Mn(E.prev,E,E.next)>=0)return!1;E=E.nextZ}return!0}function uN(i,e){let t=i;do{const n=t.prev,r=t.next.next;!hu(n,r)&&I2(n,t,t.next,r)&&wf(n,r)&&wf(r,n)&&(e.push(n.i,t.i,r.i),Tf(t),Tf(t.next),t=i=r),t=t.next}while(t!==i);return Cl(t)}function hN(i,e,t,n,r,s){let a=i;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&xN(a,o)){let l=P2(a,o);a=Cl(a,a.next),l=Cl(l,l.next),Mf(a,e,t,n,r,s,0),Mf(l,e,t,n,r,s,0);return}o=o.next}a=a.next}while(a!==i)}function fN(i,e,t,n){const r=[];for(let s=0,a=e.length;s<a;s++){const o=e[s]*n,l=s<a-1?e[s+1]*n:i.length,c=L2(i,o,l,n,!1);c===c.next&&(c.steiner=!0),r.push(_N(c))}r.sort(dN);for(let s=0;s<r.length;s++)t=pN(r[s],t);return t}function dN(i,e){let t=i.x-e.x;if(t===0&&(t=i.y-e.y,t===0)){const n=(i.next.y-i.y)/(i.next.x-i.x),r=(e.next.y-e.y)/(e.next.x-e.x);t=n-r}return t}function pN(i,e){const t=mN(i,e);if(!t)return e;const n=P2(t,i);return Cl(n,n.next),Cl(t,t.next)}function mN(i,e){let t=e;const n=i.x,r=i.y;let s=-1/0,a;if(hu(i,t))return t;do{if(hu(i,t.next))return t.next;if(r<=t.y&&r>=t.next.y&&t.next.y!==t.y){const d=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=n&&d>s&&(s=d,a=t.x<t.next.x?t:t.next,d===n))return a}t=t.next}while(t!==e);if(!a)return null;const o=a,l=a.x,c=a.y;let f=1/0;t=a;do{if(n>=t.x&&t.x>=l&&n!==t.x&&N2(r<c?n:s,r,l,c,r<c?s:n,r,t.x,t.y)){const d=Math.abs(r-t.y)/(n-t.x);wf(t,i)&&(d<f||d===f&&(t.x>a.x||t.x===a.x&&gN(a,t)))&&(a=t,f=d)}t=t.next}while(t!==o);return a}function gN(i,e){return Mn(i.prev,i,e.prev)<0&&Mn(e.next,i,i.next)<0}function vN(i,e,t,n){let r=i;do r.z===0&&(r.z=j_(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,yN(r)}function yN(i){let e,t=1;do{let n=i,r;i=null;let s=null;for(e=0;n;){e++;let a=n,o=0;for(let c=0;c<t&&(o++,a=a.nextZ,!!a);c++);let l=t;for(;o>0||l>0&&a;)o!==0&&(l===0||!a||n.z<=a.z)?(r=n,n=n.nextZ,o--):(r=a,a=a.nextZ,l--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;n=a}s.nextZ=null,t*=2}while(e>1);return i}function j_(i,e,t,n,r){return i=(i-t)*r|0,e=(e-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function _N(i){let e=i,t=i;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==i);return t}function N2(i,e,t,n,r,s,a,o){return(r-a)*(e-o)>=(i-a)*(s-o)&&(i-a)*(n-o)>=(t-a)*(e-o)&&(t-a)*(s-o)>=(r-a)*(n-o)}function Wh(i,e,t,n,r,s,a,o){return!(i===a&&e===o)&&N2(i,e,t,n,r,s,a,o)}function xN(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!bN(i,e)&&(wf(i,e)&&wf(e,i)&&SN(i,e)&&(Mn(i.prev,i,e.prev)||Mn(i,e.prev,e))||hu(i,e)&&Mn(i.prev,i,i.next)>0&&Mn(e.prev,e,e.next)>0)}function Mn(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function hu(i,e){return i.x===e.x&&i.y===e.y}function I2(i,e,t,n){const r=Sp(Mn(i,e,t)),s=Sp(Mn(i,e,n)),a=Sp(Mn(t,n,i)),o=Sp(Mn(t,n,e));return!!(r!==s&&a!==o||r===0&&bp(i,t,e)||s===0&&bp(i,n,e)||a===0&&bp(t,i,n)||o===0&&bp(t,e,n))}function bp(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function Sp(i){return i>0?1:i<0?-1:0}function bN(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&I2(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function wf(i,e){return Mn(i.prev,i,i.next)<0?Mn(i,e,i.next)>=0&&Mn(i,i.prev,e)>=0:Mn(i,e,i.prev)<0||Mn(i,i.next,e)<0}function SN(i,e){let t=i,n=!1;const r=(i.x+e.x)/2,s=(i.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function P2(i,e){const t=q_(i.i,i.x,i.y),n=q_(e.i,e.x,e.y),r=i.next,s=e.prev;return i.next=e,e.prev=i,t.next=r,r.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function UE(i,e,t,n){const r=q_(i,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function Tf(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function q_(i,e,t){return{i,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function EN(i,e,t,n){let r=0;for(let s=e,a=t-n;s<t;s+=n)r+=(i[a]-i[s])*(i[s+1]+i[a+1]),a=s;return r}class MN{static triangulate(e,t,n=2){return oN(e,t,n)}}class as{static area(e){const t=e.length;let n=0;for(let r=t-1,s=0;s<t;r=s++)n+=e[r].x*e[s].y-e[s].x*e[r].y;return n*.5}static isClockWise(e){return as.area(e)<0}static triangulateShape(e,t){const n=[],r=[],s=[];OE(e),LE(n,e);let a=e.length;t.forEach(OE);for(let l=0;l<t.length;l++)r.push(a),a+=t[l].length,LE(n,t[l]);const o=MN.triangulate(n,r);for(let l=0;l<o.length;l+=3)s.push(o.slice(l,l+3));return s}}function OE(i){const e=i.length;e>2&&i[e-1].equals(i[0])&&i.pop()}function LE(i,e){for(let t=0;t<e.length;t++)i.push(e[t].x),i.push(e[t].y)}class qg extends Ct{constructor(e=new bl([new Ge(.5,.5),new Ge(-.5,.5),new Ge(-.5,-.5),new Ge(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,r=[],s=[];for(let o=0,l=e.length;o<l;o++){const c=e[o];a(c)}this.setAttribute("position",new dt(r,3)),this.setAttribute("uv",new dt(s,2)),this.computeVertexNormals();function a(o){const l=[],c=t.curveSegments!==void 0?t.curveSegments:12,f=t.steps!==void 0?t.steps:1,d=t.depth!==void 0?t.depth:1;let p=t.bevelEnabled!==void 0?t.bevelEnabled:!0,m=t.bevelThickness!==void 0?t.bevelThickness:.2,y=t.bevelSize!==void 0?t.bevelSize:m-.1,x=t.bevelOffset!==void 0?t.bevelOffset:0,_=t.bevelSegments!==void 0?t.bevelSegments:3;const g=t.extrudePath,b=t.UVGenerator!==void 0?t.UVGenerator:wN;let S,E=!1,w,T,R,U;g&&(S=g.getSpacedPoints(f),E=!0,p=!1,w=g.computeFrenetFrames(f,!1),T=new J,R=new J,U=new J),p||(_=0,m=0,y=0,x=0);const D=o.extractPoints(c);let C=D.shape;const P=D.holes;if(!as.isClockWise(C)){C=C.reverse();for(let V=0,se=P.length;V<se;V++){const te=P[V];as.isClockWise(te)&&(P[V]=te.reverse())}}function O(V){const te=10000000000000001e-36;let Ee=V[0];for(let ce=1;ce<=V.length;ce++){const De=ce%V.length,_e=V[De],re=_e.x-Ee.x,Ie=_e.y-Ee.y,X=re*re+Ie*Ie,F=Math.max(Math.abs(_e.x),Math.abs(_e.y),Math.abs(Ee.x),Math.abs(Ee.y)),ie=te*F*F;if(X<=ie){V.splice(De,1),ce--;continue}Ee=_e}}O(C),P.forEach(O);const G=P.length,Z=C;for(let V=0;V<G;V++){const se=P[V];C=C.concat(se)}function z(V,se,te){return se||console.error("THREE.ExtrudeGeometry: vec does not exist"),V.clone().addScaledVector(se,te)}const L=C.length;function B(V,se,te){let Ee,ce,De;const _e=V.x-se.x,re=V.y-se.y,Ie=te.x-V.x,X=te.y-V.y,F=_e*_e+re*re,ie=_e*X-re*Ie;if(Math.abs(ie)>Number.EPSILON){const Se=Math.sqrt(F),ve=Math.sqrt(Ie*Ie+X*X),ge=se.x-re/Se,Be=se.y+_e/Se,Pe=te.x-X/ve,je=te.y+Ie/ve,Ze=((Pe-ge)*X-(je-Be)*Ie)/(_e*X-re*Ie);Ee=ge+_e*Ze-V.x,ce=Be+re*Ze-V.y;const Ce=Ee*Ee+ce*ce;if(Ce<=2)return new Ge(Ee,ce);De=Math.sqrt(Ce/2)}else{let Se=!1;_e>Number.EPSILON?Ie>Number.EPSILON&&(Se=!0):_e<-Number.EPSILON?Ie<-Number.EPSILON&&(Se=!0):Math.sign(re)===Math.sign(X)&&(Se=!0),Se?(Ee=-re,ce=_e,De=Math.sqrt(F)):(Ee=_e,ce=re,De=Math.sqrt(F/2))}return new Ge(Ee/De,ce/De)}const H=[];for(let V=0,se=Z.length,te=se-1,Ee=V+1;V<se;V++,te++,Ee++)te===se&&(te=0),Ee===se&&(Ee=0),H[V]=B(Z[V],Z[te],Z[Ee]);const W=[];let k,K=H.concat();for(let V=0,se=G;V<se;V++){const te=P[V];k=[];for(let Ee=0,ce=te.length,De=ce-1,_e=Ee+1;Ee<ce;Ee++,De++,_e++)De===ce&&(De=0),_e===ce&&(_e=0),k[Ee]=B(te[Ee],te[De],te[_e]);W.push(k),K=K.concat(k)}let $;if(_===0)$=as.triangulateShape(Z,P);else{const V=[],se=[];for(let te=0;te<_;te++){const Ee=te/_,ce=m*Math.cos(Ee*Math.PI/2),De=y*Math.sin(Ee*Math.PI/2)+x;for(let _e=0,re=Z.length;_e<re;_e++){const Ie=z(Z[_e],H[_e],De);Le(Ie.x,Ie.y,-ce),Ee===0&&V.push(Ie)}for(let _e=0,re=G;_e<re;_e++){const Ie=P[_e];k=W[_e];const X=[];for(let F=0,ie=Ie.length;F<ie;F++){const Se=z(Ie[F],k[F],De);Le(Se.x,Se.y,-ce),Ee===0&&X.push(Se)}Ee===0&&se.push(X)}}$=as.triangulateShape(V,se)}const j=$.length,ee=y+x;for(let V=0;V<L;V++){const se=p?z(C[V],K[V],ee):C[V];E?(R.copy(w.normals[0]).multiplyScalar(se.x),T.copy(w.binormals[0]).multiplyScalar(se.y),U.copy(S[0]).add(R).add(T),Le(U.x,U.y,U.z)):Le(se.x,se.y,0)}for(let V=1;V<=f;V++)for(let se=0;se<L;se++){const te=p?z(C[se],K[se],ee):C[se];E?(R.copy(w.normals[V]).multiplyScalar(te.x),T.copy(w.binormals[V]).multiplyScalar(te.y),U.copy(S[V]).add(R).add(T),Le(U.x,U.y,U.z)):Le(te.x,te.y,d/f*V)}for(let V=_-1;V>=0;V--){const se=V/_,te=m*Math.cos(se*Math.PI/2),Ee=y*Math.sin(se*Math.PI/2)+x;for(let ce=0,De=Z.length;ce<De;ce++){const _e=z(Z[ce],H[ce],Ee);Le(_e.x,_e.y,d+te)}for(let ce=0,De=P.length;ce<De;ce++){const _e=P[ce];k=W[ce];for(let re=0,Ie=_e.length;re<Ie;re++){const X=z(_e[re],k[re],Ee);E?Le(X.x,X.y+S[f-1].y,S[f-1].x+te):Le(X.x,X.y,d+te)}}}de(),ae();function de(){const V=r.length/3;if(p){let se=0,te=L*se;for(let Ee=0;Ee<j;Ee++){const ce=$[Ee];xe(ce[2]+te,ce[1]+te,ce[0]+te)}se=f+_*2,te=L*se;for(let Ee=0;Ee<j;Ee++){const ce=$[Ee];xe(ce[0]+te,ce[1]+te,ce[2]+te)}}else{for(let se=0;se<j;se++){const te=$[se];xe(te[2],te[1],te[0])}for(let se=0;se<j;se++){const te=$[se];xe(te[0]+L*f,te[1]+L*f,te[2]+L*f)}}n.addGroup(V,r.length/3-V,0)}function ae(){const V=r.length/3;let se=0;pe(Z,se),se+=Z.length;for(let te=0,Ee=P.length;te<Ee;te++){const ce=P[te];pe(ce,se),se+=ce.length}n.addGroup(V,r.length/3-V,1)}function pe(V,se){let te=V.length;for(;--te>=0;){const Ee=te;let ce=te-1;ce<0&&(ce=V.length-1);for(let De=0,_e=f+_*2;De<_e;De++){const re=L*De,Ie=L*(De+1),X=se+Ee+re,F=se+ce+re,ie=se+ce+Ie,Se=se+Ee+Ie;me(X,F,ie,Se)}}}function Le(V,se,te){l.push(V),l.push(se),l.push(te)}function xe(V,se,te){ne(V),ne(se),ne(te);const Ee=r.length/3,ce=b.generateTopUV(n,r,Ee-3,Ee-2,Ee-1);Ue(ce[0]),Ue(ce[1]),Ue(ce[2])}function me(V,se,te,Ee){ne(V),ne(se),ne(Ee),ne(se),ne(te),ne(Ee);const ce=r.length/3,De=b.generateSideWallUV(n,r,ce-6,ce-3,ce-2,ce-1);Ue(De[0]),Ue(De[1]),Ue(De[3]),Ue(De[1]),Ue(De[2]),Ue(De[3])}function ne(V){r.push(l[V*3+0]),r.push(l[V*3+1]),r.push(l[V*3+2])}function Ue(V){s.push(V.x),s.push(V.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options;return TN(t,n,e)}static fromJSON(e,t){const n=[];for(let s=0,a=e.shapes.length;s<a;s++){const o=t[e.shapes[s]];n.push(o)}const r=e.options.extrudePath;return r!==void 0&&(e.options.extrudePath=new eg[r.type]().fromJSON(r)),new qg(n,e.options)}}const wN={generateTopUV:function(i,e,t,n,r){const s=e[t*3],a=e[t*3+1],o=e[n*3],l=e[n*3+1],c=e[r*3],f=e[r*3+1];return[new Ge(s,a),new Ge(o,l),new Ge(c,f)]},generateSideWallUV:function(i,e,t,n,r,s){const a=e[t*3],o=e[t*3+1],l=e[t*3+2],c=e[n*3],f=e[n*3+1],d=e[n*3+2],p=e[r*3],m=e[r*3+1],y=e[r*3+2],x=e[s*3],_=e[s*3+1],g=e[s*3+2];return Math.abs(o-f)<Math.abs(a-c)?[new Ge(a,1-l),new Ge(c,1-d),new Ge(p,1-y),new Ge(x,1-g)]:[new Ge(o,1-l),new Ge(f,1-d),new Ge(m,1-y),new Ge(_,1-g)]}};function TN(i,e,t){if(t.shapes=[],Array.isArray(i))for(let n=0,r=i.length;n<r;n++){const s=i[n];t.shapes.push(s.uuid)}else t.shapes.push(i.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class Yg extends go{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,r=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Yg(e.radius,e.detail)}}class Zg extends Ct{constructor(e=[new Ge(0,-.5),new Ge(.5,0),new Ge(0,.5)],t=12,n=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:r},t=Math.floor(t),r=Tt(r,0,Math.PI*2);const s=[],a=[],o=[],l=[],c=[],f=1/t,d=new J,p=new Ge,m=new J,y=new J,x=new J;let _=0,g=0;for(let b=0;b<=e.length-1;b++)switch(b){case 0:_=e[b+1].x-e[b].x,g=e[b+1].y-e[b].y,m.x=g*1,m.y=-_,m.z=g*0,x.copy(m),m.normalize(),l.push(m.x,m.y,m.z);break;case e.length-1:l.push(x.x,x.y,x.z);break;default:_=e[b+1].x-e[b].x,g=e[b+1].y-e[b].y,m.x=g*1,m.y=-_,m.z=g*0,y.copy(m),m.x+=x.x,m.y+=x.y,m.z+=x.z,m.normalize(),l.push(m.x,m.y,m.z),x.copy(y)}for(let b=0;b<=t;b++){const S=n+b*f*r,E=Math.sin(S),w=Math.cos(S);for(let T=0;T<=e.length-1;T++){d.x=e[T].x*E,d.y=e[T].y,d.z=e[T].x*w,a.push(d.x,d.y,d.z),p.x=b/t,p.y=T/(e.length-1),o.push(p.x,p.y);const R=l[3*T+0]*E,U=l[3*T+1],D=l[3*T+0]*w;c.push(R,U,D)}}for(let b=0;b<t;b++)for(let S=0;S<e.length-1;S++){const E=S+b*e.length,w=E,T=E+e.length,R=E+e.length+1,U=E+1;s.push(w,T,U),s.push(R,U,T)}this.setIndex(s),this.setAttribute("position",new dt(a,3)),this.setAttribute("uv",new dt(o,2)),this.setAttribute("normal",new dt(c,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Zg(e.points,e.segments,e.phiStart,e.phiLength)}}class Kf extends go{constructor(e=1,t=0){const n=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],r=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(n,r,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Kf(e.radius,e.detail)}}class Ma extends Ct{constructor(e=1,t=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};const s=e/2,a=t/2,o=Math.floor(n),l=Math.floor(r),c=o+1,f=l+1,d=e/o,p=t/l,m=[],y=[],x=[],_=[];for(let g=0;g<f;g++){const b=g*p-a;for(let S=0;S<c;S++){const E=S*d-s;y.push(E,-b,0),x.push(0,0,1),_.push(S/o),_.push(1-g/l)}}for(let g=0;g<l;g++)for(let b=0;b<o;b++){const S=b+c*g,E=b+c*(g+1),w=b+1+c*(g+1),T=b+1+c*g;m.push(S,E,T),m.push(E,w,T)}this.setIndex(m),this.setAttribute("position",new dt(y,3)),this.setAttribute("normal",new dt(x,3)),this.setAttribute("uv",new dt(_,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ma(e.width,e.height,e.widthSegments,e.heightSegments)}}class Kg extends Ct{constructor(e=.5,t=1,n=32,r=1,s=0,a=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:r,thetaStart:s,thetaLength:a},n=Math.max(3,n),r=Math.max(1,r);const o=[],l=[],c=[],f=[];let d=e;const p=(t-e)/r,m=new J,y=new Ge;for(let x=0;x<=r;x++){for(let _=0;_<=n;_++){const g=s+_/n*a;m.x=d*Math.cos(g),m.y=d*Math.sin(g),l.push(m.x,m.y,m.z),c.push(0,0,1),y.x=(m.x/t+1)/2,y.y=(m.y/t+1)/2,f.push(y.x,y.y)}d+=p}for(let x=0;x<r;x++){const _=x*(n+1);for(let g=0;g<n;g++){const b=g+_,S=b,E=b+n+1,w=b+n+2,T=b+1;o.push(S,E,T),o.push(E,w,T)}}this.setIndex(o),this.setAttribute("position",new dt(l,3)),this.setAttribute("normal",new dt(c,3)),this.setAttribute("uv",new dt(f,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Kg(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class Jg extends Ct{constructor(e=new bl([new Ge(0,.5),new Ge(-.5,-.5),new Ge(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const n=[],r=[],s=[],a=[];let o=0,l=0;if(Array.isArray(e)===!1)c(e);else for(let f=0;f<e.length;f++)c(e[f]),this.addGroup(o,l,f),o+=l,l=0;this.setIndex(n),this.setAttribute("position",new dt(r,3)),this.setAttribute("normal",new dt(s,3)),this.setAttribute("uv",new dt(a,2));function c(f){const d=r.length/3,p=f.extractPoints(t);let m=p.shape;const y=p.holes;as.isClockWise(m)===!1&&(m=m.reverse());for(let _=0,g=y.length;_<g;_++){const b=y[_];as.isClockWise(b)===!0&&(y[_]=b.reverse())}const x=as.triangulateShape(m,y);for(let _=0,g=y.length;_<g;_++){const b=y[_];m=m.concat(b)}for(let _=0,g=m.length;_<g;_++){const b=m[_];r.push(b.x,b.y,0),s.push(0,0,1),a.push(b.x,b.y)}for(let _=0,g=x.length;_<g;_++){const b=x[_],S=b[0]+d,E=b[1]+d,w=b[2]+d;n.push(S,E,w),l+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return AN(t,e)}static fromJSON(e,t){const n=[];for(let r=0,s=e.shapes.length;r<s;r++){const a=t[e.shapes[r]];n.push(a)}return new Jg(n,e.curveSegments)}}function AN(i,e){if(e.shapes=[],Array.isArray(i))for(let t=0,n=i.length;t<n;t++){const r=i[t];e.shapes.push(r.uuid)}else e.shapes.push(i.uuid);return e}class Jf extends Ct{constructor(e=1,t=32,n=16,r=0,s=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:r,phiLength:s,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const l=Math.min(a+o,Math.PI);let c=0;const f=[],d=new J,p=new J,m=[],y=[],x=[],_=[];for(let g=0;g<=n;g++){const b=[],S=g/n;let E=0;g===0&&a===0?E=.5/t:g===n&&l===Math.PI&&(E=-.5/t);for(let w=0;w<=t;w++){const T=w/t;d.x=-e*Math.cos(r+T*s)*Math.sin(a+S*o),d.y=e*Math.cos(a+S*o),d.z=e*Math.sin(r+T*s)*Math.sin(a+S*o),y.push(d.x,d.y,d.z),p.copy(d).normalize(),x.push(p.x,p.y,p.z),_.push(T+E,1-S),b.push(c++)}f.push(b)}for(let g=0;g<n;g++)for(let b=0;b<t;b++){const S=f[g][b+1],E=f[g][b],w=f[g+1][b],T=f[g+1][b+1];(g!==0||a>0)&&m.push(S,E,T),(g!==n-1||l<Math.PI)&&m.push(E,w,T)}this.setIndex(m),this.setAttribute("position",new dt(y,3)),this.setAttribute("normal",new dt(x,3)),this.setAttribute("uv",new dt(_,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Jf(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class Qg extends go{constructor(e=1,t=0){const n=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],r=[2,1,0,0,3,2,1,3,0,2,3,1];super(n,r,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Qg(e.radius,e.detail)}}class $g extends Ct{constructor(e=1,t=.4,n=12,r=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:r,arc:s},n=Math.floor(n),r=Math.floor(r);const a=[],o=[],l=[],c=[],f=new J,d=new J,p=new J;for(let m=0;m<=n;m++)for(let y=0;y<=r;y++){const x=y/r*s,_=m/n*Math.PI*2;d.x=(e+t*Math.cos(_))*Math.cos(x),d.y=(e+t*Math.cos(_))*Math.sin(x),d.z=t*Math.sin(_),o.push(d.x,d.y,d.z),f.x=e*Math.cos(x),f.y=e*Math.sin(x),p.subVectors(d,f).normalize(),l.push(p.x,p.y,p.z),c.push(y/r),c.push(m/n)}for(let m=1;m<=n;m++)for(let y=1;y<=r;y++){const x=(r+1)*m+y-1,_=(r+1)*(m-1)+y-1,g=(r+1)*(m-1)+y,b=(r+1)*m+y;a.push(x,_,b),a.push(_,g,b)}this.setIndex(a),this.setAttribute("position",new dt(o,3)),this.setAttribute("normal",new dt(l,3)),this.setAttribute("uv",new dt(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new $g(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class e0 extends Ct{constructor(e=1,t=.4,n=64,r=8,s=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:r,p:s,q:a},n=Math.floor(n),r=Math.floor(r);const o=[],l=[],c=[],f=[],d=new J,p=new J,m=new J,y=new J,x=new J,_=new J,g=new J;for(let S=0;S<=n;++S){const E=S/n*s*Math.PI*2;b(E,s,a,e,m),b(E+.01,s,a,e,y),_.subVectors(y,m),g.addVectors(y,m),x.crossVectors(_,g),g.crossVectors(x,_),x.normalize(),g.normalize();for(let w=0;w<=r;++w){const T=w/r*Math.PI*2,R=-t*Math.cos(T),U=t*Math.sin(T);d.x=m.x+(R*g.x+U*x.x),d.y=m.y+(R*g.y+U*x.y),d.z=m.z+(R*g.z+U*x.z),l.push(d.x,d.y,d.z),p.subVectors(d,m).normalize(),c.push(p.x,p.y,p.z),f.push(S/n),f.push(w/r)}}for(let S=1;S<=n;S++)for(let E=1;E<=r;E++){const w=(r+1)*(S-1)+(E-1),T=(r+1)*S+(E-1),R=(r+1)*S+E,U=(r+1)*(S-1)+E;o.push(w,T,U),o.push(T,R,U)}this.setIndex(o),this.setAttribute("position",new dt(l,3)),this.setAttribute("normal",new dt(c,3)),this.setAttribute("uv",new dt(f,2));function b(S,E,w,T,R){const U=Math.cos(S),D=Math.sin(S),C=w/E*S,P=Math.cos(C);R.x=T*(2+P)*.5*U,R.y=T*(2+P)*D*.5,R.z=T*Math.sin(C)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new e0(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class Rl extends Ct{constructor(e=new jg(new J(-1,-1,0),new J(-1,1,0),new J(1,1,0)),t=64,n=1,r=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:r,closed:s};const a=e.computeFrenetFrames(t,s);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;const o=new J,l=new J,c=new Ge;let f=new J;const d=[],p=[],m=[],y=[];x(),this.setIndex(y),this.setAttribute("position",new dt(d,3)),this.setAttribute("normal",new dt(p,3)),this.setAttribute("uv",new dt(m,2));function x(){for(let S=0;S<t;S++)_(S);_(s===!1?t:0),b(),g()}function _(S){f=e.getPointAt(S/t,f);const E=a.normals[S],w=a.binormals[S];for(let T=0;T<=r;T++){const R=T/r*Math.PI*2,U=Math.sin(R),D=-Math.cos(R);l.x=D*E.x+U*w.x,l.y=D*E.y+U*w.y,l.z=D*E.z+U*w.z,l.normalize(),p.push(l.x,l.y,l.z),o.x=f.x+n*l.x,o.y=f.y+n*l.y,o.z=f.z+n*l.z,d.push(o.x,o.y,o.z)}}function g(){for(let S=1;S<=t;S++)for(let E=1;E<=r;E++){const w=(r+1)*(S-1)+(E-1),T=(r+1)*S+(E-1),R=(r+1)*S+E,U=(r+1)*(S-1)+E;y.push(w,T,U),y.push(T,R,U)}}function b(){for(let S=0;S<=t;S++)for(let E=0;E<=r;E++)c.x=S/t,c.y=E/r,m.push(c.x,c.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new Rl(new eg[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class z2 extends Ct{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],n=new Set,r=new J,s=new J;if(e.index!==null){const a=e.attributes.position,o=e.index;let l=e.groups;l.length===0&&(l=[{start:0,count:o.count,materialIndex:0}]);for(let c=0,f=l.length;c<f;++c){const d=l[c],p=d.start,m=d.count;for(let y=p,x=p+m;y<x;y+=3)for(let _=0;_<3;_++){const g=o.getX(y+_),b=o.getX(y+(_+1)%3);r.fromBufferAttribute(a,g),s.fromBufferAttribute(a,b),NE(r,s,n)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}}else{const a=e.attributes.position;for(let o=0,l=a.count/3;o<l;o++)for(let c=0;c<3;c++){const f=3*o+c,d=3*o+(c+1)%3;r.fromBufferAttribute(a,f),s.fromBufferAttribute(a,d),NE(r,s,n)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new dt(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function NE(i,e,t){const n=`${i.x},${i.y},${i.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${i.x},${i.y},${i.z}`;return t.has(n)===!0||t.has(r)===!0?!1:(t.add(n),t.add(r),!0)}var IE=Object.freeze({__proto__:null,BoxGeometry:Ea,CapsuleGeometry:Hg,CircleGeometry:Vg,ConeGeometry:Zf,CylinderGeometry:Su,DodecahedronGeometry:Wg,EdgesGeometry:C2,ExtrudeGeometry:qg,IcosahedronGeometry:Yg,LatheGeometry:Zg,OctahedronGeometry:Kf,PlaneGeometry:Ma,PolyhedronGeometry:go,RingGeometry:Kg,ShapeGeometry:Jg,SphereGeometry:Jf,TetrahedronGeometry:Qg,TorusGeometry:$g,TorusKnotGeometry:e0,TubeGeometry:Rl,WireframeGeometry:z2});class F2 extends Oi{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new et(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}class B2 extends ls{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class o1 extends Oi{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new et(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new et(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=mo,this.normalScale=new Ge(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ui,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class k2 extends o1{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ge(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Tt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new et(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new et(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new et(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class G2 extends Oi{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new et(16777215),this.specular=new et(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new et(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=mo,this.normalScale=new Ge(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ui,this.combine=jf,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class H2 extends Oi{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new et(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new et(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=mo,this.normalScale=new Ge(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class V2 extends Oi{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=mo,this.normalScale=new Ge(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class W2 extends Oi{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new et(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new et(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=mo,this.normalScale=new Ge(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ui,this.combine=jf,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class t0 extends Oi{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=i2,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class n0 extends Oi{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class X2 extends Oi{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new et(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=mo,this.normalScale=new Ge(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class j2 extends Gi{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function gl(i,e){return!i||i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}function q2(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function Y2(i){function e(r,s){return i[r]-i[s]}const t=i.length,n=new Array(t);for(let r=0;r!==t;++r)n[r]=r;return n.sort(e),n}function Y_(i,e,t){const n=i.length,r=new i.constructor(n);for(let s=0,a=0;a!==n;++s){const o=t[s]*e;for(let l=0;l!==e;++l)r[a++]=i[o+l]}return r}function l1(i,e,t,n){let r=1,s=i[0];for(;s!==void 0&&s[n]===void 0;)s=i[r++];if(s===void 0)return;let a=s[n];if(a!==void 0)if(Array.isArray(a))do a=s[n],a!==void 0&&(e.push(s.time),t.push(...a)),s=i[r++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[n],a!==void 0&&(e.push(s.time),a.toArray(t,t.length)),s=i[r++];while(s!==void 0);else do a=s[n],a!==void 0&&(e.push(s.time),t.push(a)),s=i[r++];while(s!==void 0)}function CN(i,e,t,n,r=30){const s=i.clone();s.name=e;const a=[];for(let l=0;l<s.tracks.length;++l){const c=s.tracks[l],f=c.getValueSize(),d=[],p=[];for(let m=0;m<c.times.length;++m){const y=c.times[m]*r;if(!(y<t||y>=n)){d.push(c.times[m]);for(let x=0;x<f;++x)p.push(c.values[m*f+x])}}d.length!==0&&(c.times=gl(d,c.times.constructor),c.values=gl(p,c.values.constructor),a.push(c))}s.tracks=a;let o=1/0;for(let l=0;l<s.tracks.length;++l)o>s.tracks[l].times[0]&&(o=s.tracks[l].times[0]);for(let l=0;l<s.tracks.length;++l)s.tracks[l].shift(-1*o);return s.resetDuration(),s}function RN(i,e=0,t=i,n=30){n<=0&&(n=30);const r=t.tracks.length,s=e/n;for(let a=0;a<r;++a){const o=t.tracks[a],l=o.ValueTypeName;if(l==="bool"||l==="string")continue;const c=i.tracks.find(function(g){return g.name===o.name&&g.ValueTypeName===l});if(c===void 0)continue;let f=0;const d=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(f=d/3);let p=0;const m=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(p=m/3);const y=o.times.length-1;let x;if(s<=o.times[0]){const g=f,b=d-f;x=o.values.slice(g,b)}else if(s>=o.times[y]){const g=y*d+f,b=g+d-f;x=o.values.slice(g,b)}else{const g=o.createInterpolant(),b=f,S=d-f;g.evaluate(s),x=g.resultBuffer.slice(b,S)}l==="quaternion"&&new _i().fromArray(x).normalize().conjugate().toArray(x);const _=c.times.length;for(let g=0;g<_;++g){const b=g*m+p;if(l==="quaternion")_i.multiplyQuaternionsFlat(c.values,b,x,0,c.values,b);else{const S=m-p*2;for(let E=0;E<S;++E)c.values[b+E]-=x[E]}}}return i.blendMode=Vx,i}class DN{static convertArray(e,t){return gl(e,t)}static isTypedArray(e){return q2(e)}static getKeyframeOrder(e){return Y2(e)}static sortedArray(e,t,n){return Y_(e,t,n)}static flattenJSON(e,t,n,r){l1(e,t,n,r)}static subclip(e,t,n,r,s=30){return CN(e,t,n,r,s)}static makeClipAdditive(e,t=0,n=e,r=30){return RN(e,t,n,r)}}class Qf{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,r=t[n],s=t[n-1];e:{t:{let a;n:{i:if(!(e<r)){for(let o=n+2;;){if(r===void 0){if(e<s)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(s=r,r=t[++n],e<r)break t}a=t.length;break n}if(!(e>=s)){const o=t[1];e<o&&(n=2,s=o);for(let l=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(r=s,s=t[--n-1],e>=s)break t}a=n,n=0;break n}break e}for(;n<a;){const o=n+a>>>1;e<t[o]?a=o:n=o+1}if(r=t[n],s=t[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,r)}return this.interpolate_(n,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,s=e*r;for(let a=0;a!==r;++a)t[a]=n[s+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class Z2 extends Qf{constructor(e,t,n,r){super(e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:pl,endingEnd:pl}}intervalChanged_(e,t,n){const r=this.parameterPositions;let s=e-2,a=e+1,o=r[s],l=r[a];if(o===void 0)switch(this.getSettings_().endingStart){case ml:s=e,o=2*t-n;break;case _f:s=r.length-2,o=t+r[s]-r[s+1];break;default:s=e,o=n}if(l===void 0)switch(this.getSettings_().endingEnd){case ml:a=e,l=2*n-t;break;case _f:a=1,l=n+r[1]-r[0];break;default:a=e-1,l=t}const c=(n-t)*.5,f=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(l-n),this._offsetPrev=s*f,this._offsetNext=a*f}interpolate_(e,t,n,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,f=this._offsetPrev,d=this._offsetNext,p=this._weightPrev,m=this._weightNext,y=(n-t)/(r-t),x=y*y,_=x*y,g=-p*_+2*p*x-p*y,b=(1+p)*_+(-1.5-2*p)*x+(-.5+p)*y+1,S=(-1-m)*_+(1.5+m)*x+.5*y,E=m*_-m*x;for(let w=0;w!==o;++w)s[w]=g*a[f+w]+b*a[c+w]+S*a[l+w]+E*a[d+w];return s}}class c1 extends Qf{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,f=(n-t)/(r-t),d=1-f;for(let p=0;p!==o;++p)s[p]=a[c+p]*d+a[l+p]*f;return s}}class K2 extends Qf{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}}class Hr{constructor(e,t,n,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=gl(t,this.TimeBufferType),this.values=gl(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:gl(e.times,Array),values:gl(e.values,Array)};const r=e.getInterpolation();r!==e.DefaultInterpolation&&(n.interpolation=r)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new K2(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new c1(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Z2(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case yf:t=this.InterpolantFactoryMethodDiscrete;break;case Km:t=this.InterpolantFactoryMethodLinear;break;case im:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return yf;case this.InterpolantFactoryMethodLinear:return Km;case this.InterpolantFactoryMethodSmooth:return im}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e}return this}trim(e,t){const n=this.times,r=n.length;let s=0,a=r-1;for(;s!==r&&n[s]<e;)++s;for(;a!==-1&&n[a]>t;)--a;if(++a,s!==0||a!==r){s>=a&&(a=Math.max(a,1),s=a-1);const o=this.getValueSize();this.times=n.slice(s,a),this.values=this.values.slice(s*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,r=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==s;o++){const l=n[o];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(r!==void 0&&q2(r))for(let o=0,l=r.length;o!==l;++o){const c=r[o];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===im,s=e.length-1;let a=1;for(let o=1;o<s;++o){let l=!1;const c=e[o],f=e[o+1];if(c!==f&&(o!==1||c!==e[0]))if(r)l=!0;else{const d=o*n,p=d-n,m=d+n;for(let y=0;y!==n;++y){const x=t[d+y];if(x!==t[p+y]||x!==t[m+y]){l=!0;break}}}if(l){if(o!==a){e[a]=e[o];const d=o*n,p=a*n;for(let m=0;m!==n;++m)t[p+m]=t[d+m]}++a}}if(s>0){e[a]=e[s];for(let o=s*n,l=a*n,c=0;c!==n;++c)t[l+c]=t[o+c];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}Hr.prototype.ValueTypeName="";Hr.prototype.TimeBufferType=Float32Array;Hr.prototype.ValueBufferType=Float32Array;Hr.prototype.DefaultInterpolation=Km;class Nl extends Hr{constructor(e,t,n){super(e,t,n)}}Nl.prototype.ValueTypeName="bool";Nl.prototype.ValueBufferType=Array;Nl.prototype.DefaultInterpolation=yf;Nl.prototype.InterpolantFactoryMethodLinear=void 0;Nl.prototype.InterpolantFactoryMethodSmooth=void 0;class u1 extends Hr{constructor(e,t,n,r){super(e,t,n,r)}}u1.prototype.ValueTypeName="color";class Af extends Hr{constructor(e,t,n,r){super(e,t,n,r)}}Af.prototype.ValueTypeName="number";class J2 extends Qf{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(n-t)/(r-t);let c=e*o;for(let f=c+o;c!==f;c+=4)_i.slerpFlat(s,0,a,c-o,a,c,l);return s}}class $f extends Hr{constructor(e,t,n,r){super(e,t,n,r)}InterpolantFactoryMethodLinear(e){return new J2(this.times,this.values,this.getValueSize(),e)}}$f.prototype.ValueTypeName="quaternion";$f.prototype.InterpolantFactoryMethodSmooth=void 0;class Il extends Hr{constructor(e,t,n){super(e,t,n)}}Il.prototype.ValueTypeName="string";Il.prototype.ValueBufferType=Array;Il.prototype.DefaultInterpolation=yf;Il.prototype.InterpolantFactoryMethodLinear=void 0;Il.prototype.InterpolantFactoryMethodSmooth=void 0;class Cf extends Hr{constructor(e,t,n,r){super(e,t,n,r)}}Cf.prototype.ValueTypeName="vector";class Rf{constructor(e="",t=-1,n=[],r=Ug){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=vr(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,r=1/(e.fps||1);for(let a=0,o=n.length;a!==o;++a)t.push(ON(n[a]).scale(r));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,a=n.length;s!==a;++s)t.push(Hr.toJSON(n[s]));return r}static CreateFromMorphTargetSequence(e,t,n,r){const s=t.length,a=[];for(let o=0;o<s;o++){let l=[],c=[];l.push((o+s-1)%s,o,(o+1)%s),c.push(0,1,0);const f=Y2(l);l=Y_(l,1,f),c=Y_(c,1,f),!r&&l[0]===0&&(l.push(s),c.push(c[0])),a.push(new Af(".morphTargetInfluences["+t[o].name+"]",l,c).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const r=e;n=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<n.length;r++)if(n[r].name===t)return n[r];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const r={},s=/^([\w-]*?)([\d]+)$/;for(let o=0,l=e.length;o<l;o++){const c=e[o],f=c.name.match(s);if(f&&f.length>1){const d=f[1];let p=r[d];p||(r[d]=p=[]),p.push(c)}}const a=[];for(const o in r)a.push(this.CreateFromMorphTargetSequence(o,r[o],t,n));return a}static parseAnimation(e,t){if(console.warn("THREE.AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(d,p,m,y,x){if(m.length!==0){const _=[],g=[];l1(m,_,g,y),_.length!==0&&x.push(new d(p,_,g))}},r=[],s=e.name||"default",a=e.fps||30,o=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let d=0;d<c.length;d++){const p=c[d].keys;if(!(!p||p.length===0))if(p[0].morphTargets){const m={};let y;for(y=0;y<p.length;y++)if(p[y].morphTargets)for(let x=0;x<p[y].morphTargets.length;x++)m[p[y].morphTargets[x]]=-1;for(const x in m){const _=[],g=[];for(let b=0;b!==p[y].morphTargets.length;++b){const S=p[y];_.push(S.time),g.push(S.morphTarget===x?1:0)}r.push(new Af(".morphTargetInfluence["+x+"]",_,g))}l=m.length*a}else{const m=".bones["+t[d].name+"]";n(Cf,m+".position",p,"pos",r),n($f,m+".quaternion",p,"rot",r),n(Cf,m+".scale",p,"scl",r)}}return r.length===0?null:new this(s,l,r,o)}resetDuration(){const e=this.tracks;let t=0;for(let n=0,r=e.length;n!==r;++n){const s=this.tracks[n];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function UN(i){switch(i.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Af;case"vector":case"vector2":case"vector3":case"vector4":return Cf;case"color":return u1;case"quaternion":return $f;case"bool":case"boolean":return Nl;case"string":return Il}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+i)}function ON(i){if(i.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=UN(i.type);if(i.times===void 0){const t=[],n=[];l1(i.keys,t,n,"value"),i.times=t,i.values=n}return e.parse!==void 0?e.parse(i):new e(i.name,i.times,i.values,i.interpolation)}const fa={enabled:!1,files:{},add:function(i,e){this.enabled!==!1&&(this.files[i]=e)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};class h1{constructor(e,t,n){const r=this;let s=!1,a=0,o=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(f){o++,s===!1&&r.onStart!==void 0&&r.onStart(f,a,o),s=!0},this.itemEnd=function(f){a++,r.onProgress!==void 0&&r.onProgress(f,a,o),a===o&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(f){r.onError!==void 0&&r.onError(f)},this.resolveURL=function(f){return l?l(f):f},this.setURLModifier=function(f){return l=f,this},this.addHandler=function(f,d){return c.push(f,d),this},this.removeHandler=function(f){const d=c.indexOf(f);return d!==-1&&c.splice(d,2),this},this.getHandler=function(f){for(let d=0,p=c.length;d<p;d+=2){const m=c[d],y=c[d+1];if(m.global&&(m.lastIndex=0),m.test(f))return y}return null}}}const Q2=new h1;class ir{constructor(e){this.manager=e!==void 0?e:Q2,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise(function(r,s){n.load(e,r,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}ir.DEFAULT_MATERIAL_NAME="__DEFAULT";const ta={};class LN extends Error{constructor(e,t){super(e),this.response=t}}class xa extends ir{constructor(e){super(e),this.mimeType="",this.responseType=""}load(e,t,n,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=fa.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(ta[e]!==void 0){ta[e].push({onLoad:t,onProgress:n,onError:r});return}ta[e]=[],ta[e].push({onLoad:t,onProgress:n,onError:r});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const f=ta[e],d=c.body.getReader(),p=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),m=p?parseInt(p):0,y=m!==0;let x=0;const _=new ReadableStream({start(g){b();function b(){d.read().then(({done:S,value:E})=>{if(S)g.close();else{x+=E.byteLength;const w=new ProgressEvent("progress",{lengthComputable:y,loaded:x,total:m});for(let T=0,R=f.length;T<R;T++){const U=f[T];U.onProgress&&U.onProgress(w)}g.enqueue(E),b()}},S=>{g.error(S)})}}});return new Response(_)}else throw new LN(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(f=>new DOMParser().parseFromString(f,o));case"json":return c.json();default:if(o==="")return c.text();{const d=/charset="?([^;"\s]*)"?/i.exec(o),p=d&&d[1]?d[1].toLowerCase():void 0,m=new TextDecoder(p);return c.arrayBuffer().then(y=>m.decode(y))}}}).then(c=>{fa.add(e,c);const f=ta[e];delete ta[e];for(let d=0,p=f.length;d<p;d++){const m=f[d];m.onLoad&&m.onLoad(c)}}).catch(c=>{const f=ta[e];if(f===void 0)throw this.manager.itemError(e),c;delete ta[e];for(let d=0,p=f.length;d<p;d++){const m=f[d];m.onError&&m.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class NN extends ir{constructor(e){super(e)}load(e,t,n,r){const s=this,a=new xa(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},n,r)}parse(e){const t=[];for(let n=0;n<e.length;n++){const r=Rf.parse(e[n]);t.push(r)}return t}}class IN extends ir{constructor(e){super(e)}load(e,t,n,r){const s=this,a=[],o=new Gg,l=new xa(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(s.withCredentials);let c=0;function f(d){l.load(e[d],function(p){const m=s.parse(p,!0);a[d]={width:m.width,height:m.height,format:m.format,mipmaps:m.mipmaps},c+=1,c===6&&(m.mipmapCount===1&&(o.minFilter=Pn),o.image=a,o.format=m.format,o.needsUpdate=!0,t&&t(o))},n,r)}if(Array.isArray(e))for(let d=0,p=e.length;d<p;++d)f(d);else l.load(e,function(d){const p=s.parse(d,!0);if(p.isCubemap){const m=p.mipmaps.length/p.mipmapCount;for(let y=0;y<m;y++){a[y]={mipmaps:[]};for(let x=0;x<p.mipmapCount;x++)a[y].mipmaps.push(p.mipmaps[y*p.mipmapCount+x]),a[y].format=p.format,a[y].width=p.width,a[y].height=p.height}o.image=a}else o.image.width=p.width,o.image.height=p.height,o.mipmaps=p.mipmaps;p.mipmapCount===1&&(o.minFilter=Pn),o.format=p.format,o.needsUpdate=!0,t&&t(o)},n,r);return o}}class Df extends ir{constructor(e){super(e)}load(e,t,n,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=fa.get(e);if(a!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a;const o=Ef("img");function l(){f(),fa.add(e,this),t&&t(this),s.manager.itemEnd(e)}function c(d){f(),r&&r(d),s.manager.itemError(e),s.manager.itemEnd(e)}function f(){o.removeEventListener("load",l,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),s.manager.itemStart(e),o.src=e,o}}class PN extends ir{constructor(e){super(e)}load(e,t,n,r){const s=new Yf;s.colorSpace=Ri;const a=new Df(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let o=0;function l(c){a.load(e[c],function(f){s.images[c]=f,o++,o===6&&(s.needsUpdate=!0,t&&t(s))},void 0,r)}for(let c=0;c<e.length;++c)l(c);return s}}class zN extends ir{constructor(e){super(e)}load(e,t,n,r){const s=this,a=new Ts,o=new xa(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(s.withCredentials),o.load(e,function(l){let c;try{c=s.parse(l)}catch(f){if(r!==void 0)r(f);else{console.error(f);return}}c.image!==void 0?a.image=c.image:c.data!==void 0&&(a.image.width=c.width,a.image.height=c.height,a.image.data=c.data),a.wrapS=c.wrapS!==void 0?c.wrapS:zr,a.wrapT=c.wrapT!==void 0?c.wrapT:zr,a.magFilter=c.magFilter!==void 0?c.magFilter:Pn,a.minFilter=c.minFilter!==void 0?c.minFilter:Pn,a.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.colorSpace!==void 0&&(a.colorSpace=c.colorSpace),c.flipY!==void 0&&(a.flipY=c.flipY),c.format!==void 0&&(a.format=c.format),c.type!==void 0&&(a.type=c.type),c.mipmaps!==void 0&&(a.mipmaps=c.mipmaps,a.minFilter=Ms),c.mipmapCount===1&&(a.minFilter=Pn),c.generateMipmaps!==void 0&&(a.generateMipmaps=c.generateMipmaps),a.needsUpdate=!0,t&&t(a,c)},n,r),a}}class $2 extends ir{constructor(e){super(e)}load(e,t,n,r){const s=new An,a=new Df(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){s.image=o,s.needsUpdate=!0,t!==void 0&&t(s)},n,r),s}}class vo extends Xt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new et(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}class eC extends vo{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Xt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new et(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const dy=new bt,PE=new J,zE=new J;class f1{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ge(512,512),this.mapType=Gr,this.map=null,this.mapPass=null,this.matrix=new bt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Ll,this._frameExtents=new Ge(1,1),this._viewportCount=1,this._viewports=[new kt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;PE.setFromMatrixPosition(e.matrixWorld),t.position.copy(PE),zE.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(zE),t.updateMatrixWorld(),dy.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(dy),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(dy)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class FN extends f1{constructor(){super(new Zn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,n=lu*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height*this.aspect,s=e.distance||t.far;(n!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=n,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class tC extends vo{constructor(e,t,n=0,r=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Xt.DEFAULT_UP),this.updateMatrix(),this.target=new Xt,this.distance=n,this.angle=r,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new FN}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const FE=new bt,yh=new J,py=new J;class BN extends f1{constructor(){super(new Zn(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Ge(4,2),this._viewportCount=6,this._viewports=[new kt(2,1,1,1),new kt(0,1,1,1),new kt(3,1,1,1),new kt(1,1,1,1),new kt(3,0,1,1),new kt(1,0,1,1)],this._cubeDirections=[new J(1,0,0),new J(-1,0,0),new J(0,0,1),new J(0,0,-1),new J(0,1,0),new J(0,-1,0)],this._cubeUps=[new J(0,1,0),new J(0,1,0),new J(0,1,0),new J(0,1,0),new J(0,0,1),new J(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,r=this.matrix,s=e.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),yh.setFromMatrixPosition(e.matrixWorld),n.position.copy(yh),py.copy(n.position),py.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(py),n.updateMatrixWorld(),r.makeTranslation(-yh.x,-yh.y,-yh.z),FE.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(FE)}}class nC extends vo{constructor(e,t,n=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=r,this.shadow=new BN}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class Pl extends Ng{constructor(e=-1,t=1,n=1,r=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,s,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let s=n-e,a=n+e,o=r+t,l=r-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,f=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=f*this.view.offsetY,l=o-f*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class kN extends f1{constructor(){super(new Pl(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class iC extends vo{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Xt.DEFAULT_UP),this.updateMatrix(),this.target=new Xt,this.shadow=new kN}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class rC extends vo{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class sC extends vo{constructor(e,t,n=10,r=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=r}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class aC{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new J)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const n=e.x,r=e.y,s=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*r),t.addScaledVector(a[2],.488603*s),t.addScaledVector(a[3],.488603*n),t.addScaledVector(a[4],1.092548*(n*r)),t.addScaledVector(a[5],1.092548*(r*s)),t.addScaledVector(a[6],.315392*(3*s*s-1)),t.addScaledVector(a[7],1.092548*(n*s)),t.addScaledVector(a[8],.546274*(n*n-r*r)),t}getIrradianceAt(e,t){const n=e.x,r=e.y,s=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScaledVector(a[1],2*.511664*r),t.addScaledVector(a[2],2*.511664*s),t.addScaledVector(a[3],2*.511664*n),t.addScaledVector(a[4],2*.429043*n*r),t.addScaledVector(a[5],2*.429043*r*s),t.addScaledVector(a[6],.743125*s*s-.247708),t.addScaledVector(a[7],2*.429043*n*s),t.addScaledVector(a[8],.429043*(n*n-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){const n=this.coefficients;for(let r=0;r<9;r++)n[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){const n=this.coefficients;for(let r=0;r<9;r++)n[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){const n=e.x,r=e.y,s=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*s,t[3]=.488603*n,t[4]=1.092548*n*r,t[5]=1.092548*r*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*n*s,t[8]=.546274*(n*n-r*r)}}class oC extends vo{constructor(e=new aC,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class i0 extends ir{constructor(e){super(e),this.textures={}}load(e,t,n,r){const s=this,a=new xa(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},n,r)}parse(e){const t=this.textures;function n(s){return t[s]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",s),t[s]}const r=this.createMaterialFromType(e.type);if(e.uuid!==void 0&&(r.uuid=e.uuid),e.name!==void 0&&(r.name=e.name),e.color!==void 0&&r.color!==void 0&&r.color.setHex(e.color),e.roughness!==void 0&&(r.roughness=e.roughness),e.metalness!==void 0&&(r.metalness=e.metalness),e.sheen!==void 0&&(r.sheen=e.sheen),e.sheenColor!==void 0&&(r.sheenColor=new et().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(r.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&r.emissive!==void 0&&r.emissive.setHex(e.emissive),e.specular!==void 0&&r.specular!==void 0&&r.specular.setHex(e.specular),e.specularIntensity!==void 0&&(r.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&r.specularColor!==void 0&&r.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(r.shininess=e.shininess),e.clearcoat!==void 0&&(r.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(r.dispersion=e.dispersion),e.iridescence!==void 0&&(r.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(r.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(r.transmission=e.transmission),e.thickness!==void 0&&(r.thickness=e.thickness),e.attenuationDistance!==void 0&&(r.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&r.attenuationColor!==void 0&&r.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(r.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(r.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(r.fog=e.fog),e.flatShading!==void 0&&(r.flatShading=e.flatShading),e.blending!==void 0&&(r.blending=e.blending),e.combine!==void 0&&(r.combine=e.combine),e.side!==void 0&&(r.side=e.side),e.shadowSide!==void 0&&(r.shadowSide=e.shadowSide),e.opacity!==void 0&&(r.opacity=e.opacity),e.transparent!==void 0&&(r.transparent=e.transparent),e.alphaTest!==void 0&&(r.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(r.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(r.depthFunc=e.depthFunc),e.depthTest!==void 0&&(r.depthTest=e.depthTest),e.depthWrite!==void 0&&(r.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(r.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(r.blendSrc=e.blendSrc),e.blendDst!==void 0&&(r.blendDst=e.blendDst),e.blendEquation!==void 0&&(r.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(r.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(r.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(r.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&r.blendColor!==void 0&&r.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(r.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(r.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(r.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(r.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(r.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(r.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(r.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(r.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(r.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(r.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(r.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(r.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(r.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(r.rotation=e.rotation),e.linewidth!==void 0&&(r.linewidth=e.linewidth),e.dashSize!==void 0&&(r.dashSize=e.dashSize),e.gapSize!==void 0&&(r.gapSize=e.gapSize),e.scale!==void 0&&(r.scale=e.scale),e.polygonOffset!==void 0&&(r.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(r.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(r.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(r.dithering=e.dithering),e.alphaToCoverage!==void 0&&(r.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(r.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(r.forceSinglePass=e.forceSinglePass),e.visible!==void 0&&(r.visible=e.visible),e.toneMapped!==void 0&&(r.toneMapped=e.toneMapped),e.userData!==void 0&&(r.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?r.vertexColors=e.vertexColors>0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const s in e.uniforms){const a=e.uniforms[s];switch(r.uniforms[s]={},a.type){case"t":r.uniforms[s].value=n(a.value);break;case"c":r.uniforms[s].value=new et().setHex(a.value);break;case"v2":r.uniforms[s].value=new Ge().fromArray(a.value);break;case"v3":r.uniforms[s].value=new J().fromArray(a.value);break;case"v4":r.uniforms[s].value=new kt().fromArray(a.value);break;case"m3":r.uniforms[s].value=new wt().fromArray(a.value);break;case"m4":r.uniforms[s].value=new bt().fromArray(a.value);break;default:r.uniforms[s].value=a.value}}if(e.defines!==void 0&&(r.defines=e.defines),e.vertexShader!==void 0&&(r.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(r.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(r.glslVersion=e.glslVersion),e.extensions!==void 0)for(const s in e.extensions)r.extensions[s]=e.extensions[s];if(e.lights!==void 0&&(r.lights=e.lights),e.clipping!==void 0&&(r.clipping=e.clipping),e.size!==void 0&&(r.size=e.size),e.sizeAttenuation!==void 0&&(r.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(r.map=n(e.map)),e.matcap!==void 0&&(r.matcap=n(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=n(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=n(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=n(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),r.normalScale=new Ge().fromArray(s)}return e.displacementMap!==void 0&&(r.displacementMap=n(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=n(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=n(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=n(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=n(e.specularMap)),e.specularIntensityMap!==void 0&&(r.specularIntensityMap=n(e.specularIntensityMap)),e.specularColorMap!==void 0&&(r.specularColorMap=n(e.specularColorMap)),e.envMap!==void 0&&(r.envMap=n(e.envMap)),e.envMapRotation!==void 0&&r.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(r.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(r.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(r.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(r.lightMap=n(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=n(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=n(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=n(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=n(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new Ge().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(r.iridescenceMap=n(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(r.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(r.transmissionMap=n(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=n(e.thicknessMap)),e.anisotropyMap!==void 0&&(r.anisotropyMap=n(e.anisotropyMap)),e.sheenColorMap!==void 0&&(r.sheenColorMap=n(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(r.sheenRoughnessMap=n(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return i0.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:F2,SpriteMaterial:Jx,RawShaderMaterial:B2,ShaderMaterial:ls,PointsMaterial:$x,MeshPhysicalMaterial:k2,MeshStandardMaterial:o1,MeshPhongMaterial:G2,MeshToonMaterial:H2,MeshNormalMaterial:V2,MeshLambertMaterial:W2,MeshDepthMaterial:t0,MeshDistanceMaterial:n0,MeshBasicMaterial:Sa,MeshMatcapMaterial:X2,LineDashedMaterial:j2,LineBasicMaterial:Gi,Material:Oi};return new t[e]}}class Z_{static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class d1 extends Ct{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class lC extends ir{constructor(e){super(e)}load(e,t,n,r){const s=this,a=new xa(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},n,r)}parse(e){const t={},n={};function r(m,y){if(t[y]!==void 0)return t[y];const _=m.interleavedBuffers[y],g=s(m,_.buffer),b=Yc(_.type,g),S=new Fg(b,_.stride);return S.uuid=_.uuid,t[y]=S,S}function s(m,y){if(n[y]!==void 0)return n[y];const _=m.arrayBuffers[y],g=new Uint32Array(_).buffer;return n[y]=g,g}const a=e.isInstancedBufferGeometry?new d1:new Ct,o=e.data.index;if(o!==void 0){const m=Yc(o.type,o.array);a.setIndex(new en(m,1))}const l=e.data.attributes;for(const m in l){const y=l[m];let x;if(y.isInterleavedBufferAttribute){const _=r(e.data,y.data);x=new Tl(_,y.itemSize,y.offset,y.normalized)}else{const _=Yc(y.type,y.array),g=y.isInstancedBufferAttribute?Al:en;x=new g(_,y.itemSize,y.normalized)}y.name!==void 0&&(x.name=y.name),y.usage!==void 0&&x.setUsage(y.usage),a.setAttribute(m,x)}const c=e.data.morphAttributes;if(c)for(const m in c){const y=c[m],x=[];for(let _=0,g=y.length;_<g;_++){const b=y[_];let S;if(b.isInterleavedBufferAttribute){const E=r(e.data,b.data);S=new Tl(E,b.itemSize,b.offset,b.normalized)}else{const E=Yc(b.type,b.array);S=new en(E,b.itemSize,b.normalized)}b.name!==void 0&&(S.name=b.name),x.push(S)}a.morphAttributes[m]=x}e.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);const d=e.data.groups||e.data.drawcalls||e.data.offsets;if(d!==void 0)for(let m=0,y=d.length;m!==y;++m){const x=d[m];a.addGroup(x.start,x.count,x.materialIndex)}const p=e.data.boundingSphere;return p!==void 0&&(a.boundingSphere=new ri().fromJSON(p)),e.name&&(a.name=e.name),e.userData&&(a.userData=e.userData),a}}class GN extends ir{constructor(e){super(e)}load(e,t,n,r){const s=this,a=this.path===""?Z_.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||a;const o=new xa(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){let c=null;try{c=JSON.parse(l)}catch(d){r!==void 0&&r(d),console.error("THREE:ObjectLoader: Can't parse "+e+".",d.message);return}const f=c.metadata;if(f===void 0||f.type===void 0||f.type.toLowerCase()==="geometry"){r!==void 0&&r(new Error("THREE.ObjectLoader: Can't load "+e)),console.error("THREE.ObjectLoader: Can't load "+e);return}s.parse(c,t)},n,r)}async loadAsync(e,t){const n=this,r=this.path===""?Z_.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||r;const s=new xa(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials);const a=await s.loadAsync(e,t),o=JSON.parse(a),l=o.metadata;if(l===void 0||l.type===void 0||l.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await n.parseAsync(o)}parse(e,t){const n=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),s=this.parseGeometries(e.geometries,r),a=this.parseImages(e.images,function(){t!==void 0&&t(c)}),o=this.parseTextures(e.textures,a),l=this.parseMaterials(e.materials,o),c=this.parseObject(e.object,s,l,o,n),f=this.parseSkeletons(e.skeletons,c);if(this.bindSkeletons(c,f),this.bindLightTargets(c),t!==void 0){let d=!1;for(const p in a)if(a[p].data instanceof HTMLImageElement){d=!0;break}d===!1&&t(c)}return c}async parseAsync(e){const t=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,n),s=await this.parseImagesAsync(e.images),a=this.parseTextures(e.textures,s),o=this.parseMaterials(e.materials,a),l=this.parseObject(e.object,r,o,a,t),c=this.parseSkeletons(e.skeletons,l);return this.bindSkeletons(l,c),this.bindLightTargets(l),l}parseShapes(e){const t={};if(e!==void 0)for(let n=0,r=e.length;n<r;n++){const s=new bl().fromJSON(e[n]);t[s.uuid]=s}return t}parseSkeletons(e,t){const n={},r={};if(t.traverse(function(s){s.isBone&&(r[s.uuid]=s)}),e!==void 0)for(let s=0,a=e.length;s<a;s++){const o=new Bg().fromJSON(e[s],r);n[o.uuid]=o}return n}parseGeometries(e,t){const n={};if(e!==void 0){const r=new lC;for(let s=0,a=e.length;s<a;s++){let o;const l=e[s];switch(l.type){case"BufferGeometry":case"InstancedBufferGeometry":o=r.parse(l);break;default:l.type in IE?o=IE[l.type].fromJSON(l,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${l.type}"`)}o.uuid=l.uuid,l.name!==void 0&&(o.name=l.name),l.userData!==void 0&&(o.userData=l.userData),n[l.uuid]=o}}return n}parseMaterials(e,t){const n={},r={};if(e!==void 0){const s=new i0;s.setTextures(t);for(let a=0,o=e.length;a<o;a++){const l=e[a];n[l.uuid]===void 0&&(n[l.uuid]=s.parse(l)),r[l.uuid]=n[l.uuid]}}return r}parseAnimations(e){const t={};if(e!==void 0)for(let n=0;n<e.length;n++){const r=e[n],s=Rf.parse(r);t[s.uuid]=s}return t}parseImages(e,t){const n=this,r={};let s;function a(l){return n.manager.itemStart(l),s.load(l,function(){n.manager.itemEnd(l)},void 0,function(){n.manager.itemError(l),n.manager.itemEnd(l)})}function o(l){if(typeof l=="string"){const c=l,f=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(c)?c:n.resourcePath+c;return a(f)}else return l.data?{data:Yc(l.type,l.data),width:l.width,height:l.height}:null}if(e!==void 0&&e.length>0){const l=new h1(t);s=new Df(l),s.setCrossOrigin(this.crossOrigin);for(let c=0,f=e.length;c<f;c++){const d=e[c],p=d.url;if(Array.isArray(p)){const m=[];for(let y=0,x=p.length;y<x;y++){const _=p[y],g=o(_);g!==null&&(g instanceof HTMLImageElement?m.push(g):m.push(new Ts(g.data,g.width,g.height)))}r[d.uuid]=new so(m)}else{const m=o(d.url);r[d.uuid]=new so(m)}}}return r}async parseImagesAsync(e){const t=this,n={};let r;async function s(a){if(typeof a=="string"){const o=a,l=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(o)?o:t.resourcePath+o;return await r.loadAsync(l)}else return a.data?{data:Yc(a.type,a.data),width:a.width,height:a.height}:null}if(e!==void 0&&e.length>0){r=new Df(this.manager),r.setCrossOrigin(this.crossOrigin);for(let a=0,o=e.length;a<o;a++){const l=e[a],c=l.url;if(Array.isArray(c)){const f=[];for(let d=0,p=c.length;d<p;d++){const m=c[d],y=await s(m);y!==null&&(y instanceof HTMLImageElement?f.push(y):f.push(new Ts(y.data,y.width,y.height)))}n[l.uuid]=new so(f)}else{const f=await s(l.url);n[l.uuid]=new so(f)}}}return n}parseTextures(e,t){function n(s,a){return typeof s=="number"?s:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",s),a[s])}const r={};if(e!==void 0)for(let s=0,a=e.length;s<a;s++){const o=e[s];o.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',o.uuid),t[o.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",o.image);const l=t[o.image],c=l.data;let f;Array.isArray(c)?(f=new Yf,c.length===6&&(f.needsUpdate=!0)):(c&&c.data?f=new Ts:f=new An,c&&(f.needsUpdate=!0)),f.source=l,f.uuid=o.uuid,o.name!==void 0&&(f.name=o.name),o.mapping!==void 0&&(f.mapping=n(o.mapping,HN)),o.channel!==void 0&&(f.channel=o.channel),o.offset!==void 0&&f.offset.fromArray(o.offset),o.repeat!==void 0&&f.repeat.fromArray(o.repeat),o.center!==void 0&&f.center.fromArray(o.center),o.rotation!==void 0&&(f.rotation=o.rotation),o.wrap!==void 0&&(f.wrapS=n(o.wrap[0],BE),f.wrapT=n(o.wrap[1],BE)),o.format!==void 0&&(f.format=o.format),o.internalFormat!==void 0&&(f.internalFormat=o.internalFormat),o.type!==void 0&&(f.type=o.type),o.colorSpace!==void 0&&(f.colorSpace=o.colorSpace),o.minFilter!==void 0&&(f.minFilter=n(o.minFilter,kE)),o.magFilter!==void 0&&(f.magFilter=n(o.magFilter,kE)),o.anisotropy!==void 0&&(f.anisotropy=o.anisotropy),o.flipY!==void 0&&(f.flipY=o.flipY),o.generateMipmaps!==void 0&&(f.generateMipmaps=o.generateMipmaps),o.premultiplyAlpha!==void 0&&(f.premultiplyAlpha=o.premultiplyAlpha),o.unpackAlignment!==void 0&&(f.unpackAlignment=o.unpackAlignment),o.compareFunction!==void 0&&(f.compareFunction=o.compareFunction),o.userData!==void 0&&(f.userData=o.userData),r[o.uuid]=f}return r}parseObject(e,t,n,r,s){let a;function o(p){return t[p]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",p),t[p]}function l(p){if(p!==void 0){if(Array.isArray(p)){const m=[];for(let y=0,x=p.length;y<x;y++){const _=p[y];n[_]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",_),m.push(n[_])}return m}return n[p]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",p),n[p]}}function c(p){return r[p]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",p),r[p]}let f,d;switch(e.type){case"Scene":a=new zg,e.background!==void 0&&(Number.isInteger(e.background)?a.background=new et(e.background):a.background=c(e.background)),e.environment!==void 0&&(a.environment=c(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?a.fog=new Pg(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(a.fog=new Ig(e.fog.color,e.fog.density)),e.fog.name!==""&&(a.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(a.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(a.backgroundIntensity=e.backgroundIntensity),e.backgroundRotation!==void 0&&a.backgroundRotation.fromArray(e.backgroundRotation),e.environmentIntensity!==void 0&&(a.environmentIntensity=e.environmentIntensity),e.environmentRotation!==void 0&&a.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":a=new Zn(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(a.focus=e.focus),e.zoom!==void 0&&(a.zoom=e.zoom),e.filmGauge!==void 0&&(a.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(a.filmOffset=e.filmOffset),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case"OrthographicCamera":a=new Pl(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(a.zoom=e.zoom),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case"AmbientLight":a=new rC(e.color,e.intensity);break;case"DirectionalLight":a=new iC(e.color,e.intensity),a.target=e.target||"";break;case"PointLight":a=new nC(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":a=new sC(e.color,e.intensity,e.width,e.height);break;case"SpotLight":a=new tC(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),a.target=e.target||"";break;case"HemisphereLight":a=new eC(e.color,e.groundColor,e.intensity);break;case"LightProbe":a=new oC().fromJSON(e);break;case"SkinnedMesh":f=o(e.geometry),d=l(e.material),a=new S2(f,d),e.bindMode!==void 0&&(a.bindMode=e.bindMode),e.bindMatrix!==void 0&&a.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(a.skeleton=e.skeleton);break;case"Mesh":f=o(e.geometry),d=l(e.material),a=new pn(f,d);break;case"InstancedMesh":f=o(e.geometry),d=l(e.material);const p=e.count,m=e.instanceMatrix,y=e.instanceColor;a=new E2(f,d,p),a.instanceMatrix=new Al(new Float32Array(m.array),16),y!==void 0&&(a.instanceColor=new Al(new Float32Array(y.array),y.itemSize));break;case"BatchedMesh":f=o(e.geometry),d=l(e.material),a=new M2(e.maxInstanceCount,e.maxVertexCount,e.maxIndexCount,d),a.geometry=f,a.perObjectFrustumCulled=e.perObjectFrustumCulled,a.sortObjects=e.sortObjects,a._drawRanges=e.drawRanges,a._reservedRanges=e.reservedRanges,a._geometryInfo=e.geometryInfo.map(x=>{let _=null,g=null;return x.boundingBox!==void 0&&(_=new Jn().fromJSON(x.boundingBox)),x.boundingSphere!==void 0&&(g=new ri().fromJSON(x.boundingSphere)),{...x,boundingBox:_,boundingSphere:g}}),a._instanceInfo=e.instanceInfo,a._availableInstanceIds=e._availableInstanceIds,a._availableGeometryIds=e._availableGeometryIds,a._nextIndexStart=e.nextIndexStart,a._nextVertexStart=e.nextVertexStart,a._geometryCount=e.geometryCount,a._maxInstanceCount=e.maxInstanceCount,a._maxVertexCount=e.maxVertexCount,a._maxIndexCount=e.maxIndexCount,a._geometryInitialized=e.geometryInitialized,a._matricesTexture=c(e.matricesTexture.uuid),a._indirectTexture=c(e.indirectTexture.uuid),e.colorsTexture!==void 0&&(a._colorsTexture=c(e.colorsTexture.uuid)),e.boundingSphere!==void 0&&(a.boundingSphere=new ri().fromJSON(e.boundingSphere)),e.boundingBox!==void 0&&(a.boundingBox=new Jn().fromJSON(e.boundingBox));break;case"LOD":a=new b2;break;case"Line":a=new fo(o(e.geometry),l(e.material));break;case"LineLoop":a=new w2(o(e.geometry),l(e.material));break;case"LineSegments":a=new Ds(o(e.geometry),l(e.material));break;case"PointCloud":case"Points":a=new T2(o(e.geometry),l(e.material));break;case"Sprite":a=new x2(l(e.material));break;case"Group":a=new Zc;break;case"Bone":a=new Qx;break;default:a=new Xt}if(a.uuid=e.uuid,e.name!==void 0&&(a.name=e.name),e.matrix!==void 0?(a.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(e.position!==void 0&&a.position.fromArray(e.position),e.rotation!==void 0&&a.rotation.fromArray(e.rotation),e.quaternion!==void 0&&a.quaternion.fromArray(e.quaternion),e.scale!==void 0&&a.scale.fromArray(e.scale)),e.up!==void 0&&a.up.fromArray(e.up),e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(a.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(a.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(a.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(a.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&a.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(a.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(a.visible=e.visible),e.frustumCulled!==void 0&&(a.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(a.renderOrder=e.renderOrder),e.userData!==void 0&&(a.userData=e.userData),e.layers!==void 0&&(a.layers.mask=e.layers),e.children!==void 0){const p=e.children;for(let m=0;m<p.length;m++)a.add(this.parseObject(p[m],t,n,r,s))}if(e.animations!==void 0){const p=e.animations;for(let m=0;m<p.length;m++){const y=p[m];a.animations.push(s[y])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(a.autoUpdate=e.autoUpdate);const p=e.levels;for(let m=0;m<p.length;m++){const y=p[m],x=a.getObjectByProperty("uuid",y.object);x!==void 0&&a.addLevel(x,y.distance,y.hysteresis)}}return a}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(n){if(n.isSkinnedMesh===!0&&n.skeleton!==void 0){const r=t[n.skeleton];r===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",n.skeleton):n.bind(r,n.bindMatrix)}})}bindLightTargets(e){e.traverse(function(t){if(t.isDirectionalLight||t.isSpotLight){const n=t.target,r=e.getObjectByProperty("uuid",n);r!==void 0?t.target=r:t.target=new Xt}})}}const HN={UVMapping:Mg,CubeReflectionMapping:ya,CubeRefractionMapping:uo,EquirectangularReflectionMapping:pf,EquirectangularRefractionMapping:mf,CubeUVReflectionMapping:_u},BE={RepeatWrapping:gf,ClampToEdgeWrapping:zr,MirroredRepeatWrapping:vf},kE={NearestFilter:yi,NearestMipmapNearestFilter:Ix,NearestMipmapLinearFilter:qc,LinearFilter:Pn,LinearMipmapNearestFilter:Jh,LinearMipmapLinearFilter:Ms},my=new WeakMap;class VN extends ir{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=fa.get(e);if(a!==void 0){if(s.manager.itemStart(e),a.then){a.then(c=>{if(my.has(a)===!0)r&&r(my.get(a)),s.manager.itemError(e),s.manager.itemEnd(e);else return t&&t(c),s.manager.itemEnd(e),c});return}return setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader;const l=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){return fa.add(e,c),t&&t(c),s.manager.itemEnd(e),c}).catch(function(c){r&&r(c),my.set(l,c),fa.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});fa.add(e,l),s.manager.itemStart(e)}}let Ep;class p1{static getContext(){return Ep===void 0&&(Ep=new(window.AudioContext||window.webkitAudioContext)),Ep}static setContext(e){Ep=e}}class WN extends ir{constructor(e){super(e)}load(e,t,n,r){const s=this,a=new xa(this.manager);a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(l){try{const c=l.slice(0);p1.getContext().decodeAudioData(c,function(d){t(d)}).catch(o)}catch(c){o(c)}},n,r);function o(l){r?r(l):console.error(l),s.manager.itemError(e)}}}const GE=new bt,HE=new bt,Jo=new bt;class XN{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Zn,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Zn,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,Jo.copy(e.projectionMatrix);const r=t.eyeSep/2,s=r*t.near/t.focus,a=t.near*Math.tan(xl*t.fov*.5)/t.zoom;let o,l;HE.elements[12]=-r,GE.elements[12]=r,o=-a*t.aspect+s,l=a*t.aspect+s,Jo.elements[0]=2*t.near/(l-o),Jo.elements[8]=(l+o)/(l-o),this.cameraL.projectionMatrix.copy(Jo),o=-a*t.aspect-s,l=a*t.aspect-s,Jo.elements[0]=2*t.near/(l-o),Jo.elements[8]=(l+o)/(l-o),this.cameraR.projectionMatrix.copy(Jo)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(HE),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(GE)}}class cC extends Zn{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class m1{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=VE(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=VE();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function VE(){return performance.now()}const Qo=new J,gy=new _i,jN=new J,$o=new J,el=new J;class qN extends Xt{constructor(){super(),this.type="AudioListener",this.context=p1.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new m1}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Qo,gy,jN),$o.set(0,0,-1).applyQuaternion(gy),el.set(0,1,0).applyQuaternion(gy),t.positionX){const n=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Qo.x,n),t.positionY.linearRampToValueAtTime(Qo.y,n),t.positionZ.linearRampToValueAtTime(Qo.z,n),t.forwardX.linearRampToValueAtTime($o.x,n),t.forwardY.linearRampToValueAtTime($o.y,n),t.forwardZ.linearRampToValueAtTime($o.z,n),t.upX.linearRampToValueAtTime(el.x,n),t.upY.linearRampToValueAtTime(el.y,n),t.upZ.linearRampToValueAtTime(el.z,n)}else t.setPosition(Qo.x,Qo.y,Qo.z),t.setOrientation($o.x,$o.y,$o.z,el.x,el.y,el.z)}}class uC extends Xt{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(e=0){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,this.isPlaying===!0&&this.source.detune!==void 0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1,this._progress=0}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}copy(e,t){return super.copy(e,t),e.sourceType!=="buffer"?(console.warn("THREE.Audio: Audio source type cannot be copied."),this):(this.autoplay=e.autoplay,this.buffer=e.buffer,this.detune=e.detune,this.loop=e.loop,this.loopStart=e.loopStart,this.loopEnd=e.loopEnd,this.offset=e.offset,this.duration=e.duration,this.playbackRate=e.playbackRate,this.hasPlaybackControl=e.hasPlaybackControl,this.sourceType=e.sourceType,this.filters=e.filters.slice(),this)}clone(e){return new this.constructor(this.listener).copy(this,e)}}const tl=new J,WE=new _i,YN=new J,nl=new J;class ZN extends uC{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){return super.connect(),this.panner.connect(this.gain),this}disconnect(){return super.disconnect(),this.panner.disconnect(this.gain),this}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,n){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=n,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(tl,WE,YN),nl.set(0,0,1).applyQuaternion(WE);const t=this.panner;if(t.positionX){const n=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(tl.x,n),t.positionY.linearRampToValueAtTime(tl.y,n),t.positionZ.linearRampToValueAtTime(tl.z,n),t.orientationX.linearRampToValueAtTime(nl.x,n),t.orientationY.linearRampToValueAtTime(nl.y,n),t.orientationZ.linearRampToValueAtTime(nl.z,n)}else t.setPosition(tl.x,tl.y,tl.z),t.setOrientation(nl.x,nl.y,nl.z)}}class KN{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0;const t=this.getFrequencyData();for(let n=0;n<t.length;n++)e+=t[n];return e/t.length}}class hC{constructor(e,t,n){this.binding=e,this.valueSize=n;let r,s,a;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:r=this._lerp,s=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const n=this.buffer,r=this.valueSize,s=e*r+r;let a=this.cumulativeWeight;if(a===0){for(let o=0;o!==r;++o)n[s+o]=n[o];a=t}else{a+=t;const o=t/a;this._mixBufferRegion(n,s,0,o,r)}this.cumulativeWeight=a}accumulateAdditive(e){const t=this.buffer,n=this.valueSize,r=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,n=this.buffer,r=e*t+t,s=this.cumulativeWeight,a=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){const l=t*this._origIndex;this._mixBufferRegion(n,r,l,1-s,t)}a>0&&this._mixBufferRegionAdditive(n,r,this._addIndex*t,1,t);for(let l=t,c=t+t;l!==c;++l)if(n[l]!==n[l+t]){o.setValue(n,r);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,r=n*this._origIndex;e.getValue(t,r);for(let s=n,a=r;s!==a;++s)t[s]=t[r+s%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,r,s){if(r>=.5)for(let a=0;a!==s;++a)e[t+a]=e[n+a]}_slerp(e,t,n,r){_i.slerpFlat(e,t,e,t,e,n,r)}_slerpAdditive(e,t,n,r,s){const a=this._workIndex*s;_i.multiplyQuaternionsFlat(e,a,e,t,e,n),_i.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,n,r,s){const a=1-r;for(let o=0;o!==s;++o){const l=t+o;e[l]=e[l]*a+e[n+o]*r}}_lerpAdditive(e,t,n,r,s){for(let a=0;a!==s;++a){const o=t+a;e[o]=e[o]+e[n+a]*r}}}const g1="\\[\\]\\.:\\/",JN=new RegExp("["+g1+"]","g"),v1="[^"+g1+"]",QN="[^"+g1.replace("\\.","")+"]",$N=/((?:WC+[\/:])*)/.source.replace("WC",v1),eI=/(WCOD+)?/.source.replace("WCOD",QN),tI=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",v1),nI=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",v1),iI=new RegExp("^"+$N+eI+tI+nI+"$"),rI=["material","materials","bones","map"];class sI{constructor(e,t,n){const r=n||Wt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=n.length;r!==s;++r)n[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class Wt{constructor(e,t,n){this.path=t,this.parsedPath=n||Wt.parseTrackName(t),this.node=Wt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new Wt.Composite(e,t,n):new Wt(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(JN,"")}static parseTrackName(e){const t=iI.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){const s=n.nodeName.substring(r+1);rI.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(s){for(let a=0;a<s.length;a++){const o=s[a];if(o.name===t||o.uuid===t)return o;const l=n(o.children);if(l)return l}return null},r=n(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)e[t++]=n[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,r=t.propertyName;let s=t.propertyIndex;if(e||(e=Wt.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let f=0;f<e.length;f++)if(e[f].name===c){c=f;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const a=e[r];if(a===void 0){const c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+r+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=r;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Wt.Composite=sI;Wt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Wt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Wt.prototype.GetterByBindingType=[Wt.prototype._getValue_direct,Wt.prototype._getValue_array,Wt.prototype._getValue_arrayElement,Wt.prototype._getValue_toArray];Wt.prototype.SetterByBindingTypeAndVersioning=[[Wt.prototype._setValue_direct,Wt.prototype._setValue_direct_setNeedsUpdate,Wt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Wt.prototype._setValue_array,Wt.prototype._setValue_array_setNeedsUpdate,Wt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Wt.prototype._setValue_arrayElement,Wt.prototype._setValue_arrayElement_setNeedsUpdate,Wt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Wt.prototype._setValue_fromArray,Wt.prototype._setValue_fromArray_setNeedsUpdate,Wt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class aI{constructor(){this.isAnimationObjectGroup=!0,this.uuid=vr(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let n=0,r=arguments.length;n!==r;++n)e[arguments[n].uuid]=n;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){const e=this._objects,t=this._indicesByUUID,n=this._paths,r=this._parsedPaths,s=this._bindings,a=s.length;let o,l=e.length,c=this.nCachedObjects_;for(let f=0,d=arguments.length;f!==d;++f){const p=arguments[f],m=p.uuid;let y=t[m];if(y===void 0){y=l++,t[m]=y,e.push(p);for(let x=0,_=a;x!==_;++x)s[x].push(new Wt(p,n[x],r[x]))}else if(y<c){o=e[y];const x=--c,_=e[x];t[_.uuid]=y,e[y]=_,t[m]=x,e[x]=p;for(let g=0,b=a;g!==b;++g){const S=s[g],E=S[x];let w=S[y];S[y]=E,w===void 0&&(w=new Wt(p,n[g],r[g])),S[x]=w}}else e[y]!==o&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=c}remove(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,r=n.length;let s=this.nCachedObjects_;for(let a=0,o=arguments.length;a!==o;++a){const l=arguments[a],c=l.uuid,f=t[c];if(f!==void 0&&f>=s){const d=s++,p=e[d];t[p.uuid]=f,e[f]=p,t[c]=d,e[d]=l;for(let m=0,y=r;m!==y;++m){const x=n[m],_=x[d],g=x[f];x[f]=_,x[d]=g}}}this.nCachedObjects_=s}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,r=n.length;let s=this.nCachedObjects_,a=e.length;for(let o=0,l=arguments.length;o!==l;++o){const c=arguments[o],f=c.uuid,d=t[f];if(d!==void 0)if(delete t[f],d<s){const p=--s,m=e[p],y=--a,x=e[y];t[m.uuid]=d,e[d]=m,t[x.uuid]=p,e[p]=x,e.pop();for(let _=0,g=r;_!==g;++_){const b=n[_],S=b[p],E=b[y];b[d]=S,b[p]=E,b.pop()}}else{const p=--a,m=e[p];p>0&&(t[m.uuid]=d),e[d]=m,e.pop();for(let y=0,x=r;y!==x;++y){const _=n[y];_[d]=_[p],_.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){const n=this._bindingsIndicesByPath;let r=n[e];const s=this._bindings;if(r!==void 0)return s[r];const a=this._paths,o=this._parsedPaths,l=this._objects,c=l.length,f=this.nCachedObjects_,d=new Array(c);r=s.length,n[e]=r,a.push(e),o.push(t),s.push(d);for(let p=f,m=l.length;p!==m;++p){const y=l[p];d[p]=new Wt(y,e,t)}return d}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){const r=this._paths,s=this._parsedPaths,a=this._bindings,o=a.length-1,l=a[o],c=e[o];t[c]=n,a[n]=l,a.pop(),s[n]=s[o],s.pop(),r[n]=r[o],r.pop()}}}class fC{constructor(e,t,n=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=r;const s=t.tracks,a=s.length,o=new Array(a),l={endingStart:pl,endingEnd:pl};for(let c=0;c!==a;++c){const f=s[c].createInterpolant(null);o[c]=f,f.settings=l}this._interpolantSettings=l,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=t2,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n=!1){if(e.fadeOut(t),this.fadeIn(t),n===!0){const r=this._clip.duration,s=e._clip.duration,a=s/r,o=r/s;e.warp(1,a,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,n=!1){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const r=this._mixer,s=r.time,a=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=r._lendControlInterpolant(),this._timeScaleInterpolant=o);const l=o.parameterPositions,c=o.sampleValues;return l[0]=s,l[1]=s+n,c[0]=e/a,c[1]=t/a,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,r){if(!this.enabled){this._updateWeight(e);return}const s=this._startTime;if(s!==null){const l=(e-s)*n;l<0||n===0?t=0:(this._startTime=null,t=n*l)}t*=this._updateTimeScale(e);const a=this._updateTime(t),o=this._updateWeight(e);if(o>0){const l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case Vx:for(let f=0,d=l.length;f!==d;++f)l[f].evaluate(a),c[f].accumulateAdditive(o);break;case Ug:default:for(let f=0,d=l.length;f!==d;++f)l[f].evaluate(a),c[f].accumulate(r,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(n!==null){const r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;if(n!==null){const r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let r=this.time+e,s=this._loopCount;const a=n===n2;if(e===0)return s===-1?r:a&&(s&1)===1?t-r:r;if(n===e2){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),r>=t||r<0){const o=Math.floor(r/t);r-=t*o,s+=Math.abs(o);const l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){const c=e<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=r;if(a&&(s&1)===1)return t-r}return r}_setEndings(e,t,n){const r=this._interpolantSettings;n?(r.endingStart=ml,r.endingEnd=ml):(e?r.endingStart=this.zeroSlopeAtStart?ml:pl:r.endingStart=_f,t?r.endingEnd=this.zeroSlopeAtEnd?ml:pl:r.endingEnd=_f)}_scheduleFading(e,t,n){const r=this._mixer,s=r.time;let a=this._weightInterpolant;a===null&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=s,l[0]=t,o[1]=s+e,l[1]=n,this}}const oI=new Float32Array(1);class lI extends Rs{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,r=e._clip.tracks,s=r.length,a=e._propertyBindings,o=e._interpolants,l=n.uuid,c=this._bindingsByRootAndName;let f=c[l];f===void 0&&(f={},c[l]=f);for(let d=0;d!==s;++d){const p=r[d],m=p.name;let y=f[m];if(y!==void 0)++y.referenceCount,a[d]=y;else{if(y=a[d],y!==void 0){y._cacheIndex===null&&(++y.referenceCount,this._addInactiveBinding(y,l,m));continue}const x=t&&t._propertyBindings[d].binding.parsedPath;y=new hC(Wt.create(n,m,x),p.ValueTypeName,p.getValueSize()),++y.referenceCount,this._addInactiveBinding(y,l,m),a[d]=y}o[d].resultBuffer=y.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const n=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,n)}const t=e._propertyBindings;for(let n=0,r=t.length;n!==r;++n){const s=t[n];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let n=0,r=t.length;n!==r;++n){const s=t[n];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){const r=this._actions,s=this._actionsByClip;let a=s[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=a;else{const o=a.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=r.length,r.push(e),a.actionByRoot[n]=e}_removeInactiveAction(e){const t=this._actions,n=t[t.length-1],r=e._cacheIndex;n._cacheIndex=r,t[r]=n,t.pop(),e._cacheIndex=null;const s=e._clip.uuid,a=this._actionsByClip,o=a[s],l=o.knownActions,c=l[l.length-1],f=e._byClipCacheIndex;c._byClipCacheIndex=f,l[f]=c,l.pop(),e._byClipCacheIndex=null;const d=o.actionByRoot,p=(e._localRoot||this._root).uuid;delete d[p],l.length===0&&delete a[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let n=0,r=t.length;n!==r;++n){const s=t[n];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){const t=this._actions,n=e._cacheIndex,r=this._nActiveActions++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=n,t[n]=s}_takeBackAction(e){const t=this._actions,n=e._cacheIndex,r=--this._nActiveActions,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=n,t[n]=s}_addInactiveBinding(e,t,n){const r=this._bindingsByRootAndName,s=this._bindings;let a=r[t];a===void 0&&(a={},r[t]=a),a[n]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){const t=this._bindings,n=e.binding,r=n.rootNode.uuid,s=n.path,a=this._bindingsByRootAndName,o=a[r],l=t[t.length-1],c=e._cacheIndex;l._cacheIndex=c,t[c]=l,t.pop(),delete o[s],Object.keys(o).length===0&&delete a[r]}_lendBinding(e){const t=this._bindings,n=e._cacheIndex,r=this._nActiveBindings++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=n,t[n]=s}_takeBackBinding(e){const t=this._bindings,n=e._cacheIndex,r=--this._nActiveBindings,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=n,t[n]=s}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let n=e[t];return n===void 0&&(n=new c1(new Float32Array(2),new Float32Array(2),1,oI),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){const t=this._controlInterpolants,n=e.__cacheIndex,r=--this._nActiveControlInterpolants,s=t[r];e.__cacheIndex=r,t[r]=e,s.__cacheIndex=n,t[n]=s}clipAction(e,t,n){const r=t||this._root,s=r.uuid;let a=typeof e=="string"?Rf.findByName(r,e):e;const o=a!==null?a.uuid:e,l=this._actionsByClip[o];let c=null;if(n===void 0&&(a!==null?n=a.blendMode:n=Ug),l!==void 0){const d=l.actionByRoot[s];if(d!==void 0&&d.blendMode===n)return d;c=l.knownActions[0],a===null&&(a=c._clip)}if(a===null)return null;const f=new fC(this,a,t,n);return this._bindAction(f,c),this._addInactiveAction(f,o,s),f}existingAction(e,t){const n=t||this._root,r=n.uuid,s=typeof e=="string"?Rf.findByName(n,e):e,a=s?s.uuid:e,o=this._actionsByClip[a];return o!==void 0&&o.actionByRoot[r]||null}stopAllAction(){const e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,r=this.time+=e,s=Math.sign(e),a=this._accuIndex^=1;for(let c=0;c!==n;++c)t[c]._update(r,e,s,a);const o=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)o[c].apply(a);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,n=e.uuid,r=this._actionsByClip,s=r[n];if(s!==void 0){const a=s.knownActions;for(let o=0,l=a.length;o!==l;++o){const c=a[o];this._deactivateAction(c);const f=c._cacheIndex,d=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,d._cacheIndex=f,t[f]=d,t.pop(),this._removeInactiveBindingsForAction(c)}delete r[n]}}uncacheRoot(e){const t=e.uuid,n=this._actionsByClip;for(const a in n){const o=n[a].actionByRoot,l=o[t];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}const r=this._bindingsByRootAndName,s=r[t];if(s!==void 0)for(const a in s){const o=s[a];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){const n=this.existingAction(e,t);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}}class cI extends qx{constructor(e=1,t=1,n=1,r={}){super(e,t,r),this.isRenderTarget3D=!0,this.depth=n,this.texture=new Lg(null,e,t,n),this._setTextureOptions(r),this.texture.isRenderTargetTexture=!0}}class y1{constructor(e){this.value=e}clone(){return new y1(this.value.clone===void 0?this.value:this.value.clone())}}let uI=0;class hI extends Rs{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:uI++}),this.name="",this.usage=bf,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){this.dispatchEvent({type:"dispose"})}copy(e){this.name=e.name,this.usage=e.usage;const t=e.uniforms;this.uniforms.length=0;for(let n=0,r=t.length;n<r;n++){const s=Array.isArray(t[n])?t[n]:[t[n]];for(let a=0;a<s.length;a++)this.uniforms.push(s[a].clone())}return this}clone(){return new this.constructor().copy(this)}}class fI extends Fg{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}class dI{constructor(e,t,n,r,s){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=n,this.elementSize=r,this.count=s,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}}const XE=new bt;class _1{constructor(e,t,n=0,r=1/0){this.ray=new bu(e,t),this.near=n,this.far=r,this.camera=null,this.layers=new cu,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return XE.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(XE),this}intersectObject(e,t=!0,n=[]){return K_(e,this,n,t),n.sort(jE),n}intersectObjects(e,t=!0,n=[]){for(let r=0,s=e.length;r<s;r++)K_(e[r],this,n,t);return n.sort(jE),n}}function jE(i,e){return i.distance-e.distance}function K_(i,e,t,n){let r=!0;if(i.layers.test(e.layers)&&i.raycast(e,t)===!1&&(r=!1),r===!0&&n===!0){const s=i.children;for(let a=0,o=s.length;a<o;a++)K_(s[a],e,t,!0)}}class dC{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Tt(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(Tt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class pI{constructor(e=1,t=0,n=0){this.radius=e,this.theta=t,this.y=n}set(e,t,n){return this.radius=e,this.theta=t,this.y=n,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+n*n),this.theta=Math.atan2(e,n),this.y=t,this}clone(){return new this.constructor().copy(this)}}class x1{constructor(e,t,n,r){x1.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,r)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,r){const s=this.elements;return s[0]=e,s[2]=t,s[1]=n,s[3]=r,this}}const qE=new Ge;class mI{constructor(e=new Ge(1/0,1/0),t=new Ge(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=qE.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,qE).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const YE=new J,Mp=new J;class gI{constructor(e=new J,t=new J){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){YE.subVectors(e,this.start),Mp.subVectors(this.end,this.start);const n=Mp.dot(Mp);let s=Mp.dot(YE)/n;return t&&(s=Tt(s,0,1)),s}closestPointToPoint(e,t,n){const r=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const ZE=new J;class vI extends Xt{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const n=new Ct,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let a=0,o=1,l=32;a<l;a++,o++){const c=a/l*Math.PI*2,f=o/l*Math.PI*2;r.push(Math.cos(c),Math.sin(c),1,Math.cos(f),Math.sin(f),1)}n.setAttribute("position",new dt(r,3));const s=new Gi({fog:!1,toneMapped:!1});this.cone=new Ds(n,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);const e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),ZE.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(ZE),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const eo=new J,wp=new bt,vy=new bt;class yI extends Ds{constructor(e){const t=pC(e),n=new Ct,r=[],s=[],a=new et(0,0,1),o=new et(0,1,0);for(let c=0;c<t.length;c++){const f=t[c];f.parent&&f.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),s.push(a.r,a.g,a.b),s.push(o.r,o.g,o.b))}n.setAttribute("position",new dt(r,3)),n.setAttribute("color",new dt(s,3));const l=new Gi({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(n,l),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){const t=this.bones,n=this.geometry,r=n.getAttribute("position");vy.copy(this.root.matrixWorld).invert();for(let s=0,a=0;s<t.length;s++){const o=t[s];o.parent&&o.parent.isBone&&(wp.multiplyMatrices(vy,o.matrixWorld),eo.setFromMatrixPosition(wp),r.setXYZ(a,eo.x,eo.y,eo.z),wp.multiplyMatrices(vy,o.parent.matrixWorld),eo.setFromMatrixPosition(wp),r.setXYZ(a+1,eo.x,eo.y,eo.z),a+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}}function pC(i){const e=[];i.isBone===!0&&e.push(i);for(let t=0;t<i.children.length;t++)e.push(...pC(i.children[t]));return e}class _I extends pn{constructor(e,t,n){const r=new Jf(t,4,2),s=new Sa({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=e,this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const xI=new J,KE=new et,JE=new et;class bI extends Xt{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="HemisphereLightHelper";const r=new Kf(t);r.rotateY(Math.PI*.5),this.material=new Sa({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const s=r.getAttribute("position"),a=new Float32Array(s.count*3);r.setAttribute("color",new en(a,3)),this.add(new pn(r,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");KE.copy(this.light.color),JE.copy(this.light.groundColor);for(let n=0,r=t.count;n<r;n++){const s=n<r/2?KE:JE;t.setXYZ(n,s.r,s.g,s.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(xI.setFromMatrixPosition(this.light.matrixWorld).negate())}}class SI extends Ds{constructor(e=10,t=10,n=4473924,r=8947848){n=new et(n),r=new et(r);const s=t/2,a=e/t,o=e/2,l=[],c=[];for(let p=0,m=0,y=-o;p<=t;p++,y+=a){l.push(-o,0,y,o,0,y),l.push(y,0,-o,y,0,o);const x=p===s?n:r;x.toArray(c,m),m+=3,x.toArray(c,m),m+=3,x.toArray(c,m),m+=3,x.toArray(c,m),m+=3}const f=new Ct;f.setAttribute("position",new dt(l,3)),f.setAttribute("color",new dt(c,3));const d=new Gi({vertexColors:!0,toneMapped:!1});super(f,d),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class EI extends Ds{constructor(e=10,t=16,n=8,r=64,s=4473924,a=8947848){s=new et(s),a=new et(a);const o=[],l=[];if(t>1)for(let d=0;d<t;d++){const p=d/t*(Math.PI*2),m=Math.sin(p)*e,y=Math.cos(p)*e;o.push(0,0,0),o.push(m,0,y);const x=d&1?s:a;l.push(x.r,x.g,x.b),l.push(x.r,x.g,x.b)}for(let d=0;d<n;d++){const p=d&1?s:a,m=e-e/n*d;for(let y=0;y<r;y++){let x=y/r*(Math.PI*2),_=Math.sin(x)*m,g=Math.cos(x)*m;o.push(_,0,g),l.push(p.r,p.g,p.b),x=(y+1)/r*(Math.PI*2),_=Math.sin(x)*m,g=Math.cos(x)*m,o.push(_,0,g),l.push(p.r,p.g,p.b)}}const c=new Ct;c.setAttribute("position",new dt(o,3)),c.setAttribute("color",new dt(l,3));const f=new Gi({vertexColors:!0,toneMapped:!1});super(c,f),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const QE=new J,Tp=new J,$E=new J;class MI extends Xt{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new Ct;r.setAttribute("position",new dt([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const s=new Gi({fog:!1,toneMapped:!1});this.lightPlane=new fo(r,s),this.add(this.lightPlane),r=new Ct,r.setAttribute("position",new dt([0,0,0,0,0,1],3)),this.targetLine=new fo(r,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),QE.setFromMatrixPosition(this.light.matrixWorld),Tp.setFromMatrixPosition(this.light.target.matrixWorld),$E.subVectors(Tp,QE),this.lightPlane.lookAt(Tp),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(Tp),this.targetLine.scale.z=$E.length()}}const Ap=new J,Nn=new Ng;class wI extends Ds{constructor(e){const t=new Ct,n=new Gi({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],a={};o("n1","n2"),o("n2","n4"),o("n4","n3"),o("n3","n1"),o("f1","f2"),o("f2","f4"),o("f4","f3"),o("f3","f1"),o("n1","f1"),o("n2","f2"),o("n3","f3"),o("n4","f4"),o("p","n1"),o("p","n2"),o("p","n3"),o("p","n4"),o("u1","u2"),o("u2","u3"),o("u3","u1"),o("c","t"),o("p","c"),o("cn1","cn2"),o("cn3","cn4"),o("cf1","cf2"),o("cf3","cf4");function o(y,x){l(y),l(x)}function l(y){r.push(0,0,0),s.push(0,0,0),a[y]===void 0&&(a[y]=[]),a[y].push(r.length/3-1)}t.setAttribute("position",new dt(r,3)),t.setAttribute("color",new dt(s,3)),super(t,n),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update();const c=new et(16755200),f=new et(16711680),d=new et(43775),p=new et(16777215),m=new et(3355443);this.setColors(c,f,d,p,m)}setColors(e,t,n,r,s){const o=this.geometry.getAttribute("color");o.setXYZ(0,e.r,e.g,e.b),o.setXYZ(1,e.r,e.g,e.b),o.setXYZ(2,e.r,e.g,e.b),o.setXYZ(3,e.r,e.g,e.b),o.setXYZ(4,e.r,e.g,e.b),o.setXYZ(5,e.r,e.g,e.b),o.setXYZ(6,e.r,e.g,e.b),o.setXYZ(7,e.r,e.g,e.b),o.setXYZ(8,e.r,e.g,e.b),o.setXYZ(9,e.r,e.g,e.b),o.setXYZ(10,e.r,e.g,e.b),o.setXYZ(11,e.r,e.g,e.b),o.setXYZ(12,e.r,e.g,e.b),o.setXYZ(13,e.r,e.g,e.b),o.setXYZ(14,e.r,e.g,e.b),o.setXYZ(15,e.r,e.g,e.b),o.setXYZ(16,e.r,e.g,e.b),o.setXYZ(17,e.r,e.g,e.b),o.setXYZ(18,e.r,e.g,e.b),o.setXYZ(19,e.r,e.g,e.b),o.setXYZ(20,e.r,e.g,e.b),o.setXYZ(21,e.r,e.g,e.b),o.setXYZ(22,e.r,e.g,e.b),o.setXYZ(23,e.r,e.g,e.b),o.setXYZ(24,t.r,t.g,t.b),o.setXYZ(25,t.r,t.g,t.b),o.setXYZ(26,t.r,t.g,t.b),o.setXYZ(27,t.r,t.g,t.b),o.setXYZ(28,t.r,t.g,t.b),o.setXYZ(29,t.r,t.g,t.b),o.setXYZ(30,t.r,t.g,t.b),o.setXYZ(31,t.r,t.g,t.b),o.setXYZ(32,n.r,n.g,n.b),o.setXYZ(33,n.r,n.g,n.b),o.setXYZ(34,n.r,n.g,n.b),o.setXYZ(35,n.r,n.g,n.b),o.setXYZ(36,n.r,n.g,n.b),o.setXYZ(37,n.r,n.g,n.b),o.setXYZ(38,r.r,r.g,r.b),o.setXYZ(39,r.r,r.g,r.b),o.setXYZ(40,s.r,s.g,s.b),o.setXYZ(41,s.r,s.g,s.b),o.setXYZ(42,s.r,s.g,s.b),o.setXYZ(43,s.r,s.g,s.b),o.setXYZ(44,s.r,s.g,s.b),o.setXYZ(45,s.r,s.g,s.b),o.setXYZ(46,s.r,s.g,s.b),o.setXYZ(47,s.r,s.g,s.b),o.setXYZ(48,s.r,s.g,s.b),o.setXYZ(49,s.r,s.g,s.b),o.needsUpdate=!0}update(){const e=this.geometry,t=this.pointMap,n=1,r=1;Nn.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse);const s=this.camera.coordinateSystem===Fr?-1:0;Fn("c",t,e,Nn,0,0,s),Fn("t",t,e,Nn,0,0,1),Fn("n1",t,e,Nn,-1,-1,s),Fn("n2",t,e,Nn,n,-1,s),Fn("n3",t,e,Nn,-1,r,s),Fn("n4",t,e,Nn,n,r,s),Fn("f1",t,e,Nn,-1,-1,1),Fn("f2",t,e,Nn,n,-1,1),Fn("f3",t,e,Nn,-1,r,1),Fn("f4",t,e,Nn,n,r,1),Fn("u1",t,e,Nn,n*.7,r*1.1,s),Fn("u2",t,e,Nn,-1*.7,r*1.1,s),Fn("u3",t,e,Nn,0,r*2,s),Fn("cf1",t,e,Nn,-1,0,1),Fn("cf2",t,e,Nn,n,0,1),Fn("cf3",t,e,Nn,0,-1,1),Fn("cf4",t,e,Nn,0,r,1),Fn("cn1",t,e,Nn,-1,0,s),Fn("cn2",t,e,Nn,n,0,s),Fn("cn3",t,e,Nn,0,-1,s),Fn("cn4",t,e,Nn,0,r,s),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function Fn(i,e,t,n,r,s,a){Ap.set(r,s,a).unproject(n);const o=e[i];if(o!==void 0){const l=t.getAttribute("position");for(let c=0,f=o.length;c<f;c++)l.setXYZ(o[c],Ap.x,Ap.y,Ap.z)}}const Cp=new Jn;class TI extends Ds{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new Float32Array(24),s=new Ct;s.setIndex(new en(n,1)),s.setAttribute("position",new en(r,3)),super(s,new Gi({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(this.object!==void 0&&Cp.setFromObject(this.object),Cp.isEmpty())return;const e=Cp.min,t=Cp.max,n=this.geometry.attributes.position,r=n.array;r[0]=t.x,r[1]=t.y,r[2]=t.z,r[3]=e.x,r[4]=t.y,r[5]=t.z,r[6]=e.x,r[7]=e.y,r[8]=t.z,r[9]=t.x,r[10]=e.y,r[11]=t.z,r[12]=t.x,r[13]=t.y,r[14]=e.z,r[15]=e.x,r[16]=t.y,r[17]=e.z,r[18]=e.x,r[19]=e.y,r[20]=e.z,r[21]=t.x,r[22]=e.y,r[23]=e.z,n.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class AI extends Ds{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new Ct;s.setIndex(new en(n,1)),s.setAttribute("position",new dt(r,3)),super(s,new Gi({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}}class CI extends fo{constructor(e,t=1,n=16776960){const r=n,s=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],a=new Ct;a.setAttribute("position",new dt(s,3)),a.computeBoundingSphere(),super(a,new Gi({color:r,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const o=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],l=new Ct;l.setAttribute("position",new dt(o,3)),l.computeBoundingSphere(),this.add(new pn(l,new Sa({color:r,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const eM=new J;let Rp,yy;class RI extends Xt{constructor(e=new J(0,0,1),t=new J(0,0,0),n=1,r=16776960,s=n*.2,a=s*.2){super(),this.type="ArrowHelper",Rp===void 0&&(Rp=new Ct,Rp.setAttribute("position",new dt([0,0,0,0,1,0],3)),yy=new Zf(.5,1,5,1),yy.translate(0,-.5,0)),this.position.copy(t),this.line=new fo(Rp,new Gi({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new pn(yy,new Sa({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(n,s,a)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{eM.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(eM,t)}}setLength(e,t=e*.2,n=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class DI extends Ds{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new Ct;r.setAttribute("position",new dt(t,3)),r.setAttribute("color",new dt(n,3));const s=new Gi({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,n){const r=new et,s=this.geometry.attributes.color.array;return r.set(e),r.toArray(s,0),r.toArray(s,3),r.set(t),r.toArray(s,6),r.toArray(s,9),r.set(n),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class UI{constructor(){this.type="ShapePath",this.color=new et,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new tg,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,r){return this.currentPath.quadraticCurveTo(e,t,n,r),this}bezierCurveTo(e,t,n,r,s,a){return this.currentPath.bezierCurveTo(e,t,n,r,s,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(g){const b=[];for(let S=0,E=g.length;S<E;S++){const w=g[S],T=new bl;T.curves=w.curves,b.push(T)}return b}function n(g,b){const S=b.length;let E=!1;for(let w=S-1,T=0;T<S;w=T++){let R=b[w],U=b[T],D=U.x-R.x,C=U.y-R.y;if(Math.abs(C)>Number.EPSILON){if(C<0&&(R=b[T],D=-D,U=b[w],C=-C),g.y<R.y||g.y>U.y)continue;if(g.y===R.y){if(g.x===R.x)return!0}else{const P=C*(g.x-R.x)-D*(g.y-R.y);if(P===0)return!0;if(P<0)continue;E=!E}}else{if(g.y!==R.y)continue;if(U.x<=g.x&&g.x<=R.x||R.x<=g.x&&g.x<=U.x)return!0}}return E}const r=as.isClockWise,s=this.subPaths;if(s.length===0)return[];let a,o,l;const c=[];if(s.length===1)return o=s[0],l=new bl,l.curves=o.curves,c.push(l),c;let f=!r(s[0].getPoints());f=e?!f:f;const d=[],p=[];let m=[],y=0,x;p[y]=void 0,m[y]=[];for(let g=0,b=s.length;g<b;g++)o=s[g],x=o.getPoints(),a=r(x),a=e?!a:a,a?(!f&&p[y]&&y++,p[y]={s:new bl,p:x},p[y].s.curves=o.curves,f&&y++,m[y]=[]):m[y].push({h:o,p:x[0]});if(!p[0])return t(s);if(p.length>1){let g=!1,b=0;for(let S=0,E=p.length;S<E;S++)d[S]=[];for(let S=0,E=p.length;S<E;S++){const w=m[S];for(let T=0;T<w.length;T++){const R=w[T];let U=!0;for(let D=0;D<p.length;D++)n(R.p,p[D].p)&&(S!==D&&b++,U?(U=!1,d[D].push(R)):g=!0);U&&d[S].push(R)}}b>0&&g===!1&&(m=d)}let _;for(let g=0,b=p.length;g<b;g++){l=p[g].s,c.push(l),_=m[g];for(let S=0,E=_.length;S<E;S++)l.holes.push(_[S].h)}return c}}let OI=class extends Rs{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){console.warn("THREE.Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}};function LI(i,e){const t=i.image&&i.image.width?i.image.width/i.image.height:1;return t>e?(i.repeat.x=1,i.repeat.y=t/e,i.offset.x=0,i.offset.y=(1-i.repeat.y)/2):(i.repeat.x=e/t,i.repeat.y=1,i.offset.x=(1-i.repeat.x)/2,i.offset.y=0),i}function NI(i,e){const t=i.image&&i.image.width?i.image.width/i.image.height:1;return t>e?(i.repeat.x=e/t,i.repeat.y=1,i.offset.x=(1-i.repeat.x)/2,i.offset.y=0):(i.repeat.x=1,i.repeat.y=t/e,i.offset.x=0,i.offset.y=(1-i.repeat.y)/2),i}function II(i){return i.repeat.x=1,i.repeat.y=1,i.offset.x=0,i.offset.y=0,i}function J_(i,e,t,n){const r=PI(n);switch(t){case Bx:return i*e;case Cg:return i*e/r.components*r.byteLength;case qf:return i*e/r.components*r.byteLength;case Gx:return i*e*2/r.components*r.byteLength;case Rg:return i*e*2/r.components*r.byteLength;case kx:return i*e*3/r.components*r.byteLength;case Di:return i*e*4/r.components*r.byteLength;case Dg:return i*e*4/r.components*r.byteLength;case Qh:case $h:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case ef:case tf:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case wm:case Am:return Math.max(i,16)*Math.max(e,8)/4;case Mm:case Tm:return Math.max(i,8)*Math.max(e,8)/2;case Cm:case Rm:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Dm:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Um:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Om:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case Lm:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case Nm:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case Im:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case Pm:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case zm:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case Fm:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case Bm:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case km:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case Gm:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case Hm:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case Vm:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case Wm:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case nf:case Xm:case jm:return Math.ceil(i/4)*Math.ceil(e/4)*16;case Hx:case qm:return Math.ceil(i/4)*Math.ceil(e/4)*8;case Ym:case Zm:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function PI(i){switch(i){case Gr:case Px:return{byteLength:1,components:1};case ru:case zx:case xu:return{byteLength:2,components:1};case Tg:case Ag:return{byteLength:2,components:4};case _a:case wg:case tr:return{byteLength:4,components:1};case Fx:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}class zI{static contain(e,t){return LI(e,t)}static cover(e,t){return NI(e,t)}static fill(e){return II(e)}static getByteLength(e,t,n,r){return J_(e,t,n,r)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Sg}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Sg);/**
|
|
45
45
|
* @license
|
|
46
46
|
* Copyright 2010-2025 Three.js Authors
|
|
47
47
|
* SPDX-License-Identifier: MIT
|
|
@@ -3751,7 +3751,7 @@ void main() {
|
|
|
3751
3751
|
`;return i.precision==="highp"?e+=`
|
|
3752
3752
|
#define HIGH_PRECISION`:i.precision==="mediump"?e+=`
|
|
3753
3753
|
#define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=`
|
|
3754
|
-
#define LOW_PRECISION`),e}function kB(i){let e="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===Eg?e="SHADOWMAP_TYPE_PCF":i.shadowMapType===Kh?e="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===ns&&(e="SHADOWMAP_TYPE_VSM"),e}function GB(i){let e="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case ya:case uo:e="ENVMAP_TYPE_CUBE";break;case _u:e="ENVMAP_TYPE_CUBE_UV";break}return e}function HB(i){let e="ENVMAP_MODE_REFLECTION";if(i.envMap)switch(i.envMapMode){case uo:e="ENVMAP_MODE_REFRACTION";break}return e}function VB(i){let e="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case jf:e="ENVMAP_BLENDING_MULTIPLY";break;case XA:e="ENVMAP_BLENDING_MIX";break;case jA:e="ENVMAP_BLENDING_ADD";break}return e}function WB(i){const e=i.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),
|
|
3754
|
+
#define LOW_PRECISION`),e}function kB(i){let e="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===Eg?e="SHADOWMAP_TYPE_PCF":i.shadowMapType===Kh?e="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===ns&&(e="SHADOWMAP_TYPE_VSM"),e}function GB(i){let e="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case ya:case uo:e="ENVMAP_TYPE_CUBE";break;case _u:e="ENVMAP_TYPE_CUBE_UV";break}return e}function HB(i){let e="ENVMAP_MODE_REFLECTION";if(i.envMap)switch(i.envMapMode){case uo:e="ENVMAP_MODE_REFRACTION";break}return e}function VB(i){let e="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case jf:e="ENVMAP_BLENDING_MULTIPLY";break;case XA:e="ENVMAP_BLENDING_MIX";break;case jA:e="ENVMAP_BLENDING_ADD";break}return e}function WB(i){const e=i.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:n,maxMip:t}}function XB(i,e,t,n){const r=i.getContext(),s=t.defines;let a=t.vertexShader,o=t.fragmentShader;const l=kB(t),c=GB(t),f=HB(t),d=VB(t),p=WB(t),m=OB(t),y=LB(s),x=r.createProgram();let _,g,b=t.glslVersion?"#version "+t.glslVersion+`
|
|
3755
3755
|
`:"";t.isRawShaderMaterial?(_=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,y].filter(Xh).join(`
|
|
3756
3756
|
`),_.length>0&&(_+=`
|
|
3757
3757
|
`),g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,y].filter(Xh).join(`
|
|
@@ -4136,12 +4136,12 @@ if (edgeAlpha == 0.0) {
|
|
|
4136
4136
|
`;function Z9(i){const e=Dx(i,{chained:!0,extensions:{derivatives:!0},uniforms:{uTroikaSDFTexture:{value:null},uTroikaSDFTextureSize:{value:new Ge},uTroikaSDFGlyphSize:{value:0},uTroikaSDFExponent:{value:0},uTroikaTotalBounds:{value:new kt(0,0,0,0)},uTroikaClipRect:{value:new kt(0,0,0,0)},uTroikaEdgeOffset:{value:0},uTroikaFillOpacity:{value:1},uTroikaPositionOffset:{value:new Ge},uTroikaCurveRadius:{value:0},uTroikaBlurRadius:{value:0},uTroikaStrokeWidth:{value:0},uTroikaStrokeColor:{value:new et},uTroikaStrokeOpacity:{value:1},uTroikaOrient:{value:new wt},uTroikaUseGlyphColors:{value:!0},uTroikaSDFDebug:{value:!1}},vertexDefs:X9,vertexTransform:j9,fragmentDefs:q9,fragmentColorTransform:Y9,customRewriter({vertexShader:t,fragmentShader:n}){let r=/\buniform\s+vec3\s+diffuse\b/;return r.test(n)&&(n=n.replace(r,"varying vec3 vTroikaGlyphColor").replace(/\bdiffuse\b/g,"vTroikaGlyphColor"),r.test(t)||(t=t.replace(x3,`uniform vec3 diffuse;
|
|
4137
4137
|
$&
|
|
4138
4138
|
vTroikaGlyphColor = uTroikaUseGlyphColors ? aTroikaGlyphColor / 255.0 : diffuse;
|
|
4139
|
-
`))),{vertexShader:t,fragmentShader:n}}});return e.transparent=!0,e.forceSinglePass=!0,Object.defineProperties(e,{isTroikaTextMaterial:{value:!0},shadowSide:{get(){return this.side},set(){}}}),e}const sb=new Sa({color:16777215,side:In,transparent:!0}),KT=8421504,JT=new bt,qp=new J,A_=new J,Ph=[],K9=new J,C_="+x+y";function QT(i){return Array.isArray(i)?i[0]:i}let T3=()=>{const i=new pn(new Ma(1,1),sb);return T3=()=>i,i},A3=()=>{const i=new pn(new Ma(1,1,32,1),sb);return A3=()=>i,i};const J9={type:"syncstart"},Q9={type:"synccomplete"},C3=["font","fontSize","fontStyle","fontWeight","lang","letterSpacing","lineHeight","maxWidth","overflowWrap","text","direction","textAlign","textIndent","whiteSpace","anchorX","anchorY","colorRanges","sdfGlyphSize"],$9=C3.concat("material","color","depthOffset","clipRect","curveRadius","orientation","glyphGeometryDetail");let R3=class extends pn{constructor(){const e=new W9;super(e,null),this.text="",this.anchorX=0,this.anchorY=0,this.curveRadius=0,this.direction="auto",this.font=null,this.unicodeFontsURL=null,this.fontSize=.1,this.fontWeight="normal",this.fontStyle="normal",this.lang=null,this.letterSpacing=0,this.lineHeight="normal",this.maxWidth=1/0,this.overflowWrap="normal",this.textAlign="left",this.textIndent=0,this.whiteSpace="normal",this.material=null,this.color=null,this.colorRanges=null,this.outlineWidth=0,this.outlineColor=0,this.outlineOpacity=1,this.outlineBlur=0,this.outlineOffsetX=0,this.outlineOffsetY=0,this.strokeWidth=0,this.strokeColor=KT,this.strokeOpacity=1,this.fillOpacity=1,this.depthOffset=0,this.clipRect=null,this.orientation=C_,this.glyphGeometryDetail=1,this.sdfGlyphSize=null,this.gpuAccelerateSDF=!0,this.debugSDF=!1}sync(e){this._needsSync&&(this._needsSync=!1,this._isSyncing?(this._queuedSyncs||(this._queuedSyncs=[])).push(e):(this._isSyncing=!0,this.dispatchEvent(J9),S3({text:this.text,font:this.font,lang:this.lang,fontSize:this.fontSize||.1,fontWeight:this.fontWeight||"normal",fontStyle:this.fontStyle||"normal",letterSpacing:this.letterSpacing||0,lineHeight:this.lineHeight||"normal",maxWidth:this.maxWidth,direction:this.direction||"auto",textAlign:this.textAlign,textIndent:this.textIndent,whiteSpace:this.whiteSpace,overflowWrap:this.overflowWrap,anchorX:this.anchorX,anchorY:this.anchorY,colorRanges:this.colorRanges,includeCaretPositions:!0,sdfGlyphSize:this.sdfGlyphSize,gpuAccelerateSDF:this.gpuAccelerateSDF,unicodeFontsURL:this.unicodeFontsURL},t=>{this._isSyncing=!1,this._textRenderInfo=t,this.geometry.updateGlyphs(t.glyphBounds,t.glyphAtlasIndices,t.blockBounds,t.chunkedBounds,t.glyphColors);const n=this._queuedSyncs;n&&(this._queuedSyncs=null,this._needsSync=!0,this.sync(()=>{n.forEach(r=>r&&r())})),this.dispatchEvent(Q9),e&&e()})))}onBeforeRender(e,t,n,r,s,a){this.sync(),s.isTroikaTextMaterial&&this._prepareForRender(s)}dispose(){this.geometry.dispose()}get textRenderInfo(){return this._textRenderInfo||null}createDerivedMaterial(e){return Z9(e)}get material(){let e=this._derivedMaterial;const t=this._baseMaterial||this._defaultMaterial||(this._defaultMaterial=sb.clone());if((!e||!e.isDerivedFrom(t))&&(e=this._derivedMaterial=this.createDerivedMaterial(t),t.addEventListener("dispose",function n(){t.removeEventListener("dispose",n),e.dispose()})),this.hasOutline()){let n=e._outlineMtl;return n||(n=e._outlineMtl=Object.create(e,{id:{value:e.id+.1}}),n.isTextOutlineMaterial=!0,n.depthWrite=!1,n.map=null,e.addEventListener("dispose",function r(){e.removeEventListener("dispose",r),n.dispose()})),[n,e]}else return e}set material(e){e&&e.isTroikaTextMaterial?(this._derivedMaterial=e,this._baseMaterial=e.baseMaterial):this._baseMaterial=e}hasOutline(){return!!(this.outlineWidth||this.outlineBlur||this.outlineOffsetX||this.outlineOffsetY)}get glyphGeometryDetail(){return this.geometry.detail}set glyphGeometryDetail(e){this.geometry.detail=e}get curveRadius(){return this.geometry.curveRadius}set curveRadius(e){this.geometry.curveRadius=e}get customDepthMaterial(){return QT(this.material).getDepthMaterial()}set customDepthMaterial(e){}get customDistanceMaterial(){return QT(this.material).getDistanceMaterial()}set customDistanceMaterial(e){}_prepareForRender(e){const t=e.isTextOutlineMaterial,n=e.uniforms,r=this.textRenderInfo;if(r){const{sdfTexture:o,blockBounds:l}=r;n.uTroikaSDFTexture.value=o,n.uTroikaSDFTextureSize.value.set(o.image.width,o.image.height),n.uTroikaSDFGlyphSize.value=r.sdfGlyphSize,n.uTroikaSDFExponent.value=r.sdfExponent,n.uTroikaTotalBounds.value.fromArray(l),n.uTroikaUseGlyphColors.value=!t&&!!r.glyphColors;let c=0,f=0,d=0,p,m,y,x=0,_=0;if(t){let{outlineWidth:b,outlineOffsetX:S,outlineOffsetY:E,outlineBlur:w,outlineOpacity:T}=this;c=this._parsePercent(b)||0,f=Math.max(0,this._parsePercent(w)||0),p=T,x=this._parsePercent(S)||0,_=this._parsePercent(E)||0}else d=Math.max(0,this._parsePercent(this.strokeWidth)||0),d&&(y=this.strokeColor,n.uTroikaStrokeColor.value.set(y??KT),m=this.strokeOpacity,m==null&&(m=1)),p=this.fillOpacity;n.uTroikaEdgeOffset.value=c,n.uTroikaPositionOffset.value.set(x,_),n.uTroikaBlurRadius.value=f,n.uTroikaStrokeWidth.value=d,n.uTroikaStrokeOpacity.value=m,n.uTroikaFillOpacity.value=p??1,n.uTroikaCurveRadius.value=this.curveRadius||0;let g=this.clipRect;if(g&&Array.isArray(g)&&g.length===4)n.uTroikaClipRect.value.fromArray(g);else{const b=(this.fontSize||.1)*100;n.uTroikaClipRect.value.set(l[0]-b,l[1]-b,l[2]+b,l[3]+b)}this.geometry.applyClipRect(n.uTroikaClipRect.value)}n.uTroikaSDFDebug.value=!!this.debugSDF,e.polygonOffset=!!this.depthOffset,e.polygonOffsetFactor=e.polygonOffsetUnits=this.depthOffset||0;const s=t?this.outlineColor||0:this.color;if(s==null)delete e.color;else{const o=e.hasOwnProperty("color")?e.color:e.color=new et;(s!==o._input||typeof s=="object")&&o.set(o._input=s)}let a=this.orientation||C_;if(a!==e._orientation){let o=n.uTroikaOrient.value;a=a.replace(/[^-+xyz]/g,"");let l=a!==C_&&a.match(/^([-+])([xyz])([-+])([xyz])$/);if(l){let[,c,f,d,p]=l;qp.set(0,0,0)[f]=c==="-"?1:-1,A_.set(0,0,0)[p]=d==="-"?-1:1,JT.lookAt(K9,qp.cross(A_),A_),o.setFromMatrix4(JT)}else o.identity();e._orientation=a}}_parsePercent(e){if(typeof e=="string"){let t=e.match(/^(-?[\d.]+)%$/),n=t?parseFloat(t[1]):NaN;e=(isNaN(n)?0:n/100)*this.fontSize}return e}localPositionToTextCoords(e,t=new Ge){t.copy(e);const n=this.curveRadius;return n&&(t.x=Math.atan2(e.x,Math.abs(n)-Math.abs(e.z))*Math.abs(n)),t}worldPositionToTextCoords(e,t=new Ge){return qp.copy(e),this.localPositionToTextCoords(this.worldToLocal(qp),t)}raycast(e,t){const{textRenderInfo:n,curveRadius:r}=this;if(n){const s=n.blockBounds,a=r?A3():T3(),o=a.geometry,{position:l,uv:c}=o.attributes;for(let f=0;f<c.count;f++){let d=s[0]+c.getX(f)*(s[2]-s[0]);const p=s[1]+c.getY(f)*(s[3]-s[1]);let m=0;r&&(m=r-Math.cos(d/r)*r,d=Math.sin(d/r)*r),l.setXYZ(f,d,p,m)}o.boundingSphere=this.geometry.boundingSphere,o.boundingBox=this.geometry.boundingBox,a.matrixWorld=this.matrixWorld,a.material.side=this.material.side,Ph.length=0,a.raycast(e,Ph);for(let f=0;f<Ph.length;f++)Ph[f].object=this,t.push(Ph[f])}}copy(e){const t=this.geometry;return super.copy(e),this.geometry=t,$9.forEach(n=>{this[n]=e[n]}),this}clone(){return new this.constructor().copy(this)}};C3.forEach(i=>{const e="_private_"+i;Object.defineProperty(R3.prototype,i,{get(){return this[e]},set(t){t!==this[e]&&(this[e]=t,this._needsSync=!0)}})});new Jn;new et;const eW=Q.forwardRef(({sdfGlyphSize:i=64,anchorX:e="center",anchorY:t="middle",font:n,fontSize:r=1,children:s,characters:a,onSync:o,...l},c)=>{const f=Kn(({invalidate:y})=>y),[d]=Q.useState(()=>new R3),[p,m]=Q.useMemo(()=>{const y=[];let x="";return Q.Children.forEach(s,_=>{typeof _=="string"||typeof _=="number"?x+=_:y.push(_)}),[y,x]},[s]);return G4(()=>new Promise(y=>z9({font:n,characters:a},y)),["troika-text",n,a]),Q.useLayoutEffect(()=>void d.sync(()=>{f(),o&&o(d)})),Q.useEffect(()=>()=>d.dispose(),[d]),Q.createElement("primitive",Hf({object:d,ref:c,font:n,text:m,anchorX:e,anchorY:t,fontSize:r,sdfGlyphSize:i},l),p)});/*!
|
|
4139
|
+
`))),{vertexShader:t,fragmentShader:n}}});return e.transparent=!0,e.forceSinglePass=!0,Object.defineProperties(e,{isTroikaTextMaterial:{value:!0},shadowSide:{get(){return this.side},set(){}}}),e}const sb=new Sa({color:16777215,side:In,transparent:!0}),KT=8421504,JT=new bt,qp=new J,A_=new J,Ph=[],K9=new J,C_="+x+y";function QT(i){return Array.isArray(i)?i[0]:i}let T3=()=>{const i=new pn(new Ma(1,1),sb);return T3=()=>i,i},A3=()=>{const i=new pn(new Ma(1,1,32,1),sb);return A3=()=>i,i};const J9={type:"syncstart"},Q9={type:"synccomplete"},C3=["font","fontSize","fontStyle","fontWeight","lang","letterSpacing","lineHeight","maxWidth","overflowWrap","text","direction","textAlign","textIndent","whiteSpace","anchorX","anchorY","colorRanges","sdfGlyphSize"],$9=C3.concat("material","color","depthOffset","clipRect","curveRadius","orientation","glyphGeometryDetail");let R3=class extends pn{constructor(){const e=new W9;super(e,null),this.text="",this.anchorX=0,this.anchorY=0,this.curveRadius=0,this.direction="auto",this.font=null,this.unicodeFontsURL=null,this.fontSize=.1,this.fontWeight="normal",this.fontStyle="normal",this.lang=null,this.letterSpacing=0,this.lineHeight="normal",this.maxWidth=1/0,this.overflowWrap="normal",this.textAlign="left",this.textIndent=0,this.whiteSpace="normal",this.material=null,this.color=null,this.colorRanges=null,this.outlineWidth=0,this.outlineColor=0,this.outlineOpacity=1,this.outlineBlur=0,this.outlineOffsetX=0,this.outlineOffsetY=0,this.strokeWidth=0,this.strokeColor=KT,this.strokeOpacity=1,this.fillOpacity=1,this.depthOffset=0,this.clipRect=null,this.orientation=C_,this.glyphGeometryDetail=1,this.sdfGlyphSize=null,this.gpuAccelerateSDF=!0,this.debugSDF=!1}sync(e){this._needsSync&&(this._needsSync=!1,this._isSyncing?(this._queuedSyncs||(this._queuedSyncs=[])).push(e):(this._isSyncing=!0,this.dispatchEvent(J9),S3({text:this.text,font:this.font,lang:this.lang,fontSize:this.fontSize||.1,fontWeight:this.fontWeight||"normal",fontStyle:this.fontStyle||"normal",letterSpacing:this.letterSpacing||0,lineHeight:this.lineHeight||"normal",maxWidth:this.maxWidth,direction:this.direction||"auto",textAlign:this.textAlign,textIndent:this.textIndent,whiteSpace:this.whiteSpace,overflowWrap:this.overflowWrap,anchorX:this.anchorX,anchorY:this.anchorY,colorRanges:this.colorRanges,includeCaretPositions:!0,sdfGlyphSize:this.sdfGlyphSize,gpuAccelerateSDF:this.gpuAccelerateSDF,unicodeFontsURL:this.unicodeFontsURL},t=>{this._isSyncing=!1,this._textRenderInfo=t,this.geometry.updateGlyphs(t.glyphBounds,t.glyphAtlasIndices,t.blockBounds,t.chunkedBounds,t.glyphColors);const n=this._queuedSyncs;n&&(this._queuedSyncs=null,this._needsSync=!0,this.sync(()=>{n.forEach(r=>r&&r())})),this.dispatchEvent(Q9),e&&e()})))}onBeforeRender(e,t,n,r,s,a){this.sync(),s.isTroikaTextMaterial&&this._prepareForRender(s)}dispose(){this.geometry.dispose()}get textRenderInfo(){return this._textRenderInfo||null}createDerivedMaterial(e){return Z9(e)}get material(){let e=this._derivedMaterial;const t=this._baseMaterial||this._defaultMaterial||(this._defaultMaterial=sb.clone());if((!e||!e.isDerivedFrom(t))&&(e=this._derivedMaterial=this.createDerivedMaterial(t),t.addEventListener("dispose",function n(){t.removeEventListener("dispose",n),e.dispose()})),this.hasOutline()){let n=e._outlineMtl;return n||(n=e._outlineMtl=Object.create(e,{id:{value:e.id+.1}}),n.isTextOutlineMaterial=!0,n.depthWrite=!1,n.map=null,e.addEventListener("dispose",function r(){e.removeEventListener("dispose",r),n.dispose()})),[n,e]}else return e}set material(e){e&&e.isTroikaTextMaterial?(this._derivedMaterial=e,this._baseMaterial=e.baseMaterial):this._baseMaterial=e}hasOutline(){return!!(this.outlineWidth||this.outlineBlur||this.outlineOffsetX||this.outlineOffsetY)}get glyphGeometryDetail(){return this.geometry.detail}set glyphGeometryDetail(e){this.geometry.detail=e}get curveRadius(){return this.geometry.curveRadius}set curveRadius(e){this.geometry.curveRadius=e}get customDepthMaterial(){return QT(this.material).getDepthMaterial()}set customDepthMaterial(e){}get customDistanceMaterial(){return QT(this.material).getDistanceMaterial()}set customDistanceMaterial(e){}_prepareForRender(e){const t=e.isTextOutlineMaterial,n=e.uniforms,r=this.textRenderInfo;if(r){const{sdfTexture:o,blockBounds:l}=r;n.uTroikaSDFTexture.value=o,n.uTroikaSDFTextureSize.value.set(o.image.width,o.image.height),n.uTroikaSDFGlyphSize.value=r.sdfGlyphSize,n.uTroikaSDFExponent.value=r.sdfExponent,n.uTroikaTotalBounds.value.fromArray(l),n.uTroikaUseGlyphColors.value=!t&&!!r.glyphColors;let c=0,f=0,d=0,p,m,y,x=0,_=0;if(t){let{outlineWidth:b,outlineOffsetX:S,outlineOffsetY:E,outlineBlur:w,outlineOpacity:T}=this;c=this._parsePercent(b)||0,f=Math.max(0,this._parsePercent(w)||0),p=T,x=this._parsePercent(S)||0,_=this._parsePercent(E)||0}else d=Math.max(0,this._parsePercent(this.strokeWidth)||0),d&&(y=this.strokeColor,n.uTroikaStrokeColor.value.set(y??KT),m=this.strokeOpacity,m==null&&(m=1)),p=this.fillOpacity;n.uTroikaEdgeOffset.value=c,n.uTroikaPositionOffset.value.set(x,_),n.uTroikaBlurRadius.value=f,n.uTroikaStrokeWidth.value=d,n.uTroikaStrokeOpacity.value=m,n.uTroikaFillOpacity.value=p??1,n.uTroikaCurveRadius.value=this.curveRadius||0;let g=this.clipRect;if(g&&Array.isArray(g)&&g.length===4)n.uTroikaClipRect.value.fromArray(g);else{const b=(this.fontSize||.1)*100;n.uTroikaClipRect.value.set(l[0]-b,l[1]-b,l[2]+b,l[3]+b)}this.geometry.applyClipRect(n.uTroikaClipRect.value)}n.uTroikaSDFDebug.value=!!this.debugSDF,e.polygonOffset=!!this.depthOffset,e.polygonOffsetFactor=e.polygonOffsetUnits=this.depthOffset||0;const s=t?this.outlineColor||0:this.color;if(s==null)delete e.color;else{const o=e.hasOwnProperty("color")?e.color:e.color=new et;(s!==o._input||typeof s=="object")&&o.set(o._input=s)}let a=this.orientation||C_;if(a!==e._orientation){let o=n.uTroikaOrient.value;a=a.replace(/[^-+xyz]/g,"");let l=a!==C_&&a.match(/^([-+])([xyz])([-+])([xyz])$/);if(l){let[,c,f,d,p]=l;qp.set(0,0,0)[f]=c==="-"?1:-1,A_.set(0,0,0)[p]=d==="-"?-1:1,JT.lookAt(K9,qp.cross(A_),A_),o.setFromMatrix4(JT)}else o.identity();e._orientation=a}}_parsePercent(e){if(typeof e=="string"){let t=e.match(/^(-?[\d.]+)%$/),n=t?parseFloat(t[1]):NaN;e=(isNaN(n)?0:n/100)*this.fontSize}return e}localPositionToTextCoords(e,t=new Ge){t.copy(e);const n=this.curveRadius;return n&&(t.x=Math.atan2(e.x,Math.abs(n)-Math.abs(e.z))*Math.abs(n)),t}worldPositionToTextCoords(e,t=new Ge){return qp.copy(e),this.localPositionToTextCoords(this.worldToLocal(qp),t)}raycast(e,t){const{textRenderInfo:n,curveRadius:r}=this;if(n){const s=n.blockBounds,a=r?A3():T3(),o=a.geometry,{position:l,uv:c}=o.attributes;for(let f=0;f<c.count;f++){let d=s[0]+c.getX(f)*(s[2]-s[0]);const p=s[1]+c.getY(f)*(s[3]-s[1]);let m=0;r&&(m=r-Math.cos(d/r)*r,d=Math.sin(d/r)*r),l.setXYZ(f,d,p,m)}o.boundingSphere=this.geometry.boundingSphere,o.boundingBox=this.geometry.boundingBox,a.matrixWorld=this.matrixWorld,a.material.side=this.material.side,Ph.length=0,a.raycast(e,Ph);for(let f=0;f<Ph.length;f++)Ph[f].object=this,t.push(Ph[f])}}copy(e){const t=this.geometry;return super.copy(e),this.geometry=t,$9.forEach(n=>{this[n]=e[n]}),this}clone(){return new this.constructor().copy(this)}};C3.forEach(i=>{const e="_private_"+i;Object.defineProperty(R3.prototype,i,{get(){return this[e]},set(t){t!==this[e]&&(this[e]=t,this._needsSync=!0)}})});new Jn;new et;const eW=Q.forwardRef(({sdfGlyphSize:i=64,anchorX:e="center",anchorY:t="middle",font:n,fontSize:r=1,children:s,characters:a,onSync:o,...l},c)=>{const f=Kn(({invalidate:y})=>y),[d]=Q.useState(()=>new R3),[p,m]=Q.useMemo(()=>{const y=[];let x="";return Q.Children.forEach(s,_=>{typeof _=="string"||typeof _=="number"?x+=_:y.push(_)}),[y,x]},[s]);return G4(()=>new Promise(y=>z9({font:n,characters:a},y)),["troika-text",n,a]),Q.useLayoutEffect(()=>void d.sync(()=>{f(),o&&o(d)})),Q.useEffect(()=>()=>d.dispose(),[d]),Q.createElement("primitive",Hf({object:d,ref:c,font:n,text:m,anchorX:e,anchorY:t,fontSize:r,sdfGlyphSize:i},l),p)});var zh={exports:{}},$T;function tW(){if($T)return zh.exports;$T=1;var i={ellipse:"…",chars:[" ","-"],max:140,truncate:!0};function e(n,r,s,a){if(n<=r)return n;if(r<2)return n.slice(0,r-s.length)+s;for(var o=r-s.length,l=Math.floor(o/2),c=l,f=n.length-l,d=0;d<l;d++){var p=n.charAt(d),m=n.length-d,y=n.charAt(m);a.indexOf(p)!==-1&&(c=d),a.indexOf(y)!==-1&&(f=m)}return n.slice(0,c)+s+n.slice(f)}function t(n,r,s,a,o){if(n.length<=r)return n;for(var l=r-s.length,c=l,f=0;f<=l;f++){var d=n.charAt(f);a.indexOf(d)!==-1&&(c=f)}return!o&&c==l?"":n.slice(0,c)+s}return zh.exports=function(n,r,s){if(typeof n!="string"||n.length===0||r===0)return"";s=s||{};for(var a in i)(s[a]===null||typeof s[a]>"u")&&(s[a]=i[a]);return s.max=r||s.max,s.truncate=="middle"?e(n,s.max,s.ellipse,s.chars):t(n,s.max,s.ellipse,s.chars,s.truncate)},zh.exports.ellipsizeMiddle=e,zh.exports.ellipsize=t,zh.exports}var nW=tW();const iW=po(nW);/*!
|
|
4140
4140
|
* camera-controls
|
|
4141
4141
|
* https://github.com/yomotsu/camera-controls
|
|
4142
4142
|
* (c) 2017 @yomotsu
|
|
4143
4143
|
* Released under the MIT License.
|
|
4144
|
-
*/const Sn={LEFT:1,RIGHT:2,MIDDLE:4},Ae=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,SCREEN_PAN:4,OFFSET:8,DOLLY:16,ZOOM:32,TOUCH_ROTATE:64,TOUCH_TRUCK:128,TOUCH_SCREEN_PAN:256,TOUCH_OFFSET:512,TOUCH_DOLLY:1024,TOUCH_ZOOM:2048,TOUCH_DOLLY_TRUCK:4096,TOUCH_DOLLY_SCREEN_PAN:8192,TOUCH_DOLLY_OFFSET:16384,TOUCH_DOLLY_ROTATE:32768,TOUCH_ZOOM_TRUCK:65536,TOUCH_ZOOM_OFFSET:131072,TOUCH_ZOOM_SCREEN_PAN:262144,TOUCH_ZOOM_ROTATE:524288}),Vc={NONE:0,IN:1,OUT:-1};function ll(i){return i.isPerspectiveCamera}function io(i){return i.isOrthographicCamera}const Wc=Math.PI*2,$T=Math.PI/2,D3=1e-5,zh=Math.PI/180;function es(i,e,t){return Math.max(e,Math.min(t,i))}function dn(i,e=D3){return Math.abs(i)<e}function Qt(i,e,t=D3){return dn(i-e,t)}function eA(i,e){return Math.round(i/e)*e}function Fh(i){return isFinite(i)?i:i<0?-Number.MAX_VALUE:Number.MAX_VALUE}function Bh(i){return Math.abs(i)<Number.MAX_VALUE?i:i*(1/0)}function Yp(i,e,t,n,r=1/0,s){n=Math.max(1e-4,n);const a=2/n,o=a*s,l=1/(1+o+.48*o*o+.235*o*o*o);let c=i-e;const f=e,d=r*n;c=es(c,-d,d),e=i-c;const p=(t.value+a*c)*s;t.value=(t.value-a*p)*l;let m=e+(c+p)*l;return f-i>0==m>f&&(m=f,t.value=(m-f)/s),m}function tA(i,e,t,n,r=1/0,s,a){n=Math.max(1e-4,n);const o=2/n,l=o*s,c=1/(1+l+.48*l*l+.235*l*l*l);let f=e.x,d=e.y,p=e.z,m=i.x-f,y=i.y-d,x=i.z-p;const _=f,g=d,b=p,S=r*n,E=S*S,w=m*m+y*y+x*x;if(w>E){const Z=Math.sqrt(w);m=m/Z*S,y=y/Z*S,x=x/Z*S}f=i.x-m,d=i.y-y,p=i.z-x;const T=(t.x+o*m)*s,R=(t.y+o*y)*s,U=(t.z+o*x)*s;t.x=(t.x-o*T)*c,t.y=(t.y-o*R)*c,t.z=(t.z-o*U)*c,a.x=f+(m+T)*c,a.y=d+(y+R)*c,a.z=p+(x+U)*c;const D=_-i.x,C=g-i.y,P=b-i.z,I=a.x-_,O=a.y-g,G=a.z-b;return D*I+C*O+P*G>0&&(a.x=_,a.y=g,a.z=b,t.x=(a.x-_)/s,t.y=(a.y-g)/s,t.z=(a.z-b)/s),a}function R_(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 D_(i,e){return io(i)?(console.warn(`${e} is not supported in OrthographicCamera`),!0):!1}let tW=class{constructor(){this._listeners={}}addEventListener(e,t){const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const r=this._listeners[e];if(r!==void 0){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}}removeAllEventListeners(e){if(!e){this._listeners={};return}Array.isArray(this._listeners[e])&&(this._listeners[e].length=0)}dispatchEvent(e){const n=this._listeners[e.type];if(n!==void 0){e.target=this;const r=n.slice(0);for(let s=0,a=r.length;s<a;s++)r[s].call(this,e)}}};var U_;const nW="2.10.1",Zp=1/8,iW=/Mac/.test((U_=globalThis?.navigator)===null||U_===void 0?void 0:U_.platform);let Et,nA,Kp,O_,Ji,Lt,Zt,Xc,kh,xs,bs,cl,iA,rA,Or,Gh,jc,sA,L_,aA,N_,I_,Jp,di=class Ox extends tW{static install(e){Et=e.THREE,nA=Object.freeze(new Et.Vector3(0,0,0)),Kp=Object.freeze(new Et.Vector3(0,1,0)),O_=Object.freeze(new Et.Vector3(0,0,1)),Ji=new Et.Vector2,Lt=new Et.Vector3,Zt=new Et.Vector3,Xc=new Et.Vector3,kh=new Et.Vector3,xs=new Et.Vector3,bs=new Et.Vector3,cl=new Et.Vector3,iA=new Et.Vector3,rA=new Et.Vector3,Or=new Et.Spherical,Gh=new Et.Spherical,jc=new Et.Box3,sA=new Et.Box3,L_=new Et.Sphere,aA=new Et.Quaternion,N_=new Et.Quaternion,I_=new Et.Matrix4,Jp=new Et.Raycaster}static get ACTION(){return Ae}set verticalDragToForward(e){console.warn("camera-controls: `verticalDragToForward` was removed. Use `mouseButtons.left = CameraControls.ACTION.SCREEN_PAN` instead.")}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.boundaryFriction=0,this.restThreshold=.01,this.colliderMeshes=[],this.cancel=()=>{},this._enabled=!0,this._state=Ae.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=Vc.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new Et.Vector3,this._focalOffsetVelocity=new Et.Vector3,this._zoomVelocity={value:0},this._truckInternal=(g,b,S,E)=>{let w,T;if(ll(this._camera)){const R=Lt.copy(this._camera.position).sub(this._target),U=this._camera.getEffectiveFOV()*zh,D=R.length()*Math.tan(U*.5);w=this.truckSpeed*g*D/this._elementRect.height,T=this.truckSpeed*b*D/this._elementRect.height}else if(io(this._camera)){const R=this._camera;w=this.truckSpeed*g*(R.right-R.left)/R.zoom/this._elementRect.width,T=this.truckSpeed*b*(R.top-R.bottom)/R.zoom/this._elementRect.height}else return;E?(S?this.setFocalOffset(this._focalOffsetEnd.x+w,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(w,0,!0),this.forward(-T,!0)):S?this.setFocalOffset(this._focalOffsetEnd.x+w,this._focalOffsetEnd.y+T,this._focalOffsetEnd.z,!0):this.truck(w,T,!0)},this._rotateInternal=(g,b)=>{const S=Wc*this.azimuthRotateSpeed*g/this._elementRect.height,E=Wc*this.polarRotateSpeed*b/this._elementRect.height;this.rotate(S,E,!0)},this._dollyInternal=(g,b,S)=>{const E=Math.pow(.95,-g*this.dollySpeed),w=this._sphericalEnd.radius,T=this._sphericalEnd.radius*E,R=es(T,this.minDistance,this.maxDistance),U=R-T;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(T,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(U,!0),this._dollyToNoClamp(R,!0)):this._dollyToNoClamp(R,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?T:R)-w,this._dollyControlCoord.set(b,S)),this._lastDollyDirection=Math.sign(-g)},this._zoomInternal=(g,b,S)=>{const E=Math.pow(.95,g*this.dollySpeed),w=this._zoom,T=this._zoom*E;this.zoomTo(T,!0),this.dollyToCursor&&(this._changedZoom+=T-w,this._dollyControlCoord.set(b,S))},typeof Et>"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 Et.Quaternion().setFromUnitVectors(this._camera.up,Kp),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=Ae.NONE,this._target=new Et.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new Et.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new Et.Spherical().setFromVector3(Lt.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 Et.Vector3,new Et.Vector3,new Et.Vector3,new Et.Vector3],this._updateNearPlaneCorners(),this._boundary=new Et.Box3(new Et.Vector3(-1/0,-1/0,-1/0),new Et.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 Et.Vector2,this.mouseButtons={left:Ae.ROTATE,middle:Ae.DOLLY,right:Ae.TRUCK,wheel:ll(this._camera)?Ae.DOLLY:io(this._camera)?Ae.ZOOM:Ae.NONE},this.touches={one:Ae.TOUCH_ROTATE,two:ll(this._camera)?Ae.TOUCH_DOLLY_TRUCK:io(this._camera)?Ae.TOUCH_ZOOM_TRUCK:Ae.NONE,three:Ae.TOUCH_TRUCK};const n=new Et.Vector2,r=new Et.Vector2,s=new Et.Vector2,a=g=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const E=this._domElement.getBoundingClientRect(),w=g.clientX/E.width,T=g.clientY/E.height;if(w<this._interactiveArea.left||w>this._interactiveArea.right||T<this._interactiveArea.top||T>this._interactiveArea.bottom)return}const b=g.pointerType!=="mouse"?null:(g.buttons&Sn.LEFT)===Sn.LEFT?Sn.LEFT:(g.buttons&Sn.MIDDLE)===Sn.MIDDLE?Sn.MIDDLE:(g.buttons&Sn.RIGHT)===Sn.RIGHT?Sn.RIGHT:null;if(b!==null){const E=this._findPointerByMouseButton(b);E&&this._disposePointer(E)}if((g.buttons&Sn.LEFT)===Sn.LEFT&&this._lockedPointer)return;const S={pointerId:g.pointerId,clientX:g.clientX,clientY:g.clientY,deltaX:0,deltaY:0,mouseButton:b};this._activePointers.push(S),this._domElement.ownerDocument.removeEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this._domElement.ownerDocument.addEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",l),this._isDragging=!0,p(g)},o=g=>{g.cancelable&&g.preventDefault();const b=g.pointerId,S=this._lockedPointer||this._findPointerById(b);if(S){if(S.clientX=g.clientX,S.clientY=g.clientY,S.deltaX=g.movementX,S.deltaY=g.movementY,this._state=0,g.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&&(g.buttons&Sn.LEFT)===Sn.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(g.buttons&Sn.MIDDLE)===Sn.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(g.buttons&Sn.RIGHT)===Sn.RIGHT&&(this._state=this._state|this.mouseButtons.right);m()}},l=g=>{const b=this._findPointerById(g.pointerId);if(!(b&&b===this._lockedPointer)){if(b&&this._disposePointer(b),g.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=Ae.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=Ae.NONE;y()}};let c=-1;const f=g=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===Ae.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const T=this._domElement.getBoundingClientRect(),R=g.clientX/T.width,U=g.clientY/T.height;if(R<this._interactiveArea.left||R>this._interactiveArea.right||U<this._interactiveArea.top||U>this._interactiveArea.bottom)return}if(g.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===Ae.ROTATE||this.mouseButtons.wheel===Ae.TRUCK){const T=performance.now();c-T<1e3&&this._getClientRect(this._elementRect),c=T}const b=iW?-1:-3,S=g.deltaMode===1||g.ctrlKey?g.deltaY/b:g.deltaY/(b*10),E=this.dollyToCursor?(g.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,w=this.dollyToCursor?(g.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case Ae.ROTATE:{this._rotateInternal(g.deltaX,g.deltaY),this._isUserControllingRotate=!0;break}case Ae.TRUCK:{this._truckInternal(g.deltaX,g.deltaY,!1,!1),this._isUserControllingTruck=!0;break}case Ae.SCREEN_PAN:{this._truckInternal(g.deltaX,g.deltaY,!1,!0),this._isUserControllingTruck=!0;break}case Ae.OFFSET:{this._truckInternal(g.deltaX,g.deltaY,!0,!1),this._isUserControllingOffset=!0;break}case Ae.DOLLY:{this._dollyInternal(-S,E,w),this._isUserControllingDolly=!0;break}case Ae.ZOOM:{this._zoomInternal(-S,E,w),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},d=g=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===Ox.ACTION.NONE){const b=g instanceof PointerEvent?g.pointerId:0,S=this._findPointerById(b);S&&this._disposePointer(S),this._domElement.ownerDocument.removeEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l);return}g.preventDefault()}},p=g=>{if(!this._enabled)return;if(R_(this._activePointers,Ji),this._getClientRect(this._elementRect),n.copy(Ji),r.copy(Ji),this._activePointers.length>=2){const S=Ji.x-this._activePointers[1].clientX,E=Ji.y-this._activePointers[1].clientY,w=Math.sqrt(S*S+E*E);s.set(0,w);const T=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,R=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;r.set(T,R)}if(this._state=0,!g)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in g&&g.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&&(g.buttons&Sn.LEFT)===Sn.LEFT&&(this._state=this._state|this.mouseButtons.left),(g.buttons&Sn.MIDDLE)===Sn.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(g.buttons&Sn.RIGHT)===Sn.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&Ae.ROTATE)===Ae.ROTATE||(this._state&Ae.TOUCH_ROTATE)===Ae.TOUCH_ROTATE||(this._state&Ae.TOUCH_DOLLY_ROTATE)===Ae.TOUCH_DOLLY_ROTATE||(this._state&Ae.TOUCH_ZOOM_ROTATE)===Ae.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&Ae.TRUCK)===Ae.TRUCK||(this._state&Ae.SCREEN_PAN)===Ae.SCREEN_PAN||(this._state&Ae.TOUCH_TRUCK)===Ae.TOUCH_TRUCK||(this._state&Ae.TOUCH_SCREEN_PAN)===Ae.TOUCH_SCREEN_PAN||(this._state&Ae.TOUCH_DOLLY_TRUCK)===Ae.TOUCH_DOLLY_TRUCK||(this._state&Ae.TOUCH_DOLLY_SCREEN_PAN)===Ae.TOUCH_DOLLY_SCREEN_PAN||(this._state&Ae.TOUCH_ZOOM_TRUCK)===Ae.TOUCH_ZOOM_TRUCK||(this._state&Ae.TOUCH_ZOOM_SCREEN_PAN)===Ae.TOUCH_DOLLY_SCREEN_PAN)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&Ae.DOLLY)===Ae.DOLLY||(this._state&Ae.TOUCH_DOLLY)===Ae.TOUCH_DOLLY||(this._state&Ae.TOUCH_DOLLY_TRUCK)===Ae.TOUCH_DOLLY_TRUCK||(this._state&Ae.TOUCH_DOLLY_SCREEN_PAN)===Ae.TOUCH_DOLLY_SCREEN_PAN||(this._state&Ae.TOUCH_DOLLY_OFFSET)===Ae.TOUCH_DOLLY_OFFSET||(this._state&Ae.TOUCH_DOLLY_ROTATE)===Ae.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&Ae.ZOOM)===Ae.ZOOM||(this._state&Ae.TOUCH_ZOOM)===Ae.TOUCH_ZOOM||(this._state&Ae.TOUCH_ZOOM_TRUCK)===Ae.TOUCH_ZOOM_TRUCK||(this._state&Ae.TOUCH_ZOOM_SCREEN_PAN)===Ae.TOUCH_ZOOM_SCREEN_PAN||(this._state&Ae.TOUCH_ZOOM_OFFSET)===Ae.TOUCH_ZOOM_OFFSET||(this._state&Ae.TOUCH_ZOOM_ROTATE)===Ae.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&Ae.OFFSET)===Ae.OFFSET||(this._state&Ae.TOUCH_OFFSET)===Ae.TOUCH_OFFSET||(this._state&Ae.TOUCH_DOLLY_OFFSET)===Ae.TOUCH_DOLLY_OFFSET||(this._state&Ae.TOUCH_ZOOM_OFFSET)===Ae.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},m=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,R_(this._activePointers,Ji);const b=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,S=b?-b.deltaX:r.x-Ji.x,E=b?-b.deltaY:r.y-Ji.y;if(r.copy(Ji),((this._state&Ae.ROTATE)===Ae.ROTATE||(this._state&Ae.TOUCH_ROTATE)===Ae.TOUCH_ROTATE||(this._state&Ae.TOUCH_DOLLY_ROTATE)===Ae.TOUCH_DOLLY_ROTATE||(this._state&Ae.TOUCH_ZOOM_ROTATE)===Ae.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(S,E),this._isUserControllingRotate=!0),(this._state&Ae.DOLLY)===Ae.DOLLY||(this._state&Ae.ZOOM)===Ae.ZOOM){const w=this.dollyToCursor?(n.x-this._elementRect.x)/this._elementRect.width*2-1:0,T=this.dollyToCursor?(n.y-this._elementRect.y)/this._elementRect.height*-2+1:0,R=this.dollyDragInverted?-1:1;(this._state&Ae.DOLLY)===Ae.DOLLY?(this._dollyInternal(R*E*Zp,w,T),this._isUserControllingDolly=!0):(this._zoomInternal(R*E*Zp,w,T),this._isUserControllingZoom=!0)}if((this._state&Ae.TOUCH_DOLLY)===Ae.TOUCH_DOLLY||(this._state&Ae.TOUCH_ZOOM)===Ae.TOUCH_ZOOM||(this._state&Ae.TOUCH_DOLLY_TRUCK)===Ae.TOUCH_DOLLY_TRUCK||(this._state&Ae.TOUCH_ZOOM_TRUCK)===Ae.TOUCH_ZOOM_TRUCK||(this._state&Ae.TOUCH_DOLLY_SCREEN_PAN)===Ae.TOUCH_DOLLY_SCREEN_PAN||(this._state&Ae.TOUCH_ZOOM_SCREEN_PAN)===Ae.TOUCH_ZOOM_SCREEN_PAN||(this._state&Ae.TOUCH_DOLLY_OFFSET)===Ae.TOUCH_DOLLY_OFFSET||(this._state&Ae.TOUCH_ZOOM_OFFSET)===Ae.TOUCH_ZOOM_OFFSET||(this._state&Ae.TOUCH_DOLLY_ROTATE)===Ae.TOUCH_DOLLY_ROTATE||(this._state&Ae.TOUCH_ZOOM_ROTATE)===Ae.TOUCH_ZOOM_ROTATE){const w=Ji.x-this._activePointers[1].clientX,T=Ji.y-this._activePointers[1].clientY,R=Math.sqrt(w*w+T*T),U=s.y-R;s.set(0,R);const D=this.dollyToCursor?(r.x-this._elementRect.x)/this._elementRect.width*2-1:0,C=this.dollyToCursor?(r.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&Ae.TOUCH_DOLLY)===Ae.TOUCH_DOLLY||(this._state&Ae.TOUCH_DOLLY_ROTATE)===Ae.TOUCH_DOLLY_ROTATE||(this._state&Ae.TOUCH_DOLLY_TRUCK)===Ae.TOUCH_DOLLY_TRUCK||(this._state&Ae.TOUCH_DOLLY_SCREEN_PAN)===Ae.TOUCH_DOLLY_SCREEN_PAN||(this._state&Ae.TOUCH_DOLLY_OFFSET)===Ae.TOUCH_DOLLY_OFFSET?(this._dollyInternal(U*Zp,D,C),this._isUserControllingDolly=!0):(this._zoomInternal(U*Zp,D,C),this._isUserControllingZoom=!0)}((this._state&Ae.TRUCK)===Ae.TRUCK||(this._state&Ae.TOUCH_TRUCK)===Ae.TOUCH_TRUCK||(this._state&Ae.TOUCH_DOLLY_TRUCK)===Ae.TOUCH_DOLLY_TRUCK||(this._state&Ae.TOUCH_ZOOM_TRUCK)===Ae.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(S,E,!1,!1),this._isUserControllingTruck=!0),((this._state&Ae.SCREEN_PAN)===Ae.SCREEN_PAN||(this._state&Ae.TOUCH_SCREEN_PAN)===Ae.TOUCH_SCREEN_PAN||(this._state&Ae.TOUCH_DOLLY_SCREEN_PAN)===Ae.TOUCH_DOLLY_SCREEN_PAN||(this._state&Ae.TOUCH_ZOOM_SCREEN_PAN)===Ae.TOUCH_ZOOM_SCREEN_PAN)&&(this._truckInternal(S,E,!1,!0),this._isUserControllingTruck=!0),((this._state&Ae.OFFSET)===Ae.OFFSET||(this._state&Ae.TOUCH_OFFSET)===Ae.TOUCH_OFFSET||(this._state&Ae.TOUCH_DOLLY_OFFSET)===Ae.TOUCH_DOLLY_OFFSET||(this._state&Ae.TOUCH_ZOOM_OFFSET)===Ae.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(S,E,!0,!1),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},y=()=>{R_(this._activePointers,Ji),r.copy(Ji),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",o,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),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",o,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",x),this._domElement.ownerDocument.addEventListener("pointerlockerror",_),this._domElement.ownerDocument.addEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",l),p())},this.unlockPointer=()=>{var g,b,S;this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),(g=this._domElement)===null||g===void 0||g.ownerDocument.exitPointerLock(),(b=this._domElement)===null||b===void 0||b.ownerDocument.removeEventListener("pointerlockchange",x),(S=this._domElement)===null||S===void 0||S.ownerDocument.removeEventListener("pointerlockerror",_),this.cancel()};const x=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},_=()=>{this.unlockPointer()};this._addAllEventListeners=g=>{this._domElement=g,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",a),this._domElement.addEventListener("pointercancel",l),this._domElement.addEventListener("wheel",f,{passive:!1}),this._domElement.addEventListener("contextmenu",d)},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",l),this._domElement.removeEventListener("wheel",f,{passive:!1}),this._domElement.removeEventListener("contextmenu",d),this._domElement.ownerDocument.removeEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this._domElement.ownerDocument.removeEventListener("pointerlockchange",x),this._domElement.ownerDocument.removeEventListener("pointerlockerror",_))},this.cancel=()=>{this._state!==Ae.NONE&&(this._state=Ae.NONE,this._activePointers.length=0,y())},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=es(e.width,0,1),this._interactiveArea.height=es(e.height,0,1),this._interactiveArea.x=es(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=es(e.y,0,1-this._interactiveArea.height)}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}rotate(e,t,n=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+t,n)}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,n=!1){this._isUserControllingRotate=!1;const r=es(e,this.minAzimuthAngle,this.maxAzimuthAngle),s=es(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=r,this._sphericalEnd.phi=s,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,n||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const a=!n||Qt(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Qt(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=Vc.NONE,this._changedDolly=0,this._dollyToNoClamp(es(e,this.minDistance,this.maxDistance),t)}_dollyToNoClamp(e,t=!1){const n=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const a=this._collisionTest(),o=Qt(a,this._spherical.radius);if(!(n>e)&&o)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 s=!t||Qt(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(s)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(kh).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const n=!t||Qt(this._target.x,this._targetEnd.x,this.restThreshold)&&Qt(this._target.y,this._targetEnd.y,this.restThreshold)&&Qt(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(n)}zoom(e,t=!1){return this.zoomTo(this._zoomEnd+e,t)}zoomTo(e,t=!1){this._isUserControllingZoom=!1,this._zoomEnd=es(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const n=!t||Qt(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(n)}pan(e,t,n=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,t,n)}truck(e,t,n=!1){this._camera.updateMatrix(),xs.setFromMatrixColumn(this._camera.matrix,0),bs.setFromMatrixColumn(this._camera.matrix,1),xs.multiplyScalar(e),bs.multiplyScalar(-t);const r=Lt.copy(xs).add(bs),s=Zt.copy(this._targetEnd).add(r);return this.moveTo(s.x,s.y,s.z,n)}forward(e,t=!1){Lt.setFromMatrixColumn(this._camera.matrix,0),Lt.crossVectors(this._camera.up,Lt),Lt.multiplyScalar(e);const n=Zt.copy(this._targetEnd).add(Lt);return this.moveTo(n.x,n.y,n.z,t)}elevate(e,t=!1){return Lt.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+Lt.x,this._targetEnd.y+Lt.y,this._targetEnd.z+Lt.z,t)}moveTo(e,t,n,r=!1){this._isUserControllingTruck=!1;const s=Lt.set(e,t,n).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,s,this.boundaryFriction),this._needsUpdate=!0,r||this._target.copy(this._targetEnd);const a=!r||Qt(this._target.x,this._targetEnd.x,this.restThreshold)&&Qt(this._target.y,this._targetEnd.y,this.restThreshold)&&Qt(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(a)}lookInDirectionOf(e,t,n,r=!1){const o=Lt.set(e,t,n).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);return this.setPosition(o.x,o.y,o.z,r)}fitToBox(e,t,{cover:n=!1,paddingLeft:r=0,paddingRight:s=0,paddingBottom:a=0,paddingTop:o=0}={}){const l=[],c=e.isBox3?jc.copy(e):jc.setFromObject(e);c.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const f=eA(this._sphericalEnd.theta,$T),d=eA(this._sphericalEnd.phi,$T);l.push(this.rotateTo(f,d,t));const p=Lt.setFromSpherical(this._sphericalEnd).normalize(),m=aA.setFromUnitVectors(p,O_),y=Qt(Math.abs(p.y),1);y&&m.multiply(N_.setFromAxisAngle(Kp,f)),m.multiply(this._yAxisUpSpaceInverse);const x=sA.makeEmpty();Zt.copy(c.min).applyQuaternion(m),x.expandByPoint(Zt),Zt.copy(c.min).setX(c.max.x).applyQuaternion(m),x.expandByPoint(Zt),Zt.copy(c.min).setY(c.max.y).applyQuaternion(m),x.expandByPoint(Zt),Zt.copy(c.max).setZ(c.min.z).applyQuaternion(m),x.expandByPoint(Zt),Zt.copy(c.min).setZ(c.max.z).applyQuaternion(m),x.expandByPoint(Zt),Zt.copy(c.max).setY(c.min.y).applyQuaternion(m),x.expandByPoint(Zt),Zt.copy(c.max).setX(c.min.x).applyQuaternion(m),x.expandByPoint(Zt),Zt.copy(c.max).applyQuaternion(m),x.expandByPoint(Zt),x.min.x-=r,x.min.y-=a,x.max.x+=s,x.max.y+=o,m.setFromUnitVectors(O_,p),y&&m.premultiply(N_.invert()),m.premultiply(this._yAxisUpSpace);const _=x.getSize(Lt),g=x.getCenter(Zt).applyQuaternion(m);if(ll(this._camera)){const b=this.getDistanceToFitBox(_.x,_.y,_.z,n);l.push(this.moveTo(g.x,g.y,g.z,t)),l.push(this.dollyTo(b,t)),l.push(this.setFocalOffset(0,0,0,t))}else if(io(this._camera)){const b=this._camera,S=b.right-b.left,E=b.top-b.bottom,w=n?Math.max(S/_.x,E/_.y):Math.min(S/_.x,E/_.y);l.push(this.moveTo(g.x,g.y,g.z,t)),l.push(this.zoomTo(w,t)),l.push(this.setFocalOffset(0,0,0,t))}return Promise.all(l)}fitToSphere(e,t){const n=[],s="isObject3D"in e?Ox.createBoundingSphere(e,L_):L_.copy(e);if(n.push(this.moveTo(s.center.x,s.center.y,s.center.z,t)),ll(this._camera)){const a=this.getDistanceToFitSphere(s.radius);n.push(this.dollyTo(a,t))}else if(io(this._camera)){const a=this._camera.right-this._camera.left,o=this._camera.top-this._camera.bottom,l=2*s.radius,c=Math.min(a/l,o/l);n.push(this.zoomTo(c,t))}return n.push(this.setFocalOffset(0,0,0,t)),Promise.all(n)}setLookAt(e,t,n,r,s,a,o=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Vc.NONE,this._changedDolly=0;const l=Zt.set(r,s,a),c=Lt.set(e,t,n);this._targetEnd.copy(l),this._sphericalEnd.setFromVector3(c.sub(l).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,o||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const f=!o||Qt(this._target.x,this._targetEnd.x,this.restThreshold)&&Qt(this._target.y,this._targetEnd.y,this.restThreshold)&&Qt(this._target.z,this._targetEnd.z,this.restThreshold)&&Qt(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Qt(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Qt(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(f)}lerpLookAt(e,t,n,r,s,a,o,l,c,f,d,p,m,y=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Vc.NONE,this._changedDolly=0;const x=Lt.set(r,s,a),_=Zt.set(e,t,n);Or.setFromVector3(_.sub(x).applyQuaternion(this._yAxisUpSpace));const g=Xc.set(f,d,p),b=Zt.set(o,l,c);Gh.setFromVector3(b.sub(g).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(x.lerp(g,m));const S=Gh.theta-Or.theta,E=Gh.phi-Or.phi,w=Gh.radius-Or.radius;this._sphericalEnd.set(Or.radius+w*m,Or.phi+E*m,Or.theta+S*m),this.normalizeRotations(),this._needsUpdate=!0,y||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const T=!y||Qt(this._target.x,this._targetEnd.x,this.restThreshold)&&Qt(this._target.y,this._targetEnd.y,this.restThreshold)&&Qt(this._target.z,this._targetEnd.z,this.restThreshold)&&Qt(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Qt(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Qt(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(T)}setPosition(e,t,n,r=!1){return this.setLookAt(e,t,n,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,r)}setTarget(e,t,n,r=!1){const s=this.getPosition(Lt),a=this.setLookAt(s.x,s.y,s.z,e,t,n,r);return this._sphericalEnd.phi=es(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),a}setFocalOffset(e,t,n,r=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,t,n),this._needsUpdate=!0,r||this._focalOffset.copy(this._focalOffsetEnd);const s=!r||Qt(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&Qt(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&Qt(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(s)}setOrbitPoint(e,t,n){this._camera.updateMatrixWorld(),xs.setFromMatrixColumn(this._camera.matrixWorldInverse,0),bs.setFromMatrixColumn(this._camera.matrixWorldInverse,1),cl.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const r=Lt.set(e,t,n),s=r.distanceTo(this._camera.position),a=r.sub(this._camera.position);xs.multiplyScalar(a.x),bs.multiplyScalar(a.y),cl.multiplyScalar(a.z),Lt.copy(xs).add(bs).add(cl),Lt.z=Lt.z+s,this.dollyTo(s,!1),this.setFocalOffset(-Lt.x,Lt.y,-Lt.z,!1),this.moveTo(e,t,n,!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,n,r){if(e===null){this._viewport=null;return}this._viewport=this._viewport||new Et.Vector4,typeof e=="number"?this._viewport.set(e,t,n,r):this._viewport.copy(e)}getDistanceToFitBox(e,t,n,r=!1){if(D_(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const s=e/t,a=this._camera.getEffectiveFOV()*zh,o=this._camera.aspect;return((r?s>o:s<o)?t:e/o)*.5/Math.tan(a*.5)+n*.5}getDistanceToFitSphere(e){if(D_(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*zh,n=Math.atan(Math.tan(t*.5)*this._camera.aspect)*2,r=1<this._camera.aspect?t:n;return e/Math.sin(r*.5)}getTarget(e,t=!0){return(e&&e.isVector3?e:new Et.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new Et.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e||new Et.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new Et.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%Wc,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=Wc),this._spherical.theta+=Wc*Math.round((this._sphericalEnd.theta-this._spherical.theta)/Wc)}stop(){this._focalOffset.copy(this._focalOffsetEnd),this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd),this._zoom=this._zoomEnd}reset(e=!1){if(!Qt(this._camera.up.x,this._cameraUp0.x)||!Qt(this._camera.up.y,this._cameraUp0.y)||!Qt(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const n=this.getPosition(Lt);this.updateCameraUp(),this.setPosition(n.x,n.y,n.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,Kp),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const e=Lt.subVectors(this._target,this._camera.position).normalize(),t=Zt.crossVectors(e,this._camera.up);this._camera.up.crossVectors(t,e).normalize(),this._camera.updateMatrixWorld();const n=this.getPosition(Lt);this.updateCameraUp(),this.setPosition(n.x,n.y,n.z)}update(e){const t=this._sphericalEnd.theta-this._spherical.theta,n=this._sphericalEnd.phi-this._spherical.phi,r=this._sphericalEnd.radius-this._spherical.radius,s=iA.subVectors(this._targetEnd,this._target),a=rA.subVectors(this._focalOffsetEnd,this._focalOffset),o=this._zoomEnd-this._zoom;if(dn(t))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const d=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=Yp(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,d,1/0,e),this._needsUpdate=!0}if(dn(n))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const d=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=Yp(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,d,1/0,e),this._needsUpdate=!0}if(dn(r))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const d=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=Yp(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,d,this.maxSpeed,e),this._needsUpdate=!0}if(dn(s.x)&&dn(s.y)&&dn(s.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const d=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;tA(this._target,this._targetEnd,this._targetVelocity,d,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(dn(a.x)&&dn(a.y)&&dn(a.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const d=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;tA(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,d,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(dn(o))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const d=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=Yp(this._zoom,this._zoomEnd,this._zoomVelocity,d,1/0,e)}if(this.dollyToCursor){if(ll(this._camera)&&this._changedDolly!==0){const d=this._spherical.radius-this._lastDistance,p=this._camera,m=this._getCameraDirection(kh),y=Lt.copy(m).cross(p.up).normalize();y.lengthSq()===0&&(y.x=1);const x=Zt.crossVectors(y,m),_=this._sphericalEnd.radius*Math.tan(p.getEffectiveFOV()*zh*.5),b=(this._sphericalEnd.radius-d-this._sphericalEnd.radius)/this._sphericalEnd.radius,S=Xc.copy(this._targetEnd).add(y.multiplyScalar(this._dollyControlCoord.x*_*p.aspect)).add(x.multiplyScalar(this._dollyControlCoord.y*_)),E=Lt.copy(this._targetEnd).lerp(S,b),w=this._lastDollyDirection===Vc.IN&&this._spherical.radius<=this.minDistance,T=this._lastDollyDirection===Vc.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(w||T)){this._sphericalEnd.radius-=d,this._spherical.radius-=d;const U=Zt.copy(m).multiplyScalar(-d);E.add(U)}this._boundary.clampPoint(E,E);const R=Zt.subVectors(E,this._targetEnd);this._targetEnd.copy(E),this._target.add(R),this._changedDolly-=d,dn(this._changedDolly)&&(this._changedDolly=0)}else if(io(this._camera)&&this._changedZoom!==0){const d=this._zoom-this._lastZoom,p=this._camera,m=Lt.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(p.near+p.far)/(p.near-p.far)).unproject(p),y=Zt.set(0,0,-1).applyQuaternion(p.quaternion),x=Xc.copy(m).add(y.multiplyScalar(-m.dot(p.up))),g=-(this._zoom-d-this._zoom)/this._zoom,b=this._getCameraDirection(kh),S=this._targetEnd.dot(b),E=Lt.copy(this._targetEnd).lerp(x,g),w=E.dot(b),T=b.multiplyScalar(w-S);E.sub(T),this._boundary.clampPoint(E,E);const R=Zt.subVectors(E,this._targetEnd);this._targetEnd.copy(E),this._target.add(R),this._changedZoom-=d,dn(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 l=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,l),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!dn(this._focalOffset.x)||!dn(this._focalOffset.y)||!dn(this._focalOffset.z))&&(xs.setFromMatrixColumn(this._camera.matrix,0),bs.setFromMatrixColumn(this._camera.matrix,1),cl.setFromMatrixColumn(this._camera.matrix,2),xs.multiplyScalar(this._focalOffset.x),bs.multiplyScalar(-this._focalOffset.y),cl.multiplyScalar(this._focalOffset.z),Lt.copy(xs).add(bs).add(cl),this._camera.position.add(Lt),this._camera.updateMatrixWorld()),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),Lt.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const f=this._needsUpdate;return f&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):f?(this.dispatchEvent({type:"update"}),dn(t,this.restThreshold)&&dn(n,this.restThreshold)&&dn(r,this.restThreshold)&&dn(s.x,this.restThreshold)&&dn(s.y,this.restThreshold)&&dn(s.z,this.restThreshold)&&dn(a.x,this.restThreshold)&&dn(a.y,this.restThreshold)&&dn(a.z,this.restThreshold)&&dn(o,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!f&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=f,this._needsUpdate=!1,f}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:Fh(this.maxDistance),minZoom:this.minZoom,maxZoom:Fh(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:Fh(this.maxPolarAngle),minAzimuthAngle:Fh(this.minAzimuthAngle),maxAzimuthAngle:Fh(this.maxAzimuthAngle),smoothTime:this.smoothTime,draggingSmoothTime:this.draggingSmoothTime,dollySpeed:this.dollySpeed,truckSpeed:this.truckSpeed,dollyToCursor:this.dollyToCursor,target:this._targetEnd.toArray(),position:Lt.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 n=JSON.parse(e);this.enabled=n.enabled,this.minDistance=n.minDistance,this.maxDistance=Bh(n.maxDistance),this.minZoom=n.minZoom,this.maxZoom=Bh(n.maxZoom),this.minPolarAngle=n.minPolarAngle,this.maxPolarAngle=Bh(n.maxPolarAngle),this.minAzimuthAngle=Bh(n.minAzimuthAngle),this.maxAzimuthAngle=Bh(n.maxAzimuthAngle),this.smoothTime=n.smoothTime,this.draggingSmoothTime=n.draggingSmoothTime,this.dollySpeed=n.dollySpeed,this.truckSpeed=n.truckSpeed,this.dollyToCursor=n.dollyToCursor,this._target0.fromArray(n.target0),this._position0.fromArray(n.position0),this._zoom0=n.zoom0,this._focalOffset0.fromArray(n.focalOffset0),this.moveTo(n.target[0],n.target[1],n.target[2],t),Or.setFromVector3(Lt.fromArray(n.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(Or.theta,Or.phi,t),this.dollyTo(Or.radius,t),this.zoomTo(n.zoom,t),this.setFocalOffset(n.focalOffset[0],n.focalOffset[1],n.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",nW),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,n){const r=t.lengthSq();if(r===0)return e;const s=Zt.copy(t).add(e),o=this._boundary.clampPoint(s,Xc).sub(s),l=o.lengthSq();if(l===0)return e.add(t);if(l===r)return e;if(n===0)return e.add(t).add(o);{const c=1+n*l/t.dot(o);return e.add(Zt.copy(t).multiplyScalar(c)).add(o.multiplyScalar(1-n))}}_updateNearPlaneCorners(){if(ll(this._camera)){const e=this._camera,t=e.near,n=e.getEffectiveFOV()*zh,r=Math.tan(n*.5)*t,s=r*e.aspect;this._nearPlaneCorners[0].set(-s,-r,0),this._nearPlaneCorners[1].set(s,-r,0),this._nearPlaneCorners[2].set(s,r,0),this._nearPlaneCorners[3].set(-s,r,0)}else if(io(this._camera)){const e=this._camera,t=1/e.zoom,n=e.left*t,r=e.right*t,s=e.top*t,a=e.bottom*t;this._nearPlaneCorners[0].set(n,s,0),this._nearPlaneCorners[1].set(r,s,0),this._nearPlaneCorners[2].set(r,a,0),this._nearPlaneCorners[3].set(n,a,0)}}_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||D_(this._camera,"_collisionTest"))return e;const n=this._getTargetDirection(kh);I_.lookAt(nA,n,this._camera.up);for(let r=0;r<4;r++){const s=Zt.copy(this._nearPlaneCorners[r]);s.applyMatrix4(I_);const a=Xc.addVectors(this._target,s);Jp.set(a,n),Jp.far=this._spherical.radius+1;const o=Jp.intersectObjects(this.colliderMeshes);o.length!==0&&o[0].distance<e&&(e=o[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 n=()=>{this.removeEventListener("rest",n),t()};this.addEventListener("rest",n)}))}_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 Et.Sphere){const n=t,r=n.center;jc.makeEmpty(),e.traverseVisible(a=>{a.isMesh&&jc.expandByObject(a)}),jc.getCenter(r);let s=0;return e.traverseVisible(a=>{if(!a.isMesh)return;const o=a;if(!o.geometry)return;const l=o.geometry.clone();l.applyMatrix4(o.matrixWorld);const f=l.attributes.position;for(let d=0,p=f.count;d<p;d++)Lt.fromBufferAttribute(f,d),s=Math.max(s,r.distanceToSquared(Lt))}),n.radius=Math.sqrt(s),n}};var Hh={exports:{}},oA;function rW(){if(oA)return Hh.exports;oA=1;var i={ellipse:"…",chars:[" ","-"],max:140,truncate:!0};function e(n,r,s,a){if(n<=r)return n;if(r<2)return n.slice(0,r-s.length)+s;for(var o=r-s.length,l=Math.floor(o/2),c=l,f=n.length-l,d=0;d<l;d++){var p=n.charAt(d),m=n.length-d,y=n.charAt(m);a.indexOf(p)!==-1&&(c=d),a.indexOf(y)!==-1&&(f=m)}return n.slice(0,c)+s+n.slice(f)}function t(n,r,s,a,o){if(n.length<=r)return n;for(var l=r-s.length,c=l,f=0;f<=l;f++){var d=n.charAt(f);a.indexOf(d)!==-1&&(c=f)}return!o&&c==l?"":n.slice(0,c)+s}return Hh.exports=function(n,r,s){if(typeof n!="string"||n.length===0||r===0)return"";s=s||{};for(var a in i)(s[a]===null||typeof s[a]>"u")&&(s[a]=i[a]);return s.max=r||s.max,s.truncate=="middle"?e(n,s.max,s.ellipse,s.chars):t(n,s.max,s.ellipse,s.chars,s.truncate)},Hh.exports.ellipsizeMiddle=e,Hh.exports.ellipsize=t,Hh.exports}var sW=rW();const aW=po(sW);/*!
|
|
4144
|
+
*/const Sn={LEFT:1,RIGHT:2,MIDDLE:4},Ae=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,SCREEN_PAN:4,OFFSET:8,DOLLY:16,ZOOM:32,TOUCH_ROTATE:64,TOUCH_TRUCK:128,TOUCH_SCREEN_PAN:256,TOUCH_OFFSET:512,TOUCH_DOLLY:1024,TOUCH_ZOOM:2048,TOUCH_DOLLY_TRUCK:4096,TOUCH_DOLLY_SCREEN_PAN:8192,TOUCH_DOLLY_OFFSET:16384,TOUCH_DOLLY_ROTATE:32768,TOUCH_ZOOM_TRUCK:65536,TOUCH_ZOOM_OFFSET:131072,TOUCH_ZOOM_SCREEN_PAN:262144,TOUCH_ZOOM_ROTATE:524288}),Vc={NONE:0,IN:1,OUT:-1};function ll(i){return i.isPerspectiveCamera}function io(i){return i.isOrthographicCamera}const Wc=Math.PI*2,eA=Math.PI/2,D3=1e-5,Fh=Math.PI/180;function es(i,e,t){return Math.max(e,Math.min(t,i))}function dn(i,e=D3){return Math.abs(i)<e}function Qt(i,e,t=D3){return dn(i-e,t)}function tA(i,e){return Math.round(i/e)*e}function Bh(i){return isFinite(i)?i:i<0?-Number.MAX_VALUE:Number.MAX_VALUE}function kh(i){return Math.abs(i)<Number.MAX_VALUE?i:i*(1/0)}function Yp(i,e,t,n,r=1/0,s){n=Math.max(1e-4,n);const a=2/n,o=a*s,l=1/(1+o+.48*o*o+.235*o*o*o);let c=i-e;const f=e,d=r*n;c=es(c,-d,d),e=i-c;const p=(t.value+a*c)*s;t.value=(t.value-a*p)*l;let m=e+(c+p)*l;return f-i>0==m>f&&(m=f,t.value=(m-f)/s),m}function nA(i,e,t,n,r=1/0,s,a){n=Math.max(1e-4,n);const o=2/n,l=o*s,c=1/(1+l+.48*l*l+.235*l*l*l);let f=e.x,d=e.y,p=e.z,m=i.x-f,y=i.y-d,x=i.z-p;const _=f,g=d,b=p,S=r*n,E=S*S,w=m*m+y*y+x*x;if(w>E){const Z=Math.sqrt(w);m=m/Z*S,y=y/Z*S,x=x/Z*S}f=i.x-m,d=i.y-y,p=i.z-x;const T=(t.x+o*m)*s,R=(t.y+o*y)*s,U=(t.z+o*x)*s;t.x=(t.x-o*T)*c,t.y=(t.y-o*R)*c,t.z=(t.z-o*U)*c,a.x=f+(m+T)*c,a.y=d+(y+R)*c,a.z=p+(x+U)*c;const D=_-i.x,C=g-i.y,P=b-i.z,I=a.x-_,O=a.y-g,G=a.z-b;return D*I+C*O+P*G>0&&(a.x=_,a.y=g,a.z=b,t.x=(a.x-_)/s,t.y=(a.y-g)/s,t.z=(a.z-b)/s),a}function R_(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 D_(i,e){return io(i)?(console.warn(`${e} is not supported in OrthographicCamera`),!0):!1}let rW=class{constructor(){this._listeners={}}addEventListener(e,t){const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const r=this._listeners[e];if(r!==void 0){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}}removeAllEventListeners(e){if(!e){this._listeners={};return}Array.isArray(this._listeners[e])&&(this._listeners[e].length=0)}dispatchEvent(e){const n=this._listeners[e.type];if(n!==void 0){e.target=this;const r=n.slice(0);for(let s=0,a=r.length;s<a;s++)r[s].call(this,e)}}};var U_;const sW="2.10.1",Zp=1/8,aW=/Mac/.test((U_=globalThis?.navigator)===null||U_===void 0?void 0:U_.platform);let Et,iA,Kp,O_,Ji,Lt,Zt,Xc,Gh,xs,bs,cl,rA,sA,Or,Hh,jc,aA,L_,oA,N_,I_,Jp,di=class Ox extends rW{static install(e){Et=e.THREE,iA=Object.freeze(new Et.Vector3(0,0,0)),Kp=Object.freeze(new Et.Vector3(0,1,0)),O_=Object.freeze(new Et.Vector3(0,0,1)),Ji=new Et.Vector2,Lt=new Et.Vector3,Zt=new Et.Vector3,Xc=new Et.Vector3,Gh=new Et.Vector3,xs=new Et.Vector3,bs=new Et.Vector3,cl=new Et.Vector3,rA=new Et.Vector3,sA=new Et.Vector3,Or=new Et.Spherical,Hh=new Et.Spherical,jc=new Et.Box3,aA=new Et.Box3,L_=new Et.Sphere,oA=new Et.Quaternion,N_=new Et.Quaternion,I_=new Et.Matrix4,Jp=new Et.Raycaster}static get ACTION(){return Ae}set verticalDragToForward(e){console.warn("camera-controls: `verticalDragToForward` was removed. Use `mouseButtons.left = CameraControls.ACTION.SCREEN_PAN` instead.")}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.boundaryFriction=0,this.restThreshold=.01,this.colliderMeshes=[],this.cancel=()=>{},this._enabled=!0,this._state=Ae.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=Vc.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new Et.Vector3,this._focalOffsetVelocity=new Et.Vector3,this._zoomVelocity={value:0},this._truckInternal=(g,b,S,E)=>{let w,T;if(ll(this._camera)){const R=Lt.copy(this._camera.position).sub(this._target),U=this._camera.getEffectiveFOV()*Fh,D=R.length()*Math.tan(U*.5);w=this.truckSpeed*g*D/this._elementRect.height,T=this.truckSpeed*b*D/this._elementRect.height}else if(io(this._camera)){const R=this._camera;w=this.truckSpeed*g*(R.right-R.left)/R.zoom/this._elementRect.width,T=this.truckSpeed*b*(R.top-R.bottom)/R.zoom/this._elementRect.height}else return;E?(S?this.setFocalOffset(this._focalOffsetEnd.x+w,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(w,0,!0),this.forward(-T,!0)):S?this.setFocalOffset(this._focalOffsetEnd.x+w,this._focalOffsetEnd.y+T,this._focalOffsetEnd.z,!0):this.truck(w,T,!0)},this._rotateInternal=(g,b)=>{const S=Wc*this.azimuthRotateSpeed*g/this._elementRect.height,E=Wc*this.polarRotateSpeed*b/this._elementRect.height;this.rotate(S,E,!0)},this._dollyInternal=(g,b,S)=>{const E=Math.pow(.95,-g*this.dollySpeed),w=this._sphericalEnd.radius,T=this._sphericalEnd.radius*E,R=es(T,this.minDistance,this.maxDistance),U=R-T;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(T,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(U,!0),this._dollyToNoClamp(R,!0)):this._dollyToNoClamp(R,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?T:R)-w,this._dollyControlCoord.set(b,S)),this._lastDollyDirection=Math.sign(-g)},this._zoomInternal=(g,b,S)=>{const E=Math.pow(.95,g*this.dollySpeed),w=this._zoom,T=this._zoom*E;this.zoomTo(T,!0),this.dollyToCursor&&(this._changedZoom+=T-w,this._dollyControlCoord.set(b,S))},typeof Et>"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 Et.Quaternion().setFromUnitVectors(this._camera.up,Kp),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=Ae.NONE,this._target=new Et.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new Et.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new Et.Spherical().setFromVector3(Lt.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 Et.Vector3,new Et.Vector3,new Et.Vector3,new Et.Vector3],this._updateNearPlaneCorners(),this._boundary=new Et.Box3(new Et.Vector3(-1/0,-1/0,-1/0),new Et.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 Et.Vector2,this.mouseButtons={left:Ae.ROTATE,middle:Ae.DOLLY,right:Ae.TRUCK,wheel:ll(this._camera)?Ae.DOLLY:io(this._camera)?Ae.ZOOM:Ae.NONE},this.touches={one:Ae.TOUCH_ROTATE,two:ll(this._camera)?Ae.TOUCH_DOLLY_TRUCK:io(this._camera)?Ae.TOUCH_ZOOM_TRUCK:Ae.NONE,three:Ae.TOUCH_TRUCK};const n=new Et.Vector2,r=new Et.Vector2,s=new Et.Vector2,a=g=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const E=this._domElement.getBoundingClientRect(),w=g.clientX/E.width,T=g.clientY/E.height;if(w<this._interactiveArea.left||w>this._interactiveArea.right||T<this._interactiveArea.top||T>this._interactiveArea.bottom)return}const b=g.pointerType!=="mouse"?null:(g.buttons&Sn.LEFT)===Sn.LEFT?Sn.LEFT:(g.buttons&Sn.MIDDLE)===Sn.MIDDLE?Sn.MIDDLE:(g.buttons&Sn.RIGHT)===Sn.RIGHT?Sn.RIGHT:null;if(b!==null){const E=this._findPointerByMouseButton(b);E&&this._disposePointer(E)}if((g.buttons&Sn.LEFT)===Sn.LEFT&&this._lockedPointer)return;const S={pointerId:g.pointerId,clientX:g.clientX,clientY:g.clientY,deltaX:0,deltaY:0,mouseButton:b};this._activePointers.push(S),this._domElement.ownerDocument.removeEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this._domElement.ownerDocument.addEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",l),this._isDragging=!0,p(g)},o=g=>{g.cancelable&&g.preventDefault();const b=g.pointerId,S=this._lockedPointer||this._findPointerById(b);if(S){if(S.clientX=g.clientX,S.clientY=g.clientY,S.deltaX=g.movementX,S.deltaY=g.movementY,this._state=0,g.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&&(g.buttons&Sn.LEFT)===Sn.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(g.buttons&Sn.MIDDLE)===Sn.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(g.buttons&Sn.RIGHT)===Sn.RIGHT&&(this._state=this._state|this.mouseButtons.right);m()}},l=g=>{const b=this._findPointerById(g.pointerId);if(!(b&&b===this._lockedPointer)){if(b&&this._disposePointer(b),g.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=Ae.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=Ae.NONE;y()}};let c=-1;const f=g=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===Ae.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const T=this._domElement.getBoundingClientRect(),R=g.clientX/T.width,U=g.clientY/T.height;if(R<this._interactiveArea.left||R>this._interactiveArea.right||U<this._interactiveArea.top||U>this._interactiveArea.bottom)return}if(g.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===Ae.ROTATE||this.mouseButtons.wheel===Ae.TRUCK){const T=performance.now();c-T<1e3&&this._getClientRect(this._elementRect),c=T}const b=aW?-1:-3,S=g.deltaMode===1||g.ctrlKey?g.deltaY/b:g.deltaY/(b*10),E=this.dollyToCursor?(g.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,w=this.dollyToCursor?(g.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case Ae.ROTATE:{this._rotateInternal(g.deltaX,g.deltaY),this._isUserControllingRotate=!0;break}case Ae.TRUCK:{this._truckInternal(g.deltaX,g.deltaY,!1,!1),this._isUserControllingTruck=!0;break}case Ae.SCREEN_PAN:{this._truckInternal(g.deltaX,g.deltaY,!1,!0),this._isUserControllingTruck=!0;break}case Ae.OFFSET:{this._truckInternal(g.deltaX,g.deltaY,!0,!1),this._isUserControllingOffset=!0;break}case Ae.DOLLY:{this._dollyInternal(-S,E,w),this._isUserControllingDolly=!0;break}case Ae.ZOOM:{this._zoomInternal(-S,E,w),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},d=g=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===Ox.ACTION.NONE){const b=g instanceof PointerEvent?g.pointerId:0,S=this._findPointerById(b);S&&this._disposePointer(S),this._domElement.ownerDocument.removeEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l);return}g.preventDefault()}},p=g=>{if(!this._enabled)return;if(R_(this._activePointers,Ji),this._getClientRect(this._elementRect),n.copy(Ji),r.copy(Ji),this._activePointers.length>=2){const S=Ji.x-this._activePointers[1].clientX,E=Ji.y-this._activePointers[1].clientY,w=Math.sqrt(S*S+E*E);s.set(0,w);const T=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,R=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;r.set(T,R)}if(this._state=0,!g)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in g&&g.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&&(g.buttons&Sn.LEFT)===Sn.LEFT&&(this._state=this._state|this.mouseButtons.left),(g.buttons&Sn.MIDDLE)===Sn.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(g.buttons&Sn.RIGHT)===Sn.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&Ae.ROTATE)===Ae.ROTATE||(this._state&Ae.TOUCH_ROTATE)===Ae.TOUCH_ROTATE||(this._state&Ae.TOUCH_DOLLY_ROTATE)===Ae.TOUCH_DOLLY_ROTATE||(this._state&Ae.TOUCH_ZOOM_ROTATE)===Ae.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&Ae.TRUCK)===Ae.TRUCK||(this._state&Ae.SCREEN_PAN)===Ae.SCREEN_PAN||(this._state&Ae.TOUCH_TRUCK)===Ae.TOUCH_TRUCK||(this._state&Ae.TOUCH_SCREEN_PAN)===Ae.TOUCH_SCREEN_PAN||(this._state&Ae.TOUCH_DOLLY_TRUCK)===Ae.TOUCH_DOLLY_TRUCK||(this._state&Ae.TOUCH_DOLLY_SCREEN_PAN)===Ae.TOUCH_DOLLY_SCREEN_PAN||(this._state&Ae.TOUCH_ZOOM_TRUCK)===Ae.TOUCH_ZOOM_TRUCK||(this._state&Ae.TOUCH_ZOOM_SCREEN_PAN)===Ae.TOUCH_DOLLY_SCREEN_PAN)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&Ae.DOLLY)===Ae.DOLLY||(this._state&Ae.TOUCH_DOLLY)===Ae.TOUCH_DOLLY||(this._state&Ae.TOUCH_DOLLY_TRUCK)===Ae.TOUCH_DOLLY_TRUCK||(this._state&Ae.TOUCH_DOLLY_SCREEN_PAN)===Ae.TOUCH_DOLLY_SCREEN_PAN||(this._state&Ae.TOUCH_DOLLY_OFFSET)===Ae.TOUCH_DOLLY_OFFSET||(this._state&Ae.TOUCH_DOLLY_ROTATE)===Ae.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&Ae.ZOOM)===Ae.ZOOM||(this._state&Ae.TOUCH_ZOOM)===Ae.TOUCH_ZOOM||(this._state&Ae.TOUCH_ZOOM_TRUCK)===Ae.TOUCH_ZOOM_TRUCK||(this._state&Ae.TOUCH_ZOOM_SCREEN_PAN)===Ae.TOUCH_ZOOM_SCREEN_PAN||(this._state&Ae.TOUCH_ZOOM_OFFSET)===Ae.TOUCH_ZOOM_OFFSET||(this._state&Ae.TOUCH_ZOOM_ROTATE)===Ae.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&Ae.OFFSET)===Ae.OFFSET||(this._state&Ae.TOUCH_OFFSET)===Ae.TOUCH_OFFSET||(this._state&Ae.TOUCH_DOLLY_OFFSET)===Ae.TOUCH_DOLLY_OFFSET||(this._state&Ae.TOUCH_ZOOM_OFFSET)===Ae.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},m=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,R_(this._activePointers,Ji);const b=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,S=b?-b.deltaX:r.x-Ji.x,E=b?-b.deltaY:r.y-Ji.y;if(r.copy(Ji),((this._state&Ae.ROTATE)===Ae.ROTATE||(this._state&Ae.TOUCH_ROTATE)===Ae.TOUCH_ROTATE||(this._state&Ae.TOUCH_DOLLY_ROTATE)===Ae.TOUCH_DOLLY_ROTATE||(this._state&Ae.TOUCH_ZOOM_ROTATE)===Ae.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(S,E),this._isUserControllingRotate=!0),(this._state&Ae.DOLLY)===Ae.DOLLY||(this._state&Ae.ZOOM)===Ae.ZOOM){const w=this.dollyToCursor?(n.x-this._elementRect.x)/this._elementRect.width*2-1:0,T=this.dollyToCursor?(n.y-this._elementRect.y)/this._elementRect.height*-2+1:0,R=this.dollyDragInverted?-1:1;(this._state&Ae.DOLLY)===Ae.DOLLY?(this._dollyInternal(R*E*Zp,w,T),this._isUserControllingDolly=!0):(this._zoomInternal(R*E*Zp,w,T),this._isUserControllingZoom=!0)}if((this._state&Ae.TOUCH_DOLLY)===Ae.TOUCH_DOLLY||(this._state&Ae.TOUCH_ZOOM)===Ae.TOUCH_ZOOM||(this._state&Ae.TOUCH_DOLLY_TRUCK)===Ae.TOUCH_DOLLY_TRUCK||(this._state&Ae.TOUCH_ZOOM_TRUCK)===Ae.TOUCH_ZOOM_TRUCK||(this._state&Ae.TOUCH_DOLLY_SCREEN_PAN)===Ae.TOUCH_DOLLY_SCREEN_PAN||(this._state&Ae.TOUCH_ZOOM_SCREEN_PAN)===Ae.TOUCH_ZOOM_SCREEN_PAN||(this._state&Ae.TOUCH_DOLLY_OFFSET)===Ae.TOUCH_DOLLY_OFFSET||(this._state&Ae.TOUCH_ZOOM_OFFSET)===Ae.TOUCH_ZOOM_OFFSET||(this._state&Ae.TOUCH_DOLLY_ROTATE)===Ae.TOUCH_DOLLY_ROTATE||(this._state&Ae.TOUCH_ZOOM_ROTATE)===Ae.TOUCH_ZOOM_ROTATE){const w=Ji.x-this._activePointers[1].clientX,T=Ji.y-this._activePointers[1].clientY,R=Math.sqrt(w*w+T*T),U=s.y-R;s.set(0,R);const D=this.dollyToCursor?(r.x-this._elementRect.x)/this._elementRect.width*2-1:0,C=this.dollyToCursor?(r.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&Ae.TOUCH_DOLLY)===Ae.TOUCH_DOLLY||(this._state&Ae.TOUCH_DOLLY_ROTATE)===Ae.TOUCH_DOLLY_ROTATE||(this._state&Ae.TOUCH_DOLLY_TRUCK)===Ae.TOUCH_DOLLY_TRUCK||(this._state&Ae.TOUCH_DOLLY_SCREEN_PAN)===Ae.TOUCH_DOLLY_SCREEN_PAN||(this._state&Ae.TOUCH_DOLLY_OFFSET)===Ae.TOUCH_DOLLY_OFFSET?(this._dollyInternal(U*Zp,D,C),this._isUserControllingDolly=!0):(this._zoomInternal(U*Zp,D,C),this._isUserControllingZoom=!0)}((this._state&Ae.TRUCK)===Ae.TRUCK||(this._state&Ae.TOUCH_TRUCK)===Ae.TOUCH_TRUCK||(this._state&Ae.TOUCH_DOLLY_TRUCK)===Ae.TOUCH_DOLLY_TRUCK||(this._state&Ae.TOUCH_ZOOM_TRUCK)===Ae.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(S,E,!1,!1),this._isUserControllingTruck=!0),((this._state&Ae.SCREEN_PAN)===Ae.SCREEN_PAN||(this._state&Ae.TOUCH_SCREEN_PAN)===Ae.TOUCH_SCREEN_PAN||(this._state&Ae.TOUCH_DOLLY_SCREEN_PAN)===Ae.TOUCH_DOLLY_SCREEN_PAN||(this._state&Ae.TOUCH_ZOOM_SCREEN_PAN)===Ae.TOUCH_ZOOM_SCREEN_PAN)&&(this._truckInternal(S,E,!1,!0),this._isUserControllingTruck=!0),((this._state&Ae.OFFSET)===Ae.OFFSET||(this._state&Ae.TOUCH_OFFSET)===Ae.TOUCH_OFFSET||(this._state&Ae.TOUCH_DOLLY_OFFSET)===Ae.TOUCH_DOLLY_OFFSET||(this._state&Ae.TOUCH_ZOOM_OFFSET)===Ae.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(S,E,!0,!1),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},y=()=>{R_(this._activePointers,Ji),r.copy(Ji),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",o,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),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",o,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",x),this._domElement.ownerDocument.addEventListener("pointerlockerror",_),this._domElement.ownerDocument.addEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",l),p())},this.unlockPointer=()=>{var g,b,S;this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),(g=this._domElement)===null||g===void 0||g.ownerDocument.exitPointerLock(),(b=this._domElement)===null||b===void 0||b.ownerDocument.removeEventListener("pointerlockchange",x),(S=this._domElement)===null||S===void 0||S.ownerDocument.removeEventListener("pointerlockerror",_),this.cancel()};const x=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},_=()=>{this.unlockPointer()};this._addAllEventListeners=g=>{this._domElement=g,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",a),this._domElement.addEventListener("pointercancel",l),this._domElement.addEventListener("wheel",f,{passive:!1}),this._domElement.addEventListener("contextmenu",d)},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",l),this._domElement.removeEventListener("wheel",f,{passive:!1}),this._domElement.removeEventListener("contextmenu",d),this._domElement.ownerDocument.removeEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this._domElement.ownerDocument.removeEventListener("pointerlockchange",x),this._domElement.ownerDocument.removeEventListener("pointerlockerror",_))},this.cancel=()=>{this._state!==Ae.NONE&&(this._state=Ae.NONE,this._activePointers.length=0,y())},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=es(e.width,0,1),this._interactiveArea.height=es(e.height,0,1),this._interactiveArea.x=es(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=es(e.y,0,1-this._interactiveArea.height)}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}rotate(e,t,n=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+t,n)}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,n=!1){this._isUserControllingRotate=!1;const r=es(e,this.minAzimuthAngle,this.maxAzimuthAngle),s=es(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=r,this._sphericalEnd.phi=s,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,n||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const a=!n||Qt(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Qt(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=Vc.NONE,this._changedDolly=0,this._dollyToNoClamp(es(e,this.minDistance,this.maxDistance),t)}_dollyToNoClamp(e,t=!1){const n=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const a=this._collisionTest(),o=Qt(a,this._spherical.radius);if(!(n>e)&&o)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 s=!t||Qt(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(s)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(Gh).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const n=!t||Qt(this._target.x,this._targetEnd.x,this.restThreshold)&&Qt(this._target.y,this._targetEnd.y,this.restThreshold)&&Qt(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(n)}zoom(e,t=!1){return this.zoomTo(this._zoomEnd+e,t)}zoomTo(e,t=!1){this._isUserControllingZoom=!1,this._zoomEnd=es(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const n=!t||Qt(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(n)}pan(e,t,n=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,t,n)}truck(e,t,n=!1){this._camera.updateMatrix(),xs.setFromMatrixColumn(this._camera.matrix,0),bs.setFromMatrixColumn(this._camera.matrix,1),xs.multiplyScalar(e),bs.multiplyScalar(-t);const r=Lt.copy(xs).add(bs),s=Zt.copy(this._targetEnd).add(r);return this.moveTo(s.x,s.y,s.z,n)}forward(e,t=!1){Lt.setFromMatrixColumn(this._camera.matrix,0),Lt.crossVectors(this._camera.up,Lt),Lt.multiplyScalar(e);const n=Zt.copy(this._targetEnd).add(Lt);return this.moveTo(n.x,n.y,n.z,t)}elevate(e,t=!1){return Lt.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+Lt.x,this._targetEnd.y+Lt.y,this._targetEnd.z+Lt.z,t)}moveTo(e,t,n,r=!1){this._isUserControllingTruck=!1;const s=Lt.set(e,t,n).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,s,this.boundaryFriction),this._needsUpdate=!0,r||this._target.copy(this._targetEnd);const a=!r||Qt(this._target.x,this._targetEnd.x,this.restThreshold)&&Qt(this._target.y,this._targetEnd.y,this.restThreshold)&&Qt(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(a)}lookInDirectionOf(e,t,n,r=!1){const o=Lt.set(e,t,n).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);return this.setPosition(o.x,o.y,o.z,r)}fitToBox(e,t,{cover:n=!1,paddingLeft:r=0,paddingRight:s=0,paddingBottom:a=0,paddingTop:o=0}={}){const l=[],c=e.isBox3?jc.copy(e):jc.setFromObject(e);c.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const f=tA(this._sphericalEnd.theta,eA),d=tA(this._sphericalEnd.phi,eA);l.push(this.rotateTo(f,d,t));const p=Lt.setFromSpherical(this._sphericalEnd).normalize(),m=oA.setFromUnitVectors(p,O_),y=Qt(Math.abs(p.y),1);y&&m.multiply(N_.setFromAxisAngle(Kp,f)),m.multiply(this._yAxisUpSpaceInverse);const x=aA.makeEmpty();Zt.copy(c.min).applyQuaternion(m),x.expandByPoint(Zt),Zt.copy(c.min).setX(c.max.x).applyQuaternion(m),x.expandByPoint(Zt),Zt.copy(c.min).setY(c.max.y).applyQuaternion(m),x.expandByPoint(Zt),Zt.copy(c.max).setZ(c.min.z).applyQuaternion(m),x.expandByPoint(Zt),Zt.copy(c.min).setZ(c.max.z).applyQuaternion(m),x.expandByPoint(Zt),Zt.copy(c.max).setY(c.min.y).applyQuaternion(m),x.expandByPoint(Zt),Zt.copy(c.max).setX(c.min.x).applyQuaternion(m),x.expandByPoint(Zt),Zt.copy(c.max).applyQuaternion(m),x.expandByPoint(Zt),x.min.x-=r,x.min.y-=a,x.max.x+=s,x.max.y+=o,m.setFromUnitVectors(O_,p),y&&m.premultiply(N_.invert()),m.premultiply(this._yAxisUpSpace);const _=x.getSize(Lt),g=x.getCenter(Zt).applyQuaternion(m);if(ll(this._camera)){const b=this.getDistanceToFitBox(_.x,_.y,_.z,n);l.push(this.moveTo(g.x,g.y,g.z,t)),l.push(this.dollyTo(b,t)),l.push(this.setFocalOffset(0,0,0,t))}else if(io(this._camera)){const b=this._camera,S=b.right-b.left,E=b.top-b.bottom,w=n?Math.max(S/_.x,E/_.y):Math.min(S/_.x,E/_.y);l.push(this.moveTo(g.x,g.y,g.z,t)),l.push(this.zoomTo(w,t)),l.push(this.setFocalOffset(0,0,0,t))}return Promise.all(l)}fitToSphere(e,t){const n=[],s="isObject3D"in e?Ox.createBoundingSphere(e,L_):L_.copy(e);if(n.push(this.moveTo(s.center.x,s.center.y,s.center.z,t)),ll(this._camera)){const a=this.getDistanceToFitSphere(s.radius);n.push(this.dollyTo(a,t))}else if(io(this._camera)){const a=this._camera.right-this._camera.left,o=this._camera.top-this._camera.bottom,l=2*s.radius,c=Math.min(a/l,o/l);n.push(this.zoomTo(c,t))}return n.push(this.setFocalOffset(0,0,0,t)),Promise.all(n)}setLookAt(e,t,n,r,s,a,o=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Vc.NONE,this._changedDolly=0;const l=Zt.set(r,s,a),c=Lt.set(e,t,n);this._targetEnd.copy(l),this._sphericalEnd.setFromVector3(c.sub(l).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,o||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const f=!o||Qt(this._target.x,this._targetEnd.x,this.restThreshold)&&Qt(this._target.y,this._targetEnd.y,this.restThreshold)&&Qt(this._target.z,this._targetEnd.z,this.restThreshold)&&Qt(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Qt(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Qt(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(f)}lerpLookAt(e,t,n,r,s,a,o,l,c,f,d,p,m,y=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Vc.NONE,this._changedDolly=0;const x=Lt.set(r,s,a),_=Zt.set(e,t,n);Or.setFromVector3(_.sub(x).applyQuaternion(this._yAxisUpSpace));const g=Xc.set(f,d,p),b=Zt.set(o,l,c);Hh.setFromVector3(b.sub(g).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(x.lerp(g,m));const S=Hh.theta-Or.theta,E=Hh.phi-Or.phi,w=Hh.radius-Or.radius;this._sphericalEnd.set(Or.radius+w*m,Or.phi+E*m,Or.theta+S*m),this.normalizeRotations(),this._needsUpdate=!0,y||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const T=!y||Qt(this._target.x,this._targetEnd.x,this.restThreshold)&&Qt(this._target.y,this._targetEnd.y,this.restThreshold)&&Qt(this._target.z,this._targetEnd.z,this.restThreshold)&&Qt(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Qt(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Qt(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(T)}setPosition(e,t,n,r=!1){return this.setLookAt(e,t,n,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,r)}setTarget(e,t,n,r=!1){const s=this.getPosition(Lt),a=this.setLookAt(s.x,s.y,s.z,e,t,n,r);return this._sphericalEnd.phi=es(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),a}setFocalOffset(e,t,n,r=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,t,n),this._needsUpdate=!0,r||this._focalOffset.copy(this._focalOffsetEnd);const s=!r||Qt(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&Qt(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&Qt(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(s)}setOrbitPoint(e,t,n){this._camera.updateMatrixWorld(),xs.setFromMatrixColumn(this._camera.matrixWorldInverse,0),bs.setFromMatrixColumn(this._camera.matrixWorldInverse,1),cl.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const r=Lt.set(e,t,n),s=r.distanceTo(this._camera.position),a=r.sub(this._camera.position);xs.multiplyScalar(a.x),bs.multiplyScalar(a.y),cl.multiplyScalar(a.z),Lt.copy(xs).add(bs).add(cl),Lt.z=Lt.z+s,this.dollyTo(s,!1),this.setFocalOffset(-Lt.x,Lt.y,-Lt.z,!1),this.moveTo(e,t,n,!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,n,r){if(e===null){this._viewport=null;return}this._viewport=this._viewport||new Et.Vector4,typeof e=="number"?this._viewport.set(e,t,n,r):this._viewport.copy(e)}getDistanceToFitBox(e,t,n,r=!1){if(D_(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const s=e/t,a=this._camera.getEffectiveFOV()*Fh,o=this._camera.aspect;return((r?s>o:s<o)?t:e/o)*.5/Math.tan(a*.5)+n*.5}getDistanceToFitSphere(e){if(D_(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*Fh,n=Math.atan(Math.tan(t*.5)*this._camera.aspect)*2,r=1<this._camera.aspect?t:n;return e/Math.sin(r*.5)}getTarget(e,t=!0){return(e&&e.isVector3?e:new Et.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new Et.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e||new Et.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new Et.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%Wc,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=Wc),this._spherical.theta+=Wc*Math.round((this._sphericalEnd.theta-this._spherical.theta)/Wc)}stop(){this._focalOffset.copy(this._focalOffsetEnd),this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd),this._zoom=this._zoomEnd}reset(e=!1){if(!Qt(this._camera.up.x,this._cameraUp0.x)||!Qt(this._camera.up.y,this._cameraUp0.y)||!Qt(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const n=this.getPosition(Lt);this.updateCameraUp(),this.setPosition(n.x,n.y,n.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,Kp),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const e=Lt.subVectors(this._target,this._camera.position).normalize(),t=Zt.crossVectors(e,this._camera.up);this._camera.up.crossVectors(t,e).normalize(),this._camera.updateMatrixWorld();const n=this.getPosition(Lt);this.updateCameraUp(),this.setPosition(n.x,n.y,n.z)}update(e){const t=this._sphericalEnd.theta-this._spherical.theta,n=this._sphericalEnd.phi-this._spherical.phi,r=this._sphericalEnd.radius-this._spherical.radius,s=rA.subVectors(this._targetEnd,this._target),a=sA.subVectors(this._focalOffsetEnd,this._focalOffset),o=this._zoomEnd-this._zoom;if(dn(t))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const d=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=Yp(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,d,1/0,e),this._needsUpdate=!0}if(dn(n))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const d=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=Yp(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,d,1/0,e),this._needsUpdate=!0}if(dn(r))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const d=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=Yp(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,d,this.maxSpeed,e),this._needsUpdate=!0}if(dn(s.x)&&dn(s.y)&&dn(s.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const d=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;nA(this._target,this._targetEnd,this._targetVelocity,d,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(dn(a.x)&&dn(a.y)&&dn(a.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const d=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;nA(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,d,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(dn(o))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const d=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=Yp(this._zoom,this._zoomEnd,this._zoomVelocity,d,1/0,e)}if(this.dollyToCursor){if(ll(this._camera)&&this._changedDolly!==0){const d=this._spherical.radius-this._lastDistance,p=this._camera,m=this._getCameraDirection(Gh),y=Lt.copy(m).cross(p.up).normalize();y.lengthSq()===0&&(y.x=1);const x=Zt.crossVectors(y,m),_=this._sphericalEnd.radius*Math.tan(p.getEffectiveFOV()*Fh*.5),b=(this._sphericalEnd.radius-d-this._sphericalEnd.radius)/this._sphericalEnd.radius,S=Xc.copy(this._targetEnd).add(y.multiplyScalar(this._dollyControlCoord.x*_*p.aspect)).add(x.multiplyScalar(this._dollyControlCoord.y*_)),E=Lt.copy(this._targetEnd).lerp(S,b),w=this._lastDollyDirection===Vc.IN&&this._spherical.radius<=this.minDistance,T=this._lastDollyDirection===Vc.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(w||T)){this._sphericalEnd.radius-=d,this._spherical.radius-=d;const U=Zt.copy(m).multiplyScalar(-d);E.add(U)}this._boundary.clampPoint(E,E);const R=Zt.subVectors(E,this._targetEnd);this._targetEnd.copy(E),this._target.add(R),this._changedDolly-=d,dn(this._changedDolly)&&(this._changedDolly=0)}else if(io(this._camera)&&this._changedZoom!==0){const d=this._zoom-this._lastZoom,p=this._camera,m=Lt.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(p.near+p.far)/(p.near-p.far)).unproject(p),y=Zt.set(0,0,-1).applyQuaternion(p.quaternion),x=Xc.copy(m).add(y.multiplyScalar(-m.dot(p.up))),g=-(this._zoom-d-this._zoom)/this._zoom,b=this._getCameraDirection(Gh),S=this._targetEnd.dot(b),E=Lt.copy(this._targetEnd).lerp(x,g),w=E.dot(b),T=b.multiplyScalar(w-S);E.sub(T),this._boundary.clampPoint(E,E);const R=Zt.subVectors(E,this._targetEnd);this._targetEnd.copy(E),this._target.add(R),this._changedZoom-=d,dn(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 l=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,l),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!dn(this._focalOffset.x)||!dn(this._focalOffset.y)||!dn(this._focalOffset.z))&&(xs.setFromMatrixColumn(this._camera.matrix,0),bs.setFromMatrixColumn(this._camera.matrix,1),cl.setFromMatrixColumn(this._camera.matrix,2),xs.multiplyScalar(this._focalOffset.x),bs.multiplyScalar(-this._focalOffset.y),cl.multiplyScalar(this._focalOffset.z),Lt.copy(xs).add(bs).add(cl),this._camera.position.add(Lt),this._camera.updateMatrixWorld()),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),Lt.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const f=this._needsUpdate;return f&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):f?(this.dispatchEvent({type:"update"}),dn(t,this.restThreshold)&&dn(n,this.restThreshold)&&dn(r,this.restThreshold)&&dn(s.x,this.restThreshold)&&dn(s.y,this.restThreshold)&&dn(s.z,this.restThreshold)&&dn(a.x,this.restThreshold)&&dn(a.y,this.restThreshold)&&dn(a.z,this.restThreshold)&&dn(o,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!f&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=f,this._needsUpdate=!1,f}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:Bh(this.maxDistance),minZoom:this.minZoom,maxZoom:Bh(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:Bh(this.maxPolarAngle),minAzimuthAngle:Bh(this.minAzimuthAngle),maxAzimuthAngle:Bh(this.maxAzimuthAngle),smoothTime:this.smoothTime,draggingSmoothTime:this.draggingSmoothTime,dollySpeed:this.dollySpeed,truckSpeed:this.truckSpeed,dollyToCursor:this.dollyToCursor,target:this._targetEnd.toArray(),position:Lt.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 n=JSON.parse(e);this.enabled=n.enabled,this.minDistance=n.minDistance,this.maxDistance=kh(n.maxDistance),this.minZoom=n.minZoom,this.maxZoom=kh(n.maxZoom),this.minPolarAngle=n.minPolarAngle,this.maxPolarAngle=kh(n.maxPolarAngle),this.minAzimuthAngle=kh(n.minAzimuthAngle),this.maxAzimuthAngle=kh(n.maxAzimuthAngle),this.smoothTime=n.smoothTime,this.draggingSmoothTime=n.draggingSmoothTime,this.dollySpeed=n.dollySpeed,this.truckSpeed=n.truckSpeed,this.dollyToCursor=n.dollyToCursor,this._target0.fromArray(n.target0),this._position0.fromArray(n.position0),this._zoom0=n.zoom0,this._focalOffset0.fromArray(n.focalOffset0),this.moveTo(n.target[0],n.target[1],n.target[2],t),Or.setFromVector3(Lt.fromArray(n.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(Or.theta,Or.phi,t),this.dollyTo(Or.radius,t),this.zoomTo(n.zoom,t),this.setFocalOffset(n.focalOffset[0],n.focalOffset[1],n.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",sW),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,n){const r=t.lengthSq();if(r===0)return e;const s=Zt.copy(t).add(e),o=this._boundary.clampPoint(s,Xc).sub(s),l=o.lengthSq();if(l===0)return e.add(t);if(l===r)return e;if(n===0)return e.add(t).add(o);{const c=1+n*l/t.dot(o);return e.add(Zt.copy(t).multiplyScalar(c)).add(o.multiplyScalar(1-n))}}_updateNearPlaneCorners(){if(ll(this._camera)){const e=this._camera,t=e.near,n=e.getEffectiveFOV()*Fh,r=Math.tan(n*.5)*t,s=r*e.aspect;this._nearPlaneCorners[0].set(-s,-r,0),this._nearPlaneCorners[1].set(s,-r,0),this._nearPlaneCorners[2].set(s,r,0),this._nearPlaneCorners[3].set(-s,r,0)}else if(io(this._camera)){const e=this._camera,t=1/e.zoom,n=e.left*t,r=e.right*t,s=e.top*t,a=e.bottom*t;this._nearPlaneCorners[0].set(n,s,0),this._nearPlaneCorners[1].set(r,s,0),this._nearPlaneCorners[2].set(r,a,0),this._nearPlaneCorners[3].set(n,a,0)}}_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||D_(this._camera,"_collisionTest"))return e;const n=this._getTargetDirection(Gh);I_.lookAt(iA,n,this._camera.up);for(let r=0;r<4;r++){const s=Zt.copy(this._nearPlaneCorners[r]);s.applyMatrix4(I_);const a=Xc.addVectors(this._target,s);Jp.set(a,n),Jp.far=this._spherical.radius+1;const o=Jp.intersectObjects(this.colliderMeshes);o.length!==0&&o[0].distance<e&&(e=o[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 n=()=>{this.removeEventListener("rest",n),t()};this.addEventListener("rest",n)}))}_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 Et.Sphere){const n=t,r=n.center;jc.makeEmpty(),e.traverseVisible(a=>{a.isMesh&&jc.expandByObject(a)}),jc.getCenter(r);let s=0;return e.traverseVisible(a=>{if(!a.isMesh)return;const o=a;if(!o.geometry)return;const l=o.geometry.clone();l.applyMatrix4(o.matrixWorld);const f=l.attributes.position;for(let d=0,p=f.count;d<p;d++)Lt.fromBufferAttribute(f,d),s=Math.max(s,r.distanceToSquared(Lt))}),n.radius=Math.sqrt(s),n}};/*!
|
|
4145
4145
|
* hold-event
|
|
4146
4146
|
* https://github.com/yomotsu/hold-event
|
|
4147
4147
|
* (c) 2020 @yomotsu
|
|
@@ -4230,4 +4230,4 @@ vTroikaGlyphColor = uTroikaUseGlyphColors ? aTroikaGlyphColor / 255.0 : diffuse;
|
|
|
4230
4230
|
top: 50%;
|
|
4231
4231
|
left: 50%;
|
|
4232
4232
|
transform: translate(-50%, -50%);
|
|
4233
|
-
}`)),document.head.appendChild(i)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var cA,uA;function U3(i,e=[]){const t=e.length;for(const n of i){const r=e.indexOf(n);if(r>-1){const s=[...e.slice(r),n].map(a=>a.data.id);throw new Error(`Invalid Graph: Circular node path detected: ${s.join(" -> ")}.`)}t>n.depth&&(n.depth=t,U3(n.out,[...e,n]))}}function O3(i,e){let t=!1;const n=i.reduce((a,o)=>({...a,[o.id]:{data:o,out:[],depth:-1,ins:[]}}),{});try{for(const a of e){const o=a.source,l=a.target;if(!n.hasOwnProperty(o))throw new Error(`Missing source Node ${o}`);if(!n.hasOwnProperty(l))throw new Error(`Missing target Node ${l}`);const c=n[o],f=n[l];f.ins.push(c),c.out.push(f)}U3(Object.values(n))}catch{t=!0}const r=Object.keys(n).map(a=>n[a].depth),s=Math.max(...r);return{invalid:t,depths:n,maxDepth:s||1}}const hA=["radialin","radialout"];function hW({nodes:i,edges:e,mode:t="lr",nodeLevelRatio:n=2}){const{depths:r,maxDepth:s,invalid:a}=O3(i,e);if(a)return null;const o=hA.includes(t)?1:5,l=i.length/s*n*o;if(t){const c=(m,y)=>x=>m?(r[x.id].depth-s/2)*l*(y?-1:1):void 0,f=c(["lr","rl"].includes(t),t==="rl"),d=c(["td","bu"].includes(t),t==="td"),p=c(["zin","zout"].includes(t),t==="zout");i.forEach(m=>{m.fx=f(m),m.fy=d(m),m.fz=p(m)})}return hA.includes(t)?Xk(c=>{const f=r[c.id];return(t==="radialin"?s-f.depth:f.depth)*l}).strength(1):null}function fW(i){return new Promise((e,t)=>{let n;function r(){n?e(n):(n=i.step(),r())}r()})}function ld(i){const e=[],t=[];return i.forEachNode((n,r)=>{e.push({...r,id:n,radius:r.size||1})}),i.forEachEdge((n,r)=>{t.push({...r,id:n})}),{nodes:e,edges:t}}function dW(){const i=L=>()=>L;let t=L=>L.index,n=[],r=[],s,a,o=[100,100],l=i(1),c=i(-1),f=i(100),d=i(.1),p={},m=.1,y=.001,x=[],_=[0,0],g,b=L=>L.cluster,S="treemap",E=!0,w=.1;function T(L){if(!E)return T;S==="force"&&(g.tick(),O());for(let B=0,H=n.length,W,k=L*w;B<H;++B)W=n[B],W.vx+=(p[b(W)].x-W.x)*k,W.vy+=(p[b(W)].y-W.y)*k}function R(){n&&(S==="treemap"?G():z())}T.initialize=function(L){n=L,R()};function U(L){let B=b(L.source),H=b(L.target);return B<=H?B+"~"+H:H+"~"+B}function D(L){let B=new Map,H={};return L.forEach(function(W){B.has(b(W))||B.set(b(W),{count:0,sumforceNodeSize:0})}),L.forEach(function(W){H=B.get(b(W)),H.count=H.count+1,H.sumforceNodeSize=H.sumforceNodeSize+Math.PI*(l(W)*l(W))*1.3,B.set(b(W),H)}),B}function C(L){let B=new Map,H=[];return L.forEach(function(W){let k=U(W),K;B.has(k)?K=B.get(k):K=0,K+=1,B.set(k,K)}),B.forEach(function(W,k){let K,$;K=k.split("~")[0],$=k.split("~")[1],K!==void 0&&$!==void 0&&H.push({source:K,target:$,count:W})}),H}function P(){let L=[],B=[],H=new Map,W,k,K,$,j;$=D(n),j=C(r);for(W of $.keys())K=$.get(W),L.push({id:W,size:K.count,r:Math.sqrt(K.sumforceNodeSize/Math.PI)}),H.set(W,k);return j.forEach(function(ee){let de=H.get(ee.source),ae=H.get(ee.target);de!==void 0&&ae!==void 0&&B.push({source:de,target:ae,count:ee.count})}),{nodes:L,links:B}}function I(){let L=[],B,H,W;W=D(T.nodes());for(B of W.keys())H=W.get(B),L.push({id:B,size:H.count});return{id:"clustersTree",children:L}}function O(){return p.none={x:0,y:0},x.forEach(function(L){S==="treemap"?p[L.data.id]={x:L.x0+(L.x1-L.x0)/2-_[0],y:L.y0+(L.y1-L.y0)/2-_[1]}:p[L.id]={x:L.x-_[0],y:L.y-_[1]}}),p}function G(){let L=RG().size(T.size());a=l0(I()).sum(B=>B.radius).sort(function(B,H){return H.height-B.height||H.value-B.value}),x=L(a).leaves(),O()}function Z(){let L=0;n.length!==0&&r.forEach(function(B){let H,W;if(n){if(H=B.source,W=B.target,typeof B.source!="object"&&(H=n.find(k=>k.id===B.source)),typeof B.target!="object"&&(W=n.find(k=>k.id===B.target)),H===void 0||W===void 0)throw Error("Error setting links, couldnt find nodes for a link (see it on the console)");B.source=H,B.target=W,B.index=L++}})}function z(){let L;!n||!n.length||(Z(),L=P(),s.size>0&&L.nodes.forEach(B=>{var H,W,k,K;B.fx=(W=(H=s.get(B.id))==null?void 0:H.position)==null?void 0:W.x,B.fy=(K=(k=s.get(B.id))==null?void 0:k.position)==null?void 0:K.y}),g=eR(L.nodes).force("x",lx(o[0]/2).strength(.1)).force("y",cx(o[1]/2).strength(.1)).force("collide",qC(B=>B.r).iterations(4)).force("charge",tR().strength(c)).force("links",YC(L.nodes.length?L.links:[]).distance(f).strength(d)),x=g.nodes(),O())}return T.template=function(L){return arguments.length?(S=L,R(),T):S},T.groupBy=function(L){return arguments.length?typeof L=="string"?(b=function(B){return B[L]},T):(b=L,T):b},T.enableGrouping=function(L){return arguments.length?(E=L,T):E},T.strength=function(L){return arguments.length?(w=L,T):w},T.getLinkStrength=function(L){return E?b(L.source)===b(L.target)?typeof m=="function"?m(L):m:typeof y=="function"?y(L):y:typeof m=="function"?m(L):m},T.id=function(L){return arguments.length?(t=L,T):t},T.size=function(L){return arguments.length?(o=L,T):o},T.linkStrengthInterCluster=function(L){return arguments.length?(y=L,T):y},T.linkStrengthIntraCluster=function(L){return arguments.length?(m=L,T):m},T.nodes=function(L){return arguments.length?(n=L,T):n},T.links=function(L){return arguments.length?(L===null?r=[]:r=L,R(),T):r},T.template=function(L){return arguments.length?(S=L,R(),T):S},T.forceNodeSize=function(L){return arguments.length?(l=typeof L=="function"?L:i(+L),R(),T):l},T.nodeSize=T.forceNodeSize,T.forceCharge=function(L){return arguments.length?(c=typeof L=="function"?L:i(+L),R(),T):c},T.forceLinkDistance=function(L){return arguments.length?(f=typeof L=="function"?L:i(+L),R(),T):f},T.forceLinkStrength=function(L){return arguments.length?(d=typeof L=="function"?L:i(+L),R(),T):d},T.offset=function(L){return arguments.length?(_=typeof L=="function"?L:i(+L),T):_},T.getFocis=O,T.setClusters=function(L){return s=L,T},T}function no({graph:i,nodeLevelRatio:e=2,mode:t=null,dimensions:n=2,nodeStrength:r=-250,linkDistance:s=50,clusterStrength:a=.5,linkStrengthInterCluster:o=.01,linkStrengthIntraCluster:l=.5,forceLinkDistance:c=100,forceLinkStrength:f=.1,clusterType:d="force",forceCharge:p=-700,getNodePosition:m,drags:y,clusters:x,clusterAttribute:_,forceLayout:g}){const{nodes:b,edges:S}=ld(i),w=n===2&&S.length>25?r*2:r;let T,R;g==="forceDirected2d"?(T=lx(),R=cx()):(T=lx(600).strength(.05),R=cx(600).strength(.05));const U=eR().force("center",O5(0,0)).force("link",YC()).force("charge",tR().strength(w)).force("x",T).force("y",R).force("z",jk()).force("collide",qC(I=>I.radius+10)).force("dagRadial",hW({nodes:b,edges:S,mode:t,nodeLevelRatio:e})).stop();let D;if(_){let I=p;if(b?.length){const O=Math.ceil(b.length/200);I=p*O}D=dW().setClusters(x).strength(a).template(d).groupBy(O=>O.data[_]).links(S).size([100,100]).linkStrengthInterCluster(o).linkStrengthIntraCluster(l).forceLinkDistance(c).forceLinkStrength(f).forceCharge(I).forceNodeSize(O=>O.radius)}let C=U.numDimensions(n).nodes(b);if(D&&(C=C.force("group",D)),s){let I=C.force("link");I&&(I.id(O=>O.id).links(S).distance(s),D&&(I=I.strength(D?.getLinkStrength??.1)))}const P=new Map(b.map(I=>[I.id,I]));return{step(){for(;U.alpha()>.01;)U.tick();return!0},getNodePosition(I){var O,G;if(m){const Z=m(I,{graph:i,drags:y,nodes:b,edges:S});if(Z)return Z}return(O=y?.[I])!=null&&O.position?(G=y?.[I])==null?void 0:G.position:P.get(I)}}}function pW({graph:i,radius:e,drags:t,getNodePosition:n}){const r=OG(i,{scale:e}),{nodes:s,edges:a}=ld(i);return{step(){return!0},getNodePosition(o){var l,c;if(n){const f=n(o,{graph:i,drags:t,nodes:s,edges:a});if(f)return f}return(l=t?.[o])!=null&&l.position?(c=t?.[o])==null?void 0:c.position:r?.[o]}}}const mW={td:{x:"x",y:"y",factor:-1},lr:{x:"y",y:"x",factor:1}};function fA({graph:i,drags:e,mode:t="td",nodeSeparation:n=1,nodeSize:r=[50,50],getNodePosition:s}){const{nodes:a,edges:o}=ld(i),{depths:l}=O3(a,o),c=Object.keys(l).map(x=>l[x]),f=vG().id(x=>x.data.id).parentId(x=>{var _,g,b;return(b=(g=(_=x.ins)==null?void 0:_[0])==null?void 0:g.data)==null?void 0:b.id})(c),p=MG().separation(()=>n).nodeSize(r)(l0(f)).descendants(),m=mW[t],y=new Map(a.map(x=>{const{x:_,y:g}=p.find(b=>b.data.id===x.id);return[x.id,{...x,[m.x]:_*m.factor,[m.y]:g*m.factor,z:0}]}));return{step(){return!0},getNodePosition(x){var _,g;if(s){const b=s(x,{graph:i,drags:e,nodes:a,edges:o});if(b)return b}return(_=e?.[x])!=null&&_.position?(g=e?.[x])==null?void 0:g.position:y.get(x)}}}function gW({graph:i,margin:e,drags:t,getNodePosition:n,ratio:r,gridSize:s,maxIterations:a}){const{nodes:o,edges:l}=ld(i),c=FG(i,{maxIterations:a,inputReducer:(f,d)=>({...d,x:d.x||0,y:d.y||0}),settings:{ratio:r,margin:e,gridSize:s}});return{step(){return!0},getNodePosition(f){var d,p;if(n){const m=n(f,{graph:i,drags:t,nodes:o,edges:l});if(m)return m}return(d=t?.[f])!=null&&d.position?(p=t?.[f])==null?void 0:p.position:c?.[f]}}}function vW({graph:i,drags:e,iterations:t,...n}){qG.assign(i);const r=WG(i,{iterations:t,settings:n});return{step(){return!0},getNodePosition(s){var a;return((a=e?.[s])==null?void 0:a.position)||r?.[s]}}}function yW({graph:i,drags:e,getNodePosition:t}){const{nodes:n,edges:r}=ld(i);return{step(){return!0},getNodePosition(s){return t(s,{graph:i,drags:e,nodes:n,edges:r})}}}const _W=["forceDirected2d","treeTd2d","treeLr2d","radialOut2d","treeTd3d","treeLr3d","radialOut3d","forceDirected3d"];function xW({type:i,...e}){if(_W.includes(i)){const{nodeStrength:t,linkDistance:n,nodeLevelRatio:r}=e;if(i==="forceDirected2d")return no({...e,dimensions:2,nodeLevelRatio:r||2,nodeStrength:t||-250,linkDistance:n,forceLayout:i});if(i==="treeTd2d")return no({...e,mode:"td",dimensions:2,nodeLevelRatio:r||5,nodeStrength:t||-250,linkDistance:n||50,forceLayout:i});if(i==="treeLr2d")return no({...e,mode:"lr",dimensions:2,nodeLevelRatio:r||5,nodeStrength:t||-250,linkDistance:n||50,forceLayout:i});if(i==="radialOut2d")return no({...e,mode:"radialout",dimensions:2,nodeLevelRatio:r||5,nodeStrength:t||-500,linkDistance:n||100,forceLayout:i});if(i==="treeTd3d")return no({...e,mode:"td",dimensions:3,nodeLevelRatio:r||2,nodeStrength:t||-500,linkDistance:n||50});if(i==="treeLr3d")return no({...e,mode:"lr",dimensions:3,nodeLevelRatio:r||2,nodeStrength:t||-500,linkDistance:n||50,forceLayout:i});if(i==="radialOut3d")return no({...e,mode:"radialout",dimensions:3,nodeLevelRatio:r||2,nodeStrength:t||-500,linkDistance:n||100,forceLayout:i});if(i==="forceDirected3d")return no({...e,dimensions:3,nodeLevelRatio:r||2,nodeStrength:t||-250,linkDistance:n,forceLayout:i})}else if(i==="circular2d"){const{radius:t}=e;return pW({...e,radius:t||300})}else{if(i==="hierarchicalTd")return fA({...e,mode:"td"});if(i==="hierarchicalLr")return fA({...e,mode:"lr"});if(i==="nooverlap"){const{graph:t,maxIterations:n,ratio:r,margin:s,gridSize:a,...o}=e;return gW({graph:t,margin:s||10,maxIterations:n||50,ratio:r||10,gridSize:a||20,...o})}else if(i==="forceatlas2"){const{graph:t,iterations:n,gravity:r,scalingRatio:s,...a}=e;return vW({type:"forceatlas2",graph:t,...a,scalingRatio:s||100,gravity:r||10,iterations:n||50})}else if(i==="custom")return yW({...e})}throw new Error(`Layout ${i} not found.`)}function L3({nodeCount:i,nodePosition:e,labelType:t,camera:n}){return(r,s)=>{var a;if(n&&e&&((a=n?.position)==null?void 0:a.z)/n?.zoom-e?.z>6e3)return!1;if(t==="all")return!0;if(t==="nodes"&&r==="node")return!0;if(t==="edges"&&r==="edge")return!0;if(t==="auto"&&r==="node"){if(s>7)return!0;if(n&&e&&n.position.z/n.zoom-e.z<3e3)return!0}return!1}}function N3(i,e){switch(e){case"above":return i;case"below":return-i;case"inline":case"natural":default:return 0}}const ab=typeof window>"u";function bW({graph:i}){const e=JG(i);return{ranks:e,getSizeForNode:t=>e[t]*80}}function SW({graph:i}){const e=$G.degreeCentrality(i);return{ranks:e,getSizeForNode:t=>e[t]*20}}function EW({graph:i,attribute:e,defaultSize:t}){const n=new Map;return e?i.forEachNode((r,s)=>{var a;const o=(a=s.data)==null?void 0:a[e];isNaN(o)&&console.warn(`Attribute ${o} is not a number for node ${s.id}`),n.set(r,o||0)}):console.warn("Attribute sizing configured but no attribute provided"),{getSizeForNode:r=>!e||!n?t:n.get(r)}}const dA={pagerank:bW,centrality:SW,attribute:EW,none:({defaultSize:i})=>({getSizeForNode:e=>i})};function MW({type:i,...e}){var t;const n=(t=dA[i])==null?void 0:t.call(dA,e);if(!n&&i!=="default")throw new Error(`Unknown sizing strategy: ${i}`);const{graph:r,minSize:s,maxSize:a}=e,o=new Map;let l,c;if(r.forEachNode((f,d)=>{let p;i==="default"?p=d.size||e.defaultSize:p=n.getSizeForNode(f),(l===void 0||p<l)&&(l=p),(c===void 0||p>c)&&(c=p),o.set(f,p)}),i!=="none"){const f=fR().domain([l,c]).rangeRound([s,a]);for(const[d,p]of o)o.set(d,f(p))}return o}function wW(i,e,t){i.clear();const n=new Set;for(const r of e)try{n.has(r.id)||(i.addNode(r.id,r),n.add(r.id))}catch(s){console.error(`[Graph] Error adding node '${r.id}`,s)}for(const r of t)if(!(!n.has(r.source)||!n.has(r.target)))try{i.addEdge(r.source,r.target,r)}catch(s){console.error(`[Graph] Error adding edge '${r.source} -> ${r.target}`,s)}return i}function TW({graph:i,layout:e,sizingType:t,labelType:n,sizingAttribute:r,defaultNodeSize:s,minNodeSize:a,maxNodeSize:o,clusterAttribute:l}){const c=[],f=[],d=new Map,p=MW({graph:i,type:t,attribute:r,minSize:a,maxSize:o,defaultSize:s}),m=i.nodes().length,y=L3({nodeCount:m,labelType:n});return i.forEachNode((x,_)=>{const g=e.getNodePosition(x),{data:b,fill:S,icon:E,label:w,size:T,...R}=_,U=p.get(_.id),D=y("node",U),P=(i.inboundNeighbors(_.id)||[]).map(O=>i.getNodeAttributes(O)),I={..._,size:U,labelVisible:D,label:w,icon:E,fill:S,cluster:l?b[l]:void 0,parents:P,data:{...R,...b??{}},position:{...g,x:g.x||0,y:g.y||0,z:g.z||1}};d.set(_.id,I),c.push(I)}),i.forEachEdge((x,_)=>{const g=d.get(_.source),b=d.get(_.target);if(g&&b){const{data:S,id:E,label:w,size:T,...R}=_,U=y("edge",T);f.push({..._,id:E,label:w,labelVisible:U,size:T,data:{...R,id:E,...S||{}}})}}),{nodes:c,edges:f}}const _r={mass:10,tension:1e3,friction:300,precision:.1};function I3(i,e,t){const n=e.getLength(),r=i==="end"?n:n/2,s=i==="end"?t/2:0,a=(r-s)/n,o=e.getPointAt(a),l=e.getTangentAt(a);return[o,l]}function P3(i){return[i+6,2+i/1.5]}const pA=.7;function z3(i,e,t=0){const n=new J(i.x,i.y||0,i.z||0),r=new J(e.x,e.y||0,e.z||0),s=new J().addVectors(n,r).divideScalar(2);return s.setLength(s.length()+t)}function AW(i,e,t=-1){const n=i.clone(),r=e.clone(),s=new J().subVectors(r,n),a=s.length(),o=s.clone().normalize(),l=new J().subVectors(r,n).divideScalar(2),c=Math.abs(o.x)%1,f=new J(-o.y,o.x-c*o.z,c*o.y).normalize(),d=new J().add(n).add(l).add(f.multiplyScalar(a/4).multiplyScalar(t));return[i,d,e]}function Vf(i,e,t,n,r,s){const a=mA(i,t,e),o=mA(t,i,n);return r?new jg(...AW(a,o,s)):new r1(a,o)}function Wf(i){return new J(i.position.x,i.position.y,i.position.z||0)}function mA(i,e,t){const n=i.distanceTo(e);return i.clone().add(e.clone().sub(i).multiplyScalar(t/n))}function gA(i,e){return{...i,position:{...i.position,x:i.position.x+e.x,y:i.position.y+e.y,z:i.position.z+e.z}}}function CW({edge:i,edges:e,curved:t}){var n;let r=t,s;const a=e.filter(o=>o.target===i.target&&o.source===i.source).map(o=>o.id);if(a.length>1){r=!0;const o=a.indexOf(i.id),l=o===0?1:1+o*.8,c=o%2===0?1:-1,f=pA*l;s=c*f}return(n=i.data)!=null&&n.isAggregated&&e.length>1?{curved:!0,curveOffset:a.indexOf(i.id)===0?pA:-.7}:{curved:r,curveOffset:s}}function RW(i,e,t){const n=e.x-i.x,r=e.y-i.y,s=Math.atan2(r,n),a=t==="above"?n>=0?s+Math.PI/2:s-Math.PI/2:n>=0?s-Math.PI/2:s+Math.PI/2,o=7,l=Math.cos(a)*o,c=Math.sin(a)*o;return{x:l,y:c,z:0}}function Xf(i){let e=Number.POSITIVE_INFINITY,t=Number.NEGATIVE_INFINITY,n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,s=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY;for(let o of i)e=Math.min(e,o.position.x),t=Math.max(t,o.position.x),n=Math.min(n,o.position.y),r=Math.max(r,o.position.y),s=Math.min(s,o.position.z),a=Math.max(a,o.position.z);return{height:r-n,width:t-e,minX:e,maxX:t,minY:n,maxY:r,minZ:s,maxZ:a,x:(t+e)/2,y:(r+n)/2,z:(a+s)/2}}function DW(i,e){return e?i.reduce((t,n)=>{const r=n.data[e];return r&&t.set(r,[...t.get(r)||[],n]),t},new Map):new Map}function UW({nodes:i,clusterAttribute:e}){const t=new Map;if(e){const n=DW(i,e);for(const[r,s]of n){const a=Xf(s);t.set(r,{label:r,nodes:s,position:a})}}return t}function OW(i,e,t){return yV.bidirectional(i,e,t)}const vA=i=>i.tagName!=="INPUT"&&i.tagName!=="SELECT"&&i.tagName!=="TEXTAREA"&&!i.isContentEditable,F3=({actives:i=[],selections:e=[],collapsedNodeIds:t=[],theme:n})=>iV(r=>{var s,a,o;return{theme:{...n,edge:{...n?.edge,label:{...(s=n?.edge)==null?void 0:s.label,fontSize:((o=(a=n?.edge)==null?void 0:a.label)==null?void 0:o.fontSize)??6}}},edges:[],nodes:[],collapsedNodeIds:t,clusters:new Map,panning:!1,draggingIds:[],actives:i,edgeContextMenus:new Set,edgeMeshes:[],selections:e,hoveredNodeId:null,drags:{},graph:new cn({multi:!0}),setTheme:l=>r(c=>({...c,theme:l})),setClusters:l=>r(c=>({...c,clusters:l})),setEdgeContextMenus:l=>r(c=>({...c,edgeContextMenus:l})),setEdgeMeshes:l=>r(c=>({...c,edgeMeshes:l})),setPanning:l=>r(c=>({...c,panning:l})),setDrags:l=>r(c=>({...c,drags:l})),addDraggingId:l=>r(c=>({...c,draggingIds:[...c.draggingIds,l]})),removeDraggingId:l=>r(c=>({...c,draggingIds:c.draggingIds.filter(f=>f!==l)})),setActives:l=>r(c=>({...c,actives:l})),setSelections:l=>r(c=>({...c,selections:l})),setHoveredNodeId:l=>r(c=>({...c,hoveredNodeId:l})),setNodes:l=>r(c=>({...c,nodes:l,centerPosition:Xf(l)})),setEdges:l=>r(c=>({...c,edges:l})),setNodePosition:(l,c)=>r(f=>{var d,p;const m=f.nodes.find(b=>b.id===l),y=Wf(m),_=new J(c.x,c.y,c.z).sub(y),g=[...f.nodes];if((d=f.selections)!=null&&d.includes(l))(p=f.selections)==null||p.forEach(b=>{const S=f.nodes.find(E=>E.id===b);if(S){const E=f.nodes.indexOf(S);g[E]=gA(S,_)}});else{const b=f.nodes.indexOf(m);g[b]=gA(m,_)}return{...f,drags:{...f.drags,[l]:m},nodes:g}}),setCollapsedNodeIds:(l=[])=>r(c=>({...c,collapsedNodeIds:l})),setClusterPosition:(l,c)=>r(f=>{const d=new Map(f.clusters),p=d.get(l);if(p){const m=p.position,y=new J(c.x-m.x,c.y-m.y,c.z-(m.z??0)),x=[...f.nodes],_={...f.drags};x.forEach((S,E)=>{S.cluster===l&&(x[E]={...S,position:{...S.position,x:S.position.x+y.x,y:S.position.y+y.y,z:S.position.z+(y.z??0)}},_[S.id]=S)});const g=x.filter(S=>S.cluster===l),b=Xf(g);return d.set(l,{...p,position:b}),{...f,drags:{..._,[l]:p},clusters:d,nodes:x}}return f})}}),B3=F3({}),k3=ab?null:Q.createContext(B3),LW=({children:i,store:e=B3})=>ab?i:lo.createElement(k3.Provider,{value:e},i),$e=i=>{const e=Q.useContext(k3);return dR(e,aV(i))};function G3({nodeId:i,nodes:e,edges:t,currentHiddenNodes:n,currentHiddenEdges:r}){const s=[],a=[],o=n.map(m=>m.id),l=r.map(m=>m.id),c=t.filter(m=>m.source===i),f=c.map(m=>m.target);a.push(...c);for(const m of f){const y=t.filter(_=>_.target===m&&_.source!==i);let x=!1;if((y.length===0||y.length>0&&!o.includes(m)&&y.map(g=>g.id).every(g=>l.includes(g)))&&(x=!0),x){const _=e.find(b=>b.id===m);_&&s.push(_);const g=G3({nodeId:m,nodes:e,edges:t,currentHiddenEdges:a,currentHiddenNodes:s});a.push(...g.hiddenEdges),s.push(...g.hiddenNodes)}}const d=Object.values(a.reduce((m,y)=>({...m,[y.id]:y}),{})),p=Object.values(s.reduce((m,y)=>({...m,[y.id]:y}),{}));return{hiddenEdges:d,hiddenNodes:p}}const NW=({collapsedIds:i,nodes:e,edges:t})=>{const n=[],r=[];for(const c of i){const{hiddenEdges:f,hiddenNodes:d}=G3({nodeId:c,nodes:e,edges:t,currentHiddenEdges:r,currentHiddenNodes:n});n.push(...d),r.push(...f)}const s=n.map(c=>c.id),a=r.map(c=>c.id),o=e.filter(c=>!s.includes(c.id)),l=t.filter(c=>!a.includes(c.id));return{visibleNodes:o,visibleEdges:l}},IW=({layoutType:i,sizingType:e,labelType:t,sizingAttribute:n,clusterAttribute:r,selections:s,nodes:a,edges:o,actives:l,collapsedNodeIds:c,defaultNodeSize:f,maxNodeSize:d,minNodeSize:p,layoutOverrides:m,constrainDragging:y})=>{const x=$e(k=>k.graph),_=$e(k=>k.clusters),g=$e(k=>k.nodes),b=$e(k=>k.setClusters),S=$e(k=>k.collapsedNodeIds),E=$e(k=>k.setEdges),w=$e(k=>k.nodes),T=$e(k=>k.setNodes),R=$e(k=>k.setSelections),U=$e(k=>k.setActives),D=$e(k=>k.drags),C=$e(k=>k.setDrags),P=$e(k=>k.setCollapsedNodeIds),I=Q.useRef(!1),O=Q.useRef(null),G=Kn(k=>k.camera),Z=Q.useRef(D),z=Q.useRef([]);Q.useEffect(()=>{var k;if(!r)return;const K=g.map(j=>j.id),$=a.find(j=>!K.includes(j.id));if($){const j=$.data[r],ee=_.get(j),de={...Z.current};(k=ee?.nodes)==null||k.forEach(ae=>de[ae.id]=void 0),Z.current=de,C(de)}},[g,a,r,_,C]);const{visibleEdges:L,visibleNodes:B}=Q.useMemo(()=>NW({collapsedIds:S,nodes:a,edges:o}),[S,a,o]),H=Q.useCallback(k=>{const K={...Z.current};k.forEach($=>K[$.id]=$),Z.current=K,C(K)},[C]),W=Q.useCallback(async k=>{O.current=k||xW({...m,type:i,graph:x,drags:Z.current,clusters:z?.current,clusterAttribute:r}),await fW(O.current);const K=TW({graph:x,layout:O.current,sizingType:e,labelType:t,sizingAttribute:n,maxNodeSize:d,minNodeSize:p,defaultNodeSize:f,clusterAttribute:r}),$=UW({nodes:K.nodes,clusterAttribute:r});y&&$.forEach(j=>{var ee,de;const ae=z.current.get(j.label);ae?.nodes.length===j.nodes.length&&(j.position=((de=(ee=z.current)==null?void 0:ee.get(j.label))==null?void 0:de.position)??j.position)}),E(K.edges),T(K.nodes),b($),r&&H(K.nodes)},[m,i,r,e,t,n,d,p,f,E,T,b]);return Q.useEffect(()=>{Z.current=D},[D,r,W]),Q.useEffect(()=>{z.current=_},[_]),Q.useEffect(()=>{const k=w.map($=>({...$,labelVisible:L3({nodeCount:w?.length,labelType:t,camera:G,nodePosition:$?.position})("node",$?.size)}));k.some(($,j)=>$.labelVisible!==w[j].labelVisible)&&T(k)},[G,G.zoom,G.position.z,T,w,t]),Q.useEffect(()=>{I.current&&R(s)},[s,R]),Q.useEffect(()=>{I.current&&U(l)},[l,U]),Q.useEffect(()=>{async function k(){I.current=!1,wW(x,B,L),await W(),requestAnimationFrame(()=>I.current=!0)}k()},[B,L]),Q.useEffect(()=>{I.current&&P(c)},[c,P]),Q.useEffect(()=>{I.current&&(Z.current={},C({}),W())},[i,W,C]),Q.useEffect(()=>{I.current&&W(O.current)},[e,n,t,W]),{updateLayout:W}},yu=({text:i,fontSize:e=7,fontUrl:t,color:n="#2A6475",opacity:r=1,stroke:s,active:a,ellipsis:o=75,rotation:l})=>{const c=o&&!a?aW(i,o):i,f=Q.useMemo(()=>new et(n),[n]),d=Q.useMemo(()=>s?new et(s):void 0,[s]);return he.jsx(v3,{position:[0,0,1],renderOrder:1,children:he.jsx(eW,{font:t,fontSize:e,color:f,fillOpacity:r,textAlign:"center",outlineWidth:s?1:0,outlineColor:d,depthOffset:0,maxWidth:100,overflowWrap:"break-word",rotation:l,children:c})})},H3=({draggable:i,set:e,position:t,bounds:n,onDragStart:r,onDragEnd:s})=>{const a=Kn(_=>_.camera),o=Kn(_=>_.raycaster),l=Kn(_=>_.size),c=Kn(_=>_.gl),{mouse2D:f,mouse3D:d,offset:p,normal:m,plane:y}=Q.useMemo(()=>({mouse2D:new Ge,mouse3D:new J,offset:new J,normal:new J,plane:new la}),[]),x=Q.useMemo(()=>c.domElement.getBoundingClientRect(),[c.domElement]);return r9({onDragStart:({event:_})=>{const{eventObject:g,point:b}=_;g.getWorldPosition(p).sub(b),d.copy(b),r()},onDrag:({xy:_,buttons:g,cancel:b})=>{if(g!==1){b();return}const S=(_[0]-(x?.left??0))/l.width*2-1,E=-((_[1]-(x?.top??0))/l.height)*2+1;f.set(S,E),o.setFromCamera(f,a),a.getWorldDirection(m).negate(),y.setFromNormalAndCoplanarPoint(m,d),o.ray.intersectPlane(y,d);const w=new J(t.x,t.y,t.z).copy(d).add(p);if(n){const T=new J((n.minX+n.maxX)/2,(n.minY+n.maxY)/2,(n.minZ+n.maxZ)/2),R=(n.maxX-n.minX)/2,U=w.clone().sub(T);U.length()>R&&(U.normalize().multiplyScalar(R),w.copy(T).add(U))}return e(w)},onDragEnd:s},{drag:{enabled:i,threshold:10}})},ob=({sensitivity:i=7,interval:e=50,timeout:t=0,disabled:n,onPointerOver:r,onPointerOut:s})=>{const a=Q.useRef(!1),o=Q.useRef(null),l=Q.useRef(0),c=Q.useRef({x:null,y:null,px:null,py:null}),f=Q.useCallback(_=>{c.current.x=_.clientX,c.current.y=_.clientY},[]),d=Q.useCallback(_=>{o.current=clearTimeout(o.current);const{px:g,x:b,py:S,y:E}=c.current;Math.abs(g-b)+Math.abs(S-E)<i?(l.current=1,r(_)):(c.current.px=b,c.current.py=E,o.current=setTimeout(()=>d(_),e))},[e,r,i]),p=Q.useCallback(()=>{clearTimeout(o.current),typeof window<"u"&&document.removeEventListener("mousemove",f,!1)},[f]),m=Q.useCallback(_=>{n||(a.current=!0,p(),l.current!==1&&(c.current.px=_.pointer.x,c.current.py=_.pointer.y,typeof window<"u"&&document.addEventListener("mousemove",f,!1),o.current=setTimeout(()=>d(_),t)))},[p,d,n,f,t]),y=Q.useCallback(_=>{o.current=clearTimeout(o.current),l.current=0,s(_)},[s]),x=Q.useCallback(_=>{a.current=!1,p(),l.current===1&&(o.current=setTimeout(()=>y(_),t))},[p,y,t]);return{pointerOver:m,pointerOut:x}},V3=Q.createContext({controls:null,resetControls:()=>{},zoomIn:()=>{},zoomOut:()=>{},dollyIn:()=>{},dollyOut:()=>{},panLeft:()=>{},panRight:()=>{},panUp:()=>{},panDown:()=>{},freeze:()=>{},unFreeze:()=>{}}),x0=()=>{const i=Q.useContext(V3);if(i===void 0)throw new Error("`useCameraControls` hook must be used within a `ControlsProvider` component");return i},PW=({outerRadius:i,innerRadius:e,padding:t,normalizedFill:n,normalizedStroke:r,opacity:s,animated:a,theme:o})=>{var l;const{opacity:c}=yr({from:{opacity:0},to:{opacity:s},config:{..._r,duration:a?void 0:0}});return he.jsxs(he.Fragment,{children:[he.jsxs("mesh",{children:[he.jsx("ringGeometry",{attach:"geometry",args:[i,0,128]}),he.jsx(Bn.meshBasicMaterial,{attach:"material",color:n,transparent:!0,depthTest:!1,opacity:(l=o.cluster)!=null&&l.fill?c:0,side:In,fog:!0})]}),he.jsxs("mesh",{children:[he.jsx("ringGeometry",{attach:"geometry",args:[i,e+t,128]}),he.jsx(Bn.meshBasicMaterial,{attach:"material",color:r,transparent:!0,depthTest:!1,opacity:c,side:In,fog:!0})]})]})},zW=({animated:i,position:e,padding:t=40,labelFontUrl:n,disabled:r,radius:s=2,nodes:a,label:o,onClick:l,onPointerOver:c,onPointerOut:f,draggable:d=!1,onDragged:p,onRender:m})=>{var y,x,_,g,b,S,E;const w=$e(ne=>ne.theme),T=Math.max(e.width,e.height)/2,R=T-s+t,[U,D]=Q.useState(!1),C=$e(ne=>ne.centerPosition),P=$e(ne=>ne.nodes),I=x0(),O=$e(ne=>ne.draggingIds),G=O.includes(o),Z=O.length>0,z=$e(ne=>{var Ue;return(Ue=ne.actives)==null?void 0:Ue.some(V=>a.some(se=>se.id===V))}),L=$e(ne=>ne.hoveredNodeId),B=$e(ne=>{var Ue;return(Ue=ne.selections)==null?void 0:Ue.some(V=>a.some(se=>se.id===V))}),W=$e(ne=>{var Ue;return((Ue=ne.selections)==null?void 0:Ue.length)>0})?B||U||z?(y=w.cluster)==null?void 0:y.selectedOpacity:(x=w.cluster)==null?void 0:x.inactiveOpacity:(_=w.cluster)==null?void 0:_.opacity,k=Q.useMemo(()=>{var ne,Ue;const V=[0,-R,2],se=(Ue=(ne=w.cluster)==null?void 0:ne.label)==null?void 0:Ue.offset;return se?[V[0]-se[0],V[1]-se[1],V[2]-se[2]]:V},[R,(b=(g=w.cluster)==null?void 0:g.label)==null?void 0:b.offset]),{circlePosition:K}=yr({from:{circlePosition:[C.x,C.y,-1]},to:{circlePosition:e?[e.x,e.y,-1]:[0,0,-1]},config:{..._r,duration:i&&!Z?void 0:0}}),$=Q.useMemo(()=>{var ne;return new et((ne=w.cluster)==null?void 0:ne.stroke)},[(S=w.cluster)==null?void 0:S.stroke]),j=Q.useMemo(()=>{var ne;return new et((ne=w.cluster)==null?void 0:ne.fill)},[(E=w.cluster)==null?void 0:E.fill]),ee=$e(ne=>ne.addDraggingId),de=$e(ne=>ne.removeDraggingId),ae=$e(ne=>ne.setClusterPosition),pe=H3({draggable:d&&!L,position:{x:e.x,y:e.y,z:-1},set:ne=>ae(o,ne),onDragStart:()=>{ee(o),D(!0)},onDragEnd:()=>{de(o),D(!1);const ne=P.filter(Ue=>Ue.cluster===o);p?.({nodes:ne,label:o})}});El(U&&!Z&&l!==void 0,"pointer"),El(U&&d&&!G&&l===void 0,"grab"),El(G,"grabbing");const{pointerOver:Le,pointerOut:xe}=ob({disabled:r,onPointerOver:ne=>{D(!0),I.freeze(),c?.({nodes:a,label:o},ne)},onPointerOut:ne=>{D(!1),I.unFreeze(),f?.({nodes:a,label:o},ne)}});return Q.useMemo(()=>{var ne,Ue,V;return w.cluster&&he.jsx(Bn.group,{userData:{id:o,type:"cluster"},position:K,onPointerOver:Le,onPointerOut:xe,onClick:se=>{!r&&!G&&l?.({nodes:a,label:o},se)},...pe(),children:m?m({label:{position:k,text:o,opacity:W,fontUrl:n},opacity:W,outerRadius:R,innerRadius:T,padding:t,theme:w}):he.jsxs(he.Fragment,{children:[he.jsx(PW,{outerRadius:R,innerRadius:T,padding:t,normalizedFill:j,normalizedStroke:$,opacity:W,animated:i,theme:w}),((ne=w.cluster)==null?void 0:ne.label)&&he.jsx(Bn.group,{position:k,children:he.jsx(yu,{text:o,opacity:W,fontUrl:n,stroke:w.cluster.label.stroke,active:!1,color:(Ue=w.cluster)==null?void 0:Ue.label.color,fontSize:((V=w.cluster)==null?void 0:V.label.fontSize)??12})})]})})},[w,K,Le,xe,R,j,T,t,$,k,o,W,n,r,l,a,pe,G,m,i])},FW=({animated:i,color:e="#D8E6EA",length:t,opacity:n=.5,position:r,rotation:s,size:a=1,onActive:o,onContextMenu:l})=>{const c=Q.useMemo(()=>new et(e),[e]),f=Q.useRef(null),d=$e(_=>_.draggingIds.length>0),p=$e(_=>_.centerPosition),[{pos:m,arrowOpacity:y}]=yr(()=>({from:{pos:p?[p.x,p.y,p.z]:[0,0,0],arrowOpacity:0},to:{pos:[r.x,r.y,r.z],arrowOpacity:n},config:{..._r,duration:i&&!d?void 0:0}}),[i,d,n,r]),x=Q.useCallback(()=>{var _;const g=new J(0,1,0);(_=f.current)==null||_.quaternion.setFromUnitVectors(g,s)},[s,f]);return Q.useEffect(()=>x(),[x]),he.jsxs(Bn.mesh,{position:m,ref:f,scale:[1,1,1],onPointerOver:()=>o(!0),onPointerOut:()=>o(!1),onPointerDown:_=>{_.nativeEvent.buttons===2&&(_.stopPropagation(),l())},children:[he.jsx("cylinderGeometry",{args:[0,a,t,20,1,!0],attach:"geometry"}),he.jsx(Bn.meshBasicMaterial,{attach:"material",color:c,depthTest:!1,opacity:y,transparent:!0,side:In,fog:!0})]})},BW=({curveOffset:i,animated:e,color:t="#000",curve:n,curved:r=!1,id:s,opacity:a=1,size:o=1,onContextMenu:l,onClick:c,onPointerOver:f,onPointerOut:d})=>{const p=Q.useRef(null),m=$e(b=>b.draggingIds.length>0),y=Q.useMemo(()=>new et(t),[t]),x=$e(b=>b.centerPosition),_=Q.useRef(!1),{lineOpacity:g}=yr({from:{lineOpacity:0},to:{lineOpacity:a},config:{..._r,duration:e?void 0:0}});return yr(()=>{const b=n.getPoint(0),S=n.getPoint(1);return{from:{fromVertices:_.current?[S?.x,S?.y,S?.z||0]:[x?.x,x?.y,x?.z||0],toVertices:[b?.x,b?.y,b?.z||0]},to:{fromVertices:[b?.x,b?.y,b?.z||0],toVertices:[S?.x,S?.y,S?.z||0]},onChange:E=>{const{fromVertices:w,toVertices:T}=E.value,R=new J(...w),U=new J(...T),D=Vf(R,0,U,0,r,i);p.current.copy(new Rl(D,20,o/2,5,!1))},config:{..._r,duration:e&&!m?void 0:0}}},[e,m,n,o]),Q.useEffect(()=>{_.current=!0},[]),he.jsxs("mesh",{userData:{id:s,type:"edge"},renderOrder:-1,onPointerOver:f,onPointerOut:d,onClick:c,onPointerDown:b=>{b.nativeEvent.buttons===2&&(b.stopPropagation(),l())},children:[he.jsx("tubeGeometry",{attach:"geometry",ref:p}),he.jsx(Bn.meshBasicMaterial,{attach:"material",opacity:g,fog:!0,transparent:!0,depthTest:!1,color:y})]})},yA=3,kW=({animated:i,arrowPlacement:e="end",contextMenu:t,disabled:n,labelPlacement:r="inline",id:s,interpolation:a,labelFontUrl:o,onContextMenu:l,onClick:c,onPointerOver:f,onPointerOut:d,subLabelPlacement:p="below"})=>{var m,y,x,_;const g=$e(re=>re.theme),b=$e(re=>re.draggingIds.length>0),[S,E]=Q.useState(!1),[w,T]=Q.useState(!1),R=$e(re=>re.edges),U=R.find(re=>re.id===s),{target:D,source:C,label:P,subLabel:I,labelVisible:O=!1,size:G=1,fill:Z}=U,z=U.subLabelPlacement||p,L=$e(re=>re.nodes.find(Ie=>Ie.id===C)),B=$e(re=>re.nodes.find(Ie=>Ie.id===D)),H=(G+g.edge.label.fontSize)/2,[W,k]=Q.useMemo(()=>P3(G),[G]),{curveOffset:K,curved:$}=Q.useMemo(()=>CW({edge:U,edges:R,curved:a==="curved"}),[U,R,a]),[j,ee,de]=Q.useMemo(()=>{const re=Wf(L),Ie=L.size,X=Wf(B),F=B.size;let ie=Vf(re,Ie,X,F,$,K);const[Se,ve]=I3(e,ie,W);return e==="end"&&(ie=Vf(re,Ie,Se,0,$,K)),[ie,Se,ve]},[L,B,$,K,e,W]),ae=Q.useMemo(()=>{let re=z3(L.position,B.position,N3(H,r));if($){const Ie=new J().subVectors(re,j.getPoint(.5));switch(r){case"above":Ie.y=Ie.y-yA;break;case"below":Ie.y=Ie.y+yA;break}re=re.sub(Ie)}return re},[L.position,B.position,H,r,$,j]),pe=$e(re=>{var Ie;return(Ie=re.selections)==null?void 0:Ie.includes(s)}),Le=$e(re=>{var Ie;return(Ie=re.selections)==null?void 0:Ie.length}),xe=$e(re=>{var Ie;return(Ie=re.actives)==null?void 0:Ie.includes(s)}),me=$e(re=>re.centerPosition),ne=Le?pe||xe?g.edge.selectedOpacity:g.edge.inactiveOpacity:g.edge.opacity,Ue=Q.useMemo(()=>RW(L.position,B.position,z),[L.position,B.position,z]),[{labelPosition:V}]=yr(()=>({from:{labelPosition:me?[me.x,me.y,me.z]:[0,0,0]},to:{labelPosition:[ae.x,ae.y,ae.z]},config:{..._r,duration:i&&!b?void 0:0}}),[ae,i,b]),se=Q.useMemo(()=>new Ui(0,0,r==="natural"?0:Math.atan((B.position.y-L.position.y)/(B.position.x-L.position.x))),[B.position.x,B.position.y,L.position.x,L.position.y,r]);El(S&&!b&&c!==void 0,"pointer");const{pointerOver:te,pointerOut:Ee}=ob({disabled:n,onPointerOver:re=>{E(!0),f?.(U,re)},onPointerOut:re=>{E(!1),d?.(U,re)}}),ce=Q.useMemo(()=>e!=="none"&&he.jsx(FW,{animated:i,color:pe||S||xe?g.arrow.activeFill:Z||g.arrow.fill,length:W,opacity:ne,position:ee,rotation:de,size:k,onActive:E,onContextMenu:()=>{n||(T(!0),l?.(U))}}),[Z,S,i,W,e,ee,de,k,n,U,xe,pe,l,ne,g.arrow.activeFill,g.arrow.fill]),De=Q.useMemo(()=>{var re,Ie,X,F;return O&&P&&he.jsxs(Bn.group,{position:V,onContextMenu:()=>{n||(T(!0),l?.(U))},onPointerOver:te,onPointerOut:Ee,children:[he.jsx(yu,{text:P,ellipsis:15,fontUrl:o,stroke:g.edge.label.stroke,color:pe||S||xe?g.edge.label.activeColor:g.edge.label.color,opacity:ne,fontSize:g.edge.label.fontSize,rotation:se}),I&&he.jsx("group",{position:[Ue.x,Ue.y,0],children:he.jsx(yu,{text:I,ellipsis:15,fontUrl:o,stroke:((re=g.edge.subLabel)==null?void 0:re.stroke)||g.edge.label.stroke,color:pe||S||xe?((Ie=g.edge.subLabel)==null?void 0:Ie.activeColor)||g.edge.label.activeColor:((X=g.edge.subLabel)==null?void 0:X.color)||g.edge.label.color,opacity:ne,fontSize:((F=g.edge.subLabel)==null?void 0:F.fontSize)||g.edge.label.fontSize*.8,rotation:se})})]})},[S,n,U,xe,pe,P,I,o,V,Ue,se,O,l,Ee,te,ne,g.edge.label.activeColor,g.edge.label.color,g.edge.label.fontSize,g.edge.label.stroke,(m=g.edge.subLabel)==null?void 0:m.stroke,(y=g.edge.subLabel)==null?void 0:y.activeColor,(x=g.edge.subLabel)==null?void 0:x.color,(_=g.edge.subLabel)==null?void 0:_.fontSize]),_e=Q.useMemo(()=>w&&t&&he.jsx(ib,{prepend:!0,center:!0,position:ae,children:t({data:U,onClose:()=>T(!1)})}),[w,t,ae,U]);return he.jsxs("group",{children:[he.jsx(BW,{curveOffset:K,animated:i,color:pe||S||xe?g.edge.activeFill:Z||g.edge.fill,curve:j,curved:$,id:s,opacity:ne,size:G,onClick:re=>{n||c?.(U,re)},onPointerOver:te,onPointerOut:Ee,onContextMenu:()=>{n||(T(!0),l?.(U))}}),ce,De,_e]})},_A=new Ea(0,0,0);function GW(i,e){const t=Q.useRef(null),n=$e(c=>c.theme);$e(c=>{t.current=c});const r=Q.useRef(new Map);Q.useRef(new Ea(0,0,0));const s=Q.useRef(null),a=e==="curved",o=Q.useCallback(c=>{const f=[],d=r.current,{nodes:p}=t.current,m=new Map(p.map(x=>[x.id,x])),y=n.edge.label.fontSize;return i!=="none"&&!s.current&&(s.current=new Su(0,1,1,20,1,!0)),c.forEach(x=>{const{target:_,source:g,size:b=1}=x,S=m.get(g),E=m.get(_);if(!S||!E)return;const w=`${S.position.x},${S.position.y},${E.position.x},${E.position.y},${b}`;if(d.has(w)){f.push(d.get(w));return}const T=Wf(S),R=S.size+y,U=Wf(E),D=E.size+y;let C=Vf(T,R,U,D,a),P=new Rl(C,20,b/2,5,!1);if(i==="none"){f.push(P),d.set(w,P);return}const[I,O]=P3(b),G=s.current.clone();G.scale(O,I,O);const[Z,z]=I3(i,C,I),L=new _i;if(L.setFromUnitVectors(new J(0,1,0),z),G.applyQuaternion(L),G.translate(Z.x,Z.y,Z.z),i&&i==="end"){const H=Vf(T,R,Z,0,a);P=new Rl(H,20,b/2,5,!1)}const B=Wp([P,G]);f.push(B),d.set(w,B)}),f},[i,a,n.edge.label.fontSize]),l=Q.useCallback((c,f)=>{const d=o(c),p=o(f);return Wp([p.length?Wp(p):_A,d.length?Wp(d):_A],!0)},[o]);return{getGeometries:o,getGeometry:l}}function HW(i,e,t){const n=Q.useRef(i);Q.useEffect(()=>{n.current=i},[i]);const r=$e(d=>d.edgeContextMenus),s=$e(Q.useCallback(d=>d.setEdgeContextMenus,[])),a=Q.useRef(!1),o=Q.useCallback(()=>{a.current=!0},[]),l=Q.useRef(!1),c=Q.useCallback(()=>{l.current=!0},[]),f=Q.useCallback((d,p)=>{const{onClick:m,onContextMenu:y,onPointerOver:x,onPointerOut:_}=n.current;if(m&&a.current&&!t){a.current=!1;for(const g of p)m(g)}if((e||y)&&l.current&&!t){l.current=!1;const g=new Set(r);let b=!1;for(const S of p)r.has(S.id)||(g.add(S.id),b=!0,y?.(S));b&&s(g)}x&&p.filter(b=>!d.includes(b)).forEach(b=>{x(b)}),_&&d.filter(b=>!p.includes(b)).forEach(b=>{_(b)})},[e,t,r,s]);return{handleClick:o,handleContextMenu:c,handleIntersections:f}}function VW(i,e){const t=Q.useRef(i),n=Q.useRef(null);Q.useEffect(()=>{t.current=i;const a=i.getAttribute("position");n.current=new Float32Array(a.array.length)},[i]);const r=Q.useCallback(()=>{const a=t.current.getAttribute("position");return{from:new Float32Array(a.array.length),to:a.array}},[]),s=Q.useCallback(a=>{const o=n.current;o.set(a);const l=new en(o,3,!1);t.current.setAttribute("position",l),l.needsUpdate=!0},[]);yr(()=>{if(!e)return null;const a=r();return{from:{positions:a.from},to:{positions:a.to},onChange:o=>{s(o.value.positions)},config:{..._r,duration:e?void 0:0}}},[e,r,s])}function WW(i,e,t){const[{activeOpacity:n,inactiveOpacity:r}]=yr(()=>({from:{activeOpacity:0,inactiveOpacity:0},to:{activeOpacity:e?t.edge.selectedOpacity:t.edge.opacity,inactiveOpacity:e?t.edge.inactiveOpacity:t.edge.opacity},config:{..._r,duration:i?void 0:0}}),[i,e,t]);return{activeOpacity:n,inactiveOpacity:r}}const XW=({animated:i,color:e,contextMenu:t,edge:n,labelFontUrl:r,labelPlacement:s="inline",opacity:a})=>{const o=$e(C=>C.theme),{target:l,source:c,label:f,labelVisible:d=!1,size:p=1}=n,m=$e(C=>C.nodes),[y,x]=Q.useMemo(()=>[m.find(C=>C.id===c),m.find(C=>C.id===l)],[m,c,l]),_=$e(C=>C.draggingIds.length>0),g=Q.useMemo(()=>(p+o.edge.label.fontSize)/2,[p,o.edge.label.fontSize]),b=Q.useMemo(()=>z3(y.position,x.position,N3(g,s)),[y.position,x.position,g,s]),S=$e(C=>C.edgeContextMenus),E=$e(C=>C.setEdgeContextMenus),[{labelPosition:w}]=yr(()=>({from:{labelPosition:[0,0,0]},to:{labelPosition:[b.x,b.y,b.z]},config:{..._r,duration:i&&!_?void 0:0}}),[b,i,_]),T=Q.useCallback(C=>{S.delete(C),E(new Set(S))},[S,E]),R=Q.useMemo(()=>s==="natural"?new Ui(0,0,0):new Ui(0,0,Math.atan2(x.position.y-y.position.y,x.position.x-y.position.x)),[s,x.position.y,x.position.x,y.position.y,y.position.x]),U=Q.useMemo(()=>({prepend:!0,center:!0,position:b}),[b]),D=Q.useMemo(()=>({text:f,ellipsis:15,fontUrl:r,stroke:o.edge.label.stroke,color:e,opacity:a,fontSize:o.edge.label.fontSize,rotation:R}),[f,r,o.edge.label.stroke,e,a,o.edge.label.fontSize,R]);return he.jsxs("group",{children:[d&&f&&he.jsx(Bn.group,{position:w,children:he.jsx(yu,{...D})}),t&&S.has(n.id)&&he.jsx(ib,{...U,children:t({data:n,onClose:()=>T(n.id)})})]})},jW=({interpolation:i="linear",arrowPlacement:e="end",labelPlacement:t="inline",animated:n,contextMenu:r,disabled:s,edges:a,labelFontUrl:o,onClick:l,onContextMenu:c,onPointerOut:f,onPointerOver:d})=>{const p=$e(W=>W.theme),{getGeometries:m,getGeometry:y}=GW(e,i),x=$e(W=>W.draggingIds),_=$e(W=>W.edgeMeshes),g=$e(W=>W.setEdgeMeshes),b=$e(W=>W.actives||[]),S=$e(W=>W.selections||[]),[E,w,T,R]=Q.useMemo(()=>{const W=[],k=[],K=[],$=[];return a.forEach(j=>{if(x.includes(j.source)||x.includes(j.target)){S.includes(j.id)||b.includes(j.id)?K.push(j):$.push(j);return}S.includes(j.id)||b.includes(j.id)?W.push(j):k.push(j)}),[W,k,K,$]},[a,b,S,x]),U=!!S.length,D=Q.useMemo(()=>y(E,w),[y,E,w]),{activeOpacity:C,inactiveOpacity:P}=WW(n,U,p);VW(D,n),Q.useEffect(()=>{if(x.length===0){const k=m(a).map(K=>new pn(K));g(k)}},[m,g,a,x.length]);const I=Q.useRef(new pn),O=Q.useRef(new pn),G=Q.useCallback(W=>{if(!W.camera)return[];const k=W.intersectObjects(_);return k.length?k.map(K=>a[_.indexOf(K.object)]):[]},[_,a]),{handleClick:Z,handleContextMenu:z,handleIntersections:L}=HW({onClick:l,onContextMenu:c,onPointerOut:f,onPointerOver:d},r,s),B=Q.useRef([]),H=Q.useRef([]);return s0(W=>{if(I.current.geometry=D,s)return;const k=B.current;if((x.length||x.length===0&&k!==null)&&(O.current.geometry=y(T,R)),B.current=x,x.length)return;const K=H.current,$=G(W.raycaster);L(K,$),$.join()!==K.join()&&(O.current.geometry=y($,[])),H.current=$}),he.jsxs("group",{onClick:Z,onContextMenu:z,children:[he.jsxs("mesh",{ref:I,children:[he.jsx(Bn.meshBasicMaterial,{attach:"material-0",color:p.edge.fill,depthTest:!1,fog:!0,opacity:P,side:In,transparent:!0}),he.jsx(Bn.meshBasicMaterial,{attach:"material-1",color:p.edge.activeFill,depthTest:!1,fog:!0,opacity:C,side:In,transparent:!0})]}),he.jsxs("mesh",{ref:O,children:[he.jsx(Bn.meshBasicMaterial,{attach:"material-0",color:p.edge.fill,depthTest:!1,fog:!0,opacity:P,side:In,transparent:!0}),he.jsx(Bn.meshBasicMaterial,{attach:"material-1",color:p.edge.activeFill,depthTest:!1,fog:!0,opacity:C,side:In,transparent:!0})]}),a.map(W=>he.jsx(XW,{animated:n,contextMenu:r,color:p.edge.label.color,disabled:s,edge:W,labelFontUrl:o,labelPlacement:t},W.id))]})},qW=({color:i="#D8E6EA",size:e=1,opacity:t=.5,animated:n,strokeWidth:r=5,innerRadius:s=4,segments:a=25})=>{const o=Q.useMemo(()=>new et(i),[i]),{ringSize:l,ringOpacity:c}=yr({from:{ringOpacity:0,ringSize:[1e-5,1e-5,1e-5]},to:{ringOpacity:t,ringSize:[e/2,e/2,1]},config:{..._r,duration:n?void 0:0}}),f=r/10,d=s+f;return he.jsx(v3,{position:[0,0,1],children:he.jsxs(Bn.mesh,{scale:l,children:[he.jsx("ringGeometry",{attach:"geometry",args:[s,d,a]}),he.jsx(Bn.meshBasicMaterial,{attach:"material",color:o,transparent:!0,depthTest:!1,opacity:c,side:In,fog:!0})]})})},YW=({color:i,id:e,size:t,selected:n,opacity:r=1,animated:s})=>{const{scale:a,nodeOpacity:o}=yr({from:{scale:[1e-5,1e-5,1e-5],nodeOpacity:0},to:{scale:[t,t,t],nodeOpacity:r},config:{..._r,duration:s?void 0:0}}),l=Q.useMemo(()=>new et(i),[i]),c=$e(f=>f.theme);return he.jsxs(he.Fragment,{children:[he.jsxs(Bn.mesh,{userData:{id:e,type:"node"},scale:a,children:[he.jsx("sphereGeometry",{attach:"geometry",args:[1,25,25]}),he.jsx(Bn.meshPhongMaterial,{attach:"material",side:In,transparent:!0,fog:!0,opacity:o,color:l,emissive:l,emissiveIntensity:.7})]}),he.jsx(qW,{opacity:n?.5:0,size:t,animated:s,color:n?c.ring.activeFill:c.ring.fill})]})},ZW=({image:i,id:e,size:t,opacity:n=1,animated:r})=>{const s=Q.useMemo(()=>new $2().load(i),[i]),{scale:a,spriteOpacity:o}=yr({from:{scale:[1e-5,1e-5,1e-5],spriteOpacity:0},to:{scale:[t,t,t],spriteOpacity:n},config:{..._r,duration:r?void 0:0}});return he.jsx(Bn.sprite,{userData:{id:e,type:"node"},scale:a,children:he.jsx(Bn.spriteMaterial,{attach:"material",opacity:o,fog:!0,depthTest:!1,transparent:!0,side:In,children:he.jsx("primitive",{attach:"map",object:s,minFilter:Pn})})})},KW=({animated:i,disabled:e,id:t,draggable:n=!1,labelFontUrl:r,contextMenu:s,onClick:a,onDoubleClick:o,onPointerOver:l,onDragged:c,onPointerOut:f,onContextMenu:d,renderNode:p,constrainDragging:m})=>{var y,x,_;const g=x0(),b=$e(F=>F.theme),S=$e(F=>F.nodes.find(ie=>ie.id===t)),E=$e(F=>F.edges),w=$e(F=>F.draggingIds),T=$e(F=>F.collapsedNodeIds),R=$e(F=>F.addDraggingId),U=$e(F=>F.removeDraggingId),D=$e(F=>F.setHoveredNodeId),C=$e(F=>F.setNodePosition),P=$e(F=>F.setCollapsedNodeIds),I=$e(F=>F.collapsedNodeIds.includes(t)),O=$e(F=>{var ie;return(ie=F.actives)==null?void 0:ie.includes(t)}),G=$e(F=>{var ie;return(ie=F.selections)==null?void 0:ie.includes(t)}),Z=$e(F=>{var ie;return((ie=F.selections)==null?void 0:ie.length)>0}),z=$e(F=>F.centerPosition),L=$e(F=>F.clusters.get(S.cluster)),B=w.includes(t),H=w.length>0,{position:W,label:k,subLabel:K,size:$=7,labelVisible:j=!0}=S,ee=Q.useRef(null),[de,ae]=Q.useState(!1),[pe,Le]=Q.useState(!1),xe=de||G||O,me=Z?xe?b.node.selectedOpacity:b.node.inactiveOpacity:b.node.opacity,ne=Q.useMemo(()=>E.filter(ie=>ie.source===t).length>0||I,[E,t,I]),Ue=Q.useCallback(()=>{ne&&P(I?T.filter(F=>F!==t):[...T,t])},[ne,T,t,I,P]),[{nodePosition:V,labelPosition:se}]=yr(()=>({from:{nodePosition:z?[z.x,z.y,0]:[0,0,0],labelPosition:[0,-($+7),2]},to:{nodePosition:W?[W.x,W.y,xe?W.z+1:W.z]:[0,0,0],labelPosition:[0,-($+7),2]},config:{..._r,duration:i&&!H?void 0:0}}),[B,W,i,$,xe]),te=H3({draggable:n,position:W,bounds:m?L?.position:void 0,set:F=>C(t,F),onDragStart:()=>{R(t),ae(!0)},onDragEnd:()=>{U(t),c?.(S)}});El(de&&!H&&a!==void 0,"pointer"),El(de&&n&&!B&&a===void 0,"grab"),El(B,"grabbing");const Ee=xe||B,ce=Ee?b.node.activeFill:S.fill||b.node.fill,{pointerOver:De,pointerOut:_e}=ob({disabled:e||B,onPointerOver:F=>{g.freeze(),ae(!0),l?.(S,F),D(t)},onPointerOut:F=>{g.unFreeze(),ae(!1),f?.(S,F),D(null)}}),re=Q.useMemo(()=>p?p({id:t,color:ce,size:$,active:Ee,opacity:me,animated:i,selected:G,node:S}):he.jsx(he.Fragment,{children:S.icon?he.jsx(ZW,{id:t,image:S.icon||"",size:$+8,opacity:me,animated:i,color:ce,node:S,active:Ee,selected:G}):he.jsx(YW,{id:t,size:$,opacity:me,animated:i,color:ce,node:S,active:Ee,selected:G})}),[p,t,ce,$,Ee,me,i,G,S]),Ie=Q.useMemo(()=>{var F,ie,Se;return j&&(j||G||de)&&k&&he.jsxs(Bn.group,{position:se,children:[he.jsx(yu,{text:k,fontUrl:r,opacity:me,stroke:b.node.label.stroke,active:G||de||B||O,color:G||de||B||O?b.node.label.activeColor:b.node.label.color}),K&&he.jsx("group",{position:[0,-($-3),0],children:he.jsx(yu,{text:K,fontUrl:r,fontSize:5,opacity:me,stroke:(F=b.node.subLabel)==null?void 0:F.stroke,active:G||de||B||O,color:G||de||B||O?(ie=b.node.subLabel)==null?void 0:ie.activeColor:(Se=b.node.subLabel)==null?void 0:Se.color})})]})},[de,O,B,G,k,r,se,j,$,me,K,b.node.label.activeColor,b.node.label.color,b.node.label.stroke,(y=b.node.subLabel)==null?void 0:y.activeColor,(x=b.node.subLabel)==null?void 0:x.color,(_=b.node.subLabel)==null?void 0:_.stroke]),X=Q.useMemo(()=>pe&&s&&he.jsx(ib,{prepend:!0,center:!0,children:s({data:S,canCollapse:ne,isCollapsed:I,onCollapse:Ue,onClose:()=>Le(!1)})}),[pe,s,S,ne,I,Ue]);return he.jsxs(Bn.group,{renderOrder:1,userData:{id:t,type:"node"},ref:ee,position:V,onPointerOver:De,onPointerOut:_e,onClick:F=>{!e&&!B&&a?.(S,{canCollapse:ne,isCollapsed:I},F)},onDoubleClick:F=>{!e&&!B&&o?.(S,F)},onContextMenu:()=>{e||(Le(!0),d?.(S,{canCollapse:ne,isCollapsed:I,onCollapse:Ue}))},...te(),children:[re,X,Ie]})};function W3(i,e){const t=e.position.z;i<t?i-=t:i+=t;const n=e.fov/e.zoom*Math.PI/180;return 2*Math.tan(n/2)*Math.abs(i)}function JW(i,e){return W3(i,e)*e.aspect}function xA(i,e){var t,n,r,s;const a=JW(1,i),o=W3(1,i),l={x0:((t=i?.position)==null?void 0:t.x)-a/2,x1:((n=i?.position)==null?void 0:n.x)+a/2,y0:((r=i?.position)==null?void 0:r.y)-o/2,y1:((s=i?.position)==null?void 0:s.y)+o/2};return e?.x>l.x0&&e?.x<l.x1&&e?.y>l.y0&&e?.y<l.y1}function bA(i,e){return e.reduce((t,n)=>Math.abs(n-i%Math.PI)<Math.abs(t-i%Math.PI)?n:t)}function QW(i,e){const t=bA(i,[0,Math.PI]),n=bA(e,[Math.PI/2,3*Math.PI/2]);return{horizontalRotation:t-i%Math.PI,verticalRotation:n-e%Math.PI}}const $p=50,$W=({animated:i,disabled:e,layoutType:t})=>{const n=$e(x=>x.nodes),[r,s]=Q.useState(!1),a=Kn(x=>x.invalidate),{controls:o}=x0(),l=Kn(x=>x.camera),c=Q.useRef(!1),f=Q.useCallback(async(x,_)=>{const g=_?.animated!==void 0?_?.animated:!0,b=_?.centerOnlyIfNodesNotInView!==void 0?_?.centerOnlyIfNodesNotInView:!1;if(!c.current||!b||b&&x?.some(S=>!xA(l,S.position))){const{x:S,y:E,z:w}=Xf(x);await o.setTarget(S,E,w,g),r||s(!0),a()}},[a,o,n]),d=Q.useCallback(async(x,_={animated:!0,fitOnlyIfNodesNotInView:!1})=>{const{fitOnlyIfNodesNotInView:g}=_;if(!g||g&&x?.some(b=>!xA(l,b.position))){const{minX:b,maxX:S,minY:E,maxY:w,minZ:T,maxZ:R}=Xf(x);if(!t.includes("3d")){const{horizontalRotation:U,verticalRotation:D}=QW(o?.azimuthAngle,o?.polarAngle);o?.rotate(U,D,!0)}await o?.zoomTo(1,_?.animated),await o?.fitToBox(new Jn(new J(b,E,T),new J(S,w,R)),_?.animated,{cover:!1,paddingLeft:$p,paddingRight:$p,paddingBottom:$p,paddingTop:$p})}},[l,o,t]),p=Q.useCallback(x=>{let _=null;return x?.length&&(_=x.reduce((g,b)=>{const S=n.find(E=>E.id===b);if(S)g.push(S);else throw new Error(`Attempted to center ${b} but it was not found in the nodes`);return g},[])),_},[n]),m=Q.useCallback((x,_)=>{const g=p(x);f(g||n,{animated:i,centerOnlyIfNodesNotInView:_?.centerOnlyIfNodesNotInView})},[i,f,p,n]),y=Q.useCallback(async(x,_)=>{const g=p(x);await d(g||n,{animated:i,..._})},[i,d,p,n]);return Q.useLayoutEffect(()=>{async function x(){o&&n?.length&&(c.current||(await f(n,{animated:!1}),await d(n,{animated:!1}),c.current=!0))}x()},[o,f,n,i,l,d]),{centerNodes:f,centerNodesById:m,fitNodesInViewById:y,isCentered:r}},eX=i=>i.reduceEdges((e,t,n,r,s)=>{const a=`${r}-${s}`,o={id:t,source:r,target:s,...n},l=e.get(a);return l?l.push(o):e.set(a,[o]),e},new Map),tX=(i,e)=>{if(!i||i.size===0)return[];const t=eX(i),n=[],r=e==="all"||e==="edges";for(const[s,a]of t){const[o,l]=s.split("-"),c=a[0];if(!o||!l||!c)continue;const f=c.size||1,d=f+a.length*f*.5,p={...c,source:o,target:l,label:`${a.length} edges`,labelVisible:r,size:d,data:{...c.data||{},originalEdges:a,count:a.length,isAggregated:!0,originalSize:f}};n.push(p)}return n},nX=Q.forwardRef(({onNodeClick:i,onNodeDoubleClick:e,onNodeContextMenu:t,onEdgeContextMenu:n,onEdgeClick:r,onEdgePointerOver:s,onEdgePointerOut:a,onNodePointerOver:o,onNodePointerOut:l,onClusterClick:c,onNodeDragged:f,onClusterDragged:d,onClusterPointerOver:p,onClusterPointerOut:m,contextMenu:y,animated:x,disabled:_,draggable:g,constrainDragging:b=!1,edgeLabelPosition:S,edgeArrowPosition:E,edgeInterpolation:w="linear",labelFontUrl:T,renderNode:R,onRenderCluster:U,aggregateEdges:D,...C},P)=>{const{layoutType:I,clusterAttribute:O,labelType:G}=C,Z=Kn(ne=>ne.gl),z=Kn(ne=>ne.scene),L=Kn(ne=>ne.camera),{updateLayout:B}=IW({...C,constrainDragging:b});if(O&&!(I==="forceDirected2d"||I==="forceDirected3d"))throw new Error("Clustering is only supported for the force directed layouts.");const H=$e(ne=>ne.graph),W=$e(ne=>ne.nodes),k=$e(ne=>ne.edges),K=$e(ne=>ne.setEdges),$=$e(ne=>[...ne.clusters.values()]),j=Q.useMemo(()=>D?tX(H,G):k,[k,D,H,G]);Q.useEffect(()=>{D&&k.length!==j.length&&K(j)},[j,k.length,K,D]);const{centerNodesById:ee,fitNodesInViewById:de,isCentered:ae}=$W({animated:x,disabled:_,layoutType:I});Q.useImperativeHandle(P,()=>({centerGraph:ee,fitNodesInView:de,graph:H,renderScene:()=>Z.render(z,L)}),[ee,de,H,Z,z,L]);const pe=Q.useCallback(ne=>{f?.(ne),O&&B()},[O,f,B]),Le=Q.useMemo(()=>W.map(ne=>he.jsx(KW,{id:ne?.id,labelFontUrl:T,draggable:g,constrainDragging:b,disabled:_,animated:x,contextMenu:y,renderNode:R,onClick:i,onDoubleClick:e,onContextMenu:t,onPointerOver:o,onPointerOut:l,onDragged:pe},ne?.id)),[b,x,y,_,g,T,W,i,t,e,pe,l,o,R]),xe=Q.useMemo(()=>x?j.map(ne=>he.jsx(kW,{id:ne.id,disabled:_,animated:x,labelFontUrl:T,labelPlacement:S,arrowPlacement:E,interpolation:w,contextMenu:y,onClick:r,onContextMenu:n,onPointerOver:s,onPointerOut:a},ne.id)):he.jsx(jW,{edges:j,disabled:_,animated:x,labelFontUrl:T,labelPlacement:S,arrowPlacement:E,interpolation:w,contextMenu:y,onClick:r,onContextMenu:n,onPointerOver:s,onPointerOut:a}),[x,y,_,E,w,S,j,T,r,n,a,s]),me=Q.useMemo(()=>$.map(ne=>he.jsx(zW,{animated:x,disabled:_,draggable:g,labelFontUrl:T,onClick:c,onPointerOver:p,onPointerOut:m,onDragged:d,onRender:U,...ne},ne.label)),[x,$,_,g,T,c,m,p,d,U]);return ae&&he.jsxs(Q.Fragment,{children:[xe,Le,me]})});di.install({THREE:{MOUSE:EA,Vector2:Ge,Vector3:J,Vector4:kt,Quaternion:_i,Matrix4:bt,Spherical:dC,Box3:Jn,Sphere:ri,Raycaster:_1,MathUtils:{DEG2RAD:(cA=Jm)==null?void 0:cA.DEG2RAD,clamp:(uA=Jm)==null?void 0:uA.clamp}}});PC({ThreeCameraControls:di});const em={ARROW_LEFT:37,ARROW_UP:38,ARROW_RIGHT:39,ARROW_DOWN:40},iX=Q.forwardRef(({mode:i="rotate",children:e,animated:t,disabled:n,minDistance:r=1e3,maxDistance:s=5e4},a)=>{const o=Q.useRef(null),l=Kn(O=>O.camera),c=Kn(O=>O.gl),f=i==="orbit",d=$e(O=>O.setPanning),p=$e(O=>O.draggingIds.length>0),m=Q.useRef(0),[y,x]=Q.useState(!1);s0((O,G)=>{var Z,z;(Z=o.current)!=null&&Z.enabled&&((z=o.current)==null||z.update(G)),f&&(o.current.azimuthAngle+=20*G*Jm.DEG2RAD)},-1),Q.useEffect(()=>()=>{var O;return(O=o.current)==null?void 0:O.dispose()},[]);const _=Q.useCallback(()=>{var O;(O=o.current)==null||O.zoom(l.zoom/2,t)},[t,l.zoom]),g=Q.useCallback(()=>{var O;(O=o.current)==null||O.zoom(-l.zoom/2,t)},[t,l.zoom]),b=Q.useCallback(O=>{var G;(G=o.current)==null||G.dolly(O,t)},[t]),S=Q.useCallback(O=>{var G;(G=o.current)==null||G.dolly(O,t)},[t]),E=Q.useCallback(O=>{var G;f||(G=o.current)==null||G.truck(-.03*O.deltaTime,0,t)},[t,f]),w=Q.useCallback(O=>{var G;f||(G=o.current)==null||G.truck(.03*O.deltaTime,0,t)},[t,f]),T=Q.useCallback(O=>{var G;f||(G=o.current)==null||G.truck(0,.03*O.deltaTime,t)},[t,f]),R=Q.useCallback(O=>{var G;f||(G=o.current)==null||G.truck(0,-.03*O.deltaTime,t)},[t,f]),U=Q.useCallback(O=>{O.code==="Space"&&(i==="rotate"?o.current.mouseButtons.left=di.ACTION.TRUCK:o.current.mouseButtons.left=di.ACTION.ROTATE)},[i]),D=Q.useCallback(O=>{O.code==="Space"&&(i==="rotate"?o.current.mouseButtons.left=di.ACTION.ROTATE:o.current.mouseButtons.left=di.ACTION.TRUCK)},[i]),[C,P]=Q.useState(null);Q.useEffect(()=>{ab||P({leftKey:new Qp(em.ARROW_LEFT,100),rightKey:new Qp(em.ARROW_RIGHT,100),upKey:new Qp(em.ARROW_UP,100),downKey:new Qp(em.ARROW_DOWN,100)})},[]),Q.useEffect(()=>(!n&&C&&(C.leftKey.addEventListener("holding",w),C.rightKey.addEventListener("holding",E),C.upKey.addEventListener("holding",T),C.downKey.addEventListener("holding",R),window.addEventListener("keydown",U),window.addEventListener("keyup",D)),()=>{C&&(C.leftKey.removeEventListener("holding",w),C.rightKey.removeEventListener("holding",E),C.upKey.removeEventListener("holding",T),C.downKey.removeEventListener("holding",R),window.removeEventListener("keydown",U),window.removeEventListener("keyup",D))}),[n,U,D,R,w,E,T,C]),Q.useEffect(()=>{n?(o.current.mouseButtons.left=di.ACTION.NONE,o.current.mouseButtons.middle=di.ACTION.NONE,o.current.mouseButtons.wheel=di.ACTION.NONE):(o.current.mouseButtons.left=di.ACTION.TRUCK,o.current.mouseButtons.middle=di.ACTION.TRUCK,o.current.mouseButtons.wheel=di.ACTION.DOLLY)},[n]),Q.useEffect(()=>{const O=()=>d(!0),G=()=>d(!1),Z=o.current;return Z&&(Z.addEventListener("control",O),Z.addEventListener("controlend",G)),()=>{Z&&(Z.removeEventListener("control",O),Z.removeEventListener("controlend",G))}},[o,d]),Q.useEffect(()=>{p?(o.current.mouseButtons.left=di.ACTION.NONE,o.current.touches.one=di.ACTION.NONE):i==="rotate"?(o.current.mouseButtons.left=di.ACTION.ROTATE,o.current.touches.one=di.ACTION.TOUCH_ROTATE):(o.current.touches.one=di.ACTION.TOUCH_TRUCK,o.current.mouseButtons.left=di.ACTION.TRUCK)},[p,i]);const I=Q.useMemo(()=>({controls:o.current,zoomIn:()=>_(),zoomOut:()=>g(),dollyIn:(O=1e3)=>b(O),dollyOut:(O=-1e3)=>S(O),panLeft:(O=100)=>w({deltaTime:O}),panRight:(O=100)=>E({deltaTime:O}),panDown:(O=100)=>R({deltaTime:O}),panUp:(O=100)=>T({deltaTime:O}),resetControls:O=>{var G;return(G=o.current)==null?void 0:G.reset(O)},freeze:()=>{o.current.truckSpeed&&(m.current=o.current.truckSpeed),o.current.truckSpeed=0},unFreeze:()=>o.current.truckSpeed=m.current}),[_,g,w,E,R,T,o.current]);return Q.useImperativeHandle(a,()=>I),he.jsxs(V3.Provider,{value:I,children:[he.jsx("threeCameraControls",{ref:O=>{o.current=O,y||x(!0)},args:[l,c.domElement],smoothTime:.1,minDistance:r,dollyToCursor:!0,maxDistance:s}),e]})}),X3={canvas:{background:"#fff"},node:{fill:"#7CA0AB",activeFill:"#1DE9AC",opacity:1,selectedOpacity:1,inactiveOpacity:.2,label:{color:"#2A6475",stroke:"#fff",activeColor:"#1DE9AC"},subLabel:{color:"#ddd",stroke:"transparent",activeColor:"#1DE9AC"}},lasso:{border:"1px solid #55aaff",background:"rgba(75, 160, 255, 0.1)"},ring:{fill:"#D8E6EA",activeFill:"#1DE9AC"},edge:{fill:"#D8E6EA",activeFill:"#1DE9AC",opacity:1,selectedOpacity:1,inactiveOpacity:.1,label:{stroke:"#fff",color:"#2A6475",activeColor:"#1DE9AC",fontSize:6},subLabel:{color:"#ddd",stroke:"transparent",activeColor:"#1DE9AC"}},arrow:{fill:"#D8E6EA",activeFill:"#1DE9AC"},cluster:{stroke:"#D8E6EA",opacity:1,selectedOpacity:1,inactiveOpacity:.1,label:{stroke:"#fff",color:"#2A6475"}}};function z_(i,e,t){e=Array.isArray(e)?e:[e];const n=[],r=[];for(const s of e){const a=[...i.inEdgeEntries(s)??[],...i.outEdgeEntries(s)??[]];if(a)for(const o of a){const l=o.attributes.id;if(t==="in"?o.target===s&&!r.includes(l)&&r.push(l):t==="out"?o.source===s&&!r.includes(l)&&r.push(l):r.includes(l)||r.push(l),t==="out"||t==="all"){const c=o.target;n.includes(c)||n.push(c)}(t==="in"||t==="all")&&(n.includes(o.source)||n.push(o.source))}}return{nodes:n,edges:r}}function tm(i,e,t){const{offsetX:n,offsetY:r}=i,{width:s,height:a}=t;e.set(n/s*2-1,-(r/a)*2+1)}function rX(i){const e=document.createElement("div");return e.style.pointerEvents="none",e.style.border=i.lasso.border,e.style.backgroundColor=i.lasso.background,e.style.position="fixed",e}const sX=({children:i,type:e="none",onLasso:t,onLassoEnd:n,disabled:r})=>{var s;const a=$e(I=>I.theme),o=Kn(I=>I.camera),l=Kn(I=>I.gl),c=Kn(I=>I.setEvents),f=Kn(I=>I.size),d=Kn(I=>I.get),p=Kn(I=>I.scene),m=x0(),y=$e(I=>I.actives),x=$e(I=>I.setActives),_=$e(I=>I.edges),g=$e(I=>I.edgeMeshes),b=Q.useRef(null),S=Q.useRef(null),E=Q.useRef(rX(a)),w=Q.useRef(null),T=Q.useRef(!1),R=Q.useRef(d().events.enabled),U=Q.useRef((s=m.controls)==null?void 0:s.enabled),D=Q.useCallback(I=>{if(T.current){const[O,G,Z]=w.current;Z.x=Math.max(O.x,I.clientX),Z.y=Math.max(O.y,I.clientY),G.x=Math.min(O.x,I.clientX),G.y=Math.min(O.y,I.clientY),E.current.style.left=`${G.x}px`,E.current.style.top=`${G.y}px`,E.current.style.width=`${Z.x-G.x}px`,E.current.style.height=`${Z.y-G.y}px`,tm(I,b.current.endPoint,f),tm(I,S.current.endPoint,f);const z=[],L=S.current.select().sort(H=>H.uuid).map(H=>_[g.indexOf(H)].id);z.push(...L);const B=b.current.select().sort(H=>H.uuid).filter(H=>{var W,k;return H.isMesh&&((W=H.userData)==null?void 0:W.id)&&(((k=H.userData)==null?void 0:k.type)===e||e==="all")}).map(H=>H.userData.id);z.push(...B),requestAnimationFrame(()=>{x(z),t?.(z)}),document.addEventListener("pointermove",D,{passive:!0,capture:!0,once:!0})}},[f,_,g,e,x,t]),C=Q.useCallback(()=>{var I;T.current&&(c({enabled:R.current}),T.current=!1,(I=E.current.parentElement)==null||I.removeChild(E.current),m.controls.enabled=U.current,n?.(y),document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",C))},[c,m.controls,n,y,D]),P=Q.useCallback(I=>{var O,G;if(I.shiftKey){R.current=d().events.enabled,U.current=(O=m.controls)==null?void 0:O.enabled,b.current=new FT(o,p);const Z=new zg;g.length&&Z.add(...g),S.current=new FT(o,Z),w.current=[new Ge,new Ge,new Ge];const[z]=w.current;m.controls.enabled=!1,c({enabled:!1}),T.current=!0,(G=l.domElement.parentElement)==null||G.appendChild(E.current),E.current.style.left=`${I.clientX}px`,E.current.style.top=`${I.clientY}px`,E.current.style.width="0px",E.current.style.height="0px",z.x=I.clientX,z.y=I.clientY,tm(I,b.current.startPoint,f),tm(I,S.current.startPoint,f),document.addEventListener("pointermove",D,{passive:!0,capture:!0,once:!0}),document.addEventListener("pointerup",C,{passive:!0})}},[o,m.controls,g,d,l.domElement.parentElement,D,C,p,c,f]);return Q.useEffect(()=>{if(!(r||e==="none"))return typeof window<"u"&&(document.addEventListener("pointerdown",P,{passive:!0}),document.addEventListener("pointermove",D,{passive:!0}),document.addEventListener("pointerup",C,{passive:!0})),()=>{typeof window<"u"&&(document.removeEventListener("pointerdown",P),document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",C))}},[e,r,P,D,C]),he.jsx("group",{children:i})},aX="_canvas_670zp_1",oX={canvas:aX},lX={alpha:!0,antialias:!0},cX={position:[0,0,1e3],near:5,far:5e4,fov:10},uX=Q.forwardRef(({cameraMode:i="pan",layoutType:e="forceDirected2d",sizingType:t="default",labelType:n="auto",theme:r=X3,animated:s=!0,defaultNodeSize:a=7,minNodeSize:o=5,maxNodeSize:l=15,lassoType:c="none",glOptions:f={},edges:d,children:p,nodes:m,minDistance:y,maxDistance:x,onCanvasClick:_,disabled:g,onLasso:b,onLassoEnd:S,aggregateEdges:E,...w},T)=>{var R,U;const D=Q.useRef(null),C=Q.useRef(null),P=Q.useRef(null);Q.useImperativeHandle(T,()=>({centerGraph:(B,H)=>{var W;return(W=D.current)==null?void 0:W.centerGraph(B,H)},fitNodesInView:(B,H)=>{var W;return(W=D.current)==null?void 0:W.fitNodesInView(B,H)},zoomIn:()=>{var B;return(B=C.current)==null?void 0:B.zoomIn()},zoomOut:()=>{var B;return(B=C.current)==null?void 0:B.zoomOut()},dollyIn:B=>{var H;return(H=C.current)==null?void 0:H.dollyIn(B)},dollyOut:B=>{var H;return(H=C.current)==null?void 0:H.dollyOut(B)},panLeft:()=>{var B;return(B=C.current)==null?void 0:B.panLeft()},panRight:()=>{var B;return(B=C.current)==null?void 0:B.panRight()},panDown:()=>{var B;return(B=C.current)==null?void 0:B.panDown()},panUp:()=>{var B;return(B=C.current)==null?void 0:B.panUp()},resetControls:B=>{var H;return(H=C.current)==null?void 0:H.resetControls(B)},getControls:()=>{var B;return(B=C.current)==null?void 0:B.controls},getGraph:()=>{var B;return(B=D.current)==null?void 0:B.graph},exportCanvas:()=>(D.current.renderScene(),P.current.toDataURL()),freeze:()=>{var B;return(B=C.current)==null?void 0:B.freeze()},unFreeze:()=>{var B;return(B=C.current)==null?void 0:B.unFreeze()}}));const{selections:I,actives:O,collapsedNodeIds:G}=w,Z=d.length+m.length>400?!1:s,z=Q.useMemo(()=>({...f,...lX}),[f]),L=Q.useRef(F3({selections:I,actives:O,theme:r,collapsedNodeIds:G})).current;return he.jsx("div",{className:oX.canvas,children:he.jsx(U5,{legacy:!0,linear:!0,ref:P,flat:!0,gl:z,camera:cX,onPointerMissed:_,children:he.jsxs(LW,{store:L,children:[((R=r.canvas)==null?void 0:R.background)&&he.jsx("color",{attach:"background",args:[r.canvas.background]}),he.jsx("ambientLight",{intensity:1}),p,((U=r.canvas)==null?void 0:U.fog)&&he.jsx("fog",{attach:"fog",args:[r.canvas.fog,4e3,9e3]}),he.jsx(iX,{mode:i,ref:C,disabled:g,minDistance:y,maxDistance:x,animated:s,children:he.jsx(sX,{disabled:g,type:c,onLasso:b,onLassoEnd:S,children:he.jsx(Q.Suspense,{children:he.jsx(nX,{ref:D,disabled:g,animated:Z,edges:d,nodes:m,layoutType:e,sizingType:t,labelType:n,defaultNodeSize:a,minNodeSize:o,maxNodeSize:l,aggregateEdges:E,...w})})})})]})})})}),hX=({selections:i=[],nodes:e=[],actives:t=[],focusOnSelect:n=!0,type:r="single",pathHoverType:s="out",pathSelectionType:a="direct",ref:o,disabled:l,onSelection:c})=>{const[f,d]=Q.useState([]),[p,m]=Q.useState(t),[y,x]=Q.useState(i),[_,g]=Q.useState(!1),b=r==="multi"||r==="multiModifier",S=Q.useCallback(L=>{if(!l&&L){L=Array.isArray(L)?L:[L];const B=L.filter(H=>!y.includes(H));if(B.length){const H=[...y,...B];c?.(H),x(H)}}},[l,y,c]),E=Q.useCallback(L=>{if(!l&&L){L=Array.isArray(L)?L:[L];const B=y.filter(H=>!L.includes(H));c?.(B),x(B)}},[l,y,c]),w=Q.useCallback((L=[])=>{l||(L=Array.isArray(L)?L:[L],m([]),x(L),c?.(L))},[l,c]),T=Q.useCallback(L=>{y.includes(L)?E(L):b?S(L):w(L)},[S,w,y,b,E]),R=Q.useCallback(L=>{if(b?r==="multiModifier"?_?S(L.id):w(L.id):S(L.id):w(L.id),n===!0||n==="singleOnly"&&!_){if(!o.current)throw new Error("No ref found for the graph canvas.");const B=o.current.getGraph(),{nodes:H}=z_(B,[L.id],a);o.current.fitNodesInView([L.id,...H],{fitOnlyIfNodesNotInView:!0})}},[S,w,n,b,_,a,o,r]),U=Q.useCallback((L,B)=>{const H=o.current.getGraph();if(!H)throw new Error("Graph is not initialized");const W=OW(H,L,B);w([L,B]);const k=[];for(let K=0;K<W.length-1;K++){const $=W[K],j=W[K+1],ee=H.getEdgeAttributes($,j);ee&&k.push(ee.id)}m([...W.map(K=>K),...k])},[w,o]),D=Q.useCallback(L=>{const B=L.target,H=vA(B),W=L.metaKey||L.ctrlKey;H&&W&&g(!0)},[]),C=Q.useCallback(L=>{const B=L.target,H=vA(B),W=["Meta","Control"].includes(L.key);H&&W&&g(!1)},[]);Q.useEffect(()=>(typeof window<"u"&&(window.addEventListener("keydown",D),window.addEventListener("keyup",C)),()=>{typeof window<"u"&&(window.removeEventListener("keydown",D),window.removeEventListener("keyup",C))}),[D,C]);const P=Q.useCallback(L=>{if(L.button!==2&&(y.length||p.length)&&(w(),g(!1),n&&y.length===1)){if(!o.current)throw new Error("No ref found for the graph canvas.");o.current.fitNodesInView([],{fitOnlyIfNodesNotInView:!0})}},[w,n,p.length,y.length,o]),I=Q.useCallback(L=>{m(L)},[]),O=Q.useCallback(L=>{w(L)},[w]),G=Q.useCallback(L=>{if(s){const B=o.current.getGraph();if(!B)throw new Error("No ref found for the graph canvas.");const{nodes:H,edges:W}=z_(B,[L.id],s);d([...H,...W])}},[s,o]),Z=Q.useCallback(()=>{s&&d([])},[s]);return Q.useEffect(()=>{var L;if(a!=="direct"&&y.length>0){const B=(L=o.current)==null?void 0:L.getGraph();if(B){const{nodes:H,edges:W}=z_(B,y,a);m([...H,...W])}}},[y,a,o]),{actives:Q.useMemo(()=>[...p,...f],[p,f]),onNodeClick:R,onNodePointerOver:G,onNodePointerOut:Z,onLasso:I,onLassoEnd:O,selectNodePaths:U,onCanvasClick:P,selections:y,clearSelections:w,addSelection:S,removeSelection:E,toggleSelection:T,setSelections:x}},fX=""+new URL("NotoSans-Regular-D96CXwz4.ttf",import.meta.url).href,dX=Q.memo(({data:i,onCollapse:e,isCollapsed:t,canCollapse:n,onClose:r})=>{const{t:s}=bg(["network","zigbee","common"]);let a;if(i.parent){const o=i.parent.lastIndexOf(` - ${s("children")}`);a=o>-1?i.parent.slice(0,o):i.parent}return he.jsx("div",{className:"card bg-base-100 shadow-sm",children:he.jsxs("div",{className:"card-body",children:[he.jsx("h2",{className:"card-title",children:i.friendlyName}),he.jsx("span",{children:i.type}),he.jsx("span",{title:s("zigbee:ieee_address"),children:i.ieeeAddr}),he.jsxs("span",{title:s("zigbee:network_address_hex"),className:"justify-self-end",children:[WU(i.networkAddress,4)," | ",he.jsx("span",{title:s("zigbee:network_address_dec"),children:i.networkAddress})]}),a&&he.jsxs("span",{children:[s("parent"),": ",a]}),i.failed&&i.failed.length>0&&he.jsxs("div",{className:"badge badge-ghost",children:[he.jsx(ni,{icon:XU,className:"text-error",beatFade:!0}),s("common:failed"),": ",i.failed]}),he.jsxs("div",{className:"card-actions justify-end mt-2",children:[n&&he.jsx(ts,{className:"btn btn-square btn-primary",onClick:e,children:he.jsx(ni,{icon:t?jU:qU})}),he.jsx(ts,{className:"btn btn-square btn-neutral",onClick:r,children:he.jsx(ni,{icon:YU})})]})]})})}),SA=Q.memo(i=>{const{label:e,icon:t,onChange:n,onSubmit:r,defaultValue:s,...a}=i,[o,l]=Q.useState(s);Q.useEffect(()=>{l(s)},[s]);const c=Q.useCallback(d=>{l(d.target.value?d.target.valueAsNumber:""),n?.(d)},[n]),f=Q.useCallback(d=>{r?.(o,!d.target.validationMessage)},[r,o]);return he.jsxs("div",{className:"flex flex-row flex-wrap items-center gap-2 bg-base-100 rounded-box px-2 pb-1",title:e,children:[he.jsx(ni,{icon:t}),he.jsxs("div",{className:"",children:[he.jsx("input",{className:"range range-xs",onChange:c,onTouchEnd:f,onMouseUp:f,...a,type:"range",value:o}),he.jsxs("div",{className:"flex justify-between px-1 mt-1 text-xs",children:[he.jsx("span",{children:i.min}),he.jsx("span",{children:o}),he.jsx("span",{children:i.max})]})]})]})}),pX=Q.memo(({graphRef:i,layoutType:e,onLayoutTypeChange:t,labelType:n,onLabelTypeChange:r,nodeStrength:s,onNodeStrengthChange:a,linkDistance:o,onLinkDistanceChange:l,nodes:c,showParents:f,setShowParents:d,showChildren:p,setShowChildren:m,showSiblings:y,setShowSiblings:x})=>{const{t:_}=bg("network"),g=Q.useMemo(()=>{const E=c.map(w=>[w.id,w.data.type!=="Coordinator"?`${w.data.type[0]} - ${w.label}`:w.label]);return E.sort(([,w],[,T])=>w.localeCompare(T)),E.map(([w,T])=>he.jsx("option",{value:w,children:T},w))},[c]),b=Q.useCallback(()=>{i.current&&ZU(i.current.exportCanvas(),`network-map-${Date.now()}.png`)},[i]),S=Q.useCallback(E=>{if(E.target.value){const w=[E.target.value];i.current?.centerGraph(w),i.current?.fitNodesInView(w)}},[i]);return he.jsxs(he.Fragment,{children:[he.jsxs("div",{className:"absolute z-9 top-0 left-0 p-1 flex flex-row flex-wrap gap-1 items-start",children:[he.jsx(ts,{title:_("download_image"),className:"btn btn-square btn-neutral btn-sm",onClick:b,children:he.jsx(ni,{icon:KU})}),he.jsx(ts,{title:_("reset_controls"),className:"btn btn-square btn-neutral btn-sm",onClick:()=>{i.current?.resetControls()},children:he.jsx(ni,{icon:JU})}),he.jsx(ts,{title:_("fit_view"),className:"btn btn-square btn-neutral btn-sm",onClick:()=>{i.current?.centerGraph(),i.current?.fitNodesInView()},children:he.jsx(ni,{icon:QU})}),he.jsx(ts,{title:_("zoom_in"),className:"btn btn-square btn-neutral btn-sm",onClick:()=>{i.current?.zoomIn()},children:he.jsx(ni,{icon:$U})}),he.jsx(ts,{title:_("zoom_out"),className:"btn btn-square btn-neutral btn-sm",onClick:()=>{i.current?.zoomOut()},children:he.jsx(ni,{icon:eO})}),he.jsx(ts,{className:`btn btn-square btn-neutral btn-sm ${f?"":"btn-outline"}`,item:!f,onClick:d,title:_("parent"),children:he.jsx(ni,{icon:Qc,style:{color:yl[ti.NeighborIsParent]}})}),he.jsx(ts,{className:`btn btn-square btn-neutral btn-sm ${p?"":"btn-outline"}`,item:!p,onClick:m,title:_("child"),children:he.jsx(ni,{icon:Qc,style:{color:yl[ti.NeighborIsAChild]}})}),he.jsx(ts,{className:`btn btn-square btn-neutral btn-sm ${y?"":"btn-outline"}`,item:!y,onClick:x,title:_("sibling"),children:he.jsx(ni,{icon:Qc,style:{color:yl[ti.NeighborIsASibling]}})}),he.jsxs("select",{className:"select select-sm w-36",title:_("find_node"),defaultValue:"",onChange:S,children:[he.jsx("option",{value:"",children:_("find_node")}),g]})]}),he.jsxs("div",{className:"absolute z-9 top-0 right-0 p-1 flex flex-row flex-wrap gap-1 items-start justify-end",children:[he.jsxs("select",{className:"select select-sm w-36",title:_("layout_type"),value:e,onChange:t,children:[he.jsx("option",{value:"",disabled:!0,children:_("layout_type")}),he.jsx("option",{value:"forceDirected2d",children:"forceDirected2d"}),he.jsx("option",{value:"forceDirected3d",children:"forceDirected3d"}),he.jsx("option",{value:"radialOut2d",children:"radialOut2d"}),he.jsx("option",{value:"radialOut3d",children:"radialOut3d"})]}),he.jsxs("select",{className:"select select-sm w-36",title:_("label_type"),value:n,onChange:r,children:[he.jsx("option",{value:"",disabled:!0,children:_("label_type")}),he.jsx("option",{value:"all",children:"all"}),he.jsx("option",{value:"auto",children:"auto"}),he.jsx("option",{value:"none",children:"none"}),he.jsx("option",{value:"nodes",children:"nodes"}),he.jsx("option",{value:"edges",children:"edges"})]})]}),he.jsxs("div",{className:"absolute z-9 bottom-0 left-0 p-1 flex flex-row flex-wrap gap-1 items-end",children:[he.jsx(SA,{name:"node_strength",label:_("node_strength"),icon:tO,onSubmit:(E,w)=>w&&typeof E=="number"&&a(E),min:-1e3,max:-100,step:10,defaultValue:s}),he.jsx(SA,{name:"link_distance",label:_("link_distance"),icon:nO,onSubmit:(E,w)=>w&&typeof E=="number"&&l(E),min:10,max:200,step:5,defaultValue:o})]}),he.jsx("div",{className:"absolute z-9 bottom-0 right-0 p-1 flex flex-row flex-wrap gap-1 items-end justify-end",children:he.jsx(ts,{title:_("scroll_to_top"),className:"btn btn-primary btn-sm ml-auto",onClick:()=>{window.scrollTo(0,0)},children:he.jsx(ni,{icon:iO})})})]})}),mX=Q.memo(()=>{const{t:i}=bg("network");return he.jsxs("details",{className:"collapse collapse-arrow rounded-b-none",children:[he.jsx("summary",{className:"collapse-title font-semibold",children:i("legend")}),he.jsxs("div",{className:"collapse-content text-sm",children:[he.jsxs("div",{className:"flex flex-row flex-wrap gap-3 mb-2",children:[he.jsxs("div",{children:[he.jsxs("p",{children:[i("nodes"),":"]}),he.jsxs("ul",{className:"list-none list-inside",children:[he.jsxs("li",{style:{color:nm.Coordinator},children:[he.jsx(ni,{icon:Iv})," Coordinator"]}),he.jsxs("li",{style:{color:nm.Router},children:[he.jsx(ni,{icon:Iv})," Router"]}),he.jsxs("li",{style:{color:nm.EndDevice},children:[he.jsx(ni,{icon:Iv})," EndDevice"]})]})]}),he.jsxs("div",{children:[he.jsxs("p",{children:[i("edges"),":"]}),he.jsxs("ul",{className:"list-none list-inside",children:[he.jsxs("li",{style:{color:yl[ti.NeighborIsParent]},children:[he.jsx(ni,{icon:Qc})," ",i("parent")]}),he.jsxs("li",{style:{color:yl[ti.NeighborIsAChild]},children:[he.jsx(ni,{icon:Qc})," ",i("child")]}),he.jsxs("li",{style:{color:yl[ti.NeighborIsASibling]},children:[he.jsx(ni,{icon:Qc})," ",i("sibling")]})]})]})]}),he.jsx("p",{children:i("legend_node_siblings")}),he.jsx("p",{children:i("legend_node_size")}),he.jsx("p",{children:i("legend_node_select")}),he.jsx("p",{children:i("legend_node_fold")}),he.jsx("p",{children:i("legend_edge_toggle")}),he.jsx("p",{className:"text-xs mt-2",children:"Known issues:"}),he.jsxs("ul",{className:"list-disc list-inside text-xs",children:[he.jsxs("li",{children:['If you cannot see labels (names/LQIs) after the map has finished loading, zoom-in sufficiently, switch the "',i("label_type"),'" value to something else, then back to the one you want']}),he.jsx("li",{children:"Edge colors are currently not working"}),he.jsx("li",{children:"An undesired vertical offset is applied when starting to drag a node"})]})]})]})}),RX=Q.memo(({map:i})=>{const{t:e}=bg("network"),[t,n]=Q.useState(qa.get(VS,"forceDirected2d")),[r,s]=Q.useState(qa.get(WS,"all")),[a,o]=Q.useState(qa.get(XS,-750)),[l,c]=Q.useState(qa.get(jS,50)),[f,d]=Q.useState(!0),[p,m]=Q.useState(!0),[y,x]=Q.useState(!0),_=Q.useRef(null),g=Q.useMemo(()=>{const I=new OffscreenCanvas(1,1).getContext("2d"),O=getComputedStyle(document.documentElement),G=ah(I,O.getPropertyValue("--color-base-100")),Z=ah(I,O.getPropertyValue("--color-base-200")),z=ah(I,O.getPropertyValue("--color-base-content")),L=ah(I,O.getPropertyValue("--color-primary")),B=ah(I,O.getPropertyValue("--color-accent"));return rO({},X3,{canvas:{background:G},node:{activeFill:B,label:{color:z,stroke:Z,activeColor:B},subLabel:{color:z,stroke:"transparent",activeColor:B}},lasso:{border:`1px solid ${L}`,background:"rgba(75, 160, 255, 0.1)"},ring:{fill:z,activeFill:B},edge:{fill:z,activeFill:B,label:{stroke:Z,color:z,activeColor:B},subLabel:{color:z,stroke:"transparent",activeColor:B}},arrow:{fill:z,activeFill:B},cluster:{stroke:z,label:{stroke:Z,color:z}}})},[]),[b,S]=Q.useMemo(()=>{const I=[],O=[],G=[];for(const L of i.nodes){const B=i.links.find(W=>W.relationship===ti.NeighborIsParent&&W.target.ieeeAddr===L.ieeeAddr);let H=B?i.nodes.find(W=>W.ieeeAddr===B.source.ieeeAddr)?.friendlyName:void 0;if(!B){const W=i.links.find(k=>k.relationship===ti.NeighborIsAChild&&k.source.ieeeAddr===L.ieeeAddr);H=W?i.nodes.find(k=>k.ieeeAddr===W.target.ieeeAddr)?.friendlyName:void 0,H&&(H+=` - ${e("children")}`)}I.push({id:L.ieeeAddr,data:{...L,parent:H},label:L.friendlyName,labelVisible:!0,fill:nm[L.type]})}const Z=new Map;for(const L of i.links){if(!f&&L.relationship===ti.NeighborIsParent||!p&&L.relationship===ti.NeighborIsAChild||!y&&L.relationship===ti.NeighborIsASibling)continue;if(L.relationship===ti.NeighborIsASibling){const H=Z.get(L.source.ieeeAddr);(!H||L.depth<H.depth||L.linkquality>H.linkquality||H.linkquality===L.linkquality&&L.depth<H.depth)&&Z.set(L.source.ieeeAddr,L);continue}const B=i.links.find(H=>H.source.ieeeAddr===L.target.ieeeAddr&&H.target.ieeeAddr===L.source.ieeeAddr);L.relationship===ti.NeighborIsAChild&&B?.relationship===ti.NeighborIsParent||G.push([L,B])}for(const[,L]of Z){const B=i.links.find(H=>H.source.ieeeAddr===L.target.ieeeAddr&&H.target.ieeeAddr===L.source.ieeeAddr);G.push([L,B])}const z=[];for(const[L,B]of G)z.includes(L)||L.relationship===ti.NeighborIsASibling&&(B?.relationship===ti.NeighborIsParent||B?.relationship===ti.NeighborIsAChild)||O.push({id:`${L.source.ieeeAddr}-${L.target.ieeeAddr}-${L.relationship}`,data:L,label:B?`${L.linkquality} / ${B.linkquality??"?"}`:`${L.linkquality}`,size:L.relationship===ti.NeighborIsParent||L.relationship===ti.NeighborIsAChild?1.5:.75,labelVisible:!0,source:L.source.ieeeAddr,target:L.target.ieeeAddr,fill:yl[L.relationship]});return[I,O]},[i,f,p,y,e]),{selections:E,actives:w,onNodeClick:T,onCanvasClick:R}=hX({ref:_,nodes:b,type:"single",pathSelectionType:"out",focusOnSelect:!1}),U=Q.useCallback(I=>{I.target.value&&(qa.set(VS,I.target.value),n(I.target.value),_.current?.resetControls(),_.current?.centerGraph(),_.current?.fitNodesInView())},[]),D=Q.useCallback(I=>{I.target.value&&(qa.set(WS,I.target.value),s(I.target.value))},[]),C=Q.useCallback(I=>{qa.set(XS,I),o(I)},[]),P=Q.useCallback(I=>{qa.set(jS,I),c(I)},[]);return he.jsxs(he.Fragment,{children:[he.jsx(mX,{}),he.jsxs("div",{className:"relative h-screen",children:[he.jsx(pX,{graphRef:_,layoutType:t,onLayoutTypeChange:U,labelType:r,onLabelTypeChange:D,nodeStrength:a,onNodeStrengthChange:C,linkDistance:l,onLinkDistanceChange:P,nodes:b,showParents:f,setShowParents:d,showChildren:p,setShowChildren:m,showSiblings:y,setShowSiblings:x}),he.jsx(uX,{ref:_,theme:g,nodes:b,edges:S,clusterAttribute:t.startsWith("forceDirected")?"parent":void 0,selections:E,actives:w,onCanvasClick:R,onNodeClick:T,layoutType:t,layoutOverrides:{nodeStrength:a,linkDistance:l},sizingType:"centrality",labelType:r,labelFontUrl:fX,edgeLabelPosition:"natural",lassoType:"node",cameraMode:t.endsWith("3d")?"rotate":"pan",draggable:!0,animated:!1,contextMenu:({data:{data:I},onCollapse:O,isCollapsed:G,canCollapse:Z,onClose:z})=>I.friendlyName?he.jsx(dX,{data:I,onCollapse:O,isCollapsed:G,canCollapse:Z,onClose:z}):null})]})]})});export{RX as default};
|
|
4233
|
+
}`)),document.head.appendChild(i)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var cA,uA;function U3(i,e=[]){const t=e.length;for(const n of i){const r=e.indexOf(n);if(r>-1){const s=[...e.slice(r),n].map(a=>a.data.id);throw new Error(`Invalid Graph: Circular node path detected: ${s.join(" -> ")}.`)}t>n.depth&&(n.depth=t,U3(n.out,[...e,n]))}}function O3(i,e){let t=!1;const n=i.reduce((a,o)=>({...a,[o.id]:{data:o,out:[],depth:-1,ins:[]}}),{});try{for(const a of e){const o=a.source,l=a.target;if(!n.hasOwnProperty(o))throw new Error(`Missing source Node ${o}`);if(!n.hasOwnProperty(l))throw new Error(`Missing target Node ${l}`);const c=n[o],f=n[l];f.ins.push(c),c.out.push(f)}U3(Object.values(n))}catch{t=!0}const r=Object.keys(n).map(a=>n[a].depth),s=Math.max(...r);return{invalid:t,depths:n,maxDepth:s||1}}const hA=["radialin","radialout"];function hW({nodes:i,edges:e,mode:t="lr",nodeLevelRatio:n=2}){const{depths:r,maxDepth:s,invalid:a}=O3(i,e);if(a)return null;const o=hA.includes(t)?1:5,l=i.length/s*n*o;if(t){const c=(m,y)=>x=>m?(r[x.id].depth-s/2)*l*(y?-1:1):void 0,f=c(["lr","rl"].includes(t),t==="rl"),d=c(["td","bu"].includes(t),t==="td"),p=c(["zin","zout"].includes(t),t==="zout");i.forEach(m=>{m.fx=f(m),m.fy=d(m),m.fz=p(m)})}return hA.includes(t)?Xk(c=>{const f=r[c.id];return(t==="radialin"?s-f.depth:f.depth)*l}).strength(1):null}function fW(i){return new Promise((e,t)=>{let n;function r(){n?e(n):(n=i.step(),r())}r()})}function ld(i){const e=[],t=[];return i.forEachNode((n,r)=>{e.push({...r,id:n,radius:r.size||1})}),i.forEachEdge((n,r)=>{t.push({...r,id:n})}),{nodes:e,edges:t}}function dW(){const i=L=>()=>L;let t=L=>L.index,n=[],r=[],s,a,o=[100,100],l=i(1),c=i(-1),f=i(100),d=i(.1),p={},m=.1,y=.001,x=[],_=[0,0],g,b=L=>L.cluster,S="treemap",E=!0,w=.1;function T(L){if(!E)return T;S==="force"&&(g.tick(),O());for(let B=0,H=n.length,W,k=L*w;B<H;++B)W=n[B],W.vx+=(p[b(W)].x-W.x)*k,W.vy+=(p[b(W)].y-W.y)*k}function R(){n&&(S==="treemap"?G():z())}T.initialize=function(L){n=L,R()};function U(L){let B=b(L.source),H=b(L.target);return B<=H?B+"~"+H:H+"~"+B}function D(L){let B=new Map,H={};return L.forEach(function(W){B.has(b(W))||B.set(b(W),{count:0,sumforceNodeSize:0})}),L.forEach(function(W){H=B.get(b(W)),H.count=H.count+1,H.sumforceNodeSize=H.sumforceNodeSize+Math.PI*(l(W)*l(W))*1.3,B.set(b(W),H)}),B}function C(L){let B=new Map,H=[];return L.forEach(function(W){let k=U(W),K;B.has(k)?K=B.get(k):K=0,K+=1,B.set(k,K)}),B.forEach(function(W,k){let K,$;K=k.split("~")[0],$=k.split("~")[1],K!==void 0&&$!==void 0&&H.push({source:K,target:$,count:W})}),H}function P(){let L=[],B=[],H=new Map,W,k,K,$,j;$=D(n),j=C(r);for(W of $.keys())K=$.get(W),L.push({id:W,size:K.count,r:Math.sqrt(K.sumforceNodeSize/Math.PI)}),H.set(W,k);return j.forEach(function(ee){let de=H.get(ee.source),ae=H.get(ee.target);de!==void 0&&ae!==void 0&&B.push({source:de,target:ae,count:ee.count})}),{nodes:L,links:B}}function I(){let L=[],B,H,W;W=D(T.nodes());for(B of W.keys())H=W.get(B),L.push({id:B,size:H.count});return{id:"clustersTree",children:L}}function O(){return p.none={x:0,y:0},x.forEach(function(L){S==="treemap"?p[L.data.id]={x:L.x0+(L.x1-L.x0)/2-_[0],y:L.y0+(L.y1-L.y0)/2-_[1]}:p[L.id]={x:L.x-_[0],y:L.y-_[1]}}),p}function G(){let L=RG().size(T.size());a=l0(I()).sum(B=>B.radius).sort(function(B,H){return H.height-B.height||H.value-B.value}),x=L(a).leaves(),O()}function Z(){let L=0;n.length!==0&&r.forEach(function(B){let H,W;if(n){if(H=B.source,W=B.target,typeof B.source!="object"&&(H=n.find(k=>k.id===B.source)),typeof B.target!="object"&&(W=n.find(k=>k.id===B.target)),H===void 0||W===void 0)throw Error("Error setting links, couldnt find nodes for a link (see it on the console)");B.source=H,B.target=W,B.index=L++}})}function z(){let L;!n||!n.length||(Z(),L=P(),s.size>0&&L.nodes.forEach(B=>{var H,W,k,K;B.fx=(W=(H=s.get(B.id))==null?void 0:H.position)==null?void 0:W.x,B.fy=(K=(k=s.get(B.id))==null?void 0:k.position)==null?void 0:K.y}),g=eR(L.nodes).force("x",lx(o[0]/2).strength(.1)).force("y",cx(o[1]/2).strength(.1)).force("collide",qC(B=>B.r).iterations(4)).force("charge",tR().strength(c)).force("links",YC(L.nodes.length?L.links:[]).distance(f).strength(d)),x=g.nodes(),O())}return T.template=function(L){return arguments.length?(S=L,R(),T):S},T.groupBy=function(L){return arguments.length?typeof L=="string"?(b=function(B){return B[L]},T):(b=L,T):b},T.enableGrouping=function(L){return arguments.length?(E=L,T):E},T.strength=function(L){return arguments.length?(w=L,T):w},T.getLinkStrength=function(L){return E?b(L.source)===b(L.target)?typeof m=="function"?m(L):m:typeof y=="function"?y(L):y:typeof m=="function"?m(L):m},T.id=function(L){return arguments.length?(t=L,T):t},T.size=function(L){return arguments.length?(o=L,T):o},T.linkStrengthInterCluster=function(L){return arguments.length?(y=L,T):y},T.linkStrengthIntraCluster=function(L){return arguments.length?(m=L,T):m},T.nodes=function(L){return arguments.length?(n=L,T):n},T.links=function(L){return arguments.length?(L===null?r=[]:r=L,R(),T):r},T.template=function(L){return arguments.length?(S=L,R(),T):S},T.forceNodeSize=function(L){return arguments.length?(l=typeof L=="function"?L:i(+L),R(),T):l},T.nodeSize=T.forceNodeSize,T.forceCharge=function(L){return arguments.length?(c=typeof L=="function"?L:i(+L),R(),T):c},T.forceLinkDistance=function(L){return arguments.length?(f=typeof L=="function"?L:i(+L),R(),T):f},T.forceLinkStrength=function(L){return arguments.length?(d=typeof L=="function"?L:i(+L),R(),T):d},T.offset=function(L){return arguments.length?(_=typeof L=="function"?L:i(+L),T):_},T.getFocis=O,T.setClusters=function(L){return s=L,T},T}function no({graph:i,nodeLevelRatio:e=2,mode:t=null,dimensions:n=2,nodeStrength:r=-250,linkDistance:s=50,clusterStrength:a=.5,linkStrengthInterCluster:o=.01,linkStrengthIntraCluster:l=.5,forceLinkDistance:c=100,forceLinkStrength:f=.1,clusterType:d="force",forceCharge:p=-700,getNodePosition:m,drags:y,clusters:x,clusterAttribute:_,forceLayout:g}){const{nodes:b,edges:S}=ld(i),w=n===2&&S.length>25?r*2:r;let T,R;g==="forceDirected2d"?(T=lx(),R=cx()):(T=lx(600).strength(.05),R=cx(600).strength(.05));const U=eR().force("center",O5(0,0)).force("link",YC()).force("charge",tR().strength(w)).force("x",T).force("y",R).force("z",jk()).force("collide",qC(I=>I.radius+10)).force("dagRadial",hW({nodes:b,edges:S,mode:t,nodeLevelRatio:e})).stop();let D;if(_){let I=p;if(b?.length){const O=Math.ceil(b.length/200);I=p*O}D=dW().setClusters(x).strength(a).template(d).groupBy(O=>O.data[_]).links(S).size([100,100]).linkStrengthInterCluster(o).linkStrengthIntraCluster(l).forceLinkDistance(c).forceLinkStrength(f).forceCharge(I).forceNodeSize(O=>O.radius)}let C=U.numDimensions(n).nodes(b);if(D&&(C=C.force("group",D)),s){let I=C.force("link");I&&(I.id(O=>O.id).links(S).distance(s),D&&(I=I.strength(D?.getLinkStrength??.1)))}const P=new Map(b.map(I=>[I.id,I]));return{step(){for(;U.alpha()>.01;)U.tick();return!0},getNodePosition(I){var O,G;if(m){const Z=m(I,{graph:i,drags:y,nodes:b,edges:S});if(Z)return Z}return(O=y?.[I])!=null&&O.position?(G=y?.[I])==null?void 0:G.position:P.get(I)}}}function pW({graph:i,radius:e,drags:t,getNodePosition:n}){const r=OG(i,{scale:e}),{nodes:s,edges:a}=ld(i);return{step(){return!0},getNodePosition(o){var l,c;if(n){const f=n(o,{graph:i,drags:t,nodes:s,edges:a});if(f)return f}return(l=t?.[o])!=null&&l.position?(c=t?.[o])==null?void 0:c.position:r?.[o]}}}const mW={td:{x:"x",y:"y",factor:-1},lr:{x:"y",y:"x",factor:1}};function fA({graph:i,drags:e,mode:t="td",nodeSeparation:n=1,nodeSize:r=[50,50],getNodePosition:s}){const{nodes:a,edges:o}=ld(i),{depths:l}=O3(a,o),c=Object.keys(l).map(x=>l[x]),f=vG().id(x=>x.data.id).parentId(x=>{var _,g,b;return(b=(g=(_=x.ins)==null?void 0:_[0])==null?void 0:g.data)==null?void 0:b.id})(c),p=MG().separation(()=>n).nodeSize(r)(l0(f)).descendants(),m=mW[t],y=new Map(a.map(x=>{const{x:_,y:g}=p.find(b=>b.data.id===x.id);return[x.id,{...x,[m.x]:_*m.factor,[m.y]:g*m.factor,z:0}]}));return{step(){return!0},getNodePosition(x){var _,g;if(s){const b=s(x,{graph:i,drags:e,nodes:a,edges:o});if(b)return b}return(_=e?.[x])!=null&&_.position?(g=e?.[x])==null?void 0:g.position:y.get(x)}}}function gW({graph:i,margin:e,drags:t,getNodePosition:n,ratio:r,gridSize:s,maxIterations:a}){const{nodes:o,edges:l}=ld(i),c=FG(i,{maxIterations:a,inputReducer:(f,d)=>({...d,x:d.x||0,y:d.y||0}),settings:{ratio:r,margin:e,gridSize:s}});return{step(){return!0},getNodePosition(f){var d,p;if(n){const m=n(f,{graph:i,drags:t,nodes:o,edges:l});if(m)return m}return(d=t?.[f])!=null&&d.position?(p=t?.[f])==null?void 0:p.position:c?.[f]}}}function vW({graph:i,drags:e,iterations:t,...n}){qG.assign(i);const r=WG(i,{iterations:t,settings:n});return{step(){return!0},getNodePosition(s){var a;return((a=e?.[s])==null?void 0:a.position)||r?.[s]}}}function yW({graph:i,drags:e,getNodePosition:t}){const{nodes:n,edges:r}=ld(i);return{step(){return!0},getNodePosition(s){return t(s,{graph:i,drags:e,nodes:n,edges:r})}}}const _W=["forceDirected2d","treeTd2d","treeLr2d","radialOut2d","treeTd3d","treeLr3d","radialOut3d","forceDirected3d"];function xW({type:i,...e}){if(_W.includes(i)){const{nodeStrength:t,linkDistance:n,nodeLevelRatio:r}=e;if(i==="forceDirected2d")return no({...e,dimensions:2,nodeLevelRatio:r||2,nodeStrength:t||-250,linkDistance:n,forceLayout:i});if(i==="treeTd2d")return no({...e,mode:"td",dimensions:2,nodeLevelRatio:r||5,nodeStrength:t||-250,linkDistance:n||50,forceLayout:i});if(i==="treeLr2d")return no({...e,mode:"lr",dimensions:2,nodeLevelRatio:r||5,nodeStrength:t||-250,linkDistance:n||50,forceLayout:i});if(i==="radialOut2d")return no({...e,mode:"radialout",dimensions:2,nodeLevelRatio:r||5,nodeStrength:t||-500,linkDistance:n||100,forceLayout:i});if(i==="treeTd3d")return no({...e,mode:"td",dimensions:3,nodeLevelRatio:r||2,nodeStrength:t||-500,linkDistance:n||50});if(i==="treeLr3d")return no({...e,mode:"lr",dimensions:3,nodeLevelRatio:r||2,nodeStrength:t||-500,linkDistance:n||50,forceLayout:i});if(i==="radialOut3d")return no({...e,mode:"radialout",dimensions:3,nodeLevelRatio:r||2,nodeStrength:t||-500,linkDistance:n||100,forceLayout:i});if(i==="forceDirected3d")return no({...e,dimensions:3,nodeLevelRatio:r||2,nodeStrength:t||-250,linkDistance:n,forceLayout:i})}else if(i==="circular2d"){const{radius:t}=e;return pW({...e,radius:t||300})}else{if(i==="hierarchicalTd")return fA({...e,mode:"td"});if(i==="hierarchicalLr")return fA({...e,mode:"lr"});if(i==="nooverlap"){const{graph:t,maxIterations:n,ratio:r,margin:s,gridSize:a,...o}=e;return gW({graph:t,margin:s||10,maxIterations:n||50,ratio:r||10,gridSize:a||20,...o})}else if(i==="forceatlas2"){const{graph:t,iterations:n,gravity:r,scalingRatio:s,...a}=e;return vW({type:"forceatlas2",graph:t,...a,scalingRatio:s||100,gravity:r||10,iterations:n||50})}else if(i==="custom")return yW({...e})}throw new Error(`Layout ${i} not found.`)}function L3({nodeCount:i,nodePosition:e,labelType:t,camera:n}){return(r,s)=>{var a;if(n&&e&&((a=n?.position)==null?void 0:a.z)/n?.zoom-e?.z>6e3)return!1;if(t==="all")return!0;if(t==="nodes"&&r==="node")return!0;if(t==="edges"&&r==="edge")return!0;if(t==="auto"&&r==="node"){if(s>7)return!0;if(n&&e&&n.position.z/n.zoom-e.z<3e3)return!0}return!1}}function N3(i,e){switch(e){case"above":return i;case"below":return-i;case"inline":case"natural":default:return 0}}const ab=typeof window>"u";function bW({graph:i}){const e=JG(i);return{ranks:e,getSizeForNode:t=>e[t]*80}}function SW({graph:i}){const e=$G.degreeCentrality(i);return{ranks:e,getSizeForNode:t=>e[t]*20}}function EW({graph:i,attribute:e,defaultSize:t}){const n=new Map;return e?i.forEachNode((r,s)=>{var a;const o=(a=s.data)==null?void 0:a[e];isNaN(o)&&console.warn(`Attribute ${o} is not a number for node ${s.id}`),n.set(r,o||0)}):console.warn("Attribute sizing configured but no attribute provided"),{getSizeForNode:r=>!e||!n?t:n.get(r)}}const dA={pagerank:bW,centrality:SW,attribute:EW,none:({defaultSize:i})=>({getSizeForNode:e=>i})};function MW({type:i,...e}){var t;const n=(t=dA[i])==null?void 0:t.call(dA,e);if(!n&&i!=="default")throw new Error(`Unknown sizing strategy: ${i}`);const{graph:r,minSize:s,maxSize:a}=e,o=new Map;let l,c;if(r.forEachNode((f,d)=>{let p;i==="default"?p=d.size||e.defaultSize:p=n.getSizeForNode(f),(l===void 0||p<l)&&(l=p),(c===void 0||p>c)&&(c=p),o.set(f,p)}),i!=="none"){const f=fR().domain([l,c]).rangeRound([s,a]);for(const[d,p]of o)o.set(d,f(p))}return o}function wW(i,e,t){i.clear();const n=new Set;for(const r of e)try{n.has(r.id)||(i.addNode(r.id,r),n.add(r.id))}catch(s){console.error(`[Graph] Error adding node '${r.id}`,s)}for(const r of t)if(!(!n.has(r.source)||!n.has(r.target)))try{i.addEdge(r.source,r.target,r)}catch(s){console.error(`[Graph] Error adding edge '${r.source} -> ${r.target}`,s)}return i}function TW({graph:i,layout:e,sizingType:t,labelType:n,sizingAttribute:r,defaultNodeSize:s,minNodeSize:a,maxNodeSize:o,clusterAttribute:l}){const c=[],f=[],d=new Map,p=MW({graph:i,type:t,attribute:r,minSize:a,maxSize:o,defaultSize:s}),m=i.nodes().length,y=L3({nodeCount:m,labelType:n});return i.forEachNode((x,_)=>{const g=e.getNodePosition(x),{data:b,fill:S,icon:E,label:w,size:T,...R}=_,U=p.get(_.id),D=y("node",U),P=(i.inboundNeighbors(_.id)||[]).map(O=>i.getNodeAttributes(O)),I={..._,size:U,labelVisible:D,label:w,icon:E,fill:S,cluster:l?b[l]:void 0,parents:P,data:{...R,...b??{}},position:{...g,x:g.x||0,y:g.y||0,z:g.z||1}};d.set(_.id,I),c.push(I)}),i.forEachEdge((x,_)=>{const g=d.get(_.source),b=d.get(_.target);if(g&&b){const{data:S,id:E,label:w,size:T,...R}=_,U=y("edge",T);f.push({..._,id:E,label:w,labelVisible:U,size:T,data:{...R,id:E,...S||{}}})}}),{nodes:c,edges:f}}const _r={mass:10,tension:1e3,friction:300,precision:.1};function I3(i,e,t){const n=e.getLength(),r=i==="end"?n:n/2,s=i==="end"?t/2:0,a=(r-s)/n,o=e.getPointAt(a),l=e.getTangentAt(a);return[o,l]}function P3(i){return[i+6,2+i/1.5]}const pA=.7;function z3(i,e,t=0){const n=new J(i.x,i.y||0,i.z||0),r=new J(e.x,e.y||0,e.z||0),s=new J().addVectors(n,r).divideScalar(2);return s.setLength(s.length()+t)}function AW(i,e,t=-1){const n=i.clone(),r=e.clone(),s=new J().subVectors(r,n),a=s.length(),o=s.clone().normalize(),l=new J().subVectors(r,n).divideScalar(2),c=Math.abs(o.x)%1,f=new J(-o.y,o.x-c*o.z,c*o.y).normalize(),d=new J().add(n).add(l).add(f.multiplyScalar(a/4).multiplyScalar(t));return[i,d,e]}function Vf(i,e,t,n,r,s){const a=mA(i,t,e),o=mA(t,i,n);return r?new jg(...AW(a,o,s)):new r1(a,o)}function Wf(i){return new J(i.position.x,i.position.y,i.position.z||0)}function mA(i,e,t){const n=i.distanceTo(e);return i.clone().add(e.clone().sub(i).multiplyScalar(t/n))}function gA(i,e){return{...i,position:{...i.position,x:i.position.x+e.x,y:i.position.y+e.y,z:i.position.z+e.z}}}function CW({edge:i,edges:e,curved:t}){var n;let r=t,s;const a=e.filter(o=>o.target===i.target&&o.source===i.source).map(o=>o.id);if(a.length>1){r=!0;const o=a.indexOf(i.id),l=o===0?1:1+o*.8,c=o%2===0?1:-1,f=pA*l;s=c*f}return(n=i.data)!=null&&n.isAggregated&&e.length>1?{curved:!0,curveOffset:a.indexOf(i.id)===0?pA:-.7}:{curved:r,curveOffset:s}}function RW(i,e,t){const n=e.x-i.x,r=e.y-i.y,s=Math.atan2(r,n),a=t==="above"?n>=0?s+Math.PI/2:s-Math.PI/2:n>=0?s-Math.PI/2:s+Math.PI/2,o=7,l=Math.cos(a)*o,c=Math.sin(a)*o;return{x:l,y:c,z:0}}function Xf(i){let e=Number.POSITIVE_INFINITY,t=Number.NEGATIVE_INFINITY,n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,s=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY;for(let o of i)e=Math.min(e,o.position.x),t=Math.max(t,o.position.x),n=Math.min(n,o.position.y),r=Math.max(r,o.position.y),s=Math.min(s,o.position.z),a=Math.max(a,o.position.z);return{height:r-n,width:t-e,minX:e,maxX:t,minY:n,maxY:r,minZ:s,maxZ:a,x:(t+e)/2,y:(r+n)/2,z:(a+s)/2}}function DW(i,e){return e?i.reduce((t,n)=>{const r=n.data[e];return r&&t.set(r,[...t.get(r)||[],n]),t},new Map):new Map}function UW({nodes:i,clusterAttribute:e}){const t=new Map;if(e){const n=DW(i,e);for(const[r,s]of n){const a=Xf(s);t.set(r,{label:r,nodes:s,position:a})}}return t}function OW(i,e,t){return yV.bidirectional(i,e,t)}const vA=i=>i.tagName!=="INPUT"&&i.tagName!=="SELECT"&&i.tagName!=="TEXTAREA"&&!i.isContentEditable,F3=({actives:i=[],selections:e=[],collapsedNodeIds:t=[],theme:n})=>iV(r=>{var s,a,o;return{theme:{...n,edge:{...n?.edge,label:{...(s=n?.edge)==null?void 0:s.label,fontSize:((o=(a=n?.edge)==null?void 0:a.label)==null?void 0:o.fontSize)??6}}},edges:[],nodes:[],collapsedNodeIds:t,clusters:new Map,panning:!1,draggingIds:[],actives:i,edgeContextMenus:new Set,edgeMeshes:[],selections:e,hoveredNodeId:null,drags:{},graph:new cn({multi:!0}),setTheme:l=>r(c=>({...c,theme:l})),setClusters:l=>r(c=>({...c,clusters:l})),setEdgeContextMenus:l=>r(c=>({...c,edgeContextMenus:l})),setEdgeMeshes:l=>r(c=>({...c,edgeMeshes:l})),setPanning:l=>r(c=>({...c,panning:l})),setDrags:l=>r(c=>({...c,drags:l})),addDraggingId:l=>r(c=>({...c,draggingIds:[...c.draggingIds,l]})),removeDraggingId:l=>r(c=>({...c,draggingIds:c.draggingIds.filter(f=>f!==l)})),setActives:l=>r(c=>({...c,actives:l})),setSelections:l=>r(c=>({...c,selections:l})),setHoveredNodeId:l=>r(c=>({...c,hoveredNodeId:l})),setNodes:l=>r(c=>({...c,nodes:l,centerPosition:Xf(l)})),setEdges:l=>r(c=>({...c,edges:l})),setNodePosition:(l,c)=>r(f=>{var d,p;const m=f.nodes.find(b=>b.id===l),y=Wf(m),_=new J(c.x,c.y,c.z).sub(y),g=[...f.nodes];if((d=f.selections)!=null&&d.includes(l))(p=f.selections)==null||p.forEach(b=>{const S=f.nodes.find(E=>E.id===b);if(S){const E=f.nodes.indexOf(S);g[E]=gA(S,_)}});else{const b=f.nodes.indexOf(m);g[b]=gA(m,_)}return{...f,drags:{...f.drags,[l]:m},nodes:g}}),setCollapsedNodeIds:(l=[])=>r(c=>({...c,collapsedNodeIds:l})),setClusterPosition:(l,c)=>r(f=>{const d=new Map(f.clusters),p=d.get(l);if(p){const m=p.position,y=new J(c.x-m.x,c.y-m.y,c.z-(m.z??0)),x=[...f.nodes],_={...f.drags};x.forEach((S,E)=>{S.cluster===l&&(x[E]={...S,position:{...S.position,x:S.position.x+y.x,y:S.position.y+y.y,z:S.position.z+(y.z??0)}},_[S.id]=S)});const g=x.filter(S=>S.cluster===l),b=Xf(g);return d.set(l,{...p,position:b}),{...f,drags:{..._,[l]:p},clusters:d,nodes:x}}return f})}}),B3=F3({}),k3=ab?null:Q.createContext(B3),LW=({children:i,store:e=B3})=>ab?i:lo.createElement(k3.Provider,{value:e},i),$e=i=>{const e=Q.useContext(k3);return dR(e,aV(i))};function G3({nodeId:i,nodes:e,edges:t,currentHiddenNodes:n,currentHiddenEdges:r}){const s=[],a=[],o=n.map(m=>m.id),l=r.map(m=>m.id),c=t.filter(m=>m.source===i),f=c.map(m=>m.target);a.push(...c);for(const m of f){const y=t.filter(_=>_.target===m&&_.source!==i);let x=!1;if((y.length===0||y.length>0&&!o.includes(m)&&y.map(g=>g.id).every(g=>l.includes(g)))&&(x=!0),x){const _=e.find(b=>b.id===m);_&&s.push(_);const g=G3({nodeId:m,nodes:e,edges:t,currentHiddenEdges:a,currentHiddenNodes:s});a.push(...g.hiddenEdges),s.push(...g.hiddenNodes)}}const d=Object.values(a.reduce((m,y)=>({...m,[y.id]:y}),{})),p=Object.values(s.reduce((m,y)=>({...m,[y.id]:y}),{}));return{hiddenEdges:d,hiddenNodes:p}}const NW=({collapsedIds:i,nodes:e,edges:t})=>{const n=[],r=[];for(const c of i){const{hiddenEdges:f,hiddenNodes:d}=G3({nodeId:c,nodes:e,edges:t,currentHiddenEdges:r,currentHiddenNodes:n});n.push(...d),r.push(...f)}const s=n.map(c=>c.id),a=r.map(c=>c.id),o=e.filter(c=>!s.includes(c.id)),l=t.filter(c=>!a.includes(c.id));return{visibleNodes:o,visibleEdges:l}},IW=({layoutType:i,sizingType:e,labelType:t,sizingAttribute:n,clusterAttribute:r,selections:s,nodes:a,edges:o,actives:l,collapsedNodeIds:c,defaultNodeSize:f,maxNodeSize:d,minNodeSize:p,layoutOverrides:m,constrainDragging:y})=>{const x=$e(k=>k.graph),_=$e(k=>k.clusters),g=$e(k=>k.nodes),b=$e(k=>k.setClusters),S=$e(k=>k.collapsedNodeIds),E=$e(k=>k.setEdges),w=$e(k=>k.nodes),T=$e(k=>k.setNodes),R=$e(k=>k.setSelections),U=$e(k=>k.setActives),D=$e(k=>k.drags),C=$e(k=>k.setDrags),P=$e(k=>k.setCollapsedNodeIds),I=Q.useRef(!1),O=Q.useRef(null),G=Kn(k=>k.camera),Z=Q.useRef(D),z=Q.useRef([]);Q.useEffect(()=>{var k;if(!r)return;const K=g.map(j=>j.id),$=a.find(j=>!K.includes(j.id));if($){const j=$.data[r],ee=_.get(j),de={...Z.current};(k=ee?.nodes)==null||k.forEach(ae=>de[ae.id]=void 0),Z.current=de,C(de)}},[g,a,r,_,C]);const{visibleEdges:L,visibleNodes:B}=Q.useMemo(()=>NW({collapsedIds:S,nodes:a,edges:o}),[S,a,o]),H=Q.useCallback(k=>{const K={...Z.current};k.forEach($=>K[$.id]=$),Z.current=K,C(K)},[C]),W=Q.useCallback(async k=>{O.current=k||xW({...m,type:i,graph:x,drags:Z.current,clusters:z?.current,clusterAttribute:r}),await fW(O.current);const K=TW({graph:x,layout:O.current,sizingType:e,labelType:t,sizingAttribute:n,maxNodeSize:d,minNodeSize:p,defaultNodeSize:f,clusterAttribute:r}),$=UW({nodes:K.nodes,clusterAttribute:r});y&&$.forEach(j=>{var ee,de;const ae=z.current.get(j.label);ae?.nodes.length===j.nodes.length&&(j.position=((de=(ee=z.current)==null?void 0:ee.get(j.label))==null?void 0:de.position)??j.position)}),E(K.edges),T(K.nodes),b($),r&&H(K.nodes)},[m,i,r,e,t,n,d,p,f,E,T,b]);return Q.useEffect(()=>{Z.current=D},[D,r,W]),Q.useEffect(()=>{z.current=_},[_]),Q.useEffect(()=>{const k=w.map($=>({...$,labelVisible:L3({nodeCount:w?.length,labelType:t,camera:G,nodePosition:$?.position})("node",$?.size)}));k.some(($,j)=>$.labelVisible!==w[j].labelVisible)&&T(k)},[G,G.zoom,G.position.z,T,w,t]),Q.useEffect(()=>{I.current&&R(s)},[s,R]),Q.useEffect(()=>{I.current&&U(l)},[l,U]),Q.useEffect(()=>{async function k(){I.current=!1,wW(x,B,L),await W(),requestAnimationFrame(()=>I.current=!0)}k()},[B,L]),Q.useEffect(()=>{I.current&&P(c)},[c,P]),Q.useEffect(()=>{I.current&&(Z.current={},C({}),W())},[i,W,C]),Q.useEffect(()=>{I.current&&W(O.current)},[e,n,t,W]),{updateLayout:W}},yu=({text:i,fontSize:e=7,fontUrl:t,color:n="#2A6475",opacity:r=1,stroke:s,active:a,ellipsis:o=75,rotation:l})=>{const c=o&&!a?iW(i,o):i,f=Q.useMemo(()=>new et(n),[n]),d=Q.useMemo(()=>s?new et(s):void 0,[s]);return he.jsx(v3,{position:[0,0,1],renderOrder:1,children:he.jsx(eW,{font:t,fontSize:e,color:f,fillOpacity:r,textAlign:"center",outlineWidth:s?1:0,outlineColor:d,depthOffset:0,maxWidth:100,overflowWrap:"break-word",rotation:l,children:c})})},H3=({draggable:i,set:e,position:t,bounds:n,onDragStart:r,onDragEnd:s})=>{const a=Kn(_=>_.camera),o=Kn(_=>_.raycaster),l=Kn(_=>_.size),c=Kn(_=>_.gl),{mouse2D:f,mouse3D:d,offset:p,normal:m,plane:y}=Q.useMemo(()=>({mouse2D:new Ge,mouse3D:new J,offset:new J,normal:new J,plane:new la}),[]),x=Q.useMemo(()=>c.domElement.getBoundingClientRect(),[c.domElement]);return r9({onDragStart:({event:_})=>{const{eventObject:g,point:b}=_;g.getWorldPosition(p).sub(b),d.copy(b),r()},onDrag:({xy:_,buttons:g,cancel:b})=>{if(g!==1){b();return}const S=(_[0]-(x?.left??0))/l.width*2-1,E=-((_[1]-(x?.top??0))/l.height)*2+1;f.set(S,E),o.setFromCamera(f,a),a.getWorldDirection(m).negate(),y.setFromNormalAndCoplanarPoint(m,d),o.ray.intersectPlane(y,d);const w=new J(t.x,t.y,t.z).copy(d).add(p);if(n){const T=new J((n.minX+n.maxX)/2,(n.minY+n.maxY)/2,(n.minZ+n.maxZ)/2),R=(n.maxX-n.minX)/2,U=w.clone().sub(T);U.length()>R&&(U.normalize().multiplyScalar(R),w.copy(T).add(U))}return e(w)},onDragEnd:s},{drag:{enabled:i,threshold:10}})},ob=({sensitivity:i=7,interval:e=50,timeout:t=0,disabled:n,onPointerOver:r,onPointerOut:s})=>{const a=Q.useRef(!1),o=Q.useRef(null),l=Q.useRef(0),c=Q.useRef({x:null,y:null,px:null,py:null}),f=Q.useCallback(_=>{c.current.x=_.clientX,c.current.y=_.clientY},[]),d=Q.useCallback(_=>{o.current=clearTimeout(o.current);const{px:g,x:b,py:S,y:E}=c.current;Math.abs(g-b)+Math.abs(S-E)<i?(l.current=1,r(_)):(c.current.px=b,c.current.py=E,o.current=setTimeout(()=>d(_),e))},[e,r,i]),p=Q.useCallback(()=>{clearTimeout(o.current),typeof window<"u"&&document.removeEventListener("mousemove",f,!1)},[f]),m=Q.useCallback(_=>{n||(a.current=!0,p(),l.current!==1&&(c.current.px=_.pointer.x,c.current.py=_.pointer.y,typeof window<"u"&&document.addEventListener("mousemove",f,!1),o.current=setTimeout(()=>d(_),t)))},[p,d,n,f,t]),y=Q.useCallback(_=>{o.current=clearTimeout(o.current),l.current=0,s(_)},[s]),x=Q.useCallback(_=>{a.current=!1,p(),l.current===1&&(o.current=setTimeout(()=>y(_),t))},[p,y,t]);return{pointerOver:m,pointerOut:x}},V3=Q.createContext({controls:null,resetControls:()=>{},zoomIn:()=>{},zoomOut:()=>{},dollyIn:()=>{},dollyOut:()=>{},panLeft:()=>{},panRight:()=>{},panUp:()=>{},panDown:()=>{},freeze:()=>{},unFreeze:()=>{}}),x0=()=>{const i=Q.useContext(V3);if(i===void 0)throw new Error("`useCameraControls` hook must be used within a `ControlsProvider` component");return i},PW=({outerRadius:i,innerRadius:e,padding:t,normalizedFill:n,normalizedStroke:r,opacity:s,animated:a,theme:o})=>{var l;const{opacity:c}=yr({from:{opacity:0},to:{opacity:s},config:{..._r,duration:a?void 0:0}});return he.jsxs(he.Fragment,{children:[he.jsxs("mesh",{children:[he.jsx("ringGeometry",{attach:"geometry",args:[i,0,128]}),he.jsx(Bn.meshBasicMaterial,{attach:"material",color:n,transparent:!0,depthTest:!1,opacity:(l=o.cluster)!=null&&l.fill?c:0,side:In,fog:!0})]}),he.jsxs("mesh",{children:[he.jsx("ringGeometry",{attach:"geometry",args:[i,e+t,128]}),he.jsx(Bn.meshBasicMaterial,{attach:"material",color:r,transparent:!0,depthTest:!1,opacity:c,side:In,fog:!0})]})]})},zW=({animated:i,position:e,padding:t=40,labelFontUrl:n,disabled:r,radius:s=2,nodes:a,label:o,onClick:l,onPointerOver:c,onPointerOut:f,draggable:d=!1,onDragged:p,onRender:m})=>{var y,x,_,g,b,S,E;const w=$e(ne=>ne.theme),T=Math.max(e.width,e.height)/2,R=T-s+t,[U,D]=Q.useState(!1),C=$e(ne=>ne.centerPosition),P=$e(ne=>ne.nodes),I=x0(),O=$e(ne=>ne.draggingIds),G=O.includes(o),Z=O.length>0,z=$e(ne=>{var Ue;return(Ue=ne.actives)==null?void 0:Ue.some(V=>a.some(se=>se.id===V))}),L=$e(ne=>ne.hoveredNodeId),B=$e(ne=>{var Ue;return(Ue=ne.selections)==null?void 0:Ue.some(V=>a.some(se=>se.id===V))}),W=$e(ne=>{var Ue;return((Ue=ne.selections)==null?void 0:Ue.length)>0})?B||U||z?(y=w.cluster)==null?void 0:y.selectedOpacity:(x=w.cluster)==null?void 0:x.inactiveOpacity:(_=w.cluster)==null?void 0:_.opacity,k=Q.useMemo(()=>{var ne,Ue;const V=[0,-R,2],se=(Ue=(ne=w.cluster)==null?void 0:ne.label)==null?void 0:Ue.offset;return se?[V[0]-se[0],V[1]-se[1],V[2]-se[2]]:V},[R,(b=(g=w.cluster)==null?void 0:g.label)==null?void 0:b.offset]),{circlePosition:K}=yr({from:{circlePosition:[C.x,C.y,-1]},to:{circlePosition:e?[e.x,e.y,-1]:[0,0,-1]},config:{..._r,duration:i&&!Z?void 0:0}}),$=Q.useMemo(()=>{var ne;return new et((ne=w.cluster)==null?void 0:ne.stroke)},[(S=w.cluster)==null?void 0:S.stroke]),j=Q.useMemo(()=>{var ne;return new et((ne=w.cluster)==null?void 0:ne.fill)},[(E=w.cluster)==null?void 0:E.fill]),ee=$e(ne=>ne.addDraggingId),de=$e(ne=>ne.removeDraggingId),ae=$e(ne=>ne.setClusterPosition),pe=H3({draggable:d&&!L,position:{x:e.x,y:e.y,z:-1},set:ne=>ae(o,ne),onDragStart:()=>{ee(o),D(!0)},onDragEnd:()=>{de(o),D(!1);const ne=P.filter(Ue=>Ue.cluster===o);p?.({nodes:ne,label:o})}});El(U&&!Z&&l!==void 0,"pointer"),El(U&&d&&!G&&l===void 0,"grab"),El(G,"grabbing");const{pointerOver:Le,pointerOut:xe}=ob({disabled:r,onPointerOver:ne=>{D(!0),I.freeze(),c?.({nodes:a,label:o},ne)},onPointerOut:ne=>{D(!1),I.unFreeze(),f?.({nodes:a,label:o},ne)}});return Q.useMemo(()=>{var ne,Ue,V;return w.cluster&&he.jsx(Bn.group,{userData:{id:o,type:"cluster"},position:K,onPointerOver:Le,onPointerOut:xe,onClick:se=>{!r&&!G&&l?.({nodes:a,label:o},se)},...pe(),children:m?m({label:{position:k,text:o,opacity:W,fontUrl:n},opacity:W,outerRadius:R,innerRadius:T,padding:t,theme:w}):he.jsxs(he.Fragment,{children:[he.jsx(PW,{outerRadius:R,innerRadius:T,padding:t,normalizedFill:j,normalizedStroke:$,opacity:W,animated:i,theme:w}),((ne=w.cluster)==null?void 0:ne.label)&&he.jsx(Bn.group,{position:k,children:he.jsx(yu,{text:o,opacity:W,fontUrl:n,stroke:w.cluster.label.stroke,active:!1,color:(Ue=w.cluster)==null?void 0:Ue.label.color,fontSize:((V=w.cluster)==null?void 0:V.label.fontSize)??12})})]})})},[w,K,Le,xe,R,j,T,t,$,k,o,W,n,r,l,a,pe,G,m,i])},FW=({animated:i,color:e="#D8E6EA",length:t,opacity:n=.5,position:r,rotation:s,size:a=1,onActive:o,onContextMenu:l})=>{const c=Q.useMemo(()=>new et(e),[e]),f=Q.useRef(null),d=$e(_=>_.draggingIds.length>0),p=$e(_=>_.centerPosition),[{pos:m,arrowOpacity:y}]=yr(()=>({from:{pos:p?[p.x,p.y,p.z]:[0,0,0],arrowOpacity:0},to:{pos:[r.x,r.y,r.z],arrowOpacity:n},config:{..._r,duration:i&&!d?void 0:0}}),[i,d,n,r]),x=Q.useCallback(()=>{var _;const g=new J(0,1,0);(_=f.current)==null||_.quaternion.setFromUnitVectors(g,s)},[s,f]);return Q.useEffect(()=>x(),[x]),he.jsxs(Bn.mesh,{position:m,ref:f,scale:[1,1,1],onPointerOver:()=>o(!0),onPointerOut:()=>o(!1),onPointerDown:_=>{_.nativeEvent.buttons===2&&(_.stopPropagation(),l())},children:[he.jsx("cylinderGeometry",{args:[0,a,t,20,1,!0],attach:"geometry"}),he.jsx(Bn.meshBasicMaterial,{attach:"material",color:c,depthTest:!1,opacity:y,transparent:!0,side:In,fog:!0})]})},BW=({curveOffset:i,animated:e,color:t="#000",curve:n,curved:r=!1,id:s,opacity:a=1,size:o=1,onContextMenu:l,onClick:c,onPointerOver:f,onPointerOut:d})=>{const p=Q.useRef(null),m=$e(b=>b.draggingIds.length>0),y=Q.useMemo(()=>new et(t),[t]),x=$e(b=>b.centerPosition),_=Q.useRef(!1),{lineOpacity:g}=yr({from:{lineOpacity:0},to:{lineOpacity:a},config:{..._r,duration:e?void 0:0}});return yr(()=>{const b=n.getPoint(0),S=n.getPoint(1);return{from:{fromVertices:_.current?[S?.x,S?.y,S?.z||0]:[x?.x,x?.y,x?.z||0],toVertices:[b?.x,b?.y,b?.z||0]},to:{fromVertices:[b?.x,b?.y,b?.z||0],toVertices:[S?.x,S?.y,S?.z||0]},onChange:E=>{const{fromVertices:w,toVertices:T}=E.value,R=new J(...w),U=new J(...T),D=Vf(R,0,U,0,r,i);p.current.copy(new Rl(D,20,o/2,5,!1))},config:{..._r,duration:e&&!m?void 0:0}}},[e,m,n,o]),Q.useEffect(()=>{_.current=!0},[]),he.jsxs("mesh",{userData:{id:s,type:"edge"},renderOrder:-1,onPointerOver:f,onPointerOut:d,onClick:c,onPointerDown:b=>{b.nativeEvent.buttons===2&&(b.stopPropagation(),l())},children:[he.jsx("tubeGeometry",{attach:"geometry",ref:p}),he.jsx(Bn.meshBasicMaterial,{attach:"material",opacity:g,fog:!0,transparent:!0,depthTest:!1,color:y})]})},yA=3,kW=({animated:i,arrowPlacement:e="end",contextMenu:t,disabled:n,labelPlacement:r="inline",id:s,interpolation:a,labelFontUrl:o,onContextMenu:l,onClick:c,onPointerOver:f,onPointerOut:d,subLabelPlacement:p="below"})=>{var m,y,x,_;const g=$e(re=>re.theme),b=$e(re=>re.draggingIds.length>0),[S,E]=Q.useState(!1),[w,T]=Q.useState(!1),R=$e(re=>re.edges),U=R.find(re=>re.id===s),{target:D,source:C,label:P,subLabel:I,labelVisible:O=!1,size:G=1,fill:Z}=U,z=U.subLabelPlacement||p,L=$e(re=>re.nodes.find(Ie=>Ie.id===C)),B=$e(re=>re.nodes.find(Ie=>Ie.id===D)),H=(G+g.edge.label.fontSize)/2,[W,k]=Q.useMemo(()=>P3(G),[G]),{curveOffset:K,curved:$}=Q.useMemo(()=>CW({edge:U,edges:R,curved:a==="curved"}),[U,R,a]),[j,ee,de]=Q.useMemo(()=>{const re=Wf(L),Ie=L.size,X=Wf(B),F=B.size;let ie=Vf(re,Ie,X,F,$,K);const[Se,ve]=I3(e,ie,W);return e==="end"&&(ie=Vf(re,Ie,Se,0,$,K)),[ie,Se,ve]},[L,B,$,K,e,W]),ae=Q.useMemo(()=>{let re=z3(L.position,B.position,N3(H,r));if($){const Ie=new J().subVectors(re,j.getPoint(.5));switch(r){case"above":Ie.y=Ie.y-yA;break;case"below":Ie.y=Ie.y+yA;break}re=re.sub(Ie)}return re},[L.position,B.position,H,r,$,j]),pe=$e(re=>{var Ie;return(Ie=re.selections)==null?void 0:Ie.includes(s)}),Le=$e(re=>{var Ie;return(Ie=re.selections)==null?void 0:Ie.length}),xe=$e(re=>{var Ie;return(Ie=re.actives)==null?void 0:Ie.includes(s)}),me=$e(re=>re.centerPosition),ne=Le?pe||xe?g.edge.selectedOpacity:g.edge.inactiveOpacity:g.edge.opacity,Ue=Q.useMemo(()=>RW(L.position,B.position,z),[L.position,B.position,z]),[{labelPosition:V}]=yr(()=>({from:{labelPosition:me?[me.x,me.y,me.z]:[0,0,0]},to:{labelPosition:[ae.x,ae.y,ae.z]},config:{..._r,duration:i&&!b?void 0:0}}),[ae,i,b]),se=Q.useMemo(()=>new Ui(0,0,r==="natural"?0:Math.atan((B.position.y-L.position.y)/(B.position.x-L.position.x))),[B.position.x,B.position.y,L.position.x,L.position.y,r]);El(S&&!b&&c!==void 0,"pointer");const{pointerOver:te,pointerOut:Ee}=ob({disabled:n,onPointerOver:re=>{E(!0),f?.(U,re)},onPointerOut:re=>{E(!1),d?.(U,re)}}),ce=Q.useMemo(()=>e!=="none"&&he.jsx(FW,{animated:i,color:pe||S||xe?g.arrow.activeFill:Z||g.arrow.fill,length:W,opacity:ne,position:ee,rotation:de,size:k,onActive:E,onContextMenu:()=>{n||(T(!0),l?.(U))}}),[Z,S,i,W,e,ee,de,k,n,U,xe,pe,l,ne,g.arrow.activeFill,g.arrow.fill]),De=Q.useMemo(()=>{var re,Ie,X,F;return O&&P&&he.jsxs(Bn.group,{position:V,onContextMenu:()=>{n||(T(!0),l?.(U))},onPointerOver:te,onPointerOut:Ee,children:[he.jsx(yu,{text:P,ellipsis:15,fontUrl:o,stroke:g.edge.label.stroke,color:pe||S||xe?g.edge.label.activeColor:g.edge.label.color,opacity:ne,fontSize:g.edge.label.fontSize,rotation:se}),I&&he.jsx("group",{position:[Ue.x,Ue.y,0],children:he.jsx(yu,{text:I,ellipsis:15,fontUrl:o,stroke:((re=g.edge.subLabel)==null?void 0:re.stroke)||g.edge.label.stroke,color:pe||S||xe?((Ie=g.edge.subLabel)==null?void 0:Ie.activeColor)||g.edge.label.activeColor:((X=g.edge.subLabel)==null?void 0:X.color)||g.edge.label.color,opacity:ne,fontSize:((F=g.edge.subLabel)==null?void 0:F.fontSize)||g.edge.label.fontSize*.8,rotation:se})})]})},[S,n,U,xe,pe,P,I,o,V,Ue,se,O,l,Ee,te,ne,g.edge.label.activeColor,g.edge.label.color,g.edge.label.fontSize,g.edge.label.stroke,(m=g.edge.subLabel)==null?void 0:m.stroke,(y=g.edge.subLabel)==null?void 0:y.activeColor,(x=g.edge.subLabel)==null?void 0:x.color,(_=g.edge.subLabel)==null?void 0:_.fontSize]),_e=Q.useMemo(()=>w&&t&&he.jsx(ib,{prepend:!0,center:!0,position:ae,children:t({data:U,onClose:()=>T(!1)})}),[w,t,ae,U]);return he.jsxs("group",{children:[he.jsx(BW,{curveOffset:K,animated:i,color:pe||S||xe?g.edge.activeFill:Z||g.edge.fill,curve:j,curved:$,id:s,opacity:ne,size:G,onClick:re=>{n||c?.(U,re)},onPointerOver:te,onPointerOut:Ee,onContextMenu:()=>{n||(T(!0),l?.(U))}}),ce,De,_e]})},_A=new Ea(0,0,0);function GW(i,e){const t=Q.useRef(null),n=$e(c=>c.theme);$e(c=>{t.current=c});const r=Q.useRef(new Map);Q.useRef(new Ea(0,0,0));const s=Q.useRef(null),a=e==="curved",o=Q.useCallback(c=>{const f=[],d=r.current,{nodes:p}=t.current,m=new Map(p.map(x=>[x.id,x])),y=n.edge.label.fontSize;return i!=="none"&&!s.current&&(s.current=new Su(0,1,1,20,1,!0)),c.forEach(x=>{const{target:_,source:g,size:b=1}=x,S=m.get(g),E=m.get(_);if(!S||!E)return;const w=`${S.position.x},${S.position.y},${E.position.x},${E.position.y},${b}`;if(d.has(w)){f.push(d.get(w));return}const T=Wf(S),R=S.size+y,U=Wf(E),D=E.size+y;let C=Vf(T,R,U,D,a),P=new Rl(C,20,b/2,5,!1);if(i==="none"){f.push(P),d.set(w,P);return}const[I,O]=P3(b),G=s.current.clone();G.scale(O,I,O);const[Z,z]=I3(i,C,I),L=new _i;if(L.setFromUnitVectors(new J(0,1,0),z),G.applyQuaternion(L),G.translate(Z.x,Z.y,Z.z),i&&i==="end"){const H=Vf(T,R,Z,0,a);P=new Rl(H,20,b/2,5,!1)}const B=Wp([P,G]);f.push(B),d.set(w,B)}),f},[i,a,n.edge.label.fontSize]),l=Q.useCallback((c,f)=>{const d=o(c),p=o(f);return Wp([p.length?Wp(p):_A,d.length?Wp(d):_A],!0)},[o]);return{getGeometries:o,getGeometry:l}}function HW(i,e,t){const n=Q.useRef(i);Q.useEffect(()=>{n.current=i},[i]);const r=$e(d=>d.edgeContextMenus),s=$e(Q.useCallback(d=>d.setEdgeContextMenus,[])),a=Q.useRef(!1),o=Q.useCallback(()=>{a.current=!0},[]),l=Q.useRef(!1),c=Q.useCallback(()=>{l.current=!0},[]),f=Q.useCallback((d,p)=>{const{onClick:m,onContextMenu:y,onPointerOver:x,onPointerOut:_}=n.current;if(m&&a.current&&!t){a.current=!1;for(const g of p)m(g)}if((e||y)&&l.current&&!t){l.current=!1;const g=new Set(r);let b=!1;for(const S of p)r.has(S.id)||(g.add(S.id),b=!0,y?.(S));b&&s(g)}x&&p.filter(b=>!d.includes(b)).forEach(b=>{x(b)}),_&&d.filter(b=>!p.includes(b)).forEach(b=>{_(b)})},[e,t,r,s]);return{handleClick:o,handleContextMenu:c,handleIntersections:f}}function VW(i,e){const t=Q.useRef(i),n=Q.useRef(null);Q.useEffect(()=>{t.current=i;const a=i.getAttribute("position");n.current=new Float32Array(a.array.length)},[i]);const r=Q.useCallback(()=>{const a=t.current.getAttribute("position");return{from:new Float32Array(a.array.length),to:a.array}},[]),s=Q.useCallback(a=>{const o=n.current;o.set(a);const l=new en(o,3,!1);t.current.setAttribute("position",l),l.needsUpdate=!0},[]);yr(()=>{if(!e)return null;const a=r();return{from:{positions:a.from},to:{positions:a.to},onChange:o=>{s(o.value.positions)},config:{..._r,duration:e?void 0:0}}},[e,r,s])}function WW(i,e,t){const[{activeOpacity:n,inactiveOpacity:r}]=yr(()=>({from:{activeOpacity:0,inactiveOpacity:0},to:{activeOpacity:e?t.edge.selectedOpacity:t.edge.opacity,inactiveOpacity:e?t.edge.inactiveOpacity:t.edge.opacity},config:{..._r,duration:i?void 0:0}}),[i,e,t]);return{activeOpacity:n,inactiveOpacity:r}}const XW=({animated:i,color:e,contextMenu:t,edge:n,labelFontUrl:r,labelPlacement:s="inline",opacity:a})=>{const o=$e(C=>C.theme),{target:l,source:c,label:f,labelVisible:d=!1,size:p=1}=n,m=$e(C=>C.nodes),[y,x]=Q.useMemo(()=>[m.find(C=>C.id===c),m.find(C=>C.id===l)],[m,c,l]),_=$e(C=>C.draggingIds.length>0),g=Q.useMemo(()=>(p+o.edge.label.fontSize)/2,[p,o.edge.label.fontSize]),b=Q.useMemo(()=>z3(y.position,x.position,N3(g,s)),[y.position,x.position,g,s]),S=$e(C=>C.edgeContextMenus),E=$e(C=>C.setEdgeContextMenus),[{labelPosition:w}]=yr(()=>({from:{labelPosition:[0,0,0]},to:{labelPosition:[b.x,b.y,b.z]},config:{..._r,duration:i&&!_?void 0:0}}),[b,i,_]),T=Q.useCallback(C=>{S.delete(C),E(new Set(S))},[S,E]),R=Q.useMemo(()=>s==="natural"?new Ui(0,0,0):new Ui(0,0,Math.atan2(x.position.y-y.position.y,x.position.x-y.position.x)),[s,x.position.y,x.position.x,y.position.y,y.position.x]),U=Q.useMemo(()=>({prepend:!0,center:!0,position:b}),[b]),D=Q.useMemo(()=>({text:f,ellipsis:15,fontUrl:r,stroke:o.edge.label.stroke,color:e,opacity:a,fontSize:o.edge.label.fontSize,rotation:R}),[f,r,o.edge.label.stroke,e,a,o.edge.label.fontSize,R]);return he.jsxs("group",{children:[d&&f&&he.jsx(Bn.group,{position:w,children:he.jsx(yu,{...D})}),t&&S.has(n.id)&&he.jsx(ib,{...U,children:t({data:n,onClose:()=>T(n.id)})})]})},jW=({interpolation:i="linear",arrowPlacement:e="end",labelPlacement:t="inline",animated:n,contextMenu:r,disabled:s,edges:a,labelFontUrl:o,onClick:l,onContextMenu:c,onPointerOut:f,onPointerOver:d})=>{const p=$e(W=>W.theme),{getGeometries:m,getGeometry:y}=GW(e,i),x=$e(W=>W.draggingIds),_=$e(W=>W.edgeMeshes),g=$e(W=>W.setEdgeMeshes),b=$e(W=>W.actives||[]),S=$e(W=>W.selections||[]),[E,w,T,R]=Q.useMemo(()=>{const W=[],k=[],K=[],$=[];return a.forEach(j=>{if(x.includes(j.source)||x.includes(j.target)){S.includes(j.id)||b.includes(j.id)?K.push(j):$.push(j);return}S.includes(j.id)||b.includes(j.id)?W.push(j):k.push(j)}),[W,k,K,$]},[a,b,S,x]),U=!!S.length,D=Q.useMemo(()=>y(E,w),[y,E,w]),{activeOpacity:C,inactiveOpacity:P}=WW(n,U,p);VW(D,n),Q.useEffect(()=>{if(x.length===0){const k=m(a).map(K=>new pn(K));g(k)}},[m,g,a,x.length]);const I=Q.useRef(new pn),O=Q.useRef(new pn),G=Q.useCallback(W=>{if(!W.camera)return[];const k=W.intersectObjects(_);return k.length?k.map(K=>a[_.indexOf(K.object)]):[]},[_,a]),{handleClick:Z,handleContextMenu:z,handleIntersections:L}=HW({onClick:l,onContextMenu:c,onPointerOut:f,onPointerOver:d},r,s),B=Q.useRef([]),H=Q.useRef([]);return s0(W=>{if(I.current.geometry=D,s)return;const k=B.current;if((x.length||x.length===0&&k!==null)&&(O.current.geometry=y(T,R)),B.current=x,x.length)return;const K=H.current,$=G(W.raycaster);L(K,$),$.join()!==K.join()&&(O.current.geometry=y($,[])),H.current=$}),he.jsxs("group",{onClick:Z,onContextMenu:z,children:[he.jsxs("mesh",{ref:I,children:[he.jsx(Bn.meshBasicMaterial,{attach:"material-0",color:p.edge.fill,depthTest:!1,fog:!0,opacity:P,side:In,transparent:!0}),he.jsx(Bn.meshBasicMaterial,{attach:"material-1",color:p.edge.activeFill,depthTest:!1,fog:!0,opacity:C,side:In,transparent:!0})]}),he.jsxs("mesh",{ref:O,children:[he.jsx(Bn.meshBasicMaterial,{attach:"material-0",color:p.edge.fill,depthTest:!1,fog:!0,opacity:P,side:In,transparent:!0}),he.jsx(Bn.meshBasicMaterial,{attach:"material-1",color:p.edge.activeFill,depthTest:!1,fog:!0,opacity:C,side:In,transparent:!0})]}),a.map(W=>he.jsx(XW,{animated:n,contextMenu:r,color:p.edge.label.color,disabled:s,edge:W,labelFontUrl:o,labelPlacement:t},W.id))]})},qW=({color:i="#D8E6EA",size:e=1,opacity:t=.5,animated:n,strokeWidth:r=5,innerRadius:s=4,segments:a=25})=>{const o=Q.useMemo(()=>new et(i),[i]),{ringSize:l,ringOpacity:c}=yr({from:{ringOpacity:0,ringSize:[1e-5,1e-5,1e-5]},to:{ringOpacity:t,ringSize:[e/2,e/2,1]},config:{..._r,duration:n?void 0:0}}),f=r/10,d=s+f;return he.jsx(v3,{position:[0,0,1],children:he.jsxs(Bn.mesh,{scale:l,children:[he.jsx("ringGeometry",{attach:"geometry",args:[s,d,a]}),he.jsx(Bn.meshBasicMaterial,{attach:"material",color:o,transparent:!0,depthTest:!1,opacity:c,side:In,fog:!0})]})})},YW=({color:i,id:e,size:t,selected:n,opacity:r=1,animated:s})=>{const{scale:a,nodeOpacity:o}=yr({from:{scale:[1e-5,1e-5,1e-5],nodeOpacity:0},to:{scale:[t,t,t],nodeOpacity:r},config:{..._r,duration:s?void 0:0}}),l=Q.useMemo(()=>new et(i),[i]),c=$e(f=>f.theme);return he.jsxs(he.Fragment,{children:[he.jsxs(Bn.mesh,{userData:{id:e,type:"node"},scale:a,children:[he.jsx("sphereGeometry",{attach:"geometry",args:[1,25,25]}),he.jsx(Bn.meshPhongMaterial,{attach:"material",side:In,transparent:!0,fog:!0,opacity:o,color:l,emissive:l,emissiveIntensity:.7})]}),he.jsx(qW,{opacity:n?.5:0,size:t,animated:s,color:n?c.ring.activeFill:c.ring.fill})]})},ZW=({image:i,id:e,size:t,opacity:n=1,animated:r})=>{const s=Q.useMemo(()=>new $2().load(i),[i]),{scale:a,spriteOpacity:o}=yr({from:{scale:[1e-5,1e-5,1e-5],spriteOpacity:0},to:{scale:[t,t,t],spriteOpacity:n},config:{..._r,duration:r?void 0:0}});return he.jsx(Bn.sprite,{userData:{id:e,type:"node"},scale:a,children:he.jsx(Bn.spriteMaterial,{attach:"material",opacity:o,fog:!0,depthTest:!1,transparent:!0,side:In,children:he.jsx("primitive",{attach:"map",object:s,minFilter:Pn})})})},KW=({animated:i,disabled:e,id:t,draggable:n=!1,labelFontUrl:r,contextMenu:s,onClick:a,onDoubleClick:o,onPointerOver:l,onDragged:c,onPointerOut:f,onContextMenu:d,renderNode:p,constrainDragging:m})=>{var y,x,_;const g=x0(),b=$e(F=>F.theme),S=$e(F=>F.nodes.find(ie=>ie.id===t)),E=$e(F=>F.edges),w=$e(F=>F.draggingIds),T=$e(F=>F.collapsedNodeIds),R=$e(F=>F.addDraggingId),U=$e(F=>F.removeDraggingId),D=$e(F=>F.setHoveredNodeId),C=$e(F=>F.setNodePosition),P=$e(F=>F.setCollapsedNodeIds),I=$e(F=>F.collapsedNodeIds.includes(t)),O=$e(F=>{var ie;return(ie=F.actives)==null?void 0:ie.includes(t)}),G=$e(F=>{var ie;return(ie=F.selections)==null?void 0:ie.includes(t)}),Z=$e(F=>{var ie;return((ie=F.selections)==null?void 0:ie.length)>0}),z=$e(F=>F.centerPosition),L=$e(F=>F.clusters.get(S.cluster)),B=w.includes(t),H=w.length>0,{position:W,label:k,subLabel:K,size:$=7,labelVisible:j=!0}=S,ee=Q.useRef(null),[de,ae]=Q.useState(!1),[pe,Le]=Q.useState(!1),xe=de||G||O,me=Z?xe?b.node.selectedOpacity:b.node.inactiveOpacity:b.node.opacity,ne=Q.useMemo(()=>E.filter(ie=>ie.source===t).length>0||I,[E,t,I]),Ue=Q.useCallback(()=>{ne&&P(I?T.filter(F=>F!==t):[...T,t])},[ne,T,t,I,P]),[{nodePosition:V,labelPosition:se}]=yr(()=>({from:{nodePosition:z?[z.x,z.y,0]:[0,0,0],labelPosition:[0,-($+7),2]},to:{nodePosition:W?[W.x,W.y,xe?W.z+1:W.z]:[0,0,0],labelPosition:[0,-($+7),2]},config:{..._r,duration:i&&!H?void 0:0}}),[B,W,i,$,xe]),te=H3({draggable:n,position:W,bounds:m?L?.position:void 0,set:F=>C(t,F),onDragStart:()=>{R(t),ae(!0)},onDragEnd:()=>{U(t),c?.(S)}});El(de&&!H&&a!==void 0,"pointer"),El(de&&n&&!B&&a===void 0,"grab"),El(B,"grabbing");const Ee=xe||B,ce=Ee?b.node.activeFill:S.fill||b.node.fill,{pointerOver:De,pointerOut:_e}=ob({disabled:e||B,onPointerOver:F=>{g.freeze(),ae(!0),l?.(S,F),D(t)},onPointerOut:F=>{g.unFreeze(),ae(!1),f?.(S,F),D(null)}}),re=Q.useMemo(()=>p?p({id:t,color:ce,size:$,active:Ee,opacity:me,animated:i,selected:G,node:S}):he.jsx(he.Fragment,{children:S.icon?he.jsx(ZW,{id:t,image:S.icon||"",size:$+8,opacity:me,animated:i,color:ce,node:S,active:Ee,selected:G}):he.jsx(YW,{id:t,size:$,opacity:me,animated:i,color:ce,node:S,active:Ee,selected:G})}),[p,t,ce,$,Ee,me,i,G,S]),Ie=Q.useMemo(()=>{var F,ie,Se;return j&&(j||G||de)&&k&&he.jsxs(Bn.group,{position:se,children:[he.jsx(yu,{text:k,fontUrl:r,opacity:me,stroke:b.node.label.stroke,active:G||de||B||O,color:G||de||B||O?b.node.label.activeColor:b.node.label.color}),K&&he.jsx("group",{position:[0,-($-3),0],children:he.jsx(yu,{text:K,fontUrl:r,fontSize:5,opacity:me,stroke:(F=b.node.subLabel)==null?void 0:F.stroke,active:G||de||B||O,color:G||de||B||O?(ie=b.node.subLabel)==null?void 0:ie.activeColor:(Se=b.node.subLabel)==null?void 0:Se.color})})]})},[de,O,B,G,k,r,se,j,$,me,K,b.node.label.activeColor,b.node.label.color,b.node.label.stroke,(y=b.node.subLabel)==null?void 0:y.activeColor,(x=b.node.subLabel)==null?void 0:x.color,(_=b.node.subLabel)==null?void 0:_.stroke]),X=Q.useMemo(()=>pe&&s&&he.jsx(ib,{prepend:!0,center:!0,children:s({data:S,canCollapse:ne,isCollapsed:I,onCollapse:Ue,onClose:()=>Le(!1)})}),[pe,s,S,ne,I,Ue]);return he.jsxs(Bn.group,{renderOrder:1,userData:{id:t,type:"node"},ref:ee,position:V,onPointerOver:De,onPointerOut:_e,onClick:F=>{!e&&!B&&a?.(S,{canCollapse:ne,isCollapsed:I},F)},onDoubleClick:F=>{!e&&!B&&o?.(S,F)},onContextMenu:()=>{e||(Le(!0),d?.(S,{canCollapse:ne,isCollapsed:I,onCollapse:Ue}))},...te(),children:[re,X,Ie]})};function W3(i,e){const t=e.position.z;i<t?i-=t:i+=t;const n=e.fov/e.zoom*Math.PI/180;return 2*Math.tan(n/2)*Math.abs(i)}function JW(i,e){return W3(i,e)*e.aspect}function xA(i,e){var t,n,r,s;const a=JW(1,i),o=W3(1,i),l={x0:((t=i?.position)==null?void 0:t.x)-a/2,x1:((n=i?.position)==null?void 0:n.x)+a/2,y0:((r=i?.position)==null?void 0:r.y)-o/2,y1:((s=i?.position)==null?void 0:s.y)+o/2};return e?.x>l.x0&&e?.x<l.x1&&e?.y>l.y0&&e?.y<l.y1}function bA(i,e){return e.reduce((t,n)=>Math.abs(n-i%Math.PI)<Math.abs(t-i%Math.PI)?n:t)}function QW(i,e){const t=bA(i,[0,Math.PI]),n=bA(e,[Math.PI/2,3*Math.PI/2]);return{horizontalRotation:t-i%Math.PI,verticalRotation:n-e%Math.PI}}const $p=50,$W=({animated:i,disabled:e,layoutType:t})=>{const n=$e(x=>x.nodes),[r,s]=Q.useState(!1),a=Kn(x=>x.invalidate),{controls:o}=x0(),l=Kn(x=>x.camera),c=Q.useRef(!1),f=Q.useCallback(async(x,_)=>{const g=_?.animated!==void 0?_?.animated:!0,b=_?.centerOnlyIfNodesNotInView!==void 0?_?.centerOnlyIfNodesNotInView:!1;if(!c.current||!b||b&&x?.some(S=>!xA(l,S.position))){const{x:S,y:E,z:w}=Xf(x);await o.setTarget(S,E,w,g),r||s(!0),a()}},[a,o,n]),d=Q.useCallback(async(x,_={animated:!0,fitOnlyIfNodesNotInView:!1})=>{const{fitOnlyIfNodesNotInView:g}=_;if(!g||g&&x?.some(b=>!xA(l,b.position))){const{minX:b,maxX:S,minY:E,maxY:w,minZ:T,maxZ:R}=Xf(x);if(!t.includes("3d")){const{horizontalRotation:U,verticalRotation:D}=QW(o?.azimuthAngle,o?.polarAngle);o?.rotate(U,D,!0)}await o?.zoomTo(1,_?.animated),await o?.fitToBox(new Jn(new J(b,E,T),new J(S,w,R)),_?.animated,{cover:!1,paddingLeft:$p,paddingRight:$p,paddingBottom:$p,paddingTop:$p})}},[l,o,t]),p=Q.useCallback(x=>{let _=null;return x?.length&&(_=x.reduce((g,b)=>{const S=n.find(E=>E.id===b);if(S)g.push(S);else throw new Error(`Attempted to center ${b} but it was not found in the nodes`);return g},[])),_},[n]),m=Q.useCallback((x,_)=>{const g=p(x);f(g||n,{animated:i,centerOnlyIfNodesNotInView:_?.centerOnlyIfNodesNotInView})},[i,f,p,n]),y=Q.useCallback(async(x,_)=>{const g=p(x);await d(g||n,{animated:i,..._})},[i,d,p,n]);return Q.useLayoutEffect(()=>{async function x(){o&&n?.length&&(c.current||(await f(n,{animated:!1}),await d(n,{animated:!1}),c.current=!0))}x()},[o,f,n,i,l,d]),{centerNodes:f,centerNodesById:m,fitNodesInViewById:y,isCentered:r}},eX=i=>i.reduceEdges((e,t,n,r,s)=>{const a=`${r}-${s}`,o={id:t,source:r,target:s,...n},l=e.get(a);return l?l.push(o):e.set(a,[o]),e},new Map),tX=(i,e)=>{if(!i||i.size===0)return[];const t=eX(i),n=[],r=e==="all"||e==="edges";for(const[s,a]of t){const[o,l]=s.split("-"),c=a[0];if(!o||!l||!c)continue;const f=c.size||1,d=f+a.length*f*.5,p={...c,source:o,target:l,label:`${a.length} edges`,labelVisible:r,size:d,data:{...c.data||{},originalEdges:a,count:a.length,isAggregated:!0,originalSize:f}};n.push(p)}return n},nX=Q.forwardRef(({onNodeClick:i,onNodeDoubleClick:e,onNodeContextMenu:t,onEdgeContextMenu:n,onEdgeClick:r,onEdgePointerOver:s,onEdgePointerOut:a,onNodePointerOver:o,onNodePointerOut:l,onClusterClick:c,onNodeDragged:f,onClusterDragged:d,onClusterPointerOver:p,onClusterPointerOut:m,contextMenu:y,animated:x,disabled:_,draggable:g,constrainDragging:b=!1,edgeLabelPosition:S,edgeArrowPosition:E,edgeInterpolation:w="linear",labelFontUrl:T,renderNode:R,onRenderCluster:U,aggregateEdges:D,...C},P)=>{const{layoutType:I,clusterAttribute:O,labelType:G}=C,Z=Kn(ne=>ne.gl),z=Kn(ne=>ne.scene),L=Kn(ne=>ne.camera),{updateLayout:B}=IW({...C,constrainDragging:b});if(O&&!(I==="forceDirected2d"||I==="forceDirected3d"))throw new Error("Clustering is only supported for the force directed layouts.");const H=$e(ne=>ne.graph),W=$e(ne=>ne.nodes),k=$e(ne=>ne.edges),K=$e(ne=>ne.setEdges),$=$e(ne=>[...ne.clusters.values()]),j=Q.useMemo(()=>D?tX(H,G):k,[k,D,H,G]);Q.useEffect(()=>{D&&k.length!==j.length&&K(j)},[j,k.length,K,D]);const{centerNodesById:ee,fitNodesInViewById:de,isCentered:ae}=$W({animated:x,disabled:_,layoutType:I});Q.useImperativeHandle(P,()=>({centerGraph:ee,fitNodesInView:de,graph:H,renderScene:()=>Z.render(z,L)}),[ee,de,H,Z,z,L]);const pe=Q.useCallback(ne=>{f?.(ne),O&&B()},[O,f,B]),Le=Q.useMemo(()=>W.map(ne=>he.jsx(KW,{id:ne?.id,labelFontUrl:T,draggable:g,constrainDragging:b,disabled:_,animated:x,contextMenu:y,renderNode:R,onClick:i,onDoubleClick:e,onContextMenu:t,onPointerOver:o,onPointerOut:l,onDragged:pe},ne?.id)),[b,x,y,_,g,T,W,i,t,e,pe,l,o,R]),xe=Q.useMemo(()=>x?j.map(ne=>he.jsx(kW,{id:ne.id,disabled:_,animated:x,labelFontUrl:T,labelPlacement:S,arrowPlacement:E,interpolation:w,contextMenu:y,onClick:r,onContextMenu:n,onPointerOver:s,onPointerOut:a},ne.id)):he.jsx(jW,{edges:j,disabled:_,animated:x,labelFontUrl:T,labelPlacement:S,arrowPlacement:E,interpolation:w,contextMenu:y,onClick:r,onContextMenu:n,onPointerOver:s,onPointerOut:a}),[x,y,_,E,w,S,j,T,r,n,a,s]),me=Q.useMemo(()=>$.map(ne=>he.jsx(zW,{animated:x,disabled:_,draggable:g,labelFontUrl:T,onClick:c,onPointerOver:p,onPointerOut:m,onDragged:d,onRender:U,...ne},ne.label)),[x,$,_,g,T,c,m,p,d,U]);return ae&&he.jsxs(Q.Fragment,{children:[xe,Le,me]})});di.install({THREE:{MOUSE:EA,Vector2:Ge,Vector3:J,Vector4:kt,Quaternion:_i,Matrix4:bt,Spherical:dC,Box3:Jn,Sphere:ri,Raycaster:_1,MathUtils:{DEG2RAD:(cA=Jm)==null?void 0:cA.DEG2RAD,clamp:(uA=Jm)==null?void 0:uA.clamp}}});PC({ThreeCameraControls:di});const em={ARROW_LEFT:37,ARROW_UP:38,ARROW_RIGHT:39,ARROW_DOWN:40},iX=Q.forwardRef(({mode:i="rotate",children:e,animated:t,disabled:n,minDistance:r=1e3,maxDistance:s=5e4},a)=>{const o=Q.useRef(null),l=Kn(O=>O.camera),c=Kn(O=>O.gl),f=i==="orbit",d=$e(O=>O.setPanning),p=$e(O=>O.draggingIds.length>0),m=Q.useRef(0),[y,x]=Q.useState(!1);s0((O,G)=>{var Z,z;(Z=o.current)!=null&&Z.enabled&&((z=o.current)==null||z.update(G)),f&&(o.current.azimuthAngle+=20*G*Jm.DEG2RAD)},-1),Q.useEffect(()=>()=>{var O;return(O=o.current)==null?void 0:O.dispose()},[]);const _=Q.useCallback(()=>{var O;(O=o.current)==null||O.zoom(l.zoom/2,t)},[t,l.zoom]),g=Q.useCallback(()=>{var O;(O=o.current)==null||O.zoom(-l.zoom/2,t)},[t,l.zoom]),b=Q.useCallback(O=>{var G;(G=o.current)==null||G.dolly(O,t)},[t]),S=Q.useCallback(O=>{var G;(G=o.current)==null||G.dolly(O,t)},[t]),E=Q.useCallback(O=>{var G;f||(G=o.current)==null||G.truck(-.03*O.deltaTime,0,t)},[t,f]),w=Q.useCallback(O=>{var G;f||(G=o.current)==null||G.truck(.03*O.deltaTime,0,t)},[t,f]),T=Q.useCallback(O=>{var G;f||(G=o.current)==null||G.truck(0,.03*O.deltaTime,t)},[t,f]),R=Q.useCallback(O=>{var G;f||(G=o.current)==null||G.truck(0,-.03*O.deltaTime,t)},[t,f]),U=Q.useCallback(O=>{O.code==="Space"&&(i==="rotate"?o.current.mouseButtons.left=di.ACTION.TRUCK:o.current.mouseButtons.left=di.ACTION.ROTATE)},[i]),D=Q.useCallback(O=>{O.code==="Space"&&(i==="rotate"?o.current.mouseButtons.left=di.ACTION.ROTATE:o.current.mouseButtons.left=di.ACTION.TRUCK)},[i]),[C,P]=Q.useState(null);Q.useEffect(()=>{ab||P({leftKey:new Qp(em.ARROW_LEFT,100),rightKey:new Qp(em.ARROW_RIGHT,100),upKey:new Qp(em.ARROW_UP,100),downKey:new Qp(em.ARROW_DOWN,100)})},[]),Q.useEffect(()=>(!n&&C&&(C.leftKey.addEventListener("holding",w),C.rightKey.addEventListener("holding",E),C.upKey.addEventListener("holding",T),C.downKey.addEventListener("holding",R),window.addEventListener("keydown",U),window.addEventListener("keyup",D)),()=>{C&&(C.leftKey.removeEventListener("holding",w),C.rightKey.removeEventListener("holding",E),C.upKey.removeEventListener("holding",T),C.downKey.removeEventListener("holding",R),window.removeEventListener("keydown",U),window.removeEventListener("keyup",D))}),[n,U,D,R,w,E,T,C]),Q.useEffect(()=>{n?(o.current.mouseButtons.left=di.ACTION.NONE,o.current.mouseButtons.middle=di.ACTION.NONE,o.current.mouseButtons.wheel=di.ACTION.NONE):(o.current.mouseButtons.left=di.ACTION.TRUCK,o.current.mouseButtons.middle=di.ACTION.TRUCK,o.current.mouseButtons.wheel=di.ACTION.DOLLY)},[n]),Q.useEffect(()=>{const O=()=>d(!0),G=()=>d(!1),Z=o.current;return Z&&(Z.addEventListener("control",O),Z.addEventListener("controlend",G)),()=>{Z&&(Z.removeEventListener("control",O),Z.removeEventListener("controlend",G))}},[o,d]),Q.useEffect(()=>{p?(o.current.mouseButtons.left=di.ACTION.NONE,o.current.touches.one=di.ACTION.NONE):i==="rotate"?(o.current.mouseButtons.left=di.ACTION.ROTATE,o.current.touches.one=di.ACTION.TOUCH_ROTATE):(o.current.touches.one=di.ACTION.TOUCH_TRUCK,o.current.mouseButtons.left=di.ACTION.TRUCK)},[p,i]);const I=Q.useMemo(()=>({controls:o.current,zoomIn:()=>_(),zoomOut:()=>g(),dollyIn:(O=1e3)=>b(O),dollyOut:(O=-1e3)=>S(O),panLeft:(O=100)=>w({deltaTime:O}),panRight:(O=100)=>E({deltaTime:O}),panDown:(O=100)=>R({deltaTime:O}),panUp:(O=100)=>T({deltaTime:O}),resetControls:O=>{var G;return(G=o.current)==null?void 0:G.reset(O)},freeze:()=>{o.current.truckSpeed&&(m.current=o.current.truckSpeed),o.current.truckSpeed=0},unFreeze:()=>o.current.truckSpeed=m.current}),[_,g,w,E,R,T,o.current]);return Q.useImperativeHandle(a,()=>I),he.jsxs(V3.Provider,{value:I,children:[he.jsx("threeCameraControls",{ref:O=>{o.current=O,y||x(!0)},args:[l,c.domElement],smoothTime:.1,minDistance:r,dollyToCursor:!0,maxDistance:s}),e]})}),X3={canvas:{background:"#fff"},node:{fill:"#7CA0AB",activeFill:"#1DE9AC",opacity:1,selectedOpacity:1,inactiveOpacity:.2,label:{color:"#2A6475",stroke:"#fff",activeColor:"#1DE9AC"},subLabel:{color:"#ddd",stroke:"transparent",activeColor:"#1DE9AC"}},lasso:{border:"1px solid #55aaff",background:"rgba(75, 160, 255, 0.1)"},ring:{fill:"#D8E6EA",activeFill:"#1DE9AC"},edge:{fill:"#D8E6EA",activeFill:"#1DE9AC",opacity:1,selectedOpacity:1,inactiveOpacity:.1,label:{stroke:"#fff",color:"#2A6475",activeColor:"#1DE9AC",fontSize:6},subLabel:{color:"#ddd",stroke:"transparent",activeColor:"#1DE9AC"}},arrow:{fill:"#D8E6EA",activeFill:"#1DE9AC"},cluster:{stroke:"#D8E6EA",opacity:1,selectedOpacity:1,inactiveOpacity:.1,label:{stroke:"#fff",color:"#2A6475"}}};function z_(i,e,t){e=Array.isArray(e)?e:[e];const n=[],r=[];for(const s of e){const a=[...i.inEdgeEntries(s)??[],...i.outEdgeEntries(s)??[]];if(a)for(const o of a){const l=o.attributes.id;if(t==="in"?o.target===s&&!r.includes(l)&&r.push(l):t==="out"?o.source===s&&!r.includes(l)&&r.push(l):r.includes(l)||r.push(l),t==="out"||t==="all"){const c=o.target;n.includes(c)||n.push(c)}(t==="in"||t==="all")&&(n.includes(o.source)||n.push(o.source))}}return{nodes:n,edges:r}}function tm(i,e,t){const{offsetX:n,offsetY:r}=i,{width:s,height:a}=t;e.set(n/s*2-1,-(r/a)*2+1)}function rX(i){const e=document.createElement("div");return e.style.pointerEvents="none",e.style.border=i.lasso.border,e.style.backgroundColor=i.lasso.background,e.style.position="fixed",e}const sX=({children:i,type:e="none",onLasso:t,onLassoEnd:n,disabled:r})=>{var s;const a=$e(I=>I.theme),o=Kn(I=>I.camera),l=Kn(I=>I.gl),c=Kn(I=>I.setEvents),f=Kn(I=>I.size),d=Kn(I=>I.get),p=Kn(I=>I.scene),m=x0(),y=$e(I=>I.actives),x=$e(I=>I.setActives),_=$e(I=>I.edges),g=$e(I=>I.edgeMeshes),b=Q.useRef(null),S=Q.useRef(null),E=Q.useRef(rX(a)),w=Q.useRef(null),T=Q.useRef(!1),R=Q.useRef(d().events.enabled),U=Q.useRef((s=m.controls)==null?void 0:s.enabled),D=Q.useCallback(I=>{if(T.current){const[O,G,Z]=w.current;Z.x=Math.max(O.x,I.clientX),Z.y=Math.max(O.y,I.clientY),G.x=Math.min(O.x,I.clientX),G.y=Math.min(O.y,I.clientY),E.current.style.left=`${G.x}px`,E.current.style.top=`${G.y}px`,E.current.style.width=`${Z.x-G.x}px`,E.current.style.height=`${Z.y-G.y}px`,tm(I,b.current.endPoint,f),tm(I,S.current.endPoint,f);const z=[],L=S.current.select().sort(H=>H.uuid).map(H=>_[g.indexOf(H)].id);z.push(...L);const B=b.current.select().sort(H=>H.uuid).filter(H=>{var W,k;return H.isMesh&&((W=H.userData)==null?void 0:W.id)&&(((k=H.userData)==null?void 0:k.type)===e||e==="all")}).map(H=>H.userData.id);z.push(...B),requestAnimationFrame(()=>{x(z),t?.(z)}),document.addEventListener("pointermove",D,{passive:!0,capture:!0,once:!0})}},[f,_,g,e,x,t]),C=Q.useCallback(()=>{var I;T.current&&(c({enabled:R.current}),T.current=!1,(I=E.current.parentElement)==null||I.removeChild(E.current),m.controls.enabled=U.current,n?.(y),document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",C))},[c,m.controls,n,y,D]),P=Q.useCallback(I=>{var O,G;if(I.shiftKey){R.current=d().events.enabled,U.current=(O=m.controls)==null?void 0:O.enabled,b.current=new FT(o,p);const Z=new zg;g.length&&Z.add(...g),S.current=new FT(o,Z),w.current=[new Ge,new Ge,new Ge];const[z]=w.current;m.controls.enabled=!1,c({enabled:!1}),T.current=!0,(G=l.domElement.parentElement)==null||G.appendChild(E.current),E.current.style.left=`${I.clientX}px`,E.current.style.top=`${I.clientY}px`,E.current.style.width="0px",E.current.style.height="0px",z.x=I.clientX,z.y=I.clientY,tm(I,b.current.startPoint,f),tm(I,S.current.startPoint,f),document.addEventListener("pointermove",D,{passive:!0,capture:!0,once:!0}),document.addEventListener("pointerup",C,{passive:!0})}},[o,m.controls,g,d,l.domElement.parentElement,D,C,p,c,f]);return Q.useEffect(()=>{if(!(r||e==="none"))return typeof window<"u"&&(document.addEventListener("pointerdown",P,{passive:!0}),document.addEventListener("pointermove",D,{passive:!0}),document.addEventListener("pointerup",C,{passive:!0})),()=>{typeof window<"u"&&(document.removeEventListener("pointerdown",P),document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",C))}},[e,r,P,D,C]),he.jsx("group",{children:i})},aX="_canvas_670zp_1",oX={canvas:aX},lX={alpha:!0,antialias:!0},cX={position:[0,0,1e3],near:5,far:5e4,fov:10},uX=Q.forwardRef(({cameraMode:i="pan",layoutType:e="forceDirected2d",sizingType:t="default",labelType:n="auto",theme:r=X3,animated:s=!0,defaultNodeSize:a=7,minNodeSize:o=5,maxNodeSize:l=15,lassoType:c="none",glOptions:f={},edges:d,children:p,nodes:m,minDistance:y,maxDistance:x,onCanvasClick:_,disabled:g,onLasso:b,onLassoEnd:S,aggregateEdges:E,...w},T)=>{var R,U;const D=Q.useRef(null),C=Q.useRef(null),P=Q.useRef(null);Q.useImperativeHandle(T,()=>({centerGraph:(B,H)=>{var W;return(W=D.current)==null?void 0:W.centerGraph(B,H)},fitNodesInView:(B,H)=>{var W;return(W=D.current)==null?void 0:W.fitNodesInView(B,H)},zoomIn:()=>{var B;return(B=C.current)==null?void 0:B.zoomIn()},zoomOut:()=>{var B;return(B=C.current)==null?void 0:B.zoomOut()},dollyIn:B=>{var H;return(H=C.current)==null?void 0:H.dollyIn(B)},dollyOut:B=>{var H;return(H=C.current)==null?void 0:H.dollyOut(B)},panLeft:()=>{var B;return(B=C.current)==null?void 0:B.panLeft()},panRight:()=>{var B;return(B=C.current)==null?void 0:B.panRight()},panDown:()=>{var B;return(B=C.current)==null?void 0:B.panDown()},panUp:()=>{var B;return(B=C.current)==null?void 0:B.panUp()},resetControls:B=>{var H;return(H=C.current)==null?void 0:H.resetControls(B)},getControls:()=>{var B;return(B=C.current)==null?void 0:B.controls},getGraph:()=>{var B;return(B=D.current)==null?void 0:B.graph},exportCanvas:()=>(D.current.renderScene(),P.current.toDataURL()),freeze:()=>{var B;return(B=C.current)==null?void 0:B.freeze()},unFreeze:()=>{var B;return(B=C.current)==null?void 0:B.unFreeze()}}));const{selections:I,actives:O,collapsedNodeIds:G}=w,Z=d.length+m.length>400?!1:s,z=Q.useMemo(()=>({...f,...lX}),[f]),L=Q.useRef(F3({selections:I,actives:O,theme:r,collapsedNodeIds:G})).current;return he.jsx("div",{className:oX.canvas,children:he.jsx(U5,{legacy:!0,linear:!0,ref:P,flat:!0,gl:z,camera:cX,onPointerMissed:_,children:he.jsxs(LW,{store:L,children:[((R=r.canvas)==null?void 0:R.background)&&he.jsx("color",{attach:"background",args:[r.canvas.background]}),he.jsx("ambientLight",{intensity:1}),p,((U=r.canvas)==null?void 0:U.fog)&&he.jsx("fog",{attach:"fog",args:[r.canvas.fog,4e3,9e3]}),he.jsx(iX,{mode:i,ref:C,disabled:g,minDistance:y,maxDistance:x,animated:s,children:he.jsx(sX,{disabled:g,type:c,onLasso:b,onLassoEnd:S,children:he.jsx(Q.Suspense,{children:he.jsx(nX,{ref:D,disabled:g,animated:Z,edges:d,nodes:m,layoutType:e,sizingType:t,labelType:n,defaultNodeSize:a,minNodeSize:o,maxNodeSize:l,aggregateEdges:E,...w})})})})]})})})}),hX=({selections:i=[],nodes:e=[],actives:t=[],focusOnSelect:n=!0,type:r="single",pathHoverType:s="out",pathSelectionType:a="direct",ref:o,disabled:l,onSelection:c})=>{const[f,d]=Q.useState([]),[p,m]=Q.useState(t),[y,x]=Q.useState(i),[_,g]=Q.useState(!1),b=r==="multi"||r==="multiModifier",S=Q.useCallback(L=>{if(!l&&L){L=Array.isArray(L)?L:[L];const B=L.filter(H=>!y.includes(H));if(B.length){const H=[...y,...B];c?.(H),x(H)}}},[l,y,c]),E=Q.useCallback(L=>{if(!l&&L){L=Array.isArray(L)?L:[L];const B=y.filter(H=>!L.includes(H));c?.(B),x(B)}},[l,y,c]),w=Q.useCallback((L=[])=>{l||(L=Array.isArray(L)?L:[L],m([]),x(L),c?.(L))},[l,c]),T=Q.useCallback(L=>{y.includes(L)?E(L):b?S(L):w(L)},[S,w,y,b,E]),R=Q.useCallback(L=>{if(b?r==="multiModifier"?_?S(L.id):w(L.id):S(L.id):w(L.id),n===!0||n==="singleOnly"&&!_){if(!o.current)throw new Error("No ref found for the graph canvas.");const B=o.current.getGraph(),{nodes:H}=z_(B,[L.id],a);o.current.fitNodesInView([L.id,...H],{fitOnlyIfNodesNotInView:!0})}},[S,w,n,b,_,a,o,r]),U=Q.useCallback((L,B)=>{const H=o.current.getGraph();if(!H)throw new Error("Graph is not initialized");const W=OW(H,L,B);w([L,B]);const k=[];for(let K=0;K<W.length-1;K++){const $=W[K],j=W[K+1],ee=H.getEdgeAttributes($,j);ee&&k.push(ee.id)}m([...W.map(K=>K),...k])},[w,o]),D=Q.useCallback(L=>{const B=L.target,H=vA(B),W=L.metaKey||L.ctrlKey;H&&W&&g(!0)},[]),C=Q.useCallback(L=>{const B=L.target,H=vA(B),W=["Meta","Control"].includes(L.key);H&&W&&g(!1)},[]);Q.useEffect(()=>(typeof window<"u"&&(window.addEventListener("keydown",D),window.addEventListener("keyup",C)),()=>{typeof window<"u"&&(window.removeEventListener("keydown",D),window.removeEventListener("keyup",C))}),[D,C]);const P=Q.useCallback(L=>{if(L.button!==2&&(y.length||p.length)&&(w(),g(!1),n&&y.length===1)){if(!o.current)throw new Error("No ref found for the graph canvas.");o.current.fitNodesInView([],{fitOnlyIfNodesNotInView:!0})}},[w,n,p.length,y.length,o]),I=Q.useCallback(L=>{m(L)},[]),O=Q.useCallback(L=>{w(L)},[w]),G=Q.useCallback(L=>{if(s){const B=o.current.getGraph();if(!B)throw new Error("No ref found for the graph canvas.");const{nodes:H,edges:W}=z_(B,[L.id],s);d([...H,...W])}},[s,o]),Z=Q.useCallback(()=>{s&&d([])},[s]);return Q.useEffect(()=>{var L;if(a!=="direct"&&y.length>0){const B=(L=o.current)==null?void 0:L.getGraph();if(B){const{nodes:H,edges:W}=z_(B,y,a);m([...H,...W])}}},[y,a,o]),{actives:Q.useMemo(()=>[...p,...f],[p,f]),onNodeClick:R,onNodePointerOver:G,onNodePointerOut:Z,onLasso:I,onLassoEnd:O,selectNodePaths:U,onCanvasClick:P,selections:y,clearSelections:w,addSelection:S,removeSelection:E,toggleSelection:T,setSelections:x}},fX=""+new URL("NotoSans-Regular-D96CXwz4.ttf",import.meta.url).href,dX=Q.memo(({data:i,onCollapse:e,isCollapsed:t,canCollapse:n,onClose:r})=>{const{t:s}=bg(["network","zigbee","common"]);let a;if(i.parent){const o=i.parent.lastIndexOf(` - ${s("children")}`);a=o>-1?i.parent.slice(0,o):i.parent}return he.jsx("div",{className:"card bg-base-100 shadow-sm",children:he.jsxs("div",{className:"card-body",children:[he.jsx("h2",{className:"card-title",children:i.friendlyName}),he.jsx("span",{children:i.type}),he.jsx("span",{title:s("zigbee:ieee_address"),children:i.ieeeAddr}),he.jsxs("span",{title:s("zigbee:network_address_hex"),className:"justify-self-end",children:[WU(i.networkAddress,4)," | ",he.jsx("span",{title:s("zigbee:network_address_dec"),children:i.networkAddress})]}),a&&he.jsxs("span",{children:[s("parent"),": ",a]}),i.failed&&i.failed.length>0&&he.jsxs("div",{className:"badge badge-ghost",children:[he.jsx(ni,{icon:XU,className:"text-error",beatFade:!0}),s("common:failed"),": ",i.failed]}),he.jsxs("div",{className:"card-actions justify-end mt-2",children:[n&&he.jsx(ts,{className:"btn btn-square btn-primary",onClick:e,children:he.jsx(ni,{icon:t?jU:qU})}),he.jsx(ts,{className:"btn btn-square btn-neutral",onClick:r,children:he.jsx(ni,{icon:YU})})]})]})})}),SA=Q.memo(i=>{const{label:e,icon:t,onChange:n,onSubmit:r,defaultValue:s,...a}=i,[o,l]=Q.useState(s);Q.useEffect(()=>{l(s)},[s]);const c=Q.useCallback(d=>{l(d.target.value?d.target.valueAsNumber:""),n?.(d)},[n]),f=Q.useCallback(d=>{r?.(o,!d.target.validationMessage)},[r,o]);return he.jsxs("div",{className:"flex flex-row flex-wrap items-center gap-2 bg-base-100 rounded-box px-2 pb-1",title:e,children:[he.jsx(ni,{icon:t}),he.jsxs("div",{className:"",children:[he.jsx("input",{className:"range range-xs",onChange:c,onTouchEnd:f,onMouseUp:f,...a,type:"range",value:o}),he.jsxs("div",{className:"flex justify-between px-1 mt-1 text-xs",children:[he.jsx("span",{children:i.min}),he.jsx("span",{children:o}),he.jsx("span",{children:i.max})]})]})]})}),pX=Q.memo(({graphRef:i,layoutType:e,onLayoutTypeChange:t,labelType:n,onLabelTypeChange:r,nodeStrength:s,onNodeStrengthChange:a,linkDistance:o,onLinkDistanceChange:l,nodes:c,showParents:f,setShowParents:d,showChildren:p,setShowChildren:m,showSiblings:y,setShowSiblings:x})=>{const{t:_}=bg("network"),g=Q.useMemo(()=>{const E=c.map(w=>[w.id,w.data.type!=="Coordinator"?`${w.data.type[0]} - ${w.label}`:w.label]);return E.sort(([,w],[,T])=>w.localeCompare(T)),E.map(([w,T])=>he.jsx("option",{value:w,children:T},w))},[c]),b=Q.useCallback(()=>{i.current&&ZU(i.current.exportCanvas(),`network-map-${Date.now()}.png`)},[i]),S=Q.useCallback(E=>{if(E.target.value){const w=[E.target.value];i.current?.centerGraph(w),i.current?.fitNodesInView(w)}},[i]);return he.jsxs(he.Fragment,{children:[he.jsxs("div",{className:"absolute z-9 top-0 left-0 p-1 flex flex-row flex-wrap gap-1 items-start",children:[he.jsx(ts,{title:_("download_image"),className:"btn btn-square btn-neutral btn-sm",onClick:b,children:he.jsx(ni,{icon:KU})}),he.jsx(ts,{title:_("reset_controls"),className:"btn btn-square btn-neutral btn-sm",onClick:()=>{i.current?.resetControls()},children:he.jsx(ni,{icon:JU})}),he.jsx(ts,{title:_("fit_view"),className:"btn btn-square btn-neutral btn-sm",onClick:()=>{i.current?.centerGraph(),i.current?.fitNodesInView()},children:he.jsx(ni,{icon:QU})}),he.jsx(ts,{title:_("zoom_in"),className:"btn btn-square btn-neutral btn-sm",onClick:()=>{i.current?.zoomIn()},children:he.jsx(ni,{icon:$U})}),he.jsx(ts,{title:_("zoom_out"),className:"btn btn-square btn-neutral btn-sm",onClick:()=>{i.current?.zoomOut()},children:he.jsx(ni,{icon:eO})}),he.jsx(ts,{className:`btn btn-square btn-neutral btn-sm ${f?"":"btn-outline"}`,item:!f,onClick:d,title:_("parent"),children:he.jsx(ni,{icon:Qc,style:{color:yl[ti.NeighborIsParent]}})}),he.jsx(ts,{className:`btn btn-square btn-neutral btn-sm ${p?"":"btn-outline"}`,item:!p,onClick:m,title:_("child"),children:he.jsx(ni,{icon:Qc,style:{color:yl[ti.NeighborIsAChild]}})}),he.jsx(ts,{className:`btn btn-square btn-neutral btn-sm ${y?"":"btn-outline"}`,item:!y,onClick:x,title:_("sibling"),children:he.jsx(ni,{icon:Qc,style:{color:yl[ti.NeighborIsASibling]}})}),he.jsxs("select",{className:"select select-sm w-36",title:_("find_node"),defaultValue:"",onChange:S,children:[he.jsx("option",{value:"",children:_("find_node")}),g]})]}),he.jsxs("div",{className:"absolute z-9 top-0 right-0 p-1 flex flex-row flex-wrap gap-1 items-start justify-end",children:[he.jsxs("select",{className:"select select-sm w-36",title:_("layout_type"),value:e,onChange:t,children:[he.jsx("option",{value:"",disabled:!0,children:_("layout_type")}),he.jsx("option",{value:"forceDirected2d",children:"forceDirected2d"}),he.jsx("option",{value:"forceDirected3d",children:"forceDirected3d"}),he.jsx("option",{value:"radialOut2d",children:"radialOut2d"}),he.jsx("option",{value:"radialOut3d",children:"radialOut3d"})]}),he.jsxs("select",{className:"select select-sm w-36",title:_("label_type"),value:n,onChange:r,children:[he.jsx("option",{value:"",disabled:!0,children:_("label_type")}),he.jsx("option",{value:"all",children:"all"}),he.jsx("option",{value:"auto",children:"auto"}),he.jsx("option",{value:"none",children:"none"}),he.jsx("option",{value:"nodes",children:"nodes"}),he.jsx("option",{value:"edges",children:"edges"})]})]}),he.jsxs("div",{className:"absolute z-9 bottom-0 left-0 p-1 flex flex-row flex-wrap gap-1 items-end",children:[he.jsx(SA,{name:"node_strength",label:_("node_strength"),icon:tO,onSubmit:(E,w)=>w&&typeof E=="number"&&a(E),min:-1e3,max:-100,step:10,defaultValue:s}),he.jsx(SA,{name:"link_distance",label:_("link_distance"),icon:nO,onSubmit:(E,w)=>w&&typeof E=="number"&&l(E),min:10,max:200,step:5,defaultValue:o})]}),he.jsx("div",{className:"absolute z-9 bottom-0 right-0 p-1 flex flex-row flex-wrap gap-1 items-end justify-end",children:he.jsx(ts,{title:_("scroll_to_top"),className:"btn btn-primary btn-sm ml-auto",onClick:()=>{window.scrollTo(0,0)},children:he.jsx(ni,{icon:iO})})})]})}),mX=Q.memo(()=>{const{t:i}=bg("network");return he.jsxs("details",{className:"collapse collapse-arrow rounded-b-none",children:[he.jsx("summary",{className:"collapse-title font-semibold",children:i("legend")}),he.jsxs("div",{className:"collapse-content text-sm",children:[he.jsxs("div",{className:"flex flex-row flex-wrap gap-3 mb-2",children:[he.jsxs("div",{children:[he.jsxs("p",{children:[i("nodes"),":"]}),he.jsxs("ul",{className:"list-none list-inside",children:[he.jsxs("li",{style:{color:nm.Coordinator},children:[he.jsx(ni,{icon:Iv})," Coordinator"]}),he.jsxs("li",{style:{color:nm.Router},children:[he.jsx(ni,{icon:Iv})," Router"]}),he.jsxs("li",{style:{color:nm.EndDevice},children:[he.jsx(ni,{icon:Iv})," EndDevice"]})]})]}),he.jsxs("div",{children:[he.jsxs("p",{children:[i("edges"),":"]}),he.jsxs("ul",{className:"list-none list-inside",children:[he.jsxs("li",{style:{color:yl[ti.NeighborIsParent]},children:[he.jsx(ni,{icon:Qc})," ",i("parent")]}),he.jsxs("li",{style:{color:yl[ti.NeighborIsAChild]},children:[he.jsx(ni,{icon:Qc})," ",i("child")]}),he.jsxs("li",{style:{color:yl[ti.NeighborIsASibling]},children:[he.jsx(ni,{icon:Qc})," ",i("sibling")]})]})]})]}),he.jsx("p",{children:i("legend_node_siblings")}),he.jsx("p",{children:i("legend_node_size")}),he.jsx("p",{children:i("legend_node_select")}),he.jsx("p",{children:i("legend_node_fold")}),he.jsx("p",{children:i("legend_edge_toggle")}),he.jsx("p",{className:"text-xs mt-2",children:"Known issues:"}),he.jsxs("ul",{className:"list-disc list-inside text-xs",children:[he.jsxs("li",{children:['If you cannot see labels (names/LQIs) after the map has finished loading, zoom-in sufficiently, switch the "',i("label_type"),'" value to something else, then back to the one you want']}),he.jsx("li",{children:"Edge colors are currently not working"}),he.jsx("li",{children:"An undesired vertical offset is applied when starting to drag a node"})]})]})]})}),RX=Q.memo(({map:i})=>{const{t:e}=bg("network"),[t,n]=Q.useState(qa.get(VS,"forceDirected2d")),[r,s]=Q.useState(qa.get(WS,"all")),[a,o]=Q.useState(qa.get(XS,-750)),[l,c]=Q.useState(qa.get(jS,50)),[f,d]=Q.useState(!0),[p,m]=Q.useState(!0),[y,x]=Q.useState(!0),_=Q.useRef(null),g=Q.useMemo(()=>{const I=new OffscreenCanvas(1,1).getContext("2d"),O=getComputedStyle(document.documentElement),G=ah(I,O.getPropertyValue("--color-base-100")),Z=ah(I,O.getPropertyValue("--color-base-200")),z=ah(I,O.getPropertyValue("--color-base-content")),L=ah(I,O.getPropertyValue("--color-primary")),B=ah(I,O.getPropertyValue("--color-accent"));return rO({},X3,{canvas:{background:G},node:{activeFill:B,label:{color:z,stroke:Z,activeColor:B},subLabel:{color:z,stroke:"transparent",activeColor:B}},lasso:{border:`1px solid ${L}`,background:"rgba(75, 160, 255, 0.1)"},ring:{fill:z,activeFill:B},edge:{fill:z,activeFill:B,label:{stroke:Z,color:z,activeColor:B},subLabel:{color:z,stroke:"transparent",activeColor:B}},arrow:{fill:z,activeFill:B},cluster:{stroke:z,label:{stroke:Z,color:z}}})},[]),[b,S]=Q.useMemo(()=>{const I=[],O=[],G=[];for(const L of i.nodes){const B=i.links.find(W=>W.relationship===ti.NeighborIsParent&&W.target.ieeeAddr===L.ieeeAddr);let H=B?i.nodes.find(W=>W.ieeeAddr===B.source.ieeeAddr)?.friendlyName:void 0;if(!B){const W=i.links.find(k=>k.relationship===ti.NeighborIsAChild&&k.source.ieeeAddr===L.ieeeAddr);H=W?i.nodes.find(k=>k.ieeeAddr===W.target.ieeeAddr)?.friendlyName:void 0,H&&(H+=` - ${e("children")}`)}I.push({id:L.ieeeAddr,data:{...L,parent:H},label:L.friendlyName,labelVisible:!0,fill:nm[L.type]})}const Z=new Map;for(const L of i.links){if(!f&&L.relationship===ti.NeighborIsParent||!p&&L.relationship===ti.NeighborIsAChild||!y&&L.relationship===ti.NeighborIsASibling)continue;if(L.relationship===ti.NeighborIsASibling){const H=Z.get(L.source.ieeeAddr);(!H||L.depth<H.depth||L.linkquality>H.linkquality||H.linkquality===L.linkquality&&L.depth<H.depth)&&Z.set(L.source.ieeeAddr,L);continue}const B=i.links.find(H=>H.source.ieeeAddr===L.target.ieeeAddr&&H.target.ieeeAddr===L.source.ieeeAddr);L.relationship===ti.NeighborIsAChild&&B?.relationship===ti.NeighborIsParent||G.push([L,B])}for(const[,L]of Z){const B=i.links.find(H=>H.source.ieeeAddr===L.target.ieeeAddr&&H.target.ieeeAddr===L.source.ieeeAddr);G.push([L,B])}const z=[];for(const[L,B]of G)z.includes(L)||L.relationship===ti.NeighborIsASibling&&(B?.relationship===ti.NeighborIsParent||B?.relationship===ti.NeighborIsAChild)||O.push({id:`${L.source.ieeeAddr}-${L.target.ieeeAddr}-${L.relationship}`,data:L,label:B?`${L.linkquality} / ${B.linkquality??"?"}`:`${L.linkquality}`,size:L.relationship===ti.NeighborIsParent||L.relationship===ti.NeighborIsAChild?1.5:.75,labelVisible:!0,source:L.source.ieeeAddr,target:L.target.ieeeAddr,fill:yl[L.relationship]});return[I,O]},[i,f,p,y,e]),{selections:E,actives:w,onNodeClick:T,onCanvasClick:R}=hX({ref:_,nodes:b,type:"single",pathSelectionType:"out",focusOnSelect:!1}),U=Q.useCallback(I=>{I.target.value&&(qa.set(VS,I.target.value),n(I.target.value),_.current?.resetControls(),_.current?.centerGraph(),_.current?.fitNodesInView())},[]),D=Q.useCallback(I=>{I.target.value&&(qa.set(WS,I.target.value),s(I.target.value))},[]),C=Q.useCallback(I=>{qa.set(XS,I),o(I)},[]),P=Q.useCallback(I=>{qa.set(jS,I),c(I)},[]);return he.jsxs(he.Fragment,{children:[he.jsx(mX,{}),he.jsxs("div",{className:"relative h-screen",children:[he.jsx(pX,{graphRef:_,layoutType:t,onLayoutTypeChange:U,labelType:r,onLabelTypeChange:D,nodeStrength:a,onNodeStrengthChange:C,linkDistance:l,onLinkDistanceChange:P,nodes:b,showParents:f,setShowParents:d,showChildren:p,setShowChildren:m,showSiblings:y,setShowSiblings:x}),he.jsx(uX,{ref:_,theme:g,nodes:b,edges:S,clusterAttribute:t.startsWith("forceDirected")?"parent":void 0,selections:E,actives:w,onCanvasClick:R,onNodeClick:T,layoutType:t,layoutOverrides:{nodeStrength:a,linkDistance:l},sizingType:"centrality",labelType:r,labelFontUrl:fX,edgeLabelPosition:"natural",lassoType:"node",cameraMode:t.endsWith("3d")?"rotate":"pan",draggable:!0,animated:!1,contextMenu:({data:{data:I},onCollapse:O,isCollapsed:G,canCollapse:Z,onClose:z})=>I.friendlyName?he.jsx(dX,{data:I,onCollapse:O,isCollapsed:G,canCollapse:Z,onClose:z}):null})]})]})});export{RX as default};
|