@vonage/vivid 3.0.0-next.8 → 3.0.0-next.80

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