@vonage/vivid 3.0.0 → 3.0.1

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 (323) hide show
  1. package/README.md +176 -4
  2. package/accordion/index.js +22 -61
  3. package/accordion-item/index.js +16 -118
  4. package/action-group/index.js +5 -0
  5. package/avatar/index.js +11 -0
  6. package/badge/index.js +9 -53
  7. package/banner/index.js +20 -210
  8. package/breadcrumb/index.js +7 -96
  9. package/breadcrumb-item/index.js +15 -46
  10. package/button/index.js +19 -751
  11. package/calendar/index.js +5 -1520
  12. package/calendar-event/index.js +9 -0
  13. package/card/index.js +10 -133
  14. package/checkbox/index.js +16 -0
  15. package/combobox/index.js +35 -0
  16. package/dialog/index.js +24 -0
  17. package/divider/index.js +6 -0
  18. package/elevation/index.js +4 -30
  19. package/fab/index.js +22 -0
  20. package/focus/index.js +4 -2
  21. package/header/index.js +6 -0
  22. package/icon/index.js +8 -36
  23. package/index.js +76 -26
  24. package/layout/index.js +4 -52
  25. package/lib/accordion/accordion.d.ts +3 -7
  26. package/lib/accordion/accordion.template.d.ts +1 -2
  27. package/lib/accordion/definition.d.ts +1 -0
  28. package/lib/accordion/index.d.ts +1 -2
  29. package/lib/accordion-item/accordion-item.d.ts +2 -6
  30. package/lib/accordion-item/accordion-item.template.d.ts +4 -4
  31. package/lib/accordion-item/definition.d.ts +1 -0
  32. package/lib/accordion-item/index.d.ts +1 -3
  33. package/lib/action-group/action-group.d.ts +10 -0
  34. package/lib/{sidenav-item/sidenav-item.template.d.ts → action-group/action-group.template.d.ts} +2 -2
  35. package/lib/action-group/definition.d.ts +1 -0
  36. package/lib/action-group/index.d.ts +1 -0
  37. package/lib/avatar/avatar.d.ts +15 -0
  38. package/lib/avatar/avatar.template.d.ts +4 -0
  39. package/lib/avatar/definition.d.ts +1 -0
  40. package/lib/avatar/index.d.ts +1 -0
  41. package/lib/badge/badge.d.ts +2 -4
  42. package/lib/badge/definition.d.ts +3 -0
  43. package/lib/badge/index.d.ts +1 -3
  44. package/lib/banner/banner.d.ts +1 -1
  45. package/lib/banner/banner.template.d.ts +0 -2
  46. package/lib/banner/definition.d.ts +1 -0
  47. package/lib/banner/index.d.ts +1 -2
  48. package/lib/breadcrumb/breadcrumb.template.d.ts +4 -0
  49. package/lib/breadcrumb/definition.d.ts +1 -0
  50. package/lib/breadcrumb/index.d.ts +1 -2
  51. package/lib/breadcrumb-item/definition.d.ts +1 -0
  52. package/lib/breadcrumb-item/index.d.ts +1 -3
  53. package/lib/button/button.d.ts +3 -2
  54. package/lib/button/definition.d.ts +1 -0
  55. package/lib/button/index.d.ts +1 -21
  56. package/lib/calendar/calendar.d.ts +3 -1
  57. package/lib/calendar/definition.d.ts +1 -0
  58. package/lib/calendar/index.d.ts +1 -3
  59. package/lib/calendar-event/calendar-event.d.ts +14 -0
  60. package/lib/calendar-event/calendar-event.template.d.ts +4 -0
  61. package/lib/calendar-event/definition.d.ts +1 -0
  62. package/lib/calendar-event/index.d.ts +1 -0
  63. package/lib/card/card.d.ts +2 -2
  64. package/lib/card/definition.d.ts +1 -0
  65. package/lib/card/index.d.ts +1 -5
  66. package/lib/checkbox/checkbox.d.ts +5 -0
  67. package/lib/checkbox/checkbox.template.d.ts +4 -0
  68. package/lib/checkbox/definition.d.ts +1 -0
  69. package/lib/checkbox/index.d.ts +1 -0
  70. package/lib/combobox/combobox.d.ts +14 -0
  71. package/lib/combobox/combobox.template.d.ts +4 -0
  72. package/lib/combobox/definition.d.ts +3 -0
  73. package/lib/combobox/index.d.ts +1 -0
  74. package/lib/components.d.ts +44 -16
  75. package/lib/dialog/definition.d.ts +1 -0
  76. package/lib/dialog/dialog.d.ts +23 -0
  77. package/lib/dialog/dialog.template.d.ts +4 -0
  78. package/lib/dialog/index.d.ts +1 -0
  79. package/lib/divider/definition.d.ts +1 -0
  80. package/lib/divider/divider.d.ts +3 -0
  81. package/lib/divider/divider.template.d.ts +4 -0
  82. package/lib/divider/index.d.ts +1 -0
  83. package/lib/elevation/definition.d.ts +1 -0
  84. package/lib/elevation/elevation.d.ts +1 -0
  85. package/lib/elevation/index.d.ts +1 -2
  86. package/lib/enums.d.ts +19 -6
  87. package/lib/fab/definition.d.ts +3 -0
  88. package/lib/fab/fab.d.ts +13 -0
  89. package/lib/fab/fab.template.d.ts +4 -0
  90. package/lib/fab/index.d.ts +1 -0
  91. package/lib/focus/definition.d.ts +3 -0
  92. package/lib/focus/index.d.ts +1 -2
  93. package/lib/{sidenav-item/index.d.ts → header/definition.d.ts} +2 -2
  94. package/lib/header/header.d.ts +5 -0
  95. package/lib/header/header.template.d.ts +4 -0
  96. package/lib/header/index.d.ts +1 -0
  97. package/lib/icon/definition.d.ts +3 -0
  98. package/lib/icon/icon.d.ts +5 -6
  99. package/lib/icon/index.d.ts +1 -2
  100. package/lib/layout/definition.d.ts +3 -0
  101. package/lib/layout/index.d.ts +1 -2
  102. package/lib/layout/layout.d.ts +4 -4
  103. package/lib/listbox/definition.d.ts +3 -0
  104. package/lib/listbox/index.d.ts +1 -0
  105. package/lib/listbox/listbox.d.ts +6 -0
  106. package/lib/listbox/listbox.template.d.ts +4 -0
  107. package/lib/menu/definition.d.ts +11 -0
  108. package/lib/menu/index.d.ts +1 -0
  109. package/lib/menu/menu.d.ts +10 -0
  110. package/lib/menu/menu.template.d.ts +3 -0
  111. package/lib/menu-item/definition.d.ts +3 -0
  112. package/lib/menu-item/index.d.ts +1 -0
  113. package/lib/menu-item/menu-item.d.ts +8 -0
  114. package/lib/menu-item/menu-item.template.d.ts +5 -0
  115. package/lib/nav/definition.d.ts +3 -0
  116. package/lib/nav/index.d.ts +1 -0
  117. package/lib/nav/nav.d.ts +3 -0
  118. package/lib/nav/nav.template.d.ts +4 -0
  119. package/lib/nav-disclosure/definition.d.ts +3 -0
  120. package/lib/nav-disclosure/index.d.ts +1 -0
  121. package/lib/nav-disclosure/nav-disclosure.d.ts +10 -0
  122. package/lib/nav-disclosure/nav-disclosure.template.d.ts +4 -0
  123. package/lib/nav-item/definition.d.ts +3 -0
  124. package/lib/nav-item/index.d.ts +1 -0
  125. package/lib/{sidenav-item/sidenav-item.d.ts → nav-item/nav-item.d.ts} +2 -2
  126. package/lib/nav-item/nav-item.template.d.ts +4 -0
  127. package/lib/note/definition.d.ts +3 -0
  128. package/lib/note/index.d.ts +1 -0
  129. package/lib/note/note.d.ts +10 -0
  130. package/lib/{text/text.template.d.ts → note/note.template.d.ts} +2 -2
  131. package/lib/number-field/definition.d.ts +4 -0
  132. package/lib/number-field/index.d.ts +1 -0
  133. package/lib/number-field/number-field.d.ts +14 -0
  134. package/lib/number-field/number-field.template.d.ts +4 -0
  135. package/lib/option/definition.d.ts +3 -0
  136. package/lib/option/index.d.ts +1 -0
  137. package/lib/option/option.d.ts +9 -0
  138. package/lib/option/option.template.d.ts +4 -0
  139. package/lib/popup/definition.d.ts +4 -0
  140. package/lib/popup/index.d.ts +1 -4
  141. package/lib/popup/popup.d.ts +8 -4
  142. package/lib/progress/definition.d.ts +3 -0
  143. package/lib/progress/index.d.ts +1 -2
  144. package/lib/progress/progress.d.ts +1 -1
  145. package/lib/progress-ring/definition.d.ts +3 -0
  146. package/lib/progress-ring/index.d.ts +1 -2
  147. package/lib/progress-ring/progress-ring.d.ts +2 -1
  148. package/lib/radio/definition.d.ts +3 -0
  149. package/lib/radio/index.d.ts +1 -0
  150. package/lib/radio/radio.d.ts +4 -0
  151. package/lib/radio/radio.template.d.ts +4 -0
  152. package/lib/radio-group/definition.d.ts +11 -0
  153. package/lib/radio-group/index.d.ts +1 -0
  154. package/lib/radio-group/radio-group.d.ts +4 -0
  155. package/lib/radio-group/radio-group.template.d.ts +4 -0
  156. package/lib/select/definition.d.ts +3 -0
  157. package/lib/select/index.d.ts +1 -0
  158. package/lib/select/select.d.ts +17 -0
  159. package/lib/select/select.template.d.ts +4 -0
  160. package/lib/side-drawer/definition.d.ts +3 -0
  161. package/lib/side-drawer/index.d.ts +1 -2
  162. package/lib/side-drawer/side-drawer.d.ts +3 -2
  163. package/lib/slider/definition.d.ts +3 -0
  164. package/lib/slider/index.d.ts +1 -0
  165. package/lib/slider/slider.d.ts +4 -0
  166. package/lib/slider/slider.template.d.ts +4 -0
  167. package/lib/switch/definition.d.ts +3 -0
  168. package/lib/switch/index.d.ts +1 -0
  169. package/lib/switch/switch.d.ts +7 -0
  170. package/lib/switch/switch.template.d.ts +4 -0
  171. package/lib/tab/definition.d.ts +3 -0
  172. package/lib/tab/index.d.ts +1 -0
  173. package/lib/tab/tab.d.ts +9 -0
  174. package/lib/tab/tab.template.d.ts +3 -0
  175. package/lib/tab-panel/definition.d.ts +3 -0
  176. package/lib/tab-panel/index.d.ts +1 -0
  177. package/lib/tab-panel/tab-panel.d.ts +3 -0
  178. package/lib/tab-panel/tab-panel.template.d.ts +2 -0
  179. package/lib/tabs/definition.d.ts +3 -0
  180. package/lib/tabs/index.d.ts +1 -0
  181. package/lib/tabs/tabs.d.ts +10 -0
  182. package/lib/tabs/tabs.template.d.ts +2 -0
  183. package/lib/text-anchor/definition.d.ts +3 -0
  184. package/lib/text-anchor/index.d.ts +1 -2
  185. package/lib/text-area/definition.d.ts +3 -0
  186. package/lib/text-area/index.d.ts +1 -0
  187. package/lib/text-area/text-area.d.ts +9 -0
  188. package/lib/text-area/text-area.template.d.ts +4 -0
  189. package/lib/text-field/definition.d.ts +3 -0
  190. package/lib/text-field/index.d.ts +1 -0
  191. package/lib/text-field/text-field.d.ts +14 -0
  192. package/lib/text-field/text-field.template.d.ts +4 -0
  193. package/lib/tooltip/definition.d.ts +3 -0
  194. package/lib/tooltip/index.d.ts +1 -3
  195. package/lib/tooltip/tooltip.d.ts +6 -6
  196. package/listbox/index.js +27 -0
  197. package/menu/index.js +30 -0
  198. package/menu-item/index.js +20 -0
  199. package/nav/index.js +4 -0
  200. package/nav-disclosure/index.js +17 -0
  201. package/nav-item/index.js +22 -0
  202. package/note/index.js +15 -0
  203. package/number-field/index.js +459 -0
  204. package/option/index.js +21 -0
  205. package/package.json +29 -18
  206. package/popup/index.js +21 -2062
  207. package/progress/index.js +6 -98
  208. package/progress-ring/index.js +6 -75
  209. package/radio/index.js +12 -0
  210. package/radio-group/index.js +11 -0
  211. package/select/index.js +34 -0
  212. package/shared/affix.js +2 -8
  213. package/shared/anchor.js +10 -2
  214. package/shared/apply-mixins.js +5 -4
  215. package/shared/aria-global.js +2 -86
  216. package/shared/aria.js +9 -0
  217. package/shared/base-progress.js +5 -0
  218. package/shared/breadcrumb-item.js +1 -1
  219. package/shared/button.js +200 -0
  220. package/shared/calendar-event.js +19 -0
  221. package/shared/definition.js +225 -0
  222. package/shared/definition10.js +99 -0
  223. package/shared/definition11.js +48 -0
  224. package/shared/definition12.js +1523 -0
  225. package/shared/definition13.js +111 -0
  226. package/shared/definition14.js +114 -0
  227. package/shared/definition15.js +32 -0
  228. package/shared/definition16.js +172 -0
  229. package/shared/definition17.js +727 -0
  230. package/shared/definition18.js +1842 -0
  231. package/shared/definition19.js +261 -0
  232. package/shared/definition2.js +150 -0
  233. package/shared/definition20.js +221 -0
  234. package/shared/definition21.js +78 -0
  235. package/shared/definition22.js +87 -0
  236. package/shared/definition23.js +58 -0
  237. package/shared/definition24.js +44 -0
  238. package/shared/definition25.js +58 -0
  239. package/shared/definition26.js +348 -0
  240. package/shared/definition27.js +363 -0
  241. package/shared/definition28.js +21 -0
  242. package/shared/definition29.js +75 -0
  243. package/shared/definition3.js +29 -0
  244. package/shared/definition30.js +31 -0
  245. package/shared/definition31.js +49 -0
  246. package/shared/definition32.js +94 -0
  247. package/shared/definition33.js +77 -0
  248. package/shared/definition34.js +45 -0
  249. package/shared/definition35.js +435 -0
  250. package/shared/definition36.js +634 -0
  251. package/shared/definition37.js +86 -0
  252. package/shared/definition38.js +592 -0
  253. package/shared/definition39.js +147 -0
  254. package/shared/definition4.js +19 -0
  255. package/shared/definition40.js +67 -0
  256. package/shared/definition41.js +32 -0
  257. package/shared/definition42.js +440 -0
  258. package/shared/definition43.js +282 -0
  259. package/shared/definition44.js +119 -0
  260. package/shared/definition45.js +77 -0
  261. package/shared/definition5.js +38 -0
  262. package/shared/definition6.js +60 -0
  263. package/shared/definition7.js +45 -0
  264. package/shared/definition8.js +113 -0
  265. package/shared/definition9.js +107 -0
  266. package/shared/design-system/index.d.ts +1 -1
  267. package/shared/dialog-polyfill.esm.js +858 -0
  268. package/shared/direction.js +20 -0
  269. package/shared/dom.js +8 -0
  270. package/shared/enums.js +70 -0
  271. package/shared/es.object.assign.js +2 -3
  272. package/shared/es.regexp.to-string.js +59 -0
  273. package/shared/focus.js +5 -0
  274. package/shared/focus2.js +11 -0
  275. package/shared/form-associated.js +466 -0
  276. package/shared/form-elements.js +127 -0
  277. package/shared/icon.js +538 -567
  278. package/shared/index.js +1664 -83
  279. package/shared/key-codes.js +97 -0
  280. package/shared/listbox.js +995 -0
  281. package/shared/numbers.js +34 -0
  282. package/shared/patterns/affix.d.ts +1 -1
  283. package/shared/patterns/focus.d.ts +3 -0
  284. package/shared/patterns/form-elements/form-elements.d.ts +43 -0
  285. package/shared/patterns/form-elements/index.d.ts +1 -0
  286. package/shared/patterns/index.d.ts +2 -0
  287. package/shared/radio.js +127 -0
  288. package/shared/ref.js +41 -0
  289. package/shared/select.options.js +10 -0
  290. package/shared/start-end.js +50 -0
  291. package/shared/string-trim.js +40 -0
  292. package/shared/strings.js +9 -0
  293. package/shared/text-anchor.js +0 -2
  294. package/shared/text-anchor.template.js +6 -5
  295. package/shared/text-field.js +3 -0
  296. package/shared/text-field2.js +225 -0
  297. package/shared/to-string.js +51 -0
  298. package/side-drawer/index.js +5 -81
  299. package/slider/index.js +17 -0
  300. package/styles/core/all.css +83 -0
  301. package/styles/core/theme.css +11 -0
  302. package/styles/core/typography.css +77 -0
  303. package/styles/tokens/theme-dark.css +228 -0
  304. package/styles/tokens/theme-light.css +228 -0
  305. package/switch/index.js +18 -0
  306. package/tab/index.js +16 -0
  307. package/tab-panel/index.js +4 -0
  308. package/tabs/index.js +24 -0
  309. package/text-anchor/index.js +11 -6
  310. package/text-area/index.js +23 -0
  311. package/text-field/index.js +24 -0
  312. package/tooltip/index.js +18 -55
  313. package/lib/text/index.d.ts +0 -2
  314. package/lib/text/text.d.ts +0 -10
  315. package/shared/index2.js +0 -21
  316. package/shared/object-set-prototype-of.js +0 -1009
  317. package/shared/style-inject.es.js +0 -28
  318. package/shared/web.dom-collections.iterator.js +0 -473
  319. package/sidenav-item/index.js +0 -39
  320. package/styles/fonts/spezia.css +0 -23
  321. package/styles/themes/dark.css +0 -205
  322. package/styles/themes/light.css +0 -205
  323. package/text/index.js +0 -46
@@ -0,0 +1,1842 @@
1
+ import { F as FoundationElement, U as __classPrivateFieldGet, a5 as __classPrivateFieldSet, _ as __decorate, a as attr, b as __metadata, h as html, r as registerFactory } from './index.js';
2
+ import { B as Button, b as buttonRegistries } from './definition9.js';
3
+ import { E as Elevation, e as elevationRegistries } from './definition15.js';
4
+ import './icon.js';
5
+ import './es.object.assign.js';
6
+ import { w as when } from './when.js';
7
+ import { r as ref } from './ref.js';
8
+ import { c as classNames } from './class-names.js';
9
+
10
+ function getSide(placement) {
11
+ return placement.split('-')[0];
12
+ }
13
+
14
+ function getAlignment(placement) {
15
+ return placement.split('-')[1];
16
+ }
17
+
18
+ function getMainAxisFromPlacement(placement) {
19
+ return ['top', 'bottom'].includes(getSide(placement)) ? 'x' : 'y';
20
+ }
21
+
22
+ function getLengthFromAxis(axis) {
23
+ return axis === 'y' ? 'height' : 'width';
24
+ }
25
+
26
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
27
+ let {
28
+ reference,
29
+ floating
30
+ } = _ref;
31
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
32
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
33
+ const mainAxis = getMainAxisFromPlacement(placement);
34
+ const length = getLengthFromAxis(mainAxis);
35
+ const commonAlign = reference[length] / 2 - floating[length] / 2;
36
+ const side = getSide(placement);
37
+ const isVertical = mainAxis === 'x';
38
+ let coords;
39
+
40
+ switch (side) {
41
+ case 'top':
42
+ coords = {
43
+ x: commonX,
44
+ y: reference.y - floating.height
45
+ };
46
+ break;
47
+
48
+ case 'bottom':
49
+ coords = {
50
+ x: commonX,
51
+ y: reference.y + reference.height
52
+ };
53
+ break;
54
+
55
+ case 'right':
56
+ coords = {
57
+ x: reference.x + reference.width,
58
+ y: commonY
59
+ };
60
+ break;
61
+
62
+ case 'left':
63
+ coords = {
64
+ x: reference.x - floating.width,
65
+ y: commonY
66
+ };
67
+ break;
68
+
69
+ default:
70
+ coords = {
71
+ x: reference.x,
72
+ y: reference.y
73
+ };
74
+ }
75
+
76
+ switch (getAlignment(placement)) {
77
+ case 'start':
78
+ coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
79
+ break;
80
+
81
+ case 'end':
82
+ coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
83
+ break;
84
+ }
85
+
86
+ return coords;
87
+ }
88
+
89
+ /**
90
+ * Computes the `x` and `y` coordinates that will place the floating element
91
+ * next to a reference element when it is given a certain positioning strategy.
92
+ *
93
+ * This export does not have any `platform` interface logic. You will need to
94
+ * write one for the platform you are using Floating UI with.
95
+ */
96
+
97
+ const computePosition$1 = async (reference, floating, config) => {
98
+ const {
99
+ placement = 'bottom',
100
+ strategy = 'absolute',
101
+ middleware = [],
102
+ platform
103
+ } = config;
104
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
105
+
106
+ let rects = await platform.getElementRects({
107
+ reference,
108
+ floating,
109
+ strategy
110
+ });
111
+ let {
112
+ x,
113
+ y
114
+ } = computeCoordsFromPlacement(rects, placement, rtl);
115
+ let statefulPlacement = placement;
116
+ let middlewareData = {};
117
+ let resetCount = 0;
118
+
119
+ for (let i = 0; i < middleware.length; i++) {
120
+ const {
121
+ name,
122
+ fn
123
+ } = middleware[i];
124
+ const {
125
+ x: nextX,
126
+ y: nextY,
127
+ data,
128
+ reset
129
+ } = await fn({
130
+ x,
131
+ y,
132
+ initialPlacement: placement,
133
+ placement: statefulPlacement,
134
+ strategy,
135
+ middlewareData,
136
+ rects,
137
+ platform,
138
+ elements: {
139
+ reference,
140
+ floating
141
+ }
142
+ });
143
+ x = nextX != null ? nextX : x;
144
+ y = nextY != null ? nextY : y;
145
+ middlewareData = { ...middlewareData,
146
+ [name]: { ...middlewareData[name],
147
+ ...data
148
+ }
149
+ };
150
+
151
+ if (reset && resetCount <= 50) {
152
+ resetCount++;
153
+
154
+ if (typeof reset === 'object') {
155
+ if (reset.placement) {
156
+ statefulPlacement = reset.placement;
157
+ }
158
+
159
+ if (reset.rects) {
160
+ rects = reset.rects === true ? await platform.getElementRects({
161
+ reference,
162
+ floating,
163
+ strategy
164
+ }) : reset.rects;
165
+ }
166
+
167
+ ({
168
+ x,
169
+ y
170
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
171
+ }
172
+
173
+ i = -1;
174
+ continue;
175
+ }
176
+ }
177
+
178
+ return {
179
+ x,
180
+ y,
181
+ placement: statefulPlacement,
182
+ strategy,
183
+ middlewareData
184
+ };
185
+ };
186
+
187
+ function expandPaddingObject(padding) {
188
+ return {
189
+ top: 0,
190
+ right: 0,
191
+ bottom: 0,
192
+ left: 0,
193
+ ...padding
194
+ };
195
+ }
196
+
197
+ function getSideObjectFromPadding(padding) {
198
+ return typeof padding !== 'number' ? expandPaddingObject(padding) : {
199
+ top: padding,
200
+ right: padding,
201
+ bottom: padding,
202
+ left: padding
203
+ };
204
+ }
205
+
206
+ function rectToClientRect(rect) {
207
+ return { ...rect,
208
+ top: rect.y,
209
+ left: rect.x,
210
+ right: rect.x + rect.width,
211
+ bottom: rect.y + rect.height
212
+ };
213
+ }
214
+
215
+ /**
216
+ * Resolves with an object of overflow side offsets that determine how much the
217
+ * element is overflowing a given clipping boundary.
218
+ * - positive = overflowing the boundary by that number of pixels
219
+ * - negative = how many pixels left before it will overflow
220
+ * - 0 = lies flush with the boundary
221
+ * @see https://floating-ui.com/docs/detectOverflow
222
+ */
223
+ async function detectOverflow(middlewareArguments, options) {
224
+ var _await$platform$isEle;
225
+
226
+ if (options === void 0) {
227
+ options = {};
228
+ }
229
+
230
+ const {
231
+ x,
232
+ y,
233
+ platform,
234
+ rects,
235
+ elements,
236
+ strategy
237
+ } = middlewareArguments;
238
+ const {
239
+ boundary = 'clippingAncestors',
240
+ rootBoundary = 'viewport',
241
+ elementContext = 'floating',
242
+ altBoundary = false,
243
+ padding = 0
244
+ } = options;
245
+ const paddingObject = getSideObjectFromPadding(padding);
246
+ const altContext = elementContext === 'floating' ? 'reference' : 'floating';
247
+ const element = elements[altBoundary ? altContext : elementContext];
248
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
249
+ 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))),
250
+ boundary,
251
+ rootBoundary,
252
+ strategy
253
+ }));
254
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
255
+ rect: elementContext === 'floating' ? { ...rects.floating,
256
+ x,
257
+ y
258
+ } : rects.reference,
259
+ offsetParent: await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating)),
260
+ strategy
261
+ }) : rects[elementContext]);
262
+ return {
263
+ top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
264
+ bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
265
+ left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
266
+ right: elementClientRect.right - clippingClientRect.right + paddingObject.right
267
+ };
268
+ }
269
+
270
+ const min$1 = Math.min;
271
+ const max$1 = Math.max;
272
+
273
+ function within(min$1$1, value, max$1$1) {
274
+ return max$1(min$1$1, min$1(value, max$1$1));
275
+ }
276
+
277
+ /**
278
+ * Positions an inner element of the floating element such that it is centered
279
+ * to the reference element.
280
+ * @see https://floating-ui.com/docs/arrow
281
+ */
282
+ const arrow = options => ({
283
+ name: 'arrow',
284
+ options,
285
+
286
+ async fn(middlewareArguments) {
287
+ // Since `element` is required, we don't Partial<> the type
288
+ const {
289
+ element,
290
+ padding = 0
291
+ } = options != null ? options : {};
292
+ const {
293
+ x,
294
+ y,
295
+ placement,
296
+ rects,
297
+ platform
298
+ } = middlewareArguments;
299
+
300
+ if (element == null) {
301
+
302
+ return {};
303
+ }
304
+
305
+ const paddingObject = getSideObjectFromPadding(padding);
306
+ const coords = {
307
+ x,
308
+ y
309
+ };
310
+ const axis = getMainAxisFromPlacement(placement);
311
+ const alignment = getAlignment(placement);
312
+ const length = getLengthFromAxis(axis);
313
+ const arrowDimensions = await platform.getDimensions(element);
314
+ const minProp = axis === 'y' ? 'top' : 'left';
315
+ const maxProp = axis === 'y' ? 'bottom' : 'right';
316
+ const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
317
+ const startDiff = coords[axis] - rects.reference[axis];
318
+ const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
319
+ let clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
320
+
321
+ if (clientSize === 0) {
322
+ clientSize = rects.floating[length];
323
+ }
324
+
325
+ const centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the floating element if the center
326
+ // point is outside the floating element's bounds
327
+
328
+ const min = paddingObject[minProp];
329
+ const max = clientSize - arrowDimensions[length] - paddingObject[maxProp];
330
+ const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
331
+ const offset = within(min, center, max); // Make sure that arrow points at the reference
332
+
333
+ const alignmentPadding = alignment === 'start' ? paddingObject[minProp] : paddingObject[maxProp];
334
+ const shouldAddOffset = alignmentPadding > 0 && center !== offset && rects.reference[length] <= rects.floating[length];
335
+ const alignmentOffset = shouldAddOffset ? center < min ? min - center : max - center : 0;
336
+ return {
337
+ [axis]: coords[axis] - alignmentOffset,
338
+ data: {
339
+ [axis]: offset,
340
+ centerOffset: center - offset
341
+ }
342
+ };
343
+ }
344
+
345
+ });
346
+
347
+ const hash$1 = {
348
+ left: 'right',
349
+ right: 'left',
350
+ bottom: 'top',
351
+ top: 'bottom'
352
+ };
353
+ function getOppositePlacement(placement) {
354
+ return placement.replace(/left|right|bottom|top/g, matched => hash$1[matched]);
355
+ }
356
+
357
+ function getAlignmentSides(placement, rects, rtl) {
358
+ if (rtl === void 0) {
359
+ rtl = false;
360
+ }
361
+
362
+ const alignment = getAlignment(placement);
363
+ const mainAxis = getMainAxisFromPlacement(placement);
364
+ const length = getLengthFromAxis(mainAxis);
365
+ let mainAlignmentSide = mainAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
366
+
367
+ if (rects.reference[length] > rects.floating[length]) {
368
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
369
+ }
370
+
371
+ return {
372
+ main: mainAlignmentSide,
373
+ cross: getOppositePlacement(mainAlignmentSide)
374
+ };
375
+ }
376
+
377
+ const hash = {
378
+ start: 'end',
379
+ end: 'start'
380
+ };
381
+ function getOppositeAlignmentPlacement(placement) {
382
+ return placement.replace(/start|end/g, matched => hash[matched]);
383
+ }
384
+
385
+ const sides = ['top', 'right', 'bottom', 'left'];
386
+
387
+ function getExpandedPlacements(placement) {
388
+ const oppositePlacement = getOppositePlacement(placement);
389
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
390
+ }
391
+
392
+ /**
393
+ * Changes the placement of the floating element to one that will fit if the
394
+ * initially specified `placement` does not.
395
+ * @see https://floating-ui.com/docs/flip
396
+ */
397
+ const flip = function (options) {
398
+ if (options === void 0) {
399
+ options = {};
400
+ }
401
+
402
+ return {
403
+ name: 'flip',
404
+ options,
405
+
406
+ async fn(middlewareArguments) {
407
+ var _middlewareData$flip;
408
+
409
+ const {
410
+ placement,
411
+ middlewareData,
412
+ rects,
413
+ initialPlacement,
414
+ platform,
415
+ elements
416
+ } = middlewareArguments;
417
+ const {
418
+ mainAxis: checkMainAxis = true,
419
+ crossAxis: checkCrossAxis = true,
420
+ fallbackPlacements: specifiedFallbackPlacements,
421
+ fallbackStrategy = 'bestFit',
422
+ flipAlignment = true,
423
+ ...detectOverflowOptions
424
+ } = options;
425
+ const side = getSide(placement);
426
+ const isBasePlacement = side === initialPlacement;
427
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
428
+ const placements = [initialPlacement, ...fallbackPlacements];
429
+ const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
430
+ const overflows = [];
431
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
432
+
433
+ if (checkMainAxis) {
434
+ overflows.push(overflow[side]);
435
+ }
436
+
437
+ if (checkCrossAxis) {
438
+ const {
439
+ main,
440
+ cross
441
+ } = getAlignmentSides(placement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
442
+ overflows.push(overflow[main], overflow[cross]);
443
+ }
444
+
445
+ overflowsData = [...overflowsData, {
446
+ placement,
447
+ overflows
448
+ }]; // One or more sides is overflowing
449
+
450
+ if (!overflows.every(side => side <= 0)) {
451
+ var _middlewareData$flip$, _middlewareData$flip2;
452
+
453
+ const nextIndex = ((_middlewareData$flip$ = (_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) != null ? _middlewareData$flip$ : 0) + 1;
454
+ const nextPlacement = placements[nextIndex];
455
+
456
+ if (nextPlacement) {
457
+ // Try next placement and re-run the lifecycle
458
+ return {
459
+ data: {
460
+ index: nextIndex,
461
+ overflows: overflowsData
462
+ },
463
+ reset: {
464
+ placement: nextPlacement
465
+ }
466
+ };
467
+ }
468
+
469
+ let resetPlacement = 'bottom';
470
+
471
+ switch (fallbackStrategy) {
472
+ case 'bestFit':
473
+ {
474
+ var _overflowsData$map$so;
475
+
476
+ 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;
477
+
478
+ if (placement) {
479
+ resetPlacement = placement;
480
+ }
481
+
482
+ break;
483
+ }
484
+
485
+ case 'initialPlacement':
486
+ resetPlacement = initialPlacement;
487
+ break;
488
+ }
489
+
490
+ if (placement !== resetPlacement) {
491
+ return {
492
+ reset: {
493
+ placement: resetPlacement
494
+ }
495
+ };
496
+ }
497
+ }
498
+
499
+ return {};
500
+ }
501
+
502
+ };
503
+ };
504
+
505
+ function getSideOffsets(overflow, rect) {
506
+ return {
507
+ top: overflow.top - rect.height,
508
+ right: overflow.right - rect.width,
509
+ bottom: overflow.bottom - rect.height,
510
+ left: overflow.left - rect.width
511
+ };
512
+ }
513
+
514
+ function isAnySideFullyClipped(overflow) {
515
+ return sides.some(side => overflow[side] >= 0);
516
+ }
517
+
518
+ /**
519
+ * Provides data to hide the floating element in applicable situations, such as
520
+ * when it is not in the same clipping context as the reference element.
521
+ * @see https://floating-ui.com/docs/hide
522
+ */
523
+ const hide = function (_temp) {
524
+ let {
525
+ strategy = 'referenceHidden',
526
+ ...detectOverflowOptions
527
+ } = _temp === void 0 ? {} : _temp;
528
+ return {
529
+ name: 'hide',
530
+
531
+ async fn(middlewareArguments) {
532
+ const {
533
+ rects
534
+ } = middlewareArguments;
535
+
536
+ switch (strategy) {
537
+ case 'referenceHidden':
538
+ {
539
+ const overflow = await detectOverflow(middlewareArguments, { ...detectOverflowOptions,
540
+ elementContext: 'reference'
541
+ });
542
+ const offsets = getSideOffsets(overflow, rects.reference);
543
+ return {
544
+ data: {
545
+ referenceHiddenOffsets: offsets,
546
+ referenceHidden: isAnySideFullyClipped(offsets)
547
+ }
548
+ };
549
+ }
550
+
551
+ case 'escaped':
552
+ {
553
+ const overflow = await detectOverflow(middlewareArguments, { ...detectOverflowOptions,
554
+ altBoundary: true
555
+ });
556
+ const offsets = getSideOffsets(overflow, rects.floating);
557
+ return {
558
+ data: {
559
+ escapedOffsets: offsets,
560
+ escaped: isAnySideFullyClipped(offsets)
561
+ }
562
+ };
563
+ }
564
+
565
+ default:
566
+ {
567
+ return {};
568
+ }
569
+ }
570
+ }
571
+
572
+ };
573
+ };
574
+
575
+ async function convertValueToCoords(middlewareArguments, value) {
576
+ const {
577
+ placement,
578
+ platform,
579
+ elements
580
+ } = middlewareArguments;
581
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
582
+ const side = getSide(placement);
583
+ const alignment = getAlignment(placement);
584
+ const isVertical = getMainAxisFromPlacement(placement) === 'x';
585
+ const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
586
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
587
+ const rawValue = typeof value === 'function' ? value(middlewareArguments) : value; // eslint-disable-next-line prefer-const
588
+
589
+ let {
590
+ mainAxis,
591
+ crossAxis,
592
+ alignmentAxis
593
+ } = typeof rawValue === 'number' ? {
594
+ mainAxis: rawValue,
595
+ crossAxis: 0,
596
+ alignmentAxis: null
597
+ } : {
598
+ mainAxis: 0,
599
+ crossAxis: 0,
600
+ alignmentAxis: null,
601
+ ...rawValue
602
+ };
603
+
604
+ if (alignment && typeof alignmentAxis === 'number') {
605
+ crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
606
+ }
607
+
608
+ return isVertical ? {
609
+ x: crossAxis * crossAxisMulti,
610
+ y: mainAxis * mainAxisMulti
611
+ } : {
612
+ x: mainAxis * mainAxisMulti,
613
+ y: crossAxis * crossAxisMulti
614
+ };
615
+ }
616
+ /**
617
+ * Displaces the floating element from its reference element.
618
+ * @see https://floating-ui.com/docs/offset
619
+ */
620
+
621
+ const offset = function (value) {
622
+ if (value === void 0) {
623
+ value = 0;
624
+ }
625
+
626
+ return {
627
+ name: 'offset',
628
+ options: value,
629
+
630
+ async fn(middlewareArguments) {
631
+ const {
632
+ x,
633
+ y
634
+ } = middlewareArguments;
635
+ const diffCoords = await convertValueToCoords(middlewareArguments, value);
636
+ return {
637
+ x: x + diffCoords.x,
638
+ y: y + diffCoords.y,
639
+ data: diffCoords
640
+ };
641
+ }
642
+
643
+ };
644
+ };
645
+
646
+ /**
647
+ * Provides improved positioning for inline reference elements that can span
648
+ * over multiple lines, such as hyperlinks or range selections.
649
+ * @see https://floating-ui.com/docs/inline
650
+ */
651
+ const inline = function (options) {
652
+ if (options === void 0) {
653
+ options = {};
654
+ }
655
+
656
+ return {
657
+ name: 'inline',
658
+ options,
659
+
660
+ async fn(middlewareArguments) {
661
+ var _await$platform$getCl;
662
+
663
+ const {
664
+ placement,
665
+ elements,
666
+ rects,
667
+ platform,
668
+ strategy
669
+ } = middlewareArguments; // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
670
+ // ClientRect's bounds, despite the event listener being triggered. A
671
+ // padding of 2 seems to handle this issue.
672
+
673
+ const {
674
+ padding = 2,
675
+ x,
676
+ y
677
+ } = options;
678
+ const fallback = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
679
+ rect: rects.reference,
680
+ offsetParent: await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating)),
681
+ strategy
682
+ }) : rects.reference);
683
+ const clientRects = (_await$platform$getCl = await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) != null ? _await$platform$getCl : [];
684
+ const paddingObject = getSideObjectFromPadding(padding);
685
+
686
+ function getBoundingClientRect() {
687
+ // There are two rects and they are disjoined
688
+ if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
689
+ var _clientRects$find;
690
+
691
+ // Find the first rect in which the point is fully inside
692
+ 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;
693
+ } // There are 2 or more connected rects
694
+
695
+
696
+ if (clientRects.length >= 2) {
697
+ if (getMainAxisFromPlacement(placement) === 'x') {
698
+ const firstRect = clientRects[0];
699
+ const lastRect = clientRects[clientRects.length - 1];
700
+ const isTop = getSide(placement) === 'top';
701
+ const top = firstRect.top;
702
+ const bottom = lastRect.bottom;
703
+ const left = isTop ? firstRect.left : lastRect.left;
704
+ const right = isTop ? firstRect.right : lastRect.right;
705
+ const width = right - left;
706
+ const height = bottom - top;
707
+ return {
708
+ top,
709
+ bottom,
710
+ left,
711
+ right,
712
+ width,
713
+ height,
714
+ x: left,
715
+ y: top
716
+ };
717
+ }
718
+
719
+ const isLeftSide = getSide(placement) === 'left';
720
+ const maxRight = max$1(...clientRects.map(rect => rect.right));
721
+ const minLeft = min$1(...clientRects.map(rect => rect.left));
722
+ const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
723
+ const top = measureRects[0].top;
724
+ const bottom = measureRects[measureRects.length - 1].bottom;
725
+ const left = minLeft;
726
+ const right = maxRight;
727
+ const width = right - left;
728
+ const height = bottom - top;
729
+ return {
730
+ top,
731
+ bottom,
732
+ left,
733
+ right,
734
+ width,
735
+ height,
736
+ x: left,
737
+ y: top
738
+ };
739
+ }
740
+
741
+ return fallback;
742
+ }
743
+
744
+ const resetRects = await platform.getElementRects({
745
+ reference: {
746
+ getBoundingClientRect
747
+ },
748
+ floating: elements.floating,
749
+ strategy
750
+ });
751
+
752
+ 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) {
753
+ return {
754
+ reset: {
755
+ rects: resetRects
756
+ }
757
+ };
758
+ }
759
+
760
+ return {};
761
+ }
762
+
763
+ };
764
+ };
765
+
766
+ function isWindow(value) {
767
+ return value && value.document && value.location && value.alert && value.setInterval;
768
+ }
769
+ function getWindow(node) {
770
+ if (node == null) {
771
+ return window;
772
+ }
773
+
774
+ if (!isWindow(node)) {
775
+ const ownerDocument = node.ownerDocument;
776
+ return ownerDocument ? ownerDocument.defaultView || window : window;
777
+ }
778
+
779
+ return node;
780
+ }
781
+
782
+ function getComputedStyle$1(element) {
783
+ return getWindow(element).getComputedStyle(element);
784
+ }
785
+
786
+ function getNodeName(node) {
787
+ return isWindow(node) ? '' : node ? (node.nodeName || '').toLowerCase() : '';
788
+ }
789
+
790
+ function getUAString() {
791
+ const uaData = navigator.userAgentData;
792
+
793
+ if (uaData != null && uaData.brands) {
794
+ return uaData.brands.map(item => item.brand + "/" + item.version).join(' ');
795
+ }
796
+
797
+ return navigator.userAgent;
798
+ }
799
+
800
+ function isHTMLElement(value) {
801
+ return value instanceof getWindow(value).HTMLElement;
802
+ }
803
+ function isElement(value) {
804
+ return value instanceof getWindow(value).Element;
805
+ }
806
+ function isNode(value) {
807
+ return value instanceof getWindow(value).Node;
808
+ }
809
+ function isShadowRoot(node) {
810
+ // Browsers without `ShadowRoot` support
811
+ if (typeof ShadowRoot === 'undefined') {
812
+ return false;
813
+ }
814
+
815
+ const OwnElement = getWindow(node).ShadowRoot;
816
+ return node instanceof OwnElement || node instanceof ShadowRoot;
817
+ }
818
+ function isOverflowElement(element) {
819
+ // Firefox wants us to check `-x` and `-y` variations as well
820
+ const {
821
+ overflow,
822
+ overflowX,
823
+ overflowY
824
+ } = getComputedStyle$1(element);
825
+ return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
826
+ }
827
+ function isTableElement(element) {
828
+ return ['table', 'td', 'th'].includes(getNodeName(element));
829
+ }
830
+ function isContainingBlock(element) {
831
+ // TODO: Try and use feature detection here instead
832
+ const isFirefox = /firefox/i.test(getUAString());
833
+ const css = getComputedStyle$1(element); // This is non-exhaustive but covers the most common CSS properties that
834
+ // create a containing block.
835
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
836
+
837
+ return css.transform !== 'none' || css.perspective !== 'none' || // @ts-ignore (TS 4.1 compat)
838
+ css.contain === 'paint' || ['transform', 'perspective'].includes(css.willChange) || isFirefox && css.willChange === 'filter' || isFirefox && (css.filter ? css.filter !== 'none' : false);
839
+ }
840
+ function isLayoutViewport() {
841
+ // Not Safari
842
+ return !/^((?!chrome|android).)*safari/i.test(getUAString()); // Feature detection for this fails in various ways
843
+ // • Always-visible scrollbar or not
844
+ // • Width of <html>, etc.
845
+ // const vV = win.visualViewport;
846
+ // return vV ? Math.abs(win.innerWidth / vV.scale - vV.width) < 0.5 : true;
847
+ }
848
+
849
+ const min = Math.min;
850
+ const max = Math.max;
851
+ const round = Math.round;
852
+
853
+ function getBoundingClientRect(element, includeScale, isFixedStrategy) {
854
+ var _win$visualViewport$o, _win$visualViewport, _win$visualViewport$o2, _win$visualViewport2;
855
+
856
+ if (includeScale === void 0) {
857
+ includeScale = false;
858
+ }
859
+
860
+ if (isFixedStrategy === void 0) {
861
+ isFixedStrategy = false;
862
+ }
863
+
864
+ const clientRect = element.getBoundingClientRect();
865
+ let scaleX = 1;
866
+ let scaleY = 1;
867
+
868
+ if (includeScale && isHTMLElement(element)) {
869
+ scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
870
+ scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
871
+ }
872
+
873
+ const win = isElement(element) ? getWindow(element) : window;
874
+ const addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
875
+ 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;
876
+ 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;
877
+ const width = clientRect.width / scaleX;
878
+ const height = clientRect.height / scaleY;
879
+ return {
880
+ width,
881
+ height,
882
+ top: y,
883
+ right: x + width,
884
+ bottom: y + height,
885
+ left: x,
886
+ x,
887
+ y
888
+ };
889
+ }
890
+
891
+ function getDocumentElement(node) {
892
+ return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
893
+ }
894
+
895
+ function getNodeScroll(element) {
896
+ if (isElement(element)) {
897
+ return {
898
+ scrollLeft: element.scrollLeft,
899
+ scrollTop: element.scrollTop
900
+ };
901
+ }
902
+
903
+ return {
904
+ scrollLeft: element.pageXOffset,
905
+ scrollTop: element.pageYOffset
906
+ };
907
+ }
908
+
909
+ function getWindowScrollBarX(element) {
910
+ // If <html> has a CSS width greater than the viewport, then this will be
911
+ // incorrect for RTL.
912
+ return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
913
+ }
914
+
915
+ function isScaled(element) {
916
+ const rect = getBoundingClientRect(element);
917
+ return round(rect.width) !== element.offsetWidth || round(rect.height) !== element.offsetHeight;
918
+ }
919
+
920
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
921
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
922
+ const documentElement = getDocumentElement(offsetParent);
923
+ const rect = getBoundingClientRect(element, // @ts-ignore - checked above (TS 4.1 compat)
924
+ isOffsetParentAnElement && isScaled(offsetParent), strategy === 'fixed');
925
+ let scroll = {
926
+ scrollLeft: 0,
927
+ scrollTop: 0
928
+ };
929
+ const offsets = {
930
+ x: 0,
931
+ y: 0
932
+ };
933
+
934
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
935
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
936
+ scroll = getNodeScroll(offsetParent);
937
+ }
938
+
939
+ if (isHTMLElement(offsetParent)) {
940
+ const offsetRect = getBoundingClientRect(offsetParent, true);
941
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
942
+ offsets.y = offsetRect.y + offsetParent.clientTop;
943
+ } else if (documentElement) {
944
+ offsets.x = getWindowScrollBarX(documentElement);
945
+ }
946
+ }
947
+
948
+ return {
949
+ x: rect.left + scroll.scrollLeft - offsets.x,
950
+ y: rect.top + scroll.scrollTop - offsets.y,
951
+ width: rect.width,
952
+ height: rect.height
953
+ };
954
+ }
955
+
956
+ function getParentNode(node) {
957
+ if (getNodeName(node) === 'html') {
958
+ return node;
959
+ }
960
+
961
+ return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
962
+ // @ts-ignore
963
+ node.assignedSlot || // step into the shadow DOM of the parent of a slotted node
964
+ node.parentNode || ( // DOM Element detected
965
+ isShadowRoot(node) ? node.host : null) || // ShadowRoot detected
966
+ getDocumentElement(node) // fallback
967
+
968
+ );
969
+ }
970
+
971
+ function getTrueOffsetParent(element) {
972
+ if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
973
+ return null;
974
+ }
975
+
976
+ return element.offsetParent;
977
+ }
978
+
979
+ function getContainingBlock(element) {
980
+ let currentNode = getParentNode(element);
981
+
982
+ if (isShadowRoot(currentNode)) {
983
+ currentNode = currentNode.host;
984
+ }
985
+
986
+ while (isHTMLElement(currentNode) && !['html', 'body'].includes(getNodeName(currentNode))) {
987
+ if (isContainingBlock(currentNode)) {
988
+ return currentNode;
989
+ } else {
990
+ currentNode = currentNode.parentNode;
991
+ }
992
+ }
993
+
994
+ return null;
995
+ } // Gets the closest ancestor positioned element. Handles some edge cases,
996
+ // such as table ancestors and cross browser bugs.
997
+
998
+
999
+ function getOffsetParent(element) {
1000
+ const window = getWindow(element);
1001
+ let offsetParent = getTrueOffsetParent(element);
1002
+
1003
+ while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
1004
+ offsetParent = getTrueOffsetParent(offsetParent);
1005
+ }
1006
+
1007
+ if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
1008
+ return window;
1009
+ }
1010
+
1011
+ return offsetParent || getContainingBlock(element) || window;
1012
+ }
1013
+
1014
+ function getDimensions(element) {
1015
+ if (isHTMLElement(element)) {
1016
+ return {
1017
+ width: element.offsetWidth,
1018
+ height: element.offsetHeight
1019
+ };
1020
+ }
1021
+
1022
+ const rect = getBoundingClientRect(element);
1023
+ return {
1024
+ width: rect.width,
1025
+ height: rect.height
1026
+ };
1027
+ }
1028
+
1029
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1030
+ let {
1031
+ rect,
1032
+ offsetParent,
1033
+ strategy
1034
+ } = _ref;
1035
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1036
+ const documentElement = getDocumentElement(offsetParent);
1037
+
1038
+ if (offsetParent === documentElement) {
1039
+ return rect;
1040
+ }
1041
+
1042
+ let scroll = {
1043
+ scrollLeft: 0,
1044
+ scrollTop: 0
1045
+ };
1046
+ const offsets = {
1047
+ x: 0,
1048
+ y: 0
1049
+ };
1050
+
1051
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
1052
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1053
+ scroll = getNodeScroll(offsetParent);
1054
+ }
1055
+
1056
+ if (isHTMLElement(offsetParent)) {
1057
+ const offsetRect = getBoundingClientRect(offsetParent, true);
1058
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1059
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1060
+ } // This doesn't appear to be need to be negated.
1061
+ // else if (documentElement) {
1062
+ // offsets.x = getWindowScrollBarX(documentElement);
1063
+ // }
1064
+
1065
+ }
1066
+
1067
+ return { ...rect,
1068
+ x: rect.x - scroll.scrollLeft + offsets.x,
1069
+ y: rect.y - scroll.scrollTop + offsets.y
1070
+ };
1071
+ }
1072
+
1073
+ function getViewportRect(element, strategy) {
1074
+ const win = getWindow(element);
1075
+ const html = getDocumentElement(element);
1076
+ const visualViewport = win.visualViewport;
1077
+ let width = html.clientWidth;
1078
+ let height = html.clientHeight;
1079
+ let x = 0;
1080
+ let y = 0;
1081
+
1082
+ if (visualViewport) {
1083
+ width = visualViewport.width;
1084
+ height = visualViewport.height;
1085
+ const layoutViewport = isLayoutViewport();
1086
+
1087
+ if (layoutViewport || !layoutViewport && strategy === 'fixed') {
1088
+ x = visualViewport.offsetLeft;
1089
+ y = visualViewport.offsetTop;
1090
+ }
1091
+ }
1092
+
1093
+ return {
1094
+ width,
1095
+ height,
1096
+ x,
1097
+ y
1098
+ };
1099
+ }
1100
+
1101
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable
1102
+
1103
+ function getDocumentRect(element) {
1104
+ var _element$ownerDocumen;
1105
+
1106
+ const html = getDocumentElement(element);
1107
+ const scroll = getNodeScroll(element);
1108
+ const body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
1109
+ const width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
1110
+ const height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
1111
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1112
+ const y = -scroll.scrollTop;
1113
+
1114
+ if (getComputedStyle$1(body || html).direction === 'rtl') {
1115
+ x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
1116
+ }
1117
+
1118
+ return {
1119
+ width,
1120
+ height,
1121
+ x,
1122
+ y
1123
+ };
1124
+ }
1125
+
1126
+ function getNearestOverflowAncestor(node) {
1127
+ const parentNode = getParentNode(node);
1128
+
1129
+ if (['html', 'body', '#document'].includes(getNodeName(parentNode))) {
1130
+ // @ts-ignore assume body is always available
1131
+ return node.ownerDocument.body;
1132
+ }
1133
+
1134
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1135
+ return parentNode;
1136
+ }
1137
+
1138
+ return getNearestOverflowAncestor(parentNode);
1139
+ }
1140
+
1141
+ function getOverflowAncestors(node, list) {
1142
+ var _node$ownerDocument;
1143
+
1144
+ if (list === void 0) {
1145
+ list = [];
1146
+ }
1147
+
1148
+ const scrollableAncestor = getNearestOverflowAncestor(node);
1149
+ const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
1150
+ const win = getWindow(scrollableAncestor);
1151
+ const target = isBody ? [win].concat(win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []) : scrollableAncestor;
1152
+ const updatedList = list.concat(target);
1153
+ return isBody ? updatedList : // @ts-ignore: isBody tells us target will be an HTMLElement here
1154
+ updatedList.concat(getOverflowAncestors(target));
1155
+ }
1156
+
1157
+ function contains(parent, child) {
1158
+ const rootNode = child.getRootNode == null ? void 0 : child.getRootNode(); // First, attempt with faster native method
1159
+
1160
+ if (parent.contains(child)) {
1161
+ return true;
1162
+ } // then fallback to custom implementation with Shadow DOM support
1163
+ else if (rootNode && isShadowRoot(rootNode)) {
1164
+ let next = child;
1165
+
1166
+ do {
1167
+ // use `===` replace node.isSameNode()
1168
+ if (next && parent === next) {
1169
+ return true;
1170
+ } // @ts-ignore: need a better way to handle this...
1171
+
1172
+
1173
+ next = next.parentNode || next.host;
1174
+ } while (next);
1175
+ }
1176
+
1177
+ return false;
1178
+ }
1179
+
1180
+ function getInnerBoundingClientRect(element, strategy) {
1181
+ const clientRect = getBoundingClientRect(element, false, strategy === 'fixed');
1182
+ const top = clientRect.top + element.clientTop;
1183
+ const left = clientRect.left + element.clientLeft;
1184
+ return {
1185
+ top,
1186
+ left,
1187
+ x: left,
1188
+ y: top,
1189
+ right: left + element.clientWidth,
1190
+ bottom: top + element.clientHeight,
1191
+ width: element.clientWidth,
1192
+ height: element.clientHeight
1193
+ };
1194
+ }
1195
+
1196
+ function getClientRectFromClippingAncestor(element, clippingParent, strategy) {
1197
+ if (clippingParent === 'viewport') {
1198
+ return rectToClientRect(getViewportRect(element, strategy));
1199
+ }
1200
+
1201
+ if (isElement(clippingParent)) {
1202
+ return getInnerBoundingClientRect(clippingParent, strategy);
1203
+ }
1204
+
1205
+ return rectToClientRect(getDocumentRect(getDocumentElement(element)));
1206
+ } // A "clipping ancestor" is an overflowable container with the characteristic of
1207
+ // clipping (or hiding) overflowing elements with a position different from
1208
+ // `initial`
1209
+
1210
+
1211
+ function getClippingAncestors(element) {
1212
+ const clippingAncestors = getOverflowAncestors(element);
1213
+ const canEscapeClipping = ['absolute', 'fixed'].includes(getComputedStyle$1(element).position);
1214
+ const clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
1215
+
1216
+ if (!isElement(clipperElement)) {
1217
+ return [];
1218
+ } // @ts-ignore isElement check ensures we return Array<Element>
1219
+
1220
+
1221
+ return clippingAncestors.filter(clippingAncestors => isElement(clippingAncestors) && contains(clippingAncestors, clipperElement) && getNodeName(clippingAncestors) !== 'body');
1222
+ } // Gets the maximum area that the element is visible in due to any number of
1223
+ // clipping ancestors
1224
+
1225
+
1226
+ function getClippingRect(_ref) {
1227
+ let {
1228
+ element,
1229
+ boundary,
1230
+ rootBoundary,
1231
+ strategy
1232
+ } = _ref;
1233
+ const mainClippingAncestors = boundary === 'clippingAncestors' ? getClippingAncestors(element) : [].concat(boundary);
1234
+ const clippingAncestors = [...mainClippingAncestors, rootBoundary];
1235
+ const firstClippingAncestor = clippingAncestors[0];
1236
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1237
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1238
+ accRect.top = max(rect.top, accRect.top);
1239
+ accRect.right = min(rect.right, accRect.right);
1240
+ accRect.bottom = min(rect.bottom, accRect.bottom);
1241
+ accRect.left = max(rect.left, accRect.left);
1242
+ return accRect;
1243
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1244
+ return {
1245
+ width: clippingRect.right - clippingRect.left,
1246
+ height: clippingRect.bottom - clippingRect.top,
1247
+ x: clippingRect.left,
1248
+ y: clippingRect.top
1249
+ };
1250
+ }
1251
+
1252
+ const platform = {
1253
+ getClippingRect,
1254
+ convertOffsetParentRelativeRectToViewportRelativeRect,
1255
+ isElement,
1256
+ getDimensions,
1257
+ getOffsetParent,
1258
+ getDocumentElement,
1259
+ getElementRects: _ref => {
1260
+ let {
1261
+ reference,
1262
+ floating,
1263
+ strategy
1264
+ } = _ref;
1265
+ return {
1266
+ reference: getRectRelativeToOffsetParent(reference, getOffsetParent(floating), strategy),
1267
+ floating: { ...getDimensions(floating),
1268
+ x: 0,
1269
+ y: 0
1270
+ }
1271
+ };
1272
+ },
1273
+ getClientRects: element => Array.from(element.getClientRects()),
1274
+ isRTL: element => getComputedStyle$1(element).direction === 'rtl'
1275
+ };
1276
+
1277
+ /**
1278
+ * Automatically updates the position of the floating element when necessary.
1279
+ * @see https://floating-ui.com/docs/autoUpdate
1280
+ */
1281
+ function autoUpdate(reference, floating, update, options) {
1282
+ if (options === void 0) {
1283
+ options = {};
1284
+ }
1285
+
1286
+ const {
1287
+ ancestorScroll: _ancestorScroll = true,
1288
+ ancestorResize: _ancestorResize = true,
1289
+ elementResize = true,
1290
+ animationFrame = false
1291
+ } = options;
1292
+ const ancestorScroll = _ancestorScroll && !animationFrame;
1293
+ const ancestorResize = _ancestorResize && !animationFrame;
1294
+ const ancestors = ancestorScroll || ancestorResize ? [...(isElement(reference) ? getOverflowAncestors(reference) : []), ...getOverflowAncestors(floating)] : [];
1295
+ ancestors.forEach(ancestor => {
1296
+ ancestorScroll && ancestor.addEventListener('scroll', update, {
1297
+ passive: true
1298
+ });
1299
+ ancestorResize && ancestor.addEventListener('resize', update);
1300
+ });
1301
+ let observer = null;
1302
+
1303
+ if (elementResize) {
1304
+ let initialUpdate = true;
1305
+ observer = new ResizeObserver(() => {
1306
+ if (!initialUpdate) {
1307
+ update();
1308
+ }
1309
+
1310
+ initialUpdate = false;
1311
+ });
1312
+ isElement(reference) && !animationFrame && observer.observe(reference);
1313
+ observer.observe(floating);
1314
+ }
1315
+
1316
+ let frameId;
1317
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
1318
+
1319
+ if (animationFrame) {
1320
+ frameLoop();
1321
+ }
1322
+
1323
+ function frameLoop() {
1324
+ const nextRefRect = getBoundingClientRect(reference);
1325
+
1326
+ if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
1327
+ update();
1328
+ }
1329
+
1330
+ prevRefRect = nextRefRect;
1331
+ frameId = requestAnimationFrame(frameLoop);
1332
+ }
1333
+
1334
+ update();
1335
+ return () => {
1336
+ var _observer;
1337
+
1338
+ ancestors.forEach(ancestor => {
1339
+ ancestorScroll && ancestor.removeEventListener('scroll', update);
1340
+ ancestorResize && ancestor.removeEventListener('resize', update);
1341
+ });
1342
+ (_observer = observer) == null ? void 0 : _observer.disconnect();
1343
+ observer = null;
1344
+
1345
+ if (animationFrame) {
1346
+ cancelAnimationFrame(frameId);
1347
+ }
1348
+ };
1349
+ }
1350
+
1351
+ /**
1352
+ * Computes the `x` and `y` coordinates that will place the floating element
1353
+ * next to a reference element when it is given a certain CSS positioning
1354
+ * strategy.
1355
+ */
1356
+
1357
+ const computePosition = (reference, floating, options) => computePosition$1(reference, floating, {
1358
+ platform,
1359
+ ...options
1360
+ });
1361
+
1362
+ var _Popup_instances, _Popup_arrowPosition_get, _Popup_padding_get, _Popup_distance_get, _Popup_middleware_get, _Popup_cleanup, _Popup_assignPopupPosition, _Popup_assignArrowPosition, _Popup_getAnchor;
1363
+ class Popup extends FoundationElement {
1364
+ constructor() {
1365
+ super(...arguments);
1366
+ _Popup_instances.add(this);
1367
+ _Popup_cleanup.set(this, void 0);
1368
+ this.open = false;
1369
+ this.dismissible = false;
1370
+ this.arrow = false;
1371
+ this.alternate = false;
1372
+ this.strategy = 'fixed';
1373
+ }
1374
+ openChanged(_, newValue) {
1375
+ newValue ? this.$emit('open') : this.$emit('close');
1376
+ }
1377
+ disconnectedCallback() {
1378
+ var _a;
1379
+ super.disconnectedCallback();
1380
+ (_a = __classPrivateFieldGet(this, _Popup_cleanup, "f")) === null || _a === void 0 ? void 0 : _a.call(this);
1381
+ }
1382
+ attributeChangedCallback(name, oldValue, newValue) {
1383
+ var _a;
1384
+ super.attributeChangedCallback(name, oldValue, newValue);
1385
+ switch (name) {
1386
+ case 'anchor':
1387
+ {
1388
+ this.anchorEl = __classPrivateFieldGet(this, _Popup_instances, "m", _Popup_getAnchor).call(this);
1389
+ break;
1390
+ }
1391
+ case 'open':
1392
+ {
1393
+ this.open ? this.showPopover() : this.hidePopover();
1394
+ break;
1395
+ }
1396
+ }
1397
+ if (this.anchorEl && this.popupEl) {
1398
+ __classPrivateFieldSet(this, _Popup_cleanup, autoUpdate(this.anchorEl, this.popupEl, () => this.updatePosition()), "f");
1399
+ } else {
1400
+ (_a = __classPrivateFieldGet(this, _Popup_cleanup, "f")) === null || _a === void 0 ? void 0 : _a.call(this);
1401
+ }
1402
+ }
1403
+ async updatePosition() {
1404
+ if (!this.open || !this.anchorEl) {
1405
+ return;
1406
+ }
1407
+ const positionData = await computePosition(this.anchorEl, this.popupEl, {
1408
+ placement: this.placement,
1409
+ strategy: this.strategy,
1410
+ middleware: __classPrivateFieldGet(this, _Popup_instances, "a", _Popup_middleware_get)
1411
+ });
1412
+ __classPrivateFieldGet(this, _Popup_instances, "m", _Popup_assignPopupPosition).call(this, positionData);
1413
+ if (this.arrow) {
1414
+ __classPrivateFieldGet(this, _Popup_instances, "m", _Popup_assignArrowPosition).call(this, positionData);
1415
+ }
1416
+ }
1417
+ showPopover() {
1418
+ if (!this.classList.contains(':open')) {
1419
+ super.showPopover();
1420
+ }
1421
+ this.open = this.classList.contains(':open');
1422
+ }
1423
+ hidePopover() {
1424
+ if (this.classList.contains(':open')) {
1425
+ super.hidePopover();
1426
+ }
1427
+ this.open = this.classList.contains(':open');
1428
+ }
1429
+ }
1430
+ _Popup_cleanup = new WeakMap(), _Popup_instances = new WeakSet(), _Popup_arrowPosition_get = function _Popup_arrowPosition_get() {
1431
+ return {
1432
+ top: 'bottom',
1433
+ right: 'left',
1434
+ bottom: 'top',
1435
+ left: 'right'
1436
+ };
1437
+ }, _Popup_padding_get = function _Popup_padding_get() {
1438
+ return 0;
1439
+ }, _Popup_distance_get = function _Popup_distance_get() {
1440
+ return 12;
1441
+ }, _Popup_middleware_get = function _Popup_middleware_get() {
1442
+ const middleware = [flip(), hide(), inline()];
1443
+ if (this.arrow) {
1444
+ middleware.push(arrow({
1445
+ element: this.arrowEl,
1446
+ padding: __classPrivateFieldGet(this, _Popup_instances, "a", _Popup_padding_get)
1447
+ }), offset(__classPrivateFieldGet(this, _Popup_instances, "a", _Popup_distance_get)));
1448
+ }
1449
+ return middleware;
1450
+ }, _Popup_assignPopupPosition = function _Popup_assignPopupPosition(data) {
1451
+ const {
1452
+ x: popupX,
1453
+ y: popupY
1454
+ } = data;
1455
+ const {
1456
+ referenceHidden
1457
+ } = data.middlewareData.hide;
1458
+ Object.assign(this.popupEl.style, {
1459
+ left: `${popupX}px`,
1460
+ top: `${popupY}px`,
1461
+ visibility: referenceHidden ? 'hidden' : 'visible'
1462
+ });
1463
+ }, _Popup_assignArrowPosition = function _Popup_assignArrowPosition(data) {
1464
+ const {
1465
+ x: arrowX,
1466
+ y: arrowY
1467
+ } = data.middlewareData.arrow;
1468
+ const side = __classPrivateFieldGet(this, _Popup_instances, "a", _Popup_arrowPosition_get)[data.placement.split('-')[0]];
1469
+ Object.assign(this.arrowEl.style, {
1470
+ left: `${arrowX}px`,
1471
+ top: `${arrowY}px`,
1472
+ right: '',
1473
+ bottom: '',
1474
+ [side]: '-4px'
1475
+ });
1476
+ }, _Popup_getAnchor = function _Popup_getAnchor() {
1477
+ return this.anchor instanceof HTMLElement ? this.anchor : document.getElementById(this.anchor);
1478
+ };
1479
+ __decorate([attr({
1480
+ mode: 'boolean'
1481
+ }), __metadata("design:type", Object)], Popup.prototype, "open", void 0);
1482
+ __decorate([attr({
1483
+ mode: 'boolean'
1484
+ }), __metadata("design:type", Object)], Popup.prototype, "dismissible", void 0);
1485
+ __decorate([attr({
1486
+ mode: 'boolean'
1487
+ }), __metadata("design:type", Object)], Popup.prototype, "arrow", void 0);
1488
+ __decorate([attr({
1489
+ mode: 'boolean'
1490
+ }), __metadata("design:type", Object)], Popup.prototype, "alternate", void 0);
1491
+ __decorate([attr({
1492
+ mode: 'fromView'
1493
+ }), __metadata("design:type", String)], Popup.prototype, "placement", void 0);
1494
+ __decorate([attr({
1495
+ mode: 'fromView'
1496
+ }), __metadata("design:type", String)], Popup.prototype, "strategy", void 0);
1497
+ __decorate([attr, __metadata("design:type", Object)], Popup.prototype, "anchor", void 0);
1498
+
1499
+ var css_248z = ".control {\n background: var(--vvd-color-surface-4dp);\n border-radius: inherit;\n contain: layout;\n inline-size: var(--_popup-width, fit-content);\n}\n.control:not(.open) {\n display: none;\n}\n\n.popup-wrapper {\n border-radius: 6px;\n}\n.popup-wrapper:not(.absolute) {\n position: fixed;\n}\n.popup-wrapper.absolute {\n position: absolute;\n inline-size: var(--_popup-width);\n}\n\n.popup-content {\n display: grid;\n color: var(--vvd-color-canvas-text); /* neutral-100 */\n}\n.dismissible .popup-content {\n align-content: start;\n grid-template-columns: 1fr auto;\n}\n\n.arrow {\n position: absolute;\n z-index: -1;\n width: 8px;\n height: 8px;\n background: var(--vvd-color-surface-4dp);\n transform: rotate(45deg);\n}\n\n.dismissible-button {\n align-self: flex-start;\n margin-block-start: 4px;\n margin-inline-end: 4px;\n}";
1500
+
1501
+ let _ = t => t,
1502
+ _t,
1503
+ _t2,
1504
+ _t3;
1505
+ const getClasses = ({
1506
+ open,
1507
+ dismissible,
1508
+ alternate
1509
+ }) => classNames('control', ['open', Boolean(open)], ['dismissible', Boolean(dismissible)], ['alternate', Boolean(alternate)]);
1510
+ const popupTemplate = context => {
1511
+ const elevationTag = context.tagFor(Elevation);
1512
+ const buttonTag = context.tagFor(Button);
1513
+ return html(_t || (_t = _`
1514
+ <${0}>
1515
+ <div class="popup-wrapper ${0}" ${0}>
1516
+ <div class="${0}" aria-hidden="${0}"
1517
+ part="${0}">
1518
+ <div class="popup-content">
1519
+ <slot></slot>
1520
+ ${0}
1521
+ </div>
1522
+ ${0}
1523
+ </div>
1524
+ </div>
1525
+ </${0}>`), elevationTag, x => x.strategy, ref('popupEl'), getClasses, x => x.open ? 'false' : 'true', x => x.alternate ? 'vvd-theme-alternate' : '', when(x => x.dismissible, html(_t2 || (_t2 = _`<${0} size="condensed" @click="${0}"
1526
+ class="dismissible-button" icon="close-small-solid" shape="pill"></${0}>`), buttonTag, x => x.open = false, buttonTag)), when(x => x.arrow, html(_t3 || (_t3 = _`<div class="arrow" ${0}></div>`), ref('arrowEl'))), elevationTag);
1527
+ };
1528
+
1529
+ // node_modules/query-selector-shadow-dom/src/normalize.js
1530
+ function normalizeSelector(sel) {
1531
+ function saveUnmatched() {
1532
+ if (unmatched) {
1533
+ if (tokens.length > 0 && /^[~+>]$/.test(tokens[tokens.length - 1])) {
1534
+ tokens.push(" ");
1535
+ }
1536
+ tokens.push(unmatched);
1537
+ }
1538
+ }
1539
+ var tokens = [], match, unmatched, regex, state = [0], next_match_idx = 0, prev_match_idx, not_escaped_pattern = /(?:[^\\]|(?:^|[^\\])(?:\\\\)+)$/, whitespace_pattern = /^\s+$/, state_patterns = [
1540
+ /\s+|\/\*|["'>~+[(]/g,
1541
+ /\s+|\/\*|["'[\]()]/g,
1542
+ /\s+|\/\*|["'[\]()]/g,
1543
+ null,
1544
+ /\*\//g
1545
+ ];
1546
+ sel = sel.trim();
1547
+ while (true) {
1548
+ unmatched = "";
1549
+ regex = state_patterns[state[state.length - 1]];
1550
+ regex.lastIndex = next_match_idx;
1551
+ match = regex.exec(sel);
1552
+ if (match) {
1553
+ prev_match_idx = next_match_idx;
1554
+ next_match_idx = regex.lastIndex;
1555
+ if (prev_match_idx < next_match_idx - match[0].length) {
1556
+ unmatched = sel.substring(
1557
+ prev_match_idx,
1558
+ next_match_idx - match[0].length
1559
+ );
1560
+ }
1561
+ if (state[state.length - 1] < 3) {
1562
+ saveUnmatched();
1563
+ if (match[0] === "[") {
1564
+ state.push(1);
1565
+ } else if (match[0] === "(") {
1566
+ state.push(2);
1567
+ } else if (/^["']$/.test(match[0])) {
1568
+ state.push(3);
1569
+ state_patterns[3] = new RegExp(match[0], "g");
1570
+ } else if (match[0] === "/*") {
1571
+ state.push(4);
1572
+ } else if (/^[\])]$/.test(match[0]) && state.length > 0) {
1573
+ state.pop();
1574
+ } else if (/^(?:\s+|[~+>])$/.test(match[0])) {
1575
+ if (tokens.length > 0 && !whitespace_pattern.test(tokens[tokens.length - 1]) && state[state.length - 1] === 0) {
1576
+ tokens.push(" ");
1577
+ }
1578
+ if (state[state.length - 1] === 1 && tokens.length === 5 && tokens[2].charAt(tokens[2].length - 1) === "=") {
1579
+ tokens[4] = " " + tokens[4];
1580
+ }
1581
+ if (whitespace_pattern.test(match[0])) {
1582
+ continue;
1583
+ }
1584
+ }
1585
+ tokens.push(match[0]);
1586
+ } else {
1587
+ tokens[tokens.length - 1] += unmatched;
1588
+ if (not_escaped_pattern.test(tokens[tokens.length - 1])) {
1589
+ if (state[state.length - 1] === 4) {
1590
+ if (tokens.length < 2 || whitespace_pattern.test(tokens[tokens.length - 2])) {
1591
+ tokens.pop();
1592
+ } else {
1593
+ tokens[tokens.length - 1] = " ";
1594
+ }
1595
+ match[0] = "";
1596
+ }
1597
+ state.pop();
1598
+ }
1599
+ tokens[tokens.length - 1] += match[0];
1600
+ }
1601
+ } else {
1602
+ unmatched = sel.substr(next_match_idx);
1603
+ saveUnmatched();
1604
+ break;
1605
+ }
1606
+ }
1607
+ return tokens.join("").trim();
1608
+ }
1609
+
1610
+ // node_modules/query-selector-shadow-dom/src/querySelectorDeep.js
1611
+ function querySelectorAllDeep(selector, root = document, allElements = null) {
1612
+ return _querySelectorDeep(selector, true, root, allElements);
1613
+ }
1614
+ function _querySelectorDeep(selector, findMany, root, allElements = null) {
1615
+ selector = normalizeSelector(selector);
1616
+ let lightElement = root.querySelector(selector);
1617
+ if (document.head.createShadowRoot || document.head.attachShadow) {
1618
+ if (!findMany && lightElement) {
1619
+ return lightElement;
1620
+ }
1621
+ const selectionsToMake = splitByCharacterUnlessQuoted(selector, ",");
1622
+ return selectionsToMake.reduce((acc, minimalSelector) => {
1623
+ if (!findMany && acc) {
1624
+ return acc;
1625
+ }
1626
+ const splitSelector = splitByCharacterUnlessQuoted(minimalSelector.replace(/^\s+/g, "").replace(/\s*([>+~]+)\s*/g, "$1"), " ").filter((entry) => !!entry).map((entry) => splitByCharacterUnlessQuoted(entry, ">"));
1627
+ const possibleElementsIndex = splitSelector.length - 1;
1628
+ const lastSplitPart = splitSelector[possibleElementsIndex][splitSelector[possibleElementsIndex].length - 1];
1629
+ const possibleElements = collectAllElementsDeep(lastSplitPart, root, allElements);
1630
+ const findElements = findMatchingElement(splitSelector, possibleElementsIndex, root);
1631
+ if (findMany) {
1632
+ acc = acc.concat(possibleElements.filter(findElements));
1633
+ return acc;
1634
+ } else {
1635
+ acc = possibleElements.find(findElements);
1636
+ return acc || null;
1637
+ }
1638
+ }, findMany ? [] : null);
1639
+ } else {
1640
+ if (!findMany) {
1641
+ return lightElement;
1642
+ } else {
1643
+ return root.querySelectorAll(selector);
1644
+ }
1645
+ }
1646
+ }
1647
+ function findMatchingElement(splitSelector, possibleElementsIndex, root) {
1648
+ return (element) => {
1649
+ let position = possibleElementsIndex;
1650
+ let parent = element;
1651
+ let foundElement = false;
1652
+ while (parent && !isDocumentNode(parent)) {
1653
+ let foundMatch = true;
1654
+ if (splitSelector[position].length === 1) {
1655
+ foundMatch = parent.matches(splitSelector[position]);
1656
+ } else {
1657
+ const reversedParts = [].concat(splitSelector[position]).reverse();
1658
+ let newParent = parent;
1659
+ for (const part of reversedParts) {
1660
+ if (!newParent || !newParent.matches(part)) {
1661
+ foundMatch = false;
1662
+ break;
1663
+ }
1664
+ newParent = findParentOrHost(newParent, root);
1665
+ }
1666
+ }
1667
+ if (foundMatch && position === 0) {
1668
+ foundElement = true;
1669
+ break;
1670
+ }
1671
+ if (foundMatch) {
1672
+ position--;
1673
+ }
1674
+ parent = findParentOrHost(parent, root);
1675
+ }
1676
+ return foundElement;
1677
+ };
1678
+ }
1679
+ function splitByCharacterUnlessQuoted(selector, character) {
1680
+ return selector.match(/\\?.|^$/g).reduce((p, c) => {
1681
+ if (c === '"' && !p.sQuote) {
1682
+ p.quote ^= 1;
1683
+ p.a[p.a.length - 1] += c;
1684
+ } else if (c === "'" && !p.quote) {
1685
+ p.sQuote ^= 1;
1686
+ p.a[p.a.length - 1] += c;
1687
+ } else if (!p.quote && !p.sQuote && c === character) {
1688
+ p.a.push("");
1689
+ } else {
1690
+ p.a[p.a.length - 1] += c;
1691
+ }
1692
+ return p;
1693
+ }, { a: [""] }).a;
1694
+ }
1695
+ function isDocumentNode(node) {
1696
+ return node.nodeType === Node.DOCUMENT_FRAGMENT_NODE || node.nodeType === Node.DOCUMENT_NODE;
1697
+ }
1698
+ function findParentOrHost(element, root) {
1699
+ const parentNode = element.parentNode;
1700
+ return parentNode && parentNode.host && parentNode.nodeType === 11 ? parentNode.host : parentNode === root ? null : parentNode;
1701
+ }
1702
+ function collectAllElementsDeep(selector = null, root, cachedElements = null) {
1703
+ let allElements = [];
1704
+ if (cachedElements) {
1705
+ allElements = cachedElements;
1706
+ } else {
1707
+ const findAllElements = function (nodes) {
1708
+ for (let i = 0; i < nodes.length; i++) {
1709
+ const el = nodes[i];
1710
+ allElements.push(el);
1711
+ if (el.shadowRoot) {
1712
+ findAllElements(el.shadowRoot.querySelectorAll("*"));
1713
+ }
1714
+ }
1715
+ };
1716
+ if (root.shadowRoot) {
1717
+ findAllElements(root.shadowRoot.querySelectorAll("*"));
1718
+ }
1719
+ findAllElements(root.querySelectorAll("*"));
1720
+ }
1721
+ return selector ? allElements.filter((el) => el.matches(selector)) : allElements;
1722
+ }
1723
+
1724
+ // src/popover.ts
1725
+ function closestComposed(event) {
1726
+ return event.composedPath().find((el) => el instanceof HTMLElement && el.hasAttribute("popover")) || null;
1727
+ }
1728
+ function isSupported() {
1729
+ return typeof HTMLElement !== "undefined" && typeof HTMLElement.prototype === "object" && "popover" in HTMLElement.prototype;
1730
+ }
1731
+ var notSupportedMessage = "Not supported on element that does not have valid popover attribute";
1732
+ function apply() {
1733
+ const visibleElements = /* @__PURE__ */ new WeakSet();
1734
+ Object.defineProperties(HTMLElement.prototype, {
1735
+ popover: {
1736
+ enumerable: true,
1737
+ configurable: true,
1738
+ get() {
1739
+ const value = (this.getAttribute("popover") || "").toLowerCase();
1740
+ if (value === "manual")
1741
+ return "manual";
1742
+ if (value === "" || value == "auto")
1743
+ return "auto";
1744
+ return null;
1745
+ },
1746
+ set(value) {
1747
+ this.setAttribute("popover", value);
1748
+ }
1749
+ },
1750
+ showPopover: {
1751
+ enumerable: true,
1752
+ configurable: true,
1753
+ value() {
1754
+ if (!this.popover)
1755
+ throw new DOMException(notSupportedMessage, "NotSupportedError");
1756
+ if (visibleElements.has(this))
1757
+ throw new DOMException(
1758
+ "Invalid on already-showing Popovers",
1759
+ "InvalidStateError"
1760
+ );
1761
+ this.classList.add(":open");
1762
+ visibleElements.add(this);
1763
+ if (this.popover === "auto") {
1764
+ const focusEl = this.hasAttribute("autofocus") ? this : this.querySelector("[autofocus]");
1765
+ focusEl?.focus();
1766
+ }
1767
+ }
1768
+ },
1769
+ hidePopover: {
1770
+ enumerable: true,
1771
+ configurable: true,
1772
+ value() {
1773
+ if (!this.popover)
1774
+ throw new DOMException(notSupportedMessage, "NotSupportedError");
1775
+ if (!visibleElements.has(this))
1776
+ throw new DOMException(
1777
+ "Invalid on already-hidden Popovers",
1778
+ "InvalidStateError"
1779
+ );
1780
+ this.classList.remove(":open");
1781
+ visibleElements.delete(this);
1782
+ }
1783
+ }
1784
+ });
1785
+ document.addEventListener("click", (event) => {
1786
+ const target = event.target;
1787
+ if (!(target instanceof Element))
1788
+ return;
1789
+ const doc = target.ownerDocument;
1790
+ let effectedPopover = closestComposed(event);
1791
+ const button = target.closest(
1792
+ "[popovertoggletarget],[popoverhidetarget],[popovershowtarget]"
1793
+ );
1794
+ const isButton = button instanceof HTMLButtonElement;
1795
+ if (isButton && button.hasAttribute("popovershowtarget")) {
1796
+ effectedPopover = doc.getElementById(
1797
+ button.getAttribute("popovershowtarget") || ""
1798
+ );
1799
+ if (effectedPopover && effectedPopover.popover && !visibleElements.has(effectedPopover)) {
1800
+ effectedPopover.showPopover();
1801
+ }
1802
+ } else if (isButton && button.hasAttribute("popoverhidetarget")) {
1803
+ effectedPopover = doc.getElementById(
1804
+ button.getAttribute("popoverhidetarget") || ""
1805
+ );
1806
+ if (effectedPopover && effectedPopover.popover && visibleElements.has(effectedPopover)) {
1807
+ effectedPopover.hidePopover();
1808
+ }
1809
+ } else if (isButton && button.hasAttribute("popovertoggletarget")) {
1810
+ effectedPopover = doc.getElementById(
1811
+ button.getAttribute("popovertoggletarget") || ""
1812
+ );
1813
+ if (effectedPopover && effectedPopover.popover) {
1814
+ if (visibleElements.has(effectedPopover)) {
1815
+ effectedPopover.hidePopover();
1816
+ } else {
1817
+ effectedPopover.showPopover();
1818
+ }
1819
+ }
1820
+ }
1821
+ for (const popover of querySelectorAllDeep(
1822
+ '[popover="" i].\\:open, [popover=auto i].\\:open'
1823
+ )) {
1824
+ if (popover instanceof HTMLElement && popover !== effectedPopover)
1825
+ popover.hidePopover();
1826
+ }
1827
+ });
1828
+ }
1829
+
1830
+ // src/index.ts
1831
+ if (!isSupported())
1832
+ apply();
1833
+
1834
+ const popupDefinition = Popup.compose({
1835
+ baseName: 'popup',
1836
+ template: popupTemplate,
1837
+ styles: css_248z
1838
+ });
1839
+ const popupRegistries = [popupDefinition(), ...elevationRegistries, ...buttonRegistries];
1840
+ const registerPopup = registerFactory(popupRegistries);
1841
+
1842
+ export { Popup as P, popupDefinition as a, popupRegistries as p, registerPopup as r };