@ariakit/core 0.0.1 → 0.1.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 (163) hide show
  1. package/.eslintignore +6 -0
  2. package/CHANGELOG.md +18 -0
  3. package/checkbox/checkbox-store/package.json +7 -0
  4. package/cjs/__chunks/2YFRPUZP.cjs +30 -0
  5. package/cjs/__chunks/3BBA3Z5G.cjs +143 -0
  6. package/cjs/__chunks/3KP2MDG6.cjs +1491 -0
  7. package/cjs/__chunks/5D5Y5EI4.cjs +146 -0
  8. package/cjs/__chunks/7ZXWQTAY.cjs +71 -0
  9. package/cjs/__chunks/AZVDLKO3.cjs +286 -0
  10. package/cjs/__chunks/EFEGT32M.cjs +12 -0
  11. package/cjs/__chunks/EIDN2CWH.cjs +57 -0
  12. package/cjs/__chunks/GDZQUFNP.cjs +30 -0
  13. package/cjs/__chunks/NX5OHIMM.cjs +169 -0
  14. package/cjs/__chunks/OFNGELMA.cjs +182 -0
  15. package/cjs/checkbox/checkbox-store.cjs +27 -0
  16. package/cjs/checkbox/checkbox-store.d.ts +34 -0
  17. package/cjs/collection/collection-store.cjs +9 -0
  18. package/cjs/collection/collection-store.d.ts +65 -0
  19. package/cjs/combobox/combobox-store.cjs +163 -0
  20. package/cjs/combobox/combobox-store.d.ts +67 -0
  21. package/cjs/composite/composite-overflow-store.cjs +15 -0
  22. package/cjs/composite/composite-overflow-store.d.ts +10 -0
  23. package/cjs/composite/composite-store.cjs +11 -0
  24. package/cjs/composite/composite-store.d.ts +202 -0
  25. package/cjs/dialog/dialog-store.cjs +9 -0
  26. package/cjs/dialog/dialog-store.d.ts +10 -0
  27. package/cjs/disclosure/disclosure-store.cjs +8 -0
  28. package/cjs/disclosure/disclosure-store.d.ts +87 -0
  29. package/cjs/form/form-store.cjs +241 -0
  30. package/cjs/form/form-store.d.ts +236 -0
  31. package/cjs/form/types.cjs +1 -0
  32. package/cjs/form/types.d.ts +38 -0
  33. package/cjs/hovercard/hovercard-store.cjs +11 -0
  34. package/cjs/hovercard/hovercard-store.d.ts +45 -0
  35. package/cjs/index.cjs +5 -0
  36. package/cjs/index.d.ts +2 -0
  37. package/cjs/menu/menu-bar-store.cjs +27 -0
  38. package/cjs/menu/menu-bar-store.d.ts +10 -0
  39. package/cjs/menu/menu-store.cjs +108 -0
  40. package/cjs/menu/menu-store.d.ts +70 -0
  41. package/cjs/popover/popover-store.cjs +10 -0
  42. package/cjs/popover/popover-store.d.ts +150 -0
  43. package/cjs/radio/radio-store.cjs +36 -0
  44. package/cjs/radio/radio-store.d.ts +31 -0
  45. package/cjs/select/select-store.cjs +164 -0
  46. package/cjs/select/select-store.d.ts +87 -0
  47. package/cjs/tab/tab-store.cjs +126 -0
  48. package/cjs/tab/tab-store.d.ts +78 -0
  49. package/cjs/toolbar/toolbar-store.cjs +27 -0
  50. package/cjs/toolbar/toolbar-store.d.ts +21 -0
  51. package/cjs/tooltip/tooltip-store.cjs +98 -0
  52. package/cjs/tooltip/tooltip-store.d.ts +28 -0
  53. package/cjs/tsconfig.build.tsbuildinfo +1 -0
  54. package/cjs/utils/array.cjs +12 -0
  55. package/cjs/utils/array.d.ts +29 -0
  56. package/cjs/utils/dom.cjs +38 -0
  57. package/cjs/utils/dom.d.ts +105 -0
  58. package/cjs/utils/events.cjs +132 -0
  59. package/cjs/utils/events.d.ts +73 -0
  60. package/cjs/utils/focus.cjs +222 -0
  61. package/cjs/utils/focus.d.ts +117 -0
  62. package/cjs/utils/misc.cjs +40 -0
  63. package/cjs/utils/misc.d.ts +111 -0
  64. package/cjs/utils/platform.cjs +15 -0
  65. package/cjs/utils/platform.d.ts +20 -0
  66. package/cjs/utils/store.cjs +9 -0
  67. package/cjs/utils/store.d.ts +99 -0
  68. package/cjs/utils/types.cjs +1 -0
  69. package/cjs/utils/types.d.ts +72 -0
  70. package/collection/collection-store/package.json +7 -0
  71. package/combobox/combobox-store/package.json +7 -0
  72. package/composite/composite-overflow-store/package.json +7 -0
  73. package/composite/composite-store/package.json +7 -0
  74. package/dialog/dialog-store/package.json +7 -0
  75. package/disclosure/disclosure-store/package.json +7 -0
  76. package/esm/__chunks/5XEKIOCW.js +30 -0
  77. package/esm/__chunks/6U25WEDX.js +286 -0
  78. package/esm/__chunks/6UPCMUXT.js +1491 -0
  79. package/esm/__chunks/ADRUFBEO.js +12 -0
  80. package/esm/__chunks/DXA3K2FY.js +30 -0
  81. package/esm/__chunks/HCKYJLMC.js +71 -0
  82. package/esm/__chunks/KLKI3AIB.js +146 -0
  83. package/esm/__chunks/L7KN5AYP.js +169 -0
  84. package/esm/__chunks/RX3ZUQ6U.js +57 -0
  85. package/esm/__chunks/UOJSZ35L.js +143 -0
  86. package/esm/__chunks/UVCATTRC.js +182 -0
  87. package/esm/checkbox/checkbox-store.d.ts +34 -0
  88. package/esm/checkbox/checkbox-store.js +27 -0
  89. package/esm/collection/collection-store.d.ts +65 -0
  90. package/esm/collection/collection-store.js +9 -0
  91. package/esm/combobox/combobox-store.d.ts +67 -0
  92. package/esm/combobox/combobox-store.js +163 -0
  93. package/esm/composite/composite-overflow-store.d.ts +10 -0
  94. package/esm/composite/composite-overflow-store.js +15 -0
  95. package/esm/composite/composite-store.d.ts +202 -0
  96. package/esm/composite/composite-store.js +11 -0
  97. package/esm/dialog/dialog-store.d.ts +10 -0
  98. package/esm/dialog/dialog-store.js +9 -0
  99. package/esm/disclosure/disclosure-store.d.ts +87 -0
  100. package/esm/disclosure/disclosure-store.js +8 -0
  101. package/esm/form/form-store.d.ts +236 -0
  102. package/esm/form/form-store.js +241 -0
  103. package/esm/form/types.d.ts +38 -0
  104. package/esm/form/types.js +0 -0
  105. package/esm/hovercard/hovercard-store.d.ts +45 -0
  106. package/esm/hovercard/hovercard-store.js +11 -0
  107. package/esm/index.d.ts +2 -0
  108. package/esm/index.js +5 -0
  109. package/esm/menu/menu-bar-store.d.ts +10 -0
  110. package/esm/menu/menu-bar-store.js +27 -0
  111. package/esm/menu/menu-store.d.ts +70 -0
  112. package/esm/menu/menu-store.js +108 -0
  113. package/esm/popover/popover-store.d.ts +150 -0
  114. package/esm/popover/popover-store.js +10 -0
  115. package/esm/radio/radio-store.d.ts +31 -0
  116. package/esm/radio/radio-store.js +36 -0
  117. package/esm/select/select-store.d.ts +87 -0
  118. package/esm/select/select-store.js +164 -0
  119. package/esm/tab/tab-store.d.ts +78 -0
  120. package/esm/tab/tab-store.js +126 -0
  121. package/esm/toolbar/toolbar-store.d.ts +21 -0
  122. package/esm/toolbar/toolbar-store.js +27 -0
  123. package/esm/tooltip/tooltip-store.d.ts +28 -0
  124. package/esm/tooltip/tooltip-store.js +98 -0
  125. package/esm/tsconfig.build.tsbuildinfo +1 -0
  126. package/esm/utils/array.d.ts +29 -0
  127. package/esm/utils/array.js +12 -0
  128. package/esm/utils/dom.d.ts +105 -0
  129. package/esm/utils/dom.js +38 -0
  130. package/esm/utils/events.d.ts +73 -0
  131. package/esm/utils/events.js +132 -0
  132. package/esm/utils/focus.d.ts +117 -0
  133. package/esm/utils/focus.js +222 -0
  134. package/esm/utils/misc.d.ts +111 -0
  135. package/esm/utils/misc.js +40 -0
  136. package/esm/utils/platform.d.ts +20 -0
  137. package/esm/utils/platform.js +15 -0
  138. package/esm/utils/store.d.ts +99 -0
  139. package/esm/utils/store.js +9 -0
  140. package/esm/utils/types.d.ts +72 -0
  141. package/esm/utils/types.js +0 -0
  142. package/form/form-store/package.json +7 -0
  143. package/form/types/package.json +7 -0
  144. package/hovercard/hovercard-store/package.json +7 -0
  145. package/license +21 -0
  146. package/menu/menu-bar-store/package.json +7 -0
  147. package/menu/menu-store/package.json +7 -0
  148. package/package.json +137 -6
  149. package/popover/popover-store/package.json +7 -0
  150. package/radio/radio-store/package.json +7 -0
  151. package/select/select-store/package.json +7 -0
  152. package/tab/tab-store/package.json +7 -0
  153. package/toolbar/toolbar-store/package.json +7 -0
  154. package/tooltip/tooltip-store/package.json +7 -0
  155. package/tsconfig.build.json +4 -0
  156. package/utils/array/package.json +7 -0
  157. package/utils/dom/package.json +7 -0
  158. package/utils/events/package.json +7 -0
  159. package/utils/focus/package.json +7 -0
  160. package/utils/misc/package.json +7 -0
  161. package/utils/platform/package.json +7 -0
  162. package/utils/store/package.json +7 -0
  163. package/utils/types/package.json +7 -0
@@ -0,0 +1,1491 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+ var _EFEGT32Mcjs = require('./EFEGT32M.cjs');
4
+
5
+
6
+
7
+ var _3BBA3Z5Gcjs = require('./3BBA3Z5G.cjs');
8
+
9
+
10
+ var _5D5Y5EI4cjs = require('./5D5Y5EI4.cjs');
11
+
12
+ // ../../node_modules/@floating-ui/core/dist/floating-ui.core.mjs
13
+ function getAlignment(placement) {
14
+ return placement.split("-")[1];
15
+ }
16
+ function getLengthFromAxis(axis) {
17
+ return axis === "y" ? "height" : "width";
18
+ }
19
+ function getSide(placement) {
20
+ return placement.split("-")[0];
21
+ }
22
+ function getMainAxisFromPlacement(placement) {
23
+ return ["top", "bottom"].includes(getSide(placement)) ? "x" : "y";
24
+ }
25
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
26
+ let {
27
+ reference,
28
+ floating
29
+ } = _ref;
30
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
31
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
32
+ const mainAxis = getMainAxisFromPlacement(placement);
33
+ const length = getLengthFromAxis(mainAxis);
34
+ const commonAlign = reference[length] / 2 - floating[length] / 2;
35
+ const side = getSide(placement);
36
+ const isVertical = mainAxis === "x";
37
+ let coords;
38
+ switch (side) {
39
+ case "top":
40
+ coords = {
41
+ x: commonX,
42
+ y: reference.y - floating.height
43
+ };
44
+ break;
45
+ case "bottom":
46
+ coords = {
47
+ x: commonX,
48
+ y: reference.y + reference.height
49
+ };
50
+ break;
51
+ case "right":
52
+ coords = {
53
+ x: reference.x + reference.width,
54
+ y: commonY
55
+ };
56
+ break;
57
+ case "left":
58
+ coords = {
59
+ x: reference.x - floating.width,
60
+ y: commonY
61
+ };
62
+ break;
63
+ default:
64
+ coords = {
65
+ x: reference.x,
66
+ y: reference.y
67
+ };
68
+ }
69
+ switch (getAlignment(placement)) {
70
+ case "start":
71
+ coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
72
+ break;
73
+ case "end":
74
+ coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
75
+ break;
76
+ }
77
+ return coords;
78
+ }
79
+ var computePosition = async (reference, floating, config) => {
80
+ const {
81
+ placement = "bottom",
82
+ strategy = "absolute",
83
+ middleware = [],
84
+ platform: platform2
85
+ } = config;
86
+ const validMiddleware = middleware.filter(Boolean);
87
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
88
+ let rects = await platform2.getElementRects({
89
+ reference,
90
+ floating,
91
+ strategy
92
+ });
93
+ let {
94
+ x,
95
+ y
96
+ } = computeCoordsFromPlacement(rects, placement, rtl);
97
+ let statefulPlacement = placement;
98
+ let middlewareData = {};
99
+ let resetCount = 0;
100
+ for (let i = 0; i < validMiddleware.length; i++) {
101
+ const {
102
+ name,
103
+ fn
104
+ } = validMiddleware[i];
105
+ const {
106
+ x: nextX,
107
+ y: nextY,
108
+ data,
109
+ reset
110
+ } = await fn({
111
+ x,
112
+ y,
113
+ initialPlacement: placement,
114
+ placement: statefulPlacement,
115
+ strategy,
116
+ middlewareData,
117
+ rects,
118
+ platform: platform2,
119
+ elements: {
120
+ reference,
121
+ floating
122
+ }
123
+ });
124
+ x = nextX != null ? nextX : x;
125
+ y = nextY != null ? nextY : y;
126
+ middlewareData = {
127
+ ...middlewareData,
128
+ [name]: {
129
+ ...middlewareData[name],
130
+ ...data
131
+ }
132
+ };
133
+ if (reset && resetCount <= 50) {
134
+ resetCount++;
135
+ if (typeof reset === "object") {
136
+ if (reset.placement) {
137
+ statefulPlacement = reset.placement;
138
+ }
139
+ if (reset.rects) {
140
+ rects = reset.rects === true ? await platform2.getElementRects({
141
+ reference,
142
+ floating,
143
+ strategy
144
+ }) : reset.rects;
145
+ }
146
+ ({
147
+ x,
148
+ y
149
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
150
+ }
151
+ i = -1;
152
+ continue;
153
+ }
154
+ }
155
+ return {
156
+ x,
157
+ y,
158
+ placement: statefulPlacement,
159
+ strategy,
160
+ middlewareData
161
+ };
162
+ };
163
+ function expandPaddingObject(padding) {
164
+ return {
165
+ top: 0,
166
+ right: 0,
167
+ bottom: 0,
168
+ left: 0,
169
+ ...padding
170
+ };
171
+ }
172
+ function getSideObjectFromPadding(padding) {
173
+ return typeof padding !== "number" ? expandPaddingObject(padding) : {
174
+ top: padding,
175
+ right: padding,
176
+ bottom: padding,
177
+ left: padding
178
+ };
179
+ }
180
+ function rectToClientRect(rect) {
181
+ return {
182
+ ...rect,
183
+ top: rect.y,
184
+ left: rect.x,
185
+ right: rect.x + rect.width,
186
+ bottom: rect.y + rect.height
187
+ };
188
+ }
189
+ async function detectOverflow(state, options) {
190
+ var _await$platform$isEle;
191
+ if (options === void 0) {
192
+ options = {};
193
+ }
194
+ const {
195
+ x,
196
+ y,
197
+ platform: platform2,
198
+ rects,
199
+ elements,
200
+ strategy
201
+ } = state;
202
+ const {
203
+ boundary = "clippingAncestors",
204
+ rootBoundary = "viewport",
205
+ elementContext = "floating",
206
+ altBoundary = false,
207
+ padding = 0
208
+ } = options;
209
+ const paddingObject = getSideObjectFromPadding(padding);
210
+ const altContext = elementContext === "floating" ? "reference" : "floating";
211
+ const element = elements[altBoundary ? altContext : elementContext];
212
+ const clippingClientRect = rectToClientRect(await platform2.getClippingRect({
213
+ element: ((_await$platform$isEle = await (platform2.isElement == null ? void 0 : platform2.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform2.getDocumentElement == null ? void 0 : platform2.getDocumentElement(elements.floating)),
214
+ boundary,
215
+ rootBoundary,
216
+ strategy
217
+ }));
218
+ const rect = elementContext === "floating" ? {
219
+ ...rects.floating,
220
+ x,
221
+ y
222
+ } : rects.reference;
223
+ const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
224
+ const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
225
+ x: 1,
226
+ y: 1
227
+ } : {
228
+ x: 1,
229
+ y: 1
230
+ };
231
+ const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
232
+ rect,
233
+ offsetParent,
234
+ strategy
235
+ }) : rect);
236
+ return {
237
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
238
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
239
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
240
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
241
+ };
242
+ }
243
+ var min = Math.min;
244
+ var max = Math.max;
245
+ function within(min$1, value, max$1) {
246
+ return max(min$1, min(value, max$1));
247
+ }
248
+ var arrow = (options) => ({
249
+ name: "arrow",
250
+ options,
251
+ async fn(state) {
252
+ const {
253
+ element,
254
+ padding = 0
255
+ } = options || {};
256
+ const {
257
+ x,
258
+ y,
259
+ placement,
260
+ rects,
261
+ platform: platform2,
262
+ elements
263
+ } = state;
264
+ if (element == null) {
265
+ return {};
266
+ }
267
+ const paddingObject = getSideObjectFromPadding(padding);
268
+ const coords = {
269
+ x,
270
+ y
271
+ };
272
+ const axis = getMainAxisFromPlacement(placement);
273
+ const length = getLengthFromAxis(axis);
274
+ const arrowDimensions = await platform2.getDimensions(element);
275
+ const isYAxis = axis === "y";
276
+ const minProp = isYAxis ? "top" : "left";
277
+ const maxProp = isYAxis ? "bottom" : "right";
278
+ const clientProp = isYAxis ? "clientHeight" : "clientWidth";
279
+ const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
280
+ const startDiff = coords[axis] - rects.reference[axis];
281
+ const arrowOffsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(element));
282
+ let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
283
+ if (!clientSize || !await (platform2.isElement == null ? void 0 : platform2.isElement(arrowOffsetParent))) {
284
+ clientSize = elements.floating[clientProp] || rects.floating[length];
285
+ }
286
+ const centerToReference = endDiff / 2 - startDiff / 2;
287
+ const min3 = paddingObject[minProp];
288
+ const max3 = clientSize - arrowDimensions[length] - paddingObject[maxProp];
289
+ const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
290
+ const offset2 = within(min3, center, max3);
291
+ const shouldAddOffset = getAlignment(placement) != null && center != offset2 && rects.reference[length] / 2 - (center < min3 ? paddingObject[minProp] : paddingObject[maxProp]) - arrowDimensions[length] / 2 < 0;
292
+ const alignmentOffset = shouldAddOffset ? center < min3 ? min3 - center : max3 - center : 0;
293
+ return {
294
+ [axis]: coords[axis] - alignmentOffset,
295
+ data: {
296
+ [axis]: offset2,
297
+ centerOffset: center - offset2
298
+ }
299
+ };
300
+ }
301
+ });
302
+ var oppositeSideMap = {
303
+ left: "right",
304
+ right: "left",
305
+ bottom: "top",
306
+ top: "bottom"
307
+ };
308
+ function getOppositePlacement(placement) {
309
+ return placement.replace(/left|right|bottom|top/g, (side) => oppositeSideMap[side]);
310
+ }
311
+ function getAlignmentSides(placement, rects, rtl) {
312
+ if (rtl === void 0) {
313
+ rtl = false;
314
+ }
315
+ const alignment = getAlignment(placement);
316
+ const mainAxis = getMainAxisFromPlacement(placement);
317
+ const length = getLengthFromAxis(mainAxis);
318
+ let mainAlignmentSide = mainAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
319
+ if (rects.reference[length] > rects.floating[length]) {
320
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
321
+ }
322
+ return {
323
+ main: mainAlignmentSide,
324
+ cross: getOppositePlacement(mainAlignmentSide)
325
+ };
326
+ }
327
+ var oppositeAlignmentMap = {
328
+ start: "end",
329
+ end: "start"
330
+ };
331
+ function getOppositeAlignmentPlacement(placement) {
332
+ return placement.replace(/start|end/g, (alignment) => oppositeAlignmentMap[alignment]);
333
+ }
334
+ function getExpandedPlacements(placement) {
335
+ const oppositePlacement = getOppositePlacement(placement);
336
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
337
+ }
338
+ function getSideList(side, isStart, rtl) {
339
+ const lr = ["left", "right"];
340
+ const rl = ["right", "left"];
341
+ const tb = ["top", "bottom"];
342
+ const bt = ["bottom", "top"];
343
+ switch (side) {
344
+ case "top":
345
+ case "bottom":
346
+ if (rtl)
347
+ return isStart ? rl : lr;
348
+ return isStart ? lr : rl;
349
+ case "left":
350
+ case "right":
351
+ return isStart ? tb : bt;
352
+ default:
353
+ return [];
354
+ }
355
+ }
356
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
357
+ const alignment = getAlignment(placement);
358
+ let list = getSideList(getSide(placement), direction === "start", rtl);
359
+ if (alignment) {
360
+ list = list.map((side) => side + "-" + alignment);
361
+ if (flipAlignment) {
362
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
363
+ }
364
+ }
365
+ return list;
366
+ }
367
+ var flip = function(options) {
368
+ if (options === void 0) {
369
+ options = {};
370
+ }
371
+ return {
372
+ name: "flip",
373
+ options,
374
+ async fn(state) {
375
+ var _middlewareData$flip;
376
+ const {
377
+ placement,
378
+ middlewareData,
379
+ rects,
380
+ initialPlacement,
381
+ platform: platform2,
382
+ elements
383
+ } = state;
384
+ const {
385
+ mainAxis: checkMainAxis = true,
386
+ crossAxis: checkCrossAxis = true,
387
+ fallbackPlacements: specifiedFallbackPlacements,
388
+ fallbackStrategy = "bestFit",
389
+ fallbackAxisSideDirection = "none",
390
+ flipAlignment = true,
391
+ ...detectOverflowOptions
392
+ } = options;
393
+ const side = getSide(placement);
394
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
395
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
396
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
397
+ if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== "none") {
398
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
399
+ }
400
+ const placements = [initialPlacement, ...fallbackPlacements];
401
+ const overflow = await detectOverflow(state, detectOverflowOptions);
402
+ const overflows = [];
403
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
404
+ if (checkMainAxis) {
405
+ overflows.push(overflow[side]);
406
+ }
407
+ if (checkCrossAxis) {
408
+ const {
409
+ main,
410
+ cross
411
+ } = getAlignmentSides(placement, rects, rtl);
412
+ overflows.push(overflow[main], overflow[cross]);
413
+ }
414
+ overflowsData = [...overflowsData, {
415
+ placement,
416
+ overflows
417
+ }];
418
+ if (!overflows.every((side2) => side2 <= 0)) {
419
+ var _middlewareData$flip2, _overflowsData$filter;
420
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
421
+ const nextPlacement = placements[nextIndex];
422
+ if (nextPlacement) {
423
+ return {
424
+ data: {
425
+ index: nextIndex,
426
+ overflows: overflowsData
427
+ },
428
+ reset: {
429
+ placement: nextPlacement
430
+ }
431
+ };
432
+ }
433
+ 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;
434
+ if (!resetPlacement) {
435
+ switch (fallbackStrategy) {
436
+ case "bestFit": {
437
+ var _overflowsData$map$so;
438
+ const placement2 = (_overflowsData$map$so = overflowsData.map((d) => [d.placement, d.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0];
439
+ if (placement2) {
440
+ resetPlacement = placement2;
441
+ }
442
+ break;
443
+ }
444
+ case "initialPlacement":
445
+ resetPlacement = initialPlacement;
446
+ break;
447
+ }
448
+ }
449
+ if (placement !== resetPlacement) {
450
+ return {
451
+ reset: {
452
+ placement: resetPlacement
453
+ }
454
+ };
455
+ }
456
+ }
457
+ return {};
458
+ }
459
+ };
460
+ };
461
+ async function convertValueToCoords(state, value) {
462
+ const {
463
+ placement,
464
+ platform: platform2,
465
+ elements
466
+ } = state;
467
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
468
+ const side = getSide(placement);
469
+ const alignment = getAlignment(placement);
470
+ const isVertical = getMainAxisFromPlacement(placement) === "x";
471
+ const mainAxisMulti = ["left", "top"].includes(side) ? -1 : 1;
472
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
473
+ const rawValue = typeof value === "function" ? value(state) : value;
474
+ let {
475
+ mainAxis,
476
+ crossAxis,
477
+ alignmentAxis
478
+ } = typeof rawValue === "number" ? {
479
+ mainAxis: rawValue,
480
+ crossAxis: 0,
481
+ alignmentAxis: null
482
+ } : {
483
+ mainAxis: 0,
484
+ crossAxis: 0,
485
+ alignmentAxis: null,
486
+ ...rawValue
487
+ };
488
+ if (alignment && typeof alignmentAxis === "number") {
489
+ crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
490
+ }
491
+ return isVertical ? {
492
+ x: crossAxis * crossAxisMulti,
493
+ y: mainAxis * mainAxisMulti
494
+ } : {
495
+ x: mainAxis * mainAxisMulti,
496
+ y: crossAxis * crossAxisMulti
497
+ };
498
+ }
499
+ var offset = function(value) {
500
+ if (value === void 0) {
501
+ value = 0;
502
+ }
503
+ return {
504
+ name: "offset",
505
+ options: value,
506
+ async fn(state) {
507
+ const {
508
+ x,
509
+ y
510
+ } = state;
511
+ const diffCoords = await convertValueToCoords(state, value);
512
+ return {
513
+ x: x + diffCoords.x,
514
+ y: y + diffCoords.y,
515
+ data: diffCoords
516
+ };
517
+ }
518
+ };
519
+ };
520
+ function getCrossAxis(axis) {
521
+ return axis === "x" ? "y" : "x";
522
+ }
523
+ var shift = function(options) {
524
+ if (options === void 0) {
525
+ options = {};
526
+ }
527
+ return {
528
+ name: "shift",
529
+ options,
530
+ async fn(state) {
531
+ const {
532
+ x,
533
+ y,
534
+ placement
535
+ } = state;
536
+ const {
537
+ mainAxis: checkMainAxis = true,
538
+ crossAxis: checkCrossAxis = false,
539
+ limiter = {
540
+ fn: (_ref) => {
541
+ let {
542
+ x: x2,
543
+ y: y2
544
+ } = _ref;
545
+ return {
546
+ x: x2,
547
+ y: y2
548
+ };
549
+ }
550
+ },
551
+ ...detectOverflowOptions
552
+ } = options;
553
+ const coords = {
554
+ x,
555
+ y
556
+ };
557
+ const overflow = await detectOverflow(state, detectOverflowOptions);
558
+ const mainAxis = getMainAxisFromPlacement(getSide(placement));
559
+ const crossAxis = getCrossAxis(mainAxis);
560
+ let mainAxisCoord = coords[mainAxis];
561
+ let crossAxisCoord = coords[crossAxis];
562
+ if (checkMainAxis) {
563
+ const minSide = mainAxis === "y" ? "top" : "left";
564
+ const maxSide = mainAxis === "y" ? "bottom" : "right";
565
+ const min3 = mainAxisCoord + overflow[minSide];
566
+ const max3 = mainAxisCoord - overflow[maxSide];
567
+ mainAxisCoord = within(min3, mainAxisCoord, max3);
568
+ }
569
+ if (checkCrossAxis) {
570
+ const minSide = crossAxis === "y" ? "top" : "left";
571
+ const maxSide = crossAxis === "y" ? "bottom" : "right";
572
+ const min3 = crossAxisCoord + overflow[minSide];
573
+ const max3 = crossAxisCoord - overflow[maxSide];
574
+ crossAxisCoord = within(min3, crossAxisCoord, max3);
575
+ }
576
+ const limitedCoords = limiter.fn({
577
+ ...state,
578
+ [mainAxis]: mainAxisCoord,
579
+ [crossAxis]: crossAxisCoord
580
+ });
581
+ return {
582
+ ...limitedCoords,
583
+ data: {
584
+ x: limitedCoords.x - x,
585
+ y: limitedCoords.y - y
586
+ }
587
+ };
588
+ }
589
+ };
590
+ };
591
+ var size = function(options) {
592
+ if (options === void 0) {
593
+ options = {};
594
+ }
595
+ return {
596
+ name: "size",
597
+ options,
598
+ async fn(state) {
599
+ const {
600
+ placement,
601
+ rects,
602
+ platform: platform2,
603
+ elements
604
+ } = state;
605
+ const {
606
+ apply = () => {
607
+ },
608
+ ...detectOverflowOptions
609
+ } = options;
610
+ const overflow = await detectOverflow(state, detectOverflowOptions);
611
+ const side = getSide(placement);
612
+ const alignment = getAlignment(placement);
613
+ const axis = getMainAxisFromPlacement(placement);
614
+ const isXAxis = axis === "x";
615
+ const {
616
+ width,
617
+ height
618
+ } = rects.floating;
619
+ let heightSide;
620
+ let widthSide;
621
+ if (side === "top" || side === "bottom") {
622
+ heightSide = side;
623
+ widthSide = alignment === (await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
624
+ } else {
625
+ widthSide = side;
626
+ heightSide = alignment === "end" ? "top" : "bottom";
627
+ }
628
+ const overflowAvailableHeight = height - overflow[heightSide];
629
+ const overflowAvailableWidth = width - overflow[widthSide];
630
+ const noShift = !state.middlewareData.shift;
631
+ let availableHeight = overflowAvailableHeight;
632
+ let availableWidth = overflowAvailableWidth;
633
+ if (isXAxis) {
634
+ const maximumClippingWidth = width - overflow.left - overflow.right;
635
+ availableWidth = alignment || noShift ? min(overflowAvailableWidth, maximumClippingWidth) : maximumClippingWidth;
636
+ } else {
637
+ const maximumClippingHeight = height - overflow.top - overflow.bottom;
638
+ availableHeight = alignment || noShift ? min(overflowAvailableHeight, maximumClippingHeight) : maximumClippingHeight;
639
+ }
640
+ if (noShift && !alignment) {
641
+ const xMin = max(overflow.left, 0);
642
+ const xMax = max(overflow.right, 0);
643
+ const yMin = max(overflow.top, 0);
644
+ const yMax = max(overflow.bottom, 0);
645
+ if (isXAxis) {
646
+ availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
647
+ } else {
648
+ availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
649
+ }
650
+ }
651
+ await apply({
652
+ ...state,
653
+ availableWidth,
654
+ availableHeight
655
+ });
656
+ const nextDimensions = await platform2.getDimensions(elements.floating);
657
+ if (width !== nextDimensions.width || height !== nextDimensions.height) {
658
+ return {
659
+ reset: {
660
+ rects: true
661
+ }
662
+ };
663
+ }
664
+ return {};
665
+ }
666
+ };
667
+ };
668
+
669
+ // ../../node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
670
+ function getWindow(node) {
671
+ var _node$ownerDocument;
672
+ return ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
673
+ }
674
+ function getComputedStyle$1(element) {
675
+ return getWindow(element).getComputedStyle(element);
676
+ }
677
+ function isNode(value) {
678
+ return value instanceof getWindow(value).Node;
679
+ }
680
+ function getNodeName(node) {
681
+ return isNode(node) ? (node.nodeName || "").toLowerCase() : "";
682
+ }
683
+ var uaString;
684
+ function getUAString() {
685
+ if (uaString) {
686
+ return uaString;
687
+ }
688
+ const uaData = navigator.userAgentData;
689
+ if (uaData && Array.isArray(uaData.brands)) {
690
+ uaString = uaData.brands.map((item) => item.brand + "/" + item.version).join(" ");
691
+ return uaString;
692
+ }
693
+ return navigator.userAgent;
694
+ }
695
+ function isHTMLElement(value) {
696
+ return value instanceof getWindow(value).HTMLElement;
697
+ }
698
+ function isElement(value) {
699
+ return value instanceof getWindow(value).Element;
700
+ }
701
+ function isShadowRoot(node) {
702
+ if (typeof ShadowRoot === "undefined") {
703
+ return false;
704
+ }
705
+ const OwnElement = getWindow(node).ShadowRoot;
706
+ return node instanceof OwnElement || node instanceof ShadowRoot;
707
+ }
708
+ function isOverflowElement(element) {
709
+ const {
710
+ overflow,
711
+ overflowX,
712
+ overflowY,
713
+ display
714
+ } = getComputedStyle$1(element);
715
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !["inline", "contents"].includes(display);
716
+ }
717
+ function isTableElement(element) {
718
+ return ["table", "td", "th"].includes(getNodeName(element));
719
+ }
720
+ function isContainingBlock(element) {
721
+ const isFirefox = /firefox/i.test(getUAString());
722
+ const css = getComputedStyle$1(element);
723
+ const backdropFilter = css.backdropFilter || css.WebkitBackdropFilter;
724
+ return css.transform !== "none" || css.perspective !== "none" || (backdropFilter ? backdropFilter !== "none" : false) || isFirefox && css.willChange === "filter" || isFirefox && (css.filter ? css.filter !== "none" : false) || ["transform", "perspective"].some((value) => css.willChange.includes(value)) || ["paint", "layout", "strict", "content"].some((value) => {
725
+ const contain = css.contain;
726
+ return contain != null ? contain.includes(value) : false;
727
+ });
728
+ }
729
+ function isClientRectVisualViewportBased() {
730
+ return /^((?!chrome|android).)*safari/i.test(getUAString());
731
+ }
732
+ function isLastTraversableNode(node) {
733
+ return ["html", "body", "#document"].includes(getNodeName(node));
734
+ }
735
+ var min2 = Math.min;
736
+ var max2 = Math.max;
737
+ var round = Math.round;
738
+ function getCssDimensions(element) {
739
+ const css = getComputedStyle$1(element);
740
+ let width = parseFloat(css.width);
741
+ let height = parseFloat(css.height);
742
+ const hasOffset = isHTMLElement(element);
743
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
744
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
745
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
746
+ if (shouldFallback) {
747
+ width = offsetWidth;
748
+ height = offsetHeight;
749
+ }
750
+ return {
751
+ width,
752
+ height,
753
+ fallback: shouldFallback
754
+ };
755
+ }
756
+ function unwrapElement(element) {
757
+ return !isElement(element) ? element.contextElement : element;
758
+ }
759
+ var FALLBACK_SCALE = {
760
+ x: 1,
761
+ y: 1
762
+ };
763
+ function getScale(element) {
764
+ const domElement = unwrapElement(element);
765
+ if (!isHTMLElement(domElement)) {
766
+ return FALLBACK_SCALE;
767
+ }
768
+ const rect = domElement.getBoundingClientRect();
769
+ const {
770
+ width,
771
+ height,
772
+ fallback
773
+ } = getCssDimensions(domElement);
774
+ let x = (fallback ? round(rect.width) : rect.width) / width;
775
+ let y = (fallback ? round(rect.height) : rect.height) / height;
776
+ if (!x || !Number.isFinite(x)) {
777
+ x = 1;
778
+ }
779
+ if (!y || !Number.isFinite(y)) {
780
+ y = 1;
781
+ }
782
+ return {
783
+ x,
784
+ y
785
+ };
786
+ }
787
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
788
+ var _win$visualViewport, _win$visualViewport2;
789
+ if (includeScale === void 0) {
790
+ includeScale = false;
791
+ }
792
+ if (isFixedStrategy === void 0) {
793
+ isFixedStrategy = false;
794
+ }
795
+ const clientRect = element.getBoundingClientRect();
796
+ const domElement = unwrapElement(element);
797
+ let scale = FALLBACK_SCALE;
798
+ if (includeScale) {
799
+ if (offsetParent) {
800
+ if (isElement(offsetParent)) {
801
+ scale = getScale(offsetParent);
802
+ }
803
+ } else {
804
+ scale = getScale(element);
805
+ }
806
+ }
807
+ const win = domElement ? getWindow(domElement) : window;
808
+ const addVisualOffsets = isClientRectVisualViewportBased() && isFixedStrategy;
809
+ let x = (clientRect.left + (addVisualOffsets ? ((_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) || 0 : 0)) / scale.x;
810
+ let y = (clientRect.top + (addVisualOffsets ? ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0 : 0)) / scale.y;
811
+ let width = clientRect.width / scale.x;
812
+ let height = clientRect.height / scale.y;
813
+ if (domElement) {
814
+ const win2 = getWindow(domElement);
815
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
816
+ let currentIFrame = win2.frameElement;
817
+ while (currentIFrame && offsetParent && offsetWin !== win2) {
818
+ const iframeScale = getScale(currentIFrame);
819
+ const iframeRect = currentIFrame.getBoundingClientRect();
820
+ const css = getComputedStyle(currentIFrame);
821
+ iframeRect.x += (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
822
+ iframeRect.y += (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
823
+ x *= iframeScale.x;
824
+ y *= iframeScale.y;
825
+ width *= iframeScale.x;
826
+ height *= iframeScale.y;
827
+ x += iframeRect.x;
828
+ y += iframeRect.y;
829
+ currentIFrame = getWindow(currentIFrame).frameElement;
830
+ }
831
+ }
832
+ return rectToClientRect({
833
+ width,
834
+ height,
835
+ x,
836
+ y
837
+ });
838
+ }
839
+ function getDocumentElement(node) {
840
+ return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
841
+ }
842
+ function getNodeScroll(element) {
843
+ if (isElement(element)) {
844
+ return {
845
+ scrollLeft: element.scrollLeft,
846
+ scrollTop: element.scrollTop
847
+ };
848
+ }
849
+ return {
850
+ scrollLeft: element.pageXOffset,
851
+ scrollTop: element.pageYOffset
852
+ };
853
+ }
854
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
855
+ let {
856
+ rect,
857
+ offsetParent,
858
+ strategy
859
+ } = _ref;
860
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
861
+ const documentElement = getDocumentElement(offsetParent);
862
+ if (offsetParent === documentElement) {
863
+ return rect;
864
+ }
865
+ let scroll = {
866
+ scrollLeft: 0,
867
+ scrollTop: 0
868
+ };
869
+ let scale = {
870
+ x: 1,
871
+ y: 1
872
+ };
873
+ const offsets = {
874
+ x: 0,
875
+ y: 0
876
+ };
877
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== "fixed") {
878
+ if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
879
+ scroll = getNodeScroll(offsetParent);
880
+ }
881
+ if (isHTMLElement(offsetParent)) {
882
+ const offsetRect = getBoundingClientRect(offsetParent);
883
+ scale = getScale(offsetParent);
884
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
885
+ offsets.y = offsetRect.y + offsetParent.clientTop;
886
+ }
887
+ }
888
+ return {
889
+ width: rect.width * scale.x,
890
+ height: rect.height * scale.y,
891
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x,
892
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y
893
+ };
894
+ }
895
+ function getWindowScrollBarX(element) {
896
+ return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
897
+ }
898
+ function getDocumentRect(element) {
899
+ const html = getDocumentElement(element);
900
+ const scroll = getNodeScroll(element);
901
+ const body = element.ownerDocument.body;
902
+ const width = max2(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
903
+ const height = max2(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
904
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
905
+ const y = -scroll.scrollTop;
906
+ if (getComputedStyle$1(body).direction === "rtl") {
907
+ x += max2(html.clientWidth, body.clientWidth) - width;
908
+ }
909
+ return {
910
+ width,
911
+ height,
912
+ x,
913
+ y
914
+ };
915
+ }
916
+ function getParentNode(node) {
917
+ if (getNodeName(node) === "html") {
918
+ return node;
919
+ }
920
+ const result = (
921
+ // Step into the shadow DOM of the parent of a slotted node.
922
+ node.assignedSlot || // DOM Element detected.
923
+ node.parentNode || // ShadowRoot detected.
924
+ isShadowRoot(node) && node.host || // Fallback.
925
+ getDocumentElement(node)
926
+ );
927
+ return isShadowRoot(result) ? result.host : result;
928
+ }
929
+ function getNearestOverflowAncestor(node) {
930
+ const parentNode = getParentNode(node);
931
+ if (isLastTraversableNode(parentNode)) {
932
+ return parentNode.ownerDocument.body;
933
+ }
934
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
935
+ return parentNode;
936
+ }
937
+ return getNearestOverflowAncestor(parentNode);
938
+ }
939
+ function getOverflowAncestors(node, list) {
940
+ var _node$ownerDocument;
941
+ if (list === void 0) {
942
+ list = [];
943
+ }
944
+ const scrollableAncestor = getNearestOverflowAncestor(node);
945
+ const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
946
+ const win = getWindow(scrollableAncestor);
947
+ if (isBody) {
948
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []);
949
+ }
950
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor));
951
+ }
952
+ function getViewportRect(element, strategy) {
953
+ const win = getWindow(element);
954
+ const html = getDocumentElement(element);
955
+ const visualViewport = win.visualViewport;
956
+ let width = html.clientWidth;
957
+ let height = html.clientHeight;
958
+ let x = 0;
959
+ let y = 0;
960
+ if (visualViewport) {
961
+ width = visualViewport.width;
962
+ height = visualViewport.height;
963
+ const visualViewportBased = isClientRectVisualViewportBased();
964
+ if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
965
+ x = visualViewport.offsetLeft;
966
+ y = visualViewport.offsetTop;
967
+ }
968
+ }
969
+ return {
970
+ width,
971
+ height,
972
+ x,
973
+ y
974
+ };
975
+ }
976
+ function getInnerBoundingClientRect(element, strategy) {
977
+ const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
978
+ const top = clientRect.top + element.clientTop;
979
+ const left = clientRect.left + element.clientLeft;
980
+ const scale = isHTMLElement(element) ? getScale(element) : {
981
+ x: 1,
982
+ y: 1
983
+ };
984
+ const width = element.clientWidth * scale.x;
985
+ const height = element.clientHeight * scale.y;
986
+ const x = left * scale.x;
987
+ const y = top * scale.y;
988
+ return {
989
+ width,
990
+ height,
991
+ x,
992
+ y
993
+ };
994
+ }
995
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
996
+ let rect;
997
+ if (clippingAncestor === "viewport") {
998
+ rect = getViewportRect(element, strategy);
999
+ } else if (clippingAncestor === "document") {
1000
+ rect = getDocumentRect(getDocumentElement(element));
1001
+ } else if (isElement(clippingAncestor)) {
1002
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
1003
+ } else {
1004
+ const mutableRect = {
1005
+ ...clippingAncestor
1006
+ };
1007
+ if (isClientRectVisualViewportBased()) {
1008
+ var _win$visualViewport, _win$visualViewport2;
1009
+ const win = getWindow(element);
1010
+ mutableRect.x -= ((_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) || 0;
1011
+ mutableRect.y -= ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0;
1012
+ }
1013
+ rect = mutableRect;
1014
+ }
1015
+ return rectToClientRect(rect);
1016
+ }
1017
+ function getClippingElementAncestors(element, cache) {
1018
+ const cachedResult = cache.get(element);
1019
+ if (cachedResult) {
1020
+ return cachedResult;
1021
+ }
1022
+ let result = getOverflowAncestors(element).filter((el) => isElement(el) && getNodeName(el) !== "body");
1023
+ let currentContainingBlockComputedStyle = null;
1024
+ const elementIsFixed = getComputedStyle$1(element).position === "fixed";
1025
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
1026
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
1027
+ const computedStyle = getComputedStyle$1(currentNode);
1028
+ const containingBlock = isContainingBlock(currentNode);
1029
+ if (computedStyle.position === "fixed") {
1030
+ currentContainingBlockComputedStyle = null;
1031
+ }
1032
+ const shouldDropCurrentNode = elementIsFixed ? !containingBlock && !currentContainingBlockComputedStyle : !containingBlock && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && ["absolute", "fixed"].includes(currentContainingBlockComputedStyle.position);
1033
+ if (shouldDropCurrentNode) {
1034
+ result = result.filter((ancestor) => ancestor !== currentNode);
1035
+ } else {
1036
+ currentContainingBlockComputedStyle = computedStyle;
1037
+ }
1038
+ currentNode = getParentNode(currentNode);
1039
+ }
1040
+ cache.set(element, result);
1041
+ return result;
1042
+ }
1043
+ function getClippingRect(_ref) {
1044
+ let {
1045
+ element,
1046
+ boundary,
1047
+ rootBoundary,
1048
+ strategy
1049
+ } = _ref;
1050
+ const elementClippingAncestors = boundary === "clippingAncestors" ? getClippingElementAncestors(element, this._c) : [].concat(boundary);
1051
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
1052
+ const firstClippingAncestor = clippingAncestors[0];
1053
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1054
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1055
+ accRect.top = max2(rect.top, accRect.top);
1056
+ accRect.right = min2(rect.right, accRect.right);
1057
+ accRect.bottom = min2(rect.bottom, accRect.bottom);
1058
+ accRect.left = max2(rect.left, accRect.left);
1059
+ return accRect;
1060
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1061
+ return {
1062
+ width: clippingRect.right - clippingRect.left,
1063
+ height: clippingRect.bottom - clippingRect.top,
1064
+ x: clippingRect.left,
1065
+ y: clippingRect.top
1066
+ };
1067
+ }
1068
+ function getDimensions(element) {
1069
+ return getCssDimensions(element);
1070
+ }
1071
+ function getTrueOffsetParent(element, polyfill) {
1072
+ if (!isHTMLElement(element) || getComputedStyle$1(element).position === "fixed") {
1073
+ return null;
1074
+ }
1075
+ if (polyfill) {
1076
+ return polyfill(element);
1077
+ }
1078
+ return element.offsetParent;
1079
+ }
1080
+ function getContainingBlock(element) {
1081
+ let currentNode = getParentNode(element);
1082
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
1083
+ if (isContainingBlock(currentNode)) {
1084
+ return currentNode;
1085
+ } else {
1086
+ currentNode = getParentNode(currentNode);
1087
+ }
1088
+ }
1089
+ return null;
1090
+ }
1091
+ function getOffsetParent(element, polyfill) {
1092
+ const window2 = getWindow(element);
1093
+ if (!isHTMLElement(element)) {
1094
+ return window2;
1095
+ }
1096
+ let offsetParent = getTrueOffsetParent(element, polyfill);
1097
+ while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === "static") {
1098
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
1099
+ }
1100
+ if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle$1(offsetParent).position === "static" && !isContainingBlock(offsetParent))) {
1101
+ return window2;
1102
+ }
1103
+ return offsetParent || getContainingBlock(element) || window2;
1104
+ }
1105
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1106
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1107
+ const documentElement = getDocumentElement(offsetParent);
1108
+ const rect = getBoundingClientRect(element, true, strategy === "fixed", offsetParent);
1109
+ let scroll = {
1110
+ scrollLeft: 0,
1111
+ scrollTop: 0
1112
+ };
1113
+ const offsets = {
1114
+ x: 0,
1115
+ y: 0
1116
+ };
1117
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== "fixed") {
1118
+ if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
1119
+ scroll = getNodeScroll(offsetParent);
1120
+ }
1121
+ if (isHTMLElement(offsetParent)) {
1122
+ const offsetRect = getBoundingClientRect(offsetParent, true);
1123
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1124
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1125
+ } else if (documentElement) {
1126
+ offsets.x = getWindowScrollBarX(documentElement);
1127
+ }
1128
+ }
1129
+ return {
1130
+ x: rect.left + scroll.scrollLeft - offsets.x,
1131
+ y: rect.top + scroll.scrollTop - offsets.y,
1132
+ width: rect.width,
1133
+ height: rect.height
1134
+ };
1135
+ }
1136
+ var platform = {
1137
+ getClippingRect,
1138
+ convertOffsetParentRelativeRectToViewportRelativeRect,
1139
+ isElement,
1140
+ getDimensions,
1141
+ getOffsetParent,
1142
+ getDocumentElement,
1143
+ getScale,
1144
+ async getElementRects(_ref) {
1145
+ let {
1146
+ reference,
1147
+ floating,
1148
+ strategy
1149
+ } = _ref;
1150
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
1151
+ const getDimensionsFn = this.getDimensions;
1152
+ return {
1153
+ reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
1154
+ floating: {
1155
+ x: 0,
1156
+ y: 0,
1157
+ ...await getDimensionsFn(floating)
1158
+ }
1159
+ };
1160
+ },
1161
+ getClientRects: (element) => Array.from(element.getClientRects()),
1162
+ isRTL: (element) => getComputedStyle$1(element).direction === "rtl"
1163
+ };
1164
+ function autoUpdate(reference, floating, update, options) {
1165
+ if (options === void 0) {
1166
+ options = {};
1167
+ }
1168
+ const {
1169
+ ancestorScroll: _ancestorScroll = true,
1170
+ ancestorResize = true,
1171
+ elementResize = true,
1172
+ animationFrame = false
1173
+ } = options;
1174
+ const ancestorScroll = _ancestorScroll && !animationFrame;
1175
+ const ancestors = ancestorScroll || ancestorResize ? [...isElement(reference) ? getOverflowAncestors(reference) : reference.contextElement ? getOverflowAncestors(reference.contextElement) : [], ...getOverflowAncestors(floating)] : [];
1176
+ ancestors.forEach((ancestor) => {
1177
+ ancestorScroll && ancestor.addEventListener("scroll", update, {
1178
+ passive: true
1179
+ });
1180
+ ancestorResize && ancestor.addEventListener("resize", update);
1181
+ });
1182
+ let observer = null;
1183
+ if (elementResize) {
1184
+ observer = new ResizeObserver(() => {
1185
+ update();
1186
+ });
1187
+ isElement(reference) && !animationFrame && observer.observe(reference);
1188
+ if (!isElement(reference) && reference.contextElement && !animationFrame) {
1189
+ observer.observe(reference.contextElement);
1190
+ }
1191
+ observer.observe(floating);
1192
+ }
1193
+ let frameId;
1194
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
1195
+ if (animationFrame) {
1196
+ frameLoop();
1197
+ }
1198
+ function frameLoop() {
1199
+ const nextRefRect = getBoundingClientRect(reference);
1200
+ if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
1201
+ update();
1202
+ }
1203
+ prevRefRect = nextRefRect;
1204
+ frameId = requestAnimationFrame(frameLoop);
1205
+ }
1206
+ update();
1207
+ return () => {
1208
+ var _observer;
1209
+ ancestors.forEach((ancestor) => {
1210
+ ancestorScroll && ancestor.removeEventListener("scroll", update);
1211
+ ancestorResize && ancestor.removeEventListener("resize", update);
1212
+ });
1213
+ (_observer = observer) == null ? void 0 : _observer.disconnect();
1214
+ observer = null;
1215
+ if (animationFrame) {
1216
+ cancelAnimationFrame(frameId);
1217
+ }
1218
+ };
1219
+ }
1220
+ var computePosition2 = (reference, floating, options) => {
1221
+ const cache = /* @__PURE__ */ new Map();
1222
+ const mergedOptions = {
1223
+ platform,
1224
+ ...options
1225
+ };
1226
+ const platformWithCache = {
1227
+ ...mergedOptions.platform,
1228
+ _c: cache
1229
+ };
1230
+ return computePosition(reference, floating, {
1231
+ ...mergedOptions,
1232
+ platform: platformWithCache
1233
+ });
1234
+ };
1235
+
1236
+ // src/popover/popover-store.ts
1237
+ var middlewares = { arrow, flip, offset, shift, size };
1238
+ function createDOMRect(x = 0, y = 0, width = 0, height = 0) {
1239
+ if (typeof DOMRect === "function") {
1240
+ return new DOMRect(x, y, width, height);
1241
+ }
1242
+ const rect = {
1243
+ x,
1244
+ y,
1245
+ width,
1246
+ height,
1247
+ top: y,
1248
+ right: x + width,
1249
+ bottom: y + height,
1250
+ left: x
1251
+ };
1252
+ return { ...rect, toJSON: () => rect };
1253
+ }
1254
+ function getDOMRect(anchorRect) {
1255
+ if (!anchorRect)
1256
+ return createDOMRect();
1257
+ const { x, y, width, height } = anchorRect;
1258
+ return createDOMRect(x, y, width, height);
1259
+ }
1260
+ function getAnchorElement(anchorElement, getAnchorRect) {
1261
+ const contextElement = anchorElement || void 0;
1262
+ return {
1263
+ contextElement,
1264
+ getBoundingClientRect: () => {
1265
+ const anchor = anchorElement;
1266
+ const anchorRect = _optionalChain([getAnchorRect, 'optionalCall', _ => _(anchor)]);
1267
+ if (anchorRect || !anchor) {
1268
+ return getDOMRect(anchorRect);
1269
+ }
1270
+ return anchor.getBoundingClientRect();
1271
+ }
1272
+ };
1273
+ }
1274
+ function isValidPlacement(flip2) {
1275
+ return /^(?:top|bottom|left|right)(?:-(?:start|end))?$/.test(flip2);
1276
+ }
1277
+ function createPopoverStore({
1278
+ getAnchorRect,
1279
+ renderCallback,
1280
+ popover: otherPopover,
1281
+ ...props
1282
+ } = {}) {
1283
+ const store = _3BBA3Z5Gcjs.mergeStore.call(void 0,
1284
+ props.store,
1285
+ _optionalChain([otherPopover, 'optionalAccess', _2 => _2.omit, 'call', _3 => _3(
1286
+ "arrowElement",
1287
+ "anchorElement",
1288
+ "contentElement",
1289
+ "popoverElement",
1290
+ "disclosureElement"
1291
+ )])
1292
+ );
1293
+ const syncState = _optionalChain([store, 'optionalAccess', _4 => _4.getState, 'call', _5 => _5()]);
1294
+ const rendered = _3BBA3Z5Gcjs.createStore.call(void 0, { rendered: [] });
1295
+ const dialog = _EFEGT32Mcjs.createDialogStore.call(void 0, { ...props, store });
1296
+ const placement = _5D5Y5EI4cjs.defaultValue.call(void 0,
1297
+ props.placement,
1298
+ _optionalChain([syncState, 'optionalAccess', _6 => _6.placement]),
1299
+ "bottom"
1300
+ );
1301
+ const initialState = {
1302
+ ...dialog.getState(),
1303
+ placement,
1304
+ currentPlacement: placement,
1305
+ fixed: _5D5Y5EI4cjs.defaultValue.call(void 0, props.fixed, _optionalChain([syncState, 'optionalAccess', _7 => _7.fixed]), false),
1306
+ gutter: _5D5Y5EI4cjs.defaultValue.call(void 0, props.gutter, _optionalChain([syncState, 'optionalAccess', _8 => _8.gutter])),
1307
+ flip: _5D5Y5EI4cjs.defaultValue.call(void 0, props.flip, _optionalChain([syncState, 'optionalAccess', _9 => _9.flip]), true),
1308
+ shift: _5D5Y5EI4cjs.defaultValue.call(void 0, props.shift, _optionalChain([syncState, 'optionalAccess', _10 => _10.shift]), 0),
1309
+ slide: _5D5Y5EI4cjs.defaultValue.call(void 0, props.slide, _optionalChain([syncState, 'optionalAccess', _11 => _11.slide]), true),
1310
+ overlap: _5D5Y5EI4cjs.defaultValue.call(void 0, props.overlap, _optionalChain([syncState, 'optionalAccess', _12 => _12.overlap]), false),
1311
+ sameWidth: _5D5Y5EI4cjs.defaultValue.call(void 0, props.sameWidth, _optionalChain([syncState, 'optionalAccess', _13 => _13.sameWidth]), false),
1312
+ fitViewport: _5D5Y5EI4cjs.defaultValue.call(void 0, props.fitViewport, _optionalChain([syncState, 'optionalAccess', _14 => _14.fitViewport]), false),
1313
+ arrowPadding: _5D5Y5EI4cjs.defaultValue.call(void 0, props.arrowPadding, _optionalChain([syncState, 'optionalAccess', _15 => _15.arrowPadding]), 4),
1314
+ overflowPadding: _5D5Y5EI4cjs.defaultValue.call(void 0,
1315
+ props.overflowPadding,
1316
+ _optionalChain([syncState, 'optionalAccess', _16 => _16.overflowPadding]),
1317
+ 8
1318
+ ),
1319
+ anchorElement: _5D5Y5EI4cjs.defaultValue.call(void 0, _optionalChain([syncState, 'optionalAccess', _17 => _17.anchorElement]), null),
1320
+ popoverElement: _5D5Y5EI4cjs.defaultValue.call(void 0, _optionalChain([syncState, 'optionalAccess', _18 => _18.popoverElement]), null),
1321
+ arrowElement: _5D5Y5EI4cjs.defaultValue.call(void 0, _optionalChain([syncState, 'optionalAccess', _19 => _19.arrowElement]), null)
1322
+ };
1323
+ const popover = _3BBA3Z5Gcjs.createStore.call(void 0, initialState, dialog, store);
1324
+ const setCurrentPlacement = (placement2) => {
1325
+ popover.setState("currentPlacement", placement2);
1326
+ };
1327
+ popover.setup(
1328
+ () => rendered.sync(
1329
+ () => popover.syncBatch(
1330
+ (state) => {
1331
+ if (!_optionalChain([state, 'access', _20 => _20.contentElement, 'optionalAccess', _21 => _21.isConnected]))
1332
+ return;
1333
+ const popover2 = state.popoverElement;
1334
+ if (!popover2)
1335
+ return;
1336
+ const anchor = getAnchorElement(state.anchorElement, getAnchorRect);
1337
+ popover2.style.setProperty(
1338
+ "--popover-overflow-padding",
1339
+ `${state.overflowPadding}px`
1340
+ );
1341
+ const defaultRenderCallback = () => {
1342
+ const update = async () => {
1343
+ if (!state.mounted)
1344
+ return;
1345
+ const arrow2 = state.arrowElement;
1346
+ const middleware = [
1347
+ // https://floating-ui.com/docs/offset
1348
+ middlewares.offset(({ placement: placement2 }) => {
1349
+ const arrowOffset = (_optionalChain([arrow2, 'optionalAccess', _22 => _22.clientHeight]) || 0) / 2;
1350
+ const finalGutter = typeof state.gutter === "number" ? state.gutter + arrowOffset : _nullishCoalesce(state.gutter, () => ( arrowOffset));
1351
+ const hasAlignment = !!placement2.split("-")[1];
1352
+ return {
1353
+ crossAxis: !hasAlignment ? state.shift : void 0,
1354
+ mainAxis: finalGutter,
1355
+ alignmentAxis: state.shift
1356
+ };
1357
+ })
1358
+ ];
1359
+ if (state.flip !== false) {
1360
+ const fallbackPlacements = typeof state.flip === "string" ? state.flip.split(" ") : void 0;
1361
+ if (fallbackPlacements !== void 0 && !fallbackPlacements.every(isValidPlacement)) {
1362
+ throw new Error(
1363
+ "`flip` expects a spaced-delimited list of placements"
1364
+ );
1365
+ }
1366
+ middleware.push(
1367
+ middlewares.flip({
1368
+ padding: state.overflowPadding,
1369
+ fallbackPlacements
1370
+ })
1371
+ );
1372
+ }
1373
+ if (state.slide || state.overlap) {
1374
+ middleware.push(
1375
+ middlewares.shift({
1376
+ mainAxis: state.slide,
1377
+ crossAxis: state.overlap,
1378
+ padding: state.overflowPadding
1379
+ })
1380
+ );
1381
+ }
1382
+ middleware.push(
1383
+ middlewares.size({
1384
+ padding: state.overflowPadding,
1385
+ apply({ availableWidth, availableHeight, rects }) {
1386
+ const referenceWidth = Math.round(rects.reference.width);
1387
+ availableWidth = Math.floor(availableWidth);
1388
+ availableHeight = Math.floor(availableHeight);
1389
+ popover2.style.setProperty(
1390
+ "--popover-anchor-width",
1391
+ `${referenceWidth}px`
1392
+ );
1393
+ popover2.style.setProperty(
1394
+ "--popover-available-width",
1395
+ `${availableWidth}px`
1396
+ );
1397
+ popover2.style.setProperty(
1398
+ "--popover-available-height",
1399
+ `${availableHeight}px`
1400
+ );
1401
+ if (state.sameWidth) {
1402
+ popover2.style.width = `${referenceWidth}px`;
1403
+ }
1404
+ if (state.fitViewport) {
1405
+ popover2.style.maxWidth = `${availableWidth}px`;
1406
+ popover2.style.maxHeight = `${availableHeight}px`;
1407
+ }
1408
+ }
1409
+ })
1410
+ );
1411
+ if (arrow2) {
1412
+ middleware.push(
1413
+ middlewares.arrow({
1414
+ element: arrow2,
1415
+ padding: state.arrowPadding
1416
+ })
1417
+ );
1418
+ }
1419
+ const pos = await computePosition2(anchor, popover2, {
1420
+ placement: state.placement,
1421
+ strategy: state.fixed ? "fixed" : "absolute",
1422
+ middleware
1423
+ });
1424
+ setCurrentPlacement(pos.placement);
1425
+ const x = Math.round(pos.x);
1426
+ const y = Math.round(pos.y);
1427
+ Object.assign(popover2.style, {
1428
+ top: "0",
1429
+ left: "0",
1430
+ transform: `translate3d(${x}px, ${y}px, 0)`
1431
+ });
1432
+ if (arrow2 && pos.middlewareData.arrow) {
1433
+ const { x: arrowX, y: arrowY } = pos.middlewareData.arrow;
1434
+ const dir = pos.placement.split("-")[0];
1435
+ Object.assign(arrow2.style, {
1436
+ left: arrowX != null ? `${arrowX}px` : "",
1437
+ top: arrowY != null ? `${arrowY}px` : "",
1438
+ [dir]: "100%"
1439
+ });
1440
+ }
1441
+ };
1442
+ return autoUpdate(anchor, popover2, update, {
1443
+ // JSDOM doesn't support ResizeObserver
1444
+ elementResize: typeof ResizeObserver === "function"
1445
+ });
1446
+ };
1447
+ if (renderCallback) {
1448
+ return renderCallback({
1449
+ ...state,
1450
+ setPlacement: setCurrentPlacement,
1451
+ defaultRenderCallback
1452
+ });
1453
+ }
1454
+ return defaultRenderCallback();
1455
+ },
1456
+ [
1457
+ "anchorElement",
1458
+ "popoverElement",
1459
+ "arrowElement",
1460
+ "contentElement",
1461
+ "gutter",
1462
+ "mounted",
1463
+ "shift",
1464
+ "overlap",
1465
+ "flip",
1466
+ "overflowPadding",
1467
+ "slide",
1468
+ "sameWidth",
1469
+ "fitViewport",
1470
+ "arrowPadding",
1471
+ "placement",
1472
+ "fixed"
1473
+ ]
1474
+ )
1475
+ )
1476
+ );
1477
+ return {
1478
+ ...dialog,
1479
+ ...popover,
1480
+ setAnchorElement: (element) => popover.setState("anchorElement", element),
1481
+ setPopoverElement: (element) => popover.setState("popoverElement", element),
1482
+ setArrowElement: (element) => popover.setState("arrowElement", element),
1483
+ render: () => rendered.setState("rendered", []),
1484
+ getAnchorRect,
1485
+ renderCallback
1486
+ };
1487
+ }
1488
+
1489
+
1490
+
1491
+ exports.createPopoverStore = createPopoverStore;