vrembem 4.0.0-next.3 → 4.0.0-next.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,363 +1,802 @@
1
- var Ke = (t, e, n) => {
2
- if (!e.has(t))
3
- throw TypeError("Cannot " + n);
4
- }, S = (t, e, n) => (Ke(t, e, "read from private field"), n ? n.call(t) : e.get(t)), Rt = (t, e, n) => {
5
- if (e.has(t))
6
- throw TypeError("Cannot add the same private member more than once");
7
- e instanceof WeakSet ? e.add(t) : e.set(t, n);
8
- }, nt = (t, e, n, i) => (Ke(t, e, "write to private field"), i ? i.call(t, n) : e.set(t, n), n), q;
9
- let Cn = class {
10
- constructor(e, n) {
11
- Rt(this, q, void 0), this.value = e, nt(this, q, n), this.mql = null;
12
- }
13
- get handler() {
14
- return S(this, q);
15
- }
16
- // Unmount existing handler before setting a new one.
17
- set handler(e) {
18
- this.mql && (typeof this.mql.removeEventListener == "function" ? this.mql.removeEventListener("change", S(this, q)) : this.mql.removeListener(S(this, q))), nt(this, q, e);
19
- }
20
- mount(e, n) {
21
- return e && (this.value = e), n && nt(this, q, n), this.value ? (this.mql = window.matchMedia(`(min-width: ${this.value})`), typeof this.mql.addEventListener == "function" ? this.mql.addEventListener("change", S(this, q)) : this.mql.addListener(S(this, q)), S(this, q).call(this, this.mql), this) : this;
22
- }
23
- unmount() {
24
- return this.mql ? (typeof this.mql.removeEventListener == "function" ? this.mql.removeEventListener("change", S(this, q)) : this.mql.removeListener(S(this, q)), this.value = null, nt(this, q, null), this.mql = null, this) : this;
25
- }
26
- };
27
- q = /* @__PURE__ */ new WeakMap();
28
- let In = class {
29
- constructor() {
30
- this.collection = [];
31
- }
32
- async register(e) {
33
- return await this.deregister(e), this.collection.push(e), this.collection;
34
- }
35
- async deregister(e) {
36
- const n = this.collection.findIndex((i) => i === e);
37
- if (n >= 0) {
38
- const i = this.collection[n];
39
- Object.getOwnPropertyNames(i).forEach((s) => {
40
- delete i[s];
41
- }), this.collection.splice(n, 1);
42
- }
43
- return this.collection;
44
- }
45
- async registerCollection(e) {
46
- return await Promise.all(Array.from(e, (n) => {
47
- this.register(n);
48
- })), this.collection;
49
- }
50
- async deregisterCollection() {
51
- for (; this.collection.length > 0; )
52
- await this.deregister(this.collection[0]);
53
- return this.collection;
54
- }
55
- get(e, n = "id") {
56
- return this.collection.find((i) => i[n] === e);
57
- }
1
+ var Jt = (t) => {
2
+ throw TypeError(t);
58
3
  };
59
- const p = {
60
- inert: ":not([inert]):not([inert] *)",
61
- negTabIndex: ':not([tabindex^="-"])',
62
- disabled: ":not(:disabled)"
63
- }, Sn = [
64
- `a[href]${p.inert}${p.negTabIndex}`,
65
- `area[href]${p.inert}${p.negTabIndex}`,
66
- `input:not([type="hidden"]):not([type="radio"])${p.inert}${p.negTabIndex}${p.disabled}`,
67
- `input[type="radio"]${p.inert}${p.negTabIndex}${p.disabled}`,
68
- `select${p.inert}${p.negTabIndex}${p.disabled}`,
69
- `textarea${p.inert}${p.negTabIndex}${p.disabled}`,
70
- `button${p.inert}${p.negTabIndex}${p.disabled}`,
71
- `details${p.inert} > summary:first-of-type${p.negTabIndex}`,
72
- // Discard until Firefox supports `:has()`
73
- // See: https://github.com/KittyGiraudel/focusable-selectors/issues/12
74
- // `details:not(:has(> summary))${not.inert}${not.negTabIndex}`,
75
- `iframe${p.inert}${p.negTabIndex}`,
76
- `audio[controls]${p.inert}${p.negTabIndex}`,
77
- `video[controls]${p.inert}${p.negTabIndex}`,
78
- `[contenteditable]${p.inert}${p.negTabIndex}`,
79
- `[tabindex]${p.inert}${p.negTabIndex}`
4
+ var Xt = (t, e, s) => e.has(t) || Jt("Cannot " + s);
5
+ var E = (t, e, s) => (Xt(t, e, "read from private field"), s ? s.call(t) : e.get(t)), U = (t, e, s) => e.has(t) ? Jt("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, s), S = (t, e, s, n) => (Xt(t, e, "write to private field"), n ? n.call(t, s) : e.set(t, s), s);
6
+ const C = ":not([inert])", $ = ':not([tabindex^="-"])', mt = ":not(:disabled)", se = [
7
+ `a[href]${C}${$}`,
8
+ `area[href]${C}${$}`,
9
+ `input:not([type="hidden"]):not([type="radio"])${C}${$}${mt}`,
10
+ `input[type="radio"]${C}${$}${mt}`,
11
+ `select${C}${$}${mt}`,
12
+ `textarea${C}${$}${mt}`,
13
+ `button${C}${$}${mt}`,
14
+ `details${C} > summary:first-of-type${$}`,
15
+ `iframe${C}${$}`,
16
+ `audio[controls]${C}${$}`,
17
+ `video[controls]${C}${$}`,
18
+ `[contenteditable]${C}${$}`,
19
+ `[tabindex]${C}${$}`
80
20
  ];
81
- var wt, at, lt;
82
- let Dn = class {
83
- constructor(e = null, n = "[data-focus]") {
84
- Rt(this, wt, void 0), Rt(this, at, void 0), Rt(this, lt, void 0), this.el = e, this.selectorFocus = n, nt(this, at, Pn.bind(this)), nt(this, lt, qn.bind(this));
21
+ function ie(t, e = "config") {
22
+ const n = (t.getAttribute(`data-${e}`) || "").replace(/'/g, '"');
23
+ return n ? JSON.parse(n) : {};
24
+ }
25
+ function Bt(t) {
26
+ return typeof t == "string" ? document.getElementById(t) : t instanceof HTMLElement ? t : null;
27
+ }
28
+ async function Q(t, e, ...s) {
29
+ e in t && typeof t[e] == "function" && await t[e](...s);
30
+ }
31
+ function oe(t, e, s) {
32
+ if (typeof e == "string") {
33
+ const i = document.querySelector(e);
34
+ if (!i)
35
+ throw new Error(`No teleport reference found for selector: ${e}`);
36
+ e = i;
37
+ } else if (!(e instanceof HTMLElement))
38
+ throw new Error(`Not a valid teleport reference: '${e}'`);
39
+ if (typeof e[s] != "function")
40
+ throw new Error(`Not a valid teleport method: '${s}'`);
41
+ let n = document.createComment(
42
+ "teleported #" + t.id
43
+ );
44
+ return t.before(n), e[s](t), () => {
45
+ n && (n.after(t), n.remove(), n = null);
46
+ };
47
+ }
48
+ function re(t) {
49
+ return t.split("-").map(
50
+ (e, s) => s === 0 ? e : e.charAt(0).toUpperCase() + e.slice(1)
51
+ ).join("");
52
+ }
53
+ function Ut(t) {
54
+ return t.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
55
+ }
56
+ function le(t) {
57
+ if (typeof t == "number")
58
+ return t;
59
+ const e = parseFloat(t);
60
+ if (!Number.isNaN(e)) {
61
+ const s = t.includes("ms");
62
+ return e * (s ? 1 : 1e3);
63
+ }
64
+ throw new Error(`Could not convert value to milliseconds: ${t}`);
65
+ }
66
+ function wt(t, e, s, n, i = 0) {
67
+ return new Promise((r) => {
68
+ t.classList.remove(e), t.classList.add(s), setTimeout(() => {
69
+ t.classList.add(n), t.classList.remove(s), r(t);
70
+ }, le(i));
71
+ });
72
+ }
73
+ function ae(t, e = {}) {
74
+ const s = {
75
+ fallback: null,
76
+ element: document.body,
77
+ ...e
78
+ };
79
+ if (!t.startsWith("--")) {
80
+ const i = kt();
81
+ i && (t = `${i}${t}`), t = `--${t}`;
82
+ }
83
+ const n = getComputedStyle(s.element).getPropertyValue(t).trim();
84
+ if (n)
85
+ return n;
86
+ if (s.fallback)
87
+ return s.fallback;
88
+ throw new Error(`CSS variable "${t}" was not found!`);
89
+ }
90
+ async function V(t, e, s) {
91
+ await Q(e, t, s), s && await Q(s, t);
92
+ for (const n of e.plugins)
93
+ await Q(n, t, { plugin: n, parent: e, entry: s });
94
+ await e.emit(t, s);
95
+ }
96
+ function ce(t) {
97
+ const e = getComputedStyle(t.el), s = {}, n = t.getSetting("customProps");
98
+ for (let i = 0; i < n.length; i++) {
99
+ const r = kt(), o = t.parent.module.toLowerCase(), l = Ut(n[i]), a = e.getPropertyValue(`--${r}${o}-${l}`).trim();
100
+ a && (s[l] = a);
101
+ }
102
+ return s;
103
+ }
104
+ function kt() {
105
+ return getComputedStyle(document.body).getPropertyValue("--vb-prefix").trim();
106
+ }
107
+ function He(t, e, s = "camel") {
108
+ return e = s === "camel" ? re(e) : Ut(e), t.split(".").concat(e).reduce((n, i) => n == null ? void 0 : n[i], this);
109
+ }
110
+ function fe(t, e = {}) {
111
+ const {
112
+ fallback: s,
113
+ props: n = ["dataConfig", "customProps", "settings", "parent.settings"]
114
+ } = e;
115
+ for (const i of n) {
116
+ const r = i !== "customProps" ? "camel" : "kebab", o = He.call(this, i, t, r);
117
+ if (o !== void 0)
118
+ return o;
119
+ }
120
+ if (s !== void 0)
121
+ return s;
122
+ throw new Error(`${this.parent.module} setting does not exist: ${t}`);
123
+ }
124
+ function Ne(t, e) {
125
+ e && document.querySelectorAll(e).forEach((n) => {
126
+ t ? n.style.overflow = "hidden" : n.style.removeProperty("overflow");
127
+ });
128
+ }
129
+ function Be(t, e) {
130
+ e && document.querySelectorAll(e).forEach((n) => {
131
+ t ? (n.inert = !0, n.setAttribute("aria-hidden", "true")) : (n.inert = !1, n.removeAttribute("aria-hidden"));
132
+ });
133
+ }
134
+ function bt(t, e, s) {
135
+ Be(!!t, e), Ne(!!t, s);
136
+ }
137
+ const ue = {
138
+ on(t, e, ...s) {
139
+ this.events[t] || (this.events[t] = []), this.events[t].some(
140
+ (i) => i.listener === e
141
+ ) || this.events[t].push({ listener: e, args: s });
142
+ },
143
+ off(t, e) {
144
+ this.events[t] && (this.events[t] = this.events[t].filter(
145
+ (s) => s.listener !== e
146
+ ));
147
+ },
148
+ async emit(t, e) {
149
+ if (t = t.startsWith("on") ? t.slice(2, 3).toLowerCase() + t.slice(3) : t, !!this.events[t])
150
+ for (const { listener: s, args: n } of this.events[t])
151
+ await s(e, ...n);
85
152
  }
86
- get focusable() {
87
- return S(this, wt);
153
+ };
154
+ class de extends Array {
155
+ constructor(e = null) {
156
+ super(), this.el = e, this.el && this.set();
88
157
  }
89
- set focusable(e) {
90
- nt(this, wt, e), S(this, wt).length ? (document.removeEventListener("keydown", S(this, lt)), document.addEventListener("keydown", S(this, at))) : (document.removeEventListener("keydown", S(this, at)), document.addEventListener("keydown", S(this, lt)));
158
+ get first() {
159
+ return this[0];
91
160
  }
92
- get focusableFirst() {
93
- return this.focusable[0];
161
+ get last() {
162
+ return this[this.length - 1];
94
163
  }
95
- get focusableLast() {
96
- return this.focusable[this.focusable.length - 1];
164
+ set(e = this.el) {
165
+ this.length = 0, this.push(...e.querySelectorAll(se.join(",")));
97
166
  }
98
- mount(e, n) {
99
- e && (this.el = e), n && (this.selectorFocus = n), this.focusable = this.getFocusable(), this.focus();
167
+ clear() {
168
+ this.length = 0;
100
169
  }
101
- unmount() {
102
- this.el = null, this.focusable = [], document.removeEventListener("keydown", S(this, at)), document.removeEventListener("keydown", S(this, lt));
170
+ }
171
+ class he {
172
+ constructor(e = null) {
173
+ this.el = e, this.focusable = new de(), this.handleFocusTrap = Ue.bind(this);
103
174
  }
104
- focus(e = this.el, n = this.selectorFocus) {
105
- (e.querySelector(n) || e).focus();
175
+ on(e = this.el) {
176
+ this.focusable.set(e), this.focusable.length ? document.addEventListener("keydown", this.handleFocusTrap) : document.addEventListener("keydown", Gt);
106
177
  }
107
- getFocusable(e = this.el) {
108
- const n = [], i = document.activeElement, s = e.scrollTop;
109
- return e.querySelectorAll(Sn.join(",")).forEach((r) => {
110
- r.focus(), document.activeElement === r && n.push(r);
111
- }), e.scrollTop = s, i.focus(), n;
178
+ off() {
179
+ this.focusable.clear(), document.removeEventListener("keydown", this.handleFocusTrap), document.removeEventListener("keydown", Gt);
112
180
  }
113
- };
114
- wt = /* @__PURE__ */ new WeakMap(), at = /* @__PURE__ */ new WeakMap(), lt = /* @__PURE__ */ new WeakMap();
115
- function Pn(t) {
116
- (t.key === "Tab" || t.keyCode === 9) && (t.shiftKey ? (document.activeElement === this.focusableFirst || document.activeElement === this.el) && (t.preventDefault(), this.focusableLast.focus()) : (document.activeElement === this.focusableLast || document.activeElement === this.el) && (t.preventDefault(), this.focusableFirst.focus()));
117
181
  }
118
- function qn(t) {
182
+ function Gt(t) {
119
183
  (t.key === "Tab" || t.keyCode === 9) && t.preventDefault();
120
184
  }
121
- function Mn(t, e) {
122
- const n = (t.getAttribute(`data-${e}`) || "").replace(/'/g, '"');
123
- return n ? JSON.parse(n) : {};
124
- }
125
- function Wn() {
126
- return getComputedStyle(document.body).getPropertyValue("--vrembem-variable-prefix").trim();
185
+ function Ue(t) {
186
+ if (t.key !== "Tab" && t.keyCode !== 9) return;
187
+ const { activeElement: e } = document, { el: s, focusable: n } = this, i = t.shiftKey, r = e === n.first || e === s, o = e === n.last || e === s;
188
+ (i && r || !i && o) && (t.preventDefault(), (i ? n.last : n.first).focus());
127
189
  }
128
- function jn(t, e = !0) {
129
- const n = localStorage.getItem(t), i = n ? JSON.parse(n) : {};
190
+ function Vt(t, e = !0) {
191
+ const s = localStorage.getItem(t), n = s ? JSON.parse(s) : {};
130
192
  return {
131
- get(s) {
132
- return s ? i[s] : i;
193
+ get(i, r = void 0) {
194
+ return i ? i in n ? n[i] : r : n;
133
195
  },
134
- set(s, r) {
135
- return r ? i[s] = r : delete i[s], e && localStorage.setItem(t, JSON.stringify(i)), i;
196
+ set(i, r) {
197
+ return r ? n[i] = r : delete n[i], e && localStorage.setItem(t, JSON.stringify(n)), n;
136
198
  }
137
199
  };
138
200
  }
139
- function Nn(t, e, n) {
140
- const i = e.nodeType === Node.COMMENT_NODE, s = e.nodeType === Node.ELEMENT_NODE;
141
- if (e = i || s ? e : document.querySelector(e), i && (n = "after"), !e)
142
- throw new Error(`Not a valid teleport reference: '${e}'`);
143
- if (typeof e[n] != "function")
144
- throw new Error(`Not a valid teleport method: '${n}'`);
145
- let r = null;
146
- return i || (r = document.createComment("teleported #" + t.id), t.before(r)), e[n](t), i && e.remove(), r;
147
- }
148
- const _n = (t, e) => new Promise((n) => {
149
- e.transition ? (t.classList.remove(e.stateClosed), t.classList.add(e.stateOpening), t.addEventListener("transitionend", function i(s) {
150
- s.target == t && (t.classList.add(e.stateOpened), t.classList.remove(e.stateOpening), n(t), this.removeEventListener("transitionend", i));
151
- })) : (t.classList.add(e.stateOpened), t.classList.remove(e.stateClosed), n(t));
152
- }), Fn = (t, e) => new Promise((n) => {
153
- e.transition ? (t.classList.add(e.stateClosing), t.classList.remove(e.stateOpened), t.addEventListener("transitionend", function i(s) {
154
- s.target == t && (t.classList.remove(e.stateClosing), t.classList.add(e.stateClosed), n(t), this.removeEventListener("transitionend", i));
155
- })) : (t.classList.add(e.stateClosed), t.classList.remove(e.stateOpened), n(t));
156
- });
157
- function Bn(t, e) {
158
- e && document.querySelectorAll(e).forEach((n) => {
159
- t ? n.style.overflow = "hidden" : n.style.removeProperty("overflow");
160
- });
201
+ class ge extends Array {
202
+ constructor(e = {}) {
203
+ super(), this.presets = e;
204
+ }
205
+ applySettings(e) {
206
+ var r;
207
+ const s = (e == null ? void 0 : e.defaults) || {}, n = ((r = this.presets) == null ? void 0 : r[e.name]) || {}, i = (e == null ? void 0 : e.options) || {};
208
+ e.settings = { ...s, ...n, ...i };
209
+ }
210
+ validate(e) {
211
+ return !("name" in e) || typeof e.name != "string" ? (console.error("Plugin requires a name!"), !1) : !0;
212
+ }
213
+ get(e) {
214
+ return this.find((s) => s.name === e);
215
+ }
216
+ add(e) {
217
+ if (Array.isArray(e))
218
+ e.forEach((s) => this.add(s));
219
+ else if (this.applySettings(e), this.validate(e)) {
220
+ const s = this.findIndex((n) => n.name === e.name);
221
+ ~s ? this[s] = e : this.push(e);
222
+ }
223
+ }
224
+ remove(e) {
225
+ const s = this.findIndex((n) => n.name === e);
226
+ ~s && this.splice(s, 1);
227
+ }
161
228
  }
162
- function Rn(t, e) {
163
- e && document.querySelectorAll(e).forEach((n) => {
164
- t ? (n.inert = !0, n.setAttribute("aria-hidden", !0)) : (n.inert = null, n.removeAttribute("aria-hidden"));
165
- });
229
+ class me extends Array {
230
+ constructor(e = {}) {
231
+ super(), this.settings = e;
232
+ }
233
+ get copy() {
234
+ return [...this];
235
+ }
236
+ get top() {
237
+ const e = this[this.length - 1];
238
+ return e || null;
239
+ }
240
+ updateIndex() {
241
+ this.forEach((e, s) => {
242
+ e.el.style.zIndex = null;
243
+ const n = getComputedStyle(e.el)["z-index"];
244
+ e.el.style.zIndex = parseInt(n) + s + 1;
245
+ });
246
+ }
247
+ onChange() {
248
+ this.updateIndex(), typeof this.settings.onChange == "function" && this.settings.onChange();
249
+ }
250
+ add(e) {
251
+ this.push(e), this.onChange();
252
+ }
253
+ remove(e) {
254
+ const s = this.findIndex((n) => n.id === e.id);
255
+ ~s && (e.el.style.zIndex = null, this.splice(s, 1), this.onChange());
256
+ }
257
+ moveToTop(e) {
258
+ const s = this.findIndex((n) => n.id === e.id);
259
+ ~s && (this.splice(s, 1), this.add(e));
260
+ }
166
261
  }
167
- function Hn(t, e) {
168
- Rn(!!t, e.selectorInert), Bn(!!t, e.selectorOverflow);
262
+ const Ve = {
263
+ condition: !0
264
+ }, _e = {
265
+ primary: "hsl(152deg 60% 50%)",
266
+ secondary: "hsl(214deg 50% 50%)",
267
+ neutral: "hsl(214deg 20% 50%)",
268
+ important: "hsl(0deg 80% 50%)"
269
+ };
270
+ function We(t = {}) {
271
+ const e = {
272
+ name: "debug",
273
+ defaults: Ve,
274
+ options: t
275
+ };
276
+ function s(o, l = [], a = ["primary", "secondary"]) {
277
+ const c = a.map((d) => `color: ${_e[d]}`);
278
+ console.log(`%c📡 DEBUG: %c${o}`, ...c, ...l);
279
+ }
280
+ function n(o, ...l) {
281
+ return typeof o == "function" ? o(...l) : o;
282
+ }
283
+ const i = {
284
+ beforeMountRef: s.bind(null, "Event > beforeMount()"),
285
+ afterMountRef: s.bind(null, "Event > afterMount()"),
286
+ beforeUnmountRef: s.bind(
287
+ null,
288
+ "Event > beforeUnmount()",
289
+ [],
290
+ ["important", "neutral"]
291
+ ),
292
+ afterUnmountRef: s.bind(
293
+ null,
294
+ "Event > afterUnmount()",
295
+ [],
296
+ ["important", "neutral"]
297
+ ),
298
+ createEntryRef: (o, { parent: l, plugin: a }) => {
299
+ if (n(a.settings.condition, o)) {
300
+ const c = l.collection.length;
301
+ s(`Event > createEntry() > [${c}] #${o.id}`);
302
+ }
303
+ },
304
+ registerEntryRef: (o, { parent: l, plugin: a }) => {
305
+ if (n(a.settings.condition, o)) {
306
+ const c = l.collection.length;
307
+ s(`Event > registerEntry() > [${c}] #${o.id}`);
308
+ }
309
+ },
310
+ destroyEntryRef: (o, { parent: l, plugin: a }) => {
311
+ if (n(a.settings.condition, o)) {
312
+ const c = l.collection.length;
313
+ s(
314
+ `Event > destroyEntry() > [${c}] #${o.id}`,
315
+ [],
316
+ ["important", "neutral"]
317
+ );
318
+ }
319
+ },
320
+ deregisterEntryRef: (o, { parent: l, plugin: a }) => {
321
+ if (n(a.settings.condition, o)) {
322
+ const c = l.collection.length;
323
+ s(
324
+ `Event > deregisterEntry() > [${c}] #${o.id}`,
325
+ [],
326
+ ["important", "neutral"]
327
+ );
328
+ }
329
+ }
330
+ };
331
+ return { ...e, ...{
332
+ // Plugin setup/teardown methods
333
+ setup({ parent: o }) {
334
+ s("Plugin > setup()", arguments, ["secondary", "neutral"]), o.on("beforeMount", i.beforeMountRef), o.on("createEntry", i.createEntryRef, { parent: o, plugin: this }), o.on("registerEntry", i.registerEntryRef, {
335
+ parent: o,
336
+ plugin: this
337
+ }), o.on("afterMount", i.afterMountRef), o.on("beforeUnmount", i.beforeUnmountRef), o.on("destroyEntry", i.destroyEntryRef, { parent: o, plugin: this }), o.on("deregisterEntry", i.deregisterEntryRef, {
338
+ parent: o,
339
+ plugin: this
340
+ }), o.on("afterUnmount", i.afterUnmountRef);
341
+ },
342
+ teardown({ parent: o }) {
343
+ s("Plugin > teardown()", arguments, ["secondary", "neutral"]), o.off("beforeMount", i.beforeMountRef), o.off("createEntry", i.createEntryRef), o.off("registerEntry", i.registerEntryRef), o.off("afterMount", i.afterMountRef), o.off("beforeUnmount", i.beforeUnmountRef), o.off("destroyEntry", i.destroyEntryRef), o.off("deregisterEntry", i.deregisterEntryRef), o.off("afterUnmount", i.afterUnmountRef);
344
+ },
345
+ // Mount lifecycle hooks
346
+ beforeMount() {
347
+ s("Hook > beforeMount()", arguments);
348
+ },
349
+ onCreateEntry({ parent: o, entry: l }) {
350
+ if (n(this.settings.condition, l)) {
351
+ const a = o.collection.length;
352
+ s(`Hook > onCreateEntry() > [${a}] #${l.id}`, arguments);
353
+ }
354
+ },
355
+ onRegisterEntry({ parent: o, entry: l }) {
356
+ if (n(this.settings.condition, l)) {
357
+ const a = o.collection.length - 1;
358
+ s(`Hook > onRegisterEntry() > [${a}] #${l.id}`, arguments);
359
+ }
360
+ },
361
+ afterMount() {
362
+ s("Hook > afterMount()", arguments);
363
+ },
364
+ // Unmount lifecycle hooks
365
+ beforeUnmount() {
366
+ s("Hook > beforeUnmount()", arguments, ["important", "neutral"]);
367
+ },
368
+ onDestroyEntry({ parent: o, entry: l }) {
369
+ if (n(this.settings.condition, l)) {
370
+ const a = o.collection.length - 1;
371
+ s(`Hook > onDestroyEntry() > [${a}] #${l.id}`, arguments, [
372
+ "important",
373
+ "neutral"
374
+ ]);
375
+ }
376
+ },
377
+ onDeregisterEntry({ parent: o, entry: l }) {
378
+ if (n(this.settings.condition, l)) {
379
+ const a = o.collection.length;
380
+ s(`Hook > onDeregisterEntry() > [${a}] #${l.id}`, arguments, [
381
+ "important",
382
+ "neutral"
383
+ ]);
384
+ }
385
+ },
386
+ afterUnmount() {
387
+ s("Hook > afterUnmount()", arguments, ["important", "neutral"]);
388
+ }
389
+ } };
169
390
  }
170
- const Gs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
171
- __proto__: null,
172
- Breakpoint: Cn,
173
- Collection: In,
174
- FocusTrap: Dn,
175
- closeTransition: Fn,
176
- getConfig: Mn,
177
- getPrefix: Wn,
178
- localStore: jn,
179
- openTransition: _n,
180
- teleport: Nn,
181
- updateGlobalState: Hn
182
- }, Symbol.toStringTag, { value: "Module" }));
183
- var Ge = (t, e, n) => {
184
- if (!e.has(t))
185
- throw TypeError("Cannot " + n);
186
- }, _t = (t, e, n) => (Ge(t, e, "read from private field"), n ? n.call(t) : e.get(t)), De = (t, e, n) => {
187
- if (e.has(t))
188
- throw TypeError("Cannot add the same private member more than once");
189
- e instanceof WeakSet ? e.add(t) : e.set(t, n);
190
- }, Pe = (t, e, n, i) => (Ge(t, e, "write to private field"), i ? i.call(t, n) : e.set(t, n), n), Qe = (t, e, n) => {
191
- if (!e.has(t))
192
- throw TypeError("Cannot " + n);
193
- }, D = (t, e, n) => (Qe(t, e, "read from private field"), n ? n.call(t) : e.get(t)), Ht = (t, e, n) => {
194
- if (e.has(t))
195
- throw TypeError("Cannot add the same private member more than once");
196
- e instanceof WeakSet ? e.add(t) : e.set(t, n);
197
- }, it = (t, e, n, i) => (Qe(t, e, "write to private field"), i ? i.call(t, n) : e.set(t, n), n), M;
198
- let Vn = class {
199
- constructor(e, n) {
200
- Ht(this, M, void 0), this.value = e, it(this, M, n), this.mql = null;
201
- }
202
- get handler() {
203
- return D(this, M);
204
- }
205
- // Unmount existing handler before setting a new one.
206
- set handler(e) {
207
- this.mql && (typeof this.mql.removeEventListener == "function" ? this.mql.removeEventListener("change", D(this, M)) : this.mql.removeListener(D(this, M))), it(this, M, e);
208
- }
209
- mount(e, n) {
210
- return e && (this.value = e), n && it(this, M, n), this.value ? (this.mql = window.matchMedia(`(min-width: ${this.value})`), typeof this.mql.addEventListener == "function" ? this.mql.addEventListener("change", D(this, M)) : this.mql.addListener(D(this, M)), D(this, M).call(this, this.mql), this) : this;
211
- }
212
- unmount() {
213
- return this.mql ? (typeof this.mql.removeEventListener == "function" ? this.mql.removeEventListener("change", D(this, M)) : this.mql.removeListener(D(this, M)), this.value = null, it(this, M, null), this.mql = null, this) : this;
214
- }
391
+ const ze = {
392
+ condition: !0
215
393
  };
216
- M = /* @__PURE__ */ new WeakMap();
217
- let Jn = class {
218
- constructor() {
219
- this.collection = [];
394
+ function Qe(t = {}) {
395
+ const e = {
396
+ name: "focusTrap",
397
+ defaults: ze,
398
+ options: t
399
+ }, s = {
400
+ setup({ parent: o }) {
401
+ o.on("opened", i, this), o.on("closed", r, this);
402
+ },
403
+ teardown({ parent: o }) {
404
+ o.off("opened", i), o.off("closed", r);
405
+ },
406
+ onCreateEntry({ entry: o }) {
407
+ o.focusTrap = new he();
408
+ }
409
+ };
410
+ function n(o, ...l) {
411
+ return typeof o == "function" ? o(...l) : o;
412
+ }
413
+ function i(o, l) {
414
+ var c;
415
+ const a = { plugin: l, parent: o.parent, entry: o };
416
+ n(l.settings.condition, a) && ((c = o.focusTrap) == null || c.on(o.dialog));
417
+ }
418
+ function r(o, l) {
419
+ var c;
420
+ const a = { plugin: l, parent: o.parent, entry: o };
421
+ n(l.settings.condition, a) && ((c = o.focusTrap) == null || c.off());
422
+ }
423
+ return { ...e, ...s };
424
+ }
425
+ const Ke = {
426
+ // The data attributes to get the breakpoint values from.
427
+ dataBreakpoint: "breakpoint",
428
+ // The data attributes to get the media query value from.
429
+ dataMediaQuery: "media-query",
430
+ // The string token to replace in the media query string.
431
+ token: "{{BP}}",
432
+ // Sets a global breakpoint. Can be overridden by setting a data attribute
433
+ // value. Notice: setting this option will enable a media query breakpoint on
434
+ // all entries.
435
+ breakpoint: null,
436
+ // The default media query string to use. Can be overridden by setting a data
437
+ // attribute value.
438
+ mediaQuery: "(min-width: {{BP}})",
439
+ // Maps entry ID or breakpoint key to breakpoint values. This is referenced
440
+ // when getting an entries breakpoint value.
441
+ breakpoints: {},
442
+ // Maps entry ID's to a media query strings. Media query may contain a token.
443
+ // This is referenced when getting an entries media query string.
444
+ mediaQueries: {},
445
+ // The function to run when the MediaQueryList triggers a "change" event.
446
+ // This is run once on initial mount.
447
+ onChange: () => {
220
448
  }
221
- async register(e) {
222
- return await this.deregister(e), this.collection.push(e), this.collection;
449
+ };
450
+ function je(t = {}) {
451
+ const e = {
452
+ name: "mediaQuery",
453
+ defaults: Ke,
454
+ options: t
455
+ }, s = {
456
+ onCreateEntry({ entry: l }) {
457
+ r.call(this, l);
458
+ },
459
+ onDestroyEntry({ entry: l }) {
460
+ o(l);
461
+ }
462
+ };
463
+ function n(l) {
464
+ const a = l.el.getAttribute(`data-${this.settings.dataMediaQuery}`);
465
+ return !a && l.id in this.settings.mediaQueries ? this.settings.mediaQueries[l.id] : a;
466
+ }
467
+ function i(l) {
468
+ let a = l.el.getAttribute(`data-${this.settings.dataBreakpoint}`);
469
+ return !a && l.id in this.settings.breakpoints && (a = this.settings.breakpoints[l.id]), a && a in this.settings.breakpoints && (a = this.settings.breakpoints[a]), a && (a = getComputedStyle(document.body).getPropertyValue(`--${kt()}breakpoint-${a}`).trim() || a), a || this.settings.breakpoint;
470
+ }
471
+ function r(l) {
472
+ let a = n.call(this, l);
473
+ const c = i.call(this, l);
474
+ if (!c && !a) return;
475
+ c && !a && (a = this.settings.mediaQuery);
476
+ const d = a.replace(new RegExp(`${this.settings.token}`, "g"), c);
477
+ l.mql = window.matchMedia(d), l.mql.onchange = (f) => {
478
+ this.settings.onChange(f, l);
479
+ }, this.settings.onChange(l.mql, l);
480
+ }
481
+ function o(l) {
482
+ l.mql && (l.mql.onchange = null, l.mql = null);
483
+ }
484
+ return { ...e, ...s };
485
+ }
486
+ const Ye = {
487
+ // The property on entry objects to watch.
488
+ prop: "state",
489
+ // The default value or a function to compute the initial value.
490
+ value: null,
491
+ // The local storage key prefix.
492
+ keyPrefix: "VB:",
493
+ // The local storage key to use. If not provided, module name and prop value
494
+ // will be used e.g., "VB:ModalState".
495
+ key: null,
496
+ // Condition to determine whether or not to store the value in local storage.
497
+ condition: !1,
498
+ // The function to run whenever the value changes.
499
+ onChange() {
223
500
  }
224
- async deregister(e) {
225
- const n = this.collection.findIndex((i) => i === e);
226
- if (n >= 0) {
227
- const i = this.collection[n];
228
- Object.getOwnPropertyNames(i).forEach((s) => {
229
- delete i[s];
230
- }), this.collection.splice(n, 1);
501
+ };
502
+ function Je(t = {}) {
503
+ const e = {
504
+ name: "propStore",
505
+ defaults: Ye,
506
+ options: t,
507
+ store: null
508
+ }, s = {
509
+ setup({ parent: l }) {
510
+ this.store = Vt(o.call(this, l.module));
511
+ },
512
+ async onCreateEntry({ entry: l }) {
513
+ await n.call(this, l);
514
+ },
515
+ onDestroyEntry({ entry: l }) {
516
+ r.call(this, l);
231
517
  }
232
- return this.collection;
518
+ };
519
+ async function n(l) {
520
+ let a = l[this.settings.prop] || null;
521
+ const c = { plugin: this, parent: l.parent, entry: l };
522
+ Object.defineProperty(l, this.settings.prop, {
523
+ configurable: !0,
524
+ get() {
525
+ return a;
526
+ },
527
+ set: async (d) => {
528
+ if (a === d) return;
529
+ const f = a;
530
+ a = d, i(
531
+ this.settings.condition,
532
+ c,
533
+ d,
534
+ f
535
+ ) && this.store.set(l.id, d), await this.settings.onChange(c, d, f);
536
+ }
537
+ }), Object.defineProperty(l, "store", {
538
+ configurable: !0,
539
+ get: () => this.store.get(l.id),
540
+ set: (d) => {
541
+ l[this.settings.prop] = d;
542
+ }
543
+ }), l[this.settings.prop] = await i(this.settings.value, c) || l[this.settings.prop];
233
544
  }
234
- async registerCollection(e) {
235
- return await Promise.all(Array.from(e, (n) => {
236
- this.register(n);
237
- })), this.collection;
545
+ function i(l, ...a) {
546
+ return typeof l == "function" ? l(...a) : l;
238
547
  }
239
- async deregisterCollection() {
240
- for (; this.collection.length > 0; )
241
- await this.deregister(this.collection[0]);
242
- return this.collection;
548
+ async function r(l) {
549
+ const a = l[this.settings.prop];
550
+ delete l[this.settings.prop], l[this.settings.prop] = a, this.store.set(l.id, null);
243
551
  }
244
- get(e, n = "id") {
245
- return this.collection.find((i) => i[n] === e);
552
+ function o(l) {
553
+ const a = this.settings.prop.charAt(0).toUpperCase() + this.settings.prop.slice(1), c = this.settings.key || l + a;
554
+ return this.settings.keyPrefix + c;
246
555
  }
556
+ return { ...e, ...s };
557
+ }
558
+ const Xe = {
559
+ where: null,
560
+ how: "append"
247
561
  };
248
- const g = {
249
- inert: ":not([inert]):not([inert] *)",
250
- negTabIndex: ':not([tabindex^="-"])',
251
- disabled: ":not(:disabled)"
252
- }, zn = [
253
- `a[href]${g.inert}${g.negTabIndex}`,
254
- `area[href]${g.inert}${g.negTabIndex}`,
255
- `input:not([type="hidden"]):not([type="radio"])${g.inert}${g.negTabIndex}${g.disabled}`,
256
- `input[type="radio"]${g.inert}${g.negTabIndex}${g.disabled}`,
257
- `select${g.inert}${g.negTabIndex}${g.disabled}`,
258
- `textarea${g.inert}${g.negTabIndex}${g.disabled}`,
259
- `button${g.inert}${g.negTabIndex}${g.disabled}`,
260
- `details${g.inert} > summary:first-of-type${g.negTabIndex}`,
261
- // Discard until Firefox supports `:has()`
262
- // See: https://github.com/KittyGiraudel/focusable-selectors/issues/12
263
- // `details:not(:has(> summary))${not.inert}${not.negTabIndex}`,
264
- `iframe${g.inert}${g.negTabIndex}`,
265
- `audio[controls]${g.inert}${g.negTabIndex}`,
266
- `video[controls]${g.inert}${g.negTabIndex}`,
267
- `[contenteditable]${g.inert}${g.negTabIndex}`,
268
- `[tabindex]${g.inert}${g.negTabIndex}`
269
- ];
270
- var $t, ct, dt;
271
- let Kn = class {
272
- constructor(e = null, n = "[data-focus]") {
273
- Ht(this, $t, void 0), Ht(this, ct, void 0), Ht(this, dt, void 0), this.el = e, this.selectorFocus = n, it(this, ct, Gn.bind(this)), it(this, dt, Qn.bind(this));
562
+ function Ge(t = {}) {
563
+ const e = {
564
+ name: "teleport",
565
+ defaults: Xe,
566
+ options: t
567
+ }, s = {
568
+ onCreateEntry({ plugin: r, entry: o }) {
569
+ n(r, o);
570
+ },
571
+ onDestroyEntry({ plugin: r, entry: o }) {
572
+ i(r, o);
573
+ }
574
+ };
575
+ function n(r, o) {
576
+ o.teleport = () => {
577
+ typeof o.teleportReturn == "function" && o.teleportReturn(), o.teleportReturn = oe(
578
+ o.el,
579
+ o.getSetting("teleport", { fallback: r.settings.where }),
580
+ o.getSetting("teleportMethod", { fallback: r.settings.how })
581
+ );
582
+ }, o.teleport(), o.parent.emit("teleport", { plugin: r, parent, entry: o });
274
583
  }
275
- get focusable() {
276
- return D(this, $t);
584
+ function i(r, o) {
585
+ typeof o.teleportReturn == "function" && o.teleportReturn(), o.parent.emit("teleportReturn", { plugin: r, parent, entry: o });
277
586
  }
278
- set focusable(e) {
279
- it(this, $t, e), D(this, $t).length ? (document.removeEventListener("keydown", D(this, dt)), document.addEventListener("keydown", D(this, ct))) : (document.removeEventListener("keydown", D(this, ct)), document.addEventListener("keydown", D(this, dt)));
587
+ return { ...e, ...s };
588
+ }
589
+ const qe = {
590
+ dataConfig: "config",
591
+ customProps: []
592
+ };
593
+ class xt {
594
+ constructor(e, s, n = {}) {
595
+ this.parent = e, this.id = (s == null ? void 0 : s.id) || s, this.el = Bt(s), this.settings = { ...n }, this.dataConfig = {}, this.customProps = {};
280
596
  }
281
- get focusableFirst() {
282
- return this.focusable[0];
597
+ applySettings(e) {
598
+ return Object.assign(this.settings, e);
283
599
  }
284
- get focusableLast() {
285
- return this.focusable[this.focusable.length - 1];
600
+ getSetting(e, s) {
601
+ return fe.call(this, e, s);
286
602
  }
287
- mount(e, n) {
288
- e && (this.el = e), n && (this.selectorFocus = n), this.focusable = this.getFocusable(), this.focus();
603
+ buildDataConfig() {
604
+ return Object.assign(
605
+ this.dataConfig,
606
+ ie(this.el, this.getSetting("dataConfig"))
607
+ );
289
608
  }
290
- unmount() {
291
- this.el = null, this.focusable = [], document.removeEventListener("keydown", D(this, ct)), document.removeEventListener("keydown", D(this, dt));
609
+ buildCustomProps() {
610
+ return Object.assign(this.customProps, ce(this));
292
611
  }
293
- focus(e = this.el, n = this.selectorFocus) {
294
- (e.querySelector(n) || e).focus();
612
+ async init(e = {}) {
613
+ if (this.el === null)
614
+ throw new Error(
615
+ `${this.parent.module} element was not found with ID: "${this.id}"`
616
+ );
617
+ this.applySettings(e), this.buildDataConfig(), this.buildCustomProps();
295
618
  }
296
- getFocusable(e = this.el) {
297
- const n = [], i = document.activeElement, s = e.scrollTop;
298
- return e.querySelectorAll(zn.join(",")).forEach((r) => {
299
- r.focus(), document.activeElement === r && n.push(r);
300
- }), e.scrollTop = s, i.focus(), n;
619
+ async destroy() {
620
+ Object.getOwnPropertyNames(this).forEach((e) => {
621
+ e !== "id" && delete this[e];
622
+ });
301
623
  }
302
- };
303
- $t = /* @__PURE__ */ new WeakMap(), ct = /* @__PURE__ */ new WeakMap(), dt = /* @__PURE__ */ new WeakMap();
304
- function Gn(t) {
305
- (t.key === "Tab" || t.keyCode === 9) && (t.shiftKey ? (document.activeElement === this.focusableFirst || document.activeElement === this.el) && (t.preventDefault(), this.focusableLast.focus()) : (document.activeElement === this.focusableLast || document.activeElement === this.el) && (t.preventDefault(), this.focusableFirst.focus()));
306
- }
307
- function Qn(t) {
308
- (t.key === "Tab" || t.keyCode === 9) && t.preventDefault();
309
- }
310
- function Zn(t, e) {
311
- const n = (t.getAttribute(`data-${e}`) || "").replace(/'/g, '"');
312
- return n ? JSON.parse(n) : {};
313
624
  }
314
- function Un() {
315
- return getComputedStyle(document.body).getPropertyValue("--vrembem-variable-prefix").trim();
625
+ class Ot {
626
+ constructor(e = {}) {
627
+ this.module = this.constructor.name, this.collection = [], this.entryClass = xt, this.settings = { ...qe, ...e }, this.plugins = new ge(this.settings.presets), this.events = {}, Object.assign(this, ue);
628
+ }
629
+ get(e, s = "id") {
630
+ return this.collection.find((n) => n[s] === e);
631
+ }
632
+ applySettings(e) {
633
+ return Object.assign(this.settings, e);
634
+ }
635
+ async createEntry(e, s) {
636
+ const n = new this.entryClass(this, e, s);
637
+ return await Q(n, "init"), await V("onCreateEntry", this, n), n;
638
+ }
639
+ async destroyEntry(e) {
640
+ return await V("onDestroyEntry", this, e), await Q(e, "destroy"), e;
641
+ }
642
+ async register(e, s = {}) {
643
+ const n = Bt(e);
644
+ if (n === null)
645
+ throw new Error(
646
+ `${this.module} element was not found with ID: "${(e == null ? void 0 : e.id) || e}"`
647
+ );
648
+ const i = this.collection.findIndex((r) => r.id === n.id);
649
+ if (~i) {
650
+ const r = this.collection[i];
651
+ return r.el = n, typeof r.init == "function" && await r.init(s), r;
652
+ } else {
653
+ const r = await this.createEntry(n, s);
654
+ return this.collection.push(r), await V("onRegisterEntry", this, r), r;
655
+ }
656
+ }
657
+ async deregister(e) {
658
+ const s = this.collection.findIndex((n) => n.id === e);
659
+ if (~s) {
660
+ const n = await this.destroyEntry(this.collection[s]);
661
+ return await V(
662
+ "onDeregisterEntry",
663
+ this,
664
+ this.collection[s]
665
+ ), this.collection.splice(s, 1), n;
666
+ }
667
+ return null;
668
+ }
669
+ async mount(e = {}) {
670
+ var n;
671
+ this.applySettings(e);
672
+ for (const i of ((n = this.settings) == null ? void 0 : n.plugins) || [])
673
+ this.plugins.add(i);
674
+ for (const i of this.plugins)
675
+ await Q(i, "setup", { plugin: i, parent: this });
676
+ await V("beforeMount", this);
677
+ const s = document.querySelectorAll(this.settings.selector);
678
+ for (const i of s)
679
+ await this.register(i);
680
+ return await V("afterMount", this), this;
681
+ }
682
+ async unmount() {
683
+ for (await V("beforeUnmount", this); this.collection.length > 0; )
684
+ await this.deregister(this.collection[0].id);
685
+ await V("afterUnmount", this);
686
+ for (const e of this.plugins)
687
+ await Q(e, "teardown", { plugin: e, parent: this });
688
+ for (const e of [...this.plugins])
689
+ this.plugins.remove(e.name);
690
+ return this;
691
+ }
316
692
  }
317
- function Xn(t, e = !0) {
318
- const n = localStorage.getItem(t), i = n ? JSON.parse(n) : {};
319
- return {
320
- get(s) {
321
- return s ? i[s] : i;
693
+ function Ze(t) {
694
+ const e = {
695
+ prefix: ae("prefix-themes", { fallback: "vb-theme-" }),
696
+ themes: ["root", "light", "dark"],
697
+ storeKey: "VB:Profile"
698
+ };
699
+ for (const [r] of Object.entries(e))
700
+ t && t[r] && (e[r] = t[r]);
701
+ const s = {
702
+ onInit() {
322
703
  },
323
- set(s, r) {
324
- return r ? i[s] = r : delete i[s], e && localStorage.setItem(t, JSON.stringify(i)), i;
704
+ onChange() {
325
705
  }
326
706
  };
707
+ for (const [r] of Object.entries(s))
708
+ t && t[r] && (s[r] = t[r]);
709
+ const n = Vt(e.storeKey), i = {
710
+ // Store our settings in the API
711
+ settings: e,
712
+ // Actions
713
+ add(r) {
714
+ e.themes.push(r);
715
+ },
716
+ remove(r) {
717
+ const o = e.themes.indexOf(r);
718
+ ~o && e.themes.splice(o, 1);
719
+ },
720
+ callback(r) {
721
+ s[r].call(this);
722
+ },
723
+ // Getters
724
+ get class() {
725
+ return `${e.prefix}${this.theme}`;
726
+ },
727
+ get classes() {
728
+ return e.themes.map((r) => `${e.prefix}${r}`);
729
+ },
730
+ get themes() {
731
+ return e.themes;
732
+ },
733
+ // Setup the theme get and set methods
734
+ get theme() {
735
+ return n.get("theme") || "root";
736
+ },
737
+ set theme(r) {
738
+ e.themes.includes(r) ? this.theme != r && (n.set("theme", r), document.documentElement.classList.remove(...this.classes), document.documentElement.classList.add(`${e.prefix}${r}`), this.callback("onChange")) : console.error(`Not a valid theme value: "${r}"`);
739
+ }
740
+ };
741
+ return i.callback("onInit"), i;
327
742
  }
328
- const Yn = (t, e) => new Promise((n) => {
329
- e.transition ? (t.classList.remove(e.stateClosed), t.classList.add(e.stateOpening), t.addEventListener("transitionend", function i(s) {
330
- s.target == t && (t.classList.add(e.stateOpened), t.classList.remove(e.stateOpening), n(t), this.removeEventListener("transitionend", i));
331
- })) : (t.classList.add(e.stateOpened), t.classList.remove(e.stateClosed), n(t));
332
- }), ti = (t, e) => new Promise((n) => {
333
- e.transition ? (t.classList.add(e.stateClosing), t.classList.remove(e.stateOpened), t.addEventListener("transitionend", function i(s) {
334
- s.target == t && (t.classList.remove(e.stateClosing), t.classList.add(e.stateClosed), n(t), this.removeEventListener("transitionend", i));
335
- })) : (t.classList.add(e.stateClosed), t.classList.remove(e.stateOpened), n(t));
336
- });
337
- function ei(t, e) {
338
- e && document.querySelectorAll(e).forEach((n) => {
339
- t ? n.style.overflow = "hidden" : n.style.removeProperty("overflow");
340
- });
341
- }
342
- function ni(t, e) {
343
- e && document.querySelectorAll(e).forEach((n) => {
344
- t ? (n.inert = !0, n.setAttribute("aria-hidden", !0)) : (n.inert = null, n.removeAttribute("aria-hidden"));
345
- });
346
- }
347
- function le(t, e) {
348
- ni(!!t, e.selectorInert), ei(!!t, e.selectorOverflow);
349
- }
350
- const ii = {
351
- autoInit: !1,
743
+ const fs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
744
+ __proto__: null,
745
+ Collection: Ot,
746
+ CollectionEntry: xt,
747
+ FocusTrap: he,
748
+ FocusableArray: de,
749
+ PluginsArray: ge,
750
+ StackArray: me,
751
+ cssVar: ae,
752
+ debug: We,
753
+ dispatchLifecycleHook: V,
754
+ eventEmitter: ue,
755
+ focusTrap: Qe,
756
+ focusableSelectors: se,
757
+ getCustomProps: ce,
758
+ getDataConfig: ie,
759
+ getElement: Bt,
760
+ getPrefix: kt,
761
+ getSetting: fe,
762
+ localStore: Vt,
763
+ maybeRunMethod: Q,
764
+ mediaQuery: je,
765
+ propStore: Je,
766
+ setGlobalState: bt,
767
+ teleport: Ge,
768
+ teleportElement: oe,
769
+ themeStore: Ze,
770
+ toCamel: re,
771
+ toKebab: Ut,
772
+ toMilliseconds: le,
773
+ transition: wt
774
+ }, Symbol.toStringTag, { value: "Module" })), tn = {
775
+ focusTrap: {
776
+ condition: ({ entry: t }) => t.state === "closed" || t.state === "opened" && t.mode === "modal"
777
+ },
778
+ mediaQuery: {
779
+ onChange(t, e) {
780
+ e.mode = t.matches ? "inline" : "modal";
781
+ }
782
+ },
783
+ propStore: {
784
+ prop: "inlineState",
785
+ value: ({ entry: t }) => t.store,
786
+ condition: ({ entry: t }) => ["opened", "closed", "indeterminate"].includes(t.state),
787
+ onChange: ({ entry: t }) => t.applyState()
788
+ }
789
+ }, en = {
790
+ // Plugin presets
791
+ presets: tn,
352
792
  // Data attributes
353
793
  dataOpen: "drawer-open",
354
794
  dataClose: "drawer-close",
355
795
  dataToggle: "drawer-toggle",
356
- dataBreakpoint: "drawer-breakpoint",
357
- dataConfig: "drawer-config",
358
796
  // Selectors
359
- selectorDrawer: ".drawer",
797
+ selector: ".drawer",
360
798
  selectorDialog: ".drawer__dialog",
799
+ selectorScreen: ".drawer",
361
800
  selectorFocus: "[data-focus]",
362
801
  selectorInert: null,
363
802
  selectorOverflow: "body",
@@ -369,15 +808,106 @@ const ii = {
369
808
  // Classes
370
809
  classModal: "drawer_modal",
371
810
  // Feature toggles
811
+ customProps: ["transition-duration"],
372
812
  breakpoints: null,
373
813
  customEventPrefix: "drawer:",
374
- eventListeners: !0,
375
- store: !0,
376
- storeKey: "VB:DrawerState",
377
814
  setTabindex: !0,
378
- transition: !0
815
+ transition: !0,
816
+ transitionDuration: 300
379
817
  };
380
- function si(t) {
818
+ function nn(t) {
819
+ switch (t.mode) {
820
+ case "inline":
821
+ return sn.call(this, t);
822
+ case "modal":
823
+ return on.call(this, t);
824
+ default:
825
+ throw new Error(`"${t.mode}" is not a valid drawer mode.`);
826
+ }
827
+ }
828
+ async function sn(t) {
829
+ return t.el.classList.remove(t.getSetting("classModal")), t.dialog.removeAttribute("aria-modal"), bt(
830
+ !1,
831
+ t.getSetting("selectorInert"),
832
+ t.getSetting("selectorOverflow")
833
+ ), t.applyState(), t.el.dispatchEvent(
834
+ new CustomEvent(t.getSetting("customEventPrefix") + "switchMode", {
835
+ detail: this,
836
+ bubbles: !0
837
+ })
838
+ ), await t.parent.emit("switchMode", t), t;
839
+ }
840
+ async function on(t) {
841
+ return t.el.classList.add(t.getSetting("classModal")), t.dialog.setAttribute("aria-modal", "true"), await t.close(!1, !1), t.el.dispatchEvent(
842
+ new CustomEvent(t.getSetting("customEventPrefix") + "switchMode", {
843
+ detail: this,
844
+ bubbles: !0
845
+ })
846
+ ), await t.parent.emit("switchMode", t), t;
847
+ }
848
+ var q;
849
+ class rn extends xt {
850
+ constructor(s, n, i = {}) {
851
+ super(s, n, i);
852
+ U(this, q);
853
+ this.dialog = null, this.trigger = null, this.state = null, this.inlineState = null, S(this, q, "indeterminate");
854
+ }
855
+ get mode() {
856
+ return E(this, q);
857
+ }
858
+ set mode(s) {
859
+ E(this, q) !== s && (S(this, q, s), nn.call(this.parent, this));
860
+ }
861
+ setState(s) {
862
+ this.state = s;
863
+ const n = ["opening", "closing"];
864
+ this.mode === "inline" && !n.includes(s) && (this.inlineState = s), s === "indeterminate" && (this.el.classList.remove(this.getSetting("stateOpened")), this.el.classList.remove(this.getSetting("stateOpening")), this.el.classList.remove(this.getSetting("stateClosed")), this.el.classList.remove(this.getSetting("stateClosing")));
865
+ }
866
+ async applyState() {
867
+ if (this.mode !== "modal") {
868
+ if (this.inlineState === "opened")
869
+ return await this.open(!1, !1);
870
+ if (this.inlineState === "closed")
871
+ return await this.close(!1, !1);
872
+ if (this.state === null) {
873
+ if (this.el.classList.contains(this.getSetting("stateOpened")))
874
+ return await this.open(!1, !1);
875
+ if (this.el.classList.contains(this.getSetting("stateClosed")))
876
+ return await this.close(!1, !1);
877
+ }
878
+ return this.setState("indeterminate");
879
+ }
880
+ }
881
+ async open(s, n) {
882
+ return this.parent.open(this, s, n);
883
+ }
884
+ async close(s, n) {
885
+ return this.parent.close(this, s, n);
886
+ }
887
+ async toggle(s, n) {
888
+ return this.parent.toggle(this, s, n);
889
+ }
890
+ async deregister() {
891
+ return this.parent.deregister(this.id);
892
+ }
893
+ async onCreateEntry() {
894
+ const s = this.el.querySelector(this.getSetting("selectorDialog"));
895
+ this.dialog = s || this.el, this.getSetting("setTabindex") && this.dialog.setAttribute("tabindex", "-1"), await this.applyState(), this.inlineState = this.state, this.mode = this.el.classList.contains(this.getSetting("classModal")) ? "modal" : "inline";
896
+ }
897
+ async onDestroyEntry() {
898
+ this.mode === "modal" && this.state === "opened" && await this.close(!1);
899
+ }
900
+ }
901
+ q = new WeakMap();
902
+ function nt(t) {
903
+ const e = typeof t == "string" ? this.get(t) : t;
904
+ if (e)
905
+ return e;
906
+ throw new Error(
907
+ `Drawer not found in collection with id of "${t.id || t}".`
908
+ );
909
+ }
910
+ async function ln(t) {
381
911
  const e = t.target.closest(`
382
912
  [data-${this.settings.dataOpen}],
383
913
  [data-${this.settings.dataToggle}],
@@ -385,672 +915,355 @@ function si(t) {
385
915
  `);
386
916
  if (e) {
387
917
  t.preventDefault(), e.matches(`[data-${this.settings.dataToggle}]`) && e.getAttribute(`data-${this.settings.dataToggle}`).trim().split(" ").forEach((n) => {
388
- const i = this.get(n);
389
- i.trigger = e, i.toggle();
918
+ const i = nt.call(this, n);
919
+ return i.trigger = e, i.toggle();
390
920
  }), e.matches(`[data-${this.settings.dataOpen}]`) && e.getAttribute(`data-${this.settings.dataOpen}`).trim().split(" ").forEach((n) => {
391
- const i = this.get(n);
392
- i.trigger = e, i.open();
921
+ const i = nt.call(this, n);
922
+ return i.trigger = e, i.open();
393
923
  }), e.matches(`[data-${this.settings.dataClose}]`) && e.getAttribute(`data-${this.settings.dataClose}`).trim().split(" ").forEach((n) => {
394
924
  if (n) {
395
- const i = this.get(n);
396
- i.trigger = e, i.close();
925
+ const i = nt.call(this, n);
926
+ return i.trigger = e, i.close();
397
927
  } else {
398
- const i = t.target.closest(this.settings.selectorDrawer);
399
- i && this.close(i);
928
+ const i = t.target.closest(this.settings.selector);
929
+ if (i) return this.close(i.id);
400
930
  }
401
931
  });
402
932
  return;
403
933
  }
404
- t.target.matches(this.settings.selectorDrawer) && this.close(t.target.id);
405
- }
406
- function ri(t) {
407
- if (t.key === "Escape") {
408
- const e = this.activeModal;
409
- e && this.close(e);
410
- }
411
- }
412
- async function ne(t, e = !0) {
413
- if (!t)
414
- return this.collection;
415
- const n = this.collection.findIndex((i) => i.id === t.id);
416
- if (n >= 0) {
417
- const i = this.collection[n];
418
- e && i.state === "opened" && await i.close(!1), this.store.set(i.id), i.unmountBreakpoint(), Object.getOwnPropertyNames(i).forEach((s) => {
419
- delete i[s];
420
- }), this.collection.splice(n, 1);
421
- }
422
- return this.collection;
423
- }
424
- function oi(t) {
425
- const e = Un(), n = t.getAttribute(`data-${this.settings.dataBreakpoint}`);
426
- return this.settings.breakpoints && this.settings.breakpoints[n] ? this.settings.breakpoints[n] : getComputedStyle(document.body).getPropertyValue(`--${e}breakpoint-${n}`).trim() ? getComputedStyle(document.body).getPropertyValue(`--${e}breakpoint-${n}`).trim() : n;
427
- }
428
- function ce(t) {
429
- const e = typeof t == "string" ? this.get(t) : this.get(t.id);
430
- if (e)
431
- return e;
432
- throw new Error(`Drawer not found in collection with id of "${t.id || t}".`);
433
- }
434
- function Ze(t) {
435
- return typeof t == "string" ? t : typeof t.hasAttribute == "function" ? t.hasAttribute(`data-${this.settings.dataOpen}`) ? t.getAttribute(`data-${this.settings.dataOpen}`) : t.hasAttribute(`data-${this.settings.dataClose}`) ? t.getAttribute(`data-${this.settings.dataClose}`) || !1 : t.hasAttribute(`data-${this.settings.dataToggle}`) ? t.getAttribute(`data-${this.settings.dataToggle}`) : t.closest(this.settings.selectorDrawer) ? (t = t.closest(this.settings.selectorDrawer), t.id || !1) : !1 : t.id ? t.id : !1;
436
- }
437
- function ai(t) {
438
- const e = Ze.call(this, t);
439
- if (e) {
440
- const n = document.querySelector(`#${e}`), i = n ? n.querySelector(this.settings.selectorDialog) : null;
441
- return !n && !i ? { error: new Error(`No drawer elements found using the ID: "${e}".`) } : i ? { drawer: n, dialog: i } : { error: new Error("Drawer is missing dialog element.") };
442
- } else
443
- return { error: new Error("Could not resolve the drawer ID.") };
444
- }
445
- async function Ue(t) {
446
- this.store.get(t.id) ? this.store.get(t.id) === "opened" ? await t.open(!1, !1) : await t.close(!1, !1) : t.el.classList.contains(this.settings.stateOpened) ? t.state = "opened" : (t.el.classList.remove(this.settings.stateOpening), t.el.classList.remove(this.settings.stateClosing), t.el.classList.add(this.settings.stateClosed));
447
- }
448
- function Xe(t) {
449
- t.state === "opened" ? t.mode === "modal" ? this.focusTrap.mount(t.dialog, this.settings.selectorFocus) : this.focusTrap.focus(t.dialog, this.settings.selectorFocus) : (t.trigger && (t.trigger.focus(), t.trigger = null), this.focusTrap.unmount());
450
- }
451
- async function de(t, e, n = !0) {
452
- const i = ce.call(this, t), s = { ...this.settings, ...i.settings };
453
- return e !== void 0 && (s.transition = e), i.state === "closed" && (i.state = "opening", await Yn(i.el, s), i.mode === "modal" && le(!0, s), i.state = "opened"), n && Xe.call(this, i), i.el.dispatchEvent(new CustomEvent(s.customEventPrefix + "opened", {
454
- detail: this,
455
- bubbles: !0
456
- })), i;
457
- }
458
- async function Kt(t, e, n = !0) {
459
- const i = ce.call(this, t), s = { ...this.settings, ...i.settings };
460
- return e !== void 0 && (s.transition = e), i.state === "opened" && (i.state = "closing", document.activeElement.blur(), await ti(i.el, s), i.mode === "modal" && le(!1, s), n && Xe.call(this, i), i.state = "closed", i.el.dispatchEvent(new CustomEvent(s.customEventPrefix + "closed", {
461
- detail: this,
462
- bubbles: !0
463
- }))), i;
464
- }
465
- async function Ye(t, e, n) {
466
- const i = ce.call(this, t);
467
- return i.state === "closed" ? de.call(this, i, e, n) : Kt.call(this, i, e, n);
468
- }
469
- function li(t) {
470
- switch (t.mode) {
471
- case "inline":
472
- return ci.call(this, t);
473
- case "modal":
474
- return di.call(this, t);
475
- default:
476
- throw new Error(`"${t.mode}" is not a valid drawer mode.`);
477
- }
478
- }
479
- async function ci(t) {
480
- return t.el.classList.remove(t.getSetting("classModal")), t.dialog.removeAttribute("aria-modal"), le(!1, { ...this.settings, ...t.settings }), this.focusTrap.unmount(), await Ue.call(this, t), t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix") + "switchMode", {
481
- detail: this,
482
- bubbles: !0
483
- })), t;
934
+ if (this.activeModal && t.target.matches(this.settings.selectorScreen))
935
+ return this.close(this.activeModal.id);
484
936
  }
485
- async function di(t) {
486
- return t.el.classList.add(t.getSetting("classModal")), t.dialog.setAttribute("aria-modal", "true"), !this.store.get(t.id) && t.el.classList.contains(t.getSetting("stateOpened")) && this.store.set(t.id, "opened"), await Kt.call(this, t, !1, !1), t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix") + "switchMode", {
487
- detail: this,
488
- bubbles: !0
489
- })), t;
937
+ function an(t) {
938
+ if (t.key === "Escape" && this.activeModal)
939
+ return this.close(this.activeModal.id);
940
+ }
941
+ function pe(t) {
942
+ t.state === "opened" ? (t.dialog.querySelector(this.settings.selectorFocus) || t.dialog).focus() : t.trigger && (t.trigger.focus(), t.trigger = null);
943
+ }
944
+ async function ye(t, e, s = !0) {
945
+ const n = nt.call(this, t);
946
+ return (n.state === "closed" || n.state === "indeterminate" || n.state === null) && (n.setState("opening"), e ?? n.getSetting("transition") ? await wt(
947
+ n.el,
948
+ n.getSetting("stateClosed"),
949
+ n.getSetting("stateOpening"),
950
+ n.getSetting("stateOpened"),
951
+ n.getSetting("transitionDuration")
952
+ ) : (n.el.classList.add(n.getSetting("stateOpened")), n.el.classList.remove(n.getSetting("stateClosed"))), n.setState("opened"), n.mode === "modal" && bt(
953
+ !0,
954
+ n.getSetting("selectorInert"),
955
+ n.getSetting("selectorOverflow")
956
+ ), s && pe.call(this, n), n.el.dispatchEvent(
957
+ new CustomEvent(n.getSetting("customEventPrefix") + "opened", {
958
+ detail: this,
959
+ bubbles: !0
960
+ })
961
+ ), await n.parent.emit("opened", n)), n;
962
+ }
963
+ async function we(t, e, s = !0) {
964
+ const n = nt.call(this, t);
965
+ return (n.state === "opened" || n.state === "indeterminate" || n.state === null) && (n.setState("closing"), document.activeElement.blur(), e ?? n.getSetting("transition") ? await wt(
966
+ n.el,
967
+ n.getSetting("stateOpened"),
968
+ n.getSetting("stateClosing"),
969
+ n.getSetting("stateClosed"),
970
+ n.getSetting("transitionDuration")
971
+ ) : (n.el.classList.add(n.getSetting("stateClosed")), n.el.classList.remove(n.getSetting("stateOpened"))), n.setState("closed"), n.mode === "modal" && bt(
972
+ !1,
973
+ n.getSetting("selectorInert"),
974
+ n.getSetting("selectorOverflow")
975
+ ), s && pe.call(this, n), n.el.dispatchEvent(
976
+ new CustomEvent(n.getSetting("customEventPrefix") + "closed", {
977
+ detail: this,
978
+ bubbles: !0
979
+ })
980
+ ), await n.parent.emit("closed", n)), n;
490
981
  }
491
- async function ui(t, e) {
492
- await ne.call(this, t, !1);
493
- const n = this, i = new Vn(), s = {
494
- open(o, c) {
495
- return de.call(n, this, o, c);
496
- },
497
- close(o, c) {
498
- return Kt.call(n, this, o, c);
499
- },
500
- toggle(o, c) {
501
- return Ye.call(n, this, o, c);
502
- },
503
- deregister() {
504
- return ne.call(n, this);
505
- },
506
- mountBreakpoint() {
507
- const o = this.breakpoint, c = this.handleBreakpoint.bind(this);
508
- return i.mount(o, c), this;
509
- },
510
- unmountBreakpoint() {
511
- return i.unmount(), this;
512
- },
513
- handleBreakpoint(o) {
514
- return this.mode = o.matches ? "inline" : "modal", this;
515
- },
516
- getSetting(o) {
517
- return o in this.settings ? this.settings[o] : n.settings[o];
518
- }
519
- }, r = {
520
- id: t.id,
521
- el: t,
522
- dialog: e,
523
- trigger: null,
524
- settings: Zn(t, this.settings.dataConfig),
525
- get breakpoint() {
526
- return oi.call(n, t);
527
- },
528
- get state() {
529
- return a;
530
- },
531
- set state(o) {
532
- a = o, (o === "opened" || o === "closed") && this.mode === "inline" && n.store.set(this.id, this.state);
533
- },
534
- get mode() {
535
- return l;
536
- },
537
- set mode(o) {
538
- l = o, li.call(n, this);
539
- },
540
- ...s
541
- };
542
- let a = t.classList.contains(r.getSetting("stateOpened")) ? "opened" : "closed", l = t.classList.contains(r.getSetting("classModal")) ? "modal" : "inline";
543
- return r.mode === "modal" ? r.dialog.setAttribute("aria-modal", "true") : r.dialog.removeAttribute("aria-modal"), r.getSetting("setTabindex") && r.dialog.setAttribute("tabindex", "-1"), this.collection.push(r), r.breakpoint ? r.mountBreakpoint() : await Ue.call(this, r), r;
982
+ async function cn(t, e, s) {
983
+ const n = nt.call(this, t);
984
+ return n.state === "closed" ? ye.call(this, n, e, s) : we.call(this, n, e, s);
544
985
  }
545
- var Et, xt;
546
- let Xs = class extends Jn {
547
- constructor(e) {
548
- super(), De(this, Et, void 0), De(this, xt, void 0), this.defaults = ii, this.settings = { ...this.defaults, ...e }, this.focusTrap = new Kn(), this.store = Xn(this.settings.storeKey, this.settings.store), Pe(this, Et, si.bind(this)), Pe(this, xt, ri.bind(this)), this.settings.autoInit && this.init();
986
+ var it, ot;
987
+ class us extends Ot {
988
+ constructor(s) {
989
+ super({ ...en, ...s });
990
+ U(this, it);
991
+ U(this, ot);
992
+ this.module = "Drawer", this.entryClass = rn, S(this, it, ln.bind(this)), S(this, ot, an.bind(this));
549
993
  }
550
994
  get activeModal() {
551
- return this.collection.find((e) => e.state === "opened" && e.mode === "modal");
995
+ return this.collection.find((s) => s.state === "opened" && s.mode === "modal");
552
996
  }
553
- async init(e = null) {
554
- e && (this.settings = { ...this.settings, ...e });
555
- const n = document.querySelectorAll(this.settings.selectorDrawer);
556
- return await this.registerCollection(n), this.settings.eventListeners && this.initEventListeners(), this;
997
+ async open(s, n, i) {
998
+ return ye.call(this, s, n, i);
557
999
  }
558
- async destroy() {
559
- return await this.deregisterCollection(), this.settings.eventListeners && this.destroyEventListeners(), this;
1000
+ async close(s, n, i) {
1001
+ return we.call(this, s, n, i);
560
1002
  }
561
- initEventListeners() {
562
- document.addEventListener("click", _t(this, Et), !1), document.addEventListener("keydown", _t(this, xt), !1);
1003
+ async toggle(s, n, i) {
1004
+ return cn.call(this, s, n, i);
563
1005
  }
564
- destroyEventListeners() {
565
- document.removeEventListener("click", _t(this, Et), !1), document.removeEventListener("keydown", _t(this, xt), !1);
1006
+ async afterMount() {
1007
+ document.addEventListener("click", E(this, it), !1), document.addEventListener("keydown", E(this, ot), !1);
566
1008
  }
567
- register(e) {
568
- const n = ai.call(this, e);
569
- return n.error ? Promise.reject(n.error) : ui.call(this, n.drawer, n.dialog);
1009
+ async beforeUnmount() {
1010
+ this.trigger = null;
570
1011
  }
571
- deregister(e) {
572
- const n = this.get(Ze.call(this, e));
573
- return ne.call(this, n);
1012
+ async afterUnmount() {
1013
+ document.removeEventListener("click", E(this, it), !1), document.removeEventListener("keydown", E(this, ot), !1);
574
1014
  }
575
- open(e, n, i) {
576
- return de.call(this, e, n, i);
1015
+ }
1016
+ it = new WeakMap(), ot = new WeakMap();
1017
+ const fn = {
1018
+ // Data attributes
1019
+ dataOpen: "modal-open",
1020
+ dataClose: "modal-close",
1021
+ dataReplace: "modal-replace",
1022
+ // Selectors
1023
+ selector: ".modal",
1024
+ selectorDialog: ".modal__dialog",
1025
+ selectorScreen: ".modal",
1026
+ selectorRequired: '[role="alertdialog"]',
1027
+ selectorFocus: "[data-focus]",
1028
+ selectorInert: null,
1029
+ selectorOverflow: "body",
1030
+ // State classes
1031
+ stateOpened: "is-opened",
1032
+ stateOpening: "is-opening",
1033
+ stateClosing: "is-closing",
1034
+ stateClosed: "is-closed",
1035
+ // Feature settings
1036
+ customProps: ["transition-duration"],
1037
+ customEventPrefix: "modal:",
1038
+ setTabindex: !0,
1039
+ transition: !0,
1040
+ transitionDuration: 300
1041
+ };
1042
+ class un extends xt {
1043
+ constructor(e, s, n = {}) {
1044
+ super(e, s, n), this.state = "closed", this.dialog = null;
577
1045
  }
578
- close(e, n, i) {
579
- return Kt.call(this, e, n, i);
1046
+ get isRequired() {
1047
+ return this.dialog.matches(this.getSetting("selectorRequired"));
580
1048
  }
581
- toggle(e, n, i) {
582
- return Ye.call(this, e, n, i);
1049
+ async open(e, s) {
1050
+ return this.parent.open(this, e, s);
583
1051
  }
584
- };
585
- Et = /* @__PURE__ */ new WeakMap(), xt = /* @__PURE__ */ new WeakMap();
586
- var tn = (t, e, n) => {
587
- if (!e.has(t))
588
- throw TypeError("Cannot " + n);
589
- }, Ft = (t, e, n) => (tn(t, e, "read from private field"), n ? n.call(t) : e.get(t)), qe = (t, e, n) => {
590
- if (e.has(t))
591
- throw TypeError("Cannot add the same private member more than once");
592
- e instanceof WeakSet ? e.add(t) : e.set(t, n);
593
- }, Me = (t, e, n, i) => (tn(t, e, "write to private field"), i ? i.call(t, n) : e.set(t, n), n), en = (t, e, n) => {
594
- if (!e.has(t))
595
- throw TypeError("Cannot " + n);
596
- }, Q = (t, e, n) => (en(t, e, "read from private field"), n ? n.call(t) : e.get(t)), Yt = (t, e, n) => {
597
- if (e.has(t))
598
- throw TypeError("Cannot add the same private member more than once");
599
- e instanceof WeakSet ? e.add(t) : e.set(t, n);
600
- }, te = (t, e, n, i) => (en(t, e, "write to private field"), i ? i.call(t, n) : e.set(t, n), n);
601
- class hi {
602
- constructor() {
603
- this.collection = [];
604
- }
605
- async register(e) {
606
- return await this.deregister(e), this.collection.push(e), this.collection;
1052
+ async close(e, s) {
1053
+ return this.parent.close(this, e, s);
607
1054
  }
608
- async deregister(e) {
609
- const n = this.collection.findIndex((i) => i === e);
610
- if (n >= 0) {
611
- const i = this.collection[n];
612
- Object.getOwnPropertyNames(i).forEach((s) => {
613
- delete i[s];
614
- }), this.collection.splice(n, 1);
615
- }
616
- return this.collection;
617
- }
618
- async registerCollection(e) {
619
- return await Promise.all(Array.from(e, (n) => {
620
- this.register(n);
621
- })), this.collection;
622
- }
623
- async deregisterCollection() {
624
- for (; this.collection.length > 0; )
625
- await this.deregister(this.collection[0]);
626
- return this.collection;
627
- }
628
- get(e, n = "id") {
629
- return this.collection.find((i) => i[n] === e);
630
- }
631
- }
632
- const m = {
633
- inert: ":not([inert]):not([inert] *)",
634
- negTabIndex: ':not([tabindex^="-"])',
635
- disabled: ":not(:disabled)"
636
- }, fi = [
637
- `a[href]${m.inert}${m.negTabIndex}`,
638
- `area[href]${m.inert}${m.negTabIndex}`,
639
- `input:not([type="hidden"]):not([type="radio"])${m.inert}${m.negTabIndex}${m.disabled}`,
640
- `input[type="radio"]${m.inert}${m.negTabIndex}${m.disabled}`,
641
- `select${m.inert}${m.negTabIndex}${m.disabled}`,
642
- `textarea${m.inert}${m.negTabIndex}${m.disabled}`,
643
- `button${m.inert}${m.negTabIndex}${m.disabled}`,
644
- `details${m.inert} > summary:first-of-type${m.negTabIndex}`,
645
- // Discard until Firefox supports `:has()`
646
- // See: https://github.com/KittyGiraudel/focusable-selectors/issues/12
647
- // `details:not(:has(> summary))${not.inert}${not.negTabIndex}`,
648
- `iframe${m.inert}${m.negTabIndex}`,
649
- `audio[controls]${m.inert}${m.negTabIndex}`,
650
- `video[controls]${m.inert}${m.negTabIndex}`,
651
- `[contenteditable]${m.inert}${m.negTabIndex}`,
652
- `[tabindex]${m.inert}${m.negTabIndex}`
653
- ];
654
- var Lt, ut, ht;
655
- let pi = class {
656
- constructor(e = null, n = "[data-focus]") {
657
- Yt(this, Lt, void 0), Yt(this, ut, void 0), Yt(this, ht, void 0), this.el = e, this.selectorFocus = n, te(this, ut, gi.bind(this)), te(this, ht, mi.bind(this));
1055
+ async replace(e, s) {
1056
+ return this.parent.replace(this, e, s);
658
1057
  }
659
- get focusable() {
660
- return Q(this, Lt);
1058
+ async deregister() {
1059
+ return this.parent.deregister(this.id);
661
1060
  }
662
- set focusable(e) {
663
- te(this, Lt, e), Q(this, Lt).length ? (document.removeEventListener("keydown", Q(this, ht)), document.addEventListener("keydown", Q(this, ut))) : (document.removeEventListener("keydown", Q(this, ut)), document.addEventListener("keydown", Q(this, ht)));
1061
+ async onCreateEntry() {
1062
+ const e = this.el.querySelector(this.getSetting("selectorDialog"));
1063
+ this.dialog = e || this.el, this.dialog.setAttribute("aria-modal", "true"), this.dialog.hasAttribute("role") || this.dialog.setAttribute("role", "dialog"), this.getSetting("setTabindex") && this.dialog.setAttribute("tabindex", "-1");
664
1064
  }
665
- get focusableFirst() {
666
- return this.focusable[0];
1065
+ async onRegisterEntry() {
1066
+ this.el.classList.contains(this.getSetting("stateOpened")) ? await this.open(!1) : (this.el.classList.remove(this.getSetting("stateOpening")), this.el.classList.remove(this.getSetting("stateClosing")), this.el.classList.add(this.getSetting("stateClosed")));
667
1067
  }
668
- get focusableLast() {
669
- return this.focusable[this.focusable.length - 1];
1068
+ async onDestroyEntry() {
1069
+ this.state === "opened" && await this.close(!1);
670
1070
  }
671
- mount(e, n) {
672
- e && (this.el = e), n && (this.selectorFocus = n), this.focusable = this.getFocusable(), this.focus();
673
- }
674
- unmount() {
675
- this.el = null, this.focusable = [], document.removeEventListener("keydown", Q(this, ut)), document.removeEventListener("keydown", Q(this, ht));
676
- }
677
- focus(e = this.el, n = this.selectorFocus) {
678
- (e.querySelector(n) || e).focus();
679
- }
680
- getFocusable(e = this.el) {
681
- const n = [], i = document.activeElement, s = e.scrollTop;
682
- return e.querySelectorAll(fi.join(",")).forEach((r) => {
683
- r.focus(), document.activeElement === r && n.push(r);
684
- }), e.scrollTop = s, i.focus(), n;
685
- }
686
- };
687
- Lt = /* @__PURE__ */ new WeakMap(), ut = /* @__PURE__ */ new WeakMap(), ht = /* @__PURE__ */ new WeakMap();
688
- function gi(t) {
689
- (t.key === "Tab" || t.keyCode === 9) && (t.shiftKey ? (document.activeElement === this.focusableFirst || document.activeElement === this.el) && (t.preventDefault(), this.focusableLast.focus()) : (document.activeElement === this.focusableLast || document.activeElement === this.el) && (t.preventDefault(), this.focusableFirst.focus()));
690
- }
691
- function mi(t) {
692
- (t.key === "Tab" || t.keyCode === 9) && t.preventDefault();
693
- }
694
- function vi(t, e) {
695
- const n = (t.getAttribute(`data-${e}`) || "").replace(/'/g, '"');
696
- return n ? JSON.parse(n) : {};
697
- }
698
- function We(t, e, n) {
699
- const i = e.nodeType === Node.COMMENT_NODE, s = e.nodeType === Node.ELEMENT_NODE;
700
- if (e = i || s ? e : document.querySelector(e), i && (n = "after"), !e)
701
- throw new Error(`Not a valid teleport reference: '${e}'`);
702
- if (typeof e[n] != "function")
703
- throw new Error(`Not a valid teleport method: '${n}'`);
704
- let r = null;
705
- return i || (r = document.createComment("teleported #" + t.id), t.before(r)), e[n](t), i && e.remove(), r;
706
- }
707
- const bi = (t, e) => new Promise((n) => {
708
- e.transition ? (t.classList.remove(e.stateClosed), t.classList.add(e.stateOpening), t.addEventListener("transitionend", function i(s) {
709
- s.target == t && (t.classList.add(e.stateOpened), t.classList.remove(e.stateOpening), n(t), this.removeEventListener("transitionend", i));
710
- })) : (t.classList.add(e.stateOpened), t.classList.remove(e.stateClosed), n(t));
711
- }), yi = (t, e) => new Promise((n) => {
712
- e.transition ? (t.classList.add(e.stateClosing), t.classList.remove(e.stateOpened), t.addEventListener("transitionend", function i(s) {
713
- s.target == t && (t.classList.remove(e.stateClosing), t.classList.add(e.stateClosed), n(t), this.removeEventListener("transitionend", i));
714
- })) : (t.classList.add(e.stateClosed), t.classList.remove(e.stateOpened), n(t));
715
- });
716
- function wi(t, e) {
717
- e && document.querySelectorAll(e).forEach((n) => {
718
- t ? n.style.overflow = "hidden" : n.style.removeProperty("overflow");
719
- });
720
- }
721
- function $i(t, e) {
722
- e && document.querySelectorAll(e).forEach((n) => {
723
- t ? (n.inert = !0, n.setAttribute("aria-hidden", !0)) : (n.inert = null, n.removeAttribute("aria-hidden"));
724
- });
725
1071
  }
726
- function Ei(t, e) {
727
- $i(!!t, e.selectorInert), wi(!!t, e.selectorOverflow);
728
- }
729
- const xi = {
730
- autoInit: !1,
731
- // Data attributes
732
- dataOpen: "modal-open",
733
- dataClose: "modal-close",
734
- dataReplace: "modal-replace",
735
- dataConfig: "modal-config",
736
- // Selectors
737
- selectorModal: ".modal",
738
- selectorDialog: ".modal__dialog",
739
- selectorRequired: '[role="alertdialog"]',
740
- selectorFocus: "[data-focus]",
741
- selectorInert: null,
742
- selectorOverflow: "body",
743
- // State classes
744
- stateOpened: "is-opened",
745
- stateOpening: "is-opening",
746
- stateClosing: "is-closing",
747
- stateClosed: "is-closed",
748
- // Feature settings
749
- customEventPrefix: "modal:",
750
- eventListeners: !0,
751
- teleport: null,
752
- teleportMethod: "append",
753
- setTabindex: !0,
754
- transition: !0
755
- };
756
- function ue(t) {
1072
+ function pt(t) {
757
1073
  const e = typeof t == "string" ? this.get(t) : this.get(t.id);
758
1074
  if (e)
759
1075
  return e;
760
- throw new Error(`Modal not found in collection with id of "${t.id || t}".`);
761
- }
762
- function Jt(t) {
763
- return typeof t == "string" ? t : typeof t.hasAttribute == "function" ? t.hasAttribute(`data-${this.settings.dataOpen}`) ? t.getAttribute(`data-${this.settings.dataOpen}`) : t.hasAttribute(`data-${this.settings.dataClose}`) ? t.getAttribute(`data-${this.settings.dataClose}`) || !1 : t.hasAttribute(`data-${this.settings.dataReplace}`) ? t.getAttribute(`data-${this.settings.dataReplace}`) : t.closest(this.settings.selectorModal) ? (t = t.closest(this.settings.selectorModal), t.id || !1) : !1 : t.id ? t.id : !1;
764
- }
765
- function Li(t) {
766
- const e = Jt.call(this, t);
767
- if (e) {
768
- const n = document.querySelector(`#${e}`), i = n ? n.querySelector(this.settings.selectorDialog) : null;
769
- return !n && !i ? { error: new Error(`No modal elements found using the ID: "${e}".`) } : i ? { modal: n, dialog: i } : { error: new Error("Modal is missing dialog element.") };
770
- } else
771
- return { error: new Error("Could not resolve the modal ID.") };
772
- }
773
- function Gt() {
774
- this.active ? this.focusTrap.mount(this.active.dialog, this.settings.selectorFocus) : (this.trigger && (this.trigger.focus(), this.trigger = null), this.focusTrap.unmount());
775
- }
776
- async function Oi(t) {
777
- let e = t.target.closest(
778
- `[data-${this.settings.dataOpen}], [data-${this.settings.dataReplace}]`
1076
+ throw new Error(
1077
+ `Modal not found in collection with id of "${t.id || t}".`
779
1078
  );
1079
+ }
1080
+ async function dn(t) {
1081
+ const e = t.target.closest(`
1082
+ [data-${this.settings.dataOpen}],
1083
+ [data-${this.settings.dataReplace}],
1084
+ [data-${this.settings.dataClose}]
1085
+ `);
780
1086
  if (e) {
781
- t.preventDefault(), t.target.closest(this.settings.selectorModal) || (this.trigger = e);
782
- const n = this.get(Jt.call(this, e));
783
- return e.matches(`[data-${this.settings.dataOpen}]`) ? n.open() : n.replace();
784
- }
785
- if (e = t.target.closest(`[data-${this.settings.dataClose}]`), e) {
786
- t.preventDefault();
787
- const n = e.getAttribute(`data-${this.settings.dataClose}`);
788
- return n === "*" ? this.closeAll() : this.close(n);
1087
+ if (t.preventDefault(), e.matches(`[data-${this.settings.dataOpen}]`)) {
1088
+ const s = e.getAttribute(`data-${this.settings.dataOpen}`).trim(), n = pt.call(this, s);
1089
+ return t.target.closest(this.settings.selector) || (this.trigger = e), n.open();
1090
+ }
1091
+ if (e.matches(`[data-${this.settings.dataReplace}]`)) {
1092
+ const s = e.getAttribute(`data-${this.settings.dataReplace}`).trim(), n = pt.call(this, s);
1093
+ return t.target.closest(this.settings.selector) || (this.trigger = e), n.replace();
1094
+ }
1095
+ if (e.matches(`[data-${this.settings.dataClose}]`)) {
1096
+ const s = e.getAttribute(`data-${this.settings.dataClose}`).trim();
1097
+ return s === "*" ? this.closeAll() : this.close(s);
1098
+ }
789
1099
  }
790
- if (t.target.matches(this.settings.selectorModal) && !t.target.querySelector(this.settings.selectorRequired))
791
- return this.close(Jt.call(this, t.target));
1100
+ if (this.active && t.target.matches(this.settings.selectorScreen) && !this.active.isRequired)
1101
+ return this.close(this.active.id);
792
1102
  }
793
- function ki(t) {
1103
+ function hn(t) {
794
1104
  if (t.key === "Escape" && this.active && !this.active.dialog.matches(this.settings.selectorRequired))
795
1105
  return this.close();
796
1106
  }
797
- async function ie(t, e = !0) {
798
- if (!t)
799
- return this.collection;
800
- const n = this.collection.findIndex((i) => i.id === t.id);
801
- if (n >= 0) {
802
- const i = this.collection[n];
803
- e && i.state === "opened" ? await i.close(!1) : this.stack.remove(i), i.getSetting("teleport") && i.teleportReturn(), Object.getOwnPropertyNames(i).forEach((s) => {
804
- delete i[s];
805
- }), this.collection.splice(n, 1);
806
- }
807
- return this.collection;
808
- }
809
- async function he(t, e, n = !0) {
810
- const i = ue.call(this, t), s = { ...this.settings, ...i.settings };
811
- return e !== void 0 && (s.transition = e), this.stack.moveToTop(i), i.state === "closed" && (i.state = "opening", this.stack.add(i), await bi(i.el, s), i.state = "opened"), n && Gt.call(this), i.el.dispatchEvent(new CustomEvent(s.customEventPrefix + "opened", {
812
- detail: this,
813
- bubbles: !0
814
- })), i;
815
- }
816
- async function fe(t, e, n = !0) {
817
- const i = t ? ue.call(this, t) : this.active;
818
- if (i && i.state === "opened") {
819
- i.state = "closing";
820
- const s = { ...this.settings, ...i.settings };
821
- e !== void 0 && (s.transition = e), document.activeElement.blur(), await yi(i.el, s), this.stack.remove(i), n && Gt.call(this), i.state = "closed", i.el.dispatchEvent(new CustomEvent(s.customEventPrefix + "closed", {
822
- detail: this,
1107
+ function Lt() {
1108
+ this.active ? (this.active.dialog.querySelector(this.settings.selectorFocus) || this.active.dialog).focus() : this.trigger && (this.trigger.focus(), this.trigger = null);
1109
+ }
1110
+ async function be(t, e = void 0, s = !0) {
1111
+ const n = pt.call(this, t);
1112
+ return this.stack.moveToTop(n), n.state === "closed" && (n.state = "opening", this.stack.add(n), e ?? n.getSetting("transition") ? await wt(
1113
+ n.el,
1114
+ n.getSetting("stateClosed"),
1115
+ n.getSetting("stateOpening"),
1116
+ n.getSetting("stateOpened"),
1117
+ n.getSetting("transitionDuration")
1118
+ ) : (n.el.classList.add(n.getSetting("stateOpened")), n.el.classList.remove(n.getSetting("stateClosed"))), n.state = "opened"), s && Lt.call(this), n.el.dispatchEvent(
1119
+ new CustomEvent(n.getSetting("customEventPrefix") + "opened", {
1120
+ detail: n,
823
1121
  bubbles: !0
824
- }));
825
- }
826
- return i;
827
- }
828
- async function se(t, e) {
829
- const n = [];
830
- return await Promise.all(this.stack.value.map(async (i) => {
831
- t && t === i.id ? Promise.resolve() : n.push(await fe.call(this, i, e, !1)), i.trigger = null;
832
- })), n;
833
- }
834
- async function nn(t, e, n = !0) {
835
- const i = ue.call(this, t);
836
- let s, r;
837
- return i.state === "opened" ? (s = i, r = await se.call(this, i.id, e)) : (s = he.call(this, i, e, !1), r = se.call(this, !1, e), await Promise.all([s, r])), n && Gt.call(this), { opened: s, closed: r };
838
- }
839
- async function Ti(t, e) {
840
- await ie.call(this, t, !1);
841
- const n = this, i = {
842
- open(r, a) {
843
- return he.call(n, this, r, a);
844
- },
845
- close(r, a) {
846
- return fe.call(n, this, r, a);
847
- },
848
- replace(r, a) {
849
- return nn.call(n, this, r, a);
850
- },
851
- deregister() {
852
- return ie.call(n, this);
853
- },
854
- teleport(r = this.getSetting("teleport"), a = this.getSetting("teleportMethod")) {
855
- return this.returnRef ? (console.error("Element has already been teleported:", this.el), !1) : (this.returnRef = We(this.el, r, a), this.el);
856
- },
857
- teleportReturn() {
858
- return this.returnRef ? (this.returnRef = We(this.el, this.returnRef), this.el) : (console.error("No return reference found:", this.el), !1);
859
- },
860
- getSetting(r) {
861
- return r in this.settings ? this.settings[r] : n.settings[r];
862
- }
863
- }, s = {
864
- id: t.id,
865
- state: "closed",
866
- el: t,
867
- dialog: e,
868
- returnRef: null,
869
- settings: vi(t, this.settings.dataConfig),
870
- ...i
871
- };
872
- return s.dialog.setAttribute("aria-modal", "true"), s.dialog.hasAttribute("role") || s.dialog.setAttribute("role", "dialog"), s.getSetting("setTabindex") && s.dialog.setAttribute("tabindex", "-1"), s.getSetting("teleport") && s.teleport(), this.collection.push(s), s.el.classList.contains(this.settings.stateOpened) ? await s.open(!1) : (s.el.classList.remove(this.settings.stateOpening), s.el.classList.remove(this.settings.stateClosing), s.el.classList.add(this.settings.stateClosed)), s;
873
- }
874
- function Ai(t) {
875
- const e = [];
876
- return {
877
- get value() {
878
- return [...e];
879
- },
880
- get top() {
881
- return e[e.length - 1];
882
- },
883
- updateIndex() {
884
- e.forEach((n, i) => {
885
- n.el.style.zIndex = null;
886
- const s = getComputedStyle(n.el)["z-index"];
887
- n.el.style.zIndex = parseInt(s) + i + 1;
888
- });
889
- },
890
- updateGlobalState() {
891
- Ei(this.top, t), this.updateIndex();
892
- },
893
- add(n) {
894
- n.el.style.zIndex = null;
895
- const i = getComputedStyle(n.el)["z-index"];
896
- n.el.style.zIndex = parseInt(i) + e.length + 1, e.push(n), this.updateGlobalState();
897
- },
898
- remove(n) {
899
- const i = e.findIndex((s) => s.id === n.id);
900
- i >= 0 && (n.el.style.zIndex = null, e.splice(i, 1), this.updateGlobalState());
901
- },
902
- moveToTop(n) {
903
- const i = e.findIndex((s) => s.id === n.id);
904
- i >= 0 && (e.splice(i, 1), this.add(n));
905
- }
906
- };
907
- }
908
- var Ot, kt;
909
- class er extends hi {
910
- constructor(e) {
911
- super(), qe(this, Ot, void 0), qe(this, kt, void 0), this.defaults = xi, this.settings = { ...this.defaults, ...e }, this.trigger = null, this.focusTrap = new pi(), this.stack = Ai(this.settings), Me(this, Ot, Oi.bind(this)), Me(this, kt, ki.bind(this)), this.settings.autoInit && this.init();
1122
+ })
1123
+ ), await n.parent.emit("opened", n), n;
1124
+ }
1125
+ async function xe(t, e, s = !0) {
1126
+ const n = t ? pt.call(this, t) : this.active;
1127
+ return n && n.state === "opened" && (n.state = "closing", document.activeElement.blur(), e ?? n.getSetting("transition") ? await wt(
1128
+ n.el,
1129
+ n.getSetting("stateOpened"),
1130
+ n.getSetting("stateClosing"),
1131
+ n.getSetting("stateClosed"),
1132
+ n.getSetting("transitionDuration")
1133
+ ) : (n.el.classList.add(n.getSetting("stateClosed")), n.el.classList.remove(n.getSetting("stateOpened"))), this.stack.remove(n), n.state = "closed", s && Lt.call(this), n.el.dispatchEvent(
1134
+ new CustomEvent(n.getSetting("customEventPrefix") + "closed", {
1135
+ detail: n,
1136
+ bubbles: !0
1137
+ })
1138
+ ), await n.parent.emit("closed", n)), n;
1139
+ }
1140
+ async function It(t, e) {
1141
+ const s = [];
1142
+ return await Promise.all(
1143
+ this.stack.copy.map(async (n) => {
1144
+ t && t === n.id || (s.push(await xe.call(this, n, e, !1)), n.trigger = null);
1145
+ })
1146
+ ), s;
1147
+ }
1148
+ async function gn(t, e, s = !0) {
1149
+ const n = pt.call(this, t);
1150
+ let i, r;
1151
+ return n.state === "opened" ? (i = n, r = await It.call(this, n.id, e)) : (r = It.call(this, !1, e), i = be.call(this, n, e, !1), await Promise.all([i, r])), s && Lt.call(this), { opened: i, closed: r };
1152
+ }
1153
+ var rt, lt;
1154
+ class ds extends Ot {
1155
+ constructor(s) {
1156
+ super({ ...fn, ...s });
1157
+ U(this, rt);
1158
+ U(this, lt);
1159
+ this.module = "Modal", this.entryClass = un, this.trigger = null, S(this, rt, dn.bind(this)), S(this, lt, hn.bind(this)), this.stack = new me({
1160
+ onChange: () => {
1161
+ bt(
1162
+ this.stack.top,
1163
+ this.settings.selectorInert,
1164
+ this.settings.selectorOverflow
1165
+ );
1166
+ }
1167
+ });
912
1168
  }
913
1169
  get active() {
914
1170
  return this.stack.top;
915
1171
  }
916
- async init(e) {
917
- e && (this.settings = { ...this.settings, ...e });
918
- const n = document.querySelectorAll(this.settings.selectorModal);
919
- return await this.registerCollection(n), this.settings.eventListeners && this.initEventListeners(), this;
920
- }
921
- async destroy() {
922
- return this.trigger = null, await this.deregisterCollection(), this.settings.eventListeners && this.destroyEventListeners(), this;
923
- }
924
- initEventListeners() {
925
- document.addEventListener("click", Ft(this, Ot), !1), document.addEventListener("keydown", Ft(this, kt), !1);
1172
+ async open(s, n, i) {
1173
+ return be.call(this, s, n, i);
926
1174
  }
927
- destroyEventListeners() {
928
- document.removeEventListener("click", Ft(this, Ot), !1), document.removeEventListener("keydown", Ft(this, kt), !1);
1175
+ async close(s, n, i) {
1176
+ return xe.call(this, s, n, i);
929
1177
  }
930
- register(e) {
931
- const n = Li.call(this, e);
932
- return n.error ? Promise.reject(n.error) : Ti.call(this, n.modal, n.dialog);
1178
+ async replace(s, n, i) {
1179
+ return gn.call(this, s, n, i);
933
1180
  }
934
- deregister(e) {
935
- const n = this.get(Jt.call(this, e));
936
- return ie.call(this, n);
1181
+ async closeAll(s = !1, n, i = !0) {
1182
+ const r = await It.call(this, s, n);
1183
+ return i && Lt.call(this), r;
937
1184
  }
938
- open(e, n, i) {
939
- return he.call(this, e, n, i);
1185
+ async afterMount() {
1186
+ document.addEventListener("click", E(this, rt), !1), document.addEventListener("keydown", E(this, lt), !1);
940
1187
  }
941
- close(e, n, i) {
942
- return fe.call(this, e, n, i);
1188
+ async beforeUnmount() {
1189
+ this.trigger = null;
943
1190
  }
944
- replace(e, n, i) {
945
- return nn.call(this, e, n, i);
946
- }
947
- async closeAll(e = !1, n, i = !0) {
948
- const s = await se.call(this, e, n);
949
- return i && Gt.call(this), s;
1191
+ async afterUnmount() {
1192
+ document.removeEventListener("click", E(this, rt), !1), document.removeEventListener("keydown", E(this, lt), !1);
950
1193
  }
951
1194
  }
952
- Ot = /* @__PURE__ */ new WeakMap(), kt = /* @__PURE__ */ new WeakMap();
953
- var sn = (t, e, n) => {
954
- if (!e.has(t))
955
- throw TypeError("Cannot " + n);
956
- }, je = (t, e, n) => (sn(t, e, "read from private field"), n ? n.call(t) : e.get(t)), Ci = (t, e, n) => {
957
- if (e.has(t))
958
- throw TypeError("Cannot add the same private member more than once");
959
- e instanceof WeakSet ? e.add(t) : e.set(t, n);
960
- }, Ii = (t, e, n, i) => (sn(t, e, "write to private field"), i ? i.call(t, n) : e.set(t, n), n);
961
- class Si {
962
- constructor() {
963
- this.collection = [];
964
- }
965
- async register(e) {
966
- return await this.deregister(e), this.collection.push(e), this.collection;
967
- }
968
- async deregister(e) {
969
- const n = this.collection.findIndex((i) => i === e);
970
- if (n >= 0) {
971
- const i = this.collection[n];
972
- Object.getOwnPropertyNames(i).forEach((s) => {
973
- delete i[s];
974
- }), this.collection.splice(n, 1);
975
- }
976
- return this.collection;
977
- }
978
- async registerCollection(e) {
979
- return await Promise.all(Array.from(e, (n) => {
980
- this.register(n);
981
- })), this.collection;
982
- }
983
- async deregisterCollection() {
984
- for (; this.collection.length > 0; )
985
- await this.deregister(this.collection[0]);
986
- return this.collection;
987
- }
988
- get(e, n = "id") {
989
- return this.collection.find((i) => i[n] === e);
990
- }
991
- }
992
- function Di() {
993
- return getComputedStyle(document.body).getPropertyValue("--vrembem-variable-prefix").trim();
994
- }
995
- const Pi = {
996
- autoInit: !1,
1195
+ rt = new WeakMap(), lt = new WeakMap();
1196
+ const mn = {
997
1197
  // Selectors
998
- selectorPopover: ".popover",
1198
+ selector: ".popover",
1199
+ selectorTooltip: ".popover_tooltip",
999
1200
  selectorArrow: ".popover__arrow",
1000
1201
  // State classes
1001
1202
  stateActive: "is-active",
1002
- // Feature settings
1003
- eventListeners: !0,
1004
- eventType: "click",
1005
- placement: "bottom"
1203
+ // Custom properties and their defaults
1204
+ customProps: [
1205
+ "placement",
1206
+ "event",
1207
+ "offset",
1208
+ "flip-padding",
1209
+ "shift-padding",
1210
+ "arrow-padding",
1211
+ "toggle-delay"
1212
+ ],
1213
+ customEventPrefix: "popover:",
1214
+ placement: "bottom",
1215
+ event: "click",
1216
+ offset: 0,
1217
+ flipPadding: 0,
1218
+ shiftPadding: 0,
1219
+ arrowPadding: 0,
1220
+ toggleDelay: 0
1006
1221
  };
1007
- function rn(t, e) {
1008
- const n = getComputedStyle(t), i = {
1009
- placement: e.placement,
1010
- event: e.eventType,
1011
- offset: 0,
1012
- "overflow-padding": 0,
1013
- "flip-padding": 0,
1014
- "arrow-element": e.selectorArrow,
1015
- "arrow-padding": 0
1016
- };
1017
- for (const s in i) {
1018
- const r = Di(), a = n.getPropertyValue(`--${r}popover-${s}`).trim();
1019
- a && (i[s] = a);
1020
- }
1021
- return i;
1222
+ function qt(t, e, s) {
1223
+ Object.assign(t.style, {
1224
+ left: e != null ? `${e}px` : "",
1225
+ top: s != null ? `${s}px` : ""
1226
+ });
1227
+ }
1228
+ function ve(t, e) {
1229
+ let s = t.getSetting("toggle-delay");
1230
+ typeof s == "string" && (s.indexOf(",") > -1 && (s = s.split(",")), s.indexOf(" ") > -1 && (s = s.split(" "))), Array.isArray(s) && (s = s[e]);
1231
+ const n = Number(s);
1232
+ if (Number.isNaN(n))
1233
+ throw new Error(`Provided delay value is not a number: "${s}"`);
1234
+ return n;
1022
1235
  }
1023
- function ee(t) {
1236
+ function Mt(t) {
1024
1237
  let e;
1025
- const n = typeof t == "string" ? t.trim().split(" ") : [t];
1026
- switch (n.forEach(function(i, s) {
1027
- n[s] = parseInt(i, 10);
1028
- }), n.length) {
1238
+ const s = typeof t == "string" ? t.trim().split(" ") : [t];
1239
+ for (let n = 0; n < s.length; n++)
1240
+ s[n] = Number(s[n]);
1241
+ switch (s.length) {
1029
1242
  case 1:
1030
- e = n[0];
1243
+ e = s[0];
1031
1244
  break;
1032
1245
  case 2:
1033
1246
  e = {
1034
- top: n[0],
1035
- right: n[1],
1036
- bottom: n[0],
1037
- left: n[1]
1247
+ top: s[0],
1248
+ right: s[1],
1249
+ bottom: s[0],
1250
+ left: s[1]
1038
1251
  };
1039
1252
  break;
1040
1253
  case 3:
1041
1254
  e = {
1042
- top: n[0],
1043
- right: n[1],
1044
- bottom: n[2],
1045
- left: n[1]
1255
+ top: s[0],
1256
+ right: s[1],
1257
+ bottom: s[2],
1258
+ left: s[1]
1046
1259
  };
1047
1260
  break;
1048
1261
  case 4:
1049
1262
  e = {
1050
- top: n[0],
1051
- right: n[1],
1052
- bottom: n[2],
1053
- left: n[3]
1263
+ top: s[0],
1264
+ right: s[1],
1265
+ bottom: s[2],
1266
+ left: s[3]
1054
1267
  };
1055
1268
  break;
1056
1269
  default:
@@ -1059,1120 +1272,1283 @@ function ee(t) {
1059
1272
  }
1060
1273
  return e;
1061
1274
  }
1062
- function qi(t) {
1063
- return [{
1064
- name: "offset",
1065
- options: {
1066
- offset: [0, parseInt(t.offset, 10)]
1067
- }
1068
- }, {
1069
- name: "preventOverflow",
1070
- options: {
1071
- padding: ee(t["overflow-padding"])
1072
- }
1073
- }, {
1074
- name: "flip",
1075
- options: {
1076
- padding: ee(t["flip-padding"])
1077
- }
1078
- }, {
1079
- name: "arrow",
1080
- options: {
1081
- element: t["arrow-element"],
1082
- padding: ee(t["arrow-padding"])
1275
+ function pn(t) {
1276
+ return {
1277
+ offset: Number(t.getSetting("offset")),
1278
+ flip: {
1279
+ padding: Mt(t.getSetting("flip-padding"))
1280
+ },
1281
+ shift: {
1282
+ padding: Mt(t.getSetting("shift-padding"))
1283
+ },
1284
+ arrow: {
1285
+ element: t.getSetting("selectorArrow"),
1286
+ padding: Mt(t.getSetting("arrow-padding"))
1083
1287
  }
1084
- }];
1288
+ };
1085
1289
  }
1086
- function on(t) {
1290
+ function Ee(t) {
1087
1291
  const e = typeof t == "string" ? this.get(t) : this.get(t.id);
1088
1292
  if (e)
1089
1293
  return e;
1090
1294
  throw new Error(`Popover not found in collection with id of "${t}".`);
1091
1295
  }
1092
- function an(t) {
1093
- return typeof t == "string" ? t : typeof t.hasAttribute == "function" ? t.closest(this.settings.selectorPopover) ? (t = t.closest(this.settings.selectorPopover), t.id) : t.hasAttribute("aria-controls") ? t.getAttribute("aria-controls") : t.hasAttribute("aria-describedby") ? t.getAttribute("aria-describedby") : !1 : t.id ? t.id : !1;
1296
+ async function Se(t) {
1297
+ const e = t ? Ee.call(this, t) : await Ce.call(this);
1298
+ return e && e.state === "opened" && (e.el.inert = !0, e.el.classList.remove(this.settings.stateActive), e.isTooltip || e.trigger.setAttribute("aria-expanded", "false"), e.floatingCleanup(), e.state = "closed", e.trigger === this.trigger && (this.trigger = null), e.el.dispatchEvent(
1299
+ new CustomEvent(e.getSetting("customEventPrefix") + "closed", {
1300
+ detail: this,
1301
+ bubbles: !0
1302
+ })
1303
+ ), await e.parent.emit("closed", e)), e;
1094
1304
  }
1095
- function Mi(t) {
1096
- const e = an.call(this, t);
1097
- if (e) {
1098
- const n = document.querySelector(`#${e}`), i = document.querySelector(`[aria-controls="${e}"]`) || document.querySelector(`[aria-describedby="${e}"]`);
1099
- return !i && !n ? { error: new Error(`No popover elements found using the ID: "${e}".`) } : i ? n ? { popover: n, trigger: i } : { error: new Error("No popover associated with the provided popover trigger.") } : { error: new Error("No popover trigger associated with the provided popover.") };
1100
- } else
1101
- return { error: new Error("Could not resolve the popover ID.") };
1102
- }
1103
- async function pe(t) {
1104
- const e = t ? on.call(this, t) : await ln.call(this);
1105
- return e && e.state === "opened" && (e.el.classList.remove(this.settings.stateActive), e.trigger.hasAttribute("aria-controls") && e.trigger.setAttribute("aria-expanded", "false"), e.popper.setOptions({
1106
- modifiers: [{ name: "eventListeners", enabled: !1 }]
1107
- }), e.state = "closed", e.trigger === this.trigger && (this.trigger = null)), e;
1108
- }
1109
- async function ln() {
1305
+ async function Ce() {
1110
1306
  const t = [];
1111
- return await Promise.all(this.collection.map(async (e) => {
1112
- e.state === "opened" && t.push(await pe.call(this, e));
1113
- })), t;
1307
+ return await Promise.all(
1308
+ this.collection.map(async (e) => {
1309
+ e.state === "opened" && t.push(await Se.call(this, e));
1310
+ })
1311
+ ), t;
1114
1312
  }
1115
- function cn(t) {
1313
+ function $e(t) {
1116
1314
  t.state == "opened" && setTimeout(() => {
1117
- const e = t.el.closest(":hover") === t.el || t.trigger.closest(":hover") === t.trigger, n = document.activeElement.closest(
1315
+ const e = t.el.matches(":hover") === t.el || t.trigger.matches(":hover") === t.trigger;
1316
+ let s = document.activeElement.closest(
1118
1317
  `#${t.id}, [aria-controls="${t.id}"], [aria-describedby="${t.id}"]`
1119
1318
  );
1120
- return !e && !n && t.close(), t;
1319
+ return !e && !s && t.close(), t;
1121
1320
  }, 1);
1122
1321
  }
1123
- function Wi(t) {
1124
- t.state === "opened" ? t.close() : (this.trigger = t.trigger, t.open(), dn.call(this, t));
1322
+ function yn(t) {
1323
+ t.state === "opened" ? t.close() : (this.trigger = t.trigger, t.open());
1324
+ }
1325
+ function wn(t) {
1326
+ t.isTooltip && (t.toggleDelayId && clearTimeout(t.toggleDelayId), t.close());
1327
+ }
1328
+ function bn(t, e) {
1329
+ if (t.isHovered = e, e.type == "focus" && !t.trigger.matches(":focus-visible"))
1330
+ return;
1331
+ t.toggleDelayId && clearTimeout(t.toggleDelayId);
1332
+ const s = t.trigger.getAttribute("aria-expanded");
1333
+ if (s && s == "true") return;
1334
+ const n = this.activeHover ? 0 : ve(t, 0);
1335
+ this.activeHover && this.activeHover.close(), t.toggleDelayId = setTimeout(() => {
1336
+ t.id && t.open();
1337
+ }, n);
1338
+ }
1339
+ function xn(t, e) {
1340
+ setTimeout(() => {
1341
+ t.isHovered = e, !t.isHovered && (t.toggleDelayId && clearTimeout(t.toggleDelayId), t.toggleDelayId = setTimeout(
1342
+ () => {
1343
+ $e.call(this, t);
1344
+ },
1345
+ ve(t, 1)
1346
+ ));
1347
+ }, 1);
1125
1348
  }
1126
- function ji(t) {
1349
+ function vn(t) {
1127
1350
  switch (t.key) {
1128
1351
  case "Escape":
1129
- this.trigger && this.trigger.focus(), ln.call(this);
1352
+ this.trigger && this.trigger.focus(), Ce.call(this);
1130
1353
  return;
1131
1354
  case "Tab":
1132
1355
  this.collection.forEach((e) => {
1133
- cn.call(this, e);
1356
+ $e.call(this, e);
1134
1357
  });
1135
1358
  return;
1136
1359
  default:
1137
1360
  return;
1138
1361
  }
1139
1362
  }
1140
- function dn(t) {
1363
+ function En(t) {
1141
1364
  const e = this;
1142
- document.addEventListener("click", function n(i) {
1143
- i.target.closest(
1365
+ document.addEventListener("click", function s(n) {
1366
+ n.target.closest(
1144
1367
  `#${t.id}, [aria-controls="${t.id}"], [aria-describedby="${t.id}"]`
1145
- ) ? t.el && !t.el.classList.contains(e.settings.stateActive) && this.removeEventListener("click", n) : (t.el && t.el.classList.contains(e.settings.stateActive) && t.close(), this.removeEventListener("click", n));
1368
+ ) ? t.el && !t.el.classList.contains(e.settings.stateActive) && this.removeEventListener("click", s) : (t.el && t.el.classList.contains(e.settings.stateActive) && t.close(), this.removeEventListener("click", s));
1146
1369
  });
1147
1370
  }
1148
- var W = "top", B = "bottom", R = "right", j = "left", ge = "auto", Dt = [W, B, R, j], ft = "start", It = "end", Ni = "clippingParents", un = "viewport", yt = "popper", _i = "reference", Ne = /* @__PURE__ */ Dt.reduce(function(t, e) {
1149
- return t.concat([e + "-" + ft, e + "-" + It]);
1150
- }, []), hn = /* @__PURE__ */ [].concat(Dt, [ge]).reduce(function(t, e) {
1151
- return t.concat([e, e + "-" + ft, e + "-" + It]);
1152
- }, []), Fi = "beforeRead", Bi = "read", Ri = "afterRead", Hi = "beforeMain", Vi = "main", Ji = "afterMain", zi = "beforeWrite", Ki = "write", Gi = "afterWrite", Qi = [Fi, Bi, Ri, Hi, Vi, Ji, zi, Ki, Gi];
1153
- function z(t) {
1154
- return t ? (t.nodeName || "").toLowerCase() : null;
1155
- }
1156
- function _(t) {
1157
- if (t == null)
1158
- return window;
1159
- if (t.toString() !== "[object Window]") {
1160
- var e = t.ownerDocument;
1161
- return e && e.defaultView || window;
1371
+ var L, z;
1372
+ class Sn extends xt {
1373
+ constructor(s, n, i = {}) {
1374
+ super(s, n, i);
1375
+ U(this, L);
1376
+ U(this, z);
1377
+ this.state = "closed", this.toggleDelayId = null, this.trigger = null, S(this, L, null), S(this, z, {
1378
+ el: !1,
1379
+ trigger: !1
1380
+ }), this.floatingCleanup = () => {
1381
+ };
1162
1382
  }
1163
- return t;
1164
- }
1165
- function rt(t) {
1166
- var e = _(t).Element;
1167
- return t instanceof e || t instanceof Element;
1168
- }
1169
- function F(t) {
1170
- var e = _(t).HTMLElement;
1171
- return t instanceof e || t instanceof HTMLElement;
1172
- }
1173
- function me(t) {
1174
- if (typeof ShadowRoot > "u")
1175
- return !1;
1176
- var e = _(t).ShadowRoot;
1177
- return t instanceof e || t instanceof ShadowRoot;
1178
- }
1179
- function Zi(t) {
1180
- var e = t.state;
1181
- Object.keys(e.elements).forEach(function(n) {
1182
- var i = e.styles[n] || {}, s = e.attributes[n] || {}, r = e.elements[n];
1183
- !F(r) || !z(r) || (Object.assign(r.style, i), Object.keys(s).forEach(function(a) {
1184
- var l = s[a];
1185
- l === !1 ? r.removeAttribute(a) : r.setAttribute(a, l === !0 ? "" : l);
1186
- }));
1187
- });
1188
- }
1189
- function Ui(t) {
1190
- var e = t.state, n = {
1191
- popper: {
1192
- position: e.options.strategy,
1193
- left: "0",
1194
- top: "0",
1195
- margin: "0"
1196
- },
1197
- arrow: {
1198
- position: "absolute"
1199
- },
1200
- reference: {}
1201
- };
1202
- return Object.assign(e.elements.popper.style, n.popper), e.styles = n, e.elements.arrow && Object.assign(e.elements.arrow.style, n.arrow), function() {
1203
- Object.keys(e.elements).forEach(function(i) {
1204
- var s = e.elements[i], r = e.attributes[i] || {}, a = Object.keys(e.styles.hasOwnProperty(i) ? e.styles[i] : n[i]), l = a.reduce(function(o, c) {
1205
- return o[c] = "", o;
1206
- }, {});
1207
- !F(s) || !z(s) || (Object.assign(s.style, l), Object.keys(r).forEach(function(o) {
1208
- s.removeAttribute(o);
1209
- }));
1210
- });
1211
- };
1212
- }
1213
- const Xi = {
1214
- name: "applyStyles",
1215
- enabled: !0,
1216
- phase: "write",
1217
- fn: Zi,
1218
- effect: Ui,
1219
- requires: ["computeStyles"]
1220
- };
1221
- function J(t) {
1222
- return t.split("-")[0];
1223
- }
1224
- var st = Math.max, zt = Math.min, pt = Math.round;
1225
- function re() {
1226
- var t = navigator.userAgentData;
1227
- return t != null && t.brands && Array.isArray(t.brands) ? t.brands.map(function(e) {
1228
- return e.brand + "/" + e.version;
1229
- }).join(" ") : navigator.userAgent;
1230
- }
1231
- function fn() {
1232
- return !/^((?!chrome|android).)*safari/i.test(re());
1233
- }
1234
- function gt(t, e, n) {
1235
- e === void 0 && (e = !1), n === void 0 && (n = !1);
1236
- var i = t.getBoundingClientRect(), s = 1, r = 1;
1237
- e && F(t) && (s = t.offsetWidth > 0 && pt(i.width) / t.offsetWidth || 1, r = t.offsetHeight > 0 && pt(i.height) / t.offsetHeight || 1);
1238
- var a = rt(t) ? _(t) : window, l = a.visualViewport, o = !fn() && n, c = (i.left + (o && l ? l.offsetLeft : 0)) / s, d = (i.top + (o && l ? l.offsetTop : 0)) / r, b = i.width / s, v = i.height / r;
1239
- return {
1240
- width: b,
1241
- height: v,
1242
- top: d,
1243
- right: c + b,
1244
- bottom: d + v,
1245
- left: c,
1246
- x: c,
1247
- y: d
1248
- };
1249
- }
1250
- function ve(t) {
1251
- var e = gt(t), n = t.offsetWidth, i = t.offsetHeight;
1252
- return Math.abs(e.width - n) <= 1 && (n = e.width), Math.abs(e.height - i) <= 1 && (i = e.height), {
1253
- x: t.offsetLeft,
1254
- y: t.offsetTop,
1255
- width: n,
1256
- height: i
1257
- };
1258
- }
1259
- function pn(t, e) {
1260
- var n = e.getRootNode && e.getRootNode();
1261
- if (t.contains(e))
1262
- return !0;
1263
- if (n && me(n)) {
1264
- var i = e;
1265
- do {
1266
- if (i && t.isSameNode(i))
1267
- return !0;
1268
- i = i.parentNode || i.host;
1269
- } while (i);
1383
+ get isTooltip() {
1384
+ return !!this.el.closest(this.getSetting("selectorTooltip")) || this.el.getAttribute("role") == "tooltip";
1385
+ }
1386
+ get isHovered() {
1387
+ return E(this, z).el || E(this, z).trigger;
1388
+ }
1389
+ set isHovered(s) {
1390
+ const n = s.type == "mouseenter" ? !0 : s.type == "mouseleave" ? !1 : void 0;
1391
+ if (n != null)
1392
+ switch (s.target) {
1393
+ case this.el:
1394
+ E(this, z).el = n;
1395
+ break;
1396
+ case this.trigger:
1397
+ E(this, z).trigger = n;
1398
+ break;
1399
+ }
1400
+ }
1401
+ async open() {
1402
+ return this.parent.open(this);
1403
+ }
1404
+ async close() {
1405
+ return this.parent.close(this);
1406
+ }
1407
+ async deregister() {
1408
+ return this.parent.deregister(this.id);
1409
+ }
1410
+ registerEventListeners() {
1411
+ E(this, L) || (this.getSetting("event") === "hover" ? (S(this, L, [
1412
+ {
1413
+ el: ["el", "trigger"],
1414
+ type: ["mouseenter", "focus"],
1415
+ listener: bn.bind(this.parent, this)
1416
+ },
1417
+ {
1418
+ el: ["el", "trigger"],
1419
+ type: ["mouseleave", "focusout"],
1420
+ listener: xn.bind(this.parent, this)
1421
+ },
1422
+ {
1423
+ el: ["trigger"],
1424
+ type: ["click"],
1425
+ listener: wn.bind(this.parent, this)
1426
+ }
1427
+ ]), E(this, L).forEach((n) => {
1428
+ n.el.forEach((i) => {
1429
+ n.type.forEach((r) => {
1430
+ this[i].addEventListener(r, n.listener, !1);
1431
+ });
1432
+ });
1433
+ })) : (S(this, L, [
1434
+ {
1435
+ el: ["trigger"],
1436
+ type: ["click"],
1437
+ listener: yn.bind(this.parent, this)
1438
+ }
1439
+ ]), E(this, L).forEach((n) => {
1440
+ n.el.forEach((i) => {
1441
+ n.type.forEach((r) => {
1442
+ this[i].addEventListener(r, n.listener, !1);
1443
+ });
1444
+ });
1445
+ })));
1446
+ }
1447
+ deregisterEventListeners() {
1448
+ E(this, L) && (E(this, L).forEach((s) => {
1449
+ s.el.forEach((n) => {
1450
+ s.type.forEach((i) => {
1451
+ this[n].removeEventListener(i, s.listener, !1);
1452
+ });
1453
+ });
1454
+ }), S(this, L, null));
1455
+ }
1456
+ async onCreateEntry() {
1457
+ this.trigger = document.querySelector(
1458
+ `[aria-controls="${this.id}"], [aria-describedby="${this.id}"]`
1459
+ ), this.isTooltip ? (this.settings.event = "hover", this.el.setAttribute("role", "tooltip")) : this.trigger.setAttribute("aria-expanded", "false"), this.registerEventListeners();
1460
+ }
1461
+ async onRegisterEntry() {
1462
+ this.el.classList.contains(this.getSetting("stateActive")) ? await this.open() : this.el.inert = !0;
1463
+ }
1464
+ async onDestroyEntry() {
1465
+ this.state === "opened" && await this.close(), this.floatingCleanup(), this.deregisterEventListeners();
1270
1466
  }
1271
- return !1;
1272
1467
  }
1273
- function G(t) {
1274
- return _(t).getComputedStyle(t);
1468
+ L = new WeakMap(), z = new WeakMap();
1469
+ const ct = Math.min, Z = Math.max, Ct = Math.round, St = Math.floor, I = (t) => ({
1470
+ x: t,
1471
+ y: t
1472
+ }), Cn = {
1473
+ left: "right",
1474
+ right: "left",
1475
+ bottom: "top",
1476
+ top: "bottom"
1477
+ }, $n = {
1478
+ start: "end",
1479
+ end: "start"
1480
+ };
1481
+ function Ft(t, e, s) {
1482
+ return Z(t, ct(e, s));
1275
1483
  }
1276
- function Yi(t) {
1277
- return ["table", "td", "th"].indexOf(z(t)) >= 0;
1484
+ function tt(t, e) {
1485
+ return typeof t == "function" ? t(e) : t;
1278
1486
  }
1279
- function Z(t) {
1280
- return ((rt(t) ? t.ownerDocument : (
1281
- // $FlowFixMe[prop-missing]
1282
- t.document
1283
- )) || window.document).documentElement;
1487
+ function j(t) {
1488
+ return t.split("-")[0];
1284
1489
  }
1285
- function Qt(t) {
1286
- return z(t) === "html" ? t : (
1287
- // this is a quicker (but less type safe) way to save quite some bytes from the bundle
1288
- // $FlowFixMe[incompatible-return]
1289
- // $FlowFixMe[prop-missing]
1290
- t.assignedSlot || // step into the shadow DOM of the parent of a slotted node
1291
- t.parentNode || // DOM Element detected
1292
- (me(t) ? t.host : null) || // ShadowRoot detected
1293
- // $FlowFixMe[incompatible-call]: HTMLElement is a Node
1294
- Z(t)
1295
- );
1490
+ function vt(t) {
1491
+ return t.split("-")[1];
1296
1492
  }
1297
- function _e(t) {
1298
- return !F(t) || // https://github.com/popperjs/popper-core/issues/837
1299
- G(t).position === "fixed" ? null : t.offsetParent;
1493
+ function _t(t) {
1494
+ return t === "x" ? "y" : "x";
1300
1495
  }
1301
- function ts(t) {
1302
- var e = /firefox/i.test(re()), n = /Trident/i.test(re());
1303
- if (n && F(t)) {
1304
- var i = G(t);
1305
- if (i.position === "fixed")
1306
- return null;
1307
- }
1308
- var s = Qt(t);
1309
- for (me(s) && (s = s.host); F(s) && ["html", "body"].indexOf(z(s)) < 0; ) {
1310
- var r = G(s);
1311
- if (r.transform !== "none" || r.perspective !== "none" || r.contain === "paint" || ["transform", "perspective"].indexOf(r.willChange) !== -1 || e && r.willChange === "filter" || e && r.filter && r.filter !== "none")
1312
- return s;
1313
- s = s.parentNode;
1496
+ function Wt(t) {
1497
+ return t === "y" ? "height" : "width";
1498
+ }
1499
+ function K(t) {
1500
+ return ["top", "bottom"].includes(j(t)) ? "y" : "x";
1501
+ }
1502
+ function zt(t) {
1503
+ return _t(K(t));
1504
+ }
1505
+ function An(t, e, s) {
1506
+ s === void 0 && (s = !1);
1507
+ const n = vt(t), i = zt(t), r = Wt(i);
1508
+ let o = i === "x" ? n === (s ? "end" : "start") ? "right" : "left" : n === "start" ? "bottom" : "top";
1509
+ return e.reference[r] > e.floating[r] && (o = $t(o)), [o, $t(o)];
1510
+ }
1511
+ function kn(t) {
1512
+ const e = $t(t);
1513
+ return [Ht(t), e, Ht(e)];
1514
+ }
1515
+ function Ht(t) {
1516
+ return t.replace(/start|end/g, (e) => $n[e]);
1517
+ }
1518
+ function On(t, e, s) {
1519
+ const n = ["left", "right"], i = ["right", "left"], r = ["top", "bottom"], o = ["bottom", "top"];
1520
+ switch (t) {
1521
+ case "top":
1522
+ case "bottom":
1523
+ return s ? e ? i : n : e ? n : i;
1524
+ case "left":
1525
+ case "right":
1526
+ return e ? r : o;
1527
+ default:
1528
+ return [];
1314
1529
  }
1315
- return null;
1316
1530
  }
1317
- function Pt(t) {
1318
- for (var e = _(t), n = _e(t); n && Yi(n) && G(n).position === "static"; )
1319
- n = _e(n);
1320
- return n && (z(n) === "html" || z(n) === "body" && G(n).position === "static") ? e : n || ts(t) || e;
1531
+ function Ln(t, e, s, n) {
1532
+ const i = vt(t);
1533
+ let r = On(j(t), s === "start", n);
1534
+ return i && (r = r.map((o) => o + "-" + i), e && (r = r.concat(r.map(Ht)))), r;
1321
1535
  }
1322
- function be(t) {
1323
- return ["top", "bottom"].indexOf(t) >= 0 ? "x" : "y";
1536
+ function $t(t) {
1537
+ return t.replace(/left|right|bottom|top/g, (e) => Cn[e]);
1324
1538
  }
1325
- function At(t, e, n) {
1326
- return st(t, zt(e, n));
1327
- }
1328
- function es(t, e, n) {
1329
- var i = At(t, e, n);
1330
- return i > n ? n : i;
1331
- }
1332
- function gn() {
1539
+ function Rn(t) {
1333
1540
  return {
1334
1541
  top: 0,
1335
1542
  right: 0,
1336
1543
  bottom: 0,
1337
- left: 0
1544
+ left: 0,
1545
+ ...t
1338
1546
  };
1339
1547
  }
1340
- function mn(t) {
1341
- return Object.assign({}, gn(), t);
1548
+ function Ae(t) {
1549
+ return typeof t != "number" ? Rn(t) : {
1550
+ top: t,
1551
+ right: t,
1552
+ bottom: t,
1553
+ left: t
1554
+ };
1342
1555
  }
1343
- function vn(t, e) {
1344
- return e.reduce(function(n, i) {
1345
- return n[i] = t, n;
1346
- }, {});
1556
+ function At(t) {
1557
+ const {
1558
+ x: e,
1559
+ y: s,
1560
+ width: n,
1561
+ height: i
1562
+ } = t;
1563
+ return {
1564
+ width: n,
1565
+ height: i,
1566
+ top: s,
1567
+ left: e,
1568
+ right: e + n,
1569
+ bottom: s + i,
1570
+ x: e,
1571
+ y: s
1572
+ };
1347
1573
  }
1348
- var ns = function(t, e) {
1349
- return t = typeof t == "function" ? t(Object.assign({}, e.rects, {
1350
- placement: e.placement
1351
- })) : t, mn(typeof t != "number" ? t : vn(t, Dt));
1352
- };
1353
- function is(t) {
1354
- var e, n = t.state, i = t.name, s = t.options, r = n.elements.arrow, a = n.modifiersData.popperOffsets, l = J(n.placement), o = be(l), c = [j, R].indexOf(l) >= 0, d = c ? "height" : "width";
1355
- if (!(!r || !a)) {
1356
- var b = ns(s.padding, n), v = ve(r), h = o === "y" ? W : j, $ = o === "y" ? B : R, u = n.rects.reference[d] + n.rects.reference[o] - a[o] - n.rects.popper[d], w = a[o] - n.rects.reference[o], E = Pt(r), L = E ? o === "y" ? E.clientHeight || 0 : E.clientWidth || 0 : 0, O = u / 2 - w / 2, f = b[h], y = L - v[d] - b[$], x = L / 2 - v[d] / 2 + O, k = At(f, x, y), T = o;
1357
- n.modifiersData[i] = (e = {}, e[T] = k, e.centerOffset = k - x, e);
1574
+ function Zt(t, e, s) {
1575
+ let {
1576
+ reference: n,
1577
+ floating: i
1578
+ } = t;
1579
+ const r = K(e), o = zt(e), l = Wt(o), a = j(e), c = r === "y", d = n.x + n.width / 2 - i.width / 2, f = n.y + n.height / 2 - i.height / 2, h = n[l] / 2 - i[l] / 2;
1580
+ let u;
1581
+ switch (a) {
1582
+ case "top":
1583
+ u = {
1584
+ x: d,
1585
+ y: n.y - i.height
1586
+ };
1587
+ break;
1588
+ case "bottom":
1589
+ u = {
1590
+ x: d,
1591
+ y: n.y + n.height
1592
+ };
1593
+ break;
1594
+ case "right":
1595
+ u = {
1596
+ x: n.x + n.width,
1597
+ y: f
1598
+ };
1599
+ break;
1600
+ case "left":
1601
+ u = {
1602
+ x: n.x - i.width,
1603
+ y: f
1604
+ };
1605
+ break;
1606
+ default:
1607
+ u = {
1608
+ x: n.x,
1609
+ y: n.y
1610
+ };
1358
1611
  }
1359
- }
1360
- function ss(t) {
1361
- var e = t.state, n = t.options, i = n.element, s = i === void 0 ? "[data-popper-arrow]" : i;
1362
- s != null && (typeof s == "string" && (s = e.elements.popper.querySelector(s), !s) || pn(e.elements.popper, s) && (e.elements.arrow = s));
1363
- }
1364
- const rs = {
1365
- name: "arrow",
1366
- enabled: !0,
1367
- phase: "main",
1368
- fn: is,
1369
- effect: ss,
1370
- requires: ["popperOffsets"],
1371
- requiresIfExists: ["preventOverflow"]
1372
- };
1373
- function mt(t) {
1374
- return t.split("-")[1];
1375
- }
1376
- var os = {
1377
- top: "auto",
1378
- right: "auto",
1379
- bottom: "auto",
1380
- left: "auto"
1612
+ switch (vt(e)) {
1613
+ case "start":
1614
+ u[o] -= h * (s && c ? -1 : 1);
1615
+ break;
1616
+ case "end":
1617
+ u[o] += h * (s && c ? -1 : 1);
1618
+ break;
1619
+ }
1620
+ return u;
1621
+ }
1622
+ const Pn = async (t, e, s) => {
1623
+ const {
1624
+ placement: n = "bottom",
1625
+ strategy: i = "absolute",
1626
+ middleware: r = [],
1627
+ platform: o
1628
+ } = s, l = r.filter(Boolean), a = await (o.isRTL == null ? void 0 : o.isRTL(e));
1629
+ let c = await o.getElementRects({
1630
+ reference: t,
1631
+ floating: e,
1632
+ strategy: i
1633
+ }), {
1634
+ x: d,
1635
+ y: f
1636
+ } = Zt(c, n, a), h = n, u = {}, g = 0;
1637
+ for (let m = 0; m < l.length; m++) {
1638
+ const {
1639
+ name: p,
1640
+ fn: y
1641
+ } = l[m], {
1642
+ x: w,
1643
+ y: b,
1644
+ data: v,
1645
+ reset: x
1646
+ } = await y({
1647
+ x: d,
1648
+ y: f,
1649
+ initialPlacement: n,
1650
+ placement: h,
1651
+ strategy: i,
1652
+ middlewareData: u,
1653
+ rects: c,
1654
+ platform: o,
1655
+ elements: {
1656
+ reference: t,
1657
+ floating: e
1658
+ }
1659
+ });
1660
+ d = w ?? d, f = b ?? f, u = {
1661
+ ...u,
1662
+ [p]: {
1663
+ ...u[p],
1664
+ ...v
1665
+ }
1666
+ }, x && g <= 50 && (g++, typeof x == "object" && (x.placement && (h = x.placement), x.rects && (c = x.rects === !0 ? await o.getElementRects({
1667
+ reference: t,
1668
+ floating: e,
1669
+ strategy: i
1670
+ }) : x.rects), {
1671
+ x: d,
1672
+ y: f
1673
+ } = Zt(c, h, a)), m = -1);
1674
+ }
1675
+ return {
1676
+ x: d,
1677
+ y: f,
1678
+ placement: h,
1679
+ strategy: i,
1680
+ middlewareData: u
1681
+ };
1381
1682
  };
1382
- function as(t, e) {
1383
- var n = t.x, i = t.y, s = e.devicePixelRatio || 1;
1683
+ async function ke(t, e) {
1684
+ var s;
1685
+ e === void 0 && (e = {});
1686
+ const {
1687
+ x: n,
1688
+ y: i,
1689
+ platform: r,
1690
+ rects: o,
1691
+ elements: l,
1692
+ strategy: a
1693
+ } = t, {
1694
+ boundary: c = "clippingAncestors",
1695
+ rootBoundary: d = "viewport",
1696
+ elementContext: f = "floating",
1697
+ altBoundary: h = !1,
1698
+ padding: u = 0
1699
+ } = tt(e, t), g = Ae(u), p = l[h ? f === "floating" ? "reference" : "floating" : f], y = At(await r.getClippingRect({
1700
+ element: (s = await (r.isElement == null ? void 0 : r.isElement(p))) == null || s ? p : p.contextElement || await (r.getDocumentElement == null ? void 0 : r.getDocumentElement(l.floating)),
1701
+ boundary: c,
1702
+ rootBoundary: d,
1703
+ strategy: a
1704
+ })), w = f === "floating" ? {
1705
+ x: n,
1706
+ y: i,
1707
+ width: o.floating.width,
1708
+ height: o.floating.height
1709
+ } : o.reference, b = await (r.getOffsetParent == null ? void 0 : r.getOffsetParent(l.floating)), v = await (r.isElement == null ? void 0 : r.isElement(b)) ? await (r.getScale == null ? void 0 : r.getScale(b)) || {
1710
+ x: 1,
1711
+ y: 1
1712
+ } : {
1713
+ x: 1,
1714
+ y: 1
1715
+ }, x = At(r.convertOffsetParentRelativeRectToViewportRelativeRect ? await r.convertOffsetParentRelativeRectToViewportRelativeRect({
1716
+ elements: l,
1717
+ rect: w,
1718
+ offsetParent: b,
1719
+ strategy: a
1720
+ }) : w);
1384
1721
  return {
1385
- x: pt(n * s) / s || 0,
1386
- y: pt(i * s) / s || 0
1722
+ top: (y.top - x.top + g.top) / v.y,
1723
+ bottom: (x.bottom - y.bottom + g.bottom) / v.y,
1724
+ left: (y.left - x.left + g.left) / v.x,
1725
+ right: (x.right - y.right + g.right) / v.x
1387
1726
  };
1388
1727
  }
1389
- function Fe(t) {
1390
- var e, n = t.popper, i = t.popperRect, s = t.placement, r = t.variation, a = t.offsets, l = t.position, o = t.gpuAcceleration, c = t.adaptive, d = t.roundOffsets, b = t.isFixed, v = a.x, h = v === void 0 ? 0 : v, $ = a.y, u = $ === void 0 ? 0 : $, w = typeof d == "function" ? d({
1391
- x: h,
1392
- y: u
1393
- }) : {
1394
- x: h,
1395
- y: u
1728
+ const Tn = (t) => ({
1729
+ name: "arrow",
1730
+ options: t,
1731
+ async fn(e) {
1732
+ const {
1733
+ x: s,
1734
+ y: n,
1735
+ placement: i,
1736
+ rects: r,
1737
+ platform: o,
1738
+ elements: l,
1739
+ middlewareData: a
1740
+ } = e, {
1741
+ element: c,
1742
+ padding: d = 0
1743
+ } = tt(t, e) || {};
1744
+ if (c == null)
1745
+ return {};
1746
+ const f = Ae(d), h = {
1747
+ x: s,
1748
+ y: n
1749
+ }, u = zt(i), g = Wt(u), m = await o.getDimensions(c), p = u === "y", y = p ? "top" : "left", w = p ? "bottom" : "right", b = p ? "clientHeight" : "clientWidth", v = r.reference[g] + r.reference[u] - h[u] - r.floating[g], x = h[u] - r.reference[u], k = await (o.getOffsetParent == null ? void 0 : o.getOffsetParent(c));
1750
+ let O = k ? k[b] : 0;
1751
+ (!O || !await (o.isElement == null ? void 0 : o.isElement(k))) && (O = l.floating[b] || r.floating[g]);
1752
+ const dt = v / 2 - x / 2, J = O / 2 - m[g] / 2 - 1, N = ct(f[y], J), ht = ct(f[w], J), X = N, gt = O - m[g] - ht, M = O / 2 - m[g] / 2 + dt, R = Ft(X, M, gt), G = !a.arrow && vt(i) != null && M !== R && r.reference[g] / 2 - (M < X ? N : ht) - m[g] / 2 < 0, B = G ? M < X ? M - X : M - gt : 0;
1753
+ return {
1754
+ [u]: h[u] + B,
1755
+ data: {
1756
+ [u]: R,
1757
+ centerOffset: M - R - B,
1758
+ ...G && {
1759
+ alignmentOffset: B
1760
+ }
1761
+ },
1762
+ reset: G
1763
+ };
1764
+ }
1765
+ }), Mn = function(t) {
1766
+ return t === void 0 && (t = {}), {
1767
+ name: "flip",
1768
+ options: t,
1769
+ async fn(e) {
1770
+ var s, n;
1771
+ const {
1772
+ placement: i,
1773
+ middlewareData: r,
1774
+ rects: o,
1775
+ initialPlacement: l,
1776
+ platform: a,
1777
+ elements: c
1778
+ } = e, {
1779
+ mainAxis: d = !0,
1780
+ crossAxis: f = !0,
1781
+ fallbackPlacements: h,
1782
+ fallbackStrategy: u = "bestFit",
1783
+ fallbackAxisSideDirection: g = "none",
1784
+ flipAlignment: m = !0,
1785
+ ...p
1786
+ } = tt(t, e);
1787
+ if ((s = r.arrow) != null && s.alignmentOffset)
1788
+ return {};
1789
+ const y = j(i), w = K(l), b = j(l) === l, v = await (a.isRTL == null ? void 0 : a.isRTL(c.floating)), x = h || (b || !m ? [$t(l)] : kn(l)), k = g !== "none";
1790
+ !h && k && x.push(...Ln(l, m, g, v));
1791
+ const O = [l, ...x], dt = await ke(e, p), J = [];
1792
+ let N = ((n = r.flip) == null ? void 0 : n.overflows) || [];
1793
+ if (d && J.push(dt[y]), f) {
1794
+ const R = An(i, o, v);
1795
+ J.push(dt[R[0]], dt[R[1]]);
1796
+ }
1797
+ if (N = [...N, {
1798
+ placement: i,
1799
+ overflows: J
1800
+ }], !J.every((R) => R <= 0)) {
1801
+ var ht, X;
1802
+ const R = (((ht = r.flip) == null ? void 0 : ht.index) || 0) + 1, G = O[R];
1803
+ if (G) {
1804
+ var gt;
1805
+ const _ = f === "alignment" ? w !== K(G) : !1, D = ((gt = N[0]) == null ? void 0 : gt.overflows[0]) > 0;
1806
+ if (!_ || D)
1807
+ return {
1808
+ data: {
1809
+ index: R,
1810
+ overflows: N
1811
+ },
1812
+ reset: {
1813
+ placement: G
1814
+ }
1815
+ };
1816
+ }
1817
+ let B = (X = N.filter((_) => _.overflows[0] <= 0).sort((_, D) => _.overflows[1] - D.overflows[1])[0]) == null ? void 0 : X.placement;
1818
+ if (!B)
1819
+ switch (u) {
1820
+ case "bestFit": {
1821
+ var M;
1822
+ const _ = (M = N.filter((D) => {
1823
+ if (k) {
1824
+ const W = K(D.placement);
1825
+ return W === w || // Create a bias to the `y` side axis due to horizontal
1826
+ // reading directions favoring greater width.
1827
+ W === "y";
1828
+ }
1829
+ return !0;
1830
+ }).map((D) => [D.placement, D.overflows.filter((W) => W > 0).reduce((W, Fe) => W + Fe, 0)]).sort((D, W) => D[1] - W[1])[0]) == null ? void 0 : M[0];
1831
+ _ && (B = _);
1832
+ break;
1833
+ }
1834
+ case "initialPlacement":
1835
+ B = l;
1836
+ break;
1837
+ }
1838
+ if (i !== B)
1839
+ return {
1840
+ reset: {
1841
+ placement: B
1842
+ }
1843
+ };
1844
+ }
1845
+ return {};
1846
+ }
1396
1847
  };
1397
- h = w.x, u = w.y;
1398
- var E = a.hasOwnProperty("x"), L = a.hasOwnProperty("y"), O = j, f = W, y = window;
1399
- if (c) {
1400
- var x = Pt(n), k = "clientHeight", T = "clientWidth";
1401
- if (x === _(n) && (x = Z(n), G(x).position !== "static" && l === "absolute" && (k = "scrollHeight", T = "scrollWidth")), x = x, s === W || (s === j || s === R) && r === It) {
1402
- f = B;
1403
- var A = b && x === y && y.visualViewport ? y.visualViewport.height : (
1404
- // $FlowFixMe[prop-missing]
1405
- x[k]
1406
- );
1407
- u -= A - i.height, u *= o ? 1 : -1;
1848
+ };
1849
+ async function Dn(t, e) {
1850
+ const {
1851
+ placement: s,
1852
+ platform: n,
1853
+ elements: i
1854
+ } = t, r = await (n.isRTL == null ? void 0 : n.isRTL(i.floating)), o = j(s), l = vt(s), a = K(s) === "y", c = ["left", "top"].includes(o) ? -1 : 1, d = r && a ? -1 : 1, f = tt(e, t);
1855
+ let {
1856
+ mainAxis: h,
1857
+ crossAxis: u,
1858
+ alignmentAxis: g
1859
+ } = typeof f == "number" ? {
1860
+ mainAxis: f,
1861
+ crossAxis: 0,
1862
+ alignmentAxis: null
1863
+ } : {
1864
+ mainAxis: f.mainAxis || 0,
1865
+ crossAxis: f.crossAxis || 0,
1866
+ alignmentAxis: f.alignmentAxis
1867
+ };
1868
+ return l && typeof g == "number" && (u = l === "end" ? g * -1 : g), a ? {
1869
+ x: u * d,
1870
+ y: h * c
1871
+ } : {
1872
+ x: h * c,
1873
+ y: u * d
1874
+ };
1875
+ }
1876
+ const In = function(t) {
1877
+ return t === void 0 && (t = 0), {
1878
+ name: "offset",
1879
+ options: t,
1880
+ async fn(e) {
1881
+ var s, n;
1882
+ const {
1883
+ x: i,
1884
+ y: r,
1885
+ placement: o,
1886
+ middlewareData: l
1887
+ } = e, a = await Dn(e, t);
1888
+ return o === ((s = l.offset) == null ? void 0 : s.placement) && (n = l.arrow) != null && n.alignmentOffset ? {} : {
1889
+ x: i + a.x,
1890
+ y: r + a.y,
1891
+ data: {
1892
+ ...a,
1893
+ placement: o
1894
+ }
1895
+ };
1408
1896
  }
1409
- if (s === j || (s === W || s === B) && r === It) {
1410
- O = R;
1411
- var C = b && x === y && y.visualViewport ? y.visualViewport.width : (
1412
- // $FlowFixMe[prop-missing]
1413
- x[T]
1414
- );
1415
- h -= C - i.width, h *= o ? 1 : -1;
1897
+ };
1898
+ }, Fn = function(t) {
1899
+ return t === void 0 && (t = {}), {
1900
+ name: "shift",
1901
+ options: t,
1902
+ async fn(e) {
1903
+ const {
1904
+ x: s,
1905
+ y: n,
1906
+ placement: i
1907
+ } = e, {
1908
+ mainAxis: r = !0,
1909
+ crossAxis: o = !1,
1910
+ limiter: l = {
1911
+ fn: (p) => {
1912
+ let {
1913
+ x: y,
1914
+ y: w
1915
+ } = p;
1916
+ return {
1917
+ x: y,
1918
+ y: w
1919
+ };
1920
+ }
1921
+ },
1922
+ ...a
1923
+ } = tt(t, e), c = {
1924
+ x: s,
1925
+ y: n
1926
+ }, d = await ke(e, a), f = K(j(i)), h = _t(f);
1927
+ let u = c[h], g = c[f];
1928
+ if (r) {
1929
+ const p = h === "y" ? "top" : "left", y = h === "y" ? "bottom" : "right", w = u + d[p], b = u - d[y];
1930
+ u = Ft(w, u, b);
1931
+ }
1932
+ if (o) {
1933
+ const p = f === "y" ? "top" : "left", y = f === "y" ? "bottom" : "right", w = g + d[p], b = g - d[y];
1934
+ g = Ft(w, g, b);
1935
+ }
1936
+ const m = l.fn({
1937
+ ...e,
1938
+ [h]: u,
1939
+ [f]: g
1940
+ });
1941
+ return {
1942
+ ...m,
1943
+ data: {
1944
+ x: m.x - s,
1945
+ y: m.y - n,
1946
+ enabled: {
1947
+ [h]: r,
1948
+ [f]: o
1949
+ }
1950
+ }
1951
+ };
1416
1952
  }
1417
- }
1418
- var I = Object.assign({
1419
- position: l
1420
- }, c && os), H = d === !0 ? as({
1421
- x: h,
1422
- y: u
1423
- }, _(n)) : {
1424
- x: h,
1425
- y: u
1426
1953
  };
1427
- if (h = H.x, u = H.y, o) {
1428
- var P;
1429
- return Object.assign({}, I, (P = {}, P[f] = L ? "0" : "", P[O] = E ? "0" : "", P.transform = (y.devicePixelRatio || 1) <= 1 ? "translate(" + h + "px, " + u + "px)" : "translate3d(" + h + "px, " + u + "px, 0)", P));
1430
- }
1431
- return Object.assign({}, I, (e = {}, e[f] = L ? u + "px" : "", e[O] = E ? h + "px" : "", e.transform = "", e));
1432
- }
1433
- function ls(t) {
1434
- var e = t.state, n = t.options, i = n.gpuAcceleration, s = i === void 0 ? !0 : i, r = n.adaptive, a = r === void 0 ? !0 : r, l = n.roundOffsets, o = l === void 0 ? !0 : l, c = {
1435
- placement: J(e.placement),
1436
- variation: mt(e.placement),
1437
- popper: e.elements.popper,
1438
- popperRect: e.rects.popper,
1439
- gpuAcceleration: s,
1440
- isFixed: e.options.strategy === "fixed"
1954
+ }, Hn = function(t) {
1955
+ return t === void 0 && (t = {}), {
1956
+ options: t,
1957
+ fn(e) {
1958
+ const {
1959
+ x: s,
1960
+ y: n,
1961
+ placement: i,
1962
+ rects: r,
1963
+ middlewareData: o
1964
+ } = e, {
1965
+ offset: l = 0,
1966
+ mainAxis: a = !0,
1967
+ crossAxis: c = !0
1968
+ } = tt(t, e), d = {
1969
+ x: s,
1970
+ y: n
1971
+ }, f = K(i), h = _t(f);
1972
+ let u = d[h], g = d[f];
1973
+ const m = tt(l, e), p = typeof m == "number" ? {
1974
+ mainAxis: m,
1975
+ crossAxis: 0
1976
+ } : {
1977
+ mainAxis: 0,
1978
+ crossAxis: 0,
1979
+ ...m
1980
+ };
1981
+ if (a) {
1982
+ const b = h === "y" ? "height" : "width", v = r.reference[h] - r.floating[b] + p.mainAxis, x = r.reference[h] + r.reference[b] - p.mainAxis;
1983
+ u < v ? u = v : u > x && (u = x);
1984
+ }
1985
+ if (c) {
1986
+ var y, w;
1987
+ const b = h === "y" ? "width" : "height", v = ["top", "left"].includes(j(i)), x = r.reference[f] - r.floating[b] + (v && ((y = o.offset) == null ? void 0 : y[f]) || 0) + (v ? 0 : p.crossAxis), k = r.reference[f] + r.reference[b] + (v ? 0 : ((w = o.offset) == null ? void 0 : w[f]) || 0) - (v ? p.crossAxis : 0);
1988
+ g < x ? g = x : g > k && (g = k);
1989
+ }
1990
+ return {
1991
+ [h]: u,
1992
+ [f]: g
1993
+ };
1994
+ }
1441
1995
  };
1442
- e.modifiersData.popperOffsets != null && (e.styles.popper = Object.assign({}, e.styles.popper, Fe(Object.assign({}, c, {
1443
- offsets: e.modifiersData.popperOffsets,
1444
- position: e.options.strategy,
1445
- adaptive: a,
1446
- roundOffsets: o
1447
- })))), e.modifiersData.arrow != null && (e.styles.arrow = Object.assign({}, e.styles.arrow, Fe(Object.assign({}, c, {
1448
- offsets: e.modifiersData.arrow,
1449
- position: "absolute",
1450
- adaptive: !1,
1451
- roundOffsets: o
1452
- })))), e.attributes.popper = Object.assign({}, e.attributes.popper, {
1453
- "data-popper-placement": e.placement
1454
- });
1455
- }
1456
- const cs = {
1457
- name: "computeStyles",
1458
- enabled: !0,
1459
- phase: "beforeWrite",
1460
- fn: ls,
1461
- data: {}
1462
1996
  };
1463
- var Bt = {
1464
- passive: !0
1465
- };
1466
- function ds(t) {
1467
- var e = t.state, n = t.instance, i = t.options, s = i.scroll, r = s === void 0 ? !0 : s, a = i.resize, l = a === void 0 ? !0 : a, o = _(e.elements.popper), c = [].concat(e.scrollParents.reference, e.scrollParents.popper);
1468
- return r && c.forEach(function(d) {
1469
- d.addEventListener("scroll", n.update, Bt);
1470
- }), l && o.addEventListener("resize", n.update, Bt), function() {
1471
- r && c.forEach(function(d) {
1472
- d.removeEventListener("scroll", n.update, Bt);
1473
- }), l && o.removeEventListener("resize", n.update, Bt);
1474
- };
1997
+ function Rt() {
1998
+ return typeof window < "u";
1475
1999
  }
1476
- const us = {
1477
- name: "eventListeners",
1478
- enabled: !0,
1479
- phase: "write",
1480
- fn: function() {
1481
- },
1482
- effect: ds,
1483
- data: {}
1484
- };
1485
- var hs = {
1486
- left: "right",
1487
- right: "left",
1488
- bottom: "top",
1489
- top: "bottom"
1490
- };
1491
- function Vt(t) {
1492
- return t.replace(/left|right|bottom|top/g, function(e) {
1493
- return hs[e];
1494
- });
2000
+ function ut(t) {
2001
+ return Oe(t) ? (t.nodeName || "").toLowerCase() : "#document";
1495
2002
  }
1496
- var fs = {
1497
- start: "end",
1498
- end: "start"
1499
- };
1500
- function Be(t) {
1501
- return t.replace(/start|end/g, function(e) {
1502
- return fs[e];
1503
- });
2003
+ function A(t) {
2004
+ var e;
2005
+ return (t == null || (e = t.ownerDocument) == null ? void 0 : e.defaultView) || window;
1504
2006
  }
1505
- function ye(t) {
1506
- var e = _(t), n = e.pageXOffset, i = e.pageYOffset;
1507
- return {
1508
- scrollLeft: n,
1509
- scrollTop: i
1510
- };
2007
+ function H(t) {
2008
+ var e;
2009
+ return (e = (Oe(t) ? t.ownerDocument : t.document) || window.document) == null ? void 0 : e.documentElement;
1511
2010
  }
1512
- function we(t) {
1513
- return gt(Z(t)).left + ye(t).scrollLeft;
2011
+ function Oe(t) {
2012
+ return Rt() ? t instanceof Node || t instanceof A(t).Node : !1;
1514
2013
  }
1515
- function ps(t, e) {
1516
- var n = _(t), i = Z(t), s = n.visualViewport, r = i.clientWidth, a = i.clientHeight, l = 0, o = 0;
1517
- if (s) {
1518
- r = s.width, a = s.height;
1519
- var c = fn();
1520
- (c || !c && e === "fixed") && (l = s.offsetLeft, o = s.offsetTop);
1521
- }
1522
- return {
1523
- width: r,
1524
- height: a,
1525
- x: l + we(t),
1526
- y: o
1527
- };
2014
+ function P(t) {
2015
+ return Rt() ? t instanceof Element || t instanceof A(t).Element : !1;
1528
2016
  }
1529
- function gs(t) {
1530
- var e, n = Z(t), i = ye(t), s = (e = t.ownerDocument) == null ? void 0 : e.body, r = st(n.scrollWidth, n.clientWidth, s ? s.scrollWidth : 0, s ? s.clientWidth : 0), a = st(n.scrollHeight, n.clientHeight, s ? s.scrollHeight : 0, s ? s.clientHeight : 0), l = -i.scrollLeft + we(t), o = -i.scrollTop;
1531
- return G(s || n).direction === "rtl" && (l += st(n.clientWidth, s ? s.clientWidth : 0) - r), {
1532
- width: r,
1533
- height: a,
1534
- x: l,
1535
- y: o
1536
- };
2017
+ function F(t) {
2018
+ return Rt() ? t instanceof HTMLElement || t instanceof A(t).HTMLElement : !1;
1537
2019
  }
1538
- function $e(t) {
1539
- var e = G(t), n = e.overflow, i = e.overflowX, s = e.overflowY;
1540
- return /auto|scroll|overlay|hidden/.test(n + s + i);
2020
+ function te(t) {
2021
+ return !Rt() || typeof ShadowRoot > "u" ? !1 : t instanceof ShadowRoot || t instanceof A(t).ShadowRoot;
1541
2022
  }
1542
- function bn(t) {
1543
- return ["html", "body", "#document"].indexOf(z(t)) >= 0 ? t.ownerDocument.body : F(t) && $e(t) ? t : bn(Qt(t));
2023
+ function Et(t) {
2024
+ const {
2025
+ overflow: e,
2026
+ overflowX: s,
2027
+ overflowY: n,
2028
+ display: i
2029
+ } = T(t);
2030
+ return /auto|scroll|overlay|hidden|clip/.test(e + n + s) && !["inline", "contents"].includes(i);
1544
2031
  }
1545
- function Ct(t, e) {
1546
- var n;
1547
- e === void 0 && (e = []);
1548
- var i = bn(t), s = i === ((n = t.ownerDocument) == null ? void 0 : n.body), r = _(i), a = s ? [r].concat(r.visualViewport || [], $e(i) ? i : []) : i, l = e.concat(a);
1549
- return s ? l : (
1550
- // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
1551
- l.concat(Ct(Qt(a)))
1552
- );
2032
+ function Nn(t) {
2033
+ return ["table", "td", "th"].includes(ut(t));
1553
2034
  }
1554
- function oe(t) {
1555
- return Object.assign({}, t, {
1556
- left: t.x,
1557
- top: t.y,
1558
- right: t.x + t.width,
1559
- bottom: t.y + t.height
2035
+ function Pt(t) {
2036
+ return [":popover-open", ":modal"].some((e) => {
2037
+ try {
2038
+ return t.matches(e);
2039
+ } catch {
2040
+ return !1;
2041
+ }
1560
2042
  });
1561
2043
  }
1562
- function ms(t, e) {
1563
- var n = gt(t, !1, e === "fixed");
1564
- return n.top = n.top + t.clientTop, n.left = n.left + t.clientLeft, n.bottom = n.top + t.clientHeight, n.right = n.left + t.clientWidth, n.width = t.clientWidth, n.height = t.clientHeight, n.x = n.left, n.y = n.top, n;
2044
+ function Qt(t) {
2045
+ const e = Kt(), s = P(t) ? T(t) : t;
2046
+ return ["transform", "translate", "scale", "rotate", "perspective"].some((n) => s[n] ? s[n] !== "none" : !1) || (s.containerType ? s.containerType !== "normal" : !1) || !e && (s.backdropFilter ? s.backdropFilter !== "none" : !1) || !e && (s.filter ? s.filter !== "none" : !1) || ["transform", "translate", "scale", "rotate", "perspective", "filter"].some((n) => (s.willChange || "").includes(n)) || ["paint", "layout", "strict", "content"].some((n) => (s.contain || "").includes(n));
2047
+ }
2048
+ function Bn(t) {
2049
+ let e = Y(t);
2050
+ for (; F(e) && !ft(e); ) {
2051
+ if (Qt(e))
2052
+ return e;
2053
+ if (Pt(e))
2054
+ return null;
2055
+ e = Y(e);
2056
+ }
2057
+ return null;
1565
2058
  }
1566
- function Re(t, e, n) {
1567
- return e === un ? oe(ps(t, n)) : rt(e) ? ms(e, n) : oe(gs(Z(t)));
2059
+ function Kt() {
2060
+ return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
1568
2061
  }
1569
- function vs(t) {
1570
- var e = Ct(Qt(t)), n = ["absolute", "fixed"].indexOf(G(t).position) >= 0, i = n && F(t) ? Pt(t) : t;
1571
- return rt(i) ? e.filter(function(s) {
1572
- return rt(s) && pn(s, i) && z(s) !== "body";
1573
- }) : [];
2062
+ function ft(t) {
2063
+ return ["html", "body", "#document"].includes(ut(t));
1574
2064
  }
1575
- function bs(t, e, n, i) {
1576
- var s = e === "clippingParents" ? vs(t) : [].concat(e), r = [].concat(s, [n]), a = r[0], l = r.reduce(function(o, c) {
1577
- var d = Re(t, c, i);
1578
- return o.top = st(d.top, o.top), o.right = zt(d.right, o.right), o.bottom = zt(d.bottom, o.bottom), o.left = st(d.left, o.left), o;
1579
- }, Re(t, a, i));
1580
- return l.width = l.right - l.left, l.height = l.bottom - l.top, l.x = l.left, l.y = l.top, l;
2065
+ function T(t) {
2066
+ return A(t).getComputedStyle(t);
1581
2067
  }
1582
- function yn(t) {
1583
- var e = t.reference, n = t.element, i = t.placement, s = i ? J(i) : null, r = i ? mt(i) : null, a = e.x + e.width / 2 - n.width / 2, l = e.y + e.height / 2 - n.height / 2, o;
1584
- switch (s) {
1585
- case W:
1586
- o = {
1587
- x: a,
1588
- y: e.y - n.height
1589
- };
1590
- break;
1591
- case B:
1592
- o = {
1593
- x: a,
1594
- y: e.y + e.height
1595
- };
1596
- break;
1597
- case R:
1598
- o = {
1599
- x: e.x + e.width,
1600
- y: l
1601
- };
1602
- break;
1603
- case j:
1604
- o = {
1605
- x: e.x - n.width,
1606
- y: l
1607
- };
1608
- break;
1609
- default:
1610
- o = {
1611
- x: e.x,
1612
- y: e.y
1613
- };
1614
- }
1615
- var c = s ? be(s) : null;
1616
- if (c != null) {
1617
- var d = c === "y" ? "height" : "width";
1618
- switch (r) {
1619
- case ft:
1620
- o[c] = o[c] - (e[d] / 2 - n[d] / 2);
1621
- break;
1622
- case It:
1623
- o[c] = o[c] + (e[d] / 2 - n[d] / 2);
1624
- break;
1625
- }
1626
- }
1627
- return o;
2068
+ function Tt(t) {
2069
+ return P(t) ? {
2070
+ scrollLeft: t.scrollLeft,
2071
+ scrollTop: t.scrollTop
2072
+ } : {
2073
+ scrollLeft: t.scrollX,
2074
+ scrollTop: t.scrollY
2075
+ };
1628
2076
  }
1629
- function St(t, e) {
1630
- e === void 0 && (e = {});
1631
- var n = e, i = n.placement, s = i === void 0 ? t.placement : i, r = n.strategy, a = r === void 0 ? t.strategy : r, l = n.boundary, o = l === void 0 ? Ni : l, c = n.rootBoundary, d = c === void 0 ? un : c, b = n.elementContext, v = b === void 0 ? yt : b, h = n.altBoundary, $ = h === void 0 ? !1 : h, u = n.padding, w = u === void 0 ? 0 : u, E = mn(typeof w != "number" ? w : vn(w, Dt)), L = v === yt ? _i : yt, O = t.rects.popper, f = t.elements[$ ? L : v], y = bs(rt(f) ? f : f.contextElement || Z(t.elements.popper), o, d, a), x = gt(t.elements.reference), k = yn({
1632
- reference: x,
1633
- element: O,
1634
- strategy: "absolute",
1635
- placement: s
1636
- }), T = oe(Object.assign({}, O, k)), A = v === yt ? T : x, C = {
1637
- top: y.top - A.top + E.top,
1638
- bottom: A.bottom - y.bottom + E.bottom,
1639
- left: y.left - A.left + E.left,
1640
- right: A.right - y.right + E.right
1641
- }, I = t.modifiersData.offset;
1642
- if (v === yt && I) {
1643
- var H = I[s];
1644
- Object.keys(C).forEach(function(P) {
1645
- var U = [R, B].indexOf(P) >= 0 ? 1 : -1, X = [W, B].indexOf(P) >= 0 ? "y" : "x";
1646
- C[P] += H[X] * U;
1647
- });
1648
- }
1649
- return C;
2077
+ function Y(t) {
2078
+ if (ut(t) === "html")
2079
+ return t;
2080
+ const e = (
2081
+ // Step into the shadow DOM of the parent of a slotted node.
2082
+ t.assignedSlot || // DOM Element detected.
2083
+ t.parentNode || // ShadowRoot detected.
2084
+ te(t) && t.host || // Fallback.
2085
+ H(t)
2086
+ );
2087
+ return te(e) ? e.host : e;
1650
2088
  }
1651
- function ys(t, e) {
1652
- e === void 0 && (e = {});
1653
- var n = e, i = n.placement, s = n.boundary, r = n.rootBoundary, a = n.padding, l = n.flipVariations, o = n.allowedAutoPlacements, c = o === void 0 ? hn : o, d = mt(i), b = d ? l ? Ne : Ne.filter(function($) {
1654
- return mt($) === d;
1655
- }) : Dt, v = b.filter(function($) {
1656
- return c.indexOf($) >= 0;
1657
- });
1658
- v.length === 0 && (v = b);
1659
- var h = v.reduce(function($, u) {
1660
- return $[u] = St(t, {
1661
- placement: u,
1662
- boundary: s,
1663
- rootBoundary: r,
1664
- padding: a
1665
- })[J(u)], $;
1666
- }, {});
1667
- return Object.keys(h).sort(function($, u) {
1668
- return h[$] - h[u];
1669
- });
2089
+ function Le(t) {
2090
+ const e = Y(t);
2091
+ return ft(e) ? t.ownerDocument ? t.ownerDocument.body : t.body : F(e) && Et(e) ? e : Le(e);
1670
2092
  }
1671
- function ws(t) {
1672
- if (J(t) === ge)
1673
- return [];
1674
- var e = Vt(t);
1675
- return [Be(t), e, Be(e)];
1676
- }
1677
- function $s(t) {
1678
- var e = t.state, n = t.options, i = t.name;
1679
- if (!e.modifiersData[i]._skip) {
1680
- for (var s = n.mainAxis, r = s === void 0 ? !0 : s, a = n.altAxis, l = a === void 0 ? !0 : a, o = n.fallbackPlacements, c = n.padding, d = n.boundary, b = n.rootBoundary, v = n.altBoundary, h = n.flipVariations, $ = h === void 0 ? !0 : h, u = n.allowedAutoPlacements, w = e.options.placement, E = J(w), L = E === w, O = o || (L || !$ ? [Vt(w)] : ws(w)), f = [w].concat(O).reduce(function(tt, K) {
1681
- return tt.concat(J(K) === ge ? ys(e, {
1682
- placement: K,
1683
- boundary: d,
1684
- rootBoundary: b,
1685
- padding: c,
1686
- flipVariations: $,
1687
- allowedAutoPlacements: u
1688
- }) : K);
1689
- }, []), y = e.rects.reference, x = e.rects.popper, k = /* @__PURE__ */ new Map(), T = !0, A = f[0], C = 0; C < f.length; C++) {
1690
- var I = f[C], H = J(I), P = mt(I) === ft, U = [W, B].indexOf(H) >= 0, X = U ? "width" : "height", N = St(e, {
1691
- placement: I,
1692
- boundary: d,
1693
- rootBoundary: b,
1694
- altBoundary: v,
1695
- padding: c
1696
- }), V = U ? P ? R : j : P ? B : W;
1697
- y[X] > x[X] && (V = Vt(V));
1698
- var qt = Vt(V), Y = [];
1699
- if (r && Y.push(N[H] <= 0), l && Y.push(N[V] <= 0, N[qt] <= 0), Y.every(function(tt) {
1700
- return tt;
1701
- })) {
1702
- A = I, T = !1;
1703
- break;
1704
- }
1705
- k.set(I, Y);
1706
- }
1707
- if (T)
1708
- for (var Mt = $ ? 3 : 1, Zt = function(tt) {
1709
- var K = f.find(function(jt) {
1710
- var bt = k.get(jt);
1711
- if (bt)
1712
- return bt.slice(0, tt).every(function(ot) {
1713
- return ot;
1714
- });
1715
- });
1716
- if (K)
1717
- return A = K, "break";
1718
- }, vt = Mt; vt > 0; vt--) {
1719
- var Wt = Zt(vt);
1720
- if (Wt === "break")
1721
- break;
1722
- }
1723
- e.placement !== A && (e.modifiersData[i]._skip = !0, e.placement = A, e.reset = !0);
1724
- }
1725
- }
1726
- const Es = {
1727
- name: "flip",
1728
- enabled: !0,
1729
- phase: "main",
1730
- fn: $s,
1731
- requiresIfExists: ["offset"],
1732
- data: {
1733
- _skip: !1
1734
- }
1735
- };
1736
- function He(t, e, n) {
1737
- return n === void 0 && (n = {
1738
- x: 0,
1739
- y: 0
1740
- }), {
1741
- top: t.top - e.height - n.y,
1742
- right: t.right - e.width + n.x,
1743
- bottom: t.bottom - e.height + n.y,
1744
- left: t.left - e.width - n.x
2093
+ function yt(t, e, s) {
2094
+ var n;
2095
+ e === void 0 && (e = []), s === void 0 && (s = !0);
2096
+ const i = Le(t), r = i === ((n = t.ownerDocument) == null ? void 0 : n.body), o = A(i);
2097
+ if (r) {
2098
+ const l = Nt(o);
2099
+ return e.concat(o, o.visualViewport || [], Et(i) ? i : [], l && s ? yt(l) : []);
2100
+ }
2101
+ return e.concat(i, yt(i, [], s));
2102
+ }
2103
+ function Nt(t) {
2104
+ return t.parent && Object.getPrototypeOf(t.parent) ? t.frameElement : null;
2105
+ }
2106
+ function Re(t) {
2107
+ const e = T(t);
2108
+ let s = parseFloat(e.width) || 0, n = parseFloat(e.height) || 0;
2109
+ const i = F(t), r = i ? t.offsetWidth : s, o = i ? t.offsetHeight : n, l = Ct(s) !== r || Ct(n) !== o;
2110
+ return l && (s = r, n = o), {
2111
+ width: s,
2112
+ height: n,
2113
+ $: l
1745
2114
  };
1746
2115
  }
1747
- function Ve(t) {
1748
- return [W, R, B, j].some(function(e) {
1749
- return t[e] >= 0;
1750
- });
1751
- }
1752
- function xs(t) {
1753
- var e = t.state, n = t.name, i = e.rects.reference, s = e.rects.popper, r = e.modifiersData.preventOverflow, a = St(e, {
1754
- elementContext: "reference"
1755
- }), l = St(e, {
1756
- altBoundary: !0
1757
- }), o = He(a, i), c = He(l, s, r), d = Ve(o), b = Ve(c);
1758
- e.modifiersData[n] = {
1759
- referenceClippingOffsets: o,
1760
- popperEscapeOffsets: c,
1761
- isReferenceHidden: d,
1762
- hasPopperEscaped: b
1763
- }, e.attributes.popper = Object.assign({}, e.attributes.popper, {
1764
- "data-popper-reference-hidden": d,
1765
- "data-popper-escaped": b
1766
- });
2116
+ function jt(t) {
2117
+ return P(t) ? t : t.contextElement;
1767
2118
  }
1768
- const Ls = {
1769
- name: "hide",
1770
- enabled: !0,
1771
- phase: "main",
1772
- requiresIfExists: ["preventOverflow"],
1773
- fn: xs
1774
- };
1775
- function Os(t, e, n) {
1776
- var i = J(t), s = [j, W].indexOf(i) >= 0 ? -1 : 1, r = typeof n == "function" ? n(Object.assign({}, e, {
1777
- placement: t
1778
- })) : n, a = r[0], l = r[1];
1779
- return a = a || 0, l = (l || 0) * s, [j, R].indexOf(i) >= 0 ? {
1780
- x: l,
1781
- y: a
1782
- } : {
1783
- x: a,
2119
+ function st(t) {
2120
+ const e = jt(t);
2121
+ if (!F(e))
2122
+ return I(1);
2123
+ const s = e.getBoundingClientRect(), {
2124
+ width: n,
2125
+ height: i,
2126
+ $: r
2127
+ } = Re(e);
2128
+ let o = (r ? Ct(s.width) : s.width) / n, l = (r ? Ct(s.height) : s.height) / i;
2129
+ return (!o || !Number.isFinite(o)) && (o = 1), (!l || !Number.isFinite(l)) && (l = 1), {
2130
+ x: o,
1784
2131
  y: l
1785
2132
  };
1786
2133
  }
1787
- function ks(t) {
1788
- var e = t.state, n = t.options, i = t.name, s = n.offset, r = s === void 0 ? [0, 0] : s, a = hn.reduce(function(d, b) {
1789
- return d[b] = Os(b, e.rects, r), d;
1790
- }, {}), l = a[e.placement], o = l.x, c = l.y;
1791
- e.modifiersData.popperOffsets != null && (e.modifiersData.popperOffsets.x += o, e.modifiersData.popperOffsets.y += c), e.modifiersData[i] = a;
1792
- }
1793
- const Ts = {
1794
- name: "offset",
1795
- enabled: !0,
1796
- phase: "main",
1797
- requires: ["popperOffsets"],
1798
- fn: ks
1799
- };
1800
- function As(t) {
1801
- var e = t.state, n = t.name;
1802
- e.modifiersData[n] = yn({
1803
- reference: e.rects.reference,
1804
- element: e.rects.popper,
1805
- strategy: "absolute",
1806
- placement: e.placement
2134
+ const Un = /* @__PURE__ */ I(0);
2135
+ function Pe(t) {
2136
+ const e = A(t);
2137
+ return !Kt() || !e.visualViewport ? Un : {
2138
+ x: e.visualViewport.offsetLeft,
2139
+ y: e.visualViewport.offsetTop
2140
+ };
2141
+ }
2142
+ function Vn(t, e, s) {
2143
+ return e === void 0 && (e = !1), !s || e && s !== A(t) ? !1 : e;
2144
+ }
2145
+ function et(t, e, s, n) {
2146
+ e === void 0 && (e = !1), s === void 0 && (s = !1);
2147
+ const i = t.getBoundingClientRect(), r = jt(t);
2148
+ let o = I(1);
2149
+ e && (n ? P(n) && (o = st(n)) : o = st(t));
2150
+ const l = Vn(r, s, n) ? Pe(r) : I(0);
2151
+ let a = (i.left + l.x) / o.x, c = (i.top + l.y) / o.y, d = i.width / o.x, f = i.height / o.y;
2152
+ if (r) {
2153
+ const h = A(r), u = n && P(n) ? A(n) : n;
2154
+ let g = h, m = Nt(g);
2155
+ for (; m && n && u !== g; ) {
2156
+ const p = st(m), y = m.getBoundingClientRect(), w = T(m), b = y.left + (m.clientLeft + parseFloat(w.paddingLeft)) * p.x, v = y.top + (m.clientTop + parseFloat(w.paddingTop)) * p.y;
2157
+ a *= p.x, c *= p.y, d *= p.x, f *= p.y, a += b, c += v, g = A(m), m = Nt(g);
2158
+ }
2159
+ }
2160
+ return At({
2161
+ width: d,
2162
+ height: f,
2163
+ x: a,
2164
+ y: c
1807
2165
  });
1808
2166
  }
1809
- const Cs = {
1810
- name: "popperOffsets",
1811
- enabled: !0,
1812
- phase: "read",
1813
- fn: As,
1814
- data: {}
1815
- };
1816
- function Is(t) {
1817
- return t === "x" ? "y" : "x";
2167
+ function Yt(t, e) {
2168
+ const s = Tt(t).scrollLeft;
2169
+ return e ? e.left + s : et(H(t)).left + s;
1818
2170
  }
1819
- function Ss(t) {
1820
- var e = t.state, n = t.options, i = t.name, s = n.mainAxis, r = s === void 0 ? !0 : s, a = n.altAxis, l = a === void 0 ? !1 : a, o = n.boundary, c = n.rootBoundary, d = n.altBoundary, b = n.padding, v = n.tether, h = v === void 0 ? !0 : v, $ = n.tetherOffset, u = $ === void 0 ? 0 : $, w = St(e, {
1821
- boundary: o,
1822
- rootBoundary: c,
1823
- padding: b,
1824
- altBoundary: d
1825
- }), E = J(e.placement), L = mt(e.placement), O = !L, f = be(E), y = Is(f), x = e.modifiersData.popperOffsets, k = e.rects.reference, T = e.rects.popper, A = typeof u == "function" ? u(Object.assign({}, e.rects, {
1826
- placement: e.placement
1827
- })) : u, C = typeof A == "number" ? {
1828
- mainAxis: A,
1829
- altAxis: A
1830
- } : Object.assign({
1831
- mainAxis: 0,
1832
- altAxis: 0
1833
- }, A), I = e.modifiersData.offset ? e.modifiersData.offset[e.placement] : null, H = {
1834
- x: 0,
1835
- y: 0
2171
+ function Te(t, e, s) {
2172
+ s === void 0 && (s = !1);
2173
+ const n = t.getBoundingClientRect(), i = n.left + e.scrollLeft - (s ? 0 : (
2174
+ // RTL <body> scrollbar.
2175
+ Yt(t, n)
2176
+ )), r = n.top + e.scrollTop;
2177
+ return {
2178
+ x: i,
2179
+ y: r
1836
2180
  };
1837
- if (x) {
1838
- if (r) {
1839
- var P, U = f === "y" ? W : j, X = f === "y" ? B : R, N = f === "y" ? "height" : "width", V = x[f], qt = V + w[U], Y = V - w[X], Mt = h ? -T[N] / 2 : 0, Zt = L === ft ? k[N] : T[N], vt = L === ft ? -T[N] : -k[N], Wt = e.elements.arrow, tt = h && Wt ? ve(Wt) : {
1840
- width: 0,
1841
- height: 0
1842
- }, K = e.modifiersData["arrow#persistent"] ? e.modifiersData["arrow#persistent"].padding : gn(), jt = K[U], bt = K[X], ot = At(0, k[N], tt[N]), En = O ? k[N] / 2 - Mt - ot - jt - C.mainAxis : Zt - ot - jt - C.mainAxis, xn = O ? -k[N] / 2 + Mt + ot + bt + C.mainAxis : vt + ot + bt + C.mainAxis, Ut = e.elements.arrow && Pt(e.elements.arrow), Ln = Ut ? f === "y" ? Ut.clientTop || 0 : Ut.clientLeft || 0 : 0, xe = (P = I == null ? void 0 : I[f]) != null ? P : 0, On = V + En - xe - Ln, kn = V + xn - xe, Le = At(h ? zt(qt, On) : qt, V, h ? st(Y, kn) : Y);
1843
- x[f] = Le, H[f] = Le - V;
1844
- }
1845
- if (l) {
1846
- var Oe, Tn = f === "x" ? W : j, An = f === "x" ? B : R, et = x[y], Nt = y === "y" ? "height" : "width", ke = et + w[Tn], Te = et - w[An], Xt = [W, j].indexOf(E) !== -1, Ae = (Oe = I == null ? void 0 : I[y]) != null ? Oe : 0, Ce = Xt ? ke : et - k[Nt] - T[Nt] - Ae + C.altAxis, Ie = Xt ? et + k[Nt] + T[Nt] - Ae - C.altAxis : Te, Se = h && Xt ? es(Ce, et, Ie) : At(h ? Ce : ke, et, h ? Ie : Te);
1847
- x[y] = Se, H[y] = Se - et;
1848
- }
1849
- e.modifiersData[i] = H;
2181
+ }
2182
+ function _n(t) {
2183
+ let {
2184
+ elements: e,
2185
+ rect: s,
2186
+ offsetParent: n,
2187
+ strategy: i
2188
+ } = t;
2189
+ const r = i === "fixed", o = H(n), l = e ? Pt(e.floating) : !1;
2190
+ if (n === o || l && r)
2191
+ return s;
2192
+ let a = {
2193
+ scrollLeft: 0,
2194
+ scrollTop: 0
2195
+ }, c = I(1);
2196
+ const d = I(0), f = F(n);
2197
+ if ((f || !f && !r) && ((ut(n) !== "body" || Et(o)) && (a = Tt(n)), F(n))) {
2198
+ const u = et(n);
2199
+ c = st(n), d.x = u.x + n.clientLeft, d.y = u.y + n.clientTop;
1850
2200
  }
2201
+ const h = o && !f && !r ? Te(o, a, !0) : I(0);
2202
+ return {
2203
+ width: s.width * c.x,
2204
+ height: s.height * c.y,
2205
+ x: s.x * c.x - a.scrollLeft * c.x + d.x + h.x,
2206
+ y: s.y * c.y - a.scrollTop * c.y + d.y + h.y
2207
+ };
1851
2208
  }
1852
- const Ds = {
1853
- name: "preventOverflow",
1854
- enabled: !0,
1855
- phase: "main",
1856
- fn: Ss,
1857
- requiresIfExists: ["offset"]
1858
- };
1859
- function Ps(t) {
2209
+ function Wn(t) {
2210
+ return Array.from(t.getClientRects());
2211
+ }
2212
+ function zn(t) {
2213
+ const e = H(t), s = Tt(t), n = t.ownerDocument.body, i = Z(e.scrollWidth, e.clientWidth, n.scrollWidth, n.clientWidth), r = Z(e.scrollHeight, e.clientHeight, n.scrollHeight, n.clientHeight);
2214
+ let o = -s.scrollLeft + Yt(t);
2215
+ const l = -s.scrollTop;
2216
+ return T(n).direction === "rtl" && (o += Z(e.clientWidth, n.clientWidth) - i), {
2217
+ width: i,
2218
+ height: r,
2219
+ x: o,
2220
+ y: l
2221
+ };
2222
+ }
2223
+ function Qn(t, e) {
2224
+ const s = A(t), n = H(t), i = s.visualViewport;
2225
+ let r = n.clientWidth, o = n.clientHeight, l = 0, a = 0;
2226
+ if (i) {
2227
+ r = i.width, o = i.height;
2228
+ const c = Kt();
2229
+ (!c || c && e === "fixed") && (l = i.offsetLeft, a = i.offsetTop);
2230
+ }
1860
2231
  return {
1861
- scrollLeft: t.scrollLeft,
1862
- scrollTop: t.scrollTop
2232
+ width: r,
2233
+ height: o,
2234
+ x: l,
2235
+ y: a
1863
2236
  };
1864
2237
  }
1865
- function qs(t) {
1866
- return t === _(t) || !F(t) ? ye(t) : Ps(t);
2238
+ function Kn(t, e) {
2239
+ const s = et(t, !0, e === "fixed"), n = s.top + t.clientTop, i = s.left + t.clientLeft, r = F(t) ? st(t) : I(1), o = t.clientWidth * r.x, l = t.clientHeight * r.y, a = i * r.x, c = n * r.y;
2240
+ return {
2241
+ width: o,
2242
+ height: l,
2243
+ x: a,
2244
+ y: c
2245
+ };
1867
2246
  }
1868
- function Ms(t) {
1869
- var e = t.getBoundingClientRect(), n = pt(e.width) / t.offsetWidth || 1, i = pt(e.height) / t.offsetHeight || 1;
1870
- return n !== 1 || i !== 1;
2247
+ function ee(t, e, s) {
2248
+ let n;
2249
+ if (e === "viewport")
2250
+ n = Qn(t, s);
2251
+ else if (e === "document")
2252
+ n = zn(H(t));
2253
+ else if (P(e))
2254
+ n = Kn(e, s);
2255
+ else {
2256
+ const i = Pe(t);
2257
+ n = {
2258
+ x: e.x - i.x,
2259
+ y: e.y - i.y,
2260
+ width: e.width,
2261
+ height: e.height
2262
+ };
2263
+ }
2264
+ return At(n);
2265
+ }
2266
+ function Me(t, e) {
2267
+ const s = Y(t);
2268
+ return s === e || !P(s) || ft(s) ? !1 : T(s).position === "fixed" || Me(s, e);
2269
+ }
2270
+ function jn(t, e) {
2271
+ const s = e.get(t);
2272
+ if (s)
2273
+ return s;
2274
+ let n = yt(t, [], !1).filter((l) => P(l) && ut(l) !== "body"), i = null;
2275
+ const r = T(t).position === "fixed";
2276
+ let o = r ? Y(t) : t;
2277
+ for (; P(o) && !ft(o); ) {
2278
+ const l = T(o), a = Qt(o);
2279
+ !a && l.position === "fixed" && (i = null), (r ? !a && !i : !a && l.position === "static" && !!i && ["absolute", "fixed"].includes(i.position) || Et(o) && !a && Me(t, o)) ? n = n.filter((d) => d !== o) : i = l, o = Y(o);
2280
+ }
2281
+ return e.set(t, n), n;
2282
+ }
2283
+ function Yn(t) {
2284
+ let {
2285
+ element: e,
2286
+ boundary: s,
2287
+ rootBoundary: n,
2288
+ strategy: i
2289
+ } = t;
2290
+ const o = [...s === "clippingAncestors" ? Pt(e) ? [] : jn(e, this._c) : [].concat(s), n], l = o[0], a = o.reduce((c, d) => {
2291
+ const f = ee(e, d, i);
2292
+ return c.top = Z(f.top, c.top), c.right = ct(f.right, c.right), c.bottom = ct(f.bottom, c.bottom), c.left = Z(f.left, c.left), c;
2293
+ }, ee(e, l, i));
2294
+ return {
2295
+ width: a.right - a.left,
2296
+ height: a.bottom - a.top,
2297
+ x: a.left,
2298
+ y: a.top
2299
+ };
1871
2300
  }
1872
- function Ws(t, e, n) {
1873
- n === void 0 && (n = !1);
1874
- var i = F(e), s = F(e) && Ms(e), r = Z(e), a = gt(t, s, n), l = {
2301
+ function Jn(t) {
2302
+ const {
2303
+ width: e,
2304
+ height: s
2305
+ } = Re(t);
2306
+ return {
2307
+ width: e,
2308
+ height: s
2309
+ };
2310
+ }
2311
+ function Xn(t, e, s) {
2312
+ const n = F(e), i = H(e), r = s === "fixed", o = et(t, !0, r, e);
2313
+ let l = {
1875
2314
  scrollLeft: 0,
1876
2315
  scrollTop: 0
1877
- }, o = {
1878
- x: 0,
1879
- y: 0
1880
2316
  };
1881
- return (i || !i && !n) && ((z(e) !== "body" || // https://github.com/popperjs/popper-core/issues/1078
1882
- $e(r)) && (l = qs(e)), F(e) ? (o = gt(e, !0), o.x += e.clientLeft, o.y += e.clientTop) : r && (o.x = we(r))), {
1883
- x: a.left + l.scrollLeft - o.x,
1884
- y: a.top + l.scrollTop - o.y,
1885
- width: a.width,
1886
- height: a.height
2317
+ const a = I(0);
2318
+ function c() {
2319
+ a.x = Yt(i);
2320
+ }
2321
+ if (n || !n && !r)
2322
+ if ((ut(e) !== "body" || Et(i)) && (l = Tt(e)), n) {
2323
+ const u = et(e, !0, r, e);
2324
+ a.x = u.x + e.clientLeft, a.y = u.y + e.clientTop;
2325
+ } else i && c();
2326
+ r && !n && i && c();
2327
+ const d = i && !n && !r ? Te(i, l) : I(0), f = o.left + l.scrollLeft - a.x - d.x, h = o.top + l.scrollTop - a.y - d.y;
2328
+ return {
2329
+ x: f,
2330
+ y: h,
2331
+ width: o.width,
2332
+ height: o.height
1887
2333
  };
1888
2334
  }
1889
- function js(t) {
1890
- var e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), i = [];
1891
- t.forEach(function(r) {
1892
- e.set(r.name, r);
1893
- });
1894
- function s(r) {
1895
- n.add(r.name);
1896
- var a = [].concat(r.requires || [], r.requiresIfExists || []);
1897
- a.forEach(function(l) {
1898
- if (!n.has(l)) {
1899
- var o = e.get(l);
1900
- o && s(o);
1901
- }
1902
- }), i.push(r);
1903
- }
1904
- return t.forEach(function(r) {
1905
- n.has(r.name) || s(r);
1906
- }), i;
2335
+ function Dt(t) {
2336
+ return T(t).position === "static";
1907
2337
  }
1908
- function Ns(t) {
1909
- var e = js(t);
1910
- return Qi.reduce(function(n, i) {
1911
- return n.concat(e.filter(function(s) {
1912
- return s.phase === i;
1913
- }));
1914
- }, []);
2338
+ function ne(t, e) {
2339
+ if (!F(t) || T(t).position === "fixed")
2340
+ return null;
2341
+ if (e)
2342
+ return e(t);
2343
+ let s = t.offsetParent;
2344
+ return H(t) === s && (s = s.ownerDocument.body), s;
2345
+ }
2346
+ function De(t, e) {
2347
+ const s = A(t);
2348
+ if (Pt(t))
2349
+ return s;
2350
+ if (!F(t)) {
2351
+ let i = Y(t);
2352
+ for (; i && !ft(i); ) {
2353
+ if (P(i) && !Dt(i))
2354
+ return i;
2355
+ i = Y(i);
2356
+ }
2357
+ return s;
2358
+ }
2359
+ let n = ne(t, e);
2360
+ for (; n && Nn(n) && Dt(n); )
2361
+ n = ne(n, e);
2362
+ return n && ft(n) && Dt(n) && !Qt(n) ? s : n || Bn(t) || s;
1915
2363
  }
1916
- function _s(t) {
1917
- var e;
1918
- return function() {
1919
- return e || (e = new Promise(function(n) {
1920
- Promise.resolve().then(function() {
1921
- e = void 0, n(t());
1922
- });
1923
- })), e;
2364
+ const Gn = async function(t) {
2365
+ const e = this.getOffsetParent || De, s = this.getDimensions, n = await s(t.floating);
2366
+ return {
2367
+ reference: Xn(t.reference, await e(t.floating), t.strategy),
2368
+ floating: {
2369
+ x: 0,
2370
+ y: 0,
2371
+ width: n.width,
2372
+ height: n.height
2373
+ }
1924
2374
  };
1925
- }
1926
- function Fs(t) {
1927
- var e = t.reduce(function(n, i) {
1928
- var s = n[i.name];
1929
- return n[i.name] = s ? Object.assign({}, s, i, {
1930
- options: Object.assign({}, s.options, i.options),
1931
- data: Object.assign({}, s.data, i.data)
1932
- }) : i, n;
1933
- }, {});
1934
- return Object.keys(e).map(function(n) {
1935
- return e[n];
1936
- });
1937
- }
1938
- var Je = {
1939
- placement: "bottom",
1940
- modifiers: [],
1941
- strategy: "absolute"
1942
2375
  };
1943
- function ze() {
1944
- for (var t = arguments.length, e = new Array(t), n = 0; n < t; n++)
1945
- e[n] = arguments[n];
1946
- return !e.some(function(i) {
1947
- return !(i && typeof i.getBoundingClientRect == "function");
1948
- });
1949
- }
1950
- function Bs(t) {
1951
- t === void 0 && (t = {});
1952
- var e = t, n = e.defaultModifiers, i = n === void 0 ? [] : n, s = e.defaultOptions, r = s === void 0 ? Je : s;
1953
- return function(a, l, o) {
1954
- o === void 0 && (o = r);
1955
- var c = {
1956
- placement: "bottom",
1957
- orderedModifiers: [],
1958
- options: Object.assign({}, Je, r),
1959
- modifiersData: {},
1960
- elements: {
1961
- reference: a,
1962
- popper: l
1963
- },
1964
- attributes: {},
1965
- styles: {}
1966
- }, d = [], b = !1, v = {
1967
- state: c,
1968
- setOptions: function(u) {
1969
- var w = typeof u == "function" ? u(c.options) : u;
1970
- $(), c.options = Object.assign({}, r, c.options, w), c.scrollParents = {
1971
- reference: rt(a) ? Ct(a) : a.contextElement ? Ct(a.contextElement) : [],
1972
- popper: Ct(l)
1973
- };
1974
- var E = Ns(Fs([].concat(i, c.options.modifiers)));
1975
- return c.orderedModifiers = E.filter(function(L) {
1976
- return L.enabled;
1977
- }), h(), v.update();
1978
- },
1979
- // Sync update it will always be executed, even if not necessary. This
1980
- // is useful for low frequency updates where sync behavior simplifies the
1981
- // logic.
1982
- // For high frequency updates (e.g. `resize` and `scroll` events), always
1983
- // prefer the async Popper#update method
1984
- forceUpdate: function() {
1985
- if (!b) {
1986
- var u = c.elements, w = u.reference, E = u.popper;
1987
- if (ze(w, E)) {
1988
- c.rects = {
1989
- reference: Ws(w, Pt(E), c.options.strategy === "fixed"),
1990
- popper: ve(E)
1991
- }, c.reset = !1, c.placement = c.options.placement, c.orderedModifiers.forEach(function(T) {
1992
- return c.modifiersData[T.name] = Object.assign({}, T.data);
1993
- });
1994
- for (var L = 0; L < c.orderedModifiers.length; L++) {
1995
- if (c.reset === !0) {
1996
- c.reset = !1, L = -1;
1997
- continue;
1998
- }
1999
- var O = c.orderedModifiers[L], f = O.fn, y = O.options, x = y === void 0 ? {} : y, k = O.name;
2000
- typeof f == "function" && (c = f({
2001
- state: c,
2002
- options: x,
2003
- name: k,
2004
- instance: v
2005
- }) || c);
2006
- }
2007
- }
2008
- }
2009
- },
2010
- // Async and optimistically optimized update – it will not be executed if
2011
- // not necessary (debounced to run at most once-per-tick)
2012
- update: _s(function() {
2013
- return new Promise(function(u) {
2014
- v.forceUpdate(), u(c);
2015
- });
2016
- }),
2017
- destroy: function() {
2018
- $(), b = !0;
2019
- }
2376
+ function qn(t) {
2377
+ return T(t).direction === "rtl";
2378
+ }
2379
+ const Zn = {
2380
+ convertOffsetParentRelativeRectToViewportRelativeRect: _n,
2381
+ getDocumentElement: H,
2382
+ getClippingRect: Yn,
2383
+ getOffsetParent: De,
2384
+ getElementRects: Gn,
2385
+ getClientRects: Wn,
2386
+ getDimensions: Jn,
2387
+ getScale: st,
2388
+ isElement: P,
2389
+ isRTL: qn
2390
+ };
2391
+ function Ie(t, e) {
2392
+ return t.x === e.x && t.y === e.y && t.width === e.width && t.height === e.height;
2393
+ }
2394
+ function ts(t, e) {
2395
+ let s = null, n;
2396
+ const i = H(t);
2397
+ function r() {
2398
+ var l;
2399
+ clearTimeout(n), (l = s) == null || l.disconnect(), s = null;
2400
+ }
2401
+ function o(l, a) {
2402
+ l === void 0 && (l = !1), a === void 0 && (a = 1), r();
2403
+ const c = t.getBoundingClientRect(), {
2404
+ left: d,
2405
+ top: f,
2406
+ width: h,
2407
+ height: u
2408
+ } = c;
2409
+ if (l || e(), !h || !u)
2410
+ return;
2411
+ const g = St(f), m = St(i.clientWidth - (d + h)), p = St(i.clientHeight - (f + u)), y = St(d), b = {
2412
+ rootMargin: -g + "px " + -m + "px " + -p + "px " + -y + "px",
2413
+ threshold: Z(0, ct(1, a)) || 1
2020
2414
  };
2021
- if (!ze(a, l))
2022
- return v;
2023
- v.setOptions(o).then(function(u) {
2024
- !b && o.onFirstUpdate && o.onFirstUpdate(u);
2025
- });
2026
- function h() {
2027
- c.orderedModifiers.forEach(function(u) {
2028
- var w = u.name, E = u.options, L = E === void 0 ? {} : E, O = u.effect;
2029
- if (typeof O == "function") {
2030
- var f = O({
2031
- state: c,
2032
- name: w,
2033
- instance: v,
2034
- options: L
2035
- }), y = function() {
2036
- };
2037
- d.push(f || y);
2038
- }
2039
- });
2415
+ let v = !0;
2416
+ function x(k) {
2417
+ const O = k[0].intersectionRatio;
2418
+ if (O !== a) {
2419
+ if (!v)
2420
+ return o();
2421
+ O ? o(!1, O) : n = setTimeout(() => {
2422
+ o(!1, 1e-7);
2423
+ }, 1e3);
2424
+ }
2425
+ O === 1 && !Ie(c, t.getBoundingClientRect()) && o(), v = !1;
2040
2426
  }
2041
- function $() {
2042
- d.forEach(function(u) {
2043
- return u();
2044
- }), d = [];
2427
+ try {
2428
+ s = new IntersectionObserver(x, {
2429
+ ...b,
2430
+ // Handle <iframe>s
2431
+ root: i.ownerDocument
2432
+ });
2433
+ } catch {
2434
+ s = new IntersectionObserver(x, b);
2045
2435
  }
2046
- return v;
2436
+ s.observe(t);
2437
+ }
2438
+ return o(!0), r;
2439
+ }
2440
+ function es(t, e, s, n) {
2441
+ n === void 0 && (n = {});
2442
+ const {
2443
+ ancestorScroll: i = !0,
2444
+ ancestorResize: r = !0,
2445
+ elementResize: o = typeof ResizeObserver == "function",
2446
+ layoutShift: l = typeof IntersectionObserver == "function",
2447
+ animationFrame: a = !1
2448
+ } = n, c = jt(t), d = i || r ? [...c ? yt(c) : [], ...yt(e)] : [];
2449
+ d.forEach((y) => {
2450
+ i && y.addEventListener("scroll", s, {
2451
+ passive: !0
2452
+ }), r && y.addEventListener("resize", s);
2453
+ });
2454
+ const f = c && l ? ts(c, s) : null;
2455
+ let h = -1, u = null;
2456
+ o && (u = new ResizeObserver((y) => {
2457
+ let [w] = y;
2458
+ w && w.target === c && u && (u.unobserve(e), cancelAnimationFrame(h), h = requestAnimationFrame(() => {
2459
+ var b;
2460
+ (b = u) == null || b.observe(e);
2461
+ })), s();
2462
+ }), c && !a && u.observe(c), u.observe(e));
2463
+ let g, m = a ? et(t) : null;
2464
+ a && p();
2465
+ function p() {
2466
+ const y = et(t);
2467
+ m && !Ie(m, y) && s(), m = y, g = requestAnimationFrame(p);
2468
+ }
2469
+ return s(), () => {
2470
+ var y;
2471
+ d.forEach((w) => {
2472
+ i && w.removeEventListener("scroll", s), r && w.removeEventListener("resize", s);
2473
+ }), f == null || f(), (y = u) == null || y.disconnect(), u = null, a && cancelAnimationFrame(g);
2047
2474
  };
2048
2475
  }
2049
- var Rs = [us, Cs, cs, Xi, Ts, Es, Ds, rs, Ls], Hs = /* @__PURE__ */ Bs({
2050
- defaultModifiers: Rs
2051
- });
2052
- async function ae(t) {
2053
- if (!t)
2054
- return this.collection;
2055
- const e = this.collection.findIndex((n) => n.id === t.id);
2056
- if (e >= 0) {
2057
- const n = this.collection[e];
2058
- n.state === "opened" && n.close(), n.popper.destroy(), wn(n), Object.getOwnPropertyNames(n).forEach((i) => {
2059
- delete n[i];
2060
- }), this.collection.splice(e, 1);
2061
- }
2062
- return this.collection;
2063
- }
2064
- function wn(t) {
2065
- return t.__eventListeners && (t.__eventListeners.forEach((e) => {
2066
- e.el.forEach((n) => {
2067
- e.type.forEach((i) => {
2068
- t[n].removeEventListener(i, e.listener, !1);
2069
- });
2070
- });
2071
- }), delete t.__eventListeners), t;
2072
- }
2073
- async function Ee(t) {
2074
- const e = on.call(this, t);
2075
- return e.el.classList.add(this.settings.stateActive), e.trigger.hasAttribute("aria-controls") && e.trigger.setAttribute("aria-expanded", "true"), e.config = rn(e.el, this.settings), e.popper.setOptions({
2076
- placement: e.config.placement,
2077
- modifiers: [
2078
- { name: "eventListeners", enabled: !0 },
2079
- ...qi(e.config)
2080
- ]
2081
- }), e.popper.update(), e.state = "opened", e;
2082
- }
2083
- async function Vs(t, e) {
2084
- ae.call(this, t);
2085
- const n = this, i = {
2086
- open() {
2087
- return Ee.call(n, this);
2088
- },
2089
- close() {
2090
- return pe.call(n, this);
2091
- },
2092
- deregister() {
2093
- return ae.call(n, this);
2094
- }
2095
- }, s = {
2096
- id: t.id,
2097
- state: "closed",
2098
- el: t,
2099
- trigger: e,
2100
- popper: Hs(e, t),
2101
- config: rn(t, this.settings),
2102
- ...i
2476
+ const ns = In, ss = Fn, is = Mn, os = Tn, rs = Hn, ls = (t, e, s) => {
2477
+ const n = /* @__PURE__ */ new Map(), i = {
2478
+ platform: Zn,
2479
+ ...s
2480
+ }, r = {
2481
+ ...i.platform,
2482
+ _c: n
2103
2483
  };
2104
- return s.trigger.hasAttribute("aria-controls") && s.trigger.setAttribute("aria-expanded", "false"), $n.call(this, s), this.collection.push(s), s.el.classList.contains(this.settings.stateActive) && (await s.open(), dn.call(this, s)), s;
2105
- }
2106
- function $n(t) {
2107
- return t.__eventListeners || (t.config.event === "hover" ? (t.__eventListeners = [{
2108
- el: ["trigger"],
2109
- type: ["mouseenter", "focus"],
2110
- listener: Ee.bind(this, t)
2111
- }, {
2112
- el: ["el", "trigger"],
2113
- type: ["mouseleave", "focusout"],
2114
- listener: cn.bind(this, t)
2115
- }], t.__eventListeners.forEach((e) => {
2116
- e.el.forEach((n) => {
2117
- e.type.forEach((i) => {
2118
- t[n].addEventListener(i, e.listener, !1);
2119
- });
2120
- });
2121
- })) : (t.__eventListeners = [{
2122
- el: ["trigger"],
2123
- type: ["click"],
2124
- listener: Wi.bind(this, t)
2125
- }], t.__eventListeners.forEach((e) => {
2126
- e.el.forEach((n) => {
2127
- e.type.forEach((i) => {
2128
- t[n].addEventListener(i, e.listener, !1);
2129
- });
2484
+ return Pn(t, e, {
2485
+ ...i,
2486
+ platform: r
2487
+ });
2488
+ };
2489
+ async function as(t) {
2490
+ const e = Ee.call(this, t);
2491
+ e.el.inert = !1, e.el.classList.add(this.settings.stateActive), e.isTooltip || e.trigger.setAttribute("aria-expanded", "true"), e.buildCustomProps();
2492
+ const s = pn(e), n = e.el.querySelector(s.arrow.element);
2493
+ return s.arrow.element = n || void 0, e.floatingCleanup = es(e.trigger, e.el, () => {
2494
+ ls(e.trigger, e.el, {
2495
+ placement: e.getSetting("placement"),
2496
+ middleware: [
2497
+ is(s.flip),
2498
+ ss({ ...s.shift, limiter: rs() }),
2499
+ ns(s.offset),
2500
+ os(s.arrow)
2501
+ ]
2502
+ }).then(({ x: i, y: r, placement: o, middlewareData: l }) => {
2503
+ if (e.el) {
2504
+ if (qt(e.el, i, r), s.arrow.element && l.arrow) {
2505
+ const { x: a, y: c } = l.arrow;
2506
+ qt(s.arrow.element, a, c);
2507
+ }
2508
+ e.el.setAttribute("data-floating-placement", o);
2509
+ }
2130
2510
  });
2131
- }))), t;
2511
+ }), e.state = "opened", e.getSetting("event") === "click" && En.call(this, e), e.el.dispatchEvent(
2512
+ new CustomEvent(e.getSetting("customEventPrefix") + "opened", {
2513
+ detail: this,
2514
+ bubbles: !0
2515
+ })
2516
+ ), await e.parent.emit("opened", e), e;
2132
2517
  }
2133
- var Tt;
2134
- class nr extends Si {
2135
- constructor(e) {
2136
- super(), Ci(this, Tt, void 0), this.defaults = Pi, this.settings = { ...this.defaults, ...e }, this.trigger = null, Ii(this, Tt, ji.bind(this)), this.settings.autoInit && this.init();
2518
+ var at;
2519
+ class hs extends Ot {
2520
+ constructor(s = {}) {
2521
+ super({ ...mn, ...s });
2522
+ U(this, at);
2523
+ this.module = "Popover", this.entryClass = Sn, this.trigger = null, S(this, at, vn.bind(this));
2137
2524
  }
2138
- async init(e) {
2139
- e && (this.settings = { ...this.settings, ...e });
2140
- const n = document.querySelectorAll(this.settings.selectorPopover);
2141
- return await this.registerCollection(n), this.settings.eventListeners && this.initEventListeners(!1), this;
2142
- }
2143
- async destroy() {
2144
- return this.trigger = null, await this.deregisterCollection(), this.settings.eventListeners && this.destroyEventListeners(!1), this;
2525
+ get active() {
2526
+ return this.get("opened", "state");
2145
2527
  }
2146
- initEventListeners(e = !0) {
2147
- e && this.collection.forEach((n) => {
2148
- $n.call(this, n);
2149
- }), document.addEventListener("keydown", je(this, Tt), !1);
2528
+ get activeHover() {
2529
+ return this.collection.find((s) => s.state == "opened" && s.getSetting("event") == "hover");
2150
2530
  }
2151
- destroyEventListeners(e = !0) {
2152
- e && this.collection.forEach((n) => {
2153
- wn(n);
2154
- }), document.removeEventListener("keydown", je(this, Tt), !1);
2531
+ async open(s) {
2532
+ return as.call(this, s);
2155
2533
  }
2156
- register(e) {
2157
- const n = Mi.call(this, e);
2158
- return n.error ? Promise.reject(n.error) : Vs.call(this, n.popover, n.trigger);
2534
+ async close(s) {
2535
+ return Se.call(this, s);
2159
2536
  }
2160
- deregister(e) {
2161
- const n = this.get(an.call(this, e));
2162
- return ae.call(this, n);
2537
+ async afterMount() {
2538
+ document.addEventListener("keydown", E(this, at), !1);
2163
2539
  }
2164
- open(e) {
2165
- return Ee.call(this, e);
2540
+ async beforeUnmount() {
2541
+ this.trigger = null;
2166
2542
  }
2167
- close(e) {
2168
- return pe.call(this, e);
2543
+ async afterUnmount() {
2544
+ document.removeEventListener("keydown", E(this, at), !1);
2169
2545
  }
2170
2546
  }
2171
- Tt = /* @__PURE__ */ new WeakMap();
2547
+ at = new WeakMap();
2172
2548
  export {
2173
- Xs as Drawer,
2174
- er as Modal,
2175
- nr as Popover,
2176
- Gs as core
2549
+ us as Drawer,
2550
+ ds as Modal,
2551
+ hs as Popover,
2552
+ fs as core
2177
2553
  };
2178
2554
  //# sourceMappingURL=index.js.map