/** * Muuri v0.7.1 * https://github.com/haltu/muuri * Copyright (c) 2015-present, Haltu Oy * Released under the MIT license * https://github.com/haltu/muuri/blob/master/LICENSE.md * @license MIT * * Muuri Packer * Copyright (c) 2016-present, Niklas Rämö * @license MIT * * Muuri Ticker / Muuri Emitter / Muuri Queue * Copyright (c) 2018-present, Niklas Rämö * @license MIT */ !function(t,i){if("object"==typeof exports&&"undefined"!=typeof module){var e;try{e=require("hammerjs")}catch(t){}module.exports=i(e)}else t.Muuri=i(t.Hammer)}(this,function(t){"use strict";var i="Muuri",e={},s="layoutEnd";function n(){this._events={},this._queue=[],this._counter=0,this._isDestroyed=!1}n.prototype.on=function(t,i){if(this._isDestroyed)return this;var e=this._events[t];return e||(e=this._events[t]=[]),e.push(i),this},n.prototype.once=function(t,i){if(this._isDestroyed)return this;var e=function(){this.off(t,e),i.apply(null,arguments)}.bind(this);return this.on(t,e)},n.prototype.off=function(t,i){if(this._isDestroyed)return this;var e=this._events[t];if(!e||!e.length)return this;if(!i)return e.length=0,this;for(var s=e.length;s--;)i===e[s]&&e.splice(s,1);return this},n.prototype.emit=function(t,i,e,s){if(this._isDestroyed)return this;var n=this._events[t];if(!n||!n.length)return this;var r,o=this._queue,h=o.length,a=arguments.length-1;for(r=0;r-1&&(this._queue[n]=void 0),s?this._queue.unshift(t):this._queue.push(t),this._reads[t]=i,this._writes[t]=e,this._nextTick||(this._nextTick=c(this._flush))},p.prototype.cancel=function(t){var i=this._queue.indexOf(t);i>-1&&(this._queue[i]=void 0,this._reads[t]=void 0,this._writes[t]=void 0)},p.prototype._flush=function(){var t,i,e=this._queue,s=this._reads,n=this._writes,r=this._batch,o=this._batchReads,h=this._batchWrites,a=e.length;for(this._nextTick=null,i=0;in?n:i<0?Math.max(n+i+1,0):i}function E(t,i,e){if(!(t.length<2)){var s=L(t,i),n=L(t,e);s!==n&&t.splice(n,0,t.splice(s,1)[0])}}function M(t,i,e){if(!(t.length<2)){var s,n=L(t,i),r=L(t,e);n!==r&&(s=t[n],t[n]=t[r],t[r]=s)}}var H="cancel",G="finish";function P(t,i){var e;return i>0?function(s){void 0!==e&&(e=window.clearTimeout(e),s===G&&t()),s!==H&&s!==G&&(e=window.setTimeout(function(){e=void 0,t()},i))}:function(i){i!==H&&t()}}function T(t){var i=_(t,"transform");if(!i||"none"===i)return!1;var e=_(t,"display");return"inline"!==e&&"none"!==e}function O(t,i){for(var e=(i?t:t.parentElement)||document;e&&e!==document&&"static"===_(e,"position")&&!T(e);)e=e.parentElement||document;return e}function k(t,i){return parseFloat(_(t,i))||0}var X={},Y={},q={};function B(t,i){var e,s=i||{};return s.left=0,s.top=0,t===document?s:(s.left=window.pageXOffset||0,s.top=window.pageYOffset||0,t.self===window.self?s:(e=t.getBoundingClientRect(),s.left+=e.left,s.top+=e.top,s.left+=k(t,"border-left-width"),s.top+=k(t,"border-top-width"),s))}function N(t,i,e){return q.left=0,q.top=0,t===i?q:e&&(t=O(t,!0))===(i=O(i,!0))?q:(B(t,X),B(i,Y),q.left=Y.left-X.left,q.top=Y.top-X.top,q)}var F={};function z(t){F.x=0,F.y=0;var i=_(t,"transform");if(!i)return F;var e=i.replace("matrix(","").split(",");return F.x=parseFloat(e[4])||0,F.y=parseFloat(e[5])||0,F}function V(t,i){return"translateX("+t+"px) translateY("+i+"px)"}var W=[];function j(t,i,e){var s="number"==typeof e?e:-1;s<0&&(s=t.length-s+1),t.splice.apply(t,W.concat(s,0,i)),W.length=0}var Z="[object Object]",$=Object.prototype.toString;function J(t){return"object"==typeof t&&$.call(t)===Z}var K="classList"in Element.prototype?function(t,i){t.classList.remove(i)}:function(t,i){C(t,"."+i)&&(t.className=(" "+t.className+" ").replace(" "+i+" "," ").trim())},Q=at(),U=0,tt=1,it=2,et=3;function st(e){if(!t)throw new Error("["+i+"] required dependency Hammer is not defined.");null===Q&&(Q=at());var s,n,r=this,o=e._element,h=e.getGrid(),a=h._settings,_="function"==typeof a.dragStartPredicate?a.dragStartPredicate:st.defaultStartPredicate,l=U;this._item=e,this._gridId=h._id,this._hammer=s=new t.Manager(o),this._isDestroyed=!1,this._isMigrating=!1,this._reset(),this._onScroll=this._onScroll.bind(this),this._prepareMove=this._prepareMove.bind(this),this._applyMove=this._applyMove.bind(this),this._prepareScroll=this._prepareScroll.bind(this),this._applyScroll=this._applyScroll.bind(this),this._checkOverlap=this._checkOverlap.bind(this),this._forceResolveStartPredicate=function(t){this._isDestroyed||l!==tt||(l=it,this._onStart(t))},this._checkOverlapDebounce=P(this._checkOverlap,a.dragSortInterval),s.add(new t.Pan({event:"drag",pointers:1,threshold:0,direction:t.DIRECTION_ALL})),s.add(new t.Press({event:"draginit",pointers:1,threshold:1e3,time:0})),J(a.dragHammerSettings)&&s.set(a.dragHammerSettings),s.on("draginit dragstart dragmove",function(t){l===U&&(l=tt),l===tt?!0===(n=_(r._item,t))?(l=it,r._onStart(t)):!1===n&&(l=et):l===it&&r._isActive&&r._onMove(t)}).on("dragend dragcancel draginitup",function(t){var i=l===it;_(r._item,t),l=U,i&&r._isActive&&r._onEnd(t)}),o.addEventListener("dragstart",nt,!1)}function nt(t){t.preventDefault&&t.preventDefault()}function rt(t,i){return t.left+t.width<=i.left||i.left+i.width<=t.left||t.top+t.height<=i.top||i.top+i.height<=t.top?0:(Math.min(t.left+t.width,i.left+i.width)-Math.max(t.left,i.left))*(Math.min(t.top+t.height,i.top+i.height)-Math.max(t.top,i.top))/(Math.min(t.width,i.width)*Math.min(t.height,i.height))*100}function ot(t,i){var e=i||[],s=t.parentNode;if(Q){if("fixed"===_(t,"position"))return e;for(;s&&s!==document&&s!==document.documentElement;)ht(s)&&e.push(s),s="fixed"===_(s,"position")?null:s.parentNode;return null!==s&&e.push(window),e}for(;s&&s!==document;)"fixed"!==_(t,"position")||T(s)?(ht(s)&&e.push(s),t=s,s=s.parentNode):s=s.parentNode;return e[e.length-1]===document.documentElement?e[e.length-1]=window:e.push(window),e}function ht(t){var i=_(t,"overflow");return"auto"===i||"scroll"===i||("auto"===(i=_(t,"overflow-x"))||"scroll"===i||("auto"===(i=_(t,"overflow-y"))||"scroll"===i))}function at(){if(!r)return!0;if(!document.body)return null;var t=[0,1].map(function(t,i){return(t=document.createElement("div")).style.position=i?"fixed":"absolute",t.style.display="block",t.style.visibility="hidden",t.style.left=i?"0px":"1px",t.style[h]="none",t}),i=document.body.appendChild(t[0]),e=i.appendChild(t[1]),s=e.getBoundingClientRect().left;i.style[h]="scale(1)";var n=s===e.getBoundingClientRect().left;return document.body.removeChild(i),n}function _t(){this._queue=[],this._isDestroyed=!1}function lt(t){this._item=t,this._isActive=!1,this._isDestroyed=!1,this._isInterrupted=!1,this._currentStyles={},this._targetStyles={},this._currentLeft=0,this._currentTop=0,this._offsetLeft=0,this._offsetTop=0,this._skipNextAnimation=!1,this._animateOptions={onFinish:this._finish.bind(this)},this._queue=new _t,this._setupAnimation=this._setupAnimation.bind(this),this._startAnimation=this._startAnimation.bind(this)}st.defaultStartPredicate=function(t,i,e){var s=t._drag,n=s._startPredicateData||s._setupStartPredicate(e);if(!i.isFinal)return!(!n.handleElement&&(n.handleElement=s._getStartPredicateHandle(i),!n.handleElement))&&(n.delay&&(n.event=i,n.delayTimer||(n.delayTimer=window.setTimeout(function(){n.delay=0,s._resolveStartPredicate(n.event)&&(s._forceResolveStartPredicate(n.event),s._resetStartPredicate())},n.delay))),s._resolveStartPredicate(i));s._finishStartPredicate(i)},st.defaultSortPredicate=function(){var t={},i={},e={},s=[];return function(n,r){var o=n._drag,h=o._getGrid(),a=r&&"number"==typeof r.threshold?r.threshold:50,_=r&&"swap"===r.action?"swap":"move";t.width=n._width,t.height=n._height,t.left=o._elementClientX,t.top=o._elementClientY;var l=function(e,n,r){var o,h,a,_,l=null,d=n._settings.dragSort,f=-1;if(!0===d?(s[0]=n,h=s):h=d.call(n,e),!Array.isArray(h))return l;for(_=0;_r&&o>f&&(f=o,l=a));return s.length=0,l}(n,h,a);if(!l)return!1;var d,f,u,c,p,m=0,g=0,y=-1;for(l===h?(t.left=o._gridX+n._marginLeft,t.top=o._gridY+n._marginTop):(l._updateBorders(1,0,1,0),m=l._left+l._borderLeft,g=l._top+l._borderTop),p=0;py&&(d=p,y=c));return y=a&&(e.grid=l,e.index=d,e.action=_,e)}}(),st.prototype.stop=function(){var t=this._item,i=t._element,e=this._getGrid();return this._isActive?this._isMigrating?(this._finishMigration(),this):(S(t._id),A(t._id),this._unbindScrollListeners(),this._checkOverlapDebounce("cancel"),i.parentNode!==e._element&&(e._element.appendChild(i),i.style[h]=V(this._gridX,this._gridY)),K(i,e._settings.itemDraggingClass),this._reset(),this):this},st.prototype.destroy=function(){return this._isDestroyed?this:(this.stop(),this._hammer.destroy(),this._item._element.removeEventListener("dragstart",nt,!1),this._isDestroyed=!0,this)},st.prototype._getGrid=function(){return e[this._gridId]||null},st.prototype._reset=function(){this._isActive=!1,this._container=null,this._containingBlock=null,this._lastEvent=null,this._lastScrollEvent=null,this._scrollers=[],this._left=0,this._top=0,this._gridX=0,this._gridY=0,this._elementClientX=0,this._elementClientY=0,this._containerDiffX=0,this._containerDiffY=0},st.prototype._bindScrollListeners=function(){var t,i,e=this._getGrid()._element,s=this._container,n=this._scrollers;if(n.length=0,ot(this._item._element,n),s!==e)for(ot(e,t=[]),t.push(e),i=0;i=e&&a=s&&_0;return l&&this._queue.flush(!0,o),d&&(a._isPositioningStarted=!0),"function"==typeof i&&this._queue.add(i),p?(this._isActive=!0,this._animateOptions.easing=c,this._animateOptions.duration=u,this._isInterrupted=l,s=o._id,n=this._setupAnimation,r=this._startAnimation,m.add(s+g,n,r),this):(this._updateOffsets(),this._updateTargetStyles(),l&&D(o._id),e=o._animate.isAnimating(),this.stop(!1,this._targetStyles),!e&&f(h,this._targetStyles),this._skipNextAnimation=!1,this._finish())}},lt.prototype.stop=function(t,i){if(this._isDestroyed||!this._isActive)return this;var e=this._item;return D(e._id),e._animate.stop(i),K(e._element,e.getGrid()._settings.itemPositioningClass),this._isActive=!1,t&&this._queue.flush(!0,e),this},lt.prototype.destroy=function(){return this._isDestroyed?this:(this.stop(!0,{}),this._queue.destroy(),this._item=this._currentStyles=this._targetStyles=this._animateOptions=null,this._isDestroyed=!0,this)},lt.prototype._updateOffsets=function(){if(!this._isDestroyed){var t=this._item,i=t._migrate,e=t._release;this._offsetLeft=e._isActive?e._containerDiffX:i._isActive?i._containerDiffX:0,this._offsetTop=e._isActive?e._containerDiffY:i._isActive?i._containerDiffY:0}},lt.prototype._updateTargetStyles=function(){if(!this._isDestroyed){var t=this._item;this._targetStyles.transform=V(t._left+this._offsetLeft,t._top+this._offsetTop)}},lt.prototype._finish=function(){if(!this._isDestroyed){var t=this._item,i=t._migrate,e=t._release;this._isActive&&(this._isActive=!1,K(t._element,t.getGrid()._settings.itemPositioningClass)),e._isActive&&e.stop(),i._isActive&&i.stop(),this._queue.flush(!1,t)}},lt.prototype._setupAnimation=function(){var t=z(this._item._element);this._currentLeft=t.x,this._currentTop=t.y},lt.prototype._startAnimation=function(){var t=this._item,i=t._element,e=t.getGrid()._settings;if(this._updateOffsets(),this._updateTargetStyles(),t._left===this._currentLeft-this._offsetLeft&&t._top===this._currentTop-this._offsetTop)return this._isInterrupted&&this.stop(!1,this._targetStyles),this._isActive=!1,void this._finish();!this._isInterrupted&&I(i,e.itemPositioningClass),this._currentStyles.transform=V(this._currentLeft,this._currentTop),t._animate.start(this._currentStyles,this._targetStyles,this._animateOptions)};var dt={};function ft(t){this._item=t,this._isActive=!1,this._isDestroyed=!1,this._container=!1,this._containerDiffX=0,this._containerDiffY=0}ft.prototype.start=function(t,i,e){if(this._isDestroyed)return this;var s,n,r,o,a,_,l,d,u=this._item,c=u._element,p=u.isVisible(),m=u.getGrid(),g=m._settings,y=t._settings,v=t._element,w=t._items,D=m._items.indexOf(u),b=e||document.body;if("number"==typeof i)s=L(w,i,!0);else{if(!(n=t._getItem(i)))return this;s=w.indexOf(n)}return(u.isPositioning()||this._isActive||u.isReleasing())&&(l=(_=z(c)).x,d=_.y),u.isPositioning()&&u._layout.stop(!0,{transform:V(l,d)}),this._isActive&&(l-=this._containerDiffX,d-=this._containerDiffY,this.stop(!0,{transform:V(l,d)})),u.isReleasing()&&(l-=u._release._containerDiffX,d-=u._release._containerDiffY,u._release.stop(!0,{transform:V(l,d)})),u._visibility._stopAnimation(),u._drag&&u._drag.destroy(),u._visibility._queue.flush(!0,u),m._hasListeners("beforeSend")&&m._emit("beforeSend",{item:u,fromGrid:m,fromIndex:D,toGrid:t,toIndex:s}),t._hasListeners("beforeReceive")&&t._emit("beforeReceive",{item:u,fromGrid:m,fromIndex:D,toGrid:t,toIndex:s}),K(c,g.itemClass),K(c,g.itemVisibleClass),K(c,g.itemHiddenClass),I(c,y.itemClass),I(c,p?y.itemVisibleClass:y.itemHiddenClass),m._items.splice(D,1),j(w,u,s),u._gridId=t._id,b!==(r=c.parentNode)&&(b.appendChild(c),o=N(b,r,!0),_||(l=(_=z(c)).x,d=_.y),c.style[h]=V(l+o.left,d+o.top)),u._child.removeAttribute("style"),f(u._child,p?y.visibleStyles:y.hiddenStyles),c.style.display=p?"block":"hidden",a=N(b,v,!0),u._refreshDimensions(),u._refreshSortData(),u._drag=y.dragEnabled?new st(u):null,this._isActive=!0,this._container=b,this._containerDiffX=a.left,this._containerDiffY=a.top,m._hasListeners("send")&&m._emit("send",{item:u,fromGrid:m,fromIndex:D,toGrid:t,toIndex:s}),t._hasListeners("receive")&&t._emit("receive",{item:u,fromGrid:m,fromIndex:D,toGrid:t,toIndex:s}),this},ft.prototype.stop=function(t,i){if(this._isDestroyed||!this._isActive)return this;var e,s=this._item,n=s._element,r=s.getGrid()._element;return this._container!==r&&(i||(t?(e=z(n),dt.transform=V(e.x-this._containerDiffX,e.y-this._containerDiffY)):dt.transform=V(s._left,s._top),i=dt),r.appendChild(n),f(n,i)),this._isActive=!1,this._container=null,this._containerDiffX=0,this._containerDiffY=0,this},ft.prototype.destroy=function(){return this._isDestroyed?this:(this.stop(!0),this._item=null,this._isDestroyed=!0,this)};var ut={};function ct(t){this._item=t,this._isActive=!1,this._isDestroyed=!1,this._isPositioningStarted=!1,this._containerDiffX=0,this._containerDiffY=0}function pt(t){var i=t._isActive,e=t._element,s=t.getGrid()._settings;this._item=t,this._isDestroyed=!1,this._isHidden=!i,this._isHiding=!1,this._isShowing=!1,this._queue=new _t,this._finishShow=this._finishShow.bind(this),this._finishHide=this._finishHide.bind(this),e.style.display=i?"block":"none",I(e,i?s.itemVisibleClass:s.itemHiddenClass),f(t._child,i?s.visibleStyles:s.hiddenStyles)}ct.prototype.start=function(){if(this._isDestroyed||this._isActive)return this;var t=this._item,i=t.getGrid();return this._isActive=!0,I(t._element,i._settings.itemReleasingClass),i._emit("dragReleaseStart",t),t._layout.start(!1),this},ct.prototype.stop=function(t,i){if(this._isDestroyed||!this._isActive)return this;var e,s=this._item,n=s._element,r=s.getGrid(),o=r._element;return this._reset(),n.parentNode!==o&&(i||(t?(e=z(n),ut.transform=V(e.x-this._containerDiffX,e.y-this._containerDiffY)):ut.transform=V(s._left,s._top),i=ut),o.appendChild(n),f(n,i)),t||r._emit("dragReleaseEnd",s),this},ct.prototype.destroy=function(){return this._isDestroyed?this:(this.stop(!0),this._item=null,this._isDestroyed=!0,this)},ct.prototype._reset=function(){if(!this._isDestroyed){var t=this._item;this._isActive=!1,this._isPositioningStarted=!1,this._containerDiffX=0,this._containerDiffY=0,K(t._element,t.getGrid()._settings.itemReleasingClass)}},pt.prototype.show=function(t,i){if(this._isDestroyed)return this;var e=this._item,s=e._element,n=this._queue,r="function"==typeof i?i:null,o=e.getGrid()._settings;return this._isShowing||this._isHidden?this._isShowing&&!t?(r&&n.add(r),this):(this._isShowing||(n.flush(!0,e),K(s,o.itemHiddenClass),I(s,o.itemVisibleClass),this._isHiding||(s.style.display="block")),r&&n.add(r),e._isActive=this._isShowing=!0,this._isHiding=this._isHidden=!1,this._startAnimation(!0,t,this._finishShow),this):(r&&r(!1,e),this)},pt.prototype.hide=function(t,i){if(this._isDestroyed)return this;var e=this._item,s=e._element,n=this._queue,r="function"==typeof i?i:null,o=e.getGrid()._settings;return!this._isHiding&&this._isHidden?(r&&r(!1,e),this):this._isHiding&&!t?(r&&n.add(r),this):(this._isHiding||(n.flush(!0,e),I(s,o.itemHiddenClass),K(s,o.itemVisibleClass)),r&&n.add(r),this._isHidden=this._isHiding=!0,e._isActive=this._isShowing=!1,this._startAnimation(!1,t,this._finishHide),this)},pt.prototype.destroy=function(){if(this._isDestroyed)return this;var t=this._item,i=t._element,e=t.getGrid(),s=this._queue,n=e._settings;return this._stopAnimation({}),s.flush(!0,t).destroy(),K(i,n.itemVisibleClass),K(i,n.itemHiddenClass),this._item=null,this._isHiding=this._isShowing=!1,this._isDestroyed=this._isHidden=!0,this},pt.prototype._startAnimation=function(t,i,e){if(!this._isDestroyed){var s,n=this._item,r=n.getGrid()._settings,o=t?r.visibleStyles:r.hiddenStyles,h=parseInt(t?r.showDuration:r.hideDuration)||0,a=(t?r.showEasing:r.hideEasing)||"ease",l=i||h<=0;if(o){if(b(n._id),l)return n._animateChild.isAnimating()?n._animateChild.stop(o):f(n._child,o),void(e&&e());var u,c,p;u=n._id,c=function(){s=function(t,i){var e={};for(var s in i)e[s]=_(t,d(s));return e}(n._child,o)},p=function(){n._animateChild.start(s,o,{duration:h,easing:a,onFinish:e})},m.add(u+y,c,p)}else e&&e()}},pt.prototype._stopAnimation=function(t){if(!this._isDestroyed){var i=this._item;b(i._id),i._animateChild.stop(t)}},pt.prototype._finishShow=function(){this._isHidden||(this._isShowing=!1,this._queue.flush(!1,this._item))};var mt={};pt.prototype._finishHide=function(){if(this._isHidden){var t=this._item;this._isHiding=!1,mt.transform=V(0,0),t._layout.stop(!0,mt),t._element.style.display="none",this._queue.flush(!1,t)}};var gt,yt,vt,wt,Dt=0;function bt(){return++Dt}function St(t,i,e){var s=t._settings;this._id=bt(),this._gridId=t._id,this._isDestroyed=!1,this._left=0,this._top=0,this._element=i,this._child=i.children[0],i.parentNode!==t._element&&t._element.appendChild(i),I(i,s.itemClass),"boolean"!=typeof e&&(e="none"!==_(i,"display")),this._isActive=e,i.style.left="0",i.style.top="0",i.style[h]=V(0,0),this._animate=new u(i),this._animateChild=new u(this._child),this._visibility=new pt(this),this._layout=new lt(this),this._migrate=new ft(this),this._release=new ct(this),this._drag=s.dragEnabled?new st(this):null,this._refreshDimensions(),this._refreshSortData()}function At(){this._slots=[],this._slotSizes=[],this._freeSlots=[],this._newSlots=[],this._rectItem={},this._rectStore=[],this._rectId=0,this._layout={slots:null,setWidth:!1,setHeight:!1,width:!1,height:!1},this._sortRectsLeftTop=this._sortRectsLeftTop.bind(this),this._sortRectsTopLeft=this._sortRectsTopLeft.bind(this)}St.prototype.getGrid=function(){return e[this._gridId]},St.prototype.getElement=function(){return this._element},St.prototype.getWidth=function(){return this._width},St.prototype.getHeight=function(){return this._height},St.prototype.getMargin=function(){return{left:this._marginLeft,right:this._marginRight,top:this._marginTop,bottom:this._marginBottom}},St.prototype.getPosition=function(){return{left:this._left,top:this._top}},St.prototype.isActive=function(){return this._isActive},St.prototype.isVisible=function(){return!!this._visibility&&!this._visibility._isHidden},St.prototype.isShowing=function(){return!(!this._visibility||!this._visibility._isShowing)},St.prototype.isHiding=function(){return!(!this._visibility||!this._visibility._isHiding)},St.prototype.isPositioning=function(){return!(!this._layout||!this._layout._isActive)},St.prototype.isDragging=function(){return!(!this._drag||!this._drag._isActive)},St.prototype.isReleasing=function(){return!(!this._release||!this._release._isActive)},St.prototype.isDestroyed=function(){return this._isDestroyed},St.prototype._refreshDimensions=function(){if(!this._isDestroyed&&!this._visibility._isHidden){var t=this._element,i=t.getBoundingClientRect();this._width=i.width,this._height=i.height,this._marginLeft=Math.max(0,k(t,"margin-left")),this._marginRight=Math.max(0,k(t,"margin-right")),this._marginTop=Math.max(0,k(t,"margin-top")),this._marginBottom=Math.max(0,k(t,"margin-bottom"))}},St.prototype._refreshSortData=function(){if(!this._isDestroyed){var t,i=this._sortData={},e=this.getGrid()._settings.sortData;for(t in e)i[t]=e[t](this,this._element)}},St.prototype._destroy=function(t){if(!this._isDestroyed){var i=this._element,e=this.getGrid(),s=e._settings,n=e._items.indexOf(this);this._release.destroy(),this._migrate.destroy(),this._layout.destroy(),this._visibility.destroy(),this._animate.destroy(),this._animateChild.destroy(),this._drag&&this._drag.destroy(),i.removeAttribute("style"),this._child.removeAttribute("style"),K(i,s.itemClass),n>-1&&e._items.splice(n,1),t&&i.parentNode.removeChild(i),this._isActive=!1,this._isDestroyed=!0}},At.prototype.getLayout=function(t,i,e,s,n){var r,o=this._layout,h=!(!n||!n.fillGaps),a=!(!n||!n.horizontal),_=!(!n||!n.alignRight),l=!(!n||!n.alignBottom),d=!(!n||!n.rounding),f=this._slotSizes;if(o.slots=s||this._slots,o.width=a?0:d?Math.round(i):i,o.height=a?d?Math.round(e):e:0,o.setWidth=a,o.setHeight=!a,o.slots.length=0,f.length=0,!t.length)return o;for(r=0;rd.height&&(gt.left>0&&u.push(this._addRect(0,d.height,gt.left,1/0)),gt.left+gt.widthd.width&&(gt.top>0&&u.push(this._addRect(d.width,0,1/0,gt.top)),gt.top+gt.height.49&&r.height>.49&&(!i&&r.topi.left+i.width&&yt.push(this._addRect(i.left+i.width,t.top,t.left+t.width-(i.left+i.width),t.height)),t.topi.top+i.height&&yt.push(this._addRect(t.left,i.top+i.height,t.width,t.top+t.height-(i.top+i.height))),yt):(yt.push(this._addRect(t.left,t.top,t.width,t.height)),yt)}),At.prototype._doRectsOverlap=function(t,i){return!(t.left+t.width<=i.left||i.left+i.width<=t.left||t.top+t.height<=i.top||i.top+i.height<=t.top)},At.prototype._isRectWithinRect=function(t,i){return t.left>=i.left&&t.top>=i.top&&t.left+t.width<=i.left+i.width&&t.top+t.height<=i.top+i.height},At.prototype._purgeRects=(vt={},wt={},function(t){for(var i,e=t.length;e--;)if(i=t.length,t[e])for(this._getRect(t[e],vt);i--;)if(t[i]&&e!==i&&this._isRectWithinRect(vt,this._getRect(t[i],wt))){t[e]=0;break}return t}),At.prototype._sortRectsTopLeft=function(){var t={},i={};return function(e,s){return this._getRect(e,t),this._getRect(s,i),t.topi.top?1:t.lefti.left?1:0}}(),At.prototype._sortRectsLeftTop=function(){var t={},i={};return function(e,s){return this._getRect(e,t),this._getRect(s,i),t.lefti.left?1:t.topi.top?1:0}}();var xt="[object HTMLCollection]",Rt="[object NodeList]";function Ct(t){var i=Object.prototype.toString.call(t);return i===xt||i===Rt}function It(t){return Ct(t)?Array.prototype.slice.call(t):Array.prototype.concat(t)}var Lt=new At,Et=function(){};function Mt(t,i){var s,r,o,h=this;if(t=this._element="string"==typeof t?document.querySelector(t):t,!document.body.contains(t))throw new Error("Container element must be an existing DOM element");"function"!=typeof(s=this._settings=function(t,i){var e=Ht({},t);i&&(e=Ht(e,i));return e.visibleStyles=(i||0).visibleStyles||(t||0).visibleStyles,e.hiddenStyles=(i||0).hiddenStyles||(t||0).hiddenStyles,e}(Mt.defaultOptions,i)).dragSort&&(s.dragSort=!!s.dragSort),this._id=bt(),e[this._id]=h,this._isDestroyed=!1,this._layout={id:0,items:[],slots:[],setWidth:!1,setHeight:!1,width:0,height:0},this._emitter=new n,I(t,s.containerClass),this._items=[],"string"==typeof(r=s.items)?It(t.children).forEach(function(t){("*"===r||C(t,r))&&h._items.push(new St(h,t))}):(Array.isArray(r)||Ct(r))&&(this._items=It(r).map(function(t){return new St(h,t)})),"number"!=typeof(o=s.layoutOnResize)&&(o=!0===o?0:-1),o>=0&&window.addEventListener("resize",h._resizeHandler=P(function(){h.refreshItems().layout()},o)),s.layoutOnInit&&this.layout(!0)}function Ht(t,i){var e,s,n,r=Object.keys(i),o=r.length;for(n=0;n0)){var t=o._layout.id!==l;c&&u(t,p),!t&&o._hasListeners(s)&&o._emit(s,a.items.slice(0))}}if((a.setHeight&&"number"==typeof a.height||a.setWidth&&"number"==typeof a.width)&&(e="border-box"===_(h,"box-sizing")),a.setHeight&&("number"==typeof a.height?h.style.height=(e?a.height+this._borderTop+this._borderBottom:a.height)+"px":h.style.height=a.height),a.setWidth&&("number"==typeof a.width?h.style.width=(e?a.width+this._borderLeft+this._borderRight:a.width)+"px":h.style.width=a.width),this._hasListeners("layoutStart")&&this._emit("layoutStart",a.items.slice(0)),!d)return m(),this;for(r=0;rl?1:0:ld?1:0)return f;return f||(n||(n=r(s)),f=o(i,h)),f}function a(i,h){var a=t(i,h);return e&&a&&(a=-a),a||(n||(n=r(s)),o(i,h))}return function(r,o){if(this._isDestroyed||this._items.length<2)return this;var _,l=this._items,d=o||0,f=d.layout?d.layout:void 0===d.layout;if(t=r,e=!!d.descending,s=l.slice(0),n=null,"function"==typeof t)l.sort(a);else if("string"==typeof t)t=r.trim().split(" ").map(function(t){return t.split(":")}),l.sort(h);else{if(!Array.isArray(t))return this;if(t.length!==l.length)throw new Error("["+i+"] sort reference items do not match with grid items.");for(_=0;_-1?t:this._items.length+t]||null;if(t instanceof St)return t._gridId===this._id?t:null;for(var i=0;i