From bc842ad371e2bc047db3100e623c39d7ce0fa0c2 Mon Sep 17 00:00:00 2001 From: jelveh Date: Sun, 27 Jul 2025 11:32:37 -0700 Subject: [PATCH] Update viselect.min.js --- src/gui/src/lib/viselect.min.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/src/lib/viselect.min.js b/src/gui/src/lib/viselect.min.js index 07c84a0e..cfceaa4a 100644 --- a/src/gui/src/lib/viselect.min.js +++ b/src/gui/src/lib/viselect.min.js @@ -1,3 +1,3 @@ -/*! @viselect/vanilla v3.2.4 MIT | https://github.com/Simonwep/selection/tree/master/packages/vanilla */ -(function(E,g){typeof exports=="object"&&typeof module<"u"?module.exports=g():typeof define=="function"&&define.amd?define(g):(E=typeof globalThis<"u"?globalThis:E||self,E.SelectionArea=g())})(this,function(){"use strict";var Y=Object.defineProperty;var $=(E,g,v)=>g in E?Y(E,g,{enumerable:!0,configurable:!0,writable:!0,value:v}):E[g]=v;var u=(E,g,v)=>($(E,typeof g!="symbol"?g+"":g,v),v);class E{constructor(){u(this,"_listeners",new Map);u(this,"on",this.addEventListener);u(this,"off",this.removeEventListener);u(this,"emit",this.dispatchEvent)}addEventListener(n,e){const t=this._listeners.get(n)||new Set;return this._listeners.set(n,t),t.add(e),this}removeEventListener(n,e){var t;return(t=this._listeners.get(n))==null||t.delete(e),this}dispatchEvent(n,...e){let t=!0;for(const s of this._listeners.get(n)||[])t=s(...e)!==!1&&t;return t}unbindAllListeners(){this._listeners.clear()}}const g=(r,n="px")=>typeof r=="number"?r+n:r;function v({style:r},n,e){if(typeof n=="object")for(const[t,s]of Object.entries(n))s!==void 0&&(r[t]=g(s));else e!==void 0&&(r[n]=g(e))}function C(r){return(n,e,t,s={})=>{n instanceof HTMLCollection||n instanceof NodeList?n=Array.from(n):Array.isArray(n)||(n=[n]),Array.isArray(e)||(e=[e]);for(const o of n)for(const i of e)o[r](i,t,{capture:!1,...s});return[n,e,t,s]}}const A=C("addEventListener"),b=C("removeEventListener"),w=r=>{const{clientX:n,clientY:e,target:t}=r.touches&&r.touches[0]||r;return{x:n,y:e,target:t}};function M(r,n,e="touch"){switch(e){case"center":{const t=n.left+n.width/2,s=n.top+n.height/2;return t>=r.left&&t<=r.right&&s>=r.top&&s<=r.bottom}case"cover":return n.left>=r.left&&n.top>=r.top&&n.right<=r.right&&n.bottom<=r.bottom;case"touch":return r.right>=n.left&&r.left<=n.right&&r.bottom>=n.top&&r.top<=n.bottom}}function T(r,n=document){const e=Array.isArray(r)?r:[r];let t=[];for(let s=0,o=e.length;smatchMedia("(hover: none), (pointer: coarse)").matches,q=()=>"safari"in window,R=(r,n)=>{for(const[e,t]of Object.entries(r)){const s=n[e];r[e]=s===void 0?r[e]:typeof s=="object"&&typeof t=="object"&&t!==null&&!Array.isArray(t)?R(t,s):s}return r},F=r=>{let n,e=-1,t=!1;return{next(...s){n=s,t||(t=!0,e=requestAnimationFrame(()=>{r(...n),t=!1}))},cancel(){cancelAnimationFrame(e),t=!1}}},{abs:S,max:k,min:D,ceil:j}=Math;class B extends E{constructor(e){super();u(this,"_options");u(this,"_selection",{stored:[],selected:[],touched:[],changed:{added:[],removed:[]}});u(this,"_area");u(this,"_clippingElement");u(this,"_targetElement");u(this,"_targetRect");u(this,"_selectables",[]);u(this,"_latestElement");u(this,"_areaRect",new DOMRect);u(this,"_areaLocation",{y1:0,x2:0,y2:0,x1:0});u(this,"_singleClick",!0);u(this,"_frame");u(this,"_scrollAvailable",!0);u(this,"_scrollingActive",!1);u(this,"_scrollSpeed",{x:0,y:0});u(this,"_scrollDelta",{x:0,y:0});u(this,"disable",this._bindStartEvents.bind(this,!1));u(this,"enable",this._bindStartEvents);this._options=R({selectionAreaClass:"selection-area",selectionContainerClass:void 0,selectables:[],document:window.document,behaviour:{overlap:"invert",intersect:"touch",startThreshold:{x:10,y:10},scrolling:{speedDivider:10,manualSpeed:750,startScrollMargins:{x:0,y:0}}},features:{range:!0,touch:!0,singleTap:{allow:!0,intersect:"native"}},startAreas:["html"],boundaries:["html"],container:"body"},e);for(const i of Object.getOwnPropertyNames(Object.getPrototypeOf(this)))typeof this[i]=="function"&&(this[i]=this[i].bind(this));const{document:t,selectionAreaClass:s,selectionContainerClass:o}=this._options;this._area=t.createElement("div"),this._clippingElement=t.createElement("div"),this._clippingElement.appendChild(this._area),this._area.classList.add(s),o&&this._clippingElement.classList.add(o),v(this._area,{willChange:"top, left, bottom, right, width, height",top:0,left:0,position:"fixed"}),v(this._clippingElement,{overflow:"hidden",position:"fixed",transform:"translate3d(0, 0, 0)",pointerEvents:"none",zIndex:"1"}),this._frame=F(i=>{this._recalculateSelectionAreaRect(),this._updateElementSelection(),this._emitEvent("move",i),this._redrawSelectionArea()}),this.enable()}_bindStartEvents(e=!0){const{document:t,features:s}=this._options,o=e?A:b;o(t,"mousedown",this._onTapStart),s.touch&&o(t,"touchstart",this._onTapStart,{passive:!1})}_onTapStart(e,t=!1){const{x:s,y:o,target:i}=w(e),{_options:l}=this,{document:c}=this._options,d=i.getBoundingClientRect(),_=T(l.startAreas,l.document),m=T(l.boundaries,l.document);this._targetElement=m.find(y=>M(y.getBoundingClientRect(),d));const f=e.composedPath();if(!this._targetElement||!_.find(y=>f.includes(y))||!m.find(y=>f.includes(y))||!t&&this._emitEvent("beforestart",e)===!1)return;this._areaLocation={x1:s,y1:o,x2:0,y2:0};const a=c.scrollingElement||c.body;this._scrollDelta={x:a.scrollLeft,y:a.scrollTop},this._singleClick=!0,this.clearSelection(!1,!0),A(c,["touchmove","mousemove"],this._delayedTapMove,{passive:!1}),A(c,["mouseup","touchcancel","touchend"],this._onTapStop),A(c,"scroll",this._onScroll)}_onSingleTap(e){const{singleTap:{intersect:t},range:s}=this._options.features,o=w(e);let i;if(t==="native")i=o.target;else if(t==="touch"){this.resolveSelectables();const{x:c,y:d}=o;i=this._selectables.find(_=>{const{right:m,left:f,top:a,bottom:y}=_.getBoundingClientRect();return cf&&da})}if(!i)return;for(this.resolveSelectables();!this._selectables.includes(i);){if(!i.parentElement)return;i=i.parentElement}const{stored:l}=this._selection;if(this._emitEvent("start",e),e.shiftKey&&l.length&&s){const c=this._latestElement??l[0],[d,_]=c.compareDocumentPosition(i)&4?[i,c]:[c,i],m=[...this._selectables.filter(f=>f.compareDocumentPosition(d)&4&&f.compareDocumentPosition(_)&2),d,_];this.select(m)}else l.includes(i)&&(l.length===1||e.ctrlKey||l.every(c=>this._selection.stored.includes(c)))?this.deselect(i):(this._latestElement=i,this.select(i));this._emitEvent("stop",e)}_delayedTapMove(e){const{container:t,document:s,behaviour:{startThreshold:o}}=this._options,{x1:i,y1:l}=this._areaLocation,{x:c,y:d}=w(e),_=typeof o;if(_==="number"&&S(c+d-(i+l))>=o||_==="object"&&S(c-i)>=o.x||S(d-l)>=o.y){if(b(s,["mousemove","touchmove"],this._delayedTapMove,{passive:!1}),this._emitEvent("beforedrag",e)===!1){b(s,["mouseup","touchcancel","touchend"],this._onTapStop);return}A(s,["mousemove","touchmove"],this._onTapMove,{passive:!1}),v(this._area,"display","block"),T(t,s)[0].appendChild(this._clippingElement),this.resolveSelectables(),this._singleClick=!1,this._targetRect=this._targetElement.getBoundingClientRect(),this._scrollAvailable=this._targetElement.scrollHeight!==this._targetElement.clientHeight||this._targetElement.scrollWidth!==this._targetElement.clientWidth,this._scrollAvailable&&(A(s,"wheel",this._manualScroll,{passive:!1}),this._selectables=this._selectables.filter(m=>this._targetElement.contains(m))),this._setupSelectionArea(),this._emitEvent("start",e),this._onTapMove(e)}this._handleMoveEvent(e)}_setupSelectionArea(){const{_clippingElement:e,_targetElement:t,_area:s}=this,o=this._targetRect=t.getBoundingClientRect();this._scrollAvailable?(v(e,{top:o.top,left:o.left,width:o.width,height:o.height}),v(s,{marginTop:-o.top,marginLeft:-o.left})):(v(e,{top:0,left:0,width:"100%",height:"100%"}),v(s,{marginTop:0,marginLeft:0}))}_onTapMove(e){const{x:t,y:s}=w(e),{_scrollSpeed:o,_areaLocation:i,_options:l,_frame:c}=this,{speedDivider:d}=l.behaviour.scrolling,_=this._targetElement;if(i.x2=t,i.y2=s,this._scrollAvailable&&!this._scrollingActive&&(o.y||o.x)){this._scrollingActive=!0;const m=()=>{if(!o.x&&!o.y){this._scrollingActive=!1;return}const{scrollTop:f,scrollLeft:a}=_;o.y&&(_.scrollTop+=j(o.y/d),i.y1-=_.scrollTop-f),o.x&&(_.scrollLeft+=j(o.x/d),i.x1-=_.scrollLeft-a),c.next(e),requestAnimationFrame(m)};requestAnimationFrame(m)}else c.next(e);this._handleMoveEvent(e)}_handleMoveEvent(e){const{features:t}=this._options;(t.touch&&H()||this._scrollAvailable&&q())&&e.preventDefault()}_onScroll(){const{_scrollDelta:e,_options:{document:t}}=this,{scrollTop:s,scrollLeft:o}=t.scrollingElement||t.body;this._areaLocation.x1+=e.x-o,this._areaLocation.y1+=e.y-s,e.x=o,e.y=s,this._setupSelectionArea(),this._frame.next(null)}_manualScroll(e){const{manualSpeed:t}=this._options.behaviour.scrolling,s=e.deltaY?e.deltaY>0?1:-1:0,o=e.deltaX?e.deltaX>0?1:-1:0;this._scrollSpeed.y+=s*t,this._scrollSpeed.x+=o*t,this._onTapMove(e),e.preventDefault()}_recalculateSelectionAreaRect(){const{_scrollSpeed:e,_areaLocation:t,_areaRect:s,_targetElement:o,_options:i}=this,{scrollTop:l,scrollHeight:c,clientHeight:d,scrollLeft:_,scrollWidth:m,clientWidth:f}=o,a=this._targetRect,{x1:y,y1:L}=t;let{x2:p,y2:h}=t;const{behaviour:{scrolling:{startScrollMargins:x}}}=i;pa.right-x.x?(e.x=m-_-f?S(a.left+a.width-p-x.x):0,p=p>a.right?a.right:p):e.x=0,ha.bottom-x.y?(e.y=c-l-d?S(a.top+a.height-h-x.y):0,h=h>a.bottom?a.bottom:h):e.y=0;const O=D(y,p),P=D(L,h),W=k(y,p),X=k(L,h);s.x=O,s.y=P,s.width=W-O,s.height=X-P}_redrawSelectionArea(){const{x:e,y:t,width:s,height:o}=this._areaRect,{style:i}=this._area;i.left=`${e}px`,i.top=`${t}px`,i.width=`${s}px`,i.height=`${o}px`}_onTapStop(e,t){var l;const{document:s,features:o}=this._options,{_singleClick:i}=this;b(s,["mousemove","touchmove"],this._delayedTapMove),b(s,["touchmove","mousemove"],this._onTapMove),b(s,["mouseup","touchcancel","touchend"],this._onTapStop),b(s,"scroll",this._onScroll),this._keepSelection(),e&&i&&o.singleTap.allow?this._onSingleTap(e):!i&&!t&&(this._updateElementSelection(),this._emitEvent("stop",e)),this._scrollSpeed.x=0,this._scrollSpeed.y=0,this._scrollAvailable&&b(s,"wheel",this._manualScroll,{passive:!0}),this._clippingElement.remove(),(l=this._frame)==null||l.cancel(),v(this._area,"display","none")}_updateElementSelection(){const{_selectables:e,_options:t,_selection:s,_areaRect:o}=this,{stored:i,selected:l,touched:c}=s,{intersect:d,overlap:_}=t.behaviour,m=_==="invert",f=[],a=[],y=[];for(let p=0;p!l.includes(p)));const L=_==="keep";for(let p=0;p!l.includes(d));switch(e.behaviour.overlap){case"drop":{t.stored=[...c,...l.filter(d=>!i.includes(d))];break}case"invert":{t.stored=[...c,...l.filter(d=>!o.removed.includes(d))];break}case"keep":{t.stored=[...l,...s.filter(d=>!l.includes(d))];break}}}resolveSelectables(){this._selectables=T(this._options.selectables,this._options.document)}clearSelection(e=!0,t=!1){const{selected:s,stored:o,changed:i}=this._selection;i.added=[],i.removed.push(...s,...e?o:[]),t||(this._emitEvent("move",null),this._emitEvent("stop",null)),this._latestElement=void 0,this._selection={stored:e?[]:o,selected:[],touched:[],changed:{added:[],removed:[]}}}getSelection(){return this._selection.stored}getSelectionArea(){return this._area}cancel(e=!1){this._onTapStop(null,!e)}destroy(){this.cancel(),this.disable(),this._clippingElement.remove(),super.unbindAllListeners()}select(e,t=!1){const{changed:s,selected:o,stored:i}=this._selection,l=T(e,this._options.document).filter(c=>!o.includes(c)&&!i.includes(c));return i.push(...l),o.push(...l),s.added.push(...l),s.removed=[],this._latestElement=void 0,t||(this._emitEvent("move",null),this._emitEvent("stop",null)),l}deselect(e,t=!1){const{selected:s,stored:o,changed:i}=this._selection,l=T(e,this._options.document).filter(c=>s.includes(c)||o.includes(c));l.length&&(this._selection.stored=o.filter(c=>!l.includes(c)),this._selection.selected=s.filter(c=>!l.includes(c)),this._selection.changed.added=[],this._selection.changed.removed.push(...l.filter(c=>!i.removed.includes(c))),this._latestElement=void 0,t||(this._emitEvent("move",null),this._emitEvent("stop",null)))}}return u(B,"version","3.2.4"),B}); +/*! @viselect/vanilla v3.9.0 MIT | https://github.com/Simonwep/selection/tree/master/packages/vanilla */ +(function(A,E){typeof exports=="object"&&typeof module<"u"?module.exports=E():typeof define=="function"&&define.amd?define(E):(A=typeof globalThis<"u"?globalThis:A||self,A.SelectionArea=E())})(this,function(){"use strict";class A{constructor(){this._listeners=new Map,this.on=this.addEventListener,this.off=this.removeEventListener,this.emit=this.dispatchEvent}addEventListener(e,t){const s=this._listeners.get(e)??new Set;return this._listeners.set(e,s),s.add(t),this}removeEventListener(e,t){var s;return(s=this._listeners.get(e))==null||s.delete(t),this}dispatchEvent(e,...t){let s=!0;for(const i of this._listeners.get(e)??[])s=i(...t)!==!1&&s;return s}unbindAllListeners(){this._listeners.clear()}}const E=(l,e="px")=>typeof l=="number"?l+e:l,v=({style:l},e,t)=>{if(typeof e=="object")for(const[s,i]of Object.entries(e))i!==void 0&&(l[s]=E(i));else t!==void 0&&(l[e]=E(t))},k=(l=0,e=0,t=0,s=0)=>{const i={x:l,y:e,width:t,height:s,top:e,left:l,right:l+t,bottom:e+s};return{...i,toJSON:()=>JSON.stringify(i)}},K=l=>{let e,t=-1,s=!1;return{next:(...i)=>{e=i,s||(s=!0,t=requestAnimationFrame(()=>{l(...e),s=!1}))},cancel:()=>{cancelAnimationFrame(t),s=!1}}},C=(l,e,t="touch")=>{switch(t){case"center":{const s=e.left+e.width/2,i=e.top+e.height/2;return s>=l.left&&s<=l.right&&i>=l.top&&i<=l.bottom}case"cover":return e.left>=l.left&&e.top>=l.top&&e.right<=l.right&&e.bottom<=l.bottom;case"touch":return l.right>=e.left&&l.left<=e.right&&l.bottom>=e.top&&l.top<=e.bottom}},X=()=>matchMedia("(hover: none), (pointer: coarse)").matches,Y=()=>"safari"in window,w=l=>Array.isArray(l)?l:[l],B=l=>(e,t,s,i={})=>{(e instanceof HTMLCollection||e instanceof NodeList)&&(e=Array.from(e)),t=w(t),e=w(e);for(const o of e)if(o)for(const n of t)o[l](n,s,{capture:!1,...i})},y=B("addEventListener"),m=B("removeEventListener"),T=l=>{var i;const{clientX:e,clientY:t,target:s}=((i=l.touches)==null?void 0:i[0])??l;return{x:e,y:t,target:s}},x=(l,e=document)=>w(l).map(t=>typeof t=="string"?Array.from(e.querySelectorAll(t)):t instanceof Element?t:null).flat().filter(Boolean),H=(l,e)=>e.some(t=>typeof t=="number"?l.button===t:typeof t=="object"?t.button!==l.button?!1:t.modifiers.every(s=>{switch(s){case"alt":return l.altKey;case"ctrl":return l.ctrlKey||l.metaKey;case"shift":return l.shiftKey}}):!1),{abs:b,max:R,min:D,ceil:P}=Math,O=(l=[])=>({stored:l,selected:[],touched:[],changed:{added:[],removed:[]}}),M=class M extends A{constructor(e){var o,n,r,a,u;super(),this._selection=O(),this._targetBoundaryScrolled=!0,this._selectables=[],this._areaLocation={y1:0,x2:0,y2:0,x1:0},this._areaRect=k(),this._singleClick=!0,this._scrollAvailable=!0,this._scrollingActive=!1,this._scrollSpeed={x:0,y:0},this._scrollDelta={x:0,y:0},this._lastMousePosition={x:0,y:0},this.enable=this._toggleStartEvents,this.disable=this._toggleStartEvents.bind(this,!1),this._options={selectionAreaClass:"selection-area",selectionContainerClass:void 0,selectables:[],document:window.document,startAreas:["html"],boundaries:["html"],container:"body",...e,behaviour:{overlap:"invert",intersect:"touch",triggers:[0],...e.behaviour,startThreshold:(o=e.behaviour)!=null&&o.startThreshold?typeof e.behaviour.startThreshold=="number"?e.behaviour.startThreshold:{x:10,y:10,...e.behaviour.startThreshold}:{x:10,y:10},scrolling:{speedDivider:10,manualSpeed:750,...(n=e.behaviour)==null?void 0:n.scrolling,startScrollMargins:{x:0,y:0,...(a=(r=e.behaviour)==null?void 0:r.scrolling)==null?void 0:a.startScrollMargins}}},features:{range:!0,touch:!0,deselectOnBlur:!1,...e.features,singleTap:{allow:!0,intersect:"native",...(u=e.features)==null?void 0:u.singleTap}}};for(const _ of Object.getOwnPropertyNames(Object.getPrototypeOf(this)))typeof this[_]=="function"&&(this[_]=this[_].bind(this));const{document:t,selectionAreaClass:s,selectionContainerClass:i}=this._options;this._area=t.createElement("div"),this._clippingElement=t.createElement("div"),this._clippingElement.appendChild(this._area),this._area.classList.add(s),i&&this._clippingElement.classList.add(i),v(this._area,{willChange:"top, left, bottom, right, width, height",top:0,left:0,position:"fixed"}),v(this._clippingElement,{overflow:"hidden",position:"fixed",transform:"translate3d(0, 0, 0)",pointerEvents:"none",zIndex:"1"}),this._frame=K(_=>{this._recalculateSelectionAreaRect(),this._updateElementSelection(),this._emitEvent("move",_),this._redrawSelectionArea()}),this.enable()}_toggleStartEvents(e=!0){const{document:t,features:s}=this._options,i=e?y:m;i(t,"mousedown",this._onTapStart),s.touch&&i(t,"touchstart",this._onTapStart,{passive:!1})}_onTapStart(e,t=!1){const{x:s,y:i,target:o}=T(e),{document:n,startAreas:r,boundaries:a,features:u,behaviour:_}=this._options,c=o.getBoundingClientRect();if(e instanceof MouseEvent&&!H(e,_.triggers))return;const p=x(r,n),g=x(a,n);this._targetElement=g.find(S=>C(S.getBoundingClientRect(),c));const f=e.composedPath(),d=p.find(S=>f.includes(S));if(this._targetBoundary=g.find(S=>f.includes(S)),!this._targetElement||!d||!this._targetBoundary||!t&&this._emitEvent("beforestart",e)===!1)return;this._areaLocation={x1:s,y1:i,x2:0,y2:0};const h=n.scrollingElement??n.body;this._scrollDelta={x:h.scrollLeft,y:h.scrollTop},this._singleClick=!0,this.clearSelection(!1,!0),y(n,["touchmove","mousemove"],this._delayedTapMove,{passive:!1}),y(n,["mouseup","touchcancel","touchend"],this._onTapStop),y(n,"scroll",this._onScroll),u.deselectOnBlur&&(this._targetBoundaryScrolled=!1,y(this._targetBoundary,"scroll",this._onStartAreaScroll))}_onSingleTap(e){const{singleTap:{intersect:t},range:s}=this._options.features,i=T(e);let o;if(t==="native")o=i.target;else if(t==="touch"){this.resolveSelectables();const{x:r,y:a}=i;o=this._selectables.find(u=>{const{right:_,left:c,top:p,bottom:g}=u.getBoundingClientRect();return r<_&&r>c&&ap})}if(!o)return;for(this.resolveSelectables();!this._selectables.includes(o);)if(o.parentElement)o=o.parentElement;else{this._targetBoundaryScrolled||this.clearSelection();return}const{stored:n}=this._selection;if(this._emitEvent("start",e),e.shiftKey&&s&&this._latestElement){const r=this._latestElement,[a,u]=r.compareDocumentPosition(o)&4?[o,r]:[r,o],_=[...this._selectables.filter(c=>c.compareDocumentPosition(a)&4&&c.compareDocumentPosition(u)&2),a,u];this.select(_),this._latestElement=r}else n.includes(o)&&(n.length===1||e.ctrlKey||n.every(r=>this._selection.stored.includes(r)))?this.deselect(o):(this.select(o),this._latestElement=o)}_delayedTapMove(e){const{container:t,document:s,behaviour:{startThreshold:i}}=this._options,{x1:o,y1:n}=this._areaLocation,{x:r,y:a}=T(e);if(typeof i=="number"&&b(r+a-(o+n))>=i||typeof i=="object"&&b(r-o)>=i.x||b(a-n)>=i.y){if(m(s,["mousemove","touchmove"],this._delayedTapMove,{passive:!1}),this._emitEvent("beforedrag",e)===!1){m(s,["mouseup","touchcancel","touchend"],this._onTapStop);return}y(s,["mousemove","touchmove"],this._onTapMove,{passive:!1}),v(this._area,"display","block"),x(t,s)[0].appendChild(this._clippingElement),this.resolveSelectables(),this._singleClick=!1,this._targetRect=this._targetElement.getBoundingClientRect(),this._scrollAvailable=this._targetElement.scrollHeight!==this._targetElement.clientHeight||this._targetElement.scrollWidth!==this._targetElement.clientWidth,this._scrollAvailable&&(y(this._targetElement,"wheel",this._wheelScroll,{passive:!1}),y(this._options.document,"keydown",this._keyboardScroll,{passive:!1}),this._selectables=this._selectables.filter(u=>this._targetElement.contains(u))),this._setupSelectionArea(),this._emitEvent("start",e),this._onTapMove(e)}this._handleMoveEvent(e)}_setupSelectionArea(){const{_clippingElement:e,_targetElement:t,_area:s}=this,i=this._targetRect=t.getBoundingClientRect();this._scrollAvailable?(v(e,{top:i.top,left:i.left,width:i.width,height:i.height}),v(s,{marginTop:-i.top,marginLeft:-i.left})):(v(e,{top:0,left:0,width:"100%",height:"100%"}),v(s,{marginTop:0,marginLeft:0}))}_onTapMove(e){const{_scrollSpeed:t,_areaLocation:s,_options:i,_frame:o}=this,{speedDivider:n}=i.behaviour.scrolling,r=this._targetElement,{x:a,y:u}=T(e);if(s.x2=a,s.y2=u,this._lastMousePosition.x=a,this._lastMousePosition.y=u,this._scrollAvailable&&!this._scrollingActive&&(t.y||t.x)){this._scrollingActive=!0;const _=()=>{if(!t.x&&!t.y){this._scrollingActive=!1;return}const{scrollTop:c,scrollLeft:p}=r;t.y&&(r.scrollTop+=P(t.y/n),s.y1-=r.scrollTop-c),t.x&&(r.scrollLeft+=P(t.x/n),s.x1-=r.scrollLeft-p),o.next(e),requestAnimationFrame(_)};requestAnimationFrame(_)}else o.next(e);this._handleMoveEvent(e)}_handleMoveEvent(e){const{features:t}=this._options;(t.touch&&X()||this._scrollAvailable&&Y())&&e.preventDefault()}_onScroll(){const{_scrollDelta:e,_options:{document:t}}=this,{scrollTop:s,scrollLeft:i}=t.scrollingElement??t.body;this._areaLocation.x1+=e.x-i,this._areaLocation.y1+=e.y-s,e.x=i,e.y=s,this._setupSelectionArea(),this._frame.next(null)}_onStartAreaScroll(){this._targetBoundaryScrolled=!0,m(this._targetElement,"scroll",this._onStartAreaScroll)}_wheelScroll(e){const{manualSpeed:t}=this._options.behaviour.scrolling,s=e.deltaY?e.deltaY>0?1:-1:0,i=e.deltaX?e.deltaX>0?1:-1:0;this._scrollSpeed.y+=s*t,this._scrollSpeed.x+=i*t,this._onTapMove(e),e.preventDefault()}_keyboardScroll(e){const{manualSpeed:t}=this._options.behaviour.scrolling,s=e.key==="ArrowLeft"?-1:e.key==="ArrowRight"?1:0,i=e.key==="ArrowUp"?-1:e.key==="ArrowDown"?1:0;this._scrollSpeed.x+=Math.sign(s)*t,this._scrollSpeed.y+=Math.sign(i)*t,e.preventDefault(),this._onTapMove({clientX:this._lastMousePosition.x,clientY:this._lastMousePosition.y,preventDefault:()=>{}})}_recalculateSelectionAreaRect(){const{_scrollSpeed:e,_areaLocation:t,_targetElement:s,_options:i}=this,{scrollTop:o,scrollHeight:n,clientHeight:r,scrollLeft:a,scrollWidth:u,clientWidth:_}=s,c=this._targetRect,{x1:p,y1:g}=t;let{x2:f,y2:d}=t;const{behaviour:{scrolling:{startScrollMargins:h}}}=i;fc.right-h.x?(e.x=u-a-_?b(c.left+c.width-f-h.x):0,f=f>c.right?c.right:f):e.x=0,dc.bottom-h.y?(e.y=n-o-r?b(c.top+c.height-d-h.y):0,d=d>c.bottom?c.bottom:d):e.y=0;const S=D(p,f),j=D(g,d),N=R(p,f),q=R(g,d);this._areaRect=k(S,j,N-S,q-j)}_redrawSelectionArea(){const{x:e,y:t,width:s,height:i}=this._areaRect,{style:o}=this._area;o.left=`${e}px`,o.top=`${t}px`,o.width=`${s}px`,o.height=`${i}px`}_onTapStop(e,t){var n;const{document:s,features:i}=this._options,{_singleClick:o}=this;m(this._targetElement,"scroll",this._onStartAreaScroll),m(s,["mousemove","touchmove"],this._delayedTapMove),m(s,["touchmove","mousemove"],this._onTapMove),m(s,["mouseup","touchcancel","touchend"],this._onTapStop),m(s,"scroll",this._onScroll),this._keepSelection(),e&&o&&i.singleTap.allow?this._onSingleTap(e):!o&&!t&&(this._updateElementSelection(),this._emitEvent("stop",e)),this._scrollSpeed.x=0,this._scrollSpeed.y=0,m(this._targetElement,"wheel",this._wheelScroll,{passive:!0}),m(this._options.document,"keydown",this._keyboardScroll,{passive:!0}),this._clippingElement.remove(),(n=this._frame)==null||n.cancel(),v(this._area,"display","none")}_updateElementSelection(){const{_selectables:e,_options:t,_selection:s,_areaRect:i}=this,{stored:o,selected:n,touched:r}=s,{intersect:a,overlap:u}=t.behaviour,_=u==="invert",c=[],p=[],g=[];for(let d=0;d!n.includes(d)));const f=u==="keep";for(let d=0;d!n.includes(a));switch(e.behaviour.overlap){case"drop":{t.stored=[...r,...n.filter(a=>!o.includes(a))];break}case"invert":{t.stored=[...r,...n.filter(a=>!i.removed.includes(a))];break}case"keep":{t.stored=[...n,...s.filter(a=>!n.includes(a))];break}}}trigger(e,t=!0){this._onTapStart(e,t)}resolveSelectables(){this._selectables=x(this._options.selectables,this._options.document)}clearSelection(e=!0,t=!1){const{selected:s,stored:i,changed:o}=this._selection;o.added=[],o.removed.push(...s,...e?i:[]),t||(this._emitEvent("move",null),this._emitEvent("stop",null)),this._selection=O(e?[]:i)}getSelection(){return this._selection.stored}getSelectionArea(){return this._area}getSelectables(){return this._selectables}setAreaLocation(e){Object.assign(this._areaLocation,e),this._redrawSelectionArea()}getAreaLocation(){return this._areaLocation}cancel(e=!1){this._onTapStop(null,!e)}destroy(){this.cancel(),this.disable(),this._clippingElement.remove(),super.unbindAllListeners()}select(e,t=!1){const{changed:s,selected:i,stored:o}=this._selection,n=x(e,this._options.document).filter(r=>!i.includes(r)&&!o.includes(r));return o.push(...n),i.push(...n),s.added.push(...n),s.removed=[],this._latestElement=void 0,t||(this._emitEvent("move",null),this._emitEvent("stop",null)),n}deselect(e,t=!1){const{selected:s,stored:i,changed:o}=this._selection,n=x(e,this._options.document).filter(r=>s.includes(r)||i.includes(r));this._selection.stored=i.filter(r=>!n.includes(r)),this._selection.selected=s.filter(r=>!n.includes(r)),this._selection.changed.added=[],this._selection.changed.removed.push(...n.filter(r=>!o.removed.includes(r))),this._latestElement=void 0,t||(this._emitEvent("move",null),this._emitEvent("stop",null))}};M.version="3.9.0";let L=M;return L}); //# sourceMappingURL=viselect.umd.js.map \ No newline at end of file