UNPKG

347 kBJavaScriptView Raw
1"use strict";
2
3function _typeof2(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); }
4
5/**
6 * interact.js 1.9.19
7 *
8 * Copyright (c) 2012-present Taye Adeyemi <dev@taye.me>
9 * Released under the MIT License.
10 * https://raw.github.com/taye/interact.js/master/LICENSE
11 */
12(function (f) {
13 if ((typeof exports === "undefined" ? "undefined" : _typeof2(exports)) === "object" && typeof module !== "undefined") {
14 module.exports = f();
15 } else if (typeof define === "function" && define.amd) {
16 define([], f);
17 } else {
18 var g;
19
20 if (typeof window !== "undefined") {
21 g = window;
22 } else if (typeof global !== "undefined") {
23 g = global;
24 } else if (typeof self !== "undefined") {
25 g = self;
26 } else {
27 g = this;
28 }
29
30 g.interact = f();
31 }
32})(function () {
33 var define, module, exports;
34 var _$isWindow_77 = {};
35 "use strict";
36
37 Object.defineProperty(_$isWindow_77, "__esModule", {
38 value: true
39 });
40 _$isWindow_77["default"] = void 0;
41
42 var _default = function _default(thing) {
43 return !!(thing && thing.Window) && thing instanceof thing.Window;
44 };
45
46 _$isWindow_77["default"] = _default;
47 var _$window_84 = {};
48 "use strict";
49
50 Object.defineProperty(_$window_84, "__esModule", {
51 value: true
52 });
53 _$window_84.init = init;
54 _$window_84.getWindow = getWindow;
55 _$window_84["default"] = void 0;
56 /* removed: var _$isWindow_77 = require("./isWindow.js"); */
57
58 ;
59 var win = {
60 realWindow: undefined,
61 window: undefined,
62 getWindow: getWindow,
63 init: init
64 };
65
66 function init(window) {
67 // get wrapped window if using Shadow DOM polyfill
68 win.realWindow = window; // create a TextNode
69
70 var el = window.document.createTextNode(''); // check if it's wrapped by a polyfill
71
72 if (el.ownerDocument !== window.document && typeof window.wrap === 'function' && window.wrap(el) === el) {
73 // use wrapped window
74 window = window.wrap(window);
75 }
76
77 win.window = window;
78 }
79
80 if (typeof window === 'undefined') {
81 win.window = undefined;
82 win.realWindow = undefined;
83 } else {
84 init(window);
85 }
86
87 function getWindow(node) {
88 if ((0, _$isWindow_77["default"])(node)) {
89 return node;
90 }
91
92 var rootNode = node.ownerDocument || node;
93 return rootNode.defaultView || win.window;
94 }
95
96 win.init = init;
97 var ___default_84 = win;
98 _$window_84["default"] = ___default_84;
99 var _$is_76 = {};
100 "use strict";
101
102 Object.defineProperty(_$is_76, "__esModule", {
103 value: true
104 });
105 _$is_76["default"] = void 0;
106 /* removed: var _$isWindow_77 = require("./isWindow.js"); */
107
108 ;
109 /* removed: var _$window_84 = require("./window.js"); */
110
111 ;
112
113 function _typeof(obj) {
114 "@babel/helpers - typeof";
115
116 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
117 _typeof = function _typeof(obj) {
118 return typeof obj;
119 };
120 } else {
121 _typeof = function _typeof(obj) {
122 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
123 };
124 }
125
126 return _typeof(obj);
127 }
128
129 var __window_76 = function window(thing) {
130 return thing === _$window_84["default"].window || (0, _$isWindow_77["default"])(thing);
131 };
132
133 var docFrag = function docFrag(thing) {
134 return object(thing) && thing.nodeType === 11;
135 };
136
137 var object = function object(thing) {
138 return !!thing && _typeof(thing) === 'object';
139 };
140
141 var func = function func(thing) {
142 return typeof thing === 'function';
143 };
144
145 var number = function number(thing) {
146 return typeof thing === 'number';
147 };
148
149 var bool = function bool(thing) {
150 return typeof thing === 'boolean';
151 };
152
153 var string = function string(thing) {
154 return typeof thing === 'string';
155 };
156
157 var element = function element(thing) {
158 if (!thing || _typeof(thing) !== 'object') {
159 return false;
160 } // eslint-disable-next-line import/no-named-as-default-member
161
162
163 var _window = _$window_84["default"].getWindow(thing) || _$window_84["default"].window;
164
165 return /object|function/.test(_typeof(_window.Element)) ? thing instanceof _window.Element // DOM2
166 : thing.nodeType === 1 && typeof thing.nodeName === 'string';
167 };
168
169 var plainObject = function plainObject(thing) {
170 return object(thing) && !!thing.constructor && /function Object\b/.test(thing.constructor.toString());
171 };
172
173 var array = function array(thing) {
174 return object(thing) && typeof thing.length !== 'undefined' && func(thing.splice);
175 };
176
177 var ___default_76 = {
178 window: __window_76,
179 docFrag: docFrag,
180 object: object,
181 func: func,
182 number: number,
183 bool: bool,
184 string: string,
185 element: element,
186 plainObject: plainObject,
187 array: array
188 };
189 _$is_76["default"] = ___default_76;
190 var _$plugin_1 = {};
191 "use strict";
192
193 Object.defineProperty(_$plugin_1, "__esModule", {
194 value: true
195 });
196 _$plugin_1["default"] = void 0;
197 /* removed: var _$is_76 = require("../../utils/is.js"); */
198
199 ;
200
201 function install(scope) {
202 var actions = scope.actions,
203 Interactable = scope.Interactable,
204 defaults = scope.defaults;
205 Interactable.prototype.draggable = drag.draggable;
206 actions.map.drag = drag;
207 actions.methodDict.drag = 'draggable';
208 defaults.actions.drag = drag.defaults;
209 }
210
211 function beforeMove(_ref) {
212 var interaction = _ref.interaction;
213
214 if (interaction.prepared.name !== 'drag') {
215 return;
216 }
217
218 var axis = interaction.prepared.axis;
219
220 if (axis === 'x') {
221 interaction.coords.cur.page.y = interaction.coords.start.page.y;
222 interaction.coords.cur.client.y = interaction.coords.start.client.y;
223 interaction.coords.velocity.client.y = 0;
224 interaction.coords.velocity.page.y = 0;
225 } else if (axis === 'y') {
226 interaction.coords.cur.page.x = interaction.coords.start.page.x;
227 interaction.coords.cur.client.x = interaction.coords.start.client.x;
228 interaction.coords.velocity.client.x = 0;
229 interaction.coords.velocity.page.x = 0;
230 }
231 }
232
233 function move(_ref2) {
234 var iEvent = _ref2.iEvent,
235 interaction = _ref2.interaction;
236
237 if (interaction.prepared.name !== 'drag') {
238 return;
239 }
240
241 var axis = interaction.prepared.axis;
242
243 if (axis === 'x' || axis === 'y') {
244 var opposite = axis === 'x' ? 'y' : 'x';
245 iEvent.page[opposite] = interaction.coords.start.page[opposite];
246 iEvent.client[opposite] = interaction.coords.start.client[opposite];
247 iEvent.delta[opposite] = 0;
248 }
249 }
250 /**
251 * ```js
252 * interact(element).draggable({
253 * onstart: function (event) {},
254 * onmove : function (event) {},
255 * onend : function (event) {},
256 *
257 * // the axis in which the first movement must be
258 * // for the drag sequence to start
259 * // 'xy' by default - any direction
260 * startAxis: 'x' || 'y' || 'xy',
261 *
262 * // 'xy' by default - don't restrict to one axis (move in any direction)
263 * // 'x' or 'y' to restrict movement to either axis
264 * // 'start' to restrict movement to the axis the drag started in
265 * lockAxis: 'x' || 'y' || 'xy' || 'start',
266 *
267 * // max number of drags that can happen concurrently
268 * // with elements of this Interactable. Infinity by default
269 * max: Infinity,
270 *
271 * // max number of drags that can target the same element+Interactable
272 * // 1 by default
273 * maxPerElement: 2
274 * })
275 *
276 * var isDraggable = interact('element').draggable(); // true
277 * ```
278 *
279 * Get or set whether drag actions can be performed on the target
280 *
281 * @alias Interactable.prototype.draggable
282 *
283 * @param {boolean | object} [options] true/false or An object with event
284 * listeners to be fired on drag events (object makes the Interactable
285 * draggable)
286 * @return {boolean | Interactable} boolean indicating if this can be the
287 * target of drag events, or this Interctable
288 */
289
290
291 var draggable = function draggable(options) {
292 if (_$is_76["default"].object(options)) {
293 this.options.drag.enabled = options.enabled !== false;
294 this.setPerAction('drag', options);
295 this.setOnEvents('drag', options);
296
297 if (/^(xy|x|y|start)$/.test(options.lockAxis)) {
298 this.options.drag.lockAxis = options.lockAxis;
299 }
300
301 if (/^(xy|x|y)$/.test(options.startAxis)) {
302 this.options.drag.startAxis = options.startAxis;
303 }
304
305 return this;
306 }
307
308 if (_$is_76["default"].bool(options)) {
309 this.options.drag.enabled = options;
310 return this;
311 }
312
313 return this.options.drag;
314 };
315
316 var drag = {
317 id: 'actions/drag',
318 install: install,
319 listeners: {
320 'interactions:before-action-move': beforeMove,
321 'interactions:action-resume': beforeMove,
322 // dragmove
323 'interactions:action-move': move,
324 'auto-start:check': function autoStartCheck(arg) {
325 var interaction = arg.interaction,
326 interactable = arg.interactable,
327 buttons = arg.buttons;
328 var dragOptions = interactable.options.drag;
329
330 if (!(dragOptions && dragOptions.enabled) || // check mouseButton setting if the pointer is down
331 interaction.pointerIsDown && /mouse|pointer/.test(interaction.pointerType) && (buttons & interactable.options.drag.mouseButtons) === 0) {
332 return undefined;
333 }
334
335 arg.action = {
336 name: 'drag',
337 axis: dragOptions.lockAxis === 'start' ? dragOptions.startAxis : dragOptions.lockAxis
338 };
339 return false;
340 }
341 },
342 draggable: draggable,
343 beforeMove: beforeMove,
344 move: move,
345 defaults: {
346 startAxis: 'xy',
347 lockAxis: 'xy'
348 },
349 getCursor: function getCursor() {
350 return 'move';
351 }
352 };
353 var ___default_1 = drag;
354 _$plugin_1["default"] = ___default_1;
355 var _$domObjects_70 = {};
356 "use strict";
357
358 Object.defineProperty(_$domObjects_70, "__esModule", {
359 value: true
360 });
361 _$domObjects_70["default"] = void 0;
362 var domObjects = {
363 init: __init_70,
364 document: null,
365 DocumentFragment: null,
366 SVGElement: null,
367 SVGSVGElement: null,
368 SVGElementInstance: null,
369 Element: null,
370 HTMLElement: null,
371 Event: null,
372 Touch: null,
373 PointerEvent: null
374 };
375
376 function blank() {}
377
378 var ___default_70 = domObjects;
379 _$domObjects_70["default"] = ___default_70;
380
381 function __init_70(window) {
382 var win = window;
383 domObjects.document = win.document;
384 domObjects.DocumentFragment = win.DocumentFragment || blank;
385 domObjects.SVGElement = win.SVGElement || blank;
386 domObjects.SVGSVGElement = win.SVGSVGElement || blank;
387 domObjects.SVGElementInstance = win.SVGElementInstance || blank;
388 domObjects.Element = win.Element || blank;
389 domObjects.HTMLElement = win.HTMLElement || domObjects.Element;
390 domObjects.Event = win.Event;
391 domObjects.Touch = win.Touch || blank;
392 domObjects.PointerEvent = win.PointerEvent || win.MSPointerEvent;
393 }
394
395 var _$browser_67 = {};
396 "use strict";
397
398 Object.defineProperty(_$browser_67, "__esModule", {
399 value: true
400 });
401 _$browser_67["default"] = void 0;
402 /* removed: var _$domObjects_70 = require("./domObjects.js"); */
403
404 ;
405 /* removed: var _$is_76 = require("./is.js"); */
406
407 ;
408 /* removed: var _$window_84 = require("./window.js"); */
409
410 ;
411 var browser = {
412 init: __init_67,
413 supportsTouch: null,
414 supportsPointerEvent: null,
415 isIOS7: null,
416 isIOS: null,
417 isIe9: null,
418 isOperaMobile: null,
419 prefixedMatchesSelector: null,
420 pEventTypes: null,
421 wheelEvent: null
422 };
423
424 function __init_67(window) {
425 var Element = _$domObjects_70["default"].Element;
426 var navigator = _$window_84["default"].window.navigator; // Does the browser support touch input?
427
428 browser.supportsTouch = 'ontouchstart' in window || _$is_76["default"].func(window.DocumentTouch) && _$domObjects_70["default"].document instanceof window.DocumentTouch; // Does the browser support PointerEvents
429
430 browser.supportsPointerEvent = navigator.pointerEnabled !== false && !!_$domObjects_70["default"].PointerEvent;
431 browser.isIOS = /iP(hone|od|ad)/.test(navigator.platform); // scrolling doesn't change the result of getClientRects on iOS 7
432
433 browser.isIOS7 = /iP(hone|od|ad)/.test(navigator.platform) && /OS 7[^\d]/.test(navigator.appVersion);
434 browser.isIe9 = /MSIE 9/.test(navigator.userAgent); // Opera Mobile must be handled differently
435
436 browser.isOperaMobile = navigator.appName === 'Opera' && browser.supportsTouch && /Presto/.test(navigator.userAgent); // prefix matchesSelector
437
438 browser.prefixedMatchesSelector = 'matches' in Element.prototype ? 'matches' : 'webkitMatchesSelector' in Element.prototype ? 'webkitMatchesSelector' : 'mozMatchesSelector' in Element.prototype ? 'mozMatchesSelector' : 'oMatchesSelector' in Element.prototype ? 'oMatchesSelector' : 'msMatchesSelector';
439 browser.pEventTypes = browser.supportsPointerEvent ? _$domObjects_70["default"].PointerEvent === window.MSPointerEvent ? {
440 up: 'MSPointerUp',
441 down: 'MSPointerDown',
442 over: 'mouseover',
443 out: 'mouseout',
444 move: 'MSPointerMove',
445 cancel: 'MSPointerCancel'
446 } : {
447 up: 'pointerup',
448 down: 'pointerdown',
449 over: 'pointerover',
450 out: 'pointerout',
451 move: 'pointermove',
452 cancel: 'pointercancel'
453 } : null; // because Webkit and Opera still use 'mousewheel' event type
454
455 browser.wheelEvent = 'onmousewheel' in _$domObjects_70["default"].document ? 'mousewheel' : 'wheel';
456 }
457
458 var ___default_67 = browser;
459 _$browser_67["default"] = ___default_67;
460 var _$domUtils_71 = {};
461 "use strict";
462
463 Object.defineProperty(_$domUtils_71, "__esModule", {
464 value: true
465 });
466 _$domUtils_71.nodeContains = nodeContains;
467 _$domUtils_71.closest = closest;
468 _$domUtils_71.parentNode = parentNode;
469 _$domUtils_71.matchesSelector = matchesSelector;
470 _$domUtils_71.indexOfDeepestElement = indexOfDeepestElement;
471 _$domUtils_71.matchesUpTo = matchesUpTo;
472 _$domUtils_71.getActualElement = getActualElement;
473 _$domUtils_71.getScrollXY = getScrollXY;
474 _$domUtils_71.getElementClientRect = getElementClientRect;
475 _$domUtils_71.getElementRect = getElementRect;
476 _$domUtils_71.getPath = getPath;
477 _$domUtils_71.trySelector = trySelector;
478 /* removed: var _$browser_67 = require("./browser.js"); */
479
480 ;
481 /* removed: var _$domObjects_70 = require("./domObjects.js"); */
482
483 ;
484 /* removed: var _$is_76 = require("./is.js"); */
485
486 ;
487 /* removed: var _$window_84 = require("./window.js"); */
488
489 ;
490
491 function nodeContains(parent, child) {
492 while (child) {
493 if (child === parent) {
494 return true;
495 }
496
497 child = child.parentNode;
498 }
499
500 return false;
501 }
502
503 function closest(element, selector) {
504 while (_$is_76["default"].element(element)) {
505 if (matchesSelector(element, selector)) {
506 return element;
507 }
508
509 element = parentNode(element);
510 }
511
512 return null;
513 }
514
515 function parentNode(node) {
516 var parent = node.parentNode;
517
518 if (_$is_76["default"].docFrag(parent)) {
519 // skip past #shado-root fragments
520 // tslint:disable-next-line
521 while ((parent = parent.host) && _$is_76["default"].docFrag(parent)) {
522 continue;
523 }
524
525 return parent;
526 }
527
528 return parent;
529 }
530
531 function matchesSelector(element, selector) {
532 // remove /deep/ from selectors if shadowDOM polyfill is used
533 if (_$window_84["default"].window !== _$window_84["default"].realWindow) {
534 selector = selector.replace(/\/deep\//g, ' ');
535 }
536
537 return element[_$browser_67["default"].prefixedMatchesSelector](selector);
538 }
539
540 var getParent = function getParent(el) {
541 return el.parentNode || el.host;
542 }; // Test for the element that's "above" all other qualifiers
543
544
545 function indexOfDeepestElement(elements) {
546 var deepestNodeParents = [];
547 var deepestNodeIndex;
548
549 for (var i = 0; i < elements.length; i++) {
550 var currentNode = elements[i];
551 var deepestNode = elements[deepestNodeIndex]; // node may appear in elements array multiple times
552
553 if (!currentNode || i === deepestNodeIndex) {
554 continue;
555 }
556
557 if (!deepestNode) {
558 deepestNodeIndex = i;
559 continue;
560 }
561
562 var currentNodeParent = getParent(currentNode);
563 var deepestNodeParent = getParent(deepestNode); // check if the deepest or current are document.documentElement/rootElement
564 // - if the current node is, do nothing and continue
565
566 if (currentNodeParent === currentNode.ownerDocument) {
567 continue;
568 } // - if deepest is, update with the current node and continue to next
569 else if (deepestNodeParent === currentNode.ownerDocument) {
570 deepestNodeIndex = i;
571 continue;
572 } // compare zIndex of siblings
573
574
575 if (currentNodeParent === deepestNodeParent) {
576 if (zIndexIsHigherThan(currentNode, deepestNode)) {
577 deepestNodeIndex = i;
578 }
579
580 continue;
581 } // populate the ancestry array for the latest deepest node
582
583
584 deepestNodeParents = deepestNodeParents.length ? deepestNodeParents : getNodeParents(deepestNode);
585 var ancestryStart = void 0; // if the deepest node is an HTMLElement and the current node is a non root svg element
586
587 if (deepestNode instanceof _$domObjects_70["default"].HTMLElement && currentNode instanceof _$domObjects_70["default"].SVGElement && !(currentNode instanceof _$domObjects_70["default"].SVGSVGElement)) {
588 // TODO: is this check necessary? Was this for HTML elements embedded in SVG?
589 if (currentNode === deepestNodeParent) {
590 continue;
591 }
592
593 ancestryStart = currentNode.ownerSVGElement;
594 } else {
595 ancestryStart = currentNode;
596 }
597
598 var currentNodeParents = getNodeParents(ancestryStart, deepestNode.ownerDocument);
599 var commonIndex = 0; // get (position of closest common ancestor) + 1
600
601 while (currentNodeParents[commonIndex] && currentNodeParents[commonIndex] === deepestNodeParents[commonIndex]) {
602 commonIndex++;
603 }
604
605 var parents = [currentNodeParents[commonIndex - 1], currentNodeParents[commonIndex], deepestNodeParents[commonIndex]];
606 var child = parents[0].lastChild;
607
608 while (child) {
609 if (child === parents[1]) {
610 deepestNodeIndex = i;
611 deepestNodeParents = currentNodeParents;
612 break;
613 } else if (child === parents[2]) {
614 break;
615 }
616
617 child = child.previousSibling;
618 }
619 }
620
621 return deepestNodeIndex;
622 }
623
624 function getNodeParents(node, limit) {
625 var parents = [];
626 var parent = node;
627 var parentParent;
628
629 while ((parentParent = getParent(parent)) && parent !== limit && parentParent !== parent.ownerDocument) {
630 parents.unshift(parent);
631 parent = parentParent;
632 }
633
634 return parents;
635 }
636
637 function zIndexIsHigherThan(higherNode, lowerNode) {
638 var higherIndex = parseInt((0, _$window_84.getWindow)(higherNode).getComputedStyle(higherNode).zIndex, 10) || 0;
639 var lowerIndex = parseInt((0, _$window_84.getWindow)(lowerNode).getComputedStyle(lowerNode).zIndex, 10) || 0;
640 return higherIndex >= lowerIndex;
641 }
642
643 function matchesUpTo(element, selector, limit) {
644 while (_$is_76["default"].element(element)) {
645 if (matchesSelector(element, selector)) {
646 return true;
647 }
648
649 element = parentNode(element);
650
651 if (element === limit) {
652 return matchesSelector(element, selector);
653 }
654 }
655
656 return false;
657 }
658
659 function getActualElement(element) {
660 return element instanceof _$domObjects_70["default"].SVGElementInstance ? element.correspondingUseElement : element;
661 }
662
663 function getScrollXY(relevantWindow) {
664 relevantWindow = relevantWindow || _$window_84["default"].window;
665 return {
666 x: relevantWindow.scrollX || relevantWindow.document.documentElement.scrollLeft,
667 y: relevantWindow.scrollY || relevantWindow.document.documentElement.scrollTop
668 };
669 }
670
671 function getElementClientRect(element) {
672 var clientRect = element instanceof _$domObjects_70["default"].SVGElement ? element.getBoundingClientRect() : element.getClientRects()[0];
673 return clientRect && {
674 left: clientRect.left,
675 right: clientRect.right,
676 top: clientRect.top,
677 bottom: clientRect.bottom,
678 width: clientRect.width || clientRect.right - clientRect.left,
679 height: clientRect.height || clientRect.bottom - clientRect.top
680 };
681 }
682
683 function getElementRect(element) {
684 var clientRect = getElementClientRect(element);
685
686 if (!_$browser_67["default"].isIOS7 && clientRect) {
687 var scroll = getScrollXY(_$window_84["default"].getWindow(element));
688 clientRect.left += scroll.x;
689 clientRect.right += scroll.x;
690 clientRect.top += scroll.y;
691 clientRect.bottom += scroll.y;
692 }
693
694 return clientRect;
695 }
696
697 function getPath(node) {
698 var path = [];
699
700 while (node) {
701 path.push(node);
702 node = parentNode(node);
703 }
704
705 return path;
706 }
707
708 function trySelector(value) {
709 if (!_$is_76["default"].string(value)) {
710 return false;
711 } // an exception will be raised if it is invalid
712
713
714 _$domObjects_70["default"].document.querySelector(value);
715
716 return true;
717 }
718
719 var _$extend_73 = {};
720 "use strict";
721
722 Object.defineProperty(_$extend_73, "__esModule", {
723 value: true
724 });
725 _$extend_73["default"] = extend;
726
727 function extend(dest, source) {
728 for (var prop in source) {
729 dest[prop] = source[prop];
730 }
731
732 var ret = dest;
733 return ret;
734 }
735
736 var _$rect_83 = {};
737 "use strict";
738
739 Object.defineProperty(_$rect_83, "__esModule", {
740 value: true
741 });
742 _$rect_83.getStringOptionResult = getStringOptionResult;
743 _$rect_83.resolveRectLike = resolveRectLike;
744 _$rect_83.rectToXY = rectToXY;
745 _$rect_83.xywhToTlbr = xywhToTlbr;
746 _$rect_83.tlbrToXywh = tlbrToXywh;
747 _$rect_83.addEdges = addEdges;
748 /* removed: var _$domUtils_71 = require("./domUtils.js"); */
749
750 ;
751 /* removed: var _$extend_73 = require("./extend.js"); */
752
753 ;
754 /* removed: var _$is_76 = require("./is.js"); */
755
756 ;
757
758 function _toConsumableArray(arr) {
759 return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
760 }
761
762 function _nonIterableSpread() {
763 throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
764 }
765
766 function _unsupportedIterableToArray(o, minLen) {
767 if (!o) return;
768 if (typeof o === "string") return _arrayLikeToArray(o, minLen);
769 var n = Object.prototype.toString.call(o).slice(8, -1);
770 if (n === "Object" && o.constructor) n = o.constructor.name;
771 if (n === "Map" || n === "Set") return Array.from(o);
772 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
773 }
774
775 function _iterableToArray(iter) {
776 if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
777 }
778
779 function _arrayWithoutHoles(arr) {
780 if (Array.isArray(arr)) return _arrayLikeToArray(arr);
781 }
782
783 function _arrayLikeToArray(arr, len) {
784 if (len == null || len > arr.length) len = arr.length;
785
786 for (var i = 0, arr2 = new Array(len); i < len; i++) {
787 arr2[i] = arr[i];
788 }
789
790 return arr2;
791 }
792
793 function getStringOptionResult(value, target, element) {
794 if (value === 'parent') {
795 return (0, _$domUtils_71.parentNode)(element);
796 }
797
798 if (value === 'self') {
799 return target.getRect(element);
800 }
801
802 return (0, _$domUtils_71.closest)(element, value);
803 }
804
805 function resolveRectLike(value, target, element, functionArgs) {
806 var returnValue = value;
807
808 if (_$is_76["default"].string(returnValue)) {
809 returnValue = getStringOptionResult(returnValue, target, element);
810 } else if (_$is_76["default"].func(returnValue)) {
811 returnValue = returnValue.apply(void 0, _toConsumableArray(functionArgs));
812 }
813
814 if (_$is_76["default"].element(returnValue)) {
815 returnValue = (0, _$domUtils_71.getElementRect)(returnValue);
816 }
817
818 return returnValue;
819 }
820
821 function rectToXY(rect) {
822 return rect && {
823 x: 'x' in rect ? rect.x : rect.left,
824 y: 'y' in rect ? rect.y : rect.top
825 };
826 }
827
828 function xywhToTlbr(rect) {
829 if (rect && !('left' in rect && 'top' in rect)) {
830 rect = (0, _$extend_73["default"])({}, rect);
831 rect.left = rect.x || 0;
832 rect.top = rect.y || 0;
833 rect.right = rect.right || rect.left + rect.width;
834 rect.bottom = rect.bottom || rect.top + rect.height;
835 }
836
837 return rect;
838 }
839
840 function tlbrToXywh(rect) {
841 if (rect && !('x' in rect && 'y' in rect)) {
842 rect = (0, _$extend_73["default"])({}, rect);
843 rect.x = rect.left || 0;
844 rect.y = rect.top || 0;
845 rect.width = rect.width || (rect.right || 0) - rect.x;
846 rect.height = rect.height || (rect.bottom || 0) - rect.y;
847 }
848
849 return rect;
850 }
851
852 function addEdges(edges, rect, delta) {
853 if (edges.left) {
854 rect.left += delta.x;
855 }
856
857 if (edges.right) {
858 rect.right += delta.x;
859 }
860
861 if (edges.top) {
862 rect.top += delta.y;
863 }
864
865 if (edges.bottom) {
866 rect.bottom += delta.y;
867 }
868
869 rect.width = rect.right - rect.left;
870 rect.height = rect.bottom - rect.top;
871 }
872
873 var _$getOriginXY_74 = {};
874 "use strict";
875
876 Object.defineProperty(_$getOriginXY_74, "__esModule", {
877 value: true
878 });
879 _$getOriginXY_74["default"] = ___default_74;
880 /* removed: var _$rect_83 = require("./rect.js"); */
881
882 ;
883
884 function ___default_74(target, element, actionName) {
885 var actionOptions = target.options[actionName];
886 var actionOrigin = actionOptions && actionOptions.origin;
887 var origin = actionOrigin || target.options.origin;
888 var originRect = (0, _$rect_83.resolveRectLike)(origin, target, element, [target && element]);
889 return (0, _$rect_83.rectToXY)(originRect) || {
890 x: 0,
891 y: 0
892 };
893 }
894
895 var _$normalizeListeners_79 = {};
896 "use strict";
897
898 Object.defineProperty(_$normalizeListeners_79, "__esModule", {
899 value: true
900 });
901 _$normalizeListeners_79["default"] = normalize;
902 /* removed: var _$extend_73 = require("./extend.js"); */
903
904 ;
905 /* removed: var _$is_76 = require("./is.js"); */
906
907 ;
908
909 function normalize(type, listeners, result) {
910 result = result || {};
911
912 if (_$is_76["default"].string(type) && type.search(' ') !== -1) {
913 type = split(type);
914 }
915
916 if (_$is_76["default"].array(type)) {
917 return type.reduce(function (acc, t) {
918 return (0, _$extend_73["default"])(acc, normalize(t, listeners, result));
919 }, result);
920 } // ({ type: fn }) -> ('', { type: fn })
921
922
923 if (_$is_76["default"].object(type)) {
924 listeners = type;
925 type = '';
926 }
927
928 if (_$is_76["default"].func(listeners)) {
929 result[type] = result[type] || [];
930 result[type].push(listeners);
931 } else if (_$is_76["default"].array(listeners)) {
932 for (var _i = 0; _i < listeners.length; _i++) {
933 var _ref;
934
935 _ref = listeners[_i];
936 var l = _ref;
937 normalize(type, l, result);
938 }
939 } else if (_$is_76["default"].object(listeners)) {
940 for (var prefix in listeners) {
941 var combinedTypes = split(prefix).map(function (p) {
942 return "".concat(type).concat(p);
943 });
944 normalize(combinedTypes, listeners[prefix], result);
945 }
946 }
947
948 return result;
949 }
950
951 function split(type) {
952 return type.trim().split(/ +/);
953 }
954
955 var _$hypot_75 = {};
956 "use strict";
957
958 Object.defineProperty(_$hypot_75, "__esModule", {
959 value: true
960 });
961 _$hypot_75["default"] = void 0;
962
963 var ___default_75 = function _default(x, y) {
964 return Math.sqrt(x * x + y * y);
965 };
966
967 _$hypot_75["default"] = ___default_75;
968 var _$pointerExtend_80 = {};
969 "use strict";
970
971 Object.defineProperty(_$pointerExtend_80, "__esModule", {
972 value: true
973 });
974 _$pointerExtend_80["default"] = void 0;
975
976 function pointerExtend(dest, source) {
977 for (var prop in source) {
978 var prefixedPropREs = pointerExtend.prefixedPropREs;
979 var deprecated = false; // skip deprecated prefixed properties
980
981 for (var vendor in prefixedPropREs) {
982 if (prop.indexOf(vendor) === 0 && prefixedPropREs[vendor].test(prop)) {
983 deprecated = true;
984 break;
985 }
986 }
987
988 if (!deprecated && typeof source[prop] !== 'function') {
989 dest[prop] = source[prop];
990 }
991 }
992
993 return dest;
994 }
995
996 pointerExtend.prefixedPropREs = {
997 webkit: /(Movement[XY]|Radius[XY]|RotationAngle|Force)$/,
998 moz: /(Pressure)$/
999 };
1000 var ___default_80 = pointerExtend;
1001 _$pointerExtend_80["default"] = ___default_80;
1002 var _$pointerUtils_81 = {};
1003 "use strict";
1004
1005 Object.defineProperty(_$pointerUtils_81, "__esModule", {
1006 value: true
1007 });
1008 _$pointerUtils_81.copyCoords = copyCoords;
1009 _$pointerUtils_81.setCoordDeltas = setCoordDeltas;
1010 _$pointerUtils_81.setCoordVelocity = setCoordVelocity;
1011 _$pointerUtils_81.setZeroCoords = setZeroCoords;
1012 _$pointerUtils_81.isNativePointer = isNativePointer;
1013 _$pointerUtils_81.getXY = getXY;
1014 _$pointerUtils_81.getPageXY = getPageXY;
1015 _$pointerUtils_81.getClientXY = getClientXY;
1016 _$pointerUtils_81.getPointerId = getPointerId;
1017 _$pointerUtils_81.setCoords = setCoords;
1018 _$pointerUtils_81.getTouchPair = getTouchPair;
1019 _$pointerUtils_81.pointerAverage = pointerAverage;
1020 _$pointerUtils_81.touchBBox = touchBBox;
1021 _$pointerUtils_81.touchDistance = touchDistance;
1022 _$pointerUtils_81.touchAngle = touchAngle;
1023 _$pointerUtils_81.getPointerType = getPointerType;
1024 _$pointerUtils_81.getEventTargets = getEventTargets;
1025 _$pointerUtils_81.newCoords = newCoords;
1026 _$pointerUtils_81.coordsToEvent = coordsToEvent;
1027 Object.defineProperty(_$pointerUtils_81, "pointerExtend", {
1028 enumerable: true,
1029 get: function get() {
1030 return _$pointerExtend_80["default"];
1031 }
1032 });
1033 /* removed: var _$browser_67 = require("./browser.js"); */
1034
1035 ;
1036 /* removed: var _$domObjects_70 = require("./domObjects.js"); */
1037
1038 ;
1039 /* removed: var _$domUtils_71 = require("./domUtils.js"); */
1040
1041 ;
1042 /* removed: var _$hypot_75 = require("./hypot.js"); */
1043
1044 ;
1045 /* removed: var _$is_76 = require("./is.js"); */
1046
1047 ;
1048 /* removed: var _$pointerExtend_80 = require("./pointerExtend.js"); */
1049
1050 ;
1051
1052 function copyCoords(dest, src) {
1053 dest.page = dest.page || {};
1054 dest.page.x = src.page.x;
1055 dest.page.y = src.page.y;
1056 dest.client = dest.client || {};
1057 dest.client.x = src.client.x;
1058 dest.client.y = src.client.y;
1059 dest.timeStamp = src.timeStamp;
1060 }
1061
1062 function setCoordDeltas(targetObj, prev, cur) {
1063 targetObj.page.x = cur.page.x - prev.page.x;
1064 targetObj.page.y = cur.page.y - prev.page.y;
1065 targetObj.client.x = cur.client.x - prev.client.x;
1066 targetObj.client.y = cur.client.y - prev.client.y;
1067 targetObj.timeStamp = cur.timeStamp - prev.timeStamp;
1068 }
1069
1070 function setCoordVelocity(targetObj, delta) {
1071 var dt = Math.max(delta.timeStamp / 1000, 0.001);
1072 targetObj.page.x = delta.page.x / dt;
1073 targetObj.page.y = delta.page.y / dt;
1074 targetObj.client.x = delta.client.x / dt;
1075 targetObj.client.y = delta.client.y / dt;
1076 targetObj.timeStamp = dt;
1077 }
1078
1079 function setZeroCoords(targetObj) {
1080 targetObj.page.x = 0;
1081 targetObj.page.y = 0;
1082 targetObj.client.x = 0;
1083 targetObj.client.y = 0;
1084 }
1085
1086 function isNativePointer(pointer) {
1087 return pointer instanceof _$domObjects_70["default"].Event || pointer instanceof _$domObjects_70["default"].Touch;
1088 } // Get specified X/Y coords for mouse or event.touches[0]
1089
1090
1091 function getXY(type, pointer, xy) {
1092 xy = xy || {};
1093 type = type || 'page';
1094 xy.x = pointer[type + 'X'];
1095 xy.y = pointer[type + 'Y'];
1096 return xy;
1097 }
1098
1099 function getPageXY(pointer, page) {
1100 page = page || {
1101 x: 0,
1102 y: 0
1103 }; // Opera Mobile handles the viewport and scrolling oddly
1104
1105 if (_$browser_67["default"].isOperaMobile && isNativePointer(pointer)) {
1106 getXY('screen', pointer, page);
1107 page.x += window.scrollX;
1108 page.y += window.scrollY;
1109 } else {
1110 getXY('page', pointer, page);
1111 }
1112
1113 return page;
1114 }
1115
1116 function getClientXY(pointer, client) {
1117 client = client || {};
1118
1119 if (_$browser_67["default"].isOperaMobile && isNativePointer(pointer)) {
1120 // Opera Mobile handles the viewport and scrolling oddly
1121 getXY('screen', pointer, client);
1122 } else {
1123 getXY('client', pointer, client);
1124 }
1125
1126 return client;
1127 }
1128
1129 function getPointerId(pointer) {
1130 return _$is_76["default"].number(pointer.pointerId) ? pointer.pointerId : pointer.identifier;
1131 }
1132
1133 function setCoords(targetObj, pointers, timeStamp) {
1134 var pointer = pointers.length > 1 ? pointerAverage(pointers) : pointers[0];
1135 var tmpXY = {};
1136 getPageXY(pointer, tmpXY);
1137 targetObj.page.x = tmpXY.x;
1138 targetObj.page.y = tmpXY.y;
1139 getClientXY(pointer, tmpXY);
1140 targetObj.client.x = tmpXY.x;
1141 targetObj.client.y = tmpXY.y;
1142 targetObj.timeStamp = timeStamp;
1143 }
1144
1145 function getTouchPair(event) {
1146 var touches = []; // array of touches is supplied
1147
1148 if (_$is_76["default"].array(event)) {
1149 touches[0] = event[0];
1150 touches[1] = event[1];
1151 } // an event
1152 else {
1153 if (event.type === 'touchend') {
1154 if (event.touches.length === 1) {
1155 touches[0] = event.touches[0];
1156 touches[1] = event.changedTouches[0];
1157 } else if (event.touches.length === 0) {
1158 touches[0] = event.changedTouches[0];
1159 touches[1] = event.changedTouches[1];
1160 }
1161 } else {
1162 touches[0] = event.touches[0];
1163 touches[1] = event.touches[1];
1164 }
1165 }
1166
1167 return touches;
1168 }
1169
1170 function pointerAverage(pointers) {
1171 var average = {
1172 pageX: 0,
1173 pageY: 0,
1174 clientX: 0,
1175 clientY: 0,
1176 screenX: 0,
1177 screenY: 0
1178 };
1179
1180 for (var _i = 0; _i < pointers.length; _i++) {
1181 var _ref;
1182
1183 _ref = pointers[_i];
1184 var pointer = _ref;
1185
1186 for (var _prop in average) {
1187 average[_prop] += pointer[_prop];
1188 }
1189 }
1190
1191 for (var prop in average) {
1192 average[prop] /= pointers.length;
1193 }
1194
1195 return average;
1196 }
1197
1198 function touchBBox(event) {
1199 if (!event.length && !(event.touches && event.touches.length > 1)) {
1200 return null;
1201 }
1202
1203 var touches = getTouchPair(event);
1204 var minX = Math.min(touches[0].pageX, touches[1].pageX);
1205 var minY = Math.min(touches[0].pageY, touches[1].pageY);
1206 var maxX = Math.max(touches[0].pageX, touches[1].pageX);
1207 var maxY = Math.max(touches[0].pageY, touches[1].pageY);
1208 return {
1209 x: minX,
1210 y: minY,
1211 left: minX,
1212 top: minY,
1213 right: maxX,
1214 bottom: maxY,
1215 width: maxX - minX,
1216 height: maxY - minY
1217 };
1218 }
1219
1220 function touchDistance(event, deltaSource) {
1221 var sourceX = deltaSource + 'X';
1222 var sourceY = deltaSource + 'Y';
1223 var touches = getTouchPair(event);
1224 var dx = touches[0][sourceX] - touches[1][sourceX];
1225 var dy = touches[0][sourceY] - touches[1][sourceY];
1226 return (0, _$hypot_75["default"])(dx, dy);
1227 }
1228
1229 function touchAngle(event, deltaSource) {
1230 var sourceX = deltaSource + 'X';
1231 var sourceY = deltaSource + 'Y';
1232 var touches = getTouchPair(event);
1233 var dx = touches[1][sourceX] - touches[0][sourceX];
1234 var dy = touches[1][sourceY] - touches[0][sourceY];
1235 var angle = 180 * Math.atan2(dy, dx) / Math.PI;
1236 return angle;
1237 }
1238
1239 function getPointerType(pointer) {
1240 return _$is_76["default"].string(pointer.pointerType) ? pointer.pointerType : _$is_76["default"].number(pointer.pointerType) ? [undefined, undefined, 'touch', 'pen', 'mouse'][pointer.pointerType] // if the PointerEvent API isn't available, then the "pointer" must
1241 // be either a MouseEvent, TouchEvent, or Touch object
1242 : /touch/.test(pointer.type) || pointer instanceof _$domObjects_70["default"].Touch ? 'touch' : 'mouse';
1243 } // [ event.target, event.currentTarget ]
1244
1245
1246 function getEventTargets(event) {
1247 var path = _$is_76["default"].func(event.composedPath) ? event.composedPath() : event.path;
1248 return [_$domUtils_71.getActualElement(path ? path[0] : event.target), _$domUtils_71.getActualElement(event.currentTarget)];
1249 }
1250
1251 function newCoords() {
1252 return {
1253 page: {
1254 x: 0,
1255 y: 0
1256 },
1257 client: {
1258 x: 0,
1259 y: 0
1260 },
1261 timeStamp: 0
1262 };
1263 }
1264
1265 function coordsToEvent(coords) {
1266 var event = {
1267 coords: coords,
1268
1269 get page() {
1270 return this.coords.page;
1271 },
1272
1273 get client() {
1274 return this.coords.client;
1275 },
1276
1277 get timeStamp() {
1278 return this.coords.timeStamp;
1279 },
1280
1281 get pageX() {
1282 return this.coords.page.x;
1283 },
1284
1285 get pageY() {
1286 return this.coords.page.y;
1287 },
1288
1289 get clientX() {
1290 return this.coords.client.x;
1291 },
1292
1293 get clientY() {
1294 return this.coords.client.y;
1295 },
1296
1297 get pointerId() {
1298 return this.coords.pointerId;
1299 },
1300
1301 get target() {
1302 return this.coords.target;
1303 },
1304
1305 get type() {
1306 return this.coords.type;
1307 },
1308
1309 get pointerType() {
1310 return this.coords.pointerType;
1311 },
1312
1313 get buttons() {
1314 return this.coords.buttons;
1315 },
1316
1317 preventDefault: function preventDefault() {}
1318 };
1319 return event;
1320 }
1321
1322 var _$BaseEvent_15 = {};
1323 "use strict";
1324
1325 Object.defineProperty(_$BaseEvent_15, "__esModule", {
1326 value: true
1327 });
1328 _$BaseEvent_15["default"] = _$BaseEvent_15.BaseEvent = void 0;
1329
1330 function _classCallCheck(instance, Constructor) {
1331 if (!(instance instanceof Constructor)) {
1332 throw new TypeError("Cannot call a class as a function");
1333 }
1334 }
1335
1336 function _defineProperties(target, props) {
1337 for (var i = 0; i < props.length; i++) {
1338 var descriptor = props[i];
1339 descriptor.enumerable = descriptor.enumerable || false;
1340 descriptor.configurable = true;
1341 if ("value" in descriptor) descriptor.writable = true;
1342 Object.defineProperty(target, descriptor.key, descriptor);
1343 }
1344 }
1345
1346 function _createClass(Constructor, protoProps, staticProps) {
1347 if (protoProps) _defineProperties(Constructor.prototype, protoProps);
1348 if (staticProps) _defineProperties(Constructor, staticProps);
1349 return Constructor;
1350 }
1351
1352 var BaseEvent = /*#__PURE__*/function () {
1353 function BaseEvent(interaction) {
1354 _classCallCheck(this, BaseEvent);
1355
1356 this.type = void 0;
1357 this.target = void 0;
1358 this.currentTarget = void 0;
1359 this.interactable = void 0;
1360 this._interaction = void 0;
1361 this.timeStamp = void 0;
1362 this.immediatePropagationStopped = false;
1363 this.propagationStopped = false;
1364 this._interaction = interaction;
1365 }
1366
1367 _createClass(BaseEvent, [{
1368 key: "preventDefault",
1369 value: function preventDefault() {}
1370 /**
1371 * Don't call any other listeners (even on the current target)
1372 */
1373
1374 }, {
1375 key: "stopPropagation",
1376 value: function stopPropagation() {
1377 this.propagationStopped = true;
1378 }
1379 /**
1380 * Don't call listeners on the remaining targets
1381 */
1382
1383 }, {
1384 key: "stopImmediatePropagation",
1385 value: function stopImmediatePropagation() {
1386 this.immediatePropagationStopped = this.propagationStopped = true;
1387 }
1388 }]);
1389
1390 return BaseEvent;
1391 }(); // defined outside of class definition to avoid assignment of undefined during
1392 // construction
1393 // getters and setters defined here to support typescript 3.6 and below which
1394 // don't support getter and setters in .d.ts files
1395
1396
1397 _$BaseEvent_15.BaseEvent = BaseEvent;
1398 Object.defineProperty(BaseEvent.prototype, 'interaction', {
1399 get: function get() {
1400 return this._interaction._proxy;
1401 },
1402 set: function set() {}
1403 });
1404 var ___default_15 = BaseEvent;
1405 _$BaseEvent_15["default"] = ___default_15;
1406 var _$arr_66 = {};
1407 "use strict";
1408
1409 Object.defineProperty(_$arr_66, "__esModule", {
1410 value: true
1411 });
1412 _$arr_66.find = _$arr_66.findIndex = _$arr_66.from = _$arr_66.merge = _$arr_66.remove = _$arr_66.contains = void 0;
1413
1414 var contains = function contains(array, target) {
1415 return array.indexOf(target) !== -1;
1416 };
1417
1418 _$arr_66.contains = contains;
1419
1420 var remove = function remove(array, target) {
1421 return array.splice(array.indexOf(target), 1);
1422 };
1423
1424 _$arr_66.remove = remove;
1425
1426 var merge = function merge(target, source) {
1427 for (var _i = 0; _i < source.length; _i++) {
1428 var _ref;
1429
1430 _ref = source[_i];
1431 var item = _ref;
1432 target.push(item);
1433 }
1434
1435 return target;
1436 };
1437
1438 _$arr_66.merge = merge;
1439
1440 var from = function from(source) {
1441 return merge([], source);
1442 };
1443
1444 _$arr_66.from = from;
1445
1446 var findIndex = function findIndex(array, func) {
1447 for (var i = 0; i < array.length; i++) {
1448 if (func(array[i], i, array)) {
1449 return i;
1450 }
1451 }
1452
1453 return -1;
1454 };
1455
1456 _$arr_66.findIndex = findIndex;
1457
1458 var find = function find(array, func) {
1459 return array[findIndex(array, func)];
1460 };
1461
1462 _$arr_66.find = find;
1463 var _$DropEvent_2 = {};
1464 "use strict";
1465
1466 Object.defineProperty(_$DropEvent_2, "__esModule", {
1467 value: true
1468 });
1469 _$DropEvent_2.DropEvent = void 0;
1470 /* removed: var _$BaseEvent_15 = require("../../core/BaseEvent.js"); */
1471
1472 ;
1473 /* removed: var _$arr_66 = require("../../utils/arr.js"); */
1474
1475 ;
1476
1477 function ___typeof_2(obj) {
1478 "@babel/helpers - typeof";
1479
1480 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
1481 ___typeof_2 = function _typeof(obj) {
1482 return typeof obj;
1483 };
1484 } else {
1485 ___typeof_2 = function _typeof(obj) {
1486 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
1487 };
1488 }
1489
1490 return ___typeof_2(obj);
1491 }
1492
1493 function ___classCallCheck_2(instance, Constructor) {
1494 if (!(instance instanceof Constructor)) {
1495 throw new TypeError("Cannot call a class as a function");
1496 }
1497 }
1498
1499 function ___defineProperties_2(target, props) {
1500 for (var i = 0; i < props.length; i++) {
1501 var descriptor = props[i];
1502 descriptor.enumerable = descriptor.enumerable || false;
1503 descriptor.configurable = true;
1504 if ("value" in descriptor) descriptor.writable = true;
1505 Object.defineProperty(target, descriptor.key, descriptor);
1506 }
1507 }
1508
1509 function ___createClass_2(Constructor, protoProps, staticProps) {
1510 if (protoProps) ___defineProperties_2(Constructor.prototype, protoProps);
1511 if (staticProps) ___defineProperties_2(Constructor, staticProps);
1512 return Constructor;
1513 }
1514
1515 function _inherits(subClass, superClass) {
1516 if (typeof superClass !== "function" && superClass !== null) {
1517 throw new TypeError("Super expression must either be null or a function");
1518 }
1519
1520 subClass.prototype = Object.create(superClass && superClass.prototype, {
1521 constructor: {
1522 value: subClass,
1523 writable: true,
1524 configurable: true
1525 }
1526 });
1527 if (superClass) _setPrototypeOf(subClass, superClass);
1528 }
1529
1530 function _setPrototypeOf(o, p) {
1531 _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
1532 o.__proto__ = p;
1533 return o;
1534 };
1535
1536 return _setPrototypeOf(o, p);
1537 }
1538
1539 function _createSuper(Derived) {
1540 var hasNativeReflectConstruct = _isNativeReflectConstruct();
1541
1542 return function () {
1543 var Super = _getPrototypeOf(Derived),
1544 result;
1545
1546 if (hasNativeReflectConstruct) {
1547 var NewTarget = _getPrototypeOf(this).constructor;
1548
1549 result = Reflect.construct(Super, arguments, NewTarget);
1550 } else {
1551 result = Super.apply(this, arguments);
1552 }
1553
1554 return _possibleConstructorReturn(this, result);
1555 };
1556 }
1557
1558 function _possibleConstructorReturn(self, call) {
1559 if (call && (___typeof_2(call) === "object" || typeof call === "function")) {
1560 return call;
1561 }
1562
1563 return _assertThisInitialized(self);
1564 }
1565
1566 function _assertThisInitialized(self) {
1567 if (self === void 0) {
1568 throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
1569 }
1570
1571 return self;
1572 }
1573
1574 function _isNativeReflectConstruct() {
1575 if (typeof Reflect === "undefined" || !Reflect.construct) return false;
1576 if (Reflect.construct.sham) return false;
1577 if (typeof Proxy === "function") return true;
1578
1579 try {
1580 Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
1581 return true;
1582 } catch (e) {
1583 return false;
1584 }
1585 }
1586
1587 function _getPrototypeOf(o) {
1588 _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
1589 return o.__proto__ || Object.getPrototypeOf(o);
1590 };
1591 return _getPrototypeOf(o);
1592 }
1593
1594 var DropEvent = /*#__PURE__*/function (_BaseEvent) {
1595 _inherits(DropEvent, _BaseEvent);
1596
1597 var _super = _createSuper(DropEvent);
1598 /**
1599 * Class of events fired on dropzones during drags with acceptable targets.
1600 */
1601
1602
1603 function DropEvent(dropState, dragEvent, type) {
1604 var _this;
1605
1606 ___classCallCheck_2(this, DropEvent);
1607
1608 _this = _super.call(this, dragEvent._interaction);
1609 _this.target = void 0;
1610 _this.dropzone = void 0;
1611 _this.dragEvent = void 0;
1612 _this.relatedTarget = void 0;
1613 _this.draggable = void 0;
1614 _this.timeStamp = void 0;
1615 _this.propagationStopped = false;
1616 _this.immediatePropagationStopped = false;
1617
1618 var _ref = type === 'dragleave' ? dropState.prev : dropState.cur,
1619 element = _ref.element,
1620 dropzone = _ref.dropzone;
1621
1622 _this.type = type;
1623 _this.target = element;
1624 _this.currentTarget = element;
1625 _this.dropzone = dropzone;
1626 _this.dragEvent = dragEvent;
1627 _this.relatedTarget = dragEvent.target;
1628 _this.draggable = dragEvent.interactable;
1629 _this.timeStamp = dragEvent.timeStamp;
1630 return _this;
1631 }
1632 /**
1633 * If this is a `dropactivate` event, the dropzone element will be
1634 * deactivated.
1635 *
1636 * If this is a `dragmove` or `dragenter`, a `dragleave` will be fired on the
1637 * dropzone element and more.
1638 */
1639
1640
1641 ___createClass_2(DropEvent, [{
1642 key: "reject",
1643 value: function reject() {
1644 var _this2 = this;
1645
1646 var dropState = this._interaction.dropState;
1647
1648 if (this.type !== 'dropactivate' && (!this.dropzone || dropState.cur.dropzone !== this.dropzone || dropState.cur.element !== this.target)) {
1649 return;
1650 }
1651
1652 dropState.prev.dropzone = this.dropzone;
1653 dropState.prev.element = this.target;
1654 dropState.rejected = true;
1655 dropState.events.enter = null;
1656 this.stopImmediatePropagation();
1657
1658 if (this.type === 'dropactivate') {
1659 var activeDrops = dropState.activeDrops;
1660
1661 var index = _$arr_66.findIndex(activeDrops, function (_ref2) {
1662 var dropzone = _ref2.dropzone,
1663 element = _ref2.element;
1664 return dropzone === _this2.dropzone && element === _this2.target;
1665 });
1666
1667 dropState.activeDrops.splice(index, 1);
1668 var deactivateEvent = new DropEvent(dropState, this.dragEvent, 'dropdeactivate');
1669 deactivateEvent.dropzone = this.dropzone;
1670 deactivateEvent.target = this.target;
1671 this.dropzone.fire(deactivateEvent);
1672 } else {
1673 this.dropzone.fire(new DropEvent(dropState, this.dragEvent, 'dragleave'));
1674 }
1675 }
1676 }, {
1677 key: "preventDefault",
1678 value: function preventDefault() {}
1679 }, {
1680 key: "stopPropagation",
1681 value: function stopPropagation() {
1682 this.propagationStopped = true;
1683 }
1684 }, {
1685 key: "stopImmediatePropagation",
1686 value: function stopImmediatePropagation() {
1687 this.immediatePropagationStopped = this.propagationStopped = true;
1688 }
1689 }]);
1690
1691 return DropEvent;
1692 }(_$BaseEvent_15.BaseEvent);
1693
1694 _$DropEvent_2.DropEvent = DropEvent;
1695 var _$plugin_3 = {};
1696 "use strict";
1697
1698 Object.defineProperty(_$plugin_3, "__esModule", {
1699 value: true
1700 });
1701 _$plugin_3["default"] = void 0;
1702 /* removed: var _$domUtils_71 = require("../../utils/domUtils.js"); */
1703
1704 ;
1705 /* removed: var _$extend_73 = require("../../utils/extend.js"); */
1706
1707 ;
1708 /* removed: var _$getOriginXY_74 = require("../../utils/getOriginXY.js"); */
1709
1710 ;
1711 /* removed: var _$is_76 = require("../../utils/is.js"); */
1712
1713 ;
1714 /* removed: var _$normalizeListeners_79 = require("../../utils/normalizeListeners.js"); */
1715
1716 ;
1717 /* removed: var _$pointerUtils_81 = require("../../utils/pointerUtils.js"); */
1718
1719 ;
1720 /* removed: var _$plugin_1 = require("../drag/plugin.js"); */
1721
1722 ;
1723 /* removed: var _$DropEvent_2 = require("./DropEvent.js"); */
1724
1725 ;
1726
1727 function __install_3(scope) {
1728 var actions = scope.actions,
1729 interact = scope.interactStatic,
1730 Interactable = scope.Interactable,
1731 defaults = scope.defaults;
1732 scope.usePlugin(_$plugin_1["default"]);
1733 /**
1734 *
1735 * ```js
1736 * interact('.drop').dropzone({
1737 * accept: '.can-drop' || document.getElementById('single-drop'),
1738 * overlap: 'pointer' || 'center' || zeroToOne
1739 * }
1740 * ```
1741 *
1742 * Returns or sets whether draggables can be dropped onto this target to
1743 * trigger drop events
1744 *
1745 * Dropzones can receive the following events:
1746 * - `dropactivate` and `dropdeactivate` when an acceptable drag starts and ends
1747 * - `dragenter` and `dragleave` when a draggable enters and leaves the dropzone
1748 * - `dragmove` when a draggable that has entered the dropzone is moved
1749 * - `drop` when a draggable is dropped into this dropzone
1750 *
1751 * Use the `accept` option to allow only elements that match the given CSS
1752 * selector or element. The value can be:
1753 *
1754 * - **an Element** - only that element can be dropped into this dropzone.
1755 * - **a string**, - the element being dragged must match it as a CSS selector.
1756 * - **`null`** - accept options is cleared - it accepts any element.
1757 *
1758 * Use the `overlap` option to set how drops are checked for. The allowed
1759 * values are:
1760 *
1761 * - `'pointer'`, the pointer must be over the dropzone (default)
1762 * - `'center'`, the draggable element's center must be over the dropzone
1763 * - a number from 0-1 which is the `(intersection area) / (draggable area)`.
1764 * e.g. `0.5` for drop to happen when half of the area of the draggable is
1765 * over the dropzone
1766 *
1767 * Use the `checker` option to specify a function to check if a dragged element
1768 * is over this Interactable.
1769 *
1770 * @param {boolean | object | null} [options] The new options to be set.
1771 * @return {boolean | Interactable} The current setting or this Interactable
1772 */
1773
1774 Interactable.prototype.dropzone = function (options) {
1775 return dropzoneMethod(this, options);
1776 };
1777 /**
1778 * ```js
1779 * interact(target)
1780 * .dropChecker(function(dragEvent, // related dragmove or dragend event
1781 * event, // TouchEvent/PointerEvent/MouseEvent
1782 * dropped, // bool result of the default checker
1783 * dropzone, // dropzone Interactable
1784 * dropElement, // dropzone elemnt
1785 * draggable, // draggable Interactable
1786 * draggableElement) {// draggable element
1787 *
1788 * return dropped && event.target.hasAttribute('allow-drop')
1789 * }
1790 * ```
1791 */
1792
1793
1794 Interactable.prototype.dropCheck = function (dragEvent, event, draggable, draggableElement, dropElement, rect) {
1795 return dropCheckMethod(this, dragEvent, event, draggable, draggableElement, dropElement, rect);
1796 };
1797 /**
1798 * Returns or sets whether the dimensions of dropzone elements are calculated
1799 * on every dragmove or only on dragstart for the default dropChecker
1800 *
1801 * @param {boolean} [newValue] True to check on each move. False to check only
1802 * before start
1803 * @return {boolean | interact} The current setting or interact
1804 */
1805
1806
1807 interact.dynamicDrop = function (newValue) {
1808 if (_$is_76["default"].bool(newValue)) {
1809 // if (dragging && scope.dynamicDrop !== newValue && !newValue) {
1810 // calcRects(dropzones)
1811 // }
1812 scope.dynamicDrop = newValue;
1813 return interact;
1814 }
1815
1816 return scope.dynamicDrop;
1817 };
1818
1819 (0, _$extend_73["default"])(actions.phaselessTypes, {
1820 dragenter: true,
1821 dragleave: true,
1822 dropactivate: true,
1823 dropdeactivate: true,
1824 dropmove: true,
1825 drop: true
1826 });
1827 actions.methodDict.drop = 'dropzone';
1828 scope.dynamicDrop = false;
1829 defaults.actions.drop = drop.defaults;
1830 }
1831
1832 function collectDrops(_ref, draggableElement) {
1833 var interactables = _ref.interactables;
1834 var drops = []; // collect all dropzones and their elements which qualify for a drop
1835
1836 for (var _i = 0; _i < interactables.list.length; _i++) {
1837 var _ref2;
1838
1839 _ref2 = interactables.list[_i];
1840 var dropzone = _ref2;
1841
1842 if (!dropzone.options.drop.enabled) {
1843 continue;
1844 }
1845
1846 var accept = dropzone.options.drop.accept; // test the draggable draggableElement against the dropzone's accept setting
1847
1848 if (_$is_76["default"].element(accept) && accept !== draggableElement || _$is_76["default"].string(accept) && !_$domUtils_71.matchesSelector(draggableElement, accept) || _$is_76["default"].func(accept) && !accept({
1849 dropzone: dropzone,
1850 draggableElement: draggableElement
1851 })) {
1852 continue;
1853 } // query for new elements if necessary
1854
1855
1856 var dropElements = _$is_76["default"].string(dropzone.target) ? dropzone._context.querySelectorAll(dropzone.target) : _$is_76["default"].array(dropzone.target) ? dropzone.target : [dropzone.target];
1857
1858 for (var _i2 = 0; _i2 < dropElements.length; _i2++) {
1859 var _ref3;
1860
1861 _ref3 = dropElements[_i2];
1862 var dropzoneElement = _ref3;
1863
1864 if (dropzoneElement !== draggableElement) {
1865 drops.push({
1866 dropzone: dropzone,
1867 element: dropzoneElement
1868 });
1869 }
1870 }
1871 }
1872
1873 return drops;
1874 }
1875
1876 function fireActivationEvents(activeDrops, event) {
1877 // loop through all active dropzones and trigger event
1878 for (var _i3 = 0; _i3 < activeDrops.slice().length; _i3++) {
1879 var _ref4;
1880
1881 _ref4 = activeDrops.slice()[_i3];
1882 var _ref5 = _ref4,
1883 dropzone = _ref5.dropzone,
1884 element = _ref5.element;
1885 event.dropzone = dropzone; // set current element as event target
1886
1887 event.target = element;
1888 dropzone.fire(event);
1889 event.propagationStopped = event.immediatePropagationStopped = false;
1890 }
1891 } // return a new array of possible drops. getActiveDrops should always be
1892 // called when a drag has just started or a drag event happens while
1893 // dynamicDrop is true
1894
1895
1896 function getActiveDrops(scope, dragElement) {
1897 // get dropzones and their elements that could receive the draggable
1898 var activeDrops = collectDrops(scope, dragElement);
1899
1900 for (var _i4 = 0; _i4 < activeDrops.length; _i4++) {
1901 var _ref6;
1902
1903 _ref6 = activeDrops[_i4];
1904 var activeDrop = _ref6;
1905 activeDrop.rect = activeDrop.dropzone.getRect(activeDrop.element);
1906 }
1907
1908 return activeDrops;
1909 }
1910
1911 function getDrop(_ref7, dragEvent, pointerEvent) {
1912 var dropState = _ref7.dropState,
1913 draggable = _ref7.interactable,
1914 dragElement = _ref7.element;
1915 var validDrops = []; // collect all dropzones and their elements which qualify for a drop
1916
1917 for (var _i5 = 0; _i5 < dropState.activeDrops.length; _i5++) {
1918 var _ref8;
1919
1920 _ref8 = dropState.activeDrops[_i5];
1921 var _ref9 = _ref8,
1922 dropzone = _ref9.dropzone,
1923 dropzoneElement = _ref9.element,
1924 rect = _ref9.rect;
1925 validDrops.push(dropzone.dropCheck(dragEvent, pointerEvent, draggable, dragElement, dropzoneElement, rect) ? dropzoneElement : null);
1926 } // get the most appropriate dropzone based on DOM depth and order
1927
1928
1929 var dropIndex = _$domUtils_71.indexOfDeepestElement(validDrops);
1930
1931 return dropState.activeDrops[dropIndex] || null;
1932 }
1933
1934 function getDropEvents(interaction, _pointerEvent, dragEvent) {
1935 var dropState = interaction.dropState;
1936 var dropEvents = {
1937 enter: null,
1938 leave: null,
1939 activate: null,
1940 deactivate: null,
1941 move: null,
1942 drop: null
1943 };
1944
1945 if (dragEvent.type === 'dragstart') {
1946 dropEvents.activate = new _$DropEvent_2.DropEvent(dropState, dragEvent, 'dropactivate');
1947 dropEvents.activate.target = null;
1948 dropEvents.activate.dropzone = null;
1949 }
1950
1951 if (dragEvent.type === 'dragend') {
1952 dropEvents.deactivate = new _$DropEvent_2.DropEvent(dropState, dragEvent, 'dropdeactivate');
1953 dropEvents.deactivate.target = null;
1954 dropEvents.deactivate.dropzone = null;
1955 }
1956
1957 if (dropState.rejected) {
1958 return dropEvents;
1959 }
1960
1961 if (dropState.cur.element !== dropState.prev.element) {
1962 // if there was a previous dropzone, create a dragleave event
1963 if (dropState.prev.dropzone) {
1964 dropEvents.leave = new _$DropEvent_2.DropEvent(dropState, dragEvent, 'dragleave');
1965 dragEvent.dragLeave = dropEvents.leave.target = dropState.prev.element;
1966 dragEvent.prevDropzone = dropEvents.leave.dropzone = dropState.prev.dropzone;
1967 } // if dropzone is not null, create a dragenter event
1968
1969
1970 if (dropState.cur.dropzone) {
1971 dropEvents.enter = new _$DropEvent_2.DropEvent(dropState, dragEvent, 'dragenter');
1972 dragEvent.dragEnter = dropState.cur.element;
1973 dragEvent.dropzone = dropState.cur.dropzone;
1974 }
1975 }
1976
1977 if (dragEvent.type === 'dragend' && dropState.cur.dropzone) {
1978 dropEvents.drop = new _$DropEvent_2.DropEvent(dropState, dragEvent, 'drop');
1979 dragEvent.dropzone = dropState.cur.dropzone;
1980 dragEvent.relatedTarget = dropState.cur.element;
1981 }
1982
1983 if (dragEvent.type === 'dragmove' && dropState.cur.dropzone) {
1984 dropEvents.move = new _$DropEvent_2.DropEvent(dropState, dragEvent, 'dropmove');
1985 dropEvents.move.dragmove = dragEvent;
1986 dragEvent.dropzone = dropState.cur.dropzone;
1987 }
1988
1989 return dropEvents;
1990 }
1991
1992 function fireDropEvents(interaction, events) {
1993 var dropState = interaction.dropState;
1994 var activeDrops = dropState.activeDrops,
1995 cur = dropState.cur,
1996 prev = dropState.prev;
1997
1998 if (events.leave) {
1999 prev.dropzone.fire(events.leave);
2000 }
2001
2002 if (events.move) {
2003 cur.dropzone.fire(events.move);
2004 }
2005
2006 if (events.enter) {
2007 cur.dropzone.fire(events.enter);
2008 }
2009
2010 if (events.drop) {
2011 cur.dropzone.fire(events.drop);
2012 }
2013
2014 if (events.deactivate) {
2015 fireActivationEvents(activeDrops, events.deactivate);
2016 }
2017
2018 dropState.prev.dropzone = cur.dropzone;
2019 dropState.prev.element = cur.element;
2020 }
2021
2022 function onEventCreated(_ref10, scope) {
2023 var interaction = _ref10.interaction,
2024 iEvent = _ref10.iEvent,
2025 event = _ref10.event;
2026
2027 if (iEvent.type !== 'dragmove' && iEvent.type !== 'dragend') {
2028 return;
2029 }
2030
2031 var dropState = interaction.dropState;
2032
2033 if (scope.dynamicDrop) {
2034 dropState.activeDrops = getActiveDrops(scope, interaction.element);
2035 }
2036
2037 var dragEvent = iEvent;
2038 var dropResult = getDrop(interaction, dragEvent, event); // update rejected status
2039
2040 dropState.rejected = dropState.rejected && !!dropResult && dropResult.dropzone === dropState.cur.dropzone && dropResult.element === dropState.cur.element;
2041 dropState.cur.dropzone = dropResult && dropResult.dropzone;
2042 dropState.cur.element = dropResult && dropResult.element;
2043 dropState.events = getDropEvents(interaction, event, dragEvent);
2044 }
2045
2046 function dropzoneMethod(interactable, options) {
2047 if (_$is_76["default"].object(options)) {
2048 interactable.options.drop.enabled = options.enabled !== false;
2049
2050 if (options.listeners) {
2051 var normalized = (0, _$normalizeListeners_79["default"])(options.listeners); // rename 'drop' to '' as it will be prefixed with 'drop'
2052
2053 var corrected = Object.keys(normalized).reduce(function (acc, type) {
2054 var correctedType = /^(enter|leave)/.test(type) ? "drag".concat(type) : /^(activate|deactivate|move)/.test(type) ? "drop".concat(type) : type;
2055 acc[correctedType] = normalized[type];
2056 return acc;
2057 }, {});
2058 interactable.off(interactable.options.drop.listeners);
2059 interactable.on(corrected);
2060 interactable.options.drop.listeners = corrected;
2061 }
2062
2063 if (_$is_76["default"].func(options.ondrop)) {
2064 interactable.on('drop', options.ondrop);
2065 }
2066
2067 if (_$is_76["default"].func(options.ondropactivate)) {
2068 interactable.on('dropactivate', options.ondropactivate);
2069 }
2070
2071 if (_$is_76["default"].func(options.ondropdeactivate)) {
2072 interactable.on('dropdeactivate', options.ondropdeactivate);
2073 }
2074
2075 if (_$is_76["default"].func(options.ondragenter)) {
2076 interactable.on('dragenter', options.ondragenter);
2077 }
2078
2079 if (_$is_76["default"].func(options.ondragleave)) {
2080 interactable.on('dragleave', options.ondragleave);
2081 }
2082
2083 if (_$is_76["default"].func(options.ondropmove)) {
2084 interactable.on('dropmove', options.ondropmove);
2085 }
2086
2087 if (/^(pointer|center)$/.test(options.overlap)) {
2088 interactable.options.drop.overlap = options.overlap;
2089 } else if (_$is_76["default"].number(options.overlap)) {
2090 interactable.options.drop.overlap = Math.max(Math.min(1, options.overlap), 0);
2091 }
2092
2093 if ('accept' in options) {
2094 interactable.options.drop.accept = options.accept;
2095 }
2096
2097 if ('checker' in options) {
2098 interactable.options.drop.checker = options.checker;
2099 }
2100
2101 return interactable;
2102 }
2103
2104 if (_$is_76["default"].bool(options)) {
2105 interactable.options.drop.enabled = options;
2106 return interactable;
2107 }
2108
2109 return interactable.options.drop;
2110 }
2111
2112 function dropCheckMethod(interactable, dragEvent, event, draggable, draggableElement, dropElement, rect) {
2113 var dropped = false; // if the dropzone has no rect (eg. display: none)
2114 // call the custom dropChecker or just return false
2115
2116 if (!(rect = rect || interactable.getRect(dropElement))) {
2117 return interactable.options.drop.checker ? interactable.options.drop.checker(dragEvent, event, dropped, interactable, dropElement, draggable, draggableElement) : false;
2118 }
2119
2120 var dropOverlap = interactable.options.drop.overlap;
2121
2122 if (dropOverlap === 'pointer') {
2123 var origin = (0, _$getOriginXY_74["default"])(draggable, draggableElement, 'drag');
2124
2125 var page = _$pointerUtils_81.getPageXY(dragEvent);
2126
2127 page.x += origin.x;
2128 page.y += origin.y;
2129 var horizontal = page.x > rect.left && page.x < rect.right;
2130 var vertical = page.y > rect.top && page.y < rect.bottom;
2131 dropped = horizontal && vertical;
2132 }
2133
2134 var dragRect = draggable.getRect(draggableElement);
2135
2136 if (dragRect && dropOverlap === 'center') {
2137 var cx = dragRect.left + dragRect.width / 2;
2138 var cy = dragRect.top + dragRect.height / 2;
2139 dropped = cx >= rect.left && cx <= rect.right && cy >= rect.top && cy <= rect.bottom;
2140 }
2141
2142 if (dragRect && _$is_76["default"].number(dropOverlap)) {
2143 var overlapArea = Math.max(0, Math.min(rect.right, dragRect.right) - Math.max(rect.left, dragRect.left)) * Math.max(0, Math.min(rect.bottom, dragRect.bottom) - Math.max(rect.top, dragRect.top));
2144 var overlapRatio = overlapArea / (dragRect.width * dragRect.height);
2145 dropped = overlapRatio >= dropOverlap;
2146 }
2147
2148 if (interactable.options.drop.checker) {
2149 dropped = interactable.options.drop.checker(dragEvent, event, dropped, interactable, dropElement, draggable, draggableElement);
2150 }
2151
2152 return dropped;
2153 }
2154
2155 var drop = {
2156 id: 'actions/drop',
2157 install: __install_3,
2158 listeners: {
2159 'interactions:before-action-start': function interactionsBeforeActionStart(_ref11) {
2160 var interaction = _ref11.interaction;
2161
2162 if (interaction.prepared.name !== 'drag') {
2163 return;
2164 }
2165
2166 interaction.dropState = {
2167 cur: {
2168 dropzone: null,
2169 element: null
2170 },
2171 prev: {
2172 dropzone: null,
2173 element: null
2174 },
2175 rejected: null,
2176 events: null,
2177 activeDrops: []
2178 };
2179 },
2180 'interactions:after-action-start': function interactionsAfterActionStart(_ref12, scope) {
2181 var interaction = _ref12.interaction,
2182 event = _ref12.event,
2183 dragEvent = _ref12.iEvent;
2184
2185 if (interaction.prepared.name !== 'drag') {
2186 return;
2187 }
2188
2189 var dropState = interaction.dropState; // reset active dropzones
2190
2191 dropState.activeDrops = null;
2192 dropState.events = null;
2193 dropState.activeDrops = getActiveDrops(scope, interaction.element);
2194 dropState.events = getDropEvents(interaction, event, dragEvent);
2195
2196 if (dropState.events.activate) {
2197 fireActivationEvents(dropState.activeDrops, dropState.events.activate);
2198 scope.fire('actions/drop:start', {
2199 interaction: interaction,
2200 dragEvent: dragEvent
2201 });
2202 }
2203 },
2204 // FIXME proper signal types
2205 'interactions:action-move': onEventCreated,
2206 'interactions:action-end': onEventCreated,
2207 'interactions:after-action-move': function fireDropAfterMove(_ref13, scope) {
2208 var interaction = _ref13.interaction,
2209 dragEvent = _ref13.iEvent;
2210
2211 if (interaction.prepared.name !== 'drag') {
2212 return;
2213 }
2214
2215 fireDropEvents(interaction, interaction.dropState.events);
2216 scope.fire('actions/drop:move', {
2217 interaction: interaction,
2218 dragEvent: dragEvent
2219 });
2220 interaction.dropState.events = {};
2221 },
2222 'interactions:after-action-end': function interactionsAfterActionEnd(_ref14, scope) {
2223 var interaction = _ref14.interaction,
2224 dragEvent = _ref14.iEvent;
2225
2226 if (interaction.prepared.name !== 'drag') {
2227 return;
2228 }
2229
2230 fireDropEvents(interaction, interaction.dropState.events);
2231 scope.fire('actions/drop:end', {
2232 interaction: interaction,
2233 dragEvent: dragEvent
2234 });
2235 },
2236 'interactions:stop': function interactionsStop(_ref15) {
2237 var interaction = _ref15.interaction;
2238
2239 if (interaction.prepared.name !== 'drag') {
2240 return;
2241 }
2242
2243 var dropState = interaction.dropState;
2244
2245 if (dropState) {
2246 dropState.activeDrops = null;
2247 dropState.events = null;
2248 dropState.cur.dropzone = null;
2249 dropState.cur.element = null;
2250 dropState.prev.dropzone = null;
2251 dropState.prev.element = null;
2252 dropState.rejected = false;
2253 }
2254 }
2255 },
2256 getActiveDrops: getActiveDrops,
2257 getDrop: getDrop,
2258 getDropEvents: getDropEvents,
2259 fireDropEvents: fireDropEvents,
2260 defaults: {
2261 enabled: false,
2262 accept: null,
2263 overlap: 'pointer'
2264 }
2265 };
2266 var ___default_3 = drop;
2267 _$plugin_3["default"] = ___default_3;
2268 var _$plugin_4 = {};
2269 "use strict";
2270
2271 Object.defineProperty(_$plugin_4, "__esModule", {
2272 value: true
2273 });
2274 _$plugin_4["default"] = void 0;
2275 /* removed: var _$is_76 = require("../../utils/is.js"); */
2276
2277 ;
2278 /* removed: var _$pointerUtils_81 = require("../../utils/pointerUtils.js"); */
2279
2280 ;
2281
2282 function __install_4(scope) {
2283 var actions = scope.actions,
2284 Interactable = scope.Interactable,
2285 defaults = scope.defaults;
2286 /**
2287 * ```js
2288 * interact(element).gesturable({
2289 * onstart: function (event) {},
2290 * onmove : function (event) {},
2291 * onend : function (event) {},
2292 *
2293 * // limit multiple gestures.
2294 * // See the explanation in {@link Interactable.draggable} example
2295 * max: Infinity,
2296 * maxPerElement: 1,
2297 * })
2298 *
2299 * var isGestureable = interact(element).gesturable()
2300 * ```
2301 *
2302 * Gets or sets whether multitouch gestures can be performed on the target
2303 *
2304 * @param {boolean | object} [options] true/false or An object with event
2305 * listeners to be fired on gesture events (makes the Interactable gesturable)
2306 * @return {boolean | Interactable} A boolean indicating if this can be the
2307 * target of gesture events, or this Interactable
2308 */
2309
2310 Interactable.prototype.gesturable = function (options) {
2311 if (_$is_76["default"].object(options)) {
2312 this.options.gesture.enabled = options.enabled !== false;
2313 this.setPerAction('gesture', options);
2314 this.setOnEvents('gesture', options);
2315 return this;
2316 }
2317
2318 if (_$is_76["default"].bool(options)) {
2319 this.options.gesture.enabled = options;
2320 return this;
2321 }
2322
2323 return this.options.gesture;
2324 };
2325
2326 actions.map.gesture = gesture;
2327 actions.methodDict.gesture = 'gesturable';
2328 defaults.actions.gesture = gesture.defaults;
2329 }
2330
2331 function updateGestureProps(_ref) {
2332 var interaction = _ref.interaction,
2333 iEvent = _ref.iEvent,
2334 phase = _ref.phase;
2335
2336 if (interaction.prepared.name !== 'gesture') {
2337 return;
2338 }
2339
2340 var pointers = interaction.pointers.map(function (p) {
2341 return p.pointer;
2342 });
2343 var starting = phase === 'start';
2344 var ending = phase === 'end';
2345 var deltaSource = interaction.interactable.options.deltaSource;
2346 iEvent.touches = [pointers[0], pointers[1]];
2347
2348 if (starting) {
2349 iEvent.distance = _$pointerUtils_81.touchDistance(pointers, deltaSource);
2350 iEvent.box = _$pointerUtils_81.touchBBox(pointers);
2351 iEvent.scale = 1;
2352 iEvent.ds = 0;
2353 iEvent.angle = _$pointerUtils_81.touchAngle(pointers, deltaSource);
2354 iEvent.da = 0;
2355 interaction.gesture.startDistance = iEvent.distance;
2356 interaction.gesture.startAngle = iEvent.angle;
2357 } else if (ending) {
2358 var prevEvent = interaction.prevEvent;
2359 iEvent.distance = prevEvent.distance;
2360 iEvent.box = prevEvent.box;
2361 iEvent.scale = prevEvent.scale;
2362 iEvent.ds = 0;
2363 iEvent.angle = prevEvent.angle;
2364 iEvent.da = 0;
2365 } else {
2366 iEvent.distance = _$pointerUtils_81.touchDistance(pointers, deltaSource);
2367 iEvent.box = _$pointerUtils_81.touchBBox(pointers);
2368 iEvent.scale = iEvent.distance / interaction.gesture.startDistance;
2369 iEvent.angle = _$pointerUtils_81.touchAngle(pointers, deltaSource);
2370 iEvent.ds = iEvent.scale - interaction.gesture.scale;
2371 iEvent.da = iEvent.angle - interaction.gesture.angle;
2372 }
2373
2374 interaction.gesture.distance = iEvent.distance;
2375 interaction.gesture.angle = iEvent.angle;
2376
2377 if (_$is_76["default"].number(iEvent.scale) && iEvent.scale !== Infinity && !isNaN(iEvent.scale)) {
2378 interaction.gesture.scale = iEvent.scale;
2379 }
2380 }
2381
2382 var gesture = {
2383 id: 'actions/gesture',
2384 before: ['actions/drag', 'actions/resize'],
2385 install: __install_4,
2386 listeners: {
2387 'interactions:action-start': updateGestureProps,
2388 'interactions:action-move': updateGestureProps,
2389 'interactions:action-end': updateGestureProps,
2390 'interactions:new': function interactionsNew(_ref2) {
2391 var interaction = _ref2.interaction;
2392 interaction.gesture = {
2393 angle: 0,
2394 distance: 0,
2395 scale: 1,
2396 startAngle: 0,
2397 startDistance: 0
2398 };
2399 },
2400 'auto-start:check': function autoStartCheck(arg) {
2401 if (arg.interaction.pointers.length < 2) {
2402 return undefined;
2403 }
2404
2405 var gestureOptions = arg.interactable.options.gesture;
2406
2407 if (!(gestureOptions && gestureOptions.enabled)) {
2408 return undefined;
2409 }
2410
2411 arg.action = {
2412 name: 'gesture'
2413 };
2414 return false;
2415 }
2416 },
2417 defaults: {},
2418 getCursor: function getCursor() {
2419 return '';
2420 }
2421 };
2422 var ___default_4 = gesture;
2423 _$plugin_4["default"] = ___default_4;
2424 var _$plugin_6 = {};
2425 "use strict";
2426
2427 Object.defineProperty(_$plugin_6, "__esModule", {
2428 value: true
2429 });
2430 _$plugin_6["default"] = void 0;
2431 /* removed: var _$domUtils_71 = require("../../utils/domUtils.js"); */
2432
2433 ;
2434 /* removed: var _$extend_73 = require("../../utils/extend.js"); */
2435
2436 ;
2437 /* removed: var _$is_76 = require("../../utils/is.js"); */
2438
2439 ;
2440
2441 function __install_6(scope) {
2442 var actions = scope.actions,
2443 browser = scope.browser,
2444 Interactable = scope.Interactable,
2445 defaults = scope.defaults; // Less Precision with touch input
2446
2447 resize.cursors = initCursors(browser);
2448 resize.defaultMargin = browser.supportsTouch || browser.supportsPointerEvent ? 20 : 10;
2449 /**
2450 * ```js
2451 * interact(element).resizable({
2452 * onstart: function (event) {},
2453 * onmove : function (event) {},
2454 * onend : function (event) {},
2455 *
2456 * edges: {
2457 * top : true, // Use pointer coords to check for resize.
2458 * left : false, // Disable resizing from left edge.
2459 * bottom: '.resize-s',// Resize if pointer target matches selector
2460 * right : handleEl // Resize if pointer target is the given Element
2461 * },
2462 *
2463 * // Width and height can be adjusted independently. When `true`, width and
2464 * // height are adjusted at a 1:1 ratio.
2465 * square: false,
2466 *
2467 * // Width and height can be adjusted independently. When `true`, width and
2468 * // height maintain the aspect ratio they had when resizing started.
2469 * preserveAspectRatio: false,
2470 *
2471 * // a value of 'none' will limit the resize rect to a minimum of 0x0
2472 * // 'negate' will allow the rect to have negative width/height
2473 * // 'reposition' will keep the width/height positive by swapping
2474 * // the top and bottom edges and/or swapping the left and right edges
2475 * invert: 'none' || 'negate' || 'reposition'
2476 *
2477 * // limit multiple resizes.
2478 * // See the explanation in the {@link Interactable.draggable} example
2479 * max: Infinity,
2480 * maxPerElement: 1,
2481 * })
2482 *
2483 * var isResizeable = interact(element).resizable()
2484 * ```
2485 *
2486 * Gets or sets whether resize actions can be performed on the target
2487 *
2488 * @param {boolean | object} [options] true/false or An object with event
2489 * listeners to be fired on resize events (object makes the Interactable
2490 * resizable)
2491 * @return {boolean | Interactable} A boolean indicating if this can be the
2492 * target of resize elements, or this Interactable
2493 */
2494
2495 Interactable.prototype.resizable = function (options) {
2496 return resizable(this, options, scope);
2497 };
2498
2499 actions.map.resize = resize;
2500 actions.methodDict.resize = 'resizable';
2501 defaults.actions.resize = resize.defaults;
2502 }
2503
2504 function resizeChecker(arg) {
2505 var interaction = arg.interaction,
2506 interactable = arg.interactable,
2507 element = arg.element,
2508 rect = arg.rect,
2509 buttons = arg.buttons;
2510
2511 if (!rect) {
2512 return undefined;
2513 }
2514
2515 var page = (0, _$extend_73["default"])({}, interaction.coords.cur.page);
2516 var resizeOptions = interactable.options.resize;
2517
2518 if (!(resizeOptions && resizeOptions.enabled) || // check mouseButton setting if the pointer is down
2519 interaction.pointerIsDown && /mouse|pointer/.test(interaction.pointerType) && (buttons & resizeOptions.mouseButtons) === 0) {
2520 return undefined;
2521 } // if using resize.edges
2522
2523
2524 if (_$is_76["default"].object(resizeOptions.edges)) {
2525 var resizeEdges = {
2526 left: false,
2527 right: false,
2528 top: false,
2529 bottom: false
2530 };
2531
2532 for (var edge in resizeEdges) {
2533 resizeEdges[edge] = checkResizeEdge(edge, resizeOptions.edges[edge], page, interaction._latestPointer.eventTarget, element, rect, resizeOptions.margin || resize.defaultMargin);
2534 }
2535
2536 resizeEdges.left = resizeEdges.left && !resizeEdges.right;
2537 resizeEdges.top = resizeEdges.top && !resizeEdges.bottom;
2538
2539 if (resizeEdges.left || resizeEdges.right || resizeEdges.top || resizeEdges.bottom) {
2540 arg.action = {
2541 name: 'resize',
2542 edges: resizeEdges
2543 };
2544 }
2545 } else {
2546 var right = resizeOptions.axis !== 'y' && page.x > rect.right - resize.defaultMargin;
2547 var bottom = resizeOptions.axis !== 'x' && page.y > rect.bottom - resize.defaultMargin;
2548
2549 if (right || bottom) {
2550 arg.action = {
2551 name: 'resize',
2552 axes: (right ? 'x' : '') + (bottom ? 'y' : '')
2553 };
2554 }
2555 }
2556
2557 return arg.action ? false : undefined;
2558 }
2559
2560 function resizable(interactable, options, scope) {
2561 if (_$is_76["default"].object(options)) {
2562 interactable.options.resize.enabled = options.enabled !== false;
2563 interactable.setPerAction('resize', options);
2564 interactable.setOnEvents('resize', options);
2565
2566 if (_$is_76["default"].string(options.axis) && /^x$|^y$|^xy$/.test(options.axis)) {
2567 interactable.options.resize.axis = options.axis;
2568 } else if (options.axis === null) {
2569 interactable.options.resize.axis = scope.defaults.actions.resize.axis;
2570 }
2571
2572 if (_$is_76["default"].bool(options.preserveAspectRatio)) {
2573 interactable.options.resize.preserveAspectRatio = options.preserveAspectRatio;
2574 } else if (_$is_76["default"].bool(options.square)) {
2575 interactable.options.resize.square = options.square;
2576 }
2577
2578 return interactable;
2579 }
2580
2581 if (_$is_76["default"].bool(options)) {
2582 interactable.options.resize.enabled = options;
2583 return interactable;
2584 }
2585
2586 return interactable.options.resize;
2587 }
2588
2589 function checkResizeEdge(name, value, page, element, interactableElement, rect, margin) {
2590 // false, '', undefined, null
2591 if (!value) {
2592 return false;
2593 } // true value, use pointer coords and element rect
2594
2595
2596 if (value === true) {
2597 // if dimensions are negative, "switch" edges
2598 var width = _$is_76["default"].number(rect.width) ? rect.width : rect.right - rect.left;
2599 var height = _$is_76["default"].number(rect.height) ? rect.height : rect.bottom - rect.top; // don't use margin greater than half the relevent dimension
2600
2601 margin = Math.min(margin, Math.abs((name === 'left' || name === 'right' ? width : height) / 2));
2602
2603 if (width < 0) {
2604 if (name === 'left') {
2605 name = 'right';
2606 } else if (name === 'right') {
2607 name = 'left';
2608 }
2609 }
2610
2611 if (height < 0) {
2612 if (name === 'top') {
2613 name = 'bottom';
2614 } else if (name === 'bottom') {
2615 name = 'top';
2616 }
2617 }
2618
2619 if (name === 'left') {
2620 return page.x < (width >= 0 ? rect.left : rect.right) + margin;
2621 }
2622
2623 if (name === 'top') {
2624 return page.y < (height >= 0 ? rect.top : rect.bottom) + margin;
2625 }
2626
2627 if (name === 'right') {
2628 return page.x > (width >= 0 ? rect.right : rect.left) - margin;
2629 }
2630
2631 if (name === 'bottom') {
2632 return page.y > (height >= 0 ? rect.bottom : rect.top) - margin;
2633 }
2634 } // the remaining checks require an element
2635
2636
2637 if (!_$is_76["default"].element(element)) {
2638 return false;
2639 }
2640
2641 return _$is_76["default"].element(value) // the value is an element to use as a resize handle
2642 ? value === element // otherwise check if element matches value as selector
2643 : _$domUtils_71.matchesUpTo(element, value, interactableElement);
2644 }
2645
2646 function initCursors(browser) {
2647 return browser.isIe9 ? {
2648 x: 'e-resize',
2649 y: 's-resize',
2650 xy: 'se-resize',
2651 top: 'n-resize',
2652 left: 'w-resize',
2653 bottom: 's-resize',
2654 right: 'e-resize',
2655 topleft: 'se-resize',
2656 bottomright: 'se-resize',
2657 topright: 'ne-resize',
2658 bottomleft: 'ne-resize'
2659 } : {
2660 x: 'ew-resize',
2661 y: 'ns-resize',
2662 xy: 'nwse-resize',
2663 top: 'ns-resize',
2664 left: 'ew-resize',
2665 bottom: 'ns-resize',
2666 right: 'ew-resize',
2667 topleft: 'nwse-resize',
2668 bottomright: 'nwse-resize',
2669 topright: 'nesw-resize',
2670 bottomleft: 'nesw-resize'
2671 };
2672 }
2673
2674 function start(_ref) {
2675 var iEvent = _ref.iEvent,
2676 interaction = _ref.interaction;
2677
2678 if (interaction.prepared.name !== 'resize' || !interaction.prepared.edges) {
2679 return;
2680 }
2681
2682 var resizeEvent = iEvent;
2683 var rect = interaction.rect;
2684 interaction._rects = {
2685 start: (0, _$extend_73["default"])({}, rect),
2686 corrected: (0, _$extend_73["default"])({}, rect),
2687 previous: (0, _$extend_73["default"])({}, rect),
2688 delta: {
2689 left: 0,
2690 right: 0,
2691 width: 0,
2692 top: 0,
2693 bottom: 0,
2694 height: 0
2695 }
2696 };
2697 resizeEvent.edges = interaction.prepared.edges;
2698 resizeEvent.rect = interaction._rects.corrected;
2699 resizeEvent.deltaRect = interaction._rects.delta;
2700 }
2701
2702 function __move_6(_ref2) {
2703 var iEvent = _ref2.iEvent,
2704 interaction = _ref2.interaction;
2705
2706 if (interaction.prepared.name !== 'resize' || !interaction.prepared.edges) {
2707 return;
2708 }
2709
2710 var resizeEvent = iEvent;
2711 var resizeOptions = interaction.interactable.options.resize;
2712 var invert = resizeOptions.invert;
2713 var invertible = invert === 'reposition' || invert === 'negate'; // eslint-disable-next-line no-shadow
2714
2715 var current = interaction.rect;
2716 var _interaction$_rects = interaction._rects,
2717 startRect = _interaction$_rects.start,
2718 corrected = _interaction$_rects.corrected,
2719 deltaRect = _interaction$_rects.delta,
2720 previous = _interaction$_rects.previous;
2721 (0, _$extend_73["default"])(previous, corrected);
2722
2723 if (invertible) {
2724 // if invertible, copy the current rect
2725 (0, _$extend_73["default"])(corrected, current);
2726
2727 if (invert === 'reposition') {
2728 // swap edge values if necessary to keep width/height positive
2729 if (corrected.top > corrected.bottom) {
2730 var swap = corrected.top;
2731 corrected.top = corrected.bottom;
2732 corrected.bottom = swap;
2733 }
2734
2735 if (corrected.left > corrected.right) {
2736 var _swap = corrected.left;
2737 corrected.left = corrected.right;
2738 corrected.right = _swap;
2739 }
2740 }
2741 } else {
2742 // if not invertible, restrict to minimum of 0x0 rect
2743 corrected.top = Math.min(current.top, startRect.bottom);
2744 corrected.bottom = Math.max(current.bottom, startRect.top);
2745 corrected.left = Math.min(current.left, startRect.right);
2746 corrected.right = Math.max(current.right, startRect.left);
2747 }
2748
2749 corrected.width = corrected.right - corrected.left;
2750 corrected.height = corrected.bottom - corrected.top;
2751
2752 for (var edge in corrected) {
2753 deltaRect[edge] = corrected[edge] - previous[edge];
2754 }
2755
2756 resizeEvent.edges = interaction.prepared.edges;
2757 resizeEvent.rect = corrected;
2758 resizeEvent.deltaRect = deltaRect;
2759 }
2760
2761 function end(_ref3) {
2762 var iEvent = _ref3.iEvent,
2763 interaction = _ref3.interaction;
2764
2765 if (interaction.prepared.name !== 'resize' || !interaction.prepared.edges) {
2766 return;
2767 }
2768
2769 var resizeEvent = iEvent;
2770 resizeEvent.edges = interaction.prepared.edges;
2771 resizeEvent.rect = interaction._rects.corrected;
2772 resizeEvent.deltaRect = interaction._rects.delta;
2773 }
2774
2775 function updateEventAxes(_ref4) {
2776 var iEvent = _ref4.iEvent,
2777 interaction = _ref4.interaction;
2778
2779 if (interaction.prepared.name !== 'resize' || !interaction.resizeAxes) {
2780 return;
2781 }
2782
2783 var options = interaction.interactable.options;
2784 var resizeEvent = iEvent;
2785
2786 if (options.resize.square) {
2787 if (interaction.resizeAxes === 'y') {
2788 resizeEvent.delta.x = resizeEvent.delta.y;
2789 } else {
2790 resizeEvent.delta.y = resizeEvent.delta.x;
2791 }
2792
2793 resizeEvent.axes = 'xy';
2794 } else {
2795 resizeEvent.axes = interaction.resizeAxes;
2796
2797 if (interaction.resizeAxes === 'x') {
2798 resizeEvent.delta.y = 0;
2799 } else if (interaction.resizeAxes === 'y') {
2800 resizeEvent.delta.x = 0;
2801 }
2802 }
2803 }
2804
2805 var resize = {
2806 id: 'actions/resize',
2807 before: ['actions/drag'],
2808 install: __install_6,
2809 listeners: {
2810 'interactions:new': function interactionsNew(_ref5) {
2811 var interaction = _ref5.interaction;
2812 interaction.resizeAxes = 'xy';
2813 },
2814 'interactions:action-start': function interactionsActionStart(arg) {
2815 start(arg);
2816 updateEventAxes(arg);
2817 },
2818 'interactions:action-move': function interactionsActionMove(arg) {
2819 __move_6(arg);
2820
2821 updateEventAxes(arg);
2822 },
2823 'interactions:action-end': end,
2824 'auto-start:check': resizeChecker
2825 },
2826 defaults: {
2827 square: false,
2828 preserveAspectRatio: false,
2829 axis: 'xy',
2830 // use default margin
2831 margin: NaN,
2832 // object with props left, right, top, bottom which are
2833 // true/false values to resize when the pointer is over that edge,
2834 // CSS selectors to match the handles for each direction
2835 // or the Elements for each handle
2836 edges: null,
2837 // a value of 'none' will limit the resize rect to a minimum of 0x0
2838 // 'negate' will alow the rect to have negative width/height
2839 // 'reposition' will keep the width/height positive by swapping
2840 // the top and bottom edges and/or swapping the left and right edges
2841 invert: 'none'
2842 },
2843 cursors: null,
2844 getCursor: function getCursor(_ref6) {
2845 var edges = _ref6.edges,
2846 axis = _ref6.axis,
2847 name = _ref6.name;
2848 var cursors = resize.cursors;
2849 var result = null;
2850
2851 if (axis) {
2852 result = cursors[name + axis];
2853 } else if (edges) {
2854 var cursorKey = '';
2855 var _arr = ['top', 'bottom', 'left', 'right'];
2856
2857 for (var _i = 0; _i < _arr.length; _i++) {
2858 var edge = _arr[_i];
2859
2860 if (edges[edge]) {
2861 cursorKey += edge;
2862 }
2863 }
2864
2865 result = cursors[cursorKey];
2866 }
2867
2868 return result;
2869 },
2870 defaultMargin: null
2871 };
2872 var ___default_6 = resize;
2873 _$plugin_6["default"] = ___default_6;
2874 var _$plugin_5 = {};
2875 "use strict";
2876
2877 Object.defineProperty(_$plugin_5, "__esModule", {
2878 value: true
2879 });
2880 _$plugin_5["default"] = void 0;
2881 /* removed: var _$plugin_1 = require("./drag/plugin.js"); */
2882
2883 ;
2884 /* removed: var _$plugin_3 = require("./drop/plugin.js"); */
2885
2886 ;
2887 /* removed: var _$plugin_4 = require("./gesture/plugin.js"); */
2888
2889 ;
2890 /* removed: var _$plugin_6 = require("./resize/plugin.js"); */
2891
2892 ;
2893 var ___default_5 = {
2894 id: 'actions',
2895 install: function install(scope) {
2896 scope.usePlugin(_$plugin_4["default"]);
2897 scope.usePlugin(_$plugin_6["default"]);
2898 scope.usePlugin(_$plugin_1["default"]);
2899 scope.usePlugin(_$plugin_3["default"]);
2900 }
2901 };
2902 _$plugin_5["default"] = ___default_5;
2903 var _$plugin_7 = {};
2904 "use strict";
2905
2906 Object.defineProperty(_$plugin_7, "__esModule", {
2907 value: true
2908 });
2909 _$plugin_7["default"] = void 0;
2910 var ___default_7 = {};
2911 _$plugin_7["default"] = ___default_7;
2912 var _$raf_82 = {};
2913 "use strict";
2914
2915 Object.defineProperty(_$raf_82, "__esModule", {
2916 value: true
2917 });
2918 _$raf_82["default"] = void 0;
2919 var lastTime = 0;
2920
2921 var _request;
2922
2923 var _cancel;
2924
2925 function __init_82(window) {
2926 _request = window.requestAnimationFrame;
2927 _cancel = window.cancelAnimationFrame;
2928
2929 if (!_request) {
2930 var vendors = ['ms', 'moz', 'webkit', 'o'];
2931
2932 for (var _i = 0; _i < vendors.length; _i++) {
2933 var vendor = vendors[_i];
2934 _request = window["".concat(vendor, "RequestAnimationFrame")];
2935 _cancel = window["".concat(vendor, "CancelAnimationFrame")] || window["".concat(vendor, "CancelRequestAnimationFrame")];
2936 }
2937 }
2938
2939 if (!_request) {
2940 _request = function request(callback) {
2941 var currTime = Date.now();
2942 var timeToCall = Math.max(0, 16 - (currTime - lastTime)); // eslint-disable-next-line standard/no-callback-literal
2943
2944 var token = setTimeout(function () {
2945 callback(currTime + timeToCall);
2946 }, timeToCall);
2947 lastTime = currTime + timeToCall;
2948 return token;
2949 };
2950
2951 _cancel = function cancel(token) {
2952 return clearTimeout(token);
2953 };
2954 }
2955 }
2956
2957 var ___default_82 = {
2958 request: function request(callback) {
2959 return _request(callback);
2960 },
2961 cancel: function cancel(token) {
2962 return _cancel(token);
2963 },
2964 init: __init_82
2965 };
2966 _$raf_82["default"] = ___default_82;
2967 var _$plugin_8 = {};
2968 "use strict";
2969
2970 Object.defineProperty(_$plugin_8, "__esModule", {
2971 value: true
2972 });
2973 _$plugin_8.getContainer = getContainer;
2974 _$plugin_8.getScroll = getScroll;
2975 _$plugin_8.getScrollSize = getScrollSize;
2976 _$plugin_8.getScrollSizeDelta = getScrollSizeDelta;
2977 _$plugin_8["default"] = void 0;
2978 /* removed: var _$domUtils_71 = require("../utils/domUtils.js"); */
2979
2980 ;
2981 /* removed: var _$is_76 = require("../utils/is.js"); */
2982
2983 ;
2984 /* removed: var _$raf_82 = require("../utils/raf.js"); */
2985
2986 ;
2987 /* removed: var _$rect_83 = require("../utils/rect.js"); */
2988
2989 ;
2990 /* removed: var _$window_84 = require("../utils/window.js"); */
2991
2992 ;
2993
2994 function __install_8(scope) {
2995 var defaults = scope.defaults,
2996 actions = scope.actions;
2997 scope.autoScroll = autoScroll;
2998
2999 autoScroll.now = function () {
3000 return scope.now();
3001 };
3002
3003 actions.phaselessTypes.autoscroll = true;
3004 defaults.perAction.autoScroll = autoScroll.defaults;
3005 }
3006
3007 var autoScroll = {
3008 defaults: {
3009 enabled: false,
3010 margin: 60,
3011 // the item that is scrolled (Window or HTMLElement)
3012 container: null,
3013 // the scroll speed in pixels per second
3014 speed: 300
3015 },
3016 now: Date.now,
3017 interaction: null,
3018 i: 0,
3019 // the handle returned by window.setInterval
3020 // Direction each pulse is to scroll in
3021 x: 0,
3022 y: 0,
3023 isScrolling: false,
3024 prevTime: 0,
3025 margin: 0,
3026 speed: 0,
3027 start: function start(interaction) {
3028 autoScroll.isScrolling = true;
3029
3030 _$raf_82["default"].cancel(autoScroll.i);
3031
3032 interaction.autoScroll = autoScroll;
3033 autoScroll.interaction = interaction;
3034 autoScroll.prevTime = autoScroll.now();
3035 autoScroll.i = _$raf_82["default"].request(autoScroll.scroll);
3036 },
3037 stop: function stop() {
3038 autoScroll.isScrolling = false;
3039
3040 if (autoScroll.interaction) {
3041 autoScroll.interaction.autoScroll = null;
3042 }
3043
3044 _$raf_82["default"].cancel(autoScroll.i);
3045 },
3046 // scroll the window by the values in scroll.x/y
3047 scroll: function scroll() {
3048 var interaction = autoScroll.interaction;
3049 var interactable = interaction.interactable,
3050 element = interaction.element;
3051 var actionName = interaction.prepared.name;
3052 var options = interactable.options[actionName].autoScroll;
3053 var container = getContainer(options.container, interactable, element);
3054 var now = autoScroll.now(); // change in time in seconds
3055
3056 var dt = (now - autoScroll.prevTime) / 1000; // displacement
3057
3058 var s = options.speed * dt;
3059
3060 if (s >= 1) {
3061 var scrollBy = {
3062 x: autoScroll.x * s,
3063 y: autoScroll.y * s
3064 };
3065
3066 if (scrollBy.x || scrollBy.y) {
3067 var prevScroll = getScroll(container);
3068
3069 if (_$is_76["default"].window(container)) {
3070 container.scrollBy(scrollBy.x, scrollBy.y);
3071 } else if (container) {
3072 container.scrollLeft += scrollBy.x;
3073 container.scrollTop += scrollBy.y;
3074 }
3075
3076 var curScroll = getScroll(container);
3077 var delta = {
3078 x: curScroll.x - prevScroll.x,
3079 y: curScroll.y - prevScroll.y
3080 };
3081
3082 if (delta.x || delta.y) {
3083 interactable.fire({
3084 type: 'autoscroll',
3085 target: element,
3086 interactable: interactable,
3087 delta: delta,
3088 interaction: interaction,
3089 container: container
3090 });
3091 }
3092 }
3093
3094 autoScroll.prevTime = now;
3095 }
3096
3097 if (autoScroll.isScrolling) {
3098 _$raf_82["default"].cancel(autoScroll.i);
3099
3100 autoScroll.i = _$raf_82["default"].request(autoScroll.scroll);
3101 }
3102 },
3103 check: function check(interactable, actionName) {
3104 var options = interactable.options;
3105 return options[actionName].autoScroll && options[actionName].autoScroll.enabled;
3106 },
3107 onInteractionMove: function onInteractionMove(_ref) {
3108 var interaction = _ref.interaction,
3109 pointer = _ref.pointer;
3110
3111 if (!(interaction.interacting() && autoScroll.check(interaction.interactable, interaction.prepared.name))) {
3112 return;
3113 }
3114
3115 if (interaction.simulation) {
3116 autoScroll.x = autoScroll.y = 0;
3117 return;
3118 }
3119
3120 var top;
3121 var right;
3122 var bottom;
3123 var left;
3124 var interactable = interaction.interactable,
3125 element = interaction.element;
3126 var actionName = interaction.prepared.name;
3127 var options = interactable.options[actionName].autoScroll;
3128 var container = getContainer(options.container, interactable, element);
3129
3130 if (_$is_76["default"].window(container)) {
3131 left = pointer.clientX < autoScroll.margin;
3132 top = pointer.clientY < autoScroll.margin;
3133 right = pointer.clientX > container.innerWidth - autoScroll.margin;
3134 bottom = pointer.clientY > container.innerHeight - autoScroll.margin;
3135 } else {
3136 var rect = _$domUtils_71.getElementClientRect(container);
3137
3138 left = pointer.clientX < rect.left + autoScroll.margin;
3139 top = pointer.clientY < rect.top + autoScroll.margin;
3140 right = pointer.clientX > rect.right - autoScroll.margin;
3141 bottom = pointer.clientY > rect.bottom - autoScroll.margin;
3142 }
3143
3144 autoScroll.x = right ? 1 : left ? -1 : 0;
3145 autoScroll.y = bottom ? 1 : top ? -1 : 0;
3146
3147 if (!autoScroll.isScrolling) {
3148 // set the autoScroll properties to those of the target
3149 autoScroll.margin = options.margin;
3150 autoScroll.speed = options.speed;
3151 autoScroll.start(interaction);
3152 }
3153 }
3154 };
3155
3156 function getContainer(value, interactable, element) {
3157 return (_$is_76["default"].string(value) ? (0, _$rect_83.getStringOptionResult)(value, interactable, element) : value) || (0, _$window_84.getWindow)(element);
3158 }
3159
3160 function getScroll(container) {
3161 if (_$is_76["default"].window(container)) {
3162 container = window.document.body;
3163 }
3164
3165 return {
3166 x: container.scrollLeft,
3167 y: container.scrollTop
3168 };
3169 }
3170
3171 function getScrollSize(container) {
3172 if (_$is_76["default"].window(container)) {
3173 container = window.document.body;
3174 }
3175
3176 return {
3177 x: container.scrollWidth,
3178 y: container.scrollHeight
3179 };
3180 }
3181
3182 function getScrollSizeDelta(_ref2, func) {
3183 var interaction = _ref2.interaction,
3184 element = _ref2.element;
3185 var scrollOptions = interaction && interaction.interactable.options[interaction.prepared.name].autoScroll;
3186
3187 if (!scrollOptions || !scrollOptions.enabled) {
3188 func();
3189 return {
3190 x: 0,
3191 y: 0
3192 };
3193 }
3194
3195 var scrollContainer = getContainer(scrollOptions.container, interaction.interactable, element);
3196 var prevSize = getScroll(scrollContainer);
3197 func();
3198 var curSize = getScroll(scrollContainer);
3199 return {
3200 x: curSize.x - prevSize.x,
3201 y: curSize.y - prevSize.y
3202 };
3203 }
3204
3205 var autoScrollPlugin = {
3206 id: 'auto-scroll',
3207 install: __install_8,
3208 listeners: {
3209 'interactions:new': function interactionsNew(_ref3) {
3210 var interaction = _ref3.interaction;
3211 interaction.autoScroll = null;
3212 },
3213 'interactions:destroy': function interactionsDestroy(_ref4) {
3214 var interaction = _ref4.interaction;
3215 interaction.autoScroll = null;
3216 autoScroll.stop();
3217
3218 if (autoScroll.interaction) {
3219 autoScroll.interaction = null;
3220 }
3221 },
3222 'interactions:stop': autoScroll.stop,
3223 'interactions:action-move': function interactionsActionMove(arg) {
3224 return autoScroll.onInteractionMove(arg);
3225 }
3226 }
3227 };
3228 var ___default_8 = autoScrollPlugin;
3229 _$plugin_8["default"] = ___default_8;
3230 var _$misc_78 = {};
3231 "use strict";
3232
3233 Object.defineProperty(_$misc_78, "__esModule", {
3234 value: true
3235 });
3236 _$misc_78.warnOnce = warnOnce;
3237 _$misc_78.copyAction = copyAction;
3238 /* removed: var _$window_84 = require("./window.js"); */
3239
3240 ;
3241
3242 function warnOnce(method, message) {
3243 var warned = false;
3244 return function () {
3245 if (!warned) {
3246 _$window_84["default"].window.console.warn(message);
3247
3248 warned = true;
3249 }
3250
3251 return method.apply(this, arguments);
3252 };
3253 }
3254
3255 function copyAction(dest, src) {
3256 dest.name = src.name;
3257 dest.axis = src.axis;
3258 dest.edges = src.edges;
3259 return dest;
3260 }
3261
3262 var _$InteractableMethods_9 = {};
3263 "use strict";
3264
3265 Object.defineProperty(_$InteractableMethods_9, "__esModule", {
3266 value: true
3267 });
3268 _$InteractableMethods_9["default"] = void 0;
3269 /* removed: var _$is_76 = require("../utils/is.js"); */
3270
3271 ;
3272 /* removed: var _$misc_78 = require("../utils/misc.js"); */
3273
3274 ;
3275
3276 function __install_9(scope) {
3277 var Interactable = scope.Interactable;
3278
3279 Interactable.prototype.getAction = function getAction(pointer, event, interaction, element) {
3280 var action = defaultActionChecker(this, event, interaction, element, scope);
3281
3282 if (this.options.actionChecker) {
3283 return this.options.actionChecker(pointer, event, action, this, element, interaction);
3284 }
3285
3286 return action;
3287 };
3288 /**
3289 * ```js
3290 * interact(element, { ignoreFrom: document.getElementById('no-action') })
3291 * // or
3292 * interact(element).ignoreFrom('input, textarea, a')
3293 * ```
3294 * @deprecated
3295 * If the target of the `mousedown`, `pointerdown` or `touchstart` event or any
3296 * of it's parents match the given CSS selector or Element, no
3297 * drag/resize/gesture is started.
3298 *
3299 * Don't use this method. Instead set the `ignoreFrom` option for each action
3300 * or for `pointerEvents`
3301 *
3302 * @example
3303 * interact(targett)
3304 * .draggable({
3305 * ignoreFrom: 'input, textarea, a[href]'',
3306 * })
3307 * .pointerEvents({
3308 * ignoreFrom: '[no-pointer]',
3309 * })
3310 *
3311 * @param {string | Element | null} [newValue] a CSS selector string, an
3312 * Element or `null` to not ignore any elements
3313 * @return {string | Element | object} The current ignoreFrom value or this
3314 * Interactable
3315 */
3316
3317
3318 Interactable.prototype.ignoreFrom = (0, _$misc_78.warnOnce)(function (newValue) {
3319 return this._backCompatOption('ignoreFrom', newValue);
3320 }, 'Interactable.ignoreFrom() has been deprecated. Use Interactble.draggable({ignoreFrom: newValue}).');
3321 /**
3322 * @deprecated
3323 *
3324 * A drag/resize/gesture is started only If the target of the `mousedown`,
3325 * `pointerdown` or `touchstart` event or any of it's parents match the given
3326 * CSS selector or Element.
3327 *
3328 * Don't use this method. Instead set the `allowFrom` option for each action
3329 * or for `pointerEvents`
3330 *
3331 * @example
3332 * interact(targett)
3333 * .resizable({
3334 * allowFrom: '.resize-handle',
3335 * .pointerEvents({
3336 * allowFrom: '.handle',,
3337 * })
3338 *
3339 * @param {string | Element | null} [newValue] a CSS selector string, an
3340 * Element or `null` to allow from any element
3341 * @return {string | Element | object} The current allowFrom value or this
3342 * Interactable
3343 */
3344
3345 Interactable.prototype.allowFrom = (0, _$misc_78.warnOnce)(function (newValue) {
3346 return this._backCompatOption('allowFrom', newValue);
3347 }, 'Interactable.allowFrom() has been deprecated. Use Interactble.draggable({allowFrom: newValue}).');
3348 /**
3349 * ```js
3350 * interact('.resize-drag')
3351 * .resizable(true)
3352 * .draggable(true)
3353 * .actionChecker(function (pointer, event, action, interactable, element, interaction) {
3354 *
3355 * if (interact.matchesSelector(event.target, '.drag-handle')) {
3356 * // force drag with handle target
3357 * action.name = drag
3358 * }
3359 * else {
3360 * // resize from the top and right edges
3361 * action.name = 'resize'
3362 * action.edges = { top: true, right: true }
3363 * }
3364 *
3365 * return action
3366 * })
3367 * ```
3368 *
3369 * Returns or sets the function used to check action to be performed on
3370 * pointerDown
3371 *
3372 * @param {function | null} [checker] A function which takes a pointer event,
3373 * defaultAction string, interactable, element and interaction as parameters
3374 * and returns an object with name property 'drag' 'resize' or 'gesture' and
3375 * optionally an `edges` object with boolean 'top', 'left', 'bottom' and right
3376 * props.
3377 * @return {Function | Interactable} The checker function or this Interactable
3378 */
3379
3380 Interactable.prototype.actionChecker = actionChecker;
3381 /**
3382 * Returns or sets whether the the cursor should be changed depending on the
3383 * action that would be performed if the mouse were pressed and dragged.
3384 *
3385 * @param {boolean} [newValue]
3386 * @return {boolean | Interactable} The current setting or this Interactable
3387 */
3388
3389 Interactable.prototype.styleCursor = styleCursor;
3390 }
3391
3392 function defaultActionChecker(interactable, event, interaction, element, scope) {
3393 var rect = interactable.getRect(element);
3394 var buttons = event.buttons || {
3395 0: 1,
3396 1: 4,
3397 3: 8,
3398 4: 16
3399 }[event.button];
3400 var arg = {
3401 action: null,
3402 interactable: interactable,
3403 interaction: interaction,
3404 element: element,
3405 rect: rect,
3406 buttons: buttons
3407 };
3408 scope.fire('auto-start:check', arg);
3409 return arg.action;
3410 }
3411
3412 function styleCursor(newValue) {
3413 if (_$is_76["default"].bool(newValue)) {
3414 this.options.styleCursor = newValue;
3415 return this;
3416 }
3417
3418 if (newValue === null) {
3419 delete this.options.styleCursor;
3420 return this;
3421 }
3422
3423 return this.options.styleCursor;
3424 }
3425
3426 function actionChecker(checker) {
3427 if (_$is_76["default"].func(checker)) {
3428 this.options.actionChecker = checker;
3429 return this;
3430 }
3431
3432 if (checker === null) {
3433 delete this.options.actionChecker;
3434 return this;
3435 }
3436
3437 return this.options.actionChecker;
3438 }
3439
3440 var ___default_9 = {
3441 id: 'auto-start/interactableMethods',
3442 install: __install_9
3443 };
3444 _$InteractableMethods_9["default"] = ___default_9;
3445 var _$base_10 = {};
3446 "use strict";
3447
3448 Object.defineProperty(_$base_10, "__esModule", {
3449 value: true
3450 });
3451 _$base_10["default"] = void 0;
3452 /* removed: var _$domUtils_71 = require("../utils/domUtils.js"); */
3453
3454 ;
3455 /* removed: var _$extend_73 = require("../utils/extend.js"); */
3456
3457 ;
3458 /* removed: var _$is_76 = require("../utils/is.js"); */
3459
3460 ;
3461 /* removed: var _$misc_78 = require("../utils/misc.js"); */
3462
3463 ;
3464 /* removed: var _$InteractableMethods_9 = require("./InteractableMethods.js"); */
3465
3466 ;
3467
3468 function __install_10(scope) {
3469 var interact = scope.interactStatic,
3470 defaults = scope.defaults;
3471 scope.usePlugin(_$InteractableMethods_9["default"]);
3472 defaults.base.actionChecker = null;
3473 defaults.base.styleCursor = true;
3474 (0, _$extend_73["default"])(defaults.perAction, {
3475 manualStart: false,
3476 max: Infinity,
3477 maxPerElement: 1,
3478 allowFrom: null,
3479 ignoreFrom: null,
3480 // only allow left button by default
3481 // see https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons#Return_value
3482 mouseButtons: 1
3483 });
3484 /**
3485 * Returns or sets the maximum number of concurrent interactions allowed. By
3486 * default only 1 interaction is allowed at a time (for backwards
3487 * compatibility). To allow multiple interactions on the same Interactables and
3488 * elements, you need to enable it in the draggable, resizable and gesturable
3489 * `'max'` and `'maxPerElement'` options.
3490 *
3491 * @alias module:interact.maxInteractions
3492 *
3493 * @param {number} [newValue] Any number. newValue <= 0 means no interactions.
3494 */
3495
3496 interact.maxInteractions = function (newValue) {
3497 return maxInteractions(newValue, scope);
3498 };
3499
3500 scope.autoStart = {
3501 // Allow this many interactions to happen simultaneously
3502 maxInteractions: Infinity,
3503 withinInteractionLimit: withinInteractionLimit,
3504 cursorElement: null
3505 };
3506 }
3507
3508 function prepareOnDown(_ref, scope) {
3509 var interaction = _ref.interaction,
3510 pointer = _ref.pointer,
3511 event = _ref.event,
3512 eventTarget = _ref.eventTarget;
3513
3514 if (interaction.interacting()) {
3515 return;
3516 }
3517
3518 var actionInfo = getActionInfo(interaction, pointer, event, eventTarget, scope);
3519 prepare(interaction, actionInfo, scope);
3520 }
3521
3522 function prepareOnMove(_ref2, scope) {
3523 var interaction = _ref2.interaction,
3524 pointer = _ref2.pointer,
3525 event = _ref2.event,
3526 eventTarget = _ref2.eventTarget;
3527
3528 if (interaction.pointerType !== 'mouse' || interaction.pointerIsDown || interaction.interacting()) {
3529 return;
3530 }
3531
3532 var actionInfo = getActionInfo(interaction, pointer, event, eventTarget, scope);
3533 prepare(interaction, actionInfo, scope);
3534 }
3535
3536 function startOnMove(arg, scope) {
3537 var interaction = arg.interaction;
3538
3539 if (!interaction.pointerIsDown || interaction.interacting() || !interaction.pointerWasMoved || !interaction.prepared.name) {
3540 return;
3541 }
3542
3543 scope.fire('autoStart:before-start', arg);
3544 var interactable = interaction.interactable;
3545 var actionName = interaction.prepared.name;
3546
3547 if (actionName && interactable) {
3548 // check manualStart and interaction limit
3549 if (interactable.options[actionName].manualStart || !withinInteractionLimit(interactable, interaction.element, interaction.prepared, scope)) {
3550 interaction.stop();
3551 } else {
3552 interaction.start(interaction.prepared, interactable, interaction.element);
3553 setInteractionCursor(interaction, scope);
3554 }
3555 }
3556 }
3557
3558 function clearCursorOnStop(_ref3, scope) {
3559 var interaction = _ref3.interaction;
3560 var interactable = interaction.interactable;
3561
3562 if (interactable && interactable.options.styleCursor) {
3563 setCursor(interaction.element, '', scope);
3564 }
3565 } // Check if the current interactable supports the action.
3566 // If so, return the validated action. Otherwise, return null
3567
3568
3569 function validateAction(action, interactable, element, eventTarget, scope) {
3570 if (interactable.testIgnoreAllow(interactable.options[action.name], element, eventTarget) && interactable.options[action.name].enabled && withinInteractionLimit(interactable, element, action, scope)) {
3571 return action;
3572 }
3573
3574 return null;
3575 }
3576
3577 function validateMatches(interaction, pointer, event, matches, matchElements, eventTarget, scope) {
3578 for (var i = 0, len = matches.length; i < len; i++) {
3579 var match = matches[i];
3580 var matchElement = matchElements[i];
3581 var matchAction = match.getAction(pointer, event, interaction, matchElement);
3582
3583 if (!matchAction) {
3584 continue;
3585 }
3586
3587 var action = validateAction(matchAction, match, matchElement, eventTarget, scope);
3588
3589 if (action) {
3590 return {
3591 action: action,
3592 interactable: match,
3593 element: matchElement
3594 };
3595 }
3596 }
3597
3598 return {
3599 action: null,
3600 interactable: null,
3601 element: null
3602 };
3603 }
3604
3605 function getActionInfo(interaction, pointer, event, eventTarget, scope) {
3606 var matches = [];
3607 var matchElements = [];
3608 var element = eventTarget;
3609
3610 function pushMatches(interactable) {
3611 matches.push(interactable);
3612 matchElements.push(element);
3613 }
3614
3615 while (_$is_76["default"].element(element)) {
3616 matches = [];
3617 matchElements = [];
3618 scope.interactables.forEachMatch(element, pushMatches);
3619 var actionInfo = validateMatches(interaction, pointer, event, matches, matchElements, eventTarget, scope);
3620
3621 if (actionInfo.action && !actionInfo.interactable.options[actionInfo.action.name].manualStart) {
3622 return actionInfo;
3623 }
3624
3625 element = _$domUtils_71.parentNode(element);
3626 }
3627
3628 return {
3629 action: null,
3630 interactable: null,
3631 element: null
3632 };
3633 }
3634
3635 function prepare(interaction, _ref4, scope) {
3636 var action = _ref4.action,
3637 interactable = _ref4.interactable,
3638 element = _ref4.element;
3639 action = action || {
3640 name: null
3641 };
3642 interaction.interactable = interactable;
3643 interaction.element = element;
3644 (0, _$misc_78.copyAction)(interaction.prepared, action);
3645 interaction.rect = interactable && action.name ? interactable.getRect(element) : null;
3646 setInteractionCursor(interaction, scope);
3647 scope.fire('autoStart:prepared', {
3648 interaction: interaction
3649 });
3650 }
3651
3652 function withinInteractionLimit(interactable, element, action, scope) {
3653 var options = interactable.options;
3654 var maxActions = options[action.name].max;
3655 var maxPerElement = options[action.name].maxPerElement;
3656 var autoStartMax = scope.autoStart.maxInteractions;
3657 var activeInteractions = 0;
3658 var interactableCount = 0;
3659 var elementCount = 0; // no actions if any of these values == 0
3660
3661 if (!(maxActions && maxPerElement && autoStartMax)) {
3662 return false;
3663 }
3664
3665 for (var _i = 0; _i < scope.interactions.list.length; _i++) {
3666 var _ref5;
3667
3668 _ref5 = scope.interactions.list[_i];
3669 var interaction = _ref5;
3670 var otherAction = interaction.prepared.name;
3671
3672 if (!interaction.interacting()) {
3673 continue;
3674 }
3675
3676 activeInteractions++;
3677
3678 if (activeInteractions >= autoStartMax) {
3679 return false;
3680 }
3681
3682 if (interaction.interactable !== interactable) {
3683 continue;
3684 }
3685
3686 interactableCount += otherAction === action.name ? 1 : 0;
3687
3688 if (interactableCount >= maxActions) {
3689 return false;
3690 }
3691
3692 if (interaction.element === element) {
3693 elementCount++;
3694
3695 if (otherAction === action.name && elementCount >= maxPerElement) {
3696 return false;
3697 }
3698 }
3699 }
3700
3701 return autoStartMax > 0;
3702 }
3703
3704 function maxInteractions(newValue, scope) {
3705 if (_$is_76["default"].number(newValue)) {
3706 scope.autoStart.maxInteractions = newValue;
3707 return this;
3708 }
3709
3710 return scope.autoStart.maxInteractions;
3711 }
3712
3713 function setCursor(element, cursor, scope) {
3714 var prevCursorElement = scope.autoStart.cursorElement;
3715
3716 if (prevCursorElement && prevCursorElement !== element) {
3717 prevCursorElement.style.cursor = '';
3718 }
3719
3720 element.ownerDocument.documentElement.style.cursor = cursor;
3721 element.style.cursor = cursor;
3722 scope.autoStart.cursorElement = cursor ? element : null;
3723 }
3724
3725 function setInteractionCursor(interaction, scope) {
3726 var interactable = interaction.interactable,
3727 element = interaction.element,
3728 prepared = interaction.prepared;
3729
3730 if (!(interaction.pointerType === 'mouse' && interactable && interactable.options.styleCursor)) {
3731 // clear previous target element cursor
3732 if (scope.autoStart.cursorElement) {
3733 setCursor(scope.autoStart.cursorElement, '', scope);
3734 }
3735
3736 return;
3737 }
3738
3739 var cursor = '';
3740
3741 if (prepared.name) {
3742 var cursorChecker = interactable.options[prepared.name].cursorChecker;
3743
3744 if (_$is_76["default"].func(cursorChecker)) {
3745 cursor = cursorChecker(prepared, interactable, element, interaction._interacting);
3746 } else {
3747 cursor = scope.actions.map[prepared.name].getCursor(prepared);
3748 }
3749 }
3750
3751 setCursor(interaction.element, cursor || '', scope);
3752 }
3753
3754 var autoStart = {
3755 id: 'auto-start/base',
3756 before: ['actions', 'actions/drag', 'actions/resize', 'actions/gesture'],
3757 install: __install_10,
3758 listeners: {
3759 'interactions:down': prepareOnDown,
3760 'interactions:move': function interactionsMove(arg, scope) {
3761 prepareOnMove(arg, scope);
3762 startOnMove(arg, scope);
3763 },
3764 'interactions:stop': clearCursorOnStop
3765 },
3766 maxInteractions: maxInteractions,
3767 withinInteractionLimit: withinInteractionLimit,
3768 validateAction: validateAction
3769 };
3770 var ___default_10 = autoStart;
3771 _$base_10["default"] = ___default_10;
3772 var _$dragAxis_11 = {};
3773 "use strict";
3774
3775 Object.defineProperty(_$dragAxis_11, "__esModule", {
3776 value: true
3777 });
3778 _$dragAxis_11["default"] = void 0;
3779 /* removed: var _$domUtils_71 = require("../utils/domUtils.js"); */
3780
3781 ;
3782 /* removed: var _$is_76 = require("../utils/is.js"); */
3783
3784 ;
3785 /* removed: var _$base_10 = require("./base.js"); */
3786
3787 ;
3788
3789 function beforeStart(_ref, scope) {
3790 var interaction = _ref.interaction,
3791 eventTarget = _ref.eventTarget,
3792 dx = _ref.dx,
3793 dy = _ref.dy;
3794
3795 if (interaction.prepared.name !== 'drag') {
3796 return;
3797 } // check if a drag is in the correct axis
3798
3799
3800 var absX = Math.abs(dx);
3801 var absY = Math.abs(dy);
3802 var targetOptions = interaction.interactable.options.drag;
3803 var startAxis = targetOptions.startAxis;
3804 var currentAxis = absX > absY ? 'x' : absX < absY ? 'y' : 'xy';
3805 interaction.prepared.axis = targetOptions.lockAxis === 'start' ? currentAxis[0] // always lock to one axis even if currentAxis === 'xy'
3806 : targetOptions.lockAxis; // if the movement isn't in the startAxis of the interactable
3807
3808 if (currentAxis !== 'xy' && startAxis !== 'xy' && startAxis !== currentAxis) {
3809 // cancel the prepared action
3810 interaction.prepared.name = null; // then try to get a drag from another ineractable
3811
3812 var element = eventTarget;
3813
3814 var getDraggable = function getDraggable(interactable) {
3815 if (interactable === interaction.interactable) {
3816 return;
3817 }
3818
3819 var options = interaction.interactable.options.drag;
3820
3821 if (!options.manualStart && interactable.testIgnoreAllow(options, element, eventTarget)) {
3822 var action = interactable.getAction(interaction.downPointer, interaction.downEvent, interaction, element);
3823
3824 if (action && action.name === 'drag' && checkStartAxis(currentAxis, interactable) && _$base_10["default"].validateAction(action, interactable, element, eventTarget, scope)) {
3825 return interactable;
3826 }
3827 }
3828 }; // check all interactables
3829
3830
3831 while (_$is_76["default"].element(element)) {
3832 var interactable = scope.interactables.forEachMatch(element, getDraggable);
3833
3834 if (interactable) {
3835 interaction.prepared.name = 'drag';
3836 interaction.interactable = interactable;
3837 interaction.element = element;
3838 break;
3839 }
3840
3841 element = (0, _$domUtils_71.parentNode)(element);
3842 }
3843 }
3844 }
3845
3846 function checkStartAxis(startAxis, interactable) {
3847 if (!interactable) {
3848 return false;
3849 }
3850
3851 var thisAxis = interactable.options.drag.startAxis;
3852 return startAxis === 'xy' || thisAxis === 'xy' || thisAxis === startAxis;
3853 }
3854
3855 var ___default_11 = {
3856 id: 'auto-start/dragAxis',
3857 listeners: {
3858 'autoStart:before-start': beforeStart
3859 }
3860 };
3861 _$dragAxis_11["default"] = ___default_11;
3862 var _$hold_12 = {};
3863 "use strict";
3864
3865 Object.defineProperty(_$hold_12, "__esModule", {
3866 value: true
3867 });
3868 _$hold_12["default"] = void 0;
3869 /* removed: var _$base_10 = require("./base.js"); */
3870
3871 ;
3872
3873 function __install_12(scope) {
3874 var defaults = scope.defaults;
3875 scope.usePlugin(_$base_10["default"]);
3876 defaults.perAction.hold = 0;
3877 defaults.perAction.delay = 0;
3878 }
3879
3880 function getHoldDuration(interaction) {
3881 var actionName = interaction.prepared && interaction.prepared.name;
3882
3883 if (!actionName) {
3884 return null;
3885 }
3886
3887 var options = interaction.interactable.options;
3888 return options[actionName].hold || options[actionName].delay;
3889 }
3890
3891 var ___default_12 = {
3892 id: 'auto-start/hold',
3893 install: __install_12,
3894 listeners: {
3895 'interactions:new': function interactionsNew(_ref) {
3896 var interaction = _ref.interaction;
3897 interaction.autoStartHoldTimer = null;
3898 },
3899 'autoStart:prepared': function autoStartPrepared(_ref2) {
3900 var interaction = _ref2.interaction;
3901 var hold = getHoldDuration(interaction);
3902
3903 if (hold > 0) {
3904 interaction.autoStartHoldTimer = setTimeout(function () {
3905 interaction.start(interaction.prepared, interaction.interactable, interaction.element);
3906 }, hold);
3907 }
3908 },
3909 'interactions:move': function interactionsMove(_ref3) {
3910 var interaction = _ref3.interaction,
3911 duplicate = _ref3.duplicate;
3912
3913 if (interaction.pointerWasMoved && !duplicate) {
3914 clearTimeout(interaction.autoStartHoldTimer);
3915 }
3916 },
3917 // prevent regular down->move autoStart
3918 'autoStart:before-start': function autoStartBeforeStart(_ref4) {
3919 var interaction = _ref4.interaction;
3920 var hold = getHoldDuration(interaction);
3921
3922 if (hold > 0) {
3923 interaction.prepared.name = null;
3924 }
3925 }
3926 },
3927 getHoldDuration: getHoldDuration
3928 };
3929 _$hold_12["default"] = ___default_12;
3930 var _$plugin_13 = {};
3931 "use strict";
3932
3933 Object.defineProperty(_$plugin_13, "__esModule", {
3934 value: true
3935 });
3936 _$plugin_13["default"] = void 0;
3937 /* removed: var _$base_10 = require("./base.js"); */
3938
3939 ;
3940 /* removed: var _$dragAxis_11 = require("./dragAxis.js"); */
3941
3942 ;
3943 /* removed: var _$hold_12 = require("./hold.js"); */
3944
3945 ;
3946 var ___default_13 = {
3947 id: 'auto-start',
3948 install: function install(scope) {
3949 scope.usePlugin(_$base_10["default"]);
3950 scope.usePlugin(_$hold_12["default"]);
3951 scope.usePlugin(_$dragAxis_11["default"]);
3952 }
3953 };
3954 _$plugin_13["default"] = ___default_13;
3955 var _$plugin_14 = {};
3956 "use strict";
3957
3958 Object.defineProperty(_$plugin_14, "__esModule", {
3959 value: true
3960 });
3961 _$plugin_14["default"] = void 0;
3962 var ___default_14 = {};
3963 _$plugin_14["default"] = ___default_14;
3964 var _$interactablePreventDefault_25 = {};
3965 "use strict";
3966
3967 Object.defineProperty(_$interactablePreventDefault_25, "__esModule", {
3968 value: true
3969 });
3970 _$interactablePreventDefault_25.install = __install_25;
3971 _$interactablePreventDefault_25["default"] = void 0;
3972 /* removed: var _$domUtils_71 = require("../utils/domUtils.js"); */
3973
3974 ;
3975 /* removed: var _$is_76 = require("../utils/is.js"); */
3976
3977 ;
3978 /* removed: var _$window_84 = require("../utils/window.js"); */
3979
3980 ;
3981
3982 function preventDefault(newValue) {
3983 if (/^(always|never|auto)$/.test(newValue)) {
3984 this.options.preventDefault = newValue;
3985 return this;
3986 }
3987
3988 if (_$is_76["default"].bool(newValue)) {
3989 this.options.preventDefault = newValue ? 'always' : 'never';
3990 return this;
3991 }
3992
3993 return this.options.preventDefault;
3994 }
3995
3996 function checkAndPreventDefault(interactable, scope, event) {
3997 var setting = interactable.options.preventDefault;
3998
3999 if (setting === 'never') {
4000 return;
4001 }
4002
4003 if (setting === 'always') {
4004 event.preventDefault();
4005 return;
4006 } // setting === 'auto'
4007 // if the browser supports passive event listeners and isn't running on iOS,
4008 // don't preventDefault of touch{start,move} events. CSS touch-action and
4009 // user-select should be used instead of calling event.preventDefault().
4010
4011
4012 if (scope.events.supportsPassive && /^touch(start|move)$/.test(event.type)) {
4013 var doc = (0, _$window_84.getWindow)(event.target).document;
4014 var docOptions = scope.getDocOptions(doc);
4015
4016 if (!(docOptions && docOptions.events) || docOptions.events.passive !== false) {
4017 return;
4018 }
4019 } // don't preventDefault of pointerdown events
4020
4021
4022 if (/^(mouse|pointer|touch)*(down|start)/i.test(event.type)) {
4023 return;
4024 } // don't preventDefault on editable elements
4025
4026
4027 if (_$is_76["default"].element(event.target) && (0, _$domUtils_71.matchesSelector)(event.target, 'input,select,textarea,[contenteditable=true],[contenteditable=true] *')) {
4028 return;
4029 }
4030
4031 event.preventDefault();
4032 }
4033
4034 function onInteractionEvent(_ref) {
4035 var interaction = _ref.interaction,
4036 event = _ref.event;
4037
4038 if (interaction.interactable) {
4039 interaction.interactable.checkAndPreventDefault(event);
4040 }
4041 }
4042
4043 function __install_25(scope) {
4044 /** @lends Interactable */
4045 var Interactable = scope.Interactable;
4046 /**
4047 * Returns or sets whether to prevent the browser's default behaviour in
4048 * response to pointer events. Can be set to:
4049 * - `'always'` to always prevent
4050 * - `'never'` to never prevent
4051 * - `'auto'` to let interact.js try to determine what would be best
4052 *
4053 * @param {string} [newValue] `'always'`, `'never'` or `'auto'`
4054 * @return {string | Interactable} The current setting or this Interactable
4055 */
4056
4057 Interactable.prototype.preventDefault = preventDefault;
4058
4059 Interactable.prototype.checkAndPreventDefault = function (event) {
4060 return checkAndPreventDefault(this, scope, event);
4061 }; // prevent native HTML5 drag on interact.js target elements
4062
4063
4064 scope.interactions.docEvents.push({
4065 type: 'dragstart',
4066 listener: function listener(event) {
4067 for (var _i = 0; _i < scope.interactions.list.length; _i++) {
4068 var _ref2;
4069
4070 _ref2 = scope.interactions.list[_i];
4071 var interaction = _ref2;
4072
4073 if (interaction.element && (interaction.element === event.target || (0, _$domUtils_71.nodeContains)(interaction.element, event.target))) {
4074 interaction.interactable.checkAndPreventDefault(event);
4075 return;
4076 }
4077 }
4078 }
4079 });
4080 }
4081
4082 var ___default_25 = {
4083 id: 'core/interactablePreventDefault',
4084 install: __install_25,
4085 listeners: ['down', 'move', 'up', 'cancel'].reduce(function (acc, eventType) {
4086 acc["interactions:".concat(eventType)] = onInteractionEvent;
4087 return acc;
4088 }, {})
4089 };
4090 _$interactablePreventDefault_25["default"] = ___default_25;
4091 var _$plugin_30 = {};
4092 "use strict";
4093
4094 Object.defineProperty(_$plugin_30, "__esModule", {
4095 value: true
4096 });
4097 _$plugin_30["default"] = void 0;
4098 /* removed: var _$domObjects_70 = require("../utils/domObjects.js"); */
4099
4100 ;
4101 /* removed: var _$domUtils_71 = require("../utils/domUtils.js"); */
4102
4103 ;
4104 /* removed: var _$extend_73 = require("../utils/extend.js"); */
4105
4106 ;
4107 /* removed: var _$is_76 = require("../utils/is.js"); */
4108
4109 ;
4110 /* removed: var _$window_84 = require("../utils/window.js"); */
4111
4112 ;
4113
4114 function ___toConsumableArray_30(arr) {
4115 return ___arrayWithoutHoles_30(arr) || ___iterableToArray_30(arr) || ___unsupportedIterableToArray_30(arr) || ___nonIterableSpread_30();
4116 }
4117
4118 function ___nonIterableSpread_30() {
4119 throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
4120 }
4121
4122 function ___unsupportedIterableToArray_30(o, minLen) {
4123 if (!o) return;
4124 if (typeof o === "string") return ___arrayLikeToArray_30(o, minLen);
4125 var n = Object.prototype.toString.call(o).slice(8, -1);
4126 if (n === "Object" && o.constructor) n = o.constructor.name;
4127 if (n === "Map" || n === "Set") return Array.from(o);
4128 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return ___arrayLikeToArray_30(o, minLen);
4129 }
4130
4131 function ___iterableToArray_30(iter) {
4132 if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
4133 }
4134
4135 function ___arrayWithoutHoles_30(arr) {
4136 if (Array.isArray(arr)) return ___arrayLikeToArray_30(arr);
4137 }
4138
4139 function ___arrayLikeToArray_30(arr, len) {
4140 if (len == null || len > arr.length) len = arr.length;
4141
4142 for (var i = 0, arr2 = new Array(len); i < len; i++) {
4143 arr2[i] = arr[i];
4144 }
4145
4146 return arr2;
4147 }
4148
4149 var CheckName;
4150
4151 (function (CheckName) {
4152 CheckName["touchAction"] = "touchAction";
4153 CheckName["boxSizing"] = "boxSizing";
4154 CheckName["noListeners"] = "noListeners";
4155 })(CheckName || (CheckName = {}));
4156
4157 var prefix = '[interact.js] ';
4158 var links = {
4159 touchAction: 'https://developer.mozilla.org/en-US/docs/Web/CSS/touch-action',
4160 boxSizing: 'https://developer.mozilla.org/en-US/docs/Web/CSS/box-sizing'
4161 }; // eslint-disable-next-line no-undef
4162
4163 var isProduction = "development" === 'production'; // eslint-disable-next-line no-restricted-syntax
4164
4165 function __install_30(scope) {
4166 var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
4167 logger = _ref.logger;
4168
4169 var Interactable = scope.Interactable,
4170 defaults = scope.defaults;
4171 scope.logger = logger || console;
4172 defaults.base.devTools = {
4173 ignore: {}
4174 };
4175
4176 Interactable.prototype.devTools = function (options) {
4177 if (options) {
4178 (0, _$extend_73["default"])(this.options.devTools, options);
4179 return this;
4180 }
4181
4182 return this.options.devTools;
4183 };
4184 }
4185
4186 var checks = [{
4187 name: CheckName.touchAction,
4188 perform: function perform(_ref2) {
4189 var element = _ref2.element;
4190 return !parentHasStyle(element, 'touchAction', /pan-|pinch|none/);
4191 },
4192 getInfo: function getInfo(_ref3) {
4193 var element = _ref3.element;
4194 return [element, links.touchAction];
4195 },
4196 text: 'Consider adding CSS "touch-action: none" to this element\n'
4197 }, {
4198 name: CheckName.boxSizing,
4199 perform: function perform(interaction) {
4200 var element = interaction.element;
4201 return interaction.prepared.name === 'resize' && element instanceof _$domObjects_70["default"].HTMLElement && !hasStyle(element, 'boxSizing', /border-box/);
4202 },
4203 text: 'Consider adding CSS "box-sizing: border-box" to this resizable element',
4204 getInfo: function getInfo(_ref4) {
4205 var element = _ref4.element;
4206 return [element, links.boxSizing];
4207 }
4208 }, {
4209 name: CheckName.noListeners,
4210 perform: function perform(interaction) {
4211 var actionName = interaction.prepared.name;
4212 var moveListeners = interaction.interactable.events.types["".concat(actionName, "move")] || [];
4213 return !moveListeners.length;
4214 },
4215 getInfo: function getInfo(interaction) {
4216 return [interaction.prepared.name, interaction.interactable];
4217 },
4218 text: 'There are no listeners set for this action'
4219 }];
4220
4221 function hasStyle(element, prop, styleRe) {
4222 var value = element.style[prop] || _$window_84["default"].window.getComputedStyle(element)[prop];
4223
4224 return styleRe.test((value || '').toString());
4225 }
4226
4227 function parentHasStyle(element, prop, styleRe) {
4228 var parent = element;
4229
4230 while (_$is_76["default"].element(parent)) {
4231 if (hasStyle(parent, prop, styleRe)) {
4232 return true;
4233 }
4234
4235 parent = (0, _$domUtils_71.parentNode)(parent);
4236 }
4237
4238 return false;
4239 }
4240
4241 var id = 'dev-tools';
4242 var defaultExport = isProduction ? {
4243 id: id,
4244 install: function install() {}
4245 } : {
4246 id: id,
4247 install: __install_30,
4248 listeners: {
4249 'interactions:action-start': function interactionsActionStart(_ref5, scope) {
4250 var interaction = _ref5.interaction;
4251
4252 for (var _i = 0; _i < checks.length; _i++) {
4253 var _ref6;
4254
4255 _ref6 = checks[_i];
4256 var check = _ref6;
4257 var options = interaction.interactable && interaction.interactable.options;
4258
4259 if (!(options && options.devTools && options.devTools.ignore[check.name]) && check.perform(interaction)) {
4260 var _scope$logger;
4261
4262 (_scope$logger = scope.logger).warn.apply(_scope$logger, [prefix + check.text].concat(___toConsumableArray_30(check.getInfo(interaction))));
4263 }
4264 }
4265 }
4266 },
4267 checks: checks,
4268 CheckName: CheckName,
4269 links: links,
4270 prefix: prefix
4271 };
4272 var ___default_30 = defaultExport;
4273 _$plugin_30["default"] = ___default_30;
4274 var _$plugin_31 = {};
4275 "use strict";
4276
4277 Object.defineProperty(_$plugin_31, "__esModule", {
4278 value: true
4279 });
4280 _$plugin_31["default"] = void 0;
4281 var ___default_31 = {};
4282 _$plugin_31["default"] = ___default_31;
4283 var _$clone_68 = {};
4284 "use strict";
4285
4286 Object.defineProperty(_$clone_68, "__esModule", {
4287 value: true
4288 });
4289 _$clone_68["default"] = clone;
4290 /* removed: var _$arr_66 = require("./arr.js"); */
4291
4292 ;
4293 /* removed: var _$is_76 = require("./is.js"); */
4294
4295 ; // tslint:disable-next-line ban-types
4296
4297 function clone(source) {
4298 var dest = {};
4299
4300 for (var prop in source) {
4301 var value = source[prop];
4302
4303 if (_$is_76["default"].plainObject(value)) {
4304 dest[prop] = clone(value);
4305 } else if (_$is_76["default"].array(value)) {
4306 dest[prop] = _$arr_66.from(value);
4307 } else {
4308 dest[prop] = value;
4309 }
4310 }
4311
4312 return dest;
4313 }
4314
4315 var _$Modification_35 = {};
4316 "use strict";
4317
4318 Object.defineProperty(_$Modification_35, "__esModule", {
4319 value: true
4320 });
4321 _$Modification_35.getRectOffset = getRectOffset;
4322 _$Modification_35["default"] = void 0;
4323 /* removed: var _$clone_68 = require("../utils/clone.js"); */
4324
4325 ;
4326 /* removed: var _$extend_73 = require("../utils/extend.js"); */
4327
4328 ;
4329 /* removed: var _$rect_83 = require("../utils/rect.js"); */
4330
4331 ;
4332
4333 function _slicedToArray(arr, i) {
4334 return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || ___unsupportedIterableToArray_35(arr, i) || _nonIterableRest();
4335 }
4336
4337 function _nonIterableRest() {
4338 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
4339 }
4340
4341 function ___unsupportedIterableToArray_35(o, minLen) {
4342 if (!o) return;
4343 if (typeof o === "string") return ___arrayLikeToArray_35(o, minLen);
4344 var n = Object.prototype.toString.call(o).slice(8, -1);
4345 if (n === "Object" && o.constructor) n = o.constructor.name;
4346 if (n === "Map" || n === "Set") return Array.from(o);
4347 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return ___arrayLikeToArray_35(o, minLen);
4348 }
4349
4350 function ___arrayLikeToArray_35(arr, len) {
4351 if (len == null || len > arr.length) len = arr.length;
4352
4353 for (var i = 0, arr2 = new Array(len); i < len; i++) {
4354 arr2[i] = arr[i];
4355 }
4356
4357 return arr2;
4358 }
4359
4360 function _iterableToArrayLimit(arr, i) {
4361 if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
4362 var _arr = [];
4363 var _n = true;
4364 var _d = false;
4365 var _e = undefined;
4366
4367 try {
4368 for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
4369 _arr.push(_s.value);
4370
4371 if (i && _arr.length === i) break;
4372 }
4373 } catch (err) {
4374 _d = true;
4375 _e = err;
4376 } finally {
4377 try {
4378 if (!_n && _i["return"] != null) _i["return"]();
4379 } finally {
4380 if (_d) throw _e;
4381 }
4382 }
4383
4384 return _arr;
4385 }
4386
4387 function _arrayWithHoles(arr) {
4388 if (Array.isArray(arr)) return arr;
4389 }
4390
4391 function ___classCallCheck_35(instance, Constructor) {
4392 if (!(instance instanceof Constructor)) {
4393 throw new TypeError("Cannot call a class as a function");
4394 }
4395 }
4396
4397 function ___defineProperties_35(target, props) {
4398 for (var i = 0; i < props.length; i++) {
4399 var descriptor = props[i];
4400 descriptor.enumerable = descriptor.enumerable || false;
4401 descriptor.configurable = true;
4402 if ("value" in descriptor) descriptor.writable = true;
4403 Object.defineProperty(target, descriptor.key, descriptor);
4404 }
4405 }
4406
4407 function ___createClass_35(Constructor, protoProps, staticProps) {
4408 if (protoProps) ___defineProperties_35(Constructor.prototype, protoProps);
4409 if (staticProps) ___defineProperties_35(Constructor, staticProps);
4410 return Constructor;
4411 }
4412
4413 var Modification = /*#__PURE__*/function () {
4414 function Modification(interaction) {
4415 ___classCallCheck_35(this, Modification);
4416
4417 this.states = [];
4418 this.startOffset = {
4419 left: 0,
4420 right: 0,
4421 top: 0,
4422 bottom: 0
4423 };
4424 this.startDelta = null;
4425 this.result = null;
4426 this.endResult = null;
4427 this.edges = void 0;
4428 this.interaction = void 0;
4429 this.interaction = interaction;
4430 this.result = createResult();
4431 }
4432
4433 ___createClass_35(Modification, [{
4434 key: "start",
4435 value: function start(_ref, pageCoords) {
4436 var phase = _ref.phase;
4437 var interaction = this.interaction;
4438 var modifierList = getModifierList(interaction);
4439 this.prepareStates(modifierList);
4440 this.edges = (0, _$extend_73["default"])({}, interaction.edges);
4441 this.startOffset = getRectOffset(interaction.rect, pageCoords);
4442 this.startDelta = {
4443 x: 0,
4444 y: 0
4445 };
4446 var arg = {
4447 phase: phase,
4448 pageCoords: pageCoords,
4449 preEnd: false
4450 };
4451 this.result = createResult();
4452 this.startAll(arg);
4453 var result = this.result = this.setAll(arg);
4454 return result;
4455 }
4456 }, {
4457 key: "fillArg",
4458 value: function fillArg(arg) {
4459 var interaction = this.interaction;
4460 arg.interaction = interaction;
4461 arg.interactable = interaction.interactable;
4462 arg.element = interaction.element;
4463 arg.rect = arg.rect || interaction.rect;
4464 arg.edges = this.edges;
4465 arg.startOffset = this.startOffset;
4466 }
4467 }, {
4468 key: "startAll",
4469 value: function startAll(arg) {
4470 this.fillArg(arg);
4471
4472 for (var _i = 0; _i < this.states.length; _i++) {
4473 var _ref2;
4474
4475 _ref2 = this.states[_i];
4476 var state = _ref2;
4477
4478 if (state.methods.start) {
4479 arg.state = state;
4480 state.methods.start(arg);
4481 }
4482 }
4483 }
4484 }, {
4485 key: "setAll",
4486 value: function setAll(arg) {
4487 this.fillArg(arg);
4488 var phase = arg.phase,
4489 preEnd = arg.preEnd,
4490 skipModifiers = arg.skipModifiers,
4491 unmodifiedRect = arg.rect;
4492 arg.coords = (0, _$extend_73["default"])({}, arg.pageCoords);
4493 arg.rect = (0, _$extend_73["default"])({}, unmodifiedRect);
4494 var states = skipModifiers ? this.states.slice(skipModifiers) : this.states;
4495 var newResult = createResult(arg.coords, arg.rect);
4496
4497 for (var _i2 = 0; _i2 < states.length; _i2++) {
4498 var _ref3;
4499
4500 _ref3 = states[_i2];
4501 var state = _ref3;
4502 var options = state.options;
4503 var lastModifierCoords = (0, _$extend_73["default"])({}, arg.coords);
4504 var returnValue = null;
4505
4506 if (state.methods.set && this.shouldDo(options, preEnd, phase)) {
4507 arg.state = state;
4508 returnValue = state.methods.set(arg);
4509
4510 _$rect_83.addEdges(this.interaction.edges, arg.rect, {
4511 x: arg.coords.x - lastModifierCoords.x,
4512 y: arg.coords.y - lastModifierCoords.y
4513 });
4514 }
4515
4516 newResult.eventProps.push(returnValue);
4517 }
4518
4519 newResult.delta.x = arg.coords.x - arg.pageCoords.x;
4520 newResult.delta.y = arg.coords.y - arg.pageCoords.y;
4521 newResult.rectDelta.left = arg.rect.left - unmodifiedRect.left;
4522 newResult.rectDelta.right = arg.rect.right - unmodifiedRect.right;
4523 newResult.rectDelta.top = arg.rect.top - unmodifiedRect.top;
4524 newResult.rectDelta.bottom = arg.rect.bottom - unmodifiedRect.bottom;
4525 var prevCoords = this.result.coords;
4526 var prevRect = this.result.rect;
4527
4528 if (prevCoords && prevRect) {
4529 var rectChanged = newResult.rect.left !== prevRect.left || newResult.rect.right !== prevRect.right || newResult.rect.top !== prevRect.top || newResult.rect.bottom !== prevRect.bottom;
4530 newResult.changed = rectChanged || prevCoords.x !== newResult.coords.x || prevCoords.y !== newResult.coords.y;
4531 }
4532
4533 return newResult;
4534 }
4535 }, {
4536 key: "applyToInteraction",
4537 value: function applyToInteraction(arg) {
4538 var interaction = this.interaction;
4539 var phase = arg.phase;
4540 var curCoords = interaction.coords.cur;
4541 var startCoords = interaction.coords.start;
4542 var result = this.result,
4543 startDelta = this.startDelta;
4544 var curDelta = result.delta;
4545
4546 if (phase === 'start') {
4547 (0, _$extend_73["default"])(this.startDelta, result.delta);
4548 }
4549
4550 var _arr = [[startCoords, startDelta], [curCoords, curDelta]];
4551
4552 for (var _i3 = 0; _i3 < _arr.length; _i3++) {
4553 var _arr$_i = _slicedToArray(_arr[_i3], 2),
4554 coordsSet = _arr$_i[0],
4555 delta = _arr$_i[1];
4556
4557 coordsSet.page.x += delta.x;
4558 coordsSet.page.y += delta.y;
4559 coordsSet.client.x += delta.x;
4560 coordsSet.client.y += delta.y;
4561 }
4562
4563 var rectDelta = this.result.rectDelta;
4564 var rect = arg.rect || interaction.rect;
4565 rect.left += rectDelta.left;
4566 rect.right += rectDelta.right;
4567 rect.top += rectDelta.top;
4568 rect.bottom += rectDelta.bottom;
4569 rect.width = rect.right - rect.left;
4570 rect.height = rect.bottom - rect.top;
4571 }
4572 }, {
4573 key: "setAndApply",
4574 value: function setAndApply(arg) {
4575 var interaction = this.interaction;
4576 var phase = arg.phase,
4577 preEnd = arg.preEnd,
4578 skipModifiers = arg.skipModifiers;
4579 var result = this.setAll({
4580 preEnd: preEnd,
4581 phase: phase,
4582 pageCoords: arg.modifiedCoords || interaction.coords.cur.page
4583 });
4584 this.result = result; // don't fire an action move if a modifier would keep the event in the same
4585 // cordinates as before
4586
4587 if (!result.changed && (!skipModifiers || skipModifiers < this.states.length) && interaction.interacting()) {
4588 return false;
4589 }
4590
4591 if (arg.modifiedCoords) {
4592 var page = interaction.coords.cur.page;
4593 var adjustment = {
4594 x: arg.modifiedCoords.x - page.x,
4595 y: arg.modifiedCoords.y - page.y
4596 };
4597 result.coords.x += adjustment.x;
4598 result.coords.y += adjustment.y;
4599 result.delta.x += adjustment.x;
4600 result.delta.y += adjustment.y;
4601 }
4602
4603 this.applyToInteraction(arg);
4604 }
4605 }, {
4606 key: "beforeEnd",
4607 value: function beforeEnd(arg) {
4608 var interaction = arg.interaction,
4609 event = arg.event;
4610 var states = this.states;
4611
4612 if (!states || !states.length) {
4613 return;
4614 }
4615
4616 var doPreend = false;
4617
4618 for (var _i4 = 0; _i4 < states.length; _i4++) {
4619 var _ref4;
4620
4621 _ref4 = states[_i4];
4622 var state = _ref4;
4623 arg.state = state;
4624 var options = state.options,
4625 methods = state.methods;
4626 var endPosition = methods.beforeEnd && methods.beforeEnd(arg);
4627
4628 if (endPosition) {
4629 this.endResult = endPosition;
4630 return false;
4631 }
4632
4633 doPreend = doPreend || !doPreend && this.shouldDo(options, true, arg.phase, true);
4634 }
4635
4636 if (doPreend) {
4637 // trigger a final modified move before ending
4638 interaction.move({
4639 event: event,
4640 preEnd: true
4641 });
4642 }
4643 }
4644 }, {
4645 key: "stop",
4646 value: function stop(arg) {
4647 var interaction = arg.interaction;
4648
4649 if (!this.states || !this.states.length) {
4650 return;
4651 }
4652
4653 var modifierArg = (0, _$extend_73["default"])({
4654 states: this.states,
4655 interactable: interaction.interactable,
4656 element: interaction.element,
4657 rect: null
4658 }, arg);
4659 this.fillArg(modifierArg);
4660
4661 for (var _i5 = 0; _i5 < this.states.length; _i5++) {
4662 var _ref5;
4663
4664 _ref5 = this.states[_i5];
4665 var state = _ref5;
4666 modifierArg.state = state;
4667
4668 if (state.methods.stop) {
4669 state.methods.stop(modifierArg);
4670 }
4671 }
4672
4673 this.states = null;
4674 this.endResult = null;
4675 }
4676 }, {
4677 key: "prepareStates",
4678 value: function prepareStates(modifierList) {
4679 this.states = [];
4680
4681 for (var index = 0; index < modifierList.length; index++) {
4682 var _modifierList$index = modifierList[index],
4683 options = _modifierList$index.options,
4684 methods = _modifierList$index.methods,
4685 name = _modifierList$index.name;
4686
4687 if (options && options.enabled === false) {
4688 continue;
4689 }
4690
4691 this.states.push({
4692 options: options,
4693 methods: methods,
4694 index: index,
4695 name: name
4696 });
4697 }
4698
4699 return this.states;
4700 }
4701 }, {
4702 key: "restoreInteractionCoords",
4703 value: function restoreInteractionCoords(_ref6) {
4704 var _ref6$interaction = _ref6.interaction,
4705 coords = _ref6$interaction.coords,
4706 rect = _ref6$interaction.rect,
4707 modification = _ref6$interaction.modification;
4708
4709 if (!modification.result) {
4710 return;
4711 }
4712
4713 var startDelta = modification.startDelta;
4714 var _modification$result = modification.result,
4715 curDelta = _modification$result.delta,
4716 rectDelta = _modification$result.rectDelta;
4717 var coordsAndDeltas = [[coords.start, startDelta], [coords.cur, curDelta]];
4718
4719 for (var _i6 = 0; _i6 < coordsAndDeltas.length; _i6++) {
4720 var _coordsAndDeltas$_i = _slicedToArray(coordsAndDeltas[_i6], 2),
4721 coordsSet = _coordsAndDeltas$_i[0],
4722 delta = _coordsAndDeltas$_i[1];
4723
4724 coordsSet.page.x -= delta.x;
4725 coordsSet.page.y -= delta.y;
4726 coordsSet.client.x -= delta.x;
4727 coordsSet.client.y -= delta.y;
4728 }
4729
4730 rect.left -= rectDelta.left;
4731 rect.right -= rectDelta.right;
4732 rect.top -= rectDelta.top;
4733 rect.bottom -= rectDelta.bottom;
4734 }
4735 }, {
4736 key: "shouldDo",
4737 value: function shouldDo(options, preEnd, phase, requireEndOnly) {
4738 if ( // ignore disabled modifiers
4739 !options || options.enabled === false || // check if we require endOnly option to fire move before end
4740 requireEndOnly && !options.endOnly || // don't apply endOnly modifiers when not ending
4741 options.endOnly && !preEnd || // check if modifier should run be applied on start
4742 phase === 'start' && !options.setStart) {
4743 return false;
4744 }
4745
4746 return true;
4747 }
4748 }, {
4749 key: "copyFrom",
4750 value: function copyFrom(other) {
4751 this.startOffset = other.startOffset;
4752 this.startDelta = other.startDelta;
4753 this.edges = other.edges;
4754 this.states = other.states.map(function (s) {
4755 return (0, _$clone_68["default"])(s);
4756 });
4757 this.result = createResult((0, _$extend_73["default"])({}, other.result.coords), (0, _$extend_73["default"])({}, other.result.rect));
4758 }
4759 }, {
4760 key: "destroy",
4761 value: function destroy() {
4762 for (var prop in this) {
4763 this[prop] = null;
4764 }
4765 }
4766 }]);
4767
4768 return Modification;
4769 }();
4770
4771 _$Modification_35["default"] = Modification;
4772
4773 function createResult(coords, rect) {
4774 return {
4775 rect: rect,
4776 coords: coords,
4777 delta: {
4778 x: 0,
4779 y: 0
4780 },
4781 rectDelta: {
4782 left: 0,
4783 right: 0,
4784 top: 0,
4785 bottom: 0
4786 },
4787 eventProps: [],
4788 changed: true
4789 };
4790 }
4791
4792 function getModifierList(interaction) {
4793 var actionOptions = interaction.interactable.options[interaction.prepared.name];
4794 var actionModifiers = actionOptions.modifiers;
4795
4796 if (actionModifiers && actionModifiers.length) {
4797 return actionModifiers.filter(function (modifier) {
4798 return !modifier.options || modifier.options.enabled !== false;
4799 });
4800 }
4801
4802 return ['snap', 'snapSize', 'snapEdges', 'restrict', 'restrictEdges', 'restrictSize'].map(function (type) {
4803 var options = actionOptions[type];
4804 return options && options.enabled && {
4805 options: options,
4806 methods: options._methods
4807 };
4808 }).filter(function (m) {
4809 return !!m;
4810 });
4811 }
4812
4813 function getRectOffset(rect, coords) {
4814 return rect ? {
4815 left: coords.x - rect.left,
4816 top: coords.y - rect.top,
4817 right: rect.right - coords.x,
4818 bottom: rect.bottom - coords.y
4819 } : {
4820 left: 0,
4821 top: 0,
4822 right: 0,
4823 bottom: 0
4824 };
4825 }
4826
4827 var _$base_39 = {};
4828 "use strict";
4829
4830 Object.defineProperty(_$base_39, "__esModule", {
4831 value: true
4832 });
4833 _$base_39.makeModifier = makeModifier;
4834 _$base_39.addEventModifiers = addEventModifiers;
4835 _$base_39["default"] = void 0;
4836 /* removed: var _$Modification_35 = require("./Modification.js"); */
4837
4838 ;
4839
4840 function makeModifier(module, name) {
4841 var defaults = module.defaults;
4842 var methods = {
4843 start: module.start,
4844 set: module.set,
4845 beforeEnd: module.beforeEnd,
4846 stop: module.stop
4847 };
4848
4849 var modifier = function modifier(_options) {
4850 var options = _options || {};
4851 options.enabled = options.enabled !== false; // add missing defaults to options
4852
4853 for (var prop in defaults) {
4854 if (!(prop in options)) {
4855 options[prop] = defaults[prop];
4856 }
4857 }
4858
4859 var m = {
4860 options: options,
4861 methods: methods,
4862 name: name
4863 };
4864 return m;
4865 };
4866
4867 if (name && typeof name === 'string') {
4868 // for backwrads compatibility
4869 modifier._defaults = defaults;
4870 modifier._methods = methods;
4871 }
4872
4873 return modifier;
4874 }
4875
4876 function addEventModifiers(_ref) {
4877 var iEvent = _ref.iEvent,
4878 result = _ref.interaction.modification.result;
4879
4880 if (result) {
4881 iEvent.modifiers = result.eventProps;
4882 }
4883 }
4884
4885 var modifiersBase = {
4886 id: 'modifiers/base',
4887 install: function install(scope) {
4888 scope.defaults.perAction.modifiers = [];
4889 },
4890 listeners: {
4891 'interactions:new': function interactionsNew(_ref2) {
4892 var interaction = _ref2.interaction;
4893 interaction.modification = new _$Modification_35["default"](interaction);
4894 },
4895 'interactions:before-action-start': function interactionsBeforeActionStart(arg) {
4896 var modification = arg.interaction.modification;
4897 modification.start(arg, arg.interaction.coords.start.page);
4898 arg.interaction.edges = modification.edges;
4899 modification.applyToInteraction(arg);
4900 },
4901 'interactions:before-action-move': function interactionsBeforeActionMove(arg) {
4902 return arg.interaction.modification.setAndApply(arg);
4903 },
4904 'interactions:before-action-end': function interactionsBeforeActionEnd(arg) {
4905 return arg.interaction.modification.beforeEnd(arg);
4906 },
4907 'interactions:action-start': addEventModifiers,
4908 'interactions:action-move': addEventModifiers,
4909 'interactions:action-end': addEventModifiers,
4910 'interactions:after-action-start': function interactionsAfterActionStart(arg) {
4911 return arg.interaction.modification.restoreInteractionCoords(arg);
4912 },
4913 'interactions:after-action-move': function interactionsAfterActionMove(arg) {
4914 return arg.interaction.modification.restoreInteractionCoords(arg);
4915 },
4916 'interactions:stop': function interactionsStop(arg) {
4917 return arg.interaction.modification.stop(arg);
4918 }
4919 },
4920 before: ['actions', 'action/drag', 'actions/resize', 'actions/gesture']
4921 };
4922 var ___default_39 = modifiersBase;
4923 _$base_39["default"] = ___default_39;
4924 var _$defaultOptions_22 = {};
4925 "use strict";
4926
4927 Object.defineProperty(_$defaultOptions_22, "__esModule", {
4928 value: true
4929 });
4930 _$defaultOptions_22.defaults = void 0; // eslint-disable-next-line @typescript-eslint/no-empty-interface
4931 // export interface Options extends BaseDefaults, PerActionDefaults {}
4932
4933 var defaults = {
4934 base: {
4935 preventDefault: 'auto',
4936 deltaSource: 'page'
4937 },
4938 perAction: {
4939 enabled: false,
4940 origin: {
4941 x: 0,
4942 y: 0
4943 }
4944 },
4945 actions: {}
4946 };
4947 _$defaultOptions_22.defaults = defaults;
4948 var _$InteractEvent_17 = {};
4949 "use strict";
4950
4951 Object.defineProperty(_$InteractEvent_17, "__esModule", {
4952 value: true
4953 });
4954 _$InteractEvent_17.InteractEvent = void 0;
4955 /* removed: var _$extend_73 = require("../utils/extend.js"); */
4956
4957 ;
4958 /* removed: var _$getOriginXY_74 = require("../utils/getOriginXY.js"); */
4959
4960 ;
4961 /* removed: var _$hypot_75 = require("../utils/hypot.js"); */
4962
4963 ;
4964 /* removed: var _$BaseEvent_15 = require("./BaseEvent.js"); */
4965
4966 ;
4967 /* removed: var _$defaultOptions_22 = require("./defaultOptions.js"); */
4968
4969 ;
4970
4971 function ___typeof_17(obj) {
4972 "@babel/helpers - typeof";
4973
4974 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
4975 ___typeof_17 = function _typeof(obj) {
4976 return typeof obj;
4977 };
4978 } else {
4979 ___typeof_17 = function _typeof(obj) {
4980 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
4981 };
4982 }
4983
4984 return ___typeof_17(obj);
4985 }
4986
4987 function ___classCallCheck_17(instance, Constructor) {
4988 if (!(instance instanceof Constructor)) {
4989 throw new TypeError("Cannot call a class as a function");
4990 }
4991 }
4992
4993 function ___defineProperties_17(target, props) {
4994 for (var i = 0; i < props.length; i++) {
4995 var descriptor = props[i];
4996 descriptor.enumerable = descriptor.enumerable || false;
4997 descriptor.configurable = true;
4998 if ("value" in descriptor) descriptor.writable = true;
4999 Object.defineProperty(target, descriptor.key, descriptor);
5000 }
5001 }
5002
5003 function ___createClass_17(Constructor, protoProps, staticProps) {
5004 if (protoProps) ___defineProperties_17(Constructor.prototype, protoProps);
5005 if (staticProps) ___defineProperties_17(Constructor, staticProps);
5006 return Constructor;
5007 }
5008
5009 function ___inherits_17(subClass, superClass) {
5010 if (typeof superClass !== "function" && superClass !== null) {
5011 throw new TypeError("Super expression must either be null or a function");
5012 }
5013
5014 subClass.prototype = Object.create(superClass && superClass.prototype, {
5015 constructor: {
5016 value: subClass,
5017 writable: true,
5018 configurable: true
5019 }
5020 });
5021 if (superClass) ___setPrototypeOf_17(subClass, superClass);
5022 }
5023
5024 function ___setPrototypeOf_17(o, p) {
5025 ___setPrototypeOf_17 = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
5026 o.__proto__ = p;
5027 return o;
5028 };
5029
5030 return ___setPrototypeOf_17(o, p);
5031 }
5032
5033 function ___createSuper_17(Derived) {
5034 var hasNativeReflectConstruct = ___isNativeReflectConstruct_17();
5035
5036 return function () {
5037 var Super = ___getPrototypeOf_17(Derived),
5038 result;
5039
5040 if (hasNativeReflectConstruct) {
5041 var NewTarget = ___getPrototypeOf_17(this).constructor;
5042
5043 result = Reflect.construct(Super, arguments, NewTarget);
5044 } else {
5045 result = Super.apply(this, arguments);
5046 }
5047
5048 return ___possibleConstructorReturn_17(this, result);
5049 };
5050 }
5051
5052 function ___possibleConstructorReturn_17(self, call) {
5053 if (call && (___typeof_17(call) === "object" || typeof call === "function")) {
5054 return call;
5055 }
5056
5057 return ___assertThisInitialized_17(self);
5058 }
5059
5060 function ___assertThisInitialized_17(self) {
5061 if (self === void 0) {
5062 throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
5063 }
5064
5065 return self;
5066 }
5067
5068 function ___isNativeReflectConstruct_17() {
5069 if (typeof Reflect === "undefined" || !Reflect.construct) return false;
5070 if (Reflect.construct.sham) return false;
5071 if (typeof Proxy === "function") return true;
5072
5073 try {
5074 Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
5075 return true;
5076 } catch (e) {
5077 return false;
5078 }
5079 }
5080
5081 function ___getPrototypeOf_17(o) {
5082 ___getPrototypeOf_17 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
5083 return o.__proto__ || Object.getPrototypeOf(o);
5084 };
5085 return ___getPrototypeOf_17(o);
5086 }
5087
5088 var InteractEvent = /*#__PURE__*/function (_BaseEvent) {
5089 ___inherits_17(InteractEvent, _BaseEvent);
5090
5091 var _super = ___createSuper_17(InteractEvent); // drag
5092 // resize
5093
5094 /** */
5095
5096
5097 function InteractEvent(interaction, event, actionName, phase, element, preEnd, type) {
5098 var _this;
5099
5100 ___classCallCheck_17(this, InteractEvent);
5101
5102 _this = _super.call(this, interaction);
5103 _this.target = void 0;
5104 _this.currentTarget = void 0;
5105 _this.relatedTarget = null;
5106 _this.screenX = void 0;
5107 _this.screenY = void 0;
5108 _this.button = void 0;
5109 _this.buttons = void 0;
5110 _this.ctrlKey = void 0;
5111 _this.shiftKey = void 0;
5112 _this.altKey = void 0;
5113 _this.metaKey = void 0;
5114 _this.page = void 0;
5115 _this.client = void 0;
5116 _this.delta = void 0;
5117 _this.rect = void 0;
5118 _this.x0 = void 0;
5119 _this.y0 = void 0;
5120 _this.t0 = void 0;
5121 _this.dt = void 0;
5122 _this.duration = void 0;
5123 _this.clientX0 = void 0;
5124 _this.clientY0 = void 0;
5125 _this.velocity = void 0;
5126 _this.speed = void 0;
5127 _this.swipe = void 0;
5128 _this.timeStamp = void 0;
5129 _this.dragEnter = void 0;
5130 _this.dragLeave = void 0;
5131 _this.axes = void 0;
5132 _this.preEnd = void 0;
5133 element = element || interaction.element;
5134 var target = interaction.interactable;
5135 var deltaSource = (target && target.options || _$defaultOptions_22.defaults).deltaSource;
5136 var origin = (0, _$getOriginXY_74["default"])(target, element, actionName);
5137 var starting = phase === 'start';
5138 var ending = phase === 'end';
5139 var prevEvent = starting ? ___assertThisInitialized_17(_this) : interaction.prevEvent;
5140 var coords = starting ? interaction.coords.start : ending ? {
5141 page: prevEvent.page,
5142 client: prevEvent.client,
5143 timeStamp: interaction.coords.cur.timeStamp
5144 } : interaction.coords.cur;
5145 _this.page = (0, _$extend_73["default"])({}, coords.page);
5146 _this.client = (0, _$extend_73["default"])({}, coords.client);
5147 _this.rect = (0, _$extend_73["default"])({}, interaction.rect);
5148 _this.timeStamp = coords.timeStamp;
5149
5150 if (!ending) {
5151 _this.page.x -= origin.x;
5152 _this.page.y -= origin.y;
5153 _this.client.x -= origin.x;
5154 _this.client.y -= origin.y;
5155 }
5156
5157 _this.ctrlKey = event.ctrlKey;
5158 _this.altKey = event.altKey;
5159 _this.shiftKey = event.shiftKey;
5160 _this.metaKey = event.metaKey;
5161 _this.button = event.button;
5162 _this.buttons = event.buttons;
5163 _this.target = element;
5164 _this.currentTarget = element;
5165 _this.preEnd = preEnd;
5166 _this.type = type || actionName + (phase || '');
5167 _this.interactable = target;
5168 _this.t0 = starting ? interaction.pointers[interaction.pointers.length - 1].downTime : prevEvent.t0;
5169 _this.x0 = interaction.coords.start.page.x - origin.x;
5170 _this.y0 = interaction.coords.start.page.y - origin.y;
5171 _this.clientX0 = interaction.coords.start.client.x - origin.x;
5172 _this.clientY0 = interaction.coords.start.client.y - origin.y;
5173
5174 if (starting || ending) {
5175 _this.delta = {
5176 x: 0,
5177 y: 0
5178 };
5179 } else {
5180 _this.delta = {
5181 x: _this[deltaSource].x - prevEvent[deltaSource].x,
5182 y: _this[deltaSource].y - prevEvent[deltaSource].y
5183 };
5184 }
5185
5186 _this.dt = interaction.coords.delta.timeStamp;
5187 _this.duration = _this.timeStamp - _this.t0; // velocity and speed in pixels per second
5188
5189 _this.velocity = (0, _$extend_73["default"])({}, interaction.coords.velocity[deltaSource]);
5190 _this.speed = (0, _$hypot_75["default"])(_this.velocity.x, _this.velocity.y);
5191 _this.swipe = ending || phase === 'inertiastart' ? _this.getSwipe() : null;
5192 return _this;
5193 }
5194
5195 ___createClass_17(InteractEvent, [{
5196 key: "getSwipe",
5197 value: function getSwipe() {
5198 var interaction = this._interaction;
5199
5200 if (interaction.prevEvent.speed < 600 || this.timeStamp - interaction.prevEvent.timeStamp > 150) {
5201 return null;
5202 }
5203
5204 var angle = 180 * Math.atan2(interaction.prevEvent.velocityY, interaction.prevEvent.velocityX) / Math.PI;
5205 var overlap = 22.5;
5206
5207 if (angle < 0) {
5208 angle += 360;
5209 }
5210
5211 var left = 135 - overlap <= angle && angle < 225 + overlap;
5212 var up = 225 - overlap <= angle && angle < 315 + overlap;
5213 var right = !left && (315 - overlap <= angle || angle < 45 + overlap);
5214 var down = !up && 45 - overlap <= angle && angle < 135 + overlap;
5215 return {
5216 up: up,
5217 down: down,
5218 left: left,
5219 right: right,
5220 angle: angle,
5221 speed: interaction.prevEvent.speed,
5222 velocity: {
5223 x: interaction.prevEvent.velocityX,
5224 y: interaction.prevEvent.velocityY
5225 }
5226 };
5227 }
5228 }, {
5229 key: "preventDefault",
5230 value: function preventDefault() {}
5231 /**
5232 * Don't call listeners on the remaining targets
5233 */
5234
5235 }, {
5236 key: "stopImmediatePropagation",
5237 value: function stopImmediatePropagation() {
5238 this.immediatePropagationStopped = this.propagationStopped = true;
5239 }
5240 /**
5241 * Don't call any other listeners (even on the current target)
5242 */
5243
5244 }, {
5245 key: "stopPropagation",
5246 value: function stopPropagation() {
5247 this.propagationStopped = true;
5248 }
5249 }]);
5250
5251 return InteractEvent;
5252 }(_$BaseEvent_15.BaseEvent); // getters and setters defined here to support typescript 3.6 and below which
5253 // don't support getter and setters in .d.ts files
5254
5255
5256 _$InteractEvent_17.InteractEvent = InteractEvent;
5257 Object.defineProperties(InteractEvent.prototype, {
5258 pageX: {
5259 get: function get() {
5260 return this.page.x;
5261 },
5262 set: function set(value) {
5263 this.page.x = value;
5264 }
5265 },
5266 pageY: {
5267 get: function get() {
5268 return this.page.y;
5269 },
5270 set: function set(value) {
5271 this.page.y = value;
5272 }
5273 },
5274 clientX: {
5275 get: function get() {
5276 return this.client.x;
5277 },
5278 set: function set(value) {
5279 this.client.x = value;
5280 }
5281 },
5282 clientY: {
5283 get: function get() {
5284 return this.client.y;
5285 },
5286 set: function set(value) {
5287 this.client.y = value;
5288 }
5289 },
5290 dx: {
5291 get: function get() {
5292 return this.delta.x;
5293 },
5294 set: function set(value) {
5295 this.delta.x = value;
5296 }
5297 },
5298 dy: {
5299 get: function get() {
5300 return this.delta.y;
5301 },
5302 set: function set(value) {
5303 this.delta.y = value;
5304 }
5305 },
5306 velocityX: {
5307 get: function get() {
5308 return this.velocity.x;
5309 },
5310 set: function set(value) {
5311 this.velocity.x = value;
5312 }
5313 },
5314 velocityY: {
5315 get: function get() {
5316 return this.velocity.y;
5317 },
5318 set: function set(value) {
5319 this.velocity.y = value;
5320 }
5321 }
5322 });
5323 var _$PointerInfo_21 = {};
5324 "use strict";
5325
5326 Object.defineProperty(_$PointerInfo_21, "__esModule", {
5327 value: true
5328 });
5329 _$PointerInfo_21.PointerInfo = void 0;
5330
5331 function ___classCallCheck_21(instance, Constructor) {
5332 if (!(instance instanceof Constructor)) {
5333 throw new TypeError("Cannot call a class as a function");
5334 }
5335 }
5336
5337 var PointerInfo = function PointerInfo(id, pointer, event, downTime, downTarget) {
5338 ___classCallCheck_21(this, PointerInfo);
5339
5340 this.id = void 0;
5341 this.pointer = void 0;
5342 this.event = void 0;
5343 this.downTime = void 0;
5344 this.downTarget = void 0;
5345 this.id = id;
5346 this.pointer = pointer;
5347 this.event = event;
5348 this.downTime = downTime;
5349 this.downTarget = downTarget;
5350 };
5351
5352 _$PointerInfo_21.PointerInfo = PointerInfo;
5353 var _$Interaction_20 = {};
5354 "use strict";
5355
5356 Object.defineProperty(_$Interaction_20, "__esModule", {
5357 value: true
5358 });
5359 Object.defineProperty(_$Interaction_20, "PointerInfo", {
5360 enumerable: true,
5361 get: function get() {
5362 return _$PointerInfo_21.PointerInfo;
5363 }
5364 });
5365 _$Interaction_20["default"] = _$Interaction_20.Interaction = _$Interaction_20._ProxyMethods = _$Interaction_20._ProxyValues = void 0;
5366 /* removed: var _$arr_66 = require("../utils/arr.js"); */
5367
5368 ;
5369 /* removed: var _$extend_73 = require("../utils/extend.js"); */
5370
5371 ;
5372 /* removed: var _$hypot_75 = require("../utils/hypot.js"); */
5373
5374 ;
5375 /* removed: var _$misc_78 = require("../utils/misc.js"); */
5376
5377 ;
5378 /* removed: var _$pointerUtils_81 = require("../utils/pointerUtils.js"); */
5379
5380 ;
5381 /* removed: var _$rect_83 = require("../utils/rect.js"); */
5382
5383 ;
5384 /* removed: var _$InteractEvent_17 = require("./InteractEvent.js"); */
5385
5386 ;
5387 /* removed: var _$PointerInfo_21 = require("./PointerInfo.js"); */
5388
5389 ;
5390
5391 function ___classCallCheck_20(instance, Constructor) {
5392 if (!(instance instanceof Constructor)) {
5393 throw new TypeError("Cannot call a class as a function");
5394 }
5395 }
5396
5397 function ___defineProperties_20(target, props) {
5398 for (var i = 0; i < props.length; i++) {
5399 var descriptor = props[i];
5400 descriptor.enumerable = descriptor.enumerable || false;
5401 descriptor.configurable = true;
5402 if ("value" in descriptor) descriptor.writable = true;
5403 Object.defineProperty(target, descriptor.key, descriptor);
5404 }
5405 }
5406
5407 function ___createClass_20(Constructor, protoProps, staticProps) {
5408 if (protoProps) ___defineProperties_20(Constructor.prototype, protoProps);
5409 if (staticProps) ___defineProperties_20(Constructor, staticProps);
5410 return Constructor;
5411 }
5412
5413 var _ProxyValues;
5414
5415 _$Interaction_20._ProxyValues = _ProxyValues;
5416
5417 (function (_ProxyValues) {
5418 _ProxyValues["interactable"] = "";
5419 _ProxyValues["element"] = "";
5420 _ProxyValues["prepared"] = "";
5421 _ProxyValues["pointerIsDown"] = "";
5422 _ProxyValues["pointerWasMoved"] = "";
5423 _ProxyValues["_proxy"] = "";
5424 })(_ProxyValues || (_$Interaction_20._ProxyValues = _ProxyValues = {}));
5425
5426 var _ProxyMethods;
5427
5428 _$Interaction_20._ProxyMethods = _ProxyMethods;
5429
5430 (function (_ProxyMethods) {
5431 _ProxyMethods["start"] = "";
5432 _ProxyMethods["move"] = "";
5433 _ProxyMethods["end"] = "";
5434 _ProxyMethods["stop"] = "";
5435 _ProxyMethods["interacting"] = "";
5436 })(_ProxyMethods || (_$Interaction_20._ProxyMethods = _ProxyMethods = {}));
5437
5438 var idCounter = 0;
5439
5440 var Interaction = /*#__PURE__*/function () {
5441 ___createClass_20(Interaction, [{
5442 key: "pointerMoveTolerance",
5443 // current interactable being interacted with
5444 // the target element of the interactable
5445 // action that's ready to be fired on next move event
5446 // keep track of added pointers
5447 // pointerdown/mousedown/touchstart event
5448 // previous action event
5449
5450 /** @internal */
5451 get: function get() {
5452 return 1;
5453 }
5454 /**
5455 * @alias Interaction.prototype.move
5456 */
5457
5458 /** */
5459
5460 }]);
5461
5462 function Interaction(_ref) {
5463 var _this = this;
5464
5465 var pointerType = _ref.pointerType,
5466 scopeFire = _ref.scopeFire;
5467
5468 ___classCallCheck_20(this, Interaction);
5469
5470 this.interactable = null;
5471 this.element = null;
5472 this.rect = void 0;
5473 this._rects = void 0;
5474 this.edges = void 0;
5475 this._scopeFire = void 0;
5476 this.prepared = {
5477 name: null,
5478 axis: null,
5479 edges: null
5480 };
5481 this.pointerType = void 0;
5482 this.pointers = [];
5483 this.downEvent = null;
5484 this.downPointer = {};
5485 this._latestPointer = {
5486 pointer: null,
5487 event: null,
5488 eventTarget: null
5489 };
5490 this.prevEvent = null;
5491 this.pointerIsDown = false;
5492 this.pointerWasMoved = false;
5493 this._interacting = false;
5494 this._ending = false;
5495 this._stopped = true;
5496 this._proxy = null;
5497 this.simulation = null;
5498 this.doMove = (0, _$misc_78.warnOnce)(function (signalArg) {
5499 this.move(signalArg);
5500 }, 'The interaction.doMove() method has been renamed to interaction.move()');
5501 this.coords = {
5502 // Starting InteractEvent pointer coordinates
5503 start: _$pointerUtils_81.newCoords(),
5504 // Previous native pointer move event coordinates
5505 prev: _$pointerUtils_81.newCoords(),
5506 // current native pointer move event coordinates
5507 cur: _$pointerUtils_81.newCoords(),
5508 // Change in coordinates and time of the pointer
5509 delta: _$pointerUtils_81.newCoords(),
5510 // pointer velocity
5511 velocity: _$pointerUtils_81.newCoords()
5512 };
5513 this._id = idCounter++;
5514 this._scopeFire = scopeFire;
5515 this.pointerType = pointerType;
5516 var that = this;
5517 this._proxy = {};
5518
5519 var _loop = function _loop(key) {
5520 Object.defineProperty(_this._proxy, key, {
5521 get: function get() {
5522 return that[key];
5523 }
5524 });
5525 };
5526
5527 for (var key in _ProxyValues) {
5528 _loop(key);
5529 }
5530
5531 var _loop2 = function _loop2(_key) {
5532 Object.defineProperty(_this._proxy, _key, {
5533 value: function value() {
5534 return that[_key].apply(that, arguments);
5535 }
5536 });
5537 };
5538
5539 for (var _key in _ProxyMethods) {
5540 _loop2(_key);
5541 }
5542
5543 this._scopeFire('interactions:new', {
5544 interaction: this
5545 });
5546 }
5547
5548 ___createClass_20(Interaction, [{
5549 key: "pointerDown",
5550 value: function pointerDown(pointer, event, eventTarget) {
5551 var pointerIndex = this.updatePointer(pointer, event, eventTarget, true);
5552 var pointerInfo = this.pointers[pointerIndex];
5553
5554 this._scopeFire('interactions:down', {
5555 pointer: pointer,
5556 event: event,
5557 eventTarget: eventTarget,
5558 pointerIndex: pointerIndex,
5559 pointerInfo: pointerInfo,
5560 type: 'down',
5561 interaction: this
5562 });
5563 }
5564 /**
5565 * ```js
5566 * interact(target)
5567 * .draggable({
5568 * // disable the default drag start by down->move
5569 * manualStart: true
5570 * })
5571 * // start dragging after the user holds the pointer down
5572 * .on('hold', function (event) {
5573 * var interaction = event.interaction
5574 *
5575 * if (!interaction.interacting()) {
5576 * interaction.start({ name: 'drag' },
5577 * event.interactable,
5578 * event.currentTarget)
5579 * }
5580 * })
5581 * ```
5582 *
5583 * Start an action with the given Interactable and Element as tartgets. The
5584 * action must be enabled for the target Interactable and an appropriate
5585 * number of pointers must be held down - 1 for drag/resize, 2 for gesture.
5586 *
5587 * Use it with `interactable.<action>able({ manualStart: false })` to always
5588 * [start actions manually](https://github.com/taye/interact.js/issues/114)
5589 *
5590 * @param {object} action The action to be performed - drag, resize, etc.
5591 * @param {Interactable} target The Interactable to target
5592 * @param {Element} element The DOM Element to target
5593 * @return {object} interact
5594 */
5595
5596 }, {
5597 key: "start",
5598 value: function start(action, interactable, element) {
5599 if (this.interacting() || !this.pointerIsDown || this.pointers.length < (action.name === 'gesture' ? 2 : 1) || !interactable.options[action.name].enabled) {
5600 return false;
5601 }
5602
5603 (0, _$misc_78.copyAction)(this.prepared, action);
5604 this.interactable = interactable;
5605 this.element = element;
5606 this.rect = interactable.getRect(element);
5607 this.edges = this.prepared.edges ? (0, _$extend_73["default"])({}, this.prepared.edges) : {
5608 left: true,
5609 right: true,
5610 top: true,
5611 bottom: true
5612 };
5613 this._stopped = false;
5614 this._interacting = this._doPhase({
5615 interaction: this,
5616 event: this.downEvent,
5617 phase: 'start'
5618 }) && !this._stopped;
5619 return this._interacting;
5620 }
5621 }, {
5622 key: "pointerMove",
5623 value: function pointerMove(pointer, event, eventTarget) {
5624 if (!this.simulation && !(this.modification && this.modification.endResult)) {
5625 this.updatePointer(pointer, event, eventTarget, false);
5626 }
5627
5628 var duplicateMove = this.coords.cur.page.x === this.coords.prev.page.x && this.coords.cur.page.y === this.coords.prev.page.y && this.coords.cur.client.x === this.coords.prev.client.x && this.coords.cur.client.y === this.coords.prev.client.y;
5629 var dx;
5630 var dy; // register movement greater than pointerMoveTolerance
5631
5632 if (this.pointerIsDown && !this.pointerWasMoved) {
5633 dx = this.coords.cur.client.x - this.coords.start.client.x;
5634 dy = this.coords.cur.client.y - this.coords.start.client.y;
5635 this.pointerWasMoved = (0, _$hypot_75["default"])(dx, dy) > this.pointerMoveTolerance;
5636 }
5637
5638 var pointerIndex = this.getPointerIndex(pointer);
5639 var signalArg = {
5640 pointer: pointer,
5641 pointerIndex: pointerIndex,
5642 pointerInfo: this.pointers[pointerIndex],
5643 event: event,
5644 type: 'move',
5645 eventTarget: eventTarget,
5646 dx: dx,
5647 dy: dy,
5648 duplicate: duplicateMove,
5649 interaction: this
5650 };
5651
5652 if (!duplicateMove) {
5653 // set pointer coordinate, time changes and velocity
5654 _$pointerUtils_81.setCoordVelocity(this.coords.velocity, this.coords.delta);
5655 }
5656
5657 this._scopeFire('interactions:move', signalArg);
5658
5659 if (!duplicateMove && !this.simulation) {
5660 // if interacting, fire an 'action-move' signal etc
5661 if (this.interacting()) {
5662 signalArg.type = null;
5663 this.move(signalArg);
5664 }
5665
5666 if (this.pointerWasMoved) {
5667 _$pointerUtils_81.copyCoords(this.coords.prev, this.coords.cur);
5668 }
5669 }
5670 }
5671 /**
5672 * ```js
5673 * interact(target)
5674 * .draggable(true)
5675 * .on('dragmove', function (event) {
5676 * if (someCondition) {
5677 * // change the snap settings
5678 * event.interactable.draggable({ snap: { targets: [] }})
5679 * // fire another move event with re-calculated snap
5680 * event.interaction.move()
5681 * }
5682 * })
5683 * ```
5684 *
5685 * Force a move of the current action at the same coordinates. Useful if
5686 * snap/restrict has been changed and you want a movement with the new
5687 * settings.
5688 */
5689
5690 }, {
5691 key: "move",
5692 value: function move(signalArg) {
5693 if (!signalArg || !signalArg.event) {
5694 _$pointerUtils_81.setZeroCoords(this.coords.delta);
5695 }
5696
5697 signalArg = (0, _$extend_73["default"])({
5698 pointer: this._latestPointer.pointer,
5699 event: this._latestPointer.event,
5700 eventTarget: this._latestPointer.eventTarget,
5701 interaction: this
5702 }, signalArg || {});
5703 signalArg.phase = 'move';
5704
5705 this._doPhase(signalArg);
5706 } // End interact move events and stop auto-scroll unless simulation is running
5707
5708 }, {
5709 key: "pointerUp",
5710 value: function pointerUp(pointer, event, eventTarget, curEventTarget) {
5711 var pointerIndex = this.getPointerIndex(pointer);
5712
5713 if (pointerIndex === -1) {
5714 pointerIndex = this.updatePointer(pointer, event, eventTarget, false);
5715 }
5716
5717 var type = /cancel$/i.test(event.type) ? 'cancel' : 'up';
5718
5719 this._scopeFire("interactions:".concat(type), {
5720 pointer: pointer,
5721 pointerIndex: pointerIndex,
5722 pointerInfo: this.pointers[pointerIndex],
5723 event: event,
5724 eventTarget: eventTarget,
5725 type: type,
5726 curEventTarget: curEventTarget,
5727 interaction: this
5728 });
5729
5730 if (!this.simulation) {
5731 this.end(event);
5732 }
5733
5734 this.pointerIsDown = false;
5735 this.removePointer(pointer, event);
5736 }
5737 }, {
5738 key: "documentBlur",
5739 value: function documentBlur(event) {
5740 this.end(event);
5741
5742 this._scopeFire('interactions:blur', {
5743 event: event,
5744 type: 'blur',
5745 interaction: this
5746 });
5747 }
5748 /**
5749 * ```js
5750 * interact(target)
5751 * .draggable(true)
5752 * .on('move', function (event) {
5753 * if (event.pageX > 1000) {
5754 * // end the current action
5755 * event.interaction.end()
5756 * // stop all further listeners from being called
5757 * event.stopImmediatePropagation()
5758 * }
5759 * })
5760 * ```
5761 *
5762 * @param {PointerEvent} [event]
5763 */
5764
5765 }, {
5766 key: "end",
5767 value: function end(event) {
5768 this._ending = true;
5769 event = event || this._latestPointer.event;
5770 var endPhaseResult;
5771
5772 if (this.interacting()) {
5773 endPhaseResult = this._doPhase({
5774 event: event,
5775 interaction: this,
5776 phase: 'end'
5777 });
5778 }
5779
5780 this._ending = false;
5781
5782 if (endPhaseResult === true) {
5783 this.stop();
5784 }
5785 }
5786 }, {
5787 key: "currentAction",
5788 value: function currentAction() {
5789 return this._interacting ? this.prepared.name : null;
5790 }
5791 }, {
5792 key: "interacting",
5793 value: function interacting() {
5794 return this._interacting;
5795 }
5796 /** */
5797
5798 }, {
5799 key: "stop",
5800 value: function stop() {
5801 this._scopeFire('interactions:stop', {
5802 interaction: this
5803 });
5804
5805 this.interactable = this.element = null;
5806 this._interacting = false;
5807 this._stopped = true;
5808 this.prepared.name = this.prevEvent = null;
5809 }
5810 }, {
5811 key: "getPointerIndex",
5812 value: function getPointerIndex(pointer) {
5813 var pointerId = _$pointerUtils_81.getPointerId(pointer); // mouse and pen interactions may have only one pointer
5814
5815
5816 return this.pointerType === 'mouse' || this.pointerType === 'pen' ? this.pointers.length - 1 : _$arr_66.findIndex(this.pointers, function (curPointer) {
5817 return curPointer.id === pointerId;
5818 });
5819 }
5820 }, {
5821 key: "getPointerInfo",
5822 value: function getPointerInfo(pointer) {
5823 return this.pointers[this.getPointerIndex(pointer)];
5824 }
5825 }, {
5826 key: "updatePointer",
5827 value: function updatePointer(pointer, event, eventTarget, down) {
5828 var id = _$pointerUtils_81.getPointerId(pointer);
5829
5830 var pointerIndex = this.getPointerIndex(pointer);
5831 var pointerInfo = this.pointers[pointerIndex];
5832 down = down === false ? false : down || /(down|start)$/i.test(event.type);
5833
5834 if (!pointerInfo) {
5835 pointerInfo = new _$PointerInfo_21.PointerInfo(id, pointer, event, null, null);
5836 pointerIndex = this.pointers.length;
5837 this.pointers.push(pointerInfo);
5838 } else {
5839 pointerInfo.pointer = pointer;
5840 }
5841
5842 _$pointerUtils_81.setCoords(this.coords.cur, this.pointers.map(function (p) {
5843 return p.pointer;
5844 }), this._now());
5845
5846 _$pointerUtils_81.setCoordDeltas(this.coords.delta, this.coords.prev, this.coords.cur);
5847
5848 if (down) {
5849 this.pointerIsDown = true;
5850 pointerInfo.downTime = this.coords.cur.timeStamp;
5851 pointerInfo.downTarget = eventTarget;
5852
5853 _$pointerUtils_81.pointerExtend(this.downPointer, pointer);
5854
5855 if (!this.interacting()) {
5856 _$pointerUtils_81.copyCoords(this.coords.start, this.coords.cur);
5857
5858 _$pointerUtils_81.copyCoords(this.coords.prev, this.coords.cur);
5859
5860 this.downEvent = event;
5861 this.pointerWasMoved = false;
5862 }
5863 }
5864
5865 this._updateLatestPointer(pointer, event, eventTarget);
5866
5867 this._scopeFire('interactions:update-pointer', {
5868 pointer: pointer,
5869 event: event,
5870 eventTarget: eventTarget,
5871 down: down,
5872 pointerInfo: pointerInfo,
5873 pointerIndex: pointerIndex,
5874 interaction: this
5875 });
5876
5877 return pointerIndex;
5878 }
5879 }, {
5880 key: "removePointer",
5881 value: function removePointer(pointer, event) {
5882 var pointerIndex = this.getPointerIndex(pointer);
5883
5884 if (pointerIndex === -1) {
5885 return;
5886 }
5887
5888 var pointerInfo = this.pointers[pointerIndex];
5889
5890 this._scopeFire('interactions:remove-pointer', {
5891 pointer: pointer,
5892 event: event,
5893 eventTarget: null,
5894 pointerIndex: pointerIndex,
5895 pointerInfo: pointerInfo,
5896 interaction: this
5897 });
5898
5899 this.pointers.splice(pointerIndex, 1);
5900 }
5901 }, {
5902 key: "_updateLatestPointer",
5903 value: function _updateLatestPointer(pointer, event, eventTarget) {
5904 this._latestPointer.pointer = pointer;
5905 this._latestPointer.event = event;
5906 this._latestPointer.eventTarget = eventTarget;
5907 }
5908 }, {
5909 key: "destroy",
5910 value: function destroy() {
5911 this._latestPointer.pointer = null;
5912 this._latestPointer.event = null;
5913 this._latestPointer.eventTarget = null;
5914 }
5915 }, {
5916 key: "_createPreparedEvent",
5917 value: function _createPreparedEvent(event, phase, preEnd, type) {
5918 return new _$InteractEvent_17.InteractEvent(this, event, this.prepared.name, phase, this.element, preEnd, type);
5919 }
5920 }, {
5921 key: "_fireEvent",
5922 value: function _fireEvent(iEvent) {
5923 this.interactable.fire(iEvent);
5924
5925 if (!this.prevEvent || iEvent.timeStamp >= this.prevEvent.timeStamp) {
5926 this.prevEvent = iEvent;
5927 }
5928 }
5929 }, {
5930 key: "_doPhase",
5931 value: function _doPhase(signalArg) {
5932 var event = signalArg.event,
5933 phase = signalArg.phase,
5934 preEnd = signalArg.preEnd,
5935 type = signalArg.type;
5936 var rect = this.rect;
5937
5938 if (rect && phase === 'move') {
5939 // update the rect changes due to pointer move
5940 _$rect_83.addEdges(this.edges, rect, this.coords.delta[this.interactable.options.deltaSource]);
5941
5942 rect.width = rect.right - rect.left;
5943 rect.height = rect.bottom - rect.top;
5944 }
5945
5946 var beforeResult = this._scopeFire("interactions:before-action-".concat(phase), signalArg);
5947
5948 if (beforeResult === false) {
5949 return false;
5950 }
5951
5952 var iEvent = signalArg.iEvent = this._createPreparedEvent(event, phase, preEnd, type);
5953
5954 this._scopeFire("interactions:action-".concat(phase), signalArg);
5955
5956 if (phase === 'start') {
5957 this.prevEvent = iEvent;
5958 }
5959
5960 this._fireEvent(iEvent);
5961
5962 this._scopeFire("interactions:after-action-".concat(phase), signalArg);
5963
5964 return true;
5965 }
5966 }, {
5967 key: "_now",
5968 value: function _now() {
5969 return Date.now();
5970 }
5971 }]);
5972
5973 return Interaction;
5974 }();
5975
5976 _$Interaction_20.Interaction = Interaction;
5977 var ___default_20 = Interaction;
5978 _$Interaction_20["default"] = ___default_20;
5979 var _$plugin_53 = {};
5980 "use strict";
5981
5982 Object.defineProperty(_$plugin_53, "__esModule", {
5983 value: true
5984 });
5985 _$plugin_53.addTotal = addTotal;
5986 _$plugin_53.applyPending = applyPending;
5987 _$plugin_53["default"] = void 0;
5988 /* removed: var _$Interaction_20 = require("../core/Interaction.js"); */
5989
5990 ;
5991 /* removed: var _$rect_83 = require("../utils/rect.js"); */
5992
5993 ;
5994 _$Interaction_20._ProxyMethods.offsetBy = '';
5995
5996 function addTotal(interaction) {
5997 if (!interaction.pointerIsDown) {
5998 return;
5999 }
6000
6001 addToCoords(interaction.coords.cur, interaction.offset.total);
6002 interaction.offset.pending.x = 0;
6003 interaction.offset.pending.y = 0;
6004 }
6005
6006 function beforeAction(_ref) {
6007 var interaction = _ref.interaction;
6008 applyPending(interaction);
6009 }
6010
6011 function beforeEnd(_ref2) {
6012 var interaction = _ref2.interaction;
6013 var hadPending = applyPending(interaction);
6014
6015 if (!hadPending) {
6016 return;
6017 }
6018
6019 interaction.move({
6020 offset: true
6021 });
6022 interaction.end();
6023 return false;
6024 }
6025
6026 function __end_53(_ref3) {
6027 var interaction = _ref3.interaction;
6028 interaction.offset.total.x = 0;
6029 interaction.offset.total.y = 0;
6030 interaction.offset.pending.x = 0;
6031 interaction.offset.pending.y = 0;
6032 }
6033
6034 function applyPending(interaction) {
6035 if (!hasPending(interaction)) {
6036 return false;
6037 }
6038
6039 var pending = interaction.offset.pending;
6040 addToCoords(interaction.coords.cur, pending);
6041 addToCoords(interaction.coords.delta, pending);
6042
6043 _$rect_83.addEdges(interaction.edges, interaction.rect, pending);
6044
6045 pending.x = 0;
6046 pending.y = 0;
6047 return true;
6048 }
6049
6050 function offsetBy(_ref4) {
6051 var x = _ref4.x,
6052 y = _ref4.y;
6053 this.offset.pending.x += x;
6054 this.offset.pending.y += y;
6055 this.offset.total.x += x;
6056 this.offset.total.y += y;
6057 }
6058
6059 function addToCoords(_ref5, _ref6) {
6060 var page = _ref5.page,
6061 client = _ref5.client;
6062 var x = _ref6.x,
6063 y = _ref6.y;
6064 page.x += x;
6065 page.y += y;
6066 client.x += x;
6067 client.y += y;
6068 }
6069
6070 function hasPending(interaction) {
6071 return !!(interaction.offset.pending.x || interaction.offset.pending.y);
6072 }
6073
6074 var offset = {
6075 id: 'offset',
6076 install: function install(scope) {
6077 scope.Interaction.prototype.offsetBy = offsetBy;
6078 },
6079 listeners: {
6080 'interactions:new': function interactionsNew(_ref7) {
6081 var interaction = _ref7.interaction;
6082 interaction.offset = {
6083 total: {
6084 x: 0,
6085 y: 0
6086 },
6087 pending: {
6088 x: 0,
6089 y: 0
6090 }
6091 };
6092 },
6093 'interactions:update-pointer': function interactionsUpdatePointer(_ref8) {
6094 var interaction = _ref8.interaction;
6095 return addTotal(interaction);
6096 },
6097 'interactions:before-action-start': beforeAction,
6098 'interactions:before-action-move': beforeAction,
6099 'interactions:before-action-end': beforeEnd,
6100 'interactions:stop': __end_53
6101 }
6102 };
6103 var ___default_53 = offset;
6104 _$plugin_53["default"] = ___default_53;
6105 var _$plugin_32 = {};
6106 "use strict";
6107
6108 Object.defineProperty(_$plugin_32, "__esModule", {
6109 value: true
6110 });
6111 _$plugin_32["default"] = _$plugin_32.InertiaState = void 0;
6112 /* removed: var _$Modification_35 = require("../modifiers/Modification.js"); */
6113
6114 ;
6115 /* removed: var _$base_39 = require("../modifiers/base.js"); */
6116
6117 ;
6118 /* removed: var _$plugin_53 = require("../offset/plugin.js"); */
6119
6120 ;
6121 /* removed: var _$domUtils_71 = require("../utils/domUtils.js"); */
6122
6123 ;
6124 /* removed: var _$hypot_75 = require("../utils/hypot.js"); */
6125
6126 ;
6127 /* removed: var _$is_76 = require("../utils/is.js"); */
6128
6129 ;
6130 /* removed: var _$pointerUtils_81 = require("../utils/pointerUtils.js"); */
6131
6132 ;
6133 /* removed: var _$raf_82 = require("../utils/raf.js"); */
6134
6135 ;
6136
6137 function ___classCallCheck_32(instance, Constructor) {
6138 if (!(instance instanceof Constructor)) {
6139 throw new TypeError("Cannot call a class as a function");
6140 }
6141 }
6142
6143 function ___defineProperties_32(target, props) {
6144 for (var i = 0; i < props.length; i++) {
6145 var descriptor = props[i];
6146 descriptor.enumerable = descriptor.enumerable || false;
6147 descriptor.configurable = true;
6148 if ("value" in descriptor) descriptor.writable = true;
6149 Object.defineProperty(target, descriptor.key, descriptor);
6150 }
6151 }
6152
6153 function ___createClass_32(Constructor, protoProps, staticProps) {
6154 if (protoProps) ___defineProperties_32(Constructor.prototype, protoProps);
6155 if (staticProps) ___defineProperties_32(Constructor, staticProps);
6156 return Constructor;
6157 }
6158
6159 function __install_32(scope) {
6160 var defaults = scope.defaults;
6161 scope.usePlugin(_$plugin_53["default"]);
6162 scope.usePlugin(_$base_39["default"]);
6163 scope.actions.phases.inertiastart = true;
6164 scope.actions.phases.resume = true;
6165 defaults.perAction.inertia = {
6166 enabled: false,
6167 resistance: 10,
6168 // the lambda in exponential decay
6169 minSpeed: 100,
6170 // target speed must be above this for inertia to start
6171 endSpeed: 10,
6172 // the speed at which inertia is slow enough to stop
6173 allowResume: true,
6174 // allow resuming an action in inertia phase
6175 smoothEndDuration: 300 // animate to snap/restrict endOnly if there's no inertia
6176
6177 };
6178 }
6179
6180 var InertiaState = /*#__PURE__*/function () {
6181 // eslint-disable-line camelcase
6182 // eslint-disable-line camelcase
6183 function InertiaState(interaction) {
6184 ___classCallCheck_32(this, InertiaState);
6185
6186 this.active = false;
6187 this.isModified = false;
6188 this.smoothEnd = false;
6189 this.allowResume = false;
6190 this.modification = null;
6191 this.modifierCount = 0;
6192 this.modifierArg = null;
6193 this.startCoords = null;
6194 this.t0 = 0;
6195 this.v0 = 0;
6196 this.te = 0;
6197 this.targetOffset = null;
6198 this.modifiedOffset = null;
6199 this.currentOffset = null;
6200 this.lambda_v0 = 0;
6201 this.one_ve_v0 = 0;
6202 this.timeout = null;
6203 this.interaction = void 0;
6204 this.interaction = interaction;
6205 }
6206
6207 ___createClass_32(InertiaState, [{
6208 key: "start",
6209 value: function start(event) {
6210 var interaction = this.interaction;
6211 var options = getOptions(interaction);
6212
6213 if (!options || !options.enabled) {
6214 return false;
6215 }
6216
6217 var velocityClient = interaction.coords.velocity.client;
6218 var pointerSpeed = (0, _$hypot_75["default"])(velocityClient.x, velocityClient.y);
6219 var modification = this.modification || (this.modification = new _$Modification_35["default"](interaction));
6220 modification.copyFrom(interaction.modification);
6221 this.t0 = interaction._now();
6222 this.allowResume = options.allowResume;
6223 this.v0 = pointerSpeed;
6224 this.currentOffset = {
6225 x: 0,
6226 y: 0
6227 };
6228 this.startCoords = interaction.coords.cur.page;
6229 this.modifierArg = {
6230 interaction: interaction,
6231 interactable: interaction.interactable,
6232 element: interaction.element,
6233 rect: interaction.rect,
6234 edges: interaction.edges,
6235 pageCoords: this.startCoords,
6236 preEnd: true,
6237 phase: 'inertiastart'
6238 };
6239 var thrown = this.t0 - interaction.coords.cur.timeStamp < 50 && pointerSpeed > options.minSpeed && pointerSpeed > options.endSpeed;
6240
6241 if (thrown) {
6242 this.startInertia();
6243 } else {
6244 modification.result = modification.setAll(this.modifierArg);
6245
6246 if (!modification.result.changed) {
6247 return false;
6248 }
6249
6250 this.startSmoothEnd();
6251 } // force modification change
6252
6253
6254 interaction.modification.result.rect = null; // bring inertiastart event to the target coords
6255
6256 interaction.offsetBy(this.targetOffset);
6257
6258 interaction._doPhase({
6259 interaction: interaction,
6260 event: event,
6261 phase: 'inertiastart'
6262 });
6263
6264 interaction.offsetBy({
6265 x: -this.targetOffset.x,
6266 y: -this.targetOffset.y
6267 }); // force modification change
6268
6269 interaction.modification.result.rect = null;
6270 this.active = true;
6271 interaction.simulation = this;
6272 return true;
6273 }
6274 }, {
6275 key: "startInertia",
6276 value: function startInertia() {
6277 var _this = this;
6278
6279 var startVelocity = this.interaction.coords.velocity.client;
6280 var options = getOptions(this.interaction);
6281 var lambda = options.resistance;
6282 var inertiaDur = -Math.log(options.endSpeed / this.v0) / lambda;
6283 this.targetOffset = {
6284 x: (startVelocity.x - inertiaDur) / lambda,
6285 y: (startVelocity.y - inertiaDur) / lambda
6286 };
6287 this.te = inertiaDur;
6288 this.lambda_v0 = lambda / this.v0;
6289 this.one_ve_v0 = 1 - options.endSpeed / this.v0;
6290 var modification = this.modification,
6291 modifierArg = this.modifierArg;
6292 modifierArg.pageCoords = {
6293 x: this.startCoords.x + this.targetOffset.x,
6294 y: this.startCoords.y + this.targetOffset.y
6295 };
6296 modification.result = modification.setAll(modifierArg);
6297
6298 if (modification.result.changed) {
6299 this.isModified = true;
6300 this.modifiedOffset = {
6301 x: this.targetOffset.x + modification.result.delta.x,
6302 y: this.targetOffset.y + modification.result.delta.y
6303 };
6304 }
6305
6306 this.timeout = _$raf_82["default"].request(function () {
6307 return _this.inertiaTick();
6308 });
6309 }
6310 }, {
6311 key: "startSmoothEnd",
6312 value: function startSmoothEnd() {
6313 var _this2 = this;
6314
6315 this.smoothEnd = true;
6316 this.isModified = true;
6317 this.targetOffset = {
6318 x: this.modification.result.delta.x,
6319 y: this.modification.result.delta.y
6320 };
6321 this.timeout = _$raf_82["default"].request(function () {
6322 return _this2.smoothEndTick();
6323 });
6324 }
6325 }, {
6326 key: "inertiaTick",
6327 value: function inertiaTick() {
6328 var _this3 = this;
6329
6330 var interaction = this.interaction;
6331 var options = getOptions(interaction);
6332 var lambda = options.resistance;
6333 var t = (interaction._now() - this.t0) / 1000;
6334
6335 if (t < this.te) {
6336 var progress = 1 - (Math.exp(-lambda * t) - this.lambda_v0) / this.one_ve_v0;
6337 var newOffset;
6338
6339 if (this.isModified) {
6340 newOffset = getQuadraticCurvePoint(0, 0, this.targetOffset.x, this.targetOffset.y, this.modifiedOffset.x, this.modifiedOffset.y, progress);
6341 } else {
6342 newOffset = {
6343 x: this.targetOffset.x * progress,
6344 y: this.targetOffset.y * progress
6345 };
6346 }
6347
6348 var delta = {
6349 x: newOffset.x - this.currentOffset.x,
6350 y: newOffset.y - this.currentOffset.y
6351 };
6352 this.currentOffset.x += delta.x;
6353 this.currentOffset.y += delta.y;
6354 interaction.offsetBy(delta);
6355 interaction.move();
6356 this.timeout = _$raf_82["default"].request(function () {
6357 return _this3.inertiaTick();
6358 });
6359 } else {
6360 interaction.offsetBy({
6361 x: this.modifiedOffset.x - this.currentOffset.x,
6362 y: this.modifiedOffset.y - this.currentOffset.y
6363 });
6364 this.end();
6365 }
6366 }
6367 }, {
6368 key: "smoothEndTick",
6369 value: function smoothEndTick() {
6370 var _this4 = this;
6371
6372 var interaction = this.interaction;
6373 var t = interaction._now() - this.t0;
6374
6375 var _getOptions = getOptions(interaction),
6376 duration = _getOptions.smoothEndDuration;
6377
6378 if (t < duration) {
6379 var newOffset = {
6380 x: easeOutQuad(t, 0, this.targetOffset.x, duration),
6381 y: easeOutQuad(t, 0, this.targetOffset.y, duration)
6382 };
6383 var delta = {
6384 x: newOffset.x - this.currentOffset.x,
6385 y: newOffset.y - this.currentOffset.y
6386 };
6387 this.currentOffset.x += delta.x;
6388 this.currentOffset.y += delta.y;
6389 interaction.offsetBy(delta);
6390 interaction.move({
6391 skipModifiers: this.modifierCount
6392 });
6393 this.timeout = _$raf_82["default"].request(function () {
6394 return _this4.smoothEndTick();
6395 });
6396 } else {
6397 interaction.offsetBy({
6398 x: this.targetOffset.x - this.currentOffset.x,
6399 y: this.targetOffset.y - this.currentOffset.y
6400 });
6401 this.end();
6402 }
6403 }
6404 }, {
6405 key: "resume",
6406 value: function resume(_ref) {
6407 var pointer = _ref.pointer,
6408 event = _ref.event,
6409 eventTarget = _ref.eventTarget;
6410 var interaction = this.interaction; // undo inertia changes to interaction coords
6411
6412 interaction.offsetBy({
6413 x: -this.currentOffset.x,
6414 y: -this.currentOffset.y
6415 }); // update pointer at pointer down position
6416
6417 interaction.updatePointer(pointer, event, eventTarget, true); // fire resume signals and event
6418
6419 interaction._doPhase({
6420 interaction: interaction,
6421 event: event,
6422 phase: 'resume'
6423 });
6424
6425 (0, _$pointerUtils_81.copyCoords)(interaction.coords.prev, interaction.coords.cur);
6426 this.stop();
6427 }
6428 }, {
6429 key: "end",
6430 value: function end() {
6431 this.interaction.move();
6432 this.interaction.end();
6433 this.stop();
6434 }
6435 }, {
6436 key: "stop",
6437 value: function stop() {
6438 this.active = this.smoothEnd = false;
6439 this.interaction.simulation = null;
6440
6441 _$raf_82["default"].cancel(this.timeout);
6442 }
6443 }]);
6444
6445 return InertiaState;
6446 }();
6447
6448 _$plugin_32.InertiaState = InertiaState;
6449
6450 function __start_32(_ref2) {
6451 var interaction = _ref2.interaction,
6452 event = _ref2.event;
6453
6454 if (!interaction._interacting || interaction.simulation) {
6455 return null;
6456 }
6457
6458 var started = interaction.inertia.start(event); // prevent action end if inertia or smoothEnd
6459
6460 return started ? false : null;
6461 } // Check if the down event hits the current inertia target
6462 // control should be return to the user
6463
6464
6465 function resume(arg) {
6466 var interaction = arg.interaction,
6467 eventTarget = arg.eventTarget;
6468 var state = interaction.inertia;
6469
6470 if (!state.active) {
6471 return;
6472 }
6473
6474 var element = eventTarget; // climb up the DOM tree from the event target
6475
6476 while (_$is_76["default"].element(element)) {
6477 // if interaction element is the current inertia target element
6478 if (element === interaction.element) {
6479 state.resume(arg);
6480 break;
6481 }
6482
6483 element = _$domUtils_71.parentNode(element);
6484 }
6485 }
6486
6487 function stop(_ref3) {
6488 var interaction = _ref3.interaction;
6489 var state = interaction.inertia;
6490
6491 if (state.active) {
6492 state.stop();
6493 }
6494 }
6495
6496 function getOptions(_ref4) {
6497 var interactable = _ref4.interactable,
6498 prepared = _ref4.prepared;
6499 return interactable && interactable.options && prepared.name && interactable.options[prepared.name].inertia;
6500 }
6501
6502 var inertia = {
6503 id: 'inertia',
6504 before: ['modifiers/base'],
6505 install: __install_32,
6506 listeners: {
6507 'interactions:new': function interactionsNew(_ref5) {
6508 var interaction = _ref5.interaction;
6509 interaction.inertia = new InertiaState(interaction);
6510 },
6511 'interactions:before-action-end': __start_32,
6512 'interactions:down': resume,
6513 'interactions:stop': stop,
6514 'interactions:before-action-resume': function interactionsBeforeActionResume(arg) {
6515 var modification = arg.interaction.modification;
6516 modification.stop(arg);
6517 modification.start(arg, arg.interaction.coords.cur.page);
6518 modification.applyToInteraction(arg);
6519 },
6520 'interactions:before-action-inertiastart': function interactionsBeforeActionInertiastart(arg) {
6521 return arg.interaction.modification.setAndApply(arg);
6522 },
6523 'interactions:action-resume': _$base_39.addEventModifiers,
6524 'interactions:action-inertiastart': _$base_39.addEventModifiers,
6525 'interactions:after-action-inertiastart': function interactionsAfterActionInertiastart(arg) {
6526 return arg.interaction.modification.restoreInteractionCoords(arg);
6527 },
6528 'interactions:after-action-resume': function interactionsAfterActionResume(arg) {
6529 return arg.interaction.modification.restoreInteractionCoords(arg);
6530 }
6531 }
6532 }; // http://stackoverflow.com/a/5634528/2280888
6533
6534 function _getQBezierValue(t, p1, p2, p3) {
6535 var iT = 1 - t;
6536 return iT * iT * p1 + 2 * iT * t * p2 + t * t * p3;
6537 }
6538
6539 function getQuadraticCurvePoint(startX, startY, cpX, cpY, endX, endY, position) {
6540 return {
6541 x: _getQBezierValue(position, startX, cpX, endX),
6542 y: _getQBezierValue(position, startY, cpY, endY)
6543 };
6544 } // http://gizma.com/easing/
6545
6546
6547 function easeOutQuad(t, b, c, d) {
6548 t /= d;
6549 return -c * t * (t - 2) + b;
6550 }
6551
6552 var ___default_32 = inertia;
6553 _$plugin_32["default"] = ___default_32;
6554 var _$Eventable_16 = {};
6555 "use strict";
6556
6557 Object.defineProperty(_$Eventable_16, "__esModule", {
6558 value: true
6559 });
6560 _$Eventable_16.Eventable = void 0;
6561 /* removed: var _$arr_66 = require("../utils/arr.js"); */
6562
6563 ;
6564 /* removed: var _$extend_73 = require("../utils/extend.js"); */
6565
6566 ;
6567 /* removed: var _$normalizeListeners_79 = require("../utils/normalizeListeners.js"); */
6568
6569 ;
6570
6571 function ___classCallCheck_16(instance, Constructor) {
6572 if (!(instance instanceof Constructor)) {
6573 throw new TypeError("Cannot call a class as a function");
6574 }
6575 }
6576
6577 function ___defineProperties_16(target, props) {
6578 for (var i = 0; i < props.length; i++) {
6579 var descriptor = props[i];
6580 descriptor.enumerable = descriptor.enumerable || false;
6581 descriptor.configurable = true;
6582 if ("value" in descriptor) descriptor.writable = true;
6583 Object.defineProperty(target, descriptor.key, descriptor);
6584 }
6585 }
6586
6587 function ___createClass_16(Constructor, protoProps, staticProps) {
6588 if (protoProps) ___defineProperties_16(Constructor.prototype, protoProps);
6589 if (staticProps) ___defineProperties_16(Constructor, staticProps);
6590 return Constructor;
6591 }
6592
6593 function fireUntilImmediateStopped(event, listeners) {
6594 for (var _i = 0; _i < listeners.length; _i++) {
6595 var _ref;
6596
6597 _ref = listeners[_i];
6598 var listener = _ref;
6599
6600 if (event.immediatePropagationStopped) {
6601 break;
6602 }
6603
6604 listener(event);
6605 }
6606 }
6607
6608 var Eventable = /*#__PURE__*/function () {
6609 function Eventable(options) {
6610 ___classCallCheck_16(this, Eventable);
6611
6612 this.options = void 0;
6613 this.types = {};
6614 this.propagationStopped = false;
6615 this.immediatePropagationStopped = false;
6616 this.global = void 0;
6617 this.options = (0, _$extend_73["default"])({}, options || {});
6618 }
6619
6620 ___createClass_16(Eventable, [{
6621 key: "fire",
6622 value: function fire(event) {
6623 var listeners;
6624 var global = this.global; // Interactable#on() listeners
6625 // tslint:disable no-conditional-assignment
6626
6627 if (listeners = this.types[event.type]) {
6628 fireUntilImmediateStopped(event, listeners);
6629 } // interact.on() listeners
6630
6631
6632 if (!event.propagationStopped && global && (listeners = global[event.type])) {
6633 fireUntilImmediateStopped(event, listeners);
6634 }
6635 }
6636 }, {
6637 key: "on",
6638 value: function on(type, listener) {
6639 var listeners = (0, _$normalizeListeners_79["default"])(type, listener);
6640
6641 for (type in listeners) {
6642 this.types[type] = _$arr_66.merge(this.types[type] || [], listeners[type]);
6643 }
6644 }
6645 }, {
6646 key: "off",
6647 value: function off(type, listener) {
6648 var listeners = (0, _$normalizeListeners_79["default"])(type, listener);
6649
6650 for (type in listeners) {
6651 var eventList = this.types[type];
6652
6653 if (!eventList || !eventList.length) {
6654 continue;
6655 }
6656
6657 for (var _i2 = 0; _i2 < listeners[type].length; _i2++) {
6658 var _ref2;
6659
6660 _ref2 = listeners[type][_i2];
6661 var subListener = _ref2;
6662 var index = eventList.indexOf(subListener);
6663
6664 if (index !== -1) {
6665 eventList.splice(index, 1);
6666 }
6667 }
6668 }
6669 }
6670 }, {
6671 key: "getRect",
6672 value: function getRect(_element) {
6673 return null;
6674 }
6675 }]);
6676
6677 return Eventable;
6678 }();
6679
6680 _$Eventable_16.Eventable = Eventable;
6681 var _$isNonNativeEvent_28 = {};
6682 "use strict";
6683
6684 Object.defineProperty(_$isNonNativeEvent_28, "__esModule", {
6685 value: true
6686 });
6687 _$isNonNativeEvent_28["default"] = isNonNativeEvent;
6688
6689 function isNonNativeEvent(type, actions) {
6690 if (actions.phaselessTypes[type]) {
6691 return true;
6692 }
6693
6694 for (var name in actions.map) {
6695 if (type.indexOf(name) === 0 && type.substr(name.length) in actions.phases) {
6696 return true;
6697 }
6698 }
6699
6700 return false;
6701 }
6702
6703 var _$Interactable_18 = {};
6704 "use strict";
6705
6706 Object.defineProperty(_$Interactable_18, "__esModule", {
6707 value: true
6708 });
6709 _$Interactable_18.Interactable = void 0;
6710 /* removed: var _$arr_66 = require("../utils/arr.js"); */
6711
6712 ;
6713 /* removed: var _$browser_67 = require("../utils/browser.js"); */
6714
6715 ;
6716 /* removed: var _$clone_68 = require("../utils/clone.js"); */
6717
6718 ;
6719 /* removed: var _$domUtils_71 = require("../utils/domUtils.js"); */
6720
6721 ;
6722 /* removed: var _$extend_73 = require("../utils/extend.js"); */
6723
6724 ;
6725 /* removed: var _$is_76 = require("../utils/is.js"); */
6726
6727 ;
6728 /* removed: var _$normalizeListeners_79 = require("../utils/normalizeListeners.js"); */
6729
6730 ;
6731 /* removed: var _$window_84 = require("../utils/window.js"); */
6732
6733 ;
6734 /* removed: var _$Eventable_16 = require("./Eventable.js"); */
6735
6736 ;
6737 /* removed: var _$isNonNativeEvent_28 = require("./isNonNativeEvent.js"); */
6738
6739 ;
6740
6741 function ___classCallCheck_18(instance, Constructor) {
6742 if (!(instance instanceof Constructor)) {
6743 throw new TypeError("Cannot call a class as a function");
6744 }
6745 }
6746
6747 function ___defineProperties_18(target, props) {
6748 for (var i = 0; i < props.length; i++) {
6749 var descriptor = props[i];
6750 descriptor.enumerable = descriptor.enumerable || false;
6751 descriptor.configurable = true;
6752 if ("value" in descriptor) descriptor.writable = true;
6753 Object.defineProperty(target, descriptor.key, descriptor);
6754 }
6755 }
6756
6757 function ___createClass_18(Constructor, protoProps, staticProps) {
6758 if (protoProps) ___defineProperties_18(Constructor.prototype, protoProps);
6759 if (staticProps) ___defineProperties_18(Constructor, staticProps);
6760 return Constructor;
6761 }
6762 /** */
6763
6764
6765 var Interactable = /*#__PURE__*/function () {
6766 ___createClass_18(Interactable, [{
6767 key: "_defaults",
6768
6769 /** @internal */
6770 get: function get() {
6771 return {
6772 base: {},
6773 perAction: {},
6774 actions: {}
6775 };
6776 }
6777 /** */
6778
6779 }]);
6780
6781 function Interactable(target, options, defaultContext, scopeEvents) {
6782 ___classCallCheck_18(this, Interactable);
6783
6784 this.options = void 0;
6785 this._actions = void 0;
6786 this.target = void 0;
6787 this.events = new _$Eventable_16.Eventable();
6788 this._context = void 0;
6789 this._win = void 0;
6790 this._doc = void 0;
6791 this._scopeEvents = void 0;
6792 this._rectChecker = void 0;
6793 this._actions = options.actions;
6794 this.target = target;
6795 this._context = options.context || defaultContext;
6796 this._win = (0, _$window_84.getWindow)((0, _$domUtils_71.trySelector)(target) ? this._context : target);
6797 this._doc = this._win.document;
6798 this._scopeEvents = scopeEvents;
6799 this.set(options);
6800 }
6801
6802 ___createClass_18(Interactable, [{
6803 key: "setOnEvents",
6804 value: function setOnEvents(actionName, phases) {
6805 if (_$is_76["default"].func(phases.onstart)) {
6806 this.on("".concat(actionName, "start"), phases.onstart);
6807 }
6808
6809 if (_$is_76["default"].func(phases.onmove)) {
6810 this.on("".concat(actionName, "move"), phases.onmove);
6811 }
6812
6813 if (_$is_76["default"].func(phases.onend)) {
6814 this.on("".concat(actionName, "end"), phases.onend);
6815 }
6816
6817 if (_$is_76["default"].func(phases.oninertiastart)) {
6818 this.on("".concat(actionName, "inertiastart"), phases.oninertiastart);
6819 }
6820
6821 return this;
6822 }
6823 }, {
6824 key: "updatePerActionListeners",
6825 value: function updatePerActionListeners(actionName, prev, cur) {
6826 if (_$is_76["default"].array(prev) || _$is_76["default"].object(prev)) {
6827 this.off(actionName, prev);
6828 }
6829
6830 if (_$is_76["default"].array(cur) || _$is_76["default"].object(cur)) {
6831 this.on(actionName, cur);
6832 }
6833 }
6834 }, {
6835 key: "setPerAction",
6836 value: function setPerAction(actionName, options) {
6837 var defaults = this._defaults; // for all the default per-action options
6838
6839 for (var optionName_ in options) {
6840 var optionName = optionName_;
6841 var actionOptions = this.options[actionName];
6842 var optionValue = options[optionName]; // remove old event listeners and add new ones
6843
6844 if (optionName === 'listeners') {
6845 this.updatePerActionListeners(actionName, actionOptions.listeners, optionValue);
6846 } // if the option value is an array
6847
6848
6849 if (_$is_76["default"].array(optionValue)) {
6850 actionOptions[optionName] = _$arr_66.from(optionValue);
6851 } // if the option value is an object
6852 else if (_$is_76["default"].plainObject(optionValue)) {
6853 // copy the object
6854 actionOptions[optionName] = (0, _$extend_73["default"])(actionOptions[optionName] || {}, (0, _$clone_68["default"])(optionValue)); // set anabled field to true if it exists in the defaults
6855
6856 if (_$is_76["default"].object(defaults.perAction[optionName]) && 'enabled' in defaults.perAction[optionName]) {
6857 actionOptions[optionName].enabled = optionValue.enabled !== false;
6858 }
6859 } // if the option value is a boolean and the default is an object
6860 else if (_$is_76["default"].bool(optionValue) && _$is_76["default"].object(defaults.perAction[optionName])) {
6861 actionOptions[optionName].enabled = optionValue;
6862 } // if it's anything else, do a plain assignment
6863 else {
6864 actionOptions[optionName] = optionValue;
6865 }
6866 }
6867 }
6868 /**
6869 * The default function to get an Interactables bounding rect. Can be
6870 * overridden using {@link Interactable.rectChecker}.
6871 *
6872 * @param {Element} [element] The element to measure.
6873 * @return {Interact.Rect} The object's bounding rectangle.
6874 */
6875
6876 }, {
6877 key: "getRect",
6878 value: function getRect(element) {
6879 element = element || (_$is_76["default"].element(this.target) ? this.target : null);
6880
6881 if (_$is_76["default"].string(this.target)) {
6882 element = element || this._context.querySelector(this.target);
6883 }
6884
6885 return (0, _$domUtils_71.getElementRect)(element);
6886 }
6887 /**
6888 * Returns or sets the function used to calculate the interactable's
6889 * element's rectangle
6890 *
6891 * @param {function} [checker] A function which returns this Interactable's
6892 * bounding rectangle. See {@link Interactable.getRect}
6893 * @return {function | object} The checker function or this Interactable
6894 */
6895
6896 }, {
6897 key: "rectChecker",
6898 value: function rectChecker(checker) {
6899 var _this = this;
6900
6901 if (_$is_76["default"].func(checker)) {
6902 this._rectChecker = checker;
6903
6904 this.getRect = function (element) {
6905 var rect = (0, _$extend_73["default"])({}, _this._rectChecker(element));
6906
6907 if (!('width' in rect)) {
6908 rect.width = rect.right - rect.left;
6909 rect.height = rect.bottom - rect.top;
6910 }
6911
6912 return rect;
6913 };
6914
6915 return this;
6916 }
6917
6918 if (checker === null) {
6919 delete this.getRect;
6920 delete this._rectChecker;
6921 return this;
6922 }
6923
6924 return this.getRect;
6925 }
6926 }, {
6927 key: "_backCompatOption",
6928 value: function _backCompatOption(optionName, newValue) {
6929 if ((0, _$domUtils_71.trySelector)(newValue) || _$is_76["default"].object(newValue)) {
6930 this.options[optionName] = newValue;
6931
6932 for (var action in this._actions.map) {
6933 this.options[action][optionName] = newValue;
6934 }
6935
6936 return this;
6937 }
6938
6939 return this.options[optionName];
6940 }
6941 /**
6942 * Gets or sets the origin of the Interactable's element. The x and y
6943 * of the origin will be subtracted from action event coordinates.
6944 *
6945 * @param {Element | object | string} [origin] An HTML or SVG Element whose
6946 * rect will be used, an object eg. { x: 0, y: 0 } or string 'parent', 'self'
6947 * or any CSS selector
6948 *
6949 * @return {object} The current origin or this Interactable
6950 */
6951
6952 }, {
6953 key: "origin",
6954 value: function origin(newValue) {
6955 return this._backCompatOption('origin', newValue);
6956 }
6957 /**
6958 * Returns or sets the mouse coordinate types used to calculate the
6959 * movement of the pointer.
6960 *
6961 * @param {string} [newValue] Use 'client' if you will be scrolling while
6962 * interacting; Use 'page' if you want autoScroll to work
6963 * @return {string | object} The current deltaSource or this Interactable
6964 */
6965
6966 }, {
6967 key: "deltaSource",
6968 value: function deltaSource(newValue) {
6969 if (newValue === 'page' || newValue === 'client') {
6970 this.options.deltaSource = newValue;
6971 return this;
6972 }
6973
6974 return this.options.deltaSource;
6975 }
6976 /**
6977 * Gets the selector context Node of the Interactable. The default is
6978 * `window.document`.
6979 *
6980 * @return {Node} The context Node of this Interactable
6981 */
6982
6983 }, {
6984 key: "context",
6985 value: function context() {
6986 return this._context;
6987 }
6988 }, {
6989 key: "inContext",
6990 value: function inContext(element) {
6991 return this._context === element.ownerDocument || (0, _$domUtils_71.nodeContains)(this._context, element);
6992 }
6993 }, {
6994 key: "testIgnoreAllow",
6995 value: function testIgnoreAllow(options, targetNode, eventTarget) {
6996 return !this.testIgnore(options.ignoreFrom, targetNode, eventTarget) && this.testAllow(options.allowFrom, targetNode, eventTarget);
6997 }
6998 }, {
6999 key: "testAllow",
7000 value: function testAllow(allowFrom, targetNode, element) {
7001 if (!allowFrom) {
7002 return true;
7003 }
7004
7005 if (!_$is_76["default"].element(element)) {
7006 return false;
7007 }
7008
7009 if (_$is_76["default"].string(allowFrom)) {
7010 return (0, _$domUtils_71.matchesUpTo)(element, allowFrom, targetNode);
7011 } else if (_$is_76["default"].element(allowFrom)) {
7012 return (0, _$domUtils_71.nodeContains)(allowFrom, element);
7013 }
7014
7015 return false;
7016 }
7017 }, {
7018 key: "testIgnore",
7019 value: function testIgnore(ignoreFrom, targetNode, element) {
7020 if (!ignoreFrom || !_$is_76["default"].element(element)) {
7021 return false;
7022 }
7023
7024 if (_$is_76["default"].string(ignoreFrom)) {
7025 return (0, _$domUtils_71.matchesUpTo)(element, ignoreFrom, targetNode);
7026 } else if (_$is_76["default"].element(ignoreFrom)) {
7027 return (0, _$domUtils_71.nodeContains)(ignoreFrom, element);
7028 }
7029
7030 return false;
7031 }
7032 /**
7033 * Calls listeners for the given InteractEvent type bound globally
7034 * and directly to this Interactable
7035 *
7036 * @param {InteractEvent} iEvent The InteractEvent object to be fired on this
7037 * Interactable
7038 * @return {Interactable} this Interactable
7039 */
7040
7041 }, {
7042 key: "fire",
7043 value: function fire(iEvent) {
7044 this.events.fire(iEvent);
7045 return this;
7046 }
7047 }, {
7048 key: "_onOff",
7049 value: function _onOff(method, typeArg, listenerArg, options) {
7050 if (_$is_76["default"].object(typeArg) && !_$is_76["default"].array(typeArg)) {
7051 options = listenerArg;
7052 listenerArg = null;
7053 }
7054
7055 var addRemove = method === 'on' ? 'add' : 'remove';
7056 var listeners = (0, _$normalizeListeners_79["default"])(typeArg, listenerArg);
7057
7058 for (var type in listeners) {
7059 if (type === 'wheel') {
7060 type = _$browser_67["default"].wheelEvent;
7061 }
7062
7063 for (var _i = 0; _i < listeners[type].length; _i++) {
7064 var _ref;
7065
7066 _ref = listeners[type][_i];
7067 var listener = _ref; // if it is an action event type
7068
7069 if ((0, _$isNonNativeEvent_28["default"])(type, this._actions)) {
7070 this.events[method](type, listener);
7071 } // delegated event
7072 else if (_$is_76["default"].string(this.target)) {
7073 this._scopeEvents["".concat(addRemove, "Delegate")](this.target, this._context, type, listener, options);
7074 } // remove listener from this Interactable's element
7075 else {
7076 this._scopeEvents[addRemove](this.target, type, listener, options);
7077 }
7078 }
7079 }
7080
7081 return this;
7082 }
7083 /**
7084 * Binds a listener for an InteractEvent, pointerEvent or DOM event.
7085 *
7086 * @param {string | array | object} types The types of events to listen
7087 * for
7088 * @param {function | array | object} [listener] The event listener function(s)
7089 * @param {object | boolean} [options] options object or useCapture flag for
7090 * addEventListener
7091 * @return {Interactable} This Interactable
7092 */
7093
7094 }, {
7095 key: "on",
7096 value: function on(types, listener, options) {
7097 return this._onOff('on', types, listener, options);
7098 }
7099 /**
7100 * Removes an InteractEvent, pointerEvent or DOM event listener.
7101 *
7102 * @param {string | array | object} types The types of events that were
7103 * listened for
7104 * @param {function | array | object} [listener] The event listener function(s)
7105 * @param {object | boolean} [options] options object or useCapture flag for
7106 * removeEventListener
7107 * @return {Interactable} This Interactable
7108 */
7109
7110 }, {
7111 key: "off",
7112 value: function off(types, listener, options) {
7113 return this._onOff('off', types, listener, options);
7114 }
7115 /**
7116 * Reset the options of this Interactable
7117 *
7118 * @param {object} options The new settings to apply
7119 * @return {object} This Interactable
7120 */
7121
7122 }, {
7123 key: "set",
7124 value: function set(options) {
7125 var defaults = this._defaults;
7126
7127 if (!_$is_76["default"].object(options)) {
7128 options = {};
7129 }
7130
7131 this.options = (0, _$clone_68["default"])(defaults.base);
7132
7133 for (var actionName_ in this._actions.methodDict) {
7134 var actionName = actionName_;
7135 var methodName = this._actions.methodDict[actionName];
7136 this.options[actionName] = {};
7137 this.setPerAction(actionName, (0, _$extend_73["default"])((0, _$extend_73["default"])({}, defaults.perAction), defaults.actions[actionName]));
7138 this[methodName](options[actionName]);
7139 }
7140
7141 for (var setting in options) {
7142 if (_$is_76["default"].func(this[setting])) {
7143 this[setting](options[setting]);
7144 }
7145 }
7146
7147 return this;
7148 }
7149 /**
7150 * Remove this interactable from the list of interactables and remove it's
7151 * action capabilities and event listeners
7152 */
7153
7154 }, {
7155 key: "unset",
7156 value: function unset() {
7157 if (_$is_76["default"].string(this.target)) {
7158 // remove delegated events
7159 for (var type in this._scopeEvents.delegatedEvents) {
7160 var delegated = this._scopeEvents.delegatedEvents[type];
7161
7162 for (var i = delegated.length - 1; i >= 0; i--) {
7163 var _delegated$i = delegated[i],
7164 selector = _delegated$i.selector,
7165 context = _delegated$i.context,
7166 listeners = _delegated$i.listeners;
7167
7168 if (selector === this.target && context === this._context) {
7169 delegated.splice(i, 1);
7170 }
7171
7172 for (var l = listeners.length - 1; l >= 0; l--) {
7173 this._scopeEvents.removeDelegate(this.target, this._context, type, listeners[l][0], listeners[l][1]);
7174 }
7175 }
7176 }
7177 } else {
7178 this._scopeEvents.remove(this.target, 'all');
7179 }
7180 }
7181 }]);
7182
7183 return Interactable;
7184 }();
7185
7186 _$Interactable_18.Interactable = Interactable;
7187 var _$InteractableSet_19 = {};
7188 "use strict";
7189
7190 Object.defineProperty(_$InteractableSet_19, "__esModule", {
7191 value: true
7192 });
7193 _$InteractableSet_19.InteractableSet = void 0;
7194 /* removed: var _$arr_66 = require("../utils/arr.js"); */
7195
7196 ;
7197 /* removed: var _$domUtils_71 = require("../utils/domUtils.js"); */
7198
7199 ;
7200 /* removed: var _$extend_73 = require("../utils/extend.js"); */
7201
7202 ;
7203 /* removed: var _$is_76 = require("../utils/is.js"); */
7204
7205 ;
7206
7207 function ___classCallCheck_19(instance, Constructor) {
7208 if (!(instance instanceof Constructor)) {
7209 throw new TypeError("Cannot call a class as a function");
7210 }
7211 }
7212
7213 function ___defineProperties_19(target, props) {
7214 for (var i = 0; i < props.length; i++) {
7215 var descriptor = props[i];
7216 descriptor.enumerable = descriptor.enumerable || false;
7217 descriptor.configurable = true;
7218 if ("value" in descriptor) descriptor.writable = true;
7219 Object.defineProperty(target, descriptor.key, descriptor);
7220 }
7221 }
7222
7223 function ___createClass_19(Constructor, protoProps, staticProps) {
7224 if (protoProps) ___defineProperties_19(Constructor.prototype, protoProps);
7225 if (staticProps) ___defineProperties_19(Constructor, staticProps);
7226 return Constructor;
7227 }
7228
7229 var InteractableSet = /*#__PURE__*/function () {
7230 // all set interactables
7231 function InteractableSet(scope) {
7232 var _this = this;
7233
7234 ___classCallCheck_19(this, InteractableSet);
7235
7236 this.list = [];
7237 this.selectorMap = {};
7238 this.scope = void 0;
7239 this.scope = scope;
7240 scope.addListeners({
7241 'interactable:unset': function interactableUnset(_ref) {
7242 var interactable = _ref.interactable;
7243 var target = interactable.target,
7244 context = interactable._context;
7245 var targetMappings = _$is_76["default"].string(target) ? _this.selectorMap[target] : target[_this.scope.id];
7246 var targetIndex = targetMappings.findIndex(function (m) {
7247 return m.context === context;
7248 });
7249
7250 if (targetMappings[targetIndex]) {
7251 // Destroying mappingInfo's context and interactable
7252 targetMappings[targetIndex].context = null;
7253 targetMappings[targetIndex].interactable = null;
7254 }
7255
7256 targetMappings.splice(targetIndex, 1);
7257 }
7258 });
7259 }
7260
7261 ___createClass_19(InteractableSet, [{
7262 key: "new",
7263 value: function _new(target, options) {
7264 options = (0, _$extend_73["default"])(options || {}, {
7265 actions: this.scope.actions
7266 });
7267 var interactable = new this.scope.Interactable(target, options, this.scope.document, this.scope.events);
7268 var mappingInfo = {
7269 context: interactable._context,
7270 interactable: interactable
7271 };
7272 this.scope.addDocument(interactable._doc);
7273 this.list.push(interactable);
7274
7275 if (_$is_76["default"].string(target)) {
7276 if (!this.selectorMap[target]) {
7277 this.selectorMap[target] = [];
7278 }
7279
7280 this.selectorMap[target].push(mappingInfo);
7281 } else {
7282 if (!interactable.target[this.scope.id]) {
7283 Object.defineProperty(target, this.scope.id, {
7284 value: [],
7285 configurable: true
7286 });
7287 }
7288
7289 target[this.scope.id].push(mappingInfo);
7290 }
7291
7292 this.scope.fire('interactable:new', {
7293 target: target,
7294 options: options,
7295 interactable: interactable,
7296 win: this.scope._win
7297 });
7298 return interactable;
7299 }
7300 }, {
7301 key: "get",
7302 value: function get(target, options) {
7303 var context = options && options.context || this.scope.document;
7304
7305 var isSelector = _$is_76["default"].string(target);
7306
7307 var targetMappings = isSelector ? this.selectorMap[target] : target[this.scope.id];
7308
7309 if (!targetMappings) {
7310 return null;
7311 }
7312
7313 var found = _$arr_66.find(targetMappings, function (m) {
7314 return m.context === context && (isSelector || m.interactable.inContext(target));
7315 });
7316
7317 return found && found.interactable;
7318 }
7319 }, {
7320 key: "forEachMatch",
7321 value: function forEachMatch(node, callback) {
7322 for (var _i = 0; _i < this.list.length; _i++) {
7323 var _ref2;
7324
7325 _ref2 = this.list[_i];
7326 var interactable = _ref2;
7327 var ret = void 0;
7328
7329 if ((_$is_76["default"].string(interactable.target) // target is a selector and the element matches
7330 ? _$is_76["default"].element(node) && _$domUtils_71.matchesSelector(node, interactable.target) : // target is the element
7331 node === interactable.target) && // the element is in context
7332 interactable.inContext(node)) {
7333 ret = callback(interactable);
7334 }
7335
7336 if (ret !== undefined) {
7337 return ret;
7338 }
7339 }
7340 }
7341 }]);
7342
7343 return InteractableSet;
7344 }();
7345
7346 _$InteractableSet_19.InteractableSet = InteractableSet;
7347 var _$events_23 = {};
7348 "use strict";
7349
7350 Object.defineProperty(_$events_23, "__esModule", {
7351 value: true
7352 });
7353 _$events_23["default"] = _$events_23.FakeEvent = void 0;
7354 /* removed: var _$arr_66 = require("../utils/arr.js"); */
7355
7356 ;
7357 /* removed: var _$domUtils_71 = require("../utils/domUtils.js"); */
7358
7359 ;
7360 /* removed: var _$extend_73 = require("../utils/extend.js"); */
7361
7362 ;
7363 /* removed: var _$is_76 = require("../utils/is.js"); */
7364
7365 ;
7366 /* removed: var _$pointerExtend_80 = require("../utils/pointerExtend.js"); */
7367
7368 ;
7369 /* removed: var _$pointerUtils_81 = require("../utils/pointerUtils.js"); */
7370
7371 ;
7372
7373 function ___classCallCheck_23(instance, Constructor) {
7374 if (!(instance instanceof Constructor)) {
7375 throw new TypeError("Cannot call a class as a function");
7376 }
7377 }
7378
7379 function ___defineProperties_23(target, props) {
7380 for (var i = 0; i < props.length; i++) {
7381 var descriptor = props[i];
7382 descriptor.enumerable = descriptor.enumerable || false;
7383 descriptor.configurable = true;
7384 if ("value" in descriptor) descriptor.writable = true;
7385 Object.defineProperty(target, descriptor.key, descriptor);
7386 }
7387 }
7388
7389 function ___createClass_23(Constructor, protoProps, staticProps) {
7390 if (protoProps) ___defineProperties_23(Constructor.prototype, protoProps);
7391 if (staticProps) ___defineProperties_23(Constructor, staticProps);
7392 return Constructor;
7393 }
7394
7395 function ___slicedToArray_23(arr, i) {
7396 return ___arrayWithHoles_23(arr) || ___iterableToArrayLimit_23(arr, i) || ___unsupportedIterableToArray_23(arr, i) || ___nonIterableRest_23();
7397 }
7398
7399 function ___nonIterableRest_23() {
7400 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
7401 }
7402
7403 function ___unsupportedIterableToArray_23(o, minLen) {
7404 if (!o) return;
7405 if (typeof o === "string") return ___arrayLikeToArray_23(o, minLen);
7406 var n = Object.prototype.toString.call(o).slice(8, -1);
7407 if (n === "Object" && o.constructor) n = o.constructor.name;
7408 if (n === "Map" || n === "Set") return Array.from(o);
7409 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return ___arrayLikeToArray_23(o, minLen);
7410 }
7411
7412 function ___arrayLikeToArray_23(arr, len) {
7413 if (len == null || len > arr.length) len = arr.length;
7414
7415 for (var i = 0, arr2 = new Array(len); i < len; i++) {
7416 arr2[i] = arr[i];
7417 }
7418
7419 return arr2;
7420 }
7421
7422 function ___iterableToArrayLimit_23(arr, i) {
7423 if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
7424 var _arr = [];
7425 var _n = true;
7426 var _d = false;
7427 var _e = undefined;
7428
7429 try {
7430 for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
7431 _arr.push(_s.value);
7432
7433 if (i && _arr.length === i) break;
7434 }
7435 } catch (err) {
7436 _d = true;
7437 _e = err;
7438 } finally {
7439 try {
7440 if (!_n && _i["return"] != null) _i["return"]();
7441 } finally {
7442 if (_d) throw _e;
7443 }
7444 }
7445
7446 return _arr;
7447 }
7448
7449 function ___arrayWithHoles_23(arr) {
7450 if (Array.isArray(arr)) return arr;
7451 }
7452
7453 function __install_23(scope) {
7454 var targets = [];
7455 var delegatedEvents = {};
7456 var documents = [];
7457 var eventsMethods = {
7458 add: add,
7459 remove: remove,
7460 addDelegate: addDelegate,
7461 removeDelegate: removeDelegate,
7462 delegateListener: delegateListener,
7463 delegateUseCapture: delegateUseCapture,
7464 delegatedEvents: delegatedEvents,
7465 documents: documents,
7466 targets: targets,
7467 supportsOptions: false,
7468 supportsPassive: false
7469 }; // check if browser supports passive events and options arg
7470
7471 scope.document.createElement('div').addEventListener('test', null, {
7472 get capture() {
7473 return eventsMethods.supportsOptions = true;
7474 },
7475
7476 get passive() {
7477 return eventsMethods.supportsPassive = true;
7478 }
7479
7480 });
7481 scope.events = eventsMethods;
7482
7483 function add(eventTarget, type, listener, optionalArg) {
7484 var options = __getOptions_23(optionalArg);
7485
7486 var target = _$arr_66.find(targets, function (t) {
7487 return t.eventTarget === eventTarget;
7488 });
7489
7490 if (!target) {
7491 target = {
7492 eventTarget: eventTarget,
7493 events: {}
7494 };
7495 targets.push(target);
7496 }
7497
7498 if (!target.events[type]) {
7499 target.events[type] = [];
7500 }
7501
7502 if (eventTarget.addEventListener && !_$arr_66.contains(target.events[type], listener)) {
7503 eventTarget.addEventListener(type, listener, eventsMethods.supportsOptions ? options : options.capture);
7504 target.events[type].push(listener);
7505 }
7506 }
7507
7508 function remove(eventTarget, type, listener, optionalArg) {
7509 var options = __getOptions_23(optionalArg);
7510
7511 var targetIndex = _$arr_66.findIndex(targets, function (t) {
7512 return t.eventTarget === eventTarget;
7513 });
7514
7515 var target = targets[targetIndex];
7516
7517 if (!target || !target.events) {
7518 return;
7519 }
7520
7521 if (type === 'all') {
7522 for (type in target.events) {
7523 if (target.events.hasOwnProperty(type)) {
7524 remove(eventTarget, type, 'all');
7525 }
7526 }
7527
7528 return;
7529 }
7530
7531 var typeIsEmpty = false;
7532 var typeListeners = target.events[type];
7533
7534 if (typeListeners) {
7535 if (listener === 'all') {
7536 for (var i = typeListeners.length - 1; i >= 0; i--) {
7537 remove(eventTarget, type, typeListeners[i], options);
7538 }
7539
7540 return;
7541 } else {
7542 for (var _i = 0; _i < typeListeners.length; _i++) {
7543 if (typeListeners[_i] === listener) {
7544 eventTarget.removeEventListener(type, listener, eventsMethods.supportsOptions ? options : options.capture);
7545 typeListeners.splice(_i, 1);
7546
7547 if (typeListeners.length === 0) {
7548 delete target.events[type];
7549 typeIsEmpty = true;
7550 }
7551
7552 break;
7553 }
7554 }
7555 }
7556 }
7557
7558 if (typeIsEmpty && !Object.keys(target.events).length) {
7559 targets.splice(targetIndex, 1);
7560 }
7561 }
7562
7563 function addDelegate(selector, context, type, listener, optionalArg) {
7564 var options = __getOptions_23(optionalArg);
7565
7566 if (!delegatedEvents[type]) {
7567 delegatedEvents[type] = []; // add delegate listener functions
7568
7569 for (var _i2 = 0; _i2 < documents.length; _i2++) {
7570 var _ref;
7571
7572 _ref = documents[_i2];
7573 var doc = _ref;
7574 add(doc, type, delegateListener);
7575 add(doc, type, delegateUseCapture, true);
7576 }
7577 }
7578
7579 var delegates = delegatedEvents[type];
7580
7581 var delegate = _$arr_66.find(delegates, function (d) {
7582 return d.selector === selector && d.context === context;
7583 });
7584
7585 if (!delegate) {
7586 delegate = {
7587 selector: selector,
7588 context: context,
7589 listeners: []
7590 };
7591 delegates.push(delegate);
7592 }
7593
7594 delegate.listeners.push([listener, options]);
7595 }
7596
7597 function removeDelegate(selector, context, type, listener, optionalArg) {
7598 var options = __getOptions_23(optionalArg);
7599
7600 var delegates = delegatedEvents[type];
7601 var matchFound = false;
7602 var index;
7603
7604 if (!delegates) {
7605 return;
7606 } // count from last index of delegated to 0
7607
7608
7609 for (index = delegates.length - 1; index >= 0; index--) {
7610 var cur = delegates[index]; // look for matching selector and context Node
7611
7612 if (cur.selector === selector && cur.context === context) {
7613 var listeners = cur.listeners; // each item of the listeners array is an array: [function, capture, passive]
7614
7615 for (var i = listeners.length - 1; i >= 0; i--) {
7616 var _listeners$i = ___slicedToArray_23(listeners[i], 2),
7617 fn = _listeners$i[0],
7618 _listeners$i$ = _listeners$i[1],
7619 capture = _listeners$i$.capture,
7620 passive = _listeners$i$.passive; // check if the listener functions and capture and passive flags match
7621
7622
7623 if (fn === listener && capture === options.capture && passive === options.passive) {
7624 // remove the listener from the array of listeners
7625 listeners.splice(i, 1); // if all listeners for this target have been removed
7626 // remove the target from the delegates array
7627
7628 if (!listeners.length) {
7629 delegates.splice(index, 1); // remove delegate function from context
7630
7631 remove(context, type, delegateListener);
7632 remove(context, type, delegateUseCapture, true);
7633 } // only remove one listener
7634
7635
7636 matchFound = true;
7637 break;
7638 }
7639 }
7640
7641 if (matchFound) {
7642 break;
7643 }
7644 }
7645 }
7646 } // bound to the interactable context when a DOM event
7647 // listener is added to a selector interactable
7648
7649
7650 function delegateListener(event, optionalArg) {
7651 var options = __getOptions_23(optionalArg);
7652
7653 var fakeEvent = new FakeEvent(event);
7654 var delegates = delegatedEvents[event.type];
7655
7656 var _pointerUtils$getEven = _$pointerUtils_81.getEventTargets(event),
7657 _pointerUtils$getEven2 = ___slicedToArray_23(_pointerUtils$getEven, 1),
7658 eventTarget = _pointerUtils$getEven2[0];
7659
7660 var element = eventTarget; // climb up document tree looking for selector matches
7661
7662 while (_$is_76["default"].element(element)) {
7663 for (var i = 0; i < delegates.length; i++) {
7664 var cur = delegates[i];
7665 var selector = cur.selector,
7666 context = cur.context;
7667
7668 if (_$domUtils_71.matchesSelector(element, selector) && _$domUtils_71.nodeContains(context, eventTarget) && _$domUtils_71.nodeContains(context, element)) {
7669 var listeners = cur.listeners;
7670 fakeEvent.currentTarget = element;
7671
7672 for (var _i3 = 0; _i3 < listeners.length; _i3++) {
7673 var _ref2;
7674
7675 _ref2 = listeners[_i3];
7676
7677 var _ref3 = _ref2,
7678 _ref4 = ___slicedToArray_23(_ref3, 2),
7679 fn = _ref4[0],
7680 _ref4$ = _ref4[1],
7681 capture = _ref4$.capture,
7682 passive = _ref4$.passive;
7683
7684 if (capture === options.capture && passive === options.passive) {
7685 fn(fakeEvent);
7686 }
7687 }
7688 }
7689 }
7690
7691 element = _$domUtils_71.parentNode(element);
7692 }
7693 }
7694
7695 function delegateUseCapture(event) {
7696 return delegateListener.call(this, event, true);
7697 } // for type inferrence
7698
7699
7700 return eventsMethods;
7701 }
7702
7703 var FakeEvent = /*#__PURE__*/function () {
7704 function FakeEvent(originalEvent) {
7705 ___classCallCheck_23(this, FakeEvent);
7706
7707 this.currentTarget = void 0;
7708 this.originalEvent = void 0;
7709 this.originalEvent = originalEvent; // duplicate the event so that currentTarget can be changed
7710
7711 (0, _$pointerExtend_80["default"])(this, originalEvent);
7712 }
7713
7714 ___createClass_23(FakeEvent, [{
7715 key: "preventOriginalDefault",
7716 value: function preventOriginalDefault() {
7717 this.originalEvent.preventDefault();
7718 }
7719 }, {
7720 key: "stopPropagation",
7721 value: function stopPropagation() {
7722 this.originalEvent.stopPropagation();
7723 }
7724 }, {
7725 key: "stopImmediatePropagation",
7726 value: function stopImmediatePropagation() {
7727 this.originalEvent.stopImmediatePropagation();
7728 }
7729 }]);
7730
7731 return FakeEvent;
7732 }();
7733
7734 _$events_23.FakeEvent = FakeEvent;
7735
7736 function __getOptions_23(param) {
7737 if (!_$is_76["default"].object(param)) {
7738 return {
7739 capture: !!param,
7740 passive: false
7741 };
7742 }
7743
7744 var options = (0, _$extend_73["default"])({}, param);
7745 options.capture = !!param.capture;
7746 options.passive = !!param.passive;
7747 return options;
7748 }
7749
7750 var ___default_23 = {
7751 id: 'events',
7752 install: __install_23
7753 };
7754 _$events_23["default"] = ___default_23;
7755 var _$interactStatic_24 = {};
7756 "use strict";
7757
7758 Object.defineProperty(_$interactStatic_24, "__esModule", {
7759 value: true
7760 });
7761 _$interactStatic_24.createInteractStatic = createInteractStatic;
7762 /* removed: var _$browser_67 = require("../utils/browser.js"); */
7763
7764 ;
7765 /* removed: var _$domUtils_71 = require("../utils/domUtils.js"); */
7766
7767 ;
7768 /* removed: var _$is_76 = require("../utils/is.js"); */
7769
7770 ;
7771 /* removed: var _$pointerUtils_81 = require("../utils/pointerUtils.js"); */
7772
7773 ;
7774 /* removed: var _$isNonNativeEvent_28 = require("./isNonNativeEvent.js"); */
7775
7776 ;
7777 /** @module interact */
7778
7779 function createInteractStatic(scope) {
7780 /**
7781 * ```js
7782 * interact('#draggable').draggable(true)
7783 *
7784 * var rectables = interact('rect')
7785 * rectables
7786 * .gesturable(true)
7787 * .on('gesturemove', function (event) {
7788 * // ...
7789 * })
7790 * ```
7791 *
7792 * The methods of this variable can be used to set elements as interactables
7793 * and also to change various default settings.
7794 *
7795 * Calling it as a function and passing an element or a valid CSS selector
7796 * string returns an Interactable object which has various methods to configure
7797 * it.
7798 *
7799 * @global
7800 *
7801 * @param {Element | string} target The HTML or SVG Element to interact with
7802 * or CSS selector
7803 * @return {Interactable}
7804 */
7805 var interact = function interact(target, options) {
7806 var interactable = scope.interactables.get(target, options);
7807
7808 if (!interactable) {
7809 interactable = scope.interactables["new"](target, options);
7810 interactable.events.global = interact.globalEvents;
7811 }
7812
7813 return interactable;
7814 }; // expose the functions used to calculate multi-touch properties
7815
7816
7817 interact.getPointerAverage = _$pointerUtils_81.pointerAverage;
7818 interact.getTouchBBox = _$pointerUtils_81.touchBBox;
7819 interact.getTouchDistance = _$pointerUtils_81.touchDistance;
7820 interact.getTouchAngle = _$pointerUtils_81.touchAngle;
7821 interact.getElementRect = _$domUtils_71.getElementRect;
7822 interact.getElementClientRect = _$domUtils_71.getElementClientRect;
7823 interact.matchesSelector = _$domUtils_71.matchesSelector;
7824 interact.closest = _$domUtils_71.closest;
7825 interact.globalEvents = {}; // eslint-disable-next-line no-undef
7826
7827 interact.version = undefined;
7828 interact.scope = scope;
7829 /**
7830 * Use a plugin
7831 *
7832 * @alias module:interact.use
7833 *
7834 * @param {Object} plugin
7835 * @param {function} plugin.install
7836 * @return {Interact.InteractStatic}
7837 */
7838
7839 interact.use = function (plugin, options) {
7840 this.scope.usePlugin(plugin, options);
7841 return this;
7842 };
7843 /**
7844 * Check if an element or selector has been set with the {@link interact}
7845 * function
7846 *
7847 * @alias module:interact.isSet
7848 *
7849 * @param {Element} element The Element being searched for
7850 * @return {boolean} Indicates if the element or CSS selector was previously
7851 * passed to interact
7852 */
7853
7854
7855 interact.isSet = function (target, options) {
7856 return !!this.scope.interactables.get(target, options && options.context);
7857 };
7858 /**
7859 * Add a global listener for an InteractEvent or adds a DOM event to `document`
7860 *
7861 * @alias module:interact.on
7862 *
7863 * @param {string | array | object} type The types of events to listen for
7864 * @param {function} listener The function event (s)
7865 * @param {object | boolean} [options] object or useCapture flag for
7866 * addEventListener
7867 * @return {object} interact
7868 */
7869
7870
7871 interact.on = function (type, listener, options) {
7872 if (_$is_76["default"].string(type) && type.search(' ') !== -1) {
7873 type = type.trim().split(/ +/);
7874 }
7875
7876 if (_$is_76["default"].array(type)) {
7877 for (var _i = 0; _i < type.length; _i++) {
7878 var _ref;
7879
7880 _ref = type[_i];
7881 var eventType = _ref;
7882 this.on(eventType, listener, options);
7883 }
7884
7885 return this;
7886 }
7887
7888 if (_$is_76["default"].object(type)) {
7889 for (var prop in type) {
7890 this.on(prop, type[prop], listener);
7891 }
7892
7893 return this;
7894 } // if it is an InteractEvent type, add listener to globalEvents
7895
7896
7897 if ((0, _$isNonNativeEvent_28["default"])(type, this.scope.actions)) {
7898 // if this type of event was never bound
7899 if (!this.globalEvents[type]) {
7900 this.globalEvents[type] = [listener];
7901 } else {
7902 this.globalEvents[type].push(listener);
7903 }
7904 } // If non InteractEvent type, addEventListener to document
7905 else {
7906 this.scope.events.add(this.scope.document, type, listener, {
7907 options: options
7908 });
7909 }
7910
7911 return this;
7912 };
7913 /**
7914 * Removes a global InteractEvent listener or DOM event from `document`
7915 *
7916 * @alias module:interact.off
7917 *
7918 * @param {string | array | object} type The types of events that were listened
7919 * for
7920 * @param {function} listener The listener function to be removed
7921 * @param {object | boolean} options [options] object or useCapture flag for
7922 * removeEventListener
7923 * @return {object} interact
7924 */
7925
7926
7927 interact.off = function (type, listener, options) {
7928 if (_$is_76["default"].string(type) && type.search(' ') !== -1) {
7929 type = type.trim().split(/ +/);
7930 }
7931
7932 if (_$is_76["default"].array(type)) {
7933 for (var _i2 = 0; _i2 < type.length; _i2++) {
7934 var _ref2;
7935
7936 _ref2 = type[_i2];
7937 var eventType = _ref2;
7938 this.off(eventType, listener, options);
7939 }
7940
7941 return this;
7942 }
7943
7944 if (_$is_76["default"].object(type)) {
7945 for (var prop in type) {
7946 this.off(prop, type[prop], listener);
7947 }
7948
7949 return this;
7950 }
7951
7952 if ((0, _$isNonNativeEvent_28["default"])(type, this.scope.actions)) {
7953 var index;
7954
7955 if (type in this.globalEvents && (index = this.globalEvents[type].indexOf(listener)) !== -1) {
7956 this.globalEvents[type].splice(index, 1);
7957 }
7958 } else {
7959 this.scope.events.remove(this.scope.document, type, listener, options);
7960 }
7961
7962 return this;
7963 };
7964
7965 interact.debug = function () {
7966 return this.scope;
7967 };
7968 /**
7969 * @alias module:interact.supportsTouch
7970 *
7971 * @return {boolean} Whether or not the browser supports touch input
7972 */
7973
7974
7975 interact.supportsTouch = function () {
7976 return _$browser_67["default"].supportsTouch;
7977 };
7978 /**
7979 * @alias module:interact.supportsPointerEvent
7980 *
7981 * @return {boolean} Whether or not the browser supports PointerEvents
7982 */
7983
7984
7985 interact.supportsPointerEvent = function () {
7986 return _$browser_67["default"].supportsPointerEvent;
7987 };
7988 /**
7989 * Cancels all interactions (end events are not fired)
7990 *
7991 * @alias module:interact.stop
7992 *
7993 * @return {object} interact
7994 */
7995
7996
7997 interact.stop = function () {
7998 for (var _i3 = 0; _i3 < this.scope.interactions.list.length; _i3++) {
7999 var _ref3;
8000
8001 _ref3 = this.scope.interactions.list[_i3];
8002 var interaction = _ref3;
8003 interaction.stop();
8004 }
8005
8006 return this;
8007 };
8008 /**
8009 * Returns or sets the distance the pointer must be moved before an action
8010 * sequence occurs. This also affects tolerance for tap events.
8011 *
8012 * @alias module:interact.pointerMoveTolerance
8013 *
8014 * @param {number} [newValue] The movement from the start position must be greater than this value
8015 * @return {interact | number}
8016 */
8017
8018
8019 interact.pointerMoveTolerance = function (newValue) {
8020 if (_$is_76["default"].number(newValue)) {
8021 this.scope.interactions.pointerMoveTolerance = newValue;
8022 return this;
8023 }
8024
8025 return this.scope.interactions.pointerMoveTolerance;
8026 };
8027
8028 interact.addDocument = function (doc, options) {
8029 this.scope.addDocument(doc, options);
8030 };
8031
8032 interact.removeDocument = function (doc) {
8033 this.scope.removeDocument(doc);
8034 };
8035
8036 return interact;
8037 }
8038
8039 var _$interactionFinder_26 = {};
8040 "use strict";
8041
8042 Object.defineProperty(_$interactionFinder_26, "__esModule", {
8043 value: true
8044 });
8045 _$interactionFinder_26["default"] = void 0;
8046 /* removed: var _$domUtils_71 = require("../utils/domUtils.js"); */
8047
8048 ;
8049 var finder = {
8050 methodOrder: ['simulationResume', 'mouseOrPen', 'hasPointer', 'idle'],
8051 search: function search(details) {
8052 for (var _i = 0; _i < finder.methodOrder.length; _i++) {
8053 var _ref;
8054
8055 _ref = finder.methodOrder[_i];
8056 var method = _ref;
8057 var interaction = finder[method](details);
8058
8059 if (interaction) {
8060 return interaction;
8061 }
8062 }
8063
8064 return null;
8065 },
8066 // try to resume simulation with a new pointer
8067 simulationResume: function simulationResume(_ref2) {
8068 var pointerType = _ref2.pointerType,
8069 eventType = _ref2.eventType,
8070 eventTarget = _ref2.eventTarget,
8071 scope = _ref2.scope;
8072
8073 if (!/down|start/i.test(eventType)) {
8074 return null;
8075 }
8076
8077 for (var _i2 = 0; _i2 < scope.interactions.list.length; _i2++) {
8078 var _ref3;
8079
8080 _ref3 = scope.interactions.list[_i2];
8081 var interaction = _ref3;
8082 var element = eventTarget;
8083
8084 if (interaction.simulation && interaction.simulation.allowResume && interaction.pointerType === pointerType) {
8085 while (element) {
8086 // if the element is the interaction element
8087 if (element === interaction.element) {
8088 return interaction;
8089 }
8090
8091 element = _$domUtils_71.parentNode(element);
8092 }
8093 }
8094 }
8095
8096 return null;
8097 },
8098 // if it's a mouse or pen interaction
8099 mouseOrPen: function mouseOrPen(_ref4) {
8100 var pointerId = _ref4.pointerId,
8101 pointerType = _ref4.pointerType,
8102 eventType = _ref4.eventType,
8103 scope = _ref4.scope;
8104
8105 if (pointerType !== 'mouse' && pointerType !== 'pen') {
8106 return null;
8107 }
8108
8109 var firstNonActive;
8110
8111 for (var _i3 = 0; _i3 < scope.interactions.list.length; _i3++) {
8112 var _ref5;
8113
8114 _ref5 = scope.interactions.list[_i3];
8115 var interaction = _ref5;
8116
8117 if (interaction.pointerType === pointerType) {
8118 // if it's a down event, skip interactions with running simulations
8119 if (interaction.simulation && !hasPointerId(interaction, pointerId)) {
8120 continue;
8121 } // if the interaction is active, return it immediately
8122
8123
8124 if (interaction.interacting()) {
8125 return interaction;
8126 } // otherwise save it and look for another active interaction
8127 else if (!firstNonActive) {
8128 firstNonActive = interaction;
8129 }
8130 }
8131 } // if no active mouse interaction was found use the first inactive mouse
8132 // interaction
8133
8134
8135 if (firstNonActive) {
8136 return firstNonActive;
8137 } // find any mouse or pen interaction.
8138 // ignore the interaction if the eventType is a *down, and a simulation
8139 // is active
8140
8141
8142 for (var _i4 = 0; _i4 < scope.interactions.list.length; _i4++) {
8143 var _ref6;
8144
8145 _ref6 = scope.interactions.list[_i4];
8146 var _interaction = _ref6;
8147
8148 if (_interaction.pointerType === pointerType && !(/down/i.test(eventType) && _interaction.simulation)) {
8149 return _interaction;
8150 }
8151 }
8152
8153 return null;
8154 },
8155 // get interaction that has this pointer
8156 hasPointer: function hasPointer(_ref7) {
8157 var pointerId = _ref7.pointerId,
8158 scope = _ref7.scope;
8159
8160 for (var _i5 = 0; _i5 < scope.interactions.list.length; _i5++) {
8161 var _ref8;
8162
8163 _ref8 = scope.interactions.list[_i5];
8164 var interaction = _ref8;
8165
8166 if (hasPointerId(interaction, pointerId)) {
8167 return interaction;
8168 }
8169 }
8170
8171 return null;
8172 },
8173 // get first idle interaction with a matching pointerType
8174 idle: function idle(_ref9) {
8175 var pointerType = _ref9.pointerType,
8176 scope = _ref9.scope;
8177
8178 for (var _i6 = 0; _i6 < scope.interactions.list.length; _i6++) {
8179 var _ref10;
8180
8181 _ref10 = scope.interactions.list[_i6];
8182 var interaction = _ref10; // if there's already a pointer held down
8183
8184 if (interaction.pointers.length === 1) {
8185 var target = interaction.interactable; // don't add this pointer if there is a target interactable and it
8186 // isn't gesturable
8187
8188 if (target && !(target.options.gesture && target.options.gesture.enabled)) {
8189 continue;
8190 }
8191 } // maximum of 2 pointers per interaction
8192 else if (interaction.pointers.length >= 2) {
8193 continue;
8194 }
8195
8196 if (!interaction.interacting() && pointerType === interaction.pointerType) {
8197 return interaction;
8198 }
8199 }
8200
8201 return null;
8202 }
8203 };
8204
8205 function hasPointerId(interaction, pointerId) {
8206 return interaction.pointers.some(function (_ref11) {
8207 var id = _ref11.id;
8208 return id === pointerId;
8209 });
8210 }
8211
8212 var ___default_26 = finder;
8213 _$interactionFinder_26["default"] = ___default_26;
8214 var _$interactions_27 = {};
8215 "use strict";
8216
8217 Object.defineProperty(_$interactions_27, "__esModule", {
8218 value: true
8219 });
8220 _$interactions_27["default"] = void 0;
8221 /* removed: var _$browser_67 = require("../utils/browser.js"); */
8222
8223 ;
8224 /* removed: var _$domObjects_70 = require("../utils/domObjects.js"); */
8225
8226 ;
8227 /* removed: var _$domUtils_71 = require("../utils/domUtils.js"); */
8228
8229 ;
8230 /* removed: var _$pointerUtils_81 = require("../utils/pointerUtils.js"); */
8231
8232 ;
8233 /* removed: var _$Interaction_20 = require("./Interaction.js"); */
8234
8235 ;
8236 /* removed: var _$interactablePreventDefault_25 = require("./interactablePreventDefault.js"); */
8237
8238 ;
8239 /* removed: var _$interactionFinder_26 = require("./interactionFinder.js"); */
8240
8241 ;
8242
8243 function ___typeof_27(obj) {
8244 "@babel/helpers - typeof";
8245
8246 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
8247 ___typeof_27 = function _typeof(obj) {
8248 return typeof obj;
8249 };
8250 } else {
8251 ___typeof_27 = function _typeof(obj) {
8252 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
8253 };
8254 }
8255
8256 return ___typeof_27(obj);
8257 }
8258
8259 function ___slicedToArray_27(arr, i) {
8260 return ___arrayWithHoles_27(arr) || ___iterableToArrayLimit_27(arr, i) || ___unsupportedIterableToArray_27(arr, i) || ___nonIterableRest_27();
8261 }
8262
8263 function ___nonIterableRest_27() {
8264 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
8265 }
8266
8267 function ___unsupportedIterableToArray_27(o, minLen) {
8268 if (!o) return;
8269 if (typeof o === "string") return ___arrayLikeToArray_27(o, minLen);
8270 var n = Object.prototype.toString.call(o).slice(8, -1);
8271 if (n === "Object" && o.constructor) n = o.constructor.name;
8272 if (n === "Map" || n === "Set") return Array.from(o);
8273 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return ___arrayLikeToArray_27(o, minLen);
8274 }
8275
8276 function ___arrayLikeToArray_27(arr, len) {
8277 if (len == null || len > arr.length) len = arr.length;
8278
8279 for (var i = 0, arr2 = new Array(len); i < len; i++) {
8280 arr2[i] = arr[i];
8281 }
8282
8283 return arr2;
8284 }
8285
8286 function ___iterableToArrayLimit_27(arr, i) {
8287 if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
8288 var _arr = [];
8289 var _n = true;
8290 var _d = false;
8291 var _e = undefined;
8292
8293 try {
8294 for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
8295 _arr.push(_s.value);
8296
8297 if (i && _arr.length === i) break;
8298 }
8299 } catch (err) {
8300 _d = true;
8301 _e = err;
8302 } finally {
8303 try {
8304 if (!_n && _i["return"] != null) _i["return"]();
8305 } finally {
8306 if (_d) throw _e;
8307 }
8308 }
8309
8310 return _arr;
8311 }
8312
8313 function ___arrayWithHoles_27(arr) {
8314 if (Array.isArray(arr)) return arr;
8315 }
8316
8317 function ___classCallCheck_27(instance, Constructor) {
8318 if (!(instance instanceof Constructor)) {
8319 throw new TypeError("Cannot call a class as a function");
8320 }
8321 }
8322
8323 function ___defineProperties_27(target, props) {
8324 for (var i = 0; i < props.length; i++) {
8325 var descriptor = props[i];
8326 descriptor.enumerable = descriptor.enumerable || false;
8327 descriptor.configurable = true;
8328 if ("value" in descriptor) descriptor.writable = true;
8329 Object.defineProperty(target, descriptor.key, descriptor);
8330 }
8331 }
8332
8333 function ___createClass_27(Constructor, protoProps, staticProps) {
8334 if (protoProps) ___defineProperties_27(Constructor.prototype, protoProps);
8335 if (staticProps) ___defineProperties_27(Constructor, staticProps);
8336 return Constructor;
8337 }
8338
8339 function ___inherits_27(subClass, superClass) {
8340 if (typeof superClass !== "function" && superClass !== null) {
8341 throw new TypeError("Super expression must either be null or a function");
8342 }
8343
8344 subClass.prototype = Object.create(superClass && superClass.prototype, {
8345 constructor: {
8346 value: subClass,
8347 writable: true,
8348 configurable: true
8349 }
8350 });
8351 if (superClass) ___setPrototypeOf_27(subClass, superClass);
8352 }
8353
8354 function ___setPrototypeOf_27(o, p) {
8355 ___setPrototypeOf_27 = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
8356 o.__proto__ = p;
8357 return o;
8358 };
8359
8360 return ___setPrototypeOf_27(o, p);
8361 }
8362
8363 function ___createSuper_27(Derived) {
8364 var hasNativeReflectConstruct = ___isNativeReflectConstruct_27();
8365
8366 return function () {
8367 var Super = ___getPrototypeOf_27(Derived),
8368 result;
8369
8370 if (hasNativeReflectConstruct) {
8371 var NewTarget = ___getPrototypeOf_27(this).constructor;
8372
8373 result = Reflect.construct(Super, arguments, NewTarget);
8374 } else {
8375 result = Super.apply(this, arguments);
8376 }
8377
8378 return ___possibleConstructorReturn_27(this, result);
8379 };
8380 }
8381
8382 function ___possibleConstructorReturn_27(self, call) {
8383 if (call && (___typeof_27(call) === "object" || typeof call === "function")) {
8384 return call;
8385 }
8386
8387 return ___assertThisInitialized_27(self);
8388 }
8389
8390 function ___assertThisInitialized_27(self) {
8391 if (self === void 0) {
8392 throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
8393 }
8394
8395 return self;
8396 }
8397
8398 function ___isNativeReflectConstruct_27() {
8399 if (typeof Reflect === "undefined" || !Reflect.construct) return false;
8400 if (Reflect.construct.sham) return false;
8401 if (typeof Proxy === "function") return true;
8402
8403 try {
8404 Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
8405 return true;
8406 } catch (e) {
8407 return false;
8408 }
8409 }
8410
8411 function ___getPrototypeOf_27(o) {
8412 ___getPrototypeOf_27 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
8413 return o.__proto__ || Object.getPrototypeOf(o);
8414 };
8415 return ___getPrototypeOf_27(o);
8416 }
8417
8418 var methodNames = ['pointerDown', 'pointerMove', 'pointerUp', 'updatePointer', 'removePointer', 'windowBlur'];
8419
8420 function __install_27(scope) {
8421 var listeners = {};
8422
8423 for (var _i = 0; _i < methodNames.length; _i++) {
8424 var _ref;
8425
8426 _ref = methodNames[_i];
8427 var method = _ref;
8428 listeners[method] = doOnInteractions(method, scope);
8429 }
8430
8431 var pEventTypes = _$browser_67["default"].pEventTypes;
8432 var docEvents;
8433
8434 if (_$domObjects_70["default"].PointerEvent) {
8435 docEvents = [{
8436 type: pEventTypes.down,
8437 listener: releasePointersOnRemovedEls
8438 }, {
8439 type: pEventTypes.down,
8440 listener: listeners.pointerDown
8441 }, {
8442 type: pEventTypes.move,
8443 listener: listeners.pointerMove
8444 }, {
8445 type: pEventTypes.up,
8446 listener: listeners.pointerUp
8447 }, {
8448 type: pEventTypes.cancel,
8449 listener: listeners.pointerUp
8450 }];
8451 } else {
8452 docEvents = [{
8453 type: 'mousedown',
8454 listener: listeners.pointerDown
8455 }, {
8456 type: 'mousemove',
8457 listener: listeners.pointerMove
8458 }, {
8459 type: 'mouseup',
8460 listener: listeners.pointerUp
8461 }, {
8462 type: 'touchstart',
8463 listener: releasePointersOnRemovedEls
8464 }, {
8465 type: 'touchstart',
8466 listener: listeners.pointerDown
8467 }, {
8468 type: 'touchmove',
8469 listener: listeners.pointerMove
8470 }, {
8471 type: 'touchend',
8472 listener: listeners.pointerUp
8473 }, {
8474 type: 'touchcancel',
8475 listener: listeners.pointerUp
8476 }];
8477 }
8478
8479 docEvents.push({
8480 type: 'blur',
8481 listener: function listener(event) {
8482 for (var _i2 = 0; _i2 < scope.interactions.list.length; _i2++) {
8483 var _ref2;
8484
8485 _ref2 = scope.interactions.list[_i2];
8486 var interaction = _ref2;
8487 interaction.documentBlur(event);
8488 }
8489 }
8490 }); // for ignoring browser's simulated mouse events
8491
8492 scope.prevTouchTime = 0;
8493
8494 scope.Interaction = /*#__PURE__*/function (_InteractionBase) {
8495 ___inherits_27(_class, _InteractionBase);
8496
8497 var _super = ___createSuper_27(_class);
8498
8499 function _class() {
8500 ___classCallCheck_27(this, _class);
8501
8502 return _super.apply(this, arguments);
8503 }
8504
8505 ___createClass_27(_class, [{
8506 key: "_now",
8507 value: function _now() {
8508 return scope.now();
8509 }
8510 }, {
8511 key: "pointerMoveTolerance",
8512 get: function get() {
8513 return scope.interactions.pointerMoveTolerance;
8514 },
8515 set: function set(value) {
8516 scope.interactions.pointerMoveTolerance = value;
8517 }
8518 }]);
8519
8520 return _class;
8521 }(_$Interaction_20["default"]);
8522
8523 scope.interactions = {
8524 // all active and idle interactions
8525 list: [],
8526 "new": function _new(options) {
8527 options.scopeFire = function (name, arg) {
8528 return scope.fire(name, arg);
8529 };
8530
8531 var interaction = new scope.Interaction(options);
8532 scope.interactions.list.push(interaction);
8533 return interaction;
8534 },
8535 listeners: listeners,
8536 docEvents: docEvents,
8537 pointerMoveTolerance: 1
8538 };
8539
8540 function releasePointersOnRemovedEls() {
8541 // for all inactive touch interactions with pointers down
8542 for (var _i3 = 0; _i3 < scope.interactions.list.length; _i3++) {
8543 var _ref3;
8544
8545 _ref3 = scope.interactions.list[_i3];
8546 var interaction = _ref3;
8547
8548 if (!interaction.pointerIsDown || interaction.pointerType !== 'touch' || interaction._interacting) {
8549 continue;
8550 } // if a pointer is down on an element that is no longer in the DOM tree
8551
8552
8553 var _loop = function _loop() {
8554 _ref4 = interaction.pointers[_i4];
8555 var pointer = _ref4;
8556
8557 if (!scope.documents.some(function (_ref5) {
8558 var doc = _ref5.doc;
8559 return (0, _$domUtils_71.nodeContains)(doc, pointer.downTarget);
8560 })) {
8561 // remove the pointer from the interaction
8562 interaction.removePointer(pointer.pointer, pointer.event);
8563 }
8564 };
8565
8566 for (var _i4 = 0; _i4 < interaction.pointers.length; _i4++) {
8567 var _ref4;
8568
8569 _loop();
8570 }
8571 }
8572 }
8573
8574 scope.usePlugin(_$interactablePreventDefault_25["default"]);
8575 }
8576
8577 function doOnInteractions(method, scope) {
8578 return function (event) {
8579 var interactions = scope.interactions.list;
8580
8581 var pointerType = _$pointerUtils_81.getPointerType(event);
8582
8583 var _pointerUtils$getEven = _$pointerUtils_81.getEventTargets(event),
8584 _pointerUtils$getEven2 = ___slicedToArray_27(_pointerUtils$getEven, 2),
8585 eventTarget = _pointerUtils$getEven2[0],
8586 curEventTarget = _pointerUtils$getEven2[1];
8587
8588 var matches = []; // [ [pointer, interaction], ...]
8589
8590 if (/^touch/.test(event.type)) {
8591 scope.prevTouchTime = scope.now();
8592
8593 for (var _i5 = 0; _i5 < event.changedTouches.length; _i5++) {
8594 var _ref6;
8595
8596 _ref6 = event.changedTouches[_i5];
8597 var changedTouch = _ref6;
8598 var pointer = changedTouch;
8599
8600 var pointerId = _$pointerUtils_81.getPointerId(pointer);
8601
8602 var searchDetails = {
8603 pointer: pointer,
8604 pointerId: pointerId,
8605 pointerType: pointerType,
8606 eventType: event.type,
8607 eventTarget: eventTarget,
8608 curEventTarget: curEventTarget,
8609 scope: scope
8610 };
8611 var interaction = getInteraction(searchDetails);
8612 matches.push([searchDetails.pointer, searchDetails.eventTarget, searchDetails.curEventTarget, interaction]);
8613 }
8614 } else {
8615 var invalidPointer = false;
8616
8617 if (!_$browser_67["default"].supportsPointerEvent && /mouse/.test(event.type)) {
8618 // ignore mouse events while touch interactions are active
8619 for (var i = 0; i < interactions.length && !invalidPointer; i++) {
8620 invalidPointer = interactions[i].pointerType !== 'mouse' && interactions[i].pointerIsDown;
8621 } // try to ignore mouse events that are simulated by the browser
8622 // after a touch event
8623
8624
8625 invalidPointer = invalidPointer || scope.now() - scope.prevTouchTime < 500 || // on iOS and Firefox Mobile, MouseEvent.timeStamp is zero if simulated
8626 event.timeStamp === 0;
8627 }
8628
8629 if (!invalidPointer) {
8630 var _searchDetails = {
8631 pointer: event,
8632 pointerId: _$pointerUtils_81.getPointerId(event),
8633 pointerType: pointerType,
8634 eventType: event.type,
8635 curEventTarget: curEventTarget,
8636 eventTarget: eventTarget,
8637 scope: scope
8638 };
8639
8640 var _interaction = getInteraction(_searchDetails);
8641
8642 matches.push([_searchDetails.pointer, _searchDetails.eventTarget, _searchDetails.curEventTarget, _interaction]);
8643 }
8644 } // eslint-disable-next-line no-shadow
8645
8646
8647 for (var _i6 = 0; _i6 < matches.length; _i6++) {
8648 var _matches$_i = ___slicedToArray_27(matches[_i6], 4),
8649 _pointer = _matches$_i[0],
8650 _eventTarget = _matches$_i[1],
8651 _curEventTarget = _matches$_i[2],
8652 _interaction2 = _matches$_i[3];
8653
8654 _interaction2[method](_pointer, event, _eventTarget, _curEventTarget);
8655 }
8656 };
8657 }
8658
8659 function getInteraction(searchDetails) {
8660 var pointerType = searchDetails.pointerType,
8661 scope = searchDetails.scope;
8662
8663 var foundInteraction = _$interactionFinder_26["default"].search(searchDetails);
8664
8665 var signalArg = {
8666 interaction: foundInteraction,
8667 searchDetails: searchDetails
8668 };
8669 scope.fire('interactions:find', signalArg);
8670 return signalArg.interaction || scope.interactions["new"]({
8671 pointerType: pointerType
8672 });
8673 }
8674
8675 function onDocSignal(_ref7, eventMethodName) {
8676 var doc = _ref7.doc,
8677 scope = _ref7.scope,
8678 options = _ref7.options;
8679 var docEvents = scope.interactions.docEvents,
8680 events = scope.events;
8681 var eventMethod = events[eventMethodName];
8682
8683 if (scope.browser.isIOS && !options.events) {
8684 options.events = {
8685 passive: false
8686 };
8687 } // delegate event listener
8688
8689
8690 for (var eventType in events.delegatedEvents) {
8691 eventMethod(doc, eventType, events.delegateListener);
8692 eventMethod(doc, eventType, events.delegateUseCapture, true);
8693 }
8694
8695 var eventOptions = options && options.events;
8696
8697 for (var _i7 = 0; _i7 < docEvents.length; _i7++) {
8698 var _ref8;
8699
8700 _ref8 = docEvents[_i7];
8701 var _ref9 = _ref8,
8702 type = _ref9.type,
8703 listener = _ref9.listener;
8704 eventMethod(doc, type, listener, eventOptions);
8705 }
8706 }
8707
8708 var interactions = {
8709 id: 'core/interactions',
8710 install: __install_27,
8711 listeners: {
8712 'scope:add-document': function scopeAddDocument(arg) {
8713 return onDocSignal(arg, 'add');
8714 },
8715 'scope:remove-document': function scopeRemoveDocument(arg) {
8716 return onDocSignal(arg, 'remove');
8717 },
8718 'interactable:unset': function interactableUnset(_ref10, scope) {
8719 var interactable = _ref10.interactable; // Stop and destroy related interactions when an Interactable is unset
8720
8721 for (var i = scope.interactions.list.length - 1; i >= 0; i--) {
8722 var interaction = scope.interactions.list[i];
8723
8724 if (interaction.interactable !== interactable) {
8725 continue;
8726 }
8727
8728 interaction.stop();
8729 scope.fire('interactions:destroy', {
8730 interaction: interaction
8731 });
8732 interaction.destroy();
8733
8734 if (scope.interactions.list.length > 2) {
8735 scope.interactions.list.splice(i, 1);
8736 }
8737 }
8738 }
8739 },
8740 onDocSignal: onDocSignal,
8741 doOnInteractions: doOnInteractions,
8742 methodNames: methodNames
8743 };
8744 var ___default_27 = interactions;
8745 _$interactions_27["default"] = ___default_27;
8746 var _$scope_29 = {};
8747 "use strict";
8748
8749 Object.defineProperty(_$scope_29, "__esModule", {
8750 value: true
8751 });
8752 _$scope_29.initScope = initScope;
8753 _$scope_29.Scope = void 0;
8754 /* removed: var _$browser_67 = require("../utils/browser.js"); */
8755
8756 ;
8757 /* removed: var _$clone_68 = require("../utils/clone.js"); */
8758
8759 ;
8760 /* removed: var _$domObjects_70 = require("../utils/domObjects.js"); */
8761
8762 ;
8763 /* removed: var _$extend_73 = require("../utils/extend.js"); */
8764
8765 ;
8766 /* removed: var _$raf_82 = require("../utils/raf.js"); */
8767
8768 ;
8769 /* removed: var _$window_84 = require("../utils/window.js"); */
8770
8771 ;
8772 /* removed: var _$Eventable_16 = require("./Eventable.js"); */
8773
8774 ;
8775 /* removed: var _$InteractEvent_17 = require("./InteractEvent.js"); */
8776
8777 ;
8778 /* removed: var _$Interactable_18 = require("./Interactable.js"); */
8779
8780 ;
8781 /* removed: var _$InteractableSet_19 = require("./InteractableSet.js"); */
8782
8783 ;
8784 /* removed: var _$defaultOptions_22 = require("./defaultOptions.js"); */
8785
8786 ;
8787 /* removed: var _$events_23 = require("./events.js"); */
8788
8789 ;
8790 /* removed: var _$interactStatic_24 = require("./interactStatic.js"); */
8791
8792 ;
8793 /* removed: var _$interactions_27 = require("./interactions.js"); */
8794
8795 ;
8796
8797 function ___typeof_29(obj) {
8798 "@babel/helpers - typeof";
8799
8800 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
8801 ___typeof_29 = function _typeof(obj) {
8802 return typeof obj;
8803 };
8804 } else {
8805 ___typeof_29 = function _typeof(obj) {
8806 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
8807 };
8808 }
8809
8810 return ___typeof_29(obj);
8811 }
8812
8813 function _get(target, property, receiver) {
8814 if (typeof Reflect !== "undefined" && Reflect.get) {
8815 _get = Reflect.get;
8816 } else {
8817 _get = function _get(target, property, receiver) {
8818 var base = _superPropBase(target, property);
8819
8820 if (!base) return;
8821 var desc = Object.getOwnPropertyDescriptor(base, property);
8822
8823 if (desc.get) {
8824 return desc.get.call(receiver);
8825 }
8826
8827 return desc.value;
8828 };
8829 }
8830
8831 return _get(target, property, receiver || target);
8832 }
8833
8834 function _superPropBase(object, property) {
8835 while (!Object.prototype.hasOwnProperty.call(object, property)) {
8836 object = ___getPrototypeOf_29(object);
8837 if (object === null) break;
8838 }
8839
8840 return object;
8841 }
8842
8843 function ___inherits_29(subClass, superClass) {
8844 if (typeof superClass !== "function" && superClass !== null) {
8845 throw new TypeError("Super expression must either be null or a function");
8846 }
8847
8848 subClass.prototype = Object.create(superClass && superClass.prototype, {
8849 constructor: {
8850 value: subClass,
8851 writable: true,
8852 configurable: true
8853 }
8854 });
8855 if (superClass) ___setPrototypeOf_29(subClass, superClass);
8856 }
8857
8858 function ___setPrototypeOf_29(o, p) {
8859 ___setPrototypeOf_29 = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
8860 o.__proto__ = p;
8861 return o;
8862 };
8863
8864 return ___setPrototypeOf_29(o, p);
8865 }
8866
8867 function ___createSuper_29(Derived) {
8868 var hasNativeReflectConstruct = ___isNativeReflectConstruct_29();
8869
8870 return function () {
8871 var Super = ___getPrototypeOf_29(Derived),
8872 result;
8873
8874 if (hasNativeReflectConstruct) {
8875 var NewTarget = ___getPrototypeOf_29(this).constructor;
8876
8877 result = Reflect.construct(Super, arguments, NewTarget);
8878 } else {
8879 result = Super.apply(this, arguments);
8880 }
8881
8882 return ___possibleConstructorReturn_29(this, result);
8883 };
8884 }
8885
8886 function ___possibleConstructorReturn_29(self, call) {
8887 if (call && (___typeof_29(call) === "object" || typeof call === "function")) {
8888 return call;
8889 }
8890
8891 return ___assertThisInitialized_29(self);
8892 }
8893
8894 function ___assertThisInitialized_29(self) {
8895 if (self === void 0) {
8896 throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
8897 }
8898
8899 return self;
8900 }
8901
8902 function ___isNativeReflectConstruct_29() {
8903 if (typeof Reflect === "undefined" || !Reflect.construct) return false;
8904 if (Reflect.construct.sham) return false;
8905 if (typeof Proxy === "function") return true;
8906
8907 try {
8908 Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
8909 return true;
8910 } catch (e) {
8911 return false;
8912 }
8913 }
8914
8915 function ___getPrototypeOf_29(o) {
8916 ___getPrototypeOf_29 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
8917 return o.__proto__ || Object.getPrototypeOf(o);
8918 };
8919 return ___getPrototypeOf_29(o);
8920 }
8921
8922 function ___classCallCheck_29(instance, Constructor) {
8923 if (!(instance instanceof Constructor)) {
8924 throw new TypeError("Cannot call a class as a function");
8925 }
8926 }
8927
8928 function ___defineProperties_29(target, props) {
8929 for (var i = 0; i < props.length; i++) {
8930 var descriptor = props[i];
8931 descriptor.enumerable = descriptor.enumerable || false;
8932 descriptor.configurable = true;
8933 if ("value" in descriptor) descriptor.writable = true;
8934 Object.defineProperty(target, descriptor.key, descriptor);
8935 }
8936 }
8937
8938 function ___createClass_29(Constructor, protoProps, staticProps) {
8939 if (protoProps) ___defineProperties_29(Constructor.prototype, protoProps);
8940 if (staticProps) ___defineProperties_29(Constructor, staticProps);
8941 return Constructor;
8942 }
8943
8944 var Scope = /*#__PURE__*/function () {
8945 // main window
8946 // main document
8947 // main window
8948 // all documents being listened to
8949 function Scope() {
8950 var _this = this;
8951
8952 ___classCallCheck_29(this, Scope);
8953
8954 this.id = "__interact_scope_".concat(Math.floor(Math.random() * 100));
8955 this.isInitialized = false;
8956 this.listenerMaps = [];
8957 this.browser = _$browser_67["default"];
8958 this.defaults = (0, _$clone_68["default"])(_$defaultOptions_22.defaults);
8959 this.Eventable = _$Eventable_16.Eventable;
8960 this.actions = {
8961 map: {},
8962 phases: {
8963 start: true,
8964 move: true,
8965 end: true
8966 },
8967 methodDict: {},
8968 phaselessTypes: {}
8969 };
8970 this.interactStatic = (0, _$interactStatic_24.createInteractStatic)(this);
8971 this.InteractEvent = _$InteractEvent_17.InteractEvent;
8972 this.Interactable = void 0;
8973 this.interactables = new _$InteractableSet_19.InteractableSet(this);
8974 this._win = void 0;
8975 this.document = void 0;
8976 this.window = void 0;
8977 this.documents = [];
8978 this._plugins = {
8979 list: [],
8980 map: {}
8981 };
8982
8983 this.onWindowUnload = function (event) {
8984 return _this.removeDocument(event.target);
8985 };
8986
8987 var scope = this;
8988
8989 this.Interactable = /*#__PURE__*/function (_InteractableBase) {
8990 ___inherits_29(_class, _InteractableBase);
8991
8992 var _super = ___createSuper_29(_class);
8993
8994 function _class() {
8995 ___classCallCheck_29(this, _class);
8996
8997 return _super.apply(this, arguments);
8998 }
8999
9000 ___createClass_29(_class, [{
9001 key: "set",
9002 value: function set(options) {
9003 _get(___getPrototypeOf_29(_class.prototype), "set", this).call(this, options);
9004
9005 scope.fire('interactable:set', {
9006 options: options,
9007 interactable: this
9008 });
9009 return this;
9010 }
9011 }, {
9012 key: "unset",
9013 value: function unset() {
9014 _get(___getPrototypeOf_29(_class.prototype), "unset", this).call(this);
9015
9016 scope.interactables.list.splice(scope.interactables.list.indexOf(this), 1);
9017 scope.fire('interactable:unset', {
9018 interactable: this
9019 });
9020 }
9021 }, {
9022 key: "_defaults",
9023 get: function get() {
9024 return scope.defaults;
9025 }
9026 }]);
9027
9028 return _class;
9029 }(_$Interactable_18.Interactable);
9030 }
9031
9032 ___createClass_29(Scope, [{
9033 key: "addListeners",
9034 value: function addListeners(map, id) {
9035 this.listenerMaps.push({
9036 id: id,
9037 map: map
9038 });
9039 }
9040 }, {
9041 key: "fire",
9042 value: function fire(name, arg) {
9043 for (var _i = 0; _i < this.listenerMaps.length; _i++) {
9044 var _ref;
9045
9046 _ref = this.listenerMaps[_i];
9047 var _ref2 = _ref,
9048 listener = _ref2.map[name];
9049
9050 if (!!listener && listener(arg, this, name) === false) {
9051 return false;
9052 }
9053 }
9054 }
9055 }, {
9056 key: "init",
9057 value: function init(window) {
9058 return this.isInitialized ? this : initScope(this, window);
9059 }
9060 }, {
9061 key: "pluginIsInstalled",
9062 value: function pluginIsInstalled(plugin) {
9063 return this._plugins.map[plugin.id] || this._plugins.list.indexOf(plugin) !== -1;
9064 }
9065 }, {
9066 key: "usePlugin",
9067 value: function usePlugin(plugin, options) {
9068 if (!this.isInitialized) {
9069 return this;
9070 }
9071
9072 if (this.pluginIsInstalled(plugin)) {
9073 return this;
9074 }
9075
9076 if (plugin.id) {
9077 this._plugins.map[plugin.id] = plugin;
9078 }
9079
9080 this._plugins.list.push(plugin);
9081
9082 if (plugin.install) {
9083 plugin.install(this, options);
9084 }
9085
9086 if (plugin.listeners && plugin.before) {
9087 var index = 0;
9088 var len = this.listenerMaps.length;
9089 var before = plugin.before.reduce(function (acc, id) {
9090 acc[id] = true;
9091 return acc;
9092 }, {});
9093
9094 for (; index < len; index++) {
9095 var otherId = this.listenerMaps[index].id;
9096
9097 if (before[otherId]) {
9098 break;
9099 }
9100 }
9101
9102 this.listenerMaps.splice(index, 0, {
9103 id: plugin.id,
9104 map: plugin.listeners
9105 });
9106 } else if (plugin.listeners) {
9107 this.listenerMaps.push({
9108 id: plugin.id,
9109 map: plugin.listeners
9110 });
9111 }
9112
9113 return this;
9114 }
9115 }, {
9116 key: "addDocument",
9117 value: function addDocument(doc, options) {
9118 // do nothing if document is already known
9119 if (this.getDocIndex(doc) !== -1) {
9120 return false;
9121 }
9122
9123 var window = _$window_84["default"].getWindow(doc);
9124
9125 options = options ? (0, _$extend_73["default"])({}, options) : {};
9126 this.documents.push({
9127 doc: doc,
9128 options: options
9129 });
9130 this.events.documents.push(doc); // don't add an unload event for the main document
9131 // so that the page may be cached in browser history
9132
9133 if (doc !== this.document) {
9134 this.events.add(window, 'unload', this.onWindowUnload);
9135 }
9136
9137 this.fire('scope:add-document', {
9138 doc: doc,
9139 window: window,
9140 scope: this,
9141 options: options
9142 });
9143 }
9144 }, {
9145 key: "removeDocument",
9146 value: function removeDocument(doc) {
9147 var index = this.getDocIndex(doc);
9148
9149 var window = _$window_84["default"].getWindow(doc);
9150
9151 var options = this.documents[index].options;
9152 this.events.remove(window, 'unload', this.onWindowUnload);
9153 this.documents.splice(index, 1);
9154 this.events.documents.splice(index, 1);
9155 this.fire('scope:remove-document', {
9156 doc: doc,
9157 window: window,
9158 scope: this,
9159 options: options
9160 });
9161 }
9162 }, {
9163 key: "getDocIndex",
9164 value: function getDocIndex(doc) {
9165 for (var i = 0; i < this.documents.length; i++) {
9166 if (this.documents[i].doc === doc) {
9167 return i;
9168 }
9169 }
9170
9171 return -1;
9172 }
9173 }, {
9174 key: "getDocOptions",
9175 value: function getDocOptions(doc) {
9176 var docIndex = this.getDocIndex(doc);
9177 return docIndex === -1 ? null : this.documents[docIndex].options;
9178 }
9179 }, {
9180 key: "now",
9181 value: function now() {
9182 return (this.window.Date || Date).now();
9183 }
9184 }]);
9185
9186 return Scope;
9187 }();
9188
9189 _$scope_29.Scope = Scope;
9190
9191 function initScope(scope, window) {
9192 scope.isInitialized = true;
9193
9194 _$window_84["default"].init(window);
9195
9196 _$domObjects_70["default"].init(window);
9197
9198 _$browser_67["default"].init(window);
9199
9200 _$raf_82["default"].init(window);
9201
9202 scope.window = window;
9203 scope.document = window.document;
9204 scope.usePlugin(_$interactions_27["default"]);
9205 scope.usePlugin(_$events_23["default"]);
9206 return scope;
9207 }
9208
9209 var _$interact_33 = {};
9210 "use strict";
9211
9212 Object.defineProperty(_$interact_33, "__esModule", {
9213 value: true
9214 });
9215 _$interact_33.init = _$interact_33["default"] = void 0;
9216 /* removed: var _$scope_29 = require("../core/scope.js"); */
9217
9218 ;
9219
9220 function ___typeof_33(obj) {
9221 "@babel/helpers - typeof";
9222
9223 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
9224 ___typeof_33 = function _typeof(obj) {
9225 return typeof obj;
9226 };
9227 } else {
9228 ___typeof_33 = function _typeof(obj) {
9229 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
9230 };
9231 }
9232
9233 return ___typeof_33(obj);
9234 }
9235
9236 var scope = new _$scope_29.Scope();
9237 var interact = scope.interactStatic;
9238 var ___default_33 = interact;
9239 _$interact_33["default"] = ___default_33;
9240
9241 var __init_33 = function init(win) {
9242 return scope.init(win);
9243 };
9244
9245 _$interact_33.init = __init_33;
9246
9247 if ((typeof window === "undefined" ? "undefined" : ___typeof_33(window)) === 'object' && !!window) {
9248 __init_33(window);
9249 }
9250
9251 var _$edgeTarget_62 = {};
9252 "use strict";
9253
9254 Object.defineProperty(_$edgeTarget_62, "__esModule", {
9255 value: true
9256 });
9257 _$edgeTarget_62["default"] = void 0;
9258
9259 var ___default_62 = function _default() {};
9260
9261 _$edgeTarget_62["default"] = ___default_62;
9262 var _$elements_63 = {};
9263 "use strict";
9264
9265 Object.defineProperty(_$elements_63, "__esModule", {
9266 value: true
9267 });
9268 _$elements_63["default"] = void 0;
9269
9270 var ___default_63 = function _default() {};
9271
9272 _$elements_63["default"] = ___default_63;
9273 var _$grid_64 = {};
9274 "use strict";
9275
9276 Object.defineProperty(_$grid_64, "__esModule", {
9277 value: true
9278 });
9279 _$grid_64["default"] = void 0;
9280
9281 function ___slicedToArray_64(arr, i) {
9282 return ___arrayWithHoles_64(arr) || ___iterableToArrayLimit_64(arr, i) || ___unsupportedIterableToArray_64(arr, i) || ___nonIterableRest_64();
9283 }
9284
9285 function ___nonIterableRest_64() {
9286 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
9287 }
9288
9289 function ___unsupportedIterableToArray_64(o, minLen) {
9290 if (!o) return;
9291 if (typeof o === "string") return ___arrayLikeToArray_64(o, minLen);
9292 var n = Object.prototype.toString.call(o).slice(8, -1);
9293 if (n === "Object" && o.constructor) n = o.constructor.name;
9294 if (n === "Map" || n === "Set") return Array.from(o);
9295 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return ___arrayLikeToArray_64(o, minLen);
9296 }
9297
9298 function ___arrayLikeToArray_64(arr, len) {
9299 if (len == null || len > arr.length) len = arr.length;
9300
9301 for (var i = 0, arr2 = new Array(len); i < len; i++) {
9302 arr2[i] = arr[i];
9303 }
9304
9305 return arr2;
9306 }
9307
9308 function ___iterableToArrayLimit_64(arr, i) {
9309 if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
9310 var _arr = [];
9311 var _n = true;
9312 var _d = false;
9313 var _e = undefined;
9314
9315 try {
9316 for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
9317 _arr.push(_s.value);
9318
9319 if (i && _arr.length === i) break;
9320 }
9321 } catch (err) {
9322 _d = true;
9323 _e = err;
9324 } finally {
9325 try {
9326 if (!_n && _i["return"] != null) _i["return"]();
9327 } finally {
9328 if (_d) throw _e;
9329 }
9330 }
9331
9332 return _arr;
9333 }
9334
9335 function ___arrayWithHoles_64(arr) {
9336 if (Array.isArray(arr)) return arr;
9337 }
9338
9339 var ___default_64 = function _default(grid) {
9340 var coordFields = [['x', 'y'], ['left', 'top'], ['right', 'bottom'], ['width', 'height']].filter(function (_ref) {
9341 var _ref2 = ___slicedToArray_64(_ref, 2),
9342 xField = _ref2[0],
9343 yField = _ref2[1];
9344
9345 return xField in grid || yField in grid;
9346 });
9347
9348 var gridFunc = function gridFunc(x, y) {
9349 var range = grid.range,
9350 _grid$limits = grid.limits,
9351 limits = _grid$limits === void 0 ? {
9352 left: -Infinity,
9353 right: Infinity,
9354 top: -Infinity,
9355 bottom: Infinity
9356 } : _grid$limits,
9357 _grid$offset = grid.offset,
9358 offset = _grid$offset === void 0 ? {
9359 x: 0,
9360 y: 0
9361 } : _grid$offset;
9362 var result = {
9363 range: range,
9364 grid: grid,
9365 x: null,
9366 y: null
9367 };
9368
9369 for (var _i2 = 0; _i2 < coordFields.length; _i2++) {
9370 var _ref3;
9371
9372 _ref3 = coordFields[_i2];
9373
9374 var _ref4 = _ref3,
9375 _ref5 = ___slicedToArray_64(_ref4, 2),
9376 xField = _ref5[0],
9377 yField = _ref5[1];
9378
9379 var gridx = Math.round((x - offset.x) / grid[xField]);
9380 var gridy = Math.round((y - offset.y) / grid[yField]);
9381 result[xField] = Math.max(limits.left, Math.min(limits.right, gridx * grid[xField] + offset.x));
9382 result[yField] = Math.max(limits.top, Math.min(limits.bottom, gridy * grid[yField] + offset.y));
9383 }
9384
9385 return result;
9386 };
9387
9388 gridFunc.grid = grid;
9389 gridFunc.coordFields = coordFields;
9390 return gridFunc;
9391 };
9392
9393 _$grid_64["default"] = ___default_64;
9394 var _$all_61 = {};
9395 "use strict";
9396
9397 Object.defineProperty(_$all_61, "__esModule", {
9398 value: true
9399 });
9400 Object.defineProperty(_$all_61, "edgeTarget", {
9401 enumerable: true,
9402 get: function get() {
9403 return _$edgeTarget_62["default"];
9404 }
9405 });
9406 Object.defineProperty(_$all_61, "elements", {
9407 enumerable: true,
9408 get: function get() {
9409 return _$elements_63["default"];
9410 }
9411 });
9412 Object.defineProperty(_$all_61, "grid", {
9413 enumerable: true,
9414 get: function get() {
9415 return _$grid_64["default"];
9416 }
9417 });
9418 /* removed: var _$edgeTarget_62 = require("./edgeTarget.js"); */
9419
9420 ;
9421 /* removed: var _$elements_63 = require("./elements.js"); */
9422
9423 ;
9424 /* removed: var _$grid_64 = require("./grid.js"); */
9425
9426 ;
9427 var _$plugin_65 = {};
9428 "use strict";
9429
9430 Object.defineProperty(_$plugin_65, "__esModule", {
9431 value: true
9432 });
9433 _$plugin_65["default"] = void 0;
9434 /* removed: var _$extend_73 = require("../utils/extend.js"); */
9435
9436 ;
9437 /* removed: var _$all_61 = require("./all.js"); */
9438
9439 ;
9440 var snappersPlugin = {
9441 id: 'snappers',
9442 install: function install(scope) {
9443 var interact = scope.interactStatic;
9444 interact.snappers = (0, _$extend_73["default"])(interact.snappers || {}, _$all_61);
9445 interact.createSnapGrid = interact.snappers.grid;
9446 }
9447 };
9448 var ___default_65 = snappersPlugin;
9449 _$plugin_65["default"] = ___default_65;
9450 var _$aspectRatio_37 = {};
9451 "use strict";
9452
9453 Object.defineProperty(_$aspectRatio_37, "__esModule", {
9454 value: true
9455 });
9456 _$aspectRatio_37.aspectRatio = _$aspectRatio_37["default"] = void 0;
9457 /* removed: var _$extend_73 = require("../utils/extend.js"); */
9458
9459 ;
9460 /* removed: var _$rect_83 = require("../utils/rect.js"); */
9461
9462 ;
9463 /* removed: var _$Modification_35 = require("./Modification.js"); */
9464
9465 ;
9466 /* removed: var _$base_39 = require("./base.js"); */
9467
9468 ;
9469
9470 function ownKeys(object, enumerableOnly) {
9471 var keys = Object.keys(object);
9472
9473 if (Object.getOwnPropertySymbols) {
9474 var symbols = Object.getOwnPropertySymbols(object);
9475 if (enumerableOnly) symbols = symbols.filter(function (sym) {
9476 return Object.getOwnPropertyDescriptor(object, sym).enumerable;
9477 });
9478 keys.push.apply(keys, symbols);
9479 }
9480
9481 return keys;
9482 }
9483
9484 function _objectSpread(target) {
9485 for (var i = 1; i < arguments.length; i++) {
9486 var source = arguments[i] != null ? arguments[i] : {};
9487
9488 if (i % 2) {
9489 ownKeys(Object(source), true).forEach(function (key) {
9490 _defineProperty(target, key, source[key]);
9491 });
9492 } else if (Object.getOwnPropertyDescriptors) {
9493 Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
9494 } else {
9495 ownKeys(Object(source)).forEach(function (key) {
9496 Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
9497 });
9498 }
9499 }
9500
9501 return target;
9502 }
9503
9504 function _defineProperty(obj, key, value) {
9505 if (key in obj) {
9506 Object.defineProperty(obj, key, {
9507 value: value,
9508 enumerable: true,
9509 configurable: true,
9510 writable: true
9511 });
9512 } else {
9513 obj[key] = value;
9514 }
9515
9516 return obj;
9517 }
9518
9519 var aspectRatio = {
9520 start: function start(arg) {
9521 var state = arg.state,
9522 rect = arg.rect,
9523 originalEdges = arg.edges,
9524 coords = arg.pageCoords;
9525 var ratio = state.options.ratio;
9526 var _state$options = state.options,
9527 equalDelta = _state$options.equalDelta,
9528 modifiers = _state$options.modifiers;
9529
9530 if (ratio === 'preserve') {
9531 ratio = rect.width / rect.height;
9532 }
9533
9534 state.startCoords = (0, _$extend_73["default"])({}, coords);
9535 state.startRect = (0, _$extend_73["default"])({}, rect);
9536 state.ratio = ratio;
9537 state.equalDelta = equalDelta;
9538 var linkedEdges = state.linkedEdges = {
9539 top: originalEdges.top || originalEdges.left && !originalEdges.bottom,
9540 left: originalEdges.left || originalEdges.top && !originalEdges.right,
9541 bottom: originalEdges.bottom || originalEdges.right && !originalEdges.top,
9542 right: originalEdges.right || originalEdges.bottom && !originalEdges.left
9543 };
9544 state.xIsPrimaryAxis = !!(originalEdges.left || originalEdges.right);
9545
9546 if (state.equalDelta) {
9547 state.edgeSign = (linkedEdges.left ? 1 : -1) * (linkedEdges.top ? 1 : -1);
9548 } else {
9549 var negativeSecondaryEdge = state.xIsPrimaryAxis ? linkedEdges.top : linkedEdges.left;
9550 state.edgeSign = negativeSecondaryEdge ? -1 : 1;
9551 }
9552
9553 (0, _$extend_73["default"])(arg.edges, linkedEdges);
9554
9555 if (!modifiers || !modifiers.length) {
9556 return;
9557 }
9558
9559 var subModification = new _$Modification_35["default"](arg.interaction);
9560 subModification.copyFrom(arg.interaction.modification);
9561 subModification.prepareStates(modifiers);
9562 state.subModification = subModification;
9563 subModification.startAll(_objectSpread({}, arg));
9564 },
9565 set: function set(arg) {
9566 var state = arg.state,
9567 rect = arg.rect,
9568 coords = arg.coords;
9569 var initialCoords = (0, _$extend_73["default"])({}, coords);
9570 var aspectMethod = state.equalDelta ? setEqualDelta : setRatio;
9571 aspectMethod(state, state.xIsPrimaryAxis, coords, rect);
9572
9573 if (!state.subModification) {
9574 return null;
9575 }
9576
9577 var correctedRect = (0, _$extend_73["default"])({}, rect);
9578 (0, _$rect_83.addEdges)(state.linkedEdges, correctedRect, {
9579 x: coords.x - initialCoords.x,
9580 y: coords.y - initialCoords.y
9581 });
9582 var result = state.subModification.setAll(_objectSpread(_objectSpread({}, arg), {}, {
9583 rect: correctedRect,
9584 edges: state.linkedEdges,
9585 pageCoords: coords,
9586 prevCoords: coords,
9587 prevRect: correctedRect
9588 }));
9589 var delta = result.delta;
9590
9591 if (result.changed) {
9592 var xIsCriticalAxis = Math.abs(delta.x) > Math.abs(delta.y); // do aspect modification again with critical edge axis as primary
9593
9594 aspectMethod(state, xIsCriticalAxis, result.coords, result.rect);
9595 (0, _$extend_73["default"])(coords, result.coords);
9596 }
9597
9598 return result.eventProps;
9599 },
9600 defaults: {
9601 ratio: 'preserve',
9602 equalDelta: false,
9603 modifiers: [],
9604 enabled: false
9605 }
9606 };
9607 _$aspectRatio_37.aspectRatio = aspectRatio;
9608
9609 function setEqualDelta(_ref, xIsPrimaryAxis, coords) {
9610 var startCoords = _ref.startCoords,
9611 edgeSign = _ref.edgeSign;
9612
9613 if (xIsPrimaryAxis) {
9614 coords.y = startCoords.y + (coords.x - startCoords.x) * edgeSign;
9615 } else {
9616 coords.x = startCoords.x + (coords.y - startCoords.y) * edgeSign;
9617 }
9618 }
9619
9620 function setRatio(_ref2, xIsPrimaryAxis, coords, rect) {
9621 var startRect = _ref2.startRect,
9622 startCoords = _ref2.startCoords,
9623 ratio = _ref2.ratio,
9624 edgeSign = _ref2.edgeSign;
9625
9626 if (xIsPrimaryAxis) {
9627 var newHeight = rect.width / ratio;
9628 coords.y = startCoords.y + (newHeight - startRect.height) * edgeSign;
9629 } else {
9630 var newWidth = rect.height * ratio;
9631 coords.x = startCoords.x + (newWidth - startRect.width) * edgeSign;
9632 }
9633 }
9634
9635 var ___default_37 = (0, _$base_39.makeModifier)(aspectRatio, 'aspectRatio');
9636
9637 _$aspectRatio_37["default"] = ___default_37;
9638 var _$noop_40 = {};
9639 "use strict";
9640
9641 Object.defineProperty(_$noop_40, "__esModule", {
9642 value: true
9643 });
9644 _$noop_40["default"] = void 0;
9645
9646 var noop = function noop() {};
9647
9648 noop._defaults = {};
9649 var ___default_40 = noop;
9650 _$noop_40["default"] = ___default_40;
9651 var _$avoid_38 = {};
9652 "use strict";
9653
9654 Object.defineProperty(_$avoid_38, "__esModule", {
9655 value: true
9656 });
9657 Object.defineProperty(_$avoid_38, "default", {
9658 enumerable: true,
9659 get: function get() {
9660 return _$noop_40["default"];
9661 }
9662 });
9663 /* removed: var _$noop_40 = require("./noop.js"); */
9664
9665 ;
9666 var _$pointer_43 = {};
9667 "use strict";
9668
9669 Object.defineProperty(_$pointer_43, "__esModule", {
9670 value: true
9671 });
9672 _$pointer_43.getRestrictionRect = getRestrictionRect;
9673 _$pointer_43.restrict = _$pointer_43["default"] = void 0;
9674 /* removed: var _$extend_73 = require("../../utils/extend.js"); */
9675
9676 ;
9677 /* removed: var _$is_76 = require("../../utils/is.js"); */
9678
9679 ;
9680 /* removed: var _$rect_83 = require("../../utils/rect.js"); */
9681
9682 ;
9683 /* removed: var _$base_39 = require("../base.js"); */
9684
9685 ;
9686
9687 function __start_43(_ref) {
9688 var rect = _ref.rect,
9689 startOffset = _ref.startOffset,
9690 state = _ref.state,
9691 interaction = _ref.interaction,
9692 pageCoords = _ref.pageCoords;
9693 var options = state.options;
9694 var elementRect = options.elementRect;
9695 var offset = (0, _$extend_73["default"])({
9696 left: 0,
9697 top: 0,
9698 right: 0,
9699 bottom: 0
9700 }, options.offset || {});
9701
9702 if (rect && elementRect) {
9703 var restriction = getRestrictionRect(options.restriction, interaction, pageCoords);
9704
9705 if (restriction) {
9706 var widthDiff = restriction.right - restriction.left - rect.width;
9707 var heightDiff = restriction.bottom - restriction.top - rect.height;
9708
9709 if (widthDiff < 0) {
9710 offset.left += widthDiff;
9711 offset.right += widthDiff;
9712 }
9713
9714 if (heightDiff < 0) {
9715 offset.top += heightDiff;
9716 offset.bottom += heightDiff;
9717 }
9718 }
9719
9720 offset.left += startOffset.left - rect.width * elementRect.left;
9721 offset.top += startOffset.top - rect.height * elementRect.top;
9722 offset.right += startOffset.right - rect.width * (1 - elementRect.right);
9723 offset.bottom += startOffset.bottom - rect.height * (1 - elementRect.bottom);
9724 }
9725
9726 state.offset = offset;
9727 }
9728
9729 function set(_ref2) {
9730 var coords = _ref2.coords,
9731 interaction = _ref2.interaction,
9732 state = _ref2.state;
9733 var options = state.options,
9734 offset = state.offset;
9735 var restriction = getRestrictionRect(options.restriction, interaction, coords);
9736
9737 if (!restriction) {
9738 return;
9739 }
9740
9741 var rect = _$rect_83.xywhToTlbr(restriction);
9742
9743 coords.x = Math.max(Math.min(rect.right - offset.right, coords.x), rect.left + offset.left);
9744 coords.y = Math.max(Math.min(rect.bottom - offset.bottom, coords.y), rect.top + offset.top);
9745 }
9746
9747 function getRestrictionRect(value, interaction, coords) {
9748 if (_$is_76["default"].func(value)) {
9749 return _$rect_83.resolveRectLike(value, interaction.interactable, interaction.element, [coords.x, coords.y, interaction]);
9750 } else {
9751 return _$rect_83.resolveRectLike(value, interaction.interactable, interaction.element);
9752 }
9753 }
9754
9755 var __defaults_43 = {
9756 restriction: null,
9757 elementRect: null,
9758 offset: null,
9759 endOnly: false,
9760 enabled: false
9761 };
9762 var restrict = {
9763 start: __start_43,
9764 set: set,
9765 defaults: __defaults_43
9766 };
9767 _$pointer_43.restrict = restrict;
9768
9769 var ___default_43 = (0, _$base_39.makeModifier)(restrict, 'restrict');
9770
9771 _$pointer_43["default"] = ___default_43;
9772 var _$edges_42 = {};
9773 "use strict";
9774
9775 Object.defineProperty(_$edges_42, "__esModule", {
9776 value: true
9777 });
9778 _$edges_42.restrictEdges = _$edges_42["default"] = void 0;
9779 /* removed: var _$extend_73 = require("../../utils/extend.js"); */
9780
9781 ;
9782 /* removed: var _$rect_83 = require("../../utils/rect.js"); */
9783
9784 ;
9785 /* removed: var _$base_39 = require("../base.js"); */
9786
9787 ;
9788 /* removed: var _$pointer_43 = require("./pointer.js"); */
9789
9790 ; // This module adds the options.resize.restrictEdges setting which sets min and
9791 // max for the top, left, bottom and right edges of the target being resized.
9792 //
9793 // interact(target).resize({
9794 // edges: { top: true, left: true },
9795 // restrictEdges: {
9796 // inner: { top: 200, left: 200, right: 400, bottom: 400 },
9797 // outer: { top: 0, left: 0, right: 600, bottom: 600 },
9798 // },
9799 // })
9800
9801 var noInner = {
9802 top: +Infinity,
9803 left: +Infinity,
9804 bottom: -Infinity,
9805 right: -Infinity
9806 };
9807 var noOuter = {
9808 top: -Infinity,
9809 left: -Infinity,
9810 bottom: +Infinity,
9811 right: +Infinity
9812 };
9813
9814 function __start_42(_ref) {
9815 var interaction = _ref.interaction,
9816 startOffset = _ref.startOffset,
9817 state = _ref.state;
9818 var options = state.options;
9819 var offset;
9820
9821 if (options) {
9822 var offsetRect = (0, _$pointer_43.getRestrictionRect)(options.offset, interaction, interaction.coords.start.page);
9823 offset = _$rect_83.rectToXY(offsetRect);
9824 }
9825
9826 offset = offset || {
9827 x: 0,
9828 y: 0
9829 };
9830 state.offset = {
9831 top: offset.y + startOffset.top,
9832 left: offset.x + startOffset.left,
9833 bottom: offset.y - startOffset.bottom,
9834 right: offset.x - startOffset.right
9835 };
9836 }
9837
9838 function __set_42(_ref2) {
9839 var coords = _ref2.coords,
9840 edges = _ref2.edges,
9841 interaction = _ref2.interaction,
9842 state = _ref2.state;
9843 var offset = state.offset,
9844 options = state.options;
9845
9846 if (!edges) {
9847 return;
9848 }
9849
9850 var page = (0, _$extend_73["default"])({}, coords);
9851 var inner = (0, _$pointer_43.getRestrictionRect)(options.inner, interaction, page) || {};
9852 var outer = (0, _$pointer_43.getRestrictionRect)(options.outer, interaction, page) || {};
9853 fixRect(inner, noInner);
9854 fixRect(outer, noOuter);
9855
9856 if (edges.top) {
9857 coords.y = Math.min(Math.max(outer.top + offset.top, page.y), inner.top + offset.top);
9858 } else if (edges.bottom) {
9859 coords.y = Math.max(Math.min(outer.bottom + offset.bottom, page.y), inner.bottom + offset.bottom);
9860 }
9861
9862 if (edges.left) {
9863 coords.x = Math.min(Math.max(outer.left + offset.left, page.x), inner.left + offset.left);
9864 } else if (edges.right) {
9865 coords.x = Math.max(Math.min(outer.right + offset.right, page.x), inner.right + offset.right);
9866 }
9867 }
9868
9869 function fixRect(rect, defaults) {
9870 var _arr = ['top', 'left', 'bottom', 'right'];
9871
9872 for (var _i = 0; _i < _arr.length; _i++) {
9873 var edge = _arr[_i];
9874
9875 if (!(edge in rect)) {
9876 rect[edge] = defaults[edge];
9877 }
9878 }
9879
9880 return rect;
9881 }
9882
9883 var __defaults_42 = {
9884 inner: null,
9885 outer: null,
9886 offset: null,
9887 endOnly: false,
9888 enabled: false
9889 };
9890 var restrictEdges = {
9891 noInner: noInner,
9892 noOuter: noOuter,
9893 start: __start_42,
9894 set: __set_42,
9895 defaults: __defaults_42
9896 };
9897 _$edges_42.restrictEdges = restrictEdges;
9898
9899 var ___default_42 = (0, _$base_39.makeModifier)(restrictEdges, 'restrictEdges');
9900
9901 _$edges_42["default"] = ___default_42;
9902 var _$rect_44 = {};
9903 "use strict";
9904
9905 Object.defineProperty(_$rect_44, "__esModule", {
9906 value: true
9907 });
9908 _$rect_44.restrictRect = _$rect_44["default"] = void 0;
9909 /* removed: var _$extend_73 = require("../../utils/extend.js"); */
9910
9911 ;
9912 /* removed: var _$base_39 = require("../base.js"); */
9913
9914 ;
9915 /* removed: var _$pointer_43 = require("./pointer.js"); */
9916
9917 ;
9918
9919 var __defaults_44 = (0, _$extend_73["default"])({
9920 get elementRect() {
9921 return {
9922 top: 0,
9923 left: 0,
9924 bottom: 1,
9925 right: 1
9926 };
9927 },
9928
9929 set elementRect(_) {}
9930
9931 }, _$pointer_43.restrict.defaults);
9932
9933 var restrictRect = {
9934 start: _$pointer_43.restrict.start,
9935 set: _$pointer_43.restrict.set,
9936 defaults: __defaults_44
9937 };
9938 _$rect_44.restrictRect = restrictRect;
9939
9940 var ___default_44 = (0, _$base_39.makeModifier)(restrictRect, 'restrictRect');
9941
9942 _$rect_44["default"] = ___default_44;
9943 var _$size_45 = {};
9944 "use strict";
9945
9946 Object.defineProperty(_$size_45, "__esModule", {
9947 value: true
9948 });
9949 _$size_45.restrictSize = _$size_45["default"] = void 0;
9950 /* removed: var _$extend_73 = require("../../utils/extend.js"); */
9951
9952 ;
9953 /* removed: var _$rect_83 = require("../../utils/rect.js"); */
9954
9955 ;
9956 /* removed: var _$base_39 = require("../base.js"); */
9957
9958 ;
9959 /* removed: var _$edges_42 = require("./edges.js"); */
9960
9961 ;
9962 /* removed: var _$pointer_43 = require("./pointer.js"); */
9963
9964 ;
9965 var noMin = {
9966 width: -Infinity,
9967 height: -Infinity
9968 };
9969 var noMax = {
9970 width: +Infinity,
9971 height: +Infinity
9972 };
9973
9974 function __start_45(arg) {
9975 return _$edges_42.restrictEdges.start(arg);
9976 }
9977
9978 function __set_45(arg) {
9979 var interaction = arg.interaction,
9980 state = arg.state,
9981 rect = arg.rect,
9982 edges = arg.edges;
9983 var options = state.options;
9984
9985 if (!edges) {
9986 return;
9987 }
9988
9989 var minSize = _$rect_83.tlbrToXywh((0, _$pointer_43.getRestrictionRect)(options.min, interaction, arg.coords)) || noMin;
9990 var maxSize = _$rect_83.tlbrToXywh((0, _$pointer_43.getRestrictionRect)(options.max, interaction, arg.coords)) || noMax;
9991 state.options = {
9992 endOnly: options.endOnly,
9993 inner: (0, _$extend_73["default"])({}, _$edges_42.restrictEdges.noInner),
9994 outer: (0, _$extend_73["default"])({}, _$edges_42.restrictEdges.noOuter)
9995 };
9996
9997 if (edges.top) {
9998 state.options.inner.top = rect.bottom - minSize.height;
9999 state.options.outer.top = rect.bottom - maxSize.height;
10000 } else if (edges.bottom) {
10001 state.options.inner.bottom = rect.top + minSize.height;
10002 state.options.outer.bottom = rect.top + maxSize.height;
10003 }
10004
10005 if (edges.left) {
10006 state.options.inner.left = rect.right - minSize.width;
10007 state.options.outer.left = rect.right - maxSize.width;
10008 } else if (edges.right) {
10009 state.options.inner.right = rect.left + minSize.width;
10010 state.options.outer.right = rect.left + maxSize.width;
10011 }
10012
10013 _$edges_42.restrictEdges.set(arg);
10014
10015 state.options = options;
10016 }
10017
10018 var __defaults_45 = {
10019 min: null,
10020 max: null,
10021 endOnly: false,
10022 enabled: false
10023 };
10024 var restrictSize = {
10025 start: __start_45,
10026 set: __set_45,
10027 defaults: __defaults_45
10028 };
10029 _$size_45.restrictSize = restrictSize;
10030
10031 var ___default_45 = (0, _$base_39.makeModifier)(restrictSize, 'restrictSize');
10032
10033 _$size_45["default"] = ___default_45;
10034 var _$rubberband_46 = {};
10035 "use strict";
10036
10037 Object.defineProperty(_$rubberband_46, "__esModule", {
10038 value: true
10039 });
10040 Object.defineProperty(_$rubberband_46, "default", {
10041 enumerable: true,
10042 get: function get() {
10043 return _$noop_40["default"];
10044 }
10045 });
10046 /* removed: var _$noop_40 = require("./noop.js"); */
10047
10048 ;
10049 var _$pointer_48 = {};
10050 "use strict";
10051
10052 Object.defineProperty(_$pointer_48, "__esModule", {
10053 value: true
10054 });
10055 _$pointer_48.snap = _$pointer_48["default"] = void 0;
10056 /* removed: var _$extend_73 = require("../../utils/extend.js"); */
10057
10058 ;
10059 /* removed: var _$getOriginXY_74 = require("../../utils/getOriginXY.js"); */
10060
10061 ;
10062 /* removed: var _$hypot_75 = require("../../utils/hypot.js"); */
10063
10064 ;
10065 /* removed: var _$is_76 = require("../../utils/is.js"); */
10066
10067 ;
10068 /* removed: var _$rect_83 = require("../../utils/rect.js"); */
10069
10070 ;
10071 /* removed: var _$base_39 = require("../base.js"); */
10072
10073 ;
10074
10075 function __start_48(arg) {
10076 var interaction = arg.interaction,
10077 interactable = arg.interactable,
10078 element = arg.element,
10079 rect = arg.rect,
10080 state = arg.state,
10081 startOffset = arg.startOffset;
10082 var options = state.options;
10083 var origin = options.offsetWithOrigin ? getOrigin(arg) : {
10084 x: 0,
10085 y: 0
10086 };
10087 var snapOffset;
10088
10089 if (options.offset === 'startCoords') {
10090 snapOffset = {
10091 x: interaction.coords.start.page.x,
10092 y: interaction.coords.start.page.y
10093 };
10094 } else {
10095 var offsetRect = (0, _$rect_83.resolveRectLike)(options.offset, interactable, element, [interaction]);
10096 snapOffset = (0, _$rect_83.rectToXY)(offsetRect) || {
10097 x: 0,
10098 y: 0
10099 };
10100 snapOffset.x += origin.x;
10101 snapOffset.y += origin.y;
10102 }
10103
10104 var relativePoints = options.relativePoints;
10105 state.offsets = rect && relativePoints && relativePoints.length ? relativePoints.map(function (relativePoint, index) {
10106 return {
10107 index: index,
10108 relativePoint: relativePoint,
10109 x: startOffset.left - rect.width * relativePoint.x + snapOffset.x,
10110 y: startOffset.top - rect.height * relativePoint.y + snapOffset.y
10111 };
10112 }) : [(0, _$extend_73["default"])({
10113 index: 0,
10114 relativePoint: null
10115 }, snapOffset)];
10116 }
10117
10118 function __set_48(arg) {
10119 var interaction = arg.interaction,
10120 coords = arg.coords,
10121 state = arg.state;
10122 var options = state.options,
10123 offsets = state.offsets;
10124 var origin = (0, _$getOriginXY_74["default"])(interaction.interactable, interaction.element, interaction.prepared.name);
10125 var page = (0, _$extend_73["default"])({}, coords);
10126 var targets = [];
10127
10128 if (!options.offsetWithOrigin) {
10129 page.x -= origin.x;
10130 page.y -= origin.y;
10131 }
10132
10133 for (var _i = 0; _i < offsets.length; _i++) {
10134 var _ref;
10135
10136 _ref = offsets[_i];
10137 var offset = _ref;
10138 var relativeX = page.x - offset.x;
10139 var relativeY = page.y - offset.y;
10140
10141 for (var index = 0, len = options.targets.length; index < len; index++) {
10142 var snapTarget = options.targets[index];
10143 var target = void 0;
10144
10145 if (_$is_76["default"].func(snapTarget)) {
10146 target = snapTarget(relativeX, relativeY, interaction._proxy, offset, index);
10147 } else {
10148 target = snapTarget;
10149 }
10150
10151 if (!target) {
10152 continue;
10153 }
10154
10155 targets.push({
10156 x: (_$is_76["default"].number(target.x) ? target.x : relativeX) + offset.x,
10157 y: (_$is_76["default"].number(target.y) ? target.y : relativeY) + offset.y,
10158 range: _$is_76["default"].number(target.range) ? target.range : options.range,
10159 source: snapTarget,
10160 index: index,
10161 offset: offset
10162 });
10163 }
10164 }
10165
10166 var closest = {
10167 target: null,
10168 inRange: false,
10169 distance: 0,
10170 range: 0,
10171 delta: {
10172 x: 0,
10173 y: 0
10174 }
10175 };
10176
10177 for (var _i2 = 0; _i2 < targets.length; _i2++) {
10178 var _target = targets[_i2];
10179 var range = _target.range;
10180 var dx = _target.x - page.x;
10181 var dy = _target.y - page.y;
10182 var distance = (0, _$hypot_75["default"])(dx, dy);
10183 var inRange = distance <= range; // Infinite targets count as being out of range
10184 // compared to non infinite ones that are in range
10185
10186 if (range === Infinity && closest.inRange && closest.range !== Infinity) {
10187 inRange = false;
10188 }
10189
10190 if (!closest.target || (inRange // is the closest target in range?
10191 ? closest.inRange && range !== Infinity // the pointer is relatively deeper in this target
10192 ? distance / range < closest.distance / closest.range // this target has Infinite range and the closest doesn't
10193 : range === Infinity && closest.range !== Infinity || // OR this target is closer that the previous closest
10194 distance < closest.distance : // The other is not in range and the pointer is closer to this target
10195 !closest.inRange && distance < closest.distance)) {
10196 closest.target = _target;
10197 closest.distance = distance;
10198 closest.range = range;
10199 closest.inRange = inRange;
10200 closest.delta.x = dx;
10201 closest.delta.y = dy;
10202 }
10203 }
10204
10205 if (closest.inRange) {
10206 coords.x = closest.target.x;
10207 coords.y = closest.target.y;
10208 }
10209
10210 state.closest = closest;
10211 return closest;
10212 }
10213
10214 function getOrigin(arg) {
10215 var element = arg.interaction.element;
10216 var optionsOrigin = (0, _$rect_83.rectToXY)((0, _$rect_83.resolveRectLike)(arg.state.options.origin, null, null, [element]));
10217 var origin = optionsOrigin || (0, _$getOriginXY_74["default"])(arg.interactable, element, arg.interaction.prepared.name);
10218 return origin;
10219 }
10220
10221 var __defaults_48 = {
10222 range: Infinity,
10223 targets: null,
10224 offset: null,
10225 offsetWithOrigin: true,
10226 origin: null,
10227 relativePoints: null,
10228 endOnly: false,
10229 enabled: false
10230 };
10231 var snap = {
10232 start: __start_48,
10233 set: __set_48,
10234 defaults: __defaults_48
10235 };
10236 _$pointer_48.snap = snap;
10237
10238 var ___default_48 = (0, _$base_39.makeModifier)(snap, 'snap');
10239
10240 _$pointer_48["default"] = ___default_48;
10241 var _$size_49 = {};
10242 "use strict";
10243
10244 Object.defineProperty(_$size_49, "__esModule", {
10245 value: true
10246 });
10247 _$size_49.snapSize = _$size_49["default"] = void 0;
10248 /* removed: var _$extend_73 = require("../../utils/extend.js"); */
10249
10250 ;
10251 /* removed: var _$is_76 = require("../../utils/is.js"); */
10252
10253 ;
10254 /* removed: var _$base_39 = require("../base.js"); */
10255
10256 ;
10257 /* removed: var _$pointer_48 = require("./pointer.js"); */
10258
10259 ;
10260
10261 function ___slicedToArray_49(arr, i) {
10262 return ___arrayWithHoles_49(arr) || ___iterableToArrayLimit_49(arr, i) || ___unsupportedIterableToArray_49(arr, i) || ___nonIterableRest_49();
10263 }
10264
10265 function ___nonIterableRest_49() {
10266 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
10267 }
10268
10269 function ___unsupportedIterableToArray_49(o, minLen) {
10270 if (!o) return;
10271 if (typeof o === "string") return ___arrayLikeToArray_49(o, minLen);
10272 var n = Object.prototype.toString.call(o).slice(8, -1);
10273 if (n === "Object" && o.constructor) n = o.constructor.name;
10274 if (n === "Map" || n === "Set") return Array.from(o);
10275 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return ___arrayLikeToArray_49(o, minLen);
10276 }
10277
10278 function ___arrayLikeToArray_49(arr, len) {
10279 if (len == null || len > arr.length) len = arr.length;
10280
10281 for (var i = 0, arr2 = new Array(len); i < len; i++) {
10282 arr2[i] = arr[i];
10283 }
10284
10285 return arr2;
10286 }
10287
10288 function ___iterableToArrayLimit_49(arr, i) {
10289 if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
10290 var _arr = [];
10291 var _n = true;
10292 var _d = false;
10293 var _e = undefined;
10294
10295 try {
10296 for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
10297 _arr.push(_s.value);
10298
10299 if (i && _arr.length === i) break;
10300 }
10301 } catch (err) {
10302 _d = true;
10303 _e = err;
10304 } finally {
10305 try {
10306 if (!_n && _i["return"] != null) _i["return"]();
10307 } finally {
10308 if (_d) throw _e;
10309 }
10310 }
10311
10312 return _arr;
10313 }
10314
10315 function ___arrayWithHoles_49(arr) {
10316 if (Array.isArray(arr)) return arr;
10317 }
10318
10319 function __start_49(arg) {
10320 var state = arg.state,
10321 edges = arg.edges;
10322 var options = state.options;
10323
10324 if (!edges) {
10325 return null;
10326 }
10327
10328 arg.state = {
10329 options: {
10330 targets: null,
10331 relativePoints: [{
10332 x: edges.left ? 0 : 1,
10333 y: edges.top ? 0 : 1
10334 }],
10335 offset: options.offset || 'self',
10336 origin: {
10337 x: 0,
10338 y: 0
10339 },
10340 range: options.range
10341 }
10342 };
10343 state.targetFields = state.targetFields || [['width', 'height'], ['x', 'y']];
10344
10345 _$pointer_48.snap.start(arg);
10346
10347 state.offsets = arg.state.offsets;
10348 arg.state = state;
10349 }
10350
10351 function __set_49(arg) {
10352 var interaction = arg.interaction,
10353 state = arg.state,
10354 coords = arg.coords;
10355 var options = state.options,
10356 offsets = state.offsets;
10357 var relative = {
10358 x: coords.x - offsets[0].x,
10359 y: coords.y - offsets[0].y
10360 };
10361 state.options = (0, _$extend_73["default"])({}, options);
10362 state.options.targets = [];
10363
10364 for (var _i = 0; _i < (options.targets || []).length; _i++) {
10365 var _ref;
10366
10367 _ref = (options.targets || [])[_i];
10368 var snapTarget = _ref;
10369 var target = void 0;
10370
10371 if (_$is_76["default"].func(snapTarget)) {
10372 target = snapTarget(relative.x, relative.y, interaction);
10373 } else {
10374 target = snapTarget;
10375 }
10376
10377 if (!target) {
10378 continue;
10379 }
10380
10381 for (var _i2 = 0; _i2 < state.targetFields.length; _i2++) {
10382 var _ref2;
10383
10384 _ref2 = state.targetFields[_i2];
10385
10386 var _ref3 = _ref2,
10387 _ref4 = ___slicedToArray_49(_ref3, 2),
10388 xField = _ref4[0],
10389 yField = _ref4[1];
10390
10391 if (xField in target || yField in target) {
10392 target.x = target[xField];
10393 target.y = target[yField];
10394 break;
10395 }
10396 }
10397
10398 state.options.targets.push(target);
10399 }
10400
10401 var returnValue = _$pointer_48.snap.set(arg);
10402
10403 state.options = options;
10404 return returnValue;
10405 }
10406
10407 var __defaults_49 = {
10408 range: Infinity,
10409 targets: null,
10410 offset: null,
10411 endOnly: false,
10412 enabled: false
10413 };
10414 var snapSize = {
10415 start: __start_49,
10416 set: __set_49,
10417 defaults: __defaults_49
10418 };
10419 _$size_49.snapSize = snapSize;
10420
10421 var ___default_49 = (0, _$base_39.makeModifier)(snapSize, 'snapSize');
10422
10423 _$size_49["default"] = ___default_49;
10424 var _$edges_47 = {};
10425 "use strict";
10426
10427 Object.defineProperty(_$edges_47, "__esModule", {
10428 value: true
10429 });
10430 _$edges_47.snapEdges = _$edges_47["default"] = void 0;
10431 /* removed: var _$clone_68 = require("../../utils/clone.js"); */
10432
10433 ;
10434 /* removed: var _$extend_73 = require("../../utils/extend.js"); */
10435
10436 ;
10437 /* removed: var _$base_39 = require("../base.js"); */
10438
10439 ;
10440 /* removed: var _$size_49 = require("./size.js"); */
10441
10442 ;
10443 /**
10444 * @module modifiers/snapEdges
10445 *
10446 * @description
10447 * This module allows snapping of the edges of targets during resize
10448 * interactions.
10449 *
10450 * @example
10451 * interact(target).resizable({
10452 * snapEdges: {
10453 * targets: [interact.snappers.grid({ x: 100, y: 50 })],
10454 * },
10455 * })
10456 *
10457 * interact(target).resizable({
10458 * snapEdges: {
10459 * targets: [
10460 * interact.snappers.grid({
10461 * top: 50,
10462 * left: 50,
10463 * bottom: 100,
10464 * right: 100,
10465 * }),
10466 * ],
10467 * },
10468 * })
10469 */
10470
10471 function __start_47(arg) {
10472 var edges = arg.edges;
10473
10474 if (!edges) {
10475 return null;
10476 }
10477
10478 arg.state.targetFields = arg.state.targetFields || [[edges.left ? 'left' : 'right', edges.top ? 'top' : 'bottom']];
10479 return _$size_49.snapSize.start(arg);
10480 }
10481
10482 var snapEdges = {
10483 start: __start_47,
10484 set: _$size_49.snapSize.set,
10485 defaults: (0, _$extend_73["default"])((0, _$clone_68["default"])(_$size_49.snapSize.defaults), {
10486 targets: null,
10487 range: null,
10488 offset: {
10489 x: 0,
10490 y: 0
10491 }
10492 })
10493 };
10494 _$edges_47.snapEdges = snapEdges;
10495
10496 var ___default_47 = (0, _$base_39.makeModifier)(snapEdges, 'snapEdges');
10497
10498 _$edges_47["default"] = ___default_47;
10499 var _$spring_50 = {};
10500 "use strict";
10501
10502 Object.defineProperty(_$spring_50, "__esModule", {
10503 value: true
10504 });
10505 Object.defineProperty(_$spring_50, "default", {
10506 enumerable: true,
10507 get: function get() {
10508 return _$noop_40["default"];
10509 }
10510 });
10511 /* removed: var _$noop_40 = require("./noop.js"); */
10512
10513 ;
10514 var _$transform_51 = {};
10515 "use strict";
10516
10517 Object.defineProperty(_$transform_51, "__esModule", {
10518 value: true
10519 });
10520 Object.defineProperty(_$transform_51, "default", {
10521 enumerable: true,
10522 get: function get() {
10523 return _$noop_40["default"];
10524 }
10525 });
10526 /* removed: var _$noop_40 = require("./noop.js"); */
10527
10528 ;
10529 var _$all_36 = {};
10530 "use strict";
10531
10532 Object.defineProperty(_$all_36, "__esModule", {
10533 value: true
10534 });
10535 _$all_36["default"] = void 0;
10536 /* removed: var _$aspectRatio_37 = require("./aspectRatio.js"); */
10537
10538 ;
10539 /* removed: var _$avoid_38 = require("./avoid.js"); */
10540
10541 ;
10542 /* removed: var _$edges_42 = require("./restrict/edges.js"); */
10543
10544 ;
10545 /* removed: var _$pointer_43 = require("./restrict/pointer.js"); */
10546
10547 ;
10548 /* removed: var _$rect_44 = require("./restrict/rect.js"); */
10549
10550 ;
10551 /* removed: var _$size_45 = require("./restrict/size.js"); */
10552
10553 ;
10554 /* removed: var _$rubberband_46 = require("./rubberband.js"); */
10555
10556 ;
10557 /* removed: var _$edges_47 = require("./snap/edges.js"); */
10558
10559 ;
10560 /* removed: var _$pointer_48 = require("./snap/pointer.js"); */
10561
10562 ;
10563 /* removed: var _$size_49 = require("./snap/size.js"); */
10564
10565 ;
10566 /* removed: var _$spring_50 = require("./spring.js"); */
10567
10568 ;
10569 /* removed: var _$transform_51 = require("./transform.js"); */
10570
10571 ;
10572 /* eslint-disable node/no-extraneous-import */
10573
10574 var ___default_36 = {
10575 aspectRatio: _$aspectRatio_37["default"],
10576 restrictEdges: _$edges_42["default"],
10577 restrict: _$pointer_43["default"],
10578 restrictRect: _$rect_44["default"],
10579 restrictSize: _$size_45["default"],
10580 snapEdges: _$edges_47["default"],
10581 snap: _$pointer_48["default"],
10582 snapSize: _$size_49["default"],
10583 spring: _$spring_50["default"],
10584 avoid: _$avoid_38["default"],
10585 transform: _$transform_51["default"],
10586 rubberband: _$rubberband_46["default"]
10587 };
10588 _$all_36["default"] = ___default_36;
10589 var _$plugin_41 = {};
10590 "use strict";
10591
10592 Object.defineProperty(_$plugin_41, "__esModule", {
10593 value: true
10594 });
10595 _$plugin_41["default"] = void 0;
10596 /* removed: var _$plugin_65 = require("../snappers/plugin.js"); */
10597
10598 ;
10599 /* removed: var _$all_36 = require("./all.js"); */
10600
10601 ;
10602 /* removed: var _$base_39 = require("./base.js"); */
10603
10604 ;
10605 var __modifiers_41 = {
10606 id: 'modifiers',
10607 install: function install(scope) {
10608 var interact = scope.interactStatic;
10609 scope.usePlugin(_$base_39["default"]);
10610 scope.usePlugin(_$plugin_65["default"]);
10611 interact.modifiers = _$all_36["default"]; // for backwrads compatibility
10612
10613 for (var type in _$all_36["default"]) {
10614 var _all$type = _$all_36["default"][type],
10615 _defaults = _all$type._defaults,
10616 _methods = _all$type._methods;
10617 _defaults._methods = _methods;
10618 scope.defaults.perAction[type] = _defaults;
10619 }
10620 }
10621 };
10622 var ___default_41 = __modifiers_41;
10623 _$plugin_41["default"] = ___default_41;
10624 var _$plugin_52 = {};
10625 "use strict";
10626
10627 Object.defineProperty(_$plugin_52, "__esModule", {
10628 value: true
10629 });
10630 _$plugin_52["default"] = void 0;
10631 var ___default_52 = {};
10632 _$plugin_52["default"] = ___default_52;
10633 var _$PointerEvent_54 = {};
10634 "use strict";
10635
10636 Object.defineProperty(_$PointerEvent_54, "__esModule", {
10637 value: true
10638 });
10639 _$PointerEvent_54.PointerEvent = _$PointerEvent_54["default"] = void 0;
10640 /* removed: var _$pointerUtils_81 = require("../utils/pointerUtils.js"); */
10641
10642 ;
10643 /* removed: var _$BaseEvent_15 = require("../core/BaseEvent.js"); */
10644
10645 ;
10646
10647 function ___typeof_54(obj) {
10648 "@babel/helpers - typeof";
10649
10650 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
10651 ___typeof_54 = function _typeof(obj) {
10652 return typeof obj;
10653 };
10654 } else {
10655 ___typeof_54 = function _typeof(obj) {
10656 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
10657 };
10658 }
10659
10660 return ___typeof_54(obj);
10661 }
10662
10663 function ___classCallCheck_54(instance, Constructor) {
10664 if (!(instance instanceof Constructor)) {
10665 throw new TypeError("Cannot call a class as a function");
10666 }
10667 }
10668
10669 function ___defineProperties_54(target, props) {
10670 for (var i = 0; i < props.length; i++) {
10671 var descriptor = props[i];
10672 descriptor.enumerable = descriptor.enumerable || false;
10673 descriptor.configurable = true;
10674 if ("value" in descriptor) descriptor.writable = true;
10675 Object.defineProperty(target, descriptor.key, descriptor);
10676 }
10677 }
10678
10679 function ___createClass_54(Constructor, protoProps, staticProps) {
10680 if (protoProps) ___defineProperties_54(Constructor.prototype, protoProps);
10681 if (staticProps) ___defineProperties_54(Constructor, staticProps);
10682 return Constructor;
10683 }
10684
10685 function ___inherits_54(subClass, superClass) {
10686 if (typeof superClass !== "function" && superClass !== null) {
10687 throw new TypeError("Super expression must either be null or a function");
10688 }
10689
10690 subClass.prototype = Object.create(superClass && superClass.prototype, {
10691 constructor: {
10692 value: subClass,
10693 writable: true,
10694 configurable: true
10695 }
10696 });
10697 if (superClass) ___setPrototypeOf_54(subClass, superClass);
10698 }
10699
10700 function ___setPrototypeOf_54(o, p) {
10701 ___setPrototypeOf_54 = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
10702 o.__proto__ = p;
10703 return o;
10704 };
10705
10706 return ___setPrototypeOf_54(o, p);
10707 }
10708
10709 function ___createSuper_54(Derived) {
10710 var hasNativeReflectConstruct = ___isNativeReflectConstruct_54();
10711
10712 return function () {
10713 var Super = ___getPrototypeOf_54(Derived),
10714 result;
10715
10716 if (hasNativeReflectConstruct) {
10717 var NewTarget = ___getPrototypeOf_54(this).constructor;
10718
10719 result = Reflect.construct(Super, arguments, NewTarget);
10720 } else {
10721 result = Super.apply(this, arguments);
10722 }
10723
10724 return ___possibleConstructorReturn_54(this, result);
10725 };
10726 }
10727
10728 function ___possibleConstructorReturn_54(self, call) {
10729 if (call && (___typeof_54(call) === "object" || typeof call === "function")) {
10730 return call;
10731 }
10732
10733 return ___assertThisInitialized_54(self);
10734 }
10735
10736 function ___assertThisInitialized_54(self) {
10737 if (self === void 0) {
10738 throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
10739 }
10740
10741 return self;
10742 }
10743
10744 function ___isNativeReflectConstruct_54() {
10745 if (typeof Reflect === "undefined" || !Reflect.construct) return false;
10746 if (Reflect.construct.sham) return false;
10747 if (typeof Proxy === "function") return true;
10748
10749 try {
10750 Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
10751 return true;
10752 } catch (e) {
10753 return false;
10754 }
10755 }
10756
10757 function ___getPrototypeOf_54(o) {
10758 ___getPrototypeOf_54 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
10759 return o.__proto__ || Object.getPrototypeOf(o);
10760 };
10761 return ___getPrototypeOf_54(o);
10762 }
10763
10764 var PointerEvent = /*#__PURE__*/function (_BaseEvent) {
10765 ___inherits_54(PointerEvent, _BaseEvent);
10766
10767 var _super = ___createSuper_54(PointerEvent);
10768 /** */
10769
10770
10771 function PointerEvent(type, pointer, event, eventTarget, interaction, timeStamp) {
10772 var _this;
10773
10774 ___classCallCheck_54(this, PointerEvent);
10775
10776 _this = _super.call(this, interaction);
10777 _this.type = void 0;
10778 _this.originalEvent = void 0;
10779 _this.pointerId = void 0;
10780 _this.pointerType = void 0;
10781 _this["double"] = void 0;
10782 _this.pageX = void 0;
10783 _this.pageY = void 0;
10784 _this.clientX = void 0;
10785 _this.clientY = void 0;
10786 _this.dt = void 0;
10787 _this.eventable = void 0;
10788
10789 _$pointerUtils_81.pointerExtend(___assertThisInitialized_54(_this), event);
10790
10791 if (event !== pointer) {
10792 _$pointerUtils_81.pointerExtend(___assertThisInitialized_54(_this), pointer);
10793 }
10794
10795 _this.timeStamp = timeStamp;
10796 _this.originalEvent = event;
10797 _this.type = type;
10798 _this.pointerId = _$pointerUtils_81.getPointerId(pointer);
10799 _this.pointerType = _$pointerUtils_81.getPointerType(pointer);
10800 _this.target = eventTarget;
10801 _this.currentTarget = null;
10802
10803 if (type === 'tap') {
10804 var pointerIndex = interaction.getPointerIndex(pointer);
10805 _this.dt = _this.timeStamp - interaction.pointers[pointerIndex].downTime;
10806 var interval = _this.timeStamp - interaction.tapTime;
10807 _this["double"] = !!(interaction.prevTap && interaction.prevTap.type !== 'doubletap' && interaction.prevTap.target === _this.target && interval < 500);
10808 } else if (type === 'doubletap') {
10809 _this.dt = pointer.timeStamp - interaction.tapTime;
10810 }
10811
10812 return _this;
10813 }
10814
10815 ___createClass_54(PointerEvent, [{
10816 key: "_subtractOrigin",
10817 value: function _subtractOrigin(_ref) {
10818 var originX = _ref.x,
10819 originY = _ref.y;
10820 this.pageX -= originX;
10821 this.pageY -= originY;
10822 this.clientX -= originX;
10823 this.clientY -= originY;
10824 return this;
10825 }
10826 }, {
10827 key: "_addOrigin",
10828 value: function _addOrigin(_ref2) {
10829 var originX = _ref2.x,
10830 originY = _ref2.y;
10831 this.pageX += originX;
10832 this.pageY += originY;
10833 this.clientX += originX;
10834 this.clientY += originY;
10835 return this;
10836 }
10837 /**
10838 * Prevent the default behaviour of the original Event
10839 */
10840
10841 }, {
10842 key: "preventDefault",
10843 value: function preventDefault() {
10844 this.originalEvent.preventDefault();
10845 }
10846 }]);
10847
10848 return PointerEvent;
10849 }(_$BaseEvent_15["default"]);
10850
10851 _$PointerEvent_54.PointerEvent = _$PointerEvent_54["default"] = PointerEvent;
10852 var _$base_55 = {};
10853 "use strict";
10854
10855 Object.defineProperty(_$base_55, "__esModule", {
10856 value: true
10857 });
10858 _$base_55["default"] = void 0;
10859 /* removed: var _$domUtils_71 = require("../utils/domUtils.js"); */
10860
10861 ;
10862 /* removed: var _$extend_73 = require("../utils/extend.js"); */
10863
10864 ;
10865 /* removed: var _$getOriginXY_74 = require("../utils/getOriginXY.js"); */
10866
10867 ;
10868 /* removed: var _$PointerEvent_54 = require("./PointerEvent.js"); */
10869
10870 ;
10871 var __defaults_55 = {
10872 holdDuration: 600,
10873 ignoreFrom: null,
10874 allowFrom: null,
10875 origin: {
10876 x: 0,
10877 y: 0
10878 }
10879 };
10880 var pointerEvents = {
10881 id: 'pointer-events/base',
10882 install: __install_55,
10883 listeners: {
10884 'interactions:new': addInteractionProps,
10885 'interactions:update-pointer': addHoldInfo,
10886 'interactions:move': moveAndClearHold,
10887 'interactions:down': function interactionsDown(arg, scope) {
10888 downAndStartHold(arg, scope);
10889 fire(arg, scope);
10890 },
10891 'interactions:up': function interactionsUp(arg, scope) {
10892 clearHold(arg);
10893 fire(arg, scope);
10894 tapAfterUp(arg, scope);
10895 },
10896 'interactions:cancel': function interactionsCancel(arg, scope) {
10897 clearHold(arg);
10898 fire(arg, scope);
10899 }
10900 },
10901 PointerEvent: _$PointerEvent_54.PointerEvent,
10902 fire: fire,
10903 collectEventTargets: collectEventTargets,
10904 defaults: __defaults_55,
10905 types: {
10906 down: true,
10907 move: true,
10908 up: true,
10909 cancel: true,
10910 tap: true,
10911 doubletap: true,
10912 hold: true
10913 }
10914 };
10915
10916 function fire(arg, scope) {
10917 var interaction = arg.interaction,
10918 pointer = arg.pointer,
10919 event = arg.event,
10920 eventTarget = arg.eventTarget,
10921 type = arg.type,
10922 _arg$targets = arg.targets,
10923 targets = _arg$targets === void 0 ? collectEventTargets(arg, scope) : _arg$targets;
10924 var pointerEvent = new _$PointerEvent_54.PointerEvent(type, pointer, event, eventTarget, interaction, scope.now());
10925 scope.fire('pointerEvents:new', {
10926 pointerEvent: pointerEvent
10927 });
10928 var signalArg = {
10929 interaction: interaction,
10930 pointer: pointer,
10931 event: event,
10932 eventTarget: eventTarget,
10933 targets: targets,
10934 type: type,
10935 pointerEvent: pointerEvent
10936 };
10937
10938 for (var i = 0; i < targets.length; i++) {
10939 var target = targets[i];
10940
10941 for (var prop in target.props || {}) {
10942 pointerEvent[prop] = target.props[prop];
10943 }
10944
10945 var origin = (0, _$getOriginXY_74["default"])(target.eventable, target.node);
10946
10947 pointerEvent._subtractOrigin(origin);
10948
10949 pointerEvent.eventable = target.eventable;
10950 pointerEvent.currentTarget = target.node;
10951 target.eventable.fire(pointerEvent);
10952
10953 pointerEvent._addOrigin(origin);
10954
10955 if (pointerEvent.immediatePropagationStopped || pointerEvent.propagationStopped && i + 1 < targets.length && targets[i + 1].node !== pointerEvent.currentTarget) {
10956 break;
10957 }
10958 }
10959
10960 scope.fire('pointerEvents:fired', signalArg);
10961
10962 if (type === 'tap') {
10963 // if pointerEvent should make a double tap, create and fire a doubletap
10964 // PointerEvent and use that as the prevTap
10965 var prevTap = pointerEvent["double"] ? fire({
10966 interaction: interaction,
10967 pointer: pointer,
10968 event: event,
10969 eventTarget: eventTarget,
10970 type: 'doubletap'
10971 }, scope) : pointerEvent;
10972 interaction.prevTap = prevTap;
10973 interaction.tapTime = prevTap.timeStamp;
10974 }
10975
10976 return pointerEvent;
10977 }
10978
10979 function collectEventTargets(_ref, scope) {
10980 var interaction = _ref.interaction,
10981 pointer = _ref.pointer,
10982 event = _ref.event,
10983 eventTarget = _ref.eventTarget,
10984 type = _ref.type;
10985 var pointerIndex = interaction.getPointerIndex(pointer);
10986 var pointerInfo = interaction.pointers[pointerIndex]; // do not fire a tap event if the pointer was moved before being lifted
10987
10988 if (type === 'tap' && (interaction.pointerWasMoved || // or if the pointerup target is different to the pointerdown target
10989 !(pointerInfo && pointerInfo.downTarget === eventTarget))) {
10990 return [];
10991 }
10992
10993 var path = _$domUtils_71.getPath(eventTarget);
10994
10995 var signalArg = {
10996 interaction: interaction,
10997 pointer: pointer,
10998 event: event,
10999 eventTarget: eventTarget,
11000 type: type,
11001 path: path,
11002 targets: [],
11003 node: null
11004 };
11005
11006 for (var _i = 0; _i < path.length; _i++) {
11007 var _ref2;
11008
11009 _ref2 = path[_i];
11010 var node = _ref2;
11011 signalArg.node = node;
11012 scope.fire('pointerEvents:collect-targets', signalArg);
11013 }
11014
11015 if (type === 'hold') {
11016 signalArg.targets = signalArg.targets.filter(function (target) {
11017 return target.eventable.options.holdDuration === interaction.pointers[pointerIndex].hold.duration;
11018 });
11019 }
11020
11021 return signalArg.targets;
11022 }
11023
11024 function addInteractionProps(_ref3) {
11025 var interaction = _ref3.interaction;
11026 interaction.prevTap = null; // the most recent tap event on this interaction
11027
11028 interaction.tapTime = 0; // time of the most recent tap event
11029 }
11030
11031 function addHoldInfo(_ref4) {
11032 var down = _ref4.down,
11033 pointerInfo = _ref4.pointerInfo;
11034
11035 if (!down && pointerInfo.hold) {
11036 return;
11037 }
11038
11039 pointerInfo.hold = {
11040 duration: Infinity,
11041 timeout: null
11042 };
11043 }
11044
11045 function clearHold(_ref5) {
11046 var interaction = _ref5.interaction,
11047 pointerIndex = _ref5.pointerIndex;
11048
11049 if (interaction.pointers[pointerIndex].hold) {
11050 clearTimeout(interaction.pointers[pointerIndex].hold.timeout);
11051 }
11052 }
11053
11054 function moveAndClearHold(_ref6, scope) {
11055 var interaction = _ref6.interaction,
11056 pointer = _ref6.pointer,
11057 event = _ref6.event,
11058 eventTarget = _ref6.eventTarget,
11059 duplicate = _ref6.duplicate;
11060 var pointerIndex = interaction.getPointerIndex(pointer);
11061
11062 if (!duplicate && (!interaction.pointerIsDown || interaction.pointerWasMoved)) {
11063 if (interaction.pointerIsDown) {
11064 clearTimeout(interaction.pointers[pointerIndex].hold.timeout);
11065 }
11066
11067 fire({
11068 interaction: interaction,
11069 pointer: pointer,
11070 event: event,
11071 eventTarget: eventTarget,
11072 type: 'move'
11073 }, scope);
11074 }
11075 }
11076
11077 function downAndStartHold(_ref7, scope) {
11078 var interaction = _ref7.interaction,
11079 pointer = _ref7.pointer,
11080 event = _ref7.event,
11081 eventTarget = _ref7.eventTarget,
11082 pointerIndex = _ref7.pointerIndex;
11083 var timer = interaction.pointers[pointerIndex].hold;
11084
11085 var path = _$domUtils_71.getPath(eventTarget);
11086
11087 var signalArg = {
11088 interaction: interaction,
11089 pointer: pointer,
11090 event: event,
11091 eventTarget: eventTarget,
11092 type: 'hold',
11093 targets: [],
11094 path: path,
11095 node: null
11096 };
11097
11098 for (var _i2 = 0; _i2 < path.length; _i2++) {
11099 var _ref8;
11100
11101 _ref8 = path[_i2];
11102 var node = _ref8;
11103 signalArg.node = node;
11104 scope.fire('pointerEvents:collect-targets', signalArg);
11105 }
11106
11107 if (!signalArg.targets.length) {
11108 return;
11109 }
11110
11111 var minDuration = Infinity;
11112
11113 for (var _i3 = 0; _i3 < signalArg.targets.length; _i3++) {
11114 var _ref9;
11115
11116 _ref9 = signalArg.targets[_i3];
11117 var target = _ref9;
11118 var holdDuration = target.eventable.options.holdDuration;
11119
11120 if (holdDuration < minDuration) {
11121 minDuration = holdDuration;
11122 }
11123 }
11124
11125 timer.duration = minDuration;
11126 timer.timeout = setTimeout(function () {
11127 fire({
11128 interaction: interaction,
11129 eventTarget: eventTarget,
11130 pointer: pointer,
11131 event: event,
11132 type: 'hold'
11133 }, scope);
11134 }, minDuration);
11135 }
11136
11137 function tapAfterUp(_ref10, scope) {
11138 var interaction = _ref10.interaction,
11139 pointer = _ref10.pointer,
11140 event = _ref10.event,
11141 eventTarget = _ref10.eventTarget;
11142
11143 if (!interaction.pointerWasMoved) {
11144 fire({
11145 interaction: interaction,
11146 eventTarget: eventTarget,
11147 pointer: pointer,
11148 event: event,
11149 type: 'tap'
11150 }, scope);
11151 }
11152 }
11153
11154 function __install_55(scope) {
11155 scope.pointerEvents = pointerEvents;
11156 scope.defaults.actions.pointerEvents = pointerEvents.defaults;
11157 (0, _$extend_73["default"])(scope.actions.phaselessTypes, pointerEvents.types);
11158 }
11159
11160 var ___default_55 = pointerEvents;
11161 _$base_55["default"] = ___default_55;
11162 var _$holdRepeat_56 = {};
11163 "use strict";
11164
11165 Object.defineProperty(_$holdRepeat_56, "__esModule", {
11166 value: true
11167 });
11168 _$holdRepeat_56["default"] = void 0;
11169 /* removed: var _$base_55 = require("./base.js"); */
11170
11171 ;
11172
11173 function __install_56(scope) {
11174 scope.usePlugin(_$base_55["default"]);
11175 var pointerEvents = scope.pointerEvents; // don't repeat by default
11176
11177 pointerEvents.defaults.holdRepeatInterval = 0;
11178 pointerEvents.types.holdrepeat = scope.actions.phaselessTypes.holdrepeat = true;
11179 }
11180
11181 function onNew(_ref) {
11182 var pointerEvent = _ref.pointerEvent;
11183
11184 if (pointerEvent.type !== 'hold') {
11185 return;
11186 }
11187
11188 pointerEvent.count = (pointerEvent.count || 0) + 1;
11189 }
11190
11191 function onFired(_ref2, scope) {
11192 var interaction = _ref2.interaction,
11193 pointerEvent = _ref2.pointerEvent,
11194 eventTarget = _ref2.eventTarget,
11195 targets = _ref2.targets;
11196
11197 if (pointerEvent.type !== 'hold' || !targets.length) {
11198 return;
11199 } // get the repeat interval from the first eventable
11200
11201
11202 var interval = targets[0].eventable.options.holdRepeatInterval; // don't repeat if the interval is 0 or less
11203
11204 if (interval <= 0) {
11205 return;
11206 } // set a timeout to fire the holdrepeat event
11207
11208
11209 interaction.holdIntervalHandle = setTimeout(function () {
11210 scope.pointerEvents.fire({
11211 interaction: interaction,
11212 eventTarget: eventTarget,
11213 type: 'hold',
11214 pointer: pointerEvent,
11215 event: pointerEvent
11216 }, scope);
11217 }, interval);
11218 }
11219
11220 function endHoldRepeat(_ref3) {
11221 var interaction = _ref3.interaction; // set the interaction's holdStopTime property
11222 // to stop further holdRepeat events
11223
11224 if (interaction.holdIntervalHandle) {
11225 clearInterval(interaction.holdIntervalHandle);
11226 interaction.holdIntervalHandle = null;
11227 }
11228 }
11229
11230 var holdRepeat = {
11231 id: 'pointer-events/holdRepeat',
11232 install: __install_56,
11233 listeners: ['move', 'up', 'cancel', 'endall'].reduce(function (acc, enderTypes) {
11234 acc["pointerEvents:".concat(enderTypes)] = endHoldRepeat;
11235 return acc;
11236 }, {
11237 'pointerEvents:new': onNew,
11238 'pointerEvents:fired': onFired
11239 })
11240 };
11241 var ___default_56 = holdRepeat;
11242 _$holdRepeat_56["default"] = ___default_56;
11243 var _$interactableTargets_57 = {};
11244 "use strict";
11245
11246 Object.defineProperty(_$interactableTargets_57, "__esModule", {
11247 value: true
11248 });
11249 _$interactableTargets_57["default"] = void 0;
11250 /* removed: var _$extend_73 = require("../utils/extend.js"); */
11251
11252 ;
11253
11254 function __install_57(scope) {
11255 var Interactable = scope.Interactable;
11256 Interactable.prototype.pointerEvents = pointerEventsMethod;
11257 var __backCompatOption = Interactable.prototype._backCompatOption;
11258
11259 Interactable.prototype._backCompatOption = function (optionName, newValue) {
11260 var ret = __backCompatOption.call(this, optionName, newValue);
11261
11262 if (ret === this) {
11263 this.events.options[optionName] = newValue;
11264 }
11265
11266 return ret;
11267 };
11268 }
11269
11270 function pointerEventsMethod(options) {
11271 (0, _$extend_73["default"])(this.events.options, options);
11272 return this;
11273 }
11274
11275 var plugin = {
11276 id: 'pointer-events/interactableTargets',
11277 install: __install_57,
11278 listeners: {
11279 'pointerEvents:collect-targets': function pointerEventsCollectTargets(_ref, scope) {
11280 var targets = _ref.targets,
11281 node = _ref.node,
11282 type = _ref.type,
11283 eventTarget = _ref.eventTarget;
11284 scope.interactables.forEachMatch(node, function (interactable) {
11285 var eventable = interactable.events;
11286 var options = eventable.options;
11287
11288 if (eventable.types[type] && eventable.types[type].length && interactable.testIgnoreAllow(options, node, eventTarget)) {
11289 targets.push({
11290 node: node,
11291 eventable: eventable,
11292 props: {
11293 interactable: interactable
11294 }
11295 });
11296 }
11297 });
11298 },
11299 'interactable:new': function interactableNew(_ref2) {
11300 var interactable = _ref2.interactable;
11301
11302 interactable.events.getRect = function (element) {
11303 return interactable.getRect(element);
11304 };
11305 },
11306 'interactable:set': function interactableSet(_ref3, scope) {
11307 var interactable = _ref3.interactable,
11308 options = _ref3.options;
11309 (0, _$extend_73["default"])(interactable.events.options, scope.pointerEvents.defaults);
11310 (0, _$extend_73["default"])(interactable.events.options, options.pointerEvents || {});
11311 }
11312 }
11313 };
11314 var ___default_57 = plugin;
11315 _$interactableTargets_57["default"] = ___default_57;
11316 var _$plugin_58 = {};
11317 "use strict";
11318
11319 Object.defineProperty(_$plugin_58, "__esModule", {
11320 value: true
11321 });
11322 Object.defineProperty(_$plugin_58, "holdRepeat", {
11323 enumerable: true,
11324 get: function get() {
11325 return _$holdRepeat_56["default"];
11326 }
11327 });
11328 Object.defineProperty(_$plugin_58, "interactableTargets", {
11329 enumerable: true,
11330 get: function get() {
11331 return _$interactableTargets_57["default"];
11332 }
11333 });
11334 _$plugin_58.pointerEvents = _$plugin_58["default"] = void 0;
11335 /* removed: var _$base_55 = require("./base.js"); */
11336
11337 ;
11338 _$plugin_58.pointerEvents = _$base_55;
11339 /* removed: var _$holdRepeat_56 = require("./holdRepeat.js"); */
11340
11341 ;
11342 /* removed: var _$interactableTargets_57 = require("./interactableTargets.js"); */
11343
11344 ;
11345 var __plugin_58 = {
11346 id: 'pointer-events',
11347 install: function install(scope) {
11348 scope.usePlugin(_$base_55);
11349 scope.usePlugin(_$holdRepeat_56["default"]);
11350 scope.usePlugin(_$interactableTargets_57["default"]);
11351 }
11352 };
11353 var ___default_58 = __plugin_58;
11354 _$plugin_58["default"] = ___default_58;
11355 var _$plugin_59 = {};
11356 "use strict";
11357
11358 Object.defineProperty(_$plugin_59, "__esModule", {
11359 value: true
11360 });
11361 _$plugin_59["default"] = void 0;
11362 var ___default_59 = {};
11363 _$plugin_59["default"] = ___default_59;
11364 var _$plugin_60 = {};
11365 "use strict";
11366
11367 Object.defineProperty(_$plugin_60, "__esModule", {
11368 value: true
11369 });
11370 _$plugin_60.install = __install_60;
11371 _$plugin_60["default"] = void 0;
11372 /* removed: var _$arr_66 = require("../utils/arr.js"); */
11373
11374 ;
11375 /* removed: var _$extend_73 = require("../utils/extend.js"); */
11376
11377 ;
11378 /* removed: var _$is_76 = require("../utils/is.js"); */
11379
11380 ;
11381 /* removed: var _$pointerUtils_81 = require("../utils/pointerUtils.js"); */
11382
11383 ;
11384 /* removed: var _$rect_83 = require("../utils/rect.js"); */
11385
11386 ;
11387
11388 function __install_60(scope) {
11389 var Interactable = scope.Interactable;
11390 scope.actions.phases.reflow = true;
11391 /**
11392 * ```js
11393 * const interactable = interact(target)
11394 * const drag = { name: drag, axis: 'x' }
11395 * const resize = { name: resize, edges: { left: true, bottom: true }
11396 *
11397 * interactable.reflow(drag)
11398 * interactable.reflow(resize)
11399 * ```
11400 *
11401 * Start an action sequence to re-apply modifiers, check drops, etc.
11402 *
11403 * @param { Object } action The action to begin
11404 * @param { string } action.name The name of the action
11405 * @returns { Promise } A promise that resolves to the `Interactable` when actions on all targets have ended
11406 */
11407
11408 Interactable.prototype.reflow = function (action) {
11409 return reflow(this, action, scope);
11410 };
11411 }
11412
11413 function reflow(interactable, action, scope) {
11414 var elements = _$is_76["default"].string(interactable.target) ? _$arr_66.from(interactable._context.querySelectorAll(interactable.target)) : [interactable.target]; // tslint:disable-next-line variable-name
11415
11416 var Promise = scope.window.Promise;
11417 var promises = Promise ? [] : null;
11418
11419 var _loop = function _loop() {
11420 _ref = elements[_i];
11421 var element = _ref;
11422 var rect = interactable.getRect(element);
11423
11424 if (!rect) {
11425 return "break";
11426 }
11427
11428 var runningInteraction = _$arr_66.find(scope.interactions.list, function (interaction) {
11429 return interaction.interacting() && interaction.interactable === interactable && interaction.element === element && interaction.prepared.name === action.name;
11430 });
11431
11432 var reflowPromise = void 0;
11433
11434 if (runningInteraction) {
11435 runningInteraction.move();
11436
11437 if (promises) {
11438 reflowPromise = runningInteraction._reflowPromise || new Promise(function (resolve) {
11439 runningInteraction._reflowResolve = resolve;
11440 });
11441 }
11442 } else {
11443 var xywh = (0, _$rect_83.tlbrToXywh)(rect);
11444 var coords = {
11445 page: {
11446 x: xywh.x,
11447 y: xywh.y
11448 },
11449 client: {
11450 x: xywh.x,
11451 y: xywh.y
11452 },
11453 timeStamp: scope.now()
11454 };
11455
11456 var event = _$pointerUtils_81.coordsToEvent(coords);
11457
11458 reflowPromise = startReflow(scope, interactable, element, action, event);
11459 }
11460
11461 if (promises) {
11462 promises.push(reflowPromise);
11463 }
11464 };
11465
11466 for (var _i = 0; _i < elements.length; _i++) {
11467 var _ref;
11468
11469 var _ret = _loop();
11470
11471 if (_ret === "break") break;
11472 }
11473
11474 return promises && Promise.all(promises).then(function () {
11475 return interactable;
11476 });
11477 }
11478
11479 function startReflow(scope, interactable, element, action, event) {
11480 var interaction = scope.interactions["new"]({
11481 pointerType: 'reflow'
11482 });
11483 var signalArg = {
11484 interaction: interaction,
11485 event: event,
11486 pointer: event,
11487 eventTarget: element,
11488 phase: 'reflow'
11489 };
11490 interaction.interactable = interactable;
11491 interaction.element = element;
11492 interaction.prepared = (0, _$extend_73["default"])({}, action);
11493 interaction.prevEvent = event;
11494 interaction.updatePointer(event, event, element, true);
11495
11496 interaction._doPhase(signalArg);
11497
11498 var Promise = scope.window.Promise;
11499 var reflowPromise = Promise ? new Promise(function (resolve) {
11500 interaction._reflowResolve = resolve;
11501 }) : null;
11502 interaction._reflowPromise = reflowPromise;
11503 interaction.start(action, interactable, element);
11504
11505 if (interaction._interacting) {
11506 interaction.move(signalArg);
11507 interaction.end(event);
11508 } else {
11509 interaction.stop();
11510 }
11511
11512 interaction.removePointer(event, event);
11513 interaction.pointerIsDown = false;
11514 return reflowPromise;
11515 }
11516
11517 var ___default_60 = {
11518 id: 'reflow',
11519 install: __install_60,
11520 listeners: {
11521 // remove completed reflow interactions
11522 'interactions:stop': function interactionsStop(_ref2, scope) {
11523 var interaction = _ref2.interaction;
11524
11525 if (interaction.pointerType === 'reflow') {
11526 if (interaction._reflowResolve) {
11527 interaction._reflowResolve();
11528 }
11529
11530 _$arr_66.remove(scope.interactions.list, interaction);
11531 }
11532 }
11533 }
11534 };
11535 _$plugin_60["default"] = ___default_60;
11536 var _$displace_69 = {};
11537 "use strict";
11538
11539 Object.defineProperty(_$displace_69, "__esModule", {
11540 value: true
11541 });
11542 _$displace_69["default"] = void 0;
11543 var ___default_69 = {};
11544 _$displace_69["default"] = ___default_69;
11545 var _$exchange_72 = {};
11546 "use strict";
11547
11548 Object.defineProperty(_$exchange_72, "__esModule", {
11549 value: true
11550 });
11551 _$exchange_72.exchange = void 0;
11552 var exchange = {};
11553 _$exchange_72.exchange = exchange;
11554 var _$plugin_85 = {};
11555 "use strict";
11556
11557 Object.defineProperty(_$plugin_85, "__esModule", {
11558 value: true
11559 });
11560 _$plugin_85["default"] = void 0;
11561 var ___default_85 = {};
11562 _$plugin_85["default"] = ___default_85;
11563 var _$interactjs_34 = {
11564 exports: {}
11565 };
11566 "use strict";
11567
11568 Object.defineProperty(_$interactjs_34.exports, "__esModule", {
11569 value: true
11570 });
11571 _$interactjs_34.exports["default"] = void 0;
11572 /* removed: var _$plugin_5 = require("../actions/plugin.js"); */
11573
11574 ;
11575 /* removed: var _$plugin_7 = require("../arrange/plugin.js"); */
11576
11577 ;
11578 /* removed: var _$plugin_8 = require("../auto-scroll/plugin.js"); */
11579
11580 ;
11581 /* removed: var _$plugin_13 = require("../auto-start/plugin.js"); */
11582
11583 ;
11584 /* removed: var _$plugin_14 = require("../clone/plugin.js"); */
11585
11586 ;
11587 /* removed: var _$interactablePreventDefault_25 = require("../core/interactablePreventDefault.js"); */
11588
11589 ;
11590 /* removed: var _$plugin_30 = require("../dev-tools/plugin.js"); */
11591
11592 ;
11593 /* removed: var _$plugin_31 = require("../feedback/plugin.js"); */
11594
11595 ;
11596 /* removed: var _$plugin_32 = require("../inertia/plugin.js"); */
11597
11598 ;
11599 /* removed: var _$interact_33 = require("../interact/index.js"); */
11600
11601 ;
11602 /* removed: var _$plugin_41 = require("../modifiers/plugin.js"); */
11603
11604 ;
11605 /* removed: var _$plugin_52 = require("../multi-target/plugin.js"); */
11606
11607 ;
11608 /* removed: var _$plugin_53 = require("../offset/plugin.js"); */
11609
11610 ;
11611 /* removed: var _$plugin_58 = require("../pointer-events/plugin.js"); */
11612
11613 ;
11614 /* removed: var _$plugin_59 = require("../react/plugin.js"); */
11615
11616 ;
11617 /* removed: var _$plugin_60 = require("../reflow/plugin.js"); */
11618
11619 ;
11620 /* removed: var _$displace_69 = require("../utils/displace.js"); */
11621
11622 ;
11623 /* removed: var _$exchange_72 = require("../utils/exchange.js"); */
11624
11625 ;
11626 /* removed: var _$pointerUtils_81 = require("../utils/pointerUtils.js"); */
11627
11628 ;
11629 /* removed: var _$plugin_85 = require("../vue/plugin.js"); */
11630
11631 ;
11632
11633 function ___typeof_34(obj) {
11634 "@babel/helpers - typeof";
11635
11636 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
11637 ___typeof_34 = function _typeof(obj) {
11638 return typeof obj;
11639 };
11640 } else {
11641 ___typeof_34 = function _typeof(obj) {
11642 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
11643 };
11644 }
11645
11646 return ___typeof_34(obj);
11647 }
11648
11649 _$interact_33["default"].use(_$plugin_52["default"]);
11650
11651 _$interact_33["default"].use(_$interactablePreventDefault_25["default"]);
11652
11653 _$interact_33["default"].use(_$plugin_53["default"]); // interaction element cloning
11654
11655
11656 _$interact_33["default"].use(_$plugin_14["default"]); // sortable and swappable
11657
11658
11659 _$interact_33["default"].use(_$plugin_7["default"]); // pointerEvents
11660
11661
11662 _$interact_33["default"].use(_$plugin_58["default"]); // inertia
11663
11664
11665 _$interact_33["default"].use(_$plugin_32["default"]); // snap, resize, etc.
11666
11667
11668 _$interact_33["default"].use(_$plugin_41["default"]); // autoStart, hold
11669
11670
11671 _$interact_33["default"].use(_$plugin_13["default"]); // drag and drop, resize, gesture
11672
11673
11674 _$interact_33["default"].use(_$plugin_5["default"]); // autoScroll
11675
11676
11677 _$interact_33["default"].use(_$plugin_8["default"]); // reflow
11678
11679
11680 _$interact_33["default"].use(_$plugin_60["default"]);
11681
11682 _$interact_33["default"].use(_$plugin_31["default"]);
11683
11684 _$interact_33["default"].use(_$plugin_85["default"]);
11685
11686 _$interact_33["default"].use(_$plugin_59["default"]);
11687
11688 _$interact_33["default"].__utils = {
11689 exchange: _$exchange_72.exchange,
11690 displace: _$displace_69,
11691 pointer: _$pointerUtils_81
11692 }; // eslint-disable-next-line no-undef
11693
11694 if ("development" !== 'production') {
11695 _$interact_33["default"].use(_$plugin_30["default"]);
11696 }
11697
11698 var ___default_34 = _$interact_33["default"];
11699 _$interactjs_34.exports["default"] = ___default_34;
11700
11701 if (("object" === "undefined" ? "undefined" : ___typeof_34(_$interactjs_34)) === 'object' && !!_$interactjs_34) {
11702 try {
11703 _$interactjs_34.exports = _$interact_33["default"];
11704 } catch (_unused) {}
11705 }
11706
11707 _$interact_33["default"]["default"] = _$interact_33["default"];
11708 _$interactjs_34 = _$interactjs_34.exports;
11709 var _$index_86 = {
11710 exports: {}
11711 };
11712 "use strict";
11713
11714 Object.defineProperty(_$index_86.exports, "__esModule", {
11715 value: true
11716 });
11717 _$index_86.exports["default"] = void 0;
11718 /* removed: var _$interactjs_34 = require("@interactjs/interactjs/index"); */
11719
11720 ;
11721
11722 function ___typeof_86(obj) {
11723 "@babel/helpers - typeof";
11724
11725 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
11726 ___typeof_86 = function _typeof(obj) {
11727 return typeof obj;
11728 };
11729 } else {
11730 ___typeof_86 = function _typeof(obj) {
11731 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
11732 };
11733 }
11734
11735 return ___typeof_86(obj);
11736 }
11737
11738 var ___default_86 = _$interactjs_34["default"];
11739 _$index_86.exports["default"] = ___default_86;
11740
11741 if (("object" === "undefined" ? "undefined" : ___typeof_86(_$index_86)) === 'object' && !!_$index_86) {
11742 try {
11743 _$index_86.exports = _$interactjs_34["default"];
11744 } catch (_unused) {}
11745 }
11746
11747 _$interactjs_34["default"]["default"] = _$interactjs_34["default"];
11748 _$index_86 = _$index_86.exports;
11749 return _$index_86;
11750}); //# sourceMappingURL=interact.js.map
\No newline at end of file