wj-elements 0.0.3 → 0.0.5

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.
Files changed (66) hide show
  1. package/dist/router-links-e0087f84.js +146 -0
  2. package/dist/style.css +2 -2365
  3. package/dist/wj-aside.js +18 -22
  4. package/dist/wj-avatar.js +32 -49
  5. package/dist/wj-badge.js +18 -22
  6. package/dist/wj-breadcrumb.js +53 -103
  7. package/dist/wj-breadcrumbs.js +21 -36
  8. package/dist/wj-button-group.js +24 -36
  9. package/dist/wj-button.js +37 -80
  10. package/dist/wj-card-content.js +16 -18
  11. package/dist/wj-card-controls.js +16 -18
  12. package/dist/wj-card-header.js +16 -20
  13. package/dist/wj-card-subtitle.js +17 -19
  14. package/dist/wj-card-title.js +16 -18
  15. package/dist/wj-card.js +16 -20
  16. package/dist/wj-checkbox.js +24 -46
  17. package/dist/wj-chip.js +21 -39
  18. package/dist/wj-col.js +18 -32
  19. package/dist/wj-color-picker.js +503 -868
  20. package/dist/wj-container.js +18 -20
  21. package/dist/wj-copy-button.js +66 -112
  22. package/dist/wj-dialog.js +43 -67
  23. package/dist/wj-divider.js +16 -20
  24. package/dist/wj-dropdown.js +22 -31
  25. package/dist/wj-element.js +241 -416
  26. package/dist/wj-footer.js +16 -18
  27. package/dist/wj-form.js +16 -18
  28. package/dist/wj-grid.js +17 -21
  29. package/dist/wj-header.js +18 -22
  30. package/dist/wj-icon-picker.js +66 -107
  31. package/dist/wj-icon.js +67 -142
  32. package/dist/wj-img-comparer.js +43 -72
  33. package/dist/wj-img.js +21 -31
  34. package/dist/wj-infinite-scroll.js +49 -84
  35. package/dist/wj-input.js +67 -146
  36. package/dist/wj-item.js +19 -34
  37. package/dist/wj-label.js +19 -21
  38. package/dist/wj-list.js +17 -20
  39. package/dist/wj-main.js +16 -18
  40. package/dist/wj-master.js +331 -462
  41. package/dist/wj-menu-button.js +18 -21
  42. package/dist/wj-menu-item.js +67 -144
  43. package/dist/wj-menu-label.js +17 -21
  44. package/dist/wj-menu.js +20 -24
  45. package/dist/wj-popup.js +714 -1140
  46. package/dist/wj-progress-bar.js +42 -100
  47. package/dist/wj-radio-group.js +27 -38
  48. package/dist/wj-radio.js +24 -46
  49. package/dist/wj-route.js +8 -11
  50. package/dist/wj-router-link.js +19 -22
  51. package/dist/wj-router-outlet.js +71 -135
  52. package/dist/wj-routerx.js +641 -1121
  53. package/dist/wj-row.js +20 -22
  54. package/dist/wj-slider.js +55 -97
  55. package/dist/wj-split-view.js +45 -81
  56. package/dist/wj-store.js +110 -195
  57. package/dist/wj-textarea.js +39 -86
  58. package/dist/wj-thumbnail.js +17 -19
  59. package/dist/wj-toast.js +34 -88
  60. package/dist/wj-toggle.js +24 -42
  61. package/dist/wj-toolbar-action.js +16 -27
  62. package/dist/wj-toolbar.js +21 -26
  63. package/dist/wj-tooltip.js +27 -41
  64. package/dist/wj-visually-hidden.js +16 -18
  65. package/package.json +1 -1
  66. package/dist/router-links-26e4a166.js +0 -204
package/dist/wj-popup.js CHANGED
@@ -1,1278 +1,902 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
7
- import WJElement, { event } from "./wj-element.js";
1
+ var Ot = Object.defineProperty;
2
+ var Lt = (t, e, n) => e in t ? Ot(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var ut = (t, e, n) => (Lt(t, typeof e != "symbol" ? e + "" : e, n), n);
4
+ import Tt, { event as G } from "./wj-element.js";
8
5
  import "./wj-store.js";
9
- const min = Math.min;
10
- const max = Math.max;
11
- const round = Math.round;
12
- const floor = Math.floor;
13
- const createCoords = (v) => ({
14
- x: v,
15
- y: v
16
- });
17
- const oppositeSideMap = {
6
+ const N = Math.min, R = Math.max, Z = Math.round, Q = Math.floor, B = (t) => ({
7
+ x: t,
8
+ y: t
9
+ }), Pt = {
18
10
  left: "right",
19
11
  right: "left",
20
12
  bottom: "top",
21
13
  top: "bottom"
22
- };
23
- const oppositeAlignmentMap = {
14
+ }, St = {
24
15
  start: "end",
25
16
  end: "start"
26
17
  };
27
- function clamp(start, value, end) {
28
- return max(start, min(value, end));
18
+ function Dt(t, e, n) {
19
+ return R(t, N(e, n));
29
20
  }
30
- function evaluate(value, param) {
31
- return typeof value === "function" ? value(param) : value;
21
+ function U(t, e) {
22
+ return typeof t == "function" ? t(e) : t;
32
23
  }
33
- function getSide(placement) {
34
- return placement.split("-")[0];
24
+ function j(t) {
25
+ return t.split("-")[0];
35
26
  }
36
- function getAlignment(placement) {
37
- return placement.split("-")[1];
27
+ function _(t) {
28
+ return t.split("-")[1];
38
29
  }
39
- function getOppositeAxis(axis) {
40
- return axis === "x" ? "y" : "x";
30
+ function kt(t) {
31
+ return t === "x" ? "y" : "x";
41
32
  }
42
- function getAxisLength(axis) {
43
- return axis === "y" ? "height" : "width";
33
+ function rt(t) {
34
+ return t === "y" ? "height" : "width";
44
35
  }
45
- function getSideAxis(placement) {
46
- return ["top", "bottom"].includes(getSide(placement)) ? "y" : "x";
36
+ function nt(t) {
37
+ return ["top", "bottom"].includes(j(t)) ? "y" : "x";
47
38
  }
48
- function getAlignmentAxis(placement) {
49
- return getOppositeAxis(getSideAxis(placement));
39
+ function ct(t) {
40
+ return kt(nt(t));
50
41
  }
51
- function getAlignmentSides(placement, rects, rtl) {
52
- if (rtl === void 0) {
53
- rtl = false;
54
- }
55
- const alignment = getAlignment(placement);
56
- const alignmentAxis = getAlignmentAxis(placement);
57
- const length = getAxisLength(alignmentAxis);
58
- let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
59
- if (rects.reference[length] > rects.floating[length]) {
60
- mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
61
- }
62
- return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
42
+ function Wt(t, e, n) {
43
+ n === void 0 && (n = !1);
44
+ const o = _(t), i = ct(t), s = rt(i);
45
+ let r = i === "x" ? o === (n ? "end" : "start") ? "right" : "left" : o === "start" ? "bottom" : "top";
46
+ return e.reference[s] > e.floating[s] && (r = tt(r)), [r, tt(r)];
63
47
  }
64
- function getExpandedPlacements(placement) {
65
- const oppositePlacement = getOppositePlacement(placement);
66
- return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
48
+ function Mt(t) {
49
+ const e = tt(t);
50
+ return [st(t), e, st(e)];
67
51
  }
68
- function getOppositeAlignmentPlacement(placement) {
69
- return placement.replace(/start|end/g, (alignment) => oppositeAlignmentMap[alignment]);
52
+ function st(t) {
53
+ return t.replace(/start|end/g, (e) => St[e]);
70
54
  }
71
- function getSideList(side, isStart, rtl) {
72
- const lr = ["left", "right"];
73
- const rl = ["right", "left"];
74
- const tb = ["top", "bottom"];
75
- const bt = ["bottom", "top"];
76
- switch (side) {
55
+ function Ft(t, e, n) {
56
+ const o = ["left", "right"], i = ["right", "left"], s = ["top", "bottom"], r = ["bottom", "top"];
57
+ switch (t) {
77
58
  case "top":
78
59
  case "bottom":
79
- if (rtl)
80
- return isStart ? rl : lr;
81
- return isStart ? lr : rl;
60
+ return n ? e ? i : o : e ? o : i;
82
61
  case "left":
83
62
  case "right":
84
- return isStart ? tb : bt;
63
+ return e ? s : r;
85
64
  default:
86
65
  return [];
87
66
  }
88
67
  }
89
- function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
90
- const alignment = getAlignment(placement);
91
- let list = getSideList(getSide(placement), direction === "start", rtl);
92
- if (alignment) {
93
- list = list.map((side) => side + "-" + alignment);
94
- if (flipAlignment) {
95
- list = list.concat(list.map(getOppositeAlignmentPlacement));
96
- }
97
- }
98
- return list;
68
+ function Ht(t, e, n, o) {
69
+ const i = _(t);
70
+ let s = Ft(j(t), n === "start", o);
71
+ return i && (s = s.map((r) => r + "-" + i), e && (s = s.concat(s.map(st)))), s;
99
72
  }
100
- function getOppositePlacement(placement) {
101
- return placement.replace(/left|right|bottom|top/g, (side) => oppositeSideMap[side]);
73
+ function tt(t) {
74
+ return t.replace(/left|right|bottom|top/g, (e) => Pt[e]);
102
75
  }
103
- function expandPaddingObject(padding) {
76
+ function Nt(t) {
104
77
  return {
105
78
  top: 0,
106
79
  right: 0,
107
80
  bottom: 0,
108
81
  left: 0,
109
- ...padding
82
+ ...t
110
83
  };
111
84
  }
112
- function getPaddingObject(padding) {
113
- return typeof padding !== "number" ? expandPaddingObject(padding) : {
114
- top: padding,
115
- right: padding,
116
- bottom: padding,
117
- left: padding
85
+ function gt(t) {
86
+ return typeof t != "number" ? Nt(t) : {
87
+ top: t,
88
+ right: t,
89
+ bottom: t,
90
+ left: t
118
91
  };
119
92
  }
120
- function rectToClientRect(rect) {
93
+ function et(t) {
121
94
  return {
122
- ...rect,
123
- top: rect.y,
124
- left: rect.x,
125
- right: rect.x + rect.width,
126
- bottom: rect.y + rect.height
95
+ ...t,
96
+ top: t.y,
97
+ left: t.x,
98
+ right: t.x + t.width,
99
+ bottom: t.y + t.height
127
100
  };
128
101
  }
129
- function computeCoordsFromPlacement(_ref, placement, rtl) {
102
+ function ht(t, e, n) {
130
103
  let {
131
- reference,
132
- floating
133
- } = _ref;
134
- const sideAxis = getSideAxis(placement);
135
- const alignmentAxis = getAlignmentAxis(placement);
136
- const alignLength = getAxisLength(alignmentAxis);
137
- const side = getSide(placement);
138
- const isVertical = sideAxis === "y";
139
- const commonX = reference.x + reference.width / 2 - floating.width / 2;
140
- const commonY = reference.y + reference.height / 2 - floating.height / 2;
141
- const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
142
- let coords;
143
- switch (side) {
104
+ reference: o,
105
+ floating: i
106
+ } = t;
107
+ const s = nt(e), r = ct(e), l = rt(r), c = j(e), a = s === "y", d = o.x + o.width / 2 - i.width / 2, u = o.y + o.height / 2 - i.height / 2, p = o[l] / 2 - i[l] / 2;
108
+ let f;
109
+ switch (c) {
144
110
  case "top":
145
- coords = {
146
- x: commonX,
147
- y: reference.y - floating.height
111
+ f = {
112
+ x: d,
113
+ y: o.y - i.height
148
114
  };
149
115
  break;
150
116
  case "bottom":
151
- coords = {
152
- x: commonX,
153
- y: reference.y + reference.height
117
+ f = {
118
+ x: d,
119
+ y: o.y + o.height
154
120
  };
155
121
  break;
156
122
  case "right":
157
- coords = {
158
- x: reference.x + reference.width,
159
- y: commonY
123
+ f = {
124
+ x: o.x + o.width,
125
+ y: u
160
126
  };
161
127
  break;
162
128
  case "left":
163
- coords = {
164
- x: reference.x - floating.width,
165
- y: commonY
129
+ f = {
130
+ x: o.x - i.width,
131
+ y: u
166
132
  };
167
133
  break;
168
134
  default:
169
- coords = {
170
- x: reference.x,
171
- y: reference.y
135
+ f = {
136
+ x: o.x,
137
+ y: o.y
172
138
  };
173
139
  }
174
- switch (getAlignment(placement)) {
140
+ switch (_(e)) {
175
141
  case "start":
176
- coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
142
+ f[r] -= p * (n && a ? -1 : 1);
177
143
  break;
178
144
  case "end":
179
- coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
145
+ f[r] += p * (n && a ? -1 : 1);
180
146
  break;
181
147
  }
182
- return coords;
148
+ return f;
183
149
  }
184
- const computePosition$1 = async (reference, floating, config) => {
150
+ const Bt = async (t, e, n) => {
185
151
  const {
186
- placement = "bottom",
187
- strategy = "absolute",
188
- middleware = [],
189
- platform: platform2
190
- } = config;
191
- const validMiddleware = middleware.filter(Boolean);
192
- const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
193
- let rects = await platform2.getElementRects({
194
- reference,
195
- floating,
196
- strategy
197
- });
198
- let {
199
- x,
200
- y
201
- } = computeCoordsFromPlacement(rects, placement, rtl);
202
- let statefulPlacement = placement;
203
- let middlewareData = {};
204
- let resetCount = 0;
205
- for (let i = 0; i < validMiddleware.length; i++) {
206
- const {
207
- name,
208
- fn
209
- } = validMiddleware[i];
152
+ placement: o = "bottom",
153
+ strategy: i = "absolute",
154
+ middleware: s = [],
155
+ platform: r
156
+ } = n, l = s.filter(Boolean), c = await (r.isRTL == null ? void 0 : r.isRTL(e));
157
+ let a = await r.getElementRects({
158
+ reference: t,
159
+ floating: e,
160
+ strategy: i
161
+ }), {
162
+ x: d,
163
+ y: u
164
+ } = ht(a, o, c), p = o, f = {}, h = 0;
165
+ for (let m = 0; m < l.length; m++) {
210
166
  const {
211
- x: nextX,
212
- y: nextY,
213
- data,
214
- reset
215
- } = await fn({
216
- x,
167
+ name: w,
168
+ fn: g
169
+ } = l[m], {
170
+ x: v,
217
171
  y,
218
- initialPlacement: placement,
219
- placement: statefulPlacement,
220
- strategy,
221
- middlewareData,
222
- rects,
223
- platform: platform2,
172
+ data: A,
173
+ reset: x
174
+ } = await g({
175
+ x: d,
176
+ y: u,
177
+ initialPlacement: o,
178
+ placement: p,
179
+ strategy: i,
180
+ middlewareData: f,
181
+ rects: a,
182
+ platform: r,
224
183
  elements: {
225
- reference,
226
- floating
184
+ reference: t,
185
+ floating: e
227
186
  }
228
187
  });
229
- x = nextX != null ? nextX : x;
230
- y = nextY != null ? nextY : y;
231
- middlewareData = {
232
- ...middlewareData,
233
- [name]: {
234
- ...middlewareData[name],
235
- ...data
188
+ if (d = v ?? d, u = y ?? u, f = {
189
+ ...f,
190
+ [w]: {
191
+ ...f[w],
192
+ ...A
236
193
  }
237
- };
238
- if (reset && resetCount <= 50) {
239
- resetCount++;
240
- if (typeof reset === "object") {
241
- if (reset.placement) {
242
- statefulPlacement = reset.placement;
243
- }
244
- if (reset.rects) {
245
- rects = reset.rects === true ? await platform2.getElementRects({
246
- reference,
247
- floating,
248
- strategy
249
- }) : reset.rects;
250
- }
251
- ({
252
- x,
253
- y
254
- } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
255
- }
256
- i = -1;
194
+ }, x && h <= 50) {
195
+ h++, typeof x == "object" && (x.placement && (p = x.placement), x.rects && (a = x.rects === !0 ? await r.getElementRects({
196
+ reference: t,
197
+ floating: e,
198
+ strategy: i
199
+ }) : x.rects), {
200
+ x: d,
201
+ y: u
202
+ } = ht(a, p, c)), m = -1;
257
203
  continue;
258
204
  }
259
205
  }
260
206
  return {
261
- x,
262
- y,
263
- placement: statefulPlacement,
264
- strategy,
265
- middlewareData
207
+ x: d,
208
+ y: u,
209
+ placement: p,
210
+ strategy: i,
211
+ middlewareData: f
266
212
  };
267
213
  };
268
- async function detectOverflow(state, options) {
269
- var _await$platform$isEle;
270
- if (options === void 0) {
271
- options = {};
272
- }
214
+ async function wt(t, e) {
215
+ var n;
216
+ e === void 0 && (e = {});
273
217
  const {
274
- x,
275
- y,
276
- platform: platform2,
277
- rects,
278
- elements,
279
- strategy
280
- } = state;
281
- const {
282
- boundary = "clippingAncestors",
283
- rootBoundary = "viewport",
284
- elementContext = "floating",
285
- altBoundary = false,
286
- padding = 0
287
- } = evaluate(options, state);
288
- const paddingObject = getPaddingObject(padding);
289
- const altContext = elementContext === "floating" ? "reference" : "floating";
290
- const element = elements[altBoundary ? altContext : elementContext];
291
- const clippingClientRect = rectToClientRect(await platform2.getClippingRect({
292
- element: ((_await$platform$isEle = await (platform2.isElement == null ? void 0 : platform2.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform2.getDocumentElement == null ? void 0 : platform2.getDocumentElement(elements.floating)),
293
- boundary,
294
- rootBoundary,
295
- strategy
296
- }));
297
- const rect = elementContext === "floating" ? {
298
- ...rects.floating,
299
- x,
300
- y
301
- } : rects.reference;
302
- const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
303
- const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
218
+ x: o,
219
+ y: i,
220
+ platform: s,
221
+ rects: r,
222
+ elements: l,
223
+ strategy: c
224
+ } = t, {
225
+ boundary: a = "clippingAncestors",
226
+ rootBoundary: d = "viewport",
227
+ elementContext: u = "floating",
228
+ altBoundary: p = !1,
229
+ padding: f = 0
230
+ } = U(e, t), h = gt(f), w = l[p ? u === "floating" ? "reference" : "floating" : u], g = et(await s.getClippingRect({
231
+ element: (n = await (s.isElement == null ? void 0 : s.isElement(w))) == null || n ? w : w.contextElement || await (s.getDocumentElement == null ? void 0 : s.getDocumentElement(l.floating)),
232
+ boundary: a,
233
+ rootBoundary: d,
234
+ strategy: c
235
+ })), v = u === "floating" ? {
236
+ ...r.floating,
237
+ x: o,
238
+ y: i
239
+ } : r.reference, y = await (s.getOffsetParent == null ? void 0 : s.getOffsetParent(l.floating)), A = await (s.isElement == null ? void 0 : s.isElement(y)) ? await (s.getScale == null ? void 0 : s.getScale(y)) || {
304
240
  x: 1,
305
241
  y: 1
306
242
  } : {
307
243
  x: 1,
308
244
  y: 1
309
- };
310
- const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
311
- rect,
312
- offsetParent,
313
- strategy
314
- }) : rect);
245
+ }, x = et(s.convertOffsetParentRelativeRectToViewportRelativeRect ? await s.convertOffsetParentRelativeRectToViewportRelativeRect({
246
+ rect: v,
247
+ offsetParent: y,
248
+ strategy: c
249
+ }) : v);
315
250
  return {
316
- top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
317
- bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
318
- left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
319
- right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
251
+ top: (g.top - x.top + h.top) / A.y,
252
+ bottom: (x.bottom - g.bottom + h.bottom) / A.y,
253
+ left: (g.left - x.left + h.left) / A.x,
254
+ right: (x.right - g.right + h.right) / A.x
320
255
  };
321
256
  }
322
- const arrow = (options) => ({
257
+ const Vt = (t) => ({
323
258
  name: "arrow",
324
- options,
325
- async fn(state) {
326
- const {
327
- x,
328
- y,
329
- placement,
330
- rects,
331
- platform: platform2,
332
- elements,
333
- middlewareData
334
- } = state;
259
+ options: t,
260
+ async fn(e) {
335
261
  const {
336
- element,
337
- padding = 0
338
- } = evaluate(options, state) || {};
339
- if (element == null) {
262
+ x: n,
263
+ y: o,
264
+ placement: i,
265
+ rects: s,
266
+ platform: r,
267
+ elements: l,
268
+ middlewareData: c
269
+ } = e, {
270
+ element: a,
271
+ padding: d = 0
272
+ } = U(t, e) || {};
273
+ if (a == null)
340
274
  return {};
341
- }
342
- const paddingObject = getPaddingObject(padding);
343
- const coords = {
344
- x,
345
- y
346
- };
347
- const axis = getAlignmentAxis(placement);
348
- const length = getAxisLength(axis);
349
- const arrowDimensions = await platform2.getDimensions(element);
350
- const isYAxis = axis === "y";
351
- const minProp = isYAxis ? "top" : "left";
352
- const maxProp = isYAxis ? "bottom" : "right";
353
- const clientProp = isYAxis ? "clientHeight" : "clientWidth";
354
- const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
355
- const startDiff = coords[axis] - rects.reference[axis];
356
- const arrowOffsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(element));
357
- let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
358
- if (!clientSize || !await (platform2.isElement == null ? void 0 : platform2.isElement(arrowOffsetParent))) {
359
- clientSize = elements.floating[clientProp] || rects.floating[length];
360
- }
361
- const centerToReference = endDiff / 2 - startDiff / 2;
362
- const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
363
- const minPadding = min(paddingObject[minProp], largestPossiblePadding);
364
- const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
365
- const min$1 = minPadding;
366
- const max2 = clientSize - arrowDimensions[length] - maxPadding;
367
- const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
368
- const offset2 = clamp(min$1, center, max2);
369
- const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center != offset2 && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
370
- const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max2 : 0;
275
+ const u = gt(d), p = {
276
+ x: n,
277
+ y: o
278
+ }, f = ct(i), h = rt(f), m = await r.getDimensions(a), w = f === "y", g = w ? "top" : "left", v = w ? "bottom" : "right", y = w ? "clientHeight" : "clientWidth", A = s.reference[h] + s.reference[f] - p[f] - s.floating[h], x = p[f] - s.reference[f], b = await (r.getOffsetParent == null ? void 0 : r.getOffsetParent(a));
279
+ let E = b ? b[y] : 0;
280
+ (!E || !await (r.isElement == null ? void 0 : r.isElement(b))) && (E = l.floating[y] || s.floating[h]);
281
+ const P = A / 2 - x / 2, H = E / 2 - m[h] / 2 - 1, Y = N(u[g], H), X = N(u[v], H), L = Y, q = E - m[h] - X, C = E / 2 - m[h] / 2 + P, S = Dt(L, C, q), D = !c.arrow && _(i) != null && C != S && s.reference[h] / 2 - (C < L ? Y : X) - m[h] / 2 < 0, W = D ? C < L ? C - L : C - q : 0;
371
282
  return {
372
- [axis]: coords[axis] + alignmentOffset,
283
+ [f]: p[f] + W,
373
284
  data: {
374
- [axis]: offset2,
375
- centerOffset: center - offset2 - alignmentOffset,
376
- ...shouldAddOffset && {
377
- alignmentOffset
285
+ [f]: S,
286
+ centerOffset: C - S - W,
287
+ ...D && {
288
+ alignmentOffset: W
378
289
  }
379
290
  },
380
- reset: shouldAddOffset
291
+ reset: D
381
292
  };
382
293
  }
383
- });
384
- const flip = function(options) {
385
- if (options === void 0) {
386
- options = {};
387
- }
388
- return {
294
+ }), jt = function(t) {
295
+ return t === void 0 && (t = {}), {
389
296
  name: "flip",
390
- options,
391
- async fn(state) {
392
- var _middlewareData$arrow, _middlewareData$flip;
297
+ options: t,
298
+ async fn(e) {
299
+ var n, o;
393
300
  const {
394
- placement,
395
- middlewareData,
396
- rects,
397
- initialPlacement,
398
- platform: platform2,
399
- elements
400
- } = state;
401
- const {
402
- mainAxis: checkMainAxis = true,
403
- crossAxis: checkCrossAxis = true,
404
- fallbackPlacements: specifiedFallbackPlacements,
405
- fallbackStrategy = "bestFit",
406
- fallbackAxisSideDirection = "none",
407
- flipAlignment = true,
408
- ...detectOverflowOptions
409
- } = evaluate(options, state);
410
- if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
301
+ placement: i,
302
+ middlewareData: s,
303
+ rects: r,
304
+ initialPlacement: l,
305
+ platform: c,
306
+ elements: a
307
+ } = e, {
308
+ mainAxis: d = !0,
309
+ crossAxis: u = !0,
310
+ fallbackPlacements: p,
311
+ fallbackStrategy: f = "bestFit",
312
+ fallbackAxisSideDirection: h = "none",
313
+ flipAlignment: m = !0,
314
+ ...w
315
+ } = U(t, e);
316
+ if ((n = s.arrow) != null && n.alignmentOffset)
411
317
  return {};
318
+ const g = j(i), v = j(l) === l, y = await (c.isRTL == null ? void 0 : c.isRTL(a.floating)), A = p || (v || !m ? [tt(l)] : Mt(l));
319
+ !p && h !== "none" && A.push(...Ht(l, m, h, y));
320
+ const x = [l, ...A], b = await wt(e, w), E = [];
321
+ let P = ((o = s.flip) == null ? void 0 : o.overflows) || [];
322
+ if (d && E.push(b[g]), u) {
323
+ const L = Wt(i, r, y);
324
+ E.push(b[L[0]], b[L[1]]);
412
325
  }
413
- const side = getSide(placement);
414
- const isBasePlacement = getSide(initialPlacement) === initialPlacement;
415
- const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
416
- const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
417
- if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== "none") {
418
- fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
419
- }
420
- const placements = [initialPlacement, ...fallbackPlacements];
421
- const overflow = await detectOverflow(state, detectOverflowOptions);
422
- const overflows = [];
423
- let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
424
- if (checkMainAxis) {
425
- overflows.push(overflow[side]);
426
- }
427
- if (checkCrossAxis) {
428
- const sides = getAlignmentSides(placement, rects, rtl);
429
- overflows.push(overflow[sides[0]], overflow[sides[1]]);
430
- }
431
- overflowsData = [...overflowsData, {
432
- placement,
433
- overflows
434
- }];
435
- if (!overflows.every((side2) => side2 <= 0)) {
436
- var _middlewareData$flip2, _overflowsData$filter;
437
- const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
438
- const nextPlacement = placements[nextIndex];
439
- if (nextPlacement) {
326
+ if (P = [...P, {
327
+ placement: i,
328
+ overflows: E
329
+ }], !E.every((L) => L <= 0)) {
330
+ var H, Y;
331
+ const L = (((H = s.flip) == null ? void 0 : H.index) || 0) + 1, q = x[L];
332
+ if (q)
440
333
  return {
441
334
  data: {
442
- index: nextIndex,
443
- overflows: overflowsData
335
+ index: L,
336
+ overflows: P
444
337
  },
445
338
  reset: {
446
- placement: nextPlacement
339
+ placement: q
447
340
  }
448
341
  };
449
- }
450
- let resetPlacement = (_overflowsData$filter = overflowsData.filter((d) => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
451
- if (!resetPlacement) {
452
- switch (fallbackStrategy) {
342
+ let C = (Y = P.filter((S) => S.overflows[0] <= 0).sort((S, D) => S.overflows[1] - D.overflows[1])[0]) == null ? void 0 : Y.placement;
343
+ if (!C)
344
+ switch (f) {
453
345
  case "bestFit": {
454
- var _overflowsData$map$so;
455
- const placement2 = (_overflowsData$map$so = overflowsData.map((d) => [d.placement, d.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0];
456
- if (placement2) {
457
- resetPlacement = placement2;
458
- }
346
+ var X;
347
+ const S = (X = P.map((D) => [D.placement, D.overflows.filter((W) => W > 0).reduce((W, Rt) => W + Rt, 0)]).sort((D, W) => D[1] - W[1])[0]) == null ? void 0 : X[0];
348
+ S && (C = S);
459
349
  break;
460
350
  }
461
351
  case "initialPlacement":
462
- resetPlacement = initialPlacement;
352
+ C = l;
463
353
  break;
464
354
  }
465
- }
466
- if (placement !== resetPlacement) {
355
+ if (i !== C)
467
356
  return {
468
357
  reset: {
469
- placement: resetPlacement
358
+ placement: C
470
359
  }
471
360
  };
472
- }
473
361
  }
474
362
  return {};
475
363
  }
476
364
  };
477
365
  };
478
- async function convertValueToCoords(state, options) {
366
+ async function zt(t, e) {
479
367
  const {
480
- placement,
481
- platform: platform2,
482
- elements
483
- } = state;
484
- const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
485
- const side = getSide(placement);
486
- const alignment = getAlignment(placement);
487
- const isVertical = getSideAxis(placement) === "y";
488
- const mainAxisMulti = ["left", "top"].includes(side) ? -1 : 1;
489
- const crossAxisMulti = rtl && isVertical ? -1 : 1;
490
- const rawValue = evaluate(options, state);
368
+ placement: n,
369
+ platform: o,
370
+ elements: i
371
+ } = t, s = await (o.isRTL == null ? void 0 : o.isRTL(i.floating)), r = j(n), l = _(n), c = nt(n) === "y", a = ["left", "top"].includes(r) ? -1 : 1, d = s && c ? -1 : 1, u = U(e, t);
491
372
  let {
492
- mainAxis,
493
- crossAxis,
494
- alignmentAxis
495
- } = typeof rawValue === "number" ? {
496
- mainAxis: rawValue,
373
+ mainAxis: p,
374
+ crossAxis: f,
375
+ alignmentAxis: h
376
+ } = typeof u == "number" ? {
377
+ mainAxis: u,
497
378
  crossAxis: 0,
498
379
  alignmentAxis: null
499
380
  } : {
500
381
  mainAxis: 0,
501
382
  crossAxis: 0,
502
383
  alignmentAxis: null,
503
- ...rawValue
384
+ ...u
504
385
  };
505
- if (alignment && typeof alignmentAxis === "number") {
506
- crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
507
- }
508
- return isVertical ? {
509
- x: crossAxis * crossAxisMulti,
510
- y: mainAxis * mainAxisMulti
386
+ return l && typeof h == "number" && (f = l === "end" ? h * -1 : h), c ? {
387
+ x: f * d,
388
+ y: p * a
511
389
  } : {
512
- x: mainAxis * mainAxisMulti,
513
- y: crossAxis * crossAxisMulti
390
+ x: p * a,
391
+ y: f * d
514
392
  };
515
393
  }
516
- const offset = function(options) {
517
- if (options === void 0) {
518
- options = 0;
519
- }
520
- return {
394
+ const It = function(t) {
395
+ return t === void 0 && (t = 0), {
521
396
  name: "offset",
522
- options,
523
- async fn(state) {
397
+ options: t,
398
+ async fn(e) {
524
399
  const {
525
- x,
526
- y
527
- } = state;
528
- const diffCoords = await convertValueToCoords(state, options);
400
+ x: n,
401
+ y: o
402
+ } = e, i = await zt(e, t);
529
403
  return {
530
- x: x + diffCoords.x,
531
- y: y + diffCoords.y,
532
- data: diffCoords
404
+ x: n + i.x,
405
+ y: o + i.y,
406
+ data: i
533
407
  };
534
408
  }
535
409
  };
536
- };
537
- const size = function(options) {
538
- if (options === void 0) {
539
- options = {};
540
- }
541
- return {
410
+ }, $t = function(t) {
411
+ return t === void 0 && (t = {}), {
542
412
  name: "size",
543
- options,
544
- async fn(state) {
545
- const {
546
- placement,
547
- rects,
548
- platform: platform2,
549
- elements
550
- } = state;
413
+ options: t,
414
+ async fn(e) {
551
415
  const {
552
- apply = () => {
416
+ placement: n,
417
+ rects: o,
418
+ platform: i,
419
+ elements: s
420
+ } = e, {
421
+ apply: r = () => {
553
422
  },
554
- ...detectOverflowOptions
555
- } = evaluate(options, state);
556
- const overflow = await detectOverflow(state, detectOverflowOptions);
557
- const side = getSide(placement);
558
- const alignment = getAlignment(placement);
559
- const isYAxis = getSideAxis(placement) === "y";
560
- const {
561
- width,
562
- height
563
- } = rects.floating;
564
- let heightSide;
565
- let widthSide;
566
- if (side === "top" || side === "bottom") {
567
- heightSide = side;
568
- widthSide = alignment === (await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
423
+ ...l
424
+ } = U(t, e), c = await wt(e, l), a = j(n), d = _(n), u = nt(n) === "y", {
425
+ width: p,
426
+ height: f
427
+ } = o.floating;
428
+ let h, m;
429
+ a === "top" || a === "bottom" ? (h = a, m = d === (await (i.isRTL == null ? void 0 : i.isRTL(s.floating)) ? "start" : "end") ? "left" : "right") : (m = a, h = d === "end" ? "top" : "bottom");
430
+ const w = f - c[h], g = p - c[m], v = !e.middlewareData.shift;
431
+ let y = w, A = g;
432
+ if (u) {
433
+ const b = p - c.left - c.right;
434
+ A = d || v ? N(g, b) : b;
569
435
  } else {
570
- widthSide = side;
571
- heightSide = alignment === "end" ? "top" : "bottom";
436
+ const b = f - c.top - c.bottom;
437
+ y = d || v ? N(w, b) : b;
572
438
  }
573
- const overflowAvailableHeight = height - overflow[heightSide];
574
- const overflowAvailableWidth = width - overflow[widthSide];
575
- const noShift = !state.middlewareData.shift;
576
- let availableHeight = overflowAvailableHeight;
577
- let availableWidth = overflowAvailableWidth;
578
- if (isYAxis) {
579
- const maximumClippingWidth = width - overflow.left - overflow.right;
580
- availableWidth = alignment || noShift ? min(overflowAvailableWidth, maximumClippingWidth) : maximumClippingWidth;
581
- } else {
582
- const maximumClippingHeight = height - overflow.top - overflow.bottom;
583
- availableHeight = alignment || noShift ? min(overflowAvailableHeight, maximumClippingHeight) : maximumClippingHeight;
439
+ if (v && !d) {
440
+ const b = R(c.left, 0), E = R(c.right, 0), P = R(c.top, 0), H = R(c.bottom, 0);
441
+ u ? A = p - 2 * (b !== 0 || E !== 0 ? b + E : R(c.left, c.right)) : y = f - 2 * (P !== 0 || H !== 0 ? P + H : R(c.top, c.bottom));
584
442
  }
585
- if (noShift && !alignment) {
586
- const xMin = max(overflow.left, 0);
587
- const xMax = max(overflow.right, 0);
588
- const yMin = max(overflow.top, 0);
589
- const yMax = max(overflow.bottom, 0);
590
- if (isYAxis) {
591
- availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
592
- } else {
593
- availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
594
- }
595
- }
596
- await apply({
597
- ...state,
598
- availableWidth,
599
- availableHeight
443
+ await r({
444
+ ...e,
445
+ availableWidth: A,
446
+ availableHeight: y
600
447
  });
601
- const nextDimensions = await platform2.getDimensions(elements.floating);
602
- if (width !== nextDimensions.width || height !== nextDimensions.height) {
603
- return {
604
- reset: {
605
- rects: true
606
- }
607
- };
608
- }
609
- return {};
448
+ const x = await i.getDimensions(s.floating);
449
+ return p !== x.width || f !== x.height ? {
450
+ reset: {
451
+ rects: !0
452
+ }
453
+ } : {};
610
454
  }
611
455
  };
612
456
  };
613
- function getNodeName(node) {
614
- if (isNode(node)) {
615
- return (node.nodeName || "").toLowerCase();
616
- }
617
- return "#document";
457
+ function V(t) {
458
+ return xt(t) ? (t.nodeName || "").toLowerCase() : "#document";
618
459
  }
619
- function getWindow(node) {
620
- var _node$ownerDocument;
621
- return (node == null ? void 0 : (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
460
+ function O(t) {
461
+ var e;
462
+ return (t == null || (e = t.ownerDocument) == null ? void 0 : e.defaultView) || window;
622
463
  }
623
- function getDocumentElement(node) {
624
- var _ref;
625
- return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
464
+ function F(t) {
465
+ var e;
466
+ return (e = (xt(t) ? t.ownerDocument : t.document) || window.document) == null ? void 0 : e.documentElement;
626
467
  }
627
- function isNode(value) {
628
- return value instanceof Node || value instanceof getWindow(value).Node;
468
+ function xt(t) {
469
+ return t instanceof Node || t instanceof O(t).Node;
629
470
  }
630
- function isElement(value) {
631
- return value instanceof Element || value instanceof getWindow(value).Element;
471
+ function M(t) {
472
+ return t instanceof Element || t instanceof O(t).Element;
632
473
  }
633
- function isHTMLElement(value) {
634
- return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
474
+ function k(t) {
475
+ return t instanceof HTMLElement || t instanceof O(t).HTMLElement;
635
476
  }
636
- function isShadowRoot(value) {
637
- if (typeof ShadowRoot === "undefined") {
638
- return false;
639
- }
640
- return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
477
+ function dt(t) {
478
+ return typeof ShadowRoot > "u" ? !1 : t instanceof ShadowRoot || t instanceof O(t).ShadowRoot;
641
479
  }
642
- function isOverflowElement(element) {
480
+ function J(t) {
643
481
  const {
644
- overflow,
645
- overflowX,
646
- overflowY,
647
- display
648
- } = getComputedStyle(element);
649
- return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !["inline", "contents"].includes(display);
650
- }
651
- function isTableElement(element) {
652
- return ["table", "td", "th"].includes(getNodeName(element));
653
- }
654
- function isContainingBlock(element) {
655
- const webkit = isWebKit();
656
- const css = getComputedStyle(element);
657
- return css.transform !== "none" || css.perspective !== "none" || (css.containerType ? css.containerType !== "normal" : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit && (css.filter ? css.filter !== "none" : false) || ["transform", "perspective", "filter"].some((value) => (css.willChange || "").includes(value)) || ["paint", "layout", "strict", "content"].some((value) => (css.contain || "").includes(value));
658
- }
659
- function getContainingBlock(element) {
660
- let currentNode = getParentNode(element);
661
- while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
662
- if (isContainingBlock(currentNode)) {
663
- return currentNode;
664
- } else {
665
- currentNode = getParentNode(currentNode);
666
- }
482
+ overflow: e,
483
+ overflowX: n,
484
+ overflowY: o,
485
+ display: i
486
+ } = T(t);
487
+ return /auto|scroll|overlay|hidden|clip/.test(e + o + n) && !["inline", "contents"].includes(i);
488
+ }
489
+ function _t(t) {
490
+ return ["table", "td", "th"].includes(V(t));
491
+ }
492
+ function lt(t) {
493
+ const e = at(), n = T(t);
494
+ return n.transform !== "none" || n.perspective !== "none" || (n.containerType ? n.containerType !== "normal" : !1) || !e && (n.backdropFilter ? n.backdropFilter !== "none" : !1) || !e && (n.filter ? n.filter !== "none" : !1) || ["transform", "perspective", "filter"].some((o) => (n.willChange || "").includes(o)) || ["paint", "layout", "strict", "content"].some((o) => (n.contain || "").includes(o));
495
+ }
496
+ function Yt(t) {
497
+ let e = $(t);
498
+ for (; k(e) && !ot(e); ) {
499
+ if (lt(e))
500
+ return e;
501
+ e = $(e);
667
502
  }
668
503
  return null;
669
504
  }
670
- function isWebKit() {
671
- if (typeof CSS === "undefined" || !CSS.supports)
672
- return false;
673
- return CSS.supports("-webkit-backdrop-filter", "none");
505
+ function at() {
506
+ return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
674
507
  }
675
- function isLastTraversableNode(node) {
676
- return ["html", "body", "#document"].includes(getNodeName(node));
508
+ function ot(t) {
509
+ return ["html", "body", "#document"].includes(V(t));
677
510
  }
678
- function getComputedStyle(element) {
679
- return getWindow(element).getComputedStyle(element);
511
+ function T(t) {
512
+ return O(t).getComputedStyle(t);
680
513
  }
681
- function getNodeScroll(element) {
682
- if (isElement(element)) {
683
- return {
684
- scrollLeft: element.scrollLeft,
685
- scrollTop: element.scrollTop
686
- };
687
- }
688
- return {
689
- scrollLeft: element.pageXOffset,
690
- scrollTop: element.pageYOffset
514
+ function it(t) {
515
+ return M(t) ? {
516
+ scrollLeft: t.scrollLeft,
517
+ scrollTop: t.scrollTop
518
+ } : {
519
+ scrollLeft: t.pageXOffset,
520
+ scrollTop: t.pageYOffset
691
521
  };
692
522
  }
693
- function getParentNode(node) {
694
- if (getNodeName(node) === "html") {
695
- return node;
696
- }
697
- const result = (
523
+ function $(t) {
524
+ if (V(t) === "html")
525
+ return t;
526
+ const e = (
698
527
  // Step into the shadow DOM of the parent of a slotted node.
699
- node.assignedSlot || // DOM Element detected.
700
- node.parentNode || // ShadowRoot detected.
701
- isShadowRoot(node) && node.host || // Fallback.
702
- getDocumentElement(node)
528
+ t.assignedSlot || // DOM Element detected.
529
+ t.parentNode || // ShadowRoot detected.
530
+ dt(t) && t.host || // Fallback.
531
+ F(t)
703
532
  );
704
- return isShadowRoot(result) ? result.host : result;
705
- }
706
- function getNearestOverflowAncestor(node) {
707
- const parentNode = getParentNode(node);
708
- if (isLastTraversableNode(parentNode)) {
709
- return node.ownerDocument ? node.ownerDocument.body : node.body;
710
- }
711
- if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
712
- return parentNode;
713
- }
714
- return getNearestOverflowAncestor(parentNode);
715
- }
716
- function getOverflowAncestors(node, list, traverseIframes) {
717
- var _node$ownerDocument2;
718
- if (list === void 0) {
719
- list = [];
720
- }
721
- if (traverseIframes === void 0) {
722
- traverseIframes = true;
723
- }
724
- const scrollableAncestor = getNearestOverflowAncestor(node);
725
- const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
726
- const win = getWindow(scrollableAncestor);
727
- if (isBody) {
728
- return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], win.frameElement && traverseIframes ? getOverflowAncestors(win.frameElement) : []);
729
- }
730
- return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
731
- }
732
- function getCssDimensions(element) {
733
- const css = getComputedStyle(element);
734
- let width = parseFloat(css.width) || 0;
735
- let height = parseFloat(css.height) || 0;
736
- const hasOffset = isHTMLElement(element);
737
- const offsetWidth = hasOffset ? element.offsetWidth : width;
738
- const offsetHeight = hasOffset ? element.offsetHeight : height;
739
- const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
740
- if (shouldFallback) {
741
- width = offsetWidth;
742
- height = offsetHeight;
743
- }
744
- return {
745
- width,
746
- height,
747
- $: shouldFallback
533
+ return dt(e) ? e.host : e;
534
+ }
535
+ function vt(t) {
536
+ const e = $(t);
537
+ return ot(e) ? t.ownerDocument ? t.ownerDocument.body : t.body : k(e) && J(e) ? e : vt(e);
538
+ }
539
+ function K(t, e, n) {
540
+ var o;
541
+ e === void 0 && (e = []), n === void 0 && (n = !0);
542
+ const i = vt(t), s = i === ((o = t.ownerDocument) == null ? void 0 : o.body), r = O(i);
543
+ return s ? e.concat(r, r.visualViewport || [], J(i) ? i : [], r.frameElement && n ? K(r.frameElement) : []) : e.concat(i, K(i, [], n));
544
+ }
545
+ function yt(t) {
546
+ const e = T(t);
547
+ let n = parseFloat(e.width) || 0, o = parseFloat(e.height) || 0;
548
+ const i = k(t), s = i ? t.offsetWidth : n, r = i ? t.offsetHeight : o, l = Z(n) !== s || Z(o) !== r;
549
+ return l && (n = s, o = r), {
550
+ width: n,
551
+ height: o,
552
+ $: l
748
553
  };
749
554
  }
750
- function unwrapElement(element) {
751
- return !isElement(element) ? element.contextElement : element;
752
- }
753
- function getScale(element) {
754
- const domElement = unwrapElement(element);
755
- if (!isHTMLElement(domElement)) {
756
- return createCoords(1);
757
- }
758
- const rect = domElement.getBoundingClientRect();
759
- const {
760
- width,
761
- height,
762
- $
763
- } = getCssDimensions(domElement);
764
- let x = ($ ? round(rect.width) : rect.width) / width;
765
- let y = ($ ? round(rect.height) : rect.height) / height;
766
- if (!x || !Number.isFinite(x)) {
767
- x = 1;
768
- }
769
- if (!y || !Number.isFinite(y)) {
770
- y = 1;
771
- }
772
- return {
773
- x,
774
- y
555
+ function ft(t) {
556
+ return M(t) ? t : t.contextElement;
557
+ }
558
+ function I(t) {
559
+ const e = ft(t);
560
+ if (!k(e))
561
+ return B(1);
562
+ const n = e.getBoundingClientRect(), {
563
+ width: o,
564
+ height: i,
565
+ $: s
566
+ } = yt(e);
567
+ let r = (s ? Z(n.width) : n.width) / o, l = (s ? Z(n.height) : n.height) / i;
568
+ return (!r || !Number.isFinite(r)) && (r = 1), (!l || !Number.isFinite(l)) && (l = 1), {
569
+ x: r,
570
+ y: l
775
571
  };
776
572
  }
777
- const noOffsets = /* @__PURE__ */ createCoords(0);
778
- function getVisualOffsets(element) {
779
- const win = getWindow(element);
780
- if (!isWebKit() || !win.visualViewport) {
781
- return noOffsets;
782
- }
783
- return {
784
- x: win.visualViewport.offsetLeft,
785
- y: win.visualViewport.offsetTop
573
+ const Xt = /* @__PURE__ */ B(0);
574
+ function bt(t) {
575
+ const e = O(t);
576
+ return !at() || !e.visualViewport ? Xt : {
577
+ x: e.visualViewport.offsetLeft,
578
+ y: e.visualViewport.offsetTop
786
579
  };
787
580
  }
788
- function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
789
- if (isFixed === void 0) {
790
- isFixed = false;
791
- }
792
- if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
793
- return false;
794
- }
795
- return isFixed;
796
- }
797
- function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
798
- if (includeScale === void 0) {
799
- includeScale = false;
800
- }
801
- if (isFixedStrategy === void 0) {
802
- isFixedStrategy = false;
803
- }
804
- const clientRect = element.getBoundingClientRect();
805
- const domElement = unwrapElement(element);
806
- let scale = createCoords(1);
807
- if (includeScale) {
808
- if (offsetParent) {
809
- if (isElement(offsetParent)) {
810
- scale = getScale(offsetParent);
811
- }
812
- } else {
813
- scale = getScale(element);
814
- }
815
- }
816
- const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
817
- let x = (clientRect.left + visualOffsets.x) / scale.x;
818
- let y = (clientRect.top + visualOffsets.y) / scale.y;
819
- let width = clientRect.width / scale.x;
820
- let height = clientRect.height / scale.y;
821
- if (domElement) {
822
- const win = getWindow(domElement);
823
- const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
824
- let currentIFrame = win.frameElement;
825
- while (currentIFrame && offsetParent && offsetWin !== win) {
826
- const iframeScale = getScale(currentIFrame);
827
- const iframeRect = currentIFrame.getBoundingClientRect();
828
- const css = getComputedStyle(currentIFrame);
829
- const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
830
- const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
831
- x *= iframeScale.x;
832
- y *= iframeScale.y;
833
- width *= iframeScale.x;
834
- height *= iframeScale.y;
835
- x += left;
836
- y += top;
837
- currentIFrame = getWindow(currentIFrame).frameElement;
838
- }
839
- }
840
- return rectToClientRect({
841
- width,
842
- height,
843
- x,
844
- y
581
+ function qt(t, e, n) {
582
+ return e === void 0 && (e = !1), !n || e && n !== O(t) ? !1 : e;
583
+ }
584
+ function z(t, e, n, o) {
585
+ e === void 0 && (e = !1), n === void 0 && (n = !1);
586
+ const i = t.getBoundingClientRect(), s = ft(t);
587
+ let r = B(1);
588
+ e && (o ? M(o) && (r = I(o)) : r = I(t));
589
+ const l = qt(s, n, o) ? bt(s) : B(0);
590
+ let c = (i.left + l.x) / r.x, a = (i.top + l.y) / r.y, d = i.width / r.x, u = i.height / r.y;
591
+ if (s) {
592
+ const p = O(s), f = o && M(o) ? O(o) : o;
593
+ let h = p.frameElement;
594
+ for (; h && o && f !== p; ) {
595
+ const m = I(h), w = h.getBoundingClientRect(), g = T(h), v = w.left + (h.clientLeft + parseFloat(g.paddingLeft)) * m.x, y = w.top + (h.clientTop + parseFloat(g.paddingTop)) * m.y;
596
+ c *= m.x, a *= m.y, d *= m.x, u *= m.y, c += v, a += y, h = O(h).frameElement;
597
+ }
598
+ }
599
+ return et({
600
+ width: d,
601
+ height: u,
602
+ x: c,
603
+ y: a
845
604
  });
846
605
  }
847
- function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
606
+ function Kt(t) {
848
607
  let {
849
- rect,
850
- offsetParent,
851
- strategy
852
- } = _ref;
853
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
854
- const documentElement = getDocumentElement(offsetParent);
855
- if (offsetParent === documentElement) {
856
- return rect;
857
- }
858
- let scroll = {
608
+ rect: e,
609
+ offsetParent: n,
610
+ strategy: o
611
+ } = t;
612
+ const i = k(n), s = F(n);
613
+ if (n === s)
614
+ return e;
615
+ let r = {
859
616
  scrollLeft: 0,
860
617
  scrollTop: 0
861
- };
862
- let scale = createCoords(1);
863
- const offsets = createCoords(0);
864
- if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== "fixed") {
865
- if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
866
- scroll = getNodeScroll(offsetParent);
867
- }
868
- if (isHTMLElement(offsetParent)) {
869
- const offsetRect = getBoundingClientRect(offsetParent);
870
- scale = getScale(offsetParent);
871
- offsets.x = offsetRect.x + offsetParent.clientLeft;
872
- offsets.y = offsetRect.y + offsetParent.clientTop;
873
- }
618
+ }, l = B(1);
619
+ const c = B(0);
620
+ if ((i || !i && o !== "fixed") && ((V(n) !== "body" || J(s)) && (r = it(n)), k(n))) {
621
+ const a = z(n);
622
+ l = I(n), c.x = a.x + n.clientLeft, c.y = a.y + n.clientTop;
874
623
  }
875
624
  return {
876
- width: rect.width * scale.x,
877
- height: rect.height * scale.y,
878
- x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x,
879
- y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y
625
+ width: e.width * l.x,
626
+ height: e.height * l.y,
627
+ x: e.x * l.x - r.scrollLeft * l.x + c.x,
628
+ y: e.y * l.y - r.scrollTop * l.y + c.y
880
629
  };
881
630
  }
882
- function getClientRects(element) {
883
- return Array.from(element.getClientRects());
884
- }
885
- function getWindowScrollBarX(element) {
886
- return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
887
- }
888
- function getDocumentRect(element) {
889
- const html = getDocumentElement(element);
890
- const scroll = getNodeScroll(element);
891
- const body = element.ownerDocument.body;
892
- const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
893
- const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
894
- let x = -scroll.scrollLeft + getWindowScrollBarX(element);
895
- const y = -scroll.scrollTop;
896
- if (getComputedStyle(body).direction === "rtl") {
897
- x += max(html.clientWidth, body.clientWidth) - width;
898
- }
899
- return {
900
- width,
901
- height,
902
- x,
903
- y
631
+ function Ut(t) {
632
+ return Array.from(t.getClientRects());
633
+ }
634
+ function At(t) {
635
+ return z(F(t)).left + it(t).scrollLeft;
636
+ }
637
+ function Jt(t) {
638
+ const e = F(t), n = it(t), o = t.ownerDocument.body, i = R(e.scrollWidth, e.clientWidth, o.scrollWidth, o.clientWidth), s = R(e.scrollHeight, e.clientHeight, o.scrollHeight, o.clientHeight);
639
+ let r = -n.scrollLeft + At(t);
640
+ const l = -n.scrollTop;
641
+ return T(o).direction === "rtl" && (r += R(e.clientWidth, o.clientWidth) - i), {
642
+ width: i,
643
+ height: s,
644
+ x: r,
645
+ y: l
904
646
  };
905
647
  }
906
- function getViewportRect(element, strategy) {
907
- const win = getWindow(element);
908
- const html = getDocumentElement(element);
909
- const visualViewport = win.visualViewport;
910
- let width = html.clientWidth;
911
- let height = html.clientHeight;
912
- let x = 0;
913
- let y = 0;
914
- if (visualViewport) {
915
- width = visualViewport.width;
916
- height = visualViewport.height;
917
- const visualViewportBased = isWebKit();
918
- if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
919
- x = visualViewport.offsetLeft;
920
- y = visualViewport.offsetTop;
921
- }
648
+ function Gt(t, e) {
649
+ const n = O(t), o = F(t), i = n.visualViewport;
650
+ let s = o.clientWidth, r = o.clientHeight, l = 0, c = 0;
651
+ if (i) {
652
+ s = i.width, r = i.height;
653
+ const a = at();
654
+ (!a || a && e === "fixed") && (l = i.offsetLeft, c = i.offsetTop);
922
655
  }
923
656
  return {
924
- width,
925
- height,
926
- x,
927
- y
657
+ width: s,
658
+ height: r,
659
+ x: l,
660
+ y: c
928
661
  };
929
662
  }
930
- function getInnerBoundingClientRect(element, strategy) {
931
- const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
932
- const top = clientRect.top + element.clientTop;
933
- const left = clientRect.left + element.clientLeft;
934
- const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
935
- const width = element.clientWidth * scale.x;
936
- const height = element.clientHeight * scale.y;
937
- const x = left * scale.x;
938
- const y = top * scale.y;
663
+ function Qt(t, e) {
664
+ const n = z(t, !0, e === "fixed"), o = n.top + t.clientTop, i = n.left + t.clientLeft, s = k(t) ? I(t) : B(1), r = t.clientWidth * s.x, l = t.clientHeight * s.y, c = i * s.x, a = o * s.y;
939
665
  return {
940
- width,
941
- height,
942
- x,
943
- y
666
+ width: r,
667
+ height: l,
668
+ x: c,
669
+ y: a
944
670
  };
945
671
  }
946
- function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
947
- let rect;
948
- if (clippingAncestor === "viewport") {
949
- rect = getViewportRect(element, strategy);
950
- } else if (clippingAncestor === "document") {
951
- rect = getDocumentRect(getDocumentElement(element));
952
- } else if (isElement(clippingAncestor)) {
953
- rect = getInnerBoundingClientRect(clippingAncestor, strategy);
954
- } else {
955
- const visualOffsets = getVisualOffsets(element);
956
- rect = {
957
- ...clippingAncestor,
958
- x: clippingAncestor.x - visualOffsets.x,
959
- y: clippingAncestor.y - visualOffsets.y
672
+ function pt(t, e, n) {
673
+ let o;
674
+ if (e === "viewport")
675
+ o = Gt(t, n);
676
+ else if (e === "document")
677
+ o = Jt(F(t));
678
+ else if (M(e))
679
+ o = Qt(e, n);
680
+ else {
681
+ const i = bt(t);
682
+ o = {
683
+ ...e,
684
+ x: e.x - i.x,
685
+ y: e.y - i.y
960
686
  };
961
687
  }
962
- return rectToClientRect(rect);
688
+ return et(o);
963
689
  }
964
- function hasFixedPositionAncestor(element, stopNode) {
965
- const parentNode = getParentNode(element);
966
- if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
967
- return false;
968
- }
969
- return getComputedStyle(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
690
+ function Et(t, e) {
691
+ const n = $(t);
692
+ return n === e || !M(n) || ot(n) ? !1 : T(n).position === "fixed" || Et(n, e);
970
693
  }
971
- function getClippingElementAncestors(element, cache) {
972
- const cachedResult = cache.get(element);
973
- if (cachedResult) {
974
- return cachedResult;
694
+ function Zt(t, e) {
695
+ const n = e.get(t);
696
+ if (n)
697
+ return n;
698
+ let o = K(t, [], !1).filter((l) => M(l) && V(l) !== "body"), i = null;
699
+ const s = T(t).position === "fixed";
700
+ let r = s ? $(t) : t;
701
+ for (; M(r) && !ot(r); ) {
702
+ const l = T(r), c = lt(r);
703
+ !c && l.position === "fixed" && (i = null), (s ? !c && !i : !c && l.position === "static" && !!i && ["absolute", "fixed"].includes(i.position) || J(r) && !c && Et(t, r)) ? o = o.filter((d) => d !== r) : i = l, r = $(r);
975
704
  }
976
- let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
977
- let currentContainingBlockComputedStyle = null;
978
- const elementIsFixed = getComputedStyle(element).position === "fixed";
979
- let currentNode = elementIsFixed ? getParentNode(element) : element;
980
- while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
981
- const computedStyle = getComputedStyle(currentNode);
982
- const currentNodeIsContaining = isContainingBlock(currentNode);
983
- if (!currentNodeIsContaining && computedStyle.position === "fixed") {
984
- currentContainingBlockComputedStyle = null;
985
- }
986
- const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && ["absolute", "fixed"].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
987
- if (shouldDropCurrentNode) {
988
- result = result.filter((ancestor) => ancestor !== currentNode);
989
- } else {
990
- currentContainingBlockComputedStyle = computedStyle;
991
- }
992
- currentNode = getParentNode(currentNode);
993
- }
994
- cache.set(element, result);
995
- return result;
705
+ return e.set(t, o), o;
996
706
  }
997
- function getClippingRect(_ref) {
707
+ function te(t) {
998
708
  let {
999
- element,
1000
- boundary,
1001
- rootBoundary,
1002
- strategy
1003
- } = _ref;
1004
- const elementClippingAncestors = boundary === "clippingAncestors" ? getClippingElementAncestors(element, this._c) : [].concat(boundary);
1005
- const clippingAncestors = [...elementClippingAncestors, rootBoundary];
1006
- const firstClippingAncestor = clippingAncestors[0];
1007
- const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1008
- const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1009
- accRect.top = max(rect.top, accRect.top);
1010
- accRect.right = min(rect.right, accRect.right);
1011
- accRect.bottom = min(rect.bottom, accRect.bottom);
1012
- accRect.left = max(rect.left, accRect.left);
1013
- return accRect;
1014
- }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
709
+ element: e,
710
+ boundary: n,
711
+ rootBoundary: o,
712
+ strategy: i
713
+ } = t;
714
+ const r = [...n === "clippingAncestors" ? Zt(e, this._c) : [].concat(n), o], l = r[0], c = r.reduce((a, d) => {
715
+ const u = pt(e, d, i);
716
+ return a.top = R(u.top, a.top), a.right = N(u.right, a.right), a.bottom = N(u.bottom, a.bottom), a.left = R(u.left, a.left), a;
717
+ }, pt(e, l, i));
1015
718
  return {
1016
- width: clippingRect.right - clippingRect.left,
1017
- height: clippingRect.bottom - clippingRect.top,
1018
- x: clippingRect.left,
1019
- y: clippingRect.top
719
+ width: c.right - c.left,
720
+ height: c.bottom - c.top,
721
+ x: c.left,
722
+ y: c.top
1020
723
  };
1021
724
  }
1022
- function getDimensions(element) {
1023
- return getCssDimensions(element);
725
+ function ee(t) {
726
+ return yt(t);
1024
727
  }
1025
- function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1026
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
1027
- const documentElement = getDocumentElement(offsetParent);
1028
- const isFixed = strategy === "fixed";
1029
- const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
1030
- let scroll = {
728
+ function ne(t, e, n) {
729
+ const o = k(e), i = F(e), s = n === "fixed", r = z(t, !0, s, e);
730
+ let l = {
1031
731
  scrollLeft: 0,
1032
732
  scrollTop: 0
1033
733
  };
1034
- const offsets = createCoords(0);
1035
- if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1036
- if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
1037
- scroll = getNodeScroll(offsetParent);
1038
- }
1039
- if (isOffsetParentAnElement) {
1040
- const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
1041
- offsets.x = offsetRect.x + offsetParent.clientLeft;
1042
- offsets.y = offsetRect.y + offsetParent.clientTop;
1043
- } else if (documentElement) {
1044
- offsets.x = getWindowScrollBarX(documentElement);
1045
- }
1046
- }
734
+ const c = B(0);
735
+ if (o || !o && !s)
736
+ if ((V(e) !== "body" || J(i)) && (l = it(e)), o) {
737
+ const a = z(e, !0, s, e);
738
+ c.x = a.x + e.clientLeft, c.y = a.y + e.clientTop;
739
+ } else
740
+ i && (c.x = At(i));
1047
741
  return {
1048
- x: rect.left + scroll.scrollLeft - offsets.x,
1049
- y: rect.top + scroll.scrollTop - offsets.y,
1050
- width: rect.width,
1051
- height: rect.height
742
+ x: r.left + l.scrollLeft - c.x,
743
+ y: r.top + l.scrollTop - c.y,
744
+ width: r.width,
745
+ height: r.height
1052
746
  };
1053
747
  }
1054
- function getTrueOffsetParent(element, polyfill) {
1055
- if (!isHTMLElement(element) || getComputedStyle(element).position === "fixed") {
1056
- return null;
1057
- }
1058
- if (polyfill) {
1059
- return polyfill(element);
1060
- }
1061
- return element.offsetParent;
748
+ function mt(t, e) {
749
+ return !k(t) || T(t).position === "fixed" ? null : e ? e(t) : t.offsetParent;
1062
750
  }
1063
- function getOffsetParent(element, polyfill) {
1064
- const window2 = getWindow(element);
1065
- if (!isHTMLElement(element)) {
1066
- return window2;
1067
- }
1068
- let offsetParent = getTrueOffsetParent(element, polyfill);
1069
- while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === "static") {
1070
- offsetParent = getTrueOffsetParent(offsetParent, polyfill);
1071
- }
1072
- if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle(offsetParent).position === "static" && !isContainingBlock(offsetParent))) {
1073
- return window2;
1074
- }
1075
- return offsetParent || getContainingBlock(element) || window2;
751
+ function Ct(t, e) {
752
+ const n = O(t);
753
+ if (!k(t))
754
+ return n;
755
+ let o = mt(t, e);
756
+ for (; o && _t(o) && T(o).position === "static"; )
757
+ o = mt(o, e);
758
+ return o && (V(o) === "html" || V(o) === "body" && T(o).position === "static" && !lt(o)) ? n : o || Yt(t) || n;
1076
759
  }
1077
- const getElementRects = async function(_ref) {
760
+ const oe = async function(t) {
1078
761
  let {
1079
- reference,
1080
- floating,
1081
- strategy
1082
- } = _ref;
1083
- const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
1084
- const getDimensionsFn = this.getDimensions;
762
+ reference: e,
763
+ floating: n,
764
+ strategy: o
765
+ } = t;
766
+ const i = this.getOffsetParent || Ct, s = this.getDimensions;
1085
767
  return {
1086
- reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
768
+ reference: ne(e, await i(n), o),
1087
769
  floating: {
1088
770
  x: 0,
1089
771
  y: 0,
1090
- ...await getDimensionsFn(floating)
772
+ ...await s(n)
1091
773
  }
1092
774
  };
1093
775
  };
1094
- function isRTL(element) {
1095
- return getComputedStyle(element).direction === "rtl";
1096
- }
1097
- const platform = {
1098
- convertOffsetParentRelativeRectToViewportRelativeRect,
1099
- getDocumentElement,
1100
- getClippingRect,
1101
- getOffsetParent,
1102
- getElementRects,
1103
- getClientRects,
1104
- getDimensions,
1105
- getScale,
1106
- isElement,
1107
- isRTL
776
+ function ie(t) {
777
+ return T(t).direction === "rtl";
778
+ }
779
+ const se = {
780
+ convertOffsetParentRelativeRectToViewportRelativeRect: Kt,
781
+ getDocumentElement: F,
782
+ getClippingRect: te,
783
+ getOffsetParent: Ct,
784
+ getElementRects: oe,
785
+ getClientRects: Ut,
786
+ getDimensions: ee,
787
+ getScale: I,
788
+ isElement: M,
789
+ isRTL: ie
1108
790
  };
1109
- function observeMove(element, onMove) {
1110
- let io = null;
1111
- let timeoutId;
1112
- const root = getDocumentElement(element);
1113
- function cleanup() {
1114
- clearTimeout(timeoutId);
1115
- io && io.disconnect();
1116
- io = null;
1117
- }
1118
- function refresh(skip, threshold) {
1119
- if (skip === void 0) {
1120
- skip = false;
1121
- }
1122
- if (threshold === void 0) {
1123
- threshold = 1;
1124
- }
1125
- cleanup();
791
+ function re(t, e) {
792
+ let n = null, o;
793
+ const i = F(t);
794
+ function s() {
795
+ clearTimeout(o), n && n.disconnect(), n = null;
796
+ }
797
+ function r(l, c) {
798
+ l === void 0 && (l = !1), c === void 0 && (c = 1), s();
1126
799
  const {
1127
- left,
1128
- top,
1129
- width,
1130
- height
1131
- } = element.getBoundingClientRect();
1132
- if (!skip) {
1133
- onMove();
1134
- }
1135
- if (!width || !height) {
800
+ left: a,
801
+ top: d,
802
+ width: u,
803
+ height: p
804
+ } = t.getBoundingClientRect();
805
+ if (l || e(), !u || !p)
1136
806
  return;
1137
- }
1138
- const insetTop = floor(top);
1139
- const insetRight = floor(root.clientWidth - (left + width));
1140
- const insetBottom = floor(root.clientHeight - (top + height));
1141
- const insetLeft = floor(left);
1142
- const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
1143
- const options = {
1144
- rootMargin,
1145
- threshold: max(0, min(1, threshold)) || 1
807
+ const f = Q(d), h = Q(i.clientWidth - (a + u)), m = Q(i.clientHeight - (d + p)), w = Q(a), v = {
808
+ rootMargin: -f + "px " + -h + "px " + -m + "px " + -w + "px",
809
+ threshold: R(0, N(1, c)) || 1
1146
810
  };
1147
- let isFirstUpdate = true;
1148
- function handleObserve(entries) {
1149
- const ratio = entries[0].intersectionRatio;
1150
- if (ratio !== threshold) {
1151
- if (!isFirstUpdate) {
1152
- return refresh();
1153
- }
1154
- if (!ratio) {
1155
- timeoutId = setTimeout(() => {
1156
- refresh(false, 1e-7);
1157
- }, 100);
1158
- } else {
1159
- refresh(false, ratio);
1160
- }
811
+ let y = !0;
812
+ function A(x) {
813
+ const b = x[0].intersectionRatio;
814
+ if (b !== c) {
815
+ if (!y)
816
+ return r();
817
+ b ? r(!1, b) : o = setTimeout(() => {
818
+ r(!1, 1e-7);
819
+ }, 100);
1161
820
  }
1162
- isFirstUpdate = false;
821
+ y = !1;
1163
822
  }
1164
823
  try {
1165
- io = new IntersectionObserver(handleObserve, {
1166
- ...options,
824
+ n = new IntersectionObserver(A, {
825
+ ...v,
1167
826
  // Handle <iframe>s
1168
- root: root.ownerDocument
827
+ root: i.ownerDocument
1169
828
  });
1170
- } catch (e) {
1171
- io = new IntersectionObserver(handleObserve, options);
829
+ } catch {
830
+ n = new IntersectionObserver(A, v);
1172
831
  }
1173
- io.observe(element);
832
+ n.observe(t);
1174
833
  }
1175
- refresh(true);
1176
- return cleanup;
834
+ return r(!0), s;
1177
835
  }
1178
- function autoUpdate(reference, floating, update, options) {
1179
- if (options === void 0) {
1180
- options = {};
1181
- }
836
+ function ce(t, e, n, o) {
837
+ o === void 0 && (o = {});
1182
838
  const {
1183
- ancestorScroll = true,
1184
- ancestorResize = true,
1185
- elementResize = typeof ResizeObserver === "function",
1186
- layoutShift = typeof IntersectionObserver === "function",
1187
- animationFrame = false
1188
- } = options;
1189
- const referenceEl = unwrapElement(reference);
1190
- const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...getOverflowAncestors(floating)] : [];
1191
- ancestors.forEach((ancestor) => {
1192
- ancestorScroll && ancestor.addEventListener("scroll", update, {
1193
- passive: true
1194
- });
1195
- ancestorResize && ancestor.addEventListener("resize", update);
839
+ ancestorScroll: i = !0,
840
+ ancestorResize: s = !0,
841
+ elementResize: r = typeof ResizeObserver == "function",
842
+ layoutShift: l = typeof IntersectionObserver == "function",
843
+ animationFrame: c = !1
844
+ } = o, a = ft(t), d = i || s ? [...a ? K(a) : [], ...K(e)] : [];
845
+ d.forEach((g) => {
846
+ i && g.addEventListener("scroll", n, {
847
+ passive: !0
848
+ }), s && g.addEventListener("resize", n);
1196
849
  });
1197
- const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
1198
- let reobserveFrame = -1;
1199
- let resizeObserver = null;
1200
- if (elementResize) {
1201
- resizeObserver = new ResizeObserver((_ref) => {
1202
- let [firstEntry] = _ref;
1203
- if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
1204
- resizeObserver.unobserve(floating);
1205
- cancelAnimationFrame(reobserveFrame);
1206
- reobserveFrame = requestAnimationFrame(() => {
1207
- resizeObserver && resizeObserver.observe(floating);
1208
- });
1209
- }
1210
- update();
1211
- });
1212
- if (referenceEl && !animationFrame) {
1213
- resizeObserver.observe(referenceEl);
1214
- }
1215
- resizeObserver.observe(floating);
1216
- }
1217
- let frameId;
1218
- let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
1219
- if (animationFrame) {
1220
- frameLoop();
1221
- }
1222
- function frameLoop() {
1223
- const nextRefRect = getBoundingClientRect(reference);
1224
- if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
1225
- update();
1226
- }
1227
- prevRefRect = nextRefRect;
1228
- frameId = requestAnimationFrame(frameLoop);
1229
- }
1230
- update();
1231
- return () => {
1232
- ancestors.forEach((ancestor) => {
1233
- ancestorScroll && ancestor.removeEventListener("scroll", update);
1234
- ancestorResize && ancestor.removeEventListener("resize", update);
1235
- });
1236
- cleanupIo && cleanupIo();
1237
- resizeObserver && resizeObserver.disconnect();
1238
- resizeObserver = null;
1239
- if (animationFrame) {
1240
- cancelAnimationFrame(frameId);
1241
- }
850
+ const u = a && l ? re(a, n) : null;
851
+ let p = -1, f = null;
852
+ r && (f = new ResizeObserver((g) => {
853
+ let [v] = g;
854
+ v && v.target === a && f && (f.unobserve(e), cancelAnimationFrame(p), p = requestAnimationFrame(() => {
855
+ f && f.observe(e);
856
+ })), n();
857
+ }), a && !c && f.observe(a), f.observe(e));
858
+ let h, m = c ? z(t) : null;
859
+ c && w();
860
+ function w() {
861
+ const g = z(t);
862
+ m && (g.x !== m.x || g.y !== m.y || g.width !== m.width || g.height !== m.height) && n(), m = g, h = requestAnimationFrame(w);
863
+ }
864
+ return n(), () => {
865
+ d.forEach((g) => {
866
+ i && g.removeEventListener("scroll", n), s && g.removeEventListener("resize", n);
867
+ }), u && u(), f && f.disconnect(), f = null, c && cancelAnimationFrame(h);
1242
868
  };
1243
869
  }
1244
- const computePosition = (reference, floating, options) => {
1245
- const cache = /* @__PURE__ */ new Map();
1246
- const mergedOptions = {
1247
- platform,
1248
- ...options
1249
- };
1250
- const platformWithCache = {
1251
- ...mergedOptions.platform,
1252
- _c: cache
870
+ const le = (t, e, n) => {
871
+ const o = /* @__PURE__ */ new Map(), i = {
872
+ platform: se,
873
+ ...n
874
+ }, s = {
875
+ ...i.platform,
876
+ _c: o
1253
877
  };
1254
- return computePosition$1(reference, floating, {
1255
- ...mergedOptions,
1256
- platform: platformWithCache
878
+ return Bt(t, e, {
879
+ ...i,
880
+ platform: s
1257
881
  });
1258
- };
1259
- const styles = "/*!\n* direction.scss\n*/\n/* Skeleton Variables */\n/*\n[ Popup ]\n*/\n:host {\n --wj-popup-top: auto;\n --wj-popup-left: auto;\n display: flex;\n}\n.native-popup {\n position: absolute;\n isolation: isolate;\n z-index: 999;\n left: var(--wj-popup-left);\n top: var(--wj-popup-top);\n}\n.native-popup:not(.popup-active) {\n display: none;\n}";
1260
- class Popup extends WJElement {
882
+ }, ae = `/*!
883
+ * direction.scss
884
+ */:host{--wj-popup-top: auto;--wj-popup-left: auto;display:flex}.native-popup{position:absolute;isolation:isolate;z-index:999;left:var(--wj-popup-left);top:var(--wj-popup-top)}.native-popup:not(.popup-active){display:none}
885
+ `;
886
+ class fe extends Tt {
1261
887
  constructor() {
1262
888
  super();
1263
- __publicField(this, "className", "Popup");
1264
- this._manual = false;
889
+ ut(this, "className", "Popup");
890
+ this._manual = !1;
1265
891
  }
1266
- set manual(value) {
1267
- this._manual = value;
892
+ set manual(n) {
893
+ this._manual = n;
1268
894
  }
1269
895
  get manual() {
1270
- if (this.hasAttribute("manual"))
1271
- this._manual = true;
1272
- return this._manual;
896
+ return this.hasAttribute("manual") && (this._manual = !0), this._manual;
1273
897
  }
1274
898
  static get cssStyleSheet() {
1275
- return styles;
899
+ return ae;
1276
900
  }
1277
901
  static get observedAttributes() {
1278
902
  return ["active"];
@@ -1280,145 +904,95 @@ class Popup extends WJElement {
1280
904
  setupAttributes() {
1281
905
  this.isShadowRoot = "open";
1282
906
  }
1283
- attributeChangedCallback(name, old, newName) {
1284
- if (name === "active") {
1285
- if (this.hasAttribute(name)) {
1286
- this.show();
1287
- } else {
1288
- this.hide();
1289
- }
1290
- }
907
+ attributeChangedCallback(n, o, i) {
908
+ n === "active" && (this.hasAttribute(n) ? this.show() : this.hide());
1291
909
  }
1292
- draw(context, store, params) {
1293
- let fragment = document.createDocumentFragment();
1294
- let slotAnchor = document.createElement("slot");
1295
- slotAnchor.setAttribute("name", "anchor");
1296
- let slotArrow = document.createElement("slot");
1297
- slotArrow.setAttribute("name", "arrow");
1298
- let native = document.createElement("div");
1299
- native.setAttribute("part", "native");
1300
- native.classList.add("native-popup");
1301
- let slot = document.createElement("slot");
1302
- native.appendChild(slot);
1303
- native.appendChild(slotArrow);
1304
- fragment.appendChild(slotAnchor);
1305
- fragment.appendChild(native);
1306
- this.slotAnchor = slotAnchor;
1307
- this.slotArrow = slotArrow;
1308
- this.native = native;
1309
- return fragment;
910
+ draw(n, o, i) {
911
+ let s = document.createDocumentFragment(), r = document.createElement("slot");
912
+ r.setAttribute("name", "anchor");
913
+ let l = document.createElement("slot");
914
+ l.setAttribute("name", "arrow");
915
+ let c = document.createElement("div");
916
+ c.setAttribute("part", "native"), c.classList.add("native-popup");
917
+ let a = document.createElement("slot");
918
+ return c.appendChild(a), c.appendChild(l), s.appendChild(r), s.appendChild(c), this.slotAnchor = r, this.slotArrow = l, this.native = c, s;
1310
919
  }
1311
- afterDraw(context, store, params) {
920
+ afterDraw(n, o, i) {
1312
921
  this.setAnchor();
1313
922
  }
1314
923
  setAnchor() {
1315
- if (this.slotAnchor && typeof this.anchor === "string") {
1316
- const root = this.getRootNode();
1317
- this.anchorEl = root.getElementById(this.anchor);
1318
- } else if (this.slotAnchor instanceof HTMLSlotElement) {
1319
- this.anchorEl = this.slotAnchor.assignedElements({ flatten: true })[0];
1320
- }
1321
- event.addListener(this.anchorEl, "click", null, (e) => {
1322
- console.log("som CLICK");
1323
- if (this.hasAttribute("disabled"))
1324
- return;
1325
- this.showHide();
1326
- }, { stopPropagation: true });
1327
- document.addEventListener("click", (e) => {
1328
- let clickToHost = e.composedPath().some((el) => el === this);
1329
- if (!clickToHost) {
1330
- if (this.hasAttribute("active"))
1331
- this.removeAttribute("active");
1332
- }
924
+ if (this.slotAnchor && typeof this.anchor == "string") {
925
+ const n = this.getRootNode();
926
+ this.anchorEl = n.getElementById(this.anchor);
927
+ } else
928
+ this.slotAnchor instanceof HTMLSlotElement && (this.anchorEl = this.slotAnchor.assignedElements({ flatten: !0 })[0]);
929
+ G.addListener(this.anchorEl, "click", null, (n) => {
930
+ console.log("som CLICK"), !this.hasAttribute("disabled") && this.showHide();
931
+ }, { stopPropagation: !0 }), document.addEventListener("click", (n) => {
932
+ n.composedPath().some((i) => i === this) || this.hasAttribute("active") && this.removeAttribute("active");
1333
933
  });
1334
934
  }
1335
935
  showHide() {
1336
- if (this.hasAttribute("active")) {
1337
- this.removeAttribute("active");
1338
- } else {
1339
- this.setAttribute("active", "");
1340
- event.addListener(this, "click", "wj:popup-show");
1341
- }
936
+ this.hasAttribute("active") ? this.removeAttribute("active") : (this.setAttribute("active", ""), G.addListener(this, "click", "wj:popup-show"));
1342
937
  }
1343
938
  reposition() {
1344
- const middleware = [];
1345
- this.offsetCalc = +this.offset || 0;
1346
- if (this.slotArrow instanceof HTMLSlotElement) {
1347
- this.arrow = this.slotArrow.assignedElements({ flatten: true })[0];
1348
- if (this.arrow) {
1349
- middleware.push(
1350
- arrow({
1351
- element: this.arrow
1352
- })
1353
- );
1354
- this.offsetCalc = Math.sqrt(2 * this.arrow.offsetWidth ** 2) / 2 + +this.offset;
1355
- }
1356
- }
1357
- middleware.push(
1358
- offset(this.offsetCalc)
1359
- );
1360
- middleware.push(
1361
- flip()
1362
- );
1363
- if (this.hasAttribute("size")) {
1364
- middleware.push(
1365
- size({
1366
- apply({ availableWidth, availableHeight, elements }) {
1367
- Object.assign(elements.floating.style, {
1368
- width: `${elements.reference.offsetWidth}px`
1369
- });
1370
- }
1371
- })
1372
- );
1373
- }
1374
- computePosition(this.anchorEl, this.native, {
939
+ const n = [];
940
+ this.offsetCalc = +this.offset || 0, this.slotArrow instanceof HTMLSlotElement && (this.arrow = this.slotArrow.assignedElements({ flatten: !0 })[0], this.arrow && (n.push(
941
+ Vt({
942
+ element: this.arrow
943
+ })
944
+ ), this.offsetCalc = Math.sqrt(2 * this.arrow.offsetWidth ** 2) / 2 + +this.offset)), n.push(
945
+ It(this.offsetCalc)
946
+ ), n.push(
947
+ jt()
948
+ ), this.hasAttribute("size") && n.push(
949
+ $t({
950
+ apply({ availableWidth: o, availableHeight: i, elements: s }) {
951
+ Object.assign(s.floating.style, {
952
+ width: `${s.reference.offsetWidth}px`
953
+ });
954
+ }
955
+ })
956
+ ), le(this.anchorEl, this.native, {
1375
957
  placement: this.placement || "bottom",
1376
958
  strategy: "fixed",
1377
- middleware
1378
- }).then(({ x, y, middlewareData, placement, strategy }) => {
1379
- this.native.style.setProperty("--wj-popup-left", x + "px");
1380
- this.native.style.setProperty("--wj-popup-top", y + "px");
1381
- this.native.style.position = strategy;
1382
- if (this.arrow) {
1383
- const side = this.placement.split("-")[0];
1384
- const staticSide = {
959
+ middleware: n
960
+ }).then(({ x: o, y: i, middlewareData: s, placement: r, strategy: l }) => {
961
+ if (this.native.style.setProperty("--wj-popup-left", o + "px"), this.native.style.setProperty("--wj-popup-top", i + "px"), this.native.style.position = l, this.arrow) {
962
+ const c = this.placement.split("-")[0], a = {
1385
963
  top: "bottom",
1386
964
  right: "left",
1387
965
  bottom: "top",
1388
966
  left: "right"
1389
- }[side];
1390
- if (middlewareData.arrow) {
1391
- const { x: x2, y: y2 } = middlewareData.arrow;
967
+ }[c];
968
+ if (s.arrow) {
969
+ const { x: d, y: u } = s.arrow;
1392
970
  Object.assign(this.arrow.style, {
1393
- left: x2 != null ? `${x2}px` : "",
1394
- top: y2 != null ? `${y2}px` : "",
1395
- [staticSide]: `${-this.arrow.offsetWidth / 2}px`
971
+ left: d != null ? `${d}px` : "",
972
+ top: u != null ? `${u}px` : "",
973
+ [a]: `${-this.arrow.offsetWidth / 2}px`
1396
974
  });
1397
975
  }
1398
976
  }
1399
- });
1400
- event.dispatchCustomEvent(this, "wj-popup:reposition", {
977
+ }), G.dispatchCustomEvent(this, "wj-popup:reposition", {
1401
978
  data: { top: "bottom", right: "left", bottom: "top", left: "right" },
1402
979
  context: this,
1403
980
  event: this
1404
981
  });
1405
982
  }
1406
983
  show() {
1407
- this.native.classList.add("popup-active");
1408
- this.cleanup = autoUpdate(this.anchorEl, this.native, () => {
984
+ this.native.classList.add("popup-active"), this.cleanup = ce(this.anchorEl, this.native, () => {
1409
985
  this.reposition();
1410
986
  });
1411
987
  }
1412
988
  hide() {
1413
- this.native.classList.remove("popup-active");
1414
- this.cleanup();
1415
- this.cleanup = void 0;
989
+ this.native.classList.remove("popup-active"), this.cleanup(), this.cleanup = void 0;
1416
990
  }
1417
991
  disconnectedCallback() {
1418
- event.removeElement(this.anchorEl);
992
+ G.removeElement(this.anchorEl);
1419
993
  }
1420
994
  }
1421
- customElements.get("wj-popup") || window.customElements.define("wj-popup", Popup);
995
+ customElements.get("wj-popup") || window.customElements.define("wj-popup", fe);
1422
996
  export {
1423
- Popup
997
+ fe as Popup
1424
998
  };