dragselect 3.1.0 → 3.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/DragSelect.d.ts +2 -1
  3. package/dist/DragSelect.es6m.js +3886 -0
  4. package/dist/DragSelect.esm.js +34 -5
  5. package/dist/DragSelect.js +34 -5
  6. package/dist/ds.es6m.min.js +1 -0
  7. package/dist/ds.esm.min.js +1 -1
  8. package/dist/ds.min.js +1 -1
  9. package/dist/methods/addModificationObservers.d.ts +11 -0
  10. package/dist/methods/canScroll.d.ts +3 -0
  11. package/dist/methods/createSelectorAreaElement.d.ts +3 -0
  12. package/dist/methods/createSelectorElement.d.ts +3 -0
  13. package/dist/methods/debounce.d.ts +3 -0
  14. package/dist/methods/documentScroll.d.ts +6 -0
  15. package/dist/methods/getAllParentNodes.d.ts +3 -0
  16. package/dist/methods/getAreaRect.d.ts +3 -0
  17. package/dist/methods/getBoundingClientRect.d.ts +4 -0
  18. package/dist/methods/getCurrentScroll.d.ts +3 -0
  19. package/dist/methods/getOverflowEdges.d.ts +7 -0
  20. package/dist/methods/getPointerPos.d.ts +5 -0
  21. package/dist/methods/getSelectorPosition.d.ts +12 -0
  22. package/dist/methods/getStylePosition.d.ts +3 -0
  23. package/dist/methods/handleElementOverflow.d.ts +10 -0
  24. package/dist/methods/handleElementPositionAttribute.d.ts +6 -0
  25. package/dist/methods/handleKeyboardDragPosDifference.d.ts +13 -0
  26. package/dist/methods/handleSelection.d.ts +9 -0
  27. package/dist/methods/handleUnSelection.d.ts +9 -0
  28. package/dist/methods/hydrateSettings.d.ts +3 -0
  29. package/dist/methods/index.d.ts +30 -0
  30. package/dist/methods/isCollision.d.ts +13 -0
  31. package/dist/methods/moveElement.d.ts +8 -0
  32. package/dist/methods/removeModificationObservers.d.ts +3 -0
  33. package/dist/methods/scrollElement.d.ts +3 -0
  34. package/dist/methods/setStylePosition.d.ts +3 -0
  35. package/dist/methods/subscriberAliases.d.ts +14 -0
  36. package/dist/methods/toArray.d.ts +3 -0
  37. package/dist/methods/updateElementStylePos.d.ts +8 -0
  38. package/dist/methods/vect2.d.ts +8 -0
  39. package/dist/modules/Area.d.ts +80 -0
  40. package/dist/modules/Drag.d.ts +71 -0
  41. package/dist/modules/DropZone.d.ts +90 -0
  42. package/dist/modules/DropZones.d.ts +73 -0
  43. package/dist/modules/Interaction.d.ts +51 -0
  44. package/dist/modules/PubSub.d.ts +37 -0
  45. package/dist/modules/SelectableSet.d.ts +43 -0
  46. package/dist/modules/SelectedSet.d.ts +32 -0
  47. package/dist/modules/Selection.d.ts +54 -0
  48. package/dist/modules/Selector.d.ts +29 -0
  49. package/dist/modules/SelectorArea.d.ts +58 -0
  50. package/dist/modules/index.d.ts +11 -0
  51. package/dist/stores/KeyStore.d.ts +34 -0
  52. package/dist/stores/PointerStore.d.ts +83 -0
  53. package/dist/stores/ScrollStore.d.ts +38 -0
  54. package/dist/stores/SettingsStore.d.ts +39 -0
  55. package/dist/stores/index.d.ts +5 -0
  56. package/dist/types.d.ts +276 -0
  57. package/package.json +2 -2
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";const e=(e,t)=>{const s=t;window.addEventListener("resize",s),window.addEventListener("scroll",s);const i=new MutationObserver(s),r=new ResizeObserver(s);e.forEach(((e,t)=>{i.observe(e,{childList:0!==t,attributes:!0}),e instanceof Element&&r.observe(e)}));return{observer:i,resizeObserver:r,callback:s,cleanup:()=>{window.removeEventListener("resize",s),window.removeEventListener("scroll",s),i.disconnect(),r.disconnect()}}},t=(e,t)=>{let s;return(...i)=>{clearTimeout(s),s=setTimeout((()=>{s=void 0,e(...i)}),t)}},s=e=>{const t=(e,s=0)=>{const i=e[s]?.parentNode;return i?(e.push(i),s++,t(e,s)):e};return t([e])},i=({computedStyle:e,node:t})=>{const{position:s}=e;t instanceof Document||("absolute"===s||"relative"===s||"fixed"===s)||(t.style.position="relative")};let r;class n{DS;PS;Settings;_observers;_node;_parentNodes;_computedStyle;_computedBorder;_rect;constructor({DS:e,PS:t}){this.DS=e,this.PS=t,this.Settings=this.DS.stores.SettingsStore.s,this._node=this.Settings.area,this.setArea(this.Settings.area),this.PS.subscribe("Settings:updated:area",(({settings:{area:e}})=>this.setArea(e))),this.PS.subscribe("Interaction:init",this.init),this.PS.subscribe("Interaction:end",this.reset)}setArea=e=>{this.reset(),this._node=e,i({computedStyle:this.computedStyle,node:this._node}),setTimeout((()=>{this.PS.publish("Area:modified:pre",{item:this.HTMLNode}),this.reset(),this.PS.publish("Area:modified",{item:this.HTMLNode})}))};init=()=>{this._observers=e(this.parentNodes,t((e=>{this.PS.publish("Area:modified:pre",{event:e,item:this.HTMLNode}),this.reset(),this.PS.publish("Area:modified",{event:e,item:this.HTMLNode})}),60))};reset=()=>{this._computedStyle=void 0,this._rect=void 0,this._computedBorder=void 0,this._parentNodes=void 0};stop=()=>{this._observers?.cleanup(),this.reset()};scroll=(e,t)=>{const s={scroll_directions:e,scroll_multiplier:t};this.PS.publish("Area:scroll:pre",s),((e,t,s=1)=>{if(!t?.length||!e)return;let i=e;if(e instanceof Document&&(r&&(i=r),Number.isFinite(document?.documentElement?.scrollTop))){const e=document.documentElement.scrollTop;document.documentElement.scrollTop+=1,document.documentElement.scrollTop===e?(i=document.body,r=document.body):(document.documentElement.scrollTop=e,i=document.documentElement,r=document.documentElement)}const n=t.includes("top")&&i.scrollTop>0,o=t.includes("bottom")&&i.scrollTop<i.scrollHeight,l=t.includes("left")&&i.scrollLeft>0,a=t.includes("right")&&i.scrollLeft<i.scrollWidth;n&&(i.scrollTop-=1*s),o&&(i.scrollTop+=1*s),l&&(i.scrollLeft-=1*s),a&&(i.scrollLeft+=1*s)})(this._node,e,t),this.PS.publish("Area:scroll",s)};get HTMLNode(){return this._node}get computedBorder(){return this._computedBorder?this._computedBorder:{top:parseInt(this.computedStyle.borderTopWidth),bottom:parseInt(this.computedStyle.borderBottomWidth),left:parseInt(this.computedStyle.borderLeftWidth),right:parseInt(this.computedStyle.borderRightWidth)}}get computedStyle(){return this._computedStyle?this._computedStyle:this.HTMLNode instanceof Document?this._computedStyle=window.getComputedStyle(this.HTMLNode.body||this.HTMLNode.documentElement):this._computedStyle=window.getComputedStyle(this.HTMLNode)}get rect(){return this._rect?this._rect:this._rect=((e,t)=>{if(e instanceof Document)return{top:0,left:0,bottom:0,right:0,width:window.innerWidth,height:window.innerHeight};const s=e.getBoundingClientRect();return{top:s.top,left:s.left,bottom:s.bottom,right:s.right,width:(e.clientWidth||s.width)*t,height:(e.clientHeight||s.height)*t}})(this.HTMLNode,this.DS.stores.SettingsStore.s.zoom)}get parentNodes(){return this._parentNodes?this._parentNodes:this._parentNodes=s(this.HTMLNode)}}const o=({x:e,y:t},s,{x:i,y:r})=>({"+":{x:e+i,y:t+r},"-":{x:e-i,y:t-r},"*":{x:e*i,y:t*r},"/":{x:e/i,y:t/r}}[s]),l=e=>({x:e.left,y:e.top}),a=(e,t=0)=>({left:e.x,top:e.y,right:e.x,bottom:e.y,width:t,height:t}),h=e=>({x:e,y:e}),c=e=>{const t={x:0,y:0},s=window.getComputedStyle(e);if(!s.transform||"none"===s.transform)return t;if(s.transform.indexOf("3d")>=0){const e=s.transform.trim().match(/matrix3d\((.*?)\)/);if(e&&e.length){const s=e[1]?.split(",");t.x=parseInt(s[12])||0,t.y=parseInt(s[13])||0}return t}const i=s.transform.trim().match(/matrix\((.*?)\)/);if(i&&i.length){const e=i[1]?.split(",");t.x=parseInt(e[4])||0,t.y=parseInt(e[5])||0}return t},d=(e,t)=>t?(e=>{const{transform:t}=e.style;if(!t||t.indexOf("translate")<0)return c(e);const s={x:0,y:0},i=t.trim().match(/translate[3dD]*?\(.*?\)/);if(i){const e=i[0]?.split("(");if(e){const t=e[1]?.split(",");s.x=parseInt(t[0])||0,s.y=parseInt(t[1])||0}}return s.x||s.x?s:c(e)})(e):(e=>{const{style:t}=e,s={x:parseInt(t.left)||0,y:parseInt(t.top)||0};if(!s.x&&!s.x){const t=window.getComputedStyle(e);return{x:parseInt(t.left)||0,y:parseInt(t.top)||0}}return s})(e),S=({containerRect:e,selectionRect:t,direction:s,scrollAmount:i})=>{const r={top:e.top-t.top+i.y,left:e.left-t.left+i.x,bottom:e.bottom-t.bottom+i.y,right:e.right-t.right+i.x};return 0===s.x&&0===s.y||(s.y<0&&(s.y=Math.max(s.y,r.top)),s.x<0&&(s.x=Math.max(s.x,r.left)),s.y>0&&(s.y=Math.min(s.y,r.bottom)),s.x>0&&(s.x=Math.min(s.x,r.right)),t.top+=s.y,t.bottom+=s.y,t.left+=s.x,t.right+=s.x),s};class u{_prevCursorPos;_prevScrollPos;_elements=[];_dragKeys;_dragKeysFlat=[];_selectionRect=a(h(0));DS;PS;Settings;constructor({DS:e,PS:t}){this.DS=e,this.PS=t,this.Settings=this.DS.stores.SettingsStore.s,this.PS.subscribe("Settings:updated:dragKeys",this.assignDragKeys),this.assignDragKeys(),this.PS.subscribe("Interaction:start",this.start),this.PS.subscribe("Interaction:end",this.stop),this.PS.subscribe("Interaction:update",this.update),this.PS.subscribe("KeyStore:down",this.keyboardDrag),this.PS.subscribe("KeyStore:up",this.keyboardEnd)}assignDragKeys=()=>{this._dragKeys={up:this.Settings.dragKeys.up.map((e=>e.toLowerCase())),down:this.Settings.dragKeys.down.map((e=>e.toLowerCase())),left:this.Settings.dragKeys.left.map((e=>e.toLowerCase())),right:this.Settings.dragKeys.right.map((e=>e.toLowerCase()))},this._dragKeysFlat=[...this._dragKeys.up,...this._dragKeys.down,...this._dragKeys.left,...this._dragKeys.right]};keyboardDrag=({event:e,key:t})=>{const s=t.toLowerCase();if(!this.Settings.keyboardDrag||!this._dragKeysFlat.includes(s)||!this.DS.SelectedSet.size||!this.Settings.draggability||this.DS.continue)return;const i={event:e,isDragging:!0,isDraggingKeyboard:!0,key:t};this.PS.publish(["Interaction:start:pre","Interaction:start"],i),this._elements=this.DS.getSelection(),this._selectionRect=this.DS.Selection.boundingRect,this.handleZIndex(!0);let r=(({shiftKey:e,keyboardDragSpeed:t,zoom:s,key:i,dragKeys:r,scrollDiff:n})=>{const o={x:0,y:0},l=e?4*t*s:t*s;return r?.left.includes(i)&&(o.x=n.x||-l),r?.right.includes(i)&&(o.x=n.x||l),r?.up.includes(i)&&(o.y=n.y||-l),r?.down.includes(i)&&(o.y=n.y||l),o})({shiftKey:this.DS.stores.KeyStore.currentValues.includes("shift"),keyboardDragSpeed:this.Settings.keyboardDragSpeed,zoom:this.Settings.zoom,key:s,scrollDiff:this._scrollDiff,dragKeys:this._dragKeys});r=S({direction:r,containerRect:this.DS.SelectorArea.rect,scrollAmount:this.DS.stores.ScrollStore.scrollAmount,selectionRect:this._selectionRect}),this.moveElements(r),this.PS.publish(["Interaction:update:pre","Interaction:update"],i)};keyboardEnd=({event:e,key:t})=>{const s=t.toLowerCase();if(!(this.Settings.keyboardDrag&&this._dragKeysFlat.includes(s)&&this.DS.SelectedSet.size&&this.Settings.draggability))return;const i={event:e,isDragging:this.Settings.draggability,isDraggingKeyboard:!0,key:t};this.PS.publish(["Interaction:end:pre","Interaction:end"],i)};start=({isDragging:e,isDraggingKeyboard:t})=>{e&&!t&&(this._prevCursorPos=void 0,this._prevScrollPos=void 0,this._elements=this.DS.getSelection(),this._selectionRect=this.DS.Selection.boundingRect,this.handleZIndex(!0))};stop=()=>{this._prevCursorPos=void 0,this._prevScrollPos=void 0,this.handleZIndex(!1),this._elements=[]};update=({isDragging:e,isDraggingKeyboard:t})=>{if(!e||!this._elements.length||t||this.DS.continue)return;let s=o(this._cursorDiff,"+",this._scrollDiff);s=S({direction:s,containerRect:this.DS.SelectorArea.rect,scrollAmount:this.DS.stores.ScrollStore.scrollAmount,selectionRect:this._selectionRect}),this.moveElements(s)};handleZIndex=e=>{this.Settings.useLayers&&this._elements.forEach((t=>t.style.zIndex=`${(parseInt(t.style.zIndex)||0)+(e?9999:-9998)}`))};moveElements=e=>{const{elements:t,direction:s}=this.filterDragElements({elements:this._elements,direction:e});t.forEach((e=>{(({element:e,posDirection:t,useTransform:s})=>{const i=d(e,s);((e,t,s)=>{if(s){const s=e.style.transform;e.style.transform=`translate3d(${t.x}px,${t.y}px,1px) ${s.replace(/translate.*?\)/g,"")}`}else e.style.left=`${t.x}px`,e.style.top=`${t.y}px`})(e,o(i,"+",t),s)})({element:e,posDirection:s,containerRect:this.DS.SelectorArea.rect,useTransform:this.Settings.useTransform})}))};get _cursorDiff(){const e=this.DS.stores.PointerStore.currentVal,t=this._prevCursorPos?o(e,"-",this._prevCursorPos):{x:0,y:0};return this._prevCursorPos=e,t}get _scrollDiff(){const e=this.DS.stores.ScrollStore.currentVal,t=this._prevScrollPos?o(e,"-",this._prevScrollPos):{x:0,y:0};return this._prevScrollPos=e,t}filterDragElements=({elements:e,direction:t})=>({elements:e,direction:t})}const p=(e,t,s=0)=>{if(!e||!t)return!1;let i=e;if(s>0){const t=(e.right-e.left)*s,r=(e.bottom-e.top)*s;i={left:e.left+t,right:e.right-t,top:e.top+r,bottom:e.bottom-r}}return i.left<t.right&&i.right>t.left&&i.top<t.bottom&&i.bottom>t.top},g=e=>e?Array.isArray(e)||"function"==typeof e[Symbol.iterator]?[...new Set([...e])]:[e]:[];class m{id;element;_droppables;_rect;_observers;_timeout;_itemsDropped=[];_itemsInside;DS;PS;Settings;isDestroyed=!1;_parentNodes;constructor({DS:s,PS:i,id:r,element:n,droppables:o}){this.DS=s,this.PS=i,this.Settings=this.DS.stores.SettingsStore.s,this.id=r,this.element=n,o&&(this.droppables=g(o)),this.element.classList.add(`${this.Settings.dropZoneClass}`),this.PS.subscribe("Settings:updated:dropZoneClass",(({settings:e})=>{this.element&&(this.element.classList.remove(e["dropZoneClass:pre"]),this.element.classList.add(e.dropZoneClass))})),this._observers=e(this.parentNodes,t((()=>this._rect=void 0),this.Settings.refreshMemoryRate)),this.PS.subscribe("Interaction:start",this.start),this.PS.subscribe("Interaction:end",this.stop)}setReadyClasses=e=>{if(this.isDestroyed)return;const t=this.droppables.filter((e=>this.DS.SelectedSet.has(e)));t.length&&(t.forEach((t=>{t.classList[e](`${this.Settings.droppableClass}`),t.classList[e](`${this.Settings.droppableClass}-${this.id}`)})),this.element.classList[e](`${this.Settings.dropZoneReadyClass}`))};handleNoDrop=()=>{this.isDestroyed||(this.DS.SelectedSet.forEach((e=>{e.classList.remove(this.Settings.droppedTargetClass),e.classList.remove(`${this.Settings.droppedTargetClass}-${this.id}`)})),this._itemsDropped=this._itemsDropped.filter((e=>!this.DS.SelectedSet.has(e))),this._itemsDropped?.length||this.element.classList.remove(`${this.Settings.dropZoneTargetClass}`))};handleDrop=()=>{this.isDestroyed||(this._itemsDropped=[...new Set([...this._itemsDropped,...this.droppables?.filter((e=>this.DS.SelectedSet.has(e)))])],this._itemsDropped?.forEach((e=>{e.classList.add(`${this.Settings.droppedTargetClass}`),e.classList.add(`${this.Settings.droppedTargetClass}-${this.id}`)})),this._itemsDropped?.length&&this.element.classList.add(`${this.Settings.dropZoneTargetClass}`))};handleItemsInsideClasses=()=>{let e=!1;this.droppables.forEach((t=>{this.itemsInside?.includes(t)?(t.classList.add(`${this.Settings.droppedInsideClass}`),t.classList.add(`${this.Settings.droppedInsideClass}-${this.id}`),e=!0):(t.classList.remove(`${this.Settings.droppedInsideClass}-${this.id}`),t.className.includes(`${this.Settings.droppedInsideClass}-`)||t.classList.remove(`${this.Settings.droppedInsideClass}`))})),e?this.element.classList.add(`${this.Settings.dropZoneInsideClass}`):this.element.classList.remove(`${this.Settings.dropZoneInsideClass}`)};start=({isDragging:e})=>{e&&!this.isDestroyed&&this.setReadyClasses("add")};stop=({isDragging:e})=>{e&&!this.isDestroyed&&(this.setReadyClasses("remove"),this.handleItemsInsideClasses())};destroy(){this._observers?.cleanup(),this.element.classList.remove(`${this.Settings.dropZoneClass}`),this.element.classList.remove(`${this.Settings.dropZoneTargetClass}`),this.element.classList.remove(`${this.Settings.dropZoneReadyClass}`),this.droppables.forEach((e=>{e.classList.remove(`${this.Settings.droppedTargetClass}`),e.classList.remove(`${this.Settings.droppedTargetClass}-${this.id}`),e.classList.remove(`${this.Settings.droppableClass}`),e.classList.remove(`${this.Settings.droppableClass}-${this.id}`)})),this.PS.unsubscribe("Interaction:start",this.start),this.PS.unsubscribe("Interaction:end",this.stop),this.isDestroyed=!0}toObject=()=>({id:this.id,element:this.element,droppables:this.droppables,itemsDropped:this.itemsDropped,itemsInside:this.itemsInside});get rect(){if(!this.isDestroyed)return this._rect?this._rect:this._rect=this.element.getBoundingClientRect()}get itemsDropped(){if(!this.isDestroyed)return this._itemsDropped}get itemsInside(){if(!this.isDestroyed)return this._itemsInside||(this._itemsInside=this.droppables.flatMap((e=>{const t=this.DS.SelectableSet.rects.get(e);return this.rect&&p(t,this.rect,this.Settings.dropInsideThreshold)?[e]:[]})),this._timeout&&clearTimeout(this._timeout),this._timeout=setTimeout((()=>this._itemsInside=void 0),this.Settings.refreshMemoryRate)),this._itemsInside}get parentNodes(){return this._parentNodes?this._parentNodes:this._parentNodes=s(this.element)}get droppables(){return this._droppables?this._droppables:this.DS.SelectableSet.elements}set droppables(e){this._droppables=e}}class b{_zoneByElement=new Map;_zoneById=new Map;_zonesByDroppable=new Map;_zones;DS;PS;Settings;constructor({DS:e,PS:t}){this.DS=e,this.PS=t,this.Settings=this.DS.stores.SettingsStore.s,this.PS.subscribe("Settings:updated:dropZones",(({settings:e})=>this.setDropZones(e))),this.setDropZones({dropZones:this.Settings.dropZones}),this.PS.subscribe("Interaction:end",this.stop)}setDropZones=({dropZones:e})=>{e&&(this._zones&&this._zones.forEach((e=>e.destroy())),this._zones=e.map((e=>new m({DS:this.DS,PS:this.PS,...e}))),this._zones.forEach((e=>{this._zoneByElement.set(e.element,e),this._zoneById.set(e.id,e),e.droppables.forEach((t=>{const s=this._zonesByDroppable.get(t);if(!s?.length)return this._zonesByDroppable.set(t,[e]);this._zonesByDroppable.set(t,[...new Set([...s,e])])}))})))};_handleDrops=e=>{this._zones?.forEach((t=>{t!==e&&t.handleNoDrop()})),e&&e.handleDrop()};_getZoneByElementsFromPoint=(e,{x:t,y:s})=>{for(let i=0,r=e.length;i<r;i++){const r=this._zoneByElement.get(e[i]);if(p(r?.rect,{left:t,right:t,top:s,bottom:s},Math.min(this.Settings.dropTargetThreshold,.5)))return r}};stop=({isDragging:e,isDraggingKeyboard:t,event:s})=>{if(!e)return;const i=this.getTarget({isDraggingKeyboard:t,event:s});this._handleDrops(i)};getItemsDroppedById=e=>{const t=this._zoneById.get(e);return t?t.itemsDropped:console.warn(`[DragSelect] No zone found (id: ${e})`)};getItemsInsideById=(e,t)=>{const s=this._zoneById.get(e);return s?(t&&s.handleItemsInsideClasses(),s.itemsInside):console.warn(`[DragSelect] No zone found (id: ${e})`)};getKeyboardItemCenter=(e,t)=>{if(!e||!t)return;const s=t.target?.getBoundingClientRect();return{x:s.left+s.width/2,y:s.top+s.height/2}};getTarget=({coordinates:e,isDraggingKeyboard:t,event:s})=>{if(!this._zones?.length)return;let i;!e&&t&&s&&(i=this.getKeyboardItemCenter(t,s));const r=e?.x||i?.x||this.DS.stores.PointerStore.currentVal.x,n=e?.y||i?.y||this.DS.stores.PointerStore.currentVal.y,o=document.elementsFromPoint(r,n);return this._getZoneByElementsFromPoint(o,{x:r,y:n})}}class y{isInteracting;isDragging=!1;DS;PS;Settings;constructor({DS:e,PS:t}){this.DS=e,this.PS=t,this.Settings=this.DS.stores.SettingsStore.s,this.PS.subscribe("Settings:updated:area",(({settings:e})=>{this.removeAreaEventListeners(e["area:pre"]),this.setAreaEventListeners(e.area)})),this.PS.subscribe("PointerStore:updated",(({event:e})=>this.update({event:e}))),this.PS.subscribe("Selectable:click",this.onClick),this.PS.subscribe("Selectable:pointer",(({event:e})=>this.start(e))),this.PS.subscribe("Interaction:start:pre",(({event:e})=>this._start(e))),this.PS.subscribe("Interaction:init:pre",this._init),this.PS.subscribe("Interaction:end:pre",(({event:e})=>this._reset(e))),this.PS.subscribe("Area:scroll",this.update)}init=()=>this.PS.publish("Interaction:init:pre",{init:!0});_init=()=>{this.stop(),this.setAreaEventListeners(),this.PS.publish("Interaction:init",{init:!0})};_canInteract(e){const t="clientX"in e&&0===e.clientX&&0===e.clientY&&0===e.detail&&e.target;return!("button"in e&&2===e.button||this.isInteracting||e.target&&!this.DS.SelectorArea.isInside(e.target)||!t&&!this.DS.SelectorArea.isClicked(e))}start=e=>this.PS.publish("Interaction:start:pre",{event:e,isDragging:this.isDragging});_start=e=>{"touchstart"===e.type&&e.preventDefault(),this._canInteract(e)&&(this.isInteracting=!0,this.isDragging=this.isDragEvent(e),this.PS.publish("Interaction:start",{event:e,isDragging:this.isDragging}),this.setDocEventListeners())};isDragEvent=e=>{let t=null;return e.target&&"closest"in e.target&&(t=e.target.closest(`.${this.Settings.selectableClass}`)),!(!this.Settings.draggability||this.DS.stores.KeyStore.isMultiSelectKeyPressed(e)||!t)&&(this.Settings.immediateDrag&&(this.DS.SelectedSet.size?this.DS.SelectedSet.has(t)||(this.DS.SelectedSet.clear(),this.DS.SelectedSet.add(t)):this.DS.SelectedSet.add(t)),!!this.DS.SelectedSet.has(t))};onClick=({event:e})=>{if(!this._canInteract(e))return;if(e.detail>0)return;const{stores:{PointerStore:t,KeyStore:s},SelectableSet:i,SelectedSet:r}=this.DS;t.start(e);const n=e.target;n&&!i.has(n)||(s.isMultiSelectKeyPressed(e)||r.clear(),n&&r.toggle(n),this.reset(e))};stop=(e=this.DS.Area.HTMLNode)=>{this.removeAreaEventListeners(e),this.removeDocEventListeners()};update=({event:e,scroll_directions:t,scroll_multiplier:s})=>{this.isInteracting&&this.PS.publish(["Interaction:update:pre","Interaction:update"],{event:e,scroll_directions:t,scroll_multiplier:s,isDragging:this.isDragging})};reset=e=>this.PS.publish("Interaction:end:pre",{event:e,isDragging:this.isDragging});_reset=e=>{const{isDragging:t}=this;this.isInteracting=!1,this.isDragging=!1,this.removeDocEventListeners(),this.PS.publish("Interaction:end",{event:e,isDragging:t})};setAreaEventListeners=(e=this.DS.Area.HTMLNode)=>{this.Settings.usePointerEvents?e.addEventListener("pointerdown",this.start,{passive:!1}):e.addEventListener("mousedown",this.start),e.addEventListener("touchstart",this.start,{passive:!1})};removeAreaEventListeners=(e=this.DS.Area.HTMLNode)=>{this.Settings.usePointerEvents?e.removeEventListener("pointerdown",this.start,{passive:!1}):e.removeEventListener("mousedown",this.start),e.removeEventListener("touchstart",this.start,{passive:!1})};setDocEventListeners=()=>{this.Settings.usePointerEvents?(document.addEventListener("pointerup",this.reset),document.addEventListener("pointercancel",this.reset)):document.addEventListener("mouseup",this.reset),document.addEventListener("touchend",this.reset)};removeDocEventListeners=()=>{this.Settings.usePointerEvents?(document.removeEventListener("pointerup",this.reset),document.removeEventListener("pointercancel",this.reset)):document.removeEventListener("mouseup",this.reset),document.removeEventListener("touchend",this.reset)}}class D{_currentValues=new Set;_keyMapping={control:"ctrlKey",shift:"shiftKey",meta:"metaKey"};DS;PS;settings;constructor({DS:e,PS:t}){this.DS=e,this.PS=t,this.settings=this.DS.stores.SettingsStore.s,this.PS.subscribe("Interaction:init",this.init)}init=()=>{document.addEventListener("keydown",this.keydown),document.addEventListener("keyup",this.keyup),window.addEventListener("blur",this.reset)};keydown=e=>{if(!e.key?.toLocaleLowerCase)return;const t=e.key.toLowerCase();this.PS.publish("KeyStore:down:pre",{event:e,key:t}),this._currentValues.add(t),this.PS.publish("KeyStore:down",{event:e,key:t})};keyup=e=>{if(!e.key?.toLocaleLowerCase)return;const t=e.key.toLowerCase();this.PS.publish("KeyStore:up:pre",{event:e,key:t}),this._currentValues.delete(t),this.PS.publish("KeyStore:up",{event:e,key:t})};stop=()=>{document.removeEventListener("keydown",this.keydown),document.removeEventListener("keyup",this.reset),window.removeEventListener("blur",this.reset),this.reset()};reset=()=>this._currentValues.clear();isMultiSelectKeyPressed(e){if(this.settings.multiSelectMode)return!0;const t=this.settings.multiSelectKeys?.map((e=>e.toLocaleLowerCase()))??[];return!!this.currentValues.some((e=>t.includes(e)))||!(!e||!t.some((t=>e[this._keyMapping[t]])))}get currentValues(){return Array.from(this._currentValues.values())}}class _{_isMouseInteraction=!1;_initialValArea={x:0,y:0};_currentValArea={x:0,y:0};_lastValArea={x:0,y:0};_initialVal={x:0,y:0};_currentVal={x:0,y:0};_lastVal={x:0,y:0};_lastTouch;DS;PS;settings;constructor({DS:e,PS:t}){this.DS=e,this.PS=t,this.settings=this.DS.stores.SettingsStore.s,this.PS.subscribe("Interaction:init",this.init),this.PS.subscribe("Interaction:start",(({event:e})=>this.start(e))),this.PS.subscribe("Interaction:end",(({event:e})=>this.reset(e)))}init=()=>{this.settings.usePointerEvents?document.addEventListener("pointermove",this.update,{passive:!1}):document.addEventListener("mousemove",this.update),document.addEventListener("touchmove",this.update,{passive:!1})};start(e){e&&(this._isMouseInteraction=!0,this.currentVal=this.initialVal=this.getPointerPosition(e))}getPointerPosition=e=>(({event:e})=>({x:e.clientX,y:e.clientY}))({event:this._normalizedEvent(e)});update=e=>{e&&(this.PS.publish("PointerStore:updated:pre",{event:e}),this.currentVal=this.getPointerPosition(e),this._isMouseInteraction&&this.PS.publish("PointerStore:updated",{event:e}))};stop=()=>{this.settings.usePointerEvents?document.removeEventListener("pointermove",this.update,{passive:!1}):document.removeEventListener("mousemove",this.update),document.removeEventListener("touchmove",this.update,{passive:!1}),this.reset()};reset=e=>{this.currentVal=this.lastVal=this.getPointerPosition(e),setTimeout((()=>this._isMouseInteraction=!1),100)};_normalizedEvent(e){return!e||e instanceof KeyboardEvent?{clientX:0,clientY:0}:"touches"in e?("touchend"!==e.type&&(this._lastTouch=e),this._lastTouch?.touches[0]||e.touches[0]):e}get initialValArea(){return this._initialValArea?this._initialValArea:{x:0,y:0}}get currentValArea(){return this._currentValArea?this._currentValArea:{x:0,y:0}}get lastValArea(){return this._lastValArea?this._lastValArea:{x:0,y:0}}get initialVal(){return this._initialVal?this._initialVal:{x:0,y:0}}get currentVal(){return this._currentVal?this._currentVal:{x:0,y:0}}get lastVal(){return this._lastVal?this._lastVal:{x:0,y:0}}set initialVal(e){this._initialVal=e,this._initialValArea=e&&o(e,"-",o(l(this.DS.Area.rect),"+",l(this.DS.Area.computedBorder)))}set currentVal(e){this._currentVal=e,this._currentValArea=e&&o(e,"-",o(l(this.DS.Area.rect),"+",l(this.DS.Area.computedBorder)))}set lastVal(e){this._lastVal=e,this._lastValArea=e&&o(e,"-",o(l(this.DS.Area.rect),"+",l(this.DS.Area.computedBorder)))}}class v{subscribers={};DS;constructor({DS:e}){this.DS=e}subscribe=(e,t)=>{Array.isArray(this.subscribers[e])||(this.subscribers[e]=[]);const s=this.subscribers[e];return s.push(t),s.length-1};unsubscribe=(e,t,s)=>{const i=s??this.subscribers[e]?.findIndex((e=>e===t));this.subscribers[e]?.splice(Number(i),1)};publish=(e,t)=>{Array.isArray(e)?e.forEach((e=>this._publish(e,t))):this._publish(e,t)};_publish=(e,t)=>{const s=this.subscribers[e]??[];e.includes(":pre")?this._handlePrePublish(s,t):this._handlePublish(s,t)};_handlePublish=(e,t)=>{for(let s=0,i=e.length;s<i;s++){if(this.DS.stopped)return;e[s]?.(t)}};_handlePrePublish=(e,t)=>{let s=e.length;for(;s--;){if(this.DS.stopped)return;e[s]?.(t)}}}const P=()=>({y:document.body?.scrollTop||document.documentElement?.scrollTop||0,x:document.body?.scrollLeft||document.documentElement?.scrollLeft||0}),f=e=>!e||e instanceof Document?P():{x:e.scrollLeft>=0?e.scrollLeft:P().x,y:e.scrollTop>=0?e.scrollTop:P().y},I=e=>{const t=e.scrollTop,s=Boolean(e.scrollTop=1);return e.scrollTop=t,s};class L{_initialVal={x:0,y:0};_currentVal={x:0,y:0};_canScroll;DS;PS;Settings;constructor({DS:e,PS:t}){this.DS=e,this.PS=t,this.Settings=this.DS.stores.SettingsStore.s,this.PS.subscribe("Area:modified",(()=>{this.stop(),this.init()})),this.PS.subscribe("Interaction:init",this.init),this.PS.subscribe("Interaction:start",(()=>this.start())),this.PS.subscribe("Interaction:end",(()=>this.reset()))}init=()=>this.addListeners();addListeners=()=>this.DS.Area.HTMLNode.addEventListener("scroll",this.update);removeListeners=()=>this.DS.Area.HTMLNode.removeEventListener("scroll",this.update);start=()=>{this._currentVal=this._initialVal=f(this.DS.Area.HTMLNode)};update=()=>this._currentVal=f(this.DS.Area.HTMLNode);stop=()=>{this.reset(),this.removeListeners()};reset=()=>{this._initialVal={x:0,y:0},this._canScroll=void 0};get canScroll(){return"boolean"==typeof this._canScroll?this._canScroll:this._canScroll=(e=>{const t=f(e);return!(!t.x&&!t.y)||(e instanceof Document?e.body?I(e.body):I(e.documentElement):I(e))})(this.DS.Area.HTMLNode)}get scrollAmount(){const e=o(this.currentVal,"-",this.initialVal),t=h(this.Settings.zoom),s=o(o(e,"*",t),"-",e);return{x:e.x+s.x,y:e.y+s.y}}get initialVal(){return this._initialVal?this._initialVal:{x:0,y:0}}get currentVal(){return this._currentVal||(this._currentVal=f(this.DS.Area.HTMLNode)),this._currentVal}}class T extends Set{_rects;_timeout;DS;PS;Settings;constructor({DS:e,PS:t}){super(),this.DS=e,this.PS=t,this.Settings=this.DS.stores.SettingsStore.s,this.PS.subscribe("Interaction:init",this.init),this.PS.subscribe("Settings:updated:selectables",(()=>{this.clear(),this.init()})),this.PS.subscribe("Settings:updated:selectableClass",(({settings:e})=>{this.forEach((t=>{t.classList.remove(e["selectableClass:pre"]),t.classList.add(e.selectableClass)}))}))}init=()=>g(this.Settings.selectables).forEach((e=>this.add(e)));add(e){if(!e||super.has(e))return this;const t={items:this.elements,item:e};return this.PS.publish("Selectable:added:pre",t),e.classList.add(this.Settings.selectableClass),e.addEventListener("click",this._onClick),this.Settings.usePointerEvents?e.addEventListener("pointerdown",this._onPointer,{passive:!1}):e.addEventListener("mousedown",this._onPointer),e.addEventListener("touchstart",this._onPointer,{passive:!1}),this.Settings.draggability&&!this.Settings.useTransform&&i({computedStyle:window.getComputedStyle(e),node:e}),this.PS.publish("Selectable:added",t),super.add(e)}delete(e){if(!e||!super.has(e))return!0;const t={items:this.elements,item:e};return this.PS.publish("Selectable:removed:pre",t),e.classList.remove(this.Settings.selectableClass),e.classList.remove(this.Settings.hoverClass),e.removeEventListener("click",this._onClick),this.Settings.usePointerEvents?e.removeEventListener("pointerdown",this._onPointer,{passive:!1}):e.removeEventListener("mousedown",this._onPointer),e.removeEventListener("touchstart",this._onPointer,{passive:!1}),this.PS.publish("Selectable:removed",t),super.delete(e)}clear=()=>this.forEach((e=>this.delete(e)));_onClick=e=>this.PS.publish(["Selectable:click:pre","Selectable:click"],{event:e});_onPointer=e=>this.PS.publish(["Selectable:pointer:pre","Selectable:pointer"],{event:e});addAll=e=>e.forEach((e=>this.add(e)));deleteAll=e=>e.forEach((e=>this.delete(e)));getElementRect=e=>this._rects?this._rects.get(e):e.getBoundingClientRect();get elements(){return Array.from(this.values())}get rects(){return this._rects||(this._rects=new Map,this.forEach((e=>this._rects?.set(e,e.getBoundingClientRect()))),this._timeout&&clearTimeout(this._timeout),this._timeout=setTimeout((()=>this._rects=void 0),this.Settings.refreshMemoryRate)),this._rects}}class E extends Set{_rects;_timeout;DS;PS;Settings;constructor({DS:e,PS:t}){super(),this.DS=e,this.PS=t,this.Settings=this.DS.stores.SettingsStore.s}add(e){if(!e||super.has(e))return this;const t={items:this.elements,item:e};return this.PS.publish("Selected:added:pre",t),super.add(e),e.classList.add(this.Settings.selectedClass),this.Settings.useLayers&&(e.style.zIndex=`${(parseInt(e.style.zIndex)||0)+1}`),this.PS.publish("Selected:added",t),this}delete(e){if(!e||!super.has(e))return!0;const t={items:this.elements,item:e};this.PS.publish("Selected:removed:pre",t);const s=super.delete(e);return e.classList.remove(this.Settings.selectedClass),this.Settings.useLayers&&(e.style.zIndex=""+((parseInt(e.style.zIndex)||0)-1)),this.PS.publish("Selected:removed",t),s}clear=()=>this.forEach((e=>this.delete(e)));toggle(e){return this.has(e)?this.delete(e):this.add(e),e}addAll=e=>e.forEach((e=>this.add(e)));deleteAll=e=>e.forEach((e=>this.delete(e)));get elements(){return Array.from(this.values())}get rects(){return this._rects||(this._rects=new Map,this.forEach((e=>this._rects?.set(e,e.getBoundingClientRect()))),this._timeout&&clearTimeout(this._timeout),this._timeout=setTimeout((()=>this._rects=void 0),this.Settings.refreshMemoryRate)),this._rects}}var C=(e,t)=>{t.left&&(e.style.left=`${t.left}px`),t.top&&(e.style.top=`${t.top}px`),t.width&&(e.style.width=`${t.width}px`),t.height&&(e.style.height=`${t.height}px`)};class x{_rect;DS;PS;Settings;HTMLNode;constructor({DS:e,PS:t}){this.DS=e,this.PS=t,this.Settings=this.DS.stores.SettingsStore.s,this.HTMLNode=this.Settings.selector,this.PS.subscribe("Settings:updated:selectorClass",(({settings:e})=>{this.HTMLNode.classList.remove(e["selectorClass:pre"]),this.HTMLNode.classList.add(e.selectorClass)})),this.PS.subscribe("Settings:updated:selector",this.attachSelector),this.PS.subscribe("Settings:updated:customStyles",this.attachSelector),this.attachSelector(),this.PS.subscribe("Interaction:start",this.start),this.PS.subscribe("Interaction:update",this.update),this.PS.subscribe("Interaction:end",this.stop)}attachSelector=()=>{this.HTMLNode&&this.DS.SelectorArea?.HTMLNode&&this.DS.SelectorArea.HTMLNode.removeChild(this.HTMLNode),this.HTMLNode=this.Settings.selector||(e=>{const t=document.createElement("div");return t.style.position="absolute",e||(t.style.background="rgba(0, 175, 255, 0.2)",t.style.border="1px solid rgba(0, 175, 255, 0.8)",t.style.display="none",t.style.pointerEvents="none"),t})(this.Settings.customStyles),this.HTMLNode.classList.add(this.Settings.selectorClass),this.HTMLNode&&this.DS.SelectorArea?.HTMLNode&&this.DS.SelectorArea.HTMLNode.appendChild(this.HTMLNode)};start=({isDragging:e})=>{if(e)return;const{stores:{PointerStore:t}}=this.DS,s=t.initialValArea;C(this.HTMLNode,a(s,1)),this.HTMLNode.style.display="block",this._rect=void 0};stop=()=>{this.HTMLNode.style.width="0",this.HTMLNode.style.height="0",this.HTMLNode.style.display="none"};update=({isDragging:e})=>{if(e||this.DS.continue)return;const{stores:{ScrollStore:t,PointerStore:s}}=this.DS,i=(({scrollAmount:e,initialPointerPos:t,pointerPos:s})=>{const i={};return s.x>t.x-e.x?(i.left=t.x-e.x,i.width=s.x-t.x+e.x):(i.left=s.x,i.width=t.x-s.x-e.x),s.y>t.y-e.y?(i.top=t.y-e.y,i.height=s.y-t.y+e.y):(i.top=s.y,i.height=t.y-s.y-e.y),i})({scrollAmount:t.scrollAmount,initialPointerPos:s.initialValArea,pointerPos:s.currentValArea});C(this.HTMLNode,i),this._rect=void 0};get rect(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}class A{_prevSelectedSet=new Set;_boundingRect;_timeout;DS;PS;Settings;constructor({DS:e,PS:t}){this.DS=e,this.PS=t,this.Settings=this.DS.stores.SettingsStore.s,this.PS.subscribe("Interaction:start",this.start),this.PS.subscribe("Interaction:update",this.update)}_storePrevious(e){const{stores:{KeyStore:t},SelectedSet:s}=this.DS;t.isMultiSelectKeyPressed(e)?this._prevSelectedSet=new Set(s):this._prevSelectedSet=new Set}start=({event:e,isDragging:t})=>{t||(this._storePrevious(e),this._handleInsideSelection(!0,e))};update=({isDragging:e})=>{e||this.DS.continue||this._handleInsideSelection()};_handleInsideSelection=(e,t)=>{const{SelectableSet:s,SelectorArea:i,Selector:r}=this.DS,n=this.DS.stores.KeyStore.isMultiSelectKeyPressed(t)&&this.Settings.multiSelectToggling,o=this.Settings.selectionThreshold,l=s.rects,a=r.rect,h=new Map,c=new Map;for(const[e,t]of l)i.isInside(e,t)&&(p(t,a,o)?h.set(e,t):c.set(e,t));if(this.DS.continue)return;const{select:d,unselect:S}=this.filterSelected({select:h,unselect:c,selectorRect:a});d.forEach(((t,s)=>(({element:e,force:t,multiSelectionToggle:s,SelectedSet:i,hoverClassName:r})=>{e.classList.contains(r)&&!t||(i.has(e)?s&&i.delete(e):i.add(e),e.classList.add(r))})({element:s,force:e,multiSelectionToggle:n,SelectedSet:this.DS.SelectedSet,hoverClassName:this.Settings.hoverClass}))),S.forEach(((t,s)=>(({element:e,force:t,SelectedSet:s,PrevSelectedSet:i,hoverClassName:r})=>{if(!e.classList.contains(r)&&!t)return;const n=s.has(e),o=i.has(e);n&&!o?s.delete(e):!n&&o&&s.add(e),e.classList.remove(r)})({element:s,force:e,SelectedSet:this.DS.SelectedSet,hoverClassName:this.Settings.hoverClass,PrevSelectedSet:this._prevSelectedSet})))};get boundingRect(){return this._boundingRect||(this._boundingRect=(e=>{const t={top:Number.POSITIVE_INFINITY,left:Number.POSITIVE_INFINITY,bottom:Number.NEGATIVE_INFINITY,right:Number.NEGATIVE_INFINITY,width:Number.NEGATIVE_INFINITY,height:Number.NEGATIVE_INFINITY};return e.rects.forEach((e=>{t.top=Math.min(t.top,e.top||t.top),t.left=Math.min(t.left,e.left||t.left),t.bottom=Math.max(t.bottom,e.bottom||t.bottom),t.right=Math.max(t.right,e.right||t.right)})),t.height=t.bottom-t.top,t.width=t.right-t.left,t})(this.DS.SelectedSet),this._timeout&&clearTimeout(this._timeout),this._timeout=setTimeout((()=>this._boundingRect=void 0),this.Settings.refreshMemoryRate)),this._boundingRect}filterSelected=({select:e,unselect:t,selectorRect:s})=>({select:e,unselect:t})}class w{_scrollInterval;_rect;currentEdges=[];DS;PS;Settings;HTMLNode;constructor({DS:e,PS:t}){this.DS=e,this.PS=t,this.Settings=this.DS.stores.SettingsStore.s,this.HTMLNode=(()=>{const e=document.createElement("div");return e.style.position="fixed",e.style.overflow="hidden",e.style.pointerEvents="none",e.style.zIndex="999999999999999999",e})(),this.PS.subscribe("Settings:updated:selectorAreaClass",(({settings:e})=>{this.HTMLNode.classList.remove(e["selectorAreaClass:pre"]),this.HTMLNode.classList.add(e.selectorAreaClass)})),this.HTMLNode.classList.add(this.Settings.selectorAreaClass),this.PS.subscribe("Area:modified",this.updatePos),this.PS.subscribe("Area:modified",this.updatePos),this.PS.subscribe("Interaction:init",this.init),this.PS.subscribe("Interaction:start",(({isDraggingKeyboard:e})=>this.startAutoScroll({isDraggingKeyboard:e}))),this.PS.subscribe("Interaction:end",(()=>{this.updatePos(),this.stopAutoScroll()}))}init=()=>{this.applyElements("append"),this.updatePos()};applyElements=e=>{const t=document.body?"body":"documentElement",s=`${e}Child`;this.HTMLNode[s](this.DS.Selector.HTMLNode),document[t][s](this.HTMLNode)};updatePos=()=>{this._rect=void 0;const e=this.DS.Area.rect,t=this.DS.Area.computedBorder,{style:s}=this.HTMLNode,i=`${e.top+t.top}px`,r=`${e.left+t.left}px`,n=`${e.width}px`,o=`${e.height}px`;s.top!==i&&(s.top=i),s.left!==r&&(s.left=r),s.width!==n&&(s.width=n),s.height!==o&&(s.height=o)};stop=e=>{this.stopAutoScroll(),e&&this.applyElements("remove")};startAutoScroll=({isDraggingKeyboard:e})=>{e||(this.currentEdges=[],this._scrollInterval=setInterval((()=>this.handleAutoScroll()),16))};handleAutoScroll=()=>{if(this.DS.continue)return;const{stores:{PointerStore:e},Area:t}=this.DS;this.currentEdges=(({elementRect:e,containerRect:t,tolerance:s={x:0,y:0}})=>{const i=[];return e.top-s.y<t.top&&i.push("top"),e.left-s.x<t.left&&i.push("left"),e.bottom+s.y>t.bottom&&i.push("bottom"),e.right+s.y>t.right&&i.push("right"),i})({elementRect:a(e.currentVal),containerRect:this.rect,tolerance:this.Settings.overflowTolerance}),this.currentEdges.length&&t.scroll(this.currentEdges,this.Settings.autoScrollSpeed)};stopAutoScroll=()=>{this.currentEdges=[],clearInterval(this._scrollInterval)};isInside=(e,t)=>!(!this.DS.Area.HTMLNode.contains(e)||!this.DS.stores.ScrollStore.canScroll)||p(this.rect,t||e.getBoundingClientRect());isClicked(e){const{stores:{PointerStore:t}}=this.DS,s=e?t.getPointerPosition(e):t.initialVal;return p({left:s.x,top:s.y,right:s.x,bottom:s.y},this.rect)}get rect(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}const N=(e,t)=>console.warn(`[DragSelect] TypeIssue: setting "${e}" is not of type "${t}".`),M=(e,t,s,i)=>{if(void 0===t)return s?{[e]:i}:{};if(null===t)return{[e]:null};let r=!0,n=!1;const o="string"==typeof i;o&&(r="string"==typeof t||t instanceof String),o&&!r&&(n=!0,N(e,"string"));const l=!Number.isNaN(i)&&"number"==typeof i;l&&(r=!Number.isNaN(t)&&"number"==typeof t),l&&!r&&(n=!0,N(e,"number"));const a="[object Object]"===Object.prototype.toString.call(i);a&&(r="[object Object]"===Object.prototype.toString.call(t)),a&&!r&&(n=!0,N(e,"object"));const h="boolean"==typeof i;h&&(r="boolean"==typeof t),h&&!r&&(n=!0,N(e,"boolean"));const c=Array.isArray(i);c&&(r=Array.isArray(t)),c&&!r&&(n=!0,N(e,"array"));const d=n||s;return"dragKeys"===e&&r?{[e]:Object.assign(i,t)}:"dragKeys"!==e||r?("dropZones"===e&&r&&Array.isArray(t)&&new Set(t.map((e=>e.id))).size!==t.length&&console.warn('[DragSelect] UniqueConstraintsIssue: setting "dropZones" contains duplicate ids.'),r?{[e]:t}:d?{[e]:i}:{}):d?{[e]:i}:{}};class V{_settings={};s={};PS;constructor({PS:e,settings:t}){this.PS=e,this.update({settings:t,init:!0})}update=({settings:e,init:t})=>{this.PS.publish("Settings:updated:pre",{settings:this._settings,"settings:init":Boolean(t),"settings:new":e}),this._update({settings:e,init:t})};_update=({settings:e={},init:t=!1})=>{const s=((e,t)=>({...M("area",e.area,t,document),...M("selectables",e.selectables,t,null),...M("autoScrollSpeed",e.autoScrollSpeed,t,5),...M("overflowTolerance",e.overflowTolerance,t,{x:25,y:25}),...M("zoom",e.zoom,t,1),...M("customStyles",e.customStyles,t,!1),...M("multiSelectMode",e.multiSelectMode,t,!1),...M("multiSelectToggling",e.multiSelectToggling,t,!0),...M("multiSelectKeys",e.multiSelectKeys,t,["Control","Shift","Meta"]),...M("selector",e.selector,t,null),...M("selectionThreshold",e.selectionThreshold,t,0),...M("draggability",e.draggability,t,!0),...M("immediateDrag",e.immediateDrag,t,!0),...M("keyboardDrag",e.keyboardDrag,t,!0),...M("dragKeys",e.dragKeys,t,{up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]}),...M("keyboardDragSpeed",e.keyboardDragSpeed,t,10),...M("useTransform",e.useTransform,t,!0),...M("refreshMemoryRate",e.refreshMemoryRate,t,80),...M("dropZones",e.dropZones,t,[]),...M("dropInsideThreshold",e.dropInsideThreshold,t,1),...M("dropTargetThreshold",e.dropTargetThreshold,t,0),...M("usePointerEvents",e.usePointerEvents,t,!1),...M("hoverClass",e.hoverClass,t,"ds-hover"),...M("selectableClass",e.selectableClass,t,"ds-selectable"),...M("selectedClass",e.selectedClass,t,"ds-selected"),...M("selectorClass",e.selectorClass,t,"ds-selector"),...M("selectorAreaClass",e.selectorAreaClass,t,"ds-selector-area"),...M("droppedTargetClass",e.droppedTargetClass,t,"ds-dropped-target"),...M("droppedInsideClass",e.droppedInsideClass,t,"ds-dropped-inside"),...M("droppableClass",e.droppableClass,t,"ds-droppable"),...M("dropZoneClass",e.dropZoneClass,t,"ds-dropzone"),...M("dropZoneReadyClass",e.dropZoneReadyClass,t,"ds-dropzone-ready"),...M("dropZoneTargetClass",e.dropZoneTargetClass,t,"ds-dropzone-target"),...M("dropZoneInsideClass",e.dropZoneInsideClass,t,"ds-dropzone-inside"),...M("useLayers",e.useLayers,t,!0)}))(e,t);for(const[i,r]of Object.entries(s))((s,i)=>{s in this._settings||Object.defineProperty(this.s,s,{get:()=>this._settings[s],set:e=>this.update({settings:{[s]:e}})}),this._settings[`${s}:pre`]=this._settings[s],this._settings[s]=i;const r={settings:this._settings,"settings:init":t,"settings:new":e};this.PS.publish("Settings:updated",r),this.PS.publish(`Settings:updated:${s}`,r)})(i,r)}}const K={elementselect:"DS:select",elementunselect:"DS:unselect",autoscroll:"DS:scroll",dragstart:"DS:start",dragmove:"DS:update",callback:"DS:end",preelementselect:"DS:select:pre",preelementunselect:"DS:unselect:pre",preautoscroll:"DS:scroll:pre",predragstart:"DS:start:pre",predragmove:"DS:update:pre",precallback:"DS:end:pre"},k=(e,t)=>{const s=t.DropZones.getTarget(e);return{...e,...s?{dropTarget:s.toObject()}:{}}},H=({sub_name:e,DS:t,PS:s,sub_pubs:i})=>{s.subscribe(e,(e=>i.forEach((s=>$({sub_pub:s,data:e,DS:t})))))},$=({sub_pub:e,data:t,DS:s})=>{const i=e.condition?e.condition(t,s):t;if(i){const r=e.extraData&&e.extraData(t,s)||{};s.publish(e.name,{items:s.SelectedSet.elements,isDragging:s.Interaction.isDragging,...i,...r})}};class R{continue=!1;PubSub;stores;Area;Selector;SelectorArea;SelectableSet;SelectedSet;Selection;Drag;DropZones;Interaction;stopped;constructor(e){this.stopped=!1,this.PubSub=new v({DS:this}),this.stores={},this.stores.SettingsStore=new V({settings:e,PS:this.PubSub}),this.stores.PointerStore=new _({DS:this,PS:this.PubSub}),this.stores.ScrollStore=new L({DS:this,PS:this.PubSub}),this.stores.KeyStore=new D({DS:this,PS:this.PubSub}),this.Area=new n({DS:this,PS:this.PubSub}),this.Selector=new x({DS:this,PS:this.PubSub}),this.SelectorArea=new w({DS:this,PS:this.PubSub}),this.SelectableSet=new T({DS:this,PS:this.PubSub}),this.SelectedSet=new E({DS:this,PS:this.PubSub}),this.Selection=new A({DS:this,PS:this.PubSub}),this.Drag=new u({DS:this,PS:this.PubSub}),this.DropZones=new b({DS:this,PS:this.PubSub}),this.Interaction=new y({DS:this,PS:this.PubSub}),(({PS:e,DS:t})=>{const s={"Selected:added":[{name:"preelementselect"},{name:"elementselect"},{name:"DS:select:pre"},{name:"DS:select"}],"Selected:removed":[{name:"preelementunselect"},{name:"elementunselect"},{name:"DS:unselect:pre"},{name:"DS:unselect"}],"Selectable:added":[{name:"DS:added:pre"},{name:"DS:added"}],"Selectable:removed":[{name:"DS:removed:pre"},{name:"DS:removed"}],"Area:scroll":[{name:"preautoscroll"},{name:"autoscroll"},{name:"DS:scroll:pre"},{name:"DS:scroll"}],"Interaction:start":[{name:"predragstart"},{name:"dragstart"},{name:"DS:start:pre"},{name:"DS:start"}],"Interaction:update":[{name:"predragmove",condition:e=>e.event?e:null},{name:"dragmove",condition:e=>e.event?e:null},{name:"DS:update:pre",condition:e=>e.event?e:null},{name:"DS:update",condition:e=>e.event?e:null}],"Interaction:end":[{name:"precallback",extraData:(e,t)=>k(e,t)},{name:"callback",extraData:(e,t)=>k(e,t)},{name:"DS:end:pre",extraData:(e,t)=>k(e,t)},{name:"DS:end",extraData:(e,t)=>k(e,t)}]};for(const[i,r]of Object.entries(s))H({sub_name:i,sub_pubs:r,DS:t,PS:e})})({DS:this,PS:this.PubSub}),this.PubSub.subscribe("Interaction:end",(()=>this.continue=!1)),this.PubSub.subscribe("DS:end",(({items:e})=>this.continue=!1)),this.start()}static isCollision;subscribe=(e,t)=>{K[e]&&console.warn(`[DragSelect]: The event name "${e}" is deprecated and was/will be removed in a future version. Please use the new event name "${K[e]}" instead.`),this.PubSub.subscribe(e,t)};unsubscribe=(e,t,s)=>this.PubSub.unsubscribe(e,t,s);publish=(e,t)=>this.PubSub.publish(e,t);start=()=>{this.stopped=!1,this.Interaction.init()};stop(e=!0,t=!0,s=!1){s&&this.publish("DS:end",{items:this.SelectedSet.elements,isDragging:this.Interaction.isDragging}),this.Interaction.stop(),this.Area.stop(),this.Drag.stop(),this.Selector.stop(),this.SelectorArea.stop(e),this.stores.KeyStore.stop(),this.stores.PointerStore.stop(),this.stores.ScrollStore.stop(),e&&this.SelectableSet.clear(),t&&this.SelectedSet.clear(),this.stopped=!0}break=()=>this.continue=!0;setSettings=e=>this.stores.SettingsStore.update({settings:e});getSelection=()=>this.SelectedSet.elements;addSelection(e,t=!1,s=!1){const i=g(e);return this.SelectedSet.addAll(i),s||this.addSelectables(e,!1,!1),t&&this.PubSub.publish("DS:end",{items:this.SelectedSet.elements,isDragging:this.Interaction.isDragging}),this.getSelection()}removeSelection(e,t=!1,s=!1){const i=g(e);return this.SelectedSet.deleteAll(i),s&&this.removeSelectables(e,!1,!1),t&&this.PubSub.publish("DS:end",{items:this.SelectedSet.elements,isDragging:this.Interaction.isDragging}),this.getSelection()}toggleSelection(e,t=!1,s=!1){return g(e).forEach((i=>this.SelectedSet.has(i)?this.removeSelection(e,t,s):this.addSelection(e,t,s))),t&&this.PubSub.publish("DS:end",{items:this.SelectedSet.elements,isDragging:this.Interaction.isDragging}),this.getSelection()}setSelection(e,t=!1,s=!1){return this.clearSelection(),this.addSelection(e,t,s),this.getSelection()}clearSelection(e=!1){return this.SelectedSet.clear(),e&&this.PubSub.publish("DS:end",{items:this.SelectedSet.elements,isDragging:this.Interaction.isDragging}),this.getSelection()}addSelectables(e,t,s){const i=g(e);return this.SelectableSet.addAll(i),t&&this.SelectedSet.addAll(i),s&&this.PubSub.publish("DS:end",{items:this.SelectedSet.elements,isDragging:this.Interaction.isDragging}),i}getSelectables=()=>this.SelectableSet.elements;removeSelectables(e,t,s){const i=g(e);return this.SelectableSet.deleteAll(i),t&&this.removeSelection(e),s&&this.PubSub.publish("DS:end",{items:this.SelectedSet.elements,isDragging:this.Interaction.isDragging}),i}getInitialCursorPosition=()=>this.stores.PointerStore.initialVal;getCurrentCursorPosition=()=>this.stores.PointerStore.currentVal;getPreviousCursorPosition=()=>this.stores.PointerStore.lastVal;getInitialCursorPositionArea=()=>this.stores.PointerStore.initialValArea;getCurrentCursorPositionArea=()=>this.stores.PointerStore.currentValArea;getPreviousCursorPositionArea=()=>this.stores.PointerStore.lastValArea;isMultiSelect=e=>this.stores.KeyStore.isMultiSelectKeyPressed(e);isDragging=()=>this.Interaction.isDragging;getZoneByCoordinates=e=>this.DropZones.getTarget({coordinates:e})?.toObject();getItemsDroppedByZoneId=e=>this.DropZones.getItemsDroppedById(e);getItemsInsideByZoneId=(e,t)=>this.DropZones.getItemsInsideById(e,t)}return R.isCollision=p,R}));
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";const e=(e,t)=>{const s=t;window.addEventListener("resize",s),window.addEventListener("scroll",s);const i=new MutationObserver(s),r=new ResizeObserver(s);e.forEach(((e,t)=>{i.observe(e,{childList:0!==t,attributes:!0}),e instanceof Element&&r.observe(e)}));return{observer:i,resizeObserver:r,callback:s,cleanup:()=>{window.removeEventListener("resize",s),window.removeEventListener("scroll",s),i.disconnect(),r.disconnect()}}},t=(e,t)=>{let s;return(...i)=>{clearTimeout(s),s=setTimeout((()=>{s=void 0,e(...i)}),t)}},s=e=>{const t=(e,s=0)=>{const i=e[s]?.parentNode;return i?(e.push(i),s++,t(e,s)):e};return t([e])},i=({computedStyle:e,node:t})=>{const{position:s}=e;t instanceof Document||("absolute"===s||"relative"===s||"fixed"===s)||(t.style.position="relative")};let r;class n{DS;PS;Settings;_observers;_node;_parentNodes;_computedStyle;_computedBorder;_rect;constructor({DS:e,PS:t}){this.DS=e,this.PS=t,this.Settings=this.DS.stores.SettingsStore.s,this._node=this.Settings.area,this.setArea(this.Settings.area),this.PS.subscribe("Settings:updated:area",(({settings:{area:e}})=>this.setArea(e))),this.PS.subscribe("Interaction:init",this.init),this.PS.subscribe("Interaction:end",this.reset)}setArea=e=>{this.reset(),this._node=e,i({computedStyle:this.computedStyle,node:this._node}),setTimeout((()=>{this.PS.publish("Area:modified:pre",{item:this.HTMLNode}),this.reset(),this.PS.publish("Area:modified",{item:this.HTMLNode})}))};init=()=>{this._observers=e(this.parentNodes,t((e=>{this.hasRelevantBeenModified()&&(this.PS.publish("Area:modified:pre",{event:e,item:this.HTMLNode}),this.reset(),this.PS.publish("Area:modified",{event:e,item:this.HTMLNode}))}),60))};hasRelevantBeenModified=()=>{const e=this.computedStyle,t=this.rect,s=this.computedBorder,i=this.parentNodes;return this.reset(),JSON.stringify(e)!==JSON.stringify(this.computedStyle)||(JSON.stringify(t)!==JSON.stringify(this.rect)||(JSON.stringify(s)!==JSON.stringify(this.computedBorder)||!(i.length===this.parentNodes.length||!i.some((e=>!this.parentNodes.includes(e))))))};reset=()=>{this._computedStyle=void 0,this._rect=void 0,this._computedBorder=void 0,this._parentNodes=void 0};stop=()=>{this._observers?.cleanup(),this.reset()};scroll=(e,t)=>{const s={scroll_directions:e,scroll_multiplier:t};this.PS.publish("Area:scroll:pre",s),((e,t,s=1)=>{if(!t?.length||!e)return;let i=e;if(e instanceof Document&&(r&&(i=r),Number.isFinite(document?.documentElement?.scrollTop))){const e=document.documentElement.scrollTop;document.documentElement.scrollTop+=1,document.documentElement.scrollTop===e?(i=document.body,r=document.body):(document.documentElement.scrollTop=e,i=document.documentElement,r=document.documentElement)}const n=t.includes("top")&&i.scrollTop>0,o=t.includes("bottom")&&i.scrollTop<i.scrollHeight,l=t.includes("left")&&i.scrollLeft>0,a=t.includes("right")&&i.scrollLeft<i.scrollWidth;n&&(i.scrollTop-=1*s),o&&(i.scrollTop+=1*s),l&&(i.scrollLeft-=1*s),a&&(i.scrollLeft+=1*s)})(this._node,e,t),this.PS.publish("Area:scroll",s)};get HTMLNode(){return this._node}get computedBorder(){return this._computedBorder?this._computedBorder:{top:parseInt(this.computedStyle.borderTopWidth),bottom:parseInt(this.computedStyle.borderBottomWidth),left:parseInt(this.computedStyle.borderLeftWidth),right:parseInt(this.computedStyle.borderRightWidth)}}get computedStyle(){if(this._computedStyle)return this._computedStyle;let e;return e=this.HTMLNode instanceof Document?window.getComputedStyle(this.HTMLNode.body||this.HTMLNode.documentElement):window.getComputedStyle(this.HTMLNode),this._computedStyle={borderTopWidth:e.borderTopWidth,borderBottomWidth:e.borderBottomWidth,borderLeftWidth:e.borderLeftWidth,borderRightWidth:e.borderRightWidth,position:e.position}}get rect(){return this._rect?this._rect:this._rect=((e,t)=>{if(e instanceof Document)return{top:0,left:0,bottom:0,right:0,width:window.innerWidth,height:window.innerHeight};const s=e.getBoundingClientRect();return{top:s.top,left:s.left,bottom:s.bottom,right:s.right,width:(e.clientWidth||s.width)*t,height:(e.clientHeight||s.height)*t}})(this.HTMLNode,this.DS.stores.SettingsStore.s.zoom)}get parentNodes(){return this._parentNodes?this._parentNodes:this._parentNodes=s(this.HTMLNode)}}const o=({x:e,y:t},s,{x:i,y:r})=>({"+":{x:e+i,y:t+r},"-":{x:e-i,y:t-r},"*":{x:e*i,y:t*r},"/":{x:e/i,y:t/r}}[s]),l=e=>({x:e.left,y:e.top}),a=(e,t=0)=>({left:e.x,top:e.y,right:e.x,bottom:e.y,width:t,height:t}),h=e=>({x:e,y:e}),c=e=>{const t={x:0,y:0},s=window.getComputedStyle(e);if(!s.transform||"none"===s.transform)return t;if(s.transform.indexOf("3d")>=0){const e=s.transform.trim().match(/matrix3d\((.*?)\)/);if(e&&e.length){const s=e[1]?.split(",");t.x=parseInt(s[12])||0,t.y=parseInt(s[13])||0}return t}const i=s.transform.trim().match(/matrix\((.*?)\)/);if(i&&i.length){const e=i[1]?.split(",");t.x=parseInt(e[4])||0,t.y=parseInt(e[5])||0}return t},d=(e,t)=>t?(e=>{const{transform:t}=e.style;if(!t||t.indexOf("translate")<0)return c(e);const s={x:0,y:0},i=t.trim().match(/translate[3dD]*?\(.*?\)/);if(i){const e=i[0]?.split("(");if(e){const t=e[1]?.split(",");s.x=parseInt(t[0])||0,s.y=parseInt(t[1])||0}}return s.x||s.x?s:c(e)})(e):(e=>{const{style:t}=e,s={x:parseInt(t.left)||0,y:parseInt(t.top)||0};if(!s.x&&!s.x){const t=window.getComputedStyle(e);return{x:parseInt(t.left)||0,y:parseInt(t.top)||0}}return s})(e),S=({containerRect:e,selectionRect:t,direction:s,scrollAmount:i})=>{const r={top:e.top-t.top+i.y,left:e.left-t.left+i.x,bottom:e.bottom-t.bottom+i.y,right:e.right-t.right+i.x};return 0===s.x&&0===s.y||(s.y<0&&(s.y=Math.max(s.y,r.top)),s.x<0&&(s.x=Math.max(s.x,r.left)),s.y>0&&(s.y=Math.min(s.y,r.bottom)),s.x>0&&(s.x=Math.min(s.x,r.right)),t.top+=s.y,t.bottom+=s.y,t.left+=s.x,t.right+=s.x),s};class u{_prevCursorPos;_prevScrollPos;_elements=[];_dragKeys;_dragKeysFlat=[];_selectionRect=a(h(0));DS;PS;Settings;constructor({DS:e,PS:t}){this.DS=e,this.PS=t,this.Settings=this.DS.stores.SettingsStore.s,this.PS.subscribe("Settings:updated:dragKeys",this.assignDragKeys),this.assignDragKeys(),this.PS.subscribe("Interaction:start",this.start),this.PS.subscribe("Interaction:end",this.stop),this.PS.subscribe("Interaction:update",this.update),this.PS.subscribe("KeyStore:down",this.keyboardDrag),this.PS.subscribe("KeyStore:up",this.keyboardEnd)}assignDragKeys=()=>{this._dragKeys={up:this.Settings.dragKeys.up.map((e=>e.toLowerCase())),down:this.Settings.dragKeys.down.map((e=>e.toLowerCase())),left:this.Settings.dragKeys.left.map((e=>e.toLowerCase())),right:this.Settings.dragKeys.right.map((e=>e.toLowerCase()))},this._dragKeysFlat=[...this._dragKeys.up,...this._dragKeys.down,...this._dragKeys.left,...this._dragKeys.right]};keyboardDrag=({event:e,key:t})=>{const s=t.toLowerCase();if(!this.Settings.keyboardDrag||!this._dragKeysFlat.includes(s)||!this.DS.SelectedSet.size||!this.Settings.draggability||this.DS.continue)return;const i={event:e,isDragging:!0,isDraggingKeyboard:!0,key:t};this.PS.publish(["Interaction:start:pre","Interaction:start"],i),this._elements=this.DS.getSelection(),this._selectionRect=this.DS.Selection.boundingRect,this.handleZIndex(!0);let r=(({shiftKey:e,keyboardDragSpeed:t,zoom:s,key:i,dragKeys:r,scrollDiff:n})=>{const o={x:0,y:0},l=e?4*t*s:t*s;return r?.left.includes(i)&&(o.x=n.x||-l),r?.right.includes(i)&&(o.x=n.x||l),r?.up.includes(i)&&(o.y=n.y||-l),r?.down.includes(i)&&(o.y=n.y||l),o})({shiftKey:this.DS.stores.KeyStore.currentValues.includes("shift"),keyboardDragSpeed:this.Settings.keyboardDragSpeed,zoom:this.Settings.zoom,key:s,scrollDiff:this._scrollDiff,dragKeys:this._dragKeys});r=S({direction:r,containerRect:this.DS.SelectorArea.rect,scrollAmount:this.DS.stores.ScrollStore.scrollAmount,selectionRect:this._selectionRect}),this.moveElements(r),this.PS.publish(["Interaction:update:pre","Interaction:update"],i)};keyboardEnd=({event:e,key:t})=>{const s=t.toLowerCase();if(!(this.Settings.keyboardDrag&&this._dragKeysFlat.includes(s)&&this.DS.SelectedSet.size&&this.Settings.draggability))return;const i={event:e,isDragging:this.Settings.draggability,isDraggingKeyboard:!0,key:t};this.PS.publish(["Interaction:end:pre","Interaction:end"],i)};start=({isDragging:e,isDraggingKeyboard:t})=>{e&&!t&&(this._prevCursorPos=void 0,this._prevScrollPos=void 0,this._elements=this.DS.getSelection(),this._selectionRect=this.DS.Selection.boundingRect,this.handleZIndex(!0))};stop=()=>{this._prevCursorPos=void 0,this._prevScrollPos=void 0,this.handleZIndex(!1),this._elements=[]};update=({isDragging:e,isDraggingKeyboard:t})=>{if(!e||!this._elements.length||t||this.DS.continue)return;let s=o(this._cursorDiff,"+",this._scrollDiff);s=S({direction:s,containerRect:this.DS.SelectorArea.rect,scrollAmount:this.DS.stores.ScrollStore.scrollAmount,selectionRect:this._selectionRect}),this.moveElements(s)};handleZIndex=e=>{this.Settings.useLayers&&this._elements.forEach((t=>t.style.zIndex=`${(parseInt(t.style.zIndex)||0)+(e?9999:-9998)}`))};moveElements=e=>{const{elements:t,direction:s}=this.filterDragElements({elements:this._elements,direction:e});t.forEach((e=>{(({element:e,posDirection:t,useTransform:s})=>{const i=d(e,s);((e,t,s)=>{if(s){const s=e.style.transform;e.style.transform=`translate3d(${t.x}px,${t.y}px,1px) ${s.replace(/translate.*?\)/g,"")}`}else e.style.left=`${t.x}px`,e.style.top=`${t.y}px`})(e,o(i,"+",t),s)})({element:e,posDirection:s,containerRect:this.DS.SelectorArea.rect,useTransform:this.Settings.useTransform})}))};get _cursorDiff(){const e=this.DS.stores.PointerStore.currentVal,t=this._prevCursorPos?o(e,"-",this._prevCursorPos):{x:0,y:0};return this._prevCursorPos=e,t}get _scrollDiff(){const e=this.DS.stores.ScrollStore.currentVal,t=this._prevScrollPos?o(e,"-",this._prevScrollPos):{x:0,y:0};return this._prevScrollPos=e,t}filterDragElements=({elements:e,direction:t})=>({elements:e,direction:t})}const p=(e,t,s=0)=>{if(!e||!t)return!1;let i=e;if(s>0){const t=(e.right-e.left)*s,r=(e.bottom-e.top)*s;i={left:e.left+t,right:e.right-t,top:e.top+r,bottom:e.bottom-r}}return i.left<t.right&&i.right>t.left&&i.top<t.bottom&&i.bottom>t.top},g=e=>e?Array.isArray(e)||"function"==typeof e[Symbol.iterator]?[...new Set([...e])]:[e]:[];class m{id;element;_droppables;_rect;_observers;_timeout;_itemsDropped=[];_itemsInside;DS;PS;Settings;isDestroyed=!1;_parentNodes;constructor({DS:s,PS:i,id:r,element:n,droppables:o}){this.DS=s,this.PS=i,this.Settings=this.DS.stores.SettingsStore.s,this.id=r,this.element=n,o&&(this.droppables=g(o)),this.element.classList.add(`${this.Settings.dropZoneClass}`),this.PS.subscribe("Settings:updated:dropZoneClass",(({settings:e})=>{this.element&&(this.element.classList.remove(e["dropZoneClass:pre"]),this.element.classList.add(e.dropZoneClass))})),this._observers=e(this.parentNodes,t((()=>this._rect=void 0),this.Settings.refreshMemoryRate)),this.PS.subscribe("Interaction:start",this.start),this.PS.subscribe("Interaction:end",this.stop)}setReadyClasses=e=>{if(this.isDestroyed)return;const t=this.droppables.filter((e=>this.DS.SelectedSet.has(e)));t.length&&(t.forEach((t=>{t.classList[e](`${this.Settings.droppableClass}`),t.classList[e](`${this.Settings.droppableClass}-${this.id}`)})),this.element.classList[e](`${this.Settings.dropZoneReadyClass}`))};handleNoDrop=()=>{this.isDestroyed||(this.DS.SelectedSet.forEach((e=>{e.classList.remove(this.Settings.droppedTargetClass),e.classList.remove(`${this.Settings.droppedTargetClass}-${this.id}`)})),this._itemsDropped=this._itemsDropped.filter((e=>!this.DS.SelectedSet.has(e))),this._itemsDropped?.length||this.element.classList.remove(`${this.Settings.dropZoneTargetClass}`))};handleDrop=()=>{this.isDestroyed||(this._itemsDropped=[...new Set([...this._itemsDropped,...this.droppables?.filter((e=>this.DS.SelectedSet.has(e)))])],this._itemsDropped?.forEach((e=>{e.classList.add(`${this.Settings.droppedTargetClass}`),e.classList.add(`${this.Settings.droppedTargetClass}-${this.id}`)})),this._itemsDropped?.length&&this.element.classList.add(`${this.Settings.dropZoneTargetClass}`))};handleItemsInsideClasses=()=>{let e=!1;this.droppables.forEach((t=>{this.itemsInside?.includes(t)?(t.classList.add(`${this.Settings.droppedInsideClass}`),t.classList.add(`${this.Settings.droppedInsideClass}-${this.id}`),e=!0):(t.classList.remove(`${this.Settings.droppedInsideClass}-${this.id}`),t.className.includes(`${this.Settings.droppedInsideClass}-`)||t.classList.remove(`${this.Settings.droppedInsideClass}`))})),e?this.element.classList.add(`${this.Settings.dropZoneInsideClass}`):this.element.classList.remove(`${this.Settings.dropZoneInsideClass}`)};start=({isDragging:e})=>{e&&!this.isDestroyed&&this.setReadyClasses("add")};stop=({isDragging:e})=>{e&&!this.isDestroyed&&(this.setReadyClasses("remove"),this.handleItemsInsideClasses())};destroy(){this._observers?.cleanup(),this.element.classList.remove(`${this.Settings.dropZoneClass}`),this.element.classList.remove(`${this.Settings.dropZoneTargetClass}`),this.element.classList.remove(`${this.Settings.dropZoneReadyClass}`),this.droppables.forEach((e=>{e.classList.remove(`${this.Settings.droppedTargetClass}`),e.classList.remove(`${this.Settings.droppedTargetClass}-${this.id}`),e.classList.remove(`${this.Settings.droppableClass}`),e.classList.remove(`${this.Settings.droppableClass}-${this.id}`)})),this.PS.unsubscribe("Interaction:start",this.start),this.PS.unsubscribe("Interaction:end",this.stop),this.isDestroyed=!0}toObject=()=>({id:this.id,element:this.element,droppables:this.droppables,itemsDropped:this.itemsDropped,itemsInside:this.itemsInside});get rect(){if(!this.isDestroyed)return this._rect?this._rect:this._rect=this.element.getBoundingClientRect()}get itemsDropped(){if(!this.isDestroyed)return this._itemsDropped}get itemsInside(){if(!this.isDestroyed)return this._itemsInside||(this._itemsInside=this.droppables.flatMap((e=>{const t=this.DS.SelectableSet.rects.get(e);return this.rect&&p(t,this.rect,this.Settings.dropInsideThreshold)?[e]:[]})),this._timeout&&clearTimeout(this._timeout),this._timeout=setTimeout((()=>this._itemsInside=void 0),this.Settings.refreshMemoryRate)),this._itemsInside}get parentNodes(){return this._parentNodes?this._parentNodes:this._parentNodes=s(this.element)}get droppables(){return this._droppables?this._droppables:this.DS.SelectableSet.elements}set droppables(e){this._droppables=e}}class b{_zoneByElement=new Map;_zoneById=new Map;_zonesByDroppable=new Map;_zones;DS;PS;Settings;constructor({DS:e,PS:t}){this.DS=e,this.PS=t,this.Settings=this.DS.stores.SettingsStore.s,this.PS.subscribe("Settings:updated:dropZones",(({settings:e})=>this.setDropZones(e))),this.setDropZones({dropZones:this.Settings.dropZones}),this.PS.subscribe("Interaction:end",this.stop)}setDropZones=({dropZones:e})=>{e&&(this._zones&&this._zones.forEach((e=>e.destroy())),this._zones=e.map((e=>new m({DS:this.DS,PS:this.PS,...e}))),this._zones.forEach((e=>{this._zoneByElement.set(e.element,e),this._zoneById.set(e.id,e),e.droppables.forEach((t=>{const s=this._zonesByDroppable.get(t);if(!s?.length)return this._zonesByDroppable.set(t,[e]);this._zonesByDroppable.set(t,[...new Set([...s,e])])}))})))};_handleDrops=e=>{this._zones?.forEach((t=>{t!==e&&t.handleNoDrop()})),e&&e.handleDrop()};_getZoneByElementsFromPoint=(e,{x:t,y:s})=>{for(let i=0,r=e.length;i<r;i++){const r=this._zoneByElement.get(e[i]);if(p(r?.rect,{left:t,right:t,top:s,bottom:s},Math.min(this.Settings.dropTargetThreshold,.5)))return r}};stop=({isDragging:e,isDraggingKeyboard:t,event:s})=>{if(!e)return;const i=this.getTarget({isDraggingKeyboard:t,event:s});this._handleDrops(i)};getItemsDroppedById=e=>{const t=this._zoneById.get(e);return t?t.itemsDropped:console.warn(`[DragSelect] No zone found (id: ${e})`)};getItemsInsideById=(e,t)=>{const s=this._zoneById.get(e);return s?(t&&s.handleItemsInsideClasses(),s.itemsInside):console.warn(`[DragSelect] No zone found (id: ${e})`)};getKeyboardItemCenter=(e,t)=>{if(!e||!t)return;const s=t.target?.getBoundingClientRect();return{x:s.left+s.width/2,y:s.top+s.height/2}};getTarget=({coordinates:e,isDraggingKeyboard:t,event:s})=>{if(!this._zones?.length)return;let i;!e&&t&&s&&(i=this.getKeyboardItemCenter(t,s));const r=e?.x||i?.x||this.DS.stores.PointerStore.currentVal.x,n=e?.y||i?.y||this.DS.stores.PointerStore.currentVal.y,o=document.elementsFromPoint(r,n);return this._getZoneByElementsFromPoint(o,{x:r,y:n})}}class y{isInteracting;isDragging=!1;DS;PS;Settings;constructor({DS:e,PS:t}){this.DS=e,this.PS=t,this.Settings=this.DS.stores.SettingsStore.s,this.PS.subscribe("Settings:updated:area",(({settings:e})=>{this.removeAreaEventListeners(e["area:pre"]),this.setAreaEventListeners(e.area)})),this.PS.subscribe("PointerStore:updated",(({event:e})=>this.update({event:e}))),this.PS.subscribe("Selectable:click",this.onClick),this.PS.subscribe("Selectable:pointer",(({event:e})=>this.start(e))),this.PS.subscribe("Interaction:start:pre",(({event:e})=>this._start(e))),this.PS.subscribe("Interaction:init:pre",this._init),this.PS.subscribe("Interaction:end:pre",(({event:e})=>this._reset(e))),this.PS.subscribe("Area:scroll",this.update)}init=()=>this.PS.publish("Interaction:init:pre",{init:!0});_init=()=>{this.stop(),this.setAreaEventListeners(),this.PS.publish("Interaction:init",{init:!0})};_canInteract(e){const t="clientX"in e&&0===e.clientX&&0===e.clientY&&0===e.detail&&e.target;return!("button"in e&&2===e.button||this.isInteracting||e.target&&!this.DS.SelectorArea.isInside(e.target)||!t&&!this.DS.SelectorArea.isClicked(e))}start=e=>this.PS.publish("Interaction:start:pre",{event:e,isDragging:this.isDragging});_start=e=>{"touchstart"===e.type&&e.preventDefault(),this._canInteract(e)&&(this.isInteracting=!0,this.isDragging=this.isDragEvent(e),this.PS.publish("Interaction:start",{event:e,isDragging:this.isDragging}),this.setDocEventListeners())};isDragEvent=e=>{let t=null;return e.target&&"closest"in e.target&&(t=e.target.closest(`.${this.Settings.selectableClass}`)),!(!this.Settings.draggability||this.DS.stores.KeyStore.isMultiSelectKeyPressed(e)||!t)&&(this.Settings.immediateDrag&&(this.DS.SelectedSet.size?this.DS.SelectedSet.has(t)||(this.DS.SelectedSet.clear(),this.DS.SelectedSet.add(t)):this.DS.SelectedSet.add(t)),!!this.DS.SelectedSet.has(t))};onClick=({event:e})=>{if(!this._canInteract(e))return;if(e.detail>0)return;const{stores:{PointerStore:t,KeyStore:s},SelectableSet:i,SelectedSet:r}=this.DS;t.start(e);const n=e.target;n&&!i.has(n)||(s.isMultiSelectKeyPressed(e)||r.clear(),n&&r.toggle(n),this.reset(e))};stop=(e=this.DS.Area.HTMLNode)=>{this.removeAreaEventListeners(e),this.removeDocEventListeners()};update=({event:e,scroll_directions:t,scroll_multiplier:s})=>{this.isInteracting&&this.PS.publish(["Interaction:update:pre","Interaction:update"],{event:e,scroll_directions:t,scroll_multiplier:s,isDragging:this.isDragging})};reset=e=>this.PS.publish("Interaction:end:pre",{event:e,isDragging:this.isDragging});_reset=e=>{const{isDragging:t}=this;this.isInteracting=!1,this.isDragging=!1,this.removeDocEventListeners(),this.PS.publish("Interaction:end",{event:e,isDragging:t})};setAreaEventListeners=(e=this.DS.Area.HTMLNode)=>{this.Settings.usePointerEvents?e.addEventListener("pointerdown",this.start,{passive:!1}):e.addEventListener("mousedown",this.start),e.addEventListener("touchstart",this.start,{passive:!1})};removeAreaEventListeners=(e=this.DS.Area.HTMLNode)=>{this.Settings.usePointerEvents?e.removeEventListener("pointerdown",this.start,{passive:!1}):e.removeEventListener("mousedown",this.start),e.removeEventListener("touchstart",this.start,{passive:!1})};setDocEventListeners=()=>{this.Settings.usePointerEvents?(document.addEventListener("pointerup",this.reset),document.addEventListener("pointercancel",this.reset)):document.addEventListener("mouseup",this.reset),document.addEventListener("touchend",this.reset)};removeDocEventListeners=()=>{this.Settings.usePointerEvents?(document.removeEventListener("pointerup",this.reset),document.removeEventListener("pointercancel",this.reset)):document.removeEventListener("mouseup",this.reset),document.removeEventListener("touchend",this.reset)}}class D{_currentValues=new Set;_keyMapping={control:"ctrlKey",shift:"shiftKey",meta:"metaKey"};DS;PS;settings;constructor({DS:e,PS:t}){this.DS=e,this.PS=t,this.settings=this.DS.stores.SettingsStore.s,this.PS.subscribe("Interaction:init",this.init)}init=()=>{document.addEventListener("keydown",this.keydown),document.addEventListener("keyup",this.keyup),window.addEventListener("blur",this.reset)};keydown=e=>{if(!e.key?.toLocaleLowerCase)return;const t=e.key.toLowerCase();this.PS.publish("KeyStore:down:pre",{event:e,key:t}),this._currentValues.add(t),this.PS.publish("KeyStore:down",{event:e,key:t})};keyup=e=>{if(!e.key?.toLocaleLowerCase)return;const t=e.key.toLowerCase();this.PS.publish("KeyStore:up:pre",{event:e,key:t}),this._currentValues.delete(t),this.PS.publish("KeyStore:up",{event:e,key:t})};stop=()=>{document.removeEventListener("keydown",this.keydown),document.removeEventListener("keyup",this.reset),window.removeEventListener("blur",this.reset),this.reset()};reset=()=>this._currentValues.clear();isMultiSelectKeyPressed(e){if(this.settings.multiSelectMode)return!0;const t=this.settings.multiSelectKeys?.map((e=>e.toLocaleLowerCase()))??[];return!!this.currentValues.some((e=>t.includes(e)))||!(!e||!t.some((t=>e[this._keyMapping[t]])))}get currentValues(){return Array.from(this._currentValues.values())}}class _{_isMouseInteraction=!1;_initialValArea={x:0,y:0};_currentValArea={x:0,y:0};_lastValArea={x:0,y:0};_initialVal={x:0,y:0};_currentVal={x:0,y:0};_lastVal={x:0,y:0};_lastTouch;DS;PS;settings;constructor({DS:e,PS:t}){this.DS=e,this.PS=t,this.settings=this.DS.stores.SettingsStore.s,this.PS.subscribe("Interaction:init",this.init),this.PS.subscribe("Interaction:start",(({event:e})=>this.start(e))),this.PS.subscribe("Interaction:end",(({event:e})=>this.reset(e)))}init=()=>{this.settings.usePointerEvents?document.addEventListener("pointermove",this.update,{passive:!1}):document.addEventListener("mousemove",this.update),document.addEventListener("touchmove",this.update,{passive:!1})};start(e){e&&(this._isMouseInteraction=!0,this.currentVal=this.initialVal=this.getPointerPosition(e))}getPointerPosition=e=>(({event:e})=>({x:e.clientX,y:e.clientY}))({event:this._normalizedEvent(e)});update=e=>{e&&(this.PS.publish("PointerStore:updated:pre",{event:e}),this.currentVal=this.getPointerPosition(e),this._isMouseInteraction&&this.PS.publish("PointerStore:updated",{event:e}))};stop=()=>{this.settings.usePointerEvents?document.removeEventListener("pointermove",this.update,{passive:!1}):document.removeEventListener("mousemove",this.update),document.removeEventListener("touchmove",this.update,{passive:!1}),this.reset()};reset=e=>{this.currentVal=this.lastVal=this.getPointerPosition(e),setTimeout((()=>this._isMouseInteraction=!1),100)};_normalizedEvent(e){return!e||e instanceof KeyboardEvent?{clientX:0,clientY:0}:"touches"in e?("touchend"!==e.type&&(this._lastTouch=e),this._lastTouch?.touches[0]||e.touches[0]):e}get initialValArea(){return this._initialValArea?this._initialValArea:{x:0,y:0}}get currentValArea(){return this._currentValArea?this._currentValArea:{x:0,y:0}}get lastValArea(){return this._lastValArea?this._lastValArea:{x:0,y:0}}get initialVal(){return this._initialVal?this._initialVal:{x:0,y:0}}get currentVal(){return this._currentVal?this._currentVal:{x:0,y:0}}get lastVal(){return this._lastVal?this._lastVal:{x:0,y:0}}set initialVal(e){this._initialVal=e,this._initialValArea=e&&o(e,"-",o(l(this.DS.Area.rect),"+",l(this.DS.Area.computedBorder)))}set currentVal(e){this._currentVal=e,this._currentValArea=e&&o(e,"-",o(l(this.DS.Area.rect),"+",l(this.DS.Area.computedBorder)))}set lastVal(e){this._lastVal=e,this._lastValArea=e&&o(e,"-",o(l(this.DS.Area.rect),"+",l(this.DS.Area.computedBorder)))}}class v{subscribers={};DS;constructor({DS:e}){this.DS=e}subscribe=(e,t)=>{Array.isArray(this.subscribers[e])||(this.subscribers[e]=[]);const s=this.subscribers[e];return s.push(t),s.length-1};unsubscribe=(e,t,s)=>{const i=s??this.subscribers[e]?.findIndex((e=>e===t));this.subscribers[e]?.splice(Number(i),1)};publish=(e,t)=>{Array.isArray(e)?e.forEach((e=>this._publish(e,t))):this._publish(e,t)};_publish=(e,t)=>{const s=this.subscribers[e]??[];e.includes(":pre")?this._handlePrePublish(s,t):this._handlePublish(s,t)};_handlePublish=(e,t)=>{for(let s=0,i=e.length;s<i;s++){if(this.DS.stopped)return;e[s]?.(t)}};_handlePrePublish=(e,t)=>{let s=e.length;for(;s--;){if(this.DS.stopped)return;e[s]?.(t)}}}const P=()=>({y:document.body?.scrollTop||document.documentElement?.scrollTop||0,x:document.body?.scrollLeft||document.documentElement?.scrollLeft||0}),f=e=>!e||e instanceof Document?P():{x:e.scrollLeft>=0?e.scrollLeft:P().x,y:e.scrollTop>=0?e.scrollTop:P().y},I=e=>{const t=e.scrollTop,s=Boolean(e.scrollTop=1);return e.scrollTop=t,s};class L{_initialVal={x:0,y:0};_currentVal={x:0,y:0};_canScroll;DS;PS;Settings;constructor({DS:e,PS:t}){this.DS=e,this.PS=t,this.Settings=this.DS.stores.SettingsStore.s,this.PS.subscribe("Area:modified",(()=>{this.stop(),this.init()})),this.PS.subscribe("Interaction:init",this.init),this.PS.subscribe("Interaction:start",(()=>this.start())),this.PS.subscribe("Interaction:end",(()=>this.reset()))}init=()=>this.addListeners();addListeners=()=>this.DS.Area.HTMLNode.addEventListener("scroll",this.update);removeListeners=()=>this.DS.Area.HTMLNode.removeEventListener("scroll",this.update);start=()=>{this._currentVal=this._initialVal=f(this.DS.Area.HTMLNode)};update=()=>this._currentVal=f(this.DS.Area.HTMLNode);stop=()=>{this.reset(),this.removeListeners()};reset=()=>{this._initialVal={x:0,y:0},this._canScroll=void 0};get canScroll(){return"boolean"==typeof this._canScroll?this._canScroll:this._canScroll=(e=>{const t=f(e);return!(!t.x&&!t.y)||(e instanceof Document?e.body?I(e.body):I(e.documentElement):I(e))})(this.DS.Area.HTMLNode)}get scrollAmount(){const e=o(this.currentVal,"-",this.initialVal),t=h(this.Settings.zoom),s=o(o(e,"*",t),"-",e);return{x:e.x+s.x,y:e.y+s.y}}get initialVal(){return this._initialVal?this._initialVal:{x:0,y:0}}get currentVal(){return this._currentVal||(this._currentVal=f(this.DS.Area.HTMLNode)),this._currentVal}}class T extends Set{_rects;_timeout;DS;PS;Settings;constructor({DS:e,PS:t}){super(),this.DS=e,this.PS=t,this.Settings=this.DS.stores.SettingsStore.s,this.PS.subscribe("Interaction:init",this.init),this.PS.subscribe("Settings:updated:selectables",(()=>{this.clear(),this.init()})),this.PS.subscribe("Settings:updated:selectableClass",(({settings:e})=>{this.forEach((t=>{t.classList.remove(e["selectableClass:pre"]),t.classList.add(e.selectableClass)}))}))}init=()=>g(this.Settings.selectables).forEach((e=>this.add(e)));add(e){if(!e||super.has(e))return this;const t={items:this.elements,item:e};return this.PS.publish("Selectable:added:pre",t),e.classList.add(this.Settings.selectableClass),e.addEventListener("click",this._onClick),this.Settings.usePointerEvents?e.addEventListener("pointerdown",this._onPointer,{passive:!1}):e.addEventListener("mousedown",this._onPointer),e.addEventListener("touchstart",this._onPointer,{passive:!1}),this.Settings.draggability&&!this.Settings.useTransform&&i({computedStyle:window.getComputedStyle(e),node:e}),this.PS.publish("Selectable:added",t),super.add(e)}delete(e){if(!e||!super.has(e))return!0;const t={items:this.elements,item:e};return this.PS.publish("Selectable:removed:pre",t),e.classList.remove(this.Settings.selectableClass),e.classList.remove(this.Settings.hoverClass),e.removeEventListener("click",this._onClick),this.Settings.usePointerEvents?e.removeEventListener("pointerdown",this._onPointer,{passive:!1}):e.removeEventListener("mousedown",this._onPointer),e.removeEventListener("touchstart",this._onPointer,{passive:!1}),this.PS.publish("Selectable:removed",t),super.delete(e)}clear=()=>this.forEach((e=>this.delete(e)));_onClick=e=>this.PS.publish(["Selectable:click:pre","Selectable:click"],{event:e});_onPointer=e=>this.PS.publish(["Selectable:pointer:pre","Selectable:pointer"],{event:e});addAll=e=>e.forEach((e=>this.add(e)));deleteAll=e=>e.forEach((e=>this.delete(e)));getElementRect=e=>this._rects?this._rects.get(e):e.getBoundingClientRect();get elements(){return Array.from(this.values())}get rects(){return this._rects||(this._rects=new Map,this.forEach((e=>this._rects?.set(e,e.getBoundingClientRect()))),this._timeout&&clearTimeout(this._timeout),this._timeout=setTimeout((()=>this._rects=void 0),this.Settings.refreshMemoryRate)),this._rects}}class E extends Set{_rects;_timeout;DS;PS;Settings;constructor({DS:e,PS:t}){super(),this.DS=e,this.PS=t,this.Settings=this.DS.stores.SettingsStore.s}add(e){if(!e||super.has(e))return this;const t={items:this.elements,item:e};return this.PS.publish("Selected:added:pre",t),super.add(e),e.classList.add(this.Settings.selectedClass),this.Settings.useLayers&&(e.style.zIndex=`${(parseInt(e.style.zIndex)||0)+1}`),this.PS.publish("Selected:added",t),this}delete(e){if(!e||!super.has(e))return!0;const t={items:this.elements,item:e};this.PS.publish("Selected:removed:pre",t);const s=super.delete(e);return e.classList.remove(this.Settings.selectedClass),this.Settings.useLayers&&(e.style.zIndex=""+((parseInt(e.style.zIndex)||0)-1)),this.PS.publish("Selected:removed",t),s}clear=()=>this.forEach((e=>this.delete(e)));toggle(e){return this.has(e)?this.delete(e):this.add(e),e}addAll=e=>e.forEach((e=>this.add(e)));deleteAll=e=>e.forEach((e=>this.delete(e)));get elements(){return Array.from(this.values())}get rects(){return this._rects||(this._rects=new Map,this.forEach((e=>this._rects?.set(e,e.getBoundingClientRect()))),this._timeout&&clearTimeout(this._timeout),this._timeout=setTimeout((()=>this._rects=void 0),this.Settings.refreshMemoryRate)),this._rects}}var C=(e,t)=>{t.left&&(e.style.left=`${t.left}px`),t.top&&(e.style.top=`${t.top}px`),t.width&&(e.style.width=`${t.width}px`),t.height&&(e.style.height=`${t.height}px`)};class x{_rect;DS;PS;Settings;HTMLNode;constructor({DS:e,PS:t}){this.DS=e,this.PS=t,this.Settings=this.DS.stores.SettingsStore.s,this.HTMLNode=this.Settings.selector,this.PS.subscribe("Settings:updated:selectorClass",(({settings:e})=>{this.HTMLNode.classList.remove(e["selectorClass:pre"]),this.HTMLNode.classList.add(e.selectorClass)})),this.PS.subscribe("Settings:updated:selector",this.attachSelector),this.PS.subscribe("Settings:updated:customStyles",this.attachSelector),this.attachSelector(),this.PS.subscribe("Interaction:start",this.start),this.PS.subscribe("Interaction:update",this.update),this.PS.subscribe("Interaction:end",this.stop)}attachSelector=()=>{this.HTMLNode&&this.DS.SelectorArea?.HTMLNode&&this.DS.SelectorArea.HTMLNode.removeChild(this.HTMLNode),this.HTMLNode=this.Settings.selector||(e=>{const t=document.createElement("div");return t.style.position="absolute",e||(t.style.background="rgba(0, 175, 255, 0.2)",t.style.border="1px solid rgba(0, 175, 255, 0.8)",t.style.display="none",t.style.pointerEvents="none"),t})(this.Settings.customStyles),this.HTMLNode.classList.add(this.Settings.selectorClass),this.HTMLNode&&this.DS.SelectorArea?.HTMLNode&&this.DS.SelectorArea.HTMLNode.appendChild(this.HTMLNode)};start=({isDragging:e})=>{if(e)return;const{stores:{PointerStore:t}}=this.DS,s=t.initialValArea;C(this.HTMLNode,a(s,1)),this.HTMLNode.style.display="block",this._rect=void 0};stop=()=>{this.HTMLNode.style.width="0",this.HTMLNode.style.height="0",this.HTMLNode.style.display="none"};update=({isDragging:e})=>{if(e||this.DS.continue)return;const{stores:{ScrollStore:t,PointerStore:s}}=this.DS,i=(({scrollAmount:e,initialPointerPos:t,pointerPos:s})=>{const i={};return s.x>t.x-e.x?(i.left=t.x-e.x,i.width=s.x-t.x+e.x):(i.left=s.x,i.width=t.x-s.x-e.x),s.y>t.y-e.y?(i.top=t.y-e.y,i.height=s.y-t.y+e.y):(i.top=s.y,i.height=t.y-s.y-e.y),i})({scrollAmount:t.scrollAmount,initialPointerPos:s.initialValArea,pointerPos:s.currentValArea});C(this.HTMLNode,i),this._rect=void 0};get rect(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}class A{_prevSelectedSet=new Set;_boundingRect;_timeout;DS;PS;Settings;constructor({DS:e,PS:t}){this.DS=e,this.PS=t,this.Settings=this.DS.stores.SettingsStore.s,this.PS.subscribe("Interaction:start",this.start),this.PS.subscribe("Interaction:update",this.update)}_storePrevious(e){const{stores:{KeyStore:t},SelectedSet:s}=this.DS;t.isMultiSelectKeyPressed(e)?this._prevSelectedSet=new Set(s):this._prevSelectedSet=new Set}start=({event:e,isDragging:t})=>{t||(this._storePrevious(e),this._handleInsideSelection(!0,e))};update=({isDragging:e})=>{e||this.DS.continue||this._handleInsideSelection()};_handleInsideSelection=(e,t)=>{const{SelectableSet:s,SelectorArea:i,Selector:r}=this.DS,n=this.DS.stores.KeyStore.isMultiSelectKeyPressed(t)&&this.Settings.multiSelectToggling,o=this.Settings.selectionThreshold,l=s.rects,a=r.rect,h=new Map,c=new Map;for(const[e,t]of l)i.isInside(e,t)&&(p(t,a,o)?h.set(e,t):c.set(e,t));if(this.DS.continue)return;const{select:d,unselect:S}=this.filterSelected({select:h,unselect:c,selectorRect:a});d.forEach(((t,s)=>(({element:e,force:t,multiSelectionToggle:s,SelectedSet:i,hoverClassName:r})=>{e.classList.contains(r)&&!t||(i.has(e)?s&&i.delete(e):i.add(e),e.classList.add(r))})({element:s,force:e,multiSelectionToggle:n,SelectedSet:this.DS.SelectedSet,hoverClassName:this.Settings.hoverClass}))),S.forEach(((t,s)=>(({element:e,force:t,SelectedSet:s,PrevSelectedSet:i,hoverClassName:r})=>{if(!e.classList.contains(r)&&!t)return;const n=s.has(e),o=i.has(e);n&&!o?s.delete(e):!n&&o&&s.add(e),e.classList.remove(r)})({element:s,force:e,SelectedSet:this.DS.SelectedSet,hoverClassName:this.Settings.hoverClass,PrevSelectedSet:this._prevSelectedSet})))};get boundingRect(){return this._boundingRect||(this._boundingRect=(e=>{const t={top:Number.POSITIVE_INFINITY,left:Number.POSITIVE_INFINITY,bottom:Number.NEGATIVE_INFINITY,right:Number.NEGATIVE_INFINITY,width:Number.NEGATIVE_INFINITY,height:Number.NEGATIVE_INFINITY};return e.rects.forEach((e=>{t.top=Math.min(t.top,e.top||t.top),t.left=Math.min(t.left,e.left||t.left),t.bottom=Math.max(t.bottom,e.bottom||t.bottom),t.right=Math.max(t.right,e.right||t.right)})),t.height=t.bottom-t.top,t.width=t.right-t.left,t})(this.DS.SelectedSet),this._timeout&&clearTimeout(this._timeout),this._timeout=setTimeout((()=>this._boundingRect=void 0),this.Settings.refreshMemoryRate)),this._boundingRect}filterSelected=({select:e,unselect:t,selectorRect:s})=>({select:e,unselect:t})}class w{_scrollInterval;_rect;currentEdges=[];DS;PS;Settings;HTMLNode;constructor({DS:e,PS:t}){this.DS=e,this.PS=t,this.Settings=this.DS.stores.SettingsStore.s,this.HTMLNode=(()=>{const e=document.createElement("div");return e.style.position="fixed",e.style.overflow="hidden",e.style.pointerEvents="none",e.style.zIndex="999999999999999999",e})(),this.PS.subscribe("Settings:updated:selectorAreaClass",(({settings:e})=>{this.HTMLNode.classList.remove(e["selectorAreaClass:pre"]),this.HTMLNode.classList.add(e.selectorAreaClass)})),this.HTMLNode.classList.add(this.Settings.selectorAreaClass),this.PS.subscribe("Area:modified",this.updatePos),this.PS.subscribe("Area:modified",this.updatePos),this.PS.subscribe("Interaction:init",this.init),this.PS.subscribe("Interaction:start",(({isDraggingKeyboard:e})=>this.startAutoScroll({isDraggingKeyboard:e}))),this.PS.subscribe("Interaction:end",(()=>{this.updatePos(),this.stopAutoScroll()}))}init=()=>{this.applyElements("append"),this.updatePos()};applyElements=e=>{const t=document.body?"body":"documentElement",s=`${e}Child`;this.HTMLNode[s](this.DS.Selector.HTMLNode),document[t][s](this.HTMLNode)};updatePos=()=>{this._rect=void 0;const e=this.DS.Area.rect,t=this.DS.Area.computedBorder,{style:s}=this.HTMLNode,i=`${e.top+t.top}px`,r=`${e.left+t.left}px`,n=`${e.width}px`,o=`${e.height}px`;s.top!==i&&(s.top=i),s.left!==r&&(s.left=r),s.width!==n&&(s.width=n),s.height!==o&&(s.height=o)};stop=e=>{this.stopAutoScroll(),e&&this.applyElements("remove")};startAutoScroll=({isDraggingKeyboard:e})=>{e||(this.currentEdges=[],this._scrollInterval=setInterval((()=>this.handleAutoScroll()),16))};handleAutoScroll=()=>{if(this.DS.continue)return;const{stores:{PointerStore:e},Area:t}=this.DS;this.currentEdges=(({elementRect:e,containerRect:t,tolerance:s={x:0,y:0}})=>{const i=[];return e.top-s.y<t.top&&i.push("top"),e.left-s.x<t.left&&i.push("left"),e.bottom+s.y>t.bottom&&i.push("bottom"),e.right+s.y>t.right&&i.push("right"),i})({elementRect:a(e.currentVal),containerRect:this.rect,tolerance:this.Settings.overflowTolerance}),this.currentEdges.length&&t.scroll(this.currentEdges,this.Settings.autoScrollSpeed)};stopAutoScroll=()=>{this.currentEdges=[],clearInterval(this._scrollInterval)};isInside=(e,t)=>!(!this.DS.Area.HTMLNode.contains(e)||!this.DS.stores.ScrollStore.canScroll)||p(this.rect,t||e.getBoundingClientRect());isClicked(e){const{stores:{PointerStore:t}}=this.DS,s=e?t.getPointerPosition(e):t.initialVal;return p({left:s.x,top:s.y,right:s.x,bottom:s.y},this.rect)}get rect(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}const N=(e,t)=>console.warn(`[DragSelect] TypeIssue: setting "${e}" is not of type "${t}".`),M=(e,t,s,i)=>{if(void 0===t)return s?{[e]:i}:{};if(null===t)return{[e]:null};let r=!0,n=!1;const o="string"==typeof i;o&&(r="string"==typeof t||t instanceof String),o&&!r&&(n=!0,N(e,"string"));const l=!Number.isNaN(i)&&"number"==typeof i;l&&(r=!Number.isNaN(t)&&"number"==typeof t),l&&!r&&(n=!0,N(e,"number"));const a="[object Object]"===Object.prototype.toString.call(i);a&&(r="[object Object]"===Object.prototype.toString.call(t)),a&&!r&&(n=!0,N(e,"object"));const h="boolean"==typeof i;h&&(r="boolean"==typeof t),h&&!r&&(n=!0,N(e,"boolean"));const c=Array.isArray(i);c&&(r=Array.isArray(t)),c&&!r&&(n=!0,N(e,"array"));const d=n||s;return"dragKeys"===e&&r?{[e]:Object.assign(i,t)}:"dragKeys"!==e||r?("dropZones"===e&&r&&Array.isArray(t)&&new Set(t.map((e=>e.id))).size!==t.length&&console.warn('[DragSelect] UniqueConstraintsIssue: setting "dropZones" contains duplicate ids.'),r?{[e]:t}:d?{[e]:i}:{}):d?{[e]:i}:{}};class V{_settings={};s={};PS;constructor({PS:e,settings:t}){this.PS=e,this.update({settings:t,init:!0})}update=({settings:e,init:t})=>{this.PS.publish("Settings:updated:pre",{settings:this._settings,"settings:init":Boolean(t),"settings:new":e}),this._update({settings:e,init:t})};_update=({settings:e={},init:t=!1})=>{const s=((e,t)=>({...M("area",e.area,t,document),...M("selectables",e.selectables,t,null),...M("autoScrollSpeed",e.autoScrollSpeed,t,5),...M("overflowTolerance",e.overflowTolerance,t,{x:25,y:25}),...M("zoom",e.zoom,t,1),...M("customStyles",e.customStyles,t,!1),...M("multiSelectMode",e.multiSelectMode,t,!1),...M("multiSelectToggling",e.multiSelectToggling,t,!0),...M("multiSelectKeys",e.multiSelectKeys,t,["Control","Shift","Meta"]),...M("selector",e.selector,t,null),...M("selectionThreshold",e.selectionThreshold,t,0),...M("draggability",e.draggability,t,!0),...M("immediateDrag",e.immediateDrag,t,!0),...M("keyboardDrag",e.keyboardDrag,t,!0),...M("dragKeys",e.dragKeys,t,{up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]}),...M("keyboardDragSpeed",e.keyboardDragSpeed,t,10),...M("useTransform",e.useTransform,t,!0),...M("refreshMemoryRate",e.refreshMemoryRate,t,80),...M("dropZones",e.dropZones,t,[]),...M("dropInsideThreshold",e.dropInsideThreshold,t,1),...M("dropTargetThreshold",e.dropTargetThreshold,t,0),...M("usePointerEvents",e.usePointerEvents,t,!1),...M("hoverClass",e.hoverClass,t,"ds-hover"),...M("selectableClass",e.selectableClass,t,"ds-selectable"),...M("selectedClass",e.selectedClass,t,"ds-selected"),...M("selectorClass",e.selectorClass,t,"ds-selector"),...M("selectorAreaClass",e.selectorAreaClass,t,"ds-selector-area"),...M("droppedTargetClass",e.droppedTargetClass,t,"ds-dropped-target"),...M("droppedInsideClass",e.droppedInsideClass,t,"ds-dropped-inside"),...M("droppableClass",e.droppableClass,t,"ds-droppable"),...M("dropZoneClass",e.dropZoneClass,t,"ds-dropzone"),...M("dropZoneReadyClass",e.dropZoneReadyClass,t,"ds-dropzone-ready"),...M("dropZoneTargetClass",e.dropZoneTargetClass,t,"ds-dropzone-target"),...M("dropZoneInsideClass",e.dropZoneInsideClass,t,"ds-dropzone-inside"),...M("useLayers",e.useLayers,t,!0)}))(e,t);for(const[i,r]of Object.entries(s))((s,i)=>{s in this._settings||Object.defineProperty(this.s,s,{get:()=>this._settings[s],set:e=>this.update({settings:{[s]:e}})}),this._settings[`${s}:pre`]=this._settings[s],this._settings[s]=i;const r={settings:this._settings,"settings:init":t,"settings:new":e};this.PS.publish("Settings:updated",r),this.PS.publish(`Settings:updated:${s}`,r)})(i,r)}}const K={elementselect:"DS:select",elementunselect:"DS:unselect",autoscroll:"DS:scroll",dragstart:"DS:start",dragmove:"DS:update",callback:"DS:end",preelementselect:"DS:select:pre",preelementunselect:"DS:unselect:pre",preautoscroll:"DS:scroll:pre",predragstart:"DS:start:pre",predragmove:"DS:update:pre",precallback:"DS:end:pre"},k=(e,t)=>{const s=t.DropZones.getTarget(e);return{...e,...s?{dropTarget:s.toObject()}:{}}},R=({sub_name:e,DS:t,PS:s,sub_pubs:i})=>{s.subscribe(e,(e=>i.forEach((s=>H({sub_pub:s,data:e,DS:t})))))},H=({sub_pub:e,data:t,DS:s})=>{const i=e.condition?e.condition(t,s):t;if(i){const r=e.extraData&&e.extraData(t,s)||{};s.publish(e.name,{items:s.SelectedSet.elements,isDragging:s.Interaction.isDragging,...i,...r})}};class ${continue=!1;PubSub;stores;Area;Selector;SelectorArea;SelectableSet;SelectedSet;Selection;Drag;DropZones;Interaction;stopped;constructor(e){this.stopped=!1,this.PubSub=new v({DS:this}),this.stores={},this.stores.SettingsStore=new V({settings:e,PS:this.PubSub}),this.stores.PointerStore=new _({DS:this,PS:this.PubSub}),this.stores.ScrollStore=new L({DS:this,PS:this.PubSub}),this.stores.KeyStore=new D({DS:this,PS:this.PubSub}),this.Area=new n({DS:this,PS:this.PubSub}),this.Selector=new x({DS:this,PS:this.PubSub}),this.SelectorArea=new w({DS:this,PS:this.PubSub}),this.SelectableSet=new T({DS:this,PS:this.PubSub}),this.SelectedSet=new E({DS:this,PS:this.PubSub}),this.Selection=new A({DS:this,PS:this.PubSub}),this.Drag=new u({DS:this,PS:this.PubSub}),this.DropZones=new b({DS:this,PS:this.PubSub}),this.Interaction=new y({DS:this,PS:this.PubSub}),(({PS:e,DS:t})=>{const s={"Selected:added":[{name:"preelementselect"},{name:"elementselect"},{name:"DS:select:pre"},{name:"DS:select"}],"Selected:removed":[{name:"preelementunselect"},{name:"elementunselect"},{name:"DS:unselect:pre"},{name:"DS:unselect"}],"Selectable:added":[{name:"DS:added:pre"},{name:"DS:added"}],"Selectable:removed":[{name:"DS:removed:pre"},{name:"DS:removed"}],"Area:scroll":[{name:"preautoscroll"},{name:"autoscroll"},{name:"DS:scroll:pre"},{name:"DS:scroll"}],"Interaction:start":[{name:"predragstart"},{name:"dragstart"},{name:"DS:start:pre"},{name:"DS:start"}],"Interaction:update":[{name:"predragmove",condition:e=>e.event?e:null},{name:"dragmove",condition:e=>e.event?e:null},{name:"DS:update:pre",condition:e=>e.event?e:null},{name:"DS:update",condition:e=>e.event?e:null}],"Interaction:end":[{name:"precallback",extraData:(e,t)=>k(e,t)},{name:"callback",extraData:(e,t)=>k(e,t)},{name:"DS:end:pre",extraData:(e,t)=>k(e,t)},{name:"DS:end",extraData:(e,t)=>k(e,t)}]};for(const[i,r]of Object.entries(s))R({sub_name:i,sub_pubs:r,DS:t,PS:e})})({DS:this,PS:this.PubSub}),this.PubSub.subscribe("Interaction:end",(()=>this.continue=!1)),this.PubSub.subscribe("DS:end",(({items:e})=>this.continue=!1)),this.start()}static isCollision;subscribe=(e,t)=>(K[e]&&console.warn(`[DragSelect]: The event name "${e}" is deprecated and was/will be removed in a future version. Please use the new event name "${K[e]}" instead.`),this.PubSub.subscribe(e,t));unsubscribe=(e,t,s)=>this.PubSub.unsubscribe(e,t,s);publish=(e,t)=>this.PubSub.publish(e,t);start=()=>{this.stopped=!1,this.Interaction.init()};stop(e=!0,t=!0,s=!1){s&&this.publish("DS:end",{items:this.SelectedSet.elements,isDragging:this.Interaction.isDragging}),this.Interaction.stop(),this.Area.stop(),this.Drag.stop(),this.Selector.stop(),this.SelectorArea.stop(e),this.stores.KeyStore.stop(),this.stores.PointerStore.stop(),this.stores.ScrollStore.stop(),e&&this.SelectableSet.clear(),t&&this.SelectedSet.clear(),this.stopped=!0}break=()=>this.continue=!0;setSettings=e=>this.stores.SettingsStore.update({settings:e});getSelection=()=>this.SelectedSet.elements;addSelection(e,t=!1,s=!1){const i=g(e);return this.SelectedSet.addAll(i),s||this.addSelectables(e,!1,!1),t&&this.PubSub.publish("DS:end",{items:this.SelectedSet.elements,isDragging:this.Interaction.isDragging}),this.getSelection()}removeSelection(e,t=!1,s=!1){const i=g(e);return this.SelectedSet.deleteAll(i),s&&this.removeSelectables(e,!1,!1),t&&this.PubSub.publish("DS:end",{items:this.SelectedSet.elements,isDragging:this.Interaction.isDragging}),this.getSelection()}toggleSelection(e,t=!1,s=!1){return g(e).forEach((i=>this.SelectedSet.has(i)?this.removeSelection(e,t,s):this.addSelection(e,t,s))),t&&this.PubSub.publish("DS:end",{items:this.SelectedSet.elements,isDragging:this.Interaction.isDragging}),this.getSelection()}setSelection(e,t=!1,s=!1){return this.clearSelection(),this.addSelection(e,t,s),this.getSelection()}clearSelection(e=!1){return this.SelectedSet.clear(),e&&this.PubSub.publish("DS:end",{items:this.SelectedSet.elements,isDragging:this.Interaction.isDragging}),this.getSelection()}addSelectables(e,t,s){const i=g(e);return this.SelectableSet.addAll(i),t&&this.SelectedSet.addAll(i),s&&this.PubSub.publish("DS:end",{items:this.SelectedSet.elements,isDragging:this.Interaction.isDragging}),i}getSelectables=()=>this.SelectableSet.elements;removeSelectables(e,t,s){const i=g(e);return this.SelectableSet.deleteAll(i),t&&this.removeSelection(e),s&&this.PubSub.publish("DS:end",{items:this.SelectedSet.elements,isDragging:this.Interaction.isDragging}),i}getInitialCursorPosition=()=>this.stores.PointerStore.initialVal;getCurrentCursorPosition=()=>this.stores.PointerStore.currentVal;getPreviousCursorPosition=()=>this.stores.PointerStore.lastVal;getInitialCursorPositionArea=()=>this.stores.PointerStore.initialValArea;getCurrentCursorPositionArea=()=>this.stores.PointerStore.currentValArea;getPreviousCursorPositionArea=()=>this.stores.PointerStore.lastValArea;isMultiSelect=e=>this.stores.KeyStore.isMultiSelectKeyPressed(e);isDragging=()=>this.Interaction.isDragging;getZoneByCoordinates=e=>this.DropZones.getTarget({coordinates:e})?.toObject();getItemsDroppedByZoneId=e=>this.DropZones.getItemsDroppedById(e);getItemsInsideByZoneId=(e,t)=>this.DropZones.getItemsInsideById(e,t)}return $.isCollision=p,$}));
@@ -0,0 +1,11 @@
1
+ declare function _default(nodes: DSArea[], cb: DSModificationCallback): {
2
+ observer: MutationObserver;
3
+ callback: DSModificationCallback;
4
+ cleanup: DSCleanup;
5
+ };
6
+ export default _default;
7
+ /**
8
+ * Removes event-listeners from the DOMNode
9
+ */
10
+ export type DSCleanup = () => void;
11
+ import "../types"
@@ -0,0 +1,3 @@
1
+ declare function _default(area: DSArea): boolean;
2
+ export default _default;
3
+ import "../types"
@@ -0,0 +1,3 @@
1
+ declare function _default(): HTMLDivElement;
2
+ export default _default;
3
+ import "../types"
@@ -0,0 +1,3 @@
1
+ declare function _default(customStyles: boolean): HTMLElement;
2
+ export default _default;
3
+ import "../types"
@@ -0,0 +1,3 @@
1
+ declare function _default(func: any, wait: number): DSModificationCallback;
2
+ export default _default;
3
+ import "../types"
@@ -0,0 +1,6 @@
1
+ declare function _default(): {
2
+ y: number;
3
+ x: number;
4
+ };
5
+ export default _default;
6
+ import "../types"
@@ -0,0 +1,3 @@
1
+ declare function _default(node: DSElement | DSArea): DSElements;
2
+ export default _default;
3
+ import "../types"
@@ -0,0 +1,3 @@
1
+ declare function _default(area: DSArea, zoom: number): DSBoundingRect;
2
+ export default _default;
3
+ import "../types"
@@ -0,0 +1,4 @@
1
+ declare function _default(elements: DSElements, SelectableSet: SelectableSet): DSBoundingRect;
2
+ export default _default;
3
+ import { SelectableSet } from "../modules";
4
+ import "../types"
@@ -0,0 +1,3 @@
1
+ declare function _default(area?: DSArea): Vect2;
2
+ export default _default;
3
+ import "../types"
@@ -0,0 +1,7 @@
1
+ declare function _default({ elementRect, containerRect, tolerance, }: {
2
+ elementRect: DSBoundingRect;
3
+ containerRect: DSBoundingRect;
4
+ tolerance?: Vect2;
5
+ }): DSEdges;
6
+ export default _default;
7
+ import "../types"
@@ -0,0 +1,5 @@
1
+ declare function _default({ event }: {
2
+ event: MouseEvent | Touch | PointerEvent;
3
+ }): Vect2;
4
+ export default _default;
5
+ import "../types"
@@ -0,0 +1,12 @@
1
+ declare function _default({ scrollAmount, initialPointerPos, pointerPos }: {
2
+ scrollAmount: Vect2;
3
+ initialPointerPos: Vect2;
4
+ pointerPos: Vect2;
5
+ }): {
6
+ left: number;
7
+ top: number;
8
+ width: number;
9
+ height: number;
10
+ };
11
+ export default _default;
12
+ import "../types"
@@ -0,0 +1,3 @@
1
+ declare function _default(element: DSElement, useTranslate?: boolean): Vect2;
2
+ export default _default;
3
+ import "../types"
@@ -0,0 +1,10 @@
1
+ declare function _default({ element, edges, elementRect, containerRect, elementPos, useTransform, }: {
2
+ element: DSElement;
3
+ edges: DSEdges;
4
+ elementRect: DSBoundingRect;
5
+ containerRect: DSBoundingRect;
6
+ elementPos: Vect2;
7
+ useTransform: boolean;
8
+ }): void;
9
+ export default _default;
10
+ import "../types"
@@ -0,0 +1,6 @@
1
+ declare function _default({ computedStyle, node }: {
2
+ computedStyle: CSSStyleDeclaration;
3
+ node: DSArea;
4
+ }): void;
5
+ export default _default;
6
+ import "../types"
@@ -0,0 +1,13 @@
1
+ declare function _default({ shiftKey, keyboardDragSpeed, zoom, key, dragKeys, scrollDiff, canScroll, scrollCallback, }: {
2
+ key: string;
3
+ shiftKey: boolean;
4
+ canScroll: boolean;
5
+ keyboardDragSpeed: number;
6
+ zoom: number;
7
+ scrollCallback: ScrollCallback;
8
+ scrollDiff: Vect2;
9
+ dragKeys: DSDragKeys;
10
+ }): Vect2;
11
+ export default _default;
12
+ export type ScrollCallback = Function;
13
+ import "../types"
@@ -0,0 +1,9 @@
1
+ declare function _default({ element, force, multiSelectionToggle, SelectedSet, hoverClassName, }: {
2
+ element: DSElement;
3
+ force: boolean;
4
+ multiSelectionToggle: boolean;
5
+ SelectedSet: Set<any>;
6
+ hoverClassName: string;
7
+ }): void;
8
+ export default _default;
9
+ import "../types"
@@ -0,0 +1,9 @@
1
+ declare function _default({ element, force, SelectedSet, PrevSelectedSet, hoverClassName, }: {
2
+ element: DSElement;
3
+ force: boolean;
4
+ SelectedSet: Set<any>;
5
+ PrevSelectedSet: Set<any>;
6
+ hoverClassName: string;
7
+ }): boolean;
8
+ export default _default;
9
+ import "../types"
@@ -0,0 +1,3 @@
1
+ declare function _default(settings: Settings, withFallback: boolean): any;
2
+ export default _default;
3
+ import "../types"
@@ -0,0 +1,30 @@
1
+ export * as vect2 from "./vect2";
2
+ export { default as addModificationObservers } from "./addModificationObservers";
3
+ export { default as canScroll } from "./canScroll";
4
+ export { default as createSelectorAreaElement } from "./createSelectorAreaElement";
5
+ export { default as createSelectorElement } from "./createSelectorElement";
6
+ export { default as debounce } from "./debounce";
7
+ export { default as documentScroll } from "./documentScroll";
8
+ export { default as getAllParentNodes } from "./getAllParentNodes";
9
+ export { default as getAreaRect } from "./getAreaRect";
10
+ export { default as getBoundingClientRect } from "./getBoundingClientRect";
11
+ export { default as getCurrentScroll } from "./getCurrentScroll";
12
+ export { default as getOverflowEdges } from "./getOverflowEdges";
13
+ export { default as getPointerPos } from "./getPointerPos";
14
+ export { default as getSelectorPosition } from "./getSelectorPosition";
15
+ export { default as getStylePosition } from "./getStylePosition";
16
+ export { default as handleElementOverflow } from "./handleElementOverflow";
17
+ export { default as handleElementPositionAttribute } from "./handleElementPositionAttribute";
18
+ export { default as handleKeyboardDragPosDifference } from "./handleKeyboardDragPosDifference";
19
+ export { default as handleSelection } from "./handleSelection";
20
+ export { default as handleUnSelection } from "./handleUnSelection";
21
+ export { default as hydrateSettings } from "./hydrateSettings";
22
+ export { default as isCollision } from "./isCollision";
23
+ export { default as moveElement } from "./moveElement";
24
+ export { default as removeModificationObservers } from "./removeModificationObservers";
25
+ export { default as scrollElement } from "./scrollElement";
26
+ export { default as setStylePosition } from "./setStylePosition";
27
+ export { default as subscriberAliases } from "./subscriberAliases";
28
+ export { default as toArray } from "./toArray";
29
+ export { default as updateElementStylePos } from "./updateElementStylePos";
30
+ import "../types"
@@ -0,0 +1,13 @@
1
+ declare function _default(el1: {
2
+ left: number;
3
+ right: number;
4
+ top: number;
5
+ bottom: number;
6
+ }, el2: {
7
+ left: number;
8
+ right: number;
9
+ top: number;
10
+ bottom: number;
11
+ }, percent?: number): boolean;
12
+ export default _default;
13
+ import "../types"
@@ -0,0 +1,8 @@
1
+ declare function _default({ element, posDirection, containerRect, useTransform }: {
2
+ element: DSElement;
3
+ posDirection: Vect2;
4
+ containerRect: DSBoundingRect;
5
+ useTransform: boolean;
6
+ }): void;
7
+ export default _default;
8
+ import "../types"
@@ -0,0 +1,3 @@
1
+ declare function _default(modificationObserver: MutationObserver, callback: DSModificationCallback): void;
2
+ export default _default;
3
+ import "../types"
@@ -0,0 +1,3 @@
1
+ declare function _default(element: DSArea, directions: Array<'top' | 'bottom' | 'left' | 'right' | undefined>, multiplier: number): void;
2
+ export default _default;
3
+ import "../types"
@@ -0,0 +1,3 @@
1
+ declare function _default(element: DSElement, values: Vect2, useTranslate?: boolean): DSElement;
2
+ export default _default;
3
+ import "../types"
@@ -0,0 +1,14 @@
1
+ declare function _default({ subscribe, publish, Interaction, SelectedSet, DropZones, }: {
2
+ subscribe: DSSubscribe;
3
+ publish: DSPublish;
4
+ Interaction: Interaction;
5
+ SelectedSet: SelectedSet;
6
+ DropZones: DropZones;
7
+ }): void;
8
+ export default _default;
9
+ export type DSSubscribe = Function;
10
+ export type DSPublish = Function;
11
+ import { Interaction } from "../modules";
12
+ import { SelectedSet } from "../modules";
13
+ import { DropZones } from "../modules";
14
+ import "../types"
@@ -0,0 +1,3 @@
1
+ declare function _default(items: DSInputElements): DSElements;
2
+ export default _default;
3
+ import "../types"
@@ -0,0 +1,8 @@
1
+ declare function _default(element: HTMLElement, pos: {
2
+ left: number;
3
+ top: number;
4
+ width: number;
5
+ height: number;
6
+ }): void;
7
+ export default _default;
8
+ import "../types"
@@ -0,0 +1,8 @@
1
+ export function calc({ x: x1, y: y1 }: Vect2, operator: '+' | '-' | '*' | '/', { x: x2, y: y2 }: Vect2): Vect2;
2
+ export function rect2vect(rect: {
3
+ left: number;
4
+ top: number;
5
+ }): Vect2;
6
+ export function vect2rect(vect: Vect2, dimension?: number): DSBoundingRect;
7
+ export function num2vect(n: number): Vect2;
8
+ import "../types"
@@ -0,0 +1,80 @@
1
+ export default class Area {
2
+ /**
3
+ * @constructor Area
4
+ * @param {{DS:DragSelect}} p
5
+ * @ignore
6
+ */
7
+ constructor({ DS }: {
8
+ DS: DragSelect;
9
+ });
10
+ /**
11
+ * @type {DragSelect}
12
+ * @private
13
+ */
14
+ private DS;
15
+ /**
16
+ * @type {{cleanup:() => void}}
17
+ * @private
18
+ */
19
+ private _observers;
20
+ /**
21
+ * @type {DSArea}
22
+ * @private
23
+ */
24
+ private _node;
25
+ /**
26
+ * @type {DSArea[]}
27
+ * @private
28
+ */
29
+ private _parentNodes;
30
+ /**
31
+ * @type {CSSStyleDeclaration}
32
+ * @private
33
+ * */
34
+ private _computedStyle;
35
+ /**
36
+ * @type {{top:number,bottom:number,left:number,right:number}}
37
+ * @private
38
+ * */
39
+ private _computedBorder;
40
+ /**
41
+ * @type {DSBoundingRect}
42
+ * @private
43
+ * */
44
+ private _rect;
45
+ /** @param {DSArea} area */
46
+ setArea: (area: DSArea) => void;
47
+ start: () => void;
48
+ reset: () => void;
49
+ stop: () => void;
50
+ /**
51
+ * Scroll the area in the specified direction
52
+ * @param {Array.<'top'|'bottom'|'left'|'right'|undefined>} directions
53
+ * @param {number} multiplier
54
+ */
55
+ scroll: (directions: Array<'top' | 'bottom' | 'left' | 'right' | undefined>, multiplier: number) => void;
56
+ get HTMLNode(): DSArea;
57
+ /**
58
+ * The computed border from the element (caches result)
59
+ * @type {{top:number,bottom:number,left:number,right:number}}
60
+ */
61
+ get computedBorder(): {
62
+ top: number;
63
+ bottom: number;
64
+ left: number;
65
+ right: number;
66
+ };
67
+ /**
68
+ * The computed styles from the element (caches result)
69
+ * @type {CSSStyleDeclaration}
70
+ */
71
+ get computedStyle(): CSSStyleDeclaration;
72
+ /**
73
+ * The element rect (caches result) (without scrollbar or borders)
74
+ * @type {DSBoundingRect}
75
+ */
76
+ get rect(): DSBoundingRect;
77
+ get parentNodes(): DSArea[];
78
+ }
79
+ import DragSelect from "../DragSelect";
80
+ import "../types"