import { ValueHistory as W, derived as S } from "../../../../../@dnd-kit_state@0.1.21/node_modules/@dnd-kit/state/dist/index.js";
import { batch as G } from "../../../../../@preact_signals-core@1.12.0/node_modules/@preact/signals-core/dist/signals-core.module.js";
var N = Object.create, z = Object.defineProperty, T = Object.getOwnPropertyDescriptor, R = Object.getOwnPropertySymbols, B = Object.prototype.hasOwnProperty, J = Object.prototype.propertyIsEnumerable, I = (r, t) => (t = Symbol[r]) ? t : Symbol.for("Symbol." + r), p = (r) => {
  throw TypeError(r);
}, A = Math.pow, g = (r, t, e) => t in r ? z(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, K = (r, t) => {
  for (var e in t || (t = {}))
    B.call(t, e) && g(r, e, t[e]);
  if (R)
    for (var e of R(t))
      J.call(t, e) && g(r, e, t[e]);
  return r;
}, L = (r) => {
  var t;
  return [, , , N((t = r?.[I("metadata")]) != null ? t : null)];
}, k = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], C = (r) => r !== void 0 && typeof r != "function" ? p("Function expected") : r, Q = (r, t, e, i, n) => ({ kind: k[r], name: t, metadata: i, addInitializer: (o) => e._ ? p("Already initialized") : n.push(C(o || null)) }), U = (r, t) => g(t, I("metadata"), r[3]), X = (r, t, e, i) => {
  for (var n = 0, o = r[t >> 1], s = o && o.length; n < s; n++) o[n].call(e);
  return i;
}, D = (r, t, e, i, n, o) => {
  for (var s, c, a, u, M = t & 7, j = !1, F = !1, O = 2, P = k[M + 5], H = r[O] || (r[O] = []), d = (n = n.prototype, T(n, e)), v = i.length - 1; v >= 0; v--)
    a = Q(M, e, c = {}, r[3], H), a.static = j, a.private = F, u = a.access = { has: (x) => e in x }, u.get = (x) => x[e], s = (0, i[v])(d[P], a), c._ = 1, C(s) && (d[P] = s);
  return d && z(n, e, d), n;
}, E = (r, t, e) => t.has(r) || p("Cannot " + e), Y = (r, t, e) => (E(r, t, "read from private field"), t.get(r)), Z = (r, t, e) => t.has(r) ? p("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(r) : t.set(r, e), $ = (r, t, e, i) => (E(r, t, "write to private field"), t.set(r, e), e), l = class _ {
  /**
   * @param {number} Coordinate of the point on the horizontal axis
   * @param {number} Coordinate of the point on the vertical axis
   */
  constructor(t, e) {
    this.x = t, this.y = e;
  }
  /**
   * Returns the delta between this point and another point.
   *
   * @param {Point} a - A point
   * @param {Point} b - Another point
   */
  static delta(t, e) {
    return new _(t.x - e.x, t.y - e.y);
  }
  /**
   * Returns the distance (hypotenuse) between this point and another point.
   *
   * @param {Point} a - A point
   * @param {Point} b - Another point
   */
  static distance(t, e) {
    return Math.hypot(t.x - e.x, t.y - e.y);
  }
  /**
   * Returns true if both points are equal.
   *
   * @param {Point} a - A point
   * @param {Point} b - Another point
   */
  static equals(t, e) {
    return t.x === e.x && t.y === e.y;
  }
  static from({ x: t, y: e }) {
    return new _(t, e);
  }
}, nt = class h {
  constructor(t, e, i, n) {
    this.left = t, this.top = e, this.width = i, this.height = n, this.scale = {
      x: 1,
      y: 1
    };
  }
  get inverseScale() {
    return {
      x: 1 / this.scale.x,
      y: 1 / this.scale.y
    };
  }
  translate(t, e) {
    const { top: i, left: n, width: o, height: s, scale: c } = this, a = new h(n + t, i + e, o, s);
    return a.scale = K({}, c), a;
  }
  get boundingRectangle() {
    const { width: t, height: e, left: i, top: n, right: o, bottom: s } = this;
    return { width: t, height: e, left: i, top: n, right: o, bottom: s };
  }
  get center() {
    const { left: t, top: e, right: i, bottom: n } = this;
    return new l((t + i) / 2, (e + n) / 2);
  }
  get area() {
    const { width: t, height: e } = this;
    return t * e;
  }
  equals(t) {
    if (!(t instanceof h))
      return !1;
    const { left: e, top: i, width: n, height: o } = this;
    return e === t.left && i === t.top && n === t.width && o === t.height;
  }
  containsPoint(t) {
    const { top: e, left: i, bottom: n, right: o } = this;
    return e <= t.y && t.y <= n && i <= t.x && t.x <= o;
  }
  intersectionArea(t) {
    return t instanceof h ? tt(this, t) : 0;
  }
  intersectionRatio(t) {
    const { area: e } = this, i = this.intersectionArea(t);
    return i / (t.area + e - i);
  }
  get bottom() {
    const { top: t, height: e } = this;
    return t + e;
  }
  get right() {
    const { left: t, width: e } = this;
    return t + e;
  }
  get aspectRatio() {
    const { width: t, height: e } = this;
    return t / e;
  }
  get corners() {
    return [
      { x: this.left, y: this.top },
      { x: this.right, y: this.top },
      { x: this.left, y: this.bottom },
      { x: this.right, y: this.bottom }
    ];
  }
  static from({ top: t, left: e, width: i, height: n }) {
    return new h(e, t, i, n);
  }
  static delta(t, e, i = { x: "center", y: "center" }) {
    const n = (o, s) => {
      const c = i[s], a = s === "x" ? o.left : o.top, u = s === "x" ? o.width : o.height;
      return c == "start" ? a : c == "end" ? a + u : a + u / 2;
    };
    return l.delta(
      { x: n(t, "x"), y: n(t, "y") },
      { x: n(e, "x"), y: n(e, "y") }
    );
  }
  static intersectionRatio(t, e) {
    return h.from(t).intersectionRatio(h.from(e));
  }
};
function tt(r, t) {
  const e = Math.max(t.top, r.top), i = Math.max(t.left, r.left), n = Math.min(t.left + t.width, r.left + r.width), o = Math.min(t.top + t.height, r.top + r.height), s = n - i, c = o - e;
  return i < n && e < o ? s * c : 0;
}
var b, q, w, y, f, m = class extends (w = W, q = [S], b = [S], w) {
  constructor(r) {
    const t = l.from(r);
    super(t, (e, i) => l.equals(e, i)), X(f, 5, this), Z(this, y, 0), this.velocity = { x: 0, y: 0 };
  }
  get delta() {
    return l.delta(this.current, this.initial);
  }
  get direction() {
    const { current: r, previous: t } = this;
    if (!t) return null;
    const e = {
      x: r.x - t.x,
      y: r.y - t.y
    };
    return !e.x && !e.y ? null : Math.abs(e.x) > Math.abs(e.y) ? e.x > 0 ? "right" : "left" : e.y > 0 ? "down" : "up";
  }
  get current() {
    return super.current;
  }
  set current(r) {
    const { current: t } = this, e = l.from(r), i = {
      x: e.x - t.x,
      y: e.y - t.y
    }, n = Date.now(), o = n - Y(this, y), s = (c) => Math.round(c / o * 100);
    G(() => {
      $(this, y, n), this.velocity = {
        x: s(i.x),
        y: s(i.y)
      }, super.current = e;
    });
  }
  reset(r = this.defaultValue) {
    super.reset(l.from(r)), this.velocity = { x: 0, y: 0 };
  }
};
f = L(w);
y = /* @__PURE__ */ new WeakMap();
D(f, 2, "delta", q, m);
D(f, 2, "direction", b, m);
U(f, m);
function it({ x: r, y: t }, e) {
  const i = Math.abs(r), n = Math.abs(t);
  return typeof e == "number" ? Math.sqrt(A(i, 2) + A(n, 2)) > e : "x" in e && "y" in e ? i > e.x && n > e.y : "x" in e ? i > e.x : "y" in e ? n > e.y : !1;
}
var V = /* @__PURE__ */ ((r) => (r.Horizontal = "x", r.Vertical = "y", r))(V || {}), ot = Object.values(V);
export {
  ot as Axes,
  V as Axis,
  l as Point,
  m as Position,
  nt as Rectangle,
  it as exceedsDistance
};
//# sourceMappingURL=index.js.map
