var _a, _b;
import { __decorate, __extends } from "tslib";
import Component from 'vue-class-component';
import { Emit, Prop } from 'vue-property-decorator';
import { I18N_NAME } from '../../filters/filter-names';
import { i18nFilter } from '../../filters/i18n/i18n';
import ScrollToPlugin, { ScrollToDuration } from '../../utils/scroll-to/scroll-to';
import { ModulVue } from '../../utils/vue/vue';
import { ICON_NAME, SCROLL_TOP_NAME } from '../component-names';
import { MIcon } from '../icon/icon';
import WithRender from './scroll-top.html?style=./scroll-top.scss';
export var MScrollTopPosition;
(function (MScrollTopPosition) {
    MScrollTopPosition["Fixed"] = "fixed";
    MScrollTopPosition["Relative"] = "relative";
})(MScrollTopPosition || (MScrollTopPosition = {}));
var MScrollTop = /** @class */ (function (_super) {
    __extends(MScrollTop, _super);
    function MScrollTop() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.show = false;
        _this.scrollTopBreakPoint = window.innerHeight * 0.2;
        return _this;
    }
    MScrollTop.prototype.onClick = function (event) {
        this.$scrollTo.goToTop(this.duration);
    };
    MScrollTop.prototype.created = function () {
        if (this.isPositionFixed) {
            this.$modul.event.$on('scroll', this.onScroll);
        }
        else {
            this.show = true;
        }
    };
    MScrollTop.prototype.onScroll = function () {
        var scrollPosition = window.pageYOffset;
        this.show = scrollPosition > this.scrollTopBreakPoint;
    };
    Object.defineProperty(MScrollTop.prototype, "isPositionFixed", {
        get: function () {
            return this.position === MScrollTopPosition.Fixed;
        },
        enumerable: false,
        configurable: true
    });
    __decorate([
        Prop({
            default: MScrollTopPosition.Fixed,
            validator: function (value) {
                return value === MScrollTopPosition.Fixed ||
                    value === MScrollTopPosition.Relative;
            }
        })
    ], MScrollTop.prototype, "position", void 0);
    __decorate([
        Prop({
            default: ScrollToDuration.Regular,
            validator: function (value) {
                return value === ScrollToDuration.Regular ||
                    value === ScrollToDuration.Long;
            }
        })
    ], MScrollTop.prototype, "duration", void 0);
    __decorate([
        Emit('click')
    ], MScrollTop.prototype, "onClick", null);
    MScrollTop = __decorate([
        WithRender,
        Component({
            components: (_a = {},
                _a[ICON_NAME] = MIcon,
                _a),
            filters: (_b = {},
                _b[I18N_NAME] = i18nFilter,
                _b)
        })
    ], MScrollTop);
    return MScrollTop;
}(ModulVue));
export { MScrollTop };
var ScrollTopPlugin = {
    install: function (v, options) {
        v.use(ScrollToPlugin);
        v.component(SCROLL_TOP_NAME, MScrollTop);
    }
};
export default ScrollTopPlugin;
//# sourceMappingURL=scroll-top.js.map