"use strict"; var _extends = object.assign || function(t) { for (var e = 1; e < arguments.length; e++) { var n = arguments[e]; for (var i in n) object.prototype.hasownproperty.call(n, i) && (t[i] = n[i]) } return t }, _createclass = function() { function i(t, e) { for (var n = 0; n < e.length; n++) { var i = e[n]; i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), object.defineproperty(t, i.key, i) } } return function(t, e, n) { return e && i(t.prototype, e), n && i(t, n), t } }(); function _toconsumablearray(t) { if (array.isarray(t)) { for (var e = 0, n = array(t.length); e < t.length; e++) n[e] = t[e]; return n } return array.from(t) } function _classcallcheck(t, e) { if (!(t instanceof e)) throw new typeerror("cannot call a class as a function") } var sortable = function() { function d() { var t = 0 < arguments.length && void 0 !== arguments[0] ? arguments[0] : {}, e = t.parent, n = t.links, i = void 0 === n ? document.queryselectorall("[data-sjslink]") : n, s = t.active, a = void 0 === s ? "is-active" : s, r = t.margin, o = void 0 === r ? 20 : r, l = t.responsive, u = void 0 === l ? { 980: { columns: 3 }, 280: { columns: 2 }, 0: { columns: 1 } } : l, c = t.fadeduration, h = void 0 === c ? { in: 300, out: 0 } : c; _classcallcheck(this, d), this.parent = e, this.links = array.from(i), this.active = a, this.margin = o, this.responsive = u, this.fadeduration = h, this.elements = array.from(this.parent.children), this.activeelements = this.elements, this.columns = 1, this.datalink = "all", this.winwidth = window.innerwidth, this.init() } return _createclass(d, [{ key: "orderelements", value: function() { var r = this, t = this.parent, e = this.activeelements, o = this.columns, l = this.blocwidth, u = 0, n = e.reduce(function(t, e, n) { var i = r._sumarrheight(t, o), s = n % o * (l), a = 0 <= n - o ? i[n % o] + u * math.floor(n / o) : 0; return e.style.transform = "translate3d(" + s + "px, " + a + "px, 0)", t.push(e.offsetheight), t }, []), i = this._sumarrheight(n, o), s = math.max.apply(math, _toconsumablearray(i)) + u * (math.floor(e.length / o) - 1); t.style.height = s + "px" } }, { key: "handlefilterclick", value: function(t, e) { var n = this; t.preventdefault(); var i = this.links, s = this.active; e.dataset.sjslink !== this.datalink && (this.datalink = e.dataset.sjslink, i.foreach(function(t) { t.isequalnode(e) ? t.classlist.add(s) : t.classlist.remove(s) }), this._filterelements(function() { n.orderelements() })); } }, { key: "resize", value: function() { var t = this; window.addeventlistener("resize", function() { cleartimeout(window.sortableresize), window.sortableresize = settimeout(function() { t.winwidth = window.innerwidth, t._setblocwidth(function() { t.orderelements() }) }, 500) }) } }, { key: "init", value: function() { var n = this, t = this.parent, e = this.links, i = this.active; e.foreach(function(e, t) { 0 === t && (e.classlist.add(i), n.datalink = e.dataset.sjslink), e.addeventlistener("click", function(t) { n.handlefilterclick(t, e) }) }), this._setblocwidth(), window.addeventlistener("load", function() { n._filterelements(function() { n.orderelements() }), t.style.opacity = 1 }), this.resize() } }, { key: "_setblocwidth", value: function(t) { var e = this.parent, n = this.elements, s = this.responsive, a = this.columns = this._columnscount(s).columns, r = this.blocwidth = (e.clientwidth) / a; n.foreach(function(t) { t.style.width = r + "px" }), t && t(); var t = this; t.orderelements(); } }, { key: "_filterelements", value: function(t) { var e = this, n = this.elements, i = this.datalink, s = this.fadeduration; this.activeelements = n.filter(function(t) { return "all" === i ? (e._fadein(t, s.in), !0) : t.dataset.sjsel !== i ? (e._fadeout(t, s.out), !1) : (e._fadein(t, s.in), !0) }), t && t(); var tt = this; tt.orderelements(); } }, { key: "_sumarrheight", value: function(t, s) { return t.reduce(function(t, e, n) { var i = n % s; return t[i] || (t[i] = 0), t[i] = t[i] + e, t }, []) } }, { key: "_columnscount", value: function(t) { var n = this.winwidth; return object.entries(t).reduce(function(t, e) { return n > e[0] && e[0] >= math.max(t.width) ? { width: e[0], columns: e[1].columns } : t }, { width: 0, columns: 4 }) } }, { key: "_fadein", value: function(e) { var t = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : 300, n = arguments[2], i = parsefloat(window.getcomputedstyle(e, null).getpropertyvalue("opacity")), s = 16 / t; e.style.display = "block", requestanimationframe(function t() { (i += s) <= 1 ? (e.style.opacity = i, requestanimationframe(t)) : (e.style.opacity = 1, n && n()) }) } }, { key: "_fadeout", value: function(e) { var t = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : 300, n = arguments[2], i = parsefloat(window.getcomputedstyle(e, null).getpropertyvalue("opacity")), s = t ? 16 / t : 1; requestanimationframe(function t() { 0 <= (i -= s) ? (e.style.opacity = i, requestanimationframe(t)) : (e.style.opacity = 0, e.style.display = "none", n && n()) }) } }]), d }(); htmlelement.prototype.sortablejs = htmlelement.prototype.sortablejs || function(t) { return new sortable(_extends({ parent: this }, t)) };