dragselect 3.1.0 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/DragSelect.d.ts +2 -1
- package/dist/DragSelect.es6m.js +3886 -0
- package/dist/DragSelect.esm.js +34 -5
- package/dist/DragSelect.js +34 -5
- package/dist/ds.es6m.min.js +1 -0
- package/dist/ds.esm.min.js +1 -1
- package/dist/ds.min.js +1 -1
- package/dist/methods/addModificationObservers.d.ts +11 -0
- package/dist/methods/canScroll.d.ts +3 -0
- package/dist/methods/createSelectorAreaElement.d.ts +3 -0
- package/dist/methods/createSelectorElement.d.ts +3 -0
- package/dist/methods/debounce.d.ts +3 -0
- package/dist/methods/documentScroll.d.ts +6 -0
- package/dist/methods/getAllParentNodes.d.ts +3 -0
- package/dist/methods/getAreaRect.d.ts +3 -0
- package/dist/methods/getBoundingClientRect.d.ts +4 -0
- package/dist/methods/getCurrentScroll.d.ts +3 -0
- package/dist/methods/getOverflowEdges.d.ts +7 -0
- package/dist/methods/getPointerPos.d.ts +5 -0
- package/dist/methods/getSelectorPosition.d.ts +12 -0
- package/dist/methods/getStylePosition.d.ts +3 -0
- package/dist/methods/handleElementOverflow.d.ts +10 -0
- package/dist/methods/handleElementPositionAttribute.d.ts +6 -0
- package/dist/methods/handleKeyboardDragPosDifference.d.ts +13 -0
- package/dist/methods/handleSelection.d.ts +9 -0
- package/dist/methods/handleUnSelection.d.ts +9 -0
- package/dist/methods/hydrateSettings.d.ts +3 -0
- package/dist/methods/index.d.ts +30 -0
- package/dist/methods/isCollision.d.ts +13 -0
- package/dist/methods/moveElement.d.ts +8 -0
- package/dist/methods/removeModificationObservers.d.ts +3 -0
- package/dist/methods/scrollElement.d.ts +3 -0
- package/dist/methods/setStylePosition.d.ts +3 -0
- package/dist/methods/subscriberAliases.d.ts +14 -0
- package/dist/methods/toArray.d.ts +3 -0
- package/dist/methods/updateElementStylePos.d.ts +8 -0
- package/dist/methods/vect2.d.ts +8 -0
- package/dist/modules/Area.d.ts +80 -0
- package/dist/modules/Drag.d.ts +71 -0
- package/dist/modules/DropZone.d.ts +90 -0
- package/dist/modules/DropZones.d.ts +73 -0
- package/dist/modules/Interaction.d.ts +51 -0
- package/dist/modules/PubSub.d.ts +37 -0
- package/dist/modules/SelectableSet.d.ts +43 -0
- package/dist/modules/SelectedSet.d.ts +32 -0
- package/dist/modules/Selection.d.ts +54 -0
- package/dist/modules/Selector.d.ts +29 -0
- package/dist/modules/SelectorArea.d.ts +58 -0
- package/dist/modules/index.d.ts +11 -0
- package/dist/stores/KeyStore.d.ts +34 -0
- package/dist/stores/PointerStore.d.ts +83 -0
- package/dist/stores/ScrollStore.d.ts +38 -0
- package/dist/stores/SettingsStore.d.ts +39 -0
- package/dist/stores/index.d.ts +5 -0
- package/dist/types.d.ts +276 -0
- package/package.json +2 -2
package/dist/DragSelect.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/***
|
|
2
2
|
|
|
3
|
-
~~~ Version 3.1.
|
|
3
|
+
~~~ Version 3.1.2 ~~~
|
|
4
4
|
|
|
5
5
|
******************************************
|
|
6
6
|
|
|
@@ -124,7 +124,7 @@ const getAreaRect = (area, zoom) => {
|
|
|
124
124
|
};
|
|
125
125
|
|
|
126
126
|
/** Fix: some elements have to have a special position attribute for calculations */
|
|
127
|
-
const handleElementPositionAttribute = ({ computedStyle, node }) => {
|
|
127
|
+
const handleElementPositionAttribute = ({ computedStyle, node, }) => {
|
|
128
128
|
const { position } = computedStyle;
|
|
129
129
|
const isPositioned = position === 'absolute' || position === 'relative' || position === 'fixed';
|
|
130
130
|
if (!(node instanceof Document) && !isPositioned)
|
|
@@ -205,11 +205,31 @@ class Area {
|
|
|
205
205
|
};
|
|
206
206
|
init = () => {
|
|
207
207
|
this._observers = addModificationObservers(this.parentNodes, debounce((event) => {
|
|
208
|
+
if (!this.hasRelevantBeenModified())
|
|
209
|
+
return;
|
|
208
210
|
this.PS.publish('Area:modified:pre', { event, item: this.HTMLNode });
|
|
209
211
|
this.reset();
|
|
210
212
|
this.PS.publish('Area:modified', { event, item: this.HTMLNode });
|
|
211
213
|
}, 60));
|
|
212
214
|
};
|
|
215
|
+
// Check whether the for us relevant values have been changed before making a fuzz
|
|
216
|
+
hasRelevantBeenModified = () => {
|
|
217
|
+
const prevComputedStyle = this.computedStyle;
|
|
218
|
+
const prevRect = this.rect;
|
|
219
|
+
const prevComputedBorder = this.computedBorder;
|
|
220
|
+
const prevParentNodes = this.parentNodes;
|
|
221
|
+
this.reset();
|
|
222
|
+
if (JSON.stringify(prevComputedStyle) !== JSON.stringify(this.computedStyle))
|
|
223
|
+
return true;
|
|
224
|
+
if (JSON.stringify(prevRect) !== JSON.stringify(this.rect))
|
|
225
|
+
return true;
|
|
226
|
+
if (JSON.stringify(prevComputedBorder) !== JSON.stringify(this.computedBorder))
|
|
227
|
+
return true;
|
|
228
|
+
if (prevParentNodes.length !== this.parentNodes.length &&
|
|
229
|
+
prevParentNodes.some((el) => !this.parentNodes.includes(el)))
|
|
230
|
+
return true;
|
|
231
|
+
return false;
|
|
232
|
+
};
|
|
213
233
|
reset = () => {
|
|
214
234
|
this._computedStyle = undefined;
|
|
215
235
|
this._rect = undefined;
|
|
@@ -252,9 +272,18 @@ class Area {
|
|
|
252
272
|
get computedStyle() {
|
|
253
273
|
if (this._computedStyle)
|
|
254
274
|
return this._computedStyle;
|
|
275
|
+
let tempStyles;
|
|
255
276
|
if (this.HTMLNode instanceof Document)
|
|
256
|
-
|
|
257
|
-
|
|
277
|
+
tempStyles = window.getComputedStyle(this.HTMLNode.body || this.HTMLNode.documentElement);
|
|
278
|
+
else
|
|
279
|
+
tempStyles = window.getComputedStyle(this.HTMLNode);
|
|
280
|
+
return (this._computedStyle = {
|
|
281
|
+
borderTopWidth: tempStyles.borderTopWidth,
|
|
282
|
+
borderBottomWidth: tempStyles.borderBottomWidth,
|
|
283
|
+
borderLeftWidth: tempStyles.borderLeftWidth,
|
|
284
|
+
borderRightWidth: tempStyles.borderRightWidth,
|
|
285
|
+
position: tempStyles.position,
|
|
286
|
+
});
|
|
258
287
|
}
|
|
259
288
|
/** The element rect (caches result) (without scrollbar or borders) */
|
|
260
289
|
get rect() {
|
|
@@ -2418,7 +2447,7 @@ class DragSelect {
|
|
|
2418
2447
|
// Deprecation warnings
|
|
2419
2448
|
if (deprecatedNamesMap[eventName])
|
|
2420
2449
|
console.warn(`[DragSelect]: The event name "${eventName}" is deprecated and was/will be removed in a future version. Please use the new event name "${deprecatedNamesMap[eventName]}" instead.`);
|
|
2421
|
-
this.PubSub.subscribe(eventName, callback);
|
|
2450
|
+
return this.PubSub.subscribe(eventName, callback);
|
|
2422
2451
|
};
|
|
2423
2452
|
/** Un-Subscribe from events */
|
|
2424
2453
|
unsubscribe = (eventName, callback, id) => this.PubSub.unsubscribe(eventName, callback, id);
|
package/dist/DragSelect.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/***
|
|
2
2
|
|
|
3
|
-
~~~ Version 3.1.
|
|
3
|
+
~~~ Version 3.1.2 ~~~
|
|
4
4
|
|
|
5
5
|
******************************************
|
|
6
6
|
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
};
|
|
131
131
|
|
|
132
132
|
/** Fix: some elements have to have a special position attribute for calculations */
|
|
133
|
-
const handleElementPositionAttribute = ({ computedStyle, node }) => {
|
|
133
|
+
const handleElementPositionAttribute = ({ computedStyle, node, }) => {
|
|
134
134
|
const { position } = computedStyle;
|
|
135
135
|
const isPositioned = position === 'absolute' || position === 'relative' || position === 'fixed';
|
|
136
136
|
if (!(node instanceof Document) && !isPositioned)
|
|
@@ -211,11 +211,31 @@
|
|
|
211
211
|
};
|
|
212
212
|
init = () => {
|
|
213
213
|
this._observers = addModificationObservers(this.parentNodes, debounce((event) => {
|
|
214
|
+
if (!this.hasRelevantBeenModified())
|
|
215
|
+
return;
|
|
214
216
|
this.PS.publish('Area:modified:pre', { event, item: this.HTMLNode });
|
|
215
217
|
this.reset();
|
|
216
218
|
this.PS.publish('Area:modified', { event, item: this.HTMLNode });
|
|
217
219
|
}, 60));
|
|
218
220
|
};
|
|
221
|
+
// Check whether the for us relevant values have been changed before making a fuzz
|
|
222
|
+
hasRelevantBeenModified = () => {
|
|
223
|
+
const prevComputedStyle = this.computedStyle;
|
|
224
|
+
const prevRect = this.rect;
|
|
225
|
+
const prevComputedBorder = this.computedBorder;
|
|
226
|
+
const prevParentNodes = this.parentNodes;
|
|
227
|
+
this.reset();
|
|
228
|
+
if (JSON.stringify(prevComputedStyle) !== JSON.stringify(this.computedStyle))
|
|
229
|
+
return true;
|
|
230
|
+
if (JSON.stringify(prevRect) !== JSON.stringify(this.rect))
|
|
231
|
+
return true;
|
|
232
|
+
if (JSON.stringify(prevComputedBorder) !== JSON.stringify(this.computedBorder))
|
|
233
|
+
return true;
|
|
234
|
+
if (prevParentNodes.length !== this.parentNodes.length &&
|
|
235
|
+
prevParentNodes.some((el) => !this.parentNodes.includes(el)))
|
|
236
|
+
return true;
|
|
237
|
+
return false;
|
|
238
|
+
};
|
|
219
239
|
reset = () => {
|
|
220
240
|
this._computedStyle = undefined;
|
|
221
241
|
this._rect = undefined;
|
|
@@ -258,9 +278,18 @@
|
|
|
258
278
|
get computedStyle() {
|
|
259
279
|
if (this._computedStyle)
|
|
260
280
|
return this._computedStyle;
|
|
281
|
+
let tempStyles;
|
|
261
282
|
if (this.HTMLNode instanceof Document)
|
|
262
|
-
|
|
263
|
-
|
|
283
|
+
tempStyles = window.getComputedStyle(this.HTMLNode.body || this.HTMLNode.documentElement);
|
|
284
|
+
else
|
|
285
|
+
tempStyles = window.getComputedStyle(this.HTMLNode);
|
|
286
|
+
return (this._computedStyle = {
|
|
287
|
+
borderTopWidth: tempStyles.borderTopWidth,
|
|
288
|
+
borderBottomWidth: tempStyles.borderBottomWidth,
|
|
289
|
+
borderLeftWidth: tempStyles.borderLeftWidth,
|
|
290
|
+
borderRightWidth: tempStyles.borderRightWidth,
|
|
291
|
+
position: tempStyles.position,
|
|
292
|
+
});
|
|
264
293
|
}
|
|
265
294
|
/** The element rect (caches result) (without scrollbar or borders) */
|
|
266
295
|
get rect() {
|
|
@@ -2424,7 +2453,7 @@
|
|
|
2424
2453
|
// Deprecation warnings
|
|
2425
2454
|
if (deprecatedNamesMap[eventName])
|
|
2426
2455
|
console.warn(`[DragSelect]: The event name "${eventName}" is deprecated and was/will be removed in a future version. Please use the new event name "${deprecatedNamesMap[eventName]}" instead.`);
|
|
2427
|
-
this.PubSub.subscribe(eventName, callback);
|
|
2456
|
+
return this.PubSub.subscribe(eventName, callback);
|
|
2428
2457
|
};
|
|
2429
2458
|
/** Un-Subscribe from events */
|
|
2430
2459
|
unsubscribe = (eventName, callback, id) => this.PubSub.unsubscribe(eventName, callback, id);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function t(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function e(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?t(Object(r),!0).forEach((function(t){i(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):t(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,D(r.key),r)}}function s(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function i(t,e,n){return(e=D(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&l(t,e)}function a(t){return a=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},a(t)}function l(t,e){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},l(t,e)}function c(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function u(t,e,n){return u=c()?Reflect.construct.bind():function(t,e,n){var r=[null];r.push.apply(r,e);var s=new(Function.bind.apply(t,r));return n&&l(s,n.prototype),s},u.apply(null,arguments)}function d(t){var e="function"==typeof Map?new Map:void 0;return d=function(t){if(null===t||(n=t,-1===Function.toString.call(n).indexOf("[native code]")))return t;var n;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return u(t,arguments,a(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),l(r,t)},d(t)}function h(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function S(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return h(t)}function p(t){var e=c();return function(){var n,r=a(t);if(e){var s=a(this).constructor;n=Reflect.construct(r,arguments,s)}else n=r.apply(this,arguments);return S(this,n)}}function f(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=a(t)););return t}function g(){return g="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=f(t,e);if(r){var s=Object.getOwnPropertyDescriptor(r,e);return s.get?s.get.call(arguments.length<3?t:n):s.value}},g.apply(this,arguments)}function v(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,s,i,o,a=[],l=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=i.call(n)).done)&&(a.push(r.value),a.length!==e);l=!0);}catch(t){c=!0,s=t}finally{try{if(!l&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw s}}return a}}(t,e)||m(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(t){return function(t){if(Array.isArray(t))return y(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||m(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(t,e){if(t){if("string"==typeof t)return y(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?y(t,e):void 0}}function y(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function D(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}var _=function(t,e,n){var r=t.x,s=t.y,i=n.x,o=n.y;return{"+":{x:r+i,y:s+o},"-":{x:r-i,y:s-o},"*":{x:r*i,y:s*o},"/":{x:r/i,y:s/o}}[e]},I=function(t){return{x:t.left,y:t.top}},w=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return{left:t.x,top:t.y,right:t.x,bottom:t.y,width:e,height:e}},L=function(t,e){var n=e;window.addEventListener("resize",n),window.addEventListener("scroll",n);var r=new MutationObserver(n);t.forEach((function(t,e){r.observe(t,{childList:0!==e,attributes:!0})}));return{observer:r,callback:n,cleanup:function(){return j(r,n)}}},P=function(t,e){var n;return function(){for(var r=arguments.length,s=new Array(r),i=0;i<r;i++)s[i]=arguments[i];var o=function(){n=null,t.apply(void 0,s)};clearTimeout(n),n=setTimeout(o,e)}},C=function(){var t,e,n,r;return{y:(null===(t=document.body)||void 0===t?void 0:t.scrollTop)||(null===(e=document.documentElement)||void 0===e?void 0:e.scrollTop)||0,x:(null===(n=document.body)||void 0===n?void 0:n.scrollLeft)||(null===(r=document.documentElement)||void 0===r?void 0:r.scrollLeft)||0}},E=function(t){return function t(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,s=null===(n=e[r])||void 0===n?void 0:n.parentNode;return s?(e.push(s),t(e,++r)):e}([t])},A=function(t,e){var n={top:Number.POSITIVE_INFINITY,left:Number.POSITIVE_INFINITY,bottom:Number.NEGATIVE_INFINITY,right:Number.NEGATIVE_INFINITY,width:Number.NEGATIVE_INFINITY,height:Number.NEGATIVE_INFINITY};return z(t).forEach((function(t){var r=e.getRect(t);n.top=Math.min(n.top,r.top),n.left=Math.min(n.left,r.left),n.bottom=Math.max(n.bottom,r.bottom),n.right=Math.max(n.right,r.right)})),n.height=n.bottom-n.top,n.width=n.right-n.left,n},T=function(t){return!t||t instanceof Document?C():{x:t.scrollLeft>=0?t.scrollLeft:C().x,y:t.scrollTop>=0?t.scrollTop:C().y}},x=function(t){var e=t.elementRect,n=t.containerRect,r=t.tolerance,s=void 0===r?{x:0,y:0}:r,i=[];return e.top-s.y<n.top&&i.push("top"),e.left-s.x<n.left&&i.push("left"),e.bottom+s.y>n.bottom&&i.push("bottom"),e.right+s.y>n.right&&i.push("right"),i},k=function(t){var e={x:0,y:0},n=window.getComputedStyle(t);if(!n.transform||"none"===n.transform)return e;if(n.transform.indexOf("3d")>=0){var r=n.transform.trim().match(/matrix3d\((.*?)\)/);if(r&&r.length){var s,i=null===(s=r[1])||void 0===s?void 0:s.split(",");e.x=parseInt(i[12])||0,e.y=parseInt(i[13])||0}return e}var o=n.transform.trim().match(/matrix\((.*?)\)/);if(o&&o.length){var a,l=null===(a=o[1])||void 0===a?void 0:a.split(",");e.x=parseInt(l[4])||0,e.y=parseInt(l[5])||0}return e},N=function(t,e){return e?function(t){var e=t.style.transform;if(!e||e.indexOf("translate")<0)return k(t);var n={x:0,y:0},r=e.trim().match(/translate[3dD]*?\(.*?\)/);if(r){var s,i=null===(s=r[0])||void 0===s?void 0:s.split("(");if(i){var o,a=null===(o=i[1])||void 0===o?void 0:o.split(",");n.x=parseInt(a[0])||0,n.y=parseInt(a[1])||0}}return n.x||n.x?n:k(t)}(t):function(t){var e=t.style,n={x:parseInt(e.left)||0,y:parseInt(e.top)||0};if(!n.x&&!n.x){var r=window.getComputedStyle(t);return{x:parseInt(r.left)||0,y:parseInt(r.top)||0}}return n}(t)},M=function(t){var e=t.computedStyle,n=t.node,r=e.position;n instanceof Document||("absolute"===r||"relative"===r||"fixed"===r)||(n.style.position="relative")},V=function(t,e,n){return console.warn('[DragSelect] TypeIssue: setting "'.concat(t,'" is not of type "').concat(e,'".'))},R=function(t,e,n,r){if(void 0===e)return n?i({},t,r):{};if(null===e)return i({},t,null);var s=!0,o=!1,a="string"==typeof r;a&&(s="string"==typeof e||e instanceof String),a&&!s&&(o=!0,V(t,"string"));var l=!Number.isNaN(r)&&"number"==typeof r;l&&(s=!Number.isNaN(e)&&"number"==typeof e),l&&!s&&(o=!0,V(t,"number"));var c="[object Object]"===Object.prototype.toString.call(r);c&&(s="[object Object]"===Object.prototype.toString.call(e)),c&&!s&&(o=!0,V(t,"object"));var u="boolean"==typeof r;u&&(s="boolean"==typeof e),u&&!s&&(o=!0,V(t,"boolean"));var d=Array.isArray(r);d&&(s=Array.isArray(e)),d&&!s&&(o=!0,V(t,"array"));var h=o||n;return"dragKeys"===t&&s?i({},t,Object.assign(r,e)):"dragKeys"!==t||s?("dropZones"===t&&s&&new Set(e.map((function(t){return t.id}))).size!==e.length&&console.warn('[DragSelect] UniqueConstraintsIssue: setting "dropZones" contains duplicate ids.'),s?i({},t,e):h?i({},t,r):{}):h?i({},t,r):{}},O=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=t;if(n>0){var s=(t.right-t.left)*n,i=(t.bottom-t.top)*n;r={left:t.left+s,right:t.right-s,top:t.top+i,bottom:t.bottom-i}}return r.left<e.right&&r.right>e.left&&r.top<e.bottom&&r.bottom>e.top},K=function(t){var e=t.element,n=t.posDirection,r=t.containerRect,s=t.useTransform,i=N(e,s),o=_(i,"+",n);Z(e,o,s);var a=e.getBoundingClientRect();!function(t){var e=t.element,n=t.edges,r=t.elementRect,s=t.containerRect,i=t.elementPos,o=t.useTransform;n.includes("top")&&Z(e,{y:i.y+s.top-r.top,x:i.x},o),n.includes("left")&&Z(e,{y:i.y,x:i.x+s.left-r.left},o),n.includes("bottom")&&Z(e,{y:i.y+s.bottom-r.bottom,x:i.x},o),n.includes("right")&&Z(e,{y:i.y,x:i.x+s.right-r.right},o)}({element:e,edges:x({elementRect:a,containerRect:r}),elementRect:a,containerRect:r,elementPos:o,useTransform:s})},j=function(t,e){window.removeEventListener("resize",e),window.removeEventListener("scroll",e),t.disconnect()},Z=function(t,e,n){if(n){var r=t.style.transform;t.style.transform="translate3d(".concat(e.x,"px,").concat(e.y,"px,1px) ").concat(r.replace(/translate.*?\)/g,""))}else t.style.left="".concat(e.x,"px"),t.style.top="".concat(e.y,"px");return t},z=function(t){return t?!Array.isArray(t)&&(t instanceof HTMLElement||t instanceof SVGElement)?[t]:b(new Set(b(t))):[]},B=function(t,e){t.style.left="".concat(e.left,"px"),t.style.top="".concat(e.top,"px"),t.style.width="".concat(e.width,"px"),t.style.height="".concat(e.height,"px")},H=function(){function t(e){var r=this,s=e.DS;n(this,t),i(this,"DS",void 0),i(this,"_observers",void 0),i(this,"_node",void 0),i(this,"_parentNodes",void 0),i(this,"_computedStyle",void 0),i(this,"_computedBorder",void 0),i(this,"_rect",void 0),i(this,"setArea",(function(t){r.reset(),r._node=t,M({computedStyle:r.computedStyle,node:r._node}),setTimeout((function(){r.DS.PubSub.publish("Area:modified:pre",{item:r}),r.reset(),r.DS.PubSub.publish("Area:modified",{item:r})}))})),i(this,"start",(function(){r._observers=L(r.parentNodes,P((function(t){r.DS.PubSub.publish("Area:modified:pre",{event:t,item:r}),r.reset(),r.DS.PubSub.publish("Area:modified",{event:t,item:r})}),60))})),i(this,"reset",(function(){r._computedStyle=void 0,r._rect=void 0,r._computedBorder=void 0,r._parentNodes=void 0})),i(this,"stop",(function(){r._observers.cleanup(),r.reset()})),i(this,"scroll",(function(t,e){var n={scroll_directions:t,scroll_multiplier:e};r.DS.PubSub.publish("Area:scroll:pre",n),function(t,e,n){if(e.length){var r=document&&document.documentElement&&document.documentElement.scrollTop&&document.documentElement,s=t instanceof Document?r||document.body:t,i=e.includes("top")&&s.scrollTop>0,o=e.includes("bottom")&&s.scrollTop<s.scrollHeight,a=e.includes("left")&&s.scrollLeft>0,l=e.includes("right")&&s.scrollLeft<s.scrollWidth;i&&(s.scrollTop-=1*n),o&&(s.scrollTop+=1*n),a&&(s.scrollLeft-=1*n),l&&(s.scrollLeft+=1*n)}}(r._node,t,e),r.DS.PubSub.publish("Area:scroll",n)})),this.DS=s,this.setArea(this.DS.stores.SettingsStore.s.area),this.DS.PubSub.subscribe("Settings:updated:area",(function(t){var e=t.settings;r.setArea(e.area)})),this.DS.PubSub.subscribe("Interaction:init",this.start),this.DS.PubSub.subscribe("Interaction:end",this.reset)}return s(t,[{key:"HTMLNode",get:function(){return this._node}},{key:"computedBorder",get:function(){return this._computedBorder?this._computedBorder:{top:parseInt(this.computedStyle.borderTopWidth),bottom:parseInt(this.computedStyle.borderBottomWidth),left:parseInt(this.computedStyle.borderLeftWidth),right:parseInt(this.computedStyle.borderRightWidth)}}},{key:"computedStyle",get:function(){return this._computedStyle?this._computedStyle:this.HTMLNode instanceof Document?this._computedStyle=window.getComputedStyle(this.HTMLNode.body||this.HTMLNode.documentElement):this._computedStyle=window.getComputedStyle(this.HTMLNode)}},{key:"rect",get:function(){return this._rect?this._rect:this._rect=function(t,e){if(t instanceof Document)return{top:0,left:0,bottom:0,right:0,width:window.innerWidth,height:window.innerHeight};var n=t.getBoundingClientRect();return{top:n.top,left:n.left,bottom:n.bottom,right:n.right,width:(t.clientWidth||n.width)*e,height:(t.clientHeight||n.height)*e}}(this.HTMLNode,this.DS.stores.SettingsStore.s.zoom)}},{key:"parentNodes",get:function(){return this._parentNodes?this._parentNodes:this._parentNodes=E(this.HTMLNode)}}]),t}(),F=function(){function t(e){var r=this,s=e.DS;n(this,t),i(this,"_prevCursorPos",void 0),i(this,"_prevScrollPos",void 0),i(this,"_elements",[]),i(this,"_dragKeys",void 0),i(this,"_dragKeysFlat",[]),i(this,"_selectionRect",void 0),i(this,"assignDragkeys",(function(){r._dragKeys={up:r.DS.stores.SettingsStore.s.dragKeys.up.map((function(t){return t.toLowerCase()})),down:r.DS.stores.SettingsStore.s.dragKeys.down.map((function(t){return t.toLowerCase()})),left:r.DS.stores.SettingsStore.s.dragKeys.left.map((function(t){return t.toLowerCase()})),right:r.DS.stores.SettingsStore.s.dragKeys.right.map((function(t){return t.toLowerCase()}))},r._dragKeysFlat=[].concat(b(r._dragKeys.up),b(r._dragKeys.down),b(r._dragKeys.left),b(r._dragKeys.right))})),i(this,"keyboardDrag",(function(t){var e=t.event,n=t.key.toLowerCase();if(r.DS.stores.SettingsStore.s.keyboardDrag&&r._dragKeysFlat.includes(n)&&r.DS.SelectedSet.size&&r.DS.stores.SettingsStore.s.draggability&&!r.DS.continue){var s={event:e,isDragging:!0,isDraggingKeyboard:!0};r.DS.publish(["Interaction:start:pre","Interaction:start"],s),r._elements=r.DS.getSelection(),r.DS.stores.SettingsStore.s.dragAsBlock&&(r._selectionRect=A(r._elements,r.DS.SelectableSet)),r.handleZIndex(!0);var i=function(t){var e=t.shiftKey,n=t.keyboardDragSpeed,r=t.zoom,s=t.key,i=t.dragKeys,o=t.scrollDiff,a=t.canScroll,l=t.scrollCallback,c={x:0,y:0},u=e?4*n*r:n*r;return i.left.includes(s)&&(c.x=o.x||-u,e||o.x||!a||l(["left"],n)),i.right.includes(s)&&(c.x=o.x||u,e||o.x||!a||l(["right"],n)),i.up.includes(s)&&(c.y=o.y||-u,e||o.y||!a||l(["top"],n)),i.down.includes(s)&&(c.y=o.y||u,e||o.y||!a||l(["bottom"],n)),c}({shiftKey:r.DS.stores.KeyStore.currentValues.includes("shift"),keyboardDragSpeed:r.DS.stores.SettingsStore.s.keyboardDragSpeed,zoom:r.DS.stores.SettingsStore.s.zoom,key:n,scrollCallback:r.DS.Area.scroll,scrollDiff:r._scrollDiff,canScroll:r.DS.stores.ScrollStore.canScroll,dragKeys:r._dragKeys});r.DS.stores.SettingsStore.s.dragAsBlock&&(i=r.limitDirection(i)),r._elements.forEach((function(t){return K({element:t,posDirection:i,containerRect:r.DS.SelectorArea.rect,useTransform:r.DS.stores.SettingsStore.s.useTransform})})),r.DS.publish(["Interaction:update:pre","Interaction:update"],s)}})),i(this,"keyboardEnd",(function(t){var e=t.event,n=t.key.toLowerCase();if(r.DS.stores.SettingsStore.s.keyboardDrag&&r._dragKeysFlat.includes(n)&&r.DS.SelectedSet.size&&r.DS.stores.SettingsStore.s.draggability){var s={event:e,isDragging:r.DS.stores.SettingsStore.s.draggability,isDraggingKeyboard:!0};r.DS.publish(["Interaction:end:pre","Interaction:end"],s)}})),i(this,"start",(function(t){var e=t.isDragging,n=t.isDraggingKeyboard;e&&!n&&(r._prevCursorPos=null,r._prevScrollPos=null,r._elements=r.DS.getSelection(),r.DS.stores.SettingsStore.s.dragAsBlock&&(r._selectionRect=A(r._elements,r.DS.SelectableSet)),r.handleZIndex(!0))})),i(this,"stop",(function(t){null!=t&&t.isKeyboard||(r._prevCursorPos=null,r._prevScrollPos=null,r.handleZIndex(!1),r._elements=[])})),i(this,"update",(function(t){var e=t.isDragging,n=t.isDraggingKeyboard;if(e&&r._elements.length&&!n&&!r.DS.continue){var s=_(r._cursorDiff,"+",r._scrollDiff);r.DS.stores.SettingsStore.s.dragAsBlock&&(s=r.limitDirection(s)),r._elements.forEach((function(t){return K({element:t,posDirection:s,containerRect:r.DS.SelectorArea.rect,useTransform:r.DS.stores.SettingsStore.s.useTransform})}))}})),i(this,"limitDirection",(function(t){var e=r.DS.SelectorArea.rect,n=r.DS.stores.ScrollStore.scrollAmount,s={top:e.top-r._selectionRect.top+n.y,left:e.left-r._selectionRect.left+n.x,bottom:e.bottom-r._selectionRect.bottom+n.y,right:e.right-r._selectionRect.right+n.x};return 0===t.x&&0===t.y||(t.y<0&&(t.y=Math.max(t.y,s.top)),t.x<0&&(t.x=Math.max(t.x,s.left)),t.y>0&&(t.y=Math.min(t.y,s.bottom)),t.x>0&&(t.x=Math.min(t.x,s.right)),r._selectionRect.top+=t.y,r._selectionRect.bottom+=t.y,r._selectionRect.left+=t.x,r._selectionRect.right+=t.x),t})),i(this,"handleZIndex",(function(t){r._elements.forEach((function(e){return e.style.zIndex="".concat((parseInt(e.style.zIndex)||0)+t?9999:-9998)}))})),this.DS=s,this.DS.subscribe("Settings:updated:dragKeys",this.assignDragkeys),this.assignDragkeys(),this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:end",this.stop),this.DS.subscribe("Interaction:update",this.update),this.DS.subscribe("KeyStore:down",this.keyboardDrag),this.DS.subscribe("KeyStore:up",this.keyboardEnd)}return s(t,[{key:"_cursorDiff",get:function(){var t=this.DS.stores.PointerStore.currentVal,e=this._prevCursorPos?_(t,"-",this._prevCursorPos):{x:0,y:0};return this._prevCursorPos=t,e}},{key:"_scrollDiff",get:function(){var t=this.DS.stores.ScrollStore.currentVal,e=this._prevScrollPos?_(t,"-",this._prevScrollPos):{x:0,y:0};return this._prevScrollPos=t,e}}]),t}(),Y=function(){function t(e){var r=this,s=e.DS,o=e.id,a=e.element,l=e.droppables;n(this,t),i(this,"id",void 0),i(this,"element",void 0),i(this,"_droppables",void 0),i(this,"_rect",void 0),i(this,"_observers",void 0),i(this,"_timeout",void 0),i(this,"_itemsDropped",[]),i(this,"_itemsInside",void 0),i(this,"setReadyClasses",(function(t){if(!r.isDestroyed){var e=r.droppables.filter((function(t){return r.DS.SelectedSet.has(t)}));e.length&&(e.forEach((function(e){e.classList[t]("".concat(r.Settings.droppableClass)),e.classList[t]("".concat(r.Settings.droppableClass,"-").concat(r.id))})),r.element.classList[t]("".concat(r.Settings.dropZoneReadyClass)))}})),i(this,"handleNoDrop",(function(){var t;r.isDestroyed||(r.DS.SelectedSet.forEach((function(t){t.classList.remove(r.Settings.droppedTargetClass),t.classList.remove("".concat(r.Settings.droppedTargetClass,"-").concat(r.id))})),r._itemsDropped=r._itemsDropped.filter((function(t){return!r.DS.SelectedSet.has(t)})),null!==(t=r._itemsDropped)&&void 0!==t&&t.length||r.element.classList.remove("".concat(r.Settings.dropZoneTargetClass)))})),i(this,"handleDrop",(function(){var t,e,n;r.isDestroyed||(r._itemsDropped=b(new Set([].concat(b(r._itemsDropped),b(null===(t=r.droppables)||void 0===t?void 0:t.filter((function(t){return r.DS.SelectedSet.has(t)})))))),null===(e=r._itemsDropped)||void 0===e||e.forEach((function(t){t.classList.add("".concat(r.Settings.droppedTargetClass)),t.classList.add("".concat(r.Settings.droppedTargetClass,"-").concat(r.id))})),null!==(n=r._itemsDropped)&&void 0!==n&&n.length&&r.element.classList.add("".concat(r.Settings.dropZoneTargetClass)))})),i(this,"handleItemsInsideClasses",(function(){var t=!1;r.droppables.forEach((function(e){r.itemsInside.includes(e)?(e.classList.add("".concat(r.Settings.droppedInsideClass)),e.classList.add("".concat(r.Settings.droppedInsideClass,"-").concat(r.id)),t=!0):(e.classList.remove("".concat(r.Settings.droppedInsideClass,"-").concat(r.id)),e.className.includes("".concat(r.Settings.droppedInsideClass,"-"))||e.classList.remove("".concat(r.Settings.droppedInsideClass)))})),t?r.element.classList.add("".concat(r.Settings.dropZoneInsideClass)):r.element.classList.remove("".concat(r.Settings.dropZoneInsideClass))})),i(this,"start",(function(t){t.isDragging&&!r.isDestroyed&&r.setReadyClasses("add")})),i(this,"stop",(function(t){t.isDragging&&!r.isDestroyed&&(r.setReadyClasses("remove"),r.handleItemsInsideClasses())})),i(this,"toObject",(function(){return{id:r.id,element:r.element,droppables:r.droppables,itemsDropped:r.itemsDropped,itemsInside:r.itemsInside}})),this.DS=s,this.Settings=s.stores.SettingsStore.s,this.id=o,this.element=a,l&&(this.droppables=z(l)),this.element.classList.add("".concat(this.Settings.dropZoneClass)),this.DS.subscribe("Settings:updated:dropZoneClass",(function(t){var e=t.settings;r.element&&(r.element.classList.remove(e["dropZoneClass:pre"]),r.element.classList.add(e.dropZoneClass))})),this._observers=L(this.parentNodes,P((function(){return r._rect=null}),this.Settings.refreshMemoryRate)),this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:end",this.stop)}return s(t,[{key:"destroy",value:function(){var t=this;this._observers.cleanup(),this.element.classList.remove("".concat(this.Settings.dropZoneClass)),this.element.classList.remove("".concat(this.Settings.dropZoneTargetClass)),this.element.classList.remove("".concat(this.Settings.dropZoneReadyClass)),this.droppables.forEach((function(e){e.classList.remove("".concat(t.Settings.droppedTargetClass)),e.classList.remove("".concat(t.Settings.droppedTargetClass,"-").concat(t.id)),e.classList.remove("".concat(t.Settings.droppableClass)),e.classList.remove("".concat(t.Settings.droppableClass,"-").concat(t.id))})),this.DS.unsubscribe("Interaction:start",this.start),this.DS.unsubscribe("Interaction:end",this.stop),this.element=null,this.droppables=null,this.id=null,this._itemsDropped=null,this._itemsInside=null,this.isDestroyed=!0}},{key:"rect",get:function(){return this.isDestroyed?null:this._rect?this._rect:this._rect=this.element.getBoundingClientRect()}},{key:"itemsDropped",get:function(){return this.isDestroyed?null:this._itemsDropped}},{key:"itemsInside",get:function(){var t=this;return this.isDestroyed?null:(this._itemsInside||(this._itemsInside=this.droppables.flatMap((function(e){return O(t.DS.SelectableSet.rects.get(e),t.rect,t.Settings.dropInsideThreshold)?[e]:[]})),this._timeout&&clearTimeout(this._timeout),this._timeout=setTimeout((function(){return t._itemsInside=null}),this.Settings.refreshMemoryRate)),this._itemsInside)}},{key:"parentNodes",get:function(){return this._parentNodes?this._parentNodes:this._parentNodes=E(this.element)}},{key:"droppables",get:function(){return this._droppables?this._droppables:this.DS.SelectableSet.elements},set:function(t){this._droppables=t}}]),t}(),W=s((function t(r){var s=this,o=r.DS;n(this,t),i(this,"_zoneByElement",new Map),i(this,"_zoneById",new Map),i(this,"_zonesByDroppable",new Map),i(this,"_zones",void 0),i(this,"setDropZones",(function(t){var n=t.dropZones;n&&(s._zones&&s._zones.forEach((function(t){return t.destroy()})),s._zones=n.map((function(t){return new Y(e({DS:s.DS},t))})),s._zones.forEach((function(t){s._zoneByElement.set(t.element,t),s._zoneById.set(t.id,t),t.droppables.forEach((function(e){var n=s._zonesByDroppable.get(e);if(null==n||!n.length)return s._zonesByDroppable.set(e,[t]);s._zonesByDroppable.set(e,b(new Set([].concat(b(n),[t]))))}))})))})),i(this,"_handleDrop",(function(t){s._zones.forEach((function(e){e!==t&&e.handleNoDrop()})),t&&t.handleDrop()})),i(this,"_getZoneByElementsFromPoint",(function(t,e){for(var n=e.x,r=e.y,i=0,o=t.length;i<o;i++){var a=s._zoneByElement.get(t[i]);if(a&&O(a.rect,{left:n,right:n,top:r,bottom:r},Math.min(s.Settings.dropTargetThreshold,.5)))return a}})),i(this,"stop",(function(t){if(t.isDragging){var e=s.getTarget();s._handleDrop(e)}})),i(this,"getItemsDroppedById",(function(t){var e=s._zoneById.get(t);return e?e.itemsDropped:console.warn("[DragSelect] No zone found (id: ".concat(t,")"))})),i(this,"getItemsInsideById",(function(t,e){var n=s._zoneById.get(t);if(!n)return console.warn("[DragSelect] No zone found (id: ".concat(t,")"));var r=n.itemsInside;return e&&n.handleItemsInsideClasses(),r})),i(this,"getTarget",(function(t){var e;if(null!==(e=s._zones)&&void 0!==e&&e.length){var n=(null==t?void 0:t.x)||s.DS.stores.PointerStore.currentVal.x,r=(null==t?void 0:t.y)||s.DS.stores.PointerStore.currentVal.y,i=document.elementsFromPoint(n,r);return s._getZoneByElementsFromPoint(i,{x:n,y:r})}})),this.DS=o,this.Settings=o.stores.SettingsStore.s,this.DS.subscribe("Settings:updated:dropZones",(function(t){var e=t.settings;return s.setDropZones(e)})),this.setDropZones({dropZones:this.DS.stores.SettingsStore.s.dropZones}),this.DS.subscribe("Interaction:end",this.stop)})),G=function(){function t(e){var r=this,s=e.DS;n(this,t),i(this,"isInteracting",void 0),i(this,"isDragging",void 0),i(this,"init",(function(){return r.DS.publish("Interaction:init:pre",{})})),i(this,"_init",(function(){r.stop(),r.Settings.usePointerEvents?r.DS.Area.HTMLNode.addEventListener("pointerdown",r.start,{passive:!1}):r.DS.Area.HTMLNode.addEventListener("mousedown",r.start),r.DS.Area.HTMLNode.addEventListener("touchstart",r.start,{passive:!1}),r.DS.publish("Interaction:init",{})})),i(this,"start",(function(t){return r.DS.publish("Interaction:start:pre",{event:t,isDragging:r.isDragging})})),i(this,"_start",(function(t){"touchstart"===t.type&&t.preventDefault(),r._canInteract(t)&&(r.isInteracting=!0,r.isDragging=r.isDragEvent(t),r.DS.publish("Interaction:start",{event:t,isDragging:r.isDragging}),r.Settings.usePointerEvents?(document.addEventListener("pointerup",r.reset),document.addEventListener("pointercancel",r.reset)):document.addEventListener("mouseup",r.reset),document.addEventListener("touchend",r.reset))})),i(this,"isDragEvent",(function(t){var e=t.target.closest(".".concat(r.Settings.selectableClass));return!(!r.Settings.draggability||r.DS.stores.KeyStore.isMultiSelectKeyPressed(t)||!e)&&(r.Settings.immediateDrag&&(r.DS.SelectedSet.size?r.DS.SelectedSet.has(e)||(r.DS.SelectedSet.clear(),r.DS.SelectedSet.add(e)):r.DS.SelectedSet.add(e)),!!r.DS.SelectedSet.has(e))})),i(this,"onClick",(function(t){var e=t.event;if(r._canInteract(e)&&!(e.detail>0)){var n=r.DS,s=n.stores,i=s.PointerStore,o=s.KeyStore,a=n.SelectableSet,l=n.SelectedSet;i.start(e);var c=e.target;a.has(c)&&(o.isMultiSelectKeyPressed(e)||l.clear(),l.toggle(c),r.reset())}})),i(this,"stop",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:r.DS.Area.HTMLNode;r.isInteracting=!1,r.isDragging=!1,r.Settings.usePointerEvents?(t.removeEventListener("pointerdown",r.start,{passive:!1}),document.removeEventListener("pointerup",r.reset),document.removeEventListener("pointercancel",r.reset)):(t.removeEventListener("mousedown",r.start),document.removeEventListener("mouseup",r.reset)),t.removeEventListener("touchstart",r.start,{passive:!1}),document.removeEventListener("touchend",r.reset)})),i(this,"update",(function(t){var e=t.event,n=t.scroll_directions,s=t.scroll_multiplier;r.isInteracting&&r.DS.publish(["Interaction:update:pre","Interaction:update"],{event:e,scroll_directions:n,scroll_multiplier:s,isDragging:r.isDragging})})),i(this,"reset",(function(t){return r.DS.publish("Interaction:end:pre",{event:t,isDragging:r.isDragging})})),i(this,"_reset",(function(t){var e=r.isDragging;r.stop(),r.init(),r.DS.publish("Interaction:end",{event:t,isDragging:e})})),this.DS=s,this.Settings=s.stores.SettingsStore.s,this.DS.subscribe("Settings:updated:area",(function(t){var e=t.settings;r.stop(e["area:pre"]),r.init()})),this.DS.subscribe("PointerStore:updated",this.update),this.DS.subscribe("Selectable:click",this.onClick),this.DS.subscribe("Selectable:pointer",(function(t){var e=t.event;return r.start(e)})),this.DS.subscribe("Interaction:start:pre",(function(t){var e=t.event;return r._start(e)})),this.DS.subscribe("Interaction:init:pre",this._init),this.DS.subscribe("Interaction:end:pre",(function(t){var e=t.event;return r._reset(e)})),this.DS.subscribe("Area:scroll",this.update)}return s(t,[{key:"_canInteract",value:function(t){var e=0===t.clientX&&0===t.clientY&&0===t.detail&&t.target;return!(2===t.button||this.isInteracting||t.target&&!this.DS.SelectorArea.isInside(t.target)||!e&&!this.DS.SelectorArea.isClicked(t))}}]),t}(),U=s((function t(e){var r=this,s=e.DS;n(this,t),i(this,"subscribers",{}),i(this,"subscribe",(function(t,e){return Array.isArray(r.subscribers[t])||(r.subscribers[t]=[]),r.subscribers[t].push(e),r.subscribers[t].length-1})),i(this,"unsubscribe",(function(t,e,n){n>=0?r.subscribers[t].splice(n,1):e&&(r.subscribers[t]=r.subscribers[t].filter((function(t){return t!==e})))})),i(this,"publish",(function(t,e){Array.isArray(t)?t.forEach((function(t){return r._publish(t,e)})):r._publish(t,e)})),i(this,"_publish",(function(t,e){var n=r.subscribers[t];Array.isArray(n)&&(t.includes(":pre")?r._handlePrePublish(n,e):r._handlePublish(n,e))})),i(this,"_handlePublish",(function(t,e){for(var n=0,s=t.length;n<s;n++){if(r.DS.stopped)return;t[n](e)}})),i(this,"_handlePrePublish",(function(t,e){for(var n=t.length;n--;){if(r.DS.stopped)return;t[n](e)}})),this.DS=s})),X=function(t){o(r,d(Set));var e=p(r);function r(t){var s,o=t.DS;return n(this,r),i(h(s=e.call(this)),"_rects",void 0),i(h(s),"_timeout",void 0),i(h(s),"init",(function(){return z(s.Settings.selectables).forEach((function(t){return s.add(t)}))})),i(h(s),"clear",(function(){return s.forEach((function(t){return s.delete(t)}))})),i(h(s),"_onClick",(function(t){return s.DS.publish(["Selectable:click:pre","Selectable:click"],{event:t})})),i(h(s),"_onPointer",(function(t){return s.DS.publish(["Selectable:pointer:pre","Selectable:pointer"],{event:t})})),i(h(s),"addAll",(function(t){return t.forEach((function(t){return s.add(t)}))})),i(h(s),"deleteAll",(function(t){return t.forEach((function(t){return s.delete(t)}))})),i(h(s),"getRect",(function(t){return s._rects?s.rects.get(t):t.getBoundingClientRect()})),s.DS=o,s.Settings=o.stores.SettingsStore.s,s.DS.subscribe("Interaction:init",s.init),s.DS.PubSub.subscribe("Settings:updated:selectables",(function(){s.clear(),s.init()})),s.DS.subscribe("Settings:updated:selectableClass",(function(t){var e=t.settings;s.forEach((function(t){t.classList.remove(e["selectableClass:pre"]),t.classList.add(e.selectableClass)}))})),s}return s(r,[{key:"add",value:function(t){if(g(a(r.prototype),"has",this).call(this,t))return this;var e={items:this.elements,item:t};return this.DS.publish("Selectable:added:pre",e),t.classList.add(this.Settings.selectableClass),t.addEventListener("click",this._onClick),this.Settings.usePointerEvents?t.addEventListener("pointerdown",this._onPointer,{passive:!1}):t.addEventListener("mousedown",this._onPointer),t.addEventListener("touchstart",this._onPointer,{passive:!1}),this.Settings.draggability&&!this.Settings.useTransform&&M({computedStyle:window.getComputedStyle(t),node:t}),g(a(r.prototype),"add",this).call(this,t),this.DS.publish("Selectable:added",e),this}},{key:"delete",value:function(t){if(!g(a(r.prototype),"has",this).call(this,t))return!0;var e={items:this.elements,item:t};return this.DS.publish("Selectable:removed:pre",e),t.classList.remove(this.Settings.selectableClass),t.classList.remove(this.Settings.hoverClass),t.removeEventListener("click",this._onClick),this.Settings.usePointerEvents?t.removeEventListener("pointerdown",this._onPointer,{passive:!1}):t.removeEventListener("mousedown",this._onPointer),t.removeEventListener("touchstart",this._onPointer,{passive:!1}),g(a(r.prototype),"delete",this).call(this,t),this.DS.publish("Selectable:removed",e),!0}},{key:"elements",get:function(){return Array.from(this.values())}},{key:"rects",get:function(){var t=this;return this._rects||(this._rects=new Map,this.forEach((function(e){return t._rects.set(e,e.getBoundingClientRect())})),this._timeout&&clearTimeout(this._timeout),this._timeout=setTimeout((function(){return t._rects=null}),this.Settings.refreshMemoryRate)),this._rects}}]),r}(),q=function(t){o(r,d(Set));var e=p(r);function r(t){var s,o=t.DS;return n(this,r),i(h(s=e.call(this)),"clear",(function(){return s.forEach((function(t){return s.delete(t)}))})),i(h(s),"addAll",(function(t){return t.forEach((function(t){return s.add(t)}))})),i(h(s),"deleteAll",(function(t){return t.forEach((function(t){return s.delete(t)}))})),s.DS=o,s}return s(r,[{key:"add",value:function(t){if(g(a(r.prototype),"has",this).call(this,t))return this;var e={items:this.elements,item:t};return this.DS.publish("Selected:added:pre",e),g(a(r.prototype),"add",this).call(this,t),t.classList.add(this.DS.stores.SettingsStore.s.selectedClass),t.style.zIndex="".concat((parseInt(t.style.zIndex)||0)+1),this.DS.publish("Selected:added",e),this}},{key:"delete",value:function(t){if(!g(a(r.prototype),"has",this).call(this,t))return!0;var e={items:this.elements,item:t};this.DS.publish("Selected:removed:pre",e);var n=g(a(r.prototype),"delete",this).call(this,t);return t.classList.remove(this.DS.stores.SettingsStore.s.selectedClass),t.style.zIndex="".concat((parseInt(t.style.zIndex)||0)-1),this.DS.publish("Selected:removed",e),n}},{key:"toggle",value:function(t){return this.has(t)?this.delete(t):this.add(t),t}},{key:"elements",get:function(){return Array.from(this.values())}}]),r}(),$=function(){function t(e){var r=this,s=e.DS;n(this,t),i(this,"_prevSelectedSet",void 0),i(this,"start",(function(t){var e=t.event;t.isDragging||(r._storePrevious(e),r._handleInsideSelection(!0,e))})),i(this,"update",(function(t){t.isDragging||r.DS.continue||r._handleInsideSelection()})),i(this,"_handleInsideSelection",(function(t,e){var n,s=r.DS,i=s.SelectableSet,o=s.SelectorArea,a=s.Selector,l=r.DS.stores.KeyStore.isMultiSelectKeyPressed(e)&&r.Settings.multiSelectToggling,c=r.Settings.selectionThreshold,u=i.rects,d=a.rect,h=new Map,S=new Map,p=function(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=m(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,s=function(){};return{s:s,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:s}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return o=t.done,t},e:function(t){a=!0,i=t},f:function(){try{o||null==n.return||n.return()}finally{if(a)throw i}}}}(u);try{for(p.s();!(n=p.n()).done;){var f=v(n.value,2),g=f[0],b=f[1];o.isInside(g,b)&&(O(b,d,c)?h.set(g,b):S.set(g,b))}}catch(t){p.e(t)}finally{p.f()}if(!r.DS.continue){var y=r.filterSelected({select:h,unselect:S,selectorRect:d}),D=y.select,_=y.unselect;D.forEach((function(e,n){return function(t){var e=t.element,n=t.force,r=t.multiSelectionToggle,s=t.SelectedSet,i=t.hoverClassName;e.classList.contains(i)&&!n||(s.has(e)?r&&s.delete(e):s.add(e),e.classList.add(i))}({element:n,force:t,multiSelectionToggle:l,SelectedSet:r.DS.SelectedSet,hoverClassName:r.Settings.hoverClass})})),_.forEach((function(e,n){return function(t){var e=t.element,n=t.force,r=t.SelectedSet,s=t.PrevSelectedSet,i=t.hoverClassName;if(!e.classList.contains(i)&&!n)return!1;var o=r.has(e),a=s.has(e);o&&!a?r.delete(e):!o&&a&&r.add(e),e.classList.remove(i)}({element:n,force:t,SelectedSet:r.DS.SelectedSet,hoverClassName:r.Settings.hoverClass,PrevSelectedSet:r._prevSelectedSet})}))}})),i(this,"filterSelected",(function(t){var e=t.select,n=t.unselect;return t.selectorRect,{select:e,unselect:n}})),this.DS=s,this.Settings=this.DS.stores.SettingsStore.s,this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:update",this.update)}return s(t,[{key:"_storePrevious",value:function(t){var e=this.DS,n=e.stores.KeyStore,r=e.SelectedSet;n.isMultiSelectKeyPressed(t)?this._prevSelectedSet=new Set(r):this._prevSelectedSet=new Set}}]),t}(),J=function(){function t(e){var r=this,s=e.DS;n(this,t),i(this,"_rect",void 0),i(this,"attachSelector",(function(){var t,e,n,s;r.HTMLNode&&null!==(t=r.DS.SelectorArea)&&void 0!==t&&t.HTMLNode&&r.DS.SelectorArea.HTMLNode.removeChild(r.HTMLNode),r.HTMLNode=r.DS.stores.SettingsStore.s.selector||(n=r.DS.stores.SettingsStore.s.customStyles,(s=document.createElement("div")).style.position="absolute",n||(s.style.background="rgba(0, 175, 255, 0.2)",s.style.border="1px solid rgba(0, 175, 255, 0.8)",s.style.display="none",s.style.pointerEvents="none"),s),r.HTMLNode.classList.add(r.DS.stores.SettingsStore.s.selectorClass),r.HTMLNode&&null!==(e=r.DS.SelectorArea)&&void 0!==e&&e.HTMLNode&&r.DS.SelectorArea.HTMLNode.appendChild(r.HTMLNode)})),i(this,"start",(function(t){if(!t.isDragging){var e=r.DS.stores.PointerStore.initialValArea;B(r.HTMLNode,w(e,1)),r.HTMLNode.style.display="block",r._rect=null}})),i(this,"stop",(function(){r.HTMLNode.style.width="0",r.HTMLNode.style.height="0",r.HTMLNode.style.display="none"})),i(this,"update",(function(t){if(!t.isDragging&&!r.DS.continue){var e=r.DS.stores,n=e.ScrollStore,s=e.PointerStore,i=function(t){var e=t.scrollAmount,n=t.initialPointerPos,r=t.pointerPos,s={};return r.x>n.x-e.x?(s.left=n.x-e.x,s.width=r.x-n.x+e.x):(s.left=r.x,s.width=n.x-r.x-e.x),r.y>n.y-e.y?(s.top=n.y-e.y,s.height=r.y-n.y+e.y):(s.top=r.y,s.height=n.y-r.y-e.y),s}({scrollAmount:n.scrollAmount,initialPointerPos:s.initialValArea,pointerPos:s.currentValArea});B(r.HTMLNode,i),r._rect=null}})),this.DS=s,this.DS.subscribe("Settings:updated:selectorClass",(function(t){var e=t.settings;r.HTMLNode.classList.remove(e["selectorClass:pre"]),r.HTMLNode.classList.add(e.selectorClass)})),this.DS.subscribe("Settings:updated:selector",this.attachSelector),this.DS.subscribe("Settings:updated:customStyles",this.attachSelector),this.attachSelector(),this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:update",this.update),this.DS.subscribe("Interaction:end",this.stop)}return s(t,[{key:"rect",get:function(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}]),t}(),Q=function(){function t(e){var r,s=this,o=e.DS;n(this,t),i(this,"_scrollInterval",void 0),i(this,"_rect",void 0),i(this,"currentEdges",[]),i(this,"start",(function(){s.applyElements("append"),s.updatePos()})),i(this,"applyElements",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"append",e=document.body?"body":"documentElement",n="".concat(t,"Child");s.HTMLNode[n](s.DS.Selector.HTMLNode),document[e][n](s.HTMLNode)})),i(this,"updatePos",(function(){s._rect=null;var t=s.DS.Area.rect,e=s.DS.Area.computedBorder,n=s.HTMLNode.style,r="".concat(t.top+e.top,"px"),i="".concat(t.left+e.left,"px"),o="".concat(t.width,"px"),a="".concat(t.height,"px");n.top!==r&&(n.top=r),n.left!==i&&(n.left=i),n.width!==o&&(n.width=o),n.height!==a&&(n.height=a)})),i(this,"stop",(function(t){s.stopAutoScroll(),t&&s.applyElements("remove")})),i(this,"startAutoScroll",(function(){s.currentEdges=[],s._scrollInterval=setInterval((function(){return s.handleAutoScroll()}),16)})),i(this,"handleAutoScroll",(function(){if(!s.DS.continue){var t=s.DS,e=t.stores.PointerStore,n=t.Area;s.currentEdges=x({elementRect:w(e.currentVal),containerRect:s.rect,tolerance:s.DS.stores.SettingsStore.s.overflowTolerance}),s.currentEdges.length&&n.scroll(s.currentEdges,s.DS.stores.SettingsStore.s.autoScrollSpeed)}})),i(this,"stopAutoScroll",(function(){s.currentEdges=[],clearInterval(s._scrollInterval)})),i(this,"isInside",(function(t,e){return!(!s.DS.Area.HTMLNode.contains(t)||!s.DS.stores.ScrollStore.canScroll)||O(s.rect,e||t.getBoundingClientRect())})),this.DS=o,this.HTMLNode=((r=document.createElement("div")).style.position="fixed",r.style.overflow="hidden",r.style.pointerEvents="none",r.style.zIndex="999999999999999999",r),this.DS.subscribe("Settings:updated:selectorAreaClass",(function(t){var e=t.settings;s.HTMLNode.classList.remove(e["selectorAreaClass:pre"]),s.HTMLNode.classList.add(e.selectorAreaClass)})),this.HTMLNode.classList.add(this.DS.stores.SettingsStore.s.selectorAreaClass),this.DS.subscribe("Area:modified",this.updatePos),this.DS.subscribe("Area:modified",this.updatePos),this.DS.subscribe("Interaction:init",this.start),this.DS.subscribe("Interaction:start",this.startAutoScroll),this.DS.subscribe("Interaction:end",(function(){s.updatePos(),s.stopAutoScroll()}))}return s(t,[{key:"isClicked",value:function(t){var e=this.DS.stores.PointerStore,n=t?e.getPointerPosition(t):e.initialVal;return O({left:n.x,top:n.y,right:n.x,bottom:n.y},this.rect)}},{key:"rect",get:function(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}]),t}(),tt=function(){function t(e){var r=this,s=e.DS;n(this,t),i(this,"_currentValues",new Set),i(this,"_keyMapping",{control:"ctrlKey",shift:"shiftKey",meta:"metaKey"}),i(this,"init",(function(){document.addEventListener("keydown",r.keydown),document.addEventListener("keyup",r.keyup),window.addEventListener("blur",r.reset)})),i(this,"keydown",(function(t){var e=t.key.toLowerCase();r.DS.publish("KeyStore:down:pre",{event:t,key:e}),r._currentValues.add(e),r.DS.publish("KeyStore:down",{event:t,key:e})})),i(this,"keyup",(function(t){var e=t.key.toLowerCase();r.DS.publish("KeyStore:up:pre",{event:t,key:e}),r._currentValues.delete(e),r.DS.publish("KeyStore:up",{event:t,key:e})})),i(this,"stop",(function(){document.removeEventListener("keydown",r.keydown),document.removeEventListener("keyup",r.reset),window.removeEventListener("blur",r.reset),r.reset()})),i(this,"reset",(function(){return r._currentValues.clear()})),this.DS=s,this.DS.subscribe("Interaction:init",this.init)}return s(t,[{key:"isMultiSelectKeyPressed",value:function(t){var e=this;if(this.DS.stores.SettingsStore.s.multiSelectMode)return!0;var n=this.DS.stores.SettingsStore.s.multiSelectKeys.map((function(t){return t.toLocaleLowerCase()}));return!!this.currentValues.some((function(t){return n.includes(t.toLocaleLowerCase())}))||!(!t||!n.some((function(n){return t[e._keyMapping[n]]})))}},{key:"currentValues",get:function(){return Array.from(this._currentValues.values())}}]),t}(),et=function(){function t(e){var r=this,s=e.DS;n(this,t),i(this,"_isMouseInteraction",!1),i(this,"_initialValArea",void 0),i(this,"_currentValArea",void 0),i(this,"_lastValArea",void 0),i(this,"_initialVal",void 0),i(this,"_currentVal",void 0),i(this,"_lastVal",void 0),i(this,"_lastTouch",void 0),i(this,"init",(function(){r.Settings.usePointerEvents?document.addEventListener("pointermove",r.update,{passive:!1}):document.addEventListener("mousemove",r.update),document.addEventListener("touchmove",r.update,{passive:!1})})),i(this,"getPointerPosition",(function(t){return function(t){var e=t.event;return{x:e.clientX,y:e.clientY}}({event:r._normalizedEvent(t)})})),i(this,"update",(function(t){t&&(r.DS.publish("PointerStore:updated:pre",{event:t}),r.currentVal=r.getPointerPosition(t),r._isMouseInteraction&&r.DS.publish("PointerStore:updated",{event:t}))})),i(this,"stop",(function(){r.Settings.usePointerEvents?document.removeEventListener("pointermove",r.update,{passive:!1}):document.removeEventListener("mousemove",r.update),document.removeEventListener("touchmove",r.update,{passive:!1}),setTimeout((function(){return r._isMouseInteraction=!1}),100)})),i(this,"reset",(function(t){t&&(r.currentVal=r.lastVal=r.getPointerPosition(t),r.stop(),r.init())})),this.DS=s,this.Settings=s.stores.SettingsStore.s,this.DS.subscribe("Interaction:init",this.init),this.DS.subscribe("Interaction:start",(function(t){var e=t.event;return r.start(e)})),this.DS.subscribe("Interaction:end",(function(t){var e=t.event;return r.reset(e)}))}return s(t,[{key:"start",value:function(t){t&&(this._isMouseInteraction=!0,this.currentVal=this.initialVal=this.getPointerPosition(t))}},{key:"_normalizedEvent",value:function(t){return"touches"in t&&"touchend"!==t.type&&(this._lastTouch=t),"touches"in t?this._lastTouch.touches[0]:t}},{key:"initialValArea",get:function(){return this._initialValArea?this._initialValArea:{x:0,y:0}}},{key:"currentValArea",get:function(){return this._currentValArea?this._currentValArea:{x:0,y:0}}},{key:"lastValArea",get:function(){return this._lastValArea?this._lastValArea:{x:0,y:0}}},{key:"initialVal",get:function(){return this._initialVal?this._initialVal:{x:0,y:0}},set:function(t){this._initialVal=t,this._initialValArea=t&&_(t,"-",_(I(this.DS.Area.rect),"+",I(this.DS.Area.computedBorder)))}},{key:"currentVal",get:function(){return this._currentVal?this._currentVal:{x:0,y:0}},set:function(t){this._currentVal=t,this._currentValArea=t&&_(t,"-",_(I(this.DS.Area.rect),"+",I(this.DS.Area.computedBorder)))}},{key:"lastVal",get:function(){return this._lastVal?this._lastVal:{x:0,y:0}},set:function(t){this._lastVal=t,this._lastValArea=t&&_(t,"-",_(I(this.DS.Area.rect),"+",I(this.DS.Area.computedBorder)))}}]),t}(),nt=function(){function t(e){var r=this,s=e.DS;n(this,t),i(this,"_initialVal",void 0),i(this,"_currentVal",void 0),i(this,"_canScroll",void 0),i(this,"init",(function(){return r.DS.stores.SettingsStore.s.area.addEventListener("scroll",r.update)})),i(this,"start",(function(){r._currentVal=r._initialVal=T(r.DS.stores.SettingsStore.s.area),r.DS.stores.SettingsStore.s.area.addEventListener("scroll",r.update)})),i(this,"update",(function(){return r._currentVal=T(r.DS.stores.SettingsStore.s.area)})),i(this,"stop",(function(){r.DS.stores.SettingsStore.s.area.removeEventListener("scroll",r.update),r._initialVal={x:0,y:0},r._canScroll=null})),i(this,"reset",(function(){r.stop(),r.start()})),this.DS=s,this.DS.subscribe("Interaction:init",this.init),this.DS.subscribe("Interaction:start",(function(){return r.start()})),this.DS.subscribe("Interaction:end",(function(){return r.reset()}))}return s(t,[{key:"canScroll",get:function(){return"boolean"==typeof this._canScroll?this._canScroll:this._canScroll=(t=this.DS.stores.SettingsStore.s.area,!!((e=T(t)).x||e.y||(t instanceof Document?t.body?t.body.scrollTop=1:t.documentElement.scrollTop=1:t.scrollTop=1)));var t,e}},{key:"scrollAmount",get:function(){var t,e=_(this.currentVal,"-",this.initialVal),n={x:t=this.DS.stores.SettingsStore.s.zoom,y:t},r=_(_(e,"*",n),"-",e);return{x:e.x+r.x,y:e.y+r.y}}},{key:"initialVal",get:function(){return this._initialVal?this._initialVal:{x:0,y:0}}},{key:"currentVal",get:function(){return this._currentVal||(this._currentVal=T(this.DS.stores.SettingsStore.s.area)),this._currentVal}}]),t}(),rt=s((function t(r){var s=this,o=r.DS,a=r.settings;n(this,t),i(this,"_settings",{}),i(this,"s",{}),i(this,"update",(function(t){var n=t.settings,r=t.init;return s.DS.publish("Settings:updated:pre",e({settings:n},r?{init:r}:{}))})),i(this,"_update",(function(t){for(var n=function(t,n){return e(e(e(e(e(e(e(e(e(e(e(e(e(e(e(e(e(e(e(e(e(e(e(e(e(e(e(e(e(e(e(e(e(e(e({},R("area",t.area,n,document)),R("selectables",t.selectables,n,null)),R("autoScrollSpeed",t.autoScrollSpeed,n,5)),R("overflowTolerance",t.overflowTolerance,n,{x:25,y:25})),R("zoom",t.zoom,n,1)),R("customStyles",t.customStyles,n,!1)),R("multiSelectMode",t.multiSelectMode,n,!1)),R("multiSelectToggling",t.multiSelectToggling,n,!0)),R("multiSelectKeys",t.multiSelectKeys,n,["Control","Shift","Meta"])),R("selector",t.selector,n,null)),R("selectionThreshold",t.selectionThreshold,n,0)),R("draggability",t.draggability,n,!0)),R("immediateDrag",t.immediateDrag,n,!0)),R("keyboardDrag",t.keyboardDrag,n,!0)),R("dragKeys",t.dragKeys,n,{up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]})),R("keyboardDragSpeed",t.keyboardDragSpeed,n,10)),R("useTransform",t.useTransform,n,!0)),R("refreshMemoryRate",t.refreshMemoryRate,n,80)),R("dropZones",t.dropZones,n,[])),R("dropInsideThreshold",t.dropInsideThreshold,n,1)),R("dropTargetThreshold",t.dropTargetThreshold,n,0)),R("usePointerEvents",t.usePointerEvents,n,!1)),R("hoverClass",t.hoverClass,n,"ds-hover")),R("selectableClass",t.selectableClass,n,"ds-selectable")),R("selectedClass",t.selectedClass,n,"ds-selected")),R("selectorClass",t.selectorClass,n,"ds-selector")),R("selectorAreaClass",t.selectorAreaClass,n,"ds-selector-area")),R("droppedTargetClass",t.droppedTargetClass,n,"ds-dropped-target")),R("droppedInsideClass",t.droppedInsideClass,n,"ds-dropped-inside")),R("droppableClass",t.droppableClass,n,"ds-droppable")),R("dropZoneClass",t.dropZoneClass,n,"ds-dropzone")),R("dropZoneReadyClass",t.dropZoneReadyClass,n,"ds-dropzone-ready")),R("dropZoneTargetClass",t.dropZoneTargetClass,n,"ds-dropzone-target")),R("dropZoneInsideClass",t.dropZoneInsideClass,n,"ds-dropzone-inside")),R("dragAsBlock",t.dragAsBlock,n,!1))}(t.settings,t.init),r=function(){var t,e=v(a[o],2),n=e[0],r=e[1];n in s._settings||Object.defineProperty(s.s,n,{get:function(){return s._settings[n]},set:function(t){return s.update({settings:i({},n,t)})}}),s._settings["".concat(n,":pre")]=s._settings[n],s._settings[n]=r;var l={settings:(t={},i(t,n,s._settings[n]),i(t,"".concat(n,":pre"),s._settings["".concat(n,":pre")]),t)};s.DS.publish("Settings:updated",l),s.DS.publish("Settings:updated:".concat(n),l)},o=0,a=Object.entries(n);o<a.length;o++)r()})),this.DS=o,this.DS.subscribe("Settings:updated:pre",this._update),this.update({settings:a,init:!0})})),st=function(){function t(r){var s=this;n(this,t),i(this,"continue",!1),i(this,"start",(function(){s.stopped=!1,s.Interaction.init()})),i(this,"break",(function(){return s.continue=!0})),i(this,"setSettings",(function(t){return s.stores.SettingsStore.update({settings:t})})),i(this,"getSelection",(function(){return s.SelectedSet.elements})),i(this,"getSelectables",(function(){return s.SelectableSet.elements})),i(this,"getInitialCursorPosition",(function(){return s.stores.PointerStore.initialVal})),i(this,"getCurrentCursorPosition",(function(){return s.stores.PointerStore.currentVal})),i(this,"getPreviousCursorPosition",(function(){return s.stores.PointerStore.lastVal})),i(this,"getInitialCursorPositionArea",(function(){return s.stores.PointerStore.initialValArea})),i(this,"getCurrentCursorPositionArea",(function(){return s.stores.PointerStore.currentValArea})),i(this,"getPreviousCursorPositionArea",(function(){return s.stores.PointerStore.lastValArea})),i(this,"isMultiSelect",(function(t){return s.stores.KeyStore.isMultiSelectKeyPressed(t)})),i(this,"isDragging",(function(){return s.Interaction.isDragging})),i(this,"getZoneByCoordinates",(function(t){var e;return null===(e=s.DropZones.getTarget(t))||void 0===e?void 0:e.toObject()})),i(this,"getItemsDroppedByZoneId",(function(t){return s.DropZones.getItemsDroppedById(t)})),i(this,"getItemsInsideByZoneId",(function(t,e){return s.DropZones.getItemsInsideById(t,e)})),this.PubSub=new U({DS:this}),this.subscribe=this.PubSub.subscribe,this.unsubscribe=this.PubSub.unsubscribe,this.publish=this.PubSub.publish,this.stores={},this.stores.SettingsStore=new rt({DS:this,settings:r}),this.stores.PointerStore=new et({DS:this}),this.stores.ScrollStore=new nt({DS:this}),this.stores.KeyStore=new tt({DS:this}),this.Area=new H({DS:this}),this.Selector=new J({DS:this}),this.SelectorArea=new Q({DS:this}),this.SelectableSet=new X({DS:this}),this.SelectedSet=new q({DS:this}),this.Selection=new $({DS:this}),this.Drag=new F({DS:this}),this.DropZones=new W({DS:this}),this.Interaction=new G({DS:this}),function(t){for(var n=t.subscribe,r=t.publish,s=t.Interaction,i=t.SelectedSet,o=t.DropZones,a={"Selected:added":[{name:"elementselect"}],"Selected:removed":[{name:"elementunselect"}],"Area:scroll":[{name:"autoscroll"}],"Interaction:start":[{name:"dragstart"}],"Interaction:update":[{name:"dragmove",condition:function(t){return t.event}}],"Interaction:end":[{name:"callback",extraData:function(){var t=o.getTarget();return e({},t?{dropTarget:t.toObject()}:{})}}]},l=function(){var t=v(u[c],2),o=t[0],a=t[1];["pre",!1].forEach((function(t){return n(t?"".concat(o,":").concat(t):o,(function(n){return a.forEach((function(o){return(!o.condition||o.condition(n))&&r(t?"".concat(t).concat(o.name):o.name,e(e({items:i.elements,isDragging:s.isDragging},n),o.extraData?o.extraData(n):{}))}))}))}))},c=0,u=Object.entries(a);c<u.length;c++)l()}({subscribe:this.subscribe,publish:this.publish,SelectedSet:this.SelectedSet,Interaction:this.Interaction,DropZones:this.DropZones}),this.subscribe("Interaction:end",(function(){return s.continue=!1})),this.start()}return s(t,[{key:"stop",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];n&&this.publish("callback",{items:this.getSelection()}),this.Interaction.stop(),this.Area.stop(),this.Drag.stop(),this.Selector.stop(),this.SelectorArea.stop(t),this.stores.KeyStore.stop(),this.stores.PointerStore.stop(),this.stores.ScrollStore.stop(),t&&this.SelectableSet.clear(),e&&this.SelectedSet.clear(),this.stopped=!0}},{key:"addSelection",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.addAll(z(t)),n||this.addSelectables(t),e&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"removeSelection",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.deleteAll(z(t)),n&&this.removeSelectables(t),e&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"toggleSelection",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return z(t).forEach((function(s){return e.SelectedSet.has(s)?e.removeSelection(t,n,r):e.addSelection(t,n,r)})),n&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"setSelection",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.clearSelection(),this.addSelection(t,e,n),this.getSelection()}},{key:"clearSelection",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.SelectedSet.clear(),t&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"addSelectables",value:function(t,e,n){var r=z(t);return this.SelectableSet.addAll(r),e&&this.SelectedSet.addAll(r),n&&this.PubSub.publish("callback",{items:this.getSelection()}),t}},{key:"setSelectables",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return console.warn('[DragSelect] DEPRECATION ".setSelectables" is deprecated and will be removed soon. Please use "ds.setSettings({ selectables: << new dom elements >> })" instead (see docs)'),this.removeSelectables(t,e),this.addSelectables(t,n)}},{key:"removeSelectables",value:function(t,e,n){return this.SelectableSet.deleteAll(z(t)),e&&this.removeSelection(t),n&&this.PubSub.publish("callback",{items:this.getSelection()}),t}}]),t}();st.isCollision=O;export{st as default};
|
package/dist/ds.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=(e,t)=>{const s=t;window.addEventListener("resize",s),window.addEventListener("scroll",s);const i=new MutationObserver(s),r=new ResizeObserver(s);e.forEach(((e,t)=>{i.observe(e,{childList:0!==t,attributes:!0}),e instanceof Element&&r.observe(e)}));return{observer:i,resizeObserver:r,callback:s,cleanup:()=>{window.removeEventListener("resize",s),window.removeEventListener("scroll",s),i.disconnect(),r.disconnect()}}},t=(e,t)=>{let s;return(...i)=>{clearTimeout(s),s=setTimeout((()=>{s=void 0,e(...i)}),t)}},s=e=>{const t=(e,s=0)=>{const i=e[s]?.parentNode;return i?(e.push(i),s++,t(e,s)):e};return t([e])},i=({computedStyle:e,node:t})=>{const{position:s}=e;t instanceof Document||("absolute"===s||"relative"===s||"fixed"===s)||(t.style.position="relative")};let r;class n{DS;PS;Settings;_observers;_node;_parentNodes;_computedStyle;_computedBorder;_rect;constructor({DS:e,PS:t}){this.DS=e,this.PS=t,this.Settings=this.DS.stores.SettingsStore.s,this._node=this.Settings.area,this.setArea(this.Settings.area),this.PS.subscribe("Settings:updated:area",(({settings:{area:e}})=>this.setArea(e))),this.PS.subscribe("Interaction:init",this.init),this.PS.subscribe("Interaction:end",this.reset)}setArea=e=>{this.reset(),this._node=e,i({computedStyle:this.computedStyle,node:this._node}),setTimeout((()=>{this.PS.publish("Area:modified:pre",{item:this.HTMLNode}),this.reset(),this.PS.publish("Area:modified",{item:this.HTMLNode})}))};init=()=>{this._observers=e(this.parentNodes,t((e=>{this.PS.publish("Area:modified:pre",{event:e,item:this.HTMLNode}),this.reset(),this.PS.publish("Area:modified",{event:e,item:this.HTMLNode})}),60))};reset=()=>{this._computedStyle=void 0,this._rect=void 0,this._computedBorder=void 0,this._parentNodes=void 0};stop=()=>{this._observers?.cleanup(),this.reset()};scroll=(e,t)=>{const s={scroll_directions:e,scroll_multiplier:t};this.PS.publish("Area:scroll:pre",s),((e,t,s=1)=>{if(!t?.length||!e)return;let i=e;if(e instanceof Document&&(r&&(i=r),Number.isFinite(document?.documentElement?.scrollTop))){const e=document.documentElement.scrollTop;document.documentElement.scrollTop+=1,document.documentElement.scrollTop===e?(i=document.body,r=document.body):(document.documentElement.scrollTop=e,i=document.documentElement,r=document.documentElement)}const n=t.includes("top")&&i.scrollTop>0,o=t.includes("bottom")&&i.scrollTop<i.scrollHeight,l=t.includes("left")&&i.scrollLeft>0,a=t.includes("right")&&i.scrollLeft<i.scrollWidth;n&&(i.scrollTop-=1*s),o&&(i.scrollTop+=1*s),l&&(i.scrollLeft-=1*s),a&&(i.scrollLeft+=1*s)})(this._node,e,t),this.PS.publish("Area:scroll",s)};get HTMLNode(){return this._node}get computedBorder(){return this._computedBorder?this._computedBorder:{top:parseInt(this.computedStyle.borderTopWidth),bottom:parseInt(this.computedStyle.borderBottomWidth),left:parseInt(this.computedStyle.borderLeftWidth),right:parseInt(this.computedStyle.borderRightWidth)}}get computedStyle(){return this._computedStyle?this._computedStyle:this.HTMLNode instanceof Document?this._computedStyle=window.getComputedStyle(this.HTMLNode.body||this.HTMLNode.documentElement):this._computedStyle=window.getComputedStyle(this.HTMLNode)}get rect(){return this._rect?this._rect:this._rect=((e,t)=>{if(e instanceof Document)return{top:0,left:0,bottom:0,right:0,width:window.innerWidth,height:window.innerHeight};const s=e.getBoundingClientRect();return{top:s.top,left:s.left,bottom:s.bottom,right:s.right,width:(e.clientWidth||s.width)*t,height:(e.clientHeight||s.height)*t}})(this.HTMLNode,this.DS.stores.SettingsStore.s.zoom)}get parentNodes(){return this._parentNodes?this._parentNodes:this._parentNodes=s(this.HTMLNode)}}const o=({x:e,y:t},s,{x:i,y:r})=>({"+":{x:e+i,y:t+r},"-":{x:e-i,y:t-r},"*":{x:e*i,y:t*r},"/":{x:e/i,y:t/r}}[s]),l=e=>({x:e.left,y:e.top}),a=(e,t=0)=>({left:e.x,top:e.y,right:e.x,bottom:e.y,width:t,height:t}),h=e=>({x:e,y:e}),c=e=>{const t={x:0,y:0},s=window.getComputedStyle(e);if(!s.transform||"none"===s.transform)return t;if(s.transform.indexOf("3d")>=0){const e=s.transform.trim().match(/matrix3d\((.*?)\)/);if(e&&e.length){const s=e[1]?.split(",");t.x=parseInt(s[12])||0,t.y=parseInt(s[13])||0}return t}const i=s.transform.trim().match(/matrix\((.*?)\)/);if(i&&i.length){const e=i[1]?.split(",");t.x=parseInt(e[4])||0,t.y=parseInt(e[5])||0}return t},d=(e,t)=>t?(e=>{const{transform:t}=e.style;if(!t||t.indexOf("translate")<0)return c(e);const s={x:0,y:0},i=t.trim().match(/translate[3dD]*?\(.*?\)/);if(i){const e=i[0]?.split("(");if(e){const t=e[1]?.split(",");s.x=parseInt(t[0])||0,s.y=parseInt(t[1])||0}}return s.x||s.x?s:c(e)})(e):(e=>{const{style:t}=e,s={x:parseInt(t.left)||0,y:parseInt(t.top)||0};if(!s.x&&!s.x){const t=window.getComputedStyle(e);return{x:parseInt(t.left)||0,y:parseInt(t.top)||0}}return s})(e),S=({containerRect:e,selectionRect:t,direction:s,scrollAmount:i})=>{const r={top:e.top-t.top+i.y,left:e.left-t.left+i.x,bottom:e.bottom-t.bottom+i.y,right:e.right-t.right+i.x};return 0===s.x&&0===s.y||(s.y<0&&(s.y=Math.max(s.y,r.top)),s.x<0&&(s.x=Math.max(s.x,r.left)),s.y>0&&(s.y=Math.min(s.y,r.bottom)),s.x>0&&(s.x=Math.min(s.x,r.right)),t.top+=s.y,t.bottom+=s.y,t.left+=s.x,t.right+=s.x),s};class u{_prevCursorPos;_prevScrollPos;_elements=[];_dragKeys;_dragKeysFlat=[];_selectionRect=a(h(0));DS;PS;Settings;constructor({DS:e,PS:t}){this.DS=e,this.PS=t,this.Settings=this.DS.stores.SettingsStore.s,this.PS.subscribe("Settings:updated:dragKeys",this.assignDragKeys),this.assignDragKeys(),this.PS.subscribe("Interaction:start",this.start),this.PS.subscribe("Interaction:end",this.stop),this.PS.subscribe("Interaction:update",this.update),this.PS.subscribe("KeyStore:down",this.keyboardDrag),this.PS.subscribe("KeyStore:up",this.keyboardEnd)}assignDragKeys=()=>{this._dragKeys={up:this.Settings.dragKeys.up.map((e=>e.toLowerCase())),down:this.Settings.dragKeys.down.map((e=>e.toLowerCase())),left:this.Settings.dragKeys.left.map((e=>e.toLowerCase())),right:this.Settings.dragKeys.right.map((e=>e.toLowerCase()))},this._dragKeysFlat=[...this._dragKeys.up,...this._dragKeys.down,...this._dragKeys.left,...this._dragKeys.right]};keyboardDrag=({event:e,key:t})=>{const s=t.toLowerCase();if(!this.Settings.keyboardDrag||!this._dragKeysFlat.includes(s)||!this.DS.SelectedSet.size||!this.Settings.draggability||this.DS.continue)return;const i={event:e,isDragging:!0,isDraggingKeyboard:!0,key:t};this.PS.publish(["Interaction:start:pre","Interaction:start"],i),this._elements=this.DS.getSelection(),this._selectionRect=this.DS.Selection.boundingRect,this.handleZIndex(!0);let r=(({shiftKey:e,keyboardDragSpeed:t,zoom:s,key:i,dragKeys:r,scrollDiff:n})=>{const o={x:0,y:0},l=e?4*t*s:t*s;return r?.left.includes(i)&&(o.x=n.x||-l),r?.right.includes(i)&&(o.x=n.x||l),r?.up.includes(i)&&(o.y=n.y||-l),r?.down.includes(i)&&(o.y=n.y||l),o})({shiftKey:this.DS.stores.KeyStore.currentValues.includes("shift"),keyboardDragSpeed:this.Settings.keyboardDragSpeed,zoom:this.Settings.zoom,key:s,scrollDiff:this._scrollDiff,dragKeys:this._dragKeys});r=S({direction:r,containerRect:this.DS.SelectorArea.rect,scrollAmount:this.DS.stores.ScrollStore.scrollAmount,selectionRect:this._selectionRect}),this.moveElements(r),this.PS.publish(["Interaction:update:pre","Interaction:update"],i)};keyboardEnd=({event:e,key:t})=>{const s=t.toLowerCase();if(!(this.Settings.keyboardDrag&&this._dragKeysFlat.includes(s)&&this.DS.SelectedSet.size&&this.Settings.draggability))return;const i={event:e,isDragging:this.Settings.draggability,isDraggingKeyboard:!0,key:t};this.PS.publish(["Interaction:end:pre","Interaction:end"],i)};start=({isDragging:e,isDraggingKeyboard:t})=>{e&&!t&&(this._prevCursorPos=void 0,this._prevScrollPos=void 0,this._elements=this.DS.getSelection(),this._selectionRect=this.DS.Selection.boundingRect,this.handleZIndex(!0))};stop=()=>{this._prevCursorPos=void 0,this._prevScrollPos=void 0,this.handleZIndex(!1),this._elements=[]};update=({isDragging:e,isDraggingKeyboard:t})=>{if(!e||!this._elements.length||t||this.DS.continue)return;let s=o(this._cursorDiff,"+",this._scrollDiff);s=S({direction:s,containerRect:this.DS.SelectorArea.rect,scrollAmount:this.DS.stores.ScrollStore.scrollAmount,selectionRect:this._selectionRect}),this.moveElements(s)};handleZIndex=e=>{this.Settings.useLayers&&this._elements.forEach((t=>t.style.zIndex=`${(parseInt(t.style.zIndex)||0)+(e?9999:-9998)}`))};moveElements=e=>{const{elements:t,direction:s}=this.filterDragElements({elements:this._elements,direction:e});t.forEach((e=>{(({element:e,posDirection:t,useTransform:s})=>{const i=d(e,s);((e,t,s)=>{if(s){const s=e.style.transform;e.style.transform=`translate3d(${t.x}px,${t.y}px,1px) ${s.replace(/translate.*?\)/g,"")}`}else e.style.left=`${t.x}px`,e.style.top=`${t.y}px`})(e,o(i,"+",t),s)})({element:e,posDirection:s,containerRect:this.DS.SelectorArea.rect,useTransform:this.Settings.useTransform})}))};get _cursorDiff(){const e=this.DS.stores.PointerStore.currentVal,t=this._prevCursorPos?o(e,"-",this._prevCursorPos):{x:0,y:0};return this._prevCursorPos=e,t}get _scrollDiff(){const e=this.DS.stores.ScrollStore.currentVal,t=this._prevScrollPos?o(e,"-",this._prevScrollPos):{x:0,y:0};return this._prevScrollPos=e,t}filterDragElements=({elements:e,direction:t})=>({elements:e,direction:t})}const p=(e,t,s=0)=>{if(!e||!t)return!1;let i=e;if(s>0){const t=(e.right-e.left)*s,r=(e.bottom-e.top)*s;i={left:e.left+t,right:e.right-t,top:e.top+r,bottom:e.bottom-r}}return i.left<t.right&&i.right>t.left&&i.top<t.bottom&&i.bottom>t.top},g=e=>e?Array.isArray(e)||"function"==typeof e[Symbol.iterator]?[...new Set([...e])]:[e]:[];class m{id;element;_droppables;_rect;_observers;_timeout;_itemsDropped=[];_itemsInside;DS;PS;Settings;isDestroyed=!1;_parentNodes;constructor({DS:s,PS:i,id:r,element:n,droppables:o}){this.DS=s,this.PS=i,this.Settings=this.DS.stores.SettingsStore.s,this.id=r,this.element=n,o&&(this.droppables=g(o)),this.element.classList.add(`${this.Settings.dropZoneClass}`),this.PS.subscribe("Settings:updated:dropZoneClass",(({settings:e})=>{this.element&&(this.element.classList.remove(e["dropZoneClass:pre"]),this.element.classList.add(e.dropZoneClass))})),this._observers=e(this.parentNodes,t((()=>this._rect=void 0),this.Settings.refreshMemoryRate)),this.PS.subscribe("Interaction:start",this.start),this.PS.subscribe("Interaction:end",this.stop)}setReadyClasses=e=>{if(this.isDestroyed)return;const t=this.droppables.filter((e=>this.DS.SelectedSet.has(e)));t.length&&(t.forEach((t=>{t.classList[e](`${this.Settings.droppableClass}`),t.classList[e](`${this.Settings.droppableClass}-${this.id}`)})),this.element.classList[e](`${this.Settings.dropZoneReadyClass}`))};handleNoDrop=()=>{this.isDestroyed||(this.DS.SelectedSet.forEach((e=>{e.classList.remove(this.Settings.droppedTargetClass),e.classList.remove(`${this.Settings.droppedTargetClass}-${this.id}`)})),this._itemsDropped=this._itemsDropped.filter((e=>!this.DS.SelectedSet.has(e))),this._itemsDropped?.length||this.element.classList.remove(`${this.Settings.dropZoneTargetClass}`))};handleDrop=()=>{this.isDestroyed||(this._itemsDropped=[...new Set([...this._itemsDropped,...this.droppables?.filter((e=>this.DS.SelectedSet.has(e)))])],this._itemsDropped?.forEach((e=>{e.classList.add(`${this.Settings.droppedTargetClass}`),e.classList.add(`${this.Settings.droppedTargetClass}-${this.id}`)})),this._itemsDropped?.length&&this.element.classList.add(`${this.Settings.dropZoneTargetClass}`))};handleItemsInsideClasses=()=>{let e=!1;this.droppables.forEach((t=>{this.itemsInside?.includes(t)?(t.classList.add(`${this.Settings.droppedInsideClass}`),t.classList.add(`${this.Settings.droppedInsideClass}-${this.id}`),e=!0):(t.classList.remove(`${this.Settings.droppedInsideClass}-${this.id}`),t.className.includes(`${this.Settings.droppedInsideClass}-`)||t.classList.remove(`${this.Settings.droppedInsideClass}`))})),e?this.element.classList.add(`${this.Settings.dropZoneInsideClass}`):this.element.classList.remove(`${this.Settings.dropZoneInsideClass}`)};start=({isDragging:e})=>{e&&!this.isDestroyed&&this.setReadyClasses("add")};stop=({isDragging:e})=>{e&&!this.isDestroyed&&(this.setReadyClasses("remove"),this.handleItemsInsideClasses())};destroy(){this._observers?.cleanup(),this.element.classList.remove(`${this.Settings.dropZoneClass}`),this.element.classList.remove(`${this.Settings.dropZoneTargetClass}`),this.element.classList.remove(`${this.Settings.dropZoneReadyClass}`),this.droppables.forEach((e=>{e.classList.remove(`${this.Settings.droppedTargetClass}`),e.classList.remove(`${this.Settings.droppedTargetClass}-${this.id}`),e.classList.remove(`${this.Settings.droppableClass}`),e.classList.remove(`${this.Settings.droppableClass}-${this.id}`)})),this.PS.unsubscribe("Interaction:start",this.start),this.PS.unsubscribe("Interaction:end",this.stop),this.isDestroyed=!0}toObject=()=>({id:this.id,element:this.element,droppables:this.droppables,itemsDropped:this.itemsDropped,itemsInside:this.itemsInside});get rect(){if(!this.isDestroyed)return this._rect?this._rect:this._rect=this.element.getBoundingClientRect()}get itemsDropped(){if(!this.isDestroyed)return this._itemsDropped}get itemsInside(){if(!this.isDestroyed)return this._itemsInside||(this._itemsInside=this.droppables.flatMap((e=>{const t=this.DS.SelectableSet.rects.get(e);return this.rect&&p(t,this.rect,this.Settings.dropInsideThreshold)?[e]:[]})),this._timeout&&clearTimeout(this._timeout),this._timeout=setTimeout((()=>this._itemsInside=void 0),this.Settings.refreshMemoryRate)),this._itemsInside}get parentNodes(){return this._parentNodes?this._parentNodes:this._parentNodes=s(this.element)}get droppables(){return this._droppables?this._droppables:this.DS.SelectableSet.elements}set droppables(e){this._droppables=e}}class b{_zoneByElement=new Map;_zoneById=new Map;_zonesByDroppable=new Map;_zones;DS;PS;Settings;constructor({DS:e,PS:t}){this.DS=e,this.PS=t,this.Settings=this.DS.stores.SettingsStore.s,this.PS.subscribe("Settings:updated:dropZones",(({settings:e})=>this.setDropZones(e))),this.setDropZones({dropZones:this.Settings.dropZones}),this.PS.subscribe("Interaction:end",this.stop)}setDropZones=({dropZones:e})=>{e&&(this._zones&&this._zones.forEach((e=>e.destroy())),this._zones=e.map((e=>new m({DS:this.DS,PS:this.PS,...e}))),this._zones.forEach((e=>{this._zoneByElement.set(e.element,e),this._zoneById.set(e.id,e),e.droppables.forEach((t=>{const s=this._zonesByDroppable.get(t);if(!s?.length)return this._zonesByDroppable.set(t,[e]);this._zonesByDroppable.set(t,[...new Set([...s,e])])}))})))};_handleDrops=e=>{this._zones?.forEach((t=>{t!==e&&t.handleNoDrop()})),e&&e.handleDrop()};_getZoneByElementsFromPoint=(e,{x:t,y:s})=>{for(let i=0,r=e.length;i<r;i++){const r=this._zoneByElement.get(e[i]);if(p(r?.rect,{left:t,right:t,top:s,bottom:s},Math.min(this.Settings.dropTargetThreshold,.5)))return r}};stop=({isDragging:e,isDraggingKeyboard:t,event:s})=>{if(!e)return;const i=this.getTarget({isDraggingKeyboard:t,event:s});this._handleDrops(i)};getItemsDroppedById=e=>{const t=this._zoneById.get(e);return t?t.itemsDropped:console.warn(`[DragSelect] No zone found (id: ${e})`)};getItemsInsideById=(e,t)=>{const s=this._zoneById.get(e);return s?(t&&s.handleItemsInsideClasses(),s.itemsInside):console.warn(`[DragSelect] No zone found (id: ${e})`)};getKeyboardItemCenter=(e,t)=>{if(!e||!t)return;const s=t.target?.getBoundingClientRect();return{x:s.left+s.width/2,y:s.top+s.height/2}};getTarget=({coordinates:e,isDraggingKeyboard:t,event:s})=>{if(!this._zones?.length)return;let i;!e&&t&&s&&(i=this.getKeyboardItemCenter(t,s));const r=e?.x||i?.x||this.DS.stores.PointerStore.currentVal.x,n=e?.y||i?.y||this.DS.stores.PointerStore.currentVal.y,o=document.elementsFromPoint(r,n);return this._getZoneByElementsFromPoint(o,{x:r,y:n})}}class y{isInteracting;isDragging=!1;DS;PS;Settings;constructor({DS:e,PS:t}){this.DS=e,this.PS=t,this.Settings=this.DS.stores.SettingsStore.s,this.PS.subscribe("Settings:updated:area",(({settings:e})=>{this.removeAreaEventListeners(e["area:pre"]),this.setAreaEventListeners(e.area)})),this.PS.subscribe("PointerStore:updated",(({event:e})=>this.update({event:e}))),this.PS.subscribe("Selectable:click",this.onClick),this.PS.subscribe("Selectable:pointer",(({event:e})=>this.start(e))),this.PS.subscribe("Interaction:start:pre",(({event:e})=>this._start(e))),this.PS.subscribe("Interaction:init:pre",this._init),this.PS.subscribe("Interaction:end:pre",(({event:e})=>this._reset(e))),this.PS.subscribe("Area:scroll",this.update)}init=()=>this.PS.publish("Interaction:init:pre",{init:!0});_init=()=>{this.stop(),this.setAreaEventListeners(),this.PS.publish("Interaction:init",{init:!0})};_canInteract(e){const t="clientX"in e&&0===e.clientX&&0===e.clientY&&0===e.detail&&e.target;return!("button"in e&&2===e.button||this.isInteracting||e.target&&!this.DS.SelectorArea.isInside(e.target)||!t&&!this.DS.SelectorArea.isClicked(e))}start=e=>this.PS.publish("Interaction:start:pre",{event:e,isDragging:this.isDragging});_start=e=>{"touchstart"===e.type&&e.preventDefault(),this._canInteract(e)&&(this.isInteracting=!0,this.isDragging=this.isDragEvent(e),this.PS.publish("Interaction:start",{event:e,isDragging:this.isDragging}),this.setDocEventListeners())};isDragEvent=e=>{let t=null;return e.target&&"closest"in e.target&&(t=e.target.closest(`.${this.Settings.selectableClass}`)),!(!this.Settings.draggability||this.DS.stores.KeyStore.isMultiSelectKeyPressed(e)||!t)&&(this.Settings.immediateDrag&&(this.DS.SelectedSet.size?this.DS.SelectedSet.has(t)||(this.DS.SelectedSet.clear(),this.DS.SelectedSet.add(t)):this.DS.SelectedSet.add(t)),!!this.DS.SelectedSet.has(t))};onClick=({event:e})=>{if(!this._canInteract(e))return;if(e.detail>0)return;const{stores:{PointerStore:t,KeyStore:s},SelectableSet:i,SelectedSet:r}=this.DS;t.start(e);const n=e.target;n&&!i.has(n)||(s.isMultiSelectKeyPressed(e)||r.clear(),n&&r.toggle(n),this.reset(e))};stop=(e=this.DS.Area.HTMLNode)=>{this.removeAreaEventListeners(e),this.removeDocEventListeners()};update=({event:e,scroll_directions:t,scroll_multiplier:s})=>{this.isInteracting&&this.PS.publish(["Interaction:update:pre","Interaction:update"],{event:e,scroll_directions:t,scroll_multiplier:s,isDragging:this.isDragging})};reset=e=>this.PS.publish("Interaction:end:pre",{event:e,isDragging:this.isDragging});_reset=e=>{const{isDragging:t}=this;this.isInteracting=!1,this.isDragging=!1,this.removeDocEventListeners(),this.PS.publish("Interaction:end",{event:e,isDragging:t})};setAreaEventListeners=(e=this.DS.Area.HTMLNode)=>{this.Settings.usePointerEvents?e.addEventListener("pointerdown",this.start,{passive:!1}):e.addEventListener("mousedown",this.start),e.addEventListener("touchstart",this.start,{passive:!1})};removeAreaEventListeners=(e=this.DS.Area.HTMLNode)=>{this.Settings.usePointerEvents?e.removeEventListener("pointerdown",this.start,{passive:!1}):e.removeEventListener("mousedown",this.start),e.removeEventListener("touchstart",this.start,{passive:!1})};setDocEventListeners=()=>{this.Settings.usePointerEvents?(document.addEventListener("pointerup",this.reset),document.addEventListener("pointercancel",this.reset)):document.addEventListener("mouseup",this.reset),document.addEventListener("touchend",this.reset)};removeDocEventListeners=()=>{this.Settings.usePointerEvents?(document.removeEventListener("pointerup",this.reset),document.removeEventListener("pointercancel",this.reset)):document.removeEventListener("mouseup",this.reset),document.removeEventListener("touchend",this.reset)}}class D{_currentValues=new Set;_keyMapping={control:"ctrlKey",shift:"shiftKey",meta:"metaKey"};DS;PS;settings;constructor({DS:e,PS:t}){this.DS=e,this.PS=t,this.settings=this.DS.stores.SettingsStore.s,this.PS.subscribe("Interaction:init",this.init)}init=()=>{document.addEventListener("keydown",this.keydown),document.addEventListener("keyup",this.keyup),window.addEventListener("blur",this.reset)};keydown=e=>{if(!e.key?.toLocaleLowerCase)return;const t=e.key.toLowerCase();this.PS.publish("KeyStore:down:pre",{event:e,key:t}),this._currentValues.add(t),this.PS.publish("KeyStore:down",{event:e,key:t})};keyup=e=>{if(!e.key?.toLocaleLowerCase)return;const t=e.key.toLowerCase();this.PS.publish("KeyStore:up:pre",{event:e,key:t}),this._currentValues.delete(t),this.PS.publish("KeyStore:up",{event:e,key:t})};stop=()=>{document.removeEventListener("keydown",this.keydown),document.removeEventListener("keyup",this.reset),window.removeEventListener("blur",this.reset),this.reset()};reset=()=>this._currentValues.clear();isMultiSelectKeyPressed(e){if(this.settings.multiSelectMode)return!0;const t=this.settings.multiSelectKeys?.map((e=>e.toLocaleLowerCase()))??[];return!!this.currentValues.some((e=>t.includes(e)))||!(!e||!t.some((t=>e[this._keyMapping[t]])))}get currentValues(){return Array.from(this._currentValues.values())}}class _{_isMouseInteraction=!1;_initialValArea={x:0,y:0};_currentValArea={x:0,y:0};_lastValArea={x:0,y:0};_initialVal={x:0,y:0};_currentVal={x:0,y:0};_lastVal={x:0,y:0};_lastTouch;DS;PS;settings;constructor({DS:e,PS:t}){this.DS=e,this.PS=t,this.settings=this.DS.stores.SettingsStore.s,this.PS.subscribe("Interaction:init",this.init),this.PS.subscribe("Interaction:start",(({event:e})=>this.start(e))),this.PS.subscribe("Interaction:end",(({event:e})=>this.reset(e)))}init=()=>{this.settings.usePointerEvents?document.addEventListener("pointermove",this.update,{passive:!1}):document.addEventListener("mousemove",this.update),document.addEventListener("touchmove",this.update,{passive:!1})};start(e){e&&(this._isMouseInteraction=!0,this.currentVal=this.initialVal=this.getPointerPosition(e))}getPointerPosition=e=>(({event:e})=>({x:e.clientX,y:e.clientY}))({event:this._normalizedEvent(e)});update=e=>{e&&(this.PS.publish("PointerStore:updated:pre",{event:e}),this.currentVal=this.getPointerPosition(e),this._isMouseInteraction&&this.PS.publish("PointerStore:updated",{event:e}))};stop=()=>{this.settings.usePointerEvents?document.removeEventListener("pointermove",this.update,{passive:!1}):document.removeEventListener("mousemove",this.update),document.removeEventListener("touchmove",this.update,{passive:!1}),this.reset()};reset=e=>{this.currentVal=this.lastVal=this.getPointerPosition(e),setTimeout((()=>this._isMouseInteraction=!1),100)};_normalizedEvent(e){return!e||e instanceof KeyboardEvent?{clientX:0,clientY:0}:"touches"in e?("touchend"!==e.type&&(this._lastTouch=e),this._lastTouch?.touches[0]||e.touches[0]):e}get initialValArea(){return this._initialValArea?this._initialValArea:{x:0,y:0}}get currentValArea(){return this._currentValArea?this._currentValArea:{x:0,y:0}}get lastValArea(){return this._lastValArea?this._lastValArea:{x:0,y:0}}get initialVal(){return this._initialVal?this._initialVal:{x:0,y:0}}get currentVal(){return this._currentVal?this._currentVal:{x:0,y:0}}get lastVal(){return this._lastVal?this._lastVal:{x:0,y:0}}set initialVal(e){this._initialVal=e,this._initialValArea=e&&o(e,"-",o(l(this.DS.Area.rect),"+",l(this.DS.Area.computedBorder)))}set currentVal(e){this._currentVal=e,this._currentValArea=e&&o(e,"-",o(l(this.DS.Area.rect),"+",l(this.DS.Area.computedBorder)))}set lastVal(e){this._lastVal=e,this._lastValArea=e&&o(e,"-",o(l(this.DS.Area.rect),"+",l(this.DS.Area.computedBorder)))}}class v{subscribers={};DS;constructor({DS:e}){this.DS=e}subscribe=(e,t)=>{Array.isArray(this.subscribers[e])||(this.subscribers[e]=[]);const s=this.subscribers[e];return s.push(t),s.length-1};unsubscribe=(e,t,s)=>{const i=s??this.subscribers[e]?.findIndex((e=>e===t));this.subscribers[e]?.splice(Number(i),1)};publish=(e,t)=>{Array.isArray(e)?e.forEach((e=>this._publish(e,t))):this._publish(e,t)};_publish=(e,t)=>{const s=this.subscribers[e]??[];e.includes(":pre")?this._handlePrePublish(s,t):this._handlePublish(s,t)};_handlePublish=(e,t)=>{for(let s=0,i=e.length;s<i;s++){if(this.DS.stopped)return;e[s]?.(t)}};_handlePrePublish=(e,t)=>{let s=e.length;for(;s--;){if(this.DS.stopped)return;e[s]?.(t)}}}const P=()=>({y:document.body?.scrollTop||document.documentElement?.scrollTop||0,x:document.body?.scrollLeft||document.documentElement?.scrollLeft||0}),f=e=>!e||e instanceof Document?P():{x:e.scrollLeft>=0?e.scrollLeft:P().x,y:e.scrollTop>=0?e.scrollTop:P().y},I=e=>{const t=e.scrollTop,s=Boolean(e.scrollTop=1);return e.scrollTop=t,s};class L{_initialVal={x:0,y:0};_currentVal={x:0,y:0};_canScroll;DS;PS;Settings;constructor({DS:e,PS:t}){this.DS=e,this.PS=t,this.Settings=this.DS.stores.SettingsStore.s,this.PS.subscribe("Area:modified",(()=>{this.stop(),this.init()})),this.PS.subscribe("Interaction:init",this.init),this.PS.subscribe("Interaction:start",(()=>this.start())),this.PS.subscribe("Interaction:end",(()=>this.reset()))}init=()=>this.addListeners();addListeners=()=>this.DS.Area.HTMLNode.addEventListener("scroll",this.update);removeListeners=()=>this.DS.Area.HTMLNode.removeEventListener("scroll",this.update);start=()=>{this._currentVal=this._initialVal=f(this.DS.Area.HTMLNode)};update=()=>this._currentVal=f(this.DS.Area.HTMLNode);stop=()=>{this.reset(),this.removeListeners()};reset=()=>{this._initialVal={x:0,y:0},this._canScroll=void 0};get canScroll(){return"boolean"==typeof this._canScroll?this._canScroll:this._canScroll=(e=>{const t=f(e);return!(!t.x&&!t.y)||(e instanceof Document?e.body?I(e.body):I(e.documentElement):I(e))})(this.DS.Area.HTMLNode)}get scrollAmount(){const e=o(this.currentVal,"-",this.initialVal),t=h(this.Settings.zoom),s=o(o(e,"*",t),"-",e);return{x:e.x+s.x,y:e.y+s.y}}get initialVal(){return this._initialVal?this._initialVal:{x:0,y:0}}get currentVal(){return this._currentVal||(this._currentVal=f(this.DS.Area.HTMLNode)),this._currentVal}}class E extends Set{_rects;_timeout;DS;PS;Settings;constructor({DS:e,PS:t}){super(),this.DS=e,this.PS=t,this.Settings=this.DS.stores.SettingsStore.s,this.PS.subscribe("Interaction:init",this.init),this.PS.subscribe("Settings:updated:selectables",(()=>{this.clear(),this.init()})),this.PS.subscribe("Settings:updated:selectableClass",(({settings:e})=>{this.forEach((t=>{t.classList.remove(e["selectableClass:pre"]),t.classList.add(e.selectableClass)}))}))}init=()=>g(this.Settings.selectables).forEach((e=>this.add(e)));add(e){if(!e||super.has(e))return this;const t={items:this.elements,item:e};return this.PS.publish("Selectable:added:pre",t),e.classList.add(this.Settings.selectableClass),e.addEventListener("click",this._onClick),this.Settings.usePointerEvents?e.addEventListener("pointerdown",this._onPointer,{passive:!1}):e.addEventListener("mousedown",this._onPointer),e.addEventListener("touchstart",this._onPointer,{passive:!1}),this.Settings.draggability&&!this.Settings.useTransform&&i({computedStyle:window.getComputedStyle(e),node:e}),this.PS.publish("Selectable:added",t),super.add(e)}delete(e){if(!e||!super.has(e))return!0;const t={items:this.elements,item:e};return this.PS.publish("Selectable:removed:pre",t),e.classList.remove(this.Settings.selectableClass),e.classList.remove(this.Settings.hoverClass),e.removeEventListener("click",this._onClick),this.Settings.usePointerEvents?e.removeEventListener("pointerdown",this._onPointer,{passive:!1}):e.removeEventListener("mousedown",this._onPointer),e.removeEventListener("touchstart",this._onPointer,{passive:!1}),this.PS.publish("Selectable:removed",t),super.delete(e)}clear=()=>this.forEach((e=>this.delete(e)));_onClick=e=>this.PS.publish(["Selectable:click:pre","Selectable:click"],{event:e});_onPointer=e=>this.PS.publish(["Selectable:pointer:pre","Selectable:pointer"],{event:e});addAll=e=>e.forEach((e=>this.add(e)));deleteAll=e=>e.forEach((e=>this.delete(e)));getElementRect=e=>this._rects?this._rects.get(e):e.getBoundingClientRect();get elements(){return Array.from(this.values())}get rects(){return this._rects||(this._rects=new Map,this.forEach((e=>this._rects?.set(e,e.getBoundingClientRect()))),this._timeout&&clearTimeout(this._timeout),this._timeout=setTimeout((()=>this._rects=void 0),this.Settings.refreshMemoryRate)),this._rects}}class T extends Set{_rects;_timeout;DS;PS;Settings;constructor({DS:e,PS:t}){super(),this.DS=e,this.PS=t,this.Settings=this.DS.stores.SettingsStore.s}add(e){if(!e||super.has(e))return this;const t={items:this.elements,item:e};return this.PS.publish("Selected:added:pre",t),super.add(e),e.classList.add(this.Settings.selectedClass),this.Settings.useLayers&&(e.style.zIndex=`${(parseInt(e.style.zIndex)||0)+1}`),this.PS.publish("Selected:added",t),this}delete(e){if(!e||!super.has(e))return!0;const t={items:this.elements,item:e};this.PS.publish("Selected:removed:pre",t);const s=super.delete(e);return e.classList.remove(this.Settings.selectedClass),this.Settings.useLayers&&(e.style.zIndex=""+((parseInt(e.style.zIndex)||0)-1)),this.PS.publish("Selected:removed",t),s}clear=()=>this.forEach((e=>this.delete(e)));toggle(e){return this.has(e)?this.delete(e):this.add(e),e}addAll=e=>e.forEach((e=>this.add(e)));deleteAll=e=>e.forEach((e=>this.delete(e)));get elements(){return Array.from(this.values())}get rects(){return this._rects||(this._rects=new Map,this.forEach((e=>this._rects?.set(e,e.getBoundingClientRect()))),this._timeout&&clearTimeout(this._timeout),this._timeout=setTimeout((()=>this._rects=void 0),this.Settings.refreshMemoryRate)),this._rects}}var C=(e,t)=>{t.left&&(e.style.left=`${t.left}px`),t.top&&(e.style.top=`${t.top}px`),t.width&&(e.style.width=`${t.width}px`),t.height&&(e.style.height=`${t.height}px`)};class x{_rect;DS;PS;Settings;HTMLNode;constructor({DS:e,PS:t}){this.DS=e,this.PS=t,this.Settings=this.DS.stores.SettingsStore.s,this.HTMLNode=this.Settings.selector,this.PS.subscribe("Settings:updated:selectorClass",(({settings:e})=>{this.HTMLNode.classList.remove(e["selectorClass:pre"]),this.HTMLNode.classList.add(e.selectorClass)})),this.PS.subscribe("Settings:updated:selector",this.attachSelector),this.PS.subscribe("Settings:updated:customStyles",this.attachSelector),this.attachSelector(),this.PS.subscribe("Interaction:start",this.start),this.PS.subscribe("Interaction:update",this.update),this.PS.subscribe("Interaction:end",this.stop)}attachSelector=()=>{this.HTMLNode&&this.DS.SelectorArea?.HTMLNode&&this.DS.SelectorArea.HTMLNode.removeChild(this.HTMLNode),this.HTMLNode=this.Settings.selector||(e=>{const t=document.createElement("div");return t.style.position="absolute",e||(t.style.background="rgba(0, 175, 255, 0.2)",t.style.border="1px solid rgba(0, 175, 255, 0.8)",t.style.display="none",t.style.pointerEvents="none"),t})(this.Settings.customStyles),this.HTMLNode.classList.add(this.Settings.selectorClass),this.HTMLNode&&this.DS.SelectorArea?.HTMLNode&&this.DS.SelectorArea.HTMLNode.appendChild(this.HTMLNode)};start=({isDragging:e})=>{if(e)return;const{stores:{PointerStore:t}}=this.DS,s=t.initialValArea;C(this.HTMLNode,a(s,1)),this.HTMLNode.style.display="block",this._rect=void 0};stop=()=>{this.HTMLNode.style.width="0",this.HTMLNode.style.height="0",this.HTMLNode.style.display="none"};update=({isDragging:e})=>{if(e||this.DS.continue)return;const{stores:{ScrollStore:t,PointerStore:s}}=this.DS,i=(({scrollAmount:e,initialPointerPos:t,pointerPos:s})=>{const i={};return s.x>t.x-e.x?(i.left=t.x-e.x,i.width=s.x-t.x+e.x):(i.left=s.x,i.width=t.x-s.x-e.x),s.y>t.y-e.y?(i.top=t.y-e.y,i.height=s.y-t.y+e.y):(i.top=s.y,i.height=t.y-s.y-e.y),i})({scrollAmount:t.scrollAmount,initialPointerPos:s.initialValArea,pointerPos:s.currentValArea});C(this.HTMLNode,i),this._rect=void 0};get rect(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}class A{_prevSelectedSet=new Set;_boundingRect;_timeout;DS;PS;Settings;constructor({DS:e,PS:t}){this.DS=e,this.PS=t,this.Settings=this.DS.stores.SettingsStore.s,this.PS.subscribe("Interaction:start",this.start),this.PS.subscribe("Interaction:update",this.update)}_storePrevious(e){const{stores:{KeyStore:t},SelectedSet:s}=this.DS;t.isMultiSelectKeyPressed(e)?this._prevSelectedSet=new Set(s):this._prevSelectedSet=new Set}start=({event:e,isDragging:t})=>{t||(this._storePrevious(e),this._handleInsideSelection(!0,e))};update=({isDragging:e})=>{e||this.DS.continue||this._handleInsideSelection()};_handleInsideSelection=(e,t)=>{const{SelectableSet:s,SelectorArea:i,Selector:r}=this.DS,n=this.DS.stores.KeyStore.isMultiSelectKeyPressed(t)&&this.Settings.multiSelectToggling,o=this.Settings.selectionThreshold,l=s.rects,a=r.rect,h=new Map,c=new Map;for(const[e,t]of l)i.isInside(e,t)&&(p(t,a,o)?h.set(e,t):c.set(e,t));if(this.DS.continue)return;const{select:d,unselect:S}=this.filterSelected({select:h,unselect:c,selectorRect:a});d.forEach(((t,s)=>(({element:e,force:t,multiSelectionToggle:s,SelectedSet:i,hoverClassName:r})=>{e.classList.contains(r)&&!t||(i.has(e)?s&&i.delete(e):i.add(e),e.classList.add(r))})({element:s,force:e,multiSelectionToggle:n,SelectedSet:this.DS.SelectedSet,hoverClassName:this.Settings.hoverClass}))),S.forEach(((t,s)=>(({element:e,force:t,SelectedSet:s,PrevSelectedSet:i,hoverClassName:r})=>{if(!e.classList.contains(r)&&!t)return;const n=s.has(e),o=i.has(e);n&&!o?s.delete(e):!n&&o&&s.add(e),e.classList.remove(r)})({element:s,force:e,SelectedSet:this.DS.SelectedSet,hoverClassName:this.Settings.hoverClass,PrevSelectedSet:this._prevSelectedSet})))};get boundingRect(){return this._boundingRect||(this._boundingRect=(e=>{const t={top:Number.POSITIVE_INFINITY,left:Number.POSITIVE_INFINITY,bottom:Number.NEGATIVE_INFINITY,right:Number.NEGATIVE_INFINITY,width:Number.NEGATIVE_INFINITY,height:Number.NEGATIVE_INFINITY};return e.rects.forEach((e=>{t.top=Math.min(t.top,e.top||t.top),t.left=Math.min(t.left,e.left||t.left),t.bottom=Math.max(t.bottom,e.bottom||t.bottom),t.right=Math.max(t.right,e.right||t.right)})),t.height=t.bottom-t.top,t.width=t.right-t.left,t})(this.DS.SelectedSet),this._timeout&&clearTimeout(this._timeout),this._timeout=setTimeout((()=>this._boundingRect=void 0),this.Settings.refreshMemoryRate)),this._boundingRect}filterSelected=({select:e,unselect:t,selectorRect:s})=>({select:e,unselect:t})}class w{_scrollInterval;_rect;currentEdges=[];DS;PS;Settings;HTMLNode;constructor({DS:e,PS:t}){this.DS=e,this.PS=t,this.Settings=this.DS.stores.SettingsStore.s,this.HTMLNode=(()=>{const e=document.createElement("div");return e.style.position="fixed",e.style.overflow="hidden",e.style.pointerEvents="none",e.style.zIndex="999999999999999999",e})(),this.PS.subscribe("Settings:updated:selectorAreaClass",(({settings:e})=>{this.HTMLNode.classList.remove(e["selectorAreaClass:pre"]),this.HTMLNode.classList.add(e.selectorAreaClass)})),this.HTMLNode.classList.add(this.Settings.selectorAreaClass),this.PS.subscribe("Area:modified",this.updatePos),this.PS.subscribe("Area:modified",this.updatePos),this.PS.subscribe("Interaction:init",this.init),this.PS.subscribe("Interaction:start",(({isDraggingKeyboard:e})=>this.startAutoScroll({isDraggingKeyboard:e}))),this.PS.subscribe("Interaction:end",(()=>{this.updatePos(),this.stopAutoScroll()}))}init=()=>{this.applyElements("append"),this.updatePos()};applyElements=e=>{const t=document.body?"body":"documentElement",s=`${e}Child`;this.HTMLNode[s](this.DS.Selector.HTMLNode),document[t][s](this.HTMLNode)};updatePos=()=>{this._rect=void 0;const e=this.DS.Area.rect,t=this.DS.Area.computedBorder,{style:s}=this.HTMLNode,i=`${e.top+t.top}px`,r=`${e.left+t.left}px`,n=`${e.width}px`,o=`${e.height}px`;s.top!==i&&(s.top=i),s.left!==r&&(s.left=r),s.width!==n&&(s.width=n),s.height!==o&&(s.height=o)};stop=e=>{this.stopAutoScroll(),e&&this.applyElements("remove")};startAutoScroll=({isDraggingKeyboard:e})=>{e||(this.currentEdges=[],this._scrollInterval=setInterval((()=>this.handleAutoScroll()),16))};handleAutoScroll=()=>{if(this.DS.continue)return;const{stores:{PointerStore:e},Area:t}=this.DS;this.currentEdges=(({elementRect:e,containerRect:t,tolerance:s={x:0,y:0}})=>{const i=[];return e.top-s.y<t.top&&i.push("top"),e.left-s.x<t.left&&i.push("left"),e.bottom+s.y>t.bottom&&i.push("bottom"),e.right+s.y>t.right&&i.push("right"),i})({elementRect:a(e.currentVal),containerRect:this.rect,tolerance:this.Settings.overflowTolerance}),this.currentEdges.length&&t.scroll(this.currentEdges,this.Settings.autoScrollSpeed)};stopAutoScroll=()=>{this.currentEdges=[],clearInterval(this._scrollInterval)};isInside=(e,t)=>!(!this.DS.Area.HTMLNode.contains(e)||!this.DS.stores.ScrollStore.canScroll)||p(this.rect,t||e.getBoundingClientRect());isClicked(e){const{stores:{PointerStore:t}}=this.DS,s=e?t.getPointerPosition(e):t.initialVal;return p({left:s.x,top:s.y,right:s.x,bottom:s.y},this.rect)}get rect(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}const N=(e,t)=>console.warn(`[DragSelect] TypeIssue: setting "${e}" is not of type "${t}".`),M=(e,t,s,i)=>{if(void 0===t)return s?{[e]:i}:{};if(null===t)return{[e]:null};let r=!0,n=!1;const o="string"==typeof i;o&&(r="string"==typeof t||t instanceof String),o&&!r&&(n=!0,N(e,"string"));const l=!Number.isNaN(i)&&"number"==typeof i;l&&(r=!Number.isNaN(t)&&"number"==typeof t),l&&!r&&(n=!0,N(e,"number"));const a="[object Object]"===Object.prototype.toString.call(i);a&&(r="[object Object]"===Object.prototype.toString.call(t)),a&&!r&&(n=!0,N(e,"object"));const h="boolean"==typeof i;h&&(r="boolean"==typeof t),h&&!r&&(n=!0,N(e,"boolean"));const c=Array.isArray(i);c&&(r=Array.isArray(t)),c&&!r&&(n=!0,N(e,"array"));const d=n||s;return"dragKeys"===e&&r?{[e]:Object.assign(i,t)}:"dragKeys"!==e||r?("dropZones"===e&&r&&Array.isArray(t)&&new Set(t.map((e=>e.id))).size!==t.length&&console.warn('[DragSelect] UniqueConstraintsIssue: setting "dropZones" contains duplicate ids.'),r?{[e]:t}:d?{[e]:i}:{}):d?{[e]:i}:{}};class V{_settings={};s={};PS;constructor({PS:e,settings:t}){this.PS=e,this.update({settings:t,init:!0})}update=({settings:e,init:t})=>{this.PS.publish("Settings:updated:pre",{settings:this._settings,"settings:init":Boolean(t),"settings:new":e}),this._update({settings:e,init:t})};_update=({settings:e={},init:t=!1})=>{const s=((e,t)=>({...M("area",e.area,t,document),...M("selectables",e.selectables,t,null),...M("autoScrollSpeed",e.autoScrollSpeed,t,5),...M("overflowTolerance",e.overflowTolerance,t,{x:25,y:25}),...M("zoom",e.zoom,t,1),...M("customStyles",e.customStyles,t,!1),...M("multiSelectMode",e.multiSelectMode,t,!1),...M("multiSelectToggling",e.multiSelectToggling,t,!0),...M("multiSelectKeys",e.multiSelectKeys,t,["Control","Shift","Meta"]),...M("selector",e.selector,t,null),...M("selectionThreshold",e.selectionThreshold,t,0),...M("draggability",e.draggability,t,!0),...M("immediateDrag",e.immediateDrag,t,!0),...M("keyboardDrag",e.keyboardDrag,t,!0),...M("dragKeys",e.dragKeys,t,{up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]}),...M("keyboardDragSpeed",e.keyboardDragSpeed,t,10),...M("useTransform",e.useTransform,t,!0),...M("refreshMemoryRate",e.refreshMemoryRate,t,80),...M("dropZones",e.dropZones,t,[]),...M("dropInsideThreshold",e.dropInsideThreshold,t,1),...M("dropTargetThreshold",e.dropTargetThreshold,t,0),...M("usePointerEvents",e.usePointerEvents,t,!1),...M("hoverClass",e.hoverClass,t,"ds-hover"),...M("selectableClass",e.selectableClass,t,"ds-selectable"),...M("selectedClass",e.selectedClass,t,"ds-selected"),...M("selectorClass",e.selectorClass,t,"ds-selector"),...M("selectorAreaClass",e.selectorAreaClass,t,"ds-selector-area"),...M("droppedTargetClass",e.droppedTargetClass,t,"ds-dropped-target"),...M("droppedInsideClass",e.droppedInsideClass,t,"ds-dropped-inside"),...M("droppableClass",e.droppableClass,t,"ds-droppable"),...M("dropZoneClass",e.dropZoneClass,t,"ds-dropzone"),...M("dropZoneReadyClass",e.dropZoneReadyClass,t,"ds-dropzone-ready"),...M("dropZoneTargetClass",e.dropZoneTargetClass,t,"ds-dropzone-target"),...M("dropZoneInsideClass",e.dropZoneInsideClass,t,"ds-dropzone-inside"),...M("useLayers",e.useLayers,t,!0)}))(e,t);for(const[i,r]of Object.entries(s))((s,i)=>{s in this._settings||Object.defineProperty(this.s,s,{get:()=>this._settings[s],set:e=>this.update({settings:{[s]:e}})}),this._settings[`${s}:pre`]=this._settings[s],this._settings[s]=i;const r={settings:this._settings,"settings:init":t,"settings:new":e};this.PS.publish("Settings:updated",r),this.PS.publish(`Settings:updated:${s}`,r)})(i,r)}}const K={elementselect:"DS:select",elementunselect:"DS:unselect",autoscroll:"DS:scroll",dragstart:"DS:start",dragmove:"DS:update",callback:"DS:end",preelementselect:"DS:select:pre",preelementunselect:"DS:unselect:pre",preautoscroll:"DS:scroll:pre",predragstart:"DS:start:pre",predragmove:"DS:update:pre",precallback:"DS:end:pre"},k=(e,t)=>{const s=t.DropZones.getTarget(e);return{...e,...s?{dropTarget:s.toObject()}:{}}},H=({sub_name:e,DS:t,PS:s,sub_pubs:i})=>{s.subscribe(e,(e=>i.forEach((s=>$({sub_pub:s,data:e,DS:t})))))},$=({sub_pub:e,data:t,DS:s})=>{const i=e.condition?e.condition(t,s):t;if(i){const r=e.extraData&&e.extraData(t,s)||{};s.publish(e.name,{items:s.SelectedSet.elements,isDragging:s.Interaction.isDragging,...i,...r})}};class R{continue=!1;PubSub;stores;Area;Selector;SelectorArea;SelectableSet;SelectedSet;Selection;Drag;DropZones;Interaction;stopped;constructor(e){this.stopped=!1,this.PubSub=new v({DS:this}),this.stores={},this.stores.SettingsStore=new V({settings:e,PS:this.PubSub}),this.stores.PointerStore=new _({DS:this,PS:this.PubSub}),this.stores.ScrollStore=new L({DS:this,PS:this.PubSub}),this.stores.KeyStore=new D({DS:this,PS:this.PubSub}),this.Area=new n({DS:this,PS:this.PubSub}),this.Selector=new x({DS:this,PS:this.PubSub}),this.SelectorArea=new w({DS:this,PS:this.PubSub}),this.SelectableSet=new E({DS:this,PS:this.PubSub}),this.SelectedSet=new T({DS:this,PS:this.PubSub}),this.Selection=new A({DS:this,PS:this.PubSub}),this.Drag=new u({DS:this,PS:this.PubSub}),this.DropZones=new b({DS:this,PS:this.PubSub}),this.Interaction=new y({DS:this,PS:this.PubSub}),(({PS:e,DS:t})=>{const s={"Selected:added":[{name:"preelementselect"},{name:"elementselect"},{name:"DS:select:pre"},{name:"DS:select"}],"Selected:removed":[{name:"preelementunselect"},{name:"elementunselect"},{name:"DS:unselect:pre"},{name:"DS:unselect"}],"Selectable:added":[{name:"DS:added:pre"},{name:"DS:added"}],"Selectable:removed":[{name:"DS:removed:pre"},{name:"DS:removed"}],"Area:scroll":[{name:"preautoscroll"},{name:"autoscroll"},{name:"DS:scroll:pre"},{name:"DS:scroll"}],"Interaction:start":[{name:"predragstart"},{name:"dragstart"},{name:"DS:start:pre"},{name:"DS:start"}],"Interaction:update":[{name:"predragmove",condition:e=>e.event?e:null},{name:"dragmove",condition:e=>e.event?e:null},{name:"DS:update:pre",condition:e=>e.event?e:null},{name:"DS:update",condition:e=>e.event?e:null}],"Interaction:end":[{name:"precallback",extraData:(e,t)=>k(e,t)},{name:"callback",extraData:(e,t)=>k(e,t)},{name:"DS:end:pre",extraData:(e,t)=>k(e,t)},{name:"DS:end",extraData:(e,t)=>k(e,t)}]};for(const[i,r]of Object.entries(s))H({sub_name:i,sub_pubs:r,DS:t,PS:e})})({DS:this,PS:this.PubSub}),this.PubSub.subscribe("Interaction:end",(()=>this.continue=!1)),this.PubSub.subscribe("DS:end",(({items:e})=>this.continue=!1)),this.start()}static isCollision;subscribe=(e,t)=>{K[e]&&console.warn(`[DragSelect]: The event name "${e}" is deprecated and was/will be removed in a future version. Please use the new event name "${K[e]}" instead.`),this.PubSub.subscribe(e,t)};unsubscribe=(e,t,s)=>this.PubSub.unsubscribe(e,t,s);publish=(e,t)=>this.PubSub.publish(e,t);start=()=>{this.stopped=!1,this.Interaction.init()};stop(e=!0,t=!0,s=!1){s&&this.publish("DS:end",{items:this.SelectedSet.elements,isDragging:this.Interaction.isDragging}),this.Interaction.stop(),this.Area.stop(),this.Drag.stop(),this.Selector.stop(),this.SelectorArea.stop(e),this.stores.KeyStore.stop(),this.stores.PointerStore.stop(),this.stores.ScrollStore.stop(),e&&this.SelectableSet.clear(),t&&this.SelectedSet.clear(),this.stopped=!0}break=()=>this.continue=!0;setSettings=e=>this.stores.SettingsStore.update({settings:e});getSelection=()=>this.SelectedSet.elements;addSelection(e,t=!1,s=!1){const i=g(e);return this.SelectedSet.addAll(i),s||this.addSelectables(e,!1,!1),t&&this.PubSub.publish("DS:end",{items:this.SelectedSet.elements,isDragging:this.Interaction.isDragging}),this.getSelection()}removeSelection(e,t=!1,s=!1){const i=g(e);return this.SelectedSet.deleteAll(i),s&&this.removeSelectables(e,!1,!1),t&&this.PubSub.publish("DS:end",{items:this.SelectedSet.elements,isDragging:this.Interaction.isDragging}),this.getSelection()}toggleSelection(e,t=!1,s=!1){return g(e).forEach((i=>this.SelectedSet.has(i)?this.removeSelection(e,t,s):this.addSelection(e,t,s))),t&&this.PubSub.publish("DS:end",{items:this.SelectedSet.elements,isDragging:this.Interaction.isDragging}),this.getSelection()}setSelection(e,t=!1,s=!1){return this.clearSelection(),this.addSelection(e,t,s),this.getSelection()}clearSelection(e=!1){return this.SelectedSet.clear(),e&&this.PubSub.publish("DS:end",{items:this.SelectedSet.elements,isDragging:this.Interaction.isDragging}),this.getSelection()}addSelectables(e,t,s){const i=g(e);return this.SelectableSet.addAll(i),t&&this.SelectedSet.addAll(i),s&&this.PubSub.publish("DS:end",{items:this.SelectedSet.elements,isDragging:this.Interaction.isDragging}),i}getSelectables=()=>this.SelectableSet.elements;removeSelectables(e,t,s){const i=g(e);return this.SelectableSet.deleteAll(i),t&&this.removeSelection(e),s&&this.PubSub.publish("DS:end",{items:this.SelectedSet.elements,isDragging:this.Interaction.isDragging}),i}getInitialCursorPosition=()=>this.stores.PointerStore.initialVal;getCurrentCursorPosition=()=>this.stores.PointerStore.currentVal;getPreviousCursorPosition=()=>this.stores.PointerStore.lastVal;getInitialCursorPositionArea=()=>this.stores.PointerStore.initialValArea;getCurrentCursorPositionArea=()=>this.stores.PointerStore.currentValArea;getPreviousCursorPositionArea=()=>this.stores.PointerStore.lastValArea;isMultiSelect=e=>this.stores.KeyStore.isMultiSelectKeyPressed(e);isDragging=()=>this.Interaction.isDragging;getZoneByCoordinates=e=>this.DropZones.getTarget({coordinates:e})?.toObject();getItemsDroppedByZoneId=e=>this.DropZones.getItemsDroppedById(e);getItemsInsideByZoneId=(e,t)=>this.DropZones.getItemsInsideById(e,t)}R.isCollision=p;export{R as default};
|
|
1
|
+
const t=(t,e)=>{const s=e;window.addEventListener("resize",s),window.addEventListener("scroll",s);const i=new MutationObserver(s),r=new ResizeObserver(s);t.forEach(((t,e)=>{i.observe(t,{childList:0!==e,attributes:!0}),t instanceof Element&&r.observe(t)}));return{observer:i,resizeObserver:r,callback:s,cleanup:()=>{window.removeEventListener("resize",s),window.removeEventListener("scroll",s),i.disconnect(),r.disconnect()}}},e=(t,e)=>{let s;return(...i)=>{clearTimeout(s),s=setTimeout((()=>{s=void 0,t(...i)}),e)}},s=t=>{const e=(t,s=0)=>{const i=t[s]?.parentNode;return i?(t.push(i),s++,e(t,s)):t};return e([t])},i=({computedStyle:t,node:e})=>{const{position:s}=t;e instanceof Document||("absolute"===s||"relative"===s||"fixed"===s)||(e.style.position="relative")};let r;class n{DS;PS;Settings;_observers;_node;_parentNodes;_computedStyle;_computedBorder;_rect;constructor({DS:t,PS:e}){this.DS=t,this.PS=e,this.Settings=this.DS.stores.SettingsStore.s,this._node=this.Settings.area,this.setArea(this.Settings.area),this.PS.subscribe("Settings:updated:area",(({settings:{area:t}})=>this.setArea(t))),this.PS.subscribe("Interaction:init",this.init),this.PS.subscribe("Interaction:end",this.reset)}setArea=t=>{this.reset(),this._node=t,i({computedStyle:this.computedStyle,node:this._node}),setTimeout((()=>{this.PS.publish("Area:modified:pre",{item:this.HTMLNode}),this.reset(),this.PS.publish("Area:modified",{item:this.HTMLNode})}))};init=()=>{this._observers=t(this.parentNodes,e((t=>{this.hasRelevantBeenModified()&&(this.PS.publish("Area:modified:pre",{event:t,item:this.HTMLNode}),this.reset(),this.PS.publish("Area:modified",{event:t,item:this.HTMLNode}))}),60))};hasRelevantBeenModified=()=>{const t=this.computedStyle,e=this.rect,s=this.computedBorder,i=this.parentNodes;return this.reset(),JSON.stringify(t)!==JSON.stringify(this.computedStyle)||(JSON.stringify(e)!==JSON.stringify(this.rect)||(JSON.stringify(s)!==JSON.stringify(this.computedBorder)||!(i.length===this.parentNodes.length||!i.some((t=>!this.parentNodes.includes(t))))))};reset=()=>{this._computedStyle=void 0,this._rect=void 0,this._computedBorder=void 0,this._parentNodes=void 0};stop=()=>{this._observers?.cleanup(),this.reset()};scroll=(t,e)=>{const s={scroll_directions:t,scroll_multiplier:e};this.PS.publish("Area:scroll:pre",s),((t,e,s=1)=>{if(!e?.length||!t)return;let i=t;if(t instanceof Document&&(r&&(i=r),Number.isFinite(document?.documentElement?.scrollTop))){const t=document.documentElement.scrollTop;document.documentElement.scrollTop+=1,document.documentElement.scrollTop===t?(i=document.body,r=document.body):(document.documentElement.scrollTop=t,i=document.documentElement,r=document.documentElement)}const n=e.includes("top")&&i.scrollTop>0,o=e.includes("bottom")&&i.scrollTop<i.scrollHeight,l=e.includes("left")&&i.scrollLeft>0,a=e.includes("right")&&i.scrollLeft<i.scrollWidth;n&&(i.scrollTop-=1*s),o&&(i.scrollTop+=1*s),l&&(i.scrollLeft-=1*s),a&&(i.scrollLeft+=1*s)})(this._node,t,e),this.PS.publish("Area:scroll",s)};get HTMLNode(){return this._node}get computedBorder(){return this._computedBorder?this._computedBorder:{top:parseInt(this.computedStyle.borderTopWidth),bottom:parseInt(this.computedStyle.borderBottomWidth),left:parseInt(this.computedStyle.borderLeftWidth),right:parseInt(this.computedStyle.borderRightWidth)}}get computedStyle(){if(this._computedStyle)return this._computedStyle;let t;return t=this.HTMLNode instanceof Document?window.getComputedStyle(this.HTMLNode.body||this.HTMLNode.documentElement):window.getComputedStyle(this.HTMLNode),this._computedStyle={borderTopWidth:t.borderTopWidth,borderBottomWidth:t.borderBottomWidth,borderLeftWidth:t.borderLeftWidth,borderRightWidth:t.borderRightWidth,position:t.position}}get rect(){return this._rect?this._rect:this._rect=((t,e)=>{if(t instanceof Document)return{top:0,left:0,bottom:0,right:0,width:window.innerWidth,height:window.innerHeight};const s=t.getBoundingClientRect();return{top:s.top,left:s.left,bottom:s.bottom,right:s.right,width:(t.clientWidth||s.width)*e,height:(t.clientHeight||s.height)*e}})(this.HTMLNode,this.DS.stores.SettingsStore.s.zoom)}get parentNodes(){return this._parentNodes?this._parentNodes:this._parentNodes=s(this.HTMLNode)}}const o=({x:t,y:e},s,{x:i,y:r})=>({"+":{x:t+i,y:e+r},"-":{x:t-i,y:e-r},"*":{x:t*i,y:e*r},"/":{x:t/i,y:e/r}}[s]),l=t=>({x:t.left,y:t.top}),a=(t,e=0)=>({left:t.x,top:t.y,right:t.x,bottom:t.y,width:e,height:e}),h=t=>({x:t,y:t}),c=t=>{const e={x:0,y:0},s=window.getComputedStyle(t);if(!s.transform||"none"===s.transform)return e;if(s.transform.indexOf("3d")>=0){const t=s.transform.trim().match(/matrix3d\((.*?)\)/);if(t&&t.length){const s=t[1]?.split(",");e.x=parseInt(s[12])||0,e.y=parseInt(s[13])||0}return e}const i=s.transform.trim().match(/matrix\((.*?)\)/);if(i&&i.length){const t=i[1]?.split(",");e.x=parseInt(t[4])||0,e.y=parseInt(t[5])||0}return e},d=(t,e)=>e?(t=>{const{transform:e}=t.style;if(!e||e.indexOf("translate")<0)return c(t);const s={x:0,y:0},i=e.trim().match(/translate[3dD]*?\(.*?\)/);if(i){const t=i[0]?.split("(");if(t){const e=t[1]?.split(",");s.x=parseInt(e[0])||0,s.y=parseInt(e[1])||0}}return s.x||s.x?s:c(t)})(t):(t=>{const{style:e}=t,s={x:parseInt(e.left)||0,y:parseInt(e.top)||0};if(!s.x&&!s.x){const e=window.getComputedStyle(t);return{x:parseInt(e.left)||0,y:parseInt(e.top)||0}}return s})(t),S=({containerRect:t,selectionRect:e,direction:s,scrollAmount:i})=>{const r={top:t.top-e.top+i.y,left:t.left-e.left+i.x,bottom:t.bottom-e.bottom+i.y,right:t.right-e.right+i.x};return 0===s.x&&0===s.y||(s.y<0&&(s.y=Math.max(s.y,r.top)),s.x<0&&(s.x=Math.max(s.x,r.left)),s.y>0&&(s.y=Math.min(s.y,r.bottom)),s.x>0&&(s.x=Math.min(s.x,r.right)),e.top+=s.y,e.bottom+=s.y,e.left+=s.x,e.right+=s.x),s};class u{_prevCursorPos;_prevScrollPos;_elements=[];_dragKeys;_dragKeysFlat=[];_selectionRect=a(h(0));DS;PS;Settings;constructor({DS:t,PS:e}){this.DS=t,this.PS=e,this.Settings=this.DS.stores.SettingsStore.s,this.PS.subscribe("Settings:updated:dragKeys",this.assignDragKeys),this.assignDragKeys(),this.PS.subscribe("Interaction:start",this.start),this.PS.subscribe("Interaction:end",this.stop),this.PS.subscribe("Interaction:update",this.update),this.PS.subscribe("KeyStore:down",this.keyboardDrag),this.PS.subscribe("KeyStore:up",this.keyboardEnd)}assignDragKeys=()=>{this._dragKeys={up:this.Settings.dragKeys.up.map((t=>t.toLowerCase())),down:this.Settings.dragKeys.down.map((t=>t.toLowerCase())),left:this.Settings.dragKeys.left.map((t=>t.toLowerCase())),right:this.Settings.dragKeys.right.map((t=>t.toLowerCase()))},this._dragKeysFlat=[...this._dragKeys.up,...this._dragKeys.down,...this._dragKeys.left,...this._dragKeys.right]};keyboardDrag=({event:t,key:e})=>{const s=e.toLowerCase();if(!this.Settings.keyboardDrag||!this._dragKeysFlat.includes(s)||!this.DS.SelectedSet.size||!this.Settings.draggability||this.DS.continue)return;const i={event:t,isDragging:!0,isDraggingKeyboard:!0,key:e};this.PS.publish(["Interaction:start:pre","Interaction:start"],i),this._elements=this.DS.getSelection(),this._selectionRect=this.DS.Selection.boundingRect,this.handleZIndex(!0);let r=(({shiftKey:t,keyboardDragSpeed:e,zoom:s,key:i,dragKeys:r,scrollDiff:n})=>{const o={x:0,y:0},l=t?4*e*s:e*s;return r?.left.includes(i)&&(o.x=n.x||-l),r?.right.includes(i)&&(o.x=n.x||l),r?.up.includes(i)&&(o.y=n.y||-l),r?.down.includes(i)&&(o.y=n.y||l),o})({shiftKey:this.DS.stores.KeyStore.currentValues.includes("shift"),keyboardDragSpeed:this.Settings.keyboardDragSpeed,zoom:this.Settings.zoom,key:s,scrollDiff:this._scrollDiff,dragKeys:this._dragKeys});r=S({direction:r,containerRect:this.DS.SelectorArea.rect,scrollAmount:this.DS.stores.ScrollStore.scrollAmount,selectionRect:this._selectionRect}),this.moveElements(r),this.PS.publish(["Interaction:update:pre","Interaction:update"],i)};keyboardEnd=({event:t,key:e})=>{const s=e.toLowerCase();if(!(this.Settings.keyboardDrag&&this._dragKeysFlat.includes(s)&&this.DS.SelectedSet.size&&this.Settings.draggability))return;const i={event:t,isDragging:this.Settings.draggability,isDraggingKeyboard:!0,key:e};this.PS.publish(["Interaction:end:pre","Interaction:end"],i)};start=({isDragging:t,isDraggingKeyboard:e})=>{t&&!e&&(this._prevCursorPos=void 0,this._prevScrollPos=void 0,this._elements=this.DS.getSelection(),this._selectionRect=this.DS.Selection.boundingRect,this.handleZIndex(!0))};stop=()=>{this._prevCursorPos=void 0,this._prevScrollPos=void 0,this.handleZIndex(!1),this._elements=[]};update=({isDragging:t,isDraggingKeyboard:e})=>{if(!t||!this._elements.length||e||this.DS.continue)return;let s=o(this._cursorDiff,"+",this._scrollDiff);s=S({direction:s,containerRect:this.DS.SelectorArea.rect,scrollAmount:this.DS.stores.ScrollStore.scrollAmount,selectionRect:this._selectionRect}),this.moveElements(s)};handleZIndex=t=>{this.Settings.useLayers&&this._elements.forEach((e=>e.style.zIndex=`${(parseInt(e.style.zIndex)||0)+(t?9999:-9998)}`))};moveElements=t=>{const{elements:e,direction:s}=this.filterDragElements({elements:this._elements,direction:t});e.forEach((t=>{(({element:t,posDirection:e,useTransform:s})=>{const i=d(t,s);((t,e,s)=>{if(s){const s=t.style.transform;t.style.transform=`translate3d(${e.x}px,${e.y}px,1px) ${s.replace(/translate.*?\)/g,"")}`}else t.style.left=`${e.x}px`,t.style.top=`${e.y}px`})(t,o(i,"+",e),s)})({element:t,posDirection:s,containerRect:this.DS.SelectorArea.rect,useTransform:this.Settings.useTransform})}))};get _cursorDiff(){const t=this.DS.stores.PointerStore.currentVal,e=this._prevCursorPos?o(t,"-",this._prevCursorPos):{x:0,y:0};return this._prevCursorPos=t,e}get _scrollDiff(){const t=this.DS.stores.ScrollStore.currentVal,e=this._prevScrollPos?o(t,"-",this._prevScrollPos):{x:0,y:0};return this._prevScrollPos=t,e}filterDragElements=({elements:t,direction:e})=>({elements:t,direction:e})}const p=(t,e,s=0)=>{if(!t||!e)return!1;let i=t;if(s>0){const e=(t.right-t.left)*s,r=(t.bottom-t.top)*s;i={left:t.left+e,right:t.right-e,top:t.top+r,bottom:t.bottom-r}}return i.left<e.right&&i.right>e.left&&i.top<e.bottom&&i.bottom>e.top},g=t=>t?Array.isArray(t)||"function"==typeof t[Symbol.iterator]?[...new Set([...t])]:[t]:[];class m{id;element;_droppables;_rect;_observers;_timeout;_itemsDropped=[];_itemsInside;DS;PS;Settings;isDestroyed=!1;_parentNodes;constructor({DS:s,PS:i,id:r,element:n,droppables:o}){this.DS=s,this.PS=i,this.Settings=this.DS.stores.SettingsStore.s,this.id=r,this.element=n,o&&(this.droppables=g(o)),this.element.classList.add(`${this.Settings.dropZoneClass}`),this.PS.subscribe("Settings:updated:dropZoneClass",(({settings:t})=>{this.element&&(this.element.classList.remove(t["dropZoneClass:pre"]),this.element.classList.add(t.dropZoneClass))})),this._observers=t(this.parentNodes,e((()=>this._rect=void 0),this.Settings.refreshMemoryRate)),this.PS.subscribe("Interaction:start",this.start),this.PS.subscribe("Interaction:end",this.stop)}setReadyClasses=t=>{if(this.isDestroyed)return;const e=this.droppables.filter((t=>this.DS.SelectedSet.has(t)));e.length&&(e.forEach((e=>{e.classList[t](`${this.Settings.droppableClass}`),e.classList[t](`${this.Settings.droppableClass}-${this.id}`)})),this.element.classList[t](`${this.Settings.dropZoneReadyClass}`))};handleNoDrop=()=>{this.isDestroyed||(this.DS.SelectedSet.forEach((t=>{t.classList.remove(this.Settings.droppedTargetClass),t.classList.remove(`${this.Settings.droppedTargetClass}-${this.id}`)})),this._itemsDropped=this._itemsDropped.filter((t=>!this.DS.SelectedSet.has(t))),this._itemsDropped?.length||this.element.classList.remove(`${this.Settings.dropZoneTargetClass}`))};handleDrop=()=>{this.isDestroyed||(this._itemsDropped=[...new Set([...this._itemsDropped,...this.droppables?.filter((t=>this.DS.SelectedSet.has(t)))])],this._itemsDropped?.forEach((t=>{t.classList.add(`${this.Settings.droppedTargetClass}`),t.classList.add(`${this.Settings.droppedTargetClass}-${this.id}`)})),this._itemsDropped?.length&&this.element.classList.add(`${this.Settings.dropZoneTargetClass}`))};handleItemsInsideClasses=()=>{let t=!1;this.droppables.forEach((e=>{this.itemsInside?.includes(e)?(e.classList.add(`${this.Settings.droppedInsideClass}`),e.classList.add(`${this.Settings.droppedInsideClass}-${this.id}`),t=!0):(e.classList.remove(`${this.Settings.droppedInsideClass}-${this.id}`),e.className.includes(`${this.Settings.droppedInsideClass}-`)||e.classList.remove(`${this.Settings.droppedInsideClass}`))})),t?this.element.classList.add(`${this.Settings.dropZoneInsideClass}`):this.element.classList.remove(`${this.Settings.dropZoneInsideClass}`)};start=({isDragging:t})=>{t&&!this.isDestroyed&&this.setReadyClasses("add")};stop=({isDragging:t})=>{t&&!this.isDestroyed&&(this.setReadyClasses("remove"),this.handleItemsInsideClasses())};destroy(){this._observers?.cleanup(),this.element.classList.remove(`${this.Settings.dropZoneClass}`),this.element.classList.remove(`${this.Settings.dropZoneTargetClass}`),this.element.classList.remove(`${this.Settings.dropZoneReadyClass}`),this.droppables.forEach((t=>{t.classList.remove(`${this.Settings.droppedTargetClass}`),t.classList.remove(`${this.Settings.droppedTargetClass}-${this.id}`),t.classList.remove(`${this.Settings.droppableClass}`),t.classList.remove(`${this.Settings.droppableClass}-${this.id}`)})),this.PS.unsubscribe("Interaction:start",this.start),this.PS.unsubscribe("Interaction:end",this.stop),this.isDestroyed=!0}toObject=()=>({id:this.id,element:this.element,droppables:this.droppables,itemsDropped:this.itemsDropped,itemsInside:this.itemsInside});get rect(){if(!this.isDestroyed)return this._rect?this._rect:this._rect=this.element.getBoundingClientRect()}get itemsDropped(){if(!this.isDestroyed)return this._itemsDropped}get itemsInside(){if(!this.isDestroyed)return this._itemsInside||(this._itemsInside=this.droppables.flatMap((t=>{const e=this.DS.SelectableSet.rects.get(t);return this.rect&&p(e,this.rect,this.Settings.dropInsideThreshold)?[t]:[]})),this._timeout&&clearTimeout(this._timeout),this._timeout=setTimeout((()=>this._itemsInside=void 0),this.Settings.refreshMemoryRate)),this._itemsInside}get parentNodes(){return this._parentNodes?this._parentNodes:this._parentNodes=s(this.element)}get droppables(){return this._droppables?this._droppables:this.DS.SelectableSet.elements}set droppables(t){this._droppables=t}}class b{_zoneByElement=new Map;_zoneById=new Map;_zonesByDroppable=new Map;_zones;DS;PS;Settings;constructor({DS:t,PS:e}){this.DS=t,this.PS=e,this.Settings=this.DS.stores.SettingsStore.s,this.PS.subscribe("Settings:updated:dropZones",(({settings:t})=>this.setDropZones(t))),this.setDropZones({dropZones:this.Settings.dropZones}),this.PS.subscribe("Interaction:end",this.stop)}setDropZones=({dropZones:t})=>{t&&(this._zones&&this._zones.forEach((t=>t.destroy())),this._zones=t.map((t=>new m({DS:this.DS,PS:this.PS,...t}))),this._zones.forEach((t=>{this._zoneByElement.set(t.element,t),this._zoneById.set(t.id,t),t.droppables.forEach((e=>{const s=this._zonesByDroppable.get(e);if(!s?.length)return this._zonesByDroppable.set(e,[t]);this._zonesByDroppable.set(e,[...new Set([...s,t])])}))})))};_handleDrops=t=>{this._zones?.forEach((e=>{e!==t&&e.handleNoDrop()})),t&&t.handleDrop()};_getZoneByElementsFromPoint=(t,{x:e,y:s})=>{for(let i=0,r=t.length;i<r;i++){const r=this._zoneByElement.get(t[i]);if(p(r?.rect,{left:e,right:e,top:s,bottom:s},Math.min(this.Settings.dropTargetThreshold,.5)))return r}};stop=({isDragging:t,isDraggingKeyboard:e,event:s})=>{if(!t)return;const i=this.getTarget({isDraggingKeyboard:e,event:s});this._handleDrops(i)};getItemsDroppedById=t=>{const e=this._zoneById.get(t);return e?e.itemsDropped:console.warn(`[DragSelect] No zone found (id: ${t})`)};getItemsInsideById=(t,e)=>{const s=this._zoneById.get(t);return s?(e&&s.handleItemsInsideClasses(),s.itemsInside):console.warn(`[DragSelect] No zone found (id: ${t})`)};getKeyboardItemCenter=(t,e)=>{if(!t||!e)return;const s=e.target?.getBoundingClientRect();return{x:s.left+s.width/2,y:s.top+s.height/2}};getTarget=({coordinates:t,isDraggingKeyboard:e,event:s})=>{if(!this._zones?.length)return;let i;!t&&e&&s&&(i=this.getKeyboardItemCenter(e,s));const r=t?.x||i?.x||this.DS.stores.PointerStore.currentVal.x,n=t?.y||i?.y||this.DS.stores.PointerStore.currentVal.y,o=document.elementsFromPoint(r,n);return this._getZoneByElementsFromPoint(o,{x:r,y:n})}}class y{isInteracting;isDragging=!1;DS;PS;Settings;constructor({DS:t,PS:e}){this.DS=t,this.PS=e,this.Settings=this.DS.stores.SettingsStore.s,this.PS.subscribe("Settings:updated:area",(({settings:t})=>{this.removeAreaEventListeners(t["area:pre"]),this.setAreaEventListeners(t.area)})),this.PS.subscribe("PointerStore:updated",(({event:t})=>this.update({event:t}))),this.PS.subscribe("Selectable:click",this.onClick),this.PS.subscribe("Selectable:pointer",(({event:t})=>this.start(t))),this.PS.subscribe("Interaction:start:pre",(({event:t})=>this._start(t))),this.PS.subscribe("Interaction:init:pre",this._init),this.PS.subscribe("Interaction:end:pre",(({event:t})=>this._reset(t))),this.PS.subscribe("Area:scroll",this.update)}init=()=>this.PS.publish("Interaction:init:pre",{init:!0});_init=()=>{this.stop(),this.setAreaEventListeners(),this.PS.publish("Interaction:init",{init:!0})};_canInteract(t){const e="clientX"in t&&0===t.clientX&&0===t.clientY&&0===t.detail&&t.target;return!("button"in t&&2===t.button||this.isInteracting||t.target&&!this.DS.SelectorArea.isInside(t.target)||!e&&!this.DS.SelectorArea.isClicked(t))}start=t=>this.PS.publish("Interaction:start:pre",{event:t,isDragging:this.isDragging});_start=t=>{"touchstart"===t.type&&t.preventDefault(),this._canInteract(t)&&(this.isInteracting=!0,this.isDragging=this.isDragEvent(t),this.PS.publish("Interaction:start",{event:t,isDragging:this.isDragging}),this.setDocEventListeners())};isDragEvent=t=>{let e=null;return t.target&&"closest"in t.target&&(e=t.target.closest(`.${this.Settings.selectableClass}`)),!(!this.Settings.draggability||this.DS.stores.KeyStore.isMultiSelectKeyPressed(t)||!e)&&(this.Settings.immediateDrag&&(this.DS.SelectedSet.size?this.DS.SelectedSet.has(e)||(this.DS.SelectedSet.clear(),this.DS.SelectedSet.add(e)):this.DS.SelectedSet.add(e)),!!this.DS.SelectedSet.has(e))};onClick=({event:t})=>{if(!this._canInteract(t))return;if(t.detail>0)return;const{stores:{PointerStore:e,KeyStore:s},SelectableSet:i,SelectedSet:r}=this.DS;e.start(t);const n=t.target;n&&!i.has(n)||(s.isMultiSelectKeyPressed(t)||r.clear(),n&&r.toggle(n),this.reset(t))};stop=(t=this.DS.Area.HTMLNode)=>{this.removeAreaEventListeners(t),this.removeDocEventListeners()};update=({event:t,scroll_directions:e,scroll_multiplier:s})=>{this.isInteracting&&this.PS.publish(["Interaction:update:pre","Interaction:update"],{event:t,scroll_directions:e,scroll_multiplier:s,isDragging:this.isDragging})};reset=t=>this.PS.publish("Interaction:end:pre",{event:t,isDragging:this.isDragging});_reset=t=>{const{isDragging:e}=this;this.isInteracting=!1,this.isDragging=!1,this.removeDocEventListeners(),this.PS.publish("Interaction:end",{event:t,isDragging:e})};setAreaEventListeners=(t=this.DS.Area.HTMLNode)=>{this.Settings.usePointerEvents?t.addEventListener("pointerdown",this.start,{passive:!1}):t.addEventListener("mousedown",this.start),t.addEventListener("touchstart",this.start,{passive:!1})};removeAreaEventListeners=(t=this.DS.Area.HTMLNode)=>{this.Settings.usePointerEvents?t.removeEventListener("pointerdown",this.start,{passive:!1}):t.removeEventListener("mousedown",this.start),t.removeEventListener("touchstart",this.start,{passive:!1})};setDocEventListeners=()=>{this.Settings.usePointerEvents?(document.addEventListener("pointerup",this.reset),document.addEventListener("pointercancel",this.reset)):document.addEventListener("mouseup",this.reset),document.addEventListener("touchend",this.reset)};removeDocEventListeners=()=>{this.Settings.usePointerEvents?(document.removeEventListener("pointerup",this.reset),document.removeEventListener("pointercancel",this.reset)):document.removeEventListener("mouseup",this.reset),document.removeEventListener("touchend",this.reset)}}class D{_currentValues=new Set;_keyMapping={control:"ctrlKey",shift:"shiftKey",meta:"metaKey"};DS;PS;settings;constructor({DS:t,PS:e}){this.DS=t,this.PS=e,this.settings=this.DS.stores.SettingsStore.s,this.PS.subscribe("Interaction:init",this.init)}init=()=>{document.addEventListener("keydown",this.keydown),document.addEventListener("keyup",this.keyup),window.addEventListener("blur",this.reset)};keydown=t=>{if(!t.key?.toLocaleLowerCase)return;const e=t.key.toLowerCase();this.PS.publish("KeyStore:down:pre",{event:t,key:e}),this._currentValues.add(e),this.PS.publish("KeyStore:down",{event:t,key:e})};keyup=t=>{if(!t.key?.toLocaleLowerCase)return;const e=t.key.toLowerCase();this.PS.publish("KeyStore:up:pre",{event:t,key:e}),this._currentValues.delete(e),this.PS.publish("KeyStore:up",{event:t,key:e})};stop=()=>{document.removeEventListener("keydown",this.keydown),document.removeEventListener("keyup",this.reset),window.removeEventListener("blur",this.reset),this.reset()};reset=()=>this._currentValues.clear();isMultiSelectKeyPressed(t){if(this.settings.multiSelectMode)return!0;const e=this.settings.multiSelectKeys?.map((t=>t.toLocaleLowerCase()))??[];return!!this.currentValues.some((t=>e.includes(t)))||!(!t||!e.some((e=>t[this._keyMapping[e]])))}get currentValues(){return Array.from(this._currentValues.values())}}class _{_isMouseInteraction=!1;_initialValArea={x:0,y:0};_currentValArea={x:0,y:0};_lastValArea={x:0,y:0};_initialVal={x:0,y:0};_currentVal={x:0,y:0};_lastVal={x:0,y:0};_lastTouch;DS;PS;settings;constructor({DS:t,PS:e}){this.DS=t,this.PS=e,this.settings=this.DS.stores.SettingsStore.s,this.PS.subscribe("Interaction:init",this.init),this.PS.subscribe("Interaction:start",(({event:t})=>this.start(t))),this.PS.subscribe("Interaction:end",(({event:t})=>this.reset(t)))}init=()=>{this.settings.usePointerEvents?document.addEventListener("pointermove",this.update,{passive:!1}):document.addEventListener("mousemove",this.update),document.addEventListener("touchmove",this.update,{passive:!1})};start(t){t&&(this._isMouseInteraction=!0,this.currentVal=this.initialVal=this.getPointerPosition(t))}getPointerPosition=t=>(({event:t})=>({x:t.clientX,y:t.clientY}))({event:this._normalizedEvent(t)});update=t=>{t&&(this.PS.publish("PointerStore:updated:pre",{event:t}),this.currentVal=this.getPointerPosition(t),this._isMouseInteraction&&this.PS.publish("PointerStore:updated",{event:t}))};stop=()=>{this.settings.usePointerEvents?document.removeEventListener("pointermove",this.update,{passive:!1}):document.removeEventListener("mousemove",this.update),document.removeEventListener("touchmove",this.update,{passive:!1}),this.reset()};reset=t=>{this.currentVal=this.lastVal=this.getPointerPosition(t),setTimeout((()=>this._isMouseInteraction=!1),100)};_normalizedEvent(t){return!t||t instanceof KeyboardEvent?{clientX:0,clientY:0}:"touches"in t?("touchend"!==t.type&&(this._lastTouch=t),this._lastTouch?.touches[0]||t.touches[0]):t}get initialValArea(){return this._initialValArea?this._initialValArea:{x:0,y:0}}get currentValArea(){return this._currentValArea?this._currentValArea:{x:0,y:0}}get lastValArea(){return this._lastValArea?this._lastValArea:{x:0,y:0}}get initialVal(){return this._initialVal?this._initialVal:{x:0,y:0}}get currentVal(){return this._currentVal?this._currentVal:{x:0,y:0}}get lastVal(){return this._lastVal?this._lastVal:{x:0,y:0}}set initialVal(t){this._initialVal=t,this._initialValArea=t&&o(t,"-",o(l(this.DS.Area.rect),"+",l(this.DS.Area.computedBorder)))}set currentVal(t){this._currentVal=t,this._currentValArea=t&&o(t,"-",o(l(this.DS.Area.rect),"+",l(this.DS.Area.computedBorder)))}set lastVal(t){this._lastVal=t,this._lastValArea=t&&o(t,"-",o(l(this.DS.Area.rect),"+",l(this.DS.Area.computedBorder)))}}class v{subscribers={};DS;constructor({DS:t}){this.DS=t}subscribe=(t,e)=>{Array.isArray(this.subscribers[t])||(this.subscribers[t]=[]);const s=this.subscribers[t];return s.push(e),s.length-1};unsubscribe=(t,e,s)=>{const i=s??this.subscribers[t]?.findIndex((t=>t===e));this.subscribers[t]?.splice(Number(i),1)};publish=(t,e)=>{Array.isArray(t)?t.forEach((t=>this._publish(t,e))):this._publish(t,e)};_publish=(t,e)=>{const s=this.subscribers[t]??[];t.includes(":pre")?this._handlePrePublish(s,e):this._handlePublish(s,e)};_handlePublish=(t,e)=>{for(let s=0,i=t.length;s<i;s++){if(this.DS.stopped)return;t[s]?.(e)}};_handlePrePublish=(t,e)=>{let s=t.length;for(;s--;){if(this.DS.stopped)return;t[s]?.(e)}}}const P=()=>({y:document.body?.scrollTop||document.documentElement?.scrollTop||0,x:document.body?.scrollLeft||document.documentElement?.scrollLeft||0}),f=t=>!t||t instanceof Document?P():{x:t.scrollLeft>=0?t.scrollLeft:P().x,y:t.scrollTop>=0?t.scrollTop:P().y},I=t=>{const e=t.scrollTop,s=Boolean(t.scrollTop=1);return t.scrollTop=e,s};class L{_initialVal={x:0,y:0};_currentVal={x:0,y:0};_canScroll;DS;PS;Settings;constructor({DS:t,PS:e}){this.DS=t,this.PS=e,this.Settings=this.DS.stores.SettingsStore.s,this.PS.subscribe("Area:modified",(()=>{this.stop(),this.init()})),this.PS.subscribe("Interaction:init",this.init),this.PS.subscribe("Interaction:start",(()=>this.start())),this.PS.subscribe("Interaction:end",(()=>this.reset()))}init=()=>this.addListeners();addListeners=()=>this.DS.Area.HTMLNode.addEventListener("scroll",this.update);removeListeners=()=>this.DS.Area.HTMLNode.removeEventListener("scroll",this.update);start=()=>{this._currentVal=this._initialVal=f(this.DS.Area.HTMLNode)};update=()=>this._currentVal=f(this.DS.Area.HTMLNode);stop=()=>{this.reset(),this.removeListeners()};reset=()=>{this._initialVal={x:0,y:0},this._canScroll=void 0};get canScroll(){return"boolean"==typeof this._canScroll?this._canScroll:this._canScroll=(t=>{const e=f(t);return!(!e.x&&!e.y)||(t instanceof Document?t.body?I(t.body):I(t.documentElement):I(t))})(this.DS.Area.HTMLNode)}get scrollAmount(){const t=o(this.currentVal,"-",this.initialVal),e=h(this.Settings.zoom),s=o(o(t,"*",e),"-",t);return{x:t.x+s.x,y:t.y+s.y}}get initialVal(){return this._initialVal?this._initialVal:{x:0,y:0}}get currentVal(){return this._currentVal||(this._currentVal=f(this.DS.Area.HTMLNode)),this._currentVal}}class T extends Set{_rects;_timeout;DS;PS;Settings;constructor({DS:t,PS:e}){super(),this.DS=t,this.PS=e,this.Settings=this.DS.stores.SettingsStore.s,this.PS.subscribe("Interaction:init",this.init),this.PS.subscribe("Settings:updated:selectables",(()=>{this.clear(),this.init()})),this.PS.subscribe("Settings:updated:selectableClass",(({settings:t})=>{this.forEach((e=>{e.classList.remove(t["selectableClass:pre"]),e.classList.add(t.selectableClass)}))}))}init=()=>g(this.Settings.selectables).forEach((t=>this.add(t)));add(t){if(!t||super.has(t))return this;const e={items:this.elements,item:t};return this.PS.publish("Selectable:added:pre",e),t.classList.add(this.Settings.selectableClass),t.addEventListener("click",this._onClick),this.Settings.usePointerEvents?t.addEventListener("pointerdown",this._onPointer,{passive:!1}):t.addEventListener("mousedown",this._onPointer),t.addEventListener("touchstart",this._onPointer,{passive:!1}),this.Settings.draggability&&!this.Settings.useTransform&&i({computedStyle:window.getComputedStyle(t),node:t}),this.PS.publish("Selectable:added",e),super.add(t)}delete(t){if(!t||!super.has(t))return!0;const e={items:this.elements,item:t};return this.PS.publish("Selectable:removed:pre",e),t.classList.remove(this.Settings.selectableClass),t.classList.remove(this.Settings.hoverClass),t.removeEventListener("click",this._onClick),this.Settings.usePointerEvents?t.removeEventListener("pointerdown",this._onPointer,{passive:!1}):t.removeEventListener("mousedown",this._onPointer),t.removeEventListener("touchstart",this._onPointer,{passive:!1}),this.PS.publish("Selectable:removed",e),super.delete(t)}clear=()=>this.forEach((t=>this.delete(t)));_onClick=t=>this.PS.publish(["Selectable:click:pre","Selectable:click"],{event:t});_onPointer=t=>this.PS.publish(["Selectable:pointer:pre","Selectable:pointer"],{event:t});addAll=t=>t.forEach((t=>this.add(t)));deleteAll=t=>t.forEach((t=>this.delete(t)));getElementRect=t=>this._rects?this._rects.get(t):t.getBoundingClientRect();get elements(){return Array.from(this.values())}get rects(){return this._rects||(this._rects=new Map,this.forEach((t=>this._rects?.set(t,t.getBoundingClientRect()))),this._timeout&&clearTimeout(this._timeout),this._timeout=setTimeout((()=>this._rects=void 0),this.Settings.refreshMemoryRate)),this._rects}}class E extends Set{_rects;_timeout;DS;PS;Settings;constructor({DS:t,PS:e}){super(),this.DS=t,this.PS=e,this.Settings=this.DS.stores.SettingsStore.s}add(t){if(!t||super.has(t))return this;const e={items:this.elements,item:t};return this.PS.publish("Selected:added:pre",e),super.add(t),t.classList.add(this.Settings.selectedClass),this.Settings.useLayers&&(t.style.zIndex=`${(parseInt(t.style.zIndex)||0)+1}`),this.PS.publish("Selected:added",e),this}delete(t){if(!t||!super.has(t))return!0;const e={items:this.elements,item:t};this.PS.publish("Selected:removed:pre",e);const s=super.delete(t);return t.classList.remove(this.Settings.selectedClass),this.Settings.useLayers&&(t.style.zIndex=""+((parseInt(t.style.zIndex)||0)-1)),this.PS.publish("Selected:removed",e),s}clear=()=>this.forEach((t=>this.delete(t)));toggle(t){return this.has(t)?this.delete(t):this.add(t),t}addAll=t=>t.forEach((t=>this.add(t)));deleteAll=t=>t.forEach((t=>this.delete(t)));get elements(){return Array.from(this.values())}get rects(){return this._rects||(this._rects=new Map,this.forEach((t=>this._rects?.set(t,t.getBoundingClientRect()))),this._timeout&&clearTimeout(this._timeout),this._timeout=setTimeout((()=>this._rects=void 0),this.Settings.refreshMemoryRate)),this._rects}}var C=(t,e)=>{e.left&&(t.style.left=`${e.left}px`),e.top&&(t.style.top=`${e.top}px`),e.width&&(t.style.width=`${e.width}px`),e.height&&(t.style.height=`${e.height}px`)};class x{_rect;DS;PS;Settings;HTMLNode;constructor({DS:t,PS:e}){this.DS=t,this.PS=e,this.Settings=this.DS.stores.SettingsStore.s,this.HTMLNode=this.Settings.selector,this.PS.subscribe("Settings:updated:selectorClass",(({settings:t})=>{this.HTMLNode.classList.remove(t["selectorClass:pre"]),this.HTMLNode.classList.add(t.selectorClass)})),this.PS.subscribe("Settings:updated:selector",this.attachSelector),this.PS.subscribe("Settings:updated:customStyles",this.attachSelector),this.attachSelector(),this.PS.subscribe("Interaction:start",this.start),this.PS.subscribe("Interaction:update",this.update),this.PS.subscribe("Interaction:end",this.stop)}attachSelector=()=>{this.HTMLNode&&this.DS.SelectorArea?.HTMLNode&&this.DS.SelectorArea.HTMLNode.removeChild(this.HTMLNode),this.HTMLNode=this.Settings.selector||(t=>{const e=document.createElement("div");return e.style.position="absolute",t||(e.style.background="rgba(0, 175, 255, 0.2)",e.style.border="1px solid rgba(0, 175, 255, 0.8)",e.style.display="none",e.style.pointerEvents="none"),e})(this.Settings.customStyles),this.HTMLNode.classList.add(this.Settings.selectorClass),this.HTMLNode&&this.DS.SelectorArea?.HTMLNode&&this.DS.SelectorArea.HTMLNode.appendChild(this.HTMLNode)};start=({isDragging:t})=>{if(t)return;const{stores:{PointerStore:e}}=this.DS,s=e.initialValArea;C(this.HTMLNode,a(s,1)),this.HTMLNode.style.display="block",this._rect=void 0};stop=()=>{this.HTMLNode.style.width="0",this.HTMLNode.style.height="0",this.HTMLNode.style.display="none"};update=({isDragging:t})=>{if(t||this.DS.continue)return;const{stores:{ScrollStore:e,PointerStore:s}}=this.DS,i=(({scrollAmount:t,initialPointerPos:e,pointerPos:s})=>{const i={};return s.x>e.x-t.x?(i.left=e.x-t.x,i.width=s.x-e.x+t.x):(i.left=s.x,i.width=e.x-s.x-t.x),s.y>e.y-t.y?(i.top=e.y-t.y,i.height=s.y-e.y+t.y):(i.top=s.y,i.height=e.y-s.y-t.y),i})({scrollAmount:e.scrollAmount,initialPointerPos:s.initialValArea,pointerPos:s.currentValArea});C(this.HTMLNode,i),this._rect=void 0};get rect(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}class A{_prevSelectedSet=new Set;_boundingRect;_timeout;DS;PS;Settings;constructor({DS:t,PS:e}){this.DS=t,this.PS=e,this.Settings=this.DS.stores.SettingsStore.s,this.PS.subscribe("Interaction:start",this.start),this.PS.subscribe("Interaction:update",this.update)}_storePrevious(t){const{stores:{KeyStore:e},SelectedSet:s}=this.DS;e.isMultiSelectKeyPressed(t)?this._prevSelectedSet=new Set(s):this._prevSelectedSet=new Set}start=({event:t,isDragging:e})=>{e||(this._storePrevious(t),this._handleInsideSelection(!0,t))};update=({isDragging:t})=>{t||this.DS.continue||this._handleInsideSelection()};_handleInsideSelection=(t,e)=>{const{SelectableSet:s,SelectorArea:i,Selector:r}=this.DS,n=this.DS.stores.KeyStore.isMultiSelectKeyPressed(e)&&this.Settings.multiSelectToggling,o=this.Settings.selectionThreshold,l=s.rects,a=r.rect,h=new Map,c=new Map;for(const[t,e]of l)i.isInside(t,e)&&(p(e,a,o)?h.set(t,e):c.set(t,e));if(this.DS.continue)return;const{select:d,unselect:S}=this.filterSelected({select:h,unselect:c,selectorRect:a});d.forEach(((e,s)=>(({element:t,force:e,multiSelectionToggle:s,SelectedSet:i,hoverClassName:r})=>{t.classList.contains(r)&&!e||(i.has(t)?s&&i.delete(t):i.add(t),t.classList.add(r))})({element:s,force:t,multiSelectionToggle:n,SelectedSet:this.DS.SelectedSet,hoverClassName:this.Settings.hoverClass}))),S.forEach(((e,s)=>(({element:t,force:e,SelectedSet:s,PrevSelectedSet:i,hoverClassName:r})=>{if(!t.classList.contains(r)&&!e)return;const n=s.has(t),o=i.has(t);n&&!o?s.delete(t):!n&&o&&s.add(t),t.classList.remove(r)})({element:s,force:t,SelectedSet:this.DS.SelectedSet,hoverClassName:this.Settings.hoverClass,PrevSelectedSet:this._prevSelectedSet})))};get boundingRect(){return this._boundingRect||(this._boundingRect=(t=>{const e={top:Number.POSITIVE_INFINITY,left:Number.POSITIVE_INFINITY,bottom:Number.NEGATIVE_INFINITY,right:Number.NEGATIVE_INFINITY,width:Number.NEGATIVE_INFINITY,height:Number.NEGATIVE_INFINITY};return t.rects.forEach((t=>{e.top=Math.min(e.top,t.top||e.top),e.left=Math.min(e.left,t.left||e.left),e.bottom=Math.max(e.bottom,t.bottom||e.bottom),e.right=Math.max(e.right,t.right||e.right)})),e.height=e.bottom-e.top,e.width=e.right-e.left,e})(this.DS.SelectedSet),this._timeout&&clearTimeout(this._timeout),this._timeout=setTimeout((()=>this._boundingRect=void 0),this.Settings.refreshMemoryRate)),this._boundingRect}filterSelected=({select:t,unselect:e,selectorRect:s})=>({select:t,unselect:e})}class w{_scrollInterval;_rect;currentEdges=[];DS;PS;Settings;HTMLNode;constructor({DS:t,PS:e}){this.DS=t,this.PS=e,this.Settings=this.DS.stores.SettingsStore.s,this.HTMLNode=(()=>{const t=document.createElement("div");return t.style.position="fixed",t.style.overflow="hidden",t.style.pointerEvents="none",t.style.zIndex="999999999999999999",t})(),this.PS.subscribe("Settings:updated:selectorAreaClass",(({settings:t})=>{this.HTMLNode.classList.remove(t["selectorAreaClass:pre"]),this.HTMLNode.classList.add(t.selectorAreaClass)})),this.HTMLNode.classList.add(this.Settings.selectorAreaClass),this.PS.subscribe("Area:modified",this.updatePos),this.PS.subscribe("Area:modified",this.updatePos),this.PS.subscribe("Interaction:init",this.init),this.PS.subscribe("Interaction:start",(({isDraggingKeyboard:t})=>this.startAutoScroll({isDraggingKeyboard:t}))),this.PS.subscribe("Interaction:end",(()=>{this.updatePos(),this.stopAutoScroll()}))}init=()=>{this.applyElements("append"),this.updatePos()};applyElements=t=>{const e=document.body?"body":"documentElement",s=`${t}Child`;this.HTMLNode[s](this.DS.Selector.HTMLNode),document[e][s](this.HTMLNode)};updatePos=()=>{this._rect=void 0;const t=this.DS.Area.rect,e=this.DS.Area.computedBorder,{style:s}=this.HTMLNode,i=`${t.top+e.top}px`,r=`${t.left+e.left}px`,n=`${t.width}px`,o=`${t.height}px`;s.top!==i&&(s.top=i),s.left!==r&&(s.left=r),s.width!==n&&(s.width=n),s.height!==o&&(s.height=o)};stop=t=>{this.stopAutoScroll(),t&&this.applyElements("remove")};startAutoScroll=({isDraggingKeyboard:t})=>{t||(this.currentEdges=[],this._scrollInterval=setInterval((()=>this.handleAutoScroll()),16))};handleAutoScroll=()=>{if(this.DS.continue)return;const{stores:{PointerStore:t},Area:e}=this.DS;this.currentEdges=(({elementRect:t,containerRect:e,tolerance:s={x:0,y:0}})=>{const i=[];return t.top-s.y<e.top&&i.push("top"),t.left-s.x<e.left&&i.push("left"),t.bottom+s.y>e.bottom&&i.push("bottom"),t.right+s.y>e.right&&i.push("right"),i})({elementRect:a(t.currentVal),containerRect:this.rect,tolerance:this.Settings.overflowTolerance}),this.currentEdges.length&&e.scroll(this.currentEdges,this.Settings.autoScrollSpeed)};stopAutoScroll=()=>{this.currentEdges=[],clearInterval(this._scrollInterval)};isInside=(t,e)=>!(!this.DS.Area.HTMLNode.contains(t)||!this.DS.stores.ScrollStore.canScroll)||p(this.rect,e||t.getBoundingClientRect());isClicked(t){const{stores:{PointerStore:e}}=this.DS,s=t?e.getPointerPosition(t):e.initialVal;return p({left:s.x,top:s.y,right:s.x,bottom:s.y},this.rect)}get rect(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}const N=(t,e)=>console.warn(`[DragSelect] TypeIssue: setting "${t}" is not of type "${e}".`),M=(t,e,s,i)=>{if(void 0===e)return s?{[t]:i}:{};if(null===e)return{[t]:null};let r=!0,n=!1;const o="string"==typeof i;o&&(r="string"==typeof e||e instanceof String),o&&!r&&(n=!0,N(t,"string"));const l=!Number.isNaN(i)&&"number"==typeof i;l&&(r=!Number.isNaN(e)&&"number"==typeof e),l&&!r&&(n=!0,N(t,"number"));const a="[object Object]"===Object.prototype.toString.call(i);a&&(r="[object Object]"===Object.prototype.toString.call(e)),a&&!r&&(n=!0,N(t,"object"));const h="boolean"==typeof i;h&&(r="boolean"==typeof e),h&&!r&&(n=!0,N(t,"boolean"));const c=Array.isArray(i);c&&(r=Array.isArray(e)),c&&!r&&(n=!0,N(t,"array"));const d=n||s;return"dragKeys"===t&&r?{[t]:Object.assign(i,e)}:"dragKeys"!==t||r?("dropZones"===t&&r&&Array.isArray(e)&&new Set(e.map((t=>t.id))).size!==e.length&&console.warn('[DragSelect] UniqueConstraintsIssue: setting "dropZones" contains duplicate ids.'),r?{[t]:e}:d?{[t]:i}:{}):d?{[t]:i}:{}};class V{_settings={};s={};PS;constructor({PS:t,settings:e}){this.PS=t,this.update({settings:e,init:!0})}update=({settings:t,init:e})=>{this.PS.publish("Settings:updated:pre",{settings:this._settings,"settings:init":Boolean(e),"settings:new":t}),this._update({settings:t,init:e})};_update=({settings:t={},init:e=!1})=>{const s=((t,e)=>({...M("area",t.area,e,document),...M("selectables",t.selectables,e,null),...M("autoScrollSpeed",t.autoScrollSpeed,e,5),...M("overflowTolerance",t.overflowTolerance,e,{x:25,y:25}),...M("zoom",t.zoom,e,1),...M("customStyles",t.customStyles,e,!1),...M("multiSelectMode",t.multiSelectMode,e,!1),...M("multiSelectToggling",t.multiSelectToggling,e,!0),...M("multiSelectKeys",t.multiSelectKeys,e,["Control","Shift","Meta"]),...M("selector",t.selector,e,null),...M("selectionThreshold",t.selectionThreshold,e,0),...M("draggability",t.draggability,e,!0),...M("immediateDrag",t.immediateDrag,e,!0),...M("keyboardDrag",t.keyboardDrag,e,!0),...M("dragKeys",t.dragKeys,e,{up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]}),...M("keyboardDragSpeed",t.keyboardDragSpeed,e,10),...M("useTransform",t.useTransform,e,!0),...M("refreshMemoryRate",t.refreshMemoryRate,e,80),...M("dropZones",t.dropZones,e,[]),...M("dropInsideThreshold",t.dropInsideThreshold,e,1),...M("dropTargetThreshold",t.dropTargetThreshold,e,0),...M("usePointerEvents",t.usePointerEvents,e,!1),...M("hoverClass",t.hoverClass,e,"ds-hover"),...M("selectableClass",t.selectableClass,e,"ds-selectable"),...M("selectedClass",t.selectedClass,e,"ds-selected"),...M("selectorClass",t.selectorClass,e,"ds-selector"),...M("selectorAreaClass",t.selectorAreaClass,e,"ds-selector-area"),...M("droppedTargetClass",t.droppedTargetClass,e,"ds-dropped-target"),...M("droppedInsideClass",t.droppedInsideClass,e,"ds-dropped-inside"),...M("droppableClass",t.droppableClass,e,"ds-droppable"),...M("dropZoneClass",t.dropZoneClass,e,"ds-dropzone"),...M("dropZoneReadyClass",t.dropZoneReadyClass,e,"ds-dropzone-ready"),...M("dropZoneTargetClass",t.dropZoneTargetClass,e,"ds-dropzone-target"),...M("dropZoneInsideClass",t.dropZoneInsideClass,e,"ds-dropzone-inside"),...M("useLayers",t.useLayers,e,!0)}))(t,e);for(const[i,r]of Object.entries(s))((s,i)=>{s in this._settings||Object.defineProperty(this.s,s,{get:()=>this._settings[s],set:t=>this.update({settings:{[s]:t}})}),this._settings[`${s}:pre`]=this._settings[s],this._settings[s]=i;const r={settings:this._settings,"settings:init":e,"settings:new":t};this.PS.publish("Settings:updated",r),this.PS.publish(`Settings:updated:${s}`,r)})(i,r)}}const K={elementselect:"DS:select",elementunselect:"DS:unselect",autoscroll:"DS:scroll",dragstart:"DS:start",dragmove:"DS:update",callback:"DS:end",preelementselect:"DS:select:pre",preelementunselect:"DS:unselect:pre",preautoscroll:"DS:scroll:pre",predragstart:"DS:start:pre",predragmove:"DS:update:pre",precallback:"DS:end:pre"},k=(t,e)=>{const s=e.DropZones.getTarget(t);return{...t,...s?{dropTarget:s.toObject()}:{}}},R=({sub_name:t,DS:e,PS:s,sub_pubs:i})=>{s.subscribe(t,(t=>i.forEach((s=>H({sub_pub:s,data:t,DS:e})))))},H=({sub_pub:t,data:e,DS:s})=>{const i=t.condition?t.condition(e,s):e;if(i){const r=t.extraData&&t.extraData(e,s)||{};s.publish(t.name,{items:s.SelectedSet.elements,isDragging:s.Interaction.isDragging,...i,...r})}};class ${continue=!1;PubSub;stores;Area;Selector;SelectorArea;SelectableSet;SelectedSet;Selection;Drag;DropZones;Interaction;stopped;constructor(t){this.stopped=!1,this.PubSub=new v({DS:this}),this.stores={},this.stores.SettingsStore=new V({settings:t,PS:this.PubSub}),this.stores.PointerStore=new _({DS:this,PS:this.PubSub}),this.stores.ScrollStore=new L({DS:this,PS:this.PubSub}),this.stores.KeyStore=new D({DS:this,PS:this.PubSub}),this.Area=new n({DS:this,PS:this.PubSub}),this.Selector=new x({DS:this,PS:this.PubSub}),this.SelectorArea=new w({DS:this,PS:this.PubSub}),this.SelectableSet=new T({DS:this,PS:this.PubSub}),this.SelectedSet=new E({DS:this,PS:this.PubSub}),this.Selection=new A({DS:this,PS:this.PubSub}),this.Drag=new u({DS:this,PS:this.PubSub}),this.DropZones=new b({DS:this,PS:this.PubSub}),this.Interaction=new y({DS:this,PS:this.PubSub}),(({PS:t,DS:e})=>{const s={"Selected:added":[{name:"preelementselect"},{name:"elementselect"},{name:"DS:select:pre"},{name:"DS:select"}],"Selected:removed":[{name:"preelementunselect"},{name:"elementunselect"},{name:"DS:unselect:pre"},{name:"DS:unselect"}],"Selectable:added":[{name:"DS:added:pre"},{name:"DS:added"}],"Selectable:removed":[{name:"DS:removed:pre"},{name:"DS:removed"}],"Area:scroll":[{name:"preautoscroll"},{name:"autoscroll"},{name:"DS:scroll:pre"},{name:"DS:scroll"}],"Interaction:start":[{name:"predragstart"},{name:"dragstart"},{name:"DS:start:pre"},{name:"DS:start"}],"Interaction:update":[{name:"predragmove",condition:t=>t.event?t:null},{name:"dragmove",condition:t=>t.event?t:null},{name:"DS:update:pre",condition:t=>t.event?t:null},{name:"DS:update",condition:t=>t.event?t:null}],"Interaction:end":[{name:"precallback",extraData:(t,e)=>k(t,e)},{name:"callback",extraData:(t,e)=>k(t,e)},{name:"DS:end:pre",extraData:(t,e)=>k(t,e)},{name:"DS:end",extraData:(t,e)=>k(t,e)}]};for(const[i,r]of Object.entries(s))R({sub_name:i,sub_pubs:r,DS:e,PS:t})})({DS:this,PS:this.PubSub}),this.PubSub.subscribe("Interaction:end",(()=>this.continue=!1)),this.PubSub.subscribe("DS:end",(({items:t})=>this.continue=!1)),this.start()}static isCollision;subscribe=(t,e)=>(K[t]&&console.warn(`[DragSelect]: The event name "${t}" is deprecated and was/will be removed in a future version. Please use the new event name "${K[t]}" instead.`),this.PubSub.subscribe(t,e));unsubscribe=(t,e,s)=>this.PubSub.unsubscribe(t,e,s);publish=(t,e)=>this.PubSub.publish(t,e);start=()=>{this.stopped=!1,this.Interaction.init()};stop(t=!0,e=!0,s=!1){s&&this.publish("DS:end",{items:this.SelectedSet.elements,isDragging:this.Interaction.isDragging}),this.Interaction.stop(),this.Area.stop(),this.Drag.stop(),this.Selector.stop(),this.SelectorArea.stop(t),this.stores.KeyStore.stop(),this.stores.PointerStore.stop(),this.stores.ScrollStore.stop(),t&&this.SelectableSet.clear(),e&&this.SelectedSet.clear(),this.stopped=!0}break=()=>this.continue=!0;setSettings=t=>this.stores.SettingsStore.update({settings:t});getSelection=()=>this.SelectedSet.elements;addSelection(t,e=!1,s=!1){const i=g(t);return this.SelectedSet.addAll(i),s||this.addSelectables(t,!1,!1),e&&this.PubSub.publish("DS:end",{items:this.SelectedSet.elements,isDragging:this.Interaction.isDragging}),this.getSelection()}removeSelection(t,e=!1,s=!1){const i=g(t);return this.SelectedSet.deleteAll(i),s&&this.removeSelectables(t,!1,!1),e&&this.PubSub.publish("DS:end",{items:this.SelectedSet.elements,isDragging:this.Interaction.isDragging}),this.getSelection()}toggleSelection(t,e=!1,s=!1){return g(t).forEach((i=>this.SelectedSet.has(i)?this.removeSelection(t,e,s):this.addSelection(t,e,s))),e&&this.PubSub.publish("DS:end",{items:this.SelectedSet.elements,isDragging:this.Interaction.isDragging}),this.getSelection()}setSelection(t,e=!1,s=!1){return this.clearSelection(),this.addSelection(t,e,s),this.getSelection()}clearSelection(t=!1){return this.SelectedSet.clear(),t&&this.PubSub.publish("DS:end",{items:this.SelectedSet.elements,isDragging:this.Interaction.isDragging}),this.getSelection()}addSelectables(t,e,s){const i=g(t);return this.SelectableSet.addAll(i),e&&this.SelectedSet.addAll(i),s&&this.PubSub.publish("DS:end",{items:this.SelectedSet.elements,isDragging:this.Interaction.isDragging}),i}getSelectables=()=>this.SelectableSet.elements;removeSelectables(t,e,s){const i=g(t);return this.SelectableSet.deleteAll(i),e&&this.removeSelection(t),s&&this.PubSub.publish("DS:end",{items:this.SelectedSet.elements,isDragging:this.Interaction.isDragging}),i}getInitialCursorPosition=()=>this.stores.PointerStore.initialVal;getCurrentCursorPosition=()=>this.stores.PointerStore.currentVal;getPreviousCursorPosition=()=>this.stores.PointerStore.lastVal;getInitialCursorPositionArea=()=>this.stores.PointerStore.initialValArea;getCurrentCursorPositionArea=()=>this.stores.PointerStore.currentValArea;getPreviousCursorPositionArea=()=>this.stores.PointerStore.lastValArea;isMultiSelect=t=>this.stores.KeyStore.isMultiSelectKeyPressed(t);isDragging=()=>this.Interaction.isDragging;getZoneByCoordinates=t=>this.DropZones.getTarget({coordinates:t})?.toObject();getItemsDroppedByZoneId=t=>this.DropZones.getItemsDroppedById(t);getItemsInsideByZoneId=(t,e)=>this.DropZones.getItemsInsideById(t,e)}$.isCollision=p;export{$ as default};
|