! function(e, t) {
    "function" == typeof define && define.amd ? define(t) : "object" == typeof exports ? module.exports = t(require, exports, module) : e.ScrollReveal = t()
}(this, function(e, t, n) {
    return function() {
        "use strict";
        var e, t, n;
        this.ScrollReveal = function() {
            function i(n) {
                return "undefined" == typeof this || Object.getPrototypeOf(this) !== i.prototype ? new i(n) : (e = this, e.tools = new t, e.isSupported() ? (e.tools.extend(e.defaults, n || {}), o(e.defaults), e.store = {
                    elements: {},
                    containers: []
                }, e.sequences = {}, e.history = [], e.uid = 0, e.initialized = !1) : "undefined" != typeof console && null !== console, e)
            }

            function o(t) {
                var n = t.container;
                return n && "string" == typeof n ? t.container = window.document.querySelector(n) : (n && !e.tools.isNode(n) && (t.container = null), null == n && (t.container = window.document.documentElement), t.container)
            }

            function r() {
                return ++e.uid
            }

            function s(t, n) {
                t.config ? t.config = e.tools.extendClone(t.config, n) : t.config = e.tools.extendClone(e.defaults, n), "top" === t.config.origin || "bottom" === t.config.origin ? t.config.axis = "Y" : t.config.axis = "X", "top" !== t.config.origin && "left" !== t.config.origin || (t.config.distance = "-" + t.config.distance)
            }

            function a(e) {
                var t = window.getComputedStyle(e.domEl);
                e.styles || (e.styles = {
                    transition: {},
                    transform: {},
                    computed: {}
                }, e.styles.inline = e.domEl.getAttribute("style") || "", e.styles.inline += "; visibility: visible; ", e.styles.computed.opacity = t.opacity, t.transition && "all 0s ease 0s" != t.transition ? e.styles.computed.transition = t.transition + ", " : e.styles.computed.transition = ""), e.styles.transition.instant = l(e, 0), e.styles.transition.delayed = l(e, e.config.delay), e.styles.transform.initial = " -webkit-transform:", e.styles.transform.target = " -webkit-transform:", c(e), e.styles.transform.initial += "transform:", e.styles.transform.target += "transform:", c(e)
            }

            function l(e, t) {
                var n = e.config;
                return "-webkit-transition: " + e.styles.computed.transition + "-webkit-transform " + n.duration / 1e3 + "s " + n.easing + " " + t / 1e3 + "s, opacity " + n.duration / 1e3 + "s " + n.easing + " " + t / 1e3 + "s; transition: " + e.styles.computed.transition + "transform " + n.duration / 1e3 + "s " + n.easing + " " + t / 1e3 + "s, opacity " + n.duration / 1e3 + "s " + n.easing + " " + t / 1e3 + "s; "
            }

            function c(e) {
                var t = e.config,
                    n = e.styles.transform;
                parseInt(t.distance) && (n.initial += " translate" + t.axis + "(" + t.distance + ")", n.target += " translate" + t.axis + "(0)"), t.scale && (n.initial += " scale(" + t.scale + ")", n.target += " scale(1)"), t.rotate.x && (n.initial += " rotateX(" + t.rotate.x + "deg)", n.target += " rotateX(0)"), t.rotate.y && (n.initial += " rotateY(" + t.rotate.y + "deg)", n.target += " rotateY(0)"), t.rotate.z && (n.initial += " rotateZ(" + t.rotate.z + "deg)", n.target += " rotateZ(0)"), n.initial += "; opacity: " + t.opacity + ";", n.target += "; opacity: " + e.styles.computed.opacity + ";"
            }

            function f(t) {
                var n = t.config.container;
                n && -1 == e.store.containers.indexOf(n) && e.store.containers.push(t.config.container), e.store.elements[t.id] = t
            }

            function u(t, n, i) {
                var o = {
                    selector: t,
                    config: n,
                    interval: i
                };
                e.history.push(o)
            }

            function d() {
                if (e.isSupported()) {
                    p();
                    for (var t = 0; t < e.store.containers.length; t++) e.store.containers[t].addEventListener("scroll", y), e.store.containers[t].addEventListener("resize", y);
                    e.initialized || (window.addEventListener("scroll", y), window.addEventListener("resize", y), e.initialized = !0)
                }
                return e
            }

            function y() {
                n(p)
            }

            function m() {
                var t, n, i, o;
                e.tools.forOwn(e.sequences, function(r) {
                    o = e.sequences[r], t = !1;
                    for (var s = 0; s < o.elemIds.length; s++) i = o.elemIds[s], n = e.store.elements[i], O(n) && !t && (t = !0);
                    o.active = t
                })
            }

            function p() {
                var t, n;
                m(), e.tools.forOwn(e.store.elements, function(i) {
                    n = e.store.elements[i], t = b(n), v(n) ? (t ? n.domEl.setAttribute("style", n.styles.inline + n.styles.transform.target + n.styles.transition.delayed) : n.domEl.setAttribute("style", n.styles.inline + n.styles.transform.target + n.styles.transition.instant), w("reveal", n, t), n.revealing = !0, n.seen = !0, n.sequence && g(n, t)) : h(n) && (n.domEl.setAttribute("style", n.styles.inline + n.styles.transform.initial + n.styles.transition.instant), w("reset", n), n.revealing = !1)
                })
            }

            function g(t, n) {
                var i = 0,
                    o = 0,
                    r = e.sequences[t.sequence.id];
                r.blocked = !0, n && "onload" == t.config.useDelay && (o = t.config.delay), t.sequence.timer && (i = Math.abs(t.sequence.timer.started - new Date), window.clearTimeout(t.sequence.timer)), t.sequence.timer = {
                    started: new Date
                }, t.sequence.timer.clock = window.setTimeout(function() {
                    r.blocked = !1, t.sequence.timer = null, y()
                }, Math.abs(r.interval) + o - i)
            }

            function w(e, t, n) {
                var i = 0,
                    o = 0,
                    r = "after";
                switch (e) {
                    case "reveal":
                        o = t.config.duration, n && (o += t.config.delay), r += "Reveal";
                        break;
                    case "reset":
                        o = t.config.duration, r += "Reset"
                }
                t.timer && (i = Math.abs(t.timer.started - new Date), window.clearTimeout(t.timer.clock)), t.timer = {
                    started: new Date
                }, t.timer.clock = window.setTimeout(function() {
                    t.config[r](t.domEl), t.timer = null
                }, o - i)
            }

            function v(t) {
                if (t.sequence) {
                    var n = e.sequences[t.sequence.id];
                    return n.active && !n.blocked && !t.revealing && !t.disabled
                }
                return O(t) && !t.revealing && !t.disabled
            }

            function b(t) {
                var n = t.config.useDelay;
                return "always" === n || "onload" === n && !e.initialized || "once" === n && !t.seen
            }

            function h(t) {
                if (t.sequence) {
                    var n = e.sequences[t.sequence.id];
                    return !n.active && t.config.reset && t.revealing && !t.disabled
                }
                return !O(t) && t.config.reset && t.revealing && !t.disabled
            }

            function x(e) {
                return {
                    width: e.clientWidth,
                    height: e.clientHeight
                }
            }

            function q(e) {
                if (e && e !== window.document.documentElement) {
                    var t = E(e);
                    return {
                        x: e.scrollLeft + t.left,
                        y: e.scrollTop + t.top
                    }
                }
                return {
                    x: window.pageXOffset,
                    y: window.pageYOffset
                }
            }

            function E(e) {
                var t = 0,
                    n = 0,
                    i = e.offsetHeight,
                    o = e.offsetWidth;
                do isNaN(e.offsetTop) || (t += e.offsetTop), isNaN(e.offsetLeft) || (n += e.offsetLeft); while (e = e.offsetParent);
                return {
                    top: t,
                    left: n,
                    height: i,
                    width: o
                }
            }

            function O(e) {
                function t() {
                    var t = c + a * s,
                        n = f + l * s,
                        i = u - a * s,
                        y = d - l * s,
                        m = r.y + e.config.viewOffset.top,
                        p = r.x + e.config.viewOffset.left,
                        g = r.y - e.config.viewOffset.bottom + o.height,
                        w = r.x - e.config.viewOffset.right + o.width;
                    return g > t && i > m && n > p && w > y
                }

                function n() {
                    return "fixed" === window.getComputedStyle(e.domEl).position
                }
                var i = E(e.domEl),
                    o = x(e.config.container),
                    r = q(e.config.container),
                    s = e.config.viewFactor,
                    a = i.height,
                    l = i.width,
                    c = i.top,
                    f = i.left,
                    u = c + a,
                    d = f + l;
                return t() || n()
            }
            return i.prototype.defaults = {
                origin: "bottom",
                distance: "20px",
                duration: 500,
                delay: 0,
                rotate: {
                    x: 0,
                    y: 0,
                    z: 0
                },
                opacity: 0,
                scale: .9,
                easing: "cubic-bezier(0.6, 0.2, 0.1, 1)",
                container: null,
                mobile: !0,
                reset: !1,
                useDelay: "always",
                viewFactor: .2,
                viewOffset: {
                    top: 0,
                    right: 0,
                    bottom: 0,
                    left: 0
                },
                afterReveal: function(e) {},
                afterReset: function(e) {}
            }, i.prototype.isSupported = function() {
                var e = document.documentElement.style;
                return "WebkitTransition" in e && "WebkitTransform" in e || "transition" in e && "transform" in e
            }, i.prototype.reveal = function(t, n, i, l) {
                var c, y, m, p, g, w;
                if (c = n && n.container ? o(n) : e.defaults.container, y = e.tools.isNode(t) ? [t] : Array.prototype.slice.call(c.querySelectorAll(t)), !y.length) return e;
                n && "number" == typeof n && (i = n, n = {}), i && "number" == typeof i && (w = r(), g = e.sequences[w] = {
                    id: w,
                    interval: i,
                    elemIds: [],
                    active: !1
                });
                for (var v = 0; v < y.length; v++) p = y[v].getAttribute("data-sr-id"), p ? m = e.store.elements[p] : (m = {
                    id: r(),
                    domEl: y[v],
                    seen: !1,
                    revealing: !1
                }, m.domEl.setAttribute("data-sr-id", m.id)), g && (m.sequence = {
                    id: g.id,
                    index: g.elemIds.length
                }, g.elemIds.push(m.id)), s(m, n || {}), a(m), f(m), e.tools.isMobile() && !m.config.mobile || !e.isSupported() ? (m.domEl.setAttribute("style", m.styles.inline), m.disabled = !0) : m.revealing || m.domEl.setAttribute("style", m.styles.inline + m.styles.transform.initial);
                return !l && e.isSupported() && (u(t, n), e.initTimeout && window.clearTimeout(e.initTimeout), e.initTimeout = window.setTimeout(d, 0)), e
            }, i.prototype.sync = function() {
                if (e.history.length && e.isSupported()) {
                    for (var t = 0; t < e.history.length; t++) {
                        var n = e.history[t];
                        e.reveal(n.selector, n.config, n.interval, !0)
                    }
                    d()
                }
                return e
            }, i
        }(), t = function() {
            function e() {}
            return e.prototype.isObject = function(e) {
                return null !== e && "object" == typeof e && e.constructor == Object
            }, e.prototype.isNode = function(e) {
                return "object" == typeof Node ? e instanceof Node : e && "object" == typeof e && "number" == typeof e.nodeType && "string" == typeof e.nodeName
            }, e.prototype.forOwn = function(e, t) {
                if (!this.isObject(e)) throw new TypeError('Expected "object", but received "' + typeof e + '".');
                for (var n in e) e.hasOwnProperty(n) && t(n)
            }, e.prototype.extend = function(e, t) {
                return this.forOwn(t, function(n) {
                    this.isObject(t[n]) ? (e[n] && this.isObject(e[n]) || (e[n] = {}), this.extend(e[n], t[n])) : e[n] = t[n]
                }.bind(this)), e
            }, e.prototype.extendClone = function(e, t) {
                return this.extend(this.extend({}, e), t)
            }, e.prototype.isMobile = function() {
                return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
            }, e
        }(), n = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame
    }.call(this), this.ScrollReveal
});