UNPKG

gridstack

Version:

TypeScript/JS lib for dashboard layout and creation, no external dependencies, with many wrappers (React, Angular, Vue, Ember, knockout...)

2 lines 207 kB
/*! For license information please see gridstack-jq.js.LICENSE.txt */ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.GridStack=e():t.GridStack=e()}(self,(function(){return t={852:function(t,e,i){"use strict";var n,o=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}),s=this&&this.__assign||function(){return(s=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var o in e=arguments[i])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.GridStackDD=void 0;var r=i(620),a=i(324),l=i(867),h=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.get=function(){return r.GridStackDDI.get()},e.prototype.remove=function(t){return this.draggable(t,"destroy").resizable(t,"destroy"),t.gridstackNode&&delete t.gridstackNode._initDD,this},e}(r.GridStackDDI);function u(t,e){var i=t?t.gridstackNode:void 0;i&&i.grid&&(e?i._isAboutToRemove=!0:delete i._isAboutToRemove,e?t.classList.add("grid-stack-item-removing"):t.classList.remove("grid-stack-item-removing"))}e.GridStackDD=h,a.GridStack.prototype._setupAcceptWidget=function(){var t,e,i=this;if(this.opts.staticGrid||!this.opts.acceptWidgets&&!this.opts.removable)return h.get().droppable(this.el,"destroy"),this;var n=function(n,o,s){var r=o.gridstackNode;if(r){s=s||o;var a=i.el.getBoundingClientRect(),u=s.getBoundingClientRect(),c=u.top,d=u.left;d-=a.left;var p={position:{top:c-=a.top,left:d}};if(r._temporaryRemoved){if(r.x=Math.max(0,Math.round(d/e)),r.y=Math.max(0,Math.round(c/t)),delete r.autoPosition,i.engine.nodeBoundFix(r),!i.engine.willItFit(r)){if(r.autoPosition=!0,!i.engine.willItFit(r))return void h.get().off(o,"drag");r._willFitPos&&(l.Utils.copyPos(r,r._willFitPos),delete r._willFitPos)}i._onStartMoving(s,n,p,r,e,t)}else i._dragOrResize(s,n,p,r,e,t)}};return h.get().droppable(this.el,{accept:function(t){var e=t.gridstackNode;if((null==e?void 0:e.grid)===i)return!0;if(!i.opts.acceptWidgets)return!1;if(null==e?void 0:e.subGrid)return!1;var n=!0;if("function"==typeof i.opts.acceptWidgets)n=i.opts.acceptWidgets(t);else{var o=!0===i.opts.acceptWidgets?".grid-stack-item":i.opts.acceptWidgets;n=t.matches(o)}if(n&&e&&i.opts.maxRow){var s={w:e.w,h:e.h,minW:e.minW,minH:e.minH};n=i.engine.willItFit(s)}return n}}).on(this.el,"dropover",(function(o,r,a){var l=r.gridstackNode;if((null==l?void 0:l.grid)===i&&!l._temporaryRemoved)return!1;(null==l?void 0:l.grid)&&l.grid!==i&&!l._temporaryRemoved&&l.grid._leave(r,a),e=i.cellWidth(),t=i.getCellHeight(!0),l||(l=i._readAttr(r)),l.grid||(l._isExternal=!0,r.gridstackNode=l),a=a||r;var c=l.w||Math.round(a.offsetWidth/e)||1,d=l.h||Math.round(a.offsetHeight/t)||1;return l.grid&&l.grid!==i?(r._gridstackNodeOrig||(r._gridstackNodeOrig=l),r.gridstackNode=l=s(s({},l),{w:c,h:d,grid:i}),i.engine.cleanupNode(l).nodeBoundFix(l),l._initDD=l._isExternal=l._temporaryRemoved=!0):(l.w=c,l.h=d,l._temporaryRemoved=!0),u(l.el,!1),h.get().on(r,"drag",n),n(o,r,a),!1})).on(this.el,"dropout",(function(t,e,n){var o=e.gridstackNode;return!!o&&(o.grid&&o.grid!==i||i._leave(e,n),!1)})).on(this.el,"drop",(function(t,e,n){var o=e.gridstackNode;if((null==o?void 0:o.grid)===i&&!o._isExternal)return!1;var r=!!i.placeholder.parentElement;i.placeholder.remove();var a=e._gridstackNodeOrig;if(delete e._gridstackNodeOrig,r&&a&&a.grid&&a.grid!==i){var u=a.grid;u.engine.removedNodes.push(a),u._triggerRemoveEvent()}return!!o&&(r&&(i.engine.cleanupNode(o),o.grid=i),h.get().off(e,"drag"),n!==e?(n.remove(),e.gridstackNode=a,r&&(e=e.cloneNode(!0))):(e.remove(),h.get().remove(e)),!!r&&(e.gridstackNode=o,o.el=e,l.Utils.copyPos(o,i._readAttr(i.placeholder)),l.Utils.removePositioningStyles(e),i._writeAttr(e,o),i.el.appendChild(e),i._updateContainerHeight(),i.engine.addedNodes.push(o),i._triggerAddEvent(),i._triggerChangeEvent(),i.engine.endUpdate(),i._gsEventHandler.dropped&&i._gsEventHandler.dropped(s(s({},t),{type:"dropped"}),a&&a.grid?a:void 0,o),window.setTimeout((function(){o.el&&o.el.parentElement?i._prepareDragDropByNode(o):i.engine.removeNode(o)})),!1))})),this},a.GridStack.prototype._setupRemoveDrop=function(){if(!this.opts.staticGrid&&"string"==typeof this.opts.removable){var t=document.querySelector(this.opts.removable);if(!t)return this;h.get().isDroppable(t)||h.get().droppable(t,this.opts.removableOptions).on(t,"dropover",(function(t,e){return u(e,!0)})).on(t,"dropout",(function(t,e){return u(e,!1)}))}return this},a.GridStack.setupDragIn=function(t,e){var i,n;if(t&&(i=t,n=s(s({},{revert:"invalid",handle:".grid-stack-item-content",scroll:!1,appendTo:"body"}),e||{})),"string"==typeof i){var o=h.get();l.Utils.getElements(i).forEach((function(t){o.isDraggable(t)||o.dragIn(t,n)}))}},a.GridStack.prototype._prepareDragDropByNode=function(t){var e=this,i=t.el,n=h.get();if(this.opts.staticGrid||(t.noMove||this.opts.disableDrag)&&(t.noResize||this.opts.disableResize))return t._initDD&&(n.remove(i),delete t._initDD),i.classList.add("ui-draggable-disabled","ui-resizable-disabled"),this;if(!t._initDD){var o,s,r=function(n,r){e._gsEventHandler[n.type]&&e._gsEventHandler[n.type](n,n.target),o=e.cellWidth(),s=e.getCellHeight(!0),e._onStartMoving(i,n,r,t,o,s)},a=function(n,r){e._dragOrResize(i,n,r,t,o,s)},u=function(o){e.placeholder.remove(),delete t._moving,delete t._lastTried;var s=o.target;if(s.gridstackNode&&s.gridstackNode.grid===e){if(t.el=s,t._isAboutToRemove){var r=i.gridstackNode.grid;r._gsEventHandler[o.type]&&r._gsEventHandler[o.type](o,s),n.remove(i),r.engine.removedNodes.push(t),r._triggerRemoveEvent(),delete i.gridstackNode,delete t.el,i.remove()}else t._temporaryRemoved?(l.Utils.removePositioningStyles(s),l.Utils.copyPos(t,t._orig),e._writePosAttr(s,t),e.engine.addNode(t)):(l.Utils.removePositioningStyles(s),e._writePosAttr(s,t)),e._gsEventHandler[o.type]&&e._gsEventHandler[o.type](o,s);e._extraDragRow=0,e._updateContainerHeight(),e._triggerChangeEvent(),e.engine.endUpdate()}};n.draggable(i,{start:r,stop:u,drag:a}).resizable(i,{start:r,stop:u,resize:a}),t._initDD=!0}return t.noMove||this.opts.disableDrag?(n.draggable(i,"disable"),i.classList.add("ui-draggable-disabled")):(n.draggable(i,"enable"),i.classList.remove("ui-draggable-disabled")),t.noResize||this.opts.disableResize?(n.resizable(i,"disable"),i.classList.add("ui-resizable-disabled")):(n.resizable(i,"enable"),i.classList.remove("ui-resizable-disabled")),this},a.GridStack.prototype._onStartMoving=function(t,e,i,n,o,s){if(this.engine.cleanNodes().beginUpdate(n),this._writePosAttr(this.placeholder,n),this.el.appendChild(this.placeholder),n.el=this.placeholder,n._lastUiPosition=i.position,n._prevYPix=i.position.top,n._moving="dragstart"===e.type,delete n._lastTried,"dropover"===e.type&&n._temporaryRemoved&&(this.engine.addNode(n),n._moving=!0),this.engine.cacheRects(o,s,this.opts.marginTop,this.opts.marginRight,this.opts.marginBottom,this.opts.marginLeft),"resizestart"===e.type){var r=h.get().resizable(t,"option","minWidth",o*(n.minW||1)).resizable(t,"option","minHeight",s*(n.minH||1));n.maxW&&r.resizable(t,"option","maxWidth",o*n.maxW),n.maxH&&r.resizable(t,"option","maxHeight",s*n.maxH)}},a.GridStack.prototype._leave=function(t,e){var i=t.gridstackNode;i&&(h.get().off(t,"drag"),i._temporaryRemoved||(i._temporaryRemoved=!0,this.engine.removeNode(i),i.el=i._isExternal&&e?e:t,!0===this.opts.removable&&u(t,!0),t._gridstackNodeOrig?(t.gridstackNode=t._gridstackNodeOrig,delete t._gridstackNodeOrig):i._isExternal&&(delete i.el,delete t.gridstackNode,this.engine.restoreInitial())))},a.GridStack.prototype._dragOrResize=function(t,e,i,n,o,r){var a,h=s({},n._orig),u=this.opts.marginLeft,c=this.opts.marginRight,d=this.opts.marginTop,p=this.opts.marginBottom,f=Math.round(.1*r),g=Math.round(.1*o);if(u=Math.min(u,g),c=Math.min(c,g),d=Math.min(d,f),p=Math.min(p,f),"drag"===e.type){if(n._temporaryRemoved)return;var m=i.position.top-n._prevYPix;n._prevYPix=i.position.top,l.Utils.updateScrollPosition(t,i.position,m);var v=i.position.left+(i.position.left>n._lastUiPosition.left?-c:u),y=i.position.top+(i.position.top>n._lastUiPosition.top?-p:d);h.x=Math.round(v/o),h.y=Math.round(y/r);var b=this._extraDragRow;if(this.engine.collide(n,h)){var _=this.getRow(),w=Math.max(0,h.y+n.h-_);this.opts.maxRow&&_+w>this.opts.maxRow&&(w=Math.max(0,this.opts.maxRow-_)),this._extraDragRow=w}else this._extraDragRow=0;if(this._extraDragRow!==b&&this._updateContainerHeight(),n.x===h.x&&n.y===h.y)return}else if("resize"===e.type){if(h.x<0)return;if(l.Utils.updateScrollResize(e,t,r),h.w=Math.round((i.size.width-u)/o),h.h=Math.round((i.size.height-d)/r),n.w===h.w&&n.h===h.h)return;if(n._lastTried&&n._lastTried.w===h.w&&n._lastTried.h===h.h)return;v=i.position.left+u;var x=i.position.top+d;h.x=Math.round(v/o),h.y=Math.round(x/r),a=!0}n._lastTried=h;var C={x:i.position.left+u,y:i.position.top+d,w:(i.size?i.size.width:n.w*o)-u-c,h:(i.size?i.size.height:n.h*r)-d-p};if(this.engine.moveNodeCheck(n,s(s({},h),{cellWidth:o,cellHeight:r,rect:C,resizing:a}))){n._lastUiPosition=i.position,this.engine.cacheRects(o,r,d,c,p,u),delete n._skipDown,a&&n.subGrid&&n.subGrid.onParentResize(),this._extraDragRow=0,this._updateContainerHeight();var E=e.target;this._writePosAttr(E,n),this._gsEventHandler[e.type]&&this._gsEventHandler[e.type](e,E)}},a.GridStack.prototype.movable=function(t,e){var i=this;return this.opts.staticGrid||a.GridStack.getElements(t).forEach((function(t){var n=t.gridstackNode;n&&(e?delete n.noMove:n.noMove=!0,i._prepareDragDropByNode(n))})),this},a.GridStack.prototype.resizable=function(t,e){var i=this;return this.opts.staticGrid||a.GridStack.getElements(t).forEach((function(t){var n=t.gridstackNode;n&&(e?delete n.noResize:n.noResize=!0,i._prepareDragDropByNode(n))})),this},a.GridStack.prototype.disable=function(){if(!this.opts.staticGrid)return this.enableMove(!1),this.enableResize(!1),this._triggerEvent("disable"),this},a.GridStack.prototype.enable=function(){if(!this.opts.staticGrid)return this.enableMove(!0),this.enableResize(!0),this._triggerEvent("enable"),this},a.GridStack.prototype.enableMove=function(t){var e=this;return this.opts.staticGrid||(this.opts.disableDrag=!t,this.engine.nodes.forEach((function(i){return e.movable(i.el,t)}))),this},a.GridStack.prototype.enableResize=function(t){var e=this;return this.opts.staticGrid||(this.opts.disableResize=!t,this.engine.nodes.forEach((function(i){return e.resizable(i.el,t)}))),this}},620:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.GridStackDDI=void 0;var i=function(){function t(){}return t.registerPlugin=function(e){return t.ddi=new e,t.ddi},t.get=function(){return t.ddi||t.registerPlugin(t)},t.prototype.remove=function(t){return this},t}();e.GridStackDDI=i},506:function(t,e,i){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var o in e=arguments[i])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.GridStackEngine=void 0;var o=i(867),s=function(){function t(t){void 0===t&&(t={}),this.addedNodes=[],this.removedNodes=[],this.column=t.column||12,this.onChange=t.onChange,this._float=t.float,this.maxRow=t.maxRow,this.nodes=t.nodes||[]}return t.prototype.batchUpdate=function(){return this.batchMode||(this.batchMode=!0,this._prevFloat=this._float,this._float=!0,this.saveInitial()),this},t.prototype.commit=function(){return this.batchMode?(this.batchMode=!1,this._float=this._prevFloat,delete this._prevFloat,this._packNodes()._notify()):this},t.prototype._useEntireRowArea=function(t,e){return!this.float&&!this._hasLocked&&(!t._moving||t._skipDown||e.y<=t.y)},t.prototype._fixCollisions=function(t,e,i,s){if(void 0===e&&(e=t),void 0===s&&(s={}),this._sortNodes(-1),!(i=i||this.collide(t,e)))return!1;if(t._moving&&!s.nested&&!this.float&&this.swap(t,i))return!0;var r=e;this._useEntireRowArea(t,e)&&(r={x:0,w:this.column,y:e.y,h:e.h},i=this.collide(t,r,s.skip));for(var a=!1,l={nested:!0,pack:!1};i=i||this.collide(t,r,s.skip);){var h=void 0;if(i.locked||t._moving&&!t._skipDown&&e.y>t.y&&!this.float&&(!this.collide(i,n(n({},i),{y:t.y}),t)||!this.collide(i,n(n({},i),{y:e.y-i.h}),t))?(t._skipDown=t._skipDown||e.y>t.y,h=this.moveNode(t,n(n(n({},e),{y:i.y+i.h}),l)),i.locked&&h?o.Utils.copyPos(e,t):!i.locked&&h&&s.pack&&(this._packNodes(),e.y=i.y+i.h,o.Utils.copyPos(t,e)),a=a||h):h=this.moveNode(i,n(n(n({},i),{y:e.y+e.h,skip:t}),l)),!h)return a;i=void 0}return a},t.prototype.collide=function(t,e,i){return void 0===e&&(e=t),this.nodes.find((function(n){return n!==t&&n!==i&&o.Utils.isIntercepted(n,e)}))},t.prototype.collideAll=function(t,e,i){return void 0===e&&(e=t),this.nodes.filter((function(n){return n!==t&&n!==i&&o.Utils.isIntercepted(n,e)}))},t.prototype.collideCoverage=function(t,e,i){if(e.rect&&t._rect){var o,s=t._rect,r=n({},e.rect);return r.y>s.y?(r.h+=r.y-s.y,r.y=s.y):r.h+=s.y-r.y,r.x>s.x?(r.w+=r.x-s.x,r.x=s.x):r.w+=s.x-r.x,i.forEach((function(t){if(!t.locked&&t._rect){var e=t._rect,i=Number.MAX_VALUE,n=Number.MAX_VALUE,a=.5;s.y<e.y?i=(r.y+r.h-e.y)/e.h:s.y+s.h>e.y+e.h&&(i=(e.y+e.h-r.y)/e.h),s.x<e.x?n=(r.x+r.w-e.x)/e.w:s.x+s.w>e.x+e.w&&(n=(e.x+e.w-r.x)/e.w);var l=Math.min(n,i);l>a&&(a=l,o=t)}})),o}},t.prototype.cacheRects=function(t,e,i,n,o,s){return this.nodes.forEach((function(r){return r._rect={y:r.y*e+i,x:r.x*t+s,w:r.w*t-s-n,h:r.h*e-i-o}})),this},t.prototype.swap=function(t,e){if(!e||e.locked||!t||t.locked)return!1;function i(){var i=e.x,n=e.y;return e.x=t.x,e.y=t.y,t.h!=e.h?(t.x=i,t.y=e.y+e.h):t.w!=e.w?(t.x=e.x+e.w,t.y=n):(t.x=i,t.y=n),t._dirty=e._dirty=!0,!0}var n;if(t.w===e.w&&t.h===e.h&&(t.x===e.x||t.y===e.y)&&(n=o.Utils.isTouching(t,e)))return i();if(!1!==n){if(t.w===e.w&&t.x===e.x&&(n||(n=o.Utils.isTouching(t,e)))){if(e.y<t.y){var s=t;t=e,e=s}return i()}if(!1!==n)return!(t.h!==e.h||t.y!==e.y||!n&&!(n=o.Utils.isTouching(t,e)))&&(e.x<t.x&&(s=t,t=e,e=s),i())}},t.prototype.isAreaEmpty=function(t,e,i,n){var o={x:t||0,y:e||0,w:i||1,h:n||1};return!this.collide(o)},t.prototype.compact=function(){var t=this;if(0===this.nodes.length)return this;this.batchUpdate()._sortNodes();var e=this.nodes;return this.nodes=[],e.forEach((function(e){e.locked||(e.autoPosition=!0),t.addNode(e,!1),e._dirty=!0})),this.commit()},Object.defineProperty(t.prototype,"float",{get:function(){return this._float||!1},set:function(t){this._float!==t&&(this._float=t||!1,t||this._packNodes()._notify())},enumerable:!1,configurable:!0}),t.prototype._sortNodes=function(t){return this.nodes=o.Utils.sort(this.nodes,t,this.column),this},t.prototype._packNodes=function(){var t=this;return this.batchMode||(this._sortNodes(),this.float?this.nodes.forEach((function(e){if(!e._updating&&void 0!==e._orig&&e.y!==e._orig.y)for(var i=e.y;i>e._orig.y;)--i,t.collide(e,{x:e.x,y:i,w:e.w,h:e.h})||(e._dirty=!0,e.y=i)})):this.nodes.forEach((function(e,i){if(!e.locked)for(;e.y>0;){var n=0===i?0:e.y-1;if(0!==i&&t.collide(e,{x:e.x,y:n,w:e.w,h:e.h}))break;e._dirty=e.y!==n,e.y=n}}))),this},t.prototype.prepareNode=function(e,i){(e=e||{})._id=e._id||t._idSeq++,void 0!==e.x&&void 0!==e.y&&null!==e.x&&null!==e.y||(e.autoPosition=!0);var n={x:0,y:0,w:1,h:1};return o.Utils.defaults(e,n),e.autoPosition||delete e.autoPosition,e.noResize||delete e.noResize,e.noMove||delete e.noMove,"string"==typeof e.x&&(e.x=Number(e.x)),"string"==typeof e.y&&(e.y=Number(e.y)),"string"==typeof e.w&&(e.w=Number(e.w)),"string"==typeof e.h&&(e.h=Number(e.h)),isNaN(e.x)&&(e.x=n.x,e.autoPosition=!0),isNaN(e.y)&&(e.y=n.y,e.autoPosition=!0),isNaN(e.w)&&(e.w=n.w),isNaN(e.h)&&(e.h=n.h),this.nodeBoundFix(e,i)},t.prototype.nodeBoundFix=function(t,e){var i=t._orig||o.Utils.copyPos({},t);return t.maxW&&(t.w=Math.min(t.w,t.maxW)),t.maxH&&(t.h=Math.min(t.h,t.maxH)),t.minW&&t.minW<=this.column&&(t.w=Math.max(t.w,t.minW)),t.minH&&(t.h=Math.max(t.h,t.minH)),t.w>this.column?(this.column<12&&!this._inColumnResize&&(t.w=Math.min(12,t.w),this.cacheOneLayout(t,12)),t.w=this.column):t.w<1&&(t.w=1),this.maxRow&&t.h>this.maxRow?t.h=this.maxRow:t.h<1&&(t.h=1),t.x<0&&(t.x=0),t.y<0&&(t.y=0),t.x+t.w>this.column&&(e?t.w=this.column-t.x:t.x=this.column-t.w),this.maxRow&&t.y+t.h>this.maxRow&&(e?t.h=this.maxRow-t.y:t.y=this.maxRow-t.h),o.Utils.samePos(t,i)||(t._dirty=!0),t},t.prototype.getDirtyNodes=function(t){return t?this.nodes.filter((function(t){return t._dirty&&!o.Utils.samePos(t,t._orig)})):this.nodes.filter((function(t){return t._dirty}))},t.prototype._notify=function(t,e){if(void 0===e&&(e=!0),this.batchMode)return this;var i=(t=void 0===t?[]:Array.isArray(t)?t:[t]).concat(this.getDirtyNodes());return this.onChange&&this.onChange(i,e),this},t.prototype.cleanNodes=function(){return this.batchMode||this.nodes.forEach((function(t){delete t._dirty,delete t._lastTried})),this},t.prototype.saveInitial=function(){return this.nodes.forEach((function(t){t._orig=o.Utils.copyPos({},t),delete t._dirty})),this._hasLocked=this.nodes.some((function(t){return t.locked})),this},t.prototype.restoreInitial=function(){return this.nodes.forEach((function(t){o.Utils.samePos(t,t._orig)||(o.Utils.copyPos(t,t._orig),t._dirty=!0)})),this._notify(),this},t.prototype.addNode=function(t,e){void 0===e&&(e=!1);var i=this.nodes.find((function(e){return e._id===t._id}));if(i)return i;if(delete(t=this._inColumnResize?this.nodeBoundFix(t):this.prepareNode(t))._temporaryRemoved,delete t._removeDOM,t.autoPosition){this._sortNodes();for(var n=function(e){var i=e%s.column,n=Math.floor(e/s.column);if(i+t.w>s.column)return"continue";var r={x:i,y:n,w:t.w,h:t.h};return s.nodes.find((function(t){return o.Utils.isIntercepted(r,t)}))?void 0:(t.x=i,t.y=n,delete t.autoPosition,"break")},s=this,r=0;"break"!==n(r);++r);}return this.nodes.push(t),e&&this.addedNodes.push(t),this._fixCollisions(t),this.batchMode||this._packNodes()._notify(),t},t.prototype.removeNode=function(t,e,i){return void 0===e&&(e=!0),void 0===i&&(i=!1),this.nodes.find((function(e){return e===t}))?(i&&this.removedNodes.push(t),e&&(t._removeDOM=!0),this.nodes=this.nodes.filter((function(e){return e!==t})),this._packNodes()._notify(t)):this},t.prototype.removeAll=function(t){return void 0===t&&(t=!0),delete this._layouts,0===this.nodes.length?this:(t&&this.nodes.forEach((function(t){return t._removeDOM=!0})),this.removedNodes=this.nodes,this.nodes=[],this._notify(this.removedNodes))},t.prototype.moveNodeCheck=function(e,i){var s,r=this;if(!this.changedPosConstrain(e,i))return!1;if(i.pack=!0,!this.maxRow)return this.moveNode(e,i);var a=new t({column:this.column,float:this.float,nodes:this.nodes.map((function(t){return t===e?s=n({},t):n({},t)}))});if(!s)return!1;var l=a.moveNode(s,i);if(this.maxRow&&l&&!(l=a.getRow()<=this.maxRow)&&!i.resizing){var h=this.collide(e,i);if(h&&this.swap(e,h))return this._notify(),!0}return!!l&&(a.nodes.filter((function(t){return t._dirty})).forEach((function(t){var e=r.nodes.find((function(e){return e._id===t._id}));e&&(o.Utils.copyPos(e,t),e._dirty=!0)})),this._notify(),!0)},t.prototype.willItFit=function(e){if(delete e._willFitPos,!this.maxRow)return!0;var i=new t({column:this.column,float:this.float,nodes:this.nodes.map((function(t){return n({},t)}))}),s=n({},e);return this.cleanupNode(s),delete s.el,delete s._id,delete s.content,delete s.grid,i.addNode(s),i.getRow()<=this.maxRow&&(e._willFitPos=o.Utils.copyPos({},s),!0)},t.prototype.changedPosConstrain=function(t,e){return e.w=e.w||t.w,e.h=e.h||t.h,t.x!==e.x||t.y!==e.y||(t.maxW&&(e.w=Math.min(e.w,t.maxW)),t.maxH&&(e.h=Math.min(e.h,t.maxH)),t.minW&&(e.w=Math.max(e.w,t.minW)),t.minH&&(e.h=Math.max(e.h,t.minH)),t.w!==e.w||t.h!==e.h)},t.prototype.moveNode=function(t,e){if(!t||!e)return!1;void 0===e.pack&&(e.pack=!0),"number"!=typeof e.x&&(e.x=t.x),"number"!=typeof e.y&&(e.y=t.y),"number"!=typeof e.w&&(e.w=t.w),"number"!=typeof e.h&&(e.h=t.h);var i=t.w!==e.w||t.h!==e.h,n=o.Utils.copyPos({},t,!0);if(o.Utils.copyPos(n,e),n=this.nodeBoundFix(n,i),o.Utils.copyPos(e,n),o.Utils.samePos(t,e))return!1;var s=o.Utils.copyPos({},t),r=n,a=this.collideAll(t,r,e.skip),l=!0;if(a.length){var h=t._moving&&!e.nested?this.collideCoverage(t,e,a):a[0];l=!!h&&!this._fixCollisions(t,n,h,e)}return l&&(t._dirty=!0,o.Utils.copyPos(t,n)),e.pack&&this._packNodes()._notify(),!o.Utils.samePos(t,s)},t.prototype.getRow=function(){return this.nodes.reduce((function(t,e){return Math.max(t,e.y+e.h)}),0)},t.prototype.beginUpdate=function(t){return t._updating||(t._updating=!0,delete t._skipDown,this.batchMode||this.saveInitial()),this},t.prototype.endUpdate=function(){var t=this.nodes.find((function(t){return t._updating}));return t&&(delete t._updating,delete t._skipDown),this},t.prototype.save=function(t){var e;void 0===t&&(t=!0);var i=null===(e=this._layouts)||void 0===e?void 0:e.length,o=i&&this.column!==i-1?this._layouts[i-1]:null,s=[];return this._sortNodes(),this.nodes.forEach((function(e){var i=null==o?void 0:o.find((function(t){return t._id===e._id})),r=n({},e);for(var a in i&&(r.x=i.x,r.y=i.y,r.w=i.w),r)"_"!==a[0]&&null!==r[a]&&void 0!==r[a]||delete r[a];delete r.grid,t||delete r.el,r.autoPosition||delete r.autoPosition,r.noResize||delete r.noResize,r.noMove||delete r.noMove,r.locked||delete r.locked,s.push(r)})),s},t.prototype.layoutsNodesChange=function(t){var e=this;return!this._layouts||this._inColumnResize||this._layouts.forEach((function(i,n){if(!i||n===e.column)return e;if(n<e.column)e._layouts[n]=void 0;else{var o=n/e.column;t.forEach((function(t){if(t._orig){var e=i.find((function(e){return e._id===t._id}));e&&(t.y!==t._orig.y&&(e.y+=t.y-t._orig.y),t.x!==t._orig.x&&(e.x=Math.round(t.x*o)),t.w!==t._orig.w&&(e.w=Math.round(t.w*o)))}}))}})),this},t.prototype.updateNodeWidths=function(t,e,i,n){var s,r=this;if(void 0===n&&(n="moveScale"),!this.nodes.length||!e||t===e)return this;this.cacheLayout(this.nodes,t),this.batchUpdate();var a=[],l=!1;if(1===e&&(null==i?void 0:i.length)){l=!0;var h=0;i.forEach((function(t){t.x=0,t.w=1,t.y=Math.max(t.y,h),h=t.y+t.h})),a=i,i=[]}else i=o.Utils.sort(this.nodes,-1,t);var u=[];if(e>t){u=this._layouts[e]||[];var c=this._layouts.length-1;!u.length&&t!==c&&(null===(s=this._layouts[c])||void 0===s?void 0:s.length)&&(t=c,this._layouts[c].forEach((function(t){var e=i.find((function(e){return e._id===t._id}));e&&(e.x=t.x,e.y=t.y,e.w=t.w)})))}if(u.forEach((function(t){var e=i.findIndex((function(e){return e._id===t._id}));-1!==e&&(i[e].x=t.x,i[e].y=t.y,i[e].w=t.w,a.push(i[e]),i.splice(e,1))})),i.length)if("function"==typeof n)n(e,t,a,i);else if(!l){var d=e/t,p="move"===n||"moveScale"===n,f="scale"===n||"moveScale"===n;i.forEach((function(i){i.x=1===e?0:p?Math.round(i.x*d):Math.min(i.x,e-1),i.w=1===e||1===t?1:f?Math.round(i.w*d)||1:Math.min(i.w,e),a.push(i)})),i=[]}return a=o.Utils.sort(a,-1,e),this._inColumnResize=!0,this.nodes=[],a.forEach((function(t){r.addNode(t,!1),delete t._orig})),this.commit(),delete this._inColumnResize,this},t.prototype.cacheLayout=function(e,i,n){void 0===n&&(n=!1);var o=[];return e.forEach((function(e,i){e._id=e._id||t._idSeq++,o[i]={x:e.x,y:e.y,w:e.w,_id:e._id}})),this._layouts=n?[]:this._layouts||[],this._layouts[i]=o,this},t.prototype.cacheOneLayout=function(e,i){e._id=e._id||t._idSeq++;var n={x:e.x,y:e.y,w:e.w,_id:e._id};this._layouts=this._layouts||[],this._layouts[i]=this._layouts[i]||[];var o=this._layouts[i].findIndex((function(t){return t._id===e._id}));return-1===o?this._layouts[i].push(n):this._layouts[i][o]=n,this},t.prototype.cleanupNode=function(t){for(var e in t)"_"===e[0]&&"_id"!==e&&delete t[e];return this},t._idSeq=1,t}();e.GridStackEngine=s},995:function(t,e,i){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,i,n){void 0===n&&(n=i),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[i]}})}:function(t,e,i,n){void 0===n&&(n=i),t[n]=e[i]}),o=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||e.hasOwnProperty(i)||n(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),o(i(855),e),o(i(867),e),o(i(506),e),o(i(620),e),o(i(324),e),o(i(344),e)},324:function(t,e,i){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var o in e=arguments[i])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(t,e,i,n){void 0===n&&(n=i),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[i]}})}:function(t,e,i,n){void 0===n&&(n=i),t[n]=e[i]}),s=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||e.hasOwnProperty(i)||o(e,t,i)},r=this&&this.__spreadArrays||function(){for(var t=0,e=0,i=arguments.length;e<i;e++)t+=arguments[e].length;var n=Array(t),o=0;for(e=0;e<i;e++)for(var s=arguments[e],r=0,a=s.length;r<a;r++,o++)n[o]=s[r];return n};Object.defineProperty(e,"__esModule",{value:!0}),e.GridStack=void 0;var a=i(506),l=i(867),h=i(620);s(i(855),e),s(i(867),e),s(i(506),e),s(i(620),e);var u={column:12,minRow:0,maxRow:0,itemClass:"grid-stack-item",placeholderClass:"grid-stack-placeholder",placeholderText:"",handle:".grid-stack-item-content",handleClass:null,styleInHead:!1,cellHeight:"auto",cellHeightThrottle:100,margin:10,auto:!0,minWidth:768,float:!1,staticGrid:!1,animate:!0,alwaysShowResizeHandle:!1,resizable:{autoHide:!0,handles:"se"},draggable:{handle:".grid-stack-item-content",scroll:!1,appendTo:"body"},disableDrag:!1,disableResize:!1,rtl:"auto",removable:!1,removableOptions:{accept:".grid-stack-item"},marginUnit:"px",cellHeightUnit:"px",disableOneColumnMode:!1,oneColumnModeDomSort:!1},c=function(){function t(e,i){var o=this;void 0===i&&(i={}),this._gsEventHandler={},this._extraDragRow=0,this.el=e,(i=i||{}).row&&(i.minRow=i.maxRow=i.row,delete i.row);var s=l.Utils.toNumber(e.getAttribute("gs-row"));"auto"===i.column&&delete i.column;var r=n(n({},l.Utils.cloneDeep(u)),{column:l.Utils.toNumber(e.getAttribute("gs-column"))||12,minRow:s||l.Utils.toNumber(e.getAttribute("gs-min-row"))||0,maxRow:s||l.Utils.toNumber(e.getAttribute("gs-max-row"))||0,staticGrid:l.Utils.toBool(e.getAttribute("gs-static"))||!1,_styleSheetClass:"grid-stack-instance-"+(1e4*Math.random()).toFixed(0),alwaysShowResizeHandle:i.alwaysShowResizeHandle||!1,resizable:{autoHide:!i.alwaysShowResizeHandle,handles:"se"},draggable:{handle:(i.handleClass?"."+i.handleClass:i.handle?i.handle:"")||".grid-stack-item-content",scroll:!1,appendTo:"body"},removableOptions:{accept:"."+(i.itemClass||"grid-stack-item")}});e.getAttribute("gs-animate")&&(r.animate=l.Utils.toBool(e.getAttribute("gs-animate"))),this.opts=l.Utils.defaults(i,r),i=null,this.initMargin(),1!==this.opts.column&&!this.opts.disableOneColumnMode&&this._widthOrContainer()<=this.opts.minWidth&&(this._prevColumn=this.getColumn(),this.opts.column=1),"auto"===this.opts.rtl&&(this.opts.rtl="rtl"===e.style.direction),this.opts.rtl&&this.el.classList.add("grid-stack-rtl");var h=l.Utils.closestByClass(this.el,u.itemClass);if(h&&h.gridstackNode&&(this.opts._isNested=h.gridstackNode,this.opts._isNested.subGrid=this,h.classList.add("grid-stack-nested"),this.el.classList.add("grid-stack-nested")),this._isAutoCellHeight="auto"===this.opts.cellHeight,this._isAutoCellHeight||"initial"===this.opts.cellHeight?this.cellHeight(void 0,!1):("number"==typeof this.opts.cellHeight&&this.opts.cellHeightUnit&&this.opts.cellHeightUnit!==u.cellHeightUnit&&(this.opts.cellHeight=this.opts.cellHeight+this.opts.cellHeightUnit,delete this.opts.cellHeightUnit),this.cellHeight(this.opts.cellHeight,!1)),this.el.classList.add(this.opts._styleSheetClass),this._setStaticClass(),this.engine=new a.GridStackEngine({column:this.getColumn(),float:this.opts.float,maxRow:this.opts.maxRow,onChange:function(t){var e=0;o.engine.nodes.forEach((function(t){e=Math.max(e,t.y+t.h)})),t.forEach((function(t){var e=t.el;e&&(t._removeDOM?(e&&e.remove(),delete t._removeDOM):o._writePosAttr(e,t))})),o._updateStyles(!1,e)}}),this.opts.auto){this.batchUpdate();var c=[];this.getGridItems().forEach((function(t){var e=parseInt(t.getAttribute("gs-x")),i=parseInt(t.getAttribute("gs-y"));c.push({el:t,i:(Number.isNaN(e)?1e3:e)+(Number.isNaN(i)?1e3:i)*o.getColumn()})})),c.sort((function(t,e){return t.i-e.i})).forEach((function(t){return o._prepareElement(t.el)})),this.commit()}this.setAnimation(this.opts.animate),this._updateStyles(),12!=this.opts.column&&this.el.classList.add("grid-stack-"+this.opts.column),this.opts.dragIn&&t.setupDragIn(this.opts.dragIn,this.opts.dragInOptions),delete this.opts.dragIn,delete this.opts.dragInOptions,this._setupRemoveDrop(),this._setupAcceptWidget(),this._updateWindowResizeEvent()}return t.init=function(e,i){void 0===e&&(e={}),void 0===i&&(i=".grid-stack");var n=t.getGridElement(i);return n?(n.gridstack||(n.gridstack=new t(n,l.Utils.cloneDeep(e))),n.gridstack):("string"==typeof i?console.error('GridStack.initAll() no grid was found with selector "'+i+'" - element missing or wrong selector ?\nNote: ".grid-stack" is required for proper CSS styling and drag/drop, and is the default selector.'):console.error("GridStack.init() no grid element was passed."),null)},t.initAll=function(e,i){void 0===e&&(e={}),void 0===i&&(i=".grid-stack");var n=[];return t.getGridElements(i).forEach((function(i){i.gridstack||(i.gridstack=new t(i,l.Utils.cloneDeep(e)),delete e.dragIn,delete e.dragInOptions),n.push(i.gridstack)})),0===n.length&&console.error('GridStack.initAll() no grid was found with selector "'+i+'" - element missing or wrong selector ?\nNote: ".grid-stack" is required for proper CSS styling and drag/drop, and is the default selector.'),n},t.addGrid=function(e,i){if(void 0===i&&(i={}),!e)return null;var n=e;if(!e.classList.contains("grid-stack")){var o=document.implementation.createHTMLDocument("");o.body.innerHTML='<div class="grid-stack '+(i.class||"")+'"></div>',n=o.body.children[0],e.appendChild(n)}var s=t.init(i,n);if(s.opts.children){var r=s.opts.children;delete s.opts.children,s.load(r)}return s},Object.defineProperty(t.prototype,"placeholder",{get:function(){if(!this._placeholder){var t=document.createElement("div");t.className="placeholder-content",this.opts.placeholderText&&(t.innerHTML=this.opts.placeholderText),this._placeholder=document.createElement("div"),this._placeholder.classList.add(this.opts.placeholderClass,u.itemClass,this.opts.itemClass),this.placeholder.appendChild(t)}return this._placeholder},enumerable:!1,configurable:!0}),t.prototype.addWidget=function(e,i){if(arguments.length>2){console.warn("gridstack.ts: `addWidget(el, x, y, width...)` is deprecated. Use `addWidget({x, y, w, content, ...})`. It will be removed soon");var n=arguments,o=1,s={x:n[o++],y:n[o++],w:n[o++],h:n[o++],autoPosition:n[o++],minW:n[o++],maxW:n[o++],minH:n[o++],maxH:n[o++],id:n[o++]};return this.addWidget(e,s)}function r(t){return void 0!==t.x||void 0!==t.y||void 0!==t.w||void 0!==t.h||void 0!==t.content}var a;if("string"==typeof e)(h=document.implementation.createHTMLDocument("")).body.innerHTML=e,a=h.body.children[0];else if(0===arguments.length||1===arguments.length&&r(e)){var h,u=e&&e.content||"";i=e,(h=document.implementation.createHTMLDocument("")).body.innerHTML='<div class="grid-stack-item '+(this.opts.itemClass||"")+'"><div class="grid-stack-item-content">'+u+"</div></div>",a=h.body.children[0]}else a=e;var c=this._readAttr(a);i=l.Utils.cloneDeep(i)||{},l.Utils.defaults(i,c);var d=this.engine.prepareNode(i);if(this._writeAttr(a,i),this._insertNotAppend?this.el.prepend(a):this.el.appendChild(a),this._prepareElement(a,!0,i),this._updateContainerHeight(),d.subGrid&&!d.subGrid.el){var p=void 0,f=d.subGrid;"auto"===f.column&&(f.column=d.w,f.disableOneColumnMode=!0,p=!0),u=d.el.querySelector(".grid-stack-item-content"),d.subGrid=t.addGrid(u,d.subGrid),p&&(d.subGrid._autoColumn=!0)}return this._triggerAddEvent(),this._triggerChangeEvent(),a},t.prototype.save=function(t,e){void 0===t&&(t=!0),void 0===e&&(e=!1);var i=this.engine.save(t);if(i.forEach((function(e){if(t&&e.el&&!e.subGrid){var i=e.el.querySelector(".grid-stack-item-content");e.content=i?i.innerHTML:void 0,e.content||delete e.content}else t||delete e.content,e.subGrid&&(e.subGrid=e.subGrid.save(t,!0));delete e.el})),e){var n=l.Utils.cloneDeep(this.opts);return n.marginBottom===n.marginTop&&n.marginRight===n.marginLeft&&n.marginTop===n.marginRight&&(n.margin=n.marginTop,delete n.marginTop,delete n.marginRight,delete n.marginBottom,delete n.marginLeft),n.rtl===("rtl"===this.el.style.direction)&&(n.rtl="auto"),this._isAutoCellHeight&&(n.cellHeight="auto"),this._autoColumn&&(n.column="auto",delete n.disableOneColumnMode),l.Utils.removeInternalAndSame(n,u),n.children=i,n}return i},t.prototype.load=function(e,i){var n=this;void 0===i&&(i=!0);var o=t.Utils.sort(r(e),-1,this._prevColumn||this.getColumn());this._insertNotAppend=!0,this._prevColumn&&this._prevColumn!==this.opts.column&&o.some((function(t){return t.x+t.w>n.opts.column}))&&(this._ignoreLayoutsNodeChange=!0,this.engine.cacheLayout(o,this._prevColumn,!0));var s=[];return this.batchUpdate(),i&&r(this.engine.nodes).forEach((function(t){o.find((function(e){return t.id===e.id}))||("function"==typeof i?i(n,t,!1):(s.push(t),n.removeWidget(t.el,!0,!1)))})),o.forEach((function(t){var e=t.id||0===t.id?n.engine.nodes.find((function(e){return e.id===t.id})):void 0;if(e){if(n.update(e.el,t),t.subGrid&&t.subGrid.children){var o=e.el.querySelector(".grid-stack");o&&o.gridstack&&(o.gridstack.load(t.subGrid.children),n._insertNotAppend=!0)}}else i&&(t="function"==typeof i?i(n,t,!0).gridstackNode:n.addWidget(t).gridstackNode)})),this.engine.removedNodes=s,this.commit(),delete this._ignoreLayoutsNodeChange,delete this._insertNotAppend,this},t.prototype.batchUpdate=function(){return this.engine.batchUpdate(),this},t.prototype.getCellHeight=function(t){if(void 0===t&&(t=!1),this.opts.cellHeight&&"auto"!==this.opts.cellHeight&&(!t||!this.opts.cellHeightUnit||"px"===this.opts.cellHeightUnit))return this.opts.cellHeight;var e=this.el.querySelector("."+this.opts.itemClass);if(e){var i=l.Utils.toNumber(e.getAttribute("gs-h"));return Math.round(e.offsetHeight/i)}var n=parseInt(this.el.getAttribute("gs-current-row"));return n?Math.round(this.el.getBoundingClientRect().height/n):this.opts.cellHeight},t.prototype.cellHeight=function(t,e){if(void 0===e&&(e=!0),e&&void 0!==t&&this._isAutoCellHeight!==("auto"===t)&&(this._isAutoCellHeight="auto"===t,this._updateWindowResizeEvent()),"initial"!==t&&"auto"!==t||(t=void 0),void 0===t){var i=-this.opts.marginRight-this.opts.marginLeft+this.opts.marginTop+this.opts.marginBottom;t=this.cellWidth()+i}var n=l.Utils.parseHeight(t);return this.opts.cellHeightUnit===n.unit&&this.opts.cellHeight===n.h||(this.opts.cellHeightUnit=n.unit,this.opts.cellHeight=n.h,e&&this._updateStyles(!0,this.getRow())),this},t.prototype.cellWidth=function(){return this._widthOrContainer()/this.getColumn()},t.prototype._widthOrContainer=function(){return this.el.clientWidth||this.el.parentElement.clientWidth||window.innerWidth},t.prototype.commit=function(){return this.engine.commit(),this._triggerRemoveEvent(),this._triggerAddEvent(),this._triggerChangeEvent(),this},t.prototype.compact=function(){return this.engine.compact(),this._triggerChangeEvent(),this},t.prototype.column=function(t,e){if(void 0===e&&(e="moveScale"),t<1||this.opts.column===t)return this;var i,n=this.getColumn();return 1===t?this._prevColumn=n:delete this._prevColumn,this.el.classList.remove("grid-stack-"+n),this.el.classList.add("grid-stack-"+t),this.opts.column=this.engine.column=t,1===t&&this.opts.oneColumnModeDomSort&&(i=[],this.getGridItems().forEach((function(t){t.gridstackNode&&i.push(t.gridstackNode)})),i.length||(i=void 0)),this.engine.updateNodeWidths(n,t,i,e),this._isAutoCellHeight&&this.cellHeight(),this._ignoreLayoutsNodeChange=!0,this._triggerChangeEvent(),delete this._ignoreLayoutsNodeChange,this},t.prototype.getColumn=function(){return this.opts.column},t.prototype.getGridItems=function(){var t=this;return Array.from(this.el.children).filter((function(e){return e.matches("."+t.opts.itemClass)&&!e.matches("."+t.opts.placeholderClass)}))},t.prototype.destroy=function(t){if(void 0===t&&(t=!0),this.el)return this._updateWindowResizeEvent(!0),this.setStatic(!0,!1),this.setAnimation(!1),t?this.el.parentNode.removeChild(this.el):(this.removeAll(t),this.el.classList.remove(this.opts._styleSheetClass)),this._removeStylesheet(),this.el.removeAttribute("gs-current-row"),delete this.opts._isNested,delete this.opts,delete this._placeholder,delete this.engine,delete this.el.gridstack,delete this.el,this},t.prototype.float=function(t){return this.engine.float=t,this._triggerChangeEvent(),this},t.prototype.getFloat=function(){return this.engine.float},t.prototype.getCellFromPixel=function(t,e){void 0===e&&(e=!1);var i,n=this.el.getBoundingClientRect();i=e?{top:n.top+document.documentElement.scrollTop,left:n.left}:{top:this.el.offsetTop,left:this.el.offsetLeft};var o=t.left-i.left,s=t.top-i.top,r=n.width/this.getColumn(),a=n.height/parseInt(this.el.getAttribute("gs-current-row"));return{x:Math.floor(o/r),y:Math.floor(s/a)}},t.prototype.getRow=function(){return Math.max(this.engine.getRow(),this.opts.minRow)},t.prototype.isAreaEmpty=function(t,e,i,n){return this.engine.isAreaEmpty(t,e,i,n)},t.prototype.makeWidget=function(e){var i=t.getElement(e);return this._prepareElement(i,!0),this._updateContainerHeight(),this._triggerAddEvent(),this._triggerChangeEvent(),i},t.prototype.on=function(t,e){var i=this;if(-1!==t.indexOf(" "))return t.split(" ").forEach((function(t){return i.on(t,e)})),this;if("change"===t||"added"===t||"removed"===t||"enable"===t||"disable"===t){var n="enable"===t||"disable"===t;this._gsEventHandler[t]=n?function(t){return e(t)}:function(t){return e(t,t.detail)},this.el.addEventListener(t,this._gsEventHandler[t])}else"drag"===t||"dragstart"===t||"dragstop"===t||"resizestart"===t||"resize"===t||"resizestop"===t||"dropped"===t?this._gsEventHandler[t]=e:console.log("GridStack.on("+t+') event not supported, but you can still use $(".grid-stack").on(...) while jquery-ui is still used internally.');return this},t.prototype.off=function(t){var e=this;return-1!==t.indexOf(" ")?(t.split(" ").forEach((function(t){return e.off(t)})),this):("change"!==t&&"added"!==t&&"removed"!==t&&"enable"!==t&&"disable"!==t||this._gsEventHandler[t]&&this.el.removeEventListener(t,this._gsEventHandler[t]),delete this._gsEventHandler[t],this)},t.prototype.removeWidget=function(e,i,n){var o=this;return void 0===i&&(i=!0),void 0===n&&(n=!0),t.getElements(e).forEach((function(t){if(t.parentElement===o.el){var e=t.gridstackNode;e||(e=o.engine.nodes.find((function(e){return t===e.el}))),e&&(delete t.gridstackNode,h.GridStackDDI.get().remove(t),o.engine.removeNode(e,i,n),i&&t.parentElement&&t.remove())}})),n&&(this._triggerRemoveEvent(),this._triggerChangeEvent()),this},t.prototype.removeAll=function(t){return void 0===t&&(t=!0),this.engine.nodes.forEach((function(t){delete t.el.gridstackNode,h.GridStackDDI.get().remove(t.el)})),this.engine.removeAll(t),this._triggerRemoveEvent(),this},t.prototype.setAnimation=function(t){return t?this.el.classList.add("grid-stack-animate"):this.el.classList.remove("grid-stack-animate"),this},t.prototype.setStatic=function(t,e){var i=this;return void 0===e&&(e=!0),this.opts.staticGrid===t||(this.opts.staticGrid=t,this._setupRemoveDrop(),this._setupAcceptWidget(),this.engine.nodes.forEach((function(t){return i._prepareDragDropByNode(t)})),e&&this._setStaticClass()),this},t.prototype.update=function(e,i){var n=this;if(arguments.length>2){console.warn("gridstack.ts: `update(el, x, y, w, h)` is deprecated. Use `update(el, {x, w, content, ...})`. It will be removed soon");var o=arguments,s=1;return i={x:o[s++],y:o[s++],w:o[s++],h:o[s++]},this.update(e,i)}return t.getElements(e).forEach((function(t){if(t&&t.gridstackNode){var e=t.gridstackNode,o=l.Utils.cloneDeep(i);delete o.autoPosition;var s,r=["x","y","w","h"];if(r.some((function(t){return void 0!==o[t]&&o[t]!==e[t]}))&&(s={},r.forEach((function(t){s[t]=void 0!==o[t]?o[t]:e[t],delete o[t]}))),!s&&(o.minW||o.minH||o.maxW||o.maxH)&&(s={}),o.content){var a=t.querySelector(".grid-stack-item-content");a&&a.innerHTML!==o.content&&(a.innerHTML=o.content),delete o.content}var h=!1,u=!1;for(var c in o)"_"!==c[0]&&e[c]!==o[c]&&(e[c]=o[c],h=!0,u=u||!n.opts.staticGrid&&("noResize"===c||"noMove"===c||"locked"===c));s&&(n.engine.cleanNodes().beginUpdate(e).moveNode(e,s),n._updateContainerHeight(),n._triggerChangeEvent(),n.engine.endUpdate()),h&&n._writeAttr(t,e),u&&n._prepareDragDropByNode(e)}})),this},t.prototype.margin=function(t){if(!("string"==typeof t&&t.split(" ").length>1)){var e=l.Utils.parseHeight(t);if(this.opts.marginUnit===e.unit&&this.opts.margin===e.h)return}return this.opts.margin=t,this.opts.marginTop=this.opts.marginBottom=this.opts.marginLeft=this.opts.marginRight=void 0,this.initMargin(),this._updateStyles(!0),this},t.prototype.getMargin=function(){return this.opts.margin},t.prototype.willItFit=function(t){if(arguments.length>1){console.warn("gridstack.ts: `willItFit(x,y,w,h,autoPosition)` is deprecated. Use `willItFit({x, y,...})`. It will be removed soon");var e=arguments,i=0,n={x:e[i++],y:e[i++],w:e[i++],h:e[i++],autoPosition:e[i++]};return this.willItFit(n)}return this.engine.willItFit(t)},t.prototype._triggerChangeEvent=function(){if(this.engine.batchMode)return this;var t=this.engine.getDirtyNodes(!0);return t&&t.length&&(this._ignoreLayoutsNodeChange||this.engine.layoutsNodesChange(t),this._triggerEvent("change",t)),this.engine.saveInitial(),this},t.prototype._triggerAddEvent=function(){return this.engine.batchMode||this.engine.addedNodes&&this.engine.addedNodes.length>0&&(this._ignoreLayoutsNodeChange||this.engine.layoutsNodesChange(this.engine.addedNodes),this.engine.addedNodes.forEach((function(t){delete t._dirty})),this._triggerEvent("added",this.engine.addedNodes),this.engine.addedNodes=[]),this},t.prototype._triggerRemoveEvent=function(){return this.engine.batchMode||this.engine.removedNodes&&this.engine.removedNodes.length>0&&(this._triggerEvent("removed",this.engine.removedNodes),this.engine.removedNodes=[]),this},t.prototype._triggerEvent=function(t,e){var i=e?new CustomEvent(t,{bubbles:!1,detail:e}):new Event(t);return this.el.dispatchEvent(i),this},t.prototype._removeStylesheet=function(){return this._styles&&(l.Utils.removeStylesheet(this._styles._id),delete this._styles),this},t.prototype._updateStyles=function(t,e){if(void 0===t&&(t=!1),t&&this._removeStylesheet(),this._updateContainerHeight(),0===this.opts.cellHeight)return this;var i=this.opts.cellHeight,n=this.opts.cellHeightUnit,o="."+this.opts._styleSheetClass+" > ."+this.opts.itemClass;if(!this._styles){var s="gridstack-style-"+(1e5*Math.random()).toFixed(),r=this.opts.styleInHead?void 0:this.el.parentNode;if(this._styles=l.Utils.createStylesheet(s,r),!this._styles)return this;this._styles._id=s,this._styles._max=0,l.Utils.addCSSRule(this._styles,o,"min-height: "+i+n);var a=this.opts.marginTop+this.opts.marginUnit,h=this.opts.marginBottom+this.opts.marginUnit,u=this.opts.marginRight+this.opts.marginUnit,c=this.opts.marginLeft+this.opts.marginUnit,d=o+" > .grid-stack-item-content",p="."+this.opts._styleSheetClass+" > .grid-stack-placeholder > .placeholder-content";l.Utils.addCSSRule(this._styles,d,"top: "+a+"; right: "+u+"; bottom: "+h+"; left: "+c+";"),l.Utils.addCSSRule(this._styles,p,"top: "+a+"; right: "+u+"; bottom: "+h+"; left: "+c+";"),l.Utils.addCSSRule(this._styles,o+" > .ui-resizable-ne","right: "+u),l.Utils.addCSSRule(this._styles,o+" > .ui-resizable-e","right: "+u),l.Utils.addCSSRule(this._styles,o+" > .ui-resizable-se","right: "+u+"; bottom: "+h),l.Utils.addCSSRule(this._styles,o+" > .ui-resizable-nw","left: "+c),l.Utils.addCSSRule(this._styles,o+" > .ui-resizable-w","left: "+c),l.Utils.addCSSRule(this._styles,o+" > .ui-resizable-sw","left: "+c+"; bottom: "+h)}if((e=e||this._styles._max)>this._styles._max){for(var f=function(t){return i*t+n},g=this._styles._max+1;g<=e;g++){var m=f(g);l.Utils.addCSSRule(this._styles,o+'[gs-y="'+(g-1)+'"]',"top: "+f(g-1)),l.Utils.addCSSRule(this._styles,o+'[gs-h="'+g+'"]',"height: "+m),l.Utils.addCSSRule(this._styles,o+'[gs-min-h="'+g+'"]',"min-height: "+m),l.Utils.addCSSRule(this._styles,o+'[gs-max-h="'+g+'"]',"max-height: "+m)}this._styles._max=e}return this},t.prototype._updateContainerHeight=function(){if(!this.engine||this.engine.batchMode)return this;var t=this.getRow()+this._extraDragRow;if(this.el.setAttribute("gs-current-row",String(t)),0===t)return this.el.style.removeProperty("height"),this;var e=this.opts.cellHeight,i=this.opts.cellHeightUnit;return e?(this.el.style.height=t*e+i,this):this},t.prototype._prepareElement=function(t,e,i){void 0===e&&(e=!1),i||(t.classList.add(this.opts.itemClass),i=this._readAttr(t)),t.gridstackNode=i,i.el=t,i.grid=this;var o=n({},i);return i=this.engine.addNode(i,e),l.Utils.same(i,o)||this._writeAttr(t,i),this._prepareDragDropByNode(i),this},t.prototype._writePosAttr=function(t,e){return void 0!==e.x&&null!==e.x&&t.setAttribute("gs-x",String(e.x)),void 0!==e.y&&null!==e.y&&t.setAttribute("gs-y",String(e.y)),e.w&&t.setAttribute("gs-w",String(e.w)),e.h&&t.setAttribute("gs-h",String(e.h)),this},t.prototype._writeAttr=function(t,e){if(!e)return this;this._writePosAttr(t,e);var i={autoPosition:"gs-auto-position",minW:"gs-min-w",minH:"gs-min-h",maxW:"gs-max-w",maxH:"gs-max-h",noResize:"gs-no-resize",noMove:"gs-no-move",locked:"gs-locked",id:"gs-id",resizeHandles:"gs-resize-handles"};for(var n in i)e[n]?t.setAttribute(i[n],String(e[n])):t.removeAttribute(i[n]);return this},t.prototype._readAttr=function(t){var e={};for(var i in e.x=l.Utils.toNumber(t.getAttribute("gs-x")),e.y=l.Utils.toNumber(t.getAttribute("gs-y")),e.w=l.Utils.toNumber(t.getAttribute("gs-w")),e.h=l.Utils.toNumber(t.getAttribute("gs-h")),e.maxW=l.Utils.toNumber(t.getAttribute("gs-max-w")),e.minW=l.Utils.toNumber(t.getAttribute("gs-min-w")),e.maxH=l.Utils.toNumber(t.getAttribute("gs-max-h")),e.minH=l.Utils.toNumber(t.getAttribute("gs-min-h")),e.autoPosition=l.Utils.toBool(t.getAttribute("gs-auto-position")),e.noResize=l.Utils.toBool(t.getAttribute("gs-no-resize")),e.noMove=l.Utils.toBool(t.getAttribute("gs-no-move")),e.locked=l.Utils.toBool(t.getAttribute("gs-locked")),e.resizeHandles=t.getAttribute("gs-resize-handles"),e.id=t.getAttribute("gs-id"),e){if(!e.hasOwnProperty(i))return;e[i]||0===e[i]||delete e[i]}return e},t.prototype._setStaticClass=function(){var t,e,i=["grid-stack-static"];return this.opts.staticGrid?((t=this.el.classList).add.apply(t,i),this.el.setAttribute("gs-static","true")):((e=this.el.classList).remove.apply(e,i),this.el.removeAttribute("gs-static")),this},t.prototype.onParentResize=function(){var t=this;if(this.el&&this.el.clientWidth){var e=!1;if(this._autoColumn&&this.opts._isNested)this.opts.column!==this.opts._isNested.w&&(e=!0,this.column(this.opts._isNested.w,"none"));else{var i=!this.opts.disableOneColumnMode&&this.el.clientWidth<=this.opts.minWidth;1===this.opts.column!==i&&(e=!0,this.opts.animate&&this.setAnimation(!1),this.column(i?1:this._prevColumn),this.opts.animate&&this.setAnimation(!0))}return this._isAutoCellHeight&&(!e&&this.opts.cellHeightThrottle?(this._cellHeightThrottle||(this._cellHeightThrottle=l.Utils.throttle((function(){return t.cellHeight()}),this.opts.cellHeightThrottle)),this._cellHeightThrottle()):this.cellHeight()),this.engine.nodes.forEach((function(t){t.subGrid&&t.subGrid.onParentResize()})),this}},t.prototype._updateWindowResizeEvent=function(t){void 0===t&&(t=!1);var e=(this._isAutoCellHeight||!this.opts.disableOneColumnMode)&&!this.opts._isNested;return t||!e||this._windowResizeBind?!t&&e||!this._windowResizeBind||(window.removeEventListener("resize",this._windowResizeBind),delete this._windowResizeBind):(this._windowResizeBind=this.onParentResize.bind(this),window.addEventListener("resize",this._windowResizeBind)),this},t.getElement=function(t){return void 0===t&&(t=".grid-stack-item"),l.Utils.getElement(t)},t.getElements=function(t){return void 0===t&&(t=".grid-stack-item"),l.Utils.getElements(t)},t.getGridElement=function(e){return t.getElement(e)},t.getGridElements=function(t){return l.Utils.getElements(t)},t.prototype.initMargin=function(){var t,e=0,i=[];return"string"==typeof this.opts.margin&&(i=this.opts.margin.split(" ")),2===i.length?(this.opts.marginTop=this.opts.marginBottom=i[0],this.opts.marginLeft=this.opts.marginRight=i[1]):4===i.length?(this.opts.marginTop=i[0],this.opts.marginRight=i[1],this.opts.marginBottom=i[2],this.opts.marginLeft=i[3]):(t=l.Utils.parseHeight(this.opts.margin),this.opts.marginUnit=t.unit,e=this.opts.margin=t.h),void 0===this.opts.marginTop?this.opts.marginTop=e:(t=l.Utils.parseHeight(this.opts.marginTop),this.opts.marginTop=t.h,delete this.opts.margin),void 0===this.opts.marginBottom?this.opts.marginBottom=e:(t=l.Utils.parseHeight(this.opts.marginBottom),this.opts.marginBottom=t.h,delete this.opts.margin),void 0===this.opts.marginRight?this.opts.marginRight=e:(t=l.Utils.parseHeight(this.opts.marginRight),this.opts.marginRight=t.h,delete this.opts.margin),void 0===this.opts.marginLeft?this.opts.marginLeft=e:(t=l.Utils.parseHeight(this.opts.marginLeft),this.opts.marginLeft=t.h,delete this.opts.margin),this.opts.marginUnit=t.unit,this.opts.marginTop===this.opts.marginBottom&&this.opts.marginLeft===this.opts.marginRight&&this.opts.marginTop===this.opts.marginRight&&(this.opts.margin=this.opts.marginTop),this},t.setupDragIn=function(t,e){},t.prototype.movable=function(t,e){return this},t.prototype.resizable=function(t,e){return thi