@c2n/overlay 0.0.6

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.
@@ -0,0 +1,1287 @@
1
+ import { LitElement, html, unsafeCSS } from "lit";
2
+ import { isServer } from "lit-html/is-server.js";
3
+ import { customElement, property } from "lit/decorators.js";
4
+ //#region ../../../node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
5
+ var min = Math.min;
6
+ var max = Math.max;
7
+ var round = Math.round;
8
+ var floor = Math.floor;
9
+ var createCoords = (v) => ({
10
+ x: v,
11
+ y: v
12
+ });
13
+ var oppositeSideMap = {
14
+ left: "right",
15
+ right: "left",
16
+ bottom: "top",
17
+ top: "bottom"
18
+ };
19
+ function clamp(start, value, end) {
20
+ return max(start, min(value, end));
21
+ }
22
+ function evaluate(value, param) {
23
+ return typeof value === "function" ? value(param) : value;
24
+ }
25
+ function getSide(placement) {
26
+ return placement.split("-")[0];
27
+ }
28
+ function getAlignment(placement) {
29
+ return placement.split("-")[1];
30
+ }
31
+ function getOppositeAxis(axis) {
32
+ return axis === "x" ? "y" : "x";
33
+ }
34
+ function getAxisLength(axis) {
35
+ return axis === "y" ? "height" : "width";
36
+ }
37
+ function getSideAxis(placement) {
38
+ const firstChar = placement[0];
39
+ return firstChar === "t" || firstChar === "b" ? "y" : "x";
40
+ }
41
+ function getAlignmentAxis(placement) {
42
+ return getOppositeAxis(getSideAxis(placement));
43
+ }
44
+ function getAlignmentSides(placement, rects, rtl) {
45
+ if (rtl === void 0) rtl = false;
46
+ const alignment = getAlignment(placement);
47
+ const alignmentAxis = getAlignmentAxis(placement);
48
+ const length = getAxisLength(alignmentAxis);
49
+ let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
50
+ if (rects.reference[length] > rects.floating[length]) mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
51
+ return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
52
+ }
53
+ function getExpandedPlacements(placement) {
54
+ const oppositePlacement = getOppositePlacement(placement);
55
+ return [
56
+ getOppositeAlignmentPlacement(placement),
57
+ oppositePlacement,
58
+ getOppositeAlignmentPlacement(oppositePlacement)
59
+ ];
60
+ }
61
+ function getOppositeAlignmentPlacement(placement) {
62
+ return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
63
+ }
64
+ var lrPlacement = ["left", "right"];
65
+ var rlPlacement = ["right", "left"];
66
+ var tbPlacement = ["top", "bottom"];
67
+ var btPlacement = ["bottom", "top"];
68
+ function getSideList(side, isStart, rtl) {
69
+ switch (side) {
70
+ case "top":
71
+ case "bottom":
72
+ if (rtl) return isStart ? rlPlacement : lrPlacement;
73
+ return isStart ? lrPlacement : rlPlacement;
74
+ case "left":
75
+ case "right": return isStart ? tbPlacement : btPlacement;
76
+ default: return [];
77
+ }
78
+ }
79
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
80
+ const alignment = getAlignment(placement);
81
+ let list = getSideList(getSide(placement), direction === "start", rtl);
82
+ if (alignment) {
83
+ list = list.map((side) => side + "-" + alignment);
84
+ if (flipAlignment) list = list.concat(list.map(getOppositeAlignmentPlacement));
85
+ }
86
+ return list;
87
+ }
88
+ function getOppositePlacement(placement) {
89
+ const side = getSide(placement);
90
+ return oppositeSideMap[side] + placement.slice(side.length);
91
+ }
92
+ function expandPaddingObject(padding) {
93
+ var _padding$top, _padding$right, _padding$bottom, _padding$left;
94
+ return {
95
+ top: (_padding$top = padding.top) != null ? _padding$top : 0,
96
+ right: (_padding$right = padding.right) != null ? _padding$right : 0,
97
+ bottom: (_padding$bottom = padding.bottom) != null ? _padding$bottom : 0,
98
+ left: (_padding$left = padding.left) != null ? _padding$left : 0
99
+ };
100
+ }
101
+ function getPaddingObject(padding) {
102
+ return typeof padding !== "number" ? expandPaddingObject(padding) : {
103
+ top: padding,
104
+ right: padding,
105
+ bottom: padding,
106
+ left: padding
107
+ };
108
+ }
109
+ function rectToClientRect(rect) {
110
+ const { x, y, width, height } = rect;
111
+ return {
112
+ width,
113
+ height,
114
+ top: y,
115
+ left: x,
116
+ right: x + width,
117
+ bottom: y + height,
118
+ x,
119
+ y
120
+ };
121
+ }
122
+ //#endregion
123
+ //#region ../../../node_modules/@floating-ui/core/dist/floating-ui.core.mjs
124
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
125
+ let { reference, floating } = _ref;
126
+ const sideAxis = getSideAxis(placement);
127
+ const alignmentAxis = getAlignmentAxis(placement);
128
+ const alignLength = getAxisLength(alignmentAxis);
129
+ const side = getSide(placement);
130
+ const isVertical = sideAxis === "y";
131
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
132
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
133
+ const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
134
+ let coords;
135
+ switch (side) {
136
+ case "top":
137
+ coords = {
138
+ x: commonX,
139
+ y: reference.y - floating.height
140
+ };
141
+ break;
142
+ case "bottom":
143
+ coords = {
144
+ x: commonX,
145
+ y: reference.y + reference.height
146
+ };
147
+ break;
148
+ case "right":
149
+ coords = {
150
+ x: reference.x + reference.width,
151
+ y: commonY
152
+ };
153
+ break;
154
+ case "left":
155
+ coords = {
156
+ x: reference.x - floating.width,
157
+ y: commonY
158
+ };
159
+ break;
160
+ default: coords = {
161
+ x: reference.x,
162
+ y: reference.y
163
+ };
164
+ }
165
+ const alignment = getAlignment(placement);
166
+ if (alignment) coords[alignmentAxis] += commonAlign * (alignment === "end" ? 1 : -1) * (rtl && isVertical ? -1 : 1);
167
+ return coords;
168
+ }
169
+ /**
170
+ * Resolves with an object of overflow side offsets that determine how much the
171
+ * element is overflowing a given clipping boundary on each side.
172
+ * - positive = overflowing the boundary by that number of pixels
173
+ * - negative = how many pixels left before it will overflow
174
+ * - 0 = lies flush with the boundary
175
+ * @see https://floating-ui.com/docs/detectOverflow
176
+ */
177
+ async function detectOverflow(state, options) {
178
+ var _await$platform$isEle;
179
+ if (options === void 0) options = {};
180
+ const { x, y, platform, rects, elements, strategy } = state;
181
+ const { boundary = "clippingAncestors", rootBoundary = "viewport", elementContext = "floating", altBoundary = false, padding = 0 } = evaluate(options, state);
182
+ const paddingObject = getPaddingObject(padding);
183
+ const element = elements[altBoundary ? elementContext === "floating" ? "reference" : "floating" : elementContext];
184
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
185
+ 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)),
186
+ boundary,
187
+ rootBoundary,
188
+ strategy
189
+ }));
190
+ const rect = elementContext === "floating" ? {
191
+ x,
192
+ y,
193
+ width: rects.floating.width,
194
+ height: rects.floating.height
195
+ } : rects.reference;
196
+ const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
197
+ const offsetScale = await (platform.isElement == null ? void 0 : platform.isElement(offsetParent)) && await (platform.getScale == null ? void 0 : platform.getScale(offsetParent)) || {
198
+ x: 1,
199
+ y: 1
200
+ };
201
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
202
+ elements,
203
+ rect,
204
+ offsetParent,
205
+ strategy
206
+ }) : rect);
207
+ return {
208
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
209
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
210
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
211
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
212
+ };
213
+ }
214
+ var MAX_RESET_COUNT = 50;
215
+ /**
216
+ * Computes the `x` and `y` coordinates that will place the floating element
217
+ * next to a given reference element.
218
+ *
219
+ * This export does not have any `platform` interface logic. You will need to
220
+ * write one for the platform you are using Floating UI with.
221
+ */
222
+ var computePosition$1 = async (reference, floating, config) => {
223
+ const { placement = "bottom", strategy = "absolute", middleware = [], platform } = config;
224
+ const platformWithDetectOverflow = platform.detectOverflow ? platform : {
225
+ ...platform,
226
+ detectOverflow
227
+ };
228
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
229
+ let rects = await platform.getElementRects({
230
+ reference,
231
+ floating,
232
+ strategy
233
+ });
234
+ let { x, y } = computeCoordsFromPlacement(rects, placement, rtl);
235
+ let statefulPlacement = placement;
236
+ let resetCount = 0;
237
+ const middlewareData = {};
238
+ for (let i = 0; i < middleware.length; i++) {
239
+ const currentMiddleware = middleware[i];
240
+ if (!currentMiddleware) continue;
241
+ const { name, fn } = currentMiddleware;
242
+ const { x: nextX, y: nextY, data, reset } = await fn({
243
+ x,
244
+ y,
245
+ initialPlacement: placement,
246
+ placement: statefulPlacement,
247
+ strategy,
248
+ middlewareData,
249
+ rects,
250
+ platform: platformWithDetectOverflow,
251
+ elements: {
252
+ reference,
253
+ floating
254
+ }
255
+ });
256
+ x = nextX != null ? nextX : x;
257
+ y = nextY != null ? nextY : y;
258
+ middlewareData[name] = {
259
+ ...middlewareData[name],
260
+ ...data
261
+ };
262
+ if (reset && resetCount < MAX_RESET_COUNT) {
263
+ resetCount++;
264
+ if (typeof reset === "object") {
265
+ if (reset.placement) statefulPlacement = reset.placement;
266
+ if (reset.rects) rects = reset.rects === true ? await platform.getElementRects({
267
+ reference,
268
+ floating,
269
+ strategy
270
+ }) : reset.rects;
271
+ ({x, y} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
272
+ }
273
+ i = -1;
274
+ }
275
+ }
276
+ return {
277
+ x,
278
+ y,
279
+ placement: statefulPlacement,
280
+ strategy,
281
+ middlewareData
282
+ };
283
+ };
284
+ /**
285
+ * Optimizes the visibility of the floating element by flipping the `placement`
286
+ * in order to keep it in view when the preferred placement(s) will overflow the
287
+ * clipping boundary. Alternative to `autoPlacement`.
288
+ * @see https://floating-ui.com/docs/flip
289
+ */
290
+ var flip$1 = function(options) {
291
+ if (options === void 0) options = {};
292
+ return {
293
+ name: "flip",
294
+ options,
295
+ async fn(state) {
296
+ var _middlewareData$arrow, _middlewareData$flip;
297
+ const { placement, middlewareData, rects, initialPlacement, platform, elements } = state;
298
+ const { mainAxis: checkMainAxis = true, crossAxis: checkCrossAxis = true, fallbackPlacements: specifiedFallbackPlacements, fallbackStrategy = "bestFit", fallbackAxisSideDirection = "none", flipAlignment = true, ...detectOverflowOptions } = evaluate(options, state);
299
+ if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) return {};
300
+ const side = getSide(placement);
301
+ const initialSideAxis = getSideAxis(initialPlacement);
302
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
303
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
304
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
305
+ const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
306
+ if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
307
+ const placements = [initialPlacement, ...fallbackPlacements];
308
+ const overflow = await platform.detectOverflow(state, detectOverflowOptions);
309
+ const overflows = [];
310
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
311
+ if (checkMainAxis) overflows.push(overflow[side]);
312
+ if (checkCrossAxis) {
313
+ const sides = getAlignmentSides(placement, rects, rtl);
314
+ overflows.push(overflow[sides[0]], overflow[sides[1]]);
315
+ }
316
+ overflowsData = [...overflowsData, {
317
+ placement,
318
+ overflows
319
+ }];
320
+ if (!overflows.every((side) => side <= 0)) {
321
+ var _middlewareData$flip2, _overflowsData$filter;
322
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
323
+ const nextPlacement = placements[nextIndex];
324
+ if (nextPlacement) {
325
+ if (!(checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false) || overflowsData.every((d) => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) return {
326
+ data: {
327
+ index: nextIndex,
328
+ overflows: overflowsData
329
+ },
330
+ reset: { placement: nextPlacement }
331
+ };
332
+ }
333
+ 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;
334
+ if (!resetPlacement) switch (fallbackStrategy) {
335
+ case "bestFit": {
336
+ var _overflowsData$filter2;
337
+ const placement = (_overflowsData$filter2 = overflowsData.filter((d) => {
338
+ if (hasFallbackAxisSideDirection) {
339
+ const currentSideAxis = getSideAxis(d.placement);
340
+ return currentSideAxis === initialSideAxis || currentSideAxis === "y";
341
+ }
342
+ return true;
343
+ }).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];
344
+ if (placement) resetPlacement = placement;
345
+ break;
346
+ }
347
+ case "initialPlacement": resetPlacement = initialPlacement;
348
+ }
349
+ if (placement !== resetPlacement) return { reset: { placement: resetPlacement } };
350
+ }
351
+ return {};
352
+ }
353
+ };
354
+ };
355
+ var originSides = /*#__PURE__*/ new Set(["left", "top"]);
356
+ async function convertValueToCoords(state, options) {
357
+ const { placement, platform, elements } = state;
358
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
359
+ const side = getSide(placement);
360
+ const alignment = getAlignment(placement);
361
+ const isVertical = getSideAxis(placement) === "y";
362
+ const mainAxisMulti = originSides.has(side) ? -1 : 1;
363
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
364
+ const rawValue = evaluate(options, state);
365
+ let { mainAxis, crossAxis, alignmentAxis } = typeof rawValue === "number" ? {
366
+ mainAxis: rawValue,
367
+ crossAxis: 0,
368
+ alignmentAxis: null
369
+ } : {
370
+ mainAxis: rawValue.mainAxis || 0,
371
+ crossAxis: rawValue.crossAxis || 0,
372
+ alignmentAxis: rawValue.alignmentAxis
373
+ };
374
+ if (alignment && typeof alignmentAxis === "number") crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
375
+ return isVertical ? {
376
+ x: crossAxis * crossAxisMulti,
377
+ y: mainAxis * mainAxisMulti
378
+ } : {
379
+ x: mainAxis * mainAxisMulti,
380
+ y: crossAxis * crossAxisMulti
381
+ };
382
+ }
383
+ /**
384
+ * Modifies the placement by translating the floating element along the
385
+ * specified axes.
386
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
387
+ * object may be passed.
388
+ * @see https://floating-ui.com/docs/offset
389
+ */
390
+ var offset$1 = function(options) {
391
+ if (options === void 0) options = 0;
392
+ return {
393
+ name: "offset",
394
+ options,
395
+ async fn(state) {
396
+ var _middlewareData$offse, _middlewareData$arrow;
397
+ const { x, y, placement, middlewareData } = state;
398
+ const diffCoords = await convertValueToCoords(state, options);
399
+ if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) return {};
400
+ return {
401
+ x: x + diffCoords.x,
402
+ y: y + diffCoords.y,
403
+ data: {
404
+ ...diffCoords,
405
+ placement
406
+ }
407
+ };
408
+ }
409
+ };
410
+ };
411
+ /**
412
+ * Optimizes the visibility of the floating element by shifting it in order to
413
+ * keep it in view when it will overflow the clipping boundary.
414
+ * @see https://floating-ui.com/docs/shift
415
+ */
416
+ var shift$1 = function(options) {
417
+ if (options === void 0) options = {};
418
+ return {
419
+ name: "shift",
420
+ options,
421
+ async fn(state) {
422
+ const { x, y, placement, platform } = state;
423
+ const { mainAxis: checkMainAxis = true, crossAxis: checkCrossAxis = false, limiter = { fn: (_ref) => {
424
+ let { x, y } = _ref;
425
+ return {
426
+ x,
427
+ y
428
+ };
429
+ } }, ...detectOverflowOptions } = evaluate(options, state);
430
+ const coords = {
431
+ x,
432
+ y
433
+ };
434
+ const overflow = await platform.detectOverflow(state, detectOverflowOptions);
435
+ const crossAxis = getSideAxis(placement);
436
+ const mainAxis = getOppositeAxis(crossAxis);
437
+ let mainAxisCoord = coords[mainAxis];
438
+ let crossAxisCoord = coords[crossAxis];
439
+ const clampCoord = (axis, coord) => clamp(coord + overflow[axis === "y" ? "top" : "left"], coord, coord - overflow[axis === "y" ? "bottom" : "right"]);
440
+ if (checkMainAxis) mainAxisCoord = clampCoord(mainAxis, mainAxisCoord);
441
+ if (checkCrossAxis) crossAxisCoord = clampCoord(crossAxis, crossAxisCoord);
442
+ const limitedCoords = limiter.fn({
443
+ ...state,
444
+ [mainAxis]: mainAxisCoord,
445
+ [crossAxis]: crossAxisCoord
446
+ });
447
+ return {
448
+ ...limitedCoords,
449
+ data: {
450
+ x: limitedCoords.x - x,
451
+ y: limitedCoords.y - y,
452
+ enabled: {
453
+ [mainAxis]: checkMainAxis,
454
+ [crossAxis]: checkCrossAxis
455
+ }
456
+ }
457
+ };
458
+ }
459
+ };
460
+ };
461
+ /**
462
+ * Provides data that allows you to change the size of the floating element —
463
+ * for instance, prevent it from overflowing the clipping boundary or match the
464
+ * width of the reference element.
465
+ * @see https://floating-ui.com/docs/size
466
+ */
467
+ var size$1 = function(options) {
468
+ if (options === void 0) options = {};
469
+ return {
470
+ name: "size",
471
+ options,
472
+ async fn(state) {
473
+ const { placement, rects, platform, elements } = state;
474
+ const { apply = () => {}, ...detectOverflowOptions } = evaluate(options, state);
475
+ const overflow = await platform.detectOverflow(state, detectOverflowOptions);
476
+ const side = getSide(placement);
477
+ const alignment = getAlignment(placement);
478
+ const isYAxis = getSideAxis(placement) === "y";
479
+ const { width, height } = rects.floating;
480
+ let heightSide;
481
+ let widthSide;
482
+ if (side === "top" || side === "bottom") {
483
+ heightSide = side;
484
+ widthSide = alignment === (await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
485
+ } else {
486
+ widthSide = side;
487
+ heightSide = alignment === "end" ? "top" : "bottom";
488
+ }
489
+ const maximumClippingHeight = height - overflow.top - overflow.bottom;
490
+ const maximumClippingWidth = width - overflow.left - overflow.right;
491
+ const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
492
+ const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
493
+ const shiftData = state.middlewareData.shift;
494
+ const noShift = !shiftData;
495
+ let availableHeight = overflowAvailableHeight;
496
+ let availableWidth = overflowAvailableWidth;
497
+ if (shiftData != null && shiftData.enabled.x) availableWidth = maximumClippingWidth;
498
+ if (shiftData != null && shiftData.enabled.y) availableHeight = maximumClippingHeight;
499
+ if (noShift && !alignment) {
500
+ if (isYAxis) availableWidth = width - 2 * max(overflow.left, overflow.right);
501
+ else availableHeight = height - 2 * max(overflow.top, overflow.bottom);
502
+ }
503
+ await apply({
504
+ ...state,
505
+ availableWidth,
506
+ availableHeight
507
+ });
508
+ const nextDimensions = await platform.getDimensions(elements.floating);
509
+ if (width !== nextDimensions.width || height !== nextDimensions.height) return { reset: { rects: true } };
510
+ return {};
511
+ }
512
+ };
513
+ };
514
+ //#endregion
515
+ //#region ../../../node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
516
+ function hasWindow() {
517
+ return typeof window !== "undefined";
518
+ }
519
+ function getNodeName(node) {
520
+ if (isNode(node)) return (node.nodeName || "").toLowerCase();
521
+ return "#document";
522
+ }
523
+ function getWindow(node) {
524
+ var _node$ownerDocument;
525
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
526
+ }
527
+ function getDocumentElement(node) {
528
+ var _ref;
529
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
530
+ }
531
+ function isNode(value) {
532
+ if (!hasWindow()) return false;
533
+ return value instanceof Node || value instanceof getWindow(value).Node;
534
+ }
535
+ function isElement(value) {
536
+ if (!hasWindow()) return false;
537
+ return value instanceof Element || value instanceof getWindow(value).Element;
538
+ }
539
+ function isHTMLElement(value) {
540
+ if (!hasWindow()) return false;
541
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
542
+ }
543
+ function isShadowRoot(value) {
544
+ if (!hasWindow() || typeof ShadowRoot === "undefined") return false;
545
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
546
+ }
547
+ function isOverflowElement(element) {
548
+ const { overflow, overflowX, overflowY, display } = getComputedStyle$1(element);
549
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
550
+ }
551
+ function isTableElement(element) {
552
+ return /^(table|td|th)$/.test(getNodeName(element));
553
+ }
554
+ function isTopLayer(element) {
555
+ try {
556
+ if (element.matches(":popover-open")) return true;
557
+ } catch (_e) {}
558
+ try {
559
+ return element.matches(":modal");
560
+ } catch (_e) {
561
+ return false;
562
+ }
563
+ }
564
+ var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
565
+ var containRe = /paint|layout|strict|content/;
566
+ var isNotNone = (value) => !!value && value !== "none";
567
+ var isWebKitValue;
568
+ function isContainingBlock(elementOrCss) {
569
+ const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
570
+ return isNotNone(css.transform) || isNotNone(css.translate) || isNotNone(css.scale) || isNotNone(css.rotate) || isNotNone(css.perspective) || !isWebKit() && (isNotNone(css.backdropFilter) || isNotNone(css.filter)) || willChangeRe.test(css.willChange || "") || containRe.test(css.contain || "");
571
+ }
572
+ function getContainingBlock(element) {
573
+ let currentNode = getParentNode(element);
574
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
575
+ if (isContainingBlock(currentNode)) return currentNode;
576
+ else if (isTopLayer(currentNode)) return null;
577
+ currentNode = getParentNode(currentNode);
578
+ }
579
+ return null;
580
+ }
581
+ function isWebKit() {
582
+ if (isWebKitValue == null) isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
583
+ return isWebKitValue;
584
+ }
585
+ function isLastTraversableNode(node) {
586
+ return /^(html|body|#document)$/.test(getNodeName(node));
587
+ }
588
+ function getComputedStyle$1(element) {
589
+ return getWindow(element).getComputedStyle(element);
590
+ }
591
+ function getNodeScroll(element) {
592
+ if (isElement(element)) return {
593
+ scrollLeft: element.scrollLeft,
594
+ scrollTop: element.scrollTop
595
+ };
596
+ return {
597
+ scrollLeft: element.scrollX,
598
+ scrollTop: element.scrollY
599
+ };
600
+ }
601
+ function getParentNode(node) {
602
+ if (getNodeName(node) === "html") return node;
603
+ const result = node.assignedSlot || node.parentNode || isShadowRoot(node) && node.host || getDocumentElement(node);
604
+ return isShadowRoot(result) ? result.host : result;
605
+ }
606
+ function getNearestOverflowAncestor(node) {
607
+ const parentNode = getParentNode(node);
608
+ if (isLastTraversableNode(parentNode)) return (node.ownerDocument || node).body;
609
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) return parentNode;
610
+ return getNearestOverflowAncestor(parentNode);
611
+ }
612
+ function getOverflowAncestors(node, list, traverseIframes) {
613
+ var _node$ownerDocument2;
614
+ if (list === void 0) list = [];
615
+ if (traverseIframes === void 0) traverseIframes = true;
616
+ const scrollableAncestor = getNearestOverflowAncestor(node);
617
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
618
+ const win = getWindow(scrollableAncestor);
619
+ if (isBody) {
620
+ const frameElement = getFrameElement(win);
621
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
622
+ } else return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
623
+ }
624
+ function getFrameElement(win) {
625
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
626
+ }
627
+ //#endregion
628
+ //#region ../../../node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
629
+ function getCssDimensions(element) {
630
+ const css = getComputedStyle$1(element);
631
+ let width = parseFloat(css.width) || 0;
632
+ let height = parseFloat(css.height) || 0;
633
+ const hasOffset = isHTMLElement(element);
634
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
635
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
636
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
637
+ if (shouldFallback) {
638
+ width = offsetWidth;
639
+ height = offsetHeight;
640
+ }
641
+ return {
642
+ width,
643
+ height,
644
+ $: shouldFallback
645
+ };
646
+ }
647
+ function unwrapElement(element) {
648
+ return !isElement(element) ? element.contextElement : element;
649
+ }
650
+ function getScale(element) {
651
+ const domElement = unwrapElement(element);
652
+ if (!isHTMLElement(domElement)) return createCoords(1);
653
+ const rect = domElement.getBoundingClientRect();
654
+ const { width, height, $ } = getCssDimensions(domElement);
655
+ let x = ($ ? round(rect.width) : rect.width) / width;
656
+ let y = ($ ? round(rect.height) : rect.height) / height;
657
+ if (!x || !Number.isFinite(x)) x = 1;
658
+ if (!y || !Number.isFinite(y)) y = 1;
659
+ return {
660
+ x,
661
+ y
662
+ };
663
+ }
664
+ var noOffsets = /*#__PURE__*/ createCoords(0);
665
+ function getVisualOffsets(element) {
666
+ const win = getWindow(element);
667
+ if (!isWebKit() || !win.visualViewport) return noOffsets;
668
+ return {
669
+ x: win.visualViewport.offsetLeft,
670
+ y: win.visualViewport.offsetTop
671
+ };
672
+ }
673
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
674
+ if (isFixed === void 0) isFixed = false;
675
+ return !!floatingOffsetParent && isFixed && floatingOffsetParent === getWindow(element);
676
+ }
677
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
678
+ if (includeScale === void 0) includeScale = false;
679
+ if (isFixedStrategy === void 0) isFixedStrategy = false;
680
+ const clientRect = element.getBoundingClientRect();
681
+ const domElement = unwrapElement(element);
682
+ let scale = createCoords(1);
683
+ if (includeScale) {
684
+ if (offsetParent) {
685
+ if (isElement(offsetParent)) scale = getScale(offsetParent);
686
+ } else scale = getScale(element);
687
+ }
688
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
689
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
690
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
691
+ let width = clientRect.width / scale.x;
692
+ let height = clientRect.height / scale.y;
693
+ if (domElement && offsetParent) {
694
+ const win = getWindow(domElement);
695
+ const offsetWin = isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
696
+ let currentWin = win;
697
+ let currentIFrame = getFrameElement(currentWin);
698
+ while (currentIFrame && offsetWin !== currentWin) {
699
+ const iframeScale = getScale(currentIFrame);
700
+ const iframeRect = currentIFrame.getBoundingClientRect();
701
+ const css = getComputedStyle$1(currentIFrame);
702
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
703
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
704
+ x *= iframeScale.x;
705
+ y *= iframeScale.y;
706
+ width *= iframeScale.x;
707
+ height *= iframeScale.y;
708
+ x += left;
709
+ y += top;
710
+ currentWin = getWindow(currentIFrame);
711
+ currentIFrame = getFrameElement(currentWin);
712
+ }
713
+ }
714
+ return rectToClientRect({
715
+ width,
716
+ height,
717
+ x,
718
+ y
719
+ });
720
+ }
721
+ function getWindowScrollBarX(element, rect) {
722
+ const leftScroll = getNodeScroll(element).scrollLeft;
723
+ if (!rect) return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
724
+ return rect.left + leftScroll;
725
+ }
726
+ function getHTMLOffset(documentElement, scroll) {
727
+ const htmlRect = documentElement.getBoundingClientRect();
728
+ return {
729
+ x: htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect),
730
+ y: htmlRect.top + scroll.scrollTop
731
+ };
732
+ }
733
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
734
+ let { elements, rect, offsetParent, strategy } = _ref;
735
+ const isFixed = strategy === "fixed";
736
+ const documentElement = getDocumentElement(offsetParent);
737
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
738
+ if (offsetParent === documentElement || topLayer && isFixed) return rect;
739
+ let scroll = {
740
+ scrollLeft: 0,
741
+ scrollTop: 0
742
+ };
743
+ let scale = createCoords(1);
744
+ const offsets = createCoords(0);
745
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
746
+ if (isOffsetParentAnElement || !isFixed) {
747
+ if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) scroll = getNodeScroll(offsetParent);
748
+ if (isOffsetParentAnElement) {
749
+ const offsetRect = getBoundingClientRect(offsetParent);
750
+ scale = getScale(offsetParent);
751
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
752
+ offsets.y = offsetRect.y + offsetParent.clientTop;
753
+ }
754
+ }
755
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
756
+ return {
757
+ width: rect.width * scale.x,
758
+ height: rect.height * scale.y,
759
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
760
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
761
+ };
762
+ }
763
+ function getClientRects(element) {
764
+ return element.getClientRects ? Array.from(element.getClientRects()) : [];
765
+ }
766
+ function getDocumentRect(html) {
767
+ const scroll = getNodeScroll(html);
768
+ const body = html.ownerDocument.body;
769
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
770
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
771
+ let x = -scroll.scrollLeft + getWindowScrollBarX(html);
772
+ const y = -scroll.scrollTop;
773
+ if (getComputedStyle$1(body).direction === "rtl") x += max(html.clientWidth, body.clientWidth) - width;
774
+ return {
775
+ width,
776
+ height,
777
+ x,
778
+ y
779
+ };
780
+ }
781
+ var SCROLLBAR_MAX = 25;
782
+ function getViewportRect(element, strategy, rootBoundary) {
783
+ if (rootBoundary === void 0) rootBoundary = "viewport";
784
+ const isLayoutViewport = rootBoundary === "layoutViewport";
785
+ const win = getWindow(element);
786
+ const html = getDocumentElement(element);
787
+ const visualViewport = win.visualViewport;
788
+ let width = html.clientWidth;
789
+ let height = html.clientHeight;
790
+ let x = 0;
791
+ let y = 0;
792
+ if (visualViewport) {
793
+ const layoutRelativeClientCoords = !isWebKit() || strategy === "fixed";
794
+ if (isLayoutViewport) {
795
+ if (!layoutRelativeClientCoords) {
796
+ x = -visualViewport.offsetLeft;
797
+ y = -visualViewport.offsetTop;
798
+ }
799
+ } else {
800
+ width = visualViewport.width;
801
+ height = visualViewport.height;
802
+ if (layoutRelativeClientCoords) {
803
+ x = visualViewport.offsetLeft;
804
+ y = visualViewport.offsetTop;
805
+ }
806
+ }
807
+ }
808
+ if (getWindowScrollBarX(html) <= 0) {
809
+ const doc = html.ownerDocument;
810
+ const body = doc.body;
811
+ const bodyStyles = getComputedStyle(body);
812
+ const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
813
+ const reservedWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
814
+ const gutter = getComputedStyle(html).scrollbarGutter === "stable both-edges" ? reservedWidth / 2 : reservedWidth;
815
+ if (gutter <= SCROLLBAR_MAX) width -= gutter;
816
+ }
817
+ return {
818
+ width,
819
+ height,
820
+ x,
821
+ y
822
+ };
823
+ }
824
+ function getInnerBoundingClientRect(element, strategy) {
825
+ const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
826
+ const top = clientRect.top + element.clientTop;
827
+ const left = clientRect.left + element.clientLeft;
828
+ const scale = getScale(element);
829
+ return {
830
+ width: element.clientWidth * scale.x,
831
+ height: element.clientHeight * scale.y,
832
+ x: left * scale.x,
833
+ y: top * scale.y
834
+ };
835
+ }
836
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
837
+ let rect;
838
+ if (clippingAncestor === "viewport" || clippingAncestor === "layoutViewport") rect = getViewportRect(element, strategy, clippingAncestor);
839
+ else if (clippingAncestor === "document") rect = getDocumentRect(getDocumentElement(element));
840
+ else if (isElement(clippingAncestor)) rect = getInnerBoundingClientRect(clippingAncestor, strategy);
841
+ else {
842
+ const visualOffsets = getVisualOffsets(element);
843
+ rect = {
844
+ x: clippingAncestor.x - visualOffsets.x,
845
+ y: clippingAncestor.y - visualOffsets.y,
846
+ width: clippingAncestor.width,
847
+ height: clippingAncestor.height
848
+ };
849
+ }
850
+ return rectToClientRect(rect);
851
+ }
852
+ function getClippingElementAncestors(element, cache) {
853
+ const cachedResult = cache.get(element);
854
+ if (cachedResult) return cachedResult;
855
+ let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
856
+ let lastKeptComputedStyle = null;
857
+ const elementIsFixed = getComputedStyle$1(element).position === "fixed";
858
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
859
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
860
+ const computedStyle = getComputedStyle$1(currentNode);
861
+ const currentNodeIsContaining = isContainingBlock(currentNode);
862
+ const lastPosition = lastKeptComputedStyle ? lastKeptComputedStyle.position : elementIsFixed ? "fixed" : "";
863
+ if (!currentNodeIsContaining && (lastPosition === "fixed" || lastPosition === "absolute" && computedStyle.position === "static")) result = result.filter((ancestor) => ancestor !== currentNode);
864
+ else lastKeptComputedStyle = computedStyle;
865
+ currentNode = getParentNode(currentNode);
866
+ }
867
+ cache.set(element, result);
868
+ return result;
869
+ }
870
+ function getClippingRect(_ref) {
871
+ let { element, boundary, rootBoundary, strategy } = _ref;
872
+ const clippingAncestors = [...boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary), rootBoundary];
873
+ const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
874
+ let top = firstRect.top;
875
+ let right = firstRect.right;
876
+ let bottom = firstRect.bottom;
877
+ let left = firstRect.left;
878
+ for (let i = 1; i < clippingAncestors.length; i++) {
879
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i], strategy);
880
+ top = max(rect.top, top);
881
+ right = min(rect.right, right);
882
+ bottom = min(rect.bottom, bottom);
883
+ left = max(rect.left, left);
884
+ }
885
+ return {
886
+ width: right - left,
887
+ height: bottom - top,
888
+ x: left,
889
+ y: top
890
+ };
891
+ }
892
+ function getDimensions(element) {
893
+ const { width, height } = getCssDimensions(element);
894
+ return {
895
+ width,
896
+ height
897
+ };
898
+ }
899
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
900
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
901
+ const documentElement = getDocumentElement(offsetParent);
902
+ const isFixed = strategy === "fixed";
903
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
904
+ let scroll = {
905
+ scrollLeft: 0,
906
+ scrollTop: 0
907
+ };
908
+ const offsets = createCoords(0);
909
+ if (isOffsetParentAnElement || !isFixed) {
910
+ if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) scroll = getNodeScroll(offsetParent);
911
+ if (isOffsetParentAnElement) {
912
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
913
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
914
+ offsets.y = offsetRect.y + offsetParent.clientTop;
915
+ }
916
+ }
917
+ if (!isOffsetParentAnElement && documentElement) offsets.x = getWindowScrollBarX(documentElement);
918
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
919
+ return {
920
+ x: rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x,
921
+ y: rect.top + scroll.scrollTop - offsets.y - htmlOffset.y,
922
+ width: rect.width,
923
+ height: rect.height
924
+ };
925
+ }
926
+ function isStaticPositioned(element) {
927
+ return getComputedStyle$1(element).position === "static";
928
+ }
929
+ function getTrueOffsetParent(element, polyfill) {
930
+ if (!isHTMLElement(element) || getComputedStyle$1(element).position === "fixed") return null;
931
+ if (polyfill) return polyfill(element);
932
+ let rawOffsetParent = element.offsetParent;
933
+ if (getDocumentElement(element) === rawOffsetParent) rawOffsetParent = rawOffsetParent.ownerDocument.body;
934
+ return rawOffsetParent;
935
+ }
936
+ function getOffsetParent(element, polyfill) {
937
+ const win = getWindow(element);
938
+ if (isTopLayer(element)) return win;
939
+ if (!isHTMLElement(element)) {
940
+ let svgOffsetParent = getParentNode(element);
941
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
942
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) return svgOffsetParent;
943
+ svgOffsetParent = getParentNode(svgOffsetParent);
944
+ }
945
+ return win;
946
+ }
947
+ let offsetParent = getTrueOffsetParent(element, polyfill);
948
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) offsetParent = getTrueOffsetParent(offsetParent, polyfill);
949
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) return win;
950
+ return offsetParent || getContainingBlock(element) || win;
951
+ }
952
+ var getElementRects = async function(data) {
953
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
954
+ const getDimensionsFn = this.getDimensions;
955
+ const floatingDimensions = await getDimensionsFn(data.floating);
956
+ return {
957
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
958
+ floating: {
959
+ x: 0,
960
+ y: 0,
961
+ width: floatingDimensions.width,
962
+ height: floatingDimensions.height
963
+ }
964
+ };
965
+ };
966
+ function isRTL(element) {
967
+ return getComputedStyle$1(element).direction === "rtl";
968
+ }
969
+ var platform = {
970
+ convertOffsetParentRelativeRectToViewportRelativeRect,
971
+ getDocumentElement,
972
+ getClippingRect,
973
+ getOffsetParent,
974
+ getElementRects,
975
+ getClientRects,
976
+ getDimensions,
977
+ getScale,
978
+ isElement,
979
+ isRTL
980
+ };
981
+ function rectsAreEqual(a, b) {
982
+ return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
983
+ }
984
+ function observeMove(element, onMove, ancestorResize) {
985
+ let io = null;
986
+ let timeoutId;
987
+ const root = getDocumentElement(element);
988
+ function cleanup() {
989
+ var _io;
990
+ clearTimeout(timeoutId);
991
+ (_io = io) == null || _io.disconnect();
992
+ io = null;
993
+ }
994
+ function refresh(skip, threshold) {
995
+ if (skip === void 0) skip = false;
996
+ if (threshold === void 0) threshold = 1;
997
+ cleanup();
998
+ const elementRectForRootMargin = element.getBoundingClientRect();
999
+ const { left, top, width, height } = elementRectForRootMargin;
1000
+ if (!skip) onMove();
1001
+ if (!width || !height) return;
1002
+ const insetTop = floor(top);
1003
+ const insetRight = floor(root.clientWidth - (left + width));
1004
+ const insetBottom = floor(root.clientHeight - (top + height));
1005
+ const insetLeft = floor(left);
1006
+ const options = {
1007
+ rootMargin: -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px",
1008
+ threshold: max(0, min(1, threshold)) || 1
1009
+ };
1010
+ let isFirstUpdate = true;
1011
+ function handleObserve(entries) {
1012
+ const ratio = entries[0].intersectionRatio;
1013
+ if (!rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) return refresh();
1014
+ if (ratio !== threshold) {
1015
+ if (!isFirstUpdate) return refresh();
1016
+ if (!ratio) timeoutId = setTimeout(() => {
1017
+ refresh(false, 1e-7);
1018
+ }, 1e3);
1019
+ else refresh(false, ratio);
1020
+ }
1021
+ isFirstUpdate = false;
1022
+ }
1023
+ try {
1024
+ io = new IntersectionObserver(handleObserve, {
1025
+ ...options,
1026
+ root: root.ownerDocument
1027
+ });
1028
+ } catch (_e) {
1029
+ io = new IntersectionObserver(handleObserve, options);
1030
+ }
1031
+ io.observe(element);
1032
+ }
1033
+ const win = getWindow(element);
1034
+ const handleResize = () => refresh(ancestorResize);
1035
+ win.addEventListener("resize", handleResize);
1036
+ refresh(true);
1037
+ return () => {
1038
+ win.removeEventListener("resize", handleResize);
1039
+ cleanup();
1040
+ };
1041
+ }
1042
+ /**
1043
+ * Automatically updates the position of the floating element when necessary.
1044
+ * Should only be called when the floating element is mounted on the DOM or
1045
+ * visible on the screen.
1046
+ * @returns cleanup function that should be invoked when the floating element is
1047
+ * removed from the DOM or hidden from the screen.
1048
+ * @see https://floating-ui.com/docs/autoUpdate
1049
+ */
1050
+ function autoUpdate(reference, floating, update, options) {
1051
+ if (options === void 0) options = {};
1052
+ const { ancestorScroll = true, ancestorResize = true, elementResize = typeof ResizeObserver === "function", layoutShift = typeof IntersectionObserver === "function", animationFrame = false } = options;
1053
+ const referenceEl = unwrapElement(reference);
1054
+ const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
1055
+ ancestors.forEach((ancestor) => {
1056
+ ancestorScroll && ancestor.addEventListener("scroll", update);
1057
+ ancestorResize && ancestor.addEventListener("resize", update);
1058
+ });
1059
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update, ancestorResize) : null;
1060
+ let reobserveFrame = -1;
1061
+ let resizeObserver = null;
1062
+ if (elementResize) {
1063
+ resizeObserver = new ResizeObserver((_ref) => {
1064
+ let [firstEntry] = _ref;
1065
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
1066
+ resizeObserver.unobserve(floating);
1067
+ cancelAnimationFrame(reobserveFrame);
1068
+ reobserveFrame = requestAnimationFrame(() => {
1069
+ var _resizeObserver;
1070
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
1071
+ });
1072
+ }
1073
+ update();
1074
+ });
1075
+ if (referenceEl && !animationFrame) resizeObserver.observe(referenceEl);
1076
+ if (floating) resizeObserver.observe(floating);
1077
+ }
1078
+ let frameId;
1079
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
1080
+ if (animationFrame) frameLoop();
1081
+ function frameLoop() {
1082
+ const nextRefRect = getBoundingClientRect(reference);
1083
+ if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) update();
1084
+ prevRefRect = nextRefRect;
1085
+ frameId = requestAnimationFrame(frameLoop);
1086
+ }
1087
+ update();
1088
+ return () => {
1089
+ var _resizeObserver2;
1090
+ ancestors.forEach((ancestor) => {
1091
+ ancestorScroll && ancestor.removeEventListener("scroll", update);
1092
+ ancestorResize && ancestor.removeEventListener("resize", update);
1093
+ });
1094
+ cleanupIo?.();
1095
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
1096
+ resizeObserver = null;
1097
+ if (animationFrame) cancelAnimationFrame(frameId);
1098
+ };
1099
+ }
1100
+ /**
1101
+ * Modifies the placement by translating the floating element along the
1102
+ * specified axes.
1103
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
1104
+ * object may be passed.
1105
+ * @see https://floating-ui.com/docs/offset
1106
+ */
1107
+ var offset = offset$1;
1108
+ /**
1109
+ * Optimizes the visibility of the floating element by shifting it in order to
1110
+ * keep it in view when it will overflow the clipping boundary.
1111
+ * @see https://floating-ui.com/docs/shift
1112
+ */
1113
+ var shift = shift$1;
1114
+ /**
1115
+ * Optimizes the visibility of the floating element by flipping the `placement`
1116
+ * in order to keep it in view when the preferred placement(s) will overflow the
1117
+ * clipping boundary. Alternative to `autoPlacement`.
1118
+ * @see https://floating-ui.com/docs/flip
1119
+ */
1120
+ var flip = flip$1;
1121
+ /**
1122
+ * Provides data that allows you to change the size of the floating element —
1123
+ * for instance, prevent it from overflowing the clipping boundary or match the
1124
+ * width of the reference element.
1125
+ * @see https://floating-ui.com/docs/size
1126
+ */
1127
+ var size = size$1;
1128
+ /**
1129
+ * Computes the `x` and `y` coordinates that will place the floating element
1130
+ * next to a given reference element.
1131
+ */
1132
+ var computePosition = (reference, floating, options) => {
1133
+ const cache = /* @__PURE__ */ new Map();
1134
+ const mergedOptions = options != null ? options : {};
1135
+ const platformWithCache = {
1136
+ ...platform,
1137
+ ...mergedOptions.platform,
1138
+ _c: cache
1139
+ };
1140
+ return computePosition$1(reference, floating, {
1141
+ ...mergedOptions,
1142
+ platform: platformWithCache
1143
+ });
1144
+ };
1145
+ //#endregion
1146
+ //#region src/overlay.scss?inline
1147
+ var overlay_default = "/* ex : var((width: 24px), width, c2-checkbox) returns var(--c2-checkbox-width, 24px) */\n:host {\n position: absolute;\n inset: auto;\n top: 0;\n left: 0;\n margin: 0;\n padding: 0;\n border: none;\n background: transparent;\n color: inherit;\n overflow: visible;\n box-sizing: border-box;\n transform-origin: top left;\n opacity: 1;\n transform: scale(1);\n transition: opacity var(--c2-overlay--transition-duration,150ms) cubic-bezier(0.2, 0, 0, 1), transform var(--c2-overlay--transition-duration,150ms) cubic-bezier(0.2, 0, 0, 1), display var(--c2-overlay--transition-duration,150ms) allow-discrete, overlay var(--c2-overlay--transition-duration,150ms) allow-discrete;\n}\n:host::backdrop {\n background: var(--c2-overlay__backdrop--background,transparent);\n}\n\n:host(:not(:popover-open)) {\n opacity: 0;\n transform: scale(0.96);\n}\n\n@starting-style {\n :host(:popover-open) {\n opacity: 0;\n transform: scale(0.96);\n }\n}\n:host([current-placement^=top]) {\n transform-origin: bottom center;\n}\n\n:host([current-placement^=bottom]) {\n transform-origin: top center;\n}\n\n:host([current-placement^=left]) {\n transform-origin: center right;\n}\n\n:host([current-placement^=right]) {\n transform-origin: center left;\n}\n\n:host([current-placement$=-start][current-placement^=top]) {\n transform-origin: bottom left;\n}\n\n:host([current-placement$=-start][current-placement^=bottom]) {\n transform-origin: top left;\n}\n\n:host([current-placement$=-end][current-placement^=top]) {\n transform-origin: bottom right;\n}\n\n:host([current-placement$=-end][current-placement^=bottom]) {\n transform-origin: top right;\n}\n\n@media (prefers-reduced-motion: reduce) {\n :host {\n transition: none;\n }\n}";
1148
+ //#endregion
1149
+ //#region \0@oxc-project+runtime@0.148.0/helpers/esm/decorate.js
1150
+ function __decorate(decorators, target, key, desc) {
1151
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1152
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1153
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1154
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1155
+ }
1156
+ //#endregion
1157
+ //#region src/overlay.ts
1158
+ var Overlay = class Overlay extends LitElement {
1159
+ static {
1160
+ this.styles = unsafeCSS(overlay_default);
1161
+ }
1162
+ constructor() {
1163
+ super();
1164
+ this.open = false;
1165
+ this.placement = "bottom-start";
1166
+ this.disabledCrossAxis = false;
1167
+ this.fitTarget = false;
1168
+ this.freeWidth = false;
1169
+ this.anchor = void 0;
1170
+ this.cleanupPosition = null;
1171
+ this.handleBeforeToggle = (event) => {
1172
+ if (event.newState === "open") this.startPositioning();
1173
+ else this.stopPositioning();
1174
+ };
1175
+ this.handleToggle = (event) => {
1176
+ this.open = event.newState === "open";
1177
+ };
1178
+ if (!isServer) {
1179
+ this.addEventListener("beforetoggle", this.handleBeforeToggle);
1180
+ this.addEventListener("toggle", this.handleToggle);
1181
+ }
1182
+ }
1183
+ connectedCallback() {
1184
+ super.connectedCallback();
1185
+ if (!isServer && !this.hasAttribute("popover")) this.setAttribute("popover", "auto");
1186
+ }
1187
+ disconnectedCallback() {
1188
+ super.disconnectedCallback();
1189
+ this.stopPositioning();
1190
+ }
1191
+ /** The resolved anchor element, if any. */
1192
+ get anchorElement() {
1193
+ if (this.anchor instanceof HTMLElement) return this.anchor;
1194
+ const root = this.getRootNode();
1195
+ if (typeof this.anchor === "string" && this.anchor) return root.querySelector?.(`#${CSS.escape(this.anchor)}`) ?? null;
1196
+ if (!this.id) return null;
1197
+ let parent = this.parentElement;
1198
+ while (parent) {
1199
+ const found = parent.querySelector(`[popovertarget="${CSS.escape(this.id)}"]`);
1200
+ if (found) return found;
1201
+ parent = parent.parentElement;
1202
+ }
1203
+ return root.querySelector?.(`[popovertarget="${CSS.escape(this.id)}"]`) ?? null;
1204
+ }
1205
+ readPixels(name, fallback) {
1206
+ const value = Number.parseFloat(getComputedStyle(this).getPropertyValue(name));
1207
+ return Number.isNaN(value) ? fallback : value;
1208
+ }
1209
+ startPositioning() {
1210
+ this.stopPositioning();
1211
+ const anchor = this.anchorElement;
1212
+ if (!anchor) return;
1213
+ this.cleanupPosition = autoUpdate(anchor, this, () => this.updatePosition(anchor));
1214
+ }
1215
+ stopPositioning() {
1216
+ this.cleanupPosition?.();
1217
+ this.cleanupPosition = null;
1218
+ }
1219
+ async updatePosition(anchor) {
1220
+ const mainAxis = this.readPixels("--c2-overlay--offset-y", 8);
1221
+ const crossAxis = this.readPixels("--c2-overlay--offset-x", 0);
1222
+ const padding = this.readPixels("--c2-overlay--viewport-padding", 8);
1223
+ if (this.fitTarget) this.style.width = `${anchor.offsetWidth}px`;
1224
+ else this.style.removeProperty("width");
1225
+ if (!this.freeWidth && !this.fitTarget) this.style.minWidth = `${anchor.offsetWidth}px`;
1226
+ else this.style.removeProperty("min-width");
1227
+ const { x, y, placement } = await computePosition(anchor, this, {
1228
+ placement: this.placement,
1229
+ middleware: [
1230
+ offset({
1231
+ mainAxis,
1232
+ crossAxis
1233
+ }),
1234
+ flip({
1235
+ crossAxis: !this.disabledCrossAxis,
1236
+ padding
1237
+ }),
1238
+ shift({ padding }),
1239
+ size({
1240
+ padding,
1241
+ apply: ({ availableHeight, availableWidth }) => {
1242
+ this.style.setProperty("--c2-overlay--available-height", `${Math.max(0, Math.floor(availableHeight))}px`);
1243
+ this.style.setProperty("--c2-overlay--available-width", `${Math.max(0, Math.floor(availableWidth))}px`);
1244
+ }
1245
+ })
1246
+ ]
1247
+ });
1248
+ this.style.left = `${x}px`;
1249
+ this.style.top = `${y}px`;
1250
+ this.setAttribute("current-placement", placement);
1251
+ }
1252
+ updated(changed) {
1253
+ if (changed.has("open") && !isServer && this.isConnected) {
1254
+ const isOpen = this.matches(":popover-open");
1255
+ try {
1256
+ if (this.open && !isOpen) this.showPopover();
1257
+ else if (!this.open && isOpen) this.hidePopover();
1258
+ } catch {}
1259
+ }
1260
+ if (changed.has("placement") && this.matches(":popover-open")) this.startPositioning();
1261
+ }
1262
+ render() {
1263
+ return html`<slot></slot>`;
1264
+ }
1265
+ };
1266
+ __decorate([property({
1267
+ type: Boolean,
1268
+ reflect: true
1269
+ })], Overlay.prototype, "open", void 0);
1270
+ __decorate([property({ reflect: true })], Overlay.prototype, "placement", void 0);
1271
+ __decorate([property({
1272
+ type: Boolean,
1273
+ reflect: true,
1274
+ attribute: "disabled-cross-axis"
1275
+ })], Overlay.prototype, "disabledCrossAxis", void 0);
1276
+ __decorate([property({
1277
+ type: Boolean,
1278
+ attribute: "fit-anchor"
1279
+ })], Overlay.prototype, "fitTarget", void 0);
1280
+ __decorate([property({
1281
+ type: Boolean,
1282
+ attribute: "free-width"
1283
+ })], Overlay.prototype, "freeWidth", void 0);
1284
+ __decorate([property()], Overlay.prototype, "anchor", void 0);
1285
+ Overlay = __decorate([customElement("c2-overlay")], Overlay);
1286
+ //#endregion
1287
+ export { Overlay };