@tabworthy/components 0.8.6 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/cjs/{index-w-Wtojyv.js → index-B1s0tI-Z.js} +21 -0
  2. package/dist/cjs/loader.cjs.js +2 -2
  3. package/dist/cjs/tabworthy-components.cjs.js +2 -2
  4. package/dist/cjs/tabworthy-dates-calendar_2.cjs.entry.js +1960 -8
  5. package/dist/cjs/tabworthy-dates.cjs.entry.js +9 -8
  6. package/dist/cjs/tabworthy-times-picker.cjs.entry.js +1 -1
  7. package/dist/cjs/tabworthy-times.cjs.entry.js +6 -5
  8. package/dist/collection/components/tabworthy-dates/tabworthy-dates.js +32 -7
  9. package/dist/collection/components/tabworthy-modal/tabworthy-dates-modal.css +4 -1
  10. package/dist/collection/components/tabworthy-modal/tabworthy-dates-modal.js +257 -5
  11. package/dist/collection/components/tabworthy-times/tabworthy-times.js +29 -4
  12. package/dist/components/index.js +1 -1
  13. package/dist/components/{p-DT8TK_a8.js → p-B8sG1vGD.js} +1 -1
  14. package/dist/components/{p-Bnmroodq.js → p-B9YA6avR.js} +1 -1
  15. package/dist/components/p-B9fGfjA-.js +1 -0
  16. package/dist/components/p-BiJ0HZVY.js +1 -0
  17. package/dist/components/tabworthy-dates-calendar.js +1 -1
  18. package/dist/components/tabworthy-dates-modal.js +1 -1
  19. package/dist/components/tabworthy-dates.js +1 -1
  20. package/dist/components/tabworthy-times-picker.js +1 -1
  21. package/dist/components/tabworthy-times.js +1 -1
  22. package/dist/esm/{index-CDFauf_3.js → index-CwtZ_Lud.js} +21 -0
  23. package/dist/esm/loader.js +3 -3
  24. package/dist/esm/tabworthy-components.js +3 -3
  25. package/dist/esm/tabworthy-dates-calendar_2.entry.js +1960 -8
  26. package/dist/esm/tabworthy-dates.entry.js +9 -8
  27. package/dist/esm/tabworthy-times-picker.entry.js +1 -1
  28. package/dist/esm/tabworthy-times.entry.js +6 -5
  29. package/dist/tabworthy-components/{p-8416e0a9.entry.js → p-4eec41e5.entry.js} +1 -1
  30. package/dist/tabworthy-components/{p-dcb3ea8d.entry.js → p-90de04dd.entry.js} +1 -1
  31. package/dist/tabworthy-components/p-CwtZ_Lud.js +2 -0
  32. package/dist/tabworthy-components/{p-224503da.entry.js → p-c0f957f5.entry.js} +1 -1
  33. package/dist/tabworthy-components/p-ee41beed.entry.js +1 -0
  34. package/dist/tabworthy-components/tabworthy-components.esm.js +1 -1
  35. package/dist/themes/light.css +1 -1
  36. package/dist/types/components/tabworthy-dates/tabworthy-dates.d.ts +6 -1
  37. package/dist/types/components/tabworthy-modal/tabworthy-dates-modal.d.ts +27 -0
  38. package/dist/types/components/tabworthy-times/tabworthy-times.d.ts +6 -1
  39. package/dist/types/components.d.ts +54 -0
  40. package/package.json +2 -1
  41. package/dist/components/p-CGobNAdR.js +0 -1
  42. package/dist/components/p-Kr35QPhi.js +0 -1
  43. package/dist/tabworthy-components/p-CDFauf_3.js +0 -2
  44. package/dist/tabworthy-components/p-e66c010b.entry.js +0 -1
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-CDFauf_3.js';
1
+ import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-CwtZ_Lud.js';
2
2
  import { g as getISODateString, r as removeTimezoneOffset, a as getNextMonth, b as getNextYear, c as getPreviousMonth, d as getPreviousYear, e as dateIsWithinBounds, f as getPreviousDay, h as getNextDay, s as subDays, i as addDays, j as getFirstOfMonth, k as getLastOfMonth, l as getWeekDays, m as getDaysOfMonth, n as dateIsWithinLowerBounds, o as dateIsWithinUpperBounds, p as getYear, q as getMonth, t as monthIsDisabled, u as getMonths, v as isSameDay, w as isDateInRange } from './utils-BVHu5CWV.js';
3
3
 
4
4
  const tabworthyDatesCalendarCss = () => `.visually-hidden.sc-tabworthy-dates-calendar{position:absolute;overflow:hidden;width:1px;height:1px;white-space:nowrap;clip:rect(0 0 0 0);-webkit-clip-path:inset(50%);clip-path:inset(50%)}`;
@@ -528,7 +528,7 @@ const timeouts = new Map();
528
528
  * @param ms
529
529
  * @param id
530
530
  */
531
- function debounce(cb, ms, id) {
531
+ function debounce$1(cb, ms, id) {
532
532
  // Clear current timeout for id
533
533
  const timeout = timeouts.get(id);
534
534
  if (timeout != null) {
@@ -688,7 +688,7 @@ class FocusTrap extends HTMLElement {
688
688
  * @param value
689
689
  */
690
690
  updateFocused(value) {
691
- debounce(() => {
691
+ debounce$1(() => {
692
692
  if (this.focused !== value) {
693
693
  this._focused = value;
694
694
  this.render();
@@ -834,7 +834,1796 @@ var hideOthers = function (originalTarget, parentNode, markerName) {
834
834
  return applyAttributeToOthers(targets, activeParentNode, markerName, 'aria-hidden');
835
835
  };
836
836
 
837
- const tabworthyDatesModalCss = () => `:host::part(body){position:absolute;width:-moz-fit-content;width:fit-content;z-index:1200;margin-top:0.5rem}:host::part(backdrop){}:host::part(content){}`;
837
+ var top = 'top';
838
+ var bottom = 'bottom';
839
+ var right = 'right';
840
+ var left = 'left';
841
+ var auto = 'auto';
842
+ var basePlacements = [top, bottom, right, left];
843
+ var start = 'start';
844
+ var end = 'end';
845
+ var clippingParents = 'clippingParents';
846
+ var viewport = 'viewport';
847
+ var popper = 'popper';
848
+ var reference = 'reference';
849
+ var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) {
850
+ return acc.concat([placement + "-" + start, placement + "-" + end]);
851
+ }, []);
852
+ var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
853
+ return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
854
+ }, []); // modifiers that need to read the DOM
855
+
856
+ var beforeRead = 'beforeRead';
857
+ var read = 'read';
858
+ var afterRead = 'afterRead'; // pure-logic modifiers
859
+
860
+ var beforeMain = 'beforeMain';
861
+ var main = 'main';
862
+ var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)
863
+
864
+ var beforeWrite = 'beforeWrite';
865
+ var write = 'write';
866
+ var afterWrite = 'afterWrite';
867
+ var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
868
+
869
+ function getNodeName(element) {
870
+ return element ? (element.nodeName || '').toLowerCase() : null;
871
+ }
872
+
873
+ function getWindow(node) {
874
+ if (node == null) {
875
+ return window;
876
+ }
877
+
878
+ if (node.toString() !== '[object Window]') {
879
+ var ownerDocument = node.ownerDocument;
880
+ return ownerDocument ? ownerDocument.defaultView || window : window;
881
+ }
882
+
883
+ return node;
884
+ }
885
+
886
+ function isElement(node) {
887
+ var OwnElement = getWindow(node).Element;
888
+ return node instanceof OwnElement || node instanceof Element;
889
+ }
890
+
891
+ function isHTMLElement(node) {
892
+ var OwnElement = getWindow(node).HTMLElement;
893
+ return node instanceof OwnElement || node instanceof HTMLElement;
894
+ }
895
+
896
+ function isShadowRoot(node) {
897
+ // IE 11 has no ShadowRoot
898
+ if (typeof ShadowRoot === 'undefined') {
899
+ return false;
900
+ }
901
+
902
+ var OwnElement = getWindow(node).ShadowRoot;
903
+ return node instanceof OwnElement || node instanceof ShadowRoot;
904
+ }
905
+
906
+ // and applies them to the HTMLElements such as popper and arrow
907
+
908
+ function applyStyles(_ref) {
909
+ var state = _ref.state;
910
+ Object.keys(state.elements).forEach(function (name) {
911
+ var style = state.styles[name] || {};
912
+ var attributes = state.attributes[name] || {};
913
+ var element = state.elements[name]; // arrow is optional + virtual elements
914
+
915
+ if (!isHTMLElement(element) || !getNodeName(element)) {
916
+ return;
917
+ } // Flow doesn't support to extend this property, but it's the most
918
+ // effective way to apply styles to an HTMLElement
919
+ // $FlowFixMe[cannot-write]
920
+
921
+
922
+ Object.assign(element.style, style);
923
+ Object.keys(attributes).forEach(function (name) {
924
+ var value = attributes[name];
925
+
926
+ if (value === false) {
927
+ element.removeAttribute(name);
928
+ } else {
929
+ element.setAttribute(name, value === true ? '' : value);
930
+ }
931
+ });
932
+ });
933
+ }
934
+
935
+ function effect$2(_ref2) {
936
+ var state = _ref2.state;
937
+ var initialStyles = {
938
+ popper: {
939
+ position: state.options.strategy,
940
+ left: '0',
941
+ top: '0',
942
+ margin: '0'
943
+ },
944
+ arrow: {
945
+ position: 'absolute'
946
+ },
947
+ reference: {}
948
+ };
949
+ Object.assign(state.elements.popper.style, initialStyles.popper);
950
+ state.styles = initialStyles;
951
+
952
+ if (state.elements.arrow) {
953
+ Object.assign(state.elements.arrow.style, initialStyles.arrow);
954
+ }
955
+
956
+ return function () {
957
+ Object.keys(state.elements).forEach(function (name) {
958
+ var element = state.elements[name];
959
+ var attributes = state.attributes[name] || {};
960
+ var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them
961
+
962
+ var style = styleProperties.reduce(function (style, property) {
963
+ style[property] = '';
964
+ return style;
965
+ }, {}); // arrow is optional + virtual elements
966
+
967
+ if (!isHTMLElement(element) || !getNodeName(element)) {
968
+ return;
969
+ }
970
+
971
+ Object.assign(element.style, style);
972
+ Object.keys(attributes).forEach(function (attribute) {
973
+ element.removeAttribute(attribute);
974
+ });
975
+ });
976
+ };
977
+ } // eslint-disable-next-line import/no-unused-modules
978
+
979
+
980
+ var applyStyles$1 = {
981
+ name: 'applyStyles',
982
+ enabled: true,
983
+ phase: 'write',
984
+ fn: applyStyles,
985
+ effect: effect$2,
986
+ requires: ['computeStyles']
987
+ };
988
+
989
+ function getBasePlacement(placement) {
990
+ return placement.split('-')[0];
991
+ }
992
+
993
+ var max = Math.max;
994
+ var min = Math.min;
995
+ var round = Math.round;
996
+
997
+ function getUAString() {
998
+ var uaData = navigator.userAgentData;
999
+
1000
+ if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) {
1001
+ return uaData.brands.map(function (item) {
1002
+ return item.brand + "/" + item.version;
1003
+ }).join(' ');
1004
+ }
1005
+
1006
+ return navigator.userAgent;
1007
+ }
1008
+
1009
+ function isLayoutViewport() {
1010
+ return !/^((?!chrome|android).)*safari/i.test(getUAString());
1011
+ }
1012
+
1013
+ function getBoundingClientRect(element, includeScale, isFixedStrategy) {
1014
+ if (includeScale === void 0) {
1015
+ includeScale = false;
1016
+ }
1017
+
1018
+ if (isFixedStrategy === void 0) {
1019
+ isFixedStrategy = false;
1020
+ }
1021
+
1022
+ var clientRect = element.getBoundingClientRect();
1023
+ var scaleX = 1;
1024
+ var scaleY = 1;
1025
+
1026
+ if (includeScale && isHTMLElement(element)) {
1027
+ scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
1028
+ scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
1029
+ }
1030
+
1031
+ var _ref = isElement(element) ? getWindow(element) : window,
1032
+ visualViewport = _ref.visualViewport;
1033
+
1034
+ var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
1035
+ var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
1036
+ var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
1037
+ var width = clientRect.width / scaleX;
1038
+ var height = clientRect.height / scaleY;
1039
+ return {
1040
+ width: width,
1041
+ height: height,
1042
+ top: y,
1043
+ right: x + width,
1044
+ bottom: y + height,
1045
+ left: x,
1046
+ x: x,
1047
+ y: y
1048
+ };
1049
+ }
1050
+
1051
+ // means it doesn't take into account transforms.
1052
+
1053
+ function getLayoutRect(element) {
1054
+ var clientRect = getBoundingClientRect(element); // Use the clientRect sizes if it's not been transformed.
1055
+ // Fixes https://github.com/popperjs/popper-core/issues/1223
1056
+
1057
+ var width = element.offsetWidth;
1058
+ var height = element.offsetHeight;
1059
+
1060
+ if (Math.abs(clientRect.width - width) <= 1) {
1061
+ width = clientRect.width;
1062
+ }
1063
+
1064
+ if (Math.abs(clientRect.height - height) <= 1) {
1065
+ height = clientRect.height;
1066
+ }
1067
+
1068
+ return {
1069
+ x: element.offsetLeft,
1070
+ y: element.offsetTop,
1071
+ width: width,
1072
+ height: height
1073
+ };
1074
+ }
1075
+
1076
+ function contains(parent, child) {
1077
+ var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
1078
+
1079
+ if (parent.contains(child)) {
1080
+ return true;
1081
+ } // then fallback to custom implementation with Shadow DOM support
1082
+ else if (rootNode && isShadowRoot(rootNode)) {
1083
+ var next = child;
1084
+
1085
+ do {
1086
+ if (next && parent.isSameNode(next)) {
1087
+ return true;
1088
+ } // $FlowFixMe[prop-missing]: need a better way to handle this...
1089
+
1090
+
1091
+ next = next.parentNode || next.host;
1092
+ } while (next);
1093
+ } // Give up, the result is false
1094
+
1095
+
1096
+ return false;
1097
+ }
1098
+
1099
+ function getComputedStyle(element) {
1100
+ return getWindow(element).getComputedStyle(element);
1101
+ }
1102
+
1103
+ function isTableElement(element) {
1104
+ return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
1105
+ }
1106
+
1107
+ function getDocumentElement(element) {
1108
+ // $FlowFixMe[incompatible-return]: assume body is always available
1109
+ return ((isElement(element) ? element.ownerDocument : // $FlowFixMe[prop-missing]
1110
+ element.document) || window.document).documentElement;
1111
+ }
1112
+
1113
+ function getParentNode(element) {
1114
+ if (getNodeName(element) === 'html') {
1115
+ return element;
1116
+ }
1117
+
1118
+ return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
1119
+ // $FlowFixMe[incompatible-return]
1120
+ // $FlowFixMe[prop-missing]
1121
+ element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
1122
+ element.parentNode || ( // DOM Element detected
1123
+ isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
1124
+ // $FlowFixMe[incompatible-call]: HTMLElement is a Node
1125
+ getDocumentElement(element) // fallback
1126
+
1127
+ );
1128
+ }
1129
+
1130
+ function getTrueOffsetParent(element) {
1131
+ if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
1132
+ getComputedStyle(element).position === 'fixed') {
1133
+ return null;
1134
+ }
1135
+
1136
+ return element.offsetParent;
1137
+ } // `.offsetParent` reports `null` for fixed elements, while absolute elements
1138
+ // return the containing block
1139
+
1140
+
1141
+ function getContainingBlock(element) {
1142
+ var isFirefox = /firefox/i.test(getUAString());
1143
+ var isIE = /Trident/i.test(getUAString());
1144
+
1145
+ if (isIE && isHTMLElement(element)) {
1146
+ // In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
1147
+ var elementCss = getComputedStyle(element);
1148
+
1149
+ if (elementCss.position === 'fixed') {
1150
+ return null;
1151
+ }
1152
+ }
1153
+
1154
+ var currentNode = getParentNode(element);
1155
+
1156
+ if (isShadowRoot(currentNode)) {
1157
+ currentNode = currentNode.host;
1158
+ }
1159
+
1160
+ while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
1161
+ var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that
1162
+ // create a containing block.
1163
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1164
+
1165
+ if (css.transform !== 'none' || css.perspective !== 'none' || css.contain === 'paint' || ['transform', 'perspective'].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === 'filter' || isFirefox && css.filter && css.filter !== 'none') {
1166
+ return currentNode;
1167
+ } else {
1168
+ currentNode = currentNode.parentNode;
1169
+ }
1170
+ }
1171
+
1172
+ return null;
1173
+ } // Gets the closest ancestor positioned element. Handles some edge cases,
1174
+ // such as table ancestors and cross browser bugs.
1175
+
1176
+
1177
+ function getOffsetParent(element) {
1178
+ var window = getWindow(element);
1179
+ var offsetParent = getTrueOffsetParent(element);
1180
+
1181
+ while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
1182
+ offsetParent = getTrueOffsetParent(offsetParent);
1183
+ }
1184
+
1185
+ if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static')) {
1186
+ return window;
1187
+ }
1188
+
1189
+ return offsetParent || getContainingBlock(element) || window;
1190
+ }
1191
+
1192
+ function getMainAxisFromPlacement(placement) {
1193
+ return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
1194
+ }
1195
+
1196
+ function within(min$1, value, max$1) {
1197
+ return max(min$1, min(value, max$1));
1198
+ }
1199
+ function withinMaxClamp(min, value, max) {
1200
+ var v = within(min, value, max);
1201
+ return v > max ? max : v;
1202
+ }
1203
+
1204
+ function getFreshSideObject() {
1205
+ return {
1206
+ top: 0,
1207
+ right: 0,
1208
+ bottom: 0,
1209
+ left: 0
1210
+ };
1211
+ }
1212
+
1213
+ function mergePaddingObject(paddingObject) {
1214
+ return Object.assign({}, getFreshSideObject(), paddingObject);
1215
+ }
1216
+
1217
+ function expandToHashMap(value, keys) {
1218
+ return keys.reduce(function (hashMap, key) {
1219
+ hashMap[key] = value;
1220
+ return hashMap;
1221
+ }, {});
1222
+ }
1223
+
1224
+ var toPaddingObject = function toPaddingObject(padding, state) {
1225
+ padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, {
1226
+ placement: state.placement
1227
+ })) : padding;
1228
+ return mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
1229
+ };
1230
+
1231
+ function arrow(_ref) {
1232
+ var _state$modifiersData$;
1233
+
1234
+ var state = _ref.state,
1235
+ name = _ref.name,
1236
+ options = _ref.options;
1237
+ var arrowElement = state.elements.arrow;
1238
+ var popperOffsets = state.modifiersData.popperOffsets;
1239
+ var basePlacement = getBasePlacement(state.placement);
1240
+ var axis = getMainAxisFromPlacement(basePlacement);
1241
+ var isVertical = [left, right].indexOf(basePlacement) >= 0;
1242
+ var len = isVertical ? 'height' : 'width';
1243
+
1244
+ if (!arrowElement || !popperOffsets) {
1245
+ return;
1246
+ }
1247
+
1248
+ var paddingObject = toPaddingObject(options.padding, state);
1249
+ var arrowRect = getLayoutRect(arrowElement);
1250
+ var minProp = axis === 'y' ? top : left;
1251
+ var maxProp = axis === 'y' ? bottom : right;
1252
+ var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
1253
+ var startDiff = popperOffsets[axis] - state.rects.reference[axis];
1254
+ var arrowOffsetParent = getOffsetParent(arrowElement);
1255
+ var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
1256
+ var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is
1257
+ // outside of the popper bounds
1258
+
1259
+ var min = paddingObject[minProp];
1260
+ var max = clientSize - arrowRect[len] - paddingObject[maxProp];
1261
+ var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
1262
+ var offset = within(min, center, max); // Prevents breaking syntax highlighting...
1263
+
1264
+ var axisProp = axis;
1265
+ state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
1266
+ }
1267
+
1268
+ function effect$1(_ref2) {
1269
+ var state = _ref2.state,
1270
+ options = _ref2.options;
1271
+ var _options$element = options.element,
1272
+ arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element;
1273
+
1274
+ if (arrowElement == null) {
1275
+ return;
1276
+ } // CSS selector
1277
+
1278
+
1279
+ if (typeof arrowElement === 'string') {
1280
+ arrowElement = state.elements.popper.querySelector(arrowElement);
1281
+
1282
+ if (!arrowElement) {
1283
+ return;
1284
+ }
1285
+ }
1286
+
1287
+ if (!contains(state.elements.popper, arrowElement)) {
1288
+ return;
1289
+ }
1290
+
1291
+ state.elements.arrow = arrowElement;
1292
+ } // eslint-disable-next-line import/no-unused-modules
1293
+
1294
+
1295
+ var arrow$1 = {
1296
+ name: 'arrow',
1297
+ enabled: true,
1298
+ phase: 'main',
1299
+ fn: arrow,
1300
+ effect: effect$1,
1301
+ requires: ['popperOffsets'],
1302
+ requiresIfExists: ['preventOverflow']
1303
+ };
1304
+
1305
+ function getVariation(placement) {
1306
+ return placement.split('-')[1];
1307
+ }
1308
+
1309
+ var unsetSides = {
1310
+ top: 'auto',
1311
+ right: 'auto',
1312
+ bottom: 'auto',
1313
+ left: 'auto'
1314
+ }; // Round the offsets to the nearest suitable subpixel based on the DPR.
1315
+ // Zooming can change the DPR, but it seems to report a value that will
1316
+ // cleanly divide the values into the appropriate subpixels.
1317
+
1318
+ function roundOffsetsByDPR(_ref, win) {
1319
+ var x = _ref.x,
1320
+ y = _ref.y;
1321
+ var dpr = win.devicePixelRatio || 1;
1322
+ return {
1323
+ x: round(x * dpr) / dpr || 0,
1324
+ y: round(y * dpr) / dpr || 0
1325
+ };
1326
+ }
1327
+
1328
+ function mapToStyles(_ref2) {
1329
+ var _Object$assign2;
1330
+
1331
+ var popper = _ref2.popper,
1332
+ popperRect = _ref2.popperRect,
1333
+ placement = _ref2.placement,
1334
+ variation = _ref2.variation,
1335
+ offsets = _ref2.offsets,
1336
+ position = _ref2.position,
1337
+ gpuAcceleration = _ref2.gpuAcceleration,
1338
+ adaptive = _ref2.adaptive,
1339
+ roundOffsets = _ref2.roundOffsets,
1340
+ isFixed = _ref2.isFixed;
1341
+ var _offsets$x = offsets.x,
1342
+ x = _offsets$x === void 0 ? 0 : _offsets$x,
1343
+ _offsets$y = offsets.y,
1344
+ y = _offsets$y === void 0 ? 0 : _offsets$y;
1345
+
1346
+ var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({
1347
+ x: x,
1348
+ y: y
1349
+ }) : {
1350
+ x: x,
1351
+ y: y
1352
+ };
1353
+
1354
+ x = _ref3.x;
1355
+ y = _ref3.y;
1356
+ var hasX = offsets.hasOwnProperty('x');
1357
+ var hasY = offsets.hasOwnProperty('y');
1358
+ var sideX = left;
1359
+ var sideY = top;
1360
+ var win = window;
1361
+
1362
+ if (adaptive) {
1363
+ var offsetParent = getOffsetParent(popper);
1364
+ var heightProp = 'clientHeight';
1365
+ var widthProp = 'clientWidth';
1366
+
1367
+ if (offsetParent === getWindow(popper)) {
1368
+ offsetParent = getDocumentElement(popper);
1369
+
1370
+ if (getComputedStyle(offsetParent).position !== 'static' && position === 'absolute') {
1371
+ heightProp = 'scrollHeight';
1372
+ widthProp = 'scrollWidth';
1373
+ }
1374
+ } // $FlowFixMe[incompatible-cast]: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
1375
+
1376
+
1377
+ offsetParent = offsetParent;
1378
+
1379
+ if (placement === top || (placement === left || placement === right) && variation === end) {
1380
+ sideY = bottom;
1381
+ var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]
1382
+ offsetParent[heightProp];
1383
+ y -= offsetY - popperRect.height;
1384
+ y *= gpuAcceleration ? 1 : -1;
1385
+ }
1386
+
1387
+ if (placement === left || (placement === top || placement === bottom) && variation === end) {
1388
+ sideX = right;
1389
+ var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]
1390
+ offsetParent[widthProp];
1391
+ x -= offsetX - popperRect.width;
1392
+ x *= gpuAcceleration ? 1 : -1;
1393
+ }
1394
+ }
1395
+
1396
+ var commonStyles = Object.assign({
1397
+ position: position
1398
+ }, adaptive && unsetSides);
1399
+
1400
+ var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
1401
+ x: x,
1402
+ y: y
1403
+ }, getWindow(popper)) : {
1404
+ x: x,
1405
+ y: y
1406
+ };
1407
+
1408
+ x = _ref4.x;
1409
+ y = _ref4.y;
1410
+
1411
+ if (gpuAcceleration) {
1412
+ var _Object$assign;
1413
+
1414
+ return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
1415
+ }
1416
+
1417
+ return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
1418
+ }
1419
+
1420
+ function computeStyles(_ref5) {
1421
+ var state = _ref5.state,
1422
+ options = _ref5.options;
1423
+ var _options$gpuAccelerat = options.gpuAcceleration,
1424
+ gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
1425
+ _options$adaptive = options.adaptive,
1426
+ adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
1427
+ _options$roundOffsets = options.roundOffsets,
1428
+ roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
1429
+ var commonStyles = {
1430
+ placement: getBasePlacement(state.placement),
1431
+ variation: getVariation(state.placement),
1432
+ popper: state.elements.popper,
1433
+ popperRect: state.rects.popper,
1434
+ gpuAcceleration: gpuAcceleration,
1435
+ isFixed: state.options.strategy === 'fixed'
1436
+ };
1437
+
1438
+ if (state.modifiersData.popperOffsets != null) {
1439
+ state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
1440
+ offsets: state.modifiersData.popperOffsets,
1441
+ position: state.options.strategy,
1442
+ adaptive: adaptive,
1443
+ roundOffsets: roundOffsets
1444
+ })));
1445
+ }
1446
+
1447
+ if (state.modifiersData.arrow != null) {
1448
+ state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
1449
+ offsets: state.modifiersData.arrow,
1450
+ position: 'absolute',
1451
+ adaptive: false,
1452
+ roundOffsets: roundOffsets
1453
+ })));
1454
+ }
1455
+
1456
+ state.attributes.popper = Object.assign({}, state.attributes.popper, {
1457
+ 'data-popper-placement': state.placement
1458
+ });
1459
+ } // eslint-disable-next-line import/no-unused-modules
1460
+
1461
+
1462
+ var computeStyles$1 = {
1463
+ name: 'computeStyles',
1464
+ enabled: true,
1465
+ phase: 'beforeWrite',
1466
+ fn: computeStyles,
1467
+ data: {}
1468
+ };
1469
+
1470
+ var passive = {
1471
+ passive: true
1472
+ };
1473
+
1474
+ function effect(_ref) {
1475
+ var state = _ref.state,
1476
+ instance = _ref.instance,
1477
+ options = _ref.options;
1478
+ var _options$scroll = options.scroll,
1479
+ scroll = _options$scroll === void 0 ? true : _options$scroll,
1480
+ _options$resize = options.resize,
1481
+ resize = _options$resize === void 0 ? true : _options$resize;
1482
+ var window = getWindow(state.elements.popper);
1483
+ var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
1484
+
1485
+ if (scroll) {
1486
+ scrollParents.forEach(function (scrollParent) {
1487
+ scrollParent.addEventListener('scroll', instance.update, passive);
1488
+ });
1489
+ }
1490
+
1491
+ if (resize) {
1492
+ window.addEventListener('resize', instance.update, passive);
1493
+ }
1494
+
1495
+ return function () {
1496
+ if (scroll) {
1497
+ scrollParents.forEach(function (scrollParent) {
1498
+ scrollParent.removeEventListener('scroll', instance.update, passive);
1499
+ });
1500
+ }
1501
+
1502
+ if (resize) {
1503
+ window.removeEventListener('resize', instance.update, passive);
1504
+ }
1505
+ };
1506
+ } // eslint-disable-next-line import/no-unused-modules
1507
+
1508
+
1509
+ var eventListeners = {
1510
+ name: 'eventListeners',
1511
+ enabled: true,
1512
+ phase: 'write',
1513
+ fn: function fn() {},
1514
+ effect: effect,
1515
+ data: {}
1516
+ };
1517
+
1518
+ var hash$1 = {
1519
+ left: 'right',
1520
+ right: 'left',
1521
+ bottom: 'top',
1522
+ top: 'bottom'
1523
+ };
1524
+ function getOppositePlacement(placement) {
1525
+ return placement.replace(/left|right|bottom|top/g, function (matched) {
1526
+ return hash$1[matched];
1527
+ });
1528
+ }
1529
+
1530
+ var hash = {
1531
+ start: 'end',
1532
+ end: 'start'
1533
+ };
1534
+ function getOppositeVariationPlacement(placement) {
1535
+ return placement.replace(/start|end/g, function (matched) {
1536
+ return hash[matched];
1537
+ });
1538
+ }
1539
+
1540
+ function getWindowScroll(node) {
1541
+ var win = getWindow(node);
1542
+ var scrollLeft = win.pageXOffset;
1543
+ var scrollTop = win.pageYOffset;
1544
+ return {
1545
+ scrollLeft: scrollLeft,
1546
+ scrollTop: scrollTop
1547
+ };
1548
+ }
1549
+
1550
+ function getWindowScrollBarX(element) {
1551
+ // If <html> has a CSS width greater than the viewport, then this will be
1552
+ // incorrect for RTL.
1553
+ // Popper 1 is broken in this case and never had a bug report so let's assume
1554
+ // it's not an issue. I don't think anyone ever specifies width on <html>
1555
+ // anyway.
1556
+ // Browsers where the left scrollbar doesn't cause an issue report `0` for
1557
+ // this (e.g. Edge 2019, IE11, Safari)
1558
+ return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
1559
+ }
1560
+
1561
+ function getViewportRect(element, strategy) {
1562
+ var win = getWindow(element);
1563
+ var html = getDocumentElement(element);
1564
+ var visualViewport = win.visualViewport;
1565
+ var width = html.clientWidth;
1566
+ var height = html.clientHeight;
1567
+ var x = 0;
1568
+ var y = 0;
1569
+
1570
+ if (visualViewport) {
1571
+ width = visualViewport.width;
1572
+ height = visualViewport.height;
1573
+ var layoutViewport = isLayoutViewport();
1574
+
1575
+ if (layoutViewport || !layoutViewport && strategy === 'fixed') {
1576
+ x = visualViewport.offsetLeft;
1577
+ y = visualViewport.offsetTop;
1578
+ }
1579
+ }
1580
+
1581
+ return {
1582
+ width: width,
1583
+ height: height,
1584
+ x: x + getWindowScrollBarX(element),
1585
+ y: y
1586
+ };
1587
+ }
1588
+
1589
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable
1590
+
1591
+ function getDocumentRect(element) {
1592
+ var _element$ownerDocumen;
1593
+
1594
+ var html = getDocumentElement(element);
1595
+ var winScroll = getWindowScroll(element);
1596
+ var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
1597
+ var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
1598
+ var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
1599
+ var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
1600
+ var y = -winScroll.scrollTop;
1601
+
1602
+ if (getComputedStyle(body || html).direction === 'rtl') {
1603
+ x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
1604
+ }
1605
+
1606
+ return {
1607
+ width: width,
1608
+ height: height,
1609
+ x: x,
1610
+ y: y
1611
+ };
1612
+ }
1613
+
1614
+ function isScrollParent(element) {
1615
+ // Firefox wants us to check `-x` and `-y` variations as well
1616
+ var _getComputedStyle = getComputedStyle(element),
1617
+ overflow = _getComputedStyle.overflow,
1618
+ overflowX = _getComputedStyle.overflowX,
1619
+ overflowY = _getComputedStyle.overflowY;
1620
+
1621
+ return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
1622
+ }
1623
+
1624
+ function getScrollParent(node) {
1625
+ if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
1626
+ // $FlowFixMe[incompatible-return]: assume body is always available
1627
+ return node.ownerDocument.body;
1628
+ }
1629
+
1630
+ if (isHTMLElement(node) && isScrollParent(node)) {
1631
+ return node;
1632
+ }
1633
+
1634
+ return getScrollParent(getParentNode(node));
1635
+ }
1636
+
1637
+ /*
1638
+ given a DOM element, return the list of all scroll parents, up the list of ancesors
1639
+ until we get to the top window object. This list is what we attach scroll listeners
1640
+ to, because if any of these parent elements scroll, we'll need to re-calculate the
1641
+ reference element's position.
1642
+ */
1643
+
1644
+ function listScrollParents(element, list) {
1645
+ var _element$ownerDocumen;
1646
+
1647
+ if (list === void 0) {
1648
+ list = [];
1649
+ }
1650
+
1651
+ var scrollParent = getScrollParent(element);
1652
+ var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
1653
+ var win = getWindow(scrollParent);
1654
+ var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
1655
+ var updatedList = list.concat(target);
1656
+ return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
1657
+ updatedList.concat(listScrollParents(getParentNode(target)));
1658
+ }
1659
+
1660
+ function rectToClientRect(rect) {
1661
+ return Object.assign({}, rect, {
1662
+ left: rect.x,
1663
+ top: rect.y,
1664
+ right: rect.x + rect.width,
1665
+ bottom: rect.y + rect.height
1666
+ });
1667
+ }
1668
+
1669
+ function getInnerBoundingClientRect(element, strategy) {
1670
+ var rect = getBoundingClientRect(element, false, strategy === 'fixed');
1671
+ rect.top = rect.top + element.clientTop;
1672
+ rect.left = rect.left + element.clientLeft;
1673
+ rect.bottom = rect.top + element.clientHeight;
1674
+ rect.right = rect.left + element.clientWidth;
1675
+ rect.width = element.clientWidth;
1676
+ rect.height = element.clientHeight;
1677
+ rect.x = rect.left;
1678
+ rect.y = rect.top;
1679
+ return rect;
1680
+ }
1681
+
1682
+ function getClientRectFromMixedType(element, clippingParent, strategy) {
1683
+ return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
1684
+ } // A "clipping parent" is an overflowable container with the characteristic of
1685
+ // clipping (or hiding) overflowing elements with a position different from
1686
+ // `initial`
1687
+
1688
+
1689
+ function getClippingParents(element) {
1690
+ var clippingParents = listScrollParents(getParentNode(element));
1691
+ var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0;
1692
+ var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
1693
+
1694
+ if (!isElement(clipperElement)) {
1695
+ return [];
1696
+ } // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414
1697
+
1698
+
1699
+ return clippingParents.filter(function (clippingParent) {
1700
+ return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
1701
+ });
1702
+ } // Gets the maximum area that the element is visible in due to any number of
1703
+ // clipping parents
1704
+
1705
+
1706
+ function getClippingRect(element, boundary, rootBoundary, strategy) {
1707
+ var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
1708
+ var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
1709
+ var firstClippingParent = clippingParents[0];
1710
+ var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
1711
+ var rect = getClientRectFromMixedType(element, clippingParent, strategy);
1712
+ accRect.top = max(rect.top, accRect.top);
1713
+ accRect.right = min(rect.right, accRect.right);
1714
+ accRect.bottom = min(rect.bottom, accRect.bottom);
1715
+ accRect.left = max(rect.left, accRect.left);
1716
+ return accRect;
1717
+ }, getClientRectFromMixedType(element, firstClippingParent, strategy));
1718
+ clippingRect.width = clippingRect.right - clippingRect.left;
1719
+ clippingRect.height = clippingRect.bottom - clippingRect.top;
1720
+ clippingRect.x = clippingRect.left;
1721
+ clippingRect.y = clippingRect.top;
1722
+ return clippingRect;
1723
+ }
1724
+
1725
+ function computeOffsets(_ref) {
1726
+ var reference = _ref.reference,
1727
+ element = _ref.element,
1728
+ placement = _ref.placement;
1729
+ var basePlacement = placement ? getBasePlacement(placement) : null;
1730
+ var variation = placement ? getVariation(placement) : null;
1731
+ var commonX = reference.x + reference.width / 2 - element.width / 2;
1732
+ var commonY = reference.y + reference.height / 2 - element.height / 2;
1733
+ var offsets;
1734
+
1735
+ switch (basePlacement) {
1736
+ case top:
1737
+ offsets = {
1738
+ x: commonX,
1739
+ y: reference.y - element.height
1740
+ };
1741
+ break;
1742
+
1743
+ case bottom:
1744
+ offsets = {
1745
+ x: commonX,
1746
+ y: reference.y + reference.height
1747
+ };
1748
+ break;
1749
+
1750
+ case right:
1751
+ offsets = {
1752
+ x: reference.x + reference.width,
1753
+ y: commonY
1754
+ };
1755
+ break;
1756
+
1757
+ case left:
1758
+ offsets = {
1759
+ x: reference.x - element.width,
1760
+ y: commonY
1761
+ };
1762
+ break;
1763
+
1764
+ default:
1765
+ offsets = {
1766
+ x: reference.x,
1767
+ y: reference.y
1768
+ };
1769
+ }
1770
+
1771
+ var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
1772
+
1773
+ if (mainAxis != null) {
1774
+ var len = mainAxis === 'y' ? 'height' : 'width';
1775
+
1776
+ switch (variation) {
1777
+ case start:
1778
+ offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
1779
+ break;
1780
+
1781
+ case end:
1782
+ offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
1783
+ break;
1784
+ }
1785
+ }
1786
+
1787
+ return offsets;
1788
+ }
1789
+
1790
+ function detectOverflow(state, options) {
1791
+ if (options === void 0) {
1792
+ options = {};
1793
+ }
1794
+
1795
+ var _options = options,
1796
+ _options$placement = _options.placement,
1797
+ placement = _options$placement === void 0 ? state.placement : _options$placement,
1798
+ _options$strategy = _options.strategy,
1799
+ strategy = _options$strategy === void 0 ? state.strategy : _options$strategy,
1800
+ _options$boundary = _options.boundary,
1801
+ boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
1802
+ _options$rootBoundary = _options.rootBoundary,
1803
+ rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
1804
+ _options$elementConte = _options.elementContext,
1805
+ elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
1806
+ _options$altBoundary = _options.altBoundary,
1807
+ altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
1808
+ _options$padding = _options.padding,
1809
+ padding = _options$padding === void 0 ? 0 : _options$padding;
1810
+ var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
1811
+ var altContext = elementContext === popper ? reference : popper;
1812
+ var popperRect = state.rects.popper;
1813
+ var element = state.elements[altBoundary ? altContext : elementContext];
1814
+ var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
1815
+ var referenceClientRect = getBoundingClientRect(state.elements.reference);
1816
+ var popperOffsets = computeOffsets({
1817
+ reference: referenceClientRect,
1818
+ element: popperRect,
1819
+ placement: placement
1820
+ });
1821
+ var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
1822
+ var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
1823
+ // 0 or negative = within the clipping rect
1824
+
1825
+ var overflowOffsets = {
1826
+ top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
1827
+ bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
1828
+ left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
1829
+ right: elementClientRect.right - clippingClientRect.right + paddingObject.right
1830
+ };
1831
+ var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
1832
+
1833
+ if (elementContext === popper && offsetData) {
1834
+ var offset = offsetData[placement];
1835
+ Object.keys(overflowOffsets).forEach(function (key) {
1836
+ var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
1837
+ var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
1838
+ overflowOffsets[key] += offset[axis] * multiply;
1839
+ });
1840
+ }
1841
+
1842
+ return overflowOffsets;
1843
+ }
1844
+
1845
+ function computeAutoPlacement(state, options) {
1846
+ if (options === void 0) {
1847
+ options = {};
1848
+ }
1849
+
1850
+ var _options = options,
1851
+ placement = _options.placement,
1852
+ boundary = _options.boundary,
1853
+ rootBoundary = _options.rootBoundary,
1854
+ padding = _options.padding,
1855
+ flipVariations = _options.flipVariations,
1856
+ _options$allowedAutoP = _options.allowedAutoPlacements,
1857
+ allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
1858
+ var variation = getVariation(placement);
1859
+ var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {
1860
+ return getVariation(placement) === variation;
1861
+ }) : basePlacements;
1862
+ var allowedPlacements = placements$1.filter(function (placement) {
1863
+ return allowedAutoPlacements.indexOf(placement) >= 0;
1864
+ });
1865
+
1866
+ if (allowedPlacements.length === 0) {
1867
+ allowedPlacements = placements$1;
1868
+ } // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions...
1869
+
1870
+
1871
+ var overflows = allowedPlacements.reduce(function (acc, placement) {
1872
+ acc[placement] = detectOverflow(state, {
1873
+ placement: placement,
1874
+ boundary: boundary,
1875
+ rootBoundary: rootBoundary,
1876
+ padding: padding
1877
+ })[getBasePlacement(placement)];
1878
+ return acc;
1879
+ }, {});
1880
+ return Object.keys(overflows).sort(function (a, b) {
1881
+ return overflows[a] - overflows[b];
1882
+ });
1883
+ }
1884
+
1885
+ function getExpandedFallbackPlacements(placement) {
1886
+ if (getBasePlacement(placement) === auto) {
1887
+ return [];
1888
+ }
1889
+
1890
+ var oppositePlacement = getOppositePlacement(placement);
1891
+ return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
1892
+ }
1893
+
1894
+ function flip(_ref) {
1895
+ var state = _ref.state,
1896
+ options = _ref.options,
1897
+ name = _ref.name;
1898
+
1899
+ if (state.modifiersData[name]._skip) {
1900
+ return;
1901
+ }
1902
+
1903
+ var _options$mainAxis = options.mainAxis,
1904
+ checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
1905
+ _options$altAxis = options.altAxis,
1906
+ checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis,
1907
+ specifiedFallbackPlacements = options.fallbackPlacements,
1908
+ padding = options.padding,
1909
+ boundary = options.boundary,
1910
+ rootBoundary = options.rootBoundary,
1911
+ altBoundary = options.altBoundary,
1912
+ _options$flipVariatio = options.flipVariations,
1913
+ flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio,
1914
+ allowedAutoPlacements = options.allowedAutoPlacements;
1915
+ var preferredPlacement = state.options.placement;
1916
+ var basePlacement = getBasePlacement(preferredPlacement);
1917
+ var isBasePlacement = basePlacement === preferredPlacement;
1918
+ var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
1919
+ var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) {
1920
+ return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {
1921
+ placement: placement,
1922
+ boundary: boundary,
1923
+ rootBoundary: rootBoundary,
1924
+ padding: padding,
1925
+ flipVariations: flipVariations,
1926
+ allowedAutoPlacements: allowedAutoPlacements
1927
+ }) : placement);
1928
+ }, []);
1929
+ var referenceRect = state.rects.reference;
1930
+ var popperRect = state.rects.popper;
1931
+ var checksMap = new Map();
1932
+ var makeFallbackChecks = true;
1933
+ var firstFittingPlacement = placements[0];
1934
+
1935
+ for (var i = 0; i < placements.length; i++) {
1936
+ var placement = placements[i];
1937
+
1938
+ var _basePlacement = getBasePlacement(placement);
1939
+
1940
+ var isStartVariation = getVariation(placement) === start;
1941
+ var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
1942
+ var len = isVertical ? 'width' : 'height';
1943
+ var overflow = detectOverflow(state, {
1944
+ placement: placement,
1945
+ boundary: boundary,
1946
+ rootBoundary: rootBoundary,
1947
+ altBoundary: altBoundary,
1948
+ padding: padding
1949
+ });
1950
+ var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
1951
+
1952
+ if (referenceRect[len] > popperRect[len]) {
1953
+ mainVariationSide = getOppositePlacement(mainVariationSide);
1954
+ }
1955
+
1956
+ var altVariationSide = getOppositePlacement(mainVariationSide);
1957
+ var checks = [];
1958
+
1959
+ if (checkMainAxis) {
1960
+ checks.push(overflow[_basePlacement] <= 0);
1961
+ }
1962
+
1963
+ if (checkAltAxis) {
1964
+ checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
1965
+ }
1966
+
1967
+ if (checks.every(function (check) {
1968
+ return check;
1969
+ })) {
1970
+ firstFittingPlacement = placement;
1971
+ makeFallbackChecks = false;
1972
+ break;
1973
+ }
1974
+
1975
+ checksMap.set(placement, checks);
1976
+ }
1977
+
1978
+ if (makeFallbackChecks) {
1979
+ // `2` may be desired in some cases – research later
1980
+ var numberOfChecks = flipVariations ? 3 : 1;
1981
+
1982
+ var _loop = function _loop(_i) {
1983
+ var fittingPlacement = placements.find(function (placement) {
1984
+ var checks = checksMap.get(placement);
1985
+
1986
+ if (checks) {
1987
+ return checks.slice(0, _i).every(function (check) {
1988
+ return check;
1989
+ });
1990
+ }
1991
+ });
1992
+
1993
+ if (fittingPlacement) {
1994
+ firstFittingPlacement = fittingPlacement;
1995
+ return "break";
1996
+ }
1997
+ };
1998
+
1999
+ for (var _i = numberOfChecks; _i > 0; _i--) {
2000
+ var _ret = _loop(_i);
2001
+
2002
+ if (_ret === "break") break;
2003
+ }
2004
+ }
2005
+
2006
+ if (state.placement !== firstFittingPlacement) {
2007
+ state.modifiersData[name]._skip = true;
2008
+ state.placement = firstFittingPlacement;
2009
+ state.reset = true;
2010
+ }
2011
+ } // eslint-disable-next-line import/no-unused-modules
2012
+
2013
+
2014
+ var flip$1 = {
2015
+ name: 'flip',
2016
+ enabled: true,
2017
+ phase: 'main',
2018
+ fn: flip,
2019
+ requiresIfExists: ['offset'],
2020
+ data: {
2021
+ _skip: false
2022
+ }
2023
+ };
2024
+
2025
+ function getSideOffsets(overflow, rect, preventedOffsets) {
2026
+ if (preventedOffsets === void 0) {
2027
+ preventedOffsets = {
2028
+ x: 0,
2029
+ y: 0
2030
+ };
2031
+ }
2032
+
2033
+ return {
2034
+ top: overflow.top - rect.height - preventedOffsets.y,
2035
+ right: overflow.right - rect.width + preventedOffsets.x,
2036
+ bottom: overflow.bottom - rect.height + preventedOffsets.y,
2037
+ left: overflow.left - rect.width - preventedOffsets.x
2038
+ };
2039
+ }
2040
+
2041
+ function isAnySideFullyClipped(overflow) {
2042
+ return [top, right, bottom, left].some(function (side) {
2043
+ return overflow[side] >= 0;
2044
+ });
2045
+ }
2046
+
2047
+ function hide(_ref) {
2048
+ var state = _ref.state,
2049
+ name = _ref.name;
2050
+ var referenceRect = state.rects.reference;
2051
+ var popperRect = state.rects.popper;
2052
+ var preventedOffsets = state.modifiersData.preventOverflow;
2053
+ var referenceOverflow = detectOverflow(state, {
2054
+ elementContext: 'reference'
2055
+ });
2056
+ var popperAltOverflow = detectOverflow(state, {
2057
+ altBoundary: true
2058
+ });
2059
+ var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
2060
+ var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
2061
+ var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
2062
+ var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
2063
+ state.modifiersData[name] = {
2064
+ referenceClippingOffsets: referenceClippingOffsets,
2065
+ popperEscapeOffsets: popperEscapeOffsets,
2066
+ isReferenceHidden: isReferenceHidden,
2067
+ hasPopperEscaped: hasPopperEscaped
2068
+ };
2069
+ state.attributes.popper = Object.assign({}, state.attributes.popper, {
2070
+ 'data-popper-reference-hidden': isReferenceHidden,
2071
+ 'data-popper-escaped': hasPopperEscaped
2072
+ });
2073
+ } // eslint-disable-next-line import/no-unused-modules
2074
+
2075
+
2076
+ var hide$1 = {
2077
+ name: 'hide',
2078
+ enabled: true,
2079
+ phase: 'main',
2080
+ requiresIfExists: ['preventOverflow'],
2081
+ fn: hide
2082
+ };
2083
+
2084
+ function distanceAndSkiddingToXY(placement, rects, offset) {
2085
+ var basePlacement = getBasePlacement(placement);
2086
+ var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
2087
+
2088
+ var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, {
2089
+ placement: placement
2090
+ })) : offset,
2091
+ skidding = _ref[0],
2092
+ distance = _ref[1];
2093
+
2094
+ skidding = skidding || 0;
2095
+ distance = (distance || 0) * invertDistance;
2096
+ return [left, right].indexOf(basePlacement) >= 0 ? {
2097
+ x: distance,
2098
+ y: skidding
2099
+ } : {
2100
+ x: skidding,
2101
+ y: distance
2102
+ };
2103
+ }
2104
+
2105
+ function offset(_ref2) {
2106
+ var state = _ref2.state,
2107
+ options = _ref2.options,
2108
+ name = _ref2.name;
2109
+ var _options$offset = options.offset,
2110
+ offset = _options$offset === void 0 ? [0, 0] : _options$offset;
2111
+ var data = placements.reduce(function (acc, placement) {
2112
+ acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
2113
+ return acc;
2114
+ }, {});
2115
+ var _data$state$placement = data[state.placement],
2116
+ x = _data$state$placement.x,
2117
+ y = _data$state$placement.y;
2118
+
2119
+ if (state.modifiersData.popperOffsets != null) {
2120
+ state.modifiersData.popperOffsets.x += x;
2121
+ state.modifiersData.popperOffsets.y += y;
2122
+ }
2123
+
2124
+ state.modifiersData[name] = data;
2125
+ } // eslint-disable-next-line import/no-unused-modules
2126
+
2127
+
2128
+ var offset$1 = {
2129
+ name: 'offset',
2130
+ enabled: true,
2131
+ phase: 'main',
2132
+ requires: ['popperOffsets'],
2133
+ fn: offset
2134
+ };
2135
+
2136
+ function popperOffsets(_ref) {
2137
+ var state = _ref.state,
2138
+ name = _ref.name;
2139
+ // Offsets are the actual position the popper needs to have to be
2140
+ // properly positioned near its reference element
2141
+ // This is the most basic placement, and will be adjusted by
2142
+ // the modifiers in the next step
2143
+ state.modifiersData[name] = computeOffsets({
2144
+ reference: state.rects.reference,
2145
+ element: state.rects.popper,
2146
+ placement: state.placement
2147
+ });
2148
+ } // eslint-disable-next-line import/no-unused-modules
2149
+
2150
+
2151
+ var popperOffsets$1 = {
2152
+ name: 'popperOffsets',
2153
+ enabled: true,
2154
+ phase: 'read',
2155
+ fn: popperOffsets,
2156
+ data: {}
2157
+ };
2158
+
2159
+ function getAltAxis(axis) {
2160
+ return axis === 'x' ? 'y' : 'x';
2161
+ }
2162
+
2163
+ function preventOverflow(_ref) {
2164
+ var state = _ref.state,
2165
+ options = _ref.options,
2166
+ name = _ref.name;
2167
+ var _options$mainAxis = options.mainAxis,
2168
+ checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
2169
+ _options$altAxis = options.altAxis,
2170
+ checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,
2171
+ boundary = options.boundary,
2172
+ rootBoundary = options.rootBoundary,
2173
+ altBoundary = options.altBoundary,
2174
+ padding = options.padding,
2175
+ _options$tether = options.tether,
2176
+ tether = _options$tether === void 0 ? true : _options$tether,
2177
+ _options$tetherOffset = options.tetherOffset,
2178
+ tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
2179
+ var overflow = detectOverflow(state, {
2180
+ boundary: boundary,
2181
+ rootBoundary: rootBoundary,
2182
+ padding: padding,
2183
+ altBoundary: altBoundary
2184
+ });
2185
+ var basePlacement = getBasePlacement(state.placement);
2186
+ var variation = getVariation(state.placement);
2187
+ var isBasePlacement = !variation;
2188
+ var mainAxis = getMainAxisFromPlacement(basePlacement);
2189
+ var altAxis = getAltAxis(mainAxis);
2190
+ var popperOffsets = state.modifiersData.popperOffsets;
2191
+ var referenceRect = state.rects.reference;
2192
+ var popperRect = state.rects.popper;
2193
+ var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
2194
+ placement: state.placement
2195
+ })) : tetherOffset;
2196
+ var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
2197
+ mainAxis: tetherOffsetValue,
2198
+ altAxis: tetherOffsetValue
2199
+ } : Object.assign({
2200
+ mainAxis: 0,
2201
+ altAxis: 0
2202
+ }, tetherOffsetValue);
2203
+ var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
2204
+ var data = {
2205
+ x: 0,
2206
+ y: 0
2207
+ };
2208
+
2209
+ if (!popperOffsets) {
2210
+ return;
2211
+ }
2212
+
2213
+ if (checkMainAxis) {
2214
+ var _offsetModifierState$;
2215
+
2216
+ var mainSide = mainAxis === 'y' ? top : left;
2217
+ var altSide = mainAxis === 'y' ? bottom : right;
2218
+ var len = mainAxis === 'y' ? 'height' : 'width';
2219
+ var offset = popperOffsets[mainAxis];
2220
+ var min$1 = offset + overflow[mainSide];
2221
+ var max$1 = offset - overflow[altSide];
2222
+ var additive = tether ? -popperRect[len] / 2 : 0;
2223
+ var minLen = variation === start ? referenceRect[len] : popperRect[len];
2224
+ var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
2225
+ // outside the reference bounds
2226
+
2227
+ var arrowElement = state.elements.arrow;
2228
+ var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
2229
+ width: 0,
2230
+ height: 0
2231
+ };
2232
+ var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();
2233
+ var arrowPaddingMin = arrowPaddingObject[mainSide];
2234
+ var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want
2235
+ // to include its full size in the calculation. If the reference is small
2236
+ // and near the edge of a boundary, the popper can overflow even if the
2237
+ // reference is not overflowing as well (e.g. virtual elements with no
2238
+ // width or height)
2239
+
2240
+ var arrowLen = within(0, referenceRect[len], arrowRect[len]);
2241
+ var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
2242
+ var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
2243
+ var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
2244
+ var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
2245
+ var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
2246
+ var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
2247
+ var tetherMax = offset + maxOffset - offsetModifierValue;
2248
+ var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
2249
+ popperOffsets[mainAxis] = preventedOffset;
2250
+ data[mainAxis] = preventedOffset - offset;
2251
+ }
2252
+
2253
+ if (checkAltAxis) {
2254
+ var _offsetModifierState$2;
2255
+
2256
+ var _mainSide = mainAxis === 'x' ? top : left;
2257
+
2258
+ var _altSide = mainAxis === 'x' ? bottom : right;
2259
+
2260
+ var _offset = popperOffsets[altAxis];
2261
+
2262
+ var _len = altAxis === 'y' ? 'height' : 'width';
2263
+
2264
+ var _min = _offset + overflow[_mainSide];
2265
+
2266
+ var _max = _offset - overflow[_altSide];
2267
+
2268
+ var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
2269
+
2270
+ var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
2271
+
2272
+ var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
2273
+
2274
+ var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
2275
+
2276
+ var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
2277
+
2278
+ popperOffsets[altAxis] = _preventedOffset;
2279
+ data[altAxis] = _preventedOffset - _offset;
2280
+ }
2281
+
2282
+ state.modifiersData[name] = data;
2283
+ } // eslint-disable-next-line import/no-unused-modules
2284
+
2285
+
2286
+ var preventOverflow$1 = {
2287
+ name: 'preventOverflow',
2288
+ enabled: true,
2289
+ phase: 'main',
2290
+ fn: preventOverflow,
2291
+ requiresIfExists: ['offset']
2292
+ };
2293
+
2294
+ function getHTMLElementScroll(element) {
2295
+ return {
2296
+ scrollLeft: element.scrollLeft,
2297
+ scrollTop: element.scrollTop
2298
+ };
2299
+ }
2300
+
2301
+ function getNodeScroll(node) {
2302
+ if (node === getWindow(node) || !isHTMLElement(node)) {
2303
+ return getWindowScroll(node);
2304
+ } else {
2305
+ return getHTMLElementScroll(node);
2306
+ }
2307
+ }
2308
+
2309
+ function isElementScaled(element) {
2310
+ var rect = element.getBoundingClientRect();
2311
+ var scaleX = round(rect.width) / element.offsetWidth || 1;
2312
+ var scaleY = round(rect.height) / element.offsetHeight || 1;
2313
+ return scaleX !== 1 || scaleY !== 1;
2314
+ } // Returns the composite rect of an element relative to its offsetParent.
2315
+ // Composite means it takes into account transforms as well as layout.
2316
+
2317
+
2318
+ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
2319
+ if (isFixed === void 0) {
2320
+ isFixed = false;
2321
+ }
2322
+
2323
+ var isOffsetParentAnElement = isHTMLElement(offsetParent);
2324
+ var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
2325
+ var documentElement = getDocumentElement(offsetParent);
2326
+ var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
2327
+ var scroll = {
2328
+ scrollLeft: 0,
2329
+ scrollTop: 0
2330
+ };
2331
+ var offsets = {
2332
+ x: 0,
2333
+ y: 0
2334
+ };
2335
+
2336
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
2337
+ if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
2338
+ isScrollParent(documentElement)) {
2339
+ scroll = getNodeScroll(offsetParent);
2340
+ }
2341
+
2342
+ if (isHTMLElement(offsetParent)) {
2343
+ offsets = getBoundingClientRect(offsetParent, true);
2344
+ offsets.x += offsetParent.clientLeft;
2345
+ offsets.y += offsetParent.clientTop;
2346
+ } else if (documentElement) {
2347
+ offsets.x = getWindowScrollBarX(documentElement);
2348
+ }
2349
+ }
2350
+
2351
+ return {
2352
+ x: rect.left + scroll.scrollLeft - offsets.x,
2353
+ y: rect.top + scroll.scrollTop - offsets.y,
2354
+ width: rect.width,
2355
+ height: rect.height
2356
+ };
2357
+ }
2358
+
2359
+ function order(modifiers) {
2360
+ var map = new Map();
2361
+ var visited = new Set();
2362
+ var result = [];
2363
+ modifiers.forEach(function (modifier) {
2364
+ map.set(modifier.name, modifier);
2365
+ }); // On visiting object, check for its dependencies and visit them recursively
2366
+
2367
+ function sort(modifier) {
2368
+ visited.add(modifier.name);
2369
+ var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
2370
+ requires.forEach(function (dep) {
2371
+ if (!visited.has(dep)) {
2372
+ var depModifier = map.get(dep);
2373
+
2374
+ if (depModifier) {
2375
+ sort(depModifier);
2376
+ }
2377
+ }
2378
+ });
2379
+ result.push(modifier);
2380
+ }
2381
+
2382
+ modifiers.forEach(function (modifier) {
2383
+ if (!visited.has(modifier.name)) {
2384
+ // check for visited object
2385
+ sort(modifier);
2386
+ }
2387
+ });
2388
+ return result;
2389
+ }
2390
+
2391
+ function orderModifiers(modifiers) {
2392
+ // order based on dependencies
2393
+ var orderedModifiers = order(modifiers); // order based on phase
2394
+
2395
+ return modifierPhases.reduce(function (acc, phase) {
2396
+ return acc.concat(orderedModifiers.filter(function (modifier) {
2397
+ return modifier.phase === phase;
2398
+ }));
2399
+ }, []);
2400
+ }
2401
+
2402
+ function debounce(fn) {
2403
+ var pending;
2404
+ return function () {
2405
+ if (!pending) {
2406
+ pending = new Promise(function (resolve) {
2407
+ Promise.resolve().then(function () {
2408
+ pending = undefined;
2409
+ resolve(fn());
2410
+ });
2411
+ });
2412
+ }
2413
+
2414
+ return pending;
2415
+ };
2416
+ }
2417
+
2418
+ function mergeByName(modifiers) {
2419
+ var merged = modifiers.reduce(function (merged, current) {
2420
+ var existing = merged[current.name];
2421
+ merged[current.name] = existing ? Object.assign({}, existing, current, {
2422
+ options: Object.assign({}, existing.options, current.options),
2423
+ data: Object.assign({}, existing.data, current.data)
2424
+ }) : current;
2425
+ return merged;
2426
+ }, {}); // IE11 does not support Object.values
2427
+
2428
+ return Object.keys(merged).map(function (key) {
2429
+ return merged[key];
2430
+ });
2431
+ }
2432
+
2433
+ var DEFAULT_OPTIONS = {
2434
+ placement: 'bottom',
2435
+ modifiers: [],
2436
+ strategy: 'absolute'
2437
+ };
2438
+
2439
+ function areValidElements() {
2440
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2441
+ args[_key] = arguments[_key];
2442
+ }
2443
+
2444
+ return !args.some(function (element) {
2445
+ return !(element && typeof element.getBoundingClientRect === 'function');
2446
+ });
2447
+ }
2448
+
2449
+ function popperGenerator(generatorOptions) {
2450
+ if (generatorOptions === void 0) {
2451
+ generatorOptions = {};
2452
+ }
2453
+
2454
+ var _generatorOptions = generatorOptions,
2455
+ _generatorOptions$def = _generatorOptions.defaultModifiers,
2456
+ defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
2457
+ _generatorOptions$def2 = _generatorOptions.defaultOptions,
2458
+ defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
2459
+ return function createPopper(reference, popper, options) {
2460
+ if (options === void 0) {
2461
+ options = defaultOptions;
2462
+ }
2463
+
2464
+ var state = {
2465
+ placement: 'bottom',
2466
+ orderedModifiers: [],
2467
+ options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
2468
+ modifiersData: {},
2469
+ elements: {
2470
+ reference: reference,
2471
+ popper: popper
2472
+ },
2473
+ attributes: {},
2474
+ styles: {}
2475
+ };
2476
+ var effectCleanupFns = [];
2477
+ var isDestroyed = false;
2478
+ var instance = {
2479
+ state: state,
2480
+ setOptions: function setOptions(setOptionsAction) {
2481
+ var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
2482
+ cleanupModifierEffects();
2483
+ state.options = Object.assign({}, defaultOptions, state.options, options);
2484
+ state.scrollParents = {
2485
+ reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
2486
+ popper: listScrollParents(popper)
2487
+ }; // Orders the modifiers based on their dependencies and `phase`
2488
+ // properties
2489
+
2490
+ var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers
2491
+
2492
+ state.orderedModifiers = orderedModifiers.filter(function (m) {
2493
+ return m.enabled;
2494
+ });
2495
+ runModifierEffects();
2496
+ return instance.update();
2497
+ },
2498
+ // Sync update – it will always be executed, even if not necessary. This
2499
+ // is useful for low frequency updates where sync behavior simplifies the
2500
+ // logic.
2501
+ // For high frequency updates (e.g. `resize` and `scroll` events), always
2502
+ // prefer the async Popper#update method
2503
+ forceUpdate: function forceUpdate() {
2504
+ if (isDestroyed) {
2505
+ return;
2506
+ }
2507
+
2508
+ var _state$elements = state.elements,
2509
+ reference = _state$elements.reference,
2510
+ popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements
2511
+ // anymore
2512
+
2513
+ if (!areValidElements(reference, popper)) {
2514
+ return;
2515
+ } // Store the reference and popper rects to be read by modifiers
2516
+
2517
+
2518
+ state.rects = {
2519
+ reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
2520
+ popper: getLayoutRect(popper)
2521
+ }; // Modifiers have the ability to reset the current update cycle. The
2522
+ // most common use case for this is the `flip` modifier changing the
2523
+ // placement, which then needs to re-run all the modifiers, because the
2524
+ // logic was previously ran for the previous placement and is therefore
2525
+ // stale/incorrect
2526
+
2527
+ state.reset = false;
2528
+ state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier
2529
+ // is filled with the initial data specified by the modifier. This means
2530
+ // it doesn't persist and is fresh on each update.
2531
+ // To ensure persistent data, use `${name}#persistent`
2532
+
2533
+ state.orderedModifiers.forEach(function (modifier) {
2534
+ return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
2535
+ });
2536
+
2537
+ for (var index = 0; index < state.orderedModifiers.length; index++) {
2538
+ if (state.reset === true) {
2539
+ state.reset = false;
2540
+ index = -1;
2541
+ continue;
2542
+ }
2543
+
2544
+ var _state$orderedModifie = state.orderedModifiers[index],
2545
+ fn = _state$orderedModifie.fn,
2546
+ _state$orderedModifie2 = _state$orderedModifie.options,
2547
+ _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
2548
+ name = _state$orderedModifie.name;
2549
+
2550
+ if (typeof fn === 'function') {
2551
+ state = fn({
2552
+ state: state,
2553
+ options: _options,
2554
+ name: name,
2555
+ instance: instance
2556
+ }) || state;
2557
+ }
2558
+ }
2559
+ },
2560
+ // Async and optimistically optimized update – it will not be executed if
2561
+ // not necessary (debounced to run at most once-per-tick)
2562
+ update: debounce(function () {
2563
+ return new Promise(function (resolve) {
2564
+ instance.forceUpdate();
2565
+ resolve(state);
2566
+ });
2567
+ }),
2568
+ destroy: function destroy() {
2569
+ cleanupModifierEffects();
2570
+ isDestroyed = true;
2571
+ }
2572
+ };
2573
+
2574
+ if (!areValidElements(reference, popper)) {
2575
+ return instance;
2576
+ }
2577
+
2578
+ instance.setOptions(options).then(function (state) {
2579
+ if (!isDestroyed && options.onFirstUpdate) {
2580
+ options.onFirstUpdate(state);
2581
+ }
2582
+ }); // Modifiers have the ability to execute arbitrary code before the first
2583
+ // update cycle runs. They will be executed in the same order as the update
2584
+ // cycle. This is useful when a modifier adds some persistent data that
2585
+ // other modifiers need to use, but the modifier is run after the dependent
2586
+ // one.
2587
+
2588
+ function runModifierEffects() {
2589
+ state.orderedModifiers.forEach(function (_ref) {
2590
+ var name = _ref.name,
2591
+ _ref$options = _ref.options,
2592
+ options = _ref$options === void 0 ? {} : _ref$options,
2593
+ effect = _ref.effect;
2594
+
2595
+ if (typeof effect === 'function') {
2596
+ var cleanupFn = effect({
2597
+ state: state,
2598
+ name: name,
2599
+ instance: instance,
2600
+ options: options
2601
+ });
2602
+
2603
+ var noopFn = function noopFn() {};
2604
+
2605
+ effectCleanupFns.push(cleanupFn || noopFn);
2606
+ }
2607
+ });
2608
+ }
2609
+
2610
+ function cleanupModifierEffects() {
2611
+ effectCleanupFns.forEach(function (fn) {
2612
+ return fn();
2613
+ });
2614
+ effectCleanupFns = [];
2615
+ }
2616
+
2617
+ return instance;
2618
+ };
2619
+ }
2620
+
2621
+ var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
2622
+ var createPopper = /*#__PURE__*/popperGenerator({
2623
+ defaultModifiers: defaultModifiers
2624
+ }); // eslint-disable-next-line import/no-unused-modules
2625
+
2626
+ const tabworthyDatesModalCss = () => `:host::part(body){position:absolute;top:0;left:0;width:-moz-fit-content;width:fit-content;z-index:1200}:host::part(backdrop){}:host::part(content){}`;
838
2627
 
839
2628
  const InclusiveDatesModal = class {
840
2629
  constructor(hostRef) {
@@ -842,14 +2631,132 @@ const InclusiveDatesModal = class {
842
2631
  this.opened = createEvent(this, "opened", 7);
843
2632
  this.closed = createEvent(this, "closed", 7);
844
2633
  this.inline = false;
2634
+ /** Preferred placement of the dropdown (Popper.js placement) */
2635
+ this.placement = "bottom-start";
2636
+ /** Offset from the trigger element [skidding, distance] */
2637
+ this.offset = [0, 8];
845
2638
  this.closing = false;
846
2639
  this.showing = this.inline || false;
2640
+ this.positioned = false;
2641
+ this.originalParent = null;
2642
+ this.originalNextSibling = null;
2643
+ this.isMovingPortal = false;
2644
+ this.popperInstance = null;
847
2645
  this.onKeyDown = (event) => {
848
2646
  if (event.code === "Escape") {
849
2647
  this.close();
850
2648
  }
851
2649
  };
852
2650
  }
2651
+ watchShowing(newValue) {
2652
+ if (newValue) {
2653
+ // Reset positioned state - portal setup happens in render ref callback
2654
+ this.positioned = false;
2655
+ }
2656
+ else {
2657
+ this.destroyPopperInstance();
2658
+ this.cleanupPortal();
2659
+ this.positioned = false;
2660
+ }
2661
+ }
2662
+ getAppendToElement() {
2663
+ if (!this.appendTo)
2664
+ return null;
2665
+ if (this.appendTo === "body") {
2666
+ return document.body;
2667
+ }
2668
+ if (typeof this.appendTo === "string") {
2669
+ return document.querySelector(this.appendTo);
2670
+ }
2671
+ return this.appendTo;
2672
+ }
2673
+ setupPortal() {
2674
+ const appendToEl = this.getAppendToElement();
2675
+ if (!appendToEl)
2676
+ return;
2677
+ // Store original position so we can restore later
2678
+ this.originalParent = this.hostElement.parentElement;
2679
+ this.originalNextSibling = this.hostElement.nextSibling;
2680
+ // Guard against triggering disconnectedCallback during move
2681
+ this.isMovingPortal = true;
2682
+ appendToEl.appendChild(this.hostElement);
2683
+ this.isMovingPortal = false;
2684
+ }
2685
+ cleanupPortal() {
2686
+ // Guard against recursion - moving element triggers disconnectedCallback
2687
+ if (this.isMovingPortal)
2688
+ return;
2689
+ // Move host back to original position
2690
+ if (this.originalParent) {
2691
+ this.isMovingPortal = true;
2692
+ if (this.originalNextSibling) {
2693
+ this.originalParent.insertBefore(this.hostElement, this.originalNextSibling);
2694
+ }
2695
+ else {
2696
+ this.originalParent.appendChild(this.hostElement);
2697
+ }
2698
+ this.originalParent = null;
2699
+ this.originalNextSibling = null;
2700
+ this.isMovingPortal = false;
2701
+ }
2702
+ }
2703
+ createPopperInstance() {
2704
+ if (!this.triggerElement || !this.bodyRef)
2705
+ return;
2706
+ // Use fixed strategy when portaling to escape scroll containers
2707
+ const useFixed = !!this.appendTo;
2708
+ // When portaled, use viewport boundary; otherwise use clipping parents
2709
+ const boundary = useFixed ? "viewport" : "clippingParents";
2710
+ this.popperInstance = createPopper(this.triggerElement, this.bodyRef, {
2711
+ placement: this.placement,
2712
+ strategy: useFixed ? "fixed" : "absolute",
2713
+ modifiers: [
2714
+ {
2715
+ name: "offset",
2716
+ options: {
2717
+ offset: this.offset
2718
+ }
2719
+ },
2720
+ {
2721
+ name: "flip",
2722
+ options: {
2723
+ fallbackPlacements: ["top-start", "top-end", "bottom-end"],
2724
+ boundary
2725
+ }
2726
+ },
2727
+ {
2728
+ name: "preventOverflow",
2729
+ options: {
2730
+ boundary,
2731
+ altAxis: true,
2732
+ padding: 8
2733
+ }
2734
+ },
2735
+ {
2736
+ name: "computeStyles",
2737
+ options: {
2738
+ // Use GPU acceleration for smooth animations
2739
+ gpuAcceleration: true
2740
+ }
2741
+ },
2742
+ {
2743
+ // Custom modifier to ensure initial position is applied immediately
2744
+ name: "applyStyles",
2745
+ enabled: true
2746
+ }
2747
+ ]
2748
+ });
2749
+ // Force immediate position update
2750
+ this.popperInstance.forceUpdate();
2751
+ // Mark as positioned to show the element
2752
+ this.positioned = true;
2753
+ }
2754
+ destroyPopperInstance() {
2755
+ if (this.popperInstance) {
2756
+ this.popperInstance.destroy();
2757
+ this.popperInstance = null;
2758
+ }
2759
+ }
853
2760
  /**
854
2761
  * Open the dialog.
855
2762
  */
@@ -864,28 +2771,73 @@ const InclusiveDatesModal = class {
864
2771
  * Close the dialog.
865
2772
  */
866
2773
  async close() {
2774
+ var _a;
867
2775
  if (this.inline)
868
2776
  return;
869
2777
  this.showing = false;
870
2778
  this.closed.emit(undefined);
871
- this.undo();
2779
+ (_a = this.undo) === null || _a === void 0 ? void 0 : _a.call(this);
872
2780
  if (this.triggerElement)
873
2781
  this.triggerElement.focus();
874
2782
  }
2783
+ disconnectedCallback() {
2784
+ // Skip cleanup if we're in the middle of portal operations
2785
+ if (this.isMovingPortal)
2786
+ return;
2787
+ this.destroyPopperInstance();
2788
+ this.cleanupPortal();
2789
+ }
875
2790
  async getState() {
876
2791
  return this.showing;
877
2792
  }
878
2793
  async setTriggerElement(element) {
879
2794
  this.triggerElement = element;
880
2795
  }
2796
+ /** Force update the popper position */
2797
+ async updatePosition() {
2798
+ var _a;
2799
+ await ((_a = this.popperInstance) === null || _a === void 0 ? void 0 : _a.update());
2800
+ }
881
2801
  handleClick(event) {
882
- if (this.showing && !this.el.contains(event.target)) {
883
- this.close();
2802
+ var _a;
2803
+ if (this.showing) {
2804
+ const target = event.target;
2805
+ // Check if click is inside the host element, trigger element, or original parent (when portaled)
2806
+ const clickedInside = this.hostElement.contains(target) ||
2807
+ ((_a = this.triggerElement) === null || _a === void 0 ? void 0 : _a.contains(target)) ||
2808
+ // When portaled, also check the original parent to avoid closing on container clicks
2809
+ (this.originalParent && this.originalParent.contains(target));
2810
+ if (!clickedInside) {
2811
+ this.close();
2812
+ }
884
2813
  }
885
2814
  }
886
2815
  render() {
887
- return (h(Host, { key: 'e5e440df97f5b2f51f742892ca591aff3a3e51a9', showing: this.showing, ref: (r) => r && (this.el = r) }, !this.inline && this.showing && (h("div", { key: 'f3b5f92b0f3b8eb54f665a14fcaa1616d59b182b', part: "body", onKeyDown: this.onKeyDown, role: "dialog", tabindex: -1, "aria-hidden": !this.showing, "aria-label": this.label, "aria-modal": this.showing }, h("focus-trap", { key: 'f94c02a8db391d671adc08ac1742dc6fabca72d3' }, h("div", { key: '888259505b6a2416674523d6a6924272b676daad', part: "content" }, h("slot", { key: 'e4e141ecae238f68fdde53baca66f478ebb93f88' }))))), this.inline && (h("div", { key: 'f2e7fb2614274d5dc7d03f10a0ee760363438435', part: "content" }, h("slot", { key: 'f845ef9c46b146ac916c90bb2fcec1f357aee5ee' })))));
2816
+ return (h(Host, { key: '35e8ed14b0108e9cb75782516d070dfb8474b0b2', showing: this.showing, ref: (r) => r && (this.el = r) }, !this.inline && this.showing && (h("div", { key: 'fdb64ed8717e2a1620ef2d4ffb21a44d1de03a46', part: "body", ref: (r) => {
2817
+ if (r) {
2818
+ this.bodyRef = r;
2819
+ // Setup portal and create popper when ref is set
2820
+ if (this.showing &&
2821
+ this.triggerElement &&
2822
+ !this.popperInstance) {
2823
+ // Setup portal first (move element to body), then create popper
2824
+ this.setupPortal();
2825
+ // Use double RAF to ensure DOM is fully settled after portal move
2826
+ requestAnimationFrame(() => {
2827
+ requestAnimationFrame(() => {
2828
+ this.createPopperInstance();
2829
+ });
2830
+ });
2831
+ }
2832
+ }
2833
+ }, style: { visibility: this.positioned ? "visible" : "hidden" }, onKeyDown: this.onKeyDown, role: "dialog", tabindex: -1, "aria-hidden": !this.showing, "aria-label": this.label, "aria-modal": this.showing }, h("focus-trap", { key: 'af4734b1a18dd62a600ca49313b1ba07f2d19039' }, h("div", { key: 'fb41d5ce07b5aac179e4bed63c18a8d254503a50', part: "content" }, h("slot", { key: 'fc480cf1a29a42b1a19737a72d410c139dc32f07' }))))), this.inline && (h("div", { key: '7aef10d50f790a1e72e05b26dc108c40500fa7c3', part: "content" }, h("slot", { key: '06395cd19052d1b81ab448c0a9a618da876fa86d' })))));
888
2834
  }
2835
+ get hostElement() { return getElement(this); }
2836
+ static get watchers() { return {
2837
+ "showing": [{
2838
+ "watchShowing": 0
2839
+ }]
2840
+ }; }
889
2841
  };
890
2842
  InclusiveDatesModal.style = tabworthyDatesModalCss();
891
2843