cozyclay 1.9.0 → 2.0.0
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/CHANGELOG.md +171 -0
- package/bin/agent/agent-routes.mjs +74 -70
- package/bin/agent/agent-runner.mjs +10 -3
- package/bin/agent/motion-runtime.mjs +32 -260
- package/bin/agent/providers.mjs +46 -3
- package/bin/agent/session-store.mjs +41 -5
- package/bin/agent/studio-prompt.mjs +1 -1
- package/bin/agent/studio-tools.mjs +48 -11
- package/bin/cozyclay.mjs +26 -8
- package/bin/live/cli.mjs +22 -3
- package/bin/mcp-runtime.mjs +35 -20
- package/bin/telemetry-state.mjs +5 -2
- package/bin/update-check.mjs +15 -0
- package/dist/app/index.html +6 -6
- package/dist/assets/analytics-MVZOEW8O.js +1 -0
- package/dist/assets/app-C1sdVbg4.css +1 -0
- package/dist/assets/app-CA55tcI3.js +4876 -0
- package/dist/assets/{demo-B-eg1CT8.js → demo-ByeYp-dY.js} +1 -1
- package/dist/assets/{first-shot-handoff-CGgnvNu8.js → first-shot-handoff-DgT28ZiV.js} +1 -1
- package/dist/assets/{landing-IbRp3FnQ.js → landing-BaXkpFip.js} +1 -1
- package/dist/assets/shot-prompt-CbqWcWYi.css +1 -0
- package/dist/assets/shot-prompt-Yrt99wZx.js +17 -0
- package/dist/assets/{ticket-BgIzOBOf.js → ticket-BcmsnHn5.js} +1 -1
- package/dist/assets/workflow-DRdwoDBT.css +1 -0
- package/dist/assets/workflow-dNPGY9xz.js +179 -0
- package/dist/cozyclay-package.json +1 -1
- package/dist/fonts/IBM-Plex-Sans-OFL.txt +92 -0
- package/dist/fonts/JetBrains-Mono-OFL.txt +93 -0
- package/dist/fonts/README.md +13 -9
- package/dist/fonts/ibm-plex-sans-400-latin.woff2 +0 -0
- package/dist/fonts/ibm-plex-sans-500-latin.woff2 +0 -0
- package/dist/fonts/ibm-plex-sans-600-latin.woff2 +0 -0
- package/dist/fonts/jetbrains-mono-400-latin.woff2 +0 -0
- package/dist/fonts/jetbrains-mono-500-latin.woff2 +0 -0
- package/dist/index.html +7 -7
- package/dist/privacy/index.html +13 -8
- package/dist/sitemap.xml +6 -6
- package/dist/workflow/index.html +5 -5
- package/mcp/LIVE-PROTOCOL.md +1 -1
- package/mcp/live-hub.mjs +35 -93
- package/mcp/mesh-file.mjs +48 -0
- package/mcp/server.mjs +6 -77
- package/mcp/tool-handlers.mjs +224 -377
- package/package.json +2 -1
- package/src/App.jsx +1273 -9075
- package/src/analytics.js +393 -9
- package/src/app-context.js +211 -0
- package/src/app-stage.jsx +25 -24
- package/src/ardy/auto-fix-panel.css +108 -0
- package/src/ardy/collision-blockers.js +9 -3
- package/src/ardy/fix-collisions.js +10 -66
- package/src/ardy/ground.js +4 -4
- package/src/ardy/ik-drag.js +101 -0
- package/src/ardy/ik-key-json.js +43 -0
- package/src/ardy/ik.js +122 -76
- package/src/ardy/physics-panel.css +2 -0
- package/src/ardy/physics-panel.jsx +17 -5
- package/src/ardy/platform-fit-panel.css +64 -0
- package/src/ardy/platform-fit-panel.jsx +40 -0
- package/src/ardy/platform-fit.js +326 -0
- package/src/ardy/playback.js +166 -20
- package/src/ardy/range-pin.js +299 -0
- package/src/ardy/timeline-coordinates.js +26 -0
- package/src/ardy/timeline.css +1199 -0
- package/src/ardy/timeline.jsx +149 -41
- package/src/ardy/waypoints.js +2 -2
- package/src/asset-pane.css +462 -0
- package/src/asset-pane.jsx +461 -232
- package/src/command-bus.js +349 -0
- package/src/commands/ai.js +31 -0
- package/src/commands/cast.js +140 -0
- package/src/commands/elements/character.js +13 -0
- package/src/commands/elements/motion.js +14 -0
- package/src/commands/elements/object.js +22 -0
- package/src/commands/elements/scene.js +16 -0
- package/src/commands/elements/shot.js +9 -0
- package/src/commands/elements/stage.js +11 -0
- package/src/commands/elements.js +155 -0
- package/src/commands/export.js +20 -0
- package/src/commands/index.js +40 -0
- package/src/commands/motion.js +231 -0
- package/src/commands/objects.js +174 -0
- package/src/commands/project.js +53 -0
- package/src/commands/scene.js +81 -0
- package/src/commands/shared.js +19 -0
- package/src/commands/shot.js +103 -0
- package/src/commands/stage.js +17 -0
- package/src/commands/view.js +42 -0
- package/src/document-store.js +144 -0
- package/src/domains/cast.js +1007 -0
- package/src/domains/motion.js +3219 -0
- package/src/domains/objects.js +932 -0
- package/src/domains/scenes.js +817 -0
- package/src/domains/shots.js +404 -0
- package/src/domains/stage.js +93 -0
- package/src/dualview.jsx +113 -57
- package/src/facing-marks.js +3 -0
- package/src/first-success-guide.jsx +14 -14
- package/src/grid-view.js +18 -5
- package/src/hierarchy-model.js +24 -16
- package/src/hierarchy-panel.css +386 -0
- package/src/hierarchy-panel.jsx +150 -21
- package/src/{fal-motion-client.js → i2v-motion-client.js} +13 -13
- package/src/i2v-motion-studio.jsx +180 -0
- package/src/ik-camera.js +3 -0
- package/src/main.jsx +6 -0
- package/src/motion/generation.js +105 -0
- package/src/motion-readiness-ui.jsx +4 -4
- package/src/motion-readiness.js +11 -0
- package/src/motion-trail.js +366 -9
- package/src/object-gizmo.jsx +7 -1
- package/src/otio.js +2 -1
- package/src/panels/CameraPanel.jsx +60 -0
- package/src/panels/CharacterTransformPanel.jsx +48 -0
- package/src/panels/EnvironmentPanel.jsx +40 -0
- package/src/panels/Foldout.jsx +32 -0
- package/src/panels/LightPanel.jsx +24 -0
- package/src/panels/ObjectTransformPanel.jsx +554 -0
- package/src/panels/PosePanel.jsx +97 -0
- package/src/panels/ProjectPanel.jsx +33 -0
- package/src/panels/PromptBlocksPanel.jsx +442 -0
- package/src/panels/PropsPanel.jsx +70 -0
- package/src/panels/ReferenceImageField.jsx +91 -0
- package/src/panels/RigControlPanel.jsx +78 -0
- package/src/panels/RigPanel.jsx +37 -0
- package/src/panels/SubjectBox.jsx +47 -0
- package/src/panels/SubjectsPanel.jsx +39 -0
- package/src/panels/VideoCapturePanel.jsx +180 -0
- package/src/panels/details.css +1171 -0
- package/src/panels/motion.css +197 -0
- package/src/panels/pose.css +39 -0
- package/src/planview.jsx +60 -31
- package/src/posestudio.jsx +59 -4
- package/src/project-browser.css +1073 -0
- package/src/project-browser.jsx +284 -123
- package/src/range-pin-object-transform.js +19 -0
- package/src/range-pin-panel.css +518 -0
- package/src/range-pin-panel.jsx +344 -0
- package/src/result-modal.jsx +5 -5
- package/src/room.jsx +79 -51
- package/src/scene-objects.js +37 -1
- package/src/scenes.js +5 -0
- package/src/semantic-edit.js +2 -0
- package/src/settings-menu.jsx +39 -105
- package/src/shell/BottomDock.jsx +450 -0
- package/src/shell/DetailsSlot.jsx +513 -0
- package/src/shell/LibrarySlot.jsx +86 -0
- package/src/shell/MenuBar.jsx +601 -0
- package/src/shell/OutlinerSlot.jsx +50 -0
- package/src/shell/PreferencesDialog.jsx +538 -0
- package/src/shell/PreferencesSlot.jsx +40 -0
- package/src/shell/StatusBar.jsx +125 -0
- package/src/shell/StudioShell.jsx +92 -0
- package/src/shell/TopBar.jsx +129 -0
- package/src/shell/ViewportToolbar.jsx +656 -0
- package/src/shell/agent-glass.css +296 -0
- package/src/shell/dock.css +93 -0
- package/src/shell/glass-regions.css +985 -0
- package/src/shell/glass.css +687 -0
- package/src/shell/log-store.js +52 -0
- package/src/shell/mode.css +9 -0
- package/src/shell/preferences.css +651 -0
- package/src/shell/shell.css +282 -0
- package/src/shell/studio-shell-context.js +19 -0
- package/src/shell/topbar.css +435 -0
- package/src/shell/viewport.css +451 -0
- package/src/store/authored-intent.js +22 -0
- package/src/store/runtime-adapters.js +92 -0
- package/src/store/scene-stage.js +21 -0
- package/src/store/use-document-store.js +14 -0
- package/src/studio-actions.js +210 -0
- package/src/studio-agent-commands.js +41 -271
- package/src/studio-agent-context.js +39 -10
- package/src/studio-agent-motion.js +122 -373
- package/src/studio-agent-protocol.js +67 -31
- package/src/studio-app-binding.js +379 -0
- package/src/studio-contact-sheet.js +73 -0
- package/src/studio-elements.js +58 -51
- package/src/styles/themes.css +200 -0
- package/src/styles/tokens.css +69 -0
- package/src/styles.css +460 -1742
- package/src/theme.js +44 -0
- package/src/timeline-extent.js +16 -0
- package/src/trail-key-conflicts.js +39 -0
- package/src/trail-pick.js +59 -0
- package/src/ui.jsx +8 -8
- package/src/use-case-question.jsx +66 -0
- package/src/workflow/AgentPanel.jsx +82 -69
- package/src/workflow/agent-client.js +12 -2
- package/src/workflow/agent-panel.css +34 -32
- package/src/workflow/cozy-scene-node.css +2 -0
- package/src/workflow/workflow.css +2 -0
- package/tools/ardy/__pycache__/cclay_gvhmr_worker.cpython-313.pyc +0 -0
- package/tools/ardy/bridge.mjs +164 -146
- package/tools/ardy/visual-qa.mjs +5 -5
- package/tools/bench/EXP3.md +61 -0
- package/tools/bench/cclay_bench_extract_incam.py +125 -0
- package/tools/bench/cclay_bench_extract_obs.py +204 -0
- package/tools/bench/cclay_bench_runner.py +42 -0
- package/tools/bench/cube-contact.mjs +162 -0
- package/tools/bench/exp3.mjs +152 -0
- package/tools/bench/extract-bench-lib.mjs +216 -0
- package/tools/bench/extract-bench.mjs +302 -0
- package/tools/bench/fal-generate.mjs +88 -0
- package/tools/bench/fit/README.md +189 -0
- package/tools/bench/fit/camera.mjs +59 -0
- package/tools/bench/fit/contact.mjs +419 -0
- package/tools/bench/fit/footlock.mjs +234 -0
- package/tools/bench/fit/motion.mjs +85 -0
- package/tools/bench/fit/pin.mjs +27 -0
- package/tools/bench/fit/remote.mjs +105 -0
- package/tools/bench/fit-bench.mjs +126 -0
- package/tools/bench/fit-sanity.mjs +45 -0
- package/tools/bench/metrics.mjs +313 -0
- package/tools/bench/obs/depth.mjs +258 -0
- package/tools/bench/obs/extrinsics.mjs +175 -0
- package/tools/bench/obs/fit_mannequin_betas.py +340 -0
- package/tools/bench/obs/ground.mjs +294 -0
- package/tools/bench/obs/heading.mjs +151 -0
- package/tools/bench/obs/ladder.mjs +555 -0
- package/tools/bench/obs/mannequin-betas.json +124 -0
- package/tools/bench/obs/remote.mjs +83 -0
- package/tools/bench/obs/rest_joints.py +52 -0
- package/tools/bench/obs/ybot-targets.mjs +49 -0
- package/tools/bench/obs-bench.mjs +520 -0
- package/tools/bench/score.mjs +343 -0
- package/tools/bench/summarize.mjs +86 -0
- package/tools/dev/pages/privacy.html +13 -8
- package/tools/gt-render/browser.mjs +159 -0
- package/tools/gt-render/camera-math.mjs +276 -0
- package/tools/gt-render/page.mjs +267 -0
- package/tools/gt-render/render.mjs +514 -0
- package/tools/gt-render/scene-box.mjs +31 -0
- package/tools/gt-render/take-transform.mjs +87 -0
- package/tools/morphgs/assets/gen_truth.py +39 -0
- package/tools/morphgs/assets/mesh_ori_rig.txt +27 -0
- package/tools/morphgs/assets/playback-check.mjs +30 -0
- package/tools/morphgs/demo-gate.sh +26 -0
- package/tools/morphgs/fbx2morphgs.mjs +68 -0
- package/tools/morphgs/morphgs-to-cskel27.mjs +105 -0
- package/tools/morphgs/patches/preprocess_src-none-mode.patch +76 -0
- package/tools/morphgs/setup-on-cluster.sh +126 -0
- package/tools/qa/css-rule-usage.mjs +283 -0
- package/tools/qa/studio-control-count.mjs +70 -32
- package/tools/run-tests.mjs +134 -12
- package/tools/track/DESIGN.md +513 -0
- package/tools/track/backfill-provenance.mjs +116 -0
- package/tools/track/budget.mjs +8 -0
- package/tools/track/check-rig.mjs +209 -0
- package/tools/track/diagnostics.schema.json +60 -0
- package/tools/track/export-rig.mjs +256 -0
- package/tools/track/fallback.mjs +7 -0
- package/tools/track/fk-parity-fixture.mjs +161 -0
- package/tools/track/gate.mjs +349 -0
- package/tools/track/masks.mjs +318 -0
- package/tools/track/metrics.mjs +201 -0
- package/tools/track/publish-obs.mjs +108 -0
- package/tools/track/py/check_env.py +61 -0
- package/tools/track/py/eval_lr.py +229 -0
- package/tools/track/py/lr_viterbi.py +294 -0
- package/tools/track/py/masks.py +405 -0
- package/tools/track/py/objective.py +382 -0
- package/tools/track/py/rig.py +508 -0
- package/tools/track/py/scene.py +326 -0
- package/tools/track/py/test_joint_indices.py +123 -0
- package/tools/track/py/test_lr_viterbi.py +195 -0
- package/tools/track/py/test_masks.py +229 -0
- package/tools/track/py/test_rig.py +288 -0
- package/tools/track/py/test_scene.py +354 -0
- package/tools/track/py/test_track.py +328 -0
- package/tools/track/py/track.py +411 -0
- package/tools/track/remote.mjs +140 -0
- package/tools/track/rig-dump.mjs +227 -0
- package/tools/track/run-box-tests.mjs +14 -0
- package/tools/track/run-box.mjs +168 -0
- package/tools/track/setup-box.sh +59 -0
- package/tools/track/study-2d.mjs +728 -0
- package/dist/assets/analytics-B1hnH66c.js +0 -1
- package/dist/assets/app-BWusbqgO.js +0 -4861
- package/dist/assets/app-qKDo4PBX.css +0 -1
- package/dist/assets/shot-prompt-CHUtw6af.js +0 -17
- package/dist/assets/shot-prompt-C_g2BHVc.css +0 -1
- package/dist/assets/workflow-CVwzMhz2.js +0 -179
- package/dist/assets/workflow-DsudxKHF.css +0 -1
- package/src/fal-motion-studio.jsx +0 -180
- package/src/scene-history.js +0 -129
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{$ as n,B as r,K as i,M as a,at as o,b as s,h as c,i as l,it as u,n as d,r as f,s as p,t as m}from"./analytics-MVZOEW8O.js";var h=t((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function ee(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var k=/\/+/g;function te(e,t){return typeof e==`object`&&e&&e.key!=null?ee(``+e.key):t.toString(36)}function ne(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function re(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,re(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+te(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(k,`$&/`)+`/`),re(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(k,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+te(a,u),c+=re(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+te(a,u++),c+=re(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return re(ne(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function ie(e,t,n){if(e==null)return e;var r=[],i=0;return re(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function A(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var j=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},M={map:ie,forEach:function(e,t,n){ie(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return ie(e,function(){t++}),t},toArray:function(e){return ie(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=M,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=O,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:A}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,j)}catch(e){j(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.8`})),g=t(((e,t)=>{t.exports=h()})),_=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&te(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&te(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var ee=new MessageChannel,k=ee.port2;ee.port1.onmessage=D,O=function(){k.postMessage(null)}}else O=function(){_(D,0)};function te(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,te(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),v=t(((e,t)=>{t.exports=_()})),y=t((e=>{var t=g();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.8`})),b=t(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=y()})),x=t((e=>{var t=v(),n=g(),r=b();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}var f=Object.assign,p=Symbol.for(`react.element`),m=Symbol.for(`react.transitional.element`),h=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),y=Symbol.for(`react.strict_mode`),x=Symbol.for(`react.profiler`),S=Symbol.for(`react.consumer`),C=Symbol.for(`react.context`),w=Symbol.for(`react.forward_ref`),T=Symbol.for(`react.suspense`),E=Symbol.for(`react.suspense_list`),D=Symbol.for(`react.memo`),O=Symbol.for(`react.lazy`),ee=Symbol.for(`react.activity`),k=Symbol.for(`react.memo_cache_sentinel`),te=Symbol.iterator;function ne(e){return typeof e!=`object`||!e?null:(e=te&&e[te]||e[`@@iterator`],typeof e==`function`?e:null)}var re=Symbol.for(`react.client.reference`);function ie(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===re?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case _:return`Fragment`;case x:return`Profiler`;case y:return`StrictMode`;case T:return`Suspense`;case E:return`SuspenseList`;case ee:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case h:return`Portal`;case C:return e.displayName||`Context`;case S:return(e._context.displayName||`Context`)+`.Consumer`;case w:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case D:return t=e.displayName||null,t===null?ie(e.type)||`Memo`:t;case O:t=e._payload,e=e._init;try{return ie(e(t))}catch{}}return null}var A=Array.isArray,j=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,M=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ae={pending:!1,data:null,method:null,action:null},oe=[],se=-1;function ce(e){return{current:e}}function le(e){0>se||(e.current=oe[se],oe[se]=null,se--)}function ue(e,t){se++,oe[se]=e.current,e.current=t}var de=ce(null),fe=ce(null),pe=ce(null),me=ce(null);function he(e,t){switch(ue(pe,t),ue(fe,e),ue(de,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Gd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Gd(t),e=Kd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}le(de),ue(de,e)}function ge(){le(de),le(fe),le(pe)}function _e(e){e.memoizedState!==null&&ue(me,e);var t=de.current,n=Kd(t,e.type);t!==n&&(ue(fe,e),ue(de,n))}function ve(e){fe.current===e&&(le(de),le(fe)),me.current===e&&(le(me),np._currentValue=ae)}var ye,be;function xe(e){if(ye===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ye=t&&t[1]||``,be=-1<e.stack.indexOf(`
|
|
2
|
+
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
3
|
+
`+ye+e+be}var Se=!1;function Ce(e,t){if(!e||Se)return``;Se=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
4
|
+
`),l=s.split(`
|
|
5
|
+
`);for(i=r=0;r<c.length&&!c[r].includes(`DetermineComponentFrameRoot`);)r++;for(;i<l.length&&!l[i].includes(`DetermineComponentFrameRoot`);)i++;if(r===c.length||i===l.length)for(r=c.length-1,i=l.length-1;1<=r&&0<=i&&c[r]!==l[i];)i--;for(;1<=r&&0<=i;r--,i--)if(c[r]!==l[i]){if(r!==1||i!==1)do if(r--,i--,0>i||c[r]!==l[i]){var u=`
|
|
6
|
+
`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{Se=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?xe(n):``}function we(e,t){switch(e.tag){case 26:case 27:case 5:return xe(e.type);case 16:return xe(`Lazy`);case 13:return e.child!==t&&t!==null?xe(`Suspense Fallback`):xe(`Suspense`);case 19:return xe(`SuspenseList`);case 0:case 15:return Ce(e.type,!1);case 11:return Ce(e.type.render,!1);case 1:return Ce(e.type,!0);case 31:return xe(`Activity`);default:return``}}function Te(e){try{var t=``,n=null;do t+=we(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
|
|
7
|
+
Error generating stack: `+e.message+`
|
|
8
|
+
`+e.stack}}var Ee=Object.prototype.hasOwnProperty,De=t.unstable_scheduleCallback,Oe=t.unstable_cancelCallback,ke=t.unstable_shouldYield,Ae=t.unstable_requestPaint,je=t.unstable_now,Me=t.unstable_getCurrentPriorityLevel,Ne=t.unstable_ImmediatePriority,Pe=t.unstable_UserBlockingPriority,Fe=t.unstable_NormalPriority,Ie=t.unstable_LowPriority,Le=t.unstable_IdlePriority,N=t.log,Re=t.unstable_setDisableYieldValue,ze=null,Be=null;function Ve(e){if(typeof N==`function`&&Re(e),Be&&typeof Be.setStrictMode==`function`)try{Be.setStrictMode(ze,e)}catch{}}var He=Math.clz32?Math.clz32:Ge,Ue=Math.log,We=Math.LN2;function Ge(e){return e>>>=0,e===0?32:31-(Ue(e)/We|0)|0}var Ke=256,qe=262144,Je=4194304;function Ye(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Xe(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=Ye(n))):i=Ye(o):i=Ye(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Ye(n))):i=Ye(o)):i=Ye(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function Ze(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Qe(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function $e(){var e=Je;return Je<<=1,!(Je&62914560)&&(Je=4194304),e}function et(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function tt(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function nt(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-He(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&rt(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function rt(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-He(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function it(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-He(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function at(e,t){var n=t&-t;return n=n&42?1:ot(n),(n&(e.suspendedLanes|t))===0?n:0}function ot(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function st(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function ct(){var e=M.p;return e===0?(e=window.event,e===void 0?32:vp(e.type)):e}function lt(e,t){var n=M.p;try{return M.p=e,t()}finally{M.p=n}}var ut=Math.random().toString(36).slice(2),dt=`__reactFiber$`+ut,ft=`__reactProps$`+ut,pt=`__reactContainer$`+ut,mt=`__reactEvents$`+ut,ht=`__reactListeners$`+ut,gt=`__reactHandles$`+ut,_t=`__reactResources$`+ut,vt=`__reactMarker$`+ut;function yt(e){delete e[dt],delete e[ft],delete e[mt],delete e[ht],delete e[gt]}function bt(e){var t=e[dt];if(t)return t;for(var n=e.parentNode;n;){if(t=n[pt]||n[dt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=hf(e);e!==null;){if(n=e[dt])return n;e=hf(e)}return t}e=n,n=e.parentNode}return null}function xt(e){if(e=e[dt]||e[pt]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function St(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function Ct(e){var t=e[_t];return t||=e[_t]={hoistableStyles:new Map,hoistableScripts:new Map},t}function wt(e){e[vt]=!0}var Tt=new Set,Et={};function Dt(e,t){Ot(e,t),Ot(e+`Capture`,t)}function Ot(e,t){for(Et[e]=t,e=0;e<t.length;e++)Tt.add(t[e])}var kt=RegExp(`^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`),At={},jt={};function Mt(e){return Ee.call(jt,e)?!0:Ee.call(At,e)?!1:kt.test(e)?jt[e]=!0:(At[e]=!0,!1)}function Nt(e,t,n){if(Mt(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,``+n)}}function Pt(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,``+n)}}function Ft(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,``+r)}}function It(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function Lt(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function Rt(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function zt(e){if(!e._valueTracker){var t=Lt(e)?`checked`:`value`;e._valueTracker=Rt(e,t,``+e[t])}}function Bt(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=Lt(e)?e.checked?`true`:`false`:e.value),e=r,e!==n&&(t.setValue(e),!0)}function Vt(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}var Ht=/[\n"\\]/g;function Ut(e){return e.replace(Ht,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function Wt(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+It(t)):e.value!==``+It(t)&&(e.value=``+It(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):Kt(e,o,It(n)):Kt(e,o,It(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+It(s):e.removeAttribute(`name`)}function Gt(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){zt(e);return}n=n==null?``:``+It(n),t=t==null?n:``+It(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),zt(e)}function Kt(e,t,n){t===`number`&&Vt(e.ownerDocument)===e||e.defaultValue===``+n||(e.defaultValue=``+n)}function qt(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+It(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function Jt(e,t,n){if(t!=null&&(t=``+It(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n==null?``:``+It(n)}function Yt(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(A(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=It(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),zt(e)}function Xt(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Zt=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function Qt(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||Zt.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function $t(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(i(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``);for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&Qt(e,a,r)}else for(var o in t)t.hasOwnProperty(o)&&Qt(e,o,t[o])}function en(e){if(e.indexOf(`-`)===-1)return!1;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var tn=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`dominantBaseline`,`dominant-baseline`],[`enableBackground`,`enable-background`],[`fillOpacity`,`fill-opacity`],[`fillRule`,`fill-rule`],[`floodColor`,`flood-color`],[`floodOpacity`,`flood-opacity`],[`fontFamily`,`font-family`],[`fontSize`,`font-size`],[`fontSizeAdjust`,`font-size-adjust`],[`fontStretch`,`font-stretch`],[`fontStyle`,`font-style`],[`fontVariant`,`font-variant`],[`fontWeight`,`font-weight`],[`glyphName`,`glyph-name`],[`glyphOrientationHorizontal`,`glyph-orientation-horizontal`],[`glyphOrientationVertical`,`glyph-orientation-vertical`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`renderingIntent`,`rendering-intent`],[`shapeRendering`,`shape-rendering`],[`stopColor`,`stop-color`],[`stopOpacity`,`stop-opacity`],[`strikethroughPosition`,`strikethrough-position`],[`strikethroughThickness`,`strikethrough-thickness`],[`strokeDasharray`,`stroke-dasharray`],[`strokeDashoffset`,`stroke-dashoffset`],[`strokeLinecap`,`stroke-linecap`],[`strokeLinejoin`,`stroke-linejoin`],[`strokeMiterlimit`,`stroke-miterlimit`],[`strokeOpacity`,`stroke-opacity`],[`strokeWidth`,`stroke-width`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`underlinePosition`,`underline-position`],[`underlineThickness`,`underline-thickness`],[`unicodeBidi`,`unicode-bidi`],[`unicodeRange`,`unicode-range`],[`unitsPerEm`,`units-per-em`],[`vAlphabetic`,`v-alphabetic`],[`vHanging`,`v-hanging`],[`vIdeographic`,`v-ideographic`],[`vMathematical`,`v-mathematical`],[`vectorEffect`,`vector-effect`],[`vertAdvY`,`vert-adv-y`],[`vertOriginX`,`vert-origin-x`],[`vertOriginY`,`vert-origin-y`],[`wordSpacing`,`word-spacing`],[`writingMode`,`writing-mode`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),nn=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function rn(e){return nn.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function an(){}var on=null;function sn(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var cn=null,ln=null;function un(e){var t=xt(e);if(t&&(e=t.stateNode)){var n=e[ft]||null;a:switch(e=t.stateNode,t.type){case`input`:if(Wt(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+Ut(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[ft]||null;if(!a)throw Error(i(90));Wt(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&Bt(r)}break a;case`textarea`:Jt(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&qt(e,!!n.multiple,t,!1)}}}var dn=!1;function fn(e,t,n){if(dn)return e(t,n);dn=!0;try{return e(t)}finally{if(dn=!1,(cn!==null||ln!==null)&&(Cu(),cn&&(t=cn,e=ln,ln=cn=null,un(t),e)))for(t=0;t<e.length;t++)un(e[t])}}function pn(e,t){var n=e.stateNode;if(n===null)return null;var r=n[ft]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=e!==`button`&&e!==`input`&&e!==`select`&&e!==`textarea`),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(i(231,t,typeof n));return n}var P=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),F=!1;if(P)try{var mn={};Object.defineProperty(mn,"passive",{get:function(){F=!0}}),window.addEventListener(`test`,mn,mn),window.removeEventListener(`test`,mn,mn)}catch{F=!1}var hn=null,gn=null,_n=null;function vn(){if(_n)return _n;var e,t=gn,n=t.length,r,i=`value`in hn?hn.value:hn.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return _n=i.slice(e,1<r?1-r:void 0)}function yn(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function bn(){return!0}function xn(){return!1}function Sn(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?bn:xn,this.isPropagationStopped=xn,this}return f(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=bn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=bn)},persist:function(){},isPersistent:bn}),t}var I={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Cn=Sn(I),wn=f({},I,{view:0,detail:0}),Tn=Sn(wn),En,Dn,On,kn=f({},wn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Bn,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==On&&(On&&e.type===`mousemove`?(En=e.screenX-On.screenX,Dn=e.screenY-On.screenY):Dn=En=0,On=e),En)},movementY:function(e){return`movementY`in e?e.movementY:Dn}}),An=Sn(kn),jn=Sn(f({},kn,{dataTransfer:0})),Mn=Sn(f({},wn,{relatedTarget:0})),Nn=Sn(f({},I,{animationName:0,elapsedTime:0,pseudoElement:0})),Pn=Sn(f({},I,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),Fn=Sn(f({},I,{data:0})),In={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},Ln={8:`Backspace`,9:`Tab`,12:`Clear`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,19:`Pause`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,45:`Insert`,46:`Delete`,112:`F1`,113:`F2`,114:`F3`,115:`F4`,116:`F5`,117:`F6`,118:`F7`,119:`F8`,120:`F9`,121:`F10`,122:`F11`,123:`F12`,144:`NumLock`,145:`ScrollLock`,224:`Meta`},Rn={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function zn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Rn[e])?!!t[e]:!1}function Bn(){return zn}var Vn=Sn(f({},wn,{key:function(e){if(e.key){var t=In[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=yn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?Ln[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Bn,charCode:function(e){return e.type===`keypress`?yn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?yn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),L=Sn(f({},kn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),Hn=Sn(f({},wn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Bn})),R=Sn(f({},I,{propertyName:0,elapsedTime:0,pseudoElement:0})),z=Sn(f({},kn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),B=Sn(f({},I,{newState:0,oldState:0})),Un=[9,13,27,32],Wn=P&&`CompositionEvent`in window,Gn=null;P&&`documentMode`in document&&(Gn=document.documentMode);var Kn=P&&`TextEvent`in window&&!Gn,qn=P&&(!Wn||Gn&&8<Gn&&11>=Gn),Jn=` `,Yn=!1;function Xn(e,t){switch(e){case`keyup`:return Un.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Zn(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var Qn=!1;function $n(e,t){switch(e){case`compositionend`:return Zn(t);case`keypress`:return t.which===32?(Yn=!0,Jn):null;case`textInput`:return e=t.data,e===Jn&&Yn?null:e;default:return null}}function er(e,t){if(Qn)return e===`compositionend`||!Wn&&Xn(e,t)?(e=vn(),_n=gn=hn=null,Qn=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return qn&&t.locale!==`ko`?null:t.data;default:return null}}var tr={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function nr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!tr[e.type]:t===`textarea`}function rr(e,t,n,r){cn?ln?ln.push(r):ln=[r]:cn=r,t=Ad(t,`onChange`),0<t.length&&(n=new Cn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var ir=null,ar=null;function or(e){Cd(e,0)}function sr(e){if(Bt(St(e)))return e}function cr(e,t){if(e===`change`)return t}var lr=!1;if(P){var ur;if(P){var dr=`oninput`in document;if(!dr){var fr=document.createElement(`div`);fr.setAttribute(`oninput`,`return;`),dr=typeof fr.oninput==`function`}ur=dr}else ur=!1;lr=ur&&(!document.documentMode||9<document.documentMode)}function pr(){ir&&(ir.detachEvent(`onpropertychange`,V),ar=ir=null)}function V(e){if(e.propertyName===`value`&&sr(ar)){var t=[];rr(t,ar,e,sn(e)),fn(or,t)}}function mr(e,t,n){e===`focusin`?(pr(),ir=t,ar=n,ir.attachEvent(`onpropertychange`,V)):e===`focusout`&&pr()}function hr(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return sr(ar)}function gr(e,t){if(e===`click`)return sr(t)}function _r(e,t){if(e===`input`||e===`change`)return sr(t)}function vr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var yr=typeof Object.is==`function`?Object.is:vr;function br(e,t){if(yr(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!Ee.call(t,i)||!yr(e[i],t[i]))return!1}return!0}function xr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Sr(e,t){var n=xr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=xr(n)}}function Cr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Cr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function wr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Vt(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Vt(e.document)}return t}function Tr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var Er=P&&`documentMode`in document&&11>=document.documentMode,Dr=null,Or=null,kr=null,Ar=!1;function jr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Ar||Dr==null||Dr!==Vt(r)||(r=Dr,`selectionStart`in r&&Tr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),kr&&br(kr,r)||(kr=r,r=Ad(Or,`onSelect`),0<r.length&&(t=new Cn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=Dr)))}function Mr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var Nr={animationend:Mr(`Animation`,`AnimationEnd`),animationiteration:Mr(`Animation`,`AnimationIteration`),animationstart:Mr(`Animation`,`AnimationStart`),transitionrun:Mr(`Transition`,`TransitionRun`),transitionstart:Mr(`Transition`,`TransitionStart`),transitioncancel:Mr(`Transition`,`TransitionCancel`),transitionend:Mr(`Transition`,`TransitionEnd`)},Pr={},Fr={};P&&(Fr=document.createElement(`div`).style,`AnimationEvent`in window||(delete Nr.animationend.animation,delete Nr.animationiteration.animation,delete Nr.animationstart.animation),`TransitionEvent`in window||delete Nr.transitionend.transition);function Ir(e){if(Pr[e])return Pr[e];if(!Nr[e])return e;var t=Nr[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Fr)return Pr[e]=t[n];return e}var Lr=Ir(`animationend`),Rr=Ir(`animationiteration`),zr=Ir(`animationstart`),Br=Ir(`transitionrun`),Vr=Ir(`transitionstart`),Hr=Ir(`transitioncancel`),Ur=Ir(`transitionend`),Wr=new Map,Gr=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel`.split(` `);Gr.push(`scrollEnd`);function Kr(e,t){Wr.set(e,t),Dt(t,[e])}var qr=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},H=[],Jr=0,Yr=0;function Xr(){for(var e=Jr,t=Yr=Jr=0;t<e;){var n=H[t];H[t++]=null;var r=H[t];H[t++]=null;var i=H[t];H[t++]=null;var a=H[t];if(H[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&ei(n,i,a)}}function Zr(e,t,n,r){H[Jr++]=e,H[Jr++]=t,H[Jr++]=n,H[Jr++]=r,Yr|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function Qr(e,t,n,r){return Zr(e,t,n,r),ti(e)}function $r(e,t){return Zr(e,null,null,t),ti(e)}function ei(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-He(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function ti(e){if(50<mu)throw mu=0,hu=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var ni={};function ri(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ii(e,t,n,r){return new ri(e,t,n,r)}function ai(e){return e=e.prototype,!(!e||!e.isReactComponent)}function oi(e,t){var n=e.alternate;return n===null?(n=ii(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function si(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function ci(e,t,n,r,a,o){var s=0;if(r=e,typeof e==`function`)ai(e)&&(s=1);else if(typeof e==`string`)s=qf(e,n,de.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(e){case ee:return e=ii(31,n,t,a),e.elementType=ee,e.lanes=o,e;case _:return li(n.children,a,o,t);case y:s=8,a|=24;break;case x:return e=ii(12,n,t,a|2),e.elementType=x,e.lanes=o,e;case T:return e=ii(13,n,t,a),e.elementType=T,e.lanes=o,e;case E:return e=ii(19,n,t,a),e.elementType=E,e.lanes=o,e;default:if(typeof e==`object`&&e)switch(e.$$typeof){case C:s=10;break a;case S:s=9;break a;case w:s=11;break a;case D:s=14;break a;case O:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=ii(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function li(e,t,n,r){return e=ii(7,e,r,t),e.lanes=n,e}function ui(e,t,n){return e=ii(6,e,null,t),e.lanes=n,e}function di(e){var t=ii(18,null,null,0);return t.stateNode=e,t}function fi(e,t,n){return t=ii(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var pi=new WeakMap;function mi(e,t){if(typeof e==`object`&&e){var n=pi.get(e);return n===void 0?(t={value:e,source:t,stack:Te(t)},pi.set(e,t),t):n}return{value:e,source:t,stack:Te(t)}}var hi=[],gi=0,_i=null,vi=0,yi=[],bi=0,xi=null,Si=1,Ci=``;function wi(e,t){hi[gi++]=vi,hi[gi++]=_i,_i=e,vi=t}function Ti(e,t,n){yi[bi++]=Si,yi[bi++]=Ci,yi[bi++]=xi,xi=e;var r=Si;e=Ci;var i=32-He(r)-1;r&=~(1<<i),n+=1;var a=32-He(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,Si=1<<32-He(t)+i|n<<i|r,Ci=a+e}else Si=1<<a|n<<i|r,Ci=e}function Ei(e){e.return!==null&&(wi(e,1),Ti(e,1,0))}function Di(e){for(;e===_i;)_i=hi[--gi],hi[gi]=null,vi=hi[--gi],hi[gi]=null;for(;e===xi;)xi=yi[--bi],yi[bi]=null,Ci=yi[--bi],yi[bi]=null,Si=yi[--bi],yi[bi]=null}function Oi(e,t){yi[bi++]=Si,yi[bi++]=Ci,yi[bi++]=xi,Si=t.id,Ci=t.overflow,xi=e}var ki=null,Ai=null,ji=!1,Mi=null,Ni=!1,Pi=Error(i(519));function Fi(e){throw Vi(mi(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),Pi}function Ii(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[dt]=e,t[ft]=r,n){case`dialog`:J(`cancel`,t),J(`close`,t);break;case`iframe`:case`object`:case`embed`:J(`load`,t);break;case`video`:case`audio`:for(n=0;n<xd.length;n++)J(xd[n],t);break;case`source`:J(`error`,t);break;case`img`:case`image`:case`link`:J(`error`,t),J(`load`,t);break;case`details`:J(`toggle`,t);break;case`input`:J(`invalid`,t),Gt(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:J(`invalid`,t);break;case`textarea`:J(`invalid`,t),Yt(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||Id(t.textContent,n)?(r.popover!=null&&(J(`beforetoggle`,t),J(`toggle`,t)),r.onScroll!=null&&J(`scroll`,t),r.onScrollEnd!=null&&J(`scrollend`,t),r.onClick!=null&&(t.onclick=an),t=!0):t=!1,t||Fi(e,!0)}function Li(e){for(ki=e.return;ki;)switch(ki.tag){case 5:case 31:case 13:Ni=!1;return;case 27:case 3:Ni=!0;return;default:ki=ki.return}}function Ri(e){if(e!==ki)return!1;if(!ji)return Li(e),ji=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=n===`form`||n===`button`||qd(e.type,e.memoizedProps)),n=!n),n&&Ai&&Fi(e),Li(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Ai=mf(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Ai=mf(e)}else t===27?(t=Ai,tf(e.type)?(e=pf,pf=null,Ai=e):Ai=t):Ai=ki?ff(e.stateNode.nextSibling):null;return!0}function zi(){Ai=ki=null,ji=!1}function Bi(){var e=Mi;return e!==null&&(eu===null?eu=e:eu.push.apply(eu,e),Mi=null),e}function Vi(e){Mi===null?Mi=[e]:Mi.push(e)}var Hi=ce(null),Ui=null,U=null;function Wi(e,t,n){ue(Hi,t._currentValue),t._currentValue=n}function Gi(e){e._currentValue=Hi.current,le(Hi)}function Ki(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function qi(e,t,n,r){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var o=a.dependencies;if(o!==null){var s=a.child;o=o.firstContext;a:for(;o!==null;){var c=o;o=a;for(var l=0;l<t.length;l++)if(c.context===t[l]){o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),Ki(o.return,n,e),r||(s=null);break a}o=c.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(i(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),Ki(s,n,e),s=null}else s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function Ji(e,t,n,r){e=null;for(var a=t,o=!1;a!==null;){if(!o){if(a.flags&524288)o=!0;else if(a.flags&262144)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(i(387));if(s=s.memoizedProps,s!==null){var c=a.type;yr(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===me.current){if(s=a.alternate,s===null)throw Error(i(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[np]:e.push(np))}a=a.return}e!==null&&qi(t,e,n,r),t.flags|=262144}function Yi(e){for(e=e.firstContext;e!==null;){if(!yr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Xi(e){Ui=e,U=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Zi(e){return $i(Ui,e)}function Qi(e,t){return Ui===null&&Xi(e),$i(e,t)}function $i(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},U===null){if(e===null)throw Error(i(308));U=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else U=U.next=t;return n}var ea=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},W=t.unstable_scheduleCallback,ta=t.unstable_NormalPriority,na={$$typeof:C,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function ra(){return{controller:new ea,data:new Map,refCount:0}}function ia(e){e.refCount--,e.refCount===0&&W(ta,function(){e.controller.abort()})}var aa=null,oa=0,sa=0,ca=null;function la(e,t){if(aa===null){var n=aa=[];oa=0,sa=hd(),ca={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return oa++,t.then(ua,ua),t}function ua(){if(--oa===0&&aa!==null){ca!==null&&(ca.status=`fulfilled`);var e=aa;aa=null,sa=0,ca=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function da(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var fa=j.S;j.S=function(e,t){ru=je(),typeof t==`object`&&t&&typeof t.then==`function`&&la(e,t),fa!==null&&fa(e,t)};var pa=ce(null);function ma(){var e=pa.current;return e===null?Bl.pooledCache:e}function ha(e,t){t===null?ue(pa,pa.current):ue(pa,t.pool)}function ga(){var e=ma();return e===null?null:{parent:na._currentValue,pool:e}}var _a=Error(i(460)),va=Error(i(474)),ya=Error(i(542)),ba={then:function(){}};function xa(e){return e=e.status,e===`fulfilled`||e===`rejected`}function Sa(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(an,an),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Ea(e),e;default:if(typeof t.status==`string`)t.then(an,an);else{if(e=Bl,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Ea(e),e}throw wa=t,_a}}function Ca(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(wa=e,_a):e}}var wa=null;function Ta(){if(wa===null)throw Error(i(459));var e=wa;return wa=null,e}function Ea(e){if(e===_a||e===ya)throw Error(i(483))}var Da=null,Oa=0;function ka(e){var t=Oa;return Oa+=1,Da===null&&(Da=[]),Sa(Da,e,t)}function Aa(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function ja(e,t){throw t.$$typeof===p?Error(i(525)):(e=Object.prototype.toString.call(t),Error(i(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function Ma(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function a(e,t){return e=oi(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=67108866,n):(r=r.index,r<n?(t.flags|=67108866,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=67108866),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=ui(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===_?d(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===O&&Ca(i)===t.type)?(t=a(t,n.props),Aa(t,n),t.return=e,t):(t=ci(n.type,n.key,n.props,null,e.mode,r),Aa(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=fi(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=li(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=ui(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case m:return n=ci(t.type,t.key,t.props,null,e.mode,n),Aa(n,t),n.return=e,n;case h:return t=fi(t,e.mode,n),t.return=e,t;case O:return t=Ca(t),f(e,t,n)}if(A(t)||ne(t))return t=li(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,ka(t),n);if(t.$$typeof===C)return f(e,Qi(e,t),n);ja(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case m:return n.key===i?l(e,t,n,r):null;case h:return n.key===i?u(e,t,n,r):null;case O:return n=Ca(n),p(e,t,n,r)}if(A(n)||ne(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,ka(n),r);if(n.$$typeof===C)return p(e,t,Qi(e,n),r);ja(e,n)}return null}function g(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case m:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case h:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case O:return r=Ca(r),g(e,t,n,r,i)}if(A(r)||ne(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return g(e,t,n,ka(r),i);if(r.$$typeof===C)return g(e,t,n,Qi(t,r),i);ja(t,r)}return null}function v(i,a,s,c){for(var l=null,u=null,d=a,m=a=0,h=null;d!==null&&m<s.length;m++){d.index>m?(h=d,d=null):h=d.sibling;var _=p(i,d,s[m],c);if(_===null){d===null&&(d=h);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,m),u===null?l=_:u.sibling=_,u=_,d=h}if(m===s.length)return n(i,d),ji&&wi(i,m),l;if(d===null){for(;m<s.length;m++)d=f(i,s[m],c),d!==null&&(a=o(d,a,m),u===null?l=d:u.sibling=d,u=d);return ji&&wi(i,m),l}for(d=r(d);m<s.length;m++)h=g(d,i,m,s[m],c),h!==null&&(e&&h.alternate!==null&&d.delete(h.key===null?m:h.key),a=o(h,a,m),u===null?l=h:u.sibling=h,u=h);return e&&d.forEach(function(e){return t(i,e)}),ji&&wi(i,m),l}function y(a,s,c,l){if(c==null)throw Error(i(151));for(var u=null,d=null,m=s,h=s=0,_=null,v=c.next();m!==null&&!v.done;h++,v=c.next()){m.index>h?(_=m,m=null):_=m.sibling;var y=p(a,m,v.value,l);if(y===null){m===null&&(m=_);break}e&&m&&y.alternate===null&&t(a,m),s=o(y,s,h),d===null?u=y:d.sibling=y,d=y,m=_}if(v.done)return n(a,m),ji&&wi(a,h),u;if(m===null){for(;!v.done;h++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,h),d===null?u=v:d.sibling=v,d=v);return ji&&wi(a,h),u}for(m=r(m);!v.done;h++,v=c.next())v=g(m,a,h,v.value,l),v!==null&&(e&&v.alternate!==null&&m.delete(v.key===null?h:v.key),s=o(v,s,h),d===null?u=v:d.sibling=v,d=v);return e&&m.forEach(function(e){return t(a,e)}),ji&&wi(a,h),u}function b(e,r,o,c){if(typeof o==`object`&&o&&o.type===_&&o.key===null&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case m:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===_){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===O&&Ca(l)===r.type){n(e,r.sibling),c=a(r,o.props),Aa(c,o),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}o.type===_?(c=li(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=ci(o.type,o.key,o.props,null,e.mode,c),Aa(c,o),c.return=e,e=c)}return s(e);case h:a:{for(l=o.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}else{n(e,r);break}t(e,r),r=r.sibling}c=fi(o,e.mode,c),c.return=e,e=c}return s(e);case O:return o=Ca(o),b(e,r,o,c)}if(A(o))return v(e,r,o,c);if(ne(o)){if(l=ne(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),y(e,r,o,c)}if(typeof o.then==`function`)return b(e,r,ka(o),c);if(o.$$typeof===C)return b(e,r,Qi(e,o),c);ja(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=ui(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{Oa=0;var i=b(e,t,n,r);return Da=null,i}catch(t){if(t===_a||t===ya)throw t;var a=ii(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Na=Ma(!0),Pa=Ma(!1),Fa=!1;function Ia(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function La(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Ra(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function za(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,zl&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=ti(e),ei(e,null,n),t}return Zr(e,r,t,n),ti(e)}function Ba(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,it(e,n)}}function Va(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Ha=!1;function Ua(){if(Ha){var e=ca;if(e!==null)throw e}}function Wa(e,t,n,r){Ha=!1;var i=e.updateQueue;Fa=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var p=s.lane&-536870913,m=p!==s.lane;if(m?(q&p)===p:(r&p)===p){p!==0&&p===sa&&(Ha=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var h=e,g=s;p=t;var _=n;switch(g.tag){case 1:if(h=g.payload,typeof h==`function`){d=h.call(_,d,p);break a}d=h;break a;case 3:h.flags=h.flags&-65537|128;case 0:if(h=g.payload,p=typeof h==`function`?h.call(_,d,p):h,p==null)break a;d=f({},d,p);break a;case 2:Fa=!0}}p=s.callback,p!==null&&(e.flags|=64,m&&(e.flags|=8192),m=i.callbacks,m===null?i.callbacks=[p]:m.push(p))}else m={lane:p,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=m,c=d):u=u.next=m,o|=p;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;m=s,s=m.next,m.next=null,i.lastBaseUpdate=m,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),Jl|=o,e.lanes=o,e.memoizedState=d}}function Ga(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function Ka(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)Ga(n[e],t)}var qa=ce(null),Ja=ce(0);function Ya(e,t){e=Kl,ue(Ja,e),ue(qa,t),Kl=e|t.baseLanes}function Xa(){ue(Ja,Kl),ue(qa,qa.current)}function Za(){Kl=Ja.current,le(qa),le(Ja)}var Qa=ce(null),$a=null;function eo(e){var t=e.alternate;ue(ao,ao.current&1),ue(Qa,e),$a===null&&(t===null||qa.current!==null||t.memoizedState!==null)&&($a=e)}function to(e){ue(ao,ao.current),ue(Qa,e),$a===null&&($a=e)}function no(e){e.tag===22?(ue(ao,ao.current),ue(Qa,e),$a===null&&($a=e)):ro(e)}function ro(){ue(ao,ao.current),ue(Qa,Qa.current)}function io(e){le(Qa),$a===e&&($a=null),le(ao)}var ao=ce(0);function oo(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||lf(n)||uf(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder===`forwards`||t.memoizedProps.revealOrder===`backwards`||t.memoizedProps.revealOrder===`unstable_legacy-backwards`||t.memoizedProps.revealOrder===`together`)){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var so=0,G=null,co=null,lo=null,uo=!1,fo=!1,po=!1,mo=0,ho=0,go=null,_o=0;function vo(){throw Error(i(321))}function yo(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!yr(e[n],t[n]))return!1;return!0}function bo(e,t,n,r,i,a){return so=a,G=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,j.H=e===null||e.memoizedState===null?Ls:Rs,po=!1,a=n(r,i),po=!1,fo&&(a=So(t,n,r,i)),xo(e),a}function xo(e){j.H=Is;var t=co!==null&&co.next!==null;if(so=0,lo=co=G=null,uo=!1,ho=0,go=null,t)throw Error(i(300));e===null||tc||(e=e.dependencies,e!==null&&Yi(e)&&(tc=!0))}function So(e,t,n,r){G=e;var a=0;do{if(fo&&(go=null),ho=0,fo=!1,25<=a)throw Error(i(301));if(a+=1,lo=co=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}j.H=zs,o=t(n,r)}while(fo);return o}function Co(){var e=j.H,t=e.useState()[0];return t=typeof t.then==`function`?Ao(t):t,e=e.useState()[0],(co===null?null:co.memoizedState)!==e&&(G.flags|=1024),t}function wo(){var e=mo!==0;return mo=0,e}function To(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function Eo(e){if(uo){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}uo=!1}so=0,lo=co=G=null,fo=!1,ho=mo=0,go=null}function Do(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return lo===null?G.memoizedState=lo=e:lo=lo.next=e,lo}function Oo(){if(co===null){var e=G.alternate;e=e===null?null:e.memoizedState}else e=co.next;var t=lo===null?G.memoizedState:lo.next;if(t!==null)lo=t,co=e;else{if(e===null)throw G.alternate===null?Error(i(467)):Error(i(310));co=e,e={memoizedState:co.memoizedState,baseState:co.baseState,baseQueue:co.baseQueue,queue:co.queue,next:null},lo===null?G.memoizedState=lo=e:lo=lo.next=e}return lo}function ko(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Ao(e){var t=ho;return ho+=1,go===null&&(go=[]),e=Sa(go,e,t),t=G,(lo===null?t.memoizedState:lo.next)===null&&(t=t.alternate,j.H=t===null||t.memoizedState===null?Ls:Rs),e}function jo(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return Ao(e);if(e.$$typeof===C)return Zi(e)}throw Error(i(438,String(e)))}function Mo(e){var t=null,n=G.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=G.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=ko(),G.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=k;return t.index++,n}function No(e,t){return typeof t==`function`?t(e):t}function Po(e){return Fo(Oo(),co,e)}function Fo(e,t,n){var r=e.queue;if(r===null)throw Error(i(311));r.lastRenderedReducer=n;var a=e.baseQueue,o=r.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}t.baseQueue=a=o,r.pending=null}if(o=e.baseState,a===null)e.memoizedState=o;else{t=a.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(so&f)===f:(q&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===sa&&(d=!0);else if((so&p)===p){u=u.next,p===sa&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=o):l=l.next=f,G.lanes|=p,Jl|=p;f=u.action,po&&n(o,f),o=u.hasEagerState?u.eagerState:n(o,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=o):l=l.next=p,G.lanes|=f,Jl|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!yr(o,e.memoizedState)&&(tc=!0,d&&(n=ca,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,r.lastRenderedState=o}return a===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function Io(e){var t=Oo(),n=t.queue;if(n===null)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);yr(o,t.memoizedState)||(tc=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function Lo(e,t,n){var r=G,a=Oo(),o=ji;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!yr((co||a).memoizedState,n);if(s&&(a.memoizedState=n,tc=!0),a=a.queue,cs(Bo.bind(null,r,a,e),[e]),a.getSnapshot!==t||s||lo!==null&&lo.memoizedState.tag&1){if(r.flags|=2048,rs(9,{destroy:void 0},zo.bind(null,r,a,n,t),null),Bl===null)throw Error(i(349));o||so&127||Ro(r,t,n)}return n}function Ro(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=G.updateQueue,t===null?(t=ko(),G.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function zo(e,t,n,r){t.value=n,t.getSnapshot=r,Vo(t)&&Ho(e)}function Bo(e,t,n){return n(function(){Vo(t)&&Ho(e)})}function Vo(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!yr(e,n)}catch{return!0}}function Ho(e){var t=$r(e,2);t!==null&&vu(t,e,2)}function Uo(e){var t=Do();if(typeof e==`function`){var n=e;if(e=n(),po){Ve(!0);try{n()}finally{Ve(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:No,lastRenderedState:e},t}function Wo(e,t,n,r){return e.baseState=n,Fo(e,co,typeof r==`function`?r:No)}function Go(e,t,n,r,a){if(Ns(e))throw Error(i(485));if(e=t.action,e!==null){var o={payload:a,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};j.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,Ko(t,o)):(o.next=n.next,t.pending=n.next=o)}}function Ko(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=j.T,o={};j.T=o;try{var s=n(i,r),c=j.S;c!==null&&c(o,s),qo(e,t,s)}catch(n){Yo(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),j.T=a}}else try{a=n(i,r),qo(e,t,a)}catch(n){Yo(e,t,n)}}function qo(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){Jo(e,t,n)},function(n){return Yo(e,t,n)}):Jo(e,t,n)}function Jo(e,t,n){t.status=`fulfilled`,t.value=n,Xo(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Ko(e,n)))}function Yo(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,Xo(t),t=t.next;while(t!==r)}e.action=null}function Xo(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Zo(e,t){return t}function Qo(e,t){if(ji){var n=Bl.formState;if(n!==null){a:{var r=G;if(ji){if(Ai){b:{for(var i=Ai,a=Ni;i.nodeType!==8;){if(!a){i=null;break b}if(i=ff(i.nextSibling),i===null){i=null;break b}}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){Ai=ff(i.nextSibling),r=i.data===`F!`;break a}}Fi(r)}r=!1}r&&(t=n[0])}}return n=Do(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Zo,lastRenderedState:t},n.queue=r,n=As.bind(null,G,r),r.dispatch=n,r=Uo(!1),a=Ms.bind(null,G,!1,r.queue),r=Do(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=Go.bind(null,G,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function $o(e){return es(Oo(),co,e)}function es(e,t,n){if(t=Fo(e,t,Zo)[0],e=Po(No)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=Ao(t)}catch(e){throw e===_a?ya:e}else r=t;t=Oo();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(G.flags|=2048,rs(9,{destroy:void 0},ts.bind(null,i,n),null)),[r,a,e]}function ts(e,t){e.action=t}function ns(e){var t=Oo(),n=co;if(n!==null)return es(t,n,e);Oo(),t=t.memoizedState,n=Oo();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function rs(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=G.updateQueue,t===null&&(t=ko(),G.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function is(){return Oo().memoizedState}function as(e,t,n,r){var i=Do();G.flags|=e,i.memoizedState=rs(1|t,{destroy:void 0},n,r===void 0?null:r)}function os(e,t,n,r){var i=Oo();r=r===void 0?null:r;var a=i.memoizedState.inst;co!==null&&r!==null&&yo(r,co.memoizedState.deps)?i.memoizedState=rs(t,a,n,r):(G.flags|=e,i.memoizedState=rs(1|t,a,n,r))}function ss(e,t){as(8390656,8,e,t)}function cs(e,t){os(2048,8,e,t)}function ls(e){G.flags|=4;var t=G.updateQueue;if(t===null)t=ko(),G.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function us(e){var t=Oo().memoizedState;return ls({ref:t,nextImpl:e}),function(){if(zl&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function ds(e,t){return os(4,2,e,t)}function fs(e,t){return os(4,4,e,t)}function ps(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function ms(e,t,n){n=n==null?null:n.concat([e]),os(4,4,ps.bind(null,t,e),n)}function hs(){}function gs(e,t){var n=Oo();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&yo(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function _s(e,t){var n=Oo();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&yo(t,r[1]))return r[0];if(r=e(),po){Ve(!0);try{e()}finally{Ve(!1)}}return n.memoizedState=[r,t],r}function vs(e,t,n){return n===void 0||so&1073741824&&!(q&261930)?e.memoizedState=t:(e.memoizedState=n,e=_u(),G.lanes|=e,Jl|=e,n)}function ys(e,t,n,r){return yr(n,t)?n:qa.current===null?!(so&42)||so&1073741824&&!(q&261930)?(tc=!0,e.memoizedState=n):(e=_u(),G.lanes|=e,Jl|=e,t):(e=vs(e,n,r),yr(e,t)||(tc=!0),e)}function bs(e,t,n,r,i){var a=M.p;M.p=a!==0&&8>a?a:8;var o=j.T,s={};j.T=s,Ms(e,!1,t,n);try{var c=i(),l=j.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?js(e,t,da(c,r),gu(e)):js(e,t,r,gu(e))}catch(n){js(e,t,{then:function(){},status:`rejected`,reason:n},gu())}finally{M.p=a,o!==null&&s.types!==null&&(o.types=s.types),j.T=o}}function xs(){}function Ss(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=Cs(e).queue;bs(e,a,t,ae,n===null?xs:function(){return ws(e),n(r)})}function Cs(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:ae,baseState:ae,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:No,lastRenderedState:ae},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:No,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function ws(e){var t=Cs(e);t.next===null&&(t=e.alternate.memoizedState),js(e,t.next.queue,{},gu())}function Ts(){return Zi(np)}function Es(){return Oo().memoizedState}function Ds(){return Oo().memoizedState}function Os(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=gu();e=Ra(n);var r=za(t,e,n);r!==null&&(vu(r,t,n),Ba(r,t,n)),t={cache:ra()},e.payload=t;return}t=t.return}}function ks(e,t,n){var r=gu();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Ns(e)?Ps(t,n):(n=Qr(e,t,n,r),n!==null&&(vu(n,e,r),Fs(n,t,r)))}function As(e,t,n){js(e,t,n,gu())}function js(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ns(e))Ps(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,yr(s,o))return Zr(e,t,i,0),Bl===null&&Xr(),!1}catch{}if(n=Qr(e,t,i,r),n!==null)return vu(n,e,r),Fs(n,t,r),!0}return!1}function Ms(e,t,n,r){if(r={lane:2,revertLane:hd(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Ns(e)){if(t)throw Error(i(479))}else t=Qr(e,n,r,2),t!==null&&vu(t,e,2)}function Ns(e){var t=e.alternate;return e===G||t!==null&&t===G}function Ps(e,t){fo=uo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Fs(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,it(e,n)}}var Is={readContext:Zi,use:jo,useCallback:vo,useContext:vo,useEffect:vo,useImperativeHandle:vo,useLayoutEffect:vo,useInsertionEffect:vo,useMemo:vo,useReducer:vo,useRef:vo,useState:vo,useDebugValue:vo,useDeferredValue:vo,useTransition:vo,useSyncExternalStore:vo,useId:vo,useHostTransitionStatus:vo,useFormState:vo,useActionState:vo,useOptimistic:vo,useMemoCache:vo,useCacheRefresh:vo};Is.useEffectEvent=vo;var Ls={readContext:Zi,use:jo,useCallback:function(e,t){return Do().memoizedState=[e,t===void 0?null:t],e},useContext:Zi,useEffect:ss,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),as(4194308,4,ps.bind(null,t,e),n)},useLayoutEffect:function(e,t){return as(4194308,4,e,t)},useInsertionEffect:function(e,t){as(4,2,e,t)},useMemo:function(e,t){var n=Do();t=t===void 0?null:t;var r=e();if(po){Ve(!0);try{e()}finally{Ve(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=Do();if(n!==void 0){var i=n(t);if(po){Ve(!0);try{n(t)}finally{Ve(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=ks.bind(null,G,e),[r.memoizedState,e]},useRef:function(e){var t=Do();return e={current:e},t.memoizedState=e},useState:function(e){e=Uo(e);var t=e.queue,n=As.bind(null,G,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:hs,useDeferredValue:function(e,t){return vs(Do(),e,t)},useTransition:function(){var e=Uo(!1);return e=bs.bind(null,G,e.queue,!0,!1),Do().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=G,a=Do();if(ji){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Bl===null)throw Error(i(349));q&127||Ro(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,ss(Bo.bind(null,r,o,e),[e]),r.flags|=2048,rs(9,{destroy:void 0},zo.bind(null,r,o,n,t),null),n},useId:function(){var e=Do(),t=Bl.identifierPrefix;if(ji){var n=Ci,r=Si;n=(r&~(1<<32-He(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=mo++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=_o++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:Ts,useFormState:Qo,useActionState:Qo,useOptimistic:function(e){var t=Do();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Ms.bind(null,G,!0,n),n.dispatch=t,[e,t]},useMemoCache:Mo,useCacheRefresh:function(){return Do().memoizedState=Os.bind(null,G)},useEffectEvent:function(e){var t=Do(),n={impl:e};return t.memoizedState=n,function(){if(zl&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},Rs={readContext:Zi,use:jo,useCallback:gs,useContext:Zi,useEffect:cs,useImperativeHandle:ms,useInsertionEffect:ds,useLayoutEffect:fs,useMemo:_s,useReducer:Po,useRef:is,useState:function(){return Po(No)},useDebugValue:hs,useDeferredValue:function(e,t){return ys(Oo(),co.memoizedState,e,t)},useTransition:function(){var e=Po(No)[0],t=Oo().memoizedState;return[typeof e==`boolean`?e:Ao(e),t]},useSyncExternalStore:Lo,useId:Es,useHostTransitionStatus:Ts,useFormState:$o,useActionState:$o,useOptimistic:function(e,t){return Wo(Oo(),co,e,t)},useMemoCache:Mo,useCacheRefresh:Ds};Rs.useEffectEvent=us;var zs={readContext:Zi,use:jo,useCallback:gs,useContext:Zi,useEffect:cs,useImperativeHandle:ms,useInsertionEffect:ds,useLayoutEffect:fs,useMemo:_s,useReducer:Io,useRef:is,useState:function(){return Io(No)},useDebugValue:hs,useDeferredValue:function(e,t){var n=Oo();return co===null?vs(n,e,t):ys(n,co.memoizedState,e,t)},useTransition:function(){var e=Io(No)[0],t=Oo().memoizedState;return[typeof e==`boolean`?e:Ao(e),t]},useSyncExternalStore:Lo,useId:Es,useHostTransitionStatus:Ts,useFormState:ns,useActionState:ns,useOptimistic:function(e,t){var n=Oo();return co===null?(n.baseState=e,[e,n.queue.dispatch]):Wo(n,co,e,t)},useMemoCache:Mo,useCacheRefresh:Ds};zs.useEffectEvent=us;function Bs(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:f({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Vs={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=gu(),i=Ra(r);i.payload=t,n!=null&&(i.callback=n),t=za(e,i,r),t!==null&&(vu(t,e,r),Ba(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=gu(),i=Ra(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=za(e,i,r),t!==null&&(vu(t,e,r),Ba(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=gu(),r=Ra(n);r.tag=2,t!=null&&(r.callback=t),t=za(e,r,n),t!==null&&(vu(t,e,n),Ba(t,e,n))}};function Hs(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!br(n,r)||!br(i,a):!0}function Us(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Vs.enqueueReplaceState(t,t.state,null)}function Ws(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=f({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function Gs(e){qr(e)}function Ks(e){console.error(e)}function qs(e){qr(e)}function Js(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function Ys(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Xs(e,t,n){return n=Ra(n),n.tag=3,n.payload={element:null},n.callback=function(){Js(e,t)},n}function Zs(e){return e=Ra(e),e.tag=3,e}function Qs(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){Ys(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){Ys(t,n,r),typeof i!=`function`&&(ou===null?ou=new Set([this]):ou.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function $s(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&Ji(t,n,a,!0),n=Qa.current,n!==null){switch(n.tag){case 31:case 13:return $a===null?Au():n.alternate===null&&ql===0&&(ql=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===ba?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),Yu(e,r,a)),!1;case 22:return n.flags|=65536,r===ba?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),Yu(e,r,a)),!1}throw Error(i(435,n.tag))}return Yu(e,r,a),Au(),!1}if(ji)return t=Qa.current,t===null?(r!==Pi&&(t=Error(i(423),{cause:r}),Vi(mi(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=mi(r,n),a=Xs(e.stateNode,r,a),Va(e,a),ql!==4&&(ql=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==Pi&&(e=Error(i(422),{cause:r}),Vi(mi(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=mi(o,n),$l===null?$l=[o]:$l.push(o),ql!==4&&(ql=2),t===null)return!0;r=mi(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=Xs(n.stateNode,r,e),Va(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(ou===null||!ou.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=Zs(a),Qs(a,e,n,r),Va(n,a),!1}n=n.return}while(n!==null);return!1}var ec=Error(i(461)),tc=!1;function nc(e,t,n,r){t.child=e===null?Pa(t,null,n,r):Na(t,e.child,n,r)}function rc(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return Xi(t),r=bo(e,t,n,o,a,i),s=wo(),e!==null&&!tc?(To(e,t,i),Dc(e,t,i)):(ji&&s&&Ei(t),t.flags|=1,nc(e,t,r,i),t.child)}function ic(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!ai(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,ac(e,t,a,r,i)):(e=ci(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!Oc(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?br:n,n(o,r)&&e.ref===t.ref)return Dc(e,t,i)}return t.flags|=1,e=oi(a,r),e.ref=t.ref,e.return=t,t.child=e}function ac(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(br(a,r)&&e.ref===t.ref)if(tc=!1,t.pendingProps=r=a,Oc(e,i))e.flags&131072&&(tc=!0);else return t.lanes=e.lanes,Dc(e,t,i)}return pc(e,t,n,r,i)}function oc(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return cc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&ha(t,a===null?null:a.cachePool),a===null?Xa():Ya(t,a),no(t);else return r=t.lanes=536870912,cc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&ha(t,null),Xa(),ro(t)):(ha(t,a.cachePool),Ya(t,a),ro(t),t.memoizedState=null);return nc(e,t,i,n),t.child}function sc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function cc(e,t,n,r,i){var a=ma();return a=a===null?null:{parent:na._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&ha(t,null),Xa(),no(t),e!==null&&Ji(e,t,r,!0),t.childLanes=i,null}function lc(e,t){return t=Sc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function uc(e,t,n){return Na(t,e.child,null,n),e=lc(t,t.pendingProps),e.flags|=2,io(t),t.memoizedState=null,e}function dc(e,t,n){var r=t.pendingProps,a=!!(t.flags&128);if(t.flags&=-129,e===null){if(ji){if(r.mode===`hidden`)return e=lc(t,r),t.lanes=536870912,sc(null,e);if(to(t),(e=Ai)?(e=cf(e,Ni),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:xi===null?null:{id:Si,overflow:Ci},retryLane:536870912,hydrationErrors:null},n=di(e),n.return=t,t.child=n,ki=t,Ai=null)):e=null,e===null)throw Fi(t);return t.lanes=536870912,null}return lc(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(to(t),a)if(t.flags&256)t.flags&=-257,t=uc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558));else if(tc||Ji(e,t,n,!1),a=(n&e.childLanes)!==0,tc||a){if(r=Bl,r!==null&&(s=at(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,$r(e,s),vu(r,e,s),ec;Au(),t=uc(e,t,n)}else e=o.treeContext,Ai=ff(s.nextSibling),ki=t,ji=!0,Mi=null,Ni=!1,e!==null&&Oi(t,e),t=lc(t,r),t.flags|=4096;return t}return e=oi(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function fc(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(i(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function pc(e,t,n,r,i){return Xi(t),n=bo(e,t,n,r,void 0,i),r=wo(),e!==null&&!tc?(To(e,t,i),Dc(e,t,i)):(ji&&r&&Ei(t),t.flags|=1,nc(e,t,n,i),t.child)}function mc(e,t,n,r,i,a){return Xi(t),t.updateQueue=null,n=So(t,r,n,i),xo(e),r=wo(),e!==null&&!tc?(To(e,t,a),Dc(e,t,a)):(ji&&r&&Ei(t),t.flags|=1,nc(e,t,n,a),t.child)}function hc(e,t,n,r,i){if(Xi(t),t.stateNode===null){var a=ni,o=n.contextType;typeof o==`object`&&o&&(a=Zi(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Vs,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},Ia(t),o=n.contextType,a.context=typeof o==`object`&&o?Zi(o):ni,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Bs(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&Vs.enqueueReplaceState(a,a.state,null),Wa(t,r,a,i),Ua(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=Ws(n,s);a.props=c;var l=a.context,u=n.contextType;o=ni,typeof u==`object`&&u&&(o=Zi(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&Us(t,a,r,o),Fa=!1;var f=t.memoizedState;a.state=f,Wa(t,r,a,i),Ua(),l=t.memoizedState,s||f!==l||Fa?(typeof d==`function`&&(Bs(t,n,d,r),l=t.memoizedState),(c=Fa||Hs(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,La(e,t),o=t.memoizedProps,u=Ws(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=ni,typeof l==`object`&&l&&(c=Zi(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&Us(t,a,r,c),Fa=!1,f=t.memoizedState,a.state=f,Wa(t,r,a,i),Ua();var p=t.memoizedState;o!==d||f!==p||Fa||e!==null&&e.dependencies!==null&&Yi(e.dependencies)?(typeof s==`function`&&(Bs(t,n,s,r),p=t.memoizedState),(u=Fa||Hs(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&Yi(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,fc(e,t),r=!!(t.flags&128),a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=Na(t,e.child,null,i),t.child=Na(t,null,n,i)):nc(e,t,n,i),t.memoizedState=a.state,e=t.child):e=Dc(e,t,i),e}function gc(e,t,n,r){return zi(),t.flags|=256,nc(e,t,n,r),t.child}var _c={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function vc(e){return{baseLanes:e,cachePool:ga()}}function yc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=Zl),e}function bc(e,t,n){var r=t.pendingProps,a=!1,o=!!(t.flags&128),s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:!!(ao.current&2)),s&&(a=!0,t.flags&=-129),s=!!(t.flags&32),t.flags&=-33,e===null){if(ji){if(a?eo(t):ro(t),(e=Ai)?(e=cf(e,Ni),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:xi===null?null:{id:Si,overflow:Ci},retryLane:536870912,hydrationErrors:null},n=di(e),n.return=t,t.child=n,ki=t,Ai=null)):e=null,e===null)throw Fi(t);return uf(e)?t.lanes=32:t.lanes=536870912,null}var c=r.children;return r=r.fallback,a?(ro(t),a=t.mode,c=Sc({mode:`hidden`,children:c},a),r=li(r,a,n,null),c.return=t,r.return=t,c.sibling=r,t.child=c,r=t.child,r.memoizedState=vc(n),r.childLanes=yc(e,s,n),t.memoizedState=_c,sc(null,r)):(eo(t),xc(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(o)t.flags&256?(eo(t),t.flags&=-257,t=Cc(e,t,n)):t.memoizedState===null?(ro(t),c=r.fallback,a=t.mode,r=Sc({mode:`visible`,children:r.children},a),c=li(c,a,n,null),c.flags|=2,r.return=t,c.return=t,r.sibling=c,t.child=r,Na(t,e.child,null,n),r=t.child,r.memoizedState=vc(n),r.childLanes=yc(e,s,n),t.memoizedState=_c,t=sc(null,r)):(ro(t),t.child=e.child,t.flags|=128,t=null);else if(eo(t),uf(c)){if(s=c.nextSibling&&c.nextSibling.dataset,s)var u=s.dgst;s=u,r=Error(i(419)),r.stack=``,r.digest=s,Vi({value:r,source:null,stack:null}),t=Cc(e,t,n)}else if(tc||Ji(e,t,n,!1),s=(n&e.childLanes)!==0,tc||s){if(s=Bl,s!==null&&(r=at(s,n),r!==0&&r!==l.retryLane))throw l.retryLane=r,$r(e,r),vu(s,e,r),ec;lf(c)||Au(),t=Cc(e,t,n)}else lf(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,Ai=ff(c.nextSibling),ki=t,ji=!0,Mi=null,Ni=!1,e!==null&&Oi(t,e),t=xc(t,r.children),t.flags|=4096);return t}return a?(ro(t),c=r.fallback,a=t.mode,l=e.child,u=l.sibling,r=oi(l,{mode:`hidden`,children:r.children}),r.subtreeFlags=l.subtreeFlags&65011712,u===null?(c=li(c,a,n,null),c.flags|=2):c=oi(u,c),c.return=t,r.return=t,r.sibling=c,t.child=r,sc(null,r),r=t.child,c=e.child.memoizedState,c===null?c=vc(n):(a=c.cachePool,a===null?a=ga():(l=na._currentValue,a=a.parent===l?a:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:a}),r.memoizedState=c,r.childLanes=yc(e,s,n),t.memoizedState=_c,sc(e.child,r)):(eo(t),n=e.child,e=n.sibling,n=oi(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function xc(e,t){return t=Sc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function Sc(e,t){return e=ii(22,e,null,t),e.lanes=0,e}function Cc(e,t,n){return Na(t,e.child,null,n),e=xc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function wc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Ki(e.return,t,n)}function Tc(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function Ec(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=ao.current,s=!!(o&2);if(s?(o=o&1|2,t.flags|=128):o&=1,ue(ao,o),nc(e,t,r,n),r=ji?vi:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&wc(e,n,t);else if(e.tag===19)wc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&oo(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),Tc(t,!1,i,n,a,r);break;case`backwards`:case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&oo(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}Tc(t,!0,n,null,a,r);break;case`together`:Tc(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function Dc(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Jl|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(Ji(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(i(153));if(t.child!==null){for(e=t.child,n=oi(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=oi(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Oc(e,t){return(e.lanes&t)!==0||(e=e.dependencies,!!(e!==null&&Yi(e)))}function kc(e,t,n){switch(t.tag){case 3:he(t,t.stateNode.containerInfo),Wi(t,na,e.memoizedState.cache),zi();break;case 27:case 5:_e(t);break;case 4:he(t,t.stateNode.containerInfo);break;case 10:Wi(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,to(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(eo(t),e=Dc(e,t,n),e===null?null:e.sibling):bc(e,t,n):(eo(t),t.flags|=128,null);eo(t);break;case 19:var i=!!(e.flags&128);if(r=(n&t.childLanes)!==0,r||=(Ji(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return Ec(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),ue(ao,ao.current),r)break;return null;case 22:return t.lanes=0,oc(e,t,n,t.pendingProps);case 24:Wi(t,na,e.memoizedState.cache)}return Dc(e,t,n)}function Ac(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)tc=!0;else{if(!Oc(e,n)&&!(t.flags&128))return tc=!1,kc(e,t,n);tc=!!(e.flags&131072)}else tc=!1,ji&&t.flags&1048576&&Ti(t,vi,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=Ca(t.elementType),t.type=e,typeof e==`function`)ai(e)?(r=Ws(e,r),t.tag=1,t=hc(null,t,e,r,n)):(t.tag=0,t=pc(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===w){t.tag=11,t=rc(null,t,e,r,n);break a}if(a===D){t.tag=14,t=ic(null,t,e,r,n);break a}}throw t=ie(e)||e,Error(i(306,t,``))}}return t;case 0:return pc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=Ws(r,t.pendingProps),hc(e,t,r,a,n);case 3:a:{if(he(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,La(e,t),Wa(t,r,null,n);var s=t.memoizedState;if(r=s.cache,Wi(t,na,r),r!==o.cache&&qi(t,[na],n,!0),Ua(),r=s.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=gc(e,t,r,n);break a}else if(r!==a){a=mi(Error(i(424)),t),Vi(a),t=gc(e,t,r,n);break a}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(Ai=ff(e.firstChild),ki=t,ji=!0,Mi=null,Ni=!0,n=Pa(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(zi(),r===a){t=Dc(e,t,n);break a}nc(e,t,r,n)}t=t.child}return t;case 26:return fc(e,t),e===null?(n=Nf(t.type,null,t.pendingProps,null))?t.memoizedState=n:ji||(n=t.type,e=t.pendingProps,r=Wd(pe.current).createElement(n),r[dt]=t,r[ft]=e,Y(r,n,e),wt(r),t.stateNode=r):t.memoizedState=Nf(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return _e(t),e===null&&ji&&(r=t.stateNode=gf(t.type,t.pendingProps,pe.current),ki=t,Ni=!0,a=Ai,tf(t.type)?(pf=a,Ai=ff(r.firstChild)):Ai=a),nc(e,t,t.pendingProps.children,n),fc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&ji&&((a=r=Ai)&&(r=of(r,t.type,t.pendingProps,Ni),r===null?a=!1:(t.stateNode=r,ki=t,Ai=ff(r.firstChild),Ni=!1,a=!0)),a||Fi(t)),_e(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,qd(a,o)?r=null:s!==null&&qd(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=bo(e,t,Co,null,null,n),np._currentValue=a),fc(e,t),nc(e,t,r,n),t.child;case 6:return e===null&&ji&&((e=n=Ai)&&(n=sf(n,t.pendingProps,Ni),n===null?e=!1:(t.stateNode=n,ki=t,Ai=null,e=!0)),e||Fi(t)),null;case 13:return bc(e,t,n);case 4:return he(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Na(t,null,r,n):nc(e,t,r,n),t.child;case 11:return rc(e,t,t.type,t.pendingProps,n);case 7:return nc(e,t,t.pendingProps,n),t.child;case 8:return nc(e,t,t.pendingProps.children,n),t.child;case 12:return nc(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,Wi(t,t.type,r.value),nc(e,t,r.children,n),t.child;case 9:return a=t.type._context,r=t.pendingProps.children,Xi(t),a=Zi(a),r=r(a),t.flags|=1,nc(e,t,r,n),t.child;case 14:return ic(e,t,t.type,t.pendingProps,n);case 15:return ac(e,t,t.type,t.pendingProps,n);case 19:return Ec(e,t,n);case 31:return dc(e,t,n);case 22:return oc(e,t,n,t.pendingProps);case 24:return Xi(t),r=Zi(na),e===null?(a=ma(),a===null&&(a=Bl,o=ra(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},Ia(t),Wi(t,na,a)):((e.lanes&n)!==0&&(La(e,t),Wa(t,null,null,n),Ua()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,Wi(t,na,r),r!==a.cache&&qi(t,[na],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),Wi(t,na,r))),nc(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function jc(e){e.flags|=4}function Mc(e,t,n,r,i){if((t=!!(e.mode&32))&&(t=!1),t){if(e.flags|=16777216,(i&335544128)===i)if(e.stateNode.complete)e.flags|=8192;else if(Du())e.flags|=8192;else throw wa=ba,va}else e.flags&=-16777217}function Nc(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!Jf(t))if(Du())e.flags|=8192;else throw wa=ba,va}function Pc(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:$e(),e.lanes|=t,Ql|=t)}function Fc(e,t){if(!ji)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Ic(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&65011712,r|=i.flags&65011712,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Lc(e,t,n){var r=t.pendingProps;switch(Di(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ic(t),null;case 1:return Ic(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),Gi(na),ge(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(Ri(t)?jc(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Bi())),Ic(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(jc(t),o===null?(Ic(t),Mc(t,a,null,r,n)):(Ic(t),Nc(t,o))):o?o===e.memoizedState?(Ic(t),t.flags&=-16777217):(jc(t),Ic(t),Nc(t,o)):(e=e.memoizedProps,e!==r&&jc(t),Ic(t),Mc(t,a,e,r,n)),null;case 27:if(ve(t),n=pe.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&jc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Ic(t),null}e=de.current,Ri(t)?Ii(t,e):(e=gf(a,r,n),t.stateNode=e,jc(t))}return Ic(t),null;case 5:if(ve(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&jc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Ic(t),null}if(o=de.current,Ri(t))Ii(t,o);else{var s=Wd(pe.current);switch(o){case 1:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case 2:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;default:switch(a){case`svg`:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case`math`:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;case`script`:o=s.createElement(`div`),o.innerHTML=`<script><\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[dt]=t,o[ft]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(Y(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&jc(t)}}return Ic(t),Mc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&jc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=pe.current,Ri(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=ki,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[dt]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||Id(e.nodeValue,n)),e||Fi(t,!0)}else e=Wd(e).createTextNode(r),e[dt]=t,t.stateNode=e}return Ic(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Ri(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[dt]=t}else zi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Ic(t),e=!1}else n=Bi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(io(t),t):(io(t),null);if(t.flags&128)throw Error(i(558))}return Ic(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=Ri(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[dt]=t}else zi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Ic(t),a=!1}else a=Bi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(io(t),t):(io(t),null)}return io(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Pc(t,t.updateQueue),Ic(t),null);case 4:return ge(),e===null&&Ed(t.stateNode.containerInfo),Ic(t),null;case 10:return Gi(t.type),Ic(t),null;case 19:if(le(ao),r=t.memoizedState,r===null)return Ic(t),null;if(a=!!(t.flags&128),o=r.rendering,o===null)if(a)Fc(r,!1);else{if(ql!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=oo(e),o!==null){for(t.flags|=128,Fc(r,!1),e=o.updateQueue,t.updateQueue=e,Pc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)si(n,e),n=n.sibling;return ue(ao,ao.current&1|2),ji&&wi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&je()>iu&&(t.flags|=128,a=!0,Fc(r,!1),t.lanes=4194304)}else{if(!a)if(e=oo(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Pc(t,e),Fc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!ji)return Ic(t),null}else 2*je()-r.renderingStartTime>iu&&n!==536870912&&(t.flags|=128,a=!0,Fc(r,!1),t.lanes=4194304);r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}return r.tail===null?(Ic(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=je(),e.sibling=null,n=ao.current,ue(ao,a?n&1|2:n&1),ji&&wi(t,r.treeForkCount),e);case 22:case 23:return io(t),Za(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(Ic(t),t.subtreeFlags&6&&(t.flags|=8192)):Ic(t),n=t.updateQueue,n!==null&&Pc(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&le(pa),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Gi(na),Ic(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function Rc(e,t){switch(Di(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Gi(na),ge(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ve(t),null;case 31:if(t.memoizedState!==null){if(io(t),t.alternate===null)throw Error(i(340));zi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(io(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));zi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return le(ao),null;case 4:return ge(),null;case 10:return Gi(t.type),null;case 22:case 23:return io(t),Za(),e!==null&&le(pa),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Gi(na),null;case 25:return null;default:return null}}function zc(e,t){switch(Di(t),t.tag){case 3:Gi(na),ge();break;case 26:case 27:case 5:ve(t);break;case 4:ge();break;case 31:t.memoizedState!==null&&io(t);break;case 13:io(t);break;case 19:le(ao);break;case 10:Gi(t.type);break;case 22:case 23:io(t),Za(),e!==null&&le(pa);break;case 24:Gi(na)}}function Bc(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Ju(t,t.return,e)}}function Vc(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Ju(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Ju(t,t.return,e)}}function Hc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Ka(t,n)}catch(t){Ju(e,e.return,t)}}}function Uc(e,t,n){n.props=Ws(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Ju(e,t,n)}}function Wc(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Ju(e,t,n)}}function Gc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){Ju(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Ju(e,t,n)}else n.current=null}function Kc(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Ju(e,e.return,t)}}function qc(e,t,n){try{var r=e.stateNode;zd(r,e.type,n,t),r[ft]=t}catch(t){Ju(e,e.return,t)}}function Jc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&tf(e.type)||e.tag===4}function Yc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Jc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&tf(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Xc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=an));else if(r!==4&&(r===27&&tf(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Xc(e,t,n),e=e.sibling;e!==null;)Xc(e,t,n),e=e.sibling}function Zc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&tf(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Zc(e,t,n),e=e.sibling;e!==null;)Zc(e,t,n),e=e.sibling}function Qc(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Y(t,r,n),t[dt]=e,t[ft]=n}catch(t){Ju(e,e.return,t)}}var $c=!1,el=!1,tl=!1,nl=typeof WeakSet==`function`?WeakSet:Set,rl=null;function il(e,t){if(e=e.containerInfo,Hd=dp,e=wr(e),Tr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(Ud={focusedElem:e,selectionRange:n},dp=!1,rl=t;rl!==null;)if(t=rl,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,rl=e;else for(;rl!==null;){switch(t=rl,o=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n<e.length;n++)a=e[n],a.ref.impl=a.nextImpl;break;case 11:case 15:break;case 1:if(e&1024&&o!==null){e=void 0,n=t,a=o.memoizedProps,o=o.memoizedState,r=n.stateNode;try{var h=Ws(n.type,a);e=r.getSnapshotBeforeUpdate(h,o),r.__reactInternalSnapshotBeforeUpdate=e}catch(e){Ju(n,n.return,e)}}break;case 3:if(e&1024){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)af(e);else if(n===1)switch(e.nodeName){case`HEAD`:case`HTML`:case`BODY`:af(e);break;default:e.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(e&1024)throw Error(i(163))}if(e=t.sibling,e!==null){e.return=t.return,rl=e;break}rl=t.return}}function al(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:bl(e,n),r&4&&Bc(5,n);break;case 1:if(bl(e,n),r&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){Ju(n,n.return,e)}else{var i=Ws(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){Ju(n,n.return,e)}}r&64&&Hc(n),r&512&&Wc(n,n.return);break;case 3:if(bl(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{Ka(e,t)}catch(e){Ju(n,n.return,e)}}break;case 27:t===null&&r&4&&Qc(n);case 26:case 5:bl(e,n),t===null&&r&4&&Kc(n),r&512&&Wc(n,n.return);break;case 12:bl(e,n);break;case 31:bl(e,n),r&4&&dl(e,n);break;case 13:bl(e,n),r&4&&fl(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=Qu.bind(null,n),df(e,n))));break;case 22:if(r=n.memoizedState!==null||$c,!r){t=t!==null&&t.memoizedState!==null||el,i=$c;var a=el;$c=r,(el=t)&&!a?Sl(e,n,!!(n.subtreeFlags&8772)):bl(e,n),$c=i,el=a}break;case 30:break;default:bl(e,n)}}function ol(e){var t=e.alternate;t!==null&&(e.alternate=null,ol(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&yt(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var sl=null,cl=!1;function ll(e,t,n){for(n=n.child;n!==null;)ul(e,t,n),n=n.sibling}function ul(e,t,n){if(Be&&typeof Be.onCommitFiberUnmount==`function`)try{Be.onCommitFiberUnmount(ze,n)}catch{}switch(n.tag){case 26:el||Gc(n,t),ll(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:el||Gc(n,t);var r=sl,i=cl;tf(n.type)&&(sl=n.stateNode,cl=!1),ll(e,t,n),_f(n.stateNode),sl=r,cl=i;break;case 5:el||Gc(n,t);case 6:if(r=sl,i=cl,sl=null,ll(e,t,n),sl=r,cl=i,sl!==null)if(cl)try{(sl.nodeType===9?sl.body:sl.nodeName===`HTML`?sl.ownerDocument.body:sl).removeChild(n.stateNode)}catch(e){Ju(n,t,e)}else try{sl.removeChild(n.stateNode)}catch(e){Ju(n,t,e)}break;case 18:sl!==null&&(cl?(e=sl,nf(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Lp(e)):nf(sl,n.stateNode));break;case 4:r=sl,i=cl,sl=n.stateNode.containerInfo,cl=!0,ll(e,t,n),sl=r,cl=i;break;case 0:case 11:case 14:case 15:Vc(2,n,t),el||Vc(4,n,t),ll(e,t,n);break;case 1:el||(Gc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&Uc(n,t,r)),ll(e,t,n);break;case 21:ll(e,t,n);break;case 22:el=(r=el)||n.memoizedState!==null,ll(e,t,n),el=r;break;default:ll(e,t,n)}}function dl(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Lp(e)}catch(e){Ju(t,t.return,e)}}}function fl(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Lp(e)}catch(e){Ju(t,t.return,e)}}function pl(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new nl),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new nl),t;default:throw Error(i(435,e.tag))}}function ml(e,t){var n=pl(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=$u.bind(null,e,t);t.then(r,r)}})}function hl(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var a=n[r],o=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 27:if(tf(c.type)){sl=c.stateNode,cl=!1;break a}break;case 5:sl=c.stateNode,cl=!1;break a;case 3:case 4:sl=c.stateNode.containerInfo,cl=!0;break a}c=c.return}if(sl===null)throw Error(i(160));ul(o,s,a),sl=null,cl=!1,o=a.alternate,o!==null&&(o.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)_l(t,e),t=t.sibling}var gl=null;function _l(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:hl(t,e),vl(e),r&4&&(Vc(3,e,e.return),Bc(3,e),Vc(5,e,e.return));break;case 1:hl(t,e),vl(e),r&512&&(el||n===null||Gc(n,n.return)),r&64&&$c&&(e=e.updateQueue,e!==null&&(r=e.callbacks,r!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?r:n.concat(r))));break;case 26:var a=gl;if(hl(t,e),vl(e),r&512&&(el||n===null||Gc(n,n.return)),r&4){var o=n===null?null:n.memoizedState;if(r=e.memoizedState,n===null)if(r===null)if(e.stateNode===null){a:{r=e.type,n=e.memoizedProps,a=a.ownerDocument||a;b:switch(r){case`title`:o=a.getElementsByTagName(`title`)[0],(!o||o[vt]||o[dt]||o.namespaceURI===`http://www.w3.org/2000/svg`||o.hasAttribute(`itemprop`))&&(o=a.createElement(r),a.head.insertBefore(o,a.querySelector(`head > title`))),Y(o,r,n),o[dt]=e,wt(o),r=o;break a;case`link`:var s=Gf(`link`,`href`,a).get(r+(n.href||``));if(s){for(var c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&o.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&o.getAttribute(`title`)===(n.title==null?null:n.title)&&o.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(c,1);break b}}o=a.createElement(r),Y(o,r,n),a.head.appendChild(o);break;case`meta`:if(s=Gf(`meta`,`content`,a).get(r+(n.content||``))){for(c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`content`)===(n.content==null?null:``+n.content)&&o.getAttribute(`name`)===(n.name==null?null:n.name)&&o.getAttribute(`property`)===(n.property==null?null:n.property)&&o.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&o.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){s.splice(c,1);break b}}o=a.createElement(r),Y(o,r,n),a.head.appendChild(o);break;default:throw Error(i(468,r))}o[dt]=e,wt(o),r=o}e.stateNode=r}else Kf(a,e.type,e.stateNode);else e.stateNode=Bf(a,r,e.memoizedProps);else o===r?r===null&&e.stateNode!==null&&qc(e,e.memoizedProps,n.memoizedProps):(o===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):o.count--,r===null?Kf(a,e.type,e.stateNode):Bf(a,r,e.memoizedProps))}break;case 27:hl(t,e),vl(e),r&512&&(el||n===null||Gc(n,n.return)),n!==null&&r&4&&qc(e,e.memoizedProps,n.memoizedProps);break;case 5:if(hl(t,e),vl(e),r&512&&(el||n===null||Gc(n,n.return)),e.flags&32){a=e.stateNode;try{Xt(a,``)}catch(t){Ju(e,e.return,t)}}r&4&&e.stateNode!=null&&(a=e.memoizedProps,qc(e,a,n===null?a:n.memoizedProps)),r&1024&&(tl=!0);break;case 6:if(hl(t,e),vl(e),r&4){if(e.stateNode===null)throw Error(i(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(t){Ju(e,e.return,t)}}break;case 3:if(Wf=null,a=gl,gl=bf(t.containerInfo),hl(t,e),gl=a,vl(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Lp(t.containerInfo)}catch(t){Ju(e,e.return,t)}tl&&(tl=!1,yl(e));break;case 4:r=gl,gl=bf(e.stateNode.containerInfo),hl(t,e),vl(e),gl=r;break;case 12:hl(t,e),vl(e);break;case 31:hl(t,e),vl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,ml(e,r)));break;case 13:hl(t,e),vl(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(nu=je()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,ml(e,r)));break;case 22:a=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,u=$c,d=el;if($c=u||a,el=d||l,hl(t,e),el=d,$c=u,vl(e),r&8192)a:for(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||l||$c||el||xl(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){l=n=t;try{if(o=l.stateNode,a)s=o.style,typeof s.setProperty==`function`?s.setProperty(`display`,`none`,`important`):s.display=`none`;else{c=l.stateNode;var f=l.memoizedProps.style,p=f!=null&&f.hasOwnProperty(`display`)?f.display:null;c.style.display=p==null||typeof p==`boolean`?``:(``+p).trim()}}catch(e){Ju(l,l.return,e)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=a?``:l.memoizedProps}catch(e){Ju(l,l.return,e)}}}else if(t.tag===18){if(n===null){l=t;try{var m=l.stateNode;a?rf(m,!0):rf(l.stateNode,!1)}catch(e){Ju(l,l.return,e)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break a;for(;t.sibling===null;){if(t.return===null||t.return===e)break a;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}r&4&&(r=e.updateQueue,r!==null&&(n=r.retryQueue,n!==null&&(r.retryQueue=null,ml(e,n))));break;case 19:hl(t,e),vl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,ml(e,r)));break;case 30:break;case 21:break;default:hl(t,e),vl(e)}}function vl(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(Jc(r)){n=r;break}r=r.return}if(n==null)throw Error(i(160));switch(n.tag){case 27:var a=n.stateNode;Zc(e,Yc(e),a);break;case 5:var o=n.stateNode;n.flags&32&&(Xt(o,``),n.flags&=-33),Zc(e,Yc(e),o);break;case 3:case 4:var s=n.stateNode.containerInfo;Xc(e,Yc(e),s);break;default:throw Error(i(161))}}catch(t){Ju(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function yl(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;yl(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function bl(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)al(e,t.alternate,t),t=t.sibling}function xl(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Vc(4,t,t.return),xl(t);break;case 1:Gc(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount==`function`&&Uc(t,t.return,n),xl(t);break;case 27:_f(t.stateNode);case 26:case 5:Gc(t,t.return),xl(t);break;case 22:t.memoizedState===null&&xl(t);break;case 30:xl(t);break;default:xl(t)}e=e.sibling}}function Sl(e,t,n){for(n&&=!!(t.subtreeFlags&8772),t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags;switch(a.tag){case 0:case 11:case 15:Sl(i,a,n),Bc(4,a);break;case 1:if(Sl(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){Ju(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var s=r.stateNode;try{var c=i.shared.hiddenCallbacks;if(c!==null)for(i.shared.hiddenCallbacks=null,i=0;i<c.length;i++)Ga(c[i],s)}catch(e){Ju(r,r.return,e)}}n&&o&64&&Hc(a),Wc(a,a.return);break;case 27:Qc(a);case 26:case 5:Sl(i,a,n),n&&r===null&&o&4&&Kc(a),Wc(a,a.return);break;case 12:Sl(i,a,n);break;case 31:Sl(i,a,n),n&&o&4&&dl(i,a);break;case 13:Sl(i,a,n),n&&o&4&&fl(i,a);break;case 22:a.memoizedState===null&&Sl(i,a,n),Wc(a,a.return);break;case 30:break;default:Sl(i,a,n)}t=t.sibling}}function Cl(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&ia(n))}function wl(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&ia(e))}function Tl(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)El(e,t,n,r),t=t.sibling}function El(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:Tl(e,t,n,r),i&2048&&Bc(9,t);break;case 1:Tl(e,t,n,r);break;case 3:Tl(e,t,n,r),i&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&ia(e)));break;case 12:if(i&2048){Tl(e,t,n,r),e=t.stateNode;try{var a=t.memoizedProps,o=a.id,s=a.onPostCommit;typeof s==`function`&&s(o,t.alternate===null?`mount`:`update`,e.passiveEffectDuration,-0)}catch(e){Ju(t,t.return,e)}}else Tl(e,t,n,r);break;case 31:Tl(e,t,n,r);break;case 13:Tl(e,t,n,r);break;case 23:break;case 22:a=t.stateNode,o=t.alternate,t.memoizedState===null?a._visibility&2?Tl(e,t,n,r):(a._visibility|=2,Dl(e,t,n,r,!!(t.subtreeFlags&10256)||!1)):a._visibility&2?Tl(e,t,n,r):Ol(e,t),i&2048&&Cl(o,t);break;case 24:Tl(e,t,n,r),i&2048&&wl(t.alternate,t);break;default:Tl(e,t,n,r)}}function Dl(e,t,n,r,i){for(i&&=!!(t.subtreeFlags&10256)||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:Dl(a,o,s,c,i),Bc(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,Dl(a,o,s,c,i)):u._visibility&2?Dl(a,o,s,c,i):Ol(a,o),i&&l&2048&&Cl(o.alternate,o);break;case 24:Dl(a,o,s,c,i),i&&l&2048&&wl(o.alternate,o);break;default:Dl(a,o,s,c,i)}t=t.sibling}}function Ol(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:Ol(n,r),i&2048&&Cl(r.alternate,r);break;case 24:Ol(n,r),i&2048&&wl(r.alternate,r);break;default:Ol(n,r)}t=t.sibling}}var kl=8192;function Al(e,t,n){if(e.subtreeFlags&kl)for(e=e.child;e!==null;)jl(e,t,n),e=e.sibling}function jl(e,t,n){switch(e.tag){case 26:Al(e,t,n),e.flags&kl&&e.memoizedState!==null&&Yf(n,gl,e.memoizedState,e.memoizedProps);break;case 5:Al(e,t,n);break;case 3:case 4:var r=gl;gl=bf(e.stateNode.containerInfo),Al(e,t,n),gl=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=kl,kl=16777216,Al(e,t,n),kl=r):Al(e,t,n));break;default:Al(e,t,n)}}function Ml(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Nl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];rl=r,Il(r,e)}Ml(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Pl(e),e=e.sibling}function Pl(e){switch(e.tag){case 0:case 11:case 15:Nl(e),e.flags&2048&&Vc(9,e,e.return);break;case 3:Nl(e);break;case 12:Nl(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Fl(e)):Nl(e);break;default:Nl(e)}}function Fl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];rl=r,Il(r,e)}Ml(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Vc(8,t,t.return),Fl(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Fl(t));break;default:Fl(t)}e=e.sibling}}function Il(e,t){for(;rl!==null;){var n=rl;switch(n.tag){case 0:case 11:case 15:Vc(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:ia(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,rl=r;else a:for(n=e;rl!==null;){r=rl;var i=r.sibling,a=r.return;if(ol(r),r===n){rl=null;break a}if(i!==null){i.return=a,rl=i;break a}rl=a}}}var Ll={getCacheForType:function(e){var t=Zi(na),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Zi(na).controller.signal}},Rl=typeof WeakMap==`function`?WeakMap:Map,zl=0,Bl=null,K=null,q=0,Vl=0,Hl=null,Ul=!1,Wl=!1,Gl=!1,Kl=0,ql=0,Jl=0,Yl=0,Xl=0,Zl=0,Ql=0,$l=null,eu=null,tu=!1,nu=0,ru=0,iu=1/0,au=null,ou=null,su=0,cu=null,lu=null,uu=0,du=0,fu=null,pu=null,mu=0,hu=null;function gu(){return zl&2&&q!==0?q&-q:j.T===null?ct():hd()}function _u(){if(Zl===0)if(!(q&536870912)||ji){var e=qe;qe<<=1,!(qe&3932160)&&(qe=262144),Zl=e}else Zl=536870912;return e=Qa.current,e!==null&&(e.flags|=32),Zl}function vu(e,t,n){(e===Bl&&(Vl===2||Vl===9)||e.cancelPendingCommit!==null)&&(Tu(e,0),Su(e,q,Zl,!1)),tt(e,n),(!(zl&2)||e!==Bl)&&(e===Bl&&(!(zl&2)&&(Yl|=n),ql===4&&Su(e,q,Zl,!1)),sd(e))}function yu(e,t,n){if(zl&6)throw Error(i(327));var r=!n&&!(t&127)&&(t&e.expiredLanes)===0||Ze(e,t),a=r?Nu(e,t):ju(e,t,!0),o=r;do{if(a===0){Wl&&!r&&Su(e,t,0,!1);break}if(n=e.current.alternate,o&&!xu(n)){a=ju(e,t,!1),o=!1;continue}if(a===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;a=$l;var l=c.current.memoizedState.isDehydrated;if(l&&(Tu(c,s).flags|=256),s=ju(c,s,!1),s!==2){if(Gl&&!l){c.errorRecoveryDisabledLanes|=o,Yl|=o,a=4;break a}o=eu,eu=a,o!==null&&(eu===null?eu=o:eu.push.apply(eu,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){Tu(e,0),Su(e,t,0,!0);break}a:{switch(r=e,o=a,o){case 0:case 1:throw Error(i(345));case 4:if((t&4194048)!==t)break;case 6:Su(r,t,Zl,!Ul);break a;case 2:eu=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=nu+300-je(),10<a)){if(Su(r,t,Zl,!Ul),Xe(r,0,!0)!==0)break a;uu=t,r.timeoutHandle=Xd(bu.bind(null,r,n,eu,au,tu,t,Zl,Yl,Ql,Ul,o,`Throttled`,-0,0),a);break a}bu(r,n,eu,au,tu,t,Zl,Yl,Ql,Ul,o,null,-0,0)}break}while(1);sd(e)}function bu(e,t,n,r,i,a,o,s,c,l,u,d,f,p){if(e.timeoutHandle=-1,d=t.subtreeFlags,d&8192||(d&16785408)==16785408){d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:an},jl(t,a,d);var m=(a&62914560)===a?nu-je():(a&4194048)===a?ru-je():0;if(m=Zf(d,m),m!==null){uu=a,e.cancelPendingCommit=m(Bu.bind(null,e,t,a,n,r,i,o,s,c,u,d,null,f,p)),Su(e,a,o,!l);return}}Bu(e,t,a,n,r,i,o,s,c)}function xu(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!yr(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Su(e,t,n,r){t&=~Xl,t&=~Yl,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-He(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&rt(e,n,t)}function Cu(){return zl&6?!0:(cd(0,!1),!1)}function wu(){if(K!==null){if(Vl===0)var e=K.return;else e=K,U=Ui=null,Eo(e),Da=null,Oa=0,e=K;for(;e!==null;)zc(e.alternate,e),e=e.return;K=null}}function Tu(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,Zd(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),uu=0,wu(),Bl=e,K=n=oi(e.current,null),q=t,Vl=0,Hl=null,Ul=!1,Wl=Ze(e,t),Gl=!1,Ql=Zl=Xl=Yl=Jl=ql=0,eu=$l=null,tu=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-He(r),a=1<<i;t|=e[i],r&=~a}return Kl=t,Xr(),n}function Eu(e,t){G=null,j.H=Is,t===_a||t===ya?(t=Ta(),Vl=3):t===va?(t=Ta(),Vl=4):Vl=t===ec?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,Hl=t,K===null&&(ql=1,Js(e,mi(t,e.current)))}function Du(){var e=Qa.current;return e===null?!0:(q&4194048)===q?$a===null:(q&62914560)===q||q&536870912?e===$a:!1}function Ou(){var e=j.H;return j.H=Is,e===null?Is:e}function ku(){var e=j.A;return j.A=Ll,e}function Au(){ql=4,Ul||(q&4194048)!==q&&Qa.current!==null||(Wl=!0),!(Jl&134217727)&&!(Yl&134217727)||Bl===null||Su(Bl,q,Zl,!1)}function ju(e,t,n){var r=zl;zl|=2;var i=Ou(),a=ku();(Bl!==e||q!==t)&&(au=null,Tu(e,t)),t=!1;var o=ql;a:do try{if(Vl!==0&&K!==null){var s=K,c=Hl;switch(Vl){case 8:wu(),o=6;break a;case 3:case 2:case 9:case 6:Qa.current===null&&(t=!0);var l=Vl;if(Vl=0,Hl=null,Lu(e,s,c,l),n&&Wl){o=0;break a}break;default:l=Vl,Vl=0,Hl=null,Lu(e,s,c,l)}}Mu(),o=ql;break}catch(t){Eu(e,t)}while(1);return t&&e.shellSuspendCounter++,U=Ui=null,zl=r,j.H=i,j.A=a,K===null&&(Bl=null,q=0,Xr()),o}function Mu(){for(;K!==null;)Fu(K)}function Nu(e,t){var n=zl;zl|=2;var r=Ou(),a=ku();Bl!==e||q!==t?(au=null,iu=je()+500,Tu(e,t)):Wl=Ze(e,t);a:do try{if(Vl!==0&&K!==null){t=K;var o=Hl;b:switch(Vl){case 1:Vl=0,Hl=null,Lu(e,t,o,1);break;case 2:case 9:if(xa(o)){Vl=0,Hl=null,Iu(t);break}t=function(){Vl!==2&&Vl!==9||Bl!==e||(Vl=7),sd(e)},o.then(t,t);break a;case 3:Vl=7;break a;case 4:Vl=5;break a;case 7:xa(o)?(Vl=0,Hl=null,Iu(t)):(Vl=0,Hl=null,Lu(e,t,o,7));break;case 5:var s=null;switch(K.tag){case 26:s=K.memoizedState;case 5:case 27:var c=K;if(s?Jf(s):c.stateNode.complete){Vl=0,Hl=null;var l=c.sibling;if(l!==null)K=l;else{var u=c.return;u===null?K=null:(K=u,Ru(u))}break b}}Vl=0,Hl=null,Lu(e,t,o,5);break;case 6:Vl=0,Hl=null,Lu(e,t,o,6);break;case 8:wu(),ql=6;break a;default:throw Error(i(462))}}Pu();break}catch(t){Eu(e,t)}while(1);return U=Ui=null,j.H=r,j.A=a,zl=n,K===null?(Bl=null,q=0,Xr(),ql):0}function Pu(){for(;K!==null&&!ke();)Fu(K)}function Fu(e){var t=Ac(e.alternate,e,Kl);e.memoizedProps=e.pendingProps,t===null?Ru(e):K=t}function Iu(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=mc(n,t,t.pendingProps,t.type,void 0,q);break;case 11:t=mc(n,t,t.pendingProps,t.type.render,t.ref,q);break;case 5:Eo(t);default:zc(n,t),t=K=si(t,Kl),t=Ac(n,t,Kl)}e.memoizedProps=e.pendingProps,t===null?Ru(e):K=t}function Lu(e,t,n,r){U=Ui=null,Eo(t),Da=null,Oa=0;var i=t.return;try{if($s(e,i,t,n,q)){ql=1,Js(e,mi(n,e.current)),K=null;return}}catch(t){if(i!==null)throw K=i,t;ql=1,Js(e,mi(n,e.current)),K=null;return}t.flags&32768?(ji||r===1?e=!0:Wl||q&536870912?e=!1:(Ul=e=!0,(r===2||r===9||r===3||r===6)&&(r=Qa.current,r!==null&&r.tag===13&&(r.flags|=16384))),zu(t,e)):Ru(t)}function Ru(e){var t=e;do{if(t.flags&32768){zu(t,Ul);return}e=t.return;var n=Lc(t.alternate,t,Kl);if(n!==null){K=n;return}if(t=t.sibling,t!==null){K=t;return}K=t=e}while(t!==null);ql===0&&(ql=5)}function zu(e,t){do{var n=Rc(e.alternate,e);if(n!==null){n.flags&=32767,K=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){K=e;return}K=e=n}while(e!==null);ql=6,K=null}function Bu(e,t,n,r,a,o,s,c,l){e.cancelPendingCommit=null;do Gu();while(su!==0);if(zl&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));if(o=t.lanes|t.childLanes,o|=Yr,nt(e,n,o,s,c,l),e===Bl&&(K=Bl=null,q=0),lu=t,cu=e,uu=n,du=o,fu=a,pu=r,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,ed(Fe,function(){return Ku(),null})):(e.callbackNode=null,e.callbackPriority=0),r=!!(t.flags&13878),t.subtreeFlags&13878||r){r=j.T,j.T=null,a=M.p,M.p=2,s=zl,zl|=4;try{il(e,t,n)}finally{zl=s,M.p=a,j.T=r}}su=1,Vu(),Hu(),Uu()}}function Vu(){if(su===1){su=0;var e=cu,t=lu,n=!!(t.flags&13878);if(t.subtreeFlags&13878||n){n=j.T,j.T=null;var r=M.p;M.p=2;var i=zl;zl|=4;try{_l(t,e);var a=Ud,o=wr(e.containerInfo),s=a.focusedElem,c=a.selectionRange;if(o!==s&&s&&s.ownerDocument&&Cr(s.ownerDocument.documentElement,s)){if(c!==null&&Tr(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=Sr(s,h),v=Sr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}dp=!!Hd,Ud=Hd=null}finally{zl=i,M.p=r,j.T=n}}e.current=t,su=2}}function Hu(){if(su===2){su=0;var e=cu,t=lu,n=!!(t.flags&8772);if(t.subtreeFlags&8772||n){n=j.T,j.T=null;var r=M.p;M.p=2;var i=zl;zl|=4;try{al(e,t.alternate,t)}finally{zl=i,M.p=r,j.T=n}}su=3}}function Uu(){if(su===4||su===3){su=0,Ae();var e=cu,t=lu,n=uu,r=pu;t.subtreeFlags&10256||t.flags&10256?su=5:(su=0,lu=cu=null,Wu(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(ou=null),st(n),t=t.stateNode,Be&&typeof Be.onCommitFiberRoot==`function`)try{Be.onCommitFiberRoot(ze,t,void 0,(t.current.flags&128)==128)}catch{}if(r!==null){t=j.T,i=M.p,M.p=2,j.T=null;try{for(var a=e.onRecoverableError,o=0;o<r.length;o++){var s=r[o];a(s.value,{componentStack:s.stack})}}finally{j.T=t,M.p=i}}uu&3&&Gu(),sd(e),i=e.pendingLanes,n&261930&&i&42?e===hu?mu++:(mu=0,hu=e):mu=0,cd(0,!1)}}function Wu(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,ia(t)))}function Gu(){return Vu(),Hu(),Uu(),Ku()}function Ku(){if(su!==5)return!1;var e=cu,t=du;du=0;var n=st(uu),r=j.T,a=M.p;try{M.p=32>n?32:n,j.T=null,n=fu,fu=null;var o=cu,s=uu;if(su=0,lu=cu=null,uu=0,zl&6)throw Error(i(331));var c=zl;if(zl|=4,Pl(o.current),El(o,o.current,s,n),zl=c,cd(0,!1),Be&&typeof Be.onPostCommitFiberRoot==`function`)try{Be.onPostCommitFiberRoot(ze,o)}catch{}return!0}finally{M.p=a,j.T=r,Wu(e,t)}}function qu(e,t,n){t=mi(n,t),t=Xs(e.stateNode,t,2),e=za(e,t,2),e!==null&&(tt(e,2),sd(e))}function Ju(e,t,n){if(e.tag===3)qu(e,e,n);else for(;t!==null;){if(t.tag===3){qu(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(ou===null||!ou.has(r))){e=mi(n,e),n=Zs(2),r=za(t,n,2),r!==null&&(Qs(n,r,t,e),tt(r,2),sd(r));break}}t=t.return}}function Yu(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Rl;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(Gl=!0,i.add(n),e=Xu.bind(null,e,t,n),t.then(e,e))}function Xu(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Bl===e&&(q&n)===n&&(ql===4||ql===3&&(q&62914560)===q&&300>je()-nu?!(zl&2)&&Tu(e,0):Xl|=n,Ql===q&&(Ql=0)),sd(e)}function Zu(e,t){t===0&&(t=$e()),e=$r(e,t),e!==null&&(tt(e,t),sd(e))}function Qu(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Zu(e,n)}function $u(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),Zu(e,n)}function ed(e,t){return De(e,t)}var td=null,nd=null,rd=!1,id=!1,ad=!1,od=0;function sd(e){e!==nd&&e.next===null&&(nd===null?td=nd=e:nd=nd.next=e),id=!0,rd||(rd=!0,md())}function cd(e,t){if(!ad&&id){ad=!0;do for(var n=!1,r=td;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-He(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,pd(r,a))}else a=q,a=Xe(r,r===Bl?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||Ze(r,a)||(n=!0,pd(r,a));r=r.next}while(n);ad=!1}}function ld(){ud()}function ud(){id=rd=!1;var e=0;od!==0&&Yd()&&(e=od);for(var t=je(),n=null,r=td;r!==null;){var i=r.next,a=dd(r,t);a===0?(r.next=null,n===null?td=i:n.next=i,i===null&&(nd=n)):(n=r,(e!==0||a&3)&&(id=!0)),r=i}su!==0&&su!==5||cd(e,!1),od!==0&&(od=0)}function dd(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-He(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=Qe(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Bl,n=q,n=Xe(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Vl===2||Vl===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&Oe(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||Ze(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&Oe(r),st(n)){case 2:case 8:n=Pe;break;case 32:n=Fe;break;case 268435456:n=Le;break;default:n=Fe}return r=fd.bind(null,e),n=De(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&Oe(r),e.callbackPriority=2,e.callbackNode=null,2}function fd(e,t){if(su!==0&&su!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(Gu()&&e.callbackNode!==n)return null;var r=q;return r=Xe(e,e===Bl?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(yu(e,r,t),dd(e,je()),e.callbackNode!=null&&e.callbackNode===n?fd.bind(null,e):null)}function pd(e,t){if(Gu())return null;yu(e,t,!0)}function md(){$d(function(){zl&6?De(Ne,ld):ud()})}function hd(){if(od===0){var e=sa;e===0&&(e=Ke,Ke<<=1,!(Ke&261888)&&(Ke=256)),od=e}return od}function gd(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:rn(``+e)}function _d(e,t){var n=t.ownerDocument.createElement(`input`);return n.name=t.name,n.value=t.value,e.id&&n.setAttribute(`form`,e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function vd(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=gd((i[ft]||null).action),o=r.submitter;o&&(t=(t=o[ft]||null)?gd(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new Cn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(od!==0){var e=o?_d(i,o):new FormData(i);Ss(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=o?_d(i,o):new FormData(i),Ss(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var yd=0;yd<Gr.length;yd++){var bd=Gr[yd];Kr(bd.toLowerCase(),`on`+(bd[0].toUpperCase()+bd.slice(1)))}Kr(Lr,`onAnimationEnd`),Kr(Rr,`onAnimationIteration`),Kr(zr,`onAnimationStart`),Kr(`dblclick`,`onDoubleClick`),Kr(`focusin`,`onFocus`),Kr(`focusout`,`onBlur`),Kr(Br,`onTransitionRun`),Kr(Vr,`onTransitionStart`),Kr(Hr,`onTransitionCancel`),Kr(Ur,`onTransitionEnd`),Ot(`onMouseEnter`,[`mouseout`,`mouseover`]),Ot(`onMouseLeave`,[`mouseout`,`mouseover`]),Ot(`onPointerEnter`,[`pointerout`,`pointerover`]),Ot(`onPointerLeave`,[`pointerout`,`pointerover`]),Dt(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),Dt(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),Dt(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),Dt(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),Dt(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),Dt(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var xd=`abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting`.split(` `),Sd=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(xd));function Cd(e,t){t=!!(t&4);for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){qr(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){qr(e)}i.currentTarget=null,a=c}}}}function J(e,t){var n=t[mt];n===void 0&&(n=t[mt]=new Set);var r=e+`__bubble`;n.has(r)||(Dd(t,e,2,!1),n.add(r))}function wd(e,t,n){var r=0;t&&(r|=4),Dd(n,e,r,t)}var Td=`_reactListening`+Math.random().toString(36).slice(2);function Ed(e){if(!e[Td]){e[Td]=!0,Tt.forEach(function(t){t!==`selectionchange`&&(Sd.has(t)||wd(t,!1,e),wd(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Td]||(t[Td]=!0,wd(`selectionchange`,!1,t))}}function Dd(e,t,n,r){switch(vp(t)){case 2:var i=fp;break;case 8:i=pp;break;default:i=mp}n=i.bind(null,t,n,e),i=void 0,!F||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function Od(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var s=r.tag;if(s===3||s===4){var c=r.stateNode.containerInfo;if(c===i)break;if(s===4)for(s=r.return;s!==null;){var l=s.tag;if((l===3||l===4)&&s.stateNode.containerInfo===i)return;s=s.return}for(;c!==null;){if(s=bt(c),s===null)return;if(l=s.tag,l===5||l===6||l===26||l===27){r=a=s;continue a}c=c.parentNode}}r=r.return}fn(function(){var r=a,i=sn(n),s=[];a:{var c=Wr.get(e);if(c!==void 0){var l=Cn,u=e;switch(e){case`keypress`:if(yn(n)===0)break a;case`keydown`:case`keyup`:l=Vn;break;case`focusin`:u=`focus`,l=Mn;break;case`focusout`:u=`blur`,l=Mn;break;case`beforeblur`:case`afterblur`:l=Mn;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:l=An;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=jn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=Hn;break;case Lr:case Rr:case zr:l=Nn;break;case Ur:l=R;break;case`scroll`:case`scrollend`:l=Tn;break;case`wheel`:l=z;break;case`copy`:case`cut`:case`paste`:l=Pn;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=L;break;case`toggle`:case`beforetoggle`:l=B}var d=!!(t&4),f=!d&&(e===`scroll`||e===`scrollend`),p=d?c===null?null:c+`Capture`:c;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=pn(m,p),g!=null&&d.push(kd(m,g,h))),f)break;m=m.return}0<d.length&&(c=new l(c,u,null,n,i),s.push({event:c,listeners:d}))}}if(!(t&7)){a:{if(c=e===`mouseover`||e===`pointerover`,l=e===`mouseout`||e===`pointerout`,c&&n!==on&&(u=n.relatedTarget||n.fromElement)&&(bt(u)||u[pt]))break a;if((l||c)&&(c=i.window===i?i:(c=i.ownerDocument)?c.defaultView||c.parentWindow:window,l?(u=n.relatedTarget||n.toElement,l=r,u=u?bt(u):null,u!==null&&(f=o(u),d=u.tag,u!==f||d!==5&&d!==27&&d!==6)&&(u=null)):(l=null,u=r),l!==u)){if(d=An,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=L,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=l==null?c:St(l),h=u==null?c:St(u),c=new d(g,m+`leave`,l,n,i),c.target=f,c.relatedTarget=h,g=null,bt(i)===r&&(d=new d(p,m+`enter`,u,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,l&&u)b:{for(d=jd,p=l,m=u,h=0,g=p;g;g=d(g))h++;g=0;for(var _=m;_;_=d(_))g++;for(;0<h-g;)p=d(p),h--;for(;0<g-h;)m=d(m),g--;for(;h--;){if(p===m||m!==null&&p===m.alternate){d=p;break b}p=d(p),m=d(m)}d=null}else d=null;l!==null&&Md(s,c,l,d,!1),u!==null&&f!==null&&Md(s,f,u,d,!0)}}a:{if(c=r?St(r):window,l=c.nodeName&&c.nodeName.toLowerCase(),l===`select`||l===`input`&&c.type===`file`)var v=cr;else if(nr(c))if(lr)v=_r;else{v=hr;var y=mr}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&en(r.elementType)&&(v=cr):v=gr;if(v&&=v(e,r)){rr(s,v,n,i);break a}y&&y(e,c,r),e===`focusout`&&r&&c.type===`number`&&r.memoizedProps.value!=null&&Kt(c,`number`,c.value)}switch(y=r?St(r):window,e){case`focusin`:(nr(y)||y.contentEditable===`true`)&&(Dr=y,Or=r,kr=null);break;case`focusout`:kr=Or=Dr=null;break;case`mousedown`:Ar=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:Ar=!1,jr(s,n,i);break;case`selectionchange`:if(Er)break;case`keydown`:case`keyup`:jr(s,n,i)}var b;if(Wn)b:{switch(e){case`compositionstart`:var x=`onCompositionStart`;break b;case`compositionend`:x=`onCompositionEnd`;break b;case`compositionupdate`:x=`onCompositionUpdate`;break b}x=void 0}else Qn?Xn(e,n)&&(x=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(x=`onCompositionStart`);x&&(qn&&n.locale!==`ko`&&(Qn||x!==`onCompositionStart`?x===`onCompositionEnd`&&Qn&&(b=vn()):(hn=i,gn=`value`in hn?hn.value:hn.textContent,Qn=!0)),y=Ad(r,x),0<y.length&&(x=new Fn(x,e,null,n,i),s.push({event:x,listeners:y}),b?x.data=b:(b=Zn(n),b!==null&&(x.data=b)))),(b=Kn?$n(e,n):er(e,n))&&(x=Ad(r,`onBeforeInput`),0<x.length&&(y=new Fn(`onBeforeInput`,`beforeinput`,null,n,i),s.push({event:y,listeners:x}),y.data=b)),vd(s,e,r,n,i)}Cd(s,t)})}function kd(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Ad(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=pn(e,n),i!=null&&r.unshift(kd(e,i,a)),i=pn(e,t),i!=null&&r.push(kd(e,i,a))),e.tag===3)return r;e=e.return}return[]}function jd(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Md(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=pn(n,a),l!=null&&o.unshift(kd(n,l,c))):i||(l=pn(n,a),l!=null&&o.push(kd(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Nd=/\r\n?/g,Pd=/\u0000|\uFFFD/g;function Fd(e){return(typeof e==`string`?e:``+e).replace(Nd,`
|
|
9
|
+
`).replace(Pd,``)}function Id(e,t){return t=Fd(t),Fd(e)===t}function Ld(e,t,n,r,a,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||Xt(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&Xt(e,``+r);break;case`className`:Pt(e,`class`,r);break;case`tabIndex`:Pt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Pt(e,n,r);break;case`style`:$t(e,r,o);break;case`data`:if(t!==`object`){Pt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=rn(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}if(typeof o==`function`&&(n===`formAction`?(t!==`input`&&Ld(e,t,`name`,a.name,a,null),Ld(e,t,`formEncType`,a.formEncType,a,null),Ld(e,t,`formMethod`,a.formMethod,a,null),Ld(e,t,`formTarget`,a.formTarget,a,null)):(Ld(e,t,`encType`,a.encType,a,null),Ld(e,t,`method`,a.method,a,null),Ld(e,t,`target`,a.target,a,null))),r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=rn(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=an);break;case`onScroll`:r!=null&&J(`scroll`,e);break;case`onScrollEnd`:r!=null&&J(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=rn(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:J(`beforetoggle`,e),J(`toggle`,e),Nt(e,`popover`,r);break;case`xlinkActuate`:Ft(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:Ft(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:Ft(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:Ft(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:Ft(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:Ft(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:Ft(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:Ft(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:Ft(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:Nt(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=tn.get(n)||n,Nt(e,n,r))}}function Rd(e,t,n,r,a,o){switch(n){case`style`:$t(e,r,o);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?Xt(e,r):(typeof r==`number`||typeof r==`bigint`)&&Xt(e,``+r);break;case`onScroll`:r!=null&&J(`scroll`,e);break;case`onScrollEnd`:r!=null&&J(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=an);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!Et.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),t=n.slice(2,a?n.length-7:void 0),o=e[ft]||null,o=o==null?null:o[n],typeof o==`function`&&e.removeEventListener(t,o,a),typeof r==`function`)){typeof o!=`function`&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,a);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):Nt(e,n,r)}}}function Y(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:J(`error`,e),J(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Ld(e,t,o,s,n,null)}}a&&Ld(e,t,`srcSet`,n.srcSet,n,null),r&&Ld(e,t,`src`,n.src,n,null);return;case`input`:J(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:Ld(e,t,r,d,n,null)}}Gt(e,o,c,l,u,s,a,!1);return;case`select`:for(a in J(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:Ld(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&qt(e,!!r,n,!0):qt(e,!!r,t,!1);return;case`textarea`:for(s in J(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:Ld(e,t,s,c,n,null)}Yt(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:Ld(e,t,l,r,n,null)}return;case`dialog`:J(`beforetoggle`,e),J(`toggle`,e),J(`cancel`,e),J(`close`,e);break;case`iframe`:case`object`:J(`load`,e);break;case`video`:case`audio`:for(r=0;r<xd.length;r++)J(xd[r],e);break;case`image`:J(`error`,e),J(`load`,e);break;case`details`:J(`toggle`,e);break;case`embed`:case`source`:case`link`:J(`error`,e),J(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Ld(e,t,u,r,n,null)}return;default:if(en(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Rd(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&Ld(e,t,c,r,n,null))}function zd(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||Ld(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:o=m;break;case`name`:a=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&Ld(e,t,p,m,r,f)}}Wt(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||Ld(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:p=o;break;case`defaultValue`:c=o;break;case`multiple`:s=o;default:o!==l&&Ld(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?qt(e,!!n,n?[]:``,!1):qt(e,!!n,t,!0)):qt(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:Ld(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:p=a;break;case`defaultValue`:m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&Ld(e,t,s,a,r,o)}Jt(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:Ld(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:Ld(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&Ld(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:Ld(e,t,u,p,r,m)}return;default:if(en(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Rd(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||Rd(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&Ld(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||Ld(e,t,f,p,r,m)}function Bd(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function Vd(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&Bd(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&Bd(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var Hd=null,Ud=null;function Wd(e){return e.nodeType===9?e:e.ownerDocument}function Gd(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function Kd(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function qd(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Jd=null;function Yd(){var e=window.event;return e&&e.type===`popstate`?e!==Jd&&(Jd=e,!0):(Jd=null,!1)}var Xd=typeof setTimeout==`function`?setTimeout:void 0,Zd=typeof clearTimeout==`function`?clearTimeout:void 0,Qd=typeof Promise==`function`?Promise:void 0,$d=typeof queueMicrotask==`function`?queueMicrotask:Qd===void 0?Xd:function(e){return Qd.resolve(null).then(e).catch(ef)};function ef(e){setTimeout(function(){throw e})}function tf(e){return e===`head`}function nf(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Lp(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)_f(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,_f(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[vt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&_f(e.ownerDocument.body);n=i}while(n);Lp(t)}function rf(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8)if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++;n=r}while(n)}function af(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:af(n),yt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function of(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r)if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e;else if(!e[vt])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=ff(e.nextSibling),e===null)break}return null}function sf(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=ff(e.nextSibling),e===null))return null;return e}function cf(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=ff(e.nextSibling),e===null))return null;return e}function lf(e){return e.data===`$?`||e.data===`$~`}function uf(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function df(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function ff(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var pf=null;function mf(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return ff(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function hf(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function gf(e,t,n){switch(t=Wd(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function _f(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);yt(e)}var vf=new Map,yf=new Set;function bf(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var xf=M.d;M.d={f:Sf,r:Cf,D:Ef,C:Df,L:Of,m:kf,X:jf,S:Af,M:Mf};function Sf(){var e=xf.f(),t=Cu();return e||t}function Cf(e){var t=xt(e);t!==null&&t.tag===5&&t.type===`form`?ws(t):xf.r(e)}var wf=typeof document>`u`?null:document;function Tf(e,t,n){var r=wf;if(r&&typeof t==`string`&&t){var i=Ut(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),yf.has(i)||(yf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Y(t,`link`,e),wt(t),r.head.appendChild(t)))}}function Ef(e){xf.D(e),Tf(`dns-prefetch`,e,null)}function Df(e,t){xf.C(e,t),Tf(`preconnect`,e,t)}function Of(e,t,n){xf.L(e,t,n);var r=wf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Ut(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Ut(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Ut(n.imageSizes)+`"]`)):i+=`[href="`+Ut(e)+`"]`;var a=i;switch(t){case`style`:a=Pf(e);break;case`script`:a=Rf(e)}vf.has(a)||(e=f({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),vf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Ff(a))||t===`script`&&r.querySelector(zf(a))||(t=r.createElement(`link`),Y(t,`link`,e),wt(t),r.head.appendChild(t)))}}function kf(e,t){xf.m(e,t);var n=wf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Ut(r)+`"][href="`+Ut(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Rf(e)}if(!vf.has(a)&&(e=f({rel:`modulepreload`,href:e},t),vf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(zf(a)))return}r=n.createElement(`link`),Y(r,`link`,e),wt(r),n.head.appendChild(r)}}}function Af(e,t,n){xf.S(e,t,n);var r=wf;if(r&&e){var i=Ct(r).hoistableStyles,a=Pf(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Ff(a)))s.loading=5;else{e=f({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=vf.get(a))&&Hf(e,n);var c=o=r.createElement(`link`);wt(c),Y(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Vf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function jf(e,t){xf.X(e,t);var n=wf;if(n&&e){var r=Ct(n).hoistableScripts,i=Rf(e),a=r.get(i);a||(a=n.querySelector(zf(i)),a||(e=f({src:e,async:!0},t),(t=vf.get(i))&&Uf(e,t),a=n.createElement(`script`),wt(a),Y(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Mf(e,t){xf.M(e,t);var n=wf;if(n&&e){var r=Ct(n).hoistableScripts,i=Rf(e),a=r.get(i);a||(a=n.querySelector(zf(i)),a||(e=f({src:e,async:!0,type:`module`},t),(t=vf.get(i))&&Uf(e,t),a=n.createElement(`script`),wt(a),Y(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Nf(e,t,n,r){var a=(a=pe.current)?bf(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Pf(n.href),n=Ct(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Pf(n.href);var o=Ct(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Ff(e)))&&!o._p&&(s.instance=o,s.state.loading=5),vf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},vf.set(e,n),o||Lf(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Rf(n),n=Ct(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Pf(e){return`href="`+Ut(e)+`"`}function Ff(e){return`link[rel="stylesheet"][`+e+`]`}function If(e){return f({},e,{"data-precedence":e.precedence,precedence:null})}function Lf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Y(t,`link`,n),wt(t),e.head.appendChild(t))}function Rf(e){return`[src="`+Ut(e)+`"]`}function zf(e){return`script[async]`+e}function Bf(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Ut(n.href)+`"]`);if(r)return t.instance=r,wt(r),r;var a=f({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),wt(r),Y(r,`style`,a),Vf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Pf(n.href);var o=e.querySelector(Ff(a));if(o)return t.state.loading|=4,t.instance=o,wt(o),o;r=If(n),(a=vf.get(a))&&Hf(r,a),o=(e.ownerDocument||e).createElement(`link`),wt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Y(o,`link`,r),t.state.loading|=4,Vf(o,n.precedence,e),t.instance=o;case`script`:return o=Rf(n.src),(a=e.querySelector(zf(o)))?(t.instance=a,wt(a),a):(r=n,(a=vf.get(o))&&(r=f({},n),Uf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),wt(a),Y(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Vf(r,n.precedence,e));return t.instance}function Vf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Hf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Uf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Wf=null;function Gf(e,t,n){if(Wf===null){var r=new Map,i=Wf=new Map;i.set(n,r)}else i=Wf,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[vt]||a[dt]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Kf(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function qf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Jf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Yf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Pf(r.href),a=t.querySelector(Ff(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Qf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,wt(a);return}a=t.ownerDocument||t,r=If(r),(i=vf.get(i))&&Hf(r,i),a=a.createElement(`link`),wt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Y(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=Qf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Xf=0;function Zf(e,t){return e.stylesheets&&e.count===0&&ep(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&ep(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&Xf===0&&(Xf=62500*Vd());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&ep(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>Xf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Qf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ep(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var $f=null;function ep(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,$f=new Map,t.forEach(tp,e),$f=null,Qf.call(e))}function tp(e,t){if(!(t.state.loading&4)){var n=$f.get(e);if(n)var r=n.get(null);else{n=new Map,$f.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=Qf.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var np={$$typeof:C,Provider:null,Consumer:null,_currentValue:ae,_currentValue2:ae,_threadCount:0};function rp(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=et(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=et(0),this.hiddenUpdates=et(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function ip(e,t,n,r,i,a,o,s,c,l,u,d){return e=new rp(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=ii(3,null,null,t),e.current=a,a.stateNode=e,t=ra(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},Ia(a),e}function ap(e){return e?(e=ni,e):ni}function op(e,t,n,r,i,a){i=ap(i),r.context===null?r.context=i:r.pendingContext=i,r=Ra(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=za(e,r,t),n!==null&&(vu(n,e,t),Ba(n,e,t))}function sp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function cp(e,t){sp(e,t),(e=e.alternate)&&sp(e,t)}function lp(e){if(e.tag===13||e.tag===31){var t=$r(e,67108864);t!==null&&vu(t,e,67108864),cp(e,67108864)}}function up(e){if(e.tag===13||e.tag===31){var t=gu();t=ot(t);var n=$r(e,t);n!==null&&vu(n,e,t),cp(e,t)}}var dp=!0;function fp(e,t,n,r){var i=j.T;j.T=null;var a=M.p;try{M.p=2,mp(e,t,n,r)}finally{M.p=a,j.T=i}}function pp(e,t,n,r){var i=j.T;j.T=null;var a=M.p;try{M.p=8,mp(e,t,n,r)}finally{M.p=a,j.T=i}}function mp(e,t,n,r){if(dp){var i=hp(r);if(i===null)Od(e,t,r,gp,n),Dp(e,r);else if(kp(i,e,t,n,r))r.stopPropagation();else if(Dp(e,r),t&4&&-1<Ep.indexOf(e)){for(;i!==null;){var a=xt(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=Ye(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-He(o);s.entanglements[1]|=c,o&=~c}sd(a),!(zl&6)&&(iu=je()+500,cd(0,!1))}}break;case 31:case 13:s=$r(a,2),s!==null&&vu(s,a,2),Cu(),cp(a,2)}if(a=hp(r),a===null&&Od(e,t,r,gp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Od(e,t,r,null,n)}}function hp(e){return e=sn(e),_p(e)}var gp=null;function _p(e){if(gp=null,e=bt(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return gp=e,null}function vp(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`resize`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(Me()){case Ne:return 2;case Pe:return 8;case Fe:case Ie:return 32;case Le:return 268435456;default:return 32}default:return 32}}var yp=!1,bp=null,xp=null,Sp=null,Cp=new Map,wp=new Map,Tp=[],Ep=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Dp(e,t){switch(e){case`focusin`:case`focusout`:bp=null;break;case`dragenter`:case`dragleave`:xp=null;break;case`mouseover`:case`mouseout`:Sp=null;break;case`pointerover`:case`pointerout`:Cp.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:wp.delete(t.pointerId)}}function Op(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=xt(t),t!==null&&lp(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function kp(e,t,n,r,i){switch(t){case`focusin`:return bp=Op(bp,e,t,n,r,i),!0;case`dragenter`:return xp=Op(xp,e,t,n,r,i),!0;case`mouseover`:return Sp=Op(Sp,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return Cp.set(a,Op(Cp.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,wp.set(a,Op(wp.get(a)||null,e,t,n,r,i)),!0}return!1}function Ap(e){var t=bt(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,lt(e.priority,function(){up(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,lt(e.priority,function(){up(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function jp(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=hp(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);on=r,n.target.dispatchEvent(r),on=null}else return t=xt(n),t!==null&&lp(t),e.blockedOn=n,!1;t.shift()}return!0}function Mp(e,t,n){jp(e)&&n.delete(t)}function Np(){yp=!1,bp!==null&&jp(bp)&&(bp=null),xp!==null&&jp(xp)&&(xp=null),Sp!==null&&jp(Sp)&&(Sp=null),Cp.forEach(Mp),wp.forEach(Mp)}function Pp(e,n){e.blockedOn===n&&(e.blockedOn=null,yp||(yp=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Np)))}var Fp=null;function Ip(e){Fp!==e&&(Fp=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Fp===e&&(Fp=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(_p(r||n)===null)continue;break}var a=xt(n);a!==null&&(e.splice(t,3),t-=3,Ss(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Lp(e){function t(t){return Pp(t,e)}bp!==null&&Pp(bp,e),xp!==null&&Pp(xp,e),Sp!==null&&Pp(Sp,e),Cp.forEach(t),wp.forEach(t);for(var n=0;n<Tp.length;n++){var r=Tp[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Tp.length&&(n=Tp[0],n.blockedOn===null);)Ap(n),n.blockedOn===null&&Tp.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[ft]||null;if(typeof a==`function`)o||Ip(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[ft]||null)s=o.formAction;else if(_p(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Ip(n)}}}function Rp(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function zp(e){this._internalRoot=e}Bp.prototype.render=zp.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;op(n,gu(),e,t,null,null)},Bp.prototype.unmount=zp.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;op(e.current,2,null,e,null,null),Cu(),t[pt]=null}};function Bp(e){this._internalRoot=e}Bp.prototype.unstable_scheduleHydration=function(e){if(e){var t=ct();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Tp.length&&t!==0&&t<Tp[n].priority;n++);Tp.splice(n,0,e),n===0&&Ap(e)}};var Vp=n.version;if(Vp!==`19.2.8`)throw Error(i(527,Vp,`19.2.8`));M.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=u(t),e=e===null?null:d(e),e=e===null?null:e.stateNode,e};var Hp={bundleType:0,version:`19.2.8`,rendererPackageName:`react-dom`,currentDispatcherRef:j,reconcilerVersion:`19.2.8`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Up=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Up.isDisabled&&Up.supportsFiber)try{ze=Up.inject(Hp),Be=Up}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=Gs,s=Ks,c=qs;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=ip(e,1,!1,null,null,n,r,null,o,s,c,Rp),e[pt]=t.current,Ed(e),new zp(t)}})),S=t(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=x()})),C={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},w={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},T=`attached`,E=`detached`,D=1e3,O=1001,ee=1002,k=1003,te=1004,ne=1004,re=1005,ie=1005,A=1006,j=1007,M=1007,ae=1008,oe=1008,se=1009,ce=1010,le=1011,ue=1012,de=1013,fe=1014,pe=1015,me=1016,he=1017,ge=1018,_e=1020,ve=35902,ye=35899,be=1021,xe=1022,Se=1023,Ce=1026,we=1027,Te=1028,Ee=1029,De=1030,Oe=1031,ke=1032,Ae=1033,je=33776,Me=33777,Ne=33778,Pe=33779,Fe=35840,Ie=35841,Le=35842,N=35843,Re=36196,ze=37492,Be=37496,Ve=37488,He=37489,Ue=37490,We=37491,Ge=37808,Ke=37809,qe=37810,Je=37811,Ye=37812,Xe=37813,Ze=37814,Qe=37815,$e=37816,et=37817,tt=37818,nt=37819,rt=37820,it=37821,at=36492,ot=36494,st=36495,ct=36283,lt=36284,ut=36285,dt=36286,ft=2200,pt=2201,mt=2202,ht=2300,gt=2301,_t=2302,vt=2303,yt=2400,bt=2401,xt=2402,St=2500,Ct=2501,wt=3200,Tt=3201,Et=3202,Dt=3203,Ot=`srgb`,kt=`srgb-linear`,At=`linear`,jt=`srgb`,Mt=7680,Nt=7681,Pt=7682,Ft=7683,It=34055,Lt=34056,Rt=5386,zt=35044,Bt=35048,Vt=35040,Ht=35045,Ut=35049,Wt=35041,Gt=35046,Kt=35050,qt=35042,Jt=`300 es`,Yt=2e3,Xt=2001,Zt={COMPUTE:`compute`,RENDER:`render`},Qt={PERSPECTIVE:`perspective`,LINEAR:`linear`,FLAT:`flat`},$t={NORMAL:`normal`,CENTROID:`centroid`,SAMPLE:`sample`,FIRST:`first`,EITHER:`either`},en={TEXTURE_COMPARE:`depthTextureCompare`};function tn(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}var nn={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function rn(e,t){return new nn[e](t)}function an(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function on(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}function sn(){let e=on(`canvas`);return e.style.display=`block`,e}var cn={},ln=null;function un(e){ln=e}function dn(){return ln}function fn(...e){let t=`THREE.`+e.shift();ln?ln(`log`,t,...e):console.log(t,...e)}function pn(e){let t=e[0];if(typeof t==`string`&&t.startsWith(`TSL:`)){let t=e[1];t&&t.isStackTrace?e[0]+=` `+t.getLocation():e[1]=`Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.`}return e}function P(...e){e=pn(e);let t=`THREE.`+e.shift();if(ln)ln(`warn`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.warn(n.getError(t)):console.warn(t,...e)}}function F(...e){e=pn(e);let t=`THREE.`+e.shift();if(ln)ln(`error`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.error(n.getError(t)):console.error(t,...e)}}function mn(...e){let t=e.join(` `);t in cn||(cn[t]=!0,P(...e))}function hn(e,t,n){return new Promise(function(r,i){function a(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:i();break;case e.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:r()}}setTimeout(a,n)})}var gn={0:1,2:6,4:7,3:5,1:0,6:2,7:4,5:3},_n=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n!==void 0&&n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n<r;n++)t[n].call(this,e);e.target=null}}},vn=`00.01.02.03.04.05.06.07.08.09.0a.0b.0c.0d.0e.0f.10.11.12.13.14.15.16.17.18.19.1a.1b.1c.1d.1e.1f.20.21.22.23.24.25.26.27.28.29.2a.2b.2c.2d.2e.2f.30.31.32.33.34.35.36.37.38.39.3a.3b.3c.3d.3e.3f.40.41.42.43.44.45.46.47.48.49.4a.4b.4c.4d.4e.4f.50.51.52.53.54.55.56.57.58.59.5a.5b.5c.5d.5e.5f.60.61.62.63.64.65.66.67.68.69.6a.6b.6c.6d.6e.6f.70.71.72.73.74.75.76.77.78.79.7a.7b.7c.7d.7e.7f.80.81.82.83.84.85.86.87.88.89.8a.8b.8c.8d.8e.8f.90.91.92.93.94.95.96.97.98.99.9a.9b.9c.9d.9e.9f.a0.a1.a2.a3.a4.a5.a6.a7.a8.a9.aa.ab.ac.ad.ae.af.b0.b1.b2.b3.b4.b5.b6.b7.b8.b9.ba.bb.bc.bd.be.bf.c0.c1.c2.c3.c4.c5.c6.c7.c8.c9.ca.cb.cc.cd.ce.cf.d0.d1.d2.d3.d4.d5.d6.d7.d8.d9.da.db.dc.dd.de.df.e0.e1.e2.e3.e4.e5.e6.e7.e8.e9.ea.eb.ec.ed.ee.ef.f0.f1.f2.f3.f4.f5.f6.f7.f8.f9.fa.fb.fc.fd.fe.ff`.split(`.`),yn=1234567,bn=Math.PI/180,xn=180/Math.PI;function Sn(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(vn[e&255]+vn[e>>8&255]+vn[e>>16&255]+vn[e>>24&255]+`-`+vn[t&255]+vn[t>>8&255]+`-`+vn[t>>16&15|64]+vn[t>>24&255]+`-`+vn[n&63|128]+vn[n>>8&255]+`-`+vn[n>>16&255]+vn[n>>24&255]+vn[r&255]+vn[r>>8&255]+vn[r>>16&255]+vn[r>>24&255]).toLowerCase()}function I(e,t,n){return Math.max(t,Math.min(n,e))}function Cn(e,t){return(e%t+t)%t}function wn(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function Tn(e,t,n){return e===t?0:(n-e)/(t-e)}function En(e,t,n){return(1-n)*e+n*t}function Dn(e,t,n,r){return En(e,t,1-Math.exp(-n*r))}function On(e,t=1){return t-Math.abs(Cn(e,t*2)-t)}function kn(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function An(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function jn(e,t){return e+Math.floor(Math.random()*(t-e+1))}function Mn(e,t){return e+Math.random()*(t-e)}function Nn(e){return e*(.5-Math.random())}function Pn(e){e!==void 0&&(yn=e);let t=yn+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Fn(e){return e*bn}function In(e){return e*xn}function Ln(e){return!(e&e-1)&&e!==0}function Rn(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function zn(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function Bn(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:P(`MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function Vn(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`THREE.MathUtils: Invalid component type.`)}}function L(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`THREE.MathUtils: Invalid component type.`)}}var Hn={DEG2RAD:bn,RAD2DEG:xn,generateUUID:Sn,clamp:I,euclideanModulo:Cn,mapLinear:wn,inverseLerp:Tn,lerp:En,damp:Dn,pingpong:On,smoothstep:kn,smootherstep:An,randInt:jn,randFloat:Mn,randFloatSpread:Nn,seededRandom:Pn,degToRad:Fn,radToDeg:In,isPowerOfTwo:Ln,ceilPowerOfTwo:Rn,floorPowerOfTwo:zn,setQuaternionFromProperEuler:Bn,normalize:L,denormalize:Vn},R=class e{static{e.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error(`THREE.Vector2: index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`THREE.Vector2: index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=I(this.x,e.x,t.x),this.y=I(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=I(this.x,e,t),this.y=I(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(I(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(I(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},z=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(u!==m||s!==d||c!==f||l!==p){let e=s*d+c*f+l*p+u*m;e<0&&(d=-d,f=-f,p=-p,m=-m,e=-e);let t=1-o;if(e<.9995){let n=Math.acos(e),r=Math.sin(n);t=Math.sin(t*n)/r,o=Math.sin(o*n)/r,s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o}else{s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o;let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:P(`Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(I(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,r=-r,i=-i,a=-a,o=-o);let s=1-t;if(o<.9995){let e=Math.acos(o),c=Math.sin(e);s=Math.sin(s*e)/c,t=Math.sin(t*e)/c,this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this._onChangeCallback()}else this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},B=class e{static{e.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error(`THREE.Vector3: index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`THREE.Vector3: index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Wn.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Wn.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=I(this.x,e.x,t.x),this.y=I(this.y,e.y,t.y),this.z=I(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=I(this.x,e,t),this.y=I(this.y,e,t),this.z=I(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(I(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Un.copy(this).projectOnVector(e),this.sub(Un)}reflect(e){return this.sub(Un.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(I(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Un=new B,Wn=new z,Gn=class e{static{e.prototype.isMatrix3=!0}constructor(e,t,n,r,i,a,o,s,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,i,a,o,s,c)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return mn(`Matrix3: .scale() is deprecated. Use .makeScale() instead.`),this.premultiply(Kn.makeScale(e,t)),this}rotate(e){return mn(`Matrix3: .rotate() is deprecated. Use .makeRotation() instead.`),this.premultiply(Kn.makeRotation(-e)),this}translate(e,t){return mn(`Matrix3: .translate() is deprecated. Use .makeTranslation() instead.`),this.premultiply(Kn.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},Kn=new Gn,qn=new Gn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Jn=new Gn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Yn(){let e={enabled:!0,workingColorSpace:kt,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===`srgb`&&(e.r=Zn(e.r),e.g=Zn(e.g),e.b=Zn(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===`srgb`&&(e.r=Qn(e.r),e.g=Qn(e.g),e.b=Qn(e.b)),e)},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===``?At:this.spaces[e].transfer},getToneMappingMode:function(e){return this.spaces[e].outputColorSpaceConfig.toneMappingMode||`standard`},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return mn(`ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return mn(`ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[kt]:{primaries:t,whitePoint:r,transfer:At,toXYZ:qn,fromXYZ:Jn,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Ot},outputColorSpaceConfig:{drawingBufferColorSpace:Ot}},[Ot]:{primaries:t,whitePoint:r,transfer:jt,toXYZ:qn,fromXYZ:Jn,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Ot}}}),e}var Xn=Yn();function Zn(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function Qn(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}var $n,er=class{static getDataURL(e,t=`image/png`){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>`u`)return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{$n===void 0&&($n=on(`canvas`)),$n.width=e.width,$n.height=e.height;let t=$n.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=$n}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let t=on(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e<i.length;e++)i[e]=Zn(i[e]/255)*255;return n.putImageData(r,0,0),t}if(e.data){let t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(Zn(t[e]/255)*255):t[e]=Zn(t[e]);return{data:t,width:e.width,height:e.height}}return P(`ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.`),e}},tr=0,nr=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:tr++}),this.uuid=Sn(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return typeof HTMLVideoElement<`u`&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<`u`&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t===null?e.set(0,0,0):e.set(t.width,t.height,t.depth||0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:``},r=this.data;if(r!==null){let e;if(Array.isArray(r)){e=[];for(let t=0,n=r.length;t<n;t++)r[t].isDataTexture?e.push(rr(r[t].image)):e.push(rr(r[t]))}else e=rr(r);n.url=e}return t||(e.images[this.uuid]=n),n}};function rr(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap?er.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(P(`Texture: Unable to serialize Texture.`),{})}var ir=0,ar=new B,or=class e extends _n{constructor(t=e.DEFAULT_IMAGE,n=e.DEFAULT_MAPPING,r=O,i=O,a=A,o=ae,s=Se,c=se,l=e.DEFAULT_ANISOTROPY,u=``){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:ir++}),this.uuid=Sn(),this.name=``,this.source=new nr(t),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=c,this.offset=new R(0,0),this.repeat=new R(1,1),this.center=new R(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Gn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(ar).x}get height(){return this.source.getSize(ar).y}get depth(){return this.source.getSize(ar).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){P(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){P(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:`Texture`,generator:`Texture.toJSON`},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:`dispose`})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case D:e.x-=Math.floor(e.x);break;case O:e.x=e.x<0?0:1;break;case ee:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case D:e.y-=Math.floor(e.y);break;case O:e.y=e.y<0?0:1;break;case ee:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y-=Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};or.DEFAULT_IMAGE=null,or.DEFAULT_MAPPING=300,or.DEFAULT_ANISOTROPY=1;var sr=class e{static{e.prototype.isVector4=!0}constructor(e=0,t=0,n=0,r=1){this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error(`THREE.Vector4: index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error(`THREE.Vector4: index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)<a&&Math.abs(u-m)<a&&Math.abs(p-h)<a){if(Math.abs(l+d)<o&&Math.abs(u+m)<o&&Math.abs(p+h)<o&&Math.abs(c+f+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;let e=(c+1)/2,s=(f+1)/2,_=(g+1)/2,v=(l+d)/4,y=(u+m)/4,b=(p+h)/4;return e>s&&e>_?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=v/n,i=y/n):s>_?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=b/r):_<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(_),n=y/i,r=b/i),this.set(n,r,i,t),this}let _=Math.sqrt((h-p)*(h-p)+(u-m)*(u-m)+(d-l)*(d-l));return Math.abs(_)<.001&&(_=1),this.x=(h-p)/_,this.y=(u-m)/_,this.z=(d-l)/_,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=I(this.x,e.x,t.x),this.y=I(this.y,e.y,t.y),this.z=I(this.z,e.z,t.z),this.w=I(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=I(this.x,e,t),this.y=I(this.y,e,t),this.z=I(this.z,e,t),this.w=I(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(I(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},cr=class extends _n{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:A,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new sr(0,0,e,t),this.scissorTest=!1,this.viewport=new sr(0,0,e,t),this.textures=[];let r=new or({width:e,height:t,depth:n.depth}),i=n.count;for(let e=0;e<i;e++)this.textures[e]=r.clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:A,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let e=0;e<this.textures.length;e++)this.textures[e].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,i=this.textures.length;r<i;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let n=Object.assign({},e.textures[t].image);this.textures[t].source=new nr(n)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:`dispose`})}},lr=class extends cr{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},ur=class extends or{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=k,this.minFilter=k,this.wrapR=O,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},dr=class extends lr{constructor(e=1,t=1,n=1,r={}){super(e,t,r),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new ur(null,e,t,n),this._setTextureOptions(r),this.texture.isRenderTargetTexture=!0}},fr=class extends or{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=k,this.minFilter=k,this.wrapR=O,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},pr=class extends lr{constructor(e=1,t=1,n=1,r={}){super(e,t,r),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new fr(null,e,t,n),this._setTextureOptions(r),this.texture.isRenderTargetTexture=!0}},V=class e{static{e.prototype.isMatrix4=!0}constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();let t=this.elements,n=e.elements,r=1/mr.setFromMatrixColumn(e,0).length(),i=1/mr.setFromMatrixColumn(e,1).length(),a=1/mr.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(gr,e,_r)}lookAt(e,t,n){let r=this.elements;return br.subVectors(e,t),br.lengthSq()===0&&(br.z=1),br.normalize(),vr.crossVectors(n,br),vr.lengthSq()===0&&(Math.abs(n.z)===1?br.x+=1e-4:br.z+=1e-4,br.normalize(),vr.crossVectors(n,br)),vr.normalize(),yr.crossVectors(br,vr),r[0]=vr.x,r[4]=yr.x,r[8]=br.x,r[1]=vr.y,r[5]=yr.y,r[9]=br.y,r[2]=vr.z,r[6]=yr.z,r[10]=br.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],C=r[8],w=r[12],T=r[1],E=r[5],D=r[9],O=r[13],ee=r[2],k=r[6],te=r[10],ne=r[14],re=r[3],ie=r[7],A=r[11],j=r[15];return i[0]=a*x+o*T+s*ee+c*re,i[4]=a*S+o*E+s*k+c*ie,i[8]=a*C+o*D+s*te+c*A,i[12]=a*w+o*O+s*ne+c*j,i[1]=l*x+u*T+d*ee+f*re,i[5]=l*S+u*E+d*k+f*ie,i[9]=l*C+u*D+d*te+f*A,i[13]=l*w+u*O+d*ne+f*j,i[2]=p*x+m*T+h*ee+g*re,i[6]=p*S+m*E+h*k+g*ie,i[10]=p*C+m*D+h*te+g*A,i[14]=p*w+m*O+h*ne+g*j,i[3]=_*x+v*T+y*ee+b*re,i[7]=_*S+v*E+y*k+b*ie,i[11]=_*C+v*D+y*te+b*A,i[15]=_*w+v*O+y*ne+b*j,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15],_=s*f-c*d,v=o*f-c*u,y=o*d-s*u,b=a*f-c*l,x=a*d-s*l,S=a*u-o*l;return t*(m*_-h*v+g*y)-n*(p*_-h*b+g*x)+r*(p*v-m*b+g*S)-i*(p*y-m*x+h*S)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[1],a=e[5],o=e[9],s=e[2],c=e[6],l=e[10];return t*(a*l-o*c)-n*(i*l-o*s)+r*(i*c-a*s)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=t*o-n*a,v=t*s-r*a,y=t*c-i*a,b=n*s-r*o,x=n*c-i*o,S=r*c-i*s,C=l*m-u*p,w=l*h-d*p,T=l*g-f*p,E=u*h-d*m,D=u*g-f*m,O=d*g-f*h,ee=_*O-v*D+y*E+b*T-x*w+S*C;if(ee===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let k=1/ee;return e[0]=(o*O-s*D+c*E)*k,e[1]=(r*D-n*O-i*E)*k,e[2]=(m*S-h*x+g*b)*k,e[3]=(d*x-u*S-f*b)*k,e[4]=(s*T-a*O-c*w)*k,e[5]=(t*O-r*T+i*w)*k,e[6]=(h*y-p*S-g*v)*k,e[7]=(l*S-d*y+f*v)*k,e[8]=(a*D-o*T+c*C)*k,e[9]=(n*T-t*D-i*C)*k,e[10]=(p*x-m*y+g*_)*k,e[11]=(u*y-l*x-f*_)*k,e[12]=(o*w-a*E-s*C)*k,e[13]=(t*E-n*w+r*C)*k,e[14]=(m*v-p*b-h*_)*k,e[15]=(l*b-u*v+d*_)*k,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];let i=this.determinantAffine();if(i===0)return n.set(1,1,1),t.identity(),this;let a=mr.set(r[0],r[1],r[2]).length(),o=mr.set(r[4],r[5],r[6]).length(),s=mr.set(r[8],r[9],r[10]).length();i<0&&(a=-a),hr.copy(this);let c=1/a,l=1/o,u=1/s;return hr.elements[0]*=c,hr.elements[1]*=c,hr.elements[2]*=c,hr.elements[4]*=l,hr.elements[5]*=l,hr.elements[6]*=l,hr.elements[8]*=u,hr.elements[9]*=u,hr.elements[10]*=u,t.setFromRotationMatrix(hr),n.x=a,n.y=o,n.z=s,this}makePerspective(e,t,n,r,i,a,o=Yt,s=!1){let c=this.elements,l=2*i/(t-e),u=2*i/(n-r),d=(t+e)/(t-e),f=(n+r)/(n-r),p,m;if(s)p=i/(a-i),m=a*i/(a-i);else if(o===2e3)p=-(a+i)/(a-i),m=-2*a*i/(a-i);else if(o===2001)p=-a/(a-i),m=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=Yt,s=!1){let c=this.elements,l=2/(t-e),u=2/(n-r),d=-(t+e)/(t-e),f=-(n+r)/(n-r),p,m;if(s)p=1/(a-i),m=a/(a-i);else if(o===2e3)p=-2/(a-i),m=-(a+i)/(a-i);else if(o===2001)p=-1/(a-i),m=-i/(a-i);else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},mr=new B,hr=new V,gr=new B(0,0,0),_r=new B(1,1,1),vr=new B,yr=new B,br=new B,xr=new V,Sr=new z,Cr=class e{constructor(t=0,n=0,r=0,i=e.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let r=e.elements,i=r[0],a=r[4],o=r[8],s=r[1],c=r[5],l=r[9],u=r[2],d=r[6],f=r[10];switch(t){case`XYZ`:this._y=Math.asin(I(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,f),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(d,c),this._z=0);break;case`YXZ`:this._x=Math.asin(-I(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(s,c)):(this._y=Math.atan2(-u,i),this._z=0);break;case`ZXY`:this._x=Math.asin(I(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(s,i));break;case`ZYX`:this._y=Math.asin(-I(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,c));break;case`YZX`:this._z=Math.asin(I(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(o,f));break;case`XZY`:this._z=Math.asin(-I(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-l,f),this._y=0);break;default:P(`Euler: .setFromRotationMatrix() encountered an unknown order: `+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return xr.makeRotationFromQuaternion(e),this.setFromRotationMatrix(xr,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Sr.setFromEuler(this),this.setFromQuaternion(Sr,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Cr.DEFAULT_ORDER=`XYZ`;var wr=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return!!(this.mask&(1<<e|0))}},Tr=0,Er=new B,Dr=new z,Or=new V,kr=new B,Ar=new B,jr=new B,Mr=new z,Nr=new B(1,0,0),Pr=new B(0,1,0),Fr=new B(0,0,1),Ir={type:`added`},Lr={type:`removed`},Rr={type:`childadded`,child:null},zr={type:`childremoved`,child:null},Br=class e extends _n{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Tr++}),this.uuid=Sn(),this.name=``,this.type=`Object3D`,this.parent=null,this.children=[],this.up=e.DEFAULT_UP.clone();let t=new B,n=new Cr,r=new z,i=new B(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new V},normalMatrix:{value:new Gn}}),this.matrix=new V,this.matrixWorld=new V,this.matrixAutoUpdate=e.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=e.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new wr,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Dr.setFromAxisAngle(e,t),this.quaternion.multiply(Dr),this}rotateOnWorldAxis(e,t){return Dr.setFromAxisAngle(e,t),this.quaternion.premultiply(Dr),this}rotateX(e){return this.rotateOnAxis(Nr,e)}rotateY(e){return this.rotateOnAxis(Pr,e)}rotateZ(e){return this.rotateOnAxis(Fr,e)}translateOnAxis(e,t){return Er.copy(e).applyQuaternion(this.quaternion),this.position.add(Er.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Nr,e)}translateY(e){return this.translateOnAxis(Pr,e)}translateZ(e){return this.translateOnAxis(Fr,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Or.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?kr.copy(e):kr.set(e,t,n);let r=this.parent;this.updateWorldMatrix(!0,!1),Ar.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Or.lookAt(Ar,kr,this.up):Or.lookAt(kr,Ar,this.up),this.quaternion.setFromRotationMatrix(Or),r&&(Or.extractRotation(r.matrixWorld),Dr.setFromRotationMatrix(Or),this.quaternion.premultiply(Dr.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(F(`Object3D.add: object can't be added as a child of itself.`,e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Ir),Rr.child=e,this.dispatchEvent(Rr),Rr.child=null):F(`Object3D.add: object not an instance of THREE.Object3D.`,e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Lr),zr.child=e,this.dispatchEvent(zr),zr.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Or.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Or.multiply(e.parent.matrixWorld)),e.applyMatrix4(Or),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Ir),Rr.child=e,this.dispatchEvent(Rr),Rr.child=null,this}getObjectById(e){return this.getObjectByProperty(`id`,e)}getObjectByName(e){return this.getObjectByProperty(`name`,e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){let r=this.children[n].getObjectByProperty(e,t);if(r!==void 0)return r}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let r=this.children;for(let i=0,a=r.length;i<a;i++)r[i].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ar,e,jr),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ar,Mr,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let t=e.x,n=e.y,r=e.z,i=this.matrix.elements;i[12]+=t-i[0]*t-i[4]*n-i[8]*r,i[13]+=n-i[1]*t-i[5]*n-i[9]*r,i[14]+=r-i[2]*t-i[6]*n-i[10]*r}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0),t===!0){let e=this.children;for(let t=0,r=e.length;t<r;t++)e[t].updateWorldMatrix(!1,!0,n)}}toJSON(e){let t=e===void 0||typeof e==`string`,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:`Object`,generator:`Object3D.toJSON`});let r={};r.uuid=this.uuid,r.type=this.type,this.name!==``&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),this.static!==!1&&(r.static=this.static),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type=`InstancedMesh`,r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type=`BatchedMesh`,r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(e=>({...e})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t<r;t++){let r=n[t];i(e.shapes,r)}else i(e.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let t=[];for(let n=0,r=this.material.length;n<r;n++)t.push(i(e.materials,this.material[n]));r.material=t}else r.material=i(e.materials,this.material);if(this.children.length>0){r.children=[];for(let t=0;t<this.children.length;t++)r.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let t=0;t<this.animations.length;t++){let n=this.animations[t];r.animations.push(i(e.animations,n))}}if(t){let t=a(e.geometries),r=a(e.materials),i=a(e.textures),o=a(e.images),s=a(e.shapes),c=a(e.skeletons),l=a(e.animations),u=a(e.nodes);t.length>0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot===null?null:e.pivot.clone(),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let t=0;t<e.children.length;t++){let n=e.children[t];this.add(n.clone())}return this}};Br.DEFAULT_UP=new B(0,1,0),Br.DEFAULT_MATRIX_AUTO_UPDATE=!0,Br.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var Vr=class extends Br{constructor(){super(),this.isGroup=!0,this.type=`Group`}},Hr={type:`move`},Ur=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Vr,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 Vr,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new B,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new B),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Vr,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new B,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new B,this._grip.eventsEnabled=!1),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){let t=this._hand;if(t)for(let 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,i=null,a=null,o=this._targetRay,s=this._grip,c=this._hand;if(e&&t.session.visibilityState!==`visible-blurred`){if(c&&e.hand){a=!0;for(let r of e.hand.values()){let e=t.getJointPose(r,n),i=this._getHandJoint(c,r);e!==null&&(i.matrix.fromArray(e.transform.matrix),i.matrix.decompose(i.position,i.rotation,i.scale),i.matrixWorldNeedsUpdate=!0,i.jointRadius=e.radius),i.visible=e!==null}let r=c.joints[`index-finger-tip`],i=c.joints[`thumb-tip`],o=r.position.distanceTo(i.position);c.inputState.pinching&&o>.025?(c.inputState.pinching=!1,this.dispatchEvent({type:`pinchend`,handedness:e.handedness,target:this})):!c.inputState.pinching&&o<=.015&&(c.inputState.pinching=!0,this.dispatchEvent({type:`pinchstart`,handedness:e.handedness,target:this}))}else s!==null&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),i!==null&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1,s.eventsEnabled&&s.dispatchEvent({type:`gripUpdated`,data:e,target:this})));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&i!==null&&(r=i),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(Hr)))}return o!==null&&(o.visible=r!==null),s!==null&&(s.visible=i!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new Vr;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},Wr={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Gr={h:0,s:0,l:0},Kr={h:0,s:0,l:0};function qr(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var H=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Ot){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Xn.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=Xn.workingColorSpace){return this.r=e,this.g=t,this.b=n,Xn.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=Xn.workingColorSpace){if(e=Cn(e,1),t=I(t,0,1),n=I(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=qr(i,r,e+1/3),this.g=qr(i,r,e),this.b=qr(i,r,e-1/3)}return Xn.colorSpaceToWorking(this,r),this}setStyle(e,t=Ot){function n(t){t!==void 0&&parseFloat(t)<1&&P(`Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:P(`Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);P(`Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Ot){let n=Wr[e.toLowerCase()];return n===void 0?P(`Color: Unknown color `+e):this.setHex(n,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Zn(e.r),this.g=Zn(e.g),this.b=Zn(e.b),this}copyLinearToSRGB(e){return this.r=Qn(e.r),this.g=Qn(e.g),this.b=Qn(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ot){return Xn.workingToColorSpace(Jr.copy(this),e),Math.round(I(Jr.r*255,0,255))*65536+Math.round(I(Jr.g*255,0,255))*256+Math.round(I(Jr.b*255,0,255))}getHexString(e=Ot){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Xn.workingColorSpace){Xn.workingToColorSpace(Jr.copy(this),t);let n=Jr.r,r=Jr.g,i=Jr.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4}s/=6}return e.h=s,e.s=c,e.l=l,e}getRGB(e,t=Xn.workingColorSpace){return Xn.workingToColorSpace(Jr.copy(this),t),e.r=Jr.r,e.g=Jr.g,e.b=Jr.b,e}getStyle(e=Ot){Xn.workingToColorSpace(Jr.copy(this),e);let t=Jr.r,n=Jr.g,r=Jr.b;return e===`srgb`?`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`:`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`}offsetHSL(e,t,n){return this.getHSL(Gr),this.setHSL(Gr.h+e,Gr.s+t,Gr.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Gr),e.getHSL(Kr);let n=En(Gr.h,Kr.h,t),r=En(Gr.s,Kr.s,t),i=En(Gr.l,Kr.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},Jr=new H;H.NAMES=Wr;var Yr=class e{constructor(e,t=25e-5){this.isFogExp2=!0,this.name=``,this.color=new H(e),this.density=t}clone(){return new e(this.color,this.density)}toJSON(){return{type:`FogExp2`,name:this.name,color:this.color.getHex(),density:this.density}}},Xr=class e{constructor(e,t=1,n=1e3){this.isFog=!0,this.name=``,this.color=new H(e),this.near=t,this.far=n}clone(){return new e(this.color,this.near,this.far)}toJSON(){return{type:`Fog`,name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}},Zr=class extends Br{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 Cr,this.environmentIntensity=1,this.environmentRotation=new Cr,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){let 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}},Qr=new B,$r=new B,ei=new B,ti=new B,ni=new B,ri=new B,ii=new B,ai=new B,oi=new B,si=new B,ci=new sr,li=new sr,ui=new sr,di=class e{constructor(e=new B,t=new B,n=new B){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),Qr.subVectors(e,t),r.cross(Qr);let i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){Qr.subVectors(r,t),$r.subVectors(n,t),ei.subVectors(e,t);let a=Qr.dot(Qr),o=Qr.dot($r),s=Qr.dot(ei),c=$r.dot($r),l=$r.dot(ei),u=a*c-o*o;if(u===0)return i.set(0,0,0),null;let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,ti)!==null&&ti.x>=0&&ti.y>=0&&ti.x+ti.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,ti)===null?(s.x=0,s.y=0,`z`in s&&(s.z=0),`w`in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(i,ti.x),s.addScaledVector(a,ti.y),s.addScaledVector(o,ti.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return ci.setScalar(0),li.setScalar(0),ui.setScalar(0),ci.fromBufferAttribute(e,t),li.fromBufferAttribute(e,n),ui.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(ci,i.x),a.addScaledVector(li,i.y),a.addScaledVector(ui,i.z),a}static isFrontFacing(e,t,n,r){return Qr.subVectors(n,t),$r.subVectors(e,t),Qr.cross($r).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Qr.subVectors(this.c,this.b),$r.subVectors(this.a,this.b),Qr.cross($r).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;ni.subVectors(r,n),ri.subVectors(i,n),ai.subVectors(e,n);let s=ni.dot(ai),c=ri.dot(ai);if(s<=0&&c<=0)return t.copy(n);oi.subVectors(e,r);let l=ni.dot(oi),u=ri.dot(oi);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(ni,a);si.subVectors(e,i);let f=ni.dot(si),p=ri.dot(si);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(ri,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return ii.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(ii,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(ni,a).addScaledVector(ri,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},fi=class{constructor(e=new B(1/0,1/0,1/0),t=new B(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(mi.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(mi.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=mi.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute(`position`);if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let t=0,n=r.count;t<n;t++)e.isMesh===!0?e.getVertexPosition(t,mi):mi.fromBufferAttribute(r,t),mi.applyMatrix4(e.matrixWorld),this.expandByPoint(mi);else e.boundingBox===void 0?(n.boundingBox===null&&n.computeBoundingBox(),hi.copy(n.boundingBox)):(e.boundingBox===null&&e.computeBoundingBox(),hi.copy(e.boundingBox)),hi.applyMatrix4(e.matrixWorld),this.union(hi)}let r=e.children;for(let e=0,n=r.length;e<n;e++)this.expandByObject(r[e],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,mi),mi.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Si),Ci.subVectors(this.max,Si),gi.subVectors(e.a,Si),_i.subVectors(e.b,Si),vi.subVectors(e.c,Si),yi.subVectors(_i,gi),bi.subVectors(vi,_i),xi.subVectors(gi,vi);let t=[0,-yi.z,yi.y,0,-bi.z,bi.y,0,-xi.z,xi.y,yi.z,0,-yi.x,bi.z,0,-bi.x,xi.z,0,-xi.x,-yi.y,yi.x,0,-bi.y,bi.x,0,-xi.y,xi.x,0];return!Ei(t,gi,_i,vi,Ci)||(t=[1,0,0,0,1,0,0,0,1],!Ei(t,gi,_i,vi,Ci))?!1:(wi.crossVectors(yi,bi),t=[wi.x,wi.y,wi.z],Ei(t,gi,_i,vi,Ci))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,mi).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(mi).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(pi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),pi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),pi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),pi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),pi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),pi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),pi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),pi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(pi),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},pi=[new B,new B,new B,new B,new B,new B,new B,new B],mi=new B,hi=new fi,gi=new B,_i=new B,vi=new B,yi=new B,bi=new B,xi=new B,Si=new B,Ci=new B,wi=new B,Ti=new B;function Ei(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){Ti.fromArray(e,a);let o=i.x*Math.abs(Ti.x)+i.y*Math.abs(Ti.y)+i.z*Math.abs(Ti.z),s=t.dot(Ti),c=n.dot(Ti),l=r.dot(Ti);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}var Di=Oi();function Oi(){let e=new ArrayBuffer(4),t=new Float32Array(e),n=new Uint32Array(e),r=new Uint32Array(512),i=new Uint32Array(512);for(let e=0;e<256;++e){let t=e-127;t<-27?(r[e]=0,r[e|256]=32768,i[e]=24,i[e|256]=24):t<-14?(r[e]=1024>>-t-14,r[e|256]=1024>>-t-14|32768,i[e]=-t-1,i[e|256]=-t-1):t<=15?(r[e]=t+15<<10,r[e|256]=t+15<<10|32768,i[e]=13,i[e|256]=13):t<128?(r[e]=31744,r[e|256]=64512,i[e]=24,i[e|256]=24):(r[e]=31744,r[e|256]=64512,i[e]=13,i[e|256]=13)}let a=new Uint32Array(2048),o=new Uint32Array(64),s=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,n=0;for(;!(t&8388608);)t<<=1,n-=8388608;t&=-8388609,n+=947912704,a[e]=t|n}for(let e=1024;e<2048;++e)a[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)o[e]=e<<23;o[31]=1199570944,o[32]=2147483648;for(let e=33;e<63;++e)o[e]=2147483648+(e-32<<23);o[63]=3347054592;for(let e=1;e<64;++e)e!==32&&(s[e]=1024);return{floatView:t,uint32View:n,baseTable:r,shiftTable:i,mantissaTable:a,exponentTable:o,offsetTable:s}}function ki(e){Math.abs(e)>65504&&P(`DataUtils.toHalfFloat(): Value out of range.`),e=I(e,-65504,65504),Di.floatView[0]=e;let t=Di.uint32View[0],n=t>>23&511;return Di.baseTable[n]+((t&8388607)>>Di.shiftTable[n])}function Ai(e){let t=e>>10;return Di.uint32View[0]=Di.mantissaTable[Di.offsetTable[t]+(e&1023)]+Di.exponentTable[t],Di.floatView[0]}var ji=class{static toHalfFloat(e){return ki(e)}static fromHalfFloat(e){return Ai(e)}},Mi=new B,Ni=new R,Pi=0,Fi=class extends _n{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Pi++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=zt,this.updateRanges=[],this.gpuType=pe,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Ni.fromBufferAttribute(this,t),Ni.applyMatrix3(e),this.setXY(t,Ni.x,Ni.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Mi.fromBufferAttribute(this,t),Mi.applyMatrix3(e),this.setXYZ(t,Mi.x,Mi.y,Mi.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Mi.fromBufferAttribute(this,t),Mi.applyMatrix4(e),this.setXYZ(t,Mi.x,Mi.y,Mi.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Mi.fromBufferAttribute(this,t),Mi.applyNormalMatrix(e),this.setXYZ(t,Mi.x,Mi.y,Mi.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Mi.fromBufferAttribute(this,t),Mi.transformDirection(e),this.setXYZ(t,Mi.x,Mi.y,Mi.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=Vn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=L(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Vn(t,this.array)),t}setX(e,t){return this.normalized&&(t=L(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Vn(t,this.array)),t}setY(e,t){return this.normalized&&(t=L(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Vn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=L(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Vn(t,this.array)),t}setW(e,t){return this.normalized&&(t=L(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=L(t,this.array),n=L(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=L(t,this.array),n=L(n,this.array),r=L(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=L(t,this.array),n=L(n,this.array),r=L(r,this.array),i=L(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==``&&(e.name=this.name),this.usage!==35044&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:`dispose`})}},Ii=class extends Fi{constructor(e,t,n){super(new Int8Array(e),t,n)}},Li=class extends Fi{constructor(e,t,n){super(new Uint8Array(e),t,n)}},Ri=class extends Fi{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}},zi=class extends Fi{constructor(e,t,n){super(new Int16Array(e),t,n)}},Bi=class extends Fi{constructor(e,t,n){super(new Uint16Array(e),t,n)}},Vi=class extends Fi{constructor(e,t,n){super(new Int32Array(e),t,n)}},Hi=class extends Fi{constructor(e,t,n){super(new Uint32Array(e),t,n)}},Ui=class extends Fi{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=Ai(this.array[e*this.itemSize]);return this.normalized&&(t=Vn(t,this.array)),t}setX(e,t){return this.normalized&&(t=L(t,this.array)),this.array[e*this.itemSize]=ki(t),this}getY(e){let t=Ai(this.array[e*this.itemSize+1]);return this.normalized&&(t=Vn(t,this.array)),t}setY(e,t){return this.normalized&&(t=L(t,this.array)),this.array[e*this.itemSize+1]=ki(t),this}getZ(e){let t=Ai(this.array[e*this.itemSize+2]);return this.normalized&&(t=Vn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=L(t,this.array)),this.array[e*this.itemSize+2]=ki(t),this}getW(e){let t=Ai(this.array[e*this.itemSize+3]);return this.normalized&&(t=Vn(t,this.array)),t}setW(e,t){return this.normalized&&(t=L(t,this.array)),this.array[e*this.itemSize+3]=ki(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=L(t,this.array),n=L(n,this.array)),this.array[e+0]=ki(t),this.array[e+1]=ki(n),this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=L(t,this.array),n=L(n,this.array),r=L(r,this.array)),this.array[e+0]=ki(t),this.array[e+1]=ki(n),this.array[e+2]=ki(r),this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=L(t,this.array),n=L(n,this.array),r=L(r,this.array),i=L(i,this.array)),this.array[e+0]=ki(t),this.array[e+1]=ki(n),this.array[e+2]=ki(r),this.array[e+3]=ki(i),this}},U=class extends Fi{constructor(e,t,n){super(new Float32Array(e),t,n)}},Wi=new fi,Gi=new B,Ki=new B,qi=class{constructor(e=new B,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t===void 0?Wi.setFromPoints(e).getCenter(n):n.copy(t);let r=0;for(let t=0,i=e.length;t<i;t++)r=Math.max(r,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius*=e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Gi.subVectors(e,this.center);let t=Gi.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(Gi,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Ki.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Gi.copy(e.center).add(Ki)),this.expandByPoint(Gi.copy(e.center).sub(Ki))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},Ji=0,Yi=new V,Xi=new Br,Zi=new B,Qi=new fi,$i=new fi,ea=new B,W=class e extends _n{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Ji++}),this.uuid=Sn(),this.name=``,this.type=`BufferGeometry`,this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return this.index=Array.isArray(e)?new(tn(e)?Hi:Bi)(e,1):e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let t=new Gn().getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return Yi.makeRotationFromQuaternion(e),this.applyMatrix4(Yi),this}rotateX(e){return Yi.makeRotationX(e),this.applyMatrix4(Yi),this}rotateY(e){return Yi.makeRotationY(e),this.applyMatrix4(Yi),this}rotateZ(e){return Yi.makeRotationZ(e),this.applyMatrix4(Yi),this}translate(e,t,n){return Yi.makeTranslation(e,t,n),this.applyMatrix4(Yi),this}scale(e,t,n){return Yi.makeScale(e,t,n),this.applyMatrix4(Yi),this}lookAt(e){return Xi.lookAt(e),Xi.updateMatrix(),this.applyMatrix4(Xi.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Zi).negate(),this.translate(Zi.x,Zi.y,Zi.z),this}setFromPoints(e){let t=this.getAttribute(`position`);if(t===void 0){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];t.push(r.x,r.y,r.z||0)}this.setAttribute(`position`,new U(t,3))}else{let n=Math.min(e.length,t.count);for(let r=0;r<n;r++){let n=e[r];t.setXYZ(r,n.x,n.y,n.z||0)}e.length>t.count&&P(`BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.`),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new fi);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){F(`BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.`,this),this.boundingBox.set(new B(-1/0,-1/0,-1/0),new B(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];Qi.setFromBufferAttribute(n),this.morphTargetsRelative?(ea.addVectors(this.boundingBox.min,Qi.min),this.boundingBox.expandByPoint(ea),ea.addVectors(this.boundingBox.max,Qi.max),this.boundingBox.expandByPoint(ea)):(this.boundingBox.expandByPoint(Qi.min),this.boundingBox.expandByPoint(Qi.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&F(`BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.`,this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new qi);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){F(`BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.`,this),this.boundingSphere.set(new B,1/0);return}if(e){let n=this.boundingSphere.center;if(Qi.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];$i.setFromBufferAttribute(n),this.morphTargetsRelative?(ea.addVectors(Qi.min,$i.min),Qi.expandByPoint(ea),ea.addVectors(Qi.max,$i.max),Qi.expandByPoint(ea)):(Qi.expandByPoint($i.min),Qi.expandByPoint($i.max))}Qi.getCenter(n);let r=0;for(let t=0,i=e.count;t<i;t++)ea.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(ea));if(t)for(let i=0,a=t.length;i<a;i++){let a=t[i],o=this.morphTargetsRelative;for(let t=0,i=a.count;t<i;t++)ea.fromBufferAttribute(a,t),o&&(Zi.fromBufferAttribute(e,t),ea.add(Zi)),r=Math.max(r,n.distanceToSquared(ea))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&F(`BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.`,this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){F(`BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)`);return}let n=t.position,r=t.normal,i=t.uv,a=this.getAttribute(`tangent`);(a===void 0||a.count!==n.count)&&(a=new Fi(new Float32Array(4*n.count),4),this.setAttribute(`tangent`,a));let o=[],s=[];for(let e=0;e<n.count;e++)o[e]=new B,s[e]=new B;let c=new B,l=new B,u=new B,d=new R,f=new R,p=new R,m=new B,h=new B;function g(e,t,r){c.fromBufferAttribute(n,e),l.fromBufferAttribute(n,t),u.fromBufferAttribute(n,r),d.fromBufferAttribute(i,e),f.fromBufferAttribute(i,t),p.fromBufferAttribute(i,r),l.sub(c),u.sub(c),f.sub(d),p.sub(d);let a=1/(f.x*p.y-p.x*f.y);isFinite(a)&&(m.copy(l).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(a),h.copy(u).multiplyScalar(f.x).addScaledVector(l,-p.x).multiplyScalar(a),o[e].add(m),o[t].add(m),o[r].add(m),s[e].add(h),s[t].add(h),s[r].add(h))}let _=this.groups;_.length===0&&(_=[{start:0,count:e.count}]);for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)g(e.getX(t+0),e.getX(t+1),e.getX(t+2))}let v=new B,y=new B,b=new B,x=new B;function S(e){b.fromBufferAttribute(r,e),x.copy(b);let t=o[e];v.copy(t),v.sub(b.multiplyScalar(b.dot(t))).normalize(),y.crossVectors(x,t);let n=y.dot(s[e])<0?-1:1;a.setXYZW(e,v.x,v.y,v.z,n)}for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)S(e.getX(t+0)),S(e.getX(t+1)),S(e.getX(t+2))}this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute(`position`);if(t!==void 0){let n=this.getAttribute(`normal`);if(n===void 0||n.count!==t.count)n=new Fi(new Float32Array(t.count*3),3),this.setAttribute(`normal`,n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);let r=new B,i=new B,a=new B,o=new B,s=new B,c=new B,l=new B,u=new B;if(e)for(let d=0,f=e.count;d<f;d+=3){let f=e.getX(d+0),p=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,f),i.fromBufferAttribute(t,p),a.fromBufferAttribute(t,m),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),o.fromBufferAttribute(n,f),s.fromBufferAttribute(n,p),c.fromBufferAttribute(n,m),o.add(l),s.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(p,s.x,s.y,s.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let e=0,o=t.count;e<o;e+=3)r.fromBufferAttribute(t,e+0),i.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),n.setXYZ(e+0,l.x,l.y,l.z),n.setXYZ(e+1,l.x,l.y,l.z),n.setXYZ(e+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)ea.fromBufferAttribute(e,t),ea.normalize(),e.setXYZ(t,ea.x,ea.y,ea.z)}toNonIndexed(){function t(e,t){let n=e.array,r=e.itemSize,i=e.normalized,a=new n.constructor(t.length*r),o=0,s=0;for(let i=0,c=t.length;i<c;i++){o=e.isInterleavedBufferAttribute?t[i]*e.data.stride+e.offset:t[i]*r;for(let e=0;e<r;e++)a[s++]=n[o++]}return new Fi(a,r,i)}if(this.index===null)return P(`BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.`),this;let n=new e,r=this.index.array,i=this.attributes;for(let e in i){let a=i[e],o=t(a,r);n.setAttribute(e,o)}let a=this.morphAttributes;for(let e in a){let i=[],o=a[e];for(let e=0,n=o.length;e<n;e++){let n=o[e],a=t(n,r);i.push(a)}n.morphAttributes[e]=i}n.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let e=0,t=o.length;e<t;e++){let t=o[e];n.addGroup(t.start,t.count,t.materialIndex)}return n}toJSON(){let e={metadata:{version:4.7,type:`BufferGeometry`,generator:`BufferGeometry.toJSON`}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?`BufferGeometry`:this.type,this.name!==``&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t<r;t++){let r=n[t];a.push(r.toJSON(e.data))}a.length>0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e<i;e++)n.push(r[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let e=0,t=a.length;e<t;e++){let t=a[e];this.addGroup(t.start,t.count,t.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let s=e.boundingSphere;return s!==null&&(this.boundingSphere=s.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:`dispose`})}},ta=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e===void 0?0:e.length/t,this.usage=zt,this.updateRanges=[],this.version=0,this.uuid=Sn()}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,i=this.stride;r<i;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=Sn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let 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=Sn()),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}}},na=new B,ra=class e{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++)na.fromBufferAttribute(this,t),na.applyMatrix4(e),this.setXYZ(t,na.x,na.y,na.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)na.fromBufferAttribute(this,t),na.applyNormalMatrix(e),this.setXYZ(t,na.x,na.y,na.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)na.fromBufferAttribute(this,t),na.transformDirection(e),this.setXYZ(t,na.x,na.y,na.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=Vn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=L(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=L(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=L(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=L(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=L(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=Vn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Vn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Vn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Vn(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=L(t,this.array),n=L(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=L(t,this.array),n=L(n,this.array),r=L(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,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=L(t,this.array),n=L(n,this.array),r=L(r,this.array),i=L(i,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]=i,this}clone(t){if(t===void 0){fn(`InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new Fi(new this.array.constructor(e),this.itemSize,this.normalized)}return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new e(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){fn(`InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}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}}},ia=0,aa=class extends _n{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:ia++}),this.uuid=Sn(),this.name=``,this.type=`Material`,this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new H(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Mt,this.stencilZFail=Mt,this.stencilZPass=Mt,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){P(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){P(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector2&&n&&n.isVector2||r&&r.isEuler&&n&&n.isEuler||r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:`Material`,generator:`Material.toJSON`}};n.uuid=this.uuid,n.type=this.type,this.name!==``&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==1&&(n.blending=this.blending),this.side!==0&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==204&&(n.blendSrc=this.blendSrc),this.blendDst!==205&&(n.blendDst=this.blendDst),this.blendEquation!==100&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==3&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==519&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==7680&&(n.stencilFail=this.stencilFail),this.stencilZFail!==7680&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==7680&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==`round`&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==`round`&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new H().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(this.vertexColors=typeof e.vertexColors==`number`?e.vertexColors>0:e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let t=e.normalScale;Array.isArray(t)===!1&&(t=[t,t]),this.normalScale=new R().fromArray(t)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new R().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:`dispose`})}set needsUpdate(e){e===!0&&this.version++}},oa=class extends aa{constructor(e){super(),this.isSpriteMaterial=!0,this.type=`SpriteMaterial`,this.color=new H(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}},sa,ca=new B,la=new B,ua=new B,da=new R,fa=new R,pa=new V,ma=new B,ha=new B,ga=new B,_a=new R,va=new R,ya=new R,ba=class extends Br{constructor(e=new oa){if(super(),this.isSprite=!0,this.type=`Sprite`,sa===void 0){sa=new W;let e=new ta(new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),5);sa.setIndex([0,1,2,0,2,3]),sa.setAttribute(`position`,new ra(e,3,0,!1)),sa.setAttribute(`uv`,new ra(e,2,3,!1))}this.geometry=sa,this.material=e,this.center=new R(.5,.5),this.count=1}raycast(e,t){e.camera===null&&F(`Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.`),la.setFromMatrixScale(this.matrixWorld),pa.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),ua.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&la.multiplyScalar(-ua.z);let n=this.material.rotation,r,i;n!==0&&(i=Math.cos(n),r=Math.sin(n));let a=this.center;xa(ma.set(-.5,-.5,0),ua,a,la,r,i),xa(ha.set(.5,-.5,0),ua,a,la,r,i),xa(ga.set(.5,.5,0),ua,a,la,r,i),_a.set(0,0),va.set(1,0),ya.set(1,1);let o=e.ray.intersectTriangle(ma,ha,ga,!1,ca);if(o===null&&(xa(ha.set(-.5,.5,0),ua,a,la,r,i),va.set(0,1),o=e.ray.intersectTriangle(ma,ga,ha,!1,ca),o===null))return;let s=e.ray.origin.distanceTo(ca);s<e.near||s>e.far||t.push({distance:s,point:ca.clone(),uv:di.getInterpolation(ca,ma,ha,ga,_a,va,ya,new R),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 xa(e,t,n,r,i,a){da.subVectors(e,n).addScalar(.5).multiply(r),i===void 0?fa.copy(da):(fa.x=a*da.x-i*da.y,fa.y=i*da.x+a*da.y),e.copy(t),e.x+=fa.x,e.y+=fa.y,e.applyMatrix4(pa)}var Sa=new B,Ca=new B,wa=class extends Br{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);let t=e.levels;for(let e=0,n=t.length;e<n;e++){let n=t[e];this.addLevel(n.object.clone(),n.distance,n.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,n=0){t=Math.abs(t);let r=this.levels,i;for(i=0;i<r.length&&!(t<r[i].distance);i++);return r.splice(i,0,{distance:t,hysteresis:n,object:e}),this.add(e),this}removeLevel(e){let t=this.levels;for(let n=0;n<t.length;n++)if(t[n].distance===e){let e=t.splice(n,1);return this.remove(e[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){let t=this.levels;if(t.length>0){let n,r;for(n=1,r=t.length;n<r;n++){let r=t[n].distance;if(t[n].object.visible&&(r-=r*t[n].hysteresis),e<r)break}return t[n-1].object}return null}raycast(e,t){if(this.levels.length>0){Sa.setFromMatrixPosition(this.matrixWorld);let n=e.ray.origin.distanceTo(Sa);this.getObjectForDistance(n).raycast(e,t)}}update(e){let t=this.levels;if(t.length>1){Sa.setFromMatrixPosition(e.matrixWorld),Ca.setFromMatrixPosition(this.matrixWorld);let n=Sa.distanceTo(Ca)/e.zoom;t[0].object.visible=!0;let r,i;for(r=1,i=t.length;r<i;r++){let e=t[r].distance;if(t[r].object.visible&&(e-=e*t[r].hysteresis),n>=e)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r<i;r++)t[r].object.visible=!1}}toJSON(e){let t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];let n=this.levels;for(let e=0,r=n.length;e<r;e++){let r=n[e];t.object.levels.push({object:r.object.uuid,distance:r.distance,hysteresis:r.hysteresis})}return t}},Ta=new B,Ea=new B,Da=new B,Oa=new B,ka=new B,Aa=new B,ja=new B,Ma=class{constructor(e=new B,t=new B(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Ta)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Ta.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Ta.copy(this.origin).addScaledVector(this.direction,t),Ta.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){Ea.copy(e).add(t).multiplyScalar(.5),Da.copy(t).sub(e).normalize(),Oa.copy(this.origin).sub(Ea);let i=e.distanceTo(t)*.5,a=-this.direction.dot(Da),o=Oa.dot(this.direction),s=-Oa.dot(Da),c=Oa.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0)if(u=a*s-o,d=a*o-s,p=i*l,u>=0)if(d>=-p)if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c);else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(Ea).addScaledVector(Da,d),f}intersectSphere(e,t){Ta.subVectors(e.center,this.origin);let n=Ta.dot(this.direction),r=Ta.dot(Ta)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a<r||isNaN(r))&&(r=a),u>=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s<r||r!==r)&&(r=s),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,Ta)!==null}intersectTriangle(e,t,n,r,i){ka.subVectors(t,e),Aa.subVectors(n,e),ja.crossVectors(ka,Aa);let a=this.direction.dot(ja),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Oa.subVectors(this.origin,e);let s=o*this.direction.dot(Aa.crossVectors(Oa,Aa));if(s<0)return null;let c=o*this.direction.dot(ka.cross(Oa));if(c<0||s+c>a)return null;let l=-o*Oa.dot(ja);return l<0?null:this.at(l/a,i)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Na=class extends aa{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new H(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Cr,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Pa=new V,Fa=new Ma,Ia=new qi,La=new B,Ra=new B,za=new B,Ba=new B,Va=new B,Ha=new B,Ua=new B,Wa=new B,Ga=class extends Br{constructor(e=new W,t=new Na){super(),this.isMesh=!0,this.type=`Mesh`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}getVertexPosition(e,t){let n=this.geometry,r=n.attributes.position,i=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);let o=this.morphTargetInfluences;if(i&&o){Ha.set(0,0,0);for(let n=0,r=i.length;n<r;n++){let r=o[n],s=i[n];r!==0&&(Va.fromBufferAttribute(s,e),a?Ha.addScaledVector(Va,r):Ha.addScaledVector(Va.sub(t),r))}t.add(Ha)}return t}raycast(e,t){let n=this.geometry,r=this.material,i=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Ia.copy(n.boundingSphere),Ia.applyMatrix4(i),Fa.copy(e.ray).recast(e.near),!(Ia.containsPoint(Fa.origin)===!1&&(Fa.intersectSphere(Ia,La)===null||Fa.origin.distanceToSquared(La)>(e.far-e.near)**2))&&(Pa.copy(i).invert(),Fa.copy(e.ray).applyMatrix4(Pa),(n.boundingBox===null||Fa.intersectsBox(n.boundingBox)!==!1)&&this._computeIntersections(e,t,Fa)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null)if(Array.isArray(a))for(let i=0,s=d.length;i<s;i++){let s=d[i],p=a[s.materialIndex],m=Math.max(s.start,f.start),h=Math.min(o.count,Math.min(s.start+s.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=o.getX(i),d=o.getX(i+1),f=o.getX(i+2);r=qa(this,p,e,n,c,l,u,a,d,f),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=s.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),s=Math.min(o.count,f.start+f.count);for(let d=i,f=s;d<f;d+=3){let i=o.getX(d),s=o.getX(d+1),f=o.getX(d+2);r=qa(this,a,e,n,c,l,u,i,s,f),r&&(r.faceIndex=Math.floor(d/3),t.push(r))}}else if(s!==void 0)if(Array.isArray(a))for(let i=0,o=d.length;i<o;i++){let o=d[i],p=a[o.materialIndex],m=Math.max(o.start,f.start),h=Math.min(s.count,Math.min(o.start+o.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=i,s=i+1,d=i+2;r=qa(this,p,e,n,c,l,u,a,s,d),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=o.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),o=Math.min(s.count,f.start+f.count);for(let s=i,d=o;s<d;s+=3){let i=s,o=s+1,d=s+2;r=qa(this,a,e,n,c,l,u,i,o,d),r&&(r.faceIndex=Math.floor(s/3),t.push(r))}}}};function Ka(e,t,n,r,i,a,o,s){let c;if(c=t.side===1?r.intersectTriangle(o,a,i,!0,s):r.intersectTriangle(i,a,o,t.side===0,s),c===null)return null;Wa.copy(s),Wa.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(Wa);return l<n.near||l>n.far?null:{distance:l,point:Wa.clone(),object:e}}function qa(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,Ra),e.getVertexPosition(c,za),e.getVertexPosition(l,Ba);let u=Ka(e,t,n,r,Ra,za,Ba,Ua);if(u){let e=new B;di.getBarycoord(Ua,Ra,za,Ba,e),i&&(u.uv=di.getInterpolatedAttribute(i,s,c,l,e,new R)),a&&(u.uv1=di.getInterpolatedAttribute(a,s,c,l,e,new R)),o&&(u.normal=di.getInterpolatedAttribute(o,s,c,l,e,new B),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new B,materialIndex:0};di.getNormal(Ra,za,Ba,t.normal),u.face=t,u.barycoord=e}return u}var Ja=new sr,Ya=new sr,Xa=new sr,Za=new sr,Qa=new V,$a=new B,eo=new qi,to=new V,no=new Ma,ro=class extends Ga{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type=`SkinnedMesh`,this.bindMode=T,this.bindMatrix=new V,this.bindMatrixInverse=new V,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new fi),this.boundingBox.makeEmpty();let t=e.getAttribute(`position`);for(let e=0;e<t.count;e++)this.getVertexPosition(e,$a),this.boundingBox.expandByPoint($a)}computeBoundingSphere(){let e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new qi),this.boundingSphere.makeEmpty();let t=e.getAttribute(`position`);for(let e=0;e<t.count;e++)this.getVertexPosition(e,$a),this.boundingSphere.expandByPoint($a)}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){let n=this.material,r=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),eo.copy(this.boundingSphere),eo.applyMatrix4(r),e.ray.intersectsSphere(eo)!==!1&&(to.copy(r).invert(),no.copy(e.ray).applyMatrix4(to),(this.boundingBox===null||no.intersectsBox(this.boundingBox)!==!1)&&this._computeIntersections(e,t,no)))}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(){let e=new sr,t=this.geometry.attributes.skinWeight;for(let n=0,r=t.count;n<r;n++){e.fromBufferAttribute(t,n);let r=1/e.manhattanLength();r===1/0?e.set(1,0,0,0):e.multiplyScalar(r),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===`attached`?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===`detached`?this.bindMatrixInverse.copy(this.bindMatrix).invert():P(`SkinnedMesh: Unrecognized bindMode: `+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,r=this.geometry;Ya.fromBufferAttribute(r.attributes.skinIndex,e),Xa.fromBufferAttribute(r.attributes.skinWeight,e),t.isVector4?(Ja.copy(t),t.set(0,0,0,0)):(Ja.set(...t,1),t.set(0,0,0)),Ja.applyMatrix4(this.bindMatrix);for(let e=0;e<4;e++){let r=Xa.getComponent(e);if(r!==0){let i=Ya.getComponent(e);Qa.multiplyMatrices(n.bones[i].matrixWorld,n.boneInverses[i]),t.addScaledVector(Za.copy(Ja).applyMatrix4(Qa),r)}}return t.isVector4&&(t.w=Ja.w),t.applyMatrix4(this.bindMatrixInverse)}},io=class extends Br{constructor(){super(),this.isBone=!0,this.type=`Bone`}},ao=class extends or{constructor(e=null,t=1,n=1,r,i,a,o,s,c=k,l=k,u,d){super(null,a,o,s,c,l,r,i,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},oo=new V,so=new V,G=class e{constructor(e=[],t=[]){this.uuid=Sn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let 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){P(`Skeleton: Number of inverse bone matrices does not match amount of bones.`),this.boneInverses=[];for(let e=0,t=this.bones.length;e<t;e++)this.boneInverses.push(new V)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let t=new V;this.bones[e]&&t.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(t)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let t=this.bones[e];t&&t.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let t=this.bones[e];t&&(t.parent&&t.parent.isBone?(t.matrix.copy(t.parent.matrixWorld).invert(),t.matrix.multiply(t.matrixWorld)):t.matrix.copy(t.matrixWorld),t.matrix.decompose(t.position,t.quaternion,t.scale))}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let r=0,i=e.length;r<i;r++){let i=e[r]?e[r].matrixWorld:so;oo.multiplyMatrices(i,t[r]),oo.toArray(n,r*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new e(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let n=new ao(t,e,e,Se,pe);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let n=this.bones[t];if(n.name===e)return n}}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++){let r=e.bones[n],i=t[r];i===void 0&&(P(`Skeleton: No bone found with UUID:`,r),i=new io),this.bones.push(i),this.boneInverses.push(new V().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){let e={metadata:{version:4.7,type:`Skeleton`,generator:`Skeleton.toJSON`},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,n=this.boneInverses;for(let r=0,i=t.length;r<i;r++){let i=t[r];e.bones.push(i.uuid);let a=n[r];e.boneInverses.push(a.toArray())}return e}},co=class extends Fi{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(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},lo=new V,uo=new V,fo=[],po=new fi,mo=new V,ho=new Ga,go=new qi,_o=class extends Ga{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new co(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let e=0;e<n;e++)this.setMatrixAt(e,mo)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new fi),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,lo),po.copy(e.boundingBox).applyMatrix4(lo),this.boundingBox.union(po)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new qi),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,lo),go.copy(e.boundingSphere).applyMatrix4(lo),this.boundingSphere.union(go)}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){return this.instanceColor===null?t.setRGB(1,1,1):t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let n=t.morphTargetInfluences,r=this.morphTexture.source.data.data,i=e*(n.length+1)+1;for(let e=0;e<n.length;e++)n[e]=r[i+e]}raycast(e,t){let n=this.matrixWorld,r=this.count;if(ho.geometry=this.geometry,ho.material=this.material,ho.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),go.copy(this.boundingSphere),go.applyMatrix4(n),e.ray.intersectsSphere(go)!==!1))for(let i=0;i<r;i++){this.getMatrixAt(i,lo),uo.multiplyMatrices(n,lo),ho.matrixWorld=uo,ho.raycast(e,fo);for(let e=0,n=fo.length;e<n;e++){let n=fo[e];n.instanceId=i,n.object=this,t.push(n)}fo.length=0}}setColorAt(e,t){return this.instanceColor===null&&(this.instanceColor=new co(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){let n=t.morphTargetInfluences,r=n.length+1;this.morphTexture===null&&(this.morphTexture=new ao(new Float32Array(r*this.count),r,this.count,Te,pe));let i=this.morphTexture.source.data.data,a=0;for(let e=0;e<n.length;e++)a+=n[e];let o=this.geometry.morphTargetsRelative?1:1-a,s=r*e;return i[s]=o,i.set(n,s+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:`dispose`}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}},vo=new B,yo=new B,bo=new Gn,xo=class{constructor(e=new B(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){let r=vo.subVectors(n,t).cross(yo.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let 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,n=!0){let r=e.delta(vo),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let a=-(e.start.dot(this.normal)+this.constant)/i;return n===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(r,a)}intersectsLine(e){let 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){let n=t||bo.getNormalMatrix(e),r=this.coplanarPoint(vo).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),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)}},So=new qi,Co=new R(.5,.5),wo=new B,To=class{constructor(e=new xo,t=new xo,n=new xo,r=new xo,i=new xo,a=new xo){this.planes=[e,t,n,r,i,a]}set(e,t,n,r,i,a){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Yt,n=!1){let r=this.planes,i=e.elements,a=i[0],o=i[1],s=i[2],c=i[3],l=i[4],u=i[5],d=i[6],f=i[7],p=i[8],m=i[9],h=i[10],g=i[11],_=i[12],v=i[13],y=i[14],b=i[15];if(r[0].setComponents(c-a,f-l,g-p,b-_).normalize(),r[1].setComponents(c+a,f+l,g+p,b+_).normalize(),r[2].setComponents(c+o,f+u,g+m,b+v).normalize(),r[3].setComponents(c-o,f-u,g-m,b-v).normalize(),n)r[4].setComponents(s,d,h,y).normalize(),r[5].setComponents(c-s,f-d,g-h,b-y).normalize();else if(r[4].setComponents(c-s,f-d,g-h,b-y).normalize(),t===2e3)r[5].setComponents(c+s,f+d,g+h,b+y).normalize();else if(t===2001)r[5].setComponents(s,d,h,y).normalize();else throw Error(`THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: `+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),So.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),So.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(So)}intersectsSprite(e){return So.center.set(0,0,0),So.radius=.7071067811865476+Co.distanceTo(e.center),So.applyMatrix4(e.matrixWorld),this.intersectsSphere(So)}intersectsSphere(e){let t=this.planes,n=e.center,r=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let r=t[n];if(wo.x=r.normal.x>0?e.max.x:e.min.x,wo.y=r.normal.y>0?e.max.y:e.min.y,wo.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(wo)<0)return!1}return!0}containsPoint(e){let 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)}},Eo=new V,Do=class e{constructor(){this.coordinateSystem=Yt,this._frustums=[],this._count=0}setFromArrayCamera(e){let t=e.cameras,n=this._frustums;for(let e=0;e<t.length;e++){let r=t[e];Eo.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),n[e]===void 0&&(n[e]=new To),n[e].setFromProjectionMatrix(Eo,r.coordinateSystem,r.reversedDepth)}return this._count=t.length,this}intersectsObject(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsObject(e))return!0;return!1}intersectsSprite(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsSprite(e))return!0;return!1}intersectsSphere(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsSphere(e))return!0;return!1}intersectsBox(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsBox(e))return!0;return!1}containsPoint(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].containsPoint(e))return!0;return!1}copy(e){this.coordinateSystem=e.coordinateSystem;let t=this._frustums,n=e._frustums;for(let r=0;r<e._count;r++)t[r]===void 0&&(t[r]=new To),t[r].copy(n[r]);return this._count=e._count,this}clone(){return new e().copy(this)}};function Oo(e,t){return e-t}function ko(e,t){return e.z-t.z}function Ao(e,t){return t.z-e.z}var jo=class{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,n,r){let i=this.pool,a=this.list;this.index>=i.length&&i.push({start:-1,count:-1,z:-1,index:-1});let o=i[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}},Mo=new V,No=new H(1,1,1),Po=new To,Fo=new Do,Io=new fi,Lo=new qi,Ro=new B,zo=new B,Bo=new B,Vo=new jo,Ho=new Ga,Uo=[];function Wo(e,t,n=0){let r=t.itemSize;if(e.isInterleavedBufferAttribute||e.array.constructor!==t.array.constructor){let i=e.count;for(let a=0;a<i;a++)for(let i=0;i<r;i++)t.setComponent(a+n,i,e.getComponent(a,i))}else t.array.set(e.array,n*r);t.needsUpdate=!0}function Go(e,t){if(e.constructor!==t.constructor){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)t[r]=e[r]}else{let n=Math.min(e.length,t.length);t.set(new e.constructor(e.buffer,0,n))}}var Ko=class extends Ga{constructor(e,t,n=t*2,r){super(new W,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._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);let t=new ao(new Float32Array(e*e*4),e,e,Se,pe);this._matricesTexture=t}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);let t=new ao(new Uint32Array(e*e),e,e,Ee,fe);this._indirectTexture=t}_initColorsTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);let t=new ao(new Float32Array(e*e*4).fill(1),e,e,Se,pe);t.colorSpace=Xn.workingColorSpace,this._colorsTexture=t}_initializeGeometry(e){let t=this.geometry,n=this._maxVertexCount,r=this._maxIndexCount;if(this._geometryInitialized===!1){for(let r in e.attributes){let{array:i,itemSize:a,normalized:o}=e.getAttribute(r),s=new Fi(new i.constructor(n*a),a,o);t.setAttribute(r,s)}if(e.getIndex()!==null){let e=n>65535?new Uint32Array(r):new Uint16Array(r);t.setIndex(new Fi(e,1))}this._geometryInitialized=!0}}_validateGeometry(e){let t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw Error(`THREE.BatchedMesh: All geometries must consistently have "index".`);for(let n in t.attributes){if(!e.hasAttribute(n))throw Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);let r=e.getAttribute(n),i=t.getAttribute(n);if(r.itemSize!==i.itemSize||r.normalized!==i.normalized)throw Error(`THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.`)}}validateInstanceId(e){let t=this._instanceInfo;if(e<0||e>=t.length||t[e].active===!1)throw Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){let t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw 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 fi);let e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let n=0,r=t.length;n<r;n++){if(t[n].active===!1)continue;let r=t[n].geometryIndex;this.getMatrixAt(n,Mo),this.getBoundingBoxAt(r,Io).applyMatrix4(Mo),e.union(Io)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new qi);let e=this.boundingSphere,t=this._instanceInfo;e.makeEmpty();for(let n=0,r=t.length;n<r;n++){if(t[n].active===!1)continue;let r=t[n].geometryIndex;this.getMatrixAt(n,Mo),this.getBoundingSphereAt(r,Lo).applyMatrix4(Mo),e.union(Lo)}}addInstance(e){if(this._instanceInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw Error(`THREE.BatchedMesh: Maximum item count reached.`);let t={visible:!0,active:!0,geometryIndex:e},n=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(Oo),n=this._availableInstanceIds.shift(),this._instanceInfo[n]=t):(n=this._instanceInfo.length,this._instanceInfo.push(t));let r=this._matricesTexture;Mo.identity().toArray(r.image.data,n*16),r.needsUpdate=!0;let i=this._colorsTexture;return i&&(No.toArray(i.image.data,n*4),i.needsUpdate=!0),this._visibilityChanged=!0,n}addGeometry(e,t=-1,n=-1){this._initializeGeometry(e),this._validateGeometry(e);let r={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},i=this._geometryInfo;r.vertexStart=this._nextVertexStart,r.reservedVertexCount=t===-1?e.getAttribute(`position`).count:t;let 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 Error(`THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.`);let o;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(Oo),o=this._availableGeometryIds.shift(),i[o]=r):(o=this._geometryCount,this._geometryCount++,i.push(r)),this.setGeometryAt(o,e),this._nextIndexStart=r.indexStart+r.reservedIndexCount,this._nextVertexStart=r.vertexStart+r.reservedVertexCount,o}setGeometryAt(e,t){if(e>=this._geometryCount)throw Error(`THREE.BatchedMesh: Maximum geometry count reached.`);this._validateGeometry(t);let n=this.geometry,r=n.getIndex()!==null,i=n.getIndex(),a=t.getIndex(),o=this._geometryInfo[e];if(r&&a.count>o.reservedIndexCount||t.attributes.position.count>o.reservedVertexCount)throw Error(`THREE.BatchedMesh: Reserved space not large enough for provided geometry.`);let s=o.vertexStart,c=o.reservedVertexCount;o.vertexCount=t.getAttribute(`position`).count;for(let e in n.attributes){let r=t.getAttribute(e),i=n.getAttribute(e);Wo(r,i,s);let a=r.itemSize;for(let e=r.count,t=c;e<t;e++){let t=s+e;for(let e=0;e<a;e++)i.setComponent(t,e,0)}i.needsUpdate=!0,i.addUpdateRange(s*a,c*a)}if(r){let e=o.indexStart,n=o.reservedIndexCount;o.indexCount=t.getIndex().count;for(let t=0;t<a.count;t++)i.setX(e+t,s+a.getX(t));for(let t=a.count,r=n;t<r;t++)i.setX(e+t,s);i.needsUpdate=!0,i.addUpdateRange(e,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){let t=this._geometryInfo;if(e>=t.length||t[e].active===!1)return this;let n=this._instanceInfo;for(let t=0,r=n.length;t<r;t++)n[t].active&&n[t].geometryIndex===e&&this.deleteInstance(t);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,n=this._geometryInfo,r=n.map((e,t)=>t).sort((e,t)=>n[e].vertexStart-n[t].vertexStart),i=this.geometry;for(let a=0,o=n.length;a<o;a++){let o=n[r[a]];if(o.active!==!1){if(i.index!==null){if(o.indexStart!==t){let{indexStart:n,vertexStart:r,reservedIndexCount:a}=o,s=i.index,c=s.array,l=e-r;for(let e=n;e<n+a;e++)c[e]=c[e]+l;s.array.copyWithin(t,n,n+a),s.addUpdateRange(t,a),s.needsUpdate=!0,o.indexStart=t}t+=o.reservedIndexCount}if(o.vertexStart!==e){let{vertexStart:t,reservedVertexCount:n}=o,r=i.attributes;for(let i in r){let a=r[i],{array:o,itemSize:s}=a;o.copyWithin(e*s,t*s,(t+n)*s),a.addUpdateRange(e*s,n*s),a.needsUpdate=!0}o.vertexStart=e}e+=o.reservedVertexCount,o.start=i.index?o.indexStart:o.vertexStart}}return this._nextIndexStart=t,this._nextVertexStart=e,this._visibilityChanged=!0,this}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;let n=this.geometry,r=this._geometryInfo[e];if(r.boundingBox===null){let e=new fi,t=n.index,i=n.attributes.position;for(let n=r.start,a=r.start+r.count;n<a;n++){let r=n;t&&(r=t.getX(r)),e.expandByPoint(Ro.fromBufferAttribute(i,r))}r.boundingBox=e}return t.copy(r.boundingBox),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;let n=this.geometry,r=this._geometryInfo[e];if(r.boundingSphere===null){let t=new qi;this.getBoundingBoxAt(e,Io),Io.getCenter(t.center);let i=n.index,a=n.attributes.position,o=0;for(let e=r.start,n=r.start+r.count;e<n;e++){let n=e;i&&(n=i.getX(n)),Ro.fromBufferAttribute(a,n),o=Math.max(o,t.center.distanceToSquared(Ro))}t.radius=Math.sqrt(o),r.boundingSphere=t}return t.copy(r.boundingSphere),t}setMatrixAt(e,t){this.validateInstanceId(e);let 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),this._colorsTexture===null?t.isVector4?t.set(1,1,1,1):t.setRGB(1,1,1):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);let 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){let t=this._availableInstanceIds,n=this._instanceInfo;for(t.sort(Oo);t[t.length-1]===n.length-1;)n.pop(),t.pop();if(e<n.length)throw Error(`THREE.BatchedMesh: Instance ids outside the range ${e} are being used. Cannot shrink instance count.`);let r=new Int32Array(e),i=new Int32Array(e);Go(this._multiDrawCounts,r),Go(this._multiDrawStarts,i),this._multiDrawCounts=r,this._multiDrawStarts=i,this._maxInstanceCount=e;let a=this._indirectTexture,o=this._matricesTexture,s=this._colorsTexture;a.dispose(),this._initIndirectTexture(),Go(a.image.data,this._indirectTexture.image.data),o.dispose(),this._initMatricesTexture(),Go(o.image.data,this._matricesTexture.image.data),s&&(s.dispose(),this._initColorsTexture(),Go(s.image.data,this._colorsTexture.image.data))}setGeometrySize(e,t){let n=[...this._geometryInfo].filter(e=>e.active);if(Math.max(...n.map(e=>e.vertexStart+e.reservedVertexCount))>e)throw Error(`THREE.BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map(e=>e.indexStart+e.reservedIndexCount))>t)throw Error(`THREE.BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);let r=this.geometry;r.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new W,this._initializeGeometry(r));let i=this.geometry;r.index&&Go(r.index.array,i.index.array);for(let e in r.attributes)Go(r.attributes[e].array,i.attributes[e].array)}raycast(e,t){let n=this._instanceInfo,r=this._geometryInfo,i=this.matrixWorld,a=this.geometry;Ho.material=this.material,Ho.geometry.index=a.index,Ho.geometry.attributes=a.attributes,Ho.geometry.boundingBox===null&&(Ho.geometry.boundingBox=new fi),Ho.geometry.boundingSphere===null&&(Ho.geometry.boundingSphere=new qi);for(let a=0,o=n.length;a<o;a++){if(!n[a].visible||!n[a].active)continue;let o=n[a].geometryIndex,s=r[o];Ho.geometry.setDrawRange(s.start,s.count),this.getMatrixAt(a,Ho.matrixWorld).premultiply(i),this.getBoundingBoxAt(o,Ho.geometry.boundingBox),this.getBoundingSphereAt(o,Ho.geometry.boundingSphere),Ho.raycast(e,Uo);for(let e=0,n=Uo.length;e<n;e++){let n=Uo[e];n.object=this,n.batchId=a,t.push(n)}Uo.length=0}Ho.material=null,Ho.geometry.index=null,Ho.geometry.attributes={},Ho.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?null:e.boundingBox.clone(),this.boundingSphere=e.boundingSphere===null?null:e.boundingSphere.clone(),this._geometryInfo=e._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox===null?null:e.boundingBox.clone(),boundingSphere:e.boundingSphere===null?null:e.boundingSphere.clone()})),this._instanceInfo=e._instanceInfo.map(e=>({...e})),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,i){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;let a=r.getIndex(),o=a===null?1:a.array.BYTES_PER_ELEMENT,s=1;i.wireframe&&(s=2,o=r.attributes.position.count>65535?4:2);let c=this._instanceInfo,l=this._multiDrawStarts,u=this._multiDrawCounts,d=this._geometryInfo,f=this.perObjectFrustumCulled,p=this._indirectTexture,m=p.image.data,h=n.isArrayCamera?Fo:Po;f&&(n.isArrayCamera?h.setFromArrayCamera(n):(Mo.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),h.setFromProjectionMatrix(Mo,n.coordinateSystem,n.reversedDepth)));let g=0;if(this.sortObjects){Mo.copy(this.matrixWorld).invert(),Ro.setFromMatrixPosition(n.matrixWorld).applyMatrix4(Mo),zo.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(Mo);for(let e=0,t=c.length;e<t;e++)if(c[e].visible&&c[e].active){let t=c[e].geometryIndex;this.getMatrixAt(e,Mo),this.getBoundingSphereAt(t,Lo).applyMatrix4(Mo);let n=!1;if(f&&(n=!h.intersectsSphere(Lo)),!n){let n=d[t],r=Bo.subVectors(Lo.center,Ro).dot(zo);Vo.push(n.start,n.count,r,e)}}let e=Vo.list,t=this.customSort;t===null?e.sort(i.transparent?Ao:ko):t.call(this,e,n);for(let t=0,n=e.length;t<n;t++){let n=e[t];l[g]=n.start*o*s,u[g]=n.count*s,m[g]=n.index,g++}Vo.reset()}else for(let e=0,t=c.length;e<t;e++)if(c[e].visible&&c[e].active){let t=c[e].geometryIndex,n=!1;if(f&&(this.getMatrixAt(e,Mo),this.getBoundingSphereAt(t,Lo).applyMatrix4(Mo),n=!h.intersectsSphere(Lo)),!n){let n=d[t];l[g]=n.start*o*s,u[g]=n.count*s,m[g]=e,g++}}p.needsUpdate=!0,this._multiDrawCount=g,this._visibilityChanged=!1}onBeforeShadow(e,t,n,r,i,a){this.onBeforeRender(e,null,r,i,a)}},qo=class extends aa{constructor(e){super(),this.isLineBasicMaterial=!0,this.type=`LineBasicMaterial`,this.color=new H(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}},Jo=new B,Yo=new B,Xo=new V,Zo=new Ma,Qo=new qi,$o=new B,es=new B,ts=class extends Br{constructor(e=new W,t=new qo){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(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let e=1,r=t.count;e<r;e++)Jo.fromBufferAttribute(t,e-1),Yo.fromBufferAttribute(t,e),n[e]=n[e-1],n[e]+=Jo.distanceTo(Yo);e.setAttribute(`lineDistance`,new U(n,1))}else P(`Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`);return this}raycast(e,t){let n=this.geometry,r=this.matrixWorld,i=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Qo.copy(n.boundingSphere),Qo.applyMatrix4(r),Qo.radius+=i,e.ray.intersectsSphere(Qo)===!1)return;Xo.copy(r).invert(),Zo.copy(e.ray).applyMatrix4(Xo);let o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,c=this.isLineSegments?2:1,l=n.index,u=n.attributes.position;if(l!==null){let n=Math.max(0,a.start),r=Math.min(l.count,a.start+a.count);for(let i=n,a=r-1;i<a;i+=c){let n=l.getX(i),r=l.getX(i+1),a=ns(this,e,Zo,s,n,r,i);a&&t.push(a)}if(this.isLineLoop){let i=l.getX(r-1),a=l.getX(n),o=ns(this,e,Zo,s,i,a,r-1);o&&t.push(o)}}else{let n=Math.max(0,a.start),r=Math.min(u.count,a.start+a.count);for(let i=n,a=r-1;i<a;i+=c){let n=ns(this,e,Zo,s,i,i+1,i);n&&t.push(n)}if(this.isLineLoop){let i=ns(this,e,Zo,s,r-1,n,r-1);i&&t.push(i)}}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}};function ns(e,t,n,r,i,a,o){let s=e.geometry.attributes.position;if(Jo.fromBufferAttribute(s,i),Yo.fromBufferAttribute(s,a),n.distanceSqToSegment(Jo,Yo,$o,es)>r)return;$o.applyMatrix4(e.matrixWorld);let c=t.ray.origin.distanceTo($o);if(!(c<t.near||c>t.far))return{distance:c,point:es.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var rs=new B,is=new B,as=class extends ts{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type=`LineSegments`}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let e=0,r=t.count;e<r;e+=2)rs.fromBufferAttribute(t,e),is.fromBufferAttribute(t,e+1),n[e]=e===0?0:n[e-1],n[e+1]=n[e]+rs.distanceTo(is);e.setAttribute(`lineDistance`,new U(n,1))}else P(`LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`);return this}},os=class extends ts{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type=`LineLoop`}},ss=class extends aa{constructor(e){super(),this.isPointsMaterial=!0,this.type=`PointsMaterial`,this.color=new H(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}},cs=new V,ls=new Ma,us=new qi,ds=new B,fs=class extends Br{constructor(e=new W,t=new ss){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){let n=this.geometry,r=this.matrixWorld,i=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),us.copy(n.boundingSphere),us.applyMatrix4(r),us.radius+=i,e.ray.intersectsSphere(us)===!1)return;cs.copy(r).invert(),ls.copy(e.ray).applyMatrix4(cs);let o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,c=n.index,l=n.attributes.position;if(c!==null){let n=Math.max(0,a.start),i=Math.min(c.count,a.start+a.count);for(let a=n,o=i;a<o;a++){let n=c.getX(a);ds.fromBufferAttribute(l,n),ps(ds,n,s,r,e,t,this)}}else{let n=Math.max(0,a.start),i=Math.min(l.count,a.start+a.count);for(let a=n,o=i;a<o;a++)ds.fromBufferAttribute(l,a),ps(ds,a,s,r,e,t,this)}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}};function ps(e,t,n,r,i,a,o){let s=ls.distanceSqToPoint(e);if(s<n){let n=new B;ls.closestPointToPoint(e,n),n.applyMatrix4(r);let c=i.ray.origin.distanceTo(n);if(c<i.near||c>i.far)return;a.push({distance:c,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}var ms=class extends or{constructor(e,t,n,r,i=A,a=A,o,s,c){super(e,t,n,r,i,a,o,s,c),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;let l=this;function u(){l.needsUpdate=!0,l._requestVideoFrameCallbackId=e.requestVideoFrameCallback(u)}`requestVideoFrameCallback`in e&&(this._requestVideoFrameCallbackId=e.requestVideoFrameCallback(u))}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;!(`requestVideoFrameCallback`in e)&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){this._requestVideoFrameCallbackId!==0&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}},hs=class extends ms{constructor(e,t,n,r,i,a,o,s){super({},e,t,n,r,i,a,o,s),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}},gs=class extends or{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=k,this.minFilter=k,this.generateMipmaps=!1,this.needsUpdate=!0}},_s=class extends or{constructor(e,t,n,r,i,a,o,s,c,l,u,d){super(null,a,o,s,c,l,r,i,u,d),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}},vs=class extends _s{constructor(e,t,n,r,i,a){super(e,t,n,i,a),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=O,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},ys=class extends _s{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,301),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}},bs=class extends or{constructor(e=[],t=301,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,s,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},xs=class extends or{constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r,i,a,o,s,c),this.isCanvasTexture=!0,this.needsUpdate=!0}},Ss=class extends or{constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r,i,a,o,s,c),this.isHTMLTexture=!0,this.generateMipmaps=!1,this.needsUpdate=!0;let l=e?e.parentNode:null;l!==null&&`requestPaint`in l&&(l.onpaint=()=>{this.needsUpdate=!0},l.requestPaint())}dispose(){let e=this.image?this.image.parentNode:null;e!==null&&`onpaint`in e&&(e.onpaint=null),super.dispose()}},Cs=class extends or{constructor(e,t,n=fe,r,i,a,o=k,s=k,c,l=Ce,u=1){if(l!==1026&&l!==1027)throw Error(`THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat`);super({width:e,height:t,depth:u},r,i,a,o,s,l,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new nr(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},ws=class extends Cs{constructor(e,t=fe,n=301,r,i,a=k,o=k,s,c=Ce){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,r,i,a,o,s,c),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},Ts=class extends or{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},Es=class e extends W{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type=`BoxGeometry`,this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let s=[],c=[],l=[],u=[],d=0,f=0;p(`z`,`y`,`x`,-1,-1,n,t,e,a,i,0),p(`z`,`y`,`x`,1,-1,n,t,-e,a,i,1),p(`x`,`z`,`y`,1,1,e,n,t,r,a,2),p(`x`,`z`,`y`,1,-1,e,n,-t,r,a,3),p(`x`,`y`,`z`,1,-1,e,t,n,r,i,4),p(`x`,`y`,`z`,-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute(`position`,new U(c,3)),this.setAttribute(`normal`,new U(l,3)),this.setAttribute(`uv`,new U(u,2));function p(e,t,n,r,i,a,p,m,h,g,_){let v=a/h,y=p/g,b=a/2,x=p/2,S=m/2,C=h+1,w=g+1,T=0,E=0,D=new B;for(let a=0;a<w;a++){let o=a*y-x;for(let s=0;s<C;s++)D[e]=(s*v-b)*r,D[t]=o*i,D[n]=S,c.push(D.x,D.y,D.z),D[e]=0,D[t]=0,D[n]=m>0?1:-1,l.push(D.x,D.y,D.z),u.push(s/h),u.push(1-a/g),T+=1}for(let e=0;e<g;e++)for(let t=0;t<h;t++){let n=d+t+C*e,r=d+t+C*(e+1),i=d+(t+1)+C*(e+1),a=d+(t+1)+C*e;s.push(n,r,a),s.push(r,i,a),E+=6}o.addGroup(f,E,_),f+=E,d+=T}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}},Ds=class e extends W{constructor(e=1,t=1,n=4,r=8,i=1){super(),this.type=`CapsuleGeometry`,this.parameters={radius:e,height:t,capSegments:n,radialSegments:r,heightSegments:i},t=Math.max(0,t),n=Math.max(1,Math.floor(n)),r=Math.max(3,Math.floor(r)),i=Math.max(1,Math.floor(i));let a=[],o=[],s=[],c=[],l=t/2,u=Math.PI/2*e,d=t,f=2*u+d,p=n*2+i,m=r+1,h=new B,g=new B;for(let _=0;_<=p;_++){let v=0,y=0,b=0,x=0;if(_<=n){let t=_/n,r=t*Math.PI/2;y=-l-e*Math.cos(r),b=e*Math.sin(r),x=-e*Math.cos(r),v=t*u}else if(_<=n+i){let r=(_-n)/i;y=-l+r*t,b=e,x=0,v=u+r*d}else{let t=(_-n-i)/n,r=t*Math.PI/2;y=l+e*Math.sin(r),b=e*Math.cos(r),x=e*Math.sin(r),v=u+d+t*u}let S=Math.max(0,Math.min(1,v/f)),C=0;_===0?C=.5/r:_===p&&(C=-.5/r);for(let e=0;e<=r;e++){let t=e/r,n=t*Math.PI*2,i=Math.sin(n),a=Math.cos(n);g.x=-b*a,g.y=y,g.z=b*i,o.push(g.x,g.y,g.z),h.set(-b*a,x,b*i),h.normalize(),s.push(h.x,h.y,h.z),c.push(t+C,S)}if(_>0){let e=(_-1)*m;for(let t=0;t<r;t++){let n=e+t,r=e+t+1,i=_*m+t,o=_*m+t+1;a.push(n,r,i),a.push(r,o,i)}}}this.setIndex(a),this.setAttribute(`position`,new U(o,3)),this.setAttribute(`normal`,new U(s,3)),this.setAttribute(`uv`,new U(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radius,t.height,t.capSegments,t.radialSegments,t.heightSegments)}},Os=class e extends W{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);let i=[],a=[],o=[],s=[],c=new B,l=new R;a.push(0,0,0),o.push(0,0,1),s.push(.5,.5);for(let i=0,u=3;i<=t;i++,u+=3){let d=n+i/t*r;c.x=e*Math.cos(d),c.y=e*Math.sin(d),a.push(c.x,c.y,c.z),o.push(0,0,1),l.x=(a[u]/e+1)/2,l.y=(a[u+1]/e+1)/2,s.push(l.x,l.y)}for(let e=1;e<=t;e++)i.push(e,e+1,0);this.setIndex(i),this.setAttribute(`position`,new U(a,3)),this.setAttribute(`normal`,new U(o,3)),this.setAttribute(`uv`,new U(s,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radius,t.segments,t.thetaStart,t.thetaLength)}},ks=class e extends W{constructor(e=1,t=1,n=1,r=32,i=1,a=!1,o=0,s=Math.PI*2){super(),this.type=`CylinderGeometry`,this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:i,openEnded:a,thetaStart:o,thetaLength:s};let c=this;r=Math.floor(r),i=Math.floor(i);let l=[],u=[],d=[],f=[],p=0,m=[],h=n/2,g=0;_(),a===!1&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(l),this.setAttribute(`position`,new U(u,3)),this.setAttribute(`normal`,new U(d,3)),this.setAttribute(`uv`,new U(f,2));function _(){let a=new B,_=new B,v=0,y=(t-e)/n;for(let c=0;c<=i;c++){let l=[],g=c/i,v=g*(t-e)+e;for(let e=0;e<=r;e++){let t=e/r,i=t*s+o,c=Math.sin(i),m=Math.cos(i);_.x=v*c,_.y=-g*n+h,_.z=v*m,u.push(_.x,_.y,_.z),a.set(c,y,m).normalize(),d.push(a.x,a.y,a.z),f.push(t,1-g),l.push(p++)}m.push(l)}for(let n=0;n<r;n++)for(let r=0;r<i;r++){let a=m[r][n],o=m[r+1][n],s=m[r+1][n+1],c=m[r][n+1];(e>0||r!==0)&&(l.push(a,o,c),v+=3),(t>0||r!==i-1)&&(l.push(o,s,c),v+=3)}c.addGroup(g,v,0),g+=v}function v(n){let i=p,a=new R,m=new B,_=0,v=n===!0?e:t,y=n===!0?1:-1;for(let e=1;e<=r;e++)u.push(0,h*y,0),d.push(0,y,0),f.push(.5,.5),p++;let b=p;for(let e=0;e<=r;e++){let t=e/r*s+o,n=Math.cos(t),i=Math.sin(t);m.x=v*i,m.y=h*y,m.z=v*n,u.push(m.x,m.y,m.z),d.push(0,y,0),a.x=n*.5+.5,a.y=i*.5*y+.5,f.push(a.x,a.y),p++}for(let e=0;e<r;e++){let t=i+e,r=b+e;n===!0?l.push(r,r+1,t):l.push(r+1,r,t),_+=3}c.addGroup(g,_,n===!0?1:2),g+=_}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},As=class e extends ks{constructor(e=1,t=1,n=32,r=1,i=!1,a=0,o=Math.PI*2){super(0,e,t,n,r,i,a,o),this.type=`ConeGeometry`,this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:a,thetaLength:o}}static fromJSON(t){return new e(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},js=class e extends W{constructor(e=[],t=[],n=1,r=0){super(),this.type=`PolyhedronGeometry`,this.parameters={vertices:e,indices:t,radius:n,detail:r};let i=[],a=[];o(r),c(n),l(),this.setAttribute(`position`,new U(i,3)),this.setAttribute(`normal`,new U(i.slice(),3)),this.setAttribute(`uv`,new U(a,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function o(e){let n=new B,r=new B,i=new B;for(let a=0;a<t.length;a+=3)f(t[a+0],n),f(t[a+1],r),f(t[a+2],i),s(n,r,i,e)}function s(e,t,n,r){let i=r+1,a=[];for(let r=0;r<=i;r++){a[r]=[];let o=e.clone().lerp(n,r/i),s=t.clone().lerp(n,r/i),c=i-r;for(let e=0;e<=c;e++)e===0&&r===i?a[r][e]=o:a[r][e]=o.clone().lerp(s,e/c)}for(let e=0;e<i;e++)for(let t=0;t<2*(i-e)-1;t++){let n=Math.floor(t/2);t%2==0?(d(a[e][n+1]),d(a[e+1][n]),d(a[e][n])):(d(a[e][n+1]),d(a[e+1][n+1]),d(a[e+1][n]))}}function c(e){let t=new B;for(let n=0;n<i.length;n+=3)t.x=i[n+0],t.y=i[n+1],t.z=i[n+2],t.normalize().multiplyScalar(e),i[n+0]=t.x,i[n+1]=t.y,i[n+2]=t.z}function l(){let e=new B;for(let t=0;t<i.length;t+=3){e.x=i[t+0],e.y=i[t+1],e.z=i[t+2];let n=h(e)/2/Math.PI+.5,r=g(e)/Math.PI+.5;a.push(n,1-r)}p(),u()}function u(){for(let e=0;e<a.length;e+=6){let t=a[e+0],n=a[e+2],r=a[e+4];Math.max(t,n,r)>.9&&Math.min(t,n,r)<.1&&(t<.2&&(a[e+0]+=1),n<.2&&(a[e+2]+=1),r<.2&&(a[e+4]+=1))}}function d(e){i.push(e.x,e.y,e.z)}function f(t,n){let r=t*3;n.x=e[r+0],n.y=e[r+1],n.z=e[r+2]}function p(){let e=new B,t=new B,n=new B,r=new B,o=new R,s=new R,c=new R;for(let l=0,u=0;l<i.length;l+=9,u+=6){e.set(i[l+0],i[l+1],i[l+2]),t.set(i[l+3],i[l+4],i[l+5]),n.set(i[l+6],i[l+7],i[l+8]),o.set(a[u+0],a[u+1]),s.set(a[u+2],a[u+3]),c.set(a[u+4],a[u+5]),r.copy(e).add(t).add(n).divideScalar(3);let d=h(r);m(o,u+0,e,d),m(s,u+2,t,d),m(c,u+4,n,d)}}function m(e,t,n,r){r<0&&e.x===1&&(a[t]=e.x-1),n.x===0&&n.z===0&&(a[t]=r/2/Math.PI+.5)}function h(e){return Math.atan2(e.z,-e.x)}function g(e){return Math.atan2(-e.y,Math.sqrt(e.x*e.x+e.z*e.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.vertices,t.indices,t.radius,t.detail)}},Ms=class e extends js{constructor(e=1,t=0){let n=(1+Math.sqrt(5))/2,r=1/n,i=[-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];super(i,[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],e,t),this.type=`DodecahedronGeometry`,this.parameters={radius:e,detail:t}}static fromJSON(t){return new e(t.radius,t.detail)}},Ns=new B,Ps=new B,Fs=new B,Is=new di,Ls=class extends W{constructor(e=null,t=1){if(super(),this.type=`EdgesGeometry`,this.parameters={geometry:e,thresholdAngle:t},e!==null){let n=10**4,r=Math.cos(bn*t),i=e.getIndex(),a=e.getAttribute(`position`),o=i?i.count:a.count,s=[0,0,0],c=[`a`,`b`,`c`],l=[,,,],u={},d=[];for(let e=0;e<o;e+=3){i?(s[0]=i.getX(e),s[1]=i.getX(e+1),s[2]=i.getX(e+2)):(s[0]=e,s[1]=e+1,s[2]=e+2);let{a:t,b:o,c:f}=Is;if(t.fromBufferAttribute(a,s[0]),o.fromBufferAttribute(a,s[1]),f.fromBufferAttribute(a,s[2]),Is.getNormal(Fs),l[0]=`${Math.round(t.x*n)},${Math.round(t.y*n)},${Math.round(t.z*n)}`,l[1]=`${Math.round(o.x*n)},${Math.round(o.y*n)},${Math.round(o.z*n)}`,l[2]=`${Math.round(f.x*n)},${Math.round(f.y*n)},${Math.round(f.z*n)}`,l[0]!==l[1]&&l[1]!==l[2]&&l[2]!==l[0])for(let e=0;e<3;e++){let t=(e+1)%3,n=l[e],i=l[t],a=Is[c[e]],o=Is[c[t]],f=`${n}_${i}`,p=`${i}_${n}`;p in u&&u[p]?(Fs.dot(u[p].normal)<=r&&(d.push(a.x,a.y,a.z),d.push(o.x,o.y,o.z)),u[p]=null):f in u||(u[f]={index0:s[e],index1:s[t],normal:Fs.clone()})}}for(let e in u)if(u[e]){let{index0:t,index1:n}=u[e];Ns.fromBufferAttribute(a,t),Ps.fromBufferAttribute(a,n),d.push(Ns.x,Ns.y,Ns.z),d.push(Ps.x,Ps.y,Ps.z)}this.setAttribute(`position`,new U(d,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}},Rs=class{constructor(){this.type=`Curve`,this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){P(`Curve: .getPoint() not implemented.`)}getPointAt(e,t){let n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){let 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;let t=[],n,r=this.getPoint(0),i=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),i+=n.distanceTo(r),t.push(i),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){let n=this.getLengths(),r=0,i=n.length,a;a=t||e*n[i-1];let o=0,s=i-1,c;for(;o<=s;)if(r=Math.floor(o+(s-o)/2),c=n[r]-a,c<0)o=r+1;else if(c>0)s=r-1;else{s=r;break}if(r=s,n[r]===a)return r/(i-1);let l=n[r],u=n[r+1]-l,d=(a-l)/u;return(r+d)/(i-1)}getTangent(e,t){let n=1e-4,r=e-n,i=e+n;r<0&&(r=0),i>1&&(i=1);let a=this.getPoint(r),o=this.getPoint(i),s=t||(a.isVector2?new R:new B);return s.copy(o).sub(a).normalize(),s}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){let n=new B,r=[],i=[],a=[],o=new B,s=new V;for(let t=0;t<=e;t++){let n=t/e;r[t]=this.getTangentAt(n,new B)}i[0]=new B,a[0]=new B;let c=Number.MAX_VALUE,l=Math.abs(r[0].x),u=Math.abs(r[0].y),d=Math.abs(r[0].z);l<=c&&(c=l,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),o.crossVectors(r[0],n).normalize(),i[0].crossVectors(r[0],o),a[0].crossVectors(r[0],i[0]);for(let t=1;t<=e;t++){if(i[t]=i[t-1].clone(),a[t]=a[t-1].clone(),o.crossVectors(r[t-1],r[t]),o.length()>2**-52){o.normalize();let e=Math.acos(I(r[t-1].dot(r[t]),-1,1));i[t].applyMatrix4(s.makeRotationAxis(o,e))}a[t].crossVectors(r[t],i[t])}if(t===!0){let t=Math.acos(I(i[0].dot(i[e]),-1,1));t/=e,r[0].dot(o.crossVectors(i[0],i[e]))>0&&(t=-t);for(let n=1;n<=e;n++)i[n].applyMatrix4(s.makeRotationAxis(r[n],t*n)),a[n].crossVectors(r[n],i[n])}return{tangents:r,normals:i,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let 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}},zs=class extends Rs{constructor(e=0,t=0,n=1,r=1,i=0,a=Math.PI*2,o=!1,s=0){super(),this.isEllipseCurve=!0,this.type=`EllipseCurve`,this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=i,this.aEndAngle=a,this.aClockwise=o,this.aRotation=s}getPoint(e,t=new R){let n=t,r=Math.PI*2,i=this.aEndAngle-this.aStartAngle,a=Math.abs(i)<2**-52;for(;i<0;)i+=r;for(;i>r;)i-=r;i<2**-52&&(i=a?0:r),this.aClockwise===!0&&!a&&(i===r?i=-r:i-=r);let o=this.aStartAngle+e*i,s=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){let e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),n=s-this.aX,r=c-this.aY;s=n*e-r*t+this.aX,c=n*t+r*e+this.aY}return n.set(s,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(){let 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}},Bs=class extends zs{constructor(e,t,n,r,i,a){super(e,t,n,n,r,i,a),this.isArcCurve=!0,this.type=`ArcCurve`}};function Vs(){let e=0,t=0,n=0,r=0;function i(i,a,o,s){e=i,t=o,n=-3*i+3*a-2*o-s,r=2*i-2*a+o+s}return{initCatmullRom:function(e,t,n,r,a){i(t,n,a*(n-e),a*(r-t))},initNonuniformCatmullRom:function(e,t,n,r,a,o,s){let c=(t-e)/a-(n-e)/(a+o)+(n-t)/o,l=(n-t)/o-(r-t)/(o+s)+(r-n)/s;c*=o,l*=o,i(t,n,c,l)},calc:function(i){let a=i*i,o=a*i;return e+t*i+n*a+r*o}}}var Hs=new B,Us=new B,Ws=new Vs,Gs=new Vs,Ks=new Vs,qs=class extends Rs{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 B){let n=t,r=this.points,i=r.length,a=(i-+!this.closed)*e,o=Math.floor(a),s=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/i)+1)*i:s===0&&o===i-1&&(o=i-2,s=1);let c,l;this.closed||o>0?c=r[(o-1)%i]:(Us.subVectors(r[0],r[1]).add(r[0]),c=Us);let u=r[o%i],d=r[(o+1)%i];if(this.closed||o+2<i?l=r[(o+2)%i]:(Hs.subVectors(r[i-1],r[i-2]).add(r[i-1]),l=Hs),this.curveType===`centripetal`||this.curveType===`chordal`){let e=this.curveType===`chordal`?.5:.25,t=c.distanceToSquared(u)**+e,n=u.distanceToSquared(d)**+e,r=d.distanceToSquared(l)**+e;n<1e-4&&(n=1),t<1e-4&&(t=n),r<1e-4&&(r=n),Ws.initNonuniformCatmullRom(c.x,u.x,d.x,l.x,t,n,r),Gs.initNonuniformCatmullRom(c.y,u.y,d.y,l.y,t,n,r),Ks.initNonuniformCatmullRom(c.z,u.z,d.z,l.z,t,n,r)}else this.curveType===`catmullrom`&&(Ws.initCatmullRom(c.x,u.x,d.x,l.x,this.tension),Gs.initCatmullRom(c.y,u.y,d.y,l.y,this.tension),Ks.initCatmullRom(c.z,u.z,d.z,l.z,this.tension));return n.set(Ws.calc(s),Gs.calc(s),Ks.calc(s)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(n.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let n=this.points[t];e.points.push(n.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++){let n=e.points[t];this.points.push(new B().fromArray(n))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function Js(e,t,n,r,i){let a=(r-t)*.5,o=(i-n)*.5,s=e*e,c=e*s;return(2*n-2*r+a+o)*c+(-3*n+3*r-2*a-o)*s+a*e+n}function Ys(e,t){let n=1-e;return n*n*t}function Xs(e,t){return 2*(1-e)*e*t}function Zs(e,t){return e*e*t}function Qs(e,t,n,r){return Ys(e,t)+Xs(e,n)+Zs(e,r)}function $s(e,t){let n=1-e;return n*n*n*t}function ec(e,t){let n=1-e;return 3*n*n*e*t}function tc(e,t){return 3*(1-e)*e*e*t}function nc(e,t){return e*e*e*t}function rc(e,t,n,r,i){return $s(e,t)+ec(e,n)+tc(e,r)+nc(e,i)}var ic=class extends Rs{constructor(e=new R,t=new R,n=new R,r=new R){super(),this.isCubicBezierCurve=!0,this.type=`CubicBezierCurve`,this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new R){let n=t,r=this.v0,i=this.v1,a=this.v2,o=this.v3;return n.set(rc(e,r.x,i.x,a.x,o.x),rc(e,r.y,i.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(){let 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}},ac=class extends Rs{constructor(e=new B,t=new B,n=new B,r=new B){super(),this.isCubicBezierCurve3=!0,this.type=`CubicBezierCurve3`,this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new B){let n=t,r=this.v0,i=this.v1,a=this.v2,o=this.v3;return n.set(rc(e,r.x,i.x,a.x,o.x),rc(e,r.y,i.y,a.y,o.y),rc(e,r.z,i.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(){let 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}},oc=class extends Rs{constructor(e=new R,t=new R){super(),this.isLineCurve=!0,this.type=`LineCurve`,this.v1=e,this.v2=t}getPoint(e,t=new R){let 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 R){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(){let 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}},sc=class extends Rs{constructor(e=new B,t=new B){super(),this.isLineCurve3=!0,this.type=`LineCurve3`,this.v1=e,this.v2=t}getPoint(e,t=new B){let 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 B){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(){let 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}},cc=class extends Rs{constructor(e=new R,t=new R,n=new R){super(),this.isQuadraticBezierCurve=!0,this.type=`QuadraticBezierCurve`,this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new R){let n=t,r=this.v0,i=this.v1,a=this.v2;return n.set(Qs(e,r.x,i.x,a.x),Qs(e,r.y,i.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(){let 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}},lc=class extends Rs{constructor(e=new B,t=new B,n=new B){super(),this.isQuadraticBezierCurve3=!0,this.type=`QuadraticBezierCurve3`,this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new B){let n=t,r=this.v0,i=this.v1,a=this.v2;return n.set(Qs(e,r.x,i.x,a.x),Qs(e,r.y,i.y,a.y),Qs(e,r.z,i.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(){let 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}},uc=class extends Rs{constructor(e=[]){super(),this.isSplineCurve=!0,this.type=`SplineCurve`,this.points=e}getPoint(e,t=new R){let n=t,r=this.points,i=(r.length-1)*e,a=Math.floor(i),o=i-a,s=r[a===0?a:a-1],c=r[a],l=r[a>r.length-2?r.length-1:a+1],u=r[a>r.length-3?r.length-1:a+2];return n.set(Js(o,s.x,c.x,l.x,u.x),Js(o,s.y,c.y,l.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(n.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let n=this.points[t];e.points.push(n.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(new R().fromArray(n))}return this}},dc=Object.freeze({__proto__:null,ArcCurve:Bs,CatmullRomCurve3:qs,CubicBezierCurve:ic,CubicBezierCurve3:ac,EllipseCurve:zs,LineCurve:oc,LineCurve3:sc,QuadraticBezierCurve:cc,QuadraticBezierCurve3:lc,SplineCurve:uc}),fc=class extends Rs{constructor(){super(),this.type=`CurvePath`,this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){let n=e.isVector2===!0?`LineCurve`:`LineCurve3`;this.curves.push(new dc[n](t,e))}return this}getPoint(e,t){let n=e*this.getLength(),r=this.getCurveLengths(),i=0;for(;i<r.length;){if(r[i]>=n){let e=r[i]-n,a=this.curves[i],o=a.getLength(),s=o===0?0:1-e/o;return a.getPointAt(s,t)}i++}return null}getLength(){let 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;let e=[],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){let 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){let t=[],n;for(let r=0,i=this.curves;r<i.length;r++){let a=i[r],o=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,s=a.getPoints(o);for(let e=0;e<s.length;e++){let r=s[e];n&&n.equals(r)||(t.push(r),n=r)}}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++){let n=e.curves[t];this.curves.push(n.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){let n=this.curves[t];e.curves.push(n.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++){let n=e.curves[t];this.curves.push(new dc[n.type]().fromJSON(n))}return this}},pc=class extends fc{constructor(e){super(),this.type=`Path`,this.currentPoint=new R,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){let n=new oc(this.currentPoint.clone(),new R(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,r){let i=new cc(this.currentPoint.clone(),new R(e,t),new R(n,r));return this.curves.push(i),this.currentPoint.set(n,r),this}bezierCurveTo(e,t,n,r,i,a){let o=new ic(this.currentPoint.clone(),new R(e,t),new R(n,r),new R(i,a));return this.curves.push(o),this.currentPoint.set(i,a),this}splineThru(e){let t=new uc([this.currentPoint.clone()].concat(e));return this.curves.push(t),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,r,i,a){let o=this.currentPoint.x,s=this.currentPoint.y;return this.absarc(e+o,t+s,n,r,i,a),this}absarc(e,t,n,r,i,a){return this.absellipse(e,t,n,n,r,i,a),this}ellipse(e,t,n,r,i,a,o,s){let c=this.currentPoint.x,l=this.currentPoint.y;return this.absellipse(e+c,t+l,n,r,i,a,o,s),this}absellipse(e,t,n,r,i,a,o,s){let c=new zs(e,t,n,r,i,a,o,s);if(this.curves.length>0){let e=c.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(c);let l=c.getPoint(1);return this.currentPoint.copy(l),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},mc=class extends pc{constructor(e){super(e),this.uuid=Sn(),this.type=`Shape`,this.holes=[]}getPointsHoles(e){let 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++){let n=e.holes[t];this.holes.push(n.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){let n=this.holes[t];e.holes.push(n.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++){let n=e.holes[t];this.holes.push(new pc().fromJSON(n))}return this}};function hc(e,t,n=2){let r=t&&t.length,i=r?t[0]*n:e.length,a=gc(e,0,i,n,!0),o=[];if(!a||a.next===a.prev)return o;let s,c,l;if(r&&(a=Cc(e,t,a,n)),e.length>80*n){s=e[0],c=e[1];let t=s,r=c;for(let a=n;a<i;a+=n){let n=e[a],i=e[a+1];n<s&&(s=n),i<c&&(c=i),n>t&&(t=n),i>r&&(r=i)}l=Math.max(t-s,r-c),l=l===0?0:32767/l}return vc(a,o,n,s,c,l,0),o}function gc(e,t,n,r,i){let a;if(i===qc(e,t,n,r)>0)for(let i=t;i<n;i+=r)a=Wc(i/r|0,e[i],e[i+1],a);else for(let i=n-r;i>=t;i-=r)a=Wc(i/r|0,e[i],e[i+1],a);return a&&Ic(a,a.next)&&(Gc(a),a=a.next),a}function _c(e,t){if(!e)return e;t||=e;let n=e,r;do if(r=!1,!n.steiner&&(Ic(n,n.next)||Fc(n.prev,n,n.next)===0)){if(Gc(n),n=t=n.prev,n===n.next)break;r=!0}else n=n.next;while(r||n!==t);return t}function vc(e,t,n,r,i,a,o){if(!e)return;!o&&a&&Oc(e,r,i,a);let s=e;for(;e.prev!==e.next;){let c=e.prev,l=e.next;if(a?bc(e,r,i,a):yc(e)){t.push(c.i,e.i,l.i),Gc(e),e=l.next,s=l.next;continue}if(e=l,e===s){o?o===1?(e=xc(_c(e),t),vc(e,t,n,r,i,a,2)):o===2&&Sc(e,t,n,r,i,a):vc(_c(e),t,n,r,i,a,1);break}}}function yc(e){let t=e.prev,n=e,r=e.next;if(Fc(t,n,r)>=0)return!1;let i=t.x,a=n.x,o=r.x,s=t.y,c=n.y,l=r.y,u=Math.min(i,a,o),d=Math.min(s,c,l),f=Math.max(i,a,o),p=Math.max(s,c,l),m=r.next;for(;m!==t;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=p&&Nc(i,s,a,c,o,l,m.x,m.y)&&Fc(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function bc(e,t,n,r){let i=e.prev,a=e,o=e.next;if(Fc(i,a,o)>=0)return!1;let s=i.x,c=a.x,l=o.x,u=i.y,d=a.y,f=o.y,p=Math.min(s,c,l),m=Math.min(u,d,f),h=Math.max(s,c,l),g=Math.max(u,d,f),_=Ac(p,m,t,n,r),v=Ac(h,g,t,n,r),y=e.prevZ,b=e.nextZ;for(;y&&y.z>=_&&b&&b.z<=v;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&Nc(s,u,c,d,l,f,y.x,y.y)&&Fc(y.prev,y,y.next)>=0||(y=y.prevZ,b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&Nc(s,u,c,d,l,f,b.x,b.y)&&Fc(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;y&&y.z>=_;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&Nc(s,u,c,d,l,f,y.x,y.y)&&Fc(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;b&&b.z<=v;){if(b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&Nc(s,u,c,d,l,f,b.x,b.y)&&Fc(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function xc(e,t){let n=e;do{let r=n.prev,i=n.next.next;!Ic(r,i)&&Lc(r,n,n.next,i)&&Vc(r,i)&&Vc(i,r)&&(t.push(r.i,n.i,i.i),Gc(n),Gc(n.next),n=e=i),n=n.next}while(n!==e);return _c(n)}function Sc(e,t,n,r,i,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&Pc(o,e)){let s=Uc(o,e);o=_c(o,o.next),s=_c(s,s.next),vc(o,t,n,r,i,a,0),vc(s,t,n,r,i,a,0);return}e=e.next}o=o.next}while(o!==e)}function Cc(e,t,n,r){let i=[];for(let n=0,a=t.length;n<a;n++){let o=gc(e,t[n]*r,n<a-1?t[n+1]*r:e.length,r,!1);o===o.next&&(o.steiner=!0),i.push(jc(o))}i.sort(wc);for(let e=0;e<i.length;e++)n=Tc(i[e],n);return n}function wc(e,t){let n=e.x-t.x;return n===0&&(n=e.y-t.y,n===0&&(n=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x))),n}function Tc(e,t){let n=Ec(e,t);if(!n)return t;let r=Uc(n,e);return _c(r,r.next),_c(n,n.next)}function Ec(e,t){let n=t,r=e.x,i=e.y,a=-1/0,o;if(Ic(e,n))return n;do{if(Ic(e,n.next))return n.next;if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){let e=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=r&&e>a&&(a=e,o=n.x<n.next.x?n:n.next,e===r))return o}n=n.next}while(n!==t);if(!o)return null;let s=o,c=o.x,l=o.y,u=1/0;n=o;do{if(r>=n.x&&n.x>=c&&r!==n.x&&Mc(i<l?r:a,i,c,l,i<l?a:r,i,n.x,n.y)){let t=Math.abs(i-n.y)/(r-n.x);Vc(n,e)&&(t<u||t===u&&(n.x>o.x||n.x===o.x&&Dc(o,n)))&&(o=n,u=t)}n=n.next}while(n!==s);return o}function Dc(e,t){return Fc(e.prev,e,t.prev)<0&&Fc(t.next,e,e.next)<0}function Oc(e,t,n,r){let i=e;do i.z===0&&(i.z=Ac(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,kc(i)}function kc(e){let t,n=1;do{let r=e,i;e=null;let a=null;for(t=0;r;){t++;let o=r,s=0;for(let e=0;e<n&&(s++,o=o.nextZ,o);e++);let c=n;for(;s>0||c>0&&o;)s!==0&&(c===0||!o||r.z<=o.z)?(i=r,r=r.nextZ,s--):(i=o,o=o.nextZ,c--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;r=o}a.nextZ=null,n*=2}while(t>1);return e}function Ac(e,t,n,r,i){return e=(e-n)*i|0,t=(t-r)*i|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function jc(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function Mc(e,t,n,r,i,a,o,s){return(i-o)*(t-s)>=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function Nc(e,t,n,r,i,a,o,s){return(e!==o||t!==s)&&Mc(e,t,n,r,i,a,o,s)}function Pc(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Bc(e,t)&&(Vc(e,t)&&Vc(t,e)&&Hc(e,t)&&(Fc(e.prev,e,t.prev)||Fc(e,t.prev,t))||Ic(e,t)&&Fc(e.prev,e,e.next)>0&&Fc(t.prev,t,t.next)>0)}function Fc(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Ic(e,t){return e.x===t.x&&e.y===t.y}function Lc(e,t,n,r){let i=zc(Fc(e,t,n)),a=zc(Fc(e,t,r)),o=zc(Fc(n,r,e)),s=zc(Fc(n,r,t));return!!(i!==a&&o!==s||i===0&&Rc(e,n,t)||a===0&&Rc(e,r,t)||o===0&&Rc(n,e,r)||s===0&&Rc(n,t,r))}function Rc(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function zc(e){return e>0?1:e<0?-1:0}function Bc(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&Lc(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function Vc(e,t){return Fc(e.prev,e,e.next)<0?Fc(e,t,e.next)>=0&&Fc(e,e.prev,t)>=0:Fc(e,t,e.prev)<0||Fc(e,e.next,t)<0}function Hc(e,t){let n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==e);return r}function Uc(e,t){let n=Kc(e.i,e.x,e.y),r=Kc(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function Wc(e,t,n,r){let i=Kc(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Gc(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Kc(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function qc(e,t,n,r){let i=0;for(let a=t,o=n-r;a<n;a+=r)i+=(e[o]-e[a])*(e[a+1]+e[o+1]),o=a;return i}var Jc=class{static triangulate(e,t,n=2){return hc(e,t,n)}},Yc=class e{static area(e){let t=e.length,n=0;for(let r=t-1,i=0;i<t;r=i++)n+=e[r].x*e[i].y-e[i].x*e[r].y;return n*.5}static isClockWise(t){return e.area(t)<0}static triangulateShape(e,t){let n=[],r=[],i=[];Xc(e),Zc(n,e);let a=e.length;t.forEach(Xc);for(let e=0;e<t.length;e++)r.push(a),a+=t[e].length,Zc(n,t[e]);let o=Jc.triangulate(n,r);for(let e=0;e<o.length;e+=3)i.push(o.slice(e,e+3));return i}};function Xc(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function Zc(e,t){for(let n=0;n<t.length;n++)e.push(t[n].x),e.push(t[n].y)}var Qc=class e extends W{constructor(e=new mc([new R(.5,.5),new R(-.5,.5),new R(-.5,-.5),new R(.5,-.5)]),t={}){super(),this.type=`ExtrudeGeometry`,this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];let n=this,r=[],i=[];for(let t=0,n=e.length;t<n;t++){let n=e[t];a(n)}this.setAttribute(`position`,new U(r,3)),this.setAttribute(`uv`,new U(i,2)),this.computeVertexNormals();function a(e){let a=[],o=t.curveSegments===void 0?12:t.curveSegments,s=t.steps===void 0?1:t.steps,c=t.depth===void 0?1:t.depth,l=t.bevelEnabled===void 0||t.bevelEnabled,u=t.bevelThickness===void 0?.2:t.bevelThickness,d=t.bevelSize===void 0?u-.1:t.bevelSize,f=t.bevelOffset===void 0?0:t.bevelOffset,p=t.bevelSegments===void 0?3:t.bevelSegments,m=t.extrudePath,h=t.UVGenerator===void 0?$c:t.UVGenerator,g,_=!1,v,y,b,x;if(m){g=m.getSpacedPoints(s),_=!0,l=!1;let e=m.isCatmullRomCurve3?m.closed:!1;v=m.computeFrenetFrames(s,e),y=new B,b=new B,x=new B}l||(p=0,u=0,d=0,f=0);let S=e.extractPoints(o),C=S.shape,w=S.holes;if(!Yc.isClockWise(C)){C=C.reverse();for(let e=0,t=w.length;e<t;e++){let t=w[e];Yc.isClockWise(t)&&(w[e]=t.reverse())}}function T(e){let t=e[0];for(let n=1;n<=e.length;n++){let r=n%e.length,i=e[r],a=i.x-t.x,o=i.y-t.y,s=a*a+o*o,c=Math.max(Math.abs(i.x),Math.abs(i.y),Math.abs(t.x),Math.abs(t.y));if(s<=10000000000000001e-36*c*c){e.splice(r,1),n--;continue}t=i}}T(C),w.forEach(T);let E=w.length,D=C;for(let e=0;e<E;e++){let t=w[e];C=C.concat(t)}function O(e,t,n){return t||F(`ExtrudeGeometry: vec does not exist`),e.clone().addScaledVector(t,n)}let ee=C.length;function k(e,t,n){let r,i,a,o=e.x-t.x,s=e.y-t.y,c=n.x-e.x,l=n.y-e.y,u=o*o+s*s,d=o*l-s*c;if(Math.abs(d)>2**-52){let d=Math.sqrt(u),f=Math.sqrt(c*c+l*l),p=t.x-s/d,m=t.y+o/d,h=n.x-l/f,g=n.y+c/f,_=((h-p)*l-(g-m)*c)/(o*l-s*c);r=p+o*_-e.x,i=m+s*_-e.y;let v=r*r+i*i;if(v<=2)return new R(r,i);a=Math.sqrt(v/2)}else{let e=!1;o>2**-52?c>2**-52&&(e=!0):o<-(2**-52)?c<-(2**-52)&&(e=!0):Math.sign(s)===Math.sign(l)&&(e=!0),e?(r=-s,i=o,a=Math.sqrt(u)):(r=o,i=s,a=Math.sqrt(u/2))}return new R(r/a,i/a)}let te=[];for(let e=0,t=D.length,n=t-1,r=e+1;e<t;e++,n++,r++)n===t&&(n=0),r===t&&(r=0),te[e]=k(D[e],D[n],D[r]);let ne=[],re,ie=te.concat();for(let e=0,t=E;e<t;e++){let t=w[e];re=[];for(let e=0,n=t.length,r=n-1,i=e+1;e<n;e++,r++,i++)r===n&&(r=0),i===n&&(i=0),re[e]=k(t[e],t[r],t[i]);ne.push(re),ie=ie.concat(re)}let A;if(p===0)A=Yc.triangulateShape(D,w);else{let e=[],t=[];for(let n=0;n<p;n++){let r=n/p,i=u*Math.cos(r*Math.PI/2),a=d*Math.sin(r*Math.PI/2)+f;for(let t=0,n=D.length;t<n;t++){let n=O(D[t],te[t],a);ce(n.x,n.y,-i),r===0&&e.push(n)}for(let e=0,n=E;e<n;e++){let n=w[e];re=ne[e];let o=[];for(let e=0,t=n.length;e<t;e++){let t=O(n[e],re[e],a);ce(t.x,t.y,-i),r===0&&o.push(t)}r===0&&t.push(o)}}A=Yc.triangulateShape(e,t)}let j=A.length,M=d+f;for(let e=0;e<ee;e++){let t=l?O(C[e],ie[e],M):C[e];_?(b.copy(v.normals[0]).multiplyScalar(t.x),y.copy(v.binormals[0]).multiplyScalar(t.y),x.copy(g[0]).add(b).add(y),ce(x.x,x.y,x.z)):ce(t.x,t.y,0)}for(let e=1;e<=s;e++)for(let t=0;t<ee;t++){let n=l?O(C[t],ie[t],M):C[t];_?(b.copy(v.normals[e]).multiplyScalar(n.x),y.copy(v.binormals[e]).multiplyScalar(n.y),x.copy(g[e]).add(b).add(y),ce(x.x,x.y,x.z)):ce(n.x,n.y,c/s*e)}for(let e=p-1;e>=0;e--){let t=e/p,n=u*Math.cos(t*Math.PI/2),r=d*Math.sin(t*Math.PI/2)+f;for(let e=0,t=D.length;e<t;e++){let t=O(D[e],te[e],r);ce(t.x,t.y,c+n)}for(let e=0,t=w.length;e<t;e++){let t=w[e];re=ne[e];for(let e=0,i=t.length;e<i;e++){let i=O(t[e],re[e],r);_?ce(i.x,i.y+g[s-1].y,g[s-1].x+n):ce(i.x,i.y,c+n)}}}ae(),oe();function ae(){let e=r.length/3;if(l){let e=0,t=ee*e;for(let e=0;e<j;e++){let n=A[e];le(n[2]+t,n[1]+t,n[0]+t)}e=s+p*2,t=ee*e;for(let e=0;e<j;e++){let n=A[e];le(n[0]+t,n[1]+t,n[2]+t)}}else{for(let e=0;e<j;e++){let t=A[e];le(t[2],t[1],t[0])}for(let e=0;e<j;e++){let t=A[e];le(t[0]+ee*s,t[1]+ee*s,t[2]+ee*s)}}n.addGroup(e,r.length/3-e,0)}function oe(){let e=r.length/3,t=0;se(D,t),t+=D.length;for(let e=0,n=w.length;e<n;e++){let n=w[e];se(n,t),t+=n.length}n.addGroup(e,r.length/3-e,1)}function se(e,t){let n=e.length;for(;--n>=0;){let r=n,i=n-1;i<0&&(i=e.length-1);for(let e=0,n=s+p*2;e<n;e++){let n=ee*e,a=ee*(e+1);ue(t+r+n,t+i+n,t+i+a,t+r+a)}}}function ce(e,t,n){a.push(e),a.push(t),a.push(n)}function le(e,t,i){de(e),de(t),de(i);let a=r.length/3,o=h.generateTopUV(n,r,a-3,a-2,a-1);fe(o[0]),fe(o[1]),fe(o[2])}function ue(e,t,i,a){de(e),de(t),de(a),de(t),de(i),de(a);let o=r.length/3,s=h.generateSideWallUV(n,r,o-6,o-3,o-2,o-1);fe(s[0]),fe(s[1]),fe(s[3]),fe(s[1]),fe(s[2]),fe(s[3])}function de(e){r.push(a[e*3+0]),r.push(a[e*3+1]),r.push(a[e*3+2])}function fe(e){i.push(e.x),i.push(e.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options;return el(t,n,e)}static fromJSON(t,n){let r=[];for(let e=0,i=t.shapes.length;e<i;e++){let i=n[t.shapes[e]];r.push(i)}let i=t.options.extrudePath;return i!==void 0&&(t.options.extrudePath=new dc[i.type]().fromJSON(i)),new e(r,t.options)}},$c={generateTopUV:function(e,t,n,r,i){let a=t[n*3],o=t[n*3+1],s=t[r*3],c=t[r*3+1],l=t[i*3],u=t[i*3+1];return[new R(a,o),new R(s,c),new R(l,u)]},generateSideWallUV:function(e,t,n,r,i,a){let o=t[n*3],s=t[n*3+1],c=t[n*3+2],l=t[r*3],u=t[r*3+1],d=t[r*3+2],f=t[i*3],p=t[i*3+1],m=t[i*3+2],h=t[a*3],g=t[a*3+1],_=t[a*3+2];return Math.abs(s-u)<Math.abs(o-l)?[new R(o,1-c),new R(l,1-d),new R(f,1-m),new R(h,1-_)]:[new R(s,1-c),new R(u,1-d),new R(p,1-m),new R(g,1-_)]}};function el(e,t,n){if(n.shapes=[],Array.isArray(e))for(let t=0,r=e.length;t<r;t++){let r=e[t];n.shapes.push(r.uuid)}else n.shapes.push(e.uuid);return n.options=Object.assign({},t),t.extrudePath!==void 0&&(n.options.extrudePath=t.extrudePath.toJSON()),n}var tl=class e extends js{constructor(e=1,t=0){let 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];super(r,[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],e,t),this.type=`IcosahedronGeometry`,this.parameters={radius:e,detail:t}}static fromJSON(t){return new e(t.radius,t.detail)}},nl=class e extends W{constructor(e=[new R(0,-.5),new R(.5,0),new R(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=I(r,0,Math.PI*2);let i=[],a=[],o=[],s=[],c=[],l=1/t,u=new B,d=new R,f=new B,p=new B,m=new B,h=0,g=0;for(let t=0;t<=e.length-1;t++)switch(t){case 0:h=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,f.x=g*1,f.y=-h,f.z=g*0,m.copy(f),f.normalize(),s.push(f.x,f.y,f.z);break;case e.length-1:s.push(m.x,m.y,m.z);break;default:h=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,f.x=g*1,f.y=-h,f.z=g*0,p.copy(f),f.x+=m.x,f.y+=m.y,f.z+=m.z,f.normalize(),s.push(f.x,f.y,f.z),m.copy(p)}for(let i=0;i<=t;i++){let f=n+i*l*r,p=Math.sin(f),m=Math.cos(f);for(let n=0;n<=e.length-1;n++){u.x=e[n].x*p,u.y=e[n].y,u.z=e[n].x*m,a.push(u.x,u.y,u.z),d.x=i/t,d.y=n/(e.length-1),o.push(d.x,d.y);let r=s[3*n+0]*p,l=s[3*n+1],f=s[3*n+0]*m;c.push(r,l,f)}}for(let n=0;n<t;n++)for(let t=0;t<e.length-1;t++){let r=t+n*e.length,a=r,o=r+e.length,s=r+e.length+1,c=r+1;i.push(a,o,c),i.push(s,c,o)}this.setIndex(i),this.setAttribute(`position`,new U(a,3)),this.setAttribute(`uv`,new U(o,2)),this.setAttribute(`normal`,new U(c,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.points,t.segments,t.phiStart,t.phiLength)}},rl=class e extends js{constructor(e=1,t=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],e,t),this.type=`OctahedronGeometry`,this.parameters={radius:e,detail:t}}static fromJSON(t){return new e(t.radius,t.detail)}},il=class e extends W{constructor(e=1,t=1,n=1,r=1){super(),this.type=`PlaneGeometry`,this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};let i=e/2,a=t/2,o=Math.floor(n),s=Math.floor(r),c=o+1,l=s+1,u=e/o,d=t/s,f=[],p=[],m=[],h=[];for(let e=0;e<l;e++){let t=e*d-a;for(let n=0;n<c;n++){let r=n*u-i;p.push(r,-t,0),m.push(0,0,1),h.push(n/o),h.push(1-e/s)}}for(let e=0;e<s;e++)for(let t=0;t<o;t++){let n=t+c*e,r=t+c*(e+1),i=t+1+c*(e+1),a=t+1+c*e;f.push(n,r,a),f.push(r,i,a)}this.setIndex(f),this.setAttribute(`position`,new U(p,3)),this.setAttribute(`normal`,new U(m,3)),this.setAttribute(`uv`,new U(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.widthSegments,t.heightSegments)}},al=class e extends W{constructor(e=.5,t=1,n=32,r=1,i=0,a=Math.PI*2){super(),this.type=`RingGeometry`,this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:r,thetaStart:i,thetaLength:a},n=Math.max(3,n),r=Math.max(1,r);let o=[],s=[],c=[],l=[],u=e,d=(t-e)/r,f=new B,p=new R;for(let e=0;e<=r;e++){for(let e=0;e<=n;e++){let r=i+e/n*a;f.x=u*Math.cos(r),f.y=u*Math.sin(r),s.push(f.x,f.y,f.z),c.push(0,0,1),p.x=(f.x/t+1)/2,p.y=(f.y/t+1)/2,l.push(p.x,p.y)}u+=d}for(let e=0;e<r;e++){let t=e*(n+1);for(let e=0;e<n;e++){let r=e+t,i=r,a=r+n+1,s=r+n+2,c=r+1;o.push(i,a,c),o.push(a,s,c)}}this.setIndex(o),this.setAttribute(`position`,new U(s,3)),this.setAttribute(`normal`,new U(c,3)),this.setAttribute(`uv`,new U(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}},ol=class e extends W{constructor(e=new mc([new R(0,.5),new R(-.5,-.5),new R(.5,-.5)]),t=12){super(),this.type=`ShapeGeometry`,this.parameters={shapes:e,curveSegments:t};let n=[],r=[],i=[],a=[],o=0,s=0;if(Array.isArray(e)===!1)c(e);else for(let t=0;t<e.length;t++)c(e[t]),this.addGroup(o,s,t),o+=s,s=0;this.setIndex(n),this.setAttribute(`position`,new U(r,3)),this.setAttribute(`normal`,new U(i,3)),this.setAttribute(`uv`,new U(a,2));function c(e){let o=r.length/3,c=e.extractPoints(t),l=c.shape,u=c.holes;Yc.isClockWise(l)===!1&&(l=l.reverse());for(let e=0,t=u.length;e<t;e++){let t=u[e];Yc.isClockWise(t)===!0&&(u[e]=t.reverse())}let d=Yc.triangulateShape(l,u);for(let e=0,t=u.length;e<t;e++){let t=u[e];l=l.concat(t)}for(let e=0,t=l.length;e<t;e++){let t=l[e];r.push(t.x,t.y,0),i.push(0,0,1),a.push(t.x,t.y)}for(let e=0,t=d.length;e<t;e++){let t=d[e],r=t[0]+o,i=t[1]+o,a=t[2]+o;n.push(r,i,a),s+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes;return sl(t,e)}static fromJSON(t,n){let r=[];for(let e=0,i=t.shapes.length;e<i;e++){let i=n[t.shapes[e]];r.push(i)}return new e(r,t.curveSegments)}};function sl(e,t){if(t.shapes=[],Array.isArray(e))for(let n=0,r=e.length;n<r;n++){let r=e[n];t.shapes.push(r.uuid)}else t.shapes.push(e.uuid);return t}var cl=class e extends W{constructor(e=1,t=32,n=16,r=0,i=Math.PI*2,a=0,o=Math.PI){super(),this.type=`SphereGeometry`,this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:r,phiLength:i,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));let s=Math.min(a+o,Math.PI),c=0,l=[],u=new B,d=new B,f=[],p=[],m=[],h=[];for(let f=0;f<=n;f++){let g=[],_=f/n,v=a+_*o,y=e*Math.cos(v),b=Math.sqrt(e*e-y*y),x=0;f===0&&a===0?x=.5/t:f===n&&s===Math.PI&&(x=-.5/t);for(let e=0;e<=t;e++){let n=e/t,a=r+n*i;u.x=-b*Math.cos(a),u.y=y,u.z=b*Math.sin(a),p.push(u.x,u.y,u.z),d.copy(u).normalize(),m.push(d.x,d.y,d.z),h.push(n+x,1-_),g.push(c++)}l.push(g)}for(let e=0;e<n;e++)for(let r=0;r<t;r++){let t=l[e][r+1],i=l[e][r],o=l[e+1][r],c=l[e+1][r+1];(e!==0||a>0)&&f.push(t,i,c),(e!==n-1||s<Math.PI)&&f.push(i,o,c)}this.setIndex(f),this.setAttribute(`position`,new U(p,3)),this.setAttribute(`normal`,new U(m,3)),this.setAttribute(`uv`,new U(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}},ll=class e extends js{constructor(e=1,t=0){super([1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],e,t),this.type=`TetrahedronGeometry`,this.parameters={radius:e,detail:t}}static fromJSON(t){return new e(t.radius,t.detail)}},ul=class e extends W{constructor(e=1,t=.4,n=12,r=48,i=Math.PI*2,a=0,o=Math.PI*2){super(),this.type=`TorusGeometry`,this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:r,arc:i,thetaStart:a,thetaLength:o},n=Math.floor(n),r=Math.floor(r);let s=[],c=[],l=[],u=[],d=new B,f=new B,p=new B;for(let s=0;s<=n;s++){let m=a+s/n*o;for(let a=0;a<=r;a++){let o=a/r*i;f.x=(e+t*Math.cos(m))*Math.cos(o),f.y=(e+t*Math.cos(m))*Math.sin(o),f.z=t*Math.sin(m),c.push(f.x,f.y,f.z),d.x=e*Math.cos(o),d.y=e*Math.sin(o),p.subVectors(f,d).normalize(),l.push(p.x,p.y,p.z),u.push(a/r),u.push(s/n)}}for(let e=1;e<=n;e++)for(let t=1;t<=r;t++){let n=(r+1)*e+t-1,i=(r+1)*(e-1)+t-1,a=(r+1)*(e-1)+t,o=(r+1)*e+t;s.push(n,i,o),s.push(i,a,o)}this.setIndex(s),this.setAttribute(`position`,new U(c,3)),this.setAttribute(`normal`,new U(l,3)),this.setAttribute(`uv`,new U(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}},dl=class e extends W{constructor(e=1,t=.4,n=64,r=8,i=2,a=3){super(),this.type=`TorusKnotGeometry`,this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:r,p:i,q:a},n=Math.floor(n),r=Math.floor(r);let o=[],s=[],c=[],l=[],u=new B,d=new B,f=new B,p=new B,m=new B,h=new B,g=new B;for(let o=0;o<=n;++o){let v=o/n*i*Math.PI*2;_(v,i,a,e,f),_(v+.01,i,a,e,p),h.subVectors(p,f),g.addVectors(p,f),m.crossVectors(h,g),g.crossVectors(m,h),m.normalize(),g.normalize();for(let e=0;e<=r;++e){let i=e/r*Math.PI*2,a=-t*Math.cos(i),p=t*Math.sin(i);u.x=f.x+(a*g.x+p*m.x),u.y=f.y+(a*g.y+p*m.y),u.z=f.z+(a*g.z+p*m.z),s.push(u.x,u.y,u.z),d.subVectors(u,f).normalize(),c.push(d.x,d.y,d.z),l.push(o/n),l.push(e/r)}}for(let e=1;e<=n;e++)for(let t=1;t<=r;t++){let n=(r+1)*(e-1)+(t-1),i=(r+1)*e+(t-1),a=(r+1)*e+t,s=(r+1)*(e-1)+t;o.push(n,i,s),o.push(i,a,s)}this.setIndex(o),this.setAttribute(`position`,new U(s,3)),this.setAttribute(`normal`,new U(c,3)),this.setAttribute(`uv`,new U(l,2));function _(e,t,n,r,i){let a=Math.cos(e),o=Math.sin(e),s=n/t*e,c=Math.cos(s);i.x=r*(2+c)*.5*a,i.y=r*(2+c)*o*.5,i.z=r*Math.sin(s)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}},fl=class e extends W{constructor(e=new lc(new B(-1,-1,0),new B(-1,1,0),new B(1,1,0)),t=64,n=1,r=8,i=!1){super(),this.type=`TubeGeometry`,this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:r,closed:i};let a=e.computeFrenetFrames(t,i);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;let o=new B,s=new B,c=new R,l=new B,u=[],d=[],f=[],p=[];m(),this.setIndex(p),this.setAttribute(`position`,new U(u,3)),this.setAttribute(`normal`,new U(d,3)),this.setAttribute(`uv`,new U(f,2));function m(){for(let e=0;e<t;e++)h(e);h(i===!1?t:0),_(),g()}function h(i){l=e.getPointAt(i/t,l);let c=a.normals[i],f=a.binormals[i];for(let e=0;e<=r;e++){let t=e/r*Math.PI*2,i=Math.sin(t),a=-Math.cos(t);s.x=a*c.x+i*f.x,s.y=a*c.y+i*f.y,s.z=a*c.z+i*f.z,s.normalize(),d.push(s.x,s.y,s.z),o.x=l.x+n*s.x,o.y=l.y+n*s.y,o.z=l.z+n*s.z,u.push(o.x,o.y,o.z)}}function g(){for(let e=1;e<=t;e++)for(let t=1;t<=r;t++){let n=(r+1)*(e-1)+(t-1),i=(r+1)*e+(t-1),a=(r+1)*e+t,o=(r+1)*(e-1)+t;p.push(n,i,o),p.push(i,a,o)}}function _(){for(let e=0;e<=t;e++)for(let n=0;n<=r;n++)c.x=e/t,c.y=n/r,f.push(c.x,c.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(t){return new e(new dc[t.path.type]().fromJSON(t.path),t.tubularSegments,t.radius,t.radialSegments,t.closed)}},pl=class extends W{constructor(e=null){if(super(),this.type=`WireframeGeometry`,this.parameters={geometry:e},e!==null){let t=[],n=new Set,r=new B,i=new B;if(e.index!==null){let a=e.attributes.position,o=e.index,s=e.groups;s.length===0&&(s=[{start:0,count:o.count,materialIndex:0}]);for(let e=0,c=s.length;e<c;++e){let c=s[e],l=c.start,u=c.count;for(let e=l,s=l+u;e<s;e+=3)for(let s=0;s<3;s++){let c=o.getX(e+s),l=o.getX(e+(s+1)%3);r.fromBufferAttribute(a,c),i.fromBufferAttribute(a,l),ml(r,i,n)===!0&&(t.push(r.x,r.y,r.z),t.push(i.x,i.y,i.z))}}}else{let a=e.attributes.position;for(let e=0,o=a.count/3;e<o;e++)for(let o=0;o<3;o++){let s=3*e+o,c=3*e+(o+1)%3;r.fromBufferAttribute(a,s),i.fromBufferAttribute(a,c),ml(r,i,n)===!0&&(t.push(r.x,r.y,r.z),t.push(i.x,i.y,i.z))}}this.setAttribute(`position`,new U(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}};function ml(e,t,n){let r=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`,i=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`;return n.has(r)===!0||n.has(i)===!0?!1:(n.add(r),n.add(i),!0)}var hl=Object.freeze({__proto__:null,BoxGeometry:Es,CapsuleGeometry:Ds,CircleGeometry:Os,ConeGeometry:As,CylinderGeometry:ks,DodecahedronGeometry:Ms,EdgesGeometry:Ls,ExtrudeGeometry:Qc,IcosahedronGeometry:tl,LatheGeometry:nl,OctahedronGeometry:rl,PlaneGeometry:il,PolyhedronGeometry:js,RingGeometry:al,ShapeGeometry:ol,SphereGeometry:cl,TetrahedronGeometry:ll,TorusGeometry:ul,TorusKnotGeometry:dl,TubeGeometry:fl,WireframeGeometry:pl}),gl=class extends aa{constructor(e){super(),this.isShadowMaterial=!0,this.type=`ShadowMaterial`,this.color=new H(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}};function _l(e){let t={};for(let n in e){t[n]={};for(let r in e[n]){let i=e[n][r];if(yl(i))i.isRenderTargetTexture?(P(`UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms().`),t[n][r]=null):t[n][r]=i.clone();else if(Array.isArray(i))if(yl(i[0])){let e=[];for(let t=0,n=i.length;t<n;t++)e[t]=i[t].clone();t[n][r]=e}else t[n][r]=i.slice();else t[n][r]=i}}return t}function vl(e){let t={};for(let n=0;n<e.length;n++){let r=_l(e[n]);for(let e in r)t[e]=r[e]}return t}function yl(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function bl(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function xl(e){let t=e.getRenderTarget();return t===null?e.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:Xn.workingColorSpace}var Sl={clone:_l,merge:vl},Cl=`void main() {
|
|
10
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
11
|
+
}`,wl=`void main() {
|
|
12
|
+
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
13
|
+
}`,Tl=class extends aa{constructor(e){super(),this.isShaderMaterial=!0,this.type=`ShaderMaterial`,this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Cl,this.fragmentShader=wl,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=_l(e.uniforms),this.uniformsGroups=bl(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let n in this.uniforms){let r=this.uniforms[n].value;r&&r.isTexture?t.uniforms[n]={type:`t`,value:r.toJSON(e).uuid}:r&&r.isColor?t.uniforms[n]={type:`c`,value:r.getHex()}:r&&r.isVector2?t.uniforms[n]={type:`v2`,value:r.toArray()}:r&&r.isVector3?t.uniforms[n]={type:`v3`,value:r.toArray()}:r&&r.isVector4?t.uniforms[n]={type:`v4`,value:r.toArray()}:r&&r.isMatrix3?t.uniforms[n]={type:`m3`,value:r.toArray()}:r&&r.isMatrix4?t.uniforms[n]={type:`m4`,value:r.toArray()}:t.uniforms[n]={value:r}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let e in this.extensions)this.extensions[e]===!0&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let r=e.uniforms[n];switch(this.uniforms[n]={},r.type){case`t`:this.uniforms[n].value=t[r.value]||null;break;case`c`:this.uniforms[n].value=new H().setHex(r.value);break;case`v2`:this.uniforms[n].value=new R().fromArray(r.value);break;case`v3`:this.uniforms[n].value=new B().fromArray(r.value);break;case`v4`:this.uniforms[n].value=new sr().fromArray(r.value);break;case`m3`:this.uniforms[n].value=new Gn().fromArray(r.value);break;case`m4`:this.uniforms[n].value=new V().fromArray(r.value);break;default:this.uniforms[n].value=r.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(let t in e.extensions)this.extensions[t]=e.extensions[t];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}},El=class extends Tl{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type=`RawShaderMaterial`}},Dl=class extends aa{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type=`MeshStandardMaterial`,this.defines={STANDARD:``},this.color=new H(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 H(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new R(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 Cr,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}},Ol=class extends Dl{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 R(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return I(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new H(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 H(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new H(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}},kl=class extends aa{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type=`MeshPhongMaterial`,this.color=new H(16777215),this.specular=new H(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new H(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new R(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Cr,this.combine=0,this.reflectivity=1,this.envMapIntensity=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.envMapIntensity=e.envMapIntensity,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}},Al=class extends aa{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:``},this.type=`MeshToonMaterial`,this.color=new H(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new H(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new R(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}},jl=class extends aa{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type=`MeshNormalMaterial`,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new R(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}},Ml=class extends aa{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type=`MeshLambertMaterial`,this.color=new H(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new H(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new R(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Cr,this.combine=0,this.reflectivity=1,this.envMapIntensity=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.envMapIntensity=e.envMapIntensity,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}},Nl=class extends aa{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type=`MeshDepthMaterial`,this.depthPacking=wt,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}},Pl=class extends aa{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}},Fl=class extends aa{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:``},this.type=`MeshMatcapMaterial`,this.color=new H(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new R(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,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.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this.fog=e.fog,this}},Il=class extends qo{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 Ll(e,t){return!e||e.constructor===t?e:typeof t.BYTES_PER_ELEMENT==`number`?new t(e):Array.prototype.slice.call(e)}function Rl(e){function t(t,n){return e[t]-e[n]}let n=e.length,r=Array(n);for(let e=0;e!==n;++e)r[e]=e;return r.sort(t),r}function zl(e,t,n){let r=e.length,i=new e.constructor(r);for(let a=0,o=0;o!==r;++a){let r=n[a]*t;for(let n=0;n!==t;++n)i[o++]=e[r+n]}return i}function Bl(e,t,n,r){let i=1,a=e[0];for(;a!==void 0&&a[r]===void 0;)a=e[i++];if(a===void 0)return;let o=a[r];if(o!==void 0)if(Array.isArray(o))do o=a[r],o!==void 0&&(t.push(a.time),n.push(...o)),a=e[i++];while(a!==void 0);else if(o.toArray!==void 0)do o=a[r],o!==void 0&&(t.push(a.time),o.toArray(n,n.length)),a=e[i++];while(a!==void 0);else do o=a[r],o!==void 0&&(t.push(a.time),n.push(o)),a=e[i++];while(a!==void 0)}function K(e,t,n,r,i=30){let a=e.clone();a.name=t;let o=[];for(let e=0;e<a.tracks.length;++e){let t=a.tracks[e],s=t.getValueSize(),c=[],l=[];for(let e=0;e<t.times.length;++e){let a=t.times[e]*i;if(!(a<n||a>=r)){c.push(t.times[e]);for(let n=0;n<s;++n)l.push(t.values[e*s+n])}}c.length!==0&&(t.times=Ll(c,t.times.constructor),t.values=Ll(l,t.values.constructor),o.push(t))}a.tracks=o;let s=1/0;for(let e=0;e<a.tracks.length;++e)s>a.tracks[e].times[0]&&(s=a.tracks[e].times[0]);for(let e=0;e<a.tracks.length;++e)a.tracks[e].shift(-1*s);return a.resetDuration(),a}function q(e,t=0,n=e,r=30){r<=0&&(r=30);let i=n.tracks.length,a=t/r;for(let t=0;t<i;++t){let r=n.tracks[t],i=r.ValueTypeName;if(i===`bool`||i===`string`)continue;let o=e.tracks.find(function(e){return e.name===r.name&&e.ValueTypeName===i});if(o===void 0)continue;let s=0,c=r.getValueSize();r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(s=c/3);let l=0,u=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(l=u/3);let d=r.times.length-1,f;if(a<=r.times[0]){let e=s,t=c-s;f=r.values.slice(e,t)}else if(a>=r.times[d]){let e=d*c+s,t=e+c-s;f=r.values.slice(e,t)}else{let e=r.createInterpolant(),t=s,n=c-s;e.evaluate(a),f=e.resultBuffer.slice(t,n)}i===`quaternion`&&new z().fromArray(f).normalize().conjugate().toArray(f);let p=o.times.length;for(let e=0;e<p;++e){let t=e*u+l;if(i===`quaternion`)z.multiplyQuaternionsFlat(o.values,t,f,0,o.values,t);else{let e=u-l*2;for(let n=0;n<e;++n)o.values[t+n]-=f[n]}}}return e.blendMode=Ct,e}var Vl=class{static convertArray(e,t){return Ll(e,t)}static isTypedArray(e){return an(e)}static getKeyframeOrder(e){return Rl(e)}static sortedArray(e,t,n){return zl(e,t,n)}static flattenJSON(e,t,n,r){Bl(e,t,n,r)}static subclip(e,t,n,r,i=30){return K(e,t,n,r,i)}static makeClipAdditive(e,t=0,n=e,r=30){return q(e,t,n,r)}},Hl=class{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r===void 0?new t.constructor(n):r,this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,r=t[n],i=t[n-1];validate_interval:{seek:{let a;linear_scan:{forward_scan:if(!(e<r)){for(let a=n+2;;){if(r===void 0){if(e<i)break forward_scan;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(i=r,r=t[++n],e<r)break seek}a=t.length;break linear_scan}if(!(e>=i)){let o=t[1];e<o&&(n=2,i=o);for(let a=n-2;;){if(i===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(r=i,i=t[--n-1],e>=i)break seek}a=n,n=0;break linear_scan}break validate_interval}for(;n<a;){let r=n+a>>>1;e<t[r]?a=r:n=r+1}if(r=t[n],i=t[n-1],i===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,i,r)}return this.interpolate_(n,i,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r;for(let e=0;e!==r;++e)t[e]=n[i+e];return t}interpolate_(){throw Error(`THREE.Interpolant: Call to abstract method.`)}intervalChanged_(){}},Ul=class extends Hl{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:yt,endingEnd:yt}}intervalChanged_(e,t,n){let r=this.parameterPositions,i=e-2,a=e+1,o=r[i],s=r[a];if(o===void 0)switch(this.getSettings_().endingStart){case bt:i=e,o=2*t-n;break;case xt:i=r.length-2,o=t+r[i]-r[i+1];break;default:i=e,o=n}if(s===void 0)switch(this.getSettings_().endingEnd){case bt:a=e,s=2*n-t;break;case xt:a=1,s=n+r[1]-r[0];break;default:a=e-1,s=t}let c=(n-t)*.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(s-n),this._offsetPrev=i*l,this._offsetNext=a*l}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(n-t)/(r-t),m=p*p,h=m*p,g=-d*h+2*d*m-d*p,_=(1+d)*h+(-1.5-2*d)*m+(-.5+d)*p+1,v=(-1-f)*h+(1.5+f)*m+.5*p,y=f*h-f*m;for(let e=0;e!==o;++e)i[e]=g*a[l+e]+_*a[c+e]+v*a[s+e]+y*a[u+e];return i}},Wl=class extends Hl{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=(n-t)/(r-t),u=1-l;for(let e=0;e!==o;++e)i[e]=a[c+e]*u+a[s+e]*l;return i}},Gl=class extends Hl{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}},Kl=class extends Hl{interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=this.inTangents,u=this.outTangents;if(!l||!u){let e=(n-t)/(r-t),l=1-e;for(let t=0;t!==o;++t)i[t]=a[c+t]*l+a[s+t]*e;return i}let d=o*2,f=e-1;for(let p=0;p!==o;++p){let o=a[c+p],m=a[s+p],h=f*d+p*2,g=u[h],_=u[h+1],v=e*d+p*2,y=l[v],b=l[v+1],x=(n-t)/(r-t),S,C,w,T,E;for(let e=0;e<8;e++){S=x*x,C=S*x,w=1-x,T=w*w,E=T*w;let e=E*t+3*T*x*g+3*w*S*y+C*r-n;if(Math.abs(e)<1e-10)break;let i=3*T*(g-t)+6*w*x*(y-g)+3*S*(r-y);if(Math.abs(i)<1e-10)break;x-=e/i,x=Math.max(0,Math.min(1,x))}i[p]=E*o+3*T*x*_+3*w*S*b+C*m}return i}},ql=class{constructor(e,t,n,r){if(e===void 0)throw Error(`THREE.KeyframeTrack: track name is undefined`);if(t===void 0||t.length===0)throw Error(`THREE.KeyframeTrack: no keyframes in track named `+e);this.name=e,this.times=Ll(t,this.TimeBufferType),this.values=Ll(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:Ll(e.times,Array),values:Ll(e.values,Array)};let t=e.getInterpolation();t!==e.DefaultInterpolation&&(n.interpolation=t)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Gl(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Wl(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Ul(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new Kl(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents),t}setInterpolation(e){let t;switch(e){case ht:t=this.InterpolantFactoryMethodDiscrete;break;case gt:t=this.InterpolantFactoryMethodLinear;break;case _t:t=this.InterpolantFactoryMethodSmooth;break;case vt:t=this.InterpolantFactoryMethodBezier}if(t===void 0){let t=`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 Error(t);return P(`KeyframeTrack:`,t),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return ht;case this.InterpolantFactoryMethodLinear:return gt;case this.InterpolantFactoryMethodSmooth:return _t;case this.InterpolantFactoryMethodBezier:return vt}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e}return this}trim(e,t){let n=this.times,r=n.length,i=0,a=r-1;for(;i!==r&&n[i]<e;)++i;for(;a!==-1&&n[a]>t;)--a;if(++a,i!==0||a!==r){i>=a&&(a=Math.max(a,1),i=a-1);let e=this.getValueSize();this.times=n.slice(i,a),this.values=this.values.slice(i*e,a*e)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(F(`KeyframeTrack: Invalid value size in track.`,this),e=!1);let n=this.times,r=this.values,i=n.length;i===0&&(F(`KeyframeTrack: Track is empty.`,this),e=!1);let a=null;for(let t=0;t!==i;t++){let r=n[t];if(typeof r==`number`&&isNaN(r)){F(`KeyframeTrack: Time is not a valid number.`,this,t,r),e=!1;break}if(a!==null&&a>r){F(`KeyframeTrack: Out of order keys.`,this,t,r,a),e=!1;break}a=r}if(r!==void 0&&an(r))for(let t=0,n=r.length;t!==n;++t){let n=r[t];if(isNaN(n)){F(`KeyframeTrack: Value is not a valid number.`,this,t,n),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===_t,i=e.length-1,a=1;for(let o=1;o<i;++o){let i=!1,s=e[o];if(s!==e[o+1]&&(o!==1||s!==e[0]))if(r)i=!0;else{let e=o*n,r=e-n,a=e+n;for(let o=0;o!==n;++o){let n=t[e+o];if(n!==t[r+o]||n!==t[a+o]){i=!0;break}}}if(i){if(o!==a){e[a]=e[o];let r=o*n,i=a*n;for(let e=0;e!==n;++e)t[i+e]=t[r+e]}++a}}if(i>0){e[a]=e[i];for(let e=i*n,r=a*n,o=0;o!==n;++o)t[r+o]=t[e+o];++a}return a===e.length?(this.times=e,this.values=t):(this.times=e.slice(0,a),this.values=t.slice(0,a*n)),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};ql.prototype.ValueTypeName=``,ql.prototype.TimeBufferType=Float32Array,ql.prototype.ValueBufferType=Float32Array,ql.prototype.DefaultInterpolation=gt;var Jl=class extends ql{constructor(e,t,n){super(e,t,n)}};Jl.prototype.ValueTypeName=`bool`,Jl.prototype.ValueBufferType=Array,Jl.prototype.DefaultInterpolation=ht,Jl.prototype.InterpolantFactoryMethodLinear=void 0,Jl.prototype.InterpolantFactoryMethodSmooth=void 0;var Yl=class extends ql{constructor(e,t,n,r){super(e,t,n,r)}};Yl.prototype.ValueTypeName=`color`;var Xl=class extends ql{constructor(e,t,n,r){super(e,t,n,r)}};Xl.prototype.ValueTypeName=`number`;var Zl=class extends Hl{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-t)/(r-t),c=e*o;for(let e=c+o;c!==e;c+=4)z.slerpFlat(i,0,a,c-o,a,c,s);return i}},Ql=class extends ql{constructor(e,t,n,r){super(e,t,n,r)}InterpolantFactoryMethodLinear(e){return new Zl(this.times,this.values,this.getValueSize(),e)}};Ql.prototype.ValueTypeName=`quaternion`,Ql.prototype.InterpolantFactoryMethodSmooth=void 0;var $l=class extends ql{constructor(e,t,n){super(e,t,n)}};$l.prototype.ValueTypeName=`string`,$l.prototype.ValueBufferType=Array,$l.prototype.DefaultInterpolation=ht,$l.prototype.InterpolantFactoryMethodLinear=void 0,$l.prototype.InterpolantFactoryMethodSmooth=void 0;var eu=class extends ql{constructor(e,t,n,r){super(e,t,n,r)}};eu.prototype.ValueTypeName=`vector`;var tu=class{constructor(e=``,t=-1,n=[],r=St){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=Sn(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){let t=[],n=e.tracks,r=1/(e.fps||1);for(let e=0,i=n.length;e!==i;++e)t.push(ru(n[e]).scale(r));let i=new this(e.name,e.duration,t,e.blendMode);return i.uuid=e.uuid,i.userData=JSON.parse(e.userData||`{}`),i}static toJSON(e){let t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let e=0,r=n.length;e!==r;++e)t.push(ql.toJSON(n[e]));return r}static CreateFromMorphTargetSequence(e,t,n,r){let i=t.length,a=[];for(let e=0;e<i;e++){let o=[],s=[];o.push((e+i-1)%i,e,(e+1)%i),s.push(0,1,0);let c=Rl(o);o=zl(o,1,c),s=zl(s,1,c),!r&&o[0]===0&&(o.push(i),s.push(s[0])),a.push(new Xl(`.morphTargetInfluences[`+t[e].name+`]`,o,s).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let t=e;n=t.geometry&&t.geometry.animations||t.animations}for(let e=0;e<n.length;e++)if(n[e].name===t)return n[e];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let r={},i=/^([\w-]*?)([\d]+)$/;for(let t=0,n=e.length;t<n;t++){let n=e[t],a=n.name.match(i);if(a&&a.length>1){let e=a[1],t=r[e];t||(r[e]=t=[]),t.push(n)}}let a=[];for(let e in r)a.push(this.CreateFromMorphTargetSequence(e,r[e],t,n));return a}resetDuration(){let e=this.tracks,t=0;for(let n=0,r=e.length;n!==r;++n){let e=this.tracks[n];t=Math.max(t,e.times[e.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&&=this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());let t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}};function nu(e){switch(e.toLowerCase()){case`scalar`:case`double`:case`float`:case`number`:case`integer`:return Xl;case`vector`:case`vector2`:case`vector3`:case`vector4`:return eu;case`color`:return Yl;case`quaternion`:return Ql;case`bool`:case`boolean`:return Jl;case`string`:return $l}throw Error(`THREE.KeyframeTrack: Unsupported typeName: `+e)}function ru(e){if(e.type===void 0)throw Error(`THREE.KeyframeTrack: track type undefined, can not parse`);let t=nu(e.type);if(e.times===void 0){let t=[],n=[];Bl(e.keys,t,n,`value`),e.times=t,e.values=n}return t.parse===void 0?new t(e.name,e.times,e.values,e.interpolation):t.parse(e)}var iu={enabled:!1,files:{},add:function(e,t){this.enabled!==!1&&(au(e)||(this.files[e]=t))},get:function(e){if(this.enabled!==!1&&!au(e))return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function au(e){try{let t=e.slice(e.indexOf(`:`)+1);return new URL(t).protocol===`blob:`}catch{return!1}}var ou=class{constructor(e,t,n){let r=this,i=!1,a=0,o=0,s,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(e){o++,i===!1&&r.onStart!==void 0&&r.onStart(e,a,o),i=!0},this.itemEnd=function(e){a++,r.onProgress!==void 0&&r.onProgress(e,a,o),a===o&&(i=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(e){r.onError!==void 0&&r.onError(e)},this.resolveURL=function(e){return e=e.normalize(`NFC`),s?s(e):e},this.setURLModifier=function(e){return s=e,this},this.addHandler=function(e,t){return c.push(e,t),this},this.removeHandler=function(e){let t=c.indexOf(e);return t!==-1&&c.splice(t,2),this},this.getHandler=function(e){for(let t=0,n=c.length;t<n;t+=2){let n=c[t],r=c[t+1];if(n.global&&(n.lastIndex=0),n.test(e))return r}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||=new AbortController,this._abortController}},su=new ou,cu=class{constructor(e){this.manager=e===void 0?su:e,this.crossOrigin=`anonymous`,this.withCredentials=!1,this.path=``,this.resourcePath=``,this.requestHeader={},typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}load(){}loadAsync(e,t){let n=this;return new Promise(function(r,i){n.load(e,r,t,i)})}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}abort(){return this}};cu.DEFAULT_MATERIAL_NAME=`__DEFAULT`;var lu={},uu=class extends Error{constructor(e,t){super(e),this.response=t}},du=class extends cu{constructor(e){super(e),this.mimeType=``,this.responseType=``,this._abortController=new AbortController}load(e,t,n,r){e===void 0&&(e=``),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let i=iu.get(`file:${e}`);if(i!==void 0){this.manager.itemStart(e),setTimeout(()=>{t&&t(i),this.manager.itemEnd(e)},0);return}if(lu[e]!==void 0){lu[e].push({onLoad:t,onProgress:n,onError:r});return}lu[e]=[],lu[e].push({onLoad:t,onProgress:n,onError:r});let a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?`include`:`same-origin`,signal:typeof AbortSignal.any==`function`?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,s=this.responseType;fetch(a).then(t=>{if(t.status===200||t.status===0){if(t.status===0&&P(`FileLoader: HTTP Status 0 received.`),typeof ReadableStream>`u`||t.body===void 0||t.body.getReader===void 0)return t;let n=lu[e],r=t.body.getReader(),i=t.headers.get(`X-File-Size`)||t.headers.get(`Content-Length`),a=i?parseInt(i):0,o=a!==0,s=0,c=new ReadableStream({start(e){t();function t(){r.read().then(({done:r,value:i})=>{if(r)e.close();else{s+=i.byteLength;let r=new ProgressEvent(`progress`,{lengthComputable:o,loaded:s,total:a});for(let e=0,t=n.length;e<t;e++){let t=n[e];t.onProgress&&t.onProgress(r)}e.enqueue(i),t()}},t=>{e.error(t)})}}});return new Response(c)}throw new uu(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`,t)}).then(e=>{switch(s){case`arraybuffer`:return e.arrayBuffer();case`blob`:return e.blob();case`document`:return e.text().then(e=>new DOMParser().parseFromString(e,o));case`json`:return e.json();default:if(o===``)return e.text();{let t=/charset="?([^;"\s]*)"?/i.exec(o),n=t&&t[1]?t[1].toLowerCase():void 0,r=new TextDecoder(n);return e.arrayBuffer().then(e=>r.decode(e))}}}).then(t=>{iu.add(`file:${e}`,t);let n=lu[e];delete lu[e];for(let e=0,r=n.length;e<r;e++){let r=n[e];r.onLoad&&r.onLoad(t)}}).catch(t=>{let n=lu[e];if(n===void 0)throw this.manager.itemError(e),t;delete lu[e];for(let e=0,r=n.length;e<r;e++){let r=n[e];r.onError&&r.onError(t)}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}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}},fu=class extends cu{constructor(e){super(e)}load(e,t,n,r){let i=this,a=new du(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(n){try{t(i.parse(JSON.parse(n)))}catch(t){r?r(t):F(t),i.manager.itemError(e)}},n,r)}parse(e){let t=[];for(let n=0;n<e.length;n++){let r=tu.parse(e[n]);t.push(r)}return t}},pu=class extends cu{constructor(e){super(e)}load(e,t,n,r){let i=this,a=[],o=new _s,s=new du(this.manager);s.setPath(this.path),s.setResponseType(`arraybuffer`),s.setRequestHeader(this.requestHeader),s.setWithCredentials(i.withCredentials);let c=0;function l(l){s.load(e[l],function(e){let n=i.parse(e,!0);a[l]={width:n.width,height:n.height,format:n.format,mipmaps:n.mipmaps},c+=1,c===6&&(n.mipmapCount===1&&(o.minFilter=A),o.image=a,o.format=n.format,o.needsUpdate=!0,t&&t(o))},n,r)}if(Array.isArray(e))for(let t=0,n=e.length;t<n;++t)l(t);else s.load(e,function(e){let n=i.parse(e,!0);if(n.isCubemap){let e=n.mipmaps.length/n.mipmapCount;for(let t=0;t<e;t++){a[t]={mipmaps:[]};for(let e=0;e<n.mipmapCount;e++)a[t].mipmaps.push(n.mipmaps[t*n.mipmapCount+e]),a[t].format=n.format,a[t].width=n.width,a[t].height=n.height}o.image=a}else o.image.width=n.width,o.image.height=n.height,o.mipmaps=n.mipmaps;n.mipmapCount===1&&(o.minFilter=A),o.format=n.format,o.needsUpdate=!0,t&&t(o)},n,r);return o}},mu=new WeakMap,hu=class extends cu{constructor(e){super(e)}load(e,t,n,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let i=this,a=iu.get(`image:${e}`);if(a!==void 0){if(a.complete===!0)i.manager.itemStart(e),setTimeout(function(){t&&t(a),i.manager.itemEnd(e)},0);else{let e=mu.get(a);e===void 0&&(e=[],mu.set(a,e)),e.push({onLoad:t,onError:r})}return a}let o=on(`img`);function s(){l(),t&&t(this);let n=mu.get(this)||[];for(let e=0;e<n.length;e++){let t=n[e];t.onLoad&&t.onLoad(this)}mu.delete(this),i.manager.itemEnd(e)}function c(t){l(),r&&r(t),iu.remove(`image:${e}`);let n=mu.get(this)||[];for(let e=0;e<n.length;e++){let r=n[e];r.onError&&r.onError(t)}mu.delete(this),i.manager.itemError(e),i.manager.itemEnd(e)}function l(){o.removeEventListener(`load`,s,!1),o.removeEventListener(`error`,c,!1)}return o.addEventListener(`load`,s,!1),o.addEventListener(`error`,c,!1),e.slice(0,5)!==`data:`&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),iu.add(`image:${e}`,o),i.manager.itemStart(e),o.src=e,o}},gu=class extends cu{constructor(e){super(e)}load(e,t,n,r){let i=new bs;i.colorSpace=Ot;let a=new hu(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let o=0;function s(n){a.load(e[n],function(e){i.images[n]=e,o++,o===6&&(i.needsUpdate=!0,t&&t(i))},void 0,r)}for(let t=0;t<e.length;++t)s(t);return i}},_u=class extends cu{constructor(e){super(e)}load(e,t,n,r){let i=this,a=new ao,o=new du(this.manager);return o.setResponseType(`arraybuffer`),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(i.withCredentials),o.load(e,function(e){let n;try{n=i.parse(e)}catch(e){r===void 0?F(e):r(e);return}i._applyTexData(a,n),t&&t(a,n)},n,r),a}createDataTexture(e){let t=new ao;return this._applyTexData(t,this.parse(e)),t}_applyTexData(e,t){t.image===void 0?t.data!==void 0&&(e.image.width=t.width,e.image.height=t.height,e.image.data=t.data):e.image=t.image,e.wrapS=t.wrapS===void 0?O:t.wrapS,e.wrapT=t.wrapT===void 0?O:t.wrapT,e.magFilter=t.magFilter===void 0?A:t.magFilter,e.minFilter=t.minFilter===void 0?A:t.minFilter,e.anisotropy=t.anisotropy===void 0?1:t.anisotropy,t.colorSpace!==void 0&&(e.colorSpace=t.colorSpace),t.flipY!==void 0&&(e.flipY=t.flipY),t.format!==void 0&&(e.format=t.format),t.type!==void 0&&(e.type=t.type),t.mipmaps!==void 0&&(e.mipmaps=t.mipmaps,e.minFilter=ae),t.mipmapCount===1&&(e.minFilter=A),t.generateMipmaps!==void 0&&(e.generateMipmaps=t.generateMipmaps),e.needsUpdate=!0}},vu=class extends cu{constructor(e){super(e)}load(e,t,n,r){let i=new or,a=new hu(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(e){i.image=e,i.needsUpdate=!0,t!==void 0&&t(i)},n,r),i}},yu=class extends Br{constructor(e,t=1){super(),this.isLight=!0,this.type=`Light`,this.color=new H(e),this.intensity=t}dispose(){this.dispatchEvent({type:`dispose`})}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}},bu=class extends yu{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type=`HemisphereLight`,this.position.copy(Br.DEFAULT_UP),this.updateMatrix(),this.groundColor=new H(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}},xu=new V,Su=new B,Cu=new B,wu=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new R(512,512),this.mapType=se,this.map=null,this.mapPass=null,this.matrix=new V,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new To,this._frameExtents=new R(1,1),this._viewportCount=1,this._viewports=[new sr(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,n=this.matrix;Su.setFromMatrixPosition(e.matrixWorld),t.position.copy(Su),Cu.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Cu),t.updateMatrixWorld(),xu.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(xu,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===2001||t.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(xu)}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.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let 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}},Tu=new B,Eu=new z,Du=new B,Ou=class extends Br{constructor(){super(),this.isCamera=!0,this.type=`Camera`,this.matrixWorldInverse=new V,this.projectionMatrix=new V,this.projectionMatrixInverse=new V,this.coordinateSystem=Yt,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(Tu,Eu,Du),Du.x===1&&Du.y===1&&Du.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Tu,Eu,Du.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(Tu,Eu,Du),Du.x===1&&Du.y===1&&Du.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Tu,Eu,Du.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}},ku=new B,Au=new R,ju=new R,Mu=class extends Ou{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type=`PerspectiveCamera`,this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=xn*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(bn*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return xn*2*Math.atan(Math.tan(bn*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){ku.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(ku.x,ku.y).multiplyScalar(-e/ku.z),ku.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(ku.x,ku.y).multiplyScalar(-e/ku.z)}getViewSize(e,t){return this.getViewBounds(e,Au,ju),t.subVectors(ju,Au)}setViewOffset(e,t,n,r,i,a){this.aspect=e/t,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=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(bn*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,i=-.5*r,a=this.view;if(this.view!==null&&this.view.enabled){let e=a.fullWidth,o=a.fullHeight;i+=a.offsetX*r/e,t-=a.offsetY*n/o,r*=a.width/e,n*=a.height/o}let o=this.filmOffset;o!==0&&(i+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}},Nu=class extends wu{constructor(){super(new Mu(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,n=xn*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height*this.aspect,i=e.distance||t.far;(n!==t.fov||r!==t.aspect||i!==t.far)&&(t.fov=n,t.aspect=r,t.far=i,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},Pu=class extends yu{constructor(e,t,n=0,r=Math.PI/3,i=0,a=2){super(e,t),this.isSpotLight=!0,this.type=`SpotLight`,this.position.copy(Br.DEFAULT_UP),this.updateMatrix(),this.target=new Br,this.distance=n,this.angle=r,this.penumbra=i,this.decay=a,this.map=null,this.shadow=new Nu}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.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.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture&&(t.object.map=this.map.toJSON(e).uuid),t.object.shadow=this.shadow.toJSON(),t}},Fu=class extends wu{constructor(){super(new Mu(90,1,.5,500)),this.isPointLightShadow=!0}},Iu=class extends yu{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 Fu}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.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}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}},Lu=class extends Ou{constructor(e=-1,t=1,n=1,r=-1,i=.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=i,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,i,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=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let 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,i=n-e,a=n+e,o=r+t,s=r-t;if(this.view!==null&&this.view.enabled){let e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;i+=e*this.view.offsetX,a=i+e*this.view.width,o-=t*this.view.offsetY,s=o-t*this.view.height}this.projectionMatrix.makeOrthographic(i,a,o,s,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let 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}},Ru=class extends wu{constructor(){super(new Lu(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},zu=class extends yu{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type=`DirectionalLight`,this.position.copy(Br.DEFAULT_UP),this.updateMatrix(),this.target=new Br,this.shadow=new Ru}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}},Bu=class extends yu{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type=`AmbientLight`}},Vu=class extends yu{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){let t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}},Hu=class{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new B)}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){let n=e.x,r=e.y,i=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*r),t.addScaledVector(a[2],.488603*i),t.addScaledVector(a[3],.488603*n),t.addScaledVector(a[4],n*r*1.092548),t.addScaledVector(a[5],r*i*1.092548),t.addScaledVector(a[6],.315392*(3*i*i-1)),t.addScaledVector(a[7],n*i*1.092548),t.addScaledVector(a[8],.546274*(n*n-r*r)),t}getIrradianceAt(e,t){let n=e.x,r=e.y,i=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScaledVector(a[1],1.023328*r),t.addScaledVector(a[2],1.023328*i),t.addScaledVector(a[3],1.023328*n),t.addScaledVector(a[4],.858086*n*r),t.addScaledVector(a[5],.858086*r*i),t.addScaledVector(a[6],.743125*i*i-.247708),t.addScaledVector(a[7],.858086*n*i),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){let n=this.coefficients;for(let r=0;r<9;r++)n[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){let n=this.coefficients;for(let r=0;r<9;r++)n[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){let n=e.x,r=e.y,i=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*i,t[3]=.488603*n,t[4]=1.092548*n*r,t[5]=1.092548*r*i,t[6]=.315392*(3*i*i-1),t[7]=1.092548*n*i,t[8]=.546274*(n*n-r*r)}},Uu=class extends yu{constructor(e=new Hu,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}toJSON(e){let t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}},Wu={},Gu=class e extends cu{constructor(e){super(e),this.textures={}}load(e,t,n,r){let i=this,a=new du(i.manager);a.setPath(i.path),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials),a.load(e,function(n){try{t(i.parse(JSON.parse(n)))}catch(t){r?r(t):F(t),i.manager.itemError(e)}},n,r)}parse(e){let t=this.createMaterialFromType(e.type);return t.fromJSON(e,this.textures),t}setTextures(e){return this.textures=e,this}createMaterialFromType(t){return e.createMaterialFromType(t)}static createMaterialFromType(e){let t={ShadowMaterial:gl,SpriteMaterial:oa,RawShaderMaterial:El,ShaderMaterial:Tl,PointsMaterial:ss,MeshPhysicalMaterial:Ol,MeshStandardMaterial:Dl,MeshPhongMaterial:kl,MeshToonMaterial:Al,MeshNormalMaterial:jl,MeshLambertMaterial:Ml,MeshDepthMaterial:Nl,MeshDistanceMaterial:Pl,MeshBasicMaterial:Na,MeshMatcapMaterial:Fl,LineDashedMaterial:Il,LineBasicMaterial:qo,Material:aa,...Wu}[e],n;return t===void 0?(mn(`MaterialLoader: Unknown material type "${e}". Use .registerMaterial() before starting the deserialization process.`),n=new aa):n=new t,n}static registerMaterial(e,t){Wu[e]=t}},Ku=class{static extractUrlBase(e){let 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)}},qu=class extends W{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type=`InstancedBufferGeometry`,this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},Ju=class extends cu{constructor(e){super(e)}load(e,t,n,r){let i=this,a=new du(i.manager);a.setPath(i.path),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials),a.load(e,function(n){try{t(i.parse(JSON.parse(n)))}catch(t){r?r(t):F(t),i.manager.itemError(e)}},n,r)}parse(e){let t={},n={};function r(e,n){if(t[n]!==void 0)return t[n];let r=e.interleavedBuffers[n],a=i(e,r.buffer),o=new ta(rn(r.type,a),r.stride);return o.uuid=r.uuid,t[n]=o,o}function i(e,t){if(n[t]!==void 0)return n[t];let r=e.arrayBuffers[t],i=new Uint32Array(r).buffer;return n[t]=i,i}let a=e.isInstancedBufferGeometry?new qu:new W,o=e.data.index;if(o!==void 0){let e=rn(o.type,o.array);a.setIndex(new Fi(e,1))}let s=e.data.attributes;for(let t in s){let n=s[t],i;if(n.isInterleavedBufferAttribute)i=new ra(r(e.data,n.data),n.itemSize,n.offset,n.normalized);else{let e=rn(n.type,n.array);i=new(n.isInstancedBufferAttribute?co:Fi)(e,n.itemSize,n.normalized)}n.name!==void 0&&(i.name=n.name),n.usage!==void 0&&i.setUsage(n.usage),a.setAttribute(t,i)}let c=e.data.morphAttributes;if(c)for(let t in c){let n=c[t],i=[];for(let t=0,a=n.length;t<a;t++){let a=n[t],o;o=a.isInterleavedBufferAttribute?new ra(r(e.data,a.data),a.itemSize,a.offset,a.normalized):new Fi(rn(a.type,a.array),a.itemSize,a.normalized),a.name!==void 0&&(o.name=a.name),i.push(o)}a.morphAttributes[t]=i}e.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);let l=e.data.groups||e.data.drawcalls||e.data.offsets;if(l!==void 0)for(let e=0,t=l.length;e!==t;++e){let t=l[e];a.addGroup(t.start,t.count,t.materialIndex)}let u=e.data.boundingSphere;return u!==void 0&&(a.boundingSphere=new qi().fromJSON(u)),e.name&&(a.name=e.name),e.userData&&(a.userData=e.userData),a}},Yu={},Xu=class extends cu{constructor(e){super(e)}load(e,t,n,r){let i=this,a=this.path===``?Ku.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||a;let o=new du(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(n){let a=null;try{a=JSON.parse(n)}catch(t){r!==void 0&&r(t),F(`ObjectLoader: Can't parse `+e+`.`,t.message);return}let o=a.metadata;if(o===void 0||o.type===void 0||o.type.toLowerCase()===`geometry`){r!==void 0&&r(Error(`THREE.ObjectLoader: Can't load `+e)),F(`ObjectLoader: Can't load `+e);return}i.parse(a,t)},n,r)}async loadAsync(e,t){let n=this,r=this.path===``?Ku.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||r;let i=new du(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials);let a=await i.loadAsync(e,t),o;try{o=JSON.parse(a)}catch(t){throw Error(`THREE.ObjectLoader: Can't parse `+e+`. `+t.message)}let s=o.metadata;if(s===void 0||s.type===void 0||s.type.toLowerCase()===`geometry`)throw Error(`THREE.ObjectLoader: Can't load `+e);return await n.parseAsync(o)}parse(e,t){let n=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),i=this.parseGeometries(e.geometries,r),a=this.parseImages(e.images,function(){t!==void 0&&t(c)}),o=this.parseTextures(e.textures,a),s=this.parseMaterials(e.materials,o),c=this.parseObject(e.object,i,s,o,n),l=this.parseSkeletons(e.skeletons,c);if(this.bindSkeletons(c,l),this.bindLightTargets(c),t!==void 0){let e=!1;for(let t in a)if(a[t].data instanceof HTMLImageElement){e=!0;break}e===!1&&t(c)}return c}async parseAsync(e){let t=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,n),i=await this.parseImagesAsync(e.images),a=this.parseTextures(e.textures,i),o=this.parseMaterials(e.materials,a),s=this.parseObject(e.object,r,o,a,t),c=this.parseSkeletons(e.skeletons,s);return this.bindSkeletons(s,c),this.bindLightTargets(s),s}static registerGeometry(e,t){Yu[e]=t}parseShapes(e){let t={};if(e!==void 0)for(let n=0,r=e.length;n<r;n++){let r=new mc().fromJSON(e[n]);t[r.uuid]=r}return t}parseSkeletons(e,t){let n={},r={};if(t.traverse(function(e){e.isBone&&(r[e.uuid]=e)}),e!==void 0)for(let t=0,i=e.length;t<i;t++){let i=new G().fromJSON(e[t],r);n[i.uuid]=i}return n}parseGeometries(e,t){let n={};if(e!==void 0){let r=new Ju;for(let i=0,a=e.length;i<a;i++){let a,o=e[i];switch(o.type){case`BufferGeometry`:case`InstancedBufferGeometry`:a=r.parse(o);break;default:o.type in hl?a=hl[o.type].fromJSON(o,t):o.type in Yu?a=Yu[o.type].fromJSON(o,t):P(`ObjectLoader: Unknown geometry type "${o.type}". Use .registerGeometry() before starting the deserialization process.`)}a.uuid=o.uuid,o.name!==void 0&&(a.name=o.name),o.userData!==void 0&&(a.userData=o.userData),n[o.uuid]=a}}return n}parseMaterials(e,t){let n={},r={};if(e!==void 0){let i=new Gu;i.setTextures(t);for(let t=0,a=e.length;t<a;t++){let a=e[t];n[a.uuid]===void 0&&(n[a.uuid]=i.parse(a)),r[a.uuid]=n[a.uuid]}}return r}parseAnimations(e){let t={};if(e!==void 0)for(let n=0;n<e.length;n++){let r=e[n],i=tu.parse(r);t[i.uuid]=i}return t}parseImages(e,t){let n=this,r={},i;function a(e){return e=n.manager.resolveURL(e),n.manager.itemStart(e),i.load(e,function(){n.manager.itemEnd(e)},void 0,function(){n.manager.itemError(e),n.manager.itemEnd(e)})}function o(e){if(typeof e==`string`){let t=e;return a(/^(\/\/)|([a-z]+:(\/\/)?)/i.test(t)?t:n.resourcePath+t)}return e.data?{data:rn(e.type,e.data),width:e.width,height:e.height}:null}if(e!==void 0&&e.length>0){i=new hu(new ou(t)),i.setCrossOrigin(this.crossOrigin);for(let t=0,n=e.length;t<n;t++){let n=e[t],i=n.url;if(Array.isArray(i)){let e=[];for(let t=0,n=i.length;t<n;t++){let n=i[t],r=o(n);r!==null&&(r instanceof HTMLImageElement?e.push(r):e.push(new ao(r.data,r.width,r.height)))}r[n.uuid]=new nr(e)}else{let e=o(n.url);r[n.uuid]=new nr(e)}}}return r}async parseImagesAsync(e){let t=this,n={},r;async function i(e){if(typeof e==`string`){let n=e,i=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(n)?n:t.resourcePath+n;return await r.loadAsync(i)}return e.data?{data:rn(e.type,e.data),width:e.width,height:e.height}:null}if(e!==void 0&&e.length>0){r=new hu(this.manager),r.setCrossOrigin(this.crossOrigin);for(let t=0,r=e.length;t<r;t++){let r=e[t],a=r.url;if(Array.isArray(a)){let e=[];for(let t=0,n=a.length;t<n;t++){let n=a[t],r=await i(n);r!==null&&(r instanceof HTMLImageElement?e.push(r):e.push(new ao(r.data,r.width,r.height)))}n[r.uuid]=new nr(e)}else{let e=await i(r.url);n[r.uuid]=new nr(e)}}}return n}parseTextures(e,t){function n(e,t){return typeof e==`number`?e:(P(`ObjectLoader.parseTexture: Constant should be in numeric form.`,e),t[e])}let r={};if(e!==void 0)for(let i=0,a=e.length;i<a;i++){let a=e[i];a.image===void 0&&P(`ObjectLoader: No "image" specified for`,a.uuid),t[a.image]===void 0&&P(`ObjectLoader: Undefined image`,a.image);let o=t[a.image],s=o.data,c;Array.isArray(s)?(c=new bs,s.length===6&&(c.needsUpdate=!0)):(c=s&&s.data?new ao:new or,s&&(c.needsUpdate=!0)),c.source=o,c.uuid=a.uuid,a.name!==void 0&&(c.name=a.name),a.mapping!==void 0&&(c.mapping=n(a.mapping,Zu)),a.channel!==void 0&&(c.channel=a.channel),a.offset!==void 0&&c.offset.fromArray(a.offset),a.repeat!==void 0&&c.repeat.fromArray(a.repeat),a.center!==void 0&&c.center.fromArray(a.center),a.rotation!==void 0&&(c.rotation=a.rotation),a.wrap!==void 0&&(c.wrapS=n(a.wrap[0],Qu),c.wrapT=n(a.wrap[1],Qu)),a.format!==void 0&&(c.format=a.format),a.internalFormat!==void 0&&(c.internalFormat=a.internalFormat),a.type!==void 0&&(c.type=a.type),a.colorSpace!==void 0&&(c.colorSpace=a.colorSpace),a.minFilter!==void 0&&(c.minFilter=n(a.minFilter,$u)),a.magFilter!==void 0&&(c.magFilter=n(a.magFilter,$u)),a.anisotropy!==void 0&&(c.anisotropy=a.anisotropy),a.flipY!==void 0&&(c.flipY=a.flipY),a.generateMipmaps!==void 0&&(c.generateMipmaps=a.generateMipmaps),a.premultiplyAlpha!==void 0&&(c.premultiplyAlpha=a.premultiplyAlpha),a.unpackAlignment!==void 0&&(c.unpackAlignment=a.unpackAlignment),a.compareFunction!==void 0&&(c.compareFunction=a.compareFunction),a.normalized!==void 0&&(c.normalized=a.normalized),a.userData!==void 0&&(c.userData=a.userData),r[a.uuid]=c}return r}parseObject(e,t,n,r,i){let a;function o(e){return t[e]===void 0&&P(`ObjectLoader: Undefined geometry`,e),t[e]}function s(e){if(e!==void 0){if(Array.isArray(e)){let t=[];for(let r=0,i=e.length;r<i;r++){let i=e[r];n[i]===void 0&&P(`ObjectLoader: Undefined material`,i),t.push(n[i])}return t}return n[e]===void 0&&P(`ObjectLoader: Undefined material`,e),n[e]}}function c(e){return r[e]===void 0&&P(`ObjectLoader: Undefined texture`,e),r[e]}let l,u;switch(e.type){case`Scene`:a=new Zr,e.background!==void 0&&(Number.isInteger(e.background)?a.background=new H(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 Xr(e.fog.color,e.fog.near,e.fog.far):e.fog.type===`FogExp2`&&(a.fog=new Yr(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 Mu(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 Lu(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 Bu(e.color,e.intensity);break;case`DirectionalLight`:a=new zu(e.color,e.intensity),a.target=e.target||``;break;case`PointLight`:a=new Iu(e.color,e.intensity,e.distance,e.decay);break;case`RectAreaLight`:a=new Vu(e.color,e.intensity,e.width,e.height);break;case`SpotLight`:a=new Pu(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),a.target=e.target||``;break;case`HemisphereLight`:a=new bu(e.color,e.groundColor,e.intensity);break;case`LightProbe`:a=new Uu(new Hu().fromArray(e.sh),e.intensity);break;case`SkinnedMesh`:l=o(e.geometry),u=s(e.material),a=new ro(l,u),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`:l=o(e.geometry),u=s(e.material),a=new Ga(l,u);break;case`InstancedMesh`:l=o(e.geometry),u=s(e.material);let t=e.count,n=e.instanceMatrix,r=e.instanceColor;a=new _o(l,u,t),a.instanceMatrix=new co(new Float32Array(n.array),16),r!==void 0&&(a.instanceColor=new co(new Float32Array(r.array),r.itemSize));break;case`BatchedMesh`:l=o(e.geometry),u=s(e.material),a=new Ko(e.maxInstanceCount,e.maxVertexCount,e.maxIndexCount,u),a.geometry=l,a.perObjectFrustumCulled=e.perObjectFrustumCulled,a.sortObjects=e.sortObjects,a._drawRanges=e.drawRanges,a._reservedRanges=e.reservedRanges,a._geometryInfo=e.geometryInfo.map(e=>{let t=null,n=null;return e.boundingBox!==void 0&&(t=new fi().fromJSON(e.boundingBox)),e.boundingSphere!==void 0&&(n=new qi().fromJSON(e.boundingSphere)),{...e,boundingBox:t,boundingSphere:n}}),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 qi().fromJSON(e.boundingSphere)),e.boundingBox!==void 0&&(a.boundingBox=new fi().fromJSON(e.boundingBox));break;case`LOD`:a=new wa;break;case`Line`:a=new ts(o(e.geometry),s(e.material));break;case`LineLoop`:a=new os(o(e.geometry),s(e.material));break;case`LineSegments`:a=new as(o(e.geometry),s(e.material));break;case`PointCloud`:case`Points`:a=new fs(o(e.geometry),s(e.material));break;case`Sprite`:a=new ba(s(e.material));break;case`Group`:a=new Vr;break;case`Bone`:a=new io;break;default:a=new Br}if(a.uuid=e.uuid,e.name!==void 0&&(a.name=e.name),e.matrix===void 0?(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)):(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.up!==void 0&&a.up.fromArray(e.up),e.pivot!==void 0&&(a.pivot=new B().fromArray(e.pivot)),e.morphTargetDictionary!==void 0&&(a.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),e.morphTargetInfluences!==void 0&&(a.morphTargetInfluences=e.morphTargetInfluences.slice()),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.static!==void 0&&(a.static=e.static),e.userData!==void 0&&(a.userData=e.userData),e.layers!==void 0&&(a.layers.mask=e.layers),e.children!==void 0){let o=e.children;for(let e=0;e<o.length;e++)a.add(this.parseObject(o[e],t,n,r,i))}if(e.animations!==void 0){let t=e.animations;for(let e=0;e<t.length;e++){let n=t[e];a.animations.push(i[n])}}if(e.type===`LOD`){e.autoUpdate!==void 0&&(a.autoUpdate=e.autoUpdate);let t=e.levels;for(let e=0;e<t.length;e++){let n=t[e],r=a.getObjectByProperty(`uuid`,n.object);r!==void 0&&a.addLevel(r,n.distance,n.hysteresis)}}return a}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(e){if(e.isSkinnedMesh===!0&&e.skeleton!==void 0){let n=t[e.skeleton];n===void 0?P(`ObjectLoader: No skeleton found with UUID:`,e.skeleton):e.bind(n,e.bindMatrix)}})}bindLightTargets(e){e.traverse(function(t){if(t.isDirectionalLight||t.isSpotLight){let n=t.target,r=e.getObjectByProperty(`uuid`,n);t.target=r===void 0?new Br:r}})}},Zu={UVMapping:300,CubeReflectionMapping:301,CubeRefractionMapping:302,EquirectangularReflectionMapping:303,EquirectangularRefractionMapping:304,CubeUVReflectionMapping:306},Qu={RepeatWrapping:D,ClampToEdgeWrapping:O,MirroredRepeatWrapping:ee},$u={NearestFilter:k,NearestMipmapNearestFilter:te,NearestMipmapLinearFilter:re,LinearFilter:A,LinearMipmapNearestFilter:j,LinearMipmapLinearFilter:ae},ed=new WeakMap,td=class extends cu{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>`u`&&P(`ImageBitmapLoader: createImageBitmap() not supported.`),typeof fetch>`u`&&P(`ImageBitmapLoader: fetch() not supported.`),this.options={premultiplyAlpha:`none`},this._abortController=new AbortController}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);let i=this,a=iu.get(`image-bitmap:${e}`);if(a!==void 0){if(i.manager.itemStart(e),a.then){a.then(n=>{ed.has(a)===!0?(r&&r(ed.get(a)),i.manager.itemError(e),i.manager.itemEnd(e)):(t&&t(n),i.manager.itemEnd(e))});return}setTimeout(function(){t&&t(a),i.manager.itemEnd(e)},0);return}let o={};o.credentials=this.crossOrigin===`anonymous`?`same-origin`:`include`,o.headers=this.requestHeader,o.signal=typeof AbortSignal.any==`function`?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let s=fetch(e,o).then(function(e){return e.blob()}).then(function(e){return createImageBitmap(e,Object.assign(i.options,{colorSpaceConversion:`none`}))}).then(function(n){iu.add(`image-bitmap:${e}`,n),t&&t(n),i.manager.itemEnd(e)}).catch(function(t){r&&r(t),ed.set(s,t),iu.remove(`image-bitmap:${e}`),i.manager.itemError(e),i.manager.itemEnd(e)});iu.add(`image-bitmap:${e}`,s),i.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}},nd,rd=class{static getContext(){return nd===void 0&&(nd=new(window.AudioContext||window.webkitAudioContext)),nd}static setContext(e){nd=e}},id=class extends cu{constructor(e){super(e)}load(e,t,n,r){let i=this,a=new du(this.manager);a.setResponseType(`arraybuffer`),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(n){try{let r=n.slice(0),a=rd.getContext(),s=e+`#decode`;i.manager.itemStart(s),a.decodeAudioData(r,function(e){t(e),i.manager.itemEnd(s)}).catch(function(e){o(e),i.manager.itemEnd(s)})}catch(e){o(e)}},n,r);function o(t){r?r(t):F(t),i.manager.itemError(e)}}},ad=new V,od=new V,sd=new V,cd=class{constructor(){this.type=`StereoCamera`,this.aspect=1,this.eyeSep=.064,this.cameraL=new Mu,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Mu,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){let 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,sd.copy(e.projectionMatrix);let n=t.eyeSep/2,r=n*t.near/t.focus,i=t.near*Math.tan(bn*t.fov*.5)/t.zoom,a,o;od.elements[12]=-n,ad.elements[12]=n,a=-i*t.aspect+r,o=i*t.aspect+r,sd.elements[0]=2*t.near/(o-a),sd.elements[8]=(o+a)/(o-a),this.cameraL.projectionMatrix.copy(sd),a=-i*t.aspect-r,o=i*t.aspect-r,sd.elements[0]=2*t.near/(o-a),sd.elements[8]=(o+a)/(o-a),this.cameraR.projectionMatrix.copy(sd)}this.cameraL.matrix.copy(e.matrixWorld).multiply(od),this.cameraL.matrixWorldNeedsUpdate=!0,this.cameraR.matrix.copy(e.matrixWorld).multiply(ad),this.cameraR.matrixWorldNeedsUpdate=!0}},ld=-90,ud=1,dd=class extends Br{constructor(e,t,n){super(),this.type=`CubeCamera`,this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new Mu(ld,ud,e,t);r.layers=this.layers,this.add(r);let i=new Mu(ld,ud,e,t);i.layers=this.layers,this.add(i);let a=new Mu(ld,ud,e,t);a.layers=this.layers,this.add(a);let o=new Mu(ld,ud,e,t);o.layers=this.layers,this.add(o);let s=new Mu(ld,ud,e,t);s.layers=this.layers,this.add(s);let c=new Mu(ld,ud,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,r,i,a,o,s]=t;for(let e of t)this.remove(e);if(e===2e3)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),i.up.set(0,0,-1),i.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),s.up.set(0,1,0),s.lookAt(0,0,-1);else if(e===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),i.up.set(0,0,1),i.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),s.up.set(0,-1,0),s.lookAt(0,0,-1);else throw Error(`THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: `+e);for(let e of t)this.add(e),e.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[i,a,o,s,c,l]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;let m=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let h=!1;h=e.isWebGLRenderer===!0?e.state.buffers.depth.getReversed():e.reversedDepthBuffer,e.setRenderTarget(n,0,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,i),e.setRenderTarget(n,1,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,2,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,3,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,s),e.setRenderTarget(n,4,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),n.texture.generateMipmaps=m,e.setRenderTarget(n,5,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(u,d,f),e.xr.enabled=p,n.texture.needsPMREMUpdate=!0}},fd=class extends Mu{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},pd=class{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(e){this._document=e,e.hidden!==void 0&&(this._pageVisibilityHandler=md.bind(this),e.addEventListener(`visibilitychange`,this._pageVisibilityHandler,!1))}disconnect(){this._pageVisibilityHandler!==null&&(this._document.removeEventListener(`visibilitychange`,this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(e){return this._timescale=e,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(e){return this._pageVisibilityHandler!==null&&this._document.hidden===!0?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(e===void 0?performance.now():e)-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}};function md(){this._document.hidden===!1&&this.reset()}var hd=new B,gd=new z,_d=new B,vd=new B,yd=new B,bd=class extends Br{constructor(){super(),this.type=`AudioListener`,this.context=rd.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._timer=new pd}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.context.destination):(this.gain.disconnect(this.filter),this.filter.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),this._timer.update();let t=this.context.listener;if(this.timeDelta=this._timer.getDelta(),this.matrixWorld.decompose(hd,gd,_d),vd.set(0,0,-1).applyQuaternion(gd),yd.set(0,1,0).applyQuaternion(gd),t.positionX){let e=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(hd.x,e),t.positionY.linearRampToValueAtTime(hd.y,e),t.positionZ.linearRampToValueAtTime(hd.z,e),t.forwardX.linearRampToValueAtTime(vd.x,e),t.forwardY.linearRampToValueAtTime(vd.y,e),t.forwardZ.linearRampToValueAtTime(vd.z,e),t.upX.linearRampToValueAtTime(yd.x,e),t.upY.linearRampToValueAtTime(yd.y,e),t.upZ.linearRampToValueAtTime(yd.z,e)}else t.setPosition(hd.x,hd.y,hd.z),t.setOrientation(vd.x,vd.y,vd.z,yd.x,yd.y,yd.z)}},xd=class extends Br{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){P(`Audio: Audio is already playing.`);return}if(this.hasPlaybackControl===!1){P(`Audio: this Audio has no playback control.`);return}this._startedAt=this.context.currentTime+e;let 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){P(`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.duration||this.buffer.duration),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(e=0){if(this.hasPlaybackControl===!1){P(`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||=[],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){P(`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?(P(`Audio: this Audio has no playback control.`),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){P(`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`?(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):(P(`Audio: Audio source type cannot be copied.`),this)}clone(e){return new this.constructor(this.listener).copy(this,e)}},Sd=new B,Cd=new z,J=new B,wd=new B,Td=class extends xd{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(Sd,Cd,J),wd.set(0,0,1).applyQuaternion(Cd);let t=this.panner;if(t.positionX){let e=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Sd.x,e),t.positionY.linearRampToValueAtTime(Sd.y,e),t.positionZ.linearRampToValueAtTime(Sd.z,e),t.orientationX.linearRampToValueAtTime(wd.x,e),t.orientationY.linearRampToValueAtTime(wd.y,e),t.orientationZ.linearRampToValueAtTime(wd.z,e)}else t.setPosition(Sd.x,Sd.y,Sd.z),t.setOrientation(wd.x,wd.y,wd.z)}},Ed=class{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,t=this.getFrequencyData();for(let n=0;n<t.length;n++)e+=t[n];return e/t.length}},Dd=class{constructor(e,t,n){this.binding=e,this.valueSize=n;let r,i,a;switch(t){case`quaternion`:r=this._slerp,i=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case`string`:case`bool`:r=this._select,i=this._select,a=this._setAdditiveIdentityOther,this.buffer=Array(n*5);break;default:r=this._lerp,i=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=i,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let n=this.buffer,r=this.valueSize,i=e*r+r,a=this.cumulativeWeight;if(a===0){for(let e=0;e!==r;++e)n[i+e]=n[e];a=t}else{a+=t;let e=t/a;this._mixBufferRegion(n,i,0,e,r)}this.cumulativeWeight=a}accumulateAdditive(e){let 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){let t=this.valueSize,n=this.buffer,r=e*t+t,i=this.cumulativeWeight,a=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,i<1){let e=t*this._origIndex;this._mixBufferRegion(n,r,e,1-i,t)}a>0&&this._mixBufferRegionAdditive(n,r,this._addIndex*t,1,t);for(let e=t,i=t+t;e!==i;++e)if(n[e]!==n[e+t]){o.setValue(n,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,r=n*this._origIndex;e.getValue(t,r);for(let e=n,i=r;e!==i;++e)t[e]=t[r+e%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let 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(){let 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,i){if(r>=.5)for(let r=0;r!==i;++r)e[t+r]=e[n+r]}_slerp(e,t,n,r){z.slerpFlat(e,t,e,t,e,n,r)}_slerpAdditive(e,t,n,r,i){let a=this._workIndex*i;z.multiplyQuaternionsFlat(e,a,e,t,e,n),z.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,n,r,i){let a=1-r;for(let o=0;o!==i;++o){let i=t+o;e[i]=e[i]*a+e[n+o]*r}}_lerpAdditive(e,t,n,r,i){for(let a=0;a!==i;++a){let i=t+a;e[i]=e[i]+e[n+a]*r}}},Od=`\\[\\]\\.:\\/`,kd=RegExp(`[\\[\\]\\.:\\/]`,`g`),Ad=`[^\\[\\]\\.:\\/]`,jd=`[^`+Od.replace(`\\.`,``)+`]`,Md=`((?:WC+[\\/:])*)`.replace(`WC`,Ad),Nd=`(WCOD+)?`.replace(`WCOD`,jd),Pd=`(?:\\.(WC+)(?:\\[(.+)\\])?)?`.replace(`WC`,Ad),Fd=`\\.(WC+)(?:\\[(.+)\\])?`.replace(`WC`,Ad),Id=RegExp(`^`+Md+Nd+Pd+Fd+`$`),Ld=[`material`,`materials`,`bones`,`map`],Rd=class{constructor(e,t,n){let r=n||Y.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,i=n.length;r!==i;++r)n[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},Y=class e{constructor(t,n,r){this.path=n,this.parsedPath=r||e.parseTrackName(n),this.node=e.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,n,r){return t&&t.isAnimationObjectGroup?new e.Composite(t,n,r):new e(t,n,r)}static sanitizeNodeName(e){return e.replace(/\s/g,`_`).replace(kd,``)}static parseTrackName(e){let t=Id.exec(e);if(t===null)throw Error(`THREE.PropertyBinding: Cannot parse trackName: `+e);let 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){let e=n.nodeName.substring(r+1);Ld.indexOf(e)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=e)}if(n.propertyName===null||n.propertyName.length===0)throw Error(`THREE.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){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(e){for(let r=0;r<e.length;r++){let i=e[r];if(i.name===t||i.uuid===t)return i;let a=n(i.children);if(a)return a}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){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++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){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++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 t=this.node,n=this.parsedPath,r=n.objectName,i=n.propertyName,a=n.propertyIndex;if(t||(t=e.findNode(this.rootNode,n.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){P(`PropertyBinding: No target node found for track: `+this.path+`.`);return}if(r){let e=n.objectIndex;switch(r){case`materials`:if(!t.material){F(`PropertyBinding: Can not bind to material as node does not have a material.`,this);return}if(!t.material.materials){F(`PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.`,this);return}t=t.material.materials;break;case`bones`:if(!t.skeleton){F(`PropertyBinding: Can not bind to bones as node does not have a skeleton.`,this);return}t=t.skeleton.bones;for(let n=0;n<t.length;n++)if(t[n].name===e){e=n;break}break;case`map`:if(`map`in t){t=t.map;break}if(!t.material){F(`PropertyBinding: Can not bind to material as node does not have a material.`,this);return}if(!t.material.map){F(`PropertyBinding: Can not bind to material.map as node.material does not have a map.`,this);return}t=t.material.map;break;default:if(t[r]===void 0){F(`PropertyBinding: Can not bind to objectName of node undefined.`,this);return}t=t[r]}if(e!==void 0){if(t[e]===void 0){F(`PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.`,this,t);return}t=t[e]}}let o=t[i];if(o===void 0){let e=n.nodeName;F(`PropertyBinding: Trying to update property for track: `+e+`.`+i+` but it wasn't found.`,t);return}let s=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?s=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(s=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(a!==void 0){if(i===`morphTargetInfluences`){if(!t.geometry){F(`PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.`,this);return}if(!t.geometry.morphAttributes){F(`PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.`,this);return}t.morphTargetDictionary[a]!==void 0&&(a=t.morphTargetDictionary[a])}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=a}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][s]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Y.Composite=Rd,Y.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Y.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},Y.prototype.GetterByBindingType=[Y.prototype._getValue_direct,Y.prototype._getValue_array,Y.prototype._getValue_arrayElement,Y.prototype._getValue_toArray],Y.prototype.SetterByBindingTypeAndVersioning=[[Y.prototype._setValue_direct,Y.prototype._setValue_direct_setNeedsUpdate,Y.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Y.prototype._setValue_array,Y.prototype._setValue_array_setNeedsUpdate,Y.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Y.prototype._setValue_arrayElement,Y.prototype._setValue_arrayElement_setNeedsUpdate,Y.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Y.prototype._setValue_fromArray,Y.prototype._setValue_fromArray_setNeedsUpdate,Y.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var zd=class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=Sn(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;let e={};this._indicesByUUID=e;for(let t=0,n=arguments.length;t!==n;++t)e[arguments[t].uuid]=t;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};let 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(){let e=this._objects,t=this._indicesByUUID,n=this._paths,r=this._parsedPaths,i=this._bindings,a=i.length,o,s=e.length,c=this.nCachedObjects_;for(let l=0,u=arguments.length;l!==u;++l){let u=arguments[l],d=u.uuid,f=t[d];if(f===void 0){f=s++,t[d]=f,e.push(u);for(let e=0,t=a;e!==t;++e)i[e].push(new Y(u,n[e],r[e]))}else if(f<c){o=e[f];let s=--c,l=e[s];t[l.uuid]=f,e[f]=l,t[d]=s,e[s]=u;for(let e=0,t=a;e!==t;++e){let t=i[e],a=t[s],o=t[f];t[f]=a,o===void 0&&(o=new Y(u,n[e],r[e])),t[s]=o}}else e[f]!==o&&F(`AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.`)}this.nCachedObjects_=c}remove(){let e=this._objects,t=this._indicesByUUID,n=this._bindings,r=n.length,i=this.nCachedObjects_;for(let a=0,o=arguments.length;a!==o;++a){let o=arguments[a],s=o.uuid,c=t[s];if(c!==void 0&&c>=i){let a=i++,l=e[a];t[l.uuid]=c,e[c]=l,t[s]=a,e[a]=o;for(let e=0,t=r;e!==t;++e){let t=n[e],r=t[a],i=t[c];t[c]=r,t[a]=i}}}this.nCachedObjects_=i}uncache(){let e=this._objects,t=this._indicesByUUID,n=this._bindings,r=n.length,i=this.nCachedObjects_,a=e.length;for(let o=0,s=arguments.length;o!==s;++o){let s=arguments[o].uuid,c=t[s];if(c!==void 0)if(delete t[s],c<i){let o=--i,s=e[o],l=--a,u=e[l];t[s.uuid]=c,e[c]=s,t[u.uuid]=o,e[o]=u,e.pop();for(let e=0,t=r;e!==t;++e){let t=n[e],r=t[o],i=t[l];t[c]=r,t[o]=i,t.pop()}}else{let i=--a,o=e[i];i>0&&(t[o.uuid]=c),e[c]=o,e.pop();for(let e=0,t=r;e!==t;++e){let t=n[e];t[c]=t[i],t.pop()}}}this.nCachedObjects_=i}subscribe_(e,t){let n=this._bindingsIndicesByPath,r=n[e],i=this._bindings;if(r!==void 0)return i[r];let a=this._paths,o=this._parsedPaths,s=this._objects,c=s.length,l=this.nCachedObjects_,u=Array(c);r=i.length,n[e]=r,a.push(e),o.push(t),i.push(u);for(let n=l,r=s.length;n!==r;++n){let r=s[n];u[n]=new Y(r,e,t)}return u}unsubscribe_(e){let t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){let r=this._paths,i=this._parsedPaths,a=this._bindings,o=a.length-1,s=a[o],c=e[o];t[c]=n,a[n]=s,a.pop(),i[n]=i[o],i.pop(),r[n]=r[o],r.pop()}}},Bd=class{constructor(e,t,n=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=r;let i=t.tracks,a=i.length,o=Array(a),s={endingStart:yt,endingEnd:yt};for(let e=0;e!==a;++e){let t=i[e].createInterpolant(null);o[e]=t,t.settings=s}this._interpolantSettings=s,this._interpolants=o,this._propertyBindings=Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._restoreTimeScale=null,this._weightInterpolant=null,this.loop=pt,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){let n=this._clip.duration,r=e._clip.duration,i=r/n,a=n/r;e._restoreTimeScale=e.timeScale,this._restoreTimeScale=this.timeScale,e.warp(1,i,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,n=!1){return e.crossFadeFrom(this,t,n)}stopFading(){let 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){let r=this._mixer,i=r.time,a=this.timeScale,o=this._timeScaleInterpolant;o===null&&(o=r._lendControlInterpolant(),this._timeScaleInterpolant=o);let s=o.parameterPositions,c=o.sampleValues;return s[0]=i,s[1]=i+n,c[0]=e/a,c[1]=t/a,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this._restoreTimeScale=null,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}let i=this._startTime;if(i!==null){let r=(e-i)*n;r<0||n===0?t=0:(this._startTime=null,t=n*r)}t*=this._updateTimeScale(e);let a=this._updateTime(t),o=this._updateWeight(e);if(o>0){let e=this._interpolants,t=this._propertyBindings;switch(this.blendMode){case Ct:for(let n=0,r=e.length;n!==r;++n)e[n].evaluate(a),t[n].accumulateAdditive(o);break;case St:default:for(let n=0,i=e.length;n!==i;++n)e[n].evaluate(a),t[n].accumulate(r,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(n!==null){let 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;let n=this._timeScaleInterpolant;if(n!==null){let r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(t===0?this.paused=!0:(this._restoreTimeScale!==null&&(t=this._restoreTimeScale),this.timeScale=t),this.stopWarping())}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,n=this.loop,r=this.time+e,i=this._loopCount,a=n===mt;if(e===0)return i===-1?r:a&&(i&1)==1?t-r:r;if(n===2200){i===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));handle_stop:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break handle_stop}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(i===-1&&(e>=0?(i=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),r>=t||r<0){let n=Math.floor(r/t);r-=t*n,i+=Math.abs(n);let o=this.repetitions-i;if(o<=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(o===1){let t=e<0;this._setEndings(t,!t,a)}else this._setEndings(!1,!1,a);this._loopCount=i,this.time=r,this._mixer.dispatchEvent({type:`loop`,action:this,loopDelta:n})}}else this._loopCount=i,this.time=r;if(a&&(i&1)==1)return t-r}return r}_setEndings(e,t,n){let r=this._interpolantSettings;n?(r.endingStart=bt,r.endingEnd=bt):(r.endingStart=e?this.zeroSlopeAtStart?bt:yt:xt,r.endingEnd=t?this.zeroSlopeAtEnd?bt:yt:xt)}_scheduleFading(e,t,n){let r=this._mixer,i=r.time,a=this._weightInterpolant;a===null&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);let o=a.parameterPositions,s=a.sampleValues;return o[0]=i,s[0]=t,o[1]=i+e,s[1]=n,this}},Vd=new Float32Array(1),Hd=class extends _n{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}_bindAction(e,t){let n=e._localRoot||this._root,r=e._clip.tracks,i=r.length,a=e._propertyBindings,o=e._interpolants,s=n.uuid,c=this._bindingsByRootAndName,l=c[s];l===void 0&&(l={},c[s]=l);for(let e=0;e!==i;++e){let i=r[e],c=i.name,u=l[c];if(u!==void 0)++u.referenceCount,a[e]=u;else{if(u=a[e],u!==void 0){u._cacheIndex===null&&(++u.referenceCount,this._addInactiveBinding(u,s,c));continue}let r=t&&t._propertyBindings[e].binding.parsedPath;u=new Dd(Y.create(n,c,r),i.ValueTypeName,i.getValueSize()),++u.referenceCount,this._addInactiveBinding(u,s,c),a[e]=u}o[e].resultBuffer=u.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let t=(e._localRoot||this._root).uuid,n=e._clip.uuid,r=this._actionsByClip[n];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,n,t)}let t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){let n=t[e];n.useCount++===0&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){let n=t[e];--n.useCount===0&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let 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){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){let r=this._actions,i=this._actionsByClip,a=i[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,i[t]=a;else{let t=a.knownActions;e._byClipCacheIndex=t.length,t.push(e)}e._cacheIndex=r.length,r.push(e),a.actionByRoot[n]=e}_removeInactiveAction(e){let t=this._actions,n=t[t.length-1],r=e._cacheIndex;n._cacheIndex=r,t[r]=n,t.pop(),e._cacheIndex=null;let i=e._clip.uuid,a=this._actionsByClip,o=a[i],s=o.knownActions,c=s[s.length-1],l=e._byClipCacheIndex;c._byClipCacheIndex=l,s[l]=c,s.pop(),e._byClipCacheIndex=null;let u=o.actionByRoot,d=(e._localRoot||this._root).uuid;delete u[d],s.length===0&&delete a[i],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){let n=t[e];--n.referenceCount===0&&this._removeInactiveBinding(n)}}_lendAction(e){let t=this._actions,n=e._cacheIndex,r=this._nActiveActions++,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_takeBackAction(e){let t=this._actions,n=e._cacheIndex,r=--this._nActiveActions,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_addInactiveBinding(e,t,n){let r=this._bindingsByRootAndName,i=this._bindings,a=r[t];a===void 0&&(a={},r[t]=a),a[n]=e,e._cacheIndex=i.length,i.push(e)}_removeInactiveBinding(e){let t=this._bindings,n=e.binding,r=n.rootNode.uuid,i=n.path,a=this._bindingsByRootAndName,o=a[r],s=t[t.length-1],c=e._cacheIndex;s._cacheIndex=c,t[c]=s,t.pop(),delete o[i],Object.keys(o).length===0&&delete a[r]}_lendBinding(e){let t=this._bindings,n=e._cacheIndex,r=this._nActiveBindings++,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_takeBackBinding(e){let t=this._bindings,n=e._cacheIndex,r=--this._nActiveBindings,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,n=e[t];return n===void 0&&(n=new Wl(new Float32Array(2),new Float32Array(2),1,Vd),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){let t=this._controlInterpolants,n=e.__cacheIndex,r=--this._nActiveControlInterpolants,i=t[r];e.__cacheIndex=r,t[r]=e,i.__cacheIndex=n,t[n]=i}clipAction(e,t,n){let r=t||this._root,i=r.uuid,a=typeof e==`string`?tu.findByName(r,e):e,o=a===null?e:a.uuid,s=this._actionsByClip[o],c=null;if(n===void 0&&(n=a===null?St:a.blendMode),s!==void 0){let e=s.actionByRoot[i];if(e!==void 0&&e.blendMode===n)return e;c=s.knownActions[0],a===null&&(a=c._clip)}if(a===null)return null;let l=new Bd(this,a,t,n);return this._bindAction(l,c),this._addInactiveAction(l,o,i),l}existingAction(e,t){let n=t||this._root,r=n.uuid,i=typeof e==`string`?tu.findByName(n,e):e,a=i?i.uuid:e,o=this._actionsByClip[a];return o===void 0?null:o.actionByRoot[r]||null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,r=this.time+=e,i=Math.sign(e),a=this._accuIndex^=1;for(let o=0;o!==n;++o)t[o]._update(r,e,i,a);let o=this._bindings,s=this._nActiveBindings;for(let e=0;e!==s;++e)o[e].apply(a);return this}setTime(e){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,n=e.uuid,r=this._actionsByClip,i=r[n];if(i!==void 0){let e=i.knownActions;for(let n=0,r=e.length;n!==r;++n){let r=e[n];this._deactivateAction(r);let i=r._cacheIndex,a=t[t.length-1];r._cacheIndex=null,r._byClipCacheIndex=null,a._cacheIndex=i,t[i]=a,t.pop(),this._removeInactiveBindingsForAction(r)}delete r[n]}}uncacheRoot(e){let t=e.uuid,n=this._actionsByClip;for(let e in n){let r=n[e].actionByRoot[t];r!==void 0&&(this._deactivateAction(r),this._removeInactiveAction(r))}let r=this._bindingsByRootAndName[t];if(r!==void 0)for(let e in r){let t=r[e];t.restoreOriginalState(),this._removeInactiveBinding(t)}}uncacheAction(e,t){let n=this.existingAction(e,t);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}},Ud=class extends cr{constructor(e=1,t=1,n=1,r={}){super(e,t,r),this.isRenderTarget3D=!0,this.depth=n,this.texture=new fr(null,e,t,n),this._setTextureOptions(r),this.texture.isRenderTargetTexture=!0}},Wd=class e{constructor(e){this.value=e}clone(){return new e(this.value.clone===void 0?this.value:this.value.clone())}},Gd=0,Kd=class extends _n{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:Gd++}),this.name=``,this.usage=zt,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){let 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;let t=e.uniforms;this.uniforms.length=0;for(let e=0,n=t.length;e<n;e++){let n=Array.isArray(t[e])?t[e]:[t[e]];for(let e=0;e<n.length;e++)this.uniforms.push(n[e].clone())}return this}clone(){return new this.constructor().copy(this)}},qd=class extends ta{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){let t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){let t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}},Jd=class{constructor(e,t,n,r,i,a=!1){this.isGLBufferAttribute=!0,this.name=``,this.buffer=e,this.type=t,this.itemSize=n,this.elementSize=r,this.count=i,this.normalized=a,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}},Yd=new V,Xd=class{constructor(e,t,n=0,r=1/0){this.ray=new Ma(e,t),this.near=n,this.far=r,this.camera=null,this.layers=new wr,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.projectionMatrix.elements[14]).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):F(`Raycaster: Unsupported camera type: `+t.type)}setFromXRController(e){return Yd.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Yd),this}intersectObject(e,t=!0,n=[]){return Qd(e,this,n,t),n.sort(Zd),n}intersectObjects(e,t=!0,n=[]){for(let r=0,i=e.length;r<i;r++)Qd(e[r],this,n,t);return n.sort(Zd),n}};function Zd(e,t){return e.distance-t.distance}function Qd(e,t,n,r){let i=!0;if(e.layers.test(t.layers)&&e.raycast(t,n)===!1&&(i=!1),i===!0&&r===!0){let r=e.children;for(let e=0,i=r.length;e<i;e++)Qd(r[e],t,n,!0)}}var $d=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1,P(`Clock: This module has been deprecated. Please use THREE.Timer instead.`)}start(){this.startTime=performance.now(),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){let t=performance.now();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}},ef=class{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(){let e=1e-6;return this.phi=I(this.phi,e,Math.PI-e),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(I(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},tf=class{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)}},nf=class e{static{e.prototype.isMatrix2=!0}constructor(e,t,n,r){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){let i=this.elements;return i[0]=e,i[2]=t,i[1]=n,i[3]=r,this}},rf=new R,af=class{constructor(e=new R(1/0,1/0),t=new R(-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){let n=rf.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,rf).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)}},of=new B,sf=new B,cf=new B,lf=new B,uf=new B,df=new B,ff=new B,pf=class{constructor(e=new B,t=new B){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){of.subVectors(e,this.start),sf.subVectors(this.end,this.start);let n=sf.dot(sf);if(n===0)return 0;let r=sf.dot(of)/n;return t&&(r=I(r,0,1)),r}closestPointToPoint(e,t,n){let r=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(r).add(this.start)}distanceSqToLine3(e,t=df,n=ff){let r=1e-8*1e-8,i,a,o=this.start,s=e.start,c=this.end,l=e.end;cf.subVectors(c,o),lf.subVectors(l,s),uf.subVectors(o,s);let u=cf.dot(cf),d=lf.dot(lf),f=lf.dot(uf);if(u<=r&&d<=r)return t.copy(o),n.copy(s),t.sub(n),t.dot(t);if(u<=r)i=0,a=f/d,a=I(a,0,1);else{let e=cf.dot(uf);if(d<=r)a=0,i=I(-e/u,0,1);else{let t=cf.dot(lf),n=u*d-t*t;i=n===0?0:I((t*f-e*d)/n,0,1),a=(t*i+f)/d,a<0?(a=0,i=I(-e/u,0,1)):a>1&&(a=1,i=I((t-e)/u,0,1))}}return t.copy(o).addScaledVector(cf,i),n.copy(s).addScaledVector(lf,a),t.distanceToSquared(n)}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)}},mf=new B,hf=class extends Br{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type=`SpotLightHelper`;let n=new W,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 e=0,t=1;e<32;e++,t++){let n=e/32*Math.PI*2,i=t/32*Math.PI*2;r.push(Math.cos(n),Math.sin(n),1,Math.cos(i),Math.sin(i),1)}n.setAttribute(`position`,new U(r,3));let i=new qo({fog:!1,toneMapped:!1});this.cone=new as(n,i),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.matrixWorldNeedsUpdate=!0;let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),mf.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(mf),this.color===void 0?this.cone.material.color.copy(this.light.color):this.cone.material.color.set(this.color)}},gf=new B,_f=new V,vf=new V,yf=class extends as{constructor(e){let t=bf(e),n=new W,r=[],i=[];for(let e=0;e<t.length;e++){let n=t[e];n.parent&&n.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),i.push(0,0,0),i.push(0,0,0))}n.setAttribute(`position`,new U(r,3)),n.setAttribute(`color`,new U(i,3));let a=new qo({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(n,a),this.isSkeletonHelper=!0,this.type=`SkeletonHelper`,this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1;let o=new H(255),s=new H(65280);this.setColors(o,s)}updateMatrixWorld(e){let t=this.bones,n=this.geometry,r=n.getAttribute(`position`);vf.copy(this.root.matrixWorld).invert();for(let e=0,n=0;e<t.length;e++){let i=t[e];i.parent&&i.parent.isBone&&(_f.multiplyMatrices(vf,i.matrixWorld),gf.setFromMatrixPosition(_f),r.setXYZ(n,gf.x,gf.y,gf.z),_f.multiplyMatrices(vf,i.parent.matrixWorld),gf.setFromMatrixPosition(_f),r.setXYZ(n+1,gf.x,gf.y,gf.z),n+=2)}n.getAttribute(`position`).needsUpdate=!0,super.updateMatrixWorld(e)}setColors(e,t){let n=this.geometry.getAttribute(`color`);for(let r=0;r<n.count;r+=2)n.setXYZ(r,e.r,e.g,e.b),n.setXYZ(r+1,t.r,t.g,t.b);return n.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};function bf(e){let t=[];e.isBone===!0&&t.push(e);for(let n=0;n<e.children.length;n++)t.push(...bf(e.children[n]));return t}var xf=class extends Ga{constructor(e,t,n){let r=new cl(t,4,2),i=new Na({wireframe:!0,fog:!1,toneMapped:!1});super(r,i),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.matrixWorldNeedsUpdate=!0,this.light.updateWorldMatrix(!0,!1),this.color===void 0?this.material.color.copy(this.light.color):this.material.color.set(this.color)}},Sf=new B,Cf=new H,wf=new H,Tf=class extends Br{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type=`HemisphereLightHelper`;let r=new rl(t);r.rotateY(Math.PI*.5),this.material=new Na({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);let i=r.getAttribute(`position`),a=new Float32Array(i.count*3);r.setAttribute(`color`,new Fi(a,3)),this.add(new Ga(r,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){let e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{let t=e.geometry.getAttribute(`color`);Cf.copy(this.light.color),wf.copy(this.light.groundColor);for(let e=0,n=t.count;e<n;e++){let r=e<n/2?Cf:wf;t.setXYZ(e,r.r,r.g,r.b)}t.needsUpdate=!0}this.matrixWorldNeedsUpdate=!0,this.light.updateWorldMatrix(!0,!1),e.lookAt(Sf.setFromMatrixPosition(this.light.matrixWorld).negate())}},Ef=class extends as{constructor(e=10,t=10,n=4473924,r=8947848){n=new H(n),r=new H(r);let i=t/2,a=e/t,o=e/2,s=[],c=[];for(let e=0,l=0,u=-o;e<=t;e++,u+=a){s.push(-o,0,u,o,0,u),s.push(u,0,-o,u,0,o);let t=e===i?n:r;t.toArray(c,l),l+=3,t.toArray(c,l),l+=3,t.toArray(c,l),l+=3,t.toArray(c,l),l+=3}let l=new W;l.setAttribute(`position`,new U(s,3)),l.setAttribute(`color`,new U(c,3));let u=new qo({vertexColors:!0,toneMapped:!1});super(l,u),this.type=`GridHelper`}dispose(){this.geometry.dispose(),this.material.dispose()}},Df=class extends as{constructor(e=10,t=16,n=8,r=64,i=4473924,a=8947848){i=new H(i),a=new H(a);let o=[],s=[];if(t>1)for(let n=0;n<t;n++){let r=n/t*(Math.PI*2),c=Math.sin(r)*e,l=Math.cos(r)*e;o.push(0,0,0),o.push(c,0,l);let u=n&1?i:a;s.push(u.r,u.g,u.b),s.push(u.r,u.g,u.b)}for(let t=0;t<n;t++){let c=t&1?i:a,l=e-e/n*t;for(let e=0;e<r;e++){let t=e/r*(Math.PI*2),n=Math.sin(t)*l,i=Math.cos(t)*l;o.push(n,0,i),s.push(c.r,c.g,c.b),t=(e+1)/r*(Math.PI*2),n=Math.sin(t)*l,i=Math.cos(t)*l,o.push(n,0,i),s.push(c.r,c.g,c.b)}}let c=new W;c.setAttribute(`position`,new U(o,3)),c.setAttribute(`color`,new U(s,3));let l=new qo({vertexColors:!0,toneMapped:!1});super(c,l),this.type=`PolarGridHelper`}dispose(){this.geometry.dispose(),this.material.dispose()}},Of=new B,kf=new B,Af=new B,jf=class extends Br{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 W;r.setAttribute(`position`,new U([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let i=new qo({fog:!1,toneMapped:!1});this.lightPlane=new ts(r,i),this.add(this.lightPlane),r=new W,r.setAttribute(`position`,new U([0,0,0,0,0,1],3)),this.targetLine=new ts(r,i),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.matrixWorldNeedsUpdate=!0,this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),Of.setFromMatrixPosition(this.light.matrixWorld),kf.setFromMatrixPosition(this.light.target.matrixWorld),Af.subVectors(kf,Of),this.lightPlane.lookAt(kf),this.color===void 0?(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)):(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)),this.targetLine.lookAt(kf),this.targetLine.scale.z=Af.length()}},Mf=new B,Nf=new Ou,Pf=class extends as{constructor(e){let t=new W,n=new qo({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],i=[],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(e,t){s(e),s(t)}function s(e){r.push(0,0,0),i.push(0,0,0),a[e]===void 0&&(a[e]=[]),a[e].push(r.length/3-1)}t.setAttribute(`position`,new U(r,3)),t.setAttribute(`color`,new U(i,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();let c=new H(16755200),l=new H(16711680),u=new H(43775),d=new H(16777215),f=new H(3355443);this.setColors(c,l,u,d,f)}setColors(e,t,n,r,i){let a=this.geometry.getAttribute(`color`);return a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,n.r,n.g,n.b),a.setXYZ(33,n.r,n.g,n.b),a.setXYZ(34,n.r,n.g,n.b),a.setXYZ(35,n.r,n.g,n.b),a.setXYZ(36,n.r,n.g,n.b),a.setXYZ(37,n.r,n.g,n.b),a.setXYZ(38,r.r,r.g,r.b),a.setXYZ(39,r.r,r.g,r.b),a.setXYZ(40,i.r,i.g,i.b),a.setXYZ(41,i.r,i.g,i.b),a.setXYZ(42,i.r,i.g,i.b),a.setXYZ(43,i.r,i.g,i.b),a.setXYZ(44,i.r,i.g,i.b),a.setXYZ(45,i.r,i.g,i.b),a.setXYZ(46,i.r,i.g,i.b),a.setXYZ(47,i.r,i.g,i.b),a.setXYZ(48,i.r,i.g,i.b),a.setXYZ(49,i.r,i.g,i.b),a.needsUpdate=!0,this}update(){let e=this.geometry,t=this.pointMap,n,r;if(Nf.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),this.camera.reversedDepth===!0)n=1,r=0;else if(this.camera.coordinateSystem===2e3)n=-1,r=1;else if(this.camera.coordinateSystem===2001)n=0,r=1;else throw Error(`THREE.CameraHelper.update(): Invalid coordinate system: `+this.camera.coordinateSystem);Ff(`c`,t,e,Nf,0,0,n),Ff(`t`,t,e,Nf,0,0,r),Ff(`n1`,t,e,Nf,-1,-1,n),Ff(`n2`,t,e,Nf,1,-1,n),Ff(`n3`,t,e,Nf,-1,1,n),Ff(`n4`,t,e,Nf,1,1,n),Ff(`f1`,t,e,Nf,-1,-1,r),Ff(`f2`,t,e,Nf,1,-1,r),Ff(`f3`,t,e,Nf,-1,1,r),Ff(`f4`,t,e,Nf,1,1,r),Ff(`u1`,t,e,Nf,.7,1.1,n),Ff(`u2`,t,e,Nf,-.7,1.1,n),Ff(`u3`,t,e,Nf,0,2,n),Ff(`cf1`,t,e,Nf,-1,0,r),Ff(`cf2`,t,e,Nf,1,0,r),Ff(`cf3`,t,e,Nf,0,-1,r),Ff(`cf4`,t,e,Nf,0,1,r),Ff(`cn1`,t,e,Nf,-1,0,n),Ff(`cn2`,t,e,Nf,1,0,n),Ff(`cn3`,t,e,Nf,0,-1,n),Ff(`cn4`,t,e,Nf,0,1,n),e.getAttribute(`position`).needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Ff(e,t,n,r,i,a,o){Mf.set(i,a,o).unproject(r);let s=t[e];if(s!==void 0){let e=n.getAttribute(`position`);for(let t=0,n=s.length;t<n;t++)e.setXYZ(s[t],Mf.x,Mf.y,Mf.z)}}var If=new fi,Lf=class extends as{constructor(e,t=16776960){let 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),i=new W;i.setIndex(new Fi(n,1)),i.setAttribute(`position`,new Fi(r,3)),super(i,new qo({color:t,toneMapped:!1})),this.object=e,this.type=`BoxHelper`,this.matrixAutoUpdate=!1,this.update()}update(){if(this.object!==void 0&&If.setFromObject(this.object),If.isEmpty())return;let e=If.min,t=If.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()}},Rf=class extends as{constructor(e,t=16776960){let 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],i=new W;i.setIndex(new Fi(n,1)),i.setAttribute(`position`,new U(r,3)),super(i,new qo({color:t,toneMapped:!1})),this.box=e,this.type=`Box3Helper`,this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let 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()}},zf=class extends ts{constructor(e,t=1,n=16776960){let r=n,i=[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 W;a.setAttribute(`position`,new U(i,3)),a.computeBoundingSphere(),super(a,new qo({color:r,toneMapped:!1})),this.type=`PlaneHelper`,this.plane=e,this.size=t;let o=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],s=new W;s.setAttribute(`position`,new U(o,3)),s.computeBoundingSphere(),this.add(new Ga(s,new Na({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()}},Bf=new B,Vf,Hf,Uf=class extends Br{constructor(e=new B(0,0,1),t=new B(0,0,0),n=1,r=16776960,i=n*.2,a=i*.2){super(),this.type=`ArrowHelper`,Vf===void 0&&(Vf=new W,Vf.setAttribute(`position`,new U([0,0,0,0,1,0],3)),Hf=new As(.5,1,5,1),Hf.translate(0,-.5,0)),this.position.copy(t),this.line=new ts(Vf,new qo({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Ga(Hf,new Na({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(n,i,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{Bf.set(e.z,0,-e.x).normalize();let t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Bf,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()}},Wf=class extends as{constructor(e=1){let 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 W;r.setAttribute(`position`,new U(t,3)),r.setAttribute(`color`,new U(n,3));let i=new qo({vertexColors:!0,toneMapped:!1});super(r,i),this.type=`AxesHelper`}setColors(e,t,n){let r=new H,i=this.geometry.attributes.color.array;return r.set(e),r.toArray(i,0),r.toArray(i,3),r.set(t),r.toArray(i,6),r.toArray(i,9),r.set(n),r.toArray(i,12),r.toArray(i,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},Gf=class{constructor(){this.type=`ShapePath`,this.color=new H,this.subPaths=[],this.currentPath=null,this.userData={}}moveTo(e,t){return this.currentPath=new pc,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,i,a){return this.currentPath.bezierCurveTo(e,t,n,r,i,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(){function e(e,t){let n=!1,r=t.length;for(let i=0,a=r-1;i<r;a=i++){let r=t[i],o=t[a];r.y>e.y!=o.y>e.y&&e.x<(o.x-r.x)*(e.y-r.y)/(o.y-r.y)+r.x&&(n=!n)}return n}function t(t,n){let r=n.getCenter(new R);if(e(r,t))return r;let i=r.y,a=[],o=t.length;for(let e=0;e<o;e++){let n=t[e],r=t[(e+1)%o];if(n.y>i!=r.y>i){let e=n.x+(i-n.y)*(r.x-n.x)/(r.y-n.y);a.push(e)}}return a.length>1&&(a.sort((e,t)=>e-t),r.x=(a[0]+a[1])/2),r}let n=this.userData.style&&this.userData.style.fillRule||`nonzero`;n!==`nonzero`&&n!==`evenodd`&&(P(`Fill-rule "`+n+`" is not supported, falling back to "nonzero".`),n=`nonzero`);let r=n===`nonzero`?(e=>e!==0):(e=>!!(e&1)),i=[];for(let e of this.subPaths){let n=e.getPoints();if(n.length<3)continue;let r=Yc.area(n);if(r===0)continue;let a=new af;for(let e=0;e<n.length;e++)a.expandByPoint(n[e]);i.push({subPath:e,points:n,boundingBox:a,interiorPoint:t(n,a),absArea:Math.abs(r),winding:r<0?-1:1,container:null,exclude:!1,role:null})}i.sort((e,t)=>t.absArea-e.absArea);for(let t=0;t<i.length;t++){let n=i[t],a=0;for(let r=t-1;r>=0;r--){let t=i[r];if(t.boundingBox.containsBox(n.boundingBox)&&e(n.interiorPoint,t.points)){n.container=t.exclude?t.container:t,a=t.winding,n.winding+=a;break}}r(n.winding)===r(a)&&(n.exclude=!0)}for(let e of i)e.exclude||(e.role=e.container===null||e.container.role===`hole`?`outer`:`hole`);let a=[],o=new Map;for(let e of i){if(e.exclude||e.role!==`outer`)continue;let t=new mc;t.curves=e.subPath.curves,a.push(t),o.set(e,t)}for(let e of i){if(e.exclude||e.role!==`hole`)continue;let t=o.get(e.container);if(!t)continue;let n=new pc;n.curves=e.subPath.curves,t.holes.push(n)}return a}},Kf=class extends _n{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){P(`Controls: connect() now requires an element.`);return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}};function qf(e,t){let n=e.image&&e.image.width?e.image.width/e.image.height:1;return n>t?(e.repeat.x=1,e.repeat.y=n/t,e.offset.x=0,e.offset.y=(1-e.repeat.y)/2):(e.repeat.x=t/n,e.repeat.y=1,e.offset.x=(1-e.repeat.x)/2,e.offset.y=0),e}function Jf(e,t){let n=e.image&&e.image.width?e.image.width/e.image.height:1;return n>t?(e.repeat.x=t/n,e.repeat.y=1,e.offset.x=(1-e.repeat.x)/2,e.offset.y=0):(e.repeat.x=1,e.repeat.y=n/t,e.offset.x=0,e.offset.y=(1-e.repeat.y)/2),e}function Yf(e){return e.repeat.x=1,e.repeat.y=1,e.offset.x=0,e.offset.y=0,e}function Xf(e,t,n,r){let i=Zf(r);switch(n){case be:return e*t;case Te:return e*t/i.components*i.byteLength;case Ee:return e*t/i.components*i.byteLength;case De:return e*t*2/i.components*i.byteLength;case Oe:return e*t*2/i.components*i.byteLength;case xe:return e*t*3/i.components*i.byteLength;case Se:return e*t*4/i.components*i.byteLength;case Ae:return e*t*4/i.components*i.byteLength;case je:case Me:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case Ne:case Pe:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case Ie:case N:return Math.max(e,16)*Math.max(t,8)/4;case Fe:case Le:return Math.max(e,8)*Math.max(t,8)/2;case Re:case ze:case Ve:case He:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case Be:case Ue:case We:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case Ge:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case Ke:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case qe:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case Je:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case Ye:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case Xe:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case Ze:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case Qe:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case $e:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case et:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case tt:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case nt:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case rt:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case it:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case at:case ot:case st:return Math.ceil(e/4)*Math.ceil(t/4)*16;case ct:case lt:return Math.ceil(e/4)*Math.ceil(t/4)*8;case ut:case dt:return Math.ceil(e/4)*Math.ceil(t/4)*16}throw Error(`Unable to determine texture byte length for ${n} format.`)}function Zf(e){switch(e){case se:case ce:return{byteLength:1,components:1};case ue:case le:case me:return{byteLength:2,components:1};case he:case ge:return{byteLength:2,components:4};case fe:case de:case pe:return{byteLength:4,components:1};case ve:case ye:return{byteLength:4,components:3}}throw Error(`THREE.TextureUtils: Unknown texture type ${e}.`)}var Qf=class{static contain(e,t){return qf(e,t)}static cover(e,t){return Jf(e,t)}static fill(e){return Yf(e)}static getByteLength(e,t,n,r){return Xf(e,t,n,r)}};typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`register`,{detail:{revision:`185`}})),typeof window<`u`&&(window.__THREE__?P(`WARNING: Multiple instances of Three.js being imported.`):window.__THREE__=`185`);var $f=[{id:`hips`,bone:`mixamorigHips`,label:`Hips`},{id:`spine`,bone:`mixamorigSpine`,label:`Spine`},{id:`chest`,bone:`mixamorigSpine1`,label:`Chest`},{id:`upperChest`,bone:`mixamorigSpine2`,label:`Upper Chest`},{id:`neck`,bone:`mixamorigNeck`,label:`Neck`},{id:`head`,bone:`mixamorigHead`,label:`Head`},{id:`lShoulder`,bone:`mixamorigLeftShoulder`,label:`L Shoulder`},{id:`rShoulder`,bone:`mixamorigRightShoulder`,label:`R Shoulder`},{id:`lArm`,bone:`mixamorigLeftArm`,label:`L Upper Arm`},{id:`rArm`,bone:`mixamorigRightArm`,label:`R Upper Arm`},{id:`lForeArm`,bone:`mixamorigLeftForeArm`,label:`L Forearm`},{id:`rForeArm`,bone:`mixamorigRightForeArm`,label:`R Forearm`},{id:`lHand`,bone:`mixamorigLeftHand`,label:`L Hand`},{id:`rHand`,bone:`mixamorigRightHand`,label:`R Hand`},{id:`lUpLeg`,bone:`mixamorigLeftUpLeg`,label:`L Thigh`},{id:`rUpLeg`,bone:`mixamorigRightUpLeg`,label:`R Thigh`},{id:`lLeg`,bone:`mixamorigLeftLeg`,label:`L Shin`},{id:`rLeg`,bone:`mixamorigRightLeg`,label:`R Shin`},{id:`lFoot`,bone:`mixamorigLeftFoot`,label:`L Foot`},{id:`rFoot`,bone:`mixamorigRightFoot`,label:`R Foot`}];function ep(e){return String(e??``).replace(/[^a-zA-Z0-9]/g,``).toLowerCase()}function tp(e,t){let n=ep(e),r=ep(t.bone);return n===r||n.endsWith(r)||r.endsWith(n)}var np={id:`default`,label:`Default`,prompt:`standing relaxed with arms hanging naturally at their sides`,bones:{lArm:[1.5632,.1164,-.2889],rArm:[1.5632,-.1164,.2889],lForeArm:[-.0076,3e-4,-.0874],rForeArm:[-.0076,-3e-4,.0874]}},rp=`cozyclay_poses`,ip=new WeakMap;function ap(e,t,n){let r=Math.cos(e/2),i=Math.cos(t/2),a=Math.cos(n/2),o=Math.sin(e/2),s=Math.sin(t/2),c=Math.sin(n/2);return{x:o*i*a+r*s*c,y:r*s*a-o*i*c,z:r*i*c+o*s*a,w:r*i*a-o*s*c}}function op(e,t){return{x:e.w*t.x+e.x*t.w+e.y*t.z-e.z*t.y,y:e.w*t.y-e.x*t.z+e.y*t.w+e.z*t.x,z:e.w*t.z+e.x*t.y-e.y*t.x+e.z*t.w,w:e.w*t.w-e.x*t.x-e.y*t.y-e.z*t.z}}function sp(e){return{x:-e.x,y:-e.y,z:-e.z,w:e.w}}function cp(e){let t=1-2*(e.y*e.y+e.z*e.z),n=2*(e.x*e.y-e.w*e.z),r=2*(e.x*e.z+e.w*e.y),i=1-2*(e.x*e.x+e.z*e.z),a=2*(e.y*e.z-e.w*e.x),o=2*(e.y*e.z+e.w*e.x),s=1-2*(e.x*e.x+e.y*e.y),c=Math.asin(Math.max(-1,Math.min(1,r)));return Math.abs(r)<.9999999?[Math.atan2(-a,s),c,Math.atan2(-n,t)]:[Math.atan2(o,i),c,0]}function lp(e){if(!e||e.userData?.poseBind)return;let t=new Map;e.traverse(e=>{if(e.isBone){let n=e.quaternion,r=e.position;t.set(e,{x:n.x,y:n.y,z:n.z,w:n.w,position:{x:r.x,y:r.y,z:r.z}})}}),e.userData.poseBind=t}function up(e){let t=e.userData&&e.userData.poseBind;if(t)return t;let n=ip.get(e);return n||(n=new Map,e.traverse(e=>{if(e.isBone){let t=e.quaternion,r=e.position;n.set(e,{x:t.x,y:t.y,z:t.z,w:t.w,position:{x:r.x,y:r.y,z:r.z}})}}),ip.set(e,n)),n}function dp(e,t){for(let n=e.parent;n;n=n.parent)if(t.includes(n))return!0;return!1}function fp(e,t){let n=$f.length,r=0;if(e&&t){let n=up(e),i=new Map;e.traverse(e=>{if(e.isBone){for(let t of $f)if(tp(e.name,t)){let n=i.get(t.id);n||i.set(t.id,n=[]),n.push(e)}}});for(let e of $f){let a=t[e.id],o=i.get(e.id);if(!o||!Array.isArray(a)||a.length<3)continue;let s=ap(a[0],a[1],a[2]),c=[];for(let e of o){if(c.length&&dp(e,c))continue;c.push(e);let t=op(s,n.get(e)??n.get(o[0])??{x:0,y:0,z:0,w:1});e.quaternion.set(t.x,t.y,t.z,t.w)}r++}e.updateMatrixWorld(!0)}return{applied:r,total:n}}function pp(e){let t={};if(e){let n=up(e),r=new Map;e.traverse(e=>{if(e.isBone){for(let t of $f)if(!r.has(t.id)&&tp(e.name,t)){r.set(t.id,e);break}}});for(let e of $f){let i=r.get(e.id);if(i){let r=i.quaternion,a=n.get(i),o=a?op({x:r.x,y:r.y,z:r.z,w:r.w},sp(a)):{x:r.x,y:r.y,z:r.z,w:r.w};t[e.id]=cp(o)}}}return t}function mp(e){let t=$f.find(e=>e.id===`hips`),n=null;return e.traverse(e=>{!n&&e.isBone&&tp(e.name,t)&&(n=e)}),n}function hp(e){if(!e)return 0;let t=mp(e);if(!t)return 0;let n=up(e).get(t);return n?.position?t.position.y-n.position.y:0}function gp(e){if(!e)return;let t=up(e);e.traverse(e=>{if(!e.isBone)return;let n=t.get(e)?.position;n&&e.position.set(n.x,n.y,n.z)}),e.updateMatrixWorld(!0)}function _p(e,t=0){if(!e)return;let n=mp(e);if(!n)return;let r=up(e).get(n);r?.position&&(n.position.y=r.position.y+(Number.isFinite(t)?t:0),n.updateMatrixWorld(!0))}function vp(){try{let e=localStorage.getItem(rp);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>e&&typeof e==`object`&&typeof e.id==`string`&&e.bones&&typeof e.bones==`object`):[]}catch{return[]}}function yp(e){try{return localStorage.setItem(rp,JSON.stringify(e)),!0}catch{return!1}}var bp=240,xp=(e,t,n)=>Math.min(n,Math.max(t,e)),Sp=(e,t=0)=>typeof e==`number`&&Number.isFinite(e)?e:t;function Cp(e){let t=e&&typeof e==`object`?e:{};return{x:xp(Sp(t.x),-240,bp),y:xp(Sp(t.y),0,60),z:xp(Sp(t.z),-240,bp)}}function wp(e){if(!e||typeof e!=`object`)return null;let t=Array.isArray(e.points)?e.points:[],r=[];for(let e of t){let t=Cp(e),n=r[r.length-1];if(!(n&&Math.hypot(t.x-n.x,t.z-n.z,t.y-n.y)<1e-4)&&(r.push(t),r.length>=64))break}if(r.length<2)return null;let i=Sp(e.speed,0),a=n(e.timing);return{points:r,timing:u(a)?null:a,speed:i>0?xp(i,.01,50):0,faceTravel:e.faceTravel!==!1,loop:e.loop===!0,extend:e.extend===!0}}function Tp(e,t){let n=wp(e);if(!n)return null;let r=Sp(t?.x),i=Sp(t?.y),a=Sp(t?.z);return!r&&!i&&!a?n:wp({...n,points:n.points.map(e=>({x:e.x+r,y:e.y+i,z:e.z+a}))})}function Ep(e){let t=e?.points??[],n=[0];for(let e=1;e<t.length;e+=1){let r=t[e-1],i=t[e];n.push(n[e-1]+Math.hypot(i.x-r.x,i.y-r.y,i.z-r.z))}return{cumulative:n,length:n[n.length-1]??0}}function Dp(e,t,n){let{points:r}=e,{cumulative:i,length:a}=t;if(n<=0){let e=Op(r[0],r[1]);return{...r[0],heading:e}}if(n>=a){let t=r[r.length-1],i=Op(r[r.length-2],t);if(!e.extend)return{...t,heading:i};let o=n-a,s=r[r.length-2],c=Math.hypot(t.x-s.x,t.y-s.y,t.z-s.z)||1;return{x:t.x+(t.x-s.x)/c*o,y:Math.max(0,t.y+(t.y-s.y)/c*o),z:t.z+(t.z-s.z)/c*o,heading:i}}let o=1;for(;o<i.length-1&&i[o]<n;)o+=1;let s=r[o-1],c=r[o],l=i[o]-i[o-1],u=l>1e-9?(n-i[o-1])/l:0;return{x:s.x+(c.x-s.x)*u,y:s.y+(c.y-s.y)*u,z:s.z+(c.z-s.z)*u,heading:Op(s,c)}}function Op(e,t){if(!e||!t)return null;let n=t.x-e.x,r=t.z-e.z;return Math.abs(n)<1e-9&&Math.abs(r)<1e-9?null:Math.atan2(n,r)*180/Math.PI}function kp(e,t,n={}){let r=wp(e?.path);if(!r)return null;let i=Ep(r);if(i.length<=1e-9)return null;let a=Math.max(1,Math.round(Sp(n.frameCount,1))),s=Math.max(1,Sp(n.fps,24)),c=xp(Sp(t),0,Math.max(0,a-1))/s,l=Math.max(1e-6,(a-1)/s),u=r.speed>0?r.speed:i.length/l,d=i.length/u,f=c/Math.max(1e-6,d),p;p=r.loop&&i.length>1e-9?i.length*o(r.timing,f-Math.floor(f)):f>=1?i.length+(r.extend?u*(c-d):0):i.length*o(r.timing,f);let m=Dp(r,i,p);return{x:m.x,y:m.y,z:m.z,rot:r.faceTravel&&m.heading!==null?m.heading:null}}function Ap(e,t,{maxPoints:n=5,epsilon:r=.55}={}){if(!e||e.length<2)return[];let i=t(e,r);for(let a=0;a<12&&i.length>n;a+=1)r*=1.8,i=t(e,r);if(i.length>n){let e=[i[0]];for(let t=1;t<n-1;t+=1)e.push(i[Math.round(t*(i.length-1)/(n-1))]);e.push(i[i.length-1]),i=e}return i.map(e=>({x:e.x,y:0,z:e.z}))}var jp=`img-`,Mp=`mesh-`,Np=32,Pp=`cozyclay.assets`,Fp=`images`,Ip=Object.freeze([`image/png`,`image/webp`,`image/jpeg`,`image/gif`]),Lp=Object.freeze([`model/gltf-binary`,`model/obj`,`model/fbx`]),Rp=33554432,zp=2048;function Bp(e){return typeof e==`string`&&Ip.includes(e.toLowerCase())}function Vp(e){return typeof e==`string`&&Lp.includes(e.toLowerCase())}function Hp(e,t){if(typeof t!=`string`)return null;let n=t.trim().toLowerCase();return!/^[0-9a-f]+$/.test(n)||n.length<Np?null:`${e}${n.slice(0,Np)}`}function Up(e,t){return typeof t==`string`&&RegExp(`^${e}[0-9a-f]{${Np}}$`).test(t)}function Wp(e){return Hp(jp,e)}function Gp(e){return Hp(Mp,e)}function Kp(e){return Up(jp,e)}function qp(e){return Up(Mp,e)}function Jp(e){return Kp(e)||qp(e)}async function Yp(e,t){if(!t?.digest)throw Error(`SubtleCrypto is unavailable — a secure context is required to import images`);let n=e instanceof ArrayBuffer?e:e?.buffer?e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength):null;if(!n)return null;let r=await t.digest(`SHA-256`,n);return Array.from(new Uint8Array(r),e=>e.toString(16).padStart(2,`0`)).join(``)}async function Xp(e,t=globalThis.crypto?.subtle){let n=await Yp(e,t);if(!n)throw TypeError(`assetIdForBytes needs an ArrayBuffer or a typed array`);return Wp(n)}async function Zp(e,t=globalThis.crypto?.subtle){let n=await Yp(e,t);if(!n)throw TypeError(`meshIdForBytes needs an ArrayBuffer or a typed array`);return Gp(n)}function Qp(e,t,n=zp){let r=Math.max(0,Math.round(Number(e)||0)),i=Math.max(0,Math.round(Number(t)||0));if(!r||!i)return null;let a=Math.max(r,i);if(a<=n)return{width:r,height:i,scaled:!1};let o=n/a;return{width:Math.max(1,Math.round(r*o)),height:Math.max(1,Math.round(i*o)),scaled:!0}}function $p(e){let t=Number(e?.width),n=Number(e?.height);return!Number.isFinite(t)||!Number.isFinite(n)||t<=0||n<=0?null:t/n}function em(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e.bytes instanceof ArrayBuffer?e.bytes:null;if(!t||!t.byteLength)return null;if(qp(e.id))return Vp(e.type)?{id:e.id,type:e.type.toLowerCase(),bytes:t,name:typeof e.name==`string`?e.name:``,...typeof e.role==`string`?{role:e.role}:{}}:null;if(!Kp(e.id)||!Bp(e.type))return null;let n=Math.round(Number(e.width)),r=Math.round(Number(e.height));return!Number.isInteger(n)||!Number.isInteger(r)||n<=0||r<=0?null:{id:e.id,type:e.type.toLowerCase(),width:n,height:r,bytes:t,name:typeof e.name==`string`?e.name:``,...typeof e.role==`string`?{role:e.role}:{}}}function tm(e){return Array.from(e?.files??[]).filter(e=>{if(!e)return!1;if(Bp(e.type))return!0;if(e.type)return!1;let t=String(e.name??``).toLowerCase().match(/\.([a-z0-9]+)$/)?.[1];return[`png`,`webp`,`jpg`,`jpeg`,`gif`].includes(t)})}function nm(e){let t=[],n=Array.from(e?.items??[]);for(let e of n){if(e.kind!==`file`||!Bp(e.type))continue;let n=e.getAsFile?.();n&&t.push(n.name&&n.name!==`image.png`?n:new File([n],`pasted-${Date.now()}.${e.type.split(`/`)[1]||`png`}`,{type:e.type}))}return t.length?t:tm(e)}function rm(e){return e===`image/jpeg`?`image/jpeg`:`image/png`}function im(e,t){if(typeof OffscreenCanvas==`function`)return new OffscreenCanvas(e,t);throw Error(`this browser cannot resize images — OffscreenCanvas is unavailable`)}async function am(e,{subtle:t=globalThis.crypto?.subtle,createBitmap:n=globalThis.createImageBitmap,makeCanvas:r=im,maxDimension:i=zp,maxSourceBytes:a=Rp}={}){if(!e||typeof e.arrayBuffer!=`function`)throw TypeError(`importImageFile needs a File or Blob`);let o=typeof e.type==`string`?e.type.toLowerCase():``;if(!Bp(o))throw Error(`that file is not an image CozyClay can import (PNG, WebP, JPEG or GIF)`);if(Number(e.size)>a)throw Error(`that image is larger than ${Math.round(a/1048576)} MB`);if(typeof n!=`function`)throw Error(`this browser cannot decode images — createImageBitmap is unavailable`);let s=await n(e);try{let n=Qp(s.width,s.height,i);if(!n)throw Error(`that image has no usable size`);let a=o,c;if(n.scaled){let e=r(n.width,n.height),t=e.getContext(`2d`);if(!t)throw Error(`this browser cannot resize images — no 2D context`);t.drawImage(s,0,0,n.width,n.height),a=rm(o),c=await(await e.convertToBlob({type:a})).arrayBuffer()}else c=await e.arrayBuffer();let l=em({id:await Xp(c,t),type:a,width:n.width,height:n.height,bytes:c,name:typeof e.name==`string`?e.name:``});if(!l)throw Error(`that image could not be prepared for the set`);return l}finally{s?.close?.()}}function om(e){return new Set(sm(e).keys())}function sm(e){let t=new Map;for(let n of Array.isArray(e)?e:[])for(let e of Array.isArray(n?.objects)?n.objects:[]){let n=new Set;for(let t of[e?.assetId,e?.sourceAssetId,e?.matteAssetId])Jp(t)&&n.add(t);for(let e of n)t.set(e,(t.get(e)??0)+1)}return t}function cm(e){return JSON.stringify((Array.isArray(e)?e:[]).map(e=>[typeof e?.id==`string`?e.id:null,(Array.isArray(e?.objects)?e.objects:[]).map(e=>[typeof e?.id==`string`?e.id:null,...[e?.assetId,e?.sourceAssetId,e?.matteAssetId].map(e=>Jp(e)?e:null)])]))}async function lm({expectedGraphSignature:e,deleteRecord:t,restoreRecord:n,readGraphSignature:r}){return await t(),r()===e||(await n(),!1)}function um(e,t){let n=om(t);return(Array.isArray(e)?e:[]).filter(e=>Jp(e)&&!n.has(e))}var dm=e=>new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)});function fm(e=globalThis.indexedDB){return e?new Promise((t,n)=>{let r=e.open(Pp,1);r.onupgradeneeded=()=>{r.result.objectStoreNames.contains(`images`)||r.result.createObjectStore(Fp,{keyPath:`id`})},r.onsuccess=()=>t(r.result),r.onerror=()=>n(r.error),r.onblocked=()=>n(Error(`the asset database is blocked by another tab`))}):Promise.reject(Error(`IndexedDB is unavailable`))}async function pm(e,t){let n=em(t);if(!n)throw TypeError(`putAsset needs a normalizable asset record`);let r=e.transaction(Fp,`readwrite`);return r.objectStore(Fp).put(n),await new Promise((e,t)=>{r.oncomplete=e,r.onerror=()=>t(r.error),r.onabort=()=>t(r.error)}),n}async function mm(e,t){return Jp(t)?em(await dm(e.transaction(Fp,`readonly`).objectStore(Fp).get(t))):null}async function hm(e){return(await dm(e.transaction(Fp,`readonly`).objectStore(`images`).getAllKeys())??[]).filter(Jp)}async function gm(e,t){if(!Jp(t))return!1;let n=e.transaction(Fp,`readwrite`);return n.objectStore(Fp).delete(t),await new Promise((e,t)=>{n.oncomplete=e,n.onerror=()=>t(n.error),n.onabort=()=>t(n.error)}),!0}var _m=Uint8Array,vm=Uint16Array,ym=Int32Array,bm=new _m([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),xm=new _m([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Sm=new _m([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Cm=function(e,t){for(var n=new vm(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new ym(n[30]),r=1;r<30;++r)for(var a=n[r];a<n[r+1];++a)i[a]=a-n[r]<<5|r;return{b:n,r:i}},wm=Cm(bm,2),Tm=wm.b,Em=wm.r;Tm[28]=258,Em[258]=28;var Dm=Cm(xm,0),Om=Dm.b;Dm.r;for(var km=new vm(32768),Am=0;Am<32768;++Am){var jm=(Am&43690)>>1|(Am&21845)<<1;jm=(jm&52428)>>2|(jm&13107)<<2,jm=(jm&61680)>>4|(jm&3855)<<4,km[Am]=((jm&65280)>>8|(jm&255)<<8)>>1}for(var Mm=(function(e,t,n){for(var r=e.length,i=0,a=new vm(t);i<r;++i)e[i]&&++a[e[i]-1];var o=new vm(t);for(i=1;i<t;++i)o[i]=o[i-1]+a[i-1]<<1;var s;if(n){s=new vm(1<<t);var c=15-t;for(i=0;i<r;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=o[e[i]-1]++<<u,f=d|(1<<u)-1;d<=f;++d)s[km[d]>>c]=l}else for(s=new vm(r),i=0;i<r;++i)e[i]&&(s[i]=km[o[e[i]-1]++]>>15-e[i]);return s}),Nm=new _m(288),Am=0;Am<144;++Am)Nm[Am]=8;for(var Am=144;Am<256;++Am)Nm[Am]=9;for(var Am=256;Am<280;++Am)Nm[Am]=7;for(var Am=280;Am<288;++Am)Nm[Am]=8;for(var Pm=new _m(32),Am=0;Am<32;++Am)Pm[Am]=5;var Fm=Mm(Nm,9,1),Im=Mm(Pm,5,1),Lm=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Rm=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},zm=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},Bm=function(e){return(e+7)/8|0},Vm=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new _m(e.subarray(t,n))},Hm=[`unexpected EOF`,`invalid block type`,`invalid length/literal`,`invalid distance`,`stream finished`,`no stream handler`,,`no callback`,`invalid UTF-8 data`,`extra field too long`,`date not in range 1980-2099`,`filename too long`,`stream finishing`,`invalid zip data`],Um=function(e,t,n){var r=Error(t||Hm[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,Um),!n)throw r;return r},Wm=function(e,t,n,r){var i=e.length,a=r?r.length:0;if(!i||t.f&&!t.l)return n||new _m(0);var o=!n,s=o||t.i!=2,c=t.i;o&&(n=new _m(i*3));var l=function(e){var t=n.length;if(e>t){var r=new _m(Math.max(t*2,e));r.set(n),n=r}},u=t.f||0,d=t.p||0,f=t.b||0,p=t.l,m=t.d,h=t.m,g=t.n,_=i*8;do{if(!p){u=Rm(e,d,1);var v=Rm(e,d+1,3);if(d+=3,!v){var y=Bm(d)+4,b=e[y-4]|e[y-3]<<8,x=y+b;if(x>i){c&&Um(0);break}s&&l(f+b),n.set(e.subarray(y,x),f),t.b=f+=b,t.p=d=x*8,t.f=u;continue}if(v==1)p=Fm,m=Im,h=9,g=5;else if(v==2){var S=Rm(e,d,31)+257,C=Rm(e,d+10,15)+4,w=S+Rm(e,d+5,31)+1;d+=14;for(var T=new _m(w),E=new _m(19),D=0;D<C;++D)E[Sm[D]]=Rm(e,d+D*3,7);d+=C*3;for(var O=Lm(E),ee=(1<<O)-1,k=Mm(E,O,1),D=0;D<w;){var te=k[Rm(e,d,ee)];d+=te&15;var y=te>>4;if(y<16)T[D++]=y;else{var ne=0,re=0;for(y==16?(re=3+Rm(e,d,3),d+=2,ne=T[D-1]):y==17?(re=3+Rm(e,d,7),d+=3):y==18&&(re=11+Rm(e,d,127),d+=7);re--;)T[D++]=ne}}var ie=T.subarray(0,S),A=T.subarray(S);h=Lm(ie),g=Lm(A),p=Mm(ie,h,1),m=Mm(A,g,1)}else Um(1);if(d>_){c&&Um(0);break}}s&&l(f+131072);for(var j=(1<<h)-1,M=(1<<g)-1,ae=d;;ae=d){var ne=p[zm(e,d)&j],oe=ne>>4;if(d+=ne&15,d>_){c&&Um(0);break}if(ne||Um(2),oe<256)n[f++]=oe;else if(oe==256){ae=d,p=null;break}else{var se=oe-254;if(oe>264){var D=oe-257,ce=bm[D];se=Rm(e,d,(1<<ce)-1)+Tm[D],d+=ce}var le=m[zm(e,d)&M],ue=le>>4;le||Um(3),d+=le&15;var A=Om[ue];if(ue>3){var ce=xm[ue];A+=zm(e,d)&(1<<ce)-1,d+=ce}if(d>_){c&&Um(0);break}s&&l(f+131072);var de=f+se;if(f<A){var fe=a-A,pe=Math.min(A,de);for(fe+f<0&&Um(3);f<pe;++f)n[f]=r[fe+f]}for(;f<de;++f)n[f]=n[f-A]}}t.l=p,t.p=ae,t.b=f,t.f=u,p&&(u=1,t.m=h,t.d=m,t.n=g)}while(!u);return f!=n.length&&o?Vm(n,0,f):n.subarray(0,f)},Gm=new _m(0),Km=function(e,t){return((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&Um(6,`invalid zlib data`),(e[1]>>5&1)==+!t&&Um(6,`invalid zlib data: `+(e[1]&32?`need`:`unexpected`)+` dictionary`),(e[1]>>3&4)+2};function qm(e,t){return Wm(e.subarray(Km(e,t&&t.dictionary),-4),{i:2},t&&t.out,t&&t.dictionary)}var Jm=typeof TextDecoder<`u`&&new TextDecoder;try{Jm.decode(Gm,{stream:!0})}catch{}function Ym(e,t,n){let r=n.length-e-1;if(t>=n[r])return r-1;if(t<=n[e])return e;let i=e,a=r,o=Math.floor((i+a)/2);for(;t<n[o]||t>=n[o+1];)t<n[o]?a=o:i=o,o=Math.floor((i+a)/2);return o}function Xm(e,t,n,r){let i=[],a=[],o=[];i[0]=1;for(let s=1;s<=n;++s){a[s]=t-r[e+1-s],o[s]=r[e+s]-t;let n=0;for(let e=0;e<s;++e){let t=o[e+1],r=a[s-e],c=i[e]/(t+r);i[e]=n+t*c,n=r*c}i[s]=n}return i}function Zm(e,t,n,r){let i=Ym(e,r,t),a=Xm(i,r,e,t),o=new sr(0,0,0,0);for(let t=0;t<=e;++t){let r=n[i-e+t],s=a[t],c=r.w*s;o.x+=r.x*c,o.y+=r.y*c,o.z+=r.z*c,o.w+=r.w*s}return o}function Qm(e,t,n,r,i){let a=[];for(let e=0;e<=n;++e)a[e]=0;let o=[];for(let e=0;e<=r;++e)o[e]=a.slice(0);let s=[];for(let e=0;e<=n;++e)s[e]=a.slice(0);s[0][0]=1;let c=a.slice(0),l=a.slice(0);for(let r=1;r<=n;++r){c[r]=t-i[e+1-r],l[r]=i[e+r]-t;let n=0;for(let e=0;e<r;++e){let t=l[e+1],i=c[r-e];s[r][e]=t+i;let a=s[e][r-1]/s[r][e];s[e][r]=n+t*a,n=i*a}s[r][r]=n}for(let e=0;e<=n;++e)o[0][e]=s[e][n];for(let e=0;e<=n;++e){let t=0,i=1,c=[];for(let e=0;e<=n;++e)c[e]=a.slice(0);c[0][0]=1;for(let a=1;a<=r;++a){let r=0,l=e-a,u=n-a;e>=a&&(c[i][0]=c[t][0]/s[u+1][l],r=c[i][0]*s[l][u]);let d=l>=-1?1:-l,f=e-1<=u?a-1:n-e;for(let e=d;e<=f;++e)c[i][e]=(c[t][e]-c[t][e-1])/s[u+1][l+e],r+=c[i][e]*s[l+e][u];e<=u&&(c[i][a]=-c[t][a-1]/s[u+1][e],r+=c[i][a]*s[e][u]),o[a][e]=r;let p=t;t=i,i=p}}let u=n;for(let e=1;e<=r;++e){for(let t=0;t<=n;++t)o[e][t]*=u;u*=n-e}return o}function $m(e,t,n,r,i){let a=i<e?i:e,o=[],s=Ym(e,r,t),c=Qm(s,r,e,a,t),l=[];for(let e=0;e<n.length;++e){let t=n[e].clone(),r=t.w;t.x*=r,t.y*=r,t.z*=r,l[e]=t}for(let t=0;t<=a;++t){let n=l[s-e].clone().multiplyScalar(c[t][0]);for(let r=1;r<=e;++r)n.add(l[s-e+r].clone().multiplyScalar(c[t][r]));o[t]=n}for(let e=a+1;e<=i+1;++e)o[e]=new sr(0,0,0);return o}function eh(e,t){let n=1;for(let t=2;t<=e;++t)n*=t;let r=1;for(let e=2;e<=t;++e)r*=e;for(let n=2;n<=e-t;++n)r*=n;return n/r}function th(e){let t=e.length,n=[],r=[];for(let i=0;i<t;++i){let t=e[i];n[i]=new B(t.x,t.y,t.z),r[i]=t.w}let i=[];for(let e=0;e<t;++e){let t=n[e].clone();for(let n=1;n<=e;++n)t.sub(i[e-n].clone().multiplyScalar(eh(e,n)*r[n]));i[e]=t.divideScalar(r[0])}return i}function nh(e,t,n,r,i){return th($m(e,t,n,r,i))}var rh=class extends Rs{constructor(e,t,n,r,i){super();let a=t?t.length-1:0,o=n?n.length:0;this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=r||0,this.endKnot=i||a;for(let e=0;e<o;++e){let t=n[e];this.controlPoints[e]=new sr(t.x,t.y,t.z,t.w)}}getPoint(e,t=new B){let n=t,r=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),i=Zm(this.degree,this.knots,this.controlPoints,r);return i.w!==1&&i.divideScalar(i.w),n.set(i.x,i.y,i.z)}getTangent(e,t=new B){let n=t,r=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),i=nh(this.degree,this.knots,this.controlPoints,r,1);return n.copy(i[1]).normalize(),n}toJSON(){let e=super.toJSON();return e.degree=this.degree,e.knots=[...this.knots],e.controlPoints=this.controlPoints.map(e=>e.toArray()),e.startKnot=this.startKnot,e.endKnot=this.endKnot,e}fromJSON(e){return super.fromJSON(e),this.degree=e.degree,this.knots=[...e.knots],this.controlPoints=e.controlPoints.map(e=>new sr(e[0],e[1],e[2],e[3])),this.startKnot=e.startKnot,this.endKnot=e.endKnot,this}},X,ih,ah,oh=class extends cu{constructor(e){super(e)}load(e,t,n,r){let i=this,a=i.path===``?Ku.extractUrlBase(e):i.path,o=new du(this.manager);o.setPath(i.path),o.setResponseType(`arraybuffer`),o.setRequestHeader(i.requestHeader),o.setWithCredentials(i.withCredentials),o.load(e,function(n){try{t(i.parse(n,a))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}},n,r)}parse(e,t){if(mh(e))X=new dh().parse(e);else{let t=Th(e);if(!hh(t))throw Error(`THREE.FBXLoader: Unknown format.`);if(gh(t)<7e3)throw Error(`THREE.FBXLoader: FBX version not supported, FileVersion: `+gh(t));X=new uh().parse(t)}return new sh(new vu(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin),this.manager).parse(X)}},sh=class{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){ih=this.parseConnections();let e=this.parseImages(),t=this.parseTextures(e),n=this.parseMaterials(t),r=this.parseDeformers(),i=new ch().parse(r);return this.parseScene(r,i,n),ah}parseConnections(){let e=new Map;return`Connections`in X&&X.Connections.connections.forEach(function(t){let n=t[0],r=t[1],i=t[2];e.has(n)||e.set(n,{parents:[],children:[]});let a={ID:r,relationship:i};e.get(n).parents.push(a),e.has(r)||e.set(r,{parents:[],children:[]});let o={ID:n,relationship:i};e.get(r).children.push(o)}),e}parseImages(){let e={},t={};if(`Video`in X.Objects){let n=X.Objects.Video;for(let r in n){let i=n[r],a=parseInt(r);if(e[a]=i.RelativeFilename||i.Filename,`Content`in i){let e=i.Content instanceof ArrayBuffer&&i.Content.byteLength>0,a=typeof i.Content==`string`&&i.Content!==``;if(e||a){let e=this.parseImage(n[r]);t[i.RelativeFilename||i.Filename]=e}}}}for(let n in e){let r=e[n];e[n]=t[r]===void 0?e[n].split(`\\`).pop():t[r]}return e}parseImage(e){let t=e.Content,n=e.RelativeFilename||e.Filename,r=n.slice(n.lastIndexOf(`.`)+1).toLowerCase(),i;switch(r){case`bmp`:i=`image/bmp`;break;case`jpg`:case`jpeg`:i=`image/jpeg`;break;case`png`:i=`image/png`;break;case`tif`:i=`image/tiff`;break;case`tga`:this.manager.getHandler(`.tga`)===null&&console.warn(`FBXLoader: TGA loader not found, skipping `,n),i=`image/tga`;break;case`webp`:i=`image/webp`;break;default:console.warn(`FBXLoader: Image type "`+r+`" is not supported.`);return}if(typeof t==`string`)return`data:`+i+`;base64,`+t;{let e=new Uint8Array(t);return window.URL.createObjectURL(new Blob([e],{type:i}))}}parseTextures(e){let t=new Map;if(`Texture`in X.Objects){let n=X.Objects.Texture;for(let r in n){let i=this.parseTexture(n[r],e);t.set(parseInt(r),i)}}return t}parseTexture(e,t){let n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;let r=e.WrapModeU,i=e.WrapModeV,a=r===void 0?0:r.value,o=i===void 0?0:i.value;if(n.wrapS=a===0?D:O,n.wrapT=o===0?D:O,`Scaling`in e){let t=e.Scaling.value;n.repeat.x=t[0],n.repeat.y=t[1]}if(`Translation`in e){let t=e.Translation.value;n.offset.x=t[0],n.offset.y=t[1]}return n}loadTexture(e,t){let n=e.FileName.split(`.`).pop().toLowerCase(),r=this.manager.getHandler(`.${n}`);r===null&&(r=this.textureLoader);let i=r.path;i||r.setPath(this.textureLoader.path);let a=ih.get(e.id).children,o;if(a!==void 0&&a.length>0&&t[a[0].ID]!==void 0&&(o=t[a[0].ID],(o.indexOf(`blob:`)===0||o.indexOf(`data:`)===0)&&r.setPath(void 0)),o===void 0)return console.warn(`FBXLoader: Undefined filename, creating placeholder texture.`),new or;let s=r.load(o);return r.setPath(i),s}parseMaterials(e){let t=new Map;if(`Material`in X.Objects){let n=X.Objects.Material;for(let r in n){let i=this.parseMaterial(n[r],e);i!==null&&t.set(parseInt(r),i)}}return t}parseMaterial(e,t){let n=e.id,r=e.attrName,i=e.ShadingModel;if(typeof i==`object`&&(i=i.value),!ih.has(n))return null;let a=this.parseParameters(e,t,n),o;switch(i.toLowerCase()){case`phong`:o=new kl;break;case`lambert`:o=new Ml;break;default:console.warn(`THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.`,i),o=new kl}return o.setValues(a),o.name=r,o}parseParameters(e,t,n){let r={};e.BumpFactor&&(r.bumpScale=e.BumpFactor.value),e.Diffuse?r.color=Xn.colorSpaceToWorking(new H().fromArray(e.Diffuse.value),Ot):e.DiffuseColor&&(e.DiffuseColor.type===`Color`||e.DiffuseColor.type===`ColorRGB`)&&(r.color=Xn.colorSpaceToWorking(new H().fromArray(e.DiffuseColor.value),Ot)),e.DisplacementFactor&&(r.displacementScale=e.DisplacementFactor.value),e.Emissive?r.emissive=Xn.colorSpaceToWorking(new H().fromArray(e.Emissive.value),Ot):e.EmissiveColor&&(e.EmissiveColor.type===`Color`||e.EmissiveColor.type===`ColorRGB`)&&(r.emissive=Xn.colorSpaceToWorking(new H().fromArray(e.EmissiveColor.value),Ot)),e.EmissiveFactor&&(r.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),r.opacity=1-(e.TransparencyFactor?parseFloat(e.TransparencyFactor.value):0),(r.opacity===1||r.opacity===0)&&(r.opacity=e.Opacity?parseFloat(e.Opacity.value):null,r.opacity===null&&(r.opacity=1)),r.opacity<1&&(r.transparent=!0),e.ReflectionFactor&&(r.reflectivity=e.ReflectionFactor.value),e.Shininess&&(r.shininess=e.Shininess.value),e.Specular?r.specular=Xn.colorSpaceToWorking(new H().fromArray(e.Specular.value),Ot):e.SpecularColor&&e.SpecularColor.type===`Color`&&(r.specular=Xn.colorSpaceToWorking(new H().fromArray(e.SpecularColor.value),Ot));let i=this;return ih.get(n).children.forEach(function(e){let n=e.relationship;switch(n){case`Bump`:r.bumpMap=i.getTexture(t,e.ID);break;case`Maya|TEX_ao_map`:r.aoMap=i.getTexture(t,e.ID);break;case`DiffuseColor`:case`Maya|TEX_color_map`:r.map=i.getTexture(t,e.ID),r.map!==void 0&&(r.map.colorSpace=Ot);break;case`DisplacementColor`:r.displacementMap=i.getTexture(t,e.ID);break;case`EmissiveColor`:r.emissiveMap=i.getTexture(t,e.ID),r.emissiveMap!==void 0&&(r.emissiveMap.colorSpace=Ot);break;case`NormalMap`:case`Maya|TEX_normal_map`:r.normalMap=i.getTexture(t,e.ID);break;case`ReflectionColor`:r.envMap=i.getTexture(t,e.ID),r.envMap!==void 0&&(r.envMap.mapping=303,r.envMap.colorSpace=Ot);break;case`SpecularColor`:r.specularMap=i.getTexture(t,e.ID),r.specularMap!==void 0&&(r.specularMap.colorSpace=Ot);break;case`TransparentColor`:case`TransparencyFactor`:r.alphaMap=i.getTexture(t,e.ID),r.transparent=!0;break;default:console.warn(`THREE.FBXLoader: %s map is not supported in three.js, skipping texture.`,n)}}),r}getTexture(e,t){return`LayeredTexture`in X.Objects&&t in X.Objects.LayeredTexture&&(console.warn(`THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer.`),t=ih.get(t).children[0].ID),e.get(t)}parseDeformers(){let e={},t={};if(`Deformer`in X.Objects){let n=X.Objects.Deformer;for(let r in n){let i=n[r],a=ih.get(parseInt(r));if(i.attrType===`Skin`){let t=this.parseSkeleton(a,n);t.ID=r,a.parents.length>1&&console.warn(`THREE.FBXLoader: skeleton attached to more than one geometry is not supported.`),t.geometryID=a.parents[0].ID,e[r]=t}else if(i.attrType===`BlendShape`){let e={id:r};e.rawTargets=this.parseMorphTargets(a,n),e.id=r,a.parents.length>1&&console.warn(`THREE.FBXLoader: morph target attached to more than one geometry is not supported.`),t[r]=e}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){let n=[];return e.children.forEach(function(e){let r=t[e.ID];if(r.attrType!==`Cluster`)return;let i={ID:e.ID,indices:[],weights:[],transformLink:new V().fromArray(r.TransformLink.a)};`Indexes`in r&&(i.indices=r.Indexes.a,i.weights=r.Weights.a),n.push(i)}),{rawBones:n,bones:[]}}parseMorphTargets(e,t){let n=[];for(let r=0;r<e.children.length;r++){let i=e.children[r],a=t[i.ID],o={name:a.attrName,initialWeight:a.DeformPercent,id:a.id,fullWeights:a.FullWeights.a};if(a.attrType!==`BlendShapeChannel`)return;o.geoID=ih.get(parseInt(i.ID)).children.filter(function(e){return e.relationship===void 0})[0].ID,n.push(o)}return n}parseScene(e,t,n){ah=new Vr;let r=this.parseModels(e.skeletons,t,n),i=X.Objects.Model,a=this;r.forEach(function(e){let t=i[e.ID];a.setLookAtProperties(e,t),ih.get(e.ID).parents.forEach(function(t){let n=r.get(t.ID);n!==void 0&&n.add(e)}),e.parent===null&&ah.add(e)}),this.addGlobalSceneSettings(),ah.traverse(function(e){if(e.userData.transformData){e.parent&&(e.userData.transformData.parentMatrix=e.parent.matrix,e.userData.transformData.parentMatrixWorld=e.parent.matrixWorld);let t=Sh(e.userData.transformData);e.applyMatrix4(t),e.updateWorldMatrix()}});let o=this.parsePoseNodes(),s=new Set;for(let t in e.skeletons)e.skeletons[t].rawBones.forEach(function(n,r){let i=e.skeletons[t].bones[r];i&&s.add(i.ID)});let c=new V;ah.traverse(function(e){if(e.isBone&&e.ID!==void 0&&!s.has(e.ID)){let t=o[e.ID];t!==void 0&&(e.parent?(c.copy(e.parent.matrixWorld).invert(),c.multiply(t)):c.copy(t),c.decompose(e.position,e.quaternion,e.scale),e.updateMatrix(),e.matrixWorld.copy(t))}}),this.bindSkeleton(e.skeletons,t,r);let l=new lh().parse();ah.children.length===1&&ah.children[0].isGroup&&(ah.children[0].animations=l,ah=ah.children[0]),ah.animations=l,`GlobalSettings`in X&&`UpAxis`in X.GlobalSettings&&X.GlobalSettings.UpAxis.value===2&&(console.warn(`THREE.FBXLoader: You are loading an asset with a Z-UP coordinate system. The loader just rotates the asset to transform it into Y-UP. The vertex data are not converted.`),ah.rotation.set(-Math.PI/2,0,0))}parseModels(e,t,n){let r=new Map,i=X.Objects.Model;for(let a in i){let o=parseInt(a),s=i[a],c=ih.get(o),l=this.buildSkeleton(c,e,o,s.attrName);if(!l){switch(s.attrType){case`Camera`:l=this.createCamera(c);break;case`Light`:l=this.createLight(c);break;case`Mesh`:l=this.createMesh(c,t,n);break;case`NurbsCurve`:l=this.createCurve(c,t);break;case`LimbNode`:case`Root`:l=new io;break;default:l=new Vr}l.name=s.attrName?Y.sanitizeNodeName(s.attrName):``,l.userData.originalName=s.attrName,l.ID=o}this.getTransformData(l,s),r.set(o,l)}return r}buildSkeleton(e,t,n,r){let i=null;return e.parents.forEach(function(e){for(let a in t){let o=t[a];o.rawBones.forEach(function(t,a){if(t.ID===e.ID){let e=i;i=new io,i.matrixWorld.copy(t.transformLink),i.name=r?Y.sanitizeNodeName(r):``,i.userData.originalName=r,i.ID=n,o.bones[a]=i,e!==null&&i.add(e)}})}}),i}createCamera(e){let t,n;if(e.children.forEach(function(e){let t=X.Objects.NodeAttribute[e.ID];t!==void 0&&(n=t)}),n===void 0)t=new Br;else{let e=0;n.CameraProjectionType!==void 0&&n.CameraProjectionType.value===1&&(e=1);let r=1;n.NearPlane!==void 0&&(r=n.NearPlane.value/1e3);let i=1e3;n.FarPlane!==void 0&&(i=n.FarPlane.value/1e3);let a=window.innerWidth,o=window.innerHeight;n.AspectWidth!==void 0&&n.AspectHeight!==void 0&&(a=n.AspectWidth.value,o=n.AspectHeight.value);let s=a/o,c=45;n.FieldOfView!==void 0&&(c=n.FieldOfView.value);let l=n.FocalLength?n.FocalLength.value:null;switch(e){case 0:t=new Mu(c,s,r,i),l!==null&&t.setFocalLength(l);break;case 1:console.warn(`THREE.FBXLoader: Orthographic cameras not supported yet.`),t=new Br;break;default:console.warn(`THREE.FBXLoader: Unknown camera type `+e+`.`),t=new Br}}return t}createLight(e){let t,n;if(e.children.forEach(function(e){let t=X.Objects.NodeAttribute[e.ID];t!==void 0&&(n=t)}),n===void 0)t=new Br;else{let e;e=n.LightType===void 0?0:n.LightType.value;let r=16777215;n.Color!==void 0&&(r=Xn.colorSpaceToWorking(new H().fromArray(n.Color.value),Ot));let i=n.Intensity===void 0?1:n.Intensity.value/100;n.CastLightOnObject!==void 0&&n.CastLightOnObject.value===0&&(i=0);let a=0;switch(n.FarAttenuationEnd!==void 0&&(a=n.EnableFarAttenuation!==void 0&&n.EnableFarAttenuation.value===0?0:n.FarAttenuationEnd.value),e){case 0:t=new Iu(r,i,a,1);break;case 1:t=new zu(r,i);break;case 2:let e=Math.PI/3,o=0;n.OuterAngle===void 0?n.InnerAngle!==void 0&&(e=Hn.degToRad(n.InnerAngle.value)):(e=Hn.degToRad(n.OuterAngle.value),n.InnerAngle!==void 0&&(o=1-n.InnerAngle.value/n.OuterAngle.value,o=Math.max(0,o))),t=new Pu(r,i,a,e,o,1);break;default:console.warn(`THREE.FBXLoader: Unknown light type `+n.LightType.value+`, defaulting to a PointLight.`),t=new Iu(r,i)}n.CastShadows!==void 0&&n.CastShadows.value===1&&(t.castShadow=!0)}return t}createMesh(e,t,n){let r,i=null,a=null,o=[];if(e.children.forEach(function(e){t.has(e.ID)&&(i=t.get(e.ID)),n.has(e.ID)&&o.push(n.get(e.ID))}),o.length>1?a=o:o.length>0?a=o[0]:(a=new kl({name:cu.DEFAULT_MATERIAL_NAME,color:13421772}),o.push(a)),`color`in i.attributes&&o.forEach(function(e){e.vertexColors=!0}),i.groups.length>0){let e=!1;for(let t=0,n=i.groups.length;t<n;t++){let n=i.groups[t];(n.materialIndex<0||n.materialIndex>=o.length)&&(n.materialIndex=o.length,e=!0)}if(e){let e=new kl;o.push(e)}}return i.FBX_Deformer?(r=new ro(i,a),r.normalizeSkinWeights()):r=new Ga(i,a),r}createCurve(e,t){return new ts(e.children.reduce(function(e,n){return t.has(n.ID)&&(e=t.get(n.ID)),e},null),new qo({name:cu.DEFAULT_MATERIAL_NAME,color:3342591,linewidth:1}))}getTransformData(e,t){let n={};`InheritType`in t&&(n.inheritType=parseInt(t.InheritType.value)),n.eulerOrder=`RotationOrder`in t?Ch(t.RotationOrder.value):Ch(0),`Lcl_Translation`in t&&(n.translation=t.Lcl_Translation.value),`PreRotation`in t&&(n.preRotation=t.PreRotation.value),`Lcl_Rotation`in t&&(n.rotation=t.Lcl_Rotation.value),`PostRotation`in t&&(n.postRotation=t.PostRotation.value),`Lcl_Scaling`in t&&(n.scale=t.Lcl_Scaling.value),`ScalingOffset`in t&&(n.scalingOffset=t.ScalingOffset.value),`ScalingPivot`in t&&(n.scalingPivot=t.ScalingPivot.value),`RotationOffset`in t&&(n.rotationOffset=t.RotationOffset.value),`RotationPivot`in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,t){`LookAtProperty`in t&&ih.get(e.ID).children.forEach(function(t){if(t.relationship===`LookAtProperty`){let n=X.Objects.Model[t.ID];if(`Lcl_Translation`in n){let t=n.Lcl_Translation.value;e.target===void 0?e.lookAt(new B().fromArray(t)):(e.target.position.fromArray(t),ah.add(e.target))}}})}bindSkeleton(e,t,n){for(let r in e){let i=e[r],a=[];for(let e=0,t=i.bones.length;e<t;e++){let t=new V;i.bones[e]&&i.rawBones[e]&&t.copy(i.rawBones[e].transformLink).invert(),a.push(t)}ih.get(parseInt(i.ID)).parents.forEach(function(e){if(t.has(e.ID)){let t=e.ID;ih.get(t).parents.forEach(function(e){if(n.has(e.ID)){let t=n.get(e.ID);t.updateMatrixWorld(!0),t.bind(new G(i.bones,a),t.matrixWorld)}})}})}}parsePoseNodes(){let e={};if(`Pose`in X.Objects){let t=X.Objects.Pose;for(let n in t)if(t[n].attrType===`BindPose`&&t[n].NbPoseNodes>0){let r=t[n].PoseNode;Array.isArray(r)?r.forEach(function(t){e[t.Node]=new V().fromArray(t.Matrix.a)}):e[r.Node]=new V().fromArray(r.Matrix.a)}}return e}addGlobalSceneSettings(){if(`GlobalSettings`in X){if(`AmbientColor`in X.GlobalSettings){let e=X.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],r=e[2];if(t!==0||n!==0||r!==0){let e=new H().setRGB(t,n,r,Ot);ah.add(new Bu(e,1))}}`UnitScaleFactor`in X.GlobalSettings&&(ah.userData.unitScaleFactor=X.GlobalSettings.UnitScaleFactor.value)}}},ch=class{constructor(){this.negativeMaterialIndices=!1}parse(e){let t=new Map;if(`Geometry`in X.Objects){let n=X.Objects.Geometry;for(let r in n){let i=ih.get(parseInt(r)),a=this.parseGeometry(i,n[r],e);t.set(parseInt(r),a)}}return this.negativeMaterialIndices===!0&&console.warn(`THREE.FBXLoader: The FBX file contains invalid (negative) material indices. The asset might not render as expected.`),t}parseGeometry(e,t,n){switch(t.attrType){case`Mesh`:return this.parseMeshGeometry(e,t,n);case`NurbsCurve`:return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){let r=n.skeletons,i=[],a=e.parents.map(function(e){return X.Objects.Model[e.ID]});if(a.length===0)return;let o=e.children.reduce(function(e,t){return r[t.ID]!==void 0&&(e=r[t.ID]),e},null);e.children.forEach(function(e){n.morphTargets[e.ID]!==void 0&&i.push(n.morphTargets[e.ID])});let s=a[0],c={};`RotationOrder`in s&&(c.eulerOrder=Ch(s.RotationOrder.value)),`InheritType`in s&&(c.inheritType=parseInt(s.InheritType.value)),`GeometricTranslation`in s&&(c.translation=s.GeometricTranslation.value),`GeometricRotation`in s&&(c.rotation=s.GeometricRotation.value),`GeometricScaling`in s&&(c.scale=s.GeometricScaling.value);let l=Sh(c);return this.genGeometry(t,o,i,l)}genGeometry(e,t,n,r){let i=new W;e.attrName&&(i.name=e.attrName);let a=this.parseGeoNode(e,t),o=this.genBuffers(a),s=new U(o.vertex,3);if(s.applyMatrix4(r),i.setAttribute(`position`,s),o.colors.length>0&&i.setAttribute(`color`,new U(o.colors,3)),t&&(i.setAttribute(`skinIndex`,new Bi(o.weightsIndices,4)),i.setAttribute(`skinWeight`,new U(o.vertexWeights,4)),i.FBX_Deformer=t),o.normal.length>0){let e=new Gn().getNormalMatrix(r),t=new U(o.normal,3);t.applyNormalMatrix(e),i.setAttribute(`normal`,t)}if(o.uvs.forEach(function(e,t){let n=t===0?`uv`:`uv${t}`;i.setAttribute(n,new U(o.uvs[t],2))}),a.material&&a.material.mappingType!==`AllSame`){let e=o.materialIndex[0],t=0;if(o.materialIndex.forEach(function(n,r){n!==e&&(i.addGroup(t,r-t,e),e=n,t=r)}),i.groups.length>0){let t=i.groups[i.groups.length-1],n=t.start+t.count;n!==o.materialIndex.length&&i.addGroup(n,o.materialIndex.length-n,e)}i.groups.length===0&&i.addGroup(0,o.materialIndex.length,o.materialIndex[0])}return this.addMorphTargets(i,e,n,r),i}parseGeoNode(e,t){let n={};if(n.vertexPositions=e.Vertices===void 0?[]:e.Vertices.a,n.vertexIndices=e.PolygonVertexIndex===void 0?[]:e.PolygonVertexIndex.a,e.LayerElementColor&&e.LayerElementColor[0].Colors&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let t=0;for(;e.LayerElementUV[t];)e.LayerElementUV[t].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[t])),t++}return n.weightTable={},t!==null&&(n.skeleton=t,t.rawBones.forEach(function(e,t){e.indices.forEach(function(r,i){n.weightTable[r]===void 0&&(n.weightTable[r]=[]),n.weightTable[r].push({id:t,weight:e.weights[i]})})})),n}genBuffers(e){let t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]},n=0,r=0,i=!1,a=[],o=[],s=[],c=[],l=[],u=[],d=this;return e.vertexIndices.forEach(function(f,p){let m,h=!1;f<0&&(f^=-1,h=!0);let g=[],_=[];if(a.push(f*3,f*3+1,f*3+2),e.color){let t=yh(p,n,f,e.color);s.push(t[0],t[1],t[2])}if(e.skeleton){if(e.weightTable[f]!==void 0&&e.weightTable[f].forEach(function(e){_.push(e.weight),g.push(e.id)}),_.length>4){i||=(console.warn(`THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights.`),!0);let e=[0,0,0,0],t=[0,0,0,0];_.forEach(function(n,r){let i=n,a=g[r];t.forEach(function(t,n,r){if(i>t){r[n]=i,i=t;let o=e[n];e[n]=a,a=o}})}),g=e,_=t}for(;_.length<4;)_.push(0),g.push(0);for(let e=0;e<4;++e)l.push(_[e]),u.push(g[e])}if(e.normal){let t=yh(p,n,f,e.normal);o.push(t[0],t[1],t[2])}e.material&&e.material.mappingType!==`AllSame`&&(m=yh(p,n,f,e.material)[0],m<0&&(d.negativeMaterialIndices=!0,m=0)),e.uv&&e.uv.forEach(function(e,t){let r=yh(p,n,f,e);c[t]===void 0&&(c[t]=[]),c[t].push(r[0]),c[t].push(r[1])}),r++,h&&(d.genFace(t,e,a,m,o,s,c,l,u,r),n++,r=0,a=[],o=[],s=[],c=[],l=[],u=[])}),t}getNormalNewell(e){let t=new B(0,0,0);for(let n=0;n<e.length;n++){let r=e[n],i=e[(n+1)%e.length];t.x+=(r.y-i.y)*(r.z+i.z),t.y+=(r.z-i.z)*(r.x+i.x),t.z+=(r.x-i.x)*(r.y+i.y)}return t.normalize(),t}getNormalTangentAndBitangent(e){let t=this.getNormalNewell(e),n=(Math.abs(t.z)>.5?new B(0,1,0):new B(0,0,1)).cross(t).normalize();return{normal:t,tangent:n,bitangent:t.clone().cross(n).normalize()}}flattenVertex(e,t,n){return new R(e.dot(t),e.dot(n))}genFace(e,t,n,r,i,a,o,s,c,l){let u;if(l>3){let e=[],r=t.baseVertexPositions||t.vertexPositions;for(let t=0;t<n.length;t+=3)e.push(new B(r[n[t]],r[n[t+1]],r[n[t+2]]));let{tangent:i,bitangent:a}=this.getNormalTangentAndBitangent(e),o=[];for(let t of e)o.push(this.flattenVertex(t,i,a));u=Yc.triangulateShape(o,[])}else u=[[0,1,2]];for(let[l,d,f]of u)e.vertex.push(t.vertexPositions[n[l*3]]),e.vertex.push(t.vertexPositions[n[l*3+1]]),e.vertex.push(t.vertexPositions[n[l*3+2]]),e.vertex.push(t.vertexPositions[n[d*3]]),e.vertex.push(t.vertexPositions[n[d*3+1]]),e.vertex.push(t.vertexPositions[n[d*3+2]]),e.vertex.push(t.vertexPositions[n[f*3]]),e.vertex.push(t.vertexPositions[n[f*3+1]]),e.vertex.push(t.vertexPositions[n[f*3+2]]),t.skeleton&&(e.vertexWeights.push(s[l*4]),e.vertexWeights.push(s[l*4+1]),e.vertexWeights.push(s[l*4+2]),e.vertexWeights.push(s[l*4+3]),e.vertexWeights.push(s[d*4]),e.vertexWeights.push(s[d*4+1]),e.vertexWeights.push(s[d*4+2]),e.vertexWeights.push(s[d*4+3]),e.vertexWeights.push(s[f*4]),e.vertexWeights.push(s[f*4+1]),e.vertexWeights.push(s[f*4+2]),e.vertexWeights.push(s[f*4+3]),e.weightsIndices.push(c[l*4]),e.weightsIndices.push(c[l*4+1]),e.weightsIndices.push(c[l*4+2]),e.weightsIndices.push(c[l*4+3]),e.weightsIndices.push(c[d*4]),e.weightsIndices.push(c[d*4+1]),e.weightsIndices.push(c[d*4+2]),e.weightsIndices.push(c[d*4+3]),e.weightsIndices.push(c[f*4]),e.weightsIndices.push(c[f*4+1]),e.weightsIndices.push(c[f*4+2]),e.weightsIndices.push(c[f*4+3])),t.color&&(e.colors.push(a[l*3]),e.colors.push(a[l*3+1]),e.colors.push(a[l*3+2]),e.colors.push(a[d*3]),e.colors.push(a[d*3+1]),e.colors.push(a[d*3+2]),e.colors.push(a[f*3]),e.colors.push(a[f*3+1]),e.colors.push(a[f*3+2])),t.material&&t.material.mappingType!==`AllSame`&&(e.materialIndex.push(r),e.materialIndex.push(r),e.materialIndex.push(r)),t.normal&&(e.normal.push(i[l*3]),e.normal.push(i[l*3+1]),e.normal.push(i[l*3+2]),e.normal.push(i[d*3]),e.normal.push(i[d*3+1]),e.normal.push(i[d*3+2]),e.normal.push(i[f*3]),e.normal.push(i[f*3+1]),e.normal.push(i[f*3+2])),t.uv&&t.uv.forEach(function(t,n){e.uvs[n]===void 0&&(e.uvs[n]=[]),e.uvs[n].push(o[n][l*2]),e.uvs[n].push(o[n][l*2+1]),e.uvs[n].push(o[n][d*2]),e.uvs[n].push(o[n][d*2+1]),e.uvs[n].push(o[n][f*2]),e.uvs[n].push(o[n][f*2+1])})}addMorphTargets(e,t,n,r){if(n.length===0)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];let i=r.clone().setPosition(0,0,0),a=this;n.forEach(function(n){n.rawTargets.forEach(function(n){let r=X.Objects.Geometry[n.geoID];r!==void 0&&a.genMorphGeometry(e,t,r,i,n.name)})})}genMorphGeometry(e,t,n,r,i){let a=t.Vertices===void 0?[]:t.Vertices.a,o=t.PolygonVertexIndex===void 0?[]:t.PolygonVertexIndex.a,s=n.Vertices===void 0?[]:n.Vertices.a,c=n.Indexes===void 0?[]:n.Indexes.a,l=e.attributes.position.count*3,u=new Float32Array(l);for(let e=0;e<c.length;e++){let t=c[e]*3;u[t]=s[e*3],u[t+1]=s[e*3+1],u[t+2]=s[e*3+2]}let d={vertexIndices:o,vertexPositions:u,baseVertexPositions:a},f=new U(this.genBuffers(d).vertex,3);f.name=i||n.attrName,f.applyMatrix4(r),e.morphAttributes.position.push(f)}parseNormals(e){let t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.Normals.a,i=[];return n===`IndexToDirect`&&(`NormalIndex`in e?i=e.NormalIndex.a:`NormalsIndex`in e&&(i=e.NormalsIndex.a)),{dataSize:3,buffer:r,indices:i,mappingType:t,referenceType:n}}parseUVs(e){let t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.UV.a,i=[];return n===`IndexToDirect`&&(i=e.UVIndex.a),{dataSize:2,buffer:r,indices:i,mappingType:t,referenceType:n}}parseVertexColors(e){let t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.Colors.a,i=[];n===`IndexToDirect`&&(i=e.ColorIndex.a);for(let e=0,t=new H;e<r.length;e+=4)t.fromArray(r,e),Xn.colorSpaceToWorking(t,Ot),t.toArray(r,e);return{dataSize:4,buffer:r,indices:i,mappingType:t,referenceType:n}}parseMaterialIndices(e){let t=e.MappingInformationType,n=e.ReferenceInformationType;if(t===`NoMappingInformation`)return{dataSize:1,buffer:[0],indices:[0],mappingType:`AllSame`,referenceType:n};let r=e.Materials.a,i=[];for(let e=0;e<r.length;++e)i.push(e);return{dataSize:1,buffer:r,indices:i,mappingType:t,referenceType:n}}parseNurbsGeometry(e){let t=parseInt(e.Order);if(isNaN(t))return console.error(`THREE.FBXLoader: Invalid Order %s given for geometry ID: %s`,e.Order,e.id),new W;let n=t-1,r=e.KnotVector.a,i=[],a=e.Points.a;for(let e=0,t=a.length;e<t;e+=4)i.push(new sr().fromArray(a,e));let o,s;if(e.Form===`Closed`)i.push(i[0]);else if(e.Form===`Periodic`){o=n,s=r.length-1-o;for(let e=0;e<n;++e)i.push(i[e])}let c=new rh(n,r,i,o,s).getPoints(i.length*12);return new W().setFromPoints(c)}},lh=class{parse(){let e=[],t=this.parseClips();if(t!==void 0)for(let n in t){let r=t[n],i=this.addClip(r);e.push(i)}return e}parseClips(){if(X.Objects.AnimationCurve===void 0)return;let e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);let t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){let e=X.Objects.AnimationCurveNode,t=new Map;for(let n in e){let r=e[n];if(r.attrName.match(/S|R|T|DeformPercent/)!==null){let e={id:r.id,attr:r.attrName,curves:{}};t.set(e.id,e)}}return t}parseAnimationCurves(e){let t=X.Objects.AnimationCurve;for(let n in t){let r={id:t[n].id,times:t[n].KeyTime.a.map(_h),values:t[n].KeyValueFloat.a},i=ih.get(r.id);if(i!==void 0){let t=i.parents[0].ID,n=i.parents[0].relationship;n.match(/X/)?e.get(t).curves.x=r:n.match(/Y/)?e.get(t).curves.y=r:n.match(/Z/)?e.get(t).curves.z=r:n.match(/DeformPercent/)&&e.has(t)&&(e.get(t).curves.morph=r)}}}parseAnimationLayers(e){let t=X.Objects.AnimationLayer,n=new Map;for(let r in t){let t=[],i=ih.get(parseInt(r));i!==void 0&&(i.children.forEach(function(n,r){if(e.has(n.ID)){let i=e.get(n.ID);if(i.curves.x!==void 0||i.curves.y!==void 0||i.curves.z!==void 0){if(t[r]===void 0){let e=ih.get(n.ID).parents.filter(function(e){return e.relationship!==void 0});if(e.length===0)return;let i=e[0].ID;if(i!==void 0){let e=X.Objects.Model[i.toString()];if(e===void 0){console.warn(`THREE.FBXLoader: Encountered a unused curve.`,n);return}let a={modelName:e.attrName?Y.sanitizeNodeName(e.attrName):``,ID:e.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};ah.traverse(function(t){t.ID===e.id&&(a.transform=t.matrix,t.userData.transformData&&(a.eulerOrder=t.userData.transformData.eulerOrder,t.userData.transformData.rotation&&(a.initialRotation=t.userData.transformData.rotation)))}),a.transform||=new V,`PreRotation`in e&&(a.preRotation=e.PreRotation.value),`PostRotation`in e&&(a.postRotation=e.PostRotation.value),t[r]=a}}t[r]&&(t[r][i.attr]=i)}else if(i.curves.morph!==void 0){if(t[r]===void 0){let e=ih.get(n.ID).parents.filter(function(e){return e.relationship!==void 0});if(e.length===0)return;let i=e[0].ID,a=ih.get(i).parents[0].ID,o=ih.get(a).parents[0].ID,s=ih.get(o).parents[0].ID,c=X.Objects.Model[s],l={modelName:c.attrName?Y.sanitizeNodeName(c.attrName):``,morphName:X.Objects.Deformer[i].attrName};t[r]=l}t[r][i.attr]=i}}}),n.set(parseInt(r),t))}return n}parseAnimStacks(e){let t=X.Objects.AnimationStack,n={};for(let r in t){let i=ih.get(parseInt(r)).children;i.length>1&&console.warn(`THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.`);let a=e.get(i[0].ID);n[r]={name:t[r].attrName,layer:a}}return n}addClip(e){let t=[],n=this;return e.layer.forEach(function(e){t=t.concat(n.generateTracks(e))}),new tu(e.name,-1,t)}generateTracks(e){let t=[],n=new B,r=new B;if(e.transform&&e.transform.decompose(n,new z,r),n=n.toArray(),r=r.toArray(),e.T!==void 0&&Object.keys(e.T.curves).length>0){let r=this.generateVectorTrack(e.modelName,e.T.curves,n,`position`);r!==void 0&&t.push(r)}if(e.R!==void 0&&Object.keys(e.R.curves).length>0){let n=this.generateRotationTrack(e.modelName,e.R.curves,e.preRotation,e.postRotation,e.eulerOrder,e.initialRotation);n!==void 0&&t.push(n)}if(e.S!==void 0&&Object.keys(e.S.curves).length>0){let n=this.generateVectorTrack(e.modelName,e.S.curves,r,`scale`);n!==void 0&&t.push(n)}if(e.DeformPercent!==void 0){let n=this.generateMorphTrack(e);n!==void 0&&t.push(n)}return t}generateVectorTrack(e,t,n,r){let i=this.getTimesForAllAxes(t),a=this.getKeyframeTrackValues(i,t,n);return new eu(e+`.`+r,i,a)}generateRotationTrack(e,t,n,r,i,a){let o,s;if(t.x!==void 0||t.y!==void 0||t.z!==void 0){let e=this.getTimesForAllAxes(t);if(e.length>0){let n=a||[0,0,0],r=this.synchronizeCurve(t.x,e,n[0]),c=this.synchronizeCurve(t.y,e,n[1]),l=this.synchronizeCurve(t.z,e,n[2]),u=this.interpolateRotations(r,c,l,i);o=u[0],s=u[1]}}let c=Ch(0);n!==void 0&&(n=n.map(Hn.degToRad),n.push(c),n=new Cr().fromArray(n),n=new z().setFromEuler(n)),r!==void 0&&(r=r.map(Hn.degToRad),r.push(c),r=new Cr().fromArray(r),r=new z().setFromEuler(r).invert());let l=new z,u=new Cr,d=[];if(!(!s||!o)){for(let e=0;e<s.length;e+=3)u.set(s[e],s[e+1],s[e+2],i),l.setFromEuler(u),n!==void 0&&l.premultiply(n),r!==void 0&&l.multiply(r),e>2&&new z().fromArray(d,(e-3)/3*4).dot(l)<0&&l.set(-l.x,-l.y,-l.z,-l.w),l.toArray(d,e/3*4);return new Ql(e+`.quaternion`,o,d)}}generateMorphTrack(e){let t=e.DeformPercent.curves.morph,n=t.values.map(function(e){return e/100}),r=ah.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new Xl(e.modelName+`.morphTargetInfluences[`+r+`]`,t.times,n)}getTimesForAllAxes(e){let t=[];if(e.x!==void 0&&(t=t.concat(e.x.times)),e.y!==void 0&&(t=t.concat(e.y.times)),e.z!==void 0&&(t=t.concat(e.z.times)),t=t.sort(function(e,t){return e-t}),t.length>1){let e=1,n=t[0];for(let r=1;r<t.length;r++){let i=t[r];i!==n&&(t[e]=i,n=i,e++)}t=t.slice(0,e)}return t}getKeyframeTrackValues(e,t,n){let r=n,i=[],a=-1,o=-1,s=-1;return e.forEach(function(e){if(t.x&&(a=t.x.times.indexOf(e)),t.y&&(o=t.y.times.indexOf(e)),t.z&&(s=t.z.times.indexOf(e)),a!==-1){let e=t.x.values[a];i.push(e),r[0]=e}else i.push(r[0]);if(o!==-1){let e=t.y.values[o];i.push(e),r[1]=e}else i.push(r[1]);if(s!==-1){let e=t.z.values[s];i.push(e),r[2]=e}else i.push(r[2])}),i}synchronizeCurve(e,t,n){if(e===void 0)return{times:t,values:t.map(()=>n)};if(e.times.length===t.length)return e;let r=[];for(let i=0;i<t.length;i++)r.push(this.sampleCurveValue(e,t[i],n));return{times:t,values:r}}sampleCurveValue(e,t,n){let r=e.times,i=e.values;if(t<=r[0])return i[0];if(t>=r[r.length-1])return i[i.length-1];for(let e=0;e<r.length-1;e++)if(t>=r[e]&&t<=r[e+1]){if(r[e]===t)return i[e];let n=(t-r[e])/(r[e+1]-r[e]);return i[e]*(1-n)+i[e+1]*n}return n}interpolateRotations(e,t,n,r){let i=[],a=[];i.push(e.times[0]),a.push(Hn.degToRad(e.values[0])),a.push(Hn.degToRad(t.values[0])),a.push(Hn.degToRad(n.values[0]));for(let o=1;o<e.values.length;o++){let s=[e.values[o-1],t.values[o-1],n.values[o-1]];if(isNaN(s[0])||isNaN(s[1])||isNaN(s[2]))continue;let c=s.map(Hn.degToRad),l=[e.values[o],t.values[o],n.values[o]];if(isNaN(l[0])||isNaN(l[1])||isNaN(l[2]))continue;let u=l.map(Hn.degToRad),d=[l[0]-s[0],l[1]-s[1],l[2]-s[2]],f=[Math.abs(d[0]),Math.abs(d[1]),Math.abs(d[2])];if(f[0]>=180||f[1]>=180||f[2]>=180){let t=Math.max(...f)/180,n=new Cr(...c,r),s=new Cr(...u,r),l=new z().setFromEuler(n),d=new z().setFromEuler(s);l.dot(d)<0&&d.set(-d.x,-d.y,-d.z,-d.w);let p=e.times[o-1],m=e.times[o]-p,h=new z,g=new Cr;for(let e=0;e<1;e+=1/t)h.copy(l.clone().slerp(d.clone(),e)),i.push(p+e*m),g.setFromQuaternion(h,r),a.push(g.x),a.push(g.y),a.push(g.z)}else i.push(e.times[o]),a.push(Hn.degToRad(e.values[o])),a.push(Hn.degToRad(t.values[o])),a.push(Hn.degToRad(n.values[o]))}return[i,a]}},uh=class{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(e){this.nodeStack.push(e),this.currentIndent+=1}popStack(){this.nodeStack.pop(),--this.currentIndent}setCurrentProp(e,t){this.currentProp=e,this.currentPropName=t}parse(e){this.currentIndent=0,this.allNodes=new ph,this.nodeStack=[],this.currentProp=[],this.currentPropName=``;let t=this,n=e.split(/[\r\n]+/);return n.forEach(function(e,r){let i=e.match(/^[\s\t]*;/),a=e.match(/^[\s\t]*$/);if(i||a)return;let o=e.match(`^\\t{`+t.currentIndent+`}(\\w+):(.*){`,``),s=e.match(`^\\t{`+t.currentIndent+`}(\\w+):[\\s\\t\\r\\n](.*)`),c=e.match(`^\\t{`+(t.currentIndent-1)+`}}`);o?t.parseNodeBegin(e,o):s?t.parseNodeProperty(e,s,n[++r]):c?t.popStack():e.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(e)}),this.allNodes}parseNodeBegin(e,t){let n=t[1].trim().replace(/^"/,``).replace(/"$/,``),r=t[2].split(`,`).map(function(e){return e.trim().replace(/^"/,``).replace(/"$/,``)}),i={name:n},a=this.parseNodeAttr(r),o=this.getCurrentNode();this.currentIndent===0?this.allNodes.add(n,i):n in o?(n===`PoseNode`?o.PoseNode.push(i):o[n].id!==void 0&&(o[n]={},o[n][o[n].id]=o[n]),a.id!==``&&(o[n][a.id]=i)):typeof a.id==`number`?(o[n]={},o[n][a.id]=i):n!==`Properties70`&&(o[n]=n===`PoseNode`?[i]:i),typeof a.id==`number`&&(i.id=a.id),a.name!==``&&(i.attrName=a.name),a.type!==``&&(i.attrType=a.type),this.pushStack(i)}parseNodeAttr(e){let t=e[0];e[0]!==``&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let n=``,r=``;return e.length>1&&(n=e[1].replace(/^(\w+)::/,``),r=e[2]),{id:t,name:n,type:r}}parseNodeProperty(e,t,n){let r=t[1].replace(/^"/,``).replace(/"$/,``).trim(),i=t[2].replace(/^"/,``).replace(/"$/,``).trim();r===`Content`&&i===`,`&&(i=n.replace(/"/g,``).replace(/,$/,``).trim());let a=this.getCurrentNode();if(a.name===`Properties70`){this.parseNodeSpecialProperty(e,r,i);return}if(r===`C`){let e=i.split(`,`).slice(1),t=parseInt(e[0]),n=parseInt(e[1]),o=i.split(`,`).slice(3);o=o.map(function(e){return e.trim().replace(/^"/,``)}),r=`connections`,i=[t,n],Eh(i,o),a[r]===void 0&&(a[r]=[])}r===`Node`&&(a.id=i),r in a&&Array.isArray(a[r])?a[r].push(i):r===`a`?a.a=i:a[r]=i,this.setCurrentProp(a,r),r===`a`&&i.slice(-1)!==`,`&&(a.a=wh(i))}parseNodePropertyContinued(e){let t=this.getCurrentNode();t.a+=e,e.slice(-1)!==`,`&&(t.a=wh(t.a))}parseNodeSpecialProperty(e,t,n){let r=n.split(`",`).map(function(e){return e.trim().replace(/^\"/,``).replace(/\s/,`_`)}),i=r[0],a=r[1],o=r[2],s=r[3],c=r[4];switch(a){case`int`:case`enum`:case`bool`:case`ULongLong`:case`double`:case`Number`:case`FieldOfView`:c=parseFloat(c);break;case`Color`:case`ColorRGB`:case`Vector3D`:case`Lcl_Translation`:case`Lcl_Rotation`:case`Lcl_Scaling`:c=wh(c)}this.getPrevNode()[i]={type:a,type2:o,flag:s,value:c},this.setCurrentProp(this.getPrevNode(),i)}},dh=class{parse(e){let t=new fh(e);t.skip(23);let n=t.getUint32();if(n<6400)throw Error(`THREE.FBXLoader: FBX version not supported, FileVersion: `+n);let r=new ph;for(;!this.endOfContent(t);){let e=this.parseNode(t,n);e!==null&&r.add(e.name,e)}return r}endOfContent(e){return e.size()%16==0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){let n={},r=t>=7500?e.getUint64():e.getUint32(),i=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();let a=e.getUint8(),o=e.getString(a);if(r===0)return null;let s=[];for(let t=0;t<i;t++)s.push(this.parseProperty(e));let c=s.length>0?s[0]:``,l=s.length>1?s[1]:``,u=s.length>2?s[2]:``;for(n.singleProperty=i===1&&e.getOffset()===r;r>e.getOffset();){let r=this.parseNode(e,t);r!==null&&this.parseSubNode(o,n,r)}return n.propertyList=s,typeof c==`number`&&(n.id=c),l!==``&&(n.attrName=l),u!==``&&(n.attrType=u),o!==``&&(n.name=o),n}parseSubNode(e,t,n){if(n.singleProperty===!0){let e=n.propertyList[0];Array.isArray(e)?(t[n.name]=n,n.a=e):t[n.name]=e}else if(e===`Connections`&&n.name===`C`){let e=[];n.propertyList.forEach(function(t,n){n!==0&&e.push(t)}),t.connections===void 0&&(t.connections=[]),t.connections.push(e)}else if(n.name===`Properties70`)Object.keys(n).forEach(function(e){t[e]=n[e]});else if(e===`Properties70`&&n.name===`P`){let e=n.propertyList[0],r=n.propertyList[1],i=n.propertyList[2],a=n.propertyList[3],o;e.indexOf(`Lcl `)===0&&(e=e.replace(`Lcl `,`Lcl_`)),r.indexOf(`Lcl `)===0&&(r=r.replace(`Lcl `,`Lcl_`)),o=r===`Color`||r===`ColorRGB`||r===`Vector`||r===`Vector3D`||r.indexOf(`Lcl_`)===0?[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:n.propertyList[4],t[e]={type:r,type2:i,flag:a,value:o}}else t[n.name]===void 0?typeof n.id==`number`?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:n.name===`PoseNode`?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):t[n.name][n.id]===void 0&&(t[n.name][n.id]=n)}parseProperty(e){let t=e.getString(1),n;switch(t){case`C`:return e.getBoolean();case`D`:return e.getFloat64();case`F`:return e.getFloat32();case`I`:return e.getInt32();case`L`:return e.getInt64();case`R`:return n=e.getUint32(),e.getArrayBuffer(n);case`S`:return n=e.getUint32(),e.getString(n);case`Y`:return e.getInt16();case`b`:case`c`:case`d`:case`f`:case`i`:case`l`:let r=e.getUint32(),i=e.getUint32(),a=e.getUint32();if(i===0)switch(t){case`b`:case`c`:return e.getBooleanArray(r);case`d`:return e.getFloat64Array(r);case`f`:return e.getFloat32Array(r);case`i`:return e.getInt32Array(r);case`l`:return e.getInt64Array(r)}let o=new fh(qm(new Uint8Array(e.getArrayBuffer(a))).buffer);switch(t){case`b`:case`c`:return o.getBooleanArray(r);case`d`:return o.getFloat64Array(r);case`f`:return o.getFloat32Array(r);case`i`:return o.getInt32Array(r);case`l`:return o.getInt64Array(r)}break;default:throw Error(`THREE.FBXLoader: Unknown property type `+t)}}},fh=class{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=t===void 0||t,this._textDecoder=new TextDecoder}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return(this.getUint8()&1)==1}getBooleanArray(e){let t=[];for(let n=0;n<e;n++)t.push(this.getBoolean());return t}getUint8(){let e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){let e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){let e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){let t=[];for(let n=0;n<e;n++)t.push(this.getInt32());return t}getUint32(){let e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t&2147483648?(t=~t&4294967295,e=~e&4294967295,e===4294967295&&(t=t+1&4294967295),e=e+1&4294967295,-(t*4294967296+e)):t*4294967296+e}getInt64Array(e){let t=[];for(let n=0;n<e;n++)t.push(this.getInt64());return t}getUint64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t*4294967296+e}getFloat32(){let e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){let t=[];for(let n=0;n<e;n++)t.push(this.getFloat32());return t}getFloat64(){let e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){let t=[];for(let n=0;n<e;n++)t.push(this.getFloat64());return t}getArrayBuffer(e){let t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){let t=this.offset,n=new Uint8Array(this.dv.buffer,t,e);this.skip(e);let r=n.indexOf(0);return r>=0&&(n=new Uint8Array(this.dv.buffer,t,r)),this._textDecoder.decode(n)}},ph=class{add(e,t){this[e]=t}};function mh(e){return e.byteLength>=21&&Th(e,0,21)===`Kaydara FBX Binary \0`}function hh(e){let t=[`K`,`a`,`y`,`d`,`a`,`r`,`a`,`\\`,`F`,`B`,`X`,`\\`,`B`,`i`,`n`,`a`,`r`,`y`,`\\`,`\\`],n=0;function r(t){let r=e[t-1];return e=e.slice(n+t),n++,r}for(let e=0;e<t.length;++e)if(r(1)===t[e])return!1;return!0}function gh(e){let t=e.match(/FBXVersion: (\d+)/);if(t)return parseInt(t[1]);throw Error(`THREE.FBXLoader: Cannot find the version number for the file given.`)}function _h(e){return e/46186158e3}var vh=[];function yh(e,t,n,r){let i;switch(r.mappingType){case`ByPolygonVertex`:i=e;break;case`ByPolygon`:i=t;break;case`ByVertice`:i=n;break;case`AllSame`:i=r.indices[0];break;default:console.warn(`THREE.FBXLoader: unknown attribute mapping type `+r.mappingType)}r.referenceType===`IndexToDirect`&&(i=r.indices[i]);let a=i*r.dataSize,o=a+r.dataSize;return Dh(vh,r.buffer,a,o)}var bh=new Cr,xh=new B;function Sh(e){let t=new V,n=new V,r=new V,i=new V,a=new V,o=new V,s=new V,c=new V,l=new V,u=new V,d=new V,f=new V,p=e.inheritType?e.inheritType:0;e.translation&&t.setPosition(xh.fromArray(e.translation));let m=Ch(0);if(e.preRotation){let t=e.preRotation.map(Hn.degToRad);t.push(m),n.makeRotationFromEuler(bh.fromArray(t))}if(e.rotation){let t=e.rotation.map(Hn.degToRad);t.push(e.eulerOrder||m),r.makeRotationFromEuler(bh.fromArray(t))}if(e.postRotation){let t=e.postRotation.map(Hn.degToRad);t.push(m),i.makeRotationFromEuler(bh.fromArray(t)),i.invert()}e.scale&&a.scale(xh.fromArray(e.scale)),e.scalingOffset&&s.setPosition(xh.fromArray(e.scalingOffset)),e.scalingPivot&&o.setPosition(xh.fromArray(e.scalingPivot)),e.rotationOffset&&c.setPosition(xh.fromArray(e.rotationOffset)),e.rotationPivot&&l.setPosition(xh.fromArray(e.rotationPivot)),e.parentMatrixWorld&&(d.copy(e.parentMatrix),u.copy(e.parentMatrixWorld));let h=n.clone().multiply(r).multiply(i),g=new V;g.extractRotation(u);let _=new V;_.copyPosition(u);let v=_.clone().invert().multiply(u),y=g.clone().invert().multiply(v),b=a,x=new V;if(p===0)x.copy(g).multiply(h).multiply(y).multiply(b);else if(p===1)x.copy(g).multiply(y).multiply(h).multiply(b);else{let e=new V().scale(new B().setFromMatrixScale(d)).clone().invert(),t=y.clone().multiply(e);x.copy(g).multiply(h).multiply(t).multiply(b)}let S=l.clone().invert(),C=o.clone().invert(),w=t.clone().multiply(c).multiply(l).multiply(n).multiply(r).multiply(i).multiply(S).multiply(s).multiply(o).multiply(a).multiply(C),T=new V().copyPosition(w),E=u.clone().multiply(T);return f.copyPosition(E),w=f.clone().multiply(x),w.premultiply(u.invert()),w}function Ch(e){e||=0;let t=[`ZYX`,`YZX`,`XZY`,`ZXY`,`YXZ`,`XYZ`];return e===6?(console.warn(`THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect.`),t[0]):t[e]}function wh(e){return e.split(`,`).map(function(e){return parseFloat(e)})}function Th(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=e.byteLength),new TextDecoder().decode(new Uint8Array(e,t,n))}function Eh(e,t){for(let n=0,r=e.length,i=t.length;n<i;n++,r++)e[r]=t[n]}function Dh(e,t,n,r){for(let i=n,a=0;i<r;i++,a++)e[a]=t[i];return e}var Oh=`Kaydara FBX Binary \0`,kh=65536;function Ah(e){return e instanceof ArrayBuffer?new Uint8Array(e):ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):null}function jh(e){return e instanceof ArrayBuffer?e:ArrayBuffer.isView(e)?e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength):null}function Mh(e){let t=Ah(e);if(!t||t.byteLength<21)return!1;for(let e=0;e<21;e++)if(t[e]!==Oh.charCodeAt(e))return!1;return!0}function Nh(e){let t=Ah(e);if(!t||!t.byteLength)return null;let n=t.subarray(0,Math.min(t.byteLength,kh)),r=new TextDecoder(`utf-8`).decode(n).match(/FBXVersion: (\d+)/);if(!r)return null;let i=Number(r[1]);return Number.isFinite(i)?i:null}function Ph(e){let t=jh(e);return!t||!t.byteLength?null:new oh().parse(t,``)}function Fh(e){try{let t=Ph(e);if(!t)return null;t.updateMatrixWorld(!0);let n=new fi().setFromObject(t),r=n.getSize(new B);return!(r.y>0)||!Number.isFinite(r.y)?null:{min:{x:n.min.x,y:n.min.y,z:n.min.z},max:{x:n.max.x,y:n.max.y,z:n.max.z}}}catch{return null}}var Ih=.05,Lh=1179937895,Rh=1313821514,zh=12,Bh=8;function Vh(e){return e instanceof ArrayBuffer?new DataView(e):ArrayBuffer.isView(e)?new DataView(e.buffer,e.byteOffset,e.byteLength):null}function Hh(e){let t=Vh(e);return!!(t&&t.byteLength>=4&&t.getUint32(0,!0)===Lh)}function Uh(e){let t=Vh(e);if(!t||t.byteLength<zh||t.getUint32(0,!0)!==Lh)return null;let n=zh;for(;n+Bh<=t.byteLength;){let e=t.getUint32(n,!0),r=t.getUint32(n+4,!0),i=n+Bh;if(e>t.byteLength-i)return null;if(r===Rh){let n=new Uint8Array(t.buffer,t.byteOffset+i,e);try{let e=n.length;for(;e>0&&n[e-1]===0;)--e;return JSON.parse(new TextDecoder().decode(n.subarray(0,e)))}catch{return null}}n=i+e}return null}function Wh(e){let t=Uh(e);if(!t||typeof t!=`object`)return null;let n=Array.isArray(t.accessors)?t.accessors:[],r=new Set;for(let e of Array.isArray(t.meshes)?t.meshes:[])for(let t of Array.isArray(e?.primitives)?e.primitives:[]){let e=t?.attributes?.POSITION;Number.isInteger(e)&&r.add(e)}let i=null;for(let e of r){let t=n[e],r=t?.min,a=t?.max;if(!Array.isArray(r)||!Array.isArray(a)||r.length!==3||a.length!==3)continue;let o=[Number(r[0]),Number(r[1]),Number(r[2])],s=[Number(a[0]),Number(a[1]),Number(a[2])];if(!(o.some(e=>!Number.isFinite(e))||s.some(e=>!Number.isFinite(e)))){if(!i){i={min:{x:o[0],y:o[1],z:o[2]},max:{x:s[0],y:s[1],z:s[2]}};continue}i.min.x=Math.min(i.min.x,o[0]),i.min.y=Math.min(i.min.y,o[1]),i.min.z=Math.min(i.min.z,o[2]),i.max.x=Math.max(i.max.x,s[0]),i.max.y=Math.max(i.max.y,s[1]),i.max.z=Math.max(i.max.z,s[2])}}return i}var Gh=new Set([`KHR_draco_mesh_compression`,`EXT_meshopt_compression`]),Kh=`That model is compressed — export it uncompressed (no Draco / meshopt)`;function qh(e){let t=new Set;if(!e||typeof e!=`object`)return t;for(let n of[e.extensionsUsed,e.extensionsRequired])if(Array.isArray(n))for(let e of n)typeof e==`string`&&t.add(e);for(let n of Array.isArray(e.meshes)?e.meshes:[])for(let e of Array.isArray(n?.primitives)?n.primitives:[]){let n=e?.extensions;if(!(!n||typeof n!=`object`))for(let e of Object.keys(n))t.add(e)}return t}function Jh(e){let t=Uh(e);if(!t)return null;for(let e of qh(t))if(Gh.has(e))return Kh;return null}function Yh(e){return e instanceof ArrayBuffer?new Uint8Array(e):ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):null}function Xh(e){let t=Yh(e);if(!t||!t.byteLength)return``;let n=new TextDecoder(`utf-8`).decode(t);return n.charCodeAt(0)===65279&&(n=n.slice(1)),n}function Zh(e){let t=Xh(e);if(!t)return null;let n=null;for(let e of t.split(/\r?\n/)){let t=e.trim();if(!/^v(?:\s|$)/.test(t))continue;let r=t.split(/\s+/);if(r[0]!==`v`)continue;let i=Number(r[1]),a=Number(r[2]),o=Number(r[3]);if([i,a,o].every(Number.isFinite)){if(!n){n={min:{x:i,y:a,z:o},max:{x:i,y:a,z:o}};continue}n.min.x=Math.min(n.min.x,i),n.min.y=Math.min(n.min.y,a),n.min.z=Math.min(n.min.z,o),n.max.x=Math.max(n.max.x,i),n.max.y=Math.max(n.max.y,a),n.max.z=Math.max(n.max.z,o)}}return n}function Qh(e){let t=String(e?.type??``).toLowerCase();return t===`model/obj`?Zh(e?.bytes):t===`model/fbx`?Fh(e?.bytes):t===`model/gltf-binary`?Wh(e?.bytes):null}function $h({min:e,max:t}={}){let n=Number(t?.x)-Number(e?.x),r=Number(t?.y)-Number(e?.y),i=Number(t?.z)-Number(e?.z);if(!Number.isFinite(r)||!(r>0))return null;let a=r<.05||r>10?1/r:1,o=n*a,s=r*a,c=i*a;return{width:o,height:s,depth:c,fitScale:a,footprint:{width:o,depth:c}}}function eg(e){if(!e)return!1;let t=typeof e.type==`string`?e.type.toLowerCase():``;return t===`model/gltf-binary`||t===`application/gltf-binary`?!0:t===``||t===`application/octet-stream`?String(e.name??``).toLowerCase().endsWith(`.glb`):!1}function tg(e){if(!e)return!1;let t=typeof e.type==`string`?e.type.toLowerCase():``;return t===`model/obj`?!0:String(e.name??``).toLowerCase().endsWith(`.obj`)?t===``||t===`text/plain`||t===`application/octet-stream`||t===`text/x-obj`||t===`application/object`:!1}function ng(e){if(!e)return!1;let t=typeof e.type==`string`?e.type.toLowerCase():``;return t===`model/fbx`?!0:String(e.name??``).toLowerCase().endsWith(`.fbx`)?t===``||t===`text/plain`||t===`application/octet-stream`:!1}function rg(e){return Array.from(e?.files??[]).filter(e=>eg(e)||tg(e)||ng(e))}function ig(e){return e?Array.isArray(e)?e:typeof e.length==`number`&&e.files==null?Array.from(e):Array.from(e.files??[]):[]}function ag(e){let t=[],n=[],r=[];for(let i of ig(e))rg({files:[i]}).length?n.push(i):tm({files:[i]}).length?t.push(i):r.push(i);return{images:t,meshes:n,rejected:r}}async function og(e,t=globalThis.crypto?.subtle){if(!e||typeof e.arrayBuffer!=`function`)throw Error(`importMeshFile needs a File or Blob`);if(Number(e.size)>33554432)throw Error(`That model is too large to import — larger than ${Math.round(Rp/1048576)} MB`);let n=await e.arrayBuffer(),r=typeof e.name==`string`?e.name:``,i=eg(e)||r.toLowerCase().endsWith(`.glb`),a=ng(e)||r.toLowerCase().endsWith(`.fbx`),o=tg(e)||r.toLowerCase().endsWith(`.obj`);if(Hh(n)){let e=Jh(n);if(e)throw Error(e);let i=Wh(n),a=i?$h(i):null;if(!a)throw Error(`That model has no measurable geometry`);let o=em({id:await Zp(n,t),type:`model/gltf-binary`,bytes:n,name:r});if(!o)throw Error(`That model could not be prepared for the set`);return{asset:o,height:a.height,footprint:a.footprint}}if(i)throw Error(`That file is not a GLB model`);let s=Nh(n);if(Mh(n)||(s??0)>=7e3)try{let e=Fh(n),i=e?$h(e):null;if(!i)throw Error(`That model has no measurable geometry`);let a=em({id:await Zp(n,t),type:`model/fbx`,bytes:n,name:r});if(!a)throw Error(`That model could not be prepared for the set`);return{asset:a,height:i.height,footprint:i.footprint}}catch(e){throw sg(e)}if(s!=null&&s<7e3)throw Error(`That FBX file is too old to import`);if(a)throw Error(`That file is not an FBX model`);let c=Zh(n);if(!c)throw Error(o?`That file is not an OBJ model`:`That file is not a 3D model`);let l=$h(c);if(!l)throw Error(`That model has no measurable geometry`);let u=em({id:await Zp(n,t),type:`model/obj`,bytes:n,name:r});if(!u)throw Error(`That model could not be prepared for the set`);return{asset:u,height:l.height,footprint:l.footprint}}function sg(e){let t=String(e?.message??e);return/too old to import/i.test(t)||/no measurable geometry/i.test(t)||/not an FBX/i.test(t)?e instanceof Error?e:Error(t):/version not supported|FileVersion/i.test(t)?Error(`That FBX file is too old to import`):Error(`That file is not an FBX model`)}var cg=[],lg=`XYZ`,ug=Math.PI/180,dg=i(`object.position`),fg=i(`object.rotation`),pg=i(`object.scale`),mg=(e,t,n)=>Math.min(n,Math.max(t,e)),hg=e=>{let t=fg.min.y,n=fg.max.y-t;return((e-t)%n+n)%n+t},gg=(e,t)=>Number((t>0?Math.round(e/t)*t:e).toFixed(4)),_g=`#c2c6c8`,vg=[{kind:`cube`,label:`Cube`,group:`Primitives`,footprint:{width:1,depth:1},height:1,color:_g},{kind:`sphere`,label:`Sphere`,group:`Primitives`,footprint:{width:1,depth:1},height:1,color:_g},{kind:`capsule`,label:`Capsule`,group:`Primitives`,footprint:{width:.7,depth:.7},height:1.4,color:_g},{kind:`cylinder`,label:`Cylinder`,group:`Primitives`,footprint:{width:1,depth:1},height:1,color:_g},{kind:`cone`,label:`Cone`,group:`Primitives`,footprint:{width:1,depth:1},height:1,color:_g},{kind:`plane`,label:`Plane`,group:`Primitives`,footprint:{width:2,depth:2},height:0,color:_g},{kind:`chair`,label:`Chair`,group:`Set pieces`,footprint:{width:.6,depth:.6},height:1.15,supportY:.495,color:`#b9855d`},{kind:`car`,label:`Car`,group:`Set pieces`,footprint:{width:1.8,depth:4.5},height:1.4,color:`#d98770`},{kind:`small-plane`,label:`Plane (aircraft)`,group:`Set pieces`,footprint:{width:3.4,depth:3.6},height:1.4,color:`#7896a4`}],yg=[`#e2e5e6`,_g,`#9aa1a5`,`#767d81`,`#d9b18c`,`#8fae9b`,`#d94a4a`,`#4a7bd9`,`#e2c04a`,`#4fa86a`],bg=`cozyclay.objectColors.recent`,xg=/^#?([0-9a-f]{3})$/i,Sg=/^#?([0-9a-f]{6})$/i;function Cg(e){if(typeof e!=`string`)return null;let t=e.trim(),n=xg.exec(t);if(n)return`#${n[1].toLowerCase().replace(/./g,e=>e+e)}`;let r=Sg.exec(t);return r?`#${r[1].toLowerCase()}`:null}function wg(e,t){let n=Array.isArray(e)?e.map(Cg).filter((e,t,n)=>e&&n.indexOf(e)===t&&!yg.includes(e)):[],r=Cg(t),i=(r&&!yg.includes(r)?[r,...n.filter(e=>e!==r)]:n).slice(0,6);return Array.isArray(e)&&i.length===e.length&&i.every((t,n)=>t===e[n])?e:i}function Tg(e){try{let t=JSON.parse(e?.getItem(`cozyclay.objectColors.recent`)??`[]`);return wg(Array.isArray(t)?t:[],null)}catch{return[]}}function Eg(e,t){try{e?.setItem(bg,JSON.stringify(t))}catch{}}var Dg=`cutout`,Og=.02,kg=1.8,Ag=.05,jg=.02,Mg=50,Ng=`#ffffff`,Pg={kind:Dg,label:`Cutout`,group:`Images`,footprint:{width:1,depth:Og},height:kg,color:Ng},Fg=`mesh`,Ig={kind:Fg,label:`Model`,group:`Models`,footprint:{width:1,depth:1},height:1,color:`#c49a6c`};function Lg(e){return e===`cutout`?Pg:e===`mesh`?Ig:vg.find(t=>t.kind===e)??null}function Rg(e){if(!e||typeof e!=`object`)return 0;let t=Lg(e.renderer),n=Number(e.supportY??t?.supportY??e.height??t?.height);return Number.isFinite(n)?n:0}var zg=e=>Math.max(Ag,e),Bg=e=>mg(e,jg,Mg),Vg=.1,Hg=e=>{let t=Number(e);return Number.isFinite(t)?mg(t,Vg,10):1};function Ug(e,t,n=1){return{width:zg(e)*Bg(t)*Hg(n),depth:Og}}var Wg=Object.freeze([`hips`,`spine`,`chest`,`neck`,`head`,`leftShoulder`,`leftElbow`,`leftHand`,`rightShoulder`,`rightElbow`,`rightHand`,`leftKnee`,`leftFoot`,`rightKnee`,`rightFoot`]);function Gg(e){if(e===null)return null;if(!e||typeof e!=`object`||Array.isArray(e))return;let{characterId:t,bone:n}=e;if(!(typeof t!=`string`||!t)){if(n==null)return{characterId:t,bone:null};if(!(typeof n!=`string`||!Wg.includes(n)))return{characterId:t,bone:n}}}function Kg(e){return e.startsWith(`object:`)?e.slice(7):null}function qg(e,t=[],n={}){if(e===`cutout`||e===`mesh`)return null;let r=Lg(e);if(!r)return null;let i=new Set(t.map(e=>e.name)),a=r.label;for(let e=2;i.has(a);e+=1)a=`${r.label} ${e}`;let o=new Set(t.map(e=>e.id)),s=e;for(let t=2;o.has(s);t+=1)s=`${e}-${t}`;return{id:s,name:a,renderer:e,x:Qg.x(Number(n.x)||0),y:0,z:Qg.z(Number(n.z)||0),rot:Qg.rot(Number(n.rot)||0),rotX:0,rotZ:0,scaleX:1,scaleY:1,scaleZ:1,path:null,color:r.color,parent:null,attach:null,hidden:!1,footprint:{...r.footprint},height:r.height,supportY:Number.isFinite(r.supportY)?r.supportY:r.height}}function Jg({assetId:e,aspect:t=1,height:n=kg,name:r=``,sourceAssetId:i,matteAssetId:a,matteScale:o,stretch:s}={},c=[],l={}){if(typeof e!=`string`||!e)return null;let u=Bg(Number(t)),d=zg(Number(n));if(!Number.isFinite(u)||!Number.isFinite(d))return null;let f=Hg(s),p=typeof r==`string`&&r.trim()?r.trim():Pg.label,m=new Set(c.map(e=>e.name)),h=p;for(let e=2;m.has(h);e+=1)h=`${p} ${e}`;let g=new Set(c.map(e=>e.id)),_=Dg;for(let e=2;g.has(_);e+=1)_=`${Dg}-${e}`;return{id:_,name:h,renderer:Dg,x:Qg.x(Number(l.x)||0),y:0,z:Qg.z(Number(l.z)||0),rot:Qg.rot(Number(l.rot)||0),rotX:0,rotZ:0,scaleX:1,scaleY:1,scaleZ:1,path:null,color:Ng,parent:null,attach:null,hidden:!1,assetId:e,sourceAssetId:typeof i==`string`&&i?i:e,matteAssetId:typeof a==`string`?a:``,matteScale:Number.isFinite(Number(o))?Number(o):1,aspect:u,stretch:f,footprint:Ug(d,u,f),height:d}}function Yg(e){return{assetId:e.assetId,aspect:e.aspect,height:e.height,name:e.name,sourceAssetId:e.sourceAssetId,matteAssetId:e.matteAssetId,matteScale:e.matteScale,stretch:e.stretch}}function Xg({assetId:e,height:t=1,footprint:n,name:r=``,clay:i=!1}={},a=[],o={}){if(typeof e!=`string`||!e)return null;let s=Math.max(Ih,Number(t));if(!Number.isFinite(s))return null;let c=Number(n?.width),l=Number(n?.depth),u=Number.isFinite(c)&&c>0&&Number.isFinite(l)&&l>0?{width:c,depth:l}:{width:s,depth:s},d=typeof r==`string`&&r.trim()?r.trim():Ig.label,f=new Set(a.map(e=>e.name)),p=d;for(let e=2;f.has(p);e+=1)p=`${d} ${e}`;let m=new Set(a.map(e=>e.id)),h=Fg;for(let e=2;m.has(h);e+=1)h=`${Fg}-${e}`;return{id:h,name:p,renderer:Fg,x:Qg.x(Number(o.x)||0),y:0,z:Qg.z(Number(o.z)||0),rot:hg(Number(o.rot)||0),rotX:0,rotZ:0,scaleX:1,scaleY:1,scaleZ:1,path:null,color:Ig.color,parent:null,attach:null,hidden:!1,assetId:e,clay:i===!0,footprint:u,height:s}}function Zg(e){return{assetId:e.assetId,height:e.height,footprint:e.footprint,name:e.name,clay:e.clay===!0}}var Qg={x:e=>mg(e,dg.min.x,dg.max.x),y:e=>mg(e,dg.min.y,dg.max.y),z:e=>mg(e,dg.min.z,dg.max.z),rot:e=>hg(e),rotX:e=>hg(e),rotZ:e=>hg(e),scaleX:e=>mg(e,pg.min.x,pg.max.x),scaleY:e=>mg(e,pg.min.y,pg.max.y),scaleZ:e=>mg(e,pg.min.z,pg.max.z)};function $g(e,t){let n=[],r=new Set([t]),i=[t];for(;i.length;){let t=[];for(let a of e)a.parent&&i.includes(a.parent)&&!r.has(a.id)&&(r.add(a.id),n.push(a),t.push(a.id));i=t}return n}function e_(e,t=[],n=[]){if(!e||typeof e!=`object`)return!1;let r=new Map;for(let e of t)e&&typeof e.id==`string`&&r.set(e.id,e);let i=e=>n.some(t=>t&&typeof t==`object`&&t.id===e&&t.hidden===!0),a=new Set,o=e;for(;o&&typeof o==`object`;){let e=typeof o.id==`string`?o.id:null;if(e){if(a.has(e))break;a.add(e),r.has(e)&&(o=r.get(e))}if(o.hidden===!0)return!0;let t=o.attach&&typeof o.attach.characterId==`string`?o.attach.characterId:null;if(t&&i(t))return!0;let n=typeof o.parent==`string`?o.parent:null;if(!n)break;o=r.get(n)??null}return!1}function t_(e,t,n){let r=!1,i=e.find(e=>e.id===t),a=i?$g(e,t):[],o={x:0,y:0,z:0};if(i)for(let e of[`x`,`y`,`z`]){if(n[e]===void 0)continue;let t=Number(n[e]);Number.isFinite(t)&&(o[e]=Qg[e](t)-i[e])}let s=new Set(a.map(e=>e.id)),c=o.x||o.y||o.z,l=e.map(e=>{if(e.id!==t){if(!c||!s.has(e.id))return e;let t={},n={x:0,y:0,z:0};for(let r of[`x`,`y`,`z`]){if(!o[r])continue;let i=Qg[r](e[r]+o[r]);i!==e[r]&&(t[r]=i,n[r]=i-e[r])}return e.path&&(n.x||n.y||n.z)&&(t.path=Tp(e.path,n)),Object.keys(t).length?(r=!0,{...e,...t}):e}let i={};for(let[t,r]of Object.entries(Qg)){if(n[t]===void 0)continue;let a=Number(n[t]);if(!Number.isFinite(a))continue;let o=r(a);o!==e[t]&&(i[t]=o)}for(let t of[`name`,`color`])typeof n[t]!=`string`||!n[t]||n[t]===e[t]||(i[t]=n[t]);if(typeof n.hidden==`boolean`&&n.hidden!==(e.hidden===!0)&&(i.hidden=n.hidden),n.path!==void 0){let t=n.path===null?null:wp(n.path);JSON.stringify(t??null)!==JSON.stringify(e.path??null)&&(i.path=t)}else if(e.path&&c){let t=Tp(e.path,o);JSON.stringify(t??null)!==JSON.stringify(e.path??null)&&(i.path=t)}if(e.renderer===`cutout`){for(let t of[`assetId`,`sourceAssetId`,`matteAssetId`])typeof n[t]==`string`&&n[t]&&n[t]!==e[t]&&(i[t]=n[t]);if(Number.isFinite(Number(n.matteScale))){let t=mg(Number(n.matteScale),.01,1);t!==e.matteScale&&(i.matteScale=t)}let t=n.height===void 0?NaN:zg(Number(n.height)),r=n.aspect===void 0?NaN:Bg(Number(n.aspect)),a=Number.isFinite(t)?t:e.height,o=Number.isFinite(r)?r:e.aspect,s=Hg(e.stretch),c=n.width!==void 0&&Number.isFinite(Number(n.width))?Hg(Number(n.width)/(a*o)):n.stretch===void 0?s:Hg(n.stretch);(a!==e.height||o!==e.aspect||c!==s)&&(i.height=a,i.aspect=o,i.stretch=c,i.footprint=Ug(a,o,c))}if(e.renderer===`mesh`){typeof n.clay==`boolean`&&n.clay!==(e.clay===!0)&&(i.clay=n.clay),typeof n.assetId==`string`&&n.assetId&&n.assetId!==e.assetId&&(i.assetId=n.assetId);let t=n.height===void 0?NaN:Math.max(Ih,Number(n.height));if(Number.isFinite(t)&&t!==e.height){i.height=t;let n=Number(e.height);if(n>0){let r=t/n;i.footprint={width:Number(e.footprint?.width)*r,depth:Number(e.footprint?.depth)*r}}}}return Object.keys(i).length?(r=!0,{...e,...i}):e});return r?l:e}function n_(e,t,n){if(t===n||n!==null&&!e.some(e=>e.id===n)||n!==null&&$g(e,t).some(e=>e.id===n))return e;let r=!1,i=e.map(e=>{if(e.id!==t)return e;let i=n??null,a=i!==null&&(e.attach??null)!==null;return(e.parent??null)===i&&!a?e:(r=!0,a?{...e,parent:i,attach:null}:{...e,parent:i})});return r?i:e}function r_(e,t,n){let r=Gg(n);if(r===void 0||!e.some(e=>e.id===t))return e;let i=!1,a=e.map(e=>{if(e.id!==t)return e;let n=e.attach??null;if(r===null)return n===null?e:(i=!0,{...e,attach:null});let a=n!==null&&n.characterId===r.characterId&&(n.bone??null)===r.bone,o=(e.parent??null)!==null;return a&&!o?e:(i=!0,o?{...e,attach:r,parent:null}:{...e,attach:r})});return i?a:e}function i_(e,t){let n=e.filter(e=>e.id!==t);return n.length===e.length?e:n.map(e=>e.parent===t?{...e,parent:null}:e)}function a_(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=Lg(e.renderer);if(!t||typeof e.id!=`string`||!e.id)return null;let n=t.kind===Dg,r=t.kind===Fg;if(n&&(typeof e.assetId!=`string`||!e.assetId)||r&&(typeof e.assetId!=`string`||!e.assetId))return null;let i=e.scaleX===void 0&&e.scaleY===void 0&&e.scaleZ===void 0?Number(e.scale):NaN,a=Number.isFinite(i)?i:1,o=(e,t)=>{let n=e===void 0?t:Number(e);return Number.isFinite(n)?n:t},s=Number(e.footprint?.width),c=Number(e.footprint?.depth),l=Number.isFinite(s)&&s>0&&Number.isFinite(c)&&c>0?{width:s,depth:c}:{...t.footprint};return{id:e.id,name:typeof e.name==`string`&&e.name?e.name:t.label,renderer:t.kind,x:Qg.x(o(e.x,0)),y:Qg.y(o(e.y,0)),z:Qg.z(o(e.z,0)),rot:Qg.rot(o(e.rot,0)),rotX:Qg.rotX(o(e.rotX,0)),rotZ:Qg.rotZ(o(e.rotZ,0)),scaleX:Qg.scaleX(o(e.scaleX,a)),scaleY:Qg.scaleY(o(e.scaleY,a)),scaleZ:Qg.scaleZ(o(e.scaleZ,a)),path:wp(e.path),color:typeof e.color==`string`&&e.color?e.color:t.color,parent:typeof e.parent==`string`&&e.parent?e.parent:null,attach:Gg(e.attach)??null,hidden:e.hidden===!0,...n?{assetId:e.assetId,sourceAssetId:typeof e.sourceAssetId==`string`&&e.sourceAssetId?e.sourceAssetId:e.assetId,matteAssetId:typeof e.matteAssetId==`string`?e.matteAssetId:``,matteScale:mg(o(e.matteScale,1),.01,1),aspect:Bg(o(e.aspect,1)),stretch:Hg(o(e.stretch,1)),footprint:Ug(o(e.height,kg),o(e.aspect,1),o(e.stretch,1)),height:zg(o(e.height,kg))}:r?{assetId:e.assetId,clay:e.clay===!0,footprint:l,height:Math.max(Ih,o(e.height,t.height))}:{footprint:{...t.footprint},height:t.height,supportY:Number.isFinite(t.supportY)?t.supportY:t.height}}}var o_=[`x`,`y`,`z`],s_={x:`rotX`,y:`rot`,z:`rotZ`},c_={x:`scaleX`,y:`scaleY`,z:`scaleZ`},l_=.05,u_=5,d_=.05;function f_(e,t,n,r=l_){if(!o_.includes(t)||!Number.isFinite(n))return null;let i=gg((e[t]??0)+n,r);return{[t]:i}}function p_(e,t,n,r=u_){let i=s_[t];return!i||!Number.isFinite(n)?null:{[i]:hg(gg((e[i]??0)+n,r))}}function m_(e,t,n,r=d_){if(!Number.isFinite(n)||n<=0)return null;let i=t===null?o_:o_.includes(t)?[t]:[];if(!i.length)return null;let a={};for(let t of i){let i=c_[t];a[i]=Qg[i](gg((e[i]??1)*n,r))}return a}function h_(e,t,n,r=u_){if(!Number.isFinite(n)||!t)return null;let i=gg(n,r),a=new z().setFromEuler(new Cr((e.rotX??0)*ug,(e.rot??0)*ug,(e.rotZ??0)*ug,lg));a.premultiply(new z().setFromAxisAngle(t,i*ug));let o=new Cr().setFromQuaternion(a,lg);return{rotX:hg(gg(o.x/ug,0)),rot:hg(gg(o.y/ug,0)),rotZ:hg(gg(o.z/ug,0))}}function g_(e){return{width:(e.footprint?.width??1)*(e.scaleX??1),height:(e.height??1)*(e.scaleY??1),depth:(e.footprint?.depth??1)*(e.scaleZ??1)}}var __=1e-4;function v_(e){let t=g_(e),n=(e.rot??0)*ug,r=Math.abs(Math.cos(n)),i=Math.abs(Math.sin(n)),a=(t.width*r+t.depth*i)/2,o=(t.width*i+t.depth*r)/2,s=e.x??0,c=e.z??0,l=e.y??0;return{minX:s-a,maxX:s+a,minZ:c-o,maxZ:c+o,baseY:l,topY:l+t.height}}function y_(e,t,n=[]){let r=v_(e),i=0;for(let e of t){if(e_(e,t,n))continue;let a=v_(e);r.minX>=a.maxX-__||a.minX>=r.maxX-__||r.minZ>=a.maxZ-__||a.minZ>=r.maxZ-__||a.topY>r.baseY+__||a.topY>i&&(i=a.topY)}return i===r.baseY?null:{y:i}}function b_(e,t,n=2.6){let r=e.x-Math.sin(t)*n,i=e.z-Math.cos(t)*n;return{x:gg(Qg.x(r),l_),z:gg(Qg.z(i),l_)}}var x_=t((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),S_=t(((e,t)=>{t.exports=x_()})),C_=t((e=>{var t=g();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var d=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?d:t.useSyncExternalStore})),w_=t(((e,t)=>{t.exports=C_()})),T_=t((e=>{var t=g(),n=w_();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),E_=t(((e,t)=>{t.exports=T_()})),Z=`Hips.Spine.Spine1.Spine2.Spine3.Neck.Head.RightShoulder.RightArm.RightForeArm.RightHand.RightHandEnd.RightHandThumb1.LeftShoulder.LeftArm.LeftForeArm.LeftHand.LeftHandEnd.LeftHandThumb1.RightUpLeg.RightLeg.RightFoot.RightToeBase.LeftUpLeg.LeftLeg.LeftFoot.LeftToeBase`.split(`.`),D_=Object.fromEntries(Z.map((e,t)=>[e,t])),O_={Hips:null,Spine:`Hips`,Spine1:`Spine`,Spine2:`Spine1`,Spine3:`Spine2`,Neck:`Spine3`,Head:`Neck`,RightShoulder:`Spine3`,RightArm:`RightShoulder`,RightForeArm:`RightArm`,RightHand:`RightForeArm`,RightHandEnd:`RightHand`,RightHandThumb1:`RightHand`,LeftShoulder:`Spine3`,LeftArm:`LeftShoulder`,LeftForeArm:`LeftArm`,LeftHand:`LeftForeArm`,LeftHandEnd:`LeftHand`,LeftHandThumb1:`LeftHand`,RightUpLeg:`Hips`,RightLeg:`RightUpLeg`,RightFoot:`RightLeg`,RightToeBase:`RightFoot`,LeftUpLeg:`Hips`,LeftLeg:`LeftUpLeg`,LeftFoot:`LeftLeg`,LeftToeBase:`LeftFoot`},k_=Z.map(e=>O_[e]===null?null:D_[O_[e]]),A_=[`Hips`,`Spine`,`Spine1`,`Neck`,`Head`,`LeftShoulder`,`RightShoulder`,`LeftArm`,`RightArm`,`LeftForeArm`,`RightForeArm`,`LeftHand`,`RightHand`,`LeftUpLeg`,`RightUpLeg`,`LeftLeg`,`RightLeg`,`LeftFoot`,`RightFoot`],j_=Object.fromEntries(A_.map(e=>[e,D_[e===`Spine`?`Spine1`:e===`Spine1`?`Spine2`:e]])),M_=1e-12;function N_(e){return typeof e==`number`&&Number.isFinite(e)}function P_(e,t){if(!Array.isArray(e)||e.length!==4||!e.every(N_))throw Error(`${t} must be a [w, x, y, z] quaternion of four finite numbers`);return e}function F_(e,t){if(!Array.isArray(e)||e.length!==3||!e.every(e=>Array.isArray(e)&&e.length===3&&e.every(N_)))throw Error(`${t} must be a row-major 3x3 matrix of finite numbers`);return e}function I_(e,t){if(!Array.isArray(e)||e.length!==3||!e.every(N_))throw Error(`${t} must be an [x, y, z] vector of three finite numbers`);return e}function L_(e,t){if(!Array.isArray(e)||e.length!==k_.length)throw Error(`${t} must hold ${k_.length} entries (one per cskel27 joint)`);return e.forEach((e,n)=>F_(e,`${t}[${n}]`)),e}function R_(e,t){if(!Array.isArray(e)||e.length!==k_.length)throw Error(`${t} must hold ${k_.length} entries (one per cskel27 joint)`);return e.forEach((e,n)=>I_(e,`${t}[${n}]`)),e}function z_(){let e=new Set,t=[];for(k_.forEach((n,r)=>{n===null&&(e.add(r),t.push(r))}),t.sort((e,t)=>e-t);t.length<k_.length;){let n=!1;for(let r=0;r<k_.length;r+=1)!e.has(r)&&e.has(k_[r])&&(t.push(r),e.add(r),n=!0);if(!n)throw Error(`cskel27 parent table is not a tree`)}return t}var B_=z_();function V_(e,t){return F_(e,`matMul(a, b): a`),F_(t,`matMul(a, b): b`),[[e[0][0]*t[0][0]+e[0][1]*t[1][0]+e[0][2]*t[2][0],e[0][0]*t[0][1]+e[0][1]*t[1][1]+e[0][2]*t[2][1],e[0][0]*t[0][2]+e[0][1]*t[1][2]+e[0][2]*t[2][2]],[e[1][0]*t[0][0]+e[1][1]*t[1][0]+e[1][2]*t[2][0],e[1][0]*t[0][1]+e[1][1]*t[1][1]+e[1][2]*t[2][1],e[1][0]*t[0][2]+e[1][1]*t[1][2]+e[1][2]*t[2][2]],[e[2][0]*t[0][0]+e[2][1]*t[1][0]+e[2][2]*t[2][0],e[2][0]*t[0][1]+e[2][1]*t[1][1]+e[2][2]*t[2][1],e[2][0]*t[0][2]+e[2][1]*t[1][2]+e[2][2]*t[2][2]]]}function H_(e){return F_(e,`matTranspose(m): m`),[[e[0][0],e[1][0],e[2][0]],[e[0][1],e[1][1],e[2][1]],[e[0][2],e[1][2],e[2][2]]]}function U_(e,t){return[e[0][0]*t[0]+e[0][1]*t[1]+e[0][2]*t[2],e[1][0]*t[0]+e[1][1]*t[1]+e[1][2]*t[2],e[2][0]*t[0]+e[2][1]*t[1]+e[2][2]*t[2]]}function W_(e){let[t,n,r,i]=P_(e,`quatToMat(q): q`),a=t*t+n*n+r*r+i*i;if(!Number.isFinite(a)||a<=M_)throw Error(`quatToMat(q): quaternion is zero-length and cannot represent a rotation`);let o=1/Math.sqrt(a),s=t*o,c=n*o,l=r*o,u=i*o;return[[1-2*(l*l+u*u),2*(c*l-s*u),2*(c*u+s*l)],[2*(c*l+s*u),1-2*(c*c+u*u),2*(l*u-s*c)],[2*(c*u-s*l),2*(l*u+s*c),1-2*(c*c+l*l)]]}function G_(e){F_(e,`matToQuat(m): m`);let t,n=e[0][0]+e[1][1]+e[2][2];if(n>0){let r=Math.sqrt(n+1)*2;t=[.25*r,(e[2][1]-e[1][2])/r,(e[0][2]-e[2][0])/r,(e[1][0]-e[0][1])/r]}else if(e[0][0]>e[1][1]&&e[0][0]>e[2][2]){let n=Math.sqrt(1+e[0][0]-e[1][1]-e[2][2])*2;t=[(e[2][1]-e[1][2])/n,.25*n,(e[0][1]+e[1][0])/n,(e[0][2]+e[2][0])/n]}else if(e[1][1]>e[2][2]){let n=Math.sqrt(1+e[1][1]-e[0][0]-e[2][2])*2;t=[(e[0][2]-e[2][0])/n,(e[0][1]+e[1][0])/n,.25*n,(e[1][2]+e[2][1])/n]}else{let n=Math.sqrt(1+e[2][2]-e[0][0]-e[1][1])*2;t=[(e[1][0]-e[0][1])/n,(e[0][2]+e[2][0])/n,(e[1][2]+e[2][1])/n,.25*n]}let r=t.reduce((e,t)=>e+t*t,0);if(!Number.isFinite(r)||r<=M_)throw Error(`matToQuat(m): matrix is degenerate and cannot represent a rotation`);let i=1/Math.sqrt(r),a=t.map(e=>e*i);if(!a.every(N_))throw Error(`matToQuat(m): matrix is degenerate and cannot represent a rotation`);return a}function K_(e){let t=L_(e,`globalRotations(localRotations)`),n=Array(k_.length);for(let e of B_){let r=k_[e];n[e]=r===null?t[e].map(e=>e.slice()):V_(n[r],t[e])}return n}function q_(e,t){let n=R_(e,`deriveBoneOffsets(jointPositions, ...)`),r=K_(t),i=Array(k_.length);for(let e=0;e<i.length;e+=1)i[e]=[0,0,0];for(let e of B_){let t=k_[e];if(t===null)continue;let a=[n[e][0]-n[t][0],n[e][1]-n[t][1],n[e][2]-n[t][2]];i[e]=U_(H_(r[t]),a)}return i}function J_(e,t,n=[0,0,0]){let r=K_(e);R_(t,`forwardKinematics(...): boneOffsets`);let i=I_(n,`forwardKinematics(...): rootPosition`),a=Array(k_.length);for(let e of B_){let n=k_[e];if(n===null){a[e]=i.slice();continue}let o=U_(r[n],t[e]);a[e]=[a[n][0]+o[0],a[n][1]+o[1],a[n][2]+o[2]]}return a}var Y_=[[0,0,0],[0,.0709891,-.0473261],[0,.1642033,-.0637623],[0,.2584953,-.0720118],[0,.3531475,-.0720119],[0,.6016096,-.0365176],[0,.7297793,-.0139179],[-.0319949,.5259196,-.0186873],[-.1909029,.5259195,-.0186873],[-.4863389,.5259194,-.0186873],[-.7189909,.5259193,-.0186873],[-.7886024,.5259193,-.0186873],[-.7468355,.5073563,.0277204],[.0319949,.5259196,-.0186873],[.1909029,.5259196,-.0186873],[.4863389,.5259196,-.0186873],[.7189909,.5259196,-.0186873],[.7886024,.5259196,-.0186873],[.7468355,.5073565,.0277204],[-.0949182,-.0277289,0],[-.0949182,-.4398469,0],[-.0949182,-.8959379,0],[-.0949182,-.9544128,.1606583],[.0949182,-.0277289,0],[.0949182,-.4398469,0],[.0949182,-.8959379,0],[.0949182,-.9544128,.1606583]],X_=[[1,0,0],[0,1,0],[0,0,1]];new Map(A_.map(e=>[Z[j_[e]],e]));var Z_=-Math.min(...Y_.map(e=>e[1]));function Q_(){return{local_rot_mats:Z.map(()=>X_.map(e=>e.slice())),posed_joints:Y_.map(([e,t,n])=>[e,t+Z_,n])}}function $_(e,t,n){let r=e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3],i=r<0?-1:1;r*=i;let a,o;if(r>.9995)a=1-n,o=n;else{let e=Math.acos(Math.min(1,r)),t=Math.sin(e);a=Math.sin((1-n)*e)/t,o=Math.sin(n*e)/t}let s=[e[0]*a+t[0]*i*o,e[1]*a+t[1]*i*o,e[2]*a+t[2]*i*o,e[3]*a+t[3]*i*o],c=Math.hypot(...s);return s.map(e=>e/c)}function ev(e,t){return[[e[t],e[t+1],e[t+2]],[e[t+3],e[t+4],e[t+5]],[e[t+6],e[t+7],e[t+8]]]}function tv(e,t,n){e[t]=n[0][0],e[t+1]=n[0][1],e[t+2]=n[0][2],e[t+3]=n[1][0],e[t+4]=n[1][1],e[t+5]=n[1][2],e[t+6]=n[2][0],e[t+7]=n[2][1],e[t+8]=n[2][2]}var nv=Z.length,rv=(()=>{let e=Q_();return q_(e.posed_joints,e.local_rot_mats)})(),iv=1e-4;function av(e,t){let n=Array(nv);for(let r=0;r<nv;r+=1)n[r]=ev(e,(t*nv+r)*9);return n}function ov(e){let t=Math.max(1,Math.floor(e.frames/16));for(let n=0;n<e.frames;n+=t){let t=J_(av(e.rotMats,n),rv,[e.rootPos[n*3],e.rootPos[n*3+1],e.rootPos[n*3+2]]);for(let r=0;r<nv;r+=1){let i=(n*nv+r)*3,a=t[r][0]-e.posedJoints[i],o=t[r][1]-e.posedJoints[i+1],s=t[r][2]-e.posedJoints[i+2];if(Math.hypot(a,o,s)>iv)return!1}}return!0}function sv(e,t){if(!e||!Number.isFinite(e.fps)||e.fps<=0)throw Error(`retimeMotion: motion.fps must be a positive finite number`);if(!Number.isFinite(t)||t<=0)throw Error(`retimeMotion: targetFps must be a positive finite number`);if(e.fps===t)return e;let n=e.frames;if(!Number.isInteger(n)||n<1)throw Error(`retimeMotion: motion.frames must be a positive integer`);let r=t/e.fps,i=Math.max(1,Math.round(n*r)),a=new Float32Array(i*nv*9),o=new Float32Array(i*3),s=new Float32Array(i*nv*3),c=ov(e);for(let t=0;t<i;t+=1){let i=t/r,l=Math.min(Math.floor(i),n-1),u=Math.min(l+1,n-1),d=Math.min(Math.max(i-l,0),1),f=d===0||l===u;for(let n=0;n<nv;n+=1){let r=(l*nv+n)*9,i=(t*nv+n)*9;if(f)for(let t=0;t<9;t+=1)a[i+t]=e.rotMats[r+t];else{let t=(u*nv+n)*9;tv(a,i,W_($_(G_(ev(e.rotMats,r)),G_(ev(e.rotMats,t)),d)))}}for(let n=0;n<3;n+=1)o[t*3+n]=e.rootPos[l*3+n]*(1-d)+e.rootPos[u*3+n]*d;if(c){let e=J_(av(a,t),rv,[o[t*3],o[t*3+1],o[t*3+2]]);for(let n=0;n<nv;n+=1){let r=(t*nv+n)*3;s[r]=e[n][0],s[r+1]=e[n][1],s[r+2]=e[n][2]}}else for(let n=0;n<nv;n+=1){let r=(l*nv+n)*3,i=(u*nv+n)*3,a=(t*nv+n)*3;for(let t=0;t<3;t+=1)s[a+t]=e.posedJoints[r+t]*(1-d)+e.posedJoints[i+t]*d}}let l={...e,frames:i,fps:t,rotMats:a,rootPos:o,posedJoints:s};return Number.isFinite(e.anchorFrame)&&(l.anchorFrame=Math.min(i-1,Math.round(e.anchorFrame*r))),l}var cv=Z.map(e=>{switch(e){case`Spine`:case`RightHandEnd`:case`LeftHandEnd`:case`RightHand`:case`LeftHand`:case`RightHandThumb1`:case`LeftHandThumb1`:return null;case`Spine1`:return`Spine`;case`Spine2`:return`Spine1`;case`Spine3`:return`Spine2`;default:return e}}),lv=new Set([`RightShoulder`,`RightArm`,`RightForeArm`,`LeftShoulder`,`LeftArm`,`LeftForeArm`]),uv=-.9544128;function dv(e,t){let n=ep(t),r=null;return e.traverse(e=>{if(r||!e.isBone)return;let t=ep(e.name);(t===n||t.endsWith(n))&&(r=e)}),r}var fv=new WeakMap;function pv(e){let t=e.userData&&e.userData.poseBind;if(t)return t;let n=fv.get(e);return n||(n=new Map,e.traverse(e=>{if(e.isBone){let t=e.quaternion;n.set(e,{x:t.x,y:t.y,z:t.z,w:t.w})}}),fv.set(e,n)),n}var mv=new WeakMap;function hv(e){let t=mv.get(e);if(t)return t;let n=pv(e),r=new Map,i=e=>{let t=e.isBone?n.get(e):null;return t?.position?new B(t.position.x,t.position.y,t.position.z):e.position},a=(e,t)=>{let o=e.isBone?n.get(e):null,s=o?new z(o.x,o.y,o.z,o.w):e.quaternion,c=new V().compose(i(e),s,e.scale),l=t.clone().multiply(c);r.set(e,l);for(let t of e.children)a(t,l)};for(let t of e.children)a(t,new V);let o=Array(Z.length).fill(null),s=Array(Z.length).fill(null),c=Array(Z.length).fill(null),l=Array(Z.length).fill(null),u=Array(Z.length).fill(null),d=Array(Z.length).fill(null);for(let t=0;t<Z.length;t+=1){let n=cv[t];if(!n)continue;let a=dv(e,n);if(!a)continue;let f=r.get(a);o[t]=a,s[t]=new B().setFromMatrixPosition(f),c[t]=new z().setFromRotationMatrix(f),l[t]=a.scale.clone(),u[t]=i(a).clone(),d[t]=r.get(a.parent)??new V}let f=Z.indexOf(`Hips`),p=s[f]?s[f].y:0,m=p;for(let e=0;e<s.length;e+=1)s[e]&&s[e].y<m&&(m=s[e].y);let h=p-m,g=h>1e-6?h/.9544128:1,_=Array(Z.length).fill(null);for(let e=0;e<Z.length;e+=1){if(!o[e])continue;let t=Y_[e];_[e]=new B(s[e].x-g*t[0],s[e].y-g*(t[1]-uv),s[e].z-g*t[2])}let v=new Map;for(let e=0;e<o.length;e+=1)o[e]&&v.set(o[e],e);let y=Array(Z.length).fill(-1),b=Array(Z.length).fill(null);for(let t=0;t<o.length;t+=1){let n=o[t];if(n){for(let i=n.parent;i&&i!==e;i=i.parent)if(i.isBone&&v.has(i)){y[t]=v.get(i),b[t]=new V().copy(r.get(i)).invert().multiply(r.get(n.parent));break}}}let x=[];for(let t of[`LeftHand`,`RightHand`]){let a=dv(e,t);if(a){let e=n.get(a);x.push({bone:a,joint:Z.indexOf(t),bindLocalPos:i(a).clone(),bindWorldQuat:new z().setFromRotationMatrix(r.get(a)),parentBindQuat:new z().setFromRotationMatrix(r.get(a.parent)),bindLocalQuat:e?new z(e.x,e.y,e.z,e.w):a.quaternion.clone()})}}let S=Array(Z.length).fill(0),C=Array(Z.length).fill(0);for(let e=1;e<Z.length;e+=1){let t=k_[e],n=Y_[e],r=Y_[t];S[e]=g*Math.hypot(n[0]-r[0],n[1]-r[1],n[2]-r[2]);let a=o[e]??x.find(t=>t.joint===e)?.bone;a&&(C[e]=i(a).length())}return t={bones:o,bindPos:s,stretchedLeaves:x,canonicalBoneLength:S,rigBoneLength:C,bindQuat:c,bindScale:l,bindLocalPos:u,parentBindWorld:d,chainParent:y,chainRel:b,scale:g,offsets:_},mv.set(e,t),t}function gv(e){let t=hv(e);if(!t)throw Error(`captureArdyRoot: rig is not prepared for ARDY playback`);let n=Z.indexOf(`Hips`),r=t.bones[n];if(!r)throw Error(`captureArdyRoot: mapped Hips bone is unavailable`);e.updateMatrixWorld(!0);let i=new V().copy(e.matrixWorld).invert(),a=new V().multiplyMatrices(i,r.matrixWorld),o=new B,s=new z;a.decompose(o,s,new B);let c=s.multiply(t.bindQuat[n].clone().invert()).normalize(),l=t.offsets[n].clone().applyQuaternion(c),u=t.lastScale??t.scale;return[(o.x-l.x)/u,(o.y-l.y)/u,(o.z-l.z)/u]}var _v=new WeakMap;function vv(e,t){let n=_v.get(t);if(n&&n.prep===e)return n.offsets;let r=Array(Z.length);for(let e=0;e<Z.length;e+=1){let n=k_[e],i=Y_[e];if(n===null){r[e]=[i[0],i[1],i[2]];continue}let a=Y_[n],o=r[n];r[e]=[o[0]+t[e]*(i[0]-a[0]),o[1]+t[e]*(i[1]-a[1]),o[2]+t[e]*(i[2]-a[2])]}let i=Array(Z.length).fill(null);for(let t=0;t<Z.length;t+=1){if(!e.bones[t])continue;let n=r[t];i[t]=new B(e.bindPos[t].x-e.scale*n[0],e.bindPos[t].y-e.scale*(n[1]-uv),e.bindPos[t].z-e.scale*n[2])}return _v.set(t,{prep:e,offsets:i}),i}function yv(e,t,n){if(!t.boneScale)return 1;if(bv.has(Z[n]))return t.boneScale[n];let r=e.canonicalBoneLength[n],i=e.rigBoneLength[n];return!(r>1e-6)||!(i>1e-6)?t.boneScale[n]:t.boneScale[n]*r/i}var bv=new Set([`LeftShoulder`,`RightShoulder`,`LeftArm`,`RightArm`]),xv=Array(Z.length);for(let e=0;e<xv.length;e+=1)xv[e]=[[0,0,0],[0,0,0],[0,0,0]];var Sv=new Gn,Cv=new V,wv=new V,Tv=new V,Ev=new z,Dv=new z,Ov=new B,kv=new B,Av=new B,jv=new z,Mv=new B,Nv=Array(Z.length).fill(null);function Pv(e,t){for(let n=0;n<xv.length;n+=1){let r=(t*xv.length+n)*9,i=xv[n];for(let t=0;t<3;t+=1)for(let n=0;n<3;n+=1)i[t][n]=e.rotMats[r+t*3+n]}return K_(xv)}function Fv(e,t=new z){return Sv.set(...e[0],...e[1],...e[2]),t.setFromRotationMatrix(Cv.setFromMatrix3(Sv))}function Iv(e,{base:t,chains:n},r){let i=Pv(t,r),a=t.boneScale?vv(e,t.boneScale):e.offsets,o=Math.max(0,Math.min(t.anchorFrame||0,t.frames-1))*27*3,s=new Map,c=new Map,l=new Map,u=n=>{if(!s.has(n)){let c=Fv(i[n]),l=new B().fromArray(t.posedJoints,(r*27+n)*3);l.x-=t.posedJoints[o],l.z-=t.posedJoints[o+2],l.multiplyScalar(e.scale).add(a[n].clone().applyQuaternion(c)),s.set(n,new V().compose(l,c.multiply(e.bindQuat[n]),e.bindScale[n]))}return s.get(n)};for(let t of n){let n=t.startsWith(`left`)?`Left`:`Right`;if(t.endsWith(`Hand`)){let t=e.stretchedLeaves.find(e=>Z[e.joint]===`${n}Hand`);t&&l.set(t.bone,Fv(i[k_[t.joint]]).multiply(t.bindWorldQuat))}else for(let t of[`UpLeg`,`Leg`,`Foot`,`ToeBase`]){let r=Z.indexOf(n+t),i=e.bones[r];if(!i)continue;let a=e.chainParent[r],o=a<0?e.parentBindWorld[r].clone():u(a).clone().multiply(e.chainRel[r]);c.set(i,new B().setFromMatrixPosition(u(r)).applyMatrix4(o.invert()))}}return{positions:c,wrists:l}}function Lv(e,t,n){if(!e||!t)return;let r=Math.max(0,Math.min(Math.round(n)||0,t.frames-1)),i=hv(e),a=Z.length,o=t.trailRetarget?Iv(i,t.trailRetarget,r):null,s=Pv(t,r),c=Math.max(0,Math.min(t.anchorFrame||0,t.frames-1)),l=t.posedJoints[c*a*3],u=t.posedJoints[c*a*3+2],d=i.scale;i.lastScale=d;let f=t.boneScale?vv(i,t.boneScale):i.offsets;for(let e=0;e<a;e+=1){let n=i.bones[e];if(Nv[e]=null,!n)continue;let c=s[e];Sv.set(c[0][0],c[0][1],c[0][2],c[1][0],c[1][1],c[1][2],c[2][0],c[2][1],c[2][2]),Ev.setFromRotationMatrix(Cv.setFromMatrix3(Sv));let p=(r*a+e)*3;Ov.copy(f[e]).applyQuaternion(Ev),kv.set(d*(t.posedJoints[p]-l)+Ov.x,d*t.posedJoints[p+1]+Ov.y,d*(t.posedJoints[p+2]-u)+Ov.z),Dv.copy(Ev).multiply(i.bindQuat[e]);let m=i.chainParent[e];m>=0?Tv.copy(Nv[m]).multiply(i.chainRel[e]):Tv.copy(i.parentBindWorld[e]),o?.positions.has(n)?kv.copy(o.positions.get(n)).applyMatrix4(Tv):lv.has(Z[e])&&kv.copy(i.bindLocalPos[e]).multiplyScalar(yv(i,t,e)).applyMatrix4(Tv),Cv.compose(kv,Dv,i.bindScale[e]),Nv[e]=Cv.clone(),wv.copy(Tv).invert().multiply(Cv),wv.decompose(Av,jv,Mv),n.position.copy(Av),n.quaternion.copy(jv)}for(let e of i.stretchedLeaves){e.bone.position.copy(e.bindLocalPos).multiplyScalar(yv(i,t,e.joint));let n=o?.wrists.get(e.bone);n?(Fv(s[k_[e.joint]],Ev).multiply(e.parentBindQuat),e.bone.quaternion.copy(Ev.invert().multiply(n))):e.bone.quaternion.copy(e.bindLocalQuat)}e.updateMatrixWorld(!0)}var Rv=new WeakMap;function zv(e){let t=Rv.get(e);if(t)return t;let n=e.userData?.poseBind??fv.get(e)??new Map,r=new Map,i=e=>e.isBone||e.children.some(i),a=e=>{let t=e.isBone?new io:new Br;t.name=e.name,t.position.copy(e.position),t.quaternion.copy(e.quaternion),t.scale.copy(e.scale);let o=e.isBone?n.get(e):null,s=e.quaternion;e.isBone&&r.set(t,o??{x:s.x,y:s.y,z:s.z,w:s.w});for(let n of e.children)i(n)&&t.add(a(n));return t};t=new Br;for(let n of e.children)i(n)&&t.add(a(n));return t.userData.poseBind=r,Rv.set(e,t),t}var Bv=new WeakMap;function Vv(e,t,n,r,i){let a=zv(e),o=hv(a);o.driven||=Z.map((e,t)=>o.bones[t]??o.stretchedLeaves.find(e=>e.joint===t)?.bone??null),Lv(a,t,n);for(let e=0;e<o.driven.length;e+=1){let t=o.driven[e],n=i+e*3;if(!t){r[n]=r[n+1]=r[n+2]=NaN;continue}let a=t.matrixWorld.elements;r[n]=a[12],r[n+1]=a[13],r[n+2]=a[14]}}function Hv(e,t,n){if(!e||!t?.rotMats||!(t.frames>0))return null;let r=new Float32Array(Z.length*3);return Vv(e,t,Math.max(0,Math.min(Math.round(n)||0,t.frames-1)),r,0),r}function Uv(e,t){if(!e||!t?.rotMats||!(t.frames>0))return null;let n=Bv.get(t);n||(n=new WeakMap,Bv.set(t,n));let r=n.get(e);if(r)return r;let i=Z.length,a=new Float32Array(t.frames*i*3);for(let n=0;n<t.frames;n+=1)Vv(e,t,n,a,n*i*3);let o={positions:a};return n.set(e,o),o}function Wv(e){let t=[],n=hv(e);for(let e of[...n.bones,...n.stretchedLeaves.map(e=>e.bone)])e&&t.push([e,e.quaternion.x,e.quaternion.y,e.quaternion.z,e.quaternion.w,e.position.x,e.position.y,e.position.z]);return t}function Gv(e,t){if(!(!e||!t)){for(let e of t)e[0].quaternion.set(e[1],e[2],e[3],e[4]),e.length>5&&e[0].position.set(e[5],e[6],e[7]);e.updateMatrixWorld(!0)}}function Kv(e,t,n){if(!e||!Number.isInteger(e.frames)||e.frames<1)throw Error(`sliceMotion: motion.frames must be a positive integer`);if(!Number.isInteger(t)||!Number.isInteger(n))throw Error(`sliceMotion: startFrame and endFrame must be integers`);if(t<0||n>=e.frames||t>n)throw Error(`sliceMotion: range ${t}..${n} is outside 0..${e.frames-1}`);let r=Z.length,i=n-t+1;return{...e,frames:i,rotMats:e.rotMats.slice(t*r*9,(n+1)*r*9),rootPos:e.rootPos.slice(t*3,(n+1)*3),posedJoints:e.posedJoints.slice(t*r*3,(n+1)*r*3),anchorFrame:0}}var qv=.1,Jv=4,Yv=.1,Xv=e=>Math.round(Number(e)/Yv)*Yv,Zv=e=>e.sourceEnd-e.sourceStart+1,Qv=e=>Math.max(1,Math.round(Zv(e)/e.speed));function $v(e){if(!Number.isInteger(e)||e<1)throw Error(`createMotionEdit: frames must be a positive integer`);return[{id:`motion-0`,sourceStart:0,sourceEnd:e-1,speed:1}]}function ey(e){return!Array.isArray(e)||e.length<1?0:e.reduce((e,t)=>e+Qv(t),0)}function ty(e){let t=0;return e.map(e=>{let n=Qv(e),r={...e,timelineStart:t,timelineEnd:t+n-1,timelineFrames:n};return t+=n,r})}function ny(e,t){let n=ty(e);if(n.length<1)return Math.max(0,Math.round(t)||0);let r=Math.max(0,Math.min(Number.isFinite(t)?t:0,n.at(-1).timelineEnd)),i=n.find(e=>r<=e.timelineEnd)??n.at(-1);if(i.timelineFrames<=1)return i.sourceStart;let a=(r-i.timelineStart)/(i.timelineFrames-1);return i.sourceStart+a*(i.sourceEnd-i.sourceStart)}function ry(e,t){if(!Array.isArray(e)||e.length<1||!Number.isFinite(t))return null;let n=ty(e).find(e=>t>=e.sourceStart&&t<=e.sourceEnd);if(!n)return null;if(n.sourceEnd===n.sourceStart)return n.timelineStart;let r=(t-n.sourceStart)/(n.sourceEnd-n.sourceStart);return Math.round(n.timelineStart+r*(n.timelineFrames-1))}function iy(e,t,n){return ry(t,ny(e,n))}function ay(e,t,n){let r=new Map;for(let i of[...e.keys()].sort((e,t)=>e-t)){let a=iy(t,n,i);a===null||r.has(a)||r.set(a,e.get(i))}return r}function oy(e,t){if(!Array.isArray(e)||e.length<1)return e;let n=ty(e),r=Math.round(t);if(r<=0||r>=ey(e))return e;let i=n.findIndex(e=>r>e.timelineStart&&r<=e.timelineEnd);if(i<0)return e;let a=n[i],o=Math.max(a.sourceStart+1,Math.min(a.sourceEnd,Math.round(ny(e,r))));if(o<=a.sourceStart||o>a.sourceEnd)return e;let s=[...e];return s.splice(i,1,{id:`${a.id}-a`,sourceStart:a.sourceStart,sourceEnd:o-1,speed:a.speed},{id:`${a.id}-b`,sourceStart:o,sourceEnd:a.sourceEnd,speed:a.speed}),s}function sy(e,t,n){let r=Xv(n);if(!Number.isFinite(r)||r<qv||r>Jv)throw Error(`setMotionSegmentSpeed: speed must be between 0.1 and 4.0 in 0.1 steps`);return e.map(e=>e.id===t?{...e,speed:Number(r.toFixed(1))}:e)}function cy(e,t){if(!Array.isArray(e)||e.length<2)return e;let n=e.filter(e=>e.id!==t);return n.length===e.length?e:n}function ly(e,t){let n=Math.max(1,Math.round(Number(t)||1)),r=Zv(e)/n;return Number(Xv(Math.min(Jv,Math.max(qv,r))).toFixed(1))}function uy(e,t,n){if(!Array.isArray(e)||e.length<1)return e;let r=ey(e);if(!Number.isInteger(t)||!Number.isInteger(n)||t<0||n>=r||t>n)throw Error(`trimMotionEdit: range ${t}..${n} is outside 0..${r-1}`);return ty(e).flatMap(r=>{let i=Math.max(t,r.timelineStart),a=Math.min(n,r.timelineEnd);if(i>a)return[];let o=Math.ceil(ny(e,i)),s=Math.floor(ny(e,a));return[{id:`${r.id}-trim-${o}`,sourceStart:Math.max(r.sourceStart,o),sourceEnd:Math.min(r.sourceEnd,s),speed:r.speed}]}).filter(e=>e.sourceStart<=e.sourceEnd)}function dy(e,t,n,r,i){let a=t*i;n.set(e.subarray(a,a+i),r*i)}function fy(e,t){if(!e||!Number.isInteger(e.frames)||e.frames<1||!Number.isFinite(e.fps)||e.fps<=0)throw Error(`renderMotionEdit: motion must have positive frames and fps`);let n=Array.isArray(t)&&t.length?t:$v(e.frames),r=n.map(t=>{let n=Kv(e,t.sourceStart,t.sourceEnd);return t.speed===1?n:sv(n,e.fps/t.speed)}),i=r.reduce((e,t)=>e+t.frames,0),a=e.rotMats.length/e.frames,o=e.rootPos.length/e.frames,s=e.posedJoints.length/e.frames,c=new Float32Array(i*a),l=new Float32Array(i*o),u=new Float32Array(i*s),d=0;for(let t=0;t<r.length;t+=1){let i=r[t],f=n[t];for(let t=0;t<i.frames;t+=1){let n=t===i.frames-1&&f.speed>1,r=n?e:i,p=n?f.sourceEnd:t;dy(r.rotMats,p,c,d+t,a),dy(r.rootPos,p,l,d+t,o),dy(r.posedJoints,p,u,d+t,s)}d+=i.frames}return{...e,frames:i,fps:e.fps,rotMats:c,rootPos:l,posedJoints:u,anchorFrame:0,editSegments:n.map(e=>({...e}))}}var py=.01,my=Z.length,hy=e=>Z.indexOf(e),gy={leftHand:[`LeftArm`,`LeftForeArm`,`LeftHand`],rightHand:[`RightArm`,`RightForeArm`,`RightHand`],leftFoot:[`LeftUpLeg`,`LeftLeg`,`LeftFoot`],rightFoot:[`RightUpLeg`,`RightLeg`,`RightFoot`]},_y=[{id:`leftHand`,joint:`LeftHand`,color:`#ff8a3d`},{id:`rightHand`,joint:`RightHand`,color:`#ff8a3d`},{id:`leftFoot`,joint:`LeftFoot`,color:`#4dd2ff`},{id:`rightFoot`,joint:`RightFoot`,color:`#4dd2ff`},{id:`head`,joint:`Head`,color:`#b98cff`},{id:`hips`,joint:`Hips`,color:`#ffd23d`}],vy={hips:`Hips`,spine:`Spine1`,chest:`Spine2`,neck:`Neck`,head:`Head`,leftShoulder:`LeftArm`,leftElbow:`LeftForeArm`,leftHand:`LeftHand`,rightShoulder:`RightArm`,rightElbow:`RightForeArm`,rightHand:`RightHand`,leftKnee:`LeftLeg`,leftFoot:`LeftFoot`,rightKnee:`RightLeg`,rightFoot:`RightFoot`};function yy(e){let t=e?.frames??0,n=Math.max(0,Math.min(e?.anchorFrame||0,Math.max(0,t-1))),r=(Number.isFinite(e?.rotationDeg)?e.rotationDeg:0)*Math.PI/180;return{anchorFrame:n,cos:Math.cos(r),sin:Math.sin(r),anchorX:Number.isFinite(e?.anchorX)?e.anchorX:0,anchorZ:Number.isFinite(e?.anchorZ)?e.anchorZ:0,rootX:e?.posedJoints?.[n*my*3]??e?.rootPos?.[n*3]??0,rootZ:e?.posedJoints?.[n*my*3+2]??e?.rootPos?.[n*3+2]??0}}function by(e,t,n){let r=t-e.rootX,i=n-e.rootZ;return[e.anchorX+r*e.cos+i*e.sin,e.anchorZ+-r*e.sin+i*e.cos]}function xy(e,t,n){if(!n)return null;let r=Uv(n,e);return r&&Number.isFinite(r.positions[t*3])?r:null}function Sy(e,t=`Hips`,{baseY:n=0,scale:r=1,rig:i=null}={}){if(!e?.posedJoints||!(e.frames>0))return null;let a=Z.indexOf(t);if(a<0)return null;let o=yy(e),s=new Float32Array(e.frames*3),c=xy(e,a,i);if(c){let t=py*r;for(let r=0;r<e.frames;r+=1){let e=(r*my+a)*3,i=c.positions[e]*t,l=c.positions[e+2]*t;s[r*3]=o.anchorX+i*o.cos+l*o.sin,s[r*3+1]=n+c.positions[e+1]*t,s[r*3+2]=o.anchorZ-i*o.sin+l*o.cos}return s}for(let t=0;t<e.frames;t+=1){let i=(t*my+a)*3,[c,l]=by(o,e.posedJoints[i],e.posedJoints[i+2]);s[t*3]=o.anchorX+(c-o.anchorX)*r,s[t*3+1]=n+e.posedJoints[i+1]*r,s[t*3+2]=o.anchorZ+(l-o.anchorZ)*r}return s}function Cy(e,t,{baseY:n=0,scale:r=1}={}){let i=yy(e),a=Number.isFinite(r)&&Math.abs(r)>1e-9?r:1,o=(t.x-i.anchorX)/a,s=(t.z-i.anchorZ)/a,c=o*i.cos-s*i.sin,l=o*i.sin+s*i.cos;return{x:i.rootX+c,y:(t.y-n)/a,z:i.rootZ+l}}function wy(e,t){let{cos:n,sin:r}=yy(e);return{x:t.x*n-t.z*r,y:t.y,z:t.x*r+t.z*n}}function Ty(e,t,{track:n=`hips`,grabFrame:r=0,radiusFrames:i=0,rig:a=null,scale:o=1}={}){let s=Number.isFinite(o)&&o>1e-9?o:1,c=wy(e,{x:t.x/s,y:t.y/s,z:t.z/s}),l=Math.hypot(t.x,t.y,t.z),u=hy(_y.find(e=>e.id===n)?.joint??``),d=a&&u>=0&&e?.rotMats&&l>1e-6?Uv(a,e):null,f=Math.max(0,Math.min((e?.frames??1)-1,Math.round(r)||0)),p=d?.positions.subarray((f*my+u)*3,(f*my+u)*3+3);if(!p||!Number.isFinite(p[0]))return c;let m=yy(e),h=py*s,g=[t.x,t.y,t.z],_=e=>({x:c.x*e,y:c.y*e,z:c.z*e}),v=t=>{let r=Hv(a,Xy(e,{track:n,grabFrame:f,radiusFrames:i,clipDelta:_(t)}),f).subarray(u*3,u*3+3),o=(r[0]-p[0])*h,s=(r[2]-p[2])*h;return[o*m.cos+s*m.sin,(r[1]-p[1])*h,-o*m.sin+s*m.cos]},y=1,b={gain:1,miss:1/0};for(let e=0;e<4;e+=1){let e=v(y),t=Ny(Oy(g,e));t<b.miss&&(b={gain:y,miss:t});let n=jy(e,e);if(!(n>1e-12)||t<1e-4)break;let r=Math.max(.1,Math.min(1.5,y*jy(g,e)/n));if(Math.abs(r-y)<1e-4)break;y=r}return _(b.gain)}function Ey(e,t){if(!(t>0))return+(e===0);let n=1-Math.min(1,Math.abs(e)/t);return n*n*(3-2*n)}function Dy(e,t,n){let r=Math.max(0,e-1),i=Math.max(0,Math.min(r,Math.round(t)||0)),a=Math.max(0,Math.round(n)||0);return{startFrame:Math.max(0,i-a),endFrame:Math.min(e,i+a+1)}}var Oy=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]],ky=(e,t)=>[e[0]+t[0],e[1]+t[1],e[2]+t[2]],Ay=(e,t)=>[e[0]*t,e[1]*t,e[2]*t],jy=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],My=(e,t)=>[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]],Ny=e=>Math.hypot(e[0],e[1],e[2]);function Py(e){let t=Ny(e);return t>1e-9?Ay(e,1/t):null}function Fy(e,t){let n=Array(9);for(let r=0;r<3;r+=1)for(let i=0;i<3;i+=1)n[r*3+i]=e[r*3]*t[i]+e[r*3+1]*t[3+i]+e[r*3+2]*t[6+i];return n}var Iy=e=>[e[0],e[3],e[6],e[1],e[4],e[7],e[2],e[5],e[8]],Ly=(e,t)=>[e[0]*t[0]+e[1]*t[1]+e[2]*t[2],e[3]*t[0]+e[4]*t[1]+e[5]*t[2],e[6]*t[0]+e[7]*t[1]+e[8]*t[2]];function Ry(e,t){let n=jy(e,t);if(n<-1+1e-9){let[t,n,r]=Py(My(e,Math.abs(e[0])<.9?[1,0,0]:[0,1,0]));return[2*t*t-1,2*t*n,2*t*r,2*t*n,2*n*n-1,2*n*r,2*t*r,2*n*r,2*r*r-1]}let[r,i,a]=My(e,t),o=1/(1+n);return[1-o*(i*i+a*a),-a+o*r*i,i+o*r*a,a+o*r*i,1-o*(r*r+a*a),-r+o*i*a,-i+o*r*a,r+o*i*a,1-o*(r*r+i*i)]}function zy(e){return Z.map((e,t)=>t).filter(t=>{for(let n=t;n!==null;n=k_[n])if(n===e)return!0;return!1})}function By(e,t,n){let r=new Map,i=e=>Array.from(t.subarray((n*my+e)*9,(n*my+e)*9+9)),a=e=>{if(!r.has(e)){let t=k_[e];r.set(e,t===null?i(e):Fy(a(t),i(e)))}return r.get(e)};return{pos:t=>{let r=(n*my+t)*3;return[e[r],e[r+1],e[r+2]]},setPos:(t,r)=>e.set(r,(n*my+t)*3),global:a,setGlobal:(e,r,i=k_[e]===null?null:a(k_[e]))=>{t.set(i?Fy(Iy(i),r):r,(n*my+e)*9)}}}function Vy(e,[t,n,r],i,a,o,s){let c=[0,0,0];for(let l=i;l<a;l+=1){let i=By(e.posedJoints,null,l),a=My(Oy(i.pos(n),i.pos(t)),Oy(i.pos(r),i.pos(t)));c=ky(c,Ay(a,Ey(l-o,s)))}return Py(c)}var Hy=Math.PI/6,Uy=.25;function Wy(e,t,n){if(Math.acos(Math.max(-1,Math.min(1,jy(e,t))))<=n)return t;let r=Py(Oy(t,Ay(e,jy(e,t))));return r?ky(Ay(e,Math.cos(n)),Ay(r,Math.sin(n))):e}function Gy(e,[t,n,r],i,a,o){let s=e.pos(t),c=e.pos(n),l=e.pos(r),u=Ny(Oy(c,s)),d=Ny(Oy(l,c));if(Ny(a)<1e-9)return;let f=Oy(c,s),p=Oy(l,s),m=Py(My(f,p)),h=Oy(ky(l,a),s),g=Py(h)??Py(p);if(!g)return;let _=o??m??Py(My(g,Math.abs(g[0])<.9?[1,0,0]:[0,1,0])),v=Py(Oy(_,Ay(g,jy(_,g))))??Py(My(g,Math.abs(g[0])<.9?[1,0,0]:[0,1,0])),y=(Ny(h)-(u+d))/((u+d)*Uy),b=m?Math.acos(Math.max(-1,Math.min(1,jy(m,v)))):0;if(y>0&&b>Hy){let e=Math.min(1,y),t=Wy(m,v,b-(b-Hy)*e*e*(3-2*e)),n=Oy(h,Ay(t,jy(h,t)));Py(n)&&(v=t,h=n,g=Py(n))}let x=Math.min(u+d-1e-6,Math.max(Math.abs(u-d)+1e-6,Ny(h)));if(!(x>1e-9))return;let S=(u*u-d*d+x*x)/(2*x),C=Math.sqrt(Math.max(0,u*u-S*S)),w=Py(My(g,v)),T=ky(s,ky(Ay(g,S),Ay(w,C))),E=ky(s,Ay(g,x)),D=Oy(E,l);for(let t of i)e.setPos(t,ky(e.pos(t),D));if(e.setPos(n,T),!e.rotMats)return;let O=(e,t)=>Ry(Py(e),Py(t)),ee=Fy(O(f,Oy(T,s)),e.global(t)),k=Fy(O(Oy(l,c),Oy(E,T)),e.global(n)),te=e.global(r);e.setGlobal(t,ee),e.setGlobal(n,k,ee),e.setGlobal(r,te,k)}function Ky(e,t,n,r,i){let a=e.pos(t),o=e.pos(n),s=Py(Oy(o,a)),c=Py(Oy(ky(o,i),a));if(!s||!c)return;let l=Ry(s,c);for(let t of r)e.setPos(t,ky(a,Ly(l,Oy(e.pos(t),a))));e.rotMats&&e.setGlobal(t,Fy(l,e.global(t)))}function qy(e){if(e==null)return null;let t=()=>{throw TypeError(`Invalid motion trail edit recipe`)};(e.version!==1||!Number.isInteger(e.frames)||e.frames<1||!(e.fps>0)||!Number.isFinite(e.fps)||!Array.isArray(e.edits)||e.edits.length>4096)&&t();let n=e.edits.map(n=>((!_y.some(({id:e})=>e===n?.track)||!Number.isInteger(n.grabFrame)||n.grabFrame<0||n.grabFrame>=e.frames||!Number.isInteger(n.radiusFrames)||n.radiusFrames<0||![`x`,`y`,`z`].every(e=>Number.isFinite(n.clipDelta?.[e])))&&t(),{track:n.track,grabFrame:n.grabFrame,radiusFrames:n.radiusFrames,clipDelta:{x:n.clipDelta.x,y:n.clipDelta.y,z:n.clipDelta.z}})),r=null;return e.segments!=null&&((!Array.isArray(e.segments)||!e.segments.length||e.segments.length>4096)&&t(),r=e.segments.map(e=>((typeof e?.id!=`string`||!Number.isInteger(e.sourceStart)||e.sourceStart<0||!Number.isInteger(e.sourceEnd)||e.sourceEnd<e.sourceStart||!Number.isFinite(e.speed)||e.speed<.1||e.speed>4)&&t(),{id:e.id,sourceStart:e.sourceStart,sourceEnd:e.sourceEnd,speed:e.speed}))),{version:1,frames:e.frames,fps:e.fps,segments:r,edits:n}}function Jy(e,t,n){let r=e.trailEdits;return{...t,trailEdits:{version:1,frames:e.frames,fps:e.fps,segments:r?.segments??e.editSegments?.map(e=>({...e}))??null,edits:[...r?.edits??[],{...n,clipDelta:{...n.clipDelta}}]}}}function Yy(e,t){let n=qy(t);if(!n)return e;if(n.segments?.some(t=>t.sourceEnd>=e.frames))throw RangeError(`Motion trail source segment exceeds the take`);let r=n.segments?fy(e,n.segments):e;if(r.frames!==n.frames||r.fps!==n.fps)throw RangeError(`Motion trail recipe does not match the take clock`);for(let e of n.edits)r=Xy(r,e);return r}function Xy(e,{track:t=`hips`,grabFrame:n,radiusFrames:r,clipDelta:i}){if(!e?.posedJoints||!e?.rootPos||!(e.frames>0))return e;let{startFrame:a,endFrame:o}=Dy(e.frames,n,r),s=e.rootPos.slice(),c=e.posedJoints.slice(),l=gy[t]?.map(hy);if(l||t===`head`){let u=e.rotMats?e.rotMats.slice():null,d=hy(`Neck`),f=hy(`Head`),p=zy(l?l[2]:f).filter(e=>!l||e!==l[2]),m=l?Vy(e,l,a,o,n,r):null;for(let e=a;e<o;e+=1){let t=Ey(e-n,r);if(t<=0)continue;let a={...By(c,u,e),rotMats:u},o=[i.x*t,i.y*t,i.z*t];l?Gy(a,l,[l[2],...p],o,m):Ky(a,d,f,p,o)}let h=u?{...e,rootPos:s,posedJoints:c,rotMats:u}:{...e,rootPos:s,posedJoints:c};return l&&u&&(h.trailRetarget={base:e.trailRetarget?.base??e,chains:[...new Set([...e.trailRetarget?.chains??[],t])]}),Jy(e,h,{track:t,grabFrame:n,radiusFrames:r,clipDelta:i})}for(let e=a;e<o;e+=1){let t=Ey(e-n,r);if(t<=0)continue;let a=i.x*t,o=i.y*t,l=i.z*t;s[e*3]+=a,s[e*3+1]+=o,s[e*3+2]+=l;for(let t=0;t<my;t+=1){let n=(e*my+t)*3;c[n]+=a,c[n+1]+=o,c[n+2]+=l}}return Jy(e,{...e,rootPos:s,posedJoints:c},{track:t,grabFrame:n,radiusFrames:r,clipDelta:i})}var Zy=1.8,Qy=1.3,$y=Object.freeze({super16:Object.freeze({id:`super16`,label:`Super 16`,widthMm:12.52,heightMm:7.41}),super35:Object.freeze({id:`super35`,label:`Super 35`,widthMm:24.89,heightMm:18.66}),fullFrame:Object.freeze({id:`fullFrame`,label:`Full Frame`,widthMm:36,heightMm:24}),"65mm":Object.freeze({id:`65mm`,label:`65mm`,widthMm:52.63,heightMm:23.01})}),eb=`fullFrame`,tb=16/9,nb=Object.freeze({"16:9":16/9,"2.39:1":2.39,"9:16":9/16,"1:1":1,"4:3":4/3,"12:7":12/7,"fal 480P":832/480});function rb(e){return nb[e]??1.7777777777777777}function ib(e=eb,t=tb){let n=$y[e]??$y.fullFrame,r=Number.isFinite(t)&&t>0?t:tb;return Math.min(n.heightMm,n.widthMm/r)}function ab(e,t=eb,n=tb){return ib(t,n)/(2*Math.tan(e/2))}function ob(e,t=eb,n=tb){return 2*Math.atan(ib(t,n)/(2*e))}var sb=[14,18,24,28,35,50,85,100,135];function cb(e,t=eb,n=tb){let r=ab(e,t,n);return sb.reduce((e,t)=>Math.abs(t-r)<Math.abs(e-r)?t:e)}var lb=[[2.8,`extreme close-up`,`ultra-realistic skin texture with visible pores and micro-detail, tack-sharp eyes, shallow depth of field`],[1.6,`close-up`,`ultra-realistic skin texture and fine facial detail, soft background blur, shallow depth of field`],[1.15,`medium close-up`,`natural skin and fabric texture, clear facial detail, shallow depth of field`],[.8,`medium shot`,`balanced detail on the subject and the surrounding space, moderate depth of field`],[.52,`medium-wide shot`,`the full figure with the environment clearly visible, deep focus`],[.3,`wide shot`,`full body in a richly detailed environment, deep focus`],[0,`extreme wide shot`,`a small figure within a vast, highly detailed environment, epic sense of scale, deep focus`]],ub=[[2.5,`overhead`,`a directly overhead bird's-eye view looking down at the subject`],[1.8,`high angle`,`a high angle looking down at the subject`],[1.5,`eye level`,`eye level`],[1.25,`chest level`,`chest level`],[.95,`hip level`,`a low hip-level angle`],[.45,`knee level`,`a low knee-level angle looking up at the subject`],[-1/0,`ground level`,`a dramatic ground-level angle looking up at the subject`]],db=(e,t)=>e.find(([e])=>t>=e)??e[e.length-1];function fb(e,t,n,r=Zy,i={}){let a=i.sensorId??`fullFrame`,o=i.aspectRatio??1.7777777777777777,s=e.x-t.x,c=e.z-t.z,l=e.y-Qy,u=Math.hypot(s,c),d=Math.max(Math.hypot(u,l),1e-6),f=r/(2*d*Math.tan(n/2)),[,p,m]=db(lb,f),[,h,g]=db(ub,e.y),_=Math.atan2(e.y-r*.94,Math.max(u,1e-6))*180/Math.PI,v=t.rot*Math.PI/180,y={x:Math.sin(v),z:Math.cos(v)},b={x:s/Math.max(u,1e-6),z:c/Math.max(u,1e-6)},x=y.x*b.x+y.z*b.z,S=y.x*b.z-y.z*b.x>=0?`right`:`left`,C=S===`right`?`R`:`L`,w,T;return x>.85?(w=`front`,T=`seen from the front, the face toward the camera`):x<-.85?(w=`back`,T=`seen from directly behind, the back of the head toward the camera`):x>.34?(w=`front ¾ ${C}`,T=`a three-quarter front view from the ${S}`):x<-.34?(w=`rear ¾ ${C}`,T=`a three-quarter rear view from the ${S}`):(w=`${S} profile`,T=`a ${S}-side profile view`),{sizeLabel:p,sizeContext:m,levelLabel:h,levelPhrase:g,viewShort:w,viewPhrase:T,focalMm:cb(n,a,o),exactFocalMm:ab(n,a,o),sensorId:$y[a]?.id??`fullFrame`,usedSensorHeightMm:ib(a,o),distance:d,screenFraction:f,elevationDeg:_}}function pb(e){return[e.sizeLabel,e.viewShort,e.levelLabel,`${e.focalMm}mm`].map(e=>e.toUpperCase()).join(` · `)}var mb=[{id:`nano_banana_pro`,label:`Nano Banana Pro`},{id:`nano_banana_2`,label:`Nano Banana 2`},{id:`gpt_image_2`,label:`GPT Image 2`},{id:`seedream_5`,label:`Seedream 5.0`},{id:`flux_2`,label:`Flux 2`,numericLens:!0,flavor:`fine film grain, high micro-detail`}],hb=`Custom…`,gb=[`Static / locked-off`,`Push-in (dolly in)`,`Pull-out (dolly out)`,`Pan left`,`Pan right`,`Tilt up`,`Tilt down`,`Tracking / follow`,`Orbit / arc`,`Crane up`,`Crane down`,`Handheld`,`Crash zoom in`,`Dolly-zoom (vertigo)`,`Whip pan`,`Aerial / drone`,hb];function _b({mode:e=`image`,model:t,shot:n,subject:r,subject2:i=null,posePhrase:a=``,pose2Phrase:o=``,environment:s,style:c,cameraMove:l=gb[0],customMove:u=``,hasCharSheet:d=!1,hasEnvSheet:f=!1}){let p=t?.numericLens?`${n.focalMm}mm lens at f/2.2`:`${n.focalMm}mm lens`,m=e===`video`?`Cinematic ${n.sizeLabel} at ${p}, ${n.levelPhrase}, ${n.viewPhrase}.`:`Photorealistic cinematic film still, ${n.sizeLabel} at ${p}, ${n.levelPhrase}, ${n.viewPhrase}.`,h=(e,t)=>t?`${e}, ${t}`:e,g;g=d?i?`Both subjects are the characters from the attached character sheet. Each one exactly matches their own body pose and placement shown in the blocking frame.`:`The subject is the character from the attached character sheet, exactly matching the body pose and placement shown in the blocking frame.`:i?`Two subjects. Subject 1: ${h(r,a)}. Subject 2: ${h(i,o)}. Each subject exactly matches their own body pose and placement shown in the blocking frame.`:`Subject: ${h(r,a)}, exactly matching the body pose and placement shown in the blocking frame.`;let _=f?`The setting is the location from the attached environment sheet.`:`Environment: ${s}.`,v=l===`Custom…`?u.trim()||`static, locked-off shot`:l.toLowerCase();return[m,g,_,`${c}, ${n.sizeContext}.`,e===`video`?`Camera move: ${v}.`:null,`Use the attached blocking frame ONLY as a camera and staging guide — it fixes the exact framing, this camera angle, the lens, and the subject placement. Its floor grid is a measuring aid that encodes distance and scale: read the subject's depth and size from it, but do NOT draw the grid itself. Replace the entire setting with the described environment and render real people; do NOT reproduce its grey mannequins, grey box set, measurement grid, or flat lighting.`,t?.flavor??null,e===`video`&&(t?.audio||t?.capabilities?.audio)?`Include natural ambient sound.`:null,`16:9.`].filter(Boolean).join(` `)}var vb=1;function yb(e){return Array.isArray(e)?`[${e.map(yb).join(`,`)}]`:!e||typeof e!=`object`?JSON.stringify(e):`{${Object.keys(e).filter(e=>e!==`id`).sort().map(t=>`${JSON.stringify(t)}:${yb(e[t])}`).join(`,`)}}`}function bb(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}var xb=class extends Error{constructor(e,t){super(`Unknown ${e} ID: ${t}`),this.name=`UnknownStableItemIdError`}};function Sb(e){return`${e}-${Date.now().toString(36)}-${vb++}`}function Cb(e){return typeof e==`string`&&e.trim()!==``}function wb(e,t,n=new Set){let r=n,i=new Map;return(Array.isArray(e)?e:[]).map(e=>{let n=e&&typeof e==`object`&&!Array.isArray(e)?e:{},a=Cb(n.id)?n.id:null;if(a&&!r.has(a))return r.add(a),{...n,id:a};let o=`${t}-${bb(yb(n))}`,s=i.get(o)??0;i.set(o,s+1);let c=s===0?o:`${o}-${s+1}`;for(;r.has(c);){let e=i.get(o)??0;i.set(o,e+1),c=`${o}-${e+1}`}return r.add(c),{...n,id:c}})}function Tb(e,t,n){let r=Array.isArray(e)?e.find(e=>e.id===t):void 0;if(!r)throw new xb(n,t);return r}function Eb(e,t,n,r){return Tb(e,t,r),e.map(e=>e.id===t?n(e):e)}function Db(e,t,n){return Tb(e,t,n),e.filter(e=>e.id!==t)}var Ob=Object.freeze({minScale:.1,maxScale:10,maxOffset:100}),kb=(e,t)=>{let n=Number(e);return Number.isFinite(n)?n:t};function Ab(e){let t=((e+180)%360+360)%360-180;return Object.is(t,-0)?0:t}function jb(e,t=Ob){let n=e&&typeof e==`object`&&!Array.isArray(e)?e:{},r=Math.max(2**-52,kb(t?.minScale,Ob.minScale)),i=Math.max(r,kb(t?.maxScale,Ob.maxScale)),a=Math.max(0,kb(t?.maxOffset,Ob.maxOffset)),o=kb(n.scale,1),s=kb(n.yawDeg??n.yaw,0),c=e=>Math.max(-a,Math.min(a,kb(e,0)));return{scale:Math.max(r,Math.min(i,o>0?o:1)),yawDeg:Ab(s),offsetX:c(n.offsetX??n.offset_x),offsetY:c(n.offsetY??n.offset_y),offsetZ:c(n.offsetZ??n.offset_z)}}function Mb(e){return e==null?e:typeof e.slice==`function`?e.slice():Array.from(e)}function Nb(e,t){return e!=null&&typeof e.length==`number`&&e.length>=t}function Pb(e,t=e?.sceneCalibration,n={}){let r={status:`not-needed`,applied:!1,changedFrames:0,maxDisplacement:0,maxRootDisplacement:0,maxJointDisplacement:0,calibration:jb(null,n.limits)};if(!e||typeof e!=`object`)return{motion:e,diagnostics:{...r,status:`invalid-motion`}};let i=jb(t,n.limits),a=Number(e.frames),o=Number.isInteger(a)&&a>=0&&Nb(e.rootPos,a*3),s=Number.isInteger(a)&&a>=0&&Nb(e.posedJoints,0)&&e.posedJoints.length%(a*3||1)==0;if(!o&&!s)return{motion:e,diagnostics:{...r,status:`invalid-motion`,calibration:i}};if(i.scale===1&&i.yawDeg===0&&i.offsetX===0&&i.offsetY===0&&i.offsetZ===0)return{motion:e,diagnostics:{...r,calibration:i}};let c=i.yawDeg*Math.PI/180,l=Math.cos(c),u=Math.sin(c),d=(e,t,n)=>{let r=i.scale*e,a=i.scale*t,o=i.scale*n;return[l*r+u*o+i.offsetX,a+i.offsetY,-u*r+l*o+i.offsetZ]},f=o?Mb(e.rootPos):e.rootPos,p=s?Mb(e.posedJoints):e.posedJoints,m=0,h=0,g=0,_=(e,t)=>[...e,...t].every(Number.isFinite)?Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2]):0;for(let t=0;t<a;t+=1){let n=!1;if(o){let r=t*3,i=[e.rootPos[r],e.rootPos[r+1],e.rootPos[r+2]],a=d(...i);f[r]=a[0],f[r+1]=a[1],f[r+2]=a[2],m=Math.max(m,_(i,a)),n||=_(i,a)>1e-9}if(s){let r=e.posedJoints.length/(a*3);for(let i=0;i<r;i+=1){let a=(t*r+i)*3,o=[e.posedJoints[a],e.posedJoints[a+1],e.posedJoints[a+2]],s=d(...o);p[a]=s[0],p[a+1]=s[1],p[a+2]=s[2],h=Math.max(h,_(o,s)),n||=_(o,s)>1e-9}}n&&(g+=1)}let v={status:`calibrated`,applied:!0,changedFrames:g,maxDisplacement:Math.max(m,h),maxRootDisplacement:m,maxJointDisplacement:h,calibration:i};return{motion:{...e,rootPos:f,posedJoints:p},diagnostics:v}}var Fb=i(`character.position`);i(`character.rot`);var Ib=i(`character.scale`),Lb=Object.fromEntries([`x`,`y`,`z`,`intensity`,`warmth`].map(e=>[e,i(`stage.keyLight.${e}`)])),Rb=`cozyclay.scenes.v4`,zb=`cozyclay.scenes.v4.quarantine`,Bb=`cozyclay.scenes.v3`,Vb=`cozyclay.scenes.v2`,Hb=`cozyclay.scenes.v1`,Ub=`cozyclay.scene.v1`,Wb=Object.freeze([Bb,Vb,Hb]),Gb=e=>Math.round(e*24/20),Kb=Object.freeze([`y-bot-tpose`,`x-bot-tpose`]),qb=`y-bot-tpose`,Jb=`a young woman in a tan coat`,Yb=`a man in a dark coat`,Xb=Object.freeze({characters:Object.freeze([Object.freeze({id:`char-a`,model:qb,x:0,z:0,rot:0,hidden:!1,pose:null,subject:Jb})]),hasCharSheet:!1,environmentImage:null,environment:`a sunlit modern living room`,style:`moody cinematic lighting, 35mm film look`,hasEnvSheet:!1,shotAspect:`16:9`,cameraPresetId:null,sensorId:eb,keyLight:Object.freeze({x:6,y:9,z:4,intensity:1.12,warmth:.5})});function Zb(e){let t=$b(e)?e:{},n=Xb.keyLight,r=(e,t,n)=>typeof e==`number`&&Number.isFinite(e)?Math.max(n.min,Math.min(n.max,e)):t;return{x:r(t.x,n.x,Lb.x),y:r(t.y,n.y,Lb.y),z:r(t.z,n.z,Lb.z),intensity:r(t.intensity,n.intensity,Lb.intensity),warmth:r(t.warmth,n.warmth,Lb.warmth)}}var Qb=1,$b=e=>!!e&&typeof e==`object`&&!Array.isArray(e);function ex(e,t=new WeakMap){if(e===null||typeof e==`string`||typeof e==`boolean`)return e;if(typeof e==`number`)return Number.isFinite(e)?e:null;if(typeof e!=`object`)return null;if(t.has(e))return t.get(e);if(Array.isArray(e)){let n=[];t.set(e,n);for(let r of e)n.push(ex(r,t));return n}let n={};t.set(e,n);for(let[r,i]of Object.entries(e))Object.defineProperty(n,r,{value:ex(i,t),enumerable:!0,writable:!0,configurable:!0});return n}var tx=(e,t)=>Number.isFinite(e)?e:t;function nx(e){return typeof e==`string`&&e.startsWith(`data:image/`)?e:null}Ib.min,Ib.max;var rx=e=>Number.isFinite(e)&&e>0?Math.max(Ib.min,Math.min(Ib.max,e)):1;function ix(e,t,n){let r=tx(e?.rot,0)*Math.PI/180,i=tx(t,0),a=tx(n,0);return{x:tx(e?.x,0)+i*Math.cos(r)+a*Math.sin(r),z:tx(e?.z,0)-i*Math.sin(r)+a*Math.cos(r)}}function ax(e=null,t=0){let n=$b(e)?e:{};return{id:typeof n.id==`string`&&n.id?n.id:`char-${t+1}`,model:Kb.includes(n.model)?n.model:qb,x:Math.max(Fb.min.x,Math.min(Fb.max.x,tx(n.x,0))),y:Math.max(Fb.min.y,Math.min(Fb.max.y,tx(n.y,0))),z:Math.max(Fb.min.z,Math.min(Fb.max.z,tx(n.z,0))),rot:hg(tx(n.rot,0)),hidden:n.hidden===!0,tint:typeof n.tint==`string`&&/^#[0-9a-fA-F]{6}$/.test(n.tint)?n.tint:null,pose:$b(n.pose)?ex(n.pose):null,identityImage:nx(n.identityImage),scale:rx(n.scale),subject:typeof n.subject==`string`?n.subject:t===0?Jb:Yb,layer:cx(n.layer),motionRef:sx(n.motionRef)}}var ox=/^[0-9a-f]{64}$/i;function sx(e){if(!$b(e))return null;let t=typeof e.motionId==`string`&&ox.test(e.motionId)?e.motionId.toLowerCase():null,n=typeof e.url==`string`&&e.url?e.url:null;if(!t&&!n)return null;let r={};return t&&(r.motionId=t),n&&(r.url=n),Object.assign(r,{prompt:typeof e.prompt==`string`?e.prompt:``,rotationDeg:Number.isFinite(e.rotationDeg)?e.rotationDeg:0,anchorX:Number.isFinite(e.anchorX)?e.anchorX:0,anchorZ:Number.isFinite(e.anchorZ)?e.anchorZ:0}),$b(e.calibration)&&(r.calibration=jb(e.calibration)),e.trailEdits!=null&&(r.trailEdits=qy(e.trailEdits)),typeof e.studioTakeId==`string`&&e.studioTakeId&&(r.studioTakeId=e.studioTakeId),r}function cx(e){let t=$b(e)?e:{};return{waypoints:wb(ex(t.waypoints),`waypoint`),promptClips:wb(ex(t.promptClips),`prompt-clip`)}}function lx(e){let t=$b(e)?e:{},n=new Set;return{...t,characters:Array.isArray(t.characters)?t.characters.map(e=>({...e,layer:{waypoints:wb(ex(e.layer?.waypoints),`waypoint`,n),promptClips:wb(ex(e.layer?.promptClips),`prompt-clip`,n)}})):t.characters}}function ux(){return{waypoints:[],promptClips:[]}}function dx(e){if(!$b(e))return e;let t={...ex(e)};if(Array.isArray(e.waypoints)){let n=new Map;for(let t of e.waypoints){if(!$b(t)||!Number.isFinite(t.frame))continue;let e=Math.max(0,Gb(Math.round(t.frame)));n.set(e,{...ex(t),frame:e})}t.waypoints=[...n.values()].sort((e,t)=>e.frame-t.frame)}if(Array.isArray(e.promptClips)){let n=e.promptClips.filter(e=>$b(e)&&Number.isFinite(e.startFrame)&&Number.isFinite(e.endFrame)).sort((e,t)=>e.startFrame-t.startFrame),r=[],i=0;for(let e of n){let t=Math.max(i,Gb(Math.round(e.startFrame))),n=Math.max(t,Gb(Math.round(e.endFrame)));r.push({...ex(e),startFrame:t,endFrame:n}),i=n}t.promptClips=r}return t}function fx(e){return!$b(e)||!Array.isArray(e.characters)?e:{...e,characters:e.characters.map(e=>$b(e)&&$b(e.layer)?{...e,layer:dx(e.layer)}:e)}}function px(e){let t=[ax({...$b(e.charA)?e.charA:{},id:`char-a`,pose:e.poseA??null,subject:e.subject??`a young woman in a tan coat`},0)];return e.showB===!0&&t.push(ax({...$b(e.charB)?e.charB:{},id:`char-b`,pose:e.poseB??null,subject:e.subject2??`a man in a dark coat`},1)),t}var mx=new Set([`characters`,`hasCharSheet`,`environmentImage`,`environment`,`style`,`hasEnvSheet`,`shotAspect`,`cameraPresetId`,`sensorId`,`keyLight`,`charA`,`charB`,`showB`,`poseA`,`poseB`,`subject`,`subject2`]);function hx(e=null){let t=$b(e)?e:{},n=Array.isArray(t.characters)&&t.characters.length?t.characters.map((e,t)=>ax(e,t)):px(t),r={};for(let[e,n]of Object.entries(t))mx.has(e)||(r[e]=ex(n));return{...r,characters:n,hasCharSheet:t.hasCharSheet===!0,environmentImage:nx(t.environmentImage),environment:typeof t.environment==`string`?t.environment:Xb.environment,style:typeof t.style==`string`?t.style:Xb.style,hasEnvSheet:t.hasEnvSheet===!0,shotAspect:[`16:9`,`2.39:1`,`9:16`,`1:1`,`4:3`,`12:7`,`fal 480P`].includes(t.shotAspect)?t.shotAspect:Xb.shotAspect,cameraPresetId:typeof t.cameraPresetId==`string`&&t.cameraPresetId?t.cameraPresetId:Xb.cameraPresetId,sensorId:Object.hasOwn($y,t.sensorId??t.sensorFormat)?t.sensorId??t.sensorFormat:Xb.sensorId,keyLight:Zb(t.keyLight)}}function gx(e){let t=new Set(e.map(e=>e?.id)),n;do n=`scene-${Date.now().toString(36)}-${Qb++}`;while(t.has(n));return n}function _x(e,t){let n=e=>typeof e==`string`?e.normalize(`NFKC`).toLowerCase():``,r=new Set(t.map(e=>n(e?.name))),i=e=>r.has(n(e)),a=typeof e==`string`&&e.trim()?e.trim():`SCENE 01`;if(!i(a))return a;let o=a.match(/^(.*?)(\d+)$/);if(o){let[,e,t]=o;for(let n=Number(t)+1;;n+=1){let r=`${e}${String(n).padStart(t.length,`0`)}`;if(!i(r))return r}}for(let e=2;;e+=1){let t=`${a} ${e}`;if(!i(t))return t}}function vx(e=`SCENE 01`,t=[]){return{id:gx(t),name:_x(e,t),objects:[],shotDocument:null,stage:hx()}}function yx(e,t=`SCENE 01`){let n=Array.isArray(e)?e:[];return[...n,vx(t,n)]}function bx(e,t){if(!Array.isArray(e)||t<0||t>=e.length)return e;let n=e[t],r=vx(n.name,e);return r.objects=ex(n.objects),r.shotDocument=ex(n.shotDocument),r.stage=hx(n.stage),[...e.slice(0,t+1),r,...e.slice(t+1)]}function xx(e,t,n){if(!Array.isArray(e)||t<0||t>=e.length||typeof n!=`string`||!n.trim())return e;let r=_x(n,e.filter((e,n)=>n!==t));return r===e[t].name?e:e.map((e,n)=>n===t?{...e,name:r}:e)}function Sx(e,t){return!Array.isArray(e)||e.length<=1||t<0||t>=e.length?e:e.filter((e,n)=>n!==t)}function Cx(e,t){if(!Array.isArray(e)||!e.length)return-1;let n=e.findIndex(e=>e.id===t);return n<0?0:n}function wx(){let e=vx();return{version:4,activeSceneId:e.id,scenes:[e]}}function Tx(e,t,n,r,i=!1){if(!$b(e)||typeof e.id!=`string`||!e.id||!Array.isArray(e.objects)||t.some(t=>t.id===e.id))return null;let a=lx(hx(ex($b(e.stage)?e.stage:r)));return{id:e.id,name:_x(typeof e.name==`string`?e.name:`SCENE ${String(n).padStart(2,`0`)}`,t),objects:e.objects.filter($b).map(e=>ex(e)),shotDocument:ex(e.shotDocument??null),stage:i?fx(a):a}}function Ex(e,t=Xb,n=!1){let r=[],i=0;for(let a of e.scenes){let e=Tx(a,r,r.length+1,t,n);e?r.push(e):i+=1}return r.length||r.push(vx()),{document:{version:4,activeSceneId:r[Cx(r,e.activeSceneId)].id,scenes:r},dropped:i}}function Dx(e){try{return JSON.parse(e)}catch{return null}}function Ox(e,t=null){if(e==null||e===``){if(t!=null&&t!==``){let e=Dx(t);if(!$b(e)||e.version!==1||!Array.isArray(e.objects))return{status:`corrupt`,document:wx(),dropped:0,quarantineRaw:t};let n=wx();return n.scenes[0].objects=e.objects.filter($b).map(e=>ex(e)),{status:`migrated`,document:n,dropped:e.objects.length-n.scenes[0].objects.length}}return{status:`absent`,document:wx(),dropped:0}}let n=Dx(e);if(!$b(n)||!Number.isInteger(n.version)||n.version<1)return{status:`corrupt`,document:wx(),dropped:0,quarantineRaw:e};if(n.version>4)return{status:`future`,document:null,dropped:0};if(!Array.isArray(n.scenes))return{status:`corrupt`,document:wx(),dropped:0,quarantineRaw:e};let r=n.version<4,i=n.version<4,a=Ex(n,hx(n.stage),i);return{status:r?`migrated`:`valid`,...a}}function kx(e){return JSON.stringify({version:4,activeSceneId:e.activeSceneId,scenes:e.scenes})}function Ax(e){let t=e.getItem(Rb);for(let n of Wb){if(t)break;t=e.getItem(n)}let n=t?null:e.getItem(Ub),r=Ox(t,n);return r.status===`corrupt`&&r.quarantineRaw!==void 0&&e.setItem(zb,r.quarantineRaw),r.status===`migrated`&&e.setItem(Rb,kx(r.document)),r}var Q=e(g(),1),jx=`cozyclay.locale`;function Mx(){try{let e=localStorage.getItem(jx);return e===`ko`||e===`en`?e:null}catch{return null}}var Nx=Mx()??`en`,Px=Nx===`ko`,Fx=Mx()!==null;function Ix(e,t){return Px?t:e}function Lx(e){if(e===`ko`||e===`en`){try{localStorage.setItem(jx,e)}catch{}window.location.reload()}}var Rx=`.cclayproject`,zx=`cozyclay.workflow.v1`,Bx=`cozyclay.project-handle.v1`,Vx=`kv`,Hx=`lastProjectHandle`,Ux=201326592,Wx=268435456,Gx=/^[0-9a-f]{64}$/i;function Kx(e){if(!e||typeof e!=`object`)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function qx(e,t=0){if(e===null||typeof e==`string`||typeof e==`boolean`)return e;if(typeof e==`number`)return Number.isFinite(e)?e:null;if(t>32)return null;if(Array.isArray(e))return e.map(e=>qx(e,t+1));if(!Kx(e))return null;let n={};for(let[r,i]of Object.entries(e))r!==`__proto__`&&r!==`constructor`&&r!==`prototype`&&i!==void 0&&typeof i!=`function`&&typeof i!=`symbol`&&(n[r]=qx(i,t+1));return n}function Jx(e){return{x:Number.isFinite(e?.x)?e.x:0,y:Number.isFinite(e?.y)?e.y:0}}function Yx(){return{version:1,nodes:[],edges:[]}}function Xx(e){if(!Kx(e)||e.version!==void 0&&e.version!==1)return Yx();let t=[],n=new Set;for(let r of Array.isArray(e.nodes)?e.nodes:[]){if(!Kx(r)||typeof r.id!=`string`||!r.id.trim()||n.has(r.id))continue;let e=qx(r.data);t.push({id:r.id,type:typeof r.type==`string`&&r.type.trim()?r.type:`default`,position:Jx(r.position),data:Kx(e)?e:{}}),n.add(r.id)}let r=[],i=new Set;for(let t=0;t<(Array.isArray(e.edges)?e.edges.length:0);t+=1){let a=e.edges[t];if(!Kx(a)||typeof a.source!=`string`||typeof a.target!=`string`||!n.has(a.source)||!n.has(a.target))continue;let o=typeof a.id==`string`&&a.id.trim()?a.id:`${a.source}->${a.target}:${t}`;if(i.has(o))continue;let s={id:o,source:a.source,target:a.target};typeof a.sourceHandle==`string`&&a.sourceHandle&&(s.sourceHandle=a.sourceHandle),typeof a.targetHandle==`string`&&a.targetHandle&&(s.targetHandle=a.targetHandle);let c=qx(a.data);Kx(c)&&(s.data=c),r.push(s),i.add(o)}return{version:1,nodes:t,edges:r}}function Zx(e=globalThis.localStorage){try{return Xx(JSON.parse(e?.getItem(`cozyclay.workflow.v1`)||`null`))}catch{return Yx()}}function Qx(e,t=globalThis.localStorage){let n=Xx(e);try{t?.setItem(zx,JSON.stringify(n))}catch{}try{globalThis.dispatchEvent?.(new CustomEvent(`cozyclay:workflow-change`))}catch{}return n}function $x(e){return e instanceof ArrayBuffer?e:ArrayBuffer.isView(e)?e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength):null}function eS(e){let t=new Uint8Array(e),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.subarray(e,e+32768));return btoa(n)}function tS(e,t){if(typeof e!=`string`||e.length<4||e.length%4)return{code:`bad-base64`};if(e.length>Math.ceil(t/3)*4)return{code:`too-large`};let n=e.endsWith(`==`)?2:+!!e.endsWith(`=`);for(let t=0;t<e.length-n;t+=1){let n=e.charCodeAt(t);if(!(n>=65&&n<=90||n>=97&&n<=122||n>=48&&n<=57||n===43||n===47))return{code:`bad-base64`}}let r=e.length/4*3-n;return r>t?{code:`too-large`}:{bytes:r}}function nS(e,t){let n=tS(e,t);if(n.code)return n;try{let t=atob(e),n=Uint8Array.from(t,e=>e.charCodeAt(0));return eS(n)===e?{buffer:n.buffer}:{code:`bad-base64`}}catch{return{code:`bad-base64`}}}function rS(e,t,n){let r=Error(`${n} (${e} bytes) exceeds the ${t}-byte limit.`);return r.code=`resources-too-large`,r.bytes=e,r.limit=t,r}function iS(e){let t=$x(e?.bytes),n=em({...e,bytes:t});return!n||n.bytes.byteLength>33554432?null:{record:{...n,bytes:eS(n.bytes)},bytes:n.bytes.byteLength}}function aS(e){let t=new Set,n=e=>{if(Array.isArray(e)){for(let t of e)n(t);return}if(Kx(e)){Kp(e.assetRef)&&t.add(e.assetRef);for(let t of Object.values(e))n(t)}};return n(e),t}function oS(e){return{...Number.isInteger(e.frames)&&e.frames>=0?{frames:e.frames}:{},...Number.isFinite(e.fps)&&e.fps>0?{fps:e.fps}:{},...typeof e.name==`string`&&e.name.trim()?{name:e.name}:{},...Kx(e.meta)?{meta:qx(e.meta)}:{}}}function sS(e){return typeof e==`string`&&Gx.test(e)?e.toLowerCase():null}function cS(e){if(!e||typeof e!=`object`)return null;let t=sS(e.motionId);if(!t)return null;let n=$x(e.bytes);if(n){if(!n.byteLength)return null;if(n.byteLength>201326592)throw rS(n.byteLength,Ux,`Motion ${t}`);return{motionId:t,bytes:n.byteLength,raw:n,details:oS(e)}}if(e.encoding!==`base64`)return null;let r=tS(e.data,Ux);if(r.code===`too-large`)throw rS(e.data.length/4*3,Ux,`Motion ${t}`);return r.code||e.bytes!==void 0&&e.bytes!==r.bytes?null:{motionId:t,bytes:r.bytes,data:e.data,details:oS(e)}}async function lS(e,t){let n=$x(e?.bytes);if(!n)return!1;try{return(qp(e.id)?await Zp(n,t):await Xp(n,t))===e.id}catch{return!1}}var uS={"bad-id":`its id is not a content address`,duplicate:`the same id appears earlier in the file`,"bad-encoding":`its encoding is not base64`,"bad-base64":`its payload is not valid base64`,"length-mismatch":`its payload does not match the recorded byte length`,"too-large":`its payload exceeds the size limit`,"bad-record":`its metadata is incomplete`};function dS(e,t){let n=[];if(!Array.isArray(e))return n;let r=new Set;for(let i of e){let e=typeof i?.id==`string`?i.id:null;if(!Jp(e)){t(`image`,e,`bad-id`);continue}if(r.has(e)){t(`image`,e,`duplicate`);continue}let a=nS(i.bytes,Rp);if(a.code){t(`image`,e,a.code);continue}let o=em({...i,bytes:a.buffer});if(!o){t(`image`,e,`bad-record`);continue}r.add(e),n.push(o)}return n}function fS(e,t){let n=[];if(!Array.isArray(e))return n;let r=new Set;for(let i of e){let e=sS(i?.motionId);if(!e){t(`motion`,typeof i?.motionId==`string`?i.motionId:null,`bad-id`);continue}if(r.has(e)){t(`motion`,e,`duplicate`);continue}if(i.encoding!==`base64`){t(`motion`,e,`bad-encoding`);continue}let a=tS(i.data,Ux);if(a.code){t(`motion`,e,a.code);continue}if(i.bytes!==a.bytes){t(`motion`,e,`length-mismatch`);continue}r.add(e),n.push({motionId:e,encoding:`base64`,data:i.data,bytes:a.bytes,...oS(i)})}return n}function pS({scenesDocument:e,workspaceLayout:t,customPoses:n,name:r,assets:i,motions:a,savedAt:o,workflow:s}){let c=new Map;for(let e of Array.isArray(i)?i:[]){let t=iS(e);t&&c.set(t.record.id,t)}let l=[],u=0,d=om(e?.scenes);for(let e of aS(s))d.add(e);for(let e of d){let t=c.get(e);t&&(l.push(t.record),u+=t.bytes)}let f=new Map;for(let e of Array.isArray(a)?a:[]){let t=cS(e);!t||f.has(t.motionId)||(f.set(t.motionId,t),u+=t.bytes)}if(u>268435456)throw rS(u,Wx,`Embedded resources`);let p=[...f.values()].map(({motionId:e,bytes:t,raw:n,data:r,details:i})=>({motionId:e,encoding:`base64`,data:r??eS(n),bytes:t,...i}));return{app:`cozyclay`,kind:`project`,version:4,name:typeof r==`string`&&r.trim()?r.trim():`Untitled`,...Number.isFinite(o)&&o>0?{savedAt:o}:{},scenes:e,workspace:t??null,poseLibrary:Array.isArray(n)?n:[],workflow:Xx(s),resources:{assets:l,motions:p}}}function mS(e){let t;try{t=JSON.parse(e)}catch{return{ok:!1,reason:`corrupt`}}if(!t||typeof t!=`object`)return{ok:!1,reason:`corrupt`};if(t.app!==`cozyclay`||t.kind!==`project`)return{ok:!1,reason:`not-a-project`};if(typeof t.version!=`number`)return{ok:!1,reason:`corrupt`};if(t.version>4)return{ok:!1,reason:`future`};let n=t.scenes;if(!n||typeof n!=`object`||n.version>4||!Array.isArray(n.scenes))return{ok:!1,reason:`scenes-invalid`};let r=[],i=[],a=(e,t,n)=>{let a=`Skipped embedded ${e} ${t??`(no id)`}: ${uS[n]}.`;i.push({kind:e,id:t,code:n,message:a}),r.push(a)},o=dS(t.version>=4?t.resources?.assets:t.version>=2?t.assets:void 0,a),s=t.version>=4?fS(t.resources?.motions,a):[],c=Xx(t.workflow);return{ok:!0,warnings:r,problems:i,project:{name:typeof t.name==`string`&&t.name.trim()?t.name.trim():`Untitled`,savedAt:Number.isFinite(t.savedAt)&&t.savedAt>0?t.savedAt:null,scenesDocument:{version:n.version,activeSceneId:n.activeSceneId??null,scenes:n.scenes},workspaceLayout:t.workspace&&typeof t.workspace==`object`?t.workspace:null,customPoses:Array.isArray(t.poseLibrary)?t.poseLibrary.filter(e=>e&&typeof e==`object`&&typeof e.id==`string`&&e.bones&&typeof e.bones==`object`):[],assets:o,motions:s,workflow:c}}}function hS(){return typeof window<`u`&&typeof window.showSaveFilePicker==`function`&&typeof window.showOpenFilePicker==`function`}var gS=[{description:`CozyClay Project`,accept:{"application/json":[Rx,`.json`]}}];async function _S(e){return await window.showSaveFilePicker({suggestedName:`${e||`Untitled`}${Rx}`,types:gS})}async function vS(){let[e]=await window.showOpenFilePicker({types:gS,multiple:!1});return e}async function yS(e,t){let n=await e.createWritable();await n.write(t),await n.close()}async function bS(e){let t=await e.getFile();return{name:t.name.replace(/\.cclayproject$|\.json$/i,``),text:await t.text(),savedAt:t.lastModified}}function xS(e,t){let n=new Blob([e],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${t||`Untitled`}${Rx}`,i.click(),setTimeout(()=>URL.revokeObjectURL(r),1e3)}function SS(){return new Promise(e=>{let t=document.createElement(`input`);t.type=`file`,t.accept=`${Rx},.json,application/json`,t.onchange=async()=>{let n=t.files?.[0];if(!n)return e(null);e({name:n.name.replace(/\.cclayproject$|\.json$/i,``),text:await n.text(),savedAt:n.lastModified})},t.oncancel=()=>e(null),t.click()})}function CS(){return new Promise((e,t)=>{let n=indexedDB.open(Bx,1);n.onupgradeneeded=()=>n.result.createObjectStore(Vx),n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}async function wS(e,t){try{let n=await CS();await new Promise((r,i)=>{let a=n.transaction(Vx,`readwrite`);a.objectStore(Vx).put({handle:e,name:t},Hx),a.oncomplete=r,a.onerror=()=>i(a.error)}),n.close()}catch{}}async function TS(){try{let e=await CS(),t=await new Promise((t,n)=>{let r=e.transaction(Vx,`readonly`).objectStore(Vx).get(Hx);r.onsuccess=()=>t(r.result??null),r.onerror=()=>n(r.error)});return e.close(),t}catch{return null}}async function ES(){try{let e=await CS();await new Promise((t,n)=>{let r=e.transaction(Vx,`readwrite`);r.objectStore(Vx).delete(Hx),r.oncomplete=t,r.onerror=()=>n(r.error)}),e.close()}catch{}}var DS=`recentProjects`,OS=`projectsDirectory`,kS=8,AS=`cozyclay.project-session.v1`;function jS(e=globalThis.localStorage){try{let t=JSON.parse(e?.getItem(`cozyclay.project-session.v1`)||`null`);if(!t||typeof t!=`object`)return null;let n=typeof t.name==`string`?t.name.trim():``;return n?{name:n,updatedAt:Number.isFinite(t.updatedAt)?t.updatedAt:0}:null}catch{return null}}function MS(e,t=globalThis.localStorage){let n=typeof e==`string`?e.trim():``;if(!n)return!1;try{return t?.setItem(AS,JSON.stringify({name:n,updatedAt:Date.now()})),!0}catch{return!1}}async function NS(e,t){try{let n=await CS();await new Promise((r,i)=>{let a=n.transaction(Vx,`readwrite`);a.objectStore(Vx).put(t,e),a.oncomplete=r,a.onerror=()=>i(a.error)}),n.close()}catch{}}async function PS(e){try{let t=await CS(),n=await new Promise((n,r)=>{let i=t.transaction(Vx,`readonly`).objectStore(Vx).get(e);i.onsuccess=()=>n(i.result??null),i.onerror=()=>r(i.error)});return t.close(),n}catch{return null}}async function FS(e,t){let n=await PS(DS)??[];await NS(DS,[{handle:e,name:t,openedAt:Date.now()},...n.filter(e=>e.name!==t)].slice(0,kS)),await wS(e,t)}async function IS(){return await PS(DS)??[]}async function LS(e){await NS(DS,(await PS(DS)??[]).filter(t=>t.name!==e))}function RS(){return typeof window<`u`&&typeof window.showDirectoryPicker==`function`}async function zS(){return window.showDirectoryPicker({mode:`readwrite`})}async function BS(e){await NS(OS,{handle:e})}async function VS(){return(await PS(OS))?.handle??null}async function HS(e){let t=[];try{for await(let[n,r]of e.entries()){if(r.kind!==`file`||!n.endsWith(`.cclayproject`))continue;let e=await r.getFile();t.push({name:n.slice(0,-13),handle:r,lastModified:e.lastModified})}}catch{return[]}return t.sort((e,t)=>t.lastModified-e.lastModified)}async function US(e){try{return await e.queryPermission({mode:`readwrite`})}catch{return`denied`}}async function WS(e){try{return await e.queryPermission({mode:`readwrite`})===`granted`?`granted`:await e.requestPermission({mode:`readwrite`})}catch{return`denied`}}Object.freeze([`idle`,`fetching`,`probing`,`ready`,`error`]);function GS(e,t=!1){if(!e)return``;if(e.status===`disabled`)return t?`낙하 보정 꺼짐`:`Descent recovery off`;if(e.status===`corrected`){let n=e.rejected?.length??0;return t?`낙하 보정 ${e.changedFrames}프레임 적용${n?` · ${n}구간 미해결`:``}`:`Descent recovery: ${e.changedFrames} frames corrected${n?` · ${n} unresolved spans`:``}`}let n=e.rejected?.[0]?.reason??e.reason??`unknown`;return`${t?`낙하 보정 미적용`:`Descent recovery not applied`}: ${{"world-endpoint-unsettled":[`3D endpoint never settles`,`3D 끝점이 안정되지 않음`],"no-confident-delayed-descent":[`no confident delayed descent detected`,`확실한 낙하 지연이 검출되지 않음`],"moving-camera-not-supported":[`moving-camera recovery unsupported`,`이동 카메라 보정 미지원`],"uncertain-keypoints":[`body tracking uncertain`,`관절 추적 불확실`],"uncertain-depth":[`depth change too large`,`깊이 변화가 큼`],"moving-landing":[`landing does not stay still`,`착지 후 이동이 계속됨`],"no-observed-landing":[`landing not observed`,`착지를 확인할 수 없음`],"landing-observation-too-short":[`not enough footage after landing`,`착지 이후 영상이 너무 짧음`],"excessive-correction":[`recovery exceeds its safety bound`,`보정량이 안전 범위를 초과함`]}[n]?.[+!!t]??n}`}function KS(e,t=!1){if(!e)return``;if(e.available===!1)return t?`색 세그멘테이션 측정 불가`:`Palette segmentation metrics unavailable`;if(e.detector!==`palette`||!Number.isFinite(e.detectionRate))return``;let n=Math.round(e.detectionRate*100),r=Number.isFinite(e.coverage?.mean)?Math.round(e.coverage.mean*100):null,i=Number.isFinite(e.coverage?.p10)&&Number.isFinite(e.coverage?.p90)?`${Math.round(e.coverage.p10*100)}–${Math.round(e.coverage.p90*100)}%`:null,a=Number.isFinite(e.parts?.mean)?Math.round(e.parts.mean):null,o=Number.isFinite(e.longestGapFrames)?e.longestGapFrames:0,s=Number.isFinite(e.hueErrorDeg?.p95)?Math.round(e.hueErrorDeg.p95):null;return t?`색 세그멘테이션: ${n}% 검출${r===null?``:` · 마스크 ${r}%${i?` (${i})`:``}`}${a===null?``:` · 색 파트 ${a}개`}${o?` · 최대 끊김 ${o}프레임`:``}${s===null?``:` · 색 오차 P95 ${s}°`}`:`Palette segmentation: ${n}% detected${r===null?``:` · ${r}% mask${i?` (${i})`:``}`}${a===null?``:` · ${a} colour parts`}${o?` · longest gap ${o} frames`:``}${s===null?``:` · hue error P95 ${s}°`}`}function qS(e){if(typeof e!=`string`)return{ok:!1,reason:`url-not-string`};let t=e.trim();if(t.length===0)return{ok:!1,reason:`url-empty`};if(t.startsWith(`//`))return{ok:!1,reason:`url-protocol-relative`};if(t.startsWith(`/`))return{ok:!0,url:t};if(/^https?:\/\//i.test(t)){let e;try{e=new URL(t)}catch{return{ok:!1,reason:`url-malformed`}}return YS(e.toString())?{ok:!1,reason:`url-platform-page`}:{ok:!0,url:e.toString()}}return{ok:!1,reason:`url-scheme-unsupported`}}var JS=/(?:^|\.)(?:youtube\.com|youtu\.be|vimeo\.com|tiktok\.com|instagram\.com|facebook\.com|twitter\.com|x\.com|bilibili\.com|naver\.com|kakao\.com)$/i;function YS(e){if(typeof e!=`string`)return!1;try{return JS.test(new URL(e).hostname)}catch{return!1}}async function XS(e,t,{fetchImpl:n,onProgress:r,defaultError:i}={}){let a=n??globalThis.fetch;if(typeof a!=`function`)throw Error(`fetch-unavailable`);let o;try{o=await a(e,t)}catch{throw Error(`bridge-unreachable`)}if(!o.ok){let e=`http-${o.status}`;try{e=(await o.json())?.reason??e}catch{}throw Error(e)}let s=o.body?.getReader?null:await o.text(),c=``,l=null,u=e=>{if(!e.trim())return;let t;try{t=JSON.parse(e)}catch{return}if(t.event===`progress`)r?.({stage:t.stage,ratio:t.ratio});else if(t.event===`error`)throw Error(t.message||i);else t.event===`done`&&(l=t)};if(s!==null)for(let e of s.split(`
|
|
14
|
+
`))u(e);else{let e=o.body.getReader(),t=new TextDecoder;for(;;){let{done:n,value:r}=await e.read();if(n)break;c+=t.decode(r,{stream:!0});let i=c.split(`
|
|
15
|
+
`);c=i.pop()??``;for(let e of i)u(e)}c&&u(c)}return l}async function ZS(e,t={}){let n=await XS(`/ardy/footage`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:e})},{...t,defaultError:`footage-download-failed`});if(!n||typeof n.url!=`string`)throw Error(`bridge-footage-incomplete`);return n}async function QS(e,t={}){let n=await XS(`/ardy/extract`,typeof e?.footage==`string`?{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({footage:e.footage})}:{method:`POST`,headers:{"Content-Type":`application/octet-stream`},body:e},{...t,defaultError:`extract-run-failed`});if(!n||typeof n.motionUrl!=`string`)throw Error(`bridge-extract-incomplete`);return n}async function $S(e,t=globalThis.fetch){if(typeof e!=`string`||!e)throw Error(`Generated video has no fetchable output.`);if(typeof t!=`function`)throw Error(`video-download-unavailable`);let n=await t(e);if(!n.ok)throw Error(`Generated video download failed (${n.status}).`);return n.blob()}function eC(e){if(typeof e!=`string`||e.length===0)return``;let t=e.split(/[?#]/)[0];return t.split(`/`).filter(Boolean).pop()??t}function tC(e,t){return!Number.isFinite(t)||t<=0||!Number.isFinite(e)||e<0?null:Math.min(1,e/t)}function nC(e,t){return!(e>0)||!(t>0)?1:Math.max(1,Math.floor(e*t+1e-6)+1)}function rC(e,t=30){if(!Array.isArray(e)||e.length<3)return{fps:t,measured:!1};let n=[];for(let t=1;t<e.length;t+=1){let r=e[t]-e[t-1];r>1e-4&&n.push(r)}if(n.length===0)return{fps:t,measured:!1};n.sort((e,t)=>e-t);let r=n[Math.floor(n.length/2)];return r>0?{fps:Math.round(1/r),measured:!0}:{fps:t,measured:!1}}function iC(e){return!Number.isFinite(e)||e<0?``:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(0)} KB`:`${(e/1048576).toFixed(1)} MB`}function aC(e){if(!e)return``;let t=[`${e.width}×${e.height}`,`${e.durationS.toFixed(2)}s`,`${e.fps} fps${e.fpsMeasured?``:`?`}`,`${e.frames} frames`];return Number.isFinite(e.bytes)&&e.bytes>0&&t.push(iC(e.bytes)),t.join(` · `)}async function oC(e,{fetchImpl:t,onProgress:n,signal:r}={}){let i=t??globalThis.fetch;if(typeof i!=`function`)throw Error(`fetch-unavailable`);let a;try{a=await i(e,{signal:r})}catch(e){throw e?.name===`AbortError`?e:Error(`fetch-failed`)}if(!a.ok)throw Error(`http-${a.status}`);let o=Number(a.headers?.get?.(`content-length`)),s=Number.isFinite(o)&&o>0?o:null,c=a.headers?.get?.(`content-type`)??``;if(/^(?:text\/html|application\/json|text\/plain)\b/i.test(c))throw Error(`not-a-video`);if(!a.body?.getReader){let e=await a.blob();return n?.({received:e.size,total:e.size,ratio:1}),{blob:e,bytes:e.size,type:c}}let l=a.body.getReader(),u=[],d=0;for(;;){let{done:e,value:t}=await l.read();if(e)break;u.push(t),d+=t.byteLength??t.length??0,n?.({received:d,total:s,ratio:tC(d,s)})}let f=new Blob(u,{type:c||`video/mp4`});return n?.({received:d,total:s??d,ratio:1}),{blob:f,bytes:d,type:c}}async function sC(e,{createVideo:t,timeoutMs:n=15e3,fallbackFps:r=30,knownFps:i=null}={}){let a=t();a.src=e,a.muted=!0,a.playsInline=!0,a.preload=`auto`,await new Promise((e,t)=>{let r=!1,i=setTimeout(()=>{r||(r=!0,t(Error(`probe-timeout`)))},n),o=n=>{r||(r=!0,clearTimeout(i),n?t(n):e())};a.addEventListener(`loadedmetadata`,()=>o(null),{once:!0}),a.addEventListener(`error`,()=>o(Error(`decode-failed`)),{once:!0}),a.load?.()});let o=Number(a.duration),s=Number(a.videoWidth),c=Number(a.videoHeight);if(!(o>0))throw Error(`duration-unreadable`);if(!(s>0)||!(c>0))throw Error(`dimensions-unreadable`);let l=Number.isFinite(i)&&i>0,u=l?[]:await cC(a),{fps:d,measured:f}=l?{fps:i,measured:!0}:rC(u,r);return{durationS:o,width:s,height:c,fps:d,fpsMeasured:f,frames:nC(o,d)}}async function cC(e,t=12){if(typeof e.requestVideoFrameCallback!=`function`)return[];let n=[];try{await e.play?.()}catch{return[]}return await new Promise(r=>{let i=Date.now()+2e3,a=(o,s)=>{if(n.push(s?.mediaTime??0),n.length>=t||Date.now()>i){r();return}e.requestVideoFrameCallback(a)};e.requestVideoFrameCallback(a)}),e.pause?.(),e.currentTime=0,n}var $=S_();function lC(e){return e?typeof e.id==`string`&&qp(e.id)?!0:Vp(e.type):!1}function uC({getRecord:e=async e=>mm(await fC(),e),putRecord:t=async e=>pm(await fC(),e),createBitmap:n=(...e)=>createImageBitmap(...e),makeTexture:r=e=>new or(e)}={}){let i=new Map;function a(e){let t=i.get(e);return t||(t={texture:null,record:null,promise:null,listeners:new Set,generation:0,evicted:!1},i.set(e,t)),t}function o(e){for(let t of e.listeners)t(e.texture)}function s(e){e?.image?.close?.(),e?.dispose?.()}async function c(e){if(lC(e))return null;let t=r(await n(new Blob([e.bytes],{type:e.type}),{imageOrientation:`flipY`}));return t.flipY=!1,t.colorSpace=Ot,t.generateMipmaps=!0,t.minFilter=ae,t.magFilter=A,t.anisotropy=4,t.needsUpdate=!0,t.userData.assetId=e.id,t}function l(t){if(typeof t!=`string`||!t||qp(t))return Promise.resolve(null);let n=a(t);if(n.evicted)return Promise.resolve(null);if(n.texture)return Promise.resolve(n.texture);if(!n.promise){let r=n.generation;n.promise=(async()=>{let i=n.record??await e(t);if(!i||n.evicted||n.generation!==r||lC(i))return null;n.record=i;let a=await c(i);return n.evicted||n.generation!==r?(s(a),null):(n.texture=a,o(n),a)})().catch(e=>(console.warn(`[cozyclay] could not load image asset ${t}`,e),n.failed=!0,null)).finally(()=>{n.generation===r&&(n.promise=null)})}return n.promise}async function u(t){if(typeof t!=`string`||!t)return null;let n=a(t);return n.evicted?null:(n.record||=await e(t),n.record)}async function d(e){let n=await t(e),r=a(n.id),i=++r.generation;if(r.evicted=!1,s(r.texture),r.texture=null,r.record=n,r.promise=null,lC(n)||qp(n.id))return n;let l=await c(n);return!l||r.generation!==i?(s(l),n):(r.texture=l,o(r),n)}function f(e){let t=i.get(e);t&&(t.generation+=1,t.evicted=!0,s(t.texture),t.texture=null,t.record=null,t.promise=null,o(t))}function p(e,t){if(typeof e!=`string`||!e)return()=>{};let n=a(e);return n.listeners.add(t),n.texture?t(n.texture):l(e),()=>n.listeners.delete(t)}function m(){for(let e of i.values())s(e.texture);i.clear()}return{loadAssetTexture:l,assetRecord:u,rememberAsset:d,evictAssetTexture:f,subscribeToAssetTexture:p,clearAssetTextures:m}}var dC=null;function fC(){return dC||=fm(),dC}var pC=uC();pC.loadAssetTexture;var mC=pC.assetRecord,hC=pC.rememberAsset,gC=pC.evictAssetTexture,_C=pC.subscribeToAssetTexture;pC.clearAssetTextures;var vC=new Set([`aborted`,`capture_failed`,`generation_failed`,`unknown`]),yC=new Set([`aborted`,`auth`,`rate_limited`,`tool_failed`,`upstream`,`unknown`]);function bC(){try{if(!globalThis.crypto?.getRandomValues)return null;let e=new Uint8Array(16);return globalThis.crypto.getRandomValues(e),[...e].map(e=>e.toString(16).padStart(2,`0`)).join(``)}catch{return null}}function xC(e,t,n){try{Promise.resolve(e(t,n)).catch(()=>{})}catch{}}function SC(e){try{return e()}catch{return NaN}}function CC(e,t,n=`unknown`){let r=t===`agent`?yC:vC;try{if(e?.name===`AbortError`)return`aborted`}catch{}return r.has(n)?n:`unknown`}function wC(e,{capture:t=s,now:n=()=>performance.now(),durationBucket:r=p}={}){let i=bC(),a=!1,o=!1,c=SC(n),u=(e,n)=>{i&&xC(t,e,n)};i&&u(`workflow:run_requested`,{surface:`workflow`,...l.node_count_bucket.has(e.node_count_bucket)?{node_count_bucket:e.node_count_bucket}:{},run_id:i});let d=(e,t,o)=>{if(a||!i)return;a=!0;let s=CC(t,`workflow`,o),d=e===`failed`&&s===`aborted`?`cancelled`:e,f=`lt1s`;try{let e=r(SC(n)-c);l.duration_bucket.has(e)&&(f=e)}catch{}u(`workflow:run_${d}`,{run_id:i,duration_bucket:f,...d===`succeeded`?{}:{failure_code:s}})};return{runId:i,succeed(){d(`succeeded`)},fail(e,t=`unknown`){d(`failed`,e,t)},apply(){o||!i||(o=!0,u(`workflow:result_applied`,{run_id:i}))}}}var TC=new Set([...new Set([`motion:generate_requested`,`motion:preflight_blocked`,`motion:preflight_passed`,`motion:job_started`,`motion:job_succeeded`,`motion:job_failed`,`motion:result_applied`]),...d.filter(e=>e.startsWith(`mcp:`))]),EC=`5184`,DC=((e=EC)=>`ws://127.0.0.1:${e}/live`)(),OC=1e3,kC=15e3,AC=.25,jC=2e4,MC=1e4,NC=`cozyclay:live-workspace-id`,PC=``;function FC(e){try{return e??globalThis.sessionStorage??null}catch{return null}}function IC(){return globalThis.crypto?.randomUUID?.()??`live-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function LC(e,t){PC=e;try{FC(t)?.setItem(NC,e)}catch{}return e}function RC(e){try{let t=FC(e)?.getItem(NC);if(typeof t==`string`&&t)return PC=t,t}catch{}return PC||LC(IC(),e)}function zC(e){return LC(IC(),e)}function BC(e,{target:t=globalThis,doc:n=globalThis.document}={}){if(typeof t?.addEventListener!=`function`)return()=>{};let r=()=>{n?.visibilityState===`visible`&&e()},i=[`online`,`focus`,`pageshow`];for(let n of i)t.addEventListener(n,e);return n?.addEventListener?.(`visibilitychange`,r),()=>{for(let n of i)t.removeEventListener(n,e);n?.removeEventListener?.(`visibilitychange`,r)}}var VC={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),now:()=>globalThis.performance?.now?.()??Date.now()};function HC(e){return e?.code===1008&&typeof e.reason==`string`&&e.reason.includes(`Workspace id is already connected`)}function UC(e){return e instanceof Error&&e.message?e.message:typeof e==`string`&&e?e:`Command failed`}function WC(e,t,n){return t?{type:`result`,id:e,ok:!0,value:n??{}}:{type:`result`,id:e,ok:!1,error:n}}async function GC(e,t={}){if(typeof e!=`string`)return null;let n;try{n=JSON.parse(e)}catch{return null}if(!n||typeof n!=`object`||Array.isArray(n)||n.type!==`cmd`||typeof n.id!=`string`)return null;if(typeof n.name!=`string`||!n.name)return WC(n.id,!1,`Invalid command name`);if(!n.args||typeof n.args!=`object`||Array.isArray(n.args))return WC(n.id,!1,`Invalid command arguments`);let r=t[n.name];if(typeof r!=`function`)return WC(n.id,!1,`Unknown command: ${n.name}`);try{return WC(n.id,!0,await r(n.args))}catch(e){return WC(n.id,!1,UC(e))}}function KC({handlers:e={},onWorkspace:t=()=>{},onEvent:n=()=>{},onDuplicate:r=()=>zC(),captureMotionTelemetry:i=s,captureTelemetry:a=s,workspaceId:o=``,meta:l=null,WebSocketImpl:u=globalThis.WebSocket,url:p=DC,timers:m=VC,random:h=Math.random,listen:g=BC}={}){let _=e,v=o,y=null,b=null,x=0,S=!1,C=null,w=0,T=0,E=!1,D=null,O=new Set,ee=e=>{if(!TC.has(e.event))return;let t=c(e.event,e.props),n=t.request_id;if(!n||d.includes(e.event)&&f[e.event]?.some(e=>!Object.hasOwn(t,e))||(e.event===`motion:generate_requested`||e.event.startsWith(`motion:preflight_`))&&t.surface!==`mcp`)return;let r=`${n}:${e.event}`;if(O.has(r))return;O.add(r);let o=e.event.startsWith(`motion:`)?i:a;try{Promise.resolve(o(e.event,t)).catch(()=>{})}catch{}},k=()=>{b!==null&&m.clearTimeout(b),b=null},te=()=>{let e=Math.min(OC*2**x,kC);return x+=1,Math.round(e*(1+(h()*2-1)*AC))},ne=()=>{S||b!==null||y||(b=m.setTimeout(()=>{b=null,se()},te()))},re=()=>{S||y||(k(),se())},ie=()=>{C!==null&&m.clearTimeout(C),C=null,E=!1,D=null},A=e=>{C!==null&&m.clearTimeout(C),w=m.now(),T=e,C=m.setTimeout(M,e)},j=e=>{ie(),!(typeof e!=`number`||!(e>0))&&(E=!0,A(jC))};function M(){if(C=null,S||!E||!y)return;let e=m.now();if(e-w>T+2e3){D=null,A(jC);return}if(D===null){oe({type:`ping`}),D=e,A(MC);return}let t=e-D;if(t>=1e4){ae();return}A(MC-t)}let ae=()=>{let e=y;y=null,ie();try{e?.close()}catch{}ne()},oe=e=>{if(!(!y||y.readyState!==(y.OPEN??1)))try{y.send(JSON.stringify(e))}catch{}},se=()=>{if(S||!u)return;k(),ie();try{y=new u(p)}catch{y=null,ne();return}let e=y;e.onopen=()=>{y!==e||S||oe({type:`hello`,role:`editor`,version:1,...v?{workspaceId:v}:{},...l?{meta:l}:{}})},e.onmessage=async r=>{if(y!==e||S)return;if(typeof r?.data==`string`)try{let e=JSON.parse(r.data);if(e?.type===`workspace`&&typeof e.handle==`string`){x=0,j(e.heartbeatMs),t(e.handle);return}if(e?.type===`pong`){E&&(D=null,A(jC));return}if(e?.type===`event`&&typeof e.name==`string`&&e.payload&&typeof e.payload==`object`){if(e.name===`motion_telemetry`||e.name===`telemetry`){ee(e.payload);return}n(e.name,e.payload);return}}catch{}let i=await GC(r?.data,_);i&&oe(i)},e.onerror=()=>{},e.onclose=t=>{if(y===e&&(y=null,ie()),HC(t)){x=0;try{let e=r();typeof e==`string`&&e&&(v=e)}catch{}}ne()}},ce=g(re)??(()=>{});return se(),{setHandlers(e){_=e&&typeof e==`object`?e:{}},close(){S=!0,k(),ie();try{ce()}catch{}let e=y;y=null;try{e?.close()}catch{}}}}var qC={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},JC=Q.createContext&&Q.createContext(qC),YC=[`attr`,`size`,`title`];function XC(e,t){if(e==null)return{};var n,r,i=ZC(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function ZC(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function QC(){return QC=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},QC.apply(null,arguments)}function $C(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function ew(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?$C(Object(n),!0).forEach(function(t){tw(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):$C(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function tw(e,t,n){return(t=nw(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function nw(e){var t=rw(e,`string`);return typeof t==`symbol`?t:t+``}function rw(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function iw(e){return e&&e.map((e,t)=>Q.createElement(e.tag,ew({key:t},e.attr),iw(e.child)))}function aw(e){return t=>Q.createElement(ow,QC({attr:ew({},e.attr)},t),iw(e.child))}function ow(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=XC(e,YC),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),Q.createElement(`svg`,QC({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:ew(ew({color:e.color||t.color},t.style),e.style),height:o,width:o,xmlns:`http://www.w3.org/2000/svg`}),i&&Q.createElement(`title`,null,i),e.children)};return JC===void 0?t(qC):Q.createElement(JC.Consumer,null,e=>t(e))}function sw(e){return aw({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`18`,y1:`6`,x2:`6`,y2:`18`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`6`,x2:`18`,y2:`18`},child:[]}]})(e)}function cw(e){return aw({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polygon`,attr:{points:`23 7 16 12 23 17 23 7`},child:[]},{tag:`rect`,attr:{x:`1`,y:`5`,width:`15`,height:`14`,rx:`2`,ry:`2`},child:[]}]})(e)}function lw(e){return aw({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`},child:[]},{tag:`polyline`,attr:{points:`17 8 12 3 7 8`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`3`,x2:`12`,y2:`15`},child:[]}]})(e)}function uw(e){return aw({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`4 7 4 4 20 4 20 7`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`20`,x2:`15`,y2:`20`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`4`,x2:`12`,y2:`20`},child:[]}]})(e)}function dw(e){return aw({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`23 4 23 10 17 10`},child:[]},{tag:`path`,attr:{d:`M20.49 15a9 9 0 1 1-2.12-9.36L23 10`},child:[]}]})(e)}function fw(e){return aw({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`5`,x2:`12`,y2:`19`},child:[]},{tag:`line`,attr:{x1:`5`,y1:`12`,x2:`19`,y2:`12`},child:[]}]})(e)}function pw(e){return aw({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polygon`,attr:{points:`5 3 19 12 5 21 5 3`},child:[]}]})(e)}function mw(e){return aw({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48`},child:[]}]})(e)}function hw(e){return aw({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M9 18V5l12-2v13`},child:[]},{tag:`circle`,attr:{cx:`6`,cy:`18`,r:`3`},child:[]},{tag:`circle`,attr:{cx:`18`,cy:`16`,r:`3`},child:[]}]})(e)}function gw(e){return aw({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`1`},child:[]},{tag:`circle`,attr:{cx:`19`,cy:`12`,r:`1`},child:[]},{tag:`circle`,attr:{cx:`5`,cy:`12`,r:`1`},child:[]}]})(e)}function _w(e){return aw({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`},child:[]},{tag:`path`,attr:{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`},child:[]}]})(e)}function vw(e){return aw({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`},child:[]},{tag:`circle`,attr:{cx:`8.5`,cy:`8.5`,r:`1.5`},child:[]},{tag:`polyline`,attr:{points:`21 15 16 10 5 21`},child:[]}]})(e)}function yw(e){return aw({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`2`,y:`2`,width:`20`,height:`20`,rx:`2.18`,ry:`2.18`},child:[]},{tag:`line`,attr:{x1:`7`,y1:`2`,x2:`7`,y2:`22`},child:[]},{tag:`line`,attr:{x1:`17`,y1:`2`,x2:`17`,y2:`22`},child:[]},{tag:`line`,attr:{x1:`2`,y1:`12`,x2:`22`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`2`,y1:`7`,x2:`7`,y2:`7`},child:[]},{tag:`line`,attr:{x1:`2`,y1:`17`,x2:`7`,y2:`17`},child:[]},{tag:`line`,attr:{x1:`17`,y1:`17`,x2:`22`,y2:`17`},child:[]},{tag:`line`,attr:{x1:`17`,y1:`7`,x2:`22`,y2:`7`},child:[]}]})(e)}function bw(e){return aw({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`},child:[]},{tag:`polyline`,attr:{points:`14 2 14 8 20 8`},child:[]},{tag:`line`,attr:{x1:`16`,y1:`13`,x2:`8`,y2:`13`},child:[]},{tag:`line`,attr:{x1:`16`,y1:`17`,x2:`8`,y2:`17`},child:[]},{tag:`polyline`,attr:{points:`10 9 9 9 8 9`},child:[]}]})(e)}function xw(e){return aw({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`},child:[]},{tag:`polyline`,attr:{points:`7 10 12 15 17 10`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`15`,x2:`12`,y2:`3`},child:[]}]})(e)}function Sw(e){return aw({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`,ry:`2`},child:[]},{tag:`path`,attr:{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`},child:[]}]})(e)}function Cw(e){return aw({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`16 18 22 12 16 6`},child:[]},{tag:`polyline`,attr:{points:`8 6 2 12 8 18`},child:[]}]})(e)}function ww(e){return aw({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`polyline`,attr:{points:`12 6 12 12 16 14`},child:[]}]})(e)}function Tw(e){return aw({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`9 18 15 12 9 6`},child:[]}]})(e)}function Ew(e){return aw({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`20 6 9 17 4 12`},child:[]}]})(e)}function Dw(e){return aw({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z`},child:[]},{tag:`polyline`,attr:{points:`3.27 6.96 12 12.01 20.73 6.96`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`22.08`,x2:`12`,y2:`12`},child:[]}]})(e)}function Ow(e){return aw({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`19`,x2:`12`,y2:`5`},child:[]},{tag:`polyline`,attr:{points:`5 12 12 5 19 12`},child:[]}]})(e)}function kw(e){return aw({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`9`,x2:`12`,y2:`13`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`},child:[]}]})(e)}function Aw(e){return aw({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`22 12 18 12 15 21 9 3 6 12 2 12`},child:[]}]})(e)}function jw(e){let t=Array.from(e?.files??[]).find(e=>e.type.startsWith(`image/`));if(t)return t;for(let t of Array.from(e?.items??[]))if(t.kind===`file`&&t.type.startsWith(`image/`)){let e=t.getAsFile?.();if(e)return e}return null}async function Mw(e){let t=new Uint8Array(await e.arrayBuffer()),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode.apply(null,t.subarray(e,e+32768));return`data:${e.type||`image/png`};base64,${btoa(n)}`}function Nw(e,t){return{fileName:e.name&&e.name!==`image.png`?e.name:`pasted-${new Date().toISOString().slice(0,19).replace(/[:T]/g,`-`)}.png`,mimeType:e.type||`image/png`,fileUrl:t,image_url:t,localPreview:!0,outputs:[{value:t}]}}function Pw(e,t){return jw(t)?!e||typeof e.matches!=`function`||!(e.isContentEditable||e.matches(`[contenteditable=true]`)):!1}var Fw=1600,Iw=4194304,Lw=.85,Rw=Object.freeze([`image/png`,`image/jpeg`,`image/webp`]),zw=`Up to 4 images per message`,Bw=`Attach a PNG, JPEG or WebP image`,Vw=`That image could not be attached`,Hw={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,webp:`image/webp`};function Uw(e){let t=String(e?.type??``).toLowerCase();return Rw.includes(t)?t:t?null:Hw[String(e?.name??``).toLowerCase().match(/\.([a-z0-9]+)$/)?.[1]]??null}function Ww(e){return Array.from(e?.types??[]).includes(`Files`)}function Gw(e){let t=Array.from(e?.files??[]);if(!t.length){let n=jw(e);n&&t.push(n)}let n=[],r=0;for(let e of t)Uw(e)?n.push(e):String(e?.type??``).startsWith(`image/`)&&(r+=1);return{images:n,unsupported:r}}function Kw(e){let t=String(e??``).slice(String(e??``).indexOf(`,`)+1);if(!t)return 0;let n=t.endsWith(`==`)?2:+!!t.endsWith(`=`);return Math.max(0,Math.floor(t.length*3/4)-n)}function qw(e,t,n=Fw){let r=Math.max(e,t);if(!Number.isFinite(r)||r<=0)return null;if(r<=n)return{width:Math.round(e),height:Math.round(t),scaled:!1};let i=n/r;return{width:Math.max(1,Math.round(e*i)),height:Math.max(1,Math.round(t*i)),scaled:!0}}function Jw(e=[],t=[],n=4){let r=Math.max(0,n-e.length);return{attachments:[...e,...t.slice(0,r)],rejected:Math.max(0,t.length-r)}}var Yw=32768,Xw=e=>{let t=``;for(let n=0;n<e.length;n+=Yw)t+=String.fromCharCode.apply(null,e.subarray(n,n+Yw));return btoa(t)};async function Zw(e,t){let n=new Uint8Array(await e.arrayBuffer());return`data:${t||e.type||`image/jpeg`};base64,${Xw(n)}`}function Qw(e,t){if(typeof OffscreenCanvas==`function`)return new OffscreenCanvas(e,t);throw Error(`this browser cannot resize images — OffscreenCanvas is unavailable`)}function $w(e){let t=e.indexOf(`,`),n=e.slice(5,e.indexOf(`;`)),r=atob(e.slice(t+1)),i=new Uint8Array(r.length);for(let e=0;e<r.length;e+=1)i[e]=r.charCodeAt(e);return new Blob([i],{type:n})}async function eT(e,{decode:t=globalThis.createImageBitmap,makeCanvas:n=Qw,toBlob:r=$w,maxBytes:i=Iw,maxDimension:a=Fw,quality:o=Lw}={}){if(Kw(e)<=i)return e;if(typeof t!=`function`)throw Error(`this browser cannot decode images — createImageBitmap is unavailable`);let s=await t(r(e));try{let e=qw(s.width,s.height,a);if(!e)throw Error(`that image has no usable size`);let t=n(e.width,e.height),r=t.getContext(`2d`);if(!r)throw Error(`this browser cannot resize images — no 2D context`);return r.drawImage(s,0,0,e.width,e.height),await Zw(await t.convertToBlob({type:`image/jpeg`,quality:o}),`image/jpeg`)}finally{s?.close?.()}}function tT(e){let t=String(e?.name??``).trim();return!t||t===`image.png`?`pasted-image.png`:t.slice(0,120)}async function nT(e,t={}){let{readDataUrl:n=Mw,...r}=t,i=Uw(e)??`image/png`,a=await n(e);return{dataUrl:await eT(a.startsWith(`data:${i};`)?a:`data:${i};${a.slice(a.indexOf(`;`)+1)}`,r),name:tT(e)}}var rT=`cozyclay.workflow.agentPanel.width`,iT=1100,aT=`cozyclay.agent.session.studio`,oT=[`signed-out`,`signing-in`,`no-entitlement`,`ready`,`streaming`,`rate-limited`,`error`];function sT(e=globalThis.crypto){let t=e?.randomUUID?.();if(typeof t==`string`)return t;let n=new Uint8Array(16);e.getRandomValues(n),n[6]=n[6]&15|64,n[8]=n[8]&63|128;let r=[...n].map(e=>e.toString(16).padStart(2,`0`)).join(``);return`${r.slice(0,8)}-${r.slice(8,12)}-${r.slice(12,16)}-${r.slice(16,20)}-${r.slice(20)}`}var cT={queued:`Queued`,generating:`Generating`,preparing:`Preparing`,verifying:`Verifying`,repairing:`Repairing`,committing:`Installing`,reconciling:`Reconciling`,installed:`Installed`,review_required:`Needs review`,failed:`Failed`,cancelled:`Stopped`,stale_target:`Target changed`,stale_environment:`Scene changed`},lT=new Set([`installed`,`failed`,`cancelled`,`stale_target`,`stale_environment`]),uT=e=>lT.has(e),dT=e=>e===`installed`?`ok`:e===`review_required`?`warn`:uT(e)?`alert`:`busy`,fT=e=>Number.isFinite(e)?`${Math.round(e*100)}%`:``;function pT(e){if(e?.status===`installed`){let{installed:t,verification:n}=e,r=n.status===`verified`?`verified over ${n.evaluatedFrames} frames`:`installed unverified`;return`Installed ${t.durationSeconds}s of motion on ${t.characterId} — ${r}`}return e?.status===`undone`?`Undid ${e.undoneReceiptId}`:e?.status===`noop`?`Nothing to change`:e?.status===`transient`?`Changed the view only`:`Applied to ${e?.affectedIds?.join(`, `)||`the scene`}`}function mT(e){let t=Array.isArray(e?.efforts)?e.efforts:[];if(!t.length)return[];let n=e.defaultEffort&&t.includes(e.defaultEffort)?e.defaultEffort:t[0];return[n,...t.filter(e=>e!==n)]}var hT=[`Block a two-shot conversation in this scene`,`Render this frame as a storyboard panel`,`Suggest a camera move for the current shot`],gT=[Ix(`Block a two-shot`,`투샷 블로킹`),Ix(`Frame the selected character`,`선택한 캐릭터 구도 잡기`),Ix(`Light the set warmer`,`세트 조명 더 따뜻하게`)],_T=`Image generation uses about 3-5x a normal turn`,vT={describe_workflow:`Read canvas`,add_workflow_node:`Add node`,update_workflow_node:`Edit node`,remove_workflow_node:`Remove node`,connect_workflow_nodes:`Connect nodes`,disconnect_workflow_nodes:`Disconnect nodes`,run_workflow:`Run workflow`,set_workflow_node_output:`Set node output`,focus_workflow_node:`Focus node`,add_reference_node:`Add reference image`},yT={inspect_studio:Ix(`Read the scene`,`장면 읽기`),operate_studio:Ix(`Selection and view`,`선택과 뷰`),arrange_objects:Ix(`Arrange objects`,`오브젝트 배치`),arrange_characters:Ix(`Arrange characters`,`캐릭터 배치`),patch_elements:Ix(`Edit properties`,`속성 편집`),frame_shot:Ix(`Frame the shot`,`샷 구도 잡기`),generate_motion:Ix(`Generate motion`,`모션 생성`),verify_result:Ix(`Verify the result`,`결과 검증`),undo_edit:Ix(`Undo an edit`,`편집 되돌리기`),run_action:Ix(`Run an editor action`,`편집기 동작 실행`)},bT=Object.freeze({workflow:Object.freeze({toolLabels:vT,toolBadge:`Canvas`,suggestions:hT,imageHint:_T,imageEntitlement:!0,steer:!0,history:!0,persistWidth:!0,emptyTitle:`Direct the scene`,emptyHint:e=>`Ask for blocking, a camera move, or a rendered frame from \u201C${e}\u201D.`,composerPlaceholder:`Ask the agent to block, frame or render…`}),studio:Object.freeze({toolLabels:yT,toolBadge:Ix(`Scene`,`장면`),suggestions:gT,imageHint:null,imageEntitlement:!1,steer:!1,history:!0,persistWidth:!1,emptyTitle:Ix(`Direct the scene`,`장면을 연출하세요`),emptyHint:e=>Ix(`Ask for blocking, a camera move, or a motion take in \u201C${e}\u201D.`,`\u201C${e}\u201D\uC5D0\uC11C \uBE14\uB85C\uD0B9, \uCE74\uBA54\uB77C \uC6C0\uC9C1\uC784, \uBAA8\uC158 \uD14C\uC774\uD06C\uB97C \uC694\uCCAD\uD558\uC138\uC694.`),composerPlaceholder:Ix(`Ask the agent to block, frame or animate…`,`블로킹·구도·모션을 요청하세요…`)})});function xT(e){return Object.hasOwn(bT,e)?bT[e]:bT.workflow}function ST(e,t=vT){return Object.hasOwn(t,e?.name)?t[e.name]:PT(e)}function CT(e){let t=Number(e);return Number.isFinite(t)?Math.min(560,Math.max(300,Math.round(t))):360}function wT(e=globalThis.localStorage){try{let t=e?.getItem(rT);return t==null||t===``?360:CT(t)}catch{return 360}}function TT(e,t=globalThis.localStorage){try{t?.setItem(rT,String(CT(e)))}catch{}}var ET=`cozyclay.agent.model`;function DT(e=globalThis.localStorage){try{let t=e?.getItem(ET);return typeof t==`string`&&t?t:null}catch{return null}}function OT(e,t=globalThis.localStorage){try{typeof e==`string`&&e&&t?.setItem(ET,e)}catch{}}function kT(e,t=DT()){let n=Array.isArray(e)?e:[];return n.some(e=>e?.id===t)?t:n[0]?.id??``}function AT(e,t){if(!e.length)return!0;let n=e.find(e=>e.models?.some(e=>e.key===t));return!n||n.signedIn}function jT(e,t,n){return n&&t.some(e=>e.id===n)&&AT(e,n)?n:kT(t.filter(t=>AT(e,t.id)))}function MT(e,t=Date.now()){if(!e)return null;let n=typeof e==`number`?e:Date.parse(e);if(!Number.isFinite(n))return null;let r=Math.max(0,n-t),i=Math.round(r/1e3),a=Math.floor(i/3600),o=Math.floor(i%3600/60),s=i%60;return a>0?`${a}h ${String(o).padStart(2,`0`)}m`:o>0?`${o}m ${String(s).padStart(2,`0`)}s`:`${s}s`}var NT={capture_blocking_frame:{verb:`Capture`,target:`blocking frame`},render_from_frame:{verb:`Render`,target:`from frame`},place_image_in_scene:{verb:`Place`,target:`image in scene`}};function PT(e){if(e?.label)return e.label;let t=NT[e?.name];if(t)return`${t.verb} ${t.target}`;let n=String(e?.name||`tool`).split(/[_\-\s]+/).filter(Boolean);if(!n.length)return`Run tool`;let r=n[0][0].toUpperCase()+n[0].slice(1);return n.length>1?`${r} ${n.slice(1).join(` `)}`:r}function FT(e){return!Number.isFinite(e)||e<0?``:e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(1)}s`}var IT={STEER_UNSUPPORTED:`This surface cannot steer a running turn.`,NO_ACTIVE_TURN:`That turn already ended — send it as a new message.`},LT={auth:`Your session expired. Sign in again to continue.`,entitlement:`This account cannot generate images.`,rate_limit:`You have hit the usage limit for this window.`,upstream:`The model service failed to answer.`,overloaded:`The model service is overloaded right now. Try again in a moment.`},RT=`Ready`,zT={auth:`session expired`,entitlement:`not on this plan`,rate_limit:`usage limit reached`,rate_limited:`usage limit reached`,overloaded:`service overloaded`,no_output:`no response`};function BT(e){if(!e)return`unknown error`;let t=zT[e.code];if(t)return t;let n=String(e.message??``).trim();return n?n.length>64?`${n.slice(0,63)}…`:n:String(e.code||`unknown error`)}function VT(e){let t=Number.isFinite(e)&&e>0?Math.floor(e/1e3):0;return t<60?`${t} s`:`${Math.floor(t/60)} m ${String(t%60).padStart(2,`0`)} s`}var HT=(e,t,n)=>({phase:e,kind:`live`,tone:`busy`,text:`${t} · ${VT(n)}`,ticking:!0});function UT(e,{now:t=Date.now(),toolLabel:n=PT}={}){let r=e?.items??[],i=r.find(e=>e.kind===`image`&&e.apply?.status===`applying`);if(i)return HT(`editor`,`Waiting for the editor…`,t-(i.apply.startedAt??t));if(e?.streaming){let i=t-(e.turnStartedAt??t),a=r.findLast(e=>e.kind===`job`&&!uT(e.state));if(a){let e=fT(a.progress);return HT(`job`,`${cT[a.state]||a.state} motion${e?` ${e}`:``}`,i)}let o=r.findLast(e=>e.kind===`tool`&&e.status===`running`);return o?HT(`tool`,`Running ${n(o)}…`,i):r.findLastIndex(e=>e.kind===`user`)===r.length-1?HT(`sending`,`Sending…`,i):HT(`thinking`,`Thinking…`,i)}let a=e?.lastTurn;return a&&t-a.endedAt<6e3?a.status===`stopped`?{phase:`stopped`,kind:`terminal`,tone:`warn`,text:`Stopped`,ticking:!0}:a.status===`failed`?{phase:`failed`,kind:`terminal`,tone:`alert`,text:`Failed: ${BT(a.failure)}`,ticking:!0}:{phase:`done`,kind:`terminal`,tone:`ok`,text:`Done · ${VT(a.durationMs)}`,ticking:!0}:{phase:`idle`,kind:`idle`,tone:``,text:RT,ticking:!1}}function WT(e){let t=[],n=e.split(`
|
|
16
|
+
`),r=n.pop()??``;for(let e of n){let n=e.trim();if(!n.startsWith(`data:`))continue;let r=n.slice(5).trim();if(r)try{t.push(JSON.parse(r))}catch{}}return{events:t,tail:r}}var GT=``;function KT(e){return`${GT}${e}`}var qT=e=>typeof e==`string`&&/^[a-f0-9]{32}$/.test(e),JT=new Set([`aborted`,`auth`,`rate_limited`,`tool_failed`,`upstream`,`unknown`]),YT=(e,t)=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===t.length&&t.every(t=>Object.hasOwn(e,t)),XT=(e,t)=>{try{return e()}catch{return t}},ZT=e=>XT(()=>e?.status===401||e?.code===`auth`?`auth`:e?.status===429||e?.code===`rate_limit`?`rate_limited`:`upstream`,`upstream`),QT=new Set([`auth`,`entitlement`,`rate_limit`,`overloaded`,`upstream`]);async function $T(e){let t=Number.isFinite(e?.status)?e.status:null,n=null;try{let t=await e.clone().json();n=typeof t?.error==`string`?{message:t.error}:t?.error&&typeof t.error==`object`?t.error:null}catch{}let r=typeof n?.message==`string`?n.message.trim():``,i=r?t!==null&&r.startsWith(`${t} `)?r:`${t??`Upstream`} — ${r}`:`The turn was refused with HTTP ${t??`error`}.`;return{code:QT.has(n?.code)?n.code:t===429?`rate_limit`:t===401?`auth`:`upstream`,message:i,...t===null?{}:{status:t},...n?.resetAt?{resetAt:n.resetAt}:{}}}function eE({surface:e,capture:t,now:n,correlationId:r=null}){let i=XT(()=>{let e=new Uint8Array(16);return globalThis.crypto.getRandomValues(e),[...e].map(e=>e.toString(16).padStart(2,`0`)).join(``)},null),a=()=>XT(()=>{let e=n();return Number.isFinite(e)?e:NaN},NaN),o=r??i,s=a(),c=XT(()=>[`studio`,`workflow`].includes(e)?e:/^\/workflow(?:\/|$)/.test(globalThis.location?.pathname||``)?`workflow`:`studio`,`studio`),u=!1,d=!1,f=new Map,h=new Set,g=(e,n)=>{if(i)try{Promise.resolve(t(e,n)).catch(()=>{})}catch{}},_=(e,t)=>{if(!u){if(u=!0,e===`cancelled`)for(let[e,t]of f)h.has(e)||g(`agent:tool_executed`,{turn_id:i,tool_category:t.category,outcome:`cancelled`,duration_bucket:p(a()-t.startedAt)});f.clear(),g(`agent:turn_${e}`,{turn_id:i,duration_bucket:p(a()-s),...e===`succeeded`?{}:{failure_code:t}})}};return g(`agent:turn_requested`,{surface:c,turn_id:i}),{turnId:i,cancel:()=>_(`cancelled`,`aborted`),fail:e=>_(`failed`,JT.has(e)?e:`upstream`),frame(e){try{if(!i||u)return;if(e.type===`execution_tool_started`){if(!YT(e,[`type`,`turn_id`,`telemetry_id`,`tool_category`])||e.turn_id!==o||!qT(e.telemetry_id)||!m.includes(e.tool_category))return;!f.has(e.telemetry_id)&&!h.has(e.telemetry_id)&&f.set(e.telemetry_id,{category:e.tool_category,startedAt:a()});return}let{event:t,props:n}=e;if(n?.turn_id!==o)return;if(t===`agent:tool_executed`){if(!YT(e,[`type`,`event`,`props`,`telemetry_id`])||!qT(e.telemetry_id)||!YT(n,[`turn_id`,`tool_category`,`outcome`,`duration_bucket`])||!m.includes(n.tool_category)||![`succeeded`,`failed`,`cancelled`].includes(n.outcome)||!l.duration_bucket.has(n.duration_bucket)||h.has(e.telemetry_id))return;h.add(e.telemetry_id),f.delete(e.telemetry_id),g(t,{turn_id:i,tool_category:n.tool_category,outcome:n.outcome,duration_bucket:n.duration_bucket});return}if(!YT(e,[`type`,`event`,`props`]))return;if(t===`agent:result_applied`){!d&&YT(n,[`turn_id`])&&(d=!0,g(t,{turn_id:i}));return}if(![`agent:turn_succeeded`,`agent:turn_failed`,`agent:turn_cancelled`].includes(t))return;let r=t.slice(11),s=Object.hasOwn(n,`failure_code`);if(!YT(n,[`turn_id`,`duration_bucket`,...s?[`failure_code`]:[]])||!l.duration_bucket.has(n.duration_bucket)||s&&(r===`succeeded`||!JT.has(n.failure_code)))return;_(r,r===`cancelled`?`aborted`:n.failure_code||`unknown`)}catch{}}}}var tE=3,nE={anthropic:[`ANTHROPIC_API_KEY`],openai:[`OPENAI_API_KEY`],google:[`GEMINI_API_KEY`,`GOOGLE_API_KEY`],openrouter:[`OPENROUTER_API_KEY`],cliproxy:[`CLIPROXY_API_KEY`]};function rE(e){let t=nE[e];return t?.length?t.join(` or `):`an environment variable`}function iE({fetchImpl:e=globalThis.fetch?.bind(globalThis),surface:t,capture:n=s,now:r=()=>performance.now()}={}){let i=new Map,a=async(t,n)=>{let r=await e(KT(t),{headers:{"content-type":`application/json`},...n});if(!r.ok){let e=null;try{e=await r.clone().json()}catch{}let n=typeof e?.error==`string`?e.error:e?.error?.message,i=Error(n||`${t} responded ${r.status}`);throw i.status=r.status,e?.error&&typeof e.error==`object`&&Object.assign(i,e.error),e?.preservation&&typeof e.preservation==`object`&&(i.preservation=e.preservation),i}return r.json()};return{mock:!1,async status(){return a(`/oauth/status`)},async signIn(){let e=await a(`/oauth/start`,{method:`POST`,body:`{}`});return e?.authorizeUrl&&globalThis.open?.(e.authorizeUrl,`_blank`,`noopener,noreferrer`),e},async signOut(){return a(`/oauth/logout`,{method:`POST`,body:`{}`})},async models(){let e=await a(`/agent/models`),t=Array.isArray(e?.models)?e.models:[];return{providers:Array.isArray(e?.providers)?e.providers.filter(e=>e?.id&&Array.isArray(e.models)):[],models:t}},async steer(e,t){return a(`/agent/turn/${encodeURIComponent(e)}/steer`,{method:`POST`,body:JSON.stringify(t)})},async providers(){let e=await a(`/agent/providers`);return Array.isArray(e?.providers)?e.providers:[]},async setProviderKey(e,t){return a(`/agent/providers/${encodeURIComponent(e)}`,{method:`PUT`,body:JSON.stringify({key:t})})},async removeProviderKey(e){return a(`/agent/providers/${encodeURIComponent(e)}`,{method:`DELETE`})},async listSessions(){let e=await a(`/agent/sessions?surface=${encodeURIComponent(t||`studio`)}`);return Array.isArray(e?.sessions)?e.sessions:[]},async loadSession(e){return a(`/agent/sessions/${encodeURIComponent(e)}`)},async stop(e){let t=typeof e==`string`||!e?{sessionId:e}:{surface:`studio`,sessionId:e.sessionId,turnId:e.turnId,...e.jobId?{jobId:e.jobId}:{}};return i.get(t.sessionId)?.cancel(),a(`/agent/stop`,{method:`POST`,body:JSON.stringify(t)})},async acceptJob({jobId:e,sessionId:t,turnId:n}){return a(`/agent/jobs/${encodeURIComponent(e)}/accept`,{method:`POST`,body:JSON.stringify({surface:`studio`,sessionId:t,turnId:n,explicitUnverifiedAcceptance:!0})})},async image({prompt:e,imageDataUrl:t,referenceDataUrl:n,references:r,quality:i=`auto`},o){return a(`/agent/image`,{method:`POST`,body:JSON.stringify({prompt:e,imageDataUrl:t,...n?{referenceDataUrl:n}:{},...Array.isArray(r)&&r.length?{references:r}:{},quality:i}),signal:o})},async video(e,t){return a(`/agent/video`,{method:`POST`,body:JSON.stringify(e),signal:t})},async videoProviders(){return a(`/agent/video/providers`)},async turn(a,o,s){let{sessionId:c,text:l,attachFrame:u,model:d,effort:f,attachments:p}=a,m=Array.isArray(p)&&p.length?{attachments:p}:{},h=a.surface===`studio`,g=h?a.turnId:null,_=eE({surface:t,capture:n,now:r,correlationId:g});a.onTurnId?.(h?g:_.turnId),i.set(c,_);let v=()=>{s.reason===`agent-stop`&&_.cancel()};s?.addEventListener(`abort`,v,{once:!0}),s?.aborted&&v();let y=!1,b,x=0,S=!1,C=e=>{if(e?.type===`execution_telemetry`||e?.type===`execution_tool_started`){_.frame(e);return}if(h&&Number.isFinite(e?.eventSeq)){if(e.eventSeq<=x)return;x=e.eventSeq}e?.type===`error`&&(b=ZT(e)),e?.type===`done`&&(S=!0),o(e)},w=async e=>{let t=e.body.getReader();y=!0;try{let e=new TextDecoder,n=``;for(;;){let{value:r,done:i}=await t.read();if(i)break;n+=e.decode(r,{stream:!0});let a=WT(n);n=a.tail;for(let e of a.events)C(e)}for(let e of WT(`${n}\n`).events)e?.type!==`execution_telemetry`&&e?.type!==`execution_tool_started`&&C(e)}finally{t.releaseLock()}},T=JSON.stringify(h?{surface:`studio`,sessionId:c,turnId:g,text:l,context:a.context,...d?{model:d}:{},...f?{effort:f}:{},...u===void 0?{}:{attachFrame:!!u},...m}:{sessionId:c,text:l,attachFrame:u,model:d,...f?{effort:f}:{},...m,..._.turnId?{turn_id:_.turnId}:{}});try{let t=await e(KT(`/agent/turn`),{method:`POST`,headers:{"content-type":`application/json`,accept:`text/event-stream`},body:T,signal:s});if(!t.ok||!t.body){_.fail(ZT(t)),o({type:`error`,...await $T(t)}),o({type:`done`});return}let n=null;try{await w(t)}catch(e){n=e}for(let t=0;h&&g&&!S&&!s?.aborted&&t<tE;t+=1){let t;try{t=await e(KT(`/agent/turn/${encodeURIComponent(g)}/events?after=${x}`),{headers:{accept:`text/event-stream`},signal:s})}catch{break}if(!t?.ok||!t.body)break;n=null;try{await w(t)}catch(e){n=e}}if(n)throw n;b&&_.fail(b)}catch(e){throw!s?.aborted&&(!y||b)&&_.fail(b||ZT(e)),e}finally{s?.removeEventListener(`abort`,v),i.get(c)===_&&i.delete(c)}}}}function aE(e=globalThis.location?.search||``){let t=new URLSearchParams(e);if(t.get(`agent`)!==`mock`)return null;let n=t.get(`state`);return{state:oT.includes(n)?n:`ready`,speed:Number(t.get(`speed`))||1}}var oE={signedIn:!0,email:`director@cozyclay.org`,plan:`Plus`,accountId:`acct_mock_126`,expiresAt:null},sE=[{delay:40,event:{type:`text.delta`,text:`Framing a wide two-shot from the current blocking. `}},{delay:120,event:{type:`text.delta`,text:`Capturing the viewport first.`}},{delay:120,event:{type:`tool.start`,callId:`call-1`,name:`capture_blocking_frame`,label:`Capture blocking frame`,args:{shot:`current`}}},{delay:260,event:{type:`tool.done`,callId:`call-1`,ok:!0,elapsedMs:268,result:{width:1280,height:720}}},{delay:90,event:{type:`tool.start`,callId:`call-2`,name:`render_from_frame`,label:`Render from frame`,args:{style:`storyboard`,strength:.6}}},{delay:420,event:{type:`tool.done`,callId:`call-2`,ok:!0,elapsedMs:1412,result:{imageId:`img-1`}}},{delay:80,event:{type:`image`,imageId:`img-1`,dataUrl:`data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22512%22%20height%3D%22288%22%20viewBox%3D%220%200%20512%20288%22%3E%3Cdefs%3E%3ClinearGradient%20id%3D%22g%22%20x1%3D%220%22%20y1%3D%220%22%20x2%3D%221%22%20y2%3D%221%22%3E%3Cstop%20offset%3D%220%22%20stop-color%3D%22%232a2f52%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22%235b3550%22%2F%3E%3C%2FlinearGradient%3E%3C%2Fdefs%3E%3Crect%20width%3D%22512%22%20height%3D%22288%22%20fill%3D%22url(%23g)%22%2F%3E%3Ccircle%20cx%3D%22150%22%20cy%3D%22150%22%20r%3D%2252%22%20fill%3D%22%23ef759d%22%20opacity%3D%220.85%22%2F%3E%3Crect%20x%3D%22250%22%20y%3D%22112%22%20width%3D%22180%22%20height%3D%22112%22%20rx%3D%2210%22%20fill%3D%22%238994ff%22%20opacity%3D%220.8%22%2F%3E%3Crect%20y%3D%22240%22%20width%3D%22512%22%20height%3D%2248%22%20fill%3D%22%23101116%22%20opacity%3D%220.55%22%2F%3E%3Ctext%20x%3D%2224%22%20y%3D%22272%22%20font-family%3D%22Inter%2Csans-serif%22%20font-size%3D%2218%22%20fill%3D%22%23edf0fb%22%3Emock%20render%20%C2%B7%20wide%20two-shot%3C%2Ftext%3E%3C%2Fsvg%3E`,width:512,height:288,prompt:`wide two-shot, storyboard ink`}},{delay:60,event:{type:`quota`,plan:`Plus`,primary:{usedPercent:46,windowMinutes:300,resetAt:null},credits:{has:!0}}},{delay:40,event:{type:`done`}}],cE={ok:!0,commandId:`cmd-mock-1`,receiptId:`receipt-mock-1`,host:{workspaceId:`tab-mock`,documentEpoch:`doc-mock`,sceneId:`scene-mock`,sceneEpoch:`scene-open-mock`},status:`applied`,authored:!0,revision:{before:41,after:42},affectedIds:[`char-a`],delta:[{id:`char-a`,after:{position:{x:-.8,y:0,z:.4}}}],checks:{coverage:`affected-targets`},undo:{historyEntryId:`history-mock-1`,entries:1,canUndoDirect:!0},warnings:[]},lE=[{delay:40,event:{type:`text.delta`,text:`Reading the scene before I move anyone. `}},{delay:120,event:{type:`tool.start`,callId:`studio-1`,name:`inspect_studio`,label:`inspect studio`,args:{scope:`selection`}}},{delay:220,event:{type:`tool.done`,callId:`studio-1`,ok:!0,elapsedMs:214,result:{entities:2}}},{delay:90,event:{type:`text.delta`,text:`Blocking the two-shot now.`}},{delay:120,event:{type:`tool.start`,callId:`studio-2`,name:`arrange_characters`,label:`arrange characters`,args:{ops:[{op:`update`,characterId:`char-a`,position:{world:{x:-.8,y:0,z:.4}}}]}}},{delay:320,event:{type:`tool.done`,callId:`studio-2`,ok:!0,elapsedMs:332,result:{ok:!0,receiptId:cE.receiptId}}},{delay:60,event:{type:`receipt`,receipt:cE}},{delay:40,event:{type:`done`}}],uE=[[`openai-codex`,`ChatGPT (OpenAI Codex)`],[`anthropic`,`Anthropic`],[`openai`,`OpenAI`],[`google`,`Google Gemini`],[`openrouter`,`OpenRouter`],[`cliproxy`,`CLIProxyAPI`]],dE=`google`,fE={"openai-codex":[{id:`gpt-6-astra`,label:`gpt-6-astra`,efforts:[`none`,`low`,`medium`,`high`,`xhigh`],defaultEffort:`medium`},{id:`gpt-5.1-codex`,label:`gpt-5.1-codex`,efforts:[`low`,`medium`,`high`],defaultEffort:`medium`}],anthropic:[{id:`claude-sonnet-4-5`,label:`Claude Sonnet 4.5`,efforts:[`none`,`low`,`medium`,`high`],defaultEffort:`medium`}],openai:[{id:`gpt-5.1`,label:`GPT-5.1`,efforts:[`none`,`low`,`medium`,`high`,`xhigh`],defaultEffort:`medium`}],google:[{id:`gemini-3-pro`,label:`Gemini 3 Pro`,efforts:[`none`,`low`,`medium`,`high`],defaultEffort:`medium`}],openrouter:[{id:`deepseek-v3`,label:`DeepSeek V3`,efforts:[`none`],defaultEffort:`none`}],cliproxy:[{id:`claude-sonnet-5`,label:`Claude Sonnet 5`,efforts:[`none`,`low`,`medium`,`high`],defaultEffort:`medium`}]},pE={id:`gpt-6-live-preview`,label:`gpt-6 live preview`,efforts:[`none`,`low`,`medium`,`high`],defaultEffort:`high`},mE=`cozyclay.mock.agent.status-calls`,hE=`cozyclay.mock.agent.model-calls`,gE=e=>{try{globalThis.localStorage?.setItem(e,String(Number(globalThis.localStorage.getItem(e)||0)+1))}catch{}};function _E(e={state:`ready`}){let t=e?.state||`ready`,n=e?.surface===`studio`,r=e?.speed>0?e.speed:1,i=e=>new Promise(t=>setTimeout(t,Math.max(0,e/r))),a=new Set,o=t===`signed-out`?`out`:t===`signing-in`?`pending`:`in`,s=()=>uE.map(([e,t])=>{let n=e===`openai-codex`?o===`in`?`chatgpt`:null:e===dE?`env`:a.has(e)?`file`:null;return{id:e,label:t,authSource:n,signedIn:!!n}}),c=null,l=0;return{mock:!0,state:t,async status(){gE(mE);let e=s().filter(e=>e.id!==`openai-codex`&&e.signedIn).length;return o===`pending`?{signedIn:!1,pending:!0,email:null,plan:null,accountId:null,expiresAt:null,providersConfigured:a.size}:o===`out`?{signedIn:!1,email:null,plan:null,accountId:null,expiresAt:null,providersConfigured:a.size}:t===`no-entitlement`?{...oE,plan:`Free`,entitlements:{image:!1},providersConfigured:e}:{...oE,entitlements:{image:!0},providersConfigured:e}},async signIn(){return o=`in`,{ok:!0,authorizeUrl:`https://auth.example.invalid/mock`}},async signOut(){return o=`out`,{ok:!0}},async models(){gE(hE);let e=s().map(e=>{let t=fE[e.id]??[],n=e.id===`openai-codex`&&o===`in`?[...t,pE]:t;return{...e,models:n.map(t=>({...t,key:`${e.id}/${t.id}`,input:[`text`,`image`]}))}});return{providers:e,models:e.flatMap(e=>e.models.map(e=>({...e,id:e.key})))}},async providers(){return s()},async setProviderKey(e,t){if(e===`openai-codex`)throw Object.assign(Error(`Use ChatGPT sign-in for OpenAI Codex.`),{status:400});if(typeof t!=`string`||t.trim().length<8)throw Object.assign(Error(`That key was refused: it is too short.`),{status:400});return a.add(e),{ok:!0}},async removeProviderKey(e){return a.delete(e),{ok:!0}},async stop(){return c=null,{ok:!0}},async steer(e,t){if(n)throw Object.assign(Error(`409 — Steering a Studio turn is not supported.`),{status:409,code:`STEER_UNSUPPORTED`});if(!c||e!==c)throw Object.assign(Error(`409 — This turn already ended.`),{status:409,code:`NO_ACTIVE_TURN`});try{globalThis.localStorage?.setItem(`cozyclay.mock.agent.last-steer`,JSON.stringify({turnId:e,text:t?.text??null,attachments:t?.attachments?.length??0}))}catch{}return{ok:!0,queued:!0}},async acceptJob(){return{ok:!0}},async listSessions(){if(!n)return[];let e=[];try{for(let t=0;t<globalThis.localStorage.length;t+=1){let n=globalThis.localStorage.key(t);if(!n?.startsWith(`cozyclay.mock.agent.session.`))continue;let r=JSON.parse(globalThis.localStorage.getItem(n));r?.meta&&e.push(r.meta)}}catch{}return e.sort((e,t)=>Date.parse(t.updatedAt||0)-Date.parse(e.updatedAt||0)).slice(0,50)},async loadSession(e){try{let t=JSON.parse(globalThis.localStorage.getItem(`cozyclay.mock.agent.session.${e}`));if(t?.transcript)return t}catch{}throw Error(`Mock session not found.`)},async applyImage({requestId:e}){return{ok:!0,receiptId:`mock-${e}`}},async turn(e,r,a){let o=`mock-turn-${++l}`;c=o,e?.onTurnId?.(o);try{globalThis.localStorage?.setItem(`cozyclay.mock.agent.last-turn`,JSON.stringify({turnId:o,model:e?.model??null,effort:e?.effort??null,text:e?.text??null}))}catch{}try{n&&e?.sessionId&&globalThis.localStorage?.setItem(`cozyclay.mock.agent.last-turn-session`,e.sessionId)}catch{}let s=[],u=n&&e?.sessionId?`cozyclay.mock.agent.session.${e.sessionId}`:null;if(u){try{s=JSON.parse(globalThis.localStorage.getItem(u))?.transcript||[]}catch{s=[]}s.push({kind:`user`,text:e.text})}let d=t=>{if(u){if(t.type===`text.delta`){let e=s.at(-1);e?.kind===`assistant`?e.text+=t.text:s.push({kind:`assistant`,text:t.text})}else if(t.type===`tool.start`)s.push({kind:`tool`,name:t.name,label:t.label,ok:!0,elapsedMs:null,callId:t.callId});else if(t.type===`tool.done`){let e=[...s].reverse().find(e=>e.kind===`tool`&&e.callId===t.callId);e&&Object.assign(e,{ok:t.ok,elapsedMs:t.elapsedMs})}else t.type===`receipt`&&s.push({kind:`receipt`,receiptId:t.receipt?.receiptId,summary:t.receipt?.status===`applied`?`Applied to the scene`:`Receipt`});try{globalThis.localStorage.setItem(u,JSON.stringify({sessionId:e.sessionId,transcript:s,meta:{sessionId:e.sessionId,surface:`studio`,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),sceneName:`Mock scene`,firstText:s.find(e=>e.kind===`user`)?.text||``}}))}catch{}}r(t)};if(t===`rate-limited`){d({type:`text.delta`,text:`Framing a wide two-shot from the current blocking.`}),d({type:`quota`,plan:`Plus`,primary:{usedPercent:100,windowMinutes:300,resetAt:new Date(Date.now()+252e4).toISOString()},credits:{has:!1}}),d({type:`error`,code:`rate_limit`,message:LT.rate_limit,resetAt:new Date(Date.now()+252e4).toISOString()}),d({type:`done`}),c=null;return}if(t===`error`){d({type:`text.delta`,text:n?`Reading the scene first.`:`Capturing the viewport first.`}),d(n?{type:`tool.start`,callId:`call-1`,name:`inspect_studio`,label:`inspect studio`,args:{scope:`selection`}}:{type:`tool.start`,callId:`call-1`,name:`capture_blocking_frame`,label:`Capture blocking frame`,args:{shot:`current`}}),d({type:`tool.done`,callId:`call-1`,ok:!1,elapsedMs:812,error:n?`The scene is not ready`:`Viewport is not ready`}),d({type:`error`,code:`upstream`,message:LT.upstream}),d({type:`done`}),c=null;return}for(let e of n?lE:sE){if(a?.aborted||(await i(e.delay),a?.aborted))break;d(e.event)}c=null,await i(240),a?.aborted&&d({type:`done`})}}}function vE(e={}){let t=e.mockConfig===void 0?aE():e.mockConfig;return t?_E({surface:e.surface,...t}):iE(e)}function yE(e){let t=e?.outcome;return t?.status===`already_applied`?null:t&&t.mutated===!1?{status:`not_applied`,code:t.code??`CANCELLED`,mutated:!1}:{status:`unknown`,code:t?.code??null,mutated:`unknown`}}function bE(e){return new Promise(t=>{let n=r=>{r.detail?.requestId===e.requestId&&(globalThis.removeEventListener(`cozyclay:agent-image-result`,n),t({ok:!!r.detail.ok,error:r.detail.error,receiptId:r.detail.receiptId}))};globalThis.addEventListener?.(`cozyclay:agent-image-result`,n),!(globalThis.dispatchEvent&&!globalThis.dispatchEvent(new CustomEvent(`cozyclay:agent-image`,{cancelable:!0,detail:e})))&&(globalThis.removeEventListener?.(`cozyclay:agent-image-result`,n),t({ok:!1,error:`No editor accepted the image. Open the scene that should receive it.`}))})}function xE({transport:e,surface:t=`workflow`,buildContext:n=null,requestImageAction:i=null,onAuthLost:o=null,onReceipt:s=null,newId:c=sT,clock:l=()=>Date.now()}={}){let u=t===`studio`,d=new Set,f=new Set,p=new Set,m=null,h=null,g=null,_={sessionId:c(),turnId:null,draft:``,pendingAttachments:[],items:[],streaming:!1,quota:null,rateLimit:null,lastPrompt:``,turnStartedAt:null,lastTurn:null},v=e=>{_={..._,...e};for(let e of[...d])e(_)},y=e=>v({items:e(_.items)}),b=(e,t)=>y(n=>n.map(n=>e(n)?{...n,...t}:n)),x=e=>_.items.find(t=>t.kind===`job`&&t.jobId===e);function S(e){if(!e?.jobId||!a.jobStates.includes(e.state))return;let t=typeof e.progress==`number`&&Number.isFinite(e.progress)?Math.min(1,Math.max(0,e.progress)):null;y(n=>{let r=n.find(t=>t.kind===`job`&&t.jobId===e.jobId),i={kind:`job`,id:r?.id??`job:${e.jobId}`,jobId:e.jobId,commandId:e.commandId??r?.commandId??null,state:e.state,phase:typeof e.phase==`string`?e.phase:r?.phase??null,progress:t??r?.progress??null,verification:r?.verification??null,receiptId:r?.receiptId??null,outcome:r?.outcome??null,acceptance:e.state===`review_required`?r?.acceptance??{status:`required`}:r?.acceptance??null};return r?n.map(e=>e===r?i:e):[...n,i]})}function C(e){let t;try{t=r(e)}catch(e){y(t=>[...t,{kind:`failure`,id:c(),failure:{code:e?.code||`INVALID_RECEIPT`,message:e?.message||`The host returned an unreadable receipt.`,preserved:{authoredState:`unknown`},recovery:{action:`inspect`}}}]);return}if(t.ok===!1){let e=`failure:${t.commandId}:${t.code}`;if(f.has(e))return;f.add(e),y(n=>[...n.map(e=>e.kind===`job`&&e.commandId===t.commandId&&!uT(e.state)?{...e,state:`failed`,phase:t.phase,acceptance:null}:e),{kind:`failure`,id:e,failure:t}]);return}if(!f.has(t.receiptId)){f.add(t.receiptId),y(e=>[...e.map(e=>e.kind===`job`&&e.jobId===t.jobId?{...e,state:t.status===`installed`?`installed`:e.state,verification:t.verification??null,receiptId:t.receiptId,acceptance:t.explicitUnverifiedAcceptance?{status:`accepted`}:null}:e),{kind:`receipt`,id:`receipt:${t.receiptId}`,receiptId:t.receiptId,receipt:t,summary:pT(t)}]);try{s?.(t)}catch{}}}function w(e){if(h&&[`text.delta`,`tool.start`,`tool.done`,`image`,`job.state`,`job.progress`,`receipt`,`error`].includes(e?.type)&&(h.produced=!0),e?.type===`text.delta`){y(t=>{let n=t[t.length-1];return n?.kind===`assistant`?[...t.slice(0,-1),{...n,text:n.text+e.text}]:[...t,{kind:`assistant`,id:c(),text:e.text}]});return}if(e?.type===`tool.start`){y(t=>[...t,{kind:`tool`,id:e.callId||c(),callId:e.callId,name:e.name,label:e.label,args:e.args,status:`running`}]);return}if(e?.type===`tool.done`){b(t=>t.kind===`tool`&&t.callId===e.callId,{status:e.ok?`done`:`failed`,elapsedMs:e.elapsedMs,result:e.result,error:e.error});let t=e.result;if(e.ok&&t&&typeof t==`object`&&t.ok===!0&&typeof t.receiptId==`string`&&Array.isArray(t.affectedIds))try{s?.(t)}catch{}return}if(e?.type===`image`){y(t=>[...t,{kind:`image`,id:e.imageId||c(),imageId:e.imageId,dataUrl:e.dataUrl,width:e.width,height:e.height,prompt:e.prompt,placed:!1,apply:null}]);return}if(e?.type===`job.state`||e?.type===`job.progress`){S(e);return}if(e?.type===`receipt`){C(e.receipt);return}if(e?.type===`quota`){v({quota:{plan:e.plan,usedPercent:e.primary?.usedPercent,windowMinutes:e.primary?.windowMinutes,resetAt:e.primary?.resetAt,credits:e.credits}});return}if(e?.type!==`error`)return;let t={code:e.code||`upstream`,message:e.message||LT[e.code]||`The turn failed.`,...Number.isFinite(e.status)?{status:e.status}:{}};if(h&&(h.failure=t),e.code===`rate_limit`){v({rateLimit:{resetAt:e.resetAt||null,message:e.message||LT.rate_limit}});return}if(e.code===`auth`){o?.();return}y(e=>{let n=e.findLastIndex(e=>e.kind===`user`),r=e.findLastIndex((e,t)=>t>n&&e.kind===`tool`&&e.status===`failed`);return r===-1?[...e,{kind:`failure`,id:c(),failure:{...t,recovery:{action:`retry`,retryAllowed:!0}}}]:e.map((e,n)=>n===r?{...e,failure:t}:e)})}function T(e,t,n){if(!e||p.has(e))return;p.add(e);let r=!!t?.ok,i={apply:{requestId:e,status:r?`settled`:`failed`,error:r?null:t?.error||`The editor did not apply the image.`,receiptId:t?.receiptId??null}};r&&(i.placed=n===`place`),b(t=>t.kind===`image`&&t.apply?.requestId===e,i)}async function E(e,t){let n=_.items.find(t=>t.kind===`image`&&t.id===e);if(!n||n.apply?.status===`applying`||(t===`place`?n.placed:!n.placed))return;let r=c();b(t=>t.kind===`image`&&t.id===e,{apply:{requestId:r,status:`applying`,error:null,receiptId:null,startedAt:l()}});let a={action:t,requestId:r,imageId:n.imageId,dataUrl:n.dataUrl,width:n.width,height:n.height,prompt:n.prompt};try{T(r,await(i??bE)(a),t)}catch(e){T(r,{ok:!1,error:String(e?.message||e)},t)}}let D=()=>{f.clear(),p.clear(),v({sessionId:c(),turnId:null,items:[],pendingAttachments:[],rateLimit:null,lastPrompt:``,turnStartedAt:null,lastTurn:null})};return{getState:()=>_,subscribe(e){return d.add(e),()=>d.delete(e)},setDraft:e=>v({draft:String(e??``)}),addAttachments(e){let t=(Array.isArray(e)?e:[]).filter(e=>typeof e?.dataUrl==`string`&&e.dataUrl.startsWith(`data:image/`)).map(e=>({id:c(),dataUrl:e.dataUrl,...e.name?{name:String(e.name).slice(0,120)}:{}})),{attachments:n,rejected:r}=Jw(_.pendingAttachments,t,4),i=n.length-_.pendingAttachments.length;return v({pendingAttachments:n}),{added:i,rejected:r}},removeAttachment:e=>v({pendingAttachments:_.pendingAttachments.filter(t=>t.id!==e)}),clearAttachments:()=>v({pendingAttachments:[]}),async send(t,r={}){let i=String(t??``).trim();if(!i||_.streaming)return;let a=c(),o=u?n?.()??null:null;if(u&&!o){w({type:`error`,code:`upstream`,message:`The editor is not ready to describe the scene yet.`});return}let s=l(),d={produced:!1,failure:null};h=d;let f=(Array.isArray(r.attachments)?r.attachments:_.pendingAttachments).slice(0,4).map(({dataUrl:e,name:t})=>({dataUrl:e,...t?{name:t}:{}}));v({lastPrompt:i,rateLimit:null,turnId:a,streaming:!0,draft:``,pendingAttachments:[],turnStartedAt:s,lastTurn:null,items:[..._.items,{kind:`user`,id:c(),text:i,attachFrame:!!r.attachFrame,attachments:f}]}),m=new AbortController;let p=m.signal;try{await e.turn({onTurnId:e=>{g=e},...u?{surface:`studio`,turnId:a,context:o}:{},sessionId:_.sessionId,text:i,...f.length?{attachments:f}:{},attachFrame:!!r.attachFrame,model:r.model,effort:r.effort??void 0},w,p)}catch(e){p.aborted||w({type:`error`,code:`upstream`,message:String(e?.message||e)})}finally{if(m?.signal===p&&(m=null),h===d){g=null,!d.produced&&!d.failure&&!p.aborted&&(d.failure={code:`no_output`,message:`The turn ended without a response.`,recovery:{action:`retry`,retryAllowed:!0}},y(e=>[...e,{kind:`failure`,id:c(),failure:d.failure}]));let e=l();h=null,v({streaming:!1,turnStartedAt:null,lastTurn:{status:p.aborted?`stopped`:d.failure?`failed`:`done`,endedAt:e,durationMs:e-s,failure:d.failure}})}}},async steer(t,n={}){let r=String(t??``).trim();if(!r)return{ok:!1,code:`EMPTY`,message:``};if(!_.streaming||!g||typeof e.steer!=`function`)return{ok:!1,code:`NO_ACTIVE_TURN`,message:IT.NO_ACTIVE_TURN};let i=(Array.isArray(n.attachments)?n.attachments:_.pendingAttachments).slice(0,4).map(({dataUrl:e,name:t})=>({dataUrl:e,...t?{name:t}:{}}));try{await e.steer(g,{text:r,...i.length?{attachments:i}:{}})}catch(e){let t=typeof e?.code==`string`?e.code:`upstream`;return{ok:!1,code:t,message:IT[t]||String(e?.message||e)}}return v({draft:``,pendingAttachments:[],items:[..._.items,{kind:`user`,id:c(),text:r,steered:!0,attachments:i}]}),{ok:!0,code:null,message:``}},stop(){let t=[..._.items].reverse().find(e=>e.kind===`job`&&!uT(e.state));m?.abort(`agent-stop`),m=null;let n=u?{sessionId:_.sessionId,turnId:_.turnId,...t?{jobId:t.jobId}:{}}:_.sessionId;if(Promise.resolve(e.stop?.(n)).then(e=>{if(!t)return;let n=yE(e);n&&(b(e=>e.kind===`job`&&e.jobId===t.jobId&&!uT(e.state),{state:n.status===`not_applied`?`cancelled`:`reconciling`,phase:null,outcome:n,acceptance:null}),b(e=>e.kind===`tool`&&e.status===`running`,{status:`cancelled`,result:n,elapsedMs:null}))}).catch(()=>{}),!_.streaming){v({streaming:!1});return}let r=l();v({streaming:!1,turnStartedAt:null,lastTurn:{status:`stopped`,endedAt:r,durationMs:r-(_.turnStartedAt??r),failure:null}})},async acceptJob(t){let n=x(t);if(!(!n||n.acceptance?.status!==`required`)){b(e=>e.kind===`job`&&e.jobId===t,{acceptance:{status:`accepting`}});try{let n=await e.acceptJob?.({jobId:t,sessionId:_.sessionId,turnId:_.turnId});n?.receipt?C(n.receipt):b(e=>e.kind===`job`&&e.jobId===t,{acceptance:{status:`required`,error:`The host did not acknowledge the acceptance.`}})}catch(e){b(e=>e.kind===`job`&&e.jobId===t,{acceptance:{status:`required`,error:String(e?.message||e)}})}}},applyImage:e=>E(e,`place`),undoImage:e=>E(e,`remove`),acknowledgeImageAction:({requestId:e,ok:t,error:n,receiptId:r})=>{let i=_.items.find(t=>t.kind===`image`&&t.apply?.requestId===e);T(e,{ok:t,error:n,receiptId:r},i?.placed?`remove`:`place`)},clearRateLimit:()=>v({rateLimit:null}),clearContext:D,newSession:D,restore:(e,t=_.sessionId)=>{f.clear(),p.clear();let n=new Set,r=(Array.isArray(e)?e:[]).flatMap(e=>{if(e?.kind===`user`||e?.kind===`assistant`){let t=Array.isArray(e.attachments)?e.attachments.filter(e=>typeof e?.dataUrl==`string`):[];return[{kind:e.kind,id:c(),text:String(e.text??``),...t.length?{attachments:t}:{}}]}return e?.kind===`tool`?[{kind:`tool`,id:c(),callId:c(),name:e.name||`tool`,label:e.label,ok:e.ok,elapsedMs:e.elapsedMs,status:e.ok===!1?`failed`:`done`}]:e?.kind===`receipt`?e.receiptId&&n.has(e.receiptId)?[]:(e.receiptId&&(n.add(e.receiptId),f.add(e.receiptId)),[{kind:`receipt`,id:`receipt:${e.receiptId||c()}`,receiptId:e.receiptId,summary:e.summary||`Receipt`,receipt:{status:`applied`,warnings:[],verification:{status:`verified`}}}]):e?.kind===`failure`?[{kind:`failure`,id:c(),failure:{code:e.code||`upstream`,message:String(e.message||`The turn failed.`),recovery:{action:`retry`,retryAllowed:!0}}}]:[]}),i=[...r].reverse().find(e=>e.kind===`user`)?.text||``;return v({sessionId:t,turnId:null,items:r,rateLimit:null,lastPrompt:i,turnStartedAt:null,lastTurn:null,streaming:!1}),r}}}function SE(e,t=Date.now()){let n=Date.parse(e||``);if(!Number.isFinite(n))return`just now`;let r=Math.max(0,Math.floor((t-n)/1e3));if(r<60)return`just now`;let i=Math.floor(r/60);if(i<60)return`${i}m ago`;let a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function CE({tone:e,title:t}){return(0,$.jsx)(`span`,{className:`agent-status-dot ${e}`,title:t,"aria-hidden":`true`})}function wE({call:e,presentation:t,onRetry:n}){let r=e.status===`running`?`busy`:[`failed`,`cancelled`].includes(e.status)?`alert`:`ok`,i=Object.hasOwn(t.toolLabels,e.name),a=e.error?`error: ${e.error}`:JSON.stringify(e.result??e.args??{},null,2);return(0,$.jsxs)(`div`,{className:`agent-card agent-tool-card${e.status===`failed`?` failed`:``}`,"data-tool-status":e.status,"data-tool-name":e.name,children:[(0,$.jsxs)(`details`,{children:[(0,$.jsxs)(`summary`,{children:[(0,$.jsx)(CE,{tone:r,title:e.status}),(0,$.jsx)(`span`,{className:`agent-tool-label`,children:ST(e,t.toolLabels)}),i&&(0,$.jsx)(`span`,{className:`agent-tool-badge`,children:t.toolBadge}),(0,$.jsx)(`span`,{className:`agent-tool-elapsed`,children:e.status===`running`?`running…`:e.status===`cancelled`?e.result?.status===`not_applied`?`not applied`:`result unknown`:FT(e.elapsedMs)}),(0,$.jsx)(Tw,{size:12,"aria-hidden":`true`})]}),(0,$.jsx)(`pre`,{className:`agent-tool-detail`,children:a})]}),e.failure&&(0,$.jsxs)(`div`,{className:`agent-error`,role:`alert`,children:[(0,$.jsx)(`span`,{children:e.failure.message||LT[e.failure.code]||`The turn failed.`}),(0,$.jsxs)(`div`,{className:`agent-error-actions`,children:[(0,$.jsx)(`button`,{type:`button`,className:`agent-ghost-button agent-error-retry`,onClick:n,children:`Retry`}),(0,$.jsx)(`button`,{type:`button`,className:`agent-ghost-button agent-error-details`,onClick:e=>{let t=e.currentTarget.closest(`.agent-tool-card`)?.querySelector(`details`);t&&(t.open=!t.open)},children:`Details`})]})]})]})}function TE({image:e,onUse:t,onUndo:n,onRegenerate:r,onOpen:i}){let a=e.apply?.status===`applying`,o=e.apply?.status===`failed`;return(0,$.jsxs)(`div`,{className:`agent-card agent-image-card`,"data-image-id":e.imageId,"data-placed":e.placed?`true`:`false`,"data-apply-status":e.apply?.status||`idle`,children:[(0,$.jsx)(`figure`,{children:(0,$.jsx)(`img`,{src:e.dataUrl,width:e.width,height:e.height,alt:e.prompt||`Generated image`,onClick:()=>i(e)})}),e.placed?(0,$.jsxs)(`div`,{className:`agent-placed`,children:[(0,$.jsx)(CE,{tone:`ok`}),`Placed`,(0,$.jsx)(`button`,{type:`button`,className:`agent-image-undo`,disabled:a,onClick:()=>n(e),children:a?`Removing…`:`Undo`})]}):(0,$.jsxs)(`div`,{className:`agent-image-actions`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`primary agent-image-use`,disabled:a,onClick:()=>t(e),children:[(0,$.jsx)(vw,{size:11}),` `,a?`Applying…`:`Use in scene`]}),(0,$.jsxs)(`a`,{className:`agent-image-download`,role:`button`,href:e.dataUrl,download:`${e.imageId||`agent-image`}.png`,children:[(0,$.jsx)(xw,{size:11}),` Download`]}),(0,$.jsxs)(`button`,{type:`button`,className:`agent-image-regenerate`,onClick:()=>r(e),children:[(0,$.jsx)(dw,{size:11}),` Regenerate`]})]}),o&&(0,$.jsx)(`p`,{className:`agent-image-error`,role:`alert`,children:e.apply.error})]})}function EE({resetAt:e,onRetry:t,onSwitchModel:n}){let[r,i]=(0,Q.useState)(()=>Date.now());(0,Q.useEffect)(()=>{let e=setInterval(()=>i(Date.now()),1e3);return()=>clearInterval(e)},[]);let a=MT(e,r);return(0,$.jsxs)(`div`,{className:`agent-paused`,"data-agent-card":`rate-limited`,role:`status`,children:[(0,$.jsxs)(`div`,{className:`agent-paused-head`,children:[(0,$.jsx)(ww,{size:12,"aria-hidden":`true`}),` Paused — usage limit reached`,(0,$.jsx)(`span`,{className:`agent-paused-countdown`,children:a?`resets in ${a}`:`resets soon`})]}),(0,$.jsx)(`p`,{style:{margin:0},children:LT.rate_limit}),(0,$.jsxs)(`div`,{className:`agent-paused-actions`,children:[(0,$.jsx)(`button`,{type:`button`,className:`agent-paused-wait`,onClick:t,children:`Wait & retry`}),(0,$.jsx)(`button`,{type:`button`,className:`agent-paused-switch`,onClick:n,children:`Switch model`})]})]})}function DE({job:e,onStop:t,onAccept:n}){let r=!uT(e.state),i=r&&Number.isFinite(e.progress)?Math.round(e.progress*100):null,a=e.state===`installed`?null:e.phase,o=e.state===`review_required`||e.verification?.status===`unverified`,s=e.verification?.limitations??[],c=e.state===`installed`&&o?`Installed with warnings`:cT[e.state]||e.state;return(0,$.jsxs)(`div`,{className:`agent-card agent-job-card`,"data-job-id":e.jobId,"data-job-state":e.state,children:[(0,$.jsxs)(`div`,{className:`agent-job-head`,children:[(0,$.jsx)(CE,{tone:dT(e.state),title:e.state}),(0,$.jsx)(`span`,{className:`agent-job-label`,children:c}),o&&(0,$.jsx)(`span`,{className:`agent-job-badge`,children:`Unverified`}),i!==null&&(0,$.jsx)(`span`,{className:`agent-job-progress`,children:fT(e.progress)})]}),a&&(0,$.jsx)(`p`,{className:`agent-job-phase`,children:a}),e.outcome?.status===`not_applied`&&(0,$.jsx)(`p`,{className:`agent-job-outcome`,children:`Not applied — scene unchanged.`}),e.outcome?.status===`unknown`&&(0,$.jsx)(`p`,{className:`agent-job-outcome`,children:`Stopped, but the result is unknown — reconcile before editing this target.`}),i!==null&&(0,$.jsx)(`div`,{className:`agent-job-bar`,role:`progressbar`,"aria-label":`Generation progress`,"aria-valuenow":i,"aria-valuemin":0,"aria-valuemax":100,children:(0,$.jsx)(`span`,{className:`agent-job-bar-fill`,style:{transform:`scaleX(${e.progress})`}})}),s.length>0&&(0,$.jsx)(`ul`,{className:`agent-job-limits`,children:s.map(e=>(0,$.jsx)(`li`,{children:e},e))}),(0,$.jsxs)(`div`,{className:`agent-job-actions`,children:[r&&e.state!==`review_required`&&(0,$.jsx)(`button`,{type:`button`,className:`agent-ghost-button agent-job-stop`,onClick:()=>t(e),children:`Stop`}),e.acceptance?.status===`required`&&(0,$.jsxs)(`button`,{type:`button`,className:`agent-ghost-button agent-job-accept`,onClick:()=>n(e),children:[(0,$.jsx)(kw,{size:11}),` Apply with warnings`]}),e.acceptance?.status===`accepting`&&(0,$.jsx)(`span`,{className:`agent-job-note`,children:`Applying…`}),e.acceptance?.status===`accepted`&&(0,$.jsxs)(`span`,{className:`agent-job-note`,children:[(0,$.jsx)(Ew,{size:11}),` Applied at your request`]}),e.acceptance?.error&&(0,$.jsx)(`span`,{className:`agent-job-note alert`,role:`alert`,children:e.acceptance.error})]})]})}function OE({item:e}){let{receipt:t={},summary:n}=e,r=t.verification?.status===`unverified`,i=t.verification?.limitations??[],a=t.warnings??[],o=t.status===`installed`&&r;return(0,$.jsxs)(`div`,{className:`agent-card agent-receipt-card`,"data-receipt-id":e.receiptId,"data-receipt-status":t.status,children:[(0,$.jsxs)(`div`,{className:`agent-receipt-head`,children:[(0,$.jsx)(CE,{tone:r?`warn`:`ok`,title:t.status}),o&&(0,$.jsx)(`span`,{className:`agent-job-label`,children:`Installed with warnings`}),(0,$.jsx)(`span`,{className:`agent-receipt-summary`,children:n})]}),(a.length>0||i.length>0)&&(0,$.jsxs)(`ul`,{className:`agent-receipt-notes`,children:[a.map(e=>(0,$.jsx)(`li`,{children:e.message||e.code},e.code)),i.map(e=>(0,$.jsx)(`li`,{children:e},e))]}),o&&(0,$.jsx)(`p`,{className:`agent-job-note`,children:`Undo with Cmd+Z or ask the agent.`})]})}var kE={none:`No recovery is available for this command.`,inspect:`Ask the agent to inspect the target before trying again.`,retry:`The same command can be retried.`,new_intent:`Tell the agent what to do with the changed target.`,reconcile:`The result is unknown; reconcile before changing this target.`,sign_in:`Sign in again to continue.`};function AE({failure:e,onRetry:t}){return(0,$.jsxs)(`div`,{className:`agent-card agent-failure-card`,"data-failure-code":e.code,role:`alert`,children:[(0,$.jsxs)(`div`,{className:`agent-failure-head`,children:[(0,$.jsx)(kw,{size:12,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`agent-failure-code`,children:e.code})]}),(0,$.jsx)(`p`,{className:`agent-failure-message`,children:e.message||`The command did not complete.`}),(0,$.jsxs)(`p`,{className:`agent-failure-recovery`,children:[kE[e.recovery?.action]||kE.none,e.preserved?.authoredState===`unchanged`?` Nothing in the scene changed.`:e.preserved?.authoredState===`unknown`?` Whether the scene changed is unknown.`:``]}),e.recovery?.retryAllowed&&(0,$.jsx)(`div`,{className:`agent-error-actions`,children:(0,$.jsx)(`button`,{type:`button`,className:`agent-ghost-button agent-error-retry`,onClick:t,children:`Retry`})})]})}function jE({provider:e,onSave:t,onRemove:n}){let[r,i]=(0,Q.useState)(``),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(``),l=e.authSource===`env`,u=e.authSource===`file`,d=`set by ${rE(e.id)}`,f=`agent-key-${e.id}`,p=async e=>{o(!0),c(``);try{await e(),i(``)}catch(e){c(e?.message||`The sidecar refused that key.`)}finally{o(!1)}};return(0,$.jsxs)(`div`,{className:`agent-key-row`,"data-provider":e.id,"data-provider-source":e.authSource||`none`,"data-provider-signed-in":e.signedIn?`true`:`false`,children:[(0,$.jsxs)(`div`,{className:`agent-key-head`,children:[(0,$.jsx)(CE,{tone:e.signedIn?`ok`:``,title:e.signedIn?`key configured`:`no key`}),(0,$.jsx)(`label`,{className:`agent-key-label`,htmlFor:f,children:e.label}),(0,$.jsx)(`span`,{className:`agent-key-source`,children:l?`environment`:u?`saved on this machine`:`no key`})]}),(0,$.jsxs)(`div`,{className:`agent-key-controls`,children:[(0,$.jsx)(`input`,{id:f,className:`agent-key-input`,type:`password`,autoComplete:`off`,spellCheck:`false`,"aria-label":`${e.label} API key`,placeholder:l?d:e.signedIn?`Replace key`:`Paste API key`,disabled:l||a,value:r,onChange:e=>{i(e.target.value),c(``)}}),(0,$.jsx)(`button`,{type:`button`,className:`agent-key-save`,disabled:l||a||!r.trim(),onClick:()=>p(()=>t(e.id,r)),children:`Save`}),u&&(0,$.jsx)(`button`,{type:`button`,className:`agent-ghost-button agent-key-remove`,disabled:a,onClick:()=>p(()=>n(e.id)),children:`Remove`})]}),s&&(0,$.jsx)(`p`,{className:`agent-key-error`,role:`alert`,children:s})]})}function ME({transport:e=null,sceneName:t=`CozyClay Scene`,defaultCollapsed:n=!1,onCollapsedChange:r=null,embedded:i=!1,hidden:a=!1,surface:o=`workflow`,buildContext:s=null,onImageAction:c=null,onI2vAction:l=null,onReceipt:u=null}){let d=(0,Q.useMemo)(()=>xT(o),[o]),f=(0,Q.useMemo)(()=>e||vE({surface:o}),[e,o]),p=f.mock?f.state:null,[m,h]=(0,Q.useState)(n),[g,_]=(0,Q.useState)(()=>d.persistWidth?wT():360),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(`loading`),[E,D]=(0,Q.useState)([]),[O,ee]=(0,Q.useState)([]),[k,te]=(0,Q.useState)(``),[ne,re]=(0,Q.useState)(`loading`),[ie,A]=(0,Q.useState)(null),j=(0,Q.useMemo)(()=>mT(E.find(e=>e.id===k)),[E,k]),M=(0,Q.useCallback)(e=>{te(e),A(null),OT(e)},[]),ae=(0,Q.useCallback)(e=>{let t=Array.isArray(e?.models)?e.models:[];if(!t.length)return!1;let n=Array.isArray(e?.providers)?e.providers:[];return ee(n),D(t),te(e=>jT(n,t,e)),re(`ready`),!0},[]),[oe,se]=(0,Q.useState)(!1),[ce,le]=(0,Q.useState)(null),[ue,de]=(0,Q.useState)(!1),[fe,pe]=(0,Q.useState)(null),[me,he]=(0,Q.useState)(()=>!i&&(globalThis.innerWidth||1440)<1100),[ge,_e]=(0,Q.useState)(!1),[ve,ye]=(0,Q.useState)(!1),[be,xe]=(0,Q.useState)([]),[Se,Ce]=(0,Q.useState)(`loading`),[we,Te]=(0,Q.useState)([]),[Ee,De]=(0,Q.useState)(``),[Oe,ke]=(0,Q.useState)(``),[Ae,je]=(0,Q.useState)(o!==`studio`),Me=(0,Q.useRef)(null),Ne=(0,Q.useRef)(null),Pe=(0,Q.useRef)(s);Pe.current=s;let Fe=(0,Q.useRef)(c);Fe.current=c;let Ie=(0,Q.useRef)(l);Ie.current=l;let Le=(0,Q.useRef)(u);Le.current=u;let N=(0,Q.useMemo)(()=>xE({transport:f,surface:o,buildContext:()=>Pe.current?.()??null,requestImageAction:e=>(Fe.current??f.applyImage?.bind(f)??bE)(e),onReceipt:e=>Le.current?.(e),onAuthLost:()=>T(`signed-out`)}),[o,f]),Re=(0,Q.useSyncExternalStore)(N.subscribe,N.getState,N.getState),{draft:ze,items:Be,pendingAttachments:Ve,quota:He,rateLimit:Ue,streaming:We}=Re;(0,Q.useEffect)(()=>{if(o!==`studio`){je(!0);return}let e=!1,t=null;try{t=globalThis.localStorage?.getItem(aT)}catch{}if(!t){je(!0);return}return(async()=>{try{let n=await f.loadSession(t);if(!Array.isArray(n?.transcript))throw Error(`missing transcript`);e||N.restore(n.transcript,n.sessionId||t)}catch{e||(N.newSession(),De(`Previous conversation could not be restored`))}finally{e||je(!0)}})(),()=>{e=!0}},[o,N,f]),(0,Q.useEffect)(()=>{if(!(o!==`studio`||!Ae))try{globalThis.localStorage?.setItem(aT,Re.sessionId)}catch{}},[Re.sessionId,Ae,o]);let[Ge,Ke]=(0,Q.useState)(()=>Date.now()),qe=k?UT(Re,{now:Ge,toolLabel:e=>ST(e,d.toolLabels)}):ne===`failed`?{phase:`no-model`,kind:`terminal`,tone:`alert`,text:`No model available — the agent service did not answer with one`,ticking:!1}:{phase:`models`,kind:`live`,tone:`busy`,text:`Loading models…`,ticking:!1};(0,Q.useEffect)(()=>{if(!qe.ticking)return;let e=setInterval(()=>Ke(Date.now()),500);return()=>clearInterval(e)},[qe.ticking]);let Je=(0,Q.useCallback)(e=>e?.signedIn||e?.providersConfigured>0?d.imageEntitlement&&e?.entitlements?.image===!1?`no-entitlement`:`ready`:e?.pending?`signing-in`:`signed-out`,[d]),Ye=(0,Q.useCallback)(async()=>{try{let e=await f.status();return C(e),T(Je(e)),e}catch{return T(`signed-out`),null}},[Je,f]),Xe=(0,Q.useCallback)(async()=>{try{let e=await f.providers?.();if(!Array.isArray(e))throw Error(`no provider list`);xe(e),Ce(`ready`)}catch{xe([]),Ce(`failed`)}},[f]),Ze=(0,Q.useCallback)(async()=>{let e=Ye();await Xe(),await e;try{ae(await f.models())}catch{}},[ae,Ye,Xe,f]);(0,Q.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await f.status();if(e)return;C(t),T(Je(t))}catch{e||T(`signed-out`)}try{let t=await f.models();if(e)return;if(!ae(t)){re(`failed`);return}}catch{e||re(`failed`)}})(),()=>{e=!0}},[ae,Je,f]),(0,Q.useEffect)(()=>{if(w!==`signing-in`)return;let e=()=>{document.visibilityState!==`hidden`&&Ze()};return window.addEventListener(`focus`,e),window.addEventListener(`cozyclay:agent-auth-return`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),window.removeEventListener(`cozyclay:agent-auth-return`,e),document.removeEventListener(`visibilitychange`,e)}},[w,Ze]),(0,Q.useEffect)(()=>{!p||w!==`ready`||!k||[`streaming`,`rate-limited`,`error`].includes(p)&&(Be.length||N.send(`Give me a wide two-shot of this scene`,{attachFrame:!1,model:k}))},[w,Be.length,p,k,N]),(0,Q.useEffect)(()=>{if(i)return;let e=()=>he((globalThis.innerWidth||1440)<iT);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[i]),(0,Q.useEffect)(()=>{if(i)return;let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`b`&&(e.preventDefault(),h(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i]),(0,Q.useEffect)(()=>{if(i)return;let e=()=>h(e=>!e);return window.addEventListener(`cozyclay:agent-panel-toggle`,e),()=>window.removeEventListener(`cozyclay:agent-panel-toggle`,e)},[i]),(0,Q.useEffect)(()=>{i||r?.(m)},[m,i,r]),(0,Q.useEffect)(()=>{if(a){Me.current&&Me.current===document.activeElement&&Me.current.blur();return}m||Me.current?.focus()},[w,m,a]),(0,Q.useEffect)(()=>{let e=Ne.current;e&&(e.scrollTop=e.scrollHeight)},[Be,We]);let Qe=(0,Q.useCallback)(e=>{e.preventDefault(),y(!0);let t=e.clientX,n=g,r=e=>_(CT(n+(t-e.clientX))),i=e=>{y(!1),window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,i),TT(CT(n+(t-e.clientX)))};window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,i)},[g]),$e=(0,Q.useCallback)(e=>{_(t=>{let n=CT(t+e);return TT(n),n})},[]),et=(0,Q.useCallback)(async e=>{let t=[],n=0;for(let r of e)try{t.push(await nT(r))}catch{n+=1}let r=t.length?N.addAttachments(t).rejected:0;le(r?zw:n?Vw:null)},[N]),tt=(0,Q.useCallback)(e=>{let{images:t,unsupported:n}=Gw(e);return t.length?(et(t),!0):(n&&le(Bw),n>0)},[et]),nt=(0,Q.useCallback)(e=>{tt(e.clipboardData)&&e.preventDefault()},[tt]),rt=(0,Q.useCallback)(e=>{Ww(e.dataTransfer)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,de(!0))},[]),it=(0,Q.useCallback)(e=>{e.currentTarget.contains(e.relatedTarget)||de(!1)},[]),at=(0,Q.useCallback)(e=>{de(!1),tt(e.dataTransfer)&&e.preventDefault()},[tt]),ot=(0,Q.useCallback)(e=>(le(null),ke(``),N.send(e,{attachFrame:oe,model:k,effort:ie??void 0})),[oe,ie,k,N]),st=(0,Q.useCallback)(()=>N.stop(),[N]),ct=(0,Q.useCallback)(async e=>{if(!String(e??``).trim())return;le(null),ke(``);let t=await N.steer(e);t.ok||ke(t.message||`The running turn did not take that message.`)},[N]),lt=(0,Q.useCallback)(async()=>{T(`signing-in`);try{await f.signIn(),await Ze()}catch{T(`signed-out`)}},[Ze,f]),ut=(0,Q.useCallback)(async()=>{x(!1),await f.signOut().catch(()=>{}),C(null),N.newSession(),await Ze()},[Ze,N,f]),dt=(0,Q.useCallback)(()=>{if(o===`studio`)try{globalThis.localStorage?.removeItem(aT)}catch{}N.newSession(),_e(!1),x(!1),Me.current?.focus()},[N,o]),ft=(0,Q.useCallback)(async()=>{if(o!==`studio`)return;let e=!ge;if(_e(e),e)try{Te(await f.listSessions())}catch{Te([])}},[ge,o,f]),pt=(0,Q.useCallback)(async e=>{try{let t=await f.loadSession(e);if(!Array.isArray(t?.transcript))throw Error(`missing transcript`);N.restore(t.transcript,t.sessionId||e),_e(!1),De(``)}catch{De(`Previous conversation could not be restored`)}},[N,f]),mt=(0,Q.useCallback)(()=>{x(!1);let e=!ve;ye(e),e&&(Ce(`loading`),Xe())},[ve,Xe]),ht=(0,Q.useCallback)(async(e,t)=>{await f.setProviderKey(e,t),await Ze()},[Ze,f]),gt=(0,Q.useCallback)(async e=>{await f.removeProviderKey(e),await Ze()},[Ze,f]),_t=(0,Q.useCallback)(()=>{N.clearContext(),x(!1)},[N]),vt=(0,Q.useCallback)(()=>{let e=E.filter(e=>AT(O,e.id)),t=e.length?e:E,n=t[(t.findIndex(e=>e.id===k)+1)%t.length];n&&M(n.id),N.clearRateLimit()},[M,k,O,E,N]),yt=(0,Q.useCallback)(e=>{if(e.key===`Escape`&&We){e.preventDefault(),st();return}if(e.key===`Enter`&&!e.shiftKey){if(e.preventDefault(),We){d.steer&&ct(ze);return}ot(ze)}},[ze,d,ot,ct,st,We]),bt=Ue?`rate-limited`:w===`ready`?We?`streaming`:Be.some(e=>e.kind===`tool`&&e.status===`failed`||e.kind===`failure`)?`error`:`ready`:w,xt={"signed-out":``,"signing-in":`busy`,"no-entitlement":`warn`,ready:`ok`,streaming:`busy`,"rate-limited":`warn`,error:`alert`}[bt]||``,St=MT(Ue?.resetAt||He?.resetAt),Ct=w===`ready`||w===`no-entitlement`,wt=bt===`rate-limited`||!k||!AT(O,k);return m&&!i?(0,$.jsxs)(`aside`,{className:`agent-panel collapsed`,"data-agent-state":bt,"data-agent-collapsed":`true`,"aria-label":`Agent panel, collapsed`,children:[(0,$.jsx)(`button`,{type:`button`,className:`agent-rail-toggle`,onClick:()=>h(!1),"aria-label":`Expand agent panel`,title:`Expand agent panel (Cmd/Ctrl+B)`,children:(0,$.jsx)(Tw,{size:13,style:{transform:`rotate(180deg)`}})}),(0,$.jsx)(CE,{tone:xt,title:bt}),(0,$.jsx)(`span`,{className:`agent-rail-label`,children:`Agent`})]}):(0,$.jsxs)(`aside`,{className:`agent-panel${v?` resizing`:``}${me&&!i?` overlay`:``}${i?` embedded`:``}`,style:i?void 0:{width:`${g}px`},hidden:i&&a,"data-agent-state":bt,"data-agent-width":i?void 0:g,"data-agent-overlay":me&&!i?`true`:`false`,"data-agent-embedded":i?`true`:`false`,"aria-label":`Agent`,children:[!i&&(0,$.jsx)(`div`,{role:`separator`,"aria-label":`Resize agent panel`,"aria-orientation":`vertical`,"aria-valuenow":g,"aria-valuemin":300,"aria-valuemax":560,tabIndex:0,className:`agent-resize`,onPointerDown:Qe,onKeyDown:e=>{e.key===`ArrowLeft`&&(e.preventDefault(),$e(16)),e.key===`ArrowRight`&&(e.preventDefault(),$e(-16))}}),(0,$.jsxs)(`header`,{className:`agent-header`,children:[(0,$.jsx)(CE,{tone:xt,title:bt}),(0,$.jsx)(`h2`,{className:`agent-title`,children:`Agent`}),(0,$.jsx)(`span`,{className:`agent-header-spacer`}),(0,$.jsx)(`button`,{type:`button`,className:`agent-icon-button agent-new`,"aria-label":`New conversation`,title:`New conversation`,onClick:dt,children:(0,$.jsx)(fw,{size:14,"aria-hidden":`true`})}),d.history&&(0,$.jsxs)(`span`,{className:`agent-history-wrap`,children:[(0,$.jsx)(`button`,{type:`button`,className:`agent-icon-button agent-history`,"aria-label":`History`,title:`History`,"aria-haspopup":`listbox`,"aria-expanded":o===`studio`?ge:void 0,onClick:o===`studio`?ft:void 0,disabled:o!==`studio`,children:(0,$.jsx)(ww,{size:13,"aria-hidden":`true`})}),o===`studio`&&ge&&(0,$.jsx)(`div`,{className:`agent-history-popover`,role:`listbox`,"aria-label":`Agent history`,children:we.length?we.map(e=>(0,$.jsxs)(`button`,{type:`button`,role:`option`,className:`agent-history-item`,onClick:()=>pt(e.sessionId),children:[(0,$.jsx)(`span`,{className:`agent-history-time`,children:SE(e.updatedAt)}),(0,$.jsx)(`span`,{className:`agent-history-text`,children:e.firstText||`Untitled conversation`})]},e.sessionId)):(0,$.jsx)(`span`,{className:`agent-history-empty`,children:`No previous conversations`})})]}),(0,$.jsxs)(`span`,{className:`agent-overflow`,children:[(0,$.jsx)(`button`,{type:`button`,className:`agent-icon-button agent-overflow-toggle`,"aria-haspopup":`menu`,"aria-expanded":b,"aria-label":`More agent actions`,onClick:()=>x(e=>!e),children:(0,$.jsx)(gw,{size:13})}),b&&(0,$.jsxs)(`div`,{className:`agent-menu`,role:`menu`,children:[S?.signedIn&&(0,$.jsxs)(`div`,{className:`agent-account`,role:`presentation`,children:[(0,$.jsx)(`span`,{className:`agent-account-email`,children:S.email}),(0,$.jsx)(`span`,{className:`agent-plan-badge`,children:He?.plan||S.plan||`Free`}),St&&(0,$.jsxs)(`span`,{className:`agent-account-reset`,children:[`resets in `,St]})]}),(0,$.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:_t,children:`Clear context`}),(0,$.jsx)(`button`,{type:`button`,role:`menuitem`,className:`agent-menu-keys`,"aria-expanded":ve,onClick:mt,children:`Provider keys…`}),(0,$.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:ut,children:`Sign out`})]})]}),!i&&(0,$.jsx)(`button`,{type:`button`,className:`agent-icon-button agent-collapse`,onClick:()=>h(!0),"aria-label":`Collapse agent panel`,title:`Collapse agent panel (Cmd/Ctrl+B)`,children:(0,$.jsx)(Tw,{size:13})})]}),Ee&&(0,$.jsx)(`div`,{className:`agent-toast`,role:`status`,children:Ee}),Oe&&(0,$.jsx)(`div`,{className:`agent-toast alert agent-steer-notice`,role:`alert`,children:Oe}),ve&&(0,$.jsxs)(`section`,{className:`agent-keys`,"aria-label":`Provider keys`,"data-agent-keys":`true`,children:[(0,$.jsxs)(`div`,{className:`agent-keys-head`,children:[(0,$.jsx)(`h3`,{className:`agent-keys-title`,children:`Provider keys`}),(0,$.jsx)(`button`,{type:`button`,className:`agent-icon-button agent-keys-close`,"aria-label":`Close provider keys`,onClick:()=>ye(!1),children:(0,$.jsx)(sw,{size:11,"aria-hidden":`true`})})]}),(0,$.jsx)(`p`,{className:`agent-keys-hint`,children:`Keys are stored by the local CozyClay service and are never shown again.`}),Se===`loading`&&(0,$.jsx)(`p`,{className:`agent-keys-note`,children:`Loading providers…`}),Se===`failed`&&(0,$.jsx)(`p`,{className:`agent-keys-note alert`,role:`alert`,children:`The provider list is unavailable.`}),be.filter(e=>e.id!==`openai-codex`).map(e=>(0,$.jsx)(jE,{provider:e,onSave:ht,onRemove:gt},e.id))]}),(0,$.jsxs)(`div`,{className:`agent-transcript`,ref:Ne,"aria-live":`polite`,"aria-label":`Conversation`,"data-agent-transcript":`true`,children:[w===`signed-out`&&(0,$.jsxs)(`div`,{className:`agent-state-card`,"data-agent-card":`signed-out`,children:[(0,$.jsx)(`h3`,{children:`Sign in with ChatGPT`}),(0,$.jsx)(`p`,{children:`The agent runs against your ChatGPT plan. Sign-in happens in your browser — no token is ever stored in this page.`}),(0,$.jsx)(`button`,{type:`button`,className:`agent-primary-button agent-signin`,onClick:lt,children:`Sign in with ChatGPT`})]}),w===`signing-in`&&(0,$.jsxs)(`div`,{className:`agent-state-card`,"data-agent-card":`signing-in`,children:[(0,$.jsx)(`span`,{className:`agent-spinner`,"aria-hidden":`true`}),(0,$.jsx)(`h3`,{children:`Waiting for your browser…`}),(0,$.jsx)(`p`,{children:`Finish the ChatGPT sign-in in the tab that just opened. This panel picks up the session when you come back.`})]}),w===`no-entitlement`&&(0,$.jsxs)(`div`,{className:`agent-state-card`,"data-agent-card":`no-entitlement`,children:[(0,$.jsx)(`h3`,{children:`Image generation is not on this plan`}),(0,$.jsxs)(`p`,{children:[`Signed in as `,S?.email||`your account`,`. Chat and tool calls work; image results need a plan with image generation.`]}),(0,$.jsx)(`button`,{type:`button`,className:`agent-primary-button`,onClick:()=>window.open(`https://chatgpt.com/#pricing`,`_blank`,`noopener,noreferrer`),children:`See plans`})]}),w===`ready`&&!Be.length&&!Ue&&(0,$.jsxs)(`div`,{className:`agent-state-card`,"data-agent-card":`ready`,children:[(0,$.jsx)(`h3`,{children:d.emptyTitle}),(0,$.jsx)(`p`,{children:d.emptyHint(t)}),(0,$.jsx)(`div`,{className:`agent-suggestions`,children:d.suggestions.map(e=>(0,$.jsx)(`button`,{type:`button`,className:`agent-chip`,onClick:()=>{N.setDraft(e),Me.current?.focus()},children:e},e))})]}),Be.map(e=>e.kind===`user`?(0,$.jsxs)(`div`,{className:`agent-row user`,children:[e.attachments?.length>0&&(0,$.jsx)(`div`,{className:`agent-bubble-attachments`,children:e.attachments.map((t,n)=>(0,$.jsx)(`img`,{src:t.dataUrl,alt:t.name||`Attached image`,onClick:()=>pe({dataUrl:t.dataUrl,prompt:t.name})},`${e.id}-${n}`))}),(0,$.jsx)(`div`,{className:`agent-bubble`,children:e.text})]},e.id):e.kind===`assistant`?(0,$.jsx)(`div`,{className:`agent-row assistant`,children:(0,$.jsxs)(`div`,{className:`agent-assistant-text`,children:[e.text,We&&(0,$.jsx)(`span`,{className:`agent-caret`,children:`▌`})]})},e.id):e.kind===`tool`?(0,$.jsx)(`div`,{className:`agent-row`,children:(0,$.jsx)(wE,{call:e,presentation:d,onRetry:()=>ot(Re.lastPrompt)})},e.id):e.kind===`job`?(0,$.jsx)(`div`,{className:`agent-row`,children:(0,$.jsx)(DE,{job:e,onStop:st,onAccept:e=>N.acceptJob(e.jobId)})},e.id):e.kind===`receipt`?(0,$.jsx)(`div`,{className:`agent-row`,children:(0,$.jsx)(OE,{item:e})},e.id):e.kind===`failure`?(0,$.jsx)(`div`,{className:`agent-row`,children:(0,$.jsx)(AE,{failure:e.failure,onRetry:()=>ot(Re.lastPrompt)})},e.id):(0,$.jsx)(`div`,{className:`agent-row`,children:(0,$.jsx)(TE,{image:e,onUse:e=>N.applyImage(e.id),onUndo:e=>N.undoImage(e.id),onRegenerate:()=>ot(Re.lastPrompt),onOpen:pe})},e.id)),Ue&&(0,$.jsx)(EE,{resetAt:Ue.resetAt,onRetry:()=>{N.clearRateLimit(),ot(Re.lastPrompt)},onSwitchModel:vt})]}),Ct&&(0,$.jsxs)(`div`,{className:`agent-activity`,"data-agent-activity":qe.phase,"data-agent-activity-kind":qe.kind,role:`status`,"aria-live":`polite`,children:[(0,$.jsx)(`span`,{className:`agent-activity-indicator ${qe.tone}`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`agent-activity-text`,children:qe.text})]}),Ct&&(0,$.jsxs)(`div`,{className:`agent-composer`,"data-agent-dropping":ue?`true`:`false`,onDragOver:wt?void 0:rt,onDragLeave:wt?void 0:it,onDrop:wt?void 0:at,children:[Ve.length>0&&(0,$.jsx)(`ul`,{className:`agent-attachments`,"aria-label":`Attached images`,children:Ve.map(e=>(0,$.jsxs)(`li`,{className:`agent-attachment`,children:[(0,$.jsx)(`img`,{src:e.dataUrl,alt:e.name||`Attached image`}),(0,$.jsx)(`button`,{type:`button`,className:`agent-attachment-remove`,"aria-label":`Remove ${e.name||`attached image`}`,onClick:()=>N.removeAttachment(e.id),children:(0,$.jsx)(sw,{size:10,"aria-hidden":`true`})})]},e.id))}),ce&&(0,$.jsx)(`p`,{className:`agent-attachment-notice`,role:`status`,children:ce}),(0,$.jsxs)(`div`,{className:`agent-field`,children:[(0,$.jsx)(`textarea`,{ref:Me,className:`agent-input`,"aria-label":`Message the agent`,placeholder:bt===`rate-limited`?`Composer is paused`:k?d.composerPlaceholder:`Waiting for the model list…`,value:ze,disabled:wt,onChange:e=>N.setDraft(e.target.value),onKeyDown:yt,onPaste:nt,onDragOver:rt,onDrop:at}),(0,$.jsxs)(`div`,{className:`agent-composer-controls`,children:[(0,$.jsx)(`button`,{type:`button`,className:`agent-attach-chip`,"aria-pressed":oe,"aria-label":`Attach current frame`,title:`Attach current frame`,onClick:()=>se(e=>!e),children:oe?(0,$.jsx)(`span`,{className:`agent-attach-thumb`,"aria-hidden":`true`}):(0,$.jsx)(mw,{size:13,"aria-hidden":`true`})}),(0,$.jsx)(`select`,{className:`agent-model-select`,"aria-label":`Model`,title:`Model`,value:k,disabled:!E.length,onChange:e=>M(e.target.value),children:O.length?O.map(e=>(0,$.jsx)(`optgroup`,{label:e.label,children:e.models.length?e.models.map(t=>(0,$.jsx)(`option`,{value:t.key,disabled:!e.signedIn,children:e.signedIn?t.label:`${t.label} — add key`},t.key)):(0,$.jsx)(`option`,{value:`${e.id}/`,disabled:!0,children:e.signedIn?`No models`:`No models — add key`})},e.id)):E.length?E.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.label},e.id)):(0,$.jsx)(`option`,{value:``,children:ne===`failed`?`No model available`:`Loading models…`})}),j.length>0&&(0,$.jsx)(`select`,{className:`agent-model-select agent-effort-select`,"aria-label":`Reasoning effort`,title:`Reasoning effort`,value:ie??j[0],onChange:e=>A(e.target.value),children:j.map((e,t)=>(0,$.jsx)(`option`,{value:e,title:t===0?`Default for this model`:void 0,children:e},e))}),(0,$.jsx)(`span`,{className:`agent-composer-spacer`,"aria-hidden":`true`}),o===`studio`&&Ie.current&&(0,$.jsx)(`button`,{type:`button`,className:`agent-attach-chip agent-i2v-action`,"data-testid":`i2v-agent-action`,"aria-label":`Generate motion`,title:`Generate motion from this message`,disabled:wt||!ze.trim()||We,onClick:()=>{let e=ze.trim();N.setDraft(``),Ie.current?.(e)},children:(0,$.jsx)(yw,{size:13,"aria-hidden":`true`})}),We?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{type:`button`,className:`agent-send stop agent-stop`,onClick:st,children:`Stop`}),d.steer&&(0,$.jsx)(`button`,{type:`button`,className:`agent-send agent-steer`,disabled:!ze.trim(),onClick:()=>ct(ze),children:`Steer`})]}):(0,$.jsx)(`button`,{type:`button`,className:`agent-send`,"aria-label":`Send`,title:`Send (Enter)`,disabled:wt||!ze.trim(),onClick:()=>ot(ze),children:(0,$.jsx)(Ow,{size:14,"aria-hidden":`true`})})]})]})]}),Ct&&d.imageHint&&(0,$.jsx)(`p`,{className:`agent-footer-hint`,children:d.imageHint}),fe&&(0,$.jsx)(`button`,{type:`button`,className:`agent-lightbox`,"aria-label":`Close image preview`,onClick:()=>pe(null),children:(0,$.jsx)(`img`,{src:fe.dataUrl,alt:fe.prompt||`Generated image`})})]})}var NE=`cozyclay:scene-change`,PE=`cozyclay.scene-playback.v1`,FE=`cozyclay:scene-playback`;function IE(e,t){return!e||typeof e!=`object`?!1:[e.assetId,e.sourceAssetId,e.matteAssetId].includes(t)}function LE(e,t,{height:n=kg,placement:r={},name:i=t?.name}={}){if(!t||!Kp(t.id))return{document:e,object:null,changed:!1,reason:`invalid-asset`};let a=e&&typeof e==`object`?e:wx(),o=Array.isArray(a.scenes)?a.scenes:[],s=Cx(o,a.activeSceneId);if(s<0||!o[s])return{document:a,object:null,changed:!1,reason:`no-active-scene`};let c=o[s],l=Array.isArray(c.objects)?c.objects:[];if(l.some(e=>IE(e,t.id)))return{document:a,object:null,changed:!1,reason:`already-in-scene`};let u=Jg({assetId:t.id,aspect:$p(t)??1,height:n,name:i},l,r);if(!u)return{document:a,object:null,changed:!1,reason:`cutout-failed`};let d=o.map((e,t)=>t===s?{...e,objects:[...l,u]}:e);return{document:{...a,version:Number.isInteger(a.version)?a.version:4,scenes:d},object:u,changed:!0,reason:`added`}}function RE(e,t,n={}){if(typeof t!=`string`||!t.trim()||!n||typeof n!=`object`)return{document:e,changed:!1,reason:`invalid-motion`};let r=e&&typeof e==`object`?e:wx(),i=Array.isArray(r.scenes)?r.scenes:[],a=Cx(i,r.activeSceneId);if(a<0||!i[a])return{document:r,changed:!1,reason:`no-active-scene`};let o=i[a],s=o.stage&&typeof o.stage==`object`?o.stage:{},c=Array.isArray(s.characters)?s.characters:[],l=c.find(e=>e?.id===t);if(!l)return{document:r,changed:!1,reason:`character-not-found`};let u=typeof n.url==`string`&&n.url?n.url:typeof n.objectUrl==`string`&&n.objectUrl?n.objectUrl:null;if(!u)return{document:r,changed:!1,reason:`motion-url-missing`};let d={...l.motionRef&&typeof l.motionRef==`object`?l.motionRef:{},...n.motionRef&&typeof n.motionRef==`object`?n.motionRef:{},url:u},f=c.map(e=>e?.id===t?{...e,motionRef:d}:e),p={...o,stage:{...s,characters:f}};return{document:{...r,scenes:i.map((e,t)=>t===a?p:e)},changed:!0,reason:`updated`,characterId:t,motionRef:d}}function zE(e,t,n={}){let r=RE(n.document??BE(n.storage),e,t);return r.changed&&VE(r.document,n),r}function BE(e=globalThis.localStorage){return Ox(e?.getItem?.(`cozyclay.scenes.v4`)??null).document}function VE(e,{storage:t=globalThis.localStorage,target:n=globalThis}={}){let r=e&&typeof e==`object`?e:wx(),i=kx(r);try{t?.setItem?.(Rb,i)}catch{}try{n?.dispatchEvent?.(new CustomEvent(NE,{detail:r}))}catch{}return r}function HE(e,{storage:t=globalThis.localStorage,target:n=globalThis}={}){if(typeof e!=`function`)return()=>{};let r=t=>{let n=t?.detail;n&&typeof n==`object`&&e(n,{source:`same-tab`})},i=t=>{if(t?.key!==`cozyclay.scenes.v4`||!t.newValue)return;let n=Ox(t.newValue);n.status===`corrupt`||n.status===`future`||!n.document||e(n.document,{source:`storage`})};return n?.addEventListener?.(NE,r),n?.addEventListener?.(`storage`,i),()=>{n?.removeEventListener?.(NE,r),n?.removeEventListener?.(`storage`,i)}}function UE(e,{storage:t=globalThis.localStorage,target:n=globalThis}={}){let r={activeSceneId:typeof e?.activeSceneId==`string`?e.activeSceneId:null,frame:Number.isFinite(Number(e?.frame))?Math.max(0,Math.round(Number(e.frame))):null,playing:typeof e?.playing==`boolean`&&e.playing,issuedAt:Date.now()};try{t?.setItem?.(PE,JSON.stringify(r))}catch{}try{n?.dispatchEvent?.(new CustomEvent(FE,{detail:r}))}catch{}return r}function WE(e,{storage:t=globalThis.localStorage,target:n=globalThis}={}){if(typeof e!=`function`)return()=>{};let r=t=>{try{let n=typeof t==`string`?JSON.parse(t):t;n&&typeof n==`object`&&e(n)}catch{}},i=e=>r(e?.detail),a=e=>{e?.key===`cozyclay.scene-playback.v1`&&e.newValue&&r(e.newValue)};return n?.addEventListener?.(FE,i),n?.addEventListener?.(`storage`,a),()=>{n?.removeEventListener?.(FE,i),n?.removeEventListener?.(`storage`,a)}}async function GE(e,{importer:t=am,remember:n=hC,importOptions:r}={}){return n(await t(e,{maxDimension:zp,...r||{}}))}async function KE(e,t={}){let n=await GE(e,t),r=LE(t.document??BE(t.storage),n,t);return r.changed&&VE(r.document,t),{...r,asset:n}}var qE=`follow the reference clip's framing and camera motion exactly`,JE=`clay previs, neutral look`,YE=`motion and blocking come from the reference; keep timing`;function XE(e){if(!Number.isFinite(e)||e<=0)return`normal`;let t=18/Math.tan(e*Math.PI/360);return t<=20?`wide`:t<=40?`normal`:`long`}function ZE(e){return`${Number(e.toFixed(2))}s`}function QE(e){let t=[];return e?.dolly&&t.push(`smooth dolly move`),e?.crane&&t.push(`gentle crane move`),e?.rail&&t.push(`sliding rail move`),t.length>0?t.join(`; `):`locked-off camera, no move`}var $E=[`front`,`front right`,`right`,`back right`,`back`,`back left`,`left`,`front left`];function eD(e){if(!Number.isFinite(e))return``;let t=(e%360+360)%360;return $E[Math.round(t/45)%8]}function tD(e){return Number.isFinite(e)?e>=50?`high`:e<=10?`low`:`level`:``}function nD(e){return Number.isFinite(e)?e>=.8?`strong`:e>=.35?`moderate`:`dim`:`moderate`}function rD(e){return e?`${[tD(e.elevationDeg),eD(e.azimuthDeg)].filter(Boolean).join(` `)||`even`} key light, ${nD(e.intensity)}`:`no key light, ambient fill`}function iD(e,t={}){let n=t.target===`video`?`video`:`image`,r=t.referenceOwnsCamera!==!1,i=Math.max(0,(e.frameRange?.end??0)-(e.frameRange?.start??0)+1)/(e.fps||24),a=typeof e.intent==`string`?e.intent.trim():``,o=[`SHOT: ${e.shotTitle||`untitled shot`}, ${ZE(i)}, ${e.aspect||``}`.trimEnd(),`LENS: ${e.focalMm}mm, ${XE(e.fovDeg)} shot`,r?`CAMERA: ${qE}`:`CAMERA: ${QE(e.cameraMove)}`,`LIGHT: ${rD(e.keyLight)}`,`CAST: ${(e.cast||[]).map(e=>e.name).join(`, `)||`none`}`,`LOOK: ${a||JE}`];return n===`video`&&o.push(`MOTION: ${YE}`),o.join(`
|
|
17
|
+
`)}export{RS as $,Ui as $a,Xd as $c,Pf as $i,di as $l,Jg as $n,as as $o,fm as $r,Df as $s,Db as $t,zC as A,_u as Aa,Qe as Ac,T as Ai,Hu as Al,ay as An,ra as Ao,og as Ar,Dl as As,Yb as At,yt as Au,qS as B,jf as Ba,ke as Bc,io as Bi,qt as Bl,Gv as Bn,ql as Bo,sm as Br,Br as Bs,bx as Bt,vl as Bu,pw as C,Rs as Ca,Ge as Cc,fu as Ci,G as Cl,Yy as Cn,qd as Co,t_ as Cr,Nl as Cs,Nx as Ct,dr as Cu,cw as D,fr as Da,Ye as Dc,Bs as Di,qi as Dl,$v as Dn,Ii as Do,Jh as Dr,jl as Ds,Lx as Dt,Ur as Du,lw as E,tf as Ea,Je as Ec,Vl as Ei,nr as El,Cy as En,Vi as Eo,Ih as Er,Fl as Es,Fx as Et,Xt as Eu,_C as F,Ce as Fa,Me as Fc,id as Fi,oa as Fl,oy as Fn,_t as Fo,Ip as Fr,ne as Fs,ax as Ft,F as Fu,eC as G,Ut as Ga,Ie as Gc,Es as Gi,ll as Gl,S_ as Gn,Uu as Go,nm as Gr,Mu as Gs,Sx as Gt,S as Gu,QS as H,Ms as Ha,st as Hc,af as Hi,Wt as Hl,sv as Hn,nl as Ho,lm as Hr,rl as Hs,fx as Ht,un as Hu,oC as I,we as Ia,Ne as Ic,Wf as Ii,Gt as Il,uy as In,$t as Io,Rp as Ir,re as Is,ux as It,Xf as Iu,zx as J,Cr as Ja,Dt as Jc,W as Ji,Qf as Jl,cg as Jn,qo as Jo,Kp as Jr,zf as Js,ix as Jt,g as Ju,GS as K,Ls as Ka,Fe as Kc,Lf as Ki,or as Kl,kg as Kn,ts as Ko,am as Kr,xo as Ks,xx as Kt,b as Ku,$S as L,Cs as La,Pe as Lc,wt as Li,zt as Ll,Kv as Ln,Qt as Lo,$p as Lr,te as Ls,Zb as Lt,dn as Lu,mC as M,Ft as Ma,Be as Mc,Ed as Mi,Pu as Ml,cy as Mn,vt as Mo,ag as Mr,ee as Ms,Rb as Mt,_l as Mu,gC as N,Lt as Na,N as Nc,rd as Ni,hf as Nl,fy as Nn,ht as No,jh as Nr,k as Ns,Cx as Nt,sn as Nu,KC as O,ur as Oa,Xe as Oc,fd as Oi,cl as Ol,ty as On,de as Oo,Xh as Or,kl as Os,Kb as Ot,pl as Ou,hC as P,su as Pa,Le as Pc,bd as Pi,ba as Pl,sy as Pn,gt as Po,oh as Pr,ie as Ps,yx as Pt,on as Pu,xS as Q,du as Qa,Ma as Qc,Ou as Qi,dl as Ql,Wg as Qn,os as Qo,em as Qr,ss as Qs,wb as Qt,aC as R,E as Ra,Et as Rc,Ko as Ri,Ht as Rl,Lv as Rn,Rt as Ro,cm as Rr,St as Rs,wx as Rt,xl as Ru,hw as S,Ul as Sa,it as Sc,tu as Si,le as Sl,Sy as Sn,qu as So,f_ as Sr,Na as Ss,yS as St,pr as Su,uw as T,ks as Ta,qe as Tc,zd as Ti,ro as Tl,Ty as Tn,zi as To,Eg as Tr,Ml as Ts,Ix as Tt,lr as Tu,ZS as U,Kt as Ua,Re as Uc,fi as Ui,$l as Ul,Z as Un,wr as Uo,Qp as Ur,Lu as Us,nx as Ut,P as Uu,sC as V,Gl as Va,ot as Vc,Jl as Vi,Vt as Vl,Wv as Vn,wa as Vo,gm as Vr,Xu as Vs,Ax as Vt,hn as Vu,KS as W,Bt as Wa,ze as Wc,Rf as Wi,w as Wl,E_ as Wn,yu as Wo,mm as Wr,pc as Ws,Ox as Wt,mn as Wu,pS as X,Ts as Xa,Oe as Xc,ce as Xi,Zt as Xl,yg as Xn,sc as Xo,Vp as Xr,xf as Xs,jb as Xt,ES as Y,_n as Ya,De as Yc,Ju as Yi,pd as Yl,Fg as Yn,oc as Yo,qp as Yr,Iu as Ys,Pb as Yt,Yx as Z,Qc as Za,El as Zc,iu as Zi,ul as Zl,vg as Zn,Il as Zo,hm as Zr,fs as Zs,Sb as Zt,Sw as _,ws as _a,nt as _c,yp as _i,gl as _l,ib as _n,hu as _o,Kg as _r,Hn as _s,WS as _t,B as _u,BE as a,$d as aa,lc as ac,Ep as ai,D as al,Qy as an,To as ao,Zg as ar,j as as,TS as at,Wd as au,vw as b,ic as ba,tt as bc,Bu as bi,Gf as bl,Xy as bn,It as bo,n_ as br,V as bs,Qx as bt,hs as bu,ME as c,Xn as ca,Zl as cc,$f as ci,al as cl,$y as cn,Jt as co,a_ as cr,cu as cs,SS as ct,se as cu,Mw as d,ys as da,ut as dc,hp as di,lt as dl,_b as dn,Ss as do,b_ as dr,ft as ds,zS as dt,ve as du,xs as ea,js as ec,pm as ei,Vu as el,Tb as en,U as eo,Xg as er,A as es,hS as et,fl as eu,jw as f,_s as fa,ct as fc,pp as fi,We as fl,fb as fn,me as fo,Tg as fr,mt as fs,US as ft,fe as fu,Cw as g,dd as ga,Ae as gc,gp as gi,Tl as gl,pb as gn,td as go,m_ as gr,Gu as gs,LS as gt,R as gu,Dw as h,Kf as ha,Se as hc,lp as hi,Zr as hl,rb as hn,tl as ho,p_ as hr,aa as hs,FS as ht,ue as hu,UE as i,O as ia,cc as ic,kp as ii,Ud as il,eb as in,gs as io,Yg as ir,ae as is,IS as it,Ri as iu,wC as j,ji as ja,at as jc,xd as ji,uc as jl,iy as jn,Hl as jo,Qh as jr,Al as js,zb as jt,bt as ju,RC as k,ao as ka,Ze as kc,Uf as ki,ef as kl,ly as kn,ta as ko,$h as kr,Ol as ks,Jb as kt,xt as ku,iE as l,en as la,Ve as lc,_p as li,He as ll,nb as ln,Ef as lo,v_ as lr,Ku as ls,vS as lt,ye as lu,Aw as m,As as ma,Tt as mc,ep as mi,jt as ml,ab as mn,Tf as mo,i_ as mr,C as ms,bS as mt,ge as mu,zE as n,qs as na,Y as nc,um as ni,Ee as nl,gb as nn,Xr as no,$g as nr,oe as ns,jS as nt,Hi as nu,HE as o,H as oa,z as oc,Ap as oi,Nt as ol,mb as on,Do as oo,e_ as or,kt as os,Zx as ot,Kd as ou,Nw as p,pu as pa,Ue as pc,vp as pi,Ot as pl,ob as pn,bu as po,wg as pr,pt as ps,mS as pt,he as pu,Rx as q,zs as qa,je as qc,Fi as qi,vu as ql,Dg as qn,pf as qo,Jp as qr,il as qs,kx as qt,v as qu,KE as r,Os as ra,Dd as rc,wp as ri,cr as rl,hb as rn,Yr as ro,y_ as rr,M as rs,VS as rt,Li as ru,WE as s,Yl as sa,Ql as sc,np as si,gn as sl,sb as sn,Jd as so,Cg as sr,At as ss,Xx as st,Sl as su,iD as t,Ds as ta,Td as tc,om as ti,Te as tl,Eb as tn,pe as to,qg as tr,Wl as ts,HS as tt,Bi as tu,Pw as u,vs as ua,xn as uc,fp as ui,dt as ul,Zy as un,Vr as uo,g_ as ur,ou as us,_S as ut,_e as uu,bw as v,bs as va,$e as vc,Ct as vi,mc as vl,vy as vn,er as vo,h_ as vr,nf as vs,MS as vt,sr as vu,fw as w,fc as wa,Ke as wc,Hd as wi,yf as wl,Dy as wn,_o as wo,hg as wr,Pl as ws,Px as wt,Yt as wu,_w as x,ac as xa,rt as xc,Bd as xi,Yc as xl,Ey as xn,co as xo,Rg as xr,Ga as xs,lS as xt,ms as xu,yw as y,gu as ya,et as yc,be as yi,ol as yl,_y as yn,Pt as yo,r_ as yr,Gn as ys,BS as yt,eu as yu,YS as z,zu as za,xe as zc,Kl as zi,cd as zl,gv as zn,Mt as zo,Xp as zr,Xl as zs,hx as zt,fn as zu};
|