Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dragdoll

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dragdoll - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

src/utils/create-snap-modifier.ts

183

dist/dragdoll.d.ts

@@ -1,4 +0,5 @@

import { Emitter, Events, EventListenerId, EventName } from 'eventti';
import * as eventti from 'eventti';
import { EventListenerId, Emitter, Events } from 'eventti';
import * as tikki from 'tikki';
import { Ticker, FrameCallback } from 'tikki';
import { Phase, AutoTicker, FrameCallback } from 'tikki';

@@ -44,4 +45,4 @@ declare const SensorEventType: {

events: E;
on<K extends keyof E>(eventName: K, listener: (eventData: E[K]) => void): void;
off<K extends keyof E>(eventName: K, listener: (eventData: E[K]) => void): void;
on<T extends keyof E>(type: T, listener: (eventData: E[T]) => void, listenerId?: EventListenerId): EventListenerId;
off<T extends keyof E>(type: T, listenerId: EventListenerId): void;
cancel(): void;

@@ -68,4 +69,4 @@ destroy(): void;

protected _cancel(data: E['cancel']): void;
on<K extends keyof E>(eventName: K, listener: (e: E[K]) => void, listenerId?: EventListenerId): EventListenerId;
off<K extends keyof E>(eventName: K, listener: ((e: E[K]) => void) | EventListenerId): void;
on<T extends keyof E>(type: T, listener: (e: E[T]) => void, listenerId?: EventListenerId): EventListenerId;
off<T extends keyof E>(type: T, listenerId: EventListenerId): void;
cancel(): void;

@@ -75,2 +76,25 @@ destroy(): void;

type ListenerOptions = {
capture?: boolean;
passive?: boolean;
};
type PointerType = 'mouse' | 'pen' | 'touch';
type Point = {
x: number;
y: number;
};
type Dimensions = {
width: number;
height: number;
};
interface Rect extends Dimensions {
left: number;
top: number;
}
interface RectExtended extends Rect {
right: number;
bottom: number;
}
type CSSProperties = Partial<Omit<CSSStyleDeclaration, 'getPropertyPriority' | 'getPropertyValue' | 'item' | 'removeProperty' | 'setProperty' | 'length' | 'parentRule'>>;
interface BaseMotionSensorTickEvent {

@@ -91,6 +115,3 @@ type: 'tick';

readonly drag: BaseMotionSensorDragData | null;
protected _direction: {
x: number;
y: number;
};
protected _direction: Point;
protected _speed: number;

@@ -105,21 +126,2 @@ constructor();

type ListenerOptions = {
capture?: boolean;
passive?: boolean;
};
type PointerType = 'mouse' | 'pen' | 'touch';
type Dimensions = {
width: number;
height: number;
};
interface Rect extends Dimensions {
left: number;
top: number;
}
interface RectExtended extends Rect {
right: number;
bottom: number;
}
type CSSProperties = Partial<Omit<CSSStyleDeclaration, 'getPropertyPriority' | 'getPropertyValue' | 'item' | 'removeProperty' | 'setProperty' | 'length' | 'parentRule'>>;
declare const SOURCE_EVENTS: {

@@ -211,19 +213,10 @@ readonly pointer: {

updateSettings(options: Partial<PointerSensorSettings>): void;
on<K extends keyof E>(eventName: K, listener: (e: E[K]) => void, listenerId?: EventListenerId): EventListenerId;
off<K extends keyof E>(eventName: K, listener: ((e: E[K]) => void) | EventListenerId): void;
on<T extends keyof E>(type: T, listener: (e: E[T]) => void, listenerId?: EventListenerId): EventListenerId;
off<T extends keyof E>(type: T, listenerId: EventListenerId): void;
destroy(): void;
}
type KeyboardSensorPredicate = (e: KeyboardEvent, sensor: KeyboardSensor, moveDistance: {
x: number;
y: number;
}) => {
x: number;
y: number;
} | null | undefined;
type KeyboardSensorPredicate = (e: KeyboardEvent, sensor: KeyboardSensor, moveDistance: Point) => Point | null | undefined;
interface KeyboardSensorSettings {
moveDistance: number | {
x: number;
y: number;
};
moveDistance: number | Point;
startPredicate: KeyboardSensorPredicate;

@@ -257,6 +250,3 @@ movePredicate: KeyboardSensorPredicate;

events: E;
protected _moveDistance: {
x: number;
y: number;
};
protected _moveDistance: Point;
protected _startPredicate: KeyboardSensorPredicate;

@@ -273,6 +263,3 @@ protected _movePredicate: KeyboardSensorPredicate;

interface KeyboardMotionSensorSettings<E extends KeyboardMotionSensorEvents = KeyboardMotionSensorEvents> {
startPredicate: (e: KeyboardEvent, sensor: KeyboardMotionSensor<E>) => {
x: number;
y: number;
} | null | undefined;
startPredicate: (e: KeyboardEvent, sensor: KeyboardMotionSensor<E>) => Point | null | undefined;
computeSpeed: (sensor: KeyboardMotionSensor<E>) => number;

@@ -313,3 +300,3 @@ startKeys: string[];

declare class DraggableDragItem {
declare class DraggableDragItem<S extends Sensor[] = Sensor[], E extends S[number]['events'] = S[number]['events']> {
data: {

@@ -326,25 +313,23 @@ [key: string]: any;

readonly unfrozenProps: CSSProperties | null;
readonly x: number;
readonly y: number;
readonly pX: number;
readonly pY: number;
readonly _updateDiffX: number;
readonly _updateDiffY: number;
readonly _moveDiffX: number;
readonly _moveDiffY: number;
readonly _containerDiffX: number;
readonly _containerDiffY: number;
constructor(element: HTMLElement | SVGSVGElement, elementContainer: HTMLElement, elementOffsetContainer: HTMLElement | SVGSVGElement | Window | Document, dragContainer: HTMLElement, dragOffsetContainer: HTMLElement | SVGSVGElement | Window | Document);
readonly clientRect: Rect;
readonly position: Point;
readonly _updateDiff: Point;
readonly _moveDiff: Point;
readonly _containerDiff: Point;
constructor(element: HTMLElement | SVGSVGElement, draggable: Draggable<S, E>);
updateSize(dimensions?: {
width: number;
height: number;
}): void;
}
declare class DraggableDrag<S extends Sensor[], E extends S[number]['events']> {
readonly sensor: S[number] | null;
readonly isStarted: boolean;
readonly sensor: S[number];
readonly isEnded: boolean;
readonly startEvent: E['start'] | E['move'] | null;
readonly nextMoveEvent: E['move'] | null;
readonly prevMoveEvent: E['move'] | null;
readonly event: E['start'] | E['move'];
readonly prevEvent: E['start'] | E['move'];
readonly startEvent: E['start'] | E['move'];
readonly endEvent: E['end'] | E['cancel'] | E['destroy'] | null;
readonly items: DraggableDragItem[];
constructor();
constructor(sensor: S[number], startEvent: E['start'] | E['move']);
}

@@ -377,3 +362,3 @@

sensor: S[number];
item: DraggableDragItem;
item: DraggableDragItem<S, E>;
style: CSSStyleDeclaration;

@@ -384,8 +369,5 @@ }) => CSSProperties | (keyof CSSProperties)[] | null;

sensor: S[number];
item: DraggableDragItem;
item: DraggableDragItem<S, E>;
style: CSSStyleDeclaration;
}) => {
x: number;
y: number;
};
}) => Point;
setPosition: (data: {

@@ -395,3 +377,3 @@ draggable: Draggable<S, E>;

phase: 'start' | 'move' | 'end';
item: DraggableDragItem;
item: DraggableDragItem<S, E>;
x: number;

@@ -403,10 +385,7 @@ y: number;

sensor: S[number];
item: DraggableDragItem;
event: E['move'];
item: DraggableDragItem<S, E>;
event: E['start'] | E['move'];
prevEvent: E['start'] | E['move'];
startEvent: E['start'] | E['move'];
}) => {
x: number;
y: number;
};
}) => Point;
}

@@ -456,4 +435,4 @@ interface DraggablePlugin {

protected _applyPositionUpdate(): void;
on<K extends keyof DraggableEventCallbacks<E>>(eventName: K, listener: DraggableEventCallbacks<E>[K], listenerId?: EventListenerId): EventListenerId;
off<K extends keyof DraggableEventCallbacks<E>>(eventName: K, listener: DraggableEventCallbacks<E>[K] | EventListenerId): void;
on<T extends keyof DraggableEventCallbacks<E>>(type: T, listener: DraggableEventCallbacks<E>[T], listenerId?: EventListenerId): EventListenerId;
off<T extends keyof DraggableEventCallbacks<E>>(type: T, listenerId: EventListenerId): void;
resolveStartPredicate(sensor: S[number], e?: E['start'] | E['move']): void;

@@ -528,6 +507,3 @@ rejectStartPredicate(sensor: S[number]): void;

readonly clientRect: Rect;
readonly position: {
x: number;
y: number;
};
readonly position: Point;
readonly inertAreaSize: number;

@@ -641,4 +617,4 @@ readonly smoothStop: boolean;

protected _applyActions(): void;
on<T extends keyof AutoScrollEventCallbacks>(eventName: T, listener: AutoScrollEventCallbacks[T]): EventListenerId;
off<T extends keyof AutoScrollEventCallbacks>(eventName: T, listener: AutoScrollEventCallbacks[T] | EventListenerId): void;
on<T extends keyof AutoScrollEventCallbacks>(type: T, listener: AutoScrollEventCallbacks[T], listenerId?: EventListenerId): EventListenerId;
off<T extends keyof AutoScrollEventCallbacks>(type: T, listenerId: EventListenerId): void;
addItem(item: AutoScrollItem): void;

@@ -662,6 +638,3 @@ removeItem(item: AutoScrollItem): void;

get targets(): AutoScrollItemTarget[];
get position(): {
x: number;
y: number;
};
get position(): Point;
get clientRect(): Rect;

@@ -681,6 +654,3 @@ get inertAreaSize(): number;

smoothStop: boolean;
getPosition: ((draggable: Draggable<S, E>) => {
x: number;
y: number;
}) | null;
getPosition: ((draggable: Draggable<S, E>) => Point) | null;
getClientRect: ((draggable: Draggable<S, E>) => {

@@ -713,6 +683,6 @@ left: number;

declare let tickerReadPhase: EventName;
declare let tickerWritePhase: EventName;
declare let ticker: Ticker<EventName, tikki.DefaultFrameCallback>;
declare function setTicker(newTicker: Ticker<EventName, FrameCallback>, readPhase: EventName, writePhase: EventName): void;
declare let tickerReadPhase: Phase;
declare let tickerWritePhase: Phase;
declare let ticker: AutoTicker<eventti.EventName, tikki.AutoTickerDefaultFrameCallback>;
declare function setTicker(newTicker: AutoTicker<Phase, FrameCallback>, readPhase: Phase, writePhase: Phase): void;

@@ -724,2 +694,11 @@ declare function createPointerSensorStartPredicate<S extends (Sensor | PointerSensor)[] = (Sensor | PointerSensor)[], D extends Draggable<S> = Draggable<S>>(options?: {

export { AUTO_SCROLL_AXIS, AUTO_SCROLL_AXIS_DIRECTION, AUTO_SCROLL_DIRECTION, AutoScroll, type AutoScrollEventCallbacks, type AutoScrollItem, type AutoScrollItemEffectCallback, type AutoScrollItemEventCallback, type AutoScrollItemSpeedCallback, type AutoScrollItemTarget, type AutoScrollOptions, type AutoScrollSettings, BaseMotionSensor, type BaseMotionSensorDragData, type BaseMotionSensorEvents, type BaseMotionSensorTickEvent, BaseSensor, type BaseSensorDragData, Draggable, DraggableAutoScroll, type DraggableAutoScrollOptions, type DraggableAutoScrollSettings, type DraggableEventCallbacks, type DraggablePlugin, type DraggablePluginMap, type DraggableSettings, KeyboardMotionSensor, type KeyboardMotionSensorEvents, type KeyboardMotionSensorSettings, KeyboardSensor, type KeyboardSensorCancelEvent, type KeyboardSensorDestroyEvent, type KeyboardSensorEndEvent, type KeyboardSensorEvents, type KeyboardSensorMoveEvent, type KeyboardSensorPredicate, type KeyboardSensorSettings, type KeyboardSensorStartEvent, PointerSensor, type PointerSensorCancelEvent, type PointerSensorDestroyEvent, type PointerSensorDragData, type PointerSensorEndEvent, type PointerSensorEvents, type PointerSensorMoveEvent, type PointerSensorSettings, type PointerSensorStartEvent, type Sensor, type SensorCancelEvent, type SensorDestroyEvent, type SensorEndEvent, SensorEventType, type SensorEvents, type SensorMoveEvent, type SensorStartEvent, autoScroll, autoScrollPlugin, autoScrollSmoothSpeed, createPointerSensorStartPredicate, setTicker, ticker, tickerReadPhase, tickerWritePhase };
declare function createSnapModifier(gridWidth: number, gridHeight: number): ({ startEvent, event, item, }: {
startEvent: SensorStartEvent | SensorMoveEvent;
event: SensorMoveEvent;
item: DraggableDragItem;
}) => {
x: number;
y: number;
};
export { AUTO_SCROLL_AXIS, AUTO_SCROLL_AXIS_DIRECTION, AUTO_SCROLL_DIRECTION, AutoScroll, type AutoScrollEventCallbacks, type AutoScrollItem, type AutoScrollItemEffectCallback, type AutoScrollItemEventCallback, type AutoScrollItemSpeedCallback, type AutoScrollItemTarget, type AutoScrollOptions, type AutoScrollSettings, BaseMotionSensor, type BaseMotionSensorDragData, type BaseMotionSensorEvents, type BaseMotionSensorTickEvent, BaseSensor, type BaseSensorDragData, Draggable, DraggableAutoScroll, type DraggableAutoScrollOptions, type DraggableAutoScrollSettings, type DraggableEventCallbacks, type DraggablePlugin, type DraggablePluginMap, type DraggableSettings, KeyboardMotionSensor, type KeyboardMotionSensorEvents, type KeyboardMotionSensorSettings, KeyboardSensor, type KeyboardSensorCancelEvent, type KeyboardSensorDestroyEvent, type KeyboardSensorEndEvent, type KeyboardSensorEvents, type KeyboardSensorMoveEvent, type KeyboardSensorPredicate, type KeyboardSensorSettings, type KeyboardSensorStartEvent, PointerSensor, type PointerSensorCancelEvent, type PointerSensorDestroyEvent, type PointerSensorDragData, type PointerSensorEndEvent, type PointerSensorEvents, type PointerSensorMoveEvent, type PointerSensorSettings, type PointerSensorStartEvent, type Sensor, type SensorCancelEvent, type SensorDestroyEvent, type SensorEndEvent, SensorEventType, type SensorEvents, type SensorMoveEvent, type SensorStartEvent, autoScroll, autoScrollPlugin, autoScrollSmoothSpeed, createPointerSensorStartPredicate, createSnapModifier, setTicker, ticker, tickerReadPhase, tickerWritePhase };

@@ -1,1 +0,1 @@

var _={start:"start",move:"move",cancel:"cancel",end:"end",destroy:"destroy"};import{Emitter as tt}from"eventti";var W=class{constructor(){this.drag=null,this.isDestroyed=!1,this._emitter=new tt}_createDragData(e){return{x:e.x,y:e.y}}_updateDragData(e){this.drag&&(this.drag.x=e.x,this.drag.y=e.y)}_resetDragData(){this.drag=null}_start(e){this.isDestroyed||this.drag||(this.drag=this._createDragData(e),this._emitter.emit(_.start,e))}_move(e){this.drag&&(this._updateDragData(e),this._emitter.emit(_.move,e))}_end(e){this.drag&&(this._updateDragData(e),this._emitter.emit(_.end,e),this._resetDragData())}_cancel(e){this.drag&&(this._updateDragData(e),this._emitter.emit(_.cancel,e),this._resetDragData())}on(e,t,n){return this._emitter.on(e,t,n)}off(e,t){this._emitter.off(e,t)}cancel(){this.drag&&(this._emitter.emit(_.cancel,{type:_.cancel,x:this.drag.x,y:this.drag.y}),this._resetDragData())}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.cancel(),this._emitter.emit(_.destroy,{type:_.destroy}),this._emitter.off())}};import{Ticker as nt}from"tikki";var v=Symbol(),D=Symbol(),u=new nt({phases:[v,D]});function wt(i,e,t){v=e,D=t,u=i}var $=class extends W{constructor(){super();this.drag=null,this._direction={x:0,y:0},this._speed=0,this._tick=this._tick.bind(this)}_createDragData(t){return{...super._createDragData(t),time:0,deltaTime:0}}_start(t){this.isDestroyed||this.drag||(super._start(t),u.on(v,this._tick))}_end(t){this.drag&&(u.off(v,this._tick),super._end(t))}_cancel(t){this.drag&&(u.off(v,this._tick),super._cancel(t))}_tick(t){if(this.drag)if(t&&this.drag.time){this.drag.deltaTime=t-this.drag.time,this.drag.time=t;let n={type:"tick",time:this.drag.time,deltaTime:this.drag.deltaTime};if(this._emitter.emit("tick",n),!this.drag)return;let r=this._speed*(this.drag.deltaTime/1e3),s=this._direction.x*r,o=this._direction.y*r;(s||o)&&this._move({type:"move",x:this.drag.x+s,y:this.drag.y+o})}else this.drag.time=t,this.drag.deltaTime=0}};import{Emitter as rt}from"eventti";function de(i,e){if("pointerId"in i)return i.pointerId===e?i:null;if("changedTouches"in i){let t=0;for(;t<i.changedTouches.length;t++)if(i.changedTouches[t].identifier===e)return i.changedTouches[t];return null}return i}function Re(i){return"pointerType"in i?i.pointerType:"touches"in i?"touch":"mouse"}function Me(i){return"pointerId"in i?i.pointerId:"changedTouches"in i?i.changedTouches[0]?i.changedTouches[0].identifier:null:-1}var he=typeof window<"u"&&typeof window.document<"u",J=(()=>{let i=!1;try{let e=Object.defineProperty({},"passive",{get:function(){i=!0}});window.addEventListener("testPassive",null,e),window.removeEventListener("testPassive",null,e)}catch{}return i})(),Oe=he&&"ontouchstart"in window,We=he&&!!window.PointerEvent,Ot=!!(he&&navigator.vendor&&navigator.vendor.indexOf("Apple")>-1&&navigator.userAgent&&navigator.userAgent.indexOf("CriOS")==-1&&navigator.userAgent.indexOf("FxiOS")==-1);function me(i={}){let{capture:e=!0,passive:t=!0}=i;return J?{capture:e,passive:t}:{capture:e}}function ue(i){return i==="auto"||i===void 0?We?"pointer":Oe?"touch":"mouse":i}var it={start:"pointerdown",move:"pointermove",cancel:"pointercancel",end:"pointerup"},ot={start:"touchstart",move:"touchmove",cancel:"touchcancel",end:"touchend"},st={start:"mousedown",move:"mousemove",cancel:"",end:"mouseup"},X={pointer:it,touch:ot,mouse:st},Y=class{constructor(e,t={}){let{listenerOptions:n={},sourceEvents:r="auto",startPredicate:s=o=>!("button"in o&&o.button>0)}=t;this.element=e,this.drag=null,this.isDestroyed=!1,this._areWindowListenersBound=!1,this._startPredicate=s,this._listenerOptions=me(n),this._sourceEvents=ue(r),this._emitter=new rt,this._onStart=this._onStart.bind(this),this._onMove=this._onMove.bind(this),this._onCancel=this._onCancel.bind(this),this._onEnd=this._onEnd.bind(this),e.addEventListener(X[this._sourceEvents].start,this._onStart,this._listenerOptions)}_getTrackedPointerEventData(e){return this.drag?de(e,this.drag.pointerId):null}_onStart(e){if(this.isDestroyed||this.drag||!this._startPredicate(e))return;let t=Me(e);if(t===null)return;let n=de(e,t);if(n===null)return;let r={pointerId:t,pointerType:Re(e),x:n.clientX,y:n.clientY};this.drag=r;let s={...r,type:_.start,srcEvent:e,target:n.target};this._emitter.emit(s.type,s),this.drag&&this._bindWindowListeners()}_onMove(e){if(!this.drag)return;let t=this._getTrackedPointerEventData(e);if(!t)return;this.drag.x=t.clientX,this.drag.y=t.clientY;let n={type:_.move,srcEvent:e,target:t.target,...this.drag};this._emitter.emit(n.type,n)}_onCancel(e){if(!this.drag)return;let t=this._getTrackedPointerEventData(e);if(!t)return;this.drag.x=t.clientX,this.drag.y=t.clientY;let n={type:_.cancel,srcEvent:e,target:t.target,...this.drag};this._emitter.emit(n.type,n),this._resetDrag()}_onEnd(e){if(!this.drag)return;let t=this._getTrackedPointerEventData(e);if(!t)return;this.drag.x=t.clientX,this.drag.y=t.clientY;let n={type:_.end,srcEvent:e,target:t.target,...this.drag};this._emitter.emit(n.type,n),this._resetDrag()}_bindWindowListeners(){if(this._areWindowListenersBound)return;let{move:e,end:t,cancel:n}=X[this._sourceEvents];window.addEventListener(e,this._onMove,this._listenerOptions),window.addEventListener(t,this._onEnd,this._listenerOptions),n&&window.addEventListener(n,this._onCancel,this._listenerOptions),this._areWindowListenersBound=!0}_unbindWindowListeners(){if(this._areWindowListenersBound){let{move:e,end:t,cancel:n}=X[this._sourceEvents];window.removeEventListener(e,this._onMove,this._listenerOptions),window.removeEventListener(t,this._onEnd,this._listenerOptions),n&&window.removeEventListener(n,this._onCancel,this._listenerOptions),this._areWindowListenersBound=!1}}_resetDrag(){this.drag=null,this._unbindWindowListeners()}cancel(){if(!this.drag)return;let e={type:_.cancel,srcEvent:null,target:null,...this.drag};this._emitter.emit(e.type,e),this._resetDrag()}updateSettings(e){if(this.isDestroyed)return;let{listenerOptions:t,sourceEvents:n,startPredicate:r}=e,s=ue(n),o=me(t);r&&this._startPredicate!==r&&(this._startPredicate=r),(t&&(this._listenerOptions.capture!==o.capture||this._listenerOptions.passive===o.passive)||n&&this._sourceEvents!==s)&&(this.element.removeEventListener(X[this._sourceEvents].start,this._onStart,this._listenerOptions),this._unbindWindowListeners(),this.cancel(),n&&(this._sourceEvents=s),t&&o&&(this._listenerOptions=o),this.element.addEventListener(X[this._sourceEvents].start,this._onStart,this._listenerOptions))}on(e,t,n){return this._emitter.on(e,t,n)}off(e,t){this._emitter.off(e,t)}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.cancel(),this._emitter.emit(_.destroy,{type:_.destroy}),this._emitter.off(),this.element.removeEventListener(X[this._sourceEvents].start,this._onStart,this._listenerOptions))}};var Xe=class extends W{constructor(t={}){super();let{moveDistance:n=25,startPredicate:r=l=>{if((l.key==="Enter"||l.key===" ")&&document.activeElement&&document.activeElement!==document.body){let{left:a,top:d}=document.activeElement.getBoundingClientRect();return{x:a,y:d}}return null},movePredicate:s=(l,a,d)=>{if(!a.drag)return null;switch(l.key){case"ArrowLeft":return{x:a.drag.x-d.x,y:a.drag.y};case"ArrowRight":return{x:a.drag.x+d.x,y:a.drag.y};case"ArrowUp":return{x:a.drag.x,y:a.drag.y-d.y};case"ArrowDown":return{x:a.drag.x,y:a.drag.y+d.y};default:return null}},cancelPredicate:o=(l,a)=>a.drag&&l.key==="Escape"?{x:a.drag.x,y:a.drag.y}:null,endPredicate:c=(l,a)=>a.drag&&(l.key==="Enter"||l.key===" ")?{x:a.drag.x,y:a.drag.y}:null}=t;this._moveDistance=typeof n=="number"?{x:n,y:n}:{...n},this._startPredicate=r,this._movePredicate=s,this._cancelPredicate=o,this._endPredicate=c,this.cancel=this.cancel.bind(this),this._onKeyDown=this._onKeyDown.bind(this),document.addEventListener("keydown",this._onKeyDown),window.addEventListener("blur",this.cancel),window.addEventListener("visibilitychange",this.cancel)}_onKeyDown(t){if(!this.drag){let o=this._startPredicate(t,this,this._moveDistance);o&&(t.preventDefault(),this._start({type:"start",x:o.x,y:o.y,srcEvent:t}));return}let n=this._cancelPredicate(t,this,this._moveDistance);if(n){t.preventDefault(),this._cancel({type:"cancel",x:n.x,y:n.y,srcEvent:t});return}let r=this._endPredicate(t,this,this._moveDistance);if(r){t.preventDefault(),this._end({type:"end",x:r.x,y:r.y,srcEvent:t});return}let s=this._movePredicate(t,this,this._moveDistance);if(s){t.preventDefault(),this._move({type:"move",x:s.x,y:s.y,srcEvent:t});return}}updateSettings(t={}){t.moveDistance!==void 0&&(typeof t.moveDistance=="number"?(this._moveDistance.x=t.moveDistance,this._moveDistance.y=t.moveDistance):(this._moveDistance.x=t.moveDistance.x,this._moveDistance.y=t.moveDistance.y)),t.startPredicate!==void 0&&(this._startPredicate=t.startPredicate),t.movePredicate!==void 0&&(this._movePredicate=t.movePredicate),t.cancelPredicate!==void 0&&(this._cancelPredicate=t.cancelPredicate),t.endPredicate!==void 0&&(this._endPredicate=t.endPredicate)}destroy(){this.isDestroyed||(super.destroy(),document.removeEventListener("keydown",this._onKeyDown),window.removeEventListener("blur",this.cancel),window.removeEventListener("visibilitychange",this.cancel))}};var at=["start","cancel","end","moveLeft","moveRight","moveUp","moveDown"];function Q(i,e){if(!i.size||!e.size)return 1/0;let t=1/0;for(let n of i){let r=e.get(n);r!==void 0&&r<t&&(t=r)}return t}var Ye=class extends ${constructor(t={}){super();let{startPredicate:n=()=>{if(document.activeElement){let{left:y,top:g}=document.activeElement.getBoundingClientRect();return{x:y,y:g}}return null},computeSpeed:r=()=>500,startKeys:s=[" ","Enter"],moveLeftKeys:o=["ArrowLeft"],moveRightKeys:c=["ArrowRight"],moveUpKeys:l=["ArrowUp"],moveDownKeys:a=["ArrowDown"],cancelKeys:d=["Escape"],endKeys:m=[" ","Enter"]}=t;this._computeSpeed=r,this._startPredicate=n,this._startKeys=new Set(s),this._cancelKeys=new Set(d),this._endKeys=new Set(m),this._moveLeftKeys=new Set(o),this._moveRightKeys=new Set(c),this._moveUpKeys=new Set(l),this._moveDownKeys=new Set(a),this._moveKeys=new Set([...o,...c,...l,...a]),this._moveKeyTimestamps=new Map,this._onKeyDown=this._onKeyDown.bind(this),this._onKeyUp=this._onKeyUp.bind(this),this._onTick=this._onTick.bind(this),this.on("tick",this._onTick),document.addEventListener("keydown",this._onKeyDown),document.addEventListener("keyup",this._onKeyUp),window.addEventListener("blur",this.cancel),window.addEventListener("visibilitychange",this.cancel)}_end(t){this.drag&&(this._moveKeyTimestamps.clear(),this._direction.x=0,this._direction.y=0,super._end(t))}_cancel(t){this.drag&&(this._moveKeyTimestamps.clear(),this._direction.x=0,this._direction.y=0,super._cancel(t))}_updateDirection(){let t=Q(this._moveLeftKeys,this._moveKeyTimestamps),n=Q(this._moveRightKeys,this._moveKeyTimestamps),r=Q(this._moveUpKeys,this._moveKeyTimestamps),s=Q(this._moveDownKeys,this._moveKeyTimestamps),o=t===n?0:t<n?-1:1,c=r===s?0:r<s?-1:1;if(!(o===0||c===0)){let l=1/(Math.sqrt(o*o+c*c)||1);o*=l,c*=l}this._direction.x=o,this._direction.y=c}_onTick(){this._speed=this._computeSpeed(this)}_onKeyUp(t){this._moveKeyTimestamps.get(t.key)&&(this._moveKeyTimestamps.delete(t.key),this._updateDirection())}_onKeyDown(t){if(!this.drag){if(this._startKeys.has(t.key)){let n=this._startPredicate(t,this);n&&(t.preventDefault(),this._start({type:"start",x:n.x,y:n.y}))}return}if(this._cancelKeys.has(t.key)){t.preventDefault(),this._cancel({type:"cancel",x:this.drag.x,y:this.drag.y});return}if(this._endKeys.has(t.key)){t.preventDefault(),this._end({type:"end",x:this.drag.x,y:this.drag.y});return}if(this._moveKeys.has(t.key)){t.preventDefault(),this._moveKeyTimestamps.get(t.key)||(this._moveKeyTimestamps.set(t.key,Date.now()),this._updateDirection());return}}updateSettings(t={}){let n=!1;if(t.startPredicate!==void 0&&(this._startPredicate=t.startPredicate),t.computeSpeed!==void 0&&(this._computeSpeed=t.computeSpeed),at.forEach((r,s)=>{let o=`${r}Keys`,c=t[o];c!==void 0&&(this[`_${o}`]=new Set(c),s>=3&&(n=!0))}),n){let r=[...this._moveLeftKeys,...this._moveRightKeys,...this._moveUpKeys,...this._moveDownKeys];[...this._moveKeys].every((o,c)=>r[c]===o)||(this._moveKeys=new Set(r),this._moveKeyTimestamps.clear(),this._updateDirection())}}destroy(){this.isDestroyed||(super.destroy(),this.off("tick",this._onTick),document.removeEventListener("keydown",this._onKeyDown),document.removeEventListener("keyup",this._onKeyUp),window.removeEventListener("blur",this.cancel),window.removeEventListener("visibilitychange",this.cancel))}};import{Emitter as lt}from"eventti";import{getOffsetContainer as Ve}from"mezr";var Z=class{constructor(){this.sensor=null,this.isEnded=!1,this.isStarted=!1,this.startEvent=null,this.nextMoveEvent=null,this.prevMoveEvent=null,this.endEvent=null,this.items=[]}};var ee=class{constructor(e,t,n,r,s){this.data={},this.element=e,this.elementContainer=t,this.elementOffsetContainer=n,this.dragContainer=r,this.dragOffsetContainer=s,this.initialTransform="",this.frozenProps=null,this.unfrozenProps=null,this.x=0,this.y=0,this.pX=0,this.pY=0,this._updateDiffX=0,this._updateDiffY=0,this._moveDiffX=0,this._moveDiffY=0,this._containerDiffX=0,this._containerDiffY=0}};import{getOffset as Ne}from"mezr";function pe(i,e,t={left:0,top:0}){if(t.left=0,t.top=0,i===e)return t;let n=Ne([i,"padding"]),r=Ne([e,"padding"]);return t.left=r.left-n.left,t.top=r.top-n.top,t}var qe=new WeakMap;function te(i){let e=qe.get(i)?.deref();return e||(e=window.getComputedStyle(i,null),qe.set(i,new WeakRef(e))),e}var ct="matrix(1, 0, 0, 1, 0, 0)",dt="matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)",Ue=J?{capture:!0,passive:!0}:!0,ze={left:0,top:0},fe={x:0,y:0};function ht(){return{container:null,startPredicate:()=>!0,getElements:()=>null,releaseElements:()=>null,getFrozenProps:()=>null,getStartPosition:()=>({x:0,y:0}),setPosition:({item:i,x:e,y:t})=>{i.element.style.transform=`translate(${e}px, ${t}px) ${i.initialTransform}`},getPositionChange:({event:i,prevEvent:e})=>(fe.x=i.x-e.x,fe.y=i.y-e.y,fe)}}var Be=class{constructor(e,t={}){this.sensors=e,this.settings=this._parseSettings(t),this.plugins={},this.drag=null,this.isDestroyed=!1,this._sensorData=new Map,this._emitter=new lt,this._startId=Symbol(),this._moveId=Symbol(),this._updateId=Symbol(),this._onMove=this._onMove.bind(this),this._onScroll=this._onScroll.bind(this),this._onEnd=this._onEnd.bind(this),this._prepareStart=this._prepareStart.bind(this),this._applyStart=this._applyStart.bind(this),this._prepareMove=this._prepareMove.bind(this),this._applyMove=this._applyMove.bind(this),this._preparePositionUpdate=this._preparePositionUpdate.bind(this),this._applyPositionUpdate=this._applyPositionUpdate.bind(this),this.sensors.forEach(n=>{this._sensorData.set(n,{predicateState:0,predicateEvent:null,onMove:o=>this._onMove(o,n),onEnd:o=>this._onEnd(o,n)});let{onMove:r,onEnd:s}=this._sensorData.get(n);n.on("start",r),n.on("move",r),n.on("cancel",s),n.on("end",s),n.on("destroy",s)})}_parseSettings(e,t=ht()){let{container:n=t.container,startPredicate:r=t.startPredicate,getElements:s=t.getElements,releaseElements:o=t.releaseElements,getFrozenProps:c=t.getFrozenProps,getStartPosition:l=t.getStartPosition,setPosition:a=t.setPosition,getPositionChange:d=t.getPositionChange}=e||{};return{container:n,startPredicate:r,getElements:s,releaseElements:o,getFrozenProps:c,getStartPosition:l,setPosition:a,getPositionChange:d}}_emit(e,...t){this._emitter.emit(e,...t)}_onMove(e,t){let n=this._sensorData.get(t);if(n)switch(n.predicateState){case 0:{n.predicateEvent=e;let r=this.settings.startPredicate({draggable:this,sensor:t,event:e});r===!0?this.resolveStartPredicate(t):r===!1&&this.rejectStartPredicate(t);break}case 1:{this.drag&&(this.drag.nextMoveEvent=e,u.once(v,this._prepareMove,this._moveId),u.once(D,this._applyMove,this._moveId));break}}}_onScroll(){this.updatePosition()}_onEnd(e,t){let n=this._sensorData.get(t);n&&(this.drag?n.predicateState===1&&(this.drag.endEvent=e,this._sensorData.forEach(r=>{r.predicateState=0,r.predicateEvent=null}),this.stop()):(n.predicateState=0,n.predicateEvent=null))}_prepareStart(){let{drag:e}=this;if(!e||!e.startEvent)return;let t=this.settings.getElements({draggable:this,sensor:e.sensor,startEvent:e.startEvent})||[];e.items=t.map(n=>{if(!n.isConnected)throw new Error("Element is not connected");let r=n.parentElement,s=Ve(n);if(!s)throw new Error("Offset container could not be computed for the element!");let o=this.settings.container||r,c=o===r?s:Ve(n,{container:o});if(!c)throw new Error("Drag offset container could not be computed for the element!");let l=new ee(n,r,s,o,c),a=n.getBoundingClientRect();if(l.x=a.left,l.y=a.top,s!==c){let{left:b,top:f}=pe(c,s,ze);l._containerDiffX=b,l._containerDiffY=f}let d=te(n),{transform:m}=d;m&&m!=="none"&&m!==ct&&m!==dt&&(l.initialTransform=m);let{x:y,y:g}=this.settings.getStartPosition({draggable:this,sensor:e.sensor,item:l,style:d});l.pX=y,l.pY=g;let S=this.settings.getFrozenProps({draggable:this,sensor:e.sensor,item:l,style:d});if(Array.isArray(S))if(S.length){let b={};for(let f of S)b[f]=d[f];l.frozenProps=b}else l.frozenProps=null;else l.frozenProps=S;if(l.frozenProps){let b={};for(let f in l.frozenProps)l.frozenProps.hasOwnProperty(f)&&(b[f]=n.style[f]);l.unfrozenProps=b}return l}),this._emit("preparestart",e.startEvent)}_applyStart(){let e=this.drag;if(!e||!e.startEvent)return;let{container:t}=this.settings;for(let n of e.items)t&&n.element.parentElement!==t&&(t.appendChild(n.element),n.pX+=n._containerDiffX,n.pY+=n._containerDiffY),n.frozenProps&&Object.assign(n.element.style,n.frozenProps),this.settings.setPosition({phase:"start",draggable:this,sensor:e.sensor,item:n,x:n.pX,y:n.pY});window.addEventListener("scroll",this._onScroll,Ue),e.isStarted=!0,this._emit("start",e.startEvent)}_prepareMove(){let{drag:e}=this;if(!e||!e.startEvent)return;let t=e.nextMoveEvent,n=e.prevMoveEvent||e.startEvent;if(!(!t||t===n)){for(let r of e.items){let{x:s,y:o}=this.settings.getPositionChange({draggable:this,sensor:e.sensor,item:r,startEvent:e.startEvent,prevEvent:n,event:t});s&&(r.pX=r.pX-r._moveDiffX+s,r.x=r.x-r._moveDiffX+s,r._moveDiffX=s),o&&(r.pY=r.pY-r._moveDiffY+o,r.y=r.y-r._moveDiffY+o,r._moveDiffY=o)}e.prevMoveEvent=t,this._emit("preparemove",t)}}_applyMove(){let{drag:e}=this;if(!(!e||!e.nextMoveEvent)){for(let t of e.items)t._moveDiffX=0,t._moveDiffY=0;for(let t of e.items)this.settings.setPosition({phase:"move",draggable:this,sensor:e.sensor,item:t,x:t.pX,y:t.pY});this._emit("move",e.nextMoveEvent)}}_preparePositionUpdate(){let{drag:e}=this;if(e)for(let t of e.items){if(t.elementOffsetContainer!==t.dragOffsetContainer){let{left:c,top:l}=pe(t.dragOffsetContainer,t.elementOffsetContainer,ze);t._containerDiffX=c,t._containerDiffY=l}let{left:n,top:r}=t.element.getBoundingClientRect(),s=t.x-t._moveDiffX-n;t.pX=t.pX-t._updateDiffX+s,t._updateDiffX=s;let o=t.y-t._moveDiffY-r;t.pY=t.pY-t._updateDiffY+o,t._updateDiffY=o}}_applyPositionUpdate(){let{drag:e}=this;if(e)for(let t of e.items)t._updateDiffX=0,t._updateDiffY=0,this.settings.setPosition({phase:"move",draggable:this,sensor:e.sensor,item:t,x:t.pX,y:t.pY})}on(e,t,n){return this._emitter.on(e,t,n)}off(e,t){this._emitter.off(e,t)}resolveStartPredicate(e,t){let n=this._sensorData.get(e);if(!n)return;let r=t||n.predicateEvent;n.predicateState===0&&r&&(n.predicateState=1,n.predicateEvent=null,this.drag=new Z,this.drag.sensor=e,this.drag.startEvent=r,this._sensorData.forEach((s,o)=>{o!==e&&(s.predicateState=2,s.predicateEvent=null)}),u.once(v,this._prepareStart,this._startId),u.once(D,this._applyStart,this._startId))}rejectStartPredicate(e){let t=this._sensorData.get(e);t?.predicateState===0&&(t.predicateState=2,t.predicateEvent=null)}stop(){let{drag:e}=this;if(!(!e||e.isEnded)){if(e.isEnded=!0,u.off(v,this._startId),u.off(D,this._startId),u.off(v,this._moveId),u.off(D,this._moveId),u.off(v,this._updateId),u.off(D,this._updateId),e.isStarted){window.removeEventListener("scroll",this._onScroll,Ue);let t=[];for(let n of e.items){if(t.push(n.element),n.elementContainer&&n.element.parentElement!==n.elementContainer&&(n.pX-=n._containerDiffX,n.pY-=n._containerDiffY,n._containerDiffX=0,n._containerDiffY=0,n.elementContainer.appendChild(n.element)),n.unfrozenProps)for(let r in n.unfrozenProps)n.element.style[r]=n.unfrozenProps[r]||"";this.settings.setPosition({phase:"end",draggable:this,sensor:e.sensor,item:n,x:n.pX,y:n.pY})}t.length&&this.settings.releaseElements({draggable:this,sensor:e.sensor,elements:t})}this._emit("end",e.endEvent),this.drag=null}}updatePosition(e=!1){this.drag&&(e?(this._preparePositionUpdate(),this._applyPositionUpdate()):(u.once(v,this._preparePositionUpdate,this._updateId),u.once(D,this._applyPositionUpdate,this._updateId)))}updateSettings(e={}){this.settings=this._parseSettings(e,this.settings)}use(e){return e(this)}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.stop(),this._sensorData.forEach(({onMove:e,onEnd:t},n)=>{n.off("start",e),n.off("move",e),n.off("cancel",t),n.off("end",t),n.off("destroy",t)}),this._sensorData.clear(),this._emit("destroy"),this._emitter.off())}};import{Emitter as ut}from"eventti";import{getDistance as pt,getRect as Ge}from"mezr";var B=class{constructor(e,t){this._data=[],this._createObject=e,this._onPut=t}pick(){return this._data.length?this._data.pop():this._createObject()}put(e){this._data.indexOf(e)===-1&&(this._onPut&&this._onPut(e),this._data.push(e))}reset(){this._data.length=0}};import{getIntersection as mt}from"mezr";function He(i,e){let t=mt(i,e);return t?t.width*t.height:0}function ge(i,e){let t=He(i,e);if(!t)return 0;let n=Math.min(i.width,e.width)*Math.min(i.height,e.height);return t/n*100}function w(i){return i instanceof Window}function Se(i){return w(i)||i===document.documentElement||i===document.body?window:i}function N(i){return w(i)?i.pageXOffset:i.scrollLeft}function Ee(i){return w(i)&&(i=document.documentElement),i.scrollWidth-i.clientWidth}function q(i){return w(i)?i.pageYOffset:i.scrollTop}function ve(i){return w(i)&&(i=document.documentElement),i.scrollHeight-i.clientHeight}function _e(i,e){return!(i.right<=e.left||e.right<=i.left||i.bottom<=e.top||e.bottom<=i.top)}var xe={width:0,height:0,left:0,right:0,top:0,bottom:0},Fe={...xe},je=50,I={direction:"none",threshold:0,distance:0,value:0,maxValue:0,duration:0,speed:0,deltaTime:0,isEnding:!1},h={x:1,y:2},M={forward:4,reverse:8},ne={none:0,left:h.x|M.reverse,right:h.x|M.forward},H={none:0,up:h.y|M.reverse,down:h.y|M.forward},p={...ne,...H};function ye(i){switch(i){case ne.none:case H.none:return"none";case ne.left:return"left";case ne.right:return"right";case H.up:return"up";case H.down:return"down";default:throw new Error(`Unknown direction value: ${i}`)}}function $e(i,e,t){let{left:n=0,right:r=0,top:s=0,bottom:o=0}=e;return n=Math.max(0,n),r=Math.max(0,r),s=Math.max(0,s),o=Math.max(0,o),t.width=i.width+n+r,t.height=i.height+s+o,t.left=i.left-n,t.top=i.top-s,t.right=i.right+r,t.bottom=i.bottom+o,t}function re(i,e){return Math.ceil(i)>=Math.floor(e)}function be(i,e){return Math.min(e/2,i)}function De(i,e,t,n){return Math.max(0,t+i*2+n*e-n)/2}var Pe=class{constructor(){this.positionX=0,this.positionY=0,this.directionX=p.none,this.directionY=p.none,this.overlapCheckRequestTime=0}},Te=class{constructor(){this.element=null,this.requestX=null,this.requestY=null,this.scrollLeft=0,this.scrollTop=0}reset(){this.requestX&&(this.requestX.action=null),this.requestY&&(this.requestY.action=null),this.element=null,this.requestX=null,this.requestY=null,this.scrollLeft=0,this.scrollTop=0}addRequest(e){h.x&e.direction?(this.requestX&&this.removeRequest(this.requestX),this.requestX=e):(this.requestY&&this.removeRequest(this.requestY),this.requestY=e),e.action=this}removeRequest(e){this.requestX===e?(this.requestX=null,e.action=null):this.requestY===e&&(this.requestY=null,e.action=null)}computeScrollValues(){this.element&&(this.scrollLeft=this.requestX?this.requestX.value:N(this.element),this.scrollTop=this.requestY?this.requestY.value:q(this.element))}scroll(){this.element&&(this.element.scrollTo?this.element.scrollTo(this.scrollLeft,this.scrollTop):(this.element.scrollLeft=this.scrollLeft,this.element.scrollTop=this.scrollTop))}},we=class{constructor(){this.item=null,this.element=null,this.isActive=!1,this.isEnding=!1,this.direction=0,this.value=NaN,this.maxValue=0,this.threshold=0,this.distance=0,this.deltaTime=0,this.speed=0,this.duration=0,this.action=null}reset(){this.isActive&&this.onStop(),this.item=null,this.element=null,this.isActive=!1,this.isEnding=!1,this.direction=0,this.value=NaN,this.maxValue=0,this.threshold=0,this.distance=0,this.deltaTime=0,this.speed=0,this.duration=0,this.action=null}hasReachedEnd(){return M.forward&this.direction?re(this.value,this.maxValue):this.value<=0}computeCurrentScrollValue(){return this.element?this.value!==this.value?h.x&this.direction?N(this.element):q(this.element):Math.max(0,Math.min(this.value,this.maxValue)):0}computeNextScrollValue(){let e=this.speed*(this.deltaTime/1e3),t=M.forward&this.direction?this.value+e:this.value-e;return Math.max(0,Math.min(t,this.maxValue))}computeSpeed(){if(!this.item||!this.element)return 0;let{speed:e}=this.item;return typeof e=="function"?(I.direction=ye(this.direction),I.threshold=this.threshold,I.distance=this.distance,I.value=this.value,I.maxValue=this.maxValue,I.duration=this.duration,I.speed=this.speed,I.deltaTime=this.deltaTime,I.isEnding=this.isEnding,e(this.element,I)):e}tick(e){return this.isActive||(this.isActive=!0,this.onStart()),this.deltaTime=e,this.value=this.computeCurrentScrollValue(),this.speed=this.computeSpeed(),this.value=this.computeNextScrollValue(),this.duration+=e,this.value}onStart(){if(!this.item||!this.element)return;let{onStart:e}=this.item;typeof e=="function"&&e(this.element,ye(this.direction))}onStop(){if(!this.item||!this.element)return;let{onStop:e}=this.item;typeof e=="function"&&e(this.element,ye(this.direction))}};function Je(i=500,e=.5,t=.25){let n=i*(e>0?1/e:1/0),r=i*(t>0?1/t:1/0);return function(s,o){let c=0;if(!o.isEnding)if(o.threshold>0){let d=o.threshold-Math.max(0,o.distance);c=i/o.threshold*d}else c=i;let l=o.speed;if(l===c)return c;let a=c;return l<c?(a=l+n*(o.deltaTime/1e3),Math.min(c,a)):(a=l-r*(o.deltaTime/1e3),Math.max(c,a))}}var ie=class{constructor(e={}){let{overlapCheckInterval:t=150}=e;this.items=[],this.settings={overlapCheckInterval:t},this._actions=[],this._isDestroyed=!1,this._isTicking=!1,this._tickTime=0,this._tickDeltaTime=0,this._requests={[h.x]:new Map,[h.y]:new Map},this._itemData=new Map,this._requestPool=new B(()=>new we,n=>n.reset()),this._actionPool=new B(()=>new Te,n=>n.reset()),this._emitter=new ut,this._frameRead=this._frameRead.bind(this),this._frameWrite=this._frameWrite.bind(this)}_frameRead(e){this._isDestroyed||(e&&this._tickTime?(this._tickDeltaTime=e-this._tickTime,this._tickTime=e,this._updateItems(),this._updateRequests(),this._updateActions()):(this._tickTime=e,this._tickDeltaTime=0))}_frameWrite(){this._isDestroyed||this._applyActions()}_startTicking(){this._isTicking||(this._isTicking=!0,u.on(v,this._frameRead),u.on(D,this._frameWrite))}_stopTicking(){this._isTicking&&(this._isTicking=!1,this._tickTime=0,this._tickDeltaTime=0,u.off(v,this._frameRead),u.off(D,this._frameWrite))}_getItemClientRect(e,t={width:0,height:0,left:0,right:0,top:0,bottom:0}){let{clientRect:n}=e;return t.left=n.left,t.top=n.top,t.width=n.width,t.height=n.height,t.right=n.left+n.width,t.bottom=n.top+n.height,t}_requestItemScroll(e,t,n,r,s,o,c){let l=this._requests[t],a=l.get(e);a?(a.element!==n||a.direction!==r)&&a.reset():(a=this._requestPool.pick(),l.set(e,a)),a.item=e,a.element=n,a.direction=r,a.threshold=s,a.distance=o,a.maxValue=c}_cancelItemScroll(e,t){let n=this._requests[t],r=n.get(e);r&&(r.action&&r.action.removeRequest(r),this._requestPool.put(r),n.delete(e))}_checkItemOverlap(e,t,n){let{inertAreaSize:r,targets:s}=e;if(!s.length){t&&this._cancelItemScroll(e,h.x),n&&this._cancelItemScroll(e,h.y);return}let o=this._itemData.get(e),c=o?.directionX,l=o?.directionY;if(!c&&!l){t&&this._cancelItemScroll(e,h.x),n&&this._cancelItemScroll(e,h.y);return}let a=this._getItemClientRect(e,xe),d=null,m=-1/0,y=0,g=-1/0,S=p.none,b=0,f=0,E=null,x=-1/0,V=0,U=-1/0,se=p.none,Ce=0,Le=0,ae=0;for(;ae<s.length;ae++){let A=s[ae],Ke=typeof A.threshold=="number"?A.threshold:je,le=!!(t&&c&&A.axis!=="y"),ce=!!(n&&l&&A.axis!=="x"),R=A.priority||0;if((!le||R<m)&&(!ce||R<x))continue;let k=Se(A.element||A),F=le?Ee(k):-1,j=ce?ve(k):-1;if(F<=0&&j<=0)continue;let P=Ge([k,"padding"],window),O=ge(a,P)||-1/0;if(O===-1/0)if(A.padding&&_e(a,$e(P,A.padding,Fe)))O=-(pt(a,P)||0);else continue;if(le&&R>=m&&F>0&&(R>m||O>g)){let T=0,C=p.none,L=be(Ke,P.width),z=De(L,r,a.width,P.width);c===p.right?(T=P.right+z-a.right,T<=L&&!re(N(k),F)&&(C=p.right)):c===p.left&&(T=a.left-(P.left-z),T<=L&&N(k)>0&&(C=p.left)),C&&(d=k,m=R,y=L,g=O,S=C,b=T,f=F)}if(ce&&R>=x&&j>0&&(R>x||O>U)){let T=0,C=H.none,L=be(Ke,P.height),z=De(L,r,a.height,P.height);l===p.down?(T=P.bottom+z-a.bottom,T<=L&&!re(q(k),j)&&(C=p.down)):l===p.up&&(T=a.top-(P.top-z),T<=L&&q(k)>0&&(C=p.up)),C&&(E=k,x=R,V=L,U=O,se=C,Ce=T,Le=j)}}t&&(d&&S?this._requestItemScroll(e,h.x,d,S,y,b,f):this._cancelItemScroll(e,h.x)),n&&(E&&se?this._requestItemScroll(e,h.y,E,se,V,Ce,Le):this._cancelItemScroll(e,h.y))}_updateScrollRequest(e){let t=e.item,{inertAreaSize:n,smoothStop:r,targets:s}=t,o=this._getItemClientRect(t,xe),c=null,l=0;for(;l<s.length;l++){let a=s[l],d=Se(a.element||a);if(d!==e.element)continue;let m=!!(h.x&e.direction);if(m){if(a.axis==="y")continue}else if(a.axis==="x")continue;let y=m?Ee(d):ve(d);if(y<=0)break;let g=Ge([d,"padding"],window);if((ge(o,g)||-1/0)===-1/0){let U=a.scrollPadding||a.padding;if(!(U&&_e(o,$e(g,U,Fe))))break}let b=typeof a.threshold=="number"?a.threshold:je,f=be(b,m?g.width:g.height),E=De(f,n,m?o.width:o.height,m?g.width:g.height),x=0;if(e.direction===p.left?x=o.left-(g.left-E):e.direction===p.right?x=g.right+E-o.right:e.direction===p.up?x=o.top-(g.top-E):x=g.bottom+E-o.bottom,x>f)break;let V=m?N(d):q(d);if(c=M.forward&e.direction?re(V,y):V<=0,c)break;return e.maxValue=y,e.threshold=f,e.distance=x,e.isEnding=!1,!0}return r===!0&&e.speed>0?(c===null&&(c=e.hasReachedEnd()),e.isEnding=!c):e.isEnding=!1,e.isEnding}_updateItems(){for(let e=0;e<this.items.length;e++){let t=this.items[e],n=this._itemData.get(t),{x:r,y:s}=t.position,o=n.positionX,c=n.positionY;r===o&&s===c||(n.directionX=r>o?p.right:r<o?p.left:n.directionX,n.directionY=s>c?p.down:s<c?p.up:n.directionY,n.positionX=r,n.positionY=s,n.overlapCheckRequestTime===0&&(n.overlapCheckRequestTime=this._tickTime))}}_updateRequests(){let e=this.items,t=this._requests[h.x],n=this._requests[h.y],r=0;for(;r<e.length;r++){let s=e[r],o=this._itemData.get(s),c=o.overlapCheckRequestTime,l=c>0&&this._tickTime-c>this.settings.overlapCheckInterval,a=!0,d=t.get(s);d&&d.isActive&&(a=!this._updateScrollRequest(d),a&&(l=!0,this._cancelItemScroll(s,h.x)));let m=!0,y=n.get(s);y&&y.isActive&&(m=!this._updateScrollRequest(y),m&&(l=!0,this._cancelItemScroll(s,h.y))),l&&(o.overlapCheckRequestTime=0,this._checkItemOverlap(s,a,m))}}_requestAction(e,t){let n=t===h.x,r=null,s=0;for(;s<this._actions.length;s++){if(r=this._actions[s],e.element!==r.element){r=null;continue}if(n?r.requestX:r.requestY){this._cancelItemScroll(e.item,t);return}break}r||(r=this._actionPool.pick()),r.element=e.element,r.addRequest(e),e.tick(this._tickDeltaTime),this._actions.push(r)}_updateActions(){let e=0;for(e=0;e<this.items.length;e++){let t=this.items[e],n=this._requests[h.x].get(t),r=this._requests[h.y].get(t);n&&this._requestAction(n,h.x),r&&this._requestAction(r,h.y)}for(e=0;e<this._actions.length;e++)this._actions[e].computeScrollValues()}_applyActions(){if(!this._actions.length)return;this._emitter.emit("beforescroll");let e=0;for(e=0;e<this._actions.length;e++)this._actions[e].scroll(),this._actionPool.put(this._actions[e]);this._actions.length=0;let t;for(e=0;e<this.items.length;e++)t=this.items[e],t.onPrepareScrollEffect&&t.onPrepareScrollEffect();for(e=0;e<this.items.length;e++)t=this.items[e],t.onApplyScrollEffect&&t.onApplyScrollEffect();this._emitter.emit("afterscroll")}on(e,t){return this._emitter.on(e,t)}off(e,t){this._emitter.off(e,t)}addItem(e){if(this._isDestroyed||this._itemData.has(e))return;let{x:t,y:n}=e.position,r=new Pe;r.positionX=t,r.positionY=n,r.directionX=p.none,r.directionY=p.none,r.overlapCheckRequestTime=this._tickTime,this._itemData.set(e,r),this.items.push(e),this._isTicking||this._startTicking()}removeItem(e){if(this._isDestroyed)return;let t=this.items.indexOf(e);t!==-1&&(this._requests[h.x].get(e)&&(this._cancelItemScroll(e,h.x),this._requests[h.x].delete(e)),this._requests[h.y].get(e)&&(this._cancelItemScroll(e,h.y),this._requests[h.y].delete(e)),this._itemData.delete(e),this.items.splice(t,1),this._isTicking&&!this.items.length&&this._stopTicking())}isDestroyed(){return this._isDestroyed}isItemScrollingX(e){return!!this._requests[h.x].get(e)?.isActive}isItemScrollingY(e){return!!this._requests[h.y].get(e)?.isActive}isItemScrolling(e){return this.isItemScrollingX(e)||this.isItemScrollingY(e)}updateSettings(e={}){let{overlapCheckInterval:t=this.settings.overlapCheckInterval}=e;this.settings.overlapCheckInterval=t}destroy(){if(this._isDestroyed)return;let e=this.items.slice(0),t=0;for(;t<e.length;t++)this.removeItem(e[t]);this._actions.length=0,this._requestPool.reset(),this._actionPool.reset(),this._emitter.off(),this._isDestroyed=!0}};var Ie=new ie;var G={x:0,y:0},K={left:0,top:0,width:0,height:0};function ft(){return{targets:[],inertAreaSize:.2,speed:Je(),smoothStop:!1,getPosition:i=>{let{drag:e}=i,t=e?.items[0];if(t)G.x=t.pX,G.y=t.pY;else{let n=e&&(e.nextMoveEvent||e.startEvent);G.x=n?n.x:0,G.y=n?n.y:0}return G},getClientRect:i=>{let{drag:e}=i,t=e?.items[0];if(t&&t.element){let{left:n,top:r,width:s,height:o}=t.element.getBoundingClientRect();K.left=n,K.top=r,K.width=s,K.height=o}else{let n=e&&(e.nextMoveEvent||e.startEvent);K.left=n?n.x-25:0,K.top=n?n.y-25:0,K.width=n?50:0,K.height=n?50:0}return K},onStart:null,onStop:null}}var Ae=class{constructor(e,t){this._draggableAutoScroll=e,this._draggable=t,this._position={x:0,y:0},this._clientRect={left:0,top:0,width:0,height:0}}_getSettings(){return this._draggableAutoScroll.settings}get targets(){let{targets:e}=this._getSettings();return typeof e=="function"&&(e=e(this._draggable)),e}get position(){let{getPosition:e}=this._getSettings();if(typeof e=="function"){let t=e(this._draggable);this._position.x=t.x,this._position.y=t.y}else this._position.x=0,this._position.y=0;return this._position}get clientRect(){let{getClientRect:e}=this._getSettings();if(typeof e=="function"){let{left:t,top:n,width:r,height:s}=e(this._draggable);this._clientRect.left=t,this._clientRect.top=n,this._clientRect.width=r,this._clientRect.height=s}else this._clientRect.left=0,this._clientRect.top=0,this._clientRect.width=0,this._clientRect.height=0;return this._clientRect}get inertAreaSize(){return this._getSettings().inertAreaSize}get smoothStop(){return this._getSettings().smoothStop}get speed(){return this._getSettings().speed}get onStart(){return this._getSettings().onStart}get onStop(){return this._getSettings().onStop}onPrepareScrollEffect(){let e=this._draggable._updateId;u.off(v,e),u.off(D,e),this._draggable._preparePositionUpdate()}onApplyScrollEffect(){this._draggable._applyPositionUpdate()}},ke=class{constructor(e,t={}){this.name="autoscroll",this.version="0.0.2",this.settings=this._parseSettings(t),this._autoScrollProxy=null,e.on("start",()=>{this._autoScrollProxy||(this._autoScrollProxy=new Ae(this,e),Ie.addItem(this._autoScrollProxy))}),e.on("end",()=>{this._autoScrollProxy&&(Ie.removeItem(this._autoScrollProxy),this._autoScrollProxy=null)})}_parseSettings(e,t=ft()){let{targets:n=t.targets,inertAreaSize:r=t.inertAreaSize,speed:s=t.speed,smoothStop:o=t.smoothStop,getPosition:c=t.getPosition,getClientRect:l=t.getClientRect,onStart:a=t.onStart,onStop:d=t.onStop}=e||{};return{targets:n,inertAreaSize:r,speed:s,smoothStop:o,getPosition:c,getClientRect:l,onStart:a,onStop:d}}updateSettings(e={}){this.settings=this._parseSettings(e,this.settings)}};function dr(i){return e=>{let t=new ke(e,i),n=e;return n.plugins[t.name]=t,n}}var Qe=new Set(["auto","scroll","overlay"]);function oe(i){let e=te(i);return!!(Qe.has(e.overflowY)||Qe.has(e.overflowX))}function Ze(i){return i instanceof Document}function et(i,e=[]){let t=i?.parentNode;for(;t&&!Ze(t);)t instanceof Element?(oe(t)&&e.push(t),t=t.parentNode):t instanceof ShadowRoot?t=t.host:t=t.parentNode;return e.push(window),e}function gt(i){let e=[];return oe(i)&&e.push(i),et(i,e),e}function br(i={}){let e,t=0,n=null,r,{timeout:s=250,fallback:o=()=>!0}=i,c=d=>d.preventDefault(),l=d=>{if(t){if(e){d.cancelable&&d.preventDefault();return}e===void 0&&(d.cancelable&&d.timeStamp-t>s?(e=!0,d.preventDefault()):e=!1)}};return d=>{if(!(d.sensor instanceof Y))return o(d);let{draggable:m,sensor:y,event:g}=d,S=g;if(S.pointerType==="touch"){if(S.type==="start"&&(S.srcEvent.type==="pointerdown"||S.srcEvent.type==="touchstart")){n=S.target;let b=n?gt(n):[];b.forEach(E=>{E.addEventListener("touchmove",l,{passive:!1,capture:!0})});let f=()=>{t&&(m.off("end",f),m.sensors.forEach(E=>{E instanceof Y&&E.off("end",f)}),n?.removeEventListener("contextmenu",c),b.forEach(E=>{E.removeEventListener("touchmove",l,{capture:!0})}),t=0,e=void 0,n=null,r=void window.clearTimeout(r))};e=void 0,t=S.srcEvent.timeStamp,n?.addEventListener("contextmenu",c),m.on("end",f),m.sensors.forEach(E=>{E instanceof Y&&E.off("end",f)}),s>0&&(r=window.setTimeout(()=>{m.resolveStartPredicate(y),e=!0,r=void 0},s))}return e}return S.type==="start"&&!S.srcEvent.button}}export{h as AUTO_SCROLL_AXIS,M as AUTO_SCROLL_AXIS_DIRECTION,p as AUTO_SCROLL_DIRECTION,ie as AutoScroll,$ as BaseMotionSensor,W as BaseSensor,Be as Draggable,ke as DraggableAutoScroll,Ye as KeyboardMotionSensor,Xe as KeyboardSensor,Y as PointerSensor,_ as SensorEventType,Ie as autoScroll,dr as autoScrollPlugin,Je as autoScrollSmoothSpeed,br as createPointerSensorStartPredicate,wt as setTicker,u as ticker,v as tickerReadPhase,D as tickerWritePhase};
var y={start:"start",move:"move",cancel:"cancel",end:"end",destroy:"destroy"};import{Emitter as tt}from"eventti";var W=class{constructor(){this.drag=null,this.isDestroyed=!1,this._emitter=new tt}_createDragData(e){return{x:e.x,y:e.y}}_updateDragData(e){this.drag&&(this.drag.x=e.x,this.drag.y=e.y)}_resetDragData(){this.drag=null}_start(e){this.isDestroyed||this.drag||(this.drag=this._createDragData(e),this._emitter.emit(y.start,e))}_move(e){this.drag&&(this._updateDragData(e),this._emitter.emit(y.move,e))}_end(e){this.drag&&(this._updateDragData(e),this._emitter.emit(y.end,e),this._resetDragData())}_cancel(e){this.drag&&(this._updateDragData(e),this._emitter.emit(y.cancel,e),this._resetDragData())}on(e,t,n){return this._emitter.on(e,t,n)}off(e,t){this._emitter.off(e,t)}cancel(){this.drag&&(this._emitter.emit(y.cancel,{type:y.cancel,x:this.drag.x,y:this.drag.y}),this._resetDragData())}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.cancel(),this._emitter.emit(y.destroy,{type:y.destroy}),this._emitter.off())}};import{AutoTicker as nt}from"tikki";var E=Symbol(),D=Symbol(),u=new nt({phases:[E,D]});function Ct(r,e,t){E=e,D=t,u=r}var $=class extends W{constructor(){super(),this.drag=null,this._direction={x:0,y:0},this._speed=0,this._tick=this._tick.bind(this)}_createDragData(e){return{...super._createDragData(e),time:0,deltaTime:0}}_start(e){this.isDestroyed||this.drag||(super._start(e),u.on(E,this._tick,this._tick))}_end(e){this.drag&&(u.off(E,this._tick),super._end(e))}_cancel(e){this.drag&&(u.off(E,this._tick),super._cancel(e))}_tick(e){if(this.drag)if(e&&this.drag.time){this.drag.deltaTime=e-this.drag.time,this.drag.time=e;let t={type:"tick",time:this.drag.time,deltaTime:this.drag.deltaTime};if(this._emitter.emit("tick",t),!this.drag)return;let n=this._speed*(this.drag.deltaTime/1e3),i=this._direction.x*n,o=this._direction.y*n;(i||o)&&this._move({type:"move",x:this.drag.x+i,y:this.drag.y+o})}else this.drag.time=e,this.drag.deltaTime=0}};import{Emitter as rt}from"eventti";function he(r,e){if("pointerId"in r)return r.pointerId===e?r:null;if("changedTouches"in r){let t=0;for(;t<r.changedTouches.length;t++)if(r.changedTouches[t].identifier===e)return r.changedTouches[t];return null}return r}function Oe(r){return"pointerType"in r?r.pointerType:"touches"in r?"touch":"mouse"}function Me(r){return"pointerId"in r?r.pointerId:"changedTouches"in r?r.changedTouches[0]?r.changedTouches[0].identifier:null:-1}var me=typeof window<"u"&&typeof window.document<"u",J=(()=>{let r=!1;try{let e=Object.defineProperty({},"passive",{get:function(){r=!0}});window.addEventListener("testPassive",null,e),window.removeEventListener("testPassive",null,e)}catch{}return r})(),Ke=me&&"ontouchstart"in window,We=me&&!!window.PointerEvent,Nt=!!(me&&navigator.vendor&&navigator.vendor.indexOf("Apple")>-1&&navigator.userAgent&&navigator.userAgent.indexOf("CriOS")==-1&&navigator.userAgent.indexOf("FxiOS")==-1);function ue(r={}){let{capture:e=!0,passive:t=!0}=r;return J?{capture:e,passive:t}:{capture:e}}function pe(r){return r==="auto"||r===void 0?We?"pointer":Ke?"touch":"mouse":r}var it={start:"pointerdown",move:"pointermove",cancel:"pointercancel",end:"pointerup"},ot={start:"touchstart",move:"touchmove",cancel:"touchcancel",end:"touchend"},st={start:"mousedown",move:"mousemove",cancel:"",end:"mouseup"},q={pointer:it,touch:ot,mouse:st},X=class{constructor(e,t={}){let{listenerOptions:n={},sourceEvents:i="auto",startPredicate:o=s=>!("button"in s&&s.button>0)}=t;this.element=e,this.drag=null,this.isDestroyed=!1,this._areWindowListenersBound=!1,this._startPredicate=o,this._listenerOptions=ue(n),this._sourceEvents=pe(i),this._emitter=new rt,this._onStart=this._onStart.bind(this),this._onMove=this._onMove.bind(this),this._onCancel=this._onCancel.bind(this),this._onEnd=this._onEnd.bind(this),e.addEventListener(q[this._sourceEvents].start,this._onStart,this._listenerOptions)}_getTrackedPointerEventData(e){return this.drag?he(e,this.drag.pointerId):null}_onStart(e){if(this.isDestroyed||this.drag||!this._startPredicate(e))return;let t=Me(e);if(t===null)return;let n=he(e,t);if(n===null)return;let i={pointerId:t,pointerType:Oe(e),x:n.clientX,y:n.clientY};this.drag=i;let o={...i,type:y.start,srcEvent:e,target:n.target};this._emitter.emit(o.type,o),this.drag&&this._bindWindowListeners()}_onMove(e){if(!this.drag)return;let t=this._getTrackedPointerEventData(e);if(!t)return;this.drag.x=t.clientX,this.drag.y=t.clientY;let n={type:y.move,srcEvent:e,target:t.target,...this.drag};this._emitter.emit(n.type,n)}_onCancel(e){if(!this.drag)return;let t=this._getTrackedPointerEventData(e);if(!t)return;this.drag.x=t.clientX,this.drag.y=t.clientY;let n={type:y.cancel,srcEvent:e,target:t.target,...this.drag};this._emitter.emit(n.type,n),this._resetDrag()}_onEnd(e){if(!this.drag)return;let t=this._getTrackedPointerEventData(e);if(!t)return;this.drag.x=t.clientX,this.drag.y=t.clientY;let n={type:y.end,srcEvent:e,target:t.target,...this.drag};this._emitter.emit(n.type,n),this._resetDrag()}_bindWindowListeners(){if(this._areWindowListenersBound)return;let{move:e,end:t,cancel:n}=q[this._sourceEvents];window.addEventListener(e,this._onMove,this._listenerOptions),window.addEventListener(t,this._onEnd,this._listenerOptions),n&&window.addEventListener(n,this._onCancel,this._listenerOptions),this._areWindowListenersBound=!0}_unbindWindowListeners(){if(this._areWindowListenersBound){let{move:e,end:t,cancel:n}=q[this._sourceEvents];window.removeEventListener(e,this._onMove,this._listenerOptions),window.removeEventListener(t,this._onEnd,this._listenerOptions),n&&window.removeEventListener(n,this._onCancel,this._listenerOptions),this._areWindowListenersBound=!1}}_resetDrag(){this.drag=null,this._unbindWindowListeners()}cancel(){if(!this.drag)return;let e={type:y.cancel,srcEvent:null,target:null,...this.drag};this._emitter.emit(e.type,e),this._resetDrag()}updateSettings(e){if(this.isDestroyed)return;let{listenerOptions:t,sourceEvents:n,startPredicate:i}=e,o=pe(n),s=ue(t);i&&this._startPredicate!==i&&(this._startPredicate=i),(t&&(this._listenerOptions.capture!==s.capture||this._listenerOptions.passive===s.passive)||n&&this._sourceEvents!==o)&&(this.element.removeEventListener(q[this._sourceEvents].start,this._onStart,this._listenerOptions),this._unbindWindowListeners(),this.cancel(),n&&(this._sourceEvents=o),t&&s&&(this._listenerOptions=s),this.element.addEventListener(q[this._sourceEvents].start,this._onStart,this._listenerOptions))}on(e,t,n){return this._emitter.on(e,t,n)}off(e,t){this._emitter.off(e,t)}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.cancel(),this._emitter.emit(y.destroy,{type:y.destroy}),this._emitter.off(),this.element.removeEventListener(q[this._sourceEvents].start,this._onStart,this._listenerOptions))}};var qe=class extends W{constructor(e={}){super();let{moveDistance:t=25,startPredicate:n=l=>{if((l.key==="Enter"||l.key===" ")&&document.activeElement&&document.activeElement!==document.body){let{left:a,top:c}=document.activeElement.getBoundingClientRect();return{x:a,y:c}}return null},movePredicate:i=(l,a,c)=>{if(!a.drag)return null;switch(l.key){case"ArrowLeft":return{x:a.drag.x-c.x,y:a.drag.y};case"ArrowRight":return{x:a.drag.x+c.x,y:a.drag.y};case"ArrowUp":return{x:a.drag.x,y:a.drag.y-c.y};case"ArrowDown":return{x:a.drag.x,y:a.drag.y+c.y};default:return null}},cancelPredicate:o=(l,a)=>a.drag&&l.key==="Escape"?{x:a.drag.x,y:a.drag.y}:null,endPredicate:s=(l,a)=>a.drag&&(l.key==="Enter"||l.key===" ")?{x:a.drag.x,y:a.drag.y}:null}=e;this._moveDistance=typeof t=="number"?{x:t,y:t}:{...t},this._startPredicate=n,this._movePredicate=i,this._cancelPredicate=o,this._endPredicate=s,this.cancel=this.cancel.bind(this),this._onKeyDown=this._onKeyDown.bind(this),document.addEventListener("keydown",this._onKeyDown),window.addEventListener("blur",this.cancel),window.addEventListener("visibilitychange",this.cancel)}_onKeyDown(e){if(!this.drag){let o=this._startPredicate(e,this,this._moveDistance);o&&(e.preventDefault(),this._start({type:"start",x:o.x,y:o.y,srcEvent:e}));return}let t=this._cancelPredicate(e,this,this._moveDistance);if(t){e.preventDefault(),this._cancel({type:"cancel",x:t.x,y:t.y,srcEvent:e});return}let n=this._endPredicate(e,this,this._moveDistance);if(n){e.preventDefault(),this._end({type:"end",x:n.x,y:n.y,srcEvent:e});return}let i=this._movePredicate(e,this,this._moveDistance);if(i){e.preventDefault(),this._move({type:"move",x:i.x,y:i.y,srcEvent:e});return}}updateSettings(e={}){e.moveDistance!==void 0&&(typeof e.moveDistance=="number"?(this._moveDistance.x=e.moveDistance,this._moveDistance.y=e.moveDistance):(this._moveDistance.x=e.moveDistance.x,this._moveDistance.y=e.moveDistance.y)),e.startPredicate!==void 0&&(this._startPredicate=e.startPredicate),e.movePredicate!==void 0&&(this._movePredicate=e.movePredicate),e.cancelPredicate!==void 0&&(this._cancelPredicate=e.cancelPredicate),e.endPredicate!==void 0&&(this._endPredicate=e.endPredicate)}destroy(){this.isDestroyed||(super.destroy(),document.removeEventListener("keydown",this._onKeyDown),window.removeEventListener("blur",this.cancel),window.removeEventListener("visibilitychange",this.cancel))}};var at=["start","cancel","end","moveLeft","moveRight","moveUp","moveDown"];function Q(r,e){if(!r.size||!e.size)return 1/0;let t=1/0;for(let n of r){let i=e.get(n);i!==void 0&&i<t&&(t=i)}return t}var Xe=class extends ${constructor(e={}){super();let{startPredicate:t=()=>{if(document.activeElement){let{left:m,top:b}=document.activeElement.getBoundingClientRect();return{x:m,y:b}}return null},computeSpeed:n=()=>500,startKeys:i=[" ","Enter"],moveLeftKeys:o=["ArrowLeft"],moveRightKeys:s=["ArrowRight"],moveUpKeys:l=["ArrowUp"],moveDownKeys:a=["ArrowDown"],cancelKeys:c=["Escape"],endKeys:d=[" ","Enter"]}=e;this._computeSpeed=n,this._startPredicate=t,this._startKeys=new Set(i),this._cancelKeys=new Set(c),this._endKeys=new Set(d),this._moveLeftKeys=new Set(o),this._moveRightKeys=new Set(s),this._moveUpKeys=new Set(l),this._moveDownKeys=new Set(a),this._moveKeys=new Set([...o,...s,...l,...a]),this._moveKeyTimestamps=new Map,this._onKeyDown=this._onKeyDown.bind(this),this._onKeyUp=this._onKeyUp.bind(this),this._onTick=this._onTick.bind(this),this.on("tick",this._onTick,this._onTick),document.addEventListener("keydown",this._onKeyDown),document.addEventListener("keyup",this._onKeyUp),window.addEventListener("blur",this.cancel),window.addEventListener("visibilitychange",this.cancel)}_end(e){this.drag&&(this._moveKeyTimestamps.clear(),this._direction.x=0,this._direction.y=0,super._end(e))}_cancel(e){this.drag&&(this._moveKeyTimestamps.clear(),this._direction.x=0,this._direction.y=0,super._cancel(e))}_updateDirection(){let e=Q(this._moveLeftKeys,this._moveKeyTimestamps),t=Q(this._moveRightKeys,this._moveKeyTimestamps),n=Q(this._moveUpKeys,this._moveKeyTimestamps),i=Q(this._moveDownKeys,this._moveKeyTimestamps),o=e===t?0:e<t?-1:1,s=n===i?0:n<i?-1:1;if(!(o===0||s===0)){let l=1/(Math.sqrt(o*o+s*s)||1);o*=l,s*=l}this._direction.x=o,this._direction.y=s}_onTick(){this._speed=this._computeSpeed(this)}_onKeyUp(e){this._moveKeyTimestamps.get(e.key)&&(this._moveKeyTimestamps.delete(e.key),this._updateDirection())}_onKeyDown(e){if(!this.drag){if(this._startKeys.has(e.key)){let t=this._startPredicate(e,this);t&&(e.preventDefault(),this._start({type:"start",x:t.x,y:t.y}))}return}if(this._cancelKeys.has(e.key)){e.preventDefault(),this._cancel({type:"cancel",x:this.drag.x,y:this.drag.y});return}if(this._endKeys.has(e.key)){e.preventDefault(),this._end({type:"end",x:this.drag.x,y:this.drag.y});return}if(this._moveKeys.has(e.key)){e.preventDefault(),this._moveKeyTimestamps.get(e.key)||(this._moveKeyTimestamps.set(e.key,Date.now()),this._updateDirection());return}}updateSettings(e={}){let t=!1;if(e.startPredicate!==void 0&&(this._startPredicate=e.startPredicate),e.computeSpeed!==void 0&&(this._computeSpeed=e.computeSpeed),at.forEach((n,i)=>{let o=`${n}Keys`,s=e[o];s!==void 0&&(this[`_${o}`]=new Set(s),i>=3&&(t=!0))}),t){let n=[...this._moveLeftKeys,...this._moveRightKeys,...this._moveUpKeys,...this._moveDownKeys];[...this._moveKeys].every((o,s)=>n[s]===o)||(this._moveKeys=new Set(n),this._moveKeyTimestamps.clear(),this._updateDirection())}}destroy(){this.isDestroyed||(super.destroy(),this.off("tick",this._onTick),document.removeEventListener("keydown",this._onKeyDown),document.removeEventListener("keyup",this._onKeyUp),window.removeEventListener("blur",this.cancel),window.removeEventListener("visibilitychange",this.cancel))}};import{Emitter as ht}from"eventti";var Z=class{constructor(e,t){this.sensor=e,this.isEnded=!1,this.event=t,this.prevEvent=t,this.startEvent=t,this.endEvent=null,this.items=[]}};import{getOffsetContainer as Ve}from"mezr";var Ne=new WeakMap;function ee(r){let e=Ne.get(r)?.deref();return e||(e=window.getComputedStyle(r,null),Ne.set(r,new WeakRef(e))),e}import{getOffset as Ye}from"mezr";function te(r,e,t={left:0,top:0}){if(t.left=0,t.top=0,r===e)return t;let n=Ye([r,"padding"]),i=Ye([e,"padding"]);return t.left=i.left-n.left,t.top=i.top-n.top,t}var lt={left:0,top:0},ct="matrix(1, 0, 0, 1, 0, 0)",dt="matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)",ne=class{constructor(e,t){if(!e.isConnected)throw new Error("Element is not connected");let n=t.drag?.sensor;if(!n)throw new Error("Sensor is not defined");let i=this,o=ee(e),s=e.getBoundingClientRect();this.data={},this.element=e,this.frozenProps=null,this.unfrozenProps=null,this.position={x:0,y:0},this._updateDiff={x:0,y:0},this._moveDiff={x:0,y:0},this._containerDiff={x:0,y:0};let l=e.parentElement;if(!l)throw new Error("Element does not have a parent element.");this.elementContainer=l;let a=Ve(e);if(!a)throw new Error("Offset container could not be computed for the element!");this.elementOffsetContainer=a;let c=t.settings.container||l;this.dragContainer=c;let d=c===l?a:Ve(e,{container:c});if(!d)throw new Error("Drag offset container could not be computed for the element!");this.dragOffsetContainer=d;{let{left:_,top:p,width:g,height:x}=s;this.clientRect={left:_,top:p,width:g,height:x}}if(a!==d){let{left:_,top:p}=te(d,a,lt);this._containerDiff.x=_,this._containerDiff.y=p}let{transform:m}=o;m&&m!=="none"&&m!==ct&&m!==dt?this.initialTransform=m:this.initialTransform="";let{x:b,y:v}=t.settings.getStartPosition({draggable:t,sensor:n,item:i,style:o});this.position.x=b,this.position.y=v;let S=t.settings.getFrozenProps({draggable:t,sensor:n,item:i,style:o});if(Array.isArray(S))if(S.length){let _={};for(let p of S)_[p]=o[p];this.frozenProps=_}else this.frozenProps=null;else this.frozenProps=S;if(this.frozenProps){let _={};for(let p in this.frozenProps)this.frozenProps.hasOwnProperty(p)&&(_[p]=e.style[p]);this.unfrozenProps=_}}updateSize(e){if(e)this.clientRect.width=e.width,this.clientRect.height=e.height;else{let t=this.element.getBoundingClientRect();this.clientRect.width=t.width,this.clientRect.height=t.height}}};var Ue=J?{capture:!0,passive:!0}:!0,mt={left:0,top:0},fe={x:0,y:0};function ut(){return{container:null,startPredicate:()=>!0,getElements:()=>null,releaseElements:()=>null,getFrozenProps:()=>null,getStartPosition:()=>({x:0,y:0}),setPosition:({item:r,x:e,y:t})=>{r.element.style.transform=`translate(${e}px, ${t}px) ${r.initialTransform}`},getPositionChange:({event:r,prevEvent:e})=>(fe.x=r.x-e.x,fe.y=r.y-e.y,fe)}}var ze=class{constructor(e,t={}){this.sensors=e,this.settings=this._parseSettings(t),this.plugins={},this.drag=null,this.isDestroyed=!1,this._sensorData=new Map,this._emitter=new ht,this._startId=Symbol(),this._moveId=Symbol(),this._updateId=Symbol(),this._onMove=this._onMove.bind(this),this._onScroll=this._onScroll.bind(this),this._onEnd=this._onEnd.bind(this),this._prepareStart=this._prepareStart.bind(this),this._applyStart=this._applyStart.bind(this),this._prepareMove=this._prepareMove.bind(this),this._applyMove=this._applyMove.bind(this),this._preparePositionUpdate=this._preparePositionUpdate.bind(this),this._applyPositionUpdate=this._applyPositionUpdate.bind(this),this.sensors.forEach(n=>{this._sensorData.set(n,{predicateState:0,predicateEvent:null,onMove:s=>this._onMove(s,n),onEnd:s=>this._onEnd(s,n)});let{onMove:i,onEnd:o}=this._sensorData.get(n);n.on("start",i,i),n.on("move",i,i),n.on("cancel",o,o),n.on("end",o,o),n.on("destroy",o,o)})}_parseSettings(e,t=ut()){let{container:n=t.container,startPredicate:i=t.startPredicate,getElements:o=t.getElements,releaseElements:s=t.releaseElements,getFrozenProps:l=t.getFrozenProps,getStartPosition:a=t.getStartPosition,setPosition:c=t.setPosition,getPositionChange:d=t.getPositionChange}=e||{};return{container:n,startPredicate:i,getElements:o,releaseElements:s,getFrozenProps:l,getStartPosition:a,setPosition:c,getPositionChange:d}}_emit(e,...t){this._emitter.emit(e,...t)}_onMove(e,t){let n=this._sensorData.get(t);if(n)switch(n.predicateState){case 0:{n.predicateEvent=e;let i=this.settings.startPredicate({draggable:this,sensor:t,event:e});i===!0?this.resolveStartPredicate(t):i===!1&&this.rejectStartPredicate(t);break}case 1:{this.drag&&(this.drag.event=e,u.once(E,this._prepareMove,this._moveId),u.once(D,this._applyMove,this._moveId));break}}}_onScroll(){this.updatePosition()}_onEnd(e,t){let n=this._sensorData.get(t);n&&(this.drag?n.predicateState===1&&(this.drag.endEvent=e,this._sensorData.forEach(i=>{i.predicateState=0,i.predicateEvent=null}),this.stop()):(n.predicateState=0,n.predicateEvent=null))}_prepareStart(){let e=this.drag;if(!e)return;let t=this.settings.getElements({draggable:this,sensor:e.sensor,startEvent:e.startEvent})||[];e.items=t.map(n=>new ne(n,this)),this._emit("preparestart",e.startEvent)}_applyStart(){let e=this.drag;if(!e)return;let{container:t}=this.settings;for(let n of e.items)t&&n.element.parentElement!==t&&(t.appendChild(n.element),n.position.x+=n._containerDiff.x,n.position.y+=n._containerDiff.y),n.frozenProps&&Object.assign(n.element.style,n.frozenProps),this.settings.setPosition({phase:"start",draggable:this,sensor:e.sensor,item:n,x:n.position.x,y:n.position.y});window.addEventListener("scroll",this._onScroll,Ue),this._emit("start",e.startEvent)}_prepareMove(){let e=this.drag;if(!e)return;let{event:t,prevEvent:n,startEvent:i,sensor:o}=e;if(t!==n){for(let s of e.items){let{x:l,y:a}=this.settings.getPositionChange({draggable:this,sensor:o,item:s,event:t,prevEvent:n,startEvent:i});l&&(s.position.x+=l,s.clientRect.left+=l,s._moveDiff.x+=l),a&&(s.position.y+=a,s.clientRect.top+=a,s._moveDiff.y+=a)}e.prevEvent=t,this._emit("preparemove",t)}}_applyMove(){let e=this.drag;if(e){for(let t of e.items)t._moveDiff.x=0,t._moveDiff.y=0,this.settings.setPosition({phase:"move",draggable:this,sensor:e.sensor,item:t,x:t.position.x,y:t.position.y});e.event&&this._emit("move",e.event)}}_preparePositionUpdate(){let{drag:e}=this;if(e)for(let t of e.items){if(t.elementOffsetContainer!==t.dragOffsetContainer){let{left:c,top:d}=te(t.dragOffsetContainer,t.elementOffsetContainer,mt);t._containerDiff.x=c,t._containerDiff.y=d}let{left:n,top:i,width:o,height:s}=t.element.getBoundingClientRect(),l=t.clientRect.left-t._moveDiff.x-n;t.position.x=t.position.x-t._updateDiff.x+l,t._updateDiff.x=l;let a=t.clientRect.top-t._moveDiff.y-i;t.position.y=t.position.y-t._updateDiff.y+a,t._updateDiff.y=a,t.clientRect.width=o,t.clientRect.height=s}}_applyPositionUpdate(){let{drag:e}=this;if(e)for(let t of e.items)t._updateDiff.x=0,t._updateDiff.y=0,this.settings.setPosition({phase:"move",draggable:this,sensor:e.sensor,item:t,x:t.position.x,y:t.position.y})}on(e,t,n){return this._emitter.on(e,t,n)}off(e,t){this._emitter.off(e,t)}resolveStartPredicate(e,t){let n=this._sensorData.get(e);if(!n)return;let i=t||n.predicateEvent;n.predicateState===0&&i&&(n.predicateState=1,n.predicateEvent=null,this.drag=new Z(e,i),this._sensorData.forEach((o,s)=>{s!==e&&(o.predicateState=2,o.predicateEvent=null)}),u.once(E,this._prepareStart,this._startId),u.once(D,this._applyStart,this._startId))}rejectStartPredicate(e){let t=this._sensorData.get(e);t?.predicateState===0&&(t.predicateState=2,t.predicateEvent=null)}stop(){let e=this.drag;if(!e||e.isEnded)return;e.isEnded=!0,u.off(E,this._startId),u.off(D,this._startId),u.off(E,this._moveId),u.off(D,this._moveId),u.off(E,this._updateId),u.off(D,this._updateId),window.removeEventListener("scroll",this._onScroll,Ue);let t=[];for(let n of e.items){if(t.push(n.element),n.elementContainer&&n.element.parentElement!==n.elementContainer&&(n.position.x-=n._containerDiff.x,n.position.y-=n._containerDiff.y,n._containerDiff.x=0,n._containerDiff.y=0,n.elementContainer.appendChild(n.element)),n.unfrozenProps)for(let i in n.unfrozenProps)n.element.style[i]=n.unfrozenProps[i]||"";this.settings.setPosition({phase:"end",draggable:this,sensor:e.sensor,item:n,x:n.position.x,y:n.position.y})}t.length&&this.settings.releaseElements({draggable:this,sensor:e.sensor,elements:t}),this._emit("end",e.endEvent),this.drag=null}updatePosition(e=!1){this.drag&&(e?(this._preparePositionUpdate(),this._applyPositionUpdate()):(u.once(E,this._preparePositionUpdate,this._updateId),u.once(D,this._applyPositionUpdate,this._updateId)))}updateSettings(e={}){this.settings=this._parseSettings(e,this.settings)}use(e){return e(this)}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.stop(),this._sensorData.forEach(({onMove:e,onEnd:t},n)=>{n.off("start",e),n.off("move",e),n.off("cancel",t),n.off("end",t),n.off("destroy",t)}),this._sensorData.clear(),this._emit("destroy"),this._emitter.off())}};import{Emitter as ft}from"eventti";import{getDistance as gt,getRect as He}from"mezr";var B=class{constructor(e,t){this._data=[],this._createObject=e,this._onPut=t}pick(){return this._data.length?this._data.pop():this._createObject()}put(e){this._data.indexOf(e)===-1&&(this._onPut&&this._onPut(e),this._data.push(e))}reset(){this._data.length=0}};import{getIntersection as pt}from"mezr";function Be(r,e){let t=pt(r,e);return t?t.width*t.height:0}function ge(r,e){let t=Be(r,e);if(!t)return 0;let n=Math.min(r.width,e.width)*Math.min(r.height,e.height);return t/n*100}function w(r){return r instanceof Window}function Se(r){return w(r)||r===document.documentElement||r===document.body?window:r}function N(r){return w(r)?r.pageXOffset:r.scrollLeft}function Ee(r){return w(r)&&(r=document.documentElement),r.scrollWidth-r.clientWidth}function Y(r){return w(r)?r.pageYOffset:r.scrollTop}function ve(r){return w(r)&&(r=document.documentElement),r.scrollHeight-r.clientHeight}function _e(r,e){return!(r.right<=e.left||e.right<=r.left||r.bottom<=e.top||e.bottom<=r.top)}var xe={width:0,height:0,left:0,right:0,top:0,bottom:0},Ge={...xe},Fe=50,I={direction:"none",threshold:0,distance:0,value:0,maxValue:0,duration:0,speed:0,deltaTime:0,isEnding:!1},h={x:1,y:2},M={forward:4,reverse:8},re={none:0,left:h.x|M.reverse,right:h.x|M.forward},H={none:0,up:h.y|M.reverse,down:h.y|M.forward},f={...re,...H};function ye(r){switch(r){case re.none:case H.none:return"none";case re.left:return"left";case re.right:return"right";case H.up:return"up";case H.down:return"down";default:throw new Error(`Unknown direction value: ${r}`)}}function je(r,e,t){let{left:n=0,right:i=0,top:o=0,bottom:s=0}=e;return n=Math.max(0,n),i=Math.max(0,i),o=Math.max(0,o),s=Math.max(0,s),t.width=r.width+n+i,t.height=r.height+o+s,t.left=r.left-n,t.top=r.top-o,t.right=r.right+i,t.bottom=r.bottom+s,t}function ie(r,e){return Math.ceil(r)>=Math.floor(e)}function be(r,e){return Math.min(e/2,r)}function De(r,e,t,n){return Math.max(0,t+r*2+n*e-n)/2}var Pe=class{constructor(){this.positionX=0,this.positionY=0,this.directionX=f.none,this.directionY=f.none,this.overlapCheckRequestTime=0}},Te=class{constructor(){this.element=null,this.requestX=null,this.requestY=null,this.scrollLeft=0,this.scrollTop=0}reset(){this.requestX&&(this.requestX.action=null),this.requestY&&(this.requestY.action=null),this.element=null,this.requestX=null,this.requestY=null,this.scrollLeft=0,this.scrollTop=0}addRequest(e){h.x&e.direction?(this.requestX&&this.removeRequest(this.requestX),this.requestX=e):(this.requestY&&this.removeRequest(this.requestY),this.requestY=e),e.action=this}removeRequest(e){this.requestX===e?(this.requestX=null,e.action=null):this.requestY===e&&(this.requestY=null,e.action=null)}computeScrollValues(){this.element&&(this.scrollLeft=this.requestX?this.requestX.value:N(this.element),this.scrollTop=this.requestY?this.requestY.value:Y(this.element))}scroll(){this.element&&(this.element.scrollTo?this.element.scrollTo(this.scrollLeft,this.scrollTop):(this.element.scrollLeft=this.scrollLeft,this.element.scrollTop=this.scrollTop))}},we=class{constructor(){this.item=null,this.element=null,this.isActive=!1,this.isEnding=!1,this.direction=0,this.value=NaN,this.maxValue=0,this.threshold=0,this.distance=0,this.deltaTime=0,this.speed=0,this.duration=0,this.action=null}reset(){this.isActive&&this.onStop(),this.item=null,this.element=null,this.isActive=!1,this.isEnding=!1,this.direction=0,this.value=NaN,this.maxValue=0,this.threshold=0,this.distance=0,this.deltaTime=0,this.speed=0,this.duration=0,this.action=null}hasReachedEnd(){return M.forward&this.direction?ie(this.value,this.maxValue):this.value<=0}computeCurrentScrollValue(){return this.element?this.value!==this.value?h.x&this.direction?N(this.element):Y(this.element):Math.max(0,Math.min(this.value,this.maxValue)):0}computeNextScrollValue(){let e=this.speed*(this.deltaTime/1e3),t=M.forward&this.direction?this.value+e:this.value-e;return Math.max(0,Math.min(t,this.maxValue))}computeSpeed(){if(!this.item||!this.element)return 0;let{speed:e}=this.item;return typeof e=="function"?(I.direction=ye(this.direction),I.threshold=this.threshold,I.distance=this.distance,I.value=this.value,I.maxValue=this.maxValue,I.duration=this.duration,I.speed=this.speed,I.deltaTime=this.deltaTime,I.isEnding=this.isEnding,e(this.element,I)):e}tick(e){return this.isActive||(this.isActive=!0,this.onStart()),this.deltaTime=e,this.value=this.computeCurrentScrollValue(),this.speed=this.computeSpeed(),this.value=this.computeNextScrollValue(),this.duration+=e,this.value}onStart(){if(!this.item||!this.element)return;let{onStart:e}=this.item;typeof e=="function"&&e(this.element,ye(this.direction))}onStop(){if(!this.item||!this.element)return;let{onStop:e}=this.item;typeof e=="function"&&e(this.element,ye(this.direction))}};function $e(r=500,e=.5,t=.25){let n=r*(e>0?1/e:1/0),i=r*(t>0?1/t:1/0);return function(o,s){let l=0;if(!s.isEnding)if(s.threshold>0){let d=s.threshold-Math.max(0,s.distance);l=r/s.threshold*d}else l=r;let a=s.speed;if(a===l)return l;let c=l;return a<l?(c=a+n*(s.deltaTime/1e3),Math.min(l,c)):(c=a-i*(s.deltaTime/1e3),Math.max(l,c))}}var oe=class{constructor(e={}){let{overlapCheckInterval:t=150}=e;this.items=[],this.settings={overlapCheckInterval:t},this._actions=[],this._isDestroyed=!1,this._isTicking=!1,this._tickTime=0,this._tickDeltaTime=0,this._requests={[h.x]:new Map,[h.y]:new Map},this._itemData=new Map,this._requestPool=new B(()=>new we,n=>n.reset()),this._actionPool=new B(()=>new Te,n=>n.reset()),this._emitter=new ft,this._frameRead=this._frameRead.bind(this),this._frameWrite=this._frameWrite.bind(this)}_frameRead(e){this._isDestroyed||(e&&this._tickTime?(this._tickDeltaTime=e-this._tickTime,this._tickTime=e,this._updateItems(),this._updateRequests(),this._updateActions()):(this._tickTime=e,this._tickDeltaTime=0))}_frameWrite(){this._isDestroyed||this._applyActions()}_startTicking(){this._isTicking||(this._isTicking=!0,u.on(E,this._frameRead,this._frameRead),u.on(D,this._frameWrite,this._frameWrite))}_stopTicking(){this._isTicking&&(this._isTicking=!1,this._tickTime=0,this._tickDeltaTime=0,u.off(E,this._frameRead),u.off(D,this._frameWrite))}_getItemClientRect(e,t={width:0,height:0,left:0,right:0,top:0,bottom:0}){let{clientRect:n}=e;return t.left=n.left,t.top=n.top,t.width=n.width,t.height=n.height,t.right=n.left+n.width,t.bottom=n.top+n.height,t}_requestItemScroll(e,t,n,i,o,s,l){let a=this._requests[t],c=a.get(e);c?(c.element!==n||c.direction!==i)&&c.reset():(c=this._requestPool.pick(),a.set(e,c)),c.item=e,c.element=n,c.direction=i,c.threshold=o,c.distance=s,c.maxValue=l}_cancelItemScroll(e,t){let n=this._requests[t],i=n.get(e);i&&(i.action&&i.action.removeRequest(i),this._requestPool.put(i),n.delete(e))}_checkItemOverlap(e,t,n){let{inertAreaSize:i,targets:o}=e;if(!o.length){t&&this._cancelItemScroll(e,h.x),n&&this._cancelItemScroll(e,h.y);return}let s=this._itemData.get(e),l=s?.directionX,a=s?.directionY;if(!l&&!a){t&&this._cancelItemScroll(e,h.x),n&&this._cancelItemScroll(e,h.y);return}let c=this._getItemClientRect(e,xe),d=null,m=-1/0,b=0,v=-1/0,S=f.none,_=0,p=0,g=null,x=-1/0,V=0,U=-1/0,ae=f.none,Ce=0,Re=0,le=0;for(;le<o.length;le++){let A=o[le],Le=typeof A.threshold=="number"?A.threshold:Fe,ce=!!(t&&l&&A.axis!=="y"),de=!!(n&&a&&A.axis!=="x"),O=A.priority||0;if((!ce||O<m)&&(!de||O<x))continue;let k=Se(A.element||A),F=ce?Ee(k):-1,j=de?ve(k):-1;if(F<=0&&j<=0)continue;let P=He([k,"padding"],window),K=ge(c,P)||-1/0;if(K===-1/0)if(A.padding&&_e(c,je(P,A.padding,Ge)))K=-(gt(c,P)||0);else continue;if(ce&&O>=m&&F>0&&(O>m||K>v)){let T=0,C=f.none,R=be(Le,P.width),z=De(R,i,c.width,P.width);l===f.right?(T=P.right+z-c.right,T<=R&&!ie(N(k),F)&&(C=f.right)):l===f.left&&(T=c.left-(P.left-z),T<=R&&N(k)>0&&(C=f.left)),C&&(d=k,m=O,b=R,v=K,S=C,_=T,p=F)}if(de&&O>=x&&j>0&&(O>x||K>U)){let T=0,C=H.none,R=be(Le,P.height),z=De(R,i,c.height,P.height);a===f.down?(T=P.bottom+z-c.bottom,T<=R&&!ie(Y(k),j)&&(C=f.down)):a===f.up&&(T=c.top-(P.top-z),T<=R&&Y(k)>0&&(C=f.up)),C&&(g=k,x=O,V=R,U=K,ae=C,Ce=T,Re=j)}}t&&(d&&S?this._requestItemScroll(e,h.x,d,S,b,_,p):this._cancelItemScroll(e,h.x)),n&&(g&&ae?this._requestItemScroll(e,h.y,g,ae,V,Ce,Re):this._cancelItemScroll(e,h.y))}_updateScrollRequest(e){let t=e.item,{inertAreaSize:n,smoothStop:i,targets:o}=t,s=this._getItemClientRect(t,xe),l=null,a=0;for(;a<o.length;a++){let c=o[a],d=Se(c.element||c);if(d!==e.element)continue;let m=!!(h.x&e.direction);if(m){if(c.axis==="y")continue}else if(c.axis==="x")continue;let b=m?Ee(d):ve(d);if(b<=0)break;let v=He([d,"padding"],window);if((ge(s,v)||-1/0)===-1/0){let U=c.scrollPadding||c.padding;if(!(U&&_e(s,je(v,U,Ge))))break}let _=typeof c.threshold=="number"?c.threshold:Fe,p=be(_,m?v.width:v.height),g=De(p,n,m?s.width:s.height,m?v.width:v.height),x=0;if(e.direction===f.left?x=s.left-(v.left-g):e.direction===f.right?x=v.right+g-s.right:e.direction===f.up?x=s.top-(v.top-g):x=v.bottom+g-s.bottom,x>p)break;let V=m?N(d):Y(d);if(l=M.forward&e.direction?ie(V,b):V<=0,l)break;return e.maxValue=b,e.threshold=p,e.distance=x,e.isEnding=!1,!0}return i===!0&&e.speed>0?(l===null&&(l=e.hasReachedEnd()),e.isEnding=!l):e.isEnding=!1,e.isEnding}_updateItems(){for(let e=0;e<this.items.length;e++){let t=this.items[e],n=this._itemData.get(t),{x:i,y:o}=t.position,s=n.positionX,l=n.positionY;i===s&&o===l||(n.directionX=i>s?f.right:i<s?f.left:n.directionX,n.directionY=o>l?f.down:o<l?f.up:n.directionY,n.positionX=i,n.positionY=o,n.overlapCheckRequestTime===0&&(n.overlapCheckRequestTime=this._tickTime))}}_updateRequests(){let e=this.items,t=this._requests[h.x],n=this._requests[h.y],i=0;for(;i<e.length;i++){let o=e[i],s=this._itemData.get(o),l=s.overlapCheckRequestTime,a=l>0&&this._tickTime-l>this.settings.overlapCheckInterval,c=!0,d=t.get(o);d&&d.isActive&&(c=!this._updateScrollRequest(d),c&&(a=!0,this._cancelItemScroll(o,h.x)));let m=!0,b=n.get(o);b&&b.isActive&&(m=!this._updateScrollRequest(b),m&&(a=!0,this._cancelItemScroll(o,h.y))),a&&(s.overlapCheckRequestTime=0,this._checkItemOverlap(o,c,m))}}_requestAction(e,t){let n=t===h.x,i=null,o=0;for(;o<this._actions.length;o++){if(i=this._actions[o],e.element!==i.element){i=null;continue}if(n?i.requestX:i.requestY){this._cancelItemScroll(e.item,t);return}break}i||(i=this._actionPool.pick()),i.element=e.element,i.addRequest(e),e.tick(this._tickDeltaTime),this._actions.push(i)}_updateActions(){let e=0;for(e=0;e<this.items.length;e++){let t=this.items[e],n=this._requests[h.x].get(t),i=this._requests[h.y].get(t);n&&this._requestAction(n,h.x),i&&this._requestAction(i,h.y)}for(e=0;e<this._actions.length;e++)this._actions[e].computeScrollValues()}_applyActions(){if(!this._actions.length)return;this._emitter.emit("beforescroll");let e=0;for(e=0;e<this._actions.length;e++)this._actions[e].scroll(),this._actionPool.put(this._actions[e]);this._actions.length=0;let t;for(e=0;e<this.items.length;e++)t=this.items[e],t.onPrepareScrollEffect&&t.onPrepareScrollEffect();for(e=0;e<this.items.length;e++)t=this.items[e],t.onApplyScrollEffect&&t.onApplyScrollEffect();this._emitter.emit("afterscroll")}on(e,t,n){return this._emitter.on(e,t,n)}off(e,t){this._emitter.off(e,t)}addItem(e){if(this._isDestroyed||this._itemData.has(e))return;let{x:t,y:n}=e.position,i=new Pe;i.positionX=t,i.positionY=n,i.directionX=f.none,i.directionY=f.none,i.overlapCheckRequestTime=this._tickTime,this._itemData.set(e,i),this.items.push(e),this._isTicking||this._startTicking()}removeItem(e){if(this._isDestroyed)return;let t=this.items.indexOf(e);t!==-1&&(this._requests[h.x].get(e)&&(this._cancelItemScroll(e,h.x),this._requests[h.x].delete(e)),this._requests[h.y].get(e)&&(this._cancelItemScroll(e,h.y),this._requests[h.y].delete(e)),this._itemData.delete(e),this.items.splice(t,1),this._isTicking&&!this.items.length&&this._stopTicking())}isDestroyed(){return this._isDestroyed}isItemScrollingX(e){return!!this._requests[h.x].get(e)?.isActive}isItemScrollingY(e){return!!this._requests[h.y].get(e)?.isActive}isItemScrolling(e){return this.isItemScrollingX(e)||this.isItemScrollingY(e)}updateSettings(e={}){let{overlapCheckInterval:t=this.settings.overlapCheckInterval}=e;this.settings.overlapCheckInterval=t}destroy(){if(this._isDestroyed)return;let e=this.items.slice(0),t=0;for(;t<e.length;t++)this.removeItem(e[t]);this._actions.length=0,this._requestPool.reset(),this._actionPool.reset(),this._emitter.off(),this._isDestroyed=!0}};var Ie=new oe;var G={x:0,y:0},L={left:0,top:0,width:0,height:0};function St(){return{targets:[],inertAreaSize:.2,speed:$e(),smoothStop:!1,getPosition:r=>{let{drag:e}=r,t=e?.items[0];if(t)G.x=t.position.x,G.y=t.position.y;else{let n=e&&(e.event||e.startEvent);G.x=n?n.x:0,G.y=n?n.y:0}return G},getClientRect:r=>{let{drag:e}=r,t=e?.items[0];if(t&&t.element){let{left:n,top:i,width:o,height:s}=t.clientRect;L.left=n,L.top=i,L.width=o,L.height=s}else{let n=e&&(e.event||e.startEvent);L.left=n?n.x-25:0,L.top=n?n.y-25:0,L.width=n?50:0,L.height=n?50:0}return L},onStart:null,onStop:null}}var Ae=class{constructor(e,t){this._draggableAutoScroll=e,this._draggable=t,this._position={x:0,y:0},this._clientRect={left:0,top:0,width:0,height:0}}_getSettings(){return this._draggableAutoScroll.settings}get targets(){let{targets:e}=this._getSettings();return typeof e=="function"&&(e=e(this._draggable)),e}get position(){let{getPosition:e}=this._getSettings();if(typeof e=="function"){let t=e(this._draggable);this._position.x=t.x,this._position.y=t.y}else this._position.x=0,this._position.y=0;return this._position}get clientRect(){let{getClientRect:e}=this._getSettings();if(typeof e=="function"){let{left:t,top:n,width:i,height:o}=e(this._draggable);this._clientRect.left=t,this._clientRect.top=n,this._clientRect.width=i,this._clientRect.height=o}else this._clientRect.left=0,this._clientRect.top=0,this._clientRect.width=0,this._clientRect.height=0;return this._clientRect}get inertAreaSize(){return this._getSettings().inertAreaSize}get smoothStop(){return this._getSettings().smoothStop}get speed(){return this._getSettings().speed}get onStart(){return this._getSettings().onStart}get onStop(){return this._getSettings().onStop}onPrepareScrollEffect(){let e=this._draggable._updateId;u.off(E,e),u.off(D,e),this._draggable._preparePositionUpdate()}onApplyScrollEffect(){this._draggable._applyPositionUpdate()}},ke=class{constructor(e,t={}){this.name="autoscroll",this.version="0.0.2",this.settings=this._parseSettings(t),this._autoScrollProxy=null,e.on("start",()=>{this._autoScrollProxy||(this._autoScrollProxy=new Ae(this,e),Ie.addItem(this._autoScrollProxy))}),e.on("end",()=>{this._autoScrollProxy&&(Ie.removeItem(this._autoScrollProxy),this._autoScrollProxy=null)})}_parseSettings(e,t=St()){let{targets:n=t.targets,inertAreaSize:i=t.inertAreaSize,speed:o=t.speed,smoothStop:s=t.smoothStop,getPosition:l=t.getPosition,getClientRect:a=t.getClientRect,onStart:c=t.onStart,onStop:d=t.onStop}=e||{};return{targets:n,inertAreaSize:i,speed:o,smoothStop:s,getPosition:l,getClientRect:a,onStart:c,onStop:d}}updateSettings(e={}){this.settings=this._parseSettings(e,this.settings)}};function fr(r){return e=>{let t=new ke(e,r),n=e;return n.plugins[t.name]=t,n}}var Je=new Set(["auto","scroll","overlay"]);function se(r){let e=ee(r);return!!(Je.has(e.overflowY)||Je.has(e.overflowX))}function Qe(r){return r instanceof Document}function Ze(r,e=[]){let t=r?.parentNode;for(;t&&!Qe(t);)t instanceof Element?(se(t)&&e.push(t),t=t.parentNode):t instanceof ShadowRoot?t=t.host:t=t.parentNode;return e.push(window),e}function Et(r){let e=[];return se(r)&&e.push(r),Ze(r,e),e}function wr(r={}){let e,t=0,n=null,i,{timeout:o=250,fallback:s=()=>!0}=r,l=d=>d.preventDefault(),a=d=>{if(t){if(e){d.cancelable&&d.preventDefault();return}e===void 0&&(d.cancelable&&d.timeStamp-t>o?(e=!0,d.preventDefault()):e=!1)}};return d=>{if(!(d.sensor instanceof X))return s(d);let{draggable:m,sensor:b,event:v}=d,S=v;if(S.pointerType==="touch"){if(S.type==="start"&&(S.srcEvent.type==="pointerdown"||S.srcEvent.type==="touchstart")){n=S.target;let _=n?Et(n):[];_.forEach(g=>{g.addEventListener("touchmove",a,{passive:!1,capture:!0})});let p=()=>{t&&(m.off("end",p),m.sensors.forEach(g=>{g instanceof X&&g.off("end",p)}),n?.removeEventListener("contextmenu",l),_.forEach(g=>{g.removeEventListener("touchmove",a,{capture:!0})}),t=0,e=void 0,n=null,i=void window.clearTimeout(i))};e=void 0,t=S.srcEvent.timeStamp,n?.addEventListener("contextmenu",l),m.on("end",p),m.sensors.forEach(g=>{g instanceof X&&g.off("end",p)}),o>0&&(i=window.setTimeout(()=>{m.resolveStartPredicate(b),e=!0,i=void 0},o))}return e}return S.type==="start"&&!S.srcEvent.button}}function vt(r,e){return Math.round(r/e)*e}function et(r,e,t){let n=t-e,i=Math.abs(n);if(i>=r){let o=i%r;return vt(n>0?n-o:n+o,r)}return 0}function Ar(r,e){return function({startEvent:n,event:i,item:o}){let{__snapX__:s=n.x,__snapY__:l=n.y}=o.data,a=et(r,s,i.x),c=et(e,l,i.y);return a&&(o.data.__snapX__=s+a),c&&(o.data.__snapY__=l+c),{x:a,y:c}}}export{h as AUTO_SCROLL_AXIS,M as AUTO_SCROLL_AXIS_DIRECTION,f as AUTO_SCROLL_DIRECTION,oe as AutoScroll,$ as BaseMotionSensor,W as BaseSensor,ze as Draggable,ke as DraggableAutoScroll,Xe as KeyboardMotionSensor,qe as KeyboardSensor,X as PointerSensor,y as SensorEventType,Ie as autoScroll,fr as autoScrollPlugin,$e as autoScrollSmoothSpeed,wr as createPointerSensorStartPredicate,Ar as createSnapModifier,Ct as setTicker,u as ticker,E as tickerReadPhase,D as tickerWritePhase};
{
"name": "dragdoll",
"version": "0.2.0",
"version": "0.3.0",
"description": "Modular and extensible drag & drop system.",

@@ -42,3 +42,3 @@ "keywords": [

"scripts": {
"build": "npm run del-dist && npm run ts-check && npm run format && npm run build-lib && npm run build-tests && npm run build-examples && npm run size",
"build": "npm run del-dist && npm run ts-check && npm run build-lib && npm run build-tests && npm run build-examples && npm run format && npm run size",
"build-lib": "tsup --config ./tsup.config.lib.ts",

@@ -57,37 +57,36 @@ "build-tests": "tsup --config ./tsup.config.tests.ts",

"test-browserstack": "karma start karma.browserstack.cjs",
"test-node": "mocha tests/dist/tests.js",
"ts-check": "tsc --noEmit"
},
"devDependencies": {
"@parcel/config-default": "2.10.3",
"@types/chai": "4.3.11",
"@parcel/config-default": "2.12.0",
"@types/chai": "4.3.14",
"@types/mocha": "10.0.6",
"chai": "4.3.10",
"chai": "5.1.0",
"cpy-cli": "5.0.0",
"dotenv": "16.3.1",
"eventti": "3.0.0",
"dotenv": "16.4.5",
"eventti": "4.0.0",
"gzip-size-cli": "5.1.0",
"jsdom": "23.0.1",
"karma": "6.4.2",
"jsdom": "24.0.0",
"karma": "6.4.3",
"karma-browserstack-launcher": "1.6.0",
"karma-chrome-launcher": "3.2.0",
"karma-firefox-launcher": "2.1.2",
"karma-firefox-launcher": "2.1.3",
"karma-mocha": "2.0.1",
"karma-mocha-reporter": "2.2.5",
"mezr": "1.1.0",
"mocha": "10.2.0",
"parcel": "2.10.3",
"prettier": "3.1.1",
"mocha": "10.3.0",
"parcel": "2.12.0",
"prettier": "3.2.5",
"rimraf": "5.0.5",
"tikki": "2.0.0",
"tsup": "8.0.1",
"typescript": "5.3.3",
"vitepress": "1.0.0-rc.32",
"vue": "3.3.12"
"tikki": "3.0.1",
"tsup": "8.0.2",
"typescript": "5.4.3",
"vitepress": "1.0.1",
"vue": "3.4.21"
},
"peerDependencies": {
"eventti": "^3.0.0",
"eventti": "^4.0.0",
"mezr": "^1.1.0",
"tikki": "^2.0.0"
"tikki": "^3.0.1"
}
}

@@ -5,3 +5,3 @@ import { Emitter, EventListenerId } from 'eventti';

import { Rect, RectExtended } from '../types.js';
import { Point, Rect, RectExtended } from '../types.js';

@@ -166,3 +166,3 @@ import { Pool } from '../pool.js';

readonly clientRect: Rect;
readonly position: { x: number; y: number };
readonly position: Point;
readonly inertAreaSize: number;

@@ -546,4 +546,4 @@ readonly smoothStop: boolean;

this._isTicking = true;
ticker.on(tickerReadPhase, this._frameRead);
ticker.on(tickerWritePhase, this._frameWrite);
ticker.on(tickerReadPhase, this._frameRead, this._frameRead);
ticker.on(tickerWritePhase, this._frameWrite, this._frameWrite);
}

@@ -1091,6 +1091,7 @@

on<T extends keyof AutoScrollEventCallbacks>(
eventName: T,
type: T,
listener: AutoScrollEventCallbacks[T],
listenerId?: EventListenerId,
): EventListenerId {
return this._emitter.on(eventName, listener);
return this._emitter.on(type, listener, listenerId);
}

@@ -1101,7 +1102,4 @@

*/
off<T extends keyof AutoScrollEventCallbacks>(
eventName: T,
listener: AutoScrollEventCallbacks[T] | EventListenerId,
): void {
this._emitter.off(eventName, listener);
off<T extends keyof AutoScrollEventCallbacks>(type: T, listenerId: EventListenerId): void {
this._emitter.off(type, listenerId);
}

@@ -1108,0 +1106,0 @@

@@ -1,4 +0,23 @@

import { CSSProperties } from '../types.js';
import { getOffsetContainer } from 'mezr';
export class DraggableDragItem {
import { Sensor } from '../sensors/sensor.js';
import { CSSProperties, Point, Rect } from '../types.js';
import { getStyle } from 'utils/get-style.js';
import { getOffsetDiff } from 'utils/get-offset-diff.js';
import type { Draggable } from './draggable.js';
const OFFSET_DIFF = { left: 0, top: 0 };
const IDENTITY_MATRIX = 'matrix(1, 0, 0, 1, 0, 0)';
const IDENTITY_MATRIX_3D = 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)';
export class DraggableDragItem<
S extends Sensor[] = Sensor[],
E extends S[number]['events'] = S[number]['events'],
> {
data: { [key: string]: any };

@@ -13,40 +32,148 @@ readonly element: HTMLElement | SVGSVGElement;

readonly unfrozenProps: CSSProperties | null;
readonly x: number;
readonly y: number;
readonly pX: number;
readonly pY: number;
readonly _updateDiffX: number;
readonly _updateDiffY: number;
readonly _moveDiffX: number;
readonly _moveDiffY: number;
readonly _containerDiffX: number;
readonly _containerDiffY: number;
readonly clientRect: Rect;
readonly position: Point;
readonly _updateDiff: Point;
readonly _moveDiff: Point;
readonly _containerDiff: Point;
constructor(
element: HTMLElement | SVGSVGElement,
elementContainer: HTMLElement,
elementOffsetContainer: HTMLElement | SVGSVGElement | Window | Document,
dragContainer: HTMLElement,
dragOffsetContainer: HTMLElement | SVGSVGElement | Window | Document,
) {
constructor(element: HTMLElement | SVGSVGElement, draggable: Draggable<S, E>) {
// Make sure the element is in DOM.
// https://developer.mozilla.org/en-US/docs/Web/API/Node/isConnected
if (!element.isConnected) {
throw new Error('Element is not connected');
}
// Make sure sensor is defined.
const sensor = draggable.drag?.sensor;
if (!sensor) {
throw new Error('Sensor is not defined');
}
const item = this;
const style = getStyle(element);
const clientRect = element.getBoundingClientRect();
this.data = {};
this.element = element;
this.frozenProps = null;
this.unfrozenProps = null;
this.position = { x: 0, y: 0 };
this._updateDiff = { x: 0, y: 0 };
this._moveDiff = { x: 0, y: 0 };
this._containerDiff = { x: 0, y: 0 };
// Use element's parent element as the element container.
const elementContainer = element.parentElement;
if (!elementContainer) {
throw new Error('Element does not have a parent element.');
}
this.elementContainer = elementContainer;
// Compute element's offset container.
const elementOffsetContainer = getOffsetContainer(element);
if (!elementOffsetContainer) {
throw new Error('Offset container could not be computed for the element!');
}
this.elementOffsetContainer = elementOffsetContainer;
// Get element's drag parent, default to element's parent element.
const dragContainer = draggable.settings.container || elementContainer;
this.dragContainer = dragContainer;
// Get drag container's offset container.
const dragOffsetContainer =
dragContainer === elementContainer
? elementOffsetContainer
: getOffsetContainer(element, { container: dragContainer });
if (!dragOffsetContainer) {
throw new Error('Drag offset container could not be computed for the element!');
}
this.dragOffsetContainer = dragOffsetContainer;
this.initialTransform = '';
this.frozenProps = null;
this.unfrozenProps = null;
this.x = 0;
this.y = 0;
this.pX = 0;
this.pY = 0;
this._updateDiffX = 0;
this._updateDiffY = 0;
this._moveDiffX = 0;
this._moveDiffY = 0;
this._containerDiffX = 0;
this._containerDiffY = 0;
// Store element's client rect.
{
const { left, top, width, height } = clientRect;
this.clientRect = { left, top, width, height };
}
// If element's offset container is different than drag container's
// offset container let's compute the offset between the offset containers.
if (elementOffsetContainer !== dragOffsetContainer) {
const { left, top } = getOffsetDiff(dragOffsetContainer, elementOffsetContainer, OFFSET_DIFF);
this._containerDiff.x = left;
this._containerDiff.y = top;
}
// Store element's initial transform.
const { transform } = style;
if (
transform &&
transform !== 'none' &&
transform !== IDENTITY_MATRIX &&
transform !== IDENTITY_MATRIX_3D
) {
this.initialTransform = transform;
} else {
this.initialTransform = '';
}
// Get element's initial position. This position is relative to the
// properties the user is using to move the element. For example, if the
// user is using the `translate` transform to move the element then the
// initial position will be relative to the `translate` transform and the
// position here should reflect the transform value delta.
const { x, y } = draggable.settings.getStartPosition({
draggable,
sensor,
item,
style,
});
this.position.x = x;
this.position.y = y;
// Get element's frozen props.
const frozenProps = draggable.settings.getFrozenProps({
draggable,
sensor,
item,
style,
});
if (Array.isArray(frozenProps)) {
if (frozenProps.length) {
const props: CSSProperties = {};
for (const prop of frozenProps) {
props[prop] = style[prop];
}
this.frozenProps = props;
} else {
this.frozenProps = null;
}
} else {
this.frozenProps = frozenProps;
}
// Lastly, let's compute the unfrozen props. We store the current inline
// style values for all frozen props so that we can restore them after the
// drag process is over.
if (this.frozenProps) {
const unfrozenProps: CSSProperties = {};
for (const key in this.frozenProps) {
if (this.frozenProps.hasOwnProperty(key)) {
unfrozenProps[key] = element.style[key];
}
}
this.unfrozenProps = unfrozenProps;
}
}
updateSize(dimensions?: { width: number; height: number }) {
if (dimensions) {
this.clientRect.width = dimensions.width;
this.clientRect.height = dimensions.height;
} else {
const rect = this.element.getBoundingClientRect();
this.clientRect.width = rect.width;
this.clientRect.height = rect.height;
}
}
}

@@ -6,18 +6,16 @@ import { Sensor } from '../sensors/sensor.js';

export class DraggableDrag<S extends Sensor[], E extends S[number]['events']> {
readonly sensor: S[number] | null;
readonly isStarted: boolean;
readonly sensor: S[number];
readonly isEnded: boolean;
readonly startEvent: E['start'] | E['move'] | null;
readonly nextMoveEvent: E['move'] | null;
readonly prevMoveEvent: E['move'] | null;
readonly event: E['start'] | E['move'];
readonly prevEvent: E['start'] | E['move'];
readonly startEvent: E['start'] | E['move'];
readonly endEvent: E['end'] | E['cancel'] | E['destroy'] | null;
readonly items: DraggableDragItem[];
constructor() {
this.sensor = null;
constructor(sensor: S[number], startEvent: E['start'] | E['move']) {
this.sensor = sensor;
this.isEnded = false;
this.isStarted = false;
this.startEvent = null;
this.nextMoveEvent = null;
this.prevMoveEvent = null;
this.event = startEvent;
this.prevEvent = startEvent;
this.startEvent = startEvent;
this.endEvent = null;

@@ -24,0 +22,0 @@ this.items = [];

@@ -5,4 +5,2 @@ import { HAS_PASSIVE_EVENTS } from '../constants.js';

import { getOffsetContainer } from 'mezr';
import { Sensor, SensorEvents } from '../sensors/sensor.js';

@@ -18,10 +16,4 @@

import { getStyle } from '../utils/get-style.js';
import { Writeable, CSSProperties, Point } from '../types.js';
import { Writeable, CSSProperties } from '../types.js';
const IDENTITY_MATRIX = 'matrix(1, 0, 0, 1, 0, 0)';
const IDENTITY_MATRIX_3D = 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)';
const SCROLL_LISTENER_OPTIONS = HAS_PASSIVE_EVENTS ? { capture: true, passive: true } : true;

@@ -83,3 +75,3 @@

sensor: S[number];
item: DraggableDragItem;
item: DraggableDragItem<S, E>;
style: CSSStyleDeclaration;

@@ -90,5 +82,5 @@ }) => CSSProperties | (keyof CSSProperties)[] | null;

sensor: S[number];
item: DraggableDragItem;
item: DraggableDragItem<S, E>;
style: CSSStyleDeclaration;
}) => { x: number; y: number };
}) => Point;
setPosition: (data: {

@@ -98,3 +90,3 @@ draggable: Draggable<S, E>;

phase: 'start' | 'move' | 'end';
item: DraggableDragItem;
item: DraggableDragItem<S, E>;
x: number;

@@ -106,7 +98,7 @@ y: number;

sensor: S[number];
item: DraggableDragItem;
event: E['move'];
item: DraggableDragItem<S, E>;
event: E['start'] | E['move'];
prevEvent: E['start'] | E['move'];
startEvent: E['start'] | E['move'];
}) => { x: number; y: number };
}) => Point;
}

@@ -189,7 +181,7 @@

const { onMove, onEnd } = this._sensorData.get(sensor)!;
sensor.on('start', onMove);
sensor.on('move', onMove);
sensor.on('cancel', onEnd);
sensor.on('end', onEnd);
sensor.on('destroy', onEnd);
sensor.on('start', onMove, onMove);
sensor.on('move', onMove, onMove);
sensor.on('cancel', onEnd, onEnd);
sensor.on('end', onEnd, onEnd);
sensor.on('destroy', onEnd, onEnd);
});

@@ -260,3 +252,3 @@ }

if (this.drag) {
(this.drag as Writeable<DraggableDrag<S, E>>).nextMoveEvent = e as E['move'];
(this.drag as Writeable<DraggableDrag<S, E>>).event = e;
ticker.once(tickerReadPhase, this._prepareMove, this._moveId);

@@ -297,4 +289,4 @@ ticker.once(tickerWritePhase, this._applyMove, this._moveId);

protected _prepareStart() {
const { drag } = this;
if (!drag || !drag.startEvent) return;
const drag: Writeable<DraggableDrag<S, E>> | null = this.drag;
if (!drag) return;

@@ -307,3 +299,3 @@ // Get elements that we'll need to move with the drag.

draggable: this,
sensor: drag.sensor!,
sensor: drag.sensor,
startEvent: drag.startEvent,

@@ -313,116 +305,4 @@ }) || [];

// Create drag items.
(drag as Writeable<DraggableDrag<S, E>>).items = elements.map((element) => {
// Make sure element is in connected (to DOM or shadow DOM).
// https://developer.mozilla.org/en-US/docs/Web/API/Node/isConnected
if (!element.isConnected) {
throw new Error('Element is not connected');
}
// Get element's parent.
const elementContainer = element.parentElement!;
// Get parent's containing block.
const elementOffsetContainer = getOffsetContainer(element);
if (!elementOffsetContainer) {
throw new Error('Offset container could not be computed for the element!');
}
// Get element's drag parent.
const dragContainer = this.settings.container || elementContainer;
// Get drag container's containing block.
const dragOffsetContainer =
dragContainer === elementContainer
? elementOffsetContainer
: getOffsetContainer(element, { container: dragContainer });
if (!dragOffsetContainer) {
throw new Error('Drag offset container could not be computed for the element!');
}
// Create drag item.
const item: Writeable<DraggableDragItem> = new DraggableDragItem(
element,
elementContainer,
elementOffsetContainer,
dragContainer,
dragOffsetContainer,
);
// Compute the element's current clientX/Y.
const clientRect = element.getBoundingClientRect();
item.x = clientRect.left;
item.y = clientRect.top;
// If parent's containing block is different than drag container's
// containing block let's compute the offset difference between the
// containing blocks.
if (elementOffsetContainer !== dragOffsetContainer) {
const { left, top } = getOffsetDiff(
dragOffsetContainer,
elementOffsetContainer,
OFFSET_DIFF,
);
item._containerDiffX = left;
item._containerDiffY = top;
}
// Get element's style declaration.
const style = getStyle(element);
// Store element's initial transform.
const { transform } = style;
if (
transform &&
transform !== 'none' &&
transform !== IDENTITY_MATRIX &&
transform !== IDENTITY_MATRIX_3D
) {
item.initialTransform = transform;
}
// Get element's current elementX/Y.
const { x, y } = this.settings.getStartPosition({
draggable: this,
sensor: drag.sensor!,
item,
style,
});
item.pX = x;
item.pY = y;
// Get element's frozen props.
const frozenProps = this.settings.getFrozenProps({
draggable: this,
sensor: drag.sensor!,
item,
style,
});
if (Array.isArray(frozenProps)) {
if (frozenProps.length) {
const props: CSSProperties = {};
for (const prop of frozenProps) {
props[prop] = style[prop];
}
item.frozenProps = props;
} else {
item.frozenProps = null;
}
} else {
item.frozenProps = frozenProps;
}
// Lastly, let's compute the unfrozen props. We store the current inline
// style values for all frozen props so that we can restore them after the
// drag process is over.
if (item.frozenProps) {
const unfrozenProps: CSSProperties = {};
for (const key in item.frozenProps) {
if (item.frozenProps.hasOwnProperty(key)) {
unfrozenProps[key] = element.style[key];
}
}
item.unfrozenProps = unfrozenProps;
}
return item;
drag.items = elements.map((element) => {
return new DraggableDragItem(element, this);
});

@@ -435,12 +315,12 @@

protected _applyStart() {
const drag = this.drag;
if (!drag || !drag.startEvent) return;
const drag: Writeable<DraggableDrag<S, E>> | null = this.drag;
if (!drag) return;
const { container } = this.settings;
for (const item of drag.items) {
for (const item of drag.items as Writeable<DraggableDragItem<S, E>>[]) {
// Append element within the container element if such is provided.
if (container && item.element.parentElement !== container) {
container.appendChild(item.element);
(item as Writeable<typeof item>).pX += item._containerDiffX;
(item as Writeable<typeof item>).pY += item._containerDiffY;
item.position.x += item._containerDiff.x;
item.position.y += item._containerDiff.y;
}

@@ -457,14 +337,12 @@

draggable: this,
sensor: drag.sensor!,
item,
x: item.pX,
y: item.pY,
sensor: drag.sensor,
item: item as DraggableDragItem<S, E>,
x: item.position.x,
y: item.position.y,
});
}
// Bind scroll listeners.
window.addEventListener('scroll', this._onScroll, SCROLL_LISTENER_OPTIONS);
// Mark drag as started.
(drag as Writeable<DraggableDrag<S, E>>).isStarted = true;
// Emit start event.

@@ -475,20 +353,19 @@ this._emit('start', drag.startEvent);

protected _prepareMove() {
const { drag } = this;
if (!drag || !drag.startEvent) return;
const drag: Writeable<DraggableDrag<S, E>> | null = this.drag;
if (!drag) return;
// Get next event and previous event so we can compute the movement
// difference between the clientX/Y values.
const nextEvent = drag.nextMoveEvent;
const prevEvent = drag.prevMoveEvent || drag.startEvent;
if (!nextEvent || nextEvent === prevEvent) return;
const { event, prevEvent, startEvent, sensor } = drag;
if (event === prevEvent) return;
for (const item of drag.items) {
for (const item of drag.items as Writeable<DraggableDragItem<S, E>>[]) {
// Compute how much x and y needs to be transformed.
const { x: changeX, y: changeY } = this.settings.getPositionChange({
draggable: this,
sensor: drag.sensor!,
item,
startEvent: drag.startEvent,
sensor,
item: item as DraggableDragItem<S, E>,
event,
prevEvent,
event: nextEvent,
startEvent,
});

@@ -498,5 +375,5 @@

if (changeX) {
(item as Writeable<typeof item>).pX = item.pX - item._moveDiffX + changeX;
(item as Writeable<typeof item>).x = item.x - item._moveDiffX + changeX;
(item as Writeable<typeof item>)._moveDiffX = changeX;
item.position.x += changeX;
item.clientRect.left += changeX;
item._moveDiff.x += changeX;
}

@@ -506,5 +383,5 @@

if (changeY) {
(item as Writeable<typeof item>).pY = item.pY - item._moveDiffY + changeY;
(item as Writeable<typeof item>).y = item.y - item._moveDiffY + changeY;
(item as Writeable<typeof item>)._moveDiffY = changeY;
item.position.y += changeY;
item.clientRect.top += changeY;
item._moveDiff.y += changeY;
}

@@ -514,27 +391,24 @@ }

// Store next event as previous event.
(drag as Writeable<DraggableDrag<S, E>>).prevMoveEvent = nextEvent;
(drag as Writeable<DraggableDrag<S, E>>).prevEvent = event;
// Emit preparemove event.
this._emit('preparemove', nextEvent);
this._emit('preparemove', event as E['move']);
}
protected _applyMove() {
const { drag } = this;
if (!drag || !drag.nextMoveEvent) return;
const drag: Writeable<DraggableDrag<S, E>> | null = this.drag;
if (!drag) return;
// Reset movement diff.
for (const item of drag.items) {
(item as Writeable<typeof item>)._moveDiffX = 0;
(item as Writeable<typeof item>)._moveDiffY = 0;
}
// Reset movement diff and move the element.
for (const item of drag.items as Writeable<DraggableDragItem<S, E>>[]) {
item._moveDiff.x = 0;
item._moveDiff.y = 0;
// Move the element.
for (const item of drag.items) {
this.settings.setPosition({
phase: 'move',
draggable: this,
sensor: drag.sensor!,
item,
x: item.pX,
y: item.pY,
sensor: drag.sensor,
item: item as DraggableDragItem<S, E>,
x: item.position.x,
y: item.position.y,
});

@@ -544,3 +418,5 @@ }

// Emit move event.
this._emit('move', drag.nextMoveEvent);
if (drag.event) {
this._emit('move', drag.event as E['move']);
}
}

@@ -552,3 +428,3 @@

for (const item of drag.items) {
for (const item of drag.items as Writeable<DraggableDragItem<S, E>>[]) {
// Update container diff.

@@ -561,17 +437,24 @@ if (item.elementOffsetContainer !== item.dragOffsetContainer) {

);
(item as Writeable<typeof item>)._containerDiffX = left;
(item as Writeable<typeof item>)._containerDiffY = top;
item._containerDiff.x = left;
item._containerDiff.y = top;
}
const { left, top } = item.element.getBoundingClientRect();
const { left, top, width, height } = item.element.getBoundingClientRect();
// Update horizontal position data.
const _updateDiffX = item.x - item._moveDiffX - left;
(item as Writeable<typeof item>).pX = item.pX - item._updateDiffX + _updateDiffX;
(item as Writeable<typeof item>)._updateDiffX = _updateDiffX;
const updateDiffX = item.clientRect.left - item._moveDiff.x - left;
item.position.x = item.position.x - item._updateDiff.x + updateDiffX;
item._updateDiff.x = updateDiffX;
// Update vertical position data.
const _updateDiffY = item.y - item._moveDiffY - top;
(item as Writeable<typeof item>).pY = item.pY - item._updateDiffY + _updateDiffY;
(item as Writeable<typeof item>)._updateDiffY = _updateDiffY;
const updateDiffY = item.clientRect.top - item._moveDiff.y - top;
item.position.y = item.position.y - item._updateDiff.y + updateDiffY;
item._updateDiff.y = updateDiffY;
// Update item client size. This is not necessary for the drag process,
// but since we're computing the bounding client rect, we might as well
// update the size in the process. The size is used by the auto-scroll
// plugin and possibly some other third-party plugins.
item.clientRect.width = width;
item.clientRect.height = height;
}

@@ -584,12 +467,13 @@ }

for (const item of drag.items) {
(item as Writeable<typeof item>)._updateDiffX = 0;
(item as Writeable<typeof item>)._updateDiffY = 0;
for (const item of drag.items as Writeable<DraggableDragItem<S, E>>[]) {
item._updateDiff.x = 0;
item._updateDiff.y = 0;
this.settings.setPosition({
phase: 'move',
draggable: this,
sensor: drag.sensor!,
item,
x: item.pX,
y: item.pY,
sensor: drag.sensor,
item: item as DraggableDragItem<S, E>,
x: item.position.x,
y: item.position.y,
});

@@ -599,15 +483,12 @@ }

on<K extends keyof DraggableEventCallbacks<E>>(
eventName: K,
listener: DraggableEventCallbacks<E>[K],
on<T extends keyof DraggableEventCallbacks<E>>(
type: T,
listener: DraggableEventCallbacks<E>[T],
listenerId?: EventListenerId,
): EventListenerId {
return this._emitter.on(eventName, listener, listenerId);
return this._emitter.on(type, listener, listenerId);
}
off<K extends keyof DraggableEventCallbacks<E>>(
eventName: K,
listener: DraggableEventCallbacks<E>[K] | EventListenerId,
): void {
this._emitter.off(eventName, listener);
off<T extends keyof DraggableEventCallbacks<E>>(type: T, listenerId: EventListenerId): void {
this._emitter.off(type, listenerId);
}

@@ -625,6 +506,5 @@

sensorData.predicateEvent = null;
(this as Writeable<this>).drag = new DraggableDrag();
(this.drag as Writeable<DraggableDrag<S, E>>).sensor = sensor;
(this.drag as Writeable<DraggableDrag<S, E>>).startEvent = startEvent;
(this as Writeable<this>).drag = new DraggableDrag(sensor, startEvent);
// Reject other sensors' start predicates.

@@ -652,7 +532,7 @@ this._sensorData.forEach((data, s) => {

stop() {
const { drag } = this;
const drag: Writeable<DraggableDrag<S, E>> | null = this.drag;
if (!drag || drag.isEnded) return;
// Mark drag process as ended.
(drag as Writeable<DraggableDrag<S, E>>).isEnded = true;
drag.isEnded = true;

@@ -667,48 +547,45 @@ // Cancel all queued ticks.

// If drag process is started.
if (drag.isStarted) {
// Unbind scroll listener.
window.removeEventListener('scroll', this._onScroll, SCROLL_LISTENER_OPTIONS);
// Unbind scroll listener.
window.removeEventListener('scroll', this._onScroll, SCROLL_LISTENER_OPTIONS);
// Move elements within the root container and collect all elements
// to an elements array.
const elements: (HTMLElement | SVGSVGElement)[] = [];
for (const item of drag.items) {
elements.push(item.element);
if (item.elementContainer && item.element.parentElement !== item.elementContainer) {
(item as Writeable<typeof item>).pX -= item._containerDiffX;
(item as Writeable<typeof item>).pY -= item._containerDiffY;
(item as Writeable<typeof item>)._containerDiffX = 0;
(item as Writeable<typeof item>)._containerDiffY = 0;
item.elementContainer.appendChild(item.element);
}
// Move elements within the root container and collect all elements
// to an elements array.
const elements: (HTMLElement | SVGSVGElement)[] = [];
for (const item of drag.items as Writeable<DraggableDragItem<S, E>>[]) {
elements.push(item.element);
if (item.elementContainer && item.element.parentElement !== item.elementContainer) {
item.position.x -= item._containerDiff.x;
item.position.y -= item._containerDiff.y;
item._containerDiff.x = 0;
item._containerDiff.y = 0;
item.elementContainer.appendChild(item.element);
}
// Unfreeze element's props if such are provided.
if (item.unfrozenProps) {
for (const key in item.unfrozenProps) {
item.element.style[key] = item.unfrozenProps[key] || '';
}
// Unfreeze element's props if such are provided.
if (item.unfrozenProps) {
for (const key in item.unfrozenProps) {
item.element.style[key] = item.unfrozenProps[key] || '';
}
// Set final position after drag.
this.settings.setPosition({
phase: 'end',
draggable: this,
sensor: drag.sensor!,
item,
x: item.pX,
y: item.pY,
});
}
// Call "releaseElements" callback.
if (elements.length) {
this.settings.releaseElements({
draggable: this,
sensor: drag.sensor!,
elements,
});
}
// Set final position after drag.
this.settings.setPosition({
phase: 'end',
draggable: this,
sensor: drag.sensor,
item: item as DraggableDragItem<S, E>,
x: item.position.x,
y: item.position.y,
});
}
// Call "releaseElements" callback.
if (elements.length) {
this.settings.releaseElements({
draggable: this,
sensor: drag.sensor!,
elements,
});
}
// Emit end event.

@@ -715,0 +592,0 @@ this._emit('end', drag.endEvent);

@@ -17,3 +17,3 @@ import { ticker, tickerReadPhase, tickerWritePhase } from '../../singletons/ticker.js';

import { Writeable } from '../../types.js';
import { Point, Writeable } from '../../types.js';

@@ -36,8 +36,8 @@ const AUTOSCROLL_POSITION = { x: 0, y: 0 };

if (primaryItem) {
AUTOSCROLL_POSITION.x = primaryItem.pX;
AUTOSCROLL_POSITION.y = primaryItem.pY;
AUTOSCROLL_POSITION.x = primaryItem.position.x;
AUTOSCROLL_POSITION.y = primaryItem.position.y;
}
// Fallback to the sensor's clientX/clientY values.
else {
const e = drag && (drag.nextMoveEvent || drag.startEvent);
const e = drag && (drag.event || drag.startEvent);
AUTOSCROLL_POSITION.x = e ? e.x : 0;

@@ -55,3 +55,3 @@ AUTOSCROLL_POSITION.y = e ? e.y : 0;

if (primaryItem && primaryItem.element) {
const { left, top, width, height } = primaryItem.element.getBoundingClientRect();
const { left, top, width, height } = primaryItem.clientRect;
AUTOSCROLL_CLIENT_RECT.left = left;

@@ -65,3 +65,3 @@ AUTOSCROLL_CLIENT_RECT.top = top;

else {
const e = drag && (drag.nextMoveEvent || drag.startEvent);
const e = drag && (drag.event || drag.startEvent);
AUTOSCROLL_CLIENT_RECT.left = e ? e.x - 25 : 0;

@@ -174,3 +174,3 @@ AUTOSCROLL_CLIENT_RECT.top = e ? e.y - 25 : 0;

smoothStop: boolean;
getPosition: ((draggable: Draggable<S, E>) => { x: number; y: number }) | null;
getPosition: ((draggable: Draggable<S, E>) => Point) | null;
getClientRect:

@@ -177,0 +177,0 @@ | ((draggable: Draggable<S, E>) => {

@@ -24,1 +24,3 @@ export * from './sensors/sensor.js';

export * from './utils/create-pointer-sensor-start-predicate.js';
export * from './utils/create-snap-modifier.js';

@@ -5,3 +5,3 @@ import { Sensor, SensorEvents } from './sensor.js';

import { Writeable } from '../types.js';
import { Point, Writeable } from '../types.js';

@@ -31,3 +31,3 @@ import { ticker, tickerReadPhase } from '../singletons/ticker.js';

readonly drag: BaseMotionSensorDragData | null;
protected _direction: { x: number; y: number };
protected _direction: Point;
protected _speed: number;

@@ -55,3 +55,3 @@

super._start(data);
ticker.on(tickerReadPhase, this._tick);
ticker.on(tickerReadPhase, this._tick, this._tick);
}

@@ -58,0 +58,0 @@

@@ -67,12 +67,12 @@ import { Emitter, Events, EventListenerId } from 'eventti';

on<K extends keyof E>(
eventName: K,
listener: (e: E[K]) => void,
on<T extends keyof E>(
type: T,
listener: (e: E[T]) => void,
listenerId?: EventListenerId,
): EventListenerId {
return this._emitter.on(eventName, listener, listenerId);
return this._emitter.on(type, listener, listenerId);
}
off<K extends keyof E>(eventName: K, listener: ((e: E[K]) => void) | EventListenerId): void {
this._emitter.off(eventName, listener);
off<T extends keyof E>(type: T, listenerId: EventListenerId): void {
this._emitter.off(type, listenerId);
}

@@ -79,0 +79,0 @@

@@ -5,9 +5,8 @@ import { Sensor } from './sensor.js';

import { Point } from 'types.js';
export interface KeyboardMotionSensorSettings<
E extends KeyboardMotionSensorEvents = KeyboardMotionSensorEvents,
> {
startPredicate: (
e: KeyboardEvent,
sensor: KeyboardMotionSensor<E>,
) => { x: number; y: number } | null | undefined;
startPredicate: (e: KeyboardEvent, sensor: KeyboardMotionSensor<E>) => Point | null | undefined;
computeSpeed: (sensor: KeyboardMotionSensor<E>) => number;

@@ -101,3 +100,3 @@ startKeys: string[];

this.on('tick', this._onTick);
this.on('tick', this._onTick, this._onTick);
document.addEventListener('keydown', this._onKeyDown);

@@ -104,0 +103,0 @@ document.addEventListener('keyup', this._onKeyUp);

@@ -12,10 +12,12 @@ import {

import { Point } from 'types.js';
export type KeyboardSensorPredicate = (
e: KeyboardEvent,
sensor: KeyboardSensor,
moveDistance: { x: number; y: number },
) => { x: number; y: number } | null | undefined;
moveDistance: Point,
) => Point | null | undefined;
export interface KeyboardSensorSettings {
moveDistance: number | { x: number; y: number };
moveDistance: number | Point;
startPredicate: KeyboardSensorPredicate;

@@ -58,3 +60,3 @@ movePredicate: KeyboardSensorPredicate;

declare events: E;
protected _moveDistance: { x: number; y: number };
protected _moveDistance: Point;
protected _startPredicate: KeyboardSensorPredicate;

@@ -61,0 +63,0 @@ protected _movePredicate: KeyboardSensorPredicate;

@@ -415,8 +415,8 @@ import { Emitter, Events, EventListenerId } from 'eventti';

*/
on<K extends keyof E>(
eventName: K,
listener: (e: E[K]) => void,
on<T extends keyof E>(
type: T,
listener: (e: E[T]) => void,
listenerId?: EventListenerId,
): EventListenerId {
return this._emitter.on(eventName, listener, listenerId);
return this._emitter.on(type, listener, listenerId);
}

@@ -427,4 +427,4 @@

*/
off<K extends keyof E>(eventName: K, listener: ((e: E[K]) => void) | EventListenerId): void {
this._emitter.off(eventName, listener);
off<T extends keyof E>(type: T, listenerId: EventListenerId): void {
this._emitter.off(type, listenerId);
}

@@ -431,0 +431,0 @@

@@ -0,1 +1,3 @@

import type { EventListenerId } from 'eventti';
export const SensorEventType = {

@@ -47,6 +49,10 @@ start: 'start',

events: E;
on<K extends keyof E>(eventName: K, listener: (eventData: E[K]) => void): void;
off<K extends keyof E>(eventName: K, listener: (eventData: E[K]) => void): void;
on<T extends keyof E>(
type: T,
listener: (eventData: E[T]) => void,
listenerId?: EventListenerId,
): EventListenerId;
off<T extends keyof E>(type: T, listenerId: EventListenerId): void;
cancel(): void;
destroy(): void;
}

@@ -1,15 +0,13 @@

import { Ticker, FrameCallback } from 'tikki';
import { AutoTicker, Phase, FrameCallback } from 'tikki';
import { EventName } from 'eventti';
export let tickerReadPhase: Phase = Symbol();
export let tickerReadPhase: EventName = Symbol();
export let tickerWritePhase: Phase = Symbol();
export let tickerWritePhase: EventName = Symbol();
export let ticker = new AutoTicker<Phase>({ phases: [tickerReadPhase, tickerWritePhase] });
export let ticker = new Ticker<EventName>({ phases: [tickerReadPhase, tickerWritePhase] });
export function setTicker(
newTicker: Ticker<EventName, FrameCallback>,
readPhase: EventName,
writePhase: EventName,
newTicker: AutoTicker<Phase, FrameCallback>,
readPhase: Phase,
writePhase: Phase,
) {

@@ -16,0 +14,0 @@ tickerReadPhase = readPhase;

@@ -7,2 +7,7 @@ export type Writeable<T> = { -readonly [P in keyof T]: T[P] };

export type Point = {
x: number;
y: number;
};
export type Dimensions = {

@@ -9,0 +14,0 @@ width: number;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc