UNPKG

3d-force-graph-vr

Version:

UI component for a 3D force-directed graph in VR

20 lines 315 kB
// Version 3.1.1 3d-force-graph-vr - https://github.com/vasturiano/3d-force-graph-vr
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("three")):"function"==typeof define&&define.amd?define(["three"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).ForceGraphVR=t(e.THREE)}(this,function(e){"use strict";function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function n(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(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 o(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?r(Object(o),!0).forEach(function(t){n(e,t,o[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):r(Object(o)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))})}return e}function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,a,s=[],c=!0,l=!1;try{if(i=(n=n.call(e)).next,0===t);else for(;!(c=(r=i.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,o=e}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(l)throw o}}return s}}(e,t)||s(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||s(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(e,n){if(e){if("string"==typeof e)return t(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,n):void 0}}function c(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function l(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if("function"==typeof t){var n=function e(){var n=!1;try{n=this instanceof e}catch{}return n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}),n}!function(e,t){void 0===t&&(t={});var n=t.insertAt;if("undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===n&&r.firstChild?r.insertBefore(o,r.firstChild):r.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}(".graph-nav-info {\n  position: absolute;\n  bottom: 5px;\n  width: 100%;\n  text-align: center;\n  color: slategrey;\n  opacity: 0.7;\n  font-size: 10px;\n  font-family: Sans-serif;\n  z-index: 1000;\n}");var u,d,h,f,p,g,m,y={};function v(){return h?d:(h=1,d=Object.assign(function(){},{FACE_1:0,FACE_2:1,FACE_3:2,FACE_4:3,L_SHOULDER_1:4,R_SHOULDER_1:5,L_SHOULDER_2:6,R_SHOULDER_2:7,SELECT:8,START:9,DPAD_UP:12,DPAD_DOWN:13,DPAD_LEFT:14,DPAD_RIGHT:15,VENDOR:16}))}function b(){if(m)return g;m=1;const e=v(),t=(p||(p=1,f=function(e,t,n){this.type=e,this.index=t,this.pressed=n.pressed,this.value=n.value}),f),n=.2,r="left",o="right",i=1,a=2;return g=AFRAME.registerComponent("gamepad-controls",{GamepadButton:e,schema:{enabled:{default:!0},rotationSensitivity:{default:2}},init:function(){const e=this.el.sceneEl;this.system=e.systems["tracked-controls"]||e.systems["tracked-controls-webxr"]||{controllers:[]},this.prevTime=window.performance.now(),this.buttons={};const t=this.el.object3D.rotation;this.pitch=new THREE.Object3D,this.pitch.rotation.x=t.x,this.yaw=new THREE.Object3D,this.yaw.position.y=10,this.yaw.rotation.y=t.y,this.yaw.add(this.pitch),this._lookVector=new THREE.Vector2,this._moveVector=new THREE.Vector2,this._dpadVector=new THREE.Vector2,e.addBehavior(this)},update:function(){this.tick()},tick:function(e,t){this.updateButtonState(),this.updateRotation(t)},remove:function(){},isVelocityActive:function(){if(!this.data.enabled||!this.isConnected())return!1;const e=this._dpadVector,t=this._moveVector;this.getDpad(e),this.getJoystick(i,t);const r=e.x||t.x,o=e.y||t.y;return Math.abs(r)>n||Math.abs(o)>n},getVelocityDelta:function(){const e=this._dpadVector,t=this._moveVector;this.getDpad(e),this.getJoystick(i,t);const r=e.x||t.x,o=e.y||t.y,a=new THREE.Vector3;return Math.abs(r)>n&&(a.x+=r),Math.abs(o)>n&&(a.z+=o),a},isRotationActive:function(){if(!this.data.enabled||!this.isConnected())return!1;const e=this._lookVector;return this.getJoystick(a,e),Math.abs(e.x)>n||Math.abs(e.y)>n},updateRotation:function(e){if(!this.isRotationActive())return;const t=this.data,r=this.yaw,o=this.pitch;r.rotation.y=this.el.object3D.rotation.y,o.rotation.x=this.el.object3D.rotation.x;const i=this._lookVector;this.getJoystick(a,i),Math.abs(i.x)<=n&&(i.x=0),Math.abs(i.y)<=n&&(i.y=0),i.multiplyScalar(t.rotationSensitivity*e/1e3),r.rotation.y-=i.x,o.rotation.x-=i.y,o.rotation.x=Math.max(-Math.PI/2,Math.min(Math.PI/2,o.rotation.x)),this.el.object3D.rotation.set(o.rotation.x,r.rotation.y,0)},updateButtonState:function(){const e=this.getGamepad(o);if(this.data.enabled&&e)for(var n=0;n<e.buttons.length;n++)e.buttons[n].pressed&&!this.buttons[n]?this.emit(new t("gamepadbuttondown",n,e.buttons[n])):!e.buttons[n].pressed&&this.buttons[n]&&this.emit(new t("gamepadbuttonup",n,e.buttons[n])),this.buttons[n]=e.buttons[n].pressed;else for(const e in this.buttons)this.buttons[e]=!1},emit:function(e){this.el.emit(e.type,e),this.el.emit(e.type+":"+e.index,new t(e.type,e.index,e))},getGamepad:function(){const e=[],t=[];return function(n){const r=this.el.sceneEl.components["proxy-controls"],o=r&&r.isConnected()&&r.getGamepad(0);if(o)return o;e.length=0;for(let t=0;t<this.system.controllers.length;t++){const r=this.system.controllers[t],o=r?r.gamepad:null;if(e.push(o),o&&r.handedness===n)return o}const i=navigator.getGamepads?navigator.getGamepads():t;for(let e=0;e<i.length;e++){const t=i[e];if(t&&t.hand===n)return t}return e[0]||i[0]}}(),getButton:function(e){return this.getGamepad(o).buttons[e]},getAxis:function(e){return this.getGamepad(e>1?o:r).axes[e]},getJoystick:function(e,t){const n=this.getGamepad(e===i?r:o);if(!n)return t.set(0,0);if("xr-standard"===n.mapping)switch(e){case i:return t.set(n.axes[2],n.axes[3]);case a:return t.set(n.axes[2],0)}else switch(e){case i:return t.set(n.axes[0],n.axes[1]);case a:return t.set(n.axes[2],n.axes[3])}throw new Error('Unexpected joystick index "%d".',e)},getDpad:function(t){const n=this.getGamepad(r);return n&&n.buttons[e.DPAD_RIGHT]?t.set((n.buttons[e.DPAD_RIGHT].pressed?1:0)+(n.buttons[e.DPAD_LEFT].pressed?-1:0),(n.buttons[e.DPAD_UP].pressed?-1:0)+(n.buttons[e.DPAD_DOWN].pressed?1:0)):t.set(0,0)},isConnected:function(){const e=this.getGamepad(r);return!(!e||!e.connected)},getID:function(){return this.getGamepad(r).id}}),g}var w,x,k,E,_,A,M,T={};function C(){return w||(w=1,function(e){var t="KeyboardEvent"in e;t||(e.KeyboardEvent=function(){throw TypeError("Illegal constructor")}),"DOM_KEY_LOCATION_STANDARD"in e.KeyboardEvent||(e.KeyboardEvent.DOM_KEY_LOCATION_STANDARD=0),"DOM_KEY_LOCATION_LEFT"in e.KeyboardEvent||(e.KeyboardEvent.DOM_KEY_LOCATION_LEFT=1),"DOM_KEY_LOCATION_RIGHT"in e.KeyboardEvent||(e.KeyboardEvent.DOM_KEY_LOCATION_RIGHT=2),"DOM_KEY_LOCATION_NUMPAD"in e.KeyboardEvent||(e.KeyboardEvent.DOM_KEY_LOCATION_NUMPAD=3);var n=window.KeyboardEvent.DOM_KEY_LOCATION_STANDARD,r=window.KeyboardEvent.DOM_KEY_LOCATION_LEFT,o=window.KeyboardEvent.DOM_KEY_LOCATION_RIGHT,i=window.KeyboardEvent.DOM_KEY_LOCATION_NUMPAD;function a(e,t){return-1!==String(e).indexOf(t)}var s=a(navigator.platform,"Win")?"win":a(navigator.platform,"Mac")?"mac":a(navigator.platform,"CrOS")?"cros":a(navigator.platform,"Linux")?"linux":a(navigator.userAgent,"iPad")||a(navigator.platform,"iPod")||a(navigator.platform,"iPhone")?"ios":"",c=a(navigator.userAgent,"Chrome/")?"chrome":a(navigator.vendor,"Apple")?"safari":a(navigator.userAgent,"MSIE")?"ie":a(navigator.userAgent,"Gecko/")?"moz":a(navigator.userAgent,"Opera/")?"opera":"",l=c+"-"+s;function u(e,t,n){l!==t&&c!==t&&s!==t||Object.keys(n).forEach(function(t){e[t]=n[t]})}var d={3:{code:"Cancel"},6:{code:"Help"},8:{code:"Backspace"},9:{code:"Tab"},12:{code:"Clear"},13:{code:"Enter"},16:{code:"Shift"},17:{code:"Control"},18:{code:"Alt"},19:{code:"Pause"},20:{code:"CapsLock"},21:{code:"KanaMode"},22:{code:"HangulMode"},23:{code:"JunjaMode"},24:{code:"FinalMode"},25:{code:"KanjiMode"},27:{code:"Escape"},28:{code:"Convert"},29:{code:"NonConvert"},30:{code:"Accept"},31:{code:"ModeChange"},32:{code:"Space"},33:{code:"PageUp"},34:{code:"PageDown"},35:{code:"End"},36:{code:"Home"},37:{code:"ArrowLeft"},38:{code:"ArrowUp"},39:{code:"ArrowRight"},40:{code:"ArrowDown"},41:{code:"Select"},42:{code:"Print"},43:{code:"Execute"},44:{code:"PrintScreen"},45:{code:"Insert"},46:{code:"Delete"},47:{code:"Help"},48:{code:"Digit0",keyCap:"0"},49:{code:"Digit1",keyCap:"1"},50:{code:"Digit2",keyCap:"2"},51:{code:"Digit3",keyCap:"3"},52:{code:"Digit4",keyCap:"4"},53:{code:"Digit5",keyCap:"5"},54:{code:"Digit6",keyCap:"6"},55:{code:"Digit7",keyCap:"7"},56:{code:"Digit8",keyCap:"8"},57:{code:"Digit9",keyCap:"9"},65:{code:"KeyA",keyCap:"a"},66:{code:"KeyB",keyCap:"b"},67:{code:"KeyC",keyCap:"c"},68:{code:"KeyD",keyCap:"d"},69:{code:"KeyE",keyCap:"e"},70:{code:"KeyF",keyCap:"f"},71:{code:"KeyG",keyCap:"g"},72:{code:"KeyH",keyCap:"h"},73:{code:"KeyI",keyCap:"i"},74:{code:"KeyJ",keyCap:"j"},75:{code:"KeyK",keyCap:"k"},76:{code:"KeyL",keyCap:"l"},77:{code:"KeyM",keyCap:"m"},78:{code:"KeyN",keyCap:"n"},79:{code:"KeyO",keyCap:"o"},80:{code:"KeyP",keyCap:"p"},81:{code:"KeyQ",keyCap:"q"},82:{code:"KeyR",keyCap:"r"},83:{code:"KeyS",keyCap:"s"},84:{code:"KeyT",keyCap:"t"},85:{code:"KeyU",keyCap:"u"},86:{code:"KeyV",keyCap:"v"},87:{code:"KeyW",keyCap:"w"},88:{code:"KeyX",keyCap:"x"},89:{code:"KeyY",keyCap:"y"},90:{code:"KeyZ",keyCap:"z"},91:{code:"OSLeft",location:r},92:{code:"OSRight",location:o},93:{code:"ContextMenu"},95:{code:"Standby"},96:{code:"Numpad0",keyCap:"0",location:i},97:{code:"Numpad1",keyCap:"1",location:i},98:{code:"Numpad2",keyCap:"2",location:i},99:{code:"Numpad3",keyCap:"3",location:i},100:{code:"Numpad4",keyCap:"4",location:i},101:{code:"Numpad5",keyCap:"5",location:i},102:{code:"Numpad6",keyCap:"6",location:i},103:{code:"Numpad7",keyCap:"7",location:i},104:{code:"Numpad8",keyCap:"8",location:i},105:{code:"Numpad9",keyCap:"9",location:i},106:{code:"NumpadMultiply",keyCap:"*",location:i},107:{code:"NumpadAdd",keyCap:"+",location:i},108:{code:"NumpadComma",keyCap:",",location:i},109:{code:"NumpadSubtract",keyCap:"-",location:i},110:{code:"NumpadDecimal",keyCap:".",location:i},111:{code:"NumpadDivide",keyCap:"/",location:i},112:{code:"F1"},113:{code:"F2"},114:{code:"F3"},115:{code:"F4"},116:{code:"F5"},117:{code:"F6"},118:{code:"F7"},119:{code:"F8"},120:{code:"F9"},121:{code:"F10"},122:{code:"F11"},123:{code:"F12"},124:{code:"F13"},125:{code:"F14"},126:{code:"F15"},127:{code:"F16"},128:{code:"F17"},129:{code:"F18"},130:{code:"F19"},131:{code:"F20"},132:{code:"F21"},133:{code:"F22"},134:{code:"F23"},135:{code:"F24"},144:{code:"NumLock",location:i},145:{code:"ScrollLock"},160:{code:"ShiftLeft",location:r},161:{code:"ShiftRight",location:o},162:{code:"ControlLeft",location:r},163:{code:"ControlRight",location:o},164:{code:"AltLeft",location:r},165:{code:"AltRight",location:o},166:{code:"BrowserBack"},167:{code:"BrowserForward"},168:{code:"BrowserRefresh"},169:{code:"BrowserStop"},170:{code:"BrowserSearch"},171:{code:"BrowserFavorites"},172:{code:"BrowserHome"},173:{code:"VolumeMute"},174:{code:"VolumeDown"},175:{code:"VolumeUp"},176:{code:"MediaTrackNext"},177:{code:"MediaTrackPrevious"},178:{code:"MediaStop"},179:{code:"MediaPlayPause"},180:{code:"LaunchMail"},181:{code:"MediaSelect"},182:{code:"LaunchApp1"},183:{code:"LaunchApp2"},186:{code:"Semicolon",keyCap:";"},187:{code:"Equal",keyCap:"="},188:{code:"Comma",keyCap:","},189:{code:"Minus",keyCap:"-"},190:{code:"Period",keyCap:"."},191:{code:"Slash",keyCap:"/"},192:{code:"Backquote",keyCap:"`"},219:{code:"BracketLeft",keyCap:"["},220:{code:"Backslash",keyCap:"\\"},221:{code:"BracketRight",keyCap:"]"},222:{code:"Quote",keyCap:"'"},226:{code:"IntlBackslash",keyCap:"\\"},229:{code:"Process"},246:{code:"Attn"},247:{code:"CrSel"},248:{code:"ExSel"},249:{code:"EraseEof"},250:{code:"Play"},251:{code:"ZoomToggle"},254:{code:"Clear"}};u(d,"moz",{59:{code:"Semicolon",keyCap:";"},61:{code:"Equal",keyCap:"="},107:{code:"Equal",keyCap:"="},109:{code:"Minus",keyCap:"-"},187:{code:"NumpadAdd",keyCap:"+",location:i},189:{code:"NumpadSubtract",keyCap:"-",location:i}}),u(d,"moz-mac",{12:{code:"NumLock",location:i},173:{code:"Minus",keyCap:"-"}}),u(d,"moz-win",{173:{code:"Minus",keyCap:"-"}}),u(d,"chrome-mac",{93:{code:"OSRight",location:o}}),u(d,"safari",{3:{code:"Enter"},25:{code:"Tab"}}),u(d,"ios",{10:{code:"Enter",location:n}}),u(d,"safari-mac",{91:{code:"OSLeft",location:r},93:{code:"OSRight",location:o},229:{code:"KeyQ",keyCap:"Q"}});var h={};"cros"===s&&(h["U+00A0"]={code:"ShiftLeft",location:r},h["U+00A1"]={code:"ShiftRight",location:o},h["U+00A2"]={code:"ControlLeft",location:r},h["U+00A3"]={code:"ControlRight",location:o},h["U+00A4"]={code:"AltLeft",location:r},h["U+00A5"]={code:"AltRight",location:o}),"chrome-mac"===l&&(h["U+0010"]={code:"ContextMenu"}),"safari-mac"===l&&(h["U+0010"]={code:"ContextMenu"}),"ios"===s&&(h["U+0010"]={code:"Function"},h["U+001C"]={code:"ArrowLeft"},h["U+001D"]={code:"ArrowRight"},h["U+001E"]={code:"ArrowUp"},h["U+001F"]={code:"ArrowDown"},h["U+0001"]={code:"Home"},h["U+0004"]={code:"End"},h["U+000B"]={code:"PageUp"},h["U+000C"]={code:"PageDown"});var f=[];f[r]={16:{code:"ShiftLeft",location:r},17:{code:"ControlLeft",location:r},18:{code:"AltLeft",location:r}},f[o]={16:{code:"ShiftRight",location:o},17:{code:"ControlRight",location:o},18:{code:"AltRight",location:o}},f[i]={13:{code:"NumpadEnter",location:i}},u(f[i],"moz",{109:{code:"NumpadSubtract",location:i},107:{code:"NumpadAdd",location:i}}),u(f[r],"moz-mac",{224:{code:"OSLeft",location:r}}),u(f[o],"moz-mac",{224:{code:"OSRight",location:o}}),u(f[o],"moz-win",{91:{code:"OSRight",location:o}}),u(f[o],"mac",{93:{code:"OSRight",location:o}}),u(f[i],"chrome-mac",{12:{code:"NumLock",location:i}}),u(f[i],"safari-mac",{12:{code:"NumLock",location:i},187:{code:"NumpadAdd",location:i},189:{code:"NumpadSubtract",location:i},190:{code:"NumpadDecimal",location:i},191:{code:"NumpadDivide",location:i}});var p={ShiftLeft:{key:"Shift"},ShiftRight:{key:"Shift"},ControlLeft:{key:"Control"},ControlRight:{key:"Control"},AltLeft:{key:"Alt"},AltRight:{key:"Alt"},OSLeft:{key:"OS"},OSRight:{key:"OS"},NumpadEnter:{key:"Enter"},Space:{key:" "},Digit0:{key:"0",shiftKey:")"},Digit1:{key:"1",shiftKey:"!"},Digit2:{key:"2",shiftKey:"@"},Digit3:{key:"3",shiftKey:"#"},Digit4:{key:"4",shiftKey:"$"},Digit5:{key:"5",shiftKey:"%"},Digit6:{key:"6",shiftKey:"^"},Digit7:{key:"7",shiftKey:"&"},Digit8:{key:"8",shiftKey:"*"},Digit9:{key:"9",shiftKey:"("},KeyA:{key:"a",shiftKey:"A"},KeyB:{key:"b",shiftKey:"B"},KeyC:{key:"c",shiftKey:"C"},KeyD:{key:"d",shiftKey:"D"},KeyE:{key:"e",shiftKey:"E"},KeyF:{key:"f",shiftKey:"F"},KeyG:{key:"g",shiftKey:"G"},KeyH:{key:"h",shiftKey:"H"},KeyI:{key:"i",shiftKey:"I"},KeyJ:{key:"j",shiftKey:"J"},KeyK:{key:"k",shiftKey:"K"},KeyL:{key:"l",shiftKey:"L"},KeyM:{key:"m",shiftKey:"M"},KeyN:{key:"n",shiftKey:"N"},KeyO:{key:"o",shiftKey:"O"},KeyP:{key:"p",shiftKey:"P"},KeyQ:{key:"q",shiftKey:"Q"},KeyR:{key:"r",shiftKey:"R"},KeyS:{key:"s",shiftKey:"S"},KeyT:{key:"t",shiftKey:"T"},KeyU:{key:"u",shiftKey:"U"},KeyV:{key:"v",shiftKey:"V"},KeyW:{key:"w",shiftKey:"W"},KeyX:{key:"x",shiftKey:"X"},KeyY:{key:"y",shiftKey:"Y"},KeyZ:{key:"z",shiftKey:"Z"},Numpad0:{key:"0"},Numpad1:{key:"1"},Numpad2:{key:"2"},Numpad3:{key:"3"},Numpad4:{key:"4"},Numpad5:{key:"5"},Numpad6:{key:"6"},Numpad7:{key:"7"},Numpad8:{key:"8"},Numpad9:{key:"9"},NumpadMultiply:{key:"*"},NumpadAdd:{key:"+"},NumpadComma:{key:","},NumpadSubtract:{key:"-"},NumpadDecimal:{key:"."},NumpadDivide:{key:"/"},Semicolon:{key:";",shiftKey:":"},Equal:{key:"=",shiftKey:"+"},Comma:{key:",",shiftKey:"<"},Minus:{key:"-",shiftKey:"_"},Period:{key:".",shiftKey:">"},Slash:{key:"/",shiftKey:"?"},Backquote:{key:"`",shiftKey:"~"},BracketLeft:{key:"[",shiftKey:"{"},Backslash:{key:"\\",shiftKey:"|"},BracketRight:{key:"]",shiftKey:"}"},Quote:{key:"'",shiftKey:'"'},IntlBackslash:{key:"\\",shiftKey:"|"}};u(p,"mac",{OSLeft:{key:"Meta"},OSRight:{key:"Meta"}});var g,m,y,v={Esc:"Escape",Nonconvert:"NonConvert",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Menu:"ContextMenu",MediaNextTrack:"MediaTrackNext",MediaPreviousTrack:"MediaTrackPrevious",SelectMedia:"MediaSelect",HalfWidth:"Hankaku",FullWidth:"Zenkaku",RomanCharacters:"Romaji",Crsel:"CrSel",Exsel:"ExSel",Zoom:"ZoomToggle"},b=(g=d,m="code",y={},Object.keys(g).forEach(function(e){var t=g[e];m in t&&(y[t[m]]=t)}),y);try{var w=t&&"location"in new KeyboardEvent("")}catch(e){}function x(e){var t="keyCode"in e?e.keyCode:"which"in e?e.which:0,n=function(){if(w||"keyLocation"in e){var n=w?e.location:e.keyLocation;if(n&&t in f[n])return f[n][t]}return"keyIdentifier"in e&&e.keyIdentifier in h?h[e.keyIdentifier]:t in d?d[t]:null}();if(!n)return null;var r,o=(r=p[n.code])?e.shiftKey&&"shiftKey"in r?r.shiftKey:r.key:n.code;return{code:n.code,key:o,location:n.location,keyCap:n.keyCap}}"KeyboardEvent"in e&&"defineProperty"in Object&&function(){function e(e,t,n){t in e||Object.defineProperty(e,t,n)}if(e(KeyboardEvent.prototype,"code",{get:function(){var e=x(this);return e?e.code:""}}),"key"in KeyboardEvent.prototype){var t=Object.getOwnPropertyDescriptor(KeyboardEvent.prototype,"key");Object.defineProperty(KeyboardEvent.prototype,"key",{get:function(){var e=t.get.call(this);return v.hasOwnProperty(e)?v[e]:e}})}e(KeyboardEvent.prototype,"key",{get:function(){var e=x(this);return e&&"key"in e?e.key:"Unidentified"}}),e(KeyboardEvent.prototype,"location",{get:function(){var e=x(this);return e&&"location"in e?e.location:n}}),e(KeyboardEvent.prototype,"locale",{get:function(){return""}})}(),"queryKeyCap"in e.KeyboardEvent||(e.KeyboardEvent.queryKeyCap=function(e,t){if(e=String(e),!b.hasOwnProperty(e))return"Undefined";if(t&&"en-us"!==String(t).toLowerCase())throw Error("Unsupported locale");var n=b[e];return n.keyCap||n.code||"Undefined"}),e.identifyKey=function(e){if(!("code"in e)){var t=x(e);e.code=t?t.code:"",e.key=t&&"key"in t?t.key:"Unidentified",e.location="location"in e?e.location:"keyLocation"in e?e.keyLocation:t&&"location"in t?t.location:n,e.locale=""}}}(window)),T}const N=(e,t)=>{const n=t.x-e.x,r=t.y-e.y;return Math.sqrt(n*n+r*r)},O=e=>e*(Math.PI/180),D=e=>e*(180/Math.PI),P=new Map,S=e=>{P.has(e)&&clearTimeout(P.get(e)),P.set(e,setTimeout(e,100))},L=(e,t,n)=>{const r=t.split(/[ ,]+/g);let o;for(let t=0;t<r.length;t+=1)o=r[t],e.addEventListener?e.addEventListener(o,n,!1):e.attachEvent&&e.attachEvent(o,n)},I=(e,t,n)=>{const r=t.split(/[ ,]+/g);let o;for(let t=0;t<r.length;t+=1)o=r[t],e.removeEventListener?e.removeEventListener(o,n):e.detachEvent&&e.detachEvent(o,n)},j=e=>(e.preventDefault(),e.type.match(/^touch/)?e.changedTouches:e),R=()=>({x:void 0!==window.pageXOffset?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,y:void 0!==window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop}),F=(e,t)=>{t.top||t.right||t.bottom||t.left?(e.style.top=t.top,e.style.right=t.right,e.style.bottom=t.bottom,e.style.left=t.left):(e.style.left=t.x+"px",e.style.top=t.y+"px")},B=(e,t,n)=>{const r=z(e);for(let e in r)if(r.hasOwnProperty(e))if("string"==typeof t)r[e]=t+" "+n;else{let o="";for(let e=0,r=t.length;e<r;e+=1)o+=t[e]+" "+n+", ";r[e]=o.slice(0,-2)}return r},z=e=>{const t={};t[e]="";return["webkit","Moz","o"].forEach(function(n){t[n+e.charAt(0).toUpperCase()+e.slice(1)]=""}),t},V=(e,t)=>{for(let n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e},U=(e,t)=>{if(e.length)for(let n=0,r=e.length;n<r;n+=1)t(e[n]);else t(e)};var G,H=!!("ontouchstart"in window),K=!!window.PointerEvent,q=!!window.MSPointerEvent,$={start:"mousedown",move:"mousemove",end:"mouseup"},W={};function X(){}function J(e,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=e,this.defaults={size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:.5,mode:"dynamic",zone:document.body,lockX:!1,lockY:!1,shape:"circle"},this.config(t),"dynamic"===this.options.mode&&(this.options.restOpacity=0),this.id=J.id,J.id+=1,this.buildEl().stylize(),this.instance={el:this.ui.el,on:this.on.bind(this),off:this.off.bind(this),show:this.show.bind(this),hide:this.hide.bind(this),add:this.addToDom.bind(this),remove:this.removeFromDom.bind(this),destroy:this.destroy.bind(this),setPosition:this.setPosition.bind(this),resetDirection:this.resetDirection.bind(this),computeDirection:this.computeDirection.bind(this),trigger:this.trigger.bind(this),position:this.position,frontPosition:this.frontPosition,ui:this.ui,identifier:this.identifier,id:this.id,options:this.options},this.instance}function Z(e,t){var n=this;n.nipples=[],n.idles=[],n.actives=[],n.ids=[],n.pressureIntervals={},n.manager=e,n.id=Z.id,Z.id+=1,n.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:.5,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},n.config(t),"static"!==n.options.mode&&"semi"!==n.options.mode||(n.options.multitouch=!1),n.options.multitouch||(n.options.maxNumberOfNipples=1);const r=getComputedStyle(n.options.zone.parentElement);return r&&"flex"===r.display&&(n.parentIsFlex=!0),n.updateBox(),n.prepareNipples(),n.bindings(),n.begin(),n.nipples}function Y(e){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=R(),t.config(e),t.prepareCollections();var n=function(){var e;t.collections.forEach(function(n){n.forEach(function(n){e=n.el.getBoundingClientRect(),n.position={x:t.scroll.x+e.left,y:t.scroll.y+e.top}})})};L(window,"resize",function(){S(n)});var r=function(){t.scroll=R()};return L(window,"scroll",function(){S(r)}),t.collections}K?G={start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"}:q?G={start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}:H?(G={start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},W=$):G=$,X.prototype.on=function(e,t){var n,r=this,o=e.split(/[ ,]+/g);r._handlers_=r._handlers_||{};for(var i=0;i<o.length;i+=1)n=o[i],r._handlers_[n]=r._handlers_[n]||[],r._handlers_[n].push(t);return r},X.prototype.off=function(e,t){var n=this;return n._handlers_=n._handlers_||{},void 0===e?n._handlers_={}:void 0===t?n._handlers_[e]=null:n._handlers_[e]&&n._handlers_[e].indexOf(t)>=0&&n._handlers_[e].splice(n._handlers_[e].indexOf(t),1),n},X.prototype.trigger=function(e,t){var n,r=this,o=e.split(/[ ,]+/g);r._handlers_=r._handlers_||{};for(var i=0;i<o.length;i+=1)n=o[i],r._handlers_[n]&&r._handlers_[n].length&&r._handlers_[n].forEach(function(e){e.call(r,{type:n,target:r},t)})},X.prototype.config=function(e){var t=this;t.options=t.defaults||{},e&&(t.options=((e,t)=>{const n={};for(let r in e)e.hasOwnProperty(r)&&t.hasOwnProperty(r)?n[r]=t[r]:e.hasOwnProperty(r)&&(n[r]=e[r]);return n})(t.options,e))},X.prototype.bindEvt=function(e,t){var n=this;return n._domHandlers_=n._domHandlers_||{},n._domHandlers_[t]=function(){"function"==typeof n["on"+t]?n["on"+t].apply(n,arguments):console.warn('[WARNING] : Missing "on'+t+'" handler.')},L(e,G[t],n._domHandlers_[t]),W[t]&&L(e,W[t],n._domHandlers_[t]),n},X.prototype.unbindEvt=function(e,t){var n=this;return n._domHandlers_=n._domHandlers_||{},I(e,G[t],n._domHandlers_[t]),W[t]&&I(e,W[t],n._domHandlers_[t]),delete n._domHandlers_[t],this},J.prototype=new X,J.constructor=J,J.id=0,J.prototype.buildEl=function(e){return this.ui={},this.options.dataOnly||(this.ui.el=document.createElement("div"),this.ui.back=document.createElement("div"),this.ui.front=document.createElement("div"),this.ui.el.className="nipple collection_"+this.collection.id,this.ui.back.className="back",this.ui.front.className="front",this.ui.el.setAttribute("id","nipple_"+this.collection.id+"_"+this.id),this.ui.el.appendChild(this.ui.back),this.ui.el.appendChild(this.ui.front)),this},J.prototype.stylize=function(){if(this.options.dataOnly)return this;var e=this.options.fadeTime+"ms",t=((e,t)=>{const n=z(e);for(let e in n)n.hasOwnProperty(e)&&(n[e]=t);return n})("borderRadius","50%"),n=B("transition","opacity",e),r={};return r.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},r.back={position:"absolute",display:"block",width:this.options.size+"px",height:this.options.size+"px",left:0,marginLeft:-this.options.size/2+"px",marginTop:-this.options.size/2+"px",background:this.options.color,opacity:".5"},r.front={width:this.options.size/2+"px",height:this.options.size/2+"px",position:"absolute",display:"block",left:0,marginLeft:-this.options.size/4+"px",marginTop:-this.options.size/4+"px",background:this.options.color,opacity:".5",transform:"translate(0px, 0px)"},V(r.el,n),"circle"===this.options.shape&&V(r.back,t),V(r.front,t),this.applyStyles(r),this},J.prototype.applyStyles=function(e){for(var t in this.ui)if(this.ui.hasOwnProperty(t))for(var n in e[t])this.ui[t].style[n]=e[t][n];return this},J.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)||this.options.zone.appendChild(this.ui.el),this},J.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)||this.options.zone.removeChild(this.ui.el),this},J.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()},J.prototype.show=function(e){var t=this;return t.options.dataOnly||(clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.addToDom(),t.restCallback(),setTimeout(function(){t.ui.el.style.opacity=1},0),t.showTimeout=setTimeout(function(){t.trigger("shown",t.instance),"function"==typeof e&&e.call(this)},t.options.fadeTime)),t},J.prototype.hide=function(e){var t=this;if(t.options.dataOnly)return t;if(t.ui.el.style.opacity=t.options.restOpacity,clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.removeTimeout=setTimeout(function(){var n="dynamic"===t.options.mode?"none":"block";t.ui.el.style.display=n,"function"==typeof e&&e.call(t),t.trigger("hidden",t.instance)},t.options.fadeTime),t.options.restJoystick){const n=t.options.restJoystick,r={};r.x=!0===n||!1!==n.x?0:t.instance.frontPosition.x,r.y=!0===n||!1!==n.y?0:t.instance.frontPosition.y,t.setPosition(e,r)}return t},J.prototype.setPosition=function(e,t){var n=this;n.frontPosition={x:t.x,y:t.y};var r=n.options.fadeTime+"ms",o={};o.front=B("transition",["transform"],r);var i={front:{}};i.front={transform:"translate("+n.frontPosition.x+"px,"+n.frontPosition.y+"px)"},n.applyStyles(o),n.applyStyles(i),n.restTimeout=setTimeout(function(){"function"==typeof e&&e.call(n),n.restCallback()},n.options.fadeTime)},J.prototype.restCallback=function(){var e=this,t={};t.front=B("transition","none",""),e.applyStyles(t),e.trigger("rested",e.instance)},J.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}},J.prototype.computeDirection=function(e){var t,n,r,o=e.angle.radian,i=Math.PI/4,a=Math.PI/2;if(o>i&&o<3*i&&!e.lockX?t="up":o>-i&&o<=i&&!e.lockY?t="left":o>3*-i&&o<=-i&&!e.lockX?t="down":e.lockY||(t="right"),e.lockY||(n=o>-a&&o<a?"left":"right"),e.lockX||(r=o>0?"up":"down"),e.force>this.options.threshold){var s,c={};for(s in this.direction)this.direction.hasOwnProperty(s)&&(c[s]=this.direction[s]);var l={};for(s in this.direction={x:n,y:r,angle:t},e.direction=this.direction,c)c[s]===this.direction[s]&&(l[s]=!0);if(l.x&&l.y&&l.angle)return e;l.x&&l.y||this.trigger("plain",e),l.x||this.trigger("plain:"+n,e),l.y||this.trigger("plain:"+r,e),l.angle||this.trigger("dir dir:"+t,e)}else this.resetDirection();return e},Z.prototype=new X,Z.constructor=Z,Z.id=0,Z.prototype.prepareNipples=function(){var e=this,t=e.nipples;t.on=e.on.bind(e),t.off=e.off.bind(e),t.options=e.options,t.destroy=e.destroy.bind(e),t.ids=e.ids,t.id=e.id,t.processOnMove=e.processOnMove.bind(e),t.processOnEnd=e.processOnEnd.bind(e),t.get=function(e){if(void 0===e)return t[0];for(var n=0,r=t.length;n<r;n+=1)if(t[n].identifier===e)return t[n];return!1}},Z.prototype.bindings=function(){var e=this;e.bindEvt(e.options.zone,"start"),e.options.zone.style.touchAction="none",e.options.zone.style.msTouchAction="none"},Z.prototype.begin=function(){var e=this,t=e.options;if("static"===t.mode){var n=e.createNipple(t.position,e.manager.getIdentifier());n.add(),e.idles.push(n)}},Z.prototype.createNipple=function(e,t){var n=this,r=n.manager.scroll,o={},i=n.options,a=n.parentIsFlex?r.x:r.x+n.box.left,s=n.parentIsFlex?r.y:r.y+n.box.top;if(e.x&&e.y)o={x:e.x-a,y:e.y-s};else if(e.top||e.right||e.bottom||e.left){var c=document.createElement("DIV");c.style.display="hidden",c.style.top=e.top,c.style.right=e.right,c.style.bottom=e.bottom,c.style.left=e.left,c.style.position="absolute",i.zone.appendChild(c);var l=c.getBoundingClientRect();i.zone.removeChild(c),o=e,e={x:l.left+r.x,y:l.top+r.y}}var u=new J(n,{color:i.color,size:i.size,threshold:i.threshold,fadeTime:i.fadeTime,dataOnly:i.dataOnly,restJoystick:i.restJoystick,restOpacity:i.restOpacity,mode:i.mode,identifier:t,position:e,zone:i.zone,frontPosition:{x:0,y:0},shape:i.shape});return i.dataOnly||(F(u.ui.el,o),F(u.ui.front,u.frontPosition)),n.nipples.push(u),n.trigger("added "+u.identifier+":added",u),n.manager.trigger("added "+u.identifier+":added",u),n.bindNipple(u),u},Z.prototype.updateBox=function(){this.box=this.options.zone.getBoundingClientRect()},Z.prototype.bindNipple=function(e){var t,n=this,r=function(e,r){t=e.type+" "+r.id+":"+e.type,n.trigger(t,r)};e.on("destroyed",n.onDestroyed.bind(n)),e.on("shown hidden rested dir plain",r),e.on("dir:up dir:right dir:down dir:left",r),e.on("plain:up plain:right plain:down plain:left",r)},Z.prototype.pressureFn=function(e,t,n){var r=this,o=0;clearInterval(r.pressureIntervals[n]),r.pressureIntervals[n]=setInterval(function(){var n=e.force||e.pressure||e.webkitForce||0;n!==o&&(t.trigger("pressure",n),r.trigger("pressure "+t.identifier+":pressure",n),o=n)}.bind(r),100)},Z.prototype.onstart=function(e){var t=this,n=t.options,r=e;e=j(e),t.updateBox();return U(e,function(o){t.actives.length<n.maxNumberOfNipples?t.processOnStart(o):r.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(n){if(Object.values(r.touches).findIndex(function(e){return e.identifier===n})<0){var o=[e[0]];o.identifier=n,t.processOnEnd(o)}}),t.actives.length<n.maxNumberOfNipples&&t.processOnStart(o))}),t.manager.bindDocument(),!1},Z.prototype.processOnStart=function(e){var t,n=this,r=n.options,o=n.manager.getIdentifier(e),i=e.force||e.pressure||e.webkitForce||0,a={x:e.pageX,y:e.pageY},s=n.getOrCreate(o,a);s.identifier!==o&&n.manager.removeIdentifier(s.identifier),s.identifier=o;var c=function(t){t.trigger("start",t),n.trigger("start "+t.id+":start",t),t.show(),i>0&&n.pressureFn(e,t,t.identifier),n.processOnMove(e)};if((t=n.idles.indexOf(s))>=0&&n.idles.splice(t,1),n.actives.push(s),n.ids.push(s.identifier),"semi"!==r.mode)c(s);else{if(!(N(a,s.position)<=r.catchDistance))return s.destroy(),void n.processOnStart(e);c(s)}return s},Z.prototype.getOrCreate=function(e,t){var n,r=this,o=r.options;return/(semi|static)/.test(o.mode)?(n=r.idles[0])?(r.idles.splice(0,1),n):"semi"===o.mode?r.createNipple(t,e):(console.warn("Coudln't find the needed nipple."),!1):n=r.createNipple(t,e)},Z.prototype.processOnMove=function(e){var t=this,n=t.options,r=t.manager.getIdentifier(e),o=t.nipples.get(r),i=t.manager.scroll;if((e=>isNaN(e.buttons)?0!==e.pressure:0!==e.buttons)(e)){if(!o)return console.error("Found zombie joystick with ID "+r),void t.manager.removeIdentifier(r);if(n.dynamicPage){var a=o.el.getBoundingClientRect();o.position={x:i.x+a.left,y:i.y+a.top}}o.identifier=r;var s=o.options.size/2,c={x:e.pageX,y:e.pageY};n.lockX&&(c.y=o.position.y),n.lockY&&(c.x=o.position.x);var l,u,d=N(c,o.position),h=((e,t)=>{const n=t.x-e.x,r=t.y-e.y;return D(Math.atan2(r,n))})(c,o.position),f=O(h),p=d/s,g={distance:d,position:c};if("circle"===o.options.shape?(l=Math.min(d,s),u=((e,t,n)=>{const r={x:0,y:0};return n=O(n),r.x=e.x-t*Math.cos(n),r.y=e.y-t*Math.sin(n),r})(o.position,l,h)):(u=((e,t,n)=>({x:Math.min(Math.max(e.x,t.x-n),t.x+n),y:Math.min(Math.max(e.y,t.y-n),t.y+n)}))(c,o.position,s),l=N(u,o.position)),n.follow){if(d>s){let e=c.x-u.x,n=c.y-u.y;o.position.x+=e,o.position.y+=n,o.el.style.top=o.position.y-(t.box.top+i.y)+"px",o.el.style.left=o.position.x-(t.box.left+i.x)+"px",d=N(c,o.position)}}else c=u,d=l;var m=c.x-o.position.x,y=c.y-o.position.y;o.frontPosition={x:m,y:y},n.dataOnly||(o.ui.front.style.transform="translate("+m+"px,"+y+"px)");var v={identifier:o.identifier,position:c,force:p,pressure:e.force||e.pressure||e.webkitForce||0,distance:d,angle:{radian:f,degree:h},vector:{x:m/s,y:-y/s},raw:g,instance:o,lockX:n.lockX,lockY:n.lockY};(v=o.computeDirection(v)).angle={radian:O(180-h),degree:180-h},o.trigger("move",v),t.trigger("move "+o.id+":move",v)}else this.processOnEnd(e)},Z.prototype.processOnEnd=function(e){var t=this,n=t.options,r=t.manager.getIdentifier(e),o=t.nipples.get(r),i=t.manager.removeIdentifier(o.identifier);o&&(n.dataOnly||o.hide(function(){"dynamic"===n.mode&&(o.trigger("removed",o),t.trigger("removed "+o.id+":removed",o),t.manager.trigger("removed "+o.id+":removed",o),o.destroy())}),clearInterval(t.pressureIntervals[o.identifier]),o.resetDirection(),o.trigger("end",o),t.trigger("end "+o.id+":end",o),t.ids.indexOf(o.identifier)>=0&&t.ids.splice(t.ids.indexOf(o.identifier),1),t.actives.indexOf(o)>=0&&t.actives.splice(t.actives.indexOf(o),1),/(semi|static)/.test(n.mode)?t.idles.push(o):t.nipples.indexOf(o)>=0&&t.nipples.splice(t.nipples.indexOf(o),1),t.manager.unbindDocument(),/(semi|static)/.test(n.mode)&&(t.manager.ids[i.id]=i.identifier))},Z.prototype.onDestroyed=function(e,t){var n=this;n.nipples.indexOf(t)>=0&&n.nipples.splice(n.nipples.indexOf(t),1),n.actives.indexOf(t)>=0&&n.actives.splice(n.actives.indexOf(t),1),n.idles.indexOf(t)>=0&&n.idles.splice(n.idles.indexOf(t),1),n.ids.indexOf(t.identifier)>=0&&n.ids.splice(n.ids.indexOf(t.identifier),1),n.manager.removeIdentifier(t.identifier),n.manager.unbindDocument()},Z.prototype.destroy=function(){var e=this;for(var t in e.unbindEvt(e.options.zone,"start"),e.nipples.forEach(function(e){e.destroy()}),e.pressureIntervals)e.pressureIntervals.hasOwnProperty(t)&&clearInterval(e.pressureIntervals[t]);e.trigger("destroyed",e.nipples),e.manager.unbindDocument(),e.off()},Y.prototype=new X,Y.constructor=Y,Y.prototype.prepareCollections=function(){var e=this;e.collections.create=e.create.bind(e),e.collections.on=e.on.bind(e),e.collections.off=e.off.bind(e),e.collections.destroy=e.destroy.bind(e),e.collections.get=function(t){var n;return e.collections.every(function(e){return!(n=e.get(t))}),n}},Y.prototype.create=function(e){return this.createCollection(e)},Y.prototype.createCollection=function(e){var t=this,n=new Z(t,e);return t.bindCollection(n),t.collections.push(n),n},Y.prototype.bindCollection=function(e){var t,n=this,r=function(e,r){t=e.type+" "+r.id+":"+e.type,n.trigger(t,r)};e.on("destroyed",n.onDestroyed.bind(n)),e.on("shown hidden rested dir plain",r),e.on("dir:up dir:right dir:down dir:left",r),e.on("plain:up plain:right plain:down plain:left",r)},Y.prototype.bindDocument=function(){var e=this;e.binded||(e.bindEvt(document,"move").bindEvt(document,"end"),e.binded=!0)},Y.prototype.unbindDocument=function(e){var t=this;Object.keys(t.ids).length&&!0!==e||(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)},Y.prototype.getIdentifier=function(e){var t;return e?void 0===(t=void 0===e.identifier?e.pointerId:e.identifier)&&(t=this.latest||0):t=this.index,void 0===this.ids[t]&&(this.ids[t]=this.index,this.index+=1),this.latest=t,this.ids[t]},Y.prototype.removeIdentifier=function(e){var t={};for(var n in this.ids)if(this.ids[n]===e){t.id=n,t.identifier=this.ids[n],delete this.ids[n];break}return t},Y.prototype.onmove=function(e){return this.onAny("move",e),!1},Y.prototype.onend=function(e){return this.onAny("end",e),!1},Y.prototype.oncancel=function(e){return this.onAny("end",e),!1},Y.prototype.onAny=function(e,t){var n,r=this,o="processOn"+e.charAt(0).toUpperCase()+e.slice(1);t=j(t);var i=function(e,t,n){n.ids.indexOf(t)>=0&&(n[o](e),e._found_=!0)};return U(t,function(e){n=r.getIdentifier(e),U(r.collections,i.bind(null,e,n)),e._found_||r.removeIdentifier(n)}),!1},Y.prototype.destroy=function(){var e=this;e.unbindDocument(!0),e.ids={},e.index=0,e.collections.forEach(function(e){e.destroy()}),e.off()},Y.prototype.onDestroyed=function(e,t){var n=this;if(n.collections.indexOf(t)<0)return!1;n.collections.splice(n.collections.indexOf(t),1)};const Q=new Y;var ee,te=function(e){return Q.create(e)};function ne(){return ee||(ee=1,u||(u=1,AFRAME.registerComponent("checkpoint-controls",{schema:{enabled:{default:!0},mode:{default:"teleport",oneOf:["teleport","animate"]},animateSpeed:{default:3}},init:function(){this.active=!0,this.checkpoint=null,this.isNavMeshConstrained=!1,this.offset=new THREE.Vector3,this.position=new THREE.Vector3,this.targetPosition=new THREE.Vector3},play:function(){this.active=!0},pause:function(){this.active=!1},setCheckpoint:function(e){const t=this.el;this.active&&this.checkpoint!==e&&(this.checkpoint&&t.emit("navigation-end",{checkpoint:this.checkpoint}),this.checkpoint=e,this.sync(),this.position.distanceTo(this.targetPosition)<.1?this.checkpoint=null:(t.emit("navigation-start",{checkpoint:e}),"teleport"===this.data.mode&&(this.el.setAttribute("position",this.targetPosition),this.checkpoint=null,t.emit("navigation-end",{checkpoint:e}),t.components["movement-controls"].updateNavLocation())))},isVelocityActive:function(){return!(!this.active||!this.checkpoint)},getVelocity:function(){if(!this.active)return;const e=this.data,t=this.offset,n=this.position,r=this.targetPosition,o=this.checkpoint;return this.sync(),n.distanceTo(r)<.1?(this.checkpoint=null,this.el.emit("navigation-end",{checkpoint:o}),t.set(0,0,0)):(t.setLength(e.animateSpeed),t)},sync:function(){const e=this.offset,t=this.position,n=this.targetPosition;t.copy(this.el.getAttribute("position")),this.checkpoint.object3D.getWorldPosition(n),n.add(this.checkpoint.components.checkpoint.getOffset()),e.copy(n).sub(t)}})),b(),function(){if(k)return x;k=1,C();const e=window.KeyboardEvent;x=AFRAME.registerComponent("keyboard-controls",{schema:{enabled:{default:!0},debug:{default:!1}},init:function(){this.dVelocity=new THREE.Vector3,this.localKeys={},this.listeners={keydown:this.onKeyDown.bind(this),keyup:this.onKeyUp.bind(this),blur:this.onBlur.bind(this),onContextMenu:this.onContextMenu.bind(this)}},isVelocityActive:function(){return this.data.enabled&&!!Object.keys(this.getKeys()).length},getVelocityDelta:function(){const e=this.data,t=this.getKeys();return this.dVelocity.set(0,0,0),e.enabled&&((t.KeyW||t.ArrowUp)&&(this.dVelocity.z-=1),(t.KeyA||t.ArrowLeft)&&(this.dVelocity.x-=1),(t.KeyS||t.ArrowDown)&&(this.dVelocity.z+=1),(t.KeyD||t.ArrowRight)&&(this.dVelocity.x+=1),t.ShiftLeft&&(this.dVelocity=this.dVelocity.multiplyScalar(2))),this.dVelocity.clone()},play:function(){this.attachEventListeners()},pause:function(){this.removeEventListeners()},attachEventListeners:function(){window.addEventListener("contextmenu",this.listeners.onContextMenu,!1),window.addEventListener("keydown",this.listeners.keydown,!1),window.addEventListener("keyup",this.listeners.keyup,!1),window.addEventListener("blur",this.listeners.blur,!1)},onContextMenu:function(){for(const e in this.localKeys)this.localKeys.hasOwnProperty(e)&&delete this.localKeys[e]},removeEventListeners:function(){window.removeEventListener("keydown",this.listeners.keydown),window.removeEventListener("keyup",this.listeners.keyup),window.removeEventListener("blur",this.listeners.blur)},onKeyDown:function(e){AFRAME.utils.shouldCaptureKeyEvent(e)&&(this.localKeys[e.code]=!0,this.emit(e))},onKeyUp:function(e){AFRAME.utils.shouldCaptureKeyEvent(e)&&(delete this.localKeys[e.code],this.emit(e))},onBlur:function(){for(const e in this.localKeys)this.localKeys.hasOwnProperty(e)&&delete this.localKeys[e]},emit:function(t){"__keyboard-controls-proxy"in t&&this.el.emit(t.type,t),this.el.emit(t.type+":"+t.code,new e(t.type,t)),this.data.debug&&console.log(t.type+":"+t.code)},isPressed:function(e){return e in this.getKeys()},getKeys:function(){return this.isProxied()?this.el.sceneEl.components["proxy-controls"].getKeyboard():this.localKeys},isProxied:function(){const e=this.el.sceneEl.components["proxy-controls"];return e&&e.isConnected()}})}(),E||(E=1,AFRAME.registerComponent("touch-controls",{schema:{enabled:{default:!0},reverseEnabled:{default:!0}},init:function(){this.dVelocity=new THREE.Vector3,this.bindMethods(),this.direction=0},play:function(){this.addEventListeners()},pause:function(){this.removeEventListeners(),this.dVelocity.set(0,0,0)},remove:function(){this.pause()},addEventListeners:function(){const e=this.el.sceneEl,t=e.canvas;if(!t)return void e.addEventListener("render-target-loaded",this.addEventListeners.bind(this));t.addEventListener("touchstart",this.onTouchStart,{passive:!0}),t.addEventListener("touchend",this.onTouchEnd,{passive:!0});const n=e.getAttribute("vr-mode-ui");n&&n.cardboardModeEnabled&&e.addEventListener("enter-vr",this.onEnterVR)},removeEventListeners:function(){const e=this.el.sceneEl&&this.el.sceneEl.canvas;e&&(e.removeEventListener("touchstart",this.onTouchStart),e.removeEventListener("touchend",this.onTouchEnd),this.el.sceneEl.removeEventListener("enter-vr",this.onEnterVR))},isVelocityActive:function(){return this.data.enabled&&!!this.direction},getVelocityDelta:function(){return this.dVelocity.z=this.direction,this.dVelocity.clone()},bindMethods:function(){this.onTouchStart=this.onTouchStart.bind(this),this.onTouchEnd=this.onTouchEnd.bind(this),this.onEnterVR=this.onEnterVR.bind(this)},onTouchStart:function(e){this.direction=-1,this.data.reverseEnabled&&e.touches&&2===e.touches.length&&(this.direction=1),e.preventDefault()},onTouchEnd:function(e){this.direction=0,e.preventDefault()},onEnterVR:function(){const e=this.el.sceneEl.xrSession;e&&(e.addEventListener("selectstart",this.onTouchStart),e.addEventListener("selectend",this.onTouchEnd))}})),function(){if(A)return _;A=1;const e="-controls";_=AFRAME.registerComponent("movement-controls",{dependencies:["rotation"],schema:{enabled:{default:!0},controls:{default:["gamepad","trackpad","keyboard","touch"]},speed:{default:.3,min:0},fly:{default:!1},constrainToNavMesh:{default:!1},camera:{default:"[movement-controls] [camera]",type:"selector"}},init:function(){const e=this.el;this.data.camera||(this.data.camera=e.querySelector("[camera]")),this.velocityCtrl=null,this.velocity=new THREE.Vector3,this.heading=new THREE.Quaternion,this.eventDetail={},this.navGroup=null,this.navNode=null,e.sceneEl.hasLoaded?this.injectControls():e.sceneEl.addEventListener("loaded",this.injectControls.bind(this))},update:function(t){const n=this.el,r=this.data,o=n.sceneEl.systems.nav;if(n.sceneEl.hasLoaded&&this.injectControls(),o&&r.constrainToNavMesh!==t.constrainToNavMesh&&(r.constrainToNavMesh?o.addAgent(this):o.removeAgent(this)),r.enabled!==t.enabled)for(let t=0;t<r.controls.length;t++){const n=r.controls[t]+e;this.el.setAttribute(n,{enabled:this.data.enabled})}},injectControls:function(){const t=this.data;for(let n=0;n<t.controls.length;n++){const r=t.controls[n]+e;this.el.setAttribute(r,{enabled:this.data.enabled})}},updateNavLocation:function(){this.navGroup=null,this.navNode=null},tick:function(){const e=new THREE.Vector3,t=new THREE.Vector3,n=new THREE.Vector3;return function(r,o){if(!o)return;const i=this.el,a=this.data;if(!a.enabled)return;this.updateVelocityCtrl();const s=this.velocityCtrl,c=this.velocity;if(s)if(o/1e3>.2?c.set(0,0,0):this.updateVelocity(o),a.constrainToNavMesh&&!1!==s.isNavMeshConstrained){if(c.lengthSq()<1e-5)return;e.copy(i.object3D.position),t.copy(c).multiplyScalar(o/1e3).add(e);const r=i.sceneEl.systems.nav;this.navGroup=null===this.navGroup?r.getGroup(e):this.navGroup,this.navNode=this.navNode||r.getNode(e,this.navGroup),this.navNode=r.clampStep(e,t,this.navGroup,this.navNode,n),i.object3D.position.copy(n)}else i.hasAttribute("velocity")?i.setAttribute("velocity",c):(i.object3D.position.x+=c.x*o/1e3,i.object3D.position.y+=c.y*o/1e3,i.object3D.position.z+=c.z*o/1e3)}}(),updateVelocityCtrl:function(){const t=this.data;if(t.enabled){for(let n=0,r=t.controls.length;n<r;n++){const r=this.el.components[t.controls[n]+e];if(r&&r.isVelocityActive())return void(this.velocityCtrl=r)}this.velocityCtrl=null}},updateVelocity:function(){const e=new THREE.Vector2,t=new THREE.Quaternion;return function(n){let r;const o=this.el,i=this.velocityCtrl,a=this.velocity,s=this.data;if(i){if(!i.getVelocityDelta){if(i.getVelocity)return void a.copy(i.getVelocity());if(i.getPositionDelta)return void a.copy(i.getPositionDelta(n).multiplyScalar(1e3/n));throw new Error("Incompatible movement controls: ",i)}r=i.getVelocityDelta(n)}if(o.hasAttribute("velocity")&&!s.constrainToNavMesh&&a.copy(this.el.getAttribute("velocity")),r&&s.enabled){const n=s.camera;t.copy(n.object3D.quaternion),t.premultiply(o.object3D.quaternion),r.applyQuaternion(t);const i=r.length();s.fly?(a.copy(r),a.multiplyScalar(16.66667*this.data.speed)):(e.set(r.x,r.z),e.setLength(i*this.data.speed*16.66667),a.x=e.x,a.y=0,a.z=e.y),0===a.x&&0===a.y&&0===a.z||(this.eventDetail.velocity=a,this.el.emit("moved",this.eventDetail))}}}()})}(),M||(M=1,AFRAME.registerComponent("trackpad-controls",{schema:{enabled:{default:!0},enableNegX:{default:!0},enablePosX:{default:!0},enableNegZ:{default:!0},enablePosZ:{default:!0},mode:{default:"touch",oneOf:["swipe","touch","press"]}},init:function(){this.dVelocity=new THREE.Vector3,this.zVel=0,this.xVel=0,this.bindMethods()},play:function(){this.addEventListeners()},pause:function(){this.removeEventListeners(),this.dVelocity.set(0,0,0)},remove:function(){this.pause()},addEventListeners:function(){const e=this.data,t=this.el.sceneEl;switch(t.addEventListener("axismove",this.onAxisMove),e.mode){case"swipe":case"touch":t.addEventListener("trackpadtouchstart",this.onTouchStart),t.addEventListener("trackpadtouchend",this.onTouchEnd);break;case"press":t.addEventListener("trackpaddown",this.onTouchStart),t.addEventListener("trackpadup",this.onTouchEnd)}},removeEventListeners:function(){const e=this.el.sceneEl;e.removeEventListener("axismove",this.onAxisMove),e.removeEventListener("trackpadtouchstart",this.onTouchStart),e.removeEventListener("trackpadtouchend",this.onTouchEnd),e.removeEventListener("trackpaddown",this.onTouchStart),e.removeEventListener("trackpadup",this.onTouchEnd)},isVelocityActive:function(){return this.data.enabled&&this.isMoving},getVelocityDelta:function(){return this.dVelocity.z=this.isMoving?-this.zVel:1,this.dVelocity.x=this.isMoving?this.xVel:1,this.dVelocity.clone()},bindMethods:function(){this.onTouchStart=this.onTouchStart.bind(this),this.onTouchEnd=this.onTouchEnd.bind(this),this.onAxisMove=this.onAxisMove.bind(this)},onTouchStart:function(e){switch(this.data.mode){case"swipe":this.canRecordAxis=!0,this.startingAxisData=[];break;case"touch":case"press":this.isMoving=!0}e.preventDefault()},onTouchEnd:function(e){"swipe"==this.data.mode&&(this.startingAxisData=[]),this.isMoving=!1,e.preventDefault()},onAxisMove:function(e){switch(this.data.mode){case"swipe":return this.handleSwipeAxis(e);case"touch":case"press":return this.handleTouchAxis(e)}},handleSwipeAxis:function(e){const t=this.data,n=e.detail.axis;if(0===this.startingAxisData.length&&this.canRecordAxis&&(this.canRecordAxis=!1,this.startingAxisData[0]=n[0],this.startingAxisData[1]=n[1]),this.startingAxisData.length>0){let e=0,r=0;t.enableNegX&&n[0]<this.startingAxisData[0]&&(e=-1),t.enablePosX&&n[0]>this.startingAxisData[0]&&(e=1),t.enablePosZ&&n[1]>this.startingAxisData[1]&&(r=-1),t.enableNegZ&&n[1]<this.startingAxisData[1]&&(r=1);const o=Math.abs(this.startingAxisData[1]-n[1]);Math.abs(this.startingAxisData[0]-n[0])>o?(this.zVel=0,this.xVel=e,this.isMoving=!0):(this.xVel=0,this.zVel=r,this.isMoving=!0)}},handleTouchAxis:function(e){const t=this.data,n=e.detail.axis;let r=0,o=0;t.enableNegX&&n[0]<0&&(r=-1),t.enablePosX&&n[0]>0&&(r=1),t.enablePosZ&&n[1]>0&&(o=-1),t.enableNegZ&&n[1]<0&&(o=1),Math.abs(n[0])>Math.abs(n[1])?(this.zVel=0,this.xVel=r):(this.xVel=0,this.zVel=o)}}))),y}AFRAME.registerComponent("nipple-controls",{schema:{enabled:{default:!0},mode:{default:"dynamic",oneOf:["static","semi","dynamic"]},rotationSensitivity:{default:1},moveJoystickEnabled:{default:!0},lookJoystickEnabled:{default:!0},sideMargin:{default:"30px"},bottomMargin:{default:"70px"},moveJoystickPosition:{default:"left",oneOf:["left","right"]},lookJoystickPosition:{default:"right",oneOf:["left","right"]}},init(){this.dVelocity=new THREE.Vector3,this.lookVector=new THREE.Vector2;const e=this.el.querySelector("[look-controls]").components["look-controls"];this.pitchObject=e.pitchObject,this.yawObject=e.yawObject,this.rigRotation=this.el.object3D.rotation,this.moveData=void 0,this.lookData=void 0,this.moving=!1,this.rotating=!1},update(e){this.data.moveJoystickPosition===e.moveJoystickPosition&&this.data.sideMargin===e.sideMargin&&this.data.bottomMargin===e.bottomMargin&&this.data.mode===e.mode||this.removeMoveJoystick(),this.data.lookJoystickPosition===e.lookJoystickPosition&&this.data.sideMargin===e.sideMargin&&this.data.bottomMargin===e.bottomMargin&&this.data.mode===e.mode||this.removeLookJoystick(),this.data.enabled&&this.data.moveJoystickEnabled?this.createMoveJoystick():this.removeMoveJoystick(),this.data.enabled&&this.data.lookJoystickEnabled?this.createLookJoystick():this.removeLookJoystick()},pause(){this.moving=!1,this.rotating=!1},remove(){this.removeMoveJoystick(),this.removeLookJoystick()},isVelocityActive(){return this.data.enabled&&this.moving},getVelocityDelta(){if(this.dVelocity.set(0,0,0),this.isVelocityActive()){const e=this.moveData.force<1?this.moveData.force:1,t=this.moveData.angle.radian,n=Math.cos(t)*e,r=-Math.sin(t)*e;this.dVelocity.set(n,0,r)}return this.dVelocity},isRotationActive(){return this.data.enabled&&this.rotating},updateRotation(e){if(!this.isRotationActive())return;const t=this.lookData.force<1?this.lookData.force:1,n=this.lookData.angle.radian,r=this.lookVector;r.x=Math.cos(n)*t,r.y=Math.sin(n)*t,r.multiplyScalar(this.data.rotationSensitivity*e/1e3),this.yawObject.rotation.y-=r.x;let o=this.pitchObject.rotation.x+r.y;o=Math.max(-Math.PI/2,Math.min(Math.PI/2,o)),this.pitchObject.rotation.x=o},tick:function(e,t){this.updateRotation(t)},initLeftZone(){const e=document.createElement("div");e.setAttribute("id","joystickLeftZone"),e.setAttribute("style",`position:absolute;${this.data.moveJoystickPosition}:${this.data.sideMargin};bottom:${this.data.bottomMargin};z-index:1`),document.body.appendChild(e),this.leftZone=e},initRightZone(){const e=document.createElement("div");e.setAttribute("id","joystickRightZone"),e.setAttribute("style",`position:absolute;${this.data.lookJoystickPosition}:${this.data.sideMargin};bottom:${this.data.bottomMargin};z-index:1`),document.body.appendChild(e),this.rightZone=e},createMoveJoystick(){if(this.moveJoystick)return;this.initLeftZone();const e={mode:this.data.mode,zone:this.leftZone,color:"white",fadeTime:0};this.leftZone.style.width="100px","static"===this.data.mode?(this.leftZone.style.height="100px",e.position={left:"50%",bottom:"50%"}):this.leftZone.style.height="400px",this.moveJoystick=te(e),this.moveJoystick.on("move",(e,t)=>{this.moveData=t,this.moving=!0}),this.moveJoystick.on("end",(e,t)=>{this.moving=!1})},createLookJoystick(){if(this.lookJoystick)return;this.initRightZone();const e={mode:this.data.mode,zone:this.rightZone,color:"white",fadeTime:0};this.rightZone.style.width="100px","static"===this.data.mode?(this.rightZone.style.height="100px",e.position={left:"50%",bottom:"50%"}):this.rightZone.style.height="400px",this.lookJoystick=te(e),this.lookJoystick.on("move",(e,t)=>{this.lookData=t,this.rotating=!0}),this.lookJoystick.on("end",(e,t)=>{this.rotating=!1})},removeMoveJoystick(){this.moveJoystick&&(this.moveJoystick.destroy(),this.moveJoystick=void 0),this.moveData=void 0,this.leftZone&&this.leftZone.parentNode&&(this.leftZone.remove(),this.leftZone=void 0)},removeLookJoystick(){this.lookJoystick&&(this.lookJoystick.destroy(),this.lookJoystick=void 0),this.lookData=void 0,this.rightZone&&this.rightZone.parentNode&&(this.rightZone.remove(),this.rightZone=void 0)}});var re,oe,ie={};function ae(){if(oe)return re;oe=1;const e={once:THREE.LoopOnce,repeat:THREE.LoopRepeat,pingpong:THREE.LoopPingPong};function t(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")}return re=AFRAME.registerComponent("animation-mixer",{schema:{clip:{default:"*"},useRegExp:{default:!1},duration:{default:0},clampWhenFinished:{default:!1,type:"boolean"},crossFadeDuration:{default:0},loop:{default:"repeat",oneOf:Object.keys(e)},repetitions:{default:1/0,min:0},timeScale:{default:1},startAt:{default:0}},init:function(){this.model=null,this.mixer=null,this.activeActions=[];const e=this.el.getObject3D("mesh");e?this.load(e):this.el.addEventListener("model-loaded",e=>{this.load(e.detail.model)})},load:function(e){const t=this.el;this.model=e,this.mixer=new THREE.AnimationMixer(e),this.mixer.addEventListener("loop",e=>{t.emit("animation-loop",{action:e.action,loopDelta:e.loopDelta})}),this.mixer.addEventListener("finished",e=>{t.emit("animation-finished",{action:e.action,direction:e.direction})}),this.data.clip&&this.update({})},remove:function(){this.mixer&&this.mixer.stopAllAction()},update:function(t){if(!t)return;const n=this.data,r=AFRAME.utils.diff(n,t);if("clip"in r)return this.stopAction(),void(n.clip&&this.playAction());this.activeActions.forEach(t=>{"duration"in r&&n.duration&&t.setDuration(n.duration),"clampWhenFinished"in r&&(t.clampWhenFinished=n.clampWhenFinished),("loop"in r||"repetitions"in r)&&t.setLoop(e[n.loop],n.repetitions),"timeScale"in r&&t.setEffectiveTimeScale(n.timeScale)})},stopAction:function(){const e=this.data;for(let t=0;t<this.activeActions.length;t++)e.crossFadeDuration?this.activeActions[t].fadeOut(e.crossFadeDuration):this.activeActions[t].stop();this.activeActions.length=0},playAction:function(){if(!this.mixer)return;const n=this.model,r=this.data,o=n.animations||(n.geometry||{}).animations||[];if(!o.length)return;const i=r.useRegExp?r.clip:(a=r.clip,new RegExp("^"+a.split(/\*+/).map(t).join(".*")+"$"));var a;for(let t,a=0;t=o[a];a++)if(t.name.match(i)){const o=this.mixer.clipAction(t,n);o.enabled=!0,o.clampWhenFinished=r.clampWhenFinished,r.duration&&o.setDuration(r.duration),1!==r.timeScale&&o.setEffectiveTimeScale(r.timeScale),o.startAt(this.mixer.time-r.startAt/1e3),o.setLoop(e[r.loop],r.repetitions).fadeIn(r.crossFadeDuration).play(),this.activeActions.push(o)}},tick:function(e,t){this.mixer&&!isNaN(t)&&this.mixer.update(t/1e3)}}),re}class se extends e.DataTextureLoader{constructor(e){super(e)}parse(t){const n=0,r=1,o=2,i=3,a=9,s=10,c=11,l=48,u=4,d=0,h=1,f=2,p=3;if(t.length<19)throw new Error("THREE.TGALoader: Not enough data to contain header.");let g=0;const m=new Uint8Array(t),y={id_length:m[g++],colormap_type:m[g++],image_type:m[g++],colormap_index:m[g++]|m[g++]<<8,colormap_length:m[g++]|m[g++]<<8,colormap_size:m[g++],origin:[m[g++]|m[g++]<<8,m[g++]|m[g++]<<8],width:m[g++]|m[g++]<<8,height:m[g++]|m[g++]<<8,pixel_size:m[g++],flags:m[g++]};if(function(e){switch(e.image_type){case r:case a:if(e.colormap_length>256||24!==e.colormap_size||1!==e.colormap_type)throw new Error("THREE.TGALoader: Invalid type colormap data for indexed type.");break;case o:case i:case s:case c:if(e.colormap_type)throw new Error("THREE.TGALoader: Invalid type colormap data for colormap type.");break;case n:throw new Error("THREE.TGALoader: No data.");default:throw new Error("THREE.TGALoader: Invalid type "+e.image_type)}if(e.width<=0||e.height<=0)throw new Error("THREE.TGALoader: Invalid image size.");if(8!==e.pixel_size&&16!==e.pixel_size&&24!==e.pixel_size&&32!==e.pixel_size)throw new Error("THREE.TGALoader: Invalid pixel size "+e.pixel_size)}(y),y.id_length+g>t.length)throw new Error("THREE.TGALoader: No data.");g+=y.id_length;let v=!1,b=!1,w=!1;switch(y.image_type){case a:v=!0,b=!0;break;case r:b=!0;break;case s:v=!0;break;case o:break;case c:v=!0,w=!0;break;case i:w=!0}const x=new Uint8Array(y.width*y.height*4),k=function(e,t,n,r,o){let i,a;const s=n.pixel_size>>3,c=n.width*n.height*s;if(t&&(a=o.subarray(r,r+=n.colormap_length*(n.colormap_size>>3))),e){let e,t,n;i=new Uint8Array(c);let a=0;const l=new Uint8Array(s);for(;a<c;)if(e=o[r++],t=1+(127&e),128&e){for(n=0;n<s;++n)l[n]=o[r++];for(n=0;n<t;++n)i.set(l,a+n*s);a+=s*t}else{for(t*=s,n=0;n<t;++n)i[a+n]=o[r++];a+=t}}else i=o.subarray(r,r+=t?n.width*n.height:c);return{pixel_data:i,palettes:a}}(v,b,y,g,m);return function(e,t,n,r,o){let i,a,s,c,g,m;switch((y.flags&l)>>u){default:case f:i=0,s=1,g=t,a=0,c=1,m=n;break;case d:i=0,s=1,g=t,a=n-1,c=-1,m=-1;break;case p:i=t-1,s=-1,g=-1,a=0,c=1,m=n;break;case h:i=t-1,s=-1,g=-1,a=n-1,c=-1,m=-1}if(w)switch(y.pixel_size){case 8:!function(e,t,n,r,o,i,a,s){let c,l,u,d=0;const h=y.width;for(u=t;u!==r;u+=n)for(l=o;l!==a;l+=i,d++)c=s[d],e[4*(l+h*u)+0]=c,e[4*(l+h*u)+1]=c,e[4*(l+h*u)+2]=c,e[4*(l+h*u)+3]=255}(e,a,c,m,i,s,g,r);break;case 16:!function(e,t,n,r,o,i,a,s){let c,l,u=0;const d=y.width;for(l=t;l!==r;l+=n)for(c=o;c!==a;c+=i,u+=2)e[4*(c+d*l)+0]=s[u+0],e[4*(c+d*l)+1]=s[u+0],e[4*(c+d*l)+2]=s[u+0],e[4*(c+d*l)+3]=s[u+1]}(e,a,c,m,i,s,g,r);break;default:throw new Error("THREE.TGALoader: Format not supported.")}else switch(y.pixel_size){case 8:!function(e,t,n,r,o,i,a,s,c){const l=c;let u,d,h,f=0;const p=y.width;for(h=t;h!==r;h+=n)for(d=o;d!==a;d+=i,f++)u=s[f],e[4*(d+p*h)+3]=255,e[4*(d+p*h)+2]=l[3*u+0],e[4*(d+p*h)+1]=l[3*u+1],e[4*(d+p*h)+0]=l[3*u+2]}(e,a,c,m,i,s,g,r,o);break;case 16:!function(e,t,n,r,o,i,a,s){let c,l,u,d=0;const h=y.width;for(u=t;u!==r;u+=n)for(l=o;l!==a;l+=i,d+=2)c=s[d+0]+(s[d+1]<<8),e[4*(l+h*u)+0]=(31744&c)>>7,e[4*(l+h*u)+1]=(992&c)>>2,e[4*(l+h*u)+2]=(31&c)<<3,e[4*(l+h*u)+3]=32768&c?0:255}(e,a,c,m,i,s,g,r);break;case 24:!function(e,t,n,r,o,i,a,s){let c,l,u=0;const d=y.width;for(l=t;l!==r;l+=n)for(c=o;c!==a;c+=i,u+=3)e[4*(c+d*l)+3]=255,e[4*(c+d*l)+2]=s[u+0],e[4*(c+d*l)+1]=s[u+1],e[4*(c+d*l)+0]=s[u+2]}(e,a,c,m,i,s,g,r);break;case 32:!function(e,t,n,r,o,i,a,s){let c,l,u=0;const d=y.width;for(l=t;l!==r;l+=n)for(c=o;c!==a;c+=i,u+=4)e[4*(c+d*l)+2]=s[u+0],e[4*(c+d*l)+1]=s[u+1],e[4*(c+d*l)+0]=s[u+2],e[4*(c+d*l)+3]=s[u+3]}(e,a,c,m,i,s,g,r);break;default:throw new Error("THREE.TGALoader: Format not supported.")}}(x,y.width,y.height,k.pixel_data,k.palettes),{data:x,width:y.width,height:y.height,flipY:!0,generateMipmaps:!0,minFilter:e.LinearMipmapLinearFilter}}}class ce extends e.Loader{load(t,n,r,o){const i=this,a=""===i.path?e.LoaderUtils.extractUrlBase(t):i.path,s=new e.FileLoader(i.manager);s.setPath(i.path),s.setRequestHeader(i.requestHeader),s.setWithCredentials(i.withCredentials),s.load(t,function(e){try{n(i.parse(e,a))}catch(e){o?o(e):console.error(e),i.manager.itemError(t)}},r,o)}parse(t,n){function r(e,t){const n=[],r=e.childNodes;for(let e=0,o=r.length;e<o;e++){const o=r[e];o.nodeName===t&&n.push(o)}return n}function o(e){if(0===e.length)return[];const t=e.trim().split(/\s+/),n=new Array(t.length);for(let e=0,r=t.length;e<r;e++)n[e]=t[e];return n}function i(e){if(0===e.length)return[];const t=e.trim().split(/\s+/),n=new Array(t.length);for(let e=0,r=t.length;e<r;e++)n[e]=parseFloat(t[e]);return n}function a(e){if(0===e.length)return[];const t=e.trim().split(/\s+/),n=new Array(t.length);for(let e=0,r=t.length;e<r;e++)n[e]=parseInt(t[e]);return n}function s(e){return e.substring(1)}function c(){return"three_default_"+et++}function l(e){return 0===Object.keys(e).length}function u(e){return void 0!==e&&!0===e.hasAttribute("meter")?parseFloat(e.getAttribute("meter")):1}function d(e){return void 0!==e?e.textContent:"Y_UP"}function h(e,t,n,o){const i=r(e,t)[0];if(void 0!==i){const e=r(i,n);for(let t=0;t<e.length;t++)o(e[t])}}function f(e,t){for(const n in e){e[n].build=t(e[n])}}function p(e,t){return void 0!==e.build||(e.build=t(e)),e.build}function g(e){const t={inputs:{}};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"input"===r.nodeName){const e=s(r.getAttribute("source")),n=r.getAttribute("semantic");t.inputs[n]=e}}return t}function m(e){const t={};let n=e.getAttribute("target").split("/");const r=n.shift();let o=n.shift();const i=-1!==o.indexOf("("),a=-1!==o.indexOf(".");if(a)n=o.split("."),o=n.shift(),t.member=n.shift();else if(i){const e=o.split("(");o=e.shift();for(let t=0;t<e.length;t++)e[t]=parseInt(e[t].replace(/\)/,""));t.indices=e}return t.id=r,t.sid=o,t.arraySyntax=i,t.memberSyntax=a,t.sampler=s(e.getAttribute("source")),t}function y(e){const t=[],n=e.channels,r=e.samplers,o=e.sources;for(const e in n)if(n.hasOwnProperty(e)){const i=n[e],a=r[i.sampler],s=a.inputs.INPUT,c=a.inputs.OUTPUT;E(b(i,o[s],o[c]),t)}return t}function v(e){return p(tt.animations[e],y)}function b(e,t,n){const r=tt.nodes[e.id],o=ze(r.id),i=r.transforms[e.sid],a=r.matrix.clone().transpose();let s,c,l,u,d,h;const f={};switch(i){case"matrix":for(l=0,u=t.array.length;l<u;l++)if(s=t.array[l],c=l*n.stride,void 0===f[s]&&(f[s]={}),!0===e.arraySyntax){const t=n.array[c],r=e.indices[0]+4*e.indices[1];f[s][r]=t}else for(d=0,h=n.stride;d<h;d++)f[s][d]=n.array[c+d];break;case"translate":case"rotate":case"scale":console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.',i)}const p=function(e,t){const n=[];for(const t in e)n.push({time:parseFloat(t),value:e[t]});n.sort(r);for(let e=0;e<16;e++)_(n,e,t.elements[e]);return n;function r(e,t){return e.time-t.time}}(f,a);return{name:o.uuid,keyframes:p}}const w=new e.Vector3,x=new e.Vector3,k=new e.Quaternion;function E(t,n){const r=t.keyframes,o=t.name,i=[],a=[],s=[],c=[];for(let e=0,t=r.length;e<t;e++){const t=r[e],n=t.time,o=t.value;Ne.fromArray(o).transpose(),Ne.decompose(w,k,x),i.push(n),a.push(w.x,w.y,w.z),s.push(k.x,k.y,k.z,k.w),c.push(x.x,x.y,x.z)}return a.length>0&&n.push(new e.VectorKeyframeTrack(o+".position",i,a)),s.length>0&&n.push(new e.QuaternionKeyframeTrack(o+".quaternion",i,s)),c.length>0&&n.push(new e.VectorKeyframeTrack(o+".scale",i,c)),n}function _(e,t,n){let r,o,i,a=!0;for(o=0,i=e.length;o<i;o++)r=e[o],void 0===r.value[t]?r.value[t]=null:a=!1;if(!0===a)for(o=0,i=e.length;o<i;o++)r=e[o],r.value[t]=n;else!function(e,t){let n,r;for(let o=0,i=e.length;o<i;o++){const i=e[o];if(null===i.value[t]){if(n=A(e,o,t),r=M(e,o,t),null===n){i.value[t]=r.value[t];continue}if(null===r){i.value[t]=n.value[t];continue}T(i,n,r,t)}}}(e,t)}function A(e,t,n){for(;t>=0;){const r=e[t];if(null!==r.value[n])return r;t--}return null}function M(e,t,n){for(;t<e.length;){const r=e[t];if(null!==r.value[n])return r;t++}return null}function T(e,t,n,r){n.time-t.time!==0?e.value[r]=(e.time-t.time)*(n.value[r]-t.value[r])/(n.time-t.time)+t.value[r]:e.value[r]=t.value[r]}function C(t){const n=[],r=t.name,o=t.end-t.start||-1,i=t.animations;for(let e=0,t=i.length;e<t;e++){const t=v(i[e]);for(let e=0,r=t.length;e<r;e++)n.push(t[e])}return new e.AnimationClip(r,o,n)}function N(e){return p(tt.clips[e],C)}function O(e){const t={sources:{}};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"bind_shape_matrix":t.bindShapeMatrix=i(r.textContent);break;case"source":const e=r.getAttribute("id");t.sources[e]=le(r);break;case"joints":t.joints=D(r);break;case"vertex_weights":t.vertexWeights=P(r)}}return t}function D(e){const t={inputs:{}};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"input"===r.nodeName){const e=r.getAttribute("semantic"),n=s(r.getAttribute("source"));t.inputs[e]=n}}return t}function P(e){const t={inputs:{}};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"input":const e=r.getAttribute("semantic"),n=s(r.getAttribute("source")),o=parseInt(r.getAttribute("offset"));t.inputs[e]={id:n,offset:o};break;case"vcount":t.vcount=a(r.textContent);break;case"v":t.v=a(r.textContent)}}return t}function S(t){const n={id:t.id},r=tt.geometries[n.id];return void 0!==t.skin&&(n.skin=function(t){const n=4,r={joints:[],indices:{array:[],stride:n},weights:{array:[],stride:n}},o=t.sources,i=t.vertexWeights,a=i.vcount,s=i.v,c=i.inputs.JOINT.offset,l=i.inputs.WEIGHT.offset,u=t.sources[t.joints.inputs.JOINT],d=t.sources[t.joints.inputs.INV_BIND_MATRIX],h=o[i.inputs.WEIGHT.id].array;let f,p,g,m=0;for(f=0,g=a.length;f<g;f++){const e=a[f],t=[];for(p=0;p<e;p++){const e=s[m+c],n=h[s[m+l]];t.push({index:e,weight:n}),m+=2}for(t.sort(y),p=0;p<n;p++){const e=t[p];void 0!==e?(r.indices.array.push(e.index),r.weights.array.push(e.weight)):(r.indices.array.push(0),r.weights.array.push(0))}}t.bindShapeMatrix?r.bindMatrix=(new e.Matrix4).fromArray(t.bindShapeMatrix).transpose():r.bindMatrix=(new e.Matrix4).identity();for(f=0,g=u.array.length;f<g;f++){const t=u.array[f],n=(new e.Matrix4).fromArray(d.array,f*d.stride).transpose();r.joints.push({name:t,boneInverse:n})}return r;function y(e,t){return t.weight-e.weight}}(t.skin),r.sources.skinIndices=n.skin.indices,r.sources.skinWeights=n.skin.weights),n}function L(e){return p(tt.controllers[e],S)}function I(e){return void 0!==e.build?e.build:e.init_from}function j(e){const t=tt.images[e];return void 0!==t?p(t,I):(console.warn("THREE.ColladaLoader: Couldn't find image with ID:",e),null)}function R(e){const t={surfaces:{},samplers:{}};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"newparam":F(r,t);break;case"technique":t.technique=V(r);break;case"extra":t.extra=$(r)}}return t}function F(e,t){const n=e.getAttribute("sid");for(let r=0,o=e.childNodes.length;r<o;r++){const o=e.childNodes[r];if(1===o.nodeType)switch(o.nodeName){case"surface":t.surfaces[n]=B(o);break;case"sampler2D":t.samplers[n]=z(o)}}}function B(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"init_from"===r.nodeName)t.init_from=r.textContent}return t}function z(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"source"===r.nodeName)t.source=r.textContent}return t}function V(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"constant":case"lambert":case"blinn":case"phong":t.type=r.nodeName,t.parameters=U(r);break;case"extra":t.extra=$(r)}}return t}function U(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"emission":case"diffuse":case"specular":case"bump":case"ambient":case"shininess":case"transparency":t[r.nodeName]=G(r);break;case"transparent":t[r.nodeName]={opaque:r.hasAttribute("opaque")?r.getAttribute("opaque"):"A_ONE",data:G(r)}}}return t}function G(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"color":t[r.nodeName]=i(r.textContent);break;case"float":t[r.nodeName]=parseFloat(r.textContent);break;case"texture":t[r.nodeName]={id:r.getAttribute("texture"),extra:H(r)}}}return t}function H(e){const t={technique:{}};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"extra"===r.nodeName)K(r,t)}return t}function K(e,t){for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"technique"===r.nodeName)q(r,t)}}function q(e,t){for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"repeatU":case"repeatV":case"offsetU":case"offsetV":t.technique[r.nodeName]=parseFloat(r.textContent);break;case"wrapU":case"wrapV":"TRUE"===r.textContent.toUpperCase()?t.technique[r.nodeName]=1:"FALSE"===r.textContent.toUpperCase()?t.technique[r.nodeName]=0:t.technique[r.nodeName]=parseInt(r.textContent);break;case"bump":t[r.nodeName]=X(r)}}}function $(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"technique"===r.nodeName)t.technique=W(r)}return t}function W(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"double_sided":t[r.nodeName]=parseInt(r.textContent);break;case"bump":t[r.nodeName]=X(r)}}return t}function X(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"texture"===r.nodeName)t[r.nodeName]={id:r.getAttribute("texture"),texcoord:r.getAttribute("texcoord"),extra:H(r)}}return t}function J(e){return e}function Z(t){const n=(r=t.url,p(tt.effects[r],J));var r;const o=n.profile.technique;let i;switch(o.type){case"phong":case"blinn":i=new e.MeshPhongMaterial;break;case"lambert":i=new e.MeshLambertMaterial;break;default:i=new e.MeshBasicMaterial}function a(t,r=null){const o=n.profile.samplers[t.id];let i=null;if(void 0!==o){i=j(n.profile.surfaces[o.source].init_from)}else console.warn("THREE.ColladaLoader: Undefined sampler. Access image directly (see #12530)."),i=j(t.id);if(null!==i){const n=function(e){let t,n=e.slice((e.lastIndexOf(".")-1>>>0)+2);n=n.toLowerCase(),t="tga"===n?Je:Xe;return t}(i);if(void 0!==n){const o=n.load(i),a=t.extra;if(void 0!==a&&void 0!==a.technique&&!1===l(a.technique)){const t=a.technique;o.wrapS=t.wrapU?e.RepeatWrapping:e.ClampToEdgeWrapping,o.wrapT=t.wrapV?e.RepeatWrapping:e.ClampToEdgeWrapping,o.offset.set(t.offsetU||0,t.offsetV||0),o.repeat.set(t.repeatU||1,t.repeatV||1)}else o.wrapS=e.RepeatWrapping,o.wrapT=e.RepeatWrapping;return null!==r&&(o.colorSpace=r),o}return console.warn("THREE.ColladaLoader: Loader for texture %s not found.",i),null}return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",t.id),null}i.name=t.name||"";const s=o.parameters;for(const t in s){const n=s[t];switch(t){case"diffuse":n.color&&i.color.fromArray(n.color),n.texture&&(i.map=a(n.texture,e.SRGBColorSpace));break;case"specular":n.color&&i.specular&&i.specular.fromArray(n.color),n.texture&&(i.specularMap=a(n.texture));break;case"bump":n.texture&&(i.normalMap=a(n.texture));break;case"ambient":n.texture&&(i.lightMap=a(n.texture,e.SRGBColorSpace));break;case"shininess":n.float&&i.shininess&&(i.shininess=n.float);break;case"emission":n.color&&i.emissive&&i.emissive.fromArray(n.color),n.texture&&(i.emissiveMap=a(n.texture,e.SRGBColorSpace))}}i.color.convertSRGBToLinear(),i.specular&&i.specular.convertSRGBToLinear(),i.emissive&&i.emissive.convertSRGBToLinear();let c=s.transparent,u=s.transparency;if(void 0===u&&c&&(u={float:1}),void 0===c&&u&&(c={opaque:"A_ONE",data:{color:[1,1,1,1]}}),c&&u)if(c.data.texture)i.transparent=!0;else{const e=c.data.color;switch(c.opaque){case"A_ONE":i.opacity=e[3]*u.float;break;case"RGB_ZERO":i.opacity=1-e[0]*u.float;break;case"A_ZERO":i.opacity=1-e[3]*u.float;break;case"RGB_ONE":i.opacity=e[0]*u.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',c.opaque)}i.opacity<1&&(i.transparent=!0)}if(void 0!==o.extra&&void 0!==o.extra.technique){const t=o.extra.technique;for(const n in t){const r=t[n];switch(n){case"double_sided":i.side=1===r?e.DoubleSide:e.FrontSide;break;case"bump":i.normalMap=a(r.texture),i.normalScale=new e.Vector2(1,1)}}}return i}function Y(e){return p(tt.materials[e],Z)}function Q(e){for(let t=0;t<e.childNodes.length;t++){const n=e.childNodes[t];if("technique_common"===n.nodeName)return ee(n)}return{}}function ee(e){const t={};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];switch(r.nodeName){case"perspective":case"orthographic":t.technique=r.nodeName,t.parameters=te(r)}}return t}function te(e){const t={};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];switch(r.nodeName){case"xfov":case"yfov":case"xmag":case"ymag":case"znear":case"zfar":case"aspect_ratio":t[r.nodeName]=parseFloat(r.textContent)}}return t}function ne(t){let n;switch(t.optics.technique){case"perspective":n=new e.PerspectiveCamera(t.optics.parameters.yfov,t.optics.parameters.aspect_ratio,t.optics.parameters.znear,t.optics.parameters.zfar);break;case"orthographic":let r=t.optics.parameters.ymag,o=t.optics.parameters.xmag;const i=t.optics.parameters.aspect_ratio;o=void 0===o?r*i:o,r=void 0===r?o/i:r,o*=.5,r*=.5,n=new e.OrthographicCamera(-o,o,r,-r,t.optics.parameters.znear,t.optics.parameters.zfar);break;default:n=new e.PerspectiveCamera}return n.name=t.name||"",n}function re(e){const t=tt.cameras[e];return void 0!==t?p(t,ne):(console.warn("THREE.ColladaLoader: Couldn't find camera with ID:",e),null)}function oe(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"directional":case"point":case"spot":case"ambient":t.technique=r.nodeName,t.parameters=ie(r)}}return t}function ie(t){const n={};for(let r=0,o=t.childNodes.length;r<o;r++){const o=t.childNodes[r];if(1===o.nodeType)switch(o.nodeName){case"color":const t=i(o.textContent);n.color=(new e.Color).fromArray(t).convertSRGBToLinear();break;case"falloff_angle":n.falloffAngle=parseFloat(o.textContent);break;case"quadratic_attenuation":const r=parseFloat(o.textContent);n.distance=r?Math.sqrt(1/r):0}}return n}function ae(t){let n;switch(t.technique){case"directional":n=new e.DirectionalLight;break;case"point":n=new e.PointLight;break;case"spot":n=new e.SpotLight;break;case"ambient":n=new e.AmbientLight}return t.parameters.color&&n.color.copy(t.parameters.color),t.parameters.distance&&(n.distance=t.parameters.distance),n}function ce(e){const t=tt.lights[e];return void 0!==t?p(t,ae):(console.warn("THREE.ColladaLoader: Couldn't find light with ID:",e),null)}function le(e){const t={array:[],stride:3};for(let n=0;n<e.childNodes.length;n++){const a=e.childNodes[n];if(1===a.nodeType)switch(a.nodeName){case"float_array":t.array=i(a.textContent);break;case"Name_array":t.array=o(a.textContent);break;case"technique_common":const e=r(a,"accessor")[0];void 0!==e&&(t.stride=parseInt(e.getAttribute("stride")))}}return t}function ue(e){const t={};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];1===r.nodeType&&(t[r.getAttribute("semantic")]=s(r.getAttribute("source")))}return t}function de(e){const t={type:e.nodeName,material:e.getAttribute("material"),count:parseInt(e.getAttribute("count")),inputs:{},stride:0,hasUV:!1};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"input":const e=s(r.getAttribute("source")),n=r.getAttribute("semantic"),o=parseInt(r.getAttribute("offset")),i=parseInt(r.getAttribute("set")),c=i>0?n+i:n;t.inputs[c]={id:e,offset:o},t.stride=Math.max(t.stride,o+1),"TEXCOORD"===n&&(t.hasUV=!0);break;case"vcount":t.vcount=a(r.textContent);break;case"p":t.p=a(r.textContent)}}return t}function he(e){let t=0;for(let n=0,r=e.length;n<r;n++){!0===e[n].hasUV&&t++}t>0&&t<e.length&&(e.uvsNeedsFix=!0)}function fe(e){const t={},n=e.sources,r=e.vertices,o=e.primitives;if(0===o.length)return{};const i=function(e){const t={};for(let n=0;n<e.length;n++){const r=e[n];void 0===t[r.type]&&(t[r.type]=[]),t[r.type].push(r)}return t}(o);for(const e in i){const o=i[e];he(o),t[e]=pe(o,n,r)}return t}function pe(t,n,r){const o={},i={array:[],stride:0},a={array:[],stride:0},s={array:[],stride:0},c={array:[],stride:0},l={array:[],stride:0},u=[],d=4,h=[],f=4,p=new e.BufferGeometry,g=[];let m=0;for(let e=0;e<t.length;e++){const o=t[e],d=o.inputs;let f=0;switch(o.type){case"lines":case"linestrips":f=2*o.count;break;case"triangles":f=3*o.count;break;case"polylist":for(let e=0;e<o.count;e++){const t=o.vcount[e];switch(t){case 3:f+=3;break;case 4:f+=6;break;default:f+=3*(t-2)}}break;default:console.warn("THREE.ColladaLoader: Unknow primitive type:",o.type)}p.addGroup(m,f,e),m+=f,o.material&&g.push(o.material);for(const e in d){const f=d[e];switch(e){case"VERTEX":for(const e in r){const d=r[e];switch(e){case"POSITION":const r=i.array.length;if(ge(o,n[d],f.offset,i.array),i.stride=n[d].stride,n.skinWeights&&n.skinIndices&&(ge(o,n.skinIndices,f.offset,u),ge(o,n.skinWeights,f.offset,h)),!1===o.hasUV&&!0===t.uvsNeedsFix){const e=(i.array.length-r)/i.stride;for(let t=0;t<e;t++)s.array.push(0,0)}break;case"NORMAL":ge(o,n[d],f.offset,a.array),a.stride=n[d].stride;break;case"COLOR":ge(o,n[d],f.offset,l.array),l.stride=n[d].stride;break;case"TEXCOORD":ge(o,n[d],f.offset,s.array),s.stride=n[d].stride;break;case"TEXCOORD1":ge(o,n[d],f.offset,c.array),s.stride=n[d].stride;break;default:console.warn('THREE.ColladaLoader: Semantic "%s" not handled in geometry build process.',e)}}break;case"NORMAL":ge(o,n[f.id],f.offset,a.array),a.stride=n[f.id].stride;break;case"COLOR":ge(o,n[f.id],f.offset,l.array,!0),l.stride=n[f.id].stride;break;case"TEXCOORD":ge(o,n[f.id],f.offset,s.array),s.stride=n[f.id].stride;break;case"TEXCOORD1":ge(o,n[f.id],f.offset,c.array),c.stride=n[f.id].stride}}}return i.array.length>0&&p.setAttribute("position",new e.Float32BufferAttribute(i.array,i.stride)),a.array.length>0&&p.setAttribute("normal",new e.Float32BufferAttribute(a.array,a.stride)),l.array.length>0&&p.setAttribute("color",new e.Float32BufferAttribute(l.array,l.stride)),s.array.length>0&&p.setAttribute("uv",new e.Float32BufferAttribute(s.array,s.stride)),c.array.length>0&&p.setAttribute("uv1",new e.Float32BufferAttribute(c.array,c.stride)),u.length>0&&p.setAttribute("skinIndex",new e.Float32BufferAttribute(u,d)),h.length>0&&p.setAttribute("skinWeight",new e.Float32BufferAttribute(h,f)),o.data=p,o.type=t[0].type,o.materialKeys=g,o}function ge(e,t,n,r,o=!1){const i=e.p,a=e.stride,s=e.vcount;function c(e){let t=i[e+n]*u;const a=t+u;for(;t<a;t++)r.push(l[t]);if(o){const e=r.length-u-1;Ze.setRGB(r[e+0],r[e+1],r[e+2]).convertSRGBToLinear(),r[e+0]=Ze.r,r[e+1]=Ze.g,r[e+2]=Ze.b}}const l=t.array,u=t.stride;if(void 0!==e.vcount){let e=0;for(let t=0,n=s.length;t<n;t++){const n=s[t];if(4===n){const t=e+1*a,n=e+2*a,r=e+3*a;c(e+0*a),c(t),c(r),c(t),c(n),c(r)}else if(3===n){const t=e+1*a,n=e+2*a;c(e+0*a),c(t),c(n)}else if(n>4)for(let t=1,r=n-2;t<=r;t++){const n=e+a*t,r=e+a*(t+1);c(e+0*a),c(n),c(r)}e+=a*n}}else for(let e=0,t=i.length;e<t;e+=a)c(e)}function me(e){return p(tt.geometries[e],fe)}function ye(e){return void 0!==e.build?e.build:e}function ve(e,t){for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"joint":t.joints[r.getAttribute("sid")]=be(r);break;case"link":t.links.push(xe(r))}}}function be(e){let t;for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"prismatic":case"revolute":t=we(r)}}return t}function we(t){const n={sid:t.getAttribute("sid"),name:t.getAttribute("name")||"",axis:new e.Vector3,limits:{min:0,max:0},type:t.nodeName,static:!1,zeroPosition:0,middlePosition:0};for(let e=0;e<t.childNodes.length;e++){const r=t.childNodes[e];if(1===r.nodeType)switch(r.nodeName){case"axis":const e=i(r.textContent);n.axis.fromArray(e);break;case"limits":const t=r.getElementsByTagName("max")[0],o=r.getElementsByTagName("min")[0];n.limits.max=parseFloat(t.textContent),n.limits.min=parseFloat(o.textContent)}}return n.limits.min>=n.limits.max&&(n.static=!0),n.middlePosition=(n.limits.min+n.limits.max)/2,n}function xe(e){const t={sid:e.getAttribute("sid"),name:e.getAttribute("name")||"",attachments:[],transforms:[]};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"attachment_full":t.attachments.push(ke(r));break;case"matrix":case"translate":case"rotate":t.transforms.push(Ee(r))}}return t}function ke(e){const t={joint:e.getAttribute("joint").split("/").pop(),transforms:[],links:[]};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"link":t.links.push(xe(r));break;case"matrix":case"translate":case"rotate":t.transforms.push(Ee(r))}}return t}function Ee(t){const n={type:t.nodeName},r=i(t.textContent);switch(n.type){case"matrix":n.obj=new e.Matrix4,n.obj.fromArray(r).transpose();break;case"translate":n.obj=new e.Vector3,n.obj.fromArray(r);break;case"rotate":n.obj=new e.Vector3,n.obj.fromArray(r),n.angle=e.MathUtils.degToRad(r[3])}return n}function _e(e,t){for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType&&"technique_common"===r.nodeName)Ae(r,t)}}function Ae(e,t){for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"inertia":t.inertia=i(r.textContent);break;case"mass":t.mass=i(r.textContent)[0]}}}function Me(e){const t={target:e.getAttribute("target").split("/").pop()};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType&&"axis"===r.nodeName){const e=r.getElementsByTagName("param")[0];t.axis=e.textContent;const n=t.axis.split("inst_").pop().split("axis")[0];t.jointIndex=n.substring(0,n.length-1)}}return t}function Te(e){return void 0!==e.build?e.build:e}function Ce(t){const n=[],r=Ke.querySelector('[id="'+t.id+'"]');for(let t=0;t<r.childNodes.length;t++){const o=r.childNodes[t];if(1!==o.nodeType)continue;let a,s;switch(o.nodeName){case"matrix":a=i(o.textContent);const t=(new e.Matrix4).fromArray(a).transpose();n.push({sid:o.getAttribute("sid"),type:o.nodeName,obj:t});break;case"translate":case"scale":a=i(o.textContent),s=(new e.Vector3).fromArray(a),n.push({sid:o.getAttribute("sid"),type:o.nodeName,obj:s});break;case"rotate":a=i(o.textContent),s=(new e.Vector3).fromArray(a);const r=e.MathUtils.degToRad(a[3]);n.push({sid:o.getAttribute("sid"),type:o.nodeName,obj:s,angle:r})}}return n}const Ne=new e.Matrix4,Oe=new e.Vector3;function De(t){const n={name:t.getAttribute("name")||"",type:t.getAttribute("type"),id:t.getAttribute("id"),sid:t.getAttribute("sid"),matrix:new e.Matrix4,nodes:[],instanceCameras:[],instanceControllers:[],instanceLights:[],instanceGeometries:[],instanceNodes:[],transforms:{}};for(let r=0;r<t.childNodes.length;r++){const o=t.childNodes[r];if(1!==o.nodeType)continue;let a;switch(o.nodeName){case"node":n.nodes.push(o.getAttribute("id")),De(o);break;case"instance_camera":n.instanceCameras.push(s(o.getAttribute("url")));break;case"instance_controller":n.instanceControllers.push(Pe(o));break;case"instance_light":n.instanceLights.push(s(o.getAttribute("url")));break;case"instance_geometry":n.instanceGeometries.push(Pe(o));break;case"instance_node":n.instanceNodes.push(s(o.getAttribute("url")));break;case"matrix":a=i(o.textContent),n.matrix.multiply(Ne.fromArray(a).transpose()),n.transforms[o.getAttribute("sid")]=o.nodeName;break;case"translate":a=i(o.textContent),Oe.fromArray(a),n.matrix.multiply(Ne.makeTranslation(Oe.x,Oe.y,Oe.z)),n.transforms[o.getAttribute("sid")]=o.nodeName;break;case"rotate":a=i(o.textContent);const t=e.MathUtils.degToRad(a[3]);n.matrix.multiply(Ne.makeRotationAxis(Oe.fromArray(a),t)),n.transforms[o.getAttribute("sid")]=o.nodeName;break;case"scale":a=i(o.textContent),n.matrix.scale(Oe.fromArray(a)),n.transforms[o.getAttribute("sid")]=o.nodeName;break;case"extra":break;default:console.log(o)}}return Be(n.id)?console.warn("THREE.ColladaLoader: There is already a node with ID %s. Exclude current node from further processing.",n.id):tt.nodes[n.id]=n,n}function Pe(e){const t={id:s(e.getAttribute("url")),materials:{},skeletons:[]};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];switch(r.nodeName){case"bind_material":const e=r.getElementsByTagName("instance_material");for(let n=0;n<e.length;n++){const r=e[n],o=r.getAttribute("symbol"),i=r.getAttribute("target");t.materials[o]=s(i)}break;case"skeleton":t.skeletons.push(s(r.textContent))}}return t}function Se(t,n){const r=[],o=[];let i,a,s;for(i=0;i<t.length;i++){const e=t[i];let o;if(Be(e))o=ze(e),Le(o,n,r);else if(Ue(e)){const t=tt.visualScenes[e].children;for(let e=0;e<t.length;e++){const o=t[e];if("JOINT"===o.type){Le(ze(o.id),n,r)}}}else console.error("THREE.ColladaLoader: Unable to find root bone of skeleton with ID:",e)}for(i=0;i<n.length;i++)for(a=0;a<r.length;a++)if(s=r[a],s.bone.name===n[i].name){o[i]=s,s.processed=!0;break}for(i=0;i<r.length;i++)s=r[i],!1===s.processed&&(o.push(s),s.processed=!0);const c=[],l=[];for(i=0;i<o.length;i++)s=o[i],c.push(s.bone),l.push(s.boneInverse);return new e.Skeleton(c,l)}function Le(t,n,r){t.traverse(function(t){if(!0===t.isBone){let o;for(let e=0;e<n.length;e++){const r=n[e];if(r.name===t.name){o=r.boneInverse;break}}void 0===o&&(o=new e.Matrix4),r.push({bone:t,boneInverse:o,processed:!1})}})}function Ie(t){const n=[],r=t.matrix,o=t.nodes,i=t.type,a=t.instanceCameras,s=t.instanceControllers,c=t.instanceLights,l=t.instanceGeometries,u=t.instanceNodes;for(let e=0,t=o.length;e<t;e++)n.push(ze(o[e]));for(let e=0,t=a.length;e<t;e++){const t=re(a[e]);null!==t&&n.push(t.clone())}for(let e=0,t=s.length;e<t;e++){const t=s[e],r=L(t.id),o=Fe(me(r.id),t.materials),i=Se(t.skeletons,r.skin.joints);for(let e=0,t=o.length;e<t;e++){const t=o[e];t.isSkinnedMesh&&(t.bind(i,r.skin.bindMatrix),t.normalizeSkinWeights()),n.push(t)}}for(let e=0,t=c.length;e<t;e++){const t=ce(c[e]);null!==t&&n.push(t.clone())}for(let e=0,t=l.length;e<t;e++){const t=l[e],r=Fe(me(t.id),t.materials);for(let e=0,t=r.length;e<t;e++)n.push(r[e])}for(let e=0,t=u.length;e<t;e++)n.push(ze(u[e]).clone());let d;if(0===o.length&&1===n.length)d=n[0];else{d="JOINT"===i?new e.Bone:new e.Group;for(let e=0;e<n.length;e++)d.add(n[e])}return d.name="JOINT"===i?t.sid:t.name,d.matrix.copy(r),d.matrix.decompose(d.position,d.quaternion,d.scale),d}const je=new e.MeshBasicMaterial({name:e.Loader.DEFAULT_MATERIAL_NAME,color:16711935});function Re(e,t){const n=[];for(let r=0,o=e.length;r<o;r++){const o=t[e[r]];void 0===o?(console.warn("THREE.ColladaLoader: Material with key %s not found. Apply fallback material.",e[r]),n.push(je)):n.push(Y(o))}return n}function Fe(t,n){const r=[];for(const o in t){const i=t[o],a=Re(i.materialKeys,n);if(0===a.length&&("lines"===o||"linestrips"===o?a.push(new e.LineBasicMaterial):a.push(new e.MeshPhongMaterial)),"lines"===o||"linestrips"===o)for(let t=0,n=a.length;t<n;t++){const n=a[t];if(!0===n.isMeshPhongMaterial||!0===n.isMeshLambertMaterial){const r=new e.LineBasicMaterial;r.color.copy(n.color),r.opacity=n.opacity,r.transparent=n.transparent,a[t]=r}}const s=void 0!==i.data.attributes.skinIndex,c=1===a.length?a[0]:a;let l;switch(o){case"lines":l=new e.LineSegments(i.data,c);break;case"linestrips":l=new e.Line(i.data,c);break;case"triangles":case"polylist":l=s?new e.SkinnedMesh(i.data,c):new e.Mesh(i.data,c)}r.push(l)}return r}function Be(e){return void 0!==tt.nodes[e]}function ze(e){return p(tt.nodes[e],Ie)}function Ve(t){const n=new e.Group;n.name=t.name;const r=t.children;for(let e=0;e<r.length;e++){const t=r[e];n.add(ze(t.id))}return n}function Ue(e){return void 0!==tt.visualScenes[e]}function Ge(e){return p(tt.visualScenes[e],Ve)}if(0===t.length)return{scene:new e.Scene};const He=(new DOMParser).parseFromString(t,"application/xml"),Ke=r(He,"COLLADA")[0],qe=He.getElementsByTagName("parsererror")[0];if(void 0!==qe){const e=r(qe,"div")[0];let t;return t=e?e.textContent:function(e){let t="";const n=[e];for(;n.length;){const e=n.shift();e.nodeType===Node.TEXT_NODE?t+=e.textContent:(t+="\n",n.push.apply(n,e.childNodes))}return t.trim()}(qe),console.error("THREE.ColladaLoader: Failed to parse collada file.\n",t),null}const $e=Ke.getAttribute("version");console.debug("THREE.ColladaLoader: File version",$e);const We=function(e){return{unit:u(r(e,"unit")[0]),upAxis:d(r(e,"up_axis")[0])}}(r(Ke,"asset")[0]),Xe=new e.TextureLoader(this.manager);let Je;Xe.setPath(this.resourcePath||n).setCrossOrigin(this.crossOrigin),se&&(Je=new se(this.manager),Je.setPath(this.resourcePath||n));const Ze=new e.Color,Ye=[];let Qe={},et=0;const tt={animations:{},clips:{},controllers:{},images:{},effects:{},materials:{},cameras:{},lights:{},geometries:{},nodes:{},visualScenes:{},kinematicsModels:{},physicsModels:{},kinematicsScenes:{}};h(Ke,"library_animations","animation",function t(n){const r={sources:{},samplers:{},channels:{}};let o=!1;for(let e=0,i=n.childNodes.length;e<i;e++){const i=n.childNodes[e];if(1!==i.nodeType)continue;let a;switch(i.nodeName){case"source":a=i.getAttribute("id"),r.sources[a]=le(i);break;case"sampler":a=i.getAttribute("id"),r.samplers[a]=g(i);break;case"channel":a=i.getAttribute("target"),r.channels[a]=m(i);break;case"animation":t(i),o=!0;break;default:console.log(i)}}!1===o&&(tt.animations[n.getAttribute("id")||e.MathUtils.generateUUID()]=r)}),h(Ke,"library_animation_clips","animation_clip",function(e){const t={name:e.getAttribute("id")||"default",start:parseFloat(e.getAttribute("start")||0),end:parseFloat(e.getAttribute("end")||0),animations:[]};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"instance_animation"===r.nodeName)t.animations.push(s(r.getAttribute("url")))}tt.clips[e.getAttribute("id")]=t}),h(Ke,"library_controllers","controller",function(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"skin":t.id=s(r.getAttribute("source")),t.skin=O(r);break;case"morph":t.id=s(r.getAttribute("source")),console.warn("THREE.ColladaLoader: Morph target animation not supported yet.")}}tt.controllers[e.getAttribute("id")]=t}),h(Ke,"library_images","image",function(e){const t={init_from:r(e,"init_from")[0].textContent};tt.images[e.getAttribute("id")]=t}),h(Ke,"library_effects","effect",function(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"profile_COMMON"===r.nodeName)t.profile=R(r)}tt.effects[e.getAttribute("id")]=t}),h(Ke,"library_materials","material",function(e){const t={name:e.getAttribute("name")};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"instance_effect"===r.nodeName)t.url=s(r.getAttribute("url"))}tt.materials[e.getAttribute("id")]=t}),h(Ke,"library_cameras","camera",function(e){const t={name:e.getAttribute("name")};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"optics"===r.nodeName)t.optics=Q(r)}tt.cameras[e.getAttribute("id")]=t}),h(Ke,"library_lights","light",function(e){let t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"technique_common"===r.nodeName)t=oe(r)}tt.lights[e.getAttribute("id")]=t}),h(Ke,"library_geometries","geometry",function(e){const t={name:e.getAttribute("name"),sources:{},vertices:{},primitives:[]},n=r(e,"mesh")[0];if(void 0!==n){for(let e=0;e<n.childNodes.length;e++){const r=n.childNodes[e];if(1!==r.nodeType)continue;const o=r.getAttribute("id");switch(r.nodeName){case"source":t.sources[o]=le(r);break;case"vertices":t.vertices=ue(r);break;case"polygons":console.warn("THREE.ColladaLoader: Unsupported primitive type: ",r.nodeName);break;case"lines":case"linestrips":case"polylist":case"triangles":t.primitives.push(de(r));break;default:console.log(r)}}tt.geometries[e.getAttribute("id")]=t}}),h(Ke,"library_nodes","node",De),h(Ke,"library_visual_scenes","visual_scene",function(e){const t={name:e.getAttribute("name"),children:[]};!function(e){const t=e.getElementsByTagName("node");for(let e=0;e<t.length;e++){const n=t[e];!1===n.hasAttribute("id")&&n.setAttribute("id",c())}}(e);const n=r(e,"node");for(let e=0;e<n.length;e++)t.children.push(De(n[e]));tt.visualScenes[e.getAttribute("id")]=t}),h(Ke,"library_kinematics_models","kinematics_model",function(e){const t={name:e.getAttribute("name")||"",joints:{},links:[]};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType&&"technique_common"===r.nodeName)ve(r,t)}tt.kinematicsModels[e.getAttribute("id")]=t}),h(Ke,"library_physics_models","physics_model",function(e){const t={name:e.getAttribute("name")||"",rigidBodies:{}};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType&&"rigid_body"===r.nodeName)t.rigidBodies[r.getAttribute("name")]={},_e(r,t.rigidBodies[r.getAttribute("name")])}tt.physicsModels[e.getAttribute("id")]=t}),h(Ke,"scene","instance_kinematics_scene",function(e){const t={bindJointAxis:[]};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType&&"bind_joint_axis"===r.nodeName)t.bindJointAxis.push(Me(r))}tt.kinematicsScenes[s(e.getAttribute("url"))]=t}),f(tt.animations,y),f(tt.clips,C),f(tt.controllers,S),f(tt.images,I),f(tt.effects,J),f(tt.materials,Z),f(tt.cameras,ne),f(tt.lights,ae),f(tt.geometries,fe),f(tt.visualScenes,Ve),function(){const t=tt.clips;if(!0===l(t)){if(!1===l(tt.animations)){const t=[];for(const e in tt.animations){const n=v(e);for(let e=0,r=n.length;e<r;e++)t.push(n[e])}Ye.push(new e.AnimationClip("default",-1,t))}}else for(const e in t)Ye.push(N(e))}(),function(){const t=Object.keys(tt.kinematicsModels)[0],n=Object.keys(tt.kinematicsScenes)[0],r=Object.keys(tt.visualScenes)[0];if(void 0===t||void 0===n)return;const o=(i=t,p(tt.kinematicsModels[i],ye));var i;const a=function(e){return p(tt.kinematicsScenes[e],Te)}(n),s=Ge(r),c=a.bindJointAxis,l={};for(let e=0,t=c.length;e<t;e++){const t=c[e],n=Ke.querySelector('[sid="'+t.target+'"]');if(n){const e=n.parentElement;u(t.jointIndex,e)}}function u(e,t){const n=t.getAttribute("name"),r=o.joints[e];s.traverse(function(o){o.name===n&&(l[e]={object:o,transforms:Ce(t),joint:r,position:r.zeroPosition})})}const d=new e.Matrix4;Qe={joints:o&&o.joints,getJointValue:function(e){const t=l[e];if(t)return t.position;console.warn("THREE.ColladaLoader: Joint "+e+" doesn't exist.")},setJointValue:function(t,n){const r=l[t];if(r){const o=r.joint;if(n>o.limits.max||n<o.limits.min)console.warn("THREE.ColladaLoader: Joint "+t+" value "+n+" outside of limits (min: "+o.limits.min+", max: "+o.limits.max+").");else if(o.static)console.warn("THREE.ColladaLoader: Joint "+t+" is static.");else{const i=r.object,a=o.axis,s=r.transforms;Ne.identity();for(let r=0;r<s.length;r++){const i=s[r];if(i.sid&&-1!==i.sid.indexOf(t))switch(o.type){case"revolute":Ne.multiply(d.makeRotationAxis(a,e.MathUtils.degToRad(n)));break;case"prismatic":Ne.multiply(d.makeTranslation(a.x*n,a.y*n,a.z*n));break;default:console.warn("THREE.ColladaLoader: Unknown joint type: "+o.type)}else switch(i.type){case"matrix":Ne.multiply(i.obj);break;case"translate":Ne.multiply(d.makeTranslation(i.obj.x,i.obj.y,i.obj.z));break;case"scale":Ne.scale(i.obj);break;case"rotate":Ne.multiply(d.makeRotationAxis(i.obj,i.angle))}}i.matrix.copy(Ne),i.matrix.decompose(i.position,i.quaternion,i.scale),l[t].position=n}}else console.log("THREE.ColladaLoader: "+t+" does not exist.")}}}();const nt=function(e){return Ge(s(r(e,"instance_visual_scene")[0].getAttribute("url")))}(r(Ke,"scene")[0]);return nt.animations=Ye,"Z_UP"===We.upAxis&&(console.warn("THREE.ColladaLoader: 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, see #24289."),nt.rotation.set(-Math.PI/2,0,0)),nt.scale.multiplyScalar(We.unit),{get animations(){return console.warn("THREE.ColladaLoader: Please access animations over scene.animations now."),Ye},kinematics:Qe,library:tt,scene:nt}}}THREE.ColladaLoader=ce,AFRAME.registerComponent("collada-model-legacy",{schema:{type:"asset"},init:function(){this.model=null,this.loader=new THREE.ColladaLoader},update:function(){var e=this,t=this.el,n=this.data,r=this.el.sceneEl.systems.renderer;n&&(this.remove(),this.loader.load(n,function(n){e.model=n.scene,e.model.traverse(function(e){if(e.isMesh){var t=e.material;t.color&&r.applyColorCorrection(t.color),t.map&&r.applyColorCorrection(t.map),t.emissive&&r.applyColorCorrection(t.emissive),t.emissiveMap&&r.applyColorCorrection(t.emissiveMap)}}),t.setObject3D("mesh",e.model),t.emit("model-loaded",{format:"collada",model:e.model})}))},remove:function(){this.model&&this.el.removeObject3D("mesh")}});var le=Uint8Array,ue=Uint16Array,de=Int32Array,he=new le([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]),fe=new le([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]),pe=new le([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ge=function(e,t){for(var n=new ue(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var o=new de(n[30]);for(r=1;r<30;++r)for(var i=n[r];i<n[r+1];++i)o[i]=i-n[r]<<5|r;return{b:n,r:o}},me=ge(he,2),ye=me.b,ve=me.r;ye[28]=258,ve[258]=28;for(var be=ge(fe,0).b,we=new ue(32768),xe=0;xe<32768;++xe){var ke=(43690&xe)>>1|(21845&xe)<<1;ke=(61680&(ke=(52428&ke)>>2|(13107&ke)<<2))>>4|(3855&ke)<<4,we[xe]=((65280&ke)>>8|(255&ke)<<8)>>1}var Ee=function(e,t,n){for(var r=e.length,o=0,i=new ue(t);o<r;++o)e[o]&&++i[e[o]-1];var a,s=new ue(t);for(o=1;o<t;++o)s[o]=s[o-1]+i[o-1]<<1;if(n){a=new ue(1<<t);var c=15-t;for(o=0;o<r;++o)if(e[o])for(var l=o<<4|e[o],u=t-e[o],d=s[e[o]-1]++<<u,h=d|(1<<u)-1;d<=h;++d)a[we[d]>>c]=l}else for(a=new ue(r),o=0;o<r;++o)e[o]&&(a[o]=we[s[e[o]-1]++]>>15-e[o]);return a},_e=new le(288);for(xe=0;xe<144;++xe)_e[xe]=8;for(xe=144;xe<256;++xe)_e[xe]=9;for(xe=256;xe<280;++xe)_e[xe]=7;for(xe=280;xe<288;++xe)_e[xe]=8;var Ae=new le(32);for(xe=0;xe<32;++xe)Ae[xe]=5;var Me=Ee(_e,9,1),Te=Ee(Ae,5,1),Ce=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Ne=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&n},Oe=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},De=function(e){return(e+7)/8|0},Pe=["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"],Se=function(e,t,n){var r=new Error(t||Pe[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,Se),!n)throw r;return r},Le=function(e,t,n,r){var o=e.length;if(!o||t.f&&!t.l)return n||new le(0);var i=!n,a=i||2!=t.i,s=t.i;i&&(n=new le(3*o));var c=function(e){var t=n.length;if(e>t){var r=new le(Math.max(2*t,e));r.set(n),n=r}},l=t.f||0,u=t.p||0,d=t.b||0,h=t.l,f=t.d,p=t.m,g=t.n,m=8*o;do{if(!h){l=Ne(e,u,1);var y=Ne(e,u+1,3);if(u+=3,!y){var v=e[(N=De(u)+4)-4]|e[N-3]<<8,b=N+v;if(b>o){s&&Se(0);break}a&&c(d+v),n.set(e.subarray(N,b),d),t.b=d+=v,t.p=u=8*b,t.f=l;continue}if(1==y)h=Me,f=Te,p=9,g=5;else if(2==y){var w=Ne(e,u,31)+257,x=Ne(e,u+10,15)+4,k=w+Ne(e,u+5,31)+1;u+=14;for(var E=new le(k),_=new le(19),A=0;A<x;++A)_[pe[A]]=Ne(e,u+3*A,7);u+=3*x;var M=Ce(_),T=(1<<M)-1,C=Ee(_,M,1);for(A=0;A<k;){var N,O=C[Ne(e,u,T)];if(u+=15&O,(N=O>>4)<16)E[A++]=N;else{var D=0,P=0;for(16==N?(P=3+Ne(e,u,3),u+=2,D=E[A-1]):17==N?(P=3+Ne(e,u,7),u+=3):18==N&&(P=11+Ne(e,u,127),u+=7);P--;)E[A++]=D}}var S=E.subarray(0,w),L=E.subarray(w);p=Ce(S),g=Ce(L),h=Ee(S,p,1),f=Ee(L,g,1)}else Se(1);if(u>m){s&&Se(0);break}}a&&c(d+131072);for(var I=(1<<p)-1,j=(1<<g)-1,R=u;;R=u){var F=(D=h[Oe(e,u)&I])>>4;if((u+=15&D)>m){s&&Se(0);break}if(D||Se(2),F<256)n[d++]=F;else{if(256==F){R=u,h=null;break}var B=F-254;if(F>264){var z=he[A=F-257];B=Ne(e,u,(1<<z)-1)+ye[A],u+=z}var V=f[Oe(e,u)&j],U=V>>4;V||Se(3),u+=15&V;L=be[U];if(U>3){z=fe[U];L+=Oe(e,u)&(1<<z)-1,u+=z}if(u>m){s&&Se(0);break}a&&c(d+131072);var G=d+B;if(d<L){var H=0-L,K=Math.min(L,G);for(H+d<0&&Se(3);d<K;++d)n[d]=r[H+d]}for(;d<G;++d)n[d]=n[d-L]}}t.l=h,t.p=R,t.b=d,t.f=l,h&&(l=1,t.m=p,t.d=f,t.n=g)}while(!l);return d!=n.length&&i?function(e,t,n){return(null==n||n>e.length)&&(n=e.length),new le(e.subarray(t,n))}(n,0,d):n.subarray(0,d)},Ie=new le(0);function je(e,t){return Le(e.subarray(function(e){return(8!=(15&e[0])||e[0]>>4>7||(e[0]<<8|e[1])%31)&&Se(6,"invalid zlib data"),1==(e[1]>>5&1)&&Se(6,"invalid zlib data: "+(32&e[1]?"need":"unexpected")+" dictionary"),2+(e[1]>>3&4)}(e),-4),{i:2},t,t)}var Re="undefined"!=typeof TextDecoder&&new TextDecoder;try{Re.decode(Ie,{stream:!0})}catch(e){}function Fe(e,t,n){const r=n.length-e-1;if(t>=n[r])return r-1;if(t<=n[e])return e;let o=e,i=r,a=Math.floor((o+i)/2);for(;t<n[a]||t>=n[a+1];)t<n[a]?i=a:o=a,a=Math.floor((o+i)/2);return a}function Be(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 ze(t,n,r,o,i){const a=function(t,n,r,o,i){const a=i<t?i:t,s=[],c=Fe(t,o,n),l=function(e,t,n,r,o){const i=[];for(let e=0;e<=n;++e)i[e]=0;const a=[];for(let e=0;e<=r;++e)a[e]=i.slice(0);const s=[];for(let e=0;e<=n;++e)s[e]=i.slice(0);s[0][0]=1;const c=i.slice(0),l=i.slice(0);for(let r=1;r<=n;++r){c[r]=t-o[e+1-r],l[r]=o[e+r]-t;let n=0;for(let e=0;e<r;++e){const t=l[e+1],o=c[r-e];s[r][e]=t+o;const i=s[e][r-1]/s[r][e];s[e][r]=n+t*i,n=o*i}s[r][r]=n}for(let e=0;e<=n;++e)a[0][e]=s[e][n];for(let e=0;e<=n;++e){let t=0,o=1;const c=[];for(let e=0;e<=n;++e)c[e]=i.slice(0);c[0][0]=1;for(let i=1;i<=r;++i){let r=0;const l=e-i,u=n-i;e>=i&&(c[o][0]=c[t][0]/s[u+1][l],r=c[o][0]*s[l][u]);const d=e-1<=u?i-1:n-e;for(let e=l>=-1?1:-l;e<=d;++e)c[o][e]=(c[t][e]-c[t][e-1])/s[u+1][l+e],r+=c[o][e]*s[l+e][u];e<=u&&(c[o][i]=-c[t][i-1]/s[u+1][e],r+=c[o][i]*s[e][u]),a[i][e]=r;const h=t;t=o,o=h}}let u=n;for(let e=1;e<=r;++e){for(let t=0;t<=n;++t)a[e][t]*=u;u*=n-e}return a}(c,o,t,a,n),u=[];for(let e=0;e<r.length;++e){const t=r[e].clone(),n=t.w;t.x*=n,t.y*=n,t.z*=n,u[e]=t}for(let e=0;e<=a;++e){const n=u[c-t].clone().multiplyScalar(l[e][0]);for(let r=1;r<=t;++r)n.add(u[c-t+r].clone().multiplyScalar(l[e][r]));s[e]=n}for(let t=a+1;t<=i+1;++t)s[t]=new e.Vector4(0,0,0);return s}(t,n,r,o,i);return function(t){const n=t.length,r=[],o=[];for(let i=0;i<n;++i){const n=t[i];r[i]=new e.Vector3(n.x,n.y,n.z),o[i]=n.w}const i=[];for(let e=0;e<n;++e){const t=r[e].clone();for(let n=1;n<=e;++n)t.sub(i[e-n].clone().multiplyScalar(Be(e,n)*o[n]));i[e]=t.divideScalar(o[0])}return i}(a)}class Ve extends e.Curve{constructor(t,n,r,o,i){super(),this.degree=t,this.knots=n,this.controlPoints=[],this.startKnot=o||0,this.endKnot=i||this.knots.length-1;for(let t=0;t<r.length;++t){const n=r[t];this.controlPoints[t]=new e.Vector4(n.x,n.y,n.z,n.w)}}getPoint(t,n=new e.Vector3){const r=n,o=this.knots[this.startKnot]+t*(this.knots[this.endKnot]-this.knots[this.startKnot]),i=function(t,n,r,o){const i=Fe(t,o,n),a=function(e,t,n,r){const o=[],i=[],a=[];o[0]=1;for(let s=1;s<=n;++s){i[s]=t-r[e+1-s],a[s]=r[e+s]-t;let n=0;for(let e=0;e<s;++e){const t=a[e+1],r=i[s-e],c=o[e]/(t+r);o[e]=n+t*c,n=r*c}o[s]=n}return o}(i,o,t,n),s=new e.Vector4(0,0,0,0);for(let e=0;e<=t;++e){const n=r[i-t+e],o=a[e],c=n.w*o;s.x+=n.x*c,s.y+=n.y*c,s.z+=n.z*c,s.w+=n.w*o}return s}(this.degree,this.knots,this.controlPoints,o);return 1!==i.w&&i.divideScalar(i.w),r.set(i.x,i.y,i.z)}getTangent(t,n=new e.Vector3){const r=n,o=this.knots[0]+t*(this.knots[this.knots.length-1]-this.knots[0]),i=ze(this.degree,this.knots,this.controlPoints,o,1);return r.copy(i[1]).normalize(),r}}
/**
   * Loader loads FBX file and generates Group representing FBX scene.
   * Requires FBX file to be >= 7.0 and in ASCII or >= 6400 in Binary format
   * Versions lower than this may load but will probably have errors
   *
   * Needs Support:
   *  Morph normals / blend shape normals
   *
   * FBX format references:
   * 	https://help.autodesk.com/view/FBX/2017/ENU/?guid=__cpp_ref_index_html (C++ SDK reference)
   *
   * Binary format specification:
   *	https://code.blender.org/2013/08/fbx-binary-file-format-specification/
   */let Ue,Ge,He;class Ke extends e.Loader{constructor(e){super(e)}load(t,n,r,o){const i=this,a=""===i.path?e.LoaderUtils.extractUrlBase(t):i.path,s=new e.FileLoader(this.manager);s.setPath(i.path),s.setResponseType("arraybuffer"),s.setRequestHeader(i.requestHeader),s.setWithCredentials(i.withCredentials),s.load(t,function(e){try{n(i.parse(e,a))}catch(e){o?o(e):console.error(e),i.manager.itemError(t)}},r,o)}parse(t,n){if(function(e){const t="Kaydara FBX Binary  \0";return e.byteLength>=t.length&&t===ct(e,0,t.length)}(t))Ue=(new Je).parse(t);else{const e=ct(t);if(!function(e){const t=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let n=0;function r(t){const 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}(e))throw new Error("THREE.FBXLoader: Unknown format.");if(Qe(e)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+Qe(e));Ue=(new Xe).parse(e)}const r=new e.TextureLoader(this.manager).setPath(this.resourcePath||n).setCrossOrigin(this.crossOrigin);return new qe(r,this.manager).parse(Ue)}}class qe{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){Ge=this.parseConnections();const e=this.parseImages(),t=this.parseTextures(e),n=this.parseMaterials(t),r=this.parseDeformers(),o=(new $e).parse(r);return this.parseScene(r,o,n),He}parseConnections(){const e=new Map;if("Connections"in Ue){Ue.Connections.connections.forEach(function(t){const n=t[0],r=t[1],o=t[2];e.has(n)||e.set(n,{parents:[],children:[]});const i={ID:r,relationship:o};e.get(n).parents.push(i),e.has(r)||e.set(r,{parents:[],children:[]});const a={ID:n,relationship:o};e.get(r).children.push(a)})}return e}parseImages(){const e={},t={};if("Video"in Ue.Objects){const n=Ue.Objects.Video;for(const r in n){const o=n[r];if(e[parseInt(r)]=o.RelativeFilename||o.Filename,"Content"in o){const e=o.Content instanceof ArrayBuffer&&o.Content.byteLength>0,i="string"==typeof o.Content&&""!==o.Content;if(e||i){const e=this.parseImage(n[r]);t[o.RelativeFilename||o.Filename]=e}}}}for(const n in e){const r=e[n];void 0!==t[r]?e[n]=t[r]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){const t=e.Content,n=e.RelativeFilename||e.Filename,r=n.slice(n.lastIndexOf(".")+1).toLowerCase();let o;switch(r){case"bmp":o="image/bmp";break;case"jpg":case"jpeg":o="image/jpeg";break;case"png":o="image/png";break;case"tif":o="image/tiff";break;case"tga":null===this.manager.getHandler(".tga")&&console.warn("FBXLoader: TGA loader not found, skipping ",n),o="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+r+'" is not supported.')}if("string"==typeof t)return"data:"+o+";base64,"+t;{const e=new Uint8Array(t);return window.URL.createObjectURL(new Blob([e],{type:o}))}}parseTextures(e){const t=new Map;if("Texture"in Ue.Objects){const n=Ue.Objects.Texture;for(const r in n){const o=this.parseTexture(n[r],e);t.set(parseInt(r),o)}}return t}parseTexture(t,n){const r=this.loadTexture(t,n);r.ID=t.id,r.name=t.attrName;const o=t.WrapModeU,i=t.WrapModeV,a=void 0!==o?o.value:0,s=void 0!==i?i.value:0;if(r.wrapS=0===a?e.RepeatWrapping:e.ClampToEdgeWrapping,r.wrapT=0===s?e.RepeatWrapping:e.ClampToEdgeWrapping,"Scaling"in t){const e=t.Scaling.value;r.repeat.x=e[0],r.repeat.y=e[1]}if("Translation"in t){const e=t.Translation.value;r.offset.x=e[0],r.offset.y=e[1]}return r}loadTexture(t,n){let r;const o=this.textureLoader.path,i=Ge.get(t.id).children;let a;void 0!==i&&i.length>0&&void 0!==n[i[0].ID]&&(r=n[i[0].ID],0!==r.indexOf("blob:")&&0!==r.indexOf("data:")||this.textureLoader.setPath(void 0));const s=t.FileName.slice(-3).toLowerCase();if("tga"===s){const n=this.manager.getHandler(".tga");null===n?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",t.RelativeFilename),a=new e.Texture):(n.setPath(this.textureLoader.path),a=n.load(r))}else if("dds"===s){const n=this.manager.getHandler(".dds");null===n?(console.warn("FBXLoader: DDS loader not found, creating placeholder texture for",t.RelativeFilename),a=new e.Texture):(n.setPath(this.textureLoader.path),a=n.load(r))}else"psd"===s?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",t.RelativeFilename),a=new e.Texture):a=this.textureLoader.load(r);return this.textureLoader.setPath(o),a}parseMaterials(e){const t=new Map;if("Material"in Ue.Objects){const n=Ue.Objects.Material;for(const r in n){const o=this.parseMaterial(n[r],e);null!==o&&t.set(parseInt(r),o)}}return t}parseMaterial(t,n){const r=t.id,o=t.attrName;let i=t.ShadingModel;if("object"==typeof i&&(i=i.value),!Ge.has(r))return null;const a=this.parseParameters(t,n,r);let s;switch(i.toLowerCase()){case"phong":s=new e.MeshPhongMaterial;break;case"lambert":s=new e.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',i),s=new e.MeshPhongMaterial}return s.setValues(a),s.name=o,s}parseParameters(t,n,r){const o={};t.BumpFactor&&(o.bumpScale=t.BumpFactor.value),t.Diffuse?o.color=(new e.Color).fromArray(t.Diffuse.value).convertSRGBToLinear():!t.DiffuseColor||"Color"!==t.DiffuseColor.type&&"ColorRGB"!==t.DiffuseColor.type||(o.color=(new e.Color).fromArray(t.DiffuseColor.value).convertSRGBToLinear()),t.DisplacementFactor&&(o.displacementScale=t.DisplacementFactor.value),t.Emissive?o.emissive=(new e.Color).fromArray(t.Emissive.value).convertSRGBToLinear():!t.EmissiveColor||"Color"!==t.EmissiveColor.type&&"ColorRGB"!==t.EmissiveColor.type||(o.emissive=(new e.Color).fromArray(t.EmissiveColor.value).convertSRGBToLinear()),t.EmissiveFactor&&(o.emissiveIntensity=parseFloat(t.EmissiveFactor.value)),t.Opacity&&(o.opacity=parseFloat(t.Opacity.value)),o.opacity<1&&(o.transparent=!0),t.ReflectionFactor&&(o.reflectivity=t.ReflectionFactor.value),t.Shininess&&(o.shininess=t.Shininess.value),t.Specular?o.specular=(new e.Color).fromArray(t.Specular.value).convertSRGBToLinear():t.SpecularColor&&"Color"===t.SpecularColor.type&&(o.specular=(new e.Color).fromArray(t.SpecularColor.value).convertSRGBToLinear());const i=this;return Ge.get(r).children.forEach(function(t){const r=t.relationship;switch(r){case"Bump":o.bumpMap=i.getTexture(n,t.ID);break;case"Maya|TEX_ao_map":o.aoMap=i.getTexture(n,t.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":o.map=i.getTexture(n,t.ID),void 0!==o.map&&(o.map.colorSpace=e.SRGBColorSpace);break;case"DisplacementColor":o.displacementMap=i.getTexture(n,t.ID);break;case"EmissiveColor":o.emissiveMap=i.getTexture(n,t.ID),void 0!==o.emissiveMap&&(o.emissiveMap.colorSpace=e.SRGBColorSpace);break;case"NormalMap":case"Maya|TEX_normal_map":o.normalMap=i.getTexture(n,t.ID);break;case"ReflectionColor":o.envMap=i.getTexture(n,t.ID),void 0!==o.envMap&&(o.envMap.mapping=e.EquirectangularReflectionMapping,o.envMap.colorSpace=e.SRGBColorSpace);break;case"SpecularColor":o.specularMap=i.getTexture(n,t.ID),void 0!==o.specularMap&&(o.specularMap.colorSpace=e.SRGBColorSpace);break;case"TransparentColor":case"TransparencyFactor":o.alphaMap=i.getTexture(n,t.ID),o.transparent=!0;break;default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",r)}}),o}getTexture(e,t){return"LayeredTexture"in Ue.Objects&&t in Ue.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=Ge.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in Ue.Objects){const n=Ue.Objects.Deformer;for(const r in n){const o=n[r],i=Ge.get(parseInt(r));if("Skin"===o.attrType){const t=this.parseSkeleton(i,n);t.ID=r,i.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),t.geometryID=i.parents[0].ID,e[r]=t}else if("BlendShape"===o.attrType){const e={id:r};e.rawTargets=this.parseMorphTargets(i,n),e.id=r,i.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(t,n){const r=[];return t.children.forEach(function(t){const o=n[t.ID];if("Cluster"!==o.attrType)return;const i={ID:t.ID,indices:[],weights:[],transformLink:(new e.Matrix4).fromArray(o.TransformLink.a)};"Indexes"in o&&(i.indices=o.Indexes.a,i.weights=o.Weights.a),r.push(i)}),{rawBones:r,bones:[]}}parseMorphTargets(e,t){const n=[];for(let r=0;r<e.children.length;r++){const o=e.children[r],i=t[o.ID],a={name:i.attrName,initialWeight:i.DeformPercent,id:i.id,fullWeights:i.FullWeights.a};if("BlendShapeChannel"!==i.attrType)return;a.geoID=Ge.get(parseInt(o.ID)).children.filter(function(e){return void 0===e.relationship})[0].ID,n.push(a)}return n}parseScene(t,n,r){He=new e.Group;const o=this.parseModels(t.skeletons,n,r),i=Ue.Objects.Model,a=this;o.forEach(function(e){const t=i[e.ID];a.setLookAtProperties(e,t);Ge.get(e.ID).parents.forEach(function(t){const n=o.get(t.ID);void 0!==n&&n.add(e)}),null===e.parent&&He.add(e)}),this.bindSkeleton(t.skeletons,n,o),this.addGlobalSceneSettings(),He.traverse(function(e){if(e.userData.transformData){e.parent&&(e.userData.transformData.parentMatrix=e.parent.matrix,e.userData.transformData.parentMatrixWorld=e.parent.matrixWorld);const t=it(e.userData.transformData);e.applyMatrix4(t),e.updateWorldMatrix()}});const s=(new We).parse();1===He.children.length&&He.children[0].isGroup&&(He.children[0].animations=s,He=He.children[0]),He.animations=s}parseModels(t,n,r){const o=new Map,i=Ue.Objects.Model;for(const a in i){const s=parseInt(a),c=i[a],l=Ge.get(s);let u=this.buildSkeleton(l,t,s,c.attrName);if(!u){switch(c.attrType){case"Camera":u=this.createCamera(l);break;case"Light":u=this.createLight(l);break;case"Mesh":u=this.createMesh(l,n,r);break;case"NurbsCurve":u=this.createCurve(l,n);break;case"LimbNode":case"Root":u=new e.Bone;break;default:u=new e.Group}u.name=c.attrName?e.PropertyBinding.sanitizeNodeName(c.attrName):"",u.userData.originalName=c.attrName,u.ID=s}this.getTransformData(u,c),o.set(s,u)}return o}buildSkeleton(t,n,r,o){let i=null;return t.parents.forEach(function(t){for(const a in n){const s=n[a];s.rawBones.forEach(function(n,a){if(n.ID===t.ID){const t=i;i=new e.Bone,i.matrixWorld.copy(n.transformLink),i.name=o?e.PropertyBinding.sanitizeNodeName(o):"",i.userData.originalName=o,i.ID=r,s.bones[a]=i,null!==t&&i.add(t)}})}}),i}createCamera(t){let n,r;if(t.children.forEach(function(e){const t=Ue.Objects.NodeAttribute[e.ID];void 0!==t&&(r=t)}),void 0===r)n=new e.Object3D;else{let t=0;void 0!==r.CameraProjectionType&&1===r.CameraProjectionType.value&&(t=1);let o=1;void 0!==r.NearPlane&&(o=r.NearPlane.value/1e3);let i=1e3;void 0!==r.FarPlane&&(i=r.FarPlane.value/1e3);let a=window.innerWidth,s=window.innerHeight;void 0!==r.AspectWidth&&void 0!==r.AspectHeight&&(a=r.AspectWidth.value,s=r.AspectHeight.value);const c=a/s;let l=45;void 0!==r.FieldOfView&&(l=r.FieldOfView.value);const u=r.FocalLength?r.FocalLength.value:null;switch(t){case 0:n=new e.PerspectiveCamera(l,c,o,i),null!==u&&n.setFocalLength(u);break;case 1:n=new e.OrthographicCamera(-a/2,a/2,s/2,-s/2,o,i);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+t+"."),n=new e.Object3D}}return n}createLight(t){let n,r;if(t.children.forEach(function(e){const t=Ue.Objects.NodeAttribute[e.ID];void 0!==t&&(r=t)}),void 0===r)n=new e.Object3D;else{let t;t=void 0===r.LightType?0:r.LightType.value;let o=16777215;void 0!==r.Color&&(o=(new e.Color).fromArray(r.Color.value).convertSRGBToLinear());let i=void 0===r.Intensity?1:r.Intensity.value/100;void 0!==r.CastLightOnObject&&0===r.CastLightOnObject.value&&(i=0);let a=0;void 0!==r.FarAttenuationEnd&&(a=void 0!==r.EnableFarAttenuation&&0===r.EnableFarAttenuation.value?0:r.FarAttenuationEnd.value);const s=1;switch(t){case 0:n=new e.PointLight(o,i,a,s);break;case 1:n=new e.DirectionalLight(o,i);break;case 2:let t=Math.PI/3;void 0!==r.InnerAngle&&(t=e.MathUtils.degToRad(r.InnerAngle.value));let c=0;void 0!==r.OuterAngle&&(c=e.MathUtils.degToRad(r.OuterAngle.value),c=Math.max(c,1)),n=new e.SpotLight(o,i,a,t,c,s);break;default:console.warn("THREE.FBXLoader: Unknown light type "+r.LightType.value+", defaulting to a PointLight."),n=new e.PointLight(o,i)}void 0!==r.CastShadows&&1===r.CastShadows.value&&(n.castShadow=!0)}return n}createMesh(t,n,r){let o,i=null,a=null;const s=[];return t.children.forEach(function(e){n.has(e.ID)&&(i=n.get(e.ID)),r.has(e.ID)&&s.push(r.get(e.ID))}),s.length>1?a=s:s.length>0?a=s[0]:(a=new e.MeshPhongMaterial({name:e.Loader.DEFAULT_MATERIAL_NAME,color:13421772}),s.push(a)),"color"in i.attributes&&s.forEach(function(e){e.vertexColors=!0}),i.FBX_Deformer?(o=new e.SkinnedMesh(i,a),o.normalizeSkinWeights()):o=new e.Mesh(i,a),o}createCurve(t,n){const r=t.children.reduce(function(e,t){return n.has(t.ID)&&(e=n.get(t.ID)),e},null),o=new e.LineBasicMaterial({name:e.Loader.DEFAULT_MATERIAL_NAME,color:3342591,linewidth:1});return new e.Line(r,o)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),n.eulerOrder="RotationOrder"in t?at(t.RotationOrder.value):"ZYX","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(t,n){if("LookAtProperty"in n){Ge.get(t.ID).children.forEach(function(n){if("LookAtProperty"===n.relationship){const r=Ue.Objects.Model[n.ID];if("Lcl_Translation"in r){const n=r.Lcl_Translation.value;void 0!==t.target?(t.target.position.fromArray(n),He.add(t.target)):t.lookAt((new e.Vector3).fromArray(n))}}})}}bindSkeleton(t,n,r){const o=this.parsePoseNodes();for(const i in t){const a=t[i];Ge.get(parseInt(a.ID)).parents.forEach(function(t){if(n.has(t.ID)){const n=t.ID;Ge.get(n).parents.forEach(function(t){if(r.has(t.ID)){r.get(t.ID).bind(new e.Skeleton(a.bones),o[t.ID])}})}})}}parsePoseNodes(){const t={};if("Pose"in Ue.Objects){const n=Ue.Objects.Pose;for(const r in n)if("BindPose"===n[r].attrType&&n[r].NbPoseNodes>0){const o=n[r].PoseNode;Array.isArray(o)?o.forEach(function(n){t[n.Node]=(new e.Matrix4).fromArray(n.Matrix.a)}):t[o.Node]=(new e.Matrix4).fromArray(o.Matrix.a)}}return t}addGlobalSceneSettings(){if("GlobalSettings"in Ue){if("AmbientColor"in Ue.GlobalSettings){const t=Ue.GlobalSettings.AmbientColor.value,n=t[0],r=t[1],o=t[2];if(0!==n||0!==r||0!==o){const t=new e.Color(n,r,o).convertSRGBToLinear();He.add(new e.AmbientLight(t,1))}}"UnitScaleFactor"in Ue.GlobalSettings&&(He.userData.unitScaleFactor=Ue.GlobalSettings.UnitScaleFactor.value)}}}class $e{constructor(){this.negativeMaterialIndices=!1}parse(e){const t=new Map;if("Geometry"in Ue.Objects){const n=Ue.Objects.Geometry;for(const r in n){const o=Ge.get(parseInt(r)),i=this.parseGeometry(o,n[r],e);t.set(parseInt(r),i)}}return!0===this.negativeMaterialIndices&&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){const r=n.skeletons,o=[],i=e.parents.map(function(e){return Ue.Objects.Model[e.ID]});if(0===i.length)return;const a=e.children.reduce(function(e,t){return void 0!==r[t.ID]&&(e=r[t.ID]),e},null);e.children.forEach(function(e){void 0!==n.morphTargets[e.ID]&&o.push(n.morphTargets[e.ID])});const s=i[0],c={};"RotationOrder"in s&&(c.eulerOrder=at(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);const l=it(c);return this.genGeometry(t,a,o,l)}genGeometry(t,n,r,o){const i=new e.BufferGeometry;t.attrName&&(i.name=t.attrName);const a=this.parseGeoNode(t,n),s=this.genBuffers(a),c=new e.Float32BufferAttribute(s.vertex,3);if(c.applyMatrix4(o),i.setAttribute("position",c),s.colors.length>0&&i.setAttribute("color",new e.Float32BufferAttribute(s.colors,3)),n&&(i.setAttribute("skinIndex",new e.Uint16BufferAttribute(s.weightsIndices,4)),i.setAttribute("skinWeight",new e.Float32BufferAttribute(s.vertexWeights,4)),i.FBX_Deformer=n),s.normal.length>0){const t=(new e.Matrix3).getNormalMatrix(o),n=new e.Float32BufferAttribute(s.normal,3);n.applyNormalMatrix(t),i.setAttribute("normal",n)}if(s.uvs.forEach(function(t,n){const r=0===n?"uv":`uv${n}`;i.setAttribute(r,new e.Float32BufferAttribute(s.uvs[n],2))}),a.material&&"AllSame"!==a.material.mappingType){let e=s.materialIndex[0],t=0;if(s.materialIndex.forEach(function(n,r){n!==e&&(i.addGroup(t,r-t,e),e=n,t=r)}),i.groups.length>0){const t=i.groups[i.groups.length-1],n=t.start+t.count;n!==s.materialIndex.length&&i.addGroup(n,s.materialIndex.length-n,e)}0===i.groups.length&&i.addGroup(0,s.materialIndex.length,s.materialIndex[0])}return this.addMorphTargets(i,t,r,o),i}parseGeoNode(e,t){const n={};if(n.vertexPositions=void 0!==e.Vertices?e.Vertices.a:[],n.vertexIndices=void 0!==e.PolygonVertexIndex?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(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={},null!==t&&(n.skeleton=t,t.rawBones.forEach(function(e,t){e.indices.forEach(function(r,o){void 0===n.weightTable[r]&&(n.weightTable[r]=[]),n.weightTable[r].push({id:t,weight:e.weights[o]})})})),n}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,r=0,o=!1,i=[],a=[],s=[],c=[],l=[],u=[];const d=this;return e.vertexIndices.forEach(function(h,f){let p,g=!1;h<0&&(h^=-1,g=!0);let m=[],y=[];if(i.push(3*h,3*h+1,3*h+2),e.color){const t=nt(f,n,h,e.color);s.push(t[0],t[1],t[2])}if(e.skeleton){if(void 0!==e.weightTable[h]&&e.weightTable[h].forEach(function(e){y.push(e.weight),m.push(e.id)}),y.length>4){o||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),o=!0);const e=[0,0,0,0],t=[0,0,0,0];y.forEach(function(n,r){let o=n,i=m[r];t.forEach(function(t,n,r){if(o>t){r[n]=o,o=t;const a=e[n];e[n]=i,i=a}})}),m=e,y=t}for(;y.length<4;)y.push(0),m.push(0);for(let e=0;e<4;++e)l.push(y[e]),u.push(m[e])}if(e.normal){const t=nt(f,n,h,e.normal);a.push(t[0],t[1],t[2])}e.material&&"AllSame"!==e.material.mappingType&&(p=nt(f,n,h,e.material)[0],p<0&&(d.negativeMaterialIndices=!0,p=0)),e.uv&&e.uv.forEach(function(e,t){const r=nt(f,n,h,e);void 0===c[t]&&(c[t]=[]),c[t].push(r[0]),c[t].push(r[1])}),r++,g&&(d.genFace(t,e,i,p,a,s,c,l,u,r),n++,r=0,i=[],a=[],s=[],c=[],l=[],u=[])}),t}getNormalNewell(t){const n=new e.Vector3(0,0,0);for(let e=0;e<t.length;e++){const r=t[e],o=t[(e+1)%t.length];n.x+=(r.y-o.y)*(r.z+o.z),n.y+=(r.z-o.z)*(r.x+o.x),n.z+=(r.x-o.x)*(r.y+o.y)}return n.normalize(),n}getNormalTangentAndBitangent(t){const n=this.getNormalNewell(t),r=(Math.abs(n.z)>.5?new e.Vector3(0,1,0):new e.Vector3(0,0,1)).cross(n).normalize(),o=n.clone().cross(r).normalize();return{normal:n,tangent:r,bitangent:o}}flattenVertex(t,n,r){return new e.Vector2(t.dot(n),t.dot(r))}genFace(t,n,r,o,i,a,s,c,l,u){let d;if(u>3){const t=[];for(let o=0;o<r.length;o+=3)t.push(new e.Vector3(n.vertexPositions[r[o]],n.vertexPositions[r[o+1]],n.vertexPositions[r[o+2]]));const{tangent:o,bitangent:i}=this.getNormalTangentAndBitangent(t),a=[];for(const e of t)a.push(this.flattenVertex(e,o,i));d=e.ShapeUtils.triangulateShape(a,[])}else d=[[0,1,2]];for(const[e,u,h]of d)t.vertex.push(n.vertexPositions[r[3*e]]),t.vertex.push(n.vertexPositions[r[3*e+1]]),t.vertex.push(n.vertexPositions[r[3*e+2]]),t.vertex.push(n.vertexPositions[r[3*u]]),t.vertex.push(n.vertexPositions[r[3*u+1]]),t.vertex.push(n.vertexPositions[r[3*u+2]]),t.vertex.push(n.vertexPositions[r[3*h]]),t.vertex.push(n.vertexPositions[r[3*h+1]]),t.vertex.push(n.vertexPositions[r[3*h+2]]),n.skeleton&&(t.vertexWeights.push(c[4*e]),t.vertexWeights.push(c[4*e+1]),t.vertexWeights.push(c[4*e+2]),t.vertexWeights.push(c[4*e+3]),t.vertexWeights.push(c[4*u]),t.vertexWeights.push(c[4*u+1]),t.vertexWeights.push(c[4*u+2]),t.vertexWeights.push(c[4*u+3]),t.vertexWeights.push(c[4*h]),t.vertexWeights.push(c[4*h+1]),t.vertexWeights.push(c[4*h+2]),t.vertexWeights.push(c[4*h+3]),t.weightsIndices.push(l[4*e]),t.weightsIndices.push(l[4*e+1]),t.weightsIndices.push(l[4*e+2]),t.weightsIndices.push(l[4*e+3]),t.weightsIndices.push(l[4*u]),t.weightsIndices.push(l[4*u+1]),t.weightsIndices.push(l[4*u+2]),t.weightsIndices.push(l[4*u+3]),t.weightsIndices.push(l[4*h]),t.weightsIndices.push(l[4*h+1]),t.weightsIndices.push(l[4*h+2]),t.weightsIndices.push(l[4*h+3])),n.color&&(t.colors.push(a[3*e]),t.colors.push(a[3*e+1]),t.colors.push(a[3*e+2]),t.colors.push(a[3*u]),t.colors.push(a[3*u+1]),t.colors.push(a[3*u+2]),t.colors.push(a[3*h]),t.colors.push(a[3*h+1]),t.colors.push(a[3*h+2])),n.material&&"AllSame"!==n.material.mappingType&&(t.materialIndex.push(o),t.materialIndex.push(o),t.materialIndex.push(o)),n.normal&&(t.normal.push(i[3*e]),t.normal.push(i[3*e+1]),t.normal.push(i[3*e+2]),t.normal.push(i[3*u]),t.normal.push(i[3*u+1]),t.normal.push(i[3*u+2]),t.normal.push(i[3*h]),t.normal.push(i[3*h+1]),t.normal.push(i[3*h+2])),n.uv&&n.uv.forEach(function(n,r){void 0===t.uvs[r]&&(t.uvs[r]=[]),t.uvs[r].push(s[r][2*e]),t.uvs[r].push(s[r][2*e+1]),t.uvs[r].push(s[r][2*u]),t.uvs[r].push(s[r][2*u+1]),t.uvs[r].push(s[r][2*h]),t.uvs[r].push(s[r][2*h+1])})}addMorphTargets(e,t,n,r){if(0===n.length)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];const o=this;n.forEach(function(n){n.rawTargets.forEach(function(n){const i=Ue.Objects.Geometry[n.geoID];void 0!==i&&o.genMorphGeometry(e,t,i,r,n.name)})})}genMorphGeometry(t,n,r,o,i){const a=void 0!==n.PolygonVertexIndex?n.PolygonVertexIndex.a:[],s=void 0!==r.Vertices?r.Vertices.a:[],c=void 0!==r.Indexes?r.Indexes.a:[],l=3*t.attributes.position.count,u=new Float32Array(l);for(let e=0;e<c.length;e++){const t=3*c[e];u[t]=s[3*e],u[t+1]=s[3*e+1],u[t+2]=s[3*e+2]}const d={vertexIndices:a,vertexPositions:u},h=this.genBuffers(d),f=new e.Float32BufferAttribute(h.vertex,3);f.name=i||r.attrName,f.applyMatrix4(o),t.morphAttributes.position.push(f)}parseNormals(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.Normals.a;let o=[];return"IndexToDirect"===n&&("NormalIndex"in e?o=e.NormalIndex.a:"NormalsIndex"in e&&(o=e.NormalsIndex.a)),{dataSize:3,buffer:r,indices:o,mappingType:t,referenceType:n}}parseUVs(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.UV.a;let o=[];return"IndexToDirect"===n&&(o=e.UVIndex.a),{dataSize:2,buffer:r,indices:o,mappingType:t,referenceType:n}}parseVertexColors(t){const n=t.MappingInformationType,r=t.ReferenceInformationType,o=t.Colors.a;let i=[];"IndexToDirect"===r&&(i=t.ColorIndex.a);for(let t=0,n=new e.Color;t<o.length;t+=4)n.fromArray(o,t).convertSRGBToLinear().toArray(o,t);return{dataSize:4,buffer:o,indices:i,mappingType:n,referenceType:r}}parseMaterialIndices(e){const t=e.MappingInformationType,n=e.ReferenceInformationType;if("NoMappingInformation"===t)return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:n};const r=e.Materials.a,o=[];for(let e=0;e<r.length;++e)o.push(e);return{dataSize:1,buffer:r,indices:o,mappingType:t,referenceType:n}}parseNurbsGeometry(t){const n=parseInt(t.Order);if(isNaN(n))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",t.Order,t.id),new e.BufferGeometry;const r=n-1,o=t.KnotVector.a,i=[],a=t.Points.a;for(let t=0,n=a.length;t<n;t+=4)i.push((new e.Vector4).fromArray(a,t));let s,c;if("Closed"===t.Form)i.push(i[0]);else if("Periodic"===t.Form){s=r,c=o.length-1-s;for(let e=0;e<r;++e)i.push(i[e])}const l=new Ve(r,o,i,s,c).getPoints(12*i.length);return(new e.BufferGeometry).setFromPoints(l)}}class We{parse(){const e=[],t=this.parseClips();if(void 0!==t)for(const n in t){const r=t[n],o=this.addClip(r);e.push(o)}return e}parseClips(){if(void 0===Ue.Objects.AnimationCurve)return;const e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);const t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){const e=Ue.Objects.AnimationCurveNode,t=new Map;for(const n in e){const r=e[n];if(null!==r.attrName.match(/S|R|T|DeformPercent/)){const e={id:r.id,attr:r.attrName,curves:{}};t.set(e.id,e)}}return t}parseAnimationCurves(e){const t=Ue.Objects.AnimationCurve;for(const n in t){const r={id:t[n].id,times:t[n].KeyTime.a.map(et),values:t[n].KeyValueFloat.a},o=Ge.get(r.id);if(void 0!==o){const t=o.parents[0].ID,n=o.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(t){const n=Ue.Objects.AnimationLayer,r=new Map;for(const o in n){const n=[],i=Ge.get(parseInt(o));if(void 0!==i){i.children.forEach(function(r,o){if(t.has(r.ID)){const i=t.get(r.ID);if(void 0!==i.curves.x||void 0!==i.curves.y||void 0!==i.curves.z){if(void 0===n[o]){const t=Ge.get(r.ID).parents.filter(function(e){return void 0!==e.relationship})[0].ID;if(void 0!==t){const i=Ue.Objects.Model[t.toString()];if(void 0===i)return void console.warn("THREE.FBXLoader: Encountered a unused curve.",r);const a={modelName:i.attrName?e.PropertyBinding.sanitizeNodeName(i.attrName):"",ID:i.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};He.traverse(function(e){e.ID===i.id&&(a.transform=e.matrix,e.userData.transformData&&(a.eulerOrder=e.userData.transformData.eulerOrder))}),a.transform||(a.transform=new e.Matrix4),"PreRotation"in i&&(a.preRotation=i.PreRotation.value),"PostRotation"in i&&(a.postRotation=i.PostRotation.value),n[o]=a}}n[o]&&(n[o][i.attr]=i)}else if(void 0!==i.curves.morph){if(void 0===n[o]){const t=Ge.get(r.ID).parents.filter(function(e){return void 0!==e.relationship})[0].ID,i=Ge.get(t).parents[0].ID,a=Ge.get(i).parents[0].ID,s=Ge.get(a).parents[0].ID,c=Ue.Objects.Model[s],l={modelName:c.attrName?e.PropertyBinding.sanitizeNodeName(c.attrName):"",morphName:Ue.Objects.Deformer[t].attrName};n[o]=l}n[o][i.attr]=i}}}),r.set(parseInt(o),n)}}return r}parseAnimStacks(e){const t=Ue.Objects.AnimationStack,n={};for(const r in t){const o=Ge.get(parseInt(r)).children;o.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const i=e.get(o[0].ID);n[r]={name:t[r].attrName,layer:i}}return n}addClip(t){let n=[];const r=this;return t.layer.forEach(function(e){n=n.concat(r.generateTracks(e))}),new e.AnimationClip(t.name,-1,n)}generateTracks(t){const n=[];let r=new e.Vector3,o=new e.Vector3;if(t.transform&&t.transform.decompose(r,new e.Quaternion,o),r=r.toArray(),o=o.toArray(),void 0!==t.T&&Object.keys(t.T.curves).length>0){const e=this.generateVectorTrack(t.modelName,t.T.curves,r,"position");void 0!==e&&n.push(e)}if(void 0!==t.R&&Object.keys(t.R.curves).length>0){const e=this.generateRotationTrack(t.modelName,t.R.curves,t.preRotation,t.postRotation,t.eulerOrder);void 0!==e&&n.push(e)}if(void 0!==t.S&&Object.keys(t.S.curves).length>0){const e=this.generateVectorTrack(t.modelName,t.S.curves,o,"scale");void 0!==e&&n.push(e)}if(void 0!==t.DeformPercent){const e=this.generateMorphTrack(t);void 0!==e&&n.push(e)}return n}generateVectorTrack(t,n,r,o){const i=this.getTimesForAllAxes(n),a=this.getKeyframeTrackValues(i,n,r);return new e.VectorKeyframeTrack(t+"."+o,i,a)}generateRotationTrack(t,n,r,o,i){let a,s;if(void 0!==n.x&&void 0!==n.y&&void 0!==n.z){const e=this.interpolateRotations(n.x,n.y,n.z,i);a=e[0],s=e[1]}void 0!==r&&((r=r.map(e.MathUtils.degToRad)).push(i),r=(new e.Euler).fromArray(r),r=(new e.Quaternion).setFromEuler(r)),void 0!==o&&((o=o.map(e.MathUtils.degToRad)).push(i),o=(new e.Euler).fromArray(o),o=(new e.Quaternion).setFromEuler(o).invert());const c=new e.Quaternion,l=new e.Euler,u=[];if(!s||!a)return new e.QuaternionKeyframeTrack(t+".quaternion",[0],[0]);for(let t=0;t<s.length;t+=3){if(l.set(s[t],s[t+1],s[t+2],i),c.setFromEuler(l),void 0!==r&&c.premultiply(r),void 0!==o&&c.multiply(o),t>2){(new e.Quaternion).fromArray(u,(t-3)/3*4).dot(c)<0&&c.set(-c.x,-c.y,-c.z,-c.w)}c.toArray(u,t/3*4)}return new e.QuaternionKeyframeTrack(t+".quaternion",a,u)}generateMorphTrack(t){const n=t.DeformPercent.curves.morph,r=n.values.map(function(e){return e/100}),o=He.getObjectByName(t.modelName).morphTargetDictionary[t.morphName];return new e.NumberKeyframeTrack(t.modelName+".morphTargetInfluences["+o+"]",n.times,r)}getTimesForAllAxes(e){let t=[];if(void 0!==e.x&&(t=t.concat(e.x.times)),void 0!==e.y&&(t=t.concat(e.y.times)),void 0!==e.z&&(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++){const o=t[r];o!==n&&(t[e]=o,n=o,e++)}t=t.slice(0,e)}return t}getKeyframeTrackValues(e,t,n){const r=n,o=[];let i=-1,a=-1,s=-1;return e.forEach(function(e){if(t.x&&(i=t.x.times.indexOf(e)),t.y&&(a=t.y.times.indexOf(e)),t.z&&(s=t.z.times.indexOf(e)),-1!==i){const e=t.x.values[i];o.push(e),r[0]=e}else o.push(r[0]);if(-1!==a){const e=t.y.values[a];o.push(e),r[1]=e}else o.push(r[1]);if(-1!==s){const e=t.z.values[s];o.push(e),r[2]=e}else o.push(r[2])}),o}interpolateRotations(t,n,r,o){const i=[],a=[];i.push(t.times[0]),a.push(e.MathUtils.degToRad(t.values[0])),a.push(e.MathUtils.degToRad(n.values[0])),a.push(e.MathUtils.degToRad(r.values[0]));for(let s=1;s<t.values.length;s++){const c=[t.values[s-1],n.values[s-1],r.values[s-1]];if(isNaN(c[0])||isNaN(c[1])||isNaN(c[2]))continue;const l=c.map(e.MathUtils.degToRad),u=[t.values[s],n.values[s],r.values[s]];if(isNaN(u[0])||isNaN(u[1])||isNaN(u[2]))continue;const d=u.map(e.MathUtils.degToRad),h=[u[0]-c[0],u[1]-c[1],u[2]-c[2]],f=[Math.abs(h[0]),Math.abs(h[1]),Math.abs(h[2])];if(f[0]>=180||f[1]>=180||f[2]>=180){const n=Math.max(...f)/180,r=new e.Euler(...l,o),c=new e.Euler(...d,o),u=(new e.Quaternion).setFromEuler(r),h=(new e.Quaternion).setFromEuler(c);u.dot(h)&&h.set(-h.x,-h.y,-h.z,-h.w);const p=t.times[s-1],g=t.times[s]-p,m=new e.Quaternion,y=new e.Euler;for(let e=0;e<1;e+=1/n)m.copy(u.clone().slerp(h.clone(),e)),i.push(p+e*g),y.setFromQuaternion(m,o),a.push(y.x),a.push(y.y),a.push(y.z)}else i.push(t.times[s]),a.push(e.MathUtils.degToRad(t.values[s])),a.push(e.MathUtils.degToRad(n.values[s])),a.push(e.MathUtils.degToRad(r.values[s]))}return[i,a]}}class Xe{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-=1}setCurrentProp(e,t){this.currentProp=e,this.currentPropName=t}parse(e){this.currentIndent=0,this.allNodes=new Ye,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const t=this,n=e.split(/[\r\n]+/);return n.forEach(function(e,r){const o=e.match(/^[\s\t]*;/),i=e.match(/^[\s\t]*$/);if(o||i)return;const a=e.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),s=e.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),c=e.match("^\\t{"+(t.currentIndent-1)+"}}");a?t.parseNodeBegin(e,a):s?t.parseNodeProperty(e,s,n[++r]):c?t.popStack():e.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(e)}),this.allNodes}parseNodeBegin(e,t){const n=t[1].trim().replace(/^"/,"").replace(/"$/,""),r=t[2].split(",").map(function(e){return e.trim().replace(/^"/,"").replace(/"$/,"")}),o={name:n},i=this.parseNodeAttr(r),a=this.getCurrentNode();0===this.currentIndent?this.allNodes.add(n,o):n in a?("PoseNode"===n?a.PoseNode.push(o):void 0!==a[n].id&&(a[n]={},a[n][a[n].id]=a[n]),""!==i.id&&(a[n][i.id]=o)):"number"==typeof i.id?(a[n]={},a[n][i.id]=o):"Properties70"!==n&&(a[n]="PoseNode"===n?[o]:o),"number"==typeof i.id&&(o.id=i.id),""!==i.name&&(o.attrName=i.name),""!==i.type&&(o.attrType=i.type),this.pushStack(o)}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(),o=t[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===r&&","===o&&(o=n.replace(/"/g,"").replace(/,$/,"").trim());const i=this.getCurrentNode();if("Properties70"!==i.name){if("C"===r){const e=o.split(",").slice(1),t=parseInt(e[0]),n=parseInt(e[1]);let a=o.split(",").slice(3);a=a.map(function(e){return e.trim().replace(/^"/,"")}),r="connections",o=[t,n],function(e,t){for(let n=0,r=e.length,o=t.length;n<o;n++,r++)e[r]=t[n]}(o,a),void 0===i[r]&&(i[r]=[])}"Node"===r&&(i.id=o),r in i&&Array.isArray(i[r])?i[r].push(o):"a"!==r?i[r]=o:i.a=o,this.setCurrentProp(i,r),"a"===r&&","!==o.slice(-1)&&(i.a=st(o))}else this.parseNodeSpecialProperty(e,r,o)}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,","!==e.slice(-1)&&(t.a=st(t.a))}parseNodeSpecialProperty(e,t,n){const r=n.split('",').map(function(e){return e.trim().replace(/^\"/,"").replace(/\s/,"_")}),o=r[0],i=r[1],a=r[2],s=r[3];let c=r[4];switch(i){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=st(c)}this.getPrevNode()[o]={type:i,type2:a,flag:s,value:c},this.setCurrentProp(this.getPrevNode(),o)}}class Je{parse(e){const t=new Ze(e);t.skip(23);const n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const r=new Ye;for(;!this.endOfContent(t);){const e=this.parseNode(t,n);null!==e&&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){const n={},r=t>=7500?e.getUint64():e.getUint32(),o=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const i=e.getUint8(),a=e.getString(i);if(0===r)return null;const s=[];for(let t=0;t<o;t++)s.push(this.parseProperty(e));const c=s.length>0?s[0]:"",l=s.length>1?s[1]:"",u=s.length>2?s[2]:"";for(n.singleProperty=1===o&&e.getOffset()===r;r>e.getOffset();){const r=this.parseNode(e,t);null!==r&&this.parseSubNode(a,n,r)}return n.propertyList=s,"number"==typeof c&&(n.id=c),""!==l&&(n.attrName=l),""!==u&&(n.attrType=u),""!==a&&(n.name=a),n}parseSubNode(e,t,n){if(!0===n.singleProperty){const e=n.propertyList[0];Array.isArray(e)?(t[n.name]=n,n.a=e):t[n.name]=e}else if("Connections"===e&&"C"===n.name){const e=[];n.propertyList.forEach(function(t,n){0!==n&&e.push(t)}),void 0===t.connections&&(t.connections=[]),t.connections.push(e)}else if("Properties70"===n.name){Object.keys(n).forEach(function(e){t[e]=n[e]})}else if("Properties70"===e&&"P"===n.name){let e=n.propertyList[0],r=n.propertyList[1];const o=n.propertyList[2],i=n.propertyList[3];let a;0===e.indexOf("Lcl ")&&(e=e.replace("Lcl ","Lcl_")),0===r.indexOf("Lcl ")&&(r=r.replace("Lcl ","Lcl_")),a="Color"===r||"ColorRGB"===r||"Vector"===r||"Vector3D"===r||0===r.indexOf("Lcl_")?[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:n.propertyList[4],t[e]={type:r,type2:o,flag:i,value:a}}else void 0===t[n.name]?"number"==typeof n.id?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:"PoseNode"===n.name?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):void 0===t[n.name][n.id]&&(t[n.name][n.id]=n)}parseProperty(e){const t=e.getString(1);let 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":const r=e.getUint32(),o=e.getUint32(),i=e.getUint32();if(0===o)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)}const a=je(new Uint8Array(e.getArrayBuffer(i))),s=new Ze(a.buffer);switch(t){case"b":case"c":return s.getBooleanArray(r);case"d":return s.getFloat64Array(r);case"f":return s.getFloat32Array(r);case"i":return s.getInt32Array(r);case"l":return s.getInt64Array(r)}break;default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class Ze{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=void 0===t||t,this._textDecoder=new TextDecoder}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return!(1&~this.getUint8())}getBooleanArray(e){const t=[];for(let n=0;n<e;n++)t.push(this.getBoolean());return t}getUint8(){const e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){const e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){const e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt32());return t}getUint32(){const 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()),2147483648&t?(t=4294967295&~t,e=4294967295&~e,4294967295===e&&(t=t+1&4294967295),e=e+1&4294967295,-(4294967296*t+e)):4294967296*t+e}getInt64Array(e){const 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()),4294967296*t+e}getFloat32(){const e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat32());return t}getFloat64(){const e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat64());return t}getArrayBuffer(e){const t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){const t=this.offset;let n=new Uint8Array(this.dv.buffer,t,e);this.skip(e);const r=n.indexOf(0);return r>=0&&(n=new Uint8Array(this.dv.buffer,t,r)),this._textDecoder.decode(n)}}class Ye{add(e,t){this[e]=t}}function Qe(e){const t=e.match(/FBXVersion: (\d+)/);if(t){return parseInt(t[1])}throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function et(e){return e/46186158e3}const tt=[];function nt(e,t,n,r){let o;switch(r.mappingType){case"ByPolygonVertex":o=e;break;case"ByPolygon":o=t;break;case"ByVertice":o=n;break;case"AllSame":o=r.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+r.mappingType)}"IndexToDirect"===r.referenceType&&(o=r.indices[o]);const i=o*r.dataSize,a=i+r.dataSize;return function(e,t,n,r){for(let o=n,i=0;o<r;o++,i++)e[i]=t[o];return e}(tt,r.buffer,i,a)}const rt=new e.Euler,ot=new e.Vector3;function it(t){const n=new e.Matrix4,r=new e.Matrix4,o=new e.Matrix4,i=new e.Matrix4,a=new e.Matrix4,s=new e.Matrix4,c=new e.Matrix4,l=new e.Matrix4,u=new e.Matrix4,d=new e.Matrix4,h=new e.Matrix4,f=new e.Matrix4,p=t.inheritType?t.inheritType:0;if(t.translation&&n.setPosition(ot.fromArray(t.translation)),t.preRotation){const n=t.preRotation.map(e.MathUtils.degToRad);n.push(t.eulerOrder||e.Euler.DEFAULT_ORDER),r.makeRotationFromEuler(rt.fromArray(n))}if(t.rotation){const n=t.rotation.map(e.MathUtils.degToRad);n.push(t.eulerOrder||e.Euler.DEFAULT_ORDER),o.makeRotationFromEuler(rt.fromArray(n))}if(t.postRotation){const n=t.postRotation.map(e.MathUtils.degToRad);n.push(t.eulerOrder||e.Euler.DEFAULT_ORDER),i.makeRotationFromEuler(rt.fromArray(n)),i.invert()}t.scale&&a.scale(ot.fromArray(t.scale)),t.scalingOffset&&c.setPosition(ot.fromArray(t.scalingOffset)),t.scalingPivot&&s.setPosition(ot.fromArray(t.scalingPivot)),t.rotationOffset&&l.setPosition(ot.fromArray(t.rotationOffset)),t.rotationPivot&&u.setPosition(ot.fromArray(t.rotationPivot)),t.parentMatrixWorld&&(h.copy(t.parentMatrix),d.copy(t.parentMatrixWorld));const g=r.clone().multiply(o).multiply(i),m=new e.Matrix4;m.extractRotation(d);const y=new e.Matrix4;y.copyPosition(d);const v=y.clone().invert().multiply(d),b=m.clone().invert().multiply(v),w=a,x=new e.Matrix4;if(0===p)x.copy(m).multiply(g).multiply(b).multiply(w);else if(1===p)x.copy(m).multiply(b).multiply(g).multiply(w);else{const t=(new e.Matrix4).scale((new e.Vector3).setFromMatrixScale(h)).clone().invert(),n=b.clone().multiply(t);x.copy(m).multiply(g).multiply(n).multiply(w)}const k=u.clone().invert(),E=s.clone().invert();let _=n.clone().multiply(l).multiply(u).multiply(r).multiply(o).multiply(i).multiply(k).multiply(c).multiply(s).multiply(a).multiply(E);const A=(new e.Matrix4).copyPosition(_),M=d.clone().multiply(A);return f.copyPosition(M),_=f.clone().multiply(x),_.premultiply(d.invert()),_}function at(e){const t=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return 6===(e=e||0)?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),t[0]):t[e]}function st(e){return e.split(",").map(function(e){return parseFloat(e)})}function ct(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=e.byteLength),(new TextDecoder).decode(new Uint8Array(e,t,n))}var lt,ut,dt,ht,ft,pt;function gt(){if(ut)return lt;function e(e){const t=document.getElementById(e),n=t.parentNode;try{n&&n.removeChild(t)}catch(e){}}function t(t,n,r){return new r(function(r,o){const i=n.timeout||5e3,a="script_"+Date.now()+"_"+Math.ceil(1e5*Math.random()),s=function(e,t){var n=document.createElement("script");return n.type="text/javascript",n.async=!0,n.id=t,n.src=e,n}(t,a),c=setTimeout(function(){o(new Error("Script request to "+t+" timed out")),e(a)},i),l=function(e){clearTimeout(e)};s.addEventListener("load",function(t){r({ok:!0}),l(c),e(a)}),s.addEventListener("error",function(n){o(new Error("Script request to "+t+" failed "+n)),l(c),e(a)}),function(e){const t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)}(s)})}return ut=1,lt=function(e){return e=e||{},function(n,r){return t(n,r=r||{},e.Promise||Promise)}}}function mt(){return pt||(pt=1,ae(),function(){if(ht)return dt;ht=1;const e=gt()(),t=function(){let t;return function(){return t=t||e("https://cdn.jsdelivr.net/gh/mrdoob/three.js@r86/examples/js/loaders/GLTFLoader.js"),t}}();dt=AFRAME.registerComponent("gltf-model-legacy",{schema:{type:"model"},init:function(){this.model=null,this.loader=null,this.loaderPromise=t().then(()=>{this.loader=new THREE.GLTFLoader,this.loader.setCrossOrigin("Anonymous")})},update:function(){const e=this,t=this.el,n=this.data;n&&(this.remove(),this.loaderPromise.then(()=>{this.loader.load(n,function(n){e.model=n.scene,e.model.animations=n.animations,t.setObject3D("mesh",e.model),t.emit("model-loaded",{format:"gltf",model:e.model})})}))},remove:function(){this.model&&this.el.removeObject3D("mesh")}})}(),ft||(ft=1,AFRAME.registerComponent("object-model",{schema:{src:{type:"asset"},crossorigin:{default:""}},init:function(){this.model=null},update:function(){let e;const t=this.data;t.src&&(this.remove(),e=new THREE.ObjectLoader,t.crossorigin&&e.setCrossOrigin(t.crossorigin),e.load(t.src,e=>{e.traverse(e=>{e instanceof THREE.SkinnedMesh&&e.material&&(e.material.skinning=!!(e.geometry&&e.geometry.bones||[]).length)}),this.load(e)}))},load:function(e){this.model=e,this.el.setObject3D("mesh",e),this.el.emit("model-loaded",{format:"json",model:e})},remove:function(){this.model&&this.el.removeObject3D("mesh")}}))),ie}THREE.FBXLoader=Ke,AFRAME.registerComponent("fbx-model",{schema:{src:{type:"asset"},crossorigin:{default:""}},init:function(){this.model=null},update:function(){const e=this.data;if(!e.src)return;this.remove();const t=new THREE.FBXLoader;e.crossorigin&&t.setCrossOrigin(e.crossorigin),t.load(e.src,this.load.bind(this))},load:function(e){this.model=e,this.el.setObject3D("mesh",e),this.el.emit("model-loaded",{format:"fbx",model:e})},remove:function(){this.model&&this.el.removeObject3D("mesh")}});var yt,vt,bt,wt,xt,kt,Et,_t={};function At(){if(bt)return vt;function e(e,t,n,r){e&&(t=t||[],e.traverse(e=>{if(!e.isMesh)return;var o;((o=e.material)?Array.isArray(o)?o:o.materials?o.materials:[o]:[]).forEach(e=>{e&&!("envMap"in e)||t.length&&-1===t.indexOf(e.name)||(e.envMap=n,e.reflectivity=r,e.needsUpdate=!0)})}))}return bt=1,vt=AFRAME.registerComponent("cube-env-map",{multiple:!0,schema:{path:{default:""},extension:{default:"jpg",oneOf:["jpg","png"]},enableBackground:{default:!1},reflectivity:{default:1,min:0,max:1},materials:{default:[]}},init:function(){const t=this.data;this.texture=(new THREE.CubeTextureLoader).load([t.path+"posx."+t.extension,t.path+"negx."+t.extension,t.path+"posy."+t.extension,t.path+"negy."+t.extension,t.path+"posz."+t.extension,t.path+"negz."+t.extension]),this.texture.format=THREE.RGBAFormat,this.object3dsetHandler=()=>{const t=this.el.getObject3D("mesh"),n=this.data;e(t,n.materials,this.texture,n.reflectivity)},this.object3dsetHandler(),this.el.addEventListener("object3dset",this.object3dsetHandler)},update:function(t){const n=this.data,r=this.el.getObject3D("mesh");let o=[],i=[];if(n.materials.length&&(t.materials?(o=n.materials.filter(e=>!t.materials.includes(e)),i=t.materials.filter(e=>!n.materials.includes(e))):o=n.materials),o.length&&e(r,o,this.texture,n.reflectivity),i.length&&e(r,i,null,1),t.materials&&n.reflectivity!==t.reflectivity){const o=n.materials.filter(e=>t.materials.includes(e));o.length&&e(r,o,this.texture,n.reflectivity)}this.data.enableBackground&&!t.enableBackground?this.setBackground(this.texture):!this.data.enableBackground&&t.enableBackground&&this.setBackground(null)},remove:function(){this.el.removeEventListener("object3dset",this.object3dsetHandler);const t=this.el.getObject3D("mesh"),n=this.data;e(t,n.materials,null,1),n.enableBackground&&this.setBackground(null)},setBackground:function(e){this.el.sceneEl.object3D.background=e}})}function Mt(){return Et||(Et=1,yt||(yt=1,AFRAME.registerComponent("checkpoint",{schema:{offset:{default:{x:0,y:0,z:0},type:"vec3"}},init:function(){this.active=!1,this.targetEl=null,this.fire=this.fire.bind(this),this.offset=new THREE.Vector3},update:function(){this.offset.copy(this.data.offset)},play:function(){this.el.addEventListener("click",this.fire)},pause:function(){this.el.removeEventListener("click",this.fire)},remove:function(){this.pause()},fire:function(){const e=this.el.sceneEl.querySelector("[checkpoint-controls]");if(!e)throw new Error("No `checkpoint-controls` component found.");e.components["checkpoint-controls"].setCheckpoint(this.el)},getOffset:function(){return this.offset.copy(this.data.offset)}})),At(),wt||(wt=1,AFRAME.registerComponent("grab",{init:function(){this.system=this.el.sceneEl.systems.physics,this.GRABBED_STATE="grabbed",this.grabbing=!1,this.hitEl=null,this.physics=this.el.sceneEl.systems.physics,this.constraint=null,this.onHit=this.onHit.bind(this),this.onGripOpen=this.onGripOpen.bind(this),this.onGripClose=this.onGripClose.bind(this)},play:function(){const e=this.el;e.addEventListener("hit",this.onHit),e.addEventListener("gripdown",this.onGripClose),e.addEventListener("gripup",this.onGripOpen),e.addEventListener("trackpaddown",this.onGripClose),e.addEventListener("trackpadup",this.onGripOpen),e.addEventListener("triggerdown",this.onGripClose),e.addEventListener("triggerup",this.onGripOpen)},pause:function(){const e=this.el;e.removeEventListener("hit",this.onHit),e.removeEventListener("gripdown",this.onGripClose),e.removeEventListener("gripup",this.onGripOpen),e.removeEventListener("trackpaddown",this.onGripClose),e.removeEventListener("trackpadup",this.onGripOpen),e.removeEventListener("triggerdown",this.onGripClose),e.removeEventListener("triggerup",this.onGripOpen)},onGripClose:function(){this.grabbing=!0},onGripOpen:function(){const e=this.hitEl;this.grabbing=!1,e&&(e.removeState(this.GRABBED_STATE),this.hitEl=void 0,this.system.removeConstraint(this.constraint),this.constraint=null)},onHit:function(e){const t=e.detail.el;t.is(this.GRABBED_STATE)||!this.grabbing||this.hitEl||(t.addState(this.GRABBED_STATE),this.hitEl=t,this.constraint=new CANNON.LockConstraint(this.el.body,t.body),this.system.addConstraint(this.constraint))}})),xt||(xt=1,AFRAME.registerComponent("normal-material",{init:function(){this.material=new THREE.MeshNormalMaterial({flatShading:!0}),this.applyMaterial=this.applyMaterial.bind(this),this.el.addEventListener("object3dset",this.applyMaterial),this.applyMaterial()},remove:function(){this.el.removeEventListener("object3dset",this.applyMaterial)},applyMaterial:function(){this.el.object3D.traverse(e=>{e.isMesh&&(e.material=this.material)})}})),kt||(kt=1,AFRAME.registerComponent("sphere-collider",{schema:{enabled:{default:!0},interval:{default:80},objects:{default:""},state:{default:"collided"},radius:{default:.05},watch:{default:!0}},init:function(){this.observer=null,this.els=[],this.collisions=[],this.prevCheckTime=void 0,this.eventDetail={},this.handleHit=this.handleHit.bind(this),this.handleHitEnd=this.handleHitEnd.bind(this)},play:function(){const e=this.el.sceneEl;this.data.watch&&(this.observer=new MutationObserver(this.update.bind(this,null)),this.observer.observe(e,{childList:!0,subtree:!0}))},pause:function(){this.observer&&(this.observer.disconnect(),this.observer=null)},update:function(){const e=this.data;let t;t=e.objects?this.el.sceneEl.querySelectorAll(e.objects):this.el.sceneEl.children,this.els=Array.prototype.slice.call(t)},tick:function(){const e=new THREE.Vector3,t=new THREE.Vector3,n=new THREE.Vector3,r=new THREE.Vector3,o=new THREE.Box3,i=[],a=new Map;return function(s){if(!this.data.enabled)return;const c=this.prevCheckTime;if(c&&s-c<this.data.interval)return;this.prevCheckTime=s;const l=this.el,u=this.data;let d;var h;l.getObject3D("mesh")&&(i.length=0,a.clear(),l.object3D.getWorldPosition(e),l.object3D.getWorldScale(n),d=u.radius*(h=n,Math.max(h.x,h.y,h.z)),this.els.forEach(function(n){let s,c,l,u;n.isEntity&&(c=n.getObject3D("mesh"),c&&(o.setFromObject(c).getSize(r),u=Math.max(r.x,r.y,r.z)/2,s=Math.sqrt(2*u*u),o.getCenter(t),s&&(l=e.distanceTo(t),l<s+d&&(i.push(n),a.set(n,l)))))}),i.sort((e,t)=>a.get(e)>a.get(t)?1:-1).forEach(this.handleHit),this.collisions.filter(e=>!a.has(e)).forEach(this.handleHitEnd),function(e,t){e.length=0;for(let n=0;n<t.length;n++)e[n]=t[n]}(this.collisions,i))}}(),handleHit:function(e){e.emit("hit"),e.addState(this.data.state),this.eventDetail.el=e,this.el.emit("hit",this.eventDetail)},handleHitEnd:function(e){e.emit("hitend"),e.removeState(this.data.state),this.eventDetail.el=e,this.el.emit("hitend",this.eventDetail)}}))),_t}var Tt,Ct,Nt={};class Ot{static roundNumber(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}static sample(e){return e[Math.floor(Math.random()*e.length)]}static distanceToSquared(e,t){var n=e.x-t.x,r=e.y-t.y,o=e.z-t.z;return n*n+r*r+o*o}static isPointInPoly(e,t){for(var n=!1,r=-1,o=e.length,i=o-1;++r<o;i=r)(e[r].z<=t.z&&t.z<e[i].z||e[i].z<=t.z&&t.z<e[r].z)&&t.x<(e[i].x-e[r].x)*(t.z-e[r].z)/(e[i].z-e[r].z)+e[r].x&&(n=!n);return n}static isVectorInPolygon(e,t,n){var r=1e5,o=-1e5,i=[];return t.vertexIds.forEach(e=>{r=Math.min(n[e].y,r),o=Math.max(n[e].y,o),i.push(n[e])}),!!(e.y<o+.5&&e.y>r-.5&&this.isPointInPoly(i,e))}static triarea2(e,t,n){return(n.x-e.x)*(t.z-e.z)-(t.x-e.x)*(n.z-e.z)}static vequal(e,t){return this.distanceToSquared(e,t)<1e-5}static mergeVertices(t,n=1e-4){n=Math.max(n,Number.EPSILON);for(var r={},o=t.getIndex(),i=t.getAttribute("position"),a=o?o.count:i.count,s=0,c=[],l=[],u=Math.log10(1/n),d=Math.pow(10,u),h=0;h<a;h++){var f=o?o.getX(h):h,p="";p+=~~(i.getX(f)*d)+",",p+=~~(i.getY(f)*d)+",",(p+=~~(i.getZ(f)*d)+",")in r?c.push(r[p]):(l.push(i.getX(f)),l.push(i.getY(f)),l.push(i.getZ(f)),r[p]=s,c.push(s),s++)}const g=new e.BufferAttribute(new Float32Array(l),i.itemSize,i.normalized),m=new e.BufferGeometry;return m.setAttribute("position",g),m.setIndex(c),m}}class Dt{constructor(e){this.content=[],this.scoreFunction=e}push(e){this.content.push(e),this.sinkDown(this.content.length-1)}pop(){const e=this.content[0],t=this.content.pop();return this.content.length>0&&(this.content[0]=t,this.bubbleUp(0)),e}remove(e){const t=this.content.indexOf(e),n=this.content.pop();t!==this.content.length-1&&(this.content[t]=n,this.scoreFunction(n)<this.scoreFunction(e)?this.sinkDown(t):this.bubbleUp(t))}size(){return this.content.length}rescoreElement(e){this.sinkDown(this.content.indexOf(e))}sinkDown(e){const t=this.content[e];for(;e>0;){const n=(e+1>>1)-1,r=this.content[n];if(!(this.scoreFunction(t)<this.scoreFunction(r)))break;this.content[n]=t,this.content[e]=r,e=n}}bubbleUp(e){const t=this.content.length,n=this.content[e],r=this.scoreFunction(n);for(;;){const o=e+1<<1,i=o-1;let a,s=null;if(i<t&&(a=this.scoreFunction(this.content[i]),a<r&&(s=i)),o<t&&this.scoreFunction(this.content[o])<(null===s?r:a)&&(s=o),null===s)break;this.content[e]=this.content[s],this.content[s]=n,e=s}}}class Pt{constructor(){this.portals=[]}push(e,t){void 0===t&&(t=e),this.portals.push({left:e,right:t})}stringPull(){const e=this.portals,t=[];let n,r,o,i=0,a=0,s=0;n=e[0].left,r=e[0].left,o=e[0].right,t.push(n);for(let c=1;c<e.length;c++){const l=e[c].left,u=e[c].right;if(Ot.triarea2(n,o,u)<=0){if(!(Ot.vequal(n,o)||Ot.triarea2(n,r,u)>0)){t.push(r),n=r,i=a,r=n,o=n,a=i,s=i,c=i;continue}o=u,s=c}if(Ot.triarea2(n,r,l)>=0){if(!(Ot.vequal(n,r)||Ot.triarea2(n,o,l)<0)){t.push(o),n=o,i=s,r=n,o=n,a=i,s=i,c=i;continue}r=l,a=c}}return 0!==t.length&&Ot.vequal(t[t.length-1],e[e.length-1].left)||t.push(e[e.length-1].left),this.path=t,t}}class St{constructor(){this.zones={}}static createZone(t,n=1e-4){return class{static buildZone(t,n){const r=this._buildNavigationMesh(t,n),o={};r.vertices.forEach(e=>{e.x=Ot.roundNumber(e.x,2),e.y=Ot.roundNumber(e.y,2),e.z=Ot.roundNumber(e.z,2)}),o.vertices=r.vertices;const i=this._buildPolygonGroups(r);return o.groups=new Array(i.length),i.forEach((t,n)=>{const r=new Map;t.forEach((e,t)=>{r.set(e,t)});const i=new Array(t.length);t.forEach((t,n)=>{const a=[];t.neighbours.forEach(e=>a.push(r.get(e)));const s=[];t.neighbours.forEach(e=>s.push(this._getSharedVerticesInOrder(t,e)));const c=new e.Vector3(0,0,0);c.add(o.vertices[t.vertexIds[0]]),c.add(o.vertices[t.vertexIds[1]]),c.add(o.vertices[t.vertexIds[2]]),c.divideScalar(3),c.x=Ot.roundNumber(c.x,2),c.y=Ot.roundNumber(c.y,2),c.z=Ot.roundNumber(c.z,2),i[n]={id:n,neighbours:a,vertexIds:t.vertexIds,centroid:c,portals:s}}),o.groups[n]=i}),o}static _buildNavigationMesh(e,t){return e=Ot.mergeVertices(e,t),this._buildPolygonsFromGeometry(e)}static _spreadGroupId(e){let t=new Set([e]);for(;t.size>0;){const n=t;t=new Set,n.forEach(n=>{n.group=e.group,n.neighbours.forEach(e=>{void 0===e.group&&t.add(e)})})}}static _buildPolygonGroups(e){const t=[];return e.polygons.forEach(e=>{void 0!==e.group?t[e.group].push(e):(e.group=t.length,this._spreadGroupId(e),t.push([e]))}),t}static _buildPolygonNeighbours(e,t){const n=new Set,r=t[e.vertexIds[1]],o=t[e.vertexIds[2]];return t[e.vertexIds[0]].forEach(t=>{t!==e&&(r.includes(t)||o.includes(t))&&n.add(t)}),r.forEach(t=>{t!==e&&o.includes(t)&&n.add(t)}),n}static _buildPolygonsFromGeometry(t){const n=[],r=[],o=t.attributes.position,i=t.index,a=[];for(let t=0;t<o.count;t++)r.push((new e.Vector3).fromBufferAttribute(o,t)),a[t]=[];for(let e=0;e<t.index.count;e+=3){const t=i.getX(e),r=i.getX(e+1),o=i.getX(e+2),s={vertexIds:[t,r,o],neighbours:null};n.push(s),a[t].push(s),a[r].push(s),a[o].push(s)}return n.forEach(e=>{e.neighbours=this._buildPolygonNeighbours(e,a)}),{polygons:n,vertices:r}}static _getSharedVerticesInOrder(e,t){const n=e.vertexIds,r=n[0],o=n[1],i=n[2],a=t.vertexIds,s=a.includes(r),c=a.includes(o),l=a.includes(i);return s&&c&&l?Array.from(n):s&&c?[r,o]:c&&l?[o,i]:s&&l?[i,r]:(console.warn("Error processing navigation mesh neighbors; neighbors with <2 shared vertices found."),[])}}.buildZone(t,n)}setZoneData(e,t){this.zones[e]=t}getRandomNode(t,n,r,o){if(!this.zones[t])return new e.Vector3;r=r||null,o=o||0;const i=[];return this.zones[t].groups[n].forEach(e=>{r&&o?Ot.distanceToSquared(r,e.centroid)<o*o&&i.push(e.centroid):i.push(e.centroid)}),Ot.sample(i)||new e.Vector3}getClosestNode(e,t,n,r=!1){const o=this.zones[t].vertices;let i=null,a=1/0;return this.zones[t].groups[n].forEach(t=>{const n=Ot.distanceToSquared(t.centroid,e);n<a&&(!r||Ot.isVectorInPolygon(e,t,o))&&(i=t,a=n)}),i}findPath(t,n,r,o){const i=this.zones[r].groups[o],a=this.zones[r].vertices,s=this.getClosestNode(t,r,o,!0),c=this.getClosestNode(n,r,o,!0);if(!s||!c)return null;const l=class{static init(e){for(let t=0;t<e.length;t++){const n=e[t];n.f=0,n.g=0,n.h=0,n.cost=1,n.visited=!1,n.closed=!1,n.parent=null}}static cleanUp(e){for(let t=0;t<e.length;t++){const n=e[t];delete n.f,delete n.g,delete n.h,delete n.cost,delete n.visited,delete n.closed,delete n.parent}}static heap(){return new Dt(function(e){return e.f})}static search(e,t,n){this.init(e);const r=this.heap();for(r.push(t);r.size()>0;){const t=r.pop();if(t===n){let e=t;const n=[];for(;e.parent;)n.push(e),e=e.parent;return this.cleanUp(n),n.reverse()}t.closed=!0;const o=this.neighbours(e,t);for(let e=0,i=o.length;e<i;e++){const i=o[e];if(i.closed)continue;const a=t.g+i.cost,s=i.visited;if(!s||a<i.g){if(i.visited=!0,i.parent=t,!i.centroid||!n.centroid)throw new Error("Unexpected state");i.h=i.h||this.heuristic(i.centroid,n.centroid),i.g=a,i.f=i.g+i.h,s?r.rescoreElement(i):r.push(i)}}}return[]}static heuristic(e,t){return Ot.distanceToSquared(e,t)}static neighbours(e,t){const n=[];for(let r=0;r<t.neighbours.length;r++)n.push(e[t.neighbours[r]]);return n}}.search(i,s,c),u=function(e,t){for(var n=0;n<e.neighbours.length;n++)if(e.neighbours[n]===t.id)return e.portals[n]},d=new Pt;d.push(t);for(let e=0;e<l.length;e++){const t=l[e],n=l[e+1];if(n){const e=u(t,n);d.push(a[e[0]],a[e[1]])}}d.push(n),d.stringPull();const h=d.path.map(t=>new e.Vector3(t.x,t.y,t.z));return h.shift(),h}}St.prototype.getGroup=function(){const t=new e.Plane;return function(e,n,r=!1){if(!this.zones[e])return null;let o=null,i=Math.pow(50,2);const a=this.zones[e];for(let e=0;e<a.groups.length;e++){const s=a.groups[e];for(const c of s){if(r&&(t.setFromCoplanarPoints(a.vertices[c.vertexIds[0]],a.vertices[c.vertexIds[1]],a.vertices[c.vertexIds[2]]),Math.abs(t.distanceToPoint(n))<.01)&&Ot.isPointInPoly([a.vertices[c.vertexIds[0]],a.vertices[c.vertexIds[1]],a.vertices[c.vertexIds[2]]],n))return e;const s=Ot.distanceToSquared(c.centroid,n);s<i&&(o=e,i=s)}}return o}}(),St.prototype.clampStep=function(){const t=new e.Vector3,n=new e.Plane,r=new e.Triangle,o=new e.Vector3;let i,a,s=new e.Vector3;return function(e,c,l,u,d,h){const f=this.zones[u].vertices,p=this.zones[u].groups[d],g=[l],m={};m[l.id]=0,i=void 0,s.set(0,0,0),a=1/0,n.setFromCoplanarPoints(f[l.vertexIds[0]],f[l.vertexIds[1]],f[l.vertexIds[2]]),n.projectPoint(c,t),o.copy(t);for(let e=g.pop();e;e=g.pop()){r.set(f[e.vertexIds[0]],f[e.vertexIds[1]],f[e.vertexIds[2]]),r.closestPointToPoint(o,t),t.distanceToSquared(o)<a&&(i=e,s.copy(t),a=t.distanceToSquared(o));const n=m[e.id];if(!(n>2))for(let t=0;t<e.neighbours.length;t++){const r=p[e.neighbours[t]];r.id in m||(g.push(r),m[r.id]=n+1)}}return h.copy(s),i}}();class Lt extends e.Object3D{constructor(){super(),this._playerMarker=new e.Mesh(new e.SphereGeometry(.25,32,32),new e.MeshBasicMaterial({color:15631215})),this._targetMarker=new e.Mesh(new e.BoxGeometry(.3,.3,.3),new e.MeshBasicMaterial({color:14469912})),this._nodeMarker=new e.Mesh(new e.BoxGeometry(.1,.8,.1),new e.MeshBasicMaterial({color:4417387})),this._stepMarker=new e.Mesh(new e.BoxGeometry(.1,1,.1),new e.MeshBasicMaterial({color:14472114})),this._pathMarker=new e.Object3D,this._pathLineMaterial=new e.LineBasicMaterial({color:41903,linewidth:2}),this._pathPointMaterial=new e.MeshBasicMaterial({color:41903}),this._pathPointGeometry=new e.SphereGeometry(.08),this._markers=[this._playerMarker,this._targetMarker,this._nodeMarker,this._stepMarker,this._pathMarker],this._markers.forEach(e=>{e.visible=!1,this.add(e)})}setPath(t){for(;this._pathMarker.children.length;)this._pathMarker.children[0].visible=!1,this._pathMarker.remove(this._pathMarker.children[0]);t=[this._playerMarker.position].concat(t);const n=new e.BufferGeometry;n.setAttribute("position",new e.BufferAttribute(new Float32Array(3*t.length),3));for(let e=0;e<t.length;e++)n.attributes.position.setXYZ(e,t[e].x,t[e].y+.2,t[e].z);this._pathMarker.add(new e.Line(n,this._pathLineMaterial));for(let n=0;n<t.length-1;n++){const r=new e.Mesh(this._pathPointGeometry,this._pathPointMaterial);r.position.copy(t[n]),r.position.y+=.2,this._pathMarker.add(r)}return this._pathMarker.visible=!0,this}setPlayerPosition(e){return this._playerMarker.position.copy(e),this._playerMarker.visible=!0,this}setTargetPosition(e){return this._targetMarker.position.copy(e),this._targetMarker.visible=!0,this}setNodePosition(e){return this._nodeMarker.position.copy(e),this._nodeMarker.visible=!0,this}setStepPosition(e){return this._stepMarker.position.copy(e),this._stepMarker.visible=!0,this}reset(){for(;this._pathMarker.children.length;)this._pathMarker.children[0].visible=!1,this._pathMarker.remove(this._pathMarker.children[0]);return this._markers.forEach(e=>{e.visible=!1}),this}}var It,jt,Rt,Ft=l(Object.freeze({__proto__:null,Pathfinding:St,PathfindingHelper:Lt}));function Bt(){return Rt||(Rt=1,Tt||(Tt=1,AFRAME.registerComponent("nav-mesh",{schema:{nodeName:{type:"string"}},init:function(){this.system=this.el.sceneEl.systems.nav,this.hasLoadedNavMesh=!1,this.nodeName=this.data.nodeName,this.el.addEventListener("object3dset",this.loadNavMesh.bind(this))},play:function(){this.hasLoadedNavMesh||this.loadNavMesh()},loadNavMesh:function(){var e=this;const t=this.el.getObject3D("mesh");if(this.el.sceneEl.object3D,!t)return;let n;if(t.traverse(t=>{!t.isMesh||e.nodeName&&t.name!==e.nodeName||(n=t)}),!n)return;const r=n.geometry.clone();n.updateWorldMatrix(!0,!1),r.applyMatrix4(n.matrixWorld),this.system.setNavMeshGeometry(r),this.hasLoadedNavMesh=!0}})),Ct||(Ct=1,AFRAME.registerComponent("nav-agent",{schema:{destination:{type:"vec3"},active:{default:!1},speed:{default:2}},init:function(){this.system=this.el.sceneEl.systems.nav,this.system.addAgent(this),this.group=null,this.path=[],this.raycaster=new THREE.Raycaster},remove:function(){this.system.removeAgent(this)},update:function(){this.path.length=0},updateNavLocation:function(){this.group=null,this.path=[]},tick:function(){const e=new THREE.Vector3,t=new THREE.Vector3,n=new THREE.Vector3;return function(r,o){const i=this.el,a=this.data,s=this.raycaster,c=a.speed*o/1e3;if(!a.active)return;if(!this.path.length){const t=this.el.object3D.position;this.group=this.group||this.system.getGroup(t),this.path=this.system.getPath(t,e.copy(a.destination),this.group)||[],i.emit("navigation-start")}if(!this.path.length)return console.warn("[nav] Unable to find path to %o.",a.destination),this.el.setAttribute("nav-agent",{active:!1}),void i.emit("navigation-end");const l=i.object3D.position,u=this.path[0];let d;if(t.subVectors(u,l),t.length()<c){if(this.path.shift(),!this.path.length)return this.el.setAttribute("nav-agent",{active:!1}),void i.emit("navigation-end");n.copy(l),d=this.path[0]}else n.copy(t.setLength(c)).add(l),d=u;d.y=l.y,i.object3D.lookAt(d),s.ray.origin.copy(n),s.ray.origin.y+=1.5,s.ray.direction={x:0,y:-1,z:0};const h=s.intersectObject(this.system.getNavMesh());h.length?(t.subVectors(h[0].point,l),l.add(t.setLength(c))):l.copy(n)}}()})),function(){if(jt)return It;jt=1;const{Pathfinding:e}=Ft,t=new e,n="level";It=AFRAME.registerSystem("nav",{init:function(){this.navMesh=null,this.agents=new Set},setNavMeshGeometry:function(r){this.navMesh=new THREE.Mesh(r),t.setZoneData(n,e.createZone(r)),Array.from(this.agents).forEach(e=>e.updateNavLocation())},getNavMesh:function(){return this.navMesh},addAgent:function(e){this.agents.add(e)},removeAgent:function(e){this.agents.delete(e)},getPath:function(e,r,o){return this.navMesh?t.findPath(e,r,n,o):null},getGroup:function(e){return this.navMesh?t.getGroup(n,e):null},getNode:function(e,r){return this.navMesh?t.getClosestNode(e,n,r,!0):null},clampStep:function(e,r,o,i,a){return this.navMesh?i?t.clampStep(e,r,i,n,o,a):(a.copy(r),this.getNode(r,o)):(a.copy(r),null)}})}()),Nt}var zt,Vt={};var Ut,Gt={};var Ht,Kt,qt,$t={};function Wt(){return Kt||(Kt=1,zt||(zt=1,AFRAME.registerPrimitive("a-grid",{defaultComponents:{geometry:{primitive:"plane",width:75,height:75},rotation:{x:-90,y:0,z:0},material:{src:"url(https://cdn.jsdelivr.net/gh/donmccurdy/aframe-extras@v1.16.3/assets/grid.png)",repeat:"75 75"}},mappings:{width:"geometry.width",height:"geometry.height",src:"material.src"}})),Ut||(Ut=1,Gt.Primitive=AFRAME.registerPrimitive("a-ocean",{defaultComponents:{ocean:{},rotation:{x:-90,y:0,z:0}},mappings:{width:"ocean.width",depth:"ocean.depth",density:"ocean.density",amplitude:"ocean.amplitude",amplitudeVariance:"ocean.amplitudeVariance",speed:"ocean.speed",speedVariance:"ocean.speedVariance",color:"ocean.color",opacity:"ocean.opacity"}}),Gt.Component=AFRAME.registerComponent("ocean",{schema:{width:{default:10,min:0},depth:{default:10,min:0},density:{default:10},amplitude:{default:.1},amplitudeVariance:{default:.3},speed:{default:1},speedVariance:{default:2},color:{default:"#7AD2F7",type:"color"},opacity:{default:.8}},play:function(){const e=this.el,t=this.data;let n=e.components.material;const r=new THREE.PlaneGeometry(t.width,t.depth,t.density,t.density);this.waves=[];const o=r.getAttribute("position");for(let e=0;e<o.count;e++)this.waves.push({z:o.getZ(e),ang:Math.random()*Math.PI*2,amp:t.amplitude+Math.random()*t.amplitudeVariance,speed:(t.speed+Math.random()*t.speedVariance)/1e3});n||(n={},n.material=new THREE.MeshPhongMaterial({color:t.color,transparent:t.opacity<1,opacity:t.opacity,flatShading:!0})),this.mesh=new THREE.Mesh(r,n.material),e.setObject3D("mesh",this.mesh)},remove:function(){this.el.removeObject3D("mesh")},tick:function(e,t){if(!t)return;const n=this.mesh.geometry.getAttribute("position");for(let e=0;e<n.count;e++){const r=this.waves[e],o=r.z+Math.sin(r.ang)*r.amp;n.setZ(e,o),r.ang+=r.speed*t}n.needsUpdate=!0}})),Ht||(Ht=1,$t.Primitive=AFRAME.registerPrimitive("a-tube",{defaultComponents:{tube:{}},mappings:{path:"tube.path",segments:"tube.segments",radius:"tube.radius","radial-segments":"tube.radialSegments",closed:"tube.closed"}}),$t.Component=AFRAME.registerComponent("tube",{schema:{path:{default:[]},segments:{default:64},radius:{default:1},radialSegments:{default:8},closed:{default:!1}},init:function(){const e=this.el,t=this.data;let n=e.components.material;if(!t.path.length)return void console.error("[a-tube] `path` property expected but not found.");const r=new THREE.CatmullRomCurve3(t.path.map(function(e){return e=e.split(" "),new THREE.Vector3(Number(e[0]),Number(e[1]),Number(e[2]))})),o=new THREE.TubeGeometry(r,t.segments,t.radius,t.radialSegments,t.closed);n||(n={},n.material=new THREE.MeshPhongMaterial),this.mesh=new THREE.Mesh(o,n.material),this.el.setObject3D("mesh",this.mesh)},update:function(e){Object.keys(e).length&&(this.remove(),this.init())},remove:function(){this.mesh&&this.el.removeObject3D("mesh")}}))),Vt}function Xt(e,t,n){var r,o=1;function i(){var i,a,s=r.length,c=0,l=0,u=0;for(i=0;i<s;++i)c+=(a=r[i]).x||0,l+=a.y||0,u+=a.z||0;for(c=(c/s-e)*o,l=(l/s-t)*o,u=(u/s-n)*o,i=0;i<s;++i)a=r[i],c&&(a.x-=c),l&&(a.y-=l),u&&(a.z-=u)}return null==e&&(e=0),null==t&&(t=0),null==n&&(n=0),i.initialize=function(e){r=e},i.x=function(t){return arguments.length?(e=+t,i):e},i.y=function(e){return arguments.length?(t=+e,i):t},i.z=function(e){return arguments.length?(n=+e,i):n},i.strength=function(e){return arguments.length?(o=+e,i):o},i}function Jt(e,t,n){if(isNaN(t))return e;var r,o,i,a,s,c,l=e._root,u={data:n},d=e._x0,h=e._x1;if(!l)return e._root=u,e;for(;l.length;)if((a=t>=(o=(d+h)/2))?d=o:h=o,r=l,!(l=l[s=+a]))return r[s]=u,e;if(t===(i=+e._x.call(null,l.data)))return u.next=l,r?r[s]=u:e._root=u,e;do{r=r?r[s]=new Array(2):e._root=new Array(2),(a=t>=(o=(d+h)/2))?d=o:h=o}while((s=+a)===(c=+(i>=o)));return r[c]=l,r[s]=u,e}function Zt(e,t,n){this.node=e,this.x0=t,this.x1=n}function Yt(e){return e[0]}function Qt(e,t){var n=new en(null==t?Yt:t,NaN,NaN);return null==e?n:n.addAll(e)}function en(e,t,n){this._x=e,this._x0=t,this._x1=n,this._root=void 0}function tn(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}qt||(qt=1,ne(),mt(),Mt(),Bt(),Wt());var nn=Qt.prototype=en.prototype;function rn(e,t,n,r){if(isNaN(t)||isNaN(n))return e;var o,i,a,s,c,l,u,d,h,f=e._root,p={data:r},g=e._x0,m=e._y0,y=e._x1,v=e._y1;if(!f)return e._root=p,e;for(;f.length;)if((l=t>=(i=(g+y)/2))?g=i:y=i,(u=n>=(a=(m+v)/2))?m=a:v=a,o=f,!(f=f[d=u<<1|l]))return o[d]=p,e;if(s=+e._x.call(null,f.data),c=+e._y.call(null,f.data),t===s&&n===c)return p.next=f,o?o[d]=p:e._root=p,e;do{o=o?o[d]=new Array(4):e._root=new Array(4),(l=t>=(i=(g+y)/2))?g=i:y=i,(u=n>=(a=(m+v)/2))?m=a:v=a}while((d=u<<1|l)==(h=(c>=a)<<1|s>=i));return o[h]=f,o[d]=p,e}function on(e,t,n,r,o){this.node=e,this.x0=t,this.y0=n,this.x1=r,this.y1=o}function an(e){return e[0]}function sn(e){return e[1]}function cn(e,t,n){var r=new ln(null==t?an:t,null==n?sn:n,NaN,NaN,NaN,NaN);return null==e?r:r.addAll(e)}function ln(e,t,n,r,o,i){this._x=e,this._y=t,this._x0=n,this._y0=r,this._x1=o,this._y1=i,this._root=void 0}function un(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}nn.copy=function(){var e,t,n=new en(this._x,this._x0,this._x1),r=this._root;if(!r)return n;if(!r.length)return n._root=tn(r),n;for(e=[{source:r,target:n._root=new Array(2)}];r=e.pop();)for(var o=0;o<2;++o)(t=r.source[o])&&(t.length?e.push({source:t,target:r.target[o]=new Array(2)}):r.target[o]=tn(t));return n},nn.add=function(e){const t=+this._x.call(null,e);return Jt(this.cover(t),t,e)},nn.addAll=function(e){Array.isArray(e)||(e=Array.from(e));const t=e.length,n=new Float64Array(t);let r=1/0,o=-1/0;for(let i,a=0;a<t;++a)isNaN(i=+this._x.call(null,e[a]))||(n[a]=i,i<r&&(r=i),i>o&&(o=i));if(r>o)return this;this.cover(r).cover(o);for(let r=0;r<t;++r)Jt(this,n[r],e[r]);return this},nn.cover=function(e){if(isNaN(e=+e))return this;var t=this._x0,n=this._x1;if(isNaN(t))n=(t=Math.floor(e))+1;else{for(var r,o,i=n-t||1,a=this._root;t>e||e>=n;)switch(o=+(e<t),(r=new Array(2))[o]=a,a=r,i*=2,o){case 0:n=t+i;break;case 1:t=n-i}this._root&&this._root.length&&(this._root=a)}return this._x0=t,this._x1=n,this},nn.data=function(){var e=[];return this.visit(function(t){if(!t.length)do{e.push(t.data)}while(t=t.next)}),e},nn.extent=function(e){return arguments.length?this.cover(+e[0][0]).cover(+e[1][0]):isNaN(this._x0)?void 0:[[this._x0],[this._x1]]},nn.find=function(e,t){var n,r,o,i,a,s=this._x0,c=this._x1,l=[],u=this._root;for(u&&l.push(new Zt(u,s,c)),null==t?t=1/0:(s=e-t,c=e+t);i=l.pop();)if(!(!(u=i.node)||(r=i.x0)>c||(o=i.x1)<s))if(u.length){var d=(r+o)/2;l.push(new Zt(u[1],d,o),new Zt(u[0],r,d)),(a=+(e>=d))&&(i=l[l.length-1],l[l.length-1]=l[l.length-1-a],l[l.length-1-a]=i)}else{var h=Math.abs(e-+this._x.call(null,u.data));h<t&&(t=h,s=e-h,c=e+h,n=u.data)}return n},nn.remove=function(e){if(isNaN(i=+this._x.call(null,e)))return this;var t,n,r,o,i,a,s,c,l,u=this._root,d=this._x0,h=this._x1;if(!u)return this;if(u.length)for(;;){if((s=i>=(a=(d+h)/2))?d=a:h=a,t=u,!(u=u[c=+s]))return this;if(!u.length)break;t[c+1&1]&&(n=t,l=c)}for(;u.data!==e;)if(r=u,!(u=u.next))return this;return(o=u.next)&&delete u.next,r?(o?r.next=o:delete r.next,this):t?(o?t[c]=o:delete t[c],(u=t[0]||t[1])&&u===(t[1]||t[0])&&!u.length&&(n?n[l]=u:this._root=u),this):(this._root=o,this)},nn.removeAll=function(e){for(var t=0,n=e.length;t<n;++t)this.remove(e[t]);return this},nn.root=function(){return this._root},nn.size=function(){var e=0;return this.visit(function(t){if(!t.length)do{++e}while(t=t.next)}),e},nn.visit=function(e){var t,n,r,o,i=[],a=this._root;for(a&&i.push(new Zt(a,this._x0,this._x1));t=i.pop();)if(!e(a=t.node,r=t.x0,o=t.x1)&&a.length){var s=(r+o)/2;(n=a[1])&&i.push(new Zt(n,s,o)),(n=a[0])&&i.push(new Zt(n,r,s))}return this},nn.visitAfter=function(e){var t,n=[],r=[];for(this._root&&n.push(new Zt(this._root,this._x0,this._x1));t=n.pop();){var o=t.node;if(o.length){var i,a=t.x0,s=t.x1,c=(a+s)/2;(i=o[0])&&n.push(new Zt(i,a,c)),(i=o[1])&&n.push(new Zt(i,c,s))}r.push(t)}for(;t=r.pop();)e(t.node,t.x0,t.x1);return this},nn.x=function(e){return arguments.length?(this._x=e,this):this._x};var dn=cn.prototype=ln.prototype;function hn(e,t,n,r,o){if(isNaN(t)||isNaN(n)||isNaN(r))return e;var i,a,s,c,l,u,d,h,f,p,g,m,y=e._root,v={data:o},b=e._x0,w=e._y0,x=e._z0,k=e._x1,E=e._y1,_=e._z1;if(!y)return e._root=v,e;for(;y.length;)if((h=t>=(a=(b+k)/2))?b=a:k=a,(f=n>=(s=(w+E)/2))?w=s:E=s,(p=r>=(c=(x+_)/2))?x=c:_=c,i=y,!(y=y[g=p<<2|f<<1|h]))return i[g]=v,e;if(l=+e._x.call(null,y.data),u=+e._y.call(null,y.data),d=+e._z.call(null,y.data),t===l&&n===u&&r===d)return v.next=y,i?i[g]=v:e._root=v,e;do{i=i?i[g]=new Array(8):e._root=new Array(8),(h=t>=(a=(b+k)/2))?b=a:k=a,(f=n>=(s=(w+E)/2))?w=s:E=s,(p=r>=(c=(x+_)/2))?x=c:_=c}while((g=p<<2|f<<1|h)==(m=(d>=c)<<2|(u>=s)<<1|l>=a));return i[m]=y,i[g]=v,e}function fn(e,t,n,r,o,i,a){this.node=e,this.x0=t,this.y0=n,this.z0=r,this.x1=o,this.y1=i,this.z1=a}dn.copy=function(){var e,t,n=new ln(this._x,this._y,this._x0,this._y0,this._x1,this._y1),r=this._root;if(!r)return n;if(!r.length)return n._root=un(r),n;for(e=[{source:r,target:n._root=new Array(4)}];r=e.pop();)for(var o=0;o<4;++o)(t=r.source[o])&&(t.length?e.push({source:t,target:r.target[o]=new Array(4)}):r.target[o]=un(t));return n},dn.add=function(e){const t=+this._x.call(null,e),n=+this._y.call(null,e);return rn(this.cover(t,n),t,n,e)},dn.addAll=function(e){var t,n,r,o,i=e.length,a=new Array(i),s=new Array(i),c=1/0,l=1/0,u=-1/0,d=-1/0;for(n=0;n<i;++n)isNaN(r=+this._x.call(null,t=e[n]))||isNaN(o=+this._y.call(null,t))||(a[n]=r,s[n]=o,r<c&&(c=r),r>u&&(u=r),o<l&&(l=o),o>d&&(d=o));if(c>u||l>d)return this;for(this.cover(c,l).cover(u,d),n=0;n<i;++n)rn(this,a[n],s[n],e[n]);return this},dn.cover=function(e,t){if(isNaN(e=+e)||isNaN(t=+t))return this;var n=this._x0,r=this._y0,o=this._x1,i=this._y1;if(isNaN(n))o=(n=Math.floor(e))+1,i=(r=Math.floor(t))+1;else{for(var a,s,c=o-n||1,l=this._root;n>e||e>=o||r>t||t>=i;)switch(s=(t<r)<<1|e<n,(a=new Array(4))[s]=l,l=a,c*=2,s){case 0:o=n+c,i=r+c;break;case 1:n=o-c,i=r+c;break;case 2:o=n+c,r=i-c;break;case 3:n=o-c,r=i-c}this._root&&this._root.length&&(this._root=l)}return this._x0=n,this._y0=r,this._x1=o,this._y1=i,this},dn.data=function(){var e=[];return this.visit(function(t){if(!t.length)do{e.push(t.data)}while(t=t.next)}),e},dn.extent=function(e){return arguments.length?this.cover(+e[0][0],+e[0][1]).cover(+e[1][0],+e[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},dn.find=function(e,t,n){var r,o,i,a,s,c,l,u=this._x0,d=this._y0,h=this._x1,f=this._y1,p=[],g=this._root;for(g&&p.push(new on(g,u,d,h,f)),null==n?n=1/0:(u=e-n,d=t-n,h=e+n,f=t+n,n*=n);c=p.pop();)if(!(!(g=c.node)||(o=c.x0)>h||(i=c.y0)>f||(a=c.x1)<u||(s=c.y1)<d))if(g.length){var m=(o+a)/2,y=(i+s)/2;p.push(new on(g[3],m,y,a,s),new on(g[2],o,y,m,s),new on(g[1],m,i,a,y),new on(g[0],o,i,m,y)),(l=(t>=y)<<1|e>=m)&&(c=p[p.length-1],p[p.length-1]=p[p.length-1-l],p[p.length-1-l]=c)}else{var v=e-+this._x.call(null,g.data),b=t-+this._y.call(null,g.data),w=v*v+b*b;if(w<n){var x=Math.sqrt(n=w);u=e-x,d=t-x,h=e+x,f=t+x,r=g.data}}return r},dn.remove=function(e){if(isNaN(i=+this._x.call(null,e))||isNaN(a=+this._y.call(null,e)))return this;var t,n,r,o,i,a,s,c,l,u,d,h,f=this._root,p=this._x0,g=this._y0,m=this._x1,y=this._y1;if(!f)return this;if(f.length)for(;;){if((l=i>=(s=(p+m)/2))?p=s:m=s,(u=a>=(c=(g+y)/2))?g=c:y=c,t=f,!(f=f[d=u<<1|l]))return this;if(!f.length)break;(t[d+1&3]||t[d+2&3]||t[d+3&3])&&(n=t,h=d)}for(;f.data!==e;)if(r=f,!(f=f.next))return this;return(o=f.next)&&delete f.next,r?(o?r.next=o:delete r.next,this):t?(o?t[d]=o:delete t[d],(f=t[0]||t[1]||t[2]||t[3])&&f===(t[3]||t[2]||t[1]||t[0])&&!f.length&&(n?n[h]=f:this._root=f),this):(this._root=o,this)},dn.removeAll=function(e){for(var t=0,n=e.length;t<n;++t)this.remove(e[t]);return this},dn.root=function(){return this._root},dn.size=function(){var e=0;return this.visit(function(t){if(!t.length)do{++e}while(t=t.next)}),e},dn.visit=function(e){var t,n,r,o,i,a,s=[],c=this._root;for(c&&s.push(new on(c,this._x0,this._y0,this._x1,this._y1));t=s.pop();)if(!e(c=t.node,r=t.x0,o=t.y0,i=t.x1,a=t.y1)&&c.length){var l=(r+i)/2,u=(o+a)/2;(n=c[3])&&s.push(new on(n,l,u,i,a)),(n=c[2])&&s.push(new on(n,r,u,l,a)),(n=c[1])&&s.push(new on(n,l,o,i,u)),(n=c[0])&&s.push(new on(n,r,o,l,u))}return this},dn.visitAfter=function(e){var t,n=[],r=[];for(this._root&&n.push(new on(this._root,this._x0,this._y0,this._x1,this._y1));t=n.pop();){var o=t.node;if(o.length){var i,a=t.x0,s=t.y0,c=t.x1,l=t.y1,u=(a+c)/2,d=(s+l)/2;(i=o[0])&&n.push(new on(i,a,s,u,d)),(i=o[1])&&n.push(new on(i,u,s,c,d)),(i=o[2])&&n.push(new on(i,a,d,u,l)),(i=o[3])&&n.push(new on(i,u,d,c,l))}r.push(t)}for(;t=r.pop();)e(t.node,t.x0,t.y0,t.x1,t.y1);return this},dn.x=function(e){return arguments.length?(this._x=e,this):this._x},dn.y=function(e){return arguments.length?(this._y=e,this):this._y};const pn=(e,t,n,r,o,i)=>Math.sqrt((e-r)**2+(t-o)**2+(n-i)**2);function gn(e){return e[0]}function mn(e){return e[1]}function yn(e){return e[2]}function vn(e,t,n,r){var o=new bn(null==t?gn:t,null==n?mn:n,null==r?yn:r,NaN,NaN,NaN,NaN,NaN,NaN);return null==e?o:o.addAll(e)}function bn(e,t,n,r,o,i,a,s,c){this._x=e,this._y=t,this._z=n,this._x0=r,this._y0=o,this._z0=i,this._x1=a,this._y1=s,this._z1=c,this._root=void 0}function wn(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var xn=vn.prototype=bn.prototype;function kn(e){return function(){return e}}function En(e){return 1e-6*(e()-.5)}function _n(e){return e.index}function An(e,t){var n=e.get(t);if(!n)throw new Error("node not found: "+t);return n}function Mn(e){var t,n,r,o,i,a,s,c=_n,l=function(e){return 1/Math.min(i[e.source.index],i[e.target.index])},u=kn(30),d=1;function h(r){for(var i=0,c=e.length;i<d;++i)for(var l,u,h,f,p,g=0,m=0,y=0,v=0;g<c;++g)u=(l=e[g]).source,m=(h=l.target).x+h.vx-u.x-u.vx||En(s),o>1&&(y=h.y+h.vy-u.y-u.vy||En(s)),o>2&&(v=h.z+h.vz-u.z-u.vz||En(s)),m*=f=((f=Math.sqrt(m*m+y*y+v*v))-n[g])/f*r*t[g],y*=f,v*=f,h.vx-=m*(p=a[g]),o>1&&(h.vy-=y*p),o>2&&(h.vz-=v*p),u.vx+=m*(p=1-p),o>1&&(u.vy+=y*p),o>2&&(u.vz+=v*p)}function f(){if(r){var o,s,l=r.length,u=e.length,d=new Map(r.map((e,t)=>[c(e,t,r),e]));for(o=0,i=new Array(l);o<u;++o)(s=e[o]).index=o,"object"!=typeof s.source&&(s.source=An(d,s.source)),"object"!=typeof s.target&&(s.target=An(d,s.target)),i[s.source.index]=(i[s.source.index]||0)+1,i[s.target.index]=(i[s.target.index]||0)+1;for(o=0,a=new Array(u);o<u;++o)s=e[o],a[o]=i[s.source.index]/(i[s.source.index]+i[s.target.index]);t=new Array(u),p(),n=new Array(u),g()}}function p(){if(r)for(var n=0,o=e.length;n<o;++n)t[n]=+l(e[n],n,e)}function g(){if(r)for(var t=0,o=e.length;t<o;++t)n[t]=+u(e[t],t,e)}return null==e&&(e=[]),h.initialize=function(e,...t){r=e,s=t.find(e=>"function"==typeof e)||Math.random,o=t.find(e=>[1,2,3].includes(e))||2,f()},h.links=function(t){return arguments.length?(e=t,f(),h):e},h.id=function(e){return arguments.length?(c=e,h):c},h.iterations=function(e){return arguments.length?(d=+e,h):d},h.strength=function(e){return arguments.length?(l="function"==typeof e?e:kn(+e),p(),h):l},h.distance=function(e){return arguments.length?(u="function"==typeof e?e:kn(+e),g(),h):u},h}xn.copy=function(){var e,t,n=new bn(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),r=this._root;if(!r)return n;if(!r.length)return n._root=wn(r),n;for(e=[{source:r,target:n._root=new Array(8)}];r=e.pop();)for(var o=0;o<8;++o)(t=r.source[o])&&(t.length?e.push({source:t,target:r.target[o]=new Array(8)}):r.target[o]=wn(t));return n},xn.add=function(e){const t=+this._x.call(null,e),n=+this._y.call(null,e),r=+this._z.call(null,e);return hn(this.cover(t,n,r),t,n,r,e)},xn.addAll=function(e){Array.isArray(e)||(e=Array.from(e));const t=e.length,n=new Float64Array(t),r=new Float64Array(t),o=new Float64Array(t);let i=1/0,a=1/0,s=1/0,c=-1/0,l=-1/0,u=-1/0;for(let d,h,f,p,g=0;g<t;++g)isNaN(h=+this._x.call(null,d=e[g]))||isNaN(f=+this._y.call(null,d))||isNaN(p=+this._z.call(null,d))||(n[g]=h,r[g]=f,o[g]=p,h<i&&(i=h),h>c&&(c=h),f<a&&(a=f),f>l&&(l=f),p<s&&(s=p),p>u&&(u=p));if(i>c||a>l||s>u)return this;this.cover(i,a,s).cover(c,l,u);for(let i=0;i<t;++i)hn(this,n[i],r[i],o[i],e[i]);return this},xn.cover=function(e,t,n){if(isNaN(e=+e)||isNaN(t=+t)||isNaN(n=+n))return this;var r=this._x0,o=this._y0,i=this._z0,a=this._x1,s=this._y1,c=this._z1;if(isNaN(r))a=(r=Math.floor(e))+1,s=(o=Math.floor(t))+1,c=(i=Math.floor(n))+1;else{for(var l,u,d=a-r||1,h=this._root;r>e||e>=a||o>t||t>=s||i>n||n>=c;)switch(u=(n<i)<<2|(t<o)<<1|e<r,(l=new Array(8))[u]=h,h=l,d*=2,u){case 0:a=r+d,s=o+d,c=i+d;break;case 1:r=a-d,s=o+d,c=i+d;break;case 2:a=r+d,o=s-d,c=i+d;break;case 3:r=a-d,o=s-d,c=i+d;break;case 4:a=r+d,s=o+d,i=c-d;break;case 5:r=a-d,s=o+d,i=c-d;break;case 6:a=r+d,o=s-d,i=c-d;break;case 7:r=a-d,o=s-d,i=c-d}this._root&&this._root.length&&(this._root=h)}return this._x0=r,this._y0=o,this._z0=i,this._x1=a,this._y1=s,this._z1=c,this},xn.data=function(){var e=[];return this.visit(function(t){if(!t.length)do{e.push(t.data)}while(t=t.next)}),e},xn.extent=function(e){return arguments.length?this.cover(+e[0][0],+e[0][1],+e[0][2]).cover(+e[1][0],+e[1][1],+e[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]},xn.find=function(e,t,n,r){var o,i,a,s,c,l,u,d,h,f=this._x0,p=this._y0,g=this._z0,m=this._x1,y=this._y1,v=this._z1,b=[],w=this._root;for(w&&b.push(new fn(w,f,p,g,m,y,v)),null==r?r=1/0:(f=e-r,p=t-r,g=n-r,m=e+r,y=t+r,v=n+r,r*=r);d=b.pop();)if(!(!(w=d.node)||(i=d.x0)>m||(a=d.y0)>y||(s=d.z0)>v||(c=d.x1)<f||(l=d.y1)<p||(u=d.z1)<g))if(w.length){var x=(i+c)/2,k=(a+l)/2,E=(s+u)/2;b.push(new fn(w[7],x,k,E,c,l,u),new fn(w[6],i,k,E,x,l,u),new fn(w[5],x,a,E,c,k,u),new fn(w[4],i,a,E,x,k,u),new fn(w[3],x,k,s,c,l,E),new fn(w[2],i,k,s,x,l,E),new fn(w[1],x,a,s,c,k,E),new fn(w[0],i,a,s,x,k,E)),(h=(n>=E)<<2|(t>=k)<<1|e>=x)&&(d=b[b.length-1],b[b.length-1]=b[b.length-1-h],b[b.length-1-h]=d)}else{var _=e-+this._x.call(null,w.data),A=t-+this._y.call(null,w.data),M=n-+this._z.call(null,w.data),T=_*_+A*A+M*M;if(T<r){var C=Math.sqrt(r=T);f=e-C,p=t-C,g=n-C,m=e+C,y=t+C,v=n+C,o=w.data}}return o},xn.findAllWithinRadius=function(e,t,n,r){const o=[],i=e-r,a=t-r,s=n-r,c=e+r,l=t+r,u=n+r;return this.visit((d,h,f,p,g,m,y)=>{if(!d.length)do{const i=d.data;pn(e,t,n,this._x(i),this._y(i),this._z(i))<=r&&o.push(i)}while(d=d.next);return h>c||f>l||p>u||g<i||m<a||y<s}),o},xn.remove=function(e){if(isNaN(i=+this._x.call(null,e))||isNaN(a=+this._y.call(null,e))||isNaN(s=+this._z.call(null,e)))return this;var t,n,r,o,i,a,s,c,l,u,d,h,f,p,g,m=this._root,y=this._x0,v=this._y0,b=this._z0,w=this._x1,x=this._y1,k=this._z1;if(!m)return this;if(m.length)for(;;){if((d=i>=(c=(y+w)/2))?y=c:w=c,(h=a>=(l=(v+x)/2))?v=l:x=l,(f=s>=(u=(b+k)/2))?b=u:k=u,t=m,!(m=m[p=f<<2|h<<1|d]))return this;if(!m.length)break;(t[p+1&7]||t[p+2&7]||t[p+3&7]||t[p+4&7]||t[p+5&7]||t[p+6&7]||t[p+7&7])&&(n=t,g=p)}for(;m.data!==e;)if(r=m,!(m=m.next))return this;return(o=m.next)&&delete m.next,r?(o?r.next=o:delete r.next,this):t?(o?t[p]=o:delete t[p],(m=t[0]||t[1]||t[2]||t[3]||t[4]||t[5]||t[6]||t[7])&&m===(t[7]||t[6]||t[5]||t[4]||t[3]||t[2]||t[1]||t[0])&&!m.length&&(n?n[g]=m:this._root=m),this):(this._root=o,this)},xn.removeAll=function(e){for(var t=0,n=e.length;t<n;++t)this.remove(e[t]);return this},xn.root=function(){return this._root},xn.size=function(){var e=0;return this.visit(function(t){if(!t.length)do{++e}while(t=t.next)}),e},xn.visit=function(e){var t,n,r,o,i,a,s,c,l=[],u=this._root;for(u&&l.push(new fn(u,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));t=l.pop();)if(!e(u=t.node,r=t.x0,o=t.y0,i=t.z0,a=t.x1,s=t.y1,c=t.z1)&&u.length){var d=(r+a)/2,h=(o+s)/2,f=(i+c)/2;(n=u[7])&&l.push(new fn(n,d,h,f,a,s,c)),(n=u[6])&&l.push(new fn(n,r,h,f,d,s,c)),(n=u[5])&&l.push(new fn(n,d,o,f,a,h,c)),(n=u[4])&&l.push(new fn(n,r,o,f,d,h,c)),(n=u[3])&&l.push(new fn(n,d,h,i,a,s,f)),(n=u[2])&&l.push(new fn(n,r,h,i,d,s,f)),(n=u[1])&&l.push(new fn(n,d,o,i,a,h,f)),(n=u[0])&&l.push(new fn(n,r,o,i,d,h,f))}return this},xn.visitAfter=function(e){var t,n=[],r=[];for(this._root&&n.push(new fn(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));t=n.pop();){var o=t.node;if(o.length){var i,a=t.x0,s=t.y0,c=t.z0,l=t.x1,u=t.y1,d=t.z1,h=(a+l)/2,f=(s+u)/2,p=(c+d)/2;(i=o[0])&&n.push(new fn(i,a,s,c,h,f,p)),(i=o[1])&&n.push(new fn(i,h,s,c,l,f,p)),(i=o[2])&&n.push(new fn(i,a,f,c,h,u,p)),(i=o[3])&&n.push(new fn(i,h,f,c,l,u,p)),(i=o[4])&&n.push(new fn(i,a,s,p,h,f,d)),(i=o[5])&&n.push(new fn(i,h,s,p,l,f,d)),(i=o[6])&&n.push(new fn(i,a,f,p,h,u,d)),(i=o[7])&&n.push(new fn(i,h,f,p,l,u,d))}r.push(t)}for(;t=r.pop();)e(t.node,t.x0,t.y0,t.z0,t.x1,t.y1,t.z1);return this},xn.x=function(e){return arguments.length?(this._x=e,this):this._x},xn.y=function(e){return arguments.length?(this._y=e,this):this._y},xn.z=function(e){return arguments.length?(this._z=e,this):this._z};var Tn={value:()=>{}};function Cn(){for(var e,t=0,n=arguments.length,r={};t<n;++t){if(!(e=arguments[t]+"")||e in r||/[\s.]/.test(e))throw new Error("illegal type: "+e);r[e]=[]}return new Nn(r)}function Nn(e){this._=e}function On(e,t){for(var n,r=0,o=e.length;r<o;++r)if((n=e[r]).name===t)return n.value}function Dn(e,t,n){for(var r=0,o=e.length;r<o;++r)if(e[r].name===t){e[r]=Tn,e=e.slice(0,r).concat(e.slice(r+1));break}return null!=n&&e.push({name:t,value:n}),e}Nn.prototype=Cn.prototype={constructor:Nn,on:function(e,t){var n,r,o=this._,i=(r=o,(e+"").trim().split(/^|\s+/).map(function(e){var t="",n=e.indexOf(".");if(n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),e&&!r.hasOwnProperty(e))throw new Error("unknown type: "+e);return{type:e,name:t}})),a=-1,s=i.length;if(!(arguments.length<2)){if(null!=t&&"function"!=typeof t)throw new Error("invalid callback: "+t);for(;++a<s;)if(n=(e=i[a]).type)o[n]=Dn(o[n],e.name,t);else if(null==t)for(n in o)o[n]=Dn(o[n],e.name,null);return this}for(;++a<s;)if((n=(e=i[a]).type)&&(n=On(o[n],e.name)))return n},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Nn(e)},call:function(e,t){if((n=arguments.length-2)>0)for(var n,r,o=new Array(n),i=0;i<n;++i)o[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=0,n=(r=this._[e]).length;i<n;++i)r[i].value.apply(t,o)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],o=0,i=r.length;o<i;++o)r[o].value.apply(t,n)}};var Pn,Sn,Ln=0,In=0,jn=0,Rn=0,Fn=0,Bn=0,zn="object"==typeof performance&&performance.now?performance:Date,Vn="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Un(){return Fn||(Vn(Gn),Fn=zn.now()+Bn)}function Gn(){Fn=0}function Hn(){this._call=this._time=this._next=null}function Kn(e,t,n){var r=new Hn;return r.restart(e,t,n),r}function qn(){Fn=(Rn=zn.now())+Bn,Ln=In=0;try{!function(){Un(),++Ln;for(var e,t=Pn;t;)(e=Fn-t._time)>=0&&t._call.call(void 0,e),t=t._next;--Ln}()}finally{Ln=0,function(){var e,t,n=Pn,r=1/0;for(;n;)n._call?(r>n._time&&(r=n._time),e=n,n=n._next):(t=n._next,n._next=null,n=e?e._next=t:Pn=t);Sn=e,Wn(r)}(),Fn=0}}function $n(){var e=zn.now(),t=e-Rn;t>1e3&&(Bn-=t,Rn=e)}function Wn(e){Ln||(In&&(In=clearTimeout(In)),e-Fn>24?(e<1/0&&(In=setTimeout(qn,e-zn.now()-Bn)),jn&&(jn=clearInterval(jn))):(jn||(Rn=zn.now(),jn=setInterval($n,1e3)),Ln=1,Vn(qn)))}Hn.prototype=Kn.prototype={constructor:Hn,restart:function(e,t,n){if("function"!=typeof e)throw new TypeError("callback is not a function");n=(null==n?Un():+n)+(null==t?0:+t),this._next||Sn===this||(Sn?Sn._next=this:Pn=this,Sn=this),this._call=e,this._time=n,Wn()},stop:function(){this._call&&(this._call=null,this._time=1/0,Wn())}};const Xn=4294967296;function Jn(e){return e.x}function Zn(e){return e.y}function Yn(e){return e.z}var Qn,er,tr,nr,rr=Math.PI*(3-Math.sqrt(5)),or=20*Math.PI/(9+Math.sqrt(221));function ir(e,t){t=t||2;var n,r=Math.min(3,Math.max(1,Math.round(t))),o=1,i=.001,a=1-Math.pow(i,1/300),s=0,c=.6,l=new Map,u=Kn(f),d=Cn("tick","end"),h=function(){let e=1;return()=>(e=(1664525*e+1013904223)%Xn)/Xn}();function f(){p(),d.call("tick",n),o<i&&(u.stop(),d.call("end",n))}function p(t){var i,u,d=e.length;void 0===t&&(t=1);for(var h=0;h<t;++h)for(o+=(s-o)*a,l.forEach(function(e){e(o)}),i=0;i<d;++i)null==(u=e[i]).fx?u.x+=u.vx*=c:(u.x=u.fx,u.vx=0),r>1&&(null==u.fy?u.y+=u.vy*=c:(u.y=u.fy,u.vy=0)),r>2&&(null==u.fz?u.z+=u.vz*=c:(u.z=u.fz,u.vz=0));return n}function g(){for(var t,n=0,o=e.length;n<o;++n){if((t=e[n]).index=n,null!=t.fx&&(t.x=t.fx),null!=t.fy&&(t.y=t.fy),null!=t.fz&&(t.z=t.fz),isNaN(t.x)||r>1&&isNaN(t.y)||r>2&&isNaN(t.z)){var i=10*(r>2?Math.cbrt(.5+n):r>1?Math.sqrt(.5+n):n),a=n*rr,s=n*or;1===r?t.x=i:2===r?(t.x=i*Math.cos(a),t.y=i*Math.sin(a)):(t.x=i*Math.sin(a)*Math.cos(s),t.y=i*Math.cos(a),t.z=i*Math.sin(a)*Math.sin(s))}(isNaN(t.vx)||r>1&&isNaN(t.vy)||r>2&&isNaN(t.vz))&&(t.vx=0,r>1&&(t.vy=0),r>2&&(t.vz=0))}}function m(t){return t.initialize&&t.initialize(e,h,r),t}return null==e&&(e=[]),g(),n={tick:p,restart:function(){return u.restart(f),n},stop:function(){return u.stop(),n},numDimensions:function(e){return arguments.length?(r=Math.min(3,Math.max(1,Math.round(e))),l.forEach(m),n):r},nodes:function(t){return arguments.length?(e=t,g(),l.forEach(m),n):e},alpha:function(e){return arguments.length?(o=+e,n):o},alphaMin:function(e){return arguments.length?(i=+e,n):i},alphaDecay:function(e){return arguments.length?(a=+e,n):+a},alphaTarget:function(e){return arguments.length?(s=+e,n):s},velocityDecay:function(e){return arguments.length?(c=1-e,n):1-c},randomSource:function(e){return arguments.length?(h=e,l.forEach(m),n):h},force:function(e,t){return arguments.length>1?(null==t?l.delete(e):l.set(e,m(t)),n):l.get(e)},find:function(){var t,n,o,i,a,s,c=Array.prototype.slice.call(arguments),l=c.shift()||0,u=(r>1?c.shift():null)||0,d=(r>2?c.shift():null)||0,h=c.shift()||1/0,f=0,p=e.length;for(h*=h,f=0;f<p;++f)(i=(t=l-(a=e[f]).x)*t+(n=u-(a.y||0))*n+(o=d-(a.z||0))*o)<h&&(s=a,h=i);return s},on:function(e,t){return arguments.length>1?(d.on(e,t),n):d.on(e)}}}function ar(){var e,t,n,r,o,i,a=kn(-30),s=1,c=1/0,l=.81;function u(r){var i,a=e.length,s=(1===t?Qt(e,Jn):2===t?cn(e,Jn,Zn):3===t?vn(e,Jn,Zn,Yn):null).visitAfter(h);for(o=r,i=0;i<a;++i)n=e[i],s.visit(f)}function d(){if(e){var t,n,r=e.length;for(i=new Array(r),t=0;t<r;++t)n=e[t],i[n.index]=+a(n,t,e)}}function h(e){var n,r,o,a,s,c,l=0,u=0,d=e.length;if(d){for(o=a=s=c=0;c<d;++c)(n=e[c])&&(r=Math.abs(n.value))&&(l+=n.value,u+=r,o+=r*(n.x||0),a+=r*(n.y||0),s+=r*(n.z||0));l*=Math.sqrt(4/d),e.x=o/u,t>1&&(e.y=a/u),t>2&&(e.z=s/u)}else{(n=e).x=n.data.x,t>1&&(n.y=n.data.y),t>2&&(n.z=n.data.z);do{l+=i[n.data.index]}while(n=n.next)}e.value=l}function f(e,a,u,d,h){if(!e.value)return!0;var f=[u,d,h][t-1],p=e.x-n.x,g=t>1?e.y-n.y:0,m=t>2?e.z-n.z:0,y=f-a,v=p*p+g*g+m*m;if(y*y/l<v)return v<c&&(0===p&&(v+=(p=En(r))*p),t>1&&0===g&&(v+=(g=En(r))*g),t>2&&0===m&&(v+=(m=En(r))*m),v<s&&(v=Math.sqrt(s*v)),n.vx+=p*e.value*o/v,t>1&&(n.vy+=g*e.value*o/v),t>2&&(n.vz+=m*e.value*o/v)),!0;if(!(e.length||v>=c)){(e.data!==n||e.next)&&(0===p&&(v+=(p=En(r))*p),t>1&&0===g&&(v+=(g=En(r))*g),t>2&&0===m&&(v+=(m=En(r))*m),v<s&&(v=Math.sqrt(s*v)));do{e.data!==n&&(y=i[e.data.index]*o/v,n.vx+=p*y,t>1&&(n.vy+=g*y),t>2&&(n.vz+=m*y))}while(e=e.next)}}return u.initialize=function(n,...o){e=n,r=o.find(e=>"function"==typeof e)||Math.random,t=o.find(e=>[1,2,3].includes(e))||2,d()},u.strength=function(e){return arguments.length?(a="function"==typeof e?e:kn(+e),d(),u):a},u.distanceMin=function(e){return arguments.length?(s=e*e,u):Math.sqrt(s)},u.distanceMax=function(e){return arguments.length?(c=e*e,u):Math.sqrt(c)},u.theta=function(e){return arguments.length?(l=e*e,u):Math.sqrt(l)},u}function sr(){if(er)return Qn;return er=1,Qn=function(e){!function(e){if(!e)throw new Error("Eventify cannot use falsy object as events subject");for(var t=["on","fire","off"],n=0;n<t.length;++n)if(e.hasOwnProperty(t[n]))throw new Error("Subject cannot be eventified, since it already has property '"+t[n]+"'")}(e);var t=function(e){var t=Object.create(null);return{on:function(n,r,o){if("function"!=typeof r)throw new Error("callback is expected to be a function");var i=t[n];return i||(i=t[n]=[]),i.push({callback:r,ctx:o}),e},off:function(n,r){if(void 0===n)return t=Object.create(null),e;if(t[n])if("function"!=typeof r)delete t[n];else for(var o=t[n],i=0;i<o.length;++i)o[i].callback===r&&o.splice(i,1);return e},fire:function(n){var r,o=t[n];if(!o)return e;arguments.length>1&&(r=Array.prototype.splice.call(arguments,1));for(var i=0;i<o.length;++i){var a=o[i];a.callback.apply(a.ctx,r)}return e}}}(e);return e.on=t.on,e.off=t.off,e.fire=t.fire,e},Qn}var cr,lr,ur,dr,hr,fr=function(){if(nr)return tr;nr=1,tr=function(i){"uniqueLinkId"in(i=i||{})&&(console.warn("ngraph.graph: Starting from version 0.14 `uniqueLinkId` is deprecated.\nUse `multigraph` option instead\n","\n","Note: there is also change in default behavior: From now on each graph\nis considered to be not a multigraph by default (each edge is unique)."),i.multigraph=i.uniqueLinkId);void 0===i.multigraph&&(i.multigraph=!1);if("function"!=typeof Map)throw new Error("ngraph.graph requires `Map` to be defined. Please polyfill it before using ngraph");var a=new Map,s=new Map,c={},l=0,u=i.multigraph?function(e,t,n){var i=o(e,t),a=c.hasOwnProperty(i);if(a||A(e,t)){a||(c[i]=0);var s="@"+ ++c[i];i=o(e+s,t+s)}return new r(e,t,n,i)}:function(e,t,n){var i=o(e,t),a=s.get(i);if(a)return a.data=n,a;return new r(e,t,n,i)},d=[],h=M,f=M,p=M,g=M,m={version:20,addNode:b,addLink:function(e,t,r){p();var o=w(e)||b(e),i=w(t)||b(t),a=u(e,t,r),c=s.has(a.id);s.set(a.id,a),n(o,a),e!==t&&n(i,a);return h(a,c?"update":"add"),g(),a},removeLink:function(e,t){void 0!==t&&(e=A(e,t));return _(e)},removeNode:x,getNode:w,getNodeCount:k,getLinkCount:E,getEdgeCount:E,getLinksCount:E,getNodesCount:k,getLinks:function(e){var t=w(e);return t?t.links:null},forEachNode:N,forEachLinkedNode:function(e,t,n){var r=w(e);if(r&&r.links&&"function"==typeof t)return n?function(e,t,n){var r=e.values(),o=r.next();for(;!o.done;){var i=o.value;if(i.fromId===t&&n(a.get(i.toId),i))return!0;o=r.next()}}(r.links,e,t):function(e,t,n){var r=e.values(),o=r.next();for(;!o.done;){var i=o.value,s=i.fromId===t?i.toId:i.fromId;if(n(a.get(s),i))return!0;o=r.next()}}(r.links,e,t)},forEachLink:function(e){if("function"==typeof e)for(var t=s.values(),n=t.next();!n.done;){if(e(n.value))return!0;n=t.next()}},beginUpdate:p,endUpdate:g,clear:function(){p(),N(function(e){x(e.id)}),g()},hasLink:A,hasNode:w,getLink:A};return e(m),function(){var e=m.on;function t(){return m.beginUpdate=p=T,m.endUpdate=g=C,h=y,f=v,m.on=e,e.apply(m,arguments)}m.on=t}(),m;function y(e,t){d.push({link:e,changeType:t})}function v(e,t){d.push({node:e,changeType:t})}function b(e,n){if(void 0===e)throw new Error("Invalid node identifier");p();var r=w(e);return r?(r.data=n,f(r,"update")):(r=new t(e,n),f(r,"add")),a.set(e,r),g(),r}function w(e){return a.get(e)}function x(e){var t=w(e);if(!t)return!1;p();var n=t.links;return n&&(n.forEach(_),t.links=null),a.delete(e),f(t,"remove"),g(),!0}function k(){return a.size}function E(){return s.size}function _(e){if(!e)return!1;if(!s.get(e.id))return!1;p(),s.delete(e.id);var t=w(e.fromId),n=w(e.toId);return t&&t.links.delete(e),n&&n.links.delete(e),h(e,"remove"),g(),!0}function A(e,t){if(void 0!==e&&void 0!==t)return s.get(o(e,t))}function M(){}function T(){l+=1}function C(){0===(l-=1)&&d.length>0&&(m.fire("changed",d),d.length=0)}function N(e){if("function"!=typeof e)throw new Error("Function is expected to iterate over graph nodes. You passed "+e);for(var t=a.values(),n=t.next();!n.done;){if(e(n.value))return!0;n=t.next()}}};var e=sr();function t(e,t){this.id=e,this.links=null,this.data=t}function n(e,t){e.links?e.links.add(t):e.links=new Set([t])}function r(e,t,n,r){this.fromId=e,this.toId=t,this.data=n,this.id=r}function o(e,t){return e.toString()+"👉 "+t.toString()}return tr}(),pr=c(fr),gr={exports:{}},mr={exports:{}};function yr(){return lr||(lr=1,cr=function(e){return 0===e?"x":1===e?"y":2===e?"z":"c"+(e+1)}),cr}function vr(){if(dr)return ur;dr=1;const e=yr();return ur=function(t){return function(n,r){let o=r&&r.indent||0,i=r&&void 0!==r.join?r.join:"\n",a=Array(o+1).join(" "),s=[];for(let r=0;r<t;++r){let t=e(r),o=0===r?"":a;s.push(o+n.replace(/{var}/g,t))}return s.join(i)}},ur}var br,wr={exports:{}};var xr,kr={exports:{}};var Er,_r={exports:{}};var Ar,Mr={exports:{}};var Tr,Cr,Nr,Or,Dr,Pr={exports:{}};var Sr,Lr,Ir,jr,Rr={exports:{}};function Fr(){if(Ir)return Lr;Ir=1,Lr=function(c){var l=Nr?Cr:(Nr=1,Cr=function(e,t,n,r){this.from=e,this.to=t,this.length=n,this.coefficient=r}),u=(Dr||(Dr=1,Or=function e(t,n){var r;if(t||(t={}),n)for(r in n)if(n.hasOwnProperty(r)){var o=t.hasOwnProperty(r),i=typeof n[r];o&&typeof t[r]===i?"object"===i&&(t[r]=e(t[r],n[r])):t[r]=n[r]}return t}),Or),d=sr();if(c){if(void 0!==c.springCoeff)throw new Error("springCoeff was renamed to springCoefficient");if(void 0!==c.dragCoeff)throw new Error("dragCoeff was renamed to dragCoefficient")}c=u(c,{springLength:10,springCoefficient:.8,gravity:-12,theta:.8,dragCoefficient:.9,timeStep:.5,adaptiveTimeStepWeight:0,dimensions:2,debug:!1});var h=a[c.dimensions];if(!h){var f=c.dimensions;h={Body:e(f,c.debug),createQuadTree:t(f),createBounds:n(f),createDragForce:r(f),createSpringForce:o(f),integrate:i(f)},a[f]=h}var p=h.Body,g=h.createQuadTree,m=h.createBounds,y=h.createDragForce,v=h.createSpringForce,b=h.integrate,w=function(){if(Sr)return Rr.exports;function e(e){return new t("number"==typeof e?e:+new Date)}function t(e){this.seed=e}function n(e){return Math.sqrt(2*Math.PI/e)*Math.pow(1/Math.E*(e+1/(12*e-1/(10*e))),e)}function r(){var e=this.seed;return e=4294967295&(3042594569^(e=4251993797+(e=4294967295&(3550635116+(e=374761393+(e=4294967295&(3345072700^(e=e+2127912214+(e<<12)&4294967295)^e>>>19))+(e<<5)&4294967295)^e<<9))+(e<<3)&4294967295)^e>>>16),this.seed=e,(268435455&e)/268435456}return Sr=1,Rr.exports=e,Rr.exports.random=e,Rr.exports.randomIterator=function(t,n){var r=n||e();if("function"!=typeof r.next)throw new Error("customRandom does not match expected API: next() function is missing");return{forEach:function(e){var n,o,i;for(n=t.length-1;n>0;--n)o=r.next(n+1),i=t[o],t[o]=t[n],t[n]=i,e(i);t.length&&e(t[0])},shuffle:function(){var e,n,o;for(e=t.length-1;e>0;--e)n=r.next(e+1),o=t[n],t[n]=t[e],t[e]=o;return t}}},t.prototype.next=function(e){return Math.floor(this.nextDouble()*e)},t.prototype.nextDouble=r,t.prototype.uniform=r,t.prototype.gaussian=function(){var e,t,n;do{e=(t=2*this.nextDouble()-1)*t+(n=2*this.nextDouble()-1)*n}while(e>=1||0===e);return t*Math.sqrt(-2*Math.log(e)/e)},t.prototype.random=r,t.prototype.levy=function(){var e=1.5,t=Math.pow(n(2.5)*Math.sin(Math.PI*e/2)/(n(1.25)*e*Math.pow(2,.25)),1/e);return this.gaussian()*t/Math.pow(Math.abs(this.gaussian()),1/e)},Rr.exports}().random(42),x=[],k=[],E=g(c,w),_=m(x,c,w),A=v(c,w),M=y(c),T=[],C=new Map,N=0;P("nbody",function(){if(0===x.length)return;E.insertBodies(x);var e=x.length;for(;e--;){var t=x[e];t.isPinned||(t.reset(),E.updateBodyForce(t),M.update(t))}}),P("spring",function(){var e=k.length;for(;e--;)A.update(k[e])});var O={bodies:x,quadTree:E,springs:k,settings:c,addForce:P,removeForce:function(e){var t=T.indexOf(C.get(e));if(t<0)return;T.splice(t,1),C.delete(e)},getForces:function(){return C},step:function(){for(var e=0;e<T.length;++e)T[e](N);var t=b(x,c.timeStep,c.adaptiveTimeStepWeight);return N+=1,t},addBody:function(e){if(!e)throw new Error("Body is required");return x.push(e),e},addBodyAt:function(e){if(!e)throw new Error("Body position is required");var t=(e=>new p(e))(e);return x.push(t),t},removeBody:function(e){if(e){var t=x.indexOf(e);if(!(t<0))return x.splice(t,1),0===x.length&&_.reset(),!0}},addSpring:function(e,t,n,r){if(!e||!t)throw new Error("Cannot add null spring to force simulator");"number"!=typeof n&&(n=-1);var o=new l(e,t,n,r>=0?r:-1);return k.push(o),o},getTotalMovement:function(){return 0},removeSpring:function(e){if(e){var t=k.indexOf(e);return t>-1?(k.splice(t,1),!0):void 0}},getBestNewBodyPosition:function(e){return _.getBestNewPosition(e)},getBBox:D,getBoundingBox:D,invalidateBBox:function(){console.warn("invalidateBBox() is deprecated, bounds always recomputed on `getBBox()` call")},gravity:function(e){return void 0!==e?(c.gravity=e,E.options({gravity:e}),this):c.gravity},theta:function(e){return void 0!==e?(c.theta=e,E.options({theta:e}),this):c.theta},random:w};return function(e,t){for(var n in e)s(e,t,n)}(c,O),d(O),O;function D(){return _.update(),_.box}function P(e,t){if(C.has(e))throw new Error("Force "+e+" is already added");C.set(e,t),T.push(t)}};var e=function(){if(hr)return mr.exports;hr=1;const e=vr();function t(e,t){return`\n${r(e,t)}\n${n(e)}\nreturn {Body: Body, Vector: Vector};\n`}function n(t){let n=e(t),r=n("{var}",{join:", "});return`\nfunction Body(${r}) {\n  this.isPinned = false;\n  this.pos = new Vector(${r});\n  this.force = new Vector();\n  this.velocity = new Vector();\n  this.mass = 1;\n\n  this.springCount = 0;\n  this.springLength = 0;\n}\n\nBody.prototype.reset = function() {\n  this.force.reset();\n  this.springCount = 0;\n  this.springLength = 0;\n}\n\nBody.prototype.setPosition = function (${r}) {\n  ${n("this.pos.{var} = {var} || 0;",{indent:2})}\n};`}function r(t,n){let r=e(t),o="";return n&&(o=`${r("\n\t   var v{var};\n\tObject.defineProperty(this, '{var}', {\n\t  set: function(v) { \n\t    if (!Number.isFinite(v)) throw new Error('Cannot set non-numbers to {var}');\n\t    v{var} = v; \n\t  },\n\t  get: function() { return v{var}; }\n\t});")}`),`function Vector(${r("{var}",{join:", "})}) {\n  ${o}\n    if (typeof arguments[0] === 'object') {\n      // could be another vector\n      let v = arguments[0];\n      ${r('if (!Number.isFinite(v.{var})) throw new Error("Expected value is not a finite number at Vector constructor ({var})");',{indent:4})}\n      ${r("this.{var} = v.{var};",{indent:4})}\n    } else {\n      ${r('this.{var} = typeof {var} === "number" ? {var} : 0;',{indent:4})}\n    }\n  }\n  \n  Vector.prototype.reset = function () {\n    ${r("this.{var} = ",{join:""})}0;\n  };`}return mr.exports=function(e,n){let r=t(e,n),{Body:o}=new Function(r)();return o},mr.exports.generateCreateBodyFunctionBody=t,mr.exports.getVectorCode=r,mr.exports.getBodyCode=n,mr.exports}(),t=function(){if(br)return wr.exports;br=1;const e=vr(),t=yr();function n(n){let c=e(n),l=Math.pow(2,n),u=`\n${s()}\n${a(n)}\n${r(n)}\n${i(n)}\n${o(n)}\n\nfunction createQuadTree(options, random) {\n  options = options || {};\n  options.gravity = typeof options.gravity === 'number' ? options.gravity : -1;\n  options.theta = typeof options.theta === 'number' ? options.theta : 0.8;\n\n  var gravity = options.gravity;\n  var updateQueue = [];\n  var insertStack = new InsertStack();\n  var theta = options.theta;\n\n  var nodesCache = [];\n  var currentInCache = 0;\n  var root = newNode();\n\n  return {\n    insertBodies: insertBodies,\n\n    /**\n     * Gets root node if it is present\n     */\n    getRoot: function() {\n      return root;\n    },\n\n    updateBodyForce: update,\n\n    options: function(newOptions) {\n      if (newOptions) {\n        if (typeof newOptions.gravity === 'number') {\n          gravity = newOptions.gravity;\n        }\n        if (typeof newOptions.theta === 'number') {\n          theta = newOptions.theta;\n        }\n\n        return this;\n      }\n\n      return {\n        gravity: gravity,\n        theta: theta\n      };\n    }\n  };\n\n  function newNode() {\n    // To avoid pressure on GC we reuse nodes.\n    var node = nodesCache[currentInCache];\n    if (node) {\n${function(e){let t=[];for(let n=0;n<l;++n)t.push(`${e}quad${n} = null;`);return t.join("\n")}("      node.")}\n      node.body = null;\n      node.mass = ${c("node.mass_{var} = ",{join:""})}0;\n      ${c("node.min_{var} = node.max_{var} = ",{join:""})}0;\n    } else {\n      node = new QuadNode();\n      nodesCache[currentInCache] = node;\n    }\n\n    ++currentInCache;\n    return node;\n  }\n\n  function update(sourceBody) {\n    var queue = updateQueue;\n    var v;\n    ${c("var d{var};",{indent:4})}\n    var r; \n    ${c("var f{var} = 0;",{indent:4})}\n    var queueLength = 1;\n    var shiftIdx = 0;\n    var pushIdx = 1;\n\n    queue[0] = root;\n\n    while (queueLength) {\n      var node = queue[shiftIdx];\n      var body = node.body;\n\n      queueLength -= 1;\n      shiftIdx += 1;\n      var differentBody = (body !== sourceBody);\n      if (body && differentBody) {\n        // If the current node is a leaf node (and it is not source body),\n        // calculate the force exerted by the current node on body, and add this\n        // amount to body's net force.\n        ${c("d{var} = body.pos.{var} - sourceBody.pos.{var};",{indent:8})}\n        r = Math.sqrt(${c("d{var} * d{var}",{join:" + "})});\n\n        if (r === 0) {\n          // Poor man's protection against zero distance.\n          ${c("d{var} = (random.nextDouble() - 0.5) / 50;",{indent:10})}\n          r = Math.sqrt(${c("d{var} * d{var}",{join:" + "})});\n        }\n\n        // This is standard gravitation force calculation but we divide\n        // by r^3 to save two operations when normalizing force vector.\n        v = gravity * body.mass * sourceBody.mass / (r * r * r);\n        ${c("f{var} += v * d{var};",{indent:8})}\n      } else if (differentBody) {\n        // Otherwise, calculate the ratio s / r,  where s is the width of the region\n        // represented by the internal node, and r is the distance between the body\n        // and the node's center-of-mass\n        ${c("d{var} = node.mass_{var} / node.mass - sourceBody.pos.{var};",{indent:8})}\n        r = Math.sqrt(${c("d{var} * d{var}",{join:" + "})});\n\n        if (r === 0) {\n          // Sorry about code duplication. I don't want to create many functions\n          // right away. Just want to see performance first.\n          ${c("d{var} = (random.nextDouble() - 0.5) / 50;",{indent:10})}\n          r = Math.sqrt(${c("d{var} * d{var}",{join:" + "})});\n        }\n        // If s / r < θ, treat this internal node as a single body, and calculate the\n        // force it exerts on sourceBody, and add this amount to sourceBody's net force.\n        if ((node.max_${t(0)} - node.min_${t(0)}) / r < theta) {\n          // in the if statement above we consider node's width only\n          // because the region was made into square during tree creation.\n          // Thus there is no difference between using width or height.\n          v = gravity * node.mass * sourceBody.mass / (r * r * r);\n          ${c("f{var} += v * d{var};",{indent:10})}\n        } else {\n          // Otherwise, run the procedure recursively on each of the current node's children.\n\n          // I intentionally unfolded this loop, to save several CPU cycles.\n${function(){let e=Array(11).join(" "),t=[];for(let n=0;n<l;++n)t.push(e+`if (node.quad${n}) {`),t.push(e+`  queue[pushIdx] = node.quad${n};`),t.push(e+"  queueLength += 1;"),t.push(e+"  pushIdx += 1;"),t.push(e+"}");return t.join("\n")}()}\n        }\n      }\n    }\n\n    ${c("sourceBody.force.{var} += f{var};",{indent:4})}\n  }\n\n  function insertBodies(bodies) {\n    ${c("var {var}min = Number.MAX_VALUE;",{indent:4})}\n    ${c("var {var}max = Number.MIN_VALUE;",{indent:4})}\n    var i = bodies.length;\n\n    // To reduce quad tree depth we are looking for exact bounding box of all particles.\n    while (i--) {\n      var pos = bodies[i].pos;\n      ${c("if (pos.{var} < {var}min) {var}min = pos.{var};",{indent:6})}\n      ${c("if (pos.{var} > {var}max) {var}max = pos.{var};",{indent:6})}\n    }\n\n    // Makes the bounds square.\n    var maxSideLength = -Infinity;\n    ${c("if ({var}max - {var}min > maxSideLength) maxSideLength = {var}max - {var}min ;",{indent:4})}\n\n    currentInCache = 0;\n    root = newNode();\n    ${c("root.min_{var} = {var}min;",{indent:4})}\n    ${c("root.max_{var} = {var}min + maxSideLength;",{indent:4})}\n\n    i = bodies.length - 1;\n    if (i >= 0) {\n      root.body = bodies[i];\n    }\n    while (i--) {\n      insert(bodies[i], root);\n    }\n  }\n\n  function insert(newBody) {\n    insertStack.reset();\n    insertStack.push(root, newBody);\n\n    while (!insertStack.isEmpty()) {\n      var stackItem = insertStack.pop();\n      var node = stackItem.node;\n      var body = stackItem.body;\n\n      if (!node.body) {\n        // This is internal node. Update the total mass of the node and center-of-mass.\n        ${c("var {var} = body.pos.{var};",{indent:8})}\n        node.mass += body.mass;\n        ${c("node.mass_{var} += body.mass * {var};",{indent:8})}\n\n        // Recursively insert the body in the appropriate quadrant.\n        // But first find the appropriate quadrant.\n        var quadIdx = 0; // Assume we are in the 0's quad.\n        ${c("var min_{var} = node.min_{var};",{indent:8})}\n        ${c("var max_{var} = (min_{var} + node.max_{var}) / 2;",{indent:8})}\n\n${function(){let e=[],r=Array(8+1).join(" ");for(let o=0;o<n;++o)e.push(r+`if (${t(o)} > max_${t(o)}) {`),e.push(r+`  quadIdx = quadIdx + ${Math.pow(2,o)};`),e.push(r+`  min_${t(o)} = max_${t(o)};`),e.push(r+`  max_${t(o)} = node.max_${t(o)};`),e.push(r+"}");return e.join("\n")}()}\n\n        var child = getChild(node, quadIdx);\n\n        if (!child) {\n          // The node is internal but this quadrant is not taken. Add\n          // subnode to it.\n          child = newNode();\n          ${c("child.min_{var} = min_{var};",{indent:10})}\n          ${c("child.max_{var} = max_{var};",{indent:10})}\n          child.body = body;\n\n          setChild(node, quadIdx, child);\n        } else {\n          // continue searching in this quadrant.\n          insertStack.push(child, body);\n        }\n      } else {\n        // We are trying to add to the leaf node.\n        // We have to convert current leaf into internal node\n        // and continue adding two nodes.\n        var oldBody = node.body;\n        node.body = null; // internal nodes do not cary bodies\n\n        if (isSamePosition(oldBody.pos, body.pos)) {\n          // Prevent infinite subdivision by bumping one node\n          // anywhere in this quadrant\n          var retriesCount = 3;\n          do {\n            var offset = random.nextDouble();\n            ${c("var d{var} = (node.max_{var} - node.min_{var}) * offset;",{indent:12})}\n\n            ${c("oldBody.pos.{var} = node.min_{var} + d{var};",{indent:12})}\n            retriesCount -= 1;\n            // Make sure we don't bump it out of the box. If we do, next iteration should fix it\n          } while (retriesCount > 0 && isSamePosition(oldBody.pos, body.pos));\n\n          if (retriesCount === 0 && isSamePosition(oldBody.pos, body.pos)) {\n            // This is very bad, we ran out of precision.\n            // if we do not return from the method we'll get into\n            // infinite loop here. So we sacrifice correctness of layout, and keep the app running\n            // Next layout iteration should get larger bounding box in the first step and fix this\n            return;\n          }\n        }\n        // Next iteration should subdivide node further.\n        insertStack.push(node, oldBody);\n        insertStack.push(node, body);\n      }\n    }\n  }\n}\nreturn createQuadTree;\n\n`;return u}function r(t){let n=e(t);return`\n  function isSamePosition(point1, point2) {\n    ${n("var d{var} = Math.abs(point1.{var} - point2.{var});",{indent:2})}\n  \n    return ${n("d{var} < 1e-8",{join:" && "})};\n  }  \n`}function o(e){var t=Math.pow(2,e);return`\nfunction setChild(node, idx, child) {\n  ${function(){let e=[];for(let n=0;n<t;++n){let t=0===n?"  ":"  else ";e.push(`${t}if (idx === ${n}) node.quad${n} = child;`)}return e.join("\n")}()}\n}`}function i(e){return`function getChild(node, idx) {\n${function(){let t=[],n=Math.pow(2,e);for(let e=0;e<n;++e)t.push(`  if (idx === ${e}) return node.quad${e};`);return t.join("\n")}()}\n  return null;\n}`}function a(t){let n=e(t),r=Math.pow(2,t);var o=`\nfunction QuadNode() {\n  // body stored inside this node. In quad tree only leaf nodes (by construction)\n  // contain bodies:\n  this.body = null;\n\n  // Child nodes are stored in quads. Each quad is presented by number:\n  // 0 | 1\n  // -----\n  // 2 | 3\n${function(e){let t=[];for(let n=0;n<r;++n)t.push(`${e}quad${n} = null;`);return t.join("\n")}("  this.")}\n\n  // Total mass of current node\n  this.mass = 0;\n\n  // Center of mass coordinates\n  ${n("this.mass_{var} = 0;",{indent:2})}\n\n  // bounding box coordinates\n  ${n("this.min_{var} = 0;",{indent:2})}\n  ${n("this.max_{var} = 0;",{indent:2})}\n}\n`;return o}function s(){return"\n/**\n * Our implementation of QuadTree is non-recursive to avoid GC hit\n * This data structure represent stack of elements\n * which we are trying to insert into quad tree.\n */\nfunction InsertStack () {\n    this.stack = [];\n    this.popIdx = 0;\n}\n\nInsertStack.prototype = {\n    isEmpty: function() {\n        return this.popIdx === 0;\n    },\n    push: function (node, body) {\n        var item = this.stack[this.popIdx];\n        if (!item) {\n            // we are trying to avoid memory pressure: create new element\n            // only when absolutely necessary\n            this.stack[this.popIdx] = new InsertStackElement(node, body);\n        } else {\n            item.node = node;\n            item.body = body;\n        }\n        ++this.popIdx;\n    },\n    pop: function () {\n        if (this.popIdx > 0) {\n            return this.stack[--this.popIdx];\n        }\n    },\n    reset: function () {\n        this.popIdx = 0;\n    }\n};\n\nfunction InsertStackElement(node, body) {\n    this.node = node; // QuadTree node\n    this.body = body; // physical body which needs to be inserted to node\n}\n"}return wr.exports=function(e){let t=n(e);return new Function(t)()},wr.exports.generateQuadTreeFunctionBody=n,wr.exports.getInsertStackCode=s,wr.exports.getQuadNodeCode=a,wr.exports.isSamePosition=r,wr.exports.getChildBodyCode=i,wr.exports.setChildBodyCode=o,wr.exports}(),n=function(){if(xr)return kr.exports;xr=1,kr.exports=function(e){let n=t(e);return new Function("bodies","settings","random",n)},kr.exports.generateFunctionBody=t;const e=vr();function t(t){let n=e(t);return`\n  var boundingBox = {\n    ${n("min_{var}: 0, max_{var}: 0,",{indent:4})}\n  };\n\n  return {\n    box: boundingBox,\n\n    update: updateBoundingBox,\n\n    reset: resetBoundingBox,\n\n    getBestNewPosition: function (neighbors) {\n      var ${n("base_{var} = 0",{join:", "})};\n\n      if (neighbors.length) {\n        for (var i = 0; i < neighbors.length; ++i) {\n          let neighborPos = neighbors[i].pos;\n          ${n("base_{var} += neighborPos.{var};",{indent:10})}\n        }\n\n        ${n("base_{var} /= neighbors.length;",{indent:8})}\n      } else {\n        ${n("base_{var} = (boundingBox.min_{var} + boundingBox.max_{var}) / 2;",{indent:8})}\n      }\n\n      var springLength = settings.springLength;\n      return {\n        ${n("{var}: base_{var} + (random.nextDouble() - 0.5) * springLength,",{indent:8})}\n      };\n    }\n  };\n\n  function updateBoundingBox() {\n    var i = bodies.length;\n    if (i === 0) return; // No bodies - no borders.\n\n    ${n("var max_{var} = -Infinity;",{indent:4})}\n    ${n("var min_{var} = Infinity;",{indent:4})}\n\n    while(i--) {\n      // this is O(n), it could be done faster with quadtree, if we check the root node bounds\n      var bodyPos = bodies[i].pos;\n      ${n("if (bodyPos.{var} < min_{var}) min_{var} = bodyPos.{var};",{indent:6})}\n      ${n("if (bodyPos.{var} > max_{var}) max_{var} = bodyPos.{var};",{indent:6})}\n    }\n\n    ${n("boundingBox.min_{var} = min_{var};",{indent:4})}\n    ${n("boundingBox.max_{var} = max_{var};",{indent:4})}\n  }\n\n  function resetBoundingBox() {\n    ${n("boundingBox.min_{var} = boundingBox.max_{var} = 0;",{indent:4})}\n  }\n`}return kr.exports}(),r=function(){if(Er)return _r.exports;Er=1;const e=vr();function t(t){return`\n  if (!Number.isFinite(options.dragCoefficient)) throw new Error('dragCoefficient is not a finite number');\n\n  return {\n    update: function(body) {\n      ${e(t)("body.force.{var} -= options.dragCoefficient * body.velocity.{var};",{indent:6})}\n    }\n  };\n`}return _r.exports=function(e){let n=t(e);return new Function("options",n)},_r.exports.generateCreateDragForceFunctionBody=t,_r.exports}(),o=function(){if(Ar)return Mr.exports;Ar=1;const e=vr();function t(t){let n=e(t);return`\n  if (!Number.isFinite(options.springCoefficient)) throw new Error('Spring coefficient is not a number');\n  if (!Number.isFinite(options.springLength)) throw new Error('Spring length is not a number');\n\n  return {\n    /**\n     * Updates forces acting on a spring\n     */\n    update: function (spring) {\n      var body1 = spring.from;\n      var body2 = spring.to;\n      var length = spring.length < 0 ? options.springLength : spring.length;\n      ${n("var d{var} = body2.pos.{var} - body1.pos.{var};",{indent:6})}\n      var r = Math.sqrt(${n("d{var} * d{var}",{join:" + "})});\n\n      if (r === 0) {\n        ${n("d{var} = (random.nextDouble() - 0.5) / 50;",{indent:8})}\n        r = Math.sqrt(${n("d{var} * d{var}",{join:" + "})});\n      }\n\n      var d = r - length;\n      var coefficient = ((spring.coefficient > 0) ? spring.coefficient : options.springCoefficient) * d / r;\n\n      ${n("body1.force.{var} += coefficient * d{var}",{indent:6})};\n      body1.springCount += 1;\n      body1.springLength += r;\n\n      ${n("body2.force.{var} -= coefficient * d{var}",{indent:6})};\n      body2.springCount += 1;\n      body2.springLength += r;\n    }\n  };\n`}return Mr.exports=function(e){let n=t(e);return new Function("options","random",n)},Mr.exports.generateCreateSpringForceFunctionBody=t,Mr.exports}(),i=function(){if(Tr)return Pr.exports;Tr=1;const e=vr();function t(t){let n=e(t);return`\n  var length = bodies.length;\n  if (length === 0) return 0;\n\n  ${n("var d{var} = 0, t{var} = 0;",{indent:2})}\n\n  for (var i = 0; i < length; ++i) {\n    var body = bodies[i];\n    if (body.isPinned) continue;\n\n    if (adaptiveTimeStepWeight && body.springCount) {\n      timeStep = (adaptiveTimeStepWeight * body.springLength/body.springCount);\n    }\n\n    var coeff = timeStep / body.mass;\n\n    ${n("body.velocity.{var} += coeff * body.force.{var};",{indent:4})}\n    ${n("var v{var} = body.velocity.{var};",{indent:4})}\n    var v = Math.sqrt(${n("v{var} * v{var}",{join:" + "})});\n\n    if (v > 1) {\n      // We normalize it so that we move within timeStep range. \n      // for the case when v <= 1 - we let velocity to fade out.\n      ${n("body.velocity.{var} = v{var} / v;",{indent:6})}\n    }\n\n    ${n("d{var} = timeStep * body.velocity.{var};",{indent:4})}\n\n    ${n("body.pos.{var} += d{var};",{indent:4})}\n\n    ${n("t{var} += Math.abs(d{var});",{indent:4})}\n  }\n\n  return (${n("t{var} * t{var}",{join:" + "})})/length;\n`}return Pr.exports=function(e){let n=t(e);return new Function("bodies","timeStep","adaptiveTimeStepWeight",n)},Pr.exports.generateIntegratorFunctionBody=t,Pr.exports}(),a={};function s(e,t,n){if(e.hasOwnProperty(n)&&"function"!=typeof t[n]){var r=Number.isFinite(e[n]);t[n]=r?function(r){if(void 0!==r){if(!Number.isFinite(r))throw new Error("Value of "+n+" should be a valid number.");return e[n]=r,t}return e[n]}:function(r){return void 0!==r?(e[n]=r,t):e[n]}}}return Lr}var Br=function(){if(jr)return gr.exports;jr=1,gr.exports=function(n,r){if(!n)throw new Error("Graph structure cannot be undefined");var o=(r&&r.createSimulator||Fr())(r);if(Array.isArray(r))throw new Error("Physics settings is expected to be an object");var i=n.version>19?function(e){var t=n.getLinks(e);return t?1+t.size/3:1}:function(e){var t=n.getLinks(e);return t?1+t.length/3:1};r&&"function"==typeof r.nodeMass&&(i=r.nodeMass);var a=new Map,s={},c=0,l=o.settings.springTransform||t;c=0,n.forEachNode(function(e){g(e.id),c+=1}),n.forEachLink(y),n.on("changed",p);var u=!1,d={step:function(){if(0===c)return h(!0),!0;var e=o.step();d.lastMove=e,d.fire("step");var t=e/c<=.01;return h(t),t},getNodePosition:function(e){return w(e).pos},setNodePosition:function(e){var t=w(e);t.setPosition.apply(t,Array.prototype.slice.call(arguments,1))},getLinkPosition:function(e){var t=s[e];if(t)return{from:t.from.pos,to:t.to.pos}},getGraphRect:function(){return o.getBBox()},forEachBody:f,pinNode:function(e,t){w(e.id).isPinned=!!t},isNodePinned:function(e){return w(e.id).isPinned},dispose:function(){n.off("changed",p),d.fire("disposed")},getBody:function(e){return a.get(e)},getSpring:function(e,t){var r;if(void 0===t)r="object"!=typeof e?e:e.id;else{var o=n.hasLink(e,t);if(!o)return;r=o.id}return s[r]},getForceVectorLength:function(){var e=0,t=0;return f(function(n){e+=Math.abs(n.force.x),t+=Math.abs(n.force.y)}),Math.sqrt(e*e+t*t)},simulator:o,graph:n,lastMove:0};return e(d),d;function h(e){var t;u!==e&&(u=e,t=e,d.fire("stable",t))}function f(e){a.forEach(e)}function p(e){for(var t=0;t<e.length;++t){var r=e[t];"add"===r.changeType?(r.node&&g(r.node.id),r.link&&y(r.link)):"remove"===r.changeType&&(r.node&&m(r.node),r.link&&v(r.link))}c=n.getNodesCount()}function g(e){var t=a.get(e);if(!t){var r=n.getNode(e);if(!r)throw new Error("initBody() was called with unknown node id");var i=r.position;if(!i){var s=function(e){var t=[];if(!e.links)return t;for(var n=Math.min(e.links.length,2),r=0;r<n;++r){var o=e.links[r],i=o.fromId!==e.id?a.get(o.fromId):a.get(o.toId);i&&i.pos&&t.push(i)}return t}(r);i=o.getBestNewBodyPosition(s)}(t=o.addBodyAt(i)).id=e,a.set(e,t),b(e),function(e){return e&&(e.isPinned||e.data&&e.data.isPinned)}(r)&&(t.isPinned=!0)}}function m(e){var t=e.id,n=a.get(t);n&&(a.delete(t),o.removeBody(n))}function y(e){b(e.fromId),b(e.toId);var t=a.get(e.fromId),n=a.get(e.toId),r=o.addSpring(t,n,e.length);l(e,r),s[e.id]=r}function v(e){var t=s[e.id];if(t){var r=n.getNode(e.fromId),i=n.getNode(e.toId);r&&b(r.id),i&&b(i.id),delete s[e.id],o.removeSpring(t)}}function b(e){var t=a.get(e);if(t.mass=i(e),Number.isNaN(t.mass))throw new Error("Node mass should be a number")}function w(e){var t=a.get(e);return t||(g(e),t=a.get(e)),t}},gr.exports.simulator=Fr();var e=sr();function t(){}return gr.exports}(),zr=c(Br);function Vr(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}var Ur="object"==typeof global&&global&&global.Object===Object&&global,Gr="object"==typeof self&&self&&self.Object===Object&&self,Hr=Ur||Gr||Function("return this")(),Kr=function(){return Hr.Date.now()},qr=/\s/;var $r=/^\s+/;function Wr(e){return e?e.slice(0,function(e){for(var t=e.length;t--&&qr.test(e.charAt(t)););return t}(e)+1).replace($r,""):e}var Xr=Hr.Symbol,Jr=Object.prototype,Zr=Jr.hasOwnProperty,Yr=Jr.toString,Qr=Xr?Xr.toStringTag:void 0;var eo=Object.prototype.toString;var to=Xr?Xr.toStringTag:void 0;function no(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":to&&to in Object(e)?function(e){var t=Zr.call(e,Qr),n=e[Qr];try{e[Qr]=void 0;var r=!0}catch(e){}var o=Yr.call(e);return r&&(t?e[Qr]=n:delete e[Qr]),o}(e):function(e){return eo.call(e)}(e)}var ro=/^[-+]0x[0-9a-f]+$/i,oo=/^0b[01]+$/i,io=/^0o[0-7]+$/i,ao=parseInt;function so(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return null!=e&&"object"==typeof e}(e)&&"[object Symbol]"==no(e)}(e))return NaN;if(Vr(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Vr(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=Wr(e);var n=oo.test(e);return n||io.test(e)?ao(e.slice(2),n?2:8):ro.test(e)?NaN:+e}var co=Math.max,lo=Math.min;function uo(e,t,n){var r,o,i,a,s,c,l=0,u=!1,d=!1,h=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function f(t){var n=r,i=o;return r=o=void 0,l=t,a=e.apply(i,n)}function p(e){var n=e-c;return void 0===c||n>=t||n<0||d&&e-l>=i}function g(){var e=Kr();if(p(e))return m(e);s=setTimeout(g,function(e){var n=t-(e-c);return d?lo(n,i-(e-l)):n}(e))}function m(e){return s=void 0,h&&r?f(e):(r=o=void 0,a)}function y(){var e=Kr(),n=p(e);if(r=arguments,o=this,c=e,n){if(void 0===s)return function(e){return l=e,s=setTimeout(g,t),u?f(e):a}(c);if(d)return clearTimeout(s),s=setTimeout(g,t),f(c)}return void 0===s&&(s=setTimeout(g,t)),a}return t=so(t)||0,Vr(n)&&(u=!!n.leading,i=(d="maxWait"in n)?co(so(n.maxWait)||0,t):i,h="trailing"in n?!!n.trailing:h),y.cancel=function(){void 0!==s&&clearTimeout(s),l=0,r=c=o=s=void 0},y.flush=function(){return void 0===s?a:m(Kr())},y}function ho(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function fo(e,t,n){return Object.defineProperty(e,"prototype",{writable:!1}),e}function po(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,a,s=[],c=!0,l=!1;try{if(i=(n=n.call(e)).next,0===t);else for(;!(c=(r=i.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,o=e}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(l)throw o}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return ho(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ho(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var go=fo(function e(t,n){var r=n.default,o=void 0===r?null:r,i=n.triggerUpdate,a=void 0===i||i,s=n.onChange,c=void 0===s?function(e,t){}:s;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.name=t,this.defaultVal=o,this.triggerUpdate=a,this.onChange=c});function mo(e){var t=e.stateInit,n=void 0===t?function(){return{}}:t,r=e.props,o=void 0===r?{}:r,i=e.methods,a=void 0===i?{}:i,s=e.aliases,c=void 0===s?{}:s,l=e.init,u=void 0===l?function(){}:l,d=e.update,h=void 0===d?function(){}:d,f=Object.keys(o).map(function(e){return new go(e,o[e])});return function e(){for(var t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];var i=!!(this instanceof e?this.constructor:void 0),s=i?r.shift():void 0,l=r[0],d=void 0===l?{}:l,p=Object.assign({},n instanceof Function?n(d):n,{initialised:!1}),g={};function m(e){return y(e,d),v(),m}var y=function(e,t){u.call(m,e,p,t),p.initialised=!0},v=uo(function(){p.initialised&&(h.call(m,p,g),g={})},1);return f.forEach(function(e){m[e.name]=function(e){var t=e.name,n=e.triggerUpdate,r=void 0!==n&&n,o=e.onChange,i=void 0===o?function(e,t){}:o,a=e.defaultVal,s=void 0===a?null:a;return function(e){var n=p[t];if(!arguments.length)return n;var o=void 0===e?s:e;return p[t]=o,i.call(m,o,p,n),!g.hasOwnProperty(t)&&(g[t]=n),r&&v(),m}}(e)}),Object.keys(a).forEach(function(e){m[e]=function(){for(var t,n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return(t=a[e]).call.apply(t,[m,p].concat(r))}}),Object.entries(c).forEach(function(e){var t=po(e,2),n=t[0],r=t[1];return m[n]=m[r]}),m.resetProps=function(){return f.forEach(function(e){m[e.name](e.defaultVal)}),m},m.resetProps(),p._rerender=v,i&&s&&m(s),m}}var yo=function(e){return"function"==typeof e?e:"string"==typeof e?function(t){return t[e]}:function(t){return e}};class vo extends Map{constructor(e,t=wo){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),null!=e)for(const[t,n]of e)this.set(t,n)}get(e){return super.get(bo(this,e))}has(e){return super.has(bo(this,e))}set(e,t){return super.set(function({_intern:e,_key:t},n){const r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}(this,e),t)}delete(e){return super.delete(function({_intern:e,_key:t},n){const r=t(n);e.has(r)&&(n=e.get(r),e.delete(r));return n}(this,e))}}function bo({_intern:e,_key:t},n){const r=t(n);return e.has(r)?e.get(r):n}function wo(e){return null!==e&&"object"==typeof e?e.valueOf():e}function xo(e,t){let n;if(void 0===t)for(const t of e)null!=t&&(n<t||void 0===n&&t>=t)&&(n=t);else{let r=-1;for(let o of e)null!=(o=t(o,++r,e))&&(n<o||void 0===n&&o>=o)&&(n=o)}return n}function ko(e,t){let n;if(void 0===t)for(const t of e)null!=t&&(n>t||void 0===n&&t>=t)&&(n=t);else{let r=-1;for(let o of e)null!=(o=t(o,++r,e))&&(n>o||void 0===n&&o>=o)&&(n=o)}return n}function Eo(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function _o(e,t,n){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:n;throw new TypeError("Private element is not present on this object")}function Ao(e,t){return e.get(_o(e,t))}function Mo(e,t,n){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,n)}function To(e,t,n){return e.set(_o(e,t),n),n}function Co(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,Do(r.key),r)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function No(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,a,s=[],c=!0,l=!1;try{if(i=(n=n.call(e)).next,0===t);else for(;!(c=(r=i.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,o=e}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(l)throw o}}return s}}(e,t)||Po(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Oo(e){return function(e){if(Array.isArray(e))return Eo(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Po(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Do(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function Po(e,t){if(e){if("string"==typeof e)return Eo(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Eo(e,t):void 0}}var So=new WeakMap,Lo=new WeakMap,Io=new WeakMap,jo=new WeakMap,Ro=new WeakMap,Fo=new WeakMap,Bo=function(){return Co(function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Mo(this,So,new Map),Mo(this,Lo,new Map),Mo(this,Io,function(e){return e}),Mo(this,jo,function(){return{}}),Mo(this,Ro,function(){}),Mo(this,Fo,function(){})},[{key:"getObj",value:function(e){return Ao(So,this).get(Ao(Io,this).call(this,e))}},{key:"getData",value:function(e){return Ao(Lo,this).get(e)}},{key:"entries",value:function(){return Oo(Ao(Lo,this).entries()).map(function(e){var t=No(e,2),n=t[0];return[t[1],n]})}},{key:"id",value:function(e){return To(Io,this,yo(e)),this}},{key:"onCreateObj",value:function(e){return To(jo,this,e),this}},{key:"onUpdateObj",value:function(e){return To(Ro,this,e),this}},{key:"onRemoveObj",value:function(e){return To(Fo,this,e),this}},{key:"digest",value:function(e){var t=this;e.filter(function(e){return!Ao(So,t).has(Ao(Io,t).call(t,e))}).forEach(function(e){var n=Ao(jo,t).call(t,e);Ao(So,t).set(Ao(Io,t).call(t,e),n),Ao(Lo,t).set(n,e)});var n=new Map(e.map(function(e){return[Ao(Io,t).call(t,e),e]}));return Ao(So,this).forEach(function(e,r){n.has(r)?Ao(Ro,t).call(t,e,n.get(r)):(Ao(Fo,t).call(t,e,r),Ao(So,t).delete(r),Ao(Lo,t).delete(e))}),this}},{key:"clear",value:function(){return this.digest([]),this}}])}();function zo(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e)}return this}const Vo=Symbol("implicit");var Uo=function(e){for(var t=e.length/6|0,n=new Array(t),r=0;r<t;)n[r]="#"+e.slice(6*r,6*++r);return n}("a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928");function Go(e){return Go="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Go(e)}var Ho=/^\s+/,Ko=/\s+$/;function qo(e,t){if(t=t||{},(e=e||"")instanceof qo)return e;if(!(this instanceof qo))return new qo(e,t);var n=function(e){var t={r:0,g:0,b:0},n=1,r=null,o=null,i=null,a=!1,s=!1;"string"==typeof e&&(e=function(e){e=e.replace(Ho,"").replace(Ko,"").toLowerCase();var t,n=!1;if(li[e])e=li[e],n=!0;else if("transparent"==e)return{r:0,g:0,b:0,a:0,format:"name"};if(t=ki.rgb.exec(e))return{r:t[1],g:t[2],b:t[3]};if(t=ki.rgba.exec(e))return{r:t[1],g:t[2],b:t[3],a:t[4]};if(t=ki.hsl.exec(e))return{h:t[1],s:t[2],l:t[3]};if(t=ki.hsla.exec(e))return{h:t[1],s:t[2],l:t[3],a:t[4]};if(t=ki.hsv.exec(e))return{h:t[1],s:t[2],v:t[3]};if(t=ki.hsva.exec(e))return{h:t[1],s:t[2],v:t[3],a:t[4]};if(t=ki.hex8.exec(e))return{r:pi(t[1]),g:pi(t[2]),b:pi(t[3]),a:vi(t[4]),format:n?"name":"hex8"};if(t=ki.hex6.exec(e))return{r:pi(t[1]),g:pi(t[2]),b:pi(t[3]),format:n?"name":"hex"};if(t=ki.hex4.exec(e))return{r:pi(t[1]+""+t[1]),g:pi(t[2]+""+t[2]),b:pi(t[3]+""+t[3]),a:vi(t[4]+""+t[4]),format:n?"name":"hex8"};if(t=ki.hex3.exec(e))return{r:pi(t[1]+""+t[1]),g:pi(t[2]+""+t[2]),b:pi(t[3]+""+t[3]),format:n?"name":"hex"};return!1}(e));"object"==Go(e)&&(Ei(e.r)&&Ei(e.g)&&Ei(e.b)?(t=function(e,t,n){return{r:255*hi(e,255),g:255*hi(t,255),b:255*hi(n,255)}}(e.r,e.g,e.b),a=!0,s="%"===String(e.r).substr(-1)?"prgb":"rgb"):Ei(e.h)&&Ei(e.s)&&Ei(e.v)?(r=mi(e.s),o=mi(e.v),t=function(e,t,n){e=6*hi(e,360),t=hi(t,100),n=hi(n,100);var r=Math.floor(e),o=e-r,i=n*(1-t),a=n*(1-o*t),s=n*(1-(1-o)*t),c=r%6,l=[n,a,i,i,s,n][c],u=[s,n,n,a,i,i][c],d=[i,i,s,n,n,a][c];return{r:255*l,g:255*u,b:255*d}}(e.h,r,o),a=!0,s="hsv"):Ei(e.h)&&Ei(e.s)&&Ei(e.l)&&(r=mi(e.s),i=mi(e.l),t=function(e,t,n){var r,o,i;function a(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e}if(e=hi(e,360),t=hi(t,100),n=hi(n,100),0===t)r=o=i=n;else{var s=n<.5?n*(1+t):n+t-n*t,c=2*n-s;r=a(c,s,e+1/3),o=a(c,s,e),i=a(c,s,e-1/3)}return{r:255*r,g:255*o,b:255*i}}(e.h,r,i),a=!0,s="hsl"),e.hasOwnProperty("a")&&(n=e.a));return n=di(n),{ok:a,format:e.format||s,r:Math.min(255,Math.max(t.r,0)),g:Math.min(255,Math.max(t.g,0)),b:Math.min(255,Math.max(t.b,0)),a:n}}(e);this._originalInput=e,this._r=n.r,this._g=n.g,this._b=n.b,this._a=n.a,this._roundA=Math.round(100*this._a)/100,this._format=t.format||n.format,this._gradientType=t.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=n.ok}function $o(e,t,n){e=hi(e,255),t=hi(t,255),n=hi(n,255);var r,o,i=Math.max(e,t,n),a=Math.min(e,t,n),s=(i+a)/2;if(i==a)r=o=0;else{var c=i-a;switch(o=s>.5?c/(2-i-a):c/(i+a),i){case e:r=(t-n)/c+(t<n?6:0);break;case t:r=(n-e)/c+2;break;case n:r=(e-t)/c+4}r/=6}return{h:r,s:o,l:s}}function Wo(e,t,n){e=hi(e,255),t=hi(t,255),n=hi(n,255);var r,o,i=Math.max(e,t,n),a=Math.min(e,t,n),s=i,c=i-a;if(o=0===i?0:c/i,i==a)r=0;else{switch(i){case e:r=(t-n)/c+(t<n?6:0);break;case t:r=(n-e)/c+2;break;case n:r=(e-t)/c+4}r/=6}return{h:r,s:o,v:s}}function Xo(e,t,n,r){var o=[gi(Math.round(e).toString(16)),gi(Math.round(t).toString(16)),gi(Math.round(n).toString(16))];return r&&o[0].charAt(0)==o[0].charAt(1)&&o[1].charAt(0)==o[1].charAt(1)&&o[2].charAt(0)==o[2].charAt(1)?o[0].charAt(0)+o[1].charAt(0)+o[2].charAt(0):o.join("")}function Jo(e,t,n,r){return[gi(yi(r)),gi(Math.round(e).toString(16)),gi(Math.round(t).toString(16)),gi(Math.round(n).toString(16))].join("")}function Zo(e,t){t=0===t?0:t||10;var n=qo(e).toHsl();return n.s-=t/100,n.s=fi(n.s),qo(n)}function Yo(e,t){t=0===t?0:t||10;var n=qo(e).toHsl();return n.s+=t/100,n.s=fi(n.s),qo(n)}function Qo(e){return qo(e).desaturate(100)}function ei(e,t){t=0===t?0:t||10;var n=qo(e).toHsl();return n.l+=t/100,n.l=fi(n.l),qo(n)}function ti(e,t){t=0===t?0:t||10;var n=qo(e).toRgb();return n.r=Math.max(0,Math.min(255,n.r-Math.round(-t/100*255))),n.g=Math.max(0,Math.min(255,n.g-Math.round(-t/100*255))),n.b=Math.max(0,Math.min(255,n.b-Math.round(-t/100*255))),qo(n)}function ni(e,t){t=0===t?0:t||10;var n=qo(e).toHsl();return n.l-=t/100,n.l=fi(n.l),qo(n)}function ri(e,t){var n=qo(e).toHsl(),r=(n.h+t)%360;return n.h=r<0?360+r:r,qo(n)}function oi(e){var t=qo(e).toHsl();return t.h=(t.h+180)%360,qo(t)}function ii(e,t){if(isNaN(t)||t<=0)throw new Error("Argument to polyad must be a positive number");for(var n=qo(e).toHsl(),r=[qo(e)],o=360/t,i=1;i<t;i++)r.push(qo({h:(n.h+i*o)%360,s:n.s,l:n.l}));return r}function ai(e){var t=qo(e).toHsl(),n=t.h;return[qo(e),qo({h:(n+72)%360,s:t.s,l:t.l}),qo({h:(n+216)%360,s:t.s,l:t.l})]}function si(e,t,n){t=t||6,n=n||30;var r=qo(e).toHsl(),o=360/n,i=[qo(e)];for(r.h=(r.h-(o*t>>1)+720)%360;--t;)r.h=(r.h+o)%360,i.push(qo(r));return i}function ci(e,t){t=t||6;for(var n=qo(e).toHsv(),r=n.h,o=n.s,i=n.v,a=[],s=1/t;t--;)a.push(qo({h:r,s:o,v:i})),i=(i+s)%1;return a}qo.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var e=this.toRgb();return(299*e.r+587*e.g+114*e.b)/1e3},getLuminance:function(){var e,t,n,r=this.toRgb();return e=r.r/255,t=r.g/255,n=r.b/255,.2126*(e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4))+.7152*(t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4))+.0722*(n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4))},setAlpha:function(e){return this._a=di(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=Wo(this._r,this._g,this._b);return{h:360*e.h,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=Wo(this._r,this._g,this._b),t=Math.round(360*e.h),n=Math.round(100*e.s),r=Math.round(100*e.v);return 1==this._a?"hsv("+t+", "+n+"%, "+r+"%)":"hsva("+t+", "+n+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var e=$o(this._r,this._g,this._b);return{h:360*e.h,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=$o(this._r,this._g,this._b),t=Math.round(360*e.h),n=Math.round(100*e.s),r=Math.round(100*e.l);return 1==this._a?"hsl("+t+", "+n+"%, "+r+"%)":"hsla("+t+", "+n+"%, "+r+"%, "+this._roundA+")"},toHex:function(e){return Xo(this._r,this._g,this._b,e)},toHexString:function(e){return"#"+this.toHex(e)},toHex8:function(e){return function(e,t,n,r,o){var i=[gi(Math.round(e).toString(16)),gi(Math.round(t).toString(16)),gi(Math.round(n).toString(16)),gi(yi(r))];if(o&&i[0].charAt(0)==i[0].charAt(1)&&i[1].charAt(0)==i[1].charAt(1)&&i[2].charAt(0)==i[2].charAt(1)&&i[3].charAt(0)==i[3].charAt(1))return i[0].charAt(0)+i[1].charAt(0)+i[2].charAt(0)+i[3].charAt(0);return i.join("")}(this._r,this._g,this._b,this._a,e)},toHex8String:function(e){return"#"+this.toHex8(e)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(100*hi(this._r,255))+"%",g:Math.round(100*hi(this._g,255))+"%",b:Math.round(100*hi(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+Math.round(100*hi(this._r,255))+"%, "+Math.round(100*hi(this._g,255))+"%, "+Math.round(100*hi(this._b,255))+"%)":"rgba("+Math.round(100*hi(this._r,255))+"%, "+Math.round(100*hi(this._g,255))+"%, "+Math.round(100*hi(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(ui[Xo(this._r,this._g,this._b,!0)]||!1)},toFilter:function(e){var t="#"+Jo(this._r,this._g,this._b,this._a),n=t,r=this._gradientType?"GradientType = 1, ":"";if(e){var o=qo(e);n="#"+Jo(o._r,o._g,o._b,o._a)}return"progid:DXImageTransform.Microsoft.gradient("+r+"startColorstr="+t+",endColorstr="+n+")"},toString:function(e){var t=!!e;e=e||this._format;var n=!1,r=this._a<1&&this._a>=0;return t||!r||"hex"!==e&&"hex6"!==e&&"hex3"!==e&&"hex4"!==e&&"hex8"!==e&&"name"!==e?("rgb"===e&&(n=this.toRgbString()),"prgb"===e&&(n=this.toPercentageRgbString()),"hex"!==e&&"hex6"!==e||(n=this.toHexString()),"hex3"===e&&(n=this.toHexString(!0)),"hex4"===e&&(n=this.toHex8String(!0)),"hex8"===e&&(n=this.toHex8String()),"name"===e&&(n=this.toName()),"hsl"===e&&(n=this.toHslString()),"hsv"===e&&(n=this.toHsvString()),n||this.toHexString()):"name"===e&&0===this._a?this.toName():this.toRgbString()},clone:function(){return qo(this.toString())},_applyModification:function(e,t){var n=e.apply(null,[this].concat([].slice.call(t)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(ei,arguments)},brighten:function(){return this._applyModification(ti,arguments)},darken:function(){return this._applyModification(ni,arguments)},desaturate:function(){return this._applyModification(Zo,arguments)},saturate:function(){return this._applyModification(Yo,arguments)},greyscale:function(){return this._applyModification(Qo,arguments)},spin:function(){return this._applyModification(ri,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(si,arguments)},complement:function(){return this._applyCombination(oi,arguments)},monochromatic:function(){return this._applyCombination(ci,arguments)},splitcomplement:function(){return this._applyCombination(ai,arguments)},triad:function(){return this._applyCombination(ii,[3])},tetrad:function(){return this._applyCombination(ii,[4])}},qo.fromRatio=function(e,t){if("object"==Go(e)){var n={};for(var r in e)e.hasOwnProperty(r)&&(n[r]="a"===r?e[r]:mi(e[r]));e=n}return qo(e,t)},qo.equals=function(e,t){return!(!e||!t)&&qo(e).toRgbString()==qo(t).toRgbString()},qo.random=function(){return qo.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})},qo.mix=function(e,t,n){n=0===n?0:n||50;var r=qo(e).toRgb(),o=qo(t).toRgb(),i=n/100;return qo({r:(o.r-r.r)*i+r.r,g:(o.g-r.g)*i+r.g,b:(o.b-r.b)*i+r.b,a:(o.a-r.a)*i+r.a})},
// <http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef (WCAG Version 2)
// Analyze the 2 colors and returns the color contrast defined by (WCAG Version 2)
qo.readability=function(e,t){var n=qo(e),r=qo(t);return(Math.max(n.getLuminance(),r.getLuminance())+.05)/(Math.min(n.getLuminance(),r.getLuminance())+.05)},qo.isReadable=function(e,t,n){var r,o,i=qo.readability(e,t);switch(o=!1,(r=function(e){var t,n;t=((e=e||{level:"AA",size:"small"}).level||"AA").toUpperCase(),n=(e.size||"small").toLowerCase(),"AA"!==t&&"AAA"!==t&&(t="AA");"small"!==n&&"large"!==n&&(n="small");return{level:t,size:n}}(n)).level+r.size){case"AAsmall":case"AAAlarge":o=i>=4.5;break;case"AAlarge":o=i>=3;break;case"AAAsmall":o=i>=7}return o},qo.mostReadable=function(e,t,n){var r,o,i,a,s=null,c=0;o=(n=n||{}).includeFallbackColors,i=n.level,a=n.size;for(var l=0;l<t.length;l++)(r=qo.readability(e,t[l]))>c&&(c=r,s=qo(t[l]));return qo.isReadable(e,s,{level:i,size:a})||!o?s:(n.includeFallbackColors=!1,qo.mostReadable(e,["#fff","#000"],n))};var li=qo.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},ui=qo.hexNames=function(e){var t={};for(var n in e)e.hasOwnProperty(n)&&(t[e[n]]=n);return t}(li);function di(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function hi(e,t){(function(e){return"string"==typeof e&&-1!=e.indexOf(".")&&1===parseFloat(e)})(e)&&(e="100%");var n=function(e){return"string"==typeof e&&-1!=e.indexOf("%")}(e);return e=Math.min(t,Math.max(0,parseFloat(e))),n&&(e=parseInt(e*t,10)/100),Math.abs(e-t)<1e-6?1:e%t/parseFloat(t)}function fi(e){return Math.min(1,Math.max(0,e))}function pi(e){return parseInt(e,16)}function gi(e){return 1==e.length?"0"+e:""+e}function mi(e){return e<=1&&(e=100*e+"%"),e}function yi(e){return Math.round(255*parseFloat(e)).toString(16)}function vi(e){return pi(e)/255}var bi,wi,xi,ki=(wi="[\\s|\\(]+("+(bi="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+bi+")[,|\\s]+("+bi+")\\s*\\)?",xi="[\\s|\\(]+("+bi+")[,|\\s]+("+bi+")[,|\\s]+("+bi+")[,|\\s]+("+bi+")\\s*\\)?",{CSS_UNIT:new RegExp(bi),rgb:new RegExp("rgb"+wi),rgba:new RegExp("rgba"+xi),hsl:new RegExp("hsl"+wi),hsla:new RegExp("hsla"+xi),hsv:new RegExp("hsv"+wi),hsva:new RegExp("hsva"+xi),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/});function Ei(e){return!!ki.CSS_UNIT.exec(e)}function _i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Ai(e,t,n){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:n;throw new TypeError("Private element is not present on this object")}function Mi(e,t,n){return t=Ii(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,Ri()?Reflect.construct(t,n||[],Ii(e).constructor):t.apply(e,n))}function Ti(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ci(e,t){return e.get(Ai(e,t))}function Ni(e,t,n){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,n)}function Oi(e,t,n){return e.set(Ai(e,t),n),n}function Di(e,t,n){if(Ri())return Reflect.construct.apply(null,arguments);var r=[null];return r.push.apply(r,t),new(e.bind.apply(e,r))}function Pi(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,Gi(r.key),r)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function Si(e,t,n){return(t=Gi(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Li(){return Li="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=Ii(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(arguments.length<3?e:n):o.value}},Li.apply(null,arguments)}function Ii(e){return Ii=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Ii(e)}function ji(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Bi(e,t)}function Ri(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(Ri=function(){return!!e})()}function Fi(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 Bi(e,t){return Bi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Bi(e,t)}function zi(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,a,s=[],c=!0,l=!1;try{if(i=(n=n.call(e)).next,0===t);else for(;!(c=(r=i.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,o=e}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(l)throw o}}return s}}(e,t)||Ki(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Vi(e,t,n,r){var o=Li(Ii(e.prototype),t,n);return"function"==typeof o?function(e){return o.apply(n,e)}:o}function Ui(e){return function(e){if(Array.isArray(e))return _i(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Ki(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Gi(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function Hi(e){return Hi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Hi(e)}function Ki(e,t){if(e){if("string"==typeof e)return _i(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_i(e,t):void 0}}var qi=function(e){e instanceof Array?e.forEach(qi):(e.map&&e.map.dispose(),e.dispose())},$i=function(e){e.geometry&&e.geometry.dispose(),e.material&&qi(e.material),e.texture&&e.texture.dispose(),e.children&&e.children.forEach($i)},Wi=function(e){for(;e.children.length;){var t=e.children[0];e.remove(t),$i(t)}},Xi=new WeakMap,Ji=new WeakMap,Zi=function(e){function t(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=r.dataBindAttr,i=void 0===o?"__data":o,a=r.objBindAttr,s=void 0===a?"__threeObj":a;return Ti(this,t),Si(n=Mi(this,t),"scene",void 0),Ni(n,Xi,void 0),Ni(n,Ji,void 0),n.scene=e,Oi(Xi,n,i),Oi(Ji,n,s),n.onRemoveObj(function(){}),n}return ji(t,e),Pi(t,[{key:"onCreateObj",value:function(e){var n=this;return Vi(t,"onCreateObj",this)([function(t){var r=e(t);return t[Ci(Ji,n)]=r,r[Ci(Xi,n)]=t,n.scene.add(r),r}]),this}},{key:"onRemoveObj",value:function(e){var n=this;return Vi(t,"onRemoveObj",this)([function(r,o){var i=Vi(t,"getData",n)([r]);e(r,o),n.scene.remove(r),Wi(r),delete i[Ci(Ji,n)]}]),this}}])}(Bo),Yi=function(e){return isNaN(e)?parseInt(qo(e).toHex(),16):e},Qi=function(e){return isNaN(e)?qo(e).getAlpha():1},ea=function e(){var t=new vo,n=[],r=[],o=Vo;function i(e){let i=t.get(e);if(void 0===i){if(o!==Vo)return o;t.set(e,i=n.push(e)-1)}return r[i%r.length]}return i.domain=function(e){if(!arguments.length)return n.slice();n=[],t=new vo;for(const r of e)t.has(r)||t.set(r,n.push(r)-1);return i},i.range=function(e){return arguments.length?(r=Array.from(e),i):r.slice()},i.unknown=function(e){return arguments.length?(o=e,i):o},i.copy=function(){return e(n,r).unknown(o)},zo.apply(i,arguments),i}(Uo);function ta(e,t,n){t&&"string"==typeof n&&e.filter(function(e){return!e[n]}).forEach(function(e){e[n]=ea(t(e))})}var na=window.THREE?window.THREE:{Group:e.Group,Mesh:e.Mesh,MeshLambertMaterial:e.MeshLambertMaterial,Color:e.Color,BufferGeometry:e.BufferGeometry,BufferAttribute:e.BufferAttribute,Matrix4:e.Matrix4,Vector3:e.Vector3,SphereGeometry:e.SphereGeometry,CylinderGeometry:e.CylinderGeometry,TubeGeometry:e.TubeGeometry,ConeGeometry:e.ConeGeometry,Line:e.Line,LineBasicMaterial:e.LineBasicMaterial,QuadraticBezierCurve3:e.QuadraticBezierCurve3,CubicBezierCurve3:e.CubicBezierCurve3,Box3:e.Box3},ra={graph:pr,forcelayout:zr},oa=(new na.BufferGeometry).setAttribute?"setAttribute":"addAttribute",ia=(new na.BufferGeometry).applyMatrix4?"applyMatrix4":"applyMatrix",aa=mo({props:{jsonUrl:{onChange:function(e,t){var n=this;e&&!t.fetchingJson&&(t.fetchingJson=!0,t.onLoading(),fetch(e).then(function(e){return e.json()}).then(function(e){t.fetchingJson=!1,t.onFinishLoading(e),n.graphData(e)}))},triggerUpdate:!1},graphData:{default:{nodes:[],links:[]},onChange:function(e,t){t.engineRunning=!1}},numDimensions:{default:3,onChange:function(e,t){var n=t.d3ForceLayout.force("charge");function r(e,t){e.forEach(function(e){delete e[t],delete e["v".concat(t)]})}n&&n.strength(e>2?-60:-30),e<3&&r(t.graphData.nodes,"z"),e<2&&r(t.graphData.nodes,"y")}},dagMode:{onChange:function(e,t){!e&&"d3"===t.forceEngine&&(t.graphData.nodes||[]).forEach(function(e){return e.fx=e.fy=e.fz=void 0})}},dagLevelDistance:{},dagNodeFilter:{default:function(e){return!0}},onDagError:{triggerUpdate:!1},nodeRelSize:{default:4},nodeId:{default:"id"},nodeVal:{default:"val"},nodeResolution:{default:8},nodeColor:{default:"color"},nodeAutoColorBy:{},nodeOpacity:{default:.75},nodeVisibility:{default:!0},nodeThreeObject:{},nodeThreeObjectExtend:{default:!1},nodePositionUpdate:{triggerUpdate:!1},linkSource:{default:"source"},linkTarget:{default:"target"},linkVisibility:{default:!0},linkColor:{default:"color"},linkAutoColorBy:{},linkOpacity:{default:.2},linkWidth:{},linkResolution:{default:6},linkCurvature:{default:0,triggerUpdate:!1},linkCurveRotation:{default:0,triggerUpdate:!1},linkMaterial:{},linkThreeObject:{},linkThreeObjectExtend:{default:!1},linkPositionUpdate:{triggerUpdate:!1},linkDirectionalArrowLength:{default:0},linkDirectionalArrowColor:{},linkDirectionalArrowRelPos:{default:.5,triggerUpdate:!1},linkDirectionalArrowResolution:{default:8},linkDirectionalParticles:{default:0},linkDirectionalParticleSpeed:{default:.01,triggerUpdate:!1},linkDirectionalParticleOffset:{default:0,triggerUpdate:!1},linkDirectionalParticleWidth:{default:.5},linkDirectionalParticleColor:{},linkDirectionalParticleResolution:{default:4},linkDirectionalParticleThreeObject:{},forceEngine:{default:"d3"},d3AlphaMin:{default:0},d3AlphaDecay:{default:.0228,triggerUpdate:!1,onChange:function(e,t){t.d3ForceLayout.alphaDecay(e)}},d3AlphaTarget:{default:0,triggerUpdate:!1,onChange:function(e,t){t.d3ForceLayout.alphaTarget(e)}},d3VelocityDecay:{default:.4,triggerUpdate:!1,onChange:function(e,t){t.d3ForceLayout.velocityDecay(e)}},ngraphPhysics:{default:{timeStep:20,gravity:-1.2,theta:.8,springLength:30,springCoefficient:8e-4,dragCoefficient:.02}},warmupTicks:{default:0,triggerUpdate:!1},cooldownTicks:{default:1/0,triggerUpdate:!1},cooldownTime:{default:15e3,triggerUpdate:!1},onLoading:{default:function(){},triggerUpdate:!1},onFinishLoading:{default:function(){},triggerUpdate:!1},onUpdate:{default:function(){},triggerUpdate:!1},onFinishUpdate:{default:function(){},triggerUpdate:!1},onEngineTick:{default:function(){},triggerUpdate:!1},onEngineStop:{default:function(){},triggerUpdate:!1}},methods:{refresh:function(e){return e._flushObjects=!0,e._rerender(),this},d3Force:function(e,t,n){return void 0===n?e.d3ForceLayout.force(t):(e.d3ForceLayout.force(t,n),this)},d3ReheatSimulation:function(e){return e.d3ForceLayout.alpha(1),this.resetCountdown(),this},resetCountdown:function(e){return e.cntTicks=0,e.startTickTime=new Date,e.engineRunning=!0,this},tickFrame:function(e){var t,n,r,o,i,a="ngraph"!==e.forceEngine;return e.engineRunning&&function(){++e.cntTicks>e.cooldownTicks||new Date-e.startTickTime>e.cooldownTime||a&&e.d3AlphaMin>0&&e.d3ForceLayout.alpha()<e.d3AlphaMin?(e.engineRunning=!1,e.onEngineStop()):(e.layout[a?"tick":"step"](),e.onEngineTick());var t=yo(e.nodeThreeObjectExtend);e.nodeDataMapper.entries().forEach(function(n){var r=zi(n,2),o=r[0],i=r[1];if(i){var s=a?o:e.layout.getNodePosition(o[e.nodeId]),c=t(o);e.nodePositionUpdate&&e.nodePositionUpdate(c?i.children[0]:i,{x:s.x,y:s.y,z:s.z},o)&&!c||(i.position.x=s.x,i.position.y=s.y||0,i.position.z=s.z||0)}});var n=yo(e.linkWidth),r=yo(e.linkCurvature),o=yo(e.linkCurveRotation),i=yo(e.linkThreeObjectExtend);function s(t){var n=a?t:e.layout.getLinkPosition(e.layout.graph.getLink(t.source,t.target).id),i=n[a?"source":"from"],s=n[a?"target":"to"];if(i&&s&&i.hasOwnProperty("x")&&s.hasOwnProperty("x")){var c=r(t);if(c){var l,u=new na.Vector3(i.x,i.y||0,i.z||0),d=new na.Vector3(s.x,s.y||0,s.z||0),h=u.distanceTo(d),f=o(t);if(h>0){var p=s.x-i.x,g=s.y-i.y||0,m=(new na.Vector3).subVectors(d,u),y=m.clone().multiplyScalar(c).cross(0!==p||0!==g?new na.Vector3(0,0,1):new na.Vector3(0,1,0)).applyAxisAngle(m.normalize(),f).add((new na.Vector3).addVectors(u,d).divideScalar(2));l=new na.QuadraticBezierCurve3(u,y,d)}else{var v=70*c,b=-f,w=b+Math.PI/2;l=new na.CubicBezierCurve3(u,new na.Vector3(v*Math.cos(w),v*Math.sin(w),0).add(u),new na.Vector3(v*Math.cos(b),v*Math.sin(b),0).add(u),d)}t.__curve=l}else t.__curve=null}}e.linkDataMapper.entries().forEach(function(t){var r=zi(t,2),o=r[0],c=r[1];if(c){var l=a?o:e.layout.getLinkPosition(e.layout.graph.getLink(o.source,o.target).id),u=l[a?"source":"from"],d=l[a?"target":"to"];if(u&&d&&u.hasOwnProperty("x")&&d.hasOwnProperty("x")){s(o);var h=i(o);if(!e.linkPositionUpdate||!e.linkPositionUpdate(h?c.children[1]:c,{start:{x:u.x,y:u.y,z:u.z},end:{x:d.x,y:d.y,z:d.z}},o)||h){var f=30,p=o.__curve,g=c.children.length?c.children[0]:c;if("Line"===g.type){if(p){var m=p.getPoints(f);g.geometry.getAttribute("position").array.length!==3*m.length&&g.geometry[oa]("position",new na.BufferAttribute(new Float32Array(3*m.length),3)),g.geometry.setFromPoints(m)}else{var y=g.geometry.getAttribute("position");y&&y.array&&6===y.array.length||g.geometry[oa]("position",y=new na.BufferAttribute(new Float32Array(6),3)),y.array[0]=u.x,y.array[1]=u.y||0,y.array[2]=u.z||0,y.array[3]=d.x,y.array[4]=d.y||0,y.array[5]=d.z||0,y.needsUpdate=!0}g.geometry.computeBoundingSphere()}else if("Mesh"===g.type)if(p){g.geometry.type.match(/^Tube(Buffer)?Geometry$/)||(g.position.set(0,0,0),g.rotation.set(0,0,0),g.scale.set(1,1,1));var v=Math.ceil(10*n(o))/10/2,b=new na.TubeGeometry(p,f,v,e.linkResolution,!1);g.geometry.dispose(),g.geometry=b}else{if(!g.geometry.type.match(/^Cylinder(Buffer)?Geometry$/)){var w=Math.ceil(10*n(o))/10/2,x=new na.CylinderGeometry(w,w,1,e.linkResolution,1,!1);x[ia]((new na.Matrix4).makeTranslation(0,.5,0)),x[ia]((new na.Matrix4).makeRotationX(Math.PI/2)),g.geometry.dispose(),g.geometry=x}var k=new na.Vector3(u.x,u.y||0,u.z||0),E=new na.Vector3(d.x,d.y||0,d.z||0),_=k.distanceTo(E);g.position.x=k.x,g.position.y=k.y,g.position.z=k.z,g.scale.z=_,g.parent.localToWorld(E),g.lookAt(E)}}}}})}(),t=yo(e.linkDirectionalArrowRelPos),n=yo(e.linkDirectionalArrowLength),r=yo(e.nodeVal),e.arrowDataMapper.entries().forEach(function(o){var i=zi(o,2),s=i[0],c=i[1];if(c){var l=a?s:e.layout.getLinkPosition(e.layout.graph.getLink(s.source,s.target).id),u=l[a?"source":"from"],d=l[a?"target":"to"];if(u&&d&&u.hasOwnProperty("x")&&d.hasOwnProperty("x")){var h=Math.cbrt(Math.max(0,r(u)||1))*e.nodeRelSize,f=Math.cbrt(Math.max(0,r(d)||1))*e.nodeRelSize,p=n(s),g=t(s),m=s.__curve?function(e){return s.__curve.getPoint(e)}:function(e){var t=function(e,t,n,r){return t[e]+(n[e]-t[e])*r||0};return{x:t("x",u,d,e),y:t("y",u,d,e),z:t("z",u,d,e)}},y=s.__curve?s.__curve.getLength():Math.sqrt(["x","y","z"].map(function(e){return Math.pow((d[e]||0)-(u[e]||0),2)}).reduce(function(e,t){return e+t},0)),v=h+p+(y-h-f-p)*g,b=m(v/y),w=m((v-p)/y);["x","y","z"].forEach(function(e){return c.position[e]=w[e]});var x=Di(na.Vector3,Ui(["x","y","z"].map(function(e){return b[e]})));c.parent.localToWorld(x),c.lookAt(x)}}}),o=yo(e.linkDirectionalParticleSpeed),i=yo(e.linkDirectionalParticleOffset),e.graphData.links.forEach(function(t){var n=e.particlesDataMapper.getObj(t),r=n&&n.children,s=t.__singleHopPhotonsObj&&t.__singleHopPhotonsObj.children;if(s&&s.length||r&&r.length){var c=a?t:e.layout.getLinkPosition(e.layout.graph.getLink(t.source,t.target).id),l=c[a?"source":"from"],u=c[a?"target":"to"];if(l&&u&&l.hasOwnProperty("x")&&u.hasOwnProperty("x")){var d=o(t),h=Math.abs(i(t)),f=t.__curve?function(e){return t.__curve.getPoint(e)}:function(e){var t=function(e,t,n,r){return t[e]+(n[e]-t[e])*r||0};return{x:t("x",l,u,e),y:t("y",l,u,e),z:t("z",l,u,e)}};[].concat(Ui(r||[]),Ui(s||[])).forEach(function(e,t){var n="singleHopPhotons"===e.parent.__linkThreeObjType;if(e.hasOwnProperty("__progressRatio")||(e.__progressRatio=n?0:(t+h)/r.length),e.__progressRatio+=d,e.__progressRatio>=1){if(n)return e.parent.remove(e),void Wi(e);e.__progressRatio=e.__progressRatio%1}var o=e.__progressRatio,i=f(o);"SphereGeometry"!==e.geometry.type&&e.lookAt(i.x,i.y,i.z),["x","y","z"].forEach(function(t){return e.position[t]=i[t]})})}}}),this},emitParticle:function(e,t){if(t&&e.graphData.links.includes(t)){if(!t.__singleHopPhotonsObj){var n=new na.Group;n.__linkThreeObjType="singleHopPhotons",t.__singleHopPhotonsObj=n,e.graphScene.add(n)}var r=yo(e.linkDirectionalParticleThreeObject)(t);if(r&&e.linkDirectionalParticleThreeObject===r&&(r=r.clone()),!r){var o=yo(e.linkDirectionalParticleWidth),i=Math.ceil(10*o(t))/10/2,a=e.linkDirectionalParticleResolution,s=new na.SphereGeometry(i,a,a),c=yo(e.linkColor),l=yo(e.linkDirectionalParticleColor)(t)||c(t)||"#f0f0f0",u=new na.Color(Yi(l)),d=3*e.linkOpacity,h=new na.MeshLambertMaterial({color:u,transparent:!0,opacity:d});r=new na.Mesh(s,h)}t.__singleHopPhotonsObj.add(r)}return this},getGraphBbox:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){return!0};if(!e.initialised)return null;var n=function e(n){var r=[];if(n.geometry){n.geometry.computeBoundingBox();var o=new na.Box3;o.copy(n.geometry.boundingBox).applyMatrix4(n.matrixWorld),r.push(o)}return r.concat.apply(r,Ui((n.children||[]).filter(function(e){return!e.hasOwnProperty("__graphObjType")||"node"===e.__graphObjType&&t(e.__data)}).map(e)))}(e.graphScene);return n.length?Object.assign.apply(Object,Ui(["x","y","z"].map(function(e){return Si({},e,[ko(n,function(t){return t.min[e]}),xo(n,function(t){return t.max[e]})])}))):null}},stateInit:function(){return{d3ForceLayout:ir().force("link",Mn()).force("charge",ar()).force("center",Xt()).force("dagRadial",null).stop(),engineRunning:!1}},init:function(e,t){t.graphScene=e,t.nodeDataMapper=new Zi(e,{objBindAttr:"__threeObj"}),t.linkDataMapper=new Zi(e,{objBindAttr:"__lineObj"}),t.arrowDataMapper=new Zi(e,{objBindAttr:"__arrowObj"}),t.particlesDataMapper=new Zi(e,{objBindAttr:"__photonsObj"})},update:function(e,t){var n=function(e){return e.some(function(e){return t.hasOwnProperty(e)})};if(e.engineRunning=!1,"function"==typeof e.onUpdate&&e.onUpdate(),null!==e.nodeAutoColorBy&&n(["nodeAutoColorBy","graphData","nodeColor"])&&ta(e.graphData.nodes,yo(e.nodeAutoColorBy),e.nodeColor),null!==e.linkAutoColorBy&&n(["linkAutoColorBy","graphData","linkColor"])&&ta(e.graphData.links,yo(e.linkAutoColorBy),e.linkColor),e._flushObjects||n(["graphData","nodeThreeObject","nodeThreeObjectExtend","nodeVal","nodeColor","nodeVisibility","nodeRelSize","nodeResolution","nodeOpacity"])){var r=yo(e.nodeThreeObject),o=yo(e.nodeThreeObjectExtend),i=yo(e.nodeVal),a=yo(e.nodeColor),s=yo(e.nodeVisibility),c={},l={};(e._flushObjects||n(["nodeThreeObject","nodeThreeObjectExtend"]))&&e.nodeDataMapper.clear(),e.nodeDataMapper.onCreateObj(function(t){var n,i=r(t),a=o(t);return i&&e.nodeThreeObject===i&&(i=i.clone()),i&&!a?n=i:((n=new na.Mesh).__graphDefaultObj=!0,i&&a&&n.add(i)),n.__graphObjType="node",n}).onUpdateObj(function(t,n){if(t.__graphDefaultObj){var r=i(n)||1,o=Math.cbrt(r)*e.nodeRelSize,s=e.nodeResolution;t.geometry.type.match(/^Sphere(Buffer)?Geometry$/)&&t.geometry.parameters.radius===o&&t.geometry.parameters.widthSegments===s||(c.hasOwnProperty(r)||(c[r]=new na.SphereGeometry(o,s,s)),t.geometry.dispose(),t.geometry=c[r]);var u=a(n),d=new na.Color(Yi(u||"#ffffaa")),h=e.nodeOpacity*Qi(u);"MeshLambertMaterial"===t.material.type&&t.material.color.equals(d)&&t.material.opacity===h||(l.hasOwnProperty(u)||(l[u]=new na.MeshLambertMaterial({color:d,transparent:!0,opacity:h})),t.material.dispose(),t.material=l[u])}}).digest(e.graphData.nodes.filter(s))}if(e._flushObjects||n(["graphData","linkThreeObject","linkThreeObjectExtend","linkMaterial","linkColor","linkWidth","linkVisibility","linkResolution","linkOpacity","linkDirectionalArrowLength","linkDirectionalArrowColor","linkDirectionalArrowResolution","linkDirectionalParticles","linkDirectionalParticleWidth","linkDirectionalParticleColor","linkDirectionalParticleResolution","linkDirectionalParticleThreeObject"])){var u=yo(e.linkThreeObject),d=yo(e.linkThreeObjectExtend),h=yo(e.linkMaterial),f=yo(e.linkVisibility),p=yo(e.linkColor),g=yo(e.linkWidth),m={},y={},v={},b=e.graphData.links.filter(f);if((e._flushObjects||n(["linkThreeObject","linkThreeObjectExtend","linkWidth"]))&&e.linkDataMapper.clear(),e.linkDataMapper.onRemoveObj(function(e){var t=e.__data&&e.__data.__singleHopPhotonsObj;t&&(t.parent.remove(t),Wi(t),delete e.__data.__singleHopPhotonsObj)}).onCreateObj(function(t){var n,r,o=u(t),i=d(t);if(o&&e.linkThreeObject===o&&(o=o.clone()),!o||i)if(!!g(t))n=new na.Mesh;else{var a=new na.BufferGeometry;a[oa]("position",new na.BufferAttribute(new Float32Array(6),3)),n=new na.Line(a)}return o?i?((r=new na.Group).__graphDefaultObj=!0,r.add(n),r.add(o)):r=o:(r=n).__graphDefaultObj=!0,r.renderOrder=10,r.__graphObjType="link",r}).onUpdateObj(function(t,n){if(t.__graphDefaultObj){var r=t.children.length?t.children[0]:t,o=Math.ceil(10*g(n))/10,i=!!o;if(i){var a=o/2,s=e.linkResolution;if(!r.geometry.type.match(/^Cylinder(Buffer)?Geometry$/)||r.geometry.parameters.radiusTop!==a||r.geometry.parameters.radialSegments!==s){if(!m.hasOwnProperty(o)){var c=new na.CylinderGeometry(a,a,1,s,1,!1);c[ia]((new na.Matrix4).makeTranslation(0,.5,0)),c[ia]((new na.Matrix4).makeRotationX(Math.PI/2)),m[o]=c}r.geometry.dispose(),r.geometry=m[o]}}var l=h(n);if(l)r.material=l;else{var u=p(n),d=new na.Color(Yi(u||"#f0f0f0")),f=e.linkOpacity*Qi(u),b=i?"MeshLambertMaterial":"LineBasicMaterial";if(r.material.type!==b||!r.material.color.equals(d)||r.material.opacity!==f){var w=i?y:v;w.hasOwnProperty(u)||(w[u]=new na[b]({color:d,transparent:f<1,opacity:f,depthWrite:f>=1})),r.material.dispose(),r.material=w[u]}}}}).digest(b),e.linkDirectionalArrowLength||t.hasOwnProperty("linkDirectionalArrowLength")){var w=yo(e.linkDirectionalArrowLength),x=yo(e.linkDirectionalArrowColor);e.arrowDataMapper.onCreateObj(function(){var e=new na.Mesh(void 0,new na.MeshLambertMaterial({transparent:!0}));return e.__linkThreeObjType="arrow",e}).onUpdateObj(function(t,n){var r=w(n),o=e.linkDirectionalArrowResolution;if(!t.geometry.type.match(/^Cone(Buffer)?Geometry$/)||t.geometry.parameters.height!==r||t.geometry.parameters.radialSegments!==o){var i=new na.ConeGeometry(.25*r,r,o);i.translate(0,r/2,0),i.rotateX(Math.PI/2),t.geometry.dispose(),t.geometry=i}var a=x(n)||p(n)||"#f0f0f0";t.material.color=new na.Color(Yi(a)),t.material.opacity=3*e.linkOpacity*Qi(a)}).digest(b.filter(w))}if(e.linkDirectionalParticles||t.hasOwnProperty("linkDirectionalParticles")){var k=yo(e.linkDirectionalParticles),E=yo(e.linkDirectionalParticleWidth),_=yo(e.linkDirectionalParticleColor),A=yo(e.linkDirectionalParticleThreeObject),M={},T={};e.particlesDataMapper.onCreateObj(function(){var e=new na.Group;return e.__linkThreeObjType="photons",e.__photonDataMapper=new Zi(e),e}).onUpdateObj(function(t,n){var r,o,i=!!t.children.length&&t.children[0],a=A(n);if(a)r=a.geometry,o=a.material;else{var s=Math.ceil(10*E(n))/10/2,c=e.linkDirectionalParticleResolution;i&&i.geometry.parameters.radius===s&&i.geometry.parameters.widthSegments===c?r=i.geometry:(T.hasOwnProperty(s)||(T[s]=new na.SphereGeometry(s,c,c)),r=T[s]);var l=_(n)||p(n)||"#f0f0f0",u=new na.Color(Yi(l)),d=3*e.linkOpacity;i&&i.material.color.equals(u)&&i.material.opacity===d?o=i.material:(M.hasOwnProperty(l)||(M[l]=new na.MeshLambertMaterial({color:u,transparent:!0,opacity:d})),o=M[l])}i&&(i.geometry!==r&&i.geometry.dispose(),i.material!==o&&i.material.dispose());var h=Math.round(Math.abs(k(n)));t.__photonDataMapper.id(function(e){return e.idx}).onCreateObj(function(){return new na.Mesh(r,o)}).onUpdateObj(function(e){e.geometry=r,e.material=o}).digest(Ui(new Array(h)).map(function(e,t){return{idx:t}}))}).digest(b.filter(k))}}if(e._flushObjects=!1,n(["graphData","nodeId","linkSource","linkTarget","numDimensions","forceEngine","dagMode","dagNodeFilter","dagLevelDistance"])){e.engineRunning=!1,e.graphData.links.forEach(function(t){t.source=t[e.linkSource],t.target=t[e.linkTarget]});var C,N="ngraph"!==e.forceEngine;if(N){(C=e.d3ForceLayout).stop().alpha(1).numDimensions(e.numDimensions).nodes(e.graphData.nodes);var O=e.d3ForceLayout.force("link");O&&O.id(function(t){return t[e.nodeId]}).links(e.graphData.links);var D=e.dagMode&&function(e,t){var n=e.nodes,r=e.links,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=o.nodeFilter,a=void 0===i?function(){return!0}:i,s=o.onLoopError,c=void 0===s?function(e){throw"Invalid DAG structure! Found cycle in node path: ".concat(e.join(" -> "),".")}:s,l={};n.forEach(function(e){return l[t(e)]={data:e,out:[],depth:-1,skip:!a(e)}}),r.forEach(function(e){var n=e.source,r=e.target,o=c(n),i=c(r);if(!l.hasOwnProperty(o))throw"Missing source node with id: ".concat(o);if(!l.hasOwnProperty(i))throw"Missing target node with id: ".concat(i);var a=l[o],s=l[i];function c(e){return"object"===Hi(e)?t(e):e}a.out.push(s)});var u=[];return function e(n){for(var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=function(){var i=n[a];if(-1!==r.indexOf(i)){var s=[].concat(Ui(r.slice(r.indexOf(i))),[i]).map(function(e){return t(e.data)});return u.some(function(e){return e.length===s.length&&e.every(function(e,t){return e===s[t]})})||(u.push(s),c(s)),1}o>i.depth&&(i.depth=o,e(i.out,[].concat(Ui(r),[i]),o+(i.skip?0:1)))},a=0,s=n.length;a<s;a++)i()}(Object.values(l)),Object.assign.apply(Object,[{}].concat(Ui(Object.entries(l).filter(function(e){return!zi(e,2)[1].skip}).map(function(e){var t=zi(e,2);return Si({},t[0],t[1].depth)}))))}(e.graphData,function(t){return t[e.nodeId]},{nodeFilter:e.dagNodeFilter,onLoopError:e.onDagError||void 0}),P=Math.max.apply(Math,Ui(Object.values(D||[]))),S=e.dagLevelDistance||e.graphData.nodes.length/(P||1)*2*(-1!==["radialin","radialout"].indexOf(e.dagMode)?.7:1);if(["lr","rl","td","bu","zin","zout"].includes(t.dagMode)){var L=["lr","rl"].includes(t.dagMode)?"fx":["td","bu"].includes(t.dagMode)?"fy":"fz";e.graphData.nodes.filter(e.dagNodeFilter).forEach(function(e){return delete e[L]})}if(["lr","rl","td","bu","zin","zout"].includes(e.dagMode)){var I=["rl","td","zout"].includes(e.dagMode),j=["lr","rl"].includes(e.dagMode)?"fx":["td","bu"].includes(e.dagMode)?"fy":"fz";e.graphData.nodes.filter(e.dagNodeFilter).forEach(function(t){return t[j]=function(t){return(D[t[e.nodeId]]-P/2)*S*(I?-1:1)}(t)})}e.d3ForceLayout.force("dagRadial",-1!==["radialin","radialout"].indexOf(e.dagMode)?function(e,t,n,r){var o,i,a,s,c=kn(.1);function l(e){for(var c=0,l=o.length;c<l;++c){var u=o[c],d=u.x-t||1e-6,h=(u.y||0)-n||1e-6,f=(u.z||0)-r||1e-6,p=Math.sqrt(d*d+h*h+f*f),g=(s[c]-p)*a[c]*e/p;u.vx+=d*g,i>1&&(u.vy+=h*g),i>2&&(u.vz+=f*g)}}function u(){if(o){var t,n=o.length;for(a=new Array(n),s=new Array(n),t=0;t<n;++t)s[t]=+e(o[t],t,o),a[t]=isNaN(s[t])?0:+c(o[t],t,o)}}return"function"!=typeof e&&(e=kn(+e)),null==t&&(t=0),null==n&&(n=0),null==r&&(r=0),l.initialize=function(e,...t){o=e,i=t.find(e=>[1,2,3].includes(e))||2,u()},l.strength=function(e){return arguments.length?(c="function"==typeof e?e:kn(+e),u(),l):c},l.radius=function(t){return arguments.length?(e="function"==typeof t?t:kn(+t),u(),l):e},l.x=function(e){return arguments.length?(t=+e,l):t},l.y=function(e){return arguments.length?(n=+e,l):n},l.z=function(e){return arguments.length?(r=+e,l):r},l}(function(t){var n=D[t[e.nodeId]]||-1;return("radialin"===e.dagMode?P-n:n)*S}).strength(function(t){return e.dagNodeFilter(t)?1:0}):null)}else{var R=ra.graph();e.graphData.nodes.forEach(function(t){R.addNode(t[e.nodeId])}),e.graphData.links.forEach(function(e){R.addLink(e.source,e.target)}),C=ra.forcelayout(R,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Fi(Object(n),!0).forEach(function(t){Si(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Fi(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}({dimensions:e.numDimensions},e.ngraphPhysics)),C.graph=R}for(var F=0;F<e.warmupTicks&&!(N&&e.d3AlphaMin>0&&e.d3ForceLayout.alpha()<e.d3AlphaMin);F++)C[N?"tick":"step"]();e.layout=C,this.resetCountdown()}e.engineRunning=!0,e.onFinishUpdate()}});var sa=function(e){var t=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=function(n){function r(){var n;Ti(this,r);for(var o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];return(n=Mi(this,r,[].concat(i))).__kapsuleInstance=Di(e,[].concat(Ui(t?[n]:[]),i)),n}return ji(r,n),Pi(r)}(arguments.length>1&&void 0!==arguments[1]?arguments[1]:Object);return Object.keys(e()).forEach(function(e){return n.prototype[e]=function(){var t,n=(t=this.__kapsuleInstance)[e].apply(t,arguments);return n===this.__kapsuleInstance?this:n}}),n}(aa,(window.THREE?window.THREE:{Group:e.Group}).Group,!0);if("undefined"==typeof AFRAME)throw new Error("Component attempted to register before AFRAME was available.");var ca=function(e){return"string"==typeof e?JSON.parse(e):e},la=function(e){if("function"==typeof e)return e;var t=eval;try{return t("("+e+")")}catch(e){}return null},ua=function(e){return isNaN(parseFloat(e))?la(e)?la(e):e:parseFloat(e)};function da(){return da=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},da.apply(null,arguments)}function ha(e,t){return ha=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},ha(e,t)}function fa(e){return fa=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},fa(e)}function pa(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(pa=function(){return!!e})()}function ga(e){var t="function"==typeof Map?new Map:void 0;return ga=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(pa())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var o=new(e.bind.apply(e,r));return n&&ha(o,n.prototype),o}(e,arguments,fa(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),ha(n,e)},ga(e)}AFRAME.components.hasOwnProperty("forcegraph")||AFRAME.registerComponent("forcegraph",{schema:{jsonUrl:{type:"string",default:""},nodes:{parse:ca,default:[]},links:{parse:ca,default:[]},numDimensions:{type:"number",default:3},dagMode:{type:"string",default:""},dagLevelDistance:{type:"number",default:0},dagNodeFilter:{parse:la,default:function(){return!0}},onDagError:{parse:la,default:void 0},nodeRelSize:{type:"number",default:4},nodeId:{type:"string",default:"id"},nodeVal:{parse:ua,default:"val"},nodeResolution:{type:"number",default:8},nodeVisibility:{parse:ua,default:!0},nodeColor:{parse:ua,default:"color"},nodeAutoColorBy:{parse:ua,default:""},nodeOpacity:{type:"number",default:.75},nodeThreeObject:{parse:ua,default:null},nodeThreeObjectExtend:{parse:ua,default:!1},linkSource:{type:"string",default:"source"},linkTarget:{type:"string",default:"target"},linkVisibility:{parse:ua,default:!0},linkColor:{parse:ua,default:"color"},linkAutoColorBy:{parse:ua,default:""},linkOpacity:{type:"number",default:.2},linkWidth:{parse:ua,default:0},linkResolution:{type:"number",default:6},linkCurvature:{parse:ua,default:0},linkCurveRotation:{parse:ua,default:0},linkMaterial:{parse:ua,default:null},linkThreeObject:{parse:ua,default:null},linkThreeObjectExtend:{parse:ua,default:!1},linkPositionUpdate:{parse:la,default:null},linkDirectionalArrowLength:{parse:ua,default:0},linkDirectionalArrowColor:{parse:ua,default:null},linkDirectionalArrowRelPos:{parse:ua,default:.5},linkDirectionalArrowResolution:{type:"number",default:8},linkDirectionalParticles:{parse:ua,default:0},linkDirectionalParticleSpeed:{parse:ua,default:.01},linkDirectionalParticleOffset:{parse:ua,default:0},linkDirectionalParticleWidth:{parse:ua,default:.5},linkDirectionalParticleColor:{parse:ua,default:null},linkDirectionalParticleResolution:{type:"number",default:4},linkDirectionalParticleThreeObject:{parse:ua,default:null},onNodeHover:{parse:la,default:function(){}},onLinkHover:{parse:la,default:function(){}},onNodeClick:{parse:la,default:function(){}},onLinkClick:{parse:la,default:function(){}},forceEngine:{type:"string",default:"d3"},d3AlphaMin:{type:"number",default:0},d3AlphaDecay:{type:"number",default:.0228},d3VelocityDecay:{type:"number",default:.4},ngraphPhysics:{parse:ca,default:null},warmupTicks:{type:"int",default:0},cooldownTicks:{type:"int",default:1e18},cooldownTime:{type:"int",default:15e3},onEngineTick:{parse:la,default:function(){}},onEngineStop:{parse:la,default:function(){}}},getGraphBbox:function(e){return this.forceGraph||(this.forceGraph=new sa),this.forceGraph.getGraphBbox(e)},emitParticle:function(){this.forceGraph||(this.forceGraph=new sa);var e=this.forceGraph,t=e.emitParticle.apply(e,arguments);return t===e?this:t},d3Force:function(){this.forceGraph||(this.forceGraph=new sa);var e=this.forceGraph,t=e.d3Force.apply(e,arguments);return t===e?this:t},d3ReheatSimulation:function(){return this.forceGraph&&this.forceGraph.d3ReheatSimulation(),this},refresh:function(){return this.forceGraph&&this.forceGraph.refresh(),this},init:function(){var e=this,t=this.state={};t.infoEl=document.createElement("a-text"),t.infoEl.setAttribute("position","0 -0.1 -1"),t.infoEl.setAttribute("width",1),t.infoEl.setAttribute("align","center"),t.infoEl.setAttribute("color","lavender");var n=document.querySelector("a-entity[camera], a-camera");n.appendChild(t.infoEl),t.cameraObj=n.object3D.children.filter(function(e){return"PerspectiveCamera"===e.type})[0],this.el.sceneEl.addEventListener("camera-set-active",function(e){t.cameraObj=e.detail.cameraEl.components.camera.camera}),this.forceGraph||(this.forceGraph=new sa),this.forceGraph.onFinishUpdate(function(){return e.el.setObject3D("forcegraphGroup",e.forceGraph)}).onLoading(function(){return t.infoEl.setAttribute("value","Loading...")}).onFinishLoading(function(){return t.infoEl.setAttribute("value","")}),this.el.addEventListener("raycaster-intersected",function(e){return t.hoverDetail=e.detail}),this.el.addEventListener("raycaster-intersected-cleared",function(e){return t.hoverDetail=e.detail}),this.el.addEventListener("click",function(){return t.hoverObj&&e.data["on"+("node"===t.hoverObj.__graphObjType?"Node":"Link")+"Click"](t.hoverObj.__data)})},remove:function(){this.state.infoEl.remove(),this.el.removeObject3D("forcegraphGroup")},update:function(e){var t=this,n=this.data,r=AFRAME.utils.diff(n,e);["jsonUrl","numDimensions","dagMode","dagLevelDistance","dagNodeFilter","onDagError","nodeRelSize","nodeId","nodeVal","nodeResolution","nodeVisibility","nodeColor","nodeAutoColorBy","nodeOpacity","nodeThreeObject","nodeThreeObjectExtend","linkSource","linkTarget","linkVisibility","linkColor","linkAutoColorBy","linkOpacity","linkWidth","linkResolution","linkCurvature","linkCurveRotation","linkMaterial","linkThreeObject","linkThreeObjectExtend","linkPositionUpdate","linkDirectionalArrowLength","linkDirectionalArrowColor","linkDirectionalArrowRelPos","linkDirectionalArrowResolution","linkDirectionalParticles","linkDirectionalParticleSpeed","linkDirectionalParticleOffset","linkDirectionalParticleWidth","linkDirectionalParticleColor","linkDirectionalParticleResolution","linkDirectionalParticleThreeObject","forceEngine","d3AlphaMin","d3AphaDecay","d3VelocityDecay","ngraphPhysics","warmupTicks","cooldownTicks","cooldownTime","onEngineTick","onEngineStop"].filter(function(e){return e in r}).forEach(function(e){t.forceGraph[e](""!==n[e]?n[e]:null)}),("nodes"in r||"links"in r)&&t.forceGraph.graphData({nodes:n.nodes,links:n.links})},tick:function(e,t){for(var n=this.state,r=this.data,o=n.hoverDetail?n.hoverDetail.getIntersection?n.hoverDetail.getIntersection(this.el):n.hoverDetail.intersection||void 0:void 0,i=o?o.object:void 0;i&&!i.hasOwnProperty("__graphObjType");)i=i.parent;if(i!==n.hoverObj){var a=n.hoverObj?n.hoverObj.__graphObjType:null,s=n.hoverObj?n.hoverObj.__data:null,c=i?i.__graphObjType:null,l=i?i.__data:null;a&&a!==c&&r["on"+("node"===a?"Node":"Link")+"Hover"](null,s),c&&r["on"+("node"===c?"Node":"Link")+"Hover"](l,a===c?s:null),n.hoverObj=i}this.forceGraph.tickFrame()}});var ma={1:"Passed invalid arguments to hsl, please pass multiple numbers e.g. hsl(360, 0.75, 0.4) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75 }).\n\n",2:"Passed invalid arguments to hsla, please pass multiple numbers e.g. hsla(360, 0.75, 0.4, 0.7) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75, alpha: 0.7 }).\n\n",3:"Passed an incorrect argument to a color function, please pass a string representation of a color.\n\n",4:"Couldn't generate valid rgb string from %s, it returned %s.\n\n",5:"Couldn't parse the color string. Please provide the color as a string in hex, rgb, rgba, hsl or hsla notation.\n\n",6:"Passed invalid arguments to rgb, please pass multiple numbers e.g. rgb(255, 205, 100) or an object e.g. rgb({ red: 255, green: 205, blue: 100 }).\n\n",7:"Passed invalid arguments to rgba, please pass multiple numbers e.g. rgb(255, 205, 100, 0.75) or an object e.g. rgb({ red: 255, green: 205, blue: 100, alpha: 0.75 }).\n\n",8:"Passed invalid argument to toColorString, please pass a RgbColor, RgbaColor, HslColor or HslaColor object.\n\n",9:"Please provide a number of steps to the modularScale helper.\n\n",10:"Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",11:'Invalid value passed as base to modularScale, expected number or em string but got "%s"\n\n',12:'Expected a string ending in "px" or a number passed as the first argument to %s(), got "%s" instead.\n\n',13:'Expected a string ending in "px" or a number passed as the second argument to %s(), got "%s" instead.\n\n',14:'Passed invalid pixel value ("%s") to %s(), please pass a value like "12px" or 12.\n\n',15:'Passed invalid base value ("%s") to %s(), please pass a value like "12px" or 12.\n\n',16:"You must provide a template to this method.\n\n",17:"You passed an unsupported selector state to this method.\n\n",18:"minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",19:"fromSize and toSize must be provided as stringified numbers with the same units.\n\n",20:"expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",21:"expects the objects in the first argument array to have the properties `prop`, `fromSize`, and `toSize`.\n\n",22:"expects the first argument object to have the properties `prop`, `fromSize`, and `toSize`.\n\n",23:"fontFace expects a name of a font-family.\n\n",24:"fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",25:"fontFace expects localFonts to be an array.\n\n",26:"fontFace expects fileFormats to be an array.\n\n",27:"radialGradient requries at least 2 color-stops to properly render.\n\n",28:"Please supply a filename to retinaImage() as the first argument.\n\n",29:"Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",30:"Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",31:"The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation\n\n",32:"To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s')\n\n",33:"The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation\n\n",34:"borderRadius expects a radius value as a string or number as the second argument.\n\n",35:'borderRadius expects one of "top", "bottom", "left" or "right" as the first argument.\n\n',36:"Property must be a string value.\n\n",37:"Syntax Error at %s.\n\n",38:"Formula contains a function that needs parentheses at %s.\n\n",39:"Formula is missing closing parenthesis at %s.\n\n",40:"Formula has too many closing parentheses at %s.\n\n",41:"All values in a formula must have the same unit or be unitless.\n\n",42:"Please provide a number of steps to the modularScale helper.\n\n",43:"Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",44:"Invalid value passed as base to modularScale, expected number or em/rem string but got %s.\n\n",45:"Passed invalid argument to hslToColorString, please pass a HslColor or HslaColor object.\n\n",46:"Passed invalid argument to rgbToColorString, please pass a RgbColor or RgbaColor object.\n\n",47:"minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",48:"fromSize and toSize must be provided as stringified numbers with the same units.\n\n",49:"Expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",50:"Expects the objects in the first argument array to have the properties prop, fromSize, and toSize.\n\n",51:"Expects the first argument object to have the properties prop, fromSize, and toSize.\n\n",52:"fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",53:"fontFace expects localFonts to be an array.\n\n",54:"fontFace expects fileFormats to be an array.\n\n",55:"fontFace expects a name of a font-family.\n\n",56:"linearGradient requries at least 2 color-stops to properly render.\n\n",57:"radialGradient requries at least 2 color-stops to properly render.\n\n",58:"Please supply a filename to retinaImage() as the first argument.\n\n",59:"Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",60:"Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",61:"Property must be a string value.\n\n",62:"borderRadius expects a radius value as a string or number as the second argument.\n\n",63:'borderRadius expects one of "top", "bottom", "left" or "right" as the first argument.\n\n',64:"The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation.\n\n",65:"To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s').\n\n",66:"The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation.\n\n",67:"You must provide a template to this method.\n\n",68:"You passed an unsupported selector state to this method.\n\n",69:'Expected a string ending in "px" or a number passed as the first argument to %s(), got %s instead.\n\n',70:'Expected a string ending in "px" or a number passed as the second argument to %s(), got %s instead.\n\n',71:'Passed invalid pixel value %s to %s(), please pass a value like "12px" or 12.\n\n',72:'Passed invalid base value %s to %s(), please pass a value like "12px" or 12.\n\n',73:"Please provide a valid CSS variable.\n\n",74:"CSS variable not found and no default was provided.\n\n",75:"important requires a valid style object, got a %s instead.\n\n",76:"fromSize and toSize must be provided as stringified numbers with the same units as minScreen and maxScreen.\n\n",77:'remToPx expects a value in "rem" but you provided it in "%s".\n\n',78:'base must be set in "px" or "%" but you set it in "%s".\n'};function ya(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r,o=t[0],i=[];for(r=1;r<t.length;r+=1)i.push(t[r]);return i.forEach(function(e){o=o.replace(/%[a-z]/,e)}),o}var va=function(e){var t,n;function r(t){var n;if("production"===process.env.NODE_ENV)n=e.call(this,"An error occurred. See https://github.com/styled-components/polished/blob/main/src/internalHelpers/errors.md#"+t+" for more information.")||this;else{for(var r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];n=e.call(this,ya.apply(void 0,[ma[t]].concat(o)))||this}return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n)}return n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,ha(t,n),r}(ga(Error));function ba(e){return Math.round(255*e)}function wa(e,t,n){return ba(e)+","+ba(t)+","+ba(n)}function xa(e,t,n,r){if(void 0===r&&(r=wa),0===t)return r(n,n,n);var o=(e%360+360)%360/60,i=(1-Math.abs(2*n-1))*t,a=i*(1-Math.abs(o%2-1)),s=0,c=0,l=0;o>=0&&o<1?(s=i,c=a):o>=1&&o<2?(s=a,c=i):o>=2&&o<3?(c=i,l=a):o>=3&&o<4?(c=a,l=i):o>=4&&o<5?(s=a,l=i):o>=5&&o<6&&(s=i,l=a);var u=n-i/2;return r(s+u,c+u,l+u)}var ka={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"639",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"};var Ea=/^#[a-fA-F0-9]{6}$/,_a=/^#[a-fA-F0-9]{8}$/,Aa=/^#[a-fA-F0-9]{3}$/,Ma=/^#[a-fA-F0-9]{4}$/,Ta=/^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i,Ca=/^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i,Na=/^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i,Oa=/^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;function Da(e){if("string"!=typeof e)throw new va(3);var t=function(e){if("string"!=typeof e)return e;var t=e.toLowerCase();return ka[t]?"#"+ka[t]:e}(e);if(t.match(Ea))return{red:parseInt(""+t[1]+t[2],16),green:parseInt(""+t[3]+t[4],16),blue:parseInt(""+t[5]+t[6],16)};if(t.match(_a)){var n=parseFloat((parseInt(""+t[7]+t[8],16)/255).toFixed(2));return{red:parseInt(""+t[1]+t[2],16),green:parseInt(""+t[3]+t[4],16),blue:parseInt(""+t[5]+t[6],16),alpha:n}}if(t.match(Aa))return{red:parseInt(""+t[1]+t[1],16),green:parseInt(""+t[2]+t[2],16),blue:parseInt(""+t[3]+t[3],16)};if(t.match(Ma)){var r=parseFloat((parseInt(""+t[4]+t[4],16)/255).toFixed(2));return{red:parseInt(""+t[1]+t[1],16),green:parseInt(""+t[2]+t[2],16),blue:parseInt(""+t[3]+t[3],16),alpha:r}}var o=Ta.exec(t);if(o)return{red:parseInt(""+o[1],10),green:parseInt(""+o[2],10),blue:parseInt(""+o[3],10)};var i=Ca.exec(t.substring(0,50));if(i)return{red:parseInt(""+i[1],10),green:parseInt(""+i[2],10),blue:parseInt(""+i[3],10),alpha:parseFloat(""+i[4])>1?parseFloat(""+i[4])/100:parseFloat(""+i[4])};var a=Na.exec(t);if(a){var s="rgb("+xa(parseInt(""+a[1],10),parseInt(""+a[2],10)/100,parseInt(""+a[3],10)/100)+")",c=Ta.exec(s);if(!c)throw new va(4,t,s);return{red:parseInt(""+c[1],10),green:parseInt(""+c[2],10),blue:parseInt(""+c[3],10)}}var l=Oa.exec(t.substring(0,50));if(l){var u="rgb("+xa(parseInt(""+l[1],10),parseInt(""+l[2],10)/100,parseInt(""+l[3],10)/100)+")",d=Ta.exec(u);if(!d)throw new va(4,t,u);return{red:parseInt(""+d[1],10),green:parseInt(""+d[2],10),blue:parseInt(""+d[3],10),alpha:parseFloat(""+l[4])>1?parseFloat(""+l[4])/100:parseFloat(""+l[4])}}throw new va(5)}function Pa(e){return function(e){var t,n=e.red/255,r=e.green/255,o=e.blue/255,i=Math.max(n,r,o),a=Math.min(n,r,o),s=(i+a)/2;if(i===a)return void 0!==e.alpha?{hue:0,saturation:0,lightness:s,alpha:e.alpha}:{hue:0,saturation:0,lightness:s};var c=i-a,l=s>.5?c/(2-i-a):c/(i+a);switch(i){case n:t=(r-o)/c+(r<o?6:0);break;case r:t=(o-n)/c+2;break;default:t=(n-r)/c+4}return t*=60,void 0!==e.alpha?{hue:t,saturation:l,lightness:s,alpha:e.alpha}:{hue:t,saturation:l,lightness:s}}(Da(e))}var Sa=function(e){return 7===e.length&&e[1]===e[2]&&e[3]===e[4]&&e[5]===e[6]?"#"+e[1]+e[3]+e[5]:e};function La(e){var t=e.toString(16);return 1===t.length?"0"+t:t}function Ia(e){return La(Math.round(255*e))}function ja(e,t,n){return Sa("#"+Ia(e)+Ia(t)+Ia(n))}function Ra(e,t,n){return xa(e,t,n,ja)}function Fa(e,t,n){if("number"==typeof e&&"number"==typeof t&&"number"==typeof n)return Sa("#"+La(e)+La(t)+La(n));if("object"==typeof e&&void 0===t&&void 0===n)return Sa("#"+La(e.red)+La(e.green)+La(e.blue));throw new va(6)}function Ba(e,t,n,r){if("object"==typeof e&&void 0===t&&void 0===n&&void 0===r)return e.alpha>=1?Fa(e.red,e.green,e.blue):"rgba("+e.red+","+e.green+","+e.blue+","+e.alpha+")";throw new va(7)}function za(e){if("object"!=typeof e)throw new va(8);if(function(e){return"number"==typeof e.red&&"number"==typeof e.green&&"number"==typeof e.blue&&"number"==typeof e.alpha}(e))return Ba(e);if(function(e){return"number"==typeof e.red&&"number"==typeof e.green&&"number"==typeof e.blue&&("number"!=typeof e.alpha||void 0===e.alpha)}(e))return Fa(e);if(function(e){return"number"==typeof e.hue&&"number"==typeof e.saturation&&"number"==typeof e.lightness&&"number"==typeof e.alpha}(e))return function(e,t,n,r){if("object"==typeof e&&void 0===t&&void 0===n&&void 0===r)return e.alpha>=1?Ra(e.hue,e.saturation,e.lightness):"rgba("+xa(e.hue,e.saturation,e.lightness)+","+e.alpha+")";throw new va(2)}(e);if(function(e){return"number"==typeof e.hue&&"number"==typeof e.saturation&&"number"==typeof e.lightness&&("number"!=typeof e.alpha||void 0===e.alpha)}(e))return function(e,t,n){if("object"==typeof e&&void 0===t&&void 0===n)return Ra(e.hue,e.saturation,e.lightness);throw new va(1)}(e);throw new va(8)}function Va(e,t,n){return function(){var r=n.concat(Array.prototype.slice.call(arguments));return r.length>=t?e.apply(this,r):Va(e,t,r)}}function Ua(e){return Va(e,e.length,[])}function Ga(e,t,n){return Math.max(e,Math.min(t,n))}Ua(function(e,t){if("transparent"===t)return t;var n=Pa(t);return za(da({},n,{hue:n.hue+parseFloat(e)}))}),Ua(function(e,t){if("transparent"===t)return t;var n=Pa(t);return za(da({},n,{lightness:Ga(0,1,n.lightness-parseFloat(e))}))}),Ua(function(e,t){if("transparent"===t)return t;var n=Pa(t);return za(da({},n,{saturation:Ga(0,1,n.saturation-parseFloat(e))}))}),Ua(function(e,t){if("transparent"===t)return t;var n=Pa(t);return za(da({},n,{lightness:Ga(0,1,n.lightness+parseFloat(e))}))});var Ha=Ua(function(e,t,n){if("transparent"===t)return n;if("transparent"===n)return t;if(0===e)return n;var r=Da(t),o=da({},r,{alpha:"number"==typeof r.alpha?r.alpha:1}),i=Da(n),a=da({},i,{alpha:"number"==typeof i.alpha?i.alpha:1}),s=o.alpha-a.alpha,c=2*parseFloat(e)-1,l=((c*s===-1?c:c+s)/(1+c*s)+1)/2,u=1-l;return Ba({red:Math.floor(o.red*l+a.red*u),green:Math.floor(o.green*l+a.green*u),blue:Math.floor(o.blue*l+a.blue*u),alpha:o.alpha*parseFloat(e)+a.alpha*(1-parseFloat(e))})}),Ka=Ha;var qa=Ua(function(e,t){if("transparent"===t)return t;var n=Da(t);return Ba(da({},n,{alpha:Ga(0,1,(100*("number"==typeof n.alpha?n.alpha:1)+100*parseFloat(e))/100)}))});Ua(function(e,t){if("transparent"===t)return t;var n=Pa(t);return za(da({},n,{saturation:Ga(0,1,n.saturation+parseFloat(e))}))}),Ua(function(e,t){return"transparent"===t?t:za(da({},Pa(t),{hue:parseFloat(e)}))}),Ua(function(e,t){return"transparent"===t?t:za(da({},Pa(t),{lightness:parseFloat(e)}))}),Ua(function(e,t){return"transparent"===t?t:za(da({},Pa(t),{saturation:parseFloat(e)}))}),Ua(function(e,t){return"transparent"===t?t:Ka(parseFloat(e),"rgb(0, 0, 0)",t)}),Ua(function(e,t){return"transparent"===t?t:Ka(parseFloat(e),"rgb(255, 255, 255)",t)}),Ua(function(e,t){if("transparent"===t)return t;var n=Da(t);return Ba(da({},n,{alpha:Ga(0,1,+(100*("number"==typeof n.alpha?n.alpha:1)-100*parseFloat(e)).toFixed(2)/100)}))});var $a=mo({props:{width:{default:window.innerWidth,triggerUpdate:!1,onChange:function(e,t){t.container&&(t.container.style.width="".concat(e,"px"))}},height:{default:window.innerHeight,triggerUpdate:!1,onChange:function(e,t){t.container&&(t.container.style.height="".concat(e,"px"))}},jsonUrl:{},graphData:{default:{nodes:[],links:[]}},numDimensions:{default:3},dagMode:{},dagLevelDistance:{},dagNodeFilter:{default:function(){return!0}},onDagError:{default:void 0},backgroundColor:{default:"#002"},showNavInfo:{default:!0},nodeRelSize:{default:4},nodeId:{default:"id"},nodeLabel:{default:"name"},nodeDesc:{default:"desc"},onNodeHover:{},onNodeClick:{},nodeVal:{default:"val"},nodeResolution:{default:8},nodeVisibility:{default:!0},nodeColor:{default:"color"},nodeAutoColorBy:{},nodeOpacity:{default:.75},nodeThreeObject:{},nodeThreeObjectExtend:{default:!1},linkSource:{default:"source"},linkTarget:{default:"target"},linkLabel:{default:"name"},linkDesc:{default:"desc"},onLinkHover:{},onLinkClick:{},linkVisibility:{default:!0},linkColor:{default:"color"},linkAutoColorBy:{},linkOpacity:{default:.2},linkWidth:{default:0},linkResolution:{default:6},linkCurvature:{default:0},linkCurveRotation:{default:0},linkMaterial:{},linkThreeObject:{},linkThreeObjectExtend:{default:!1},linkPositionUpdate:{},linkDirectionalArrowLength:{default:0},linkDirectionalArrowColor:{},linkDirectionalArrowRelPos:{default:.5},linkDirectionalArrowResolution:{default:8},linkDirectionalParticles:{default:0},linkDirectionalParticleSpeed:{default:.01},linkDirectionalParticleOffset:{default:0},linkDirectionalParticleWidth:{default:.5},linkDirectionalParticleColor:{},linkDirectionalParticleResolution:{default:4},linkDirectionalParticleThreeObject:{},forceEngine:{default:"d3"},d3AlphaMin:{default:0},d3AlphaDecay:{default:.0228},d3VelocityDecay:{default:.4},ngraphPhysics:{},warmupTicks:{default:0},cooldownTicks:{},cooldownTime:{default:15e3},onEngineTick:{},onEngineStop:{}},methods:o(o({},Object.assign.apply(Object,[{}].concat(a(["getGraphBbox","emitParticle","d3Force","d3ReheatSimulation","refresh"].map(function(e){return n({},e,function(t){for(var n=t.forcegraph.components.forcegraph,r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];var a=n[e].apply(n,o);return a===n?this:a})}))))),{},{_destructor:function(){this.graphData({nodes:[],links:[]})}}),init:function(e,t){e.innerHTML="",t.container=document.createElement("div"),e.appendChild(t.container),t.container.style.position="relative",t.container.style.width="".concat(t.width,"px"),t.container.style.height="".concat(t.height,"px"),t.container.appendChild(t.navInfo=document.createElement("div")),t.navInfo.className="graph-nav-info",t.navInfo.textContent="Mouse drag: look, gamepad/arrow/wasd keys: move";var r,o,i,s,c,l=document.createElement("a-scene");l.setAttribute("embedded",""),l.appendChild(t.sky=document.createElement("a-sky")),t.sky.setAttribute("radius",3e3),l.appendChild(r=document.createElement("a-entity")),r.setAttribute("position","0 0 300"),r.setAttribute("movement-controls","controls: gamepad, touch; fly: true; speed: 7"),r.appendChild(o=document.createElement("a-entity")),o.setAttribute("camera",""),o.setAttribute("position","0 0 0"),o.setAttribute("look-controls","pointerLockEnabled: false"),o.setAttribute("wasd-controls","fly: true; acceleration: 700"),o.appendChild(i=document.createElement("a-text")),i.setAttribute("position","0 -0.3 -1"),i.setAttribute("width",2),i.setAttribute("align","center"),i.setAttribute("color","lavender"),i.setAttribute("value",""),o.appendChild(s=document.createElement("a-text")),s.setAttribute("position","0 -0.4 -1"),s.setAttribute("width",1.3),s.setAttribute("align","center"),s.setAttribute("color","lavender"),s.setAttribute("value",""),t.raycasterEls=[],l.appendChild(c=document.createElement("a-entity")),c.setAttribute("cursor","rayOrigin: mouse; mouseCursorStylesEnabled: true"),c.setAttribute("raycaster","objects: [forcegraph]; interval: 100"),t.raycasterEls.push(c),["left","right"].forEach(function(e){var n;r.appendChild(n=document.createElement("a-entity")),n.setAttribute("laser-controls","hand: ".concat(e,"; model: false;")),n.setAttribute("raycaster","objects: [forcegraph]; interval: 100; lineColor: steelblue; lineOpacity: 0.85"),t.raycasterEls.push(n)}),l.appendChild(t.forcegraph=document.createElement("a-entity")),t.forcegraph.setAttribute("forcegraph",null),t.container.appendChild(l),t.forcegraph.setAttribute("forcegraph",Object.assign.apply(Object,a(["node","link"].map(function(e){var r={node:"Node",link:"Link"}[e];return n({},"on".concat(r,"Hover"),function(n,o){var a=n&&yo(t["".concat(e,"Label")])(n)||"",c=n&&yo(t["".concat(e,"Desc")])(n)||"";i.setAttribute("value",a),s.setAttribute("value",c),t["on".concat(r,"Hover")]&&t["on".concat(r,"Hover")](n,o)})}))))},update:function(e,t){if(t.hasOwnProperty("backgroundColor")){var r=Da(e.backgroundColor).alpha;void 0===r&&(r=1),e.sky.setAttribute("color",qa(1,e.backgroundColor)),e.sky.setAttribute("opacity",r)}t.hasOwnProperty("showNavInfo")&&(e.navInfo.style.display=e.showNavInfo?null:"none");var o=["onNodeHover","onLinkHover","onNodeClick","onLinkClick"].some(function(t){return e[t]})||["nodeLabel","linkLabel"].some(function(t){return"name"!==e[t]})||["nodeDesc","linkDesc"].some(function(t){return"desc"!==e[t]});e.raycasterEls.forEach(function(e){return e.setAttribute("raycaster",o?"objects: [forcegraph]; interval: 100":"objects: __none__")});var s=["jsonUrl","numDimensions","dagMode","dagLevelDistance","dagNodeFilter","onDagError","nodeRelSize","nodeId","onNodeClick","nodeVal","nodeResolution","nodeVisibility","nodeColor","nodeAutoColorBy","nodeOpacity","nodeThreeObject","nodeThreeObjectExtend","linkSource","linkTarget","onLinkClick","linkVisibility","linkColor","linkAutoColorBy","linkOpacity","linkWidth","linkResolution","linkCurvature","linkCurveRotation","linkMaterial","linkThreeObject","linkThreeObjectExtend","linkPositionUpdate","linkDirectionalArrowLength","linkDirectionalArrowColor","linkDirectionalArrowRelPos","linkDirectionalArrowResolution","linkDirectionalParticles","linkDirectionalParticleSpeed","linkDirectionalParticleOffset","linkDirectionalParticleWidth","linkDirectionalParticleColor","linkDirectionalParticleResolution","linkDirectionalParticleThreeObject","forceEngine","d3AlphaMin","d3AlphaDecay","d3VelocityDecay","ngraphPhysics","warmupTicks","cooldownTicks","cooldownTime","onEngineTick","onEngineStop"],c=Object.assign.apply(Object,[{}].concat(a(Object.entries(e).filter(function(e){var n=i(e,2),r=n[0],o=n[1];return t.hasOwnProperty(r)&&-1!==s.indexOf(r)&&null!=o}).map(function(e){var t=i(e,2);return n({},t[0],t[1])})),a(Object.entries(e.graphData).map(function(e){var t=i(e,2);return n({},t[0],t[1])}))));e.forcegraph.setAttribute("forcegraph",c)}});return $a});