var __extends = (this && this.__extends) || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
(function (factory) {
    if (typeof module === 'object' && typeof module.exports === 'object') {
        var v = factory(require, exports); if (v !== undefined) module.exports = v;
    }
    else if (typeof define === 'function' && define.amd) {
        define(["require", "exports", '../util/util', '../gestures/slide-edge-gesture'], factory);
    }
})(function (require, exports) {
    "use strict";
    var util_1 = require('../util/util');
    var slide_edge_gesture_1 = require('../gestures/slide-edge-gesture');
    var SwipeBackGesture = (function (_super) {
        __extends(SwipeBackGesture, _super);
        function SwipeBackGesture(element, options, _nav, gestureCtlr) {
            _super.call(this, element, util_1.assign({
                direction: 'x',
                maxEdgeStart: 75,
                gesture: gestureCtlr.create('goback-swipe', {
                    priority: 20,
                })
            }, options));
            this._nav = _nav;
        }
        SwipeBackGesture.prototype.canStart = function (ev) {
            return (this._nav.canSwipeBack() &&
                _super.prototype.canStart.call(this, ev));
        };
        SwipeBackGesture.prototype.onSlideBeforeStart = function (ev) {
            console.debug('swipeBack, onSlideBeforeStart', ev.type);
            this._nav.swipeBackStart();
        };
        SwipeBackGesture.prototype.onSlide = function (slide) {
            var stepValue = (slide.distance / slide.max);
            console.debug('swipeBack, onSlide, distance', slide.distance, 'max', slide.max, 'stepValue', stepValue);
            this._nav.swipeBackProgress(stepValue);
        };
        SwipeBackGesture.prototype.onSlideEnd = function (slide, ev) {
            var shouldComplete = (Math.abs(slide.velocity) > 0.2 || Math.abs(slide.delta) > Math.abs(slide.max) * 0.5);
            var currentStepValue = (slide.distance / slide.max);
            console.debug('swipeBack, onSlideEnd, shouldComplete', shouldComplete, 'currentStepValue', currentStepValue);
            this._nav.swipeBackEnd(shouldComplete, currentStepValue);
        };
        return SwipeBackGesture;
    }(slide_edge_gesture_1.SlideEdgeGesture));
    exports.SwipeBackGesture = SwipeBackGesture;
});
