@vonage/vivid 3.0.0-next.45 → 3.0.0-next.46

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