!function(t,e){"function"==typeof define&&define.amd?define("packery/js/rect",e):"object"==typeof module&&module.exports?module.exports=e():(t.Packery=t.Packery||{},t.Packery.Rect=e())}(window,function(){function t(e){for(var i in t.defaults)this[i]=t.defaults[i];for(i in e)this[i]=e[i]}t.defaults={x:0,y:0,width:0,height:0};var e=t.prototype;return e.contains=function(t){var e=t.width||0,i=t.height||0;return this.x<=t.x&&this.y<=t.y&&this.x+this.width>=t.x+e&&this.y+this.height>=t.y+i},e.overlaps=function(t){var e=this.x+this.width,i=this.y+this.height,s=t.x+t.width,r=t.y+t.height;return this.xt.x&&this.yt.y},e.getMaximalFreeRects=function(e){if(!this.overlaps(e))return!1;var i,s=[],r=this.x+this.width,h=this.y+this.height,n=e.x+e.width,o=e.y+e.height;return this.yn&&(i=new t({x:n,y:this.y,width:r-n,height:this.height}),s.push(i)),h>o&&(i=new t({x:this.x,y:o,width:this.width,height:h-o}),s.push(i)),this.x=t.width&&this.height>=t.height},t}),function(t,e){if("function"==typeof define&&define.amd)define("packery/js/packer",["./rect"],e);else if("object"==typeof module&&module.exports)module.exports=e(require("./rect"));else{var i=t.Packery=t.Packery||{};i.Packer=e(i.Rect)}}(window,function(t){function e(t,e,i){this.width=t||0,this.height=e||0,this.sortDirection=i||"downwardLeftToRight",this.reset()}var i=e.prototype;i.reset=function(){this.spaces=[];var e=new t({x:0,y:0,width:this.width,height:this.height});this.spaces.push(e),this.sorter=s[this.sortDirection]||s.downwardLeftToRight},i.pack=function(t){for(var e=0;e=t.x+t.width&&i.height>=t.height-.01){t.y=i.y,this.placed(t);break}}},i.rowPack=function(t){for(var e=0;e=t.y+t.height&&i.width>=t.width-.01){t.x=i.x,this.placed(t);break}}},i.placeInSpace=function(t,e){t.x=e.x,t.y=e.y,this.placed(t)},i.placed=function(t){for(var e=[],i=0;i=t.width-1&&this.height>=t.height-1};var a=e.create("packery");a.Item=r;var c=a.prototype;c._create=function(){e.prototype._create.call(this),this.packer=new s,this.shiftPacker=new s,this.isEnabled=!0,this.dragItemCount=0;var t=this;this.handleDraggabilly={dragStart:function(){t.itemDragStart(this.element)},dragMove:function(){t.itemDragMove(this.element,this.position.x,this.position.y)},dragEnd:function(){t.itemDragEnd(this.element)}},this.handleUIDraggable={start:function(e,i){i&&t.itemDragStart(e.currentTarget)},drag:function(e,i){i&&t.itemDragMove(e.currentTarget,i.position.left,i.position.top)},stop:function(e,i){i&&t.itemDragEnd(e.currentTarget)}}},c._resetLayout=function(){this.getSize(),this._getMeasurements();var t,e,i;this._getOption("horizontal")?(t=1/0,e=this.size.innerHeight+this.gutter,i="rightwardTopToBottom"):(t=this.size.innerWidth+this.gutter,e=1/0,i="downwardLeftToRight"),this.packer.width=this.shiftPacker.width=t,this.packer.height=this.shiftPacker.height=e,this.packer.sortDirection=this.shiftPacker.sortDirection=i,this.packer.reset(),this.maxY=0,this.maxX=0},c._getMeasurements=function(){this._getMeasurement("columnWidth","width"),this._getMeasurement("rowHeight","height"),this._getMeasurement("gutter","width")},c._getItemLayoutPosition=function(t){if(this._setRectSize(t.element,t.rect),this.isShifting||this.dragItemCount>0){var e=this._getPackMethod();this.packer[e](t.rect)}else this.packer.pack(t.rect);return this._setMaxXY(t.rect),t.rect},c.shiftLayout=function(){this.isShifting=!0,this.layout(),delete this.isShifting},c._getPackMethod=function(){return this._getOption("horizontal")?"rowPack":"columnPack"},c._setMaxXY=function(t){this.maxX=Math.max(t.x+t.width,this.maxX),this.maxY=Math.max(t.y+t.height,this.maxY)},c._setRectSize=function(e,i){var s=t(e),r=s.outerWidth,h=s.outerHeight;(r||h)&&(r=this._applyGridGutter(r,this.columnWidth),h=this._applyGridGutter(h,this.rowHeight)),i.width=Math.min(r,this.packer.width),i.height=Math.min(h,this.packer.height)},c._applyGridGutter=function(t,e){if(!e)return t+this.gutter;var i=t%(e+=this.gutter),s=i&&i<1?"round":"ceil";return t=Math[s](t/e)*e},c._getContainerSize=function(){return this._getOption("horizontal")?{width:this.maxX-this.gutter}:{height:this.maxY-this.gutter}},c._manageStamp=function(t){var e,s=this.getItem(t);if(s&&s.isPlacing)e=s.rect;else{var r=this._getElementOffset(t);e=new i({x:this._getOption("originLeft")?r.left:r.right,y:this._getOption("originTop")?r.top:r.bottom})}this._setRectSize(t,e),this.packer.placed(e),this._setMaxXY(e)},c.sortItemsByPosition=function(){var t=this._getOption("horizontal")?n:h;this.items.sort(t)},c.fit=function(t,e,i){var s=this.getItem(t);s&&(this.stamp(s.element),s.enablePlacing(),this.updateShiftTargets(s),e=void 0===e?s.rect.x:e,i=void 0===i?s.rect.y:i,this.shift(s,e,i),this._bindFitEvents(s),s.moveTo(s.rect.x,s.rect.y),this.shiftLayout(),this.unstamp(s.element),this.sortItemsByPosition(),s.disablePlacing())},c._bindFitEvents=function(t){function e(){2==++s&&i.dispatchEvent("fitComplete",null,[t])}var i=this,s=0;t.once("layout",e),this.once("layoutComplete",e)},c.resize=function(){this.isResizeBound&&this.needsResizeLayout()&&(this.options.shiftPercentResize?this.resizeShiftPercentLayout():this.layout())},c.needsResizeLayout=function(){var e=t(this.element),i=this._getOption("horizontal")?"innerHeight":"innerWidth";return e[i]!=this.size[i]},c.resizeShiftPercentLayout=function(){var e=this._getItemsForLayout(this.items),i=this._getOption("horizontal"),s=i?"y":"x",r=i?"height":"width",h=i?"rowHeight":"columnWidth",n=i?"innerHeight":"innerWidth",o=this[h];if(o=o&&o+this.gutter){this._getMeasurements();var a=this[h]+this.gutter;e.forEach(function(t){var e=Math.round(t.rect[s]/o);t.rect[s]=e*a})}else{var c=t(this.element)[n]+this.gutter,u=this.packer[r];e.forEach(function(t){t.rect[s]=t.rect[s]/u*c})}this.shiftLayout()},c.itemDragStart=function(t){if(this.isEnabled){this.stamp(t);var e=this.getItem(t);e&&(e.enablePlacing(),e.showDropPlaceholder(),this.dragItemCount++,this.updateShiftTargets(e))}},c.updateShiftTargets=function(t){this.shiftPacker.reset(),this._getBoundingRect();var e=this._getOption("originLeft"),s=this._getOption("originTop");this.stamps.forEach(function(t){var r=this.getItem(t);if(!r||!r.isPlacing){var h=this._getElementOffset(t),n=new i({x:e?h.left:h.right,y:s?h.top:h.bottom});this._setRectSize(t,n),this.shiftPacker.placed(n)}},this);var r=this._getOption("horizontal"),h=r?"rowHeight":"columnWidth",n=r?"height":"width";this.shiftTargetKeys=[],this.shiftTargets=[];var o,a=this[h];if(a=a&&a+this.gutter){var c=Math.ceil(t.rect[n]/a),u=Math.floor((this.shiftPacker[n]+this.gutter)/a);o=(u-c)*a;for(var d=0;di)){var r=t+","+e;-1!=this.shiftTargetKeys.indexOf(r)||(this.shiftTargetKeys.push(r),this.shiftTargets.push({x:t,y:e}))}},c.shift=function(t,e,i){var s,r=1/0,h={x:e,y:i};this.shiftTargets.forEach(function(t){var e=o(t,h);e