dragselect 2.1.2 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,i,r){return i&&t(e.prototype,i),r&&t(e,r),e}function r(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function n(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}function o(e){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function a(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function l(e,t,i){return(l=a()?Reflect.construct:function(e,t,i){var r=[null];r.push.apply(r,t);var n=new(Function.bind.apply(e,r));return i&&s(n,i.prototype),n}).apply(null,arguments)}function c(e){var t="function"==typeof Map?new Map:void 0;return(c=function(e){if(null===e||(i=e,-1===Function.toString.call(i).indexOf("[native code]")))return e;var i;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return l(e,arguments,o(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),s(r,e)})(e)}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function d(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?u(e):t}function h(e){var t=a();return function(){var i,r=o(e);if(t){var n=o(this).constructor;i=Reflect.construct(r,arguments,n)}else i=r.apply(this,arguments);return d(this,i)}}function f(e,t,i){return(f="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,i){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=o(e)););return e}(e,t);if(r){var n=Object.getOwnPropertyDescriptor(r,t);return n.get?n.get.call(i):n.value}})(e,t,i||e)}function v(e){return function(e){if(Array.isArray(e))return S(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return S(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return S(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=new Array(t);i<t;i++)r[i]=e[i];return r}var m=function(e,t,i){var r=e.x,n=e.y,o=i.x,s=i.y;return{"+":{x:r+o,y:n+s},"-":{x:r-o,y:n-s},"*":{x:r*o,y:n*s},"/":{x:r/o,y:n/s}}[t]},g=function(e){return{x:e.left,y:e.top}},p=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return{left:e.x,top:e.y,right:e.x,bottom:e.y,width:t,height:t}},y=function(){var e,t,i,r;return{y:(null===(e=document.body)||void 0===e?void 0:e.scrollTop)||(null===(t=document.documentElement)||void 0===t?void 0:t.scrollTop)||0,x:(null===(i=document.body)||void 0===i?void 0:i.scrollLeft)||(null===(r=document.documentElement)||void 0===r?void 0:r.scrollLeft)||0}},b=function(e){return!e||e instanceof Document?y():{x:e.scrollLeft>=0?e.scrollLeft:y().x,y:e.scrollTop>=0?e.scrollTop:y().y}},_=function(e){var t=e.elementRect,i=e.containerRect,r=e.tolerance,n=void 0===r?{x:0,y:0}:r,o=[];return t.top-n.y<i.top&&o.push("top"),t.left-n.x<i.left&&o.push("left"),t.bottom+n.y>i.bottom&&o.push("bottom"),t.right+n.y>i.right&&o.push("right"),o},D=function(e){var t=e.event;return{x:t.clientX,y:t.clientY}},w=function(e){var t={x:0,y:0},i=window.getComputedStyle(e);if(!i.transform||"none"===i.transform)return t;if(i.transform.indexOf("3d")>=0){var r=i.transform.trim().match(/matrix3d\((.*?)\)/);if(r&&r.length){var n,o=null===(n=r[1])||void 0===n?void 0:n.split(",");t.x=parseInt(o[12])||0,t.y=parseInt(o[13])||0}return t}var s=i.transform.trim().match(/matrix\((.*?)\)/);if(s&&s.length){var a,l=null===(a=s[1])||void 0===a?void 0:a.split(",");t.x=parseInt(l[4])||0,t.y=parseInt(l[5])||0}return t},x=function(e,t){return t?function(e){var t=e.style.transform;if(!t||t.indexOf("translate")<0)return w(e);var i={x:0,y:0},r=t.trim().match(/translate[3dD]*?\(.*?\)/);if(r){var n,o=null===(n=r[0])||void 0===n?void 0:n.split("(");if(o){var s,a=null===(s=o[1])||void 0===s?void 0:s.split(",");i.x=parseInt(a[0])||0,i.y=parseInt(a[1])||0}}return i.x||i.x?i:w(e)}(e):function(e){var t=e.style,i={x:parseInt(t.left)||0,y:parseInt(t.top)||0};if(!i.x&&!i.x){var r=window.getComputedStyle(e);return{x:parseInt(r.left)||0,y:parseInt(r.top)||0}}return i}(e)},k=function(e){var t=e.computedStyle,i=e.node,r=t.position;i instanceof HTMLDocument||("absolute"===r||"relative"===r||"fixed"===r)||(i.style.position="relative")},E=function(e,t){return e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top},I=function(e){var t=e.element,i=e.posDirection,r=e.containerRect,n=e.useTransform,o=x(t,n),s=m(o,"+",i);P(t,s,n);var a=t.getBoundingClientRect();!function(e){var t=e.element,i=e.edges,r=e.elementRect,n=e.containerRect,o=e.elementPos,s=e.useTransform;i.includes("top")&&P(t,{y:o.y+n.top-r.top,x:o.x},s),i.includes("left")&&P(t,{y:o.y,x:o.x+n.left-r.left},s),i.includes("bottom")&&P(t,{y:o.y+n.bottom-r.bottom,x:o.x},s),i.includes("right")&&P(t,{y:o.y,x:o.x+n.right-r.right},s)}({element:t,edges:_({elementRect:a,containerRect:r}),elementRect:a,containerRect:r,elementPos:s,useTransform:n})},P=function(e,t,i){if(i){var r=e.style.transform;e.style.transform="translate3d(".concat(t.x,"px,").concat(t.y,"px,1px) ").concat(r.replace(/translate.*?\)/g,""))}else e.style.left="".concat(t.x,"px"),e.style.top="".concat(t.y,"px");return e},A=function(e){return e?!Array.isArray(e)&&(e instanceof HTMLElement||e instanceof SVGElement)?[e]:v(e):[]},L=function(e,t){e.style.left="".concat(t.left,"px"),e.style.top="".concat(t.top,"px"),e.style.width="".concat(t.width,"px"),e.style.height="".concat(t.height,"px")},C=function(){function t(i){var n,o,s,a=this,l=i.area,c=i.PS,u=i.zoom;e(this,t),r(this,"_modificationCallback",void 0),r(this,"_modificationObserver",void 0),r(this,"_zoom",void 0),r(this,"_node",void 0),r(this,"_parentNodes",void 0),r(this,"_computedStyle",void 0),r(this,"_computedBorder",void 0),r(this,"_rect",void 0),r(this,"start",(function(){var e,t,i;e=a.parentNodes,t=a._modificationCallback,i=a._modificationObserver,window.addEventListener("resize",t),window.addEventListener("scroll",t),e.forEach((function(e,t){i.observe(e,{childList:0!==t,attributes:!0})}))})),r(this,"reset",(function(){a._computedStyle=void 0,a._rect=void 0,a._computedBorder=void 0,a._parentNodes=void 0})),r(this,"stop",(function(){var e,t;e=a._modificationObserver,t=a._modificationCallback,window.removeEventListener("resize",t),window.removeEventListener("scroll",t),e.disconnect(),a.reset()})),r(this,"scroll",(function(e,t){!function(e,t,i){if(t.length){var r=document&&document.documentElement&&document.documentElement.scrollTop&&document.documentElement,n=e instanceof HTMLDocument?r||document.body:e,o=t.includes("top")&&n.scrollTop>0,s=t.includes("bottom")&&n.scrollTop<n.scrollHeight,a=t.includes("left")&&n.scrollLeft>0,l=t.includes("right")&&n.scrollLeft<n.scrollWidth;o&&(n.scrollTop-=1*i),s&&(n.scrollTop+=1*i),a&&(n.scrollLeft-=1*i),l&&(n.scrollLeft+=1*i)}}(a._node,e,t),a.PubSub.publish("Area:scroll",{scroll_directions:e,scroll_multiplier:t})})),this._node=l,this._zoom=u,this.PubSub=c,k({computedStyle:this.computedStyle,node:this._node}),this._modificationCallback=(n=function(e){a.reset(),a.PubSub.publish("Area:modified",{event:e,item:a})},o=60,function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];var r=function(){s=null,n.apply(void 0,t)};clearTimeout(s),s=setTimeout(r,o)}),this._modificationObserver=new MutationObserver(this._modificationCallback),setTimeout((function(){a.reset(),a.PubSub.publish("Area:modified",{event:event,item:a})})),this.PubSub.subscribe("Interaction:init",this.start),this.PubSub.subscribe("Interaction:end",this.reset)}return i(t,[{key:"HTMLNode",get:function(){return this._node}},{key:"computedBorder",get:function(){return this._computedBorder?this._computedBorder:{top:parseInt(this.computedStyle.borderTopWidth),bottom:parseInt(this.computedStyle.borderBottomWidth),left:parseInt(this.computedStyle.borderLeftWidth),right:parseInt(this.computedStyle.borderRightWidth)}}},{key:"computedStyle",get:function(){return this._computedStyle?this._computedStyle:this.HTMLNode instanceof HTMLDocument?this._computedStyle=window.getComputedStyle(this.HTMLNode.body||this.HTMLNode.documentElement):this._computedStyle=window.getComputedStyle(this.HTMLNode)}},{key:"rect",get:function(){return this._rect?this._rect:this._rect=function(e,t){if(e instanceof Document)return{top:0,left:0,bottom:0,right:0,width:window.innerWidth,height:window.innerHeight};var i=e.getBoundingClientRect();return{top:i.top,left:i.left,bottom:i.bottom,right:i.right,width:(e.clientWidth||i.width)*t,height:(e.clientHeight||i.height)*t}}(this.HTMLNode,this._zoom)}},{key:"parentNodes",get:function(){if(this._parentNodes)return this._parentNodes;return this._parentNodes=function e(t){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=null===(i=t[r])||void 0===i?void 0:i.parentNode;return n?(t.push(n),e(t,++r)):t}([this.HTMLNode]),this._parentNodes}}]),t}(),T=function(){function t(i){var n=this,o=i.DS,s=i.dragKeys,a=i.draggability,l=i.keyboardDragSpeed,c=i.useTransform,u=i.zoom;e(this,t),r(this,"_useTransform",void 0),r(this,"_prevCursorPos",void 0),r(this,"_prevScrollPos",void 0),r(this,"_elements",[]),r(this,"_draggability",void 0),r(this,"_dragKeys",void 0),r(this,"_dragKeysFlat",void 0),r(this,"_keyboardDragSpeed",void 0),r(this,"_zoom",void 0),r(this,"keyboardDrag",(function(e){var t=e.event,i=e.key;if(console.log(t,i,n._draggability),n._dragKeysFlat.includes(i)&&n.DS.SelectedSet.size&&n._draggability){n._isKeyboard=!0,n.DS.publish("Interaction:start",{event:t,isDragging:!0}),n._elements=n.DS.getSelection(),n.handleZIndex(!0);var r=function(e){var t=e.shiftKey,i=e.keyboardDragSpeed,r=e.zoom,n=e.key,o=e.dragKeys,s=e.scrollDiff,a=e.canScroll,l=e.scrollCallback,c={x:0,y:0},u=t?4*i*r:i*r;return o.left.includes(n)&&(c.x=s.x||-u,t||s.x||!a||l(["left"],i)),o.right.includes(n)&&(c.x=s.x||u,t||s.x||!a||l(["right"],i)),o.up.includes(n)&&(c.y=s.y||-u,t||s.y||!a||l(["top"],i)),o.down.includes(n)&&(c.y=s.y||u,t||s.y||!a||l(["bottom"],i)),c}({shiftKey:n.DS.stores.KeyStore.currentValues.includes("shift"),keyboardDragSpeed:n._keyboardDragSpeed,zoom:n._zoom,key:i,scrollCallback:n.DS.Area.scroll,scrollDiff:n._scrollDiff,canScroll:n.DS.stores.ScrollStore.canScroll,dragKeys:n._dragKeys});n._elements.forEach((function(e){return I({element:e,posDirection:r,containerRect:n.DS.SelectorArea.rect,useTransform:n._useTransform})})),n.DS.publish("Interaction:update",{event:t,isDragging:!0}),n._isKeyboard=!1}})),r(this,"keyboardEnd",(function(e){var t=e.event,i=e.key;n._dragKeysFlat.includes(i)&&n.DS.SelectedSet.size&&n._draggability&&(n._isKeyboard=!0,n.DS.publish("Interaction:end",{event:t,isDragging:!0}),n._isKeyboard=!1)})),r(this,"start",(function(e){e.isDragging&&!n._isKeyboard&&(n._prevCursorPos=null,n._prevScrollPos=null,n._elements=n.DS.getSelection(),n.handleZIndex(!0))})),r(this,"stop",(function(){n._isKeyboard||(n._prevCursorPos=null,n._prevScrollPos=null,n.handleZIndex(!1),n._elements=[])})),r(this,"update",(function(e){if(e.isDragging&&n._elements.length&&!n._isKeyboard){var t=m(n._cursorDiff,"+",n._scrollDiff);n._elements.forEach((function(e){return I({element:e,posDirection:t,containerRect:n.DS.SelectorArea.rect,useTransform:n._useTransform})}))}})),r(this,"handleZIndex",(function(e){n._elements.forEach((function(t){return t.style.zIndex="".concat((parseInt(t.style.zIndex)||0)+e?9999:-9998)}))})),this.DS=o,this._useTransform=c,this._keyboardDragSpeed=l,this._zoom=u,this._draggability=a,this._dragKeys={up:s.up.map((function(e){return e.toLowerCase()})),down:s.down.map((function(e){return e.toLowerCase()})),left:s.left.map((function(e){return e.toLowerCase()})),right:s.right.map((function(e){return e.toLowerCase()}))},this._dragKeysFlat=[].concat(v(this._dragKeys.up),v(this._dragKeys.down),v(this._dragKeys.left),v(this._dragKeys.right)),this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:end",this.stop),this.DS.subscribe("Interaction:update",this.update),this.DS.subscribe("KeyStore:down",this.keyboardDrag),this.DS.subscribe("KeyStore:up",this.keyboardEnd)}return i(t,[{key:"_cursorDiff",get:function(){var e=this.DS.stores.PointerStore.currentVal,t=this._prevCursorPos?m(e,"-",this._prevCursorPos):{x:0,y:0};return this._prevCursorPos=e,t}},{key:"_scrollDiff",get:function(){var e=this.DS.stores.ScrollStore.currentVal,t=this._prevScrollPos?m(e,"-",this._prevScrollPos):{x:0,y:0};return this._prevScrollPos=e,t}}]),t}(),V=function(){function t(i){var n=this,o=i.areaElement,s=i.DS,a=i.draggability,l=i.immediateDrag;e(this,t),r(this,"_areaElement",void 0),r(this,"_draggability",void 0),r(this,"_immediateDrag",void 0),r(this,"isInteracting",void 0),r(this,"isDragging",void 0),r(this,"init",(function(){n.stop(),n._areaElement.addEventListener("mousedown",n.start),n._areaElement.addEventListener("touchstart",n.start,{passive:!1}),n.DS.publish("Interaction:init",{})})),r(this,"start",(function(e){"touchstart"===e.type&&e.preventDefault(),n._canInteract(e)&&(n.isInteracting=!0,n.isDragging=n.isDragEvent(e),n.DS.publish("Interaction:start",{event:e,isDragging:n.isDragging}),document.addEventListener("mouseup",n.reset),document.addEventListener("touchend",n.reset))})),r(this,"isDragEvent",(function(e){return!(!n._draggability||n.DS.stores.KeyStore.isMultiSelectKeyPressed(e)||!n.DS.SelectableSet.has(e.target))&&(n._immediateDrag&&(n.DS.SelectedSet.size?n.DS.SelectedSet.has(e.target)||(n.DS.SelectedSet.clear(),n.DS.SelectedSet.add(e.target)):n.DS.SelectedSet.add(e.target)),!!n.DS.SelectedSet.has(e.target))})),r(this,"onClick",(function(e){var t=e.event;if(n._canInteract(t)&&!(t.detail>0)){var i=n.DS,r=i.stores,o=r.PointerStore,s=r.KeyStore,a=i.SelectableSet,l=i.SelectedSet,c=i.publish;o.start(t);var u=t.target;a.has(u)&&(s.isMultiSelectKeyPressed(t)||l.clear(),l.toggle(u),c("Interaction:end",{event:t,isDragging:n.isDragging}))}})),r(this,"stop",(function(){n.isInteracting=!1,n.isDragging=!1,n._areaElement.removeEventListener("mousedown",n.start),n._areaElement.removeEventListener("touchstart",n.start,{passive:!1}),document.removeEventListener("mouseup",n.reset),document.removeEventListener("touchend",n.reset)})),r(this,"update",(function(e){var t=e.event,i=e.data;n.isInteracting&&n.DS.publish("Interaction:update",{event:t,data:i,isDragging:n.isDragging})})),r(this,"reset",(function(e){var t=n.isDragging;n.stop(),n.init(),n.DS.publish("Interaction:end",{event:e,isDragging:t})})),this._areaElement=o,this._draggability=a,this._immediateDrag=l,this.DS=s,this.DS.subscribe("PointerStore:updated",this.update),this.DS.subscribe("Selectable:click",this.onClick),this.DS.subscribe("Selectable:pointer",(function(e){var t=e.event;return n.start(t)})),this.DS.subscribe("Area:scroll",this.update)}return i(t,[{key:"_canInteract",value:function(e){return!(2===e.button||this.isInteracting||e.target&&!this.DS.SelectorArea.isInside(e.target))}}]),t}(),N=function t(){var i=this;e(this,t),r(this,"subscribers",{}),r(this,"subscribe",(function(e,t){return Array.isArray(i.subscribers[e])||(i.subscribers[e]=[]),i.subscribers[e].push(t),i.subscribers[e].length-1})),r(this,"unsubscribe",(function(e,t,r){r>=0?i.subscribers[e].splice(r,1):t&&(i.subscribers[e]=i.subscribers[e].filter((function(e){return e!==t})))})),r(this,"publish",(function(e,t){Array.isArray(i.subscribers[e])&&i.subscribers[e].forEach((function(e){return e(t)}))}))},M=function(t){n(a,c(Set));var s=h(a);function a(t){var i,n=t.elements,o=t.className,l=t.hoverClassName,c=t.draggability,d=t.useTransform,h=t.DS;return e(this,a),r(u(i=s.call(this)),"_initElements",void 0),r(u(i),"_className",void 0),r(u(i),"_hoverClassName",void 0),r(u(i),"_useTransform",void 0),r(u(i),"_draggability",void 0),r(u(i),"init",(function(){return i._initElements.forEach((function(e){return i.add(e)}))})),r(u(i),"clear",(function(){return i.forEach((function(e){return i.delete(e)}))})),r(u(i),"_onClick",(function(e){return i.DS.publish("Selectable:click",{event:e})})),r(u(i),"_onPointer",(function(e){return i.DS.publish("Selectable:pointer",{event:e})})),r(u(i),"addAll",(function(e){return e.forEach((function(e){return i.add(e)}))})),r(u(i),"deleteAll",(function(e){return e.forEach((function(e){return i.delete(e)}))})),i.DS=h,i._initElements=A(n),i._className=o,i._hoverClassName=l,i._useTransform=d,i._draggability=c,i.DS.subscribe("Interaction:init",i.init),i}return i(a,[{key:"add",value:function(e){return e.classList.add(this._className),e.addEventListener("click",this._onClick),e.addEventListener("mousedown",this._onPointer),e.addEventListener("touchstart",this._onPointer,{passive:!1}),this._draggability&&!this._useTransform&&k({computedStyle:window.getComputedStyle(e),node:e}),f(o(a.prototype),"add",this).call(this,e)}},{key:"delete",value:function(e){return e.classList.remove(this._className),e.classList.remove(this._hoverClassName),e.removeEventListener("click",this._onClick),e.removeEventListener("mousedown",this._onPointer),e.removeEventListener("touchstart",this._onPointer,{passive:!1}),f(o(a.prototype),"delete",this).call(this,e)}},{key:"elements",get:function(){return Array.from(this.values())}}]),a}(),K=function(t){n(a,c(Set));var s=h(a);function a(t){var i,n=t.className,o=t.DS;return e(this,a),r(u(i=s.call(this)),"_className",void 0),r(u(i),"clear",(function(){return i.forEach((function(e){return i.delete(e)}))})),r(u(i),"addAll",(function(e){return e.forEach((function(e){return i.add(e)}))})),r(u(i),"deleteAll",(function(e){return e.forEach((function(e){return i.delete(e)}))})),i.DS=o,i._className=n,i}return i(a,[{key:"add",value:function(e){if(!f(o(a.prototype),"has",this).call(this,e))return f(o(a.prototype),"add",this).call(this,e),e.classList.add(this._className),this.DS.publish("Selected:added",{items:this.elements,item:e}),e.style.zIndex="".concat((parseInt(e.style.zIndex)||0)+1),this}},{key:"delete",value:function(e){if(f(o(a.prototype),"has",this).call(this,e)){var t=f(o(a.prototype),"delete",this).call(this,e);return e.classList.remove(this._className),this.DS.publish("Selected:removed",{items:this.elements,item:e}),e.style.zIndex="".concat((parseInt(e.style.zIndex)||0)-1),t}}},{key:"toggle",value:function(e){return this.has(e)?this.delete(e):this.add(e),e}},{key:"elements",get:function(){return Array.from(this.values())}}]),a}(),z=function(){function t(i){var n=this,o=i.DS,s=i.hoverClassName,a=i.multiSelectToggling;e(this,t),r(this,"_prevSelectedSet",void 0),r(this,"_hoverClassName",void 0),r(this,"_multiSelectToggling",void 0),r(this,"start",(function(e){var t=e.event;e.isDragging||(n._storePrevious(t),n._handleInsideSelection(!0,t))})),r(this,"update",(function(e){e.isDragging||n._handleInsideSelection()})),r(this,"_handleInsideSelection",(function(e,t){for(var i=n.DS,r=i.SelectableSet,o=i.SelectorArea,s=i.Selector,a=r.elements.map((function(e){return[e,e.getBoundingClientRect()]})),l=[],c=[],u=0,d=a.length;u<d;u++)o.isInside(a[u][0],a[u][1])&&(E(a[u][1],s.rect)?l.push(a[u][0]):c.push(a[u][0]));var h=n.DS.stores.KeyStore.isMultiSelectKeyPressed(t)&&n._multiSelectToggling;l.forEach((function(t){return function(e){var t=e.element,i=e.force,r=e.multiSelectionToggle,n=e.SelectedSet,o=e.hoverClassName;t.classList.contains(o)&&!i||(n.has(t)?r&&n.delete(t):n.add(t),t.classList.add(o))}({element:t,force:e,multiSelectionToggle:h,SelectedSet:n.DS.SelectedSet,hoverClassName:n._hoverClassName})})),c.forEach((function(t){return function(e){var t=e.element,i=e.force,r=e.SelectedSet,n=e.PrevSelectedSet,o=e.hoverClassName;if(!t.classList.contains(o)&&!i)return!1;var s=r.has(t),a=n.has(t);s&&!a?r.delete(t):!s&&a&&r.add(t),t.classList.remove(o)}({element:t,force:e,SelectedSet:n.DS.SelectedSet,hoverClassName:n._hoverClassName,PrevSelectedSet:n._prevSelectedSet})}))})),this._hoverClassName=s,this._multiSelectToggling=a,this.DS=o,this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:update",this.update)}return i(t,[{key:"_storePrevious",value:function(e){var t=this.DS,i=t.stores.KeyStore,r=t.SelectedSet;i.isMultiSelectKeyPressed(e)?this._prevSelectedSet=new Set(r):this._prevSelectedSet=new Set}}]),t}(),H=function(){function t(i){var n=this,o=i.DS,s=i.selector,a=i.selectorClass,l=i.customStyles;e(this,t),r(this,"_rect",void 0),r(this,"start",(function(e){if(!e.isDragging){var t=n.DS.stores.PointerStore.initialValArea;L(n.HTMLNode,p(t,1)),n.HTMLNode.style.display="block",n._rect=null}})),r(this,"stop",(function(){n.HTMLNode.style.width="0",n.HTMLNode.style.height="0",n.HTMLNode.style.display="none"})),r(this,"update",(function(e){if(!e.isDragging){var t=n.DS.stores,i=t.ScrollStore,r=t.PointerStore,o=function(e){var t=e.scrollAmount,i=e.initialPointerPos,r=e.pointerPos,n={};return r.x>i.x-t.x?(n.left=i.x-t.x,n.width=r.x-i.x+t.x):(n.left=r.x,n.width=i.x-r.x-t.x),r.y>i.y-t.y?(n.top=i.y-t.y,n.height=r.y-i.y+t.y):(n.top=r.y,n.height=i.y-r.y-t.y),n}({scrollAmount:i.scrollAmount,initialPointerPos:r.initialValArea,pointerPos:r.currentValArea});L(n.HTMLNode,o),n._rect=null}})),this.DS=o,this.HTMLNode=s||function(e){var t=document.createElement("div");return t.style.position="absolute",e||(t.style.background="rgba(0, 0, 255, 0.1)",t.style.border="1px solid rgba(0, 0, 255, 0.45)",t.style.display="none",t.style.pointerEvents="none"),t}(l),this.HTMLNode.classList.add(a),this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:update",this.update),this.DS.subscribe("Interaction:end",this.stop)}return i(t,[{key:"rect",get:function(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}]),t}(),R=function(){function t(i){var n=this,o=i.DS,s=i.selectorAreaClass,a=i.autoScrollSpeed,l=i.overflowTolerance;e(this,t),r(this,"_autoScrollSpeed",void 0),r(this,"_scrollInterval",void 0),r(this,"_rect",void 0),r(this,"currentEdges",[]),r(this,"_overflowTolerance",void 0),r(this,"updatePos",(function(){n._rect=null;var e=n.DS.Area.rect,t=n.DS.Area.computedBorder,i=n.HTMLNode.style,r="".concat(e.top+t.top,"px"),o="".concat(e.left+t.left,"px"),s="".concat(e.width,"px"),a="".concat(e.height,"px");i.top!==r&&(i.top=r),i.left!==o&&(i.left=o),i.width!==s&&(i.width=s),i.height!==a&&(i.height=a)})),r(this,"startAutoScroll",(function(){n.currentEdges=[],n._scrollInterval=setInterval((function(){return n.handleAutoScroll()}),16)})),r(this,"handleAutoScroll",(function(){var e=n.DS,t=e.stores.PointerStore,i=e.Area;n.currentEdges=_({elementRect:p(t.currentVal),containerRect:n.rect,tolerance:n._overflowTolerance}),n.currentEdges.length&&i.scroll(n.currentEdges,n._autoScrollSpeed)})),r(this,"stopAutoScroll",(function(){n.currentEdges=[],clearInterval(n._scrollInterval)})),r(this,"isInside",(function(e,t){return!(!n.DS.Area.HTMLNode.contains(e)||!n.DS.stores.ScrollStore.canScroll)||E(n.rect,t||e.getBoundingClientRect())})),this._autoScrollSpeed=a,this._overflowTolerance=l,this.DS=o,this.HTMLNode=function(e){var t=document.createElement("div");return t.style.position="fixed",t.style.overflow="hidden",t.style.pointerEvents="none",t.style.zIndex="999999999999999999",t.classList.add(e),t}(s),this.HTMLNode.appendChild(this.DS.Selector.HTMLNode);var c=document.body?"body":"documentElement";document[c].appendChild(this.HTMLNode),this.DS.subscribe("Area:modified",this.updatePos),this.DS.subscribe("Interaction:start",this.startAutoScroll),this.DS.subscribe("Interaction:end",(function(){n.updatePos(),n.stopAutoScroll()}))}return i(t,[{key:"isClicked",value:function(){var e=this.DS.stores.PointerStore;return E({left:e.initialVal.x,top:e.initialVal.y,right:e.initialVal.x,bottom:e.initialVal.y},this.rect)}},{key:"rect",get:function(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}]),t}(),O=function(){function t(i){var n=this,o=i.DS,s=i.multiSelectKeys,a=i.multiSelectMode;e(this,t),r(this,"_multiSelectMode",void 0),r(this,"_multiSelectKeys",void 0),r(this,"_currentValues",new Set),r(this,"_keyMapping",{control:"ctrlKey",shift:"shiftKey",meta:"metaKey"}),r(this,"init",(function(){document.addEventListener("keydown",n.keydown),document.addEventListener("keyup",n.keyup),window.addEventListener("blur",n.reset)})),r(this,"keydown",(function(e){var t=e.key.toLowerCase();n._currentValues.add(t),n.DS.publish("KeyStore:down",{event:e,key:t})})),r(this,"keyup",(function(e){var t=e.key.toLowerCase();n._currentValues.delete(t),n.DS.publish("KeyStore:up",{event:e,key:t})})),r(this,"stop",(function(){document.removeEventListener("keydown",n.keydown),document.removeEventListener("keyup",n.reset),window.removeEventListener("blur",n.reset),n.reset()})),r(this,"reset",(function(){return n._currentValues.clear()})),this.DS=o,this._multiSelectMode=a,this._multiSelectKeys=s.map((function(e){var t={ctrlKey:"Control",shiftKey:"Shift",metaKey:"Meta"}[e];return t?(console.warn("[DragSelect] ".concat(e,' is deprecated. Use "').concat(t,'" instead. Act Now!. See docs for more info')),t.toLowerCase()):e.toLowerCase()})),this.DS.subscribe("Interaction:init",this.init)}return i(t,[{key:"isMultiSelectKeyPressed",value:function(e){var t=this;return!!this._multiSelectMode||(!!this.currentValues.some((function(e){return t._multiSelectKeys.includes(e)}))||!(!e||!this._multiSelectKeys.some((function(i){return e[t._keyMapping[i]]}))))}},{key:"currentValues",get:function(){return Array.from(this._currentValues.values())}}]),t}(),B=function(){function t(i){var n=this,o=i.DS;e(this,t),r(this,"_isMouseInteraction",!1),r(this,"_initialValArea",void 0),r(this,"_currentValArea",void 0),r(this,"_lastValArea",void 0),r(this,"_initialVal",void 0),r(this,"_currentVal",void 0),r(this,"_lastVal",void 0),r(this,"_lastTouch",void 0),r(this,"init",(function(){document.addEventListener("mousemove",n.update),document.addEventListener("touchmove",n.update,{passive:!1})})),r(this,"update",(function(e){e&&(n.currentVal=D({event:n._normalizedEvent(e)}),n._isMouseInteraction&&n.DS.publish("PointerStore:updated",{event:e}))})),r(this,"stop",(function(){document.removeEventListener("mousemove",n.update),document.removeEventListener("touchmove",n.update,{passive:!1}),setTimeout((function(){return n._isMouseInteraction=!1}),100)})),r(this,"reset",(function(e){e&&(n.currentVal=n.lastVal=D({event:n._normalizedEvent(e)}),n.stop(),n.init())})),this.DS=o,this.DS.subscribe("Interaction:init",this.init),this.DS.subscribe("Interaction:start",(function(e){var t=e.event;return n.start(t)})),this.DS.subscribe("Interaction:end",(function(e){var t=e.event;return n.reset(t)}))}return i(t,[{key:"start",value:function(e){e&&(this._isMouseInteraction=!0,this.currentVal=this.initialVal=D({event:this._normalizedEvent(e)}))}},{key:"_normalizedEvent",value:function(e){return"touches"in e&&"touchend"!==e.type&&(this._lastTouch=e),"touches"in e?this._lastTouch.touches[0]:e}},{key:"initialValArea",get:function(){return this._initialValArea?this._initialValArea:{x:0,y:0}}},{key:"currentValArea",get:function(){return this._currentValArea?this._currentValArea:{x:0,y:0}}},{key:"lastValArea",get:function(){return this._lastValArea?this._lastValArea:{x:0,y:0}}},{key:"initialVal",get:function(){return this._initialVal?this._initialVal:{x:0,y:0}},set:function(e){this._initialVal=e,this._initialValArea=e&&m(e,"-",m(g(this.DS.Area.rect),"+",g(this.DS.Area.computedBorder)))}},{key:"currentVal",get:function(){return this._currentVal?this._currentVal:{x:0,y:0}},set:function(e){this._currentVal=e,this._currentValArea=e&&m(e,"-",m(g(this.DS.Area.rect),"+",g(this.DS.Area.computedBorder)))}},{key:"lastVal",get:function(){return this._lastVal?this._lastVal:{x:0,y:0}},set:function(e){this._lastVal=e,this._lastValArea=e&&m(e,"-",m(g(this.DS.Area.rect),"+",g(this.DS.Area.computedBorder)))}}]),t}(),j=function(){function t(i){var n=this,o=i.DS,s=i.areaElement,a=i.zoom;e(this,t),r(this,"_initialVal",void 0),r(this,"_currentVal",void 0),r(this,"_areaElement",void 0),r(this,"_canScroll",void 0),r(this,"init",(function(){return n._areaElement.addEventListener("scroll",n.update)})),r(this,"start",(function(){n._currentVal=n._initialVal=b(n._areaElement),n._areaElement.addEventListener("scroll",n.update)})),r(this,"update",(function(){return n._currentVal=b(n._areaElement)})),r(this,"stop",(function(){n._areaElement.removeEventListener("scroll",n.update),n._initialVal={x:0,y:0},n._canScroll=null})),r(this,"reset",(function(){n.stop(),n.start()})),this._areaElement=s,this.DS=o,this.zoom=a,this.DS.subscribe("Interaction:init",this.init),this.DS.subscribe("Interaction:start",(function(){return n.start()})),this.DS.subscribe("Interaction:end",(function(){return n.reset()}))}return i(t,[{key:"canScroll",get:function(){return"boolean"==typeof this._canScroll?this._canScroll:this._canScroll=(e=this._areaElement,!!((t=b(e)).x||t.y||(e instanceof HTMLDocument?e.body?e.body.scrollTop=1:e.documentElement.scrollTop=1:e.scrollTop=1)));var e,t}},{key:"scrollAmount",get:function(){var e,t=m(this.currentVal,"-",this.initialVal),i={x:e=this.zoom,y:e},r=m(m(t,"*",i),"-",t);return{x:t.x+r.x,y:t.y+r.y}}},{key:"initialVal",get:function(){return this._initialVal?this._initialVal:{x:0,y:0}}},{key:"currentVal",get:function(){return this._currentVal||(this._currentVal=b(this._areaElement)),this._currentVal}}]),t}(),U=function(){function t(i){var n=this,o=i.area,s=void 0===o?document:o,a=i.selectables,l=void 0===a?[]:a,c=i.autoScrollSpeed,u=void 0===c?5:c,d=i.overflowTolerance,h=void 0===d?{x:25,y:25}:d,f=i.zoom,v=void 0===f?1:f,S=i.customStyles,m=void 0!==S&&S,g=i.multiSelectMode,p=void 0!==g&&g,y=i.multiSelectToggling,b=void 0===y||y,_=i.multiSelectKeys,D=void 0===_?["Control","Shift","Meta"]:_,w=i.selector,x=void 0===w?void 0:w,k=i.draggability,E=void 0===k||k,I=i.immediateDrag,P=void 0===I||I,A=i.dragKeys,L=i.keyboardDragSpeed,U=void 0===L?10:L,W=i.useTransform,F=void 0===W||W,Z=i.hoverClass,G=void 0===Z?"ds-hover":Z,X=i.selectableClass,Y=void 0===X?"ds-selectable":X,$=i.selectedClass,q=void 0===$?"ds-selected":$,J=i.selectorClass,Q=void 0===J?"ds-selector":J,ee=i.selectorAreaClass,te=void 0===ee?"ds-selector-area":ee,ie=i.callback,re=i.onDragMove,ne=i.onDragStartBegin,oe=i.onDragStart,se=i.onElementSelect,ae=i.onElementUnselect;e(this,t),r(this,"start",(function(){return n.Interaction.init()})),r(this,"getSelection",(function(){return n.SelectedSet.elements})),r(this,"getSelectables",(function(){return n.SelectableSet.elements})),r(this,"getInitialCursorPosition",(function(){return n.stores.PointerStore.initialVal})),r(this,"getCurrentCursorPosition",(function(){return n.stores.PointerStore.currentVal})),r(this,"getPreviousCursorPosition",(function(){return n.stores.PointerStore.lastVal})),r(this,"getInitialCursorPositionArea",(function(){return n.stores.PointerStore.initialValArea})),r(this,"getCurrentCursorPositionArea",(function(){return n.stores.PointerStore.currentValArea})),r(this,"getPreviousCursorPositionArea",(function(){return n.stores.PointerStore.lastValArea})),r(this,"isMultiSelect",(function(e){return n.stores.KeyStore.isMultiSelectKeyPressed(e)})),r(this,"isDragging",(function(){return n.Interaction.isDragging})),this.PubSub=new N,this.subscribe=this.PubSub.subscribe,this.unsubscribe=this.PubSub.unsubscribe,this.publish=this.PubSub.publish,this._callbacksTemp({callback:ie,onDragMove:re,onDragStart:oe,onDragStartBegin:ne,onElementSelect:se,onElementUnselect:ae}),this.stores={PointerStore:new B({DS:this}),ScrollStore:new j({DS:this,areaElement:s,zoom:v}),KeyStore:new O({DS:this,multiSelectKeys:D,multiSelectMode:p})},this.Area=new C({area:s,PS:this.PubSub,zoom:v}),this.Selector=new H({DS:this,selector:x,selectorClass:Q,customStyles:m}),this.SelectorArea=new R({DS:this,selectorAreaClass:te,autoScrollSpeed:u,overflowTolerance:h}),this.SelectableSet=new M({elements:l,DS:this,className:Y,hoverClassName:G,useTransform:F,draggability:E}),this.SelectedSet=new K({DS:this,className:q}),this.Selection=new z({DS:this,hoverClassName:G,multiSelectToggling:b}),this.Drag=new T({DS:this,draggability:E,useTransform:F,dragKeys:Object.assign({up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]},A),zoom:v,keyboardDragSpeed:U}),this.Interaction=new V({areaElement:s,DS:this,draggability:E,immediateDrag:P}),this.subscribe("Selected:added",(function(e){var t=e.items,i=e.item;return n.publish("elementselect",{items:t,item:i,isDragging:n.Interaction.isDragging})})),this.subscribe("Selected:removed",(function(e){var t=e.items,i=e.item;return n.publish("elementunselect",{items:t,item:i,isDragging:n.Interaction.isDragging})})),this.subscribe("Interaction:update",(function(e){var t=e.event,i=e.isDragging;t&&n.publish("dragmove",{items:n.getSelection(),event:t,isDragging:i})})),this.subscribe("Area:scroll",(function(e){var t=e.scroll_directions,i=e.scroll_multiplier;n.publish("autoscroll",{items:n.getSelection(),scroll_directions:t,scroll_multiplier:i,isDragging:n.Interaction.isDragging})})),this.subscribe("Interaction:start",(function(e){var t=e.event,i=e.isDragging;return n.publish("dragstart",{items:n.getSelection(),event:t,isDragging:i})})),this.subscribe("Interaction:end",(function(e){var t=e.event,i=e.isDragging;return n.publish("callback",{items:n.getSelection(),event:t,isDragging:i})})),this.start()}return i(t,[{key:"_callbacksTemp",value:function(e){var t=e.callback,i=e.onDragMove,r=e.onDragStart,n=e.onDragStartBegin,o=e.onElementSelect,s=e.onElementUnselect,a=function(e,t){return console.warn("[DragSelect] ".concat(e,' is deprecated. Use DragSelect.subscribe("').concat(t,'", (callbackObject) => {}) instead. Act Now! See docs for more info'))};t&&(a("callback","callback"),this.subscribe("callback",(function(e){var i=e.items,r=(e.item,e.event);return t(i,r)}))),i&&(a("onDragMove","dragmove"),this.subscribe("dragmove",(function(e){e.items,e.item;var t=e.event;return i(t)}))),r&&(a("onDragStart","dragstart"),this.subscribe("dragstart",(function(e){e.items,e.item;var t=e.event;return r(t)}))),n&&(a("onDragStartBegin","dragstart"),this.subscribe("dragstart",(function(e){e.items,e.item;var t=e.event;return n(t)}))),o&&(a("onElementSelect","elementselect"),this.subscribe("elementselect",(function(e){e.items;var t=e.item,i=e.event;return o(t,i)}))),s&&(a("onElementUnselect","elementunselect"),this.subscribe("elementunselect",(function(e){e.items;var t=e.item,i=e.event;return s(t,i)})))}},{key:"stop",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];i&&this.publish("callback",{items:this.getSelection()}),this.Interaction.stop(),this.Area.stop(),this.Drag.stop(),this.Selector.stop(),this.stores.KeyStore.stop(),this.stores.PointerStore.stop(),this.stores.ScrollStore.stop(),e&&this.SelectableSet.clear(),t&&this.SelectedSet.clear()}},{key:"addSelection",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.addAll(A(e)),i||this.addSelectables(e),t&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"removeSelection",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.deleteAll(A(e)),i&&this.removeSelectables(e),t&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"toggleSelection",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return A(e).forEach((function(n){return t.SelectedSet.has(n)?t.removeSelection(e,i,r):t.addSelection(e,i,r)})),i&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"setSelection",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.clearSelection(),this.addSelection(e,t,i),this.getSelection()}},{key:"clearSelection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.SelectedSet.clear(),e&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"addSelectables",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=A(e);return this.SelectableSet.addAll(i),t&&this.SelectedSet.addAll(i),e}},{key:"setSelectables",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.removeSelectables(e,t),this.addSelectables(e,i)}},{key:"removeSelectables",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.SelectableSet.deleteAll(A(e)),t&&this.removeSelection(e),e}},{key:"getCursorPositionDifference",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];console.warn("[DragSelect] Using .getCursorPositionDifference is deprecated. Calculate yourself instead. i.e. `.getCurrentCursorPosition().x - .getInitialCursorPosition().x`");var t=this.getCurrentCursorPosition(),i=e?this.getPreviousCursorPosition():this.getInitialCursorPosition();return m(t,"-",i)}}]),t}();export default U;
1
+ function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function r(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function c(e,t,r){return(c=l()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&a(i,r.prototype),i}).apply(null,arguments)}function u(e){var t="function"==typeof Map?new Map:void 0;return(u=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return c(e,arguments,s(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),a(n,e)})(e)}function d(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function h(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?d(e):t}function f(e){var t=l();return function(){var r,n=s(e);if(t){var i=s(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return h(this,r)}}function v(e,t,r){return(v="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=s(e)););return e}(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(r):i.value}})(e,t,r||e)}function S(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,i=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(n=(s=a.next()).done)&&(r.push(s.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(i)throw o}}return r}(e,t)||m(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(e){return function(e){if(Array.isArray(e))return g(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||m(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(e,t){if(e){if("string"==typeof e)return g(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?g(e,t):void 0}}function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var b=function(e,t,r){var n=e.x,i=e.y,o=r.x,s=r.y;return{"+":{x:n+o,y:i+s},"-":{x:n-o,y:i-s},"*":{x:n*o,y:i*s},"/":{x:n/o,y:i/s}}[t]},y=function(e){return{x:e.left,y:e.top}},_=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return{left:e.x,top:e.y,right:e.x,bottom:e.y,width:t,height:t}},D=function(){var e,t,r,n;return{y:(null===(e=document.body)||void 0===e?void 0:e.scrollTop)||(null===(t=document.documentElement)||void 0===t?void 0:t.scrollTop)||0,x:(null===(r=document.body)||void 0===r?void 0:r.scrollLeft)||(null===(n=document.documentElement)||void 0===n?void 0:n.scrollLeft)||0}},P=function(e){return!e||e instanceof Document?D():{x:e.scrollLeft>=0?e.scrollLeft:D().x,y:e.scrollTop>=0?e.scrollTop:D().y}},w=function(e){var t=e.elementRect,r=e.containerRect,n=e.tolerance,i=void 0===n?{x:0,y:0}:n,o=[];return t.top-i.y<r.top&&o.push("top"),t.left-i.x<r.left&&o.push("left"),t.bottom+i.y>r.bottom&&o.push("bottom"),t.right+i.y>r.right&&o.push("right"),o},k=function(e){var t={x:0,y:0},r=window.getComputedStyle(e);if(!r.transform||"none"===r.transform)return t;if(r.transform.indexOf("3d")>=0){var n=r.transform.trim().match(/matrix3d\((.*?)\)/);if(n&&n.length){var i,o=null===(i=n[1])||void 0===i?void 0:i.split(",");t.x=parseInt(o[12])||0,t.y=parseInt(o[13])||0}return t}var s=r.transform.trim().match(/matrix\((.*?)\)/);if(s&&s.length){var a,l=null===(a=s[1])||void 0===a?void 0:a.split(",");t.x=parseInt(l[4])||0,t.y=parseInt(l[5])||0}return t},E=function(e,t){return t?function(e){var t=e.style.transform;if(!t||t.indexOf("translate")<0)return k(e);var r={x:0,y:0},n=t.trim().match(/translate[3dD]*?\(.*?\)/);if(n){var i,o=null===(i=n[0])||void 0===i?void 0:i.split("(");if(o){var s,a=null===(s=o[1])||void 0===s?void 0:s.split(",");r.x=parseInt(a[0])||0,r.y=parseInt(a[1])||0}}return r.x||r.x?r:k(e)}(e):function(e){var t=e.style,r={x:parseInt(t.left)||0,y:parseInt(t.top)||0};if(!r.x&&!r.x){var n=window.getComputedStyle(e);return{x:parseInt(n.left)||0,y:parseInt(n.top)||0}}return r}(e)},x=function(e){var t=e.computedStyle,r=e.node,n=t.position;r instanceof HTMLDocument||("absolute"===n||"relative"===n||"fixed"===n)||(r.style.position="relative")},I=function(e,t){return e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top},A=function(e){var t=e.element,r=e.posDirection,n=e.containerRect,i=e.useTransform,o=E(t,i),s=b(o,"+",r);C(t,s,i);var a=t.getBoundingClientRect();!function(e){var t=e.element,r=e.edges,n=e.elementRect,i=e.containerRect,o=e.elementPos,s=e.useTransform;r.includes("top")&&C(t,{y:o.y+i.top-n.top,x:o.x},s),r.includes("left")&&C(t,{y:o.y,x:o.x+i.left-n.left},s),r.includes("bottom")&&C(t,{y:o.y+i.bottom-n.bottom,x:o.x},s),r.includes("right")&&C(t,{y:o.y,x:o.x+i.right-n.right},s)}({element:t,edges:w({elementRect:a,containerRect:n}),elementRect:a,containerRect:n,elementPos:s,useTransform:i})},C=function(e,t,r){if(r){var n=e.style.transform;e.style.transform="translate3d(".concat(t.x,"px,").concat(t.y,"px,1px) ").concat(n.replace(/translate.*?\)/g,""))}else e.style.left="".concat(t.x,"px"),e.style.top="".concat(t.y,"px");return e},L=function(e){for(var t=e.subscribe,r=e.publish,o=e.Interaction,s=e.SelectedSet,a=function(){var e=S(c[l],2),a=e[0],u=e[1];["pre",!1].forEach((function(e){return t(e?"".concat(a,":").concat(e):a,(function(t){return u.forEach((function(a){return(!a.condition||a.condition(t))&&r(e?"".concat(e).concat(a.name):a.name,function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach((function(t){n(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({items:s.elements,isDragging:o.isDragging},t))}))}))}))},l=0,c=Object.entries({"Selected:added":[{name:"elementselect"}],"Selected:removed":[{name:"elementunselect"}],"Area:scroll":[{name:"autoscroll"}],"Interaction:start":[{name:"dragstart"}],"Interaction:update":[{name:"dragmove",condition:function(e){return e.event}}],"Interaction:end":[{name:"callback"}]});l<c.length;l++)a()},T=function(e){return e?!Array.isArray(e)&&(e instanceof HTMLElement||e instanceof SVGElement)?[e]:p(e):[]},V=function(e,t){e.style.left="".concat(t.left,"px"),e.style.top="".concat(t.top,"px"),e.style.width="".concat(t.width,"px"),e.style.height="".concat(t.height,"px")},N=function(){function t(r){var i,o,s,a=this,l=r.area,c=r.PS,u=r.zoom;e(this,t),n(this,"_modificationCallback",void 0),n(this,"_modificationObserver",void 0),n(this,"_zoom",void 0),n(this,"_node",void 0),n(this,"_parentNodes",void 0),n(this,"_computedStyle",void 0),n(this,"_computedBorder",void 0),n(this,"_rect",void 0),n(this,"setArea",(function(e){a._node=e,x({computedStyle:a.computedStyle,node:a._node}),setTimeout((function(){a.PubSub.publish("Area:modified:pre",{item:a}),a.reset(),a.PubSub.publish("Area:modified",{item:a})}))})),n(this,"start",(function(){var e,t,r;e=a.parentNodes,t=a._modificationCallback,r=a._modificationObserver,window.addEventListener("resize",t),window.addEventListener("scroll",t),e.forEach((function(e,t){r.observe(e,{childList:0!==t,attributes:!0})}))})),n(this,"reset",(function(){a._computedStyle=void 0,a._rect=void 0,a._computedBorder=void 0,a._parentNodes=void 0})),n(this,"stop",(function(){var e,t;e=a._modificationObserver,t=a._modificationCallback,window.removeEventListener("resize",t),window.removeEventListener("scroll",t),e.disconnect(),a.reset()})),n(this,"scroll",(function(e,t){var r={scroll_directions:e,scroll_multiplier:t};a.PubSub.publish("Area:scroll:pre",r),function(e,t,r){if(t.length){var n=document&&document.documentElement&&document.documentElement.scrollTop&&document.documentElement,i=e instanceof HTMLDocument?n||document.body:e,o=t.includes("top")&&i.scrollTop>0,s=t.includes("bottom")&&i.scrollTop<i.scrollHeight,a=t.includes("left")&&i.scrollLeft>0,l=t.includes("right")&&i.scrollLeft<i.scrollWidth;o&&(i.scrollTop-=1*r),s&&(i.scrollTop+=1*r),a&&(i.scrollLeft-=1*r),l&&(i.scrollLeft+=1*r)}}(a._node,e,t),a.PubSub.publish("Area:scroll",r)})),this._zoom=u,this.PubSub=c,this.setArea(l),this._modificationCallback=(i=function(e){a.PubSub.publish("Area:modified:pre",{event:e,item:a}),a.reset(),a.PubSub.publish("Area:modified",{event:e,item:a})},o=60,function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=function(){s=null,i.apply(void 0,t)};clearTimeout(s),s=setTimeout(n,o)}),this._modificationObserver=new MutationObserver(this._modificationCallback),this.PubSub.subscribe("Interaction:init",this.start),this.PubSub.subscribe("Interaction:end",this.reset)}return r(t,[{key:"HTMLNode",get:function(){return this._node}},{key:"computedBorder",get:function(){return this._computedBorder?this._computedBorder:{top:parseInt(this.computedStyle.borderTopWidth),bottom:parseInt(this.computedStyle.borderBottomWidth),left:parseInt(this.computedStyle.borderLeftWidth),right:parseInt(this.computedStyle.borderRightWidth)}}},{key:"computedStyle",get:function(){return this._computedStyle?this._computedStyle:this.HTMLNode instanceof HTMLDocument?this._computedStyle=window.getComputedStyle(this.HTMLNode.body||this.HTMLNode.documentElement):this._computedStyle=window.getComputedStyle(this.HTMLNode)}},{key:"rect",get:function(){return this._rect?this._rect:this._rect=function(e,t){if(e instanceof Document)return{top:0,left:0,bottom:0,right:0,width:window.innerWidth,height:window.innerHeight};var r=e.getBoundingClientRect();return{top:r.top,left:r.left,bottom:r.bottom,right:r.right,width:(e.clientWidth||r.width)*t,height:(e.clientHeight||r.height)*t}}(this.HTMLNode,this._zoom)}},{key:"parentNodes",get:function(){if(this._parentNodes)return this._parentNodes;return this._parentNodes=function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=null===(r=t[n])||void 0===r?void 0:r.parentNode;return i?(t.push(i),e(t,++n)):t}([this.HTMLNode]),this._parentNodes}}]),t}(),M=function(){function t(r){var i=this,o=r.DS,s=r.dragKeys,a=r.draggability,l=r.keyboardDrag,c=r.keyboardDragSpeed,u=r.useTransform,d=r.zoom;e(this,t),n(this,"_useTransform",void 0),n(this,"_prevCursorPos",void 0),n(this,"_prevScrollPos",void 0),n(this,"_elements",[]),n(this,"_draggability",void 0),n(this,"_dragKeys",void 0),n(this,"_dragKeysFlat",void 0),n(this,"_keyboardDrag",void 0),n(this,"_keyboardDragSpeed",void 0),n(this,"_zoom",void 0),n(this,"keyboardDrag",(function(e){var t=e.event,r=e.key;if(i._keyboardDrag&&i._dragKeysFlat.includes(r)&&i.DS.SelectedSet.size&&i._draggability&&!i.DS.continue){var n={event:t,isDragging:!0,isDraggingKeyboard:!0};i.DS.publish(["Interaction:start:pre","Interaction:start"],n),i._elements=i.DS.getSelection(),i.handleZIndex(!0);var o=function(e){var t=e.shiftKey,r=e.keyboardDragSpeed,n=e.zoom,i=e.key,o=e.dragKeys,s=e.scrollDiff,a=e.canScroll,l=e.scrollCallback,c={x:0,y:0},u=t?4*r*n:r*n;return o.left.includes(i)&&(c.x=s.x||-u,t||s.x||!a||l(["left"],r)),o.right.includes(i)&&(c.x=s.x||u,t||s.x||!a||l(["right"],r)),o.up.includes(i)&&(c.y=s.y||-u,t||s.y||!a||l(["top"],r)),o.down.includes(i)&&(c.y=s.y||u,t||s.y||!a||l(["bottom"],r)),c}({shiftKey:i.DS.stores.KeyStore.currentValues.includes("shift"),keyboardDragSpeed:i._keyboardDragSpeed,zoom:i._zoom,key:r,scrollCallback:i.DS.Area.scroll,scrollDiff:i._scrollDiff,canScroll:i.DS.stores.ScrollStore.canScroll,dragKeys:i._dragKeys});i._elements.forEach((function(e){return A({element:e,posDirection:o,containerRect:i.DS.SelectorArea.rect,useTransform:i._useTransform})})),i.DS.publish(["Interaction:update:pre","Interaction:update"],n)}})),n(this,"keyboardEnd",(function(e){var t=e.event,r=e.key;if(i._keyboardDrag&&i._dragKeysFlat.includes(r)&&i.DS.SelectedSet.size&&i._draggability){var n={event:t,isDragging:i._draggability,isDraggingKeyboard:!0};i.DS.publish(["Interaction:end:pre","Interaction:end"],n)}})),n(this,"start",(function(e){var t=e.isDragging,r=e.isDraggingKeyboard;t&&!r&&(i._prevCursorPos=null,i._prevScrollPos=null,i._elements=i.DS.getSelection(),i.handleZIndex(!0))})),n(this,"stop",(function(e){null!=e&&e.isKeyboard||(i._prevCursorPos=null,i._prevScrollPos=null,i.handleZIndex(!1),i._elements=[])})),n(this,"update",(function(e){var t=e.isDragging,r=e.isDraggingKeyboard;if(t&&i._elements.length&&!r&&!i.DS.continue){var n=b(i._cursorDiff,"+",i._scrollDiff);i._elements.forEach((function(e){return A({element:e,posDirection:n,containerRect:i.DS.SelectorArea.rect,useTransform:i._useTransform})}))}})),n(this,"handleZIndex",(function(e){i._elements.forEach((function(t){return t.style.zIndex="".concat((parseInt(t.style.zIndex)||0)+e?9999:-9998)}))})),this.DS=o,this._useTransform=u,this._keyboardDragSpeed=c,this._keyboardDrag=l,this._zoom=d,this._draggability=a,this._dragKeys={up:s.up.map((function(e){return e.toLowerCase()})),down:s.down.map((function(e){return e.toLowerCase()})),left:s.left.map((function(e){return e.toLowerCase()})),right:s.right.map((function(e){return e.toLowerCase()}))},this._dragKeysFlat=[].concat(p(this._dragKeys.up),p(this._dragKeys.down),p(this._dragKeys.left),p(this._dragKeys.right)),this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:end",this.stop),this.DS.subscribe("Interaction:update",this.update),this.DS.subscribe("KeyStore:down",this.keyboardDrag),this.DS.subscribe("KeyStore:up",this.keyboardEnd)}return r(t,[{key:"_cursorDiff",get:function(){var e=this.DS.stores.PointerStore.currentVal,t=this._prevCursorPos?b(e,"-",this._prevCursorPos):{x:0,y:0};return this._prevCursorPos=e,t}},{key:"_scrollDiff",get:function(){var e=this.DS.stores.ScrollStore.currentVal,t=this._prevScrollPos?b(e,"-",this._prevScrollPos):{x:0,y:0};return this._prevScrollPos=e,t}}]),t}(),K=function(){function t(r){var i=this,o=r.areaElement,s=r.DS,a=r.draggability,l=r.immediateDrag;e(this,t),n(this,"_areaElement",void 0),n(this,"_draggability",void 0),n(this,"_immediateDrag",void 0),n(this,"isInteracting",void 0),n(this,"isDragging",void 0),n(this,"init",(function(){return i.DS.publish("Interaction:init:pre",{})})),n(this,"_init",(function(){i.stop(),i._areaElement.addEventListener("mousedown",i.start),i._areaElement.addEventListener("touchstart",i.start,{passive:!1}),i.DS.publish("Interaction:init",{})})),n(this,"start",(function(e){return i.DS.publish("Interaction:start:pre",{event:e,isDragging:i.isDragging})})),n(this,"_start",(function(e){"touchstart"===e.type&&e.preventDefault(),i._canInteract(e)&&(i.isInteracting=!0,i.isDragging=i.isDragEvent(e),i.DS.publish("Interaction:start",{event:e,isDragging:i.isDragging}),document.addEventListener("mouseup",i.reset),document.addEventListener("touchend",i.reset))})),n(this,"isDragEvent",(function(e){return!(!i._draggability||i.DS.stores.KeyStore.isMultiSelectKeyPressed(e)||!i.DS.SelectableSet.has(e.target))&&(i._immediateDrag&&(i.DS.SelectedSet.size?i.DS.SelectedSet.has(e.target)||(i.DS.SelectedSet.clear(),i.DS.SelectedSet.add(e.target)):i.DS.SelectedSet.add(e.target)),!!i.DS.SelectedSet.has(e.target))})),n(this,"onClick",(function(e){var t=e.event;if(i._canInteract(t)&&!(t.detail>0)){var r=i.DS,n=r.stores,o=n.PointerStore,s=n.KeyStore,a=r.SelectableSet,l=r.SelectedSet;o.start(t);var c=t.target;a.has(c)&&(s.isMultiSelectKeyPressed(t)||l.clear(),l.toggle(c),i.reset())}})),n(this,"stop",(function(){i.isInteracting=!1,i.isDragging=!1,i._areaElement.removeEventListener("mousedown",i.start),i._areaElement.removeEventListener("touchstart",i.start,{passive:!1}),document.removeEventListener("mouseup",i.reset),document.removeEventListener("touchend",i.reset)})),n(this,"update",(function(e){var t=e.event,r=e.scroll_directions,n=e.scroll_multiplier;i.isInteracting&&i.DS.publish(["Interaction:update:pre","Interaction:update"],{event:t,scroll_directions:r,scroll_multiplier:n,isDragging:i.isDragging})})),n(this,"reset",(function(e){return i.DS.publish("Interaction:end:pre",{event:e,isDragging:i.isDragging})})),n(this,"_reset",(function(e){var t=i.isDragging;i.stop(),i.init(),i.DS.publish("Interaction:end",{event:e,isDragging:t})})),this._areaElement=o,this._draggability=a,this._immediateDrag=l,this.DS=s,this.DS.subscribe("PointerStore:updated",this.update),this.DS.subscribe("Selectable:click",this.onClick),this.DS.subscribe("Selectable:pointer",(function(e){var t=e.event;return i.start(t)})),this.DS.subscribe("Interaction:start:pre",(function(e){var t=e.event;return i._start(t)})),this.DS.subscribe("Interaction:init:pre",this._init),this.DS.subscribe("Interaction:end:pre",(function(e){var t=e.event;return i._reset(t)})),this.DS.subscribe("Area:scroll",this.update)}return r(t,[{key:"_canInteract",value:function(e){var t=0===e.clientX&&0===e.clientY&&0===e.detail&&e.target;return!(2===e.button||this.isInteracting||e.target&&!this.DS.SelectorArea.isInside(e.target)||!t&&!this.DS.SelectorArea.isClicked(e))}}]),t}(),O=function t(r){var i=this,o=r.DS;e(this,t),n(this,"subscribers",{}),n(this,"subscribe",(function(e,t){return Array.isArray(i.subscribers[e])||(i.subscribers[e]=[]),i.subscribers[e].push(t),i.subscribers[e].length-1})),n(this,"unsubscribe",(function(e,t,r){r>=0?i.subscribers[e].splice(r,1):t&&(i.subscribers[e]=i.subscribers[e].filter((function(e){return e!==t})))})),n(this,"publish",(function(e,t){Array.isArray(e)?e.forEach((function(e){return i._publish(e,t)})):i._publish(e,t)})),n(this,"_publish",(function(e,t){var r=i.subscribers[e];Array.isArray(r)&&(e.includes(":pre")?i._handlePrePublish(r,t):i._handlePublish(r,t))})),n(this,"_handlePublish",(function(e,t){for(var r=0,n=e.length;r<n;r++){if(i.DS.stopped)return;e[r](t)}})),n(this,"_handlePrePublish",(function(e,t){for(var r=e.length;r--;){if(i.DS.stopped)return;e[r](t)}})),this.DS=o},j=function(t){o(a,u(Set));var i=f(a);function a(t){var r,o=t.elements,s=t.className,l=t.hoverClassName,c=t.draggability,u=t.useTransform,h=t.DS;return e(this,a),n(d(r=i.call(this)),"_initElements",void 0),n(d(r),"_className",void 0),n(d(r),"_hoverClassName",void 0),n(d(r),"_useTransform",void 0),n(d(r),"_draggability",void 0),n(d(r),"init",(function(){return r._initElements.forEach((function(e){return r.add(e)}))})),n(d(r),"clear",(function(){return r.forEach((function(e){return r.delete(e)}))})),n(d(r),"_onClick",(function(e){return r.DS.publish(["Selectable:click:pre","Selectable:click"],{event:e})})),n(d(r),"_onPointer",(function(e){return r.DS.publish(["Selectable:pointer:pre","Selectable:pointer"],{event:e})})),n(d(r),"addAll",(function(e){return e.forEach((function(e){return r.add(e)}))})),n(d(r),"deleteAll",(function(e){return e.forEach((function(e){return r.delete(e)}))})),r.DS=h,r._initElements=T(o),r._className=s,r._hoverClassName=l,r._useTransform=u,r._draggability=c,r.DS.subscribe("Interaction:init",r.init),r}return r(a,[{key:"add",value:function(e){return e.classList.add(this._className),e.addEventListener("click",this._onClick),e.addEventListener("mousedown",this._onPointer),e.addEventListener("touchstart",this._onPointer,{passive:!1}),this._draggability&&!this._useTransform&&x({computedStyle:window.getComputedStyle(e),node:e}),v(s(a.prototype),"add",this).call(this,e)}},{key:"delete",value:function(e){return e.classList.remove(this._className),e.classList.remove(this._hoverClassName),e.removeEventListener("click",this._onClick),e.removeEventListener("mousedown",this._onPointer),e.removeEventListener("touchstart",this._onPointer,{passive:!1}),v(s(a.prototype),"delete",this).call(this,e)}},{key:"elements",get:function(){return Array.from(this.values())}}]),a}(),z=function(t){o(a,u(Set));var i=f(a);function a(t){var r,o=t.className,s=t.DS;return e(this,a),n(d(r=i.call(this)),"_className",void 0),n(d(r),"clear",(function(){return r.forEach((function(e){return r.delete(e)}))})),n(d(r),"addAll",(function(e){return e.forEach((function(e){return r.add(e)}))})),n(d(r),"deleteAll",(function(e){return e.forEach((function(e){return r.delete(e)}))})),r.DS=s,r._className=o,r}return r(a,[{key:"add",value:function(e){if(!v(s(a.prototype),"has",this).call(this,e)){var t={items:this.elements,item:e};return this.DS.publish("Selected:added:pre",t),v(s(a.prototype),"add",this).call(this,e),e.classList.add(this._className),e.style.zIndex="".concat((parseInt(e.style.zIndex)||0)+1),this.DS.publish("Selected:added",t),this}}},{key:"delete",value:function(e){if(v(s(a.prototype),"has",this).call(this,e)){var t={items:this.elements,item:e};this.DS.publish("Selected:removed:pre",t);var r=v(s(a.prototype),"delete",this).call(this,e);return e.classList.remove(this._className),e.style.zIndex="".concat((parseInt(e.style.zIndex)||0)-1),this.DS.publish("Selected:removed",t),r}}},{key:"toggle",value:function(e){return this.has(e)?this.delete(e):this.add(e),e}},{key:"elements",get:function(){return Array.from(this.values())}}]),a}(),H=function(){function t(r){var i=this,o=r.DS,s=r.hoverClassName,a=r.multiSelectToggling;e(this,t),n(this,"_prevSelectedSet",void 0),n(this,"_hoverClassName",void 0),n(this,"_multiSelectToggling",void 0),n(this,"start",(function(e){var t=e.event;e.isDragging||(i._storePrevious(t),i._handleInsideSelection(!0,t))})),n(this,"update",(function(e){e.isDragging||i.DS.continue||i._handleInsideSelection()})),n(this,"_handleInsideSelection",(function(e,t){for(var r=i.DS,n=r.SelectableSet,o=r.SelectorArea,s=r.Selector,a=n.elements.map((function(e){return[e,e.getBoundingClientRect()]})),l=[],c=[],u=0,d=a.length;u<d;u++)o.isInside(a[u][0],a[u][1])&&(I(a[u][1],s.rect)?l.push(a[u][0]):c.push(a[u][0]));var h=i.DS.stores.KeyStore.isMultiSelectKeyPressed(t)&&i._multiSelectToggling;i.DS.continue||(l.forEach((function(t){return function(e){var t=e.element,r=e.force,n=e.multiSelectionToggle,i=e.SelectedSet,o=e.hoverClassName;t.classList.contains(o)&&!r||(i.has(t)?n&&i.delete(t):i.add(t),t.classList.add(o))}({element:t,force:e,multiSelectionToggle:h,SelectedSet:i.DS.SelectedSet,hoverClassName:i._hoverClassName})})),c.forEach((function(t){return function(e){var t=e.element,r=e.force,n=e.SelectedSet,i=e.PrevSelectedSet,o=e.hoverClassName;if(!t.classList.contains(o)&&!r)return!1;var s=n.has(t),a=i.has(t);s&&!a?n.delete(t):!s&&a&&n.add(t),t.classList.remove(o)}({element:t,force:e,SelectedSet:i.DS.SelectedSet,hoverClassName:i._hoverClassName,PrevSelectedSet:i._prevSelectedSet})})))})),this._hoverClassName=s,this._multiSelectToggling=a,this.DS=o,this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:update",this.update)}return r(t,[{key:"_storePrevious",value:function(e){var t=this.DS,r=t.stores.KeyStore,n=t.SelectedSet;r.isMultiSelectKeyPressed(e)?this._prevSelectedSet=new Set(n):this._prevSelectedSet=new Set}}]),t}(),R=function(){function t(r){var i=this,o=r.DS,s=r.selector,a=r.selectorClass,l=r.customStyles;e(this,t),n(this,"_rect",void 0),n(this,"start",(function(e){if(!e.isDragging){var t=i.DS.stores.PointerStore.initialValArea;V(i.HTMLNode,_(t,1)),i.HTMLNode.style.display="block",i._rect=null}})),n(this,"stop",(function(){i.HTMLNode.style.width="0",i.HTMLNode.style.height="0",i.HTMLNode.style.display="none"})),n(this,"update",(function(e){if(!e.isDragging&&!i.DS.continue){var t=i.DS.stores,r=t.ScrollStore,n=t.PointerStore,o=function(e){var t=e.scrollAmount,r=e.initialPointerPos,n=e.pointerPos,i={};return n.x>r.x-t.x?(i.left=r.x-t.x,i.width=n.x-r.x+t.x):(i.left=n.x,i.width=r.x-n.x-t.x),n.y>r.y-t.y?(i.top=r.y-t.y,i.height=n.y-r.y+t.y):(i.top=n.y,i.height=r.y-n.y-t.y),i}({scrollAmount:r.scrollAmount,initialPointerPos:n.initialValArea,pointerPos:n.currentValArea});V(i.HTMLNode,o),i._rect=null}})),this.DS=o,this.HTMLNode=s||function(e){var t=document.createElement("div");return t.style.position="absolute",e||(t.style.background="rgba(0, 0, 255, 0.1)",t.style.border="1px solid rgba(0, 0, 255, 0.45)",t.style.display="none",t.style.pointerEvents="none"),t}(l),this.HTMLNode.classList.add(a),this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:update",this.update),this.DS.subscribe("Interaction:end",this.stop)}return r(t,[{key:"rect",get:function(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}]),t}(),B=function(){function t(r){var i=this,o=r.DS,s=r.selectorAreaClass,a=r.autoScrollSpeed,l=r.overflowTolerance;e(this,t),n(this,"_autoScrollSpeed",void 0),n(this,"_scrollInterval",void 0),n(this,"_rect",void 0),n(this,"currentEdges",[]),n(this,"_overflowTolerance",void 0),n(this,"start",(function(){return i.applyElements("append")})),n(this,"applyElements",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"append",t=document.body?"body":"documentElement",r="".concat(e,"Child");i.HTMLNode[r](i.DS.Selector.HTMLNode),document[t][r](i.HTMLNode)})),n(this,"updatePos",(function(){i._rect=null;var e=i.DS.Area.rect,t=i.DS.Area.computedBorder,r=i.HTMLNode.style,n="".concat(e.top+t.top,"px"),o="".concat(e.left+t.left,"px"),s="".concat(e.width,"px"),a="".concat(e.height,"px");r.top!==n&&(r.top=n),r.left!==o&&(r.left=o),r.width!==s&&(r.width=s),r.height!==a&&(r.height=a)})),n(this,"stop",(function(e){i.stopAutoScroll(),e&&i.applyElements("remove")})),n(this,"startAutoScroll",(function(){i.currentEdges=[],i._scrollInterval=setInterval((function(){return i.handleAutoScroll()}),16)})),n(this,"handleAutoScroll",(function(){if(!i.DS.continue){var e=i.DS,t=e.stores.PointerStore,r=e.Area;i.currentEdges=w({elementRect:_(t.currentVal),containerRect:i.rect,tolerance:i._overflowTolerance}),i.currentEdges.length&&r.scroll(i.currentEdges,i._autoScrollSpeed)}})),n(this,"stopAutoScroll",(function(){i.currentEdges=[],clearInterval(i._scrollInterval)})),n(this,"isInside",(function(e,t){return!(!i.DS.Area.HTMLNode.contains(e)||!i.DS.stores.ScrollStore.canScroll)||I(i.rect,t||e.getBoundingClientRect())})),this._autoScrollSpeed=a,this._overflowTolerance=l,this.DS=o,this.HTMLNode=function(e){var t=document.createElement("div");return t.style.position="fixed",t.style.overflow="hidden",t.style.pointerEvents="none",t.style.zIndex="999999999999999999",t.classList.add(e),t}(s),this.DS.subscribe("Area:modified",this.updatePos),this.DS.subscribe("Interaction:init",this.start),this.DS.subscribe("Interaction:start",this.startAutoScroll),this.DS.subscribe("Interaction:end",(function(){i.updatePos(),i.stopAutoScroll()}))}return r(t,[{key:"isClicked",value:function(e){var t=this.DS.stores.PointerStore,r=e?t.getPointerPosition(e):t.initialVal;return I({left:r.x,top:r.y,right:r.x,bottom:r.y},this.rect)}},{key:"rect",get:function(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}]),t}(),U=function(){function t(r){var i=this,o=r.DS,s=r.multiSelectKeys,a=r.multiSelectMode;e(this,t),n(this,"_multiSelectMode",void 0),n(this,"_multiSelectKeys",void 0),n(this,"_currentValues",new Set),n(this,"_keyMapping",{control:"ctrlKey",shift:"shiftKey",meta:"metaKey"}),n(this,"init",(function(){document.addEventListener("keydown",i.keydown),document.addEventListener("keyup",i.keyup),window.addEventListener("blur",i.reset)})),n(this,"keydown",(function(e){var t=e.key.toLowerCase();i.DS.publish("KeyStore:down:pre",{event:e,key:t}),i._currentValues.add(t),i.DS.publish("KeyStore:down",{event:e,key:t})})),n(this,"keyup",(function(e){var t=e.key.toLowerCase();i.DS.publish("KeyStore:up:pre",{event:e,key:t}),i._currentValues.delete(t),i.DS.publish("KeyStore:up",{event:e,key:t})})),n(this,"stop",(function(){document.removeEventListener("keydown",i.keydown),document.removeEventListener("keyup",i.reset),window.removeEventListener("blur",i.reset),i.reset()})),n(this,"reset",(function(){return i._currentValues.clear()})),this.DS=o,this._multiSelectMode=a,this._multiSelectKeys=s.map((function(e){var t={ctrlKey:"Control",shiftKey:"Shift",metaKey:"Meta"}[e];return t?(console.warn("[DragSelect] ".concat(e,' is deprecated. Use "').concat(t,'" instead. Act Now!. See docs for more info')),t.toLowerCase()):e.toLowerCase()})),this.DS.subscribe("Interaction:init",this.init)}return r(t,[{key:"isMultiSelectKeyPressed",value:function(e){var t=this;return!!this._multiSelectMode||(!!this.currentValues.some((function(e){return t._multiSelectKeys.includes(e)}))||!(!e||!this._multiSelectKeys.some((function(r){return e[t._keyMapping[r]]}))))}},{key:"currentValues",get:function(){return Array.from(this._currentValues.values())}}]),t}(),W=function(){function t(r){var i=this,o=r.DS;e(this,t),n(this,"_isMouseInteraction",!1),n(this,"_initialValArea",void 0),n(this,"_currentValArea",void 0),n(this,"_lastValArea",void 0),n(this,"_initialVal",void 0),n(this,"_currentVal",void 0),n(this,"_lastVal",void 0),n(this,"_lastTouch",void 0),n(this,"init",(function(){document.addEventListener("mousemove",i.update),document.addEventListener("touchmove",i.update,{passive:!1})})),n(this,"getPointerPosition",(function(e){return function(e){var t=e.event;return{x:t.clientX,y:t.clientY}}({event:i._normalizedEvent(e)})})),n(this,"update",(function(e){e&&(i.DS.publish("PointerStore:updated:pre",{event:e}),i.currentVal=i.getPointerPosition(e),i._isMouseInteraction&&i.DS.publish("PointerStore:updated",{event:e}))})),n(this,"stop",(function(){document.removeEventListener("mousemove",i.update),document.removeEventListener("touchmove",i.update,{passive:!1}),setTimeout((function(){return i._isMouseInteraction=!1}),100)})),n(this,"reset",(function(e){e&&(i.currentVal=i.lastVal=i.getPointerPosition(e),i.stop(),i.init())})),this.DS=o,this.DS.subscribe("Interaction:init",this.init),this.DS.subscribe("Interaction:start",(function(e){var t=e.event;return i.start(t)})),this.DS.subscribe("Interaction:end",(function(e){var t=e.event;return i.reset(t)}))}return r(t,[{key:"start",value:function(e){e&&(this._isMouseInteraction=!0,this.currentVal=this.initialVal=this.getPointerPosition(e))}},{key:"_normalizedEvent",value:function(e){return"touches"in e&&"touchend"!==e.type&&(this._lastTouch=e),"touches"in e?this._lastTouch.touches[0]:e}},{key:"initialValArea",get:function(){return this._initialValArea?this._initialValArea:{x:0,y:0}}},{key:"currentValArea",get:function(){return this._currentValArea?this._currentValArea:{x:0,y:0}}},{key:"lastValArea",get:function(){return this._lastValArea?this._lastValArea:{x:0,y:0}}},{key:"initialVal",get:function(){return this._initialVal?this._initialVal:{x:0,y:0}},set:function(e){this._initialVal=e,this._initialValArea=e&&b(e,"-",b(y(this.DS.Area.rect),"+",y(this.DS.Area.computedBorder)))}},{key:"currentVal",get:function(){return this._currentVal?this._currentVal:{x:0,y:0}},set:function(e){this._currentVal=e,this._currentValArea=e&&b(e,"-",b(y(this.DS.Area.rect),"+",y(this.DS.Area.computedBorder)))}},{key:"lastVal",get:function(){return this._lastVal?this._lastVal:{x:0,y:0}},set:function(e){this._lastVal=e,this._lastValArea=e&&b(e,"-",b(y(this.DS.Area.rect),"+",y(this.DS.Area.computedBorder)))}}]),t}(),F=function(){function t(r){var i=this,o=r.DS,s=r.areaElement,a=r.zoom;e(this,t),n(this,"_initialVal",void 0),n(this,"_currentVal",void 0),n(this,"_areaElement",void 0),n(this,"_canScroll",void 0),n(this,"init",(function(){return i._areaElement.addEventListener("scroll",i.update)})),n(this,"start",(function(){i._currentVal=i._initialVal=P(i._areaElement),i._areaElement.addEventListener("scroll",i.update)})),n(this,"update",(function(){return i._currentVal=P(i._areaElement)})),n(this,"stop",(function(){i._areaElement.removeEventListener("scroll",i.update),i._initialVal={x:0,y:0},i._canScroll=null})),n(this,"reset",(function(){i.stop(),i.start()})),this._areaElement=s,this.DS=o,this.zoom=a,this.DS.subscribe("Interaction:init",this.init),this.DS.subscribe("Interaction:start",(function(){return i.start()})),this.DS.subscribe("Interaction:end",(function(){return i.reset()}))}return r(t,[{key:"canScroll",get:function(){return"boolean"==typeof this._canScroll?this._canScroll:this._canScroll=(e=this._areaElement,!!((t=P(e)).x||t.y||(e instanceof HTMLDocument?e.body?e.body.scrollTop=1:e.documentElement.scrollTop=1:e.scrollTop=1)));var e,t}},{key:"scrollAmount",get:function(){var e,t=b(this.currentVal,"-",this.initialVal),r={x:e=this.zoom,y:e},n=b(b(t,"*",r),"-",t);return{x:t.x+n.x,y:t.y+n.y}}},{key:"initialVal",get:function(){return this._initialVal?this._initialVal:{x:0,y:0}}},{key:"currentVal",get:function(){return this._currentVal||(this._currentVal=P(this._areaElement)),this._currentVal}}]),t}(),Z=function(){function t(r){var i=this,o=r.area,s=void 0===o?document:o,a=r.selectables,l=void 0===a?[]:a,c=r.autoScrollSpeed,u=void 0===c?5:c,d=r.overflowTolerance,h=void 0===d?{x:25,y:25}:d,f=r.zoom,v=void 0===f?1:f,S=r.customStyles,p=void 0!==S&&S,m=r.multiSelectMode,g=void 0!==m&&m,b=r.multiSelectToggling,y=void 0===b||b,_=r.multiSelectKeys,D=void 0===_?["Control","Shift","Meta"]:_,P=r.selector,w=void 0===P?void 0:P,k=r.draggability,E=void 0===k||k,x=r.immediateDrag,I=void 0===x||x,A=r.keyboardDrag,C=void 0===A||A,T=r.dragKeys,V=r.keyboardDragSpeed,Z=void 0===V?10:V,X=r.useTransform,Y=void 0===X||X,G=r.hoverClass,$=void 0===G?"ds-hover":G,q=r.selectableClass,J=void 0===q?"ds-selectable":q,Q=r.selectedClass,ee=void 0===Q?"ds-selected":Q,te=r.selectorClass,re=void 0===te?"ds-selector":te,ne=r.selectorAreaClass,ie=void 0===ne?"ds-selector-area":ne,oe=r.callback,se=r.onDragMove,ae=r.onDragStartBegin,le=r.onDragStart,ce=r.onElementSelect,ue=r.onElementUnselect;e(this,t),n(this,"continue",!1),n(this,"start",(function(){i.stopped=!1,i.Interaction.init()})),n(this,"break",(function(){return i.continue=!0})),n(this,"getSelection",(function(){return i.SelectedSet.elements})),n(this,"getSelectables",(function(){return i.SelectableSet.elements})),n(this,"getInitialCursorPosition",(function(){return i.stores.PointerStore.initialVal})),n(this,"getCurrentCursorPosition",(function(){return i.stores.PointerStore.currentVal})),n(this,"getPreviousCursorPosition",(function(){return i.stores.PointerStore.lastVal})),n(this,"getInitialCursorPositionArea",(function(){return i.stores.PointerStore.initialValArea})),n(this,"getCurrentCursorPositionArea",(function(){return i.stores.PointerStore.currentValArea})),n(this,"getPreviousCursorPositionArea",(function(){return i.stores.PointerStore.lastValArea})),n(this,"isMultiSelect",(function(e){return i.stores.KeyStore.isMultiSelectKeyPressed(e)})),n(this,"isDragging",(function(){return i.Interaction.isDragging})),this.PubSub=new O({DS:this}),this.subscribe=this.PubSub.subscribe,this.unsubscribe=this.PubSub.unsubscribe,this.publish=this.PubSub.publish,this._callbacksTemp({callback:oe,onDragMove:se,onDragStart:le,onDragStartBegin:ae,onElementSelect:ce,onElementUnselect:ue}),this.stores={PointerStore:new W({DS:this}),ScrollStore:new F({DS:this,areaElement:s,zoom:v}),KeyStore:new U({DS:this,multiSelectKeys:D,multiSelectMode:g})},this.Area=new N({area:s,PS:this.PubSub,zoom:v}),this.Selector=new R({DS:this,selector:w,selectorClass:re,customStyles:p}),this.SelectorArea=new B({DS:this,selectorAreaClass:ie,autoScrollSpeed:u,overflowTolerance:h}),this.SelectableSet=new j({elements:l,DS:this,className:J,hoverClassName:$,useTransform:Y,draggability:E}),this.SelectedSet=new z({DS:this,className:ee}),this.Selection=new H({DS:this,hoverClassName:$,multiSelectToggling:y}),this.Drag=new M({DS:this,draggability:E,useTransform:Y,keyboardDrag:C,dragKeys:Object.assign({up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]},T),zoom:v,keyboardDragSpeed:Z}),this.Interaction=new K({areaElement:s,DS:this,draggability:E,immediateDrag:I}),L({subscribe:this.subscribe,publish:this.publish,SelectedSet:this.SelectedSet,Interaction:this.Interaction}),this.subscribe("Interaction:end",(function(){return i.continue=!1})),this.start()}return r(t,[{key:"_callbacksTemp",value:function(e){var t=e.callback,r=e.onDragMove,n=e.onDragStart,i=e.onDragStartBegin,o=e.onElementSelect,s=e.onElementUnselect,a=function(e,t){return console.warn("[DragSelect] ".concat(e,' is deprecated. Use DragSelect.subscribe("').concat(t,'", (callbackObject) => {}) instead. Act Now! See docs for more info'))};t&&(a("callback","callback"),this.subscribe("callback",(function(e){var r=e.items,n=(e.item,e.event);return t(r,n)}))),r&&(a("onDragMove","dragmove"),this.subscribe("dragmove",(function(e){e.items,e.item;var t=e.event;return r(t)}))),n&&(a("onDragStart","dragstart"),this.subscribe("dragstart",(function(e){e.items,e.item;var t=e.event;return n(t)}))),i&&(a("onDragStartBegin","dragstart"),this.subscribe("dragstart",(function(e){e.items,e.item;var t=e.event;return i(t)}))),o&&(a("onElementSelect","elementselect"),this.subscribe("elementselect",(function(e){e.items;var t=e.item,r=e.event;return o(t,r)}))),s&&(a("onElementUnselect","elementunselect"),this.subscribe("elementunselect",(function(e){e.items;var t=e.item,r=e.event;return s(t,r)})))}},{key:"stop",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];r&&this.publish("callback",{items:this.getSelection()}),this.Interaction.stop(),this.Area.stop(),this.Drag.stop(),this.Selector.stop(),this.SelectorArea.stop(e),this.stores.KeyStore.stop(),this.stores.PointerStore.stop(),this.stores.ScrollStore.stop(),e&&this.SelectableSet.clear(),t&&this.SelectedSet.clear(),this.stopped=!0}},{key:"addSelection",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.addAll(T(e)),r||this.addSelectables(e),t&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"removeSelection",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.deleteAll(T(e)),r&&this.removeSelectables(e),t&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"toggleSelection",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return T(e).forEach((function(i){return t.SelectedSet.has(i)?t.removeSelection(e,r,n):t.addSelection(e,r,n)})),r&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"setSelection",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.clearSelection(),this.addSelection(e,t,r),this.getSelection()}},{key:"clearSelection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.SelectedSet.clear(),e&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"addSelectables",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=T(e);return this.SelectableSet.addAll(r),t&&this.SelectedSet.addAll(r),e}},{key:"setSelectables",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.removeSelectables(e,t),this.addSelectables(e,r)}},{key:"removeSelectables",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.SelectableSet.deleteAll(T(e)),t&&this.removeSelection(e),e}},{key:"getCursorPositionDifference",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];console.warn("[DragSelect] Using .getCursorPositionDifference is deprecated. Calculate yourself instead. i.e. `.getCurrentCursorPosition().x - .getInitialCursorPosition().x`");var r=t?this.getCurrentCursorPositionArea():this.getCurrentCursorPosition(),n=e?t?this.getPreviousCursorPositionArea():this.getPreviousCursorPosition():t?this.getInitialCursorPositionArea():this.getInitialCursorPosition();return b(r,"-",n)}}]),t}();export default Z;
package/dist/ds.min.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).DragSelect=t()}(this,(function(){"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,i,r){return i&&t(e.prototype,i),r&&t(e,r),e}function r(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function n(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}function o(e){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function a(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function l(e,t,i){return(l=a()?Reflect.construct:function(e,t,i){var r=[null];r.push.apply(r,t);var n=new(Function.bind.apply(e,r));return i&&s(n,i.prototype),n}).apply(null,arguments)}function c(e){var t="function"==typeof Map?new Map:void 0;return(c=function(e){if(null===e||(i=e,-1===Function.toString.call(i).indexOf("[native code]")))return e;var i;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return l(e,arguments,o(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),s(r,e)})(e)}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function d(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?u(e):t}function h(e){var t=a();return function(){var i,r=o(e);if(t){var n=o(this).constructor;i=Reflect.construct(r,arguments,n)}else i=r.apply(this,arguments);return d(this,i)}}function f(e,t,i){return(f="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,i){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=o(e)););return e}(e,t);if(r){var n=Object.getOwnPropertyDescriptor(r,t);return n.get?n.get.call(i):n.value}})(e,t,i||e)}function v(e){return function(e){if(Array.isArray(e))return S(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return S(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return S(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=new Array(t);i<t;i++)r[i]=e[i];return r}var m=function(e,t,i){var r=e.x,n=e.y,o=i.x,s=i.y;return{"+":{x:r+o,y:n+s},"-":{x:r-o,y:n-s},"*":{x:r*o,y:n*s},"/":{x:r/o,y:n/s}}[t]},g=function(e){return{x:e.left,y:e.top}},p=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return{left:e.x,top:e.y,right:e.x,bottom:e.y,width:t,height:t}},y=function(){var e,t,i,r;return{y:(null===(e=document.body)||void 0===e?void 0:e.scrollTop)||(null===(t=document.documentElement)||void 0===t?void 0:t.scrollTop)||0,x:(null===(i=document.body)||void 0===i?void 0:i.scrollLeft)||(null===(r=document.documentElement)||void 0===r?void 0:r.scrollLeft)||0}},b=function(e){return!e||e instanceof Document?y():{x:e.scrollLeft>=0?e.scrollLeft:y().x,y:e.scrollTop>=0?e.scrollTop:y().y}},_=function(e){var t=e.elementRect,i=e.containerRect,r=e.tolerance,n=void 0===r?{x:0,y:0}:r,o=[];return t.top-n.y<i.top&&o.push("top"),t.left-n.x<i.left&&o.push("left"),t.bottom+n.y>i.bottom&&o.push("bottom"),t.right+n.y>i.right&&o.push("right"),o},D=function(e){var t=e.event;return{x:t.clientX,y:t.clientY}},w=function(e){var t={x:0,y:0},i=window.getComputedStyle(e);if(!i.transform||"none"===i.transform)return t;if(i.transform.indexOf("3d")>=0){var r=i.transform.trim().match(/matrix3d\((.*?)\)/);if(r&&r.length){var n,o=null===(n=r[1])||void 0===n?void 0:n.split(",");t.x=parseInt(o[12])||0,t.y=parseInt(o[13])||0}return t}var s=i.transform.trim().match(/matrix\((.*?)\)/);if(s&&s.length){var a,l=null===(a=s[1])||void 0===a?void 0:a.split(",");t.x=parseInt(l[4])||0,t.y=parseInt(l[5])||0}return t},x=function(e,t){return t?function(e){var t=e.style.transform;if(!t||t.indexOf("translate")<0)return w(e);var i={x:0,y:0},r=t.trim().match(/translate[3dD]*?\(.*?\)/);if(r){var n,o=null===(n=r[0])||void 0===n?void 0:n.split("(");if(o){var s,a=null===(s=o[1])||void 0===s?void 0:s.split(",");i.x=parseInt(a[0])||0,i.y=parseInt(a[1])||0}}return i.x||i.x?i:w(e)}(e):function(e){var t=e.style,i={x:parseInt(t.left)||0,y:parseInt(t.top)||0};if(!i.x&&!i.x){var r=window.getComputedStyle(e);return{x:parseInt(r.left)||0,y:parseInt(r.top)||0}}return i}(e)},k=function(e){var t=e.computedStyle,i=e.node,r=t.position;i instanceof HTMLDocument||("absolute"===r||"relative"===r||"fixed"===r)||(i.style.position="relative")},E=function(e,t){return e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top},I=function(e){var t=e.element,i=e.posDirection,r=e.containerRect,n=e.useTransform,o=x(t,n),s=m(o,"+",i);P(t,s,n);var a=t.getBoundingClientRect();!function(e){var t=e.element,i=e.edges,r=e.elementRect,n=e.containerRect,o=e.elementPos,s=e.useTransform;i.includes("top")&&P(t,{y:o.y+n.top-r.top,x:o.x},s),i.includes("left")&&P(t,{y:o.y,x:o.x+n.left-r.left},s),i.includes("bottom")&&P(t,{y:o.y+n.bottom-r.bottom,x:o.x},s),i.includes("right")&&P(t,{y:o.y,x:o.x+n.right-r.right},s)}({element:t,edges:_({elementRect:a,containerRect:r}),elementRect:a,containerRect:r,elementPos:s,useTransform:n})},P=function(e,t,i){if(i){var r=e.style.transform;e.style.transform="translate3d(".concat(t.x,"px,").concat(t.y,"px,1px) ").concat(r.replace(/translate.*?\)/g,""))}else e.style.left="".concat(t.x,"px"),e.style.top="".concat(t.y,"px");return e},A=function(e){return e?!Array.isArray(e)&&(e instanceof HTMLElement||e instanceof SVGElement)?[e]:v(e):[]},L=function(e,t){e.style.left="".concat(t.left,"px"),e.style.top="".concat(t.top,"px"),e.style.width="".concat(t.width,"px"),e.style.height="".concat(t.height,"px")},T=function(){function t(i){var n,o,s,a=this,l=i.area,c=i.PS,u=i.zoom;e(this,t),r(this,"_modificationCallback",void 0),r(this,"_modificationObserver",void 0),r(this,"_zoom",void 0),r(this,"_node",void 0),r(this,"_parentNodes",void 0),r(this,"_computedStyle",void 0),r(this,"_computedBorder",void 0),r(this,"_rect",void 0),r(this,"start",(function(){var e,t,i;e=a.parentNodes,t=a._modificationCallback,i=a._modificationObserver,window.addEventListener("resize",t),window.addEventListener("scroll",t),e.forEach((function(e,t){i.observe(e,{childList:0!==t,attributes:!0})}))})),r(this,"reset",(function(){a._computedStyle=void 0,a._rect=void 0,a._computedBorder=void 0,a._parentNodes=void 0})),r(this,"stop",(function(){var e,t;e=a._modificationObserver,t=a._modificationCallback,window.removeEventListener("resize",t),window.removeEventListener("scroll",t),e.disconnect(),a.reset()})),r(this,"scroll",(function(e,t){!function(e,t,i){if(t.length){var r=document&&document.documentElement&&document.documentElement.scrollTop&&document.documentElement,n=e instanceof HTMLDocument?r||document.body:e,o=t.includes("top")&&n.scrollTop>0,s=t.includes("bottom")&&n.scrollTop<n.scrollHeight,a=t.includes("left")&&n.scrollLeft>0,l=t.includes("right")&&n.scrollLeft<n.scrollWidth;o&&(n.scrollTop-=1*i),s&&(n.scrollTop+=1*i),a&&(n.scrollLeft-=1*i),l&&(n.scrollLeft+=1*i)}}(a._node,e,t),a.PubSub.publish("Area:scroll",{scroll_directions:e,scroll_multiplier:t})})),this._node=l,this._zoom=u,this.PubSub=c,k({computedStyle:this.computedStyle,node:this._node}),this._modificationCallback=(n=function(e){a.reset(),a.PubSub.publish("Area:modified",{event:e,item:a})},o=60,function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];var r=function(){s=null,n.apply(void 0,t)};clearTimeout(s),s=setTimeout(r,o)}),this._modificationObserver=new MutationObserver(this._modificationCallback),setTimeout((function(){a.reset(),a.PubSub.publish("Area:modified",{event:event,item:a})})),this.PubSub.subscribe("Interaction:init",this.start),this.PubSub.subscribe("Interaction:end",this.reset)}return i(t,[{key:"HTMLNode",get:function(){return this._node}},{key:"computedBorder",get:function(){return this._computedBorder?this._computedBorder:{top:parseInt(this.computedStyle.borderTopWidth),bottom:parseInt(this.computedStyle.borderBottomWidth),left:parseInt(this.computedStyle.borderLeftWidth),right:parseInt(this.computedStyle.borderRightWidth)}}},{key:"computedStyle",get:function(){return this._computedStyle?this._computedStyle:this.HTMLNode instanceof HTMLDocument?this._computedStyle=window.getComputedStyle(this.HTMLNode.body||this.HTMLNode.documentElement):this._computedStyle=window.getComputedStyle(this.HTMLNode)}},{key:"rect",get:function(){return this._rect?this._rect:this._rect=function(e,t){if(e instanceof Document)return{top:0,left:0,bottom:0,right:0,width:window.innerWidth,height:window.innerHeight};var i=e.getBoundingClientRect();return{top:i.top,left:i.left,bottom:i.bottom,right:i.right,width:(e.clientWidth||i.width)*t,height:(e.clientHeight||i.height)*t}}(this.HTMLNode,this._zoom)}},{key:"parentNodes",get:function(){if(this._parentNodes)return this._parentNodes;return this._parentNodes=function e(t){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=null===(i=t[r])||void 0===i?void 0:i.parentNode;return n?(t.push(n),e(t,++r)):t}([this.HTMLNode]),this._parentNodes}}]),t}(),C=function(){function t(i){var n=this,o=i.DS,s=i.dragKeys,a=i.draggability,l=i.keyboardDragSpeed,c=i.useTransform,u=i.zoom;e(this,t),r(this,"_useTransform",void 0),r(this,"_prevCursorPos",void 0),r(this,"_prevScrollPos",void 0),r(this,"_elements",[]),r(this,"_draggability",void 0),r(this,"_dragKeys",void 0),r(this,"_dragKeysFlat",void 0),r(this,"_keyboardDragSpeed",void 0),r(this,"_zoom",void 0),r(this,"keyboardDrag",(function(e){var t=e.event,i=e.key;if(console.log(t,i,n._draggability),n._dragKeysFlat.includes(i)&&n.DS.SelectedSet.size&&n._draggability){n._isKeyboard=!0,n.DS.publish("Interaction:start",{event:t,isDragging:!0}),n._elements=n.DS.getSelection(),n.handleZIndex(!0);var r=function(e){var t=e.shiftKey,i=e.keyboardDragSpeed,r=e.zoom,n=e.key,o=e.dragKeys,s=e.scrollDiff,a=e.canScroll,l=e.scrollCallback,c={x:0,y:0},u=t?4*i*r:i*r;return o.left.includes(n)&&(c.x=s.x||-u,t||s.x||!a||l(["left"],i)),o.right.includes(n)&&(c.x=s.x||u,t||s.x||!a||l(["right"],i)),o.up.includes(n)&&(c.y=s.y||-u,t||s.y||!a||l(["top"],i)),o.down.includes(n)&&(c.y=s.y||u,t||s.y||!a||l(["bottom"],i)),c}({shiftKey:n.DS.stores.KeyStore.currentValues.includes("shift"),keyboardDragSpeed:n._keyboardDragSpeed,zoom:n._zoom,key:i,scrollCallback:n.DS.Area.scroll,scrollDiff:n._scrollDiff,canScroll:n.DS.stores.ScrollStore.canScroll,dragKeys:n._dragKeys});n._elements.forEach((function(e){return I({element:e,posDirection:r,containerRect:n.DS.SelectorArea.rect,useTransform:n._useTransform})})),n.DS.publish("Interaction:update",{event:t,isDragging:!0}),n._isKeyboard=!1}})),r(this,"keyboardEnd",(function(e){var t=e.event,i=e.key;n._dragKeysFlat.includes(i)&&n.DS.SelectedSet.size&&n._draggability&&(n._isKeyboard=!0,n.DS.publish("Interaction:end",{event:t,isDragging:!0}),n._isKeyboard=!1)})),r(this,"start",(function(e){e.isDragging&&!n._isKeyboard&&(n._prevCursorPos=null,n._prevScrollPos=null,n._elements=n.DS.getSelection(),n.handleZIndex(!0))})),r(this,"stop",(function(){n._isKeyboard||(n._prevCursorPos=null,n._prevScrollPos=null,n.handleZIndex(!1),n._elements=[])})),r(this,"update",(function(e){if(e.isDragging&&n._elements.length&&!n._isKeyboard){var t=m(n._cursorDiff,"+",n._scrollDiff);n._elements.forEach((function(e){return I({element:e,posDirection:t,containerRect:n.DS.SelectorArea.rect,useTransform:n._useTransform})}))}})),r(this,"handleZIndex",(function(e){n._elements.forEach((function(t){return t.style.zIndex="".concat((parseInt(t.style.zIndex)||0)+e?9999:-9998)}))})),this.DS=o,this._useTransform=c,this._keyboardDragSpeed=l,this._zoom=u,this._draggability=a,this._dragKeys={up:s.up.map((function(e){return e.toLowerCase()})),down:s.down.map((function(e){return e.toLowerCase()})),left:s.left.map((function(e){return e.toLowerCase()})),right:s.right.map((function(e){return e.toLowerCase()}))},this._dragKeysFlat=[].concat(v(this._dragKeys.up),v(this._dragKeys.down),v(this._dragKeys.left),v(this._dragKeys.right)),this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:end",this.stop),this.DS.subscribe("Interaction:update",this.update),this.DS.subscribe("KeyStore:down",this.keyboardDrag),this.DS.subscribe("KeyStore:up",this.keyboardEnd)}return i(t,[{key:"_cursorDiff",get:function(){var e=this.DS.stores.PointerStore.currentVal,t=this._prevCursorPos?m(e,"-",this._prevCursorPos):{x:0,y:0};return this._prevCursorPos=e,t}},{key:"_scrollDiff",get:function(){var e=this.DS.stores.ScrollStore.currentVal,t=this._prevScrollPos?m(e,"-",this._prevScrollPos):{x:0,y:0};return this._prevScrollPos=e,t}}]),t}(),V=function(){function t(i){var n=this,o=i.areaElement,s=i.DS,a=i.draggability,l=i.immediateDrag;e(this,t),r(this,"_areaElement",void 0),r(this,"_draggability",void 0),r(this,"_immediateDrag",void 0),r(this,"isInteracting",void 0),r(this,"isDragging",void 0),r(this,"init",(function(){n.stop(),n._areaElement.addEventListener("mousedown",n.start),n._areaElement.addEventListener("touchstart",n.start,{passive:!1}),n.DS.publish("Interaction:init",{})})),r(this,"start",(function(e){"touchstart"===e.type&&e.preventDefault(),n._canInteract(e)&&(n.isInteracting=!0,n.isDragging=n.isDragEvent(e),n.DS.publish("Interaction:start",{event:e,isDragging:n.isDragging}),document.addEventListener("mouseup",n.reset),document.addEventListener("touchend",n.reset))})),r(this,"isDragEvent",(function(e){return!(!n._draggability||n.DS.stores.KeyStore.isMultiSelectKeyPressed(e)||!n.DS.SelectableSet.has(e.target))&&(n._immediateDrag&&(n.DS.SelectedSet.size?n.DS.SelectedSet.has(e.target)||(n.DS.SelectedSet.clear(),n.DS.SelectedSet.add(e.target)):n.DS.SelectedSet.add(e.target)),!!n.DS.SelectedSet.has(e.target))})),r(this,"onClick",(function(e){var t=e.event;if(n._canInteract(t)&&!(t.detail>0)){var i=n.DS,r=i.stores,o=r.PointerStore,s=r.KeyStore,a=i.SelectableSet,l=i.SelectedSet,c=i.publish;o.start(t);var u=t.target;a.has(u)&&(s.isMultiSelectKeyPressed(t)||l.clear(),l.toggle(u),c("Interaction:end",{event:t,isDragging:n.isDragging}))}})),r(this,"stop",(function(){n.isInteracting=!1,n.isDragging=!1,n._areaElement.removeEventListener("mousedown",n.start),n._areaElement.removeEventListener("touchstart",n.start,{passive:!1}),document.removeEventListener("mouseup",n.reset),document.removeEventListener("touchend",n.reset)})),r(this,"update",(function(e){var t=e.event,i=e.data;n.isInteracting&&n.DS.publish("Interaction:update",{event:t,data:i,isDragging:n.isDragging})})),r(this,"reset",(function(e){var t=n.isDragging;n.stop(),n.init(),n.DS.publish("Interaction:end",{event:e,isDragging:t})})),this._areaElement=o,this._draggability=a,this._immediateDrag=l,this.DS=s,this.DS.subscribe("PointerStore:updated",this.update),this.DS.subscribe("Selectable:click",this.onClick),this.DS.subscribe("Selectable:pointer",(function(e){var t=e.event;return n.start(t)})),this.DS.subscribe("Area:scroll",this.update)}return i(t,[{key:"_canInteract",value:function(e){return!(2===e.button||this.isInteracting||e.target&&!this.DS.SelectorArea.isInside(e.target))}}]),t}(),N=function t(){var i=this;e(this,t),r(this,"subscribers",{}),r(this,"subscribe",(function(e,t){return Array.isArray(i.subscribers[e])||(i.subscribers[e]=[]),i.subscribers[e].push(t),i.subscribers[e].length-1})),r(this,"unsubscribe",(function(e,t,r){r>=0?i.subscribers[e].splice(r,1):t&&(i.subscribers[e]=i.subscribers[e].filter((function(e){return e!==t})))})),r(this,"publish",(function(e,t){Array.isArray(i.subscribers[e])&&i.subscribers[e].forEach((function(e){return e(t)}))}))},M=function(t){n(a,t);var s=h(a);function a(t){var i,n=t.elements,o=t.className,l=t.hoverClassName,c=t.draggability,d=t.useTransform,h=t.DS;return e(this,a),r(u(i=s.call(this)),"_initElements",void 0),r(u(i),"_className",void 0),r(u(i),"_hoverClassName",void 0),r(u(i),"_useTransform",void 0),r(u(i),"_draggability",void 0),r(u(i),"init",(function(){return i._initElements.forEach((function(e){return i.add(e)}))})),r(u(i),"clear",(function(){return i.forEach((function(e){return i.delete(e)}))})),r(u(i),"_onClick",(function(e){return i.DS.publish("Selectable:click",{event:e})})),r(u(i),"_onPointer",(function(e){return i.DS.publish("Selectable:pointer",{event:e})})),r(u(i),"addAll",(function(e){return e.forEach((function(e){return i.add(e)}))})),r(u(i),"deleteAll",(function(e){return e.forEach((function(e){return i.delete(e)}))})),i.DS=h,i._initElements=A(n),i._className=o,i._hoverClassName=l,i._useTransform=d,i._draggability=c,i.DS.subscribe("Interaction:init",i.init),i}return i(a,[{key:"add",value:function(e){return e.classList.add(this._className),e.addEventListener("click",this._onClick),e.addEventListener("mousedown",this._onPointer),e.addEventListener("touchstart",this._onPointer,{passive:!1}),this._draggability&&!this._useTransform&&k({computedStyle:window.getComputedStyle(e),node:e}),f(o(a.prototype),"add",this).call(this,e)}},{key:"delete",value:function(e){return e.classList.remove(this._className),e.classList.remove(this._hoverClassName),e.removeEventListener("click",this._onClick),e.removeEventListener("mousedown",this._onPointer),e.removeEventListener("touchstart",this._onPointer,{passive:!1}),f(o(a.prototype),"delete",this).call(this,e)}},{key:"elements",get:function(){return Array.from(this.values())}}]),a}(c(Set)),K=function(t){n(a,t);var s=h(a);function a(t){var i,n=t.className,o=t.DS;return e(this,a),r(u(i=s.call(this)),"_className",void 0),r(u(i),"clear",(function(){return i.forEach((function(e){return i.delete(e)}))})),r(u(i),"addAll",(function(e){return e.forEach((function(e){return i.add(e)}))})),r(u(i),"deleteAll",(function(e){return e.forEach((function(e){return i.delete(e)}))})),i.DS=o,i._className=n,i}return i(a,[{key:"add",value:function(e){if(!f(o(a.prototype),"has",this).call(this,e))return f(o(a.prototype),"add",this).call(this,e),e.classList.add(this._className),this.DS.publish("Selected:added",{items:this.elements,item:e}),e.style.zIndex="".concat((parseInt(e.style.zIndex)||0)+1),this}},{key:"delete",value:function(e){if(f(o(a.prototype),"has",this).call(this,e)){var t=f(o(a.prototype),"delete",this).call(this,e);return e.classList.remove(this._className),this.DS.publish("Selected:removed",{items:this.elements,item:e}),e.style.zIndex="".concat((parseInt(e.style.zIndex)||0)-1),t}}},{key:"toggle",value:function(e){return this.has(e)?this.delete(e):this.add(e),e}},{key:"elements",get:function(){return Array.from(this.values())}}]),a}(c(Set)),z=function(){function t(i){var n=this,o=i.DS,s=i.hoverClassName,a=i.multiSelectToggling;e(this,t),r(this,"_prevSelectedSet",void 0),r(this,"_hoverClassName",void 0),r(this,"_multiSelectToggling",void 0),r(this,"start",(function(e){var t=e.event;e.isDragging||(n._storePrevious(t),n._handleInsideSelection(!0,t))})),r(this,"update",(function(e){e.isDragging||n._handleInsideSelection()})),r(this,"_handleInsideSelection",(function(e,t){for(var i=n.DS,r=i.SelectableSet,o=i.SelectorArea,s=i.Selector,a=r.elements.map((function(e){return[e,e.getBoundingClientRect()]})),l=[],c=[],u=0,d=a.length;u<d;u++)o.isInside(a[u][0],a[u][1])&&(E(a[u][1],s.rect)?l.push(a[u][0]):c.push(a[u][0]));var h=n.DS.stores.KeyStore.isMultiSelectKeyPressed(t)&&n._multiSelectToggling;l.forEach((function(t){return function(e){var t=e.element,i=e.force,r=e.multiSelectionToggle,n=e.SelectedSet,o=e.hoverClassName;t.classList.contains(o)&&!i||(n.has(t)?r&&n.delete(t):n.add(t),t.classList.add(o))}({element:t,force:e,multiSelectionToggle:h,SelectedSet:n.DS.SelectedSet,hoverClassName:n._hoverClassName})})),c.forEach((function(t){return function(e){var t=e.element,i=e.force,r=e.SelectedSet,n=e.PrevSelectedSet,o=e.hoverClassName;if(!t.classList.contains(o)&&!i)return!1;var s=r.has(t),a=n.has(t);s&&!a?r.delete(t):!s&&a&&r.add(t),t.classList.remove(o)}({element:t,force:e,SelectedSet:n.DS.SelectedSet,hoverClassName:n._hoverClassName,PrevSelectedSet:n._prevSelectedSet})}))})),this._hoverClassName=s,this._multiSelectToggling=a,this.DS=o,this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:update",this.update)}return i(t,[{key:"_storePrevious",value:function(e){var t=this.DS,i=t.stores.KeyStore,r=t.SelectedSet;i.isMultiSelectKeyPressed(e)?this._prevSelectedSet=new Set(r):this._prevSelectedSet=new Set}}]),t}(),H=function(){function t(i){var n=this,o=i.DS,s=i.selector,a=i.selectorClass,l=i.customStyles;e(this,t),r(this,"_rect",void 0),r(this,"start",(function(e){if(!e.isDragging){var t=n.DS.stores.PointerStore.initialValArea;L(n.HTMLNode,p(t,1)),n.HTMLNode.style.display="block",n._rect=null}})),r(this,"stop",(function(){n.HTMLNode.style.width="0",n.HTMLNode.style.height="0",n.HTMLNode.style.display="none"})),r(this,"update",(function(e){if(!e.isDragging){var t=n.DS.stores,i=t.ScrollStore,r=t.PointerStore,o=function(e){var t=e.scrollAmount,i=e.initialPointerPos,r=e.pointerPos,n={};return r.x>i.x-t.x?(n.left=i.x-t.x,n.width=r.x-i.x+t.x):(n.left=r.x,n.width=i.x-r.x-t.x),r.y>i.y-t.y?(n.top=i.y-t.y,n.height=r.y-i.y+t.y):(n.top=r.y,n.height=i.y-r.y-t.y),n}({scrollAmount:i.scrollAmount,initialPointerPos:r.initialValArea,pointerPos:r.currentValArea});L(n.HTMLNode,o),n._rect=null}})),this.DS=o,this.HTMLNode=s||function(e){var t=document.createElement("div");return t.style.position="absolute",e||(t.style.background="rgba(0, 0, 255, 0.1)",t.style.border="1px solid rgba(0, 0, 255, 0.45)",t.style.display="none",t.style.pointerEvents="none"),t}(l),this.HTMLNode.classList.add(a),this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:update",this.update),this.DS.subscribe("Interaction:end",this.stop)}return i(t,[{key:"rect",get:function(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}]),t}(),R=function(){function t(i){var n=this,o=i.DS,s=i.selectorAreaClass,a=i.autoScrollSpeed,l=i.overflowTolerance;e(this,t),r(this,"_autoScrollSpeed",void 0),r(this,"_scrollInterval",void 0),r(this,"_rect",void 0),r(this,"currentEdges",[]),r(this,"_overflowTolerance",void 0),r(this,"updatePos",(function(){n._rect=null;var e=n.DS.Area.rect,t=n.DS.Area.computedBorder,i=n.HTMLNode.style,r="".concat(e.top+t.top,"px"),o="".concat(e.left+t.left,"px"),s="".concat(e.width,"px"),a="".concat(e.height,"px");i.top!==r&&(i.top=r),i.left!==o&&(i.left=o),i.width!==s&&(i.width=s),i.height!==a&&(i.height=a)})),r(this,"startAutoScroll",(function(){n.currentEdges=[],n._scrollInterval=setInterval((function(){return n.handleAutoScroll()}),16)})),r(this,"handleAutoScroll",(function(){var e=n.DS,t=e.stores.PointerStore,i=e.Area;n.currentEdges=_({elementRect:p(t.currentVal),containerRect:n.rect,tolerance:n._overflowTolerance}),n.currentEdges.length&&i.scroll(n.currentEdges,n._autoScrollSpeed)})),r(this,"stopAutoScroll",(function(){n.currentEdges=[],clearInterval(n._scrollInterval)})),r(this,"isInside",(function(e,t){return!(!n.DS.Area.HTMLNode.contains(e)||!n.DS.stores.ScrollStore.canScroll)||E(n.rect,t||e.getBoundingClientRect())})),this._autoScrollSpeed=a,this._overflowTolerance=l,this.DS=o,this.HTMLNode=function(e){var t=document.createElement("div");return t.style.position="fixed",t.style.overflow="hidden",t.style.pointerEvents="none",t.style.zIndex="999999999999999999",t.classList.add(e),t}(s),this.HTMLNode.appendChild(this.DS.Selector.HTMLNode);var c=document.body?"body":"documentElement";document[c].appendChild(this.HTMLNode),this.DS.subscribe("Area:modified",this.updatePos),this.DS.subscribe("Interaction:start",this.startAutoScroll),this.DS.subscribe("Interaction:end",(function(){n.updatePos(),n.stopAutoScroll()}))}return i(t,[{key:"isClicked",value:function(){var e=this.DS.stores.PointerStore;return E({left:e.initialVal.x,top:e.initialVal.y,right:e.initialVal.x,bottom:e.initialVal.y},this.rect)}},{key:"rect",get:function(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}]),t}(),O=function(){function t(i){var n=this,o=i.DS,s=i.multiSelectKeys,a=i.multiSelectMode;e(this,t),r(this,"_multiSelectMode",void 0),r(this,"_multiSelectKeys",void 0),r(this,"_currentValues",new Set),r(this,"_keyMapping",{control:"ctrlKey",shift:"shiftKey",meta:"metaKey"}),r(this,"init",(function(){document.addEventListener("keydown",n.keydown),document.addEventListener("keyup",n.keyup),window.addEventListener("blur",n.reset)})),r(this,"keydown",(function(e){var t=e.key.toLowerCase();n._currentValues.add(t),n.DS.publish("KeyStore:down",{event:e,key:t})})),r(this,"keyup",(function(e){var t=e.key.toLowerCase();n._currentValues.delete(t),n.DS.publish("KeyStore:up",{event:e,key:t})})),r(this,"stop",(function(){document.removeEventListener("keydown",n.keydown),document.removeEventListener("keyup",n.reset),window.removeEventListener("blur",n.reset),n.reset()})),r(this,"reset",(function(){return n._currentValues.clear()})),this.DS=o,this._multiSelectMode=a,this._multiSelectKeys=s.map((function(e){var t={ctrlKey:"Control",shiftKey:"Shift",metaKey:"Meta"}[e];return t?(console.warn("[DragSelect] ".concat(e,' is deprecated. Use "').concat(t,'" instead. Act Now!. See docs for more info')),t.toLowerCase()):e.toLowerCase()})),this.DS.subscribe("Interaction:init",this.init)}return i(t,[{key:"isMultiSelectKeyPressed",value:function(e){var t=this;return!!this._multiSelectMode||(!!this.currentValues.some((function(e){return t._multiSelectKeys.includes(e)}))||!(!e||!this._multiSelectKeys.some((function(i){return e[t._keyMapping[i]]}))))}},{key:"currentValues",get:function(){return Array.from(this._currentValues.values())}}]),t}(),B=function(){function t(i){var n=this,o=i.DS;e(this,t),r(this,"_isMouseInteraction",!1),r(this,"_initialValArea",void 0),r(this,"_currentValArea",void 0),r(this,"_lastValArea",void 0),r(this,"_initialVal",void 0),r(this,"_currentVal",void 0),r(this,"_lastVal",void 0),r(this,"_lastTouch",void 0),r(this,"init",(function(){document.addEventListener("mousemove",n.update),document.addEventListener("touchmove",n.update,{passive:!1})})),r(this,"update",(function(e){e&&(n.currentVal=D({event:n._normalizedEvent(e)}),n._isMouseInteraction&&n.DS.publish("PointerStore:updated",{event:e}))})),r(this,"stop",(function(){document.removeEventListener("mousemove",n.update),document.removeEventListener("touchmove",n.update,{passive:!1}),setTimeout((function(){return n._isMouseInteraction=!1}),100)})),r(this,"reset",(function(e){e&&(n.currentVal=n.lastVal=D({event:n._normalizedEvent(e)}),n.stop(),n.init())})),this.DS=o,this.DS.subscribe("Interaction:init",this.init),this.DS.subscribe("Interaction:start",(function(e){var t=e.event;return n.start(t)})),this.DS.subscribe("Interaction:end",(function(e){var t=e.event;return n.reset(t)}))}return i(t,[{key:"start",value:function(e){e&&(this._isMouseInteraction=!0,this.currentVal=this.initialVal=D({event:this._normalizedEvent(e)}))}},{key:"_normalizedEvent",value:function(e){return"touches"in e&&"touchend"!==e.type&&(this._lastTouch=e),"touches"in e?this._lastTouch.touches[0]:e}},{key:"initialValArea",get:function(){return this._initialValArea?this._initialValArea:{x:0,y:0}}},{key:"currentValArea",get:function(){return this._currentValArea?this._currentValArea:{x:0,y:0}}},{key:"lastValArea",get:function(){return this._lastValArea?this._lastValArea:{x:0,y:0}}},{key:"initialVal",get:function(){return this._initialVal?this._initialVal:{x:0,y:0}},set:function(e){this._initialVal=e,this._initialValArea=e&&m(e,"-",m(g(this.DS.Area.rect),"+",g(this.DS.Area.computedBorder)))}},{key:"currentVal",get:function(){return this._currentVal?this._currentVal:{x:0,y:0}},set:function(e){this._currentVal=e,this._currentValArea=e&&m(e,"-",m(g(this.DS.Area.rect),"+",g(this.DS.Area.computedBorder)))}},{key:"lastVal",get:function(){return this._lastVal?this._lastVal:{x:0,y:0}},set:function(e){this._lastVal=e,this._lastValArea=e&&m(e,"-",m(g(this.DS.Area.rect),"+",g(this.DS.Area.computedBorder)))}}]),t}(),j=function(){function t(i){var n=this,o=i.DS,s=i.areaElement,a=i.zoom;e(this,t),r(this,"_initialVal",void 0),r(this,"_currentVal",void 0),r(this,"_areaElement",void 0),r(this,"_canScroll",void 0),r(this,"init",(function(){return n._areaElement.addEventListener("scroll",n.update)})),r(this,"start",(function(){n._currentVal=n._initialVal=b(n._areaElement),n._areaElement.addEventListener("scroll",n.update)})),r(this,"update",(function(){return n._currentVal=b(n._areaElement)})),r(this,"stop",(function(){n._areaElement.removeEventListener("scroll",n.update),n._initialVal={x:0,y:0},n._canScroll=null})),r(this,"reset",(function(){n.stop(),n.start()})),this._areaElement=s,this.DS=o,this.zoom=a,this.DS.subscribe("Interaction:init",this.init),this.DS.subscribe("Interaction:start",(function(){return n.start()})),this.DS.subscribe("Interaction:end",(function(){return n.reset()}))}return i(t,[{key:"canScroll",get:function(){return"boolean"==typeof this._canScroll?this._canScroll:this._canScroll=(e=this._areaElement,!!((t=b(e)).x||t.y||(e instanceof HTMLDocument?e.body?e.body.scrollTop=1:e.documentElement.scrollTop=1:e.scrollTop=1)));var e,t}},{key:"scrollAmount",get:function(){var e,t=m(this.currentVal,"-",this.initialVal),i={x:e=this.zoom,y:e},r=m(m(t,"*",i),"-",t);return{x:t.x+r.x,y:t.y+r.y}}},{key:"initialVal",get:function(){return this._initialVal?this._initialVal:{x:0,y:0}}},{key:"currentVal",get:function(){return this._currentVal||(this._currentVal=b(this._areaElement)),this._currentVal}}]),t}();return function(){function t(i){var n=this,o=i.area,s=void 0===o?document:o,a=i.selectables,l=void 0===a?[]:a,c=i.autoScrollSpeed,u=void 0===c?5:c,d=i.overflowTolerance,h=void 0===d?{x:25,y:25}:d,f=i.zoom,v=void 0===f?1:f,S=i.customStyles,m=void 0!==S&&S,g=i.multiSelectMode,p=void 0!==g&&g,y=i.multiSelectToggling,b=void 0===y||y,_=i.multiSelectKeys,D=void 0===_?["Control","Shift","Meta"]:_,w=i.selector,x=void 0===w?void 0:w,k=i.draggability,E=void 0===k||k,I=i.immediateDrag,P=void 0===I||I,A=i.dragKeys,L=i.keyboardDragSpeed,U=void 0===L?10:L,W=i.useTransform,F=void 0===W||W,Z=i.hoverClass,G=void 0===Z?"ds-hover":Z,X=i.selectableClass,Y=void 0===X?"ds-selectable":X,$=i.selectedClass,q=void 0===$?"ds-selected":$,J=i.selectorClass,Q=void 0===J?"ds-selector":J,ee=i.selectorAreaClass,te=void 0===ee?"ds-selector-area":ee,ie=i.callback,re=i.onDragMove,ne=i.onDragStartBegin,oe=i.onDragStart,se=i.onElementSelect,ae=i.onElementUnselect;e(this,t),r(this,"start",(function(){return n.Interaction.init()})),r(this,"getSelection",(function(){return n.SelectedSet.elements})),r(this,"getSelectables",(function(){return n.SelectableSet.elements})),r(this,"getInitialCursorPosition",(function(){return n.stores.PointerStore.initialVal})),r(this,"getCurrentCursorPosition",(function(){return n.stores.PointerStore.currentVal})),r(this,"getPreviousCursorPosition",(function(){return n.stores.PointerStore.lastVal})),r(this,"getInitialCursorPositionArea",(function(){return n.stores.PointerStore.initialValArea})),r(this,"getCurrentCursorPositionArea",(function(){return n.stores.PointerStore.currentValArea})),r(this,"getPreviousCursorPositionArea",(function(){return n.stores.PointerStore.lastValArea})),r(this,"isMultiSelect",(function(e){return n.stores.KeyStore.isMultiSelectKeyPressed(e)})),r(this,"isDragging",(function(){return n.Interaction.isDragging})),this.PubSub=new N,this.subscribe=this.PubSub.subscribe,this.unsubscribe=this.PubSub.unsubscribe,this.publish=this.PubSub.publish,this._callbacksTemp({callback:ie,onDragMove:re,onDragStart:oe,onDragStartBegin:ne,onElementSelect:se,onElementUnselect:ae}),this.stores={PointerStore:new B({DS:this}),ScrollStore:new j({DS:this,areaElement:s,zoom:v}),KeyStore:new O({DS:this,multiSelectKeys:D,multiSelectMode:p})},this.Area=new T({area:s,PS:this.PubSub,zoom:v}),this.Selector=new H({DS:this,selector:x,selectorClass:Q,customStyles:m}),this.SelectorArea=new R({DS:this,selectorAreaClass:te,autoScrollSpeed:u,overflowTolerance:h}),this.SelectableSet=new M({elements:l,DS:this,className:Y,hoverClassName:G,useTransform:F,draggability:E}),this.SelectedSet=new K({DS:this,className:q}),this.Selection=new z({DS:this,hoverClassName:G,multiSelectToggling:b}),this.Drag=new C({DS:this,draggability:E,useTransform:F,dragKeys:Object.assign({up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]},A),zoom:v,keyboardDragSpeed:U}),this.Interaction=new V({areaElement:s,DS:this,draggability:E,immediateDrag:P}),this.subscribe("Selected:added",(function(e){var t=e.items,i=e.item;return n.publish("elementselect",{items:t,item:i,isDragging:n.Interaction.isDragging})})),this.subscribe("Selected:removed",(function(e){var t=e.items,i=e.item;return n.publish("elementunselect",{items:t,item:i,isDragging:n.Interaction.isDragging})})),this.subscribe("Interaction:update",(function(e){var t=e.event,i=e.isDragging;t&&n.publish("dragmove",{items:n.getSelection(),event:t,isDragging:i})})),this.subscribe("Area:scroll",(function(e){var t=e.scroll_directions,i=e.scroll_multiplier;n.publish("autoscroll",{items:n.getSelection(),scroll_directions:t,scroll_multiplier:i,isDragging:n.Interaction.isDragging})})),this.subscribe("Interaction:start",(function(e){var t=e.event,i=e.isDragging;return n.publish("dragstart",{items:n.getSelection(),event:t,isDragging:i})})),this.subscribe("Interaction:end",(function(e){var t=e.event,i=e.isDragging;return n.publish("callback",{items:n.getSelection(),event:t,isDragging:i})})),this.start()}return i(t,[{key:"_callbacksTemp",value:function(e){var t=e.callback,i=e.onDragMove,r=e.onDragStart,n=e.onDragStartBegin,o=e.onElementSelect,s=e.onElementUnselect,a=function(e,t){return console.warn("[DragSelect] ".concat(e,' is deprecated. Use DragSelect.subscribe("').concat(t,'", (callbackObject) => {}) instead. Act Now! See docs for more info'))};t&&(a("callback","callback"),this.subscribe("callback",(function(e){var i=e.items,r=(e.item,e.event);return t(i,r)}))),i&&(a("onDragMove","dragmove"),this.subscribe("dragmove",(function(e){e.items,e.item;var t=e.event;return i(t)}))),r&&(a("onDragStart","dragstart"),this.subscribe("dragstart",(function(e){e.items,e.item;var t=e.event;return r(t)}))),n&&(a("onDragStartBegin","dragstart"),this.subscribe("dragstart",(function(e){e.items,e.item;var t=e.event;return n(t)}))),o&&(a("onElementSelect","elementselect"),this.subscribe("elementselect",(function(e){e.items;var t=e.item,i=e.event;return o(t,i)}))),s&&(a("onElementUnselect","elementunselect"),this.subscribe("elementunselect",(function(e){e.items;var t=e.item,i=e.event;return s(t,i)})))}},{key:"stop",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];i&&this.publish("callback",{items:this.getSelection()}),this.Interaction.stop(),this.Area.stop(),this.Drag.stop(),this.Selector.stop(),this.stores.KeyStore.stop(),this.stores.PointerStore.stop(),this.stores.ScrollStore.stop(),e&&this.SelectableSet.clear(),t&&this.SelectedSet.clear()}},{key:"addSelection",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.addAll(A(e)),i||this.addSelectables(e),t&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"removeSelection",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.deleteAll(A(e)),i&&this.removeSelectables(e),t&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"toggleSelection",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return A(e).forEach((function(n){return t.SelectedSet.has(n)?t.removeSelection(e,i,r):t.addSelection(e,i,r)})),i&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"setSelection",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.clearSelection(),this.addSelection(e,t,i),this.getSelection()}},{key:"clearSelection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.SelectedSet.clear(),e&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"addSelectables",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=A(e);return this.SelectableSet.addAll(i),t&&this.SelectedSet.addAll(i),e}},{key:"setSelectables",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.removeSelectables(e,t),this.addSelectables(e,i)}},{key:"removeSelectables",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.SelectableSet.deleteAll(A(e)),t&&this.removeSelection(e),e}},{key:"getCursorPositionDifference",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];console.warn("[DragSelect] Using .getCursorPositionDifference is deprecated. Calculate yourself instead. i.e. `.getCurrentCursorPosition().x - .getInitialCursorPosition().x`");var t=this.getCurrentCursorPosition(),i=e?this.getPreviousCursorPosition():this.getInitialCursorPosition();return m(t,"-",i)}}]),t}()}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).DragSelect=t()}(this,(function(){"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function r(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function c(e,t,r){return(c=l()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&a(i,r.prototype),i}).apply(null,arguments)}function u(e){var t="function"==typeof Map?new Map:void 0;return(u=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return c(e,arguments,s(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),a(n,e)})(e)}function d(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function h(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?d(e):t}function f(e){var t=l();return function(){var r,n=s(e);if(t){var i=s(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return h(this,r)}}function v(e,t,r){return(v="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=s(e)););return e}(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(r):i.value}})(e,t,r||e)}function S(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,i=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(n=(s=a.next()).done)&&(r.push(s.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(i)throw o}}return r}(e,t)||m(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(e){return function(e){if(Array.isArray(e))return g(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||m(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(e,t){if(e){if("string"==typeof e)return g(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?g(e,t):void 0}}function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var b=function(e,t,r){var n=e.x,i=e.y,o=r.x,s=r.y;return{"+":{x:n+o,y:i+s},"-":{x:n-o,y:i-s},"*":{x:n*o,y:i*s},"/":{x:n/o,y:i/s}}[t]},y=function(e){return{x:e.left,y:e.top}},_=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return{left:e.x,top:e.y,right:e.x,bottom:e.y,width:t,height:t}},D=function(){var e,t,r,n;return{y:(null===(e=document.body)||void 0===e?void 0:e.scrollTop)||(null===(t=document.documentElement)||void 0===t?void 0:t.scrollTop)||0,x:(null===(r=document.body)||void 0===r?void 0:r.scrollLeft)||(null===(n=document.documentElement)||void 0===n?void 0:n.scrollLeft)||0}},P=function(e){return!e||e instanceof Document?D():{x:e.scrollLeft>=0?e.scrollLeft:D().x,y:e.scrollTop>=0?e.scrollTop:D().y}},w=function(e){var t=e.elementRect,r=e.containerRect,n=e.tolerance,i=void 0===n?{x:0,y:0}:n,o=[];return t.top-i.y<r.top&&o.push("top"),t.left-i.x<r.left&&o.push("left"),t.bottom+i.y>r.bottom&&o.push("bottom"),t.right+i.y>r.right&&o.push("right"),o},k=function(e){var t={x:0,y:0},r=window.getComputedStyle(e);if(!r.transform||"none"===r.transform)return t;if(r.transform.indexOf("3d")>=0){var n=r.transform.trim().match(/matrix3d\((.*?)\)/);if(n&&n.length){var i,o=null===(i=n[1])||void 0===i?void 0:i.split(",");t.x=parseInt(o[12])||0,t.y=parseInt(o[13])||0}return t}var s=r.transform.trim().match(/matrix\((.*?)\)/);if(s&&s.length){var a,l=null===(a=s[1])||void 0===a?void 0:a.split(",");t.x=parseInt(l[4])||0,t.y=parseInt(l[5])||0}return t},E=function(e,t){return t?function(e){var t=e.style.transform;if(!t||t.indexOf("translate")<0)return k(e);var r={x:0,y:0},n=t.trim().match(/translate[3dD]*?\(.*?\)/);if(n){var i,o=null===(i=n[0])||void 0===i?void 0:i.split("(");if(o){var s,a=null===(s=o[1])||void 0===s?void 0:s.split(",");r.x=parseInt(a[0])||0,r.y=parseInt(a[1])||0}}return r.x||r.x?r:k(e)}(e):function(e){var t=e.style,r={x:parseInt(t.left)||0,y:parseInt(t.top)||0};if(!r.x&&!r.x){var n=window.getComputedStyle(e);return{x:parseInt(n.left)||0,y:parseInt(n.top)||0}}return r}(e)},x=function(e){var t=e.computedStyle,r=e.node,n=t.position;r instanceof HTMLDocument||("absolute"===n||"relative"===n||"fixed"===n)||(r.style.position="relative")},I=function(e,t){return e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top},A=function(e){var t=e.element,r=e.posDirection,n=e.containerRect,i=e.useTransform,o=E(t,i),s=b(o,"+",r);C(t,s,i);var a=t.getBoundingClientRect();!function(e){var t=e.element,r=e.edges,n=e.elementRect,i=e.containerRect,o=e.elementPos,s=e.useTransform;r.includes("top")&&C(t,{y:o.y+i.top-n.top,x:o.x},s),r.includes("left")&&C(t,{y:o.y,x:o.x+i.left-n.left},s),r.includes("bottom")&&C(t,{y:o.y+i.bottom-n.bottom,x:o.x},s),r.includes("right")&&C(t,{y:o.y,x:o.x+i.right-n.right},s)}({element:t,edges:w({elementRect:a,containerRect:n}),elementRect:a,containerRect:n,elementPos:s,useTransform:i})},C=function(e,t,r){if(r){var n=e.style.transform;e.style.transform="translate3d(".concat(t.x,"px,").concat(t.y,"px,1px) ").concat(n.replace(/translate.*?\)/g,""))}else e.style.left="".concat(t.x,"px"),e.style.top="".concat(t.y,"px");return e},L=function(e){for(var t=e.subscribe,r=e.publish,o=e.Interaction,s=e.SelectedSet,a=function(){var e=S(c[l],2),a=e[0],u=e[1];["pre",!1].forEach((function(e){return t(e?"".concat(a,":").concat(e):a,(function(t){return u.forEach((function(a){return(!a.condition||a.condition(t))&&r(e?"".concat(e).concat(a.name):a.name,function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach((function(t){n(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({items:s.elements,isDragging:o.isDragging},t))}))}))}))},l=0,c=Object.entries({"Selected:added":[{name:"elementselect"}],"Selected:removed":[{name:"elementunselect"}],"Area:scroll":[{name:"autoscroll"}],"Interaction:start":[{name:"dragstart"}],"Interaction:update":[{name:"dragmove",condition:function(e){return e.event}}],"Interaction:end":[{name:"callback"}]});l<c.length;l++)a()},T=function(e){return e?!Array.isArray(e)&&(e instanceof HTMLElement||e instanceof SVGElement)?[e]:p(e):[]},V=function(e,t){e.style.left="".concat(t.left,"px"),e.style.top="".concat(t.top,"px"),e.style.width="".concat(t.width,"px"),e.style.height="".concat(t.height,"px")},N=function(){function t(r){var i,o,s,a=this,l=r.area,c=r.PS,u=r.zoom;e(this,t),n(this,"_modificationCallback",void 0),n(this,"_modificationObserver",void 0),n(this,"_zoom",void 0),n(this,"_node",void 0),n(this,"_parentNodes",void 0),n(this,"_computedStyle",void 0),n(this,"_computedBorder",void 0),n(this,"_rect",void 0),n(this,"setArea",(function(e){a._node=e,x({computedStyle:a.computedStyle,node:a._node}),setTimeout((function(){a.PubSub.publish("Area:modified:pre",{item:a}),a.reset(),a.PubSub.publish("Area:modified",{item:a})}))})),n(this,"start",(function(){var e,t,r;e=a.parentNodes,t=a._modificationCallback,r=a._modificationObserver,window.addEventListener("resize",t),window.addEventListener("scroll",t),e.forEach((function(e,t){r.observe(e,{childList:0!==t,attributes:!0})}))})),n(this,"reset",(function(){a._computedStyle=void 0,a._rect=void 0,a._computedBorder=void 0,a._parentNodes=void 0})),n(this,"stop",(function(){var e,t;e=a._modificationObserver,t=a._modificationCallback,window.removeEventListener("resize",t),window.removeEventListener("scroll",t),e.disconnect(),a.reset()})),n(this,"scroll",(function(e,t){var r={scroll_directions:e,scroll_multiplier:t};a.PubSub.publish("Area:scroll:pre",r),function(e,t,r){if(t.length){var n=document&&document.documentElement&&document.documentElement.scrollTop&&document.documentElement,i=e instanceof HTMLDocument?n||document.body:e,o=t.includes("top")&&i.scrollTop>0,s=t.includes("bottom")&&i.scrollTop<i.scrollHeight,a=t.includes("left")&&i.scrollLeft>0,l=t.includes("right")&&i.scrollLeft<i.scrollWidth;o&&(i.scrollTop-=1*r),s&&(i.scrollTop+=1*r),a&&(i.scrollLeft-=1*r),l&&(i.scrollLeft+=1*r)}}(a._node,e,t),a.PubSub.publish("Area:scroll",r)})),this._zoom=u,this.PubSub=c,this.setArea(l),this._modificationCallback=(i=function(e){a.PubSub.publish("Area:modified:pre",{event:e,item:a}),a.reset(),a.PubSub.publish("Area:modified",{event:e,item:a})},o=60,function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=function(){s=null,i.apply(void 0,t)};clearTimeout(s),s=setTimeout(n,o)}),this._modificationObserver=new MutationObserver(this._modificationCallback),this.PubSub.subscribe("Interaction:init",this.start),this.PubSub.subscribe("Interaction:end",this.reset)}return r(t,[{key:"HTMLNode",get:function(){return this._node}},{key:"computedBorder",get:function(){return this._computedBorder?this._computedBorder:{top:parseInt(this.computedStyle.borderTopWidth),bottom:parseInt(this.computedStyle.borderBottomWidth),left:parseInt(this.computedStyle.borderLeftWidth),right:parseInt(this.computedStyle.borderRightWidth)}}},{key:"computedStyle",get:function(){return this._computedStyle?this._computedStyle:this.HTMLNode instanceof HTMLDocument?this._computedStyle=window.getComputedStyle(this.HTMLNode.body||this.HTMLNode.documentElement):this._computedStyle=window.getComputedStyle(this.HTMLNode)}},{key:"rect",get:function(){return this._rect?this._rect:this._rect=function(e,t){if(e instanceof Document)return{top:0,left:0,bottom:0,right:0,width:window.innerWidth,height:window.innerHeight};var r=e.getBoundingClientRect();return{top:r.top,left:r.left,bottom:r.bottom,right:r.right,width:(e.clientWidth||r.width)*t,height:(e.clientHeight||r.height)*t}}(this.HTMLNode,this._zoom)}},{key:"parentNodes",get:function(){if(this._parentNodes)return this._parentNodes;return this._parentNodes=function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=null===(r=t[n])||void 0===r?void 0:r.parentNode;return i?(t.push(i),e(t,++n)):t}([this.HTMLNode]),this._parentNodes}}]),t}(),M=function(){function t(r){var i=this,o=r.DS,s=r.dragKeys,a=r.draggability,l=r.keyboardDrag,c=r.keyboardDragSpeed,u=r.useTransform,d=r.zoom;e(this,t),n(this,"_useTransform",void 0),n(this,"_prevCursorPos",void 0),n(this,"_prevScrollPos",void 0),n(this,"_elements",[]),n(this,"_draggability",void 0),n(this,"_dragKeys",void 0),n(this,"_dragKeysFlat",void 0),n(this,"_keyboardDrag",void 0),n(this,"_keyboardDragSpeed",void 0),n(this,"_zoom",void 0),n(this,"keyboardDrag",(function(e){var t=e.event,r=e.key;if(i._keyboardDrag&&i._dragKeysFlat.includes(r)&&i.DS.SelectedSet.size&&i._draggability&&!i.DS.continue){var n={event:t,isDragging:!0,isDraggingKeyboard:!0};i.DS.publish(["Interaction:start:pre","Interaction:start"],n),i._elements=i.DS.getSelection(),i.handleZIndex(!0);var o=function(e){var t=e.shiftKey,r=e.keyboardDragSpeed,n=e.zoom,i=e.key,o=e.dragKeys,s=e.scrollDiff,a=e.canScroll,l=e.scrollCallback,c={x:0,y:0},u=t?4*r*n:r*n;return o.left.includes(i)&&(c.x=s.x||-u,t||s.x||!a||l(["left"],r)),o.right.includes(i)&&(c.x=s.x||u,t||s.x||!a||l(["right"],r)),o.up.includes(i)&&(c.y=s.y||-u,t||s.y||!a||l(["top"],r)),o.down.includes(i)&&(c.y=s.y||u,t||s.y||!a||l(["bottom"],r)),c}({shiftKey:i.DS.stores.KeyStore.currentValues.includes("shift"),keyboardDragSpeed:i._keyboardDragSpeed,zoom:i._zoom,key:r,scrollCallback:i.DS.Area.scroll,scrollDiff:i._scrollDiff,canScroll:i.DS.stores.ScrollStore.canScroll,dragKeys:i._dragKeys});i._elements.forEach((function(e){return A({element:e,posDirection:o,containerRect:i.DS.SelectorArea.rect,useTransform:i._useTransform})})),i.DS.publish(["Interaction:update:pre","Interaction:update"],n)}})),n(this,"keyboardEnd",(function(e){var t=e.event,r=e.key;if(i._keyboardDrag&&i._dragKeysFlat.includes(r)&&i.DS.SelectedSet.size&&i._draggability){var n={event:t,isDragging:i._draggability,isDraggingKeyboard:!0};i.DS.publish(["Interaction:end:pre","Interaction:end"],n)}})),n(this,"start",(function(e){var t=e.isDragging,r=e.isDraggingKeyboard;t&&!r&&(i._prevCursorPos=null,i._prevScrollPos=null,i._elements=i.DS.getSelection(),i.handleZIndex(!0))})),n(this,"stop",(function(e){null!=e&&e.isKeyboard||(i._prevCursorPos=null,i._prevScrollPos=null,i.handleZIndex(!1),i._elements=[])})),n(this,"update",(function(e){var t=e.isDragging,r=e.isDraggingKeyboard;if(t&&i._elements.length&&!r&&!i.DS.continue){var n=b(i._cursorDiff,"+",i._scrollDiff);i._elements.forEach((function(e){return A({element:e,posDirection:n,containerRect:i.DS.SelectorArea.rect,useTransform:i._useTransform})}))}})),n(this,"handleZIndex",(function(e){i._elements.forEach((function(t){return t.style.zIndex="".concat((parseInt(t.style.zIndex)||0)+e?9999:-9998)}))})),this.DS=o,this._useTransform=u,this._keyboardDragSpeed=c,this._keyboardDrag=l,this._zoom=d,this._draggability=a,this._dragKeys={up:s.up.map((function(e){return e.toLowerCase()})),down:s.down.map((function(e){return e.toLowerCase()})),left:s.left.map((function(e){return e.toLowerCase()})),right:s.right.map((function(e){return e.toLowerCase()}))},this._dragKeysFlat=[].concat(p(this._dragKeys.up),p(this._dragKeys.down),p(this._dragKeys.left),p(this._dragKeys.right)),this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:end",this.stop),this.DS.subscribe("Interaction:update",this.update),this.DS.subscribe("KeyStore:down",this.keyboardDrag),this.DS.subscribe("KeyStore:up",this.keyboardEnd)}return r(t,[{key:"_cursorDiff",get:function(){var e=this.DS.stores.PointerStore.currentVal,t=this._prevCursorPos?b(e,"-",this._prevCursorPos):{x:0,y:0};return this._prevCursorPos=e,t}},{key:"_scrollDiff",get:function(){var e=this.DS.stores.ScrollStore.currentVal,t=this._prevScrollPos?b(e,"-",this._prevScrollPos):{x:0,y:0};return this._prevScrollPos=e,t}}]),t}(),K=function(){function t(r){var i=this,o=r.areaElement,s=r.DS,a=r.draggability,l=r.immediateDrag;e(this,t),n(this,"_areaElement",void 0),n(this,"_draggability",void 0),n(this,"_immediateDrag",void 0),n(this,"isInteracting",void 0),n(this,"isDragging",void 0),n(this,"init",(function(){return i.DS.publish("Interaction:init:pre",{})})),n(this,"_init",(function(){i.stop(),i._areaElement.addEventListener("mousedown",i.start),i._areaElement.addEventListener("touchstart",i.start,{passive:!1}),i.DS.publish("Interaction:init",{})})),n(this,"start",(function(e){return i.DS.publish("Interaction:start:pre",{event:e,isDragging:i.isDragging})})),n(this,"_start",(function(e){"touchstart"===e.type&&e.preventDefault(),i._canInteract(e)&&(i.isInteracting=!0,i.isDragging=i.isDragEvent(e),i.DS.publish("Interaction:start",{event:e,isDragging:i.isDragging}),document.addEventListener("mouseup",i.reset),document.addEventListener("touchend",i.reset))})),n(this,"isDragEvent",(function(e){return!(!i._draggability||i.DS.stores.KeyStore.isMultiSelectKeyPressed(e)||!i.DS.SelectableSet.has(e.target))&&(i._immediateDrag&&(i.DS.SelectedSet.size?i.DS.SelectedSet.has(e.target)||(i.DS.SelectedSet.clear(),i.DS.SelectedSet.add(e.target)):i.DS.SelectedSet.add(e.target)),!!i.DS.SelectedSet.has(e.target))})),n(this,"onClick",(function(e){var t=e.event;if(i._canInteract(t)&&!(t.detail>0)){var r=i.DS,n=r.stores,o=n.PointerStore,s=n.KeyStore,a=r.SelectableSet,l=r.SelectedSet;o.start(t);var c=t.target;a.has(c)&&(s.isMultiSelectKeyPressed(t)||l.clear(),l.toggle(c),i.reset())}})),n(this,"stop",(function(){i.isInteracting=!1,i.isDragging=!1,i._areaElement.removeEventListener("mousedown",i.start),i._areaElement.removeEventListener("touchstart",i.start,{passive:!1}),document.removeEventListener("mouseup",i.reset),document.removeEventListener("touchend",i.reset)})),n(this,"update",(function(e){var t=e.event,r=e.scroll_directions,n=e.scroll_multiplier;i.isInteracting&&i.DS.publish(["Interaction:update:pre","Interaction:update"],{event:t,scroll_directions:r,scroll_multiplier:n,isDragging:i.isDragging})})),n(this,"reset",(function(e){return i.DS.publish("Interaction:end:pre",{event:e,isDragging:i.isDragging})})),n(this,"_reset",(function(e){var t=i.isDragging;i.stop(),i.init(),i.DS.publish("Interaction:end",{event:e,isDragging:t})})),this._areaElement=o,this._draggability=a,this._immediateDrag=l,this.DS=s,this.DS.subscribe("PointerStore:updated",this.update),this.DS.subscribe("Selectable:click",this.onClick),this.DS.subscribe("Selectable:pointer",(function(e){var t=e.event;return i.start(t)})),this.DS.subscribe("Interaction:start:pre",(function(e){var t=e.event;return i._start(t)})),this.DS.subscribe("Interaction:init:pre",this._init),this.DS.subscribe("Interaction:end:pre",(function(e){var t=e.event;return i._reset(t)})),this.DS.subscribe("Area:scroll",this.update)}return r(t,[{key:"_canInteract",value:function(e){var t=0===e.clientX&&0===e.clientY&&0===e.detail&&e.target;return!(2===e.button||this.isInteracting||e.target&&!this.DS.SelectorArea.isInside(e.target)||!t&&!this.DS.SelectorArea.isClicked(e))}}]),t}(),O=function t(r){var i=this,o=r.DS;e(this,t),n(this,"subscribers",{}),n(this,"subscribe",(function(e,t){return Array.isArray(i.subscribers[e])||(i.subscribers[e]=[]),i.subscribers[e].push(t),i.subscribers[e].length-1})),n(this,"unsubscribe",(function(e,t,r){r>=0?i.subscribers[e].splice(r,1):t&&(i.subscribers[e]=i.subscribers[e].filter((function(e){return e!==t})))})),n(this,"publish",(function(e,t){Array.isArray(e)?e.forEach((function(e){return i._publish(e,t)})):i._publish(e,t)})),n(this,"_publish",(function(e,t){var r=i.subscribers[e];Array.isArray(r)&&(e.includes(":pre")?i._handlePrePublish(r,t):i._handlePublish(r,t))})),n(this,"_handlePublish",(function(e,t){for(var r=0,n=e.length;r<n;r++){if(i.DS.stopped)return;e[r](t)}})),n(this,"_handlePrePublish",(function(e,t){for(var r=e.length;r--;){if(i.DS.stopped)return;e[r](t)}})),this.DS=o},j=function(t){o(a,t);var i=f(a);function a(t){var r,o=t.elements,s=t.className,l=t.hoverClassName,c=t.draggability,u=t.useTransform,h=t.DS;return e(this,a),n(d(r=i.call(this)),"_initElements",void 0),n(d(r),"_className",void 0),n(d(r),"_hoverClassName",void 0),n(d(r),"_useTransform",void 0),n(d(r),"_draggability",void 0),n(d(r),"init",(function(){return r._initElements.forEach((function(e){return r.add(e)}))})),n(d(r),"clear",(function(){return r.forEach((function(e){return r.delete(e)}))})),n(d(r),"_onClick",(function(e){return r.DS.publish(["Selectable:click:pre","Selectable:click"],{event:e})})),n(d(r),"_onPointer",(function(e){return r.DS.publish(["Selectable:pointer:pre","Selectable:pointer"],{event:e})})),n(d(r),"addAll",(function(e){return e.forEach((function(e){return r.add(e)}))})),n(d(r),"deleteAll",(function(e){return e.forEach((function(e){return r.delete(e)}))})),r.DS=h,r._initElements=T(o),r._className=s,r._hoverClassName=l,r._useTransform=u,r._draggability=c,r.DS.subscribe("Interaction:init",r.init),r}return r(a,[{key:"add",value:function(e){return e.classList.add(this._className),e.addEventListener("click",this._onClick),e.addEventListener("mousedown",this._onPointer),e.addEventListener("touchstart",this._onPointer,{passive:!1}),this._draggability&&!this._useTransform&&x({computedStyle:window.getComputedStyle(e),node:e}),v(s(a.prototype),"add",this).call(this,e)}},{key:"delete",value:function(e){return e.classList.remove(this._className),e.classList.remove(this._hoverClassName),e.removeEventListener("click",this._onClick),e.removeEventListener("mousedown",this._onPointer),e.removeEventListener("touchstart",this._onPointer,{passive:!1}),v(s(a.prototype),"delete",this).call(this,e)}},{key:"elements",get:function(){return Array.from(this.values())}}]),a}(u(Set)),z=function(t){o(a,t);var i=f(a);function a(t){var r,o=t.className,s=t.DS;return e(this,a),n(d(r=i.call(this)),"_className",void 0),n(d(r),"clear",(function(){return r.forEach((function(e){return r.delete(e)}))})),n(d(r),"addAll",(function(e){return e.forEach((function(e){return r.add(e)}))})),n(d(r),"deleteAll",(function(e){return e.forEach((function(e){return r.delete(e)}))})),r.DS=s,r._className=o,r}return r(a,[{key:"add",value:function(e){if(!v(s(a.prototype),"has",this).call(this,e)){var t={items:this.elements,item:e};return this.DS.publish("Selected:added:pre",t),v(s(a.prototype),"add",this).call(this,e),e.classList.add(this._className),e.style.zIndex="".concat((parseInt(e.style.zIndex)||0)+1),this.DS.publish("Selected:added",t),this}}},{key:"delete",value:function(e){if(v(s(a.prototype),"has",this).call(this,e)){var t={items:this.elements,item:e};this.DS.publish("Selected:removed:pre",t);var r=v(s(a.prototype),"delete",this).call(this,e);return e.classList.remove(this._className),e.style.zIndex="".concat((parseInt(e.style.zIndex)||0)-1),this.DS.publish("Selected:removed",t),r}}},{key:"toggle",value:function(e){return this.has(e)?this.delete(e):this.add(e),e}},{key:"elements",get:function(){return Array.from(this.values())}}]),a}(u(Set)),H=function(){function t(r){var i=this,o=r.DS,s=r.hoverClassName,a=r.multiSelectToggling;e(this,t),n(this,"_prevSelectedSet",void 0),n(this,"_hoverClassName",void 0),n(this,"_multiSelectToggling",void 0),n(this,"start",(function(e){var t=e.event;e.isDragging||(i._storePrevious(t),i._handleInsideSelection(!0,t))})),n(this,"update",(function(e){e.isDragging||i.DS.continue||i._handleInsideSelection()})),n(this,"_handleInsideSelection",(function(e,t){for(var r=i.DS,n=r.SelectableSet,o=r.SelectorArea,s=r.Selector,a=n.elements.map((function(e){return[e,e.getBoundingClientRect()]})),l=[],c=[],u=0,d=a.length;u<d;u++)o.isInside(a[u][0],a[u][1])&&(I(a[u][1],s.rect)?l.push(a[u][0]):c.push(a[u][0]));var h=i.DS.stores.KeyStore.isMultiSelectKeyPressed(t)&&i._multiSelectToggling;i.DS.continue||(l.forEach((function(t){return function(e){var t=e.element,r=e.force,n=e.multiSelectionToggle,i=e.SelectedSet,o=e.hoverClassName;t.classList.contains(o)&&!r||(i.has(t)?n&&i.delete(t):i.add(t),t.classList.add(o))}({element:t,force:e,multiSelectionToggle:h,SelectedSet:i.DS.SelectedSet,hoverClassName:i._hoverClassName})})),c.forEach((function(t){return function(e){var t=e.element,r=e.force,n=e.SelectedSet,i=e.PrevSelectedSet,o=e.hoverClassName;if(!t.classList.contains(o)&&!r)return!1;var s=n.has(t),a=i.has(t);s&&!a?n.delete(t):!s&&a&&n.add(t),t.classList.remove(o)}({element:t,force:e,SelectedSet:i.DS.SelectedSet,hoverClassName:i._hoverClassName,PrevSelectedSet:i._prevSelectedSet})})))})),this._hoverClassName=s,this._multiSelectToggling=a,this.DS=o,this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:update",this.update)}return r(t,[{key:"_storePrevious",value:function(e){var t=this.DS,r=t.stores.KeyStore,n=t.SelectedSet;r.isMultiSelectKeyPressed(e)?this._prevSelectedSet=new Set(n):this._prevSelectedSet=new Set}}]),t}(),R=function(){function t(r){var i=this,o=r.DS,s=r.selector,a=r.selectorClass,l=r.customStyles;e(this,t),n(this,"_rect",void 0),n(this,"start",(function(e){if(!e.isDragging){var t=i.DS.stores.PointerStore.initialValArea;V(i.HTMLNode,_(t,1)),i.HTMLNode.style.display="block",i._rect=null}})),n(this,"stop",(function(){i.HTMLNode.style.width="0",i.HTMLNode.style.height="0",i.HTMLNode.style.display="none"})),n(this,"update",(function(e){if(!e.isDragging&&!i.DS.continue){var t=i.DS.stores,r=t.ScrollStore,n=t.PointerStore,o=function(e){var t=e.scrollAmount,r=e.initialPointerPos,n=e.pointerPos,i={};return n.x>r.x-t.x?(i.left=r.x-t.x,i.width=n.x-r.x+t.x):(i.left=n.x,i.width=r.x-n.x-t.x),n.y>r.y-t.y?(i.top=r.y-t.y,i.height=n.y-r.y+t.y):(i.top=n.y,i.height=r.y-n.y-t.y),i}({scrollAmount:r.scrollAmount,initialPointerPos:n.initialValArea,pointerPos:n.currentValArea});V(i.HTMLNode,o),i._rect=null}})),this.DS=o,this.HTMLNode=s||function(e){var t=document.createElement("div");return t.style.position="absolute",e||(t.style.background="rgba(0, 0, 255, 0.1)",t.style.border="1px solid rgba(0, 0, 255, 0.45)",t.style.display="none",t.style.pointerEvents="none"),t}(l),this.HTMLNode.classList.add(a),this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:update",this.update),this.DS.subscribe("Interaction:end",this.stop)}return r(t,[{key:"rect",get:function(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}]),t}(),B=function(){function t(r){var i=this,o=r.DS,s=r.selectorAreaClass,a=r.autoScrollSpeed,l=r.overflowTolerance;e(this,t),n(this,"_autoScrollSpeed",void 0),n(this,"_scrollInterval",void 0),n(this,"_rect",void 0),n(this,"currentEdges",[]),n(this,"_overflowTolerance",void 0),n(this,"start",(function(){return i.applyElements("append")})),n(this,"applyElements",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"append",t=document.body?"body":"documentElement",r="".concat(e,"Child");i.HTMLNode[r](i.DS.Selector.HTMLNode),document[t][r](i.HTMLNode)})),n(this,"updatePos",(function(){i._rect=null;var e=i.DS.Area.rect,t=i.DS.Area.computedBorder,r=i.HTMLNode.style,n="".concat(e.top+t.top,"px"),o="".concat(e.left+t.left,"px"),s="".concat(e.width,"px"),a="".concat(e.height,"px");r.top!==n&&(r.top=n),r.left!==o&&(r.left=o),r.width!==s&&(r.width=s),r.height!==a&&(r.height=a)})),n(this,"stop",(function(e){i.stopAutoScroll(),e&&i.applyElements("remove")})),n(this,"startAutoScroll",(function(){i.currentEdges=[],i._scrollInterval=setInterval((function(){return i.handleAutoScroll()}),16)})),n(this,"handleAutoScroll",(function(){if(!i.DS.continue){var e=i.DS,t=e.stores.PointerStore,r=e.Area;i.currentEdges=w({elementRect:_(t.currentVal),containerRect:i.rect,tolerance:i._overflowTolerance}),i.currentEdges.length&&r.scroll(i.currentEdges,i._autoScrollSpeed)}})),n(this,"stopAutoScroll",(function(){i.currentEdges=[],clearInterval(i._scrollInterval)})),n(this,"isInside",(function(e,t){return!(!i.DS.Area.HTMLNode.contains(e)||!i.DS.stores.ScrollStore.canScroll)||I(i.rect,t||e.getBoundingClientRect())})),this._autoScrollSpeed=a,this._overflowTolerance=l,this.DS=o,this.HTMLNode=function(e){var t=document.createElement("div");return t.style.position="fixed",t.style.overflow="hidden",t.style.pointerEvents="none",t.style.zIndex="999999999999999999",t.classList.add(e),t}(s),this.DS.subscribe("Area:modified",this.updatePos),this.DS.subscribe("Interaction:init",this.start),this.DS.subscribe("Interaction:start",this.startAutoScroll),this.DS.subscribe("Interaction:end",(function(){i.updatePos(),i.stopAutoScroll()}))}return r(t,[{key:"isClicked",value:function(e){var t=this.DS.stores.PointerStore,r=e?t.getPointerPosition(e):t.initialVal;return I({left:r.x,top:r.y,right:r.x,bottom:r.y},this.rect)}},{key:"rect",get:function(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}]),t}(),U=function(){function t(r){var i=this,o=r.DS,s=r.multiSelectKeys,a=r.multiSelectMode;e(this,t),n(this,"_multiSelectMode",void 0),n(this,"_multiSelectKeys",void 0),n(this,"_currentValues",new Set),n(this,"_keyMapping",{control:"ctrlKey",shift:"shiftKey",meta:"metaKey"}),n(this,"init",(function(){document.addEventListener("keydown",i.keydown),document.addEventListener("keyup",i.keyup),window.addEventListener("blur",i.reset)})),n(this,"keydown",(function(e){var t=e.key.toLowerCase();i.DS.publish("KeyStore:down:pre",{event:e,key:t}),i._currentValues.add(t),i.DS.publish("KeyStore:down",{event:e,key:t})})),n(this,"keyup",(function(e){var t=e.key.toLowerCase();i.DS.publish("KeyStore:up:pre",{event:e,key:t}),i._currentValues.delete(t),i.DS.publish("KeyStore:up",{event:e,key:t})})),n(this,"stop",(function(){document.removeEventListener("keydown",i.keydown),document.removeEventListener("keyup",i.reset),window.removeEventListener("blur",i.reset),i.reset()})),n(this,"reset",(function(){return i._currentValues.clear()})),this.DS=o,this._multiSelectMode=a,this._multiSelectKeys=s.map((function(e){var t={ctrlKey:"Control",shiftKey:"Shift",metaKey:"Meta"}[e];return t?(console.warn("[DragSelect] ".concat(e,' is deprecated. Use "').concat(t,'" instead. Act Now!. See docs for more info')),t.toLowerCase()):e.toLowerCase()})),this.DS.subscribe("Interaction:init",this.init)}return r(t,[{key:"isMultiSelectKeyPressed",value:function(e){var t=this;return!!this._multiSelectMode||(!!this.currentValues.some((function(e){return t._multiSelectKeys.includes(e)}))||!(!e||!this._multiSelectKeys.some((function(r){return e[t._keyMapping[r]]}))))}},{key:"currentValues",get:function(){return Array.from(this._currentValues.values())}}]),t}(),W=function(){function t(r){var i=this,o=r.DS;e(this,t),n(this,"_isMouseInteraction",!1),n(this,"_initialValArea",void 0),n(this,"_currentValArea",void 0),n(this,"_lastValArea",void 0),n(this,"_initialVal",void 0),n(this,"_currentVal",void 0),n(this,"_lastVal",void 0),n(this,"_lastTouch",void 0),n(this,"init",(function(){document.addEventListener("mousemove",i.update),document.addEventListener("touchmove",i.update,{passive:!1})})),n(this,"getPointerPosition",(function(e){return function(e){var t=e.event;return{x:t.clientX,y:t.clientY}}({event:i._normalizedEvent(e)})})),n(this,"update",(function(e){e&&(i.DS.publish("PointerStore:updated:pre",{event:e}),i.currentVal=i.getPointerPosition(e),i._isMouseInteraction&&i.DS.publish("PointerStore:updated",{event:e}))})),n(this,"stop",(function(){document.removeEventListener("mousemove",i.update),document.removeEventListener("touchmove",i.update,{passive:!1}),setTimeout((function(){return i._isMouseInteraction=!1}),100)})),n(this,"reset",(function(e){e&&(i.currentVal=i.lastVal=i.getPointerPosition(e),i.stop(),i.init())})),this.DS=o,this.DS.subscribe("Interaction:init",this.init),this.DS.subscribe("Interaction:start",(function(e){var t=e.event;return i.start(t)})),this.DS.subscribe("Interaction:end",(function(e){var t=e.event;return i.reset(t)}))}return r(t,[{key:"start",value:function(e){e&&(this._isMouseInteraction=!0,this.currentVal=this.initialVal=this.getPointerPosition(e))}},{key:"_normalizedEvent",value:function(e){return"touches"in e&&"touchend"!==e.type&&(this._lastTouch=e),"touches"in e?this._lastTouch.touches[0]:e}},{key:"initialValArea",get:function(){return this._initialValArea?this._initialValArea:{x:0,y:0}}},{key:"currentValArea",get:function(){return this._currentValArea?this._currentValArea:{x:0,y:0}}},{key:"lastValArea",get:function(){return this._lastValArea?this._lastValArea:{x:0,y:0}}},{key:"initialVal",get:function(){return this._initialVal?this._initialVal:{x:0,y:0}},set:function(e){this._initialVal=e,this._initialValArea=e&&b(e,"-",b(y(this.DS.Area.rect),"+",y(this.DS.Area.computedBorder)))}},{key:"currentVal",get:function(){return this._currentVal?this._currentVal:{x:0,y:0}},set:function(e){this._currentVal=e,this._currentValArea=e&&b(e,"-",b(y(this.DS.Area.rect),"+",y(this.DS.Area.computedBorder)))}},{key:"lastVal",get:function(){return this._lastVal?this._lastVal:{x:0,y:0}},set:function(e){this._lastVal=e,this._lastValArea=e&&b(e,"-",b(y(this.DS.Area.rect),"+",y(this.DS.Area.computedBorder)))}}]),t}(),F=function(){function t(r){var i=this,o=r.DS,s=r.areaElement,a=r.zoom;e(this,t),n(this,"_initialVal",void 0),n(this,"_currentVal",void 0),n(this,"_areaElement",void 0),n(this,"_canScroll",void 0),n(this,"init",(function(){return i._areaElement.addEventListener("scroll",i.update)})),n(this,"start",(function(){i._currentVal=i._initialVal=P(i._areaElement),i._areaElement.addEventListener("scroll",i.update)})),n(this,"update",(function(){return i._currentVal=P(i._areaElement)})),n(this,"stop",(function(){i._areaElement.removeEventListener("scroll",i.update),i._initialVal={x:0,y:0},i._canScroll=null})),n(this,"reset",(function(){i.stop(),i.start()})),this._areaElement=s,this.DS=o,this.zoom=a,this.DS.subscribe("Interaction:init",this.init),this.DS.subscribe("Interaction:start",(function(){return i.start()})),this.DS.subscribe("Interaction:end",(function(){return i.reset()}))}return r(t,[{key:"canScroll",get:function(){return"boolean"==typeof this._canScroll?this._canScroll:this._canScroll=(e=this._areaElement,!!((t=P(e)).x||t.y||(e instanceof HTMLDocument?e.body?e.body.scrollTop=1:e.documentElement.scrollTop=1:e.scrollTop=1)));var e,t}},{key:"scrollAmount",get:function(){var e,t=b(this.currentVal,"-",this.initialVal),r={x:e=this.zoom,y:e},n=b(b(t,"*",r),"-",t);return{x:t.x+n.x,y:t.y+n.y}}},{key:"initialVal",get:function(){return this._initialVal?this._initialVal:{x:0,y:0}}},{key:"currentVal",get:function(){return this._currentVal||(this._currentVal=P(this._areaElement)),this._currentVal}}]),t}();return function(){function t(r){var i=this,o=r.area,s=void 0===o?document:o,a=r.selectables,l=void 0===a?[]:a,c=r.autoScrollSpeed,u=void 0===c?5:c,d=r.overflowTolerance,h=void 0===d?{x:25,y:25}:d,f=r.zoom,v=void 0===f?1:f,S=r.customStyles,p=void 0!==S&&S,m=r.multiSelectMode,g=void 0!==m&&m,b=r.multiSelectToggling,y=void 0===b||b,_=r.multiSelectKeys,D=void 0===_?["Control","Shift","Meta"]:_,P=r.selector,w=void 0===P?void 0:P,k=r.draggability,E=void 0===k||k,x=r.immediateDrag,I=void 0===x||x,A=r.keyboardDrag,C=void 0===A||A,T=r.dragKeys,V=r.keyboardDragSpeed,Z=void 0===V?10:V,X=r.useTransform,Y=void 0===X||X,G=r.hoverClass,$=void 0===G?"ds-hover":G,q=r.selectableClass,J=void 0===q?"ds-selectable":q,Q=r.selectedClass,ee=void 0===Q?"ds-selected":Q,te=r.selectorClass,re=void 0===te?"ds-selector":te,ne=r.selectorAreaClass,ie=void 0===ne?"ds-selector-area":ne,oe=r.callback,se=r.onDragMove,ae=r.onDragStartBegin,le=r.onDragStart,ce=r.onElementSelect,ue=r.onElementUnselect;e(this,t),n(this,"continue",!1),n(this,"start",(function(){i.stopped=!1,i.Interaction.init()})),n(this,"break",(function(){return i.continue=!0})),n(this,"getSelection",(function(){return i.SelectedSet.elements})),n(this,"getSelectables",(function(){return i.SelectableSet.elements})),n(this,"getInitialCursorPosition",(function(){return i.stores.PointerStore.initialVal})),n(this,"getCurrentCursorPosition",(function(){return i.stores.PointerStore.currentVal})),n(this,"getPreviousCursorPosition",(function(){return i.stores.PointerStore.lastVal})),n(this,"getInitialCursorPositionArea",(function(){return i.stores.PointerStore.initialValArea})),n(this,"getCurrentCursorPositionArea",(function(){return i.stores.PointerStore.currentValArea})),n(this,"getPreviousCursorPositionArea",(function(){return i.stores.PointerStore.lastValArea})),n(this,"isMultiSelect",(function(e){return i.stores.KeyStore.isMultiSelectKeyPressed(e)})),n(this,"isDragging",(function(){return i.Interaction.isDragging})),this.PubSub=new O({DS:this}),this.subscribe=this.PubSub.subscribe,this.unsubscribe=this.PubSub.unsubscribe,this.publish=this.PubSub.publish,this._callbacksTemp({callback:oe,onDragMove:se,onDragStart:le,onDragStartBegin:ae,onElementSelect:ce,onElementUnselect:ue}),this.stores={PointerStore:new W({DS:this}),ScrollStore:new F({DS:this,areaElement:s,zoom:v}),KeyStore:new U({DS:this,multiSelectKeys:D,multiSelectMode:g})},this.Area=new N({area:s,PS:this.PubSub,zoom:v}),this.Selector=new R({DS:this,selector:w,selectorClass:re,customStyles:p}),this.SelectorArea=new B({DS:this,selectorAreaClass:ie,autoScrollSpeed:u,overflowTolerance:h}),this.SelectableSet=new j({elements:l,DS:this,className:J,hoverClassName:$,useTransform:Y,draggability:E}),this.SelectedSet=new z({DS:this,className:ee}),this.Selection=new H({DS:this,hoverClassName:$,multiSelectToggling:y}),this.Drag=new M({DS:this,draggability:E,useTransform:Y,keyboardDrag:C,dragKeys:Object.assign({up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]},T),zoom:v,keyboardDragSpeed:Z}),this.Interaction=new K({areaElement:s,DS:this,draggability:E,immediateDrag:I}),L({subscribe:this.subscribe,publish:this.publish,SelectedSet:this.SelectedSet,Interaction:this.Interaction}),this.subscribe("Interaction:end",(function(){return i.continue=!1})),this.start()}return r(t,[{key:"_callbacksTemp",value:function(e){var t=e.callback,r=e.onDragMove,n=e.onDragStart,i=e.onDragStartBegin,o=e.onElementSelect,s=e.onElementUnselect,a=function(e,t){return console.warn("[DragSelect] ".concat(e,' is deprecated. Use DragSelect.subscribe("').concat(t,'", (callbackObject) => {}) instead. Act Now! See docs for more info'))};t&&(a("callback","callback"),this.subscribe("callback",(function(e){var r=e.items,n=(e.item,e.event);return t(r,n)}))),r&&(a("onDragMove","dragmove"),this.subscribe("dragmove",(function(e){e.items,e.item;var t=e.event;return r(t)}))),n&&(a("onDragStart","dragstart"),this.subscribe("dragstart",(function(e){e.items,e.item;var t=e.event;return n(t)}))),i&&(a("onDragStartBegin","dragstart"),this.subscribe("dragstart",(function(e){e.items,e.item;var t=e.event;return i(t)}))),o&&(a("onElementSelect","elementselect"),this.subscribe("elementselect",(function(e){e.items;var t=e.item,r=e.event;return o(t,r)}))),s&&(a("onElementUnselect","elementunselect"),this.subscribe("elementunselect",(function(e){e.items;var t=e.item,r=e.event;return s(t,r)})))}},{key:"stop",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];r&&this.publish("callback",{items:this.getSelection()}),this.Interaction.stop(),this.Area.stop(),this.Drag.stop(),this.Selector.stop(),this.SelectorArea.stop(e),this.stores.KeyStore.stop(),this.stores.PointerStore.stop(),this.stores.ScrollStore.stop(),e&&this.SelectableSet.clear(),t&&this.SelectedSet.clear(),this.stopped=!0}},{key:"addSelection",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.addAll(T(e)),r||this.addSelectables(e),t&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"removeSelection",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.deleteAll(T(e)),r&&this.removeSelectables(e),t&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"toggleSelection",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return T(e).forEach((function(i){return t.SelectedSet.has(i)?t.removeSelection(e,r,n):t.addSelection(e,r,n)})),r&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"setSelection",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.clearSelection(),this.addSelection(e,t,r),this.getSelection()}},{key:"clearSelection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.SelectedSet.clear(),e&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"addSelectables",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=T(e);return this.SelectableSet.addAll(r),t&&this.SelectedSet.addAll(r),e}},{key:"setSelectables",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.removeSelectables(e,t),this.addSelectables(e,r)}},{key:"removeSelectables",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.SelectableSet.deleteAll(T(e)),t&&this.removeSelection(e),e}},{key:"getCursorPositionDifference",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];console.warn("[DragSelect] Using .getCursorPositionDifference is deprecated. Calculate yourself instead. i.e. `.getCurrentCursorPosition().x - .getInitialCursorPosition().x`");var r=t?this.getCurrentCursorPositionArea():this.getCurrentCursorPosition(),n=e?t?this.getPreviousCursorPositionArea():this.getPreviousCursorPosition():t?this.getInitialCursorPositionArea():this.getInitialCursorPosition();return b(r,"-",n)}}]),t}()}));
@@ -21,6 +21,7 @@ export { default as moveElement } from "./moveElement";
21
21
  export { default as removeModificationObservers } from "./removeModificationObservers";
22
22
  export { default as scrollElement } from "./scrollElement";
23
23
  export { default as setStylePosition } from "./setStylePosition";
24
+ export { default as subscriberAliases } from "./subscriberAliases";
24
25
  export { default as toArray } from "./toArray";
25
26
  export { default as updateElementStylePos } from "./updateElementStylePos";
26
27
  import "../types"
@@ -0,0 +1,12 @@
1
+ declare function _default({ subscribe, publish, Interaction, SelectedSet }: {
2
+ subscribe: DSSubscribe;
3
+ publish: DSPublish;
4
+ Interaction: Interaction;
5
+ SelectedSet: SelectedSet;
6
+ }): void;
7
+ export default _default;
8
+ export type DSSubscribe = Function;
9
+ export type DSPublish = Function;
10
+ import { Interaction } from "../modules";
11
+ import { SelectedSet } from "../modules";
12
+ import "../types"
@@ -1,17 +1,16 @@
1
+ /**
2
+ * @typedef {Object} AreaProps
3
+ * @property {DSArea} area
4
+ * @property {PubSub} PS
5
+ * @property {number} zoom
6
+ */
1
7
  export default class Area {
2
8
  /**
3
9
  * @constructor Area
4
- * @param {Object} obj
5
- * @param {DSArea} obj.area
6
- * @param {PubSub} obj.PS
7
- * @param {number} obj.zoom
10
+ * @param {AreaProps} settings
8
11
  * @ignore
9
12
  */
10
- constructor({ area, PS, zoom }: {
11
- area: DSArea;
12
- PS: PubSub;
13
- zoom: number;
14
- });
13
+ constructor({ area, PS, zoom }: AreaProps);
15
14
  /**
16
15
  * @type {DSModificationCallback}
17
16
  * @private
@@ -53,6 +52,8 @@ export default class Area {
53
52
  * */
54
53
  private _rect;
55
54
  PubSub: PubSub;
55
+ /** @param {DSArea} area */
56
+ setArea: (area: DSArea) => void;
56
57
  start: () => void;
57
58
  reset: () => void;
58
59
  stop: () => void;
@@ -85,5 +86,10 @@ export default class Area {
85
86
  get rect(): DSBoundingRect;
86
87
  get parentNodes(): DSArea[];
87
88
  }
89
+ export type AreaProps = {
90
+ area: DSArea;
91
+ PS: PubSub;
92
+ zoom: number;
93
+ };
88
94
  import { PubSub } from "./index.js";
89
95
  import "../types"
@@ -5,15 +5,17 @@ export default class Drag {
5
5
  * @param {boolean} p.draggability
6
6
  * @param {boolean} p.useTransform
7
7
  * @param {DSDragKeys} p.dragKeys
8
+ * @param {boolean} p.keyboardDrag
8
9
  * @param {number} p.keyboardDragSpeed
9
10
  * @param {number} p.zoom
10
11
  * @ignore
11
12
  */
12
- constructor({ DS, dragKeys, draggability, keyboardDragSpeed, useTransform, zoom, }: {
13
+ constructor({ DS, dragKeys, draggability, keyboardDrag, keyboardDragSpeed, useTransform, zoom, }: {
13
14
  DS: DragSelect;
14
15
  draggability: boolean;
15
16
  useTransform: boolean;
16
17
  dragKeys: DSDragKeys;
18
+ keyboardDrag: boolean;
17
19
  keyboardDragSpeed: number;
18
20
  zoom: number;
19
21
  });
@@ -52,6 +54,11 @@ export default class Drag {
52
54
  * @private
53
55
  */
54
56
  private _dragKeysFlat;
57
+ /**
58
+ * @type {boolean}
59
+ * @private
60
+ */
61
+ private _keyboardDrag;
55
62
  /**
56
63
  * @type {number}
57
64
  * @private
@@ -67,17 +74,18 @@ export default class Drag {
67
74
  event: any;
68
75
  key: any;
69
76
  }) => void;
70
- _isKeyboard: boolean;
71
77
  keyboardEnd: ({ event, key }: {
72
78
  event: any;
73
79
  key: any;
74
80
  }) => void;
75
- start: ({ isDragging }: {
81
+ start: ({ isDragging, isDraggingKeyboard }: {
76
82
  isDragging: any;
83
+ isDraggingKeyboard: any;
77
84
  }) => void;
78
- stop: () => void;
79
- update: ({ isDragging }: {
85
+ stop: (evt: any) => void;
86
+ update: ({ isDragging, isDraggingKeyboard }: {
80
87
  isDragging: any;
88
+ isDraggingKeyboard: any;
81
89
  }) => void;
82
90
  handleZIndex: (add: any) => void;
83
91
  get _cursorDiff(): Vect2;
@@ -35,11 +35,16 @@ export default class Interaction {
35
35
  isDragging: boolean;
36
36
  DS: DragSelect;
37
37
  init: () => void;
38
- _canInteract(event: any): boolean;
38
+ _init: () => void;
39
+ /**
40
+ * @param {DSEvent} event
41
+ */
42
+ _canInteract(event: DSEvent): boolean;
39
43
  /**
40
44
  * @param {DSEvent} event
41
45
  */
42
46
  start: (event: DSEvent) => void;
47
+ _start: (event: any) => void;
43
48
  /**
44
49
  * Drag interaction
45
50
  * @param {DSEvent} event
@@ -49,17 +54,19 @@ export default class Interaction {
49
54
  /**
50
55
  * Triggers when a node is actively selected: <button> nodes that are pressed via the keyboard.
51
56
  * Making DragSelect accessible for everyone!
52
- * @param {{ event:MouseEvent }} p
57
+ * @param {{ event:MouseEvent }} prop
53
58
  */
54
59
  onClick: ({ event }: {
55
60
  event: MouseEvent;
56
61
  }) => void;
57
62
  stop: () => void;
58
- update: ({ event, data }: {
63
+ update: ({ event, scroll_directions, scroll_multiplier }: {
59
64
  event: any;
60
- data: any;
65
+ scroll_directions: any;
66
+ scroll_multiplier: any;
61
67
  }) => void;
62
68
  reset: (event: any) => void;
69
+ _reset: (event: any) => void;
63
70
  }
64
71
  import DragSelect from "../DragSelect";
65
72
  import "../types"
@@ -1,5 +1,9 @@
1
1
  export default class PubSub {
2
+ constructor({ DS }: {
3
+ DS: any;
4
+ });
2
5
  subscribers: {};
6
+ DS: any;
3
7
  /**
4
8
  * Subscribe to an event
5
9
  * @memberof DragSelect#
@@ -22,9 +26,12 @@ export default class PubSub {
22
26
  * Publishes an event to all subscribers
23
27
  * @memberof DragSelect#
24
28
  * @function publish
25
- * @param {DSCallbackNames} eventName
26
- * @param {CallbackObject|*} data passed to the subscription method
29
+ * @param {DSCallbackNames|DSCallbackNames[]} eventName
30
+ * @param {CallbackObject} data passed to the subscription method
27
31
  */
28
- publish: (eventName: DSCallbackNames, data: CallbackObject | any) => void;
32
+ publish: (eventName: DSCallbackNames | DSCallbackNames[], data: CallbackObject) => void;
33
+ _publish: (eventName: any, data: any) => void;
34
+ _handlePublish: (subscribers: any, data: any) => void;
35
+ _handlePrePublish: (subscribers: any, data: any) => void;
29
36
  }
30
37
  import "../types"