@vonage/vivid 3.0.0-next.2 → 3.0.0-next.20

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 (122) hide show
  1. package/README.md +49 -4
  2. package/accordion/index.js +61 -0
  3. package/accordion-item/index.js +120 -0
  4. package/action-group/index.js +34 -0
  5. package/badge/index.js +24 -22
  6. package/banner/index.js +148 -0
  7. package/breadcrumb/index.js +102 -0
  8. package/breadcrumb-item/index.js +14 -9
  9. package/button/index.js +36 -663
  10. package/calendar/index.js +1526 -0
  11. package/card/index.js +139 -0
  12. package/elevation/index.js +8 -15
  13. package/fab/index.js +94 -0
  14. package/focus/index.js +20 -3
  15. package/icon/index.js +38 -5
  16. package/index.d.ts +1 -0
  17. package/index.js +43 -12
  18. package/layout/index.js +5 -5
  19. package/lib/accordion/accordion.d.ts +9 -0
  20. package/lib/accordion/accordion.template.d.ts +4 -0
  21. package/lib/accordion/index.d.ts +2 -0
  22. package/lib/accordion-item/accordion-item.d.ts +13 -0
  23. package/lib/accordion-item/accordion-item.template.d.ts +4 -0
  24. package/lib/accordion-item/index.d.ts +3 -0
  25. package/lib/action-group/action-group.d.ts +9 -0
  26. package/lib/action-group/action-group.template.d.ts +4 -0
  27. package/lib/action-group/index.d.ts +2 -0
  28. package/lib/badge/badge.d.ts +8 -8
  29. package/lib/badge/index.d.ts +1 -1
  30. package/lib/banner/banner.d.ts +20 -0
  31. package/lib/banner/banner.template.d.ts +6 -0
  32. package/lib/banner/index.d.ts +2 -0
  33. package/lib/breadcrumb/breadcrumb.d.ts +3 -0
  34. package/lib/breadcrumb/index.d.ts +2 -0
  35. package/lib/breadcrumb-item/breadcrumb-item.d.ts +3 -3
  36. package/lib/breadcrumb-item/breadcrumb-item.template.d.ts +0 -1
  37. package/lib/breadcrumb-item/index.d.ts +1 -0
  38. package/lib/button/button.d.ts +9 -8
  39. package/lib/button/index.d.ts +2 -19
  40. package/lib/calendar/calendar.d.ts +11 -0
  41. package/lib/calendar/calendar.template.d.ts +4 -0
  42. package/lib/calendar/helpers/calendar.date-functions.d.ts +2 -0
  43. package/lib/calendar/helpers/calendar.event-context.d.ts +6 -0
  44. package/lib/calendar/helpers/calendar.keyboard-interactions.d.ts +9 -0
  45. package/lib/calendar/index.d.ts +3 -0
  46. package/lib/card/card.d.ts +10 -0
  47. package/lib/card/card.template.d.ts +4 -0
  48. package/lib/card/index.d.ts +5 -0
  49. package/lib/components.d.ts +19 -3
  50. package/lib/elevation/elevation.d.ts +1 -1
  51. package/lib/elevation/index.d.ts +1 -1
  52. package/lib/enums.d.ts +14 -7
  53. package/lib/fab/fab.d.ts +10 -0
  54. package/lib/fab/fab.template.d.ts +4 -0
  55. package/lib/fab/index.d.ts +4 -0
  56. package/lib/focus/index.d.ts +1 -1
  57. package/lib/icon/icon.d.ts +4 -5
  58. package/lib/layout/index.d.ts +1 -1
  59. package/lib/layout/layout.d.ts +3 -3
  60. package/lib/note/index.d.ts +2 -0
  61. package/lib/note/note.d.ts +10 -0
  62. package/lib/note/note.template.d.ts +5 -0
  63. package/lib/popup/index.d.ts +4 -0
  64. package/lib/popup/popup.d.ts +17 -0
  65. package/lib/popup/popup.template.d.ts +4 -0
  66. package/lib/progress/index.d.ts +2 -0
  67. package/lib/progress/progress.d.ts +9 -0
  68. package/lib/progress/progress.template.d.ts +5 -0
  69. package/lib/progress-ring/index.d.ts +2 -0
  70. package/lib/progress-ring/progress-ring.d.ts +7 -0
  71. package/lib/progress-ring/progress-ring.template.d.ts +4 -0
  72. package/lib/side-drawer/index.d.ts +2 -0
  73. package/lib/side-drawer/side-drawer.d.ts +8 -0
  74. package/lib/side-drawer/side-drawer.template.d.ts +4 -0
  75. package/lib/sidenav-item/sidenav-item.d.ts +4 -5
  76. package/lib/text/index.d.ts +2 -0
  77. package/lib/text/text.d.ts +10 -0
  78. package/lib/text/text.template.d.ts +4 -0
  79. package/lib/text-anchor/text-anchor.d.ts +4 -1
  80. package/lib/text-field/index.d.ts +4 -0
  81. package/lib/text-field/text-field.d.ts +20 -0
  82. package/lib/text-field/text-field.template.d.ts +5 -0
  83. package/lib/tooltip/index.d.ts +3 -0
  84. package/lib/tooltip/tooltip.d.ts +8 -0
  85. package/lib/tooltip/tooltip.template.d.ts +4 -0
  86. package/note/index.js +65 -0
  87. package/package.json +33 -6
  88. package/popup/index.js +2106 -0
  89. package/progress/index.js +99 -0
  90. package/progress-ring/index.js +82 -0
  91. package/shared/_has.js +58 -0
  92. package/shared/affix.js +10 -25
  93. package/shared/anchor.js +11 -4
  94. package/shared/aria-global.js +20 -20
  95. package/shared/base-progress.js +70 -0
  96. package/shared/breadcrumb-item.js +25 -0
  97. package/shared/button.js +195 -0
  98. package/shared/enums.js +79 -0
  99. package/shared/es.object.assign.js +69 -0
  100. package/shared/focus.js +5 -0
  101. package/shared/focus2.js +468 -0
  102. package/shared/icon.js +1435 -0
  103. package/shared/index.js +4940 -1426
  104. package/shared/object-set-prototype-of.js +1030 -0
  105. package/shared/patterns/affix.d.ts +3 -4
  106. package/shared/patterns/focus.d.ts +3 -0
  107. package/shared/patterns/index.d.ts +1 -0
  108. package/shared/slotted.js +119 -0
  109. package/shared/text-anchor.js +12 -0
  110. package/shared/text-anchor.template.js +14 -19
  111. package/shared/web.dom-collections.iterator.js +46 -1051
  112. package/shared/when.js +15 -0
  113. package/side-drawer/index.js +82 -0
  114. package/sidenav-item/index.js +17 -57
  115. package/styles/themes/dark.css +16 -4
  116. package/styles/themes/light.css +16 -4
  117. package/text/index.js +46 -0
  118. package/text-anchor/index.js +7 -2
  119. package/text-field/index.js +389 -0
  120. package/tooltip/index.js +66 -0
  121. package/shared/index2.js +0 -4911
  122. package/shared/index3.js +0 -21
package/popup/index.js ADDED
@@ -0,0 +1,2106 @@
1
+ import '../elevation/index.js';
2
+ import '../button/index.js';
3
+ import { F as FoundationElement, c as __classPrivateFieldGet, g as __classPrivateFieldSet, _ as __decorate, a as attr, b as __metadata, h as html, d as designSystem } from '../shared/index.js';
4
+ import { t as toString$3, s as speciesConstructor$1, f as functionApply } from '../shared/icon.js';
5
+ import { a as objectCreate } from '../shared/web.dom-collections.iterator.js';
6
+ import '../shared/es.object.assign.js';
7
+ import { b as anObject$3, g as fails$5, z as global$3, u as functionCall, D as functionUncurryThis, T as shared$1, y as internalState, _ as _export, w as wellKnownSymbol$2, l as defineBuiltIn$1, r as createNonEnumerableProperty$1, M as isObject$1, A as classofRaw, P as requireObjectCoercible$2, U as toIntegerOrInfinity$1, V as toPropertyKey$1, a as objectDefineProperty, m as createPropertyDescriptor$1, O as lengthOfArrayLike$1, W as toAbsoluteIndex$1, j as isCallable$1, X as toLength$1, N as getMethod$1 } from '../shared/object-set-prototype-of.js';
8
+ import { s as styleInject } from '../shared/style-inject.es.js';
9
+ import { w as when } from '../shared/when.js';
10
+ import { r as ref } from '../shared/aria-global.js';
11
+ import { c as classNames } from '../shared/class-names.js';
12
+ import '../icon/index.js';
13
+ import '../shared/_has.js';
14
+ import '../focus/index.js';
15
+ import '../shared/focus.js';
16
+ import '../shared/affix.js';
17
+ import '../shared/button.js';
18
+ import '../shared/apply-mixins.js';
19
+ import '../shared/focus2.js';
20
+
21
+ var anObject$2 = anObject$3;
22
+
23
+ // `RegExp.prototype.flags` getter implementation
24
+ // https://tc39.es/ecma262/#sec-get-regexp.prototype.flags
25
+ var regexpFlags$1 = function () {
26
+ var that = anObject$2(this);
27
+ var result = '';
28
+ if (that.hasIndices) result += 'd';
29
+ if (that.global) result += 'g';
30
+ if (that.ignoreCase) result += 'i';
31
+ if (that.multiline) result += 'm';
32
+ if (that.dotAll) result += 's';
33
+ if (that.unicode) result += 'u';
34
+ if (that.sticky) result += 'y';
35
+ return result;
36
+ };
37
+
38
+ var fails$4 = fails$5;
39
+ var global$2 = global$3;
40
+
41
+ // babel-minify and Closure Compiler transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError
42
+ var $RegExp$2 = global$2.RegExp;
43
+
44
+ var UNSUPPORTED_Y$2 = fails$4(function () {
45
+ var re = $RegExp$2('a', 'y');
46
+ re.lastIndex = 2;
47
+ return re.exec('abcd') != null;
48
+ });
49
+
50
+ // UC Browser bug
51
+ // https://github.com/zloirock/core-js/issues/1008
52
+ var MISSED_STICKY = UNSUPPORTED_Y$2 || fails$4(function () {
53
+ return !$RegExp$2('a', 'y').sticky;
54
+ });
55
+
56
+ var BROKEN_CARET = UNSUPPORTED_Y$2 || fails$4(function () {
57
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=773687
58
+ var re = $RegExp$2('^r', 'gy');
59
+ re.lastIndex = 2;
60
+ return re.exec('str') != null;
61
+ });
62
+
63
+ var regexpStickyHelpers = {
64
+ BROKEN_CARET: BROKEN_CARET,
65
+ MISSED_STICKY: MISSED_STICKY,
66
+ UNSUPPORTED_Y: UNSUPPORTED_Y$2
67
+ };
68
+
69
+ var fails$3 = fails$5;
70
+ var global$1 = global$3;
71
+
72
+ // babel-minify and Closure Compiler transpiles RegExp('.', 's') -> /./s and it causes SyntaxError
73
+ var $RegExp$1 = global$1.RegExp;
74
+
75
+ var regexpUnsupportedDotAll = fails$3(function () {
76
+ var re = $RegExp$1('.', 's');
77
+ return !(re.dotAll && re.exec('\n') && re.flags === 's');
78
+ });
79
+
80
+ var fails$2 = fails$5;
81
+ var global = global$3;
82
+
83
+ // babel-minify and Closure Compiler transpiles RegExp('(?<a>b)', 'g') -> /(?<a>b)/g and it causes SyntaxError
84
+ var $RegExp = global.RegExp;
85
+
86
+ var regexpUnsupportedNcg = fails$2(function () {
87
+ var re = $RegExp('(?<a>b)', 'g');
88
+ return re.exec('b').groups.a !== 'b' ||
89
+ 'b'.replace(re, '$<a>c') !== 'bc';
90
+ });
91
+
92
+ /* eslint-disable regexp/no-empty-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */
93
+ /* eslint-disable regexp/no-useless-quantifier -- testing */
94
+ var call$2 = functionCall;
95
+ var uncurryThis$3 = functionUncurryThis;
96
+ var toString$2 = toString$3;
97
+ var regexpFlags = regexpFlags$1;
98
+ var stickyHelpers$1 = regexpStickyHelpers;
99
+ var shared = shared$1.exports;
100
+ var create = objectCreate;
101
+ var getInternalState = internalState.get;
102
+ var UNSUPPORTED_DOT_ALL = regexpUnsupportedDotAll;
103
+ var UNSUPPORTED_NCG = regexpUnsupportedNcg;
104
+
105
+ var nativeReplace = shared('native-string-replace', String.prototype.replace);
106
+ var nativeExec = RegExp.prototype.exec;
107
+ var patchedExec = nativeExec;
108
+ var charAt$2 = uncurryThis$3(''.charAt);
109
+ var indexOf = uncurryThis$3(''.indexOf);
110
+ var replace = uncurryThis$3(''.replace);
111
+ var stringSlice$2 = uncurryThis$3(''.slice);
112
+
113
+ var UPDATES_LAST_INDEX_WRONG = (function () {
114
+ var re1 = /a/;
115
+ var re2 = /b*/g;
116
+ call$2(nativeExec, re1, 'a');
117
+ call$2(nativeExec, re2, 'a');
118
+ return re1.lastIndex !== 0 || re2.lastIndex !== 0;
119
+ })();
120
+
121
+ var UNSUPPORTED_Y$1 = stickyHelpers$1.BROKEN_CARET;
122
+
123
+ // nonparticipating capturing group, copied from es5-shim's String#split patch.
124
+ var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;
125
+
126
+ var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y$1 || UNSUPPORTED_DOT_ALL || UNSUPPORTED_NCG;
127
+
128
+ if (PATCH) {
129
+ patchedExec = function exec(string) {
130
+ var re = this;
131
+ var state = getInternalState(re);
132
+ var str = toString$2(string);
133
+ var raw = state.raw;
134
+ var result, reCopy, lastIndex, match, i, object, group;
135
+
136
+ if (raw) {
137
+ raw.lastIndex = re.lastIndex;
138
+ result = call$2(patchedExec, raw, str);
139
+ re.lastIndex = raw.lastIndex;
140
+ return result;
141
+ }
142
+
143
+ var groups = state.groups;
144
+ var sticky = UNSUPPORTED_Y$1 && re.sticky;
145
+ var flags = call$2(regexpFlags, re);
146
+ var source = re.source;
147
+ var charsAdded = 0;
148
+ var strCopy = str;
149
+
150
+ if (sticky) {
151
+ flags = replace(flags, 'y', '');
152
+ if (indexOf(flags, 'g') === -1) {
153
+ flags += 'g';
154
+ }
155
+
156
+ strCopy = stringSlice$2(str, re.lastIndex);
157
+ // Support anchored sticky behavior.
158
+ if (re.lastIndex > 0 && (!re.multiline || re.multiline && charAt$2(str, re.lastIndex - 1) !== '\n')) {
159
+ source = '(?: ' + source + ')';
160
+ strCopy = ' ' + strCopy;
161
+ charsAdded++;
162
+ }
163
+ // ^(? + rx + ) is needed, in combination with some str slicing, to
164
+ // simulate the 'y' flag.
165
+ reCopy = new RegExp('^(?:' + source + ')', flags);
166
+ }
167
+
168
+ if (NPCG_INCLUDED) {
169
+ reCopy = new RegExp('^' + source + '$(?!\\s)', flags);
170
+ }
171
+ if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex;
172
+
173
+ match = call$2(nativeExec, sticky ? reCopy : re, strCopy);
174
+
175
+ if (sticky) {
176
+ if (match) {
177
+ match.input = stringSlice$2(match.input, charsAdded);
178
+ match[0] = stringSlice$2(match[0], charsAdded);
179
+ match.index = re.lastIndex;
180
+ re.lastIndex += match[0].length;
181
+ } else re.lastIndex = 0;
182
+ } else if (UPDATES_LAST_INDEX_WRONG && match) {
183
+ re.lastIndex = re.global ? match.index + match[0].length : lastIndex;
184
+ }
185
+ if (NPCG_INCLUDED && match && match.length > 1) {
186
+ // Fix browsers whose `exec` methods don't consistently return `undefined`
187
+ // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/
188
+ call$2(nativeReplace, match[0], reCopy, function () {
189
+ for (i = 1; i < arguments.length - 2; i++) {
190
+ if (arguments[i] === undefined) match[i] = undefined;
191
+ }
192
+ });
193
+ }
194
+
195
+ if (match && groups) {
196
+ match.groups = object = create(null);
197
+ for (i = 0; i < groups.length; i++) {
198
+ group = groups[i];
199
+ object[group[0]] = match[group[1]];
200
+ }
201
+ }
202
+
203
+ return match;
204
+ };
205
+ }
206
+
207
+ var regexpExec$3 = patchedExec;
208
+
209
+ var $ = _export;
210
+ var exec$1 = regexpExec$3;
211
+
212
+ // `RegExp.prototype.exec` method
213
+ // https://tc39.es/ecma262/#sec-regexp.prototype.exec
214
+ $({ target: 'RegExp', proto: true, forced: /./.exec !== exec$1 }, {
215
+ exec: exec$1
216
+ });
217
+
218
+ // TODO: Remove from `core-js@4` since it's moved to entry points
219
+
220
+ var uncurryThis$2 = functionUncurryThis;
221
+ var defineBuiltIn = defineBuiltIn$1;
222
+ var regexpExec$2 = regexpExec$3;
223
+ var fails$1 = fails$5;
224
+ var wellKnownSymbol$1 = wellKnownSymbol$2;
225
+ var createNonEnumerableProperty = createNonEnumerableProperty$1;
226
+
227
+ var SPECIES = wellKnownSymbol$1('species');
228
+ var RegExpPrototype = RegExp.prototype;
229
+
230
+ var fixRegexpWellKnownSymbolLogic = function (KEY, exec, FORCED, SHAM) {
231
+ var SYMBOL = wellKnownSymbol$1(KEY);
232
+
233
+ var DELEGATES_TO_SYMBOL = !fails$1(function () {
234
+ // String methods call symbol-named RegEp methods
235
+ var O = {};
236
+ O[SYMBOL] = function () { return 7; };
237
+ return ''[KEY](O) != 7;
238
+ });
239
+
240
+ var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails$1(function () {
241
+ // Symbol-named RegExp methods call .exec
242
+ var execCalled = false;
243
+ var re = /a/;
244
+
245
+ if (KEY === 'split') {
246
+ // We can't use real regex here since it causes deoptimization
247
+ // and serious performance degradation in V8
248
+ // https://github.com/zloirock/core-js/issues/306
249
+ re = {};
250
+ // RegExp[@@split] doesn't call the regex's exec method, but first creates
251
+ // a new one. We need to return the patched regex when creating the new one.
252
+ re.constructor = {};
253
+ re.constructor[SPECIES] = function () { return re; };
254
+ re.flags = '';
255
+ re[SYMBOL] = /./[SYMBOL];
256
+ }
257
+
258
+ re.exec = function () { execCalled = true; return null; };
259
+
260
+ re[SYMBOL]('');
261
+ return !execCalled;
262
+ });
263
+
264
+ if (
265
+ !DELEGATES_TO_SYMBOL ||
266
+ !DELEGATES_TO_EXEC ||
267
+ FORCED
268
+ ) {
269
+ var uncurriedNativeRegExpMethod = uncurryThis$2(/./[SYMBOL]);
270
+ var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) {
271
+ var uncurriedNativeMethod = uncurryThis$2(nativeMethod);
272
+ var $exec = regexp.exec;
273
+ if ($exec === regexpExec$2 || $exec === RegExpPrototype.exec) {
274
+ if (DELEGATES_TO_SYMBOL && !forceStringMethod) {
275
+ // The native String method already delegates to @@method (this
276
+ // polyfilled function), leasing to infinite recursion.
277
+ // We avoid it by directly calling the native @@method method.
278
+ return { done: true, value: uncurriedNativeRegExpMethod(regexp, str, arg2) };
279
+ }
280
+ return { done: true, value: uncurriedNativeMethod(str, regexp, arg2) };
281
+ }
282
+ return { done: false };
283
+ });
284
+
285
+ defineBuiltIn(String.prototype, KEY, methods[0]);
286
+ defineBuiltIn(RegExpPrototype, SYMBOL, methods[1]);
287
+ }
288
+
289
+ if (SHAM) createNonEnumerableProperty(RegExpPrototype[SYMBOL], 'sham', true);
290
+ };
291
+
292
+ var isObject = isObject$1;
293
+ var classof$1 = classofRaw;
294
+ var wellKnownSymbol = wellKnownSymbol$2;
295
+
296
+ var MATCH = wellKnownSymbol('match');
297
+
298
+ // `IsRegExp` abstract operation
299
+ // https://tc39.es/ecma262/#sec-isregexp
300
+ var isRegexp = function (it) {
301
+ var isRegExp;
302
+ return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classof$1(it) == 'RegExp');
303
+ };
304
+
305
+ var uncurryThis$1 = functionUncurryThis;
306
+ var toIntegerOrInfinity = toIntegerOrInfinity$1;
307
+ var toString$1 = toString$3;
308
+ var requireObjectCoercible$1 = requireObjectCoercible$2;
309
+
310
+ var charAt$1 = uncurryThis$1(''.charAt);
311
+ var charCodeAt = uncurryThis$1(''.charCodeAt);
312
+ var stringSlice$1 = uncurryThis$1(''.slice);
313
+
314
+ var createMethod = function (CONVERT_TO_STRING) {
315
+ return function ($this, pos) {
316
+ var S = toString$1(requireObjectCoercible$1($this));
317
+ var position = toIntegerOrInfinity(pos);
318
+ var size = S.length;
319
+ var first, second;
320
+ if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
321
+ first = charCodeAt(S, position);
322
+ return first < 0xD800 || first > 0xDBFF || position + 1 === size
323
+ || (second = charCodeAt(S, position + 1)) < 0xDC00 || second > 0xDFFF
324
+ ? CONVERT_TO_STRING
325
+ ? charAt$1(S, position)
326
+ : first
327
+ : CONVERT_TO_STRING
328
+ ? stringSlice$1(S, position, position + 2)
329
+ : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
330
+ };
331
+ };
332
+
333
+ var stringMultibyte = {
334
+ // `String.prototype.codePointAt` method
335
+ // https://tc39.es/ecma262/#sec-string.prototype.codepointat
336
+ codeAt: createMethod(false),
337
+ // `String.prototype.at` method
338
+ // https://github.com/mathiasbynens/String.prototype.at
339
+ charAt: createMethod(true)
340
+ };
341
+
342
+ var charAt = stringMultibyte.charAt;
343
+
344
+ // `AdvanceStringIndex` abstract operation
345
+ // https://tc39.es/ecma262/#sec-advancestringindex
346
+ var advanceStringIndex$1 = function (S, index, unicode) {
347
+ return index + (unicode ? charAt(S, index).length : 1);
348
+ };
349
+
350
+ var toPropertyKey = toPropertyKey$1;
351
+ var definePropertyModule = objectDefineProperty;
352
+ var createPropertyDescriptor = createPropertyDescriptor$1;
353
+
354
+ var createProperty$1 = function (object, key, value) {
355
+ var propertyKey = toPropertyKey(key);
356
+ if (propertyKey in object) definePropertyModule.f(object, propertyKey, createPropertyDescriptor(0, value));
357
+ else object[propertyKey] = value;
358
+ };
359
+
360
+ var toAbsoluteIndex = toAbsoluteIndex$1;
361
+ var lengthOfArrayLike = lengthOfArrayLike$1;
362
+ var createProperty = createProperty$1;
363
+
364
+ var $Array = Array;
365
+ var max$2 = Math.max;
366
+
367
+ var arraySliceSimple = function (O, start, end) {
368
+ var length = lengthOfArrayLike(O);
369
+ var k = toAbsoluteIndex(start, length);
370
+ var fin = toAbsoluteIndex(end === undefined ? length : end, length);
371
+ var result = $Array(max$2(fin - k, 0));
372
+ for (var n = 0; k < fin; k++, n++) createProperty(result, n, O[k]);
373
+ result.length = n;
374
+ return result;
375
+ };
376
+
377
+ var call$1 = functionCall;
378
+ var anObject$1 = anObject$3;
379
+ var isCallable = isCallable$1;
380
+ var classof = classofRaw;
381
+ var regexpExec$1 = regexpExec$3;
382
+
383
+ var $TypeError = TypeError;
384
+
385
+ // `RegExpExec` abstract operation
386
+ // https://tc39.es/ecma262/#sec-regexpexec
387
+ var regexpExecAbstract = function (R, S) {
388
+ var exec = R.exec;
389
+ if (isCallable(exec)) {
390
+ var result = call$1(exec, R, S);
391
+ if (result !== null) anObject$1(result);
392
+ return result;
393
+ }
394
+ if (classof(R) === 'RegExp') return call$1(regexpExec$1, R, S);
395
+ throw $TypeError('RegExp#exec called on incompatible receiver');
396
+ };
397
+
398
+ var apply = functionApply;
399
+ var call = functionCall;
400
+ var uncurryThis = functionUncurryThis;
401
+ var fixRegExpWellKnownSymbolLogic = fixRegexpWellKnownSymbolLogic;
402
+ var isRegExp = isRegexp;
403
+ var anObject = anObject$3;
404
+ var requireObjectCoercible = requireObjectCoercible$2;
405
+ var speciesConstructor = speciesConstructor$1;
406
+ var advanceStringIndex = advanceStringIndex$1;
407
+ var toLength = toLength$1;
408
+ var toString = toString$3;
409
+ var getMethod = getMethod$1;
410
+ var arraySlice = arraySliceSimple;
411
+ var callRegExpExec = regexpExecAbstract;
412
+ var regexpExec = regexpExec$3;
413
+ var stickyHelpers = regexpStickyHelpers;
414
+ var fails = fails$5;
415
+
416
+ var UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y;
417
+ var MAX_UINT32 = 0xFFFFFFFF;
418
+ var min$2 = Math.min;
419
+ var $push = [].push;
420
+ var exec = uncurryThis(/./.exec);
421
+ var push = uncurryThis($push);
422
+ var stringSlice = uncurryThis(''.slice);
423
+
424
+ // Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec
425
+ // Weex JS has frozen built-in prototypes, so use try / catch wrapper
426
+ var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = !fails(function () {
427
+ // eslint-disable-next-line regexp/no-empty-group -- required for testing
428
+ var re = /(?:)/;
429
+ var originalExec = re.exec;
430
+ re.exec = function () { return originalExec.apply(this, arguments); };
431
+ var result = 'ab'.split(re);
432
+ return result.length !== 2 || result[0] !== 'a' || result[1] !== 'b';
433
+ });
434
+
435
+ // @@split logic
436
+ fixRegExpWellKnownSymbolLogic('split', function (SPLIT, nativeSplit, maybeCallNative) {
437
+ var internalSplit;
438
+ if (
439
+ 'abbc'.split(/(b)*/)[1] == 'c' ||
440
+ // eslint-disable-next-line regexp/no-empty-group -- required for testing
441
+ 'test'.split(/(?:)/, -1).length != 4 ||
442
+ 'ab'.split(/(?:ab)*/).length != 2 ||
443
+ '.'.split(/(.?)(.?)/).length != 4 ||
444
+ // eslint-disable-next-line regexp/no-empty-capturing-group, regexp/no-empty-group -- required for testing
445
+ '.'.split(/()()/).length > 1 ||
446
+ ''.split(/.?/).length
447
+ ) {
448
+ // based on es5-shim implementation, need to rework it
449
+ internalSplit = function (separator, limit) {
450
+ var string = toString(requireObjectCoercible(this));
451
+ var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
452
+ if (lim === 0) return [];
453
+ if (separator === undefined) return [string];
454
+ // If `separator` is not a regex, use native split
455
+ if (!isRegExp(separator)) {
456
+ return call(nativeSplit, string, separator, lim);
457
+ }
458
+ var output = [];
459
+ var flags = (separator.ignoreCase ? 'i' : '') +
460
+ (separator.multiline ? 'm' : '') +
461
+ (separator.unicode ? 'u' : '') +
462
+ (separator.sticky ? 'y' : '');
463
+ var lastLastIndex = 0;
464
+ // Make `global` and avoid `lastIndex` issues by working with a copy
465
+ var separatorCopy = new RegExp(separator.source, flags + 'g');
466
+ var match, lastIndex, lastLength;
467
+ while (match = call(regexpExec, separatorCopy, string)) {
468
+ lastIndex = separatorCopy.lastIndex;
469
+ if (lastIndex > lastLastIndex) {
470
+ push(output, stringSlice(string, lastLastIndex, match.index));
471
+ if (match.length > 1 && match.index < string.length) apply($push, output, arraySlice(match, 1));
472
+ lastLength = match[0].length;
473
+ lastLastIndex = lastIndex;
474
+ if (output.length >= lim) break;
475
+ }
476
+ if (separatorCopy.lastIndex === match.index) separatorCopy.lastIndex++; // Avoid an infinite loop
477
+ }
478
+ if (lastLastIndex === string.length) {
479
+ if (lastLength || !exec(separatorCopy, '')) push(output, '');
480
+ } else push(output, stringSlice(string, lastLastIndex));
481
+ return output.length > lim ? arraySlice(output, 0, lim) : output;
482
+ };
483
+ // Chakra, V8
484
+ } else if ('0'.split(undefined, 0).length) {
485
+ internalSplit = function (separator, limit) {
486
+ return separator === undefined && limit === 0 ? [] : call(nativeSplit, this, separator, limit);
487
+ };
488
+ } else internalSplit = nativeSplit;
489
+
490
+ return [
491
+ // `String.prototype.split` method
492
+ // https://tc39.es/ecma262/#sec-string.prototype.split
493
+ function split(separator, limit) {
494
+ var O = requireObjectCoercible(this);
495
+ var splitter = separator == undefined ? undefined : getMethod(separator, SPLIT);
496
+ return splitter
497
+ ? call(splitter, separator, O, limit)
498
+ : call(internalSplit, toString(O), separator, limit);
499
+ },
500
+ // `RegExp.prototype[@@split]` method
501
+ // https://tc39.es/ecma262/#sec-regexp.prototype-@@split
502
+ //
503
+ // NOTE: This cannot be properly polyfilled in engines that don't support
504
+ // the 'y' flag.
505
+ function (string, limit) {
506
+ var rx = anObject(this);
507
+ var S = toString(string);
508
+ var res = maybeCallNative(internalSplit, rx, S, limit, internalSplit !== nativeSplit);
509
+
510
+ if (res.done) return res.value;
511
+
512
+ var C = speciesConstructor(rx, RegExp);
513
+
514
+ var unicodeMatching = rx.unicode;
515
+ var flags = (rx.ignoreCase ? 'i' : '') +
516
+ (rx.multiline ? 'm' : '') +
517
+ (rx.unicode ? 'u' : '') +
518
+ (UNSUPPORTED_Y ? 'g' : 'y');
519
+
520
+ // ^(? + rx + ) is needed, in combination with some S slicing, to
521
+ // simulate the 'y' flag.
522
+ var splitter = new C(UNSUPPORTED_Y ? '^(?:' + rx.source + ')' : rx, flags);
523
+ var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
524
+ if (lim === 0) return [];
525
+ if (S.length === 0) return callRegExpExec(splitter, S) === null ? [S] : [];
526
+ var p = 0;
527
+ var q = 0;
528
+ var A = [];
529
+ while (q < S.length) {
530
+ splitter.lastIndex = UNSUPPORTED_Y ? 0 : q;
531
+ var z = callRegExpExec(splitter, UNSUPPORTED_Y ? stringSlice(S, q) : S);
532
+ var e;
533
+ if (
534
+ z === null ||
535
+ (e = min$2(toLength(splitter.lastIndex + (UNSUPPORTED_Y ? q : 0)), S.length)) === p
536
+ ) {
537
+ q = advanceStringIndex(S, q, unicodeMatching);
538
+ } else {
539
+ push(A, stringSlice(S, p, q));
540
+ if (A.length === lim) return A;
541
+ for (var i = 1; i <= z.length - 1; i++) {
542
+ push(A, z[i]);
543
+ if (A.length === lim) return A;
544
+ }
545
+ q = p = e;
546
+ }
547
+ }
548
+ push(A, stringSlice(S, p));
549
+ return A;
550
+ }
551
+ ];
552
+ }, !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC, UNSUPPORTED_Y);
553
+
554
+ function getSide(placement) {
555
+ return placement.split('-')[0];
556
+ }
557
+
558
+ function getAlignment(placement) {
559
+ return placement.split('-')[1];
560
+ }
561
+
562
+ function getMainAxisFromPlacement(placement) {
563
+ return ['top', 'bottom'].includes(getSide(placement)) ? 'x' : 'y';
564
+ }
565
+
566
+ function getLengthFromAxis(axis) {
567
+ return axis === 'y' ? 'height' : 'width';
568
+ }
569
+
570
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
571
+ let {
572
+ reference,
573
+ floating
574
+ } = _ref;
575
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
576
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
577
+ const mainAxis = getMainAxisFromPlacement(placement);
578
+ const length = getLengthFromAxis(mainAxis);
579
+ const commonAlign = reference[length] / 2 - floating[length] / 2;
580
+ const side = getSide(placement);
581
+ const isVertical = mainAxis === 'x';
582
+ let coords;
583
+
584
+ switch (side) {
585
+ case 'top':
586
+ coords = {
587
+ x: commonX,
588
+ y: reference.y - floating.height
589
+ };
590
+ break;
591
+
592
+ case 'bottom':
593
+ coords = {
594
+ x: commonX,
595
+ y: reference.y + reference.height
596
+ };
597
+ break;
598
+
599
+ case 'right':
600
+ coords = {
601
+ x: reference.x + reference.width,
602
+ y: commonY
603
+ };
604
+ break;
605
+
606
+ case 'left':
607
+ coords = {
608
+ x: reference.x - floating.width,
609
+ y: commonY
610
+ };
611
+ break;
612
+
613
+ default:
614
+ coords = {
615
+ x: reference.x,
616
+ y: reference.y
617
+ };
618
+ }
619
+
620
+ switch (getAlignment(placement)) {
621
+ case 'start':
622
+ coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
623
+ break;
624
+
625
+ case 'end':
626
+ coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
627
+ break;
628
+ }
629
+
630
+ return coords;
631
+ }
632
+
633
+ /**
634
+ * Computes the `x` and `y` coordinates that will place the floating element
635
+ * next to a reference element when it is given a certain positioning strategy.
636
+ *
637
+ * This export does not have any `platform` interface logic. You will need to
638
+ * write one for the platform you are using Floating UI with.
639
+ */
640
+
641
+ const computePosition$1 = async (reference, floating, config) => {
642
+ const {
643
+ placement = 'bottom',
644
+ strategy = 'absolute',
645
+ middleware = [],
646
+ platform
647
+ } = config;
648
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
649
+
650
+ {
651
+ if (platform == null) {
652
+ console.error(['Floating UI: `platform` property was not passed to config. If you', 'want to use Floating UI on the web, install @floating-ui/dom', 'instead of the /core package. Otherwise, you can create your own', '`platform`: https://floating-ui.com/docs/platform'].join(' '));
653
+ }
654
+
655
+ if (middleware.filter(_ref => {
656
+ let {
657
+ name
658
+ } = _ref;
659
+ return name === 'autoPlacement' || name === 'flip';
660
+ }).length > 1) {
661
+ throw new Error(['Floating UI: duplicate `flip` and/or `autoPlacement`', 'middleware detected. This will lead to an infinite loop. Ensure only', 'one of either has been passed to the `middleware` array.'].join(' '));
662
+ }
663
+ }
664
+
665
+ let rects = await platform.getElementRects({
666
+ reference,
667
+ floating,
668
+ strategy
669
+ });
670
+ let {
671
+ x,
672
+ y
673
+ } = computeCoordsFromPlacement(rects, placement, rtl);
674
+ let statefulPlacement = placement;
675
+ let middlewareData = {};
676
+ let _debug_loop_count_ = 0;
677
+
678
+ for (let i = 0; i < middleware.length; i++) {
679
+ {
680
+ _debug_loop_count_++;
681
+
682
+ if (_debug_loop_count_ > 100) {
683
+ throw new Error(['Floating UI: The middleware lifecycle appears to be', 'running in an infinite loop. This is usually caused by a `reset`', 'continually being returned without a break condition.'].join(' '));
684
+ }
685
+ }
686
+
687
+ const {
688
+ name,
689
+ fn
690
+ } = middleware[i];
691
+ const {
692
+ x: nextX,
693
+ y: nextY,
694
+ data,
695
+ reset
696
+ } = await fn({
697
+ x,
698
+ y,
699
+ initialPlacement: placement,
700
+ placement: statefulPlacement,
701
+ strategy,
702
+ middlewareData,
703
+ rects,
704
+ platform,
705
+ elements: {
706
+ reference,
707
+ floating
708
+ }
709
+ });
710
+ x = nextX != null ? nextX : x;
711
+ y = nextY != null ? nextY : y;
712
+ middlewareData = { ...middlewareData,
713
+ [name]: { ...middlewareData[name],
714
+ ...data
715
+ }
716
+ };
717
+
718
+ if (reset) {
719
+ if (typeof reset === 'object') {
720
+ if (reset.placement) {
721
+ statefulPlacement = reset.placement;
722
+ }
723
+
724
+ if (reset.rects) {
725
+ rects = reset.rects === true ? await platform.getElementRects({
726
+ reference,
727
+ floating,
728
+ strategy
729
+ }) : reset.rects;
730
+ }
731
+
732
+ ({
733
+ x,
734
+ y
735
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
736
+ }
737
+
738
+ i = -1;
739
+ continue;
740
+ }
741
+ }
742
+
743
+ return {
744
+ x,
745
+ y,
746
+ placement: statefulPlacement,
747
+ strategy,
748
+ middlewareData
749
+ };
750
+ };
751
+
752
+ function expandPaddingObject(padding) {
753
+ return {
754
+ top: 0,
755
+ right: 0,
756
+ bottom: 0,
757
+ left: 0,
758
+ ...padding
759
+ };
760
+ }
761
+
762
+ function getSideObjectFromPadding(padding) {
763
+ return typeof padding !== 'number' ? expandPaddingObject(padding) : {
764
+ top: padding,
765
+ right: padding,
766
+ bottom: padding,
767
+ left: padding
768
+ };
769
+ }
770
+
771
+ function rectToClientRect(rect) {
772
+ return { ...rect,
773
+ top: rect.y,
774
+ left: rect.x,
775
+ right: rect.x + rect.width,
776
+ bottom: rect.y + rect.height
777
+ };
778
+ }
779
+
780
+ /**
781
+ * Resolves with an object of overflow side offsets that determine how much the
782
+ * element is overflowing a given clipping boundary.
783
+ * - positive = overflowing the boundary by that number of pixels
784
+ * - negative = how many pixels left before it will overflow
785
+ * - 0 = lies flush with the boundary
786
+ * @see https://floating-ui.com/docs/detectOverflow
787
+ */
788
+ async function detectOverflow(middlewareArguments, options) {
789
+ var _await$platform$isEle;
790
+
791
+ if (options === void 0) {
792
+ options = {};
793
+ }
794
+
795
+ const {
796
+ x,
797
+ y,
798
+ platform,
799
+ rects,
800
+ elements,
801
+ strategy
802
+ } = middlewareArguments;
803
+ const {
804
+ boundary = 'clippingAncestors',
805
+ rootBoundary = 'viewport',
806
+ elementContext = 'floating',
807
+ altBoundary = false,
808
+ padding = 0
809
+ } = options;
810
+ const paddingObject = getSideObjectFromPadding(padding);
811
+ const altContext = elementContext === 'floating' ? 'reference' : 'floating';
812
+ const element = elements[altBoundary ? altContext : elementContext];
813
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
814
+ 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))),
815
+ boundary,
816
+ rootBoundary,
817
+ strategy
818
+ }));
819
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
820
+ rect: elementContext === 'floating' ? { ...rects.floating,
821
+ x,
822
+ y
823
+ } : rects.reference,
824
+ offsetParent: await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating)),
825
+ strategy
826
+ }) : rects[elementContext]);
827
+ return {
828
+ top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
829
+ bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
830
+ left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
831
+ right: elementClientRect.right - clippingClientRect.right + paddingObject.right
832
+ };
833
+ }
834
+
835
+ const min$1 = Math.min;
836
+ const max$1 = Math.max;
837
+
838
+ function within(min$1$1, value, max$1$1) {
839
+ return max$1(min$1$1, min$1(value, max$1$1));
840
+ }
841
+
842
+ /**
843
+ * Positions an inner element of the floating element such that it is centered
844
+ * to the reference element.
845
+ * @see https://floating-ui.com/docs/arrow
846
+ */
847
+ const arrow = options => ({
848
+ name: 'arrow',
849
+ options,
850
+
851
+ async fn(middlewareArguments) {
852
+ // Since `element` is required, we don't Partial<> the type
853
+ const {
854
+ element,
855
+ padding = 0
856
+ } = options != null ? options : {};
857
+ const {
858
+ x,
859
+ y,
860
+ placement,
861
+ rects,
862
+ platform
863
+ } = middlewareArguments;
864
+
865
+ if (element == null) {
866
+ {
867
+ console.warn('Floating UI: No `element` was passed to the `arrow` middleware.');
868
+ }
869
+
870
+ return {};
871
+ }
872
+
873
+ const paddingObject = getSideObjectFromPadding(padding);
874
+ const coords = {
875
+ x,
876
+ y
877
+ };
878
+ const axis = getMainAxisFromPlacement(placement);
879
+ const alignment = getAlignment(placement);
880
+ const length = getLengthFromAxis(axis);
881
+ const arrowDimensions = await platform.getDimensions(element);
882
+ const minProp = axis === 'y' ? 'top' : 'left';
883
+ const maxProp = axis === 'y' ? 'bottom' : 'right';
884
+ const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
885
+ const startDiff = coords[axis] - rects.reference[axis];
886
+ const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
887
+ let clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
888
+
889
+ if (clientSize === 0) {
890
+ clientSize = rects.floating[length];
891
+ }
892
+
893
+ const centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the floating element if the center
894
+ // point is outside the floating element's bounds
895
+
896
+ const min = paddingObject[minProp];
897
+ const max = clientSize - arrowDimensions[length] - paddingObject[maxProp];
898
+ const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
899
+ const offset = within(min, center, max); // Make sure that arrow points at the reference
900
+
901
+ const alignmentPadding = alignment === 'start' ? paddingObject[minProp] : paddingObject[maxProp];
902
+ const shouldAddOffset = alignmentPadding > 0 && center !== offset && rects.reference[length] <= rects.floating[length];
903
+ const alignmentOffset = shouldAddOffset ? center < min ? min - center : max - center : 0;
904
+ return {
905
+ [axis]: coords[axis] - alignmentOffset,
906
+ data: {
907
+ [axis]: offset,
908
+ centerOffset: center - offset
909
+ }
910
+ };
911
+ }
912
+
913
+ });
914
+
915
+ const hash$1 = {
916
+ left: 'right',
917
+ right: 'left',
918
+ bottom: 'top',
919
+ top: 'bottom'
920
+ };
921
+ function getOppositePlacement(placement) {
922
+ return placement.replace(/left|right|bottom|top/g, matched => hash$1[matched]);
923
+ }
924
+
925
+ function getAlignmentSides(placement, rects, rtl) {
926
+ if (rtl === void 0) {
927
+ rtl = false;
928
+ }
929
+
930
+ const alignment = getAlignment(placement);
931
+ const mainAxis = getMainAxisFromPlacement(placement);
932
+ const length = getLengthFromAxis(mainAxis);
933
+ let mainAlignmentSide = mainAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
934
+
935
+ if (rects.reference[length] > rects.floating[length]) {
936
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
937
+ }
938
+
939
+ return {
940
+ main: mainAlignmentSide,
941
+ cross: getOppositePlacement(mainAlignmentSide)
942
+ };
943
+ }
944
+
945
+ const hash = {
946
+ start: 'end',
947
+ end: 'start'
948
+ };
949
+ function getOppositeAlignmentPlacement(placement) {
950
+ return placement.replace(/start|end/g, matched => hash[matched]);
951
+ }
952
+
953
+ const sides = ['top', 'right', 'bottom', 'left'];
954
+
955
+ function getExpandedPlacements(placement) {
956
+ const oppositePlacement = getOppositePlacement(placement);
957
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
958
+ }
959
+
960
+ /**
961
+ * Changes the placement of the floating element to one that will fit if the
962
+ * initially specified `placement` does not.
963
+ * @see https://floating-ui.com/docs/flip
964
+ */
965
+ const flip = function (options) {
966
+ if (options === void 0) {
967
+ options = {};
968
+ }
969
+
970
+ return {
971
+ name: 'flip',
972
+ options,
973
+
974
+ async fn(middlewareArguments) {
975
+ var _middlewareData$flip;
976
+
977
+ const {
978
+ placement,
979
+ middlewareData,
980
+ rects,
981
+ initialPlacement,
982
+ platform,
983
+ elements
984
+ } = middlewareArguments;
985
+ const {
986
+ mainAxis: checkMainAxis = true,
987
+ crossAxis: checkCrossAxis = true,
988
+ fallbackPlacements: specifiedFallbackPlacements,
989
+ fallbackStrategy = 'bestFit',
990
+ flipAlignment = true,
991
+ ...detectOverflowOptions
992
+ } = options;
993
+ const side = getSide(placement);
994
+ const isBasePlacement = side === initialPlacement;
995
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
996
+ const placements = [initialPlacement, ...fallbackPlacements];
997
+ const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
998
+ const overflows = [];
999
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
1000
+
1001
+ if (checkMainAxis) {
1002
+ overflows.push(overflow[side]);
1003
+ }
1004
+
1005
+ if (checkCrossAxis) {
1006
+ const {
1007
+ main,
1008
+ cross
1009
+ } = getAlignmentSides(placement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
1010
+ overflows.push(overflow[main], overflow[cross]);
1011
+ }
1012
+
1013
+ overflowsData = [...overflowsData, {
1014
+ placement,
1015
+ overflows
1016
+ }]; // One or more sides is overflowing
1017
+
1018
+ if (!overflows.every(side => side <= 0)) {
1019
+ var _middlewareData$flip$, _middlewareData$flip2;
1020
+
1021
+ const nextIndex = ((_middlewareData$flip$ = (_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) != null ? _middlewareData$flip$ : 0) + 1;
1022
+ const nextPlacement = placements[nextIndex];
1023
+
1024
+ if (nextPlacement) {
1025
+ // Try next placement and re-run the lifecycle
1026
+ return {
1027
+ data: {
1028
+ index: nextIndex,
1029
+ overflows: overflowsData
1030
+ },
1031
+ reset: {
1032
+ placement: nextPlacement
1033
+ }
1034
+ };
1035
+ }
1036
+
1037
+ let resetPlacement = 'bottom';
1038
+
1039
+ switch (fallbackStrategy) {
1040
+ case 'bestFit':
1041
+ {
1042
+ var _overflowsData$map$so;
1043
+
1044
+ const placement = (_overflowsData$map$so = overflowsData.map(d => [d, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0].placement;
1045
+
1046
+ if (placement) {
1047
+ resetPlacement = placement;
1048
+ }
1049
+
1050
+ break;
1051
+ }
1052
+
1053
+ case 'initialPlacement':
1054
+ resetPlacement = initialPlacement;
1055
+ break;
1056
+ }
1057
+
1058
+ if (placement !== resetPlacement) {
1059
+ return {
1060
+ reset: {
1061
+ placement: resetPlacement
1062
+ }
1063
+ };
1064
+ }
1065
+ }
1066
+
1067
+ return {};
1068
+ }
1069
+
1070
+ };
1071
+ };
1072
+
1073
+ function getSideOffsets(overflow, rect) {
1074
+ return {
1075
+ top: overflow.top - rect.height,
1076
+ right: overflow.right - rect.width,
1077
+ bottom: overflow.bottom - rect.height,
1078
+ left: overflow.left - rect.width
1079
+ };
1080
+ }
1081
+
1082
+ function isAnySideFullyClipped(overflow) {
1083
+ return sides.some(side => overflow[side] >= 0);
1084
+ }
1085
+
1086
+ /**
1087
+ * Provides data to hide the floating element in applicable situations, such as
1088
+ * when it is not in the same clipping context as the reference element.
1089
+ * @see https://floating-ui.com/docs/hide
1090
+ */
1091
+ const hide = function (_temp) {
1092
+ let {
1093
+ strategy = 'referenceHidden',
1094
+ ...detectOverflowOptions
1095
+ } = _temp === void 0 ? {} : _temp;
1096
+ return {
1097
+ name: 'hide',
1098
+
1099
+ async fn(middlewareArguments) {
1100
+ const {
1101
+ rects
1102
+ } = middlewareArguments;
1103
+
1104
+ switch (strategy) {
1105
+ case 'referenceHidden':
1106
+ {
1107
+ const overflow = await detectOverflow(middlewareArguments, { ...detectOverflowOptions,
1108
+ elementContext: 'reference'
1109
+ });
1110
+ const offsets = getSideOffsets(overflow, rects.reference);
1111
+ return {
1112
+ data: {
1113
+ referenceHiddenOffsets: offsets,
1114
+ referenceHidden: isAnySideFullyClipped(offsets)
1115
+ }
1116
+ };
1117
+ }
1118
+
1119
+ case 'escaped':
1120
+ {
1121
+ const overflow = await detectOverflow(middlewareArguments, { ...detectOverflowOptions,
1122
+ altBoundary: true
1123
+ });
1124
+ const offsets = getSideOffsets(overflow, rects.floating);
1125
+ return {
1126
+ data: {
1127
+ escapedOffsets: offsets,
1128
+ escaped: isAnySideFullyClipped(offsets)
1129
+ }
1130
+ };
1131
+ }
1132
+
1133
+ default:
1134
+ {
1135
+ return {};
1136
+ }
1137
+ }
1138
+ }
1139
+
1140
+ };
1141
+ };
1142
+
1143
+ async function convertValueToCoords(middlewareArguments, value) {
1144
+ const {
1145
+ placement,
1146
+ platform,
1147
+ elements
1148
+ } = middlewareArguments;
1149
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
1150
+ const side = getSide(placement);
1151
+ const alignment = getAlignment(placement);
1152
+ const isVertical = getMainAxisFromPlacement(placement) === 'x';
1153
+ const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
1154
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
1155
+ const rawValue = typeof value === 'function' ? value(middlewareArguments) : value; // eslint-disable-next-line prefer-const
1156
+
1157
+ let {
1158
+ mainAxis,
1159
+ crossAxis,
1160
+ alignmentAxis
1161
+ } = typeof rawValue === 'number' ? {
1162
+ mainAxis: rawValue,
1163
+ crossAxis: 0,
1164
+ alignmentAxis: null
1165
+ } : {
1166
+ mainAxis: 0,
1167
+ crossAxis: 0,
1168
+ alignmentAxis: null,
1169
+ ...rawValue
1170
+ };
1171
+
1172
+ if (alignment && typeof alignmentAxis === 'number') {
1173
+ crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
1174
+ }
1175
+
1176
+ return isVertical ? {
1177
+ x: crossAxis * crossAxisMulti,
1178
+ y: mainAxis * mainAxisMulti
1179
+ } : {
1180
+ x: mainAxis * mainAxisMulti,
1181
+ y: crossAxis * crossAxisMulti
1182
+ };
1183
+ }
1184
+ /**
1185
+ * Displaces the floating element from its reference element.
1186
+ * @see https://floating-ui.com/docs/offset
1187
+ */
1188
+
1189
+ const offset = function (value) {
1190
+ if (value === void 0) {
1191
+ value = 0;
1192
+ }
1193
+
1194
+ return {
1195
+ name: 'offset',
1196
+ options: value,
1197
+
1198
+ async fn(middlewareArguments) {
1199
+ const {
1200
+ x,
1201
+ y
1202
+ } = middlewareArguments;
1203
+ const diffCoords = await convertValueToCoords(middlewareArguments, value);
1204
+ return {
1205
+ x: x + diffCoords.x,
1206
+ y: y + diffCoords.y,
1207
+ data: diffCoords
1208
+ };
1209
+ }
1210
+
1211
+ };
1212
+ };
1213
+
1214
+ /**
1215
+ * Provides improved positioning for inline reference elements that can span
1216
+ * over multiple lines, such as hyperlinks or range selections.
1217
+ * @see https://floating-ui.com/docs/inline
1218
+ */
1219
+ const inline = function (options) {
1220
+ if (options === void 0) {
1221
+ options = {};
1222
+ }
1223
+
1224
+ return {
1225
+ name: 'inline',
1226
+ options,
1227
+
1228
+ async fn(middlewareArguments) {
1229
+ var _await$platform$getCl;
1230
+
1231
+ const {
1232
+ placement,
1233
+ elements,
1234
+ rects,
1235
+ platform,
1236
+ strategy
1237
+ } = middlewareArguments; // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
1238
+ // ClientRect's bounds, despite the event listener being triggered. A
1239
+ // padding of 2 seems to handle this issue.
1240
+
1241
+ const {
1242
+ padding = 2,
1243
+ x,
1244
+ y
1245
+ } = options;
1246
+ const fallback = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
1247
+ rect: rects.reference,
1248
+ offsetParent: await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating)),
1249
+ strategy
1250
+ }) : rects.reference);
1251
+ const clientRects = (_await$platform$getCl = await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) != null ? _await$platform$getCl : [];
1252
+ const paddingObject = getSideObjectFromPadding(padding);
1253
+
1254
+ function getBoundingClientRect() {
1255
+ // There are two rects and they are disjoined
1256
+ if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
1257
+ var _clientRects$find;
1258
+
1259
+ // Find the first rect in which the point is fully inside
1260
+ return (_clientRects$find = clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom)) != null ? _clientRects$find : fallback;
1261
+ } // There are 2 or more connected rects
1262
+
1263
+
1264
+ if (clientRects.length >= 2) {
1265
+ if (getMainAxisFromPlacement(placement) === 'x') {
1266
+ const firstRect = clientRects[0];
1267
+ const lastRect = clientRects[clientRects.length - 1];
1268
+ const isTop = getSide(placement) === 'top';
1269
+ const top = firstRect.top;
1270
+ const bottom = lastRect.bottom;
1271
+ const left = isTop ? firstRect.left : lastRect.left;
1272
+ const right = isTop ? firstRect.right : lastRect.right;
1273
+ const width = right - left;
1274
+ const height = bottom - top;
1275
+ return {
1276
+ top,
1277
+ bottom,
1278
+ left,
1279
+ right,
1280
+ width,
1281
+ height,
1282
+ x: left,
1283
+ y: top
1284
+ };
1285
+ }
1286
+
1287
+ const isLeftSide = getSide(placement) === 'left';
1288
+ const maxRight = max$1(...clientRects.map(rect => rect.right));
1289
+ const minLeft = min$1(...clientRects.map(rect => rect.left));
1290
+ const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
1291
+ const top = measureRects[0].top;
1292
+ const bottom = measureRects[measureRects.length - 1].bottom;
1293
+ const left = minLeft;
1294
+ const right = maxRight;
1295
+ const width = right - left;
1296
+ const height = bottom - top;
1297
+ return {
1298
+ top,
1299
+ bottom,
1300
+ left,
1301
+ right,
1302
+ width,
1303
+ height,
1304
+ x: left,
1305
+ y: top
1306
+ };
1307
+ }
1308
+
1309
+ return fallback;
1310
+ }
1311
+
1312
+ const resetRects = await platform.getElementRects({
1313
+ reference: {
1314
+ getBoundingClientRect
1315
+ },
1316
+ floating: elements.floating,
1317
+ strategy
1318
+ });
1319
+
1320
+ if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {
1321
+ return {
1322
+ reset: {
1323
+ rects: resetRects
1324
+ }
1325
+ };
1326
+ }
1327
+
1328
+ return {};
1329
+ }
1330
+
1331
+ };
1332
+ };
1333
+
1334
+ function isWindow(value) {
1335
+ return value && value.document && value.location && value.alert && value.setInterval;
1336
+ }
1337
+ function getWindow(node) {
1338
+ if (node == null) {
1339
+ return window;
1340
+ }
1341
+
1342
+ if (!isWindow(node)) {
1343
+ const ownerDocument = node.ownerDocument;
1344
+ return ownerDocument ? ownerDocument.defaultView || window : window;
1345
+ }
1346
+
1347
+ return node;
1348
+ }
1349
+
1350
+ function getComputedStyle$1(element) {
1351
+ return getWindow(element).getComputedStyle(element);
1352
+ }
1353
+
1354
+ function getNodeName(node) {
1355
+ return isWindow(node) ? '' : node ? (node.nodeName || '').toLowerCase() : '';
1356
+ }
1357
+
1358
+ function getUAString() {
1359
+ const uaData = navigator.userAgentData;
1360
+
1361
+ if (uaData != null && uaData.brands) {
1362
+ return uaData.brands.map(item => item.brand + "/" + item.version).join(' ');
1363
+ }
1364
+
1365
+ return navigator.userAgent;
1366
+ }
1367
+
1368
+ function isHTMLElement(value) {
1369
+ return value instanceof getWindow(value).HTMLElement;
1370
+ }
1371
+ function isElement(value) {
1372
+ return value instanceof getWindow(value).Element;
1373
+ }
1374
+ function isNode(value) {
1375
+ return value instanceof getWindow(value).Node;
1376
+ }
1377
+ function isShadowRoot(node) {
1378
+ // Browsers without `ShadowRoot` support
1379
+ if (typeof ShadowRoot === 'undefined') {
1380
+ return false;
1381
+ }
1382
+
1383
+ const OwnElement = getWindow(node).ShadowRoot;
1384
+ return node instanceof OwnElement || node instanceof ShadowRoot;
1385
+ }
1386
+ function isOverflowElement(element) {
1387
+ // Firefox wants us to check `-x` and `-y` variations as well
1388
+ const {
1389
+ overflow,
1390
+ overflowX,
1391
+ overflowY
1392
+ } = getComputedStyle$1(element);
1393
+ return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
1394
+ }
1395
+ function isTableElement(element) {
1396
+ return ['table', 'td', 'th'].includes(getNodeName(element));
1397
+ }
1398
+ function isContainingBlock(element) {
1399
+ // TODO: Try and use feature detection here instead
1400
+ const isFirefox = /firefox/i.test(getUAString());
1401
+ const css = getComputedStyle$1(element); // This is non-exhaustive but covers the most common CSS properties that
1402
+ // create a containing block.
1403
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1404
+
1405
+ return css.transform !== 'none' || css.perspective !== 'none' || // @ts-ignore (TS 4.1 compat)
1406
+ css.contain === 'paint' || ['transform', 'perspective'].includes(css.willChange) || isFirefox && css.willChange === 'filter' || isFirefox && (css.filter ? css.filter !== 'none' : false);
1407
+ }
1408
+ function isLayoutViewport() {
1409
+ // Not Safari
1410
+ return !/^((?!chrome|android).)*safari/i.test(getUAString()); // Feature detection for this fails in various ways
1411
+ // • Always-visible scrollbar or not
1412
+ // • Width of <html>, etc.
1413
+ // const vV = win.visualViewport;
1414
+ // return vV ? Math.abs(win.innerWidth / vV.scale - vV.width) < 0.5 : true;
1415
+ }
1416
+
1417
+ const min = Math.min;
1418
+ const max = Math.max;
1419
+ const round = Math.round;
1420
+
1421
+ function getBoundingClientRect(element, includeScale, isFixedStrategy) {
1422
+ var _win$visualViewport$o, _win$visualViewport, _win$visualViewport$o2, _win$visualViewport2;
1423
+
1424
+ if (includeScale === void 0) {
1425
+ includeScale = false;
1426
+ }
1427
+
1428
+ if (isFixedStrategy === void 0) {
1429
+ isFixedStrategy = false;
1430
+ }
1431
+
1432
+ const clientRect = element.getBoundingClientRect();
1433
+ let scaleX = 1;
1434
+ let scaleY = 1;
1435
+
1436
+ if (includeScale && isHTMLElement(element)) {
1437
+ scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
1438
+ scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
1439
+ }
1440
+
1441
+ const win = isElement(element) ? getWindow(element) : window;
1442
+ const addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
1443
+ const x = (clientRect.left + (addVisualOffsets ? (_win$visualViewport$o = (_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) != null ? _win$visualViewport$o : 0 : 0)) / scaleX;
1444
+ const y = (clientRect.top + (addVisualOffsets ? (_win$visualViewport$o2 = (_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) != null ? _win$visualViewport$o2 : 0 : 0)) / scaleY;
1445
+ const width = clientRect.width / scaleX;
1446
+ const height = clientRect.height / scaleY;
1447
+ return {
1448
+ width,
1449
+ height,
1450
+ top: y,
1451
+ right: x + width,
1452
+ bottom: y + height,
1453
+ left: x,
1454
+ x,
1455
+ y
1456
+ };
1457
+ }
1458
+
1459
+ function getDocumentElement(node) {
1460
+ return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
1461
+ }
1462
+
1463
+ function getNodeScroll(element) {
1464
+ if (isElement(element)) {
1465
+ return {
1466
+ scrollLeft: element.scrollLeft,
1467
+ scrollTop: element.scrollTop
1468
+ };
1469
+ }
1470
+
1471
+ return {
1472
+ scrollLeft: element.pageXOffset,
1473
+ scrollTop: element.pageYOffset
1474
+ };
1475
+ }
1476
+
1477
+ function getWindowScrollBarX(element) {
1478
+ // If <html> has a CSS width greater than the viewport, then this will be
1479
+ // incorrect for RTL.
1480
+ return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
1481
+ }
1482
+
1483
+ function isScaled(element) {
1484
+ const rect = getBoundingClientRect(element);
1485
+ return round(rect.width) !== element.offsetWidth || round(rect.height) !== element.offsetHeight;
1486
+ }
1487
+
1488
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1489
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1490
+ const documentElement = getDocumentElement(offsetParent);
1491
+ const rect = getBoundingClientRect(element, // @ts-ignore - checked above (TS 4.1 compat)
1492
+ isOffsetParentAnElement && isScaled(offsetParent), strategy === 'fixed');
1493
+ let scroll = {
1494
+ scrollLeft: 0,
1495
+ scrollTop: 0
1496
+ };
1497
+ const offsets = {
1498
+ x: 0,
1499
+ y: 0
1500
+ };
1501
+
1502
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
1503
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1504
+ scroll = getNodeScroll(offsetParent);
1505
+ }
1506
+
1507
+ if (isHTMLElement(offsetParent)) {
1508
+ const offsetRect = getBoundingClientRect(offsetParent, true);
1509
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1510
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1511
+ } else if (documentElement) {
1512
+ offsets.x = getWindowScrollBarX(documentElement);
1513
+ }
1514
+ }
1515
+
1516
+ return {
1517
+ x: rect.left + scroll.scrollLeft - offsets.x,
1518
+ y: rect.top + scroll.scrollTop - offsets.y,
1519
+ width: rect.width,
1520
+ height: rect.height
1521
+ };
1522
+ }
1523
+
1524
+ function getParentNode(node) {
1525
+ if (getNodeName(node) === 'html') {
1526
+ return node;
1527
+ }
1528
+
1529
+ return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
1530
+ // @ts-ignore
1531
+ node.assignedSlot || // step into the shadow DOM of the parent of a slotted node
1532
+ node.parentNode || ( // DOM Element detected
1533
+ isShadowRoot(node) ? node.host : null) || // ShadowRoot detected
1534
+ getDocumentElement(node) // fallback
1535
+
1536
+ );
1537
+ }
1538
+
1539
+ function getTrueOffsetParent(element) {
1540
+ if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
1541
+ return null;
1542
+ }
1543
+
1544
+ return element.offsetParent;
1545
+ }
1546
+
1547
+ function getContainingBlock(element) {
1548
+ let currentNode = getParentNode(element);
1549
+
1550
+ if (isShadowRoot(currentNode)) {
1551
+ currentNode = currentNode.host;
1552
+ }
1553
+
1554
+ while (isHTMLElement(currentNode) && !['html', 'body'].includes(getNodeName(currentNode))) {
1555
+ if (isContainingBlock(currentNode)) {
1556
+ return currentNode;
1557
+ } else {
1558
+ currentNode = currentNode.parentNode;
1559
+ }
1560
+ }
1561
+
1562
+ return null;
1563
+ } // Gets the closest ancestor positioned element. Handles some edge cases,
1564
+ // such as table ancestors and cross browser bugs.
1565
+
1566
+
1567
+ function getOffsetParent(element) {
1568
+ const window = getWindow(element);
1569
+ let offsetParent = getTrueOffsetParent(element);
1570
+
1571
+ while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
1572
+ offsetParent = getTrueOffsetParent(offsetParent);
1573
+ }
1574
+
1575
+ if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
1576
+ return window;
1577
+ }
1578
+
1579
+ return offsetParent || getContainingBlock(element) || window;
1580
+ }
1581
+
1582
+ function getDimensions(element) {
1583
+ if (isHTMLElement(element)) {
1584
+ return {
1585
+ width: element.offsetWidth,
1586
+ height: element.offsetHeight
1587
+ };
1588
+ }
1589
+
1590
+ const rect = getBoundingClientRect(element);
1591
+ return {
1592
+ width: rect.width,
1593
+ height: rect.height
1594
+ };
1595
+ }
1596
+
1597
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1598
+ let {
1599
+ rect,
1600
+ offsetParent,
1601
+ strategy
1602
+ } = _ref;
1603
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1604
+ const documentElement = getDocumentElement(offsetParent);
1605
+
1606
+ if (offsetParent === documentElement) {
1607
+ return rect;
1608
+ }
1609
+
1610
+ let scroll = {
1611
+ scrollLeft: 0,
1612
+ scrollTop: 0
1613
+ };
1614
+ const offsets = {
1615
+ x: 0,
1616
+ y: 0
1617
+ };
1618
+
1619
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
1620
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1621
+ scroll = getNodeScroll(offsetParent);
1622
+ }
1623
+
1624
+ if (isHTMLElement(offsetParent)) {
1625
+ const offsetRect = getBoundingClientRect(offsetParent, true);
1626
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1627
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1628
+ } // This doesn't appear to be need to be negated.
1629
+ // else if (documentElement) {
1630
+ // offsets.x = getWindowScrollBarX(documentElement);
1631
+ // }
1632
+
1633
+ }
1634
+
1635
+ return { ...rect,
1636
+ x: rect.x - scroll.scrollLeft + offsets.x,
1637
+ y: rect.y - scroll.scrollTop + offsets.y
1638
+ };
1639
+ }
1640
+
1641
+ function getViewportRect(element, strategy) {
1642
+ const win = getWindow(element);
1643
+ const html = getDocumentElement(element);
1644
+ const visualViewport = win.visualViewport;
1645
+ let width = html.clientWidth;
1646
+ let height = html.clientHeight;
1647
+ let x = 0;
1648
+ let y = 0;
1649
+
1650
+ if (visualViewport) {
1651
+ width = visualViewport.width;
1652
+ height = visualViewport.height;
1653
+ const layoutViewport = isLayoutViewport();
1654
+
1655
+ if (layoutViewport || !layoutViewport && strategy === 'fixed') {
1656
+ x = visualViewport.offsetLeft;
1657
+ y = visualViewport.offsetTop;
1658
+ }
1659
+ }
1660
+
1661
+ return {
1662
+ width,
1663
+ height,
1664
+ x,
1665
+ y
1666
+ };
1667
+ }
1668
+
1669
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable
1670
+
1671
+ function getDocumentRect(element) {
1672
+ var _element$ownerDocumen;
1673
+
1674
+ const html = getDocumentElement(element);
1675
+ const scroll = getNodeScroll(element);
1676
+ const body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
1677
+ const width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
1678
+ const height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
1679
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1680
+ const y = -scroll.scrollTop;
1681
+
1682
+ if (getComputedStyle$1(body || html).direction === 'rtl') {
1683
+ x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
1684
+ }
1685
+
1686
+ return {
1687
+ width,
1688
+ height,
1689
+ x,
1690
+ y
1691
+ };
1692
+ }
1693
+
1694
+ function getNearestOverflowAncestor(node) {
1695
+ const parentNode = getParentNode(node);
1696
+
1697
+ if (['html', 'body', '#document'].includes(getNodeName(parentNode))) {
1698
+ // @ts-ignore assume body is always available
1699
+ return node.ownerDocument.body;
1700
+ }
1701
+
1702
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1703
+ return parentNode;
1704
+ }
1705
+
1706
+ return getNearestOverflowAncestor(parentNode);
1707
+ }
1708
+
1709
+ function getOverflowAncestors(node, list) {
1710
+ var _node$ownerDocument;
1711
+
1712
+ if (list === void 0) {
1713
+ list = [];
1714
+ }
1715
+
1716
+ const scrollableAncestor = getNearestOverflowAncestor(node);
1717
+ const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
1718
+ const win = getWindow(scrollableAncestor);
1719
+ const target = isBody ? [win].concat(win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []) : scrollableAncestor;
1720
+ const updatedList = list.concat(target);
1721
+ return isBody ? updatedList : // @ts-ignore: isBody tells us target will be an HTMLElement here
1722
+ updatedList.concat(getOverflowAncestors(target));
1723
+ }
1724
+
1725
+ function contains(parent, child) {
1726
+ const rootNode = child.getRootNode == null ? void 0 : child.getRootNode(); // First, attempt with faster native method
1727
+
1728
+ if (parent.contains(child)) {
1729
+ return true;
1730
+ } // then fallback to custom implementation with Shadow DOM support
1731
+ else if (rootNode && isShadowRoot(rootNode)) {
1732
+ let next = child;
1733
+
1734
+ do {
1735
+ // use `===` replace node.isSameNode()
1736
+ if (next && parent === next) {
1737
+ return true;
1738
+ } // @ts-ignore: need a better way to handle this...
1739
+
1740
+
1741
+ next = next.parentNode || next.host;
1742
+ } while (next);
1743
+ }
1744
+
1745
+ return false;
1746
+ }
1747
+
1748
+ function getInnerBoundingClientRect(element, strategy) {
1749
+ const clientRect = getBoundingClientRect(element, false, strategy === 'fixed');
1750
+ const top = clientRect.top + element.clientTop;
1751
+ const left = clientRect.left + element.clientLeft;
1752
+ return {
1753
+ top,
1754
+ left,
1755
+ x: left,
1756
+ y: top,
1757
+ right: left + element.clientWidth,
1758
+ bottom: top + element.clientHeight,
1759
+ width: element.clientWidth,
1760
+ height: element.clientHeight
1761
+ };
1762
+ }
1763
+
1764
+ function getClientRectFromClippingAncestor(element, clippingParent, strategy) {
1765
+ if (clippingParent === 'viewport') {
1766
+ return rectToClientRect(getViewportRect(element, strategy));
1767
+ }
1768
+
1769
+ if (isElement(clippingParent)) {
1770
+ return getInnerBoundingClientRect(clippingParent, strategy);
1771
+ }
1772
+
1773
+ return rectToClientRect(getDocumentRect(getDocumentElement(element)));
1774
+ } // A "clipping ancestor" is an overflowable container with the characteristic of
1775
+ // clipping (or hiding) overflowing elements with a position different from
1776
+ // `initial`
1777
+
1778
+
1779
+ function getClippingAncestors(element) {
1780
+ const clippingAncestors = getOverflowAncestors(element);
1781
+ const canEscapeClipping = ['absolute', 'fixed'].includes(getComputedStyle$1(element).position);
1782
+ const clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
1783
+
1784
+ if (!isElement(clipperElement)) {
1785
+ return [];
1786
+ } // @ts-ignore isElement check ensures we return Array<Element>
1787
+
1788
+
1789
+ return clippingAncestors.filter(clippingAncestors => isElement(clippingAncestors) && contains(clippingAncestors, clipperElement) && getNodeName(clippingAncestors) !== 'body');
1790
+ } // Gets the maximum area that the element is visible in due to any number of
1791
+ // clipping ancestors
1792
+
1793
+
1794
+ function getClippingRect(_ref) {
1795
+ let {
1796
+ element,
1797
+ boundary,
1798
+ rootBoundary,
1799
+ strategy
1800
+ } = _ref;
1801
+ const mainClippingAncestors = boundary === 'clippingAncestors' ? getClippingAncestors(element) : [].concat(boundary);
1802
+ const clippingAncestors = [...mainClippingAncestors, rootBoundary];
1803
+ const firstClippingAncestor = clippingAncestors[0];
1804
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1805
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1806
+ accRect.top = max(rect.top, accRect.top);
1807
+ accRect.right = min(rect.right, accRect.right);
1808
+ accRect.bottom = min(rect.bottom, accRect.bottom);
1809
+ accRect.left = max(rect.left, accRect.left);
1810
+ return accRect;
1811
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1812
+ return {
1813
+ width: clippingRect.right - clippingRect.left,
1814
+ height: clippingRect.bottom - clippingRect.top,
1815
+ x: clippingRect.left,
1816
+ y: clippingRect.top
1817
+ };
1818
+ }
1819
+
1820
+ const platform = {
1821
+ getClippingRect,
1822
+ convertOffsetParentRelativeRectToViewportRelativeRect,
1823
+ isElement,
1824
+ getDimensions,
1825
+ getOffsetParent,
1826
+ getDocumentElement,
1827
+ getElementRects: _ref => {
1828
+ let {
1829
+ reference,
1830
+ floating,
1831
+ strategy
1832
+ } = _ref;
1833
+ return {
1834
+ reference: getRectRelativeToOffsetParent(reference, getOffsetParent(floating), strategy),
1835
+ floating: { ...getDimensions(floating),
1836
+ x: 0,
1837
+ y: 0
1838
+ }
1839
+ };
1840
+ },
1841
+ getClientRects: element => Array.from(element.getClientRects()),
1842
+ isRTL: element => getComputedStyle$1(element).direction === 'rtl'
1843
+ };
1844
+
1845
+ /**
1846
+ * Automatically updates the position of the floating element when necessary.
1847
+ * @see https://floating-ui.com/docs/autoUpdate
1848
+ */
1849
+ function autoUpdate(reference, floating, update, options) {
1850
+ if (options === void 0) {
1851
+ options = {};
1852
+ }
1853
+
1854
+ const {
1855
+ ancestorScroll: _ancestorScroll = true,
1856
+ ancestorResize: _ancestorResize = true,
1857
+ elementResize = true,
1858
+ animationFrame = false
1859
+ } = options;
1860
+ const ancestorScroll = _ancestorScroll && !animationFrame;
1861
+ const ancestorResize = _ancestorResize && !animationFrame;
1862
+ const ancestors = ancestorScroll || ancestorResize ? [...(isElement(reference) ? getOverflowAncestors(reference) : []), ...getOverflowAncestors(floating)] : [];
1863
+ ancestors.forEach(ancestor => {
1864
+ ancestorScroll && ancestor.addEventListener('scroll', update, {
1865
+ passive: true
1866
+ });
1867
+ ancestorResize && ancestor.addEventListener('resize', update);
1868
+ });
1869
+ let observer = null;
1870
+
1871
+ if (elementResize) {
1872
+ observer = new ResizeObserver(update);
1873
+ isElement(reference) && !animationFrame && observer.observe(reference);
1874
+ observer.observe(floating);
1875
+ }
1876
+
1877
+ let frameId;
1878
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
1879
+
1880
+ if (animationFrame) {
1881
+ frameLoop();
1882
+ }
1883
+
1884
+ function frameLoop() {
1885
+ const nextRefRect = getBoundingClientRect(reference);
1886
+
1887
+ if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
1888
+ update();
1889
+ }
1890
+
1891
+ prevRefRect = nextRefRect;
1892
+ frameId = requestAnimationFrame(frameLoop);
1893
+ }
1894
+
1895
+ if (!elementResize) {
1896
+ update();
1897
+ }
1898
+
1899
+ return () => {
1900
+ var _observer;
1901
+
1902
+ ancestors.forEach(ancestor => {
1903
+ ancestorScroll && ancestor.removeEventListener('scroll', update);
1904
+ ancestorResize && ancestor.removeEventListener('resize', update);
1905
+ });
1906
+ (_observer = observer) == null ? void 0 : _observer.disconnect();
1907
+ observer = null;
1908
+
1909
+ if (animationFrame) {
1910
+ cancelAnimationFrame(frameId);
1911
+ }
1912
+ };
1913
+ }
1914
+
1915
+ /**
1916
+ * Computes the `x` and `y` coordinates that will place the floating element
1917
+ * next to a reference element when it is given a certain CSS positioning
1918
+ * strategy.
1919
+ */
1920
+
1921
+ const computePosition = (reference, floating, options) => computePosition$1(reference, floating, {
1922
+ platform,
1923
+ ...options
1924
+ });
1925
+
1926
+ var _Popup_instances, _Popup_arrowPosition_get, _Popup_padding_get, _Popup_distance_get, _Popup_strategy_get, _Popup_middleware_get, _Popup_cleanup, _Popup_anchorEl, _Popup_assignPopupPosition, _Popup_assignArrowPosition, _Popup_getAnchorById;
1927
+ class Popup extends FoundationElement {
1928
+ constructor() {
1929
+ super();
1930
+
1931
+ _Popup_instances.add(this);
1932
+
1933
+ _Popup_cleanup.set(this, void 0);
1934
+
1935
+ _Popup_anchorEl.set(this, void 0);
1936
+
1937
+ this.open = false;
1938
+ this.dismissible = false;
1939
+ this.arrow = false;
1940
+ this.alternate = false;
1941
+ this.corner = 'left';
1942
+ }
1943
+
1944
+ disconnectedCallback() {
1945
+ var _a;
1946
+
1947
+ super.disconnectedCallback();
1948
+ (_a = __classPrivateFieldGet(this, _Popup_cleanup, "f")) === null || _a === void 0 ? void 0 : _a.call(this);
1949
+ }
1950
+
1951
+ attributeChangedCallback(name, oldValue, newValue) {
1952
+ var _a;
1953
+
1954
+ super.attributeChangedCallback(name, oldValue, newValue);
1955
+
1956
+ switch (name) {
1957
+ case 'anchor':
1958
+ {
1959
+ __classPrivateFieldSet(this, _Popup_anchorEl, __classPrivateFieldGet(this, _Popup_instances, "m", _Popup_getAnchorById).call(this), "f");
1960
+
1961
+ break;
1962
+ }
1963
+ }
1964
+
1965
+ if (__classPrivateFieldGet(this, _Popup_anchorEl, "f") && this.popupEl) {
1966
+ __classPrivateFieldSet(this, _Popup_cleanup, autoUpdate(__classPrivateFieldGet(this, _Popup_anchorEl, "f"), this.popupEl, () => this.updatePosition()), "f");
1967
+ } else {
1968
+ (_a = __classPrivateFieldGet(this, _Popup_cleanup, "f")) === null || _a === void 0 ? void 0 : _a.call(this);
1969
+ }
1970
+ }
1971
+
1972
+ async updatePosition() {
1973
+ if (!this.open || !__classPrivateFieldGet(this, _Popup_anchorEl, "f")) {
1974
+ return;
1975
+ }
1976
+
1977
+ const positionData = await computePosition(__classPrivateFieldGet(this, _Popup_anchorEl, "f"), this.popupEl, {
1978
+ placement: this.corner,
1979
+ strategy: __classPrivateFieldGet(this, _Popup_instances, "a", _Popup_strategy_get),
1980
+ middleware: __classPrivateFieldGet(this, _Popup_instances, "a", _Popup_middleware_get)
1981
+ });
1982
+
1983
+ __classPrivateFieldGet(this, _Popup_instances, "m", _Popup_assignPopupPosition).call(this, positionData);
1984
+
1985
+ if (this.arrow) {
1986
+ __classPrivateFieldGet(this, _Popup_instances, "m", _Popup_assignArrowPosition).call(this, positionData);
1987
+ }
1988
+ }
1989
+
1990
+ }
1991
+ _Popup_cleanup = new WeakMap(), _Popup_anchorEl = new WeakMap(), _Popup_instances = new WeakSet(), _Popup_arrowPosition_get = function _Popup_arrowPosition_get() {
1992
+ return {
1993
+ top: 'bottom',
1994
+ right: 'left',
1995
+ bottom: 'top',
1996
+ left: 'right'
1997
+ };
1998
+ }, _Popup_padding_get = function _Popup_padding_get() {
1999
+ return 0;
2000
+ }, _Popup_distance_get = function _Popup_distance_get() {
2001
+ return 12;
2002
+ }, _Popup_strategy_get = function _Popup_strategy_get() {
2003
+ return 'fixed';
2004
+ }, _Popup_middleware_get = function _Popup_middleware_get() {
2005
+ const middleware = [flip(), hide(), inline()];
2006
+
2007
+ if (this.arrow) {
2008
+ middleware.push(arrow({
2009
+ element: this.arrowEl,
2010
+ padding: __classPrivateFieldGet(this, _Popup_instances, "a", _Popup_padding_get)
2011
+ }), offset(__classPrivateFieldGet(this, _Popup_instances, "a", _Popup_distance_get)));
2012
+ }
2013
+
2014
+ return middleware;
2015
+ }, _Popup_assignPopupPosition = function _Popup_assignPopupPosition(data) {
2016
+ const {
2017
+ x: popupX,
2018
+ y: popupY
2019
+ } = data;
2020
+ const {
2021
+ referenceHidden
2022
+ } = data.middlewareData.hide;
2023
+ Object.assign(this.popupEl.style, {
2024
+ left: `${popupX}px`,
2025
+ top: `${popupY}px`,
2026
+ visibility: referenceHidden ? 'hidden' : 'visible'
2027
+ });
2028
+ }, _Popup_assignArrowPosition = function _Popup_assignArrowPosition(data) {
2029
+ const {
2030
+ x: arrowX,
2031
+ y: arrowY
2032
+ } = data.middlewareData.arrow;
2033
+
2034
+ const side = __classPrivateFieldGet(this, _Popup_instances, "a", _Popup_arrowPosition_get)[data.placement.split('-')[0]];
2035
+
2036
+ Object.assign(this.arrowEl.style, {
2037
+ left: `${arrowX}px`,
2038
+ top: `${arrowY}px`,
2039
+ right: '',
2040
+ bottom: '',
2041
+ [side]: '-4px'
2042
+ });
2043
+ }, _Popup_getAnchorById = function _Popup_getAnchorById() {
2044
+ return document.getElementById(this.anchor);
2045
+ };
2046
+
2047
+ __decorate([attr({
2048
+ mode: 'boolean'
2049
+ }), __metadata("design:type", Object)], Popup.prototype, "open", void 0);
2050
+
2051
+ __decorate([attr({
2052
+ mode: 'boolean'
2053
+ }), __metadata("design:type", Object)], Popup.prototype, "dismissible", void 0);
2054
+
2055
+ __decorate([attr({
2056
+ mode: 'boolean'
2057
+ }), __metadata("design:type", Object)], Popup.prototype, "arrow", void 0);
2058
+
2059
+ __decorate([attr({
2060
+ mode: 'boolean'
2061
+ }), __metadata("design:type", Object)], Popup.prototype, "alternate", void 0);
2062
+
2063
+ __decorate([attr({
2064
+ mode: 'fromView'
2065
+ }), __metadata("design:type", String)], Popup.prototype, "corner", void 0);
2066
+
2067
+ __decorate([attr, __metadata("design:type", String)], Popup.prototype, "anchor", void 0);
2068
+
2069
+ var css_248z = ".control {\n background-color: var(--vvd-color-surface-4dp);\n border-radius: inherit;\n contain: layout;\n inline-size: -moz-fit-content;\n inline-size: fit-content;\n}\n.control:not(.open) {\n display: none;\n}\n\n.popup-wrapper {\n position: fixed;\n border-radius: 6px;\n}\n\n.popup-content {\n display: grid;\n color: var(--vvd-color-on-canvas); /* neutral-100 */\n}\n.dismissible .popup-content {\n align-content: start;\n grid-template-columns: 1fr auto;\n}\n\n.arrow {\n position: absolute;\n z-index: -1;\n width: 8px;\n height: 8px;\n background-color: var(--vvd-color-surface-4dp);\n transform: rotate(45deg);\n}\n\n.dismissible-button {\n align-self: flex-start;\n margin-block-start: 0.25rem;\n margin-inline-end: 0.25rem;\n}";
2070
+ styleInject(css_248z);
2071
+
2072
+ let _ = t => t,
2073
+ _t,
2074
+ _t2,
2075
+ _t3;
2076
+
2077
+ const getClasses = ({
2078
+ open,
2079
+ dismissible,
2080
+ alternate
2081
+ }) => classNames('control', ['open', Boolean(open)], ['dismissible', Boolean(dismissible)], ['alternate', Boolean(alternate)]);
2082
+
2083
+ const popupTemplate = () => html(_t || (_t = _`
2084
+ <vwc-elevation>
2085
+ <!--the popup-wrapper is needed for alternating the inside of the popup nd not its shadow-->
2086
+ <div class="popup-wrapper" ${0}>
2087
+ <div class="${0}" aria-hidden="${0}"
2088
+ part="${0}">
2089
+ <div class="popup-content">
2090
+ <slot></slot>
2091
+ ${0}
2092
+ </div>
2093
+ ${0}
2094
+ </div>
2095
+ </div>
2096
+ </vwc-elevation>`), ref('popupEl'), getClasses, x => x.open ? 'false' : 'true', x => x.alternate ? 'vvd-theme-alternate' : '', when(x => x.dismissible, html(_t2 || (_t2 = _`<vwc-button density="condensed" @click="${0}"
2097
+ class="dismissible-button" icon="close-small-solid" shape="pill"></vwc-button>`), x => x.open = false)), when(x => x.arrow, html(_t3 || (_t3 = _`<div class="arrow" ${0}></div>`), ref('arrowEl'))));
2098
+
2099
+ const vividPopup = Popup.compose({
2100
+ baseName: 'popup',
2101
+ template: popupTemplate,
2102
+ styles: css_248z
2103
+ });
2104
+ designSystem.register(vividPopup());
2105
+
2106
+ export { vividPopup };