diff --git a/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/LICENSE b/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/LICENSE index cb9d9576..afa5dda6 100644 --- a/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/LICENSE +++ b/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/LICENSE @@ -1,6 +1,14 @@ -The MIT License (MIT) +v4+ Copyright (c) 2021 Alain Dumesny +under MIT license + +previous v3.x and older is: +/** + * https://gridstackjs.com/ + * (c) 2014-2020 Alain Dumesny, Dylan Weiss, Pavel Reznikov + * gridstack.js may be freely distributed under the MIT license. +*/ -Copyright (c) 2014-2020 Alain Dumesny, Dylan Weiss, Pavel Reznikov +The MIT License (MIT) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-dd.d.ts b/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-dd.d.ts index 7e482f61..33f65a6b 100644 --- a/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-dd.d.ts +++ b/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-dd.d.ts @@ -1,5 +1,5 @@ /** - * gridstack-dd.ts 4.2.5 + * gridstack-dd.ts 4.2.6 * Copyright (c) 2021 Alain Dumesny - see GridStack root license */ import { GridStackDDI } from './gridstack-ddi'; diff --git a/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-dd.js b/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-dd.js index 25014d38..af5680e1 100644 --- a/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-dd.js +++ b/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-dd.js @@ -1,9 +1,10 @@ "use strict"; /** - * gridstack-dd.ts 4.2.5 + * gridstack-dd.ts 4.2.6 * Copyright (c) 2021 Alain Dumesny - see GridStack root license */ Object.defineProperty(exports, "__esModule", { value: true }); +exports.GridStackDD = void 0; /* eslint-disable @typescript-eslint/no-unused-vars */ const gridstack_ddi_1 = require("./gridstack-ddi"); const gridstack_1 = require("./gridstack"); @@ -36,7 +37,7 @@ exports.GridStackDD = GridStackDD; /** @internal called to add drag over to support widgets being added externally */ gridstack_1.GridStack.prototype._setupAcceptWidget = function () { // check if we need to disable things - if (this.opts.staticGrid || !this.opts.acceptWidgets) { + if (this.opts.staticGrid || (!this.opts.acceptWidgets && !this.opts.removable)) { GridStackDD.get().droppable(this.el, 'destroy'); return this; } @@ -126,7 +127,7 @@ gridstack_1.GridStack.prototype._setupAcceptWidget = function () { cellWidth = this.cellWidth(); cellHeight = this.getCellHeight(true); // load any element attributes if we don't have a node - if (!node) { + if (!node) { // @ts-ignore node = this._readAttr(el); } if (!node.grid) { @@ -219,13 +220,14 @@ gridstack_1.GridStack.prototype._setupAcceptWidget = function () { return false; el.gridstackNode = node; node.el = el; + // @ts-ignore utils_1.Utils.copyPos(node, this._readAttr(this.placeholder)); // placeholder values as moving VERY fast can throw things off #1578 - utils_1.Utils.removePositioningStyles(el); + utils_1.Utils.removePositioningStyles(el); // @ts-ignore this._writeAttr(el, node); - this.el.appendChild(el); + this.el.appendChild(el); // @ts-ignore this._updateContainerHeight(); - this.engine.addedNodes.push(node); - this._triggerAddEvent(); + this.engine.addedNodes.push(node); // @ts-ignore + this._triggerAddEvent(); // @ts-ignore this._triggerChangeEvent(); this.engine.endUpdate(); if (this._gsEventHandler['dropped']) { @@ -354,13 +356,13 @@ gridstack_1.GridStack.prototype._prepareDragDropByNode = function (node) { else { if (!node._temporaryRemoved) { // move to new placeholder location - utils_1.Utils.removePositioningStyles(target); + utils_1.Utils.removePositioningStyles(target); // @ts-ignore this._writePosAttr(target, node); } else { // got removed - restore item back to before dragging position utils_1.Utils.removePositioningStyles(target); - utils_1.Utils.copyPos(node, node._orig); + utils_1.Utils.copyPos(node, node._orig); // @ts-ignore this._writePosAttr(target, node); this.engine.addNode(node); } @@ -368,8 +370,9 @@ gridstack_1.GridStack.prototype._prepareDragDropByNode = function (node) { this._gsEventHandler[event.type](event, target); } } - this._extraDragRow = 0; - this._updateContainerHeight(); + // @ts-ignore + this._extraDragRow = 0; // @ts-ignore + this._updateContainerHeight(); // @ts-ignore this._triggerChangeEvent(); this.engine.endUpdate(); }; @@ -407,6 +410,7 @@ gridstack_1.GridStack.prototype._prepareDragDropByNode = function (node) { gridstack_1.GridStack.prototype._onStartMoving = function (el, event, ui, node, cellWidth, cellHeight) { this.engine.cleanNodes() .beginUpdate(node); + // @ts-ignore this._writePosAttr(this.placeholder, node); this.el.appendChild(this.placeholder); // TEST console.log('_onStartMoving placeholder') @@ -471,6 +475,7 @@ gridstack_1.GridStack.prototype._leave = function (el, helper) { gridstack_1.GridStack.prototype._dragOrResize = function (el, event, ui, node, cellWidth, cellHeight) { let p = Object.assign({}, node._orig); // could be undefined (_isExternal) which is ok (drag only set x,y and w,h will default to node value) let resizing; + const mLeft = this.opts.marginLeft, mRight = this.opts.marginRight, mTop = this.opts.marginTop, mBottom = this.opts.marginBottom; if (event.type === 'drag') { if (node._temporaryRemoved) return; // handled by dropover @@ -478,22 +483,22 @@ gridstack_1.GridStack.prototype._dragOrResize = function (el, event, ui, node, c node._prevYPix = ui.position.top; utils_1.Utils.updateScrollPosition(el, ui.position, distance); // get new position taking into account the margin in the direction we are moving! (need to pass mid point by margin) - let left = ui.position.left + (ui.position.left > node._lastUiPosition.left ? -this.opts.marginRight : this.opts.marginLeft); - let top = ui.position.top + (ui.position.top > node._lastUiPosition.top ? -this.opts.marginBottom : this.opts.marginTop); + let left = ui.position.left + (ui.position.left > node._lastUiPosition.left ? -mRight : mLeft); + let top = ui.position.top + (ui.position.top > node._lastUiPosition.top ? -mBottom : mTop); p.x = Math.round(left / cellWidth); p.y = Math.round(top / cellHeight); - // if we're at the bottom hitting something else, grow the grid so cursor doesn't leave when trying to place below others + // @ts-ignore// if we're at the bottom hitting something else, grow the grid so cursor doesn't leave when trying to place below others let prev = this._extraDragRow; if (this.engine.collide(node, p)) { let row = this.getRow(); let extra = Math.max(0, (p.y + node.h) - row); if (this.opts.maxRow && row + extra > this.opts.maxRow) { extra = Math.max(0, this.opts.maxRow - row); - } - this._extraDragRow = extra; + } // @ts-ignore + this._extraDragRow = extra; // @ts-ignore } else - this._extraDragRow = 0; + this._extraDragRow = 0; // @ts-ignore if (this._extraDragRow !== prev) this._updateContainerHeight(); if (node.x === p.x && node.y === p.y) @@ -507,36 +512,36 @@ gridstack_1.GridStack.prototype._dragOrResize = function (el, event, ui, node, c // Scrolling page if needed utils_1.Utils.updateScrollResize(event, el, cellHeight); // get new size - p.w = Math.round((ui.size.width - this.opts.marginLeft) / cellWidth); - p.h = Math.round((ui.size.height - this.opts.marginTop) / cellHeight); + p.w = Math.round((ui.size.width - mLeft) / cellWidth); + p.h = Math.round((ui.size.height - mTop) / cellHeight); if (node.w === p.w && node.h === p.h) return; if (node._lastTried && node._lastTried.w === p.w && node._lastTried.h === p.h) return; // skip one we tried (but failed) // if we size on left/top side this might move us, so get possible new position as well - let left = ui.position.left + this.opts.marginLeft; - let top = ui.position.top + this.opts.marginTop; + let left = ui.position.left + mLeft; + let top = ui.position.top + mTop; p.x = Math.round(left / cellWidth); p.y = Math.round(top / cellHeight); resizing = true; } node._lastTried = p; // set as last tried (will nuke if we go there) let rect = { - x: ui.position.left + this.opts.marginLeft, - y: ui.position.top + this.opts.marginTop, - w: (ui.size ? ui.size.width : node.w * cellWidth) - this.opts.marginLeft - this.opts.marginRight, - h: (ui.size ? ui.size.height : node.h * cellHeight) - this.opts.marginTop - this.opts.marginBottom + x: ui.position.left + mLeft, + y: ui.position.top + mTop, + w: (ui.size ? ui.size.width : node.w * cellWidth) - mLeft - mRight, + h: (ui.size ? ui.size.height : node.h * cellHeight) - mTop - mBottom }; if (this.engine.moveNodeCheck(node, Object.assign(Object.assign({}, p), { cellWidth, cellHeight, rect }))) { node._lastUiPosition = ui.position; - this.engine.cacheRects(cellWidth, cellHeight, this.opts.marginTop, this.opts.marginRight, this.opts.marginBottom, this.opts.marginLeft); + this.engine.cacheRects(cellWidth, cellHeight, mTop, mRight, mBottom, mLeft); delete node._skipDown; if (resizing && node.subGrid) { node.subGrid.onParentResize(); - } - this._extraDragRow = 0; + } // @ts-ignore + this._extraDragRow = 0; // @ts-ignore this._updateContainerHeight(); - let target = event.target; + let target = event.target; // @ts-ignore this._writePosAttr(target, node); if (this._gsEventHandler[event.type]) { this._gsEventHandler[event.type](event, target); @@ -596,7 +601,7 @@ gridstack_1.GridStack.prototype.disable = function () { if (this.opts.staticGrid) return; this.enableMove(false); - this.enableResize(false); + this.enableResize(false); // @ts-ignore this._triggerEvent('disable'); return this; }; @@ -612,7 +617,7 @@ gridstack_1.GridStack.prototype.enable = function () { if (this.opts.staticGrid) return; this.enableMove(true); - this.enableResize(true); + this.enableResize(true); // @ts-ignore this._triggerEvent('enable'); return this; }; diff --git a/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-dd.js.map b/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-dd.js.map index f827e9ef..4747a8f0 100644 --- a/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-dd.js.map +++ b/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-dd.js.map @@ -1 +1 @@ -{"version":3,"file":"gridstack-dd.js","sourceRoot":"","sources":["../src/gridstack-dd.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAEH,sDAAsD;AACtD,mDAA+C;AAE/C,2CAAuD;AACvD,mCAAgC;AAiBhC;;GAEG;AACH,MAAsB,WAAY,SAAQ,4BAAY;IAEpD,uCAAuC;IACvC,MAAM,CAAC,GAAG;QACR,OAAO,4BAAY,CAAC,GAAG,EAAiB,CAAC;IAC3C,CAAC;IAED,4DAA4D;IACrD,MAAM,CAAC,EAAuB;QACnC,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,SAAS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AAQ,CAAC,CAAC,CAAC;IAC/D,OAAO,IAAI,CAAC;AACd,CAAC,CAAA","sourcesContent":["/**\r\n * gridstack-dd.ts 4.2.5\r\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\r\n */\r\n\r\n/* eslint-disable @typescript-eslint/no-unused-vars */\r\nimport { GridStackDDI } from './gridstack-ddi';\r\nimport { GridItemHTMLElement, GridStackNode, GridStackElement, DDUIData, DDDragInOpt, GridStackPosition } from './types';\r\nimport { GridStack, MousePosition } from './gridstack';\r\nimport { Utils } from './utils';\r\n\r\n/** Drag&Drop drop options */\r\nexport type DDDropOpt = {\r\n /** function or class type that this grid will accept as dropped items (see GridStackOptions.acceptWidgets) */\r\n accept?: (el: GridItemHTMLElement) => boolean;\r\n}\r\n\r\n/** drag&drop options currently called from the main code, but others can be passed in grid options */\r\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\r\nexport type DDOpts = 'enable' | 'disable' | 'destroy' | 'option' | string | any;\r\nexport type DDKey = 'minWidth' | 'minHeight' | 'maxWidth' | 'maxHeight';\r\nexport type DDValue = number | string;\r\n\r\n/** drag&drop events callbacks */\r\nexport type DDCallback = (event: Event, arg2: GridItemHTMLElement, helper?: GridItemHTMLElement) => void;\r\n\r\n/**\r\n * Base class implementing common Grid drag'n'drop functionality, with domain specific subclass (h5 vs jq subclasses)\r\n */\r\nexport abstract class GridStackDD extends GridStackDDI {\r\n\r\n /** override to cast to correct type */\r\n static get(): GridStackDD {\r\n return GridStackDDI.get() as GridStackDD;\r\n }\r\n\r\n /** removes any drag&drop present (called during destroy) */\r\n public remove(el: GridItemHTMLElement): GridStackDD {\r\n this.draggable(el, 'destroy').resizable(el, 'destroy');\r\n if (el.gridstackNode) {\r\n delete el.gridstackNode._initDD; // reset our DD init flag\r\n }\r\n return this;\r\n }\r\n\r\n // APIs that must be implemented by subclasses to do actual darg/drop/resize called by GridStack code below\r\n\r\n public abstract resizable(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue): GridStackDD;\r\n\r\n public abstract isResizable(el: HTMLElement): boolean;\r\n\r\n public abstract draggable(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue): GridStackDD;\r\n\r\n public abstract dragIn(el: GridStackElement, opts: DDDragInOpt): GridStackDD;\r\n\r\n public abstract isDraggable(el: HTMLElement): boolean;\r\n\r\n public abstract droppable(el: GridItemHTMLElement, opts: DDOpts | DDDropOpt, key?: DDKey, value?: DDValue): GridStackDD;\r\n\r\n public abstract isDroppable(el: HTMLElement): boolean;\r\n\r\n public abstract on(el: GridItemHTMLElement, eventName: string, callback: DDCallback): GridStackDD;\r\n\r\n public abstract off(el: GridItemHTMLElement, eventName: string): GridStackDD;\r\n}\r\n\r\n/********************************************************************************\r\n * GridStack code that is doing drag&drop extracted here so main class is smaller\r\n * for static grid that don't do any of this work anyway. Saves about 10k.\r\n * TODO: no code hint in code below as this is so look at alternatives ?\r\n * https://www.typescriptlang.org/docs/handbook/declaration-merging.html\r\n * https://www.typescriptlang.org/docs/handbook/mixins.html\r\n ********************************************************************************/\r\n\r\n/** @internal called to add drag over to support widgets being added externally */\r\nGridStack.prototype._setupAcceptWidget = function(): GridStack {\r\n\r\n // check if we need to disable things\r\n if (this.opts.staticGrid || !this.opts.acceptWidgets) {\r\n GridStackDD.get().droppable(this.el, 'destroy');\r\n return this;\r\n }\r\n\r\n // vars shared across all methods\r\n let gridPos: MousePosition;\r\n let cellHeight: number, cellWidth: number;\r\n\r\n let onDrag = (event: DragEvent, el: GridItemHTMLElement, helper: GridItemHTMLElement) => {\r\n let node = el.gridstackNode;\r\n if (!node) return;\r\n\r\n helper = helper || el;\r\n let rec = helper.getBoundingClientRect();\r\n let left = rec.left - gridPos.left;\r\n let top = rec.top - gridPos.top;\r\n let ui: DDUIData = {position: {top, left}};\r\n\r\n if (node._temporaryRemoved) {\r\n node.x = Math.max(0, Math.round(left / cellWidth));\r\n node.y = Math.max(0, Math.round(top / cellHeight));\r\n delete node.autoPosition;\r\n this.engine.nodeBoundFix(node);\r\n\r\n // don't accept *initial* location if doesn't fit #1419 (locked drop region, or can't grow), but maybe try if it will go somewhere\r\n if (!this.engine.willItFit(node)) {\r\n node.autoPosition = true; // ignore x,y and try for any slot...\r\n if (!this.engine.willItFit(node)) {\r\n GridStackDD.get().off(el, 'drag'); // stop calling us\r\n return; // full grid or can't grow\r\n }\r\n if (node._willFitPos) {\r\n // use the auto position instead #1687\r\n Utils.copyPos(node, node._willFitPos);\r\n delete node._willFitPos;\r\n }\r\n }\r\n\r\n // re-use the existing node dragging method\r\n this._onStartMoving(helper, event, ui, node, cellWidth, cellHeight);\r\n } else {\r\n // re-use the existing node dragging that does so much of the collision detection\r\n this._dragOrResize(helper, event, ui, node, cellWidth, cellHeight);\r\n }\r\n }\r\n\r\n GridStackDD.get()\r\n .droppable(this.el, {\r\n accept: (el: GridItemHTMLElement) => {\r\n let node: GridStackNode = el.gridstackNode;\r\n // set accept drop to true on ourself (which we ignore) so we don't get \"can't drop\" icon in HTML5 mode while moving\r\n if (node && node.grid === this) return true;\r\n if (!this.opts.acceptWidgets) return false;\r\n // check for accept method or class matching\r\n let canAccept = true;\r\n if (typeof this.opts.acceptWidgets === 'function') {\r\n canAccept = this.opts.acceptWidgets(el);\r\n } else {\r\n let selector = (this.opts.acceptWidgets === true ? '.grid-stack-item' : this.opts.acceptWidgets as string);\r\n canAccept = el.matches(selector);\r\n }\r\n // finally check to make sure we actually have space left #1571\r\n if (canAccept && node && this.opts.maxRow) {\r\n let n = {w: node.w, h: node.h, minW: node.minW, minH: node.minH}; // only width/height matters and autoPosition\r\n canAccept = this.engine.willItFit(n);\r\n }\r\n return canAccept;\r\n }\r\n })\r\n /**\r\n * entering our grid area\r\n */\r\n .on(this.el, 'dropover', (event: Event, el: GridItemHTMLElement, helper: GridItemHTMLElement) => {\r\n let node = el.gridstackNode;\r\n // ignore drop enter on ourself (unless we temporarily removed) which happens on a simple drag of our item\r\n if (node && node.grid === this && !node._temporaryRemoved) {\r\n // delete node._added; // reset this to track placeholder again in case we were over other grid #1484 (dropout doesn't always clear)\r\n return false; // prevent parent from receiving msg (which may be a grid as well)\r\n }\r\n\r\n // fix #1578 when dragging fast, we may not get a leave on the previous grid so force one now\r\n if (node && node.grid && node.grid !== this && !node._temporaryRemoved) {\r\n // TEST console.log('dropover without leave');\r\n let otherGrid = node.grid;\r\n otherGrid._leave(el, helper);\r\n }\r\n\r\n // get grid screen coordinates and cell dimensions\r\n let box = this.el.getBoundingClientRect();\r\n gridPos = {top: box.top, left: box.left};\r\n cellWidth = this.cellWidth();\r\n cellHeight = this.getCellHeight(true);\r\n\r\n // load any element attributes if we don't have a node\r\n if (!node) {\r\n node = this._readAttr(el);\r\n }\r\n if (!node.grid) {\r\n node._isExternal = true;\r\n el.gridstackNode = node;\r\n }\r\n\r\n // calculate the grid size based on element outer size\r\n helper = helper || el;\r\n let w = node.w || Math.round(helper.offsetWidth / cellWidth) || 1;\r\n let h = node.h || Math.round(helper.offsetHeight / cellHeight) || 1;\r\n\r\n // if the item came from another grid, make a copy and save the original info in case we go back there\r\n if (node.grid && node.grid !== this) {\r\n // copy the node original values (min/max/id/etc...) but override width/height/other flags which are this grid specific\r\n // TEST console.log('dropover cloning node');\r\n if (!el._gridstackNodeOrig) el._gridstackNodeOrig = node; // shouldn't have multiple nested!\r\n el.gridstackNode = node = {...node, w, h, grid: this};\r\n this.engine.cleanupNode(node)\r\n .nodeBoundFix(node);\r\n // restore some internal fields we need after clearing them all\r\n node._initDD =\r\n node._isExternal = // DOM needs to be re-parented on a drop\r\n node._temporaryRemoved = true; // so it can be inserted onDrag below\r\n } else {\r\n node.w = w; node.h = h;\r\n node._temporaryRemoved = true; // so we can insert it\r\n }\r\n\r\n // clear any marked for complete removal (Note: don't check _isAboutToRemove as that is cleared above - just do it)\r\n _itemRemoving(node.el, false);\r\n\r\n GridStackDD.get().on(el, 'drag', onDrag);\r\n // make sure this is called at least once when going fast #1578\r\n onDrag(event as DragEvent, el, helper);\r\n return false; // prevent parent from receiving msg (which may be a grid as well)\r\n })\r\n /**\r\n * Leaving our grid area...\r\n */\r\n .on(this.el, 'dropout', (event, el: GridItemHTMLElement, helper: GridItemHTMLElement) => {\r\n let node = el.gridstackNode;\r\n // fix #1578 when dragging fast, we might get leave after other grid gets enter (which calls us to clean)\r\n // so skip this one if we're not the active grid really..\r\n if (!node.grid || node.grid === this) {\r\n this._leave(el, helper);\r\n }\r\n return false; // prevent parent from receiving msg (which may be grid as well)\r\n })\r\n /**\r\n * end - releasing the mouse\r\n */\r\n .on(this.el, 'drop', (event, el: GridItemHTMLElement, helper: GridItemHTMLElement) => {\r\n let node = el.gridstackNode;\r\n // ignore drop on ourself from ourself that didn't come from the outside - dragend will handle the simple move instead\r\n if (node && node.grid === this && !node._isExternal) return false;\r\n\r\n let wasAdded = !!this.placeholder.parentElement; // skip items not actually added to us because of constrains, but do cleanup #1419\r\n this.placeholder.remove();\r\n\r\n // notify previous grid of removal\r\n // TEST console.log('drop delete _gridstackNodeOrig')\r\n let origNode = el._gridstackNodeOrig;\r\n delete el._gridstackNodeOrig;\r\n if (wasAdded && origNode && origNode.grid && origNode.grid !== this) {\r\n let oGrid = origNode.grid;\r\n oGrid.engine.removedNodes.push(origNode);\r\n oGrid._triggerRemoveEvent();\r\n }\r\n\r\n if (!node) return false;\r\n\r\n // use existing placeholder node as it's already in our list with drop location\r\n if (wasAdded) {\r\n this.engine.cleanupNode(node); // removes all internal _xyz values\r\n node.grid = this;\r\n }\r\n GridStackDD.get().off(el, 'drag');\r\n // if we made a copy ('helper' which is temp) of the original node then insert a copy, else we move the original node (#1102)\r\n // as the helper will be nuked by jquery-ui otherwise\r\n if (helper !== el) {\r\n helper.remove();\r\n el.gridstackNode = origNode; // original item (left behind) is re-stored to pre dragging as the node now has drop info\r\n if (wasAdded) {\r\n el = el.cloneNode(true) as GridItemHTMLElement;\r\n }\r\n } else {\r\n el.remove(); // reduce flicker as we change depth here, and size further down\r\n GridStackDD.get().remove(el);\r\n }\r\n if (!wasAdded) return false;\r\n el.gridstackNode = node;\r\n node.el = el;\r\n\r\n Utils.copyPos(node, this._readAttr(this.placeholder)); // placeholder values as moving VERY fast can throw things off #1578\r\n Utils.removePositioningStyles(el);\r\n this._writeAttr(el, node);\r\n this.el.appendChild(el);\r\n this._updateContainerHeight();\r\n this.engine.addedNodes.push(node);\r\n this._triggerAddEvent();\r\n this._triggerChangeEvent();\r\n\r\n this.engine.endUpdate();\r\n if (this._gsEventHandler['dropped']) {\r\n this._gsEventHandler['dropped']({type: 'dropped'}, origNode && origNode.grid ? origNode : undefined, node);\r\n }\r\n\r\n // wait till we return out of the drag callback to set the new drag&resize handler or they may get messed up\r\n window.setTimeout(() => {\r\n // IFF we are still there (some application will use as placeholder and insert their real widget instead and better call makeWidget())\r\n if (node.el && node.el.parentElement) {\r\n this._prepareDragDropByNode(node);\r\n } else {\r\n this.engine.removeNode(node);\r\n }\r\n });\r\n\r\n return false; // prevent parent from receiving msg (which may be grid as well)\r\n });\r\n return this;\r\n}\r\n\r\n/** @internal mark item for removal */\r\nfunction _itemRemoving(el: GridItemHTMLElement, remove: boolean) {\r\n let node = el ? el.gridstackNode : undefined;\r\n if (!node || !node.grid) return;\r\n remove ? node._isAboutToRemove = true : delete node._isAboutToRemove;\r\n remove ? el.classList.add('grid-stack-item-removing') : el.classList.remove('grid-stack-item-removing');\r\n}\r\n\r\n/** @internal called to setup a trash drop zone if the user specifies it */\r\nGridStack.prototype._setupRemoveDrop = function(): GridStack {\r\n if (!this.opts.staticGrid && typeof this.opts.removable === 'string') {\r\n let trashEl = document.querySelector(this.opts.removable) as HTMLElement;\r\n if (!trashEl) return this;\r\n // only register ONE drop-over/dropout callback for the 'trash', and it will\r\n // update the passed in item and parent grid because the 'trash' is a shared resource anyway,\r\n // and Native DD only has 1 event CB (having a list and technically a per grid removableOptions complicates things greatly)\r\n if (!GridStackDD.get().isDroppable(trashEl)) {\r\n GridStackDD.get().droppable(trashEl, this.opts.removableOptions)\r\n .on(trashEl, 'dropover', (event, el) => _itemRemoving(el, true))\r\n .on(trashEl, 'dropout', (event, el) => _itemRemoving(el, false));\r\n }\r\n }\r\n return this;\r\n}\r\n\r\n/**\r\n * call to setup dragging in from the outside (say toolbar), by specifying the class selection and options.\r\n * Called during GridStack.init() as options, but can also be called directly (last param are cached) in case the toolbar\r\n * is dynamically create and needs to change later.\r\n **/\r\nGridStack.setupDragIn = function(_dragIn?: string, _dragInOptions?: DDDragInOpt) {\r\n let dragIn: string;\r\n let dragInOptions: DDDragInOpt;\r\n const dragInDefaultOptions: DDDragInOpt = {\r\n revert: 'invalid',\r\n handle: '.grid-stack-item-content',\r\n scroll: false,\r\n appendTo: 'body'\r\n };\r\n\r\n // cache in the passed in values (form grid init?) so they don't have to resend them each time\r\n if (_dragIn) {\r\n dragIn = _dragIn;\r\n dragInOptions = {...dragInDefaultOptions, ...(_dragInOptions || {})};\r\n }\r\n if (typeof dragIn !== 'string') return;\r\n let dd = GridStackDD.get();\r\n Utils.getElements(dragIn).forEach(el => {\r\n if (!dd.isDraggable(el)) dd.dragIn(el, dragInOptions);\r\n });\r\n}\r\n\r\n/** @internal prepares the element for drag&drop **/\r\nGridStack.prototype._prepareDragDropByNode = function(node: GridStackNode): GridStack {\r\n let el = node.el;\r\n let dd = GridStackDD.get();\r\n\r\n // check for disabled grid first\r\n if (this.opts.staticGrid || ((node.noMove || this.opts.disableDrag) && (node.noResize || this.opts.disableResize))) {\r\n if (node._initDD) {\r\n dd.remove(el); // nukes everything instead of just disable, will add some styles back next\r\n delete node._initDD;\r\n }\r\n el.classList.add('ui-draggable-disabled', 'ui-resizable-disabled'); // add styles one might depend on #1435\r\n return this;\r\n }\r\n\r\n if (!node._initDD) {\r\n // variables used/cashed between the 3 start/move/end methods, in addition to node passed above\r\n let cellWidth: number;\r\n let cellHeight: number;\r\n\r\n /** called when item starts moving/resizing */\r\n let onStartMoving = (event: Event, ui: DDUIData) => {\r\n // trigger any 'dragstart' / 'resizestart' manually\r\n if (this._gsEventHandler[event.type]) {\r\n this._gsEventHandler[event.type](event, event.target);\r\n }\r\n cellWidth = this.cellWidth();\r\n cellHeight = this.getCellHeight(true); // force pixels for calculations\r\n\r\n this._onStartMoving(el, event, ui, node, cellWidth, cellHeight);\r\n }\r\n\r\n /** called when item is being dragged/resized */\r\n let dragOrResize = (event: Event, ui: DDUIData) => {\r\n this._dragOrResize(el, event, ui, node, cellWidth, cellHeight);\r\n }\r\n\r\n /** called when the item stops moving/resizing */\r\n let onEndMoving = (event: Event) => {\r\n this.placeholder.remove();\r\n delete node._moving;\r\n delete node._lastTried;\r\n\r\n // if the item has moved to another grid, we're done here\r\n let target: GridItemHTMLElement = event.target as GridItemHTMLElement;\r\n if (!target.gridstackNode || target.gridstackNode.grid !== this) return;\r\n\r\n node.el = target;\r\n\r\n if (node._isAboutToRemove) {\r\n let gridToNotify = el.gridstackNode.grid;\r\n if (gridToNotify._gsEventHandler[event.type]) {\r\n gridToNotify._gsEventHandler[event.type](event, target);\r\n }\r\n dd.remove(el);\r\n gridToNotify.engine.removedNodes.push(node);\r\n gridToNotify._triggerRemoveEvent();\r\n // break circular links and remove DOM\r\n delete el.gridstackNode;\r\n delete node.el;\r\n el.remove();\r\n } else {\r\n if (!node._temporaryRemoved) {\r\n // move to new placeholder location\r\n Utils.removePositioningStyles(target);\r\n this._writePosAttr(target, node);\r\n } else {\r\n // got removed - restore item back to before dragging position\r\n Utils.removePositioningStyles(target);\r\n Utils.copyPos(node, node._orig);\r\n this._writePosAttr(target, node);\r\n this.engine.addNode(node);\r\n }\r\n if (this._gsEventHandler[event.type]) {\r\n this._gsEventHandler[event.type](event, target);\r\n }\r\n }\r\n\r\n this._extraDragRow = 0;\r\n this._updateContainerHeight();\r\n this._triggerChangeEvent();\r\n\r\n this.engine.endUpdate();\r\n }\r\n\r\n dd.draggable(el, {\r\n start: onStartMoving,\r\n stop: onEndMoving,\r\n drag: dragOrResize\r\n }).resizable(el, {\r\n start: onStartMoving,\r\n stop: onEndMoving,\r\n resize: dragOrResize\r\n });\r\n node._initDD = true; // we've set DD support now\r\n }\r\n\r\n // finally fine tune move vs resize by disabling any part...\r\n if (node.noMove || this.opts.disableDrag) {\r\n dd.draggable(el, 'disable');\r\n el.classList.add('ui-draggable-disabled');\r\n } else {\r\n dd.draggable(el, 'enable');\r\n el.classList.remove('ui-draggable-disabled');\r\n }\r\n if (node.noResize || this.opts.disableResize) {\r\n dd.resizable(el, 'disable');\r\n el.classList.add('ui-resizable-disabled');\r\n } else {\r\n dd.resizable(el, 'enable');\r\n el.classList.remove('ui-resizable-disabled');\r\n }\r\n\r\n return this;\r\n}\r\n\r\n/** @internal called when item is starting a drag/resize */\r\nGridStack.prototype._onStartMoving = function(el: GridItemHTMLElement, event: Event, ui: DDUIData, node: GridStackNode, cellWidth: number, cellHeight: number) {\r\n this.engine.cleanNodes()\r\n .beginUpdate(node);\r\n\r\n this._writePosAttr(this.placeholder, node)\r\n this.el.appendChild(this.placeholder);\r\n // TEST console.log('_onStartMoving placeholder')\r\n\r\n node.el = this.placeholder;\r\n node._lastUiPosition = ui.position;\r\n node._prevYPix = ui.position.top;\r\n node._moving = (event.type === 'dragstart'); // 'dropover' are not initially moving so they can go exactly where they enter (will push stuff out of the way)\r\n delete node._lastTried;\r\n\r\n if (event.type === 'dropover' && node._temporaryRemoved) {\r\n // TEST console.log('engine.addNode x=' + node.x);\r\n this.engine.addNode(node); // will add, fix collisions, update attr and clear _temporaryRemoved\r\n node._moving = true; // AFTER, mark as moving object (wanted fix location before)\r\n }\r\n\r\n // set the min/max resize info\r\n this.engine.cacheRects(cellWidth, cellHeight, this.opts.marginTop, this.opts.marginRight, this.opts.marginBottom, this.opts.marginLeft);\r\n if (event.type === 'resizestart') {\r\n let dd = GridStackDD.get()\r\n .resizable(el, 'option', 'minWidth', cellWidth * (node.minW || 1))\r\n .resizable(el, 'option', 'minHeight', cellHeight * (node.minH || 1));\r\n if (node.maxW) { dd.resizable(el, 'option', 'maxWidth', cellWidth * node.maxW); }\r\n if (node.maxH) { dd.resizable(el, 'option', 'maxHeight', cellHeight * node.maxH); }\r\n }\r\n}\r\n\r\n/** @internal called when item leaving our area by either cursor dropout event\r\n * or shape is outside our boundaries. remove it from us, and mark temporary if this was\r\n * our item to start with else restore prev node values from prev grid it came from.\r\n **/\r\nGridStack.prototype._leave = function(el: GridItemHTMLElement, helper?: GridItemHTMLElement) {\r\n let node = el.gridstackNode;\r\n if (!node) return;\r\n\r\n GridStackDD.get().off(el, 'drag'); // no need to track while being outside\r\n\r\n // this gets called when cursor leaves and shape is outside, so only do this once\r\n if (node._temporaryRemoved) return;\r\n node._temporaryRemoved = true;\r\n\r\n this.engine.removeNode(node); // remove placeholder as well, otherwise it's a sign node is not in our list, which is a bigger issue\r\n node.el = node._isExternal && helper ? helper : el; // point back to real item being dragged\r\n\r\n if (this.opts.removable === true) { // boolean vs a class string\r\n // item leaving us and we are supposed to remove on leave (no need to drag onto trash) mark it so\r\n _itemRemoving(el, true);\r\n }\r\n\r\n // finally if item originally came from another grid, but left us, restore things back to prev info\r\n if (el._gridstackNodeOrig) {\r\n // TEST console.log('leave delete _gridstackNodeOrig')\r\n el.gridstackNode = el._gridstackNodeOrig;\r\n delete el._gridstackNodeOrig;\r\n } else if (node._isExternal) {\r\n // item came from outside (like a toolbar) so nuke any node info\r\n delete node.el;\r\n delete el.gridstackNode;\r\n // and restore all nodes back to original\r\n this.engine.restoreInitial();\r\n }\r\n}\r\n\r\n/** @internal called when item is being dragged/resized */\r\nGridStack.prototype._dragOrResize = function(el: GridItemHTMLElement, event: Event, ui: DDUIData, node: GridStackNode, cellWidth: number, cellHeight: number) {\r\n let p = {...node._orig}; // could be undefined (_isExternal) which is ok (drag only set x,y and w,h will default to node value)\r\n let resizing: boolean;\r\n\r\n if (event.type === 'drag') {\r\n if (node._temporaryRemoved) return; // handled by dropover\r\n let distance = ui.position.top - node._prevYPix;\r\n node._prevYPix = ui.position.top;\r\n Utils.updateScrollPosition(el, ui.position, distance);\r\n\r\n // get new position taking into account the margin in the direction we are moving! (need to pass mid point by margin)\r\n let left = ui.position.left + (ui.position.left > node._lastUiPosition.left ? -this.opts.marginRight : this.opts.marginLeft);\r\n let top = ui.position.top + (ui.position.top > node._lastUiPosition.top ? -this.opts.marginBottom : this.opts.marginTop);\r\n p.x = Math.round(left / cellWidth);\r\n p.y = Math.round(top / cellHeight);\r\n\r\n // if we're at the bottom hitting something else, grow the grid so cursor doesn't leave when trying to place below others\r\n let prev = this._extraDragRow;\r\n if (this.engine.collide(node, p)) {\r\n let row = this.getRow();\r\n let extra = Math.max(0, (p.y + node.h) - row);\r\n if (this.opts.maxRow && row + extra > this.opts.maxRow) {\r\n extra = Math.max(0, this.opts.maxRow - row);\r\n }\r\n this._extraDragRow = extra;\r\n } else this._extraDragRow = 0;\r\n if (this._extraDragRow !== prev) this._updateContainerHeight();\r\n\r\n if (node.x === p.x && node.y === p.y) return; // skip same\r\n // DON'T skip one we tried as we might have failed because of coverage <50% before\r\n // if (node._lastTried && node._lastTried.x === x && node._lastTried.y === y) return;\r\n } else if (event.type === 'resize') {\r\n if (p.x < 0) return;\r\n // Scrolling page if needed\r\n Utils.updateScrollResize(event as MouseEvent, el, cellHeight);\r\n\r\n // get new size\r\n p.w = Math.round((ui.size.width - this.opts.marginLeft) / cellWidth);\r\n p.h = Math.round((ui.size.height - this.opts.marginTop) / cellHeight);\r\n if (node.w === p.w && node.h === p.h) return;\r\n if (node._lastTried && node._lastTried.w === p.w && node._lastTried.h === p.h) return; // skip one we tried (but failed)\r\n\r\n // if we size on left/top side this might move us, so get possible new position as well\r\n let left = ui.position.left + this.opts.marginLeft;\r\n let top = ui.position.top + this.opts.marginTop;\r\n p.x = Math.round(left / cellWidth);\r\n p.y = Math.round(top / cellHeight);\r\n\r\n resizing = true;\r\n }\r\n\r\n node._lastTried = p; // set as last tried (will nuke if we go there)\r\n let rect: GridStackPosition = { // screen pix of the dragged box\r\n x: ui.position.left + this.opts.marginLeft,\r\n y: ui.position.top + this.opts.marginTop,\r\n w: (ui.size ? ui.size.width : node.w * cellWidth) - this.opts.marginLeft - this.opts.marginRight,\r\n h: (ui.size ? ui.size.height : node.h * cellHeight) - this.opts.marginTop - this.opts.marginBottom\r\n };\r\n if (this.engine.moveNodeCheck(node, {...p, cellWidth, cellHeight, rect})) {\r\n node._lastUiPosition = ui.position;\r\n this.engine.cacheRects(cellWidth, cellHeight, this.opts.marginTop, this.opts.marginRight, this.opts.marginBottom, this.opts.marginLeft);\r\n delete node._skipDown;\r\n if (resizing && node.subGrid) { (node.subGrid as GridStack).onParentResize(); }\r\n this._extraDragRow = 0;\r\n this._updateContainerHeight();\r\n\r\n let target = event.target as GridItemHTMLElement;\r\n this._writePosAttr(target, node);\r\n if (this._gsEventHandler[event.type]) {\r\n this._gsEventHandler[event.type](event, target);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Enables/Disables moving.\r\n * @param els widget or selector to modify.\r\n * @param val if true widget will be draggable.\r\n */\r\nGridStack.prototype.movable = function(els: GridStackElement, val: boolean): GridStack {\r\n if (this.opts.staticGrid) return this; // can't move a static grid!\r\n GridStack.getElements(els).forEach(el => {\r\n let node = el.gridstackNode;\r\n if (!node) return;\r\n if (val) delete node.noMove; else node.noMove = true;\r\n this._prepareDragDropByNode(node); // init DD if need be, and adjust\r\n });\r\n return this;\r\n}\r\n\r\n/**\r\n * Enables/Disables resizing.\r\n * @param els widget or selector to modify\r\n * @param val if true widget will be resizable.\r\n */\r\nGridStack.prototype.resizable = function(els: GridStackElement, val: boolean): GridStack {\r\n if (this.opts.staticGrid) return this; // can't resize a static grid!\r\n GridStack.getElements(els).forEach(el => {\r\n let node = el.gridstackNode;\r\n if (!node) return;\r\n if (val) delete node.noResize; else node.noResize = true;\r\n this._prepareDragDropByNode(node); // init DD if need be, and adjust\r\n });\r\n return this;\r\n}\r\n\r\n\r\n/**\r\n * Temporarily disables widgets moving/resizing.\r\n * If you want a more permanent way (which freezes up resources) use `setStatic(true)` instead.\r\n * Note: no-op for static grid\r\n * This is a shortcut for:\r\n * @example\r\n * grid.enableMove(false);\r\n * grid.enableResize(false);\r\n */\r\nGridStack.prototype.disable = function(): GridStack {\r\n if (this.opts.staticGrid) return;\r\n this.enableMove(false);\r\n this.enableResize(false);\r\n this._triggerEvent('disable');\r\n return this;\r\n}\r\n\r\n/**\r\n * Re-enables widgets moving/resizing - see disable().\r\n * Note: no-op for static grid.\r\n * This is a shortcut for:\r\n * @example\r\n * grid.enableMove(true);\r\n * grid.enableResize(true);\r\n */\r\nGridStack.prototype.enable = function(): GridStack {\r\n if (this.opts.staticGrid) return;\r\n this.enableMove(true);\r\n this.enableResize(true);\r\n this._triggerEvent('enable');\r\n return this;\r\n}\r\n\r\n/** Enables/disables widget moving. No-op for static grids. */\r\nGridStack.prototype.enableMove = function(doEnable: boolean): GridStack {\r\n if (this.opts.staticGrid) return this; // can't move a static grid!\r\n this.opts.disableDrag = !doEnable; // FIRST before we update children as grid overrides #1658\r\n this.engine.nodes.forEach(n => this.movable(n.el, doEnable));\r\n return this;\r\n}\r\n\r\n/** Enables/disables widget resizing. No-op for static grids. */\r\nGridStack.prototype.enableResize = function(doEnable: boolean): GridStack {\r\n if (this.opts.staticGrid) return this; // can't size a static grid!\r\n this.opts.disableResize = !doEnable; // FIRST before we update children as grid overrides #1658\r\n this.engine.nodes.forEach(n => this.resizable(n.el, doEnable));\r\n return this;\r\n}\r\n"]} \ No newline at end of file +{"version":3,"file":"gridstack-dd.js","sourceRoot":"","sources":["../src/gridstack-dd.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,sDAAsD;AACtD,mDAA+C;AAE/C,2CAAuD;AACvD,mCAAgC;AAiBhC;;GAEG;AACH,MAAsB,WAAY,SAAQ,4BAAY;IAEpD,uCAAuC;IACvC,MAAM,CAAC,GAAG;QACR,OAAO,4BAAY,CAAC,GAAG,EAAiB,CAAC;IAC3C,CAAC;IAED,4DAA4D;IACrD,MAAM,CAAC,EAAuB;QACnC,IAAI,CAAC,SAA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C,QAAQ,CAAC,CAAC,0DAA0D;IAC/F,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC/D,OAAO,IAAI,CAAC;AACd,CAAC,CAAA","sourcesContent":["/**\r\n * gridstack-dd.ts 4.2.6\r\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\r\n */\r\n\r\n/* eslint-disable @typescript-eslint/no-unused-vars */\r\nimport { GridStackDDI } from './gridstack-ddi';\r\nimport { GridItemHTMLElement, GridStackNode, GridStackElement, DDUIData, DDDragInOpt, GridStackPosition } from './types';\r\nimport { GridStack, MousePosition } from './gridstack';\r\nimport { Utils } from './utils';\r\n\r\n/** Drag&Drop drop options */\r\nexport type DDDropOpt = {\r\n /** function or class type that this grid will accept as dropped items (see GridStackOptions.acceptWidgets) */\r\n accept?: (el: GridItemHTMLElement) => boolean;\r\n}\r\n\r\n/** drag&drop options currently called from the main code, but others can be passed in grid options */\r\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\r\nexport type DDOpts = 'enable' | 'disable' | 'destroy' | 'option' | string | any;\r\nexport type DDKey = 'minWidth' | 'minHeight' | 'maxWidth' | 'maxHeight';\r\nexport type DDValue = number | string;\r\n\r\n/** drag&drop events callbacks */\r\nexport type DDCallback = (event: Event, arg2: GridItemHTMLElement, helper?: GridItemHTMLElement) => void;\r\n\r\n/**\r\n * Base class implementing common Grid drag'n'drop functionality, with domain specific subclass (h5 vs jq subclasses)\r\n */\r\nexport abstract class GridStackDD extends GridStackDDI {\r\n\r\n /** override to cast to correct type */\r\n static get(): GridStackDD {\r\n return GridStackDDI.get() as GridStackDD;\r\n }\r\n\r\n /** removes any drag&drop present (called during destroy) */\r\n public remove(el: GridItemHTMLElement): GridStackDD {\r\n this.draggable(el, 'destroy').resizable(el, 'destroy');\r\n if (el.gridstackNode) {\r\n delete el.gridstackNode._initDD; // reset our DD init flag\r\n }\r\n return this;\r\n }\r\n\r\n // APIs that must be implemented by subclasses to do actual darg/drop/resize called by GridStack code below\r\n\r\n public abstract resizable(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue): GridStackDD;\r\n\r\n public abstract isResizable(el: HTMLElement): boolean;\r\n\r\n public abstract draggable(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue): GridStackDD;\r\n\r\n public abstract dragIn(el: GridStackElement, opts: DDDragInOpt): GridStackDD;\r\n\r\n public abstract isDraggable(el: HTMLElement): boolean;\r\n\r\n public abstract droppable(el: GridItemHTMLElement, opts: DDOpts | DDDropOpt, key?: DDKey, value?: DDValue): GridStackDD;\r\n\r\n public abstract isDroppable(el: HTMLElement): boolean;\r\n\r\n public abstract on(el: GridItemHTMLElement, eventName: string, callback: DDCallback): GridStackDD;\r\n\r\n public abstract off(el: GridItemHTMLElement, eventName: string): GridStackDD;\r\n}\r\n\r\n/********************************************************************************\r\n * GridStack code that is doing drag&drop extracted here so main class is smaller\r\n * for static grid that don't do any of this work anyway. Saves about 10k.\r\n * TODO: no code hint in code below as this is so look at alternatives ?\r\n * https://www.typescriptlang.org/docs/handbook/declaration-merging.html\r\n * https://www.typescriptlang.org/docs/handbook/mixins.html\r\n ********************************************************************************/\r\n\r\n/** @internal called to add drag over to support widgets being added externally */\r\nGridStack.prototype._setupAcceptWidget = function(this: GridStack): GridStack {\r\n\r\n // check if we need to disable things\r\n if (this.opts.staticGrid || (!this.opts.acceptWidgets && !this.opts.removable)) {\r\n GridStackDD.get().droppable(this.el, 'destroy');\r\n return this;\r\n }\r\n\r\n // vars shared across all methods\r\n let gridPos: MousePosition;\r\n let cellHeight: number, cellWidth: number;\r\n\r\n let onDrag = (event: DragEvent, el: GridItemHTMLElement, helper: GridItemHTMLElement) => {\r\n let node = el.gridstackNode;\r\n if (!node) return;\r\n\r\n helper = helper || el;\r\n let rec = helper.getBoundingClientRect();\r\n let left = rec.left - gridPos.left;\r\n let top = rec.top - gridPos.top;\r\n let ui: DDUIData = {position: {top, left}};\r\n\r\n if (node._temporaryRemoved) {\r\n node.x = Math.max(0, Math.round(left / cellWidth));\r\n node.y = Math.max(0, Math.round(top / cellHeight));\r\n delete node.autoPosition;\r\n this.engine.nodeBoundFix(node);\r\n\r\n // don't accept *initial* location if doesn't fit #1419 (locked drop region, or can't grow), but maybe try if it will go somewhere\r\n if (!this.engine.willItFit(node)) {\r\n node.autoPosition = true; // ignore x,y and try for any slot...\r\n if (!this.engine.willItFit(node)) {\r\n GridStackDD.get().off(el, 'drag'); // stop calling us\r\n return; // full grid or can't grow\r\n }\r\n if (node._willFitPos) {\r\n // use the auto position instead #1687\r\n Utils.copyPos(node, node._willFitPos);\r\n delete node._willFitPos;\r\n }\r\n }\r\n\r\n // re-use the existing node dragging method\r\n this._onStartMoving(helper, event, ui, node, cellWidth, cellHeight);\r\n } else {\r\n // re-use the existing node dragging that does so much of the collision detection\r\n this._dragOrResize(helper, event, ui, node, cellWidth, cellHeight);\r\n }\r\n }\r\n\r\n GridStackDD.get()\r\n .droppable(this.el, {\r\n accept: (el: GridItemHTMLElement) => {\r\n let node: GridStackNode = el.gridstackNode;\r\n // set accept drop to true on ourself (which we ignore) so we don't get \"can't drop\" icon in HTML5 mode while moving\r\n if (node && node.grid === this) return true;\r\n if (!this.opts.acceptWidgets) return false;\r\n // check for accept method or class matching\r\n let canAccept = true;\r\n if (typeof this.opts.acceptWidgets === 'function') {\r\n canAccept = this.opts.acceptWidgets(el);\r\n } else {\r\n let selector = (this.opts.acceptWidgets === true ? '.grid-stack-item' : this.opts.acceptWidgets as string);\r\n canAccept = el.matches(selector);\r\n }\r\n // finally check to make sure we actually have space left #1571\r\n if (canAccept && node && this.opts.maxRow) {\r\n let n = {w: node.w, h: node.h, minW: node.minW, minH: node.minH}; // only width/height matters and autoPosition\r\n canAccept = this.engine.willItFit(n);\r\n }\r\n return canAccept;\r\n }\r\n })\r\n /**\r\n * entering our grid area\r\n */\r\n .on(this.el, 'dropover', (event: Event, el: GridItemHTMLElement, helper: GridItemHTMLElement) => {\r\n let node = el.gridstackNode;\r\n // ignore drop enter on ourself (unless we temporarily removed) which happens on a simple drag of our item\r\n if (node && node.grid === this && !node._temporaryRemoved) {\r\n // delete node._added; // reset this to track placeholder again in case we were over other grid #1484 (dropout doesn't always clear)\r\n return false; // prevent parent from receiving msg (which may be a grid as well)\r\n }\r\n\r\n // fix #1578 when dragging fast, we may not get a leave on the previous grid so force one now\r\n if (node && node.grid && node.grid !== this && !node._temporaryRemoved) {\r\n // TEST console.log('dropover without leave');\r\n let otherGrid = node.grid;\r\n otherGrid._leave(el, helper);\r\n }\r\n\r\n // get grid screen coordinates and cell dimensions\r\n let box = this.el.getBoundingClientRect();\r\n gridPos = {top: box.top, left: box.left};\r\n cellWidth = this.cellWidth();\r\n cellHeight = this.getCellHeight(true);\r\n\r\n // load any element attributes if we don't have a node\r\n if (!node) {// @ts-ignore\r\n node = this._readAttr(el);\r\n }\r\n if (!node.grid) {\r\n node._isExternal = true;\r\n el.gridstackNode = node;\r\n }\r\n\r\n // calculate the grid size based on element outer size\r\n helper = helper || el;\r\n let w = node.w || Math.round(helper.offsetWidth / cellWidth) || 1;\r\n let h = node.h || Math.round(helper.offsetHeight / cellHeight) || 1;\r\n\r\n // if the item came from another grid, make a copy and save the original info in case we go back there\r\n if (node.grid && node.grid !== this) {\r\n // copy the node original values (min/max/id/etc...) but override width/height/other flags which are this grid specific\r\n // TEST console.log('dropover cloning node');\r\n if (!el._gridstackNodeOrig) el._gridstackNodeOrig = node; // shouldn't have multiple nested!\r\n el.gridstackNode = node = {...node, w, h, grid: this};\r\n this.engine.cleanupNode(node)\r\n .nodeBoundFix(node);\r\n // restore some internal fields we need after clearing them all\r\n node._initDD =\r\n node._isExternal = // DOM needs to be re-parented on a drop\r\n node._temporaryRemoved = true; // so it can be inserted onDrag below\r\n } else {\r\n node.w = w; node.h = h;\r\n node._temporaryRemoved = true; // so we can insert it\r\n }\r\n\r\n // clear any marked for complete removal (Note: don't check _isAboutToRemove as that is cleared above - just do it)\r\n _itemRemoving(node.el, false);\r\n\r\n GridStackDD.get().on(el, 'drag', onDrag);\r\n // make sure this is called at least once when going fast #1578\r\n onDrag(event as DragEvent, el, helper);\r\n return false; // prevent parent from receiving msg (which may be a grid as well)\r\n })\r\n /**\r\n * Leaving our grid area...\r\n */\r\n .on(this.el, 'dropout', (event, el: GridItemHTMLElement, helper: GridItemHTMLElement) => {\r\n let node = el.gridstackNode;\r\n // fix #1578 when dragging fast, we might get leave after other grid gets enter (which calls us to clean)\r\n // so skip this one if we're not the active grid really..\r\n if (!node.grid || node.grid === this) {\r\n this._leave(el, helper);\r\n }\r\n return false; // prevent parent from receiving msg (which may be grid as well)\r\n })\r\n /**\r\n * end - releasing the mouse\r\n */\r\n .on(this.el, 'drop', (event, el: GridItemHTMLElement, helper: GridItemHTMLElement) => {\r\n let node = el.gridstackNode;\r\n // ignore drop on ourself from ourself that didn't come from the outside - dragend will handle the simple move instead\r\n if (node && node.grid === this && !node._isExternal) return false;\r\n\r\n let wasAdded = !!this.placeholder.parentElement; // skip items not actually added to us because of constrains, but do cleanup #1419\r\n this.placeholder.remove();\r\n\r\n // notify previous grid of removal\r\n // TEST console.log('drop delete _gridstackNodeOrig')\r\n let origNode = el._gridstackNodeOrig;\r\n delete el._gridstackNodeOrig;\r\n if (wasAdded && origNode && origNode.grid && origNode.grid !== this) {\r\n let oGrid = origNode.grid;\r\n oGrid.engine.removedNodes.push(origNode);\r\n oGrid._triggerRemoveEvent();\r\n }\r\n\r\n if (!node) return false;\r\n\r\n // use existing placeholder node as it's already in our list with drop location\r\n if (wasAdded) {\r\n this.engine.cleanupNode(node); // removes all internal _xyz values\r\n node.grid = this;\r\n }\r\n GridStackDD.get().off(el, 'drag');\r\n // if we made a copy ('helper' which is temp) of the original node then insert a copy, else we move the original node (#1102)\r\n // as the helper will be nuked by jquery-ui otherwise\r\n if (helper !== el) {\r\n helper.remove();\r\n el.gridstackNode = origNode; // original item (left behind) is re-stored to pre dragging as the node now has drop info\r\n if (wasAdded) {\r\n el = el.cloneNode(true) as GridItemHTMLElement;\r\n }\r\n } else {\r\n el.remove(); // reduce flicker as we change depth here, and size further down\r\n GridStackDD.get().remove(el);\r\n }\r\n if (!wasAdded) return false;\r\n el.gridstackNode = node;\r\n node.el = el;\r\n // @ts-ignore\r\n Utils.copyPos(node, this._readAttr(this.placeholder)); // placeholder values as moving VERY fast can throw things off #1578\r\n Utils.removePositioningStyles(el);// @ts-ignore\r\n this._writeAttr(el, node);\r\n this.el.appendChild(el);// @ts-ignore\r\n this._updateContainerHeight();\r\n this.engine.addedNodes.push(node);// @ts-ignore\r\n this._triggerAddEvent();// @ts-ignore\r\n this._triggerChangeEvent();\r\n\r\n this.engine.endUpdate();\r\n if (this._gsEventHandler['dropped']) {\r\n this._gsEventHandler['dropped']({type: 'dropped'}, origNode && origNode.grid ? origNode : undefined, node);\r\n }\r\n\r\n // wait till we return out of the drag callback to set the new drag&resize handler or they may get messed up\r\n window.setTimeout(() => {\r\n // IFF we are still there (some application will use as placeholder and insert their real widget instead and better call makeWidget())\r\n if (node.el && node.el.parentElement) {\r\n this._prepareDragDropByNode(node);\r\n } else {\r\n this.engine.removeNode(node);\r\n }\r\n });\r\n\r\n return false; // prevent parent from receiving msg (which may be grid as well)\r\n });\r\n return this;\r\n}\r\n\r\n/** @internal mark item for removal */\r\nfunction _itemRemoving(el: GridItemHTMLElement, remove: boolean) {\r\n let node = el ? el.gridstackNode : undefined;\r\n if (!node || !node.grid) return;\r\n remove ? node._isAboutToRemove = true : delete node._isAboutToRemove;\r\n remove ? el.classList.add('grid-stack-item-removing') : el.classList.remove('grid-stack-item-removing');\r\n}\r\n\r\n/** @internal called to setup a trash drop zone if the user specifies it */\r\nGridStack.prototype._setupRemoveDrop = function(this: GridStack): GridStack {\r\n if (!this.opts.staticGrid && typeof this.opts.removable === 'string') {\r\n let trashEl = document.querySelector(this.opts.removable) as HTMLElement;\r\n if (!trashEl) return this;\r\n // only register ONE drop-over/dropout callback for the 'trash', and it will\r\n // update the passed in item and parent grid because the 'trash' is a shared resource anyway,\r\n // and Native DD only has 1 event CB (having a list and technically a per grid removableOptions complicates things greatly)\r\n if (!GridStackDD.get().isDroppable(trashEl)) {\r\n GridStackDD.get().droppable(trashEl, this.opts.removableOptions)\r\n .on(trashEl, 'dropover', (event, el) => _itemRemoving(el, true))\r\n .on(trashEl, 'dropout', (event, el) => _itemRemoving(el, false));\r\n }\r\n }\r\n return this;\r\n}\r\n\r\n/**\r\n * call to setup dragging in from the outside (say toolbar), by specifying the class selection and options.\r\n * Called during GridStack.init() as options, but can also be called directly (last param are cached) in case the toolbar\r\n * is dynamically create and needs to change later.\r\n **/\r\nGridStack.setupDragIn = function(this: GridStack, _dragIn?: string, _dragInOptions?: DDDragInOpt) {\r\n let dragIn: string;\r\n let dragInOptions: DDDragInOpt;\r\n const dragInDefaultOptions: DDDragInOpt = {\r\n revert: 'invalid',\r\n handle: '.grid-stack-item-content',\r\n scroll: false,\r\n appendTo: 'body'\r\n };\r\n\r\n // cache in the passed in values (form grid init?) so they don't have to resend them each time\r\n if (_dragIn) {\r\n dragIn = _dragIn;\r\n dragInOptions = {...dragInDefaultOptions, ...(_dragInOptions || {})};\r\n }\r\n if (typeof dragIn !== 'string') return;\r\n let dd = GridStackDD.get();\r\n Utils.getElements(dragIn).forEach(el => {\r\n if (!dd.isDraggable(el)) dd.dragIn(el, dragInOptions);\r\n });\r\n}\r\n\r\n/** @internal prepares the element for drag&drop **/\r\nGridStack.prototype._prepareDragDropByNode = function(this: GridStack, node: GridStackNode): GridStack {\r\n let el = node.el;\r\n let dd = GridStackDD.get();\r\n\r\n // check for disabled grid first\r\n if (this.opts.staticGrid || ((node.noMove || this.opts.disableDrag) && (node.noResize || this.opts.disableResize))) {\r\n if (node._initDD) {\r\n dd.remove(el); // nukes everything instead of just disable, will add some styles back next\r\n delete node._initDD;\r\n }\r\n el.classList.add('ui-draggable-disabled', 'ui-resizable-disabled'); // add styles one might depend on #1435\r\n return this;\r\n }\r\n\r\n if (!node._initDD) {\r\n // variables used/cashed between the 3 start/move/end methods, in addition to node passed above\r\n let cellWidth: number;\r\n let cellHeight: number;\r\n\r\n /** called when item starts moving/resizing */\r\n let onStartMoving = (event: Event, ui: DDUIData) => {\r\n // trigger any 'dragstart' / 'resizestart' manually\r\n if (this._gsEventHandler[event.type]) {\r\n this._gsEventHandler[event.type](event, event.target);\r\n }\r\n cellWidth = this.cellWidth();\r\n cellHeight = this.getCellHeight(true); // force pixels for calculations\r\n\r\n this._onStartMoving(el, event, ui, node, cellWidth, cellHeight);\r\n }\r\n\r\n /** called when item is being dragged/resized */\r\n let dragOrResize = (event: Event, ui: DDUIData) => {\r\n this._dragOrResize(el, event, ui, node, cellWidth, cellHeight);\r\n }\r\n\r\n /** called when the item stops moving/resizing */\r\n let onEndMoving = (event: Event) => {\r\n this.placeholder.remove();\r\n delete node._moving;\r\n delete node._lastTried;\r\n\r\n // if the item has moved to another grid, we're done here\r\n let target: GridItemHTMLElement = event.target as GridItemHTMLElement;\r\n if (!target.gridstackNode || target.gridstackNode.grid !== this) return;\r\n\r\n node.el = target;\r\n\r\n if (node._isAboutToRemove) {\r\n let gridToNotify = el.gridstackNode.grid;\r\n if (gridToNotify._gsEventHandler[event.type]) {\r\n gridToNotify._gsEventHandler[event.type](event, target);\r\n }\r\n dd.remove(el);\r\n gridToNotify.engine.removedNodes.push(node);\r\n gridToNotify._triggerRemoveEvent();\r\n // break circular links and remove DOM\r\n delete el.gridstackNode;\r\n delete node.el;\r\n el.remove();\r\n } else {\r\n if (!node._temporaryRemoved) {\r\n // move to new placeholder location\r\n Utils.removePositioningStyles(target);// @ts-ignore\r\n this._writePosAttr(target, node);\r\n } else {\r\n // got removed - restore item back to before dragging position\r\n Utils.removePositioningStyles(target);\r\n Utils.copyPos(node, node._orig);// @ts-ignore\r\n this._writePosAttr(target, node);\r\n this.engine.addNode(node);\r\n }\r\n if (this._gsEventHandler[event.type]) {\r\n this._gsEventHandler[event.type](event, target);\r\n }\r\n }\r\n // @ts-ignore\r\n this._extraDragRow = 0;// @ts-ignore\r\n this._updateContainerHeight();// @ts-ignore\r\n this._triggerChangeEvent();\r\n\r\n this.engine.endUpdate();\r\n }\r\n\r\n dd.draggable(el, {\r\n start: onStartMoving,\r\n stop: onEndMoving,\r\n drag: dragOrResize\r\n }).resizable(el, {\r\n start: onStartMoving,\r\n stop: onEndMoving,\r\n resize: dragOrResize\r\n });\r\n node._initDD = true; // we've set DD support now\r\n }\r\n\r\n // finally fine tune move vs resize by disabling any part...\r\n if (node.noMove || this.opts.disableDrag) {\r\n dd.draggable(el, 'disable');\r\n el.classList.add('ui-draggable-disabled');\r\n } else {\r\n dd.draggable(el, 'enable');\r\n el.classList.remove('ui-draggable-disabled');\r\n }\r\n if (node.noResize || this.opts.disableResize) {\r\n dd.resizable(el, 'disable');\r\n el.classList.add('ui-resizable-disabled');\r\n } else {\r\n dd.resizable(el, 'enable');\r\n el.classList.remove('ui-resizable-disabled');\r\n }\r\n\r\n return this;\r\n}\r\n\r\n/** @internal called when item is starting a drag/resize */\r\nGridStack.prototype._onStartMoving = function(this: GridStack, el: GridItemHTMLElement, event: Event, ui: DDUIData, node: GridStackNode, cellWidth: number, cellHeight: number) {\r\n this.engine.cleanNodes()\r\n .beginUpdate(node);\r\n // @ts-ignore\r\n this._writePosAttr(this.placeholder, node)\r\n this.el.appendChild(this.placeholder);\r\n // TEST console.log('_onStartMoving placeholder')\r\n\r\n node.el = this.placeholder;\r\n node._lastUiPosition = ui.position;\r\n node._prevYPix = ui.position.top;\r\n node._moving = (event.type === 'dragstart'); // 'dropover' are not initially moving so they can go exactly where they enter (will push stuff out of the way)\r\n delete node._lastTried;\r\n\r\n if (event.type === 'dropover' && node._temporaryRemoved) {\r\n // TEST console.log('engine.addNode x=' + node.x);\r\n this.engine.addNode(node); // will add, fix collisions, update attr and clear _temporaryRemoved\r\n node._moving = true; // AFTER, mark as moving object (wanted fix location before)\r\n }\r\n\r\n // set the min/max resize info\r\n this.engine.cacheRects(cellWidth, cellHeight, this.opts.marginTop as number, this.opts.marginRight as number, this.opts.marginBottom as number, this.opts.marginLeft as number);\r\n if (event.type === 'resizestart') {\r\n let dd = GridStackDD.get()\r\n .resizable(el, 'option', 'minWidth', cellWidth * (node.minW || 1))\r\n .resizable(el, 'option', 'minHeight', cellHeight * (node.minH || 1));\r\n if (node.maxW) { dd.resizable(el, 'option', 'maxWidth', cellWidth * node.maxW); }\r\n if (node.maxH) { dd.resizable(el, 'option', 'maxHeight', cellHeight * node.maxH); }\r\n }\r\n}\r\n\r\n/** @internal called when item leaving our area by either cursor dropout event\r\n * or shape is outside our boundaries. remove it from us, and mark temporary if this was\r\n * our item to start with else restore prev node values from prev grid it came from.\r\n **/\r\nGridStack.prototype._leave = function(this: GridStack, el: GridItemHTMLElement, helper?: GridItemHTMLElement) {\r\n let node = el.gridstackNode;\r\n if (!node) return;\r\n\r\n GridStackDD.get().off(el, 'drag'); // no need to track while being outside\r\n\r\n // this gets called when cursor leaves and shape is outside, so only do this once\r\n if (node._temporaryRemoved) return;\r\n node._temporaryRemoved = true;\r\n\r\n this.engine.removeNode(node); // remove placeholder as well, otherwise it's a sign node is not in our list, which is a bigger issue\r\n node.el = node._isExternal && helper ? helper : el; // point back to real item being dragged\r\n\r\n if (this.opts.removable === true) { // boolean vs a class string\r\n // item leaving us and we are supposed to remove on leave (no need to drag onto trash) mark it so\r\n _itemRemoving(el, true);\r\n }\r\n\r\n // finally if item originally came from another grid, but left us, restore things back to prev info\r\n if (el._gridstackNodeOrig) {\r\n // TEST console.log('leave delete _gridstackNodeOrig')\r\n el.gridstackNode = el._gridstackNodeOrig;\r\n delete el._gridstackNodeOrig;\r\n } else if (node._isExternal) {\r\n // item came from outside (like a toolbar) so nuke any node info\r\n delete node.el;\r\n delete el.gridstackNode;\r\n // and restore all nodes back to original\r\n this.engine.restoreInitial();\r\n }\r\n}\r\n\r\n/** @internal called when item is being dragged/resized */\r\nGridStack.prototype._dragOrResize = function(this: GridStack, el: GridItemHTMLElement, event: Event, ui: DDUIData, node: GridStackNode, cellWidth: number, cellHeight: number) {\r\n let p = {...node._orig}; // could be undefined (_isExternal) which is ok (drag only set x,y and w,h will default to node value)\r\n let resizing: boolean;\r\n const mLeft = this.opts.marginLeft as number,\r\n mRight = this.opts.marginRight as number,\r\n mTop = this.opts.marginTop as number,\r\n mBottom = this.opts.marginBottom as number;\r\n\r\n if (event.type === 'drag') {\r\n if (node._temporaryRemoved) return; // handled by dropover\r\n let distance = ui.position.top - node._prevYPix;\r\n node._prevYPix = ui.position.top;\r\n Utils.updateScrollPosition(el, ui.position, distance);\r\n\r\n // get new position taking into account the margin in the direction we are moving! (need to pass mid point by margin)\r\n let left = ui.position.left + (ui.position.left > node._lastUiPosition.left ? -mRight : mLeft);\r\n let top = ui.position.top + (ui.position.top > node._lastUiPosition.top ? -mBottom : mTop);\r\n p.x = Math.round(left / cellWidth);\r\n p.y = Math.round(top / cellHeight);\r\n\r\n // @ts-ignore// if we're at the bottom hitting something else, grow the grid so cursor doesn't leave when trying to place below others\r\n let prev = this._extraDragRow;\r\n if (this.engine.collide(node, p)) {\r\n let row = this.getRow();\r\n let extra = Math.max(0, (p.y + node.h) - row);\r\n if (this.opts.maxRow && row + extra > this.opts.maxRow) {\r\n extra = Math.max(0, this.opts.maxRow - row);\r\n }// @ts-ignore\r\n this._extraDragRow = extra;// @ts-ignore\r\n } else this._extraDragRow = 0;// @ts-ignore\r\n if (this._extraDragRow !== prev) this._updateContainerHeight();\r\n\r\n if (node.x === p.x && node.y === p.y) return; // skip same\r\n // DON'T skip one we tried as we might have failed because of coverage <50% before\r\n // if (node._lastTried && node._lastTried.x === x && node._lastTried.y === y) return;\r\n } else if (event.type === 'resize') {\r\n if (p.x < 0) return;\r\n // Scrolling page if needed\r\n Utils.updateScrollResize(event as MouseEvent, el, cellHeight);\r\n\r\n // get new size\r\n p.w = Math.round((ui.size.width - mLeft) / cellWidth);\r\n p.h = Math.round((ui.size.height - mTop) / cellHeight);\r\n if (node.w === p.w && node.h === p.h) return;\r\n if (node._lastTried && node._lastTried.w === p.w && node._lastTried.h === p.h) return; // skip one we tried (but failed)\r\n\r\n // if we size on left/top side this might move us, so get possible new position as well\r\n let left = ui.position.left + mLeft;\r\n let top = ui.position.top + mTop;\r\n p.x = Math.round(left / cellWidth);\r\n p.y = Math.round(top / cellHeight);\r\n\r\n resizing = true;\r\n }\r\n\r\n node._lastTried = p; // set as last tried (will nuke if we go there)\r\n let rect: GridStackPosition = { // screen pix of the dragged box\r\n x: ui.position.left + mLeft,\r\n y: ui.position.top + mTop,\r\n w: (ui.size ? ui.size.width : node.w * cellWidth) - mLeft - mRight,\r\n h: (ui.size ? ui.size.height : node.h * cellHeight) - mTop - mBottom\r\n };\r\n if (this.engine.moveNodeCheck(node, {...p, cellWidth, cellHeight, rect})) {\r\n node._lastUiPosition = ui.position;\r\n this.engine.cacheRects(cellWidth, cellHeight, mTop, mRight, mBottom, mLeft);\r\n delete node._skipDown;\r\n if (resizing && node.subGrid) { (node.subGrid as GridStack).onParentResize(); }// @ts-ignore\r\n this._extraDragRow = 0;// @ts-ignore\r\n this._updateContainerHeight();\r\n\r\n let target = event.target as GridItemHTMLElement;// @ts-ignore\r\n this._writePosAttr(target, node);\r\n if (this._gsEventHandler[event.type]) {\r\n this._gsEventHandler[event.type](event, target);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Enables/Disables moving.\r\n * @param els widget or selector to modify.\r\n * @param val if true widget will be draggable.\r\n */\r\nGridStack.prototype.movable = function(this: GridStack, els: GridStackElement, val: boolean): GridStack {\r\n if (this.opts.staticGrid) return this; // can't move a static grid!\r\n GridStack.getElements(els).forEach(el => {\r\n let node = el.gridstackNode;\r\n if (!node) return;\r\n if (val) delete node.noMove; else node.noMove = true;\r\n this._prepareDragDropByNode(node); // init DD if need be, and adjust\r\n });\r\n return this;\r\n}\r\n\r\n/**\r\n * Enables/Disables resizing.\r\n * @param els widget or selector to modify\r\n * @param val if true widget will be resizable.\r\n */\r\nGridStack.prototype.resizable = function(this: GridStack, els: GridStackElement, val: boolean): GridStack {\r\n if (this.opts.staticGrid) return this; // can't resize a static grid!\r\n GridStack.getElements(els).forEach(el => {\r\n let node = el.gridstackNode;\r\n if (!node) return;\r\n if (val) delete node.noResize; else node.noResize = true;\r\n this._prepareDragDropByNode(node); // init DD if need be, and adjust\r\n });\r\n return this;\r\n}\r\n\r\n\r\n/**\r\n * Temporarily disables widgets moving/resizing.\r\n * If you want a more permanent way (which freezes up resources) use `setStatic(true)` instead.\r\n * Note: no-op for static grid\r\n * This is a shortcut for:\r\n * @example\r\n * grid.enableMove(false);\r\n * grid.enableResize(false);\r\n */\r\nGridStack.prototype.disable = function(this: GridStack): GridStack {\r\n if (this.opts.staticGrid) return;\r\n this.enableMove(false);\r\n this.enableResize(false);// @ts-ignore\r\n this._triggerEvent('disable');\r\n return this;\r\n}\r\n\r\n/**\r\n * Re-enables widgets moving/resizing - see disable().\r\n * Note: no-op for static grid.\r\n * This is a shortcut for:\r\n * @example\r\n * grid.enableMove(true);\r\n * grid.enableResize(true);\r\n */\r\nGridStack.prototype.enable = function(this: GridStack): GridStack {\r\n if (this.opts.staticGrid) return;\r\n this.enableMove(true);\r\n this.enableResize(true);// @ts-ignore\r\n this._triggerEvent('enable');\r\n return this;\r\n}\r\n\r\n/** Enables/disables widget moving. No-op for static grids. */\r\nGridStack.prototype.enableMove = function(this: GridStack, doEnable: boolean): GridStack {\r\n if (this.opts.staticGrid) return this; // can't move a static grid!\r\n this.opts.disableDrag = !doEnable; // FIRST before we update children as grid overrides #1658\r\n this.engine.nodes.forEach(n => this.movable(n.el, doEnable));\r\n return this;\r\n}\r\n\r\n/** Enables/disables widget resizing. No-op for static grids. */\r\nGridStack.prototype.enableResize = function(this: GridStack, doEnable: boolean): GridStack {\r\n if (this.opts.staticGrid) return this; // can't size a static grid!\r\n this.opts.disableResize = !doEnable; // FIRST before we update children as grid overrides #1658\r\n this.engine.nodes.forEach(n => this.resizable(n.el, doEnable));\r\n return this;\r\n}\r\n"]} \ No newline at end of file diff --git a/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-ddi.d.ts b/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-ddi.d.ts index b99412fd..ae8b21ba 100644 --- a/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-ddi.d.ts +++ b/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-ddi.d.ts @@ -1,5 +1,5 @@ /** - * gridstack-ddi.ts 4.2.5 + * gridstack-ddi.ts 4.2.6 * Copyright (c) 2021 Alain Dumesny - see GridStack root license */ import { GridItemHTMLElement } from './types'; diff --git a/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-ddi.js b/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-ddi.js index f35a076e..5a9fff0b 100644 --- a/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-ddi.js +++ b/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-ddi.js @@ -1,9 +1,10 @@ "use strict"; /** - * gridstack-ddi.ts 4.2.5 + * gridstack-ddi.ts 4.2.6 * Copyright (c) 2021 Alain Dumesny - see GridStack root license */ Object.defineProperty(exports, "__esModule", { value: true }); +exports.GridStackDDI = void 0; /** * Abstract Partial Interface API for drag'n'drop plugin - look at GridStackDD and HTML5 / Jquery implementation versions */ diff --git a/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-ddi.js.map b/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-ddi.js.map index c093f325..06d815e5 100644 --- a/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-ddi.js.map +++ b/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-ddi.js.map @@ -1 +1 @@ -{"version":3,"file":"gridstack-ddi.js","sourceRoot":"","sources":["../src/gridstack-ddi.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAIH;;GAEG;AACH,MAAa,YAAY;IAIvB,gFAAgF;IAChF,MAAM,CAAC,cAAc,CAAC,WAAgC;QACpD,YAAY,CAAC,GAAG,GAAG,IAAI,WAAW,EAAE,CAAC;QACrC,OAAO,YAAY,CAAC,GAAG,CAAC;IAC1B,CAAC;IAED,+CAA+C;IAC/C,MAAM,CAAC,GAAG;QACR,OAAO,YAAY,CAAC,GAAG,IAAI,YAAY,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;IACvE,CAAC;IAED,4DAA4D;IAC5D,gEAAgE;IACzD,MAAM,CAAC,EAAuB;QACnC,OAAO,IAAI,CAAC,CAAC,yBAAyB;IACxC,CAAC;CACF;AApBD,oCAoBC","sourcesContent":["/**\r\n * gridstack-ddi.ts 4.2.5\r\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\r\n */\r\n\r\nimport { GridItemHTMLElement } from './types';\r\n\r\n/**\r\n * Abstract Partial Interface API for drag'n'drop plugin - look at GridStackDD and HTML5 / Jquery implementation versions\r\n */\r\nexport class GridStackDDI {\r\n\r\n protected static ddi: GridStackDDI;\r\n\r\n /** call this method to register your plugin instead of the default no-op one */\r\n static registerPlugin(pluginClass: typeof GridStackDDI): GridStackDDI {\r\n GridStackDDI.ddi = new pluginClass();\r\n return GridStackDDI.ddi;\r\n }\r\n\r\n /** get the current registered plugin to use */\r\n static get(): GridStackDDI {\r\n return GridStackDDI.ddi || GridStackDDI.registerPlugin(GridStackDDI);\r\n }\r\n\r\n /** removes any drag&drop present (called during destroy) */\r\n /* eslint-disable-next-line @typescript-eslint/no-unused-vars */\r\n public remove(el: GridItemHTMLElement): GridStackDDI {\r\n return this; // no-op for static grids\r\n }\r\n}\r\n"]} \ No newline at end of file +{"version":3,"file":"gridstack-ddi.js","sourceRoot":"","sources":["../src/gridstack-ddi.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH;;GAEG;AACH,MAAa,YAAY;IAIvB,gFAAgF;IAChF,MAAM,CAAC,cAAc,CAAC,WAAgC;QACpD,YAAY,CAAC,GAAG,GAAG,IAAI,WAAW,EAAE,CAAC;QACrC,OAAO,YAAY,CAAC,GAAG,CAAC;IAC1B,CAAC;IAED,+CAA+C;IAC/C,MAAM,CAAC,GAAG;QACR,OAAO,YAAY,CAAC,GAAG,IAAI,YAAY,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;IACvE,CAAC;IAED,4DAA4D;IAC5D,gEAAgE;IACzD,MAAM,CAAC,EAAuB;QACnC,OAAO,IAAI,CAAC,CAAC,yBAAyB;IACxC,CAAC;CACF;AApBD,oCAoBC","sourcesContent":["/**\r\n * gridstack-ddi.ts 4.2.6\r\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\r\n */\r\n\r\nimport { GridItemHTMLElement } from './types';\r\n\r\n/**\r\n * Abstract Partial Interface API for drag'n'drop plugin - look at GridStackDD and HTML5 / Jquery implementation versions\r\n */\r\nexport class GridStackDDI {\r\n\r\n protected static ddi: GridStackDDI;\r\n\r\n /** call this method to register your plugin instead of the default no-op one */\r\n static registerPlugin(pluginClass: typeof GridStackDDI): GridStackDDI {\r\n GridStackDDI.ddi = new pluginClass();\r\n return GridStackDDI.ddi;\r\n }\r\n\r\n /** get the current registered plugin to use */\r\n static get(): GridStackDDI {\r\n return GridStackDDI.ddi || GridStackDDI.registerPlugin(GridStackDDI);\r\n }\r\n\r\n /** removes any drag&drop present (called during destroy) */\r\n /* eslint-disable-next-line @typescript-eslint/no-unused-vars */\r\n public remove(el: GridItemHTMLElement): GridStackDDI {\r\n return this; // no-op for static grids\r\n }\r\n}\r\n"]} \ No newline at end of file diff --git a/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-engine.d.ts b/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-engine.d.ts index f637f638..34bbba11 100644 --- a/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-engine.d.ts +++ b/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-engine.d.ts @@ -1,5 +1,5 @@ /** - * gridstack-engine.ts 4.2.5 + * gridstack-engine.ts 4.2.6 * Copyright (c) 2021 Alain Dumesny - see GridStack root license */ import { GridStackNode, GridStackPosition, GridStackMoveOpts } from './types'; @@ -43,8 +43,9 @@ export declare class GridStackEngine { /** re-layout grid items to reclaim any empty space */ compact(): GridStackEngine; /** enable/disable floating widgets (default: `false`) See [example](http://gridstackjs.com/demo/float.html) */ + set float(val: boolean); /** float getter method */ - float: boolean; + get float(): boolean; /** * given a random node, makes sure it's coordinates/values are valid in the current grid * @param node to adjust @@ -71,7 +72,7 @@ export declare class GridStackEngine { getRow(): number; beginUpdate(node: GridStackNode): GridStackEngine; endUpdate(): GridStackEngine; - /** saves the current layout returning a list of widgets for serialization */ + /** saves a copy of the current layout returning a list of widgets for serialization */ save(saveElement?: boolean): GridStackNode[]; /** * call to cache the given layout internally to the given location so we can restore back when column changes size diff --git a/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-engine.js b/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-engine.js index 86bb8feb..7b2f5902 100644 --- a/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-engine.js +++ b/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-engine.js @@ -1,9 +1,10 @@ "use strict"; /** - * gridstack-engine.ts 4.2.5 + * gridstack-engine.ts 4.2.6 * Copyright (c) 2021 Alain Dumesny - see GridStack root license */ Object.defineProperty(exports, "__esModule", { value: true }); +exports.GridStackEngine = void 0; const utils_1 = require("./utils"); /** * Defines the GridStack engine that does most no DOM grid manipulation. @@ -666,9 +667,9 @@ class GridStackEngine { } return this; } - /** saves the current layout returning a list of widgets for serialization */ + /** saves a copy of the current layout returning a list of widgets for serialization */ save(saveElement = true) { - let widgets = []; + let list = []; this._sortNodes(); this.nodes.forEach(n => { let w = {}; @@ -677,9 +678,9 @@ class GridStackEngine { w[key] = n[key]; } // delete other internals + delete w.grid; if (!saveElement) delete w.el; - delete w.grid; // delete default values (will be re-created on read) if (!w.autoPosition) delete w.autoPosition; @@ -689,9 +690,9 @@ class GridStackEngine { delete w.noMove; if (!w.locked) delete w.locked; - widgets.push(w); + list.push(w); }); - return widgets; + return list; } /** @internal called whenever a node is added or moved - updates the cached layouts */ layoutsNodesChange(nodes) { diff --git a/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-engine.js.map b/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-engine.js.map index ea50788f..863e6f8c 100644 --- a/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-engine.js.map +++ b/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-engine.js.map @@ -1 +1 @@ -{"version":3,"file":"gridstack-engine.js","sourceRoot":"","sources":["../src/gridstack-engine.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAEH,mCAAgC;AAahC;;;;;GAKG;AACH,MAAa,eAAe;IAqB1B,YAAmB,OAA+B,EAAE;QAhB7C,eAAU,GAAoB,EAAE,CAAC;QACjC,iBAAY,GAAoB,EAAE,CAAC;QAgBxC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;QAChC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;IAChC,CAAC;IAEM,WAAW;QAChB,IAAI,IAAI,CAAC,SAAS;YAAE,OAAO,IAAI,CAAC;QAChC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,C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AC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC;QAC1F,OAAO,IAAI,CAAC;IACd,CAAC;IAGD,uDAAuD;IAChD,WAAW,CAAC,IAAmB;QACpC,KAAK,IAAI,IAAI,IAAI,IAAI,EAAE;YACrB,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,IAAI,KAAK,KAAK;gBAAE,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC;SAC1D;QACD,OAAO,IAAI,CAAC;IACd,CAAC;;AAn0BH,0CAo0BC;AAlzBC,qEAAqE;AACtD,sBAAM,GAAG,CAAC,CAAC","sourcesContent":["/**\r\n * gridstack-engine.ts 4.2.5\r\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\r\n */\r\n\r\nimport { Utils } from './utils';\r\nimport { GridStackNode, ColumnOptions, GridStackPosition, GridStackMoveOpts } from './types';\r\n\r\nexport type onChangeCB = (nodes: GridStackNode[], removeDOM?: boolean) => void;\r\n/** options used for creations - similar to GridStackOptions */\r\nexport interface GridStackEngineOptions {\r\n column?: number;\r\n maxRow?: number;\r\n float?: boolean;\r\n nodes?: GridStackNode[];\r\n onChange?: onChangeCB;\r\n}\r\n\r\n/**\r\n * Defines the GridStack engine that does most no DOM grid manipulation.\r\n * See GridStack methods and vars for descriptions.\r\n *\r\n * NOTE: values should not be modified directly - call the main GridStack API instead\r\n */\r\nexport class GridStackEngine {\r\n public column: number;\r\n public maxRow: number;\r\n public nodes: GridStackNode[];\r\n public onChange: onChangeCB;\r\n public addedNodes: GridStackNode[] = [];\r\n public removedNodes: GridStackNode[] = [];\r\n public batchMode: boolean;\r\n /** @internal */\r\n private _float: boolean;\r\n /** @internal */\r\n private _prevFloat: boolean;\r\n /** @internal */\r\n private _layouts?: Layout[][]; // maps column # to array of values nodes\r\n /** @internal */\r\n private _ignoreLayoutsNodeChange: boolean;\r\n /** @internal true if we have some items locked */\r\n private _hasLocked: boolean;\r\n /** @internal unique global internal _id counter NOT starting at 0 */\r\n private static _idSeq = 1;\r\n\r\n public constructor(opts: GridStackEngineOptions = {}) {\r\n this.column = opts.column || 12;\r\n this.onChange = opts.onChange;\r\n this._float = opts.float;\r\n this.maxRow = opts.maxRow;\r\n this.nodes = opts.nodes || [];\r\n }\r\n\r\n public batchUpdate(): GridStackEngine {\r\n if (this.batchMode) return this;\r\n this.batchMode = true;\r\n this._prevFloat = this._float;\r\n this._float = true; // let things go anywhere for now... commit() will restore and possibly reposition\r\n this.saveInitial(); // since begin update (which is called multiple times) won't do this\r\n return this;\r\n }\r\n\r\n public commit(): GridStackEngine {\r\n if (!this.batchMode) return this;\r\n this.batchMode = false;\r\n this._float = this._prevFloat;\r\n delete this._prevFloat;\r\n return this._packNodes()\r\n ._notify();\r\n }\r\n\r\n // use entire row for hitting area (will use bottom reverse sorted first) if we not actively moving DOWN and didn't already skip\r\n private _useEntireRowArea(node: GridStackNode, nn: GridStackPosition): boolean {\r\n return !this.float && !this._hasLocked && (!node._moving || node._skipDown || nn.y <= node.y);\r\n }\r\n\r\n /** @internal fix collision on given 'node', going to given new location 'nn', with optional 'collide' node already found.\r\n * return true if we moved. */\r\n private _fixCollisions(node: GridStackNode, nn = node, collide?: GridStackNode, opt: GridStackMoveOpts = {}): boolean {\r\n this._sortNodes(-1); // from last to first, so recursive collision move items in the right order\r\n\r\n collide = collide || this.collide(node, nn); // REAL area collide for swap and skip if none...\r\n if (!collide) return false;\r\n\r\n // swap check: if we're actively moving in gravity mode, see if we collide with an object the same size\r\n if (node._moving && !opt.nested && !this.float) {\r\n if (this.swap(node, collide)) return true;\r\n }\r\n\r\n // during while() collisions MAKE SURE to check entire row so larger items don't leap frog small ones (push them all down starting last in grid)\r\n let area = nn;\r\n if (this._useEntireRowArea(node, nn)) {\r\n area = {x: 0, w: this.column, y: nn.y, h: nn.h};\r\n collide = this.collide(node, area, opt.skip); // force new hit\r\n }\r\n\r\n let didMove = false;\r\n let newOpt: GridStackMoveOpts = {nested: true, pack: false};\r\n while (collide = collide || this.collide(node, area, opt.skip)) { // could collide with more than 1 item... so repeat for each\r\n let moved: boolean;\r\n // if colliding with a locked item OR moving down with top gravity (and collide could move up) -> skip past the collide,\r\n // but remember that skip down so we only do this once (and push others otherwise).\r\n if (collide.locked || node._moving && !node._skipDown && nn.y > node.y && !this.float &&\r\n // can take space we had, or before where we're going\r\n (!this.collide(collide, {...collide, y: node.y}, node) || !this.collide(collide, {...collide, y: nn.y - collide.h}, node))) {\r\n node._skipDown = (node._skipDown || nn.y > node.y);\r\n moved = this.moveNode(node, {...nn, y: collide.y + collide.h, ...newOpt});\r\n if (collide.locked && moved) {\r\n Utils.copyPos(nn, node); // moving after lock become our new desired location\r\n } else if (!collide.locked && moved && opt.pack) {\r\n // we moved after and will pack: do it now and keep the original drop location, but past the old collide to see what else we might push way\r\n this._packNodes();\r\n nn.y = collide.y + collide.h;\r\n Utils.copyPos(node, nn);\r\n }\r\n didMove = didMove || moved;\r\n } else {\r\n // move collide down *after* where we will be, ignoring where we are now (don't collide with us)\r\n moved = this.moveNode(collide, {...collide, y: nn.y + nn.h, skip: node, ...newOpt});\r\n }\r\n if (!moved) { return didMove; } // break inf loop if we couldn't move after all (ex: maxRow, fixed)\r\n collide = undefined;\r\n }\r\n return didMove;\r\n }\r\n\r\n /** return the nodes that intercept the given node. Optionally a different area can be used, as well as a second node to skip */\r\n public collide(skip: GridStackNode, area = skip, skip2?: GridStackNode): GridStackNode {\r\n return this.nodes.find(n => n !== skip && n !== skip2 && Utils.isIntercepted(n, area));\r\n }\r\n public collideAll(skip: GridStackNode, area = skip, skip2?: GridStackNode): GridStackNode[] {\r\n return this.nodes.filter(n => n !== skip && n !== skip2 && Utils.isIntercepted(n, area));\r\n }\r\n\r\n /** does a pixel coverage collision, returning the node that has the most coverage that is >50% mid line */\r\n public collideCoverage(node: GridStackNode, o: GridStackMoveOpts, collides: GridStackNode[]): GridStackNode {\r\n if (!o.rect || !node._rect) return;\r\n let r0 = node._rect; // where started\r\n let r = {...o.rect}; // where we are\r\n\r\n // update dragged rect to show where it's coming from (above or below, etc...)\r\n if (r.y > r0.y) {\r\n r.h += r.y - r0.y;\r\n r.y = r0.y;\r\n } else {\r\n r.h += r0.y - r.y;\r\n }\r\n if (r.x > r0.x) {\r\n r.w += r.x - r0.x;\r\n r.x = r0.x;\r\n } else {\r\n r.w += r0.x - r.x;\r\n }\r\n\r\n let collide: GridStackNode;\r\n collides.forEach(n => {\r\n if (n.locked || !n._rect) return;\r\n let r2 = n._rect; // overlapping target\r\n let yOver = Number.MAX_VALUE, xOver = Number.MAX_VALUE, overMax = 0.5; // need >50%\r\n // depending on which side we started from, compute the overlap % of coverage\r\n // (ex: from above/below we only compute the max horizontal line coverage)\r\n if (r0.y < r2.y) { // from above\r\n yOver = ((r.y + r.h) - r2.y) / r2.h;\r\n } else if (r0.y+r0.h > r2.y+r2.h) { // from below\r\n yOver = ((r2.y + r2.h) - r.y) / r2.h;\r\n }\r\n if (r0.x < r2.x) { // from the left\r\n xOver = ((r.x + r.w) - r2.x) / r2.w;\r\n } else if (r0.x+r0.w > r2.x+r2.w) { // from the right\r\n xOver = ((r2.x + r2.w) - r.x) / r2.w;\r\n }\r\n let over = Math.min(xOver, yOver);\r\n if (over > overMax) {\r\n overMax = over;\r\n collide = n;\r\n }\r\n });\r\n return collide;\r\n }\r\n\r\n /** called to cache the nodes pixel rectangles used for collision detection during drag */\r\n public cacheRects(w: number, h: number, top: number, right: number, bottom: number, left: number): GridStackEngine\r\n {\r\n this.nodes.forEach(n =>\r\n n._rect = {\r\n y: n.y * h + top,\r\n x: n.x * w + left,\r\n w: n.w * w - left - right,\r\n h: n.h * h - top - bottom\r\n }\r\n );\r\n return this;\r\n }\r\n\r\n /** called to possibly swap between 2 nodes (same size or column, not locked, touching), returning true if successful */\r\n public swap(a: GridStackNode, b: GridStackNode): boolean {\r\n if (!b || b.locked || !a || a.locked) return false;\r\n\r\n function _doSwap(): true { // assumes a is before b IFF they have different height (put after rather than exact swap)\r\n let x = b.x, y = b.y;\r\n b.x = a.x; b.y = a.y; // b -> a position\r\n if (a.h != b.h) {\r\n a.x = x; a.y = b.y + b.h; // a -> goes after b\r\n } else {\r\n a.x = x; a.y = y; // a -> old b position\r\n }\r\n a._dirty = b._dirty = true;\r\n return true;\r\n }\r\n let touching: boolean; // remember if we called it (vs undefined)\r\n\r\n // same size and same row or column, and touching\r\n if (a.w === b.w && a.h === b.h && (a.x === b.x || a.y === b.y) && (touching = Utils.isTouching(a, b)))\r\n return _doSwap();\r\n if (touching === false) return; // ran test and fail, bail out\r\n\r\n // check for taking same columns (but different height) and touching\r\n if (a.w === b.w && a.x === b.x && (touching || Utils.isTouching(a, b))) {\r\n if (b.y < a.y) { let t = a; a = b; b = t; } // swap a <-> b vars so a is first\r\n return _doSwap();\r\n }\r\n\r\n /* different X will be weird (expect vertical swap) and different height overlap, so too complex. user regular layout instead\r\n // else check if swapping would not collide with anything else (requiring a re-layout)\r\n if (!this.collide(a, {x: a.x, y: a.y, w: b.w, h: b.h}, b) &&\r\n !this.collide(a, {x: b.x, y: b.y, w: a.w, h: a.h}, b))\r\n return _doSwap(); */\r\n return false;\r\n }\r\n\r\n public isAreaEmpty(x: number, y: number, w: number, h: number): boolean {\r\n let nn: GridStackNode = {x: x || 0, y: y || 0, w: w || 1, h: h || 1};\r\n return !this.collide(nn);\r\n }\r\n\r\n /** re-layout grid items to reclaim any empty space */\r\n public compact(): GridStackEngine {\r\n if (this.nodes.length === 0) return this;\r\n this.batchUpdate()\r\n ._sortNodes();\r\n let copyNodes = this.nodes;\r\n this.nodes = []; // pretend we have no nodes to conflict layout to start with...\r\n copyNodes.forEach(node => {\r\n if (!node.locked) {\r\n node.autoPosition = true;\r\n }\r\n this.addNode(node, false); // 'false' for add event trigger\r\n node._dirty = true; // will force attr update\r\n });\r\n return this.commit();\r\n }\r\n\r\n /** enable/disable floating widgets (default: `false`) See [example](http://gridstackjs.com/demo/float.html) */\r\n public set float(val: boolean) {\r\n if (this._float === val) return;\r\n this._float = val || false;\r\n if (!val) {\r\n this._packNodes()._notify();\r\n }\r\n }\r\n\r\n /** float getter method */\r\n public get float(): boolean { return this._float || false; }\r\n\r\n /** @internal */\r\n private _sortNodes(dir?: -1 | 1): GridStackEngine {\r\n this.nodes = Utils.sort(this.nodes, dir, this.column);\r\n return this;\r\n }\r\n\r\n /** @internal called to top gravity pack the items back OR revert back to original Y positions when floating */\r\n private _packNodes(): GridStackEngine {\r\n this._sortNodes(); // first to last\r\n\r\n if (this.float) {\r\n // restore original Y pos\r\n this.nodes.forEach(n => {\r\n if (n._updating || n._orig === undefined || n.y === n._orig.y) return;\r\n let newY = n.y;\r\n while (newY > n._orig.y) {\r\n --newY;\r\n let collide = this.collide(n, {x: n.x, y: newY, w: n.w, h: n.h});\r\n if (!collide) {\r\n n._dirty = true;\r\n n.y = newY;\r\n }\r\n }\r\n });\r\n } else {\r\n // top gravity pack\r\n this.nodes.forEach((n, i) => {\r\n if (n.locked) return;\r\n while (n.y > 0) {\r\n let newY = i === 0 ? 0 : n.y - 1;\r\n let canBeMoved = i === 0 || !this.collide(n, {x: n.x, y: newY, w: n.w, h: n.h});\r\n if (!canBeMoved) break;\r\n // Note: must be dirty (from last position) for GridStack::OnChange CB to update positions\r\n // and move items back. The user 'change' CB should detect changes from the original\r\n // starting position instead.\r\n n._dirty = (n.y !== newY);\r\n n.y = newY;\r\n }\r\n });\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * given a random node, makes sure it's coordinates/values are valid in the current grid\r\n * @param node to adjust\r\n * @param resizing if out of bound, resize down or move into the grid to fit ?\r\n */\r\n public prepareNode(node: GridStackNode, resizing?: boolean): GridStackNode {\r\n node = node || {};\r\n node._id = node._id || GridStackEngine._idSeq++;\r\n\r\n // if we're missing position, have the grid position us automatically (before we set them to 0,0)\r\n if (node.x === undefined || node.y === undefined || node.x === null || node.y === null) {\r\n node.autoPosition = true;\r\n }\r\n\r\n // assign defaults for missing required fields\r\n let defaults: GridStackNode = { x: 0, y: 0, w: 1, h: 1};\r\n Utils.defaults(node, defaults);\r\n\r\n if (!node.autoPosition) { delete node.autoPosition; }\r\n if (!node.noResize) { delete node.noResize; }\r\n if (!node.noMove) { delete node.noMove; }\r\n\r\n // check for NaN (in case messed up strings were passed. can't do parseInt() || defaults.x above as 0 is valid #)\r\n if (typeof node.x == 'string') { node.x = Number(node.x); }\r\n if (typeof node.y == 'string') { node.y = Number(node.y); }\r\n if (typeof node.w == 'string') { node.w = Number(node.w); }\r\n if (typeof node.h == 'string') { node.h = Number(node.h); }\r\n if (isNaN(node.x)) { node.x = defaults.x; node.autoPosition = true; }\r\n if (isNaN(node.y)) { node.y = defaults.y; node.autoPosition = true; }\r\n if (isNaN(node.w)) { node.w = defaults.w; }\r\n if (isNaN(node.h)) { node.h = defaults.h; }\r\n\r\n return this.nodeBoundFix(node, resizing);\r\n }\r\n\r\n /** part2 of preparing a node to fit inside our grid - checks for x,y from grid dimensions */\r\n public nodeBoundFix(node: GridStackNode, resizing?: boolean): GridStackNode {\r\n\r\n if (node.maxW) { node.w = Math.min(node.w, node.maxW); }\r\n if (node.maxH) { node.h = Math.min(node.h, node.maxH); }\r\n if (node.minW) { node.w = Math.max(node.w, node.minW); }\r\n if (node.minH) { node.h = Math.max(node.h, node.minH); }\r\n\r\n if (node.w > this.column) {\r\n // if user loaded a larger than allowed widget for current # of columns,\r\n // remember it's full width so we can restore back (1 -> 12 column) #1655\r\n if (this.column < 12) {\r\n node.w = Math.min(12, node.w);\r\n this.cacheOneLayout(node, 12);\r\n }\r\n node.w = this.column;\r\n } else if (node.w < 1) {\r\n node.w = 1;\r\n }\r\n\r\n if (this.maxRow && node.h > this.maxRow) {\r\n node.h = this.maxRow;\r\n } else if (node.h < 1) {\r\n node.h = 1;\r\n }\r\n\r\n if (node.x < 0) {\r\n node.x = 0;\r\n }\r\n if (node.y < 0) {\r\n node.y = 0;\r\n }\r\n\r\n if (node.x + node.w > this.column) {\r\n if (resizing) {\r\n node.w = this.column - node.x;\r\n } else {\r\n node.x = this.column - node.w;\r\n }\r\n }\r\n if (this.maxRow && node.y + node.h > this.maxRow) {\r\n if (resizing) {\r\n node.h = this.maxRow - node.y;\r\n } else {\r\n node.y = this.maxRow - node.h;\r\n }\r\n }\r\n\r\n return node;\r\n }\r\n\r\n public getDirtyNodes(verify?: boolean): GridStackNode[] {\r\n // compare original x,y,w,h instead as _dirty can be a temporary state\r\n if (verify) {\r\n return this.nodes.filter(n => n._dirty && !Utils.samePos(n, n._orig));\r\n }\r\n return this.nodes.filter(n => n._dirty);\r\n }\r\n\r\n /** @internal call this to call onChange CB with dirty nodes */\r\n private _notify(nodes?: GridStackNode | GridStackNode[], removeDOM = true): GridStackEngine {\r\n if (this.batchMode) return this;\r\n nodes = (nodes === undefined ? [] : (Array.isArray(nodes) ? nodes : [nodes]) );\r\n let dirtyNodes = nodes.concat(this.getDirtyNodes());\r\n this.onChange && this.onChange(dirtyNodes, removeDOM);\r\n return this;\r\n }\r\n\r\n /** @internal remove dirty and last tried info */\r\n public cleanNodes(): GridStackEngine {\r\n if (this.batchMode) return this;\r\n this.nodes.forEach(n => {\r\n delete n._dirty;\r\n delete n._lastTried;\r\n });\r\n return this;\r\n }\r\n\r\n /** @internal called to save initial position/size to track real dirty state.\r\n * Note: should be called right after we call change event (so next API is can detect changes)\r\n * as well as right before we start move/resize/enter (so we can restore items to prev values) */\r\n public saveInitial(): GridStackEngine {\r\n this.nodes.forEach(n => {\r\n n._orig = Utils.copyPos({}, n);\r\n delete n._dirty;\r\n });\r\n this._hasLocked = this.nodes.some(n => n.locked);\r\n return this;\r\n }\r\n\r\n /** @internal restore all the nodes back to initial values (called when we leave) */\r\n public restoreInitial(): GridStackEngine {\r\n this.nodes.forEach(n => {\r\n if (Utils.samePos(n, n._orig)) return;\r\n Utils.copyPos(n, n._orig);\r\n n._dirty = true;\r\n });\r\n this._notify();\r\n return this;\r\n }\r\n\r\n /** call to add the given node to our list, fixing collision and re-packing */\r\n public addNode(node: GridStackNode, triggerAddEvent = false): GridStackNode {\r\n let dup: GridStackNode;\r\n if (dup = this.nodes.find(n => n._id === node._id)) return dup; // prevent inserting twice! return it instead.\r\n\r\n node = this.prepareNode(node);\r\n delete node._temporaryRemoved;\r\n delete node._removeDOM;\r\n\r\n if (node.autoPosition) {\r\n this._sortNodes();\r\n\r\n for (let i = 0;; ++i) {\r\n let x = i % this.column;\r\n let y = Math.floor(i / this.column);\r\n if (x + node.w > this.column) {\r\n continue;\r\n }\r\n let box = {x, y, w: node.w, h: node.h};\r\n if (!this.nodes.find(n => Utils.isIntercepted(box, n))) {\r\n node.x = x;\r\n node.y = y;\r\n delete node.autoPosition; // found our slot\r\n break;\r\n }\r\n }\r\n }\r\n\r\n this.nodes.push(node);\r\n triggerAddEvent && this.addedNodes.push(node);\r\n\r\n this._fixCollisions(node);\r\n this._packNodes()\r\n ._notify();\r\n return node;\r\n }\r\n\r\n public removeNode(node: GridStackNode, removeDOM = true, triggerEvent = false): GridStackEngine {\r\n if (!this.nodes.find(n => n === node)) {\r\n // TEST console.log(`Error: GridStackEngine.removeNode() node._id=${node._id} not found!`)\r\n return this;\r\n }\r\n if (triggerEvent) { // we wait until final drop to manually track removed items (rather than during drag)\r\n this.removedNodes.push(node);\r\n }\r\n if (removeDOM) node._removeDOM = true; // let CB remove actual HTML (used to set _id to null, but then we loose layout info)\r\n // don't use 'faster' .splice(findIndex(),1) in case node isn't in our list, or in multiple times.\r\n this.nodes = this.nodes.filter(n => n !== node);\r\n return this._packNodes()\r\n ._notify(node);\r\n }\r\n\r\n public removeAll(removeDOM = true): GridStackEngine {\r\n delete this._layouts;\r\n if (this.nodes.length === 0) return this;\r\n removeDOM && this.nodes.forEach(n => n._removeDOM = true); // let CB remove actual HTML (used to set _id to null, but then we loose layout info)\r\n this.removedNodes = this.nodes;\r\n this.nodes = [];\r\n return this._notify(this.removedNodes);\r\n }\r\n\r\n /** checks if item can be moved (layout constrain) vs moveNode(), returning true if was able to move.\r\n * In more complicated cases (maxRow) it will attempt at moving the item and fixing\r\n * others in a clone first, then apply those changes if still within specs. */\r\n public moveNodeCheck(node: GridStackNode, o: GridStackMoveOpts): boolean {\r\n // if (node.locked) return false;\r\n if (!this.changedPosConstrain(node, o)) return false;\r\n o.pack = true;\r\n\r\n // simpler case: move item directly...\r\n if (!this.maxRow/* && !this._hasLocked*/) {\r\n return this.moveNode(node, o);\r\n }\r\n\r\n // complex case: create a clone with NO maxRow (will check for out of bounds at the end)\r\n let clonedNode: GridStackNode;\r\n let clone = new GridStackEngine({\r\n column: this.column,\r\n float: this.float,\r\n nodes: this.nodes.map(n => {\r\n if (n === node) {\r\n clonedNode = {...n};\r\n return clonedNode;\r\n }\r\n return {...n};\r\n })\r\n });\r\n if (!clonedNode) return false;\r\n\r\n let canMove = clone.moveNode(clonedNode, o);\r\n // if maxRow make sure we are still valid size\r\n if (this.maxRow && canMove) {\r\n canMove = (clone.getRow() <= this.maxRow);\r\n // turns out we can't grow, then see if we can swap instead (ex: full grid)\r\n if (!canMove) {\r\n let collide = this.collide(node, o);\r\n if (collide && this.swap(node, collide)) {\r\n this._notify();\r\n return true;\r\n }\r\n }\r\n }\r\n if (!canMove) return false;\r\n\r\n // if clone was able to move, copy those mods over to us now instead of caller trying to do this all over!\r\n // Note: we can't use the list directly as elements and other parts point to actual node, so copy content\r\n clone.nodes.filter(n => n._dirty).forEach(c => {\r\n let n = this.nodes.find(a => a._id === c._id);\r\n if (!n) return;\r\n Utils.copyPos(n, c);\r\n n._dirty = true;\r\n });\r\n this._notify();\r\n return true;\r\n }\r\n\r\n /** return true if can fit in grid height constrain only (always true if no maxRow) */\r\n public willItFit(node: GridStackNode): boolean {\r\n delete node._willFitPos;\r\n if (!this.maxRow) return true;\r\n // create a clone with NO maxRow and check if still within size\r\n let clone = new GridStackEngine({\r\n column: this.column,\r\n float: this.float,\r\n nodes: this.nodes.map(n => {return {...n}})\r\n });\r\n let n = {...node}; // clone node so we don't mod any settings on it but have full autoPosition and min/max as well! #1687\r\n this.cleanupNode(n);\r\n delete n.el; delete n._id; delete n.content; delete n.grid;\r\n clone.addNode(n);\r\n if (clone.getRow() <= this.maxRow) {\r\n node._willFitPos = Utils.copyPos({}, n);\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /** true if x,y or w,h are different after clamping to min/max */\r\n public changedPosConstrain(node: GridStackNode, p: GridStackPosition): boolean {\r\n // make sure w,h are set\r\n p.w = p.w || node.w;\r\n p.h = p.h || node.h;\r\n if (node.x !== p.x || node.y !== p.y) return true;\r\n // check constrained w,h\r\n if (node.maxW) { p.w = Math.min(p.w, node.maxW); }\r\n if (node.maxH) { p.h = Math.min(p.h, node.maxH); }\r\n if (node.minW) { p.w = Math.max(p.w, node.minW); }\r\n if (node.minH) { p.h = Math.max(p.h, node.minH); }\r\n return (node.w !== p.w || node.h !== p.h);\r\n }\r\n\r\n /** return true if the passed in node was actually moved (checks for no-op and locked) */\r\n public moveNode(node: GridStackNode, o: GridStackMoveOpts): boolean {\r\n if (!node || /*node.locked ||*/ !o) return false;\r\n if (o.pack === undefined) o.pack = true;\r\n\r\n // constrain the passed in values and check if we're still changing our node\r\n if (typeof o.x !== 'number') { o.x = node.x; }\r\n if (typeof o.y !== 'number') { o.y = node.y; }\r\n if (typeof o.w !== 'number') { o.w = node.w; }\r\n if (typeof o.h !== 'number') { o.h = node.h; }\r\n let resizing = (node.w !== o.w || node.h !== o.h);\r\n let nn: GridStackNode = Utils.copyPos({}, node, true); // get min/max out first, then opt positions next\r\n Utils.copyPos(nn, o);\r\n nn = this.nodeBoundFix(nn, resizing);\r\n Utils.copyPos(o, nn);\r\n\r\n if (Utils.samePos(node, o)) return false;\r\n let prevPos: GridStackPosition = Utils.copyPos({}, node);\r\n\r\n // during while() collisions make sure to check entire row so larger items don't leap frog small ones (push them all down)\r\n let area = nn;\r\n // if (this._useEntireRowArea(node, nn)) {\r\n // area = {x: 0, w: this.column, y: nn.y, h: nn.h};\r\n // }\r\n\r\n // check if we will need to fix collision at our new location\r\n let collides = this.collideAll(node, area, o.skip);\r\n let needToMove = true;\r\n if (collides.length) {\r\n // now check to make sure we actually collided over 50% surface area while dragging\r\n let collide = node._moving && !o.nested ? this.collideCoverage(node, o, collides) : collides[0];\r\n if (collide) {\r\n needToMove = !this._fixCollisions(node, nn, collide, o); // check if already moved...\r\n } else {\r\n needToMove = false; // we didn't cover >50% for a move, skip...\r\n }\r\n }\r\n\r\n // now move (to the original ask vs the collision version which might differ) and repack things\r\n if (needToMove) {\r\n node._dirty = true;\r\n Utils.copyPos(node, nn);\r\n }\r\n if (o.pack) {\r\n this._packNodes()\r\n ._notify();\r\n }\r\n return !Utils.samePos(node, prevPos); // pack might have moved things back\r\n }\r\n\r\n public getRow(): number {\r\n return this.nodes.reduce((row, n) => Math.max(row, n.y + n.h), 0);\r\n }\r\n\r\n public beginUpdate(node: GridStackNode): GridStackEngine {\r\n if (!node._updating) {\r\n node._updating = true;\r\n delete node._skipDown;\r\n if (!this.batchMode) this.saveInitial();\r\n }\r\n return this;\r\n }\r\n\r\n public endUpdate(): GridStackEngine {\r\n let n = this.nodes.find(n => n._updating);\r\n if (n) {\r\n delete n._updating;\r\n delete n._skipDown;\r\n }\r\n return this;\r\n }\r\n\r\n /** saves the current layout returning a list of widgets for serialization */\r\n public save(saveElement = true): GridStackNode[] {\r\n let widgets: GridStackNode[] = [];\r\n this._sortNodes();\r\n this.nodes.forEach(n => {\r\n let w: GridStackNode = {};\r\n for (let key in n) { if (key[0] !== '_' && n[key] !== null && n[key] !== undefined ) w[key] = n[key]; }\r\n // delete other internals\r\n if (!saveElement) delete w.el;\r\n delete w.grid;\r\n // delete default values (will be re-created on read)\r\n if (!w.autoPosition) delete w.autoPosition;\r\n if (!w.noResize) delete w.noResize;\r\n if (!w.noMove) delete w.noMove;\r\n if (!w.locked) delete w.locked;\r\n widgets.push(w);\r\n });\r\n return widgets;\r\n }\r\n\r\n /** @internal called whenever a node is added or moved - updates the cached layouts */\r\n public layoutsNodesChange(nodes: GridStackNode[]): GridStackEngine {\r\n if (!this._layouts || this._ignoreLayoutsNodeChange) return this;\r\n // remove smaller layouts - we will re-generate those on the fly... larger ones need to update\r\n this._layouts.forEach((layout, column) => {\r\n if (!layout || column === this.column) return this;\r\n if (column < this.column) {\r\n this._layouts[column] = undefined;\r\n }\r\n else {\r\n // we save the original x,y,w (h isn't cached) to see what actually changed to propagate better.\r\n // Note: we don't need to check against out of bound scaling/moving as that will be done when using those cache values.\r\n nodes.forEach(node => {\r\n if (!node._orig) return; // didn't change (newly added ?)\r\n let n = layout.find(l => l._id === node._id);\r\n if (!n) return; // no cache for new nodes. Will use those values.\r\n let ratio = column / this.column;\r\n // Y changed, push down same amount\r\n // TODO: detect doing item 'swaps' will help instead of move (especially in 1 column mode)\r\n if (node.y !== node._orig.y) {\r\n n.y += (node.y - node._orig.y);\r\n }\r\n // X changed, scale from new position\r\n if (node.x !== node._orig.x) {\r\n n.x = Math.round(node.x * ratio);\r\n }\r\n // width changed, scale from new width\r\n if (node.w !== node._orig.w) {\r\n n.w = Math.round(node.w * ratio);\r\n }\r\n // ...height always carries over from cache\r\n });\r\n }\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * @internal Called to scale the widget width & position up/down based on the column change.\r\n * Note we store previous layouts (especially original ones) to make it possible to go\r\n * from say 12 -> 1 -> 12 and get back to where we were.\r\n *\r\n * @param oldColumn previous number of columns\r\n * @param column new column number\r\n * @param nodes different sorted list (ex: DOM order) instead of current list\r\n * @param layout specify the type of re-layout that will happen (position, size, etc...).\r\n * Note: items will never be outside of the current column boundaries. default (moveScale). Ignored for 1 column\r\n */\r\n public updateNodeWidths(oldColumn: number, column: number, nodes: GridStackNode[], layout: ColumnOptions = 'moveScale'): GridStackEngine {\r\n if (!this.nodes.length || oldColumn === column) return this;\r\n\r\n // cache the current layout in case they want to go back (like 12 -> 1 -> 12) as it requires original data\r\n this.cacheLayout(this.nodes, oldColumn);\r\n\r\n // if we're going to 1 column and using DOM order rather than default sorting, then generate that layout\r\n if (column === 1 && nodes && nodes.length) {\r\n let top = 0;\r\n nodes.forEach(n => {\r\n n.x = 0;\r\n n.w = 1;\r\n n.y = Math.max(n.y, top);\r\n top = n.y + n.h;\r\n });\r\n } else {\r\n nodes = Utils.sort(this.nodes, -1, oldColumn); // current column reverse sorting so we can insert last to front (limit collision)\r\n }\r\n\r\n // see if we have cached previous layout.\r\n let cacheNodes = this._layouts[column] || [];\r\n // if not AND we are going up in size start with the largest layout as down-scaling is more accurate\r\n let lastIndex = this._layouts.length - 1;\r\n if (cacheNodes.length === 0 && column > oldColumn && column < lastIndex) {\r\n cacheNodes = this._layouts[lastIndex] || [];\r\n if (cacheNodes.length) {\r\n // pretend we came from that larger column by assigning those values as starting point\r\n oldColumn = lastIndex;\r\n cacheNodes.forEach(cacheNode => {\r\n let j = nodes.findIndex(n => n._id === cacheNode._id);\r\n if (j !== -1) {\r\n // still current, use cache info positions\r\n nodes[j].x = cacheNode.x;\r\n nodes[j].y = cacheNode.y;\r\n nodes[j].w = cacheNode.w;\r\n }\r\n });\r\n cacheNodes = []; // we still don't have new column cached data... will generate from larger one.\r\n }\r\n }\r\n\r\n // if we found cache re-use those nodes that are still current\r\n let newNodes: GridStackNode[] = [];\r\n cacheNodes.forEach(cacheNode => {\r\n let j = nodes.findIndex(n => n._id === cacheNode._id);\r\n if (j !== -1) {\r\n // still current, use cache info positions\r\n nodes[j].x = cacheNode.x;\r\n nodes[j].y = cacheNode.y;\r\n nodes[j].w = cacheNode.w;\r\n newNodes.push(nodes[j]);\r\n nodes.splice(j, 1);\r\n }\r\n });\r\n // ...and add any extra non-cached ones\r\n if (nodes.length) {\r\n if (typeof layout === 'function') {\r\n layout(column, oldColumn, newNodes, nodes);\r\n } else {\r\n let ratio = column / oldColumn;\r\n let move = (layout === 'move' || layout === 'moveScale');\r\n let scale = (layout === 'scale' || layout === 'moveScale');\r\n nodes.forEach(node => {\r\n node.x = (column === 1 ? 0 : (move ? Math.round(node.x * ratio) : Math.min(node.x, column - 1)));\r\n node.w = ((column === 1 || oldColumn === 1) ? 1 :\r\n scale ? (Math.round(node.w * ratio) || 1) : (Math.min(node.w, column)));\r\n newNodes.push(node);\r\n });\r\n nodes = [];\r\n }\r\n }\r\n\r\n // finally re-layout them in reverse order (to get correct placement)\r\n newNodes = Utils.sort(newNodes, -1, column);\r\n this._ignoreLayoutsNodeChange = true;\r\n this.batchUpdate();\r\n this.nodes = []; // pretend we have no nodes to start with (we use same structures) to simplify layout\r\n newNodes.forEach(node => {\r\n this.addNode(node, false); // 'false' for add event trigger\r\n node._dirty = true; // force attr update\r\n }, this);\r\n this.commit();\r\n delete this._ignoreLayoutsNodeChange;\r\n return this;\r\n }\r\n\r\n /**\r\n * call to cache the given layout internally to the given location so we can restore back when column changes size\r\n * @param nodes list of nodes\r\n * @param column corresponding column index to save it under\r\n * @param clear if true, will force other caches to be removed (default false)\r\n */\r\n public cacheLayout(nodes: GridStackNode[], column: number, clear = false): GridStackEngine {\r\n let copy: Layout[] = [];\r\n nodes.forEach((n, i) => {\r\n n._id = n._id || GridStackEngine._idSeq++; // make sure we have an id in case this is new layout, else re-use id already set\r\n copy[i] = {x: n.x, y: n.y, w: n.w, _id: n._id} // only thing we change is x,y,w and id to find it back\r\n });\r\n this._layouts = clear ? [] : this._layouts || []; // use array to find larger quick\r\n this._layouts[column] = copy;\r\n return this;\r\n }\r\n\r\n /**\r\n * call to cache the given node layout internally to the given location so we can restore back when column changes size\r\n * @param node single node to cache\r\n * @param column corresponding column index to save it under\r\n */\r\n public cacheOneLayout(n: GridStackNode, column: number): GridStackEngine {\r\n n._id = n._id || GridStackEngine._idSeq++;\r\n let layout: Layout = {x: n.x, y: n.y, w: n.w, _id: n._id}\r\n this._layouts = this._layouts || [];\r\n this._layouts[column] = this._layouts[column] || [];\r\n let index = this._layouts[column].findIndex(l => l._id === n._id);\r\n index === -1 ? this._layouts[column].push(layout) : this._layouts[column][index] = layout;\r\n return this;\r\n }\r\n\r\n\r\n /** called to remove all internal values but the _id */\r\n public cleanupNode(node: GridStackNode): GridStackEngine {\r\n for (let prop in node) {\r\n if (prop[0] === '_' && prop !== '_id') delete node[prop];\r\n }\r\n return this;\r\n }\r\n}\r\n\r\n/** @internal class to store per column layout bare minimal info (subset of GridStackWidget) */\r\ninterface Layout {\r\n x: number;\r\n y: number;\r\n w: number;\r\n _id: number; // so we can find full node back\r\n}\r\n"]} \ No newline at end of file +{"version":3,"file":"gridstack-engine.js","sourceRoot":"","sources":["../src/gridstack-engine.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,mCAAgC;AAahC;;;;;GAKG;AACH,MAAa,eAAe;IAqB1B,YAAmB,OAA+B,EAAE;QAhB7C,eAAU,GAAoB,EAAE,CAAC;QACjC,iBAAY,GAAoB,EAAE,CAAC;QAgBxC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;QAChC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;IAChC,CAAC;IAEM,WAAW;QAChB,IAAI,IAAI,CAAC,SAAS;YAAE,OAAO,IAAI,CAAC;QAChC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,kFAAkF;QACtG,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,oEAAoE;QACxF,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,MAAM;QACX,IAAI,CAAC,IAAI,CAAC,SAAS;YAAE,OAAO,IAAI,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,KAAK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;YACrB,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,IAAI,KAAK,KAAK;gBAAE,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC;SAC1D;QACD,OAAO,IAAI,CAAC;IACd,CAAC;;AAn0BH,0CAo0BC;AAlzBC,qEAAqE;AACtD,sBAAM,GAAG,CAAC,CAAC","sourcesContent":["/**\r\n * gridstack-engine.ts 4.2.6\r\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\r\n */\r\n\r\nimport { Utils } from './utils';\r\nimport { GridStackNode, ColumnOptions, GridStackPosition, GridStackMoveOpts } from './types';\r\n\r\nexport type onChangeCB = (nodes: GridStackNode[], removeDOM?: boolean) => void;\r\n/** options used for creations - similar to GridStackOptions */\r\nexport interface GridStackEngineOptions {\r\n column?: number;\r\n maxRow?: number;\r\n float?: boolean;\r\n nodes?: GridStackNode[];\r\n onChange?: onChangeCB;\r\n}\r\n\r\n/**\r\n * Defines the GridStack engine that does most no DOM grid manipulation.\r\n * See GridStack methods and vars for descriptions.\r\n *\r\n * NOTE: values should not be modified directly - call the main GridStack API instead\r\n */\r\nexport class GridStackEngine {\r\n public column: number;\r\n public maxRow: number;\r\n public nodes: GridStackNode[];\r\n public onChange: onChangeCB;\r\n public addedNodes: GridStackNode[] = [];\r\n public removedNodes: GridStackNode[] = [];\r\n public batchMode: boolean;\r\n /** @internal */\r\n private _float: boolean;\r\n /** @internal */\r\n private _prevFloat: boolean;\r\n /** @internal */\r\n private _layouts?: Layout[][]; // maps column # to array of values nodes\r\n /** @internal */\r\n private _ignoreLayoutsNodeChange: boolean;\r\n /** @internal true if we have some items locked */\r\n private _hasLocked: boolean;\r\n /** @internal unique global internal _id counter NOT starting at 0 */\r\n private static _idSeq = 1;\r\n\r\n public constructor(opts: GridStackEngineOptions = {}) {\r\n this.column = opts.column || 12;\r\n this.onChange = opts.onChange;\r\n this._float = opts.float;\r\n this.maxRow = opts.maxRow;\r\n this.nodes = opts.nodes || [];\r\n }\r\n\r\n public batchUpdate(): GridStackEngine {\r\n if (this.batchMode) return this;\r\n this.batchMode = true;\r\n this._prevFloat = this._float;\r\n this._float = true; // let things go anywhere for now... commit() will restore and possibly reposition\r\n this.saveInitial(); // since begin update (which is called multiple times) won't do this\r\n return this;\r\n }\r\n\r\n public commit(): GridStackEngine {\r\n if (!this.batchMode) return this;\r\n this.batchMode = false;\r\n this._float = this._prevFloat;\r\n delete this._prevFloat;\r\n return this._packNodes()\r\n ._notify();\r\n }\r\n\r\n // use entire row for hitting area (will use bottom reverse sorted first) if we not actively moving DOWN and didn't already skip\r\n private _useEntireRowArea(node: GridStackNode, nn: GridStackPosition): boolean {\r\n return !this.float && !this._hasLocked && (!node._moving || node._skipDown || nn.y <= node.y);\r\n }\r\n\r\n /** @internal fix collision on given 'node', going to given new location 'nn', with optional 'collide' node already found.\r\n * return true if we moved. */\r\n private _fixCollisions(node: GridStackNode, nn = node, collide?: GridStackNode, opt: GridStackMoveOpts = {}): boolean {\r\n this._sortNodes(-1); // from last to first, so recursive collision move items in the right order\r\n\r\n collide = collide || this.collide(node, nn); // REAL area collide for swap and skip if none...\r\n if (!collide) return false;\r\n\r\n // swap check: if we're actively moving in gravity mode, see if we collide with an object the same size\r\n if (node._moving && !opt.nested && !this.float) {\r\n if (this.swap(node, collide)) return true;\r\n }\r\n\r\n // during while() collisions MAKE SURE to check entire row so larger items don't leap frog small ones (push them all down starting last in grid)\r\n let area = nn;\r\n if (this._useEntireRowArea(node, nn)) {\r\n area = {x: 0, w: this.column, y: nn.y, h: nn.h};\r\n collide = this.collide(node, area, opt.skip); // force new hit\r\n }\r\n\r\n let didMove = false;\r\n let newOpt: GridStackMoveOpts = {nested: true, pack: false};\r\n while (collide = collide || this.collide(node, area, opt.skip)) { // could collide with more than 1 item... so repeat for each\r\n let moved: boolean;\r\n // if colliding with a locked item OR moving down with top gravity (and collide could move up) -> skip past the collide,\r\n // but remember that skip down so we only do this once (and push others otherwise).\r\n if (collide.locked || node._moving && !node._skipDown && nn.y > node.y && !this.float &&\r\n // can take space we had, or before where we're going\r\n (!this.collide(collide, {...collide, y: node.y}, node) || !this.collide(collide, {...collide, y: nn.y - collide.h}, node))) {\r\n node._skipDown = (node._skipDown || nn.y > node.y);\r\n moved = this.moveNode(node, {...nn, y: collide.y + collide.h, ...newOpt});\r\n if (collide.locked && moved) {\r\n Utils.copyPos(nn, node); // moving after lock become our new desired location\r\n } else if (!collide.locked && moved && opt.pack) {\r\n // we moved after and will pack: do it now and keep the original drop location, but past the old collide to see what else we might push way\r\n this._packNodes();\r\n nn.y = collide.y + collide.h;\r\n Utils.copyPos(node, nn);\r\n }\r\n didMove = didMove || moved;\r\n } else {\r\n // move collide down *after* where we will be, ignoring where we are now (don't collide with us)\r\n moved = this.moveNode(collide, {...collide, y: nn.y + nn.h, skip: node, ...newOpt});\r\n }\r\n if (!moved) { return didMove; } // break inf loop if we couldn't move after all (ex: maxRow, fixed)\r\n collide = undefined;\r\n }\r\n return didMove;\r\n }\r\n\r\n /** return the nodes that intercept the given node. Optionally a different area can be used, as well as a second node to skip */\r\n public collide(skip: GridStackNode, area = skip, skip2?: GridStackNode): GridStackNode {\r\n return this.nodes.find(n => n !== skip && n !== skip2 && Utils.isIntercepted(n, area));\r\n }\r\n public collideAll(skip: GridStackNode, area = skip, skip2?: GridStackNode): GridStackNode[] {\r\n return this.nodes.filter(n => n !== skip && n !== skip2 && Utils.isIntercepted(n, area));\r\n }\r\n\r\n /** does a pixel coverage collision, returning the node that has the most coverage that is >50% mid line */\r\n public collideCoverage(node: GridStackNode, o: GridStackMoveOpts, collides: GridStackNode[]): GridStackNode {\r\n if (!o.rect || !node._rect) return;\r\n let r0 = node._rect; // where started\r\n let r = {...o.rect}; // where we are\r\n\r\n // update dragged rect to show where it's coming from (above or below, etc...)\r\n if (r.y > r0.y) {\r\n r.h += r.y - r0.y;\r\n r.y = r0.y;\r\n } else {\r\n r.h += r0.y - r.y;\r\n }\r\n if (r.x > r0.x) {\r\n r.w += r.x - r0.x;\r\n r.x = r0.x;\r\n } else {\r\n r.w += r0.x - r.x;\r\n }\r\n\r\n let collide: GridStackNode;\r\n collides.forEach(n => {\r\n if (n.locked || !n._rect) return;\r\n let r2 = n._rect; // overlapping target\r\n let yOver = Number.MAX_VALUE, xOver = Number.MAX_VALUE, overMax = 0.5; // need >50%\r\n // depending on which side we started from, compute the overlap % of coverage\r\n // (ex: from above/below we only compute the max horizontal line coverage)\r\n if (r0.y < r2.y) { // from above\r\n yOver = ((r.y + r.h) - r2.y) / r2.h;\r\n } else if (r0.y+r0.h > r2.y+r2.h) { // from below\r\n yOver = ((r2.y + r2.h) - r.y) / r2.h;\r\n }\r\n if (r0.x < r2.x) { // from the left\r\n xOver = ((r.x + r.w) - r2.x) / r2.w;\r\n } else if (r0.x+r0.w > r2.x+r2.w) { // from the right\r\n xOver = ((r2.x + r2.w) - r.x) / r2.w;\r\n }\r\n let over = Math.min(xOver, yOver);\r\n if (over > overMax) {\r\n overMax = over;\r\n collide = n;\r\n }\r\n });\r\n return collide;\r\n }\r\n\r\n /** called to cache the nodes pixel rectangles used for collision detection during drag */\r\n public cacheRects(w: number, h: number, top: number, right: number, bottom: number, left: number): GridStackEngine\r\n {\r\n this.nodes.forEach(n =>\r\n n._rect = {\r\n y: n.y * h + top,\r\n x: n.x * w + left,\r\n w: n.w * w - left - right,\r\n h: n.h * h - top - bottom\r\n }\r\n );\r\n return this;\r\n }\r\n\r\n /** called to possibly swap between 2 nodes (same size or column, not locked, touching), returning true if successful */\r\n public swap(a: GridStackNode, b: GridStackNode): boolean {\r\n if (!b || b.locked || !a || a.locked) return false;\r\n\r\n function _doSwap(): true { // assumes a is before b IFF they have different height (put after rather than exact swap)\r\n let x = b.x, y = b.y;\r\n b.x = a.x; b.y = a.y; // b -> a position\r\n if (a.h != b.h) {\r\n a.x = x; a.y = b.y + b.h; // a -> goes after b\r\n } else {\r\n a.x = x; a.y = y; // a -> old b position\r\n }\r\n a._dirty = b._dirty = true;\r\n return true;\r\n }\r\n let touching: boolean; // remember if we called it (vs undefined)\r\n\r\n // same size and same row or column, and touching\r\n if (a.w === b.w && a.h === b.h && (a.x === b.x || a.y === b.y) && (touching = Utils.isTouching(a, b)))\r\n return _doSwap();\r\n if (touching === false) return; // ran test and fail, bail out\r\n\r\n // check for taking same columns (but different height) and touching\r\n if (a.w === b.w && a.x === b.x && (touching || Utils.isTouching(a, b))) {\r\n if (b.y < a.y) { let t = a; a = b; b = t; } // swap a <-> b vars so a is first\r\n return _doSwap();\r\n }\r\n\r\n /* different X will be weird (expect vertical swap) and different height overlap, so too complex. user regular layout instead\r\n // else check if swapping would not collide with anything else (requiring a re-layout)\r\n if (!this.collide(a, {x: a.x, y: a.y, w: b.w, h: b.h}, b) &&\r\n !this.collide(a, {x: b.x, y: b.y, w: a.w, h: a.h}, b))\r\n return _doSwap(); */\r\n return false;\r\n }\r\n\r\n public isAreaEmpty(x: number, y: number, w: number, h: number): boolean {\r\n let nn: GridStackNode = {x: x || 0, y: y || 0, w: w || 1, h: h || 1};\r\n return !this.collide(nn);\r\n }\r\n\r\n /** re-layout grid items to reclaim any empty space */\r\n public compact(): GridStackEngine {\r\n if (this.nodes.length === 0) return this;\r\n this.batchUpdate()\r\n ._sortNodes();\r\n let copyNodes = this.nodes;\r\n this.nodes = []; // pretend we have no nodes to conflict layout to start with...\r\n copyNodes.forEach(node => {\r\n if (!node.locked) {\r\n node.autoPosition = true;\r\n }\r\n this.addNode(node, false); // 'false' for add event trigger\r\n node._dirty = true; // will force attr update\r\n });\r\n return this.commit();\r\n }\r\n\r\n /** enable/disable floating widgets (default: `false`) See [example](http://gridstackjs.com/demo/float.html) */\r\n public set float(val: boolean) {\r\n if (this._float === val) return;\r\n this._float = val || false;\r\n if (!val) {\r\n this._packNodes()._notify();\r\n }\r\n }\r\n\r\n /** float getter method */\r\n public get float(): boolean { return this._float || false; }\r\n\r\n /** @internal */\r\n private _sortNodes(dir?: -1 | 1): GridStackEngine {\r\n this.nodes = Utils.sort(this.nodes, dir, this.column);\r\n return this;\r\n }\r\n\r\n /** @internal called to top gravity pack the items back OR revert back to original Y positions when floating */\r\n private _packNodes(): GridStackEngine {\r\n this._sortNodes(); // first to last\r\n\r\n if (this.float) {\r\n // restore original Y pos\r\n this.nodes.forEach(n => {\r\n if (n._updating || n._orig === undefined || n.y === n._orig.y) return;\r\n let newY = n.y;\r\n while (newY > n._orig.y) {\r\n --newY;\r\n let collide = this.collide(n, {x: n.x, y: newY, w: n.w, h: n.h});\r\n if (!collide) {\r\n n._dirty = true;\r\n n.y = newY;\r\n }\r\n }\r\n });\r\n } else {\r\n // top gravity pack\r\n this.nodes.forEach((n, i) => {\r\n if (n.locked) return;\r\n while (n.y > 0) {\r\n let newY = i === 0 ? 0 : n.y - 1;\r\n let canBeMoved = i === 0 || !this.collide(n, {x: n.x, y: newY, w: n.w, h: n.h});\r\n if (!canBeMoved) break;\r\n // Note: must be dirty (from last position) for GridStack::OnChange CB to update positions\r\n // and move items back. The user 'change' CB should detect changes from the original\r\n // starting position instead.\r\n n._dirty = (n.y !== newY);\r\n n.y = newY;\r\n }\r\n });\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * given a random node, makes sure it's coordinates/values are valid in the current grid\r\n * @param node to adjust\r\n * @param resizing if out of bound, resize down or move into the grid to fit ?\r\n */\r\n public prepareNode(node: GridStackNode, resizing?: boolean): GridStackNode {\r\n node = node || {};\r\n node._id = node._id || GridStackEngine._idSeq++;\r\n\r\n // if we're missing position, have the grid position us automatically (before we set them to 0,0)\r\n if (node.x === undefined || node.y === undefined || node.x === null || node.y === null) {\r\n node.autoPosition = true;\r\n }\r\n\r\n // assign defaults for missing required fields\r\n let defaults: GridStackNode = { x: 0, y: 0, w: 1, h: 1};\r\n Utils.defaults(node, defaults);\r\n\r\n if (!node.autoPosition) { delete node.autoPosition; }\r\n if (!node.noResize) { delete node.noResize; }\r\n if (!node.noMove) { delete node.noMove; }\r\n\r\n // check for NaN (in case messed up strings were passed. can't do parseInt() || defaults.x above as 0 is valid #)\r\n if (typeof node.x == 'string') { node.x = Number(node.x); }\r\n if (typeof node.y == 'string') { node.y = Number(node.y); }\r\n if (typeof node.w == 'string') { node.w = Number(node.w); }\r\n if (typeof node.h == 'string') { node.h = Number(node.h); }\r\n if (isNaN(node.x)) { node.x = defaults.x; node.autoPosition = true; }\r\n if (isNaN(node.y)) { node.y = defaults.y; node.autoPosition = true; }\r\n if (isNaN(node.w)) { node.w = defaults.w; }\r\n if (isNaN(node.h)) { node.h = defaults.h; }\r\n\r\n return this.nodeBoundFix(node, resizing);\r\n }\r\n\r\n /** part2 of preparing a node to fit inside our grid - checks for x,y from grid dimensions */\r\n public nodeBoundFix(node: GridStackNode, resizing?: boolean): GridStackNode {\r\n\r\n if (node.maxW) { node.w = Math.min(node.w, node.maxW); }\r\n if (node.maxH) { node.h = Math.min(node.h, node.maxH); }\r\n if (node.minW) { node.w = Math.max(node.w, node.minW); }\r\n if (node.minH) { node.h = Math.max(node.h, node.minH); }\r\n\r\n if (node.w > this.column) {\r\n // if user loaded a larger than allowed widget for current # of columns,\r\n // remember it's full width so we can restore back (1 -> 12 column) #1655\r\n if (this.column < 12) {\r\n node.w = Math.min(12, node.w);\r\n this.cacheOneLayout(node, 12);\r\n }\r\n node.w = this.column;\r\n } else if (node.w < 1) {\r\n node.w = 1;\r\n }\r\n\r\n if (this.maxRow && node.h > this.maxRow) {\r\n node.h = this.maxRow;\r\n } else if (node.h < 1) {\r\n node.h = 1;\r\n }\r\n\r\n if (node.x < 0) {\r\n node.x = 0;\r\n }\r\n if (node.y < 0) {\r\n node.y = 0;\r\n }\r\n\r\n if (node.x + node.w > this.column) {\r\n if (resizing) {\r\n node.w = this.column - node.x;\r\n } else {\r\n node.x = this.column - node.w;\r\n }\r\n }\r\n if (this.maxRow && node.y + node.h > this.maxRow) {\r\n if (resizing) {\r\n node.h = this.maxRow - node.y;\r\n } else {\r\n node.y = this.maxRow - node.h;\r\n }\r\n }\r\n\r\n return node;\r\n }\r\n\r\n public getDirtyNodes(verify?: boolean): GridStackNode[] {\r\n // compare original x,y,w,h instead as _dirty can be a temporary state\r\n if (verify) {\r\n return this.nodes.filter(n => n._dirty && !Utils.samePos(n, n._orig));\r\n }\r\n return this.nodes.filter(n => n._dirty);\r\n }\r\n\r\n /** @internal call this to call onChange CB with dirty nodes */\r\n private _notify(nodes?: GridStackNode | GridStackNode[], removeDOM = true): GridStackEngine {\r\n if (this.batchMode) return this;\r\n nodes = (nodes === undefined ? [] : (Array.isArray(nodes) ? nodes : [nodes]) );\r\n let dirtyNodes = nodes.concat(this.getDirtyNodes());\r\n this.onChange && this.onChange(dirtyNodes, removeDOM);\r\n return this;\r\n }\r\n\r\n /** @internal remove dirty and last tried info */\r\n public cleanNodes(): GridStackEngine {\r\n if (this.batchMode) return this;\r\n this.nodes.forEach(n => {\r\n delete n._dirty;\r\n delete n._lastTried;\r\n });\r\n return this;\r\n }\r\n\r\n /** @internal called to save initial position/size to track real dirty state.\r\n * Note: should be called right after we call change event (so next API is can detect changes)\r\n * as well as right before we start move/resize/enter (so we can restore items to prev values) */\r\n public saveInitial(): GridStackEngine {\r\n this.nodes.forEach(n => {\r\n n._orig = Utils.copyPos({}, n);\r\n delete n._dirty;\r\n });\r\n this._hasLocked = this.nodes.some(n => n.locked);\r\n return this;\r\n }\r\n\r\n /** @internal restore all the nodes back to initial values (called when we leave) */\r\n public restoreInitial(): GridStackEngine {\r\n this.nodes.forEach(n => {\r\n if (Utils.samePos(n, n._orig)) return;\r\n Utils.copyPos(n, n._orig);\r\n n._dirty = true;\r\n });\r\n this._notify();\r\n return this;\r\n }\r\n\r\n /** call to add the given node to our list, fixing collision and re-packing */\r\n public addNode(node: GridStackNode, triggerAddEvent = false): GridStackNode {\r\n let dup: GridStackNode;\r\n if (dup = this.nodes.find(n => n._id === node._id)) return dup; // prevent inserting twice! return it instead.\r\n\r\n node = this.prepareNode(node);\r\n delete node._temporaryRemoved;\r\n delete node._removeDOM;\r\n\r\n if (node.autoPosition) {\r\n this._sortNodes();\r\n\r\n for (let i = 0;; ++i) {\r\n let x = i % this.column;\r\n let y = Math.floor(i / this.column);\r\n if (x + node.w > this.column) {\r\n continue;\r\n }\r\n let box = {x, y, w: node.w, h: node.h};\r\n if (!this.nodes.find(n => Utils.isIntercepted(box, n))) {\r\n node.x = x;\r\n node.y = y;\r\n delete node.autoPosition; // found our slot\r\n break;\r\n }\r\n }\r\n }\r\n\r\n this.nodes.push(node);\r\n triggerAddEvent && this.addedNodes.push(node);\r\n\r\n this._fixCollisions(node);\r\n this._packNodes()\r\n ._notify();\r\n return node;\r\n }\r\n\r\n public removeNode(node: GridStackNode, removeDOM = true, triggerEvent = false): GridStackEngine {\r\n if (!this.nodes.find(n => n === node)) {\r\n // TEST console.log(`Error: GridStackEngine.removeNode() node._id=${node._id} not found!`)\r\n return this;\r\n }\r\n if (triggerEvent) { // we wait until final drop to manually track removed items (rather than during drag)\r\n this.removedNodes.push(node);\r\n }\r\n if (removeDOM) node._removeDOM = true; // let CB remove actual HTML (used to set _id to null, but then we loose layout info)\r\n // don't use 'faster' .splice(findIndex(),1) in case node isn't in our list, or in multiple times.\r\n this.nodes = this.nodes.filter(n => n !== node);\r\n return this._packNodes()\r\n ._notify(node);\r\n }\r\n\r\n public removeAll(removeDOM = true): GridStackEngine {\r\n delete this._layouts;\r\n if (this.nodes.length === 0) return this;\r\n removeDOM && this.nodes.forEach(n => n._removeDOM = true); // let CB remove actual HTML (used to set _id to null, but then we loose layout info)\r\n this.removedNodes = this.nodes;\r\n this.nodes = [];\r\n return this._notify(this.removedNodes);\r\n }\r\n\r\n /** checks if item can be moved (layout constrain) vs moveNode(), returning true if was able to move.\r\n * In more complicated cases (maxRow) it will attempt at moving the item and fixing\r\n * others in a clone first, then apply those changes if still within specs. */\r\n public moveNodeCheck(node: GridStackNode, o: GridStackMoveOpts): boolean {\r\n // if (node.locked) return false;\r\n if (!this.changedPosConstrain(node, o)) return false;\r\n o.pack = true;\r\n\r\n // simpler case: move item directly...\r\n if (!this.maxRow/* && !this._hasLocked*/) {\r\n return this.moveNode(node, o);\r\n }\r\n\r\n // complex case: create a clone with NO maxRow (will check for out of bounds at the end)\r\n let clonedNode: GridStackNode;\r\n let clone = new GridStackEngine({\r\n column: this.column,\r\n float: this.float,\r\n nodes: this.nodes.map(n => {\r\n if (n === node) {\r\n clonedNode = {...n};\r\n return clonedNode;\r\n }\r\n return {...n};\r\n })\r\n });\r\n if (!clonedNode) return false;\r\n\r\n let canMove = clone.moveNode(clonedNode, o);\r\n // if maxRow make sure we are still valid size\r\n if (this.maxRow && canMove) {\r\n canMove = (clone.getRow() <= this.maxRow);\r\n // turns out we can't grow, then see if we can swap instead (ex: full grid)\r\n if (!canMove) {\r\n let collide = this.collide(node, o);\r\n if (collide && this.swap(node, collide)) {\r\n this._notify();\r\n return true;\r\n }\r\n }\r\n }\r\n if (!canMove) return false;\r\n\r\n // if clone was able to move, copy those mods over to us now instead of caller trying to do this all over!\r\n // Note: we can't use the list directly as elements and other parts point to actual node, so copy content\r\n clone.nodes.filter(n => n._dirty).forEach(c => {\r\n let n = this.nodes.find(a => a._id === c._id);\r\n if (!n) return;\r\n Utils.copyPos(n, c);\r\n n._dirty = true;\r\n });\r\n this._notify();\r\n return true;\r\n }\r\n\r\n /** return true if can fit in grid height constrain only (always true if no maxRow) */\r\n public willItFit(node: GridStackNode): boolean {\r\n delete node._willFitPos;\r\n if (!this.maxRow) return true;\r\n // create a clone with NO maxRow and check if still within size\r\n let clone = new GridStackEngine({\r\n column: this.column,\r\n float: this.float,\r\n nodes: this.nodes.map(n => {return {...n}})\r\n });\r\n let n = {...node}; // clone node so we don't mod any settings on it but have full autoPosition and min/max as well! #1687\r\n this.cleanupNode(n);\r\n delete n.el; delete n._id; delete n.content; delete n.grid;\r\n clone.addNode(n);\r\n if (clone.getRow() <= this.maxRow) {\r\n node._willFitPos = Utils.copyPos({}, n);\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /** true if x,y or w,h are different after clamping to min/max */\r\n public changedPosConstrain(node: GridStackNode, p: GridStackPosition): boolean {\r\n // make sure w,h are set\r\n p.w = p.w || node.w;\r\n p.h = p.h || node.h;\r\n if (node.x !== p.x || node.y !== p.y) return true;\r\n // check constrained w,h\r\n if (node.maxW) { p.w = Math.min(p.w, node.maxW); }\r\n if (node.maxH) { p.h = Math.min(p.h, node.maxH); }\r\n if (node.minW) { p.w = Math.max(p.w, node.minW); }\r\n if (node.minH) { p.h = Math.max(p.h, node.minH); }\r\n return (node.w !== p.w || node.h !== p.h);\r\n }\r\n\r\n /** return true if the passed in node was actually moved (checks for no-op and locked) */\r\n public moveNode(node: GridStackNode, o: GridStackMoveOpts): boolean {\r\n if (!node || /*node.locked ||*/ !o) return false;\r\n if (o.pack === undefined) o.pack = true;\r\n\r\n // constrain the passed in values and check if we're still changing our node\r\n if (typeof o.x !== 'number') { o.x = node.x; }\r\n if (typeof o.y !== 'number') { o.y = node.y; }\r\n if (typeof o.w !== 'number') { o.w = node.w; }\r\n if (typeof o.h !== 'number') { o.h = node.h; }\r\n let resizing = (node.w !== o.w || node.h !== o.h);\r\n let nn: GridStackNode = Utils.copyPos({}, node, true); // get min/max out first, then opt positions next\r\n Utils.copyPos(nn, o);\r\n nn = this.nodeBoundFix(nn, resizing);\r\n Utils.copyPos(o, nn);\r\n\r\n if (Utils.samePos(node, o)) return false;\r\n let prevPos: GridStackPosition = Utils.copyPos({}, node);\r\n\r\n // during while() collisions make sure to check entire row so larger items don't leap frog small ones (push them all down)\r\n let area = nn;\r\n // if (this._useEntireRowArea(node, nn)) {\r\n // area = {x: 0, w: this.column, y: nn.y, h: nn.h};\r\n // }\r\n\r\n // check if we will need to fix collision at our new location\r\n let collides = this.collideAll(node, area, o.skip);\r\n let needToMove = true;\r\n if (collides.length) {\r\n // now check to make sure we actually collided over 50% surface area while dragging\r\n let collide = node._moving && !o.nested ? this.collideCoverage(node, o, collides) : collides[0];\r\n if (collide) {\r\n needToMove = !this._fixCollisions(node, nn, collide, o); // check if already moved...\r\n } else {\r\n needToMove = false; // we didn't cover >50% for a move, skip...\r\n }\r\n }\r\n\r\n // now move (to the original ask vs the collision version which might differ) and repack things\r\n if (needToMove) {\r\n node._dirty = true;\r\n Utils.copyPos(node, nn);\r\n }\r\n if (o.pack) {\r\n this._packNodes()\r\n ._notify();\r\n }\r\n return !Utils.samePos(node, prevPos); // pack might have moved things back\r\n }\r\n\r\n public getRow(): number {\r\n return this.nodes.reduce((row, n) => Math.max(row, n.y + n.h), 0);\r\n }\r\n\r\n public beginUpdate(node: GridStackNode): GridStackEngine {\r\n if (!node._updating) {\r\n node._updating = true;\r\n delete node._skipDown;\r\n if (!this.batchMode) this.saveInitial();\r\n }\r\n return this;\r\n }\r\n\r\n public endUpdate(): GridStackEngine {\r\n let n = this.nodes.find(n => n._updating);\r\n if (n) {\r\n delete n._updating;\r\n delete n._skipDown;\r\n }\r\n return this;\r\n }\r\n\r\n /** saves a copy of the current layout returning a list of widgets for serialization */\r\n public save(saveElement = true): GridStackNode[] {\r\n let list: GridStackNode[] = [];\r\n this._sortNodes();\r\n this.nodes.forEach(n => {\r\n let w: GridStackNode = {};\r\n for (let key in n) { if (key[0] !== '_' && n[key] !== null && n[key] !== undefined ) w[key] = n[key]; }\r\n // delete other internals\r\n delete w.grid;\r\n if (!saveElement) delete w.el;\r\n // delete default values (will be re-created on read)\r\n if (!w.autoPosition) delete w.autoPosition;\r\n if (!w.noResize) delete w.noResize;\r\n if (!w.noMove) delete w.noMove;\r\n if (!w.locked) delete w.locked;\r\n list.push(w);\r\n });\r\n return list;\r\n }\r\n\r\n /** @internal called whenever a node is added or moved - updates the cached layouts */\r\n public layoutsNodesChange(nodes: GridStackNode[]): GridStackEngine {\r\n if (!this._layouts || this._ignoreLayoutsNodeChange) return this;\r\n // remove smaller layouts - we will re-generate those on the fly... larger ones need to update\r\n this._layouts.forEach((layout, column) => {\r\n if (!layout || column === this.column) return this;\r\n if (column < this.column) {\r\n this._layouts[column] = undefined;\r\n }\r\n else {\r\n // we save the original x,y,w (h isn't cached) to see what actually changed to propagate better.\r\n // Note: we don't need to check against out of bound scaling/moving as that will be done when using those cache values.\r\n nodes.forEach(node => {\r\n if (!node._orig) return; // didn't change (newly added ?)\r\n let n = layout.find(l => l._id === node._id);\r\n if (!n) return; // no cache for new nodes. Will use those values.\r\n let ratio = column / this.column;\r\n // Y changed, push down same amount\r\n // TODO: detect doing item 'swaps' will help instead of move (especially in 1 column mode)\r\n if (node.y !== node._orig.y) {\r\n n.y += (node.y - node._orig.y);\r\n }\r\n // X changed, scale from new position\r\n if (node.x !== node._orig.x) {\r\n n.x = Math.round(node.x * ratio);\r\n }\r\n // width changed, scale from new width\r\n if (node.w !== node._orig.w) {\r\n n.w = Math.round(node.w * ratio);\r\n }\r\n // ...height always carries over from cache\r\n });\r\n }\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * @internal Called to scale the widget width & position up/down based on the column change.\r\n * Note we store previous layouts (especially original ones) to make it possible to go\r\n * from say 12 -> 1 -> 12 and get back to where we were.\r\n *\r\n * @param oldColumn previous number of columns\r\n * @param column new column number\r\n * @param nodes different sorted list (ex: DOM order) instead of current list\r\n * @param layout specify the type of re-layout that will happen (position, size, etc...).\r\n * Note: items will never be outside of the current column boundaries. default (moveScale). Ignored for 1 column\r\n */\r\n public updateNodeWidths(oldColumn: number, column: number, nodes: GridStackNode[], layout: ColumnOptions = 'moveScale'): GridStackEngine {\r\n if (!this.nodes.length || oldColumn === column) return this;\r\n\r\n // cache the current layout in case they want to go back (like 12 -> 1 -> 12) as it requires original data\r\n this.cacheLayout(this.nodes, oldColumn);\r\n\r\n // if we're going to 1 column and using DOM order rather than default sorting, then generate that layout\r\n if (column === 1 && nodes && nodes.length) {\r\n let top = 0;\r\n nodes.forEach(n => {\r\n n.x = 0;\r\n n.w = 1;\r\n n.y = Math.max(n.y, top);\r\n top = n.y + n.h;\r\n });\r\n } else {\r\n nodes = Utils.sort(this.nodes, -1, oldColumn); // current column reverse sorting so we can insert last to front (limit collision)\r\n }\r\n\r\n // see if we have cached previous layout.\r\n let cacheNodes = this._layouts[column] || [];\r\n // if not AND we are going up in size start with the largest layout as down-scaling is more accurate\r\n let lastIndex = this._layouts.length - 1;\r\n if (cacheNodes.length === 0 && column > oldColumn && column < lastIndex) {\r\n cacheNodes = this._layouts[lastIndex] || [];\r\n if (cacheNodes.length) {\r\n // pretend we came from that larger column by assigning those values as starting point\r\n oldColumn = lastIndex;\r\n cacheNodes.forEach(cacheNode => {\r\n let j = nodes.findIndex(n => n._id === cacheNode._id);\r\n if (j !== -1) {\r\n // still current, use cache info positions\r\n nodes[j].x = cacheNode.x;\r\n nodes[j].y = cacheNode.y;\r\n nodes[j].w = cacheNode.w;\r\n }\r\n });\r\n cacheNodes = []; // we still don't have new column cached data... will generate from larger one.\r\n }\r\n }\r\n\r\n // if we found cache re-use those nodes that are still current\r\n let newNodes: GridStackNode[] = [];\r\n cacheNodes.forEach(cacheNode => {\r\n let j = nodes.findIndex(n => n._id === cacheNode._id);\r\n if (j !== -1) {\r\n // still current, use cache info positions\r\n nodes[j].x = cacheNode.x;\r\n nodes[j].y = cacheNode.y;\r\n nodes[j].w = cacheNode.w;\r\n newNodes.push(nodes[j]);\r\n nodes.splice(j, 1);\r\n }\r\n });\r\n // ...and add any extra non-cached ones\r\n if (nodes.length) {\r\n if (typeof layout === 'function') {\r\n layout(column, oldColumn, newNodes, nodes);\r\n } else {\r\n let ratio = column / oldColumn;\r\n let move = (layout === 'move' || layout === 'moveScale');\r\n let scale = (layout === 'scale' || layout === 'moveScale');\r\n nodes.forEach(node => {\r\n node.x = (column === 1 ? 0 : (move ? Math.round(node.x * ratio) : Math.min(node.x, column - 1)));\r\n node.w = ((column === 1 || oldColumn === 1) ? 1 :\r\n scale ? (Math.round(node.w * ratio) || 1) : (Math.min(node.w, column)));\r\n newNodes.push(node);\r\n });\r\n nodes = [];\r\n }\r\n }\r\n\r\n // finally re-layout them in reverse order (to get correct placement)\r\n newNodes = Utils.sort(newNodes, -1, column);\r\n this._ignoreLayoutsNodeChange = true;\r\n this.batchUpdate();\r\n this.nodes = []; // pretend we have no nodes to start with (we use same structures) to simplify layout\r\n newNodes.forEach(node => {\r\n this.addNode(node, false); // 'false' for add event trigger\r\n node._dirty = true; // force attr update\r\n }, this);\r\n this.commit();\r\n delete this._ignoreLayoutsNodeChange;\r\n return this;\r\n }\r\n\r\n /**\r\n * call to cache the given layout internally to the given location so we can restore back when column changes size\r\n * @param nodes list of nodes\r\n * @param column corresponding column index to save it under\r\n * @param clear if true, will force other caches to be removed (default false)\r\n */\r\n public cacheLayout(nodes: GridStackNode[], column: number, clear = false): GridStackEngine {\r\n let copy: Layout[] = [];\r\n nodes.forEach((n, i) => {\r\n n._id = n._id || GridStackEngine._idSeq++; // make sure we have an id in case this is new layout, else re-use id already set\r\n copy[i] = {x: n.x, y: n.y, w: n.w, _id: n._id} // only thing we change is x,y,w and id to find it back\r\n });\r\n this._layouts = clear ? [] : this._layouts || []; // use array to find larger quick\r\n this._layouts[column] = copy;\r\n return this;\r\n }\r\n\r\n /**\r\n * call to cache the given node layout internally to the given location so we can restore back when column changes size\r\n * @param node single node to cache\r\n * @param column corresponding column index to save it under\r\n */\r\n public cacheOneLayout(n: GridStackNode, column: number): GridStackEngine {\r\n n._id = n._id || GridStackEngine._idSeq++;\r\n let layout: Layout = {x: n.x, y: n.y, w: n.w, _id: n._id}\r\n this._layouts = this._layouts || [];\r\n this._layouts[column] = this._layouts[column] || [];\r\n let index = this._layouts[column].findIndex(l => l._id === n._id);\r\n index === -1 ? this._layouts[column].push(layout) : this._layouts[column][index] = layout;\r\n return this;\r\n }\r\n\r\n\r\n /** called to remove all internal values but the _id */\r\n public cleanupNode(node: GridStackNode): GridStackEngine {\r\n for (let prop in node) {\r\n if (prop[0] === '_' && prop !== '_id') delete node[prop];\r\n }\r\n return this;\r\n }\r\n}\r\n\r\n/** @internal class to store per column layout bare minimal info (subset of GridStackWidget) */\r\ninterface Layout {\r\n x: number;\r\n y: number;\r\n w: number;\r\n _id: number; // so we can find full node back\r\n}\r\n"]} \ No newline at end of file diff --git a/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-h5.d.ts b/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-h5.d.ts index d75f4e74..b9ee2772 100644 --- a/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-h5.d.ts +++ b/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-h5.d.ts @@ -1,5 +1,5 @@ /** - * index-h5.ts 4.2.5 - everything you need for a Grid that uses HTML5 native drag&drop + * index-h5.ts 4.2.6 - everything you need for a Grid that uses HTML5 native drag&drop * Copyright (c) 2021 Alain Dumesny - see GridStack root license */ export * from './types'; diff --git a/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-h5.js b/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-h5.js index 4ddcbab2..7eb98a91 100644 --- a/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-h5.js +++ b/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-h5.js @@ -1,3 +1,3 @@ /*! For license information please see gridstack-h5.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(()=>{"use strict";var t={21:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0});const s=i(334),o=i(270),r=i(593);class n extends s.GridStackDDI{static get(){return s.GridStackDDI.get()}remove(t){return this.draggable(t,"destroy").resizable(t,"destroy"),t.gridstackNode&&delete t.gridstackNode._initDD,this}}function l(t,e){let 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=n,o.GridStack.prototype._setupAcceptWidget=function(){if(this.opts.staticGrid||!this.opts.acceptWidgets)return n.get().droppable(this.el,"destroy"),this;let t,e,i,s=(s,o,l)=>{let a=o.gridstackNode;if(!a)return;let h=(l=l||o).getBoundingClientRect(),d=h.left-t.left,g=h.top-t.top,p={position:{top:g,left:d}};if(a._temporaryRemoved){if(a.x=Math.max(0,Math.round(d/i)),a.y=Math.max(0,Math.round(g/e)),delete a.autoPosition,this.engine.nodeBoundFix(a),!this.engine.willItFit(a)){if(a.autoPosition=!0,!this.engine.willItFit(a))return void n.get().off(o,"drag");a._willFitPos&&(r.Utils.copyPos(a,a._willFitPos),delete a._willFitPos)}this._onStartMoving(l,s,p,a,i,e)}else this._dragOrResize(l,s,p,a,i,e)};return n.get().droppable(this.el,{accept:t=>{let e=t.gridstackNode;if(e&&e.grid===this)return!0;if(!this.opts.acceptWidgets)return!1;let i=!0;if("function"==typeof this.opts.acceptWidgets)i=this.opts.acceptWidgets(t);else{let e=!0===this.opts.acceptWidgets?".grid-stack-item":this.opts.acceptWidgets;i=t.matches(e)}if(i&&e&&this.opts.maxRow){let t={w:e.w,h:e.h,minW:e.minW,minH:e.minH};i=this.engine.willItFit(t)}return i}}).on(this.el,"dropover",((o,r,a)=>{let h=r.gridstackNode;if(h&&h.grid===this&&!h._temporaryRemoved)return!1;h&&h.grid&&h.grid!==this&&!h._temporaryRemoved&&h.grid._leave(r,a);let d=this.el.getBoundingClientRect();t={top:d.top,left:d.left},i=this.cellWidth(),e=this.getCellHeight(!0),h||(h=this._readAttr(r)),h.grid||(h._isExternal=!0,r.gridstackNode=h),a=a||r;let g=h.w||Math.round(a.offsetWidth/i)||1,p=h.h||Math.round(a.offsetHeight/e)||1;return h.grid&&h.grid!==this?(r._gridstackNodeOrig||(r._gridstackNodeOrig=h),r.gridstackNode=h=Object.assign(Object.assign({},h),{w:g,h:p,grid:this}),this.engine.cleanupNode(h).nodeBoundFix(h),h._initDD=h._isExternal=h._temporaryRemoved=!0):(h.w=g,h.h=p,h._temporaryRemoved=!0),l(h.el,!1),n.get().on(r,"drag",s),s(o,r,a),!1})).on(this.el,"dropout",((t,e,i)=>{let s=e.gridstackNode;return s.grid&&s.grid!==this||this._leave(e,i),!1})).on(this.el,"drop",((t,e,i)=>{let s=e.gridstackNode;if(s&&s.grid===this&&!s._isExternal)return!1;let o=!!this.placeholder.parentElement;this.placeholder.remove();let l=e._gridstackNodeOrig;if(delete e._gridstackNodeOrig,o&&l&&l.grid&&l.grid!==this){let t=l.grid;t.engine.removedNodes.push(l),t._triggerRemoveEvent()}return!!s&&(o&&(this.engine.cleanupNode(s),s.grid=this),n.get().off(e,"drag"),i!==e?(i.remove(),e.gridstackNode=l,o&&(e=e.cloneNode(!0))):(e.remove(),n.get().remove(e)),!!o&&(e.gridstackNode=s,s.el=e,r.Utils.copyPos(s,this._readAttr(this.placeholder)),r.Utils.removePositioningStyles(e),this._writeAttr(e,s),this.el.appendChild(e),this._updateContainerHeight(),this.engine.addedNodes.push(s),this._triggerAddEvent(),this._triggerChangeEvent(),this.engine.endUpdate(),this._gsEventHandler.dropped&&this._gsEventHandler.dropped({type:"dropped"},l&&l.grid?l:void 0,s),window.setTimeout((()=>{s.el&&s.el.parentElement?this._prepareDragDropByNode(s):this.engine.removeNode(s)})),!1))})),this},o.GridStack.prototype._setupRemoveDrop=function(){if(!this.opts.staticGrid&&"string"==typeof this.opts.removable){let t=document.querySelector(this.opts.removable);if(!t)return this;n.get().isDroppable(t)||n.get().droppable(t,this.opts.removableOptions).on(t,"dropover",((t,e)=>l(e,!0))).on(t,"dropout",((t,e)=>l(e,!1)))}return this},o.GridStack.setupDragIn=function(t,e){let i,s;if(t&&(i=t,s=Object.assign(Object.assign({},{revert:"invalid",handle:".grid-stack-item-content",scroll:!1,appendTo:"body"}),e||{})),"string"!=typeof i)return;let o=n.get();r.Utils.getElements(i).forEach((t=>{o.isDraggable(t)||o.dragIn(t,s)}))},o.GridStack.prototype._prepareDragDropByNode=function(t){let e=t.el,i=n.get();if(this.opts.staticGrid||(t.noMove||this.opts.disableDrag)&&(t.noResize||this.opts.disableResize))return t._initDD&&(i.remove(e),delete t._initDD),e.classList.add("ui-draggable-disabled","ui-resizable-disabled"),this;if(!t._initDD){let s,o,n=(i,r)=>{this._gsEventHandler[i.type]&&this._gsEventHandler[i.type](i,i.target),s=this.cellWidth(),o=this.getCellHeight(!0),this._onStartMoving(e,i,r,t,s,o)},l=(i,r)=>{this._dragOrResize(e,i,r,t,s,o)},a=s=>{this.placeholder.remove(),delete t._moving,delete t._lastTried;let o=s.target;if(o.gridstackNode&&o.gridstackNode.grid===this){if(t.el=o,t._isAboutToRemove){let r=e.gridstackNode.grid;r._gsEventHandler[s.type]&&r._gsEventHandler[s.type](s,o),i.remove(e),r.engine.removedNodes.push(t),r._triggerRemoveEvent(),delete e.gridstackNode,delete t.el,e.remove()}else t._temporaryRemoved?(r.Utils.removePositioningStyles(o),r.Utils.copyPos(t,t._orig),this._writePosAttr(o,t),this.engine.addNode(t)):(r.Utils.removePositioningStyles(o),this._writePosAttr(o,t)),this._gsEventHandler[s.type]&&this._gsEventHandler[s.type](s,o);this._extraDragRow=0,this._updateContainerHeight(),this._triggerChangeEvent(),this.engine.endUpdate()}};i.draggable(e,{start:n,stop:a,drag:l}).resizable(e,{start:n,stop:a,resize:l}),t._initDD=!0}return t.noMove||this.opts.disableDrag?(i.draggable(e,"disable"),e.classList.add("ui-draggable-disabled")):(i.draggable(e,"enable"),e.classList.remove("ui-draggable-disabled")),t.noResize||this.opts.disableResize?(i.resizable(e,"disable"),e.classList.add("ui-resizable-disabled")):(i.resizable(e,"enable"),e.classList.remove("ui-resizable-disabled")),this},o.GridStack.prototype._onStartMoving=function(t,e,i,s,o,r){if(this.engine.cleanNodes().beginUpdate(s),this._writePosAttr(this.placeholder,s),this.el.appendChild(this.placeholder),s.el=this.placeholder,s._lastUiPosition=i.position,s._prevYPix=i.position.top,s._moving="dragstart"===e.type,delete s._lastTried,"dropover"===e.type&&s._temporaryRemoved&&(this.engine.addNode(s),s._moving=!0),this.engine.cacheRects(o,r,this.opts.marginTop,this.opts.marginRight,this.opts.marginBottom,this.opts.marginLeft),"resizestart"===e.type){let e=n.get().resizable(t,"option","minWidth",o*(s.minW||1)).resizable(t,"option","minHeight",r*(s.minH||1));s.maxW&&e.resizable(t,"option","maxWidth",o*s.maxW),s.maxH&&e.resizable(t,"option","maxHeight",r*s.maxH)}},o.GridStack.prototype._leave=function(t,e){let i=t.gridstackNode;i&&(n.get().off(t,"drag"),i._temporaryRemoved||(i._temporaryRemoved=!0,this.engine.removeNode(i),i.el=i._isExternal&&e?e:t,!0===this.opts.removable&&l(t,!0),t._gridstackNodeOrig?(t.gridstackNode=t._gridstackNodeOrig,delete t._gridstackNodeOrig):i._isExternal&&(delete i.el,delete t.gridstackNode,this.engine.restoreInitial())))},o.GridStack.prototype._dragOrResize=function(t,e,i,s,o,n){let l,a=Object.assign({},s._orig);if("drag"===e.type){if(s._temporaryRemoved)return;let e=i.position.top-s._prevYPix;s._prevYPix=i.position.top,r.Utils.updateScrollPosition(t,i.position,e);let l=i.position.left+(i.position.left>s._lastUiPosition.left?-this.opts.marginRight:this.opts.marginLeft),h=i.position.top+(i.position.top>s._lastUiPosition.top?-this.opts.marginBottom:this.opts.marginTop);a.x=Math.round(l/o),a.y=Math.round(h/n);let d=this._extraDragRow;if(this.engine.collide(s,a)){let t=this.getRow(),e=Math.max(0,a.y+s.h-t);this.opts.maxRow&&t+e>this.opts.maxRow&&(e=Math.max(0,this.opts.maxRow-t)),this._extraDragRow=e}else this._extraDragRow=0;if(this._extraDragRow!==d&&this._updateContainerHeight(),s.x===a.x&&s.y===a.y)return}else if("resize"===e.type){if(a.x<0)return;if(r.Utils.updateScrollResize(e,t,n),a.w=Math.round((i.size.width-this.opts.marginLeft)/o),a.h=Math.round((i.size.height-this.opts.marginTop)/n),s.w===a.w&&s.h===a.h)return;if(s._lastTried&&s._lastTried.w===a.w&&s._lastTried.h===a.h)return;let h=i.position.left+this.opts.marginLeft,d=i.position.top+this.opts.marginTop;a.x=Math.round(h/o),a.y=Math.round(d/n),l=!0}s._lastTried=a;let h={x:i.position.left+this.opts.marginLeft,y:i.position.top+this.opts.marginTop,w:(i.size?i.size.width:s.w*o)-this.opts.marginLeft-this.opts.marginRight,h:(i.size?i.size.height:s.h*n)-this.opts.marginTop-this.opts.marginBottom};if(this.engine.moveNodeCheck(s,Object.assign(Object.assign({},a),{cellWidth:o,cellHeight:n,rect:h}))){s._lastUiPosition=i.position,this.engine.cacheRects(o,n,this.opts.marginTop,this.opts.marginRight,this.opts.marginBottom,this.opts.marginLeft),delete s._skipDown,l&&s.subGrid&&s.subGrid.onParentResize(),this._extraDragRow=0,this._updateContainerHeight();let t=e.target;this._writePosAttr(t,s),this._gsEventHandler[e.type]&&this._gsEventHandler[e.type](e,t)}},o.GridStack.prototype.movable=function(t,e){return this.opts.staticGrid||o.GridStack.getElements(t).forEach((t=>{let i=t.gridstackNode;i&&(e?delete i.noMove:i.noMove=!0,this._prepareDragDropByNode(i))})),this},o.GridStack.prototype.resizable=function(t,e){return this.opts.staticGrid||o.GridStack.getElements(t).forEach((t=>{let i=t.gridstackNode;i&&(e?delete i.noResize:i.noResize=!0,this._prepareDragDropByNode(i))})),this},o.GridStack.prototype.disable=function(){if(!this.opts.staticGrid)return this.enableMove(!1),this.enableResize(!1),this._triggerEvent("disable"),this},o.GridStack.prototype.enable=function(){if(!this.opts.staticGrid)return this.enableMove(!0),this.enableResize(!0),this._triggerEvent("enable"),this},o.GridStack.prototype.enableMove=function(t){return this.opts.staticGrid||(this.opts.disableDrag=!t,this.engine.nodes.forEach((e=>this.movable(e.el,t)))),this},o.GridStack.prototype.enableResize=function(t){return this.opts.staticGrid||(this.opts.disableResize=!t,this.engine.nodes.forEach((e=>this.resizable(e.el,t)))),this}},334:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0});class i{static registerPlugin(t){return i.ddi=new t,i.ddi}static get(){return i.ddi||i.registerPlugin(i)}remove(t){return this}}e.GridStackDDI=i},62:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0});const s=i(593);class o{constructor(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||[]}batchUpdate(){return this.batchMode||(this.batchMode=!0,this._prevFloat=this._float,this._float=!0,this.saveInitial()),this}commit(){return this.batchMode?(this.batchMode=!1,this._float=this._prevFloat,delete this._prevFloat,this._packNodes()._notify()):this}_useEntireRowArea(t,e){return!this.float&&!this._hasLocked&&(!t._moving||t._skipDown||e.y<=t.y)}_fixCollisions(t,e=t,i,o={}){if(this._sortNodes(-1),!(i=i||this.collide(t,e)))return!1;if(t._moving&&!o.nested&&!this.float&&this.swap(t,i))return!0;let r=e;this._useEntireRowArea(t,e)&&(r={x:0,w:this.column,y:e.y,h:e.h},i=this.collide(t,r,o.skip));let n=!1,l={nested:!0,pack:!1};for(;i=i||this.collide(t,r,o.skip);){let r;if(i.locked||t._moving&&!t._skipDown&&e.y>t.y&&!this.float&&(!this.collide(i,Object.assign(Object.assign({},i),{y:t.y}),t)||!this.collide(i,Object.assign(Object.assign({},i),{y:e.y-i.h}),t))?(t._skipDown=t._skipDown||e.y>t.y,r=this.moveNode(t,Object.assign(Object.assign(Object.assign({},e),{y:i.y+i.h}),l)),i.locked&&r?s.Utils.copyPos(e,t):!i.locked&&r&&o.pack&&(this._packNodes(),e.y=i.y+i.h,s.Utils.copyPos(t,e)),n=n||r):r=this.moveNode(i,Object.assign(Object.assign(Object.assign({},i),{y:e.y+e.h,skip:t}),l)),!r)return n;i=void 0}return n}collide(t,e=t,i){return this.nodes.find((o=>o!==t&&o!==i&&s.Utils.isIntercepted(o,e)))}collideAll(t,e=t,i){return this.nodes.filter((o=>o!==t&&o!==i&&s.Utils.isIntercepted(o,e)))}collideCoverage(t,e,i){if(!e.rect||!t._rect)return;let s,o=t._rect,r=Object.assign({},e.rect);return r.y>o.y?(r.h+=r.y-o.y,r.y=o.y):r.h+=o.y-r.y,r.x>o.x?(r.w+=r.x-o.x,r.x=o.x):r.w+=o.x-r.x,i.forEach((t=>{if(t.locked||!t._rect)return;let e=t._rect,i=Number.MAX_VALUE,n=Number.MAX_VALUE,l=.5;o.ye.y+e.h&&(i=(e.y+e.h-r.y)/e.h),o.xe.x+e.w&&(n=(e.x+e.w-r.x)/e.w);let a=Math.min(n,i);a>l&&(l=a,s=t)})),s}cacheRects(t,e,i,s,o,r){return this.nodes.forEach((n=>n._rect={y:n.y*e+i,x:n.x*t+r,w:n.w*t-r-s,h:n.h*e-i-o})),this}swap(t,e){if(!e||e.locked||!t||t.locked)return!1;function i(){let i=e.x,s=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.x=i,t.y=s),t._dirty=e._dirty=!0,!0}let o;if(t.w===e.w&&t.h===e.h&&(t.x===e.x||t.y===e.y)&&(o=s.Utils.isTouching(t,e)))return i();if(!1!==o){if(t.w===e.w&&t.x===e.x&&(o||s.Utils.isTouching(t,e))){if(e.y{t.locked||(t.autoPosition=!0),this.addNode(t,!1),t._dirty=!0})),this.commit()}set float(t){this._float!==t&&(this._float=t||!1,t||this._packNodes()._notify())}get float(){return this._float||!1}_sortNodes(t){return this.nodes=s.Utils.sort(this.nodes,t,this.column),this}_packNodes(){return this._sortNodes(),this.float?this.nodes.forEach((t=>{if(t._updating||void 0===t._orig||t.y===t._orig.y)return;let e=t.y;for(;e>t._orig.y;)--e,this.collide(t,{x:t.x,y:e,w:t.w,h:t.h})||(t._dirty=!0,t.y=e)})):this.nodes.forEach(((t,e)=>{if(!t.locked)for(;t.y>0;){let i=0===e?0:t.y-1;if(0!==e&&this.collide(t,{x:t.x,y:i,w:t.w,h:t.h}))break;t._dirty=t.y!==i,t.y=i}})),this}prepareNode(t,e){(t=t||{})._id=t._id||o._idSeq++,void 0!==t.x&&void 0!==t.y&&null!==t.x&&null!==t.y||(t.autoPosition=!0);let i={x:0,y:0,w:1,h:1};return s.Utils.defaults(t,i),t.autoPosition||delete t.autoPosition,t.noResize||delete t.noResize,t.noMove||delete t.noMove,"string"==typeof t.x&&(t.x=Number(t.x)),"string"==typeof t.y&&(t.y=Number(t.y)),"string"==typeof t.w&&(t.w=Number(t.w)),"string"==typeof t.h&&(t.h=Number(t.h)),isNaN(t.x)&&(t.x=i.x,t.autoPosition=!0),isNaN(t.y)&&(t.y=i.y,t.autoPosition=!0),isNaN(t.w)&&(t.w=i.w),isNaN(t.h)&&(t.h=i.h),this.nodeBoundFix(t,e)}nodeBoundFix(t,e){return t.maxW&&(t.w=Math.min(t.w,t.maxW)),t.maxH&&(t.h=Math.min(t.h,t.maxH)),t.minW&&(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&&(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),t}getDirtyNodes(t){return t?this.nodes.filter((t=>t._dirty&&!s.Utils.samePos(t,t._orig))):this.nodes.filter((t=>t._dirty))}_notify(t,e=!0){if(this.batchMode)return this;let i=(t=void 0===t?[]:Array.isArray(t)?t:[t]).concat(this.getDirtyNodes());return this.onChange&&this.onChange(i,e),this}cleanNodes(){return this.batchMode||this.nodes.forEach((t=>{delete t._dirty,delete t._lastTried})),this}saveInitial(){return this.nodes.forEach((t=>{t._orig=s.Utils.copyPos({},t),delete t._dirty})),this._hasLocked=this.nodes.some((t=>t.locked)),this}restoreInitial(){return this.nodes.forEach((t=>{s.Utils.samePos(t,t._orig)||(s.Utils.copyPos(t,t._orig),t._dirty=!0)})),this._notify(),this}addNode(t,e=!1){let i;if(i=this.nodes.find((e=>e._id===t._id)))return i;if(delete(t=this.prepareNode(t))._temporaryRemoved,delete t._removeDOM,t.autoPosition){this._sortNodes();for(let e=0;;++e){let i=e%this.column,o=Math.floor(e/this.column);if(i+t.w>this.column)continue;let r={x:i,y:o,w:t.w,h:t.h};if(!this.nodes.find((t=>s.Utils.isIntercepted(r,t)))){t.x=i,t.y=o,delete t.autoPosition;break}}}return this.nodes.push(t),e&&this.addedNodes.push(t),this._fixCollisions(t),this._packNodes()._notify(),t}removeNode(t,e=!0,i=!1){return this.nodes.find((e=>e===t))?(i&&this.removedNodes.push(t),e&&(t._removeDOM=!0),this.nodes=this.nodes.filter((e=>e!==t)),this._packNodes()._notify(t)):this}removeAll(t=!0){return delete this._layouts,0===this.nodes.length?this:(t&&this.nodes.forEach((t=>t._removeDOM=!0)),this.removedNodes=this.nodes,this.nodes=[],this._notify(this.removedNodes))}moveNodeCheck(t,e){if(!this.changedPosConstrain(t,e))return!1;if(e.pack=!0,!this.maxRow)return this.moveNode(t,e);let i,r=new o({column:this.column,float:this.float,nodes:this.nodes.map((e=>e===t?(i=Object.assign({},e),i):Object.assign({},e)))});if(!i)return!1;let n=r.moveNode(i,e);if(this.maxRow&&n&&(n=r.getRow()<=this.maxRow,!n)){let i=this.collide(t,e);if(i&&this.swap(t,i))return this._notify(),!0}return!!n&&(r.nodes.filter((t=>t._dirty)).forEach((t=>{let e=this.nodes.find((e=>e._id===t._id));e&&(s.Utils.copyPos(e,t),e._dirty=!0)})),this._notify(),!0)}willItFit(t){if(delete t._willFitPos,!this.maxRow)return!0;let e=new o({column:this.column,float:this.float,nodes:this.nodes.map((t=>Object.assign({},t)))}),i=Object.assign({},t);return this.cleanupNode(i),delete i.el,delete i._id,delete i.content,delete i.grid,e.addNode(i),e.getRow()<=this.maxRow&&(t._willFitPos=s.Utils.copyPos({},i),!0)}changedPosConstrain(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)}moveNode(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);let i=t.w!==e.w||t.h!==e.h,o=s.Utils.copyPos({},t,!0);if(s.Utils.copyPos(o,e),o=this.nodeBoundFix(o,i),s.Utils.copyPos(e,o),s.Utils.samePos(t,e))return!1;let r=s.Utils.copyPos({},t),n=o,l=this.collideAll(t,n,e.skip),a=!0;if(l.length){let i=t._moving&&!e.nested?this.collideCoverage(t,e,l):l[0];a=!!i&&!this._fixCollisions(t,o,i,e)}return a&&(t._dirty=!0,s.Utils.copyPos(t,o)),e.pack&&this._packNodes()._notify(),!s.Utils.samePos(t,r)}getRow(){return this.nodes.reduce(((t,e)=>Math.max(t,e.y+e.h)),0)}beginUpdate(t){return t._updating||(t._updating=!0,delete t._skipDown,this.batchMode||this.saveInitial()),this}endUpdate(){let t=this.nodes.find((t=>t._updating));return t&&(delete t._updating,delete t._skipDown),this}save(t=!0){let e=[];return this._sortNodes(),this.nodes.forEach((i=>{let s={};for(let t in i)"_"!==t[0]&&null!==i[t]&&void 0!==i[t]&&(s[t]=i[t]);t||delete s.el,delete s.grid,s.autoPosition||delete s.autoPosition,s.noResize||delete s.noResize,s.noMove||delete s.noMove,s.locked||delete s.locked,e.push(s)})),e}layoutsNodesChange(t){return!this._layouts||this._ignoreLayoutsNodeChange||this._layouts.forEach(((e,i)=>{if(!e||i===this.column)return this;i{if(!t._orig)return;let s=e.find((e=>e._id===t._id));if(!s)return;let o=i/this.column;t.y!==t._orig.y&&(s.y+=t.y-t._orig.y),t.x!==t._orig.x&&(s.x=Math.round(t.x*o)),t.w!==t._orig.w&&(s.w=Math.round(t.w*o))}))})),this}updateNodeWidths(t,e,i,o="moveScale"){if(!this.nodes.length||t===e)return this;if(this.cacheLayout(this.nodes,t),1===e&&i&&i.length){let t=0;i.forEach((e=>{e.x=0,e.w=1,e.y=Math.max(e.y,t),t=e.y+e.h}))}else i=s.Utils.sort(this.nodes,-1,t);let r=this._layouts[e]||[],n=this._layouts.length-1;0===r.length&&e>t&&e{let e=i.findIndex((e=>e._id===t._id));-1!==e&&(i[e].x=t.x,i[e].y=t.y,i[e].w=t.w)})),r=[]));let l=[];if(r.forEach((t=>{let e=i.findIndex((e=>e._id===t._id));-1!==e&&(i[e].x=t.x,i[e].y=t.y,i[e].w=t.w,l.push(i[e]),i.splice(e,1))})),i.length)if("function"==typeof o)o(e,t,l,i);else{let s=e/t,r="move"===o||"moveScale"===o,n="scale"===o||"moveScale"===o;i.forEach((i=>{i.x=1===e?0:r?Math.round(i.x*s):Math.min(i.x,e-1),i.w=1===e||1===t?1:n?Math.round(i.w*s)||1:Math.min(i.w,e),l.push(i)})),i=[]}return l=s.Utils.sort(l,-1,e),this._ignoreLayoutsNodeChange=!0,this.batchUpdate(),this.nodes=[],l.forEach((t=>{this.addNode(t,!1),t._dirty=!0}),this),this.commit(),delete this._ignoreLayoutsNodeChange,this}cacheLayout(t,e,i=!1){let s=[];return t.forEach(((t,e)=>{t._id=t._id||o._idSeq++,s[e]={x:t.x,y:t.y,w:t.w,_id:t._id}})),this._layouts=i?[]:this._layouts||[],this._layouts[e]=s,this}cacheOneLayout(t,e){t._id=t._id||o._idSeq++;let i={x:t.x,y:t.y,w:t.w,_id:t._id};this._layouts=this._layouts||[],this._layouts[e]=this._layouts[e]||[];let s=this._layouts[e].findIndex((e=>e._id===t._id));return-1===s?this._layouts[e].push(i):this._layouts[e][s]=i,this}cleanupNode(t){for(let e in t)"_"===e[0]&&"_id"!==e&&delete t[e];return this}}e.GridStackEngine=o,o._idSeq=1},930:(t,e,i)=>{function s(t){for(var i in t)e.hasOwnProperty(i)||(e[i]=t[i])}Object.defineProperty(e,"__esModule",{value:!0}),s(i(593)),s(i(62)),s(i(334)),s(i(270)),s(i(761))},270:(t,e,i)=>{function s(t){for(var i in t)e.hasOwnProperty(i)||(e[i]=t[i])}Object.defineProperty(e,"__esModule",{value:!0});const o=i(62),r=i(593),n=i(334);s(i(593)),s(i(62)),s(i(334));const l={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};class a{constructor(t,e={}){this._gsEventHandler={},this._extraDragRow=0,this.el=t,(e=e||{}).row&&(e.minRow=e.maxRow=e.row,delete e.row);let i=r.Utils.toNumber(t.getAttribute("gs-row")),s=Object.assign(Object.assign({},l),{column:r.Utils.toNumber(t.getAttribute("gs-column"))||12,minRow:i||r.Utils.toNumber(t.getAttribute("gs-min-row"))||0,maxRow:i||r.Utils.toNumber(t.getAttribute("gs-max-row"))||0,staticGrid:r.Utils.toBool(t.getAttribute("gs-static"))||!1,_styleSheetClass:"grid-stack-instance-"+(1e4*Math.random()).toFixed(0),alwaysShowResizeHandle:e.alwaysShowResizeHandle||!1,resizable:{autoHide:!e.alwaysShowResizeHandle,handles:"se"},draggable:{handle:(e.handleClass?"."+e.handleClass:e.handle?e.handle:"")||".grid-stack-item-content",scroll:!1,appendTo:"body"},removableOptions:{accept:"."+(e.itemClass||"grid-stack-item")}});t.getAttribute("gs-animate")&&(s.animate=r.Utils.toBool(t.getAttribute("gs-animate"))),this.opts=r.Utils.defaults(e,s),e=null,this.initMargin(),1!==this.opts.column&&!this.opts.disableOneColumnMode&&this._widthOrContainer()<=this.opts.minWidth&&(this._prevColumn=this.opts.column,this.opts.column=1),"auto"===this.opts.rtl&&(this.opts.rtl="rtl"===t.style.direction),this.opts.rtl&&this.el.classList.add("grid-stack-rtl");let n=r.Utils.closestByClass(this.el,l.itemClass);if(n&&n.gridstackNode&&(this.opts._isNested=n.gridstackNode,this.opts._isNested.subGrid=this,this.el.classList.add("grid-stack-nested")),this._isAutoCellHeight="auto"===this.opts.cellHeight,this._isAutoCellHeight||"initial"===this.opts.cellHeight?this.cellHeight(void 0,!1):this.cellHeight(this.opts.cellHeight,!1),this.el.classList.add(this.opts._styleSheetClass),this._setStaticClass(),this.engine=new o.GridStackEngine({column:this.opts.column,float:this.opts.float,maxRow:this.opts.maxRow,onChange:t=>{let e=0;this.engine.nodes.forEach((t=>{e=Math.max(e,t.y+t.h)})),t.forEach((t=>{let e=t.el;t._removeDOM?(e&&e.remove(),delete t._removeDOM):this._writePosAttr(e,t)})),this._updateStyles(!1,e)}}),this.opts.auto){this.batchUpdate();let t=[];this.getGridItems().forEach((e=>{let i=parseInt(e.getAttribute("gs-x")),s=parseInt(e.getAttribute("gs-y"));t.push({el:e,i:(Number.isNaN(i)?1e3:i)+(Number.isNaN(s)?1e3:s)*this.opts.column})})),t.sort(((t,e)=>t.i-e.i)).forEach((t=>this._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&&a.setupDragIn(this.opts.dragIn,this.opts.dragInOptions),delete this.opts.dragIn,delete this.opts.dragInOptions,this._setupRemoveDrop(),this._setupAcceptWidget(),this._updateWindowResizeEvent()}static init(t={},e=".grid-stack"){let i=a.getGridElement(e);return i?(i.gridstack||(i.gridstack=new a(i,Object.assign({},t))),i.gridstack):("string"==typeof e?console.error('GridStack.initAll() no grid was found with selector "'+e+'" - 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)}static initAll(t={},e=".grid-stack"){let i=[];return a.getGridElements(e).forEach((e=>{e.gridstack||(e.gridstack=new a(e,Object.assign({},t)),delete t.dragIn,delete t.dragInOptions),i.push(e.gridstack)})),0===i.length&&console.error('GridStack.initAll() no grid was found with selector "'+e+'" - element missing or wrong selector ?\nNote: ".grid-stack" is required for proper CSS styling and drag/drop, and is the default selector.'),i}static addGrid(t,e={}){if(!t)return null;let i=t;if(!t.classList.contains("grid-stack")){let s=document.implementation.createHTMLDocument();s.body.innerHTML=`
`,i=s.body.children[0],t.appendChild(i)}let s=a.init(e,i);if(s.opts.children){let t=s.opts.children;delete s.opts.children,s.load(t)}return s}get placeholder(){if(!this._placeholder){let 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,l.itemClass,this.opts.itemClass),this.placeholder.appendChild(t)}return this._placeholder}addWidget(t,e){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");let e=arguments,i=1,s={x:e[i++],y:e[i++],w:e[i++],h:e[i++],autoPosition:e[i++],minW:e[i++],maxW:e[i++],minH:e[i++],maxH:e[i++],id:e[i++]};return this.addWidget(t,s)}let i;if("string"==typeof t){let e=document.implementation.createHTMLDocument();e.body.innerHTML=t,i=e.body.children[0]}else if(0===arguments.length||1===arguments.length&&(void 0!==(s=t).x||void 0!==s.y||void 0!==s.w||void 0!==s.h||void 0!==s.content)){let s=t&&t.content||"";e=t;let o=document.implementation.createHTMLDocument();o.body.innerHTML=`
${s}
`,i=o.body.children[0]}else i=t;var s;let o=this._readAttr(i);e=Object.assign({},e||{}),r.Utils.defaults(e,o);let n=this.engine.prepareNode(e);if(this._writeAttr(i,e),this._insertNotAppend?this.el.prepend(i):this.el.appendChild(i),this._prepareElement(i,!0,e),this._updateContainerHeight(),n.subGrid&&!n.subGrid.el){let t=n.el.querySelector(".grid-stack-item-content");n.subGrid=a.addGrid(t,n.subGrid)}return this._triggerAddEvent(),this._triggerChangeEvent(),i}save(t=!0,e=!1){let i=this.engine.save(t);if(t&&i.forEach((t=>{if(t.el&&!t.subGrid){let e=t.el.querySelector(".grid-stack-item-content");t.content=e?e.innerHTML:void 0,t.content||delete t.content,delete t.el}})),e){i.forEach((i=>{i.subGrid&&(i.subGrid=i.subGrid.save(t,e))}));let s=Object.assign({},this.opts);return s.marginBottom===s.marginTop&&s.marginRight===s.marginLeft&&s.marginTop===s.marginRight&&(s.margin=s.marginTop,delete s.marginTop,delete s.marginRight,delete s.marginBottom,delete s.marginLeft),s.rtl===("rtl"===this.el.style.direction)&&(s.rtl="auto"),this._isAutoCellHeight&&(s.cellHeight="auto"),r.Utils.removeInternalAndSame(s,l),s.children=i,s}return i}load(t,e=!0){let i=a.Utils.sort([...t],-1,this._prevColumn||this.opts.column);this._insertNotAppend=!0,this._prevColumn&&this._prevColumn!==this.opts.column&&i.some((t=>t.x+t.w>this.opts.column))&&(this._ignoreLayoutsNodeChange=!0,this.engine.cacheLayout(i,this._prevColumn,!0));let s=[];return this.batchUpdate(),e&&[...this.engine.nodes].forEach((t=>{i.find((e=>t.id===e.id))||("function"==typeof e?e(this,t,!1):(s.push(t),this.removeWidget(t.el,!0,!1)))})),i.forEach((t=>{let i=t.id||0===t.id?this.engine.nodes.find((e=>e.id===t.id)):void 0;if(i){if(this.update(i.el,t),t.subGrid&&t.subGrid.children){let e=i.el.querySelector(".grid-stack");e&&e.gridstack&&(e.gridstack.load(t.subGrid.children),this._insertNotAppend=!0)}}else e&&(t="function"==typeof e?e(this,t,!0).gridstackNode:this.addWidget(t).gridstackNode)})),this.engine.removedNodes=s,this.commit(),delete this._ignoreLayoutsNodeChange,delete this._insertNotAppend,this}batchUpdate(){return this.engine.batchUpdate(),this}getCellHeight(t=!1){return!this.opts.cellHeight||"auto"===this.opts.cellHeight||t&&this.opts.cellHeightUnit&&"px"!==this.opts.cellHeightUnit?Math.round(this.el.getBoundingClientRect().height)/parseInt(this.el.getAttribute("gs-current-row")):this.opts.cellHeight}cellHeight(t,e=!0){if(e&&void 0!==t&&this._isAutoCellHeight!==("auto"===t)&&(this._isAutoCellHeight="auto"===t,this._updateWindowResizeEvent()),"initial"!==t&&"auto"!==t||(t=void 0),void 0===t){let e=-this.opts.marginRight-this.opts.marginLeft+this.opts.marginTop+this.opts.marginBottom;t=this.cellWidth()+e}let i=r.Utils.parseHeight(t);return this.opts.cellHeightUnit===i.unit&&this.opts.cellHeight===i.h||(this.opts.cellHeightUnit=i.unit,this.opts.cellHeight=i.h,e&&this._updateStyles(!0,this.getRow())),this}cellWidth(){return this._widthOrContainer()/this.opts.column}_widthOrContainer(){return this.el.clientWidth||this.el.parentElement.clientWidth||window.innerWidth}commit(){return this.engine.commit(),this._triggerRemoveEvent(),this._triggerAddEvent(),this._triggerChangeEvent(),this}compact(){return this.engine.compact(),this._triggerChangeEvent(),this}column(t,e="moveScale"){if(this.opts.column===t)return this;let i,s=this.opts.column;return 1===t?this._prevColumn=s:delete this._prevColumn,this.el.classList.remove("grid-stack-"+s),this.el.classList.add("grid-stack-"+t),this.opts.column=this.engine.column=t,1===t&&this.opts.oneColumnModeDomSort&&(i=[],this.getGridItems().forEach((t=>{t.gridstackNode&&i.push(t.gridstackNode)})),i.length||(i=void 0)),this.engine.updateNodeWidths(s,t,i,e),this._isAutoCellHeight&&this.cellHeight(),this._ignoreLayoutsNodeChange=!0,this._triggerChangeEvent(),delete this._ignoreLayoutsNodeChange,this}getColumn(){return this.opts.column}getGridItems(){return Array.from(this.el.children).filter((t=>t.matches("."+this.opts.itemClass)&&!t.matches("."+this.opts.placeholderClass)))}destroy(t=!0){if(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}float(t){return this.engine.float=t,this._triggerChangeEvent(),this}getFloat(){return this.engine.float}getCellFromPixel(t,e=!1){let i,s=this.el.getBoundingClientRect();i=e?{top:s.top+document.documentElement.scrollTop,left:s.left}:{top:this.el.offsetTop,left:this.el.offsetLeft};let o=t.left-i.left,r=t.top-i.top,n=s.width/this.opts.column,l=s.height/parseInt(this.el.getAttribute("gs-current-row"));return{x:Math.floor(o/n),y:Math.floor(r/l)}}getRow(){return Math.max(this.engine.getRow(),this.opts.minRow)}isAreaEmpty(t,e,i,s){return this.engine.isAreaEmpty(t,e,i,s)}makeWidget(t){let e=a.getElement(t);return this._prepareElement(e,!0),this._updateContainerHeight(),this._triggerAddEvent(),this._triggerChangeEvent(),e}on(t,e){if(-1!==t.indexOf(" "))return t.split(" ").forEach((t=>this.on(t,e))),this;if("change"===t||"added"===t||"removed"===t||"enable"===t||"disable"===t){let i="enable"===t||"disable"===t;this._gsEventHandler[t]=i?t=>e(t):t=>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}off(t){return-1!==t.indexOf(" ")?(t.split(" ").forEach((t=>this.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)}removeWidget(t,e=!0,i=!0){return a.getElements(t).forEach((t=>{if(t.parentElement!==this.el)return;let s=t.gridstackNode;s||(s=this.engine.nodes.find((e=>t===e.el))),s&&(delete t.gridstackNode,n.GridStackDDI.get().remove(t),this.engine.removeNode(s,e,i),e&&t.parentElement&&t.remove())})),i&&(this._triggerRemoveEvent(),this._triggerChangeEvent()),this}removeAll(t=!0){return this.engine.nodes.forEach((t=>{delete t.el.gridstackNode,n.GridStackDDI.get().remove(t.el)})),this.engine.removeAll(t),this._triggerRemoveEvent(),this}setAnimation(t){return t?this.el.classList.add("grid-stack-animate"):this.el.classList.remove("grid-stack-animate"),this}setStatic(t,e=!0){return this.opts.staticGrid===t||(this.opts.staticGrid=t,this._setupRemoveDrop(),this._setupAcceptWidget(),this.engine.nodes.forEach((t=>this._prepareDragDropByNode(t))),e&&this._setStaticClass()),this}update(t,e){if(arguments.length>2){console.warn("gridstack.ts: `update(el, x, y, w, h)` is deprecated. Use `update({x, w, content, ...})`. It will be removed soon");let i=arguments,s=1;return e={x:i[s++],y:i[s++],w:i[s++],h:i[s++]},this.update(t,e)}return a.getElements(t).forEach((t=>{if(!t||!t.gridstackNode)return;let i=t.gridstackNode,s=Object.assign({},e);delete s.autoPosition;let o,r=["x","y","w","h"];if(r.some((t=>void 0!==s[t]&&s[t]!==i[t]))&&(o={},r.forEach((t=>{o[t]=void 0!==s[t]?s[t]:i[t],delete s[t]}))),!o&&(s.minW||s.minH||s.maxW||s.maxH)&&(o={}),s.content){let e=t.querySelector(".grid-stack-item-content");e&&e.innerHTML!==s.content&&(e.innerHTML=s.content),delete s.content}let n=!1,l=!1;for(const t in s)"_"!==t[0]&&i[t]!==s[t]&&(i[t]=s[t],n=!0,l=l||!this.opts.staticGrid&&("noResize"===t||"noMove"===t||"locked"===t));o&&(this.engine.cleanNodes().beginUpdate(i).moveNode(i,o),this._updateContainerHeight(),this._triggerChangeEvent(),this.engine.endUpdate()),n&&this._writeAttr(t,i),l&&this._prepareDragDropByNode(i)})),this}margin(t){if(!("string"==typeof t&&t.split(" ").length>1)){let e=r.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}getMargin(){return this.opts.margin}willItFit(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");let t=arguments,e=0,i={x:t[e++],y:t[e++],w:t[e++],h:t[e++],autoPosition:t[e++]};return this.willItFit(i)}return this.engine.willItFit(t)}_triggerChangeEvent(){if(this.engine.batchMode)return this;let t=this.engine.getDirtyNodes(!0);return t&&t.length&&(this._ignoreLayoutsNodeChange||this.engine.layoutsNodesChange(t),this._triggerEvent("change",t)),this.engine.saveInitial(),this}_triggerAddEvent(){return this.engine.batchMode||this.engine.addedNodes&&this.engine.addedNodes.length>0&&(this._ignoreLayoutsNodeChange||this.engine.layoutsNodesChange(this.engine.addedNodes),this.engine.addedNodes.forEach((t=>{delete t._dirty})),this._triggerEvent("added",this.engine.addedNodes),this.engine.addedNodes=[]),this}_triggerRemoveEvent(){return this.engine.batchMode||this.engine.removedNodes&&this.engine.removedNodes.length>0&&(this._triggerEvent("removed",this.engine.removedNodes),this.engine.removedNodes=[]),this}_triggerEvent(t,e){let i=e?new CustomEvent(t,{bubbles:!1,detail:e}):new Event(t);return this.el.dispatchEvent(i),this}_removeStylesheet(){return this._styles&&(r.Utils.removeStylesheet(this._styles._id),delete this._styles),this}_updateStyles(t=!1,e){if(t&&this._removeStylesheet(),this._updateContainerHeight(),0===this.opts.cellHeight)return this;let i=this.opts.cellHeight,s=this.opts.cellHeightUnit,o=`.${this.opts._styleSheetClass} > .${this.opts.itemClass}`;if(!this._styles){let t="gridstack-style-"+(1e5*Math.random()).toFixed(),e=this.opts.styleInHead?void 0:this.el.parentNode;if(this._styles=r.Utils.createStylesheet(t,e),!this._styles)return this;this._styles._id=t,this._styles._max=0,r.Utils.addCSSRule(this._styles,o,`min-height: ${i}${s}`);let n=this.opts.marginTop+this.opts.marginUnit,l=this.opts.marginBottom+this.opts.marginUnit,a=this.opts.marginRight+this.opts.marginUnit,h=this.opts.marginLeft+this.opts.marginUnit,d=`${o} > .grid-stack-item-content`,g=`.${this.opts._styleSheetClass} > .grid-stack-placeholder > .placeholder-content`;r.Utils.addCSSRule(this._styles,d,`top: ${n}; right: ${a}; bottom: ${l}; left: ${h};`),r.Utils.addCSSRule(this._styles,g,`top: ${n}; right: ${a}; bottom: ${l}; left: ${h};`),r.Utils.addCSSRule(this._styles,`${o} > .ui-resizable-ne`,`right: ${a}`),r.Utils.addCSSRule(this._styles,`${o} > .ui-resizable-e`,`right: ${a}`),r.Utils.addCSSRule(this._styles,`${o} > .ui-resizable-se`,`right: ${a}; bottom: ${l}`),r.Utils.addCSSRule(this._styles,`${o} > .ui-resizable-nw`,`left: ${h}`),r.Utils.addCSSRule(this._styles,`${o} > .ui-resizable-w`,`left: ${h}`),r.Utils.addCSSRule(this._styles,`${o} > .ui-resizable-sw`,`left: ${h}; bottom: ${l}`)}if((e=e||this._styles._max)>this._styles._max){let t=t=>i*t+s;for(let i=this._styles._max+1;i<=e;i++){let e=t(i);r.Utils.addCSSRule(this._styles,`${o}[gs-y="${i-1}"]`,`top: ${t(i-1)}`),r.Utils.addCSSRule(this._styles,`${o}[gs-h="${i}"]`,`height: ${e}`),r.Utils.addCSSRule(this._styles,`${o}[gs-min-h="${i}"]`,`min-height: ${e}`),r.Utils.addCSSRule(this._styles,`${o}[gs-max-h="${i}"]`,`max-height: ${e}`)}this._styles._max=e}return this}_updateContainerHeight(){if(!this.engine||this.engine.batchMode)return this;let t=this.getRow()+this._extraDragRow,e=parseInt(getComputedStyle(this.el)["min-height"]);if(e>0){let i=Math.round(e/this.getCellHeight(!0));tthis.cellHeight()),this.opts.cellHeightThrottle)),this._cellHeightThrottle()):this.cellHeight()),this.engine.nodes.forEach((t=>{t.subGrid&&t.subGrid.onParentResize()})),this}_updateWindowResizeEvent(t=!1){const 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}static getElement(t=".grid-stack-item"){return r.Utils.getElement(t)}static getElements(t=".grid-stack-item"){return r.Utils.getElements(t)}static getGridElement(t){return a.getElement(t)}static getGridElements(t){return r.Utils.getElements(t)}initMargin(){let 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=r.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=r.Utils.parseHeight(this.opts.marginTop),this.opts.marginTop=t.h,delete this.opts.margin),void 0===this.opts.marginBottom?this.opts.marginBottom=e:(t=r.Utils.parseHeight(this.opts.marginBottom),this.opts.marginBottom=t.h,delete this.opts.margin),void 0===this.opts.marginRight?this.opts.marginRight=e:(t=r.Utils.parseHeight(this.opts.marginRight),this.opts.marginRight=t.h,delete this.opts.margin),void 0===this.opts.marginLeft?this.opts.marginLeft=e:(t=r.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}static setupDragIn(t,e){}movable(t,e){return this}resizable(t,e){return this}disable(){return this}enable(){return this}enableMove(t){return this}enableResize(t){return this}_setupAcceptWidget(){return this}_setupRemoveDrop(){return this}_prepareDragDropByNode(t){return this}_onStartMoving(t,e,i,s,o,r){}_dragOrResize(t,e,i,s,o,r){}_leave(t,e){}}e.GridStack=a,a.Utils=r.Utils,a.Engine=o.GridStackEngine},861:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DDBaseImplement=class{constructor(){this._disabled=!1,this._eventRegister={}}get disabled(){return this._disabled}on(t,e){this._eventRegister[t]=e}off(t){delete this._eventRegister[t]}enable(){this._disabled=!1}disable(){this._disabled=!0}destroy(){delete this._eventRegister}triggerEvent(t,e){if(!this.disabled&&this._eventRegister&&this._eventRegister[t])return this._eventRegister[t](e)}}},311:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0});const s=i(849),o=i(943),r=i(861);class n extends r.DDBaseImplement{constructor(t,e={}){super(),this.dragging=!1,this.ui=()=>{const t=this.el.parentElement.getBoundingClientRect(),e=this.helper.getBoundingClientRect();return{position:{top:e.top-t.top,left:e.left-t.left}}},this.el=t,this.option=e;let i=e.handle.substring(1);this.dragEl=t.classList.contains(i)?t:t.querySelector(e.handle)||t,this._dragStart=this._dragStart.bind(this),this._drag=this._drag.bind(this),this._dragEnd=this._dragEnd.bind(this),this.enable()}on(t,e){super.on(t,e)}off(t){super.off(t)}enable(){super.enable(),this.dragEl.draggable=!0,this.dragEl.addEventListener("dragstart",this._dragStart),this.el.classList.remove("ui-draggable-disabled"),this.el.classList.add("ui-draggable")}disable(t=!1){super.disable(),this.dragEl.removeAttribute("draggable"),this.dragEl.removeEventListener("dragstart",this._dragStart),this.el.classList.remove("ui-draggable"),t||this.el.classList.add("ui-draggable-disabled")}destroy(){this.dragging&&this._dragEnd({}),this.disable(!0),delete this.el,delete this.helper,delete this.option,super.destroy()}updateOption(t){return Object.keys(t).forEach((e=>this.option[e]=t[e])),this}_dragStart(t){s.DDManager.dragElement=this,this.helper=this._createHelper(t),this._setupHelperContainmentStyle(),this.dragOffset=this._getDragOffset(t,this.el,this.helperContainment);const e=o.DDUtils.initEvent(t,{target:this.el,type:"dragstart"});this.helper!==this.el?this._setupDragFollowNodeNotifyStart(e):this.dragFollowTimer=window.setTimeout((()=>{delete this.dragFollowTimer,this._setupDragFollowNodeNotifyStart(e)}),0),this._cancelDragGhost(t)}_setupDragFollowNodeNotifyStart(t){return this._setupHelperStyle(),document.addEventListener("dragover",this._drag,n.dragEventListenerOption),this.dragEl.addEventListener("dragend",this._dragEnd),this.option.start&&this.option.start(t,this.ui()),this.dragging=!0,this.helper.classList.add("ui-draggable-dragging"),this.triggerEvent("dragstart",t),this}_drag(t){t.preventDefault(),this._dragFollow(t);const e=o.DDUtils.initEvent(t,{target:this.el,type:"drag"});this.option.drag&&this.option.drag(e,this.ui()),this.triggerEvent("drag",e)}_dragEnd(t){if(this.dragFollowTimer)return clearTimeout(this.dragFollowTimer),void delete this.dragFollowTimer;this.paintTimer&&cancelAnimationFrame(this.paintTimer),document.removeEventListener("dragover",this._drag,n.dragEventListenerOption),this.dragEl.removeEventListener("dragend",this._dragEnd),this.dragging=!1,this.helper.classList.remove("ui-draggable-dragging"),this.helperContainment.style.position=this.parentOriginStylePosition||null,this.helper===this.el?this._removeHelperStyle():this.helper.remove();const e=o.DDUtils.initEvent(t,{target:this.el,type:"dragstop"});this.option.stop&&this.option.stop(e),this.triggerEvent("dragstop",e),delete s.DDManager.dragElement,delete this.helper}_createHelper(t){let e=this.el;return"function"==typeof this.option.helper?e=this.option.helper(t):"clone"===this.option.helper&&(e=o.DDUtils.clone(this.el)),document.body.contains(e)||o.DDUtils.appendTo(e,"parent"===this.option.appendTo?this.el.parentNode:this.option.appendTo),e===this.el&&(this.dragElementOriginStyle=n.originStyleProp.map((t=>this.el.style[t]))),e}_setupHelperStyle(){return this.helper.style.pointerEvents="none",this.helper.style.width=this.dragOffset.width+"px",this.helper.style.height=this.dragOffset.height+"px",this.helper.style.willChange="left, top",this.helper.style.transition="none",this.helper.style.position=this.option.basePosition||n.basePosition,this.helper.style.zIndex="1000",setTimeout((()=>{this.helper&&(this.helper.style.transition=null)}),0),this}_removeHelperStyle(){let t=this.helper?this.helper.gridstackNode:void 0;return t&&t._isAboutToRemove||n.originStyleProp.forEach((t=>{this.helper.style[t]=this.dragElementOriginStyle[t]||null})),delete this.dragElementOriginStyle,this}_dragFollow(t){this.paintTimer&&cancelAnimationFrame(this.paintTimer),this.paintTimer=requestAnimationFrame((()=>{delete this.paintTimer;const e=this.dragOffset;let i={left:0,top:0};if("absolute"===this.helper.style.position){const{left:t,top:e}=this.helperContainment.getBoundingClientRect();i={left:t,top:e}}this.helper.style.left=t.clientX+e.offsetLeft-i.left+"px",this.helper.style.top=t.clientY+e.offsetTop-i.top+"px"}))}_setupHelperContainmentStyle(){return this.helperContainment=this.helper.parentElement,"fixed"!==this.option.basePosition&&(this.parentOriginStylePosition=this.helperContainment.style.position,window.getComputedStyle(this.helperContainment).position.match(/static/)&&(this.helperContainment.style.position="relative")),this}_cancelDragGhost(t){let e=document.createElement("div");return e.style.width="1px",e.style.height="1px",document.body.appendChild(e),t.dataTransfer.setDragImage(e,0,0),setTimeout((()=>document.body.removeChild(e))),t.stopPropagation(),this}_getDragOffset(t,e,i){let s=0,r=0;if(i){const t=document.createElement("div");o.DDUtils.addElStyles(t,{opacity:"0",position:"fixed",top:"0px",left:"0px",width:"1px",height:"1px",zIndex:"-999999"}),i.appendChild(t);const e=t.getBoundingClientRect();i.removeChild(t),s=e.left,r=e.top}const n=e.getBoundingClientRect();return{left:n.left,top:n.top,offsetLeft:-t.clientX+n.left-s,offsetTop:-t.clientY+n.top-r,width:n.width,height:n.height}}}e.DDDraggable=n,n.basePosition="absolute",n.dragEventListenerOption=!0,n.originStyleProp=["transition","pointerEvents","position","left","top","opacity","zIndex","width","height","willChange"]},54:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0});const s=i(849),o=i(861),r=i(943);class n extends o.DDBaseImplement{constructor(t,e={}){super(),this.el=t,this.option=e,this._dragEnter=this._dragEnter.bind(this),this._dragOver=this._dragOver.bind(this),this._dragLeave=this._dragLeave.bind(this),this._drop=this._drop.bind(this),this.el.classList.add("ui-droppable"),this.el.addEventListener("dragenter",this._dragEnter),this._setupAccept()}on(t,e){super.on(t,e)}off(t){super.off(t)}enable(){this.disabled&&(super.enable(),this.el.classList.remove("ui-droppable-disabled"),this.el.addEventListener("dragenter",this._dragEnter))}disable(t=!1){this.disabled||(super.disable(),t||this.el.classList.add("ui-droppable-disabled"),this.el.removeEventListener("dragenter",this._dragEnter))}destroy(){this.moving&&this._removeLeaveCallbacks(),this.disable(!0),this.el.classList.remove("ui-droppable"),this.el.classList.remove("ui-droppable-disabled"),delete this.moving,super.destroy()}updateOption(t){return Object.keys(t).forEach((e=>this.option[e]=t[e])),this._setupAccept(),this}_dragEnter(t){if(!this._canDrop())return;if(t.preventDefault(),this.moving)return;this.moving=!0;const e=r.DDUtils.initEvent(t,{target:this.el,type:"dropover"});this.option.over&&this.option.over(e,this._ui(s.DDManager.dragElement)),this.triggerEvent("dropover",e),this.el.addEventListener("dragover",this._dragOver),this.el.addEventListener("drop",this._drop),this.el.addEventListener("dragleave",this._dragLeave),this.el.classList.add("ui-droppable-over")}_dragOver(t){t.preventDefault(),t.stopPropagation()}_dragLeave(t){if(t.relatedTarget){if(this.el.contains(t.relatedTarget))return}else{const{bottom:e,left:i,right:s,top:o}=this.el.getBoundingClientRect();if(t.xi&&t.yo)return}if(this._removeLeaveCallbacks(),this.moving){t.preventDefault();const e=r.DDUtils.initEvent(t,{target:this.el,type:"dropout"});this.option.out&&this.option.out(e,this._ui(s.DDManager.dragElement)),this.triggerEvent("dropout",e)}delete this.moving}_drop(t){if(!this.moving)return;t.preventDefault();const e=r.DDUtils.initEvent(t,{target:this.el,type:"drop"});this.option.drop&&this.option.drop(e,this._ui(s.DDManager.dragElement)),this.triggerEvent("drop",e),this._removeLeaveCallbacks(),delete this.moving}_removeLeaveCallbacks(){this.el.removeEventListener("dragleave",this._dragLeave),this.el.classList.remove("ui-droppable-over"),this.moving&&(this.el.removeEventListener("dragover",this._dragOver),this.el.removeEventListener("drop",this._drop))}_canDrop(){return s.DDManager.dragElement&&(!this.accept||this.accept(s.DDManager.dragElement.el))}_setupAccept(){return this.option.accept&&"string"==typeof this.option.accept?this.accept=t=>t.matches(this.option.accept):this.accept=this.option.accept,this}_ui(t){return Object.assign({draggable:t.el},t.ui())}}e.DDDroppable=n},485:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0});const s=i(97),o=i(311),r=i(54);class n{constructor(t){this.el=t}static init(t){return t.ddElement||(t.ddElement=new n(t)),t.ddElement}on(t,e){return this.ddDraggable&&["drag","dragstart","dragstop"].indexOf(t)>-1?this.ddDraggable.on(t,e):this.ddDroppable&&["drop","dropover","dropout"].indexOf(t)>-1?this.ddDroppable.on(t,e):this.ddResizable&&["resizestart","resize","resizestop"].indexOf(t)>-1&&this.ddResizable.on(t,e),this}off(t){return this.ddDraggable&&["drag","dragstart","dragstop"].indexOf(t)>-1?this.ddDraggable.off(t):this.ddDroppable&&["drop","dropover","dropout"].indexOf(t)>-1?this.ddDroppable.off(t):this.ddResizable&&["resizestart","resize","resizestop"].indexOf(t)>-1&&this.ddResizable.off(t),this}setupDraggable(t){return this.ddDraggable?this.ddDraggable.updateOption(t):this.ddDraggable=new o.DDDraggable(this.el,t),this}cleanDraggable(){return this.ddDraggable&&(this.ddDraggable.destroy(),delete this.ddDraggable),this}setupResizable(t){return this.ddResizable?this.ddResizable.updateOption(t):this.ddResizable=new s.DDResizable(this.el,t),this}cleanResizable(){return this.ddResizable&&(this.ddResizable.destroy(),delete this.ddResizable),this}setupDroppable(t){return this.ddDroppable?this.ddDroppable.updateOption(t):this.ddDroppable=new r.DDDroppable(this.el,t),this}cleanDroppable(){return this.ddDroppable&&(this.ddDroppable.destroy(),delete this.ddDroppable),this}}e.DDElement=n},849:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DDManager=class{}},680:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0});class i{constructor(t,e,i){this.moving=!1,this.host=t,this.dir=e,this.option=i,this._mouseDown=this._mouseDown.bind(this),this._mouseMove=this._mouseMove.bind(this),this._mouseUp=this._mouseUp.bind(this),this._init()}_init(){const t=document.createElement("div");return t.classList.add("ui-resizable-handle"),t.classList.add(`${i.prefix}${this.dir}`),t.style.zIndex="100",t.style.userSelect="none",this.el=t,this.host.appendChild(this.el),this.el.addEventListener("mousedown",this._mouseDown),this}destroy(){return this.moving&&this._mouseUp(this.mouseDownEvent),this.el.removeEventListener("mousedown",this._mouseDown),this.host.removeChild(this.el),delete this.el,delete this.host,this}_mouseDown(t){t.preventDefault(),this.mouseDownEvent=t,document.addEventListener("mousemove",this._mouseMove,!0),document.addEventListener("mouseup",this._mouseUp)}_mouseMove(t){let e=this.mouseDownEvent;!this.moving&&Math.abs(t.x-e.x)+Math.abs(t.y-e.y)>2?(this.moving=!0,this._triggerEvent("start",this.mouseDownEvent)):this.moving&&this._triggerEvent("move",t)}_mouseUp(t){this.moving&&this._triggerEvent("stop",t),document.removeEventListener("mousemove",this._mouseMove,!0),document.removeEventListener("mouseup",this._mouseUp),delete this.moving,delete this.mouseDownEvent}_triggerEvent(t,e){return this.option[t]&&this.option[t](e),this}}e.DDResizableHandle=i,i.prefix="ui-resizable-"},97:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0});const s=i(680),o=i(861),r=i(943),n=i(593);class l extends o.DDBaseImplement{constructor(t,e={}){super(),this._showHandlers=()=>{this.el.classList.remove("ui-resizable-autohide")},this._hideHandlers=()=>{this.el.classList.add("ui-resizable-autohide")},this._ui=()=>{const t=this.el.parentElement.getBoundingClientRect(),e={width:this.originalRect.width,height:this.originalRect.height+this.scrolled,left:this.originalRect.left,top:this.originalRect.top-this.scrolled},i=this.temporalRect||e;return{position:{left:i.left-t.left,top:i.top-t.top},size:{width:i.width,height:i.height}}},this.el=t,this.option=e,this.enable(),this._setupAutoHide(),this._setupHandlers()}on(t,e){super.on(t,e)}off(t){super.off(t)}enable(){super.enable(),this.el.classList.add("ui-resizable"),this.el.classList.remove("ui-resizable-disabled")}disable(){super.disable(),this.el.classList.add("ui-resizable-disabled"),this.el.classList.remove("ui-resizable")}destroy(){this._removeHandlers(),this.option.autoHide&&(this.el.removeEventListener("mouseover",this._showHandlers),this.el.removeEventListener("mouseout",this._hideHandlers)),this.el.classList.remove("ui-resizable"),delete this.el,super.destroy()}updateOption(t){let e=t.handles&&t.handles!==this.option.handles,i=t.autoHide&&t.autoHide!==this.option.autoHide;return Object.keys(t).forEach((e=>this.option[e]=t[e])),e&&(this._removeHandlers(),this._setupHandlers()),i&&this._setupAutoHide(),this}_setupAutoHide(){return this.option.autoHide?(this.el.classList.add("ui-resizable-autohide"),this.el.addEventListener("mouseover",this._showHandlers),this.el.addEventListener("mouseout",this._hideHandlers)):(this.el.classList.remove("ui-resizable-autohide"),this.el.removeEventListener("mouseover",this._showHandlers),this.el.removeEventListener("mouseout",this._hideHandlers)),this}_setupHandlers(){let t=this.option.handles||"e,s,se";return"all"===t&&(t="n,e,s,w,se,sw,ne,nw"),this.handlers=t.split(",").map((t=>t.trim())).map((t=>new s.DDResizableHandle(this.el,t,{start:t=>{this._resizeStart(t)},stop:t=>{this._resizeStop(t)},move:e=>{this._resizing(e,t)}}))),this}_resizeStart(t){this.originalRect=this.el.getBoundingClientRect(),this.scrollEl=n.Utils.getScrollElement(this.el),this.scrollY=this.scrollEl.scrollTop,this.startEvent=t,this._setupHelper(),this._applyChange();const e=r.DDUtils.initEvent(t,{type:"resizestart",target:this.el});return this.option.start&&this.option.start(e,this._ui()),this.el.classList.add("ui-resizable-resizing"),this.triggerEvent("resizestart",e),this}_resizing(t,e){this.scrolled=this.scrollEl.scrollTop-this.scrollY,this.temporalRect=this._getChange(t,e),this._applyChange();const i=r.DDUtils.initEvent(t,{type:"resize",target:this.el});return this.option.resize&&this.option.resize(i,this._ui()),this.triggerEvent("resize",i),this}_resizeStop(t){const e=r.DDUtils.initEvent(t,{type:"resizestop",target:this.el});return this.option.stop&&this.option.stop(e),this.el.classList.remove("ui-resizable-resizing"),this.triggerEvent("resizestop",e),this._cleanHelper(),delete this.startEvent,delete this.originalRect,delete this.temporalRect,delete this.scrollY,delete this.scrolled,this}_setupHelper(){return this.elOriginStyleVal=l._originStyleProp.map((t=>this.el.style[t])),this.parentOriginStylePosition=this.el.parentElement.style.position,window.getComputedStyle(this.el.parentElement).position.match(/static/)&&(this.el.parentElement.style.position="relative"),this.el.style.position=this.option.basePosition||"absolute",this.el.style.opacity="0.8",this.el.style.zIndex="1000",this}_cleanHelper(){return l._originStyleProp.forEach(((t,e)=>{this.el.style[t]=this.elOriginStyleVal[e]||null})),this.el.parentElement.style.position=this.parentOriginStylePosition||null,this}_getChange(t,e){const i=this.startEvent,s={width:this.originalRect.width,height:this.originalRect.height+this.scrolled,left:this.originalRect.left,top:this.originalRect.top-this.scrolled},o=t.clientX-i.clientX,r=t.clientY-i.clientY;e.indexOf("e")>-1?s.width+=o:e.indexOf("w")>-1&&(s.width-=o,s.left+=o),e.indexOf("s")>-1?s.height+=r:e.indexOf("n")>-1&&(s.height-=r,s.top+=r);const n=this._constrainSize(s.width,s.height);return Math.round(s.width)!==Math.round(n.width)&&(e.indexOf("w")>-1&&(s.left+=s.width-n.width),s.width=n.width),Math.round(s.height)!==Math.round(n.height)&&(e.indexOf("n")>-1&&(s.top+=s.height-n.height),s.height=n.height),s}_constrainSize(t,e){const i=this.option.maxWidth||Number.MAX_SAFE_INTEGER,s=this.option.minWidth||t,o=this.option.maxHeight||Number.MAX_SAFE_INTEGER,r=this.option.minHeight||e;return{width:Math.min(i,Math.max(s,t)),height:Math.min(o,Math.max(r,e))}}_applyChange(){let t={left:0,top:0,width:0,height:0};if("absolute"===this.el.style.position){const e=this.el.parentElement,{left:i,top:s}=e.getBoundingClientRect();t={left:i,top:s,width:0,height:0}}return this.temporalRect?(Object.keys(this.temporalRect).forEach((e=>{const i=this.temporalRect[e];this.el.style[e]=i-t[e]+"px"})),this):this}_removeHandlers(){return this.handlers.forEach((t=>t.destroy())),delete this.handlers,this}}e.DDResizable=l,l._originStyleProp=["width","height","position","left","top","opacity","zIndex"]},943:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0});class i{static clone(t){const e=t.cloneNode(!0);return e.removeAttribute("id"),e}static appendTo(t,e){let i;i="string"==typeof e?document.querySelector(e):e,i&&i.appendChild(t)}static setPositionRelative(t){/^(?:r|a|f)/.test(window.getComputedStyle(t).position)||(t.style.position="relative")}static addElStyles(t,e){if(e instanceof Object)for(const i in e)e.hasOwnProperty(i)&&(Array.isArray(e[i])?e[i].forEach((e=>{t.style[i]=e})):t.style[i]=e[i])}static initEvent(t,e){const i={type:e.type},s={button:0,which:0,buttons:1,bubbles:!0,cancelable:!0,target:e.target?e.target:t.target};return t.dataTransfer&&(i.dataTransfer=t.dataTransfer),["altKey","ctrlKey","metaKey","shiftKey"].forEach((e=>i[e]=t[e])),["pageX","pageY","clientX","clientY","screenX","screenY"].forEach((e=>i[e]=t[e])),Object.assign(Object.assign({},i),s)}}e.DDUtils=i,i.isEventSupportPassiveOption=(()=>{let t=!1,e=()=>{};return document.addEventListener("test",e,{get passive(){return t=!0,!0}}),document.removeEventListener("test",e),t})()},761:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0});const s=i(849),o=i(485),r=i(21),n=i(593);!function(t){for(var i in t)e.hasOwnProperty(i)||(e[i]=t[i])}(i(21));class l extends r.GridStackDD{resizable(t,e,i,s){return this._getDDElements(t).forEach((t=>{if("disable"===e||"enable"===e)t.ddResizable&&t.ddResizable[e]();else if("destroy"===e)t.ddResizable&&t.cleanResizable();else if("option"===e)t.setupResizable({[i]:s});else{const i=t.el.gridstackNode.grid;let s=t.el.getAttribute("gs-resize-handles")?t.el.getAttribute("gs-resize-handles"):i.opts.resizable.handles;t.setupResizable(Object.assign(Object.assign(Object.assign({},i.opts.resizable),{handles:s}),{start:e.start,stop:e.stop,resize:e.resize}))}})),this}draggable(t,e,i,s){return this._getDDElements(t).forEach((t=>{if("disable"===e||"enable"===e)t.ddDraggable&&t.ddDraggable[e]();else if("destroy"===e)t.ddDraggable&&t.cleanDraggable();else if("option"===e)t.setupDraggable({[i]:s});else{const i=t.el.gridstackNode.grid;t.setupDraggable(Object.assign(Object.assign({},i.opts.draggable),{containment:i.opts._isNested&&!i.opts.dragOut?i.el.parentElement:i.opts.draggable.containment||null,start:e.start,stop:e.stop,drag:e.drag}))}})),this}dragIn(t,e){return this._getDDElements(t).forEach((t=>t.setupDraggable(e))),this}droppable(t,e,i,s){return"function"!=typeof e.accept||e._accept||(e._accept=e.accept,e.accept=t=>e._accept(t)),this._getDDElements(t).forEach((t=>{"disable"===e||"enable"===e?t.ddDroppable&&t.ddDroppable[e]():"destroy"===e?t.ddDroppable&&t.cleanDroppable():"option"===e?t.setupDroppable({[i]:s}):t.setupDroppable(e)})),this}isDroppable(t){return!(!(t&&t.ddElement&&t.ddElement.ddDroppable)||t.ddElement.ddDroppable.disabled)}isDraggable(t){return!(!(t&&t.ddElement&&t.ddElement.ddDraggable)||t.ddElement.ddDraggable.disabled)}isResizable(t){return!(!(t&&t.ddElement&&t.ddElement.ddResizable)||t.ddElement.ddResizable.disabled)}on(t,e,i){return this._getDDElements(t).forEach((t=>t.on(e,(t=>{i(t,s.DDManager.dragElement?s.DDManager.dragElement.el:t.target,s.DDManager.dragElement?s.DDManager.dragElement.helper:null)})))),this}off(t,e){return this._getDDElements(t).forEach((t=>t.off(e))),this}_getDDElements(t,e=!0){let i=n.Utils.getElements(t);if(!i.length)return[];let s=i.map((t=>t.ddElement||(e?o.DDElement.init(t):null)));return e||s.filter((t=>t)),s}}e.GridStackDDNative=l,r.GridStackDD.registerPlugin(l)},593:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.obsolete=function(t,e,i,s,o){let r=(...r)=>(console.warn("gridstack.js: Function `"+i+"` is deprecated in "+o+" and has been replaced with `"+s+"`. It will be **completely** removed in v1.0"),e.apply(t,r));return r.prototype=e.prototype,r},e.obsoleteOpts=function(t,e,i,s){void 0!==t[e]&&(t[i]=t[e],console.warn("gridstack.js: Option `"+e+"` is deprecated in "+s+" and has been replaced with `"+i+"`. It will be **completely** removed in v1.0"))},e.obsoleteOptsDel=function(t,e,i,s){void 0!==t[e]&&console.warn("gridstack.js: Option `"+e+"` is deprecated in "+i+s)},e.obsoleteAttr=function(t,e,i,s){let o=t.getAttribute(e);null!==o&&(t.setAttribute(i,o),console.warn("gridstack.js: attribute `"+e+"`="+o+" is deprecated on this object in "+s+" and has been replaced with `"+i+"`. It will be **completely** removed in v1.0"))};class i{static getElements(t){if("string"==typeof t){let e=document.querySelectorAll(t);return e.length||"."===t[0]||"#"===t[0]||(e=document.querySelectorAll("."+t),e.length||(e=document.querySelectorAll("#"+t))),Array.from(e)}return[t]}static getElement(t){if("string"==typeof t){if(!t.length)return null;if("#"===t[0])return document.getElementById(t.substring(1));if("."===t[0]||"["===t[0])return document.querySelector(t);if(!isNaN(+t[0]))return document.getElementById(t);let e=document.querySelector(t);return e||(e=document.getElementById(t)),e||(e=document.querySelector("."+t)),e}return t}static isIntercepted(t,e){return!(t.y>=e.y+e.h||t.y+t.h<=e.y||t.x+t.w<=e.x||t.x>=e.x+e.w)}static isTouching(t,e){return i.isIntercepted(t,{x:e.x-.5,y:e.y-.5,w:e.w+1,h:e.h+1})}static sort(t,e,i){return i=i||t.reduce(((t,e)=>Math.max(e.x+e.w,t)),0)||12,-1===e?t.sort(((t,e)=>e.x+e.y*i-(t.x+t.y*i))):t.sort(((t,e)=>t.x+t.y*i-(e.x+e.y*i)))}static createStylesheet(t,e){let i=document.createElement("style");return i.setAttribute("type","text/css"),i.setAttribute("gs-style-id",t),i.styleSheet?i.styleSheet.cssText="":i.appendChild(document.createTextNode("")),e?e.insertBefore(i,e.firstChild):(e=document.getElementsByTagName("head")[0]).appendChild(i),i.sheet}static removeStylesheet(t){let e=document.querySelector("STYLE[gs-style-id="+t+"]");e&&e.parentNode&&e.remove()}static addCSSRule(t,e,i){"function"==typeof t.addRule?t.addRule(e,i):"function"==typeof t.insertRule&&t.insertRule(`${e}{${i}}`)}static toBool(t){return"boolean"==typeof t?t:"string"==typeof t?!(""===(t=t.toLowerCase())||"no"===t||"false"===t||"0"===t):Boolean(t)}static toNumber(t){return null===t||0===t.length?void 0:Number(t)}static parseHeight(t){let e,i="px";if("string"==typeof t){let s=t.match(/^(-[0-9]+\.[0-9]+|[0-9]*\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw|%)?$/);if(!s)throw new Error("Invalid height");i=s[2]||"px",e=parseFloat(s[1])}else e=t;return{h:e,unit:i}}static defaults(t,...e){return e.forEach((e=>{for(const i in e){if(!e.hasOwnProperty(i))return;null===t[i]||void 0===t[i]?t[i]=e[i]:"object"==typeof e[i]&&"object"==typeof t[i]&&this.defaults(t[i],e[i])}})),t}static same(t,e){if("object"!=typeof t)return t==e;if(typeof t!=typeof e)return!1;if(Object.keys(t).length!==Object.keys(e).length)return!1;for(const i in t)if(t[i]!==e[i])return!1;return!0}static copyPos(t,e,i=!1){return t.x=e.x,t.y=e.y,t.w=e.w,t.h=e.h,i?(e.minW&&(t.minW=e.minW),e.minH&&(t.minH=e.minH),e.maxW&&(t.maxW=e.maxW),e.maxH&&(t.maxH=e.maxH),t):t}static samePos(t,e){return t&&e&&t.x===e.x&&t.y===e.y&&t.w===e.w&&t.h===e.h}static removeInternalAndSame(t,e){if("object"==typeof t&&"object"==typeof e)for(let i in t){let s=t[i];if(s&&"object"==typeof s&&void 0!==e[i]){for(let t in s)s[t]!==e[i][t]&&"_"!==t[0]||delete s[t];Object.keys(s).length||delete t[i]}else s!==e[i]&&"_"!==i[0]||delete t[i]}}static closestByClass(t,e){for(;t=t.parentElement;)if(t.classList.contains(e))return t;return null}static throttle(t,e){let i=!1;return(...s)=>{i||(i=!0,setTimeout((()=>{t(...s),i=!1}),e))}}static removePositioningStyles(t){let e=t.style;e.position&&e.removeProperty("position"),e.left&&e.removeProperty("left"),e.top&&e.removeProperty("top"),e.width&&e.removeProperty("width"),e.height&&e.removeProperty("height")}static getScrollElement(t){if(!t)return document.scrollingElement;const e=getComputedStyle(t);return/(auto|scroll)/.test(e.overflow+e.overflowY)?t:this.getScrollElement(t.parentElement)}static updateScrollPosition(t,e,i){let s=t.getBoundingClientRect(),o=window.innerHeight||document.documentElement.clientHeight;if(s.top<0||s.bottom>o){let r=s.bottom-o,n=s.top,l=this.getScrollElement(t);if(null!==l){let a=l.scrollTop;s.top<0&&i<0?t.offsetHeight>o?l.scrollTop+=i:l.scrollTop+=Math.abs(n)>Math.abs(i)?i:n:i>0&&(t.offsetHeight>o?l.scrollTop+=i:l.scrollTop+=r>i?i:r),e.top+=l.scrollTop-a}}}static updateScrollResize(t,e,i){const s=this.getScrollElement(e),o=s.clientHeight,r=s===this.getScrollElement()?0:s.getBoundingClientRect().top,n=t.clientY-r,l=n>o-i;n{"use strict";var t={21:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.GridStackDD=void 0;const s=i(334),o=i(270),r=i(593);class n extends s.GridStackDDI{static get(){return s.GridStackDDI.get()}remove(t){return this.draggable(t,"destroy").resizable(t,"destroy"),t.gridstackNode&&delete t.gridstackNode._initDD,this}}function l(t,e){let 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=n,o.GridStack.prototype._setupAcceptWidget=function(){if(this.opts.staticGrid||!this.opts.acceptWidgets&&!this.opts.removable)return n.get().droppable(this.el,"destroy"),this;let t,e,i,s=(s,o,l)=>{let a=o.gridstackNode;if(!a)return;let h=(l=l||o).getBoundingClientRect(),d=h.left-t.left,g=h.top-t.top,p={position:{top:g,left:d}};if(a._temporaryRemoved){if(a.x=Math.max(0,Math.round(d/i)),a.y=Math.max(0,Math.round(g/e)),delete a.autoPosition,this.engine.nodeBoundFix(a),!this.engine.willItFit(a)){if(a.autoPosition=!0,!this.engine.willItFit(a))return void n.get().off(o,"drag");a._willFitPos&&(r.Utils.copyPos(a,a._willFitPos),delete a._willFitPos)}this._onStartMoving(l,s,p,a,i,e)}else this._dragOrResize(l,s,p,a,i,e)};return n.get().droppable(this.el,{accept:t=>{let e=t.gridstackNode;if(e&&e.grid===this)return!0;if(!this.opts.acceptWidgets)return!1;let i=!0;if("function"==typeof this.opts.acceptWidgets)i=this.opts.acceptWidgets(t);else{let e=!0===this.opts.acceptWidgets?".grid-stack-item":this.opts.acceptWidgets;i=t.matches(e)}if(i&&e&&this.opts.maxRow){let t={w:e.w,h:e.h,minW:e.minW,minH:e.minH};i=this.engine.willItFit(t)}return i}}).on(this.el,"dropover",((o,r,a)=>{let h=r.gridstackNode;if(h&&h.grid===this&&!h._temporaryRemoved)return!1;h&&h.grid&&h.grid!==this&&!h._temporaryRemoved&&h.grid._leave(r,a);let d=this.el.getBoundingClientRect();t={top:d.top,left:d.left},i=this.cellWidth(),e=this.getCellHeight(!0),h||(h=this._readAttr(r)),h.grid||(h._isExternal=!0,r.gridstackNode=h),a=a||r;let g=h.w||Math.round(a.offsetWidth/i)||1,p=h.h||Math.round(a.offsetHeight/e)||1;return h.grid&&h.grid!==this?(r._gridstackNodeOrig||(r._gridstackNodeOrig=h),r.gridstackNode=h=Object.assign(Object.assign({},h),{w:g,h:p,grid:this}),this.engine.cleanupNode(h).nodeBoundFix(h),h._initDD=h._isExternal=h._temporaryRemoved=!0):(h.w=g,h.h=p,h._temporaryRemoved=!0),l(h.el,!1),n.get().on(r,"drag",s),s(o,r,a),!1})).on(this.el,"dropout",((t,e,i)=>{let s=e.gridstackNode;return s.grid&&s.grid!==this||this._leave(e,i),!1})).on(this.el,"drop",((t,e,i)=>{let s=e.gridstackNode;if(s&&s.grid===this&&!s._isExternal)return!1;let o=!!this.placeholder.parentElement;this.placeholder.remove();let l=e._gridstackNodeOrig;if(delete e._gridstackNodeOrig,o&&l&&l.grid&&l.grid!==this){let t=l.grid;t.engine.removedNodes.push(l),t._triggerRemoveEvent()}return!!s&&(o&&(this.engine.cleanupNode(s),s.grid=this),n.get().off(e,"drag"),i!==e?(i.remove(),e.gridstackNode=l,o&&(e=e.cloneNode(!0))):(e.remove(),n.get().remove(e)),!!o&&(e.gridstackNode=s,s.el=e,r.Utils.copyPos(s,this._readAttr(this.placeholder)),r.Utils.removePositioningStyles(e),this._writeAttr(e,s),this.el.appendChild(e),this._updateContainerHeight(),this.engine.addedNodes.push(s),this._triggerAddEvent(),this._triggerChangeEvent(),this.engine.endUpdate(),this._gsEventHandler.dropped&&this._gsEventHandler.dropped({type:"dropped"},l&&l.grid?l:void 0,s),window.setTimeout((()=>{s.el&&s.el.parentElement?this._prepareDragDropByNode(s):this.engine.removeNode(s)})),!1))})),this},o.GridStack.prototype._setupRemoveDrop=function(){if(!this.opts.staticGrid&&"string"==typeof this.opts.removable){let t=document.querySelector(this.opts.removable);if(!t)return this;n.get().isDroppable(t)||n.get().droppable(t,this.opts.removableOptions).on(t,"dropover",((t,e)=>l(e,!0))).on(t,"dropout",((t,e)=>l(e,!1)))}return this},o.GridStack.setupDragIn=function(t,e){let i,s;if(t&&(i=t,s=Object.assign(Object.assign({},{revert:"invalid",handle:".grid-stack-item-content",scroll:!1,appendTo:"body"}),e||{})),"string"!=typeof i)return;let o=n.get();r.Utils.getElements(i).forEach((t=>{o.isDraggable(t)||o.dragIn(t,s)}))},o.GridStack.prototype._prepareDragDropByNode=function(t){let e=t.el,i=n.get();if(this.opts.staticGrid||(t.noMove||this.opts.disableDrag)&&(t.noResize||this.opts.disableResize))return t._initDD&&(i.remove(e),delete t._initDD),e.classList.add("ui-draggable-disabled","ui-resizable-disabled"),this;if(!t._initDD){let s,o,n=(i,r)=>{this._gsEventHandler[i.type]&&this._gsEventHandler[i.type](i,i.target),s=this.cellWidth(),o=this.getCellHeight(!0),this._onStartMoving(e,i,r,t,s,o)},l=(i,r)=>{this._dragOrResize(e,i,r,t,s,o)},a=s=>{this.placeholder.remove(),delete t._moving,delete t._lastTried;let o=s.target;if(o.gridstackNode&&o.gridstackNode.grid===this){if(t.el=o,t._isAboutToRemove){let r=e.gridstackNode.grid;r._gsEventHandler[s.type]&&r._gsEventHandler[s.type](s,o),i.remove(e),r.engine.removedNodes.push(t),r._triggerRemoveEvent(),delete e.gridstackNode,delete t.el,e.remove()}else t._temporaryRemoved?(r.Utils.removePositioningStyles(o),r.Utils.copyPos(t,t._orig),this._writePosAttr(o,t),this.engine.addNode(t)):(r.Utils.removePositioningStyles(o),this._writePosAttr(o,t)),this._gsEventHandler[s.type]&&this._gsEventHandler[s.type](s,o);this._extraDragRow=0,this._updateContainerHeight(),this._triggerChangeEvent(),this.engine.endUpdate()}};i.draggable(e,{start:n,stop:a,drag:l}).resizable(e,{start:n,stop:a,resize:l}),t._initDD=!0}return t.noMove||this.opts.disableDrag?(i.draggable(e,"disable"),e.classList.add("ui-draggable-disabled")):(i.draggable(e,"enable"),e.classList.remove("ui-draggable-disabled")),t.noResize||this.opts.disableResize?(i.resizable(e,"disable"),e.classList.add("ui-resizable-disabled")):(i.resizable(e,"enable"),e.classList.remove("ui-resizable-disabled")),this},o.GridStack.prototype._onStartMoving=function(t,e,i,s,o,r){if(this.engine.cleanNodes().beginUpdate(s),this._writePosAttr(this.placeholder,s),this.el.appendChild(this.placeholder),s.el=this.placeholder,s._lastUiPosition=i.position,s._prevYPix=i.position.top,s._moving="dragstart"===e.type,delete s._lastTried,"dropover"===e.type&&s._temporaryRemoved&&(this.engine.addNode(s),s._moving=!0),this.engine.cacheRects(o,r,this.opts.marginTop,this.opts.marginRight,this.opts.marginBottom,this.opts.marginLeft),"resizestart"===e.type){let e=n.get().resizable(t,"option","minWidth",o*(s.minW||1)).resizable(t,"option","minHeight",r*(s.minH||1));s.maxW&&e.resizable(t,"option","maxWidth",o*s.maxW),s.maxH&&e.resizable(t,"option","maxHeight",r*s.maxH)}},o.GridStack.prototype._leave=function(t,e){let i=t.gridstackNode;i&&(n.get().off(t,"drag"),i._temporaryRemoved||(i._temporaryRemoved=!0,this.engine.removeNode(i),i.el=i._isExternal&&e?e:t,!0===this.opts.removable&&l(t,!0),t._gridstackNodeOrig?(t.gridstackNode=t._gridstackNodeOrig,delete t._gridstackNodeOrig):i._isExternal&&(delete i.el,delete t.gridstackNode,this.engine.restoreInitial())))},o.GridStack.prototype._dragOrResize=function(t,e,i,s,o,n){let l,a=Object.assign({},s._orig);const h=this.opts.marginLeft,d=this.opts.marginRight,g=this.opts.marginTop,p=this.opts.marginBottom;if("drag"===e.type){if(s._temporaryRemoved)return;let e=i.position.top-s._prevYPix;s._prevYPix=i.position.top,r.Utils.updateScrollPosition(t,i.position,e);let l=i.position.left+(i.position.left>s._lastUiPosition.left?-d:h),c=i.position.top+(i.position.top>s._lastUiPosition.top?-p:g);a.x=Math.round(l/o),a.y=Math.round(c/n);let u=this._extraDragRow;if(this.engine.collide(s,a)){let t=this.getRow(),e=Math.max(0,a.y+s.h-t);this.opts.maxRow&&t+e>this.opts.maxRow&&(e=Math.max(0,this.opts.maxRow-t)),this._extraDragRow=e}else this._extraDragRow=0;if(this._extraDragRow!==u&&this._updateContainerHeight(),s.x===a.x&&s.y===a.y)return}else if("resize"===e.type){if(a.x<0)return;if(r.Utils.updateScrollResize(e,t,n),a.w=Math.round((i.size.width-h)/o),a.h=Math.round((i.size.height-g)/n),s.w===a.w&&s.h===a.h)return;if(s._lastTried&&s._lastTried.w===a.w&&s._lastTried.h===a.h)return;let d=i.position.left+h,p=i.position.top+g;a.x=Math.round(d/o),a.y=Math.round(p/n),l=!0}s._lastTried=a;let c={x:i.position.left+h,y:i.position.top+g,w:(i.size?i.size.width:s.w*o)-h-d,h:(i.size?i.size.height:s.h*n)-g-p};if(this.engine.moveNodeCheck(s,Object.assign(Object.assign({},a),{cellWidth:o,cellHeight:n,rect:c}))){s._lastUiPosition=i.position,this.engine.cacheRects(o,n,g,d,p,h),delete s._skipDown,l&&s.subGrid&&s.subGrid.onParentResize(),this._extraDragRow=0,this._updateContainerHeight();let t=e.target;this._writePosAttr(t,s),this._gsEventHandler[e.type]&&this._gsEventHandler[e.type](e,t)}},o.GridStack.prototype.movable=function(t,e){return this.opts.staticGrid||o.GridStack.getElements(t).forEach((t=>{let i=t.gridstackNode;i&&(e?delete i.noMove:i.noMove=!0,this._prepareDragDropByNode(i))})),this},o.GridStack.prototype.resizable=function(t,e){return this.opts.staticGrid||o.GridStack.getElements(t).forEach((t=>{let i=t.gridstackNode;i&&(e?delete i.noResize:i.noResize=!0,this._prepareDragDropByNode(i))})),this},o.GridStack.prototype.disable=function(){if(!this.opts.staticGrid)return this.enableMove(!1),this.enableResize(!1),this._triggerEvent("disable"),this},o.GridStack.prototype.enable=function(){if(!this.opts.staticGrid)return this.enableMove(!0),this.enableResize(!0),this._triggerEvent("enable"),this},o.GridStack.prototype.enableMove=function(t){return this.opts.staticGrid||(this.opts.disableDrag=!t,this.engine.nodes.forEach((e=>this.movable(e.el,t)))),this},o.GridStack.prototype.enableResize=function(t){return this.opts.staticGrid||(this.opts.disableResize=!t,this.engine.nodes.forEach((e=>this.resizable(e.el,t)))),this}},334:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.GridStackDDI=void 0;class i{static registerPlugin(t){return i.ddi=new t,i.ddi}static get(){return i.ddi||i.registerPlugin(i)}remove(t){return this}}e.GridStackDDI=i},62:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.GridStackEngine=void 0;const s=i(593);class o{constructor(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||[]}batchUpdate(){return this.batchMode||(this.batchMode=!0,this._prevFloat=this._float,this._float=!0,this.saveInitial()),this}commit(){return this.batchMode?(this.batchMode=!1,this._float=this._prevFloat,delete this._prevFloat,this._packNodes()._notify()):this}_useEntireRowArea(t,e){return!this.float&&!this._hasLocked&&(!t._moving||t._skipDown||e.y<=t.y)}_fixCollisions(t,e=t,i,o={}){if(this._sortNodes(-1),!(i=i||this.collide(t,e)))return!1;if(t._moving&&!o.nested&&!this.float&&this.swap(t,i))return!0;let r=e;this._useEntireRowArea(t,e)&&(r={x:0,w:this.column,y:e.y,h:e.h},i=this.collide(t,r,o.skip));let n=!1,l={nested:!0,pack:!1};for(;i=i||this.collide(t,r,o.skip);){let r;if(i.locked||t._moving&&!t._skipDown&&e.y>t.y&&!this.float&&(!this.collide(i,Object.assign(Object.assign({},i),{y:t.y}),t)||!this.collide(i,Object.assign(Object.assign({},i),{y:e.y-i.h}),t))?(t._skipDown=t._skipDown||e.y>t.y,r=this.moveNode(t,Object.assign(Object.assign(Object.assign({},e),{y:i.y+i.h}),l)),i.locked&&r?s.Utils.copyPos(e,t):!i.locked&&r&&o.pack&&(this._packNodes(),e.y=i.y+i.h,s.Utils.copyPos(t,e)),n=n||r):r=this.moveNode(i,Object.assign(Object.assign(Object.assign({},i),{y:e.y+e.h,skip:t}),l)),!r)return n;i=void 0}return n}collide(t,e=t,i){return this.nodes.find((o=>o!==t&&o!==i&&s.Utils.isIntercepted(o,e)))}collideAll(t,e=t,i){return this.nodes.filter((o=>o!==t&&o!==i&&s.Utils.isIntercepted(o,e)))}collideCoverage(t,e,i){if(!e.rect||!t._rect)return;let s,o=t._rect,r=Object.assign({},e.rect);return r.y>o.y?(r.h+=r.y-o.y,r.y=o.y):r.h+=o.y-r.y,r.x>o.x?(r.w+=r.x-o.x,r.x=o.x):r.w+=o.x-r.x,i.forEach((t=>{if(t.locked||!t._rect)return;let e=t._rect,i=Number.MAX_VALUE,n=Number.MAX_VALUE,l=.5;o.ye.y+e.h&&(i=(e.y+e.h-r.y)/e.h),o.xe.x+e.w&&(n=(e.x+e.w-r.x)/e.w);let a=Math.min(n,i);a>l&&(l=a,s=t)})),s}cacheRects(t,e,i,s,o,r){return this.nodes.forEach((n=>n._rect={y:n.y*e+i,x:n.x*t+r,w:n.w*t-r-s,h:n.h*e-i-o})),this}swap(t,e){if(!e||e.locked||!t||t.locked)return!1;function i(){let i=e.x,s=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.x=i,t.y=s),t._dirty=e._dirty=!0,!0}let o;if(t.w===e.w&&t.h===e.h&&(t.x===e.x||t.y===e.y)&&(o=s.Utils.isTouching(t,e)))return i();if(!1!==o){if(t.w===e.w&&t.x===e.x&&(o||s.Utils.isTouching(t,e))){if(e.y{t.locked||(t.autoPosition=!0),this.addNode(t,!1),t._dirty=!0})),this.commit()}set float(t){this._float!==t&&(this._float=t||!1,t||this._packNodes()._notify())}get float(){return this._float||!1}_sortNodes(t){return this.nodes=s.Utils.sort(this.nodes,t,this.column),this}_packNodes(){return this._sortNodes(),this.float?this.nodes.forEach((t=>{if(t._updating||void 0===t._orig||t.y===t._orig.y)return;let e=t.y;for(;e>t._orig.y;)--e,this.collide(t,{x:t.x,y:e,w:t.w,h:t.h})||(t._dirty=!0,t.y=e)})):this.nodes.forEach(((t,e)=>{if(!t.locked)for(;t.y>0;){let i=0===e?0:t.y-1;if(0!==e&&this.collide(t,{x:t.x,y:i,w:t.w,h:t.h}))break;t._dirty=t.y!==i,t.y=i}})),this}prepareNode(t,e){(t=t||{})._id=t._id||o._idSeq++,void 0!==t.x&&void 0!==t.y&&null!==t.x&&null!==t.y||(t.autoPosition=!0);let i={x:0,y:0,w:1,h:1};return s.Utils.defaults(t,i),t.autoPosition||delete t.autoPosition,t.noResize||delete t.noResize,t.noMove||delete t.noMove,"string"==typeof t.x&&(t.x=Number(t.x)),"string"==typeof t.y&&(t.y=Number(t.y)),"string"==typeof t.w&&(t.w=Number(t.w)),"string"==typeof t.h&&(t.h=Number(t.h)),isNaN(t.x)&&(t.x=i.x,t.autoPosition=!0),isNaN(t.y)&&(t.y=i.y,t.autoPosition=!0),isNaN(t.w)&&(t.w=i.w),isNaN(t.h)&&(t.h=i.h),this.nodeBoundFix(t,e)}nodeBoundFix(t,e){return t.maxW&&(t.w=Math.min(t.w,t.maxW)),t.maxH&&(t.h=Math.min(t.h,t.maxH)),t.minW&&(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&&(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),t}getDirtyNodes(t){return t?this.nodes.filter((t=>t._dirty&&!s.Utils.samePos(t,t._orig))):this.nodes.filter((t=>t._dirty))}_notify(t,e=!0){if(this.batchMode)return this;let i=(t=void 0===t?[]:Array.isArray(t)?t:[t]).concat(this.getDirtyNodes());return this.onChange&&this.onChange(i,e),this}cleanNodes(){return this.batchMode||this.nodes.forEach((t=>{delete t._dirty,delete t._lastTried})),this}saveInitial(){return this.nodes.forEach((t=>{t._orig=s.Utils.copyPos({},t),delete t._dirty})),this._hasLocked=this.nodes.some((t=>t.locked)),this}restoreInitial(){return this.nodes.forEach((t=>{s.Utils.samePos(t,t._orig)||(s.Utils.copyPos(t,t._orig),t._dirty=!0)})),this._notify(),this}addNode(t,e=!1){let i;if(i=this.nodes.find((e=>e._id===t._id)))return i;if(delete(t=this.prepareNode(t))._temporaryRemoved,delete t._removeDOM,t.autoPosition){this._sortNodes();for(let e=0;;++e){let i=e%this.column,o=Math.floor(e/this.column);if(i+t.w>this.column)continue;let r={x:i,y:o,w:t.w,h:t.h};if(!this.nodes.find((t=>s.Utils.isIntercepted(r,t)))){t.x=i,t.y=o,delete t.autoPosition;break}}}return this.nodes.push(t),e&&this.addedNodes.push(t),this._fixCollisions(t),this._packNodes()._notify(),t}removeNode(t,e=!0,i=!1){return this.nodes.find((e=>e===t))?(i&&this.removedNodes.push(t),e&&(t._removeDOM=!0),this.nodes=this.nodes.filter((e=>e!==t)),this._packNodes()._notify(t)):this}removeAll(t=!0){return delete this._layouts,0===this.nodes.length?this:(t&&this.nodes.forEach((t=>t._removeDOM=!0)),this.removedNodes=this.nodes,this.nodes=[],this._notify(this.removedNodes))}moveNodeCheck(t,e){if(!this.changedPosConstrain(t,e))return!1;if(e.pack=!0,!this.maxRow)return this.moveNode(t,e);let i,r=new o({column:this.column,float:this.float,nodes:this.nodes.map((e=>e===t?(i=Object.assign({},e),i):Object.assign({},e)))});if(!i)return!1;let n=r.moveNode(i,e);if(this.maxRow&&n&&(n=r.getRow()<=this.maxRow,!n)){let i=this.collide(t,e);if(i&&this.swap(t,i))return this._notify(),!0}return!!n&&(r.nodes.filter((t=>t._dirty)).forEach((t=>{let e=this.nodes.find((e=>e._id===t._id));e&&(s.Utils.copyPos(e,t),e._dirty=!0)})),this._notify(),!0)}willItFit(t){if(delete t._willFitPos,!this.maxRow)return!0;let e=new o({column:this.column,float:this.float,nodes:this.nodes.map((t=>Object.assign({},t)))}),i=Object.assign({},t);return this.cleanupNode(i),delete i.el,delete i._id,delete i.content,delete i.grid,e.addNode(i),e.getRow()<=this.maxRow&&(t._willFitPos=s.Utils.copyPos({},i),!0)}changedPosConstrain(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)}moveNode(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);let i=t.w!==e.w||t.h!==e.h,o=s.Utils.copyPos({},t,!0);if(s.Utils.copyPos(o,e),o=this.nodeBoundFix(o,i),s.Utils.copyPos(e,o),s.Utils.samePos(t,e))return!1;let r=s.Utils.copyPos({},t),n=o,l=this.collideAll(t,n,e.skip),a=!0;if(l.length){let i=t._moving&&!e.nested?this.collideCoverage(t,e,l):l[0];a=!!i&&!this._fixCollisions(t,o,i,e)}return a&&(t._dirty=!0,s.Utils.copyPos(t,o)),e.pack&&this._packNodes()._notify(),!s.Utils.samePos(t,r)}getRow(){return this.nodes.reduce(((t,e)=>Math.max(t,e.y+e.h)),0)}beginUpdate(t){return t._updating||(t._updating=!0,delete t._skipDown,this.batchMode||this.saveInitial()),this}endUpdate(){let t=this.nodes.find((t=>t._updating));return t&&(delete t._updating,delete t._skipDown),this}save(t=!0){let e=[];return this._sortNodes(),this.nodes.forEach((i=>{let s={};for(let t in i)"_"!==t[0]&&null!==i[t]&&void 0!==i[t]&&(s[t]=i[t]);delete s.grid,t||delete s.el,s.autoPosition||delete s.autoPosition,s.noResize||delete s.noResize,s.noMove||delete s.noMove,s.locked||delete s.locked,e.push(s)})),e}layoutsNodesChange(t){return!this._layouts||this._ignoreLayoutsNodeChange||this._layouts.forEach(((e,i)=>{if(!e||i===this.column)return this;i{if(!t._orig)return;let s=e.find((e=>e._id===t._id));if(!s)return;let o=i/this.column;t.y!==t._orig.y&&(s.y+=t.y-t._orig.y),t.x!==t._orig.x&&(s.x=Math.round(t.x*o)),t.w!==t._orig.w&&(s.w=Math.round(t.w*o))}))})),this}updateNodeWidths(t,e,i,o="moveScale"){if(!this.nodes.length||t===e)return this;if(this.cacheLayout(this.nodes,t),1===e&&i&&i.length){let t=0;i.forEach((e=>{e.x=0,e.w=1,e.y=Math.max(e.y,t),t=e.y+e.h}))}else i=s.Utils.sort(this.nodes,-1,t);let r=this._layouts[e]||[],n=this._layouts.length-1;0===r.length&&e>t&&e{let e=i.findIndex((e=>e._id===t._id));-1!==e&&(i[e].x=t.x,i[e].y=t.y,i[e].w=t.w)})),r=[]));let l=[];if(r.forEach((t=>{let e=i.findIndex((e=>e._id===t._id));-1!==e&&(i[e].x=t.x,i[e].y=t.y,i[e].w=t.w,l.push(i[e]),i.splice(e,1))})),i.length)if("function"==typeof o)o(e,t,l,i);else{let s=e/t,r="move"===o||"moveScale"===o,n="scale"===o||"moveScale"===o;i.forEach((i=>{i.x=1===e?0:r?Math.round(i.x*s):Math.min(i.x,e-1),i.w=1===e||1===t?1:n?Math.round(i.w*s)||1:Math.min(i.w,e),l.push(i)})),i=[]}return l=s.Utils.sort(l,-1,e),this._ignoreLayoutsNodeChange=!0,this.batchUpdate(),this.nodes=[],l.forEach((t=>{this.addNode(t,!1),t._dirty=!0}),this),this.commit(),delete this._ignoreLayoutsNodeChange,this}cacheLayout(t,e,i=!1){let s=[];return t.forEach(((t,e)=>{t._id=t._id||o._idSeq++,s[e]={x:t.x,y:t.y,w:t.w,_id:t._id}})),this._layouts=i?[]:this._layouts||[],this._layouts[e]=s,this}cacheOneLayout(t,e){t._id=t._id||o._idSeq++;let i={x:t.x,y:t.y,w:t.w,_id:t._id};this._layouts=this._layouts||[],this._layouts[e]=this._layouts[e]||[];let s=this._layouts[e].findIndex((e=>e._id===t._id));return-1===s?this._layouts[e].push(i):this._layouts[e][s]=i,this}cleanupNode(t){for(let e in t)"_"===e[0]&&"_id"!==e&&delete t[e];return this}}e.GridStackEngine=o,o._idSeq=1},930:function(t,e,i){var s=this&&this.__createBinding||(Object.create?function(t,e,i,s){void 0===s&&(s=i),Object.defineProperty(t,s,{enumerable:!0,get:function(){return e[i]}})}:function(t,e,i,s){void 0===s&&(s=i),t[s]=e[i]}),o=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||e.hasOwnProperty(i)||s(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),o(i(699),e),o(i(593),e),o(i(62),e),o(i(334),e),o(i(270),e),o(i(761),e)},270:function(t,e,i){var s=this&&this.__createBinding||(Object.create?function(t,e,i,s){void 0===s&&(s=i),Object.defineProperty(t,s,{enumerable:!0,get:function(){return e[i]}})}:function(t,e,i,s){void 0===s&&(s=i),t[s]=e[i]}),o=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||e.hasOwnProperty(i)||s(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),e.GridStack=void 0;const r=i(62),n=i(593),l=i(334);o(i(699),e),o(i(593),e),o(i(62),e),o(i(334),e);const a={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};class h{constructor(t,e={}){this._gsEventHandler={},this._extraDragRow=0,this.el=t,(e=e||{}).row&&(e.minRow=e.maxRow=e.row,delete e.row);let i=n.Utils.toNumber(t.getAttribute("gs-row")),s=Object.assign(Object.assign({},n.Utils.cloneDeep(a)),{column:n.Utils.toNumber(t.getAttribute("gs-column"))||12,minRow:i||n.Utils.toNumber(t.getAttribute("gs-min-row"))||0,maxRow:i||n.Utils.toNumber(t.getAttribute("gs-max-row"))||0,staticGrid:n.Utils.toBool(t.getAttribute("gs-static"))||!1,_styleSheetClass:"grid-stack-instance-"+(1e4*Math.random()).toFixed(0),alwaysShowResizeHandle:e.alwaysShowResizeHandle||!1,resizable:{autoHide:!e.alwaysShowResizeHandle,handles:"se"},draggable:{handle:(e.handleClass?"."+e.handleClass:e.handle?e.handle:"")||".grid-stack-item-content",scroll:!1,appendTo:"body"},removableOptions:{accept:"."+(e.itemClass||"grid-stack-item")}});t.getAttribute("gs-animate")&&(s.animate=n.Utils.toBool(t.getAttribute("gs-animate"))),this.opts=n.Utils.defaults(e,s),e=null,this.initMargin(),1!==this.opts.column&&!this.opts.disableOneColumnMode&&this._widthOrContainer()<=this.opts.minWidth&&(this._prevColumn=this.opts.column,this.opts.column=1),"auto"===this.opts.rtl&&(this.opts.rtl="rtl"===t.style.direction),this.opts.rtl&&this.el.classList.add("grid-stack-rtl");let o=n.Utils.closestByClass(this.el,a.itemClass);if(o&&o.gridstackNode&&(this.opts._isNested=o.gridstackNode,this.opts._isNested.subGrid=this,this.el.classList.add("grid-stack-nested")),this._isAutoCellHeight="auto"===this.opts.cellHeight,this._isAutoCellHeight||"initial"===this.opts.cellHeight?this.cellHeight(void 0,!1):this.cellHeight(this.opts.cellHeight,!1),this.el.classList.add(this.opts._styleSheetClass),this._setStaticClass(),this.engine=new r.GridStackEngine({column:this.opts.column,float:this.opts.float,maxRow:this.opts.maxRow,onChange:t=>{let e=0;this.engine.nodes.forEach((t=>{e=Math.max(e,t.y+t.h)})),t.forEach((t=>{let e=t.el;t._removeDOM?(e&&e.remove(),delete t._removeDOM):this._writePosAttr(e,t)})),this._updateStyles(!1,e)}}),this.opts.auto){this.batchUpdate();let t=[];this.getGridItems().forEach((e=>{let i=parseInt(e.getAttribute("gs-x")),s=parseInt(e.getAttribute("gs-y"));t.push({el:e,i:(Number.isNaN(i)?1e3:i)+(Number.isNaN(s)?1e3:s)*this.opts.column})})),t.sort(((t,e)=>t.i-e.i)).forEach((t=>this._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&&h.setupDragIn(this.opts.dragIn,this.opts.dragInOptions),delete this.opts.dragIn,delete this.opts.dragInOptions,this._setupRemoveDrop(),this._setupAcceptWidget(),this._updateWindowResizeEvent()}static init(t={},e=".grid-stack"){let i=h.getGridElement(e);return i?(i.gridstack||(i.gridstack=new h(i,n.Utils.cloneDeep(t))),i.gridstack):("string"==typeof e?console.error('GridStack.initAll() no grid was found with selector "'+e+'" - 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)}static initAll(t={},e=".grid-stack"){let i=[];return h.getGridElements(e).forEach((e=>{e.gridstack||(e.gridstack=new h(e,n.Utils.cloneDeep(t)),delete t.dragIn,delete t.dragInOptions),i.push(e.gridstack)})),0===i.length&&console.error('GridStack.initAll() no grid was found with selector "'+e+'" - element missing or wrong selector ?\nNote: ".grid-stack" is required for proper CSS styling and drag/drop, and is the default selector.'),i}static addGrid(t,e={}){if(!t)return null;let i=t;if(!t.classList.contains("grid-stack")){let s=document.implementation.createHTMLDocument();s.body.innerHTML=`
`,i=s.body.children[0],t.appendChild(i)}let s=h.init(e,i);if(s.opts.children){let t=s.opts.children;delete s.opts.children,s.load(t)}return s}get placeholder(){if(!this._placeholder){let 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,a.itemClass,this.opts.itemClass),this.placeholder.appendChild(t)}return this._placeholder}addWidget(t,e){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");let e=arguments,i=1,s={x:e[i++],y:e[i++],w:e[i++],h:e[i++],autoPosition:e[i++],minW:e[i++],maxW:e[i++],minH:e[i++],maxH:e[i++],id:e[i++]};return this.addWidget(t,s)}let i;if("string"==typeof t){let e=document.implementation.createHTMLDocument();e.body.innerHTML=t,i=e.body.children[0]}else if(0===arguments.length||1===arguments.length&&(void 0!==(s=t).x||void 0!==s.y||void 0!==s.w||void 0!==s.h||void 0!==s.content)){let s=t&&t.content||"";e=t;let o=document.implementation.createHTMLDocument();o.body.innerHTML=`
${s}
`,i=o.body.children[0]}else i=t;var s;let o=this._readAttr(i);e=n.Utils.cloneDeep(e)||{},n.Utils.defaults(e,o);let r=this.engine.prepareNode(e);if(this._writeAttr(i,e),this._insertNotAppend?this.el.prepend(i):this.el.appendChild(i),this._prepareElement(i,!0,e),this._updateContainerHeight(),r.subGrid&&!r.subGrid.el){let t=r.el.querySelector(".grid-stack-item-content");r.subGrid=h.addGrid(t,r.subGrid)}return this._triggerAddEvent(),this._triggerChangeEvent(),i}save(t=!0,e=!1){let i=this.engine.save(t);if(i.forEach((e=>{if(t&&e.el&&!e.subGrid){let t=e.el.querySelector(".grid-stack-item-content");e.content=t?t.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){let t=n.Utils.cloneDeep(this.opts);return t.marginBottom===t.marginTop&&t.marginRight===t.marginLeft&&t.marginTop===t.marginRight&&(t.margin=t.marginTop,delete t.marginTop,delete t.marginRight,delete t.marginBottom,delete t.marginLeft),t.rtl===("rtl"===this.el.style.direction)&&(t.rtl="auto"),this._isAutoCellHeight&&(t.cellHeight="auto"),n.Utils.removeInternalAndSame(t,a),t.children=i,t}return i}load(t,e=!0){let i=h.Utils.sort([...t],-1,this._prevColumn||this.opts.column);this._insertNotAppend=!0,this._prevColumn&&this._prevColumn!==this.opts.column&&i.some((t=>t.x+t.w>this.opts.column))&&(this._ignoreLayoutsNodeChange=!0,this.engine.cacheLayout(i,this._prevColumn,!0));let s=[];return this.batchUpdate(),e&&[...this.engine.nodes].forEach((t=>{i.find((e=>t.id===e.id))||("function"==typeof e?e(this,t,!1):(s.push(t),this.removeWidget(t.el,!0,!1)))})),i.forEach((t=>{let i=t.id||0===t.id?this.engine.nodes.find((e=>e.id===t.id)):void 0;if(i){if(this.update(i.el,t),t.subGrid&&t.subGrid.children){let e=i.el.querySelector(".grid-stack");e&&e.gridstack&&(e.gridstack.load(t.subGrid.children),this._insertNotAppend=!0)}}else e&&(t="function"==typeof e?e(this,t,!0).gridstackNode:this.addWidget(t).gridstackNode)})),this.engine.removedNodes=s,this.commit(),delete this._ignoreLayoutsNodeChange,delete this._insertNotAppend,this}batchUpdate(){return this.engine.batchUpdate(),this}getCellHeight(t=!1){return!this.opts.cellHeight||"auto"===this.opts.cellHeight||t&&this.opts.cellHeightUnit&&"px"!==this.opts.cellHeightUnit?Math.round(this.el.getBoundingClientRect().height)/parseInt(this.el.getAttribute("gs-current-row")):this.opts.cellHeight}cellHeight(t,e=!0){if(e&&void 0!==t&&this._isAutoCellHeight!==("auto"===t)&&(this._isAutoCellHeight="auto"===t,this._updateWindowResizeEvent()),"initial"!==t&&"auto"!==t||(t=void 0),void 0===t){let e=-this.opts.marginRight-this.opts.marginLeft+this.opts.marginTop+this.opts.marginBottom;t=this.cellWidth()+e}let i=n.Utils.parseHeight(t);return this.opts.cellHeightUnit===i.unit&&this.opts.cellHeight===i.h||(this.opts.cellHeightUnit=i.unit,this.opts.cellHeight=i.h,e&&this._updateStyles(!0,this.getRow())),this}cellWidth(){return this._widthOrContainer()/this.opts.column}_widthOrContainer(){return this.el.clientWidth||this.el.parentElement.clientWidth||window.innerWidth}commit(){return this.engine.commit(),this._triggerRemoveEvent(),this._triggerAddEvent(),this._triggerChangeEvent(),this}compact(){return this.engine.compact(),this._triggerChangeEvent(),this}column(t,e="moveScale"){if(this.opts.column===t)return this;let i,s=this.opts.column;return 1===t?this._prevColumn=s:delete this._prevColumn,this.el.classList.remove("grid-stack-"+s),this.el.classList.add("grid-stack-"+t),this.opts.column=this.engine.column=t,1===t&&this.opts.oneColumnModeDomSort&&(i=[],this.getGridItems().forEach((t=>{t.gridstackNode&&i.push(t.gridstackNode)})),i.length||(i=void 0)),this.engine.updateNodeWidths(s,t,i,e),this._isAutoCellHeight&&this.cellHeight(),this._ignoreLayoutsNodeChange=!0,this._triggerChangeEvent(),delete this._ignoreLayoutsNodeChange,this}getColumn(){return this.opts.column}getGridItems(){return Array.from(this.el.children).filter((t=>t.matches("."+this.opts.itemClass)&&!t.matches("."+this.opts.placeholderClass)))}destroy(t=!0){if(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}float(t){return this.engine.float=t,this._triggerChangeEvent(),this}getFloat(){return this.engine.float}getCellFromPixel(t,e=!1){let i,s=this.el.getBoundingClientRect();i=e?{top:s.top+document.documentElement.scrollTop,left:s.left}:{top:this.el.offsetTop,left:this.el.offsetLeft};let o=t.left-i.left,r=t.top-i.top,n=s.width/this.opts.column,l=s.height/parseInt(this.el.getAttribute("gs-current-row"));return{x:Math.floor(o/n),y:Math.floor(r/l)}}getRow(){return Math.max(this.engine.getRow(),this.opts.minRow)}isAreaEmpty(t,e,i,s){return this.engine.isAreaEmpty(t,e,i,s)}makeWidget(t){let e=h.getElement(t);return this._prepareElement(e,!0),this._updateContainerHeight(),this._triggerAddEvent(),this._triggerChangeEvent(),e}on(t,e){if(-1!==t.indexOf(" "))return t.split(" ").forEach((t=>this.on(t,e))),this;if("change"===t||"added"===t||"removed"===t||"enable"===t||"disable"===t){let i="enable"===t||"disable"===t;this._gsEventHandler[t]=i?t=>e(t):t=>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}off(t){return-1!==t.indexOf(" ")?(t.split(" ").forEach((t=>this.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)}removeWidget(t,e=!0,i=!0){return h.getElements(t).forEach((t=>{if(t.parentElement!==this.el)return;let s=t.gridstackNode;s||(s=this.engine.nodes.find((e=>t===e.el))),s&&(delete t.gridstackNode,l.GridStackDDI.get().remove(t),this.engine.removeNode(s,e,i),e&&t.parentElement&&t.remove())})),i&&(this._triggerRemoveEvent(),this._triggerChangeEvent()),this}removeAll(t=!0){return this.engine.nodes.forEach((t=>{delete t.el.gridstackNode,l.GridStackDDI.get().remove(t.el)})),this.engine.removeAll(t),this._triggerRemoveEvent(),this}setAnimation(t){return t?this.el.classList.add("grid-stack-animate"):this.el.classList.remove("grid-stack-animate"),this}setStatic(t,e=!0){return this.opts.staticGrid===t||(this.opts.staticGrid=t,this._setupRemoveDrop(),this._setupAcceptWidget(),this.engine.nodes.forEach((t=>this._prepareDragDropByNode(t))),e&&this._setStaticClass()),this}update(t,e){if(arguments.length>2){console.warn("gridstack.ts: `update(el, x, y, w, h)` is deprecated. Use `update({x, w, content, ...})`. It will be removed soon");let i=arguments,s=1;return e={x:i[s++],y:i[s++],w:i[s++],h:i[s++]},this.update(t,e)}return h.getElements(t).forEach((t=>{if(!t||!t.gridstackNode)return;let i=t.gridstackNode,s=n.Utils.cloneDeep(e);delete s.autoPosition;let o,r=["x","y","w","h"];if(r.some((t=>void 0!==s[t]&&s[t]!==i[t]))&&(o={},r.forEach((t=>{o[t]=void 0!==s[t]?s[t]:i[t],delete s[t]}))),!o&&(s.minW||s.minH||s.maxW||s.maxH)&&(o={}),s.content){let e=t.querySelector(".grid-stack-item-content");e&&e.innerHTML!==s.content&&(e.innerHTML=s.content),delete s.content}let l=!1,a=!1;for(const t in s)"_"!==t[0]&&i[t]!==s[t]&&(i[t]=s[t],l=!0,a=a||!this.opts.staticGrid&&("noResize"===t||"noMove"===t||"locked"===t));o&&(this.engine.cleanNodes().beginUpdate(i).moveNode(i,o),this._updateContainerHeight(),this._triggerChangeEvent(),this.engine.endUpdate()),l&&this._writeAttr(t,i),a&&this._prepareDragDropByNode(i)})),this}margin(t){if(!("string"==typeof t&&t.split(" ").length>1)){let e=n.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}getMargin(){return this.opts.margin}willItFit(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");let t=arguments,e=0,i={x:t[e++],y:t[e++],w:t[e++],h:t[e++],autoPosition:t[e++]};return this.willItFit(i)}return this.engine.willItFit(t)}_triggerChangeEvent(){if(this.engine.batchMode)return this;let t=this.engine.getDirtyNodes(!0);return t&&t.length&&(this._ignoreLayoutsNodeChange||this.engine.layoutsNodesChange(t),this._triggerEvent("change",t)),this.engine.saveInitial(),this}_triggerAddEvent(){return this.engine.batchMode||this.engine.addedNodes&&this.engine.addedNodes.length>0&&(this._ignoreLayoutsNodeChange||this.engine.layoutsNodesChange(this.engine.addedNodes),this.engine.addedNodes.forEach((t=>{delete t._dirty})),this._triggerEvent("added",this.engine.addedNodes),this.engine.addedNodes=[]),this}_triggerRemoveEvent(){return this.engine.batchMode||this.engine.removedNodes&&this.engine.removedNodes.length>0&&(this._triggerEvent("removed",this.engine.removedNodes),this.engine.removedNodes=[]),this}_triggerEvent(t,e){let i=e?new CustomEvent(t,{bubbles:!1,detail:e}):new Event(t);return this.el.dispatchEvent(i),this}_removeStylesheet(){return this._styles&&(n.Utils.removeStylesheet(this._styles._id),delete this._styles),this}_updateStyles(t=!1,e){if(t&&this._removeStylesheet(),this._updateContainerHeight(),0===this.opts.cellHeight)return this;let i=this.opts.cellHeight,s=this.opts.cellHeightUnit,o=`.${this.opts._styleSheetClass} > .${this.opts.itemClass}`;if(!this._styles){let t="gridstack-style-"+(1e5*Math.random()).toFixed(),e=this.opts.styleInHead?void 0:this.el.parentNode;if(this._styles=n.Utils.createStylesheet(t,e),!this._styles)return this;this._styles._id=t,this._styles._max=0,n.Utils.addCSSRule(this._styles,o,`min-height: ${i}${s}`);let r=this.opts.marginTop+this.opts.marginUnit,l=this.opts.marginBottom+this.opts.marginUnit,a=this.opts.marginRight+this.opts.marginUnit,h=this.opts.marginLeft+this.opts.marginUnit,d=`${o} > .grid-stack-item-content`,g=`.${this.opts._styleSheetClass} > .grid-stack-placeholder > .placeholder-content`;n.Utils.addCSSRule(this._styles,d,`top: ${r}; right: ${a}; bottom: ${l}; left: ${h};`),n.Utils.addCSSRule(this._styles,g,`top: ${r}; right: ${a}; bottom: ${l}; left: ${h};`),n.Utils.addCSSRule(this._styles,`${o} > .ui-resizable-ne`,`right: ${a}`),n.Utils.addCSSRule(this._styles,`${o} > .ui-resizable-e`,`right: ${a}`),n.Utils.addCSSRule(this._styles,`${o} > .ui-resizable-se`,`right: ${a}; bottom: ${l}`),n.Utils.addCSSRule(this._styles,`${o} > .ui-resizable-nw`,`left: ${h}`),n.Utils.addCSSRule(this._styles,`${o} > .ui-resizable-w`,`left: ${h}`),n.Utils.addCSSRule(this._styles,`${o} > .ui-resizable-sw`,`left: ${h}; bottom: ${l}`)}if((e=e||this._styles._max)>this._styles._max){let t=t=>i*t+s;for(let i=this._styles._max+1;i<=e;i++){let e=t(i);n.Utils.addCSSRule(this._styles,`${o}[gs-y="${i-1}"]`,`top: ${t(i-1)}`),n.Utils.addCSSRule(this._styles,`${o}[gs-h="${i}"]`,`height: ${e}`),n.Utils.addCSSRule(this._styles,`${o}[gs-min-h="${i}"]`,`min-height: ${e}`),n.Utils.addCSSRule(this._styles,`${o}[gs-max-h="${i}"]`,`max-height: ${e}`)}this._styles._max=e}return this}_updateContainerHeight(){if(!this.engine||this.engine.batchMode)return this;let t=this.getRow()+this._extraDragRow,e=parseInt(getComputedStyle(this.el)["min-height"]);if(e>0){let i=Math.round(e/this.getCellHeight(!0));tthis.cellHeight()),this.opts.cellHeightThrottle)),this._cellHeightThrottle()):this.cellHeight()),this.engine.nodes.forEach((t=>{t.subGrid&&t.subGrid.onParentResize()})),this}_updateWindowResizeEvent(t=!1){const 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}static getElement(t=".grid-stack-item"){return n.Utils.getElement(t)}static getElements(t=".grid-stack-item"){return n.Utils.getElements(t)}static getGridElement(t){return h.getElement(t)}static getGridElements(t){return n.Utils.getElements(t)}initMargin(){let 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=n.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=n.Utils.parseHeight(this.opts.marginTop),this.opts.marginTop=t.h,delete this.opts.margin),void 0===this.opts.marginBottom?this.opts.marginBottom=e:(t=n.Utils.parseHeight(this.opts.marginBottom),this.opts.marginBottom=t.h,delete this.opts.margin),void 0===this.opts.marginRight?this.opts.marginRight=e:(t=n.Utils.parseHeight(this.opts.marginRight),this.opts.marginRight=t.h,delete this.opts.margin),void 0===this.opts.marginLeft?this.opts.marginLeft=e:(t=n.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}static setupDragIn(t,e){}movable(t,e){return this}resizable(t,e){return this}disable(){return this}enable(){return this}enableMove(t){return this}enableResize(t){return this}_setupAcceptWidget(){return this}_setupRemoveDrop(){return this}_prepareDragDropByNode(t){return this}_onStartMoving(t,e,i,s,o,r){}_dragOrResize(t,e,i,s,o,r){}_leave(t,e){}}e.GridStack=h,h.Utils=n.Utils,h.Engine=r.GridStackEngine},861:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DDBaseImplement=void 0,e.DDBaseImplement=class{constructor(){this._disabled=!1,this._eventRegister={}}get disabled(){return this._disabled}on(t,e){this._eventRegister[t]=e}off(t){delete this._eventRegister[t]}enable(){this._disabled=!1}disable(){this._disabled=!0}destroy(){delete this._eventRegister}triggerEvent(t,e){if(!this.disabled&&this._eventRegister&&this._eventRegister[t])return this._eventRegister[t](e)}}},311:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DDDraggable=void 0;const s=i(849),o=i(943),r=i(861);class n extends r.DDBaseImplement{constructor(t,e={}){super(),this.dragging=!1,this.ui=()=>{const t=this.el.parentElement.getBoundingClientRect(),e=this.helper.getBoundingClientRect();return{position:{top:e.top-t.top,left:e.left-t.left}}},this.el=t,this.option=e;let i=e.handle.substring(1);this.dragEl=t.classList.contains(i)?t:t.querySelector(e.handle)||t,this._dragStart=this._dragStart.bind(this),this._drag=this._drag.bind(this),this._dragEnd=this._dragEnd.bind(this),this.enable()}on(t,e){super.on(t,e)}off(t){super.off(t)}enable(){super.enable(),this.dragEl.draggable=!0,this.dragEl.addEventListener("dragstart",this._dragStart),this.el.classList.remove("ui-draggable-disabled"),this.el.classList.add("ui-draggable")}disable(t=!1){super.disable(),this.dragEl.removeAttribute("draggable"),this.dragEl.removeEventListener("dragstart",this._dragStart),this.el.classList.remove("ui-draggable"),t||this.el.classList.add("ui-draggable-disabled")}destroy(){this.dragging&&this._dragEnd({}),this.disable(!0),delete this.el,delete this.helper,delete this.option,super.destroy()}updateOption(t){return Object.keys(t).forEach((e=>this.option[e]=t[e])),this}_dragStart(t){s.DDManager.dragElement=this,this.helper=this._createHelper(t),this._setupHelperContainmentStyle(),this.dragOffset=this._getDragOffset(t,this.el,this.helperContainment);const e=o.DDUtils.initEvent(t,{target:this.el,type:"dragstart"});this.helper!==this.el?(this._setupDragFollowNodeNotifyStart(e),this._dragFollow(t)):this.dragFollowTimer=window.setTimeout((()=>{delete this.dragFollowTimer,this._setupDragFollowNodeNotifyStart(e)}),0),this._cancelDragGhost(t)}_setupDragFollowNodeNotifyStart(t){return this._setupHelperStyle(),document.addEventListener("dragover",this._drag,n.dragEventListenerOption),this.dragEl.addEventListener("dragend",this._dragEnd),this.option.start&&this.option.start(t,this.ui()),this.dragging=!0,this.helper.classList.add("ui-draggable-dragging"),this.triggerEvent("dragstart",t),this}_drag(t){t.preventDefault(),this._dragFollow(t);const e=o.DDUtils.initEvent(t,{target:this.el,type:"drag"});this.option.drag&&this.option.drag(e,this.ui()),this.triggerEvent("drag",e)}_dragEnd(t){if(this.dragFollowTimer)return clearTimeout(this.dragFollowTimer),void delete this.dragFollowTimer;this.paintTimer&&cancelAnimationFrame(this.paintTimer),document.removeEventListener("dragover",this._drag,n.dragEventListenerOption),this.dragEl.removeEventListener("dragend",this._dragEnd),this.dragging=!1,this.helper.classList.remove("ui-draggable-dragging"),this.helperContainment.style.position=this.parentOriginStylePosition||null,this.helper===this.el?this._removeHelperStyle():this.helper.remove();const e=o.DDUtils.initEvent(t,{target:this.el,type:"dragstop"});this.option.stop&&this.option.stop(e),this.triggerEvent("dragstop",e),delete s.DDManager.dragElement,delete this.helper}_createHelper(t){let e=this.el;return"function"==typeof this.option.helper?e=this.option.helper(t):"clone"===this.option.helper&&(e=o.DDUtils.clone(this.el)),document.body.contains(e)||o.DDUtils.appendTo(e,"parent"===this.option.appendTo?this.el.parentNode:this.option.appendTo),e===this.el&&(this.dragElementOriginStyle=n.originStyleProp.map((t=>this.el.style[t]))),e}_setupHelperStyle(){return this.helper.style.pointerEvents="none",this.helper.style.width=this.dragOffset.width+"px",this.helper.style.height=this.dragOffset.height+"px",this.helper.style.willChange="left, top",this.helper.style.transition="none",this.helper.style.position=this.option.basePosition||n.basePosition,this.helper.style.zIndex="1000",setTimeout((()=>{this.helper&&(this.helper.style.transition=null)}),0),this}_removeHelperStyle(){let t=this.helper?this.helper.gridstackNode:void 0;return t&&t._isAboutToRemove||n.originStyleProp.forEach((t=>{this.helper.style[t]=this.dragElementOriginStyle[t]||null})),delete this.dragElementOriginStyle,this}_dragFollow(t){this.paintTimer&&cancelAnimationFrame(this.paintTimer),this.paintTimer=requestAnimationFrame((()=>{delete this.paintTimer;const e=this.dragOffset;let i={left:0,top:0};if("absolute"===this.helper.style.position){const{left:t,top:e}=this.helperContainment.getBoundingClientRect();i={left:t,top:e}}this.helper.style.left=t.clientX+e.offsetLeft-i.left+"px",this.helper.style.top=t.clientY+e.offsetTop-i.top+"px"}))}_setupHelperContainmentStyle(){return this.helperContainment=this.helper.parentElement,"fixed"!==this.option.basePosition&&(this.parentOriginStylePosition=this.helperContainment.style.position,window.getComputedStyle(this.helperContainment).position.match(/static/)&&(this.helperContainment.style.position="relative")),this}_cancelDragGhost(t){let e=document.createElement("div");return e.style.width="1px",e.style.height="1px",e.style.position="fixed",document.body.appendChild(e),t.dataTransfer.setDragImage(e,0,0),setTimeout((()=>document.body.removeChild(e))),t.stopPropagation(),this}_getDragOffset(t,e,i){let s=0,r=0;if(i){const t=document.createElement("div");o.DDUtils.addElStyles(t,{opacity:"0",position:"fixed",top:"0px",left:"0px",width:"1px",height:"1px",zIndex:"-999999"}),i.appendChild(t);const e=t.getBoundingClientRect();i.removeChild(t),s=e.left,r=e.top}const n=e.getBoundingClientRect();return{left:n.left,top:n.top,offsetLeft:-t.clientX+n.left-s,offsetTop:-t.clientY+n.top-r,width:n.width,height:n.height}}}e.DDDraggable=n,n.basePosition="absolute",n.dragEventListenerOption=!0,n.originStyleProp=["transition","pointerEvents","position","left","top","opacity","zIndex","width","height","willChange"]},54:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DDDroppable=void 0;const s=i(849),o=i(861),r=i(943);class n extends o.DDBaseImplement{constructor(t,e={}){super(),this.el=t,this.option=e,this._dragEnter=this._dragEnter.bind(this),this._dragOver=this._dragOver.bind(this),this._dragLeave=this._dragLeave.bind(this),this._drop=this._drop.bind(this),this.el.classList.add("ui-droppable"),this.el.addEventListener("dragenter",this._dragEnter),this._setupAccept()}on(t,e){super.on(t,e)}off(t){super.off(t)}enable(){this.disabled&&(super.enable(),this.el.classList.remove("ui-droppable-disabled"),this.el.addEventListener("dragenter",this._dragEnter))}disable(t=!1){this.disabled||(super.disable(),t||this.el.classList.add("ui-droppable-disabled"),this.el.removeEventListener("dragenter",this._dragEnter))}destroy(){this.moving&&this._removeLeaveCallbacks(),this.disable(!0),this.el.classList.remove("ui-droppable"),this.el.classList.remove("ui-droppable-disabled"),delete this.moving,super.destroy()}updateOption(t){return Object.keys(t).forEach((e=>this.option[e]=t[e])),this._setupAccept(),this}_dragEnter(t){if(!this._canDrop())return;if(t.preventDefault(),this.moving)return;this.moving=!0;const e=r.DDUtils.initEvent(t,{target:this.el,type:"dropover"});this.option.over&&this.option.over(e,this._ui(s.DDManager.dragElement)),this.triggerEvent("dropover",e),this.el.addEventListener("dragover",this._dragOver),this.el.addEventListener("drop",this._drop),this.el.addEventListener("dragleave",this._dragLeave),this.el.classList.add("ui-droppable-over")}_dragOver(t){t.preventDefault(),t.stopPropagation()}_dragLeave(t){if(t.relatedTarget){if(this.el.contains(t.relatedTarget))return}else{const{bottom:e,left:i,right:s,top:o}=this.el.getBoundingClientRect();if(t.xi&&t.yo)return}if(this._removeLeaveCallbacks(),this.moving){t.preventDefault();const e=r.DDUtils.initEvent(t,{target:this.el,type:"dropout"});this.option.out&&this.option.out(e,this._ui(s.DDManager.dragElement)),this.triggerEvent("dropout",e)}delete this.moving}_drop(t){if(!this.moving)return;t.preventDefault();const e=r.DDUtils.initEvent(t,{target:this.el,type:"drop"});this.option.drop&&this.option.drop(e,this._ui(s.DDManager.dragElement)),this.triggerEvent("drop",e),this._removeLeaveCallbacks(),delete this.moving}_removeLeaveCallbacks(){this.el.removeEventListener("dragleave",this._dragLeave),this.el.classList.remove("ui-droppable-over"),this.moving&&(this.el.removeEventListener("dragover",this._dragOver),this.el.removeEventListener("drop",this._drop))}_canDrop(){return s.DDManager.dragElement&&(!this.accept||this.accept(s.DDManager.dragElement.el))}_setupAccept(){return this.option.accept&&"string"==typeof this.option.accept?this.accept=t=>t.matches(this.option.accept):this.accept=this.option.accept,this}_ui(t){return Object.assign({draggable:t.el},t.ui())}}e.DDDroppable=n},485:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DDElement=void 0;const s=i(97),o=i(311),r=i(54);class n{constructor(t){this.el=t}static init(t){return t.ddElement||(t.ddElement=new n(t)),t.ddElement}on(t,e){return this.ddDraggable&&["drag","dragstart","dragstop"].indexOf(t)>-1?this.ddDraggable.on(t,e):this.ddDroppable&&["drop","dropover","dropout"].indexOf(t)>-1?this.ddDroppable.on(t,e):this.ddResizable&&["resizestart","resize","resizestop"].indexOf(t)>-1&&this.ddResizable.on(t,e),this}off(t){return this.ddDraggable&&["drag","dragstart","dragstop"].indexOf(t)>-1?this.ddDraggable.off(t):this.ddDroppable&&["drop","dropover","dropout"].indexOf(t)>-1?this.ddDroppable.off(t):this.ddResizable&&["resizestart","resize","resizestop"].indexOf(t)>-1&&this.ddResizable.off(t),this}setupDraggable(t){return this.ddDraggable?this.ddDraggable.updateOption(t):this.ddDraggable=new o.DDDraggable(this.el,t),this}cleanDraggable(){return this.ddDraggable&&(this.ddDraggable.destroy(),delete this.ddDraggable),this}setupResizable(t){return this.ddResizable?this.ddResizable.updateOption(t):this.ddResizable=new s.DDResizable(this.el,t),this}cleanResizable(){return this.ddResizable&&(this.ddResizable.destroy(),delete this.ddResizable),this}setupDroppable(t){return this.ddDroppable?this.ddDroppable.updateOption(t):this.ddDroppable=new r.DDDroppable(this.el,t),this}cleanDroppable(){return this.ddDroppable&&(this.ddDroppable.destroy(),delete this.ddDroppable),this}}e.DDElement=n},849:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DDManager=void 0,e.DDManager=class{}},680:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DDResizableHandle=void 0;class i{constructor(t,e,i){this.moving=!1,this.host=t,this.dir=e,this.option=i,this._mouseDown=this._mouseDown.bind(this),this._mouseMove=this._mouseMove.bind(this),this._mouseUp=this._mouseUp.bind(this),this._init()}_init(){const t=document.createElement("div");return t.classList.add("ui-resizable-handle"),t.classList.add(`${i.prefix}${this.dir}`),t.style.zIndex="100",t.style.userSelect="none",this.el=t,this.host.appendChild(this.el),this.el.addEventListener("mousedown",this._mouseDown),this}destroy(){return this.moving&&this._mouseUp(this.mouseDownEvent),this.el.removeEventListener("mousedown",this._mouseDown),this.host.removeChild(this.el),delete this.el,delete this.host,this}_mouseDown(t){t.preventDefault(),this.mouseDownEvent=t,document.addEventListener("mousemove",this._mouseMove,!0),document.addEventListener("mouseup",this._mouseUp)}_mouseMove(t){let e=this.mouseDownEvent;!this.moving&&Math.abs(t.x-e.x)+Math.abs(t.y-e.y)>2?(this.moving=!0,this._triggerEvent("start",this.mouseDownEvent)):this.moving&&this._triggerEvent("move",t)}_mouseUp(t){this.moving&&this._triggerEvent("stop",t),document.removeEventListener("mousemove",this._mouseMove,!0),document.removeEventListener("mouseup",this._mouseUp),delete this.moving,delete this.mouseDownEvent}_triggerEvent(t,e){return this.option[t]&&this.option[t](e),this}}e.DDResizableHandle=i,i.prefix="ui-resizable-"},97:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DDResizable=void 0;const s=i(680),o=i(861),r=i(943),n=i(593);class l extends o.DDBaseImplement{constructor(t,e={}){super(),this._showHandlers=()=>{this.el.classList.remove("ui-resizable-autohide")},this._hideHandlers=()=>{this.el.classList.add("ui-resizable-autohide")},this._ui=()=>{const t=this.el.parentElement.getBoundingClientRect(),e={width:this.originalRect.width,height:this.originalRect.height+this.scrolled,left:this.originalRect.left,top:this.originalRect.top-this.scrolled},i=this.temporalRect||e;return{position:{left:i.left-t.left,top:i.top-t.top},size:{width:i.width,height:i.height}}},this.el=t,this.option=e,this.enable(),this._setupAutoHide(),this._setupHandlers()}on(t,e){super.on(t,e)}off(t){super.off(t)}enable(){super.enable(),this.el.classList.add("ui-resizable"),this.el.classList.remove("ui-resizable-disabled")}disable(){super.disable(),this.el.classList.add("ui-resizable-disabled"),this.el.classList.remove("ui-resizable")}destroy(){this._removeHandlers(),this.option.autoHide&&(this.el.removeEventListener("mouseover",this._showHandlers),this.el.removeEventListener("mouseout",this._hideHandlers)),this.el.classList.remove("ui-resizable"),delete this.el,super.destroy()}updateOption(t){let e=t.handles&&t.handles!==this.option.handles,i=t.autoHide&&t.autoHide!==this.option.autoHide;return Object.keys(t).forEach((e=>this.option[e]=t[e])),e&&(this._removeHandlers(),this._setupHandlers()),i&&this._setupAutoHide(),this}_setupAutoHide(){return this.option.autoHide?(this.el.classList.add("ui-resizable-autohide"),this.el.addEventListener("mouseover",this._showHandlers),this.el.addEventListener("mouseout",this._hideHandlers)):(this.el.classList.remove("ui-resizable-autohide"),this.el.removeEventListener("mouseover",this._showHandlers),this.el.removeEventListener("mouseout",this._hideHandlers)),this}_setupHandlers(){let t=this.option.handles||"e,s,se";return"all"===t&&(t="n,e,s,w,se,sw,ne,nw"),this.handlers=t.split(",").map((t=>t.trim())).map((t=>new s.DDResizableHandle(this.el,t,{start:t=>{this._resizeStart(t)},stop:t=>{this._resizeStop(t)},move:e=>{this._resizing(e,t)}}))),this}_resizeStart(t){this.originalRect=this.el.getBoundingClientRect(),this.scrollEl=n.Utils.getScrollElement(this.el),this.scrollY=this.scrollEl.scrollTop,this.startEvent=t,this._setupHelper(),this._applyChange();const e=r.DDUtils.initEvent(t,{type:"resizestart",target:this.el});return this.option.start&&this.option.start(e,this._ui()),this.el.classList.add("ui-resizable-resizing"),this.triggerEvent("resizestart",e),this}_resizing(t,e){this.scrolled=this.scrollEl.scrollTop-this.scrollY,this.temporalRect=this._getChange(t,e),this._applyChange();const i=r.DDUtils.initEvent(t,{type:"resize",target:this.el});return this.option.resize&&this.option.resize(i,this._ui()),this.triggerEvent("resize",i),this}_resizeStop(t){const e=r.DDUtils.initEvent(t,{type:"resizestop",target:this.el});return this.option.stop&&this.option.stop(e),this.el.classList.remove("ui-resizable-resizing"),this.triggerEvent("resizestop",e),this._cleanHelper(),delete this.startEvent,delete this.originalRect,delete this.temporalRect,delete this.scrollY,delete this.scrolled,this}_setupHelper(){return this.elOriginStyleVal=l._originStyleProp.map((t=>this.el.style[t])),this.parentOriginStylePosition=this.el.parentElement.style.position,window.getComputedStyle(this.el.parentElement).position.match(/static/)&&(this.el.parentElement.style.position="relative"),this.el.style.position=this.option.basePosition||"absolute",this.el.style.opacity="0.8",this.el.style.zIndex="1000",this}_cleanHelper(){return l._originStyleProp.forEach(((t,e)=>{this.el.style[t]=this.elOriginStyleVal[e]||null})),this.el.parentElement.style.position=this.parentOriginStylePosition||null,this}_getChange(t,e){const i=this.startEvent,s={width:this.originalRect.width,height:this.originalRect.height+this.scrolled,left:this.originalRect.left,top:this.originalRect.top-this.scrolled},o=t.clientX-i.clientX,r=t.clientY-i.clientY;e.indexOf("e")>-1?s.width+=o:e.indexOf("w")>-1&&(s.width-=o,s.left+=o),e.indexOf("s")>-1?s.height+=r:e.indexOf("n")>-1&&(s.height-=r,s.top+=r);const n=this._constrainSize(s.width,s.height);return Math.round(s.width)!==Math.round(n.width)&&(e.indexOf("w")>-1&&(s.left+=s.width-n.width),s.width=n.width),Math.round(s.height)!==Math.round(n.height)&&(e.indexOf("n")>-1&&(s.top+=s.height-n.height),s.height=n.height),s}_constrainSize(t,e){const i=this.option.maxWidth||Number.MAX_SAFE_INTEGER,s=this.option.minWidth||t,o=this.option.maxHeight||Number.MAX_SAFE_INTEGER,r=this.option.minHeight||e;return{width:Math.min(i,Math.max(s,t)),height:Math.min(o,Math.max(r,e))}}_applyChange(){let t={left:0,top:0,width:0,height:0};if("absolute"===this.el.style.position){const e=this.el.parentElement,{left:i,top:s}=e.getBoundingClientRect();t={left:i,top:s,width:0,height:0}}return this.temporalRect?(Object.keys(this.temporalRect).forEach((e=>{const i=this.temporalRect[e];this.el.style[e]=i-t[e]+"px"})),this):this}_removeHandlers(){return this.handlers.forEach((t=>t.destroy())),delete this.handlers,this}}e.DDResizable=l,l._originStyleProp=["width","height","position","left","top","opacity","zIndex"]},943:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DDUtils=void 0;class i{static clone(t){const e=t.cloneNode(!0);return e.removeAttribute("id"),e}static appendTo(t,e){let i;i="string"==typeof e?document.querySelector(e):e,i&&i.appendChild(t)}static setPositionRelative(t){/^(?:r|a|f)/.test(window.getComputedStyle(t).position)||(t.style.position="relative")}static addElStyles(t,e){if(e instanceof Object)for(const i in e)e.hasOwnProperty(i)&&(Array.isArray(e[i])?e[i].forEach((e=>{t.style[i]=e})):t.style[i]=e[i])}static initEvent(t,e){const i={type:e.type},s={button:0,which:0,buttons:1,bubbles:!0,cancelable:!0,target:e.target?e.target:t.target};return t.dataTransfer&&(i.dataTransfer=t.dataTransfer),["altKey","ctrlKey","metaKey","shiftKey"].forEach((e=>i[e]=t[e])),["pageX","pageY","clientX","clientY","screenX","screenY"].forEach((e=>i[e]=t[e])),Object.assign(Object.assign({},i),s)}}e.DDUtils=i,i.isEventSupportPassiveOption=(()=>{let t=!1,e=()=>{};return document.addEventListener("test",e,{get passive(){return t=!0,!0}}),document.removeEventListener("test",e),t})()},761:function(t,e,i){var s=this&&this.__createBinding||(Object.create?function(t,e,i,s){void 0===s&&(s=i),Object.defineProperty(t,s,{enumerable:!0,get:function(){return e[i]}})}:function(t,e,i,s){void 0===s&&(s=i),t[s]=e[i]}),o=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||e.hasOwnProperty(i)||s(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),e.GridStackDDNative=void 0;const r=i(849),n=i(485),l=i(21),a=i(593);o(i(21),e);class h extends l.GridStackDD{resizable(t,e,i,s){return this._getDDElements(t).forEach((t=>{if("disable"===e||"enable"===e)t.ddResizable&&t.ddResizable[e]();else if("destroy"===e)t.ddResizable&&t.cleanResizable();else if("option"===e)t.setupResizable({[i]:s});else{const i=t.el.gridstackNode.grid;let s=t.el.getAttribute("gs-resize-handles")?t.el.getAttribute("gs-resize-handles"):i.opts.resizable.handles;t.setupResizable(Object.assign(Object.assign(Object.assign({},i.opts.resizable),{handles:s}),{start:e.start,stop:e.stop,resize:e.resize}))}})),this}draggable(t,e,i,s){return this._getDDElements(t).forEach((t=>{if("disable"===e||"enable"===e)t.ddDraggable&&t.ddDraggable[e]();else if("destroy"===e)t.ddDraggable&&t.cleanDraggable();else if("option"===e)t.setupDraggable({[i]:s});else{const i=t.el.gridstackNode.grid;t.setupDraggable(Object.assign(Object.assign({},i.opts.draggable),{containment:i.opts._isNested&&!i.opts.dragOut?i.el.parentElement:i.opts.draggable.containment||null,start:e.start,stop:e.stop,drag:e.drag}))}})),this}dragIn(t,e){return this._getDDElements(t).forEach((t=>t.setupDraggable(e))),this}droppable(t,e,i,s){return"function"!=typeof e.accept||e._accept||(e._accept=e.accept,e.accept=t=>e._accept(t)),this._getDDElements(t).forEach((t=>{"disable"===e||"enable"===e?t.ddDroppable&&t.ddDroppable[e]():"destroy"===e?t.ddDroppable&&t.cleanDroppable():"option"===e?t.setupDroppable({[i]:s}):t.setupDroppable(e)})),this}isDroppable(t){return!(!(t&&t.ddElement&&t.ddElement.ddDroppable)||t.ddElement.ddDroppable.disabled)}isDraggable(t){return!(!(t&&t.ddElement&&t.ddElement.ddDraggable)||t.ddElement.ddDraggable.disabled)}isResizable(t){return!(!(t&&t.ddElement&&t.ddElement.ddResizable)||t.ddElement.ddResizable.disabled)}on(t,e,i){return this._getDDElements(t).forEach((t=>t.on(e,(t=>{i(t,r.DDManager.dragElement?r.DDManager.dragElement.el:t.target,r.DDManager.dragElement?r.DDManager.dragElement.helper:null)})))),this}off(t,e){return this._getDDElements(t).forEach((t=>t.off(e))),this}_getDDElements(t,e=!0){let i=a.Utils.getElements(t);if(!i.length)return[];let s=i.map((t=>t.ddElement||(e?n.DDElement.init(t):null)));return e||s.filter((t=>t)),s}}e.GridStackDDNative=h,l.GridStackDD.registerPlugin(h)},699:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},593:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Utils=e.obsoleteAttr=e.obsoleteOptsDel=e.obsoleteOpts=e.obsolete=void 0,e.obsolete=function(t,e,i,s,o){let r=(...r)=>(console.warn("gridstack.js: Function `"+i+"` is deprecated in "+o+" and has been replaced with `"+s+"`. It will be **completely** removed in v1.0"),e.apply(t,r));return r.prototype=e.prototype,r},e.obsoleteOpts=function(t,e,i,s){void 0!==t[e]&&(t[i]=t[e],console.warn("gridstack.js: Option `"+e+"` is deprecated in "+s+" and has been replaced with `"+i+"`. It will be **completely** removed in v1.0"))},e.obsoleteOptsDel=function(t,e,i,s){void 0!==t[e]&&console.warn("gridstack.js: Option `"+e+"` is deprecated in "+i+s)},e.obsoleteAttr=function(t,e,i,s){let o=t.getAttribute(e);null!==o&&(t.setAttribute(i,o),console.warn("gridstack.js: attribute `"+e+"`="+o+" is deprecated on this object in "+s+" and has been replaced with `"+i+"`. It will be **completely** removed in v1.0"))};class i{static getElements(t){if("string"==typeof t){let e=document.querySelectorAll(t);return e.length||"."===t[0]||"#"===t[0]||(e=document.querySelectorAll("."+t),e.length||(e=document.querySelectorAll("#"+t))),Array.from(e)}return[t]}static getElement(t){if("string"==typeof t){if(!t.length)return null;if("#"===t[0])return document.getElementById(t.substring(1));if("."===t[0]||"["===t[0])return document.querySelector(t);if(!isNaN(+t[0]))return document.getElementById(t);let e=document.querySelector(t);return e||(e=document.getElementById(t)),e||(e=document.querySelector("."+t)),e}return t}static isIntercepted(t,e){return!(t.y>=e.y+e.h||t.y+t.h<=e.y||t.x+t.w<=e.x||t.x>=e.x+e.w)}static isTouching(t,e){return i.isIntercepted(t,{x:e.x-.5,y:e.y-.5,w:e.w+1,h:e.h+1})}static sort(t,e,i){return i=i||t.reduce(((t,e)=>Math.max(e.x+e.w,t)),0)||12,-1===e?t.sort(((t,e)=>e.x+e.y*i-(t.x+t.y*i))):t.sort(((t,e)=>t.x+t.y*i-(e.x+e.y*i)))}static createStylesheet(t,e){let i=document.createElement("style");return i.setAttribute("type","text/css"),i.setAttribute("gs-style-id",t),i.styleSheet?i.styleSheet.cssText="":i.appendChild(document.createTextNode("")),e?e.insertBefore(i,e.firstChild):(e=document.getElementsByTagName("head")[0]).appendChild(i),i.sheet}static removeStylesheet(t){let e=document.querySelector("STYLE[gs-style-id="+t+"]");e&&e.parentNode&&e.remove()}static addCSSRule(t,e,i){"function"==typeof t.addRule?t.addRule(e,i):"function"==typeof t.insertRule&&t.insertRule(`${e}{${i}}`)}static toBool(t){return"boolean"==typeof t?t:"string"==typeof t?!(""===(t=t.toLowerCase())||"no"===t||"false"===t||"0"===t):Boolean(t)}static toNumber(t){return null===t||0===t.length?void 0:Number(t)}static parseHeight(t){let e,i="px";if("string"==typeof t){let s=t.match(/^(-[0-9]+\.[0-9]+|[0-9]*\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw|%)?$/);if(!s)throw new Error("Invalid height");i=s[2]||"px",e=parseFloat(s[1])}else e=t;return{h:e,unit:i}}static defaults(t,...e){return e.forEach((e=>{for(const i in e){if(!e.hasOwnProperty(i))return;null===t[i]||void 0===t[i]?t[i]=e[i]:"object"==typeof e[i]&&"object"==typeof t[i]&&this.defaults(t[i],e[i])}})),t}static same(t,e){if("object"!=typeof t)return t==e;if(typeof t!=typeof e)return!1;if(Object.keys(t).length!==Object.keys(e).length)return!1;for(const i in t)if(t[i]!==e[i])return!1;return!0}static copyPos(t,e,i=!1){return t.x=e.x,t.y=e.y,t.w=e.w,t.h=e.h,i?(e.minW&&(t.minW=e.minW),e.minH&&(t.minH=e.minH),e.maxW&&(t.maxW=e.maxW),e.maxH&&(t.maxH=e.maxH),t):t}static samePos(t,e){return t&&e&&t.x===e.x&&t.y===e.y&&t.w===e.w&&t.h===e.h}static removeInternalAndSame(t,e){if("object"==typeof t&&"object"==typeof e)for(let i in t){let s=t[i];if("_"===i[0]||s===e[i])delete t[i];else if(s&&"object"==typeof s&&void 0!==e[i]){for(let t in s)s[t]!==e[i][t]&&"_"!==t[0]||delete s[t];Object.keys(s).length||delete t[i]}}}static closestByClass(t,e){for(;t=t.parentElement;)if(t.classList.contains(e))return t;return null}static throttle(t,e){let i=!1;return(...s)=>{i||(i=!0,setTimeout((()=>{t(...s),i=!1}),e))}}static removePositioningStyles(t){let e=t.style;e.position&&e.removeProperty("position"),e.left&&e.removeProperty("left"),e.top&&e.removeProperty("top"),e.width&&e.removeProperty("width"),e.height&&e.removeProperty("height")}static getScrollElement(t){if(!t)return document.scrollingElement;const e=getComputedStyle(t);return/(auto|scroll)/.test(e.overflow+e.overflowY)?t:this.getScrollElement(t.parentElement)}static updateScrollPosition(t,e,i){let s=t.getBoundingClientRect(),o=window.innerHeight||document.documentElement.clientHeight;if(s.top<0||s.bottom>o){let r=s.bottom-o,n=s.top,l=this.getScrollElement(t);if(null!==l){let a=l.scrollTop;s.top<0&&i<0?t.offsetHeight>o?l.scrollTop+=i:l.scrollTop+=Math.abs(n)>Math.abs(i)?i:n:i>0&&(t.offsetHeight>o?l.scrollTop+=i:l.scrollTop+=r>i?i:r),e.top+=l.scrollTop-a}}}static updateScrollResize(t,e,i){const s=this.getScrollElement(e),o=s.clientHeight,r=s===this.getScrollElement()?0:s.getBoundingClientRect().top,n=t.clientY-r,l=n>o-i;n boolean;\r\n}\r\n\r\n/** drag&drop options currently called from the main code, but others can be passed in grid options */\r\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\r\nexport type DDOpts = 'enable' | 'disable' | 'destroy' | 'option' | string | any;\r\nexport type DDKey = 'minWidth' | 'minHeight' | 'maxWidth' | 'maxHeight';\r\nexport type DDValue = number | string;\r\n\r\n/** drag&drop events callbacks */\r\nexport type DDCallback = (event: Event, arg2: GridItemHTMLElement, helper?: GridItemHTMLElement) => void;\r\n\r\n/**\r\n * Base class implementing common Grid drag'n'drop functionality, with domain specific subclass (h5 vs jq subclasses)\r\n */\r\nexport abstract class GridStackDD extends GridStackDDI {\r\n\r\n /** override to cast to correct type */\r\n static get(): GridStackDD {\r\n return GridStackDDI.get() as GridStackDD;\r\n }\r\n\r\n /** removes any drag&drop present (called during destroy) */\r\n public remove(el: GridItemHTMLElement): GridStackDD {\r\n this.draggable(el, 'destroy').resizable(el, 'destroy');\r\n if (el.gridstackNode) {\r\n delete el.gridstackNode._initDD; // reset our DD init flag\r\n }\r\n return this;\r\n }\r\n\r\n // APIs that must be implemented by subclasses to do actual darg/drop/resize called by GridStack code below\r\n\r\n public abstract resizable(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue): GridStackDD;\r\n\r\n public abstract isResizable(el: HTMLElement): boolean;\r\n\r\n public abstract draggable(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue): GridStackDD;\r\n\r\n public abstract dragIn(el: GridStackElement, opts: DDDragInOpt): GridStackDD;\r\n\r\n public abstract isDraggable(el: HTMLElement): boolean;\r\n\r\n public abstract droppable(el: GridItemHTMLElement, opts: DDOpts | DDDropOpt, key?: DDKey, value?: DDValue): GridStackDD;\r\n\r\n public abstract isDroppable(el: HTMLElement): boolean;\r\n\r\n public abstract on(el: GridItemHTMLElement, eventName: string, callback: DDCallback): GridStackDD;\r\n\r\n public abstract off(el: GridItemHTMLElement, eventName: string): GridStackDD;\r\n}\r\n\r\n/********************************************************************************\r\n * GridStack code that is doing drag&drop extracted here so main class is smaller\r\n * for static grid that don't do any of this work anyway. Saves about 10k.\r\n * TODO: no code hint in code below as this is so look at alternatives ?\r\n * https://www.typescriptlang.org/docs/handbook/declaration-merging.html\r\n * https://www.typescriptlang.org/docs/handbook/mixins.html\r\n ********************************************************************************/\r\n\r\n/** @internal called to add drag over to support widgets being added externally */\r\nGridStack.prototype._setupAcceptWidget = function(): GridStack {\r\n\r\n // check if we need to disable things\r\n if (this.opts.staticGrid || !this.opts.acceptWidgets) {\r\n GridStackDD.get().droppable(this.el, 'destroy');\r\n return this;\r\n }\r\n\r\n // vars shared across all methods\r\n let gridPos: MousePosition;\r\n let cellHeight: number, cellWidth: number;\r\n\r\n let onDrag = (event: DragEvent, el: GridItemHTMLElement, helper: GridItemHTMLElement) => {\r\n let node = el.gridstackNode;\r\n if (!node) return;\r\n\r\n helper = helper || el;\r\n let rec = helper.getBoundingClientRect();\r\n let left = rec.left - gridPos.left;\r\n let top = rec.top - gridPos.top;\r\n let ui: DDUIData = {position: {top, left}};\r\n\r\n if (node._temporaryRemoved) {\r\n node.x = Math.max(0, Math.round(left / cellWidth));\r\n node.y = Math.max(0, Math.round(top / cellHeight));\r\n delete node.autoPosition;\r\n this.engine.nodeBoundFix(node);\r\n\r\n // don't accept *initial* location if doesn't fit #1419 (locked drop region, or can't grow), but maybe try if it will go somewhere\r\n if (!this.engine.willItFit(node)) {\r\n node.autoPosition = true; // ignore x,y and try for any slot...\r\n if (!this.engine.willItFit(node)) {\r\n GridStackDD.get().off(el, 'drag'); // stop calling us\r\n return; // full grid or can't grow\r\n }\r\n if (node._willFitPos) {\r\n // use the auto position instead #1687\r\n Utils.copyPos(node, node._willFitPos);\r\n delete node._willFitPos;\r\n }\r\n }\r\n\r\n // re-use the existing node dragging method\r\n this._onStartMoving(helper, event, ui, node, cellWidth, cellHeight);\r\n } else {\r\n // re-use the existing node dragging that does so much of the collision detection\r\n this._dragOrResize(helper, event, ui, node, cellWidth, cellHeight);\r\n }\r\n }\r\n\r\n GridStackDD.get()\r\n .droppable(this.el, {\r\n accept: (el: GridItemHTMLElement) => {\r\n let node: GridStackNode = el.gridstackNode;\r\n // set accept drop to true on ourself (which we ignore) so we don't get \"can't drop\" icon in HTML5 mode while moving\r\n if (node && node.grid === this) return true;\r\n if (!this.opts.acceptWidgets) return false;\r\n // check for accept method or class matching\r\n let canAccept = true;\r\n if (typeof this.opts.acceptWidgets === 'function') {\r\n canAccept = this.opts.acceptWidgets(el);\r\n } else {\r\n let selector = (this.opts.acceptWidgets === true ? '.grid-stack-item' : this.opts.acceptWidgets as string);\r\n canAccept = el.matches(selector);\r\n }\r\n // finally check to make sure we actually have space left #1571\r\n if (canAccept && node && this.opts.maxRow) {\r\n let n = {w: node.w, h: node.h, minW: node.minW, minH: node.minH}; // only width/height matters and autoPosition\r\n canAccept = this.engine.willItFit(n);\r\n }\r\n return canAccept;\r\n }\r\n })\r\n /**\r\n * entering our grid area\r\n */\r\n .on(this.el, 'dropover', (event: Event, el: GridItemHTMLElement, helper: GridItemHTMLElement) => {\r\n let node = el.gridstackNode;\r\n // ignore drop enter on ourself (unless we temporarily removed) which happens on a simple drag of our item\r\n if (node && node.grid === this && !node._temporaryRemoved) {\r\n // delete node._added; // reset this to track placeholder again in case we were over other grid #1484 (dropout doesn't always clear)\r\n return false; // prevent parent from receiving msg (which may be a grid as well)\r\n }\r\n\r\n // fix #1578 when dragging fast, we may not get a leave on the previous grid so force one now\r\n if (node && node.grid && node.grid !== this && !node._temporaryRemoved) {\r\n // TEST console.log('dropover without leave');\r\n let otherGrid = node.grid;\r\n otherGrid._leave(el, helper);\r\n }\r\n\r\n // get grid screen coordinates and cell dimensions\r\n let box = this.el.getBoundingClientRect();\r\n gridPos = {top: box.top, left: box.left};\r\n cellWidth = this.cellWidth();\r\n cellHeight = this.getCellHeight(true);\r\n\r\n // load any element attributes if we don't have a node\r\n if (!node) {\r\n node = this._readAttr(el);\r\n }\r\n if (!node.grid) {\r\n node._isExternal = true;\r\n el.gridstackNode = node;\r\n }\r\n\r\n // calculate the grid size based on element outer size\r\n helper = helper || el;\r\n let w = node.w || Math.round(helper.offsetWidth / cellWidth) || 1;\r\n let h = node.h || Math.round(helper.offsetHeight / cellHeight) || 1;\r\n\r\n // if the item came from another grid, make a copy and save the original info in case we go back there\r\n if (node.grid && node.grid !== this) {\r\n // copy the node original values (min/max/id/etc...) but override width/height/other flags which are this grid specific\r\n // TEST console.log('dropover cloning node');\r\n if (!el._gridstackNodeOrig) el._gridstackNodeOrig = node; // shouldn't have multiple nested!\r\n el.gridstackNode = node = {...node, w, h, grid: this};\r\n this.engine.cleanupNode(node)\r\n .nodeBoundFix(node);\r\n // restore some internal fields we need after clearing them all\r\n node._initDD =\r\n node._isExternal = // DOM needs to be re-parented on a drop\r\n node._temporaryRemoved = true; // so it can be inserted onDrag below\r\n } else {\r\n node.w = w; node.h = h;\r\n node._temporaryRemoved = true; // so we can insert it\r\n }\r\n\r\n // clear any marked for complete removal (Note: don't check _isAboutToRemove as that is cleared above - just do it)\r\n _itemRemoving(node.el, false);\r\n\r\n GridStackDD.get().on(el, 'drag', onDrag);\r\n // make sure this is called at least once when going fast #1578\r\n onDrag(event as DragEvent, el, helper);\r\n return false; // prevent parent from receiving msg (which may be a grid as well)\r\n })\r\n /**\r\n * Leaving our grid area...\r\n */\r\n .on(this.el, 'dropout', (event, el: GridItemHTMLElement, helper: GridItemHTMLElement) => {\r\n let node = el.gridstackNode;\r\n // fix #1578 when dragging fast, we might get leave after other grid gets enter (which calls us to clean)\r\n // so skip this one if we're not the active grid really..\r\n if (!node.grid || node.grid === this) {\r\n this._leave(el, helper);\r\n }\r\n return false; // prevent parent from receiving msg (which may be grid as well)\r\n })\r\n /**\r\n * end - releasing the mouse\r\n */\r\n .on(this.el, 'drop', (event, el: GridItemHTMLElement, helper: GridItemHTMLElement) => {\r\n let node = el.gridstackNode;\r\n // ignore drop on ourself from ourself that didn't come from the outside - dragend will handle the simple move instead\r\n if (node && node.grid === this && !node._isExternal) return false;\r\n\r\n let wasAdded = !!this.placeholder.parentElement; // skip items not actually added to us because of constrains, but do cleanup #1419\r\n this.placeholder.remove();\r\n\r\n // notify previous grid of removal\r\n // TEST console.log('drop delete _gridstackNodeOrig')\r\n let origNode = el._gridstackNodeOrig;\r\n delete el._gridstackNodeOrig;\r\n if (wasAdded && origNode && origNode.grid && origNode.grid !== this) {\r\n let oGrid = origNode.grid;\r\n oGrid.engine.removedNodes.push(origNode);\r\n oGrid._triggerRemoveEvent();\r\n }\r\n\r\n if (!node) return false;\r\n\r\n // use existing placeholder node as it's already in our list with drop location\r\n if (wasAdded) {\r\n this.engine.cleanupNode(node); // removes all internal _xyz values\r\n node.grid = this;\r\n }\r\n GridStackDD.get().off(el, 'drag');\r\n // if we made a copy ('helper' which is temp) of the original node then insert a copy, else we move the original node (#1102)\r\n // as the helper will be nuked by jquery-ui otherwise\r\n if (helper !== el) {\r\n helper.remove();\r\n el.gridstackNode = origNode; // original item (left behind) is re-stored to pre dragging as the node now has drop info\r\n if (wasAdded) {\r\n el = el.cloneNode(true) as GridItemHTMLElement;\r\n }\r\n } else {\r\n el.remove(); // reduce flicker as we change depth here, and size further down\r\n GridStackDD.get().remove(el);\r\n }\r\n if (!wasAdded) return false;\r\n el.gridstackNode = node;\r\n node.el = el;\r\n\r\n Utils.copyPos(node, this._readAttr(this.placeholder)); // placeholder values as moving VERY fast can throw things off #1578\r\n Utils.removePositioningStyles(el);\r\n this._writeAttr(el, node);\r\n this.el.appendChild(el);\r\n this._updateContainerHeight();\r\n this.engine.addedNodes.push(node);\r\n this._triggerAddEvent();\r\n this._triggerChangeEvent();\r\n\r\n this.engine.endUpdate();\r\n if (this._gsEventHandler['dropped']) {\r\n this._gsEventHandler['dropped']({type: 'dropped'}, origNode && origNode.grid ? origNode : undefined, node);\r\n }\r\n\r\n // wait till we return out of the drag callback to set the new drag&resize handler or they may get messed up\r\n window.setTimeout(() => {\r\n // IFF we are still there (some application will use as placeholder and insert their real widget instead and better call makeWidget())\r\n if (node.el && node.el.parentElement) {\r\n this._prepareDragDropByNode(node);\r\n } else {\r\n this.engine.removeNode(node);\r\n }\r\n });\r\n\r\n return false; // prevent parent from receiving msg (which may be grid as well)\r\n });\r\n return this;\r\n}\r\n\r\n/** @internal mark item for removal */\r\nfunction _itemRemoving(el: GridItemHTMLElement, remove: boolean) {\r\n let node = el ? el.gridstackNode : undefined;\r\n if (!node || !node.grid) return;\r\n remove ? node._isAboutToRemove = true : delete node._isAboutToRemove;\r\n remove ? el.classList.add('grid-stack-item-removing') : el.classList.remove('grid-stack-item-removing');\r\n}\r\n\r\n/** @internal called to setup a trash drop zone if the user specifies it */\r\nGridStack.prototype._setupRemoveDrop = function(): GridStack {\r\n if (!this.opts.staticGrid && typeof this.opts.removable === 'string') {\r\n let trashEl = document.querySelector(this.opts.removable) as HTMLElement;\r\n if (!trashEl) return this;\r\n // only register ONE drop-over/dropout callback for the 'trash', and it will\r\n // update the passed in item and parent grid because the 'trash' is a shared resource anyway,\r\n // and Native DD only has 1 event CB (having a list and technically a per grid removableOptions complicates things greatly)\r\n if (!GridStackDD.get().isDroppable(trashEl)) {\r\n GridStackDD.get().droppable(trashEl, this.opts.removableOptions)\r\n .on(trashEl, 'dropover', (event, el) => _itemRemoving(el, true))\r\n .on(trashEl, 'dropout', (event, el) => _itemRemoving(el, false));\r\n }\r\n }\r\n return this;\r\n}\r\n\r\n/**\r\n * call to setup dragging in from the outside (say toolbar), by specifying the class selection and options.\r\n * Called during GridStack.init() as options, but can also be called directly (last param are cached) in case the toolbar\r\n * is dynamically create and needs to change later.\r\n **/\r\nGridStack.setupDragIn = function(_dragIn?: string, _dragInOptions?: DDDragInOpt) {\r\n let dragIn: string;\r\n let dragInOptions: DDDragInOpt;\r\n const dragInDefaultOptions: DDDragInOpt = {\r\n revert: 'invalid',\r\n handle: '.grid-stack-item-content',\r\n scroll: false,\r\n appendTo: 'body'\r\n };\r\n\r\n // cache in the passed in values (form grid init?) so they don't have to resend them each time\r\n if (_dragIn) {\r\n dragIn = _dragIn;\r\n dragInOptions = {...dragInDefaultOptions, ...(_dragInOptions || {})};\r\n }\r\n if (typeof dragIn !== 'string') return;\r\n let dd = GridStackDD.get();\r\n Utils.getElements(dragIn).forEach(el => {\r\n if (!dd.isDraggable(el)) dd.dragIn(el, dragInOptions);\r\n });\r\n}\r\n\r\n/** @internal prepares the element for drag&drop **/\r\nGridStack.prototype._prepareDragDropByNode = function(node: GridStackNode): GridStack {\r\n let el = node.el;\r\n let dd = GridStackDD.get();\r\n\r\n // check for disabled grid first\r\n if (this.opts.staticGrid || ((node.noMove || this.opts.disableDrag) && (node.noResize || this.opts.disableResize))) {\r\n if (node._initDD) {\r\n dd.remove(el); // nukes everything instead of just disable, will add some styles back next\r\n delete node._initDD;\r\n }\r\n el.classList.add('ui-draggable-disabled', 'ui-resizable-disabled'); // add styles one might depend on #1435\r\n return this;\r\n }\r\n\r\n if (!node._initDD) {\r\n // variables used/cashed between the 3 start/move/end methods, in addition to node passed above\r\n let cellWidth: number;\r\n let cellHeight: number;\r\n\r\n /** called when item starts moving/resizing */\r\n let onStartMoving = (event: Event, ui: DDUIData) => {\r\n // trigger any 'dragstart' / 'resizestart' manually\r\n if (this._gsEventHandler[event.type]) {\r\n this._gsEventHandler[event.type](event, event.target);\r\n }\r\n cellWidth = this.cellWidth();\r\n cellHeight = this.getCellHeight(true); // force pixels for calculations\r\n\r\n this._onStartMoving(el, event, ui, node, cellWidth, cellHeight);\r\n }\r\n\r\n /** called when item is being dragged/resized */\r\n let dragOrResize = (event: Event, ui: DDUIData) => {\r\n this._dragOrResize(el, event, ui, node, cellWidth, cellHeight);\r\n }\r\n\r\n /** called when the item stops moving/resizing */\r\n let onEndMoving = (event: Event) => {\r\n this.placeholder.remove();\r\n delete node._moving;\r\n delete node._lastTried;\r\n\r\n // if the item has moved to another grid, we're done here\r\n let target: GridItemHTMLElement = event.target as GridItemHTMLElement;\r\n if (!target.gridstackNode || target.gridstackNode.grid !== this) return;\r\n\r\n node.el = target;\r\n\r\n if (node._isAboutToRemove) {\r\n let gridToNotify = el.gridstackNode.grid;\r\n if (gridToNotify._gsEventHandler[event.type]) {\r\n gridToNotify._gsEventHandler[event.type](event, target);\r\n }\r\n dd.remove(el);\r\n gridToNotify.engine.removedNodes.push(node);\r\n gridToNotify._triggerRemoveEvent();\r\n // break circular links and remove DOM\r\n delete el.gridstackNode;\r\n delete node.el;\r\n el.remove();\r\n } else {\r\n if (!node._temporaryRemoved) {\r\n // move to new placeholder location\r\n Utils.removePositioningStyles(target);\r\n this._writePosAttr(target, node);\r\n } else {\r\n // got removed - restore item back to before dragging position\r\n Utils.removePositioningStyles(target);\r\n Utils.copyPos(node, node._orig);\r\n this._writePosAttr(target, node);\r\n this.engine.addNode(node);\r\n }\r\n if (this._gsEventHandler[event.type]) {\r\n this._gsEventHandler[event.type](event, target);\r\n }\r\n }\r\n\r\n this._extraDragRow = 0;\r\n this._updateContainerHeight();\r\n this._triggerChangeEvent();\r\n\r\n this.engine.endUpdate();\r\n }\r\n\r\n dd.draggable(el, {\r\n start: onStartMoving,\r\n stop: onEndMoving,\r\n drag: dragOrResize\r\n }).resizable(el, {\r\n start: onStartMoving,\r\n stop: onEndMoving,\r\n resize: dragOrResize\r\n });\r\n node._initDD = true; // we've set DD support now\r\n }\r\n\r\n // finally fine tune move vs resize by disabling any part...\r\n if (node.noMove || this.opts.disableDrag) {\r\n dd.draggable(el, 'disable');\r\n el.classList.add('ui-draggable-disabled');\r\n } else {\r\n dd.draggable(el, 'enable');\r\n el.classList.remove('ui-draggable-disabled');\r\n }\r\n if (node.noResize || this.opts.disableResize) {\r\n dd.resizable(el, 'disable');\r\n el.classList.add('ui-resizable-disabled');\r\n } else {\r\n dd.resizable(el, 'enable');\r\n el.classList.remove('ui-resizable-disabled');\r\n }\r\n\r\n return this;\r\n}\r\n\r\n/** @internal called when item is starting a drag/resize */\r\nGridStack.prototype._onStartMoving = function(el: GridItemHTMLElement, event: Event, ui: DDUIData, node: GridStackNode, cellWidth: number, cellHeight: number) {\r\n this.engine.cleanNodes()\r\n .beginUpdate(node);\r\n\r\n this._writePosAttr(this.placeholder, node)\r\n this.el.appendChild(this.placeholder);\r\n // TEST console.log('_onStartMoving placeholder')\r\n\r\n node.el = this.placeholder;\r\n node._lastUiPosition = ui.position;\r\n node._prevYPix = ui.position.top;\r\n node._moving = (event.type === 'dragstart'); // 'dropover' are not initially moving so they can go exactly where they enter (will push stuff out of the way)\r\n delete node._lastTried;\r\n\r\n if (event.type === 'dropover' && node._temporaryRemoved) {\r\n // TEST console.log('engine.addNode x=' + node.x);\r\n this.engine.addNode(node); // will add, fix collisions, update attr and clear _temporaryRemoved\r\n node._moving = true; // AFTER, mark as moving object (wanted fix location before)\r\n }\r\n\r\n // set the min/max resize info\r\n this.engine.cacheRects(cellWidth, cellHeight, this.opts.marginTop, this.opts.marginRight, this.opts.marginBottom, this.opts.marginLeft);\r\n if (event.type === 'resizestart') {\r\n let dd = GridStackDD.get()\r\n .resizable(el, 'option', 'minWidth', cellWidth * (node.minW || 1))\r\n .resizable(el, 'option', 'minHeight', cellHeight * (node.minH || 1));\r\n if (node.maxW) { dd.resizable(el, 'option', 'maxWidth', cellWidth * node.maxW); }\r\n if (node.maxH) { dd.resizable(el, 'option', 'maxHeight', cellHeight * node.maxH); }\r\n }\r\n}\r\n\r\n/** @internal called when item leaving our area by either cursor dropout event\r\n * or shape is outside our boundaries. remove it from us, and mark temporary if this was\r\n * our item to start with else restore prev node values from prev grid it came from.\r\n **/\r\nGridStack.prototype._leave = function(el: GridItemHTMLElement, helper?: GridItemHTMLElement) {\r\n let node = el.gridstackNode;\r\n if (!node) return;\r\n\r\n GridStackDD.get().off(el, 'drag'); // no need to track while being outside\r\n\r\n // this gets called when cursor leaves and shape is outside, so only do this once\r\n if (node._temporaryRemoved) return;\r\n node._temporaryRemoved = true;\r\n\r\n this.engine.removeNode(node); // remove placeholder as well, otherwise it's a sign node is not in our list, which is a bigger issue\r\n node.el = node._isExternal && helper ? helper : el; // point back to real item being dragged\r\n\r\n if (this.opts.removable === true) { // boolean vs a class string\r\n // item leaving us and we are supposed to remove on leave (no need to drag onto trash) mark it so\r\n _itemRemoving(el, true);\r\n }\r\n\r\n // finally if item originally came from another grid, but left us, restore things back to prev info\r\n if (el._gridstackNodeOrig) {\r\n // TEST console.log('leave delete _gridstackNodeOrig')\r\n el.gridstackNode = el._gridstackNodeOrig;\r\n delete el._gridstackNodeOrig;\r\n } else if (node._isExternal) {\r\n // item came from outside (like a toolbar) so nuke any node info\r\n delete node.el;\r\n delete el.gridstackNode;\r\n // and restore all nodes back to original\r\n this.engine.restoreInitial();\r\n }\r\n}\r\n\r\n/** @internal called when item is being dragged/resized */\r\nGridStack.prototype._dragOrResize = function(el: GridItemHTMLElement, event: Event, ui: DDUIData, node: GridStackNode, cellWidth: number, cellHeight: number) {\r\n let p = {...node._orig}; // could be undefined (_isExternal) which is ok (drag only set x,y and w,h will default to node value)\r\n let resizing: boolean;\r\n\r\n if (event.type === 'drag') {\r\n if (node._temporaryRemoved) return; // handled by dropover\r\n let distance = ui.position.top - node._prevYPix;\r\n node._prevYPix = ui.position.top;\r\n Utils.updateScrollPosition(el, ui.position, distance);\r\n\r\n // get new position taking into account the margin in the direction we are moving! (need to pass mid point by margin)\r\n let left = ui.position.left + (ui.position.left > node._lastUiPosition.left ? -this.opts.marginRight : this.opts.marginLeft);\r\n let top = ui.position.top + (ui.position.top > node._lastUiPosition.top ? -this.opts.marginBottom : this.opts.marginTop);\r\n p.x = Math.round(left / cellWidth);\r\n p.y = Math.round(top / cellHeight);\r\n\r\n // if we're at the bottom hitting something else, grow the grid so cursor doesn't leave when trying to place below others\r\n let prev = this._extraDragRow;\r\n if (this.engine.collide(node, p)) {\r\n let row = this.getRow();\r\n let extra = Math.max(0, (p.y + node.h) - row);\r\n if (this.opts.maxRow && row + extra > this.opts.maxRow) {\r\n extra = Math.max(0, this.opts.maxRow - row);\r\n }\r\n this._extraDragRow = extra;\r\n } else this._extraDragRow = 0;\r\n if (this._extraDragRow !== prev) this._updateContainerHeight();\r\n\r\n if (node.x === p.x && node.y === p.y) return; // skip same\r\n // DON'T skip one we tried as we might have failed because of coverage <50% before\r\n // if (node._lastTried && node._lastTried.x === x && node._lastTried.y === y) return;\r\n } else if (event.type === 'resize') {\r\n if (p.x < 0) return;\r\n // Scrolling page if needed\r\n Utils.updateScrollResize(event as MouseEvent, el, cellHeight);\r\n\r\n // get new size\r\n p.w = Math.round((ui.size.width - this.opts.marginLeft) / cellWidth);\r\n p.h = Math.round((ui.size.height - this.opts.marginTop) / cellHeight);\r\n if (node.w === p.w && node.h === p.h) return;\r\n if (node._lastTried && node._lastTried.w === p.w && node._lastTried.h === p.h) return; // skip one we tried (but failed)\r\n\r\n // if we size on left/top side this might move us, so get possible new position as well\r\n let left = ui.position.left + this.opts.marginLeft;\r\n let top = ui.position.top + this.opts.marginTop;\r\n p.x = Math.round(left / cellWidth);\r\n p.y = Math.round(top / cellHeight);\r\n\r\n resizing = true;\r\n }\r\n\r\n node._lastTried = p; // set as last tried (will nuke if we go there)\r\n let rect: GridStackPosition = { // screen pix of the dragged box\r\n x: ui.position.left + this.opts.marginLeft,\r\n y: ui.position.top + this.opts.marginTop,\r\n w: (ui.size ? ui.size.width : node.w * cellWidth) - this.opts.marginLeft - this.opts.marginRight,\r\n h: (ui.size ? ui.size.height : node.h * cellHeight) - this.opts.marginTop - this.opts.marginBottom\r\n };\r\n if (this.engine.moveNodeCheck(node, {...p, cellWidth, cellHeight, rect})) {\r\n node._lastUiPosition = ui.position;\r\n this.engine.cacheRects(cellWidth, cellHeight, this.opts.marginTop, this.opts.marginRight, this.opts.marginBottom, this.opts.marginLeft);\r\n delete node._skipDown;\r\n if (resizing && node.subGrid) { (node.subGrid as GridStack).onParentResize(); }\r\n this._extraDragRow = 0;\r\n this._updateContainerHeight();\r\n\r\n let target = event.target as GridItemHTMLElement;\r\n this._writePosAttr(target, node);\r\n if (this._gsEventHandler[event.type]) {\r\n this._gsEventHandler[event.type](event, target);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Enables/Disables moving.\r\n * @param els widget or selector to modify.\r\n * @param val if true widget will be draggable.\r\n */\r\nGridStack.prototype.movable = function(els: GridStackElement, val: boolean): GridStack {\r\n if (this.opts.staticGrid) return this; // can't move a static grid!\r\n GridStack.getElements(els).forEach(el => {\r\n let node = el.gridstackNode;\r\n if (!node) return;\r\n if (val) delete node.noMove; else node.noMove = true;\r\n this._prepareDragDropByNode(node); // init DD if need be, and adjust\r\n });\r\n return this;\r\n}\r\n\r\n/**\r\n * Enables/Disables resizing.\r\n * @param els widget or selector to modify\r\n * @param val if true widget will be resizable.\r\n */\r\nGridStack.prototype.resizable = function(els: GridStackElement, val: boolean): GridStack {\r\n if (this.opts.staticGrid) return this; // can't resize a static grid!\r\n GridStack.getElements(els).forEach(el => {\r\n let node = el.gridstackNode;\r\n if (!node) return;\r\n if (val) delete node.noResize; else node.noResize = true;\r\n this._prepareDragDropByNode(node); // init DD if need be, and adjust\r\n });\r\n return this;\r\n}\r\n\r\n\r\n/**\r\n * Temporarily disables widgets moving/resizing.\r\n * If you want a more permanent way (which freezes up resources) use `setStatic(true)` instead.\r\n * Note: no-op for static grid\r\n * This is a shortcut for:\r\n * @example\r\n * grid.enableMove(false);\r\n * grid.enableResize(false);\r\n */\r\nGridStack.prototype.disable = function(): GridStack {\r\n if (this.opts.staticGrid) return;\r\n this.enableMove(false);\r\n this.enableResize(false);\r\n this._triggerEvent('disable');\r\n return this;\r\n}\r\n\r\n/**\r\n * Re-enables widgets moving/resizing - see disable().\r\n * Note: no-op for static grid.\r\n * This is a shortcut for:\r\n * @example\r\n * grid.enableMove(true);\r\n * grid.enableResize(true);\r\n */\r\nGridStack.prototype.enable = function(): GridStack {\r\n if (this.opts.staticGrid) return;\r\n this.enableMove(true);\r\n this.enableResize(true);\r\n this._triggerEvent('enable');\r\n return this;\r\n}\r\n\r\n/** Enables/disables widget moving. No-op for static grids. */\r\nGridStack.prototype.enableMove = function(doEnable: boolean): GridStack {\r\n if (this.opts.staticGrid) return this; // can't move a static grid!\r\n this.opts.disableDrag = !doEnable; // FIRST before we update children as grid overrides #1658\r\n this.engine.nodes.forEach(n => this.movable(n.el, doEnable));\r\n return this;\r\n}\r\n\r\n/** Enables/disables widget resizing. No-op for static grids. */\r\nGridStack.prototype.enableResize = function(doEnable: boolean): GridStack {\r\n if (this.opts.staticGrid) return this; // can't size a static grid!\r\n this.opts.disableResize = !doEnable; // FIRST before we update children as grid overrides #1658\r\n this.engine.nodes.forEach(n => this.resizable(n.el, doEnable));\r\n return this;\r\n}\r\n","/**\r\n * gridstack-ddi.ts 4.2.5\r\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\r\n */\r\n\r\nimport { GridItemHTMLElement } from './types';\r\n\r\n/**\r\n * Abstract Partial Interface API for drag'n'drop plugin - look at GridStackDD and HTML5 / Jquery implementation versions\r\n */\r\nexport class GridStackDDI {\r\n\r\n protected static ddi: GridStackDDI;\r\n\r\n /** call this method to register your plugin instead of the default no-op one */\r\n static registerPlugin(pluginClass: typeof GridStackDDI): GridStackDDI {\r\n GridStackDDI.ddi = new pluginClass();\r\n return GridStackDDI.ddi;\r\n }\r\n\r\n /** get the current registered plugin to use */\r\n static get(): GridStackDDI {\r\n return GridStackDDI.ddi || GridStackDDI.registerPlugin(GridStackDDI);\r\n }\r\n\r\n /** removes any drag&drop present (called during destroy) */\r\n /* eslint-disable-next-line @typescript-eslint/no-unused-vars */\r\n public remove(el: GridItemHTMLElement): GridStackDDI {\r\n return this; // no-op for static grids\r\n }\r\n}\r\n","/**\r\n * gridstack-engine.ts 4.2.5\r\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\r\n */\r\n\r\nimport { Utils } from './utils';\r\nimport { GridStackNode, ColumnOptions, GridStackPosition, GridStackMoveOpts } from './types';\r\n\r\nexport type onChangeCB = (nodes: GridStackNode[], removeDOM?: boolean) => void;\r\n/** options used for creations - similar to GridStackOptions */\r\nexport interface GridStackEngineOptions {\r\n column?: number;\r\n maxRow?: number;\r\n float?: boolean;\r\n nodes?: GridStackNode[];\r\n onChange?: onChangeCB;\r\n}\r\n\r\n/**\r\n * Defines the GridStack engine that does most no DOM grid manipulation.\r\n * See GridStack methods and vars for descriptions.\r\n *\r\n * NOTE: values should not be modified directly - call the main GridStack API instead\r\n */\r\nexport class GridStackEngine {\r\n public column: number;\r\n public maxRow: number;\r\n public nodes: GridStackNode[];\r\n public onChange: onChangeCB;\r\n public addedNodes: GridStackNode[] = [];\r\n public removedNodes: GridStackNode[] = [];\r\n public batchMode: boolean;\r\n /** @internal */\r\n private _float: boolean;\r\n /** @internal */\r\n private _prevFloat: boolean;\r\n /** @internal */\r\n private _layouts?: Layout[][]; // maps column # to array of values nodes\r\n /** @internal */\r\n private _ignoreLayoutsNodeChange: boolean;\r\n /** @internal true if we have some items locked */\r\n private _hasLocked: boolean;\r\n /** @internal unique global internal _id counter NOT starting at 0 */\r\n private static _idSeq = 1;\r\n\r\n public constructor(opts: GridStackEngineOptions = {}) {\r\n this.column = opts.column || 12;\r\n this.onChange = opts.onChange;\r\n this._float = opts.float;\r\n this.maxRow = opts.maxRow;\r\n this.nodes = opts.nodes || [];\r\n }\r\n\r\n public batchUpdate(): GridStackEngine {\r\n if (this.batchMode) return this;\r\n this.batchMode = true;\r\n this._prevFloat = this._float;\r\n this._float = true; // let things go anywhere for now... commit() will restore and possibly reposition\r\n this.saveInitial(); // since begin update (which is called multiple times) won't do this\r\n return this;\r\n }\r\n\r\n public commit(): GridStackEngine {\r\n if (!this.batchMode) return this;\r\n this.batchMode = false;\r\n this._float = this._prevFloat;\r\n delete this._prevFloat;\r\n return this._packNodes()\r\n ._notify();\r\n }\r\n\r\n // use entire row for hitting area (will use bottom reverse sorted first) if we not actively moving DOWN and didn't already skip\r\n private _useEntireRowArea(node: GridStackNode, nn: GridStackPosition): boolean {\r\n return !this.float && !this._hasLocked && (!node._moving || node._skipDown || nn.y <= node.y);\r\n }\r\n\r\n /** @internal fix collision on given 'node', going to given new location 'nn', with optional 'collide' node already found.\r\n * return true if we moved. */\r\n private _fixCollisions(node: GridStackNode, nn = node, collide?: GridStackNode, opt: GridStackMoveOpts = {}): boolean {\r\n this._sortNodes(-1); // from last to first, so recursive collision move items in the right order\r\n\r\n collide = collide || this.collide(node, nn); // REAL area collide for swap and skip if none...\r\n if (!collide) return false;\r\n\r\n // swap check: if we're actively moving in gravity mode, see if we collide with an object the same size\r\n if (node._moving && !opt.nested && !this.float) {\r\n if (this.swap(node, collide)) return true;\r\n }\r\n\r\n // during while() collisions MAKE SURE to check entire row so larger items don't leap frog small ones (push them all down starting last in grid)\r\n let area = nn;\r\n if (this._useEntireRowArea(node, nn)) {\r\n area = {x: 0, w: this.column, y: nn.y, h: nn.h};\r\n collide = this.collide(node, area, opt.skip); // force new hit\r\n }\r\n\r\n let didMove = false;\r\n let newOpt: GridStackMoveOpts = {nested: true, pack: false};\r\n while (collide = collide || this.collide(node, area, opt.skip)) { // could collide with more than 1 item... so repeat for each\r\n let moved: boolean;\r\n // if colliding with a locked item OR moving down with top gravity (and collide could move up) -> skip past the collide,\r\n // but remember that skip down so we only do this once (and push others otherwise).\r\n if (collide.locked || node._moving && !node._skipDown && nn.y > node.y && !this.float &&\r\n // can take space we had, or before where we're going\r\n (!this.collide(collide, {...collide, y: node.y}, node) || !this.collide(collide, {...collide, y: nn.y - collide.h}, node))) {\r\n node._skipDown = (node._skipDown || nn.y > node.y);\r\n moved = this.moveNode(node, {...nn, y: collide.y + collide.h, ...newOpt});\r\n if (collide.locked && moved) {\r\n Utils.copyPos(nn, node); // moving after lock become our new desired location\r\n } else if (!collide.locked && moved && opt.pack) {\r\n // we moved after and will pack: do it now and keep the original drop location, but past the old collide to see what else we might push way\r\n this._packNodes();\r\n nn.y = collide.y + collide.h;\r\n Utils.copyPos(node, nn);\r\n }\r\n didMove = didMove || moved;\r\n } else {\r\n // move collide down *after* where we will be, ignoring where we are now (don't collide with us)\r\n moved = this.moveNode(collide, {...collide, y: nn.y + nn.h, skip: node, ...newOpt});\r\n }\r\n if (!moved) { return didMove; } // break inf loop if we couldn't move after all (ex: maxRow, fixed)\r\n collide = undefined;\r\n }\r\n return didMove;\r\n }\r\n\r\n /** return the nodes that intercept the given node. Optionally a different area can be used, as well as a second node to skip */\r\n public collide(skip: GridStackNode, area = skip, skip2?: GridStackNode): GridStackNode {\r\n return this.nodes.find(n => n !== skip && n !== skip2 && Utils.isIntercepted(n, area));\r\n }\r\n public collideAll(skip: GridStackNode, area = skip, skip2?: GridStackNode): GridStackNode[] {\r\n return this.nodes.filter(n => n !== skip && n !== skip2 && Utils.isIntercepted(n, area));\r\n }\r\n\r\n /** does a pixel coverage collision, returning the node that has the most coverage that is >50% mid line */\r\n public collideCoverage(node: GridStackNode, o: GridStackMoveOpts, collides: GridStackNode[]): GridStackNode {\r\n if (!o.rect || !node._rect) return;\r\n let r0 = node._rect; // where started\r\n let r = {...o.rect}; // where we are\r\n\r\n // update dragged rect to show where it's coming from (above or below, etc...)\r\n if (r.y > r0.y) {\r\n r.h += r.y - r0.y;\r\n r.y = r0.y;\r\n } else {\r\n r.h += r0.y - r.y;\r\n }\r\n if (r.x > r0.x) {\r\n r.w += r.x - r0.x;\r\n r.x = r0.x;\r\n } else {\r\n r.w += r0.x - r.x;\r\n }\r\n\r\n let collide: GridStackNode;\r\n collides.forEach(n => {\r\n if (n.locked || !n._rect) return;\r\n let r2 = n._rect; // overlapping target\r\n let yOver = Number.MAX_VALUE, xOver = Number.MAX_VALUE, overMax = 0.5; // need >50%\r\n // depending on which side we started from, compute the overlap % of coverage\r\n // (ex: from above/below we only compute the max horizontal line coverage)\r\n if (r0.y < r2.y) { // from above\r\n yOver = ((r.y + r.h) - r2.y) / r2.h;\r\n } else if (r0.y+r0.h > r2.y+r2.h) { // from below\r\n yOver = ((r2.y + r2.h) - r.y) / r2.h;\r\n }\r\n if (r0.x < r2.x) { // from the left\r\n xOver = ((r.x + r.w) - r2.x) / r2.w;\r\n } else if (r0.x+r0.w > r2.x+r2.w) { // from the right\r\n xOver = ((r2.x + r2.w) - r.x) / r2.w;\r\n }\r\n let over = Math.min(xOver, yOver);\r\n if (over > overMax) {\r\n overMax = over;\r\n collide = n;\r\n }\r\n });\r\n return collide;\r\n }\r\n\r\n /** called to cache the nodes pixel rectangles used for collision detection during drag */\r\n public cacheRects(w: number, h: number, top: number, right: number, bottom: number, left: number): GridStackEngine\r\n {\r\n this.nodes.forEach(n =>\r\n n._rect = {\r\n y: n.y * h + top,\r\n x: n.x * w + left,\r\n w: n.w * w - left - right,\r\n h: n.h * h - top - bottom\r\n }\r\n );\r\n return this;\r\n }\r\n\r\n /** called to possibly swap between 2 nodes (same size or column, not locked, touching), returning true if successful */\r\n public swap(a: GridStackNode, b: GridStackNode): boolean {\r\n if (!b || b.locked || !a || a.locked) return false;\r\n\r\n function _doSwap(): true { // assumes a is before b IFF they have different height (put after rather than exact swap)\r\n let x = b.x, y = b.y;\r\n b.x = a.x; b.y = a.y; // b -> a position\r\n if (a.h != b.h) {\r\n a.x = x; a.y = b.y + b.h; // a -> goes after b\r\n } else {\r\n a.x = x; a.y = y; // a -> old b position\r\n }\r\n a._dirty = b._dirty = true;\r\n return true;\r\n }\r\n let touching: boolean; // remember if we called it (vs undefined)\r\n\r\n // same size and same row or column, and touching\r\n if (a.w === b.w && a.h === b.h && (a.x === b.x || a.y === b.y) && (touching = Utils.isTouching(a, b)))\r\n return _doSwap();\r\n if (touching === false) return; // ran test and fail, bail out\r\n\r\n // check for taking same columns (but different height) and touching\r\n if (a.w === b.w && a.x === b.x && (touching || Utils.isTouching(a, b))) {\r\n if (b.y < a.y) { let t = a; a = b; b = t; } // swap a <-> b vars so a is first\r\n return _doSwap();\r\n }\r\n\r\n /* different X will be weird (expect vertical swap) and different height overlap, so too complex. user regular layout instead\r\n // else check if swapping would not collide with anything else (requiring a re-layout)\r\n if (!this.collide(a, {x: a.x, y: a.y, w: b.w, h: b.h}, b) &&\r\n !this.collide(a, {x: b.x, y: b.y, w: a.w, h: a.h}, b))\r\n return _doSwap(); */\r\n return false;\r\n }\r\n\r\n public isAreaEmpty(x: number, y: number, w: number, h: number): boolean {\r\n let nn: GridStackNode = {x: x || 0, y: y || 0, w: w || 1, h: h || 1};\r\n return !this.collide(nn);\r\n }\r\n\r\n /** re-layout grid items to reclaim any empty space */\r\n public compact(): GridStackEngine {\r\n if (this.nodes.length === 0) return this;\r\n this.batchUpdate()\r\n ._sortNodes();\r\n let copyNodes = this.nodes;\r\n this.nodes = []; // pretend we have no nodes to conflict layout to start with...\r\n copyNodes.forEach(node => {\r\n if (!node.locked) {\r\n node.autoPosition = true;\r\n }\r\n this.addNode(node, false); // 'false' for add event trigger\r\n node._dirty = true; // will force attr update\r\n });\r\n return this.commit();\r\n }\r\n\r\n /** enable/disable floating widgets (default: `false`) See [example](http://gridstackjs.com/demo/float.html) */\r\n public set float(val: boolean) {\r\n if (this._float === val) return;\r\n this._float = val || false;\r\n if (!val) {\r\n this._packNodes()._notify();\r\n }\r\n }\r\n\r\n /** float getter method */\r\n public get float(): boolean { return this._float || false; }\r\n\r\n /** @internal */\r\n private _sortNodes(dir?: -1 | 1): GridStackEngine {\r\n this.nodes = Utils.sort(this.nodes, dir, this.column);\r\n return this;\r\n }\r\n\r\n /** @internal called to top gravity pack the items back OR revert back to original Y positions when floating */\r\n private _packNodes(): GridStackEngine {\r\n this._sortNodes(); // first to last\r\n\r\n if (this.float) {\r\n // restore original Y pos\r\n this.nodes.forEach(n => {\r\n if (n._updating || n._orig === undefined || n.y === n._orig.y) return;\r\n let newY = n.y;\r\n while (newY > n._orig.y) {\r\n --newY;\r\n let collide = this.collide(n, {x: n.x, y: newY, w: n.w, h: n.h});\r\n if (!collide) {\r\n n._dirty = true;\r\n n.y = newY;\r\n }\r\n }\r\n });\r\n } else {\r\n // top gravity pack\r\n this.nodes.forEach((n, i) => {\r\n if (n.locked) return;\r\n while (n.y > 0) {\r\n let newY = i === 0 ? 0 : n.y - 1;\r\n let canBeMoved = i === 0 || !this.collide(n, {x: n.x, y: newY, w: n.w, h: n.h});\r\n if (!canBeMoved) break;\r\n // Note: must be dirty (from last position) for GridStack::OnChange CB to update positions\r\n // and move items back. The user 'change' CB should detect changes from the original\r\n // starting position instead.\r\n n._dirty = (n.y !== newY);\r\n n.y = newY;\r\n }\r\n });\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * given a random node, makes sure it's coordinates/values are valid in the current grid\r\n * @param node to adjust\r\n * @param resizing if out of bound, resize down or move into the grid to fit ?\r\n */\r\n public prepareNode(node: GridStackNode, resizing?: boolean): GridStackNode {\r\n node = node || {};\r\n node._id = node._id || GridStackEngine._idSeq++;\r\n\r\n // if we're missing position, have the grid position us automatically (before we set them to 0,0)\r\n if (node.x === undefined || node.y === undefined || node.x === null || node.y === null) {\r\n node.autoPosition = true;\r\n }\r\n\r\n // assign defaults for missing required fields\r\n let defaults: GridStackNode = { x: 0, y: 0, w: 1, h: 1};\r\n Utils.defaults(node, defaults);\r\n\r\n if (!node.autoPosition) { delete node.autoPosition; }\r\n if (!node.noResize) { delete node.noResize; }\r\n if (!node.noMove) { delete node.noMove; }\r\n\r\n // check for NaN (in case messed up strings were passed. can't do parseInt() || defaults.x above as 0 is valid #)\r\n if (typeof node.x == 'string') { node.x = Number(node.x); }\r\n if (typeof node.y == 'string') { node.y = Number(node.y); }\r\n if (typeof node.w == 'string') { node.w = Number(node.w); }\r\n if (typeof node.h == 'string') { node.h = Number(node.h); }\r\n if (isNaN(node.x)) { node.x = defaults.x; node.autoPosition = true; }\r\n if (isNaN(node.y)) { node.y = defaults.y; node.autoPosition = true; }\r\n if (isNaN(node.w)) { node.w = defaults.w; }\r\n if (isNaN(node.h)) { node.h = defaults.h; }\r\n\r\n return this.nodeBoundFix(node, resizing);\r\n }\r\n\r\n /** part2 of preparing a node to fit inside our grid - checks for x,y from grid dimensions */\r\n public nodeBoundFix(node: GridStackNode, resizing?: boolean): GridStackNode {\r\n\r\n if (node.maxW) { node.w = Math.min(node.w, node.maxW); }\r\n if (node.maxH) { node.h = Math.min(node.h, node.maxH); }\r\n if (node.minW) { node.w = Math.max(node.w, node.minW); }\r\n if (node.minH) { node.h = Math.max(node.h, node.minH); }\r\n\r\n if (node.w > this.column) {\r\n // if user loaded a larger than allowed widget for current # of columns,\r\n // remember it's full width so we can restore back (1 -> 12 column) #1655\r\n if (this.column < 12) {\r\n node.w = Math.min(12, node.w);\r\n this.cacheOneLayout(node, 12);\r\n }\r\n node.w = this.column;\r\n } else if (node.w < 1) {\r\n node.w = 1;\r\n }\r\n\r\n if (this.maxRow && node.h > this.maxRow) {\r\n node.h = this.maxRow;\r\n } else if (node.h < 1) {\r\n node.h = 1;\r\n }\r\n\r\n if (node.x < 0) {\r\n node.x = 0;\r\n }\r\n if (node.y < 0) {\r\n node.y = 0;\r\n }\r\n\r\n if (node.x + node.w > this.column) {\r\n if (resizing) {\r\n node.w = this.column - node.x;\r\n } else {\r\n node.x = this.column - node.w;\r\n }\r\n }\r\n if (this.maxRow && node.y + node.h > this.maxRow) {\r\n if (resizing) {\r\n node.h = this.maxRow - node.y;\r\n } else {\r\n node.y = this.maxRow - node.h;\r\n }\r\n }\r\n\r\n return node;\r\n }\r\n\r\n public getDirtyNodes(verify?: boolean): GridStackNode[] {\r\n // compare original x,y,w,h instead as _dirty can be a temporary state\r\n if (verify) {\r\n return this.nodes.filter(n => n._dirty && !Utils.samePos(n, n._orig));\r\n }\r\n return this.nodes.filter(n => n._dirty);\r\n }\r\n\r\n /** @internal call this to call onChange CB with dirty nodes */\r\n private _notify(nodes?: GridStackNode | GridStackNode[], removeDOM = true): GridStackEngine {\r\n if (this.batchMode) return this;\r\n nodes = (nodes === undefined ? [] : (Array.isArray(nodes) ? nodes : [nodes]) );\r\n let dirtyNodes = nodes.concat(this.getDirtyNodes());\r\n this.onChange && this.onChange(dirtyNodes, removeDOM);\r\n return this;\r\n }\r\n\r\n /** @internal remove dirty and last tried info */\r\n public cleanNodes(): GridStackEngine {\r\n if (this.batchMode) return this;\r\n this.nodes.forEach(n => {\r\n delete n._dirty;\r\n delete n._lastTried;\r\n });\r\n return this;\r\n }\r\n\r\n /** @internal called to save initial position/size to track real dirty state.\r\n * Note: should be called right after we call change event (so next API is can detect changes)\r\n * as well as right before we start move/resize/enter (so we can restore items to prev values) */\r\n public saveInitial(): GridStackEngine {\r\n this.nodes.forEach(n => {\r\n n._orig = Utils.copyPos({}, n);\r\n delete n._dirty;\r\n });\r\n this._hasLocked = this.nodes.some(n => n.locked);\r\n return this;\r\n }\r\n\r\n /** @internal restore all the nodes back to initial values (called when we leave) */\r\n public restoreInitial(): GridStackEngine {\r\n this.nodes.forEach(n => {\r\n if (Utils.samePos(n, n._orig)) return;\r\n Utils.copyPos(n, n._orig);\r\n n._dirty = true;\r\n });\r\n this._notify();\r\n return this;\r\n }\r\n\r\n /** call to add the given node to our list, fixing collision and re-packing */\r\n public addNode(node: GridStackNode, triggerAddEvent = false): GridStackNode {\r\n let dup: GridStackNode;\r\n if (dup = this.nodes.find(n => n._id === node._id)) return dup; // prevent inserting twice! return it instead.\r\n\r\n node = this.prepareNode(node);\r\n delete node._temporaryRemoved;\r\n delete node._removeDOM;\r\n\r\n if (node.autoPosition) {\r\n this._sortNodes();\r\n\r\n for (let i = 0;; ++i) {\r\n let x = i % this.column;\r\n let y = Math.floor(i / this.column);\r\n if (x + node.w > this.column) {\r\n continue;\r\n }\r\n let box = {x, y, w: node.w, h: node.h};\r\n if (!this.nodes.find(n => Utils.isIntercepted(box, n))) {\r\n node.x = x;\r\n node.y = y;\r\n delete node.autoPosition; // found our slot\r\n break;\r\n }\r\n }\r\n }\r\n\r\n this.nodes.push(node);\r\n triggerAddEvent && this.addedNodes.push(node);\r\n\r\n this._fixCollisions(node);\r\n this._packNodes()\r\n ._notify();\r\n return node;\r\n }\r\n\r\n public removeNode(node: GridStackNode, removeDOM = true, triggerEvent = false): GridStackEngine {\r\n if (!this.nodes.find(n => n === node)) {\r\n // TEST console.log(`Error: GridStackEngine.removeNode() node._id=${node._id} not found!`)\r\n return this;\r\n }\r\n if (triggerEvent) { // we wait until final drop to manually track removed items (rather than during drag)\r\n this.removedNodes.push(node);\r\n }\r\n if (removeDOM) node._removeDOM = true; // let CB remove actual HTML (used to set _id to null, but then we loose layout info)\r\n // don't use 'faster' .splice(findIndex(),1) in case node isn't in our list, or in multiple times.\r\n this.nodes = this.nodes.filter(n => n !== node);\r\n return this._packNodes()\r\n ._notify(node);\r\n }\r\n\r\n public removeAll(removeDOM = true): GridStackEngine {\r\n delete this._layouts;\r\n if (this.nodes.length === 0) return this;\r\n removeDOM && this.nodes.forEach(n => n._removeDOM = true); // let CB remove actual HTML (used to set _id to null, but then we loose layout info)\r\n this.removedNodes = this.nodes;\r\n this.nodes = [];\r\n return this._notify(this.removedNodes);\r\n }\r\n\r\n /** checks if item can be moved (layout constrain) vs moveNode(), returning true if was able to move.\r\n * In more complicated cases (maxRow) it will attempt at moving the item and fixing\r\n * others in a clone first, then apply those changes if still within specs. */\r\n public moveNodeCheck(node: GridStackNode, o: GridStackMoveOpts): boolean {\r\n // if (node.locked) return false;\r\n if (!this.changedPosConstrain(node, o)) return false;\r\n o.pack = true;\r\n\r\n // simpler case: move item directly...\r\n if (!this.maxRow/* && !this._hasLocked*/) {\r\n return this.moveNode(node, o);\r\n }\r\n\r\n // complex case: create a clone with NO maxRow (will check for out of bounds at the end)\r\n let clonedNode: GridStackNode;\r\n let clone = new GridStackEngine({\r\n column: this.column,\r\n float: this.float,\r\n nodes: this.nodes.map(n => {\r\n if (n === node) {\r\n clonedNode = {...n};\r\n return clonedNode;\r\n }\r\n return {...n};\r\n })\r\n });\r\n if (!clonedNode) return false;\r\n\r\n let canMove = clone.moveNode(clonedNode, o);\r\n // if maxRow make sure we are still valid size\r\n if (this.maxRow && canMove) {\r\n canMove = (clone.getRow() <= this.maxRow);\r\n // turns out we can't grow, then see if we can swap instead (ex: full grid)\r\n if (!canMove) {\r\n let collide = this.collide(node, o);\r\n if (collide && this.swap(node, collide)) {\r\n this._notify();\r\n return true;\r\n }\r\n }\r\n }\r\n if (!canMove) return false;\r\n\r\n // if clone was able to move, copy those mods over to us now instead of caller trying to do this all over!\r\n // Note: we can't use the list directly as elements and other parts point to actual node, so copy content\r\n clone.nodes.filter(n => n._dirty).forEach(c => {\r\n let n = this.nodes.find(a => a._id === c._id);\r\n if (!n) return;\r\n Utils.copyPos(n, c);\r\n n._dirty = true;\r\n });\r\n this._notify();\r\n return true;\r\n }\r\n\r\n /** return true if can fit in grid height constrain only (always true if no maxRow) */\r\n public willItFit(node: GridStackNode): boolean {\r\n delete node._willFitPos;\r\n if (!this.maxRow) return true;\r\n // create a clone with NO maxRow and check if still within size\r\n let clone = new GridStackEngine({\r\n column: this.column,\r\n float: this.float,\r\n nodes: this.nodes.map(n => {return {...n}})\r\n });\r\n let n = {...node}; // clone node so we don't mod any settings on it but have full autoPosition and min/max as well! #1687\r\n this.cleanupNode(n);\r\n delete n.el; delete n._id; delete n.content; delete n.grid;\r\n clone.addNode(n);\r\n if (clone.getRow() <= this.maxRow) {\r\n node._willFitPos = Utils.copyPos({}, n);\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /** true if x,y or w,h are different after clamping to min/max */\r\n public changedPosConstrain(node: GridStackNode, p: GridStackPosition): boolean {\r\n // make sure w,h are set\r\n p.w = p.w || node.w;\r\n p.h = p.h || node.h;\r\n if (node.x !== p.x || node.y !== p.y) return true;\r\n // check constrained w,h\r\n if (node.maxW) { p.w = Math.min(p.w, node.maxW); }\r\n if (node.maxH) { p.h = Math.min(p.h, node.maxH); }\r\n if (node.minW) { p.w = Math.max(p.w, node.minW); }\r\n if (node.minH) { p.h = Math.max(p.h, node.minH); }\r\n return (node.w !== p.w || node.h !== p.h);\r\n }\r\n\r\n /** return true if the passed in node was actually moved (checks for no-op and locked) */\r\n public moveNode(node: GridStackNode, o: GridStackMoveOpts): boolean {\r\n if (!node || /*node.locked ||*/ !o) return false;\r\n if (o.pack === undefined) o.pack = true;\r\n\r\n // constrain the passed in values and check if we're still changing our node\r\n if (typeof o.x !== 'number') { o.x = node.x; }\r\n if (typeof o.y !== 'number') { o.y = node.y; }\r\n if (typeof o.w !== 'number') { o.w = node.w; }\r\n if (typeof o.h !== 'number') { o.h = node.h; }\r\n let resizing = (node.w !== o.w || node.h !== o.h);\r\n let nn: GridStackNode = Utils.copyPos({}, node, true); // get min/max out first, then opt positions next\r\n Utils.copyPos(nn, o);\r\n nn = this.nodeBoundFix(nn, resizing);\r\n Utils.copyPos(o, nn);\r\n\r\n if (Utils.samePos(node, o)) return false;\r\n let prevPos: GridStackPosition = Utils.copyPos({}, node);\r\n\r\n // during while() collisions make sure to check entire row so larger items don't leap frog small ones (push them all down)\r\n let area = nn;\r\n // if (this._useEntireRowArea(node, nn)) {\r\n // area = {x: 0, w: this.column, y: nn.y, h: nn.h};\r\n // }\r\n\r\n // check if we will need to fix collision at our new location\r\n let collides = this.collideAll(node, area, o.skip);\r\n let needToMove = true;\r\n if (collides.length) {\r\n // now check to make sure we actually collided over 50% surface area while dragging\r\n let collide = node._moving && !o.nested ? this.collideCoverage(node, o, collides) : collides[0];\r\n if (collide) {\r\n needToMove = !this._fixCollisions(node, nn, collide, o); // check if already moved...\r\n } else {\r\n needToMove = false; // we didn't cover >50% for a move, skip...\r\n }\r\n }\r\n\r\n // now move (to the original ask vs the collision version which might differ) and repack things\r\n if (needToMove) {\r\n node._dirty = true;\r\n Utils.copyPos(node, nn);\r\n }\r\n if (o.pack) {\r\n this._packNodes()\r\n ._notify();\r\n }\r\n return !Utils.samePos(node, prevPos); // pack might have moved things back\r\n }\r\n\r\n public getRow(): number {\r\n return this.nodes.reduce((row, n) => Math.max(row, n.y + n.h), 0);\r\n }\r\n\r\n public beginUpdate(node: GridStackNode): GridStackEngine {\r\n if (!node._updating) {\r\n node._updating = true;\r\n delete node._skipDown;\r\n if (!this.batchMode) this.saveInitial();\r\n }\r\n return this;\r\n }\r\n\r\n public endUpdate(): GridStackEngine {\r\n let n = this.nodes.find(n => n._updating);\r\n if (n) {\r\n delete n._updating;\r\n delete n._skipDown;\r\n }\r\n return this;\r\n }\r\n\r\n /** saves the current layout returning a list of widgets for serialization */\r\n public save(saveElement = true): GridStackNode[] {\r\n let widgets: GridStackNode[] = [];\r\n this._sortNodes();\r\n this.nodes.forEach(n => {\r\n let w: GridStackNode = {};\r\n for (let key in n) { if (key[0] !== '_' && n[key] !== null && n[key] !== undefined ) w[key] = n[key]; }\r\n // delete other internals\r\n if (!saveElement) delete w.el;\r\n delete w.grid;\r\n // delete default values (will be re-created on read)\r\n if (!w.autoPosition) delete w.autoPosition;\r\n if (!w.noResize) delete w.noResize;\r\n if (!w.noMove) delete w.noMove;\r\n if (!w.locked) delete w.locked;\r\n widgets.push(w);\r\n });\r\n return widgets;\r\n }\r\n\r\n /** @internal called whenever a node is added or moved - updates the cached layouts */\r\n public layoutsNodesChange(nodes: GridStackNode[]): GridStackEngine {\r\n if (!this._layouts || this._ignoreLayoutsNodeChange) return this;\r\n // remove smaller layouts - we will re-generate those on the fly... larger ones need to update\r\n this._layouts.forEach((layout, column) => {\r\n if (!layout || column === this.column) return this;\r\n if (column < this.column) {\r\n this._layouts[column] = undefined;\r\n }\r\n else {\r\n // we save the original x,y,w (h isn't cached) to see what actually changed to propagate better.\r\n // Note: we don't need to check against out of bound scaling/moving as that will be done when using those cache values.\r\n nodes.forEach(node => {\r\n if (!node._orig) return; // didn't change (newly added ?)\r\n let n = layout.find(l => l._id === node._id);\r\n if (!n) return; // no cache for new nodes. Will use those values.\r\n let ratio = column / this.column;\r\n // Y changed, push down same amount\r\n // TODO: detect doing item 'swaps' will help instead of move (especially in 1 column mode)\r\n if (node.y !== node._orig.y) {\r\n n.y += (node.y - node._orig.y);\r\n }\r\n // X changed, scale from new position\r\n if (node.x !== node._orig.x) {\r\n n.x = Math.round(node.x * ratio);\r\n }\r\n // width changed, scale from new width\r\n if (node.w !== node._orig.w) {\r\n n.w = Math.round(node.w * ratio);\r\n }\r\n // ...height always carries over from cache\r\n });\r\n }\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * @internal Called to scale the widget width & position up/down based on the column change.\r\n * Note we store previous layouts (especially original ones) to make it possible to go\r\n * from say 12 -> 1 -> 12 and get back to where we were.\r\n *\r\n * @param oldColumn previous number of columns\r\n * @param column new column number\r\n * @param nodes different sorted list (ex: DOM order) instead of current list\r\n * @param layout specify the type of re-layout that will happen (position, size, etc...).\r\n * Note: items will never be outside of the current column boundaries. default (moveScale). Ignored for 1 column\r\n */\r\n public updateNodeWidths(oldColumn: number, column: number, nodes: GridStackNode[], layout: ColumnOptions = 'moveScale'): GridStackEngine {\r\n if (!this.nodes.length || oldColumn === column) return this;\r\n\r\n // cache the current layout in case they want to go back (like 12 -> 1 -> 12) as it requires original data\r\n this.cacheLayout(this.nodes, oldColumn);\r\n\r\n // if we're going to 1 column and using DOM order rather than default sorting, then generate that layout\r\n if (column === 1 && nodes && nodes.length) {\r\n let top = 0;\r\n nodes.forEach(n => {\r\n n.x = 0;\r\n n.w = 1;\r\n n.y = Math.max(n.y, top);\r\n top = n.y + n.h;\r\n });\r\n } else {\r\n nodes = Utils.sort(this.nodes, -1, oldColumn); // current column reverse sorting so we can insert last to front (limit collision)\r\n }\r\n\r\n // see if we have cached previous layout.\r\n let cacheNodes = this._layouts[column] || [];\r\n // if not AND we are going up in size start with the largest layout as down-scaling is more accurate\r\n let lastIndex = this._layouts.length - 1;\r\n if (cacheNodes.length === 0 && column > oldColumn && column < lastIndex) {\r\n cacheNodes = this._layouts[lastIndex] || [];\r\n if (cacheNodes.length) {\r\n // pretend we came from that larger column by assigning those values as starting point\r\n oldColumn = lastIndex;\r\n cacheNodes.forEach(cacheNode => {\r\n let j = nodes.findIndex(n => n._id === cacheNode._id);\r\n if (j !== -1) {\r\n // still current, use cache info positions\r\n nodes[j].x = cacheNode.x;\r\n nodes[j].y = cacheNode.y;\r\n nodes[j].w = cacheNode.w;\r\n }\r\n });\r\n cacheNodes = []; // we still don't have new column cached data... will generate from larger one.\r\n }\r\n }\r\n\r\n // if we found cache re-use those nodes that are still current\r\n let newNodes: GridStackNode[] = [];\r\n cacheNodes.forEach(cacheNode => {\r\n let j = nodes.findIndex(n => n._id === cacheNode._id);\r\n if (j !== -1) {\r\n // still current, use cache info positions\r\n nodes[j].x = cacheNode.x;\r\n nodes[j].y = cacheNode.y;\r\n nodes[j].w = cacheNode.w;\r\n newNodes.push(nodes[j]);\r\n nodes.splice(j, 1);\r\n }\r\n });\r\n // ...and add any extra non-cached ones\r\n if (nodes.length) {\r\n if (typeof layout === 'function') {\r\n layout(column, oldColumn, newNodes, nodes);\r\n } else {\r\n let ratio = column / oldColumn;\r\n let move = (layout === 'move' || layout === 'moveScale');\r\n let scale = (layout === 'scale' || layout === 'moveScale');\r\n nodes.forEach(node => {\r\n node.x = (column === 1 ? 0 : (move ? Math.round(node.x * ratio) : Math.min(node.x, column - 1)));\r\n node.w = ((column === 1 || oldColumn === 1) ? 1 :\r\n scale ? (Math.round(node.w * ratio) || 1) : (Math.min(node.w, column)));\r\n newNodes.push(node);\r\n });\r\n nodes = [];\r\n }\r\n }\r\n\r\n // finally re-layout them in reverse order (to get correct placement)\r\n newNodes = Utils.sort(newNodes, -1, column);\r\n this._ignoreLayoutsNodeChange = true;\r\n this.batchUpdate();\r\n this.nodes = []; // pretend we have no nodes to start with (we use same structures) to simplify layout\r\n newNodes.forEach(node => {\r\n this.addNode(node, false); // 'false' for add event trigger\r\n node._dirty = true; // force attr update\r\n }, this);\r\n this.commit();\r\n delete this._ignoreLayoutsNodeChange;\r\n return this;\r\n }\r\n\r\n /**\r\n * call to cache the given layout internally to the given location so we can restore back when column changes size\r\n * @param nodes list of nodes\r\n * @param column corresponding column index to save it under\r\n * @param clear if true, will force other caches to be removed (default false)\r\n */\r\n public cacheLayout(nodes: GridStackNode[], column: number, clear = false): GridStackEngine {\r\n let copy: Layout[] = [];\r\n nodes.forEach((n, i) => {\r\n n._id = n._id || GridStackEngine._idSeq++; // make sure we have an id in case this is new layout, else re-use id already set\r\n copy[i] = {x: n.x, y: n.y, w: n.w, _id: n._id} // only thing we change is x,y,w and id to find it back\r\n });\r\n this._layouts = clear ? [] : this._layouts || []; // use array to find larger quick\r\n this._layouts[column] = copy;\r\n return this;\r\n }\r\n\r\n /**\r\n * call to cache the given node layout internally to the given location so we can restore back when column changes size\r\n * @param node single node to cache\r\n * @param column corresponding column index to save it under\r\n */\r\n public cacheOneLayout(n: GridStackNode, column: number): GridStackEngine {\r\n n._id = n._id || GridStackEngine._idSeq++;\r\n let layout: Layout = {x: n.x, y: n.y, w: n.w, _id: n._id}\r\n this._layouts = this._layouts || [];\r\n this._layouts[column] = this._layouts[column] || [];\r\n let index = this._layouts[column].findIndex(l => l._id === n._id);\r\n index === -1 ? this._layouts[column].push(layout) : this._layouts[column][index] = layout;\r\n return this;\r\n }\r\n\r\n\r\n /** called to remove all internal values but the _id */\r\n public cleanupNode(node: GridStackNode): GridStackEngine {\r\n for (let prop in node) {\r\n if (prop[0] === '_' && prop !== '_id') delete node[prop];\r\n }\r\n return this;\r\n }\r\n}\r\n\r\n/** @internal class to store per column layout bare minimal info (subset of GridStackWidget) */\r\ninterface Layout {\r\n x: number;\r\n y: number;\r\n w: number;\r\n _id: number; // so we can find full node back\r\n}\r\n","/**\r\n * index-h5.ts 4.2.5 - everything you need for a Grid that uses HTML5 native drag&drop\r\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\r\n */\r\n\r\nexport * from './types';\r\nexport * from './utils';\r\nexport * from './gridstack-engine';\r\nexport * from './gridstack-ddi';\r\nexport * from './gridstack';\r\n\r\nexport * from './h5/gridstack-dd-native';\r\n\r\n// declare module 'gridstack'; for umd ?\r\n","/*!\r\n * GridStack 4.2.5\r\n * https://gridstackjs.com/\r\n *\r\n * Copyright (c) 2021 Alain Dumesny\r\n * see root license https://github.com/gridstack/gridstack.js/tree/master/LICENSE\r\n */\r\n\r\nimport { GridStackEngine } from './gridstack-engine';\r\nimport { Utils, HeightData } from './utils';\r\nimport { ColumnOptions, GridItemHTMLElement, GridStackElement, GridStackEventHandlerCallback,\r\n GridStackNode, GridStackOptions, GridStackWidget, numberOrString, DDUIData, DDDragInOpt, GridStackPosition } from './types';\r\nimport { GridStackDDI } from './gridstack-ddi';\r\n\r\n// export all dependent file as well to make it easier for users to just import the main file\r\nexport * from './types';\r\nexport * from './utils';\r\nexport * from './gridstack-engine';\r\nexport * from './gridstack-ddi';\r\n\r\nexport interface GridHTMLElement extends HTMLElement {\r\n gridstack?: GridStack; // grid's parent DOM element points back to grid class\r\n}\r\nexport type GridStackEvent = 'added' | 'change' | 'disable' | 'drag' | 'dragstart' | 'dragstop' | 'dropped' |\r\n 'enable' | 'removed' | 'resize' | 'resizestart' | 'resizestop';\r\n\r\n/** Defines the coordinates of an object */\r\nexport interface MousePosition {\r\n top: number;\r\n left: number;\r\n}\r\n\r\n/** Defines the position of a cell inside the grid*/\r\nexport interface CellPosition {\r\n x: number;\r\n y: number;\r\n}\r\n\r\ninterface GridCSSStyleSheet extends CSSStyleSheet {\r\n _id?: string; // random id we will use to style us\r\n _max?: number; // internal tracker of the max # of rows we created\\\r\n}\r\n\r\n// default values for grid options - used during init and when saving out\r\nconst GridDefaults: GridStackOptions = {\r\n column: 12,\r\n minRow: 0,\r\n maxRow: 0,\r\n itemClass: 'grid-stack-item',\r\n placeholderClass: 'grid-stack-placeholder',\r\n placeholderText: '',\r\n handle: '.grid-stack-item-content',\r\n handleClass: null,\r\n styleInHead: false,\r\n cellHeight: 'auto',\r\n cellHeightThrottle: 100,\r\n margin: 10,\r\n auto: true,\r\n minWidth: 768,\r\n float: false,\r\n staticGrid: false,\r\n animate: true,\r\n alwaysShowResizeHandle: false,\r\n resizable: {\r\n autoHide: true,\r\n handles: 'se'\r\n },\r\n draggable: {\r\n handle: '.grid-stack-item-content',\r\n scroll: false,\r\n appendTo: 'body'\r\n },\r\n disableDrag: false,\r\n disableResize: false,\r\n rtl: 'auto',\r\n removable: false,\r\n removableOptions: {\r\n accept: '.grid-stack-item'\r\n },\r\n marginUnit: 'px',\r\n cellHeightUnit: 'px',\r\n disableOneColumnMode: false,\r\n oneColumnModeDomSort: false\r\n};\r\n\r\n/**\r\n * Main gridstack class - you will need to call `GridStack.init()` first to initialize your grid.\r\n * Note: your grid elements MUST have the following classes for the CSS layout to work:\r\n * @example\r\n *
\r\n *
\r\n *
Item 1
\r\n *
\r\n *
\r\n */\r\nexport class GridStack {\r\n\r\n /**\r\n * initializing the HTML element, or selector string, into a grid will return the grid. Calling it again will\r\n * simply return the existing instance (ignore any passed options). There is also an initAll() version that support\r\n * multiple grids initialization at once. Or you can use addGrid() to create the entire grid from JSON.\r\n * @param options grid options (optional)\r\n * @param elOrString element or CSS selector (first one used) to convert to a grid (default to '.grid-stack' class selector)\r\n *\r\n * @example\r\n * let grid = GridStack.init();\r\n *\r\n * Note: the HTMLElement (of type GridHTMLElement) will store a `gridstack: GridStack` value that can be retrieve later\r\n * let grid = document.querySelector('.grid-stack').gridstack;\r\n */\r\n public static init(options: GridStackOptions = {}, elOrString: GridStackElement = '.grid-stack'): GridStack {\r\n let el = GridStack.getGridElement(elOrString);\r\n if (!el) {\r\n if (typeof elOrString === 'string') {\r\n console.error('GridStack.initAll() no grid was found with selector \"' + elOrString + '\" - element missing or wrong selector ?' +\r\n '\\nNote: \".grid-stack\" is required for proper CSS styling and drag/drop, and is the default selector.');\r\n } else {\r\n console.error('GridStack.init() no grid element was passed.');\r\n }\r\n return null;\r\n }\r\n if (!el.gridstack) {\r\n el.gridstack = new GridStack(el, {...options});\r\n }\r\n return el.gridstack\r\n }\r\n\r\n /**\r\n * Will initialize a list of elements (given a selector) and return an array of grids.\r\n * @param options grid options (optional)\r\n * @param selector elements selector to convert to grids (default to '.grid-stack' class selector)\r\n *\r\n * @example\r\n * let grids = GridStack.initAll();\r\n * grids.forEach(...)\r\n */\r\n public static initAll(options: GridStackOptions = {}, selector = '.grid-stack'): GridStack[] {\r\n let grids: GridStack[] = [];\r\n GridStack.getGridElements(selector).forEach(el => {\r\n if (!el.gridstack) {\r\n el.gridstack = new GridStack(el, {...options});\r\n delete options.dragIn; delete options.dragInOptions; // only need to be done once (really a static global thing, not per grid)\r\n }\r\n grids.push(el.gridstack);\r\n });\r\n if (grids.length === 0) {\r\n console.error('GridStack.initAll() no grid was found with selector \"' + selector + '\" - element missing or wrong selector ?' +\r\n '\\nNote: \".grid-stack\" is required for proper CSS styling and drag/drop, and is the default selector.');\r\n }\r\n return grids;\r\n }\r\n\r\n /**\r\n * call to create a grid with the given options, including loading any children from JSON structure. This will call GridStack.init(), then\r\n * grid.load() on any passed children (recursively). Great alternative to calling init() if you want entire grid to come from\r\n * JSON serialized data, including options.\r\n * @param parent HTML element parent to the grid\r\n * @param opt grids options used to initialize the grid, and list of children\r\n */\r\n public static addGrid(parent: HTMLElement, opt: GridStackOptions = {}): GridStack {\r\n if (!parent) return null;\r\n\r\n // create the grid element, but check if the passed 'parent' already has grid styling and should be used instead\r\n let el = parent;\r\n if (!parent.classList.contains('grid-stack')) {\r\n let doc = document.implementation.createHTMLDocument();\r\n doc.body.innerHTML = `
`;\r\n el = doc.body.children[0] as HTMLElement;\r\n parent.appendChild(el);\r\n }\r\n\r\n // create grid class and load any children\r\n let grid = GridStack.init(opt, el);\r\n if (grid.opts.children) {\r\n let children = grid.opts.children;\r\n delete grid.opts.children;\r\n grid.load(children);\r\n }\r\n return grid;\r\n }\r\n\r\n /** scoping so users can call GridStack.Utils.sort() for example */\r\n public static Utils = Utils;\r\n\r\n /** scoping so users can call new GridStack.Engine(12) for example */\r\n public static Engine = GridStackEngine;\r\n\r\n /** the HTML element tied to this grid after it's been initialized */\r\n public el: GridHTMLElement;\r\n\r\n /** engine used to implement non DOM grid functionality */\r\n public engine: GridStackEngine;\r\n\r\n /** grid options - public for classes to access, but use methods to modify! */\r\n public opts: GridStackOptions;\r\n\r\n /** @internal create placeholder DIV as needed */\r\n public get placeholder(): HTMLElement {\r\n if (!this._placeholder) {\r\n let placeholderChild = document.createElement('div'); // child so padding match item-content\r\n placeholderChild.className = 'placeholder-content';\r\n if (this.opts.placeholderText) {\r\n placeholderChild.innerHTML = this.opts.placeholderText;\r\n }\r\n this._placeholder = document.createElement('div');\r\n this._placeholder.classList.add(this.opts.placeholderClass, GridDefaults.itemClass, this.opts.itemClass);\r\n this.placeholder.appendChild(placeholderChild);\r\n }\r\n return this._placeholder;\r\n }\r\n /** @internal */\r\n private _placeholder: HTMLElement;\r\n /** @internal */\r\n private _prevColumn: number;\r\n /** @internal */\r\n private _ignoreLayoutsNodeChange: boolean;\r\n /** @internal */\r\n public _gsEventHandler = {};\r\n /** @internal */\r\n private _styles: GridCSSStyleSheet;\r\n /** @internal flag to keep cells square during resize */\r\n private _isAutoCellHeight: boolean;\r\n /** @internal track event binding to window resize so we can remove */\r\n private _windowResizeBind: () => void;\r\n /** @internal limit auto cell resizing method */\r\n private _cellHeightThrottle: () => void;\r\n /** @internal true when loading items to insert first rather than append */\r\n private _insertNotAppend: boolean;\r\n /** @internal extra row added when dragging at the bottom of the grid */\r\n private _extraDragRow = 0;\r\n\r\n /**\r\n * Construct a grid item from the given element and options\r\n * @param el\r\n * @param opts\r\n */\r\n public constructor(el: GridHTMLElement, opts: GridStackOptions = {}) {\r\n this.el = el; // exposed HTML element to the user\r\n opts = opts || {}; // handles null/undefined/0\r\n\r\n // if row property exists, replace minRow and maxRow instead\r\n if (opts.row) {\r\n opts.minRow = opts.maxRow = opts.row;\r\n delete opts.row;\r\n }\r\n let rowAttr = Utils.toNumber(el.getAttribute('gs-row'));\r\n\r\n // elements attributes override any passed options (like CSS style) - merge the two together\r\n let defaults: GridStackOptions = {...GridDefaults,\r\n column: Utils.toNumber(el.getAttribute('gs-column')) || 12,\r\n minRow: rowAttr ? rowAttr : Utils.toNumber(el.getAttribute('gs-min-row')) || 0,\r\n maxRow: rowAttr ? rowAttr : Utils.toNumber(el.getAttribute('gs-max-row')) || 0,\r\n staticGrid: Utils.toBool(el.getAttribute('gs-static')) || false,\r\n _styleSheetClass: 'grid-stack-instance-' + (Math.random() * 10000).toFixed(0),\r\n alwaysShowResizeHandle: opts.alwaysShowResizeHandle || false,\r\n resizable: {\r\n autoHide: !(opts.alwaysShowResizeHandle || false),\r\n handles: 'se'\r\n },\r\n draggable: {\r\n handle: (opts.handleClass ? '.' + opts.handleClass : (opts.handle ? opts.handle : '')) || '.grid-stack-item-content',\r\n scroll: false,\r\n appendTo: 'body'\r\n },\r\n removableOptions: {\r\n accept: '.' + (opts.itemClass || 'grid-stack-item')\r\n },\r\n };\r\n if (el.getAttribute('gs-animate')) { // default to true, but if set to false use that instead\r\n defaults.animate = Utils.toBool(el.getAttribute('gs-animate'))\r\n }\r\n\r\n this.opts = Utils.defaults(opts, defaults);\r\n opts = null; // make sure we use this.opts instead\r\n this.initMargin(); // part of settings defaults...\r\n\r\n // Now check if we're loading into 1 column mode FIRST so we don't do un-necessary work (like cellHeight = width / 12 then go 1 column)\r\n if (this.opts.column !== 1 && !this.opts.disableOneColumnMode && this._widthOrContainer() <= this.opts.minWidth) {\r\n this._prevColumn = this.opts.column;\r\n this.opts.column = 1;\r\n }\r\n\r\n if (this.opts.rtl === 'auto') {\r\n this.opts.rtl = (el.style.direction === 'rtl');\r\n }\r\n\r\n if (this.opts.rtl) {\r\n this.el.classList.add('grid-stack-rtl');\r\n }\r\n\r\n // check if we're been nested, and if so update our style and keep pointer around (used during save)\r\n let parentGridItemEl = Utils.closestByClass(this.el, GridDefaults.itemClass) as GridItemHTMLElement;\r\n if (parentGridItemEl && parentGridItemEl.gridstackNode) {\r\n this.opts._isNested = parentGridItemEl.gridstackNode;\r\n this.opts._isNested.subGrid = this;\r\n this.el.classList.add('grid-stack-nested');\r\n }\r\n\r\n this._isAutoCellHeight = (this.opts.cellHeight === 'auto');\r\n if (this._isAutoCellHeight || this.opts.cellHeight === 'initial') {\r\n // make the cell content square initially (will use resize/column event to keep it square)\r\n this.cellHeight(undefined, false);\r\n } else {\r\n this.cellHeight(this.opts.cellHeight, false);\r\n }\r\n\r\n this.el.classList.add(this.opts._styleSheetClass);\r\n\r\n this._setStaticClass();\r\n\r\n this.engine = new GridStackEngine({\r\n column: this.opts.column,\r\n float: this.opts.float,\r\n maxRow: this.opts.maxRow,\r\n onChange: (cbNodes) => {\r\n let maxH = 0;\r\n this.engine.nodes.forEach(n => { maxH = Math.max(maxH, n.y + n.h) });\r\n cbNodes.forEach(n => {\r\n let el = n.el;\r\n if (n._removeDOM) {\r\n if (el) el.remove();\r\n delete n._removeDOM;\r\n } else {\r\n this._writePosAttr(el, n);\r\n }\r\n });\r\n this._updateStyles(false, maxH); // false = don't recreate, just append if need be\r\n }\r\n });\r\n\r\n if (this.opts.auto) {\r\n this.batchUpdate(); // prevent in between re-layout #1535 TODO: this only set float=true, need to prevent collision check...\r\n let elements: {el: HTMLElement; i: number}[] = [];\r\n this.getGridItems().forEach(el => { // get dom elements (not nodes yet)\r\n let x = parseInt(el.getAttribute('gs-x'));\r\n let y = parseInt(el.getAttribute('gs-y'));\r\n elements.push({\r\n el,\r\n // if x,y are missing (autoPosition) add them to end of list - but keep their respective DOM order\r\n i: (Number.isNaN(x) ? 1000 : x) + (Number.isNaN(y) ? 1000 : y) * this.opts.column\r\n });\r\n });\r\n elements.sort((a, b) => a.i - b.i).forEach(e => this._prepareElement(e.el));\r\n this.commit();\r\n }\r\n\r\n this.setAnimation(this.opts.animate);\r\n\r\n this._updateStyles();\r\n if (this.opts.column != 12) {\r\n this.el.classList.add('grid-stack-' + this.opts.column);\r\n }\r\n\r\n // legacy support to appear 'per grid` options when really global.\r\n if (this.opts.dragIn) GridStack.setupDragIn(this.opts.dragIn, this.opts.dragInOptions);\r\n delete this.opts.dragIn;\r\n delete this.opts.dragInOptions;\r\n\r\n this._setupRemoveDrop();\r\n this._setupAcceptWidget();\r\n this._updateWindowResizeEvent();\r\n }\r\n\r\n /**\r\n * add a new widget and returns it.\r\n *\r\n * Widget will be always placed even if result height is more than actual grid height.\r\n * You need to use `willItFit()` before calling addWidget for additional check.\r\n * See also `makeWidget()`.\r\n *\r\n * @example\r\n * let grid = GridStack.init();\r\n * grid.addWidget({w: 3, content: 'hello'});\r\n * grid.addWidget('
hello
', {w: 3});\r\n *\r\n * @param el GridStackWidget (which can have content string as well), html element, or string definition to add\r\n * @param options widget position/size options (optional, and ignore if first param is already option) - see GridStackWidget\r\n */\r\n public addWidget(els?: GridStackWidget | GridStackElement, options?: GridStackWidget): GridItemHTMLElement {\r\n\r\n // support legacy call for now ?\r\n if (arguments.length > 2) {\r\n console.warn('gridstack.ts: `addWidget(el, x, y, width...)` is deprecated. Use `addWidget({x, y, w, content, ...})`. It will be removed soon');\r\n // eslint-disable-next-line prefer-rest-params\r\n let a = arguments, i = 1,\r\n opt: GridStackWidget = { x:a[i++], y:a[i++], w:a[i++], h:a[i++], autoPosition:a[i++],\r\n minW:a[i++], maxW:a[i++], minH:a[i++], maxH:a[i++], id:a[i++] };\r\n return this.addWidget(els, opt);\r\n }\r\n\r\n function isGridStackWidget(w: GridStackWidget): w is GridStackWidget { // https://medium.com/ovrsea/checking-the-type-of-an-object-in-typescript-the-type-guards-24d98d9119b0\r\n return w.x !== undefined || w.y !== undefined || w.w !== undefined || w.h !== undefined || w.content !== undefined ? true : false;\r\n }\r\n\r\n let el: HTMLElement;\r\n if (typeof els === 'string') {\r\n let doc = document.implementation.createHTMLDocument();\r\n doc.body.innerHTML = els;\r\n el = doc.body.children[0] as HTMLElement;\r\n } else if (arguments.length === 0 || arguments.length === 1 && isGridStackWidget(els)) {\r\n let content = els ? (els as GridStackWidget).content || '' : '';\r\n options = els;\r\n let doc = document.implementation.createHTMLDocument();\r\n doc.body.innerHTML = `
${content}
`;\r\n el = doc.body.children[0] as HTMLElement;\r\n } else {\r\n el = els as HTMLElement;\r\n }\r\n\r\n // Tempting to initialize the passed in opt with default and valid values, but this break knockout demos\r\n // as the actual value are filled in when _prepareElement() calls el.getAttribute('gs-xyz) before adding the node.\r\n // So make sure we load any DOM attributes that are not specified in passed in options (which override)\r\n let domAttr = this._readAttr(el);\r\n options = {...(options || {})}; // make a copy before we modify in case caller re-uses it\r\n Utils.defaults(options, domAttr);\r\n let node = this.engine.prepareNode(options);\r\n this._writeAttr(el, options);\r\n\r\n if (this._insertNotAppend) {\r\n this.el.prepend(el);\r\n } else {\r\n this.el.appendChild(el);\r\n }\r\n\r\n // similar to makeWidget() that doesn't read attr again and worse re-create a new node and loose any _id\r\n this._prepareElement(el, true, options);\r\n this._updateContainerHeight();\r\n\r\n // check if nested grid definition is present\r\n if (node.subGrid && !(node.subGrid as GridStack).el) { // see if there is a sub-grid to create too\r\n let content = node.el.querySelector('.grid-stack-item-content') as HTMLElement;\r\n node.subGrid = GridStack.addGrid(content, node.subGrid as GridStackOptions);\r\n }\r\n\r\n this._triggerAddEvent();\r\n this._triggerChangeEvent();\r\n\r\n return el;\r\n }\r\n\r\n /**\r\n * saves the current layout returning a list of widgets for serialization (with default to save content), which might include any nested grids.\r\n * Optionally you can also save the grid with options itself, so you can call the new GridStack.addGrid()\r\n * to recreate everything from scratch. GridStackOptions.children would then contain the widget list.\r\n */\r\n public save(saveContent = true, saveGridOpt = false): GridStackWidget[] | GridStackOptions {\r\n // return copied nodes we can modify at will...\r\n let list = this.engine.save(saveContent);\r\n\r\n // check for HTML content as well\r\n if (saveContent) {\r\n list.forEach(n => {\r\n if (n.el && !n.subGrid) { // sub-grid are saved differently, not plain content\r\n let sub = n.el.querySelector('.grid-stack-item-content');\r\n n.content = sub ? sub.innerHTML : undefined;\r\n if (!n.content) delete n.content;\r\n delete n.el;\r\n }\r\n });\r\n }\r\n\r\n // check if save entire grid options (needed for recursive) + children...\r\n if (saveGridOpt) {\r\n\r\n // check for nested grid\r\n list.forEach(n => {\r\n if (n.subGrid) {\r\n n.subGrid = (n.subGrid as GridStack).save(saveContent, saveGridOpt) as GridStackOptions;\r\n }\r\n })\r\n\r\n let o: GridStackOptions = {...this.opts};\r\n // delete default values that will be recreated on launch\r\n if (o.marginBottom === o.marginTop && o.marginRight === o.marginLeft && o.marginTop === o.marginRight) {\r\n o.margin = o.marginTop;\r\n delete o.marginTop; delete o.marginRight; delete o.marginBottom; delete o.marginLeft;\r\n }\r\n if (o.rtl === (this.el.style.direction === 'rtl')) { o.rtl = 'auto' }\r\n if (this._isAutoCellHeight) { o.cellHeight = 'auto' }\r\n Utils.removeInternalAndSame(o, GridDefaults);\r\n o.children = list;\r\n return o;\r\n }\r\n\r\n return list;\r\n }\r\n\r\n /**\r\n * load the widgets from a list. This will call update() on each (matching by id) or add/remove widgets that are not there.\r\n *\r\n * @param layout list of widgets definition to update/create\r\n * @param addAndRemove boolean (default true) or callback method can be passed to control if and how missing widgets can be added/removed, giving\r\n * the user control of insertion.\r\n *\r\n * @example\r\n * see http://gridstackjs.com/demo/serialization.html\r\n **/\r\n public load(layout: GridStackWidget[], addAndRemove: boolean | ((g: GridStack, w: GridStackWidget, add: boolean) => GridItemHTMLElement) = true): GridStack {\r\n let items = GridStack.Utils.sort([...layout], -1, this._prevColumn || this.opts.column); // make copy before we mod/sort\r\n this._insertNotAppend = true; // since create in reverse order...\r\n\r\n // if we're loading a layout into 1 column (_prevColumn is set only when going to 1) and items don't fit, make sure to save\r\n // the original wanted layout so we can scale back up correctly #1471\r\n if (this._prevColumn && this._prevColumn !== this.opts.column && items.some(n => (n.x + n.w) > this.opts.column)) {\r\n this._ignoreLayoutsNodeChange = true; // skip layout update\r\n this.engine.cacheLayout(items, this._prevColumn, true);\r\n }\r\n\r\n let removed: GridStackNode[] = [];\r\n this.batchUpdate();\r\n\r\n // see if any items are missing from new layout and need to be removed first\r\n if (addAndRemove) {\r\n let copyNodes = [...this.engine.nodes]; // don't loop through array you modify\r\n copyNodes.forEach(n => {\r\n let item = items.find(w => n.id === w.id);\r\n if (!item) {\r\n if (typeof(addAndRemove) === 'function') {\r\n addAndRemove(this, n, false);\r\n } else {\r\n removed.push(n); // batch keep track\r\n this.removeWidget(n.el, true, false);\r\n }\r\n }\r\n });\r\n }\r\n\r\n // now add/update the widgets\r\n items.forEach(w => {\r\n let item = (w.id || w.id === 0) ? this.engine.nodes.find(n => n.id === w.id) : undefined;\r\n if (item) {\r\n this.update(item.el, w);\r\n if (w.subGrid && (w.subGrid as GridStackOptions).children) { // update any sub grid as well\r\n let sub = item.el.querySelector('.grid-stack') as GridHTMLElement;\r\n if (sub && sub.gridstack) {\r\n sub.gridstack.load((w.subGrid as GridStackOptions).children); // TODO: support updating grid options ?\r\n this._insertNotAppend = true; // got reset by above call\r\n }\r\n }\r\n } else if (addAndRemove) {\r\n if (typeof(addAndRemove) === 'function') {\r\n w = addAndRemove(this, w, true).gridstackNode;\r\n } else {\r\n w = this.addWidget(w).gridstackNode;\r\n }\r\n }\r\n });\r\n\r\n this.engine.removedNodes = removed;\r\n this.commit();\r\n\r\n // after commit, clear that flag\r\n delete this._ignoreLayoutsNodeChange;\r\n delete this._insertNotAppend;\r\n return this;\r\n }\r\n\r\n /**\r\n * Initializes batch updates. You will see no changes until `commit()` method is called.\r\n */\r\n public batchUpdate(): GridStack {\r\n this.engine.batchUpdate();\r\n return this;\r\n }\r\n\r\n /**\r\n * Gets current cell height.\r\n */\r\n public getCellHeight(forcePixel = false): number {\r\n if (this.opts.cellHeight && this.opts.cellHeight !== 'auto' &&\r\n (!forcePixel || !this.opts.cellHeightUnit || this.opts.cellHeightUnit === 'px')) {\r\n return this.opts.cellHeight as number;\r\n }\r\n // else do entire grid and # of rows\r\n // or get first cell height ?\r\n // let el = this.el.querySelector('.' + this.opts.itemClass) as HTMLElement;\r\n // let height = Utils.toNumber(el.getAttribute('gs-h'));\r\n // return Math.round(el.offsetHeight / height);\r\n return Math.round(this.el.getBoundingClientRect().height) / parseInt(this.el.getAttribute('gs-current-row'));\r\n }\r\n\r\n /**\r\n * Update current cell height - see `GridStackOptions.cellHeight` for format.\r\n * This method rebuilds an internal CSS style sheet.\r\n * Note: You can expect performance issues if call this method too often.\r\n *\r\n * @param val the cell height. If not passed (undefined), cells content will be made square (match width minus margin),\r\n * if pass 0 the CSS will be generated by the application instead.\r\n * @param update (Optional) if false, styles will not be updated\r\n *\r\n * @example\r\n * grid.cellHeight(100); // same as 100px\r\n * grid.cellHeight('70px');\r\n * grid.cellHeight(grid.cellWidth() * 1.2);\r\n */\r\n public cellHeight(val?: numberOrString, update = true): GridStack {\r\n\r\n // if not called internally, check if we're changing mode\r\n if (update && val !== undefined) {\r\n if (this._isAutoCellHeight !== (val === 'auto')) {\r\n this._isAutoCellHeight = (val === 'auto');\r\n this._updateWindowResizeEvent();\r\n }\r\n }\r\n if (val === 'initial' || val === 'auto') { val = undefined; }\r\n\r\n // make item content be square\r\n if (val === undefined) {\r\n let marginDiff = - (this.opts.marginRight as number) - (this.opts.marginLeft as number)\r\n + (this.opts.marginTop as number) + (this.opts.marginBottom as number);\r\n val = this.cellWidth() + marginDiff;\r\n }\r\n\r\n let data = Utils.parseHeight(val);\r\n if (this.opts.cellHeightUnit === data.unit && this.opts.cellHeight === data.h) {\r\n return this;\r\n }\r\n this.opts.cellHeightUnit = data.unit;\r\n this.opts.cellHeight = data.h;\r\n\r\n if (update) {\r\n this._updateStyles(true, this.getRow()); // true = force re-create, for that # of rows\r\n }\r\n return this;\r\n }\r\n\r\n /** Gets current cell width. */\r\n public cellWidth(): number {\r\n return this._widthOrContainer() / this.opts.column;\r\n }\r\n /** return our expected width (or parent) for 1 column check */\r\n private _widthOrContainer(): number {\r\n // use `offsetWidth` or `clientWidth` (no scrollbar) ?\r\n // https://stackoverflow.com/questions/21064101/understanding-offsetwidth-clientwidth-scrollwidth-and-height-respectively\r\n return (this.el.clientWidth || this.el.parentElement.clientWidth || window.innerWidth);\r\n }\r\n\r\n /**\r\n * Finishes batch updates. Updates DOM nodes. You must call it after batchUpdate.\r\n */\r\n public commit(): GridStack {\r\n this.engine.commit();\r\n this._triggerRemoveEvent();\r\n this._triggerAddEvent();\r\n this._triggerChangeEvent();\r\n return this;\r\n }\r\n\r\n /** re-layout grid items to reclaim any empty space */\r\n public compact(): GridStack {\r\n this.engine.compact();\r\n this._triggerChangeEvent();\r\n return this;\r\n }\r\n\r\n /**\r\n * set the number of columns in the grid. Will update existing widgets to conform to new number of columns,\r\n * as well as cache the original layout so you can revert back to previous positions without loss.\r\n * Requires `gridstack-extra.css` or `gridstack-extra.min.css` for [2-11],\r\n * else you will need to generate correct CSS (see https://github.com/gridstack/gridstack.js#change-grid-columns)\r\n * @param column - Integer > 0 (default 12).\r\n * @param layout specify the type of re-layout that will happen (position, size, etc...).\r\n * Note: items will never be outside of the current column boundaries. default (moveScale). Ignored for 1 column\r\n */\r\n public column(column: number, layout: ColumnOptions = 'moveScale'): GridStack {\r\n if (this.opts.column === column) return this;\r\n let oldColumn = this.opts.column;\r\n\r\n // if we go into 1 column mode (which happens if we're sized less than minW unless disableOneColumnMode is on)\r\n // then remember the original columns so we can restore.\r\n if (column === 1) {\r\n this._prevColumn = oldColumn;\r\n } else {\r\n delete this._prevColumn;\r\n }\r\n\r\n this.el.classList.remove('grid-stack-' + oldColumn);\r\n this.el.classList.add('grid-stack-' + column);\r\n this.opts.column = this.engine.column = column;\r\n\r\n // update the items now - see if the dom order nodes should be passed instead (else default to current list)\r\n let domNodes: GridStackNode[];\r\n if (column === 1 && this.opts.oneColumnModeDomSort) {\r\n domNodes = [];\r\n this.getGridItems().forEach(el => { // get dom elements in order\r\n if (el.gridstackNode) { domNodes.push(el.gridstackNode); }\r\n });\r\n if (!domNodes.length) { domNodes = undefined; }\r\n }\r\n this.engine.updateNodeWidths(oldColumn, column, domNodes, layout);\r\n if (this._isAutoCellHeight) this.cellHeight();\r\n\r\n // and trigger our event last...\r\n this._ignoreLayoutsNodeChange = true; // skip layout update\r\n this._triggerChangeEvent();\r\n delete this._ignoreLayoutsNodeChange;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * get the number of columns in the grid (default 12)\r\n */\r\n public getColumn(): number {\r\n return this.opts.column;\r\n }\r\n\r\n /** returns an array of grid HTML elements (no placeholder) - used to iterate through our children in DOM order */\r\n public getGridItems(): GridItemHTMLElement[] {\r\n return Array.from(this.el.children)\r\n .filter((el: HTMLElement) => el.matches('.' + this.opts.itemClass) && !el.matches('.' + this.opts.placeholderClass)) as GridItemHTMLElement[];\r\n }\r\n\r\n /**\r\n * Destroys a grid instance. DO NOT CALL any methods or access any vars after this as it will free up members.\r\n * @param removeDOM if `false` grid and items HTML elements will not be removed from the DOM (Optional. Default `true`).\r\n */\r\n public destroy(removeDOM = true): GridStack {\r\n if (!this.el) return; // prevent multiple calls\r\n this._updateWindowResizeEvent(true);\r\n this.setStatic(true, false); // permanently removes DD but don't set CSS class (we're going away)\r\n this.setAnimation(false);\r\n if (!removeDOM) {\r\n this.removeAll(removeDOM);\r\n this.el.classList.remove(this.opts._styleSheetClass);\r\n } else {\r\n this.el.parentNode.removeChild(this.el);\r\n }\r\n this._removeStylesheet();\r\n this.el.removeAttribute('gs-current-row');\r\n delete this.opts._isNested;\r\n delete this.opts;\r\n delete this._placeholder;\r\n delete this.engine;\r\n delete this.el.gridstack; // remove circular dependency that would prevent a freeing\r\n delete this.el;\r\n return this;\r\n }\r\n\r\n /**\r\n * enable/disable floating widgets (default: `false`) See [example](http://gridstackjs.com/demo/float.html)\r\n */\r\n public float(val: boolean): GridStack {\r\n this.engine.float = val;\r\n this._triggerChangeEvent();\r\n return this;\r\n }\r\n\r\n /**\r\n * get the current float mode\r\n */\r\n public getFloat(): boolean {\r\n return this.engine.float;\r\n }\r\n\r\n /**\r\n * Get the position of the cell under a pixel on screen.\r\n * @param position the position of the pixel to resolve in\r\n * absolute coordinates, as an object with top and left properties\r\n * @param useDocRelative if true, value will be based on document position vs parent position (Optional. Default false).\r\n * Useful when grid is within `position: relative` element\r\n *\r\n * Returns an object with properties `x` and `y` i.e. the column and row in the grid.\r\n */\r\n public getCellFromPixel(position: MousePosition, useDocRelative = false): CellPosition {\r\n let box = this.el.getBoundingClientRect();\r\n // console.log(`getBoundingClientRect left: ${box.left} top: ${box.top} w: ${box.w} h: ${box.h}`)\r\n let containerPos: {top: number, left: number};\r\n if (useDocRelative) {\r\n containerPos = {top: box.top + document.documentElement.scrollTop, left: box.left};\r\n // console.log(`getCellFromPixel scrollTop: ${document.documentElement.scrollTop}`)\r\n } else {\r\n containerPos = {top: this.el.offsetTop, left: this.el.offsetLeft}\r\n // console.log(`getCellFromPixel offsetTop: ${containerPos.left} offsetLeft: ${containerPos.top}`)\r\n }\r\n let relativeLeft = position.left - containerPos.left;\r\n let relativeTop = position.top - containerPos.top;\r\n\r\n let columnWidth = (box.width / this.opts.column);\r\n let rowHeight = (box.height / parseInt(this.el.getAttribute('gs-current-row')));\r\n\r\n return {x: Math.floor(relativeLeft / columnWidth), y: Math.floor(relativeTop / rowHeight)};\r\n }\r\n\r\n /** returns the current number of rows, which will be at least `minRow` if set */\r\n public getRow(): number {\r\n return Math.max(this.engine.getRow(), this.opts.minRow);\r\n }\r\n\r\n /**\r\n * Checks if specified area is empty.\r\n * @param x the position x.\r\n * @param y the position y.\r\n * @param w the width of to check\r\n * @param h the height of to check\r\n */\r\n public isAreaEmpty(x: number, y: number, w: number, h: number): boolean {\r\n return this.engine.isAreaEmpty(x, y, w, h);\r\n }\r\n\r\n /**\r\n * If you add elements to your grid by hand, you have to tell gridstack afterwards to make them widgets.\r\n * If you want gridstack to add the elements for you, use `addWidget()` instead.\r\n * Makes the given element a widget and returns it.\r\n * @param els widget or single selector to convert.\r\n *\r\n * @example\r\n * let grid = GridStack.init();\r\n * grid.el.appendChild('
');\r\n * grid.makeWidget('#gsi-1');\r\n */\r\n public makeWidget(els: GridStackElement): GridItemHTMLElement {\r\n let el = GridStack.getElement(els);\r\n this._prepareElement(el, true);\r\n this._updateContainerHeight();\r\n this._triggerAddEvent();\r\n this._triggerChangeEvent();\r\n return el;\r\n }\r\n\r\n /**\r\n * Event handler that extracts our CustomEvent data out automatically for receiving custom\r\n * notifications (see doc for supported events)\r\n * @param name of the event (see possible values) or list of names space separated\r\n * @param callback function called with event and optional second/third param\r\n * (see README documentation for each signature).\r\n *\r\n * @example\r\n * grid.on('added', function(e, items) { log('added ', items)} );\r\n * or\r\n * grid.on('added removed change', function(e, items) { log(e.type, items)} );\r\n *\r\n * Note: in some cases it is the same as calling native handler and parsing the event.\r\n * grid.el.addEventListener('added', function(event) { log('added ', event.detail)} );\r\n *\r\n */\r\n public on(name: GridStackEvent, callback: GridStackEventHandlerCallback): GridStack {\r\n // check for array of names being passed instead\r\n if (name.indexOf(' ') !== -1) {\r\n let names = name.split(' ') as GridStackEvent[];\r\n names.forEach(name => this.on(name, callback));\r\n return this;\r\n }\r\n\r\n if (name === 'change' || name === 'added' || name === 'removed' || name === 'enable' || name === 'disable') {\r\n // native CustomEvent handlers - cash the generic handlers so we can easily remove\r\n let noData = (name === 'enable' || name === 'disable');\r\n if (noData) {\r\n this._gsEventHandler[name] = (event: Event) => callback(event);\r\n } else {\r\n this._gsEventHandler[name] = (event: CustomEvent) => callback(event, event.detail);\r\n }\r\n this.el.addEventListener(name, this._gsEventHandler[name]);\r\n } else if (name === 'drag' || name === 'dragstart' || name === 'dragstop' || name === 'resizestart' || name === 'resize' || name === 'resizestop' || name === 'dropped') {\r\n // drag&drop stop events NEED to be call them AFTER we update node attributes so handle them ourself.\r\n // do same for start event to make it easier...\r\n this._gsEventHandler[name] = callback;\r\n } else {\r\n console.log('GridStack.on(' + name + ') event not supported, but you can still use $(\".grid-stack\").on(...) while jquery-ui is still used internally.');\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * unsubscribe from the 'on' event below\r\n * @param name of the event (see possible values)\r\n */\r\n public off(name: GridStackEvent): GridStack {\r\n // check for array of names being passed instead\r\n if (name.indexOf(' ') !== -1) {\r\n let names = name.split(' ') as GridStackEvent[];\r\n names.forEach(name => this.off(name));\r\n return this;\r\n }\r\n\r\n if (name === 'change' || name === 'added' || name === 'removed' || name === 'enable' || name === 'disable') {\r\n // remove native CustomEvent handlers\r\n if (this._gsEventHandler[name]) {\r\n this.el.removeEventListener(name, this._gsEventHandler[name]);\r\n }\r\n }\r\n delete this._gsEventHandler[name];\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Removes widget from the grid.\r\n * @param el widget or selector to modify\r\n * @param removeDOM if `false` DOM element won't be removed from the tree (Default? true).\r\n * @param triggerEvent if `false` (quiet mode) element will not be added to removed list and no 'removed' callbacks will be called (Default? true).\r\n */\r\n public removeWidget(els: GridStackElement, removeDOM = true, triggerEvent = true): GridStack {\r\n GridStack.getElements(els).forEach(el => {\r\n if (el.parentElement !== this.el) return; // not our child!\r\n let node = el.gridstackNode;\r\n // For Meteor support: https://github.com/gridstack/gridstack.js/pull/272\r\n if (!node) {\r\n node = this.engine.nodes.find(n => el === n.el);\r\n }\r\n if (!node) return;\r\n\r\n // remove our DOM data (circular link) and drag&drop permanently\r\n delete el.gridstackNode;\r\n GridStackDDI.get().remove(el);\r\n\r\n this.engine.removeNode(node, removeDOM, triggerEvent);\r\n\r\n if (removeDOM && el.parentElement) {\r\n el.remove(); // in batch mode engine.removeNode doesn't call back to remove DOM\r\n }\r\n });\r\n if (triggerEvent) {\r\n this._triggerRemoveEvent();\r\n this._triggerChangeEvent();\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Removes all widgets from the grid.\r\n * @param removeDOM if `false` DOM elements won't be removed from the tree (Default? `true`).\r\n */\r\n public removeAll(removeDOM = true): GridStack {\r\n // always remove our DOM data (circular link) before list gets emptied and drag&drop permanently\r\n this.engine.nodes.forEach(n => {\r\n delete n.el.gridstackNode;\r\n GridStackDDI.get().remove(n.el);\r\n });\r\n this.engine.removeAll(removeDOM);\r\n this._triggerRemoveEvent();\r\n return this;\r\n }\r\n\r\n /**\r\n * Toggle the grid animation state. Toggles the `grid-stack-animate` class.\r\n * @param doAnimate if true the grid will animate.\r\n */\r\n public setAnimation(doAnimate: boolean): GridStack {\r\n if (doAnimate) {\r\n this.el.classList.add('grid-stack-animate');\r\n } else {\r\n this.el.classList.remove('grid-stack-animate');\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Toggle the grid static state, which permanently removes/add Drag&Drop support, unlike disable()/enable() that just turns it off/on.\r\n * Also toggle the grid-stack-static class.\r\n * @param val if true the grid become static.\r\n */\r\n public setStatic(val: boolean, updateClass = true): GridStack {\r\n if (this.opts.staticGrid === val) return this;\r\n this.opts.staticGrid = val;\r\n this._setupRemoveDrop();\r\n this._setupAcceptWidget();\r\n this.engine.nodes.forEach(n => this._prepareDragDropByNode(n)); // either delete or init Drag&drop\r\n if (updateClass) { this._setStaticClass(); }\r\n return this;\r\n }\r\n\r\n /**\r\n * Updates widget position/size and other info. Note: if you need to call this on all nodes, use load() instead which will update what changed.\r\n * @param els widget or selector of objects to modify (note: setting the same x,y for multiple items will be indeterministic and likely unwanted)\r\n * @param opt new widget options (x,y,w,h, etc..). Only those set will be updated.\r\n */\r\n public update(els: GridStackElement, opt: GridStackWidget): GridStack {\r\n\r\n // support legacy call for now ?\r\n if (arguments.length > 2) {\r\n console.warn('gridstack.ts: `update(el, x, y, w, h)` is deprecated. Use `update({x, w, content, ...})`. It will be removed soon');\r\n // eslint-disable-next-line prefer-rest-params\r\n let a = arguments, i = 1;\r\n opt = { x:a[i++], y:a[i++], w:a[i++], h:a[i++] };\r\n return this.update(els, opt);\r\n }\r\n\r\n GridStack.getElements(els).forEach(el => {\r\n if (!el || !el.gridstackNode) return;\r\n let n = el.gridstackNode;\r\n let w = {...opt}; // make a copy we can modify in case they re-use it or multiple items\r\n delete w.autoPosition;\r\n\r\n // move/resize widget if anything changed\r\n let keys = ['x', 'y', 'w', 'h'];\r\n let m: GridStackWidget;\r\n if (keys.some(k => w[k] !== undefined && w[k] !== n[k])) {\r\n m = {};\r\n keys.forEach(k => {\r\n m[k] = (w[k] !== undefined) ? w[k] : n[k];\r\n delete w[k];\r\n });\r\n }\r\n // for a move as well IFF there is any min/max fields set\r\n if (!m && (w.minW || w.minH || w.maxW || w.maxH)) {\r\n m = {}; // will use node position but validate values\r\n }\r\n\r\n // check for content changing\r\n if (w.content) {\r\n let sub = el.querySelector('.grid-stack-item-content');\r\n if (sub && sub.innerHTML !== w.content) {\r\n sub.innerHTML = w.content;\r\n }\r\n delete w.content;\r\n }\r\n\r\n // any remaining fields are assigned, but check for dragging changes, resize constrain\r\n let changed = false;\r\n let ddChanged = false;\r\n for (const key in w) {\r\n if (key[0] !== '_' && n[key] !== w[key]) {\r\n n[key] = w[key];\r\n changed = true;\r\n ddChanged = ddChanged || (!this.opts.staticGrid && (key === 'noResize' || key === 'noMove' || key === 'locked'));\r\n }\r\n }\r\n\r\n // finally move the widget\r\n if (m) {\r\n this.engine.cleanNodes()\r\n .beginUpdate(n)\r\n .moveNode(n, m);\r\n this._updateContainerHeight();\r\n this._triggerChangeEvent();\r\n this.engine.endUpdate();\r\n }\r\n if (changed) { // move will only update x,y,w,h so update the rest too\r\n this._writeAttr(el, n);\r\n }\r\n if (ddChanged) {\r\n this._prepareDragDropByNode(n);\r\n }\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Updates the margins which will set all 4 sides at once - see `GridStackOptions.margin` for format options (CSS string format of 1,2,4 values or single number).\r\n * @param value margin value\r\n */\r\n public margin(value: numberOrString): GridStack {\r\n let isMultiValue = (typeof value === 'string' && value.split(' ').length > 1);\r\n // check if we can skip re-creating our CSS file... won't check if multi values (too much hassle)\r\n if (!isMultiValue) {\r\n let data = Utils.parseHeight(value);\r\n if (this.opts.marginUnit === data.unit && this.opts.margin === data.h) return;\r\n }\r\n // re-use existing margin handling\r\n this.opts.margin = value;\r\n this.opts.marginTop = this.opts.marginBottom = this.opts.marginLeft = this.opts.marginRight = undefined;\r\n this.initMargin();\r\n\r\n this._updateStyles(true); // true = force re-create\r\n\r\n return this;\r\n }\r\n\r\n /** returns current margin number value (undefined if 4 sides don't match) */\r\n public getMargin(): number { return this.opts.margin as number; }\r\n\r\n /**\r\n * Returns true if the height of the grid will be less than the vertical\r\n * constraint. Always returns true if grid doesn't have height constraint.\r\n * @param node contains x,y,w,h,auto-position options\r\n *\r\n * @example\r\n * if (grid.willItFit(newWidget)) {\r\n * grid.addWidget(newWidget);\r\n * } else {\r\n * alert('Not enough free space to place the widget');\r\n * }\r\n */\r\n public willItFit(node: GridStackWidget): boolean {\r\n // support legacy call for now\r\n if (arguments.length > 1) {\r\n console.warn('gridstack.ts: `willItFit(x,y,w,h,autoPosition)` is deprecated. Use `willItFit({x, y,...})`. It will be removed soon');\r\n // eslint-disable-next-line prefer-rest-params\r\n let a = arguments, i = 0,\r\n w: GridStackWidget = { x:a[i++], y:a[i++], w:a[i++], h:a[i++], autoPosition:a[i++] };\r\n return this.willItFit(w);\r\n }\r\n return this.engine.willItFit(node);\r\n }\r\n\r\n /** @internal */\r\n private _triggerChangeEvent(): GridStack {\r\n if (this.engine.batchMode) return this;\r\n let elements = this.engine.getDirtyNodes(true); // verify they really changed\r\n if (elements && elements.length) {\r\n if (!this._ignoreLayoutsNodeChange) {\r\n this.engine.layoutsNodesChange(elements);\r\n }\r\n this._triggerEvent('change', elements);\r\n }\r\n this.engine.saveInitial(); // we called, now reset initial values & dirty flags\r\n return this;\r\n }\r\n\r\n /** @internal */\r\n private _triggerAddEvent(): GridStack {\r\n if (this.engine.batchMode) return this;\r\n if (this.engine.addedNodes && this.engine.addedNodes.length > 0) {\r\n if (!this._ignoreLayoutsNodeChange) {\r\n this.engine.layoutsNodesChange(this.engine.addedNodes);\r\n }\r\n // prevent added nodes from also triggering 'change' event (which is called next)\r\n this.engine.addedNodes.forEach(n => { delete n._dirty; });\r\n this._triggerEvent('added', this.engine.addedNodes);\r\n this.engine.addedNodes = [];\r\n }\r\n return this;\r\n }\r\n\r\n /** @internal */\r\n public _triggerRemoveEvent(): GridStack {\r\n if (this.engine.batchMode) return this;\r\n if (this.engine.removedNodes && this.engine.removedNodes.length > 0) {\r\n this._triggerEvent('removed', this.engine.removedNodes);\r\n this.engine.removedNodes = [];\r\n }\r\n return this;\r\n }\r\n\r\n /** @internal */\r\n private _triggerEvent(name: string, data?: GridStackNode[]): GridStack {\r\n let event = data ? new CustomEvent(name, {bubbles: false, detail: data}) : new Event(name);\r\n this.el.dispatchEvent(event);\r\n return this;\r\n }\r\n\r\n /** @internal called to delete the current dynamic style sheet used for our layout */\r\n private _removeStylesheet(): GridStack {\r\n\r\n if (this._styles) {\r\n Utils.removeStylesheet(this._styles._id);\r\n delete this._styles;\r\n }\r\n return this;\r\n }\r\n\r\n /** @internal updated/create the CSS styles for row based layout and initial margin setting */\r\n private _updateStyles(forceUpdate = false, maxH?: number): GridStack {\r\n // call to delete existing one if we change cellHeight / margin\r\n if (forceUpdate) {\r\n this._removeStylesheet();\r\n }\r\n\r\n this._updateContainerHeight();\r\n\r\n // if user is telling us they will handle the CSS themselves by setting heights to 0. Do we need this opts really ??\r\n if (this.opts.cellHeight === 0) {\r\n return this;\r\n }\r\n\r\n let cellHeight = this.opts.cellHeight as number;\r\n let cellHeightUnit = this.opts.cellHeightUnit;\r\n let prefix = `.${this.opts._styleSheetClass} > .${this.opts.itemClass}`;\r\n\r\n // create one as needed\r\n if (!this._styles) {\r\n let id = 'gridstack-style-' + (Math.random() * 100000).toFixed();\r\n // insert style to parent (instead of 'head' by default) to support WebComponent\r\n let styleLocation = this.opts.styleInHead ? undefined : this.el.parentNode as HTMLElement;\r\n this._styles = Utils.createStylesheet(id, styleLocation);\r\n if (!this._styles) return this;\r\n this._styles._id = id;\r\n this._styles._max = 0;\r\n\r\n // these are done once only\r\n Utils.addCSSRule(this._styles, prefix, `min-height: ${cellHeight}${cellHeightUnit}`);\r\n // content margins\r\n let top: string = this.opts.marginTop + this.opts.marginUnit;\r\n let bottom: string = this.opts.marginBottom + this.opts.marginUnit;\r\n let right: string = this.opts.marginRight + this.opts.marginUnit;\r\n let left: string = this.opts.marginLeft + this.opts.marginUnit;\r\n let content = `${prefix} > .grid-stack-item-content`;\r\n let placeholder = `.${this.opts._styleSheetClass} > .grid-stack-placeholder > .placeholder-content`;\r\n Utils.addCSSRule(this._styles, content, `top: ${top}; right: ${right}; bottom: ${bottom}; left: ${left};`);\r\n Utils.addCSSRule(this._styles, placeholder, `top: ${top}; right: ${right}; bottom: ${bottom}; left: ${left};`);\r\n // resize handles offset (to match margin)\r\n Utils.addCSSRule(this._styles, `${prefix} > .ui-resizable-ne`, `right: ${right}`);\r\n Utils.addCSSRule(this._styles, `${prefix} > .ui-resizable-e`, `right: ${right}`);\r\n Utils.addCSSRule(this._styles, `${prefix} > .ui-resizable-se`, `right: ${right}; bottom: ${bottom}`);\r\n Utils.addCSSRule(this._styles, `${prefix} > .ui-resizable-nw`, `left: ${left}`);\r\n Utils.addCSSRule(this._styles, `${prefix} > .ui-resizable-w`, `left: ${left}`);\r\n Utils.addCSSRule(this._styles, `${prefix} > .ui-resizable-sw`, `left: ${left}; bottom: ${bottom}`);\r\n }\r\n\r\n // now update the height specific fields\r\n maxH = maxH || this._styles._max;\r\n if (maxH > this._styles._max) {\r\n let getHeight = (rows: number): string => (cellHeight * rows) + cellHeightUnit;\r\n for (let i = this._styles._max + 1; i <= maxH; i++) { // start at 1\r\n let h: string = getHeight(i);\r\n Utils.addCSSRule(this._styles, `${prefix}[gs-y=\"${i-1}\"]`, `top: ${getHeight(i-1)}`); // start at 0\r\n Utils.addCSSRule(this._styles, `${prefix}[gs-h=\"${i}\"]`, `height: ${h}`);\r\n Utils.addCSSRule(this._styles, `${prefix}[gs-min-h=\"${i}\"]`, `min-height: ${h}`);\r\n Utils.addCSSRule(this._styles, `${prefix}[gs-max-h=\"${i}\"]`, `max-height: ${h}`);\r\n }\r\n this._styles._max = maxH;\r\n }\r\n return this;\r\n }\r\n\r\n /** @internal */\r\n private _updateContainerHeight(): GridStack {\r\n if (!this.engine || this.engine.batchMode) return this;\r\n let row = this.getRow() + this._extraDragRow; // checks for minRow already\r\n // check for css min height\r\n let cssMinHeight = parseInt(getComputedStyle(this.el)['min-height']);\r\n if (cssMinHeight > 0) {\r\n let minRow = Math.round(cssMinHeight / this.getCellHeight(true));\r\n if (row < minRow) {\r\n row = minRow;\r\n }\r\n }\r\n this.el.setAttribute('gs-current-row', String(row));\r\n if (row === 0) {\r\n this.el.style.removeProperty('height');\r\n return this;\r\n }\r\n let cellHeight = this.opts.cellHeight as number;\r\n let unit = this.opts.cellHeightUnit;\r\n if (!cellHeight) return this;\r\n this.el.style.height = row * cellHeight + unit;\r\n return this;\r\n }\r\n\r\n /** @internal */\r\n private _prepareElement(el: GridItemHTMLElement, triggerAddEvent = false, node?: GridStackNode): GridStack {\r\n if (!node) {\r\n el.classList.add(this.opts.itemClass);\r\n node = this._readAttr(el);\r\n }\r\n el.gridstackNode = node;\r\n node.el = el;\r\n node.grid = this;\r\n let copy = {...node};\r\n node = this.engine.addNode(node, triggerAddEvent);\r\n // write node attr back in case there was collision or we have to fix bad values during addNode()\r\n if (!Utils.same(node, copy)) {\r\n this._writeAttr(el, node);\r\n }\r\n this._prepareDragDropByNode(node);\r\n return this;\r\n }\r\n\r\n /** @internal call to write position x,y,w,h attributes back to element */\r\n private _writePosAttr(el: HTMLElement, n: GridStackPosition): GridStack {\r\n if (n.x !== undefined && n.x !== null) { el.setAttribute('gs-x', String(n.x)); }\r\n if (n.y !== undefined && n.y !== null) { el.setAttribute('gs-y', String(n.y)); }\r\n if (n.w) { el.setAttribute('gs-w', String(n.w)); }\r\n if (n.h) { el.setAttribute('gs-h', String(n.h)); }\r\n return this;\r\n }\r\n\r\n /** @internal call to write any default attributes back to element */\r\n private _writeAttr(el: HTMLElement, node: GridStackWidget): GridStack {\r\n if (!node) return this;\r\n this._writePosAttr(el, node);\r\n\r\n let attrs /*: GridStackWidget but strings */ = { // remaining attributes\r\n autoPosition: 'gs-auto-position',\r\n minW: 'gs-min-w',\r\n minH: 'gs-min-h',\r\n maxW: 'gs-max-w',\r\n maxH: 'gs-max-h',\r\n noResize: 'gs-no-resize',\r\n noMove: 'gs-no-move',\r\n locked: 'gs-locked',\r\n id: 'gs-id',\r\n resizeHandles: 'gs-resize-handles'\r\n };\r\n for (const key in attrs) {\r\n if (node[key]) { // 0 is valid for x,y only but done above already and not in list anyway\r\n el.setAttribute(attrs[key], String(node[key]));\r\n } else {\r\n el.removeAttribute(attrs[key]);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n /** @internal call to read any default attributes from element */\r\n private _readAttr(el: HTMLElement): GridStackWidget {\r\n let node: GridStackNode = {};\r\n node.x = Utils.toNumber(el.getAttribute('gs-x'));\r\n node.y = Utils.toNumber(el.getAttribute('gs-y'));\r\n node.w = Utils.toNumber(el.getAttribute('gs-w'));\r\n node.h = Utils.toNumber(el.getAttribute('gs-h'));\r\n node.maxW = Utils.toNumber(el.getAttribute('gs-max-w'));\r\n node.minW = Utils.toNumber(el.getAttribute('gs-min-w'));\r\n node.maxH = Utils.toNumber(el.getAttribute('gs-max-h'));\r\n node.minH = Utils.toNumber(el.getAttribute('gs-min-h'));\r\n node.autoPosition = Utils.toBool(el.getAttribute('gs-auto-position'));\r\n node.noResize = Utils.toBool(el.getAttribute('gs-no-resize'));\r\n node.noMove = Utils.toBool(el.getAttribute('gs-no-move'));\r\n node.locked = Utils.toBool(el.getAttribute('gs-locked'));\r\n node.resizeHandles = el.getAttribute('gs-resize-handles');\r\n node.id = el.getAttribute('gs-id');\r\n\r\n // remove any key not found (null or false which is default)\r\n for (const key in node) {\r\n if (!node.hasOwnProperty(key)) return;\r\n if (!node[key] && node[key] !== 0) { // 0 can be valid value (x,y only really)\r\n delete node[key];\r\n }\r\n }\r\n\r\n return node;\r\n }\r\n\r\n /** @internal */\r\n private _setStaticClass(): GridStack {\r\n let classes = ['grid-stack-static'];\r\n\r\n if (this.opts.staticGrid) {\r\n this.el.classList.add(...classes);\r\n this.el.setAttribute('gs-static', 'true');\r\n } else {\r\n this.el.classList.remove(...classes);\r\n this.el.removeAttribute('gs-static');\r\n\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * called when we are being resized by the window - check if the one Column Mode needs to be turned on/off\r\n * and remember the prev columns we used, as well as check for auto cell height (square)\r\n */\r\n public onParentResize(): GridStack {\r\n if (!this.el || !this.el.clientWidth) return; // return if we're gone or no size yet (will get called again)\r\n let oneColumn = !this.opts.disableOneColumnMode && this.el.clientWidth <= this.opts.minWidth;\r\n let changedOneColumn = false;\r\n\r\n if ((this.opts.column === 1) !== oneColumn) {\r\n changedOneColumn = true;\r\n if (this.opts.animate) { this.setAnimation(false); } // 1 <-> 12 is too radical, turn off animation\r\n this.column(oneColumn ? 1 : this._prevColumn);\r\n if (this.opts.animate) { this.setAnimation(true); }\r\n }\r\n\r\n // make the cells content square again\r\n if (this._isAutoCellHeight) {\r\n if (!changedOneColumn && this.opts.cellHeightThrottle) {\r\n if (!this._cellHeightThrottle) {\r\n this._cellHeightThrottle = Utils.throttle(() => this.cellHeight(), this.opts.cellHeightThrottle);\r\n }\r\n this._cellHeightThrottle();\r\n } else {\r\n // immediate update if we've changed to/from oneColumn or have no threshold\r\n this.cellHeight();\r\n }\r\n }\r\n\r\n // finally update any nested grids\r\n this.engine.nodes.forEach(n => {\r\n if (n.subGrid) {(n.subGrid as GridStack).onParentResize()}\r\n });\r\n\r\n return this;\r\n }\r\n\r\n /** add or remove the window size event handler */\r\n private _updateWindowResizeEvent(forceRemove = false): GridStack {\r\n // only add event if we're not nested (parent will call us) and we're auto sizing cells or supporting oneColumn (i.e. doing work)\r\n const workTodo = (this._isAutoCellHeight || !this.opts.disableOneColumnMode) && !this.opts._isNested;\r\n\r\n if (!forceRemove && workTodo && !this._windowResizeBind) {\r\n this._windowResizeBind = this.onParentResize.bind(this); // so we can properly remove later\r\n window.addEventListener('resize', this._windowResizeBind);\r\n } else if ((forceRemove || !workTodo) && this._windowResizeBind) {\r\n window.removeEventListener('resize', this._windowResizeBind);\r\n delete this._windowResizeBind; // remove link to us so we can free\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /** @internal convert a potential selector into actual element */\r\n public static getElement(els: GridStackElement = '.grid-stack-item'): GridItemHTMLElement { return Utils.getElement(els) }\r\n /** @internal */\r\n public static getElements(els: GridStackElement = '.grid-stack-item'): GridItemHTMLElement[] { return Utils.getElements(els) }\r\n /** @internal */\r\n public static getGridElement(els: GridStackElement): GridHTMLElement { return GridStack.getElement(els) }\r\n /** @internal */\r\n public static getGridElements(els: string): GridHTMLElement[] { return Utils.getElements(els) }\r\n\r\n /** @internal initialize margin top/bottom/left/right and units */\r\n private initMargin(): GridStack {\r\n\r\n let data: HeightData;\r\n let margin = 0;\r\n\r\n // support passing multiple values like CSS (ex: '5px 10px 0 20px')\r\n let margins: string[] = [];\r\n if (typeof this.opts.margin === 'string') {\r\n margins = this.opts.margin.split(' ')\r\n }\r\n if (margins.length === 2) { // top/bot, left/right like CSS\r\n this.opts.marginTop = this.opts.marginBottom = margins[0];\r\n this.opts.marginLeft = this.opts.marginRight = margins[1];\r\n } else if (margins.length === 4) { // Clockwise like CSS\r\n this.opts.marginTop = margins[0];\r\n this.opts.marginRight = margins[1];\r\n this.opts.marginBottom = margins[2];\r\n this.opts.marginLeft = margins[3];\r\n } else {\r\n data = Utils.parseHeight(this.opts.margin);\r\n this.opts.marginUnit = data.unit;\r\n margin = this.opts.margin = data.h;\r\n }\r\n\r\n // see if top/bottom/left/right need to be set as well\r\n if (this.opts.marginTop === undefined) {\r\n this.opts.marginTop = margin;\r\n } else {\r\n data = Utils.parseHeight(this.opts.marginTop);\r\n this.opts.marginTop = data.h;\r\n delete this.opts.margin;\r\n }\r\n\r\n if (this.opts.marginBottom === undefined) {\r\n this.opts.marginBottom = margin;\r\n } else {\r\n data = Utils.parseHeight(this.opts.marginBottom);\r\n this.opts.marginBottom = data.h;\r\n delete this.opts.margin;\r\n }\r\n\r\n if (this.opts.marginRight === undefined) {\r\n this.opts.marginRight = margin;\r\n } else {\r\n data = Utils.parseHeight(this.opts.marginRight);\r\n this.opts.marginRight = data.h;\r\n delete this.opts.margin;\r\n }\r\n\r\n if (this.opts.marginLeft === undefined) {\r\n this.opts.marginLeft = margin;\r\n } else {\r\n data = Utils.parseHeight(this.opts.marginLeft);\r\n this.opts.marginLeft = data.h;\r\n delete this.opts.margin;\r\n }\r\n this.opts.marginUnit = data.unit; // in case side were spelled out, use those units instead...\r\n if (this.opts.marginTop === this.opts.marginBottom && this.opts.marginLeft === this.opts.marginRight && this.opts.marginTop === this.opts.marginRight) {\r\n this.opts.margin = this.opts.marginTop; // makes it easier to check for no-ops in setMargin()\r\n }\r\n return this;\r\n }\r\n\r\n /*\r\n * drag&drop empty stubs that will be implemented in gridstack-dd.ts for non static grid\r\n * so we don't incur the load unless needed.\r\n * NOTE: had to make those methods public in order to define them else as\r\n * GridStack.prototype._setupAcceptWidget = function()\r\n * maybe there is a better way ????\r\n */\r\n /* eslint-disable @typescript-eslint/no-unused-vars */\r\n\r\n /**\r\n * call to setup dragging in from the outside (say toolbar), by specifying the class selection and options.\r\n * Called during GridStack.init() as options, but can also be called directly (last param are cached) in case the toolbar\r\n * is dynamically create and needs to change later.\r\n * @param dragIn string selector (ex: '.sidebar .grid-stack-item')\r\n * @param dragInOptions options - see DDDragInOpt. (default: {revert: 'invalid', handle: '.grid-stack-item-content', scroll: false, appendTo: 'body'}\r\n **/\r\n public static setupDragIn(dragIn?: string, dragInOptions?: DDDragInOpt): void { /* implemented in gridstack-dd.ts */ }\r\n\r\n /**\r\n * Enables/Disables dragging by the user of specific grid element. If you want all items, and have it affect future items, use enableMove() instead. No-op for static grids.\r\n * IF you are looking to prevent an item from moving (due to being pushed around by another during collision) use locked property instead.\r\n * @param els widget or selector to modify.\r\n * @param val if true widget will be draggable.\r\n */\r\n public movable(els: GridStackElement, val: boolean): GridStack { return this }\r\n /**\r\n * Enables/Disables user resizing of specific grid element. If you want all items, and have it affect future items, use enableResize() instead. No-op for static grids.\r\n * @param els widget or selector to modify\r\n * @param val if true widget will be resizable.\r\n */\r\n public resizable(els: GridStackElement, val: boolean): GridStack { return this }\r\n /**\r\n * Temporarily disables widgets moving/resizing.\r\n * If you want a more permanent way (which freezes up resources) use `setStatic(true)` instead.\r\n * Note: no-op for static grid\r\n * This is a shortcut for:\r\n * @example\r\n * grid.enableMove(false);\r\n * grid.enableResize(false);\r\n */\r\n public disable(): GridStack { return this }\r\n /**\r\n * Re-enables widgets moving/resizing - see disable().\r\n * Note: no-op for static grid.\r\n * This is a shortcut for:\r\n * @example\r\n * grid.enableMove(true);\r\n * grid.enableResize(true);\r\n */\r\n public enable(): GridStack { return this }\r\n /**\r\n * Enables/disables widget moving. No-op for static grids.\r\n */\r\n public enableMove(doEnable: boolean): GridStack { return this }\r\n /**\r\n * Enables/disables widget resizing. No-op for static grids.\r\n */\r\n public enableResize(doEnable: boolean): GridStack { return this }\r\n\r\n /** @internal called to add drag over support to support widgets */\r\n public _setupAcceptWidget(): GridStack { return this }\r\n /** @internal called to setup a trash drop zone if the user specifies it */\r\n public _setupRemoveDrop(): GridStack { return this }\r\n /** @internal prepares the element for drag&drop **/\r\n public _prepareDragDropByNode(node: GridStackNode): GridStack { return this }\r\n /** @internal handles actual drag/resize start **/\r\n public _onStartMoving(el: GridItemHTMLElement, event: Event, ui: DDUIData, node: GridStackNode, cellWidth: number, cellHeight: number): void { return }\r\n /** @internal handles actual drag/resize **/\r\n public _dragOrResize(el: GridItemHTMLElement, event: Event, ui: DDUIData, node: GridStackNode, cellWidth: number, cellHeight: number): void { return }\r\n /** @internal called when a node leaves our area (mouse out or shape outside) **/\r\n public _leave(el: GridItemHTMLElement, helper?: GridItemHTMLElement): void { return }\r\n}\r\n","/**\n * dd-base-impl.ts 4.2.5\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\n */\n\nexport type EventCallback = (event: Event) => boolean|void;\nexport abstract class DDBaseImplement {\n /** returns the enable state, but you have to call enable()/disable() to change (as other things need to happen) */\n public get disabled(): boolean { return this._disabled; }\n\n /** @internal */\n private _disabled = false;\n /** @internal */\n private _eventRegister: {\n [eventName: string]: EventCallback;\n } = {};\n\n public on(event: string, callback: EventCallback): void {\n this._eventRegister[event] = callback;\n }\n\n public off(event: string): void {\n delete this._eventRegister[event];\n }\n\n public enable(): void {\n this._disabled = false;\n }\n\n public disable(): void {\n this._disabled = true;\n }\n\n public destroy(): void {\n delete this._eventRegister;\n }\n\n public triggerEvent(eventName: string, event: Event): boolean|void {\n if (!this.disabled && this._eventRegister && this._eventRegister[eventName])\n return this._eventRegister[eventName](event);\n }\n}\n\nexport interface HTMLElementExtendOpt {\n el: HTMLElement;\n option: T;\n updateOption(T): DDBaseImplement;\n}\n","/**\n * dd-draggable.ts 4.2.5\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\n */\n\nimport { DDManager } from './dd-manager';\nimport { DDUtils } from './dd-utils';\nimport { DDBaseImplement, HTMLElementExtendOpt } from './dd-base-impl';\nimport { GridItemHTMLElement, DDUIData } from '../types';\n\n// TODO: merge with DDDragOpt ?\nexport interface DDDraggableOpt {\n appendTo?: string | HTMLElement;\n containment?: string | HTMLElement; // TODO: not implemented yet\n handle?: string;\n revert?: string | boolean | unknown; // TODO: not implemented yet\n scroll?: boolean; // nature support by HTML5 drag drop, can't be switch to off actually\n helper?: string | HTMLElement | ((event: Event) => HTMLElement);\n basePosition?: 'fixed' | 'absolute';\n start?: (event: Event, ui: DDUIData) => void;\n stop?: (event: Event) => void;\n drag?: (event: Event, ui: DDUIData) => void;\n}\n\ninterface DragOffset {\n left: number;\n top: number;\n width: number;\n height: number;\n offsetLeft: number;\n offsetTop: number;\n}\n\nexport class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt {\n public el: HTMLElement;\n public option: DDDraggableOpt;\n public helper: HTMLElement; // used by GridStackDDNative\n\n /** @internal */\n private dragOffset: DragOffset;\n /** @internal */\n private dragElementOriginStyle: Array;\n /** @internal */\n private dragFollowTimer: number;\n /** @internal */\n private dragEl: HTMLElement;\n /** @internal */\n private dragging = false;\n /** @internal */\n private paintTimer: number;\n /** @internal */\n private parentOriginStylePosition: string;\n /** @internal */\n private helperContainment: HTMLElement;\n /** @internal */\n private static basePosition: 'fixed' | 'absolute' = 'absolute';\n /** @internal #1541 can't have {passive: true} on Safari as otherwise it reverts animate back to old location on drop */\n private static dragEventListenerOption = true; // DDUtils.isEventSupportPassiveOption ? { capture: true, passive: true } : true;\n /** @internal */\n private static originStyleProp = ['transition', 'pointerEvents', 'position',\n 'left', 'top', 'opacity', 'zIndex', 'width', 'height', 'willChange'];\n\n constructor(el: HTMLElement, option: DDDraggableOpt = {}) {\n super();\n this.el = el;\n this.option = option;\n // get the element that is actually supposed to be dragged by\n let className = option.handle.substring(1);\n this.dragEl = el.classList.contains(className) ? el : el.querySelector(option.handle) || el;\n // create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)\n this._dragStart = this._dragStart.bind(this);\n this._drag = this._drag.bind(this);\n this._dragEnd = this._dragEnd.bind(this);\n this.enable();\n }\n\n public on(event: 'drag' | 'dragstart' | 'dragstop', callback: (event: DragEvent) => void): void {\n super.on(event, callback);\n }\n\n public off(event: 'drag' | 'dragstart' | 'dragstop'): void {\n super.off(event);\n }\n\n public enable(): void {\n super.enable();\n this.dragEl.draggable = true;\n this.dragEl.addEventListener('dragstart', this._dragStart);\n this.el.classList.remove('ui-draggable-disabled');\n this.el.classList.add('ui-draggable');\n }\n\n public disable(forDestroy = false): void {\n super.disable();\n this.dragEl.removeAttribute('draggable');\n this.dragEl.removeEventListener('dragstart', this._dragStart);\n this.el.classList.remove('ui-draggable');\n if (!forDestroy) this.el.classList.add('ui-draggable-disabled');\n }\n\n public destroy(): void {\n if (this.dragging) {\n // Destroy while dragging should remove dragend listener and manually trigger\n // dragend, otherwise dragEnd can't perform dragstop because eventRegistry is\n // destroyed.\n this._dragEnd({} as DragEvent);\n }\n this.disable(true);\n delete this.el;\n delete this.helper;\n delete this.option;\n super.destroy();\n }\n\n public updateOption(opts: DDDraggableOpt): DDDraggable {\n Object.keys(opts).forEach(key => this.option[key] = opts[key]);\n return this;\n }\n\n /** @internal */\n private _dragStart(event: DragEvent): void {\n DDManager.dragElement = this;\n this.helper = this._createHelper(event);\n this._setupHelperContainmentStyle();\n this.dragOffset = this._getDragOffset(event, this.el, this.helperContainment);\n const ev = DDUtils.initEvent(event, { target: this.el, type: 'dragstart' });\n if (this.helper !== this.el) {\n this._setupDragFollowNodeNotifyStart(ev);\n } else {\n this.dragFollowTimer = window.setTimeout(() => {\n delete this.dragFollowTimer;\n this._setupDragFollowNodeNotifyStart(ev);\n }, 0);\n }\n this._cancelDragGhost(event);\n }\n\n /** @internal */\n private _setupDragFollowNodeNotifyStart(ev: Event): DDDraggable {\n this._setupHelperStyle();\n document.addEventListener('dragover', this._drag, DDDraggable.dragEventListenerOption);\n this.dragEl.addEventListener('dragend', this._dragEnd);\n if (this.option.start) {\n this.option.start(ev, this.ui());\n }\n this.dragging = true;\n this.helper.classList.add('ui-draggable-dragging');\n this.triggerEvent('dragstart', ev);\n return this;\n }\n\n /** @internal */\n private _drag(event: DragEvent): void {\n // Safari: prevent default to allow drop to happen instead of reverting back (with animation) and delaying dragend #1541\n // https://stackoverflow.com/questions/61760755/how-to-fire-dragend-event-immediately\n event.preventDefault();\n this._dragFollow(event);\n const ev = DDUtils.initEvent(event, { target: this.el, type: 'drag' });\n if (this.option.drag) {\n this.option.drag(ev, this.ui());\n }\n this.triggerEvent('drag', ev);\n }\n\n /** @internal */\n private _dragEnd(event: DragEvent): void {\n if (this.dragFollowTimer) {\n clearTimeout(this.dragFollowTimer);\n delete this.dragFollowTimer;\n return;\n } else {\n if (this.paintTimer) {\n cancelAnimationFrame(this.paintTimer);\n }\n document.removeEventListener('dragover', this._drag, DDDraggable.dragEventListenerOption);\n this.dragEl.removeEventListener('dragend', this._dragEnd);\n }\n this.dragging = false;\n this.helper.classList.remove('ui-draggable-dragging');\n this.helperContainment.style.position = this.parentOriginStylePosition || null;\n if (this.helper === this.el) {\n this._removeHelperStyle();\n } else {\n this.helper.remove();\n }\n const ev = DDUtils.initEvent(event, { target: this.el, type: 'dragstop' });\n if (this.option.stop) {\n this.option.stop(ev); // Note: ui() not used by gridstack so don't pass\n }\n this.triggerEvent('dragstop', ev);\n delete DDManager.dragElement;\n delete this.helper;\n }\n\n /** @internal create a clone copy (or user defined method) of the original drag item if set */\n private _createHelper(event: DragEvent): HTMLElement {\n let helper = this.el;\n if (typeof this.option.helper === 'function') {\n helper = this.option.helper(event);\n } else if (this.option.helper === 'clone') {\n helper = DDUtils.clone(this.el);\n }\n if (!document.body.contains(helper)) {\n DDUtils.appendTo(helper, this.option.appendTo === 'parent' ? this.el.parentNode : this.option.appendTo);\n }\n if (helper === this.el) {\n this.dragElementOriginStyle = DDDraggable.originStyleProp.map(prop => this.el.style[prop]);\n }\n return helper;\n }\n\n /** @internal */\n private _setupHelperStyle(): DDDraggable {\n this.helper.style.pointerEvents = 'none';\n this.helper.style.width = this.dragOffset.width + 'px';\n this.helper.style.height = this.dragOffset.height + 'px';\n this.helper.style.willChange = 'left, top';\n this.helper.style.transition = 'none'; // show up instantly\n this.helper.style.position = this.option.basePosition || DDDraggable.basePosition;\n this.helper.style.zIndex = '1000';\n setTimeout(() => {\n if (this.helper) {\n this.helper.style.transition = null; // recover animation\n }\n }, 0);\n return this;\n }\n\n /** @internal */\n private _removeHelperStyle(): DDDraggable {\n // don't bother restoring styles if we're gonna remove anyway...\n let node = this.helper ? (this.helper as GridItemHTMLElement).gridstackNode : undefined;\n if (!node || !node._isAboutToRemove) {\n DDDraggable.originStyleProp.forEach(prop => {\n this.helper.style[prop] = this.dragElementOriginStyle[prop] || null;\n });\n }\n delete this.dragElementOriginStyle;\n return this;\n }\n\n /** @internal */\n private _dragFollow(event: DragEvent): void {\n if (this.paintTimer) {\n cancelAnimationFrame(this.paintTimer);\n }\n this.paintTimer = requestAnimationFrame(() => {\n delete this.paintTimer;\n const offset = this.dragOffset;\n let containmentRect = { left: 0, top: 0 };\n if (this.helper.style.position === 'absolute') {\n const { left, top } = this.helperContainment.getBoundingClientRect();\n containmentRect = { left, top };\n }\n this.helper.style.left = event.clientX + offset.offsetLeft - containmentRect.left + 'px';\n this.helper.style.top = event.clientY + offset.offsetTop - containmentRect.top + 'px';\n });\n }\n\n /** @internal */\n private _setupHelperContainmentStyle(): DDDraggable {\n this.helperContainment = this.helper.parentElement;\n if (this.option.basePosition !== 'fixed') {\n this.parentOriginStylePosition = this.helperContainment.style.position;\n if (window.getComputedStyle(this.helperContainment).position.match(/static/)) {\n this.helperContainment.style.position = 'relative';\n }\n }\n return this;\n }\n\n /** @internal prevent the default gost image to be created (which has wrongas we move the helper/element instead\n * (legacy jquery UI code updates the top/left of the item).\n * TODO: maybe use mouse event instead of HTML5 drag as we have to work around it anyway, or change code to not update\n * the actual grid-item but move the gost image around (and special case jq version) ?\n **/\n private _cancelDragGhost(e: DragEvent): DDDraggable {\n /* doesn't seem to do anything...\n let t = e.dataTransfer;\n t.effectAllowed = 'none';\n t.dropEffect = 'none';\n t.setData('text', '');\n */\n\n // NOTE: according to spec (and required by Safari see #1540) the image has to be visible in the browser (in dom and not hidden) so make it a 1px div\n let img = document.createElement('div');\n img.style.width = '1px';\n img.style.height = '1px';\n document.body.appendChild(img);\n e.dataTransfer.setDragImage(img, 0, 0);\n setTimeout(() => document.body.removeChild(img)); // nuke once drag had a chance to grab this 'image'\n\n e.stopPropagation();\n return this;\n }\n\n /** @internal */\n private _getDragOffset(event: DragEvent, el: HTMLElement, parent: HTMLElement): DragOffset {\n\n // in case ancestor has transform/perspective css properties that change the viewpoint\n let xformOffsetX = 0;\n let xformOffsetY = 0;\n if (parent) {\n const testEl = document.createElement('div');\n DDUtils.addElStyles(testEl, {\n opacity: '0',\n position: 'fixed',\n top: 0 + 'px',\n left: 0 + 'px',\n width: '1px',\n height: '1px',\n zIndex: '-999999',\n });\n parent.appendChild(testEl);\n const testElPosition = testEl.getBoundingClientRect();\n parent.removeChild(testEl);\n xformOffsetX = testElPosition.left;\n xformOffsetY = testElPosition.top;\n // TODO: scale ?\n }\n\n const targetOffset = el.getBoundingClientRect();\n return {\n left: targetOffset.left,\n top: targetOffset.top,\n offsetLeft: - event.clientX + targetOffset.left - xformOffsetX,\n offsetTop: - event.clientY + targetOffset.top - xformOffsetY,\n width: targetOffset.width,\n height: targetOffset.height\n };\n }\n\n /** @internal TODO: set to public as called by DDDroppable! */\n public ui = (): DDUIData => {\n const containmentEl = this.el.parentElement;\n const containmentRect = containmentEl.getBoundingClientRect();\n const offset = this.helper.getBoundingClientRect();\n return {\n position: { //Current CSS position of the helper as { top, left } object\n top: offset.top - containmentRect.top,\n left: offset.left - containmentRect.left\n }\n /* not used by GridStack for now...\n helper: [this.helper], //The object arr representing the helper that's being dragged.\n offset: { top: offset.top, left: offset.left } // Current offset position of the helper as { top, left } object.\n */\n };\n }\n}\n\n\n","/**\n * dd-droppable.ts 4.2.5\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\n */\n\nimport { DDDraggable } from './dd-draggable';\nimport { DDManager } from './dd-manager';\nimport { DDBaseImplement, HTMLElementExtendOpt } from './dd-base-impl';\nimport { DDUtils } from './dd-utils';\n\nexport interface DDDroppableOpt {\n accept?: string | ((el: HTMLElement) => boolean);\n drop?: (event: DragEvent, ui) => void;\n over?: (event: DragEvent, ui) => void;\n out?: (event: DragEvent, ui) => void;\n}\n\nexport class DDDroppable extends DDBaseImplement implements HTMLElementExtendOpt {\n\n public accept: (el: HTMLElement) => boolean;\n public el: HTMLElement;\n public option: DDDroppableOpt;\n\n /** @internal */\n private moving: boolean;\n\n constructor(el: HTMLElement, opts: DDDroppableOpt = {}) {\n super();\n this.el = el;\n this.option = opts;\n // create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)\n this._dragEnter = this._dragEnter.bind(this);\n this._dragOver = this._dragOver.bind(this);\n this._dragLeave = this._dragLeave.bind(this);\n this._drop = this._drop.bind(this);\n\n this.el.classList.add('ui-droppable');\n this.el.addEventListener('dragenter', this._dragEnter);\n this._setupAccept();\n }\n\n public on(event: 'drop' | 'dropover' | 'dropout', callback: (event: DragEvent) => void): void {\n super.on(event, callback);\n }\n\n public off(event: 'drop' | 'dropover' | 'dropout'): void {\n super.off(event);\n }\n\n public enable(): void {\n if (!this.disabled) return;\n super.enable();\n this.el.classList.remove('ui-droppable-disabled');\n this.el.addEventListener('dragenter', this._dragEnter);\n }\n\n public disable(forDestroy=false): void {\n if (this.disabled) return;\n super.disable();\n if (!forDestroy) this.el.classList.add('ui-droppable-disabled');\n this.el.removeEventListener('dragenter', this._dragEnter);\n }\n\n public destroy(): void {\n if (this.moving) {\n this._removeLeaveCallbacks();\n } \n this.disable(true);\n this.el.classList.remove('ui-droppable');\n this.el.classList.remove('ui-droppable-disabled');\n delete this.moving;\n super.destroy();\n }\n\n public updateOption(opts: DDDroppableOpt): DDDroppable {\n Object.keys(opts).forEach(key => this.option[key] = opts[key]);\n this._setupAccept();\n return this;\n }\n\n /** @internal called when the cursor enters our area - prepare for a possible drop and track leaving */\n private _dragEnter(event: DragEvent): void {\n if (!this._canDrop()) return;\n event.preventDefault();\n\n if (this.moving) return; // ignore multiple 'dragenter' as we go over existing items\n this.moving = true;\n\n const ev = DDUtils.initEvent(event, { target: this.el, type: 'dropover' });\n if (this.option.over) {\n this.option.over(ev, this._ui(DDManager.dragElement))\n }\n this.triggerEvent('dropover', ev);\n this.el.addEventListener('dragover', this._dragOver);\n this.el.addEventListener('drop', this._drop);\n this.el.addEventListener('dragleave', this._dragLeave);\n this.el.classList.add('ui-droppable-over');\n }\n\n /** @internal called when an moving to drop item is being dragged over - do nothing but eat the event */\n private _dragOver(event: DragEvent): void {\n event.preventDefault();\n event.stopPropagation();\n }\n\n /** @internal called when the item is leaving our area, stop tracking if we had moving item */\n private _dragLeave(event: DragEvent): void {\n\n // ignore leave events on our children (get when starting to drag our items)\n // Note: Safari Mac has null relatedTarget which causes #1684 so check if DragEvent is inside the grid instead\n if (!event.relatedTarget) {\n const { bottom, left, right, top } = this.el.getBoundingClientRect();\n if (event.x < right && event.x > left && event.y < bottom && event.y > top) return;\n } else if (this.el.contains(event.relatedTarget as HTMLElement)) return;\n\n this._removeLeaveCallbacks();\n if (this.moving) {\n event.preventDefault();\n const ev = DDUtils.initEvent(event, { target: this.el, type: 'dropout' });\n if (this.option.out) {\n this.option.out(ev, this._ui(DDManager.dragElement))\n }\n this.triggerEvent('dropout', ev);\n }\n delete this.moving;\n }\n\n /** @internal item is being dropped on us - call the client drop event */\n private _drop(event: DragEvent): void {\n if (!this.moving) return; // should not have received event...\n event.preventDefault();\n const ev = DDUtils.initEvent(event, { target: this.el, type: 'drop' });\n if (this.option.drop) {\n this.option.drop(ev, this._ui(DDManager.dragElement))\n }\n this.triggerEvent('drop', ev);\n this._removeLeaveCallbacks();\n delete this.moving;\n }\n\n /** @internal called to remove callbacks when leaving or dropping */\n private _removeLeaveCallbacks() {\n this.el.removeEventListener('dragleave', this._dragLeave);\n this.el.classList.remove('ui-droppable-over');\n if (this.moving) {\n this.el.removeEventListener('dragover', this._dragOver);\n this.el.removeEventListener('drop', this._drop);\n }\n // Note: this.moving is reset by callee of this routine to control the flow\n }\n\n /** @internal */\n private _canDrop(): boolean {\n return DDManager.dragElement && (!this.accept || this.accept(DDManager.dragElement.el));\n }\n\n /** @internal */\n private _setupAccept(): DDDroppable {\n if (this.option.accept && typeof this.option.accept === 'string') {\n this.accept = (el: HTMLElement) => {\n return el.matches(this.option.accept as string)\n }\n } else {\n this.accept = this.option.accept as ((el: HTMLElement) => boolean);\n }\n return this;\n }\n\n /** @internal */\n private _ui(drag: DDDraggable) {\n return {\n draggable: drag.el,\n ...drag.ui()\n };\n }\n}\n\n","/**\n * dd-elements.ts 4.2.5\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\n */\n\nimport { DDResizable, DDResizableOpt } from './dd-resizable';\nimport { GridItemHTMLElement } from './../types';\nimport { DDDraggable, DDDraggableOpt } from './dd-draggable';\nimport { DDDroppable, DDDroppableOpt } from './dd-droppable';\n\nexport interface DDElementHost extends GridItemHTMLElement {\n ddElement?: DDElement;\n}\n\nexport class DDElement {\n\n static init(el: DDElementHost): DDElement {\n if (!el.ddElement) { el.ddElement = new DDElement(el); }\n return el.ddElement;\n }\n\n public el: DDElementHost;\n public ddDraggable?: DDDraggable;\n public ddDroppable?: DDDroppable;\n public ddResizable?: DDResizable;\n\n constructor(el: DDElementHost) {\n this.el = el;\n }\n\n public on(eventName: string, callback: (event: MouseEvent) => void): DDElement {\n if (this.ddDraggable && ['drag', 'dragstart', 'dragstop'].indexOf(eventName) > -1) {\n this.ddDraggable.on(eventName as 'drag' | 'dragstart' | 'dragstop', callback);\n } else if (this.ddDroppable && ['drop', 'dropover', 'dropout'].indexOf(eventName) > -1) {\n this.ddDroppable.on(eventName as 'drop' | 'dropover' | 'dropout', callback);\n } else if (this.ddResizable && ['resizestart', 'resize', 'resizestop'].indexOf(eventName) > -1) {\n this.ddResizable.on(eventName as 'resizestart' | 'resize' | 'resizestop', callback);\n }\n return this;\n }\n\n public off(eventName: string): DDElement {\n if (this.ddDraggable && ['drag', 'dragstart', 'dragstop'].indexOf(eventName) > -1) {\n this.ddDraggable.off(eventName as 'drag' | 'dragstart' | 'dragstop');\n } else if (this.ddDroppable && ['drop', 'dropover', 'dropout'].indexOf(eventName) > -1) {\n this.ddDroppable.off(eventName as 'drop' | 'dropover' | 'dropout');\n } else if (this.ddResizable && ['resizestart', 'resize', 'resizestop'].indexOf(eventName) > -1) {\n this.ddResizable.off(eventName as 'resizestart' | 'resize' | 'resizestop');\n }\n return this;\n }\n\n public setupDraggable(opts: DDDraggableOpt): DDElement {\n if (!this.ddDraggable) {\n this.ddDraggable = new DDDraggable(this.el, opts);\n } else {\n this.ddDraggable.updateOption(opts);\n }\n return this;\n }\n\n public cleanDraggable(): DDElement {\n if (this.ddDraggable) {\n this.ddDraggable.destroy();\n delete this.ddDraggable;\n }\n return this;\n }\n\n public setupResizable(opts: DDResizableOpt): DDElement {\n if (!this.ddResizable) {\n this.ddResizable = new DDResizable(this.el, opts);\n } else {\n this.ddResizable.updateOption(opts);\n }\n return this;\n }\n\n public cleanResizable(): DDElement {\n if (this.ddResizable) {\n this.ddResizable.destroy();\n delete this.ddResizable;\n }\n return this;\n }\n\n public setupDroppable(opts: DDDroppableOpt): DDElement {\n if (!this.ddDroppable) {\n this.ddDroppable = new DDDroppable(this.el, opts);\n } else {\n this.ddDroppable.updateOption(opts);\n }\n return this;\n }\n\n public cleanDroppable(): DDElement {\n if (this.ddDroppable) {\n this.ddDroppable.destroy();\n delete this.ddDroppable;\n }\n return this;\n }\n}\n","/**\n * dd-manager.ts 4.2.5\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\n */\n\nimport { DDDraggable } from './dd-draggable';\n\nexport class DDManager {\n static dragElement: DDDraggable;\n}\n","/**\n * dd-resizable-handle.ts 4.2.5\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\n */\n\nexport interface DDResizableHandleOpt {\n start?: (event) => void;\n move?: (event) => void;\n stop?: (event) => void;\n}\n\nexport class DDResizableHandle {\n /** @internal */\n private el: HTMLElement;\n /** @internal */\n private host: HTMLElement;\n /** @internal */\n private option: DDResizableHandleOpt;\n /** @internal */\n private dir: string;\n /** @internal true after we've moved enough pixels to start a resize */\n private moving = false;\n /** @internal */\n private mouseDownEvent: MouseEvent;\n /** @internal */\n private static prefix = 'ui-resizable-';\n\n constructor(host: HTMLElement, direction: string, option: DDResizableHandleOpt) {\n this.host = host;\n this.dir = direction;\n this.option = option;\n // create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)\n this._mouseDown = this._mouseDown.bind(this);\n this._mouseMove = this._mouseMove.bind(this);\n this._mouseUp = this._mouseUp.bind(this);\n\n this._init();\n }\n\n /** @internal */\n private _init(): DDResizableHandle {\n const el = document.createElement('div');\n el.classList.add('ui-resizable-handle');\n el.classList.add(`${DDResizableHandle.prefix}${this.dir}`);\n el.style.zIndex = '100';\n el.style.userSelect = 'none';\n this.el = el;\n this.host.appendChild(this.el);\n this.el.addEventListener('mousedown', this._mouseDown);\n return this;\n }\n\n /** call this when resize handle needs to be removed and cleaned up */\n public destroy(): DDResizableHandle {\n if (this.moving) this._mouseUp(this.mouseDownEvent);\n this.el.removeEventListener('mousedown', this._mouseDown);\n this.host.removeChild(this.el);\n delete this.el;\n delete this.host;\n return this;\n }\n\n /** @internal called on mouse down on us: capture move on the entire document (mouse might not stay on us) until we release the mouse */\n private _mouseDown(e: MouseEvent): void {\n e.preventDefault();\n this.mouseDownEvent = e;\n document.addEventListener('mousemove', this._mouseMove, true); // capture, not bubble\n document.addEventListener('mouseup', this._mouseUp);\n }\n\n /** @internal */\n private _mouseMove(e: MouseEvent): void {\n let s = this.mouseDownEvent;\n // don't start unless we've moved at least 3 pixels\n if (!this.moving && Math.abs(e.x - s.x) + Math.abs(e.y - s.y) > 2) {\n this.moving = true;\n this._triggerEvent('start', this.mouseDownEvent);\n } else if (this.moving) {\n this._triggerEvent('move', e);\n }\n }\n\n /** @internal */\n private _mouseUp(e: MouseEvent): void {\n if (this.moving) {\n this._triggerEvent('stop', e);\n }\n document.removeEventListener('mousemove', this._mouseMove, true);\n document.removeEventListener('mouseup', this._mouseUp);\n delete this.moving;\n delete this.mouseDownEvent;\n }\n\n /** @internal */\n private _triggerEvent(name: string, event: MouseEvent): DDResizableHandle {\n if (this.option[name]) this.option[name](event);\n return this;\n }\n}\n","/**\n * dd-resizable.ts 4.2.5\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\n */\n\nimport { DDResizableHandle } from './dd-resizable-handle';\nimport { DDBaseImplement, HTMLElementExtendOpt } from './dd-base-impl';\nimport { DDUtils } from './dd-utils';\nimport { Utils } from '../utils';\nimport { DDUIData, Rect, Size } from '../types';\n\n// TODO: merge with DDDragOpt\nexport interface DDResizableOpt {\n autoHide?: boolean;\n handles?: string;\n maxHeight?: number;\n maxWidth?: number;\n minHeight?: number;\n minWidth?: number;\n basePosition?: 'fixed' | 'absolute';\n start?: (event: Event, ui: DDUIData) => void;\n stop?: (event: Event) => void;\n resize?: (event: Event, ui: DDUIData) => void;\n}\n\nexport class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt {\n\n // have to be public else complains for HTMLElementExtendOpt ?\n public el: HTMLElement;\n public option: DDResizableOpt;\n\n /** @internal */\n private handlers: DDResizableHandle[];\n /** @internal */\n private originalRect: Rect;\n /** @internal */\n private temporalRect: Rect;\n /** @internal */\n private scrollY: number;\n /** @internal */\n private scrolled: number;\n /** @internal */\n private scrollEl: HTMLElement;\n /** @internal */\n private startEvent: MouseEvent;\n /** @internal value saved in the same order as _originStyleProp[] */\n private elOriginStyleVal: string[];\n /** @internal */\n private parentOriginStylePosition: string;\n /** @internal */\n private static _originStyleProp = ['width', 'height', 'position', 'left', 'top', 'opacity', 'zIndex'];\n\n constructor(el: HTMLElement, opts: DDResizableOpt = {}) {\n super();\n this.el = el;\n this.option = opts;\n this.enable();\n this._setupAutoHide();\n this._setupHandlers();\n }\n\n public on(event: 'resizestart' | 'resize' | 'resizestop', callback: (event: DragEvent) => void): void {\n super.on(event, callback);\n }\n\n public off(event: 'resizestart' | 'resize' | 'resizestop'): void {\n super.off(event);\n }\n\n public enable(): void {\n super.enable();\n this.el.classList.add('ui-resizable');\n this.el.classList.remove('ui-resizable-disabled');\n }\n\n public disable(): void {\n super.disable();\n this.el.classList.add('ui-resizable-disabled');\n this.el.classList.remove('ui-resizable');\n }\n\n public destroy(): void {\n this._removeHandlers();\n if (this.option.autoHide) {\n this.el.removeEventListener('mouseover', this._showHandlers);\n this.el.removeEventListener('mouseout', this._hideHandlers);\n }\n this.el.classList.remove('ui-resizable');\n delete this.el;\n super.destroy();\n }\n\n public updateOption(opts: DDResizableOpt): DDResizable {\n let updateHandles = (opts.handles && opts.handles !== this.option.handles);\n let updateAutoHide = (opts.autoHide && opts.autoHide !== this.option.autoHide);\n Object.keys(opts).forEach(key => this.option[key] = opts[key]);\n if (updateHandles) {\n this._removeHandlers();\n this._setupHandlers();\n }\n if (updateAutoHide) {\n this._setupAutoHide();\n }\n return this;\n }\n\n /** @internal */\n private _setupAutoHide(): DDResizable {\n if (this.option.autoHide) {\n this.el.classList.add('ui-resizable-autohide');\n // use mouseover/mouseout instead of mouseenter/mouseleave to get better performance;\n this.el.addEventListener('mouseover', this._showHandlers);\n this.el.addEventListener('mouseout', this._hideHandlers);\n } else {\n this.el.classList.remove('ui-resizable-autohide');\n this.el.removeEventListener('mouseover', this._showHandlers);\n this.el.removeEventListener('mouseout', this._hideHandlers);\n }\n return this;\n }\n\n /** @internal */\n private _showHandlers = () => {\n this.el.classList.remove('ui-resizable-autohide');\n }\n\n /** @internal */\n private _hideHandlers = () => {\n this.el.classList.add('ui-resizable-autohide');\n }\n\n /** @internal */\n private _setupHandlers(): DDResizable {\n let handlerDirection = this.option.handles || 'e,s,se';\n if (handlerDirection === 'all') {\n handlerDirection = 'n,e,s,w,se,sw,ne,nw';\n }\n this.handlers = handlerDirection.split(',')\n .map(dir => dir.trim())\n .map(dir => new DDResizableHandle(this.el, dir, {\n start: (event: MouseEvent) => {\n this._resizeStart(event);\n },\n stop: (event: MouseEvent) => {\n this._resizeStop(event);\n },\n move: (event: MouseEvent) => {\n this._resizing(event, dir);\n }\n }));\n return this;\n }\n\n /** @internal */\n private _resizeStart(event: MouseEvent): DDResizable {\n this.originalRect = this.el.getBoundingClientRect();\n this.scrollEl = Utils.getScrollElement(this.el);\n this.scrollY = this.scrollEl.scrollTop;\n this.startEvent = event;\n this._setupHelper();\n this._applyChange();\n const ev = DDUtils.initEvent(event, { type: 'resizestart', target: this.el });\n if (this.option.start) {\n this.option.start(ev, this._ui());\n }\n this.el.classList.add('ui-resizable-resizing');\n this.triggerEvent('resizestart', ev);\n return this;\n }\n\n /** @internal */\n private _resizing(event: MouseEvent, dir: string): DDResizable {\n this.scrolled = this.scrollEl.scrollTop - this.scrollY;\n this.temporalRect = this._getChange(event, dir);\n this._applyChange();\n const ev = DDUtils.initEvent(event, { type: 'resize', target: this.el });\n if (this.option.resize) {\n this.option.resize(ev, this._ui());\n }\n this.triggerEvent('resize', ev);\n return this;\n }\n\n /** @internal */\n private _resizeStop(event: MouseEvent): DDResizable {\n const ev = DDUtils.initEvent(event, { type: 'resizestop', target: this.el });\n if (this.option.stop) {\n this.option.stop(ev); // Note: ui() not used by gridstack so don't pass\n }\n this.el.classList.remove('ui-resizable-resizing');\n this.triggerEvent('resizestop', ev);\n this._cleanHelper();\n delete this.startEvent;\n delete this.originalRect;\n delete this.temporalRect;\n delete this.scrollY;\n delete this.scrolled;\n return this;\n }\n\n /** @internal */\n private _setupHelper(): DDResizable {\n this.elOriginStyleVal = DDResizable._originStyleProp.map(prop => this.el.style[prop]);\n this.parentOriginStylePosition = this.el.parentElement.style.position;\n if (window.getComputedStyle(this.el.parentElement).position.match(/static/)) {\n this.el.parentElement.style.position = 'relative';\n }\n this.el.style.position = this.option.basePosition || 'absolute'; // or 'fixed'\n this.el.style.opacity = '0.8';\n this.el.style.zIndex = '1000';\n return this;\n }\n\n /** @internal */\n private _cleanHelper(): DDResizable {\n DDResizable._originStyleProp.forEach((prop, i) => {\n this.el.style[prop] = this.elOriginStyleVal[i] || null;\n });\n this.el.parentElement.style.position = this.parentOriginStylePosition || null;\n return this;\n }\n\n /** @internal */\n private _getChange(event: MouseEvent, dir: string): Rect {\n const oEvent = this.startEvent;\n const newRect = { // Note: originalRect is a complex object, not a simple Rect, so copy out.\n width: this.originalRect.width,\n height: this.originalRect.height + this.scrolled,\n left: this.originalRect.left,\n top: this.originalRect.top - this.scrolled\n };\n \n const offsetX = event.clientX - oEvent.clientX;\n const offsetY = event.clientY - oEvent.clientY;\n\n if (dir.indexOf('e') > -1) {\n newRect.width += offsetX;\n } else if (dir.indexOf('w') > -1) {\n newRect.width -= offsetX;\n newRect.left += offsetX;\n }\n if (dir.indexOf('s') > -1) {\n newRect.height += offsetY;\n } else if (dir.indexOf('n') > -1) {\n newRect.height -= offsetY;\n newRect.top += offsetY\n }\n const constrain = this._constrainSize(newRect.width, newRect.height);\n if (Math.round(newRect.width) !== Math.round(constrain.width)) { // round to ignore slight round-off errors\n if (dir.indexOf('w') > -1) {\n newRect.left += newRect.width - constrain.width;\n }\n newRect.width = constrain.width;\n }\n if (Math.round(newRect.height) !== Math.round(constrain.height)) {\n if (dir.indexOf('n') > -1) {\n newRect.top += newRect.height - constrain.height;\n }\n newRect.height = constrain.height;\n }\n return newRect;\n }\n\n /** @internal constrain the size to the set min/max values */\n private _constrainSize(oWidth: number, oHeight: number): Size {\n const maxWidth = this.option.maxWidth || Number.MAX_SAFE_INTEGER;\n const minWidth = this.option.minWidth || oWidth;\n const maxHeight = this.option.maxHeight || Number.MAX_SAFE_INTEGER;\n const minHeight = this.option.minHeight || oHeight;\n const width = Math.min(maxWidth, Math.max(minWidth, oWidth));\n const height = Math.min(maxHeight, Math.max(minHeight, oHeight));\n return { width, height };\n }\n\n /** @internal */\n private _applyChange(): DDResizable {\n let containmentRect = { left: 0, top: 0, width: 0, height: 0 };\n if (this.el.style.position === 'absolute') {\n const containmentEl = this.el.parentElement;\n const { left, top } = containmentEl.getBoundingClientRect();\n containmentRect = { left, top, width: 0, height: 0 };\n }\n if (!this.temporalRect) return this;\n Object.keys(this.temporalRect).forEach(key => {\n const value = this.temporalRect[key];\n this.el.style[key] = value - containmentRect[key] + 'px';\n });\n return this;\n }\n\n /** @internal */\n private _removeHandlers(): DDResizable {\n this.handlers.forEach(handle => handle.destroy());\n delete this.handlers;\n return this;\n }\n\n /** @internal */\n private _ui = (): DDUIData => {\n const containmentEl = this.el.parentElement;\n const containmentRect = containmentEl.getBoundingClientRect();\n const newRect = { // Note: originalRect is a complex object, not a simple Rect, so copy out.\n width: this.originalRect.width,\n height: this.originalRect.height + this.scrolled,\n left: this.originalRect.left,\n top: this.originalRect.top - this.scrolled\n };\n const rect = this.temporalRect || newRect;\n return {\n position: {\n left: rect.left - containmentRect.left,\n top: rect.top - containmentRect.top\n },\n size: {\n width: rect.width,\n height: rect.height\n }\n /* Gridstack ONLY needs position set above... keep around in case.\n element: [this.el], // The object representing the element to be resized\n helper: [], // TODO: not support yet - The object representing the helper that's being resized\n originalElement: [this.el],// we don't wrap here, so simplify as this.el //The object representing the original element before it is wrapped\n originalPosition: { // The position represented as { left, top } before the resizable is resized\n left: this.originalRect.left - containmentRect.left,\n top: this.originalRect.top - containmentRect.top\n },\n originalSize: { // The size represented as { width, height } before the resizable is resized\n width: this.originalRect.width,\n height: this.originalRect.height\n }\n */\n };\n }\n}\n","/**\n * dd-utils.ts 4.2.5\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\n */\nexport class DDUtils {\n\n public static isEventSupportPassiveOption = ((() => {\n let supportsPassive = false;\n let passiveTest = () => {\n // do nothing\n };\n document.addEventListener('test', passiveTest, {\n get passive() {\n supportsPassive = true;\n return true;\n }\n });\n document.removeEventListener('test', passiveTest);\n return supportsPassive;\n })());\n\n public static clone(el: HTMLElement): HTMLElement {\n const node = el.cloneNode(true) as HTMLElement;\n node.removeAttribute('id');\n return node;\n }\n\n public static appendTo(el: HTMLElement, parent: string | HTMLElement | Node): void {\n let parentNode: HTMLElement;\n if (typeof parent === 'string') {\n parentNode = document.querySelector(parent as string);\n } else {\n parentNode = parent as HTMLElement;\n }\n if (parentNode) {\n parentNode.appendChild(el);\n }\n }\n\n public static setPositionRelative(el: HTMLElement): void {\n if (!(/^(?:r|a|f)/).test(window.getComputedStyle(el).position)) {\n el.style.position = \"relative\";\n }\n }\n\n public static addElStyles(el: HTMLElement, styles: { [prop: string]: string | string[] }): void {\n if (styles instanceof Object) {\n for (const s in styles) {\n if (styles.hasOwnProperty(s)) {\n if (Array.isArray(styles[s])) {\n // support fallback value\n (styles[s] as string[]).forEach(val => {\n el.style[s] = val;\n });\n } else {\n el.style[s] = styles[s];\n }\n }\n }\n }\n }\n\n public static initEvent(e: DragEvent | MouseEvent, info: { type: string; target?: EventTarget }): T {\n const evt = { type: info.type };\n const obj = {\n button: 0,\n which: 0,\n buttons: 1,\n bubbles: true,\n cancelable: true,\n target: info.target ? info.target : e.target\n };\n // don't check for `instanceof DragEvent` as Safari use MouseEvent #1540\n if ((e as DragEvent).dataTransfer) {\n evt['dataTransfer'] = (e as DragEvent).dataTransfer; // workaround 'readonly' field.\n }\n ['altKey','ctrlKey','metaKey','shiftKey'].forEach(p => evt[p] = e[p]); // keys\n ['pageX','pageY','clientX','clientY','screenX','screenY'].forEach(p => evt[p] = e[p]); // point info\n return {...evt, ...obj} as unknown as T;\n }\n}","/**\n * gridstack-dd-native.ts 4.2.5\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\n */\n\nimport { DDManager } from './dd-manager';\nimport { DDElement, DDElementHost } from './dd-element';\n\nimport { GridStackElement } from '../gridstack';\nimport { GridStackDD, DDOpts, DDKey, DDDropOpt, DDCallback, DDValue } from '../gridstack-dd';\nimport { GridItemHTMLElement, DDDragInOpt } from '../types';\nimport { Utils } from '../utils';\n\n// export our base class (what user should use) and all associated types\nexport * from '../gridstack-dd';\n\n/**\n * HTML 5 Native DragDrop based drag'n'drop plugin.\n */\nexport class GridStackDDNative extends GridStackDD {\n\n public resizable(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue): GridStackDDNative {\n this._getDDElements(el).forEach(dEl => {\n if (opts === 'disable' || opts === 'enable') {\n dEl.ddResizable && dEl.ddResizable[opts](); // can't create DD as it requires options for setupResizable()\n } else if (opts === 'destroy') {\n dEl.ddResizable && dEl.cleanResizable();\n } else if (opts === 'option') {\n dEl.setupResizable({ [key]: value });\n } else {\n const grid = dEl.el.gridstackNode.grid;\n let handles = dEl.el.getAttribute('gs-resize-handles') ? dEl.el.getAttribute('gs-resize-handles') : grid.opts.resizable.handles;\n dEl.setupResizable({\n ...grid.opts.resizable,\n ...{ handles: handles },\n ...{\n start: opts.start,\n stop: opts.stop,\n resize: opts.resize\n }\n });\n }\n });\n return this;\n }\n\n public draggable(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue): GridStackDDNative {\n this._getDDElements(el).forEach(dEl => {\n if (opts === 'disable' || opts === 'enable') {\n dEl.ddDraggable && dEl.ddDraggable[opts](); // can't create DD as it requires options for setupDraggable()\n } else if (opts === 'destroy') {\n dEl.ddDraggable && dEl.cleanDraggable();\n } else if (opts === 'option') {\n dEl.setupDraggable({ [key]: value });\n } else {\n const grid = dEl.el.gridstackNode.grid;\n dEl.setupDraggable({\n ...grid.opts.draggable,\n ...{\n containment: (grid.opts._isNested && !grid.opts.dragOut)\n ? grid.el.parentElement\n : (grid.opts.draggable.containment || null),\n start: opts.start,\n stop: opts.stop,\n drag: opts.drag\n }\n });\n }\n });\n return this;\n }\n\n public dragIn(el: GridStackElement, opts: DDDragInOpt): GridStackDDNative {\n this._getDDElements(el).forEach(dEl => dEl.setupDraggable(opts));\n return this;\n }\n\n public droppable(el: GridItemHTMLElement, opts: DDOpts | DDDropOpt, key?: DDKey, value?: DDValue): GridStackDDNative {\n if (typeof opts.accept === 'function' && !opts._accept) {\n opts._accept = opts.accept;\n opts.accept = (el) => opts._accept(el);\n }\n this._getDDElements(el).forEach(dEl => {\n if (opts === 'disable' || opts === 'enable') {\n dEl.ddDroppable && dEl.ddDroppable[opts]();\n } else if (opts === 'destroy') {\n if (dEl.ddDroppable) { // error to call destroy if not there\n dEl.cleanDroppable();\n }\n } else if (opts === 'option') {\n dEl.setupDroppable({ [key]: value });\n } else {\n dEl.setupDroppable(opts);\n }\n });\n return this;\n }\n\n /** true if element is droppable */\n public isDroppable(el: DDElementHost): boolean {\n return !!(el && el.ddElement && el.ddElement.ddDroppable && !el.ddElement.ddDroppable.disabled);\n }\n\n /** true if element is draggable */\n public isDraggable(el: DDElementHost): boolean {\n return !!(el && el.ddElement && el.ddElement.ddDraggable && !el.ddElement.ddDraggable.disabled);\n }\n\n /** true if element is draggable */\n public isResizable(el: DDElementHost): boolean {\n return !!(el && el.ddElement && el.ddElement.ddResizable && !el.ddElement.ddResizable.disabled);\n }\n\n public on(el: GridItemHTMLElement, name: string, callback: DDCallback): GridStackDDNative {\n this._getDDElements(el).forEach(dEl =>\n dEl.on(name, (event: Event) => {\n callback(\n event,\n DDManager.dragElement ? DDManager.dragElement.el : event.target as GridItemHTMLElement,\n DDManager.dragElement ? DDManager.dragElement.helper : null)\n })\n );\n return this;\n }\n\n public off(el: GridItemHTMLElement, name: string): GridStackDD {\n this._getDDElements(el).forEach(dEl => dEl.off(name));\n return this;\n }\n\n /** @internal returns a list of DD elements, creating them on the fly by default */\n private _getDDElements(els: GridStackElement, create = true): DDElement[] {\n let hosts = Utils.getElements(els) as DDElementHost[];\n if (!hosts.length) return [];\n let list = hosts.map(e => e.ddElement || (create ? DDElement.init(e) : null));\n if (!create) { list.filter(d => d); } // remove nulls\n return list;\n }\n}\n\n// finally register ourself\nGridStackDD.registerPlugin(GridStackDDNative);\n","/**\r\n * utils.ts 4.2.5\r\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\r\n */\r\n\r\nimport { GridStackElement, GridStackNode, GridStackOptions, numberOrString, GridStackPosition, GridStackWidget } from './types';\r\n\r\nexport interface HeightData {\r\n h: number;\r\n unit: string;\r\n}\r\n\r\n/** checks for obsolete method names */\r\n// eslint-disable-next-line\r\nexport function obsolete(self, f, oldName: string, newName: string, rev: string): (...args: any[]) => any {\r\n let wrapper = (...args) => {\r\n console.warn('gridstack.js: Function `' + oldName + '` is deprecated in ' + rev + ' and has been replaced ' +\r\n 'with `' + newName + '`. It will be **completely** removed in v1.0');\r\n return f.apply(self, args);\r\n }\r\n wrapper.prototype = f.prototype;\r\n return wrapper;\r\n}\r\n\r\n/** checks for obsolete grid options (can be used for any fields, but msg is about options) */\r\nexport function obsoleteOpts(opts: GridStackOptions, oldName: string, newName: string, rev: string): void {\r\n if (opts[oldName] !== undefined) {\r\n opts[newName] = opts[oldName];\r\n console.warn('gridstack.js: Option `' + oldName + '` is deprecated in ' + rev + ' and has been replaced with `' +\r\n newName + '`. It will be **completely** removed in v1.0');\r\n }\r\n}\r\n\r\n/** checks for obsolete grid options which are gone */\r\nexport function obsoleteOptsDel(opts: GridStackOptions, oldName: string, rev: string, info: string): void {\r\n if (opts[oldName] !== undefined) {\r\n console.warn('gridstack.js: Option `' + oldName + '` is deprecated in ' + rev + info);\r\n }\r\n}\r\n\r\n/** checks for obsolete Jquery element attributes */\r\nexport function obsoleteAttr(el: HTMLElement, oldName: string, newName: string, rev: string): void {\r\n let oldAttr = el.getAttribute(oldName);\r\n if (oldAttr !== null) {\r\n el.setAttribute(newName, oldAttr);\r\n console.warn('gridstack.js: attribute `' + oldName + '`=' + oldAttr + ' is deprecated on this object in ' + rev + ' and has been replaced with `' +\r\n newName + '`. It will be **completely** removed in v1.0');\r\n }\r\n}\r\n\r\n/**\r\n * Utility methods\r\n */\r\nexport class Utils {\r\n\r\n /** convert a potential selector into actual list of html elements */\r\n static getElements(els: GridStackElement): HTMLElement[] {\r\n if (typeof els === 'string') {\r\n let list = document.querySelectorAll(els);\r\n if (!list.length && els[0] !== '.' && els[0] !== '#') {\r\n list = document.querySelectorAll('.' + els);\r\n if (!list.length) { list = document.querySelectorAll('#' + els) }\r\n }\r\n return Array.from(list) as HTMLElement[];\r\n }\r\n return [els];\r\n }\r\n\r\n /** convert a potential selector into actual single element */\r\n static getElement(els: GridStackElement): HTMLElement {\r\n if (typeof els === 'string') {\r\n if (!els.length) return null;\r\n if (els[0] === '#') {\r\n return document.getElementById(els.substring(1));\r\n }\r\n if (els[0] === '.' || els[0] === '[') {\r\n return document.querySelector(els);\r\n }\r\n\r\n // if we start with a digit, assume it's an id (error calling querySelector('#1')) as class are not valid CSS\r\n if(!isNaN(+els[0])) { // start with digit\r\n return document.getElementById(els);\r\n }\r\n\r\n // finally try string, then id then class\r\n let el = document.querySelector(els);\r\n if (!el) { el = document.getElementById(els) }\r\n if (!el) { el = document.querySelector('.' + els) }\r\n return el as HTMLElement;\r\n }\r\n return els;\r\n }\r\n\r\n /** returns true if a and b overlap */\r\n static isIntercepted(a: GridStackPosition, b: GridStackPosition): boolean {\r\n return !(a.y >= b.y + b.h || a.y + a.h <= b.y || a.x + a.w <= b.x || a.x >= b.x + b.w);\r\n }\r\n\r\n /** returns true if a and b touch edges or corners */\r\n static isTouching(a: GridStackPosition, b: GridStackPosition): boolean {\r\n return Utils.isIntercepted(a, {x: b.x-0.5, y: b.y-0.5, w: b.w+1, h: b.h+1})\r\n }\r\n /**\r\n * Sorts array of nodes\r\n * @param nodes array to sort\r\n * @param dir 1 for asc, -1 for desc (optional)\r\n * @param width width of the grid. If undefined the width will be calculated automatically (optional).\r\n **/\r\n static sort(nodes: GridStackNode[], dir?: -1 | 1, column?: number): GridStackNode[] {\r\n column = column || nodes.reduce((col, n) => Math.max(n.x + n.w, col), 0) || 12;\r\n if (dir === -1)\r\n return nodes.sort((a, b) => (b.x + b.y * column)-(a.x + a.y * column));\r\n else\r\n return nodes.sort((b, a) => (b.x + b.y * column)-(a.x + a.y * column));\r\n }\r\n\r\n /**\r\n * creates a style sheet with style id under given parent\r\n * @param id will set the 'gs-style-id' attribute to that id\r\n * @param parent to insert the stylesheet as first child,\r\n * if none supplied it will be appended to the document head instead.\r\n */\r\n static createStylesheet(id: string, parent?: HTMLElement): CSSStyleSheet {\r\n let style: HTMLStyleElement = document.createElement('style');\r\n style.setAttribute('type', 'text/css');\r\n style.setAttribute('gs-style-id', id);\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n if ((style as any).styleSheet) { // TODO: only CSSImportRule have that and different beast ??\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n (style as any).styleSheet.cssText = '';\r\n } else {\r\n style.appendChild(document.createTextNode('')); // WebKit hack\r\n }\r\n if (!parent) {\r\n // default to head\r\n parent = document.getElementsByTagName('head')[0];\r\n parent.appendChild(style);\r\n } else {\r\n parent.insertBefore(style, parent.firstChild);\r\n }\r\n return style.sheet as CSSStyleSheet;\r\n }\r\n\r\n /** removed the given stylesheet id */\r\n static removeStylesheet(id: string): void {\r\n let el = document.querySelector('STYLE[gs-style-id=' + id + ']');\r\n if (el && el.parentNode) el.remove();\r\n }\r\n\r\n /** inserts a CSS rule */\r\n static addCSSRule(sheet: CSSStyleSheet, selector: string, rules: string): void {\r\n if (typeof sheet.addRule === 'function') {\r\n sheet.addRule(selector, rules);\r\n } else if (typeof sheet.insertRule === 'function') {\r\n sheet.insertRule(`${selector}{${rules}}`);\r\n }\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n static toBool(v: unknown): boolean {\r\n if (typeof v === 'boolean') {\r\n return v;\r\n }\r\n if (typeof v === 'string') {\r\n v = v.toLowerCase();\r\n return !(v === '' || v === 'no' || v === 'false' || v === '0');\r\n }\r\n return Boolean(v);\r\n }\r\n\r\n static toNumber(value: null | string): number {\r\n return (value === null || value.length === 0) ? undefined : Number(value);\r\n }\r\n\r\n static parseHeight(val: numberOrString): HeightData {\r\n let h: number;\r\n let unit = 'px';\r\n if (typeof val === 'string') {\r\n let match = val.match(/^(-[0-9]+\\.[0-9]+|[0-9]*\\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw|%)?$/);\r\n if (!match) {\r\n throw new Error('Invalid height');\r\n }\r\n unit = match[2] || 'px';\r\n h = parseFloat(match[1]);\r\n } else {\r\n h = val;\r\n }\r\n return { h, unit };\r\n }\r\n\r\n /** copies unset fields in target to use the given default sources values */\r\n // eslint-disable-next-line\r\n static defaults(target, ...sources): {} {\r\n\r\n sources.forEach(source => {\r\n for (const key in source) {\r\n if (!source.hasOwnProperty(key)) return;\r\n if (target[key] === null || target[key] === undefined) {\r\n target[key] = source[key];\r\n } else if (typeof source[key] === 'object' && typeof target[key] === 'object') {\r\n // property is an object, recursively add it's field over... #1373\r\n this.defaults(target[key], source[key]);\r\n }\r\n }\r\n });\r\n\r\n return target;\r\n }\r\n\r\n /** given 2 objects return true if they have the same values. Checks for Object {} having same fields and values (just 1 level down) */\r\n static same(a: unknown, b: unknown): boolean {\r\n if (typeof a !== 'object') return a == b;\r\n if (typeof a !== typeof b) return false;\r\n // else we have object, check just 1 level deep for being same things...\r\n if (Object.keys(a).length !== Object.keys(b).length) return false;\r\n for (const key in a) {\r\n if (a[key] !== b[key]) return false;\r\n }\r\n return true;\r\n }\r\n\r\n /* copies over b size & position (GridStackPosition), and possibly min/max as well */\r\n static copyPos(a: GridStackWidget, b: GridStackWidget, minMax = false): GridStackWidget {\r\n a.x = b.x;\r\n a.y = b.y;\r\n a.w = b.w;\r\n a.h = b.h;\r\n if (!minMax) return a;\r\n if (b.minW) a.minW = b.minW;\r\n if (b.minH) a.minH = b.minH;\r\n if (b.maxW) a.maxW = b.maxW;\r\n if (b.maxH) a.maxH = b.maxH;\r\n return a;\r\n }\r\n\r\n /* true if a and b has same size & position */\r\n static samePos(a: GridStackPosition, b: GridStackPosition): boolean {\r\n return a && b && a.x === b.x && a.y === b.y && a.w === b.w && a.h === b.h;\r\n }\r\n\r\n /** removes field from the first object if same as the second objects (like diffing) and internal '_' for saving */\r\n static removeInternalAndSame(a: unknown, b: unknown):void {\r\n if (typeof a !== 'object' || typeof b !== 'object') return;\r\n for (let key in a) {\r\n let val = a[key];\r\n if (val && typeof val === 'object' && b[key] !== undefined) {\r\n for (let i in val) {\r\n if (val[i] === b[key][i] || i[0] === '_') { delete val[i] }\r\n }\r\n if (!Object.keys(val).length) { delete a[key] }\r\n } else if (val === b[key] || key[0] === '_') { delete a[key] }\r\n }\r\n }\r\n\r\n /** return the closest parent matching the given class */\r\n static closestByClass(el: HTMLElement, name: string): HTMLElement {\r\n\r\n while(el = el.parentElement) {\r\n if (el.classList.contains(name)) return el;\r\n }\r\n return null;\r\n }\r\n\r\n /** delay calling the given function for given delay, preventing new calls from happening while waiting */\r\n static throttle(func: () => void, delay: number): () => void {\r\n let isWaiting = false;\r\n return (...args) => {\r\n if (!isWaiting) {\r\n isWaiting = true;\r\n setTimeout(() => { func(...args); isWaiting = false; }, delay);\r\n }\r\n }\r\n }\r\n\r\n static removePositioningStyles(el: HTMLElement): void {\r\n let style = el.style;\r\n if (style.position) {\r\n style.removeProperty('position');\r\n }\r\n if (style.left) {\r\n style.removeProperty('left');\r\n }\r\n if (style.top) {\r\n style.removeProperty('top');\r\n }\r\n if (style.width) {\r\n style.removeProperty('width');\r\n }\r\n if (style.height) {\r\n style.removeProperty('height');\r\n }\r\n }\r\n\r\n /** @internal returns the passed element if scrollable, else the closest parent that will, up to the entire document scrolling element */\r\n static getScrollElement(el?: HTMLElement): HTMLElement {\r\n if (!el) return document.scrollingElement as HTMLElement;\r\n const style = getComputedStyle(el);\r\n const overflowRegex = /(auto|scroll)/;\r\n\r\n if (overflowRegex.test(style.overflow + style.overflowY)) {\r\n return el;\r\n } else {\r\n return this.getScrollElement(el.parentElement);\r\n }\r\n }\r\n\r\n /** @internal */\r\n static updateScrollPosition(el: HTMLElement, position: {top: number}, distance: number): void {\r\n // is widget in view?\r\n let rect = el.getBoundingClientRect();\r\n let innerHeightOrClientHeight = (window.innerHeight || document.documentElement.clientHeight);\r\n if (rect.top < 0 ||\r\n rect.bottom > innerHeightOrClientHeight\r\n ) {\r\n // set scrollTop of first parent that scrolls\r\n // if parent is larger than el, set as low as possible\r\n // to get entire widget on screen\r\n let offsetDiffDown = rect.bottom - innerHeightOrClientHeight;\r\n let offsetDiffUp = rect.top;\r\n let scrollEl = this.getScrollElement(el);\r\n if (scrollEl !== null) {\r\n let prevScroll = scrollEl.scrollTop;\r\n if (rect.top < 0 && distance < 0) {\r\n // moving up\r\n if (el.offsetHeight > innerHeightOrClientHeight) {\r\n scrollEl.scrollTop += distance;\r\n } else {\r\n scrollEl.scrollTop += Math.abs(offsetDiffUp) > Math.abs(distance) ? distance : offsetDiffUp;\r\n }\r\n } else if (distance > 0) {\r\n // moving down\r\n if (el.offsetHeight > innerHeightOrClientHeight) {\r\n scrollEl.scrollTop += distance;\r\n } else {\r\n scrollEl.scrollTop += offsetDiffDown > distance ? distance : offsetDiffDown;\r\n }\r\n }\r\n // move widget y by amount scrolled\r\n position.top += scrollEl.scrollTop - prevScroll;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @internal Function used to scroll the page.\r\n *\r\n * @param event `MouseEvent` that triggers the resize\r\n * @param el `HTMLElement` that's being resized\r\n * @param distance Distance from the V edges to start scrolling\r\n */\r\n static updateScrollResize(event: MouseEvent, el: HTMLElement, distance: number): void {\r\n const scrollEl = this.getScrollElement(el);\r\n const height = scrollEl.clientHeight;\r\n // #1727 event.clientY is relative to viewport, so must compare this against position of scrollEl getBoundingClientRect().top\r\n // #1745 Special situation if scrollEl is document 'html': here browser spec states that\r\n // clientHeight is height of viewport, but getBoundingClientRect() is rectangle of html element;\r\n // this discrepancy arises because in reality scrollbar is attached to viewport, not html element itself.\r\n const offsetTop = (scrollEl === this.getScrollElement()) ? 0 : scrollEl.getBoundingClientRect().top;\r\n const pointerPosY = event.clientY - offsetTop;\r\n const top = pointerPosY < distance;\r\n const bottom = pointerPosY > height - distance;\r\n\r\n if (top) {\r\n // This also can be done with a timeout to keep scrolling while the mouse is\r\n // in the scrolling zone. (will have smoother behavior)\r\n scrollEl.scrollBy({ behavior: 'smooth', top: pointerPosY - distance});\r\n } else if (bottom) {\r\n scrollEl.scrollBy({ behavior: 'smooth', top: distance - (height - pointerPosY)});\r\n }\r\n }\r\n}\r\n\r\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(930);\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://GridStack/webpack/universalModuleDefinition","webpack://GridStack/./src/gridstack-dd.ts","webpack://GridStack/./src/gridstack-ddi.ts","webpack://GridStack/./src/gridstack-engine.ts","webpack://GridStack/./src/gridstack-h5.ts","webpack://GridStack/./src/gridstack.ts","webpack://GridStack/./src/h5/dd-base-impl.ts","webpack://GridStack/./src/h5/dd-draggable.ts","webpack://GridStack/./src/h5/dd-droppable.ts","webpack://GridStack/./src/h5/dd-element.ts","webpack://GridStack/./src/h5/dd-manager.ts","webpack://GridStack/./src/h5/dd-resizable-handle.ts","webpack://GridStack/./src/h5/dd-resizable.ts","webpack://GridStack/./src/h5/dd-utils.ts","webpack://GridStack/./src/h5/gridstack-dd-native.ts","webpack://GridStack/./src/utils.ts","webpack://GridStack/webpack/bootstrap","webpack://GridStack/webpack/startup"],"names":["root","factory","exports","module","define","amd","self","GridStackDD","GridStackDDI","get","el","this","draggable","resizable","gridstackNode","_initDD","_itemRemoving","remove","node","undefined","grid","_isAboutToRemove","classList","add","GridStack","prototype","_setupAcceptWidget","opts","staticGrid","acceptWidgets","removable","droppable","gridPos","cellHeight","cellWidth","onDrag","event","helper","rec","getBoundingClientRect","left","top","ui","position","_temporaryRemoved","x","Math","max","round","y","autoPosition","engine","nodeBoundFix","willItFit","off","_willFitPos","Utils","copyPos","_onStartMoving","_dragOrResize","accept","canAccept","selector","matches","maxRow","n","w","h","minW","minH","on","_leave","box","getCellHeight","_readAttr","_isExternal","offsetWidth","offsetHeight","_gridstackNodeOrig","cleanupNode","wasAdded","placeholder","parentElement","origNode","oGrid","removedNodes","push","_triggerRemoveEvent","cloneNode","removePositioningStyles","_writeAttr","appendChild","_updateContainerHeight","addedNodes","_triggerAddEvent","_triggerChangeEvent","endUpdate","_gsEventHandler","type","window","setTimeout","_prepareDragDropByNode","removeNode","_setupRemoveDrop","trashEl","document","querySelector","isDroppable","removableOptions","setupDragIn","_dragIn","_dragInOptions","dragIn","dragInOptions","revert","handle","scroll","appendTo","dd","getElements","forEach","isDraggable","noMove","disableDrag","noResize","disableResize","onStartMoving","target","dragOrResize","onEndMoving","_moving","_lastTried","gridToNotify","_orig","_writePosAttr","addNode","_extraDragRow","start","stop","drag","resize","cleanNodes","beginUpdate","_lastUiPosition","_prevYPix","cacheRects","marginTop","marginRight","marginBottom","marginLeft","maxW","maxH","restoreInitial","resizing","p","mLeft","mRight","mTop","mBottom","distance","updateScrollPosition","prev","collide","row","getRow","extra","updateScrollResize","size","width","height","rect","moveNodeCheck","_skipDown","subGrid","onParentResize","movable","els","val","disable","enableMove","enableResize","_triggerEvent","enable","doEnable","nodes","pluginClass","ddi","registerPlugin","GridStackEngine","column","onChange","_float","float","batchMode","_prevFloat","saveInitial","_packNodes","_notify","nn","_hasLocked","opt","_sortNodes","nested","swap","area","_useEntireRowArea","skip","didMove","newOpt","pack","moved","locked","moveNode","skip2","find","isIntercepted","filter","o","collides","_rect","r0","r","r2","yOver","Number","MAX_VALUE","xOver","overMax","over","min","right","bottom","a","b","_doSwap","_dirty","touching","isTouching","t","length","batchUpdate","copyNodes","commit","dir","sort","_updating","newY","i","_id","_idSeq","defaults","isNaN","cacheOneLayout","verify","samePos","removeDOM","dirtyNodes","Array","isArray","concat","getDirtyNodes","some","triggerAddEvent","dup","prepareNode","_removeDOM","floor","_fixCollisions","triggerEvent","_layouts","changedPosConstrain","clonedNode","clone","map","canMove","c","content","prevPos","collideAll","needToMove","collideCoverage","reduce","saveElement","list","key","_ignoreLayoutsNodeChange","layout","l","ratio","oldColumn","cacheLayout","cacheNodes","lastIndex","cacheNode","j","findIndex","newNodes","splice","move","scale","clear","copy","index","prop","GridDefaults","minRow","itemClass","placeholderClass","placeholderText","handleClass","styleInHead","cellHeightThrottle","margin","auto","minWidth","animate","alwaysShowResizeHandle","autoHide","handles","rtl","marginUnit","cellHeightUnit","disableOneColumnMode","oneColumnModeDomSort","rowAttr","toNumber","getAttribute","cloneDeep","toBool","_styleSheetClass","random","toFixed","initMargin","_widthOrContainer","_prevColumn","style","direction","parentGridItemEl","closestByClass","_isNested","_isAutoCellHeight","_setStaticClass","cbNodes","_updateStyles","elements","getGridItems","parseInt","e","_prepareElement","setAnimation","_updateWindowResizeEvent","options","elOrString","getGridElement","gridstack","console","error","grids","getGridElements","parent","contains","doc","implementation","createHTMLDocument","body","innerHTML","class","children","init","load","_placeholder","placeholderChild","createElement","className","arguments","warn","id","addWidget","domAttr","_insertNotAppend","prepend","addGrid","saveContent","saveGridOpt","save","sub","removeInternalAndSame","addAndRemove","items","removed","removeWidget","item","update","forcePixel","marginDiff","data","parseHeight","unit","clientWidth","innerWidth","compact","domNodes","updateNodeWidths","from","setStatic","parentNode","removeChild","removeAll","_removeStylesheet","removeAttribute","useDocRelative","containerPos","documentElement","scrollTop","offsetTop","offsetLeft","relativeLeft","relativeTop","columnWidth","rowHeight","isAreaEmpty","getElement","name","callback","indexOf","split","noData","detail","addEventListener","log","removeEventListener","doAnimate","updateClass","m","keys","k","changed","ddChanged","value","layoutsNodesChange","CustomEvent","bubbles","Event","dispatchEvent","_styles","removeStylesheet","forceUpdate","prefix","styleLocation","createStylesheet","_max","addCSSRule","getHeight","rows","cssMinHeight","getComputedStyle","setAttribute","String","removeProperty","same","attrs","resizeHandles","hasOwnProperty","classes","oneColumn","changedOneColumn","_cellHeightThrottle","throttle","forceRemove","workTodo","_windowResizeBind","bind","margins","Engine","_disabled","_eventRegister","eventName","disabled","DDDraggable","DDBaseImplement","option","super","dragging","containmentRect","offset","substring","dragEl","_dragStart","_drag","_dragEnd","forDestroy","destroy","Object","DDManager","dragElement","_createHelper","_setupHelperContainmentStyle","dragOffset","_getDragOffset","helperContainment","ev","DDUtils","initEvent","_setupDragFollowNodeNotifyStart","_dragFollow","dragFollowTimer","_cancelDragGhost","_setupHelperStyle","dragEventListenerOption","preventDefault","clearTimeout","paintTimer","cancelAnimationFrame","parentOriginStylePosition","_removeHelperStyle","dragElementOriginStyle","originStyleProp","pointerEvents","willChange","transition","basePosition","zIndex","requestAnimationFrame","clientX","clientY","match","img","dataTransfer","setDragImage","stopPropagation","xformOffsetX","xformOffsetY","testEl","addElStyles","opacity","testElPosition","targetOffset","DDDroppable","_dragEnter","_dragOver","_dragLeave","_drop","_setupAccept","moving","_removeLeaveCallbacks","_canDrop","_ui","relatedTarget","out","drop","DDElement","ddElement","ddDraggable","ddDroppable","ddResizable","updateOption","DDResizable","DDResizableHandle","host","_mouseDown","_mouseMove","_mouseUp","_init","userSelect","mouseDownEvent","s","abs","_showHandlers","_hideHandlers","newRect","originalRect","scrolled","temporalRect","_setupAutoHide","_setupHandlers","_removeHandlers","updateHandles","updateAutoHide","handlerDirection","handlers","trim","_resizeStart","_resizeStop","_resizing","scrollEl","getScrollElement","scrollY","startEvent","_setupHelper","_applyChange","_getChange","_cleanHelper","elOriginStyleVal","_originStyleProp","oEvent","offsetX","offsetY","constrain","_constrainSize","oWidth","oHeight","maxWidth","MAX_SAFE_INTEGER","maxHeight","minHeight","containmentEl","test","styles","info","evt","obj","button","which","buttons","cancelable","isEventSupportPassiveOption","supportsPassive","passiveTest","GridStackDDNative","_getDDElements","dEl","cleanResizable","setupResizable","cleanDraggable","setupDraggable","containment","dragOut","_accept","cleanDroppable","setupDroppable","create","hosts","d","f","oldName","newName","rev","wrapper","args","apply","oldAttr","querySelectorAll","getElementById","col","styleSheet","cssText","createTextNode","insertBefore","firstChild","getElementsByTagName","sheet","rules","addRule","insertRule","v","toLowerCase","Boolean","Error","parseFloat","sources","source","minMax","func","delay","isWaiting","scrollingElement","overflow","overflowY","innerHeightOrClientHeight","innerHeight","clientHeight","offsetDiffDown","offsetDiffUp","prevScroll","pointerPosY","scrollBy","behavior","ret","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","__webpack_modules__","call"],"mappings":";CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAmB,UAAID,IAEvBD,EAAgB,UAAIC,IARtB,CASGK,MAAM,WACT,M,6GCJA,eAEA,SACA,SAoBA,MAAsBC,UAAoB,EAAAC,aAGxC,aACE,OAAO,EAAAA,aAAaC,MAIf,OAAOC,GAKZ,OAJAC,KAAKC,UAAUF,EAAI,WAAWG,UAAUH,EAAI,WACxCA,EAAGI,sBACEJ,EAAGI,cAAcC,QAEnBJ,MAgQX,SAASK,EAAcN,EAAyBO,GAC9C,IAAIC,EAAOR,EAAKA,EAAGI,mBAAgBK,EAC9BD,GAASA,EAAKE,OACnBH,EAASC,EAAKG,kBAAmB,SAAcH,EAAKG,iBACpDJ,EAASP,EAAGY,UAAUC,IAAI,4BAA8Bb,EAAGY,UAAUL,OAAO,6BAjR9E,gBA8CA,EAAAO,UAAUC,UAAUC,mBAAqB,WAGvC,GAAIf,KAAKgB,KAAKC,aAAgBjB,KAAKgB,KAAKE,gBAAkBlB,KAAKgB,KAAKG,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IAA8C,OAAxBA,EAAIyM,UAAU,EAAG,KAC/EgM,EAAIzY,GAAOpO,EAAM+Q,UAAU2R,EAAItU,KAGnC,OAAOyY,GA1VX,YCpDIC,EAA2B,GCE3BC,EDCJ,SAASC,EAAoBC,GAE5B,IAAIC,EAAeJ,EAAyBG,GAC5C,QAAqBtpB,IAAjBupB,EACH,OAAOA,EAAaxqB,QAGrB,IAAIC,EAASmqB,EAAyBG,GAAY,CAGjDvqB,QAAS,IAOV,OAHAyqB,EAAoBF,GAAUG,KAAKzqB,EAAOD,QAASC,EAAQA,EAAOD,QAASsqB,GAGpErqB,EAAOD,QClBWsqB,CAAoB,K","file":"gridstack-h5.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"GridStack\"] = factory();\n\telse\n\t\troot[\"GridStack\"] = factory();\n})(self, function() {\nreturn ","/**\r\n * gridstack-dd.ts 4.2.6\r\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\r\n */\r\n\r\n/* eslint-disable @typescript-eslint/no-unused-vars */\r\nimport { GridStackDDI } from './gridstack-ddi';\r\nimport { GridItemHTMLElement, GridStackNode, GridStackElement, DDUIData, DDDragInOpt, GridStackPosition } from './types';\r\nimport { GridStack, MousePosition } from './gridstack';\r\nimport { Utils } from './utils';\r\n\r\n/** Drag&Drop drop options */\r\nexport type DDDropOpt = {\r\n /** function or class type that this grid will accept as dropped items (see GridStackOptions.acceptWidgets) */\r\n accept?: (el: GridItemHTMLElement) => boolean;\r\n}\r\n\r\n/** drag&drop options currently called from the main code, but others can be passed in grid options */\r\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\r\nexport type DDOpts = 'enable' | 'disable' | 'destroy' | 'option' | string | any;\r\nexport type DDKey = 'minWidth' | 'minHeight' | 'maxWidth' | 'maxHeight';\r\nexport type DDValue = number | string;\r\n\r\n/** drag&drop events callbacks */\r\nexport type DDCallback = (event: Event, arg2: GridItemHTMLElement, helper?: GridItemHTMLElement) => void;\r\n\r\n/**\r\n * Base class implementing common Grid drag'n'drop functionality, with domain specific subclass (h5 vs jq subclasses)\r\n */\r\nexport abstract class GridStackDD extends GridStackDDI {\r\n\r\n /** override to cast to correct type */\r\n static get(): GridStackDD {\r\n return GridStackDDI.get() as GridStackDD;\r\n }\r\n\r\n /** removes any drag&drop present (called during destroy) */\r\n public remove(el: GridItemHTMLElement): GridStackDD {\r\n this.draggable(el, 'destroy').resizable(el, 'destroy');\r\n if (el.gridstackNode) {\r\n delete el.gridstackNode._initDD; // reset our DD init flag\r\n }\r\n return this;\r\n }\r\n\r\n // APIs that must be implemented by subclasses to do actual darg/drop/resize called by GridStack code below\r\n\r\n public abstract resizable(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue): GridStackDD;\r\n\r\n public abstract isResizable(el: HTMLElement): boolean;\r\n\r\n public abstract draggable(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue): GridStackDD;\r\n\r\n public abstract dragIn(el: GridStackElement, opts: DDDragInOpt): GridStackDD;\r\n\r\n public abstract isDraggable(el: HTMLElement): boolean;\r\n\r\n public abstract droppable(el: GridItemHTMLElement, opts: DDOpts | DDDropOpt, key?: DDKey, value?: DDValue): GridStackDD;\r\n\r\n public abstract isDroppable(el: HTMLElement): boolean;\r\n\r\n public abstract on(el: GridItemHTMLElement, eventName: string, callback: DDCallback): GridStackDD;\r\n\r\n public abstract off(el: GridItemHTMLElement, eventName: string): GridStackDD;\r\n}\r\n\r\n/********************************************************************************\r\n * GridStack code that is doing drag&drop extracted here so main class is smaller\r\n * for static grid that don't do any of this work anyway. Saves about 10k.\r\n * TODO: no code hint in code below as this is so look at alternatives ?\r\n * https://www.typescriptlang.org/docs/handbook/declaration-merging.html\r\n * https://www.typescriptlang.org/docs/handbook/mixins.html\r\n ********************************************************************************/\r\n\r\n/** @internal called to add drag over to support widgets being added externally */\r\nGridStack.prototype._setupAcceptWidget = function(this: GridStack): GridStack {\r\n\r\n // check if we need to disable things\r\n if (this.opts.staticGrid || (!this.opts.acceptWidgets && !this.opts.removable)) {\r\n GridStackDD.get().droppable(this.el, 'destroy');\r\n return this;\r\n }\r\n\r\n // vars shared across all methods\r\n let gridPos: MousePosition;\r\n let cellHeight: number, cellWidth: number;\r\n\r\n let onDrag = (event: DragEvent, el: GridItemHTMLElement, helper: GridItemHTMLElement) => {\r\n let node = el.gridstackNode;\r\n if (!node) return;\r\n\r\n helper = helper || el;\r\n let rec = helper.getBoundingClientRect();\r\n let left = rec.left - gridPos.left;\r\n let top = rec.top - gridPos.top;\r\n let ui: DDUIData = {position: {top, left}};\r\n\r\n if (node._temporaryRemoved) {\r\n node.x = Math.max(0, Math.round(left / cellWidth));\r\n node.y = Math.max(0, Math.round(top / cellHeight));\r\n delete node.autoPosition;\r\n this.engine.nodeBoundFix(node);\r\n\r\n // don't accept *initial* location if doesn't fit #1419 (locked drop region, or can't grow), but maybe try if it will go somewhere\r\n if (!this.engine.willItFit(node)) {\r\n node.autoPosition = true; // ignore x,y and try for any slot...\r\n if (!this.engine.willItFit(node)) {\r\n GridStackDD.get().off(el, 'drag'); // stop calling us\r\n return; // full grid or can't grow\r\n }\r\n if (node._willFitPos) {\r\n // use the auto position instead #1687\r\n Utils.copyPos(node, node._willFitPos);\r\n delete node._willFitPos;\r\n }\r\n }\r\n\r\n // re-use the existing node dragging method\r\n this._onStartMoving(helper, event, ui, node, cellWidth, cellHeight);\r\n } else {\r\n // re-use the existing node dragging that does so much of the collision detection\r\n this._dragOrResize(helper, event, ui, node, cellWidth, cellHeight);\r\n }\r\n }\r\n\r\n GridStackDD.get()\r\n .droppable(this.el, {\r\n accept: (el: GridItemHTMLElement) => {\r\n let node: GridStackNode = el.gridstackNode;\r\n // set accept drop to true on ourself (which we ignore) so we don't get \"can't drop\" icon in HTML5 mode while moving\r\n if (node && node.grid === this) return true;\r\n if (!this.opts.acceptWidgets) return false;\r\n // check for accept method or class matching\r\n let canAccept = true;\r\n if (typeof this.opts.acceptWidgets === 'function') {\r\n canAccept = this.opts.acceptWidgets(el);\r\n } else {\r\n let selector = (this.opts.acceptWidgets === true ? '.grid-stack-item' : this.opts.acceptWidgets as string);\r\n canAccept = el.matches(selector);\r\n }\r\n // finally check to make sure we actually have space left #1571\r\n if (canAccept && node && this.opts.maxRow) {\r\n let n = {w: node.w, h: node.h, minW: node.minW, minH: node.minH}; // only width/height matters and autoPosition\r\n canAccept = this.engine.willItFit(n);\r\n }\r\n return canAccept;\r\n }\r\n })\r\n /**\r\n * entering our grid area\r\n */\r\n .on(this.el, 'dropover', (event: Event, el: GridItemHTMLElement, helper: GridItemHTMLElement) => {\r\n let node = el.gridstackNode;\r\n // ignore drop enter on ourself (unless we temporarily removed) which happens on a simple drag of our item\r\n if (node && node.grid === this && !node._temporaryRemoved) {\r\n // delete node._added; // reset this to track placeholder again in case we were over other grid #1484 (dropout doesn't always clear)\r\n return false; // prevent parent from receiving msg (which may be a grid as well)\r\n }\r\n\r\n // fix #1578 when dragging fast, we may not get a leave on the previous grid so force one now\r\n if (node && node.grid && node.grid !== this && !node._temporaryRemoved) {\r\n // TEST console.log('dropover without leave');\r\n let otherGrid = node.grid;\r\n otherGrid._leave(el, helper);\r\n }\r\n\r\n // get grid screen coordinates and cell dimensions\r\n let box = this.el.getBoundingClientRect();\r\n gridPos = {top: box.top, left: box.left};\r\n cellWidth = this.cellWidth();\r\n cellHeight = this.getCellHeight(true);\r\n\r\n // load any element attributes if we don't have a node\r\n if (!node) {// @ts-ignore\r\n node = this._readAttr(el);\r\n }\r\n if (!node.grid) {\r\n node._isExternal = true;\r\n el.gridstackNode = node;\r\n }\r\n\r\n // calculate the grid size based on element outer size\r\n helper = helper || el;\r\n let w = node.w || Math.round(helper.offsetWidth / cellWidth) || 1;\r\n let h = node.h || Math.round(helper.offsetHeight / cellHeight) || 1;\r\n\r\n // if the item came from another grid, make a copy and save the original info in case we go back there\r\n if (node.grid && node.grid !== this) {\r\n // copy the node original values (min/max/id/etc...) but override width/height/other flags which are this grid specific\r\n // TEST console.log('dropover cloning node');\r\n if (!el._gridstackNodeOrig) el._gridstackNodeOrig = node; // shouldn't have multiple nested!\r\n el.gridstackNode = node = {...node, w, h, grid: this};\r\n this.engine.cleanupNode(node)\r\n .nodeBoundFix(node);\r\n // restore some internal fields we need after clearing them all\r\n node._initDD =\r\n node._isExternal = // DOM needs to be re-parented on a drop\r\n node._temporaryRemoved = true; // so it can be inserted onDrag below\r\n } else {\r\n node.w = w; node.h = h;\r\n node._temporaryRemoved = true; // so we can insert it\r\n }\r\n\r\n // clear any marked for complete removal (Note: don't check _isAboutToRemove as that is cleared above - just do it)\r\n _itemRemoving(node.el, false);\r\n\r\n GridStackDD.get().on(el, 'drag', onDrag);\r\n // make sure this is called at least once when going fast #1578\r\n onDrag(event as DragEvent, el, helper);\r\n return false; // prevent parent from receiving msg (which may be a grid as well)\r\n })\r\n /**\r\n * Leaving our grid area...\r\n */\r\n .on(this.el, 'dropout', (event, el: GridItemHTMLElement, helper: GridItemHTMLElement) => {\r\n let node = el.gridstackNode;\r\n // fix #1578 when dragging fast, we might get leave after other grid gets enter (which calls us to clean)\r\n // so skip this one if we're not the active grid really..\r\n if (!node.grid || node.grid === this) {\r\n this._leave(el, helper);\r\n }\r\n return false; // prevent parent from receiving msg (which may be grid as well)\r\n })\r\n /**\r\n * end - releasing the mouse\r\n */\r\n .on(this.el, 'drop', (event, el: GridItemHTMLElement, helper: GridItemHTMLElement) => {\r\n let node = el.gridstackNode;\r\n // ignore drop on ourself from ourself that didn't come from the outside - dragend will handle the simple move instead\r\n if (node && node.grid === this && !node._isExternal) return false;\r\n\r\n let wasAdded = !!this.placeholder.parentElement; // skip items not actually added to us because of constrains, but do cleanup #1419\r\n this.placeholder.remove();\r\n\r\n // notify previous grid of removal\r\n // TEST console.log('drop delete _gridstackNodeOrig')\r\n let origNode = el._gridstackNodeOrig;\r\n delete el._gridstackNodeOrig;\r\n if (wasAdded && origNode && origNode.grid && origNode.grid !== this) {\r\n let oGrid = origNode.grid;\r\n oGrid.engine.removedNodes.push(origNode);\r\n oGrid._triggerRemoveEvent();\r\n }\r\n\r\n if (!node) return false;\r\n\r\n // use existing placeholder node as it's already in our list with drop location\r\n if (wasAdded) {\r\n this.engine.cleanupNode(node); // removes all internal _xyz values\r\n node.grid = this;\r\n }\r\n GridStackDD.get().off(el, 'drag');\r\n // if we made a copy ('helper' which is temp) of the original node then insert a copy, else we move the original node (#1102)\r\n // as the helper will be nuked by jquery-ui otherwise\r\n if (helper !== el) {\r\n helper.remove();\r\n el.gridstackNode = origNode; // original item (left behind) is re-stored to pre dragging as the node now has drop info\r\n if (wasAdded) {\r\n el = el.cloneNode(true) as GridItemHTMLElement;\r\n }\r\n } else {\r\n el.remove(); // reduce flicker as we change depth here, and size further down\r\n GridStackDD.get().remove(el);\r\n }\r\n if (!wasAdded) return false;\r\n el.gridstackNode = node;\r\n node.el = el;\r\n // @ts-ignore\r\n Utils.copyPos(node, this._readAttr(this.placeholder)); // placeholder values as moving VERY fast can throw things off #1578\r\n Utils.removePositioningStyles(el);// @ts-ignore\r\n this._writeAttr(el, node);\r\n this.el.appendChild(el);// @ts-ignore\r\n this._updateContainerHeight();\r\n this.engine.addedNodes.push(node);// @ts-ignore\r\n this._triggerAddEvent();// @ts-ignore\r\n this._triggerChangeEvent();\r\n\r\n this.engine.endUpdate();\r\n if (this._gsEventHandler['dropped']) {\r\n this._gsEventHandler['dropped']({type: 'dropped'}, origNode && origNode.grid ? origNode : undefined, node);\r\n }\r\n\r\n // wait till we return out of the drag callback to set the new drag&resize handler or they may get messed up\r\n window.setTimeout(() => {\r\n // IFF we are still there (some application will use as placeholder and insert their real widget instead and better call makeWidget())\r\n if (node.el && node.el.parentElement) {\r\n this._prepareDragDropByNode(node);\r\n } else {\r\n this.engine.removeNode(node);\r\n }\r\n });\r\n\r\n return false; // prevent parent from receiving msg (which may be grid as well)\r\n });\r\n return this;\r\n}\r\n\r\n/** @internal mark item for removal */\r\nfunction _itemRemoving(el: GridItemHTMLElement, remove: boolean) {\r\n let node = el ? el.gridstackNode : undefined;\r\n if (!node || !node.grid) return;\r\n remove ? node._isAboutToRemove = true : delete node._isAboutToRemove;\r\n remove ? el.classList.add('grid-stack-item-removing') : el.classList.remove('grid-stack-item-removing');\r\n}\r\n\r\n/** @internal called to setup a trash drop zone if the user specifies it */\r\nGridStack.prototype._setupRemoveDrop = function(this: GridStack): GridStack {\r\n if (!this.opts.staticGrid && typeof this.opts.removable === 'string') {\r\n let trashEl = document.querySelector(this.opts.removable) as HTMLElement;\r\n if (!trashEl) return this;\r\n // only register ONE drop-over/dropout callback for the 'trash', and it will\r\n // update the passed in item and parent grid because the 'trash' is a shared resource anyway,\r\n // and Native DD only has 1 event CB (having a list and technically a per grid removableOptions complicates things greatly)\r\n if (!GridStackDD.get().isDroppable(trashEl)) {\r\n GridStackDD.get().droppable(trashEl, this.opts.removableOptions)\r\n .on(trashEl, 'dropover', (event, el) => _itemRemoving(el, true))\r\n .on(trashEl, 'dropout', (event, el) => _itemRemoving(el, false));\r\n }\r\n }\r\n return this;\r\n}\r\n\r\n/**\r\n * call to setup dragging in from the outside (say toolbar), by specifying the class selection and options.\r\n * Called during GridStack.init() as options, but can also be called directly (last param are cached) in case the toolbar\r\n * is dynamically create and needs to change later.\r\n **/\r\nGridStack.setupDragIn = function(this: GridStack, _dragIn?: string, _dragInOptions?: DDDragInOpt) {\r\n let dragIn: string;\r\n let dragInOptions: DDDragInOpt;\r\n const dragInDefaultOptions: DDDragInOpt = {\r\n revert: 'invalid',\r\n handle: '.grid-stack-item-content',\r\n scroll: false,\r\n appendTo: 'body'\r\n };\r\n\r\n // cache in the passed in values (form grid init?) so they don't have to resend them each time\r\n if (_dragIn) {\r\n dragIn = _dragIn;\r\n dragInOptions = {...dragInDefaultOptions, ...(_dragInOptions || {})};\r\n }\r\n if (typeof dragIn !== 'string') return;\r\n let dd = GridStackDD.get();\r\n Utils.getElements(dragIn).forEach(el => {\r\n if (!dd.isDraggable(el)) dd.dragIn(el, dragInOptions);\r\n });\r\n}\r\n\r\n/** @internal prepares the element for drag&drop **/\r\nGridStack.prototype._prepareDragDropByNode = function(this: GridStack, node: GridStackNode): GridStack {\r\n let el = node.el;\r\n let dd = GridStackDD.get();\r\n\r\n // check for disabled grid first\r\n if (this.opts.staticGrid || ((node.noMove || this.opts.disableDrag) && (node.noResize || this.opts.disableResize))) {\r\n if (node._initDD) {\r\n dd.remove(el); // nukes everything instead of just disable, will add some styles back next\r\n delete node._initDD;\r\n }\r\n el.classList.add('ui-draggable-disabled', 'ui-resizable-disabled'); // add styles one might depend on #1435\r\n return this;\r\n }\r\n\r\n if (!node._initDD) {\r\n // variables used/cashed between the 3 start/move/end methods, in addition to node passed above\r\n let cellWidth: number;\r\n let cellHeight: number;\r\n\r\n /** called when item starts moving/resizing */\r\n let onStartMoving = (event: Event, ui: DDUIData) => {\r\n // trigger any 'dragstart' / 'resizestart' manually\r\n if (this._gsEventHandler[event.type]) {\r\n this._gsEventHandler[event.type](event, event.target);\r\n }\r\n cellWidth = this.cellWidth();\r\n cellHeight = this.getCellHeight(true); // force pixels for calculations\r\n\r\n this._onStartMoving(el, event, ui, node, cellWidth, cellHeight);\r\n }\r\n\r\n /** called when item is being dragged/resized */\r\n let dragOrResize = (event: Event, ui: DDUIData) => {\r\n this._dragOrResize(el, event, ui, node, cellWidth, cellHeight);\r\n }\r\n\r\n /** called when the item stops moving/resizing */\r\n let onEndMoving = (event: Event) => {\r\n this.placeholder.remove();\r\n delete node._moving;\r\n delete node._lastTried;\r\n\r\n // if the item has moved to another grid, we're done here\r\n let target: GridItemHTMLElement = event.target as GridItemHTMLElement;\r\n if (!target.gridstackNode || target.gridstackNode.grid !== this) return;\r\n\r\n node.el = target;\r\n\r\n if (node._isAboutToRemove) {\r\n let gridToNotify = el.gridstackNode.grid;\r\n if (gridToNotify._gsEventHandler[event.type]) {\r\n gridToNotify._gsEventHandler[event.type](event, target);\r\n }\r\n dd.remove(el);\r\n gridToNotify.engine.removedNodes.push(node);\r\n gridToNotify._triggerRemoveEvent();\r\n // break circular links and remove DOM\r\n delete el.gridstackNode;\r\n delete node.el;\r\n el.remove();\r\n } else {\r\n if (!node._temporaryRemoved) {\r\n // move to new placeholder location\r\n Utils.removePositioningStyles(target);// @ts-ignore\r\n this._writePosAttr(target, node);\r\n } else {\r\n // got removed - restore item back to before dragging position\r\n Utils.removePositioningStyles(target);\r\n Utils.copyPos(node, node._orig);// @ts-ignore\r\n this._writePosAttr(target, node);\r\n this.engine.addNode(node);\r\n }\r\n if (this._gsEventHandler[event.type]) {\r\n this._gsEventHandler[event.type](event, target);\r\n }\r\n }\r\n // @ts-ignore\r\n this._extraDragRow = 0;// @ts-ignore\r\n this._updateContainerHeight();// @ts-ignore\r\n this._triggerChangeEvent();\r\n\r\n this.engine.endUpdate();\r\n }\r\n\r\n dd.draggable(el, {\r\n start: onStartMoving,\r\n stop: onEndMoving,\r\n drag: dragOrResize\r\n }).resizable(el, {\r\n start: onStartMoving,\r\n stop: onEndMoving,\r\n resize: dragOrResize\r\n });\r\n node._initDD = true; // we've set DD support now\r\n }\r\n\r\n // finally fine tune move vs resize by disabling any part...\r\n if (node.noMove || this.opts.disableDrag) {\r\n dd.draggable(el, 'disable');\r\n el.classList.add('ui-draggable-disabled');\r\n } else {\r\n dd.draggable(el, 'enable');\r\n el.classList.remove('ui-draggable-disabled');\r\n }\r\n if (node.noResize || this.opts.disableResize) {\r\n dd.resizable(el, 'disable');\r\n el.classList.add('ui-resizable-disabled');\r\n } else {\r\n dd.resizable(el, 'enable');\r\n el.classList.remove('ui-resizable-disabled');\r\n }\r\n\r\n return this;\r\n}\r\n\r\n/** @internal called when item is starting a drag/resize */\r\nGridStack.prototype._onStartMoving = function(this: GridStack, el: GridItemHTMLElement, event: Event, ui: DDUIData, node: GridStackNode, cellWidth: number, cellHeight: number) {\r\n this.engine.cleanNodes()\r\n .beginUpdate(node);\r\n // @ts-ignore\r\n this._writePosAttr(this.placeholder, node)\r\n this.el.appendChild(this.placeholder);\r\n // TEST console.log('_onStartMoving placeholder')\r\n\r\n node.el = this.placeholder;\r\n node._lastUiPosition = ui.position;\r\n node._prevYPix = ui.position.top;\r\n node._moving = (event.type === 'dragstart'); // 'dropover' are not initially moving so they can go exactly where they enter (will push stuff out of the way)\r\n delete node._lastTried;\r\n\r\n if (event.type === 'dropover' && node._temporaryRemoved) {\r\n // TEST console.log('engine.addNode x=' + node.x);\r\n this.engine.addNode(node); // will add, fix collisions, update attr and clear _temporaryRemoved\r\n node._moving = true; // AFTER, mark as moving object (wanted fix location before)\r\n }\r\n\r\n // set the min/max resize info\r\n this.engine.cacheRects(cellWidth, cellHeight, this.opts.marginTop as number, this.opts.marginRight as number, this.opts.marginBottom as number, this.opts.marginLeft as number);\r\n if (event.type === 'resizestart') {\r\n let dd = GridStackDD.get()\r\n .resizable(el, 'option', 'minWidth', cellWidth * (node.minW || 1))\r\n .resizable(el, 'option', 'minHeight', cellHeight * (node.minH || 1));\r\n if (node.maxW) { dd.resizable(el, 'option', 'maxWidth', cellWidth * node.maxW); }\r\n if (node.maxH) { dd.resizable(el, 'option', 'maxHeight', cellHeight * node.maxH); }\r\n }\r\n}\r\n\r\n/** @internal called when item leaving our area by either cursor dropout event\r\n * or shape is outside our boundaries. remove it from us, and mark temporary if this was\r\n * our item to start with else restore prev node values from prev grid it came from.\r\n **/\r\nGridStack.prototype._leave = function(this: GridStack, el: GridItemHTMLElement, helper?: GridItemHTMLElement) {\r\n let node = el.gridstackNode;\r\n if (!node) return;\r\n\r\n GridStackDD.get().off(el, 'drag'); // no need to track while being outside\r\n\r\n // this gets called when cursor leaves and shape is outside, so only do this once\r\n if (node._temporaryRemoved) return;\r\n node._temporaryRemoved = true;\r\n\r\n this.engine.removeNode(node); // remove placeholder as well, otherwise it's a sign node is not in our list, which is a bigger issue\r\n node.el = node._isExternal && helper ? helper : el; // point back to real item being dragged\r\n\r\n if (this.opts.removable === true) { // boolean vs a class string\r\n // item leaving us and we are supposed to remove on leave (no need to drag onto trash) mark it so\r\n _itemRemoving(el, true);\r\n }\r\n\r\n // finally if item originally came from another grid, but left us, restore things back to prev info\r\n if (el._gridstackNodeOrig) {\r\n // TEST console.log('leave delete _gridstackNodeOrig')\r\n el.gridstackNode = el._gridstackNodeOrig;\r\n delete el._gridstackNodeOrig;\r\n } else if (node._isExternal) {\r\n // item came from outside (like a toolbar) so nuke any node info\r\n delete node.el;\r\n delete el.gridstackNode;\r\n // and restore all nodes back to original\r\n this.engine.restoreInitial();\r\n }\r\n}\r\n\r\n/** @internal called when item is being dragged/resized */\r\nGridStack.prototype._dragOrResize = function(this: GridStack, el: GridItemHTMLElement, event: Event, ui: DDUIData, node: GridStackNode, cellWidth: number, cellHeight: number) {\r\n let p = {...node._orig}; // could be undefined (_isExternal) which is ok (drag only set x,y and w,h will default to node value)\r\n let resizing: boolean;\r\n const mLeft = this.opts.marginLeft as number,\r\n mRight = this.opts.marginRight as number,\r\n mTop = this.opts.marginTop as number,\r\n mBottom = this.opts.marginBottom as number;\r\n\r\n if (event.type === 'drag') {\r\n if (node._temporaryRemoved) return; // handled by dropover\r\n let distance = ui.position.top - node._prevYPix;\r\n node._prevYPix = ui.position.top;\r\n Utils.updateScrollPosition(el, ui.position, distance);\r\n\r\n // get new position taking into account the margin in the direction we are moving! (need to pass mid point by margin)\r\n let left = ui.position.left + (ui.position.left > node._lastUiPosition.left ? -mRight : mLeft);\r\n let top = ui.position.top + (ui.position.top > node._lastUiPosition.top ? -mBottom : mTop);\r\n p.x = Math.round(left / cellWidth);\r\n p.y = Math.round(top / cellHeight);\r\n\r\n // @ts-ignore// if we're at the bottom hitting something else, grow the grid so cursor doesn't leave when trying to place below others\r\n let prev = this._extraDragRow;\r\n if (this.engine.collide(node, p)) {\r\n let row = this.getRow();\r\n let extra = Math.max(0, (p.y + node.h) - row);\r\n if (this.opts.maxRow && row + extra > this.opts.maxRow) {\r\n extra = Math.max(0, this.opts.maxRow - row);\r\n }// @ts-ignore\r\n this._extraDragRow = extra;// @ts-ignore\r\n } else this._extraDragRow = 0;// @ts-ignore\r\n if (this._extraDragRow !== prev) this._updateContainerHeight();\r\n\r\n if (node.x === p.x && node.y === p.y) return; // skip same\r\n // DON'T skip one we tried as we might have failed because of coverage <50% before\r\n // if (node._lastTried && node._lastTried.x === x && node._lastTried.y === y) return;\r\n } else if (event.type === 'resize') {\r\n if (p.x < 0) return;\r\n // Scrolling page if needed\r\n Utils.updateScrollResize(event as MouseEvent, el, cellHeight);\r\n\r\n // get new size\r\n p.w = Math.round((ui.size.width - mLeft) / cellWidth);\r\n p.h = Math.round((ui.size.height - mTop) / cellHeight);\r\n if (node.w === p.w && node.h === p.h) return;\r\n if (node._lastTried && node._lastTried.w === p.w && node._lastTried.h === p.h) return; // skip one we tried (but failed)\r\n\r\n // if we size on left/top side this might move us, so get possible new position as well\r\n let left = ui.position.left + mLeft;\r\n let top = ui.position.top + mTop;\r\n p.x = Math.round(left / cellWidth);\r\n p.y = Math.round(top / cellHeight);\r\n\r\n resizing = true;\r\n }\r\n\r\n node._lastTried = p; // set as last tried (will nuke if we go there)\r\n let rect: GridStackPosition = { // screen pix of the dragged box\r\n x: ui.position.left + mLeft,\r\n y: ui.position.top + mTop,\r\n w: (ui.size ? ui.size.width : node.w * cellWidth) - mLeft - mRight,\r\n h: (ui.size ? ui.size.height : node.h * cellHeight) - mTop - mBottom\r\n };\r\n if (this.engine.moveNodeCheck(node, {...p, cellWidth, cellHeight, rect})) {\r\n node._lastUiPosition = ui.position;\r\n this.engine.cacheRects(cellWidth, cellHeight, mTop, mRight, mBottom, mLeft);\r\n delete node._skipDown;\r\n if (resizing && node.subGrid) { (node.subGrid as GridStack).onParentResize(); }// @ts-ignore\r\n this._extraDragRow = 0;// @ts-ignore\r\n this._updateContainerHeight();\r\n\r\n let target = event.target as GridItemHTMLElement;// @ts-ignore\r\n this._writePosAttr(target, node);\r\n if (this._gsEventHandler[event.type]) {\r\n this._gsEventHandler[event.type](event, target);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Enables/Disables moving.\r\n * @param els widget or selector to modify.\r\n * @param val if true widget will be draggable.\r\n */\r\nGridStack.prototype.movable = function(this: GridStack, els: GridStackElement, val: boolean): GridStack {\r\n if (this.opts.staticGrid) return this; // can't move a static grid!\r\n GridStack.getElements(els).forEach(el => {\r\n let node = el.gridstackNode;\r\n if (!node) return;\r\n if (val) delete node.noMove; else node.noMove = true;\r\n this._prepareDragDropByNode(node); // init DD if need be, and adjust\r\n });\r\n return this;\r\n}\r\n\r\n/**\r\n * Enables/Disables resizing.\r\n * @param els widget or selector to modify\r\n * @param val if true widget will be resizable.\r\n */\r\nGridStack.prototype.resizable = function(this: GridStack, els: GridStackElement, val: boolean): GridStack {\r\n if (this.opts.staticGrid) return this; // can't resize a static grid!\r\n GridStack.getElements(els).forEach(el => {\r\n let node = el.gridstackNode;\r\n if (!node) return;\r\n if (val) delete node.noResize; else node.noResize = true;\r\n this._prepareDragDropByNode(node); // init DD if need be, and adjust\r\n });\r\n return this;\r\n}\r\n\r\n\r\n/**\r\n * Temporarily disables widgets moving/resizing.\r\n * If you want a more permanent way (which freezes up resources) use `setStatic(true)` instead.\r\n * Note: no-op for static grid\r\n * This is a shortcut for:\r\n * @example\r\n * grid.enableMove(false);\r\n * grid.enableResize(false);\r\n */\r\nGridStack.prototype.disable = function(this: GridStack): GridStack {\r\n if (this.opts.staticGrid) return;\r\n this.enableMove(false);\r\n this.enableResize(false);// @ts-ignore\r\n this._triggerEvent('disable');\r\n return this;\r\n}\r\n\r\n/**\r\n * Re-enables widgets moving/resizing - see disable().\r\n * Note: no-op for static grid.\r\n * This is a shortcut for:\r\n * @example\r\n * grid.enableMove(true);\r\n * grid.enableResize(true);\r\n */\r\nGridStack.prototype.enable = function(this: GridStack): GridStack {\r\n if (this.opts.staticGrid) return;\r\n this.enableMove(true);\r\n this.enableResize(true);// @ts-ignore\r\n this._triggerEvent('enable');\r\n return this;\r\n}\r\n\r\n/** Enables/disables widget moving. No-op for static grids. */\r\nGridStack.prototype.enableMove = function(this: GridStack, doEnable: boolean): GridStack {\r\n if (this.opts.staticGrid) return this; // can't move a static grid!\r\n this.opts.disableDrag = !doEnable; // FIRST before we update children as grid overrides #1658\r\n this.engine.nodes.forEach(n => this.movable(n.el, doEnable));\r\n return this;\r\n}\r\n\r\n/** Enables/disables widget resizing. No-op for static grids. */\r\nGridStack.prototype.enableResize = function(this: GridStack, doEnable: boolean): GridStack {\r\n if (this.opts.staticGrid) return this; // can't size a static grid!\r\n this.opts.disableResize = !doEnable; // FIRST before we update children as grid overrides #1658\r\n this.engine.nodes.forEach(n => this.resizable(n.el, doEnable));\r\n return this;\r\n}\r\n","/**\r\n * gridstack-ddi.ts 4.2.6\r\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\r\n */\r\n\r\nimport { GridItemHTMLElement } from './types';\r\n\r\n/**\r\n * Abstract Partial Interface API for drag'n'drop plugin - look at GridStackDD and HTML5 / Jquery implementation versions\r\n */\r\nexport class GridStackDDI {\r\n\r\n protected static ddi: GridStackDDI;\r\n\r\n /** call this method to register your plugin instead of the default no-op one */\r\n static registerPlugin(pluginClass: typeof GridStackDDI): GridStackDDI {\r\n GridStackDDI.ddi = new pluginClass();\r\n return GridStackDDI.ddi;\r\n }\r\n\r\n /** get the current registered plugin to use */\r\n static get(): GridStackDDI {\r\n return GridStackDDI.ddi || GridStackDDI.registerPlugin(GridStackDDI);\r\n }\r\n\r\n /** removes any drag&drop present (called during destroy) */\r\n /* eslint-disable-next-line @typescript-eslint/no-unused-vars */\r\n public remove(el: GridItemHTMLElement): GridStackDDI {\r\n return this; // no-op for static grids\r\n }\r\n}\r\n","/**\r\n * gridstack-engine.ts 4.2.6\r\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\r\n */\r\n\r\nimport { Utils } from './utils';\r\nimport { GridStackNode, ColumnOptions, GridStackPosition, GridStackMoveOpts } from './types';\r\n\r\nexport type onChangeCB = (nodes: GridStackNode[], removeDOM?: boolean) => void;\r\n/** options used for creations - similar to GridStackOptions */\r\nexport interface GridStackEngineOptions {\r\n column?: number;\r\n maxRow?: number;\r\n float?: boolean;\r\n nodes?: GridStackNode[];\r\n onChange?: onChangeCB;\r\n}\r\n\r\n/**\r\n * Defines the GridStack engine that does most no DOM grid manipulation.\r\n * See GridStack methods and vars for descriptions.\r\n *\r\n * NOTE: values should not be modified directly - call the main GridStack API instead\r\n */\r\nexport class GridStackEngine {\r\n public column: number;\r\n public maxRow: number;\r\n public nodes: GridStackNode[];\r\n public onChange: onChangeCB;\r\n public addedNodes: GridStackNode[] = [];\r\n public removedNodes: GridStackNode[] = [];\r\n public batchMode: boolean;\r\n /** @internal */\r\n private _float: boolean;\r\n /** @internal */\r\n private _prevFloat: boolean;\r\n /** @internal */\r\n private _layouts?: Layout[][]; // maps column # to array of values nodes\r\n /** @internal */\r\n private _ignoreLayoutsNodeChange: boolean;\r\n /** @internal true if we have some items locked */\r\n private _hasLocked: boolean;\r\n /** @internal unique global internal _id counter NOT starting at 0 */\r\n private static _idSeq = 1;\r\n\r\n public constructor(opts: GridStackEngineOptions = {}) {\r\n this.column = opts.column || 12;\r\n this.onChange = opts.onChange;\r\n this._float = opts.float;\r\n this.maxRow = opts.maxRow;\r\n this.nodes = opts.nodes || [];\r\n }\r\n\r\n public batchUpdate(): GridStackEngine {\r\n if (this.batchMode) return this;\r\n this.batchMode = true;\r\n this._prevFloat = this._float;\r\n this._float = true; // let things go anywhere for now... commit() will restore and possibly reposition\r\n this.saveInitial(); // since begin update (which is called multiple times) won't do this\r\n return this;\r\n }\r\n\r\n public commit(): GridStackEngine {\r\n if (!this.batchMode) return this;\r\n this.batchMode = false;\r\n this._float = this._prevFloat;\r\n delete this._prevFloat;\r\n return this._packNodes()\r\n ._notify();\r\n }\r\n\r\n // use entire row for hitting area (will use bottom reverse sorted first) if we not actively moving DOWN and didn't already skip\r\n private _useEntireRowArea(node: GridStackNode, nn: GridStackPosition): boolean {\r\n return !this.float && !this._hasLocked && (!node._moving || node._skipDown || nn.y <= node.y);\r\n }\r\n\r\n /** @internal fix collision on given 'node', going to given new location 'nn', with optional 'collide' node already found.\r\n * return true if we moved. */\r\n private _fixCollisions(node: GridStackNode, nn = node, collide?: GridStackNode, opt: GridStackMoveOpts = {}): boolean {\r\n this._sortNodes(-1); // from last to first, so recursive collision move items in the right order\r\n\r\n collide = collide || this.collide(node, nn); // REAL area collide for swap and skip if none...\r\n if (!collide) return false;\r\n\r\n // swap check: if we're actively moving in gravity mode, see if we collide with an object the same size\r\n if (node._moving && !opt.nested && !this.float) {\r\n if (this.swap(node, collide)) return true;\r\n }\r\n\r\n // during while() collisions MAKE SURE to check entire row so larger items don't leap frog small ones (push them all down starting last in grid)\r\n let area = nn;\r\n if (this._useEntireRowArea(node, nn)) {\r\n area = {x: 0, w: this.column, y: nn.y, h: nn.h};\r\n collide = this.collide(node, area, opt.skip); // force new hit\r\n }\r\n\r\n let didMove = false;\r\n let newOpt: GridStackMoveOpts = {nested: true, pack: false};\r\n while (collide = collide || this.collide(node, area, opt.skip)) { // could collide with more than 1 item... so repeat for each\r\n let moved: boolean;\r\n // if colliding with a locked item OR moving down with top gravity (and collide could move up) -> skip past the collide,\r\n // but remember that skip down so we only do this once (and push others otherwise).\r\n if (collide.locked || node._moving && !node._skipDown && nn.y > node.y && !this.float &&\r\n // can take space we had, or before where we're going\r\n (!this.collide(collide, {...collide, y: node.y}, node) || !this.collide(collide, {...collide, y: nn.y - collide.h}, node))) {\r\n node._skipDown = (node._skipDown || nn.y > node.y);\r\n moved = this.moveNode(node, {...nn, y: collide.y + collide.h, ...newOpt});\r\n if (collide.locked && moved) {\r\n Utils.copyPos(nn, node); // moving after lock become our new desired location\r\n } else if (!collide.locked && moved && opt.pack) {\r\n // we moved after and will pack: do it now and keep the original drop location, but past the old collide to see what else we might push way\r\n this._packNodes();\r\n nn.y = collide.y + collide.h;\r\n Utils.copyPos(node, nn);\r\n }\r\n didMove = didMove || moved;\r\n } else {\r\n // move collide down *after* where we will be, ignoring where we are now (don't collide with us)\r\n moved = this.moveNode(collide, {...collide, y: nn.y + nn.h, skip: node, ...newOpt});\r\n }\r\n if (!moved) { return didMove; } // break inf loop if we couldn't move after all (ex: maxRow, fixed)\r\n collide = undefined;\r\n }\r\n return didMove;\r\n }\r\n\r\n /** return the nodes that intercept the given node. Optionally a different area can be used, as well as a second node to skip */\r\n public collide(skip: GridStackNode, area = skip, skip2?: GridStackNode): GridStackNode {\r\n return this.nodes.find(n => n !== skip && n !== skip2 && Utils.isIntercepted(n, area));\r\n }\r\n public collideAll(skip: GridStackNode, area = skip, skip2?: GridStackNode): GridStackNode[] {\r\n return this.nodes.filter(n => n !== skip && n !== skip2 && Utils.isIntercepted(n, area));\r\n }\r\n\r\n /** does a pixel coverage collision, returning the node that has the most coverage that is >50% mid line */\r\n public collideCoverage(node: GridStackNode, o: GridStackMoveOpts, collides: GridStackNode[]): GridStackNode {\r\n if (!o.rect || !node._rect) return;\r\n let r0 = node._rect; // where started\r\n let r = {...o.rect}; // where we are\r\n\r\n // update dragged rect to show where it's coming from (above or below, etc...)\r\n if (r.y > r0.y) {\r\n r.h += r.y - r0.y;\r\n r.y = r0.y;\r\n } else {\r\n r.h += r0.y - r.y;\r\n }\r\n if (r.x > r0.x) {\r\n r.w += r.x - r0.x;\r\n r.x = r0.x;\r\n } else {\r\n r.w += r0.x - r.x;\r\n }\r\n\r\n let collide: GridStackNode;\r\n collides.forEach(n => {\r\n if (n.locked || !n._rect) return;\r\n let r2 = n._rect; // overlapping target\r\n let yOver = Number.MAX_VALUE, xOver = Number.MAX_VALUE, overMax = 0.5; // need >50%\r\n // depending on which side we started from, compute the overlap % of coverage\r\n // (ex: from above/below we only compute the max horizontal line coverage)\r\n if (r0.y < r2.y) { // from above\r\n yOver = ((r.y + r.h) - r2.y) / r2.h;\r\n } else if (r0.y+r0.h > r2.y+r2.h) { // from below\r\n yOver = ((r2.y + r2.h) - r.y) / r2.h;\r\n }\r\n if (r0.x < r2.x) { // from the left\r\n xOver = ((r.x + r.w) - r2.x) / r2.w;\r\n } else if (r0.x+r0.w > r2.x+r2.w) { // from the right\r\n xOver = ((r2.x + r2.w) - r.x) / r2.w;\r\n }\r\n let over = Math.min(xOver, yOver);\r\n if (over > overMax) {\r\n overMax = over;\r\n collide = n;\r\n }\r\n });\r\n return collide;\r\n }\r\n\r\n /** called to cache the nodes pixel rectangles used for collision detection during drag */\r\n public cacheRects(w: number, h: number, top: number, right: number, bottom: number, left: number): GridStackEngine\r\n {\r\n this.nodes.forEach(n =>\r\n n._rect = {\r\n y: n.y * h + top,\r\n x: n.x * w + left,\r\n w: n.w * w - left - right,\r\n h: n.h * h - top - bottom\r\n }\r\n );\r\n return this;\r\n }\r\n\r\n /** called to possibly swap between 2 nodes (same size or column, not locked, touching), returning true if successful */\r\n public swap(a: GridStackNode, b: GridStackNode): boolean {\r\n if (!b || b.locked || !a || a.locked) return false;\r\n\r\n function _doSwap(): true { // assumes a is before b IFF they have different height (put after rather than exact swap)\r\n let x = b.x, y = b.y;\r\n b.x = a.x; b.y = a.y; // b -> a position\r\n if (a.h != b.h) {\r\n a.x = x; a.y = b.y + b.h; // a -> goes after b\r\n } else {\r\n a.x = x; a.y = y; // a -> old b position\r\n }\r\n a._dirty = b._dirty = true;\r\n return true;\r\n }\r\n let touching: boolean; // remember if we called it (vs undefined)\r\n\r\n // same size and same row or column, and touching\r\n if (a.w === b.w && a.h === b.h && (a.x === b.x || a.y === b.y) && (touching = Utils.isTouching(a, b)))\r\n return _doSwap();\r\n if (touching === false) return; // ran test and fail, bail out\r\n\r\n // check for taking same columns (but different height) and touching\r\n if (a.w === b.w && a.x === b.x && (touching || Utils.isTouching(a, b))) {\r\n if (b.y < a.y) { let t = a; a = b; b = t; } // swap a <-> b vars so a is first\r\n return _doSwap();\r\n }\r\n\r\n /* different X will be weird (expect vertical swap) and different height overlap, so too complex. user regular layout instead\r\n // else check if swapping would not collide with anything else (requiring a re-layout)\r\n if (!this.collide(a, {x: a.x, y: a.y, w: b.w, h: b.h}, b) &&\r\n !this.collide(a, {x: b.x, y: b.y, w: a.w, h: a.h}, b))\r\n return _doSwap(); */\r\n return false;\r\n }\r\n\r\n public isAreaEmpty(x: number, y: number, w: number, h: number): boolean {\r\n let nn: GridStackNode = {x: x || 0, y: y || 0, w: w || 1, h: h || 1};\r\n return !this.collide(nn);\r\n }\r\n\r\n /** re-layout grid items to reclaim any empty space */\r\n public compact(): GridStackEngine {\r\n if (this.nodes.length === 0) return this;\r\n this.batchUpdate()\r\n ._sortNodes();\r\n let copyNodes = this.nodes;\r\n this.nodes = []; // pretend we have no nodes to conflict layout to start with...\r\n copyNodes.forEach(node => {\r\n if (!node.locked) {\r\n node.autoPosition = true;\r\n }\r\n this.addNode(node, false); // 'false' for add event trigger\r\n node._dirty = true; // will force attr update\r\n });\r\n return this.commit();\r\n }\r\n\r\n /** enable/disable floating widgets (default: `false`) See [example](http://gridstackjs.com/demo/float.html) */\r\n public set float(val: boolean) {\r\n if (this._float === val) return;\r\n this._float = val || false;\r\n if (!val) {\r\n this._packNodes()._notify();\r\n }\r\n }\r\n\r\n /** float getter method */\r\n public get float(): boolean { return this._float || false; }\r\n\r\n /** @internal */\r\n private _sortNodes(dir?: -1 | 1): GridStackEngine {\r\n this.nodes = Utils.sort(this.nodes, dir, this.column);\r\n return this;\r\n }\r\n\r\n /** @internal called to top gravity pack the items back OR revert back to original Y positions when floating */\r\n private _packNodes(): GridStackEngine {\r\n this._sortNodes(); // first to last\r\n\r\n if (this.float) {\r\n // restore original Y pos\r\n this.nodes.forEach(n => {\r\n if (n._updating || n._orig === undefined || n.y === n._orig.y) return;\r\n let newY = n.y;\r\n while (newY > n._orig.y) {\r\n --newY;\r\n let collide = this.collide(n, {x: n.x, y: newY, w: n.w, h: n.h});\r\n if (!collide) {\r\n n._dirty = true;\r\n n.y = newY;\r\n }\r\n }\r\n });\r\n } else {\r\n // top gravity pack\r\n this.nodes.forEach((n, i) => {\r\n if (n.locked) return;\r\n while (n.y > 0) {\r\n let newY = i === 0 ? 0 : n.y - 1;\r\n let canBeMoved = i === 0 || !this.collide(n, {x: n.x, y: newY, w: n.w, h: n.h});\r\n if (!canBeMoved) break;\r\n // Note: must be dirty (from last position) for GridStack::OnChange CB to update positions\r\n // and move items back. The user 'change' CB should detect changes from the original\r\n // starting position instead.\r\n n._dirty = (n.y !== newY);\r\n n.y = newY;\r\n }\r\n });\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * given a random node, makes sure it's coordinates/values are valid in the current grid\r\n * @param node to adjust\r\n * @param resizing if out of bound, resize down or move into the grid to fit ?\r\n */\r\n public prepareNode(node: GridStackNode, resizing?: boolean): GridStackNode {\r\n node = node || {};\r\n node._id = node._id || GridStackEngine._idSeq++;\r\n\r\n // if we're missing position, have the grid position us automatically (before we set them to 0,0)\r\n if (node.x === undefined || node.y === undefined || node.x === null || node.y === null) {\r\n node.autoPosition = true;\r\n }\r\n\r\n // assign defaults for missing required fields\r\n let defaults: GridStackNode = { x: 0, y: 0, w: 1, h: 1};\r\n Utils.defaults(node, defaults);\r\n\r\n if (!node.autoPosition) { delete node.autoPosition; }\r\n if (!node.noResize) { delete node.noResize; }\r\n if (!node.noMove) { delete node.noMove; }\r\n\r\n // check for NaN (in case messed up strings were passed. can't do parseInt() || defaults.x above as 0 is valid #)\r\n if (typeof node.x == 'string') { node.x = Number(node.x); }\r\n if (typeof node.y == 'string') { node.y = Number(node.y); }\r\n if (typeof node.w == 'string') { node.w = Number(node.w); }\r\n if (typeof node.h == 'string') { node.h = Number(node.h); }\r\n if (isNaN(node.x)) { node.x = defaults.x; node.autoPosition = true; }\r\n if (isNaN(node.y)) { node.y = defaults.y; node.autoPosition = true; }\r\n if (isNaN(node.w)) { node.w = defaults.w; }\r\n if (isNaN(node.h)) { node.h = defaults.h; }\r\n\r\n return this.nodeBoundFix(node, resizing);\r\n }\r\n\r\n /** part2 of preparing a node to fit inside our grid - checks for x,y from grid dimensions */\r\n public nodeBoundFix(node: GridStackNode, resizing?: boolean): GridStackNode {\r\n\r\n if (node.maxW) { node.w = Math.min(node.w, node.maxW); }\r\n if (node.maxH) { node.h = Math.min(node.h, node.maxH); }\r\n if (node.minW) { node.w = Math.max(node.w, node.minW); }\r\n if (node.minH) { node.h = Math.max(node.h, node.minH); }\r\n\r\n if (node.w > this.column) {\r\n // if user loaded a larger than allowed widget for current # of columns,\r\n // remember it's full width so we can restore back (1 -> 12 column) #1655\r\n if (this.column < 12) {\r\n node.w = Math.min(12, node.w);\r\n this.cacheOneLayout(node, 12);\r\n }\r\n node.w = this.column;\r\n } else if (node.w < 1) {\r\n node.w = 1;\r\n }\r\n\r\n if (this.maxRow && node.h > this.maxRow) {\r\n node.h = this.maxRow;\r\n } else if (node.h < 1) {\r\n node.h = 1;\r\n }\r\n\r\n if (node.x < 0) {\r\n node.x = 0;\r\n }\r\n if (node.y < 0) {\r\n node.y = 0;\r\n }\r\n\r\n if (node.x + node.w > this.column) {\r\n if (resizing) {\r\n node.w = this.column - node.x;\r\n } else {\r\n node.x = this.column - node.w;\r\n }\r\n }\r\n if (this.maxRow && node.y + node.h > this.maxRow) {\r\n if (resizing) {\r\n node.h = this.maxRow - node.y;\r\n } else {\r\n node.y = this.maxRow - node.h;\r\n }\r\n }\r\n\r\n return node;\r\n }\r\n\r\n public getDirtyNodes(verify?: boolean): GridStackNode[] {\r\n // compare original x,y,w,h instead as _dirty can be a temporary state\r\n if (verify) {\r\n return this.nodes.filter(n => n._dirty && !Utils.samePos(n, n._orig));\r\n }\r\n return this.nodes.filter(n => n._dirty);\r\n }\r\n\r\n /** @internal call this to call onChange CB with dirty nodes */\r\n private _notify(nodes?: GridStackNode | GridStackNode[], removeDOM = true): GridStackEngine {\r\n if (this.batchMode) return this;\r\n nodes = (nodes === undefined ? [] : (Array.isArray(nodes) ? nodes : [nodes]) );\r\n let dirtyNodes = nodes.concat(this.getDirtyNodes());\r\n this.onChange && this.onChange(dirtyNodes, removeDOM);\r\n return this;\r\n }\r\n\r\n /** @internal remove dirty and last tried info */\r\n public cleanNodes(): GridStackEngine {\r\n if (this.batchMode) return this;\r\n this.nodes.forEach(n => {\r\n delete n._dirty;\r\n delete n._lastTried;\r\n });\r\n return this;\r\n }\r\n\r\n /** @internal called to save initial position/size to track real dirty state.\r\n * Note: should be called right after we call change event (so next API is can detect changes)\r\n * as well as right before we start move/resize/enter (so we can restore items to prev values) */\r\n public saveInitial(): GridStackEngine {\r\n this.nodes.forEach(n => {\r\n n._orig = Utils.copyPos({}, n);\r\n delete n._dirty;\r\n });\r\n this._hasLocked = this.nodes.some(n => n.locked);\r\n return this;\r\n }\r\n\r\n /** @internal restore all the nodes back to initial values (called when we leave) */\r\n public restoreInitial(): GridStackEngine {\r\n this.nodes.forEach(n => {\r\n if (Utils.samePos(n, n._orig)) return;\r\n Utils.copyPos(n, n._orig);\r\n n._dirty = true;\r\n });\r\n this._notify();\r\n return this;\r\n }\r\n\r\n /** call to add the given node to our list, fixing collision and re-packing */\r\n public addNode(node: GridStackNode, triggerAddEvent = false): GridStackNode {\r\n let dup: GridStackNode;\r\n if (dup = this.nodes.find(n => n._id === node._id)) return dup; // prevent inserting twice! return it instead.\r\n\r\n node = this.prepareNode(node);\r\n delete node._temporaryRemoved;\r\n delete node._removeDOM;\r\n\r\n if (node.autoPosition) {\r\n this._sortNodes();\r\n\r\n for (let i = 0;; ++i) {\r\n let x = i % this.column;\r\n let y = Math.floor(i / this.column);\r\n if (x + node.w > this.column) {\r\n continue;\r\n }\r\n let box = {x, y, w: node.w, h: node.h};\r\n if (!this.nodes.find(n => Utils.isIntercepted(box, n))) {\r\n node.x = x;\r\n node.y = y;\r\n delete node.autoPosition; // found our slot\r\n break;\r\n }\r\n }\r\n }\r\n\r\n this.nodes.push(node);\r\n triggerAddEvent && this.addedNodes.push(node);\r\n\r\n this._fixCollisions(node);\r\n this._packNodes()\r\n ._notify();\r\n return node;\r\n }\r\n\r\n public removeNode(node: GridStackNode, removeDOM = true, triggerEvent = false): GridStackEngine {\r\n if (!this.nodes.find(n => n === node)) {\r\n // TEST console.log(`Error: GridStackEngine.removeNode() node._id=${node._id} not found!`)\r\n return this;\r\n }\r\n if (triggerEvent) { // we wait until final drop to manually track removed items (rather than during drag)\r\n this.removedNodes.push(node);\r\n }\r\n if (removeDOM) node._removeDOM = true; // let CB remove actual HTML (used to set _id to null, but then we loose layout info)\r\n // don't use 'faster' .splice(findIndex(),1) in case node isn't in our list, or in multiple times.\r\n this.nodes = this.nodes.filter(n => n !== node);\r\n return this._packNodes()\r\n ._notify(node);\r\n }\r\n\r\n public removeAll(removeDOM = true): GridStackEngine {\r\n delete this._layouts;\r\n if (this.nodes.length === 0) return this;\r\n removeDOM && this.nodes.forEach(n => n._removeDOM = true); // let CB remove actual HTML (used to set _id to null, but then we loose layout info)\r\n this.removedNodes = this.nodes;\r\n this.nodes = [];\r\n return this._notify(this.removedNodes);\r\n }\r\n\r\n /** checks if item can be moved (layout constrain) vs moveNode(), returning true if was able to move.\r\n * In more complicated cases (maxRow) it will attempt at moving the item and fixing\r\n * others in a clone first, then apply those changes if still within specs. */\r\n public moveNodeCheck(node: GridStackNode, o: GridStackMoveOpts): boolean {\r\n // if (node.locked) return false;\r\n if (!this.changedPosConstrain(node, o)) return false;\r\n o.pack = true;\r\n\r\n // simpler case: move item directly...\r\n if (!this.maxRow/* && !this._hasLocked*/) {\r\n return this.moveNode(node, o);\r\n }\r\n\r\n // complex case: create a clone with NO maxRow (will check for out of bounds at the end)\r\n let clonedNode: GridStackNode;\r\n let clone = new GridStackEngine({\r\n column: this.column,\r\n float: this.float,\r\n nodes: this.nodes.map(n => {\r\n if (n === node) {\r\n clonedNode = {...n};\r\n return clonedNode;\r\n }\r\n return {...n};\r\n })\r\n });\r\n if (!clonedNode) return false;\r\n\r\n let canMove = clone.moveNode(clonedNode, o);\r\n // if maxRow make sure we are still valid size\r\n if (this.maxRow && canMove) {\r\n canMove = (clone.getRow() <= this.maxRow);\r\n // turns out we can't grow, then see if we can swap instead (ex: full grid)\r\n if (!canMove) {\r\n let collide = this.collide(node, o);\r\n if (collide && this.swap(node, collide)) {\r\n this._notify();\r\n return true;\r\n }\r\n }\r\n }\r\n if (!canMove) return false;\r\n\r\n // if clone was able to move, copy those mods over to us now instead of caller trying to do this all over!\r\n // Note: we can't use the list directly as elements and other parts point to actual node, so copy content\r\n clone.nodes.filter(n => n._dirty).forEach(c => {\r\n let n = this.nodes.find(a => a._id === c._id);\r\n if (!n) return;\r\n Utils.copyPos(n, c);\r\n n._dirty = true;\r\n });\r\n this._notify();\r\n return true;\r\n }\r\n\r\n /** return true if can fit in grid height constrain only (always true if no maxRow) */\r\n public willItFit(node: GridStackNode): boolean {\r\n delete node._willFitPos;\r\n if (!this.maxRow) return true;\r\n // create a clone with NO maxRow and check if still within size\r\n let clone = new GridStackEngine({\r\n column: this.column,\r\n float: this.float,\r\n nodes: this.nodes.map(n => {return {...n}})\r\n });\r\n let n = {...node}; // clone node so we don't mod any settings on it but have full autoPosition and min/max as well! #1687\r\n this.cleanupNode(n);\r\n delete n.el; delete n._id; delete n.content; delete n.grid;\r\n clone.addNode(n);\r\n if (clone.getRow() <= this.maxRow) {\r\n node._willFitPos = Utils.copyPos({}, n);\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /** true if x,y or w,h are different after clamping to min/max */\r\n public changedPosConstrain(node: GridStackNode, p: GridStackPosition): boolean {\r\n // make sure w,h are set\r\n p.w = p.w || node.w;\r\n p.h = p.h || node.h;\r\n if (node.x !== p.x || node.y !== p.y) return true;\r\n // check constrained w,h\r\n if (node.maxW) { p.w = Math.min(p.w, node.maxW); }\r\n if (node.maxH) { p.h = Math.min(p.h, node.maxH); }\r\n if (node.minW) { p.w = Math.max(p.w, node.minW); }\r\n if (node.minH) { p.h = Math.max(p.h, node.minH); }\r\n return (node.w !== p.w || node.h !== p.h);\r\n }\r\n\r\n /** return true if the passed in node was actually moved (checks for no-op and locked) */\r\n public moveNode(node: GridStackNode, o: GridStackMoveOpts): boolean {\r\n if (!node || /*node.locked ||*/ !o) return false;\r\n if (o.pack === undefined) o.pack = true;\r\n\r\n // constrain the passed in values and check if we're still changing our node\r\n if (typeof o.x !== 'number') { o.x = node.x; }\r\n if (typeof o.y !== 'number') { o.y = node.y; }\r\n if (typeof o.w !== 'number') { o.w = node.w; }\r\n if (typeof o.h !== 'number') { o.h = node.h; }\r\n let resizing = (node.w !== o.w || node.h !== o.h);\r\n let nn: GridStackNode = Utils.copyPos({}, node, true); // get min/max out first, then opt positions next\r\n Utils.copyPos(nn, o);\r\n nn = this.nodeBoundFix(nn, resizing);\r\n Utils.copyPos(o, nn);\r\n\r\n if (Utils.samePos(node, o)) return false;\r\n let prevPos: GridStackPosition = Utils.copyPos({}, node);\r\n\r\n // during while() collisions make sure to check entire row so larger items don't leap frog small ones (push them all down)\r\n let area = nn;\r\n // if (this._useEntireRowArea(node, nn)) {\r\n // area = {x: 0, w: this.column, y: nn.y, h: nn.h};\r\n // }\r\n\r\n // check if we will need to fix collision at our new location\r\n let collides = this.collideAll(node, area, o.skip);\r\n let needToMove = true;\r\n if (collides.length) {\r\n // now check to make sure we actually collided over 50% surface area while dragging\r\n let collide = node._moving && !o.nested ? this.collideCoverage(node, o, collides) : collides[0];\r\n if (collide) {\r\n needToMove = !this._fixCollisions(node, nn, collide, o); // check if already moved...\r\n } else {\r\n needToMove = false; // we didn't cover >50% for a move, skip...\r\n }\r\n }\r\n\r\n // now move (to the original ask vs the collision version which might differ) and repack things\r\n if (needToMove) {\r\n node._dirty = true;\r\n Utils.copyPos(node, nn);\r\n }\r\n if (o.pack) {\r\n this._packNodes()\r\n ._notify();\r\n }\r\n return !Utils.samePos(node, prevPos); // pack might have moved things back\r\n }\r\n\r\n public getRow(): number {\r\n return this.nodes.reduce((row, n) => Math.max(row, n.y + n.h), 0);\r\n }\r\n\r\n public beginUpdate(node: GridStackNode): GridStackEngine {\r\n if (!node._updating) {\r\n node._updating = true;\r\n delete node._skipDown;\r\n if (!this.batchMode) this.saveInitial();\r\n }\r\n return this;\r\n }\r\n\r\n public endUpdate(): GridStackEngine {\r\n let n = this.nodes.find(n => n._updating);\r\n if (n) {\r\n delete n._updating;\r\n delete n._skipDown;\r\n }\r\n return this;\r\n }\r\n\r\n /** saves a copy of the current layout returning a list of widgets for serialization */\r\n public save(saveElement = true): GridStackNode[] {\r\n let list: GridStackNode[] = [];\r\n this._sortNodes();\r\n this.nodes.forEach(n => {\r\n let w: GridStackNode = {};\r\n for (let key in n) { if (key[0] !== '_' && n[key] !== null && n[key] !== undefined ) w[key] = n[key]; }\r\n // delete other internals\r\n delete w.grid;\r\n if (!saveElement) delete w.el;\r\n // delete default values (will be re-created on read)\r\n if (!w.autoPosition) delete w.autoPosition;\r\n if (!w.noResize) delete w.noResize;\r\n if (!w.noMove) delete w.noMove;\r\n if (!w.locked) delete w.locked;\r\n list.push(w);\r\n });\r\n return list;\r\n }\r\n\r\n /** @internal called whenever a node is added or moved - updates the cached layouts */\r\n public layoutsNodesChange(nodes: GridStackNode[]): GridStackEngine {\r\n if (!this._layouts || this._ignoreLayoutsNodeChange) return this;\r\n // remove smaller layouts - we will re-generate those on the fly... larger ones need to update\r\n this._layouts.forEach((layout, column) => {\r\n if (!layout || column === this.column) return this;\r\n if (column < this.column) {\r\n this._layouts[column] = undefined;\r\n }\r\n else {\r\n // we save the original x,y,w (h isn't cached) to see what actually changed to propagate better.\r\n // Note: we don't need to check against out of bound scaling/moving as that will be done when using those cache values.\r\n nodes.forEach(node => {\r\n if (!node._orig) return; // didn't change (newly added ?)\r\n let n = layout.find(l => l._id === node._id);\r\n if (!n) return; // no cache for new nodes. Will use those values.\r\n let ratio = column / this.column;\r\n // Y changed, push down same amount\r\n // TODO: detect doing item 'swaps' will help instead of move (especially in 1 column mode)\r\n if (node.y !== node._orig.y) {\r\n n.y += (node.y - node._orig.y);\r\n }\r\n // X changed, scale from new position\r\n if (node.x !== node._orig.x) {\r\n n.x = Math.round(node.x * ratio);\r\n }\r\n // width changed, scale from new width\r\n if (node.w !== node._orig.w) {\r\n n.w = Math.round(node.w * ratio);\r\n }\r\n // ...height always carries over from cache\r\n });\r\n }\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * @internal Called to scale the widget width & position up/down based on the column change.\r\n * Note we store previous layouts (especially original ones) to make it possible to go\r\n * from say 12 -> 1 -> 12 and get back to where we were.\r\n *\r\n * @param oldColumn previous number of columns\r\n * @param column new column number\r\n * @param nodes different sorted list (ex: DOM order) instead of current list\r\n * @param layout specify the type of re-layout that will happen (position, size, etc...).\r\n * Note: items will never be outside of the current column boundaries. default (moveScale). Ignored for 1 column\r\n */\r\n public updateNodeWidths(oldColumn: number, column: number, nodes: GridStackNode[], layout: ColumnOptions = 'moveScale'): GridStackEngine {\r\n if (!this.nodes.length || oldColumn === column) return this;\r\n\r\n // cache the current layout in case they want to go back (like 12 -> 1 -> 12) as it requires original data\r\n this.cacheLayout(this.nodes, oldColumn);\r\n\r\n // if we're going to 1 column and using DOM order rather than default sorting, then generate that layout\r\n if (column === 1 && nodes && nodes.length) {\r\n let top = 0;\r\n nodes.forEach(n => {\r\n n.x = 0;\r\n n.w = 1;\r\n n.y = Math.max(n.y, top);\r\n top = n.y + n.h;\r\n });\r\n } else {\r\n nodes = Utils.sort(this.nodes, -1, oldColumn); // current column reverse sorting so we can insert last to front (limit collision)\r\n }\r\n\r\n // see if we have cached previous layout.\r\n let cacheNodes = this._layouts[column] || [];\r\n // if not AND we are going up in size start with the largest layout as down-scaling is more accurate\r\n let lastIndex = this._layouts.length - 1;\r\n if (cacheNodes.length === 0 && column > oldColumn && column < lastIndex) {\r\n cacheNodes = this._layouts[lastIndex] || [];\r\n if (cacheNodes.length) {\r\n // pretend we came from that larger column by assigning those values as starting point\r\n oldColumn = lastIndex;\r\n cacheNodes.forEach(cacheNode => {\r\n let j = nodes.findIndex(n => n._id === cacheNode._id);\r\n if (j !== -1) {\r\n // still current, use cache info positions\r\n nodes[j].x = cacheNode.x;\r\n nodes[j].y = cacheNode.y;\r\n nodes[j].w = cacheNode.w;\r\n }\r\n });\r\n cacheNodes = []; // we still don't have new column cached data... will generate from larger one.\r\n }\r\n }\r\n\r\n // if we found cache re-use those nodes that are still current\r\n let newNodes: GridStackNode[] = [];\r\n cacheNodes.forEach(cacheNode => {\r\n let j = nodes.findIndex(n => n._id === cacheNode._id);\r\n if (j !== -1) {\r\n // still current, use cache info positions\r\n nodes[j].x = cacheNode.x;\r\n nodes[j].y = cacheNode.y;\r\n nodes[j].w = cacheNode.w;\r\n newNodes.push(nodes[j]);\r\n nodes.splice(j, 1);\r\n }\r\n });\r\n // ...and add any extra non-cached ones\r\n if (nodes.length) {\r\n if (typeof layout === 'function') {\r\n layout(column, oldColumn, newNodes, nodes);\r\n } else {\r\n let ratio = column / oldColumn;\r\n let move = (layout === 'move' || layout === 'moveScale');\r\n let scale = (layout === 'scale' || layout === 'moveScale');\r\n nodes.forEach(node => {\r\n node.x = (column === 1 ? 0 : (move ? Math.round(node.x * ratio) : Math.min(node.x, column - 1)));\r\n node.w = ((column === 1 || oldColumn === 1) ? 1 :\r\n scale ? (Math.round(node.w * ratio) || 1) : (Math.min(node.w, column)));\r\n newNodes.push(node);\r\n });\r\n nodes = [];\r\n }\r\n }\r\n\r\n // finally re-layout them in reverse order (to get correct placement)\r\n newNodes = Utils.sort(newNodes, -1, column);\r\n this._ignoreLayoutsNodeChange = true;\r\n this.batchUpdate();\r\n this.nodes = []; // pretend we have no nodes to start with (we use same structures) to simplify layout\r\n newNodes.forEach(node => {\r\n this.addNode(node, false); // 'false' for add event trigger\r\n node._dirty = true; // force attr update\r\n }, this);\r\n this.commit();\r\n delete this._ignoreLayoutsNodeChange;\r\n return this;\r\n }\r\n\r\n /**\r\n * call to cache the given layout internally to the given location so we can restore back when column changes size\r\n * @param nodes list of nodes\r\n * @param column corresponding column index to save it under\r\n * @param clear if true, will force other caches to be removed (default false)\r\n */\r\n public cacheLayout(nodes: GridStackNode[], column: number, clear = false): GridStackEngine {\r\n let copy: Layout[] = [];\r\n nodes.forEach((n, i) => {\r\n n._id = n._id || GridStackEngine._idSeq++; // make sure we have an id in case this is new layout, else re-use id already set\r\n copy[i] = {x: n.x, y: n.y, w: n.w, _id: n._id} // only thing we change is x,y,w and id to find it back\r\n });\r\n this._layouts = clear ? [] : this._layouts || []; // use array to find larger quick\r\n this._layouts[column] = copy;\r\n return this;\r\n }\r\n\r\n /**\r\n * call to cache the given node layout internally to the given location so we can restore back when column changes size\r\n * @param node single node to cache\r\n * @param column corresponding column index to save it under\r\n */\r\n public cacheOneLayout(n: GridStackNode, column: number): GridStackEngine {\r\n n._id = n._id || GridStackEngine._idSeq++;\r\n let layout: Layout = {x: n.x, y: n.y, w: n.w, _id: n._id}\r\n this._layouts = this._layouts || [];\r\n this._layouts[column] = this._layouts[column] || [];\r\n let index = this._layouts[column].findIndex(l => l._id === n._id);\r\n index === -1 ? this._layouts[column].push(layout) : this._layouts[column][index] = layout;\r\n return this;\r\n }\r\n\r\n\r\n /** called to remove all internal values but the _id */\r\n public cleanupNode(node: GridStackNode): GridStackEngine {\r\n for (let prop in node) {\r\n if (prop[0] === '_' && prop !== '_id') delete node[prop];\r\n }\r\n return this;\r\n }\r\n}\r\n\r\n/** @internal class to store per column layout bare minimal info (subset of GridStackWidget) */\r\ninterface Layout {\r\n x: number;\r\n y: number;\r\n w: number;\r\n _id: number; // so we can find full node back\r\n}\r\n","/**\r\n * index-h5.ts 4.2.6 - everything you need for a Grid that uses HTML5 native drag&drop\r\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\r\n */\r\n\r\nexport * from './types';\r\nexport * from './utils';\r\nexport * from './gridstack-engine';\r\nexport * from './gridstack-ddi';\r\nexport * from './gridstack';\r\n\r\nexport * from './h5/gridstack-dd-native';\r\n\r\n// declare module 'gridstack'; for umd ?\r\n","/*!\r\n * GridStack 4.2.6\r\n * https://gridstackjs.com/\r\n *\r\n * Copyright (c) 2021 Alain Dumesny\r\n * see root license https://github.com/gridstack/gridstack.js/tree/master/LICENSE\r\n */\r\n\r\nimport { GridStackEngine } from './gridstack-engine';\r\nimport { Utils, HeightData } from './utils';\r\nimport { ColumnOptions, GridItemHTMLElement, GridStackElement, GridStackEventHandlerCallback,\r\n GridStackNode, GridStackOptions, GridStackWidget, numberOrString, DDUIData, DDDragInOpt, GridStackPosition } from './types';\r\nimport { GridStackDDI } from './gridstack-ddi';\r\n\r\n// export all dependent file as well to make it easier for users to just import the main file\r\nexport * from './types';\r\nexport * from './utils';\r\nexport * from './gridstack-engine';\r\nexport * from './gridstack-ddi';\r\n\r\nexport interface GridHTMLElement extends HTMLElement {\r\n gridstack?: GridStack; // grid's parent DOM element points back to grid class\r\n}\r\n/** list of possible events, or space separated list of them */\r\nexport type GridStackEvent = 'added' | 'change' | 'disable' | 'drag' | 'dragstart' | 'dragstop' | 'dropped' |\r\n 'enable' | 'removed' | 'resize' | 'resizestart' | 'resizestop' | string;\r\n\r\n/** Defines the coordinates of an object */\r\nexport interface MousePosition {\r\n top: number;\r\n left: number;\r\n}\r\n\r\n/** Defines the position of a cell inside the grid*/\r\nexport interface CellPosition {\r\n x: number;\r\n y: number;\r\n}\r\n\r\ninterface GridCSSStyleSheet extends CSSStyleSheet {\r\n _id?: string; // random id we will use to style us\r\n _max?: number; // internal tracker of the max # of rows we created\\\r\n}\r\n\r\n// default values for grid options - used during init and when saving out\r\nconst GridDefaults: GridStackOptions = {\r\n column: 12,\r\n minRow: 0,\r\n maxRow: 0,\r\n itemClass: 'grid-stack-item',\r\n placeholderClass: 'grid-stack-placeholder',\r\n placeholderText: '',\r\n handle: '.grid-stack-item-content',\r\n handleClass: null,\r\n styleInHead: false,\r\n cellHeight: 'auto',\r\n cellHeightThrottle: 100,\r\n margin: 10,\r\n auto: true,\r\n minWidth: 768,\r\n float: false,\r\n staticGrid: false,\r\n animate: true,\r\n alwaysShowResizeHandle: false,\r\n resizable: {\r\n autoHide: true,\r\n handles: 'se'\r\n },\r\n draggable: {\r\n handle: '.grid-stack-item-content',\r\n scroll: false,\r\n appendTo: 'body'\r\n },\r\n disableDrag: false,\r\n disableResize: false,\r\n rtl: 'auto',\r\n removable: false,\r\n removableOptions: {\r\n accept: '.grid-stack-item'\r\n },\r\n marginUnit: 'px',\r\n cellHeightUnit: 'px',\r\n disableOneColumnMode: false,\r\n oneColumnModeDomSort: false\r\n};\r\n\r\n/**\r\n * Main gridstack class - you will need to call `GridStack.init()` first to initialize your grid.\r\n * Note: your grid elements MUST have the following classes for the CSS layout to work:\r\n * @example\r\n *
\r\n *
\r\n *
Item 1
\r\n *
\r\n *
\r\n */\r\nexport class GridStack {\r\n\r\n /**\r\n * initializing the HTML element, or selector string, into a grid will return the grid. Calling it again will\r\n * simply return the existing instance (ignore any passed options). There is also an initAll() version that support\r\n * multiple grids initialization at once. Or you can use addGrid() to create the entire grid from JSON.\r\n * @param options grid options (optional)\r\n * @param elOrString element or CSS selector (first one used) to convert to a grid (default to '.grid-stack' class selector)\r\n *\r\n * @example\r\n * let grid = GridStack.init();\r\n *\r\n * Note: the HTMLElement (of type GridHTMLElement) will store a `gridstack: GridStack` value that can be retrieve later\r\n * let grid = document.querySelector('.grid-stack').gridstack;\r\n */\r\n public static init(options: GridStackOptions = {}, elOrString: GridStackElement = '.grid-stack'): GridStack {\r\n let el = GridStack.getGridElement(elOrString);\r\n if (!el) {\r\n if (typeof elOrString === 'string') {\r\n console.error('GridStack.initAll() no grid was found with selector \"' + elOrString + '\" - element missing or wrong selector ?' +\r\n '\\nNote: \".grid-stack\" is required for proper CSS styling and drag/drop, and is the default selector.');\r\n } else {\r\n console.error('GridStack.init() no grid element was passed.');\r\n }\r\n return null;\r\n }\r\n if (!el.gridstack) {\r\n el.gridstack = new GridStack(el, Utils.cloneDeep(options));\r\n }\r\n return el.gridstack\r\n }\r\n\r\n /**\r\n * Will initialize a list of elements (given a selector) and return an array of grids.\r\n * @param options grid options (optional)\r\n * @param selector elements selector to convert to grids (default to '.grid-stack' class selector)\r\n *\r\n * @example\r\n * let grids = GridStack.initAll();\r\n * grids.forEach(...)\r\n */\r\n public static initAll(options: GridStackOptions = {}, selector = '.grid-stack'): GridStack[] {\r\n let grids: GridStack[] = [];\r\n GridStack.getGridElements(selector).forEach(el => {\r\n if (!el.gridstack) {\r\n el.gridstack = new GridStack(el, Utils.cloneDeep(options));\r\n delete options.dragIn; delete options.dragInOptions; // only need to be done once (really a static global thing, not per grid)\r\n }\r\n grids.push(el.gridstack);\r\n });\r\n if (grids.length === 0) {\r\n console.error('GridStack.initAll() no grid was found with selector \"' + selector + '\" - element missing or wrong selector ?' +\r\n '\\nNote: \".grid-stack\" is required for proper CSS styling and drag/drop, and is the default selector.');\r\n }\r\n return grids;\r\n }\r\n\r\n /**\r\n * call to create a grid with the given options, including loading any children from JSON structure. This will call GridStack.init(), then\r\n * grid.load() on any passed children (recursively). Great alternative to calling init() if you want entire grid to come from\r\n * JSON serialized data, including options.\r\n * @param parent HTML element parent to the grid\r\n * @param opt grids options used to initialize the grid, and list of children\r\n */\r\n public static addGrid(parent: HTMLElement, opt: GridStackOptions = {}): GridStack {\r\n if (!parent) return null;\r\n\r\n // create the grid element, but check if the passed 'parent' already has grid styling and should be used instead\r\n let el = parent;\r\n if (!parent.classList.contains('grid-stack')) {\r\n let doc = document.implementation.createHTMLDocument();\r\n doc.body.innerHTML = `
`;\r\n el = doc.body.children[0] as HTMLElement;\r\n parent.appendChild(el);\r\n }\r\n\r\n // create grid class and load any children\r\n let grid = GridStack.init(opt, el);\r\n if (grid.opts.children) {\r\n let children = grid.opts.children;\r\n delete grid.opts.children;\r\n grid.load(children);\r\n }\r\n return grid;\r\n }\r\n\r\n /** scoping so users can call GridStack.Utils.sort() for example */\r\n public static Utils = Utils;\r\n\r\n /** scoping so users can call new GridStack.Engine(12) for example */\r\n public static Engine = GridStackEngine;\r\n\r\n /** the HTML element tied to this grid after it's been initialized */\r\n public el: GridHTMLElement;\r\n\r\n /** engine used to implement non DOM grid functionality */\r\n public engine: GridStackEngine;\r\n\r\n /** grid options - public for classes to access, but use methods to modify! */\r\n public opts: GridStackOptions;\r\n\r\n /** @internal create placeholder DIV as needed */\r\n public get placeholder(): HTMLElement {\r\n if (!this._placeholder) {\r\n let placeholderChild = document.createElement('div'); // child so padding match item-content\r\n placeholderChild.className = 'placeholder-content';\r\n if (this.opts.placeholderText) {\r\n placeholderChild.innerHTML = this.opts.placeholderText;\r\n }\r\n this._placeholder = document.createElement('div');\r\n this._placeholder.classList.add(this.opts.placeholderClass, GridDefaults.itemClass, this.opts.itemClass);\r\n this.placeholder.appendChild(placeholderChild);\r\n }\r\n return this._placeholder;\r\n }\r\n /** @internal */\r\n private _placeholder: HTMLElement;\r\n /** @internal */\r\n private _prevColumn: number;\r\n /** @internal */\r\n private _ignoreLayoutsNodeChange: boolean;\r\n /** @internal */\r\n public _gsEventHandler = {};\r\n /** @internal */\r\n private _styles: GridCSSStyleSheet;\r\n /** @internal flag to keep cells square during resize */\r\n private _isAutoCellHeight: boolean;\r\n /** @internal track event binding to window resize so we can remove */\r\n private _windowResizeBind: () => void;\r\n /** @internal limit auto cell resizing method */\r\n private _cellHeightThrottle: () => void;\r\n /** @internal true when loading items to insert first rather than append */\r\n private _insertNotAppend: boolean;\r\n /** @internal extra row added when dragging at the bottom of the grid */\r\n private _extraDragRow = 0;\r\n\r\n /**\r\n * Construct a grid item from the given element and options\r\n * @param el\r\n * @param opts\r\n */\r\n public constructor(el: GridHTMLElement, opts: GridStackOptions = {}) {\r\n this.el = el; // exposed HTML element to the user\r\n opts = opts || {}; // handles null/undefined/0\r\n\r\n // if row property exists, replace minRow and maxRow instead\r\n if (opts.row) {\r\n opts.minRow = opts.maxRow = opts.row;\r\n delete opts.row;\r\n }\r\n let rowAttr = Utils.toNumber(el.getAttribute('gs-row'));\r\n\r\n // elements attributes override any passed options (like CSS style) - merge the two together\r\n let defaults: GridStackOptions = {...Utils.cloneDeep(GridDefaults),\r\n column: Utils.toNumber(el.getAttribute('gs-column')) || 12,\r\n minRow: rowAttr ? rowAttr : Utils.toNumber(el.getAttribute('gs-min-row')) || 0,\r\n maxRow: rowAttr ? rowAttr : Utils.toNumber(el.getAttribute('gs-max-row')) || 0,\r\n staticGrid: Utils.toBool(el.getAttribute('gs-static')) || false,\r\n _styleSheetClass: 'grid-stack-instance-' + (Math.random() * 10000).toFixed(0),\r\n alwaysShowResizeHandle: opts.alwaysShowResizeHandle || false,\r\n resizable: {\r\n autoHide: !(opts.alwaysShowResizeHandle || false),\r\n handles: 'se'\r\n },\r\n draggable: {\r\n handle: (opts.handleClass ? '.' + opts.handleClass : (opts.handle ? opts.handle : '')) || '.grid-stack-item-content',\r\n scroll: false,\r\n appendTo: 'body'\r\n },\r\n removableOptions: {\r\n accept: '.' + (opts.itemClass || 'grid-stack-item')\r\n },\r\n };\r\n if (el.getAttribute('gs-animate')) { // default to true, but if set to false use that instead\r\n defaults.animate = Utils.toBool(el.getAttribute('gs-animate'))\r\n }\r\n\r\n this.opts = Utils.defaults(opts, defaults);\r\n opts = null; // make sure we use this.opts instead\r\n this.initMargin(); // part of settings defaults...\r\n\r\n // Now check if we're loading into 1 column mode FIRST so we don't do un-necessary work (like cellHeight = width / 12 then go 1 column)\r\n if (this.opts.column !== 1 && !this.opts.disableOneColumnMode && this._widthOrContainer() <= this.opts.minWidth) {\r\n this._prevColumn = this.opts.column;\r\n this.opts.column = 1;\r\n }\r\n\r\n if (this.opts.rtl === 'auto') {\r\n this.opts.rtl = (el.style.direction === 'rtl');\r\n }\r\n\r\n if (this.opts.rtl) {\r\n this.el.classList.add('grid-stack-rtl');\r\n }\r\n\r\n // check if we're been nested, and if so update our style and keep pointer around (used during save)\r\n let parentGridItemEl = Utils.closestByClass(this.el, GridDefaults.itemClass) as GridItemHTMLElement;\r\n if (parentGridItemEl && parentGridItemEl.gridstackNode) {\r\n this.opts._isNested = parentGridItemEl.gridstackNode;\r\n this.opts._isNested.subGrid = this;\r\n this.el.classList.add('grid-stack-nested');\r\n }\r\n\r\n this._isAutoCellHeight = (this.opts.cellHeight === 'auto');\r\n if (this._isAutoCellHeight || this.opts.cellHeight === 'initial') {\r\n // make the cell content square initially (will use resize/column event to keep it square)\r\n this.cellHeight(undefined, false);\r\n } else {\r\n this.cellHeight(this.opts.cellHeight, false);\r\n }\r\n\r\n this.el.classList.add(this.opts._styleSheetClass);\r\n\r\n this._setStaticClass();\r\n\r\n this.engine = new GridStackEngine({\r\n column: this.opts.column,\r\n float: this.opts.float,\r\n maxRow: this.opts.maxRow,\r\n onChange: (cbNodes) => {\r\n let maxH = 0;\r\n this.engine.nodes.forEach(n => { maxH = Math.max(maxH, n.y + n.h) });\r\n cbNodes.forEach(n => {\r\n let el = n.el;\r\n if (n._removeDOM) {\r\n if (el) el.remove();\r\n delete n._removeDOM;\r\n } else {\r\n this._writePosAttr(el, n);\r\n }\r\n });\r\n this._updateStyles(false, maxH); // false = don't recreate, just append if need be\r\n }\r\n });\r\n\r\n if (this.opts.auto) {\r\n this.batchUpdate(); // prevent in between re-layout #1535 TODO: this only set float=true, need to prevent collision check...\r\n let elements: {el: HTMLElement; i: number}[] = [];\r\n this.getGridItems().forEach(el => { // get dom elements (not nodes yet)\r\n let x = parseInt(el.getAttribute('gs-x'));\r\n let y = parseInt(el.getAttribute('gs-y'));\r\n elements.push({\r\n el,\r\n // if x,y are missing (autoPosition) add them to end of list - but keep their respective DOM order\r\n i: (Number.isNaN(x) ? 1000 : x) + (Number.isNaN(y) ? 1000 : y) * this.opts.column\r\n });\r\n });\r\n elements.sort((a, b) => a.i - b.i).forEach(e => this._prepareElement(e.el));\r\n this.commit();\r\n }\r\n\r\n this.setAnimation(this.opts.animate);\r\n\r\n this._updateStyles();\r\n if (this.opts.column != 12) {\r\n this.el.classList.add('grid-stack-' + this.opts.column);\r\n }\r\n\r\n // legacy support to appear 'per grid` options when really global.\r\n if (this.opts.dragIn) GridStack.setupDragIn(this.opts.dragIn, this.opts.dragInOptions);\r\n delete this.opts.dragIn;\r\n delete this.opts.dragInOptions;\r\n\r\n this._setupRemoveDrop();\r\n this._setupAcceptWidget();\r\n this._updateWindowResizeEvent();\r\n }\r\n\r\n /**\r\n * add a new widget and returns it.\r\n *\r\n * Widget will be always placed even if result height is more than actual grid height.\r\n * You need to use `willItFit()` before calling addWidget for additional check.\r\n * See also `makeWidget()`.\r\n *\r\n * @example\r\n * let grid = GridStack.init();\r\n * grid.addWidget({w: 3, content: 'hello'});\r\n * grid.addWidget('
hello
', {w: 3});\r\n *\r\n * @param el GridStackWidget (which can have content string as well), html element, or string definition to add\r\n * @param options widget position/size options (optional, and ignore if first param is already option) - see GridStackWidget\r\n */\r\n public addWidget(els?: GridStackWidget | GridStackElement, options?: GridStackWidget): GridItemHTMLElement {\r\n\r\n // support legacy call for now ?\r\n if (arguments.length > 2) {\r\n console.warn('gridstack.ts: `addWidget(el, x, y, width...)` is deprecated. Use `addWidget({x, y, w, content, ...})`. It will be removed soon');\r\n // eslint-disable-next-line prefer-rest-params\r\n let a = arguments, i = 1,\r\n opt: GridStackWidget = { x:a[i++], y:a[i++], w:a[i++], h:a[i++], autoPosition:a[i++],\r\n minW:a[i++], maxW:a[i++], minH:a[i++], maxH:a[i++], id:a[i++] };\r\n return this.addWidget(els, opt);\r\n }\r\n\r\n function isGridStackWidget(w: GridStackWidget): w is GridStackWidget { // https://medium.com/ovrsea/checking-the-type-of-an-object-in-typescript-the-type-guards-24d98d9119b0\r\n return w.x !== undefined || w.y !== undefined || w.w !== undefined || w.h !== undefined || w.content !== undefined ? true : false;\r\n }\r\n\r\n let el: HTMLElement;\r\n if (typeof els === 'string') {\r\n let doc = document.implementation.createHTMLDocument();\r\n doc.body.innerHTML = els;\r\n el = doc.body.children[0] as HTMLElement;\r\n } else if (arguments.length === 0 || arguments.length === 1 && isGridStackWidget(els)) {\r\n let content = els ? (els as GridStackWidget).content || '' : '';\r\n options = els;\r\n let doc = document.implementation.createHTMLDocument();\r\n doc.body.innerHTML = `
${content}
`;\r\n el = doc.body.children[0] as HTMLElement;\r\n } else {\r\n el = els as HTMLElement;\r\n }\r\n\r\n // Tempting to initialize the passed in opt with default and valid values, but this break knockout demos\r\n // as the actual value are filled in when _prepareElement() calls el.getAttribute('gs-xyz) before adding the node.\r\n // So make sure we load any DOM attributes that are not specified in passed in options (which override)\r\n let domAttr = this._readAttr(el);\r\n options = Utils.cloneDeep(options) || {}; // make a copy before we modify in case caller re-uses it\r\n Utils.defaults(options, domAttr);\r\n let node = this.engine.prepareNode(options);\r\n this._writeAttr(el, options);\r\n\r\n if (this._insertNotAppend) {\r\n this.el.prepend(el);\r\n } else {\r\n this.el.appendChild(el);\r\n }\r\n\r\n // similar to makeWidget() that doesn't read attr again and worse re-create a new node and loose any _id\r\n this._prepareElement(el, true, options);\r\n this._updateContainerHeight();\r\n\r\n // check if nested grid definition is present\r\n if (node.subGrid && !(node.subGrid as GridStack).el) { // see if there is a sub-grid to create too\r\n let content = node.el.querySelector('.grid-stack-item-content') as HTMLElement;\r\n node.subGrid = GridStack.addGrid(content, node.subGrid as GridStackOptions);\r\n }\r\n\r\n this._triggerAddEvent();\r\n this._triggerChangeEvent();\r\n\r\n return el;\r\n }\r\n\r\n /**\r\n /**\r\n * saves the current layout returning a list of widgets for serialization which might include any nested grids.\r\n * @param saveContent if true (default) the latest html inside .grid-stack-content will be saved to GridStackWidget.content field, else it will\r\n * be removed.\r\n * @param saveGridOpt if true (default false), save the grid options itself, so you can call the new GridStack.addGrid()\r\n * to recreate everything from scratch. GridStackOptions.children would then contain the widget list instead.\r\n * @returns list of widgets or full grid option, including .children list of widgets\r\n */\r\n public save(saveContent = true, saveGridOpt = false): GridStackWidget[] | GridStackOptions {\r\n // return copied nodes we can modify at will...\r\n let list = this.engine.save(saveContent);\r\n\r\n // check for HTML content and nested grids\r\n list.forEach(n => {\r\n if (saveContent && n.el && !n.subGrid) { // sub-grid are saved differently, not plain content\r\n let sub = n.el.querySelector('.grid-stack-item-content');\r\n n.content = sub ? sub.innerHTML : undefined;\r\n if (!n.content) delete n.content;\r\n } else {\r\n if (!saveContent) { delete n.content; }\r\n // check for nested grid\r\n if (n.subGrid) {\r\n n.subGrid = (n.subGrid as GridStack).save(saveContent, true) as GridStackOptions;\r\n }\r\n }\r\n delete n.el;\r\n });\r\n\r\n // check if save entire grid options (needed for recursive) + children...\r\n if (saveGridOpt) {\r\n let o: GridStackOptions = Utils.cloneDeep(this.opts);\r\n // delete default values that will be recreated on launch\r\n if (o.marginBottom === o.marginTop && o.marginRight === o.marginLeft && o.marginTop === o.marginRight) {\r\n o.margin = o.marginTop;\r\n delete o.marginTop; delete o.marginRight; delete o.marginBottom; delete o.marginLeft;\r\n }\r\n if (o.rtl === (this.el.style.direction === 'rtl')) { o.rtl = 'auto' }\r\n if (this._isAutoCellHeight) { o.cellHeight = 'auto' }\r\n Utils.removeInternalAndSame(o, GridDefaults);\r\n o.children = list;\r\n return o;\r\n }\r\n\r\n return list;\r\n }\r\n\r\n /**\r\n * load the widgets from a list. This will call update() on each (matching by id) or add/remove widgets that are not there.\r\n *\r\n * @param layout list of widgets definition to update/create\r\n * @param addAndRemove boolean (default true) or callback method can be passed to control if and how missing widgets can be added/removed, giving\r\n * the user control of insertion.\r\n *\r\n * @example\r\n * see http://gridstackjs.com/demo/serialization.html\r\n **/\r\n public load(layout: GridStackWidget[], addAndRemove: boolean | ((g: GridStack, w: GridStackWidget, add: boolean) => GridItemHTMLElement) = true): GridStack {\r\n let items = GridStack.Utils.sort([...layout], -1, this._prevColumn || this.opts.column); // make copy before we mod/sort\r\n this._insertNotAppend = true; // since create in reverse order...\r\n\r\n // if we're loading a layout into 1 column (_prevColumn is set only when going to 1) and items don't fit, make sure to save\r\n // the original wanted layout so we can scale back up correctly #1471\r\n if (this._prevColumn && this._prevColumn !== this.opts.column && items.some(n => (n.x + n.w) > this.opts.column)) {\r\n this._ignoreLayoutsNodeChange = true; // skip layout update\r\n this.engine.cacheLayout(items, this._prevColumn, true);\r\n }\r\n\r\n let removed: GridStackNode[] = [];\r\n this.batchUpdate();\r\n\r\n // see if any items are missing from new layout and need to be removed first\r\n if (addAndRemove) {\r\n let copyNodes = [...this.engine.nodes]; // don't loop through array you modify\r\n copyNodes.forEach(n => {\r\n let item = items.find(w => n.id === w.id);\r\n if (!item) {\r\n if (typeof(addAndRemove) === 'function') {\r\n addAndRemove(this, n, false);\r\n } else {\r\n removed.push(n); // batch keep track\r\n this.removeWidget(n.el, true, false);\r\n }\r\n }\r\n });\r\n }\r\n\r\n // now add/update the widgets\r\n items.forEach(w => {\r\n let item = (w.id || w.id === 0) ? this.engine.nodes.find(n => n.id === w.id) : undefined;\r\n if (item) {\r\n this.update(item.el, w);\r\n if (w.subGrid && (w.subGrid as GridStackOptions).children) { // update any sub grid as well\r\n let sub = item.el.querySelector('.grid-stack') as GridHTMLElement;\r\n if (sub && sub.gridstack) {\r\n sub.gridstack.load((w.subGrid as GridStackOptions).children); // TODO: support updating grid options ?\r\n this._insertNotAppend = true; // got reset by above call\r\n }\r\n }\r\n } else if (addAndRemove) {\r\n if (typeof(addAndRemove) === 'function') {\r\n w = addAndRemove(this, w, true).gridstackNode;\r\n } else {\r\n w = this.addWidget(w).gridstackNode;\r\n }\r\n }\r\n });\r\n\r\n this.engine.removedNodes = removed;\r\n this.commit();\r\n\r\n // after commit, clear that flag\r\n delete this._ignoreLayoutsNodeChange;\r\n delete this._insertNotAppend;\r\n return this;\r\n }\r\n\r\n /**\r\n * Initializes batch updates. You will see no changes until `commit()` method is called.\r\n */\r\n public batchUpdate(): GridStack {\r\n this.engine.batchUpdate();\r\n return this;\r\n }\r\n\r\n /**\r\n * Gets current cell height.\r\n */\r\n public getCellHeight(forcePixel = false): number {\r\n if (this.opts.cellHeight && this.opts.cellHeight !== 'auto' &&\r\n (!forcePixel || !this.opts.cellHeightUnit || this.opts.cellHeightUnit === 'px')) {\r\n return this.opts.cellHeight as number;\r\n }\r\n // else do entire grid and # of rows\r\n // or get first cell height ?\r\n // let el = this.el.querySelector('.' + this.opts.itemClass) as HTMLElement;\r\n // let height = Utils.toNumber(el.getAttribute('gs-h'));\r\n // return Math.round(el.offsetHeight / height);\r\n return Math.round(this.el.getBoundingClientRect().height) / parseInt(this.el.getAttribute('gs-current-row'));\r\n }\r\n\r\n /**\r\n * Update current cell height - see `GridStackOptions.cellHeight` for format.\r\n * This method rebuilds an internal CSS style sheet.\r\n * Note: You can expect performance issues if call this method too often.\r\n *\r\n * @param val the cell height. If not passed (undefined), cells content will be made square (match width minus margin),\r\n * if pass 0 the CSS will be generated by the application instead.\r\n * @param update (Optional) if false, styles will not be updated\r\n *\r\n * @example\r\n * grid.cellHeight(100); // same as 100px\r\n * grid.cellHeight('70px');\r\n * grid.cellHeight(grid.cellWidth() * 1.2);\r\n */\r\n public cellHeight(val?: numberOrString, update = true): GridStack {\r\n\r\n // if not called internally, check if we're changing mode\r\n if (update && val !== undefined) {\r\n if (this._isAutoCellHeight !== (val === 'auto')) {\r\n this._isAutoCellHeight = (val === 'auto');\r\n this._updateWindowResizeEvent();\r\n }\r\n }\r\n if (val === 'initial' || val === 'auto') { val = undefined; }\r\n\r\n // make item content be square\r\n if (val === undefined) {\r\n let marginDiff = - (this.opts.marginRight as number) - (this.opts.marginLeft as number)\r\n + (this.opts.marginTop as number) + (this.opts.marginBottom as number);\r\n val = this.cellWidth() + marginDiff;\r\n }\r\n\r\n let data = Utils.parseHeight(val);\r\n if (this.opts.cellHeightUnit === data.unit && this.opts.cellHeight === data.h) {\r\n return this;\r\n }\r\n this.opts.cellHeightUnit = data.unit;\r\n this.opts.cellHeight = data.h;\r\n\r\n if (update) {\r\n this._updateStyles(true, this.getRow()); // true = force re-create, for that # of rows\r\n }\r\n return this;\r\n }\r\n\r\n /** Gets current cell width. */\r\n public cellWidth(): number {\r\n return this._widthOrContainer() / this.opts.column;\r\n }\r\n /** return our expected width (or parent) for 1 column check */\r\n private _widthOrContainer(): number {\r\n // use `offsetWidth` or `clientWidth` (no scrollbar) ?\r\n // https://stackoverflow.com/questions/21064101/understanding-offsetwidth-clientwidth-scrollwidth-and-height-respectively\r\n return (this.el.clientWidth || this.el.parentElement.clientWidth || window.innerWidth);\r\n }\r\n\r\n /**\r\n * Finishes batch updates. Updates DOM nodes. You must call it after batchUpdate.\r\n */\r\n public commit(): GridStack {\r\n this.engine.commit();\r\n this._triggerRemoveEvent();\r\n this._triggerAddEvent();\r\n this._triggerChangeEvent();\r\n return this;\r\n }\r\n\r\n /** re-layout grid items to reclaim any empty space */\r\n public compact(): GridStack {\r\n this.engine.compact();\r\n this._triggerChangeEvent();\r\n return this;\r\n }\r\n\r\n /**\r\n * set the number of columns in the grid. Will update existing widgets to conform to new number of columns,\r\n * as well as cache the original layout so you can revert back to previous positions without loss.\r\n * Requires `gridstack-extra.css` or `gridstack-extra.min.css` for [2-11],\r\n * else you will need to generate correct CSS (see https://github.com/gridstack/gridstack.js#change-grid-columns)\r\n * @param column - Integer > 0 (default 12).\r\n * @param layout specify the type of re-layout that will happen (position, size, etc...).\r\n * Note: items will never be outside of the current column boundaries. default (moveScale). Ignored for 1 column\r\n */\r\n public column(column: number, layout: ColumnOptions = 'moveScale'): GridStack {\r\n if (this.opts.column === column) return this;\r\n let oldColumn = this.opts.column;\r\n\r\n // if we go into 1 column mode (which happens if we're sized less than minW unless disableOneColumnMode is on)\r\n // then remember the original columns so we can restore.\r\n if (column === 1) {\r\n this._prevColumn = oldColumn;\r\n } else {\r\n delete this._prevColumn;\r\n }\r\n\r\n this.el.classList.remove('grid-stack-' + oldColumn);\r\n this.el.classList.add('grid-stack-' + column);\r\n this.opts.column = this.engine.column = column;\r\n\r\n // update the items now - see if the dom order nodes should be passed instead (else default to current list)\r\n let domNodes: GridStackNode[];\r\n if (column === 1 && this.opts.oneColumnModeDomSort) {\r\n domNodes = [];\r\n this.getGridItems().forEach(el => { // get dom elements in order\r\n if (el.gridstackNode) { domNodes.push(el.gridstackNode); }\r\n });\r\n if (!domNodes.length) { domNodes = undefined; }\r\n }\r\n this.engine.updateNodeWidths(oldColumn, column, domNodes, layout);\r\n if (this._isAutoCellHeight) this.cellHeight();\r\n\r\n // and trigger our event last...\r\n this._ignoreLayoutsNodeChange = true; // skip layout update\r\n this._triggerChangeEvent();\r\n delete this._ignoreLayoutsNodeChange;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * get the number of columns in the grid (default 12)\r\n */\r\n public getColumn(): number {\r\n return this.opts.column;\r\n }\r\n\r\n /** returns an array of grid HTML elements (no placeholder) - used to iterate through our children in DOM order */\r\n public getGridItems(): GridItemHTMLElement[] {\r\n return Array.from(this.el.children)\r\n .filter((el: HTMLElement) => el.matches('.' + this.opts.itemClass) && !el.matches('.' + this.opts.placeholderClass)) as GridItemHTMLElement[];\r\n }\r\n\r\n /**\r\n * Destroys a grid instance. DO NOT CALL any methods or access any vars after this as it will free up members.\r\n * @param removeDOM if `false` grid and items HTML elements will not be removed from the DOM (Optional. Default `true`).\r\n */\r\n public destroy(removeDOM = true): GridStack {\r\n if (!this.el) return; // prevent multiple calls\r\n this._updateWindowResizeEvent(true);\r\n this.setStatic(true, false); // permanently removes DD but don't set CSS class (we're going away)\r\n this.setAnimation(false);\r\n if (!removeDOM) {\r\n this.removeAll(removeDOM);\r\n this.el.classList.remove(this.opts._styleSheetClass);\r\n } else {\r\n this.el.parentNode.removeChild(this.el);\r\n }\r\n this._removeStylesheet();\r\n this.el.removeAttribute('gs-current-row');\r\n delete this.opts._isNested;\r\n delete this.opts;\r\n delete this._placeholder;\r\n delete this.engine;\r\n delete this.el.gridstack; // remove circular dependency that would prevent a freeing\r\n delete this.el;\r\n return this;\r\n }\r\n\r\n /**\r\n * enable/disable floating widgets (default: `false`) See [example](http://gridstackjs.com/demo/float.html)\r\n */\r\n public float(val: boolean): GridStack {\r\n this.engine.float = val;\r\n this._triggerChangeEvent();\r\n return this;\r\n }\r\n\r\n /**\r\n * get the current float mode\r\n */\r\n public getFloat(): boolean {\r\n return this.engine.float;\r\n }\r\n\r\n /**\r\n * Get the position of the cell under a pixel on screen.\r\n * @param position the position of the pixel to resolve in\r\n * absolute coordinates, as an object with top and left properties\r\n * @param useDocRelative if true, value will be based on document position vs parent position (Optional. Default false).\r\n * Useful when grid is within `position: relative` element\r\n *\r\n * Returns an object with properties `x` and `y` i.e. the column and row in the grid.\r\n */\r\n public getCellFromPixel(position: MousePosition, useDocRelative = false): CellPosition {\r\n let box = this.el.getBoundingClientRect();\r\n // console.log(`getBoundingClientRect left: ${box.left} top: ${box.top} w: ${box.w} h: ${box.h}`)\r\n let containerPos: {top: number, left: number};\r\n if (useDocRelative) {\r\n containerPos = {top: box.top + document.documentElement.scrollTop, left: box.left};\r\n // console.log(`getCellFromPixel scrollTop: ${document.documentElement.scrollTop}`)\r\n } else {\r\n containerPos = {top: this.el.offsetTop, left: this.el.offsetLeft}\r\n // console.log(`getCellFromPixel offsetTop: ${containerPos.left} offsetLeft: ${containerPos.top}`)\r\n }\r\n let relativeLeft = position.left - containerPos.left;\r\n let relativeTop = position.top - containerPos.top;\r\n\r\n let columnWidth = (box.width / this.opts.column);\r\n let rowHeight = (box.height / parseInt(this.el.getAttribute('gs-current-row')));\r\n\r\n return {x: Math.floor(relativeLeft / columnWidth), y: Math.floor(relativeTop / rowHeight)};\r\n }\r\n\r\n /** returns the current number of rows, which will be at least `minRow` if set */\r\n public getRow(): number {\r\n return Math.max(this.engine.getRow(), this.opts.minRow);\r\n }\r\n\r\n /**\r\n * Checks if specified area is empty.\r\n * @param x the position x.\r\n * @param y the position y.\r\n * @param w the width of to check\r\n * @param h the height of to check\r\n */\r\n public isAreaEmpty(x: number, y: number, w: number, h: number): boolean {\r\n return this.engine.isAreaEmpty(x, y, w, h);\r\n }\r\n\r\n /**\r\n * If you add elements to your grid by hand, you have to tell gridstack afterwards to make them widgets.\r\n * If you want gridstack to add the elements for you, use `addWidget()` instead.\r\n * Makes the given element a widget and returns it.\r\n * @param els widget or single selector to convert.\r\n *\r\n * @example\r\n * let grid = GridStack.init();\r\n * grid.el.appendChild('
');\r\n * grid.makeWidget('#gsi-1');\r\n */\r\n public makeWidget(els: GridStackElement): GridItemHTMLElement {\r\n let el = GridStack.getElement(els);\r\n this._prepareElement(el, true);\r\n this._updateContainerHeight();\r\n this._triggerAddEvent();\r\n this._triggerChangeEvent();\r\n return el;\r\n }\r\n\r\n /**\r\n * Event handler that extracts our CustomEvent data out automatically for receiving custom\r\n * notifications (see doc for supported events)\r\n * @param name of the event (see possible values) or list of names space separated\r\n * @param callback function called with event and optional second/third param\r\n * (see README documentation for each signature).\r\n *\r\n * @example\r\n * grid.on('added', function(e, items) { log('added ', items)} );\r\n * or\r\n * grid.on('added removed change', function(e, items) { log(e.type, items)} );\r\n *\r\n * Note: in some cases it is the same as calling native handler and parsing the event.\r\n * grid.el.addEventListener('added', function(event) { log('added ', event.detail)} );\r\n *\r\n */\r\n public on(name: GridStackEvent, callback: GridStackEventHandlerCallback): GridStack {\r\n // check for array of names being passed instead\r\n if (name.indexOf(' ') !== -1) {\r\n let names = name.split(' ') as GridStackEvent[];\r\n names.forEach(name => this.on(name, callback));\r\n return this;\r\n }\r\n\r\n if (name === 'change' || name === 'added' || name === 'removed' || name === 'enable' || name === 'disable') {\r\n // native CustomEvent handlers - cash the generic handlers so we can easily remove\r\n let noData = (name === 'enable' || name === 'disable');\r\n if (noData) {\r\n this._gsEventHandler[name] = (event: Event) => callback(event);\r\n } else {\r\n this._gsEventHandler[name] = (event: CustomEvent) => callback(event, event.detail);\r\n }\r\n this.el.addEventListener(name, this._gsEventHandler[name]);\r\n } else if (name === 'drag' || name === 'dragstart' || name === 'dragstop' || name === 'resizestart' || name === 'resize' || name === 'resizestop' || name === 'dropped') {\r\n // drag&drop stop events NEED to be call them AFTER we update node attributes so handle them ourself.\r\n // do same for start event to make it easier...\r\n this._gsEventHandler[name] = callback;\r\n } else {\r\n console.log('GridStack.on(' + name + ') event not supported, but you can still use $(\".grid-stack\").on(...) while jquery-ui is still used internally.');\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * unsubscribe from the 'on' event below\r\n * @param name of the event (see possible values)\r\n */\r\n public off(name: GridStackEvent): GridStack {\r\n // check for array of names being passed instead\r\n if (name.indexOf(' ') !== -1) {\r\n let names = name.split(' ') as GridStackEvent[];\r\n names.forEach(name => this.off(name));\r\n return this;\r\n }\r\n\r\n if (name === 'change' || name === 'added' || name === 'removed' || name === 'enable' || name === 'disable') {\r\n // remove native CustomEvent handlers\r\n if (this._gsEventHandler[name]) {\r\n this.el.removeEventListener(name, this._gsEventHandler[name]);\r\n }\r\n }\r\n delete this._gsEventHandler[name];\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Removes widget from the grid.\r\n * @param el widget or selector to modify\r\n * @param removeDOM if `false` DOM element won't be removed from the tree (Default? true).\r\n * @param triggerEvent if `false` (quiet mode) element will not be added to removed list and no 'removed' callbacks will be called (Default? true).\r\n */\r\n public removeWidget(els: GridStackElement, removeDOM = true, triggerEvent = true): GridStack {\r\n GridStack.getElements(els).forEach(el => {\r\n if (el.parentElement !== this.el) return; // not our child!\r\n let node = el.gridstackNode;\r\n // For Meteor support: https://github.com/gridstack/gridstack.js/pull/272\r\n if (!node) {\r\n node = this.engine.nodes.find(n => el === n.el);\r\n }\r\n if (!node) return;\r\n\r\n // remove our DOM data (circular link) and drag&drop permanently\r\n delete el.gridstackNode;\r\n GridStackDDI.get().remove(el);\r\n\r\n this.engine.removeNode(node, removeDOM, triggerEvent);\r\n\r\n if (removeDOM && el.parentElement) {\r\n el.remove(); // in batch mode engine.removeNode doesn't call back to remove DOM\r\n }\r\n });\r\n if (triggerEvent) {\r\n this._triggerRemoveEvent();\r\n this._triggerChangeEvent();\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Removes all widgets from the grid.\r\n * @param removeDOM if `false` DOM elements won't be removed from the tree (Default? `true`).\r\n */\r\n public removeAll(removeDOM = true): GridStack {\r\n // always remove our DOM data (circular link) before list gets emptied and drag&drop permanently\r\n this.engine.nodes.forEach(n => {\r\n delete n.el.gridstackNode;\r\n GridStackDDI.get().remove(n.el);\r\n });\r\n this.engine.removeAll(removeDOM);\r\n this._triggerRemoveEvent();\r\n return this;\r\n }\r\n\r\n /**\r\n * Toggle the grid animation state. Toggles the `grid-stack-animate` class.\r\n * @param doAnimate if true the grid will animate.\r\n */\r\n public setAnimation(doAnimate: boolean): GridStack {\r\n if (doAnimate) {\r\n this.el.classList.add('grid-stack-animate');\r\n } else {\r\n this.el.classList.remove('grid-stack-animate');\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Toggle the grid static state, which permanently removes/add Drag&Drop support, unlike disable()/enable() that just turns it off/on.\r\n * Also toggle the grid-stack-static class.\r\n * @param val if true the grid become static.\r\n */\r\n public setStatic(val: boolean, updateClass = true): GridStack {\r\n if (this.opts.staticGrid === val) return this;\r\n this.opts.staticGrid = val;\r\n this._setupRemoveDrop();\r\n this._setupAcceptWidget();\r\n this.engine.nodes.forEach(n => this._prepareDragDropByNode(n)); // either delete or init Drag&drop\r\n if (updateClass) { this._setStaticClass(); }\r\n return this;\r\n }\r\n\r\n /**\r\n * Updates widget position/size and other info. Note: if you need to call this on all nodes, use load() instead which will update what changed.\r\n * @param els widget or selector of objects to modify (note: setting the same x,y for multiple items will be indeterministic and likely unwanted)\r\n * @param opt new widget options (x,y,w,h, etc..). Only those set will be updated.\r\n */\r\n public update(els: GridStackElement, opt: GridStackWidget): GridStack {\r\n\r\n // support legacy call for now ?\r\n if (arguments.length > 2) {\r\n console.warn('gridstack.ts: `update(el, x, y, w, h)` is deprecated. Use `update({x, w, content, ...})`. It will be removed soon');\r\n // eslint-disable-next-line prefer-rest-params\r\n let a = arguments, i = 1;\r\n opt = { x:a[i++], y:a[i++], w:a[i++], h:a[i++] };\r\n return this.update(els, opt);\r\n }\r\n\r\n GridStack.getElements(els).forEach(el => {\r\n if (!el || !el.gridstackNode) return;\r\n let n = el.gridstackNode;\r\n let w = Utils.cloneDeep(opt); // make a copy we can modify in case they re-use it or multiple items\r\n delete w.autoPosition;\r\n\r\n // move/resize widget if anything changed\r\n let keys = ['x', 'y', 'w', 'h'];\r\n let m: GridStackWidget;\r\n if (keys.some(k => w[k] !== undefined && w[k] !== n[k])) {\r\n m = {};\r\n keys.forEach(k => {\r\n m[k] = (w[k] !== undefined) ? w[k] : n[k];\r\n delete w[k];\r\n });\r\n }\r\n // for a move as well IFF there is any min/max fields set\r\n if (!m && (w.minW || w.minH || w.maxW || w.maxH)) {\r\n m = {}; // will use node position but validate values\r\n }\r\n\r\n // check for content changing\r\n if (w.content) {\r\n let sub = el.querySelector('.grid-stack-item-content');\r\n if (sub && sub.innerHTML !== w.content) {\r\n sub.innerHTML = w.content;\r\n }\r\n delete w.content;\r\n }\r\n\r\n // any remaining fields are assigned, but check for dragging changes, resize constrain\r\n let changed = false;\r\n let ddChanged = false;\r\n for (const key in w) {\r\n if (key[0] !== '_' && n[key] !== w[key]) {\r\n n[key] = w[key];\r\n changed = true;\r\n ddChanged = ddChanged || (!this.opts.staticGrid && (key === 'noResize' || key === 'noMove' || key === 'locked'));\r\n }\r\n }\r\n\r\n // finally move the widget\r\n if (m) {\r\n this.engine.cleanNodes()\r\n .beginUpdate(n)\r\n .moveNode(n, m);\r\n this._updateContainerHeight();\r\n this._triggerChangeEvent();\r\n this.engine.endUpdate();\r\n }\r\n if (changed) { // move will only update x,y,w,h so update the rest too\r\n this._writeAttr(el, n);\r\n }\r\n if (ddChanged) {\r\n this._prepareDragDropByNode(n);\r\n }\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Updates the margins which will set all 4 sides at once - see `GridStackOptions.margin` for format options (CSS string format of 1,2,4 values or single number).\r\n * @param value margin value\r\n */\r\n public margin(value: numberOrString): GridStack {\r\n let isMultiValue = (typeof value === 'string' && value.split(' ').length > 1);\r\n // check if we can skip re-creating our CSS file... won't check if multi values (too much hassle)\r\n if (!isMultiValue) {\r\n let data = Utils.parseHeight(value);\r\n if (this.opts.marginUnit === data.unit && this.opts.margin === data.h) return;\r\n }\r\n // re-use existing margin handling\r\n this.opts.margin = value;\r\n this.opts.marginTop = this.opts.marginBottom = this.opts.marginLeft = this.opts.marginRight = undefined;\r\n this.initMargin();\r\n\r\n this._updateStyles(true); // true = force re-create\r\n\r\n return this;\r\n }\r\n\r\n /** returns current margin number value (undefined if 4 sides don't match) */\r\n public getMargin(): number { return this.opts.margin as number; }\r\n\r\n /**\r\n * Returns true if the height of the grid will be less than the vertical\r\n * constraint. Always returns true if grid doesn't have height constraint.\r\n * @param node contains x,y,w,h,auto-position options\r\n *\r\n * @example\r\n * if (grid.willItFit(newWidget)) {\r\n * grid.addWidget(newWidget);\r\n * } else {\r\n * alert('Not enough free space to place the widget');\r\n * }\r\n */\r\n public willItFit(node: GridStackWidget): boolean {\r\n // support legacy call for now\r\n if (arguments.length > 1) {\r\n console.warn('gridstack.ts: `willItFit(x,y,w,h,autoPosition)` is deprecated. Use `willItFit({x, y,...})`. It will be removed soon');\r\n // eslint-disable-next-line prefer-rest-params\r\n let a = arguments, i = 0,\r\n w: GridStackWidget = { x:a[i++], y:a[i++], w:a[i++], h:a[i++], autoPosition:a[i++] };\r\n return this.willItFit(w);\r\n }\r\n return this.engine.willItFit(node);\r\n }\r\n\r\n /** @internal */\r\n private _triggerChangeEvent(): GridStack {\r\n if (this.engine.batchMode) return this;\r\n let elements = this.engine.getDirtyNodes(true); // verify they really changed\r\n if (elements && elements.length) {\r\n if (!this._ignoreLayoutsNodeChange) {\r\n this.engine.layoutsNodesChange(elements);\r\n }\r\n this._triggerEvent('change', elements);\r\n }\r\n this.engine.saveInitial(); // we called, now reset initial values & dirty flags\r\n return this;\r\n }\r\n\r\n /** @internal */\r\n private _triggerAddEvent(): GridStack {\r\n if (this.engine.batchMode) return this;\r\n if (this.engine.addedNodes && this.engine.addedNodes.length > 0) {\r\n if (!this._ignoreLayoutsNodeChange) {\r\n this.engine.layoutsNodesChange(this.engine.addedNodes);\r\n }\r\n // prevent added nodes from also triggering 'change' event (which is called next)\r\n this.engine.addedNodes.forEach(n => { delete n._dirty; });\r\n this._triggerEvent('added', this.engine.addedNodes);\r\n this.engine.addedNodes = [];\r\n }\r\n return this;\r\n }\r\n\r\n /** @internal */\r\n public _triggerRemoveEvent(): GridStack {\r\n if (this.engine.batchMode) return this;\r\n if (this.engine.removedNodes && this.engine.removedNodes.length > 0) {\r\n this._triggerEvent('removed', this.engine.removedNodes);\r\n this.engine.removedNodes = [];\r\n }\r\n return this;\r\n }\r\n\r\n /** @internal */\r\n private _triggerEvent(name: string, data?: GridStackNode[]): GridStack {\r\n let event = data ? new CustomEvent(name, {bubbles: false, detail: data}) : new Event(name);\r\n this.el.dispatchEvent(event);\r\n return this;\r\n }\r\n\r\n /** @internal called to delete the current dynamic style sheet used for our layout */\r\n private _removeStylesheet(): GridStack {\r\n\r\n if (this._styles) {\r\n Utils.removeStylesheet(this._styles._id);\r\n delete this._styles;\r\n }\r\n return this;\r\n }\r\n\r\n /** @internal updated/create the CSS styles for row based layout and initial margin setting */\r\n private _updateStyles(forceUpdate = false, maxH?: number): GridStack {\r\n // call to delete existing one if we change cellHeight / margin\r\n if (forceUpdate) {\r\n this._removeStylesheet();\r\n }\r\n\r\n this._updateContainerHeight();\r\n\r\n // if user is telling us they will handle the CSS themselves by setting heights to 0. Do we need this opts really ??\r\n if (this.opts.cellHeight === 0) {\r\n return this;\r\n }\r\n\r\n let cellHeight = this.opts.cellHeight as number;\r\n let cellHeightUnit = this.opts.cellHeightUnit;\r\n let prefix = `.${this.opts._styleSheetClass} > .${this.opts.itemClass}`;\r\n\r\n // create one as needed\r\n if (!this._styles) {\r\n let id = 'gridstack-style-' + (Math.random() * 100000).toFixed();\r\n // insert style to parent (instead of 'head' by default) to support WebComponent\r\n let styleLocation = this.opts.styleInHead ? undefined : this.el.parentNode as HTMLElement;\r\n this._styles = Utils.createStylesheet(id, styleLocation);\r\n if (!this._styles) return this;\r\n this._styles._id = id;\r\n this._styles._max = 0;\r\n\r\n // these are done once only\r\n Utils.addCSSRule(this._styles, prefix, `min-height: ${cellHeight}${cellHeightUnit}`);\r\n // content margins\r\n let top: string = this.opts.marginTop + this.opts.marginUnit;\r\n let bottom: string = this.opts.marginBottom + this.opts.marginUnit;\r\n let right: string = this.opts.marginRight + this.opts.marginUnit;\r\n let left: string = this.opts.marginLeft + this.opts.marginUnit;\r\n let content = `${prefix} > .grid-stack-item-content`;\r\n let placeholder = `.${this.opts._styleSheetClass} > .grid-stack-placeholder > .placeholder-content`;\r\n Utils.addCSSRule(this._styles, content, `top: ${top}; right: ${right}; bottom: ${bottom}; left: ${left};`);\r\n Utils.addCSSRule(this._styles, placeholder, `top: ${top}; right: ${right}; bottom: ${bottom}; left: ${left};`);\r\n // resize handles offset (to match margin)\r\n Utils.addCSSRule(this._styles, `${prefix} > .ui-resizable-ne`, `right: ${right}`);\r\n Utils.addCSSRule(this._styles, `${prefix} > .ui-resizable-e`, `right: ${right}`);\r\n Utils.addCSSRule(this._styles, `${prefix} > .ui-resizable-se`, `right: ${right}; bottom: ${bottom}`);\r\n Utils.addCSSRule(this._styles, `${prefix} > .ui-resizable-nw`, `left: ${left}`);\r\n Utils.addCSSRule(this._styles, `${prefix} > .ui-resizable-w`, `left: ${left}`);\r\n Utils.addCSSRule(this._styles, `${prefix} > .ui-resizable-sw`, `left: ${left}; bottom: ${bottom}`);\r\n }\r\n\r\n // now update the height specific fields\r\n maxH = maxH || this._styles._max;\r\n if (maxH > this._styles._max) {\r\n let getHeight = (rows: number): string => (cellHeight * rows) + cellHeightUnit;\r\n for (let i = this._styles._max + 1; i <= maxH; i++) { // start at 1\r\n let h: string = getHeight(i);\r\n Utils.addCSSRule(this._styles, `${prefix}[gs-y=\"${i-1}\"]`, `top: ${getHeight(i-1)}`); // start at 0\r\n Utils.addCSSRule(this._styles, `${prefix}[gs-h=\"${i}\"]`, `height: ${h}`);\r\n Utils.addCSSRule(this._styles, `${prefix}[gs-min-h=\"${i}\"]`, `min-height: ${h}`);\r\n Utils.addCSSRule(this._styles, `${prefix}[gs-max-h=\"${i}\"]`, `max-height: ${h}`);\r\n }\r\n this._styles._max = maxH;\r\n }\r\n return this;\r\n }\r\n\r\n /** @internal */\r\n private _updateContainerHeight(): GridStack {\r\n if (!this.engine || this.engine.batchMode) return this;\r\n let row = this.getRow() + this._extraDragRow; // checks for minRow already\r\n // check for css min height\r\n let cssMinHeight = parseInt(getComputedStyle(this.el)['min-height']);\r\n if (cssMinHeight > 0) {\r\n let minRow = Math.round(cssMinHeight / this.getCellHeight(true));\r\n if (row < minRow) {\r\n row = minRow;\r\n }\r\n }\r\n this.el.setAttribute('gs-current-row', String(row));\r\n if (row === 0) {\r\n this.el.style.removeProperty('height');\r\n return this;\r\n }\r\n let cellHeight = this.opts.cellHeight as number;\r\n let unit = this.opts.cellHeightUnit;\r\n if (!cellHeight) return this;\r\n this.el.style.height = row * cellHeight + unit;\r\n return this;\r\n }\r\n\r\n /** @internal */\r\n private _prepareElement(el: GridItemHTMLElement, triggerAddEvent = false, node?: GridStackNode): GridStack {\r\n if (!node) {\r\n el.classList.add(this.opts.itemClass);\r\n node = this._readAttr(el);\r\n }\r\n el.gridstackNode = node;\r\n node.el = el;\r\n node.grid = this;\r\n let copy = {...node};\r\n node = this.engine.addNode(node, triggerAddEvent);\r\n // write node attr back in case there was collision or we have to fix bad values during addNode()\r\n if (!Utils.same(node, copy)) {\r\n this._writeAttr(el, node);\r\n }\r\n this._prepareDragDropByNode(node);\r\n return this;\r\n }\r\n\r\n /** @internal call to write position x,y,w,h attributes back to element */\r\n private _writePosAttr(el: HTMLElement, n: GridStackPosition): GridStack {\r\n if (n.x !== undefined && n.x !== null) { el.setAttribute('gs-x', String(n.x)); }\r\n if (n.y !== undefined && n.y !== null) { el.setAttribute('gs-y', String(n.y)); }\r\n if (n.w) { el.setAttribute('gs-w', String(n.w)); }\r\n if (n.h) { el.setAttribute('gs-h', String(n.h)); }\r\n return this;\r\n }\r\n\r\n /** @internal call to write any default attributes back to element */\r\n private _writeAttr(el: HTMLElement, node: GridStackWidget): GridStack {\r\n if (!node) return this;\r\n this._writePosAttr(el, node);\r\n\r\n let attrs /*: GridStackWidget but strings */ = { // remaining attributes\r\n autoPosition: 'gs-auto-position',\r\n minW: 'gs-min-w',\r\n minH: 'gs-min-h',\r\n maxW: 'gs-max-w',\r\n maxH: 'gs-max-h',\r\n noResize: 'gs-no-resize',\r\n noMove: 'gs-no-move',\r\n locked: 'gs-locked',\r\n id: 'gs-id',\r\n resizeHandles: 'gs-resize-handles'\r\n };\r\n for (const key in attrs) {\r\n if (node[key]) { // 0 is valid for x,y only but done above already and not in list anyway\r\n el.setAttribute(attrs[key], String(node[key]));\r\n } else {\r\n el.removeAttribute(attrs[key]);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n /** @internal call to read any default attributes from element */\r\n private _readAttr(el: HTMLElement): GridStackWidget {\r\n let node: GridStackNode = {};\r\n node.x = Utils.toNumber(el.getAttribute('gs-x'));\r\n node.y = Utils.toNumber(el.getAttribute('gs-y'));\r\n node.w = Utils.toNumber(el.getAttribute('gs-w'));\r\n node.h = Utils.toNumber(el.getAttribute('gs-h'));\r\n node.maxW = Utils.toNumber(el.getAttribute('gs-max-w'));\r\n node.minW = Utils.toNumber(el.getAttribute('gs-min-w'));\r\n node.maxH = Utils.toNumber(el.getAttribute('gs-max-h'));\r\n node.minH = Utils.toNumber(el.getAttribute('gs-min-h'));\r\n node.autoPosition = Utils.toBool(el.getAttribute('gs-auto-position'));\r\n node.noResize = Utils.toBool(el.getAttribute('gs-no-resize'));\r\n node.noMove = Utils.toBool(el.getAttribute('gs-no-move'));\r\n node.locked = Utils.toBool(el.getAttribute('gs-locked'));\r\n node.resizeHandles = el.getAttribute('gs-resize-handles');\r\n node.id = el.getAttribute('gs-id');\r\n\r\n // remove any key not found (null or false which is default)\r\n for (const key in node) {\r\n if (!node.hasOwnProperty(key)) return;\r\n if (!node[key] && node[key] !== 0) { // 0 can be valid value (x,y only really)\r\n delete node[key];\r\n }\r\n }\r\n\r\n return node;\r\n }\r\n\r\n /** @internal */\r\n private _setStaticClass(): GridStack {\r\n let classes = ['grid-stack-static'];\r\n\r\n if (this.opts.staticGrid) {\r\n this.el.classList.add(...classes);\r\n this.el.setAttribute('gs-static', 'true');\r\n } else {\r\n this.el.classList.remove(...classes);\r\n this.el.removeAttribute('gs-static');\r\n\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * called when we are being resized by the window - check if the one Column Mode needs to be turned on/off\r\n * and remember the prev columns we used, as well as check for auto cell height (square)\r\n */\r\n public onParentResize(): GridStack {\r\n if (!this.el || !this.el.clientWidth) return; // return if we're gone or no size yet (will get called again)\r\n let oneColumn = !this.opts.disableOneColumnMode && this.el.clientWidth <= this.opts.minWidth;\r\n let changedOneColumn = false;\r\n\r\n if ((this.opts.column === 1) !== oneColumn) {\r\n changedOneColumn = true;\r\n if (this.opts.animate) { this.setAnimation(false); } // 1 <-> 12 is too radical, turn off animation\r\n this.column(oneColumn ? 1 : this._prevColumn);\r\n if (this.opts.animate) { this.setAnimation(true); }\r\n }\r\n\r\n // make the cells content square again\r\n if (this._isAutoCellHeight) {\r\n if (!changedOneColumn && this.opts.cellHeightThrottle) {\r\n if (!this._cellHeightThrottle) {\r\n this._cellHeightThrottle = Utils.throttle(() => this.cellHeight(), this.opts.cellHeightThrottle);\r\n }\r\n this._cellHeightThrottle();\r\n } else {\r\n // immediate update if we've changed to/from oneColumn or have no threshold\r\n this.cellHeight();\r\n }\r\n }\r\n\r\n // finally update any nested grids\r\n this.engine.nodes.forEach(n => {\r\n if (n.subGrid) {(n.subGrid as GridStack).onParentResize()}\r\n });\r\n\r\n return this;\r\n }\r\n\r\n /** add or remove the window size event handler */\r\n private _updateWindowResizeEvent(forceRemove = false): GridStack {\r\n // only add event if we're not nested (parent will call us) and we're auto sizing cells or supporting oneColumn (i.e. doing work)\r\n const workTodo = (this._isAutoCellHeight || !this.opts.disableOneColumnMode) && !this.opts._isNested;\r\n\r\n if (!forceRemove && workTodo && !this._windowResizeBind) {\r\n this._windowResizeBind = this.onParentResize.bind(this); // so we can properly remove later\r\n window.addEventListener('resize', this._windowResizeBind);\r\n } else if ((forceRemove || !workTodo) && this._windowResizeBind) {\r\n window.removeEventListener('resize', this._windowResizeBind);\r\n delete this._windowResizeBind; // remove link to us so we can free\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /** @internal convert a potential selector into actual element */\r\n public static getElement(els: GridStackElement = '.grid-stack-item'): GridItemHTMLElement { return Utils.getElement(els) }\r\n /** @internal */\r\n public static getElements(els: GridStackElement = '.grid-stack-item'): GridItemHTMLElement[] { return Utils.getElements(els) }\r\n /** @internal */\r\n public static getGridElement(els: GridStackElement): GridHTMLElement { return GridStack.getElement(els) }\r\n /** @internal */\r\n public static getGridElements(els: string): GridHTMLElement[] { return Utils.getElements(els) }\r\n\r\n /** @internal initialize margin top/bottom/left/right and units */\r\n private initMargin(): GridStack {\r\n\r\n let data: HeightData;\r\n let margin = 0;\r\n\r\n // support passing multiple values like CSS (ex: '5px 10px 0 20px')\r\n let margins: string[] = [];\r\n if (typeof this.opts.margin === 'string') {\r\n margins = this.opts.margin.split(' ')\r\n }\r\n if (margins.length === 2) { // top/bot, left/right like CSS\r\n this.opts.marginTop = this.opts.marginBottom = margins[0];\r\n this.opts.marginLeft = this.opts.marginRight = margins[1];\r\n } else if (margins.length === 4) { // Clockwise like CSS\r\n this.opts.marginTop = margins[0];\r\n this.opts.marginRight = margins[1];\r\n this.opts.marginBottom = margins[2];\r\n this.opts.marginLeft = margins[3];\r\n } else {\r\n data = Utils.parseHeight(this.opts.margin);\r\n this.opts.marginUnit = data.unit;\r\n margin = this.opts.margin = data.h;\r\n }\r\n\r\n // see if top/bottom/left/right need to be set as well\r\n if (this.opts.marginTop === undefined) {\r\n this.opts.marginTop = margin;\r\n } else {\r\n data = Utils.parseHeight(this.opts.marginTop);\r\n this.opts.marginTop = data.h;\r\n delete this.opts.margin;\r\n }\r\n\r\n if (this.opts.marginBottom === undefined) {\r\n this.opts.marginBottom = margin;\r\n } else {\r\n data = Utils.parseHeight(this.opts.marginBottom);\r\n this.opts.marginBottom = data.h;\r\n delete this.opts.margin;\r\n }\r\n\r\n if (this.opts.marginRight === undefined) {\r\n this.opts.marginRight = margin;\r\n } else {\r\n data = Utils.parseHeight(this.opts.marginRight);\r\n this.opts.marginRight = data.h;\r\n delete this.opts.margin;\r\n }\r\n\r\n if (this.opts.marginLeft === undefined) {\r\n this.opts.marginLeft = margin;\r\n } else {\r\n data = Utils.parseHeight(this.opts.marginLeft);\r\n this.opts.marginLeft = data.h;\r\n delete this.opts.margin;\r\n }\r\n this.opts.marginUnit = data.unit; // in case side were spelled out, use those units instead...\r\n if (this.opts.marginTop === this.opts.marginBottom && this.opts.marginLeft === this.opts.marginRight && this.opts.marginTop === this.opts.marginRight) {\r\n this.opts.margin = this.opts.marginTop; // makes it easier to check for no-ops in setMargin()\r\n }\r\n return this;\r\n }\r\n\r\n /*\r\n * drag&drop empty stubs that will be implemented in gridstack-dd.ts for non static grid\r\n * so we don't incur the load unless needed.\r\n * NOTE: had to make those methods public in order to define them else as\r\n * GridStack.prototype._setupAcceptWidget = function()\r\n * maybe there is a better way ????\r\n */\r\n /* eslint-disable @typescript-eslint/no-unused-vars */\r\n\r\n /**\r\n * call to setup dragging in from the outside (say toolbar), by specifying the class selection and options.\r\n * Called during GridStack.init() as options, but can also be called directly (last param are cached) in case the toolbar\r\n * is dynamically create and needs to change later.\r\n * @param dragIn string selector (ex: '.sidebar .grid-stack-item')\r\n * @param dragInOptions options - see DDDragInOpt. (default: {revert: 'invalid', handle: '.grid-stack-item-content', scroll: false, appendTo: 'body'}\r\n **/\r\n public static setupDragIn(dragIn?: string, dragInOptions?: DDDragInOpt): void { /* implemented in gridstack-dd.ts */ }\r\n\r\n /**\r\n * Enables/Disables dragging by the user of specific grid element. If you want all items, and have it affect future items, use enableMove() instead. No-op for static grids.\r\n * IF you are looking to prevent an item from moving (due to being pushed around by another during collision) use locked property instead.\r\n * @param els widget or selector to modify.\r\n * @param val if true widget will be draggable.\r\n */\r\n public movable(els: GridStackElement, val: boolean): GridStack { return this }\r\n /**\r\n * Enables/Disables user resizing of specific grid element. If you want all items, and have it affect future items, use enableResize() instead. No-op for static grids.\r\n * @param els widget or selector to modify\r\n * @param val if true widget will be resizable.\r\n */\r\n public resizable(els: GridStackElement, val: boolean): GridStack { return this }\r\n /**\r\n * Temporarily disables widgets moving/resizing.\r\n * If you want a more permanent way (which freezes up resources) use `setStatic(true)` instead.\r\n * Note: no-op for static grid\r\n * This is a shortcut for:\r\n * @example\r\n * grid.enableMove(false);\r\n * grid.enableResize(false);\r\n */\r\n public disable(): GridStack { return this }\r\n /**\r\n * Re-enables widgets moving/resizing - see disable().\r\n * Note: no-op for static grid.\r\n * This is a shortcut for:\r\n * @example\r\n * grid.enableMove(true);\r\n * grid.enableResize(true);\r\n */\r\n public enable(): GridStack { return this }\r\n /**\r\n * Enables/disables widget moving. No-op for static grids.\r\n */\r\n public enableMove(doEnable: boolean): GridStack { return this }\r\n /**\r\n * Enables/disables widget resizing. No-op for static grids.\r\n */\r\n public enableResize(doEnable: boolean): GridStack { return this }\r\n\r\n /** @internal called to add drag over support to support widgets */\r\n public _setupAcceptWidget(): GridStack { return this }\r\n /** @internal called to setup a trash drop zone if the user specifies it */\r\n public _setupRemoveDrop(): GridStack { return this }\r\n /** @internal prepares the element for drag&drop **/\r\n public _prepareDragDropByNode(node: GridStackNode): GridStack { return this }\r\n /** @internal handles actual drag/resize start **/\r\n public _onStartMoving(el: GridItemHTMLElement, event: Event, ui: DDUIData, node: GridStackNode, cellWidth: number, cellHeight: number): void { return }\r\n /** @internal handles actual drag/resize **/\r\n public _dragOrResize(el: GridItemHTMLElement, event: Event, ui: DDUIData, node: GridStackNode, cellWidth: number, cellHeight: number): void { return }\r\n /** @internal called when a node leaves our area (mouse out or shape outside) **/\r\n public _leave(el: GridItemHTMLElement, helper?: GridItemHTMLElement): void { return }\r\n}\r\n","/**\n * dd-base-impl.ts 4.2.6\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\n */\n\nexport type EventCallback = (event: Event) => boolean|void;\nexport abstract class DDBaseImplement {\n /** returns the enable state, but you have to call enable()/disable() to change (as other things need to happen) */\n public get disabled(): boolean { return this._disabled; }\n\n /** @internal */\n private _disabled = false;\n /** @internal */\n private _eventRegister: {\n [eventName: string]: EventCallback;\n } = {};\n\n public on(event: string, callback: EventCallback): void {\n this._eventRegister[event] = callback;\n }\n\n public off(event: string): void {\n delete this._eventRegister[event];\n }\n\n public enable(): void {\n this._disabled = false;\n }\n\n public disable(): void {\n this._disabled = true;\n }\n\n public destroy(): void {\n delete this._eventRegister;\n }\n\n public triggerEvent(eventName: string, event: Event): boolean|void {\n if (!this.disabled && this._eventRegister && this._eventRegister[eventName])\n return this._eventRegister[eventName](event);\n }\n}\n\nexport interface HTMLElementExtendOpt {\n el: HTMLElement;\n option: T;\n updateOption(T): DDBaseImplement;\n}\n","/**\n * dd-draggable.ts 4.2.6\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\n */\n\nimport { DDManager } from './dd-manager';\nimport { DDUtils } from './dd-utils';\nimport { DDBaseImplement, HTMLElementExtendOpt } from './dd-base-impl';\nimport { GridItemHTMLElement, DDUIData } from '../types';\n\n// TODO: merge with DDDragOpt ?\nexport interface DDDraggableOpt {\n appendTo?: string | HTMLElement;\n containment?: string | HTMLElement; // TODO: not implemented yet\n handle?: string;\n revert?: string | boolean | unknown; // TODO: not implemented yet\n scroll?: boolean; // nature support by HTML5 drag drop, can't be switch to off actually\n helper?: string | HTMLElement | ((event: Event) => HTMLElement);\n basePosition?: 'fixed' | 'absolute';\n start?: (event: Event, ui: DDUIData) => void;\n stop?: (event: Event) => void;\n drag?: (event: Event, ui: DDUIData) => void;\n}\n\ninterface DragOffset {\n left: number;\n top: number;\n width: number;\n height: number;\n offsetLeft: number;\n offsetTop: number;\n}\n\nexport class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt {\n public el: HTMLElement;\n public option: DDDraggableOpt;\n public helper: HTMLElement; // used by GridStackDDNative\n\n /** @internal */\n private dragOffset: DragOffset;\n /** @internal */\n private dragElementOriginStyle: Array;\n /** @internal */\n private dragFollowTimer: number;\n /** @internal */\n private dragEl: HTMLElement;\n /** @internal */\n private dragging = false;\n /** @internal */\n private paintTimer: number;\n /** @internal */\n private parentOriginStylePosition: string;\n /** @internal */\n private helperContainment: HTMLElement;\n /** @internal */\n private static basePosition: 'fixed' | 'absolute' = 'absolute';\n /** @internal #1541 can't have {passive: true} on Safari as otherwise it reverts animate back to old location on drop */\n private static dragEventListenerOption = true; // DDUtils.isEventSupportPassiveOption ? { capture: true, passive: true } : true;\n /** @internal */\n private static originStyleProp = ['transition', 'pointerEvents', 'position',\n 'left', 'top', 'opacity', 'zIndex', 'width', 'height', 'willChange'];\n\n constructor(el: HTMLElement, option: DDDraggableOpt = {}) {\n super();\n this.el = el;\n this.option = option;\n // get the element that is actually supposed to be dragged by\n let className = option.handle.substring(1);\n this.dragEl = el.classList.contains(className) ? el : el.querySelector(option.handle) || el;\n // create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)\n this._dragStart = this._dragStart.bind(this);\n this._drag = this._drag.bind(this);\n this._dragEnd = this._dragEnd.bind(this);\n this.enable();\n }\n\n public on(event: 'drag' | 'dragstart' | 'dragstop', callback: (event: DragEvent) => void): void {\n super.on(event, callback);\n }\n\n public off(event: 'drag' | 'dragstart' | 'dragstop'): void {\n super.off(event);\n }\n\n public enable(): void {\n super.enable();\n this.dragEl.draggable = true;\n this.dragEl.addEventListener('dragstart', this._dragStart);\n this.el.classList.remove('ui-draggable-disabled');\n this.el.classList.add('ui-draggable');\n }\n\n public disable(forDestroy = false): void {\n super.disable();\n this.dragEl.removeAttribute('draggable');\n this.dragEl.removeEventListener('dragstart', this._dragStart);\n this.el.classList.remove('ui-draggable');\n if (!forDestroy) this.el.classList.add('ui-draggable-disabled');\n }\n\n public destroy(): void {\n if (this.dragging) {\n // Destroy while dragging should remove dragend listener and manually trigger\n // dragend, otherwise dragEnd can't perform dragstop because eventRegistry is\n // destroyed.\n this._dragEnd({} as DragEvent);\n }\n this.disable(true);\n delete this.el;\n delete this.helper;\n delete this.option;\n super.destroy();\n }\n\n public updateOption(opts: DDDraggableOpt): DDDraggable {\n Object.keys(opts).forEach(key => this.option[key] = opts[key]);\n return this;\n }\n\n /** @internal */\n private _dragStart(event: DragEvent): void {\n DDManager.dragElement = this;\n this.helper = this._createHelper(event);\n this._setupHelperContainmentStyle();\n this.dragOffset = this._getDragOffset(event, this.el, this.helperContainment);\n const ev = DDUtils.initEvent(event, { target: this.el, type: 'dragstart' });\n if (this.helper !== this.el) {\n this._setupDragFollowNodeNotifyStart(ev);\n // immediately set external helper initial position to avoid flickering behavior and unnecessary looping in `_packNodes()`\n this._dragFollow(event);\n } else {\n this.dragFollowTimer = window.setTimeout(() => {\n delete this.dragFollowTimer;\n this._setupDragFollowNodeNotifyStart(ev);\n }, 0);\n }\n this._cancelDragGhost(event);\n }\n\n /** @internal */\n private _setupDragFollowNodeNotifyStart(ev: Event): DDDraggable {\n this._setupHelperStyle();\n document.addEventListener('dragover', this._drag, DDDraggable.dragEventListenerOption);\n this.dragEl.addEventListener('dragend', this._dragEnd);\n if (this.option.start) {\n this.option.start(ev, this.ui());\n }\n this.dragging = true;\n this.helper.classList.add('ui-draggable-dragging');\n this.triggerEvent('dragstart', ev);\n return this;\n }\n\n /** @internal */\n private _drag(event: DragEvent): void {\n // Safari: prevent default to allow drop to happen instead of reverting back (with animation) and delaying dragend #1541\n // https://stackoverflow.com/questions/61760755/how-to-fire-dragend-event-immediately\n event.preventDefault();\n this._dragFollow(event);\n const ev = DDUtils.initEvent(event, { target: this.el, type: 'drag' });\n if (this.option.drag) {\n this.option.drag(ev, this.ui());\n }\n this.triggerEvent('drag', ev);\n }\n\n /** @internal */\n private _dragEnd(event: DragEvent): void {\n if (this.dragFollowTimer) {\n clearTimeout(this.dragFollowTimer);\n delete this.dragFollowTimer;\n return;\n } else {\n if (this.paintTimer) {\n cancelAnimationFrame(this.paintTimer);\n }\n document.removeEventListener('dragover', this._drag, DDDraggable.dragEventListenerOption);\n this.dragEl.removeEventListener('dragend', this._dragEnd);\n }\n this.dragging = false;\n this.helper.classList.remove('ui-draggable-dragging');\n this.helperContainment.style.position = this.parentOriginStylePosition || null;\n if (this.helper === this.el) {\n this._removeHelperStyle();\n } else {\n this.helper.remove();\n }\n const ev = DDUtils.initEvent(event, { target: this.el, type: 'dragstop' });\n if (this.option.stop) {\n this.option.stop(ev); // Note: ui() not used by gridstack so don't pass\n }\n this.triggerEvent('dragstop', ev);\n delete DDManager.dragElement;\n delete this.helper;\n }\n\n /** @internal create a clone copy (or user defined method) of the original drag item if set */\n private _createHelper(event: DragEvent): HTMLElement {\n let helper = this.el;\n if (typeof this.option.helper === 'function') {\n helper = this.option.helper(event);\n } else if (this.option.helper === 'clone') {\n helper = DDUtils.clone(this.el);\n }\n if (!document.body.contains(helper)) {\n DDUtils.appendTo(helper, this.option.appendTo === 'parent' ? this.el.parentNode : this.option.appendTo);\n }\n if (helper === this.el) {\n this.dragElementOriginStyle = DDDraggable.originStyleProp.map(prop => this.el.style[prop]);\n }\n return helper;\n }\n\n /** @internal */\n private _setupHelperStyle(): DDDraggable {\n this.helper.style.pointerEvents = 'none';\n this.helper.style.width = this.dragOffset.width + 'px';\n this.helper.style.height = this.dragOffset.height + 'px';\n this.helper.style.willChange = 'left, top';\n this.helper.style.transition = 'none'; // show up instantly\n this.helper.style.position = this.option.basePosition || DDDraggable.basePosition;\n this.helper.style.zIndex = '1000';\n setTimeout(() => {\n if (this.helper) {\n this.helper.style.transition = null; // recover animation\n }\n }, 0);\n return this;\n }\n\n /** @internal */\n private _removeHelperStyle(): DDDraggable {\n // don't bother restoring styles if we're gonna remove anyway...\n let node = this.helper ? (this.helper as GridItemHTMLElement).gridstackNode : undefined;\n if (!node || !node._isAboutToRemove) {\n DDDraggable.originStyleProp.forEach(prop => {\n this.helper.style[prop] = this.dragElementOriginStyle[prop] || null;\n });\n }\n delete this.dragElementOriginStyle;\n return this;\n }\n\n /** @internal */\n private _dragFollow(event: DragEvent): void {\n if (this.paintTimer) {\n cancelAnimationFrame(this.paintTimer);\n }\n this.paintTimer = requestAnimationFrame(() => {\n delete this.paintTimer;\n const offset = this.dragOffset;\n let containmentRect = { left: 0, top: 0 };\n if (this.helper.style.position === 'absolute') {\n const { left, top } = this.helperContainment.getBoundingClientRect();\n containmentRect = { left, top };\n }\n this.helper.style.left = event.clientX + offset.offsetLeft - containmentRect.left + 'px';\n this.helper.style.top = event.clientY + offset.offsetTop - containmentRect.top + 'px';\n });\n }\n\n /** @internal */\n private _setupHelperContainmentStyle(): DDDraggable {\n this.helperContainment = this.helper.parentElement;\n if (this.option.basePosition !== 'fixed') {\n this.parentOriginStylePosition = this.helperContainment.style.position;\n if (window.getComputedStyle(this.helperContainment).position.match(/static/)) {\n this.helperContainment.style.position = 'relative';\n }\n }\n return this;\n }\n\n /** @internal prevent the default gost image to be created (which has wrongas we move the helper/element instead\n * (legacy jquery UI code updates the top/left of the item).\n * TODO: maybe use mouse event instead of HTML5 drag as we have to work around it anyway, or change code to not update\n * the actual grid-item but move the gost image around (and special case jq version) ?\n **/\n private _cancelDragGhost(e: DragEvent): DDDraggable {\n /* doesn't seem to do anything...\n let t = e.dataTransfer;\n t.effectAllowed = 'none';\n t.dropEffect = 'none';\n t.setData('text', '');\n */\n\n // NOTE: according to spec (and required by Safari see #1540) the image has to be visible in the browser (in dom and not hidden) so make it a 1px div\n let img = document.createElement('div');\n img.style.width = '1px';\n img.style.height = '1px';\n img.style.position = 'fixed'; // prevent unwanted scrollbar\n document.body.appendChild(img);\n e.dataTransfer.setDragImage(img, 0, 0);\n setTimeout(() => document.body.removeChild(img)); // nuke once drag had a chance to grab this 'image'\n\n e.stopPropagation();\n return this;\n }\n\n /** @internal */\n private _getDragOffset(event: DragEvent, el: HTMLElement, parent: HTMLElement): DragOffset {\n\n // in case ancestor has transform/perspective css properties that change the viewpoint\n let xformOffsetX = 0;\n let xformOffsetY = 0;\n if (parent) {\n const testEl = document.createElement('div');\n DDUtils.addElStyles(testEl, {\n opacity: '0',\n position: 'fixed',\n top: 0 + 'px',\n left: 0 + 'px',\n width: '1px',\n height: '1px',\n zIndex: '-999999',\n });\n parent.appendChild(testEl);\n const testElPosition = testEl.getBoundingClientRect();\n parent.removeChild(testEl);\n xformOffsetX = testElPosition.left;\n xformOffsetY = testElPosition.top;\n // TODO: scale ?\n }\n\n const targetOffset = el.getBoundingClientRect();\n return {\n left: targetOffset.left,\n top: targetOffset.top,\n offsetLeft: - event.clientX + targetOffset.left - xformOffsetX,\n offsetTop: - event.clientY + targetOffset.top - xformOffsetY,\n width: targetOffset.width,\n height: targetOffset.height\n };\n }\n\n /** @internal TODO: set to public as called by DDDroppable! */\n public ui = (): DDUIData => {\n const containmentEl = this.el.parentElement;\n const containmentRect = containmentEl.getBoundingClientRect();\n const offset = this.helper.getBoundingClientRect();\n return {\n position: { //Current CSS position of the helper as { top, left } object\n top: offset.top - containmentRect.top,\n left: offset.left - containmentRect.left\n }\n /* not used by GridStack for now...\n helper: [this.helper], //The object arr representing the helper that's being dragged.\n offset: { top: offset.top, left: offset.left } // Current offset position of the helper as { top, left } object.\n */\n };\n }\n}\n\n\n","/**\n * dd-droppable.ts 4.2.6\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\n */\n\nimport { DDDraggable } from './dd-draggable';\nimport { DDManager } from './dd-manager';\nimport { DDBaseImplement, HTMLElementExtendOpt } from './dd-base-impl';\nimport { DDUtils } from './dd-utils';\n\nexport interface DDDroppableOpt {\n accept?: string | ((el: HTMLElement) => boolean);\n drop?: (event: DragEvent, ui) => void;\n over?: (event: DragEvent, ui) => void;\n out?: (event: DragEvent, ui) => void;\n}\n\nexport class DDDroppable extends DDBaseImplement implements HTMLElementExtendOpt {\n\n public accept: (el: HTMLElement) => boolean;\n public el: HTMLElement;\n public option: DDDroppableOpt;\n\n /** @internal */\n private moving: boolean;\n\n constructor(el: HTMLElement, opts: DDDroppableOpt = {}) {\n super();\n this.el = el;\n this.option = opts;\n // create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)\n this._dragEnter = this._dragEnter.bind(this);\n this._dragOver = this._dragOver.bind(this);\n this._dragLeave = this._dragLeave.bind(this);\n this._drop = this._drop.bind(this);\n\n this.el.classList.add('ui-droppable');\n this.el.addEventListener('dragenter', this._dragEnter);\n this._setupAccept();\n }\n\n public on(event: 'drop' | 'dropover' | 'dropout', callback: (event: DragEvent) => void): void {\n super.on(event, callback);\n }\n\n public off(event: 'drop' | 'dropover' | 'dropout'): void {\n super.off(event);\n }\n\n public enable(): void {\n if (!this.disabled) return;\n super.enable();\n this.el.classList.remove('ui-droppable-disabled');\n this.el.addEventListener('dragenter', this._dragEnter);\n }\n\n public disable(forDestroy=false): void {\n if (this.disabled) return;\n super.disable();\n if (!forDestroy) this.el.classList.add('ui-droppable-disabled');\n this.el.removeEventListener('dragenter', this._dragEnter);\n }\n\n public destroy(): void {\n if (this.moving) {\n this._removeLeaveCallbacks();\n } \n this.disable(true);\n this.el.classList.remove('ui-droppable');\n this.el.classList.remove('ui-droppable-disabled');\n delete this.moving;\n super.destroy();\n }\n\n public updateOption(opts: DDDroppableOpt): DDDroppable {\n Object.keys(opts).forEach(key => this.option[key] = opts[key]);\n this._setupAccept();\n return this;\n }\n\n /** @internal called when the cursor enters our area - prepare for a possible drop and track leaving */\n private _dragEnter(event: DragEvent): void {\n if (!this._canDrop()) return;\n event.preventDefault();\n\n if (this.moving) return; // ignore multiple 'dragenter' as we go over existing items\n this.moving = true;\n\n const ev = DDUtils.initEvent(event, { target: this.el, type: 'dropover' });\n if (this.option.over) {\n this.option.over(ev, this._ui(DDManager.dragElement))\n }\n this.triggerEvent('dropover', ev);\n this.el.addEventListener('dragover', this._dragOver);\n this.el.addEventListener('drop', this._drop);\n this.el.addEventListener('dragleave', this._dragLeave);\n this.el.classList.add('ui-droppable-over');\n }\n\n /** @internal called when an moving to drop item is being dragged over - do nothing but eat the event */\n private _dragOver(event: DragEvent): void {\n event.preventDefault();\n event.stopPropagation();\n }\n\n /** @internal called when the item is leaving our area, stop tracking if we had moving item */\n private _dragLeave(event: DragEvent): void {\n\n // ignore leave events on our children (get when starting to drag our items)\n // Note: Safari Mac has null relatedTarget which causes #1684 so check if DragEvent is inside the grid instead\n if (!event.relatedTarget) {\n const { bottom, left, right, top } = this.el.getBoundingClientRect();\n if (event.x < right && event.x > left && event.y < bottom && event.y > top) return;\n } else if (this.el.contains(event.relatedTarget as HTMLElement)) return;\n\n this._removeLeaveCallbacks();\n if (this.moving) {\n event.preventDefault();\n const ev = DDUtils.initEvent(event, { target: this.el, type: 'dropout' });\n if (this.option.out) {\n this.option.out(ev, this._ui(DDManager.dragElement))\n }\n this.triggerEvent('dropout', ev);\n }\n delete this.moving;\n }\n\n /** @internal item is being dropped on us - call the client drop event */\n private _drop(event: DragEvent): void {\n if (!this.moving) return; // should not have received event...\n event.preventDefault();\n const ev = DDUtils.initEvent(event, { target: this.el, type: 'drop' });\n if (this.option.drop) {\n this.option.drop(ev, this._ui(DDManager.dragElement))\n }\n this.triggerEvent('drop', ev);\n this._removeLeaveCallbacks();\n delete this.moving;\n }\n\n /** @internal called to remove callbacks when leaving or dropping */\n private _removeLeaveCallbacks() {\n this.el.removeEventListener('dragleave', this._dragLeave);\n this.el.classList.remove('ui-droppable-over');\n if (this.moving) {\n this.el.removeEventListener('dragover', this._dragOver);\n this.el.removeEventListener('drop', this._drop);\n }\n // Note: this.moving is reset by callee of this routine to control the flow\n }\n\n /** @internal */\n private _canDrop(): boolean {\n return DDManager.dragElement && (!this.accept || this.accept(DDManager.dragElement.el));\n }\n\n /** @internal */\n private _setupAccept(): DDDroppable {\n if (this.option.accept && typeof this.option.accept === 'string') {\n this.accept = (el: HTMLElement) => {\n return el.matches(this.option.accept as string)\n }\n } else {\n this.accept = this.option.accept as ((el: HTMLElement) => boolean);\n }\n return this;\n }\n\n /** @internal */\n private _ui(drag: DDDraggable) {\n return {\n draggable: drag.el,\n ...drag.ui()\n };\n }\n}\n\n","/**\n * dd-elements.ts 4.2.6\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\n */\n\nimport { DDResizable, DDResizableOpt } from './dd-resizable';\nimport { GridItemHTMLElement } from './../types';\nimport { DDDraggable, DDDraggableOpt } from './dd-draggable';\nimport { DDDroppable, DDDroppableOpt } from './dd-droppable';\n\nexport interface DDElementHost extends GridItemHTMLElement {\n ddElement?: DDElement;\n}\n\nexport class DDElement {\n\n static init(el: DDElementHost): DDElement {\n if (!el.ddElement) { el.ddElement = new DDElement(el); }\n return el.ddElement;\n }\n\n public el: DDElementHost;\n public ddDraggable?: DDDraggable;\n public ddDroppable?: DDDroppable;\n public ddResizable?: DDResizable;\n\n constructor(el: DDElementHost) {\n this.el = el;\n }\n\n public on(eventName: string, callback: (event: MouseEvent) => void): DDElement {\n if (this.ddDraggable && ['drag', 'dragstart', 'dragstop'].indexOf(eventName) > -1) {\n this.ddDraggable.on(eventName as 'drag' | 'dragstart' | 'dragstop', callback);\n } else if (this.ddDroppable && ['drop', 'dropover', 'dropout'].indexOf(eventName) > -1) {\n this.ddDroppable.on(eventName as 'drop' | 'dropover' | 'dropout', callback);\n } else if (this.ddResizable && ['resizestart', 'resize', 'resizestop'].indexOf(eventName) > -1) {\n this.ddResizable.on(eventName as 'resizestart' | 'resize' | 'resizestop', callback);\n }\n return this;\n }\n\n public off(eventName: string): DDElement {\n if (this.ddDraggable && ['drag', 'dragstart', 'dragstop'].indexOf(eventName) > -1) {\n this.ddDraggable.off(eventName as 'drag' | 'dragstart' | 'dragstop');\n } else if (this.ddDroppable && ['drop', 'dropover', 'dropout'].indexOf(eventName) > -1) {\n this.ddDroppable.off(eventName as 'drop' | 'dropover' | 'dropout');\n } else if (this.ddResizable && ['resizestart', 'resize', 'resizestop'].indexOf(eventName) > -1) {\n this.ddResizable.off(eventName as 'resizestart' | 'resize' | 'resizestop');\n }\n return this;\n }\n\n public setupDraggable(opts: DDDraggableOpt): DDElement {\n if (!this.ddDraggable) {\n this.ddDraggable = new DDDraggable(this.el, opts);\n } else {\n this.ddDraggable.updateOption(opts);\n }\n return this;\n }\n\n public cleanDraggable(): DDElement {\n if (this.ddDraggable) {\n this.ddDraggable.destroy();\n delete this.ddDraggable;\n }\n return this;\n }\n\n public setupResizable(opts: DDResizableOpt): DDElement {\n if (!this.ddResizable) {\n this.ddResizable = new DDResizable(this.el, opts);\n } else {\n this.ddResizable.updateOption(opts);\n }\n return this;\n }\n\n public cleanResizable(): DDElement {\n if (this.ddResizable) {\n this.ddResizable.destroy();\n delete this.ddResizable;\n }\n return this;\n }\n\n public setupDroppable(opts: DDDroppableOpt): DDElement {\n if (!this.ddDroppable) {\n this.ddDroppable = new DDDroppable(this.el, opts);\n } else {\n this.ddDroppable.updateOption(opts);\n }\n return this;\n }\n\n public cleanDroppable(): DDElement {\n if (this.ddDroppable) {\n this.ddDroppable.destroy();\n delete this.ddDroppable;\n }\n return this;\n }\n}\n","/**\n * dd-manager.ts 4.2.6\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\n */\n\nimport { DDDraggable } from './dd-draggable';\n\nexport class DDManager {\n static dragElement: DDDraggable;\n}\n","/**\n * dd-resizable-handle.ts 4.2.6\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\n */\n\nexport interface DDResizableHandleOpt {\n start?: (event) => void;\n move?: (event) => void;\n stop?: (event) => void;\n}\n\nexport class DDResizableHandle {\n /** @internal */\n private el: HTMLElement;\n /** @internal */\n private host: HTMLElement;\n /** @internal */\n private option: DDResizableHandleOpt;\n /** @internal */\n private dir: string;\n /** @internal true after we've moved enough pixels to start a resize */\n private moving = false;\n /** @internal */\n private mouseDownEvent: MouseEvent;\n /** @internal */\n private static prefix = 'ui-resizable-';\n\n constructor(host: HTMLElement, direction: string, option: DDResizableHandleOpt) {\n this.host = host;\n this.dir = direction;\n this.option = option;\n // create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)\n this._mouseDown = this._mouseDown.bind(this);\n this._mouseMove = this._mouseMove.bind(this);\n this._mouseUp = this._mouseUp.bind(this);\n\n this._init();\n }\n\n /** @internal */\n private _init(): DDResizableHandle {\n const el = document.createElement('div');\n el.classList.add('ui-resizable-handle');\n el.classList.add(`${DDResizableHandle.prefix}${this.dir}`);\n el.style.zIndex = '100';\n el.style.userSelect = 'none';\n this.el = el;\n this.host.appendChild(this.el);\n this.el.addEventListener('mousedown', this._mouseDown);\n return this;\n }\n\n /** call this when resize handle needs to be removed and cleaned up */\n public destroy(): DDResizableHandle {\n if (this.moving) this._mouseUp(this.mouseDownEvent);\n this.el.removeEventListener('mousedown', this._mouseDown);\n this.host.removeChild(this.el);\n delete this.el;\n delete this.host;\n return this;\n }\n\n /** @internal called on mouse down on us: capture move on the entire document (mouse might not stay on us) until we release the mouse */\n private _mouseDown(e: MouseEvent): void {\n e.preventDefault();\n this.mouseDownEvent = e;\n document.addEventListener('mousemove', this._mouseMove, true); // capture, not bubble\n document.addEventListener('mouseup', this._mouseUp);\n }\n\n /** @internal */\n private _mouseMove(e: MouseEvent): void {\n let s = this.mouseDownEvent;\n // don't start unless we've moved at least 3 pixels\n if (!this.moving && Math.abs(e.x - s.x) + Math.abs(e.y - s.y) > 2) {\n this.moving = true;\n this._triggerEvent('start', this.mouseDownEvent);\n } else if (this.moving) {\n this._triggerEvent('move', e);\n }\n }\n\n /** @internal */\n private _mouseUp(e: MouseEvent): void {\n if (this.moving) {\n this._triggerEvent('stop', e);\n }\n document.removeEventListener('mousemove', this._mouseMove, true);\n document.removeEventListener('mouseup', this._mouseUp);\n delete this.moving;\n delete this.mouseDownEvent;\n }\n\n /** @internal */\n private _triggerEvent(name: string, event: MouseEvent): DDResizableHandle {\n if (this.option[name]) this.option[name](event);\n return this;\n }\n}\n","/**\n * dd-resizable.ts 4.2.6\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\n */\n\nimport { DDResizableHandle } from './dd-resizable-handle';\nimport { DDBaseImplement, HTMLElementExtendOpt } from './dd-base-impl';\nimport { DDUtils } from './dd-utils';\nimport { Utils } from '../utils';\nimport { DDUIData, Rect, Size } from '../types';\n\n// TODO: merge with DDDragOpt\nexport interface DDResizableOpt {\n autoHide?: boolean;\n handles?: string;\n maxHeight?: number;\n maxWidth?: number;\n minHeight?: number;\n minWidth?: number;\n basePosition?: 'fixed' | 'absolute';\n start?: (event: Event, ui: DDUIData) => void;\n stop?: (event: Event) => void;\n resize?: (event: Event, ui: DDUIData) => void;\n}\n\nexport class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt {\n\n // have to be public else complains for HTMLElementExtendOpt ?\n public el: HTMLElement;\n public option: DDResizableOpt;\n\n /** @internal */\n private handlers: DDResizableHandle[];\n /** @internal */\n private originalRect: Rect;\n /** @internal */\n private temporalRect: Rect;\n /** @internal */\n private scrollY: number;\n /** @internal */\n private scrolled: number;\n /** @internal */\n private scrollEl: HTMLElement;\n /** @internal */\n private startEvent: MouseEvent;\n /** @internal value saved in the same order as _originStyleProp[] */\n private elOriginStyleVal: string[];\n /** @internal */\n private parentOriginStylePosition: string;\n /** @internal */\n private static _originStyleProp = ['width', 'height', 'position', 'left', 'top', 'opacity', 'zIndex'];\n\n constructor(el: HTMLElement, opts: DDResizableOpt = {}) {\n super();\n this.el = el;\n this.option = opts;\n this.enable();\n this._setupAutoHide();\n this._setupHandlers();\n }\n\n public on(event: 'resizestart' | 'resize' | 'resizestop', callback: (event: DragEvent) => void): void {\n super.on(event, callback);\n }\n\n public off(event: 'resizestart' | 'resize' | 'resizestop'): void {\n super.off(event);\n }\n\n public enable(): void {\n super.enable();\n this.el.classList.add('ui-resizable');\n this.el.classList.remove('ui-resizable-disabled');\n }\n\n public disable(): void {\n super.disable();\n this.el.classList.add('ui-resizable-disabled');\n this.el.classList.remove('ui-resizable');\n }\n\n public destroy(): void {\n this._removeHandlers();\n if (this.option.autoHide) {\n this.el.removeEventListener('mouseover', this._showHandlers);\n this.el.removeEventListener('mouseout', this._hideHandlers);\n }\n this.el.classList.remove('ui-resizable');\n delete this.el;\n super.destroy();\n }\n\n public updateOption(opts: DDResizableOpt): DDResizable {\n let updateHandles = (opts.handles && opts.handles !== this.option.handles);\n let updateAutoHide = (opts.autoHide && opts.autoHide !== this.option.autoHide);\n Object.keys(opts).forEach(key => this.option[key] = opts[key]);\n if (updateHandles) {\n this._removeHandlers();\n this._setupHandlers();\n }\n if (updateAutoHide) {\n this._setupAutoHide();\n }\n return this;\n }\n\n /** @internal */\n private _setupAutoHide(): DDResizable {\n if (this.option.autoHide) {\n this.el.classList.add('ui-resizable-autohide');\n // use mouseover/mouseout instead of mouseenter/mouseleave to get better performance;\n this.el.addEventListener('mouseover', this._showHandlers);\n this.el.addEventListener('mouseout', this._hideHandlers);\n } else {\n this.el.classList.remove('ui-resizable-autohide');\n this.el.removeEventListener('mouseover', this._showHandlers);\n this.el.removeEventListener('mouseout', this._hideHandlers);\n }\n return this;\n }\n\n /** @internal */\n private _showHandlers = () => {\n this.el.classList.remove('ui-resizable-autohide');\n }\n\n /** @internal */\n private _hideHandlers = () => {\n this.el.classList.add('ui-resizable-autohide');\n }\n\n /** @internal */\n private _setupHandlers(): DDResizable {\n let handlerDirection = this.option.handles || 'e,s,se';\n if (handlerDirection === 'all') {\n handlerDirection = 'n,e,s,w,se,sw,ne,nw';\n }\n this.handlers = handlerDirection.split(',')\n .map(dir => dir.trim())\n .map(dir => new DDResizableHandle(this.el, dir, {\n start: (event: MouseEvent) => {\n this._resizeStart(event);\n },\n stop: (event: MouseEvent) => {\n this._resizeStop(event);\n },\n move: (event: MouseEvent) => {\n this._resizing(event, dir);\n }\n }));\n return this;\n }\n\n /** @internal */\n private _resizeStart(event: MouseEvent): DDResizable {\n this.originalRect = this.el.getBoundingClientRect();\n this.scrollEl = Utils.getScrollElement(this.el);\n this.scrollY = this.scrollEl.scrollTop;\n this.startEvent = event;\n this._setupHelper();\n this._applyChange();\n const ev = DDUtils.initEvent(event, { type: 'resizestart', target: this.el });\n if (this.option.start) {\n this.option.start(ev, this._ui());\n }\n this.el.classList.add('ui-resizable-resizing');\n this.triggerEvent('resizestart', ev);\n return this;\n }\n\n /** @internal */\n private _resizing(event: MouseEvent, dir: string): DDResizable {\n this.scrolled = this.scrollEl.scrollTop - this.scrollY;\n this.temporalRect = this._getChange(event, dir);\n this._applyChange();\n const ev = DDUtils.initEvent(event, { type: 'resize', target: this.el });\n if (this.option.resize) {\n this.option.resize(ev, this._ui());\n }\n this.triggerEvent('resize', ev);\n return this;\n }\n\n /** @internal */\n private _resizeStop(event: MouseEvent): DDResizable {\n const ev = DDUtils.initEvent(event, { type: 'resizestop', target: this.el });\n if (this.option.stop) {\n this.option.stop(ev); // Note: ui() not used by gridstack so don't pass\n }\n this.el.classList.remove('ui-resizable-resizing');\n this.triggerEvent('resizestop', ev);\n this._cleanHelper();\n delete this.startEvent;\n delete this.originalRect;\n delete this.temporalRect;\n delete this.scrollY;\n delete this.scrolled;\n return this;\n }\n\n /** @internal */\n private _setupHelper(): DDResizable {\n this.elOriginStyleVal = DDResizable._originStyleProp.map(prop => this.el.style[prop]);\n this.parentOriginStylePosition = this.el.parentElement.style.position;\n if (window.getComputedStyle(this.el.parentElement).position.match(/static/)) {\n this.el.parentElement.style.position = 'relative';\n }\n this.el.style.position = this.option.basePosition || 'absolute'; // or 'fixed'\n this.el.style.opacity = '0.8';\n this.el.style.zIndex = '1000';\n return this;\n }\n\n /** @internal */\n private _cleanHelper(): DDResizable {\n DDResizable._originStyleProp.forEach((prop, i) => {\n this.el.style[prop] = this.elOriginStyleVal[i] || null;\n });\n this.el.parentElement.style.position = this.parentOriginStylePosition || null;\n return this;\n }\n\n /** @internal */\n private _getChange(event: MouseEvent, dir: string): Rect {\n const oEvent = this.startEvent;\n const newRect = { // Note: originalRect is a complex object, not a simple Rect, so copy out.\n width: this.originalRect.width,\n height: this.originalRect.height + this.scrolled,\n left: this.originalRect.left,\n top: this.originalRect.top - this.scrolled\n };\n \n const offsetX = event.clientX - oEvent.clientX;\n const offsetY = event.clientY - oEvent.clientY;\n\n if (dir.indexOf('e') > -1) {\n newRect.width += offsetX;\n } else if (dir.indexOf('w') > -1) {\n newRect.width -= offsetX;\n newRect.left += offsetX;\n }\n if (dir.indexOf('s') > -1) {\n newRect.height += offsetY;\n } else if (dir.indexOf('n') > -1) {\n newRect.height -= offsetY;\n newRect.top += offsetY\n }\n const constrain = this._constrainSize(newRect.width, newRect.height);\n if (Math.round(newRect.width) !== Math.round(constrain.width)) { // round to ignore slight round-off errors\n if (dir.indexOf('w') > -1) {\n newRect.left += newRect.width - constrain.width;\n }\n newRect.width = constrain.width;\n }\n if (Math.round(newRect.height) !== Math.round(constrain.height)) {\n if (dir.indexOf('n') > -1) {\n newRect.top += newRect.height - constrain.height;\n }\n newRect.height = constrain.height;\n }\n return newRect;\n }\n\n /** @internal constrain the size to the set min/max values */\n private _constrainSize(oWidth: number, oHeight: number): Size {\n const maxWidth = this.option.maxWidth || Number.MAX_SAFE_INTEGER;\n const minWidth = this.option.minWidth || oWidth;\n const maxHeight = this.option.maxHeight || Number.MAX_SAFE_INTEGER;\n const minHeight = this.option.minHeight || oHeight;\n const width = Math.min(maxWidth, Math.max(minWidth, oWidth));\n const height = Math.min(maxHeight, Math.max(minHeight, oHeight));\n return { width, height };\n }\n\n /** @internal */\n private _applyChange(): DDResizable {\n let containmentRect = { left: 0, top: 0, width: 0, height: 0 };\n if (this.el.style.position === 'absolute') {\n const containmentEl = this.el.parentElement;\n const { left, top } = containmentEl.getBoundingClientRect();\n containmentRect = { left, top, width: 0, height: 0 };\n }\n if (!this.temporalRect) return this;\n Object.keys(this.temporalRect).forEach(key => {\n const value = this.temporalRect[key];\n this.el.style[key] = value - containmentRect[key] + 'px';\n });\n return this;\n }\n\n /** @internal */\n private _removeHandlers(): DDResizable {\n this.handlers.forEach(handle => handle.destroy());\n delete this.handlers;\n return this;\n }\n\n /** @internal */\n private _ui = (): DDUIData => {\n const containmentEl = this.el.parentElement;\n const containmentRect = containmentEl.getBoundingClientRect();\n const newRect = { // Note: originalRect is a complex object, not a simple Rect, so copy out.\n width: this.originalRect.width,\n height: this.originalRect.height + this.scrolled,\n left: this.originalRect.left,\n top: this.originalRect.top - this.scrolled\n };\n const rect = this.temporalRect || newRect;\n return {\n position: {\n left: rect.left - containmentRect.left,\n top: rect.top - containmentRect.top\n },\n size: {\n width: rect.width,\n height: rect.height\n }\n /* Gridstack ONLY needs position set above... keep around in case.\n element: [this.el], // The object representing the element to be resized\n helper: [], // TODO: not support yet - The object representing the helper that's being resized\n originalElement: [this.el],// we don't wrap here, so simplify as this.el //The object representing the original element before it is wrapped\n originalPosition: { // The position represented as { left, top } before the resizable is resized\n left: this.originalRect.left - containmentRect.left,\n top: this.originalRect.top - containmentRect.top\n },\n originalSize: { // The size represented as { width, height } before the resizable is resized\n width: this.originalRect.width,\n height: this.originalRect.height\n }\n */\n };\n }\n}\n","/**\n * dd-utils.ts 4.2.6\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\n */\nexport class DDUtils {\n\n public static isEventSupportPassiveOption = ((() => {\n let supportsPassive = false;\n let passiveTest = () => {\n // do nothing\n };\n document.addEventListener('test', passiveTest, {\n get passive() {\n supportsPassive = true;\n return true;\n }\n });\n document.removeEventListener('test', passiveTest);\n return supportsPassive;\n })());\n\n public static clone(el: HTMLElement): HTMLElement {\n const node = el.cloneNode(true) as HTMLElement;\n node.removeAttribute('id');\n return node;\n }\n\n public static appendTo(el: HTMLElement, parent: string | HTMLElement | Node): void {\n let parentNode: HTMLElement;\n if (typeof parent === 'string') {\n parentNode = document.querySelector(parent as string);\n } else {\n parentNode = parent as HTMLElement;\n }\n if (parentNode) {\n parentNode.appendChild(el);\n }\n }\n\n public static setPositionRelative(el: HTMLElement): void {\n if (!(/^(?:r|a|f)/).test(window.getComputedStyle(el).position)) {\n el.style.position = \"relative\";\n }\n }\n\n public static addElStyles(el: HTMLElement, styles: { [prop: string]: string | string[] }): void {\n if (styles instanceof Object) {\n for (const s in styles) {\n if (styles.hasOwnProperty(s)) {\n if (Array.isArray(styles[s])) {\n // support fallback value\n (styles[s] as string[]).forEach(val => {\n el.style[s] = val;\n });\n } else {\n el.style[s] = styles[s];\n }\n }\n }\n }\n }\n\n public static initEvent(e: DragEvent | MouseEvent, info: { type: string; target?: EventTarget }): T {\n const evt = { type: info.type };\n const obj = {\n button: 0,\n which: 0,\n buttons: 1,\n bubbles: true,\n cancelable: true,\n target: info.target ? info.target : e.target\n };\n // don't check for `instanceof DragEvent` as Safari use MouseEvent #1540\n if ((e as DragEvent).dataTransfer) {\n evt['dataTransfer'] = (e as DragEvent).dataTransfer; // workaround 'readonly' field.\n }\n ['altKey','ctrlKey','metaKey','shiftKey'].forEach(p => evt[p] = e[p]); // keys\n ['pageX','pageY','clientX','clientY','screenX','screenY'].forEach(p => evt[p] = e[p]); // point info\n return {...evt, ...obj} as unknown as T;\n }\n}","/**\n * gridstack-dd-native.ts 4.2.6\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\n */\n\nimport { DDManager } from './dd-manager';\nimport { DDElement, DDElementHost } from './dd-element';\n\nimport { GridStackElement } from '../gridstack';\nimport { GridStackDD, DDOpts, DDKey, DDDropOpt, DDCallback, DDValue } from '../gridstack-dd';\nimport { GridItemHTMLElement, DDDragInOpt } from '../types';\nimport { Utils } from '../utils';\n\n// export our base class (what user should use) and all associated types\nexport * from '../gridstack-dd';\n\n/**\n * HTML 5 Native DragDrop based drag'n'drop plugin.\n */\nexport class GridStackDDNative extends GridStackDD {\n\n public resizable(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue): GridStackDDNative {\n this._getDDElements(el).forEach(dEl => {\n if (opts === 'disable' || opts === 'enable') {\n dEl.ddResizable && dEl.ddResizable[opts](); // can't create DD as it requires options for setupResizable()\n } else if (opts === 'destroy') {\n dEl.ddResizable && dEl.cleanResizable();\n } else if (opts === 'option') {\n dEl.setupResizable({ [key]: value });\n } else {\n const grid = dEl.el.gridstackNode.grid;\n let handles = dEl.el.getAttribute('gs-resize-handles') ? dEl.el.getAttribute('gs-resize-handles') : grid.opts.resizable.handles;\n dEl.setupResizable({\n ...grid.opts.resizable,\n ...{ handles: handles },\n ...{\n start: opts.start,\n stop: opts.stop,\n resize: opts.resize\n }\n });\n }\n });\n return this;\n }\n\n public draggable(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue): GridStackDDNative {\n this._getDDElements(el).forEach(dEl => {\n if (opts === 'disable' || opts === 'enable') {\n dEl.ddDraggable && dEl.ddDraggable[opts](); // can't create DD as it requires options for setupDraggable()\n } else if (opts === 'destroy') {\n dEl.ddDraggable && dEl.cleanDraggable();\n } else if (opts === 'option') {\n dEl.setupDraggable({ [key]: value });\n } else {\n const grid = dEl.el.gridstackNode.grid;\n dEl.setupDraggable({\n ...grid.opts.draggable,\n ...{\n containment: (grid.opts._isNested && !grid.opts.dragOut)\n ? grid.el.parentElement\n : (grid.opts.draggable.containment || null),\n start: opts.start,\n stop: opts.stop,\n drag: opts.drag\n }\n });\n }\n });\n return this;\n }\n\n public dragIn(el: GridStackElement, opts: DDDragInOpt): GridStackDDNative {\n this._getDDElements(el).forEach(dEl => dEl.setupDraggable(opts));\n return this;\n }\n\n public droppable(el: GridItemHTMLElement, opts: DDOpts | DDDropOpt, key?: DDKey, value?: DDValue): GridStackDDNative {\n if (typeof opts.accept === 'function' && !opts._accept) {\n opts._accept = opts.accept;\n opts.accept = (el) => opts._accept(el);\n }\n this._getDDElements(el).forEach(dEl => {\n if (opts === 'disable' || opts === 'enable') {\n dEl.ddDroppable && dEl.ddDroppable[opts]();\n } else if (opts === 'destroy') {\n if (dEl.ddDroppable) { // error to call destroy if not there\n dEl.cleanDroppable();\n }\n } else if (opts === 'option') {\n dEl.setupDroppable({ [key]: value });\n } else {\n dEl.setupDroppable(opts);\n }\n });\n return this;\n }\n\n /** true if element is droppable */\n public isDroppable(el: DDElementHost): boolean {\n return !!(el && el.ddElement && el.ddElement.ddDroppable && !el.ddElement.ddDroppable.disabled);\n }\n\n /** true if element is draggable */\n public isDraggable(el: DDElementHost): boolean {\n return !!(el && el.ddElement && el.ddElement.ddDraggable && !el.ddElement.ddDraggable.disabled);\n }\n\n /** true if element is draggable */\n public isResizable(el: DDElementHost): boolean {\n return !!(el && el.ddElement && el.ddElement.ddResizable && !el.ddElement.ddResizable.disabled);\n }\n\n public on(el: GridItemHTMLElement, name: string, callback: DDCallback): GridStackDDNative {\n this._getDDElements(el).forEach(dEl =>\n dEl.on(name, (event: Event) => {\n callback(\n event,\n DDManager.dragElement ? DDManager.dragElement.el : event.target as GridItemHTMLElement,\n DDManager.dragElement ? DDManager.dragElement.helper : null)\n })\n );\n return this;\n }\n\n public off(el: GridItemHTMLElement, name: string): GridStackDD {\n this._getDDElements(el).forEach(dEl => dEl.off(name));\n return this;\n }\n\n /** @internal returns a list of DD elements, creating them on the fly by default */\n private _getDDElements(els: GridStackElement, create = true): DDElement[] {\n let hosts = Utils.getElements(els) as DDElementHost[];\n if (!hosts.length) return [];\n let list = hosts.map(e => e.ddElement || (create ? DDElement.init(e) : null));\n if (!create) { list.filter(d => d); } // remove nulls\n return list;\n }\n}\n\n// finally register ourself\nGridStackDD.registerPlugin(GridStackDDNative);\n","/**\r\n * utils.ts 4.2.6\r\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\r\n */\r\n\r\nimport { GridStackElement, GridStackNode, GridStackOptions, numberOrString, GridStackPosition, GridStackWidget } from './types';\r\n\r\nexport interface HeightData {\r\n h: number;\r\n unit: string;\r\n}\r\n\r\n/** checks for obsolete method names */\r\n// eslint-disable-next-line\r\nexport function obsolete(self, f, oldName: string, newName: string, rev: string): (...args: any[]) => any {\r\n let wrapper = (...args) => {\r\n console.warn('gridstack.js: Function `' + oldName + '` is deprecated in ' + rev + ' and has been replaced ' +\r\n 'with `' + newName + '`. It will be **completely** removed in v1.0');\r\n return f.apply(self, args);\r\n }\r\n wrapper.prototype = f.prototype;\r\n return wrapper;\r\n}\r\n\r\n/** checks for obsolete grid options (can be used for any fields, but msg is about options) */\r\nexport function obsoleteOpts(opts: GridStackOptions, oldName: string, newName: string, rev: string): void {\r\n if (opts[oldName] !== undefined) {\r\n opts[newName] = opts[oldName];\r\n console.warn('gridstack.js: Option `' + oldName + '` is deprecated in ' + rev + ' and has been replaced with `' +\r\n newName + '`. It will be **completely** removed in v1.0');\r\n }\r\n}\r\n\r\n/** checks for obsolete grid options which are gone */\r\nexport function obsoleteOptsDel(opts: GridStackOptions, oldName: string, rev: string, info: string): void {\r\n if (opts[oldName] !== undefined) {\r\n console.warn('gridstack.js: Option `' + oldName + '` is deprecated in ' + rev + info);\r\n }\r\n}\r\n\r\n/** checks for obsolete Jquery element attributes */\r\nexport function obsoleteAttr(el: HTMLElement, oldName: string, newName: string, rev: string): void {\r\n let oldAttr = el.getAttribute(oldName);\r\n if (oldAttr !== null) {\r\n el.setAttribute(newName, oldAttr);\r\n console.warn('gridstack.js: attribute `' + oldName + '`=' + oldAttr + ' is deprecated on this object in ' + rev + ' and has been replaced with `' +\r\n newName + '`. It will be **completely** removed in v1.0');\r\n }\r\n}\r\n\r\n/**\r\n * Utility methods\r\n */\r\nexport class Utils {\r\n\r\n /** convert a potential selector into actual list of html elements */\r\n static getElements(els: GridStackElement): HTMLElement[] {\r\n if (typeof els === 'string') {\r\n let list = document.querySelectorAll(els);\r\n if (!list.length && els[0] !== '.' && els[0] !== '#') {\r\n list = document.querySelectorAll('.' + els);\r\n if (!list.length) { list = document.querySelectorAll('#' + els) }\r\n }\r\n return Array.from(list) as HTMLElement[];\r\n }\r\n return [els];\r\n }\r\n\r\n /** convert a potential selector into actual single element */\r\n static getElement(els: GridStackElement): HTMLElement {\r\n if (typeof els === 'string') {\r\n if (!els.length) return null;\r\n if (els[0] === '#') {\r\n return document.getElementById(els.substring(1));\r\n }\r\n if (els[0] === '.' || els[0] === '[') {\r\n return document.querySelector(els);\r\n }\r\n\r\n // if we start with a digit, assume it's an id (error calling querySelector('#1')) as class are not valid CSS\r\n if(!isNaN(+els[0])) { // start with digit\r\n return document.getElementById(els);\r\n }\r\n\r\n // finally try string, then id then class\r\n let el = document.querySelector(els);\r\n if (!el) { el = document.getElementById(els) }\r\n if (!el) { el = document.querySelector('.' + els) }\r\n return el as HTMLElement;\r\n }\r\n return els;\r\n }\r\n\r\n /** returns true if a and b overlap */\r\n static isIntercepted(a: GridStackPosition, b: GridStackPosition): boolean {\r\n return !(a.y >= b.y + b.h || a.y + a.h <= b.y || a.x + a.w <= b.x || a.x >= b.x + b.w);\r\n }\r\n\r\n /** returns true if a and b touch edges or corners */\r\n static isTouching(a: GridStackPosition, b: GridStackPosition): boolean {\r\n return Utils.isIntercepted(a, {x: b.x-0.5, y: b.y-0.5, w: b.w+1, h: b.h+1})\r\n }\r\n /**\r\n * Sorts array of nodes\r\n * @param nodes array to sort\r\n * @param dir 1 for asc, -1 for desc (optional)\r\n * @param width width of the grid. If undefined the width will be calculated automatically (optional).\r\n **/\r\n static sort(nodes: GridStackNode[], dir?: -1 | 1, column?: number): GridStackNode[] {\r\n column = column || nodes.reduce((col, n) => Math.max(n.x + n.w, col), 0) || 12;\r\n if (dir === -1)\r\n return nodes.sort((a, b) => (b.x + b.y * column)-(a.x + a.y * column));\r\n else\r\n return nodes.sort((b, a) => (b.x + b.y * column)-(a.x + a.y * column));\r\n }\r\n\r\n /**\r\n * creates a style sheet with style id under given parent\r\n * @param id will set the 'gs-style-id' attribute to that id\r\n * @param parent to insert the stylesheet as first child,\r\n * if none supplied it will be appended to the document head instead.\r\n */\r\n static createStylesheet(id: string, parent?: HTMLElement): CSSStyleSheet {\r\n let style: HTMLStyleElement = document.createElement('style');\r\n style.setAttribute('type', 'text/css');\r\n style.setAttribute('gs-style-id', id);\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n if ((style as any).styleSheet) { // TODO: only CSSImportRule have that and different beast ??\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n (style as any).styleSheet.cssText = '';\r\n } else {\r\n style.appendChild(document.createTextNode('')); // WebKit hack\r\n }\r\n if (!parent) {\r\n // default to head\r\n parent = document.getElementsByTagName('head')[0];\r\n parent.appendChild(style);\r\n } else {\r\n parent.insertBefore(style, parent.firstChild);\r\n }\r\n return style.sheet as CSSStyleSheet;\r\n }\r\n\r\n /** removed the given stylesheet id */\r\n static removeStylesheet(id: string): void {\r\n let el = document.querySelector('STYLE[gs-style-id=' + id + ']');\r\n if (el && el.parentNode) el.remove();\r\n }\r\n\r\n /** inserts a CSS rule */\r\n static addCSSRule(sheet: CSSStyleSheet, selector: string, rules: string): void {\r\n if (typeof sheet.addRule === 'function') {\r\n sheet.addRule(selector, rules);\r\n } else if (typeof sheet.insertRule === 'function') {\r\n sheet.insertRule(`${selector}{${rules}}`);\r\n }\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n static toBool(v: unknown): boolean {\r\n if (typeof v === 'boolean') {\r\n return v;\r\n }\r\n if (typeof v === 'string') {\r\n v = v.toLowerCase();\r\n return !(v === '' || v === 'no' || v === 'false' || v === '0');\r\n }\r\n return Boolean(v);\r\n }\r\n\r\n static toNumber(value: null | string): number {\r\n return (value === null || value.length === 0) ? undefined : Number(value);\r\n }\r\n\r\n static parseHeight(val: numberOrString): HeightData {\r\n let h: number;\r\n let unit = 'px';\r\n if (typeof val === 'string') {\r\n let match = val.match(/^(-[0-9]+\\.[0-9]+|[0-9]*\\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw|%)?$/);\r\n if (!match) {\r\n throw new Error('Invalid height');\r\n }\r\n unit = match[2] || 'px';\r\n h = parseFloat(match[1]);\r\n } else {\r\n h = val;\r\n }\r\n return { h, unit };\r\n }\r\n\r\n /** copies unset fields in target to use the given default sources values */\r\n // eslint-disable-next-line\r\n static defaults(target, ...sources): {} {\r\n\r\n sources.forEach(source => {\r\n for (const key in source) {\r\n if (!source.hasOwnProperty(key)) return;\r\n if (target[key] === null || target[key] === undefined) {\r\n target[key] = source[key];\r\n } else if (typeof source[key] === 'object' && typeof target[key] === 'object') {\r\n // property is an object, recursively add it's field over... #1373\r\n this.defaults(target[key], source[key]);\r\n }\r\n }\r\n });\r\n\r\n return target;\r\n }\r\n\r\n /** given 2 objects return true if they have the same values. Checks for Object {} having same fields and values (just 1 level down) */\r\n static same(a: unknown, b: unknown): boolean {\r\n if (typeof a !== 'object') return a == b;\r\n if (typeof a !== typeof b) return false;\r\n // else we have object, check just 1 level deep for being same things...\r\n if (Object.keys(a).length !== Object.keys(b).length) return false;\r\n for (const key in a) {\r\n if (a[key] !== b[key]) return false;\r\n }\r\n return true;\r\n }\r\n\r\n /* copies over b size & position (GridStackPosition), and possibly min/max as well */\r\n static copyPos(a: GridStackWidget, b: GridStackWidget, minMax = false): GridStackWidget {\r\n a.x = b.x;\r\n a.y = b.y;\r\n a.w = b.w;\r\n a.h = b.h;\r\n if (!minMax) return a;\r\n if (b.minW) a.minW = b.minW;\r\n if (b.minH) a.minH = b.minH;\r\n if (b.maxW) a.maxW = b.maxW;\r\n if (b.maxH) a.maxH = b.maxH;\r\n return a;\r\n }\r\n\r\n /* true if a and b has same size & position */\r\n static samePos(a: GridStackPosition, b: GridStackPosition): boolean {\r\n return a && b && a.x === b.x && a.y === b.y && a.w === b.w && a.h === b.h;\r\n }\r\n\r\n /** removes field from the first object if same as the second objects (like diffing) and internal '_' for saving */\r\n static removeInternalAndSame(a: unknown, b: unknown):void {\r\n if (typeof a !== 'object' || typeof b !== 'object') return;\r\n for (let key in a) {\r\n let val = a[key];\r\n if (key[0] === '_' || val === b[key]) {\r\n delete a[key]\r\n } else if (val && typeof val === 'object' && b[key] !== undefined) {\r\n for (let i in val) {\r\n if (val[i] === b[key][i] || i[0] === '_') { delete val[i] }\r\n }\r\n if (!Object.keys(val).length) { delete a[key] }\r\n }\r\n }\r\n }\r\n\r\n /** return the closest parent matching the given class */\r\n static closestByClass(el: HTMLElement, name: string): HTMLElement {\r\n\r\n while(el = el.parentElement) {\r\n if (el.classList.contains(name)) return el;\r\n }\r\n return null;\r\n }\r\n\r\n /** delay calling the given function for given delay, preventing new calls from happening while waiting */\r\n static throttle(func: () => void, delay: number): () => void {\r\n let isWaiting = false;\r\n return (...args) => {\r\n if (!isWaiting) {\r\n isWaiting = true;\r\n setTimeout(() => { func(...args); isWaiting = false; }, delay);\r\n }\r\n }\r\n }\r\n\r\n static removePositioningStyles(el: HTMLElement): void {\r\n let style = el.style;\r\n if (style.position) {\r\n style.removeProperty('position');\r\n }\r\n if (style.left) {\r\n style.removeProperty('left');\r\n }\r\n if (style.top) {\r\n style.removeProperty('top');\r\n }\r\n if (style.width) {\r\n style.removeProperty('width');\r\n }\r\n if (style.height) {\r\n style.removeProperty('height');\r\n }\r\n }\r\n\r\n /** @internal returns the passed element if scrollable, else the closest parent that will, up to the entire document scrolling element */\r\n static getScrollElement(el?: HTMLElement): HTMLElement {\r\n if (!el) return document.scrollingElement as HTMLElement;\r\n const style = getComputedStyle(el);\r\n const overflowRegex = /(auto|scroll)/;\r\n\r\n if (overflowRegex.test(style.overflow + style.overflowY)) {\r\n return el;\r\n } else {\r\n return this.getScrollElement(el.parentElement);\r\n }\r\n }\r\n\r\n /** @internal */\r\n static updateScrollPosition(el: HTMLElement, position: {top: number}, distance: number): void {\r\n // is widget in view?\r\n let rect = el.getBoundingClientRect();\r\n let innerHeightOrClientHeight = (window.innerHeight || document.documentElement.clientHeight);\r\n if (rect.top < 0 ||\r\n rect.bottom > innerHeightOrClientHeight\r\n ) {\r\n // set scrollTop of first parent that scrolls\r\n // if parent is larger than el, set as low as possible\r\n // to get entire widget on screen\r\n let offsetDiffDown = rect.bottom - innerHeightOrClientHeight;\r\n let offsetDiffUp = rect.top;\r\n let scrollEl = this.getScrollElement(el);\r\n if (scrollEl !== null) {\r\n let prevScroll = scrollEl.scrollTop;\r\n if (rect.top < 0 && distance < 0) {\r\n // moving up\r\n if (el.offsetHeight > innerHeightOrClientHeight) {\r\n scrollEl.scrollTop += distance;\r\n } else {\r\n scrollEl.scrollTop += Math.abs(offsetDiffUp) > Math.abs(distance) ? distance : offsetDiffUp;\r\n }\r\n } else if (distance > 0) {\r\n // moving down\r\n if (el.offsetHeight > innerHeightOrClientHeight) {\r\n scrollEl.scrollTop += distance;\r\n } else {\r\n scrollEl.scrollTop += offsetDiffDown > distance ? distance : offsetDiffDown;\r\n }\r\n }\r\n // move widget y by amount scrolled\r\n position.top += scrollEl.scrollTop - prevScroll;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @internal Function used to scroll the page.\r\n *\r\n * @param event `MouseEvent` that triggers the resize\r\n * @param el `HTMLElement` that's being resized\r\n * @param distance Distance from the V edges to start scrolling\r\n */\r\n static updateScrollResize(event: MouseEvent, el: HTMLElement, distance: number): void {\r\n const scrollEl = this.getScrollElement(el);\r\n const height = scrollEl.clientHeight;\r\n // #1727 event.clientY is relative to viewport, so must compare this against position of scrollEl getBoundingClientRect().top\r\n // #1745 Special situation if scrollEl is document 'html': here browser spec states that\r\n // clientHeight is height of viewport, but getBoundingClientRect() is rectangle of html element;\r\n // this discrepancy arises because in reality scrollbar is attached to viewport, not html element itself.\r\n const offsetTop = (scrollEl === this.getScrollElement()) ? 0 : scrollEl.getBoundingClientRect().top;\r\n const pointerPosY = event.clientY - offsetTop;\r\n const top = pointerPosY < distance;\r\n const bottom = pointerPosY > height - distance;\r\n\r\n if (top) {\r\n // This also can be done with a timeout to keep scrolling while the mouse is\r\n // in the scrolling zone. (will have smoother behavior)\r\n scrollEl.scrollBy({ behavior: 'smooth', top: pointerPosY - distance});\r\n } else if (bottom) {\r\n scrollEl.scrollBy({ behavior: 'smooth', top: distance - (height - pointerPosY)});\r\n }\r\n }\r\n\r\n /** single level clone, returning a new object with same top fields. This will share sub objects and arrays */\r\n static clone(obj: T): T {\r\n if (obj === null || obj === undefined || typeof(obj) !== 'object') {\r\n return obj;\r\n }\r\n // return Object.assign({}, obj);\r\n if (obj instanceof Array) {\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n return [...obj] as any;\r\n }\r\n return {...obj};\r\n }\r\n\r\n /**\r\n * Recursive clone version that returns a full copy, checking for nested objects and arrays ONLY.\r\n * Note: this will use as-is any key starting with double __ (and not copy inside) some lib have circular dependencies.\r\n */\r\n static cloneDeep(obj: T): T {\r\n // return JSON.parse(JSON.stringify(obj)); // doesn't work with date format ?\r\n const ret = Utils.clone(obj);\r\n for (const key in ret) {\r\n // NOTE: we don't support function/circular dependencies so skip those properties for now...\r\n if (ret.hasOwnProperty(key) && typeof(ret[key]) === 'object' && key.substring(0, 2) !== '__') {\r\n ret[key] = Utils.cloneDeep(obj[key]);\r\n }\r\n }\r\n return ret;\r\n }\r\n}\r\n\r\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(930);\n"],"sourceRoot":""} \ No newline at end of file diff --git a/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-jq.d.ts b/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-jq.d.ts index e72af94e..1cc15221 100644 --- a/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-jq.d.ts +++ b/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-jq.d.ts @@ -1,5 +1,5 @@ /** - * index-jq.ts 4.2.5 - everything you need for a Grid that uses Jquery-ui drag&drop (original, full feature) + * index-jq.ts 4.2.6 - everything you need for a Grid that uses Jquery-ui drag&drop (original, full feature) * Copyright (c) 2021 Alain Dumesny - see GridStack root license */ export * from './types'; diff --git a/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-jq.js b/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-jq.js index 6efb1a3c..ab6318c4 100644 --- a/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-jq.js +++ b/public/overrides/zikulacontentmodule/js/vendor/gridstack.js/gridstack-jq.js @@ -1,3 +1,3 @@ /*! For license information please see gridstack-jq.js.LICENSE.txt */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.GridStack=t():e.GridStack=t()}(self,(function(){return e={21:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=i(334),s=i(270),o=i(593);class r extends n.GridStackDDI{static get(){return n.GridStackDDI.get()}remove(e){return this.draggable(e,"destroy").resizable(e,"destroy"),e.gridstackNode&&delete e.gridstackNode._initDD,this}}function a(e,t){let i=e?e.gridstackNode:void 0;i&&i.grid&&(t?i._isAboutToRemove=!0:delete i._isAboutToRemove,t?e.classList.add("grid-stack-item-removing"):e.classList.remove("grid-stack-item-removing"))}t.GridStackDD=r,s.GridStack.prototype._setupAcceptWidget=function(){if(this.opts.staticGrid||!this.opts.acceptWidgets)return r.get().droppable(this.el,"destroy"),this;let e,t,i,n=(n,s,a)=>{let l=s.gridstackNode;if(!l)return;let h=(a=a||s).getBoundingClientRect(),u=h.left-e.left,c=h.top-e.top,d={position:{top:c,left:u}};if(l._temporaryRemoved){if(l.x=Math.max(0,Math.round(u/i)),l.y=Math.max(0,Math.round(c/t)),delete l.autoPosition,this.engine.nodeBoundFix(l),!this.engine.willItFit(l)){if(l.autoPosition=!0,!this.engine.willItFit(l))return void r.get().off(s,"drag");l._willFitPos&&(o.Utils.copyPos(l,l._willFitPos),delete l._willFitPos)}this._onStartMoving(a,n,d,l,i,t)}else this._dragOrResize(a,n,d,l,i,t)};return r.get().droppable(this.el,{accept:e=>{let t=e.gridstackNode;if(t&&t.grid===this)return!0;if(!this.opts.acceptWidgets)return!1;let i=!0;if("function"==typeof this.opts.acceptWidgets)i=this.opts.acceptWidgets(e);else{let t=!0===this.opts.acceptWidgets?".grid-stack-item":this.opts.acceptWidgets;i=e.matches(t)}if(i&&t&&this.opts.maxRow){let e={w:t.w,h:t.h,minW:t.minW,minH:t.minH};i=this.engine.willItFit(e)}return i}}).on(this.el,"dropover",((s,o,l)=>{let h=o.gridstackNode;if(h&&h.grid===this&&!h._temporaryRemoved)return!1;h&&h.grid&&h.grid!==this&&!h._temporaryRemoved&&h.grid._leave(o,l);let u=this.el.getBoundingClientRect();e={top:u.top,left:u.left},i=this.cellWidth(),t=this.getCellHeight(!0),h||(h=this._readAttr(o)),h.grid||(h._isExternal=!0,o.gridstackNode=h),l=l||o;let c=h.w||Math.round(l.offsetWidth/i)||1,d=h.h||Math.round(l.offsetHeight/t)||1;return h.grid&&h.grid!==this?(o._gridstackNodeOrig||(o._gridstackNodeOrig=h),o.gridstackNode=h=Object.assign(Object.assign({},h),{w:c,h:d,grid:this}),this.engine.cleanupNode(h).nodeBoundFix(h),h._initDD=h._isExternal=h._temporaryRemoved=!0):(h.w=c,h.h=d,h._temporaryRemoved=!0),a(h.el,!1),r.get().on(o,"drag",n),n(s,o,l),!1})).on(this.el,"dropout",((e,t,i)=>{let n=t.gridstackNode;return n.grid&&n.grid!==this||this._leave(t,i),!1})).on(this.el,"drop",((e,t,i)=>{let n=t.gridstackNode;if(n&&n.grid===this&&!n._isExternal)return!1;let s=!!this.placeholder.parentElement;this.placeholder.remove();let a=t._gridstackNodeOrig;if(delete t._gridstackNodeOrig,s&&a&&a.grid&&a.grid!==this){let e=a.grid;e.engine.removedNodes.push(a),e._triggerRemoveEvent()}return!!n&&(s&&(this.engine.cleanupNode(n),n.grid=this),r.get().off(t,"drag"),i!==t?(i.remove(),t.gridstackNode=a,s&&(t=t.cloneNode(!0))):(t.remove(),r.get().remove(t)),!!s&&(t.gridstackNode=n,n.el=t,o.Utils.copyPos(n,this._readAttr(this.placeholder)),o.Utils.removePositioningStyles(t),this._writeAttr(t,n),this.el.appendChild(t),this._updateContainerHeight(),this.engine.addedNodes.push(n),this._triggerAddEvent(),this._triggerChangeEvent(),this.engine.endUpdate(),this._gsEventHandler.dropped&&this._gsEventHandler.dropped({type:"dropped"},a&&a.grid?a:void 0,n),window.setTimeout((()=>{n.el&&n.el.parentElement?this._prepareDragDropByNode(n):this.engine.removeNode(n)})),!1))})),this},s.GridStack.prototype._setupRemoveDrop=function(){if(!this.opts.staticGrid&&"string"==typeof this.opts.removable){let e=document.querySelector(this.opts.removable);if(!e)return this;r.get().isDroppable(e)||r.get().droppable(e,this.opts.removableOptions).on(e,"dropover",((e,t)=>a(t,!0))).on(e,"dropout",((e,t)=>a(t,!1)))}return this},s.GridStack.setupDragIn=function(e,t){let i,n;if(e&&(i=e,n=Object.assign(Object.assign({},{revert:"invalid",handle:".grid-stack-item-content",scroll:!1,appendTo:"body"}),t||{})),"string"!=typeof i)return;let s=r.get();o.Utils.getElements(i).forEach((e=>{s.isDraggable(e)||s.dragIn(e,n)}))},s.GridStack.prototype._prepareDragDropByNode=function(e){let t=e.el,i=r.get();if(this.opts.staticGrid||(e.noMove||this.opts.disableDrag)&&(e.noResize||this.opts.disableResize))return e._initDD&&(i.remove(t),delete e._initDD),t.classList.add("ui-draggable-disabled","ui-resizable-disabled"),this;if(!e._initDD){let n,s,r=(i,o)=>{this._gsEventHandler[i.type]&&this._gsEventHandler[i.type](i,i.target),n=this.cellWidth(),s=this.getCellHeight(!0),this._onStartMoving(t,i,o,e,n,s)},a=(i,o)=>{this._dragOrResize(t,i,o,e,n,s)},l=n=>{this.placeholder.remove(),delete e._moving,delete e._lastTried;let s=n.target;if(s.gridstackNode&&s.gridstackNode.grid===this){if(e.el=s,e._isAboutToRemove){let o=t.gridstackNode.grid;o._gsEventHandler[n.type]&&o._gsEventHandler[n.type](n,s),i.remove(t),o.engine.removedNodes.push(e),o._triggerRemoveEvent(),delete t.gridstackNode,delete e.el,t.remove()}else e._temporaryRemoved?(o.Utils.removePositioningStyles(s),o.Utils.copyPos(e,e._orig),this._writePosAttr(s,e),this.engine.addNode(e)):(o.Utils.removePositioningStyles(s),this._writePosAttr(s,e)),this._gsEventHandler[n.type]&&this._gsEventHandler[n.type](n,s);this._extraDragRow=0,this._updateContainerHeight(),this._triggerChangeEvent(),this.engine.endUpdate()}};i.draggable(t,{start:r,stop:l,drag:a}).resizable(t,{start:r,stop:l,resize:a}),e._initDD=!0}return e.noMove||this.opts.disableDrag?(i.draggable(t,"disable"),t.classList.add("ui-draggable-disabled")):(i.draggable(t,"enable"),t.classList.remove("ui-draggable-disabled")),e.noResize||this.opts.disableResize?(i.resizable(t,"disable"),t.classList.add("ui-resizable-disabled")):(i.resizable(t,"enable"),t.classList.remove("ui-resizable-disabled")),this},s.GridStack.prototype._onStartMoving=function(e,t,i,n,s,o){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"===t.type,delete n._lastTried,"dropover"===t.type&&n._temporaryRemoved&&(this.engine.addNode(n),n._moving=!0),this.engine.cacheRects(s,o,this.opts.marginTop,this.opts.marginRight,this.opts.marginBottom,this.opts.marginLeft),"resizestart"===t.type){let t=r.get().resizable(e,"option","minWidth",s*(n.minW||1)).resizable(e,"option","minHeight",o*(n.minH||1));n.maxW&&t.resizable(e,"option","maxWidth",s*n.maxW),n.maxH&&t.resizable(e,"option","maxHeight",o*n.maxH)}},s.GridStack.prototype._leave=function(e,t){let i=e.gridstackNode;i&&(r.get().off(e,"drag"),i._temporaryRemoved||(i._temporaryRemoved=!0,this.engine.removeNode(i),i.el=i._isExternal&&t?t:e,!0===this.opts.removable&&a(e,!0),e._gridstackNodeOrig?(e.gridstackNode=e._gridstackNodeOrig,delete e._gridstackNodeOrig):i._isExternal&&(delete i.el,delete e.gridstackNode,this.engine.restoreInitial())))},s.GridStack.prototype._dragOrResize=function(e,t,i,n,s,r){let a,l=Object.assign({},n._orig);if("drag"===t.type){if(n._temporaryRemoved)return;let t=i.position.top-n._prevYPix;n._prevYPix=i.position.top,o.Utils.updateScrollPosition(e,i.position,t);let a=i.position.left+(i.position.left>n._lastUiPosition.left?-this.opts.marginRight:this.opts.marginLeft),h=i.position.top+(i.position.top>n._lastUiPosition.top?-this.opts.marginBottom:this.opts.marginTop);l.x=Math.round(a/s),l.y=Math.round(h/r);let u=this._extraDragRow;if(this.engine.collide(n,l)){let e=this.getRow(),t=Math.max(0,l.y+n.h-e);this.opts.maxRow&&e+t>this.opts.maxRow&&(t=Math.max(0,this.opts.maxRow-e)),this._extraDragRow=t}else this._extraDragRow=0;if(this._extraDragRow!==u&&this._updateContainerHeight(),n.x===l.x&&n.y===l.y)return}else if("resize"===t.type){if(l.x<0)return;if(o.Utils.updateScrollResize(t,e,r),l.w=Math.round((i.size.width-this.opts.marginLeft)/s),l.h=Math.round((i.size.height-this.opts.marginTop)/r),n.w===l.w&&n.h===l.h)return;if(n._lastTried&&n._lastTried.w===l.w&&n._lastTried.h===l.h)return;let h=i.position.left+this.opts.marginLeft,u=i.position.top+this.opts.marginTop;l.x=Math.round(h/s),l.y=Math.round(u/r),a=!0}n._lastTried=l;let h={x:i.position.left+this.opts.marginLeft,y:i.position.top+this.opts.marginTop,w:(i.size?i.size.width:n.w*s)-this.opts.marginLeft-this.opts.marginRight,h:(i.size?i.size.height:n.h*r)-this.opts.marginTop-this.opts.marginBottom};if(this.engine.moveNodeCheck(n,Object.assign(Object.assign({},l),{cellWidth:s,cellHeight:r,rect:h}))){n._lastUiPosition=i.position,this.engine.cacheRects(s,r,this.opts.marginTop,this.opts.marginRight,this.opts.marginBottom,this.opts.marginLeft),delete n._skipDown,a&&n.subGrid&&n.subGrid.onParentResize(),this._extraDragRow=0,this._updateContainerHeight();let e=t.target;this._writePosAttr(e,n),this._gsEventHandler[t.type]&&this._gsEventHandler[t.type](t,e)}},s.GridStack.prototype.movable=function(e,t){return this.opts.staticGrid||s.GridStack.getElements(e).forEach((e=>{let i=e.gridstackNode;i&&(t?delete i.noMove:i.noMove=!0,this._prepareDragDropByNode(i))})),this},s.GridStack.prototype.resizable=function(e,t){return this.opts.staticGrid||s.GridStack.getElements(e).forEach((e=>{let i=e.gridstackNode;i&&(t?delete i.noResize:i.noResize=!0,this._prepareDragDropByNode(i))})),this},s.GridStack.prototype.disable=function(){if(!this.opts.staticGrid)return this.enableMove(!1),this.enableResize(!1),this._triggerEvent("disable"),this},s.GridStack.prototype.enable=function(){if(!this.opts.staticGrid)return this.enableMove(!0),this.enableResize(!0),this._triggerEvent("enable"),this},s.GridStack.prototype.enableMove=function(e){return this.opts.staticGrid||(this.opts.disableDrag=!e,this.engine.nodes.forEach((t=>this.movable(t.el,e)))),this},s.GridStack.prototype.enableResize=function(e){return this.opts.staticGrid||(this.opts.disableResize=!e,this.engine.nodes.forEach((t=>this.resizable(t.el,e)))),this}},334:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});class i{static registerPlugin(e){return i.ddi=new e,i.ddi}static get(){return i.ddi||i.registerPlugin(i)}remove(e){return this}}t.GridStackDDI=i},62:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=i(593);class s{constructor(e={}){this.addedNodes=[],this.removedNodes=[],this.column=e.column||12,this.onChange=e.onChange,this._float=e.float,this.maxRow=e.maxRow,this.nodes=e.nodes||[]}batchUpdate(){return this.batchMode||(this.batchMode=!0,this._prevFloat=this._float,this._float=!0,this.saveInitial()),this}commit(){return this.batchMode?(this.batchMode=!1,this._float=this._prevFloat,delete this._prevFloat,this._packNodes()._notify()):this}_useEntireRowArea(e,t){return!this.float&&!this._hasLocked&&(!e._moving||e._skipDown||t.y<=e.y)}_fixCollisions(e,t=e,i,s={}){if(this._sortNodes(-1),!(i=i||this.collide(e,t)))return!1;if(e._moving&&!s.nested&&!this.float&&this.swap(e,i))return!0;let o=t;this._useEntireRowArea(e,t)&&(o={x:0,w:this.column,y:t.y,h:t.h},i=this.collide(e,o,s.skip));let r=!1,a={nested:!0,pack:!1};for(;i=i||this.collide(e,o,s.skip);){let o;if(i.locked||e._moving&&!e._skipDown&&t.y>e.y&&!this.float&&(!this.collide(i,Object.assign(Object.assign({},i),{y:e.y}),e)||!this.collide(i,Object.assign(Object.assign({},i),{y:t.y-i.h}),e))?(e._skipDown=e._skipDown||t.y>e.y,o=this.moveNode(e,Object.assign(Object.assign(Object.assign({},t),{y:i.y+i.h}),a)),i.locked&&o?n.Utils.copyPos(t,e):!i.locked&&o&&s.pack&&(this._packNodes(),t.y=i.y+i.h,n.Utils.copyPos(e,t)),r=r||o):o=this.moveNode(i,Object.assign(Object.assign(Object.assign({},i),{y:t.y+t.h,skip:e}),a)),!o)return r;i=void 0}return r}collide(e,t=e,i){return this.nodes.find((s=>s!==e&&s!==i&&n.Utils.isIntercepted(s,t)))}collideAll(e,t=e,i){return this.nodes.filter((s=>s!==e&&s!==i&&n.Utils.isIntercepted(s,t)))}collideCoverage(e,t,i){if(!t.rect||!e._rect)return;let n,s=e._rect,o=Object.assign({},t.rect);return o.y>s.y?(o.h+=o.y-s.y,o.y=s.y):o.h+=s.y-o.y,o.x>s.x?(o.w+=o.x-s.x,o.x=s.x):o.w+=s.x-o.x,i.forEach((e=>{if(e.locked||!e._rect)return;let t=e._rect,i=Number.MAX_VALUE,r=Number.MAX_VALUE,a=.5;s.yt.y+t.h&&(i=(t.y+t.h-o.y)/t.h),s.xt.x+t.w&&(r=(t.x+t.w-o.x)/t.w);let l=Math.min(r,i);l>a&&(a=l,n=e)})),n}cacheRects(e,t,i,n,s,o){return this.nodes.forEach((r=>r._rect={y:r.y*t+i,x:r.x*e+o,w:r.w*e-o-n,h:r.h*t-i-s})),this}swap(e,t){if(!t||t.locked||!e||e.locked)return!1;function i(){let i=t.x,n=t.y;return t.x=e.x,t.y=e.y,e.h!=t.h?(e.x=i,e.y=t.y+t.h):(e.x=i,e.y=n),e._dirty=t._dirty=!0,!0}let s;if(e.w===t.w&&e.h===t.h&&(e.x===t.x||e.y===t.y)&&(s=n.Utils.isTouching(e,t)))return i();if(!1!==s){if(e.w===t.w&&e.x===t.x&&(s||n.Utils.isTouching(e,t))){if(t.y{e.locked||(e.autoPosition=!0),this.addNode(e,!1),e._dirty=!0})),this.commit()}set float(e){this._float!==e&&(this._float=e||!1,e||this._packNodes()._notify())}get float(){return this._float||!1}_sortNodes(e){return this.nodes=n.Utils.sort(this.nodes,e,this.column),this}_packNodes(){return this._sortNodes(),this.float?this.nodes.forEach((e=>{if(e._updating||void 0===e._orig||e.y===e._orig.y)return;let t=e.y;for(;t>e._orig.y;)--t,this.collide(e,{x:e.x,y:t,w:e.w,h:e.h})||(e._dirty=!0,e.y=t)})):this.nodes.forEach(((e,t)=>{if(!e.locked)for(;e.y>0;){let i=0===t?0:e.y-1;if(0!==t&&this.collide(e,{x:e.x,y:i,w:e.w,h:e.h}))break;e._dirty=e.y!==i,e.y=i}})),this}prepareNode(e,t){(e=e||{})._id=e._id||s._idSeq++,void 0!==e.x&&void 0!==e.y&&null!==e.x&&null!==e.y||(e.autoPosition=!0);let i={x:0,y:0,w:1,h:1};return n.Utils.defaults(e,i),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=i.x,e.autoPosition=!0),isNaN(e.y)&&(e.y=i.y,e.autoPosition=!0),isNaN(e.w)&&(e.w=i.w),isNaN(e.h)&&(e.h=i.h),this.nodeBoundFix(e,t)}nodeBoundFix(e,t){return e.maxW&&(e.w=Math.min(e.w,e.maxW)),e.maxH&&(e.h=Math.min(e.h,e.maxH)),e.minW&&(e.w=Math.max(e.w,e.minW)),e.minH&&(e.h=Math.max(e.h,e.minH)),e.w>this.column?(this.column<12&&(e.w=Math.min(12,e.w),this.cacheOneLayout(e,12)),e.w=this.column):e.w<1&&(e.w=1),this.maxRow&&e.h>this.maxRow?e.h=this.maxRow:e.h<1&&(e.h=1),e.x<0&&(e.x=0),e.y<0&&(e.y=0),e.x+e.w>this.column&&(t?e.w=this.column-e.x:e.x=this.column-e.w),this.maxRow&&e.y+e.h>this.maxRow&&(t?e.h=this.maxRow-e.y:e.y=this.maxRow-e.h),e}getDirtyNodes(e){return e?this.nodes.filter((e=>e._dirty&&!n.Utils.samePos(e,e._orig))):this.nodes.filter((e=>e._dirty))}_notify(e,t=!0){if(this.batchMode)return this;let i=(e=void 0===e?[]:Array.isArray(e)?e:[e]).concat(this.getDirtyNodes());return this.onChange&&this.onChange(i,t),this}cleanNodes(){return this.batchMode||this.nodes.forEach((e=>{delete e._dirty,delete e._lastTried})),this}saveInitial(){return this.nodes.forEach((e=>{e._orig=n.Utils.copyPos({},e),delete e._dirty})),this._hasLocked=this.nodes.some((e=>e.locked)),this}restoreInitial(){return this.nodes.forEach((e=>{n.Utils.samePos(e,e._orig)||(n.Utils.copyPos(e,e._orig),e._dirty=!0)})),this._notify(),this}addNode(e,t=!1){let i;if(i=this.nodes.find((t=>t._id===e._id)))return i;if(delete(e=this.prepareNode(e))._temporaryRemoved,delete e._removeDOM,e.autoPosition){this._sortNodes();for(let t=0;;++t){let i=t%this.column,s=Math.floor(t/this.column);if(i+e.w>this.column)continue;let o={x:i,y:s,w:e.w,h:e.h};if(!this.nodes.find((e=>n.Utils.isIntercepted(o,e)))){e.x=i,e.y=s,delete e.autoPosition;break}}}return this.nodes.push(e),t&&this.addedNodes.push(e),this._fixCollisions(e),this._packNodes()._notify(),e}removeNode(e,t=!0,i=!1){return this.nodes.find((t=>t===e))?(i&&this.removedNodes.push(e),t&&(e._removeDOM=!0),this.nodes=this.nodes.filter((t=>t!==e)),this._packNodes()._notify(e)):this}removeAll(e=!0){return delete this._layouts,0===this.nodes.length?this:(e&&this.nodes.forEach((e=>e._removeDOM=!0)),this.removedNodes=this.nodes,this.nodes=[],this._notify(this.removedNodes))}moveNodeCheck(e,t){if(!this.changedPosConstrain(e,t))return!1;if(t.pack=!0,!this.maxRow)return this.moveNode(e,t);let i,o=new s({column:this.column,float:this.float,nodes:this.nodes.map((t=>t===e?(i=Object.assign({},t),i):Object.assign({},t)))});if(!i)return!1;let r=o.moveNode(i,t);if(this.maxRow&&r&&(r=o.getRow()<=this.maxRow,!r)){let i=this.collide(e,t);if(i&&this.swap(e,i))return this._notify(),!0}return!!r&&(o.nodes.filter((e=>e._dirty)).forEach((e=>{let t=this.nodes.find((t=>t._id===e._id));t&&(n.Utils.copyPos(t,e),t._dirty=!0)})),this._notify(),!0)}willItFit(e){if(delete e._willFitPos,!this.maxRow)return!0;let t=new s({column:this.column,float:this.float,nodes:this.nodes.map((e=>Object.assign({},e)))}),i=Object.assign({},e);return this.cleanupNode(i),delete i.el,delete i._id,delete i.content,delete i.grid,t.addNode(i),t.getRow()<=this.maxRow&&(e._willFitPos=n.Utils.copyPos({},i),!0)}changedPosConstrain(e,t){return t.w=t.w||e.w,t.h=t.h||e.h,e.x!==t.x||e.y!==t.y||(e.maxW&&(t.w=Math.min(t.w,e.maxW)),e.maxH&&(t.h=Math.min(t.h,e.maxH)),e.minW&&(t.w=Math.max(t.w,e.minW)),e.minH&&(t.h=Math.max(t.h,e.minH)),e.w!==t.w||e.h!==t.h)}moveNode(e,t){if(!e||!t)return!1;void 0===t.pack&&(t.pack=!0),"number"!=typeof t.x&&(t.x=e.x),"number"!=typeof t.y&&(t.y=e.y),"number"!=typeof t.w&&(t.w=e.w),"number"!=typeof t.h&&(t.h=e.h);let i=e.w!==t.w||e.h!==t.h,s=n.Utils.copyPos({},e,!0);if(n.Utils.copyPos(s,t),s=this.nodeBoundFix(s,i),n.Utils.copyPos(t,s),n.Utils.samePos(e,t))return!1;let o=n.Utils.copyPos({},e),r=s,a=this.collideAll(e,r,t.skip),l=!0;if(a.length){let i=e._moving&&!t.nested?this.collideCoverage(e,t,a):a[0];l=!!i&&!this._fixCollisions(e,s,i,t)}return l&&(e._dirty=!0,n.Utils.copyPos(e,s)),t.pack&&this._packNodes()._notify(),!n.Utils.samePos(e,o)}getRow(){return this.nodes.reduce(((e,t)=>Math.max(e,t.y+t.h)),0)}beginUpdate(e){return e._updating||(e._updating=!0,delete e._skipDown,this.batchMode||this.saveInitial()),this}endUpdate(){let e=this.nodes.find((e=>e._updating));return e&&(delete e._updating,delete e._skipDown),this}save(e=!0){let t=[];return this._sortNodes(),this.nodes.forEach((i=>{let n={};for(let e in i)"_"!==e[0]&&null!==i[e]&&void 0!==i[e]&&(n[e]=i[e]);e||delete n.el,delete n.grid,n.autoPosition||delete n.autoPosition,n.noResize||delete n.noResize,n.noMove||delete n.noMove,n.locked||delete n.locked,t.push(n)})),t}layoutsNodesChange(e){return!this._layouts||this._ignoreLayoutsNodeChange||this._layouts.forEach(((t,i)=>{if(!t||i===this.column)return this;i{if(!e._orig)return;let n=t.find((t=>t._id===e._id));if(!n)return;let s=i/this.column;e.y!==e._orig.y&&(n.y+=e.y-e._orig.y),e.x!==e._orig.x&&(n.x=Math.round(e.x*s)),e.w!==e._orig.w&&(n.w=Math.round(e.w*s))}))})),this}updateNodeWidths(e,t,i,s="moveScale"){if(!this.nodes.length||e===t)return this;if(this.cacheLayout(this.nodes,e),1===t&&i&&i.length){let e=0;i.forEach((t=>{t.x=0,t.w=1,t.y=Math.max(t.y,e),e=t.y+t.h}))}else i=n.Utils.sort(this.nodes,-1,e);let o=this._layouts[t]||[],r=this._layouts.length-1;0===o.length&&t>e&&t{let t=i.findIndex((t=>t._id===e._id));-1!==t&&(i[t].x=e.x,i[t].y=e.y,i[t].w=e.w)})),o=[]));let a=[];if(o.forEach((e=>{let t=i.findIndex((t=>t._id===e._id));-1!==t&&(i[t].x=e.x,i[t].y=e.y,i[t].w=e.w,a.push(i[t]),i.splice(t,1))})),i.length)if("function"==typeof s)s(t,e,a,i);else{let n=t/e,o="move"===s||"moveScale"===s,r="scale"===s||"moveScale"===s;i.forEach((i=>{i.x=1===t?0:o?Math.round(i.x*n):Math.min(i.x,t-1),i.w=1===t||1===e?1:r?Math.round(i.w*n)||1:Math.min(i.w,t),a.push(i)})),i=[]}return a=n.Utils.sort(a,-1,t),this._ignoreLayoutsNodeChange=!0,this.batchUpdate(),this.nodes=[],a.forEach((e=>{this.addNode(e,!1),e._dirty=!0}),this),this.commit(),delete this._ignoreLayoutsNodeChange,this}cacheLayout(e,t,i=!1){let n=[];return e.forEach(((e,t)=>{e._id=e._id||s._idSeq++,n[t]={x:e.x,y:e.y,w:e.w,_id:e._id}})),this._layouts=i?[]:this._layouts||[],this._layouts[t]=n,this}cacheOneLayout(e,t){e._id=e._id||s._idSeq++;let i={x:e.x,y:e.y,w:e.w,_id:e._id};this._layouts=this._layouts||[],this._layouts[t]=this._layouts[t]||[];let n=this._layouts[t].findIndex((t=>t._id===e._id));return-1===n?this._layouts[t].push(i):this._layouts[t][n]=i,this}cleanupNode(e){for(let t in e)"_"===t[0]&&"_id"!==t&&delete e[t];return this}}t.GridStackEngine=s,s._idSeq=1},572:(e,t,i)=>{"use strict";function n(e){for(var i in e)t.hasOwnProperty(i)||(t[i]=e[i])}Object.defineProperty(t,"__esModule",{value:!0}),n(i(593)),n(i(62)),n(i(334)),n(i(270)),n(i(906))},270:(e,t,i)=>{"use strict";function n(e){for(var i in e)t.hasOwnProperty(i)||(t[i]=e[i])}Object.defineProperty(t,"__esModule",{value:!0});const s=i(62),o=i(593),r=i(334);n(i(593)),n(i(62)),n(i(334));const a={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};class l{constructor(e,t={}){this._gsEventHandler={},this._extraDragRow=0,this.el=e,(t=t||{}).row&&(t.minRow=t.maxRow=t.row,delete t.row);let i=o.Utils.toNumber(e.getAttribute("gs-row")),n=Object.assign(Object.assign({},a),{column:o.Utils.toNumber(e.getAttribute("gs-column"))||12,minRow:i||o.Utils.toNumber(e.getAttribute("gs-min-row"))||0,maxRow:i||o.Utils.toNumber(e.getAttribute("gs-max-row"))||0,staticGrid:o.Utils.toBool(e.getAttribute("gs-static"))||!1,_styleSheetClass:"grid-stack-instance-"+(1e4*Math.random()).toFixed(0),alwaysShowResizeHandle:t.alwaysShowResizeHandle||!1,resizable:{autoHide:!t.alwaysShowResizeHandle,handles:"se"},draggable:{handle:(t.handleClass?"."+t.handleClass:t.handle?t.handle:"")||".grid-stack-item-content",scroll:!1,appendTo:"body"},removableOptions:{accept:"."+(t.itemClass||"grid-stack-item")}});e.getAttribute("gs-animate")&&(n.animate=o.Utils.toBool(e.getAttribute("gs-animate"))),this.opts=o.Utils.defaults(t,n),t=null,this.initMargin(),1!==this.opts.column&&!this.opts.disableOneColumnMode&&this._widthOrContainer()<=this.opts.minWidth&&(this._prevColumn=this.opts.column,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");let r=o.Utils.closestByClass(this.el,a.itemClass);if(r&&r.gridstackNode&&(this.opts._isNested=r.gridstackNode,this.opts._isNested.subGrid=this,this.el.classList.add("grid-stack-nested")),this._isAutoCellHeight="auto"===this.opts.cellHeight,this._isAutoCellHeight||"initial"===this.opts.cellHeight?this.cellHeight(void 0,!1):this.cellHeight(this.opts.cellHeight,!1),this.el.classList.add(this.opts._styleSheetClass),this._setStaticClass(),this.engine=new s.GridStackEngine({column:this.opts.column,float:this.opts.float,maxRow:this.opts.maxRow,onChange:e=>{let t=0;this.engine.nodes.forEach((e=>{t=Math.max(t,e.y+e.h)})),e.forEach((e=>{let t=e.el;e._removeDOM?(t&&t.remove(),delete e._removeDOM):this._writePosAttr(t,e)})),this._updateStyles(!1,t)}}),this.opts.auto){this.batchUpdate();let e=[];this.getGridItems().forEach((t=>{let i=parseInt(t.getAttribute("gs-x")),n=parseInt(t.getAttribute("gs-y"));e.push({el:t,i:(Number.isNaN(i)?1e3:i)+(Number.isNaN(n)?1e3:n)*this.opts.column})})),e.sort(((e,t)=>e.i-t.i)).forEach((e=>this._prepareElement(e.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&&l.setupDragIn(this.opts.dragIn,this.opts.dragInOptions),delete this.opts.dragIn,delete this.opts.dragInOptions,this._setupRemoveDrop(),this._setupAcceptWidget(),this._updateWindowResizeEvent()}static init(e={},t=".grid-stack"){let i=l.getGridElement(t);return i?(i.gridstack||(i.gridstack=new l(i,Object.assign({},e))),i.gridstack):("string"==typeof t?console.error('GridStack.initAll() no grid was found with selector "'+t+'" - 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)}static initAll(e={},t=".grid-stack"){let i=[];return l.getGridElements(t).forEach((t=>{t.gridstack||(t.gridstack=new l(t,Object.assign({},e)),delete e.dragIn,delete e.dragInOptions),i.push(t.gridstack)})),0===i.length&&console.error('GridStack.initAll() no grid was found with selector "'+t+'" - element missing or wrong selector ?\nNote: ".grid-stack" is required for proper CSS styling and drag/drop, and is the default selector.'),i}static addGrid(e,t={}){if(!e)return null;let i=e;if(!e.classList.contains("grid-stack")){let n=document.implementation.createHTMLDocument();n.body.innerHTML=`
`,i=n.body.children[0],e.appendChild(i)}let n=l.init(t,i);if(n.opts.children){let e=n.opts.children;delete n.opts.children,n.load(e)}return n}get placeholder(){if(!this._placeholder){let e=document.createElement("div");e.className="placeholder-content",this.opts.placeholderText&&(e.innerHTML=this.opts.placeholderText),this._placeholder=document.createElement("div"),this._placeholder.classList.add(this.opts.placeholderClass,a.itemClass,this.opts.itemClass),this.placeholder.appendChild(e)}return this._placeholder}addWidget(e,t){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");let t=arguments,i=1,n={x:t[i++],y:t[i++],w:t[i++],h:t[i++],autoPosition:t[i++],minW:t[i++],maxW:t[i++],minH:t[i++],maxH:t[i++],id:t[i++]};return this.addWidget(e,n)}let i;if("string"==typeof e){let t=document.implementation.createHTMLDocument();t.body.innerHTML=e,i=t.body.children[0]}else if(0===arguments.length||1===arguments.length&&(void 0!==(n=e).x||void 0!==n.y||void 0!==n.w||void 0!==n.h||void 0!==n.content)){let n=e&&e.content||"";t=e;let s=document.implementation.createHTMLDocument();s.body.innerHTML=`
${n}
`,i=s.body.children[0]}else i=e;var n;let s=this._readAttr(i);t=Object.assign({},t||{}),o.Utils.defaults(t,s);let r=this.engine.prepareNode(t);if(this._writeAttr(i,t),this._insertNotAppend?this.el.prepend(i):this.el.appendChild(i),this._prepareElement(i,!0,t),this._updateContainerHeight(),r.subGrid&&!r.subGrid.el){let e=r.el.querySelector(".grid-stack-item-content");r.subGrid=l.addGrid(e,r.subGrid)}return this._triggerAddEvent(),this._triggerChangeEvent(),i}save(e=!0,t=!1){let i=this.engine.save(e);if(e&&i.forEach((e=>{if(e.el&&!e.subGrid){let t=e.el.querySelector(".grid-stack-item-content");e.content=t?t.innerHTML:void 0,e.content||delete e.content,delete e.el}})),t){i.forEach((i=>{i.subGrid&&(i.subGrid=i.subGrid.save(e,t))}));let n=Object.assign({},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"),o.Utils.removeInternalAndSame(n,a),n.children=i,n}return i}load(e,t=!0){let i=l.Utils.sort([...e],-1,this._prevColumn||this.opts.column);this._insertNotAppend=!0,this._prevColumn&&this._prevColumn!==this.opts.column&&i.some((e=>e.x+e.w>this.opts.column))&&(this._ignoreLayoutsNodeChange=!0,this.engine.cacheLayout(i,this._prevColumn,!0));let n=[];return this.batchUpdate(),t&&[...this.engine.nodes].forEach((e=>{i.find((t=>e.id===t.id))||("function"==typeof t?t(this,e,!1):(n.push(e),this.removeWidget(e.el,!0,!1)))})),i.forEach((e=>{let i=e.id||0===e.id?this.engine.nodes.find((t=>t.id===e.id)):void 0;if(i){if(this.update(i.el,e),e.subGrid&&e.subGrid.children){let t=i.el.querySelector(".grid-stack");t&&t.gridstack&&(t.gridstack.load(e.subGrid.children),this._insertNotAppend=!0)}}else t&&(e="function"==typeof t?t(this,e,!0).gridstackNode:this.addWidget(e).gridstackNode)})),this.engine.removedNodes=n,this.commit(),delete this._ignoreLayoutsNodeChange,delete this._insertNotAppend,this}batchUpdate(){return this.engine.batchUpdate(),this}getCellHeight(e=!1){return!this.opts.cellHeight||"auto"===this.opts.cellHeight||e&&this.opts.cellHeightUnit&&"px"!==this.opts.cellHeightUnit?Math.round(this.el.getBoundingClientRect().height)/parseInt(this.el.getAttribute("gs-current-row")):this.opts.cellHeight}cellHeight(e,t=!0){if(t&&void 0!==e&&this._isAutoCellHeight!==("auto"===e)&&(this._isAutoCellHeight="auto"===e,this._updateWindowResizeEvent()),"initial"!==e&&"auto"!==e||(e=void 0),void 0===e){let t=-this.opts.marginRight-this.opts.marginLeft+this.opts.marginTop+this.opts.marginBottom;e=this.cellWidth()+t}let i=o.Utils.parseHeight(e);return this.opts.cellHeightUnit===i.unit&&this.opts.cellHeight===i.h||(this.opts.cellHeightUnit=i.unit,this.opts.cellHeight=i.h,t&&this._updateStyles(!0,this.getRow())),this}cellWidth(){return this._widthOrContainer()/this.opts.column}_widthOrContainer(){return this.el.clientWidth||this.el.parentElement.clientWidth||window.innerWidth}commit(){return this.engine.commit(),this._triggerRemoveEvent(),this._triggerAddEvent(),this._triggerChangeEvent(),this}compact(){return this.engine.compact(),this._triggerChangeEvent(),this}column(e,t="moveScale"){if(this.opts.column===e)return this;let i,n=this.opts.column;return 1===e?this._prevColumn=n:delete this._prevColumn,this.el.classList.remove("grid-stack-"+n),this.el.classList.add("grid-stack-"+e),this.opts.column=this.engine.column=e,1===e&&this.opts.oneColumnModeDomSort&&(i=[],this.getGridItems().forEach((e=>{e.gridstackNode&&i.push(e.gridstackNode)})),i.length||(i=void 0)),this.engine.updateNodeWidths(n,e,i,t),this._isAutoCellHeight&&this.cellHeight(),this._ignoreLayoutsNodeChange=!0,this._triggerChangeEvent(),delete this._ignoreLayoutsNodeChange,this}getColumn(){return this.opts.column}getGridItems(){return Array.from(this.el.children).filter((e=>e.matches("."+this.opts.itemClass)&&!e.matches("."+this.opts.placeholderClass)))}destroy(e=!0){if(this.el)return this._updateWindowResizeEvent(!0),this.setStatic(!0,!1),this.setAnimation(!1),e?this.el.parentNode.removeChild(this.el):(this.removeAll(e),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}float(e){return this.engine.float=e,this._triggerChangeEvent(),this}getFloat(){return this.engine.float}getCellFromPixel(e,t=!1){let i,n=this.el.getBoundingClientRect();i=t?{top:n.top+document.documentElement.scrollTop,left:n.left}:{top:this.el.offsetTop,left:this.el.offsetLeft};let s=e.left-i.left,o=e.top-i.top,r=n.width/this.opts.column,a=n.height/parseInt(this.el.getAttribute("gs-current-row"));return{x:Math.floor(s/r),y:Math.floor(o/a)}}getRow(){return Math.max(this.engine.getRow(),this.opts.minRow)}isAreaEmpty(e,t,i,n){return this.engine.isAreaEmpty(e,t,i,n)}makeWidget(e){let t=l.getElement(e);return this._prepareElement(t,!0),this._updateContainerHeight(),this._triggerAddEvent(),this._triggerChangeEvent(),t}on(e,t){if(-1!==e.indexOf(" "))return e.split(" ").forEach((e=>this.on(e,t))),this;if("change"===e||"added"===e||"removed"===e||"enable"===e||"disable"===e){let i="enable"===e||"disable"===e;this._gsEventHandler[e]=i?e=>t(e):e=>t(e,e.detail),this.el.addEventListener(e,this._gsEventHandler[e])}else"drag"===e||"dragstart"===e||"dragstop"===e||"resizestart"===e||"resize"===e||"resizestop"===e||"dropped"===e?this._gsEventHandler[e]=t:console.log("GridStack.on("+e+') event not supported, but you can still use $(".grid-stack").on(...) while jquery-ui is still used internally.');return this}off(e){return-1!==e.indexOf(" ")?(e.split(" ").forEach((e=>this.off(e))),this):("change"!==e&&"added"!==e&&"removed"!==e&&"enable"!==e&&"disable"!==e||this._gsEventHandler[e]&&this.el.removeEventListener(e,this._gsEventHandler[e]),delete this._gsEventHandler[e],this)}removeWidget(e,t=!0,i=!0){return l.getElements(e).forEach((e=>{if(e.parentElement!==this.el)return;let n=e.gridstackNode;n||(n=this.engine.nodes.find((t=>e===t.el))),n&&(delete e.gridstackNode,r.GridStackDDI.get().remove(e),this.engine.removeNode(n,t,i),t&&e.parentElement&&e.remove())})),i&&(this._triggerRemoveEvent(),this._triggerChangeEvent()),this}removeAll(e=!0){return this.engine.nodes.forEach((e=>{delete e.el.gridstackNode,r.GridStackDDI.get().remove(e.el)})),this.engine.removeAll(e),this._triggerRemoveEvent(),this}setAnimation(e){return e?this.el.classList.add("grid-stack-animate"):this.el.classList.remove("grid-stack-animate"),this}setStatic(e,t=!0){return this.opts.staticGrid===e||(this.opts.staticGrid=e,this._setupRemoveDrop(),this._setupAcceptWidget(),this.engine.nodes.forEach((e=>this._prepareDragDropByNode(e))),t&&this._setStaticClass()),this}update(e,t){if(arguments.length>2){console.warn("gridstack.ts: `update(el, x, y, w, h)` is deprecated. Use `update({x, w, content, ...})`. It will be removed soon");let i=arguments,n=1;return t={x:i[n++],y:i[n++],w:i[n++],h:i[n++]},this.update(e,t)}return l.getElements(e).forEach((e=>{if(!e||!e.gridstackNode)return;let i=e.gridstackNode,n=Object.assign({},t);delete n.autoPosition;let s,o=["x","y","w","h"];if(o.some((e=>void 0!==n[e]&&n[e]!==i[e]))&&(s={},o.forEach((e=>{s[e]=void 0!==n[e]?n[e]:i[e],delete n[e]}))),!s&&(n.minW||n.minH||n.maxW||n.maxH)&&(s={}),n.content){let t=e.querySelector(".grid-stack-item-content");t&&t.innerHTML!==n.content&&(t.innerHTML=n.content),delete n.content}let r=!1,a=!1;for(const e in n)"_"!==e[0]&&i[e]!==n[e]&&(i[e]=n[e],r=!0,a=a||!this.opts.staticGrid&&("noResize"===e||"noMove"===e||"locked"===e));s&&(this.engine.cleanNodes().beginUpdate(i).moveNode(i,s),this._updateContainerHeight(),this._triggerChangeEvent(),this.engine.endUpdate()),r&&this._writeAttr(e,i),a&&this._prepareDragDropByNode(i)})),this}margin(e){if(!("string"==typeof e&&e.split(" ").length>1)){let t=o.Utils.parseHeight(e);if(this.opts.marginUnit===t.unit&&this.opts.margin===t.h)return}return this.opts.margin=e,this.opts.marginTop=this.opts.marginBottom=this.opts.marginLeft=this.opts.marginRight=void 0,this.initMargin(),this._updateStyles(!0),this}getMargin(){return this.opts.margin}willItFit(e){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");let e=arguments,t=0,i={x:e[t++],y:e[t++],w:e[t++],h:e[t++],autoPosition:e[t++]};return this.willItFit(i)}return this.engine.willItFit(e)}_triggerChangeEvent(){if(this.engine.batchMode)return this;let e=this.engine.getDirtyNodes(!0);return e&&e.length&&(this._ignoreLayoutsNodeChange||this.engine.layoutsNodesChange(e),this._triggerEvent("change",e)),this.engine.saveInitial(),this}_triggerAddEvent(){return this.engine.batchMode||this.engine.addedNodes&&this.engine.addedNodes.length>0&&(this._ignoreLayoutsNodeChange||this.engine.layoutsNodesChange(this.engine.addedNodes),this.engine.addedNodes.forEach((e=>{delete e._dirty})),this._triggerEvent("added",this.engine.addedNodes),this.engine.addedNodes=[]),this}_triggerRemoveEvent(){return this.engine.batchMode||this.engine.removedNodes&&this.engine.removedNodes.length>0&&(this._triggerEvent("removed",this.engine.removedNodes),this.engine.removedNodes=[]),this}_triggerEvent(e,t){let i=t?new CustomEvent(e,{bubbles:!1,detail:t}):new Event(e);return this.el.dispatchEvent(i),this}_removeStylesheet(){return this._styles&&(o.Utils.removeStylesheet(this._styles._id),delete this._styles),this}_updateStyles(e=!1,t){if(e&&this._removeStylesheet(),this._updateContainerHeight(),0===this.opts.cellHeight)return this;let i=this.opts.cellHeight,n=this.opts.cellHeightUnit,s=`.${this.opts._styleSheetClass} > .${this.opts.itemClass}`;if(!this._styles){let e="gridstack-style-"+(1e5*Math.random()).toFixed(),t=this.opts.styleInHead?void 0:this.el.parentNode;if(this._styles=o.Utils.createStylesheet(e,t),!this._styles)return this;this._styles._id=e,this._styles._max=0,o.Utils.addCSSRule(this._styles,s,`min-height: ${i}${n}`);let r=this.opts.marginTop+this.opts.marginUnit,a=this.opts.marginBottom+this.opts.marginUnit,l=this.opts.marginRight+this.opts.marginUnit,h=this.opts.marginLeft+this.opts.marginUnit,u=`${s} > .grid-stack-item-content`,c=`.${this.opts._styleSheetClass} > .grid-stack-placeholder > .placeholder-content`;o.Utils.addCSSRule(this._styles,u,`top: ${r}; right: ${l}; bottom: ${a}; left: ${h};`),o.Utils.addCSSRule(this._styles,c,`top: ${r}; right: ${l}; bottom: ${a}; left: ${h};`),o.Utils.addCSSRule(this._styles,`${s} > .ui-resizable-ne`,`right: ${l}`),o.Utils.addCSSRule(this._styles,`${s} > .ui-resizable-e`,`right: ${l}`),o.Utils.addCSSRule(this._styles,`${s} > .ui-resizable-se`,`right: ${l}; bottom: ${a}`),o.Utils.addCSSRule(this._styles,`${s} > .ui-resizable-nw`,`left: ${h}`),o.Utils.addCSSRule(this._styles,`${s} > .ui-resizable-w`,`left: ${h}`),o.Utils.addCSSRule(this._styles,`${s} > .ui-resizable-sw`,`left: ${h}; bottom: ${a}`)}if((t=t||this._styles._max)>this._styles._max){let e=e=>i*e+n;for(let i=this._styles._max+1;i<=t;i++){let t=e(i);o.Utils.addCSSRule(this._styles,`${s}[gs-y="${i-1}"]`,`top: ${e(i-1)}`),o.Utils.addCSSRule(this._styles,`${s}[gs-h="${i}"]`,`height: ${t}`),o.Utils.addCSSRule(this._styles,`${s}[gs-min-h="${i}"]`,`min-height: ${t}`),o.Utils.addCSSRule(this._styles,`${s}[gs-max-h="${i}"]`,`max-height: ${t}`)}this._styles._max=t}return this}_updateContainerHeight(){if(!this.engine||this.engine.batchMode)return this;let e=this.getRow()+this._extraDragRow,t=parseInt(getComputedStyle(this.el)["min-height"]);if(t>0){let i=Math.round(t/this.getCellHeight(!0));ethis.cellHeight()),this.opts.cellHeightThrottle)),this._cellHeightThrottle()):this.cellHeight()),this.engine.nodes.forEach((e=>{e.subGrid&&e.subGrid.onParentResize()})),this}_updateWindowResizeEvent(e=!1){const t=(this._isAutoCellHeight||!this.opts.disableOneColumnMode)&&!this.opts._isNested;return e||!t||this._windowResizeBind?!e&&t||!this._windowResizeBind||(window.removeEventListener("resize",this._windowResizeBind),delete this._windowResizeBind):(this._windowResizeBind=this.onParentResize.bind(this),window.addEventListener("resize",this._windowResizeBind)),this}static getElement(e=".grid-stack-item"){return o.Utils.getElement(e)}static getElements(e=".grid-stack-item"){return o.Utils.getElements(e)}static getGridElement(e){return l.getElement(e)}static getGridElements(e){return o.Utils.getElements(e)}initMargin(){let e,t=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]):(e=o.Utils.parseHeight(this.opts.margin),this.opts.marginUnit=e.unit,t=this.opts.margin=e.h),void 0===this.opts.marginTop?this.opts.marginTop=t:(e=o.Utils.parseHeight(this.opts.marginTop),this.opts.marginTop=e.h,delete this.opts.margin),void 0===this.opts.marginBottom?this.opts.marginBottom=t:(e=o.Utils.parseHeight(this.opts.marginBottom),this.opts.marginBottom=e.h,delete this.opts.margin),void 0===this.opts.marginRight?this.opts.marginRight=t:(e=o.Utils.parseHeight(this.opts.marginRight),this.opts.marginRight=e.h,delete this.opts.margin),void 0===this.opts.marginLeft?this.opts.marginLeft=t:(e=o.Utils.parseHeight(this.opts.marginLeft),this.opts.marginLeft=e.h,delete this.opts.margin),this.opts.marginUnit=e.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}static setupDragIn(e,t){}movable(e,t){return this}resizable(e,t){return this}disable(){return this}enable(){return this}enableMove(e){return this}enableResize(e){return this}_setupAcceptWidget(){return this}_setupRemoveDrop(){return this}_prepareDragDropByNode(e){return this}_onStartMoving(e,t,i,n,s,o){}_dragOrResize(e,t,i,n,s,o){}_leave(e,t){}}t.GridStack=l,l.Utils=o.Utils,l.Engine=s.GridStackEngine},906:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=i(21),s=i(28);t.$=s,i(87),i(949),function(e){for(var i in e)t.hasOwnProperty(i)||(t[i]=e[i])}(i(21));class o extends n.GridStackDD{resizable(e,t,i,n){let o=s(e);if("enable"===t)o.resizable().resizable(t);else if("disable"===t||"destroy"===t)o.data("ui-resizable")&&o.resizable(t);else if("option"===t)o.resizable(t,i,n);else{const i=e.gridstackNode.grid;let n=o.data("gs-resize-handles")?o.data("gs-resize-handles"):i.opts.resizable.handles;o.resizable(Object.assign(Object.assign(Object.assign({},i.opts.resizable),{handles:n}),{start:t.start,stop:t.stop,resize:t.resize}))}return this}draggable(e,t,i,n){let o=s(e);if("enable"===t)o.draggable().draggable("enable");else if("disable"===t||"destroy"===t)o.data("ui-draggable")&&o.draggable(t);else if("option"===t)o.draggable(t,i,n);else{const i=e.gridstackNode.grid;o.draggable(Object.assign(Object.assign({},i.opts.draggable),{containment:i.opts._isNested&&!i.opts.dragOut?s(i.el).parent():i.opts.draggable.containment||null,start:t.start,stop:t.stop,drag:t.drag}))}return this}dragIn(e,t){return s(e).draggable(t),this}droppable(e,t,i,n){let o=s(e);return"function"!=typeof t.accept||t._accept||(t._accept=t.accept,t.accept=e=>t._accept(e.get(0))),"disable"===t||"destroy"===t?o.data("ui-droppable")&&o.droppable(t):o.droppable(t,i,n),this}isDroppable(e){let t=s(e);return Boolean(t.data("ui-droppable"))}isDraggable(e){let t=s(e);return Boolean(t.data("ui-draggable"))}isResizable(e){let t=s(e);return Boolean(t.data("ui-resizable"))}on(e,t,i){return s(e).on(t,((e,t)=>i(e,t.draggable?t.draggable[0]:e.target,t.helper?t.helper[0]:null))),this}off(e,t){return s(e).off(t),this}}t.GridStackDDJQueryUI=o,n.GridStackDD.registerPlugin(o)},593:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.obsolete=function(e,t,i,n,s){let o=(...o)=>(console.warn("gridstack.js: Function `"+i+"` is deprecated in "+s+" and has been replaced with `"+n+"`. It will be **completely** removed in v1.0"),t.apply(e,o));return o.prototype=t.prototype,o},t.obsoleteOpts=function(e,t,i,n){void 0!==e[t]&&(e[i]=e[t],console.warn("gridstack.js: Option `"+t+"` is deprecated in "+n+" and has been replaced with `"+i+"`. It will be **completely** removed in v1.0"))},t.obsoleteOptsDel=function(e,t,i,n){void 0!==e[t]&&console.warn("gridstack.js: Option `"+t+"` is deprecated in "+i+n)},t.obsoleteAttr=function(e,t,i,n){let s=e.getAttribute(t);null!==s&&(e.setAttribute(i,s),console.warn("gridstack.js: attribute `"+t+"`="+s+" is deprecated on this object in "+n+" and has been replaced with `"+i+"`. It will be **completely** removed in v1.0"))};class i{static getElements(e){if("string"==typeof e){let t=document.querySelectorAll(e);return t.length||"."===e[0]||"#"===e[0]||(t=document.querySelectorAll("."+e),t.length||(t=document.querySelectorAll("#"+e))),Array.from(t)}return[e]}static getElement(e){if("string"==typeof e){if(!e.length)return null;if("#"===e[0])return document.getElementById(e.substring(1));if("."===e[0]||"["===e[0])return document.querySelector(e);if(!isNaN(+e[0]))return document.getElementById(e);let t=document.querySelector(e);return t||(t=document.getElementById(e)),t||(t=document.querySelector("."+e)),t}return e}static isIntercepted(e,t){return!(e.y>=t.y+t.h||e.y+e.h<=t.y||e.x+e.w<=t.x||e.x>=t.x+t.w)}static isTouching(e,t){return i.isIntercepted(e,{x:t.x-.5,y:t.y-.5,w:t.w+1,h:t.h+1})}static sort(e,t,i){return i=i||e.reduce(((e,t)=>Math.max(t.x+t.w,e)),0)||12,-1===t?e.sort(((e,t)=>t.x+t.y*i-(e.x+e.y*i))):e.sort(((e,t)=>e.x+e.y*i-(t.x+t.y*i)))}static createStylesheet(e,t){let i=document.createElement("style");return i.setAttribute("type","text/css"),i.setAttribute("gs-style-id",e),i.styleSheet?i.styleSheet.cssText="":i.appendChild(document.createTextNode("")),t?t.insertBefore(i,t.firstChild):(t=document.getElementsByTagName("head")[0]).appendChild(i),i.sheet}static removeStylesheet(e){let t=document.querySelector("STYLE[gs-style-id="+e+"]");t&&t.parentNode&&t.remove()}static addCSSRule(e,t,i){"function"==typeof e.addRule?e.addRule(t,i):"function"==typeof e.insertRule&&e.insertRule(`${t}{${i}}`)}static toBool(e){return"boolean"==typeof e?e:"string"==typeof e?!(""===(e=e.toLowerCase())||"no"===e||"false"===e||"0"===e):Boolean(e)}static toNumber(e){return null===e||0===e.length?void 0:Number(e)}static parseHeight(e){let t,i="px";if("string"==typeof e){let n=e.match(/^(-[0-9]+\.[0-9]+|[0-9]*\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw|%)?$/);if(!n)throw new Error("Invalid height");i=n[2]||"px",t=parseFloat(n[1])}else t=e;return{h:t,unit:i}}static defaults(e,...t){return t.forEach((t=>{for(const i in t){if(!t.hasOwnProperty(i))return;null===e[i]||void 0===e[i]?e[i]=t[i]:"object"==typeof t[i]&&"object"==typeof e[i]&&this.defaults(e[i],t[i])}})),e}static same(e,t){if("object"!=typeof e)return e==t;if(typeof e!=typeof t)return!1;if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const i in e)if(e[i]!==t[i])return!1;return!0}static copyPos(e,t,i=!1){return e.x=t.x,e.y=t.y,e.w=t.w,e.h=t.h,i?(t.minW&&(e.minW=t.minW),t.minH&&(e.minH=t.minH),t.maxW&&(e.maxW=t.maxW),t.maxH&&(e.maxH=t.maxH),e):e}static samePos(e,t){return e&&t&&e.x===t.x&&e.y===t.y&&e.w===t.w&&e.h===t.h}static removeInternalAndSame(e,t){if("object"==typeof e&&"object"==typeof t)for(let i in e){let n=e[i];if(n&&"object"==typeof n&&void 0!==t[i]){for(let e in n)n[e]!==t[i][e]&&"_"!==e[0]||delete n[e];Object.keys(n).length||delete e[i]}else n!==t[i]&&"_"!==i[0]||delete e[i]}}static closestByClass(e,t){for(;e=e.parentElement;)if(e.classList.contains(t))return e;return null}static throttle(e,t){let i=!1;return(...n)=>{i||(i=!0,setTimeout((()=>{e(...n),i=!1}),t))}}static removePositioningStyles(e){let t=e.style;t.position&&t.removeProperty("position"),t.left&&t.removeProperty("left"),t.top&&t.removeProperty("top"),t.width&&t.removeProperty("width"),t.height&&t.removeProperty("height")}static getScrollElement(e){if(!e)return document.scrollingElement;const t=getComputedStyle(e);return/(auto|scroll)/.test(t.overflow+t.overflowY)?e:this.getScrollElement(e.parentElement)}static updateScrollPosition(e,t,i){let n=e.getBoundingClientRect(),s=window.innerHeight||document.documentElement.clientHeight;if(n.top<0||n.bottom>s){let o=n.bottom-s,r=n.top,a=this.getScrollElement(e);if(null!==a){let l=a.scrollTop;n.top<0&&i<0?e.offsetHeight>s?a.scrollTop+=i:a.scrollTop+=Math.abs(r)>Math.abs(i)?i:r:i>0&&(e.offsetHeight>s?a.scrollTop+=i:a.scrollTop+=o>i?i:o),t.top+=a.scrollTop-l}}}static updateScrollResize(e,t,i){const n=this.getScrollElement(t),s=n.clientHeight,o=n===this.getScrollElement()?0:n.getBoundingClientRect().top,r=e.clientY-o,a=r>s-i;r{var n,s,o;s=[i(28)],void 0===(o="function"==typeof(n=function(e){e.ui=e.ui||{},e.ui.version="1.12.1";var t,i=0,n=Array.prototype.slice;e.cleanData=(t=e.cleanData,function(i){var n,s,o;for(o=0;null!=(s=i[o]);o++)try{(n=e._data(s,"events"))&&n.remove&&e(s).triggerHandler("remove")}catch(e){}t(i)}),e.widget=function(t,i,n){var s,o,r,a={},l=t.split(".")[0],h=l+"-"+(t=t.split(".")[1]);return n||(n=i,i=e.Widget),e.isArray(n)&&(n=e.extend.apply(null,[{}].concat(n))),e.expr[":"][h.toLowerCase()]=function(t){return!!e.data(t,h)},e[l]=e[l]||{},s=e[l][t],o=e[l][t]=function(e,t){if(!this._createWidget)return new o(e,t);arguments.length&&this._createWidget(e,t)},e.extend(o,s,{version:n.version,_proto:e.extend({},n),_childConstructors:[]}),(r=new i).options=e.widget.extend({},r.options),e.each(n,(function(t,n){e.isFunction(n)?a[t]=function(){function e(){return i.prototype[t].apply(this,arguments)}function s(e){return i.prototype[t].apply(this,e)}return function(){var t,i=this._super,o=this._superApply;return this._super=e,this._superApply=s,t=n.apply(this,arguments),this._super=i,this._superApply=o,t}}():a[t]=n})),o.prototype=e.widget.extend(r,{widgetEventPrefix:s&&r.widgetEventPrefix||t},a,{constructor:o,namespace:l,widgetName:t,widgetFullName:h}),s?(e.each(s._childConstructors,(function(t,i){var n=i.prototype;e.widget(n.namespace+"."+n.widgetName,o,i._proto)})),delete s._childConstructors):i._childConstructors.push(o),e.widget.bridge(t,o),o},e.widget.extend=function(t){for(var i,s,o=n.call(arguments,1),r=0,a=o.length;r",options:{classes:{},disabled:!1,create:null},_createWidget:function(t,n){n=e(n||this.defaultElement||this)[0],this.element=e(n),this.uuid=i++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=e(),this.hoverable=e(),this.focusable=e(),this.classesElementLookup={},n!==this&&(e.data(n,this.widgetFullName,this),this._on(!0,this.element,{remove:function(e){e.target===n&&this.destroy()}}),this.document=e(n.style?n.ownerDocument:n.document||n),this.window=e(this.document[0].defaultView||this.document[0].parentWindow)),this.options=e.widget.extend({},this.options,this._getCreateOptions(),t),this._create(),this.options.disabled&&this._setOptionDisabled(this.options.disabled),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:function(){return{}},_getCreateEventData:e.noop,_create:e.noop,_init:e.noop,destroy:function(){var t=this;this._destroy(),e.each(this.classesElementLookup,(function(e,i){t._removeClass(i,e)})),this.element.off(this.eventNamespace).removeData(this.widgetFullName),this.widget().off(this.eventNamespace).removeAttr("aria-disabled"),this.bindings.off(this.eventNamespace)},_destroy:e.noop,widget:function(){return this.element},option:function(t,i){var n,s,o,r=t;if(0===arguments.length)return e.widget.extend({},this.options);if("string"==typeof t)if(r={},n=t.split("."),t=n.shift(),n.length){for(s=r[t]=e.widget.extend({},this.options[t]),o=0;o=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}}),e.ui.plugin={add:function(t,i,n){var s,o=e.ui[t].prototype;for(s in n)o.plugins[s]=o.plugins[s]||[],o.plugins[s].push([i,n[s]])},call:function(e,t,i,n){var s,o=e.plugins[t];if(o&&(n||e.element[0].parentNode&&11!==e.element[0].parentNode.nodeType))for(s=0;s0||(this.handle=this._getHandle(t),!this.handle||(this._blurActiveElement(t),this._blockFrames(!0===i.iframeFix?"iframe":i.iframeFix),0)))},_blockFrames:function(t){this.iframeBlocks=this.document.find(t).map((function(){var t=e(this);return e("
").css("position","absolute").appendTo(t.parent()).outerWidth(t.outerWidth()).outerHeight(t.outerHeight()).offset(t.offset())[0]}))},_unblockFrames:function(){this.iframeBlocks&&(this.iframeBlocks.remove(),delete this.iframeBlocks)},_blurActiveElement:function(t){var i=e.ui.safeActiveElement(this.document[0]);e(t.target).closest(i).length||e.ui.safeBlur(i)},_mouseStart:function(t){var i=this.options;return this.helper=this._createHelper(t),this._addClass(this.helper,"ui-draggable-dragging"),this._cacheHelperProportions(),e.ui.ddmanager&&(e.ui.ddmanager.current=this),this._cacheMargins(),this.cssPosition=this.helper.css("position"),this.scrollParent=this.helper.scrollParent(!0),this.offsetParent=this.helper.offsetParent(),this.hasFixedAncestor=this.helper.parents().filter((function(){return"fixed"===e(this).css("position")})).length>0,this.positionAbs=this.element.offset(),this._refreshOffsets(t),this.originalPosition=this.position=this._generatePosition(t,!1),this.originalPageX=t.pageX,this.originalPageY=t.pageY,i.cursorAt&&this._adjustOffsetFromHelper(i.cursorAt),this._setContainment(),!1===this._trigger("start",t)?(this._clear(),!1):(this._cacheHelperProportions(),e.ui.ddmanager&&!i.dropBehaviour&&e.ui.ddmanager.prepareOffsets(this,t),this._mouseDrag(t,!0),e.ui.ddmanager&&e.ui.ddmanager.dragStart(this,t),!0)},_refreshOffsets:function(e){this.offset={top:this.positionAbs.top-this.margins.top,left:this.positionAbs.left-this.margins.left,scroll:!1,parent:this._getParentOffset(),relative:this._getRelativeOffset()},this.offset.click={left:e.pageX-this.offset.left,top:e.pageY-this.offset.top}},_mouseDrag:function(t,i){if(this.hasFixedAncestor&&(this.offset.parent=this._getParentOffset()),this.position=this._generatePosition(t,!0),this.positionAbs=this._convertPositionTo("absolute"),!i){var n=this._uiHash();if(!1===this._trigger("drag",t,n))return this._mouseUp(new e.Event("mouseup",t)),!1;this.position=n.position}return this.helper[0].style.left=this.position.left+"px",this.helper[0].style.top=this.position.top+"px",e.ui.ddmanager&&e.ui.ddmanager.drag(this,t),!1},_mouseStop:function(t){var i=this,n=!1;return e.ui.ddmanager&&!this.options.dropBehaviour&&(n=e.ui.ddmanager.drop(this,t)),this.dropped&&(n=this.dropped,this.dropped=!1),"invalid"===this.options.revert&&!n||"valid"===this.options.revert&&n||!0===this.options.revert||e.isFunction(this.options.revert)&&this.options.revert.call(this.element,n)?e(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),(function(){!1!==i._trigger("stop",t)&&i._clear()})):!1!==this._trigger("stop",t)&&this._clear(),!1},_mouseUp:function(t){return this._unblockFrames(),e.ui.ddmanager&&e.ui.ddmanager.dragStop(this,t),this.handleElement.is(t.target)&&this.element.trigger("focus"),e.ui.mouse.prototype._mouseUp.call(this,t)},cancel:function(){return this.helper.is(".ui-draggable-dragging")?this._mouseUp(new e.Event("mouseup",{target:this.element[0]})):this._clear(),this},_getHandle:function(t){return!this.options.handle||!!e(t.target).closest(this.element.find(this.options.handle)).length},_setHandleClassName:function(){this.handleElement=this.options.handle?this.element.find(this.options.handle):this.element,this._addClass(this.handleElement,"ui-draggable-handle")},_removeHandleClassName:function(){this._removeClass(this.handleElement,"ui-draggable-handle")},_createHelper:function(t){var i=this.options,n=e.isFunction(i.helper),s=n?e(i.helper.apply(this.element[0],[t])):"clone"===i.helper?this.element.clone().removeAttr("id"):this.element;return s.parents("body").length||s.appendTo("parent"===i.appendTo?this.element[0].parentNode:i.appendTo),n&&s[0]===this.element[0]&&this._setPositionRelative(),s[0]===this.element[0]||/(fixed|absolute)/.test(s.css("position"))||s.css("position","absolute"),s},_setPositionRelative:function(){/^(?:r|a|f)/.test(this.element.css("position"))||(this.element[0].style.position="relative")},_adjustOffsetFromHelper:function(t){"string"==typeof t&&(t=t.split(" ")),e.isArray(t)&&(t={left:+t[0],top:+t[1]||0}),"left"in t&&(this.offset.click.left=t.left+this.margins.left),"right"in t&&(this.offset.click.left=this.helperProportions.width-t.right+this.margins.left),"top"in t&&(this.offset.click.top=t.top+this.margins.top),"bottom"in t&&(this.offset.click.top=this.helperProportions.height-t.bottom+this.margins.top)},_isRootNode:function(e){return/(html|body)/i.test(e.tagName)||e===this.document[0]},_getParentOffset:function(){var t=this.offsetParent.offset(),i=this.document[0];return"absolute"===this.cssPosition&&this.scrollParent[0]!==i&&e.contains(this.scrollParent[0],this.offsetParent[0])&&(t.left+=this.scrollParent.scrollLeft(),t.top+=this.scrollParent.scrollTop()),this._isRootNode(this.offsetParent[0])&&(t={top:0,left:0}),{top:t.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:t.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"!==this.cssPosition)return{top:0,left:0};var e=this.element.position(),t=this._isRootNode(this.scrollParent[0]);return{top:e.top-(parseInt(this.helper.css("top"),10)||0)+(t?0:this.scrollParent.scrollTop()),left:e.left-(parseInt(this.helper.css("left"),10)||0)+(t?0:this.scrollParent.scrollLeft())}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var t,i,n,s=this.options,o=this.document[0];this.relativeContainer=null,s.containment?"window"!==s.containment?"document"!==s.containment?s.containment.constructor!==Array?("parent"===s.containment&&(s.containment=this.helper[0].parentNode),(n=(i=e(s.containment))[0])&&(t=/(scroll|auto)/.test(i.css("overflow")),this.containment=[(parseInt(i.css("borderLeftWidth"),10)||0)+(parseInt(i.css("paddingLeft"),10)||0),(parseInt(i.css("borderTopWidth"),10)||0)+(parseInt(i.css("paddingTop"),10)||0),(t?Math.max(n.scrollWidth,n.offsetWidth):n.offsetWidth)-(parseInt(i.css("borderRightWidth"),10)||0)-(parseInt(i.css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(t?Math.max(n.scrollHeight,n.offsetHeight):n.offsetHeight)-(parseInt(i.css("borderBottomWidth"),10)||0)-(parseInt(i.css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom],this.relativeContainer=i)):this.containment=s.containment:this.containment=[0,0,e(o).width()-this.helperProportions.width-this.margins.left,(e(o).height()||o.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top]:this.containment=[e(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,e(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,e(window).scrollLeft()+e(window).width()-this.helperProportions.width-this.margins.left,e(window).scrollTop()+(e(window).height()||o.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top]:this.containment=null},_convertPositionTo:function(e,t){t||(t=this.position);var i="absolute"===e?1:-1,n=this._isRootNode(this.scrollParent[0]);return{top:t.top+this.offset.relative.top*i+this.offset.parent.top*i-("fixed"===this.cssPosition?-this.offset.scroll.top:n?0:this.offset.scroll.top)*i,left:t.left+this.offset.relative.left*i+this.offset.parent.left*i-("fixed"===this.cssPosition?-this.offset.scroll.left:n?0:this.offset.scroll.left)*i}},_generatePosition:function(e,t){var i,n,s,o,r=this.options,a=this._isRootNode(this.scrollParent[0]),l=e.pageX,h=e.pageY;return a&&this.offset.scroll||(this.offset.scroll={top:this.scrollParent.scrollTop(),left:this.scrollParent.scrollLeft()}),t&&(this.containment&&(this.relativeContainer?(n=this.relativeContainer.offset(),i=[this.containment[0]+n.left,this.containment[1]+n.top,this.containment[2]+n.left,this.containment[3]+n.top]):i=this.containment,e.pageX-this.offset.click.lefti[2]&&(l=i[2]+this.offset.click.left),e.pageY-this.offset.click.top>i[3]&&(h=i[3]+this.offset.click.top)),r.grid&&(s=r.grid[1]?this.originalPageY+Math.round((h-this.originalPageY)/r.grid[1])*r.grid[1]:this.originalPageY,h=i?s-this.offset.click.top>=i[1]||s-this.offset.click.top>i[3]?s:s-this.offset.click.top>=i[1]?s-r.grid[1]:s+r.grid[1]:s,o=r.grid[0]?this.originalPageX+Math.round((l-this.originalPageX)/r.grid[0])*r.grid[0]:this.originalPageX,l=i?o-this.offset.click.left>=i[0]||o-this.offset.click.left>i[2]?o:o-this.offset.click.left>=i[0]?o-r.grid[0]:o+r.grid[0]:o),"y"===r.axis&&(l=this.originalPageX),"x"===r.axis&&(h=this.originalPageY)),{top:h-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.offset.scroll.top:a?0:this.offset.scroll.top),left:l-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.offset.scroll.left:a?0:this.offset.scroll.left)}},_clear:function(){this._removeClass(this.helper,"ui-draggable-dragging"),this.helper[0]===this.element[0]||this.cancelHelperRemoval||this.helper.remove(),this.helper=null,this.cancelHelperRemoval=!1,this.destroyOnClear&&this.destroy()},_trigger:function(t,i,n){return n=n||this._uiHash(),e.ui.plugin.call(this,t,[i,n,this],!0),/^(drag|start|stop)/.test(t)&&(this.positionAbs=this._convertPositionTo("absolute"),n.offset=this.positionAbs),e.Widget.prototype._trigger.call(this,t,i,n)},plugins:{},_uiHash:function(){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}}),e.ui.plugin.add("draggable","connectToSortable",{start:function(t,i,n){var s=e.extend({},i,{item:n.element});n.sortables=[],e(n.options.connectToSortable).each((function(){var i=e(this).sortable("instance");i&&!i.options.disabled&&(n.sortables.push(i),i.refreshPositions(),i._trigger("activate",t,s))}))},stop:function(t,i,n){var s=e.extend({},i,{item:n.element});n.cancelHelperRemoval=!1,e.each(n.sortables,(function(){var e=this;e.isOver?(e.isOver=0,n.cancelHelperRemoval=!0,e.cancelHelperRemoval=!1,e._storedCSS={position:e.placeholder.css("position"),top:e.placeholder.css("top"),left:e.placeholder.css("left")},e._mouseStop(t),e.options.helper=e.options._helper):(e.cancelHelperRemoval=!0,e._trigger("deactivate",t,s))}))},drag:function(t,i,n){e.each(n.sortables,(function(){var s=!1,o=this;o.positionAbs=n.positionAbs,o.helperProportions=n.helperProportions,o.offset.click=n.offset.click,o._intersectsWith(o.containerCache)&&(s=!0,e.each(n.sortables,(function(){return this.positionAbs=n.positionAbs,this.helperProportions=n.helperProportions,this.offset.click=n.offset.click,this!==o&&this._intersectsWith(this.containerCache)&&e.contains(o.element[0],this.element[0])&&(s=!1),s}))),s?(o.isOver||(o.isOver=1,n._parent=i.helper.parent(),o.currentItem=i.helper.appendTo(o.element).data("ui-sortable-item",!0),o.options._helper=o.options.helper,o.options.helper=function(){return i.helper[0]},t.target=o.currentItem[0],o._mouseCapture(t,!0),o._mouseStart(t,!0,!0),o.offset.click.top=n.offset.click.top,o.offset.click.left=n.offset.click.left,o.offset.parent.left-=n.offset.parent.left-o.offset.parent.left,o.offset.parent.top-=n.offset.parent.top-o.offset.parent.top,n._trigger("toSortable",t),n.dropped=o.element,e.each(n.sortables,(function(){this.refreshPositions()})),n.currentItem=n.element,o.fromOutside=n),o.currentItem&&(o._mouseDrag(t),i.position=o.position)):o.isOver&&(o.isOver=0,o.cancelHelperRemoval=!0,o.options._revert=o.options.revert,o.options.revert=!1,o._trigger("out",t,o._uiHash(o)),o._mouseStop(t,!0),o.options.revert=o.options._revert,o.options.helper=o.options._helper,o.placeholder&&o.placeholder.remove(),i.helper.appendTo(n._parent),n._refreshOffsets(t),i.position=n._generatePosition(t,!0),n._trigger("fromSortable",t),n.dropped=!1,e.each(n.sortables,(function(){this.refreshPositions()})))}))}}),e.ui.plugin.add("draggable","cursor",{start:function(t,i,n){var s=e("body"),o=n.options;s.css("cursor")&&(o._cursor=s.css("cursor")),s.css("cursor",o.cursor)},stop:function(t,i,n){var s=n.options;s._cursor&&e("body").css("cursor",s._cursor)}}),e.ui.plugin.add("draggable","opacity",{start:function(t,i,n){var s=e(i.helper),o=n.options;s.css("opacity")&&(o._opacity=s.css("opacity")),s.css("opacity",o.opacity)},stop:function(t,i,n){var s=n.options;s._opacity&&e(i.helper).css("opacity",s._opacity)}}),e.ui.plugin.add("draggable","scroll",{start:function(e,t,i){i.scrollParentNotHidden||(i.scrollParentNotHidden=i.helper.scrollParent(!1)),i.scrollParentNotHidden[0]!==i.document[0]&&"HTML"!==i.scrollParentNotHidden[0].tagName&&(i.overflowOffset=i.scrollParentNotHidden.offset())},drag:function(t,i,n){var s=n.options,o=!1,r=n.scrollParentNotHidden[0],a=n.document[0];r!==a&&"HTML"!==r.tagName?(s.axis&&"x"===s.axis||(n.overflowOffset.top+r.offsetHeight-t.pageY=0;d--)h=(l=n.snapElements[d].left-n.margins.left)+n.snapElements[d].width,c=(u=n.snapElements[d].top-n.margins.top)+n.snapElements[d].height,vh+g||bc+g||!e.contains(n.snapElements[d].item.ownerDocument,n.snapElements[d].item)?(n.snapElements[d].snapping&&n.options.snap.release&&n.options.snap.release.call(n.element,t,e.extend(n._uiHash(),{snapItem:n.snapElements[d].item})),n.snapElements[d].snapping=!1):("inner"!==f.snapMode&&(s=Math.abs(u-b)<=g,o=Math.abs(c-y)<=g,r=Math.abs(l-v)<=g,a=Math.abs(h-m)<=g,s&&(i.position.top=n._convertPositionTo("relative",{top:u-n.helperProportions.height,left:0}).top),o&&(i.position.top=n._convertPositionTo("relative",{top:c,left:0}).top),r&&(i.position.left=n._convertPositionTo("relative",{top:0,left:l-n.helperProportions.width}).left),a&&(i.position.left=n._convertPositionTo("relative",{top:0,left:h}).left)),p=s||o||r||a,"outer"!==f.snapMode&&(s=Math.abs(u-y)<=g,o=Math.abs(c-b)<=g,r=Math.abs(l-m)<=g,a=Math.abs(h-v)<=g,s&&(i.position.top=n._convertPositionTo("relative",{top:u,left:0}).top),o&&(i.position.top=n._convertPositionTo("relative",{top:c-n.helperProportions.height,left:0}).top),r&&(i.position.left=n._convertPositionTo("relative",{top:0,left:l}).left),a&&(i.position.left=n._convertPositionTo("relative",{top:0,left:h-n.helperProportions.width}).left)),!n.snapElements[d].snapping&&(s||o||r||a||p)&&n.options.snap.snap&&n.options.snap.snap.call(n.element,t,e.extend(n._uiHash(),{snapItem:n.snapElements[d].item})),n.snapElements[d].snapping=s||o||r||a||p)}}),e.ui.plugin.add("draggable","stack",{start:function(t,i,n){var s,o=n.options,r=e.makeArray(e(o.stack)).sort((function(t,i){return(parseInt(e(t).css("zIndex"),10)||0)-(parseInt(e(i).css("zIndex"),10)||0)}));r.length&&(s=parseInt(e(r[0]).css("zIndex"),10)||0,e(r).each((function(t){e(this).css("zIndex",s+t)})),this.css("zIndex",s+r.length))}}),e.ui.plugin.add("draggable","zIndex",{start:function(t,i,n){var s=e(i.helper),o=n.options;s.css("zIndex")&&(o._zIndex=s.css("zIndex")),s.css("zIndex",o.zIndex)},stop:function(t,i,n){var s=n.options;s._zIndex&&e(i.helper).css("zIndex",s._zIndex)}}),e.ui.draggable,e.widget("ui.droppable",{version:"1.12.1",widgetEventPrefix:"drop",options:{accept:"*",addClasses:!0,greedy:!1,scope:"default",tolerance:"intersect",activate:null,deactivate:null,drop:null,out:null,over:null},_create:function(){var t,i=this.options,n=i.accept;this.isover=!1,this.isout=!0,this.accept=e.isFunction(n)?n:function(e){return e.is(n)},this.proportions=function(){if(!arguments.length)return t||(t={width:this.element[0].offsetWidth,height:this.element[0].offsetHeight});t=arguments[0]},this._addToManager(i.scope),i.addClasses&&this._addClass("ui-droppable")},_addToManager:function(t){e.ui.ddmanager.droppables[t]=e.ui.ddmanager.droppables[t]||[],e.ui.ddmanager.droppables[t].push(this)},_splice:function(e){for(var t=0;t=t&&e=u&&r<=d||l>=u&&l<=d||rd)&&(o>=h&&o<=c||a>=h&&a<=c||oc);default:return!1}}}();e.ui.ddmanager={current:null,droppables:{default:[]},prepareOffsets:function(t,i){var n,s,o=e.ui.ddmanager.droppables[t.options.scope]||[],r=i?i.type:null,a=(t.currentItem||t.element).find(":data(ui-droppable)").addBack();e:for(n=0;n0||(t[n]=1,s=t[n]>0,t[n]=0,s)},_create:function(){var t,i=this.options,n=this;this._addClass("ui-resizable"),e.extend(this,{_aspectRatio:!!i.aspectRatio,aspectRatio:i.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:i.helper||i.ghost||i.animate?i.helper||"ui-resizable-helper":null}),this.element[0].nodeName.match(/^(canvas|textarea|input|select|button|img)$/i)&&(this.element.wrap(e("
").css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")})),this.element=this.element.parent().data("ui-resizable",this.element.resizable("instance")),this.elementIsWrapper=!0,t={marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom"),marginLeft:this.originalElement.css("marginLeft")},this.element.css(t),this.originalElement.css("margin",0),this.originalResizeStyle=this.originalElement.css("resize"),this.originalElement.css("resize","none"),this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"})),this.originalElement.css(t),this._proportionallyResize()),this._setupHandles(),i.autoHide&&e(this.element).on("mouseenter",(function(){i.disabled||(n._removeClass("ui-resizable-autohide"),n._handles.show())})).on("mouseleave",(function(){i.disabled||n.resizing||(n._addClass("ui-resizable-autohide"),n._handles.hide())})),this._mouseInit()},_destroy:function(){this._mouseDestroy();var t,i=function(t){e(t).removeData("resizable").removeData("ui-resizable").off(".resizable").find(".ui-resizable-handle").remove()};return this.elementIsWrapper&&(i(this.element),t=this.element,this.originalElement.css({position:t.css("position"),width:t.outerWidth(),height:t.outerHeight(),top:t.css("top"),left:t.css("left")}).insertAfter(t),t.remove()),this.originalElement.css("resize",this.originalResizeStyle),i(this.originalElement),this},_setOption:function(e,t){switch(this._super(e,t),e){case"handles":this._removeHandles(),this._setupHandles()}},_setupHandles:function(){var t,i,n,s,o,r=this.options,a=this;if(this.handles=r.handles||(e(".ui-resizable-handle",this.element).length?{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"}:"e,s,se"),this._handles=e(),this.handles.constructor===String)for("all"===this.handles&&(this.handles="n,e,s,w,se,sw,ne,nw"),n=this.handles.split(","),this.handles={},i=0;i"),this._addClass(o,"ui-resizable-handle "+s),o.css({zIndex:r.zIndex}),this.handles[t]=".ui-resizable-"+t,this.element.append(o);this._renderAxis=function(t){var i,n,s,o;for(i in t=t||this.element,this.handles)this.handles[i].constructor===String?this.handles[i]=this.element.children(this.handles[i]).first().show():(this.handles[i].jquery||this.handles[i].nodeType)&&(this.handles[i]=e(this.handles[i]),this._on(this.handles[i],{mousedown:a._mouseDown})),this.elementIsWrapper&&this.originalElement[0].nodeName.match(/^(textarea|input|select|button)$/i)&&(n=e(this.handles[i],this.element),o=/sw|ne|nw|se|n|s/.test(i)?n.outerHeight():n.outerWidth(),s=["padding",/ne|nw|n/.test(i)?"Top":/se|sw|s/.test(i)?"Bottom":/^e$/.test(i)?"Right":"Left"].join(""),t.css(s,o),this._proportionallyResize()),this._handles=this._handles.add(this.handles[i])},this._renderAxis(this.element),this._handles=this._handles.add(this.element.find(".ui-resizable-handle")),this._handles.disableSelection(),this._handles.on("mouseover",(function(){a.resizing||(this.className&&(o=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)),a.axis=o&&o[1]?o[1]:"se")})),r.autoHide&&(this._handles.hide(),this._addClass("ui-resizable-autohide"))},_removeHandles:function(){this._handles.remove()},_mouseCapture:function(t){var i,n,s=!1;for(i in this.handles)((n=e(this.handles[i])[0])===t.target||e.contains(n,t.target))&&(s=!0);return!this.options.disabled&&s},_mouseStart:function(t){var i,n,s,o=this.options,r=this.element;return this.resizing=!0,this._renderProxy(),i=this._num(this.helper.css("left")),n=this._num(this.helper.css("top")),o.containment&&(i+=e(o.containment).scrollLeft()||0,n+=e(o.containment).scrollTop()||0),this.offset=this.helper.offset(),this.position={left:i,top:n},this.size=this._helper?{width:this.helper.width(),height:this.helper.height()}:{width:r.width(),height:r.height()},this.originalSize=this._helper?{width:r.outerWidth(),height:r.outerHeight()}:{width:r.width(),height:r.height()},this.sizeDiff={width:r.outerWidth()-r.width(),height:r.outerHeight()-r.height()},this.originalPosition={left:i,top:n},this.originalMousePosition={left:t.pageX,top:t.pageY},this.aspectRatio="number"==typeof o.aspectRatio?o.aspectRatio:this.originalSize.width/this.originalSize.height||1,s=e(".ui-resizable-"+this.axis).css("cursor"),e("body").css("cursor","auto"===s?this.axis+"-resize":s),this._addClass("ui-resizable-resizing"),this._propagate("start",t),!0},_mouseDrag:function(t){var i,n,s=this.originalMousePosition,o=this.axis,r=t.pageX-s.left||0,a=t.pageY-s.top||0,l=this._change[o];return this._updatePrevProperties(),!!l&&(i=l.apply(this,[t,r,a]),this._updateVirtualBoundaries(t.shiftKey),(this._aspectRatio||t.shiftKey)&&(i=this._updateRatio(i,t)),i=this._respectSize(i,t),this._updateCache(i),this._propagate("resize",t),n=this._applyChanges(),!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize(),e.isEmptyObject(n)||(this._updatePrevProperties(),this._trigger("resize",t,this.ui()),this._applyChanges()),!1)},_mouseStop:function(t){this.resizing=!1;var i,n,s,o,r,a,l,h=this.options,u=this;return this._helper&&(s=(n=(i=this._proportionallyResizeElements).length&&/textarea/i.test(i[0].nodeName))&&this._hasScroll(i[0],"left")?0:u.sizeDiff.height,o=n?0:u.sizeDiff.width,r={width:u.helper.width()-o,height:u.helper.height()-s},a=parseFloat(u.element.css("left"))+(u.position.left-u.originalPosition.left)||null,l=parseFloat(u.element.css("top"))+(u.position.top-u.originalPosition.top)||null,h.animate||this.element.css(e.extend(r,{top:l,left:a})),u.helper.height(u.size.height),u.helper.width(u.size.width),this._helper&&!h.animate&&this._proportionallyResize()),e("body").css("cursor","auto"),this._removeClass("ui-resizable-resizing"),this._propagate("stop",t),this._helper&&this.helper.remove(),!1},_updatePrevProperties:function(){this.prevPosition={top:this.position.top,left:this.position.left},this.prevSize={width:this.size.width,height:this.size.height}},_applyChanges:function(){var e={};return this.position.top!==this.prevPosition.top&&(e.top=this.position.top+"px"),this.position.left!==this.prevPosition.left&&(e.left=this.position.left+"px"),this.size.width!==this.prevSize.width&&(e.width=this.size.width+"px"),this.size.height!==this.prevSize.height&&(e.height=this.size.height+"px"),this.helper.css(e),e},_updateVirtualBoundaries:function(e){var t,i,n,s,o,r=this.options;o={minWidth:this._isNumber(r.minWidth)?r.minWidth:0,maxWidth:this._isNumber(r.maxWidth)?r.maxWidth:1/0,minHeight:this._isNumber(r.minHeight)?r.minHeight:0,maxHeight:this._isNumber(r.maxHeight)?r.maxHeight:1/0},(this._aspectRatio||e)&&(t=o.minHeight*this.aspectRatio,n=o.minWidth/this.aspectRatio,i=o.maxHeight*this.aspectRatio,s=o.maxWidth/this.aspectRatio,t>o.minWidth&&(o.minWidth=t),n>o.minHeight&&(o.minHeight=n),ie.width,r=this._isNumber(e.height)&&t.minHeight&&t.minHeight>e.height,a=this.originalPosition.left+this.originalSize.width,l=this.originalPosition.top+this.originalSize.height,h=/sw|nw|w/.test(i),u=/nw|ne|n/.test(i);return o&&(e.width=t.minWidth),r&&(e.height=t.minHeight),n&&(e.width=t.maxWidth),s&&(e.height=t.maxHeight),o&&h&&(e.left=a-t.minWidth),n&&h&&(e.left=a-t.maxWidth),r&&u&&(e.top=l-t.minHeight),s&&u&&(e.top=l-t.maxHeight),e.width||e.height||e.left||!e.top?e.width||e.height||e.top||!e.left||(e.left=null):e.top=null,e},_getPaddingPlusBorderDimensions:function(e){for(var t=0,i=[],n=[e.css("borderTopWidth"),e.css("borderRightWidth"),e.css("borderBottomWidth"),e.css("borderLeftWidth")],s=[e.css("paddingTop"),e.css("paddingRight"),e.css("paddingBottom"),e.css("paddingLeft")];t<4;t++)i[t]=parseFloat(n[t])||0,i[t]+=parseFloat(s[t])||0;return{height:i[0]+i[2],width:i[1]+i[3]}},_proportionallyResize:function(){if(this._proportionallyResizeElements.length)for(var e,t=0,i=this.helper||this.element;t
"),this._addClass(this.helper,this._helper),this.helper.css({width:this.element.outerWidth(),height:this.element.outerHeight(),position:"absolute",left:this.elementOffset.left+"px",top:this.elementOffset.top+"px",zIndex:++i.zIndex}),this.helper.appendTo("body").disableSelection()):this.helper=this.element},_change:{e:function(e,t){return{width:this.originalSize.width+t}},w:function(e,t){var i=this.originalSize;return{left:this.originalPosition.left+t,width:i.width-t}},n:function(e,t,i){var n=this.originalSize;return{top:this.originalPosition.top+i,height:n.height-i}},s:function(e,t,i){return{height:this.originalSize.height+i}},se:function(t,i,n){return e.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[t,i,n]))},sw:function(t,i,n){return e.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[t,i,n]))},ne:function(t,i,n){return e.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[t,i,n]))},nw:function(t,i,n){return e.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[t,i,n]))}},_propagate:function(t,i){e.ui.plugin.call(this,t,[i,this.ui()]),"resize"!==t&&this._trigger(t,i,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}}),e.ui.plugin.add("resizable","animate",{stop:function(t){var i=e(this).resizable("instance"),n=i.options,s=i._proportionallyResizeElements,o=s.length&&/textarea/i.test(s[0].nodeName),r=o&&i._hasScroll(s[0],"left")?0:i.sizeDiff.height,a=o?0:i.sizeDiff.width,l={width:i.size.width-a,height:i.size.height-r},h=parseFloat(i.element.css("left"))+(i.position.left-i.originalPosition.left)||null,u=parseFloat(i.element.css("top"))+(i.position.top-i.originalPosition.top)||null;i.element.animate(e.extend(l,u&&h?{top:u,left:h}:{}),{duration:n.animateDuration,easing:n.animateEasing,step:function(){var n={width:parseFloat(i.element.css("width")),height:parseFloat(i.element.css("height")),top:parseFloat(i.element.css("top")),left:parseFloat(i.element.css("left"))};s&&s.length&&e(s[0]).css({width:n.width,height:n.height}),i._updateCache(n),i._propagate("resize",t)}})}}),e.ui.plugin.add("resizable","containment",{start:function(){var t,i,n,s,o,r,a,l=e(this).resizable("instance"),h=l.options,u=l.element,c=h.containment,d=c instanceof e?c.get(0):/parent/.test(c)?u.parent().get(0):c;d&&(l.containerElement=e(d),/document/.test(c)||c===document?(l.containerOffset={left:0,top:0},l.containerPosition={left:0,top:0},l.parentData={element:e(document),left:0,top:0,width:e(document).width(),height:e(document).height()||document.body.parentNode.scrollHeight}):(t=e(d),i=[],e(["Top","Right","Left","Bottom"]).each((function(e,n){i[e]=l._num(t.css("padding"+n))})),l.containerOffset=t.offset(),l.containerPosition=t.position(),l.containerSize={height:t.innerHeight()-i[3],width:t.innerWidth()-i[1]},n=l.containerOffset,s=l.containerSize.height,o=l.containerSize.width,r=l._hasScroll(d,"left")?d.scrollWidth:o,a=l._hasScroll(d)?d.scrollHeight:s,l.parentData={element:d,left:n.left,top:n.top,width:r,height:a}))},resize:function(t){var i,n,s,o,r=e(this).resizable("instance"),a=r.options,l=r.containerOffset,h=r.position,u=r._aspectRatio||t.shiftKey,c={top:0,left:0},d=r.containerElement,p=!0;d[0]!==document&&/static/.test(d.css("position"))&&(c=l),h.left<(r._helper?l.left:0)&&(r.size.width=r.size.width+(r._helper?r.position.left-l.left:r.position.left-c.left),u&&(r.size.height=r.size.width/r.aspectRatio,p=!1),r.position.left=a.helper?l.left:0),h.top<(r._helper?l.top:0)&&(r.size.height=r.size.height+(r._helper?r.position.top-l.top:r.position.top),u&&(r.size.width=r.size.height*r.aspectRatio,p=!1),r.position.top=r._helper?l.top:0),s=r.containerElement.get(0)===r.element.parent().get(0),o=/relative|absolute/.test(r.containerElement.css("position")),s&&o?(r.offset.left=r.parentData.left+r.position.left,r.offset.top=r.parentData.top+r.position.top):(r.offset.left=r.element.offset().left,r.offset.top=r.element.offset().top),i=Math.abs(r.sizeDiff.width+(r._helper?r.offset.left-c.left:r.offset.left-l.left)),n=Math.abs(r.sizeDiff.height+(r._helper?r.offset.top-c.top:r.offset.top-l.top)),i+r.size.width>=r.parentData.width&&(r.size.width=r.parentData.width-i,u&&(r.size.height=r.size.width/r.aspectRatio,p=!1)),n+r.size.height>=r.parentData.height&&(r.size.height=r.parentData.height-n,u&&(r.size.width=r.size.height*r.aspectRatio,p=!1)),p||(r.position.left=r.prevPosition.left,r.position.top=r.prevPosition.top,r.size.width=r.prevSize.width,r.size.height=r.prevSize.height)},stop:function(){var t=e(this).resizable("instance"),i=t.options,n=t.containerOffset,s=t.containerPosition,o=t.containerElement,r=e(t.helper),a=r.offset(),l=r.outerWidth()-t.sizeDiff.width,h=r.outerHeight()-t.sizeDiff.height;t._helper&&!i.animate&&/relative/.test(o.css("position"))&&e(this).css({left:a.left-s.left-n.left,width:l,height:h}),t._helper&&!i.animate&&/static/.test(o.css("position"))&&e(this).css({left:a.left-s.left-n.left,width:l,height:h})}}),e.ui.plugin.add("resizable","alsoResize",{start:function(){var t=e(this).resizable("instance").options;e(t.alsoResize).each((function(){var t=e(this);t.data("ui-resizable-alsoresize",{width:parseFloat(t.width()),height:parseFloat(t.height()),left:parseFloat(t.css("left")),top:parseFloat(t.css("top"))})}))},resize:function(t,i){var n=e(this).resizable("instance"),s=n.options,o=n.originalSize,r=n.originalPosition,a={height:n.size.height-o.height||0,width:n.size.width-o.width||0,top:n.position.top-r.top||0,left:n.position.left-r.left||0};e(s.alsoResize).each((function(){var t=e(this),n=e(this).data("ui-resizable-alsoresize"),s={},o=t.parents(i.originalElement[0]).length?["width","height"]:["width","height","top","left"];e.each(o,(function(e,t){var i=(n[t]||0)+(a[t]||0);i&&i>=0&&(s[t]=i||null)})),t.css(s)}))},stop:function(){e(this).removeData("ui-resizable-alsoresize")}}),e.ui.plugin.add("resizable","ghost",{start:function(){var t=e(this).resizable("instance"),i=t.size;t.ghost=t.originalElement.clone(),t.ghost.css({opacity:.25,display:"block",position:"relative",height:i.height,width:i.width,margin:0,left:0,top:0}),t._addClass(t.ghost,"ui-resizable-ghost"),!1!==e.uiBackCompat&&"string"==typeof t.options.ghost&&t.ghost.addClass(this.options.ghost),t.ghost.appendTo(t.helper)},resize:function(){var t=e(this).resizable("instance");t.ghost&&t.ghost.css({position:"relative",height:t.size.height,width:t.size.width})},stop:function(){var t=e(this).resizable("instance");t.ghost&&t.helper&&t.helper.get(0).removeChild(t.ghost.get(0))}}),e.ui.plugin.add("resizable","grid",{resize:function(){var t,i=e(this).resizable("instance"),n=i.options,s=i.size,o=i.originalSize,r=i.originalPosition,a=i.axis,l="number"==typeof n.grid?[n.grid,n.grid]:n.grid,h=l[0]||1,u=l[1]||1,c=Math.round((s.width-o.width)/h)*h,d=Math.round((s.height-o.height)/u)*u,p=o.width+c,f=o.height+d,g=n.maxWidth&&n.maxWidthp,y=n.minHeight&&n.minHeight>f;n.grid=l,v&&(p+=h),y&&(f+=u),g&&(p-=h),m&&(f-=u),/^(se|s|e)$/.test(a)?(i.size.width=p,i.size.height=f):/^(ne)$/.test(a)?(i.size.width=p,i.size.height=f,i.position.top=r.top-d):/^(sw)$/.test(a)?(i.size.width=p,i.size.height=f,i.position.left=r.left-c):((f-u<=0||p-h<=0)&&(t=i._getPaddingPlusBorderDimensions(this)),f-u>0?(i.size.height=f,i.position.top=r.top-d):(f=u-t.height,i.size.height=f,i.position.top=r.top+o.height-f),p-h>0?(i.size.width=p,i.position.left=r.left-c):(p=h-t.width,i.size.width=p,i.position.left=r.left+o.width-p))}}),e.ui.resizable})?n.apply(t,s):n)||(e.exports=o)},28:function(e,t){var i;!function(t,i){"use strict";"object"==typeof e.exports?e.exports=t.document?i(t):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return i(e)}:i(t)}("undefined"!=typeof window?window:this,(function(n,s){"use strict";var o=[],r=Object.getPrototypeOf,a=o.slice,l=o.flat?function(e){return o.flat.call(e)}:function(e){return o.concat.apply([],e)},h=o.push,u=o.indexOf,c={},d=c.toString,p=c.hasOwnProperty,f=p.toString,g=f.call(Object),m={},v=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},y=function(e){return null!=e&&e===e.window},b=n.document,_={type:!0,src:!0,nonce:!0,noModule:!0};function w(e,t,i){var n,s,o=(i=i||b).createElement("script");if(o.text=e,t)for(n in _)(s=t[n]||t.getAttribute&&t.getAttribute(n))&&o.setAttribute(n,s);i.head.appendChild(o).parentNode.removeChild(o)}function x(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?c[d.call(e)]||"object":typeof e}var C="3.5.1",E=function(e,t){return new E.fn.init(e,t)};function N(e){var t=!!e&&"length"in e&&e.length,i=x(e);return!v(e)&&!y(e)&&("array"===i||0===t||"number"==typeof t&&t>0&&t-1 in e)}E.fn=E.prototype={jquery:C,constructor:E,length:0,toArray:function(){return a.call(this)},get:function(e){return null==e?a.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=E.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return E.each(this,e)},map:function(e){return this.pushStack(E.map(this,(function(t,i){return e.call(t,i,t)})))},slice:function(){return this.pushStack(a.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},even:function(){return this.pushStack(E.grep(this,(function(e,t){return(t+1)%2})))},odd:function(){return this.pushStack(E.grep(this,(function(e,t){return t%2})))},eq:function(e){var t=this.length,i=+e+(e<0?t:0);return this.pushStack(i>=0&&i+~]|[\\x20\\t\\r\\n\\f])[\\x20\\t\\r\\n\\f]*"),$=new RegExp(L+"|>"),G=new RegExp(I),X=new RegExp("^"+j+"$"),Y={ID:new RegExp("^#("+j+")"),CLASS:new RegExp("^\\.("+j+")"),TAG:new RegExp("^("+j+"|[*])"),ATTR:new RegExp("^"+W),PSEUDO:new RegExp("^"+I),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\([\\x20\\t\\r\\n\\f]*(even|odd|(([+-]|)(\\d*)n|)[\\x20\\t\\r\\n\\f]*(?:([+-]|)[\\x20\\t\\r\\n\\f]*(\\d+)|))[\\x20\\t\\r\\n\\f]*\\)|)","i"),bool:new RegExp("^(?:"+O+")$","i"),needsContext:new RegExp("^[\\x20\\t\\r\\n\\f]*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\([\\x20\\t\\r\\n\\f]*((?:-\\d)?\\d*)[\\x20\\t\\r\\n\\f]*\\)|)(?=[^-]|$)","i")},V=/HTML$/i,K=/^(?:input|select|textarea|button)$/i,Q=/^h\d$/i,J=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ee=/[+~]/,te=new RegExp("\\\\[\\da-fA-F]{1,6}[\\x20\\t\\r\\n\\f]?|\\\\([^\\r\\n\\f])","g"),ie=function(e,t){var i="0x"+e.slice(1)-65536;return t||(i<0?String.fromCharCode(i+65536):String.fromCharCode(i>>10|55296,1023&i|56320))},ne=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,se=function(e,t){return t?"\0"===e?"�":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},oe=function(){d()},re=_e((function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()}),{dir:"parentNode",next:"legend"});try{A.apply(P=R.call(w.childNodes),w.childNodes),P[w.childNodes.length].nodeType}catch(e){A={apply:P.length?function(e,t){z.apply(e,R.call(t))}:function(e,t){for(var i=e.length,n=0;e[i++]=t[n++];);e.length=i-1}}}function ae(e,t,n,s){var o,a,h,u,c,f,v,y=t&&t.ownerDocument,w=t?t.nodeType:9;if(n=n||[],"string"!=typeof e||!e||1!==w&&9!==w&&11!==w)return n;if(!s&&(d(t),t=t||p,g)){if(11!==w&&(c=Z.exec(e)))if(o=c[1]){if(9===w){if(!(h=t.getElementById(o)))return n;if(h.id===o)return n.push(h),n}else if(y&&(h=y.getElementById(o))&&b(t,h)&&h.id===o)return n.push(h),n}else{if(c[2])return A.apply(n,t.getElementsByTagName(e)),n;if((o=c[3])&&i.getElementsByClassName&&t.getElementsByClassName)return A.apply(n,t.getElementsByClassName(o)),n}if(i.qsa&&!S[e+" "]&&(!m||!m.test(e))&&(1!==w||"object"!==t.nodeName.toLowerCase())){if(v=e,y=t,1===w&&($.test(e)||F.test(e))){for((y=ee.test(e)&&ve(t.parentNode)||t)===t&&i.scope||((u=t.getAttribute("id"))?u=u.replace(ne,se):t.setAttribute("id",u=_)),a=(f=r(e)).length;a--;)f[a]=(u?"#"+u:":scope")+" "+be(f[a]);v=f.join(",")}try{return A.apply(n,y.querySelectorAll(v)),n}catch(t){S(e,!0)}finally{u===_&&t.removeAttribute("id")}}}return l(e.replace(q,"$1"),t,n,s)}function le(){var e=[];return function t(i,s){return e.push(i+" ")>n.cacheLength&&delete t[e.shift()],t[i+" "]=s}}function he(e){return e[_]=!0,e}function ue(e){var t=p.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function ce(e,t){for(var i=e.split("|"),s=i.length;s--;)n.attrHandle[i[s]]=t}function de(e,t){var i=t&&e,n=i&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(n)return n;if(i)for(;i=i.nextSibling;)if(i===t)return-1;return e?1:-1}function pe(e){return function(t){return"input"===t.nodeName.toLowerCase()&&t.type===e}}function fe(e){return function(t){var i=t.nodeName.toLowerCase();return("input"===i||"button"===i)&&t.type===e}}function ge(e){return function(t){return"form"in t?t.parentNode&&!1===t.disabled?"label"in t?"label"in t.parentNode?t.parentNode.disabled===e:t.disabled===e:t.isDisabled===e||t.isDisabled!==!e&&re(t)===e:t.disabled===e:"label"in t&&t.disabled===e}}function me(e){return he((function(t){return t=+t,he((function(i,n){for(var s,o=e([],i.length,t),r=o.length;r--;)i[s=o[r]]&&(i[s]=!(n[s]=i[s]))}))}))}function ve(e){return e&&void 0!==e.getElementsByTagName&&e}for(t in i=ae.support={},o=ae.isXML=function(e){var t=e.namespaceURI,i=(e.ownerDocument||e).documentElement;return!V.test(t||i&&i.nodeName||"HTML")},d=ae.setDocument=function(e){var t,s,r=e?e.ownerDocument||e:w;return r!=p&&9===r.nodeType&&r.documentElement?(f=(p=r).documentElement,g=!o(p),w!=p&&(s=p.defaultView)&&s.top!==s&&(s.addEventListener?s.addEventListener("unload",oe,!1):s.attachEvent&&s.attachEvent("onunload",oe)),i.scope=ue((function(e){return f.appendChild(e).appendChild(p.createElement("div")),void 0!==e.querySelectorAll&&!e.querySelectorAll(":scope fieldset div").length})),i.attributes=ue((function(e){return e.className="i",!e.getAttribute("className")})),i.getElementsByTagName=ue((function(e){return e.appendChild(p.createComment("")),!e.getElementsByTagName("*").length})),i.getElementsByClassName=J.test(p.getElementsByClassName),i.getById=ue((function(e){return f.appendChild(e).id=_,!p.getElementsByName||!p.getElementsByName(_).length})),i.getById?(n.filter.ID=function(e){var t=e.replace(te,ie);return function(e){return e.getAttribute("id")===t}},n.find.ID=function(e,t){if(void 0!==t.getElementById&&g){var i=t.getElementById(e);return i?[i]:[]}}):(n.filter.ID=function(e){var t=e.replace(te,ie);return function(e){var i=void 0!==e.getAttributeNode&&e.getAttributeNode("id");return i&&i.value===t}},n.find.ID=function(e,t){if(void 0!==t.getElementById&&g){var i,n,s,o=t.getElementById(e);if(o){if((i=o.getAttributeNode("id"))&&i.value===e)return[o];for(s=t.getElementsByName(e),n=0;o=s[n++];)if((i=o.getAttributeNode("id"))&&i.value===e)return[o]}return[]}}),n.find.TAG=i.getElementsByTagName?function(e,t){return void 0!==t.getElementsByTagName?t.getElementsByTagName(e):i.qsa?t.querySelectorAll(e):void 0}:function(e,t){var i,n=[],s=0,o=t.getElementsByTagName(e);if("*"===e){for(;i=o[s++];)1===i.nodeType&&n.push(i);return n}return o},n.find.CLASS=i.getElementsByClassName&&function(e,t){if(void 0!==t.getElementsByClassName&&g)return t.getElementsByClassName(e)},v=[],m=[],(i.qsa=J.test(p.querySelectorAll))&&(ue((function(e){var t;f.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&m.push("[*^$]=[\\x20\\t\\r\\n\\f]*(?:''|\"\")"),e.querySelectorAll("[selected]").length||m.push("\\[[\\x20\\t\\r\\n\\f]*(?:value|"+O+")"),e.querySelectorAll("[id~="+_+"-]").length||m.push("~="),(t=p.createElement("input")).setAttribute("name",""),e.appendChild(t),e.querySelectorAll("[name='']").length||m.push("\\[[\\x20\\t\\r\\n\\f]*name[\\x20\\t\\r\\n\\f]*=[\\x20\\t\\r\\n\\f]*(?:''|\"\")"),e.querySelectorAll(":checked").length||m.push(":checked"),e.querySelectorAll("a#"+_+"+*").length||m.push(".#.+[+~]"),e.querySelectorAll("\\\f"),m.push("[\\r\\n\\f]")})),ue((function(e){e.innerHTML="";var t=p.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&m.push("name[\\x20\\t\\r\\n\\f]*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&m.push(":enabled",":disabled"),f.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&m.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),m.push(",.*:")}))),(i.matchesSelector=J.test(y=f.matches||f.webkitMatchesSelector||f.mozMatchesSelector||f.oMatchesSelector||f.msMatchesSelector))&&ue((function(e){i.disconnectedMatch=y.call(e,"*"),y.call(e,"[s!='']:x"),v.push("!=",I)})),m=m.length&&new RegExp(m.join("|")),v=v.length&&new RegExp(v.join("|")),t=J.test(f.compareDocumentPosition),b=t||J.test(f.contains)?function(e,t){var i=9===e.nodeType?e.documentElement:e,n=t&&t.parentNode;return e===n||!(!n||1!==n.nodeType||!(i.contains?i.contains(n):e.compareDocumentPosition&&16&e.compareDocumentPosition(n)))}:function(e,t){if(t)for(;t=t.parentNode;)if(t===e)return!0;return!1},T=t?function(e,t){if(e===t)return c=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)==(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!i.sortDetached&&t.compareDocumentPosition(e)===n?e==p||e.ownerDocument==w&&b(w,e)?-1:t==p||t.ownerDocument==w&&b(w,t)?1:u?M(u,e)-M(u,t):0:4&n?-1:1)}:function(e,t){if(e===t)return c=!0,0;var i,n=0,s=e.parentNode,o=t.parentNode,r=[e],a=[t];if(!s||!o)return e==p?-1:t==p?1:s?-1:o?1:u?M(u,e)-M(u,t):0;if(s===o)return de(e,t);for(i=e;i=i.parentNode;)r.unshift(i);for(i=t;i=i.parentNode;)a.unshift(i);for(;r[n]===a[n];)n++;return n?de(r[n],a[n]):r[n]==w?-1:a[n]==w?1:0},p):p},ae.matches=function(e,t){return ae(e,null,null,t)},ae.matchesSelector=function(e,t){if(d(e),i.matchesSelector&&g&&!S[t+" "]&&(!v||!v.test(t))&&(!m||!m.test(t)))try{var n=y.call(e,t);if(n||i.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){S(t,!0)}return ae(t,p,null,[e]).length>0},ae.contains=function(e,t){return(e.ownerDocument||e)!=p&&d(e),b(e,t)},ae.attr=function(e,t){(e.ownerDocument||e)!=p&&d(e);var s=n.attrHandle[t.toLowerCase()],o=s&&D.call(n.attrHandle,t.toLowerCase())?s(e,t,!g):void 0;return void 0!==o?o:i.attributes||!g?e.getAttribute(t):(o=e.getAttributeNode(t))&&o.specified?o.value:null},ae.escape=function(e){return(e+"").replace(ne,se)},ae.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},ae.uniqueSort=function(e){var t,n=[],s=0,o=0;if(c=!i.detectDuplicates,u=!i.sortStable&&e.slice(0),e.sort(T),c){for(;t=e[o++];)t===e[o]&&(s=n.push(o));for(;s--;)e.splice(n[s],1)}return u=null,e},s=ae.getText=function(e){var t,i="",n=0,o=e.nodeType;if(o){if(1===o||9===o||11===o){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)i+=s(e)}else if(3===o||4===o)return e.nodeValue}else for(;t=e[n++];)i+=s(t);return i},(n=ae.selectors={cacheLength:50,createPseudo:he,match:Y,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(te,ie),e[3]=(e[3]||e[4]||e[5]||"").replace(te,ie),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||ae.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&ae.error(e[0]),e},PSEUDO:function(e){var t,i=!e[6]&&e[2];return Y.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":i&&G.test(i)&&(t=r(i,!0))&&(t=i.indexOf(")",i.length-t)-i.length)&&(e[0]=e[0].slice(0,t),e[2]=i.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(te,ie).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=E[e+" "];return t||(t=new RegExp("(^|[\\x20\\t\\r\\n\\f])"+e+"("+L+"|$)"))&&E(e,(function(e){return t.test("string"==typeof e.className&&e.className||void 0!==e.getAttribute&&e.getAttribute("class")||"")}))},ATTR:function(e,t,i){return function(n){var s=ae.attr(n,e);return null==s?"!="===t:!t||(s+="","="===t?s===i:"!="===t?s!==i:"^="===t?i&&0===s.indexOf(i):"*="===t?i&&s.indexOf(i)>-1:"$="===t?i&&s.slice(-i.length)===i:"~="===t?(" "+s.replace(U," ")+" ").indexOf(i)>-1:"|="===t&&(s===i||s.slice(0,i.length+1)===i+"-"))}},CHILD:function(e,t,i,n,s){var o="nth"!==e.slice(0,3),r="last"!==e.slice(-4),a="of-type"===t;return 1===n&&0===s?function(e){return!!e.parentNode}:function(t,i,l){var h,u,c,d,p,f,g=o!==r?"nextSibling":"previousSibling",m=t.parentNode,v=a&&t.nodeName.toLowerCase(),y=!l&&!a,b=!1;if(m){if(o){for(;g;){for(d=t;d=d[g];)if(a?d.nodeName.toLowerCase()===v:1===d.nodeType)return!1;f=g="only"===e&&!f&&"nextSibling"}return!0}if(f=[r?m.firstChild:m.lastChild],r&&y){for(b=(p=(h=(u=(c=(d=m)[_]||(d[_]={}))[d.uniqueID]||(c[d.uniqueID]={}))[e]||[])[0]===x&&h[1])&&h[2],d=p&&m.childNodes[p];d=++p&&d&&d[g]||(b=p=0)||f.pop();)if(1===d.nodeType&&++b&&d===t){u[e]=[x,p,b];break}}else if(y&&(b=p=(h=(u=(c=(d=t)[_]||(d[_]={}))[d.uniqueID]||(c[d.uniqueID]={}))[e]||[])[0]===x&&h[1]),!1===b)for(;(d=++p&&d&&d[g]||(b=p=0)||f.pop())&&((a?d.nodeName.toLowerCase()!==v:1!==d.nodeType)||!++b||(y&&((u=(c=d[_]||(d[_]={}))[d.uniqueID]||(c[d.uniqueID]={}))[e]=[x,b]),d!==t)););return(b-=s)===n||b%n==0&&b/n>=0}}},PSEUDO:function(e,t){var i,s=n.pseudos[e]||n.setFilters[e.toLowerCase()]||ae.error("unsupported pseudo: "+e);return s[_]?s(t):s.length>1?(i=[e,e,"",t],n.setFilters.hasOwnProperty(e.toLowerCase())?he((function(e,i){for(var n,o=s(e,t),r=o.length;r--;)e[n=M(e,o[r])]=!(i[n]=o[r])})):function(e){return s(e,0,i)}):s}},pseudos:{not:he((function(e){var t=[],i=[],n=a(e.replace(q,"$1"));return n[_]?he((function(e,t,i,s){for(var o,r=n(e,null,s,[]),a=e.length;a--;)(o=r[a])&&(e[a]=!(t[a]=o))})):function(e,s,o){return t[0]=e,n(t,null,o,i),t[0]=null,!i.pop()}})),has:he((function(e){return function(t){return ae(e,t).length>0}})),contains:he((function(e){return e=e.replace(te,ie),function(t){return(t.textContent||s(t)).indexOf(e)>-1}})),lang:he((function(e){return X.test(e||"")||ae.error("unsupported lang: "+e),e=e.replace(te,ie).toLowerCase(),function(t){var i;do{if(i=g?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return(i=i.toLowerCase())===e||0===i.indexOf(e+"-")}while((t=t.parentNode)&&1===t.nodeType);return!1}})),target:function(t){var i=e.location&&e.location.hash;return i&&i.slice(1)===t.id},root:function(e){return e===f},focus:function(e){return e===p.activeElement&&(!p.hasFocus||p.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:ge(!1),disabled:ge(!0),checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!n.pseudos.empty(e)},header:function(e){return Q.test(e.nodeName)},input:function(e){return K.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||"text"===t.toLowerCase())},first:me((function(){return[0]})),last:me((function(e,t){return[t-1]})),eq:me((function(e,t,i){return[i<0?i+t:i]})),even:me((function(e,t){for(var i=0;it?t:i;--n>=0;)e.push(n);return e})),gt:me((function(e,t,i){for(var n=i<0?i+t:i;++n1?function(t,i,n){for(var s=e.length;s--;)if(!e[s](t,i,n))return!1;return!0}:e[0]}function xe(e,t,i,n,s){for(var o,r=[],a=0,l=e.length,h=null!=t;a-1&&(o[h]=!(r[h]=c))}}else v=xe(v===r?v.splice(f,v.length):v),s?s(null,r,v,l):A.apply(r,v)}))}function Ee(e){for(var t,i,s,o=e.length,r=n.relative[e[0].type],a=r||n.relative[" "],l=r?1:0,u=_e((function(e){return e===t}),a,!0),c=_e((function(e){return M(t,e)>-1}),a,!0),d=[function(e,i,n){var s=!r&&(n||i!==h)||((t=i).nodeType?u(e,i,n):c(e,i,n));return t=null,s}];l1&&we(d),l>1&&be(e.slice(0,l-1).concat({value:" "===e[l-2].type?"*":""})).replace(q,"$1"),i,l0,s=e.length>0,o=function(o,r,a,l,u){var c,f,m,v=0,y="0",b=o&&[],_=[],w=h,C=o||s&&n.find.TAG("*",u),E=x+=null==w?1:Math.random()||.1,N=C.length;for(u&&(h=r==p||r||u);y!==N&&null!=(c=C[y]);y++){if(s&&c){for(f=0,r||c.ownerDocument==p||(d(c),a=!g);m=e[f++];)if(m(c,r||p,a)){l.push(c);break}u&&(x=E)}i&&((c=!m&&c)&&v--,o&&b.push(c))}if(v+=y,i&&y!==v){for(f=0;m=t[f++];)m(b,_,r,a);if(o){if(v>0)for(;y--;)b[y]||_[y]||(_[y]=H.call(l));_=xe(_)}A.apply(l,_),u&&!o&&_.length>0&&v+t.length>1&&ae.uniqueSort(l)}return u&&(x=E,h=w),b};return i?he(o):o}(o,s))).selector=e}return a},l=ae.select=function(e,t,i,s){var o,l,h,u,c,d="function"==typeof e&&e,p=!s&&r(e=d.selector||e);if(i=i||[],1===p.length){if((l=p[0]=p[0].slice(0)).length>2&&"ID"===(h=l[0]).type&&9===t.nodeType&&g&&n.relative[l[1].type]){if(!(t=(n.find.ID(h.matches[0].replace(te,ie),t)||[])[0]))return i;d&&(t=t.parentNode),e=e.slice(l.shift().value.length)}for(o=Y.needsContext.test(e)?0:l.length;o--&&(h=l[o],!n.relative[u=h.type]);)if((c=n.find[u])&&(s=c(h.matches[0].replace(te,ie),ee.test(l[0].type)&&ve(t.parentNode)||t))){if(l.splice(o,1),!(e=s.length&&be(l)))return A.apply(i,s),i;break}}return(d||a(e,p))(s,t,!g,i,!t||ee.test(e)&&ve(t.parentNode)||t),i},i.sortStable=_.split("").sort(T).join("")===_,i.detectDuplicates=!!c,d(),i.sortDetached=ue((function(e){return 1&e.compareDocumentPosition(p.createElement("fieldset"))})),ue((function(e){return e.innerHTML="","#"===e.firstChild.getAttribute("href")}))||ce("type|href|height|width",(function(e,t,i){if(!i)return e.getAttribute(t,"type"===t.toLowerCase()?1:2)})),i.attributes&&ue((function(e){return e.innerHTML="",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")}))||ce("value",(function(e,t,i){if(!i&&"input"===e.nodeName.toLowerCase())return e.defaultValue})),ue((function(e){return null==e.getAttribute("disabled")}))||ce(O,(function(e,t,i){var n;if(!i)return!0===e[t]?t.toLowerCase():(n=e.getAttributeNode(t))&&n.specified?n.value:null})),ae}(n);E.find=k,E.expr=k.selectors,E.expr[":"]=E.expr.pseudos,E.uniqueSort=E.unique=k.uniqueSort,E.text=k.getText,E.isXMLDoc=k.isXML,E.contains=k.contains,E.escapeSelector=k.escape;var S=function(e,t,i){for(var n=[],s=void 0!==i;(e=e[t])&&9!==e.nodeType;)if(1===e.nodeType){if(s&&E(e).is(i))break;n.push(e)}return n},T=function(e,t){for(var i=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&i.push(e);return i},D=E.expr.match.needsContext;function P(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()}var H=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function z(e,t,i){return v(t)?E.grep(e,(function(e,n){return!!t.call(e,n,e)!==i})):t.nodeType?E.grep(e,(function(e){return e===t!==i})):"string"!=typeof t?E.grep(e,(function(e){return u.call(t,e)>-1!==i})):E.filter(t,e,i)}E.filter=function(e,t,i){var n=t[0];return i&&(e=":not("+e+")"),1===t.length&&1===n.nodeType?E.find.matchesSelector(n,e)?[n]:[]:E.find.matches(e,E.grep(t,(function(e){return 1===e.nodeType})))},E.fn.extend({find:function(e){var t,i,n=this.length,s=this;if("string"!=typeof e)return this.pushStack(E(e).filter((function(){for(t=0;t1?E.uniqueSort(i):i},filter:function(e){return this.pushStack(z(this,e||[],!1))},not:function(e){return this.pushStack(z(this,e||[],!0))},is:function(e){return!!z(this,"string"==typeof e&&D.test(e)?E(e):e||[],!1).length}});var A,R=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;(E.fn.init=function(e,t,i){var n,s;if(!e)return this;if(i=i||A,"string"==typeof e){if(!(n="<"===e[0]&&">"===e[e.length-1]&&e.length>=3?[null,e,null]:R.exec(e))||!n[1]&&t)return!t||t.jquery?(t||i).find(e):this.constructor(t).find(e);if(n[1]){if(t=t instanceof E?t[0]:t,E.merge(this,E.parseHTML(n[1],t&&t.nodeType?t.ownerDocument||t:b,!0)),H.test(n[1])&&E.isPlainObject(t))for(n in t)v(this[n])?this[n](t[n]):this.attr(n,t[n]);return this}return(s=b.getElementById(n[2]))&&(this[0]=s,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):v(e)?void 0!==i.ready?i.ready(e):e(E):E.makeArray(e,this)}).prototype=E.fn,A=E(b);var M=/^(?:parents|prev(?:Until|All))/,O={children:!0,contents:!0,next:!0,prev:!0};function L(e,t){for(;(e=e[t])&&1!==e.nodeType;);return e}E.fn.extend({has:function(e){var t=E(e,this),i=t.length;return this.filter((function(){for(var e=0;e-1:1===i.nodeType&&E.find.matchesSelector(i,e))){o.push(i);break}return this.pushStack(o.length>1?E.uniqueSort(o):o)},index:function(e){return e?"string"==typeof e?u.call(E(e),this[0]):u.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(E.uniqueSort(E.merge(this.get(),E(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),E.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return S(e,"parentNode")},parentsUntil:function(e,t,i){return S(e,"parentNode",i)},next:function(e){return L(e,"nextSibling")},prev:function(e){return L(e,"previousSibling")},nextAll:function(e){return S(e,"nextSibling")},prevAll:function(e){return S(e,"previousSibling")},nextUntil:function(e,t,i){return S(e,"nextSibling",i)},prevUntil:function(e,t,i){return S(e,"previousSibling",i)},siblings:function(e){return T((e.parentNode||{}).firstChild,e)},children:function(e){return T(e.firstChild)},contents:function(e){return null!=e.contentDocument&&r(e.contentDocument)?e.contentDocument:(P(e,"template")&&(e=e.content||e),E.merge([],e.childNodes))}},(function(e,t){E.fn[e]=function(i,n){var s=E.map(this,t,i);return"Until"!==e.slice(-5)&&(n=i),n&&"string"==typeof n&&(s=E.filter(n,s)),this.length>1&&(O[e]||E.uniqueSort(s),M.test(e)&&s.reverse()),this.pushStack(s)}}));var j=/[^\x20\t\r\n\f]+/g;function W(e){return e}function I(e){throw e}function U(e,t,i,n){var s;try{e&&v(s=e.promise)?s.call(e).done(t).fail(i):e&&v(s=e.then)?s.call(e,t,i):t.apply(void 0,[e].slice(n))}catch(e){i.apply(void 0,[e])}}E.Callbacks=function(e){e="string"==typeof e?function(e){var t={};return E.each(e.match(j)||[],(function(e,i){t[i]=!0})),t}(e):E.extend({},e);var t,i,n,s,o=[],r=[],a=-1,l=function(){for(s=s||e.once,n=t=!0;r.length;a=-1)for(i=r.shift();++a-1;)o.splice(i,1),i<=a&&a--})),this},has:function(e){return e?E.inArray(e,o)>-1:o.length>0},empty:function(){return o&&(o=[]),this},disable:function(){return s=r=[],o=i="",this},disabled:function(){return!o},lock:function(){return s=r=[],i||t||(o=i=""),this},locked:function(){return!!s},fireWith:function(e,i){return s||(i=[e,(i=i||[]).slice?i.slice():i],r.push(i),t||l()),this},fire:function(){return h.fireWith(this,arguments),this},fired:function(){return!!n}};return h},E.extend({Deferred:function(e){var t=[["notify","progress",E.Callbacks("memory"),E.Callbacks("memory"),2],["resolve","done",E.Callbacks("once memory"),E.Callbacks("once memory"),0,"resolved"],["reject","fail",E.Callbacks("once memory"),E.Callbacks("once memory"),1,"rejected"]],i="pending",s={state:function(){return i},always:function(){return o.done(arguments).fail(arguments),this},catch:function(e){return s.then(null,e)},pipe:function(){var e=arguments;return E.Deferred((function(i){E.each(t,(function(t,n){var s=v(e[n[4]])&&e[n[4]];o[n[1]]((function(){var e=s&&s.apply(this,arguments);e&&v(e.promise)?e.promise().progress(i.notify).done(i.resolve).fail(i.reject):i[n[0]+"With"](this,s?[e]:arguments)}))})),e=null})).promise()},then:function(e,i,s){var o=0;function r(e,t,i,s){return function(){var a=this,l=arguments,h=function(){var n,h;if(!(e=o&&(i!==I&&(a=void 0,l=[n]),t.rejectWith(a,l))}};e?u():(E.Deferred.getStackHook&&(u.stackTrace=E.Deferred.getStackHook()),n.setTimeout(u))}}return E.Deferred((function(n){t[0][3].add(r(0,n,v(s)?s:W,n.notifyWith)),t[1][3].add(r(0,n,v(e)?e:W)),t[2][3].add(r(0,n,v(i)?i:I))})).promise()},promise:function(e){return null!=e?E.extend(e,s):s}},o={};return E.each(t,(function(e,n){var r=n[2],a=n[5];s[n[1]]=r.add,a&&r.add((function(){i=a}),t[3-e][2].disable,t[3-e][3].disable,t[0][2].lock,t[0][3].lock),r.add(n[3].fire),o[n[0]]=function(){return o[n[0]+"With"](this===o?void 0:this,arguments),this},o[n[0]+"With"]=r.fireWith})),s.promise(o),e&&e.call(o,o),o},when:function(e){var t=arguments.length,i=t,n=Array(i),s=a.call(arguments),o=E.Deferred(),r=function(e){return function(i){n[e]=this,s[e]=arguments.length>1?a.call(arguments):i,--t||o.resolveWith(n,s)}};if(t<=1&&(U(e,o.done(r(i)).resolve,o.reject,!t),"pending"===o.state()||v(s[i]&&s[i].then)))return o.then();for(;i--;)U(s[i],r(i),o.reject);return o.promise()}});var q=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;E.Deferred.exceptionHook=function(e,t){n.console&&n.console.warn&&e&&q.test(e.name)&&n.console.warn("jQuery.Deferred exception: "+e.message,e.stack,t)},E.readyException=function(e){n.setTimeout((function(){throw e}))};var B=E.Deferred();function F(){b.removeEventListener("DOMContentLoaded",F),n.removeEventListener("load",F),E.ready()}E.fn.ready=function(e){return B.then(e).catch((function(e){E.readyException(e)})),this},E.extend({isReady:!1,readyWait:1,ready:function(e){(!0===e?--E.readyWait:E.isReady)||(E.isReady=!0,!0!==e&&--E.readyWait>0||B.resolveWith(b,[E]))}}),E.ready.then=B.then,"complete"===b.readyState||"loading"!==b.readyState&&!b.documentElement.doScroll?n.setTimeout(E.ready):(b.addEventListener("DOMContentLoaded",F),n.addEventListener("load",F));var $=function(e,t,i,n,s,o,r){var a=0,l=e.length,h=null==i;if("object"===x(i))for(a in s=!0,i)$(e,t,a,i[a],!0,o,r);else if(void 0!==n&&(s=!0,v(n)||(r=!0),h&&(r?(t.call(e,n),t=null):(h=t,t=function(e,t,i){return h.call(E(e),i)})),t))for(;a1,null,!0)},removeData:function(e){return this.each((function(){Z.remove(this,e)}))}}),E.extend({queue:function(e,t,i){var n;if(e)return t=(t||"fx")+"queue",n=J.get(e,t),i&&(!n||Array.isArray(i)?n=J.access(e,t,E.makeArray(i)):n.push(i)),n||[]},dequeue:function(e,t){t=t||"fx";var i=E.queue(e,t),n=i.length,s=i.shift(),o=E._queueHooks(e,t);"inprogress"===s&&(s=i.shift(),n--),s&&("fx"===t&&i.unshift("inprogress"),delete o.stop,s.call(e,(function(){E.dequeue(e,t)}),o)),!n&&o&&o.empty.fire()},_queueHooks:function(e,t){var i=t+"queueHooks";return J.get(e,i)||J.access(e,i,{empty:E.Callbacks("once memory").add((function(){J.remove(e,[t+"queue",i])}))})}}),E.fn.extend({queue:function(e,t){var i=2;return"string"!=typeof e&&(t=e,e="fx",i--),arguments.length\x20\t\r\n\f]*)/i,ye=/^$|^module$|\/(?:java|ecma)script/i;fe=b.createDocumentFragment().appendChild(b.createElement("div")),(ge=b.createElement("input")).setAttribute("type","radio"),ge.setAttribute("checked","checked"),ge.setAttribute("name","t"),fe.appendChild(ge),m.checkClone=fe.cloneNode(!0).cloneNode(!0).lastChild.checked,fe.innerHTML="",m.noCloneChecked=!!fe.cloneNode(!0).lastChild.defaultValue,fe.innerHTML="",m.option=!!fe.lastChild;var be={thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};function _e(e,t){var i;return i=void 0!==e.getElementsByTagName?e.getElementsByTagName(t||"*"):void 0!==e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&P(e,t)?E.merge([e],i):i}function we(e,t){for(var i=0,n=e.length;i",""]);var xe=/<|&#?\w+;/;function Ce(e,t,i,n,s){for(var o,r,a,l,h,u,c=t.createDocumentFragment(),d=[],p=0,f=e.length;p-1)s&&s.push(o);else if(h=ae(o),r=_e(c.appendChild(o),"script"),h&&we(r),i)for(u=0;o=r[u++];)ye.test(o.type||"")&&i.push(o);return c}var Ee=/^key/,Ne=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,ke=/^([^.]*)(?:\.(.+)|)/;function Se(){return!0}function Te(){return!1}function De(e,t){return e===function(){try{return b.activeElement}catch(e){}}()==("focus"===t)}function Pe(e,t,i,n,s,o){var r,a;if("object"==typeof t){for(a in"string"!=typeof i&&(n=n||i,i=void 0),t)Pe(e,a,i,n,t[a],o);return e}if(null==n&&null==s?(s=i,n=i=void 0):null==s&&("string"==typeof i?(s=n,n=void 0):(s=n,n=i,i=void 0)),!1===s)s=Te;else if(!s)return e;return 1===o&&(r=s,(s=function(e){return E().off(e),r.apply(this,arguments)}).guid=r.guid||(r.guid=E.guid++)),e.each((function(){E.event.add(this,t,s,n,i)}))}function He(e,t,i){i?(J.set(e,t,!1),E.event.add(e,t,{namespace:!1,handler:function(e){var n,s,o=J.get(this,t);if(1&e.isTrigger&&this[t]){if(o.length)(E.event.special[t]||{}).delegateType&&e.stopPropagation();else if(o=a.call(arguments),J.set(this,t,o),n=i(this,t),this[t](),o!==(s=J.get(this,t))||n?J.set(this,t,!1):s={},o!==s)return e.stopImmediatePropagation(),e.preventDefault(),s.value}else o.length&&(J.set(this,t,{value:E.event.trigger(E.extend(o[0],E.Event.prototype),o.slice(1),this)}),e.stopImmediatePropagation())}})):void 0===J.get(e,t)&&E.event.add(e,t,Se)}E.event={global:{},add:function(e,t,i,n,s){var o,r,a,l,h,u,c,d,p,f,g,m=J.get(e);if(K(e))for(i.handler&&(i=(o=i).handler,s=o.selector),s&&E.find.matchesSelector(re,s),i.guid||(i.guid=E.guid++),(l=m.events)||(l=m.events=Object.create(null)),(r=m.handle)||(r=m.handle=function(t){return void 0!==E&&E.event.triggered!==t.type?E.event.dispatch.apply(e,arguments):void 0}),h=(t=(t||"").match(j)||[""]).length;h--;)p=g=(a=ke.exec(t[h])||[])[1],f=(a[2]||"").split(".").sort(),p&&(c=E.event.special[p]||{},p=(s?c.delegateType:c.bindType)||p,c=E.event.special[p]||{},u=E.extend({type:p,origType:g,data:n,handler:i,guid:i.guid,selector:s,needsContext:s&&E.expr.match.needsContext.test(s),namespace:f.join(".")},o),(d=l[p])||((d=l[p]=[]).delegateCount=0,c.setup&&!1!==c.setup.call(e,n,f,r)||e.addEventListener&&e.addEventListener(p,r)),c.add&&(c.add.call(e,u),u.handler.guid||(u.handler.guid=i.guid)),s?d.splice(d.delegateCount++,0,u):d.push(u),E.event.global[p]=!0)},remove:function(e,t,i,n,s){var o,r,a,l,h,u,c,d,p,f,g,m=J.hasData(e)&&J.get(e);if(m&&(l=m.events)){for(h=(t=(t||"").match(j)||[""]).length;h--;)if(p=g=(a=ke.exec(t[h])||[])[1],f=(a[2]||"").split(".").sort(),p){for(c=E.event.special[p]||{},d=l[p=(n?c.delegateType:c.bindType)||p]||[],a=a[2]&&new RegExp("(^|\\.)"+f.join("\\.(?:.*\\.|)")+"(\\.|$)"),r=o=d.length;o--;)u=d[o],!s&&g!==u.origType||i&&i.guid!==u.guid||a&&!a.test(u.namespace)||n&&n!==u.selector&&("**"!==n||!u.selector)||(d.splice(o,1),u.selector&&d.delegateCount--,c.remove&&c.remove.call(e,u));r&&!d.length&&(c.teardown&&!1!==c.teardown.call(e,f,m.handle)||E.removeEvent(e,p,m.handle),delete l[p])}else for(p in l)E.event.remove(e,p+t[h],i,n,!0);E.isEmptyObject(l)&&J.remove(e,"handle events")}},dispatch:function(e){var t,i,n,s,o,r,a=new Array(arguments.length),l=E.event.fix(e),h=(J.get(this,"events")||Object.create(null))[l.type]||[],u=E.event.special[l.type]||{};for(a[0]=l,t=1;t=1))for(;h!==this;h=h.parentNode||this)if(1===h.nodeType&&("click"!==e.type||!0!==h.disabled)){for(o=[],r={},i=0;i-1:E.find(s,this,null,[h]).length),r[s]&&o.push(n);o.length&&a.push({elem:h,handlers:o})}return h=this,l\s*$/g;function Me(e,t){return P(e,"table")&&P(11!==t.nodeType?t:t.firstChild,"tr")&&E(e).children("tbody")[0]||e}function Oe(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function Le(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function je(e,t){var i,n,s,o,r,a;if(1===t.nodeType){if(J.hasData(e)&&(a=J.get(e).events))for(s in J.remove(t,"handle events"),a)for(i=0,n=a[s].length;i1&&"string"==typeof f&&!m.checkClone&&Ae.test(f))return e.each((function(s){var o=e.eq(s);g&&(t[0]=f.call(this,s,o.html())),Ie(o,t,i,n)}));if(d&&(o=(s=Ce(t,e[0].ownerDocument,!1,e,n)).firstChild,1===s.childNodes.length&&(s=o),o||n)){for(a=(r=E.map(_e(s,"script"),Oe)).length;c0&&we(r,!l&&_e(e,"script")),a},cleanData:function(e){for(var t,i,n,s=E.event.special,o=0;void 0!==(i=e[o]);o++)if(K(i)){if(t=i[J.expando]){if(t.events)for(n in t.events)s[n]?E.event.remove(i,n):E.removeEvent(i,n,t.handle);i[J.expando]=void 0}i[Z.expando]&&(i[Z.expando]=void 0)}}}),E.fn.extend({detach:function(e){return Ue(this,e,!0)},remove:function(e){return Ue(this,e)},text:function(e){return $(this,(function(e){return void 0===e?E.text(this):this.empty().each((function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=e)}))}),null,e,arguments.length)},append:function(){return Ie(this,arguments,(function(e){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||Me(this,e).appendChild(e)}))},prepend:function(){return Ie(this,arguments,(function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Me(this,e);t.insertBefore(e,t.firstChild)}}))},before:function(){return Ie(this,arguments,(function(e){this.parentNode&&this.parentNode.insertBefore(e,this)}))},after:function(){return Ie(this,arguments,(function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)}))},empty:function(){for(var e,t=0;null!=(e=this[t]);t++)1===e.nodeType&&(E.cleanData(_e(e,!1)),e.textContent="");return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map((function(){return E.clone(this,e,t)}))},html:function(e){return $(this,(function(e){var t=this[0]||{},i=0,n=this.length;if(void 0===e&&1===t.nodeType)return t.innerHTML;if("string"==typeof e&&!ze.test(e)&&!be[(ve.exec(e)||["",""])[1].toLowerCase()]){e=E.htmlPrefilter(e);try{for(;i3,re.removeChild(e)),a}}))}();var Ye=["Webkit","Moz","ms"],Ve=b.createElement("div").style,Ke={};function Qe(e){return E.cssProps[e]||Ke[e]||(e in Ve?e:Ke[e]=function(e){for(var t=e[0].toUpperCase()+e.slice(1),i=Ye.length;i--;)if((e=Ye[i]+t)in Ve)return e}(e)||e)}var Je=/^(none|table(?!-c[ea]).+)/,Ze=/^--/,et={position:"absolute",visibility:"hidden",display:"block"},tt={letterSpacing:"0",fontWeight:"400"};function it(e,t,i){var n=se.exec(t);return n?Math.max(0,n[2]-(i||0))+(n[3]||"px"):t}function nt(e,t,i,n,s,o){var r="width"===t?1:0,a=0,l=0;if(i===(n?"border":"content"))return 0;for(;r<4;r+=2)"margin"===i&&(l+=E.css(e,i+oe[r],!0,s)),n?("content"===i&&(l-=E.css(e,"padding"+oe[r],!0,s)),"margin"!==i&&(l-=E.css(e,"border"+oe[r]+"Width",!0,s))):(l+=E.css(e,"padding"+oe[r],!0,s),"padding"!==i?l+=E.css(e,"border"+oe[r]+"Width",!0,s):a+=E.css(e,"border"+oe[r]+"Width",!0,s));return!n&&o>=0&&(l+=Math.max(0,Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-o-l-a-.5))||0),l}function st(e,t,i){var n=Be(e),s=(!m.boxSizingReliable()||i)&&"border-box"===E.css(e,"boxSizing",!1,n),o=s,r=Ge(e,t,n),a="offset"+t[0].toUpperCase()+t.slice(1);if(qe.test(r)){if(!i)return r;r="auto"}return(!m.boxSizingReliable()&&s||!m.reliableTrDimensions()&&P(e,"tr")||"auto"===r||!parseFloat(r)&&"inline"===E.css(e,"display",!1,n))&&e.getClientRects().length&&(s="border-box"===E.css(e,"boxSizing",!1,n),(o=a in e)&&(r=e[a])),(r=parseFloat(r)||0)+nt(e,t,i||(s?"border":"content"),o,n,r)+"px"}function ot(e,t,i,n,s){return new ot.prototype.init(e,t,i,n,s)}E.extend({cssHooks:{opacity:{get:function(e,t){if(t){var i=Ge(e,"opacity");return""===i?"1":i}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{},style:function(e,t,i,n){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var s,o,r,a=V(t),l=Ze.test(t),h=e.style;if(l||(t=Qe(a)),r=E.cssHooks[t]||E.cssHooks[a],void 0===i)return r&&"get"in r&&void 0!==(s=r.get(e,!1,n))?s:h[t];"string"==(o=typeof i)&&(s=se.exec(i))&&s[1]&&(i=ue(e,t,s),o="number"),null!=i&&i==i&&("number"!==o||l||(i+=s&&s[3]||(E.cssNumber[a]?"":"px")),m.clearCloneStyle||""!==i||0!==t.indexOf("background")||(h[t]="inherit"),r&&"set"in r&&void 0===(i=r.set(e,i,n))||(l?h.setProperty(t,i):h[t]=i))}},css:function(e,t,i,n){var s,o,r,a=V(t);return Ze.test(t)||(t=Qe(a)),(r=E.cssHooks[t]||E.cssHooks[a])&&"get"in r&&(s=r.get(e,!0,i)),void 0===s&&(s=Ge(e,t,n)),"normal"===s&&t in tt&&(s=tt[t]),""===i||i?(o=parseFloat(s),!0===i||isFinite(o)?o||0:s):s}}),E.each(["height","width"],(function(e,t){E.cssHooks[t]={get:function(e,i,n){if(i)return!Je.test(E.css(e,"display"))||e.getClientRects().length&&e.getBoundingClientRect().width?st(e,t,n):Fe(e,et,(function(){return st(e,t,n)}))},set:function(e,i,n){var s,o=Be(e),r=!m.scrollboxSize()&&"absolute"===o.position,a=(r||n)&&"border-box"===E.css(e,"boxSizing",!1,o),l=n?nt(e,t,n,a,o):0;return a&&r&&(l-=Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-parseFloat(o[t])-nt(e,t,"border",!1,o)-.5)),l&&(s=se.exec(i))&&"px"!==(s[3]||"px")&&(e.style[t]=i,i=E.css(e,t)),it(0,i,l)}}})),E.cssHooks.marginLeft=Xe(m.reliableMarginLeft,(function(e,t){if(t)return(parseFloat(Ge(e,"marginLeft"))||e.getBoundingClientRect().left-Fe(e,{marginLeft:0},(function(){return e.getBoundingClientRect().left})))+"px"})),E.each({margin:"",padding:"",border:"Width"},(function(e,t){E.cssHooks[e+t]={expand:function(i){for(var n=0,s={},o="string"==typeof i?i.split(" "):[i];n<4;n++)s[e+oe[n]+t]=o[n]||o[n-2]||o[0];return s}},"margin"!==e&&(E.cssHooks[e+t].set=it)})),E.fn.extend({css:function(e,t){return $(this,(function(e,t,i){var n,s,o={},r=0;if(Array.isArray(t)){for(n=Be(e),s=t.length;r1)}}),E.Tween=ot,ot.prototype={constructor:ot,init:function(e,t,i,n,s,o){this.elem=e,this.prop=i,this.easing=s||E.easing._default,this.options=t,this.start=this.now=this.cur(),this.end=n,this.unit=o||(E.cssNumber[i]?"":"px")},cur:function(){var e=ot.propHooks[this.prop];return e&&e.get?e.get(this):ot.propHooks._default.get(this)},run:function(e){var t,i=ot.propHooks[this.prop];return this.options.duration?this.pos=t=E.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),i&&i.set?i.set(this):ot.propHooks._default.set(this),this}},ot.prototype.init.prototype=ot.prototype,ot.propHooks={_default:{get:function(e){var t;return 1!==e.elem.nodeType||null!=e.elem[e.prop]&&null==e.elem.style[e.prop]?e.elem[e.prop]:(t=E.css(e.elem,e.prop,""))&&"auto"!==t?t:0},set:function(e){E.fx.step[e.prop]?E.fx.step[e.prop](e):1!==e.elem.nodeType||!E.cssHooks[e.prop]&&null==e.elem.style[Qe(e.prop)]?e.elem[e.prop]=e.now:E.style(e.elem,e.prop,e.now+e.unit)}}},ot.propHooks.scrollTop=ot.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},E.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2},_default:"swing"},E.fx=ot.prototype.init,E.fx.step={};var rt,at,lt=/^(?:toggle|show|hide)$/,ht=/queueHooks$/;function ut(){at&&(!1===b.hidden&&n.requestAnimationFrame?n.requestAnimationFrame(ut):n.setTimeout(ut,E.fx.interval),E.fx.tick())}function ct(){return n.setTimeout((function(){rt=void 0})),rt=Date.now()}function dt(e,t){var i,n=0,s={height:e};for(t=t?1:0;n<4;n+=2-t)s["margin"+(i=oe[n])]=s["padding"+i]=e;return t&&(s.opacity=s.width=e),s}function pt(e,t,i){for(var n,s=(ft.tweeners[t]||[]).concat(ft.tweeners["*"]),o=0,r=s.length;o1)},removeAttr:function(e){return this.each((function(){E.removeAttr(this,e)}))}}),E.extend({attr:function(e,t,i){var n,s,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return void 0===e.getAttribute?E.prop(e,t,i):(1===o&&E.isXMLDoc(e)||(s=E.attrHooks[t.toLowerCase()]||(E.expr.match.bool.test(t)?gt:void 0)),void 0!==i?null===i?void E.removeAttr(e,t):s&&"set"in s&&void 0!==(n=s.set(e,i,t))?n:(e.setAttribute(t,i+""),i):s&&"get"in s&&null!==(n=s.get(e,t))?n:null==(n=E.find.attr(e,t))?void 0:n)},attrHooks:{type:{set:function(e,t){if(!m.radioValue&&"radio"===t&&P(e,"input")){var i=e.value;return e.setAttribute("type",t),i&&(e.value=i),t}}}},removeAttr:function(e,t){var i,n=0,s=t&&t.match(j);if(s&&1===e.nodeType)for(;i=s[n++];)e.removeAttribute(i)}}),gt={set:function(e,t,i){return!1===t?E.removeAttr(e,i):e.setAttribute(i,i),i}},E.each(E.expr.match.bool.source.match(/\w+/g),(function(e,t){var i=mt[t]||E.find.attr;mt[t]=function(e,t,n){var s,o,r=t.toLowerCase();return n||(o=mt[r],mt[r]=s,s=null!=i(e,t,n)?r:null,mt[r]=o),s}}));var vt=/^(?:input|select|textarea|button)$/i,yt=/^(?:a|area)$/i;function bt(e){return(e.match(j)||[]).join(" ")}function _t(e){return e.getAttribute&&e.getAttribute("class")||""}function wt(e){return Array.isArray(e)?e:"string"==typeof e&&e.match(j)||[]}E.fn.extend({prop:function(e,t){return $(this,E.prop,e,t,arguments.length>1)},removeProp:function(e){return this.each((function(){delete this[E.propFix[e]||e]}))}}),E.extend({prop:function(e,t,i){var n,s,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return 1===o&&E.isXMLDoc(e)||(t=E.propFix[t]||t,s=E.propHooks[t]),void 0!==i?s&&"set"in s&&void 0!==(n=s.set(e,i,t))?n:e[t]=i:s&&"get"in s&&null!==(n=s.get(e,t))?n:e[t]},propHooks:{tabIndex:{get:function(e){var t=E.find.attr(e,"tabindex");return t?parseInt(t,10):vt.test(e.nodeName)||yt.test(e.nodeName)&&e.href?0:-1}}},propFix:{for:"htmlFor",class:"className"}}),m.optSelected||(E.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),E.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],(function(){E.propFix[this.toLowerCase()]=this})),E.fn.extend({addClass:function(e){var t,i,n,s,o,r,a,l=0;if(v(e))return this.each((function(t){E(this).addClass(e.call(this,t,_t(this)))}));if((t=wt(e)).length)for(;i=this[l++];)if(s=_t(i),n=1===i.nodeType&&" "+bt(s)+" "){for(r=0;o=t[r++];)n.indexOf(" "+o+" ")<0&&(n+=o+" ");s!==(a=bt(n))&&i.setAttribute("class",a)}return this},removeClass:function(e){var t,i,n,s,o,r,a,l=0;if(v(e))return this.each((function(t){E(this).removeClass(e.call(this,t,_t(this)))}));if(!arguments.length)return this.attr("class","");if((t=wt(e)).length)for(;i=this[l++];)if(s=_t(i),n=1===i.nodeType&&" "+bt(s)+" "){for(r=0;o=t[r++];)for(;n.indexOf(" "+o+" ")>-1;)n=n.replace(" "+o+" "," ");s!==(a=bt(n))&&i.setAttribute("class",a)}return this},toggleClass:function(e,t){var i=typeof e,n="string"===i||Array.isArray(e);return"boolean"==typeof t&&n?t?this.addClass(e):this.removeClass(e):v(e)?this.each((function(i){E(this).toggleClass(e.call(this,i,_t(this),t),t)})):this.each((function(){var t,s,o,r;if(n)for(s=0,o=E(this),r=wt(e);t=r[s++];)o.hasClass(t)?o.removeClass(t):o.addClass(t);else void 0!==e&&"boolean"!==i||((t=_t(this))&&J.set(this,"__className__",t),this.setAttribute&&this.setAttribute("class",t||!1===e?"":J.get(this,"__className__")||""))}))},hasClass:function(e){var t,i,n=0;for(t=" "+e+" ";i=this[n++];)if(1===i.nodeType&&(" "+bt(_t(i))+" ").indexOf(t)>-1)return!0;return!1}});var xt=/\r/g;E.fn.extend({val:function(e){var t,i,n,s=this[0];return arguments.length?(n=v(e),this.each((function(i){var s;1===this.nodeType&&(null==(s=n?e.call(this,i,E(this).val()):e)?s="":"number"==typeof s?s+="":Array.isArray(s)&&(s=E.map(s,(function(e){return null==e?"":e+""}))),(t=E.valHooks[this.type]||E.valHooks[this.nodeName.toLowerCase()])&&"set"in t&&void 0!==t.set(this,s,"value")||(this.value=s))}))):s?(t=E.valHooks[s.type]||E.valHooks[s.nodeName.toLowerCase()])&&"get"in t&&void 0!==(i=t.get(s,"value"))?i:"string"==typeof(i=s.value)?i.replace(xt,""):null==i?"":i:void 0}}),E.extend({valHooks:{option:{get:function(e){var t=E.find.attr(e,"value");return null!=t?t:bt(E.text(e))}},select:{get:function(e){var t,i,n,s=e.options,o=e.selectedIndex,r="select-one"===e.type,a=r?null:[],l=r?o+1:s.length;for(n=o<0?l:r?o:0;n-1)&&(i=!0);return i||(e.selectedIndex=-1),o}}}}),E.each(["radio","checkbox"],(function(){E.valHooks[this]={set:function(e,t){if(Array.isArray(t))return e.checked=E.inArray(E(e).val(),t)>-1}},m.checkOn||(E.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})})),m.focusin="onfocusin"in n;var Ct=/^(?:focusinfocus|focusoutblur)$/,Et=function(e){e.stopPropagation()};E.extend(E.event,{trigger:function(e,t,i,s){var o,r,a,l,h,u,c,d,f=[i||b],g=p.call(e,"type")?e.type:e,m=p.call(e,"namespace")?e.namespace.split("."):[];if(r=d=a=i=i||b,3!==i.nodeType&&8!==i.nodeType&&!Ct.test(g+E.event.triggered)&&(g.indexOf(".")>-1&&(m=g.split("."),g=m.shift(),m.sort()),h=g.indexOf(":")<0&&"on"+g,(e=e[E.expando]?e:new E.Event(g,"object"==typeof e&&e)).isTrigger=s?2:3,e.namespace=m.join("."),e.rnamespace=e.namespace?new RegExp("(^|\\.)"+m.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,e.result=void 0,e.target||(e.target=i),t=null==t?[e]:E.makeArray(t,[e]),c=E.event.special[g]||{},s||!c.trigger||!1!==c.trigger.apply(i,t))){if(!s&&!c.noBubble&&!y(i)){for(l=c.delegateType||g,Ct.test(l+g)||(r=r.parentNode);r;r=r.parentNode)f.push(r),a=r;a===(i.ownerDocument||b)&&f.push(a.defaultView||a.parentWindow||n)}for(o=0;(r=f[o++])&&!e.isPropagationStopped();)d=r,e.type=o>1?l:c.bindType||g,(u=(J.get(r,"events")||Object.create(null))[e.type]&&J.get(r,"handle"))&&u.apply(r,t),(u=h&&r[h])&&u.apply&&K(r)&&(e.result=u.apply(r,t),!1===e.result&&e.preventDefault());return e.type=g,s||e.isDefaultPrevented()||c._default&&!1!==c._default.apply(f.pop(),t)||!K(i)||h&&v(i[g])&&!y(i)&&((a=i[h])&&(i[h]=null),E.event.triggered=g,e.isPropagationStopped()&&d.addEventListener(g,Et),i[g](),e.isPropagationStopped()&&d.removeEventListener(g,Et),E.event.triggered=void 0,a&&(i[h]=a)),e.result}},simulate:function(e,t,i){var n=E.extend(new E.Event,i,{type:e,isSimulated:!0});E.event.trigger(n,null,t)}}),E.fn.extend({trigger:function(e,t){return this.each((function(){E.event.trigger(e,t,this)}))},triggerHandler:function(e,t){var i=this[0];if(i)return E.event.trigger(e,t,i,!0)}}),m.focusin||E.each({focus:"focusin",blur:"focusout"},(function(e,t){var i=function(e){E.event.simulate(t,e.target,E.event.fix(e))};E.event.special[t]={setup:function(){var n=this.ownerDocument||this.document||this,s=J.access(n,t);s||n.addEventListener(e,i,!0),J.access(n,t,(s||0)+1)},teardown:function(){var n=this.ownerDocument||this.document||this,s=J.access(n,t)-1;s?J.access(n,t,s):(n.removeEventListener(e,i,!0),J.remove(n,t))}}}));var Nt=n.location,kt={guid:Date.now()},St=/\?/;E.parseXML=function(e){var t;if(!e||"string"!=typeof e)return null;try{t=(new n.DOMParser).parseFromString(e,"text/xml")}catch(e){t=void 0}return t&&!t.getElementsByTagName("parsererror").length||E.error("Invalid XML: "+e),t};var Tt=/\[\]$/,Dt=/\r?\n/g,Pt=/^(?:submit|button|image|reset|file)$/i,Ht=/^(?:input|select|textarea|keygen)/i;function zt(e,t,i,n){var s;if(Array.isArray(t))E.each(t,(function(t,s){i||Tt.test(e)?n(e,s):zt(e+"["+("object"==typeof s&&null!=s?t:"")+"]",s,i,n)}));else if(i||"object"!==x(t))n(e,t);else for(s in t)zt(e+"["+s+"]",t[s],i,n)}E.param=function(e,t){var i,n=[],s=function(e,t){var i=v(t)?t():t;n[n.length]=encodeURIComponent(e)+"="+encodeURIComponent(null==i?"":i)};if(null==e)return"";if(Array.isArray(e)||e.jquery&&!E.isPlainObject(e))E.each(e,(function(){s(this.name,this.value)}));else for(i in e)zt(i,e[i],t,s);return n.join("&")},E.fn.extend({serialize:function(){return E.param(this.serializeArray())},serializeArray:function(){return this.map((function(){var e=E.prop(this,"elements");return e?E.makeArray(e):this})).filter((function(){var e=this.type;return this.name&&!E(this).is(":disabled")&&Ht.test(this.nodeName)&&!Pt.test(e)&&(this.checked||!me.test(e))})).map((function(e,t){var i=E(this).val();return null==i?null:Array.isArray(i)?E.map(i,(function(e){return{name:t.name,value:e.replace(Dt,"\r\n")}})):{name:t.name,value:i.replace(Dt,"\r\n")}})).get()}});var At=/%20/g,Rt=/#.*$/,Mt=/([?&])_=[^&]*/,Ot=/^(.*?):[ \t]*([^\r\n]*)$/gm,Lt=/^(?:GET|HEAD)$/,jt=/^\/\//,Wt={},It={},Ut="*/".concat("*"),qt=b.createElement("a");function Bt(e){return function(t,i){"string"!=typeof t&&(i=t,t="*");var n,s=0,o=t.toLowerCase().match(j)||[];if(v(i))for(;n=o[s++];)"+"===n[0]?(n=n.slice(1)||"*",(e[n]=e[n]||[]).unshift(i)):(e[n]=e[n]||[]).push(i)}}function Ft(e,t,i,n){var s={},o=e===It;function r(a){var l;return s[a]=!0,E.each(e[a]||[],(function(e,a){var h=a(t,i,n);return"string"!=typeof h||o||s[h]?o?!(l=h):void 0:(t.dataTypes.unshift(h),r(h),!1)})),l}return r(t.dataTypes[0])||!s["*"]&&r("*")}function $t(e,t){var i,n,s=E.ajaxSettings.flatOptions||{};for(i in t)void 0!==t[i]&&((s[i]?e:n||(n={}))[i]=t[i]);return n&&E.extend(!0,e,n),e}qt.href=Nt.href,E.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Nt.href,type:"GET",isLocal:/^(?:about|app|app-storage|.+-extension|file|res|widget):$/.test(Nt.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Ut,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":E.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?$t($t(e,E.ajaxSettings),t):$t(E.ajaxSettings,e)},ajaxPrefilter:Bt(Wt),ajaxTransport:Bt(It),ajax:function(e,t){"object"==typeof e&&(t=e,e=void 0),t=t||{};var i,s,o,r,a,l,h,u,c,d,p=E.ajaxSetup({},t),f=p.context||p,g=p.context&&(f.nodeType||f.jquery)?E(f):E.event,m=E.Deferred(),v=E.Callbacks("once memory"),y=p.statusCode||{},_={},w={},x="canceled",C={readyState:0,getResponseHeader:function(e){var t;if(h){if(!r)for(r={};t=Ot.exec(o);)r[t[1].toLowerCase()+" "]=(r[t[1].toLowerCase()+" "]||[]).concat(t[2]);t=r[e.toLowerCase()+" "]}return null==t?null:t.join(", ")},getAllResponseHeaders:function(){return h?o:null},setRequestHeader:function(e,t){return null==h&&(e=w[e.toLowerCase()]=w[e.toLowerCase()]||e,_[e]=t),this},overrideMimeType:function(e){return null==h&&(p.mimeType=e),this},statusCode:function(e){var t;if(e)if(h)C.always(e[C.status]);else for(t in e)y[t]=[y[t],e[t]];return this},abort:function(e){var t=e||x;return i&&i.abort(t),N(0,t),this}};if(m.promise(C),p.url=((e||p.url||Nt.href)+"").replace(jt,Nt.protocol+"//"),p.type=t.method||t.type||p.method||p.type,p.dataTypes=(p.dataType||"*").toLowerCase().match(j)||[""],null==p.crossDomain){l=b.createElement("a");try{l.href=p.url,l.href=l.href,p.crossDomain=qt.protocol+"//"+qt.host!=l.protocol+"//"+l.host}catch(e){p.crossDomain=!0}}if(p.data&&p.processData&&"string"!=typeof p.data&&(p.data=E.param(p.data,p.traditional)),Ft(Wt,p,t,C),h)return C;for(c in(u=E.event&&p.global)&&0==E.active++&&E.event.trigger("ajaxStart"),p.type=p.type.toUpperCase(),p.hasContent=!Lt.test(p.type),s=p.url.replace(Rt,""),p.hasContent?p.data&&p.processData&&0===(p.contentType||"").indexOf("application/x-www-form-urlencoded")&&(p.data=p.data.replace(At,"+")):(d=p.url.slice(s.length),p.data&&(p.processData||"string"==typeof p.data)&&(s+=(St.test(s)?"&":"?")+p.data,delete p.data),!1===p.cache&&(s=s.replace(Mt,"$1"),d=(St.test(s)?"&":"?")+"_="+kt.guid+++d),p.url=s+d),p.ifModified&&(E.lastModified[s]&&C.setRequestHeader("If-Modified-Since",E.lastModified[s]),E.etag[s]&&C.setRequestHeader("If-None-Match",E.etag[s])),(p.data&&p.hasContent&&!1!==p.contentType||t.contentType)&&C.setRequestHeader("Content-Type",p.contentType),C.setRequestHeader("Accept",p.dataTypes[0]&&p.accepts[p.dataTypes[0]]?p.accepts[p.dataTypes[0]]+("*"!==p.dataTypes[0]?", "+Ut+"; q=0.01":""):p.accepts["*"]),p.headers)C.setRequestHeader(c,p.headers[c]);if(p.beforeSend&&(!1===p.beforeSend.call(f,C,p)||h))return C.abort();if(x="abort",v.add(p.complete),C.done(p.success),C.fail(p.error),i=Ft(It,p,t,C)){if(C.readyState=1,u&&g.trigger("ajaxSend",[C,p]),h)return C;p.async&&p.timeout>0&&(a=n.setTimeout((function(){C.abort("timeout")}),p.timeout));try{h=!1,i.send(_,N)}catch(e){if(h)throw e;N(-1,e)}}else N(-1,"No Transport");function N(e,t,r,l){var c,d,b,_,w,x=t;h||(h=!0,a&&n.clearTimeout(a),i=void 0,o=l||"",C.readyState=e>0?4:0,c=e>=200&&e<300||304===e,r&&(_=function(e,t,i){for(var n,s,o,r,a=e.contents,l=e.dataTypes;"*"===l[0];)l.shift(),void 0===n&&(n=e.mimeType||t.getResponseHeader("Content-Type"));if(n)for(s in a)if(a[s]&&a[s].test(n)){l.unshift(s);break}if(l[0]in i)o=l[0];else{for(s in i){if(!l[0]||e.converters[s+" "+l[0]]){o=s;break}r||(r=s)}o=o||r}if(o)return o!==l[0]&&l.unshift(o),i[o]}(p,C,r)),!c&&E.inArray("script",p.dataTypes)>-1&&(p.converters["text script"]=function(){}),_=function(e,t,i,n){var s,o,r,a,l,h={},u=e.dataTypes.slice();if(u[1])for(r in e.converters)h[r.toLowerCase()]=e.converters[r];for(o=u.shift();o;)if(e.responseFields[o]&&(i[e.responseFields[o]]=t),!l&&n&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),l=o,o=u.shift())if("*"===o)o=l;else if("*"!==l&&l!==o){if(!(r=h[l+" "+o]||h["* "+o]))for(s in h)if((a=s.split(" "))[1]===o&&(r=h[l+" "+a[0]]||h["* "+a[0]])){!0===r?r=h[s]:!0!==h[s]&&(o=a[0],u.unshift(a[1]));break}if(!0!==r)if(r&&e.throws)t=r(t);else try{t=r(t)}catch(e){return{state:"parsererror",error:r?e:"No conversion from "+l+" to "+o}}}return{state:"success",data:t}}(p,_,C,c),c?(p.ifModified&&((w=C.getResponseHeader("Last-Modified"))&&(E.lastModified[s]=w),(w=C.getResponseHeader("etag"))&&(E.etag[s]=w)),204===e||"HEAD"===p.type?x="nocontent":304===e?x="notmodified":(x=_.state,d=_.data,c=!(b=_.error))):(b=x,!e&&x||(x="error",e<0&&(e=0))),C.status=e,C.statusText=(t||x)+"",c?m.resolveWith(f,[d,x,C]):m.rejectWith(f,[C,x,b]),C.statusCode(y),y=void 0,u&&g.trigger(c?"ajaxSuccess":"ajaxError",[C,p,c?d:b]),v.fireWith(f,[C,x]),u&&(g.trigger("ajaxComplete",[C,p]),--E.active||E.event.trigger("ajaxStop")))}return C},getJSON:function(e,t,i){return E.get(e,t,i,"json")},getScript:function(e,t){return E.get(e,void 0,t,"script")}}),E.each(["get","post"],(function(e,t){E[t]=function(e,i,n,s){return v(i)&&(s=s||n,n=i,i=void 0),E.ajax(E.extend({url:e,type:t,dataType:s,data:i,success:n},E.isPlainObject(e)&&e))}})),E.ajaxPrefilter((function(e){var t;for(t in e.headers)"content-type"===t.toLowerCase()&&(e.contentType=e.headers[t]||"")})),E._evalUrl=function(e,t,i){return E.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,converters:{"text script":function(){}},dataFilter:function(e){E.globalEval(e,t,i)}})},E.fn.extend({wrapAll:function(e){var t;return this[0]&&(v(e)&&(e=e.call(this[0])),t=E(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map((function(){for(var e=this;e.firstElementChild;)e=e.firstElementChild;return e})).append(this)),this},wrapInner:function(e){return v(e)?this.each((function(t){E(this).wrapInner(e.call(this,t))})):this.each((function(){var t=E(this),i=t.contents();i.length?i.wrapAll(e):t.append(e)}))},wrap:function(e){var t=v(e);return this.each((function(i){E(this).wrapAll(t?e.call(this,i):e)}))},unwrap:function(e){return this.parent(e).not("body").each((function(){E(this).replaceWith(this.childNodes)})),this}}),E.expr.pseudos.hidden=function(e){return!E.expr.pseudos.visible(e)},E.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},E.ajaxSettings.xhr=function(){try{return new n.XMLHttpRequest}catch(e){}};var Gt={0:200,1223:204},Xt=E.ajaxSettings.xhr();m.cors=!!Xt&&"withCredentials"in Xt,m.ajax=Xt=!!Xt,E.ajaxTransport((function(e){var t,i;if(m.cors||Xt&&!e.crossDomain)return{send:function(s,o){var r,a=e.xhr();if(a.open(e.type,e.url,e.async,e.username,e.password),e.xhrFields)for(r in e.xhrFields)a[r]=e.xhrFields[r];for(r in e.mimeType&&a.overrideMimeType&&a.overrideMimeType(e.mimeType),e.crossDomain||s["X-Requested-With"]||(s["X-Requested-With"]="XMLHttpRequest"),s)a.setRequestHeader(r,s[r]);t=function(e){return function(){t&&(t=i=a.onload=a.onerror=a.onabort=a.ontimeout=a.onreadystatechange=null,"abort"===e?a.abort():"error"===e?"number"!=typeof a.status?o(0,"error"):o(a.status,a.statusText):o(Gt[a.status]||a.status,a.statusText,"text"!==(a.responseType||"text")||"string"!=typeof a.responseText?{binary:a.response}:{text:a.responseText},a.getAllResponseHeaders()))}},a.onload=t(),i=a.onerror=a.ontimeout=t("error"),void 0!==a.onabort?a.onabort=i:a.onreadystatechange=function(){4===a.readyState&&n.setTimeout((function(){t&&i()}))},t=t("abort");try{a.send(e.hasContent&&e.data||null)}catch(e){if(t)throw e}},abort:function(){t&&t()}}})),E.ajaxPrefilter((function(e){e.crossDomain&&(e.contents.script=!1)})),E.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(e){return E.globalEval(e),e}}}),E.ajaxPrefilter("script",(function(e){void 0===e.cache&&(e.cache=!1),e.crossDomain&&(e.type="GET")})),E.ajaxTransport("script",(function(e){var t,i;if(e.crossDomain||e.scriptAttrs)return{send:function(n,s){t=E("