diff --git a/dist/humaninput-1.1.14-full.min.js.gz b/dist/humaninput-1.1.14-full.min.js.gz deleted file mode 100644 index e97822e..0000000 Binary files a/dist/humaninput-1.1.14-full.min.js.gz and /dev/null differ diff --git a/dist/humaninput-1.1.14-full.js b/dist/humaninput-1.1.15-full.js similarity index 99% rename from dist/humaninput-1.1.14-full.js rename to dist/humaninput-1.1.15-full.js index 1d37f40..3a6bee0 100644 --- a/dist/humaninput-1.1.14-full.js +++ b/dist/humaninput-1.1.15-full.js @@ -250,7 +250,7 @@ var HumanInput = function (_EventHandler) { _this.elem = (0, _utils.getNode)(elem || window); _this.Logger = _logger.Logger; // In case someone wants to use it separately _this.log = log; - _this.VERSION = "1.1.14"; + _this.VERSION = "1.1.15"; _this.plugin_instances = []; // Each instance of HumanInput gets its own set of plugin instances // NOTE: Most state-tracking variables are set inside HumanInput.init() @@ -699,7 +699,7 @@ var HumanInput = function (_EventHandler) { return code; // The code for spacebar is 'Space' } if (code.hasOwnProperty('includes')) { - // This check should resolve the edge case in issue #14 (https://github.com/liftoff/HumanInput/issues/14) + // This check was put here to resolve the edge case in issue #14 (https://github.com/liftoff/HumanInput/issues/14) if (code.includes('Left') || code.includes('Right')) { // Use the left and right variants of the name as the 'key' key = code; // So modifiers can be more specific @@ -2795,10 +2795,10 @@ var GamepadPlugin = exports.GamepadPlugin = function () { this.exports = { gamepads: this.gamepads, _gamepadTimer: this._gamepadTimer, - gamepadUpdate: this.gamepadUpdate, - loadController: this.loadController, - stopGamepadUpdates: this.stopGamepadUpdates, - startGamepadUpdates: this.startGamepadUpdates + gamepadUpdate: this.gamepadUpdate.bind(this), + loadController: this.loadController.bind(this), + stopGamepadUpdates: this.stopGamepadUpdates.bind(this), + startGamepadUpdates: this.startGamepadUpdates.bind(this) }; return this; } @@ -2820,10 +2820,10 @@ var GamepadPlugin = exports.GamepadPlugin = function () { this.gamepadUpdate(); this.startGamepadUpdates(); // Make sure we play nice and disable our interval timer when the user changes tabs - HI.on('document:hidden', this.stopGamepadUpdates); - HI.on('document:visibile', this.startGamepadUpdates); + HI.on('document:hidden', this.stopGamepadUpdates.bind(this)); + HI.on('document:visible', this.startGamepadUpdates.bind(this)); // This ensures the gpadCheckInterval is replaced with the gpadInterval - HI.on('gpad:connected', this.startGamepadUpdates); + HI.on('gpad:connected', this.startGamepadUpdates.bind(this)); } return this; }; @@ -2878,7 +2878,7 @@ var GamepadPlugin = exports.GamepadPlugin = function () { continue; // Nothing changed } // NOTE: We we have to make value-by-value copy of the previous gamepad state because Gamepad objects retain references to their internal state (i.e. button and axes values) when copied using traditional methods. Benchmarking has shown the JSON.parse/JSON.stringify method to be the fastest so far (0.3-0.5ms per call to gamepadUpdate() VS 0.7-1.2ms per call when creating a new object literal, looping over the axes and buttons to copy their values). - prevState = JSON.parse(JSON.stringify(gp)); // This should be slower but I think the JS engine has an optimization for this specific parse(stringify()) situation resulting in it being the fastest method + prevState = JSON.parse(JSON.stringify(gp)); // You'd think this would be slower but I think the JS engine has an optimization for this specific parse(stringify()) situation resulting in it being the fastest method gp.timestamp = gamepads[i].timestamp; gp.axes = gamepads[i].axes.slice(0); for (j = 0; j < prevState.buttons.length; j++) { @@ -2890,7 +2890,7 @@ var GamepadPlugin = exports.GamepadPlugin = function () { // Update the state of all down buttons (axes stand alone) for (j = 0; j < gp.buttons.length; j++) { buttonState = 'up'; - if (gp.buttons[j].pressed) { + if (gp.buttons[j].pressed && gp.buttons[j].value == 1) { buttonState = 'down'; } event = 'gpad:button:' + j; @@ -2935,17 +2935,20 @@ var GamepadPlugin = exports.GamepadPlugin = function () { }; GamepadPlugin.prototype.stopGamepadUpdates = function stopGamepadUpdates() { + this.log.debug('Stopping gamepad updates.', this); clearInterval(this._gamepadTimer); }; GamepadPlugin.prototype.startGamepadUpdates = function startGamepadUpdates() { + this.log.debug('Starting gamepad updates.', this); + var gamepadUpdate = this.gamepadUpdate.bind(this); clearInterval(this._gamepadTimer); if (this.gamepads.length) { // At least one gamepad is connected - this._gamepadTimer = setInterval(this.gamepadUpdate, this.HI.settings.gpadInterval); + this._gamepadTimer = setInterval(gamepadUpdate, this.HI.settings.gpadInterval); } else { // Check for a new gamepad every few seconds in case the user plugs one in later - this._gamepadTimer = setInterval(this.gamepadUpdate, this.HI.settings.gpadCheckInterval); + this._gamepadTimer = setInterval(gamepadUpdate, this.HI.settings.gpadCheckInterval); } }; diff --git a/dist/humaninput-1.1.14-full.min.js b/dist/humaninput-1.1.15-full.min.js similarity index 66% rename from dist/humaninput-1.1.14-full.min.js rename to dist/humaninput-1.1.15-full.min.js index 1001dda..2c7def5 100644 --- a/dist/humaninput-1.1.14-full.min.js +++ b/dist/humaninput-1.1.15-full.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["humaninput-full"]=e():(t.HumanInput=t.HumanInput||{},t.HumanInput["humaninput-full"]=e())}(this,function(){return function(t){function e(i){if(n[i])return n[i].exports;var o=n[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=28)}([function(t,e){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){(function(e){t.exports=e.HumanInput=n(10)}).call(e,n(0))},function(t,e,n){(function(e){t.exports=e.HumanInput=n(4)}).call(e,n(0))},function(t,e,n){(function(e){t.exports=e.HumanInput=n(5)}).call(e,n(0))},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}e.__esModule=!0;var r=function(){function t(t,e){for(var n=0;nthis.settings.maxSequenceBuf&&n.shift(),n.length>1)){for(var s=this._seqCombinations(n),r=0;r1&&(t=this._handleShifted(n),e=e.concat(this._seqCombinations([n],"->")),t&&(e=e.concat(this._seqCombinations([o],"->")))),n.length>1&&((0,c.sortEvents)(n),e=e.concat(this._seqCombinations([n]))),t&&((0,c.sortEvents)(o),e=e.concat(this._seqCombinations([o])))}return e},e.prototype._keydown=function(t){var e,n=this.state,i=t.which||t.keyCode,o=t.location||0,s=this.keyMaps[o][i]||this.keyMaps[0][i]||t.code,r=t.key||s,a=t.type,l=this.filter(t),u=this.scope+"faceplant";return t.repeat&&l&&this.settings.noKeyRepeat?(t.preventDefault(),!1):"Compose"==(r=this._normSpecial(o,r,s))?void(n.composing=!0):(n.down.includes(r)||this._addDown(r,s),this._resetSeqTimeout(),void(l&&(e=this._triggerWithSelectors(a,[t,r,s]),e=e.concat(this._triggerWithSelectors(a+=":"+r.toLowerCase(),[t,r,s])),n.down.length>5&&(e=e.concat(this.trigger(u,t))),b&&(e=e.concat(this._handleDownEvents(t,r,s))),(0,c.handlePreventDefault)(t,e))))},e.prototype._keypress=function(t){var e=t.charCode||t.which,n=t.key||String.fromCharCode(e);!b&&e>47&&n.length&&(this.state.down.pop(),this.state.down.push(n))},e.prototype._keyup=function(t){var e,n=this.state,i=t.which||t.keyCode,o=t.location||0,s=this.keyMaps[o][i]||this.keyMaps[0][i]||t.code,r=t.key||s,a=t.type;if(r=this._normSpecial(o,r,s),l.MACOS&&l.OSKEYS.includes(r)){for(var u=[],h=0;h")||(t=(0,s.normCombo)(t))),n||(n={});var u={callback:e,context:n,times:i};o.events[t]||(o.events[t]=[]),o.events[t].push(u)}),this},t.prototype.once=function(t,e,n){return this.on(t,e,n,1)},t.prototype.off=function(t,e,n){if(arguments.length){t=t?(0,s.normEvents)(t):Object.keys(this.events);for(var i in t){var o=t[i],r=this.events[o];if(r){var a=[];if(!n&&!e){delete this.events[o];break}for(var l=0;l1&&!isNaN(e)&&(e=parseInt(e)),o[t][o[t][e]]=e})}(p)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.Logger=void 0;var o=n(1),s=window.console,r={40:"ERROR",30:"WARNING",20:"INFO",10:"DEBUG",ERROR:40,WARNING:30,INFO:20,DEBUG:10};e.Logger=function(){function t(e,n){i(this,t),this.prefix=n,this.setLevel(e),this.writeErr=this.fallback,this.writeWarn=this.fallback,this.writeInfo=this.fallback,this.writeDebug=this.fallback,(0,o.isFunction)(s.error)&&(this.writeErr=s.error),(0,o.isFunction)(s.warn)&&(this.writeWarn=s.warn),(0,o.isFunction)(s.info)&&(this.writeInfo=s.info),(0,o.isFunction)(s.debug)&&(this.writeDebug=s.debug)}return t.prototype.setLevel=function(t){t=t.toUpperCase(),this.error=this.write.bind(this,40),this.warn=this.write.bind(this,30),this.info=this.write.bind(this,20),this.debug=this.write.bind(this,10),this.logLevel=t,isNaN(t)&&(this.logLevel=t=r[t]),t>40&&(this.error=o.noop),t>30&&(this.warn=o.noop),t>20&&(this.info=o.noop),t>10&&(this.debug=o.noop)},t.prototype.fallback=function(t){var e=Array.from(arguments);e[0]=this.prefix+r[t]+" "+e[0],(0,o.isFunction)(s.log)&&s.log.apply(s,e)},t.prototype.write=function(t){var e=this.logLevel,n=Array.from(arguments).slice(1);this.prefix.length&&n.unshift(this.prefix),40===t&&e<=40?this.writeErr.apply(s,n):30===t&&e<=30?this.writeWarn.apply(s,n):20===t&&e<=20?this.writeInfo.apply(s,n):10===t&&e<=10&&this.writeDebug.apply(s,n)},t}()},function(t,e,n){"use strict";function i(){Array.from||(Array.prototype.from=function(t){return[].slice.call(t)}),Array.prototype.includes||(Array.prototype.includes=function(t){var e,n,i=Object(this),o=parseInt(i.length,10)||0,s=parseInt(arguments[1],10)||0;if(0===o)return!1;for(s>=0?e=s:(e=o+s)<0&&(e=0);ethis.length)&&-1!==this.indexOf(t,e)}),String.prototype.endsWith||(String.prototype.endsWith=function(t,e){var n=this.toString();("number"!=typeof e||!isFinite(e)||Math.floor(e)!==e||e>n.length)&&(e=n.length),e-=t.length;var i=n.indexOf(t,e);return-1!==i&&i===e}),String.prototype.startsWith||(String.prototype.startsWith=function(t,e){return e=e||0,this.substr(e,t.length)===t})}e.__esModule=!0,e.polyfill=i},function(t,e,n){"use strict";function i(t){return t}function o(t){var e="";return t.name?e+=" "+t.name:t.id?e+=" "+t.id:t.nodeName&&(e+=" "+t.nodeName),"[HI"+e+"]"}function s(t){if("string"==typeof t){return document.querySelector(t)}return t}function r(t){return p(t)?[t]:t}function a(t,e){if(e.includes(!1))return t.preventDefault(),!0}function l(t){var e,n,i,o=[];for(t=t.split(/ +(?=(?:(?:[^"]*"){2})*[^"]*$)/g),e=0;ee[n]?-1:e[t]t[n+1]&&e.push(n);return e},c=e.ClapperPlugin=function(){function t(e){i(this,t),this.HI=e,this.l=e.l,this.exports={},this.history=[],this.rollingAvg=[],this.calcHistoryAverage=this.calcHistoryAverage.bind(this),this.startClapper=this.startClapper.bind(this),this.stopClapper=this.stopClapper.bind(this)}return t.prototype.init=function(t){var e=this;t.state;return this.log=new t.Logger(t.settings.logLevel||"INFO","[HI Clapper]"),t.settings.autostartClapper=t.settings.autostartClapper||!1,t.settings.clapThreshold=t.settings.clapThreshold||130,t.settings.autotoggleClapper=t.settings.autotoggleClapper||!0,-1!=t.settings.listenEvents.indexOf("clapper")&&(r?(t.settings.autostartClapper&&this.startClapper(),t.settings.autotoggleClapper&&(t.on("document:hidden",function(){e._started&&e.stopClapper()}),t.on("document:visible",function(){!e._started&&t.settings.autostartClapper&&e.startClapper()}))):(this.startClapper=t.noop,this.stopClapper=t.noop)),this.exports.startClapper=this.startClapper,this.exports.stopClapper=this.stopClapper,this},t.prototype.calcHistoryAverage=function(){var t,e,n=0;for(t=0;t60&&(t.freqData=new Uint8Array(t.analyser.frequencyBinCount),t.analyser.getByteFrequencyData(t.freqData),u=l(t.freqData),h=t.freqData.indexOf(Math.max.apply(null,t.freqData)),t.freqData[h],p=t.freqData[h]-t.rollingAvg[h],s>=240&&h<8&&p>t.HI.settings.clapThreshold&&(d=a(t.freqData.slice(0,10))/a(t.freqData.slice(10,20)),f=a(t.freqData.slice(0,3))/a(t.freqData.slice(3,6)),d<1.8&&f<1.4&&u.length>2&&(c="clap",s<480&&(c="doubleclap",o=g,r<720&&(c="applause")),t.HI._addDown(c),t.HI._handleDownEvents(),t.HI._handleSeqEvents(),t.HI._removeDown(c),i=g)),n=g,i!=g&&(t.history.push(t.freqData),t.history.length>50&&t.history.shift(),t.calcHistoryAverage()))}};this.context=new r,this.scriptProcessor=this.context.createScriptProcessor(1024,1,1),this.analyser=this.context.createAnalyser(),this.freqData=new Uint8Array(this.analyser.frequencyBinCount),this.log.debug(this.l("Starting clap detection")),this._started=!0,navigator.mediaDevices.getUserMedia({audio:!0}).then(e,function(e){t.log.error(t.l("Could not get audio stream"),e)})},t.prototype.stopClapper=function(){this.log.debug(this.l("Stopping clap detection")),this.stream.getAudioTracks().forEach(function(t){t.stop()}),this.stream.getVideoTracks().forEach(function(t){t.stop()}),this.streamSource.disconnect(this.analyser),this.analyser.disconnect(this.scriptProcessor),this.scriptProcessor.disconnect(this.context.destination),this._started=!1},t}();s.default.plugins.push(c)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.ClipboardPlugin=void 0;var o=n(1),s=n(2),r=function(t){return t&&t.__esModule?t:{default:t}}(s);r.default.defaultListenEvents=r.default.defaultListenEvents.concat(["cut","copy","paste","select"]);var a=e.ClipboardPlugin=function(){function t(e){i(this,t),this.HI=e,e._clipboard=this._clipboard.bind(e),this._paste=this._clipboard,this._copy=this._clipboard,this._cut=this._clipboard,e._select=this._select.bind(e),this._input=this._select}return t.prototype.init=function(t){return this},t.prototype._clipboard=function(t){var e,n=t.type+':"';if(this.filter(t)&&(window.clipboardData?e=window.clipboardData.getData("Text"):t.clipboardData&&(e=t.clipboardData.getData("text/plain")),e||"copy"!=t.type&&"cut"!=t.type||(e=this.getSelText()),e)){var i=this._triggerWithSelectors(t.type,[t,e]);i=i.concat(this._triggerWithSelectors(n+e+'"',[t])),(0,o.handlePreventDefault)(t,i)}},t.prototype._select=function(t){var e=t.type+':"';if("select"==t.type)var n=this.getSelText();else if("input"==t.type)var n=t.data||t.target.value;if(this.filter(t)){var i=this._triggerWithSelectors(t.type,[t,n]);n&&(i=i.concat(this._triggerWithSelectors(e+n+'"',[t])),(0,o.handlePreventDefault)(t,i))}},t}();r.default.plugins.push(a)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:50,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"sine",i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.5,o=c.createGain(),s=c.createOscillator();s.connect(o),o.connect(c.destination),s.frequency.value=e,o.gain.value=i,s.type=n,s.start(),setTimeout(function(){s.stop()},t||50)}e.__esModule=!0,e.FeedbackPlugin=void 0;var s=n(2),r=function(t){return t&&t.__esModule?t:{default:t}}(s),a=n(1),l=n(3),c=new(window.AudioContext||window.webkitAudioContext||window.audioContext),u=["keydown","dblclick","wheel:down","wheel:up","wheel:left","wheel:right","pointer:left:down","pointer:middle:down","pointer:right:down","scroll:up","scroll:down","scroll:left","scroll:right"],h=["keydown","dblclick","wheel:down","wheel:up","wheel:left","wheel:right","pointer:down"],p=["pointer:down"],d=e.FeedbackPlugin=function(){function t(e){return i(this,t),this.HI=e,this.l=e.l,this.exports={beep:o},this.vibrationInterval=null,this}return t.prototype.init=function(t){var e=this;return this.log=new t.Logger(t.settings.logLevel||"INFO","[HI Feedback]"),this.lastActivity=new Date,this.timeout=null,t.settings.visualEvents=t.settings.visualEvents||u,t.settings.audioEvents=t.settings.audioEvents||h,t.settings.vibrationEvents=t.settings.vibrationEvents||p,t.settings.visualFeedback=t.settings.visualFeedback||!1,t.settings.audioFeedback=t.settings.audioFeedback||!1,t.settings.vibrationFeedback=t.settings.vibrationFeedback||!1,t.settings.feedbackClass=t.settings.feedbackClass||"event",this.feedbackElem=(0,a.getNode)(t.settings.feedbackElem),this.feedbackElem||(this.feedbackElem=(0,a.getNode)("#hi_feedback")),this.feedbackElem||(t.settings.feedbackElem="#hi_feedback",this.feedbackStyle=document.createElement("style"),this.feedbackStyle.type="text/css",this.feedbackStyle.appendChild(document.createTextNode("\n#hi_feedback {\n position: fixed;\n top: 1em;\n right: 1em;\n align-items: flex-end;\n justify-content: flex-end;\n font-size: 2em;\n display: flex;\n flex-flow: row wrap;\n width: 8em;\n}\n\n#hi_feedback .event {\n transition: all .5s ease-in-out;\n transform-origin: right bottom;\n opacity: 0;\n border: black .15rem solid;\n border-radius: .2em;\n text-align: center;\n padding: .2rem;\n min-width: 1em;\n padding: .2em;\n background-color: rgba(0,0,0,0.7);\n color: #fff;\n z-index: 9999;\n}\n")),document.body.appendChild(this.feedbackStyle),this.feedbackElem=document.createElement("div"),this.feedbackElem.id="hi_feedback",t.elem!==window?t.elem.appendChild(this.feedbackElem):document.body.appendChild(this.feedbackElem)),t.settings.visualFeedback&&t.on(t.settings.visualEvents,this.visualEvent,this),t.settings.audioFeedback&&t.on(t.settings.audioEvents,this.audioEvent,this),t.settings.vibrationFeedback&&(t.on(t.settings.vibrationEvents,this.vibrationEvent,this),t.settings.vibrationEvents.forEach(function(n){n.endsWith("down")&&t.on(n.split("down",1)[0]+"up",e.stopVibration,e)})),this},t.prototype.containsModifiers=function(t,e,n){return l.AllModifiers.includes(t)},t.prototype.visualEvent=function(t){var e=this.HIEvent,n=["cut","copy","paste","select"],i=HI.getDown(),o=document.createElement("div");if(o.classList.add(this.HI.settings.feedbackClass),n.includes(t.type)&&(arguments.length<=1?0:arguments.length-1))o.innerHTML=e+":"+(arguments.length<=1?void 0:arguments[1]);else if("keydown"==t.type)e=arguments.length<=1?void 0:arguments[1],o.innerHTML=e,l.AllModifiers.includes(e)&&!i.includes("-")?o.innerHTML=e.toLowerCase():HI.state.down.some(this.containsModifiers)&&(o.innerHTML=i);else if(e.startsWith("pointer")){var s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("width",100),s.setAttribute("height",100),s.style.position="fixed",s.style.top=t.clientY-50+"px",s.style.left=t.clientX-50+"px",s.style.transition="all .33s ease-out",s.style.transform="scale(0.1)",s.style.zIndex=1e4,s.innerHTML='',document.body.appendChild(s),setTimeout(function(){s.style.transform="scale(2)",s.style.opacity=0,setTimeout(function(){s.parentNode.removeChild(s)},500)},10),e.includes(":down")&&(e=e.substr(0,e.length-5)),o.innerHTML=e}else i.length?o.innerHTML=i:o.innerHTML=e;o.style.opacity=1,this.feedbackElem.appendChild(o),setTimeout(function(){o.style.opacity=0,showEventTimeout=setTimeout(function(){o.parentNode.removeChild(o)},500)},1e3)},t.prototype.audioEvent=function(t){o(33,500,"triangle")},t.prototype.startVibration=function(){navigator.vibrate(150)},t.prototype.stopVibration=function(){clearInterval(this.vibrationInterval),navigator.vibrate(0)},t.prototype.vibrationEvent=function(t){navigator.vibrate(150),clearInterval(this.vibrationInterval),this.vibrationInterval=setInterval(this.startVibration,100)},t}();r.default.plugins.push(d)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.GamepadPlugin=void 0;var o=(n(1),n(2)),s=function(t){return t&&t.__esModule?t:{default:t}}(o),r=function(t){for(var e=navigator.getGamepads(),n=0;nthis.idleTimeout?this.HI.trigger("idle",this.lastActivity):this.timeout=setTimeout(this.idleCheck,this.idleCheckInterval)},t}();r.default.plugins.push(a)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.PointerPlugin=void 0;var o,s=n(1),r=n(2),a=function(t){return t&&t.__esModule?t:{default:t}}(r),l=["pan","mousedown","mouseup","touchstart","touchend","touchcancel","wheel"],c=["pointermove"];a.default.defaultListenEvents=a.default.defaultListenEvents.concat(l),c=["mousemove","touchmove"];var u=e.PointerPlugin=function(){function t(e){var n=this;i(this,t),this.HI=e,["_click","_dragendPointerup","_pointerdown","_pointerup","_pointercancel","_pointerMoveCheck","_trackMotion","_wheel"].forEach(function(t){e[t]=n[t].bind(e)}),e.on("hold",function(t){t.includes("pointer:")&&((0,s.removeListeners)(window,c,e._pointerMoveCheck,!0),(0,s.addListeners)(window,c,e._pointerMoveCheck,!0))}),e._mousedown=e._pointerdown,e._touchstart=e._pointerdown,e._mouseup=e._pointerup,e._touchend=e._pointerup,e._touchcancel=e._pointercancel,e._tap=e._click,e.on("hi:resetstates",this._resetStates,e),e.on("hi:removedown",function(t){(0,s.removeListeners)(window,c,e._pointerMoveCheck,!0)}),e.on("hold",this._holdCheck,e)}return t.prototype.init=function(t){var e=t.state;return e.multitap=0,e.pointerCount=0,e.pointers={},e.scrollX=0,e.scrollY=0,(0,s.removeListeners)(window,c,t._pointerMoveCheck,!0),(0,s.removeListeners)(t.elem,c,t._trackMotion,!0),this.exports={mouse:this.mouse},this},t.prototype._resetStates=function(){(0,s.removeListeners)(window,c,this._pointerMoveCheck,!0),(0,s.removeListeners)(this.elem,c,this._trackMotion,!0),this.state.pointers={},this.state.pointerCount=0},t.prototype._holdCheck=function(t){t.includes("pointer:")&&((0,s.removeListeners)(window,c,this._pointerMoveCheck,!0),(0,s.addListeners)(window,c,this._pointerMoveCheck,!0))},t.prototype._pointerMoveCheck=function(t){var e,n,i,o,r=this.settings.moveThreshold,a=this.state.pointers,l=t.touches;if(t.pointerType||"mousemove"==t.type)i=t.pointerId||1;else if(l&&l.length)for(var u=0;ur||Math.abs(o.y-n)>r)&&(clearTimeout(this.state.holdTimeout),(0,s.removeListeners)(window,c,this._pointerMoveCheck,!0)))},t.prototype._trackMotion=function(t){var e,n,i=[],o="pan",r={},a=this.state.pointers,l=t.touches;if(t.pointerType||"mousemove"==t.type){if(e=t.pointerId||1,!(n=a[e]))return;n.event=t}else if(l&&l.length)for(var c=0;c1?(o="multitouch:",i=i.concat(this._triggerWithSelectors(o+"pan",[t,a])),i=i.concat(this._triggerWithSelectors(o+this.state.pointerCount+":pan",[t,a]))):i=i.concat(this._triggerWithSelectors(o,[t,r])),(0,s.handlePreventDefault)(t,i))},t.prototype._dragendPointerup=function(t){var e=t.pointerId||1,n=this.state.pointers,i={bubbles:!0,cancelable:!0,clientX:t.clientX,clientY:t.clientY,isPrimary:!0,layerX:t.layerX,layerY:t.layerY,offsetX:t.offsetX,offsetY:t.offsetY,pageX:t.pageX,pageY:t.pageY,pointerId:e,pressure:t.pressure||0,relatedTarget:window,screenX:t.screenX,screenY:t.screenY,target:t.target,tiltX:t.tiltX||0,tiltY:t.tiltY||0,view:window,x:t.x,y:t.y};new MouseEvent("mouseup",i);n[e]&&(this._pointerup(t),window.removeEventListener("dragend",this._dragendPointerup,!0))},t.prototype._pointerdown=function(t){var e,n,i=this.state,r=this.mouse(t),a=t.changedTouches,l=t.pointerType,u="pointer",h=":down";if("mousedown"!=t.type||!o){if(l||"mousedown"==t.type)e=t.pointerId||1,i.pointers[e]={x:t.clientX,y:t.clientY,event:t,timestamp:Date.now()};else if(a&&a.length){for(var p=0;p1||this.settings.listenEvents.includes("pan"))&&((0,s.removeListeners)(window,c,this._trackMotion,!0),(0,s.addListeners)(window,c,this._trackMotion,!0)),this._addDown(u+":"+r.buttonName),this._resetSeqTimeout(),this.filter(t)&&(n=this._triggerWithSelectors(u+h,[t]),void 0!==r.buttonName&&(u+=":"+r.buttonName,n=n.concat(this._triggerWithSelectors(u+h,[t]))),n=n.concat(this._handleDownEvents(t)),(0,s.handlePreventDefault)(t,n))}},t.prototype._pointerup=function(t){var e,n,i,r,a=this.state,l=this.settings.moveThreshold,u=t.clientX,h=t.clientY,p=a.pointers,d={},f=t.changedTouches,g=t.pointerType,v=this.settings.swipeThreshold,m="pointer:",w=this.filter(t);if("mouseup"==t.type&&o)return void(o=!1);if(g||"mouseup"==t.type)e=t.pointerId||1;else if(f&&f.length)for(var y=0;yMath.abs(d.y)?d.x>v?i+="left":d.x<-v&&(i+="right"):d.y>v?i+="up":d.y<-v&&(i+="down")),o=!1,delete p[e],a.pointerCount--,a.pointerCount>0?d.x0?n=n.concat(this._doDownEvent("wheel:down",t)):t.deltaY<0&&(n=n.concat(this._doDownEvent("wheel:up",t))),t.deltaZ>0?n=n.concat(this._doDownEvent("wheel:out",t)):t.deltaZ<0&&(n=n.concat(this._doDownEvent("wheel:in",t))),t.deltaX>0?(n=n.concat(this._doDownEvent("wheel:right",t)),this.isDown("shift")&&(n=n.concat(this._triggerWithSelectors("wheel:right",[t])))):t.deltaX<0&&(n=n.concat(this._doDownEvent("wheel:left",t)),this.isDown("shift")&&(n=n.concat(this._triggerWithSelectors("wheel:left",[t])))),(0,s.handlePreventDefault)(t,n)}},t.prototype.mouse=function(t){var e={type:t.type};return"mousemove"!=t.type&&"wheel"!=t.type&&(0===t.button?(e.left=!0,e.buttonName="left"):1===t.button?(e.middle=!0,e.buttonName="middle"):2===t.button?(e.right=!0,e.buttonName="right"):3===t.button?(e.back=!0,e.buttonName="back"):4===t.button?(e.forward=!0,e.buttonName="forward"):5===t.button?(e.forward=!0,e.buttonName="eraser"):e.buttonName=t.button),e.button=t.button,e},t}();a.default.plugins.push(u)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.ScrollPlugin=void 0;var o=n(1),s=n(2),r=function(t){return t&&t.__esModule?t:{default:t}}(s);r.default.defaultListenEvents.push("scroll");var a=e.ScrollPlugin=function(){function t(e){i(this,t),this.HI=e,e._scroll=(0,o.debounce)(this._scroll.bind(e),50),e.on("hi:resetstates",this._resetStates,e)}return t.prototype.init=function(t){var e=t.state;return e.scrollX=0,e.scrollY=0,this},t.prototype._resetStates=function(){this.state.scrollX=0,this.state.scrollY=0},t.prototype._scroll=function(t){var e,n,i,s=this.state,r=t.target,a=r.scrollLeft,l=r.scrollTop;r.scrollingElement&&(a=r.scrollingElement.scrollLeft,l=r.scrollingElement.scrollTop),n=a-s.scrollX,0===(i=l-s.scrollY)&&0===n||(e=this._triggerWithSelectors(t.type,[t,{x:n,y:i}]),void 0!==a&&a!==s.scrollX&&(n=Math.abs(n),e=a>s.scrollX?e.concat(this._triggerWithSelectors(t.type+":right",[t,n])):e.concat(this._triggerWithSelectors(t.type+":left",[t,n])),s.scrollX=a),void 0!==l&&l!==s.scrollY&&(i=Math.abs(i),e=l>s.scrollY?e.concat(this._triggerWithSelectors(t.type+":down",[t,i])):e.concat(this._triggerWithSelectors(t.type+":up",[t,i])),s.scrollY=l),(0,o.handlePreventDefault)(t,e))},t}();r.default.plugins.push(a)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.SpeechRecPlugin=void 0;var o=n(1),s=n(2),r=function(t){return t&&t.__esModule?t:{default:t}}(s);r.default.defaultListenEvents.push("speech");var a=window.SpeechRecognition||window.webkitSpeechRecognition||window.mozSpeechRecognition||window.msSpeechRecognition||window.oSpeechRecognition,l=e.SpeechRecPlugin=function(){function t(e){return i(this,t),this.exports={startSpeechRec:this.startSpeechRec.bind(this),stopSpeechRec:this.stopSpeechRec.bind(this)},this.HI=e,this.l=e.l,this.log=new e.Logger(e.settings.logLevel||"INFO","[HI SpeechRec]"),this._rtSpeech=[],this._rtSpeechTimer=null,this}return t.prototype.init=function(){var t=this,e=this.HI,n=e.settings;return n.autostartSpeech=n.autostartSpeech||!1,n.listenEvents.includes("speech")&&(a?(n.autostartSpeech&&this.startSpeechRec(),e.on("document:hidden",function(){t._started&&t.stopSpeechRec()}),e.on("document:visible",function(){!t._started&&n.autostartSpeech&&t.startSpeechRec()})):(this.startSpeechRec=o.noop,this.stopSpeechRec=o.noop)),this},t.prototype.startSpeechRec=function(){var t=this,e=this.HI;this._recognition=new a,this.log.debug(this.l("Starting speech recognition"),this._recognition),this._recognition.lang=e.settings.speechLang||navigator.language||"en-US",this._recognition.continuous=!0,this._recognition.interimResults=!0,this._recognition.onresult=function(e){for(var n=e.resultIndex;nthis.settings.maxSequenceBuf&&n.shift(),n.length>1)){for(var s=this._seqCombinations(n),r=0;r1&&(t=this._handleShifted(n),e=e.concat(this._seqCombinations([n],"->")),t&&(e=e.concat(this._seqCombinations([o],"->")))),n.length>1&&((0,c.sortEvents)(n),e=e.concat(this._seqCombinations([n]))),t&&((0,c.sortEvents)(o),e=e.concat(this._seqCombinations([o])))}return e},e.prototype._keydown=function(t){var e,n=this.state,i=t.which||t.keyCode,o=t.location||0,s=this.keyMaps[o][i]||this.keyMaps[0][i]||t.code,r=t.key||s,a=t.type,l=this.filter(t),u=this.scope+"faceplant";return t.repeat&&l&&this.settings.noKeyRepeat?(t.preventDefault(),!1):"Compose"==(r=this._normSpecial(o,r,s))?void(n.composing=!0):(n.down.includes(r)||this._addDown(r,s),this._resetSeqTimeout(),void(l&&(e=this._triggerWithSelectors(a,[t,r,s]),e=e.concat(this._triggerWithSelectors(a+=":"+r.toLowerCase(),[t,r,s])),n.down.length>5&&(e=e.concat(this.trigger(u,t))),b&&(e=e.concat(this._handleDownEvents(t,r,s))),(0,c.handlePreventDefault)(t,e))))},e.prototype._keypress=function(t){var e=t.charCode||t.which,n=t.key||String.fromCharCode(e);!b&&e>47&&n.length&&(this.state.down.pop(),this.state.down.push(n))},e.prototype._keyup=function(t){var e,n=this.state,i=t.which||t.keyCode,o=t.location||0,s=this.keyMaps[o][i]||this.keyMaps[0][i]||t.code,r=t.key||s,a=t.type;if(r=this._normSpecial(o,r,s),l.MACOS&&l.OSKEYS.includes(r)){for(var u=[],h=0;h")||(t=(0,s.normCombo)(t))),n||(n={});var u={callback:e,context:n,times:i};o.events[t]||(o.events[t]=[]),o.events[t].push(u)}),this},t.prototype.once=function(t,e,n){return this.on(t,e,n,1)},t.prototype.off=function(t,e,n){if(arguments.length){t=t?(0,s.normEvents)(t):Object.keys(this.events);for(var i in t){var o=t[i],r=this.events[o];if(r){var a=[];if(!n&&!e){delete this.events[o];break}for(var l=0;l1&&!isNaN(e)&&(e=parseInt(e)),o[t][o[t][e]]=e})}(p)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.Logger=void 0;var o=n(1),s=window.console,r={40:"ERROR",30:"WARNING",20:"INFO",10:"DEBUG",ERROR:40,WARNING:30,INFO:20,DEBUG:10};e.Logger=function(){function t(e,n){i(this,t),this.prefix=n,this.setLevel(e),this.writeErr=this.fallback,this.writeWarn=this.fallback,this.writeInfo=this.fallback,this.writeDebug=this.fallback,(0,o.isFunction)(s.error)&&(this.writeErr=s.error),(0,o.isFunction)(s.warn)&&(this.writeWarn=s.warn),(0,o.isFunction)(s.info)&&(this.writeInfo=s.info),(0,o.isFunction)(s.debug)&&(this.writeDebug=s.debug)}return t.prototype.setLevel=function(t){t=t.toUpperCase(),this.error=this.write.bind(this,40),this.warn=this.write.bind(this,30),this.info=this.write.bind(this,20),this.debug=this.write.bind(this,10),this.logLevel=t,isNaN(t)&&(this.logLevel=t=r[t]),t>40&&(this.error=o.noop),t>30&&(this.warn=o.noop),t>20&&(this.info=o.noop),t>10&&(this.debug=o.noop)},t.prototype.fallback=function(t){var e=Array.from(arguments);e[0]=this.prefix+r[t]+" "+e[0],(0,o.isFunction)(s.log)&&s.log.apply(s,e)},t.prototype.write=function(t){var e=this.logLevel,n=Array.from(arguments).slice(1);this.prefix.length&&n.unshift(this.prefix),40===t&&e<=40?this.writeErr.apply(s,n):30===t&&e<=30?this.writeWarn.apply(s,n):20===t&&e<=20?this.writeInfo.apply(s,n):10===t&&e<=10&&this.writeDebug.apply(s,n)},t}()},function(t,e,n){"use strict";function i(){Array.from||(Array.prototype.from=function(t){return[].slice.call(t)}),Array.prototype.includes||(Array.prototype.includes=function(t){var e,n,i=Object(this),o=parseInt(i.length,10)||0,s=parseInt(arguments[1],10)||0;if(0===o)return!1;for(s>=0?e=s:(e=o+s)<0&&(e=0);ethis.length)&&-1!==this.indexOf(t,e)}),String.prototype.endsWith||(String.prototype.endsWith=function(t,e){var n=this.toString();("number"!=typeof e||!isFinite(e)||Math.floor(e)!==e||e>n.length)&&(e=n.length),e-=t.length;var i=n.indexOf(t,e);return-1!==i&&i===e}),String.prototype.startsWith||(String.prototype.startsWith=function(t,e){return e=e||0,this.substr(e,t.length)===t})}e.__esModule=!0,e.polyfill=i},function(t,e,n){"use strict";function i(t){return t}function o(t){var e="";return t.name?e+=" "+t.name:t.id?e+=" "+t.id:t.nodeName&&(e+=" "+t.nodeName),"[HI"+e+"]"}function s(t){if("string"==typeof t){return document.querySelector(t)}return t}function r(t){return p(t)?[t]:t}function a(t,e){if(e.includes(!1))return t.preventDefault(),!0}function l(t){var e,n,i,o=[];for(t=t.split(/ +(?=(?:(?:[^"]*"){2})*[^"]*$)/g),e=0;ee[n]?-1:e[t]t[n+1]&&e.push(n);return e},c=e.ClapperPlugin=function(){function t(e){i(this,t),this.HI=e,this.l=e.l,this.exports={},this.history=[],this.rollingAvg=[],this.calcHistoryAverage=this.calcHistoryAverage.bind(this),this.startClapper=this.startClapper.bind(this),this.stopClapper=this.stopClapper.bind(this)}return t.prototype.init=function(t){var e=this;t.state;return this.log=new t.Logger(t.settings.logLevel||"INFO","[HI Clapper]"),t.settings.autostartClapper=t.settings.autostartClapper||!1,t.settings.clapThreshold=t.settings.clapThreshold||130,t.settings.autotoggleClapper=t.settings.autotoggleClapper||!0,-1!=t.settings.listenEvents.indexOf("clapper")&&(r?(t.settings.autostartClapper&&this.startClapper(),t.settings.autotoggleClapper&&(t.on("document:hidden",function(){e._started&&e.stopClapper()}),t.on("document:visible",function(){!e._started&&t.settings.autostartClapper&&e.startClapper()}))):(this.startClapper=t.noop,this.stopClapper=t.noop)),this.exports.startClapper=this.startClapper,this.exports.stopClapper=this.stopClapper,this},t.prototype.calcHistoryAverage=function(){var t,e,n=0;for(t=0;t60&&(t.freqData=new Uint8Array(t.analyser.frequencyBinCount),t.analyser.getByteFrequencyData(t.freqData),u=l(t.freqData),h=t.freqData.indexOf(Math.max.apply(null,t.freqData)),t.freqData[h],p=t.freqData[h]-t.rollingAvg[h],s>=240&&h<8&&p>t.HI.settings.clapThreshold&&(d=a(t.freqData.slice(0,10))/a(t.freqData.slice(10,20)),f=a(t.freqData.slice(0,3))/a(t.freqData.slice(3,6)),d<1.8&&f<1.4&&u.length>2&&(c="clap",s<480&&(c="doubleclap",o=g,r<720&&(c="applause")),t.HI._addDown(c),t.HI._handleDownEvents(),t.HI._handleSeqEvents(),t.HI._removeDown(c),i=g)),n=g,i!=g&&(t.history.push(t.freqData),t.history.length>50&&t.history.shift(),t.calcHistoryAverage()))}};this.context=new r,this.scriptProcessor=this.context.createScriptProcessor(1024,1,1),this.analyser=this.context.createAnalyser(),this.freqData=new Uint8Array(this.analyser.frequencyBinCount),this.log.debug(this.l("Starting clap detection")),this._started=!0,navigator.mediaDevices.getUserMedia({audio:!0}).then(e,function(e){t.log.error(t.l("Could not get audio stream"),e)})},t.prototype.stopClapper=function(){this.log.debug(this.l("Stopping clap detection")),this.stream.getAudioTracks().forEach(function(t){t.stop()}),this.stream.getVideoTracks().forEach(function(t){t.stop()}),this.streamSource.disconnect(this.analyser),this.analyser.disconnect(this.scriptProcessor),this.scriptProcessor.disconnect(this.context.destination),this._started=!1},t}();s.default.plugins.push(c)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.ClipboardPlugin=void 0;var o=n(1),s=n(2),r=function(t){return t&&t.__esModule?t:{default:t}}(s);r.default.defaultListenEvents=r.default.defaultListenEvents.concat(["cut","copy","paste","select"]);var a=e.ClipboardPlugin=function(){function t(e){i(this,t),this.HI=e,e._clipboard=this._clipboard.bind(e),this._paste=this._clipboard,this._copy=this._clipboard,this._cut=this._clipboard,e._select=this._select.bind(e),this._input=this._select}return t.prototype.init=function(t){return this},t.prototype._clipboard=function(t){var e,n=t.type+':"';if(this.filter(t)&&(window.clipboardData?e=window.clipboardData.getData("Text"):t.clipboardData&&(e=t.clipboardData.getData("text/plain")),e||"copy"!=t.type&&"cut"!=t.type||(e=this.getSelText()),e)){var i=this._triggerWithSelectors(t.type,[t,e]);i=i.concat(this._triggerWithSelectors(n+e+'"',[t])),(0,o.handlePreventDefault)(t,i)}},t.prototype._select=function(t){var e=t.type+':"';if("select"==t.type)var n=this.getSelText();else if("input"==t.type)var n=t.data||t.target.value;if(this.filter(t)){var i=this._triggerWithSelectors(t.type,[t,n]);n&&(i=i.concat(this._triggerWithSelectors(e+n+'"',[t])),(0,o.handlePreventDefault)(t,i))}},t}();r.default.plugins.push(a)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:50,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"sine",i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.5,o=c.createGain(),s=c.createOscillator();s.connect(o),o.connect(c.destination),s.frequency.value=e,o.gain.value=i,s.type=n,s.start(),setTimeout(function(){s.stop()},t||50)}e.__esModule=!0,e.FeedbackPlugin=void 0;var s=n(2),r=function(t){return t&&t.__esModule?t:{default:t}}(s),a=n(1),l=n(3),c=new(window.AudioContext||window.webkitAudioContext||window.audioContext),u=["keydown","dblclick","wheel:down","wheel:up","wheel:left","wheel:right","pointer:left:down","pointer:middle:down","pointer:right:down","scroll:up","scroll:down","scroll:left","scroll:right"],h=["keydown","dblclick","wheel:down","wheel:up","wheel:left","wheel:right","pointer:down"],p=["pointer:down"],d=e.FeedbackPlugin=function(){function t(e){return i(this,t),this.HI=e,this.l=e.l,this.exports={beep:o},this.vibrationInterval=null,this}return t.prototype.init=function(t){var e=this;return this.log=new t.Logger(t.settings.logLevel||"INFO","[HI Feedback]"),this.lastActivity=new Date,this.timeout=null,t.settings.visualEvents=t.settings.visualEvents||u,t.settings.audioEvents=t.settings.audioEvents||h,t.settings.vibrationEvents=t.settings.vibrationEvents||p,t.settings.visualFeedback=t.settings.visualFeedback||!1,t.settings.audioFeedback=t.settings.audioFeedback||!1,t.settings.vibrationFeedback=t.settings.vibrationFeedback||!1,t.settings.feedbackClass=t.settings.feedbackClass||"event",this.feedbackElem=(0,a.getNode)(t.settings.feedbackElem),this.feedbackElem||(this.feedbackElem=(0,a.getNode)("#hi_feedback")),this.feedbackElem||(t.settings.feedbackElem="#hi_feedback",this.feedbackStyle=document.createElement("style"),this.feedbackStyle.type="text/css",this.feedbackStyle.appendChild(document.createTextNode("\n#hi_feedback {\n position: fixed;\n top: 1em;\n right: 1em;\n align-items: flex-end;\n justify-content: flex-end;\n font-size: 2em;\n display: flex;\n flex-flow: row wrap;\n width: 8em;\n}\n\n#hi_feedback .event {\n transition: all .5s ease-in-out;\n transform-origin: right bottom;\n opacity: 0;\n border: black .15rem solid;\n border-radius: .2em;\n text-align: center;\n padding: .2rem;\n min-width: 1em;\n padding: .2em;\n background-color: rgba(0,0,0,0.7);\n color: #fff;\n z-index: 9999;\n}\n")),document.body.appendChild(this.feedbackStyle),this.feedbackElem=document.createElement("div"),this.feedbackElem.id="hi_feedback",t.elem!==window?t.elem.appendChild(this.feedbackElem):document.body.appendChild(this.feedbackElem)),t.settings.visualFeedback&&t.on(t.settings.visualEvents,this.visualEvent,this),t.settings.audioFeedback&&t.on(t.settings.audioEvents,this.audioEvent,this),t.settings.vibrationFeedback&&(t.on(t.settings.vibrationEvents,this.vibrationEvent,this),t.settings.vibrationEvents.forEach(function(n){n.endsWith("down")&&t.on(n.split("down",1)[0]+"up",e.stopVibration,e)})),this},t.prototype.containsModifiers=function(t,e,n){return l.AllModifiers.includes(t)},t.prototype.visualEvent=function(t){var e=this.HIEvent,n=["cut","copy","paste","select"],i=HI.getDown(),o=document.createElement("div");if(o.classList.add(this.HI.settings.feedbackClass),n.includes(t.type)&&(arguments.length<=1?0:arguments.length-1))o.innerHTML=e+":"+(arguments.length<=1?void 0:arguments[1]);else if("keydown"==t.type)e=arguments.length<=1?void 0:arguments[1],o.innerHTML=e,l.AllModifiers.includes(e)&&!i.includes("-")?o.innerHTML=e.toLowerCase():HI.state.down.some(this.containsModifiers)&&(o.innerHTML=i);else if(e.startsWith("pointer")){var s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("width",100),s.setAttribute("height",100),s.style.position="fixed",s.style.top=t.clientY-50+"px",s.style.left=t.clientX-50+"px",s.style.transition="all .33s ease-out",s.style.transform="scale(0.1)",s.style.zIndex=1e4,s.innerHTML='',document.body.appendChild(s),setTimeout(function(){s.style.transform="scale(2)",s.style.opacity=0,setTimeout(function(){s.parentNode.removeChild(s)},500)},10),e.includes(":down")&&(e=e.substr(0,e.length-5)),o.innerHTML=e}else i.length?o.innerHTML=i:o.innerHTML=e;o.style.opacity=1,this.feedbackElem.appendChild(o),setTimeout(function(){o.style.opacity=0,showEventTimeout=setTimeout(function(){o.parentNode.removeChild(o)},500)},1e3)},t.prototype.audioEvent=function(t){o(33,500,"triangle")},t.prototype.startVibration=function(){navigator.vibrate(150)},t.prototype.stopVibration=function(){clearInterval(this.vibrationInterval),navigator.vibrate(0)},t.prototype.vibrationEvent=function(t){navigator.vibrate(150),clearInterval(this.vibrationInterval),this.vibrationInterval=setInterval(this.startVibration,100)},t}();r.default.plugins.push(d)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.GamepadPlugin=void 0;var o=(n(1),n(2)),s=function(t){return t&&t.__esModule?t:{default:t}}(o),r=function(t){for(var e=navigator.getGamepads(),n=0;nthis.idleTimeout?this.HI.trigger("idle",this.lastActivity):this.timeout=setTimeout(this.idleCheck,this.idleCheckInterval)},t}();r.default.plugins.push(a)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.PointerPlugin=void 0;var o,s=n(1),r=n(2),a=function(t){return t&&t.__esModule?t:{default:t}}(r),l=["pan","mousedown","mouseup","touchstart","touchend","touchcancel","wheel"],c=["pointermove"];a.default.defaultListenEvents=a.default.defaultListenEvents.concat(l),c=["mousemove","touchmove"];var u=e.PointerPlugin=function(){function t(e){var n=this;i(this,t),this.HI=e,["_click","_dragendPointerup","_pointerdown","_pointerup","_pointercancel","_pointerMoveCheck","_trackMotion","_wheel"].forEach(function(t){e[t]=n[t].bind(e)}),e.on("hold",function(t){t.includes("pointer:")&&((0,s.removeListeners)(window,c,e._pointerMoveCheck,!0),(0,s.addListeners)(window,c,e._pointerMoveCheck,!0))}),e._mousedown=e._pointerdown,e._touchstart=e._pointerdown,e._mouseup=e._pointerup,e._touchend=e._pointerup,e._touchcancel=e._pointercancel,e._tap=e._click,e.on("hi:resetstates",this._resetStates,e),e.on("hi:removedown",function(t){(0,s.removeListeners)(window,c,e._pointerMoveCheck,!0)}),e.on("hold",this._holdCheck,e)}return t.prototype.init=function(t){var e=t.state;return e.multitap=0,e.pointerCount=0,e.pointers={},e.scrollX=0,e.scrollY=0,(0,s.removeListeners)(window,c,t._pointerMoveCheck,!0),(0,s.removeListeners)(t.elem,c,t._trackMotion,!0),this.exports={mouse:this.mouse},this},t.prototype._resetStates=function(){(0,s.removeListeners)(window,c,this._pointerMoveCheck,!0),(0,s.removeListeners)(this.elem,c,this._trackMotion,!0),this.state.pointers={},this.state.pointerCount=0},t.prototype._holdCheck=function(t){t.includes("pointer:")&&((0,s.removeListeners)(window,c,this._pointerMoveCheck,!0),(0,s.addListeners)(window,c,this._pointerMoveCheck,!0))},t.prototype._pointerMoveCheck=function(t){var e,n,i,o,r=this.settings.moveThreshold,a=this.state.pointers,l=t.touches;if(t.pointerType||"mousemove"==t.type)i=t.pointerId||1;else if(l&&l.length)for(var u=0;ur||Math.abs(o.y-n)>r)&&(clearTimeout(this.state.holdTimeout),(0,s.removeListeners)(window,c,this._pointerMoveCheck,!0)))},t.prototype._trackMotion=function(t){var e,n,i=[],o="pan",r={},a=this.state.pointers,l=t.touches;if(t.pointerType||"mousemove"==t.type){if(e=t.pointerId||1,!(n=a[e]))return;n.event=t}else if(l&&l.length)for(var c=0;c1?(o="multitouch:",i=i.concat(this._triggerWithSelectors(o+"pan",[t,a])),i=i.concat(this._triggerWithSelectors(o+this.state.pointerCount+":pan",[t,a]))):i=i.concat(this._triggerWithSelectors(o,[t,r])),(0,s.handlePreventDefault)(t,i))},t.prototype._dragendPointerup=function(t){var e=t.pointerId||1,n=this.state.pointers,i={bubbles:!0,cancelable:!0,clientX:t.clientX,clientY:t.clientY,isPrimary:!0,layerX:t.layerX,layerY:t.layerY,offsetX:t.offsetX,offsetY:t.offsetY,pageX:t.pageX,pageY:t.pageY,pointerId:e,pressure:t.pressure||0,relatedTarget:window,screenX:t.screenX,screenY:t.screenY,target:t.target,tiltX:t.tiltX||0,tiltY:t.tiltY||0,view:window,x:t.x,y:t.y};new MouseEvent("mouseup",i);n[e]&&(this._pointerup(t),window.removeEventListener("dragend",this._dragendPointerup,!0))},t.prototype._pointerdown=function(t){var e,n,i=this.state,r=this.mouse(t),a=t.changedTouches,l=t.pointerType,u="pointer",h=":down";if("mousedown"!=t.type||!o){if(l||"mousedown"==t.type)e=t.pointerId||1,i.pointers[e]={x:t.clientX,y:t.clientY,event:t,timestamp:Date.now()};else if(a&&a.length){for(var p=0;p1||this.settings.listenEvents.includes("pan"))&&((0,s.removeListeners)(window,c,this._trackMotion,!0),(0,s.addListeners)(window,c,this._trackMotion,!0)),this._addDown(u+":"+r.buttonName),this._resetSeqTimeout(),this.filter(t)&&(n=this._triggerWithSelectors(u+h,[t]),void 0!==r.buttonName&&(u+=":"+r.buttonName,n=n.concat(this._triggerWithSelectors(u+h,[t]))),n=n.concat(this._handleDownEvents(t)),(0,s.handlePreventDefault)(t,n))}},t.prototype._pointerup=function(t){var e,n,i,r,a=this.state,l=this.settings.moveThreshold,u=t.clientX,h=t.clientY,p=a.pointers,d={},f=t.changedTouches,g=t.pointerType,v=this.settings.swipeThreshold,m="pointer:",w=this.filter(t);if("mouseup"==t.type&&o)return void(o=!1);if(g||"mouseup"==t.type)e=t.pointerId||1;else if(f&&f.length)for(var y=0;yMath.abs(d.y)?d.x>v?i+="left":d.x<-v&&(i+="right"):d.y>v?i+="up":d.y<-v&&(i+="down")),o=!1,delete p[e],a.pointerCount--,a.pointerCount>0?d.x0?n=n.concat(this._doDownEvent("wheel:down",t)):t.deltaY<0&&(n=n.concat(this._doDownEvent("wheel:up",t))),t.deltaZ>0?n=n.concat(this._doDownEvent("wheel:out",t)):t.deltaZ<0&&(n=n.concat(this._doDownEvent("wheel:in",t))),t.deltaX>0?(n=n.concat(this._doDownEvent("wheel:right",t)),this.isDown("shift")&&(n=n.concat(this._triggerWithSelectors("wheel:right",[t])))):t.deltaX<0&&(n=n.concat(this._doDownEvent("wheel:left",t)),this.isDown("shift")&&(n=n.concat(this._triggerWithSelectors("wheel:left",[t])))),(0,s.handlePreventDefault)(t,n)}},t.prototype.mouse=function(t){var e={type:t.type};return"mousemove"!=t.type&&"wheel"!=t.type&&(0===t.button?(e.left=!0,e.buttonName="left"):1===t.button?(e.middle=!0,e.buttonName="middle"):2===t.button?(e.right=!0,e.buttonName="right"):3===t.button?(e.back=!0,e.buttonName="back"):4===t.button?(e.forward=!0,e.buttonName="forward"):5===t.button?(e.forward=!0,e.buttonName="eraser"):e.buttonName=t.button),e.button=t.button,e},t}();a.default.plugins.push(u)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.ScrollPlugin=void 0;var o=n(1),s=n(2),r=function(t){return t&&t.__esModule?t:{default:t}}(s);r.default.defaultListenEvents.push("scroll");var a=e.ScrollPlugin=function(){function t(e){i(this,t),this.HI=e,e._scroll=(0,o.debounce)(this._scroll.bind(e),50),e.on("hi:resetstates",this._resetStates,e)}return t.prototype.init=function(t){var e=t.state;return e.scrollX=0,e.scrollY=0,this},t.prototype._resetStates=function(){this.state.scrollX=0,this.state.scrollY=0},t.prototype._scroll=function(t){var e,n,i,s=this.state,r=t.target,a=r.scrollLeft,l=r.scrollTop;r.scrollingElement&&(a=r.scrollingElement.scrollLeft,l=r.scrollingElement.scrollTop),n=a-s.scrollX,0===(i=l-s.scrollY)&&0===n||(e=this._triggerWithSelectors(t.type,[t,{x:n,y:i}]),void 0!==a&&a!==s.scrollX&&(n=Math.abs(n),e=a>s.scrollX?e.concat(this._triggerWithSelectors(t.type+":right",[t,n])):e.concat(this._triggerWithSelectors(t.type+":left",[t,n])),s.scrollX=a),void 0!==l&&l!==s.scrollY&&(i=Math.abs(i),e=l>s.scrollY?e.concat(this._triggerWithSelectors(t.type+":down",[t,i])):e.concat(this._triggerWithSelectors(t.type+":up",[t,i])),s.scrollY=l),(0,o.handlePreventDefault)(t,e))},t}();r.default.plugins.push(a)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.SpeechRecPlugin=void 0;var o=n(1),s=n(2),r=function(t){return t&&t.__esModule?t:{default:t}}(s);r.default.defaultListenEvents.push("speech");var a=window.SpeechRecognition||window.webkitSpeechRecognition||window.mozSpeechRecognition||window.msSpeechRecognition||window.oSpeechRecognition,l=e.SpeechRecPlugin=function(){function t(e){return i(this,t),this.exports={startSpeechRec:this.startSpeechRec.bind(this),stopSpeechRec:this.stopSpeechRec.bind(this)},this.HI=e,this.l=e.l,this.log=new e.Logger(e.settings.logLevel||"INFO","[HI SpeechRec]"),this._rtSpeech=[],this._rtSpeechTimer=null,this}return t.prototype.init=function(){var t=this,e=this.HI,n=e.settings;return n.autostartSpeech=n.autostartSpeech||!1,n.listenEvents.includes("speech")&&(a?(n.autostartSpeech&&this.startSpeechRec(),e.on("document:hidden",function(){t._started&&t.stopSpeechRec()}),e.on("document:visible",function(){!t._started&&n.autostartSpeech&&t.startSpeechRec()})):(this.startSpeechRec=o.noop,this.stopSpeechRec=o.noop)),this},t.prototype.startSpeechRec=function(){var t=this,e=this.HI;this._recognition=new a,this.log.debug(this.l("Starting speech recognition"),this._recognition),this._recognition.lang=e.settings.speechLang||navigator.language||"en-US",this._recognition.continuous=!0,this._recognition.interimResults=!0,this._recognition.onresult=function(e){for(var n=e.resultIndex;nthis.settings.maxSequenceBuf&&n.shift(),n.length>1)){for(var r=this._seqCombinations(n),s=0;s1&&(t=this._handleShifted(n),e=e.concat(this._seqCombinations([n],"->")),t&&(e=e.concat(this._seqCombinations([i],"->")))),n.length>1&&((0,u.sortEvents)(n),e=e.concat(this._seqCombinations([n]))),t&&((0,u.sortEvents)(i),e=e.concat(this._seqCombinations([i])))}return e},e.prototype._keydown=function(t){var e,n=this.state,o=t.which||t.keyCode,i=t.location||0,r=this.keyMaps[i][o]||this.keyMaps[0][o]||t.code,s=t.key||r,a=t.type,l=this.filter(t),c=this.scope+"faceplant";return t.repeat&&l&&this.settings.noKeyRepeat?(t.preventDefault(),!1):"Compose"==(s=this._normSpecial(i,s,r))?void(n.composing=!0):(n.down.includes(s)||this._addDown(s,r),this._resetSeqTimeout(),void(l&&(e=this._triggerWithSelectors(a,[t,s,r]),e=e.concat(this._triggerWithSelectors(a+=":"+s.toLowerCase(),[t,s,r])),n.down.length>5&&(e=e.concat(this.trigger(c,t))),E&&(e=e.concat(this._handleDownEvents(t,s,r))),(0,u.handlePreventDefault)(t,e))))},e.prototype._keypress=function(t){var e=t.charCode||t.which,n=t.key||String.fromCharCode(e);!E&&e>47&&n.length&&(this.state.down.pop(),this.state.down.push(n))},e.prototype._keyup=function(t){var e,n=this.state,o=t.which||t.keyCode,i=t.location||0,r=this.keyMaps[i][o]||this.keyMaps[0][o]||t.code,s=t.key||r,a=t.type;if(s=this._normSpecial(i,s,r),l.MACOS&&l.OSKEYS.includes(s)){for(var c=[],h=0;h")||(t=(0,r.normCombo)(t))),n||(n={});var c={callback:e,context:n,times:o};i.events[t]||(i.events[t]=[]),i.events[t].push(c)}),this},t.prototype.once=function(t,e,n){return this.on(t,e,n,1)},t.prototype.off=function(t,e,n){if(arguments.length){t=t?(0,r.normEvents)(t):Object.keys(this.events);for(var o in t){var i=t[o],s=this.events[i];if(s){var a=[];if(!n&&!e){delete this.events[i];break}for(var l=0;l1&&!isNaN(e)&&(e=parseInt(e)),i[t][i[t][e]]=e})}(f)},function(t,e,n){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.Logger=void 0;var i=n(1),r=window.console,s={40:"ERROR",30:"WARNING",20:"INFO",10:"DEBUG",ERROR:40,WARNING:30,INFO:20,DEBUG:10};e.Logger=function(){function t(e,n){o(this,t),this.prefix=n,this.setLevel(e),this.writeErr=this.fallback,this.writeWarn=this.fallback,this.writeInfo=this.fallback,this.writeDebug=this.fallback,(0,i.isFunction)(r.error)&&(this.writeErr=r.error),(0,i.isFunction)(r.warn)&&(this.writeWarn=r.warn),(0,i.isFunction)(r.info)&&(this.writeInfo=r.info),(0,i.isFunction)(r.debug)&&(this.writeDebug=r.debug)}return t.prototype.setLevel=function(t){t=t.toUpperCase(),this.error=this.write.bind(this,40),this.warn=this.write.bind(this,30),this.info=this.write.bind(this,20),this.debug=this.write.bind(this,10),this.logLevel=t,isNaN(t)&&(this.logLevel=t=s[t]),t>40&&(this.error=i.noop),t>30&&(this.warn=i.noop),t>20&&(this.info=i.noop),t>10&&(this.debug=i.noop)},t.prototype.fallback=function(t){var e=Array.from(arguments);e[0]=this.prefix+s[t]+" "+e[0],(0,i.isFunction)(r.log)&&r.log.apply(r,e)},t.prototype.write=function(t){var e=this.logLevel,n=Array.from(arguments).slice(1);this.prefix.length&&n.unshift(this.prefix),40===t&&e<=40?this.writeErr.apply(r,n):30===t&&e<=30?this.writeWarn.apply(r,n):20===t&&e<=20?this.writeInfo.apply(r,n):10===t&&e<=10&&this.writeDebug.apply(r,n)},t}()},function(t,e,n){"use strict";function o(){Array.from||(Array.prototype.from=function(t){return[].slice.call(t)}),Array.prototype.includes||(Array.prototype.includes=function(t){var e,n,o=Object(this),i=parseInt(o.length,10)||0,r=parseInt(arguments[1],10)||0;if(0===i)return!1;for(r>=0?e=r:(e=i+r)<0&&(e=0);ethis.length)&&-1!==this.indexOf(t,e)}),String.prototype.endsWith||(String.prototype.endsWith=function(t,e){var n=this.toString();("number"!=typeof e||!isFinite(e)||Math.floor(e)!==e||e>n.length)&&(e=n.length),e-=t.length;var o=n.indexOf(t,e);return-1!==o&&o===e}),String.prototype.startsWith||(String.prototype.startsWith=function(t,e){return e=e||0,this.substr(e,t.length)===t})}e.__esModule=!0,e.polyfill=o},function(t,e,n){"use strict";function o(t){return t}function i(t){var e="";return t.name?e+=" "+t.name:t.id?e+=" "+t.id:t.nodeName&&(e+=" "+t.nodeName),"[HI"+e+"]"}function r(t){if("string"==typeof t){return document.querySelector(t)}return t}function s(t){return f(t)?[t]:t}function a(t,e){if(e.includes(!1))return t.preventDefault(),!0}function l(t){var e,n,o,i=[];for(t=t.split(/ +(?=(?:(?:[^"]*"){2})*[^"]*$)/g),e=0;ee[n]?-1:e[t]this.settings.maxSequenceBuf&&n.shift(),n.length>1)){for(var r=this._seqCombinations(n),s=0;s1&&(t=this._handleShifted(n),e=e.concat(this._seqCombinations([n],"->")),t&&(e=e.concat(this._seqCombinations([i],"->")))),n.length>1&&((0,u.sortEvents)(n),e=e.concat(this._seqCombinations([n]))),t&&((0,u.sortEvents)(i),e=e.concat(this._seqCombinations([i])))}return e},e.prototype._keydown=function(t){var e,n=this.state,o=t.which||t.keyCode,i=t.location||0,r=this.keyMaps[i][o]||this.keyMaps[0][o]||t.code,s=t.key||r,a=t.type,l=this.filter(t),c=this.scope+"faceplant";return t.repeat&&l&&this.settings.noKeyRepeat?(t.preventDefault(),!1):"Compose"==(s=this._normSpecial(i,s,r))?void(n.composing=!0):(n.down.includes(s)||this._addDown(s,r),this._resetSeqTimeout(),void(l&&(e=this._triggerWithSelectors(a,[t,s,r]),e=e.concat(this._triggerWithSelectors(a+=":"+s.toLowerCase(),[t,s,r])),n.down.length>5&&(e=e.concat(this.trigger(c,t))),E&&(e=e.concat(this._handleDownEvents(t,s,r))),(0,u.handlePreventDefault)(t,e))))},e.prototype._keypress=function(t){var e=t.charCode||t.which,n=t.key||String.fromCharCode(e);!E&&e>47&&n.length&&(this.state.down.pop(),this.state.down.push(n))},e.prototype._keyup=function(t){var e,n=this.state,o=t.which||t.keyCode,i=t.location||0,r=this.keyMaps[i][o]||this.keyMaps[0][o]||t.code,s=t.key||r,a=t.type;if(s=this._normSpecial(i,s,r),l.MACOS&&l.OSKEYS.includes(s)){for(var c=[],h=0;h")||(t=(0,r.normCombo)(t))),n||(n={});var c={callback:e,context:n,times:o};i.events[t]||(i.events[t]=[]),i.events[t].push(c)}),this},t.prototype.once=function(t,e,n){return this.on(t,e,n,1)},t.prototype.off=function(t,e,n){if(arguments.length){t=t?(0,r.normEvents)(t):Object.keys(this.events);for(var o in t){var i=t[o],s=this.events[i];if(s){var a=[];if(!n&&!e){delete this.events[i];break}for(var l=0;l1&&!isNaN(e)&&(e=parseInt(e)),i[t][i[t][e]]=e})}(f)},function(t,e,n){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.Logger=void 0;var i=n(1),r=window.console,s={40:"ERROR",30:"WARNING",20:"INFO",10:"DEBUG",ERROR:40,WARNING:30,INFO:20,DEBUG:10};e.Logger=function(){function t(e,n){o(this,t),this.prefix=n,this.setLevel(e),this.writeErr=this.fallback,this.writeWarn=this.fallback,this.writeInfo=this.fallback,this.writeDebug=this.fallback,(0,i.isFunction)(r.error)&&(this.writeErr=r.error),(0,i.isFunction)(r.warn)&&(this.writeWarn=r.warn),(0,i.isFunction)(r.info)&&(this.writeInfo=r.info),(0,i.isFunction)(r.debug)&&(this.writeDebug=r.debug)}return t.prototype.setLevel=function(t){t=t.toUpperCase(),this.error=this.write.bind(this,40),this.warn=this.write.bind(this,30),this.info=this.write.bind(this,20),this.debug=this.write.bind(this,10),this.logLevel=t,isNaN(t)&&(this.logLevel=t=s[t]),t>40&&(this.error=i.noop),t>30&&(this.warn=i.noop),t>20&&(this.info=i.noop),t>10&&(this.debug=i.noop)},t.prototype.fallback=function(t){var e=Array.from(arguments);e[0]=this.prefix+s[t]+" "+e[0],(0,i.isFunction)(r.log)&&r.log.apply(r,e)},t.prototype.write=function(t){var e=this.logLevel,n=Array.from(arguments).slice(1);this.prefix.length&&n.unshift(this.prefix),40===t&&e<=40?this.writeErr.apply(r,n):30===t&&e<=30?this.writeWarn.apply(r,n):20===t&&e<=20?this.writeInfo.apply(r,n):10===t&&e<=10&&this.writeDebug.apply(r,n)},t}()},function(t,e,n){"use strict";function o(){Array.from||(Array.prototype.from=function(t){return[].slice.call(t)}),Array.prototype.includes||(Array.prototype.includes=function(t){var e,n,o=Object(this),i=parseInt(o.length,10)||0,r=parseInt(arguments[1],10)||0;if(0===i)return!1;for(r>=0?e=r:(e=i+r)<0&&(e=0);ethis.length)&&-1!==this.indexOf(t,e)}),String.prototype.endsWith||(String.prototype.endsWith=function(t,e){var n=this.toString();("number"!=typeof e||!isFinite(e)||Math.floor(e)!==e||e>n.length)&&(e=n.length),e-=t.length;var o=n.indexOf(t,e);return-1!==o&&o===e}),String.prototype.startsWith||(String.prototype.startsWith=function(t,e){return e=e||0,this.substr(e,t.length)===t})}e.__esModule=!0,e.polyfill=o},function(t,e,n){"use strict";function o(t){return t}function i(t){var e="";return t.name?e+=" "+t.name:t.id?e+=" "+t.id:t.nodeName&&(e+=" "+t.nodeName),"[HI"+e+"]"}function r(t){if("string"==typeof t){return document.querySelector(t)}return t}function s(t){return f(t)?[t]:t}function a(t,e){if(e.includes(!1))return t.preventDefault(),!0}function l(t){var e,n,o,i=[];for(t=t.split(/ +(?=(?:(?:[^"]*"){2})*[^"]*$)/g),e=0;ee[n]?-1:e[t]this.settings.maxSequenceBuf&&n.shift(),n.length>1)){for(var s=this._seqCombinations(n),r=0;r1&&(t=this._handleShifted(n),e=e.concat(this._seqCombinations([n],"->")),t&&(e=e.concat(this._seqCombinations([o],"->")))),n.length>1&&((0,c.sortEvents)(n),e=e.concat(this._seqCombinations([n]))),t&&((0,c.sortEvents)(o),e=e.concat(this._seqCombinations([o])))}return e},e.prototype._keydown=function(t){var e,n=this.state,i=t.which||t.keyCode,o=t.location||0,s=this.keyMaps[o][i]||this.keyMaps[0][i]||t.code,r=t.key||s,a=t.type,l=this.filter(t),u=this.scope+"faceplant";return t.repeat&&l&&this.settings.noKeyRepeat?(t.preventDefault(),!1):"Compose"==(r=this._normSpecial(o,r,s))?void(n.composing=!0):(n.down.includes(r)||this._addDown(r,s),this._resetSeqTimeout(),void(l&&(e=this._triggerWithSelectors(a,[t,r,s]),e=e.concat(this._triggerWithSelectors(a+=":"+r.toLowerCase(),[t,r,s])),n.down.length>5&&(e=e.concat(this.trigger(u,t))),b&&(e=e.concat(this._handleDownEvents(t,r,s))),(0,c.handlePreventDefault)(t,e))))},e.prototype._keypress=function(t){var e=t.charCode||t.which,n=t.key||String.fromCharCode(e);!b&&e>47&&n.length&&(this.state.down.pop(),this.state.down.push(n))},e.prototype._keyup=function(t){var e,n=this.state,i=t.which||t.keyCode,o=t.location||0,s=this.keyMaps[o][i]||this.keyMaps[0][i]||t.code,r=t.key||s,a=t.type;if(r=this._normSpecial(o,r,s),l.MACOS&&l.OSKEYS.includes(r)){for(var u=[],h=0;h")||(t=(0,s.normCombo)(t))),n||(n={});var u={callback:e,context:n,times:i};o.events[t]||(o.events[t]=[]),o.events[t].push(u)}),this},t.prototype.once=function(t,e,n){return this.on(t,e,n,1)},t.prototype.off=function(t,e,n){if(arguments.length){t=t?(0,s.normEvents)(t):Object.keys(this.events);for(var i in t){var o=t[i],r=this.events[o];if(r){var a=[];if(!n&&!e){delete this.events[o];break}for(var l=0;l1&&!isNaN(e)&&(e=parseInt(e)),o[t][o[t][e]]=e})}(p)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.Logger=void 0;var o=n(1),s=window.console,r={40:"ERROR",30:"WARNING",20:"INFO",10:"DEBUG",ERROR:40,WARNING:30,INFO:20,DEBUG:10};e.Logger=function(){function t(e,n){i(this,t),this.prefix=n,this.setLevel(e),this.writeErr=this.fallback,this.writeWarn=this.fallback,this.writeInfo=this.fallback,this.writeDebug=this.fallback,(0,o.isFunction)(s.error)&&(this.writeErr=s.error),(0,o.isFunction)(s.warn)&&(this.writeWarn=s.warn),(0,o.isFunction)(s.info)&&(this.writeInfo=s.info),(0,o.isFunction)(s.debug)&&(this.writeDebug=s.debug)}return t.prototype.setLevel=function(t){t=t.toUpperCase(),this.error=this.write.bind(this,40),this.warn=this.write.bind(this,30),this.info=this.write.bind(this,20),this.debug=this.write.bind(this,10),this.logLevel=t,isNaN(t)&&(this.logLevel=t=r[t]),t>40&&(this.error=o.noop),t>30&&(this.warn=o.noop),t>20&&(this.info=o.noop),t>10&&(this.debug=o.noop)},t.prototype.fallback=function(t){var e=Array.from(arguments);e[0]=this.prefix+r[t]+" "+e[0],(0,o.isFunction)(s.log)&&s.log.apply(s,e)},t.prototype.write=function(t){var e=this.logLevel,n=Array.from(arguments).slice(1);this.prefix.length&&n.unshift(this.prefix),40===t&&e<=40?this.writeErr.apply(s,n):30===t&&e<=30?this.writeWarn.apply(s,n):20===t&&e<=20?this.writeInfo.apply(s,n):10===t&&e<=10&&this.writeDebug.apply(s,n)},t}()},function(t,e,n){"use strict";function i(){Array.from||(Array.prototype.from=function(t){return[].slice.call(t)}),Array.prototype.includes||(Array.prototype.includes=function(t){var e,n,i=Object(this),o=parseInt(i.length,10)||0,s=parseInt(arguments[1],10)||0;if(0===o)return!1;for(s>=0?e=s:(e=o+s)<0&&(e=0);ethis.length)&&-1!==this.indexOf(t,e)}),String.prototype.endsWith||(String.prototype.endsWith=function(t,e){var n=this.toString();("number"!=typeof e||!isFinite(e)||Math.floor(e)!==e||e>n.length)&&(e=n.length),e-=t.length;var i=n.indexOf(t,e);return-1!==i&&i===e}),String.prototype.startsWith||(String.prototype.startsWith=function(t,e){return e=e||0,this.substr(e,t.length)===t})}e.__esModule=!0,e.polyfill=i},function(t,e,n){"use strict";function i(t){return t}function o(t){var e="";return t.name?e+=" "+t.name:t.id?e+=" "+t.id:t.nodeName&&(e+=" "+t.nodeName),"[HI"+e+"]"}function s(t){if("string"==typeof t){return document.querySelector(t)}return t}function r(t){return p(t)?[t]:t}function a(t,e){if(e.includes(!1))return t.preventDefault(),!0}function l(t){var e,n,i,o=[];for(t=t.split(/ +(?=(?:(?:[^"]*"){2})*[^"]*$)/g),e=0;ee[n]?-1:e[t]t[n+1]&&e.push(n);return e},c=e.ClapperPlugin=function(){function t(e){i(this,t),this.HI=e,this.l=e.l,this.exports={},this.history=[],this.rollingAvg=[],this.calcHistoryAverage=this.calcHistoryAverage.bind(this),this.startClapper=this.startClapper.bind(this),this.stopClapper=this.stopClapper.bind(this)}return t.prototype.init=function(t){var e=this;t.state;return this.log=new t.Logger(t.settings.logLevel||"INFO","[HI Clapper]"),t.settings.autostartClapper=t.settings.autostartClapper||!1,t.settings.clapThreshold=t.settings.clapThreshold||130,t.settings.autotoggleClapper=t.settings.autotoggleClapper||!0,-1!=t.settings.listenEvents.indexOf("clapper")&&(r?(t.settings.autostartClapper&&this.startClapper(),t.settings.autotoggleClapper&&(t.on("document:hidden",function(){e._started&&e.stopClapper()}),t.on("document:visible",function(){!e._started&&t.settings.autostartClapper&&e.startClapper()}))):(this.startClapper=t.noop,this.stopClapper=t.noop)),this.exports.startClapper=this.startClapper,this.exports.stopClapper=this.stopClapper,this},t.prototype.calcHistoryAverage=function(){var t,e,n=0;for(t=0;t60&&(t.freqData=new Uint8Array(t.analyser.frequencyBinCount),t.analyser.getByteFrequencyData(t.freqData),u=l(t.freqData),h=t.freqData.indexOf(Math.max.apply(null,t.freqData)),t.freqData[h],p=t.freqData[h]-t.rollingAvg[h],s>=240&&h<8&&p>t.HI.settings.clapThreshold&&(d=a(t.freqData.slice(0,10))/a(t.freqData.slice(10,20)),f=a(t.freqData.slice(0,3))/a(t.freqData.slice(3,6)),d<1.8&&f<1.4&&u.length>2&&(c="clap",s<480&&(c="doubleclap",o=g,r<720&&(c="applause")),t.HI._addDown(c),t.HI._handleDownEvents(),t.HI._handleSeqEvents(),t.HI._removeDown(c),i=g)),n=g,i!=g&&(t.history.push(t.freqData),t.history.length>50&&t.history.shift(),t.calcHistoryAverage()))}};this.context=new r,this.scriptProcessor=this.context.createScriptProcessor(1024,1,1),this.analyser=this.context.createAnalyser(),this.freqData=new Uint8Array(this.analyser.frequencyBinCount),this.log.debug(this.l("Starting clap detection")),this._started=!0,navigator.mediaDevices.getUserMedia({audio:!0}).then(e,function(e){t.log.error(t.l("Could not get audio stream"),e)})},t.prototype.stopClapper=function(){this.log.debug(this.l("Stopping clap detection")),this.stream.getAudioTracks().forEach(function(t){t.stop()}),this.stream.getVideoTracks().forEach(function(t){t.stop()}),this.streamSource.disconnect(this.analyser),this.analyser.disconnect(this.scriptProcessor),this.scriptProcessor.disconnect(this.context.destination),this._started=!1},t}();s.default.plugins.push(c)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.ClipboardPlugin=void 0;var o=n(1),s=n(2),r=function(t){return t&&t.__esModule?t:{default:t}}(s);r.default.defaultListenEvents=r.default.defaultListenEvents.concat(["cut","copy","paste","select"]);var a=e.ClipboardPlugin=function(){function t(e){i(this,t),this.HI=e,e._clipboard=this._clipboard.bind(e),this._paste=this._clipboard,this._copy=this._clipboard,this._cut=this._clipboard,e._select=this._select.bind(e),this._input=this._select}return t.prototype.init=function(t){return this},t.prototype._clipboard=function(t){var e,n=t.type+':"';if(this.filter(t)&&(window.clipboardData?e=window.clipboardData.getData("Text"):t.clipboardData&&(e=t.clipboardData.getData("text/plain")),e||"copy"!=t.type&&"cut"!=t.type||(e=this.getSelText()),e)){var i=this._triggerWithSelectors(t.type,[t,e]);i=i.concat(this._triggerWithSelectors(n+e+'"',[t])),(0,o.handlePreventDefault)(t,i)}},t.prototype._select=function(t){var e=t.type+':"';if("select"==t.type)var n=this.getSelText();else if("input"==t.type)var n=t.data||t.target.value;if(this.filter(t)){var i=this._triggerWithSelectors(t.type,[t,n]);n&&(i=i.concat(this._triggerWithSelectors(e+n+'"',[t])),(0,o.handlePreventDefault)(t,i))}},t}();r.default.plugins.push(a)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:50,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"sine",i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.5,o=c.createGain(),s=c.createOscillator();s.connect(o),o.connect(c.destination),s.frequency.value=e,o.gain.value=i,s.type=n,s.start(),setTimeout(function(){s.stop()},t||50)}e.__esModule=!0,e.FeedbackPlugin=void 0;var s=n(2),r=function(t){return t&&t.__esModule?t:{default:t}}(s),a=n(1),l=n(3),c=new(window.AudioContext||window.webkitAudioContext||window.audioContext),u=["keydown","dblclick","wheel:down","wheel:up","wheel:left","wheel:right","pointer:left:down","pointer:middle:down","pointer:right:down","scroll:up","scroll:down","scroll:left","scroll:right"],h=["keydown","dblclick","wheel:down","wheel:up","wheel:left","wheel:right","pointer:down"],p=["pointer:down"],d=e.FeedbackPlugin=function(){function t(e){return i(this,t),this.HI=e,this.l=e.l,this.exports={beep:o},this.vibrationInterval=null,this}return t.prototype.init=function(t){var e=this;return this.log=new t.Logger(t.settings.logLevel||"INFO","[HI Feedback]"),this.lastActivity=new Date,this.timeout=null,t.settings.visualEvents=t.settings.visualEvents||u,t.settings.audioEvents=t.settings.audioEvents||h,t.settings.vibrationEvents=t.settings.vibrationEvents||p,t.settings.visualFeedback=t.settings.visualFeedback||!1,t.settings.audioFeedback=t.settings.audioFeedback||!1,t.settings.vibrationFeedback=t.settings.vibrationFeedback||!1,t.settings.feedbackClass=t.settings.feedbackClass||"event",this.feedbackElem=(0,a.getNode)(t.settings.feedbackElem),this.feedbackElem||(this.feedbackElem=(0,a.getNode)("#hi_feedback")),this.feedbackElem||(t.settings.feedbackElem="#hi_feedback",this.feedbackStyle=document.createElement("style"),this.feedbackStyle.type="text/css",this.feedbackStyle.appendChild(document.createTextNode("\n#hi_feedback {\n position: fixed;\n top: 1em;\n right: 1em;\n align-items: flex-end;\n justify-content: flex-end;\n font-size: 2em;\n display: flex;\n flex-flow: row wrap;\n width: 8em;\n}\n\n#hi_feedback .event {\n transition: all .5s ease-in-out;\n transform-origin: right bottom;\n opacity: 0;\n border: black .15rem solid;\n border-radius: .2em;\n text-align: center;\n padding: .2rem;\n min-width: 1em;\n padding: .2em;\n background-color: rgba(0,0,0,0.7);\n color: #fff;\n z-index: 9999;\n}\n")),document.body.appendChild(this.feedbackStyle),this.feedbackElem=document.createElement("div"),this.feedbackElem.id="hi_feedback",t.elem!==window?t.elem.appendChild(this.feedbackElem):document.body.appendChild(this.feedbackElem)),t.settings.visualFeedback&&t.on(t.settings.visualEvents,this.visualEvent,this),t.settings.audioFeedback&&t.on(t.settings.audioEvents,this.audioEvent,this),t.settings.vibrationFeedback&&(t.on(t.settings.vibrationEvents,this.vibrationEvent,this),t.settings.vibrationEvents.forEach(function(n){n.endsWith("down")&&t.on(n.split("down",1)[0]+"up",e.stopVibration,e)})),this},t.prototype.containsModifiers=function(t,e,n){return l.AllModifiers.includes(t)},t.prototype.visualEvent=function(t){var e=this.HIEvent,n=["cut","copy","paste","select"],i=HI.getDown(),o=document.createElement("div");if(o.classList.add(this.HI.settings.feedbackClass),n.includes(t.type)&&(arguments.length<=1?0:arguments.length-1))o.innerHTML=e+":"+(arguments.length<=1?void 0:arguments[1]);else if("keydown"==t.type)e=arguments.length<=1?void 0:arguments[1],o.innerHTML=e,l.AllModifiers.includes(e)&&!i.includes("-")?o.innerHTML=e.toLowerCase():HI.state.down.some(this.containsModifiers)&&(o.innerHTML=i);else if(e.startsWith("pointer")){var s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("width",100),s.setAttribute("height",100),s.style.position="fixed",s.style.top=t.clientY-50+"px",s.style.left=t.clientX-50+"px",s.style.transition="all .33s ease-out",s.style.transform="scale(0.1)",s.style.zIndex=1e4,s.innerHTML='',document.body.appendChild(s),setTimeout(function(){s.style.transform="scale(2)",s.style.opacity=0,setTimeout(function(){s.parentNode.removeChild(s)},500)},10),e.includes(":down")&&(e=e.substr(0,e.length-5)),o.innerHTML=e}else i.length?o.innerHTML=i:o.innerHTML=e;o.style.opacity=1,this.feedbackElem.appendChild(o),setTimeout(function(){o.style.opacity=0,showEventTimeout=setTimeout(function(){o.parentNode.removeChild(o)},500)},1e3)},t.prototype.audioEvent=function(t){o(33,500,"triangle")},t.prototype.startVibration=function(){navigator.vibrate(150)},t.prototype.stopVibration=function(){clearInterval(this.vibrationInterval),navigator.vibrate(0)},t.prototype.vibrationEvent=function(t){navigator.vibrate(150),clearInterval(this.vibrationInterval),this.vibrationInterval=setInterval(this.startVibration,100)},t}();r.default.plugins.push(d)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.GamepadPlugin=void 0;var o=(n(1),n(2)),s=function(t){return t&&t.__esModule?t:{default:t}}(o),r=function(t){for(var e=navigator.getGamepads(),n=0;nthis.idleTimeout?this.HI.trigger("idle",this.lastActivity):this.timeout=setTimeout(this.idleCheck,this.idleCheckInterval)},t}();r.default.plugins.push(a)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.PointerPlugin=void 0;var o,s=n(1),r=n(2),a=function(t){return t&&t.__esModule?t:{default:t}}(r),l=["pan","mousedown","mouseup","touchstart","touchend","touchcancel","wheel"],c=["pointermove"];a.default.defaultListenEvents=a.default.defaultListenEvents.concat(l),c=["mousemove","touchmove"];var u=e.PointerPlugin=function(){function t(e){var n=this;i(this,t),this.HI=e,["_click","_dragendPointerup","_pointerdown","_pointerup","_pointercancel","_pointerMoveCheck","_trackMotion","_wheel"].forEach(function(t){e[t]=n[t].bind(e)}),e.on("hold",function(t){t.includes("pointer:")&&((0,s.removeListeners)(window,c,e._pointerMoveCheck,!0),(0,s.addListeners)(window,c,e._pointerMoveCheck,!0))}),e._mousedown=e._pointerdown,e._touchstart=e._pointerdown,e._mouseup=e._pointerup,e._touchend=e._pointerup,e._touchcancel=e._pointercancel,e._tap=e._click,e.on("hi:resetstates",this._resetStates,e),e.on("hi:removedown",function(t){(0,s.removeListeners)(window,c,e._pointerMoveCheck,!0)}),e.on("hold",this._holdCheck,e)}return t.prototype.init=function(t){var e=t.state;return e.multitap=0,e.pointerCount=0,e.pointers={},e.scrollX=0,e.scrollY=0,(0,s.removeListeners)(window,c,t._pointerMoveCheck,!0),(0,s.removeListeners)(t.elem,c,t._trackMotion,!0),this.exports={mouse:this.mouse},this},t.prototype._resetStates=function(){(0,s.removeListeners)(window,c,this._pointerMoveCheck,!0),(0,s.removeListeners)(this.elem,c,this._trackMotion,!0),this.state.pointers={},this.state.pointerCount=0},t.prototype._holdCheck=function(t){t.includes("pointer:")&&((0,s.removeListeners)(window,c,this._pointerMoveCheck,!0),(0,s.addListeners)(window,c,this._pointerMoveCheck,!0))},t.prototype._pointerMoveCheck=function(t){var e,n,i,o,r=this.settings.moveThreshold,a=this.state.pointers,l=t.touches;if(t.pointerType||"mousemove"==t.type)i=t.pointerId||1;else if(l&&l.length)for(var u=0;ur||Math.abs(o.y-n)>r)&&(clearTimeout(this.state.holdTimeout),(0,s.removeListeners)(window,c,this._pointerMoveCheck,!0)))},t.prototype._trackMotion=function(t){var e,n,i=[],o="pan",r={},a=this.state.pointers,l=t.touches;if(t.pointerType||"mousemove"==t.type){if(e=t.pointerId||1,!(n=a[e]))return;n.event=t}else if(l&&l.length)for(var c=0;c1?(o="multitouch:",i=i.concat(this._triggerWithSelectors(o+"pan",[t,a])),i=i.concat(this._triggerWithSelectors(o+this.state.pointerCount+":pan",[t,a]))):i=i.concat(this._triggerWithSelectors(o,[t,r])),(0,s.handlePreventDefault)(t,i))},t.prototype._dragendPointerup=function(t){var e=t.pointerId||1,n=this.state.pointers,i={bubbles:!0,cancelable:!0,clientX:t.clientX,clientY:t.clientY,isPrimary:!0,layerX:t.layerX,layerY:t.layerY,offsetX:t.offsetX,offsetY:t.offsetY,pageX:t.pageX,pageY:t.pageY,pointerId:e,pressure:t.pressure||0,relatedTarget:window,screenX:t.screenX,screenY:t.screenY,target:t.target,tiltX:t.tiltX||0,tiltY:t.tiltY||0,view:window,x:t.x,y:t.y};new MouseEvent("mouseup",i);n[e]&&(this._pointerup(t),window.removeEventListener("dragend",this._dragendPointerup,!0))},t.prototype._pointerdown=function(t){var e,n,i=this.state,r=this.mouse(t),a=t.changedTouches,l=t.pointerType,u="pointer",h=":down";if("mousedown"!=t.type||!o){if(l||"mousedown"==t.type)e=t.pointerId||1,i.pointers[e]={x:t.clientX,y:t.clientY,event:t,timestamp:Date.now()};else if(a&&a.length){for(var p=0;p1||this.settings.listenEvents.includes("pan"))&&((0,s.removeListeners)(window,c,this._trackMotion,!0),(0,s.addListeners)(window,c,this._trackMotion,!0)),this._addDown(u+":"+r.buttonName),this._resetSeqTimeout(),this.filter(t)&&(n=this._triggerWithSelectors(u+h,[t]),void 0!==r.buttonName&&(u+=":"+r.buttonName,n=n.concat(this._triggerWithSelectors(u+h,[t]))),n=n.concat(this._handleDownEvents(t)),(0,s.handlePreventDefault)(t,n))}},t.prototype._pointerup=function(t){var e,n,i,r,a=this.state,l=this.settings.moveThreshold,u=t.clientX,h=t.clientY,p=a.pointers,d={},f=t.changedTouches,g=t.pointerType,v=this.settings.swipeThreshold,m="pointer:",w=this.filter(t);if("mouseup"==t.type&&o)return void(o=!1);if(g||"mouseup"==t.type)e=t.pointerId||1;else if(f&&f.length)for(var y=0;yMath.abs(d.y)?d.x>v?i+="left":d.x<-v&&(i+="right"):d.y>v?i+="up":d.y<-v&&(i+="down")),o=!1,delete p[e],a.pointerCount--,a.pointerCount>0?d.x0?n=n.concat(this._doDownEvent("wheel:down",t)):t.deltaY<0&&(n=n.concat(this._doDownEvent("wheel:up",t))),t.deltaZ>0?n=n.concat(this._doDownEvent("wheel:out",t)):t.deltaZ<0&&(n=n.concat(this._doDownEvent("wheel:in",t))),t.deltaX>0?(n=n.concat(this._doDownEvent("wheel:right",t)),this.isDown("shift")&&(n=n.concat(this._triggerWithSelectors("wheel:right",[t])))):t.deltaX<0&&(n=n.concat(this._doDownEvent("wheel:left",t)),this.isDown("shift")&&(n=n.concat(this._triggerWithSelectors("wheel:left",[t])))),(0,s.handlePreventDefault)(t,n)}},t.prototype.mouse=function(t){var e={type:t.type};return"mousemove"!=t.type&&"wheel"!=t.type&&(0===t.button?(e.left=!0,e.buttonName="left"):1===t.button?(e.middle=!0,e.buttonName="middle"):2===t.button?(e.right=!0,e.buttonName="right"):3===t.button?(e.back=!0,e.buttonName="back"):4===t.button?(e.forward=!0,e.buttonName="forward"):5===t.button?(e.forward=!0,e.buttonName="eraser"):e.buttonName=t.button),e.button=t.button,e},t}();a.default.plugins.push(u)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.ScrollPlugin=void 0;var o=n(1),s=n(2),r=function(t){return t&&t.__esModule?t:{default:t}}(s);r.default.defaultListenEvents.push("scroll");var a=e.ScrollPlugin=function(){function t(e){i(this,t),this.HI=e,e._scroll=(0,o.debounce)(this._scroll.bind(e),50),e.on("hi:resetstates",this._resetStates,e)}return t.prototype.init=function(t){var e=t.state;return e.scrollX=0,e.scrollY=0,this},t.prototype._resetStates=function(){this.state.scrollX=0,this.state.scrollY=0},t.prototype._scroll=function(t){var e,n,i,s=this.state,r=t.target,a=r.scrollLeft,l=r.scrollTop;r.scrollingElement&&(a=r.scrollingElement.scrollLeft,l=r.scrollingElement.scrollTop),n=a-s.scrollX,0===(i=l-s.scrollY)&&0===n||(e=this._triggerWithSelectors(t.type,[t,{x:n,y:i}]),void 0!==a&&a!==s.scrollX&&(n=Math.abs(n),e=a>s.scrollX?e.concat(this._triggerWithSelectors(t.type+":right",[t,n])):e.concat(this._triggerWithSelectors(t.type+":left",[t,n])),s.scrollX=a),void 0!==l&&l!==s.scrollY&&(i=Math.abs(i),e=l>s.scrollY?e.concat(this._triggerWithSelectors(t.type+":down",[t,i])):e.concat(this._triggerWithSelectors(t.type+":up",[t,i])),s.scrollY=l),(0,o.handlePreventDefault)(t,e))},t}();r.default.plugins.push(a)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.SpeechRecPlugin=void 0;var o=n(1),s=n(2),r=function(t){return t&&t.__esModule?t:{default:t}}(s);r.default.defaultListenEvents.push("speech");var a=window.SpeechRecognition||window.webkitSpeechRecognition||window.mozSpeechRecognition||window.msSpeechRecognition||window.oSpeechRecognition,l=e.SpeechRecPlugin=function(){function t(e){return i(this,t),this.exports={startSpeechRec:this.startSpeechRec.bind(this),stopSpeechRec:this.stopSpeechRec.bind(this)},this.HI=e,this.l=e.l,this.log=new e.Logger(e.settings.logLevel||"INFO","[HI SpeechRec]"),this._rtSpeech=[],this._rtSpeechTimer=null,this}return t.prototype.init=function(){var t=this,e=this.HI,n=e.settings;return n.autostartSpeech=n.autostartSpeech||!1,n.listenEvents.includes("speech")&&(a?(n.autostartSpeech&&this.startSpeechRec(),e.on("document:hidden",function(){t._started&&t.stopSpeechRec()}),e.on("document:visible",function(){!t._started&&n.autostartSpeech&&t.startSpeechRec()})):(this.startSpeechRec=o.noop,this.stopSpeechRec=o.noop)),this},t.prototype.startSpeechRec=function(){var t=this,e=this.HI;this._recognition=new a,this.log.debug(this.l("Starting speech recognition"),this._recognition),this._recognition.lang=e.settings.speechLang||navigator.language||"en-US",this._recognition.continuous=!0,this._recognition.interimResults=!0,this._recognition.onresult=function(e){for(var n=e.resultIndex;nthis.settings.maxSequenceBuf&&n.shift(),n.length>1)){for(var s=this._seqCombinations(n),r=0;r1&&(t=this._handleShifted(n),e=e.concat(this._seqCombinations([n],"->")),t&&(e=e.concat(this._seqCombinations([o],"->")))),n.length>1&&((0,c.sortEvents)(n),e=e.concat(this._seqCombinations([n]))),t&&((0,c.sortEvents)(o),e=e.concat(this._seqCombinations([o])))}return e},e.prototype._keydown=function(t){var e,n=this.state,i=t.which||t.keyCode,o=t.location||0,s=this.keyMaps[o][i]||this.keyMaps[0][i]||t.code,r=t.key||s,a=t.type,l=this.filter(t),u=this.scope+"faceplant";return t.repeat&&l&&this.settings.noKeyRepeat?(t.preventDefault(),!1):"Compose"==(r=this._normSpecial(o,r,s))?void(n.composing=!0):(n.down.includes(r)||this._addDown(r,s),this._resetSeqTimeout(),void(l&&(e=this._triggerWithSelectors(a,[t,r,s]),e=e.concat(this._triggerWithSelectors(a+=":"+r.toLowerCase(),[t,r,s])),n.down.length>5&&(e=e.concat(this.trigger(u,t))),b&&(e=e.concat(this._handleDownEvents(t,r,s))),(0,c.handlePreventDefault)(t,e))))},e.prototype._keypress=function(t){var e=t.charCode||t.which,n=t.key||String.fromCharCode(e);!b&&e>47&&n.length&&(this.state.down.pop(),this.state.down.push(n))},e.prototype._keyup=function(t){var e,n=this.state,i=t.which||t.keyCode,o=t.location||0,s=this.keyMaps[o][i]||this.keyMaps[0][i]||t.code,r=t.key||s,a=t.type;if(r=this._normSpecial(o,r,s),l.MACOS&&l.OSKEYS.includes(r)){for(var u=[],h=0;h")||(t=(0,s.normCombo)(t))),n||(n={});var u={callback:e,context:n,times:i};o.events[t]||(o.events[t]=[]),o.events[t].push(u)}),this},t.prototype.once=function(t,e,n){return this.on(t,e,n,1)},t.prototype.off=function(t,e,n){if(arguments.length){t=t?(0,s.normEvents)(t):Object.keys(this.events);for(var i in t){var o=t[i],r=this.events[o];if(r){var a=[];if(!n&&!e){delete this.events[o];break}for(var l=0;l1&&!isNaN(e)&&(e=parseInt(e)),o[t][o[t][e]]=e})}(p)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.Logger=void 0;var o=n(1),s=window.console,r={40:"ERROR",30:"WARNING",20:"INFO",10:"DEBUG",ERROR:40,WARNING:30,INFO:20,DEBUG:10};e.Logger=function(){function t(e,n){i(this,t),this.prefix=n,this.setLevel(e),this.writeErr=this.fallback,this.writeWarn=this.fallback,this.writeInfo=this.fallback,this.writeDebug=this.fallback,(0,o.isFunction)(s.error)&&(this.writeErr=s.error),(0,o.isFunction)(s.warn)&&(this.writeWarn=s.warn),(0,o.isFunction)(s.info)&&(this.writeInfo=s.info),(0,o.isFunction)(s.debug)&&(this.writeDebug=s.debug)}return t.prototype.setLevel=function(t){t=t.toUpperCase(),this.error=this.write.bind(this,40),this.warn=this.write.bind(this,30),this.info=this.write.bind(this,20),this.debug=this.write.bind(this,10),this.logLevel=t,isNaN(t)&&(this.logLevel=t=r[t]),t>40&&(this.error=o.noop),t>30&&(this.warn=o.noop),t>20&&(this.info=o.noop),t>10&&(this.debug=o.noop)},t.prototype.fallback=function(t){var e=Array.from(arguments);e[0]=this.prefix+r[t]+" "+e[0],(0,o.isFunction)(s.log)&&s.log.apply(s,e)},t.prototype.write=function(t){var e=this.logLevel,n=Array.from(arguments).slice(1);this.prefix.length&&n.unshift(this.prefix),40===t&&e<=40?this.writeErr.apply(s,n):30===t&&e<=30?this.writeWarn.apply(s,n):20===t&&e<=20?this.writeInfo.apply(s,n):10===t&&e<=10&&this.writeDebug.apply(s,n)},t}()},function(t,e,n){"use strict";function i(){Array.from||(Array.prototype.from=function(t){return[].slice.call(t)}),Array.prototype.includes||(Array.prototype.includes=function(t){var e,n,i=Object(this),o=parseInt(i.length,10)||0,s=parseInt(arguments[1],10)||0;if(0===o)return!1;for(s>=0?e=s:(e=o+s)<0&&(e=0);ethis.length)&&-1!==this.indexOf(t,e)}),String.prototype.endsWith||(String.prototype.endsWith=function(t,e){var n=this.toString();("number"!=typeof e||!isFinite(e)||Math.floor(e)!==e||e>n.length)&&(e=n.length),e-=t.length;var i=n.indexOf(t,e);return-1!==i&&i===e}),String.prototype.startsWith||(String.prototype.startsWith=function(t,e){return e=e||0,this.substr(e,t.length)===t})}e.__esModule=!0,e.polyfill=i},function(t,e,n){"use strict";function i(t){return t}function o(t){var e="";return t.name?e+=" "+t.name:t.id?e+=" "+t.id:t.nodeName&&(e+=" "+t.nodeName),"[HI"+e+"]"}function s(t){if("string"==typeof t){return document.querySelector(t)}return t}function r(t){return p(t)?[t]:t}function a(t,e){if(e.includes(!1))return t.preventDefault(),!0}function l(t){var e,n,i,o=[];for(t=t.split(/ +(?=(?:(?:[^"]*"){2})*[^"]*$)/g),e=0;ee[n]?-1:e[t]t[n+1]&&e.push(n);return e},c=e.ClapperPlugin=function(){function t(e){i(this,t),this.HI=e,this.l=e.l,this.exports={},this.history=[],this.rollingAvg=[],this.calcHistoryAverage=this.calcHistoryAverage.bind(this),this.startClapper=this.startClapper.bind(this),this.stopClapper=this.stopClapper.bind(this)}return t.prototype.init=function(t){var e=this;t.state;return this.log=new t.Logger(t.settings.logLevel||"INFO","[HI Clapper]"),t.settings.autostartClapper=t.settings.autostartClapper||!1,t.settings.clapThreshold=t.settings.clapThreshold||130,t.settings.autotoggleClapper=t.settings.autotoggleClapper||!0,-1!=t.settings.listenEvents.indexOf("clapper")&&(r?(t.settings.autostartClapper&&this.startClapper(),t.settings.autotoggleClapper&&(t.on("document:hidden",function(){e._started&&e.stopClapper()}),t.on("document:visible",function(){!e._started&&t.settings.autostartClapper&&e.startClapper()}))):(this.startClapper=t.noop,this.stopClapper=t.noop)),this.exports.startClapper=this.startClapper,this.exports.stopClapper=this.stopClapper,this},t.prototype.calcHistoryAverage=function(){var t,e,n=0;for(t=0;t60&&(t.freqData=new Uint8Array(t.analyser.frequencyBinCount),t.analyser.getByteFrequencyData(t.freqData),u=l(t.freqData),h=t.freqData.indexOf(Math.max.apply(null,t.freqData)),t.freqData[h],p=t.freqData[h]-t.rollingAvg[h],s>=240&&h<8&&p>t.HI.settings.clapThreshold&&(d=a(t.freqData.slice(0,10))/a(t.freqData.slice(10,20)),f=a(t.freqData.slice(0,3))/a(t.freqData.slice(3,6)),d<1.8&&f<1.4&&u.length>2&&(c="clap",s<480&&(c="doubleclap",o=g,r<720&&(c="applause")),t.HI._addDown(c),t.HI._handleDownEvents(),t.HI._handleSeqEvents(),t.HI._removeDown(c),i=g)),n=g,i!=g&&(t.history.push(t.freqData),t.history.length>50&&t.history.shift(),t.calcHistoryAverage()))}};this.context=new r,this.scriptProcessor=this.context.createScriptProcessor(1024,1,1),this.analyser=this.context.createAnalyser(),this.freqData=new Uint8Array(this.analyser.frequencyBinCount),this.log.debug(this.l("Starting clap detection")),this._started=!0,navigator.mediaDevices.getUserMedia({audio:!0}).then(e,function(e){t.log.error(t.l("Could not get audio stream"),e)})},t.prototype.stopClapper=function(){this.log.debug(this.l("Stopping clap detection")),this.stream.getAudioTracks().forEach(function(t){t.stop()}),this.stream.getVideoTracks().forEach(function(t){t.stop()}),this.streamSource.disconnect(this.analyser),this.analyser.disconnect(this.scriptProcessor),this.scriptProcessor.disconnect(this.context.destination),this._started=!1},t}();s.default.plugins.push(c)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.ClipboardPlugin=void 0;var o=n(1),s=n(2),r=function(t){return t&&t.__esModule?t:{default:t}}(s);r.default.defaultListenEvents=r.default.defaultListenEvents.concat(["cut","copy","paste","select"]);var a=e.ClipboardPlugin=function(){function t(e){i(this,t),this.HI=e,e._clipboard=this._clipboard.bind(e),this._paste=this._clipboard,this._copy=this._clipboard,this._cut=this._clipboard,e._select=this._select.bind(e),this._input=this._select}return t.prototype.init=function(t){return this},t.prototype._clipboard=function(t){var e,n=t.type+':"';if(this.filter(t)&&(window.clipboardData?e=window.clipboardData.getData("Text"):t.clipboardData&&(e=t.clipboardData.getData("text/plain")),e||"copy"!=t.type&&"cut"!=t.type||(e=this.getSelText()),e)){var i=this._triggerWithSelectors(t.type,[t,e]);i=i.concat(this._triggerWithSelectors(n+e+'"',[t])),(0,o.handlePreventDefault)(t,i)}},t.prototype._select=function(t){var e=t.type+':"';if("select"==t.type)var n=this.getSelText();else if("input"==t.type)var n=t.data||t.target.value;if(this.filter(t)){var i=this._triggerWithSelectors(t.type,[t,n]);n&&(i=i.concat(this._triggerWithSelectors(e+n+'"',[t])),(0,o.handlePreventDefault)(t,i))}},t}();r.default.plugins.push(a)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:50,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"sine",i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.5,o=c.createGain(),s=c.createOscillator();s.connect(o),o.connect(c.destination),s.frequency.value=e,o.gain.value=i,s.type=n,s.start(),setTimeout(function(){s.stop()},t||50)}e.__esModule=!0,e.FeedbackPlugin=void 0;var s=n(2),r=function(t){return t&&t.__esModule?t:{default:t}}(s),a=n(1),l=n(3),c=new(window.AudioContext||window.webkitAudioContext||window.audioContext),u=["keydown","dblclick","wheel:down","wheel:up","wheel:left","wheel:right","pointer:left:down","pointer:middle:down","pointer:right:down","scroll:up","scroll:down","scroll:left","scroll:right"],h=["keydown","dblclick","wheel:down","wheel:up","wheel:left","wheel:right","pointer:down"],p=["pointer:down"],d=e.FeedbackPlugin=function(){function t(e){return i(this,t),this.HI=e,this.l=e.l,this.exports={beep:o},this.vibrationInterval=null,this}return t.prototype.init=function(t){var e=this;return this.log=new t.Logger(t.settings.logLevel||"INFO","[HI Feedback]"),this.lastActivity=new Date,this.timeout=null,t.settings.visualEvents=t.settings.visualEvents||u,t.settings.audioEvents=t.settings.audioEvents||h,t.settings.vibrationEvents=t.settings.vibrationEvents||p,t.settings.visualFeedback=t.settings.visualFeedback||!1,t.settings.audioFeedback=t.settings.audioFeedback||!1,t.settings.vibrationFeedback=t.settings.vibrationFeedback||!1,t.settings.feedbackClass=t.settings.feedbackClass||"event",this.feedbackElem=(0,a.getNode)(t.settings.feedbackElem),this.feedbackElem||(this.feedbackElem=(0,a.getNode)("#hi_feedback")),this.feedbackElem||(t.settings.feedbackElem="#hi_feedback",this.feedbackStyle=document.createElement("style"),this.feedbackStyle.type="text/css",this.feedbackStyle.appendChild(document.createTextNode("\n#hi_feedback {\n position: fixed;\n top: 1em;\n right: 1em;\n align-items: flex-end;\n justify-content: flex-end;\n font-size: 2em;\n display: flex;\n flex-flow: row wrap;\n width: 8em;\n}\n\n#hi_feedback .event {\n transition: all .5s ease-in-out;\n transform-origin: right bottom;\n opacity: 0;\n border: black .15rem solid;\n border-radius: .2em;\n text-align: center;\n padding: .2rem;\n min-width: 1em;\n padding: .2em;\n background-color: rgba(0,0,0,0.7);\n color: #fff;\n z-index: 9999;\n}\n")),document.body.appendChild(this.feedbackStyle),this.feedbackElem=document.createElement("div"),this.feedbackElem.id="hi_feedback",t.elem!==window?t.elem.appendChild(this.feedbackElem):document.body.appendChild(this.feedbackElem)),t.settings.visualFeedback&&t.on(t.settings.visualEvents,this.visualEvent,this),t.settings.audioFeedback&&t.on(t.settings.audioEvents,this.audioEvent,this),t.settings.vibrationFeedback&&(t.on(t.settings.vibrationEvents,this.vibrationEvent,this),t.settings.vibrationEvents.forEach(function(n){n.endsWith("down")&&t.on(n.split("down",1)[0]+"up",e.stopVibration,e)})),this},t.prototype.containsModifiers=function(t,e,n){return l.AllModifiers.includes(t)},t.prototype.visualEvent=function(t){var e=this.HIEvent,n=["cut","copy","paste","select"],i=HI.getDown(),o=document.createElement("div");if(o.classList.add(this.HI.settings.feedbackClass),n.includes(t.type)&&(arguments.length<=1?0:arguments.length-1))o.innerHTML=e+":"+(arguments.length<=1?void 0:arguments[1]);else if("keydown"==t.type)e=arguments.length<=1?void 0:arguments[1],o.innerHTML=e,l.AllModifiers.includes(e)&&!i.includes("-")?o.innerHTML=e.toLowerCase():HI.state.down.some(this.containsModifiers)&&(o.innerHTML=i);else if(e.startsWith("pointer")){var s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("width",100),s.setAttribute("height",100),s.style.position="fixed",s.style.top=t.clientY-50+"px",s.style.left=t.clientX-50+"px",s.style.transition="all .33s ease-out",s.style.transform="scale(0.1)",s.style.zIndex=1e4,s.innerHTML='',document.body.appendChild(s),setTimeout(function(){s.style.transform="scale(2)",s.style.opacity=0,setTimeout(function(){s.parentNode.removeChild(s)},500)},10),e.includes(":down")&&(e=e.substr(0,e.length-5)),o.innerHTML=e}else i.length?o.innerHTML=i:o.innerHTML=e;o.style.opacity=1,this.feedbackElem.appendChild(o),setTimeout(function(){o.style.opacity=0,showEventTimeout=setTimeout(function(){o.parentNode.removeChild(o)},500)},1e3)},t.prototype.audioEvent=function(t){o(33,500,"triangle")},t.prototype.startVibration=function(){navigator.vibrate(150)},t.prototype.stopVibration=function(){clearInterval(this.vibrationInterval),navigator.vibrate(0)},t.prototype.vibrationEvent=function(t){navigator.vibrate(150),clearInterval(this.vibrationInterval),this.vibrationInterval=setInterval(this.startVibration,100)},t}();r.default.plugins.push(d)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.GamepadPlugin=void 0;var o=(n(1),n(2)),s=function(t){return t&&t.__esModule?t:{default:t}}(o),r=function(t){for(var e=navigator.getGamepads(),n=0;nthis.idleTimeout?this.HI.trigger("idle",this.lastActivity):this.timeout=setTimeout(this.idleCheck,this.idleCheckInterval)},t}();r.default.plugins.push(a)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.PointerPlugin=void 0;var o,s=n(1),r=n(2),a=function(t){return t&&t.__esModule?t:{default:t}}(r),l=["pan","mousedown","mouseup","touchstart","touchend","touchcancel","wheel"],c=["pointermove"];a.default.defaultListenEvents=a.default.defaultListenEvents.concat(l),c=["mousemove","touchmove"];var u=e.PointerPlugin=function(){function t(e){var n=this;i(this,t),this.HI=e,["_click","_dragendPointerup","_pointerdown","_pointerup","_pointercancel","_pointerMoveCheck","_trackMotion","_wheel"].forEach(function(t){e[t]=n[t].bind(e)}),e.on("hold",function(t){t.includes("pointer:")&&((0,s.removeListeners)(window,c,e._pointerMoveCheck,!0),(0,s.addListeners)(window,c,e._pointerMoveCheck,!0))}),e._mousedown=e._pointerdown,e._touchstart=e._pointerdown,e._mouseup=e._pointerup,e._touchend=e._pointerup,e._touchcancel=e._pointercancel,e._tap=e._click,e.on("hi:resetstates",this._resetStates,e),e.on("hi:removedown",function(t){(0,s.removeListeners)(window,c,e._pointerMoveCheck,!0)}),e.on("hold",this._holdCheck,e)}return t.prototype.init=function(t){var e=t.state;return e.multitap=0,e.pointerCount=0,e.pointers={},e.scrollX=0,e.scrollY=0,(0,s.removeListeners)(window,c,t._pointerMoveCheck,!0),(0,s.removeListeners)(t.elem,c,t._trackMotion,!0),this.exports={mouse:this.mouse},this},t.prototype._resetStates=function(){(0,s.removeListeners)(window,c,this._pointerMoveCheck,!0),(0,s.removeListeners)(this.elem,c,this._trackMotion,!0),this.state.pointers={},this.state.pointerCount=0},t.prototype._holdCheck=function(t){t.includes("pointer:")&&((0,s.removeListeners)(window,c,this._pointerMoveCheck,!0),(0,s.addListeners)(window,c,this._pointerMoveCheck,!0))},t.prototype._pointerMoveCheck=function(t){var e,n,i,o,r=this.settings.moveThreshold,a=this.state.pointers,l=t.touches;if(t.pointerType||"mousemove"==t.type)i=t.pointerId||1;else if(l&&l.length)for(var u=0;ur||Math.abs(o.y-n)>r)&&(clearTimeout(this.state.holdTimeout),(0,s.removeListeners)(window,c,this._pointerMoveCheck,!0)))},t.prototype._trackMotion=function(t){var e,n,i=[],o="pan",r={},a=this.state.pointers,l=t.touches;if(t.pointerType||"mousemove"==t.type){if(e=t.pointerId||1,!(n=a[e]))return;n.event=t}else if(l&&l.length)for(var c=0;c1?(o="multitouch:",i=i.concat(this._triggerWithSelectors(o+"pan",[t,a])),i=i.concat(this._triggerWithSelectors(o+this.state.pointerCount+":pan",[t,a]))):i=i.concat(this._triggerWithSelectors(o,[t,r])),(0,s.handlePreventDefault)(t,i))},t.prototype._dragendPointerup=function(t){var e=t.pointerId||1,n=this.state.pointers,i={bubbles:!0,cancelable:!0,clientX:t.clientX,clientY:t.clientY,isPrimary:!0,layerX:t.layerX,layerY:t.layerY,offsetX:t.offsetX,offsetY:t.offsetY,pageX:t.pageX,pageY:t.pageY,pointerId:e,pressure:t.pressure||0,relatedTarget:window,screenX:t.screenX,screenY:t.screenY,target:t.target,tiltX:t.tiltX||0,tiltY:t.tiltY||0,view:window,x:t.x,y:t.y};new MouseEvent("mouseup",i);n[e]&&(this._pointerup(t),window.removeEventListener("dragend",this._dragendPointerup,!0))},t.prototype._pointerdown=function(t){var e,n,i=this.state,r=this.mouse(t),a=t.changedTouches,l=t.pointerType,u="pointer",h=":down";if("mousedown"!=t.type||!o){if(l||"mousedown"==t.type)e=t.pointerId||1,i.pointers[e]={x:t.clientX,y:t.clientY,event:t,timestamp:Date.now()};else if(a&&a.length){for(var p=0;p1||this.settings.listenEvents.includes("pan"))&&((0,s.removeListeners)(window,c,this._trackMotion,!0),(0,s.addListeners)(window,c,this._trackMotion,!0)),this._addDown(u+":"+r.buttonName),this._resetSeqTimeout(),this.filter(t)&&(n=this._triggerWithSelectors(u+h,[t]),void 0!==r.buttonName&&(u+=":"+r.buttonName,n=n.concat(this._triggerWithSelectors(u+h,[t]))),n=n.concat(this._handleDownEvents(t)),(0,s.handlePreventDefault)(t,n))}},t.prototype._pointerup=function(t){var e,n,i,r,a=this.state,l=this.settings.moveThreshold,u=t.clientX,h=t.clientY,p=a.pointers,d={},f=t.changedTouches,g=t.pointerType,v=this.settings.swipeThreshold,m="pointer:",w=this.filter(t);if("mouseup"==t.type&&o)return void(o=!1);if(g||"mouseup"==t.type)e=t.pointerId||1;else if(f&&f.length)for(var y=0;yMath.abs(d.y)?d.x>v?i+="left":d.x<-v&&(i+="right"):d.y>v?i+="up":d.y<-v&&(i+="down")),o=!1,delete p[e],a.pointerCount--,a.pointerCount>0?d.x0?n=n.concat(this._doDownEvent("wheel:down",t)):t.deltaY<0&&(n=n.concat(this._doDownEvent("wheel:up",t))),t.deltaZ>0?n=n.concat(this._doDownEvent("wheel:out",t)):t.deltaZ<0&&(n=n.concat(this._doDownEvent("wheel:in",t))),t.deltaX>0?(n=n.concat(this._doDownEvent("wheel:right",t)),this.isDown("shift")&&(n=n.concat(this._triggerWithSelectors("wheel:right",[t])))):t.deltaX<0&&(n=n.concat(this._doDownEvent("wheel:left",t)),this.isDown("shift")&&(n=n.concat(this._triggerWithSelectors("wheel:left",[t])))),(0,s.handlePreventDefault)(t,n)}},t.prototype.mouse=function(t){var e={type:t.type};return"mousemove"!=t.type&&"wheel"!=t.type&&(0===t.button?(e.left=!0,e.buttonName="left"):1===t.button?(e.middle=!0,e.buttonName="middle"):2===t.button?(e.right=!0,e.buttonName="right"):3===t.button?(e.back=!0,e.buttonName="back"):4===t.button?(e.forward=!0,e.buttonName="forward"):5===t.button?(e.forward=!0,e.buttonName="eraser"):e.buttonName=t.button),e.button=t.button,e},t}();a.default.plugins.push(u)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.ScrollPlugin=void 0;var o=n(1),s=n(2),r=function(t){return t&&t.__esModule?t:{default:t}}(s);r.default.defaultListenEvents.push("scroll");var a=e.ScrollPlugin=function(){function t(e){i(this,t),this.HI=e,e._scroll=(0,o.debounce)(this._scroll.bind(e),50),e.on("hi:resetstates",this._resetStates,e)}return t.prototype.init=function(t){var e=t.state;return e.scrollX=0,e.scrollY=0,this},t.prototype._resetStates=function(){this.state.scrollX=0,this.state.scrollY=0},t.prototype._scroll=function(t){var e,n,i,s=this.state,r=t.target,a=r.scrollLeft,l=r.scrollTop;r.scrollingElement&&(a=r.scrollingElement.scrollLeft,l=r.scrollingElement.scrollTop),n=a-s.scrollX,0===(i=l-s.scrollY)&&0===n||(e=this._triggerWithSelectors(t.type,[t,{x:n,y:i}]),void 0!==a&&a!==s.scrollX&&(n=Math.abs(n),e=a>s.scrollX?e.concat(this._triggerWithSelectors(t.type+":right",[t,n])):e.concat(this._triggerWithSelectors(t.type+":left",[t,n])),s.scrollX=a),void 0!==l&&l!==s.scrollY&&(i=Math.abs(i),e=l>s.scrollY?e.concat(this._triggerWithSelectors(t.type+":down",[t,i])):e.concat(this._triggerWithSelectors(t.type+":up",[t,i])),s.scrollY=l),(0,o.handlePreventDefault)(t,e))},t}();r.default.plugins.push(a)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.SpeechRecPlugin=void 0;var o=n(1),s=n(2),r=function(t){return t&&t.__esModule?t:{default:t}}(s);r.default.defaultListenEvents.push("speech");var a=window.SpeechRecognition||window.webkitSpeechRecognition||window.mozSpeechRecognition||window.msSpeechRecognition||window.oSpeechRecognition,l=e.SpeechRecPlugin=function(){function t(e){return i(this,t),this.exports={startSpeechRec:this.startSpeechRec.bind(this),stopSpeechRec:this.stopSpeechRec.bind(this)},this.HI=e,this.l=e.l,this.log=new e.Logger(e.settings.logLevel||"INFO","[HI SpeechRec]"),this._rtSpeech=[],this._rtSpeechTimer=null,this}return t.prototype.init=function(){var t=this,e=this.HI,n=e.settings;return n.autostartSpeech=n.autostartSpeech||!1,n.listenEvents.includes("speech")&&(a?(n.autostartSpeech&&this.startSpeechRec(),e.on("document:hidden",function(){t._started&&t.stopSpeechRec()}),e.on("document:visible",function(){!t._started&&n.autostartSpeech&&t.startSpeechRec()})):(this.startSpeechRec=o.noop,this.stopSpeechRec=o.noop)),this},t.prototype.startSpeechRec=function(){var t=this,e=this.HI;this._recognition=new a,this.log.debug(this.l("Starting speech recognition"),this._recognition),this._recognition.lang=e.settings.speechLang||navigator.language||"en-US",this._recognition.continuous=!0,this._recognition.interimResults=!0,this._recognition.onresult=function(e){for(var n=e.resultIndex;n