import { ref as it, getCurrentInstance as yt, onMounted as ot, onUnmounted as bt, nextTick as wt, unref as o, defineComponent as _t, useUser as St, useColor as xt, useSpace as Tt, watch as It, useDraw as Dt, onActivated as Et, onDeactivated as Ct, onBeforeUnmount as kt, resolveComponent as Pt, openBlock as b, createElementBlock as S, normalizeStyle as Ot, createCommentVNode as Nt, createVNode as q, createBaseVNode as v, toDisplayString as Mt, Fragment as B, renderList as R, normalizeClass as $t, createBlock as j, selectedUser as D, mergeProps as Lt, withCtx as At, safeHash as zt, useDebounceFn as Gt } from "./composables-Ci32s3jE.js";
import { SpaceArrow as Kt, SpaceGuest as Ut, AccountHome as Bt, UiLayer as Rt } from "./components.js";
function jt() {
  try {
    return "constructor" in GestureEvent;
  } catch {
    return !1;
  }
}
function at() {
  return typeof window < "u" && "ontouchstart" in window;
}
function lt(e) {
  return "pointerId" in e ? null : e.type === "touchend" ? e.changedTouches : e.targetTouches;
}
function ct(e) {
  return Array.from(lt(e)).map((t) => t.identifier);
}
function J(e) {
  const t = "buttons" in e ? e.buttons : 0, { shiftKey: n, altKey: s, metaKey: r, ctrlKey: i } = e;
  return { buttons: t, shiftKey: n, altKey: s, metaKey: r, ctrlKey: i };
}
const Vt = (e) => e;
function Q(e, t = Vt) {
  const n = lt(e), { clientX: s, clientY: r } = n ? n[0] : e;
  return t([s, r]);
}
function ut() {
}
function ft(...e) {
  return e.length === 0 ? ut : e.length === 1 ? e[0] : function() {
    var t;
    for (let n of e)
      t = n.apply(this, arguments) || t;
    return t;
  };
}
function x(e, t) {
  if (e === void 0) {
    if (t === void 0)
      throw new Error("Must define fallback value if undefined is expected");
    e = t;
  }
  return Array.isArray(e) ? e : [e, e];
}
function Z(e, ...t) {
  return typeof e == "function" ? e(...t) : e;
}
function N(e) {
  return {
    _active: !1,
    _blocked: !1,
    _intentional: [!1, !1],
    _movement: [0, 0],
    _initial: [0, 0],
    _bounds: [
      [-1 / 0, 1 / 0],
      [-1 / 0, 1 / 0]
    ],
    _lastEventType: void 0,
    _dragStarted: !1,
    _dragPreventScroll: !1,
    _dragIsTap: !0,
    _dragDelayed: !1,
    event: void 0,
    intentional: !1,
    values: [0, 0],
    velocities: [0, 0],
    delta: [0, 0],
    movement: [0, 0],
    offset: [0, 0],
    lastOffset: [0, 0],
    direction: [0, 0],
    initial: [0, 0],
    previous: [0, 0],
    first: !1,
    last: !1,
    active: !1,
    timeStamp: 0,
    startTime: 0,
    elapsedTime: 0,
    cancel: ut,
    canceled: !1,
    memo: void 0,
    args: void 0,
    ...e
  };
}
function W() {
  const e = {
    hovering: !1,
    scrolling: !1,
    wheeling: !1,
    dragging: !1,
    moving: !1,
    pinching: !1,
    touches: 0,
    buttons: 0,
    down: !1,
    shiftKey: !1,
    altKey: !1,
    metaKey: !1,
    ctrlKey: !1,
    locked: !1
  }, t = N({
    _pointerId: void 0,
    axis: void 0,
    xy: [0, 0],
    vxvy: [0, 0],
    velocity: 0,
    distance: 0,
    tap: !1,
    swipe: [0, 0]
  }), n = N({
    // @ts-expect-error when used _pointerIds we can assert its type will be [number, number]
    _pointerIds: [],
    da: [0, 0],
    vdva: [0, 0],
    // @ts-expect-error origin can never be passed as undefined in userland
    origin: void 0,
    turns: 0
  }), s = N({
    axis: void 0,
    xy: [0, 0],
    vxvy: [0, 0],
    velocity: 0,
    distance: 0
  }), r = N({
    axis: void 0,
    xy: [0, 0],
    vxvy: [0, 0],
    velocity: 0,
    distance: 0
  }), i = N({
    axis: void 0,
    xy: [0, 0],
    vxvy: [0, 0],
    velocity: 0,
    distance: 0
  });
  return { shared: e, drag: t, pinch: n, wheel: s, move: r, scroll: i };
}
var Wt = Object.defineProperty, Ft = (e, t, n) => t in e ? Wt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, g = (e, t, n) => (Ft(e, typeof t != "symbol" ? t + "" : t, n), n);
class Yt {
  constructor(t) {
    this.classes = t, g(this, "nativeRefs"), g(this, "config"), g(this, "handlers"), g(this, "state"), g(this, "timeouts"), g(this, "domListeners"), g(this, "windowListeners"), g(this, "pointerIds", /* @__PURE__ */ new Set()), g(this, "touchIds", /* @__PURE__ */ new Set()), g(this, "supportsTouchEvents", at()), g(this, "supportsGestureEvents", jt()), g(this, "bind", (...n) => {
      const s = {};
      for (let r of this.classes)
        new r(this, n).addBindings(s);
      for (let r in this.nativeRefs)
        w(
          s,
          r,
          (i) => this.nativeRefs[r]({ ...this.state.shared, event: i, args: n })
        );
      return this.config.domTarget ? Zt(this, s) : te(this, s);
    }), g(this, "clean", () => {
      const { eventOptions: n, domTarget: s } = this.config, r = o(s);
      r && M(r, dt(this.domListeners), n), Object.values(this.timeouts).forEach(clearTimeout), qt(this);
    }), g(this, "reset", () => {
      this.state = W();
    }), this.classes = t, this.state = W(), this.timeouts = {}, this.domListeners = [], this.windowListeners = {};
  }
}
function Ht(e, t) {
  "pointerId" in t ? e.pointerIds.add(t.pointerId) : e.touchIds = new Set(ct(t));
}
function Xt(e, t) {
  "pointerId" in t ? e.pointerIds.delete(t.pointerId) : ct(t).forEach((n) => e.touchIds.delete(n));
}
function qt(e) {
  const {
    config: { window: t, eventOptions: n },
    windowListeners: s
  } = e, r = o(t);
  if (r) {
    for (let i in s) {
      const a = s[i];
      M(r, a, n);
    }
    e.windowListeners = {};
  }
}
function Jt({ config: e, windowListeners: t }, n, s = e.eventOptions) {
  const r = o(e.window);
  r && (M(r, t[n], s), delete t[n]);
}
function Qt({ config: e, windowListeners: t }, n, s = [], r = e.eventOptions) {
  const i = o(e.window);
  i && (M(i, t[n], r), ht(i, t[n] = s, r));
}
function Zt({ config: e, domListeners: t }, n) {
  const { eventOptions: s, domTarget: r } = e, i = o(r);
  if (!i)
    throw new Error("domTarget must be defined");
  M(i, dt(t), s);
  for (let [a, l] of Object.entries(n)) {
    const h = a.slice(2).toLowerCase();
    t.push([h, ft(...l)]);
  }
  ht(i, t, s);
}
function te({ config: e }, t) {
  const n = {}, s = e.eventOptions.capture ? "Capture" : "";
  for (let [r, i] of Object.entries(t)) {
    const a = Array.isArray(i) ? i : [i], l = r + s;
    n[l] = ft(...a);
  }
  return n;
}
function dt(e = []) {
  return e.splice(0, e.length);
}
function w(e, t, n) {
  e[t] || (e[t] = []), e[t].push(n);
}
function ht(e, t = [], n = {}) {
  if (e)
    for (let [s, r] of t)
      e.addEventListener(s, r, n);
}
function M(e, t = [], n = {}) {
  if (e)
    for (let [s, r] of t)
      e.removeEventListener(s, r, n);
}
function F(e, t) {
  return e.map((n, s) => n + t[s]);
}
function pt(e, t) {
  return e.map((n, s) => n - t[s]);
}
function Y(e) {
  return Math.hypot(...e);
}
function ee(e, t, n) {
  const s = Y(t), r = s === 0 ? 0 : 1 / s, i = n === 0 ? 0 : 1 / n, a = i * s, l = t.map((c) => i * c), h = t.map((c) => r * c), f = Y(e);
  return { velocities: l, velocity: a, distance: f, direction: h };
}
function H(e) {
  return Math.sign ? Math.sign(e) : +(e > 0) - +(e < 0) || +e;
}
function ne(e, t, n) {
  return Math.max(t, Math.min(e, n));
}
function se(e, t) {
  return Math.pow(e, t * 5);
}
function tt(e, t, n) {
  return t === 0 || Math.abs(t) === 1 / 0 ? se(e, n) : e * t * n / (t + n * e);
}
function et(e, t, n, s = 0.15) {
  return s === 0 ? ne(e, t, n) : e < t ? -tt(t - e, n - t, s) + t : e > n ? +tt(e - n, n - t, s) + n : e;
}
var re = Object.defineProperty, ie = (e, t, n) => t in e ? re(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, A = (e, t, n) => (ie(e, typeof t != "symbol" ? t + "" : t, n), n);
const E = /* @__PURE__ */ new Map(), oe = (e) => e;
class ae {
  /**
   * Creates an instance of a gesture recognizer.
   * @param stateKey drag, move, pinch, etc.
   * @param controller the controller attached to the gesture
   * @param [args] the args that should be passed to the gesture handler
   */
  constructor(t, n = []) {
    this.controller = t, this.args = n, A(this, "debounced", !0), A(this, "setTimeout", (s, r = 140, ...i) => {
      clearTimeout(this.controller.timeouts[this.stateKey]), this.controller.timeouts[this.stateKey] = window.setTimeout(
        s,
        r,
        ...i
      );
    }), A(this, "clearTimeout", () => {
      clearTimeout(this.controller.timeouts[this.stateKey]);
    }), A(this, "fireGestureHandler", (s = !1) => {
      if (this.state._blocked)
        return this.debounced || (this.state._active = !1, this.clean()), null;
      if (!s && !this.state.intentional && !this.config.triggerAllEvents)
        return null;
      if (this.state.intentional) {
        const h = this.state.active, f = this.state._active;
        this.state.active = f, this.state.first = f && !h, this.state.last = h && !f, this.controller.state.shared[this.ingKey] = f;
      }
      const r = this.controller.pointerIds.size || this.controller.touchIds.size, i = this.controller.state.shared.buttons > 0 || r > 0, a = {
        ...this.controller.state.shared,
        ...this.state,
        ...this.mapStateValues(this.state),
        // Sets xy or da to the gesture state values
        locked: !!document.pointerLockElement,
        touches: r,
        down: i
      }, l = this.handler(a);
      return this.state.memo = l !== void 0 ? l : this.state.memo, a;
    }), this.controller = t, this.args = n;
  }
  // Returns the gesture config
  get config() {
    return this.controller.config[this.stateKey];
  }
  // Is the gesture enabled
  get enabled() {
    return this.controller.config.enabled && this.config.enabled;
  }
  // Returns the controller state for a given gesture
  get state() {
    return this.controller.state[this.stateKey];
  }
  // Returns the gesture handler
  get handler() {
    return this.controller.handlers[this.stateKey];
  }
  get transform() {
    return this.config.transform || this.controller.config.transform || oe;
  }
  // Convenience method to update the shared state
  updateSharedState(t) {
    Object.assign(this.controller.state.shared, t);
  }
  // Convenience method to update the gesture state
  updateGestureState(t) {
    Object.assign(this.state, t);
  }
  /**
   * Returns state properties depending on the movement and state.
   *
   * Should be overriden for custom behavior, doesn't do anything in the implementation
   * below.
   */
  checkIntentionality(t, n) {
    return { _intentional: t, _blocked: !1 };
  }
  /**
   * Returns basic movement properties for the gesture based on the next values and current state.
   */
  getMovement(t) {
    const { rubberband: n, threshold: s } = this.config, {
      _bounds: r,
      _initial: i,
      _active: a,
      _intentional: l,
      lastOffset: h,
      movement: f
    } = this.state, c = this.getInternalMovement(t, this.state), T = this.transform(s).map(Math.abs), C = l[0] === !1 ? nt(c[0], T[0]) : l[0], k = l[1] === !1 ? nt(c[1], T[1]) : l[1], _ = this.checkIntentionality([C, k], c);
    if (_._blocked)
      return { ..._, _movement: c, delta: [0, 0] };
    const y = _._intentional, G = c;
    let I = [
      y[0] !== !1 ? c[0] - y[0] : 0,
      y[1] !== !1 ? c[1] - y[1] : 0
    ];
    const P = F(I, h), O = a ? n : [0, 0];
    return I = st(r, F(I, i), O), {
      ..._,
      intentional: y[0] !== !1 || y[1] !== !1,
      _initial: i,
      _movement: G,
      movement: I,
      values: t,
      offset: st(r, P, O),
      delta: pt(I, f)
    };
  }
  // Cleans the gesture. Can be overriden by gestures.
  clean() {
    this.clearTimeout();
  }
}
function nt(e, t) {
  return Math.abs(e) >= t ? H(e) * t : !1;
}
function st(e, [t, n], [s, r]) {
  const [[i, a], [l, h]] = e;
  return [
    et(t, i, a, s),
    et(n, l, h, r)
  ];
}
function V({ state: e }, t, n) {
  const { timeStamp: s, type: r } = t, i = e.values, a = n ? 0 : s - e.startTime;
  return { _lastEventType: r, event: t, timeStamp: s, elapsedTime: a, previous: i };
}
function le({ state: e, config: t, stateKey: n, args: s }, r, i) {
  const a = e.offset, l = i.timeStamp, { initial: h, bounds: f } = t, c = {
    ...W()[n],
    _active: !0,
    args: s,
    values: r,
    initial: r,
    offset: a,
    lastOffset: a,
    startTime: l
  };
  return {
    ...c,
    _initial: Z(h, c),
    _bounds: Z(f, c)
  };
}
class ce extends ae {
  /**
   * Returns the real movement (without taking intentionality into account)
   */
  getInternalMovement(t, n) {
    return pt(t, n.initial);
  }
  /**
   * In coordinates-based gesture, this function will detect the first intentional axis,
   * lock the gesture axis if lockDirection is specified in the config, block the gesture
   * if the first intentional axis doesn't match the specified axis in config.
   */
  checkIntentionality(t, n) {
    if (t[0] === !1 && t[1] === !1)
      return { _intentional: t, axis: this.state.axis };
    const [s, r] = n.map(Math.abs), i = this.state.axis || (s > r ? "x" : s < r ? "y" : void 0);
    return !this.config.axis && !this.config.lockDirection ? { _intentional: t, _blocked: !1, axis: i } : i ? this.config.axis && i !== this.config.axis ? { _intentional: t, _blocked: !0, axis: i } : (t[i === "x" ? 1 : 0] = !1, { _intentional: t, _blocked: !1, axis: i }) : { _intentional: [!1, !1], _blocked: !1, axis: i };
  }
  getKinematics(t, n) {
    const s = this.getMovement(t);
    if (!s._blocked) {
      const r = n.timeStamp - this.state.timeStamp;
      Object.assign(
        s,
        ee(s.movement, s.delta, r)
      );
    }
    return s;
  }
  mapStateValues(t) {
    return { xy: t.values, vxvy: t.velocities };
  }
}
var ue = Object.defineProperty, fe = (e, t, n) => t in e ? ue(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, p = (e, t, n) => (fe(e, typeof t != "symbol" ? t + "" : t, n), n);
const de = 3;
function rt(e) {
  "persist" in e && typeof e.persist == "function" && e.persist();
}
class he extends ce {
  constructor() {
    super(...arguments), p(this, "ingKey", "dragging"), p(this, "stateKey", "drag"), p(this, "setPointerCapture", (t) => {
      if (this.config.useTouch || document.pointerLockElement)
        return;
      const { target: n, pointerId: s } = t;
      n && "setPointerCapture" in n && n.setPointerCapture(s), this.updateGestureState({
        _dragTarget: n,
        _dragPointerId: s
      });
    }), p(this, "releasePointerCapture", () => {
      if (this.config.useTouch || document.pointerLockElement)
        return;
      const { _dragTarget: t, _dragPointerId: n } = this.state;
      if (n && t && "releasePointerCapture" in t && (!("hasPointerCapture" in t) || t.hasPointerCapture(n)))
        try {
          t.releasePointerCapture(n);
        } catch {
        }
    }), p(this, "preventScroll", (t) => {
      this.state._dragPreventScroll && t.cancelable && t.preventDefault();
    }), p(this, "getEventId", (t) => this.config.useTouch ? t.changedTouches[0].identifier : t.pointerId), p(this, "isValidEvent", (t) => this.state._pointerId === this.getEventId(t)), p(this, "shouldPreventWindowScrollY", this.config.preventWindowScrollY && this.controller.supportsTouchEvents), p(this, "setUpWindowScrollDetection", (t) => {
      rt(t), Qt(
        this.controller,
        this.stateKey,
        [
          ["touchmove", this.preventScroll],
          ["touchend", this.clean.bind(this)],
          ["touchcancel", this.clean.bind(this)]
        ],
        { passive: !1 }
      ), this.setTimeout(this.startDrag.bind(this), 250, t);
    }), p(this, "setUpDelayedDragTrigger", (t) => {
      this.state._dragDelayed = !0, rt(t), this.setTimeout(this.startDrag.bind(this), this.config.delay, t);
    }), p(this, "setStartState", (t) => {
      const n = Q(t, this.transform);
      this.updateSharedState(J(t)), this.updateGestureState({
        ...le(this, n, t),
        ...V(this, t, !0),
        _pointerId: this.getEventId(t)
        // setting pointerId locks the gesture to this specific event
      }), this.updateGestureState(this.getMovement(n));
    }), p(this, "onDragStart", (t) => {
      Ht(this.controller, t), !(!this.enabled || this.state._active) && (this.setStartState(t), this.setPointerCapture(t), this.shouldPreventWindowScrollY ? this.setUpWindowScrollDetection(t) : this.config.delay > 0 ? this.setUpDelayedDragTrigger(t) : this.startDrag(t, !0));
    }), p(this, "onDragChange", (t) => {
      if (
        // if the gesture was canceled or
        this.state.canceled || // if onDragStart wasn't fired or
        !this.state._active || // if the event pointerId doesn't match the one that initiated the drag
        !this.isValidEvent(t) || // if the event has the same timestamp as the previous event
        // note that checking type equality is ONLY for tests ¯\_(ツ)_/¯
        this.state._lastEventType === t.type && t.timeStamp === this.state.timeStamp
      )
        return;
      let n;
      if (document.pointerLockElement) {
        const { movementX: h, movementY: f } = t;
        n = F(this.transform([h, f]), this.state.values);
      } else
        n = Q(t, this.transform);
      const s = this.getKinematics(n, t);
      if (!this.state._dragStarted) {
        if (this.state._dragDelayed) {
          this.startDrag(t);
          return;
        }
        if (this.shouldPreventWindowScrollY)
          if (!this.state._dragPreventScroll && s.axis)
            if (s.axis === "x")
              this.startDrag(t);
            else {
              this.state._active = !1;
              return;
            }
          else
            return;
        else
          return;
      }
      const r = J(t);
      this.updateSharedState(r);
      const i = V(this, t), a = Y(s._movement);
      let { _dragIsTap: l } = this.state;
      l && a >= de && (l = !1), this.updateGestureState({ ...i, ...s, _dragIsTap: l }), this.fireGestureHandler();
    }), p(this, "onDragEnd", (t) => {
      if (Xt(this.controller, t), !this.isValidEvent(t) || (this.clean(), !this.state._active))
        return;
      this.state._active = !1;
      const n = this.state._dragIsTap, [s, r] = this.state.velocities, [i, a] = this.state.movement, [l, h] = this.state._intentional, [f, c] = this.config.swipeVelocity, [T, C] = this.config.swipeDistance, k = this.config.swipeDuration, _ = {
        ...V(this, t),
        ...this.getMovement(this.state.values)
      }, y = [0, 0];
      _.elapsedTime < k && (l !== !1 && Math.abs(s) > f && Math.abs(i) > T && (y[0] = H(s)), h !== !1 && Math.abs(r) > c && Math.abs(a) > C && (y[1] = H(r))), this.updateSharedState({ buttons: 0 }), this.updateGestureState({ ..._, tap: n, swipe: y }), this.fireGestureHandler(this.config.filterTaps && n === !0);
    }), p(this, "clean", () => {
      super.clean(), this.state._dragStarted = !1, this.releasePointerCapture(), Jt(this.controller, this.stateKey);
    }), p(this, "onCancel", () => {
      this.state.canceled || (this.updateGestureState({ canceled: !0, _active: !1 }), this.updateSharedState({ buttons: 0 }), wt(this.fireGestureHandler));
    }), p(this, "onClick", (t) => {
      this.state._dragIsTap || t.stopPropagation();
    });
  }
  startDrag(t, n = !1) {
    // if the gesture isn't active (probably means)
    !this.state._active || // if the drag has already started we should ignore subsequent attempts
    this.state._dragStarted || (n || this.setStartState(t), this.updateGestureState({
      _dragStarted: !0,
      _dragPreventScroll: !0,
      cancel: this.onCancel
    }), this.clearTimeout(), this.fireGestureHandler());
  }
  addBindings(t) {
    if (this.config.useTouch ? (w(t, "onTouchStart", this.onDragStart), w(t, "onTouchMove", this.onDragChange), w(t, "onTouchEnd", this.onDragEnd), w(t, "onTouchCancel", this.onDragEnd)) : (w(t, "onPointerDown", this.onDragStart), w(t, "onPointerMove", this.onDragChange), w(t, "onPointerUp", this.onDragEnd), w(t, "onPointerCancel", this.onDragEnd)), this.config.filterTaps) {
      const n = this.controller.config.eventOptions.capture ? "onClick" : "onClickCapture";
      w(t, n, this.onClick);
    }
  }
}
function pe(e, t) {
  let n, s = [], r, i = !1;
  function a(...l) {
    return i && n === this && t(l, s) || (r = e.apply(this, l), i = !0, n = this, s = l), r;
  }
  return a;
}
function z(e, t) {
  if (e === t)
    return !0;
  if (e && t && typeof e == "object" && typeof t == "object") {
    if (e.constructor !== t.constructor)
      return !1;
    let n, s, r;
    if (Array.isArray(e)) {
      if (n = e.length, n !== t.length)
        return !1;
      for (s = n; s-- !== 0; )
        if (!z(e[s], t[s]))
          return !1;
      return !0;
    }
    let i;
    if (typeof Map == "function" && e instanceof Map && t instanceof Map) {
      if (e.size !== t.size)
        return !1;
      for (i = e.entries(); !(s = i.next()).done; )
        if (!t.has(s.value[0]))
          return !1;
      for (i = e.entries(); !(s = i.next()).done; )
        if (!z(s.value[1], t.get(s.value[0])))
          return !1;
      return !0;
    }
    if (typeof Set == "function" && e instanceof Set && t instanceof Set) {
      if (e.size !== t.size)
        return !1;
      for (i = e.entries(); !(s = i.next()).done; )
        if (!t.has(s.value[0]))
          return !1;
      return !0;
    }
    if (e.constructor === RegExp)
      return e.source === t.source && e.flags === t.flags;
    if (e.valueOf !== Object.prototype.valueOf)
      return e.valueOf() === t.valueOf();
    if (e.toString !== Object.prototype.toString)
      return e.toString() === t.toString();
    if (r = Object.keys(e), n = r.length, n !== Object.keys(t).length)
      return !1;
    for (s = n; s-- !== 0; )
      if (!Object.prototype.hasOwnProperty.call(t, r[s]))
        return !1;
    if (typeof Element < "u" && e instanceof Element)
      return !1;
    for (s = n; s-- !== 0; )
      if (!(r[s] === "_owner" && e.$$typeof) && !z(e[r[s]], t[r[s]]))
        return !1;
    return !0;
  }
  return e !== e && t !== t;
}
function me(e, t) {
  try {
    return z(e, t);
  } catch (n) {
    if ((n.message || "").match(/stack|recursion/i))
      return console.warn("react-fast-compare cannot handle circular refs"), !1;
    throw n;
  }
}
function X(e = {}, t) {
  const n = {};
  for (const [s, r] of Object.entries(t))
    switch (typeof r) {
      case "function":
        n[s] = r.call(n, e[s], s, e);
        break;
      case "object":
        n[s] = X(e[s], r);
        break;
      case "boolean":
        r && (n[s] = e[s]);
        break;
    }
  return n;
}
const ge = 180, ve = 0.15, ye = 0.5, be = 50, we = 250, _e = {
  threshold(e = 0) {
    return x(e);
  },
  rubberband(e = 0) {
    switch (e) {
      case !0:
        return x(ve);
      case !1:
        return x(0);
      default:
        return x(e);
    }
  },
  enabled(e = !0) {
    return e;
  },
  triggerAllEvents(e = !1) {
    return e;
  },
  initial(e = 0) {
    return typeof e == "function" ? e : x(e);
  },
  transform: !0
}, mt = {
  ..._e,
  axis: !0,
  lockDirection(e = !1) {
    return e;
  },
  bounds(e = {}) {
    if (typeof e == "function")
      return (i) => mt.bounds(e(i));
    const {
      left: t = -1 / 0,
      right: n = 1 / 0,
      top: s = -1 / 0,
      bottom: r = 1 / 0
    } = e;
    return [
      [t, n],
      [s, r]
    ];
  }
}, Se = typeof window < "u" && window.document && window.document.createElement, xe = {
  enabled(e = !0) {
    return e;
  },
  domTarget: !0,
  window(e = Se ? window : void 0) {
    return e;
  },
  eventOptions({ passive: e = !0, capture: t = !1 } = {}) {
    return { passive: e, capture: t };
  },
  transform: !0
}, Te = {
  ...mt,
  useTouch(e = !0) {
    return e && at();
  },
  preventWindowScrollY(e = !1) {
    return e;
  },
  threshold(e, t, { filterTaps: n = !1, lockDirection: s = !1, axis: r = void 0 }) {
    const i = x(
      e,
      n ? 3 : s || r ? 1 : 0
    );
    return this.filterTaps = n, i;
  },
  swipeVelocity(e = ye) {
    return x(e);
  },
  swipeDistance(e = be) {
    return x(e);
  },
  swipeDuration(e = we) {
    return e;
  },
  delay(e = 0) {
    switch (e) {
      case !0:
        return ge;
      case !1:
        return 0;
      default:
        return e;
    }
  }
};
function Ie(e) {
  return X(
    e,
    xe
  );
}
function De(e = {}) {
  return X(
    e,
    Te
  );
}
function Ee({
  domTarget: e,
  eventOptions: t,
  window: n,
  enabled: s,
  ...r
}) {
  const i = Ie({
    domTarget: e,
    eventOptions: t,
    window: n,
    enabled: s
  });
  return i.drag = De(r), i;
}
function Ce(e, t, n = {}) {
  const s = ke(e), r = new Yt(s);
  return r.config = t, r.handlers = e, r.nativeRefs = n, yt() && !t.manual && (ot(r.bind), bt(r.clean)), r;
}
function ke(e) {
  const t = /* @__PURE__ */ new Set();
  return e.drag && t.add(E.get("drag")), e.wheel && t.add(E.get("wheel")), e.scroll && t.add(E.get("scroll")), e.move && t.add(E.get("move")), e.pinch && t.add(E.get("pinch")), e.hover && t.add(E.get("hover")), t;
}
function Pe(e, t = {}) {
  E.set("drag", he);
  const n = it();
  return n.value || (n.value = pe(Ee, me)), Ce({ drag: e }, n.value(t));
}
const Oe = { class: "flex flex-col items-center" }, Ne = ["viewBox"], Me = /* @__PURE__ */ v("defs", null, [
  /* @__PURE__ */ v("filter", {
    id: "shadowButton",
    x: "-50%",
    height: "200%",
    width: "300%"
  }, [
    /* @__PURE__ */ v("feDropShadow", {
      dx: "0",
      dy: "3",
      stdDeviation: "3",
      "flood-color": "#2225"
    })
  ]),
  /* @__PURE__ */ v("clipPath", {
    id: "mask",
    clipPathUnits: "objectBoundingBox"
  }, [
    /* @__PURE__ */ v("circle", {
      r: ".5",
      cx: ".5",
      cy: ".5"
    })
  ])
], -1), $e = ["transform"], Le = ["innerHTML"], Ae = ["x", "y", "viewBox"], ze = ["x", "y", "width", "height"], Ge = { class: "link" }, Ke = ["x1", "x2", "y1", "y2", "stroke"], Ue = ["transform"], Be = { class: "mouse" }, Re = ["fill"], je = { class: "arrows" }, Ve = { class: "guests" }, Ye = /* @__PURE__ */ _t({
  __name: "SpacePlane",
  props: {
    pad: { type: Number, default: 50 },
    coord: { type: String, default: "" }
  },
  emits: ["user", "enter", "leave", "chat", "post", "update:coord"],
  setup(e, { emit: t }) {
    const n = t, { user: s } = St();
    xt("deep");
    const {
      space: r,
      plane: i,
      pos: a,
      zoom: l,
      links: h,
      width: f,
      height: c,
      guests: T,
      guestCount: C,
      area: k,
      join: _,
      place: y,
      setStatus: G
    } = Tt({
      TIMEOUT: 1e4
    });
    It(C, (m, d) => {
      m > d ? n("enter") : n("leave");
    });
    const I = Gt((m) => {
      y({
        x: m[0],
        y: m[1]
      }), n("update:coord", `${m[0]},${m[1]}`);
    }, 200);
    Pe(
      (m) => {
        if (!(m.delta[0] && m.delta[1]) || K.ing) return;
        const [d, U] = m.delta;
        a[0] -= d, a[1] -= U, I(a);
      },
      {
        domTarget: i
      }
    );
    const P = it(), { drauu: O, draw: K, loadCanvas: gt } = Dt();
    return ot(() => {
      O.mount(P.value, P.value.parentElement), gt();
    }), Et(() => {
      console.log("activated");
    }), Ct(() => {
      console.log("deactivated");
    }), kt(() => {
      O.unmount();
    }), (m, d) => {
      const U = Pt("space-draw");
      return b(), S("div", Oe, [
        !o(r).joined && o(s).is ? (b(), S("div", {
          key: 0,
          class: "text-2xl p-8 top-15vh cursor-pointer absolute rounded-3xl shadow-xl border-4",
          style: Ot({ borderColor: o(s).color }),
          onClick: d[0] || (d[0] = (u) => {
            o(_)();
          })
        }, "Click anywhere to join the space", 4)) : Nt("", !0),
        q(U, { class: "z-500" }),
        (b(), S("svg", {
          class: "h-full w-full z-200 bg-dark-100 bg-opacity-5 touch-none cursor-grab active-cursor-grabbing",
          ref_key: "plane",
          ref: i,
          xmlns: "http://www.w3.org/2000/svg",
          version: "1.1",
          baseProfile: "full",
          "font-family": "Commissioner , sans-serif",
          "text-anchor": "middle",
          "dominant-baseline": "middle",
          viewBox: `${-e.pad + o(a)[0] - Number(o(f)) / 2} ${-e.pad + o(a)[1] - Number(o(c)) / 2} ${Number(o(f)) * Number(o(l)) + 2 * e.pad} ${Number(o(c)) * Number(o(l)) + 2 * e.pad}`,
          onClick: d[3] || (d[3] = (u) => {
            o(s).is || (o(s).auth = !0);
          })
        }, [
          Me,
          v("text", {
            class: "text-xs",
            "text-anchor": "end",
            fill: "currentColor",
            transform: `translate(${o(a)[0] + Number(o(f)) / 2 - 10} ${o(a)[1] - Number(o(c)) / 2 + 20})`
          }, Mt(o(a)), 9, $e),
          (b(!0), S(B, null, R(o(T), (u) => (b(), S("g", {
            class: "opacity-90",
            key: u.draw,
            innerHTML: u.draw
          }, null, 8, Le))), 128)),
          (b(), S("svg", {
            class: $t(["opacity-70", { "pointer-events-none": !o(K).enabled, "touch-none": o(K).enabled }]),
            ref_key: "paper",
            ref: P,
            x: o(a)[0] - Number(o(f)) / 2 - e.pad,
            y: o(a)[1] - Number(o(c)) / 2 - e.pad,
            viewBox: `${-e.pad + o(a)[0] - Number(o(f)) / 2} ${-e.pad + o(a)[1] - Number(o(c)) / 2} ${Number(o(f)) + 2 * e.pad} ${Number(o(c)) + 2 * e.pad}`
          }, null, 10, Ae)),
          v("rect", {
            ref_key: "area",
            ref: k,
            x: o(a)[0] - Number(o(f)) / 2,
            y: o(a)[1] - Number(o(c)) / 2,
            rx: "12",
            width: Number(o(f)),
            height: Number(o(c)),
            fill: "none",
            stroke: "#3333",
            "stroke-width": "1"
          }, null, 8, ze),
          v("g", Ge, [
            v("line", {
              x1: o(a)[0],
              x2: o(r).my.mouse.x,
              y1: o(a)[1],
              y2: o(r).my.mouse.y,
              stroke: o(s).color,
              "stroke-dasharray": "6"
            }, null, 8, Ke)
          ]),
          v("g", {
            class: "pointer",
            transform: `translate(${o(a)[0]} ${o(a)[1]})`
          }, [
            v("g", Be, [
              v("circle", {
                style: { filter: "url(#shadowButton)" },
                fill: o(s).color,
                r: "8"
              }, null, 8, Re)
            ])
          ], 8, Ue),
          v("g", je, [
            (b(!0), S(B, null, R(o(h), (u, $) => (b(), j(o(Kt), {
              key: $,
              link: u,
              onUser: d[1] || (d[1] = (L) => o(D).pub = L)
            }, null, 8, ["link"]))), 128))
          ]),
          v("g", Ve, [
            (b(!0), S(B, null, R(o(T), (u) => {
              var $, L;
              return b(), j(o(Ut), Lt({
                class: "cursor-pointer transition-all ease-out duration-600",
                key: u == null ? void 0 : u.pub,
                ref_for: !0
              }, u, {
                style: { transform: `translate(${($ = u == null ? void 0 : u.pos) == null ? void 0 : $.x}px, ${(L = u == null ? void 0 : u.pos) == null ? void 0 : L.y}px)` },
                onUpdateStatus: d[2] || (d[2] = (vt) => o(G)(vt))
              }), null, 16, ["style"]);
            }), 128))
          ])
        ], 8, Ne)),
        q(o(Rt), {
          class: "z-4000",
          open: !!o(D).pub,
          onClose: d[8] || (d[8] = (u) => o(D).pub = null)
        }, {
          default: At(() => [
            (b(), j(o(Bt), {
              class: "max-w-600px",
              key: o(D).pub,
              pub: o(D).pub,
              onUser: d[4] || (d[4] = (u) => m.$emit("user", u)),
              onPost: d[5] || (d[5] = (u) => m.$emit("post", String(o(zt)(u)))),
              onChat: d[6] || (d[6] = (u) => m.$emit("chat", o(D).pub)),
              onClose: d[7] || (d[7] = (u) => o(D).pub = null)
            }, null, 8, ["pub"]))
          ]),
          _: 1
        }, 8, ["open"])
      ]);
    };
  }
});
export {
  Ye as default
};
//# sourceMappingURL=SpacePlane-BxMRZyk5.js.map
