@getflip/swirl-components 0.432.0 → 0.433.0

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 (36) hide show
  1. package/components.json +1 -1
  2. package/dist/cjs/floating-ui.dom-C8bqk2dV.js +1624 -0
  3. package/dist/cjs/swirl-autocomplete.cjs.entry.js +4 -4
  4. package/dist/cjs/swirl-menu.cjs.entry.js +4 -4
  5. package/dist/cjs/swirl-popover_2.cjs.entry.js +6 -6
  6. package/dist/cjs/swirl-skeleton-box.cjs.entry.js +1 -1
  7. package/dist/cjs/swirl-tooltip.cjs.entry.js +10 -10
  8. package/dist/collection/components/swirl-skeleton-box/swirl-skeleton-box.css +1 -2
  9. package/dist/collection/components/swirl-tooltip/swirl-tooltip.js +3 -3
  10. package/dist/components/assets/pdfjs/pdf.worker.min.mjs +1 -1
  11. package/dist/components/floating-ui.dom.js +1617 -0
  12. package/dist/components/swirl-autocomplete.js +4 -4
  13. package/dist/components/swirl-menu.js +4 -4
  14. package/dist/components/swirl-popover2.js +6 -6
  15. package/dist/components/swirl-skeleton-box2.js +1 -1
  16. package/dist/components/swirl-tooltip2.js +10 -10
  17. package/dist/esm/floating-ui.dom-CLsTbQHn.js +1617 -0
  18. package/dist/esm/swirl-autocomplete.entry.js +4 -4
  19. package/dist/esm/swirl-menu.entry.js +4 -4
  20. package/dist/esm/swirl-popover_2.entry.js +6 -6
  21. package/dist/esm/swirl-skeleton-box.entry.js +1 -1
  22. package/dist/esm/swirl-tooltip.entry.js +10 -10
  23. package/dist/swirl-components/p-13d33aa2.entry.js +1 -0
  24. package/dist/swirl-components/{p-f53180cb.entry.js → p-322f18d4.entry.js} +1 -1
  25. package/dist/swirl-components/p-52737e44.entry.js +1 -0
  26. package/dist/swirl-components/{p-35461505.entry.js → p-8d0be9c3.entry.js} +1 -1
  27. package/dist/swirl-components/p-CLsTbQHn.js +1 -0
  28. package/dist/swirl-components/{p-85371da0.entry.js → p-c8c1b0b2.entry.js} +1 -1
  29. package/dist/swirl-components/swirl-components.esm.js +1 -1
  30. package/package.json +2 -2
  31. package/dist/cjs/floating-ui.dom.browser.min-PA1q-Uql.js +0 -12
  32. package/dist/components/floating-ui.dom.browser.min.js +0 -5
  33. package/dist/esm/floating-ui.dom.browser.min-BtsCuEVE.js +0 -5
  34. package/dist/swirl-components/p-5c638e8c.entry.js +0 -1
  35. package/dist/swirl-components/p-BtsCuEVE.js +0 -1
  36. package/dist/swirl-components/p-de985b44.entry.js +0 -1
@@ -0,0 +1,1624 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Custom positioning reference element.
5
+ * @see https://floating-ui.com/docs/virtual-elements
6
+ */
7
+
8
+ const min = Math.min;
9
+ const max = Math.max;
10
+ const round = Math.round;
11
+ const floor = Math.floor;
12
+ const createCoords = v => ({
13
+ x: v,
14
+ y: v
15
+ });
16
+ const oppositeSideMap = {
17
+ left: 'right',
18
+ right: 'left',
19
+ bottom: 'top',
20
+ top: 'bottom'
21
+ };
22
+ const oppositeAlignmentMap = {
23
+ start: 'end',
24
+ end: 'start'
25
+ };
26
+ function clamp(start, value, end) {
27
+ return max(start, min(value, end));
28
+ }
29
+ function evaluate(value, param) {
30
+ return typeof value === 'function' ? value(param) : value;
31
+ }
32
+ function getSide(placement) {
33
+ return placement.split('-')[0];
34
+ }
35
+ function getAlignment(placement) {
36
+ return placement.split('-')[1];
37
+ }
38
+ function getOppositeAxis(axis) {
39
+ return axis === 'x' ? 'y' : 'x';
40
+ }
41
+ function getAxisLength(axis) {
42
+ return axis === 'y' ? 'height' : 'width';
43
+ }
44
+ const yAxisSides = /*#__PURE__*/new Set(['top', 'bottom']);
45
+ function getSideAxis(placement) {
46
+ return yAxisSides.has(getSide(placement)) ? 'y' : 'x';
47
+ }
48
+ function getAlignmentAxis(placement) {
49
+ return getOppositeAxis(getSideAxis(placement));
50
+ }
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)];
63
+ }
64
+ function getExpandedPlacements(placement) {
65
+ const oppositePlacement = getOppositePlacement(placement);
66
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
67
+ }
68
+ function getOppositeAlignmentPlacement(placement) {
69
+ return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
70
+ }
71
+ const lrPlacement = ['left', 'right'];
72
+ const rlPlacement = ['right', 'left'];
73
+ const tbPlacement = ['top', 'bottom'];
74
+ const btPlacement = ['bottom', 'top'];
75
+ function getSideList(side, isStart, rtl) {
76
+ switch (side) {
77
+ case 'top':
78
+ case 'bottom':
79
+ if (rtl) return isStart ? rlPlacement : lrPlacement;
80
+ return isStart ? lrPlacement : rlPlacement;
81
+ case 'left':
82
+ case 'right':
83
+ return isStart ? tbPlacement : btPlacement;
84
+ default:
85
+ return [];
86
+ }
87
+ }
88
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
89
+ const alignment = getAlignment(placement);
90
+ let list = getSideList(getSide(placement), direction === 'start', rtl);
91
+ if (alignment) {
92
+ list = list.map(side => side + "-" + alignment);
93
+ if (flipAlignment) {
94
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
95
+ }
96
+ }
97
+ return list;
98
+ }
99
+ function getOppositePlacement(placement) {
100
+ return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
101
+ }
102
+ function expandPaddingObject(padding) {
103
+ return {
104
+ top: 0,
105
+ right: 0,
106
+ bottom: 0,
107
+ left: 0,
108
+ ...padding
109
+ };
110
+ }
111
+ function getPaddingObject(padding) {
112
+ return typeof padding !== 'number' ? expandPaddingObject(padding) : {
113
+ top: padding,
114
+ right: padding,
115
+ bottom: padding,
116
+ left: padding
117
+ };
118
+ }
119
+ function rectToClientRect(rect) {
120
+ const {
121
+ x,
122
+ y,
123
+ width,
124
+ height
125
+ } = rect;
126
+ return {
127
+ width,
128
+ height,
129
+ top: y,
130
+ left: x,
131
+ right: x + width,
132
+ bottom: y + height,
133
+ x,
134
+ y
135
+ };
136
+ }
137
+
138
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
139
+ let {
140
+ reference,
141
+ floating
142
+ } = _ref;
143
+ const sideAxis = getSideAxis(placement);
144
+ const alignmentAxis = getAlignmentAxis(placement);
145
+ const alignLength = getAxisLength(alignmentAxis);
146
+ const side = getSide(placement);
147
+ const isVertical = sideAxis === 'y';
148
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
149
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
150
+ const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
151
+ let coords;
152
+ switch (side) {
153
+ case 'top':
154
+ coords = {
155
+ x: commonX,
156
+ y: reference.y - floating.height
157
+ };
158
+ break;
159
+ case 'bottom':
160
+ coords = {
161
+ x: commonX,
162
+ y: reference.y + reference.height
163
+ };
164
+ break;
165
+ case 'right':
166
+ coords = {
167
+ x: reference.x + reference.width,
168
+ y: commonY
169
+ };
170
+ break;
171
+ case 'left':
172
+ coords = {
173
+ x: reference.x - floating.width,
174
+ y: commonY
175
+ };
176
+ break;
177
+ default:
178
+ coords = {
179
+ x: reference.x,
180
+ y: reference.y
181
+ };
182
+ }
183
+ switch (getAlignment(placement)) {
184
+ case 'start':
185
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
186
+ break;
187
+ case 'end':
188
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
189
+ break;
190
+ }
191
+ return coords;
192
+ }
193
+
194
+ /**
195
+ * Resolves with an object of overflow side offsets that determine how much the
196
+ * element is overflowing a given clipping boundary on each side.
197
+ * - positive = overflowing the boundary by that number of pixels
198
+ * - negative = how many pixels left before it will overflow
199
+ * - 0 = lies flush with the boundary
200
+ * @see https://floating-ui.com/docs/detectOverflow
201
+ */
202
+ async function detectOverflow(state, options) {
203
+ var _await$platform$isEle;
204
+ if (options === void 0) {
205
+ options = {};
206
+ }
207
+ const {
208
+ x,
209
+ y,
210
+ platform,
211
+ rects,
212
+ elements,
213
+ strategy
214
+ } = state;
215
+ const {
216
+ boundary = 'clippingAncestors',
217
+ rootBoundary = 'viewport',
218
+ elementContext = 'floating',
219
+ altBoundary = false,
220
+ padding = 0
221
+ } = evaluate(options, state);
222
+ const paddingObject = getPaddingObject(padding);
223
+ const altContext = elementContext === 'floating' ? 'reference' : 'floating';
224
+ const element = elements[altBoundary ? altContext : elementContext];
225
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
226
+ element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
227
+ boundary,
228
+ rootBoundary,
229
+ strategy
230
+ }));
231
+ const rect = elementContext === 'floating' ? {
232
+ x,
233
+ y,
234
+ width: rects.floating.width,
235
+ height: rects.floating.height
236
+ } : rects.reference;
237
+ const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
238
+ const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
239
+ x: 1,
240
+ y: 1
241
+ } : {
242
+ x: 1,
243
+ y: 1
244
+ };
245
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
246
+ elements,
247
+ rect,
248
+ offsetParent,
249
+ strategy
250
+ }) : rect);
251
+ return {
252
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
253
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
254
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
255
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
256
+ };
257
+ }
258
+
259
+ /**
260
+ * Computes the `x` and `y` coordinates that will place the floating element
261
+ * next to a given reference element.
262
+ *
263
+ * This export does not have any `platform` interface logic. You will need to
264
+ * write one for the platform you are using Floating UI with.
265
+ */
266
+ const computePosition$1 = async (reference, floating, config) => {
267
+ const {
268
+ placement = 'bottom',
269
+ strategy = 'absolute',
270
+ middleware = [],
271
+ platform
272
+ } = config;
273
+ const validMiddleware = middleware.filter(Boolean);
274
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
275
+ let rects = await platform.getElementRects({
276
+ reference,
277
+ floating,
278
+ strategy
279
+ });
280
+ let {
281
+ x,
282
+ y
283
+ } = computeCoordsFromPlacement(rects, placement, rtl);
284
+ let statefulPlacement = placement;
285
+ let middlewareData = {};
286
+ let resetCount = 0;
287
+ for (let i = 0; i < validMiddleware.length; i++) {
288
+ var _platform$detectOverf;
289
+ const {
290
+ name,
291
+ fn
292
+ } = validMiddleware[i];
293
+ const {
294
+ x: nextX,
295
+ y: nextY,
296
+ data,
297
+ reset
298
+ } = await fn({
299
+ x,
300
+ y,
301
+ initialPlacement: placement,
302
+ placement: statefulPlacement,
303
+ strategy,
304
+ middlewareData,
305
+ rects,
306
+ platform: {
307
+ ...platform,
308
+ detectOverflow: (_platform$detectOverf = platform.detectOverflow) != null ? _platform$detectOverf : detectOverflow
309
+ },
310
+ elements: {
311
+ reference,
312
+ floating
313
+ }
314
+ });
315
+ x = nextX != null ? nextX : x;
316
+ y = nextY != null ? nextY : y;
317
+ middlewareData = {
318
+ ...middlewareData,
319
+ [name]: {
320
+ ...middlewareData[name],
321
+ ...data
322
+ }
323
+ };
324
+ if (reset && resetCount <= 50) {
325
+ resetCount++;
326
+ if (typeof reset === 'object') {
327
+ if (reset.placement) {
328
+ statefulPlacement = reset.placement;
329
+ }
330
+ if (reset.rects) {
331
+ rects = reset.rects === true ? await platform.getElementRects({
332
+ reference,
333
+ floating,
334
+ strategy
335
+ }) : reset.rects;
336
+ }
337
+ ({
338
+ x,
339
+ y
340
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
341
+ }
342
+ i = -1;
343
+ }
344
+ }
345
+ return {
346
+ x,
347
+ y,
348
+ placement: statefulPlacement,
349
+ strategy,
350
+ middlewareData
351
+ };
352
+ };
353
+
354
+ /**
355
+ * Provides data to position an inner element of the floating element so that it
356
+ * appears centered to the reference element.
357
+ * @see https://floating-ui.com/docs/arrow
358
+ */
359
+ const arrow$1 = options => ({
360
+ name: 'arrow',
361
+ options,
362
+ async fn(state) {
363
+ const {
364
+ x,
365
+ y,
366
+ placement,
367
+ rects,
368
+ platform,
369
+ elements,
370
+ middlewareData
371
+ } = state;
372
+ // Since `element` is required, we don't Partial<> the type.
373
+ const {
374
+ element,
375
+ padding = 0
376
+ } = evaluate(options, state) || {};
377
+ if (element == null) {
378
+ return {};
379
+ }
380
+ const paddingObject = getPaddingObject(padding);
381
+ const coords = {
382
+ x,
383
+ y
384
+ };
385
+ const axis = getAlignmentAxis(placement);
386
+ const length = getAxisLength(axis);
387
+ const arrowDimensions = await platform.getDimensions(element);
388
+ const isYAxis = axis === 'y';
389
+ const minProp = isYAxis ? 'top' : 'left';
390
+ const maxProp = isYAxis ? 'bottom' : 'right';
391
+ const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
392
+ const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
393
+ const startDiff = coords[axis] - rects.reference[axis];
394
+ const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
395
+ let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
396
+
397
+ // DOM platform can return `window` as the `offsetParent`.
398
+ if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
399
+ clientSize = elements.floating[clientProp] || rects.floating[length];
400
+ }
401
+ const centerToReference = endDiff / 2 - startDiff / 2;
402
+
403
+ // If the padding is large enough that it causes the arrow to no longer be
404
+ // centered, modify the padding so that it is centered.
405
+ const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
406
+ const minPadding = min(paddingObject[minProp], largestPossiblePadding);
407
+ const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
408
+
409
+ // Make sure the arrow doesn't overflow the floating element if the center
410
+ // point is outside the floating element's bounds.
411
+ const min$1 = minPadding;
412
+ const max = clientSize - arrowDimensions[length] - maxPadding;
413
+ const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
414
+ const offset = clamp(min$1, center, max);
415
+
416
+ // If the reference is small enough that the arrow's padding causes it to
417
+ // to point to nothing for an aligned placement, adjust the offset of the
418
+ // floating element itself. To ensure `shift()` continues to take action,
419
+ // a single reset is performed when this is true.
420
+ const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
421
+ const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
422
+ return {
423
+ [axis]: coords[axis] + alignmentOffset,
424
+ data: {
425
+ [axis]: offset,
426
+ centerOffset: center - offset - alignmentOffset,
427
+ ...(shouldAddOffset && {
428
+ alignmentOffset
429
+ })
430
+ },
431
+ reset: shouldAddOffset
432
+ };
433
+ }
434
+ });
435
+
436
+ /**
437
+ * Optimizes the visibility of the floating element by flipping the `placement`
438
+ * in order to keep it in view when the preferred placement(s) will overflow the
439
+ * clipping boundary. Alternative to `autoPlacement`.
440
+ * @see https://floating-ui.com/docs/flip
441
+ */
442
+ const flip$1 = function (options) {
443
+ if (options === void 0) {
444
+ options = {};
445
+ }
446
+ return {
447
+ name: 'flip',
448
+ options,
449
+ async fn(state) {
450
+ var _middlewareData$arrow, _middlewareData$flip;
451
+ const {
452
+ placement,
453
+ middlewareData,
454
+ rects,
455
+ initialPlacement,
456
+ platform,
457
+ elements
458
+ } = state;
459
+ const {
460
+ mainAxis: checkMainAxis = true,
461
+ crossAxis: checkCrossAxis = true,
462
+ fallbackPlacements: specifiedFallbackPlacements,
463
+ fallbackStrategy = 'bestFit',
464
+ fallbackAxisSideDirection = 'none',
465
+ flipAlignment = true,
466
+ ...detectOverflowOptions
467
+ } = evaluate(options, state);
468
+
469
+ // If a reset by the arrow was caused due to an alignment offset being
470
+ // added, we should skip any logic now since `flip()` has already done its
471
+ // work.
472
+ // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
473
+ if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
474
+ return {};
475
+ }
476
+ const side = getSide(placement);
477
+ const initialSideAxis = getSideAxis(initialPlacement);
478
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
479
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
480
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
481
+ const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
482
+ if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
483
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
484
+ }
485
+ const placements = [initialPlacement, ...fallbackPlacements];
486
+ const overflow = await platform.detectOverflow(state, detectOverflowOptions);
487
+ const overflows = [];
488
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
489
+ if (checkMainAxis) {
490
+ overflows.push(overflow[side]);
491
+ }
492
+ if (checkCrossAxis) {
493
+ const sides = getAlignmentSides(placement, rects, rtl);
494
+ overflows.push(overflow[sides[0]], overflow[sides[1]]);
495
+ }
496
+ overflowsData = [...overflowsData, {
497
+ placement,
498
+ overflows
499
+ }];
500
+
501
+ // One or more sides is overflowing.
502
+ if (!overflows.every(side => side <= 0)) {
503
+ var _middlewareData$flip2, _overflowsData$filter;
504
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
505
+ const nextPlacement = placements[nextIndex];
506
+ if (nextPlacement) {
507
+ const ignoreCrossAxisOverflow = checkCrossAxis === 'alignment' ? initialSideAxis !== getSideAxis(nextPlacement) : false;
508
+ if (!ignoreCrossAxisOverflow ||
509
+ // We leave the current main axis only if every placement on that axis
510
+ // overflows the main axis.
511
+ overflowsData.every(d => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
512
+ // Try next placement and re-run the lifecycle.
513
+ return {
514
+ data: {
515
+ index: nextIndex,
516
+ overflows: overflowsData
517
+ },
518
+ reset: {
519
+ placement: nextPlacement
520
+ }
521
+ };
522
+ }
523
+ }
524
+
525
+ // First, find the candidates that fit on the mainAxis side of overflow,
526
+ // then find the placement that fits the best on the main crossAxis side.
527
+ 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;
528
+
529
+ // Otherwise fallback.
530
+ if (!resetPlacement) {
531
+ switch (fallbackStrategy) {
532
+ case 'bestFit':
533
+ {
534
+ var _overflowsData$filter2;
535
+ const placement = (_overflowsData$filter2 = overflowsData.filter(d => {
536
+ if (hasFallbackAxisSideDirection) {
537
+ const currentSideAxis = getSideAxis(d.placement);
538
+ return currentSideAxis === initialSideAxis ||
539
+ // Create a bias to the `y` side axis due to horizontal
540
+ // reading directions favoring greater width.
541
+ currentSideAxis === 'y';
542
+ }
543
+ return true;
544
+ }).map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
545
+ if (placement) {
546
+ resetPlacement = placement;
547
+ }
548
+ break;
549
+ }
550
+ case 'initialPlacement':
551
+ resetPlacement = initialPlacement;
552
+ break;
553
+ }
554
+ }
555
+ if (placement !== resetPlacement) {
556
+ return {
557
+ reset: {
558
+ placement: resetPlacement
559
+ }
560
+ };
561
+ }
562
+ }
563
+ return {};
564
+ }
565
+ };
566
+ };
567
+
568
+ const originSides = /*#__PURE__*/new Set(['left', 'top']);
569
+
570
+ // For type backwards-compatibility, the `OffsetOptions` type was also
571
+ // Derivable.
572
+
573
+ async function convertValueToCoords(state, options) {
574
+ const {
575
+ placement,
576
+ platform,
577
+ elements
578
+ } = state;
579
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
580
+ const side = getSide(placement);
581
+ const alignment = getAlignment(placement);
582
+ const isVertical = getSideAxis(placement) === 'y';
583
+ const mainAxisMulti = originSides.has(side) ? -1 : 1;
584
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
585
+ const rawValue = evaluate(options, state);
586
+
587
+ // eslint-disable-next-line prefer-const
588
+ let {
589
+ mainAxis,
590
+ crossAxis,
591
+ alignmentAxis
592
+ } = typeof rawValue === 'number' ? {
593
+ mainAxis: rawValue,
594
+ crossAxis: 0,
595
+ alignmentAxis: null
596
+ } : {
597
+ mainAxis: rawValue.mainAxis || 0,
598
+ crossAxis: rawValue.crossAxis || 0,
599
+ alignmentAxis: rawValue.alignmentAxis
600
+ };
601
+ if (alignment && typeof alignmentAxis === 'number') {
602
+ crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
603
+ }
604
+ return isVertical ? {
605
+ x: crossAxis * crossAxisMulti,
606
+ y: mainAxis * mainAxisMulti
607
+ } : {
608
+ x: mainAxis * mainAxisMulti,
609
+ y: crossAxis * crossAxisMulti
610
+ };
611
+ }
612
+
613
+ /**
614
+ * Modifies the placement by translating the floating element along the
615
+ * specified axes.
616
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
617
+ * object may be passed.
618
+ * @see https://floating-ui.com/docs/offset
619
+ */
620
+ const offset$1 = function (options) {
621
+ if (options === void 0) {
622
+ options = 0;
623
+ }
624
+ return {
625
+ name: 'offset',
626
+ options,
627
+ async fn(state) {
628
+ var _middlewareData$offse, _middlewareData$arrow;
629
+ const {
630
+ x,
631
+ y,
632
+ placement,
633
+ middlewareData
634
+ } = state;
635
+ const diffCoords = await convertValueToCoords(state, options);
636
+
637
+ // If the placement is the same and the arrow caused an alignment offset
638
+ // then we don't need to change the positioning coordinates.
639
+ if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
640
+ return {};
641
+ }
642
+ return {
643
+ x: x + diffCoords.x,
644
+ y: y + diffCoords.y,
645
+ data: {
646
+ ...diffCoords,
647
+ placement
648
+ }
649
+ };
650
+ }
651
+ };
652
+ };
653
+
654
+ /**
655
+ * Optimizes the visibility of the floating element by shifting it in order to
656
+ * keep it in view when it will overflow the clipping boundary.
657
+ * @see https://floating-ui.com/docs/shift
658
+ */
659
+ const shift$1 = function (options) {
660
+ if (options === void 0) {
661
+ options = {};
662
+ }
663
+ return {
664
+ name: 'shift',
665
+ options,
666
+ async fn(state) {
667
+ const {
668
+ x,
669
+ y,
670
+ placement,
671
+ platform
672
+ } = state;
673
+ const {
674
+ mainAxis: checkMainAxis = true,
675
+ crossAxis: checkCrossAxis = false,
676
+ limiter = {
677
+ fn: _ref => {
678
+ let {
679
+ x,
680
+ y
681
+ } = _ref;
682
+ return {
683
+ x,
684
+ y
685
+ };
686
+ }
687
+ },
688
+ ...detectOverflowOptions
689
+ } = evaluate(options, state);
690
+ const coords = {
691
+ x,
692
+ y
693
+ };
694
+ const overflow = await platform.detectOverflow(state, detectOverflowOptions);
695
+ const crossAxis = getSideAxis(getSide(placement));
696
+ const mainAxis = getOppositeAxis(crossAxis);
697
+ let mainAxisCoord = coords[mainAxis];
698
+ let crossAxisCoord = coords[crossAxis];
699
+ if (checkMainAxis) {
700
+ const minSide = mainAxis === 'y' ? 'top' : 'left';
701
+ const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
702
+ const min = mainAxisCoord + overflow[minSide];
703
+ const max = mainAxisCoord - overflow[maxSide];
704
+ mainAxisCoord = clamp(min, mainAxisCoord, max);
705
+ }
706
+ if (checkCrossAxis) {
707
+ const minSide = crossAxis === 'y' ? 'top' : 'left';
708
+ const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
709
+ const min = crossAxisCoord + overflow[minSide];
710
+ const max = crossAxisCoord - overflow[maxSide];
711
+ crossAxisCoord = clamp(min, crossAxisCoord, max);
712
+ }
713
+ const limitedCoords = limiter.fn({
714
+ ...state,
715
+ [mainAxis]: mainAxisCoord,
716
+ [crossAxis]: crossAxisCoord
717
+ });
718
+ return {
719
+ ...limitedCoords,
720
+ data: {
721
+ x: limitedCoords.x - x,
722
+ y: limitedCoords.y - y,
723
+ enabled: {
724
+ [mainAxis]: checkMainAxis,
725
+ [crossAxis]: checkCrossAxis
726
+ }
727
+ }
728
+ };
729
+ }
730
+ };
731
+ };
732
+
733
+ function hasWindow() {
734
+ return typeof window !== 'undefined';
735
+ }
736
+ function getNodeName(node) {
737
+ if (isNode(node)) {
738
+ return (node.nodeName || '').toLowerCase();
739
+ }
740
+ // Mocked nodes in testing environments may not be instances of Node. By
741
+ // returning `#document` an infinite loop won't occur.
742
+ // https://github.com/floating-ui/floating-ui/issues/2317
743
+ return '#document';
744
+ }
745
+ function getWindow(node) {
746
+ var _node$ownerDocument;
747
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
748
+ }
749
+ function getDocumentElement(node) {
750
+ var _ref;
751
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
752
+ }
753
+ function isNode(value) {
754
+ if (!hasWindow()) {
755
+ return false;
756
+ }
757
+ return value instanceof Node || value instanceof getWindow(value).Node;
758
+ }
759
+ function isElement(value) {
760
+ if (!hasWindow()) {
761
+ return false;
762
+ }
763
+ return value instanceof Element || value instanceof getWindow(value).Element;
764
+ }
765
+ function isHTMLElement(value) {
766
+ if (!hasWindow()) {
767
+ return false;
768
+ }
769
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
770
+ }
771
+ function isShadowRoot(value) {
772
+ if (!hasWindow() || typeof ShadowRoot === 'undefined') {
773
+ return false;
774
+ }
775
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
776
+ }
777
+ const invalidOverflowDisplayValues = /*#__PURE__*/new Set(['inline', 'contents']);
778
+ function isOverflowElement(element) {
779
+ const {
780
+ overflow,
781
+ overflowX,
782
+ overflowY,
783
+ display
784
+ } = getComputedStyle$1(element);
785
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
786
+ }
787
+ const tableElements = /*#__PURE__*/new Set(['table', 'td', 'th']);
788
+ function isTableElement(element) {
789
+ return tableElements.has(getNodeName(element));
790
+ }
791
+ const topLayerSelectors = [':popover-open', ':modal'];
792
+ function isTopLayer(element) {
793
+ return topLayerSelectors.some(selector => {
794
+ try {
795
+ return element.matches(selector);
796
+ } catch (_e) {
797
+ return false;
798
+ }
799
+ });
800
+ }
801
+ const transformProperties = ['transform', 'translate', 'scale', 'rotate', 'perspective'];
802
+ const willChangeValues = ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'];
803
+ const containValues = ['paint', 'layout', 'strict', 'content'];
804
+ function isContainingBlock(elementOrCss) {
805
+ const webkit = isWebKit();
806
+ const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
807
+
808
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
809
+ // https://drafts.csswg.org/css-transforms-2/#individual-transforms
810
+ return transformProperties.some(value => css[value] ? css[value] !== 'none' : false) || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || willChangeValues.some(value => (css.willChange || '').includes(value)) || containValues.some(value => (css.contain || '').includes(value));
811
+ }
812
+ function getContainingBlock(element) {
813
+ let currentNode = getParentNode(element);
814
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
815
+ if (isContainingBlock(currentNode)) {
816
+ return currentNode;
817
+ } else if (isTopLayer(currentNode)) {
818
+ return null;
819
+ }
820
+ currentNode = getParentNode(currentNode);
821
+ }
822
+ return null;
823
+ }
824
+ function isWebKit() {
825
+ if (typeof CSS === 'undefined' || !CSS.supports) return false;
826
+ return CSS.supports('-webkit-backdrop-filter', 'none');
827
+ }
828
+ const lastTraversableNodeNames = /*#__PURE__*/new Set(['html', 'body', '#document']);
829
+ function isLastTraversableNode(node) {
830
+ return lastTraversableNodeNames.has(getNodeName(node));
831
+ }
832
+ function getComputedStyle$1(element) {
833
+ return getWindow(element).getComputedStyle(element);
834
+ }
835
+ function getNodeScroll(element) {
836
+ if (isElement(element)) {
837
+ return {
838
+ scrollLeft: element.scrollLeft,
839
+ scrollTop: element.scrollTop
840
+ };
841
+ }
842
+ return {
843
+ scrollLeft: element.scrollX,
844
+ scrollTop: element.scrollY
845
+ };
846
+ }
847
+ function getParentNode(node) {
848
+ if (getNodeName(node) === 'html') {
849
+ return node;
850
+ }
851
+ const result =
852
+ // Step into the shadow DOM of the parent of a slotted node.
853
+ node.assignedSlot ||
854
+ // DOM Element detected.
855
+ node.parentNode ||
856
+ // ShadowRoot detected.
857
+ isShadowRoot(node) && node.host ||
858
+ // Fallback.
859
+ getDocumentElement(node);
860
+ return isShadowRoot(result) ? result.host : result;
861
+ }
862
+ function getNearestOverflowAncestor(node) {
863
+ const parentNode = getParentNode(node);
864
+ if (isLastTraversableNode(parentNode)) {
865
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
866
+ }
867
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
868
+ return parentNode;
869
+ }
870
+ return getNearestOverflowAncestor(parentNode);
871
+ }
872
+ function getOverflowAncestors(node, list, traverseIframes) {
873
+ var _node$ownerDocument2;
874
+ if (list === void 0) {
875
+ list = [];
876
+ }
877
+ if (traverseIframes === void 0) {
878
+ traverseIframes = true;
879
+ }
880
+ const scrollableAncestor = getNearestOverflowAncestor(node);
881
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
882
+ const win = getWindow(scrollableAncestor);
883
+ if (isBody) {
884
+ const frameElement = getFrameElement(win);
885
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
886
+ }
887
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
888
+ }
889
+ function getFrameElement(win) {
890
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
891
+ }
892
+
893
+ function getCssDimensions(element) {
894
+ const css = getComputedStyle$1(element);
895
+ // In testing environments, the `width` and `height` properties are empty
896
+ // strings for SVG elements, returning NaN. Fallback to `0` in this case.
897
+ let width = parseFloat(css.width) || 0;
898
+ let height = parseFloat(css.height) || 0;
899
+ const hasOffset = isHTMLElement(element);
900
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
901
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
902
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
903
+ if (shouldFallback) {
904
+ width = offsetWidth;
905
+ height = offsetHeight;
906
+ }
907
+ return {
908
+ width,
909
+ height,
910
+ $: shouldFallback
911
+ };
912
+ }
913
+
914
+ function unwrapElement(element) {
915
+ return !isElement(element) ? element.contextElement : element;
916
+ }
917
+
918
+ function getScale(element) {
919
+ const domElement = unwrapElement(element);
920
+ if (!isHTMLElement(domElement)) {
921
+ return createCoords(1);
922
+ }
923
+ const rect = domElement.getBoundingClientRect();
924
+ const {
925
+ width,
926
+ height,
927
+ $
928
+ } = getCssDimensions(domElement);
929
+ let x = ($ ? round(rect.width) : rect.width) / width;
930
+ let y = ($ ? round(rect.height) : rect.height) / height;
931
+
932
+ // 0, NaN, or Infinity should always fallback to 1.
933
+
934
+ if (!x || !Number.isFinite(x)) {
935
+ x = 1;
936
+ }
937
+ if (!y || !Number.isFinite(y)) {
938
+ y = 1;
939
+ }
940
+ return {
941
+ x,
942
+ y
943
+ };
944
+ }
945
+
946
+ const noOffsets = /*#__PURE__*/createCoords(0);
947
+ function getVisualOffsets(element) {
948
+ const win = getWindow(element);
949
+ if (!isWebKit() || !win.visualViewport) {
950
+ return noOffsets;
951
+ }
952
+ return {
953
+ x: win.visualViewport.offsetLeft,
954
+ y: win.visualViewport.offsetTop
955
+ };
956
+ }
957
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
958
+ if (isFixed === void 0) {
959
+ isFixed = false;
960
+ }
961
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
962
+ return false;
963
+ }
964
+ return isFixed;
965
+ }
966
+
967
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
968
+ if (includeScale === void 0) {
969
+ includeScale = false;
970
+ }
971
+ if (isFixedStrategy === void 0) {
972
+ isFixedStrategy = false;
973
+ }
974
+ const clientRect = element.getBoundingClientRect();
975
+ const domElement = unwrapElement(element);
976
+ let scale = createCoords(1);
977
+ if (includeScale) {
978
+ if (offsetParent) {
979
+ if (isElement(offsetParent)) {
980
+ scale = getScale(offsetParent);
981
+ }
982
+ } else {
983
+ scale = getScale(element);
984
+ }
985
+ }
986
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
987
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
988
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
989
+ let width = clientRect.width / scale.x;
990
+ let height = clientRect.height / scale.y;
991
+ if (domElement) {
992
+ const win = getWindow(domElement);
993
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
994
+ let currentWin = win;
995
+ let currentIFrame = getFrameElement(currentWin);
996
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
997
+ const iframeScale = getScale(currentIFrame);
998
+ const iframeRect = currentIFrame.getBoundingClientRect();
999
+ const css = getComputedStyle$1(currentIFrame);
1000
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
1001
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
1002
+ x *= iframeScale.x;
1003
+ y *= iframeScale.y;
1004
+ width *= iframeScale.x;
1005
+ height *= iframeScale.y;
1006
+ x += left;
1007
+ y += top;
1008
+ currentWin = getWindow(currentIFrame);
1009
+ currentIFrame = getFrameElement(currentWin);
1010
+ }
1011
+ }
1012
+ return rectToClientRect({
1013
+ width,
1014
+ height,
1015
+ x,
1016
+ y
1017
+ });
1018
+ }
1019
+
1020
+ // If <html> has a CSS width greater than the viewport, then this will be
1021
+ // incorrect for RTL.
1022
+ function getWindowScrollBarX(element, rect) {
1023
+ const leftScroll = getNodeScroll(element).scrollLeft;
1024
+ if (!rect) {
1025
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
1026
+ }
1027
+ return rect.left + leftScroll;
1028
+ }
1029
+
1030
+ function getHTMLOffset(documentElement, scroll) {
1031
+ const htmlRect = documentElement.getBoundingClientRect();
1032
+ const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
1033
+ const y = htmlRect.top + scroll.scrollTop;
1034
+ return {
1035
+ x,
1036
+ y
1037
+ };
1038
+ }
1039
+
1040
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1041
+ let {
1042
+ elements,
1043
+ rect,
1044
+ offsetParent,
1045
+ strategy
1046
+ } = _ref;
1047
+ const isFixed = strategy === 'fixed';
1048
+ const documentElement = getDocumentElement(offsetParent);
1049
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
1050
+ if (offsetParent === documentElement || topLayer && isFixed) {
1051
+ return rect;
1052
+ }
1053
+ let scroll = {
1054
+ scrollLeft: 0,
1055
+ scrollTop: 0
1056
+ };
1057
+ let scale = createCoords(1);
1058
+ const offsets = createCoords(0);
1059
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1060
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1061
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1062
+ scroll = getNodeScroll(offsetParent);
1063
+ }
1064
+ if (isHTMLElement(offsetParent)) {
1065
+ const offsetRect = getBoundingClientRect(offsetParent);
1066
+ scale = getScale(offsetParent);
1067
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1068
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1069
+ }
1070
+ }
1071
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
1072
+ return {
1073
+ width: rect.width * scale.x,
1074
+ height: rect.height * scale.y,
1075
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
1076
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
1077
+ };
1078
+ }
1079
+
1080
+ function getClientRects(element) {
1081
+ return Array.from(element.getClientRects());
1082
+ }
1083
+
1084
+ // Gets the entire size of the scrollable document area, even extending outside
1085
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
1086
+ function getDocumentRect(element) {
1087
+ const html = getDocumentElement(element);
1088
+ const scroll = getNodeScroll(element);
1089
+ const body = element.ownerDocument.body;
1090
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
1091
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
1092
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1093
+ const y = -scroll.scrollTop;
1094
+ if (getComputedStyle$1(body).direction === 'rtl') {
1095
+ x += max(html.clientWidth, body.clientWidth) - width;
1096
+ }
1097
+ return {
1098
+ width,
1099
+ height,
1100
+ x,
1101
+ y
1102
+ };
1103
+ }
1104
+
1105
+ // Safety check: ensure the scrollbar space is reasonable in case this
1106
+ // calculation is affected by unusual styles.
1107
+ // Most scrollbars leave 15-18px of space.
1108
+ const SCROLLBAR_MAX = 25;
1109
+ function getViewportRect(element, strategy) {
1110
+ const win = getWindow(element);
1111
+ const html = getDocumentElement(element);
1112
+ const visualViewport = win.visualViewport;
1113
+ let width = html.clientWidth;
1114
+ let height = html.clientHeight;
1115
+ let x = 0;
1116
+ let y = 0;
1117
+ if (visualViewport) {
1118
+ width = visualViewport.width;
1119
+ height = visualViewport.height;
1120
+ const visualViewportBased = isWebKit();
1121
+ if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
1122
+ x = visualViewport.offsetLeft;
1123
+ y = visualViewport.offsetTop;
1124
+ }
1125
+ }
1126
+ const windowScrollbarX = getWindowScrollBarX(html);
1127
+ // <html> `overflow: hidden` + `scrollbar-gutter: stable` reduces the
1128
+ // visual width of the <html> but this is not considered in the size
1129
+ // of `html.clientWidth`.
1130
+ if (windowScrollbarX <= 0) {
1131
+ const doc = html.ownerDocument;
1132
+ const body = doc.body;
1133
+ const bodyStyles = getComputedStyle(body);
1134
+ const bodyMarginInline = doc.compatMode === 'CSS1Compat' ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
1135
+ const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
1136
+ if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
1137
+ width -= clippingStableScrollbarWidth;
1138
+ }
1139
+ } else if (windowScrollbarX <= SCROLLBAR_MAX) {
1140
+ // If the <body> scrollbar is on the left, the width needs to be extended
1141
+ // by the scrollbar amount so there isn't extra space on the right.
1142
+ width += windowScrollbarX;
1143
+ }
1144
+ return {
1145
+ width,
1146
+ height,
1147
+ x,
1148
+ y
1149
+ };
1150
+ }
1151
+
1152
+ const absoluteOrFixed = /*#__PURE__*/new Set(['absolute', 'fixed']);
1153
+ // Returns the inner client rect, subtracting scrollbars if present.
1154
+ function getInnerBoundingClientRect(element, strategy) {
1155
+ const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
1156
+ const top = clientRect.top + element.clientTop;
1157
+ const left = clientRect.left + element.clientLeft;
1158
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
1159
+ const width = element.clientWidth * scale.x;
1160
+ const height = element.clientHeight * scale.y;
1161
+ const x = left * scale.x;
1162
+ const y = top * scale.y;
1163
+ return {
1164
+ width,
1165
+ height,
1166
+ x,
1167
+ y
1168
+ };
1169
+ }
1170
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
1171
+ let rect;
1172
+ if (clippingAncestor === 'viewport') {
1173
+ rect = getViewportRect(element, strategy);
1174
+ } else if (clippingAncestor === 'document') {
1175
+ rect = getDocumentRect(getDocumentElement(element));
1176
+ } else if (isElement(clippingAncestor)) {
1177
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
1178
+ } else {
1179
+ const visualOffsets = getVisualOffsets(element);
1180
+ rect = {
1181
+ x: clippingAncestor.x - visualOffsets.x,
1182
+ y: clippingAncestor.y - visualOffsets.y,
1183
+ width: clippingAncestor.width,
1184
+ height: clippingAncestor.height
1185
+ };
1186
+ }
1187
+ return rectToClientRect(rect);
1188
+ }
1189
+ function hasFixedPositionAncestor(element, stopNode) {
1190
+ const parentNode = getParentNode(element);
1191
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
1192
+ return false;
1193
+ }
1194
+ return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
1195
+ }
1196
+
1197
+ // A "clipping ancestor" is an `overflow` element with the characteristic of
1198
+ // clipping (or hiding) child elements. This returns all clipping ancestors
1199
+ // of the given element up the tree.
1200
+ function getClippingElementAncestors(element, cache) {
1201
+ const cachedResult = cache.get(element);
1202
+ if (cachedResult) {
1203
+ return cachedResult;
1204
+ }
1205
+ let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
1206
+ let currentContainingBlockComputedStyle = null;
1207
+ const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
1208
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
1209
+
1210
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1211
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
1212
+ const computedStyle = getComputedStyle$1(currentNode);
1213
+ const currentNodeIsContaining = isContainingBlock(currentNode);
1214
+ if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
1215
+ currentContainingBlockComputedStyle = null;
1216
+ }
1217
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
1218
+ if (shouldDropCurrentNode) {
1219
+ // Drop non-containing blocks.
1220
+ result = result.filter(ancestor => ancestor !== currentNode);
1221
+ } else {
1222
+ // Record last containing block for next iteration.
1223
+ currentContainingBlockComputedStyle = computedStyle;
1224
+ }
1225
+ currentNode = getParentNode(currentNode);
1226
+ }
1227
+ cache.set(element, result);
1228
+ return result;
1229
+ }
1230
+
1231
+ // Gets the maximum area that the element is visible in due to any number of
1232
+ // clipping ancestors.
1233
+ function getClippingRect(_ref) {
1234
+ let {
1235
+ element,
1236
+ boundary,
1237
+ rootBoundary,
1238
+ strategy
1239
+ } = _ref;
1240
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
1241
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
1242
+ const firstClippingAncestor = clippingAncestors[0];
1243
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1244
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1245
+ accRect.top = max(rect.top, accRect.top);
1246
+ accRect.right = min(rect.right, accRect.right);
1247
+ accRect.bottom = min(rect.bottom, accRect.bottom);
1248
+ accRect.left = max(rect.left, accRect.left);
1249
+ return accRect;
1250
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1251
+ return {
1252
+ width: clippingRect.right - clippingRect.left,
1253
+ height: clippingRect.bottom - clippingRect.top,
1254
+ x: clippingRect.left,
1255
+ y: clippingRect.top
1256
+ };
1257
+ }
1258
+
1259
+ function getDimensions(element) {
1260
+ const {
1261
+ width,
1262
+ height
1263
+ } = getCssDimensions(element);
1264
+ return {
1265
+ width,
1266
+ height
1267
+ };
1268
+ }
1269
+
1270
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1271
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1272
+ const documentElement = getDocumentElement(offsetParent);
1273
+ const isFixed = strategy === 'fixed';
1274
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
1275
+ let scroll = {
1276
+ scrollLeft: 0,
1277
+ scrollTop: 0
1278
+ };
1279
+ const offsets = createCoords(0);
1280
+
1281
+ // If the <body> scrollbar appears on the left (e.g. RTL systems). Use
1282
+ // Firefox with layout.scrollbar.side = 3 in about:config to test this.
1283
+ function setLeftRTLScrollbarOffset() {
1284
+ offsets.x = getWindowScrollBarX(documentElement);
1285
+ }
1286
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1287
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1288
+ scroll = getNodeScroll(offsetParent);
1289
+ }
1290
+ if (isOffsetParentAnElement) {
1291
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
1292
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1293
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1294
+ } else if (documentElement) {
1295
+ setLeftRTLScrollbarOffset();
1296
+ }
1297
+ }
1298
+ if (isFixed && !isOffsetParentAnElement && documentElement) {
1299
+ setLeftRTLScrollbarOffset();
1300
+ }
1301
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
1302
+ const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
1303
+ const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
1304
+ return {
1305
+ x,
1306
+ y,
1307
+ width: rect.width,
1308
+ height: rect.height
1309
+ };
1310
+ }
1311
+
1312
+ function isStaticPositioned(element) {
1313
+ return getComputedStyle$1(element).position === 'static';
1314
+ }
1315
+
1316
+ function getTrueOffsetParent(element, polyfill) {
1317
+ if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
1318
+ return null;
1319
+ }
1320
+ if (polyfill) {
1321
+ return polyfill(element);
1322
+ }
1323
+ let rawOffsetParent = element.offsetParent;
1324
+
1325
+ // Firefox returns the <html> element as the offsetParent if it's non-static,
1326
+ // while Chrome and Safari return the <body> element. The <body> element must
1327
+ // be used to perform the correct calculations even if the <html> element is
1328
+ // non-static.
1329
+ if (getDocumentElement(element) === rawOffsetParent) {
1330
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
1331
+ }
1332
+ return rawOffsetParent;
1333
+ }
1334
+
1335
+ // Gets the closest ancestor positioned element. Handles some edge cases,
1336
+ // such as table ancestors and cross browser bugs.
1337
+ function getOffsetParent(element, polyfill) {
1338
+ const win = getWindow(element);
1339
+ if (isTopLayer(element)) {
1340
+ return win;
1341
+ }
1342
+ if (!isHTMLElement(element)) {
1343
+ let svgOffsetParent = getParentNode(element);
1344
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
1345
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
1346
+ return svgOffsetParent;
1347
+ }
1348
+ svgOffsetParent = getParentNode(svgOffsetParent);
1349
+ }
1350
+ return win;
1351
+ }
1352
+ let offsetParent = getTrueOffsetParent(element, polyfill);
1353
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
1354
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
1355
+ }
1356
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
1357
+ return win;
1358
+ }
1359
+ return offsetParent || getContainingBlock(element) || win;
1360
+ }
1361
+
1362
+ const getElementRects = async function (data) {
1363
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
1364
+ const getDimensionsFn = this.getDimensions;
1365
+ const floatingDimensions = await getDimensionsFn(data.floating);
1366
+ return {
1367
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
1368
+ floating: {
1369
+ x: 0,
1370
+ y: 0,
1371
+ width: floatingDimensions.width,
1372
+ height: floatingDimensions.height
1373
+ }
1374
+ };
1375
+ };
1376
+
1377
+ function isRTL(element) {
1378
+ return getComputedStyle$1(element).direction === 'rtl';
1379
+ }
1380
+
1381
+ const platform = {
1382
+ convertOffsetParentRelativeRectToViewportRelativeRect,
1383
+ getDocumentElement,
1384
+ getClippingRect,
1385
+ getOffsetParent,
1386
+ getElementRects,
1387
+ getClientRects,
1388
+ getDimensions,
1389
+ getScale,
1390
+ isElement,
1391
+ isRTL
1392
+ };
1393
+
1394
+ function rectsAreEqual(a, b) {
1395
+ return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
1396
+ }
1397
+
1398
+ // https://samthor.au/2021/observing-dom/
1399
+ function observeMove(element, onMove) {
1400
+ let io = null;
1401
+ let timeoutId;
1402
+ const root = getDocumentElement(element);
1403
+ function cleanup() {
1404
+ var _io;
1405
+ clearTimeout(timeoutId);
1406
+ (_io = io) == null || _io.disconnect();
1407
+ io = null;
1408
+ }
1409
+ function refresh(skip, threshold) {
1410
+ if (skip === void 0) {
1411
+ skip = false;
1412
+ }
1413
+ if (threshold === void 0) {
1414
+ threshold = 1;
1415
+ }
1416
+ cleanup();
1417
+ const elementRectForRootMargin = element.getBoundingClientRect();
1418
+ const {
1419
+ left,
1420
+ top,
1421
+ width,
1422
+ height
1423
+ } = elementRectForRootMargin;
1424
+ if (!skip) {
1425
+ onMove();
1426
+ }
1427
+ if (!width || !height) {
1428
+ return;
1429
+ }
1430
+ const insetTop = floor(top);
1431
+ const insetRight = floor(root.clientWidth - (left + width));
1432
+ const insetBottom = floor(root.clientHeight - (top + height));
1433
+ const insetLeft = floor(left);
1434
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
1435
+ const options = {
1436
+ rootMargin,
1437
+ threshold: max(0, min(1, threshold)) || 1
1438
+ };
1439
+ let isFirstUpdate = true;
1440
+ function handleObserve(entries) {
1441
+ const ratio = entries[0].intersectionRatio;
1442
+ if (ratio !== threshold) {
1443
+ if (!isFirstUpdate) {
1444
+ return refresh();
1445
+ }
1446
+ if (!ratio) {
1447
+ // If the reference is clipped, the ratio is 0. Throttle the refresh
1448
+ // to prevent an infinite loop of updates.
1449
+ timeoutId = setTimeout(() => {
1450
+ refresh(false, 1e-7);
1451
+ }, 1000);
1452
+ } else {
1453
+ refresh(false, ratio);
1454
+ }
1455
+ }
1456
+ if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
1457
+ // It's possible that even though the ratio is reported as 1, the
1458
+ // element is not actually fully within the IntersectionObserver's root
1459
+ // area anymore. This can happen under performance constraints. This may
1460
+ // be a bug in the browser's IntersectionObserver implementation. To
1461
+ // work around this, we compare the element's bounding rect now with
1462
+ // what it was at the time we created the IntersectionObserver. If they
1463
+ // are not equal then the element moved, so we refresh.
1464
+ refresh();
1465
+ }
1466
+ isFirstUpdate = false;
1467
+ }
1468
+
1469
+ // Older browsers don't support a `document` as the root and will throw an
1470
+ // error.
1471
+ try {
1472
+ io = new IntersectionObserver(handleObserve, {
1473
+ ...options,
1474
+ // Handle <iframe>s
1475
+ root: root.ownerDocument
1476
+ });
1477
+ } catch (_e) {
1478
+ io = new IntersectionObserver(handleObserve, options);
1479
+ }
1480
+ io.observe(element);
1481
+ }
1482
+ refresh(true);
1483
+ return cleanup;
1484
+ }
1485
+
1486
+ /**
1487
+ * Automatically updates the position of the floating element when necessary.
1488
+ * Should only be called when the floating element is mounted on the DOM or
1489
+ * visible on the screen.
1490
+ * @returns cleanup function that should be invoked when the floating element is
1491
+ * removed from the DOM or hidden from the screen.
1492
+ * @see https://floating-ui.com/docs/autoUpdate
1493
+ */
1494
+ function autoUpdate(reference, floating, update, options) {
1495
+ if (options === void 0) {
1496
+ options = {};
1497
+ }
1498
+ const {
1499
+ ancestorScroll = true,
1500
+ ancestorResize = true,
1501
+ elementResize = typeof ResizeObserver === 'function',
1502
+ layoutShift = typeof IntersectionObserver === 'function',
1503
+ animationFrame = false
1504
+ } = options;
1505
+ const referenceEl = unwrapElement(reference);
1506
+ const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
1507
+ ancestors.forEach(ancestor => {
1508
+ ancestorScroll && ancestor.addEventListener('scroll', update, {
1509
+ passive: true
1510
+ });
1511
+ ancestorResize && ancestor.addEventListener('resize', update);
1512
+ });
1513
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
1514
+ let reobserveFrame = -1;
1515
+ let resizeObserver = null;
1516
+ if (elementResize) {
1517
+ resizeObserver = new ResizeObserver(_ref => {
1518
+ let [firstEntry] = _ref;
1519
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
1520
+ // Prevent update loops when using the `size` middleware.
1521
+ // https://github.com/floating-ui/floating-ui/issues/1740
1522
+ resizeObserver.unobserve(floating);
1523
+ cancelAnimationFrame(reobserveFrame);
1524
+ reobserveFrame = requestAnimationFrame(() => {
1525
+ var _resizeObserver;
1526
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
1527
+ });
1528
+ }
1529
+ update();
1530
+ });
1531
+ if (referenceEl && !animationFrame) {
1532
+ resizeObserver.observe(referenceEl);
1533
+ }
1534
+ resizeObserver.observe(floating);
1535
+ }
1536
+ let frameId;
1537
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
1538
+ if (animationFrame) {
1539
+ frameLoop();
1540
+ }
1541
+ function frameLoop() {
1542
+ const nextRefRect = getBoundingClientRect(reference);
1543
+ if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
1544
+ update();
1545
+ }
1546
+ prevRefRect = nextRefRect;
1547
+ frameId = requestAnimationFrame(frameLoop);
1548
+ }
1549
+ update();
1550
+ return () => {
1551
+ var _resizeObserver2;
1552
+ ancestors.forEach(ancestor => {
1553
+ ancestorScroll && ancestor.removeEventListener('scroll', update);
1554
+ ancestorResize && ancestor.removeEventListener('resize', update);
1555
+ });
1556
+ cleanupIo == null || cleanupIo();
1557
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
1558
+ resizeObserver = null;
1559
+ if (animationFrame) {
1560
+ cancelAnimationFrame(frameId);
1561
+ }
1562
+ };
1563
+ }
1564
+
1565
+ /**
1566
+ * Modifies the placement by translating the floating element along the
1567
+ * specified axes.
1568
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
1569
+ * object may be passed.
1570
+ * @see https://floating-ui.com/docs/offset
1571
+ */
1572
+ const offset = offset$1;
1573
+
1574
+ /**
1575
+ * Optimizes the visibility of the floating element by shifting it in order to
1576
+ * keep it in view when it will overflow the clipping boundary.
1577
+ * @see https://floating-ui.com/docs/shift
1578
+ */
1579
+ const shift = shift$1;
1580
+
1581
+ /**
1582
+ * Optimizes the visibility of the floating element by flipping the `placement`
1583
+ * in order to keep it in view when the preferred placement(s) will overflow the
1584
+ * clipping boundary. Alternative to `autoPlacement`.
1585
+ * @see https://floating-ui.com/docs/flip
1586
+ */
1587
+ const flip = flip$1;
1588
+
1589
+ /**
1590
+ * Provides data to position an inner element of the floating element so that it
1591
+ * appears centered to the reference element.
1592
+ * @see https://floating-ui.com/docs/arrow
1593
+ */
1594
+ const arrow = arrow$1;
1595
+
1596
+ /**
1597
+ * Computes the `x` and `y` coordinates that will place the floating element
1598
+ * next to a given reference element.
1599
+ */
1600
+ const computePosition = (reference, floating, options) => {
1601
+ // This caches the expensive `getClippingElementAncestors` function so that
1602
+ // multiple lifecycle resets re-use the same result. It only lives for a
1603
+ // single call. If other functions become expensive, we can add them as well.
1604
+ const cache = new Map();
1605
+ const mergedOptions = {
1606
+ platform,
1607
+ ...options
1608
+ };
1609
+ const platformWithCache = {
1610
+ ...mergedOptions.platform,
1611
+ _c: cache
1612
+ };
1613
+ return computePosition$1(reference, floating, {
1614
+ ...mergedOptions,
1615
+ platform: platformWithCache
1616
+ });
1617
+ };
1618
+
1619
+ exports.arrow = arrow;
1620
+ exports.autoUpdate = autoUpdate;
1621
+ exports.computePosition = computePosition;
1622
+ exports.flip = flip;
1623
+ exports.offset = offset;
1624
+ exports.shift = shift;