/*! Hammer.JS - v2.0.7 - 2016-04-22
 * http://hammerjs.github.io/
 *
 * Copyright (c) 2016 Jorik Tangelder;
 * Licensed under the MIT license */

/**
         * @type {Number}
         * @default 1
         */

/**
         * Disable the Windows Phone grippers when pressing an element.
         * @type {String}
         * @default 'none'
         */

/**
         * Disables text selection to improve the dragging gesture. Mainly for desktop browsers.
         * @type {String}
         * @default 'none'
         */

/**
         * Disables the default callout shown when you touch and hold a touch target.
         * On iOS, when you touch and hold a touch target such as a link, Safari displays
         * a callout containing information about the link. This property allows you to disable that callout.
         * @type {String}
         * @default 'none'
         */

/**
         * Overrides the highlight color shown when the user taps a link or a JavaScript
         * clickable element in iOS. This property obeys the alpha value, if specified.
         * @type {String}
         * @default 'rgba(0,0,0,0)'
         */

/**
         * Specifies that an entire element should be draggable instead of its contents. Mainly for desktop browsers.
         * @type {String}
         * @default 'none'
         */

/**
         * Specifies whether zooming is enabled. Used by IE10>
         * @type {String}
         * @default 'none'
         */

/**
     * @namespace
     * @memberof AttrRecognizer
     */

/**
     * @namespace
     * @memberof PanRecognizer
     */

/**
     * @namespace
     * @memberof PinchRecognizer
     */

/**
     * @namespace
     * @memberof PressRecognizer
     */

/**
     * @namespace
     * @memberof RotateRecognizer
     */

/**
     * @namespace
     * @memberof SwipeRecognizer
     */

/**
     * @type {Boolean}
     * @default true
     */

/**
     * @virtual
     * @type {Object}
     */

/**
     * Check that all the require failure recognizers has failed,
     * if true, it emits a gesture event,
     * otherwise, setup the state to FAILED.
     * @param {Object} input
     */

/**
     * Default recognizer setup when calling `Hammer()`
     * When creating a new Manager these will be skipped.
     * @type {Array}
     */

/**
     * EXPERIMENTAL FEATURE -- can be removed/changed
     * Change the parent input target element.
     * If Null, then it is being set the to main element.
     * @type {Null|EventTarget}
     * @default null
     */

/**
     * Process the input and return the state for the recognizer
     * @memberof AttrRecognizer
     * @param {Object} input
     * @returns {*} State
     */

/**
     * Some CSS properties can be used to improve the working of Hammer.
     * Add them to this method and they will be set when creating a new Manager.
     * @namespace
     */

/**
     * The value for the touchAction property/fallback.
     * When set to `compute` it will magically set the correct value based on the added recognizers.
     * @type {String}
     * @default compute
     */

/**
     * Used to check if it the recognizer receives valid input, like input.distance > 10.
     * @memberof AttrRecognizer
     * @param {Object} input
     * @returns {Boolean} recognized
     */

/**
     * You should use `tryEmit` instead of `emit` directly to check
     * that all the needed recognizers has failed before emitting.
     * @param {Object} input
     */

/**
     * add a recognizer to the manager
     * existing recognizers with the same event name will be removed
     * @param {Recognizer} recognizer
     * @returns {Recognizer|Manager}
     */

/**
     * bind event
     * @param {String} events
     * @param {Function} handler
     * @returns {EventEmitter} this
     */

/**
     * bind the events
     */

/**
     * call preventDefault to prevent the browser's default behavior (scrolling in most cases)
     * @param {Object} srcEvent
     */

/**
     * called when the gesture isn't allowed to recognize
     * like when another is being recognized or it is disabled
     * @virtual
     */

/**
     * can we emit?
     * @returns {boolean}
     */

/**
     * compute the value for the touchAction property based on the recognizer's settings
     * @returns {String} value
     */

/**
     * destroy the manager and unbinds all events
     * it doesn't unbind dom events, that is the user own responsibility
     */

/**
     * drop the requireFailure link. it does not remove the link on the other recognizer.
     * @param {Recognizer} otherRecognizer
     * @returns {Recognizer} this
     */

/**
     * drop the simultaneous link. it doesnt remove the link on the other recognizer.
     * @param {Recognizer} otherRecognizer
     * @returns {Recognizer} this
     */

/**
     * emit event to the listeners
     * @param {String} event
     * @param {Object} data
     */

/**
     * force an input class
     * @type {Null|Function}
     * @default null
     */

/**
     * get a recognizer by its event name.
     * @param {Recognizer|String} recognizer
     * @returns {Recognizer|Null}
     */

/**
     * handle mouse and touch events
     * @param {Hammer} manager
     * @param {String} inputEvent
     * @param {Object} inputData
     */

/**
     * handle mouse events
     * @param {Object} ev
     */

/**
     * has require failures boolean
     * @returns {boolean}
     */

/**
     * if the recognizer can recognize simultaneous with an other recognizer
     * @param {Recognizer} otherRecognizer
     * @returns {Boolean}
     */

/**
     * just re-set the touchAction value
     */

/**
     * recognize simultaneous with an other recognizer.
     * @param {Recognizer} otherRecognizer
     * @returns {Recognizer} this
     */

/**
     * recognizer can only run when an other is failing
     * @param {Recognizer} otherRecognizer
     * @returns {Recognizer} this
     */

/**
     * remove a recognizer by name or instance
     * @param {Recognizer|String} recognizer
     * @returns {Manager}
     */

/**
     * remove the event listeners
     */

/**
     * return the preferred touch-action
     * @virtual
     * @returns {Array}
     */

/**
     * return the state of the recognizer
     * the actual recognizing happens in this method
     * @virtual
     * @param {Object} inputData
     * @returns {Const} STATE
     */

/**
     * run the recognizers!
     * called by the inputHandler function on every movement of the pointers (touches)
     * it walks through all the recognizers and tries to detect the gesture that is being made
     * @param {Object} inputData
     */

/**
     * set if DOM events are being triggered.
     * But this is slower and unused by simple implementations, so disabled by default.
     * @type {Boolean}
     * @default false
     */

/**
     * set options
     * @param {Object} options
     * @return {Recognizer}
     */

/**
     * set options
     * @param {Object} options
     * @returns {Manager}
     */

/**
     * set the touchAction value on the element or enable the polyfill
     * @param {String} value
     */

/**
     * should handle the inputEvent data and trigger the callback
     * @virtual
     */

/**
     * stop recognizing for this session.
     * This session will be discarded, when a new [input]start event is fired.
     * When forced, the recognizer cycle is stopped immediately.
     * @param {Boolean} [force]
     */

/**
     * this method is called on each input cycle and provides the preventing of the browser behavior
     * @param {Object} input
     */

/**
     * unbind event, leave emit blank to remove all handlers
     * @param {String} events
     * @param {Function} [handler]
     * @returns {EventEmitter} this
     */

/**
     * unbind the events
     */

/**
     * update the recognizer
     * @param {Object} inputData
     */

/**
 * @const {string}
 */

/**
 * @this {TouchInput}
 * @param {Object} ev
 * @param {Number} type flag
 * @returns {undefined|Array} [all, changed]
 */

/**
 * A tap is ecognized when the pointer is doing a small tap/click. Multiple taps are recognized if they occur
 * between the given interval and position. The delay option can be used to recognize multi-taps without firing
 * a single tap.
 *
 * The eventData from the emitted event contains the property `tapCount`, which contains the amount of
 * multi-taps being recognized.
 * @constructor
 * @extends Recognizer
 */

/**
 * Combined touch and mouse input
 *
 * Touch has a higher priority then mouse, and while touching no mouse events are allowed.
 * This because touch devices also emit mouse events while doing a touch.
 *
 * @constructor
 * @extends Input
 */

/**
 * Manager
 * @param {HTMLElement} element
 * @param {Object} [options]
 * @constructor
 */

/**
 * Mouse events input
 * @constructor
 * @extends Input
 */

/**
 * Multi-user touch events input
 * @constructor
 * @extends Input
 */

/**
 * Pan
 * Recognized when the pointer is down and moved in the allowed direction.
 * @constructor
 * @extends AttrRecognizer
 */

/**
 * Pinch
 * Recognized when two or more pointers are moving toward (zoom-in) or away from each other (zoom-out).
 * @constructor
 * @extends AttrRecognizer
 */

/**
 * Pointer events input
 * @constructor
 * @extends Input
 */

/**
 * Press
 * Recognized when the pointer is down for x ms without any movement.
 * @constructor
 * @extends Recognizer
 */

/**
 * Recognizer
 * Every recognizer needs to extend from this class.
 * @constructor
 * @param {Object} options
 */

/**
 * Recognizer flow explained; *
 * All recognizers have the initial state of POSSIBLE when a input session starts.
 * The definition of a input session is from the first input until the last input, with all it's movement in it. *
 * Example session for mouse-input: mousedown -> mousemove -> mouseup
 *
 * On each recognizing cycle (see Manager.recognize) the .recognize() method is executed
 * which determines with state it should be.
 *
 * If the recognizer has the state FAILED, CANCELLED or RECOGNIZED (equals ENDED), it is reset to
 * POSSIBLE to give it another change on the next cycle.
 *
 *               Possible
 *                  |
 *            +-----+---------------+
 *            |                     |
 *      +-----+-----+               |
 *      |           |               |
 *   Failed      Cancelled          |
 *                          +-------+------+
 *                          |              |
 *                      Recognized       Began
 *                                         |
 *                                      Changed
 *                                         |
 *                                  Ended/Recognized
 */

/**
 * Rotate
 * Recognized when two or more pointer are moving in a circular motion.
 * @constructor
 * @extends AttrRecognizer
 */

/**
 * Simple way to create a manager with a default set of recognizers.
 * @param {HTMLElement} element
 * @param {Object} [options]
 * @constructor
 */

/**
 * Swipe
 * Recognized when the pointer is moving fast (velocity), with enough distance in the allowed direction.
 * @constructor
 * @extends AttrRecognizer
 */

/**
 * This recognizer is just used as a base for the simple attribute recognizers.
 * @constructor
 * @extends Recognizer
 */

/**
 * Touch Action
 * sets the touchAction property or uses the js alternative
 * @param {Manager} manager
 * @param {String} value
 * @constructor
 */

/**
 * Touch events input
 * @constructor
 * @extends Input
 */

/**
 * add/remove the css properties as defined in manager.options.cssProps
 * @param {Manager} manager
 * @param {Boolean} add
 */

/**
 * addEventListener with multiple events at once
 * @param {EventTarget} target
 * @param {String} types
 * @param {Function} handler
 */

/**
 * calculate the absolute distance between two points
 * @param {Object} p1 {x, y}
 * @param {Object} p2 {x, y}
 * @param {Array} [props] containing x and y keys
 * @return {Number} distance
 */

/**
 * calculate the angle between two coordinates
 * @param {Object} p1
 * @param {Object} p2
 * @param {Array} [props] containing x and y keys
 * @return {Number} angle
 */

/**
 * calculate the rotation degrees between two pointersets
 * @param {Array} start array of pointers
 * @param {Array} end array of pointers
 * @return {Number} rotation
 */

/**
 * calculate the scale factor between two pointersets
 * no scale is 1, and goes down to 0 when pinched together, and bigger when pinched out
 * @param {Array} start array of pointers
 * @param {Array} end array of pointers
 * @return {Number} scale
 */

/**
 * calculate the velocity between two points. unit is in px per ms.
 * @param {Number} deltaTime
 * @param {Number} x
 * @param {Number} y
 * @return {Object} velocity `x` and `y`
 */

/**
 * convert array-like objects to real arrays
 * @param {Object} obj
 * @returns {Array}
 */

/**
 * create a simple clone from the input used for storage of firstInput and firstMultiple
 * @param {Object} input
 * @returns {Object} clonedInputData
 */

/**
 * create new input type manager
 * @param {Manager} manager
 * @param {Function} callback
 * @returns {Input}
 * @constructor
 */

/**
 * create new input type manager
 * called by the Manager constructor
 * @param {Hammer} manager
 * @returns {Input}
 */

/**
 * default settings
 * @namespace
 */

/**
 * direction cons to string
 * @param {Const} direction
 * @returns {String}
 */

/**
 * extend object.
 * means that properties in dest will be overwritten by the ones in src.
 * @param {Object} dest
 * @param {Object} src
 * @param {Boolean} [merge=false]
 * @returns {Object} dest
 */

/**
 * extend object.
 * means that properties in dest will be overwritten by the ones in src.
 * @param {Object} target
 * @param {...Object} objects_to_assign
 * @returns {Object} target
 */

/**
 * extend the data with some usable properties like scale, rotate, velocity etc
 * @param {Object} manager
 * @param {Object} input
 */

/**
 * find if a array contains the object using indexOf or a simple polyFill
 * @param {Array} src
 * @param {String} find
 * @param {String} [findByKey]
 * @return {Boolean|Number} false when not found, or the index
 */

/**
 * find if a node is in the given parent
 * @method hasParent
 * @param {HTMLElement} node
 * @param {HTMLElement} parent
 * @return {Boolean} found
 */

/**
 * get a recognizer by name if it is bound to a manager
 * @param {Recognizer|String} otherRecognizer
 * @param {Recognizer} recognizer
 * @returns {Recognizer}
 */

/**
 * get a unique id
 * @returns {number} uniqueId
 */

/**
 * get a usable string, used as event postfix
 * @param {Const} state
 * @returns {String} state
 */

/**
 * get the center of all the pointers
 * @param {Array} pointers
 * @return {Object} center contains `x` and `y` properties
 */

/**
 * get the direction between two points
 * @param {Number} x
 * @param {Number} y
 * @return {Number} direction
 */

/**
 * get the prefixed property
 * @param {Object} obj
 * @param {String} property
 * @returns {String|Undefined} prefixed
 */

/**
 * get the window object of an element
 * @param {HTMLElement} element
 * @returns {DocumentView|Window}
 */

/**
 * handle input events
 * @param {Manager} manager
 * @param {String} eventType
 * @param {Object} input
 */

/**
 * if the argument is an array, we want to execute the fn on each entry
 * if it aint an array we don't want to do a thing.
 * this is used by all the methods that accept a single and array argument.
 * @param {*|Array} arg
 * @param {String} fn
 * @param {Object} [context]
 * @returns {Boolean}
 */

/**
 * let a boolean value also be a function that must return a boolean
 * this first item in args will be used as the context
 * @param {Boolean|Function} val
 * @param {Array} [args]
 * @returns {Boolean}
 */

/**
 * merge the values from src in the dest.
 * means that properties that exist in dest will not be overwritten by src
 * @param {Object} dest
 * @param {Object} src
 * @returns {Object} dest
 */

/**
 * removeEventListener with multiple events at once
 * @param {EventTarget} target
 * @param {String} types
 * @param {Function} handler
 */

/**
 * set a timeout with a given scope
 * @param {Function} fn
 * @param {Number} timeout
 * @param {Object} context
 * @returns {number}
 */

/**
 * simple class inheritance
 * @param {Function} child
 * @param {Function} base
 * @param {Object} [properties]
 */

/**
 * simple function bind
 * @param {Function} fn
 * @param {Object} context
 * @returns {Function}
 */

/**
 * small indexOf wrapper
 * @param {String} str
 * @param {String} find
 * @returns {Boolean} found
 */

/**
 * split string on whitespace
 * @param {String} str
 * @returns {Array} words
 */

/**
 * trigger dom event
 * @param {String} event
 * @param {Object} data
 */

/**
 * unique array with objects based on a key (like 'id') or just by the array's value
 * @param {Array} src [{id:1},{id:2},{id:1}]
 * @param {String} [key]
 * @param {Boolean} [sort=False]
 * @returns {Array} [{id:1},{id:2}]
 */

/**
 * use the val2 when val1 is undefined
 * @param {*} val1
 * @param {*} val2
 * @returns {*}
 */

/**
 * velocity is calculated every x ms
 * @param {Object} session
 * @param {Object} input
 */

/**
 * walk objects and arrays
 * @param {Object} obj
 * @param {Function} iterator
 * @param {Object} context
 */

/**
 * when the touchActions are collected they are not a valid value, so we need to clean things up. *
 * @param {String} actions
 * @returns {*}
 */

/**
 * wrap a method with a deprecation warning and stack trace
 * @param {Function} method
 * @param {String} name
 * @param {String} message
 * @returns {Function} A new function wrapping the supplied method.
 */

/***/

//      that is being recognized.

//      this can be setup with the `recognizeWith()` method on the recognizer.

// 'panstart' and 'panmove'

// 1

// 1.   allow if the session is NOT forced stopped (see the .stop() method)

// 2

// 2.   allow if we still haven't recognized a gesture in this session, or the this recognizer is the one

// 3

// 3.   allow if the recognizer is allowed to run simultaneous with the current recognized recognizer.

// Clean up existing event listeners and reinitialize

// IE10 has prefixed support, and case-sensitive

// If css.supports is not supported but there is native touch-action assume it supports

// Options that need a little more setup

// RecognizerClass, options, [recognizeWith, ...], [requireFailure, ...]

// a minimal movement is ok, but keep it low

// additional event(panleft, panright, pinchin, pinchout...)

// all values. This is the case for IE 10 and 11.

// also update the touchAction, in case something changed about the directions/enabled state

// and we've reached an end event, so a tap is possible

// cleanup removed touches

// collect touches

// compute scale, rotation etc

// current active recognizer. but only if we don't already have an active recognizer

// default is enable true

// emit secret event

// filter changed touches to only contain touches that exist in the collected target ids

// find out if we are allowed try to recognize the input for this one.

// find out the touch-action by the event handlers

// find the correct target

// for different directions, e.g. horizontal pan but vertical swipe?)

// get target touches from touches

// if both pan-x and pan-y are set (different recognizers

// if no recognizer is detecting a thing, it is set to `null`

// if the recognizer has been recognizing the input as a valid gesture, we want to store this one as the

// if the touch action did prevented once this session

// in IE10 the pointer types is defined as an enum

// is is enabled and allow recognizing?

// it not found, so the pointer hasn't been down (so it's probably a hover)

// it's failing anyway

// jshint ignore:line

// let's make sure this recognizer exists

// like 'touchstart, mouseup, pointerdown'

// lock to axis?

// make a new copy of the inputData

// make a simple copy of the pointers because we will get a reference if we don't

// manipulation

// max time between the multi-tap taps

// max time of the pointer to be down (like finger on the screen)

// merge targetTouches with changedTargetTouches so it contains ALL touches, including 'end' and 'cancel'

// minimal time of the pointer to be pressed

// mouse must be down

// mousedown state

// no failing requirements, immediately trigger the tap event

// no handlers, so skip it all

// no need to loop when only one touch

// none

// on cancel input and we've recognized before, return STATE_CANCELLED

// on start we want to have the left mouse button down

// or wait as long as the multitap interval to trigger

// or when we're in a new session

// pan-x OR pan-y

// panend and pancancel

// previous time and center,

// recognizers will work, since the browser would handle all panning

// remove existing

// remove from the store

// reset when the last recognizer is recognized

// reset when we've reached the end

// run the touch-action polyfill

// should we handle the touch events?

// simple 'eventName' events

// smaller wrapper around the handler, for the scope and the enabled state of the manager,

// so the recognizer's state needs to be BEGAN, CHANGED, ENDED or RECOGNIZED

// so trigger an event

// so we can change the inputData without messing up the other recognizers

// so when disabled the input events are completely bypassed.

// source event is the normalized value of the domEvents

// start and mouse must be down

// store the first input to calculate the distance and direction

// the recognizer has recognized a gesture

// this holds the recognizer that is being recognized.

// to compute scale and rotation we need to store the multiple touches

// update the event in the store

// use latest velocity info if it doesn't overtake a minimum period

// used for tap counting

// we also want to trigger dom events

// we need none (as otherwise with pan-x pan-y combined none of these

// we only allow little movement

// we only need clientXY for the calculations

// when done, reset the started state

// when there is only one touch, the process can be simplified

// when we're in a touch event, record touches to  de-dupe synthetic mouse event

//do not prevent defaults if this is a tap gesture
