import { n as __esmMin, r as __export, t as __commonJSMin } from "../../rolldown-runtime.mjs";

//#region node_modules/@use-gesture/core/dist/maths-0ab39ae9.esm.js
function clamp(v, min, max) {
	return Math.max(min, Math.min(v, max));
}
function rubberband(distance, dimension, constant) {
	if (dimension === 0 || Math.abs(dimension) === Infinity) return Math.pow(distance, constant * 5);
	return distance * dimension * constant / (dimension + constant * distance);
}
function rubberbandIfOutOfBounds(position, min, max, constant = .15) {
	if (constant === 0) return clamp(position, min, max);
	if (position < min) return -rubberband(min - position, max - min, constant) + min;
	if (position > max) return +rubberband(position - max, max - min, constant) + max;
	return position;
}
function computeRubberband(bounds, [Vx, Vy], [Rx, Ry]) {
	const [[X0, X1], [Y0, Y1]] = bounds;
	return [rubberbandIfOutOfBounds(Vx, X0, X1, Rx), rubberbandIfOutOfBounds(Vy, Y0, Y1, Ry)];
}
var V;
var init_maths_0ab39ae9_esm = __esmMin((() => {
	V = {
		toVector(v, fallback) {
			if (v === void 0) v = fallback;
			return Array.isArray(v) ? v : [v, v];
		},
		add(v1, v2) {
			return [v1[0] + v2[0], v1[1] + v2[1]];
		},
		sub(v1, v2) {
			return [v1[0] - v2[0], v1[1] - v2[1]];
		},
		addTo(v1, v2) {
			v1[0] += v2[0];
			v1[1] += v2[1];
		},
		subTo(v1, v2) {
			v1[0] -= v2[0];
			v1[1] -= v2[1];
		}
	};
}));

//#endregion
//#region node_modules/@use-gesture/core/dist/actions-fe213e88.esm.js
function _toPrimitive(input, hint) {
	if (typeof input !== "object" || input === null) return input;
	var prim = input[Symbol.toPrimitive];
	if (prim !== void 0) {
		var res = prim.call(input, hint || "default");
		if (typeof res !== "object") return res;
		throw new TypeError("@@toPrimitive must return a primitive value.");
	}
	return (hint === "string" ? String : Number)(input);
}
function _toPropertyKey(arg) {
	var key = _toPrimitive(arg, "string");
	return typeof key === "symbol" ? key : String(key);
}
function _defineProperty(obj, key, value) {
	key = _toPropertyKey(key);
	if (key in obj) Object.defineProperty(obj, key, {
		value,
		enumerable: true,
		configurable: true,
		writable: true
	});
	else obj[key] = value;
	return obj;
}
function ownKeys(e, r) {
	var t = Object.keys(e);
	if (Object.getOwnPropertySymbols) {
		var o = Object.getOwnPropertySymbols(e);
		r && (o = o.filter(function(r$1) {
			return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
		})), t.push.apply(t, o);
	}
	return t;
}
function _objectSpread2(e) {
	for (var r = 1; r < arguments.length; r++) {
		var t = null != arguments[r] ? arguments[r] : {};
		r % 2 ? ownKeys(Object(t), !0).forEach(function(r$1) {
			_defineProperty(e, r$1, t[r$1]);
		}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
			Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
		});
	}
	return e;
}
function capitalize(string) {
	if (!string) return "";
	return string[0].toUpperCase() + string.slice(1);
}
function hasCapture(capture = false, actionKey) {
	return capture && !actionsWithoutCaptureSupported.includes(actionKey);
}
function toHandlerProp(device, action = "", capture = false) {
	const deviceProps = EVENT_TYPE_MAP[device];
	const actionKey = deviceProps ? deviceProps[action] || action : action;
	return "on" + capitalize(device) + capitalize(actionKey) + (hasCapture(capture, actionKey) ? "Capture" : "");
}
function parseProp(prop) {
	let eventKey = prop.substring(2).toLowerCase();
	const passive = !!~eventKey.indexOf("passive");
	if (passive) eventKey = eventKey.replace("passive", "");
	const captureKey = pointerCaptureEvents.includes(eventKey) ? "capturecapture" : "capture";
	const capture = !!~eventKey.indexOf(captureKey);
	if (capture) eventKey = eventKey.replace("capture", "");
	return {
		device: eventKey,
		capture,
		passive
	};
}
function toDomEventType(device, action = "") {
	const deviceProps = EVENT_TYPE_MAP[device];
	return device + (deviceProps ? deviceProps[action] || action : action);
}
function isTouch(event) {
	return "touches" in event;
}
function getPointerType(event) {
	if (isTouch(event)) return "touch";
	if ("pointerType" in event) return event.pointerType;
	return "mouse";
}
function getCurrentTargetTouchList(event) {
	return Array.from(event.touches).filter((e) => {
		var _event$currentTarget, _event$currentTarget$;
		return e.target === event.currentTarget || ((_event$currentTarget = event.currentTarget) === null || _event$currentTarget === void 0 || (_event$currentTarget$ = _event$currentTarget.contains) === null || _event$currentTarget$ === void 0 ? void 0 : _event$currentTarget$.call(_event$currentTarget, e.target));
	});
}
function getTouchList(event) {
	return event.type === "touchend" || event.type === "touchcancel" ? event.changedTouches : event.targetTouches;
}
function getValueEvent(event) {
	return isTouch(event) ? getTouchList(event)[0] : event;
}
function distanceAngle(P1, P2) {
	try {
		const dx = P2.clientX - P1.clientX;
		const dy = P2.clientY - P1.clientY;
		const cx = (P2.clientX + P1.clientX) / 2;
		const cy = (P2.clientY + P1.clientY) / 2;
		const distance = Math.hypot(dx, dy);
		return {
			angle: -(Math.atan2(dx, dy) * 180) / Math.PI,
			distance,
			origin: [cx, cy]
		};
	} catch (_unused) {}
	return null;
}
function touchIds(event) {
	return getCurrentTargetTouchList(event).map((touch) => touch.identifier);
}
function touchDistanceAngle(event, ids) {
	const [P1, P2] = Array.from(event.touches).filter((touch) => ids.includes(touch.identifier));
	return distanceAngle(P1, P2);
}
function pointerId(event) {
	const valueEvent = getValueEvent(event);
	return isTouch(event) ? valueEvent.identifier : valueEvent.pointerId;
}
function pointerValues(event) {
	const valueEvent = getValueEvent(event);
	return [valueEvent.clientX, valueEvent.clientY];
}
function wheelValues(event) {
	let { deltaX, deltaY, deltaMode } = event;
	if (deltaMode === 1) {
		deltaX *= LINE_HEIGHT;
		deltaY *= LINE_HEIGHT;
	} else if (deltaMode === 2) {
		deltaX *= PAGE_HEIGHT;
		deltaY *= PAGE_HEIGHT;
	}
	return [deltaX, deltaY];
}
function scrollValues(event) {
	var _ref, _ref2;
	const { scrollX, scrollY, scrollLeft, scrollTop } = event.currentTarget;
	return [(_ref = scrollX !== null && scrollX !== void 0 ? scrollX : scrollLeft) !== null && _ref !== void 0 ? _ref : 0, (_ref2 = scrollY !== null && scrollY !== void 0 ? scrollY : scrollTop) !== null && _ref2 !== void 0 ? _ref2 : 0];
}
function getEventDetails(event) {
	const payload = {};
	if ("buttons" in event) payload.buttons = event.buttons;
	if ("shiftKey" in event) {
		const { shiftKey, altKey, metaKey, ctrlKey } = event;
		Object.assign(payload, {
			shiftKey,
			altKey,
			metaKey,
			ctrlKey
		});
	}
	return payload;
}
function call(v, ...args) {
	if (typeof v === "function") return v(...args);
	else return v;
}
function noop() {}
function chain(...fns) {
	if (fns.length === 0) return noop;
	if (fns.length === 1) return fns[0];
	return function() {
		let result;
		for (const fn of fns) result = fn.apply(this, arguments) || result;
		return result;
	};
}
function assignDefault(value, fallback) {
	return Object.assign({}, fallback, value || {});
}
function selectAxis([dx, dy], threshold) {
	const absDx = Math.abs(dx);
	const absDy = Math.abs(dy);
	if (absDx > absDy && absDx > threshold) return "x";
	if (absDy > absDx && absDy > threshold) return "y";
}
function persistEvent(event) {
	"persist" in event && typeof event.persist === "function" && event.persist();
}
function supportsTouchEvents() {
	return isBrowser && "ontouchstart" in window;
}
function isTouchScreen() {
	return supportsTouchEvents() || isBrowser && window.navigator.maxTouchPoints > 1;
}
function supportsPointerEvents() {
	return isBrowser && "onpointerdown" in window;
}
function supportsPointerLock() {
	return isBrowser && "exitPointerLock" in window.document;
}
function supportsGestureEvents() {
	try {
		return "constructor" in GestureEvent;
	} catch (e) {
		return false;
	}
}
function clampStateInternalMovementToBounds(state) {
	const [ox, oy] = state.overflow;
	const [dx, dy] = state._delta;
	const [dirx, diry] = state._direction;
	if (ox < 0 && dx > 0 && dirx < 0 || ox > 0 && dx < 0 && dirx > 0) state._movement[0] = state._movementBound[0];
	if (oy < 0 && dy > 0 && diry < 0 || oy > 0 && dy < 0 && diry > 0) state._movement[1] = state._movementBound[1];
}
function registerAction(action) {
	EngineMap.set(action.key, action.engine);
	ConfigResolverMap.set(action.key, action.resolver);
}
var EVENT_TYPE_MAP, actionsWithoutCaptureSupported, pointerCaptureEvents, LINE_HEIGHT, PAGE_HEIGHT, BEFORE_LAST_KINEMATICS_DELAY, Engine, CoordinatesEngine, identity, DEFAULT_RUBBERBAND, commonConfigResolver, DEFAULT_AXIS_THRESHOLD, coordinatesConfigResolver, KEYS_DELTA_MAP, DragEngine, isBrowser, SUPPORT, DEFAULT_PREVENT_SCROLL_DELAY, DEFAULT_DRAG_DELAY, DEFAULT_SWIPE_VELOCITY, DEFAULT_SWIPE_DISTANCE, DEFAULT_SWIPE_DURATION, DEFAULT_KEYBOARD_DISPLACEMENT, DEFAULT_DRAG_AXIS_THRESHOLD, dragConfigResolver, SCALE_ANGLE_RATIO_INTENT_DEG, PINCH_WHEEL_RATIO, PinchEngine, pinchConfigResolver, MoveEngine, moveConfigResolver, ScrollEngine, scrollConfigResolver, WheelEngine, wheelConfigResolver, HoverEngine, hoverConfigResolver, EngineMap, ConfigResolverMap, dragAction, hoverAction, moveAction, pinchAction, scrollAction, wheelAction;
var init_actions_fe213e88_esm = __esmMin((() => {
	init_maths_0ab39ae9_esm();
	EVENT_TYPE_MAP = {
		pointer: {
			start: "down",
			change: "move",
			end: "up"
		},
		mouse: {
			start: "down",
			change: "move",
			end: "up"
		},
		touch: {
			start: "start",
			change: "move",
			end: "end"
		},
		gesture: {
			start: "start",
			change: "change",
			end: "end"
		}
	};
	actionsWithoutCaptureSupported = ["enter", "leave"];
	pointerCaptureEvents = ["gotpointercapture", "lostpointercapture"];
	LINE_HEIGHT = 40;
	PAGE_HEIGHT = 800;
	BEFORE_LAST_KINEMATICS_DELAY = 32;
	Engine = class {
		constructor(ctrl, args, key) {
			this.ctrl = ctrl;
			this.args = args;
			this.key = key;
			if (!this.state) {
				this.state = {};
				this.computeValues([0, 0]);
				this.computeInitial();
				if (this.init) this.init();
				this.reset();
			}
		}
		get state() {
			return this.ctrl.state[this.key];
		}
		set state(state) {
			this.ctrl.state[this.key] = state;
		}
		get shared() {
			return this.ctrl.state.shared;
		}
		get eventStore() {
			return this.ctrl.gestureEventStores[this.key];
		}
		get timeoutStore() {
			return this.ctrl.gestureTimeoutStores[this.key];
		}
		get config() {
			return this.ctrl.config[this.key];
		}
		get sharedConfig() {
			return this.ctrl.config.shared;
		}
		get handler() {
			return this.ctrl.handlers[this.key];
		}
		reset() {
			const { state, shared, ingKey, args } = this;
			shared[ingKey] = state._active = state.active = state._blocked = state._force = false;
			state._step = [false, false];
			state.intentional = false;
			state._movement = [0, 0];
			state._distance = [0, 0];
			state._direction = [0, 0];
			state._delta = [0, 0];
			state._bounds = [[-Infinity, Infinity], [-Infinity, Infinity]];
			state.args = args;
			state.axis = void 0;
			state.memo = void 0;
			state.elapsedTime = state.timeDelta = 0;
			state.direction = [0, 0];
			state.distance = [0, 0];
			state.overflow = [0, 0];
			state._movementBound = [false, false];
			state.velocity = [0, 0];
			state.movement = [0, 0];
			state.delta = [0, 0];
			state.timeStamp = 0;
		}
		start(event) {
			const state = this.state;
			const config = this.config;
			if (!state._active) {
				this.reset();
				this.computeInitial();
				state._active = true;
				state.target = event.target;
				state.currentTarget = event.currentTarget;
				state.lastOffset = config.from ? call(config.from, state) : state.offset;
				state.offset = state.lastOffset;
				state.startTime = state.timeStamp = event.timeStamp;
			}
		}
		computeValues(values) {
			const state = this.state;
			state._values = values;
			state.values = this.config.transform(values);
		}
		computeInitial() {
			const state = this.state;
			state._initial = state._values;
			state.initial = state.values;
		}
		compute(event) {
			const { state, config, shared } = this;
			state.args = this.args;
			let dt = 0;
			if (event) {
				state.event = event;
				if (config.preventDefault && event.cancelable) state.event.preventDefault();
				state.type = event.type;
				shared.touches = this.ctrl.pointerIds.size || this.ctrl.touchIds.size;
				shared.locked = !!document.pointerLockElement;
				Object.assign(shared, getEventDetails(event));
				shared.down = shared.pressed = shared.buttons % 2 === 1 || shared.touches > 0;
				dt = event.timeStamp - state.timeStamp;
				state.timeStamp = event.timeStamp;
				state.elapsedTime = state.timeStamp - state.startTime;
			}
			if (state._active) {
				const _absoluteDelta = state._delta.map(Math.abs);
				V.addTo(state._distance, _absoluteDelta);
			}
			if (this.axisIntent) this.axisIntent(event);
			const [_m0, _m1] = state._movement;
			const [t0, t1] = config.threshold;
			const { _step, values } = state;
			if (config.hasCustomTransform) {
				if (_step[0] === false) _step[0] = Math.abs(_m0) >= t0 && values[0];
				if (_step[1] === false) _step[1] = Math.abs(_m1) >= t1 && values[1];
			} else {
				if (_step[0] === false) _step[0] = Math.abs(_m0) >= t0 && Math.sign(_m0) * t0;
				if (_step[1] === false) _step[1] = Math.abs(_m1) >= t1 && Math.sign(_m1) * t1;
			}
			state.intentional = _step[0] !== false || _step[1] !== false;
			if (!state.intentional) return;
			const movement = [0, 0];
			if (config.hasCustomTransform) {
				const [v0, v1] = values;
				movement[0] = _step[0] !== false ? v0 - _step[0] : 0;
				movement[1] = _step[1] !== false ? v1 - _step[1] : 0;
			} else {
				movement[0] = _step[0] !== false ? _m0 - _step[0] : 0;
				movement[1] = _step[1] !== false ? _m1 - _step[1] : 0;
			}
			if (this.restrictToAxis && !state._blocked) this.restrictToAxis(movement);
			const previousOffset = state.offset;
			const gestureIsActive = state._active && !state._blocked || state.active;
			if (gestureIsActive) {
				state.first = state._active && !state.active;
				state.last = !state._active && state.active;
				state.active = shared[this.ingKey] = state._active;
				if (event) {
					if (state.first) {
						if ("bounds" in config) state._bounds = call(config.bounds, state);
						if (this.setup) this.setup();
					}
					state.movement = movement;
					this.computeOffset();
				}
			}
			const [ox, oy] = state.offset;
			const [[x0, x1], [y0, y1]] = state._bounds;
			state.overflow = [ox < x0 ? -1 : ox > x1 ? 1 : 0, oy < y0 ? -1 : oy > y1 ? 1 : 0];
			state._movementBound[0] = state.overflow[0] ? state._movementBound[0] === false ? state._movement[0] : state._movementBound[0] : false;
			state._movementBound[1] = state.overflow[1] ? state._movementBound[1] === false ? state._movement[1] : state._movementBound[1] : false;
			const rubberband$1 = state._active ? config.rubberband || [0, 0] : [0, 0];
			state.offset = computeRubberband(state._bounds, state.offset, rubberband$1);
			state.delta = V.sub(state.offset, previousOffset);
			this.computeMovement();
			if (gestureIsActive && (!state.last || dt > BEFORE_LAST_KINEMATICS_DELAY)) {
				state.delta = V.sub(state.offset, previousOffset);
				const absoluteDelta = state.delta.map(Math.abs);
				V.addTo(state.distance, absoluteDelta);
				state.direction = state.delta.map(Math.sign);
				state._direction = state._delta.map(Math.sign);
				if (!state.first && dt > 0) {
					state.velocity = [absoluteDelta[0] / dt, absoluteDelta[1] / dt];
					state.timeDelta = dt;
				}
			}
		}
		emit() {
			const state = this.state;
			const shared = this.shared;
			const config = this.config;
			if (!state._active) this.clean();
			if ((state._blocked || !state.intentional) && !state._force && !config.triggerAllEvents) return;
			const memo = this.handler(_objectSpread2(_objectSpread2(_objectSpread2({}, shared), state), {}, { [this.aliasKey]: state.values }));
			if (memo !== void 0) state.memo = memo;
		}
		clean() {
			this.eventStore.clean();
			this.timeoutStore.clean();
		}
	};
	CoordinatesEngine = class extends Engine {
		constructor(...args) {
			super(...args);
			_defineProperty(this, "aliasKey", "xy");
		}
		reset() {
			super.reset();
			this.state.axis = void 0;
		}
		init() {
			this.state.offset = [0, 0];
			this.state.lastOffset = [0, 0];
		}
		computeOffset() {
			this.state.offset = V.add(this.state.lastOffset, this.state.movement);
		}
		computeMovement() {
			this.state.movement = V.sub(this.state.offset, this.state.lastOffset);
		}
		axisIntent(event) {
			const state = this.state;
			const config = this.config;
			if (!state.axis && event) {
				const threshold = typeof config.axisThreshold === "object" ? config.axisThreshold[getPointerType(event)] : config.axisThreshold;
				state.axis = selectAxis(state._movement, threshold);
			}
			state._blocked = (config.lockDirection || !!config.axis) && !state.axis || !!config.axis && config.axis !== state.axis;
		}
		restrictToAxis(v) {
			if (this.config.axis || this.config.lockDirection) switch (this.state.axis) {
				case "x":
					v[1] = 0;
					break;
				case "y":
					v[0] = 0;
					break;
			}
		}
	};
	identity = (v) => v;
	DEFAULT_RUBBERBAND = .15;
	commonConfigResolver = {
		enabled(value = true) {
			return value;
		},
		eventOptions(value, _k, config) {
			return _objectSpread2(_objectSpread2({}, config.shared.eventOptions), value);
		},
		preventDefault(value = false) {
			return value;
		},
		triggerAllEvents(value = false) {
			return value;
		},
		rubberband(value = 0) {
			switch (value) {
				case true: return [DEFAULT_RUBBERBAND, DEFAULT_RUBBERBAND];
				case false: return [0, 0];
				default: return V.toVector(value);
			}
		},
		from(value) {
			if (typeof value === "function") return value;
			if (value != null) return V.toVector(value);
		},
		transform(value, _k, config) {
			const transform = value || config.shared.transform;
			this.hasCustomTransform = !!transform;
			if (process.env.NODE_ENV === "development") {
				const originalTransform = transform || identity;
				return (v) => {
					const r = originalTransform(v);
					if (!isFinite(r[0]) || !isFinite(r[1])) console.warn(`[@use-gesture]: config.transform() must produce a valid result, but it was: [${r[0]},1]`);
					return r;
				};
			}
			return transform || identity;
		},
		threshold(value) {
			return V.toVector(value, 0);
		}
	};
	if (process.env.NODE_ENV === "development") Object.assign(commonConfigResolver, {
		domTarget(value) {
			if (value !== void 0) throw Error(`[@use-gesture]: \`domTarget\` option has been renamed to \`target\`.`);
			return NaN;
		},
		lockDirection(value) {
			if (value !== void 0) throw Error(`[@use-gesture]: \`lockDirection\` option has been merged with \`axis\`. Use it as in \`{ axis: 'lock' }\``);
			return NaN;
		},
		initial(value) {
			if (value !== void 0) throw Error(`[@use-gesture]: \`initial\` option has been renamed to \`from\`.`);
			return NaN;
		}
	});
	DEFAULT_AXIS_THRESHOLD = 0;
	coordinatesConfigResolver = _objectSpread2(_objectSpread2({}, commonConfigResolver), {}, {
		axis(_v, _k, { axis }) {
			this.lockDirection = axis === "lock";
			if (!this.lockDirection) return axis;
		},
		axisThreshold(value = DEFAULT_AXIS_THRESHOLD) {
			return value;
		},
		bounds(value = {}) {
			if (typeof value === "function") return (state) => coordinatesConfigResolver.bounds(value(state));
			if ("current" in value) return () => value.current;
			if (typeof HTMLElement === "function" && value instanceof HTMLElement) return value;
			const { left = -Infinity, right = Infinity, top = -Infinity, bottom = Infinity } = value;
			return [[left, right], [top, bottom]];
		}
	});
	KEYS_DELTA_MAP = {
		ArrowRight: (displacement, factor = 1) => [displacement * factor, 0],
		ArrowLeft: (displacement, factor = 1) => [-1 * displacement * factor, 0],
		ArrowUp: (displacement, factor = 1) => [0, -1 * displacement * factor],
		ArrowDown: (displacement, factor = 1) => [0, displacement * factor]
	};
	DragEngine = class extends CoordinatesEngine {
		constructor(...args) {
			super(...args);
			_defineProperty(this, "ingKey", "dragging");
		}
		reset() {
			super.reset();
			const state = this.state;
			state._pointerId = void 0;
			state._pointerActive = false;
			state._keyboardActive = false;
			state._preventScroll = false;
			state._delayed = false;
			state.swipe = [0, 0];
			state.tap = false;
			state.canceled = false;
			state.cancel = this.cancel.bind(this);
		}
		setup() {
			const state = this.state;
			if (state._bounds instanceof HTMLElement) {
				const boundRect = state._bounds.getBoundingClientRect();
				const targetRect = state.currentTarget.getBoundingClientRect();
				const _bounds = {
					left: boundRect.left - targetRect.left + state.offset[0],
					right: boundRect.right - targetRect.right + state.offset[0],
					top: boundRect.top - targetRect.top + state.offset[1],
					bottom: boundRect.bottom - targetRect.bottom + state.offset[1]
				};
				state._bounds = coordinatesConfigResolver.bounds(_bounds);
			}
		}
		cancel() {
			const state = this.state;
			if (state.canceled) return;
			state.canceled = true;
			state._active = false;
			setTimeout(() => {
				this.compute();
				this.emit();
			}, 0);
		}
		setActive() {
			this.state._active = this.state._pointerActive || this.state._keyboardActive;
		}
		clean() {
			this.pointerClean();
			this.state._pointerActive = false;
			this.state._keyboardActive = false;
			super.clean();
		}
		pointerDown(event) {
			const config = this.config;
			const state = this.state;
			if (event.buttons != null && (Array.isArray(config.pointerButtons) ? !config.pointerButtons.includes(event.buttons) : config.pointerButtons !== -1 && config.pointerButtons !== event.buttons)) return;
			const ctrlIds = this.ctrl.setEventIds(event);
			if (config.pointerCapture) event.target.setPointerCapture(event.pointerId);
			if (ctrlIds && ctrlIds.size > 1 && state._pointerActive) return;
			this.start(event);
			this.setupPointer(event);
			state._pointerId = pointerId(event);
			state._pointerActive = true;
			this.computeValues(pointerValues(event));
			this.computeInitial();
			if (config.preventScrollAxis && getPointerType(event) !== "mouse") {
				state._active = false;
				this.setupScrollPrevention(event);
			} else if (config.delay > 0) {
				this.setupDelayTrigger(event);
				if (config.triggerAllEvents) {
					this.compute(event);
					this.emit();
				}
			} else this.startPointerDrag(event);
		}
		startPointerDrag(event) {
			const state = this.state;
			state._active = true;
			state._preventScroll = true;
			state._delayed = false;
			this.compute(event);
			this.emit();
		}
		pointerMove(event) {
			const state = this.state;
			const config = this.config;
			if (!state._pointerActive) return;
			const id = pointerId(event);
			if (state._pointerId !== void 0 && id !== state._pointerId) return;
			const _values = pointerValues(event);
			if (document.pointerLockElement === event.target) state._delta = [event.movementX, event.movementY];
			else {
				state._delta = V.sub(_values, state._values);
				this.computeValues(_values);
			}
			V.addTo(state._movement, state._delta);
			this.compute(event);
			if (state._delayed && state.intentional) {
				this.timeoutStore.remove("dragDelay");
				state.active = false;
				this.startPointerDrag(event);
				return;
			}
			if (config.preventScrollAxis && !state._preventScroll) if (state.axis) if (state.axis === config.preventScrollAxis || config.preventScrollAxis === "xy") {
				state._active = false;
				this.clean();
				return;
			} else {
				this.timeoutStore.remove("startPointerDrag");
				this.startPointerDrag(event);
				return;
			}
			else return;
			this.emit();
		}
		pointerUp(event) {
			this.ctrl.setEventIds(event);
			try {
				if (this.config.pointerCapture && event.target.hasPointerCapture(event.pointerId)) event.target.releasePointerCapture(event.pointerId);
			} catch (_unused) {
				if (process.env.NODE_ENV === "development") console.warn(`[@use-gesture]: If you see this message, it's likely that you're using an outdated version of \`@react-three/fiber\`. \n\nPlease upgrade to the latest version.`);
			}
			const state = this.state;
			const config = this.config;
			if (!state._active || !state._pointerActive) return;
			const id = pointerId(event);
			if (state._pointerId !== void 0 && id !== state._pointerId) return;
			this.state._pointerActive = false;
			this.setActive();
			this.compute(event);
			const [dx, dy] = state._distance;
			state.tap = dx <= config.tapsThreshold && dy <= config.tapsThreshold;
			if (state.tap && config.filterTaps) state._force = true;
			else {
				const [_dx, _dy] = state._delta;
				const [_mx, _my] = state._movement;
				const [svx, svy] = config.swipe.velocity;
				const [sx, sy] = config.swipe.distance;
				const sdt = config.swipe.duration;
				if (state.elapsedTime < sdt) {
					const _vx = Math.abs(_dx / state.timeDelta);
					const _vy = Math.abs(_dy / state.timeDelta);
					if (_vx > svx && Math.abs(_mx) > sx) state.swipe[0] = Math.sign(_dx);
					if (_vy > svy && Math.abs(_my) > sy) state.swipe[1] = Math.sign(_dy);
				}
			}
			this.emit();
		}
		pointerClick(event) {
			if (!this.state.tap && event.detail > 0) {
				event.preventDefault();
				event.stopPropagation();
			}
		}
		setupPointer(event) {
			const config = this.config;
			const device = config.device;
			if (process.env.NODE_ENV === "development") try {
				if (device === "pointer" && config.preventScrollDelay === void 0) {
					const currentTarget = "uv" in event ? event.sourceEvent.currentTarget : event.currentTarget;
					if (window.getComputedStyle(currentTarget).touchAction === "auto") console.warn(`[@use-gesture]: The drag target has its \`touch-action\` style property set to \`auto\`. It is recommended to add \`touch-action: 'none'\` so that the drag gesture behaves correctly on touch-enabled devices. For more information read this: https://use-gesture.netlify.app/docs/extras/#touch-action.\n\nThis message will only show in development mode. It won't appear in production. If this is intended, you can ignore it.`, currentTarget);
				}
			} catch (_unused2) {}
			if (config.pointerLock) event.currentTarget.requestPointerLock();
			if (!config.pointerCapture) {
				this.eventStore.add(this.sharedConfig.window, device, "change", this.pointerMove.bind(this));
				this.eventStore.add(this.sharedConfig.window, device, "end", this.pointerUp.bind(this));
				this.eventStore.add(this.sharedConfig.window, device, "cancel", this.pointerUp.bind(this));
			}
		}
		pointerClean() {
			if (this.config.pointerLock && document.pointerLockElement === this.state.currentTarget) document.exitPointerLock();
		}
		preventScroll(event) {
			if (this.state._preventScroll && event.cancelable) event.preventDefault();
		}
		setupScrollPrevention(event) {
			this.state._preventScroll = false;
			persistEvent(event);
			const remove = this.eventStore.add(this.sharedConfig.window, "touch", "change", this.preventScroll.bind(this), { passive: false });
			this.eventStore.add(this.sharedConfig.window, "touch", "end", remove);
			this.eventStore.add(this.sharedConfig.window, "touch", "cancel", remove);
			this.timeoutStore.add("startPointerDrag", this.startPointerDrag.bind(this), this.config.preventScrollDelay, event);
		}
		setupDelayTrigger(event) {
			this.state._delayed = true;
			this.timeoutStore.add("dragDelay", () => {
				this.state._step = [0, 0];
				this.startPointerDrag(event);
			}, this.config.delay);
		}
		keyDown(event) {
			const deltaFn = KEYS_DELTA_MAP[event.key];
			if (deltaFn) {
				const state = this.state;
				const factor = event.shiftKey ? 10 : event.altKey ? .1 : 1;
				this.start(event);
				state._delta = deltaFn(this.config.keyboardDisplacement, factor);
				state._keyboardActive = true;
				V.addTo(state._movement, state._delta);
				this.compute(event);
				this.emit();
			}
		}
		keyUp(event) {
			if (!(event.key in KEYS_DELTA_MAP)) return;
			this.state._keyboardActive = false;
			this.setActive();
			this.compute(event);
			this.emit();
		}
		bind(bindFunction) {
			const device = this.config.device;
			bindFunction(device, "start", this.pointerDown.bind(this));
			if (this.config.pointerCapture) {
				bindFunction(device, "change", this.pointerMove.bind(this));
				bindFunction(device, "end", this.pointerUp.bind(this));
				bindFunction(device, "cancel", this.pointerUp.bind(this));
				bindFunction("lostPointerCapture", "", this.pointerUp.bind(this));
			}
			if (this.config.keys) {
				bindFunction("key", "down", this.keyDown.bind(this));
				bindFunction("key", "up", this.keyUp.bind(this));
			}
			if (this.config.filterTaps) bindFunction("click", "", this.pointerClick.bind(this), {
				capture: true,
				passive: false
			});
		}
	};
	isBrowser = typeof window !== "undefined" && window.document && window.document.createElement;
	SUPPORT = {
		isBrowser,
		gesture: supportsGestureEvents(),
		touch: supportsTouchEvents(),
		touchscreen: isTouchScreen(),
		pointer: supportsPointerEvents(),
		pointerLock: supportsPointerLock()
	};
	DEFAULT_PREVENT_SCROLL_DELAY = 250;
	DEFAULT_DRAG_DELAY = 180;
	DEFAULT_SWIPE_VELOCITY = .5;
	DEFAULT_SWIPE_DISTANCE = 50;
	DEFAULT_SWIPE_DURATION = 250;
	DEFAULT_KEYBOARD_DISPLACEMENT = 10;
	DEFAULT_DRAG_AXIS_THRESHOLD = {
		mouse: 0,
		touch: 0,
		pen: 8
	};
	dragConfigResolver = _objectSpread2(_objectSpread2({}, coordinatesConfigResolver), {}, {
		device(_v, _k, { pointer: { touch = false, lock = false, mouse = false } = {} }) {
			this.pointerLock = lock && SUPPORT.pointerLock;
			if (SUPPORT.touch && touch) return "touch";
			if (this.pointerLock) return "mouse";
			if (SUPPORT.pointer && !mouse) return "pointer";
			if (SUPPORT.touch) return "touch";
			return "mouse";
		},
		preventScrollAxis(value, _k, { preventScroll }) {
			this.preventScrollDelay = typeof preventScroll === "number" ? preventScroll : preventScroll || preventScroll === void 0 && value ? DEFAULT_PREVENT_SCROLL_DELAY : void 0;
			if (!SUPPORT.touchscreen || preventScroll === false) return void 0;
			return value ? value : preventScroll !== void 0 ? "y" : void 0;
		},
		pointerCapture(_v, _k, { pointer: { capture = true, buttons = 1, keys = true } = {} }) {
			this.pointerButtons = buttons;
			this.keys = keys;
			return !this.pointerLock && this.device === "pointer" && capture;
		},
		threshold(value, _k, { filterTaps = false, tapsThreshold = 3, axis = void 0 }) {
			const threshold = V.toVector(value, filterTaps ? tapsThreshold : axis ? 1 : 0);
			this.filterTaps = filterTaps;
			this.tapsThreshold = tapsThreshold;
			return threshold;
		},
		swipe({ velocity = DEFAULT_SWIPE_VELOCITY, distance = DEFAULT_SWIPE_DISTANCE, duration = DEFAULT_SWIPE_DURATION } = {}) {
			return {
				velocity: this.transform(V.toVector(velocity)),
				distance: this.transform(V.toVector(distance)),
				duration
			};
		},
		delay(value = 0) {
			switch (value) {
				case true: return DEFAULT_DRAG_DELAY;
				case false: return 0;
				default: return value;
			}
		},
		axisThreshold(value) {
			if (!value) return DEFAULT_DRAG_AXIS_THRESHOLD;
			return _objectSpread2(_objectSpread2({}, DEFAULT_DRAG_AXIS_THRESHOLD), value);
		},
		keyboardDisplacement(value = DEFAULT_KEYBOARD_DISPLACEMENT) {
			return value;
		}
	});
	if (process.env.NODE_ENV === "development") Object.assign(dragConfigResolver, {
		useTouch(value) {
			if (value !== void 0) throw Error(`[@use-gesture]: \`useTouch\` option has been renamed to \`pointer.touch\`. Use it as in \`{ pointer: { touch: true } }\`.`);
			return NaN;
		},
		experimental_preventWindowScrollY(value) {
			if (value !== void 0) throw Error(`[@use-gesture]: \`experimental_preventWindowScrollY\` option has been renamed to \`preventScroll\`.`);
			return NaN;
		},
		swipeVelocity(value) {
			if (value !== void 0) throw Error(`[@use-gesture]: \`swipeVelocity\` option has been renamed to \`swipe.velocity\`. Use it as in \`{ swipe: { velocity: 0.5 } }\`.`);
			return NaN;
		},
		swipeDistance(value) {
			if (value !== void 0) throw Error(`[@use-gesture]: \`swipeDistance\` option has been renamed to \`swipe.distance\`. Use it as in \`{ swipe: { distance: 50 } }\`.`);
			return NaN;
		},
		swipeDuration(value) {
			if (value !== void 0) throw Error(`[@use-gesture]: \`swipeDuration\` option has been renamed to \`swipe.duration\`. Use it as in \`{ swipe: { duration: 250 } }\`.`);
			return NaN;
		}
	});
	SCALE_ANGLE_RATIO_INTENT_DEG = 30;
	PINCH_WHEEL_RATIO = 100;
	PinchEngine = class extends Engine {
		constructor(...args) {
			super(...args);
			_defineProperty(this, "ingKey", "pinching");
			_defineProperty(this, "aliasKey", "da");
		}
		init() {
			this.state.offset = [1, 0];
			this.state.lastOffset = [1, 0];
			this.state._pointerEvents = /* @__PURE__ */ new Map();
		}
		reset() {
			super.reset();
			const state = this.state;
			state._touchIds = [];
			state.canceled = false;
			state.cancel = this.cancel.bind(this);
			state.turns = 0;
		}
		computeOffset() {
			const { type, movement, lastOffset } = this.state;
			if (type === "wheel") this.state.offset = V.add(movement, lastOffset);
			else this.state.offset = [(1 + movement[0]) * lastOffset[0], movement[1] + lastOffset[1]];
		}
		computeMovement() {
			const { offset, lastOffset } = this.state;
			this.state.movement = [offset[0] / lastOffset[0], offset[1] - lastOffset[1]];
		}
		axisIntent() {
			const state = this.state;
			const [_m0, _m1] = state._movement;
			if (!state.axis) {
				const axisMovementDifference = Math.abs(_m0) * SCALE_ANGLE_RATIO_INTENT_DEG - Math.abs(_m1);
				if (axisMovementDifference < 0) state.axis = "angle";
				else if (axisMovementDifference > 0) state.axis = "scale";
			}
		}
		restrictToAxis(v) {
			if (this.config.lockDirection) {
				if (this.state.axis === "scale") v[1] = 0;
				else if (this.state.axis === "angle") v[0] = 0;
			}
		}
		cancel() {
			const state = this.state;
			if (state.canceled) return;
			setTimeout(() => {
				state.canceled = true;
				state._active = false;
				this.compute();
				this.emit();
			}, 0);
		}
		touchStart(event) {
			this.ctrl.setEventIds(event);
			const state = this.state;
			const ctrlTouchIds = this.ctrl.touchIds;
			if (state._active) {
				if (state._touchIds.every((id) => ctrlTouchIds.has(id))) return;
			}
			if (ctrlTouchIds.size < 2) return;
			this.start(event);
			state._touchIds = Array.from(ctrlTouchIds).slice(0, 2);
			const payload = touchDistanceAngle(event, state._touchIds);
			if (!payload) return;
			this.pinchStart(event, payload);
		}
		pointerStart(event) {
			if (event.buttons != null && event.buttons % 2 !== 1) return;
			this.ctrl.setEventIds(event);
			event.target.setPointerCapture(event.pointerId);
			const state = this.state;
			const _pointerEvents = state._pointerEvents;
			const ctrlPointerIds = this.ctrl.pointerIds;
			if (state._active) {
				if (Array.from(_pointerEvents.keys()).every((id) => ctrlPointerIds.has(id))) return;
			}
			if (_pointerEvents.size < 2) _pointerEvents.set(event.pointerId, event);
			if (state._pointerEvents.size < 2) return;
			this.start(event);
			const payload = distanceAngle(...Array.from(_pointerEvents.values()));
			if (!payload) return;
			this.pinchStart(event, payload);
		}
		pinchStart(event, payload) {
			const state = this.state;
			state.origin = payload.origin;
			this.computeValues([payload.distance, payload.angle]);
			this.computeInitial();
			this.compute(event);
			this.emit();
		}
		touchMove(event) {
			if (!this.state._active) return;
			const payload = touchDistanceAngle(event, this.state._touchIds);
			if (!payload) return;
			this.pinchMove(event, payload);
		}
		pointerMove(event) {
			const _pointerEvents = this.state._pointerEvents;
			if (_pointerEvents.has(event.pointerId)) _pointerEvents.set(event.pointerId, event);
			if (!this.state._active) return;
			const payload = distanceAngle(...Array.from(_pointerEvents.values()));
			if (!payload) return;
			this.pinchMove(event, payload);
		}
		pinchMove(event, payload) {
			const state = this.state;
			const prev_a = state._values[1];
			const delta_a = payload.angle - prev_a;
			let delta_turns = 0;
			if (Math.abs(delta_a) > 270) delta_turns += Math.sign(delta_a);
			this.computeValues([payload.distance, payload.angle - 360 * delta_turns]);
			state.origin = payload.origin;
			state.turns = delta_turns;
			state._movement = [state._values[0] / state._initial[0] - 1, state._values[1] - state._initial[1]];
			this.compute(event);
			this.emit();
		}
		touchEnd(event) {
			this.ctrl.setEventIds(event);
			if (!this.state._active) return;
			if (this.state._touchIds.some((id) => !this.ctrl.touchIds.has(id))) {
				this.state._active = false;
				this.compute(event);
				this.emit();
			}
		}
		pointerEnd(event) {
			const state = this.state;
			this.ctrl.setEventIds(event);
			try {
				event.target.releasePointerCapture(event.pointerId);
			} catch (_unused) {}
			if (state._pointerEvents.has(event.pointerId)) state._pointerEvents.delete(event.pointerId);
			if (!state._active) return;
			if (state._pointerEvents.size < 2) {
				state._active = false;
				this.compute(event);
				this.emit();
			}
		}
		gestureStart(event) {
			if (event.cancelable) event.preventDefault();
			const state = this.state;
			if (state._active) return;
			this.start(event);
			this.computeValues([event.scale, event.rotation]);
			state.origin = [event.clientX, event.clientY];
			this.compute(event);
			this.emit();
		}
		gestureMove(event) {
			if (event.cancelable) event.preventDefault();
			if (!this.state._active) return;
			const state = this.state;
			this.computeValues([event.scale, event.rotation]);
			state.origin = [event.clientX, event.clientY];
			const _previousMovement = state._movement;
			state._movement = [event.scale - 1, event.rotation];
			state._delta = V.sub(state._movement, _previousMovement);
			this.compute(event);
			this.emit();
		}
		gestureEnd(event) {
			if (!this.state._active) return;
			this.state._active = false;
			this.compute(event);
			this.emit();
		}
		wheel(event) {
			const modifierKey = this.config.modifierKey;
			if (modifierKey && (Array.isArray(modifierKey) ? !modifierKey.find((k) => event[k]) : !event[modifierKey])) return;
			if (!this.state._active) this.wheelStart(event);
			else this.wheelChange(event);
			this.timeoutStore.add("wheelEnd", this.wheelEnd.bind(this));
		}
		wheelStart(event) {
			this.start(event);
			this.wheelChange(event);
		}
		wheelChange(event) {
			if (!("uv" in event)) {
				if (event.cancelable) event.preventDefault();
				if (process.env.NODE_ENV === "development" && !event.defaultPrevented) console.warn(`[@use-gesture]: To properly support zoom on trackpads, try using the \`target\` option.\n\nThis message will only appear in development mode.`);
			}
			const state = this.state;
			state._delta = [-wheelValues(event)[1] / PINCH_WHEEL_RATIO * state.offset[0], 0];
			V.addTo(state._movement, state._delta);
			clampStateInternalMovementToBounds(state);
			this.state.origin = [event.clientX, event.clientY];
			this.compute(event);
			this.emit();
		}
		wheelEnd() {
			if (!this.state._active) return;
			this.state._active = false;
			this.compute();
			this.emit();
		}
		bind(bindFunction) {
			const device = this.config.device;
			if (!!device) {
				bindFunction(device, "start", this[device + "Start"].bind(this));
				bindFunction(device, "change", this[device + "Move"].bind(this));
				bindFunction(device, "end", this[device + "End"].bind(this));
				bindFunction(device, "cancel", this[device + "End"].bind(this));
				bindFunction("lostPointerCapture", "", this[device + "End"].bind(this));
			}
			if (this.config.pinchOnWheel) bindFunction("wheel", "", this.wheel.bind(this), { passive: false });
		}
	};
	pinchConfigResolver = _objectSpread2(_objectSpread2({}, commonConfigResolver), {}, {
		device(_v, _k, { shared, pointer: { touch = false } = {} }) {
			if (shared.target && !SUPPORT.touch && SUPPORT.gesture) return "gesture";
			if (SUPPORT.touch && touch) return "touch";
			if (SUPPORT.touchscreen) {
				if (SUPPORT.pointer) return "pointer";
				if (SUPPORT.touch) return "touch";
			}
		},
		bounds(_v, _k, { scaleBounds = {}, angleBounds = {} }) {
			const _scaleBounds = (state) => {
				const D = assignDefault(call(scaleBounds, state), {
					min: -Infinity,
					max: Infinity
				});
				return [D.min, D.max];
			};
			const _angleBounds = (state) => {
				const A = assignDefault(call(angleBounds, state), {
					min: -Infinity,
					max: Infinity
				});
				return [A.min, A.max];
			};
			if (typeof scaleBounds !== "function" && typeof angleBounds !== "function") return [_scaleBounds(), _angleBounds()];
			return (state) => [_scaleBounds(state), _angleBounds(state)];
		},
		threshold(value, _k, config) {
			this.lockDirection = config.axis === "lock";
			return V.toVector(value, this.lockDirection ? [.1, 3] : 0);
		},
		modifierKey(value) {
			if (value === void 0) return "ctrlKey";
			return value;
		},
		pinchOnWheel(value = true) {
			return value;
		}
	});
	MoveEngine = class extends CoordinatesEngine {
		constructor(...args) {
			super(...args);
			_defineProperty(this, "ingKey", "moving");
		}
		move(event) {
			if (this.config.mouseOnly && event.pointerType !== "mouse") return;
			if (!this.state._active) this.moveStart(event);
			else this.moveChange(event);
			this.timeoutStore.add("moveEnd", this.moveEnd.bind(this));
		}
		moveStart(event) {
			this.start(event);
			this.computeValues(pointerValues(event));
			this.compute(event);
			this.computeInitial();
			this.emit();
		}
		moveChange(event) {
			if (!this.state._active) return;
			const values = pointerValues(event);
			const state = this.state;
			state._delta = V.sub(values, state._values);
			V.addTo(state._movement, state._delta);
			this.computeValues(values);
			this.compute(event);
			this.emit();
		}
		moveEnd(event) {
			if (!this.state._active) return;
			this.state._active = false;
			this.compute(event);
			this.emit();
		}
		bind(bindFunction) {
			bindFunction("pointer", "change", this.move.bind(this));
			bindFunction("pointer", "leave", this.moveEnd.bind(this));
		}
	};
	moveConfigResolver = _objectSpread2(_objectSpread2({}, coordinatesConfigResolver), {}, { mouseOnly: (value = true) => value });
	ScrollEngine = class extends CoordinatesEngine {
		constructor(...args) {
			super(...args);
			_defineProperty(this, "ingKey", "scrolling");
		}
		scroll(event) {
			if (!this.state._active) this.start(event);
			this.scrollChange(event);
			this.timeoutStore.add("scrollEnd", this.scrollEnd.bind(this));
		}
		scrollChange(event) {
			if (event.cancelable) event.preventDefault();
			const state = this.state;
			const values = scrollValues(event);
			state._delta = V.sub(values, state._values);
			V.addTo(state._movement, state._delta);
			this.computeValues(values);
			this.compute(event);
			this.emit();
		}
		scrollEnd() {
			if (!this.state._active) return;
			this.state._active = false;
			this.compute();
			this.emit();
		}
		bind(bindFunction) {
			bindFunction("scroll", "", this.scroll.bind(this));
		}
	};
	scrollConfigResolver = coordinatesConfigResolver;
	WheelEngine = class extends CoordinatesEngine {
		constructor(...args) {
			super(...args);
			_defineProperty(this, "ingKey", "wheeling");
		}
		wheel(event) {
			if (!this.state._active) this.start(event);
			this.wheelChange(event);
			this.timeoutStore.add("wheelEnd", this.wheelEnd.bind(this));
		}
		wheelChange(event) {
			const state = this.state;
			state._delta = wheelValues(event);
			V.addTo(state._movement, state._delta);
			clampStateInternalMovementToBounds(state);
			this.compute(event);
			this.emit();
		}
		wheelEnd() {
			if (!this.state._active) return;
			this.state._active = false;
			this.compute();
			this.emit();
		}
		bind(bindFunction) {
			bindFunction("wheel", "", this.wheel.bind(this));
		}
	};
	wheelConfigResolver = coordinatesConfigResolver;
	HoverEngine = class extends CoordinatesEngine {
		constructor(...args) {
			super(...args);
			_defineProperty(this, "ingKey", "hovering");
		}
		enter(event) {
			if (this.config.mouseOnly && event.pointerType !== "mouse") return;
			this.start(event);
			this.computeValues(pointerValues(event));
			this.compute(event);
			this.emit();
		}
		leave(event) {
			if (this.config.mouseOnly && event.pointerType !== "mouse") return;
			const state = this.state;
			if (!state._active) return;
			state._active = false;
			const values = pointerValues(event);
			state._movement = state._delta = V.sub(values, state._values);
			this.computeValues(values);
			this.compute(event);
			state.delta = state.movement;
			this.emit();
		}
		bind(bindFunction) {
			bindFunction("pointer", "enter", this.enter.bind(this));
			bindFunction("pointer", "leave", this.leave.bind(this));
		}
	};
	hoverConfigResolver = _objectSpread2(_objectSpread2({}, coordinatesConfigResolver), {}, { mouseOnly: (value = true) => value });
	EngineMap = /* @__PURE__ */ new Map();
	ConfigResolverMap = /* @__PURE__ */ new Map();
	dragAction = {
		key: "drag",
		engine: DragEngine,
		resolver: dragConfigResolver
	};
	hoverAction = {
		key: "hover",
		engine: HoverEngine,
		resolver: hoverConfigResolver
	};
	moveAction = {
		key: "move",
		engine: MoveEngine,
		resolver: moveConfigResolver
	};
	pinchAction = {
		key: "pinch",
		engine: PinchEngine,
		resolver: pinchConfigResolver
	};
	scrollAction = {
		key: "scroll",
		engine: ScrollEngine,
		resolver: scrollConfigResolver
	};
	wheelAction = {
		key: "wheel",
		engine: WheelEngine,
		resolver: wheelConfigResolver
	};
}));

//#endregion
//#region node_modules/@use-gesture/core/actions/dist/use-gesture-core-actions.esm.js
var use_gesture_core_actions_esm_exports = /* @__PURE__ */ __export({
	ConfigResolverMap: () => ConfigResolverMap,
	EngineMap: () => EngineMap,
	dragAction: () => dragAction,
	hoverAction: () => hoverAction,
	moveAction: () => moveAction,
	pinchAction: () => pinchAction,
	registerAction: () => registerAction,
	scrollAction: () => scrollAction,
	wheelAction: () => wheelAction
});
var init_use_gesture_core_actions_esm = __esmMin((() => {
	init_actions_fe213e88_esm();
}));

//#endregion
//#region node_modules/@use-gesture/core/dist/use-gesture-core.esm.js
var use_gesture_core_esm_exports = /* @__PURE__ */ __export({
	Controller: () => Controller,
	parseMergedHandlers: () => parseMergedHandlers
});
function _objectWithoutPropertiesLoose(source, excluded) {
	if (source == null) return {};
	var target = {};
	var sourceKeys = Object.keys(source);
	var key, i;
	for (i = 0; i < sourceKeys.length; i++) {
		key = sourceKeys[i];
		if (excluded.indexOf(key) >= 0) continue;
		target[key] = source[key];
	}
	return target;
}
function _objectWithoutProperties(source, excluded) {
	if (source == null) return {};
	var target = _objectWithoutPropertiesLoose(source, excluded);
	var key, i;
	if (Object.getOwnPropertySymbols) {
		var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
		for (i = 0; i < sourceSymbolKeys.length; i++) {
			key = sourceSymbolKeys[i];
			if (excluded.indexOf(key) >= 0) continue;
			if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
			target[key] = source[key];
		}
	}
	return target;
}
function resolveWith(config = {}, resolvers) {
	const result = {};
	for (const [key, resolver] of Object.entries(resolvers)) switch (typeof resolver) {
		case "function":
			if (process.env.NODE_ENV === "development") {
				const r = resolver.call(result, config[key], key, config);
				if (!Number.isNaN(r)) result[key] = r;
			} else result[key] = resolver.call(result, config[key], key, config);
			break;
		case "object":
			result[key] = resolveWith(config[key], resolver);
			break;
		case "boolean":
			if (resolver) result[key] = config[key];
			break;
	}
	return result;
}
function parse(newConfig, gestureKey, _config = {}) {
	const _ref = newConfig, { target, eventOptions, window: window$1, enabled, transform } = _ref, rest = _objectWithoutProperties(_ref, _excluded);
	_config.shared = resolveWith({
		target,
		eventOptions,
		window: window$1,
		enabled,
		transform
	}, sharedConfigResolver);
	if (gestureKey) {
		const resolver = ConfigResolverMap.get(gestureKey);
		_config[gestureKey] = resolveWith(_objectSpread2({ shared: _config.shared }, rest), resolver);
	} else for (const key in rest) {
		const resolver = ConfigResolverMap.get(key);
		if (resolver) _config[key] = resolveWith(_objectSpread2({ shared: _config.shared }, rest[key]), resolver);
		else if (process.env.NODE_ENV === "development") {
			if (![
				"drag",
				"pinch",
				"scroll",
				"wheel",
				"move",
				"hover"
			].includes(key)) {
				if (key === "domTarget") throw Error(`[@use-gesture]: \`domTarget\` option has been renamed to \`target\`.`);
				console.warn(`[@use-gesture]: Unknown config key \`${key}\` was used. Please read the documentation for further information.`);
			}
		}
	}
	return _config;
}
function setupGesture(ctrl, gestureKey) {
	ctrl.gestures.add(gestureKey);
	ctrl.gestureEventStores[gestureKey] = new EventStore(ctrl, gestureKey);
	ctrl.gestureTimeoutStores[gestureKey] = new TimeoutStore();
}
function resolveGestures(ctrl, internalHandlers) {
	if (internalHandlers.drag) setupGesture(ctrl, "drag");
	if (internalHandlers.wheel) setupGesture(ctrl, "wheel");
	if (internalHandlers.scroll) setupGesture(ctrl, "scroll");
	if (internalHandlers.move) setupGesture(ctrl, "move");
	if (internalHandlers.pinch) setupGesture(ctrl, "pinch");
	if (internalHandlers.hover) setupGesture(ctrl, "hover");
}
function sortHandlers(_handlers) {
	const native = {};
	const handlers = {};
	const actions = /* @__PURE__ */ new Set();
	for (let key in _handlers) if (RE_NOT_NATIVE.test(key)) {
		actions.add(RegExp.lastMatch);
		handlers[key] = _handlers[key];
	} else native[key] = _handlers[key];
	return [
		handlers,
		native,
		actions
	];
}
function registerGesture(actions, handlers, handlerKey, key, internalHandlers, config) {
	if (!actions.has(handlerKey)) return;
	if (!EngineMap.has(key)) {
		if (process.env.NODE_ENV === "development") console.warn(`[@use-gesture]: You've created a custom handler that that uses the \`${key}\` gesture but isn't properly configured.\n\nPlease add \`${key}Action\` when creating your handler.`);
		return;
	}
	const startKey = handlerKey + "Start";
	const endKey = handlerKey + "End";
	const fn = (state) => {
		let memo = void 0;
		if (state.first && startKey in handlers) handlers[startKey](state);
		if (handlerKey in handlers) memo = handlers[handlerKey](state);
		if (state.last && endKey in handlers) handlers[endKey](state);
		return memo;
	};
	internalHandlers[key] = fn;
	config[key] = config[key] || {};
}
function parseMergedHandlers(mergedHandlers, mergedConfig) {
	const [handlers, nativeHandlers, actions] = sortHandlers(mergedHandlers);
	const internalHandlers = {};
	registerGesture(actions, handlers, "onDrag", "drag", internalHandlers, mergedConfig);
	registerGesture(actions, handlers, "onWheel", "wheel", internalHandlers, mergedConfig);
	registerGesture(actions, handlers, "onScroll", "scroll", internalHandlers, mergedConfig);
	registerGesture(actions, handlers, "onPinch", "pinch", internalHandlers, mergedConfig);
	registerGesture(actions, handlers, "onMove", "move", internalHandlers, mergedConfig);
	registerGesture(actions, handlers, "onHover", "hover", internalHandlers, mergedConfig);
	return {
		handlers: internalHandlers,
		config: mergedConfig,
		nativeHandlers
	};
}
var sharedConfigResolver, _excluded, EventStore, TimeoutStore, Controller, bindToProps, RE_NOT_NATIVE;
var init_use_gesture_core_esm = __esmMin((() => {
	init_actions_fe213e88_esm();
	sharedConfigResolver = {
		target(value) {
			if (value) return () => "current" in value ? value.current : value;
		},
		enabled(value = true) {
			return value;
		},
		window(value = SUPPORT.isBrowser ? window : void 0) {
			return value;
		},
		eventOptions({ passive = true, capture = false } = {}) {
			return {
				passive,
				capture
			};
		},
		transform(value) {
			return value;
		}
	};
	_excluded = [
		"target",
		"eventOptions",
		"window",
		"enabled",
		"transform"
	];
	EventStore = class {
		constructor(ctrl, gestureKey) {
			_defineProperty(this, "_listeners", /* @__PURE__ */ new Set());
			this._ctrl = ctrl;
			this._gestureKey = gestureKey;
		}
		add(element, device, action, handler, options) {
			const listeners = this._listeners;
			const type = toDomEventType(device, action);
			const eventOptions = _objectSpread2(_objectSpread2({}, this._gestureKey ? this._ctrl.config[this._gestureKey].eventOptions : {}), options);
			element.addEventListener(type, handler, eventOptions);
			const remove = () => {
				element.removeEventListener(type, handler, eventOptions);
				listeners.delete(remove);
			};
			listeners.add(remove);
			return remove;
		}
		clean() {
			this._listeners.forEach((remove) => remove());
			this._listeners.clear();
		}
	};
	TimeoutStore = class {
		constructor() {
			_defineProperty(this, "_timeouts", /* @__PURE__ */ new Map());
		}
		add(key, callback, ms = 140, ...args) {
			this.remove(key);
			this._timeouts.set(key, window.setTimeout(callback, ms, ...args));
		}
		remove(key) {
			const timeout = this._timeouts.get(key);
			if (timeout) window.clearTimeout(timeout);
		}
		clean() {
			this._timeouts.forEach((timeout) => void window.clearTimeout(timeout));
			this._timeouts.clear();
		}
	};
	Controller = class {
		constructor(handlers) {
			_defineProperty(this, "gestures", /* @__PURE__ */ new Set());
			_defineProperty(this, "_targetEventStore", new EventStore(this));
			_defineProperty(this, "gestureEventStores", {});
			_defineProperty(this, "gestureTimeoutStores", {});
			_defineProperty(this, "handlers", {});
			_defineProperty(this, "config", {});
			_defineProperty(this, "pointerIds", /* @__PURE__ */ new Set());
			_defineProperty(this, "touchIds", /* @__PURE__ */ new Set());
			_defineProperty(this, "state", { shared: {
				shiftKey: false,
				metaKey: false,
				ctrlKey: false,
				altKey: false
			} });
			resolveGestures(this, handlers);
		}
		setEventIds(event) {
			if (isTouch(event)) {
				this.touchIds = new Set(touchIds(event));
				return this.touchIds;
			} else if ("pointerId" in event) {
				if (event.type === "pointerup" || event.type === "pointercancel") this.pointerIds.delete(event.pointerId);
				else if (event.type === "pointerdown") this.pointerIds.add(event.pointerId);
				return this.pointerIds;
			}
		}
		applyHandlers(handlers, nativeHandlers) {
			this.handlers = handlers;
			this.nativeHandlers = nativeHandlers;
		}
		applyConfig(config, gestureKey) {
			this.config = parse(config, gestureKey, this.config);
		}
		clean() {
			this._targetEventStore.clean();
			for (const key of this.gestures) {
				this.gestureEventStores[key].clean();
				this.gestureTimeoutStores[key].clean();
			}
		}
		effect() {
			if (this.config.shared.target) this.bind();
			return () => this._targetEventStore.clean();
		}
		bind(...args) {
			const sharedConfig = this.config.shared;
			const props = {};
			let target;
			if (sharedConfig.target) {
				target = sharedConfig.target();
				if (!target) return;
			}
			if (sharedConfig.enabled) {
				for (const gestureKey of this.gestures) {
					const gestureConfig = this.config[gestureKey];
					const bindFunction = bindToProps(props, gestureConfig.eventOptions, !!target);
					if (gestureConfig.enabled) new (EngineMap.get(gestureKey))(this, args, gestureKey).bind(bindFunction);
				}
				const nativeBindFunction = bindToProps(props, sharedConfig.eventOptions, !!target);
				for (const eventKey in this.nativeHandlers) nativeBindFunction(eventKey, "", (event) => this.nativeHandlers[eventKey](_objectSpread2(_objectSpread2({}, this.state.shared), {}, {
					event,
					args
				})), void 0, true);
			}
			for (const handlerProp in props) props[handlerProp] = chain(...props[handlerProp]);
			if (!target) return props;
			for (const handlerProp in props) {
				const { device, capture, passive } = parseProp(handlerProp);
				this._targetEventStore.add(target, device, "", props[handlerProp], {
					capture,
					passive
				});
			}
		}
	};
	bindToProps = (props, eventOptions, withPassiveOption) => (device, action, handler, options = {}, isNative = false) => {
		var _options$capture, _options$passive;
		const capture = (_options$capture = options.capture) !== null && _options$capture !== void 0 ? _options$capture : eventOptions.capture;
		const passive = (_options$passive = options.passive) !== null && _options$passive !== void 0 ? _options$passive : eventOptions.passive;
		let handlerProp = isNative ? device : toHandlerProp(device, action, capture);
		if (withPassiveOption && passive) handlerProp += "Passive";
		props[handlerProp] = props[handlerProp] || [];
		props[handlerProp].push(handler);
	};
	RE_NOT_NATIVE = /^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/;
}));

//#endregion
//#region node_modules/@use-gesture/core/utils/dist/use-gesture-core-utils.esm.js
var use_gesture_core_utils_esm_exports = /* @__PURE__ */ __export({ rubberbandIfOutOfBounds: () => rubberbandIfOutOfBounds });
var init_use_gesture_core_utils_esm = __esmMin((() => {
	init_maths_0ab39ae9_esm();
}));

//#endregion
//#region node_modules/@use-gesture/core/types/dist/use-gesture-core-types.esm.js
var require_use_gesture_core_types_esm = /* @__PURE__ */ __commonJSMin((() => {}));

//#endregion
export { use_gesture_core_esm_exports as a, init_use_gesture_core_esm as i, init_use_gesture_core_utils_esm as n, init_use_gesture_core_actions_esm as o, use_gesture_core_utils_esm_exports as r, use_gesture_core_actions_esm_exports as s, require_use_gesture_core_types_esm as t };