vue3-ts-grid-layout
Version:
Vue 3 Responsive & Dynamic Grid / Dashboard layout with drag, drop and resizable actions.
1,660 lines • 155 kB
JavaScript
var Fi = Object.defineProperty;
var Yi = (t, e, n) => e in t ? Fi(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
var g = (t, e, n) => (Yi(t, typeof e != "symbol" ? e + "" : e, n), n);
import { getCurrentInstance as Ui, defineComponent as se, inject as Vi, ref as N, computed as At, watch as Y, onBeforeUnmount as ti, onMounted as ei, useSlots as ji, openBlock as _e, createElementBlock as Ie, normalizeClass as ni, normalizeStyle as tn, createCommentVNode as Gi, renderSlot as ii, pushScopeId as fn, popScopeId as dn, createElementVNode as De, useCssVars as Xi, unref as me, toRef as Sn, provide as qi, toRefs as Ki, onBeforeMount as Zi, nextTick as Ct, withDirectives as Ji, createVNode as Qi, vShow as to, toDisplayString as eo } from "vue";
const wt = {
init: no,
document: null,
DocumentFragment: null,
SVGElement: null,
SVGSVGElement: null,
SVGElementInstance: null,
Element: null,
HTMLElement: null,
Event: null,
Touch: null,
PointerEvent: null
};
function Qt() {
}
const vt = wt;
function no(t) {
const e = t;
wt.document = e.document, wt.DocumentFragment = e.DocumentFragment || Qt, wt.SVGElement = e.SVGElement || Qt, wt.SVGSVGElement = e.SVGSVGElement || Qt, wt.SVGElementInstance = e.SVGElementInstance || Qt, wt.Element = e.Element || Qt, wt.HTMLElement = e.HTMLElement || wt.Element, wt.Event = e.Event, wt.Touch = e.Touch || Qt, wt.PointerEvent = e.PointerEvent || e.MSPointerEvent;
}
const oi = (t) => !!(t && t.Window) && t instanceof t.Window;
let ri, Wt;
function si(t) {
ri = t;
const e = t.document.createTextNode("");
e.ownerDocument !== t.document && typeof t.wrap == "function" && t.wrap(e) === e && (t = t.wrap(t)), Wt = t;
}
typeof window < "u" && !!window && si(window);
function qt(t) {
return oi(t) ? t : (t.ownerDocument || t).defaultView || Wt.window;
}
const io = (t) => t === Wt || oi(t), oo = (t) => Le(t) && t.nodeType === 11, Le = (t) => !!t && typeof t == "object", ai = (t) => typeof t == "function", ro = (t) => typeof t == "number", so = (t) => typeof t == "boolean", ao = (t) => typeof t == "string", lo = (t) => {
if (!t || typeof t != "object")
return !1;
const e = qt(t) || Wt;
return /object|function/.test(typeof Element) ? t instanceof Element || t instanceof e.Element : t.nodeType === 1 && typeof t.nodeName == "string";
}, co = (t) => Le(t) && !!t.constructor && /function Object\b/.test(t.constructor.toString()), uo = (t) => Le(t) && typeof t.length < "u" && ai(t.splice), m = {
window: io,
docFrag: oo,
object: Le,
func: ai,
number: ro,
bool: so,
string: ao,
element: lo,
plainObject: co,
array: uo
}, _t = {
init: fo,
supportsTouch: null,
supportsPointerEvent: null,
isIOS7: null,
isIOS: null,
isIe9: null,
isOperaMobile: null,
prefixedMatchesSelector: null,
pEventTypes: null,
wheelEvent: null
};
function fo(t) {
const e = vt.Element, n = t.navigator || {};
_t.supportsTouch = "ontouchstart" in t || m.func(t.DocumentTouch) && vt.document instanceof t.DocumentTouch, _t.supportsPointerEvent = n.pointerEnabled !== !1 && !!vt.PointerEvent, _t.isIOS = /iP(hone|od|ad)/.test(n.platform), _t.isIOS7 = /iP(hone|od|ad)/.test(n.platform) && /OS 7[^\d]/.test(n.appVersion), _t.isIe9 = /MSIE 9/.test(n.userAgent), _t.isOperaMobile = n.appName === "Opera" && _t.supportsTouch && /Presto/.test(n.userAgent), _t.prefixedMatchesSelector = "matches" in e.prototype ? "matches" : "webkitMatchesSelector" in e.prototype ? "webkitMatchesSelector" : "mozMatchesSelector" in e.prototype ? "mozMatchesSelector" : "oMatchesSelector" in e.prototype ? "oMatchesSelector" : "msMatchesSelector", _t.pEventTypes = _t.supportsPointerEvent ? vt.PointerEvent === t.MSPointerEvent ? {
up: "MSPointerUp",
down: "MSPointerDown",
over: "mouseover",
out: "mouseout",
move: "MSPointerMove",
cancel: "MSPointerCancel"
} : {
up: "pointerup",
down: "pointerdown",
over: "pointerover",
out: "pointerout",
move: "pointermove",
cancel: "pointercancel"
} : null, _t.wheelEvent = vt.document && "onmousewheel" in vt.document ? "mousewheel" : "wheel";
}
const Tt = _t, ho = (t, e) => t.indexOf(e) !== -1, li = (t, e) => {
for (const n of e)
t.push(n);
return t;
}, ci = (t) => li([], t), $e = (t, e) => {
for (let n = 0; n < t.length; n++)
if (e(t[n], n, t))
return n;
return -1;
}, en = (t, e) => t[$e(t, e)];
function re(t) {
const e = {};
for (const n in t) {
const i = t[n];
m.plainObject(i) ? e[n] = re(i) : m.array(i) ? e[n] = ci(i) : e[n] = i;
}
return e;
}
function P(t, e) {
for (const i in e)
t[i] = e[i];
return t;
}
let En = 0, Nt, Vt;
function po(t) {
if (Nt = t.requestAnimationFrame, Vt = t.cancelAnimationFrame, !Nt) {
const e = ["ms", "moz", "webkit", "o"];
for (const n of e)
Nt = t[`${n}RequestAnimationFrame`], Vt = t[`${n}CancelAnimationFrame`] || t[`${n}CancelRequestAnimationFrame`];
}
Nt = Nt && Nt.bind(t), Vt = Vt && Vt.bind(t), Nt || (Nt = (e) => {
const n = Date.now(), i = Math.max(0, 16 - (n - En)), o = t.setTimeout(() => {
e(n + i);
}, i);
return En = n + i, o;
}, Vt = (e) => clearTimeout(e));
}
const te = {
request: (t) => Nt(t),
cancel: (t) => Vt(t),
init: po
};
function ie(t, e, n) {
if (n = n || {}, m.string(t) && t.search(" ") !== -1 && (t = Dn(t)), m.array(t))
return t.reduce((i, o) => P(i, ie(o, e, n)), n);
if (m.object(t) && (e = t, t = ""), m.func(e))
n[t] = n[t] || [], n[t].push(e);
else if (m.array(e))
for (const i of e)
ie(t, i, n);
else if (m.object(e))
for (const i in e) {
const o = Dn(i).map((s) => `${t}${s}`);
ie(o, e[i], n);
}
return n;
}
function Dn(t) {
return t.trim().split(/ +/);
}
function An(t, e) {
for (const n of e) {
if (t.immediatePropagationStopped)
break;
n(t);
}
}
class ui {
constructor(e) {
g(this, "options");
g(this, "types", {});
g(this, "propagationStopped", !1);
g(this, "immediatePropagationStopped", !1);
g(this, "global");
this.options = P({}, e || {});
}
fire(e) {
let n;
const i = this.global;
(n = this.types[e.type]) && An(e, n), !e.propagationStopped && i && (n = i[e.type]) && An(e, n);
}
on(e, n) {
const i = ie(e, n);
for (e in i)
this.types[e] = li(this.types[e] || [], i[e]);
}
off(e, n) {
const i = ie(e, n);
for (e in i) {
const o = this.types[e];
if (!(!o || !o.length))
for (const s of i[e]) {
const a = o.indexOf(s);
a !== -1 && o.splice(a, 1);
}
}
}
getRect(e) {
return null;
}
}
function Gt(t, e) {
if (t.contains)
return t.contains(e);
for (; e; ) {
if (e === t)
return !0;
e = e.parentNode;
}
return !1;
}
function fi(t, e) {
for (; m.element(t); ) {
if (Kt(t, e))
return t;
t = Ft(t);
}
return null;
}
function Ft(t) {
let e = t.parentNode;
if (m.docFrag(e)) {
for (; (e = e.host) && m.docFrag(e); )
;
return e;
}
return e;
}
function Kt(t, e) {
return Wt !== ri && (e = e.replace(/\/deep\//g, " ")), t[Tt.prefixedMatchesSelector](e);
}
function nn(t, e, n) {
for (; m.element(t); ) {
if (Kt(t, e))
return !0;
if (t = Ft(t), t === n)
return Kt(t, e);
}
return !1;
}
function Tn(t) {
return t.correspondingUseElement || t;
}
function go(t) {
return t = t || Wt, {
x: t.scrollX || t.document.documentElement.scrollLeft,
y: t.scrollY || t.document.documentElement.scrollTop
};
}
function hn(t) {
const e = t instanceof vt.SVGElement ? t.getBoundingClientRect() : t.getClientRects()[0];
return e && {
left: e.left,
right: e.right,
top: e.top,
bottom: e.bottom,
width: e.width || e.right - e.left,
height: e.height || e.bottom - e.top
};
}
function pn(t) {
const e = hn(t);
if (!Tt.isIOS7 && e) {
const n = go(qt(t));
e.left += n.x, e.right += n.x, e.top += n.y, e.bottom += n.y;
}
return e;
}
function Rn(t) {
return m.string(t) ? (vt.document.querySelector(t), !0) : !1;
}
function di(t, e, n) {
return t === "parent" ? Ft(n) : t === "self" ? e.getRect(n) : fi(n, t);
}
function Se(t, e, n, i) {
let o = t;
return m.string(o) ? o = di(o, e, n) : m.func(o) && (o = o(...i)), m.element(o) && (o = pn(o)), o;
}
function He(t) {
return t && {
x: "x" in t ? t.x : t.left,
y: "y" in t ? t.y : t.top
};
}
function mo(t) {
return t && !("left" in t && "top" in t) && (t = P({}, t), t.left = t.x || 0, t.top = t.y || 0, t.right = t.right || t.left + t.width, t.bottom = t.bottom || t.top + t.height), t;
}
function On(t) {
return t && !("x" in t && "y" in t) && (t = P({}, t), t.x = t.left || 0, t.y = t.top || 0, t.width = t.width || (t.right || 0) - t.x, t.height = t.height || (t.bottom || 0) - t.y), t;
}
function gn(t, e, n) {
t.left && (e.left += n.x), t.right && (e.right += n.x), t.top && (e.top += n.y), t.bottom && (e.bottom += n.y), e.width = e.right - e.left, e.height = e.bottom - e.top;
}
function mn(t, e, n) {
const i = t.options[n], s = i && i.origin || t.options.origin, a = Se(s, t, e, [t && e]);
return He(a) || {
x: 0,
y: 0
};
}
const Be = (t, e) => Math.sqrt(t * t + e * e);
class hi {
constructor(e) {
g(this, "immediatePropagationStopped", !1);
g(this, "propagationStopped", !1);
this._interaction = e;
}
preventDefault() {
}
stopPropagation() {
this.propagationStopped = !0;
}
stopImmediatePropagation() {
this.immediatePropagationStopped = this.propagationStopped = !0;
}
}
Object.defineProperty(hi.prototype, "interaction", {
get() {
return this._interaction._proxy;
},
set() {
}
});
const pi = {
base: {
preventDefault: "auto",
deltaSource: "page"
},
perAction: {
enabled: !1,
origin: {
x: 0,
y: 0
}
},
actions: {}
};
class vn extends hi {
constructor(n, i, o, s, a, r, l) {
super(n);
g(this, "relatedTarget", null);
g(this, "screenX");
g(this, "screenY");
g(this, "button");
g(this, "buttons");
g(this, "ctrlKey");
g(this, "shiftKey");
g(this, "altKey");
g(this, "metaKey");
g(this, "page");
g(this, "client");
g(this, "delta");
g(this, "rect");
g(this, "x0");
g(this, "y0");
g(this, "t0");
g(this, "dt");
g(this, "duration");
g(this, "clientX0");
g(this, "clientY0");
g(this, "velocity");
g(this, "speed");
g(this, "swipe");
g(this, "axes");
g(this, "preEnd");
a = a || n.element;
const c = n.interactable, u = (c && c.options || pi).deltaSource, f = mn(c, a, o), h = s === "start", b = s === "end", y = h ? this : n.prevEvent, E = h ? n.coords.start : b ? {
page: y.page,
client: y.client,
timeStamp: n.coords.cur.timeStamp
} : n.coords.cur;
this.page = P({}, E.page), this.client = P({}, E.client), this.rect = P({}, n.rect), this.timeStamp = E.timeStamp, b || (this.page.x -= f.x, this.page.y -= f.y, this.client.x -= f.x, this.client.y -= f.y), this.ctrlKey = i.ctrlKey, this.altKey = i.altKey, this.shiftKey = i.shiftKey, this.metaKey = i.metaKey, this.button = i.button, this.buttons = i.buttons, this.target = a, this.currentTarget = a, this.preEnd = r, this.type = l || o + (s || ""), this.interactable = c, this.t0 = h ? n.pointers[n.pointers.length - 1].downTime : y.t0, this.x0 = n.coords.start.page.x - f.x, this.y0 = n.coords.start.page.y - f.y, this.clientX0 = n.coords.start.client.x - f.x, this.clientY0 = n.coords.start.client.y - f.y, h || b ? this.delta = {
x: 0,
y: 0
} : this.delta = {
x: this[u].x - y[u].x,
y: this[u].y - y[u].y
}, this.dt = n.coords.delta.timeStamp, this.duration = this.timeStamp - this.t0, this.velocity = P({}, n.coords.velocity[u]), this.speed = Be(this.velocity.x, this.velocity.y), this.swipe = b || s === "inertiastart" ? this.getSwipe() : null;
}
getSwipe() {
const n = this._interaction;
if (n.prevEvent.speed < 600 || this.timeStamp - n.prevEvent.timeStamp > 150)
return null;
let i = 180 * Math.atan2(n.prevEvent.velocityY, n.prevEvent.velocityX) / Math.PI;
const o = 22.5;
i < 0 && (i += 360);
const s = 135 - o <= i && i < 225 + o, a = 225 - o <= i && i < 315 + o, r = !s && (315 - o <= i || i < 45 + o), l = !a && 45 - o <= i && i < 135 + o;
return {
up: a,
down: l,
left: s,
right: r,
angle: i,
speed: n.prevEvent.speed,
velocity: {
x: n.prevEvent.velocityX,
y: n.prevEvent.velocityY
}
};
}
preventDefault() {
}
stopImmediatePropagation() {
this.immediatePropagationStopped = this.propagationStopped = !0;
}
stopPropagation() {
this.propagationStopped = !0;
}
}
Object.defineProperties(vn.prototype, {
pageX: {
get() {
return this.page.x;
},
set(t) {
this.page.x = t;
}
},
pageY: {
get() {
return this.page.y;
},
set(t) {
this.page.y = t;
}
},
clientX: {
get() {
return this.client.x;
},
set(t) {
this.client.x = t;
}
},
clientY: {
get() {
return this.client.y;
},
set(t) {
this.client.y = t;
}
},
dx: {
get() {
return this.delta.x;
},
set(t) {
this.delta.x = t;
}
},
dy: {
get() {
return this.delta.y;
},
set(t) {
this.delta.y = t;
}
},
velocityX: {
get() {
return this.velocity.x;
},
set(t) {
this.velocity.x = t;
}
},
velocityY: {
get() {
return this.velocity.y;
},
set(t) {
this.velocity.y = t;
}
}
});
function Ee(t, e) {
let n = !1;
return function() {
return n || (Wt.console.warn(e), n = !0), t.apply(this, arguments);
};
}
function gi(t, e) {
return t.name = e.name, t.axis = e.axis, t.edges = e.edges, t;
}
function mi(t, e) {
t.__set || (t.__set = {});
for (const n in e)
typeof t[n] != "function" && n !== "__set" && Object.defineProperty(t, n, {
get() {
return n in t.__set ? t.__set[n] : t.__set[n] = e[n];
},
set(i) {
t.__set[n] = i;
},
configurable: !0
});
return t;
}
function Xe(t, e) {
t.page = t.page || {}, t.page.x = e.page.x, t.page.y = e.page.y, t.client = t.client || {}, t.client.x = e.client.x, t.client.y = e.client.y, t.timeStamp = e.timeStamp;
}
function vo(t, e, n) {
t.page.x = n.page.x - e.page.x, t.page.y = n.page.y - e.page.y, t.client.x = n.client.x - e.client.x, t.client.y = n.client.y - e.client.y, t.timeStamp = n.timeStamp - e.timeStamp;
}
function yo(t, e) {
const n = Math.max(e.timeStamp / 1e3, 1e-3);
t.page.x = e.page.x / n, t.page.y = e.page.y / n, t.client.x = e.client.x / n, t.client.y = e.client.y / n, t.timeStamp = n;
}
function bo(t) {
t.page.x = 0, t.page.y = 0, t.client.x = 0, t.client.y = 0;
}
function vi(t) {
return t instanceof vt.Event || t instanceof vt.Touch;
}
function Me(t, e, n) {
return n = n || {}, t = t || "page", n.x = e[t + "X"], n.y = e[t + "Y"], n;
}
function xo(t, e) {
return e = e || {
x: 0,
y: 0
}, Tt.isOperaMobile && vi(t) ? (Me("screen", t, e), e.x += window.scrollX, e.y += window.scrollY) : Me("page", t, e), e;
}
function wo(t, e) {
return e = e || {}, Tt.isOperaMobile && vi(t) ? Me("screen", t, e) : Me("client", t, e), e;
}
function Pe(t) {
return m.number(t.pointerId) ? t.pointerId : t.identifier;
}
function _o(t, e, n) {
const i = e.length > 1 ? yi(e) : e[0];
xo(i, t.page), wo(i, t.client), t.timeStamp = n;
}
function yn(t) {
const e = [];
return m.array(t) ? (e[0] = t[0], e[1] = t[1]) : t.type === "touchend" ? t.touches.length === 1 ? (e[0] = t.touches[0], e[1] = t.changedTouches[0]) : t.touches.length === 0 && (e[0] = t.changedTouches[0], e[1] = t.changedTouches[1]) : (e[0] = t.touches[0], e[1] = t.touches[1]), e;
}
function yi(t) {
const e = {
pageX: 0,
pageY: 0,
clientX: 0,
clientY: 0,
screenX: 0,
screenY: 0
};
for (const n of t)
for (const i in e)
e[i] += n[i];
for (const n in e)
e[n] /= t.length;
return e;
}
function Io(t) {
if (!t.length)
return null;
const e = yn(t), n = Math.min(e[0].pageX, e[1].pageX), i = Math.min(e[0].pageY, e[1].pageY), o = Math.max(e[0].pageX, e[1].pageX), s = Math.max(e[0].pageY, e[1].pageY);
return {
x: n,
y: i,
left: n,
top: i,
right: o,
bottom: s,
width: o - n,
height: s - i
};
}
function So(t, e) {
const n = e + "X", i = e + "Y", o = yn(t), s = o[0][n] - o[1][n], a = o[0][i] - o[1][i];
return Be(s, a);
}
function Eo(t, e) {
const n = e + "X", i = e + "Y", o = yn(t), s = o[1][n] - o[0][n], a = o[1][i] - o[0][i];
return 180 * Math.atan2(a, s) / Math.PI;
}
function Do(t) {
return m.string(t.pointerType) ? t.pointerType : m.number(t.pointerType) ? [void 0, void 0, "touch", "pen", "mouse"][t.pointerType] : /touch/.test(t.type || "") || t instanceof vt.Touch ? "touch" : "mouse";
}
function bi(t) {
const e = m.func(t.composedPath) ? t.composedPath() : t.path;
return [Tn(e ? e[0] : t.target), Tn(t.currentTarget)];
}
function ve() {
return {
page: {
x: 0,
y: 0
},
client: {
x: 0,
y: 0
},
timeStamp: 0
};
}
function on(t, e) {
if (e.phaselessTypes[t])
return !0;
for (const n in e.map)
if (t.indexOf(n) === 0 && t.substr(n.length) in e.phases)
return !0;
return !1;
}
function Ao(t) {
const e = (n, i) => {
let o = t.interactables.get(n, i);
return o || (o = t.interactables.new(n, i), o.events.global = e.globalEvents), o;
};
return e.getPointerAverage = yi, e.getTouchBBox = Io, e.getTouchDistance = So, e.getTouchAngle = Eo, e.getElementRect = pn, e.getElementClientRect = hn, e.matchesSelector = Kt, e.closest = fi, e.globalEvents = {}, e.version = "1.10.17", e.scope = t, e.use = function(n, i) {
return this.scope.usePlugin(n, i), this;
}, e.isSet = function(n, i) {
return !!this.scope.interactables.get(n, i && i.context);
}, e.on = Ee(function(i, o, s) {
if (m.string(i) && i.search(" ") !== -1 && (i = i.trim().split(/ +/)), m.array(i)) {
for (const a of i)
this.on(a, o, s);
return this;
}
if (m.object(i)) {
for (const a in i)
this.on(a, i[a], o);
return this;
}
return on(i, this.scope.actions) ? this.globalEvents[i] ? this.globalEvents[i].push(o) : this.globalEvents[i] = [o] : this.scope.events.add(this.scope.document, i, o, {
options: s
}), this;
}, "The interact.on() method is being deprecated"), e.off = Ee(function(i, o, s) {
if (m.string(i) && i.search(" ") !== -1 && (i = i.trim().split(/ +/)), m.array(i)) {
for (const a of i)
this.off(a, o, s);
return this;
}
if (m.object(i)) {
for (const a in i)
this.off(a, i[a], o);
return this;
}
if (on(i, this.scope.actions)) {
let a;
i in this.globalEvents && (a = this.globalEvents[i].indexOf(o)) !== -1 && this.globalEvents[i].splice(a, 1);
} else
this.scope.events.remove(this.scope.document, i, o, s);
return this;
}, "The interact.off() method is being deprecated"), e.debug = function() {
return this.scope;
}, e.supportsTouch = function() {
return Tt.supportsTouch;
}, e.supportsPointerEvent = function() {
return Tt.supportsPointerEvent;
}, e.stop = function() {
for (const n of this.scope.interactions.list)
n.stop();
return this;
}, e.pointerMoveTolerance = function(n) {
return m.number(n) ? (this.scope.interactions.pointerMoveTolerance = n, this) : this.scope.interactions.pointerMoveTolerance;
}, e.addDocument = function(n, i) {
this.scope.addDocument(n, i);
}, e.removeDocument = function(n) {
this.scope.removeDocument(n);
}, e;
}
class To {
constructor(e, n, i, o) {
g(this, "options");
g(this, "_actions");
g(this, "target");
g(this, "events", new ui());
g(this, "_context");
g(this, "_win");
g(this, "_doc");
g(this, "_scopeEvents");
g(this, "_rectChecker");
this._actions = n.actions, this.target = e, this._context = n.context || i, this._win = qt(Rn(e) ? this._context : e), this._doc = this._win.document, this._scopeEvents = o, this.set(n);
}
get _defaults() {
return {
base: {},
perAction: {},
actions: {}
};
}
setOnEvents(e, n) {
return m.func(n.onstart) && this.on(`${e}start`, n.onstart), m.func(n.onmove) && this.on(`${e}move`, n.onmove), m.func(n.onend) && this.on(`${e}end`, n.onend), m.func(n.oninertiastart) && this.on(`${e}inertiastart`, n.oninertiastart), this;
}
updatePerActionListeners(e, n, i) {
(m.array(n) || m.object(n)) && this.off(e, n), (m.array(i) || m.object(i)) && this.on(e, i);
}
setPerAction(e, n) {
const i = this._defaults;
for (const o in n) {
const s = o, a = this.options[e], r = n[s];
s === "listeners" && this.updatePerActionListeners(e, a.listeners, r), m.array(r) ? a[s] = ci(r) : m.plainObject(r) ? (a[s] = P(a[s] || {}, re(r)), m.object(i.perAction[s]) && "enabled" in i.perAction[s] && (a[s].enabled = r.enabled !== !1)) : m.bool(r) && m.object(i.perAction[s]) ? a[s].enabled = r : a[s] = r;
}
}
getRect(e) {
return e = e || (m.element(this.target) ? this.target : null), m.string(this.target) && (e = e || this._context.querySelector(this.target)), pn(e);
}
rectChecker(e) {
return m.func(e) ? (this._rectChecker = e, this.getRect = (n) => {
const i = P({}, this._rectChecker(n));
return "width" in i || (i.width = i.right - i.left, i.height = i.bottom - i.top), i;
}, this) : e === null ? (delete this.getRect, delete this._rectChecker, this) : this.getRect;
}
_backCompatOption(e, n) {
if (Rn(n) || m.object(n)) {
this.options[e] = n;
for (const i in this._actions.map)
this.options[i][e] = n;
return this;
}
return this.options[e];
}
origin(e) {
return this._backCompatOption("origin", e);
}
deltaSource(e) {
return e === "page" || e === "client" ? (this.options.deltaSource = e, this) : this.options.deltaSource;
}
context() {
return this._context;
}
inContext(e) {
return this._context === e.ownerDocument || Gt(this._context, e);
}
testIgnoreAllow(e, n, i) {
return !this.testIgnore(e.ignoreFrom, n, i) && this.testAllow(e.allowFrom, n, i);
}
testAllow(e, n, i) {
return e ? m.element(i) ? m.string(e) ? nn(i, e, n) : m.element(e) ? Gt(e, i) : !1 : !1 : !0;
}
testIgnore(e, n, i) {
return !e || !m.element(i) ? !1 : m.string(e) ? nn(i, e, n) : m.element(e) ? Gt(e, i) : !1;
}
fire(e) {
return this.events.fire(e), this;
}
_onOff(e, n, i, o) {
m.object(n) && !m.array(n) && (o = i, i = null);
const s = e === "on" ? "add" : "remove", a = ie(n, i);
for (let r in a) {
r === "wheel" && (r = Tt.wheelEvent);
for (const l of a[r])
on(r, this._actions) ? this.events[e](r, l) : m.string(this.target) ? this._scopeEvents[`${s}Delegate`](this.target, this._context, r, l, o) : this._scopeEvents[s](this.target, r, l, o);
}
return this;
}
on(e, n, i) {
return this._onOff("on", e, n, i);
}
off(e, n, i) {
return this._onOff("off", e, n, i);
}
set(e) {
const n = this._defaults;
m.object(e) || (e = {}), this.options = re(n.base);
for (const i in this._actions.methodDict) {
const o = i, s = this._actions.methodDict[o];
this.options[o] = {}, this.setPerAction(o, P(P({}, n.perAction), n.actions[o])), this[s](e[o]);
}
for (const i in e)
m.func(this[i]) && this[i](e[i]);
return this;
}
unset() {
if (m.string(this.target))
for (const e in this._scopeEvents.delegatedEvents) {
const n = this._scopeEvents.delegatedEvents[e];
for (let i = n.length - 1; i >= 0; i--) {
const {
selector: o,
context: s,
listeners: a
} = n[i];
o === this.target && s === this._context && n.splice(i, 1);
for (let r = a.length - 1; r >= 0; r--)
this._scopeEvents.removeDelegate(this.target, this._context, e, a[r][0], a[r][1]);
}
}
else
this._scopeEvents.remove(this.target, "all");
}
}
class Ro {
constructor(e) {
g(this, "list", []);
g(this, "selectorMap", {});
g(this, "scope");
this.scope = e, e.addListeners({
"interactable:unset": ({
interactable: n
}) => {
const {
target: i,
_context: o
} = n, s = m.string(i) ? this.selectorMap[i] : i[this.scope.id], a = $e(s, (r) => r.context === o);
s[a] && (s[a].context = null, s[a].interactable = null), s.splice(a, 1);
}
});
}
new(e, n) {
n = P(n || {}, {
actions: this.scope.actions
});
const i = new this.scope.Interactable(e, n, this.scope.document, this.scope.events), o = {
context: i._context,
interactable: i
};
return this.scope.addDocument(i._doc), this.list.push(i), m.string(e) ? (this.selectorMap[e] || (this.selectorMap[e] = []), this.selectorMap[e].push(o)) : (i.target[this.scope.id] || Object.defineProperty(e, this.scope.id, {
value: [],
configurable: !0
}), e[this.scope.id].push(o)), this.scope.fire("interactable:new", {
target: e,
options: n,
interactable: i,
win: this.scope._win
}), i;
}
get(e, n) {
const i = n && n.context || this.scope.document, o = m.string(e), s = o ? this.selectorMap[e] : e[this.scope.id];
if (!s)
return null;
const a = en(s, (r) => r.context === i && (o || r.interactable.inContext(e)));
return a && a.interactable;
}
forEachMatch(e, n) {
for (const i of this.list) {
let o;
if ((m.string(i.target) ? m.element(e) && Kt(e, i.target) : e === i.target) && i.inContext(e) && (o = n(i)), o !== void 0)
return o;
}
}
}
function Oo(t) {
var e;
const n = [], i = {}, o = [], s = {
add: a,
remove: r,
addDelegate: l,
removeDelegate: c,
delegateListener: u,
delegateUseCapture: f,
delegatedEvents: i,
documents: o,
targets: n,
supportsOptions: !1,
supportsPassive: !1
};
(e = t.document) == null || e.createElement("div").addEventListener("test", null, {
get capture() {
return s.supportsOptions = !0;
},
get passive() {
return s.supportsPassive = !0;
}
}), t.events = s;
function a(h, b, y, E) {
const S = ye(E);
let L = en(n, (T) => T.eventTarget === h);
L || (L = {
eventTarget: h,
events: {}
}, n.push(L)), L.events[b] || (L.events[b] = []), h.addEventListener && !ho(L.events[b], y) && (h.addEventListener(b, y, s.supportsOptions ? S : S.capture), L.events[b].push(y));
}
function r(h, b, y, E) {
const S = ye(E), L = $e(n, (d) => d.eventTarget === h), T = n[L];
if (!T || !T.events)
return;
if (b === "all") {
for (b in T.events)
T.events.hasOwnProperty(b) && r(h, b, "all");
return;
}
let I = !1;
const v = T.events[b];
if (v) {
if (y === "all") {
for (let d = v.length - 1; d >= 0; d--)
r(h, b, v[d], S);
return;
} else
for (let d = 0; d < v.length; d++)
if (v[d] === y) {
h.removeEventListener(b, y, s.supportsOptions ? S : S.capture), v.splice(d, 1), v.length === 0 && (delete T.events[b], I = !0);
break;
}
}
I && !Object.keys(T.events).length && n.splice(L, 1);
}
function l(h, b, y, E, S) {
const L = ye(S);
if (!i[y]) {
i[y] = [];
for (const v of o)
a(v, y, u), a(v, y, f, !0);
}
const T = i[y];
let I = en(T, (v) => v.selector === h && v.context === b);
I || (I = {
selector: h,
context: b,
listeners: []
}, T.push(I)), I.listeners.push([E, L]);
}
function c(h, b, y, E, S) {
const L = ye(S), T = i[y];
let I = !1, v;
if (!!T)
for (v = T.length - 1; v >= 0; v--) {
const d = T[v];
if (d.selector === h && d.context === b) {
const {
listeners: H
} = d;
for (let w = H.length - 1; w >= 0; w--) {
const [U, {
capture: X,
passive: O
}] = H[w];
if (U === E && X === L.capture && O === L.passive) {
H.splice(w, 1), H.length || (T.splice(v, 1), r(b, y, u), r(b, y, f, !0)), I = !0;
break;
}
}
if (I)
break;
}
}
}
function u(h, b) {
const y = ye(b), E = new Co(h), S = i[h.type], [L] = bi(h);
let T = L;
for (; m.element(T); ) {
for (let I = 0; I < S.length; I++) {
const v = S[I], {
selector: d,
context: H
} = v;
if (Kt(T, d) && Gt(H, L) && Gt(H, T)) {
const {
listeners: w
} = v;
E.currentTarget = T;
for (const [U, {
capture: X,
passive: O
}] of w)
X === y.capture && O === y.passive && U(E);
}
}
T = Ft(T);
}
}
function f(h) {
return u.call(this, h, !0);
}
return s;
}
class Co {
constructor(e) {
g(this, "currentTarget");
g(this, "originalEvent");
g(this, "type");
this.originalEvent = e, mi(this, e);
}
preventOriginalDefault() {
this.originalEvent.preventDefault();
}
stopPropagation() {
this.originalEvent.stopPropagation();
}
stopImmediatePropagation() {
this.originalEvent.stopImmediatePropagation();
}
}
function ye(t) {
if (!m.object(t))
return {
capture: !!t,
passive: !1
};
const e = P({}, t);
return e.capture = !!t.capture, e.passive = !!t.passive, e;
}
const Mo = {
id: "events",
install: Oo
};
class Po {
constructor(e, n, i, o, s) {
g(this, "id");
g(this, "pointer");
g(this, "event");
g(this, "downTime");
g(this, "downTarget");
this.id = e, this.pointer = n, this.event = i, this.downTime = o, this.downTarget = s;
}
}
let rn;
(function(t) {
t.interactable = "", t.element = "", t.prepared = "", t.pointerIsDown = "", t.pointerWasMoved = "", t._proxy = "";
})(rn || (rn = {}));
let sn;
(function(t) {
t.start = "", t.move = "", t.end = "", t.stop = "", t.interacting = "";
})(sn || (sn = {}));
let zo = 0;
class No {
constructor({
pointerType: e,
scopeFire: n
}) {
g(this, "interactable", null);
g(this, "element", null);
g(this, "rect", null);
g(this, "_rects");
g(this, "edges", null);
g(this, "_scopeFire");
g(this, "prepared", {
name: null,
axis: null,
edges: null
});
g(this, "pointerType");
g(this, "pointers", []);
g(this, "downEvent", null);
g(this, "downPointer", {});
g(this, "_latestPointer", {
pointer: null,
event: null,
eventTarget: null
});
g(this, "prevEvent", null);
g(this, "pointerIsDown", !1);
g(this, "pointerWasMoved", !1);
g(this, "_interacting", !1);
g(this, "_ending", !1);
g(this, "_stopped", !0);
g(this, "_proxy", null);
g(this, "simulation", null);
g(this, "doMove", Ee(function(e) {
this.move(e);
}, "The interaction.doMove() method has been renamed to interaction.move()"));
g(this, "coords", {
start: ve(),
prev: ve(),
cur: ve(),
delta: ve(),
velocity: ve()
});
g(this, "_id", zo++);
this._scopeFire = n, this.pointerType = e;
const i = this;
this._proxy = {};
for (const o in rn)
Object.defineProperty(this._proxy, o, {
get() {
return i[o];
}
});
for (const o in sn)
Object.defineProperty(this._proxy, o, {
value: (...s) => i[o](...s)
});
this._scopeFire("interactions:new", {
interaction: this
});
}
get pointerMoveTolerance() {
return 1;
}
pointerDown(e, n, i) {
const o = this.updatePointer(e, n, i, !0), s = this.pointers[o];
this._scopeFire("interactions:down", {
pointer: e,
event: n,
eventTarget: i,
pointerIndex: o,
pointerInfo: s,
type: "down",
interaction: this
});
}
start(e, n, i) {
return this.interacting() || !this.pointerIsDown || this.pointers.length < (e.name === "gesture" ? 2 : 1) || !n.options[e.name].enabled ? !1 : (gi(this.prepared, e), this.interactable = n, this.element = i, this.rect = n.getRect(i), this.edges = this.prepared.edges ? P({}, this.prepared.edges) : {
left: !0,
right: !0,
top: !0,
bottom: !0
}, this._stopped = !1, this._interacting = this._doPhase({
interaction: this,
event: this.downEvent,
phase: "start"
}) && !this._stopped, this._interacting);
}
pointerMove(e, n, i) {
!this.simulation && !(this.modification && this.modification.endResult) && this.updatePointer(e, n, i, !1);
const o = this.coords.cur.page.x === this.coords.prev.page.x && this.coords.cur.page.y === this.coords.prev.page.y && this.coords.cur.client.x === this.coords.prev.client.x && this.coords.cur.client.y === this.coords.prev.client.y;
let s, a;
this.pointerIsDown && !this.pointerWasMoved && (s = this.coords.cur.client.x - this.coords.start.client.x, a = this.coords.cur.client.y - this.coords.start.client.y, this.pointerWasMoved = Be(s, a) > this.pointerMoveTolerance);
const r = this.getPointerIndex(e), l = {
pointer: e,
pointerIndex: r,
pointerInfo: this.pointers[r],
event: n,
type: "move",
eventTarget: i,
dx: s,
dy: a,
duplicate: o,
interaction: this
};
o || yo(this.coords.velocity, this.coords.delta), this._scopeFire("interactions:move", l), !o && !this.simulation && (this.interacting() && (l.type = null, this.move(l)), this.pointerWasMoved && Xe(this.coords.prev, this.coords.cur));
}
move(e) {
(!e || !e.event) && bo(this.coords.delta), e = P({
pointer: this._latestPointer.pointer,
event: this._latestPointer.event,
eventTarget: this._latestPointer.eventTarget,
interaction: this
}, e || {}), e.phase = "move", this._doPhase(e);
}
pointerUp(e, n, i, o) {
let s = this.getPointerIndex(e);
s === -1 && (s = this.updatePointer(e, n, i, !1));
const a = /cancel$/i.test(n.type) ? "cancel" : "up";
this._scopeFire(`interactions:${a}`, {
pointer: e,
pointerIndex: s,
pointerInfo: this.pointers[s],
event: n,
eventTarget: i,
type: a,
curEventTarget: o,
interaction: this
}), this.simulation || this.end(n), this.removePointer(e, n);
}
documentBlur(e) {
this.end(e), this._scopeFire("interactions:blur", {
event: e,
type: "blur",
interaction: this
});
}
end(e) {
this._ending = !0, e = e || this._latestPointer.event;
let n;
this.interacting() && (n = this._doPhase({
event: e,
interaction: this,
phase: "end"
})), this._ending = !1, n === !0 && this.stop();
}
currentAction() {
return this._interacting ? this.prepared.name : null;
}
interacting() {
return this._interacting;
}
stop() {
this._scopeFire("interactions:stop", {
interaction: this
}), this.interactable = this.element = null, this._interacting = !1, this._stopped = !0, this.prepared.name = this.prevEvent = null;
}
getPointerIndex(e) {
const n = Pe(e);
return this.pointerType === "mouse" || this.pointerType === "pen" ? this.pointers.length - 1 : $e(this.pointers, (i) => i.id === n);
}
getPointerInfo(e) {
return this.pointers[this.getPointerIndex(e)];
}
updatePointer(e, n, i, o) {
const s = Pe(e);
let a = this.getPointerIndex(e), r = this.pointers[a];
return o = o === !1 ? !1 : o || /(down|start)$/i.test(n.type), r ? r.pointer = e : (r = new Po(s, e, n, null, null), a = this.pointers.length, this.pointers.push(r)), _o(this.coords.cur, this.pointers.map((l) => l.pointer), this._now()), vo(this.coords.delta, this.coords.prev, this.coords.cur), o && (this.pointerIsDown = !0, r.downTime = this.coords.cur.timeStamp, r.downTarget = i, mi(this.downPointer, e), this.interacting() || (Xe(this.coords.start, this.coords.cur), Xe(this.coords.prev, this.coords.cur), this.downEvent = n, this.pointerWasMoved = !1)), this._updateLatestPointer(e, n, i), this._scopeFire("interactions:update-pointer", {
pointer: e,
event: n,
eventTarget: i,
down: o,
pointerInfo: r,
pointerIndex: a,
interaction: this
}), a;
}
removePointer(e, n) {
const i = this.getPointerIndex(e);
if (i === -1)
return;
const o = this.pointers[i];
this._scopeFire("interactions:remove-pointer", {
pointer: e,
event: n,
eventTarget: null,
pointerIndex: i,
pointerInfo: o,
interaction: this
}), this.pointers.splice(i, 1), this.pointerIsDown = !1;
}
_updateLatestPointer(e, n, i) {
this._latestPointer.pointer = e, this._latestPointer.event = n, this._latestPointer.eventTarget = i;
}
destroy() {
this._latestPointer.pointer = null, this._latestPointer.event = null, this._latestPointer.eventTarget = null;
}
_createPreparedEvent(e, n, i, o) {
return new vn(this, e, this.prepared.name, n, this.element, i, o);
}
_fireEvent(e) {
var n;
(n = this.interactable) == null || n.fire(e), (!this.prevEvent || e.timeStamp >= this.prevEvent.timeStamp) && (this.prevEvent = e);
}
_doPhase(e) {
const {
event: n,
phase: i,
preEnd: o,
type: s
} = e, {
rect: a
} = this;
if (a && i === "move" && (gn(this.edges, a, this.coords.delta[this.interactable.options.deltaSource]), a.width = a.right - a.left, a.height = a.bottom - a.top), this._scopeFire(`interactions:before-action-${i}`, e) === !1)
return !1;
const l = e.iEvent = this._createPreparedEvent(n, i, o, s);
return this._scopeFire(`interactions:action-${i}`, e), i === "start" && (this.prevEvent = l), this._fireEvent(l), this._scopeFire(`interactions:after-action-${i}`, e), !0;
}
_now() {
return Date.now();
}
}
const ko = No;
function Lo(t) {
return /^(always|never|auto)$/.test(t) ? (this.options.preventDefault = t, this) : m.bool(t) ? (this.options.preventDefault = t ? "always" : "never", this) : this.options.preventDefault;
}
function $o(t, e, n) {
const i = t.options.preventDefault;
if (i !== "never") {
if (i === "always") {
n.preventDefault();
return;
}
if (e.events.supportsPassive && /^touch(start|move)$/.test(n.type)) {
const o = qt(n.target).document, s = e.getDocOptions(o);
if (!(s && s.events) || s.events.passive !== !1)
return;
}
/^(mouse|pointer|touch)*(down|start)/i.test(n.type) || m.element(n.target) && Kt(n.target, "input,select,textarea,[contenteditable=true],[contenteditable=true] *") || n.preventDefault();
}
}
function Ho({
interaction: t,
event: e
}) {
t.interactable && t.interactable.checkAndPreventDefault(e);
}
function Bo(t) {
const {
Interactable: e
} = t;
e.prototype.preventDefault = Lo, e.prototype.checkAndPreventDefault = function(n) {
return $o(this, t, n);
}, t.interactions.docEvents.push({
type: "dragstart",
listener(n) {
for (const i of t.interactions.list)
if (i.element && (i.element === n.target || Gt(i.element, n.target))) {
i.interactable.checkAndPreventDefault(n);
return;
}
}
});
}
const Wo = {
id: "core/interactablePreventDefault",
install: Bo,
listeners: ["down", "move", "up", "cancel"].reduce((t, e) => (t[`interactions:${e}`] = Ho, t), {})
}, an = {
methodOrder: ["simulationResume", "mouseOrPen", "hasPointer", "idle"],
search(t) {
for (const e of an.methodOrder) {
const n = an[e](t);
if (n)
return n;
}
return null;
},
simulationResume({
pointerType: t,
eventType: e,
eventTarget: n,
scope: i
}) {
if (!/down|start/i.test(e))
return null;
for (const o of i.interactions.list) {
let s = n;
if (o.simulation && o.simulation.allowResume && o.pointerType === t)
for (; s; ) {
if (s === o.element)
return o;
s = Ft(s);
}
}
return null;
},
mouseOrPen({
pointerId: t,
pointerType: e,
eventType: n,
scope: i
}) {
if (e !== "mouse" && e !== "pen")
return null;
let o;
for (const s of i.interactions.list)
if (s.pointerType === e) {
if (s.simulation && !Cn(s, t))
continue;
if (s.interacting())
return s;
o || (o = s);
}
if (o)
return o;
for (const s of i.interactions.list)
if (s.pointerType === e && !(/down/i.test(n) && s.simulation))
return s;
return null;
},
hasPointer({
pointerId: t,
scope: e
}) {
for (const n of e.interactions.list)
if (Cn(n, t))
return n;
return null;
},
idle({
pointerType: t,
scope: e
}) {
for (const n of e.interactions.list) {
if (n.pointers.length === 1) {
const i = n.interactable;
if (i && !(i.options.gesture && i.options.gesture.enabled))
continue;
} else if (n.pointers.length >= 2)
continue;
if (!n.interacting() && t === n.pointerType)
return n;
}
return null;
}
};
function Cn(t, e) {
return t.pointers.some(({
id: n
}) => n === e);
}
const Fo = an, xi = ["pointerDown", "pointerMove", "pointerUp", "updatePointer", "removePointer", "windowBlur"];
function Yo(t) {
const e = {};
for (const s of xi)
e[s] = wi(s, t);
const n = Tt.pEventTypes;
let i;
vt.PointerEvent ? i = [{
type: n.down,
listener: o
}, {
type: n.down,
listener: e.pointerDown
}, {
type: n.move,
listener: e.pointerMove
}, {
type: n.up,
listener: e.pointerUp
}, {
type: n.cancel,
listener: e.pointerUp
}] : i = [{
type: "mousedown",
listener: e.pointerDown
}, {
type: "mousemove",
listener: e.pointerMove
}, {
type: "mouseup",
listener: e.pointerUp
}, {
type: "touchstart",
listener: o
}, {
type: "touchstart",
listener: e.pointerDown
}, {
type: "touchmove",
listener: e.pointerMove
}, {
type: "touchend",
listener: e.pointerUp
}, {
type: "touchcancel",
listener: e.pointerUp
}], i.push({
type: "blur",
listener(s) {
for (const a of t.interactions.list)
a.documentBlur(s);
}
}), t.prevTouchTime = 0, t.Interaction = class extends ko {
get pointerMoveTolerance() {
return t.interactions.pointerMoveTolerance;
}
set pointerMoveTolerance(s) {
t.interactions.pointerMoveTolerance = s;
}
_now() {
return t.now();
}
}, t.interactions = {
list: [],
new(s) {
s.scopeFire = (r, l) => t.fire(r, l);
const a = new t.Interaction(s);
return t.interactions.list.push(a), a;
},
listeners: e,
docEvents: i,
pointerMoveTolerance: 1
};
function o() {
for (const s of t.interactions.list)
if (!(!s.pointerIsDown || s.pointerType !== "touch" || s._interacting))
for (const a of s.pointers)
t.documents.some(({
doc: r
}) => Gt(r, a.downTarget)) || s.removePointer(a.pointer, a.event);
}
t.usePlugin(Wo);
}
function wi(t, e) {
return function(n) {
const i = e.interactions.list, o = Do(n), [s, a] = bi(n), r = [];
if (/^touch/.test(n.type)) {
e.prevTouchTime = e.now();
for (const l of n.changedTouches) {
const c = l, u = Pe(c), f = {
pointer: c,
pointerId: u,
pointerType: o,
eventType: n.type,
eventTarget: s,
curEventTarget: a,
scope: e
}, h = Mn(f);
r.push([f.pointer, f.eventTarget, f.curEventTarget, h]);
}
} else {
let l = !1;
if (!Tt.supportsPointerEvent && /mouse/.test(n.type)) {
for (let c = 0; c < i.length && !l; c++)
l = i[c].pointerType !== "mouse" && i[c].pointerIsDown;
l = l || e.now() - e.prevTouchTime < 500 || n.timeStamp === 0;
}
if (!l) {
const c = {
pointer: n,
pointerId: Pe(n),
pointerType: o,
eventType: n.type,
curEventTarget: a,
eventTarget: s,
scope: e
}, u = Mn(c);
r.push([c.pointer, c.eventTarget, c.curEventTarget, u]);
}
}
for (const [l, c, u, f] of r)
f[t](l, n, c, u);
};
}
function Mn(t) {
const {
pointerType: e,
scope: n
} = t, o = {
interaction: Fo.search(t),
searchDetails: t
};
return n.fire("interactions:find", o), o.interaction || n.interactions.new({
pointerType: e
});
}
function qe({
doc: t,
scope: e,
options: n
}, i) {
const {
interactions: {
docEvents: o
},
events: s
} = e, a = s[i];
e.browser.isIOS && !n.events && (n.events = {
passive: !1
});
for (const l in s.delegatedEvents)
a(t, l, s.delegateListener), a(t, l, s.delegateUseCapture, !0);
const r = n && n.events;
for (const {
type: l,
listener: c
} of o)
a(t, l, c, r);
}
const Uo = {
id: "core/interactions",
install: Yo,
listeners: {
"scope:add-document": (t) => qe(t, "add"),
"scope:remove-document": (t) => qe(t, "remove"),
"interactable:unset": ({
interactable: t
}, e) => {
for (let n = e.interactions.list.length - 1; n >= 0; n--) {
const i = e.interactions.list[n];
i.interactable === t && (i.stop(), e.fire("interactions:destroy", {
interaction: i
}), i.destroy(), e.interactions.list.length > 2 && e.interactions.list.splice(n, 1));
}
}
},
onDocSignal: qe,
doOnInteractions: wi,
methodNames: xi
}, Vo = Uo;
class jo {
constructor() {
g(this, "id", `__interact_scope_${Math.floor(Math.random() * 100)}`);
g(this, "isInitialized", !1);
g(this, "listenerMaps", []);
g(this, "browser", Tt);
g(this, "defaults", re(pi));
g(this, "Eventable", ui);
g(this, "actions", {
map: {},
phases: {
start: !0,
move: !0,
end: !0
},
methodDict: {},
phaselessTypes: {}
});
g(this, "interactStatic", Ao(this));
g(this, "InteractEvent", vn);
g(this, "Interactable");
g(this, "interactables", new Ro(this));
g(this, "_win");
g(this, "document");
g(this, "window");
g(this, "documents", []);
g(this, "_plugins", {
list: [],
map: {}
});
g(this, "onWindowUnload", (e) => this.removeDocument(e.target));
const e = this;
this.Interactable = class extends To {
get _defaults() {
return e.defaults;
}
set(n) {
return super.set(n), e.fire("interactable:set", {
options: n,
interactable: this
}), this;
}
unset() {
super.unset();
const n = e.interactables.list.indexOf(this);
n < 0 || (super.unset(), e.interactables.list.splice(n, 1), e.fire("interactable:unset", {
interactable: this
}));
}
};
}
addListeners(e, n) {
this.listenerMaps.push({
id: n,
map: e
});
}
fire(e, n) {
for (const {
map: {
[e]: i
}
} of this.listenerMaps)
if (!!i && i(n, this, e) === !1)
return !1;
}
init(e) {
return this.isInitialized ? this : Go(this, e);
}
pluginIsInstalled(e) {
return this._plugins.map[e.id] || this._plugins.list.indexOf(e) !== -1;
}
usePlugin(e, n) {
if (!this.isInitialized)
return this;
if (this.pluginIsInstalled(e))
return this;
if (e.id && (this._plugins.map[e.id] = e), this._plugins.list.push(e), e.install && e.install(this, n), e.listeners && e.before) {
let i = 0;
const o = this.listenerMaps.length, s = e.before.reduce((a, r) => (a[r] = !0, a[Pn(r)] = !0, a), {});
for (; i < o; i++) {
const a = this.listenerMaps[i].id;
if (s[a] || s[Pn(a)])
break;
}
this.listenerMaps.splice(i, 0, {
id: e.id,
map: e.listeners
});
} else
e.listeners && this.listenerMaps.push({
id: e.id,
map: e.listeners
});
return this;
}
addDocument(e, n) {
if (this.getDocIndex(e) !== -1)
return !1;
const i = qt(e);
n = n ? P({}, n) : {}, this.documents.push({
doc: e,
options: n
}), this.events.documents.push(e), e !== this.document && this.events.add(i, "unload", this.onWindowUnload), this.fire("scope:add-document", {
doc: e,
window: i,
scope: this,
options: n
});
}
removeDocument(e) {
const n = this.getDocIndex(e), i = qt(e), o = this.documents[n].options;
this.events.remove(i, "unload", this.onWindowUnload), this.documents.splice(n, 1), this.events.documents.splice(n, 1), this.fire("scope:remove-document", {
doc: e,
window: i,
scope: this,
options: o
});
}
getDocIndex(e) {
for (let n = 0; n < this.documents.length; n++)
if (this.documents[n].doc === e)
return n;
return -1;
}
getDocOptions(e) {
const n = this.getDocIndex(e);
return n === -1 ? null : this.documents[n].options;
}
now() {
return (this.window.Date || Date).now();
}
}
function Go(t, e) {
return t.isInitialized = !0, m.window(e) && si(e), vt.init(e), Tt.init(e), te.init(e), t.window = e, t.document = e.document, t.usePlugin(Vo), t.usePlugin(Mo), t;
}
function Pn(t) {
return t && t.replace(/\/.*$/, "");
}
const _i = new jo(), Xo = _i.interactStatic, Lt = Xo, qo = typeof globalThis < "u" ?