react-force-graph-vr
Version:
React component for VR force directed graphs
2 lines • 522 kB
JavaScript
// Version 2.1.0 react-force-graph-vr - https://github.com/vasturiano/react-force-graph
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).ForceGraphVR=e(t.React)}(this,function(t){"use strict";function e(t,e,n){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,e);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function n(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o,s,a=[],h=!0,c=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;h=!1}else for(;!(h=(i=o.call(n)).done)&&(a.push(i.value),a.length!==e);h=!0);}catch(t){c=!0,r=t}finally{try{if(!h&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw r}}return a}}(t,e)||r(t,e)||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 i(t){return function(t){if(Array.isArray(t))return o(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||r(t)||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 r(t,e){if(t){if("string"==typeof t)return o(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(t,e):void 0}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function s(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}function a(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o,s,a=[],h=!0,c=!1;try{if(o=(n=n.call(t)).next,0===e);else for(;!(h=(i=o.call(n)).done)&&(a.push(i.value),a.length!==e);h=!0);}catch(t){c=!0,r=t}finally{try{if(!h&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw r}}return a}}(t,e)||c(t,e)||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 h(t){return function(t){if(Array.isArray(t))return s(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||c(t)||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 c(t,e){if(t){if("string"==typeof t)return s(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(t,e):void 0}}function l(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.useEffect,i=t.useRef(),r=t.useRef(!1),o=t.useRef(!1),s=a(t.useState(0),2);s[0];var h=s[1];r.current&&(o.current=!0),n(function(){return r.current||(i.current=e(),r.current=!0),h(function(t){return t+1}),function(){o.current&&i.current&&i.current()}},[])}function u(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function d(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if("function"==typeof e){var n=function t(){var n=!1;try{n=this instanceof t}catch{}return n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(e){var i=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,i.get?i:{enumerable:!0,get:function(){return t[e]}})}),n}var p,f,m,y,g,v,b,x={};function w(){return m?f:(m=1,f=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 M(){if(b)return v;b=1;const t=w(),e=(g||(g=1,y=function(t,e,n){this.type=t,this.index=e,this.pressed=n.pressed,this.value=n.value}),y),n=.2,i="left",r="right",o=1,s=2;return v=AFRAME.registerComponent("gamepad-controls",{GamepadButton:t,schema:{enabled:{default:!0},rotationSensitivity:{default:2}},init:function(){const t=this.el.sceneEl;this.system=t.systems["tracked-controls"]||t.systems["tracked-controls-webxr"]||{controllers:[]},this.prevTime=window.performance.now(),this.buttons={};const e=this.el.object3D.rotation;this.pitch=new THREE.Object3D,this.pitch.rotation.x=e.x,this.yaw=new THREE.Object3D,this.yaw.position.y=10,this.yaw.rotation.y=e.y,this.yaw.add(this.pitch),this._lookVector=new THREE.Vector2,this._moveVector=new THREE.Vector2,this._dpadVector=new THREE.Vector2,t.addBehavior(this)},update:function(){this.tick()},tick:function(t,e){this.updateButtonState(),this.updateRotation(e)},remove:function(){},isVelocityActive:function(){if(!this.data.enabled||!this.isConnected())return!1;const t=this._dpadVector,e=this._moveVector;this.getDpad(t),this.getJoystick(o,e);const i=t.x||e.x,r=t.y||e.y;return Math.abs(i)>n||Math.abs(r)>n},getVelocityDelta:function(){const t=this._dpadVector,e=this._moveVector;this.getDpad(t),this.getJoystick(o,e);const i=t.x||e.x,r=t.y||e.y,s=new THREE.Vector3;return Math.abs(i)>n&&(s.x+=i),Math.abs(r)>n&&(s.z+=r),s},isRotationActive:function(){if(!this.data.enabled||!this.isConnected())return!1;const t=this._lookVector;return this.getJoystick(s,t),Math.abs(t.x)>n||Math.abs(t.y)>n},updateRotation:function(t){if(!this.isRotationActive())return;const e=this.data,i=this.yaw,r=this.pitch;i.rotation.y=this.el.object3D.rotation.y,r.rotation.x=this.el.object3D.rotation.x;const o=this._lookVector;this.getJoystick(s,o),Math.abs(o.x)<=n&&(o.x=0),Math.abs(o.y)<=n&&(o.y=0),o.multiplyScalar(e.rotationSensitivity*t/1e3),i.rotation.y-=o.x,r.rotation.x-=o.y,r.rotation.x=Math.max(-Math.PI/2,Math.min(Math.PI/2,r.rotation.x)),this.el.object3D.rotation.set(r.rotation.x,i.rotation.y,0)},updateButtonState:function(){const t=this.getGamepad(r);if(this.data.enabled&&t)for(var n=0;n<t.buttons.length;n++)t.buttons[n].pressed&&!this.buttons[n]?this.emit(new e("gamepadbuttondown",n,t.buttons[n])):!t.buttons[n].pressed&&this.buttons[n]&&this.emit(new e("gamepadbuttonup",n,t.buttons[n])),this.buttons[n]=t.buttons[n].pressed;else for(const t in this.buttons)this.buttons[t]=!1},emit:function(t){this.el.emit(t.type,t),this.el.emit(t.type+":"+t.index,new e(t.type,t.index,t))},getGamepad:function(){const t=[],e=[];return function(n){const i=this.el.sceneEl.components["proxy-controls"],r=i&&i.isConnected()&&i.getGamepad(0);if(r)return r;t.length=0;for(let e=0;e<this.system.controllers.length;e++){const i=this.system.controllers[e],r=i?i.gamepad:null;if(t.push(r),r&&i.handedness===n)return r}const o=navigator.getGamepads?navigator.getGamepads():e;for(let t=0;t<o.length;t++){const e=o[t];if(e&&e.hand===n)return e}return t[0]||o[0]}}(),getButton:function(t){return this.getGamepad(r).buttons[t]},getAxis:function(t){return this.getGamepad(t>1?r:i).axes[t]},getJoystick:function(t,e){const n=this.getGamepad(t===o?i:r);if(!n)return e.set(0,0);if("xr-standard"===n.mapping)switch(t){case o:return e.set(n.axes[2],n.axes[3]);case s:return e.set(n.axes[2],0)}else switch(t){case o:return e.set(n.axes[0],n.axes[1]);case s:return e.set(n.axes[2],n.axes[3])}throw new Error('Unexpected joystick index "%d".',t)},getDpad:function(e){const n=this.getGamepad(i);return n&&n.buttons[t.DPAD_RIGHT]?e.set((n.buttons[t.DPAD_RIGHT].pressed?1:0)+(n.buttons[t.DPAD_LEFT].pressed?-1:0),(n.buttons[t.DPAD_UP].pressed?-1:0)+(n.buttons[t.DPAD_DOWN].pressed?1:0)):e.set(0,0)},isConnected:function(){const t=this.getGamepad(i);return!(!t||!t.connected)},getID:function(){return this.getGamepad(i).id}}),v}var k,_,A,E,S,T,O,C={};function N(){return k||(k=1,function(t){var e="KeyboardEvent"in t;e||(t.KeyboardEvent=function(){throw TypeError("Illegal constructor")}),"DOM_KEY_LOCATION_STANDARD"in t.KeyboardEvent||(t.KeyboardEvent.DOM_KEY_LOCATION_STANDARD=0),"DOM_KEY_LOCATION_LEFT"in t.KeyboardEvent||(t.KeyboardEvent.DOM_KEY_LOCATION_LEFT=1),"DOM_KEY_LOCATION_RIGHT"in t.KeyboardEvent||(t.KeyboardEvent.DOM_KEY_LOCATION_RIGHT=2),"DOM_KEY_LOCATION_NUMPAD"in t.KeyboardEvent||(t.KeyboardEvent.DOM_KEY_LOCATION_NUMPAD=3);var n=window.KeyboardEvent.DOM_KEY_LOCATION_STANDARD,i=window.KeyboardEvent.DOM_KEY_LOCATION_LEFT,r=window.KeyboardEvent.DOM_KEY_LOCATION_RIGHT,o=window.KeyboardEvent.DOM_KEY_LOCATION_NUMPAD;function s(t,e){return-1!==String(t).indexOf(e)}var a=s(navigator.platform,"Win")?"win":s(navigator.platform,"Mac")?"mac":s(navigator.platform,"CrOS")?"cros":s(navigator.platform,"Linux")?"linux":s(navigator.userAgent,"iPad")||s(navigator.platform,"iPod")||s(navigator.platform,"iPhone")?"ios":"",h=s(navigator.userAgent,"Chrome/")?"chrome":s(navigator.vendor,"Apple")?"safari":s(navigator.userAgent,"MSIE")?"ie":s(navigator.userAgent,"Gecko/")?"moz":s(navigator.userAgent,"Opera/")?"opera":"",c=h+"-"+a;function l(t,e,n){c!==e&&h!==e&&a!==e||Object.keys(n).forEach(function(e){t[e]=n[e]})}var u={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:i},92:{code:"OSRight",location:r},93:{code:"ContextMenu"},95:{code:"Standby"},96:{code:"Numpad0",keyCap:"0",location:o},97:{code:"Numpad1",keyCap:"1",location:o},98:{code:"Numpad2",keyCap:"2",location:o},99:{code:"Numpad3",keyCap:"3",location:o},100:{code:"Numpad4",keyCap:"4",location:o},101:{code:"Numpad5",keyCap:"5",location:o},102:{code:"Numpad6",keyCap:"6",location:o},103:{code:"Numpad7",keyCap:"7",location:o},104:{code:"Numpad8",keyCap:"8",location:o},105:{code:"Numpad9",keyCap:"9",location:o},106:{code:"NumpadMultiply",keyCap:"*",location:o},107:{code:"NumpadAdd",keyCap:"+",location:o},108:{code:"NumpadComma",keyCap:",",location:o},109:{code:"NumpadSubtract",keyCap:"-",location:o},110:{code:"NumpadDecimal",keyCap:".",location:o},111:{code:"NumpadDivide",keyCap:"/",location:o},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:o},145:{code:"ScrollLock"},160:{code:"ShiftLeft",location:i},161:{code:"ShiftRight",location:r},162:{code:"ControlLeft",location:i},163:{code:"ControlRight",location:r},164:{code:"AltLeft",location:i},165:{code:"AltRight",location:r},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"}};l(u,"moz",{59:{code:"Semicolon",keyCap:";"},61:{code:"Equal",keyCap:"="},107:{code:"Equal",keyCap:"="},109:{code:"Minus",keyCap:"-"},187:{code:"NumpadAdd",keyCap:"+",location:o},189:{code:"NumpadSubtract",keyCap:"-",location:o}}),l(u,"moz-mac",{12:{code:"NumLock",location:o},173:{code:"Minus",keyCap:"-"}}),l(u,"moz-win",{173:{code:"Minus",keyCap:"-"}}),l(u,"chrome-mac",{93:{code:"OSRight",location:r}}),l(u,"safari",{3:{code:"Enter"},25:{code:"Tab"}}),l(u,"ios",{10:{code:"Enter",location:n}}),l(u,"safari-mac",{91:{code:"OSLeft",location:i},93:{code:"OSRight",location:r},229:{code:"KeyQ",keyCap:"Q"}});var d={};"cros"===a&&(d["U+00A0"]={code:"ShiftLeft",location:i},d["U+00A1"]={code:"ShiftRight",location:r},d["U+00A2"]={code:"ControlLeft",location:i},d["U+00A3"]={code:"ControlRight",location:r},d["U+00A4"]={code:"AltLeft",location:i},d["U+00A5"]={code:"AltRight",location:r}),"chrome-mac"===c&&(d["U+0010"]={code:"ContextMenu"}),"safari-mac"===c&&(d["U+0010"]={code:"ContextMenu"}),"ios"===a&&(d["U+0010"]={code:"Function"},d["U+001C"]={code:"ArrowLeft"},d["U+001D"]={code:"ArrowRight"},d["U+001E"]={code:"ArrowUp"},d["U+001F"]={code:"ArrowDown"},d["U+0001"]={code:"Home"},d["U+0004"]={code:"End"},d["U+000B"]={code:"PageUp"},d["U+000C"]={code:"PageDown"});var p=[];p[i]={16:{code:"ShiftLeft",location:i},17:{code:"ControlLeft",location:i},18:{code:"AltLeft",location:i}},p[r]={16:{code:"ShiftRight",location:r},17:{code:"ControlRight",location:r},18:{code:"AltRight",location:r}},p[o]={13:{code:"NumpadEnter",location:o}},l(p[o],"moz",{109:{code:"NumpadSubtract",location:o},107:{code:"NumpadAdd",location:o}}),l(p[i],"moz-mac",{224:{code:"OSLeft",location:i}}),l(p[r],"moz-mac",{224:{code:"OSRight",location:r}}),l(p[r],"moz-win",{91:{code:"OSRight",location:r}}),l(p[r],"mac",{93:{code:"OSRight",location:r}}),l(p[o],"chrome-mac",{12:{code:"NumLock",location:o}}),l(p[o],"safari-mac",{12:{code:"NumLock",location:o},187:{code:"NumpadAdd",location:o},189:{code:"NumpadSubtract",location:o},190:{code:"NumpadDecimal",location:o},191:{code:"NumpadDivide",location:o}});var f={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:"|"}};l(f,"mac",{OSLeft:{key:"Meta"},OSRight:{key:"Meta"}});var m,y,g,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=(m=u,y="code",g={},Object.keys(m).forEach(function(t){var e=m[t];y in e&&(g[e[y]]=e)}),g);try{var x=e&&"location"in new KeyboardEvent("")}catch(t){}function w(t){var e="keyCode"in t?t.keyCode:"which"in t?t.which:0,n=function(){if(x||"keyLocation"in t){var n=x?t.location:t.keyLocation;if(n&&e in p[n])return p[n][e]}return"keyIdentifier"in t&&t.keyIdentifier in d?d[t.keyIdentifier]:e in u?u[e]:null}();if(!n)return null;var i,r=(i=f[n.code])?t.shiftKey&&"shiftKey"in i?i.shiftKey:i.key:n.code;return{code:n.code,key:r,location:n.location,keyCap:n.keyCap}}"KeyboardEvent"in t&&"defineProperty"in Object&&function(){function t(t,e,n){e in t||Object.defineProperty(t,e,n)}if(t(KeyboardEvent.prototype,"code",{get:function(){var t=w(this);return t?t.code:""}}),"key"in KeyboardEvent.prototype){var e=Object.getOwnPropertyDescriptor(KeyboardEvent.prototype,"key");Object.defineProperty(KeyboardEvent.prototype,"key",{get:function(){var t=e.get.call(this);return v.hasOwnProperty(t)?v[t]:t}})}t(KeyboardEvent.prototype,"key",{get:function(){var t=w(this);return t&&"key"in t?t.key:"Unidentified"}}),t(KeyboardEvent.prototype,"location",{get:function(){var t=w(this);return t&&"location"in t?t.location:n}}),t(KeyboardEvent.prototype,"locale",{get:function(){return""}})}(),"queryKeyCap"in t.KeyboardEvent||(t.KeyboardEvent.queryKeyCap=function(t,e){if(t=String(t),!b.hasOwnProperty(t))return"Undefined";if(e&&"en-us"!==String(e).toLowerCase())throw Error("Unsupported locale");var n=b[t];return n.keyCap||n.code||"Undefined"}),t.identifyKey=function(t){if(!("code"in t)){var e=w(t);t.code=e?e.code:"",t.key=e&&"key"in e?e.key:"Unidentified",t.location="location"in t?t.location:"keyLocation"in t?t.keyLocation:e&&"location"in e?e.location:n,t.locale=""}}}(window)),C}const z=(t,e)=>{const n=e.x-t.x,i=e.y-t.y;return Math.sqrt(n*n+i*i)},P=t=>t*(Math.PI/180),I=t=>t*(180/Math.PI),R=new Map,D=t=>{R.has(t)&&clearTimeout(R.get(t)),R.set(t,setTimeout(t,100))},j=(t,e,n)=>{const i=e.split(/[ ,]+/g);let r;for(let e=0;e<i.length;e+=1)r=i[e],t.addEventListener?t.addEventListener(r,n,!1):t.attachEvent&&t.attachEvent(r,n)},L=(t,e,n)=>{const i=e.split(/[ ,]+/g);let r;for(let e=0;e<i.length;e+=1)r=i[e],t.removeEventListener?t.removeEventListener(r,n):t.detachEvent&&t.detachEvent(r,n)},F=t=>(t.preventDefault(),t.type.match(/^touch/)?t.changedTouches:t),B=()=>({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}),V=(t,e)=>{e.top||e.right||e.bottom||e.left?(t.style.top=e.top,t.style.right=e.right,t.style.bottom=e.bottom,t.style.left=e.left):(t.style.left=e.x+"px",t.style.top=e.y+"px")},U=(t,e,n)=>{const i=H(t);for(let t in i)if(i.hasOwnProperty(t))if("string"==typeof e)i[t]=e+" "+n;else{let r="";for(let t=0,i=e.length;t<i;t+=1)r+=e[t]+" "+n+", ";i[t]=r.slice(0,-2)}return i},H=t=>{const e={};e[t]="";return["webkit","Moz","o"].forEach(function(n){e[n+t.charAt(0).toUpperCase()+t.slice(1)]=""}),e},q=(t,e)=>{for(let n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t},W=(t,e)=>{if(t.length)for(let n=0,i=t.length;n<i;n+=1)e(t[n]);else e(t)};var G,J=!!("ontouchstart"in window),K=!!window.PointerEvent,$=!!window.MSPointerEvent,X={start:"mousedown",move:"mousemove",end:"mouseup"},Z={};function Y(){}function Q(t,e){return this.identifier=e.identifier,this.position=e.position,this.frontPosition=e.frontPosition,this.collection=t,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(e),"dynamic"===this.options.mode&&(this.options.restOpacity=0),this.id=Q.id,Q.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 tt(t,e){var n=this;n.nipples=[],n.idles=[],n.actives=[],n.ids=[],n.pressureIntervals={},n.manager=t,n.id=tt.id,tt.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(e),"static"!==n.options.mode&&"semi"!==n.options.mode||(n.options.multitouch=!1),n.options.multitouch||(n.options.maxNumberOfNipples=1);const i=getComputedStyle(n.options.zone.parentElement);return i&&"flex"===i.display&&(n.parentIsFlex=!0),n.updateBox(),n.prepareNipples(),n.bindings(),n.begin(),n.nipples}function et(t){var e=this;e.ids={},e.index=0,e.collections=[],e.scroll=B(),e.config(t),e.prepareCollections();var n=function(){var t;e.collections.forEach(function(n){n.forEach(function(n){t=n.el.getBoundingClientRect(),n.position={x:e.scroll.x+t.left,y:e.scroll.y+t.top}})})};j(window,"resize",function(){D(n)});var i=function(){e.scroll=B()};return j(window,"scroll",function(){D(i)}),e.collections}K?G={start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"}:$?G={start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}:J?(G={start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},Z=X):G=X,Y.prototype.on=function(t,e){var n,i=this,r=t.split(/[ ,]+/g);i._handlers_=i._handlers_||{};for(var o=0;o<r.length;o+=1)n=r[o],i._handlers_[n]=i._handlers_[n]||[],i._handlers_[n].push(e);return i},Y.prototype.off=function(t,e){var n=this;return n._handlers_=n._handlers_||{},void 0===t?n._handlers_={}:void 0===e?n._handlers_[t]=null:n._handlers_[t]&&n._handlers_[t].indexOf(e)>=0&&n._handlers_[t].splice(n._handlers_[t].indexOf(e),1),n},Y.prototype.trigger=function(t,e){var n,i=this,r=t.split(/[ ,]+/g);i._handlers_=i._handlers_||{};for(var o=0;o<r.length;o+=1)n=r[o],i._handlers_[n]&&i._handlers_[n].length&&i._handlers_[n].forEach(function(t){t.call(i,{type:n,target:i},e)})},Y.prototype.config=function(t){var e=this;e.options=e.defaults||{},t&&(e.options=((t,e)=>{const n={};for(let i in t)t.hasOwnProperty(i)&&e.hasOwnProperty(i)?n[i]=e[i]:t.hasOwnProperty(i)&&(n[i]=t[i]);return n})(e.options,t))},Y.prototype.bindEvt=function(t,e){var n=this;return n._domHandlers_=n._domHandlers_||{},n._domHandlers_[e]=function(){"function"==typeof n["on"+e]?n["on"+e].apply(n,arguments):console.warn('[WARNING] : Missing "on'+e+'" handler.')},j(t,G[e],n._domHandlers_[e]),Z[e]&&j(t,Z[e],n._domHandlers_[e]),n},Y.prototype.unbindEvt=function(t,e){var n=this;return n._domHandlers_=n._domHandlers_||{},L(t,G[e],n._domHandlers_[e]),Z[e]&&L(t,Z[e],n._domHandlers_[e]),delete n._domHandlers_[e],this},Q.prototype=new Y,Q.constructor=Q,Q.id=0,Q.prototype.buildEl=function(t){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},Q.prototype.stylize=function(){if(this.options.dataOnly)return this;var t=this.options.fadeTime+"ms",e=((t,e)=>{const n=H(t);for(let t in n)n.hasOwnProperty(t)&&(n[t]=e);return n})("borderRadius","50%"),n=U("transition","opacity",t),i={};return i.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},i.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"},i.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)"},q(i.el,n),"circle"===this.options.shape&&q(i.back,e),q(i.front,e),this.applyStyles(i),this},Q.prototype.applyStyles=function(t){for(var e in this.ui)if(this.ui.hasOwnProperty(e))for(var n in t[e])this.ui[e].style[n]=t[e][n];return this},Q.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)||this.options.zone.appendChild(this.ui.el),this},Q.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)||this.options.zone.removeChild(this.ui.el),this},Q.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()},Q.prototype.show=function(t){var e=this;return e.options.dataOnly||(clearTimeout(e.removeTimeout),clearTimeout(e.showTimeout),clearTimeout(e.restTimeout),e.addToDom(),e.restCallback(),setTimeout(function(){e.ui.el.style.opacity=1},0),e.showTimeout=setTimeout(function(){e.trigger("shown",e.instance),"function"==typeof t&&t.call(this)},e.options.fadeTime)),e},Q.prototype.hide=function(t){var e=this;if(e.options.dataOnly)return e;if(e.ui.el.style.opacity=e.options.restOpacity,clearTimeout(e.removeTimeout),clearTimeout(e.showTimeout),clearTimeout(e.restTimeout),e.removeTimeout=setTimeout(function(){var n="dynamic"===e.options.mode?"none":"block";e.ui.el.style.display=n,"function"==typeof t&&t.call(e),e.trigger("hidden",e.instance)},e.options.fadeTime),e.options.restJoystick){const n=e.options.restJoystick,i={};i.x=!0===n||!1!==n.x?0:e.instance.frontPosition.x,i.y=!0===n||!1!==n.y?0:e.instance.frontPosition.y,e.setPosition(t,i)}return e},Q.prototype.setPosition=function(t,e){var n=this;n.frontPosition={x:e.x,y:e.y};var i=n.options.fadeTime+"ms",r={};r.front=U("transition",["transform"],i);var o={front:{}};o.front={transform:"translate("+n.frontPosition.x+"px,"+n.frontPosition.y+"px)"},n.applyStyles(r),n.applyStyles(o),n.restTimeout=setTimeout(function(){"function"==typeof t&&t.call(n),n.restCallback()},n.options.fadeTime)},Q.prototype.restCallback=function(){var t=this,e={};e.front=U("transition","none",""),t.applyStyles(e),t.trigger("rested",t.instance)},Q.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}},Q.prototype.computeDirection=function(t){var e,n,i,r=t.angle.radian,o=Math.PI/4,s=Math.PI/2;if(r>o&&r<3*o&&!t.lockX?e="up":r>-o&&r<=o&&!t.lockY?e="left":r>3*-o&&r<=-o&&!t.lockX?e="down":t.lockY||(e="right"),t.lockY||(n=r>-s&&r<s?"left":"right"),t.lockX||(i=r>0?"up":"down"),t.force>this.options.threshold){var a,h={};for(a in this.direction)this.direction.hasOwnProperty(a)&&(h[a]=this.direction[a]);var c={};for(a in this.direction={x:n,y:i,angle:e},t.direction=this.direction,h)h[a]===this.direction[a]&&(c[a]=!0);if(c.x&&c.y&&c.angle)return t;c.x&&c.y||this.trigger("plain",t),c.x||this.trigger("plain:"+n,t),c.y||this.trigger("plain:"+i,t),c.angle||this.trigger("dir dir:"+e,t)}else this.resetDirection();return t},tt.prototype=new Y,tt.constructor=tt,tt.id=0,tt.prototype.prepareNipples=function(){var t=this,e=t.nipples;e.on=t.on.bind(t),e.off=t.off.bind(t),e.options=t.options,e.destroy=t.destroy.bind(t),e.ids=t.ids,e.id=t.id,e.processOnMove=t.processOnMove.bind(t),e.processOnEnd=t.processOnEnd.bind(t),e.get=function(t){if(void 0===t)return e[0];for(var n=0,i=e.length;n<i;n+=1)if(e[n].identifier===t)return e[n];return!1}},tt.prototype.bindings=function(){var t=this;t.bindEvt(t.options.zone,"start"),t.options.zone.style.touchAction="none",t.options.zone.style.msTouchAction="none"},tt.prototype.begin=function(){var t=this,e=t.options;if("static"===e.mode){var n=t.createNipple(e.position,t.manager.getIdentifier());n.add(),t.idles.push(n)}},tt.prototype.createNipple=function(t,e){var n=this,i=n.manager.scroll,r={},o=n.options,s=n.parentIsFlex?i.x:i.x+n.box.left,a=n.parentIsFlex?i.y:i.y+n.box.top;if(t.x&&t.y)r={x:t.x-s,y:t.y-a};else if(t.top||t.right||t.bottom||t.left){var h=document.createElement("DIV");h.style.display="hidden",h.style.top=t.top,h.style.right=t.right,h.style.bottom=t.bottom,h.style.left=t.left,h.style.position="absolute",o.zone.appendChild(h);var c=h.getBoundingClientRect();o.zone.removeChild(h),r=t,t={x:c.left+i.x,y:c.top+i.y}}var l=new Q(n,{color:o.color,size:o.size,threshold:o.threshold,fadeTime:o.fadeTime,dataOnly:o.dataOnly,restJoystick:o.restJoystick,restOpacity:o.restOpacity,mode:o.mode,identifier:e,position:t,zone:o.zone,frontPosition:{x:0,y:0},shape:o.shape});return o.dataOnly||(V(l.ui.el,r),V(l.ui.front,l.frontPosition)),n.nipples.push(l),n.trigger("added "+l.identifier+":added",l),n.manager.trigger("added "+l.identifier+":added",l),n.bindNipple(l),l},tt.prototype.updateBox=function(){this.box=this.options.zone.getBoundingClientRect()},tt.prototype.bindNipple=function(t){var e,n=this,i=function(t,i){e=t.type+" "+i.id+":"+t.type,n.trigger(e,i)};t.on("destroyed",n.onDestroyed.bind(n)),t.on("shown hidden rested dir plain",i),t.on("dir:up dir:right dir:down dir:left",i),t.on("plain:up plain:right plain:down plain:left",i)},tt.prototype.pressureFn=function(t,e,n){var i=this,r=0;clearInterval(i.pressureIntervals[n]),i.pressureIntervals[n]=setInterval(function(){var n=t.force||t.pressure||t.webkitForce||0;n!==r&&(e.trigger("pressure",n),i.trigger("pressure "+e.identifier+":pressure",n),r=n)}.bind(i),100)},tt.prototype.onstart=function(t){var e=this,n=e.options,i=t;t=F(t),e.updateBox();return W(t,function(r){e.actives.length<n.maxNumberOfNipples?e.processOnStart(r):i.type.match(/^touch/)&&(Object.keys(e.manager.ids).forEach(function(n){if(Object.values(i.touches).findIndex(function(t){return t.identifier===n})<0){var r=[t[0]];r.identifier=n,e.processOnEnd(r)}}),e.actives.length<n.maxNumberOfNipples&&e.processOnStart(r))}),e.manager.bindDocument(),!1},tt.prototype.processOnStart=function(t){var e,n=this,i=n.options,r=n.manager.getIdentifier(t),o=t.force||t.pressure||t.webkitForce||0,s={x:t.pageX,y:t.pageY},a=n.getOrCreate(r,s);a.identifier!==r&&n.manager.removeIdentifier(a.identifier),a.identifier=r;var h=function(e){e.trigger("start",e),n.trigger("start "+e.id+":start",e),e.show(),o>0&&n.pressureFn(t,e,e.identifier),n.processOnMove(t)};if((e=n.idles.indexOf(a))>=0&&n.idles.splice(e,1),n.actives.push(a),n.ids.push(a.identifier),"semi"!==i.mode)h(a);else{if(!(z(s,a.position)<=i.catchDistance))return a.destroy(),void n.processOnStart(t);h(a)}return a},tt.prototype.getOrCreate=function(t,e){var n,i=this,r=i.options;return/(semi|static)/.test(r.mode)?(n=i.idles[0])?(i.idles.splice(0,1),n):"semi"===r.mode?i.createNipple(e,t):(console.warn("Coudln't find the needed nipple."),!1):n=i.createNipple(e,t)},tt.prototype.processOnMove=function(t){var e=this,n=e.options,i=e.manager.getIdentifier(t),r=e.nipples.get(i),o=e.manager.scroll;if((t=>isNaN(t.buttons)?0!==t.pressure:0!==t.buttons)(t)){if(!r)return console.error("Found zombie joystick with ID "+i),void e.manager.removeIdentifier(i);if(n.dynamicPage){var s=r.el.getBoundingClientRect();r.position={x:o.x+s.left,y:o.y+s.top}}r.identifier=i;var a=r.options.size/2,h={x:t.pageX,y:t.pageY};n.lockX&&(h.y=r.position.y),n.lockY&&(h.x=r.position.x);var c,l,u=z(h,r.position),d=((t,e)=>{const n=e.x-t.x,i=e.y-t.y;return I(Math.atan2(i,n))})(h,r.position),p=P(d),f=u/a,m={distance:u,position:h};if("circle"===r.options.shape?(c=Math.min(u,a),l=((t,e,n)=>{const i={x:0,y:0};return n=P(n),i.x=t.x-e*Math.cos(n),i.y=t.y-e*Math.sin(n),i})(r.position,c,d)):(l=((t,e,n)=>({x:Math.min(Math.max(t.x,e.x-n),e.x+n),y:Math.min(Math.max(t.y,e.y-n),e.y+n)}))(h,r.position,a),c=z(l,r.position)),n.follow){if(u>a){let t=h.x-l.x,n=h.y-l.y;r.position.x+=t,r.position.y+=n,r.el.style.top=r.position.y-(e.box.top+o.y)+"px",r.el.style.left=r.position.x-(e.box.left+o.x)+"px",u=z(h,r.position)}}else h=l,u=c;var y=h.x-r.position.x,g=h.y-r.position.y;r.frontPosition={x:y,y:g},n.dataOnly||(r.ui.front.style.transform="translate("+y+"px,"+g+"px)");var v={identifier:r.identifier,position:h,force:f,pressure:t.force||t.pressure||t.webkitForce||0,distance:u,angle:{radian:p,degree:d},vector:{x:y/a,y:-g/a},raw:m,instance:r,lockX:n.lockX,lockY:n.lockY};(v=r.computeDirection(v)).angle={radian:P(180-d),degree:180-d},r.trigger("move",v),e.trigger("move "+r.id+":move",v)}else this.processOnEnd(t)},tt.prototype.processOnEnd=function(t){var e=this,n=e.options,i=e.manager.getIdentifier(t),r=e.nipples.get(i),o=e.manager.removeIdentifier(r.identifier);r&&(n.dataOnly||r.hide(function(){"dynamic"===n.mode&&(r.trigger("removed",r),e.trigger("removed "+r.id+":removed",r),e.manager.trigger("removed "+r.id+":removed",r),r.destroy())}),clearInterval(e.pressureIntervals[r.identifier]),r.resetDirection(),r.trigger("end",r),e.trigger("end "+r.id+":end",r),e.ids.indexOf(r.identifier)>=0&&e.ids.splice(e.ids.indexOf(r.identifier),1),e.actives.indexOf(r)>=0&&e.actives.splice(e.actives.indexOf(r),1),/(semi|static)/.test(n.mode)?e.idles.push(r):e.nipples.indexOf(r)>=0&&e.nipples.splice(e.nipples.indexOf(r),1),e.manager.unbindDocument(),/(semi|static)/.test(n.mode)&&(e.manager.ids[o.id]=o.identifier))},tt.prototype.onDestroyed=function(t,e){var n=this;n.nipples.indexOf(e)>=0&&n.nipples.splice(n.nipples.indexOf(e),1),n.actives.indexOf(e)>=0&&n.actives.splice(n.actives.indexOf(e),1),n.idles.indexOf(e)>=0&&n.idles.splice(n.idles.indexOf(e),1),n.ids.indexOf(e.identifier)>=0&&n.ids.splice(n.ids.indexOf(e.identifier),1),n.manager.removeIdentifier(e.identifier),n.manager.unbindDocument()},tt.prototype.destroy=function(){var t=this;for(var e in t.unbindEvt(t.options.zone,"start"),t.nipples.forEach(function(t){t.destroy()}),t.pressureIntervals)t.pressureIntervals.hasOwnProperty(e)&&clearInterval(t.pressureIntervals[e]);t.trigger("destroyed",t.nipples),t.manager.unbindDocument(),t.off()},et.prototype=new Y,et.constructor=et,et.prototype.prepareCollections=function(){var t=this;t.collections.create=t.create.bind(t),t.collections.on=t.on.bind(t),t.collections.off=t.off.bind(t),t.collections.destroy=t.destroy.bind(t),t.collections.get=function(e){var n;return t.collections.every(function(t){return!(n=t.get(e))}),n}},et.prototype.create=function(t){return this.createCollection(t)},et.prototype.createCollection=function(t){var e=this,n=new tt(e,t);return e.bindCollection(n),e.collections.push(n),n},et.prototype.bindCollection=function(t){var e,n=this,i=function(t,i){e=t.type+" "+i.id+":"+t.type,n.trigger(e,i)};t.on("destroyed",n.onDestroyed.bind(n)),t.on("shown hidden rested dir plain",i),t.on("dir:up dir:right dir:down dir:left",i),t.on("plain:up plain:right plain:down plain:left",i)},et.prototype.bindDocument=function(){var t=this;t.binded||(t.bindEvt(document,"move").bindEvt(document,"end"),t.binded=!0)},et.prototype.unbindDocument=function(t){var e=this;Object.keys(e.ids).length&&!0!==t||(e.unbindEvt(document,"move").unbindEvt(document,"end"),e.binded=!1)},et.prototype.getIdentifier=function(t){var e;return t?void 0===(e=void 0===t.identifier?t.pointerId:t.identifier)&&(e=this.latest||0):e=this.index,void 0===this.ids[e]&&(this.ids[e]=this.index,this.index+=1),this.latest=e,this.ids[e]},et.prototype.removeIdentifier=function(t){var e={};for(var n in this.ids)if(this.ids[n]===t){e.id=n,e.identifier=this.ids[n],delete this.ids[n];break}return e},et.prototype.onmove=function(t){return this.onAny("move",t),!1},et.prototype.onend=function(t){return this.onAny("end",t),!1},et.prototype.oncancel=function(t){return this.onAny("end",t),!1},et.prototype.onAny=function(t,e){var n,i=this,r="processOn"+t.charAt(0).toUpperCase()+t.slice(1);e=F(e);var o=function(t,e,n){n.ids.indexOf(e)>=0&&(n[r](t),t._found_=!0)};return W(e,function(t){n=i.getIdentifier(t),W(i.collections,o.bind(null,t,n)),t._found_||i.removeIdentifier(n)}),!1},et.prototype.destroy=function(){var t=this;t.unbindDocument(!0),t.ids={},t.index=0,t.collections.forEach(function(t){t.destroy()}),t.off()},et.prototype.onDestroyed=function(t,e){var n=this;if(n.collections.indexOf(e)<0)return!1;n.collections.splice(n.collections.indexOf(e),1)};const nt=new et;var it,rt=function(t){return nt.create(t)};function ot(){return it||(it=1,p||(p=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(t){const e=this.el;this.active&&this.checkpoint!==t&&(this.checkpoint&&e.emit("navigation-end",{checkpoint:this.checkpoint}),this.checkpoint=t,this.sync(),this.position.distanceTo(this.targetPosition)<.1?this.checkpoint=null:(e.emit("navigation-start",{checkpoint:t}),"teleport"===this.data.mode&&(this.el.setAttribute("position",this.targetPosition),this.checkpoint=null,e.emit("navigation-end",{checkpoint:t}),e.components["movement-controls"].updateNavLocation())))},isVelocityActive:function(){return!(!this.active||!this.checkpoint)},getVelocity:function(){if(!this.active)return;const t=this.data,e=this.offset,n=this.position,i=this.targetPosition,r=this.checkpoint;return this.sync(),n.distanceTo(i)<.1?(this.checkpoint=null,this.el.emit("navigation-end",{checkpoint:r}),e.set(0,0,0)):(e.setLength(t.animateSpeed),e)},sync:function(){const t=this.offset,e=this.position,n=this.targetPosition;e.copy(this.el.getAttribute("position")),this.checkpoint.object3D.getWorldPosition(n),n.add(this.checkpoint.components.checkpoint.getOffset()),t.copy(n).sub(e)}})),M(),function(){if(A)return _;A=1,N();const t=window.KeyboardEvent;_=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 t=this.data,e=this.getKeys();return this.dVelocity.set(0,0,0),t.enabled&&((e.KeyW||e.ArrowUp)&&(this.dVelocity.z-=1),(e.KeyA||e.ArrowLeft)&&(this.dVelocity.x-=1),(e.KeyS||e.ArrowDown)&&(this.dVelocity.z+=1),(e.KeyD||e.ArrowRight)&&(this.dVelocity.x+=1),e.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 t in this.localKeys)this.localKeys.hasOwnProperty(t)&&delete this.localKeys[t]},removeEventListeners:function(){window.removeEventListener("keydown",this.listeners.keydown),window.removeEventListener("keyup",this.listeners.keyup),window.removeEventListener("blur",this.listeners.blur)},onKeyDown:function(t){AFRAME.utils.shouldCaptureKeyEvent(t)&&(this.localKeys[t.code]=!0,this.emit(t))},onKeyUp:function(t){AFRAME.utils.shouldCaptureKeyEvent(t)&&(delete this.localKeys[t.code],this.emit(t))},onBlur:function(){for(const t in this.localKeys)this.localKeys.hasOwnProperty(t)&&delete this.localKeys[t]},emit:function(e){"__keyboard-controls-proxy"in e&&this.el.emit(e.type,e),this.el.emit(e.type+":"+e.code,new t(e.type,e)),this.data.debug&&console.log(e.type+":"+e.code)},isPressed:function(t){return t in this.getKeys()},getKeys:function(){return this.isProxied()?this.el.sceneEl.components["proxy-controls"].getKeyboard():this.localKeys},isProxied:function(){const t=this.el.sceneEl.components["proxy-controls"];return t&&t.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 t=this.el.sceneEl,e=t.canvas;if(!e)return void t.addEventListener("render-target-loaded",this.addEventListeners.bind(this));e.addEventListener("touchstart",this.onTouchStart,{passive:!0}),e.addEventListener("touchend",this.onTouchEnd,{passive:!0});const n=t.getAttribute("vr-mode-ui");n&&n.cardboardModeEnabled&&t.addEventListener("enter-vr",this.onEnterVR)},removeEventListeners:function(){const t=this.el.sceneEl&&this.el.sceneEl.canvas;t&&(t.removeEventListener("touchstart",this.onTouchStart),t.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(t){this.direction=-1,this.data.reverseEnabled&&t.touches&&2===t.touches.length&&(this.direction=1),t.preventDefault()},onTouchEnd:function(t){this.direction=0,t.preventDefault()},onEnterVR:function(){const t=this.el.sceneEl.xrSession;t&&(t.addEventListener("selectstart",this.onTouchStart),t.addEventListener("selectend",this.onTouchEnd))}})),function(){if(T)return S;T=1;const t="-controls";S=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 t=this.el;this.data.camera||(this.data.camera=t.querySelector("[camera]")),this.velocityCtrl=null,this.velocity=new THREE.Vector3,this.heading=new THREE.Quaternion,this.eventDetail={},this.navGroup=null,this.navNode=null,t.sceneEl.hasLoaded?this.injectControls():t.sceneEl.addEventListener("loaded",this.injectControls.bind(this))},update:function(e){const n=this.el,i=this.data,r=n.sceneEl.systems.nav;if(n.sceneEl.hasLoaded&&this.injectControls(),r&&i.constrainToNavMesh!==e.constrainToNavMesh&&(i.constrainToNavMesh?r.addAgent(this):r.removeAgent(this)),i.enabled!==e.enabled)for(let e=0;e<i.controls.length;e++){const n=i.controls[e]+t;this.el.setAttribute(n,{enabled:this.data.enabled})}},injectControls:function(){const e=this.data;for(let n=0;n<e.controls.length;n++){const i=e.controls[n]+t;this.el.setAttribute(i,{enabled:this.data.enabled})}},updateNavLocation:function(){this.navGroup=null,this.navNode=null},tick:function(){const t=new THREE.Vector3,e=new THREE.Vector3,n=new THREE.Vector3;return function(i,r){if(!r)return;const o=this.el,s=this.data;if(!s.enabled)return;this.updateVelocityCtrl();const a=this.velocityCtrl,h=this.velocity;if(a)if(r/1e3>.2?h.set(0,0,0):this.updateVelocity(r),s.constrainToNavMesh&&!1!==a.isNavMeshConstrained){if(h.lengthSq()<1e-5)return;t.copy(o.object3D.position),e.copy(h).multiplyScalar(r/1e3).add(t);const i=o.sceneEl.systems.nav;this.navGroup=null===this.navGroup?i.getGroup(t):this.navGroup,this.navNode=this.navNode||i.getNode(t,this.navGroup),this.navNode=i.clampStep(t,e,this.navGroup,this.navNode,n),o.object3D.position.copy(n)}else o.hasAttribute("velocity")?o.setAttribute("velocity",h):(o.object3D.position.x+=h.x*r/1e3,o.object3D.position.y+=h.y*r/1e3,o.object3D.position.z+=h.z*r/1e3)}}(),updateVelocityCtrl:function(){const e=this.data;if(e.enabled){for(let n=0,i=e.controls.length;n<i;n++){const i=this.el.components[e.controls[n]+t];if(i&&i.isVelocityActive())return void(this.velocityCtrl=i)}this.velocityCtrl=null}},updateVelocity:function(){const t=new THREE.Vector2,e=new THREE.Quaternion;return function(n){let i;const r=this.el,o=this.velocityCtrl,s=this.velocity,a=this.data;if(o){if(!o.getVelocityDelta){if(o.getVelocity)return void s.copy(o.getVelocity());if(o.getPositionDelta)return void s.copy(o.getPositionDelta(n).multiplyScalar(1e3/n));throw new Error("Incompatible movement controls: ",o)}i=o.getVelocityDelta(n)}if(r.hasAttribute("velocity")&&!a.constrainToNavMesh&&s.copy(this.el.getAttribute("velocity")),i&&a.enabled){const n=a.camera;e.copy(n.object3D.quaternion),e.premultiply(r.object3D.quaternion),i.applyQuaternion(e);const o=i.length();a.fly?(s.copy(i),s.multiplyScalar(16.66667*this.data.speed)):(t.set(i.x,i.z),t.setLength(o*this.data.speed*16.66667),s.x=t.x,s.y=0,s.z=t.y),0===s.x&&0===s.y&&0===s.z||(this.eventDetail.velocity=s,this.el.emit("moved",this.eventDetail))}}}()})}(),O||(O=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 t=this.data,e=this.el.sceneEl;switch(e.addEventListener("axismove",this.onAxisMove),t.mode){case"swipe":case"touch":e.addEventListener("trackpadtouchstart",this.onTouchStart),e.addEventListener("trackpadtouchend",this.onTouchEnd);break;case"press":e.addEventListener("trackpaddown",this.onTouchStart),e.addEventListener("trackpadup",this.onTouchEnd)}},removeEventListeners:function(){const t=this.el.sceneEl;t.removeEventListener("axismove",this.onAxisMove),t.removeEventListener("trackpadtouchstart",this.onTouchStart),t.removeEventListener("trackpadtouchend",this.onTouchEnd),t.removeEventListener("trackpaddown",this.onTouchStart),t.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(t){switch(this.data.mode){case"swipe":this.canRecordAxis=!0,this.startingAxisData=[];break;case"touch":case"press":this.isMoving=!0}t.preventDefault()},onTouchEnd:function(t){"swipe"==this.data.mode&&(this.startingAxisData=[]),this.isMoving=!1,t.preventDefault()},onAxisMove:function(t){switch(this.data.mode){case"swipe":return this.handleSwipeAxis(t);case"touch":case"press":return this.handleTouchAxis(t)}},handleSwipeAxis:function(t){const e=this.data,n=t.detail.axis;if(0===this.startingAxisData.length&&this.canRecordAxi