wj-elements 0.0.11 → 0.0.13

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 (79) hide show
  1. package/dist/localize-20081fd1.js +55 -0
  2. package/dist/router-links-26e4a166.js +204 -0
  3. package/dist/style.css +2243 -2
  4. package/dist/wj-animation.js +35 -23
  5. package/dist/wj-aside.js +22 -16
  6. package/dist/wj-avatar.js +49 -30
  7. package/dist/wj-badge.js +22 -18
  8. package/dist/wj-breadcrumb.js +102 -50
  9. package/dist/wj-breadcrumbs.js +36 -19
  10. package/dist/wj-button-group.js +36 -22
  11. package/dist/wj-button.js +104 -39
  12. package/dist/wj-card-content.js +18 -14
  13. package/dist/wj-card-controls.js +18 -14
  14. package/dist/wj-card-header.js +20 -14
  15. package/dist/wj-card-subtitle.js +19 -15
  16. package/dist/wj-card-title.js +18 -14
  17. package/dist/wj-card.js +20 -14
  18. package/dist/wj-carousel-item.js +22 -16
  19. package/dist/wj-carousel.js +169 -92
  20. package/dist/wj-checkbox.js +46 -24
  21. package/dist/wj-chip.js +39 -21
  22. package/dist/wj-col.js +31 -17
  23. package/dist/wj-color-picker.js +877 -509
  24. package/dist/wj-container.js +20 -16
  25. package/dist/wj-copy-button.js +112 -64
  26. package/dist/wj-dialog.js +68 -42
  27. package/dist/wj-divider.js +20 -14
  28. package/dist/wj-dropdown.js +29 -17
  29. package/dist/wj-element.js +415 -241
  30. package/dist/wj-fetchAndParseCSS.js +49 -32
  31. package/dist/wj-file-upload-item.js +64 -38
  32. package/dist/wj-file-upload.js +237 -137
  33. package/dist/wj-footer.js +18 -14
  34. package/dist/wj-form.js +18 -14
  35. package/dist/wj-format-digital.js +40 -25
  36. package/dist/wj-grid.js +20 -16
  37. package/dist/wj-header.js +22 -16
  38. package/dist/wj-icon-picker.js +122 -68
  39. package/dist/wj-icon.js +144 -64
  40. package/dist/wj-img-comparer.js +72 -41
  41. package/dist/wj-img.js +31 -19
  42. package/dist/wj-infinite-scroll.js +90 -52
  43. package/dist/wj-input-file.js +50 -27
  44. package/dist/wj-input.js +169 -70
  45. package/dist/wj-item.js +34 -17
  46. package/dist/wj-label.js +21 -19
  47. package/dist/wj-list.js +20 -15
  48. package/dist/wj-main.js +18 -14
  49. package/dist/wj-masonry.js +140 -83
  50. package/dist/wj-master.js +492 -350
  51. package/dist/wj-menu-button.js +19 -15
  52. package/dist/wj-menu-item.js +150 -64
  53. package/dist/wj-menu-label.js +21 -17
  54. package/dist/wj-menu.js +24 -18
  55. package/dist/wj-popup.js +1140 -712
  56. package/dist/wj-progress-bar.js +100 -40
  57. package/dist/wj-radio-group.js +38 -25
  58. package/dist/wj-radio.js +46 -22
  59. package/dist/wj-rate.js +121 -71
  60. package/dist/wj-relative-time.js +48 -24
  61. package/dist/wj-route.js +11 -8
  62. package/dist/wj-router-link.js +22 -17
  63. package/dist/wj-router-outlet.js +135 -71
  64. package/dist/wj-routerx.js +1124 -641
  65. package/dist/wj-row.js +21 -19
  66. package/dist/wj-slider.js +97 -55
  67. package/dist/wj-split-view.js +81 -43
  68. package/dist/wj-store.js +195 -110
  69. package/dist/wj-textarea.js +86 -37
  70. package/dist/wj-thumbnail.js +19 -15
  71. package/dist/wj-toast.js +87 -34
  72. package/dist/wj-toggle.js +42 -24
  73. package/dist/wj-toolbar-action.js +27 -16
  74. package/dist/wj-toolbar.js +26 -19
  75. package/dist/wj-tooltip.js +40 -24
  76. package/dist/wj-visually-hidden.js +18 -14
  77. package/package.json +1 -1
  78. package/dist/localize-762a9f0f.js +0 -43
  79. package/dist/router-links-e0087f84.js +0 -146
package/dist/wj-popup.js CHANGED
@@ -1,900 +1,1278 @@
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 U } from "./wj-element.js";
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";
5
8
  import "./wj-store.js";
6
- const N = Math.min, R = Math.max, Z = Math.round, Q = Math.floor, B = (t) => ({
7
- x: t,
8
- y: t
9
- }), Pt = {
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 = {
10
18
  left: "right",
11
19
  right: "left",
12
20
  bottom: "top",
13
21
  top: "bottom"
14
- }, St = {
22
+ };
23
+ const oppositeAlignmentMap = {
15
24
  start: "end",
16
25
  end: "start"
17
26
  };
18
- function Dt(t, e, n) {
19
- return R(t, N(e, n));
27
+ function clamp(start, value, end) {
28
+ return max(start, min(value, end));
20
29
  }
21
- function K(t, e) {
22
- return typeof t == "function" ? t(e) : t;
30
+ function evaluate(value, param) {
31
+ return typeof value === "function" ? value(param) : value;
23
32
  }
24
- function V(t) {
25
- return t.split("-")[0];
33
+ function getSide(placement) {
34
+ return placement.split("-")[0];
26
35
  }
27
- function _(t) {
28
- return t.split("-")[1];
36
+ function getAlignment(placement) {
37
+ return placement.split("-")[1];
29
38
  }
30
- function kt(t) {
31
- return t === "x" ? "y" : "x";
39
+ function getOppositeAxis(axis) {
40
+ return axis === "x" ? "y" : "x";
32
41
  }
33
- function rt(t) {
34
- return t === "y" ? "height" : "width";
42
+ function getAxisLength(axis) {
43
+ return axis === "y" ? "height" : "width";
35
44
  }
36
- function nt(t) {
37
- return ["top", "bottom"].includes(V(t)) ? "y" : "x";
45
+ function getSideAxis(placement) {
46
+ return ["top", "bottom"].includes(getSide(placement)) ? "y" : "x";
38
47
  }
39
- function ct(t) {
40
- return kt(nt(t));
48
+ function getAlignmentAxis(placement) {
49
+ return getOppositeAxis(getSideAxis(placement));
41
50
  }
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)];
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)];
47
63
  }
48
- function Ht(t) {
49
- const e = tt(t);
50
- return [st(t), e, st(e)];
64
+ function getExpandedPlacements(placement) {
65
+ const oppositePlacement = getOppositePlacement(placement);
66
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
51
67
  }
52
- function st(t) {
53
- return t.replace(/start|end/g, (e) => St[e]);
68
+ function getOppositeAlignmentPlacement(placement) {
69
+ return placement.replace(/start|end/g, (alignment) => oppositeAlignmentMap[alignment]);
54
70
  }
55
- function Mt(t, e, n) {
56
- const o = ["left", "right"], i = ["right", "left"], s = ["top", "bottom"], r = ["bottom", "top"];
57
- switch (t) {
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) {
58
77
  case "top":
59
78
  case "bottom":
60
- return n ? e ? i : o : e ? o : i;
79
+ if (rtl)
80
+ return isStart ? rl : lr;
81
+ return isStart ? lr : rl;
61
82
  case "left":
62
83
  case "right":
63
- return e ? s : r;
84
+ return isStart ? tb : bt;
64
85
  default:
65
86
  return [];
66
87
  }
67
88
  }
68
- function Ft(t, e, n, o) {
69
- const i = _(t);
70
- let s = Mt(V(t), n === "start", o);
71
- return i && (s = s.map((r) => r + "-" + i), e && (s = s.concat(s.map(st)))), s;
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;
72
99
  }
73
- function tt(t) {
74
- return t.replace(/left|right|bottom|top/g, (e) => Pt[e]);
100
+ function getOppositePlacement(placement) {
101
+ return placement.replace(/left|right|bottom|top/g, (side) => oppositeSideMap[side]);
75
102
  }
76
- function Nt(t) {
103
+ function expandPaddingObject(padding) {
77
104
  return {
78
105
  top: 0,
79
106
  right: 0,
80
107
  bottom: 0,
81
108
  left: 0,
82
- ...t
109
+ ...padding
83
110
  };
84
111
  }
85
- function gt(t) {
86
- return typeof t != "number" ? Nt(t) : {
87
- top: t,
88
- right: t,
89
- bottom: t,
90
- left: t
112
+ function getPaddingObject(padding) {
113
+ return typeof padding !== "number" ? expandPaddingObject(padding) : {
114
+ top: padding,
115
+ right: padding,
116
+ bottom: padding,
117
+ left: padding
91
118
  };
92
119
  }
93
- function et(t) {
120
+ function rectToClientRect(rect) {
94
121
  return {
95
- ...t,
96
- top: t.y,
97
- left: t.x,
98
- right: t.x + t.width,
99
- bottom: t.y + t.height
122
+ ...rect,
123
+ top: rect.y,
124
+ left: rect.x,
125
+ right: rect.x + rect.width,
126
+ bottom: rect.y + rect.height
100
127
  };
101
128
  }
102
- function ht(t, e, n) {
129
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
103
130
  let {
104
- reference: o,
105
- floating: i
106
- } = t;
107
- const s = nt(e), r = ct(e), l = rt(r), c = V(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) {
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) {
110
144
  case "top":
111
- f = {
112
- x: d,
113
- y: o.y - i.height
145
+ coords = {
146
+ x: commonX,
147
+ y: reference.y - floating.height
114
148
  };
115
149
  break;
116
150
  case "bottom":
117
- f = {
118
- x: d,
119
- y: o.y + o.height
151
+ coords = {
152
+ x: commonX,
153
+ y: reference.y + reference.height
120
154
  };
121
155
  break;
122
156
  case "right":
123
- f = {
124
- x: o.x + o.width,
125
- y: u
157
+ coords = {
158
+ x: reference.x + reference.width,
159
+ y: commonY
126
160
  };
127
161
  break;
128
162
  case "left":
129
- f = {
130
- x: o.x - i.width,
131
- y: u
163
+ coords = {
164
+ x: reference.x - floating.width,
165
+ y: commonY
132
166
  };
133
167
  break;
134
168
  default:
135
- f = {
136
- x: o.x,
137
- y: o.y
169
+ coords = {
170
+ x: reference.x,
171
+ y: reference.y
138
172
  };
139
173
  }
140
- switch (_(e)) {
174
+ switch (getAlignment(placement)) {
141
175
  case "start":
142
- f[r] -= p * (n && a ? -1 : 1);
176
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
143
177
  break;
144
178
  case "end":
145
- f[r] += p * (n && a ? -1 : 1);
179
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
146
180
  break;
147
181
  }
148
- return f;
182
+ return coords;
149
183
  }
150
- const Bt = async (t, e, n) => {
184
+ const computePosition$1 = async (reference, floating, config) => {
151
185
  const {
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++) {
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];
166
210
  const {
167
- name: w,
168
- fn: g
169
- } = l[m], {
170
- x: v,
211
+ x: nextX,
212
+ y: nextY,
213
+ data,
214
+ reset
215
+ } = await fn({
216
+ x,
171
217
  y,
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,
218
+ initialPlacement: placement,
219
+ placement: statefulPlacement,
220
+ strategy,
221
+ middlewareData,
222
+ rects,
223
+ platform: platform2,
183
224
  elements: {
184
- reference: t,
185
- floating: e
225
+ reference,
226
+ floating
186
227
  }
187
228
  });
188
- if (d = v ?? d, u = y ?? u, f = {
189
- ...f,
190
- [w]: {
191
- ...f[w],
192
- ...A
229
+ x = nextX != null ? nextX : x;
230
+ y = nextY != null ? nextY : y;
231
+ middlewareData = {
232
+ ...middlewareData,
233
+ [name]: {
234
+ ...middlewareData[name],
235
+ ...data
193
236
  }
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;
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;
203
257
  continue;
204
258
  }
205
259
  }
206
260
  return {
207
- x: d,
208
- y: u,
209
- placement: p,
210
- strategy: i,
211
- middlewareData: f
261
+ x,
262
+ y,
263
+ placement: statefulPlacement,
264
+ strategy,
265
+ middlewareData
212
266
  };
213
267
  };
214
- async function wt(t, e) {
215
- var n;
216
- e === void 0 && (e = {});
268
+ async function detectOverflow(state, options) {
269
+ var _await$platform$isEle;
270
+ if (options === void 0) {
271
+ options = {};
272
+ }
217
273
  const {
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
- } = K(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)) || {
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)) || {
240
304
  x: 1,
241
305
  y: 1
242
306
  } : {
243
307
  x: 1,
244
308
  y: 1
245
- }, x = et(s.convertOffsetParentRelativeRectToViewportRelativeRect ? await s.convertOffsetParentRelativeRectToViewportRelativeRect({
246
- rect: v,
247
- offsetParent: y,
248
- strategy: c
249
- }) : v);
309
+ };
310
+ const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
311
+ rect,
312
+ offsetParent,
313
+ strategy
314
+ }) : rect);
250
315
  return {
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
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
255
320
  };
256
321
  }
257
- const jt = (t) => ({
322
+ const arrow = (options) => ({
258
323
  name: "arrow",
259
- options: t,
260
- async fn(e) {
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;
261
335
  const {
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
- } = K(t, e) || {};
273
- if (a == null)
336
+ element,
337
+ padding = 0
338
+ } = evaluate(options, state) || {};
339
+ if (element == null) {
274
340
  return {};
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, F = E / 2 - m[h] / 2 - 1, Y = N(u[g], F), X = N(u[v], F), 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;
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;
282
371
  return {
283
- [f]: p[f] + W,
372
+ [axis]: coords[axis] + alignmentOffset,
284
373
  data: {
285
- [f]: S,
286
- centerOffset: C - S - W,
287
- ...D && {
288
- alignmentOffset: W
374
+ [axis]: offset2,
375
+ centerOffset: center - offset2 - alignmentOffset,
376
+ ...shouldAddOffset && {
377
+ alignmentOffset
289
378
  }
290
379
  },
291
- reset: D
380
+ reset: shouldAddOffset
292
381
  };
293
382
  }
294
- }), Vt = function(t) {
295
- return t === void 0 && (t = {}), {
383
+ });
384
+ const flip = function(options) {
385
+ if (options === void 0) {
386
+ options = {};
387
+ }
388
+ return {
296
389
  name: "flip",
297
- options: t,
298
- async fn(e) {
299
- var n, o;
390
+ options,
391
+ async fn(state) {
392
+ var _middlewareData$arrow, _middlewareData$flip;
300
393
  const {
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
- } = K(t, e);
316
- if ((n = s.arrow) != null && n.alignmentOffset)
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) {
317
411
  return {};
318
- const g = V(i), v = V(l) === l, y = await (c.isRTL == null ? void 0 : c.isRTL(a.floating)), A = p || (v || !m ? [tt(l)] : Ht(l));
319
- !p && h !== "none" && A.push(...Ft(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]]);
325
412
  }
326
- if (P = [...P, {
327
- placement: i,
328
- overflows: E
329
- }], !E.every((L) => L <= 0)) {
330
- var F, Y;
331
- const L = (((F = s.flip) == null ? void 0 : F.index) || 0) + 1, q = x[L];
332
- if (q)
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) {
333
440
  return {
334
441
  data: {
335
- index: L,
336
- overflows: P
442
+ index: nextIndex,
443
+ overflows: overflowsData
337
444
  },
338
445
  reset: {
339
- placement: q
446
+ placement: nextPlacement
340
447
  }
341
448
  };
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) {
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) {
345
453
  case "bestFit": {
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);
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
+ }
349
459
  break;
350
460
  }
351
461
  case "initialPlacement":
352
- C = l;
462
+ resetPlacement = initialPlacement;
353
463
  break;
354
464
  }
355
- if (i !== C)
465
+ }
466
+ if (placement !== resetPlacement) {
356
467
  return {
357
468
  reset: {
358
- placement: C
469
+ placement: resetPlacement
359
470
  }
360
471
  };
472
+ }
361
473
  }
362
474
  return {};
363
475
  }
364
476
  };
365
477
  };
366
- async function zt(t, e) {
478
+ async function convertValueToCoords(state, options) {
367
479
  const {
368
- placement: n,
369
- platform: o,
370
- elements: i
371
- } = t, s = await (o.isRTL == null ? void 0 : o.isRTL(i.floating)), r = V(n), l = _(n), c = nt(n) === "y", a = ["left", "top"].includes(r) ? -1 : 1, d = s && c ? -1 : 1, u = K(e, t);
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);
372
491
  let {
373
- mainAxis: p,
374
- crossAxis: f,
375
- alignmentAxis: h
376
- } = typeof u == "number" ? {
377
- mainAxis: u,
492
+ mainAxis,
493
+ crossAxis,
494
+ alignmentAxis
495
+ } = typeof rawValue === "number" ? {
496
+ mainAxis: rawValue,
378
497
  crossAxis: 0,
379
498
  alignmentAxis: null
380
499
  } : {
381
500
  mainAxis: 0,
382
501
  crossAxis: 0,
383
502
  alignmentAxis: null,
384
- ...u
503
+ ...rawValue
385
504
  };
386
- return l && typeof h == "number" && (f = l === "end" ? h * -1 : h), c ? {
387
- x: f * d,
388
- y: p * a
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
389
511
  } : {
390
- x: p * a,
391
- y: f * d
512
+ x: mainAxis * mainAxisMulti,
513
+ y: crossAxis * crossAxisMulti
392
514
  };
393
515
  }
394
- const $t = function(t) {
395
- return t === void 0 && (t = 0), {
516
+ const offset = function(options) {
517
+ if (options === void 0) {
518
+ options = 0;
519
+ }
520
+ return {
396
521
  name: "offset",
397
- options: t,
398
- async fn(e) {
522
+ options,
523
+ async fn(state) {
399
524
  const {
400
- x: n,
401
- y: o
402
- } = e, i = await zt(e, t);
525
+ x,
526
+ y
527
+ } = state;
528
+ const diffCoords = await convertValueToCoords(state, options);
403
529
  return {
404
- x: n + i.x,
405
- y: o + i.y,
406
- data: i
530
+ x: x + diffCoords.x,
531
+ y: y + diffCoords.y,
532
+ data: diffCoords
407
533
  };
408
534
  }
409
535
  };
410
- }, It = function(t) {
411
- return t === void 0 && (t = {}), {
536
+ };
537
+ const size = function(options) {
538
+ if (options === void 0) {
539
+ options = {};
540
+ }
541
+ return {
412
542
  name: "size",
413
- options: t,
414
- async fn(e) {
543
+ options,
544
+ async fn(state) {
545
+ const {
546
+ placement,
547
+ rects,
548
+ platform: platform2,
549
+ elements
550
+ } = state;
415
551
  const {
416
- placement: n,
417
- rects: o,
418
- platform: i,
419
- elements: s
420
- } = e, {
421
- apply: r = () => {
552
+ apply = () => {
422
553
  },
423
- ...l
424
- } = K(t, e), c = await wt(e, l), a = V(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;
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";
435
569
  } else {
436
- const b = f - c.top - c.bottom;
437
- y = d || v ? N(w, b) : b;
570
+ widthSide = side;
571
+ heightSide = alignment === "end" ? "top" : "bottom";
438
572
  }
439
- if (v && !d) {
440
- const b = R(c.left, 0), E = R(c.right, 0), P = R(c.top, 0), F = 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 || F !== 0 ? P + F : R(c.top, c.bottom));
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;
442
584
  }
443
- await r({
444
- ...e,
445
- availableWidth: A,
446
- availableHeight: y
447
- });
448
- const x = await i.getDimensions(s.floating);
449
- return p !== x.width || f !== x.height ? {
450
- reset: {
451
- rects: !0
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));
452
594
  }
453
- } : {};
595
+ }
596
+ await apply({
597
+ ...state,
598
+ availableWidth,
599
+ availableHeight
600
+ });
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 {};
454
610
  }
455
611
  };
456
612
  };
457
- function j(t) {
458
- return xt(t) ? (t.nodeName || "").toLowerCase() : "#document";
613
+ function getNodeName(node) {
614
+ if (isNode(node)) {
615
+ return (node.nodeName || "").toLowerCase();
616
+ }
617
+ return "#document";
459
618
  }
460
- function O(t) {
461
- var e;
462
- return (t == null || (e = t.ownerDocument) == null ? void 0 : e.defaultView) || window;
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;
463
622
  }
464
- function M(t) {
465
- var e;
466
- return (e = (xt(t) ? t.ownerDocument : t.document) || window.document) == null ? void 0 : e.documentElement;
623
+ function getDocumentElement(node) {
624
+ var _ref;
625
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
467
626
  }
468
- function xt(t) {
469
- return t instanceof Node || t instanceof O(t).Node;
627
+ function isNode(value) {
628
+ return value instanceof Node || value instanceof getWindow(value).Node;
470
629
  }
471
- function H(t) {
472
- return t instanceof Element || t instanceof O(t).Element;
630
+ function isElement(value) {
631
+ return value instanceof Element || value instanceof getWindow(value).Element;
473
632
  }
474
- function k(t) {
475
- return t instanceof HTMLElement || t instanceof O(t).HTMLElement;
633
+ function isHTMLElement(value) {
634
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
476
635
  }
477
- function dt(t) {
478
- return typeof ShadowRoot > "u" ? !1 : t instanceof ShadowRoot || t instanceof O(t).ShadowRoot;
636
+ function isShadowRoot(value) {
637
+ if (typeof ShadowRoot === "undefined") {
638
+ return false;
639
+ }
640
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
479
641
  }
480
- function G(t) {
642
+ function isOverflowElement(element) {
481
643
  const {
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(j(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 = I(t);
498
- for (; k(e) && !ot(e); ) {
499
- if (lt(e))
500
- return e;
501
- e = I(e);
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
+ }
502
667
  }
503
668
  return null;
504
669
  }
505
- function at() {
506
- return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
670
+ function isWebKit() {
671
+ if (typeof CSS === "undefined" || !CSS.supports)
672
+ return false;
673
+ return CSS.supports("-webkit-backdrop-filter", "none");
507
674
  }
508
- function ot(t) {
509
- return ["html", "body", "#document"].includes(j(t));
675
+ function isLastTraversableNode(node) {
676
+ return ["html", "body", "#document"].includes(getNodeName(node));
510
677
  }
511
- function T(t) {
512
- return O(t).getComputedStyle(t);
678
+ function getComputedStyle(element) {
679
+ return getWindow(element).getComputedStyle(element);
513
680
  }
514
- function it(t) {
515
- return H(t) ? {
516
- scrollLeft: t.scrollLeft,
517
- scrollTop: t.scrollTop
518
- } : {
519
- scrollLeft: t.pageXOffset,
520
- scrollTop: t.pageYOffset
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
521
691
  };
522
692
  }
523
- function I(t) {
524
- if (j(t) === "html")
525
- return t;
526
- const e = (
693
+ function getParentNode(node) {
694
+ if (getNodeName(node) === "html") {
695
+ return node;
696
+ }
697
+ const result = (
527
698
  // Step into the shadow DOM of the parent of a slotted node.
528
- t.assignedSlot || // DOM Element detected.
529
- t.parentNode || // ShadowRoot detected.
530
- dt(t) && t.host || // Fallback.
531
- M(t)
699
+ node.assignedSlot || // DOM Element detected.
700
+ node.parentNode || // ShadowRoot detected.
701
+ isShadowRoot(node) && node.host || // Fallback.
702
+ getDocumentElement(node)
532
703
  );
533
- return dt(e) ? e.host : e;
534
- }
535
- function vt(t) {
536
- const e = I(t);
537
- return ot(e) ? t.ownerDocument ? t.ownerDocument.body : t.body : k(e) && G(e) ? e : vt(e);
538
- }
539
- function J(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 || [], G(i) ? i : [], r.frameElement && n ? J(r.frameElement) : []) : e.concat(i, J(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
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
553
748
  };
554
749
  }
555
- function ft(t) {
556
- return H(t) ? t : t.contextElement;
557
- }
558
- function $(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
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
571
775
  };
572
776
  }
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
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
579
786
  };
580
787
  }
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 ? H(o) && (r = $(o)) : r = $(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 && H(o) ? O(o) : o;
593
- let h = p.frameElement;
594
- for (; h && o && f !== p; ) {
595
- const m = $(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
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
604
845
  });
605
846
  }
606
- function Ut(t) {
847
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
607
848
  let {
608
- rect: e,
609
- offsetParent: n,
610
- strategy: o
611
- } = t;
612
- const i = k(n), s = M(n);
613
- if (n === s)
614
- return e;
615
- let r = {
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 = {
616
859
  scrollLeft: 0,
617
860
  scrollTop: 0
618
- }, l = B(1);
619
- const c = B(0);
620
- if ((i || !i && o !== "fixed") && ((j(n) !== "body" || G(s)) && (r = it(n)), k(n))) {
621
- const a = z(n);
622
- l = $(n), c.x = a.x + n.clientLeft, c.y = a.y + n.clientTop;
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
+ }
623
874
  }
624
875
  return {
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
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
629
880
  };
630
881
  }
631
- function Jt(t) {
632
- return Array.from(t.getClientRects());
633
- }
634
- function At(t) {
635
- return z(M(t)).left + it(t).scrollLeft;
636
- }
637
- function Kt(t) {
638
- const e = M(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
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
646
904
  };
647
905
  }
648
- function Gt(t, e) {
649
- const n = O(t), o = M(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);
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
+ }
655
922
  }
656
923
  return {
657
- width: s,
658
- height: r,
659
- x: l,
660
- y: c
924
+ width,
925
+ height,
926
+ x,
927
+ y
661
928
  };
662
929
  }
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) ? $(t) : B(1), r = t.clientWidth * s.x, l = t.clientHeight * s.y, c = i * s.x, a = o * s.y;
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;
665
939
  return {
666
- width: r,
667
- height: l,
668
- x: c,
669
- y: a
940
+ width,
941
+ height,
942
+ x,
943
+ y
670
944
  };
671
945
  }
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 = Kt(M(t));
678
- else if (H(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
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
686
960
  };
687
961
  }
688
- return et(o);
962
+ return rectToClientRect(rect);
689
963
  }
690
- function Et(t, e) {
691
- const n = I(t);
692
- return n === e || !H(n) || ot(n) ? !1 : T(n).position === "fixed" || Et(n, e);
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);
693
970
  }
694
- function Zt(t, e) {
695
- const n = e.get(t);
696
- if (n)
697
- return n;
698
- let o = J(t, [], !1).filter((l) => H(l) && j(l) !== "body"), i = null;
699
- const s = T(t).position === "fixed";
700
- let r = s ? I(t) : t;
701
- for (; H(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) || G(r) && !c && Et(t, r)) ? o = o.filter((d) => d !== r) : i = l, r = I(r);
971
+ function getClippingElementAncestors(element, cache) {
972
+ const cachedResult = cache.get(element);
973
+ if (cachedResult) {
974
+ return cachedResult;
704
975
  }
705
- return e.set(t, o), o;
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;
706
996
  }
707
- function te(t) {
997
+ function getClippingRect(_ref) {
708
998
  let {
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));
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));
718
1015
  return {
719
- width: c.right - c.left,
720
- height: c.bottom - c.top,
721
- x: c.left,
722
- y: c.top
1016
+ width: clippingRect.right - clippingRect.left,
1017
+ height: clippingRect.bottom - clippingRect.top,
1018
+ x: clippingRect.left,
1019
+ y: clippingRect.top
723
1020
  };
724
1021
  }
725
- function ee(t) {
726
- return yt(t);
1022
+ function getDimensions(element) {
1023
+ return getCssDimensions(element);
727
1024
  }
728
- function ne(t, e, n) {
729
- const o = k(e), i = M(e), s = n === "fixed", r = z(t, !0, s, e);
730
- let l = {
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 = {
731
1031
  scrollLeft: 0,
732
1032
  scrollTop: 0
733
1033
  };
734
- const c = B(0);
735
- if (o || !o && !s)
736
- if ((j(e) !== "body" || G(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));
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
+ }
741
1047
  return {
742
- x: r.left + l.scrollLeft - c.x,
743
- y: r.top + l.scrollTop - c.y,
744
- width: r.width,
745
- height: r.height
1048
+ x: rect.left + scroll.scrollLeft - offsets.x,
1049
+ y: rect.top + scroll.scrollTop - offsets.y,
1050
+ width: rect.width,
1051
+ height: rect.height
746
1052
  };
747
1053
  }
748
- function mt(t, e) {
749
- return !k(t) || T(t).position === "fixed" ? null : e ? e(t) : t.offsetParent;
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;
750
1062
  }
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 && (j(o) === "html" || j(o) === "body" && T(o).position === "static" && !lt(o)) ? n : o || Yt(t) || n;
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;
759
1076
  }
760
- const oe = async function(t) {
1077
+ const getElementRects = async function(_ref) {
761
1078
  let {
762
- reference: e,
763
- floating: n,
764
- strategy: o
765
- } = t;
766
- const i = this.getOffsetParent || Ct, s = this.getDimensions;
1079
+ reference,
1080
+ floating,
1081
+ strategy
1082
+ } = _ref;
1083
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
1084
+ const getDimensionsFn = this.getDimensions;
767
1085
  return {
768
- reference: ne(e, await i(n), o),
1086
+ reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
769
1087
  floating: {
770
1088
  x: 0,
771
1089
  y: 0,
772
- ...await s(n)
1090
+ ...await getDimensionsFn(floating)
773
1091
  }
774
1092
  };
775
1093
  };
776
- function ie(t) {
777
- return T(t).direction === "rtl";
778
- }
779
- const se = {
780
- convertOffsetParentRelativeRectToViewportRelativeRect: Ut,
781
- getDocumentElement: M,
782
- getClippingRect: te,
783
- getOffsetParent: Ct,
784
- getElementRects: oe,
785
- getClientRects: Jt,
786
- getDimensions: ee,
787
- getScale: $,
788
- isElement: H,
789
- isRTL: ie
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
790
1108
  };
791
- function re(t, e) {
792
- let n = null, o;
793
- const i = M(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();
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();
799
1126
  const {
800
- left: a,
801
- top: d,
802
- width: u,
803
- height: p
804
- } = t.getBoundingClientRect();
805
- if (l || e(), !u || !p)
1127
+ left,
1128
+ top,
1129
+ width,
1130
+ height
1131
+ } = element.getBoundingClientRect();
1132
+ if (!skip) {
1133
+ onMove();
1134
+ }
1135
+ if (!width || !height) {
806
1136
  return;
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
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
810
1146
  };
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);
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
+ }
820
1161
  }
821
- y = !1;
1162
+ isFirstUpdate = false;
822
1163
  }
823
1164
  try {
824
- n = new IntersectionObserver(A, {
825
- ...v,
1165
+ io = new IntersectionObserver(handleObserve, {
1166
+ ...options,
826
1167
  // Handle <iframe>s
827
- root: i.ownerDocument
1168
+ root: root.ownerDocument
828
1169
  });
829
- } catch {
830
- n = new IntersectionObserver(A, v);
1170
+ } catch (e) {
1171
+ io = new IntersectionObserver(handleObserve, options);
831
1172
  }
832
- n.observe(t);
1173
+ io.observe(element);
833
1174
  }
834
- return r(!0), s;
1175
+ refresh(true);
1176
+ return cleanup;
835
1177
  }
836
- function ce(t, e, n, o) {
837
- o === void 0 && (o = {});
1178
+ function autoUpdate(reference, floating, update, options) {
1179
+ if (options === void 0) {
1180
+ options = {};
1181
+ }
838
1182
  const {
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 ? J(a) : [], ...J(e)] : [];
845
- d.forEach((g) => {
846
- i && g.addEventListener("scroll", n, {
847
- passive: !0
848
- }), s && g.addEventListener("resize", n);
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);
849
1196
  });
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);
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
+ }
868
1242
  };
869
1243
  }
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
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
877
1253
  };
878
- return Bt(t, e, {
879
- ...i,
880
- platform: s
1254
+ return computePosition$1(reference, floating, {
1255
+ ...mergedOptions,
1256
+ platform: platformWithCache
881
1257
  });
882
- }, ae = `: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}
883
- `;
884
- class fe extends Tt {
1258
+ };
1259
+ const styles = "/*\n[ WJ Popup ]\n*/\n:host {\n --wj-popup-top: auto;\n --wj-popup-left: auto;\n display: flex;\n}\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\n.native-popup:not(.popup-active) {\n display: none;\n}";
1260
+ class Popup extends WJElement {
885
1261
  constructor() {
886
1262
  super();
887
- ut(this, "className", "Popup");
888
- this._manual = !1;
1263
+ __publicField(this, "className", "Popup");
1264
+ this._manual = false;
889
1265
  }
890
- set manual(n) {
891
- this._manual = n;
1266
+ set manual(value) {
1267
+ this._manual = value;
892
1268
  }
893
1269
  get manual() {
894
- return this.hasAttribute("manual") && (this._manual = !0), this._manual;
1270
+ if (this.hasAttribute("manual"))
1271
+ this._manual = true;
1272
+ return this._manual;
895
1273
  }
896
1274
  static get cssStyleSheet() {
897
- return ae;
1275
+ return styles;
898
1276
  }
899
1277
  static get observedAttributes() {
900
1278
  return ["active"];
@@ -902,98 +1280,148 @@ class fe extends Tt {
902
1280
  setupAttributes() {
903
1281
  this.isShadowRoot = "open";
904
1282
  }
905
- attributeChangedCallback(n, o, i) {
906
- n === "active" && (this.hasAttribute(n) ? this.show() : this.hide());
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
1291
  }
908
- draw(n, o, i) {
909
- let s = document.createDocumentFragment(), r = document.createElement("slot");
910
- r.setAttribute("name", "anchor");
911
- let l = document.createElement("slot");
912
- l.setAttribute("name", "arrow");
913
- let c = document.createElement("div");
914
- c.setAttribute("part", "native"), c.classList.add("native-popup");
915
- let a = document.createElement("slot");
916
- return c.appendChild(a), c.appendChild(l), s.appendChild(r), s.appendChild(c), this.slotAnchor = r, this.slotArrow = l, this.native = c, s;
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;
917
1310
  }
918
- afterDraw(n, o, i) {
1311
+ afterDraw(context, store, params) {
919
1312
  this.setAnchor();
920
1313
  }
921
1314
  setAnchor() {
922
- if (this.slotAnchor && typeof this.anchor == "string") {
923
- const n = this.getRootNode();
924
- this.anchorEl = n.getElementById(this.anchor);
925
- } else
926
- this.slotAnchor instanceof HTMLSlotElement && (this.anchorEl = this.slotAnchor.assignedElements({ flatten: !0 })[0]);
927
- U.addListener(this.anchorEl, "click", null, (n) => {
928
- this.hasAttribute("disabled") || this.showHide();
929
- }, { stopPropagation: !0 }), document.addEventListener("click", (n) => {
930
- n.composedPath().some((i) => i === this) || this.hasAttribute("active") && this.removeAttribute("active");
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
+ if (this.hasAttribute("disabled"))
1323
+ return;
1324
+ this.showHide();
1325
+ }, { stopPropagation: true });
1326
+ document.addEventListener("click", (e) => {
1327
+ let clickToHost = e.composedPath().some((el) => el === this);
1328
+ if (!clickToHost) {
1329
+ if (this.hasAttribute("active"))
1330
+ this.removeAttribute("active");
1331
+ }
931
1332
  });
932
1333
  }
933
1334
  showHide() {
934
- this.hasAttribute("active") ? this.removeAttribute("active") : this.setAttribute("active", "");
1335
+ if (this.hasAttribute("active")) {
1336
+ this.removeAttribute("active");
1337
+ } else {
1338
+ this.setAttribute("active", "");
1339
+ }
935
1340
  }
936
1341
  reposition() {
937
- const n = [];
938
- this.offsetCalc = +this.offset || 0, this.slotArrow instanceof HTMLSlotElement && (this.arrow = this.slotArrow.assignedElements({ flatten: !0 })[0], this.arrow && (n.push(
939
- jt({
940
- element: this.arrow
941
- })
942
- ), this.offsetCalc = Math.sqrt(2 * this.arrow.offsetWidth ** 2) / 2 + +this.offset)), n.push(
943
- $t(this.offsetCalc)
944
- ), n.push(
945
- Vt()
946
- ), this.hasAttribute("size") && n.push(
947
- It({
948
- apply({ availableWidth: o, availableHeight: i, elements: s }) {
949
- Object.assign(s.floating.style, {
950
- width: `${s.reference.offsetWidth}px`
951
- });
952
- }
953
- })
954
- ), le(this.anchorEl, this.native, {
1342
+ const middleware = [];
1343
+ this.offsetCalc = +this.offset || 0;
1344
+ if (this.slotArrow instanceof HTMLSlotElement) {
1345
+ this.arrow = this.slotArrow.assignedElements({ flatten: true })[0];
1346
+ if (this.arrow) {
1347
+ middleware.push(
1348
+ arrow({
1349
+ element: this.arrow
1350
+ })
1351
+ );
1352
+ this.offsetCalc = Math.sqrt(2 * this.arrow.offsetWidth ** 2) / 2 + +this.offset;
1353
+ }
1354
+ }
1355
+ middleware.push(
1356
+ offset(this.offsetCalc)
1357
+ );
1358
+ middleware.push(
1359
+ flip()
1360
+ );
1361
+ if (this.hasAttribute("size")) {
1362
+ middleware.push(
1363
+ size({
1364
+ apply({ availableWidth, availableHeight, elements }) {
1365
+ Object.assign(elements.floating.style, {
1366
+ width: `${elements.reference.offsetWidth}px`
1367
+ });
1368
+ }
1369
+ })
1370
+ );
1371
+ }
1372
+ computePosition(this.anchorEl, this.native, {
955
1373
  placement: this.placement || "bottom",
956
1374
  strategy: "fixed",
957
- middleware: n
958
- }).then(({ x: o, y: i, middlewareData: s, placement: r, strategy: l }) => {
959
- 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) {
960
- const c = this.placement.split("-")[0], a = {
1375
+ middleware
1376
+ }).then(({ x, y, middlewareData, placement, strategy }) => {
1377
+ this.native.style.setProperty("--wj-popup-left", x + "px");
1378
+ this.native.style.setProperty("--wj-popup-top", y + "px");
1379
+ this.native.style.position = strategy;
1380
+ if (this.arrow) {
1381
+ const side = this.placement.split("-")[0];
1382
+ const staticSide = {
961
1383
  top: "bottom",
962
1384
  right: "left",
963
1385
  bottom: "top",
964
1386
  left: "right"
965
- }[c];
966
- if (s.arrow) {
967
- const { x: d, y: u } = s.arrow;
1387
+ }[side];
1388
+ if (middlewareData.arrow) {
1389
+ const { x: x2, y: y2 } = middlewareData.arrow;
968
1390
  Object.assign(this.arrow.style, {
969
- left: d != null ? `${d}px` : "",
970
- top: u != null ? `${u}px` : "",
971
- [a]: `${-this.arrow.offsetWidth / 2}px`
1391
+ left: x2 != null ? `${x2}px` : "",
1392
+ top: y2 != null ? `${y2}px` : "",
1393
+ [staticSide]: `${-this.arrow.offsetWidth / 2}px`
972
1394
  });
973
1395
  }
974
1396
  }
975
- }), U.dispatchCustomEvent(this, "wj-popup:reposition", {
1397
+ });
1398
+ event.dispatchCustomEvent(this, "wj-popup:reposition", {
976
1399
  data: { top: "bottom", right: "left", bottom: "top", left: "right" },
977
1400
  context: this,
978
1401
  event: this
979
1402
  });
980
1403
  }
981
1404
  show() {
982
- U.dispatchCustomEvent(this, "wj-popup:show"), this.native.classList.add("popup-active"), this.cleanup = ce(this.anchorEl, this.native, () => {
1405
+ event.dispatchCustomEvent(this, "wj-popup:show");
1406
+ this.native.classList.add("popup-active");
1407
+ this.cleanup = autoUpdate(this.anchorEl, this.native, () => {
983
1408
  this.reposition();
984
1409
  });
985
1410
  }
986
1411
  hide() {
987
- U.dispatchCustomEvent(this, "wj-popup:hide"), this.native.classList.remove("popup-active"), this.cleanup(), this.cleanup = void 0;
1412
+ event.dispatchCustomEvent(this, "wj-popup:hide");
1413
+ this.native.classList.remove("popup-active");
1414
+ this.cleanup();
1415
+ this.cleanup = void 0;
988
1416
  }
989
1417
  onHide() {
990
1418
  this.removeAttribute("active");
991
1419
  }
992
1420
  disconnectedCallback() {
993
- U.removeElement(this.anchorEl);
1421
+ event.removeElement(this.anchorEl);
994
1422
  }
995
1423
  }
996
- customElements.get("wj-popup") || window.customElements.define("wj-popup", fe);
1424
+ customElements.get("wj-popup") || window.customElements.define("wj-popup", Popup);
997
1425
  export {
998
- fe as Popup
1426
+ Popup
999
1427
  };