@spscommerce/positioning 6.37.2 → 7.0.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.
package/lib/index.es.js CHANGED
@@ -1,512 +1,273 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- import { onNextTick, lockedToAnimationFrames } from "@spscommerce/utils";
21
- var Position;
22
- (function(Position2) {
23
- Position2["TOP_LEFT"] = "top left";
24
- Position2["TOP_MIDDLE"] = "top middle";
25
- Position2["TOP_RIGHT"] = "top right";
26
- Position2["RIGHT_TOP"] = "right top";
27
- Position2["RIGHT_MIDDLE"] = "right middle";
28
- Position2["RIGHT_BOTTOM"] = "right bottom";
29
- Position2["BOTTOM_RIGHT"] = "bottom right";
30
- Position2["BOTTOM_MIDDLE"] = "bottom middle";
31
- Position2["BOTTOM_LEFT"] = "bottom left";
32
- Position2["LEFT_BOTTOM"] = "left bottom";
33
- Position2["LEFT_MIDDLE"] = "left middle";
34
- Position2["LEFT_TOP"] = "left top";
35
- })(Position || (Position = {}));
36
- var PositionAnchor;
37
- (function(PositionAnchor2) {
38
- PositionAnchor2["TOP_LEFT"] = "top left";
39
- PositionAnchor2["TOP_RIGHT"] = "top right";
40
- PositionAnchor2["BOTTOM_LEFT"] = "bottom left";
41
- PositionAnchor2["BOTTOM_RIGHT"] = "bottom right";
42
- })(PositionAnchor || (PositionAnchor = {}));
43
- const DEFAULT_POSITIONING_OPTIONS = {
44
- anchor: PositionAnchor.TOP_LEFT,
1
+ var H = Object.defineProperty;
2
+ var N = (e, r, s) => r in e ? H(e, r, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[r] = s;
3
+ var k = (e, r, s) => (N(e, typeof r != "symbol" ? r + "" : r, s), s);
4
+ import { onNextTick as U, lockedToAnimationFrames as j } from "@spscommerce/utils";
5
+ var F = /* @__PURE__ */ ((e) => (e.TOP_LEFT = "top left", e.TOP_MIDDLE = "top middle", e.TOP_RIGHT = "top right", e.RIGHT_TOP = "right top", e.RIGHT_MIDDLE = "right middle", e.RIGHT_BOTTOM = "right bottom", e.BOTTOM_RIGHT = "bottom right", e.BOTTOM_MIDDLE = "bottom middle", e.BOTTOM_LEFT = "bottom left", e.LEFT_BOTTOM = "left bottom", e.LEFT_MIDDLE = "left middle", e.LEFT_TOP = "left top", e))(F || {}), P = /* @__PURE__ */ ((e) => (e.TOP_LEFT = "top left", e.TOP_RIGHT = "top right", e.BOTTOM_LEFT = "bottom left", e.BOTTOM_RIGHT = "bottom right", e))(P || {});
6
+ const V = {
7
+ anchor: P.TOP_LEFT,
45
8
  offsets: [],
46
- position: Position.TOP_LEFT
9
+ position: F.TOP_LEFT
47
10
  };
48
11
  (function() {
49
- if (typeof window !== "object") {
12
+ if (typeof window != "object")
50
13
  return;
51
- }
52
14
  if ("IntersectionObserver" in window && "IntersectionObserverEntry" in window && "intersectionRatio" in window.IntersectionObserverEntry.prototype) {
53
- if (!("isIntersecting" in window.IntersectionObserverEntry.prototype)) {
54
- Object.defineProperty(window.IntersectionObserverEntry.prototype, "isIntersecting", {
15
+ "isIntersecting" in window.IntersectionObserverEntry.prototype || Object.defineProperty(
16
+ window.IntersectionObserverEntry.prototype,
17
+ "isIntersecting",
18
+ {
55
19
  get: function() {
56
20
  return this.intersectionRatio > 0;
57
21
  }
58
- });
59
- }
22
+ }
23
+ );
60
24
  return;
61
25
  }
62
- function getFrameElement(doc) {
26
+ function e(t) {
63
27
  try {
64
- return doc.defaultView && doc.defaultView.frameElement || null;
65
- } catch (e) {
28
+ return t.defaultView && t.defaultView.frameElement || null;
29
+ } catch {
66
30
  return null;
67
31
  }
68
32
  }
69
- var document2 = function(startDoc) {
70
- var doc = startDoc;
71
- var frame = getFrameElement(doc);
72
- while (frame) {
73
- doc = frame.ownerDocument;
74
- frame = getFrameElement(doc);
75
- }
76
- return doc;
77
- }(window.document);
78
- var registry = [];
79
- var crossOriginUpdater = null;
80
- var crossOriginRect = null;
81
- function IntersectionObserverEntry2(entry) {
82
- this.time = entry.time;
83
- this.target = entry.target;
84
- this.rootBounds = ensureDOMRect(entry.rootBounds);
85
- this.boundingClientRect = ensureDOMRect(entry.boundingClientRect);
86
- this.intersectionRect = ensureDOMRect(entry.intersectionRect || getEmptyRect());
87
- this.isIntersecting = !!entry.intersectionRect;
88
- var targetRect = this.boundingClientRect;
89
- var targetArea = targetRect.width * targetRect.height;
90
- var intersectionRect = this.intersectionRect;
91
- var intersectionArea = intersectionRect.width * intersectionRect.height;
92
- if (targetArea) {
93
- this.intersectionRatio = Number((intersectionArea / targetArea).toFixed(4));
94
- } else {
95
- this.intersectionRatio = this.isIntersecting ? 1 : 0;
96
- }
33
+ var r = function(t) {
34
+ for (var n = t, o = e(n); o; )
35
+ n = o.ownerDocument, o = e(n);
36
+ return n;
37
+ }(window.document), s = [], f = null, g = null;
38
+ function b(t) {
39
+ this.time = t.time, this.target = t.target, this.rootBounds = m(t.rootBounds), this.boundingClientRect = m(t.boundingClientRect), this.intersectionRect = m(t.intersectionRect || w()), this.isIntersecting = !!t.intersectionRect;
40
+ var n = this.boundingClientRect, o = n.width * n.height, a = this.intersectionRect, c = a.width * a.height;
41
+ o ? this.intersectionRatio = Number((c / o).toFixed(4)) : this.intersectionRatio = this.isIntersecting ? 1 : 0;
97
42
  }
98
- function IntersectionObserver2(callback, opt_options) {
99
- var options = opt_options || {};
100
- if (typeof callback != "function") {
43
+ function l(t, n) {
44
+ var o = n || {};
45
+ if (typeof t != "function")
101
46
  throw new Error("callback must be a function");
102
- }
103
- if (options.root && options.root.nodeType != 1 && options.root.nodeType != 9) {
47
+ if (o.root && o.root.nodeType != 1 && o.root.nodeType != 9)
104
48
  throw new Error("root must be a Document or Element");
105
- }
106
- this._checkForIntersections = throttle(this._checkForIntersections.bind(this), this.THROTTLE_TIMEOUT);
107
- this._callback = callback;
108
- this._observationTargets = [];
109
- this._queuedEntries = [];
110
- this._rootMarginValues = this._parseRootMargin(options.rootMargin);
111
- this.thresholds = this._initThresholds(options.threshold);
112
- this.root = options.root || null;
113
- this.rootMargin = this._rootMarginValues.map(function(margin) {
114
- return margin.value + margin.unit;
115
- }).join(" ");
116
- this._monitoringDocuments = [];
117
- this._monitoringUnsubscribes = [];
118
- }
119
- IntersectionObserver2.prototype.THROTTLE_TIMEOUT = 100;
120
- IntersectionObserver2.prototype.POLL_INTERVAL = null;
121
- IntersectionObserver2.prototype.USE_MUTATION_OBSERVER = true;
122
- IntersectionObserver2._setupCrossOriginUpdater = function() {
123
- if (!crossOriginUpdater) {
124
- crossOriginUpdater = function(boundingClientRect, intersectionRect) {
125
- if (!boundingClientRect || !intersectionRect) {
126
- crossOriginRect = getEmptyRect();
127
- } else {
128
- crossOriginRect = convertFromParentRect(boundingClientRect, intersectionRect);
129
- }
130
- registry.forEach(function(observer) {
131
- observer._checkForIntersections();
132
- });
133
- };
134
- }
135
- return crossOriginUpdater;
136
- };
137
- IntersectionObserver2._resetCrossOriginUpdater = function() {
138
- crossOriginUpdater = null;
139
- crossOriginRect = null;
140
- };
141
- IntersectionObserver2.prototype.observe = function(target) {
142
- var isTargetAlreadyObserved = this._observationTargets.some(function(item) {
143
- return item.element == target;
144
- });
145
- if (isTargetAlreadyObserved) {
146
- return;
147
- }
148
- if (!(target && target.nodeType == 1)) {
149
- throw new Error("target must be an Element");
150
- }
151
- this._registerInstance();
152
- this._observationTargets.push({ element: target, entry: null });
153
- this._monitorIntersections(target.ownerDocument);
154
- this._checkForIntersections();
155
- };
156
- IntersectionObserver2.prototype.unobserve = function(target) {
157
- this._observationTargets = this._observationTargets.filter(function(item) {
158
- return item.element != target;
49
+ this._checkForIntersections = d(
50
+ this._checkForIntersections.bind(this),
51
+ this.THROTTLE_TIMEOUT
52
+ ), this._callback = t, this._observationTargets = [], this._queuedEntries = [], this._rootMarginValues = this._parseRootMargin(o.rootMargin), this.thresholds = this._initThresholds(o.threshold), this.root = o.root || null, this.rootMargin = this._rootMarginValues.map(function(a) {
53
+ return a.value + a.unit;
54
+ }).join(" "), this._monitoringDocuments = [], this._monitoringUnsubscribes = [];
55
+ }
56
+ l.prototype.THROTTLE_TIMEOUT = 100, l.prototype.POLL_INTERVAL = null, l.prototype.USE_MUTATION_OBSERVER = !0, l._setupCrossOriginUpdater = function() {
57
+ return f || (f = function(t, n) {
58
+ !t || !n ? g = w() : g = x(t, n), s.forEach(function(o) {
59
+ o._checkForIntersections();
60
+ });
61
+ }), f;
62
+ }, l._resetCrossOriginUpdater = function() {
63
+ f = null, g = null;
64
+ }, l.prototype.observe = function(t) {
65
+ var n = this._observationTargets.some(function(o) {
66
+ return o.element == t;
159
67
  });
160
- this._unmonitorIntersections(target.ownerDocument);
161
- if (this._observationTargets.length == 0) {
162
- this._unregisterInstance();
163
- }
164
- };
165
- IntersectionObserver2.prototype.disconnect = function() {
166
- this._observationTargets = [];
167
- this._unmonitorAllIntersections();
168
- this._unregisterInstance();
169
- };
170
- IntersectionObserver2.prototype.takeRecords = function() {
171
- var records = this._queuedEntries.slice();
172
- this._queuedEntries = [];
173
- return records;
174
- };
175
- IntersectionObserver2.prototype._initThresholds = function(opt_threshold) {
176
- var threshold = opt_threshold || [0];
177
- if (!Array.isArray(threshold))
178
- threshold = [threshold];
179
- return threshold.sort().filter(function(t, i, a) {
180
- if (typeof t != "number" || isNaN(t) || t < 0 || t > 1) {
68
+ if (!n) {
69
+ if (!(t && t.nodeType == 1))
70
+ throw new Error("target must be an Element");
71
+ this._registerInstance(), this._observationTargets.push({ element: t, entry: null }), this._monitorIntersections(t.ownerDocument), this._checkForIntersections();
72
+ }
73
+ }, l.prototype.unobserve = function(t) {
74
+ this._observationTargets = this._observationTargets.filter(function(n) {
75
+ return n.element != t;
76
+ }), this._unmonitorIntersections(t.ownerDocument), this._observationTargets.length == 0 && this._unregisterInstance();
77
+ }, l.prototype.disconnect = function() {
78
+ this._observationTargets = [], this._unmonitorAllIntersections(), this._unregisterInstance();
79
+ }, l.prototype.takeRecords = function() {
80
+ var t = this._queuedEntries.slice();
81
+ return this._queuedEntries = [], t;
82
+ }, l.prototype._initThresholds = function(t) {
83
+ var n = t || [0];
84
+ return Array.isArray(n) || (n = [n]), n.sort().filter(function(o, a, c) {
85
+ if (typeof o != "number" || isNaN(o) || o < 0 || o > 1)
181
86
  throw new Error("threshold must be a number between 0 and 1 inclusively");
182
- }
183
- return t !== a[i - 1];
87
+ return o !== c[a - 1];
184
88
  });
185
- };
186
- IntersectionObserver2.prototype._parseRootMargin = function(opt_rootMargin) {
187
- var marginString = opt_rootMargin || "0px";
188
- var margins = marginString.split(/\s+/).map(function(margin) {
189
- var parts = /^(-?\d*\.?\d+)(px|%)$/.exec(margin);
190
- if (!parts) {
89
+ }, l.prototype._parseRootMargin = function(t) {
90
+ var n = t || "0px", o = n.split(/\s+/).map(function(a) {
91
+ var c = /^(-?\d*\.?\d+)(px|%)$/.exec(a);
92
+ if (!c)
191
93
  throw new Error("rootMargin must be specified in pixels or percent");
192
- }
193
- return { value: parseFloat(parts[1]), unit: parts[2] };
194
- });
195
- margins[1] = margins[1] || margins[0];
196
- margins[2] = margins[2] || margins[0];
197
- margins[3] = margins[3] || margins[1];
198
- return margins;
199
- };
200
- IntersectionObserver2.prototype._monitorIntersections = function(doc) {
201
- var win = doc.defaultView;
202
- if (!win) {
203
- return;
204
- }
205
- if (this._monitoringDocuments.indexOf(doc) != -1) {
206
- return;
207
- }
208
- var callback = this._checkForIntersections;
209
- var monitoringInterval = null;
210
- var domObserver = null;
211
- if (this.POLL_INTERVAL) {
212
- monitoringInterval = win.setInterval(callback, this.POLL_INTERVAL);
213
- } else {
214
- addEvent(win, "resize", callback, true);
215
- addEvent(doc, "scroll", callback, true);
216
- if (this.USE_MUTATION_OBSERVER && "MutationObserver" in win) {
217
- domObserver = new win.MutationObserver(callback);
218
- domObserver.observe(doc, {
219
- attributes: true,
220
- childList: true,
221
- characterData: true,
222
- subtree: true
223
- });
224
- }
225
- }
226
- this._monitoringDocuments.push(doc);
227
- this._monitoringUnsubscribes.push(function() {
228
- var win2 = doc.defaultView;
229
- if (win2) {
230
- if (monitoringInterval) {
231
- win2.clearInterval(monitoringInterval);
232
- }
233
- removeEvent(win2, "resize", callback, true);
234
- }
235
- removeEvent(doc, "scroll", callback, true);
236
- if (domObserver) {
237
- domObserver.disconnect();
238
- }
94
+ return { value: parseFloat(c[1]), unit: c[2] };
239
95
  });
240
- var rootDoc = this.root && (this.root.ownerDocument || this.root) || document2;
241
- if (doc != rootDoc) {
242
- var frame = getFrameElement(doc);
243
- if (frame) {
244
- this._monitorIntersections(frame.ownerDocument);
96
+ return o[1] = o[1] || o[0], o[2] = o[2] || o[0], o[3] = o[3] || o[1], o;
97
+ }, l.prototype._monitorIntersections = function(t) {
98
+ var n = t.defaultView;
99
+ if (!!n && this._monitoringDocuments.indexOf(t) == -1) {
100
+ var o = this._checkForIntersections, a = null, c = null;
101
+ this.POLL_INTERVAL ? a = n.setInterval(o, this.POLL_INTERVAL) : (u(n, "resize", o, !0), u(t, "scroll", o, !0), this.USE_MUTATION_OBSERVER && "MutationObserver" in n && (c = new n.MutationObserver(o), c.observe(t, {
102
+ attributes: !0,
103
+ childList: !0,
104
+ characterData: !0,
105
+ subtree: !0
106
+ }))), this._monitoringDocuments.push(t), this._monitoringUnsubscribes.push(function() {
107
+ var O = t.defaultView;
108
+ O && (a && O.clearInterval(a), p(O, "resize", o, !0)), p(t, "scroll", o, !0), c && c.disconnect();
109
+ });
110
+ var E = this.root && (this.root.ownerDocument || this.root) || r;
111
+ if (t != E) {
112
+ var y = e(t);
113
+ y && this._monitorIntersections(y.ownerDocument);
245
114
  }
246
115
  }
247
- };
248
- IntersectionObserver2.prototype._unmonitorIntersections = function(doc) {
249
- var index = this._monitoringDocuments.indexOf(doc);
250
- if (index == -1) {
251
- return;
252
- }
253
- var rootDoc = this.root && (this.root.ownerDocument || this.root) || document2;
254
- var hasDependentTargets = this._observationTargets.some(function(item) {
255
- var itemDoc = item.element.ownerDocument;
256
- if (itemDoc == doc) {
257
- return true;
258
- }
259
- while (itemDoc && itemDoc != rootDoc) {
260
- var frame2 = getFrameElement(itemDoc);
261
- itemDoc = frame2 && frame2.ownerDocument;
262
- if (itemDoc == doc) {
263
- return true;
116
+ }, l.prototype._unmonitorIntersections = function(t) {
117
+ var n = this._monitoringDocuments.indexOf(t);
118
+ if (n != -1) {
119
+ var o = this.root && (this.root.ownerDocument || this.root) || r, a = this._observationTargets.some(function(y) {
120
+ var O = y.element.ownerDocument;
121
+ if (O == t)
122
+ return !0;
123
+ for (; O && O != o; ) {
124
+ var R = e(O);
125
+ if (O = R && R.ownerDocument, O == t)
126
+ return !0;
264
127
  }
265
- }
266
- return false;
267
- });
268
- if (hasDependentTargets) {
269
- return;
270
- }
271
- var unsubscribe = this._monitoringUnsubscribes[index];
272
- this._monitoringDocuments.splice(index, 1);
273
- this._monitoringUnsubscribes.splice(index, 1);
274
- unsubscribe();
275
- if (doc != rootDoc) {
276
- var frame = getFrameElement(doc);
277
- if (frame) {
278
- this._unmonitorIntersections(frame.ownerDocument);
279
- }
280
- }
281
- };
282
- IntersectionObserver2.prototype._unmonitorAllIntersections = function() {
283
- var unsubscribes = this._monitoringUnsubscribes.slice(0);
284
- this._monitoringDocuments.length = 0;
285
- this._monitoringUnsubscribes.length = 0;
286
- for (var i = 0; i < unsubscribes.length; i++) {
287
- unsubscribes[i]();
288
- }
289
- };
290
- IntersectionObserver2.prototype._checkForIntersections = function() {
291
- if (!this.root && crossOriginUpdater && !crossOriginRect) {
292
- return;
293
- }
294
- var rootIsInDom = this._rootIsInDom();
295
- var rootRect = rootIsInDom ? this._getRootRect() : getEmptyRect();
296
- this._observationTargets.forEach(function(item) {
297
- var target = item.element;
298
- var targetRect = getBoundingClientRect(target);
299
- var rootContainsTarget = this._rootContainsTarget(target);
300
- var oldEntry = item.entry;
301
- var intersectionRect = rootIsInDom && rootContainsTarget && this._computeTargetAndRootIntersection(target, targetRect, rootRect);
302
- var rootBounds = null;
303
- if (!this._rootContainsTarget(target)) {
304
- rootBounds = getEmptyRect();
305
- } else if (!crossOriginUpdater || this.root) {
306
- rootBounds = rootRect;
307
- }
308
- var newEntry = item.entry = new IntersectionObserverEntry2({
309
- time: now(),
310
- target,
311
- boundingClientRect: targetRect,
312
- rootBounds,
313
- intersectionRect
128
+ return !1;
314
129
  });
315
- if (!oldEntry) {
316
- this._queuedEntries.push(newEntry);
317
- } else if (rootIsInDom && rootContainsTarget) {
318
- if (this._hasCrossedThreshold(oldEntry, newEntry)) {
319
- this._queuedEntries.push(newEntry);
320
- }
321
- } else {
322
- if (oldEntry && oldEntry.isIntersecting) {
323
- this._queuedEntries.push(newEntry);
130
+ if (!a) {
131
+ var c = this._monitoringUnsubscribes[n];
132
+ if (this._monitoringDocuments.splice(n, 1), this._monitoringUnsubscribes.splice(n, 1), c(), t != o) {
133
+ var E = e(t);
134
+ E && this._unmonitorIntersections(E.ownerDocument);
324
135
  }
325
136
  }
326
- }, this);
327
- if (this._queuedEntries.length) {
328
- this._callback(this.takeRecords(), this);
329
137
  }
330
- };
331
- IntersectionObserver2.prototype._computeTargetAndRootIntersection = function(target, targetRect, rootRect) {
332
- if (window.getComputedStyle(target).display == "none")
333
- return;
334
- var intersectionRect = targetRect;
335
- var parent = getParentNode(target);
336
- var atRoot = false;
337
- while (!atRoot && parent) {
338
- var parentRect = null;
339
- var parentComputedStyle = parent.nodeType == 1 ? window.getComputedStyle(parent) : {};
340
- if (parentComputedStyle.display == "none")
341
- return null;
342
- if (parent == this.root || parent.nodeType == 9) {
343
- atRoot = true;
344
- if (parent == this.root || parent == document2) {
345
- if (crossOriginUpdater && !this.root) {
346
- if (!crossOriginRect || crossOriginRect.width == 0 && crossOriginRect.height == 0) {
347
- parent = null;
348
- parentRect = null;
349
- intersectionRect = null;
350
- } else {
351
- parentRect = crossOriginRect;
352
- }
353
- } else {
354
- parentRect = rootRect;
355
- }
356
- } else {
357
- var frame = getParentNode(parent);
358
- var frameRect = frame && getBoundingClientRect(frame);
359
- var frameIntersect = frame && this._computeTargetAndRootIntersection(frame, frameRect, rootRect);
360
- if (frameRect && frameIntersect) {
361
- parent = frame;
362
- parentRect = convertFromParentRect(frameRect, frameIntersect);
363
- } else {
364
- parent = null;
365
- intersectionRect = null;
138
+ }, l.prototype._unmonitorAllIntersections = function() {
139
+ var t = this._monitoringUnsubscribes.slice(0);
140
+ this._monitoringDocuments.length = 0, this._monitoringUnsubscribes.length = 0;
141
+ for (var n = 0; n < t.length; n++)
142
+ t[n]();
143
+ }, l.prototype._checkForIntersections = function() {
144
+ if (!(!this.root && f && !g)) {
145
+ var t = this._rootIsInDom(), n = t ? this._getRootRect() : w();
146
+ this._observationTargets.forEach(function(o) {
147
+ var a = o.element, c = T(a), E = this._rootContainsTarget(a), y = o.entry, O = t && E && this._computeTargetAndRootIntersection(a, c, n), R = null;
148
+ this._rootContainsTarget(a) ? (!f || this.root) && (R = n) : R = w();
149
+ var D = o.entry = new b({
150
+ time: _(),
151
+ target: a,
152
+ boundingClientRect: c,
153
+ rootBounds: R,
154
+ intersectionRect: O
155
+ });
156
+ y ? t && E ? this._hasCrossedThreshold(y, D) && this._queuedEntries.push(D) : y && y.isIntersecting && this._queuedEntries.push(D) : this._queuedEntries.push(D);
157
+ }, this), this._queuedEntries.length && this._callback(this.takeRecords(), this);
158
+ }
159
+ }, l.prototype._computeTargetAndRootIntersection = function(t, n, o) {
160
+ if (window.getComputedStyle(t).display != "none") {
161
+ for (var a = n, c = I(t), E = !1; !E && c; ) {
162
+ var y = null, O = c.nodeType == 1 ? window.getComputedStyle(c) : {};
163
+ if (O.display == "none")
164
+ return null;
165
+ if (c == this.root || c.nodeType == 9)
166
+ if (E = !0, c == this.root || c == r)
167
+ f && !this.root ? !g || g.width == 0 && g.height == 0 ? (c = null, y = null, a = null) : y = g : y = o;
168
+ else {
169
+ var R = I(c), D = R && T(R), C = R && this._computeTargetAndRootIntersection(R, D, o);
170
+ D && C ? (c = R, y = x(D, C)) : (c = null, a = null);
366
171
  }
172
+ else {
173
+ var A = c.ownerDocument;
174
+ c != A.body && c != A.documentElement && O.overflow != "visible" && (y = T(c));
367
175
  }
368
- } else {
369
- var doc = parent.ownerDocument;
370
- if (parent != doc.body && parent != doc.documentElement && parentComputedStyle.overflow != "visible") {
371
- parentRect = getBoundingClientRect(parent);
372
- }
373
- }
374
- if (parentRect) {
375
- intersectionRect = computeRectIntersection(parentRect, intersectionRect);
176
+ if (y && (a = v(y, a)), !a)
177
+ break;
178
+ c = c && I(c);
376
179
  }
377
- if (!intersectionRect)
378
- break;
379
- parent = parent && getParentNode(parent);
380
- }
381
- return intersectionRect;
382
- };
383
- IntersectionObserver2.prototype._getRootRect = function() {
384
- var rootRect;
385
- if (this.root && !isDoc(this.root)) {
386
- rootRect = getBoundingClientRect(this.root);
387
- } else {
388
- var doc = isDoc(this.root) ? this.root : document2;
389
- var html = doc.documentElement;
390
- var body = doc.body;
391
- rootRect = {
180
+ return a;
181
+ }
182
+ }, l.prototype._getRootRect = function() {
183
+ var t;
184
+ if (this.root && !L(this.root))
185
+ t = T(this.root);
186
+ else {
187
+ var n = L(this.root) ? this.root : r, o = n.documentElement, a = n.body;
188
+ t = {
392
189
  top: 0,
393
190
  left: 0,
394
- right: html.clientWidth || body.clientWidth,
395
- width: html.clientWidth || body.clientWidth,
396
- bottom: html.clientHeight || body.clientHeight,
397
- height: html.clientHeight || body.clientHeight
191
+ right: o.clientWidth || a.clientWidth,
192
+ width: o.clientWidth || a.clientWidth,
193
+ bottom: o.clientHeight || a.clientHeight,
194
+ height: o.clientHeight || a.clientHeight
398
195
  };
399
196
  }
400
- return this._expandRectByRootMargin(rootRect);
401
- };
402
- IntersectionObserver2.prototype._expandRectByRootMargin = function(rect) {
403
- var margins = this._rootMarginValues.map(function(margin, i) {
404
- return margin.unit == "px" ? margin.value : margin.value * (i % 2 ? rect.width : rect.height) / 100;
405
- });
406
- var newRect = {
407
- top: rect.top - margins[0],
408
- right: rect.right + margins[1],
409
- bottom: rect.bottom + margins[2],
410
- left: rect.left - margins[3]
197
+ return this._expandRectByRootMargin(t);
198
+ }, l.prototype._expandRectByRootMargin = function(t) {
199
+ var n = this._rootMarginValues.map(function(a, c) {
200
+ return a.unit == "px" ? a.value : a.value * (c % 2 ? t.width : t.height) / 100;
201
+ }), o = {
202
+ top: t.top - n[0],
203
+ right: t.right + n[1],
204
+ bottom: t.bottom + n[2],
205
+ left: t.left - n[3]
411
206
  };
412
- newRect.width = newRect.right - newRect.left;
413
- newRect.height = newRect.bottom - newRect.top;
414
- return newRect;
415
- };
416
- IntersectionObserver2.prototype._hasCrossedThreshold = function(oldEntry, newEntry) {
417
- var oldRatio = oldEntry && oldEntry.isIntersecting ? oldEntry.intersectionRatio || 0 : -1;
418
- var newRatio = newEntry.isIntersecting ? newEntry.intersectionRatio || 0 : -1;
419
- if (oldRatio === newRatio)
420
- return;
421
- for (var i = 0; i < this.thresholds.length; i++) {
422
- var threshold = this.thresholds[i];
423
- if (threshold == oldRatio || threshold == newRatio || threshold < oldRatio !== threshold < newRatio) {
424
- return true;
207
+ return o.width = o.right - o.left, o.height = o.bottom - o.top, o;
208
+ }, l.prototype._hasCrossedThreshold = function(t, n) {
209
+ var o = t && t.isIntersecting ? t.intersectionRatio || 0 : -1, a = n.isIntersecting ? n.intersectionRatio || 0 : -1;
210
+ if (o !== a)
211
+ for (var c = 0; c < this.thresholds.length; c++) {
212
+ var E = this.thresholds[c];
213
+ if (E == o || E == a || E < o != E < a)
214
+ return !0;
425
215
  }
426
- }
427
- };
428
- IntersectionObserver2.prototype._rootIsInDom = function() {
429
- return !this.root || containsDeep(document2, this.root);
430
- };
431
- IntersectionObserver2.prototype._rootContainsTarget = function(target) {
432
- var rootDoc = this.root && (this.root.ownerDocument || this.root) || document2;
433
- return containsDeep(rootDoc, target) && (!this.root || rootDoc == target.ownerDocument);
434
- };
435
- IntersectionObserver2.prototype._registerInstance = function() {
436
- if (registry.indexOf(this) < 0) {
437
- registry.push(this);
438
- }
216
+ }, l.prototype._rootIsInDom = function() {
217
+ return !this.root || h(r, this.root);
218
+ }, l.prototype._rootContainsTarget = function(t) {
219
+ var n = this.root && (this.root.ownerDocument || this.root) || r;
220
+ return h(n, t) && (!this.root || n == t.ownerDocument);
221
+ }, l.prototype._registerInstance = function() {
222
+ s.indexOf(this) < 0 && s.push(this);
223
+ }, l.prototype._unregisterInstance = function() {
224
+ var t = s.indexOf(this);
225
+ t != -1 && s.splice(t, 1);
439
226
  };
440
- IntersectionObserver2.prototype._unregisterInstance = function() {
441
- var index = registry.indexOf(this);
442
- if (index != -1)
443
- registry.splice(index, 1);
444
- };
445
- function now() {
227
+ function _() {
446
228
  return window.performance && performance.now && performance.now();
447
229
  }
448
- function throttle(fn, timeout) {
449
- var timer = null;
230
+ function d(t, n) {
231
+ var o = null;
450
232
  return function() {
451
- if (!timer) {
452
- timer = setTimeout(function() {
453
- fn();
454
- timer = null;
455
- }, timeout);
456
- }
233
+ o || (o = setTimeout(function() {
234
+ t(), o = null;
235
+ }, n));
457
236
  };
458
237
  }
459
- function addEvent(node, event, fn, opt_useCapture) {
460
- if (typeof node.addEventListener == "function") {
461
- node.addEventListener(event, fn, opt_useCapture || false);
462
- } else if (typeof node.attachEvent == "function") {
463
- node.attachEvent("on" + event, fn);
464
- }
465
- }
466
- function removeEvent(node, event, fn, opt_useCapture) {
467
- if (typeof node.removeEventListener == "function") {
468
- node.removeEventListener(event, fn, opt_useCapture || false);
469
- } else if (typeof node.detatchEvent == "function") {
470
- node.detatchEvent("on" + event, fn);
471
- }
472
- }
473
- function computeRectIntersection(rect1, rect2) {
474
- var top = Math.max(rect1.top, rect2.top);
475
- var bottom = Math.min(rect1.bottom, rect2.bottom);
476
- var left = Math.max(rect1.left, rect2.left);
477
- var right = Math.min(rect1.right, rect2.right);
478
- var width = right - left;
479
- var height = bottom - top;
480
- return width >= 0 && height >= 0 && {
481
- top,
482
- bottom,
483
- left,
484
- right,
485
- width,
486
- height
238
+ function u(t, n, o, a) {
239
+ typeof t.addEventListener == "function" ? t.addEventListener(n, o, a || !1) : typeof t.attachEvent == "function" && t.attachEvent("on" + n, o);
240
+ }
241
+ function p(t, n, o, a) {
242
+ typeof t.removeEventListener == "function" ? t.removeEventListener(n, o, a || !1) : typeof t.detatchEvent == "function" && t.detatchEvent("on" + n, o);
243
+ }
244
+ function v(t, n) {
245
+ var o = Math.max(t.top, n.top), a = Math.min(t.bottom, n.bottom), c = Math.max(t.left, n.left), E = Math.min(t.right, n.right), y = E - c, O = a - o;
246
+ return y >= 0 && O >= 0 && {
247
+ top: o,
248
+ bottom: a,
249
+ left: c,
250
+ right: E,
251
+ width: y,
252
+ height: O
487
253
  } || null;
488
254
  }
489
- function getBoundingClientRect(el) {
490
- var rect;
255
+ function T(t) {
256
+ var n;
491
257
  try {
492
- rect = el.getBoundingClientRect();
493
- } catch (err) {
494
- }
495
- if (!rect)
496
- return getEmptyRect();
497
- if (!(rect.width && rect.height)) {
498
- rect = {
499
- top: rect.top,
500
- right: rect.right,
501
- bottom: rect.bottom,
502
- left: rect.left,
503
- width: rect.right - rect.left,
504
- height: rect.bottom - rect.top
505
- };
506
- }
507
- return rect;
508
- }
509
- function getEmptyRect() {
258
+ n = t.getBoundingClientRect();
259
+ } catch {
260
+ }
261
+ return n ? (n.width && n.height || (n = {
262
+ top: n.top,
263
+ right: n.right,
264
+ bottom: n.bottom,
265
+ left: n.left,
266
+ width: n.right - n.left,
267
+ height: n.bottom - n.top
268
+ }), n) : w();
269
+ }
270
+ function w() {
510
271
  return {
511
272
  top: 0,
512
273
  bottom: 0,
@@ -516,383 +277,262 @@ const DEFAULT_POSITIONING_OPTIONS = {
516
277
  height: 0
517
278
  };
518
279
  }
519
- function ensureDOMRect(rect) {
520
- if (!rect || "x" in rect) {
521
- return rect;
522
- }
523
- return {
524
- top: rect.top,
525
- y: rect.top,
526
- bottom: rect.bottom,
527
- left: rect.left,
528
- x: rect.left,
529
- right: rect.right,
530
- width: rect.width,
531
- height: rect.height
280
+ function m(t) {
281
+ return !t || "x" in t ? t : {
282
+ top: t.top,
283
+ y: t.top,
284
+ bottom: t.bottom,
285
+ left: t.left,
286
+ x: t.left,
287
+ right: t.right,
288
+ width: t.width,
289
+ height: t.height
532
290
  };
533
291
  }
534
- function convertFromParentRect(parentBoundingRect, parentIntersectionRect) {
535
- var top = parentIntersectionRect.top - parentBoundingRect.top;
536
- var left = parentIntersectionRect.left - parentBoundingRect.left;
292
+ function x(t, n) {
293
+ var o = n.top - t.top, a = n.left - t.left;
537
294
  return {
538
- top,
539
- left,
540
- height: parentIntersectionRect.height,
541
- width: parentIntersectionRect.width,
542
- bottom: top + parentIntersectionRect.height,
543
- right: left + parentIntersectionRect.width
295
+ top: o,
296
+ left: a,
297
+ height: n.height,
298
+ width: n.width,
299
+ bottom: o + n.height,
300
+ right: a + n.width
544
301
  };
545
302
  }
546
- function containsDeep(parent, child) {
547
- var node = child;
548
- while (node) {
549
- if (node == parent)
550
- return true;
551
- node = getParentNode(node);
303
+ function h(t, n) {
304
+ for (var o = n; o; ) {
305
+ if (o == t)
306
+ return !0;
307
+ o = I(o);
552
308
  }
553
- return false;
309
+ return !1;
554
310
  }
555
- function getParentNode(node) {
556
- var parent = node.parentNode;
557
- if (node.nodeType == 9 && node != document2) {
558
- return getFrameElement(node);
559
- }
560
- if (parent && parent.assignedSlot) {
561
- parent = parent.assignedSlot.parentNode;
562
- }
563
- if (parent && parent.nodeType == 11 && parent.host) {
564
- return parent.host;
565
- }
566
- return parent;
311
+ function I(t) {
312
+ var n = t.parentNode;
313
+ return t.nodeType == 9 && t != r ? e(t) : (n && n.assignedSlot && (n = n.assignedSlot.parentNode), n && n.nodeType == 11 && n.host ? n.host : n);
567
314
  }
568
- function isDoc(node) {
569
- return node && node.nodeType === 9;
315
+ function L(t) {
316
+ return t && t.nodeType === 9;
570
317
  }
571
- window.IntersectionObserver = IntersectionObserver2;
572
- window.IntersectionObserverEntry = IntersectionObserverEntry2;
318
+ window.IntersectionObserver = l, window.IntersectionObserverEntry = b;
573
319
  })();
574
- var eventemitter3 = { exports: {} };
575
- (function(module) {
576
- var has = Object.prototype.hasOwnProperty, prefix = "~";
577
- function Events() {
578
- }
579
- if (Object.create) {
580
- Events.prototype = Object.create(null);
581
- if (!new Events().__proto__)
582
- prefix = false;
320
+ var S = { exports: {} };
321
+ (function(e) {
322
+ var r = Object.prototype.hasOwnProperty, s = "~";
323
+ function f() {
583
324
  }
584
- function EE(fn, context, once) {
585
- this.fn = fn;
586
- this.context = context;
587
- this.once = once || false;
325
+ Object.create && (f.prototype = /* @__PURE__ */ Object.create(null), new f().__proto__ || (s = !1));
326
+ function g(d, u, p) {
327
+ this.fn = d, this.context = u, this.once = p || !1;
588
328
  }
589
- function addListener(emitter, event, fn, context, once) {
590
- if (typeof fn !== "function") {
329
+ function b(d, u, p, v, T) {
330
+ if (typeof p != "function")
591
331
  throw new TypeError("The listener must be a function");
592
- }
593
- var listener = new EE(fn, context || emitter, once), evt = prefix ? prefix + event : event;
594
- if (!emitter._events[evt])
595
- emitter._events[evt] = listener, emitter._eventsCount++;
596
- else if (!emitter._events[evt].fn)
597
- emitter._events[evt].push(listener);
598
- else
599
- emitter._events[evt] = [emitter._events[evt], listener];
600
- return emitter;
332
+ var w = new g(p, v || d, T), m = s ? s + u : u;
333
+ return d._events[m] ? d._events[m].fn ? d._events[m] = [d._events[m], w] : d._events[m].push(w) : (d._events[m] = w, d._eventsCount++), d;
601
334
  }
602
- function clearEvent(emitter, evt) {
603
- if (--emitter._eventsCount === 0)
604
- emitter._events = new Events();
605
- else
606
- delete emitter._events[evt];
335
+ function l(d, u) {
336
+ --d._eventsCount === 0 ? d._events = new f() : delete d._events[u];
607
337
  }
608
- function EventEmitter() {
609
- this._events = new Events();
610
- this._eventsCount = 0;
338
+ function _() {
339
+ this._events = new f(), this._eventsCount = 0;
611
340
  }
612
- EventEmitter.prototype.eventNames = function eventNames() {
613
- var names = [], events, name;
341
+ _.prototype.eventNames = function() {
342
+ var u = [], p, v;
614
343
  if (this._eventsCount === 0)
615
- return names;
616
- for (name in events = this._events) {
617
- if (has.call(events, name))
618
- names.push(prefix ? name.slice(1) : name);
619
- }
620
- if (Object.getOwnPropertySymbols) {
621
- return names.concat(Object.getOwnPropertySymbols(events));
622
- }
623
- return names;
624
- };
625
- EventEmitter.prototype.listeners = function listeners(event) {
626
- var evt = prefix ? prefix + event : event, handlers = this._events[evt];
627
- if (!handlers)
344
+ return u;
345
+ for (v in p = this._events)
346
+ r.call(p, v) && u.push(s ? v.slice(1) : v);
347
+ return Object.getOwnPropertySymbols ? u.concat(Object.getOwnPropertySymbols(p)) : u;
348
+ }, _.prototype.listeners = function(u) {
349
+ var p = s ? s + u : u, v = this._events[p];
350
+ if (!v)
628
351
  return [];
629
- if (handlers.fn)
630
- return [handlers.fn];
631
- for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
632
- ee[i] = handlers[i].fn;
633
- }
634
- return ee;
635
- };
636
- EventEmitter.prototype.listenerCount = function listenerCount(event) {
637
- var evt = prefix ? prefix + event : event, listeners = this._events[evt];
638
- if (!listeners)
639
- return 0;
640
- if (listeners.fn)
641
- return 1;
642
- return listeners.length;
643
- };
644
- EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
645
- var evt = prefix ? prefix + event : event;
646
- if (!this._events[evt])
647
- return false;
648
- var listeners = this._events[evt], len = arguments.length, args, i;
649
- if (listeners.fn) {
650
- if (listeners.once)
651
- this.removeListener(event, listeners.fn, void 0, true);
652
- switch (len) {
352
+ if (v.fn)
353
+ return [v.fn];
354
+ for (var T = 0, w = v.length, m = new Array(w); T < w; T++)
355
+ m[T] = v[T].fn;
356
+ return m;
357
+ }, _.prototype.listenerCount = function(u) {
358
+ var p = s ? s + u : u, v = this._events[p];
359
+ return v ? v.fn ? 1 : v.length : 0;
360
+ }, _.prototype.emit = function(u, p, v, T, w, m) {
361
+ var x = s ? s + u : u;
362
+ if (!this._events[x])
363
+ return !1;
364
+ var h = this._events[x], I = arguments.length, L, t;
365
+ if (h.fn) {
366
+ switch (h.once && this.removeListener(u, h.fn, void 0, !0), I) {
653
367
  case 1:
654
- return listeners.fn.call(listeners.context), true;
368
+ return h.fn.call(h.context), !0;
655
369
  case 2:
656
- return listeners.fn.call(listeners.context, a1), true;
370
+ return h.fn.call(h.context, p), !0;
657
371
  case 3:
658
- return listeners.fn.call(listeners.context, a1, a2), true;
372
+ return h.fn.call(h.context, p, v), !0;
659
373
  case 4:
660
- return listeners.fn.call(listeners.context, a1, a2, a3), true;
374
+ return h.fn.call(h.context, p, v, T), !0;
661
375
  case 5:
662
- return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
376
+ return h.fn.call(h.context, p, v, T, w), !0;
663
377
  case 6:
664
- return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
378
+ return h.fn.call(h.context, p, v, T, w, m), !0;
665
379
  }
666
- for (i = 1, args = new Array(len - 1); i < len; i++) {
667
- args[i - 1] = arguments[i];
668
- }
669
- listeners.fn.apply(listeners.context, args);
380
+ for (t = 1, L = new Array(I - 1); t < I; t++)
381
+ L[t - 1] = arguments[t];
382
+ h.fn.apply(h.context, L);
670
383
  } else {
671
- var length = listeners.length, j;
672
- for (i = 0; i < length; i++) {
673
- if (listeners[i].once)
674
- this.removeListener(event, listeners[i].fn, void 0, true);
675
- switch (len) {
384
+ var n = h.length, o;
385
+ for (t = 0; t < n; t++)
386
+ switch (h[t].once && this.removeListener(u, h[t].fn, void 0, !0), I) {
676
387
  case 1:
677
- listeners[i].fn.call(listeners[i].context);
388
+ h[t].fn.call(h[t].context);
678
389
  break;
679
390
  case 2:
680
- listeners[i].fn.call(listeners[i].context, a1);
391
+ h[t].fn.call(h[t].context, p);
681
392
  break;
682
393
  case 3:
683
- listeners[i].fn.call(listeners[i].context, a1, a2);
394
+ h[t].fn.call(h[t].context, p, v);
684
395
  break;
685
396
  case 4:
686
- listeners[i].fn.call(listeners[i].context, a1, a2, a3);
397
+ h[t].fn.call(h[t].context, p, v, T);
687
398
  break;
688
399
  default:
689
- if (!args)
690
- for (j = 1, args = new Array(len - 1); j < len; j++) {
691
- args[j - 1] = arguments[j];
692
- }
693
- listeners[i].fn.apply(listeners[i].context, args);
400
+ if (!L)
401
+ for (o = 1, L = new Array(I - 1); o < I; o++)
402
+ L[o - 1] = arguments[o];
403
+ h[t].fn.apply(h[t].context, L);
694
404
  }
695
- }
696
405
  }
697
- return true;
698
- };
699
- EventEmitter.prototype.on = function on(event, fn, context) {
700
- return addListener(this, event, fn, context, false);
701
- };
702
- EventEmitter.prototype.once = function once(event, fn, context) {
703
- return addListener(this, event, fn, context, true);
704
- };
705
- EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
706
- var evt = prefix ? prefix + event : event;
707
- if (!this._events[evt])
708
- return this;
709
- if (!fn) {
710
- clearEvent(this, evt);
406
+ return !0;
407
+ }, _.prototype.on = function(u, p, v) {
408
+ return b(this, u, p, v, !1);
409
+ }, _.prototype.once = function(u, p, v) {
410
+ return b(this, u, p, v, !0);
411
+ }, _.prototype.removeListener = function(u, p, v, T) {
412
+ var w = s ? s + u : u;
413
+ if (!this._events[w])
711
414
  return this;
712
- }
713
- var listeners = this._events[evt];
714
- if (listeners.fn) {
715
- if (listeners.fn === fn && (!once || listeners.once) && (!context || listeners.context === context)) {
716
- clearEvent(this, evt);
717
- }
718
- } else {
719
- for (var i = 0, events = [], length = listeners.length; i < length; i++) {
720
- if (listeners[i].fn !== fn || once && !listeners[i].once || context && listeners[i].context !== context) {
721
- events.push(listeners[i]);
722
- }
723
- }
724
- if (events.length)
725
- this._events[evt] = events.length === 1 ? events[0] : events;
726
- else
727
- clearEvent(this, evt);
728
- }
729
- return this;
730
- };
731
- EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
732
- var evt;
733
- if (event) {
734
- evt = prefix ? prefix + event : event;
735
- if (this._events[evt])
736
- clearEvent(this, evt);
737
- } else {
738
- this._events = new Events();
739
- this._eventsCount = 0;
415
+ if (!p)
416
+ return l(this, w), this;
417
+ var m = this._events[w];
418
+ if (m.fn)
419
+ m.fn === p && (!T || m.once) && (!v || m.context === v) && l(this, w);
420
+ else {
421
+ for (var x = 0, h = [], I = m.length; x < I; x++)
422
+ (m[x].fn !== p || T && !m[x].once || v && m[x].context !== v) && h.push(m[x]);
423
+ h.length ? this._events[w] = h.length === 1 ? h[0] : h : l(this, w);
740
424
  }
741
425
  return this;
742
- };
743
- EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
744
- EventEmitter.prototype.addListener = EventEmitter.prototype.on;
745
- EventEmitter.prefixed = prefix;
746
- EventEmitter.EventEmitter = EventEmitter;
747
- {
748
- module.exports = EventEmitter;
749
- }
750
- })(eventemitter3);
751
- var __defProp2 = Object.defineProperty;
752
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
753
- var __decorateClass = (decorators, target, key, kind) => {
754
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
755
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
756
- if (decorator = decorators[i])
757
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
758
- if (kind && result)
759
- __defProp2(target, key, result);
760
- return result;
426
+ }, _.prototype.removeAllListeners = function(u) {
427
+ var p;
428
+ return u ? (p = s ? s + u : u, this._events[p] && l(this, p)) : (this._events = new f(), this._eventsCount = 0), this;
429
+ }, _.prototype.off = _.prototype.removeListener, _.prototype.addListener = _.prototype.on, _.prefixed = s, _.EventEmitter = _, e.exports = _;
430
+ })(S);
431
+ var G = Object.defineProperty, z = Object.getOwnPropertyDescriptor, W = (e, r, s, f) => {
432
+ for (var g = f > 1 ? void 0 : f ? z(r, s) : r, b = e.length - 1, l; b >= 0; b--)
433
+ (l = e[b]) && (g = (f ? l(r, s, g) : l(g)) || g);
434
+ return f && g && G(r, s, g), g;
761
435
  };
762
- const NAVBAR_HEIGHT = 60;
763
- const _PositioningService = class {
764
- static on(eventName, handler) {
765
- _PositioningService.events.on(eventName, handler);
766
- }
767
- static off(eventName, handler) {
768
- _PositioningService.events.off(eventName, handler);
769
- }
770
- static once(eventName, handler) {
771
- _PositioningService.events.once(eventName, handler);
772
- }
773
- static checkCollisions(element, otherElements) {
774
- const otherElementsList = otherElements || Array.from(_PositioningService.elements.keys());
775
- const bounds = element.getBoundingClientRect();
776
- const collisions = [];
777
- for (const otherElement of otherElementsList) {
778
- if (otherElement !== element) {
779
- const otherBounds = otherElement.getBoundingClientRect();
780
- if (otherBounds.left <= bounds.right && otherBounds.right >= bounds.left && otherBounds.top <= bounds.bottom && otherBounds.bottom >= bounds.top) {
781
- collisions.push(otherElement);
782
- }
436
+ const B = 60;
437
+ var M;
438
+ const i = (M = class {
439
+ static on(e, r) {
440
+ i.events.on(e, r);
441
+ }
442
+ static off(e, r) {
443
+ i.events.off(e, r);
444
+ }
445
+ static once(e, r) {
446
+ i.events.once(e, r);
447
+ }
448
+ static checkCollisions(e, r) {
449
+ const s = r || Array.from(i.elements.keys()), f = e.getBoundingClientRect(), g = [];
450
+ for (const b of s)
451
+ if (b !== e) {
452
+ const l = b.getBoundingClientRect();
453
+ l.left <= f.right && l.right >= f.left && l.top <= f.bottom && l.bottom >= f.top && g.push(b);
783
454
  }
784
- }
785
- if (collisions.length) {
786
- _PositioningService.onElementIntersection(element, collisions);
787
- }
455
+ g.length && i.onElementIntersection(e, g);
788
456
  }
789
- static isPositioned(element) {
790
- return _PositioningService.elements.has(element);
457
+ static isPositioned(e) {
458
+ return i.elements.has(e);
791
459
  }
792
- static getPositioningOptions(element) {
793
- if (_PositioningService.elements.has(element)) {
794
- return _PositioningService.elements.get(element);
795
- }
796
- return null;
460
+ static getPositioningOptions(e) {
461
+ return i.elements.has(e) ? i.elements.get(e) : null;
797
462
  }
798
- static position(element, options = {}) {
799
- const opts = __spreadValues(__spreadValues({}, DEFAULT_POSITIONING_OPTIONS), options);
800
- let e = element;
801
- while (e !== document.body) {
802
- e = e.parentElement;
803
- if (e.classList.contains("sps-focused-task")) {
804
- opts.scrollParent = e;
805
- if (!_PositioningService.registeredScrollParents.has(e)) {
806
- _PositioningService.registeredScrollParents.add(e);
807
- e.addEventListener("scroll", _PositioningService.update);
808
- }
463
+ static position(e, r = {}) {
464
+ const s = {
465
+ ...V,
466
+ ...r
467
+ };
468
+ let f = e;
469
+ for (; f !== document.body; )
470
+ if (f = f.parentElement, f.classList.contains("sps-focused-task")) {
471
+ s.scrollParent = f, i.registeredScrollParents.has(f) || (i.registeredScrollParents.add(f), f.addEventListener("scroll", i.update));
809
472
  break;
810
473
  }
811
- }
812
- element.style.visibility = "hidden";
813
- if (_PositioningService.elements.size === 0) {
814
- window.addEventListener("resize", _PositioningService.update);
815
- window.addEventListener("scroll", _PositioningService.update);
816
- }
817
- if (!opts.relativeTo) {
818
- throw new Error("You must provide an element for the relativeTo option to position an element.");
819
- }
820
- _PositioningService.elements.set(element, opts);
821
- onNextTick(() => {
822
- _PositioningService.fixElementPosition(element);
823
- _PositioningService.viewportObserver.observe(element);
824
- element.style.visibility = "";
825
- _PositioningService.checkCollisions(element);
474
+ if (e.style.visibility = "hidden", i.elements.size === 0 && (window.addEventListener("resize", i.update), window.addEventListener("scroll", i.update)), !s.relativeTo)
475
+ throw new Error(
476
+ "You must provide an element for the relativeTo option to position an element."
477
+ );
478
+ i.elements.set(e, s), U(() => {
479
+ i.fixElementPosition(e), i.viewportObserver.observe(e), e.style.visibility = "", i.checkCollisions(e);
826
480
  });
827
481
  }
828
- static release(element) {
829
- if (_PositioningService.elements.has(element)) {
830
- _PositioningService.clearStyles(element);
831
- const options = _PositioningService.elements.get(element);
832
- if (options.scrollParent) {
833
- options.scrollParent.removeEventListener("scroll", _PositioningService.update);
834
- _PositioningService.registeredScrollParents.delete(options.scrollParent);
835
- }
836
- _PositioningService.elements.delete(element);
837
- if (_PositioningService.elements.size === 0) {
838
- window.removeEventListener("resize", _PositioningService.update);
839
- window.removeEventListener("scroll", _PositioningService.update);
840
- }
841
- _PositioningService.viewportObserver.unobserve(element);
482
+ static release(e) {
483
+ if (i.elements.has(e)) {
484
+ i.clearStyles(e);
485
+ const r = i.elements.get(e);
486
+ r.scrollParent && (r.scrollParent.removeEventListener("scroll", i.update), i.registeredScrollParents.delete(r.scrollParent)), i.elements.delete(e), i.elements.size === 0 && (window.removeEventListener("resize", i.update), window.removeEventListener("scroll", i.update)), i.viewportObserver.unobserve(e);
842
487
  }
843
488
  }
844
489
  static releaseAll() {
845
- for (const element of _PositioningService.elements.keys()) {
846
- _PositioningService.release(element);
847
- }
490
+ for (const e of i.elements.keys())
491
+ i.release(e);
848
492
  }
849
- static refresh(element) {
850
- if (_PositioningService.elements.has(element)) {
851
- _PositioningService.clearStyles(element);
852
- _PositioningService.fixElementPosition(element);
853
- _PositioningService.checkCollisions(element);
854
- }
493
+ static refresh(e) {
494
+ i.elements.has(e) && (i.clearStyles(e), i.fixElementPosition(e), i.checkCollisions(e));
855
495
  }
856
496
  static refreshAll() {
857
- for (const element of _PositioningService.elements.keys()) {
858
- _PositioningService.refresh(element);
859
- }
497
+ for (const e of i.elements.keys())
498
+ i.refresh(e);
860
499
  }
861
- static reposition(element, newOptions) {
862
- if (_PositioningService.elements.has(element)) {
863
- const options = _PositioningService.elements.get(element);
864
- _PositioningService.elements.set(element, Object.assign(options, newOptions));
865
- _PositioningService.refresh(element);
500
+ static reposition(e, r) {
501
+ if (i.elements.has(e)) {
502
+ const s = i.elements.get(e);
503
+ i.elements.set(e, Object.assign(s, r)), i.refresh(e);
866
504
  }
867
505
  }
868
- static onViewportIntersection(entries) {
869
- for (const entry of entries) {
870
- const entryCopy = Object.keys(IntersectionObserverEntry.prototype).reduce((copy, key) => __spreadProps(__spreadValues({}, copy), {
871
- [key]: entry[key]
872
- }), {});
873
- entryCopy.rootBounds = entryCopy.rootBounds || _PositioningService.getRootBounds();
874
- _PositioningService.events.emit("viewportIntersection", Object.freeze(entryCopy));
506
+ static onViewportIntersection(e) {
507
+ for (const r of e) {
508
+ const s = Object.keys(IntersectionObserverEntry.prototype).reduce(
509
+ (f, g) => ({
510
+ ...f,
511
+ [g]: r[g]
512
+ }),
513
+ {}
514
+ );
515
+ s.rootBounds = s.rootBounds || i.getRootBounds(), i.events.emit("viewportIntersection", Object.freeze(s));
875
516
  }
876
517
  }
877
- static onElementIntersection(target, intersectingWith) {
878
- _PositioningService.events.emit("elementIntersection", { target, intersectingWith });
518
+ static onElementIntersection(e, r) {
519
+ i.events.emit("elementIntersection", { target: e, intersectingWith: r });
879
520
  }
880
521
  static getRootBounds() {
881
- const rootWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
882
- const rootHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
522
+ const e = Math.max(document.documentElement.clientWidth, window.innerWidth || 0), r = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
883
523
  return {
884
524
  x: 0,
885
- y: NAVBAR_HEIGHT,
525
+ y: B,
886
526
  left: 0,
887
- top: NAVBAR_HEIGHT,
888
- right: rootWidth,
889
- bottom: rootHeight,
890
- height: rootHeight - NAVBAR_HEIGHT,
891
- width: rootWidth
527
+ top: B,
528
+ right: e,
529
+ bottom: r,
530
+ height: r - B,
531
+ width: e
892
532
  };
893
533
  }
894
- static clearStyles(element) {
895
- Object.assign(element.style, {
534
+ static clearStyles(e) {
535
+ Object.assign(e.style, {
896
536
  position: "",
897
537
  width: "",
898
538
  top: "",
@@ -903,161 +543,140 @@ const _PositioningService = class {
903
543
  zIndex: ""
904
544
  });
905
545
  }
906
- static fixElementPosition(element, options) {
907
- if (!this.elements.has(element)) {
546
+ static fixElementPosition(e, r) {
547
+ if (!this.elements.has(e))
908
548
  return;
909
- }
910
- const opts = options || this.elements.get(element);
911
- const rootBounds = this.getRootBounds();
912
- const positionedElementBounds = element.getBoundingClientRect();
913
- const relativeTargetBounds = opts.relativeTo.getBoundingClientRect();
914
- const { width } = opts.useRelativeTargetWidth ? relativeTargetBounds : positionedElementBounds;
915
- Object.assign(element.style, {
916
- minWidth: `${width}px`,
549
+ const s = r || this.elements.get(e), f = this.getRootBounds(), g = e.getBoundingClientRect(), b = s.relativeTo.getBoundingClientRect(), { width: l } = s.useRelativeTargetWidth ? b : g;
550
+ Object.assign(e.style, {
551
+ minWidth: `${l}px`,
917
552
  position: "fixed",
918
- zIndex: opts.zIndex || ""
553
+ zIndex: s.zIndex || ""
919
554
  });
920
- let top;
921
- let left;
922
- const positionRelativeToTarget = opts.position.split(" ");
923
- const offsetA = opts.offsets[0] || 0;
924
- const offsetB = opts.offsets[1] || 0;
925
- top = 0;
926
- left = 0;
927
- switch (positionRelativeToTarget[0]) {
555
+ let _, d;
556
+ const u = s.position.split(" "), p = s.offsets[0] || 0, v = s.offsets[1] || 0;
557
+ switch (_ = 0, d = 0, u[0]) {
928
558
  case "top":
929
- top = relativeTargetBounds.top - positionedElementBounds.height - offsetA;
559
+ _ = b.top - g.height - p;
930
560
  break;
931
561
  case "left":
932
- left = relativeTargetBounds.left - width - offsetA;
562
+ d = b.left - l - p;
933
563
  break;
934
564
  case "right":
935
- left = relativeTargetBounds.right + offsetA;
565
+ d = b.right + p;
936
566
  break;
937
567
  case "bottom":
938
- top = relativeTargetBounds.bottom + offsetA;
568
+ _ = b.bottom + p;
939
569
  break;
940
570
  default:
941
- throw new Error(`${opts.position} is not a valid position`);
571
+ throw new Error(`${s.position} is not a valid position`);
942
572
  }
943
- switch (positionRelativeToTarget[1]) {
573
+ switch (u[1]) {
944
574
  case "left":
945
- left = relativeTargetBounds.left - offsetB;
575
+ d = b.left - v;
946
576
  break;
947
577
  case "top":
948
- top = relativeTargetBounds.top - offsetB;
578
+ _ = b.top - v;
949
579
  break;
950
580
  case "middle":
951
- if (positionRelativeToTarget[0] === "top" || positionRelativeToTarget[0] === "bottom") {
952
- left = relativeTargetBounds.left + relativeTargetBounds.width / 2 - width / 2 + offsetB;
953
- } else if (positionRelativeToTarget[0] === "left" || positionRelativeToTarget[0] === "right") {
954
- top = relativeTargetBounds.top + relativeTargetBounds.height / 2 - positionedElementBounds.height / 2 + offsetB;
955
- }
581
+ u[0] === "top" || u[0] === "bottom" ? d = b.left + b.width / 2 - l / 2 + v : (u[0] === "left" || u[0] === "right") && (_ = b.top + b.height / 2 - g.height / 2 + v);
956
582
  break;
957
583
  case "bottom":
958
- top = relativeTargetBounds.bottom - positionedElementBounds.height + offsetB;
584
+ _ = b.bottom - g.height + v;
959
585
  break;
960
586
  case "right":
961
- left = relativeTargetBounds.right - width + offsetB;
587
+ d = b.right - l + v;
962
588
  break;
963
589
  default:
964
- throw new Error(`${opts.position} is not a valid position`);
590
+ throw new Error(`${s.position} is not a valid position`);
965
591
  }
966
- const bottom = top + positionedElementBounds.height;
967
- const right = left + positionedElementBounds.width;
968
- const topPx = `${Math.round(top)}px`;
969
- const bottomPx = `${Math.round(rootBounds.bottom - bottom)}px`;
970
- const leftPx = `${Math.round(left)}px`;
971
- const rightPx = `${Math.round(rootBounds.right - right)}px`;
972
- switch (opts.anchor) {
973
- case PositionAnchor.TOP_LEFT:
974
- Object.assign(element.style, {
975
- top: topPx,
592
+ const T = _ + g.height, w = d + g.width, m = `${Math.round(_)}px`, x = `${Math.round(f.bottom - T)}px`, h = `${Math.round(d)}px`, I = `${Math.round(f.right - w)}px`;
593
+ switch (s.anchor) {
594
+ case P.TOP_LEFT:
595
+ Object.assign(e.style, {
596
+ top: m,
976
597
  bottom: "auto",
977
- left: leftPx,
598
+ left: h,
978
599
  right: "auto"
979
600
  });
980
601
  break;
981
- case PositionAnchor.TOP_RIGHT:
982
- Object.assign(element.style, {
983
- top: topPx,
602
+ case P.TOP_RIGHT:
603
+ Object.assign(e.style, {
604
+ top: m,
984
605
  bottom: "auto",
985
606
  left: "auto",
986
- right: rightPx
607
+ right: I
987
608
  });
988
609
  break;
989
- case PositionAnchor.BOTTOM_LEFT:
990
- Object.assign(element.style, {
610
+ case P.BOTTOM_LEFT:
611
+ Object.assign(e.style, {
991
612
  top: "auto",
992
- bottom: bottomPx,
993
- left: leftPx,
613
+ bottom: x,
614
+ left: h,
994
615
  right: "auto"
995
616
  });
996
617
  break;
997
- case PositionAnchor.BOTTOM_RIGHT:
998
- Object.assign(element.style, {
618
+ case P.BOTTOM_RIGHT:
619
+ Object.assign(e.style, {
999
620
  top: "auto",
1000
- bottom: bottomPx,
621
+ bottom: x,
1001
622
  left: "auto",
1002
- right: rightPx
623
+ right: I
1003
624
  });
1004
625
  break;
1005
626
  }
1006
627
  }
1007
- static update(event) {
1008
- const elements = _PositioningService.elements.entries();
1009
- const updatedElements = [];
1010
- for (const [element, options] of elements) {
1011
- if (!event || event.target === document || event.target === options.scrollParent || event.target === window) {
1012
- _PositioningService.fixElementPosition(element, options);
1013
- _PositioningService.checkCollisions(element, updatedElements);
1014
- updatedElements.push(element);
1015
- }
1016
- }
628
+ static update(e) {
629
+ const r = i.elements.entries(), s = [];
630
+ for (const [f, g] of r)
631
+ (!e || e.target === document || e.target === g.scrollParent || e.target === window) && (i.fixElementPosition(f, g), i.checkCollisions(f, s), s.push(f));
1017
632
  }
1018
- on(eventName, handler) {
1019
- _PositioningService.on(eventName, handler);
633
+ on(e, r) {
634
+ i.on(e, r);
1020
635
  }
1021
- off(eventName, handler) {
1022
- _PositioningService.off(eventName, handler);
636
+ off(e, r) {
637
+ i.off(e, r);
1023
638
  }
1024
- once(eventName, handler) {
1025
- _PositioningService.once(eventName, handler);
639
+ once(e, r) {
640
+ i.once(e, r);
1026
641
  }
1027
- isPositioned(element) {
1028
- return _PositioningService.isPositioned(element);
642
+ isPositioned(e) {
643
+ return i.isPositioned(e);
1029
644
  }
1030
- getPositioningOptions(element) {
1031
- return _PositioningService.getPositioningOptions(element);
645
+ getPositioningOptions(e) {
646
+ return i.getPositioningOptions(e);
1032
647
  }
1033
- position(element, options = {}) {
1034
- _PositioningService.position(element, options);
648
+ position(e, r = {}) {
649
+ i.position(e, r);
1035
650
  }
1036
- release(element) {
1037
- _PositioningService.release(element);
651
+ release(e) {
652
+ i.release(e);
1038
653
  }
1039
654
  releaseAll() {
1040
- _PositioningService.releaseAll();
655
+ i.releaseAll();
1041
656
  }
1042
- refresh(element) {
1043
- _PositioningService.refresh(element);
657
+ refresh(e) {
658
+ i.refresh(e);
1044
659
  }
1045
660
  refreshAll() {
1046
- _PositioningService.refreshAll();
661
+ i.refreshAll();
1047
662
  }
1048
- reposition(element, newOptions) {
1049
- _PositioningService.reposition(element, newOptions);
663
+ reposition(e, r) {
664
+ i.reposition(e, r);
1050
665
  }
666
+ }, k(M, "elements", /* @__PURE__ */ new Map()), k(M, "registeredScrollParents", /* @__PURE__ */ new Set()), k(M, "events", new S.exports.EventEmitter()), k(M, "viewportObserver", new IntersectionObserver(
667
+ i.onViewportIntersection,
668
+ {
669
+ rootMargin: `-${B}px 0px 0px`,
670
+ threshold: 1
671
+ }
672
+ )), M);
673
+ let $ = i;
674
+ W([
675
+ j
676
+ ], $, "update", 1);
677
+ export {
678
+ V as DEFAULT_POSITIONING_OPTIONS,
679
+ F as Position,
680
+ P as PositionAnchor,
681
+ $ as PositioningService
1051
682
  };
1052
- let PositioningService = _PositioningService;
1053
- PositioningService.elements = new Map();
1054
- PositioningService.registeredScrollParents = new Set();
1055
- PositioningService.events = new eventemitter3.exports.EventEmitter();
1056
- PositioningService.viewportObserver = new IntersectionObserver(_PositioningService.onViewportIntersection, {
1057
- rootMargin: `-${NAVBAR_HEIGHT}px 0px 0px`,
1058
- threshold: 1
1059
- });
1060
- __decorateClass([
1061
- lockedToAnimationFrames
1062
- ], PositioningService, "update", 1);
1063
- export { DEFAULT_POSITIONING_OPTIONS, Position, PositionAnchor, PositioningService };