@zag-js/tooltip 0.0.0-dev-20220413174154 → 0.0.0-dev-20220416104915

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/dist/index.mjs CHANGED
@@ -17,149 +17,77 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- var __objRest = (source, exclude) => {
21
- var target = {};
22
- for (var prop in source)
23
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
- target[prop] = source[prop];
25
- if (source != null && __getOwnPropSymbols)
26
- for (var prop of __getOwnPropSymbols(source)) {
27
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
- target[prop] = source[prop];
29
- }
30
- return target;
31
- };
32
- var __async = (__this, __arguments, generator) => {
33
- return new Promise((resolve, reject) => {
34
- var fulfilled = (value) => {
35
- try {
36
- step(generator.next(value));
37
- } catch (e) {
38
- reject(e);
39
- }
40
- };
41
- var rejected = (value) => {
42
- try {
43
- step(generator.throw(value));
44
- } catch (e) {
45
- reject(e);
46
- }
47
- };
48
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
49
- step((generator = generator.apply(__this, __arguments)).next());
50
- });
51
- };
52
20
 
53
- // ../../utilities/dom/src/attrs.ts
21
+ // ../../utilities/dom/dist/index.mjs
54
22
  var dataAttr = (guard) => {
55
23
  return guard ? "" : void 0;
56
24
  };
57
-
58
- // ../../utilities/dom/src/computed-style.ts
59
- var styleCache = /* @__PURE__ */ new WeakMap();
25
+ function getStyleCache() {
26
+ ;
27
+ globalThis.__styleCache__ = globalThis.__styleCache__ || /* @__PURE__ */ new WeakMap();
28
+ return globalThis.__styleCache__;
29
+ }
60
30
  function getComputedStyle2(el) {
61
31
  var _a;
62
32
  if (!el)
63
33
  return {};
64
- let style = styleCache.get(el);
34
+ const cache = getStyleCache();
35
+ let style = cache.get(el);
65
36
  if (!style) {
66
37
  const win = (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
67
38
  style = win.getComputedStyle(el);
68
- styleCache.set(el, style);
39
+ cache.set(el, style);
69
40
  }
70
41
  return style;
71
42
  }
72
-
73
- // ../../utilities/dom/src/next-tick.ts
74
43
  function raf(fn) {
75
44
  const id = globalThis.requestAnimationFrame(fn);
76
45
  return function cleanup() {
77
46
  globalThis.cancelAnimationFrame(id);
78
47
  };
79
48
  }
80
-
81
- // ../../utilities/core/src/array.ts
82
- function clear(v) {
83
- while (v.length > 0)
84
- v.pop();
85
- return v;
86
- }
87
-
88
- // ../../utilities/core/src/functions.ts
89
- var runIfFn = (v, ...a) => {
90
- const res = typeof v === "function" ? v(...a) : v;
91
- return res != null ? res : void 0;
92
- };
93
- var cast = (v) => v;
94
49
  var noop = () => {
95
50
  };
96
- var pipe = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
97
- var uuid = /* @__PURE__ */ (() => {
98
- let id = 0;
99
- return () => {
100
- id++;
101
- return id.toString(36);
102
- };
103
- })();
104
-
105
- // ../../utilities/core/src/guard.ts
106
- var ua = (v) => isDom() && v.test(navigator.userAgent);
107
- var isDom = () => !!(typeof window !== "undefined");
108
- var isSafari = () => ua(/^((?!chrome|android).)*safari/i);
109
- var isArray = (v) => Array.isArray(v);
110
- var isBoolean = (v) => v === true || v === false;
111
- var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
112
- var isNumber = (v) => typeof v === "number" && !Number.isNaN(v);
113
- var isString = (v) => typeof v === "string";
114
- var isFunction = (v) => typeof v === "function";
115
-
116
- // ../../utilities/core/src/warning.ts
117
- function warn(...a) {
118
- const m = a.length === 1 ? a[0] : a[1];
119
- const c = a.length === 2 ? a[0] : true;
120
- if (c && void 0 !== "production") {
121
- console.warn(m);
122
- }
51
+ function getListenerElements() {
52
+ ;
53
+ globalThis.__listenerElements__ = globalThis.__listenerElements__ || /* @__PURE__ */ new Map();
54
+ return globalThis.__listenerElements__;
123
55
  }
124
- function invariant(...a) {
125
- const m = a.length === 1 ? a[0] : a[1];
126
- const c = a.length === 2 ? a[0] : true;
127
- if (c && void 0 !== "production") {
128
- throw new Error(m);
129
- }
56
+ function getListenerCache() {
57
+ ;
58
+ globalThis.__listenerCache__ = globalThis.__listenerCache__ || /* @__PURE__ */ new Map();
59
+ return globalThis.__listenerCache__;
130
60
  }
131
-
132
- // ../../utilities/dom/src/event-bus.ts
133
- var listenerElements = /* @__PURE__ */ new Map();
134
- var listenerCache = /* @__PURE__ */ new Map();
135
61
  function globalEventBus(node, type, handler, options) {
136
62
  var _a;
137
63
  if (!node)
138
64
  return noop;
139
- const hash2 = JSON.stringify({ type, options });
65
+ const hash = JSON.stringify({ type, options });
66
+ const listenerElements = getListenerElements();
67
+ const listenerCache = getListenerCache();
140
68
  const group = listenerElements.get(node);
141
69
  if (!listenerElements.has(node)) {
142
- const group2 = /* @__PURE__ */ new Map([[hash2, /* @__PURE__ */ new Set([handler])]]);
70
+ const group2 = /* @__PURE__ */ new Map([[hash, /* @__PURE__ */ new Set([handler])]]);
143
71
  listenerElements.set(node, group2);
144
- } else if (group == null ? void 0 : group.has(hash2)) {
145
- (_a = group == null ? void 0 : group.get(hash2)) == null ? void 0 : _a.add(handler);
72
+ } else if (group == null ? void 0 : group.has(hash)) {
73
+ (_a = group == null ? void 0 : group.get(hash)) == null ? void 0 : _a.add(handler);
146
74
  } else {
147
- group == null ? void 0 : group.set(hash2, /* @__PURE__ */ new Set([handler]));
75
+ group == null ? void 0 : group.set(hash, /* @__PURE__ */ new Set([handler]));
148
76
  }
149
77
  function attach(node2) {
150
78
  var _a2, _b;
151
79
  function listener(event) {
152
80
  var _a3;
153
81
  const group2 = listenerElements.get(node2);
154
- (_a3 = group2 == null ? void 0 : group2.get(hash2)) == null ? void 0 : _a3.forEach((fn) => fn(event));
82
+ (_a3 = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _a3.forEach((fn) => fn(event));
155
83
  }
156
84
  if (!(listenerCache == null ? void 0 : listenerCache.has(node2))) {
157
- listenerCache.set(node2, /* @__PURE__ */ new Map([[hash2, listener]]));
85
+ listenerCache.set(node2, /* @__PURE__ */ new Map([[hash, listener]]));
158
86
  node2.addEventListener(type, listener, options);
159
87
  return;
160
88
  }
161
- if (!((_a2 = listenerCache == null ? void 0 : listenerCache.get(node2)) == null ? void 0 : _a2.has(hash2))) {
162
- (_b = listenerCache.get(node2)) == null ? void 0 : _b.set(hash2, listener);
89
+ if (!((_a2 = listenerCache == null ? void 0 : listenerCache.get(node2)) == null ? void 0 : _a2.has(hash))) {
90
+ (_b = listenerCache.get(node2)) == null ? void 0 : _b.set(hash, listener);
163
91
  node2.addEventListener(type, listener, options);
164
92
  }
165
93
  }
@@ -169,12 +97,12 @@ function globalEventBus(node, type, handler, options) {
169
97
  if (!listenerElements.has(node))
170
98
  return;
171
99
  const group2 = listenerElements.get(node);
172
- (_a2 = group2 == null ? void 0 : group2.get(hash2)) == null ? void 0 : _a2.delete(handler);
173
- if (((_b = group2 == null ? void 0 : group2.get(hash2)) == null ? void 0 : _b.size) === 0) {
174
- const listener = (_c = listenerCache.get(node)) == null ? void 0 : _c.get(hash2);
100
+ (_a2 = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _a2.delete(handler);
101
+ if (((_b = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _b.size) === 0) {
102
+ const listener = (_c = listenerCache.get(node)) == null ? void 0 : _c.get(hash);
175
103
  node.removeEventListener(type, listener, options);
176
- group2 == null ? void 0 : group2.delete(hash2);
177
- (_d = listenerCache.get(node)) == null ? void 0 : _d.delete(hash2);
104
+ group2 == null ? void 0 : group2.delete(hash);
105
+ (_d = listenerCache.get(node)) == null ? void 0 : _d.delete(hash);
178
106
  if ((group2 == null ? void 0 : group2.size) === 0) {
179
107
  listenerElements.delete(node);
180
108
  listenerCache.delete(node);
@@ -182,11 +110,9 @@ function globalEventBus(node, type, handler, options) {
182
110
  }
183
111
  };
184
112
  }
185
-
186
- // ../../utilities/dom/src/listener.ts
187
113
  var t = (v) => Object.prototype.toString.call(v).slice(8, -1);
188
114
  var isRef = (v) => t(v) === "Object" && "current" in v;
189
- var runIfFn2 = (fn) => t(fn) === "Function" ? fn() : fn;
115
+ var runIfFn = (fn) => t(fn) === "Function" ? fn() : fn;
190
116
  var isTouchEvent = (v) => t(v) === "Object" && !!v.touches;
191
117
  var fallback = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
192
118
  function extractInfo(event, type = "page") {
@@ -199,7 +125,7 @@ function extractInfo(event, type = "page") {
199
125
  };
200
126
  }
201
127
  function addDomEvent(target, event, listener, options) {
202
- const node = isRef(target) ? target.current : runIfFn2(target);
128
+ const node = isRef(target) ? target.current : runIfFn(target);
203
129
  return globalEventBus(node, event, listener, options);
204
130
  }
205
131
  function addPointerEvent(target, event, listener, options) {
@@ -217,8 +143,8 @@ function filterPrimaryPointer(fn) {
217
143
  return (event) => {
218
144
  var _a;
219
145
  const win = (_a = event.view) != null ? _a : window;
220
- const isMouseEvent = event instanceof win.MouseEvent;
221
- const isPrimary = !isMouseEvent || isMouseEvent && event.button === 0;
146
+ const isMouseEvent2 = event instanceof win.MouseEvent;
147
+ const isPrimary = !isMouseEvent2 || isMouseEvent2 && event.button === 0;
222
148
  if (isPrimary)
223
149
  fn(event);
224
150
  };
@@ -251,8 +177,6 @@ function getEventName(evt) {
251
177
  return mouseEventNames[evt];
252
178
  return evt;
253
179
  }
254
-
255
- // ../../utilities/dom/src/query.ts
256
180
  function getOwnerDocument(el) {
257
181
  var _a;
258
182
  if (isWindow(el))
@@ -278,8 +202,6 @@ function isHTMLElement(v) {
278
202
  function isWindow(value) {
279
203
  return (value == null ? void 0 : value.toString()) === "[object Window]";
280
204
  }
281
-
282
- // ../../utilities/dom/src/scrollable.ts
283
205
  function isScrollParent(el) {
284
206
  const { overflow, overflowX, overflowY } = getComputedStyle2(el);
285
207
  return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
@@ -303,8 +225,6 @@ function getScrollParents(el, list = []) {
303
225
  return parents;
304
226
  return parents.concat(getScrollParents(getParent(target)));
305
227
  }
306
-
307
- // ../../utilities/dom/src/visually-hidden.ts
308
228
  var visuallyHiddenStyle = {
309
229
  border: "0",
310
230
  clip: "rect(0 0 0 0)",
@@ -317,1247 +237,14 @@ var visuallyHiddenStyle = {
317
237
  whiteSpace: "nowrap",
318
238
  wordWrap: "normal"
319
239
  };
320
-
321
- // ../../utilities/dom/src/pointerlock.ts
322
240
  function addPointerlockChangeListener(doc, fn) {
323
241
  return addDomEvent(doc, "pointerlockchange", fn, false);
324
242
  }
325
243
 
326
- // ../../utilities/dom/src/rect-observer.ts
327
- var observedElements = /* @__PURE__ */ new Map();
328
- function observeElementRect(el, fn) {
329
- const data = observedElements.get(el);
330
- if (!data) {
331
- observedElements.set(el, { rect: {}, callbacks: [fn] });
332
- if (observedElements.size === 1) {
333
- rafId = requestAnimationFrame(runLoop);
334
- }
335
- } else {
336
- data.callbacks.push(fn);
337
- fn(el.getBoundingClientRect());
338
- }
339
- return function unobserve() {
340
- const data2 = observedElements.get(el);
341
- if (!data2)
342
- return;
343
- const index = data2.callbacks.indexOf(fn);
344
- if (index > -1) {
345
- data2.callbacks.splice(index, 1);
346
- }
347
- if (data2.callbacks.length === 0) {
348
- observedElements.delete(el);
349
- if (observedElements.size === 0) {
350
- cancelAnimationFrame(rafId);
351
- }
352
- }
353
- };
354
- }
355
- var rafId;
356
- function runLoop() {
357
- const changedRectsData = [];
358
- observedElements.forEach((data, element) => {
359
- const newRect = element.getBoundingClientRect();
360
- if (!isEqual(data.rect, newRect)) {
361
- data.rect = newRect;
362
- changedRectsData.push(data);
363
- }
364
- });
365
- changedRectsData.forEach((data) => {
366
- data.callbacks.forEach((callback) => callback(data.rect));
367
- });
368
- rafId = requestAnimationFrame(runLoop);
369
- }
370
- function isEqual(rect1, rect2) {
371
- return rect1.width === rect2.width && rect1.height === rect2.height && rect1.top === rect2.top && rect1.right === rect2.right && rect1.bottom === rect2.bottom && rect1.left === rect2.left;
372
- }
373
-
374
- // ../../../node_modules/@floating-ui/core/dist/floating-ui.core.esm.js
375
- function getSide(placement) {
376
- return placement.split("-")[0];
377
- }
378
- function getAlignment(placement) {
379
- return placement.split("-")[1];
380
- }
381
- function getMainAxisFromPlacement(placement) {
382
- return ["top", "bottom"].includes(getSide(placement)) ? "x" : "y";
383
- }
384
- function getLengthFromAxis(axis) {
385
- return axis === "y" ? "height" : "width";
386
- }
387
- function computeCoordsFromPlacement(_ref, placement, rtl) {
388
- let {
389
- reference,
390
- floating
391
- } = _ref;
392
- const commonX = reference.x + reference.width / 2 - floating.width / 2;
393
- const commonY = reference.y + reference.height / 2 - floating.height / 2;
394
- const mainAxis = getMainAxisFromPlacement(placement);
395
- const length = getLengthFromAxis(mainAxis);
396
- const commonAlign = reference[length] / 2 - floating[length] / 2;
397
- const side = getSide(placement);
398
- const isVertical = mainAxis === "x";
399
- let coords;
400
- switch (side) {
401
- case "top":
402
- coords = {
403
- x: commonX,
404
- y: reference.y - floating.height
405
- };
406
- break;
407
- case "bottom":
408
- coords = {
409
- x: commonX,
410
- y: reference.y + reference.height
411
- };
412
- break;
413
- case "right":
414
- coords = {
415
- x: reference.x + reference.width,
416
- y: commonY
417
- };
418
- break;
419
- case "left":
420
- coords = {
421
- x: reference.x - floating.width,
422
- y: commonY
423
- };
424
- break;
425
- default:
426
- coords = {
427
- x: reference.x,
428
- y: reference.y
429
- };
430
- }
431
- switch (getAlignment(placement)) {
432
- case "start":
433
- coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
434
- break;
435
- case "end":
436
- coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
437
- break;
438
- }
439
- return coords;
440
- }
441
- var computePosition = (reference, floating, config) => __async(void 0, null, function* () {
442
- const {
443
- placement = "bottom",
444
- strategy = "absolute",
445
- middleware = [],
446
- platform: platform2
447
- } = config;
448
- const rtl = yield platform2.isRTL == null ? void 0 : platform2.isRTL(floating);
449
- if (void 0 !== "production") {
450
- if (platform2 == null) {
451
- console.error(["Floating UI: `platform` property was not passed to config. If you", "want to use Floating UI on the web, install @floating-ui/dom", "instead of the /core package. Otherwise, you can create your own", "`platform`: https://floating-ui.com/docs/platform"].join(" "));
452
- }
453
- if (middleware.filter((_ref) => {
454
- let {
455
- name
456
- } = _ref;
457
- return name === "autoPlacement" || name === "flip";
458
- }).length > 1) {
459
- throw new Error(["Floating UI: duplicate `flip` and/or `autoPlacement`", "middleware detected. This will lead to an infinite loop. Ensure only", "one of either has been passed to the `middleware` array."].join(" "));
460
- }
461
- }
462
- let rects = yield platform2.getElementRects({
463
- reference,
464
- floating,
465
- strategy
466
- });
467
- let {
468
- x,
469
- y
470
- } = computeCoordsFromPlacement(rects, placement, rtl);
471
- let statefulPlacement = placement;
472
- let middlewareData = {};
473
- let _debug_loop_count_ = 0;
474
- for (let i = 0; i < middleware.length; i++) {
475
- if (void 0 !== "production") {
476
- _debug_loop_count_++;
477
- if (_debug_loop_count_ > 100) {
478
- throw new Error(["Floating UI: The middleware lifecycle appears to be", "running in an infinite loop. This is usually caused by a `reset`", "continually being returned without a break condition."].join(" "));
479
- }
480
- }
481
- const {
482
- name,
483
- fn
484
- } = middleware[i];
485
- const {
486
- x: nextX,
487
- y: nextY,
488
- data,
489
- reset
490
- } = yield fn({
491
- x,
492
- y,
493
- initialPlacement: placement,
494
- placement: statefulPlacement,
495
- strategy,
496
- middlewareData,
497
- rects,
498
- platform: platform2,
499
- elements: {
500
- reference,
501
- floating
502
- }
503
- });
504
- x = nextX != null ? nextX : x;
505
- y = nextY != null ? nextY : y;
506
- middlewareData = __spreadProps(__spreadValues({}, middlewareData), {
507
- [name]: __spreadValues(__spreadValues({}, middlewareData[name]), data)
508
- });
509
- if (reset) {
510
- if (typeof reset === "object") {
511
- if (reset.placement) {
512
- statefulPlacement = reset.placement;
513
- }
514
- if (reset.rects) {
515
- rects = reset.rects === true ? yield platform2.getElementRects({
516
- reference,
517
- floating,
518
- strategy
519
- }) : reset.rects;
520
- }
521
- ({
522
- x,
523
- y
524
- } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
525
- }
526
- i = -1;
527
- continue;
528
- }
529
- }
530
- return {
531
- x,
532
- y,
533
- placement: statefulPlacement,
534
- strategy,
535
- middlewareData
536
- };
537
- });
538
- function expandPaddingObject(padding) {
539
- return __spreadValues({
540
- top: 0,
541
- right: 0,
542
- bottom: 0,
543
- left: 0
544
- }, padding);
545
- }
546
- function getSideObjectFromPadding(padding) {
547
- return typeof padding !== "number" ? expandPaddingObject(padding) : {
548
- top: padding,
549
- right: padding,
550
- bottom: padding,
551
- left: padding
552
- };
553
- }
554
- function rectToClientRect(rect) {
555
- return __spreadProps(__spreadValues({}, rect), {
556
- top: rect.y,
557
- left: rect.x,
558
- right: rect.x + rect.width,
559
- bottom: rect.y + rect.height
560
- });
561
- }
562
- function detectOverflow(middlewareArguments, options) {
563
- return __async(this, null, function* () {
564
- var _await$platform$isEle;
565
- if (options === void 0) {
566
- options = {};
567
- }
568
- const {
569
- x,
570
- y,
571
- platform: platform2,
572
- rects,
573
- elements,
574
- strategy
575
- } = middlewareArguments;
576
- const {
577
- boundary = "clippingAncestors",
578
- rootBoundary = "viewport",
579
- elementContext = "floating",
580
- altBoundary = false,
581
- padding = 0
582
- } = options;
583
- const paddingObject = getSideObjectFromPadding(padding);
584
- const altContext = elementContext === "floating" ? "reference" : "floating";
585
- const element = elements[altBoundary ? altContext : elementContext];
586
- const clippingClientRect = rectToClientRect(yield platform2.getClippingRect({
587
- element: ((_await$platform$isEle = yield platform2.isElement == null ? void 0 : platform2.isElement(element)) != null ? _await$platform$isEle : true) ? element : element.contextElement || (yield platform2.getDocumentElement == null ? void 0 : platform2.getDocumentElement(elements.floating)),
588
- boundary,
589
- rootBoundary,
590
- strategy
591
- }));
592
- const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? yield platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
593
- rect: elementContext === "floating" ? __spreadProps(__spreadValues({}, rects.floating), {
594
- x,
595
- y
596
- }) : rects.reference,
597
- offsetParent: yield platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating),
598
- strategy
599
- }) : rects[elementContext]);
600
- return {
601
- top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
602
- bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
603
- left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
604
- right: elementClientRect.right - clippingClientRect.right + paddingObject.right
605
- };
606
- });
607
- }
608
- var min = Math.min;
609
- var max = Math.max;
610
- function within(min$1, value, max$1) {
611
- return max(min$1, min(value, max$1));
612
- }
613
- var arrow = (options) => ({
614
- name: "arrow",
615
- options,
616
- fn(middlewareArguments) {
617
- return __async(this, null, function* () {
618
- const {
619
- element,
620
- padding = 0
621
- } = options != null ? options : {};
622
- const {
623
- x,
624
- y,
625
- placement,
626
- rects,
627
- platform: platform2
628
- } = middlewareArguments;
629
- if (element == null) {
630
- if (void 0 !== "production") {
631
- console.warn("Floating UI: No `element` was passed to the `arrow` middleware.");
632
- }
633
- return {};
634
- }
635
- const paddingObject = getSideObjectFromPadding(padding);
636
- const coords = {
637
- x,
638
- y
639
- };
640
- const axis = getMainAxisFromPlacement(placement);
641
- const length = getLengthFromAxis(axis);
642
- const arrowDimensions = yield platform2.getDimensions(element);
643
- const minProp = axis === "y" ? "top" : "left";
644
- const maxProp = axis === "y" ? "bottom" : "right";
645
- const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
646
- const startDiff = coords[axis] - rects.reference[axis];
647
- const arrowOffsetParent = yield platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(element);
648
- const clientSize = arrowOffsetParent ? axis === "y" ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
649
- const centerToReference = endDiff / 2 - startDiff / 2;
650
- const min3 = paddingObject[minProp];
651
- const max3 = clientSize - arrowDimensions[length] - paddingObject[maxProp];
652
- const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
653
- const offset2 = within(min3, center, max3);
654
- return {
655
- data: {
656
- [axis]: offset2,
657
- centerOffset: center - offset2
658
- }
659
- };
660
- });
661
- }
662
- });
663
- var hash$1 = {
664
- left: "right",
665
- right: "left",
666
- bottom: "top",
667
- top: "bottom"
668
- };
669
- function getOppositePlacement(placement) {
670
- return placement.replace(/left|right|bottom|top/g, (matched) => hash$1[matched]);
671
- }
672
- function getAlignmentSides(placement, rects, rtl) {
673
- if (rtl === void 0) {
674
- rtl = false;
675
- }
676
- const alignment = getAlignment(placement);
677
- const mainAxis = getMainAxisFromPlacement(placement);
678
- const length = getLengthFromAxis(mainAxis);
679
- let mainAlignmentSide = mainAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
680
- if (rects.reference[length] > rects.floating[length]) {
681
- mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
682
- }
683
- return {
684
- main: mainAlignmentSide,
685
- cross: getOppositePlacement(mainAlignmentSide)
686
- };
687
- }
688
- var hash = {
689
- start: "end",
690
- end: "start"
691
- };
692
- function getOppositeAlignmentPlacement(placement) {
693
- return placement.replace(/start|end/g, (matched) => hash[matched]);
694
- }
695
- function getExpandedPlacements(placement) {
696
- const oppositePlacement = getOppositePlacement(placement);
697
- return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
698
- }
699
- var flip = function(options) {
700
- if (options === void 0) {
701
- options = {};
702
- }
703
- return {
704
- name: "flip",
705
- options,
706
- fn(middlewareArguments) {
707
- return __async(this, null, function* () {
708
- var _middlewareData$flip;
709
- const {
710
- placement,
711
- middlewareData,
712
- rects,
713
- initialPlacement,
714
- platform: platform2,
715
- elements
716
- } = middlewareArguments;
717
- const _a2 = options, {
718
- mainAxis: checkMainAxis = true,
719
- crossAxis: checkCrossAxis = true,
720
- fallbackPlacements: specifiedFallbackPlacements,
721
- fallbackStrategy = "bestFit",
722
- flipAlignment = true
723
- } = _a2, detectOverflowOptions = __objRest(_a2, [
724
- "mainAxis",
725
- "crossAxis",
726
- "fallbackPlacements",
727
- "fallbackStrategy",
728
- "flipAlignment"
729
- ]);
730
- const side = getSide(placement);
731
- const isBasePlacement = side === initialPlacement;
732
- const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
733
- const placements = [initialPlacement, ...fallbackPlacements];
734
- const overflow = yield detectOverflow(middlewareArguments, detectOverflowOptions);
735
- const overflows = [];
736
- let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
737
- if (checkMainAxis) {
738
- overflows.push(overflow[side]);
739
- }
740
- if (checkCrossAxis) {
741
- const {
742
- main,
743
- cross
744
- } = getAlignmentSides(placement, rects, yield platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
745
- overflows.push(overflow[main], overflow[cross]);
746
- }
747
- overflowsData = [...overflowsData, {
748
- placement,
749
- overflows
750
- }];
751
- if (!overflows.every((side2) => side2 <= 0)) {
752
- var _middlewareData$flip$, _middlewareData$flip2;
753
- const nextIndex = ((_middlewareData$flip$ = (_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) != null ? _middlewareData$flip$ : 0) + 1;
754
- const nextPlacement = placements[nextIndex];
755
- if (nextPlacement) {
756
- return {
757
- data: {
758
- index: nextIndex,
759
- overflows: overflowsData
760
- },
761
- reset: {
762
- placement: nextPlacement
763
- }
764
- };
765
- }
766
- let resetPlacement = "bottom";
767
- switch (fallbackStrategy) {
768
- case "bestFit": {
769
- var _overflowsData$slice$;
770
- const placement2 = (_overflowsData$slice$ = overflowsData.slice().sort((a, b) => a.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0) - b.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0))[0]) == null ? void 0 : _overflowsData$slice$.placement;
771
- if (placement2) {
772
- resetPlacement = placement2;
773
- }
774
- break;
775
- }
776
- case "initialPlacement":
777
- resetPlacement = initialPlacement;
778
- break;
779
- }
780
- if (placement !== resetPlacement) {
781
- return {
782
- reset: {
783
- placement: resetPlacement
784
- }
785
- };
786
- }
787
- }
788
- return {};
789
- });
790
- }
791
- };
792
- };
793
- function convertValueToCoords(placement, rects, value, rtl) {
794
- if (rtl === void 0) {
795
- rtl = false;
796
- }
797
- const side = getSide(placement);
798
- const alignment = getAlignment(placement);
799
- const isVertical = getMainAxisFromPlacement(placement) === "x";
800
- const mainAxisMulti = ["left", "top"].includes(side) ? -1 : 1;
801
- const crossAxisMulti = rtl && isVertical ? -1 : 1;
802
- const rawValue = typeof value === "function" ? value(__spreadProps(__spreadValues({}, rects), {
803
- placement
804
- })) : value;
805
- const isNumber2 = typeof rawValue === "number";
806
- let {
807
- mainAxis,
808
- crossAxis,
809
- alignmentAxis
810
- } = isNumber2 ? {
811
- mainAxis: rawValue,
812
- crossAxis: 0,
813
- alignmentAxis: null
814
- } : __spreadValues({
815
- mainAxis: 0,
816
- crossAxis: 0,
817
- alignmentAxis: null
818
- }, rawValue);
819
- if (alignment && typeof alignmentAxis === "number") {
820
- crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
821
- }
822
- return isVertical ? {
823
- x: crossAxis * crossAxisMulti,
824
- y: mainAxis * mainAxisMulti
825
- } : {
826
- x: mainAxis * mainAxisMulti,
827
- y: crossAxis * crossAxisMulti
828
- };
829
- }
830
- var offset = function(value) {
831
- if (value === void 0) {
832
- value = 0;
833
- }
834
- return {
835
- name: "offset",
836
- options: value,
837
- fn(middlewareArguments) {
838
- return __async(this, null, function* () {
839
- const {
840
- x,
841
- y,
842
- placement,
843
- rects,
844
- platform: platform2,
845
- elements
846
- } = middlewareArguments;
847
- const diffCoords = convertValueToCoords(placement, rects, value, yield platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
848
- return {
849
- x: x + diffCoords.x,
850
- y: y + diffCoords.y,
851
- data: diffCoords
852
- };
853
- });
854
- }
855
- };
856
- };
857
- function getCrossAxis(axis) {
858
- return axis === "x" ? "y" : "x";
859
- }
860
- var shift = function(options) {
861
- if (options === void 0) {
862
- options = {};
863
- }
864
- return {
865
- name: "shift",
866
- options,
867
- fn(middlewareArguments) {
868
- return __async(this, null, function* () {
869
- const {
870
- x,
871
- y,
872
- placement
873
- } = middlewareArguments;
874
- const _a2 = options, {
875
- mainAxis: checkMainAxis = true,
876
- crossAxis: checkCrossAxis = false,
877
- limiter = {
878
- fn: (_ref) => {
879
- let {
880
- x: x2,
881
- y: y2
882
- } = _ref;
883
- return {
884
- x: x2,
885
- y: y2
886
- };
887
- }
888
- }
889
- } = _a2, detectOverflowOptions = __objRest(_a2, [
890
- "mainAxis",
891
- "crossAxis",
892
- "limiter"
893
- ]);
894
- const coords = {
895
- x,
896
- y
897
- };
898
- const overflow = yield detectOverflow(middlewareArguments, detectOverflowOptions);
899
- const mainAxis = getMainAxisFromPlacement(getSide(placement));
900
- const crossAxis = getCrossAxis(mainAxis);
901
- let mainAxisCoord = coords[mainAxis];
902
- let crossAxisCoord = coords[crossAxis];
903
- if (checkMainAxis) {
904
- const minSide = mainAxis === "y" ? "top" : "left";
905
- const maxSide = mainAxis === "y" ? "bottom" : "right";
906
- const min3 = mainAxisCoord + overflow[minSide];
907
- const max3 = mainAxisCoord - overflow[maxSide];
908
- mainAxisCoord = within(min3, mainAxisCoord, max3);
909
- }
910
- if (checkCrossAxis) {
911
- const minSide = crossAxis === "y" ? "top" : "left";
912
- const maxSide = crossAxis === "y" ? "bottom" : "right";
913
- const min3 = crossAxisCoord + overflow[minSide];
914
- const max3 = crossAxisCoord - overflow[maxSide];
915
- crossAxisCoord = within(min3, crossAxisCoord, max3);
916
- }
917
- const limitedCoords = limiter.fn(__spreadProps(__spreadValues({}, middlewareArguments), {
918
- [mainAxis]: mainAxisCoord,
919
- [crossAxis]: crossAxisCoord
920
- }));
921
- return __spreadProps(__spreadValues({}, limitedCoords), {
922
- data: {
923
- x: limitedCoords.x - x,
924
- y: limitedCoords.y - y
925
- }
926
- });
927
- });
928
- }
929
- };
930
- };
931
- var size = function(options) {
932
- if (options === void 0) {
933
- options = {};
934
- }
935
- return {
936
- name: "size",
937
- options,
938
- fn(middlewareArguments) {
939
- return __async(this, null, function* () {
940
- const {
941
- placement,
942
- rects,
943
- platform: platform2,
944
- elements
945
- } = middlewareArguments;
946
- const _a2 = options, {
947
- apply
948
- } = _a2, detectOverflowOptions = __objRest(_a2, [
949
- "apply"
950
- ]);
951
- const overflow = yield detectOverflow(middlewareArguments, detectOverflowOptions);
952
- const side = getSide(placement);
953
- const alignment = getAlignment(placement);
954
- let heightSide;
955
- let widthSide;
956
- if (side === "top" || side === "bottom") {
957
- heightSide = side;
958
- widthSide = alignment === ((yield platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
959
- } else {
960
- widthSide = side;
961
- heightSide = alignment === "end" ? "top" : "bottom";
962
- }
963
- const xMin = max(overflow.left, 0);
964
- const xMax = max(overflow.right, 0);
965
- const yMin = max(overflow.top, 0);
966
- const yMax = max(overflow.bottom, 0);
967
- const dimensions = {
968
- height: rects.floating.height - (["left", "right"].includes(placement) ? 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom)) : overflow[heightSide]),
969
- width: rects.floating.width - (["top", "bottom"].includes(placement) ? 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right)) : overflow[widthSide])
970
- };
971
- const prevDimensions = yield platform2.getDimensions(elements.floating);
972
- apply == null ? void 0 : apply(__spreadValues(__spreadValues({}, dimensions), rects));
973
- const nextDimensions = yield platform2.getDimensions(elements.floating);
974
- if (prevDimensions.width !== nextDimensions.width || prevDimensions.height !== nextDimensions.height) {
975
- return {
976
- reset: {
977
- rects: true
978
- }
979
- };
980
- }
981
- return {};
982
- });
983
- }
984
- };
985
- };
986
-
987
- // ../../../node_modules/@floating-ui/dom/dist/floating-ui.dom.esm.js
988
- function isWindow2(value) {
989
- return value && value.document && value.location && value.alert && value.setInterval;
990
- }
991
- function getWindow(node) {
992
- if (node == null) {
993
- return window;
994
- }
995
- if (!isWindow2(node)) {
996
- const ownerDocument = node.ownerDocument;
997
- return ownerDocument ? ownerDocument.defaultView || window : window;
998
- }
999
- return node;
1000
- }
1001
- function getComputedStyle$1(element) {
1002
- return getWindow(element).getComputedStyle(element);
1003
- }
1004
- function getNodeName2(node) {
1005
- return isWindow2(node) ? "" : node ? (node.nodeName || "").toLowerCase() : "";
1006
- }
1007
- function isHTMLElement2(value) {
1008
- return value instanceof getWindow(value).HTMLElement;
1009
- }
1010
- function isElement(value) {
1011
- return value instanceof getWindow(value).Element;
1012
- }
1013
- function isNode(value) {
1014
- return value instanceof getWindow(value).Node;
1015
- }
1016
- function isShadowRoot(node) {
1017
- const OwnElement = getWindow(node).ShadowRoot;
1018
- return node instanceof OwnElement || node instanceof ShadowRoot;
1019
- }
1020
- function isOverflowElement(element) {
1021
- const {
1022
- overflow,
1023
- overflowX,
1024
- overflowY
1025
- } = getComputedStyle$1(element);
1026
- return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
1027
- }
1028
- function isTableElement(element) {
1029
- return ["table", "td", "th"].includes(getNodeName2(element));
1030
- }
1031
- function isContainingBlock(element) {
1032
- const isFirefox = navigator.userAgent.toLowerCase().includes("firefox");
1033
- const css = getComputedStyle$1(element);
1034
- return css.transform !== "none" || css.perspective !== "none" || css.contain === "paint" || ["transform", "perspective"].includes(css.willChange) || isFirefox && css.willChange === "filter" || isFirefox && (css.filter ? css.filter !== "none" : false);
1035
- }
1036
- function isLayoutViewport() {
1037
- return !/^((?!chrome|android).)*safari/i.test(navigator.userAgent);
1038
- }
1039
- var min2 = Math.min;
1040
- var max2 = Math.max;
1041
- var round = Math.round;
1042
- function getBoundingClientRect(element, includeScale, isFixedStrategy) {
1043
- if (includeScale === void 0) {
1044
- includeScale = false;
1045
- }
1046
- if (isFixedStrategy === void 0) {
1047
- isFixedStrategy = false;
1048
- }
1049
- const clientRect = element.getBoundingClientRect();
1050
- let scaleX = 1;
1051
- let scaleY = 1;
1052
- if (includeScale && isHTMLElement2(element)) {
1053
- scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
1054
- scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
1055
- }
1056
- const win = isElement(element) ? getWindow(element) : window;
1057
- const addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
1058
- const x = (clientRect.left + (addVisualOffsets ? win.visualViewport.offsetLeft : 0)) / scaleX;
1059
- const y = (clientRect.top + (addVisualOffsets ? win.visualViewport.offsetTop : 0)) / scaleY;
1060
- const width = clientRect.width / scaleX;
1061
- const height = clientRect.height / scaleY;
1062
- return {
1063
- width,
1064
- height,
1065
- top: y,
1066
- right: x + width,
1067
- bottom: y + height,
1068
- left: x,
1069
- x,
1070
- y
1071
- };
1072
- }
1073
- function getDocumentElement(node) {
1074
- return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
1075
- }
1076
- function getNodeScroll(element) {
1077
- if (isElement(element)) {
1078
- return {
1079
- scrollLeft: element.scrollLeft,
1080
- scrollTop: element.scrollTop
1081
- };
1082
- }
1083
- return {
1084
- scrollLeft: element.pageXOffset,
1085
- scrollTop: element.pageYOffset
1086
- };
1087
- }
1088
- function getWindowScrollBarX(element) {
1089
- return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
1090
- }
1091
- function isScaled(element) {
1092
- const rect = getBoundingClientRect(element);
1093
- return round(rect.width) !== element.offsetWidth || round(rect.height) !== element.offsetHeight;
1094
- }
1095
- function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1096
- const isOffsetParentAnElement = isHTMLElement2(offsetParent);
1097
- const documentElement = getDocumentElement(offsetParent);
1098
- const rect = getBoundingClientRect(element, isOffsetParentAnElement && isScaled(offsetParent), strategy === "fixed");
1099
- let scroll = {
1100
- scrollLeft: 0,
1101
- scrollTop: 0
1102
- };
1103
- const offsets = {
1104
- x: 0,
1105
- y: 0
1106
- };
1107
- if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== "fixed") {
1108
- if (getNodeName2(offsetParent) !== "body" || isOverflowElement(documentElement)) {
1109
- scroll = getNodeScroll(offsetParent);
1110
- }
1111
- if (isHTMLElement2(offsetParent)) {
1112
- const offsetRect = getBoundingClientRect(offsetParent, true);
1113
- offsets.x = offsetRect.x + offsetParent.clientLeft;
1114
- offsets.y = offsetRect.y + offsetParent.clientTop;
1115
- } else if (documentElement) {
1116
- offsets.x = getWindowScrollBarX(documentElement);
1117
- }
1118
- }
1119
- return {
1120
- x: rect.left + scroll.scrollLeft - offsets.x,
1121
- y: rect.top + scroll.scrollTop - offsets.y,
1122
- width: rect.width,
1123
- height: rect.height
1124
- };
1125
- }
1126
- function getParentNode(node) {
1127
- if (getNodeName2(node) === "html") {
1128
- return node;
1129
- }
1130
- return node.assignedSlot || node.parentNode || (isShadowRoot(node) ? node.host : null) || getDocumentElement(node);
1131
- }
1132
- function getTrueOffsetParent(element) {
1133
- if (!isHTMLElement2(element) || getComputedStyle(element).position === "fixed") {
1134
- return null;
1135
- }
1136
- return element.offsetParent;
1137
- }
1138
- function getContainingBlock(element) {
1139
- let currentNode = getParentNode(element);
1140
- if (isShadowRoot(currentNode)) {
1141
- currentNode = currentNode.host;
1142
- }
1143
- while (isHTMLElement2(currentNode) && !["html", "body"].includes(getNodeName2(currentNode))) {
1144
- if (isContainingBlock(currentNode)) {
1145
- return currentNode;
1146
- } else {
1147
- currentNode = currentNode.parentNode;
1148
- }
1149
- }
1150
- return null;
1151
- }
1152
- function getOffsetParent(element) {
1153
- const window2 = getWindow(element);
1154
- let offsetParent = getTrueOffsetParent(element);
1155
- while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === "static") {
1156
- offsetParent = getTrueOffsetParent(offsetParent);
1157
- }
1158
- if (offsetParent && (getNodeName2(offsetParent) === "html" || getNodeName2(offsetParent) === "body" && getComputedStyle(offsetParent).position === "static" && !isContainingBlock(offsetParent))) {
1159
- return window2;
1160
- }
1161
- return offsetParent || getContainingBlock(element) || window2;
1162
- }
1163
- function getDimensions(element) {
1164
- if (isHTMLElement2(element)) {
1165
- return {
1166
- width: element.offsetWidth,
1167
- height: element.offsetHeight
1168
- };
1169
- }
1170
- const rect = getBoundingClientRect(element);
1171
- return {
1172
- width: rect.width,
1173
- height: rect.height
1174
- };
1175
- }
1176
- function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1177
- let {
1178
- rect,
1179
- offsetParent,
1180
- strategy
1181
- } = _ref;
1182
- const isOffsetParentAnElement = isHTMLElement2(offsetParent);
1183
- const documentElement = getDocumentElement(offsetParent);
1184
- if (offsetParent === documentElement) {
1185
- return rect;
1186
- }
1187
- let scroll = {
1188
- scrollLeft: 0,
1189
- scrollTop: 0
1190
- };
1191
- const offsets = {
1192
- x: 0,
1193
- y: 0
1194
- };
1195
- if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== "fixed") {
1196
- if (getNodeName2(offsetParent) !== "body" || isOverflowElement(documentElement)) {
1197
- scroll = getNodeScroll(offsetParent);
1198
- }
1199
- if (isHTMLElement2(offsetParent)) {
1200
- const offsetRect = getBoundingClientRect(offsetParent, true);
1201
- offsets.x = offsetRect.x + offsetParent.clientLeft;
1202
- offsets.y = offsetRect.y + offsetParent.clientTop;
1203
- }
1204
- }
1205
- return __spreadProps(__spreadValues({}, rect), {
1206
- x: rect.x - scroll.scrollLeft + offsets.x,
1207
- y: rect.y - scroll.scrollTop + offsets.y
1208
- });
1209
- }
1210
- function getViewportRect(element, strategy) {
1211
- const win = getWindow(element);
1212
- const html = getDocumentElement(element);
1213
- const visualViewport = win.visualViewport;
1214
- let width = html.clientWidth;
1215
- let height = html.clientHeight;
1216
- let x = 0;
1217
- let y = 0;
1218
- if (visualViewport) {
1219
- width = visualViewport.width;
1220
- height = visualViewport.height;
1221
- const layoutViewport = isLayoutViewport();
1222
- if (layoutViewport || !layoutViewport && strategy === "fixed") {
1223
- x = visualViewport.offsetLeft;
1224
- y = visualViewport.offsetTop;
1225
- }
1226
- }
1227
- return {
1228
- width,
1229
- height,
1230
- x,
1231
- y
1232
- };
1233
- }
1234
- function getDocumentRect(element) {
1235
- var _element$ownerDocumen;
1236
- const html = getDocumentElement(element);
1237
- const scroll = getNodeScroll(element);
1238
- const body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
1239
- const width = max2(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
1240
- const height = max2(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
1241
- let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1242
- const y = -scroll.scrollTop;
1243
- if (getComputedStyle$1(body || html).direction === "rtl") {
1244
- x += max2(html.clientWidth, body ? body.clientWidth : 0) - width;
1245
- }
1246
- return {
1247
- width,
1248
- height,
1249
- x,
1250
- y
1251
- };
1252
- }
1253
- function getNearestOverflowAncestor(node) {
1254
- const parentNode = getParentNode(node);
1255
- if (["html", "body", "#document"].includes(getNodeName2(parentNode))) {
1256
- return node.ownerDocument.body;
1257
- }
1258
- if (isHTMLElement2(parentNode) && isOverflowElement(parentNode)) {
1259
- return parentNode;
1260
- }
1261
- return getNearestOverflowAncestor(parentNode);
1262
- }
1263
- function getOverflowAncestors(node, list) {
1264
- var _node$ownerDocument;
1265
- if (list === void 0) {
1266
- list = [];
1267
- }
1268
- const scrollableAncestor = getNearestOverflowAncestor(node);
1269
- const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
1270
- const win = getWindow(scrollableAncestor);
1271
- const target = isBody ? [win].concat(win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []) : scrollableAncestor;
1272
- const updatedList = list.concat(target);
1273
- return isBody ? updatedList : updatedList.concat(getOverflowAncestors(getParentNode(target)));
1274
- }
1275
- function contains(parent, child) {
1276
- const rootNode = child.getRootNode == null ? void 0 : child.getRootNode();
1277
- if (parent.contains(child)) {
1278
- return true;
1279
- } else if (rootNode && isShadowRoot(rootNode)) {
1280
- let next = child;
1281
- do {
1282
- if (next && parent === next) {
1283
- return true;
1284
- }
1285
- next = next.parentNode || next.host;
1286
- } while (next);
1287
- }
1288
- return false;
1289
- }
1290
- function getInnerBoundingClientRect(element, strategy) {
1291
- const clientRect = getBoundingClientRect(element, false, strategy === "fixed");
1292
- const top = clientRect.top + element.clientTop;
1293
- const left = clientRect.left + element.clientLeft;
1294
- return {
1295
- top,
1296
- left,
1297
- x: left,
1298
- y: top,
1299
- right: left + element.clientWidth,
1300
- bottom: top + element.clientHeight,
1301
- width: element.clientWidth,
1302
- height: element.clientHeight
1303
- };
1304
- }
1305
- function getClientRectFromClippingAncestor(element, clippingParent, strategy) {
1306
- if (clippingParent === "viewport") {
1307
- return rectToClientRect(getViewportRect(element, strategy));
1308
- }
1309
- if (isElement(clippingParent)) {
1310
- return getInnerBoundingClientRect(clippingParent, strategy);
1311
- }
1312
- return rectToClientRect(getDocumentRect(getDocumentElement(element)));
1313
- }
1314
- function getClippingAncestors(element) {
1315
- const clippingAncestors = getOverflowAncestors(element);
1316
- const canEscapeClipping = ["absolute", "fixed"].includes(getComputedStyle$1(element).position);
1317
- const clipperElement = canEscapeClipping && isHTMLElement2(element) ? getOffsetParent(element) : element;
1318
- if (!isElement(clipperElement)) {
1319
- return [];
1320
- }
1321
- return clippingAncestors.filter((clippingAncestors2) => isElement(clippingAncestors2) && contains(clippingAncestors2, clipperElement) && getNodeName2(clippingAncestors2) !== "body");
1322
- }
1323
- function getClippingRect(_ref) {
1324
- let {
1325
- element,
1326
- boundary,
1327
- rootBoundary,
1328
- strategy
1329
- } = _ref;
1330
- const mainClippingAncestors = boundary === "clippingAncestors" ? getClippingAncestors(element) : [].concat(boundary);
1331
- const clippingAncestors = [...mainClippingAncestors, rootBoundary];
1332
- const firstClippingAncestor = clippingAncestors[0];
1333
- const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1334
- const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1335
- accRect.top = max2(rect.top, accRect.top);
1336
- accRect.right = min2(rect.right, accRect.right);
1337
- accRect.bottom = min2(rect.bottom, accRect.bottom);
1338
- accRect.left = max2(rect.left, accRect.left);
1339
- return accRect;
1340
- }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1341
- return {
1342
- width: clippingRect.right - clippingRect.left,
1343
- height: clippingRect.bottom - clippingRect.top,
1344
- x: clippingRect.left,
1345
- y: clippingRect.top
1346
- };
1347
- }
1348
- var platform = {
1349
- getClippingRect,
1350
- convertOffsetParentRelativeRectToViewportRelativeRect,
1351
- isElement,
1352
- getDimensions,
1353
- getOffsetParent,
1354
- getDocumentElement,
1355
- getElementRects: (_ref) => {
1356
- let {
1357
- reference,
1358
- floating,
1359
- strategy
1360
- } = _ref;
1361
- return {
1362
- reference: getRectRelativeToOffsetParent(reference, getOffsetParent(floating), strategy),
1363
- floating: __spreadProps(__spreadValues({}, getDimensions(floating)), {
1364
- x: 0,
1365
- y: 0
1366
- })
1367
- };
1368
- },
1369
- getClientRects: (element) => Array.from(element.getClientRects()),
1370
- isRTL: (element) => getComputedStyle$1(element).direction === "rtl"
1371
- };
1372
- var computePosition2 = (reference, floating, options) => computePosition(reference, floating, __spreadValues({
1373
- platform
1374
- }, options));
1375
-
1376
- // ../../utilities/popper/src/auto-update.ts
1377
- function resolveOptions(option) {
1378
- if (isBoolean(option))
1379
- return { ancestorResize: option, ancestorScroll: option, referenceResize: option };
1380
- return Object.assign({ ancestorResize: true, ancestorScroll: true, referenceResize: true }, option);
1381
- }
1382
- function autoUpdate(reference, floating, update, options = false) {
1383
- const { ancestorScroll, ancestorResize, referenceResize } = resolveOptions(options);
1384
- const useAncestors = ancestorScroll || ancestorResize;
1385
- const ancestors = [];
1386
- if (useAncestors && isHTMLElement(reference)) {
1387
- ancestors.push(...getOverflowAncestors(reference));
1388
- }
1389
- function addResizeListeners() {
1390
- let cleanups = [observeElementRect(floating, update)];
1391
- if (referenceResize && isHTMLElement(reference)) {
1392
- cleanups.push(observeElementRect(reference, update));
1393
- }
1394
- cleanups.push(pipe(...ancestors.map((el) => addDomEvent(el, "resize", update))));
1395
- return () => cleanups.forEach((fn) => fn());
1396
- }
1397
- function addScrollListeners() {
1398
- return pipe(...ancestors.map((el) => addDomEvent(el, "scroll", update, { passive: true })));
1399
- }
1400
- return pipe(addResizeListeners(), addScrollListeners());
1401
- }
1402
-
1403
- // ../../utilities/popper/src/middleware.ts
1404
- var toVar = (value) => ({ variable: value, reference: `var(${value})` });
1405
- var cssVars = {
1406
- arrowShadowColor: toVar("--arrow-shadow-color"),
1407
- arrowSize: toVar("--arrow-size"),
1408
- arrowSizeHalf: toVar("--arrow-size-half"),
1409
- arrowBg: toVar("--arrow-background"),
1410
- transformOrigin: toVar("--transform-origin"),
1411
- arrowOffset: toVar("--arrow-offset"),
1412
- boxShadow: toVar("--arrow-box-shadow")
1413
- };
1414
- var transforms = {
1415
- top: "bottom center",
1416
- "top-start": "bottom left",
1417
- "top-end": "bottom right",
1418
- bottom: "top center",
1419
- "bottom-start": "top left",
1420
- "bottom-end": "top right",
1421
- left: "right center",
1422
- "left-start": "right top",
1423
- "left-end": "right bottom",
1424
- right: "left center",
1425
- "right-start": "left top",
1426
- "right-end": "left bottom"
1427
- };
1428
- var transformOrigin = {
1429
- name: "transformOrigin",
1430
- fn({ placement, elements }) {
1431
- const { floating } = elements;
1432
- floating.style.setProperty(cssVars.transformOrigin.variable, transforms[placement]);
1433
- return {
1434
- data: { transformOrigin: transforms[placement] }
1435
- };
1436
- }
1437
- };
1438
- var shiftArrow = (opts) => ({
1439
- name: "shiftArrow",
1440
- fn({ placement, middlewareData }) {
1441
- var _a;
1442
- const { element: arrow2 } = opts;
1443
- const { x, y } = (_a = middlewareData.arrow) != null ? _a : { x: 0, y: 0 };
1444
- const staticSide = {
1445
- top: "bottom",
1446
- right: "left",
1447
- bottom: "top",
1448
- left: "right"
1449
- }[placement.split("-")[0]];
1450
- Object.assign(arrow2.style, {
1451
- top: `${y}px`,
1452
- left: `${x}px`,
1453
- [staticSide]: cssVars.arrowOffset.reference,
1454
- [cssVars.boxShadow.variable]: getBoxShadow(placement)
1455
- });
1456
- return {};
1457
- }
1458
- });
1459
- function getBoxShadow(placement) {
1460
- if (placement.includes("top"))
1461
- return `1px 1px 1px 0 ${cssVars.arrowShadowColor.reference}`;
1462
- if (placement.includes("bottom"))
1463
- return `-1px -1px 1px 0 ${cssVars.arrowShadowColor.reference}`;
1464
- if (placement.includes("right"))
1465
- return `-1px 1px 1px 0 ${cssVars.arrowShadowColor.reference}`;
1466
- if (placement.includes("left"))
1467
- return `1px -1px 1px 0 ${cssVars.arrowShadowColor.reference}`;
1468
- }
1469
-
1470
- // ../../utilities/popper/src/get-placement.ts
1471
- var defaultOptions = {
1472
- strategy: "absolute",
1473
- placement: "bottom",
1474
- listeners: true,
1475
- gutter: 8,
1476
- flip: true,
1477
- sameWidth: false
1478
- };
1479
- function getPlacement(reference, floating, options = {}) {
1480
- var _a;
1481
- if (reference == null || floating == null)
1482
- return noop;
1483
- options = Object.assign({}, defaultOptions, options);
1484
- const middleware = [transformOrigin];
1485
- if (options.flip) {
1486
- middleware.push(flip({ boundary: options.boundary, padding: 8 }));
1487
- }
1488
- if (options.gutter || options.offset) {
1489
- const data = options.gutter ? { mainAxis: options.gutter } : options.offset;
1490
- middleware.push(offset(data));
1491
- }
1492
- middleware.push(shift({ boundary: options.boundary }));
1493
- const doc = getOwnerDocument(floating);
1494
- const arrowEl = doc.querySelector("[data-part=arrow]");
1495
- if (arrowEl) {
1496
- middleware.push(arrow({ element: arrowEl, padding: 8 }), shiftArrow({ element: arrowEl }));
1497
- }
1498
- if (options.sameWidth) {
1499
- middleware.push(size({
1500
- apply(data) {
1501
- const { width } = data.reference;
1502
- Object.assign(floating.style, { width: `${width}px`, minWidth: "unset" });
1503
- }
1504
- }));
1505
- }
1506
- function compute() {
1507
- if (reference == null || floating == null)
1508
- return;
1509
- const { placement, strategy } = options;
1510
- computePosition2(reference, floating, { placement, middleware, strategy }).then((data) => {
1511
- const { x, y, strategy: strategy2 } = data;
1512
- Object.assign(floating.style, { left: `${x}px`, top: `${y}px`, position: strategy2 });
1513
- return data;
1514
- }).then((data) => {
1515
- var _a2;
1516
- (_a2 = options.onComplete) == null ? void 0 : _a2.call(options, data);
1517
- });
1518
- }
1519
- compute();
1520
- return pipe(autoUpdate(reference, floating, compute, options.listeners), (_a = options.onCleanup) != null ? _a : noop);
1521
- }
1522
-
1523
- // ../../utilities/popper/src/get-styles.ts
1524
- var UNMEASURED_FLOATING_STYLE = {
1525
- position: "fixed",
1526
- top: 0,
1527
- left: 0,
1528
- opacity: 0,
1529
- transform: "translate3d(0, -200%, 0)",
1530
- pointerEvents: "none"
1531
- };
1532
- function getPlacementStyles(options) {
1533
- const { measured, strategy = "absolute" } = options;
1534
- return {
1535
- arrow: {
1536
- position: "absolute",
1537
- width: cssVars.arrowSize.reference,
1538
- height: cssVars.arrowSize.reference,
1539
- [cssVars.arrowSizeHalf.variable]: `calc(${cssVars.arrowSize.reference} / 2)`,
1540
- [cssVars.arrowOffset.variable]: `calc(${cssVars.arrowSizeHalf.reference} * -1)`,
1541
- opacity: !measured ? 0 : void 0
1542
- },
1543
- innerArrow: {
1544
- transform: "rotate(45deg)",
1545
- background: cssVars.arrowBg.reference,
1546
- top: "0",
1547
- left: "0",
1548
- width: "100%",
1549
- height: "100%",
1550
- position: "absolute",
1551
- zIndex: "inherit"
1552
- },
1553
- floating: __spreadValues({
1554
- position: strategy,
1555
- minWidth: "max-content"
1556
- }, !measured && UNMEASURED_FLOATING_STYLE)
1557
- };
1558
- }
244
+ // src/tooltip.connect.ts
245
+ import { getPlacementStyles } from "@zag-js/popper";
1559
246
 
1560
- // ../../types/src/prop-types.ts
247
+ // ../../types/dist/index.mjs
1561
248
  function createNormalizer(fn) {
1562
249
  return { button: fn, label: fn, input: fn, output: fn, element: fn };
1563
250
  }
@@ -1594,671 +281,9 @@ var dom = {
1594
281
  }
1595
282
  };
1596
283
 
1597
- // ../../../node_modules/@zag-js/core/src/index.ts
1598
- import { proxy as proxy2, ref as ref2, snapshot as snapshot2, subscribe as subscribe2 } from "valtio/vanilla";
1599
-
1600
- // ../../core/src/action-utils.ts
1601
- function isGuardHelper(value) {
1602
- return isObject(value) && value.predicate != null;
1603
- }
1604
- function determineActionsFn(values, guardMap) {
1605
- return (context, event) => {
1606
- if (isGuardHelper(values))
1607
- return values.predicate(guardMap != null ? guardMap : {})(context, event);
1608
- return values;
1609
- };
1610
- }
1611
-
1612
- // ../../core/src/guard-utils.ts
1613
- function isGuardHelper2(value) {
1614
- return isObject(value) && value.predicate != null;
1615
- }
1616
- var TruthyGuard = () => true;
1617
- function determineGuardFn(guard, guardMap) {
1618
- guard = guard != null ? guard : TruthyGuard;
1619
- return (context, event) => {
1620
- if (isString(guard)) {
1621
- const value = guardMap == null ? void 0 : guardMap[guard];
1622
- return isFunction(value) ? value(context, event) : value;
1623
- }
1624
- if (isGuardHelper2(guard)) {
1625
- return guard.predicate(guardMap != null ? guardMap : {})(context, event);
1626
- }
1627
- return guard == null ? void 0 : guard(context, event);
1628
- };
1629
- }
1630
-
1631
- // ../../../node_modules/klona/json/index.mjs
1632
- function klona(val) {
1633
- var k, out, tmp;
1634
- if (Array.isArray(val)) {
1635
- out = Array(k = val.length);
1636
- while (k--)
1637
- out[k] = (tmp = val[k]) && typeof tmp === "object" ? klona(tmp) : tmp;
1638
- return out;
1639
- }
1640
- if (Object.prototype.toString.call(val) === "[object Object]") {
1641
- out = {};
1642
- for (k in val) {
1643
- if (k === "__proto__") {
1644
- Object.defineProperty(out, k, {
1645
- value: klona(val[k]),
1646
- configurable: true,
1647
- enumerable: true,
1648
- writable: true
1649
- });
1650
- } else {
1651
- out[k] = (tmp = val[k]) && typeof tmp === "object" ? klona(tmp) : tmp;
1652
- }
1653
- }
1654
- return out;
1655
- }
1656
- return val;
1657
- }
1658
-
1659
- // ../../core/src/machine.ts
1660
- import { derive, subscribeKey, underive } from "valtio/utils";
1661
- import { ref, snapshot, subscribe } from "valtio/vanilla";
1662
-
1663
- // ../../core/src/create-proxy.ts
1664
- import { proxy } from "valtio/vanilla";
1665
- function createProxy(config) {
1666
- var _a;
1667
- const state = proxy({
1668
- value: "",
1669
- previousValue: "",
1670
- event: cast({}),
1671
- context: (_a = config.context) != null ? _a : cast({}),
1672
- done: false,
1673
- tags: [],
1674
- hasTag(tag) {
1675
- return this.tags.includes(tag);
1676
- },
1677
- matches(...value) {
1678
- return value.includes(this.value);
1679
- },
1680
- can(event) {
1681
- return cast(this).nextEvents.includes(event);
1682
- },
1683
- get nextEvents() {
1684
- var _a2, _b, _c, _d;
1685
- const stateEvents = (_c = (_b = (_a2 = config.states) == null ? void 0 : _a2[this.value]) == null ? void 0 : _b["on"]) != null ? _c : {};
1686
- const globalEvents = (_d = config == null ? void 0 : config.on) != null ? _d : {};
1687
- return Object.keys(__spreadValues(__spreadValues({}, stateEvents), globalEvents));
1688
- },
1689
- get changed() {
1690
- if (this.event.value === "machine.init" /* Init */ || !this.previousValue)
1691
- return false;
1692
- return this.value !== this.previousValue;
1693
- }
1694
- });
1695
- return cast(state);
1696
- }
1697
-
1698
- // ../../core/src/delay-utils.ts
1699
- function determineDelayFn(delay, delaysMap) {
1700
- return (context, event) => {
1701
- if (isNumber(delay))
1702
- return delay;
1703
- if (isFunction(delay)) {
1704
- return delay(context, event);
1705
- }
1706
- if (isString(delay)) {
1707
- const value = Number.parseFloat(delay);
1708
- if (!Number.isNaN(value)) {
1709
- return value;
1710
- }
1711
- if (delaysMap) {
1712
- const valueOrFn = delaysMap == null ? void 0 : delaysMap[delay];
1713
- if (valueOrFn == null) {
1714
- const msg = `[machine] Cannot determine delay for ${delay}. It doesn't exist in options.delays`;
1715
- throw new Error(msg);
1716
- }
1717
- return isFunction(valueOrFn) ? valueOrFn(context, event) : valueOrFn;
1718
- }
1719
- }
1720
- };
1721
- }
1722
-
1723
- // ../../core/src/utils.ts
1724
- function toEvent(event) {
1725
- const obj = isString(event) ? { type: event } : event;
1726
- return obj;
1727
- }
1728
- function toArray(value) {
1729
- if (!value)
1730
- return [];
1731
- return isArray(value) ? value : [value];
1732
- }
1733
-
1734
- // ../../core/src/transition-utils.ts
1735
- function toTarget(target) {
1736
- return isString(target) ? { target } : target;
1737
- }
1738
- function determineTransitionFn(transitions, guardMap) {
1739
- return (context, event) => {
1740
- return toArray(transitions).map(toTarget).find((transition) => {
1741
- var _a;
1742
- const determineGuard = determineGuardFn(transition.guard, guardMap);
1743
- const guard = determineGuard(context, event);
1744
- return (_a = guard != null ? guard : transition.target) != null ? _a : transition.actions;
1745
- });
1746
- };
1747
- }
1748
- function toTransition(transition, current) {
1749
- const _transition = isString(transition) ? toTarget(transition) : transition;
1750
- const fn = (t2) => {
1751
- const isTargetless = t2.actions && !t2.target;
1752
- if (isTargetless && current)
1753
- t2.target = current;
1754
- return t2;
1755
- };
1756
- if (isArray(_transition)) {
1757
- return _transition.map(fn);
1758
- }
1759
- if (isObject(_transition)) {
1760
- return fn(cast(_transition));
1761
- }
1762
- }
1763
-
1764
- // ../../core/src/machine.ts
1765
- var Machine = class {
1766
- constructor(config, options) {
1767
- this.config = config;
1768
- this.status = "Not Started" /* NotStarted */;
1769
- this.type = "machine" /* Machine */;
1770
- this.activityEvents = /* @__PURE__ */ new Map();
1771
- this.delayedEvents = /* @__PURE__ */ new Map();
1772
- this.stateListeners = /* @__PURE__ */ new Set();
1773
- this.eventListeners = /* @__PURE__ */ new Set();
1774
- this.doneListeners = /* @__PURE__ */ new Set();
1775
- this.contextWatchers = /* @__PURE__ */ new Set();
1776
- this.removeStateListener = noop;
1777
- this.removeEventListener = noop;
1778
- this.children = /* @__PURE__ */ new Map();
1779
- this.start = (init) => {
1780
- if (this.status === "Running" /* Running */) {
1781
- return this;
1782
- }
1783
- this.status = "Running" /* Running */;
1784
- const event = toEvent("machine.init" /* Init */);
1785
- if (init) {
1786
- const resolved = isObject(init) ? init : { context: this.config.context, value: init };
1787
- this.setState(resolved.value);
1788
- this.setContext(resolved.context);
1789
- }
1790
- const transition = {
1791
- target: !!init ? void 0 : this.config.initial
1792
- };
1793
- const info = this.getNextStateInfo(transition, event);
1794
- info.target = cast(info.target || transition.target);
1795
- this.initialState = info;
1796
- this.performStateChangeEffects(info.target, info, event);
1797
- this.removeStateListener = subscribe(this.state, () => {
1798
- this.stateListeners.forEach((listener) => {
1799
- listener(this.stateSnapshot);
1800
- });
1801
- }, this.sync);
1802
- this.removeEventListener = subscribeKey(this.state, "event", (value) => {
1803
- if (this.config.onEvent) {
1804
- this.executeActions(this.config.onEvent, value);
1805
- }
1806
- for (const listener of this.eventListeners) {
1807
- listener(value);
1808
- }
1809
- });
1810
- this.setupContextWatchers();
1811
- this.executeActivities(toEvent("machine.start" /* Start */), toArray(this.config.activities), "machine.start" /* Start */);
1812
- this.executeActions(this.config.entry, toEvent("machine.start" /* Start */));
1813
- return this;
1814
- };
1815
- this.setupContextWatchers = () => {
1816
- var _a;
1817
- for (const [key, fn] of Object.entries((_a = this.config.watch) != null ? _a : {})) {
1818
- this.contextWatchers.add(subscribeKey(this.state.context, key, () => {
1819
- this.executeActions(fn, this.state.event);
1820
- }));
1821
- }
1822
- };
1823
- this.setupComputed = () => {
1824
- var _a;
1825
- const computed = cast((_a = this.config.computed) != null ? _a : {});
1826
- const deriveFns = Object.fromEntries(Object.entries(computed).map(([key, fn]) => [key, (get) => fn(get(this.state.context))]));
1827
- derive(deriveFns, { proxy: this.state.context });
1828
- };
1829
- this.detachComputed = () => {
1830
- underive(this.state.context, { delete: true });
1831
- };
1832
- this.stop = () => {
1833
- if (this.status === "Stopped" /* Stopped */)
1834
- return;
1835
- this.setState(null);
1836
- this.setEvent("machine.stop" /* Stop */);
1837
- if (this.config.context) {
1838
- this.setContext(this.config.context);
1839
- }
1840
- this.stopStateListeners();
1841
- this.stopChildren();
1842
- this.stopActivities();
1843
- this.stopDelayedEvents();
1844
- this.stopContextWatchers();
1845
- this.stopEventListeners();
1846
- this.detachComputed();
1847
- this.status = "Stopped" /* Stopped */;
1848
- this.executeActions(this.config.exit, toEvent("machine.stop" /* Stop */));
1849
- return this;
1850
- };
1851
- this.stopEventListeners = () => {
1852
- this.eventListeners.clear();
1853
- this.removeEventListener();
1854
- };
1855
- this.stopStateListeners = () => {
1856
- this.removeStateListener();
1857
- this.stateListeners.clear();
1858
- };
1859
- this.stopContextWatchers = () => {
1860
- this.contextWatchers.forEach((fn) => fn());
1861
- this.contextWatchers.clear();
1862
- };
1863
- this.stopDelayedEvents = () => {
1864
- this.delayedEvents.forEach((state) => {
1865
- state.forEach((stop) => stop());
1866
- });
1867
- this.delayedEvents.clear();
1868
- };
1869
- this.stopActivities = (state) => {
1870
- var _a, _b;
1871
- if (state) {
1872
- (_a = this.activityEvents.get(state)) == null ? void 0 : _a.forEach((stop) => stop());
1873
- (_b = this.activityEvents.get(state)) == null ? void 0 : _b.clear();
1874
- this.activityEvents.delete(state);
1875
- } else {
1876
- this.activityEvents.forEach((state2) => {
1877
- state2.forEach((stop) => stop());
1878
- state2.clear();
1879
- });
1880
- this.activityEvents.clear();
1881
- }
1882
- };
1883
- this.sendChild = (evt, to) => {
1884
- const event = toEvent(evt);
1885
- const id = runIfFn(to, this.contextSnapshot);
1886
- const child = this.children.get(id);
1887
- if (!child) {
1888
- invariant(`[machine/send-child] Cannot send '${event.type}' event to unknown child`);
1889
- }
1890
- child.send(event);
1891
- };
1892
- this.stopChild = (id) => {
1893
- if (!this.children.has(id)) {
1894
- invariant("[machine/stop-child] Cannot stop unknown child");
1895
- }
1896
- this.children.get(id).stop();
1897
- this.children.delete(id);
1898
- };
1899
- this.removeChild = (id) => {
1900
- this.children.delete(id);
1901
- };
1902
- this.stopChildren = () => {
1903
- this.children.forEach((child) => child.stop());
1904
- this.children.clear();
1905
- };
1906
- this.setParent = (parent) => {
1907
- this.parent = parent;
1908
- };
1909
- this.spawn = (src, id) => {
1910
- const actor = runIfFn(src);
1911
- if (id)
1912
- actor.id = id;
1913
- actor.type = "machine.actor" /* Actor */;
1914
- actor.setParent(this);
1915
- this.children.set(actor.id, cast(actor));
1916
- actor.onDone(() => {
1917
- this.removeChild(actor.id);
1918
- }).start();
1919
- return cast(ref(actor));
1920
- };
1921
- this.addActivityCleanup = (state, cleanup) => {
1922
- var _a;
1923
- if (!state)
1924
- return;
1925
- if (!this.activityEvents.has(state)) {
1926
- this.activityEvents.set(state, /* @__PURE__ */ new Set([cleanup]));
1927
- } else {
1928
- (_a = this.activityEvents.get(state)) == null ? void 0 : _a.add(cleanup);
1929
- }
1930
- };
1931
- this.setState = (target) => {
1932
- this.state.previousValue = this.state.value;
1933
- this.state.value = target;
1934
- const stateNode = this.getStateNode(target);
1935
- if (target == null) {
1936
- clear(this.state.tags);
1937
- } else {
1938
- this.state.tags = toArray(stateNode == null ? void 0 : stateNode.tags);
1939
- }
1940
- };
1941
- this.setContext = (context) => {
1942
- for (const key in context) {
1943
- this.state.context[key] = context[key];
1944
- }
1945
- };
1946
- this.withContext = (context) => {
1947
- this.detachComputed();
1948
- const newContext = __spreadValues(__spreadValues({}, this.config.context), context);
1949
- return new Machine(__spreadProps(__spreadValues({}, this.config), { context: newContext }), this.options);
1950
- };
1951
- this.withOptions = (options) => {
1952
- this.detachComputed();
1953
- return new Machine(this.config, __spreadValues(__spreadValues({}, this.options), options));
1954
- };
1955
- this.setActions = (actions) => {
1956
- this.actionMap = __spreadValues(__spreadValues({}, this.actionMap), actions);
1957
- };
1958
- this.clone = () => {
1959
- this.detachComputed();
1960
- return new Machine(this.config, this.options);
1961
- };
1962
- this.getStateNode = (state) => {
1963
- var _a;
1964
- if (!state)
1965
- return;
1966
- return (_a = this.config.states) == null ? void 0 : _a[state];
1967
- };
1968
- this.getNextStateInfo = (transitions, event) => {
1969
- var _a;
1970
- const transition = this.determineTransition(transitions, event);
1971
- const target = (_a = transition == null ? void 0 : transition.target) != null ? _a : this.state.value;
1972
- const stateNode = this.getStateNode(target);
1973
- return {
1974
- transition,
1975
- stateNode,
1976
- target
1977
- };
1978
- };
1979
- this.getActionFromDelayedTransition = (transition) => {
1980
- const event = toEvent("machine.after" /* After */);
1981
- const determineDelay = determineDelayFn(transition.delay, this.delayMap);
1982
- const delay = determineDelay(this.contextSnapshot, event);
1983
- let id;
1984
- return {
1985
- entry: () => {
1986
- id = globalThis.setTimeout(() => {
1987
- const current = this.state.value;
1988
- const next = this.getNextStateInfo(transition, event);
1989
- this.performStateChangeEffects(current, next, event);
1990
- }, delay);
1991
- },
1992
- exit: () => {
1993
- globalThis.clearTimeout(id);
1994
- }
1995
- };
1996
- };
1997
- this.getDelayedEventActions = (state) => {
1998
- const stateNode = this.getStateNode(state);
1999
- const event = toEvent("machine.after" /* After */);
2000
- if (!stateNode || !stateNode.after)
2001
- return;
2002
- const entries = [];
2003
- const exits = [];
2004
- if (isArray(stateNode.after)) {
2005
- const transition = this.determineTransition(stateNode.after, event);
2006
- if (!transition)
2007
- return;
2008
- const actions = this.getActionFromDelayedTransition(transition);
2009
- entries.push(actions.entry);
2010
- exits.push(actions.exit);
2011
- } else if (isObject(stateNode.after)) {
2012
- for (const delay in stateNode.after) {
2013
- const transition = stateNode.after[delay];
2014
- let resolvedTransition = {};
2015
- if (isArray(transition)) {
2016
- const picked = this.determineTransition(transition, event);
2017
- if (picked)
2018
- resolvedTransition = picked;
2019
- } else if (isString(transition)) {
2020
- resolvedTransition = { target: transition, delay };
2021
- } else {
2022
- resolvedTransition = __spreadProps(__spreadValues({}, transition), { delay });
2023
- }
2024
- const actions = this.getActionFromDelayedTransition(resolvedTransition);
2025
- entries.push(actions.entry);
2026
- exits.push(actions.exit);
2027
- }
2028
- }
2029
- return { entries, exits };
2030
- };
2031
- this.executeActions = (actions, event) => {
2032
- var _a;
2033
- const _actions = determineActionsFn(actions, this.guardMap)(this.contextSnapshot, event);
2034
- for (const action of toArray(_actions)) {
2035
- const fn = isString(action) ? (_a = this.actionMap) == null ? void 0 : _a[action] : action;
2036
- warn(isString(action) && !fn, `[machine/exec-action] No implementation found for action: \`${action}\``);
2037
- fn == null ? void 0 : fn(this.state.context, event, this.meta);
2038
- }
2039
- };
2040
- this.executeActivities = (event, activities, state) => {
2041
- var _a;
2042
- for (const activity of activities) {
2043
- const fn = isString(activity) ? (_a = this.activityMap) == null ? void 0 : _a[activity] : activity;
2044
- if (!fn) {
2045
- warn(`[machine/exec-activity] No implementation found for activity: \`${activity}\``);
2046
- continue;
2047
- }
2048
- const cleanup = fn(this.state.context, event, this.meta);
2049
- if (cleanup) {
2050
- this.addActivityCleanup(state != null ? state : this.state.value, cleanup);
2051
- }
2052
- }
2053
- };
2054
- this.createEveryActivities = (every, callbackfn) => {
2055
- if (!every)
2056
- return;
2057
- const event = toEvent("machine.every" /* Every */);
2058
- if (isArray(every)) {
2059
- const picked = toArray(every).find((t2) => {
2060
- const determineDelay2 = determineDelayFn(t2.delay, this.delayMap);
2061
- t2.delay = determineDelay2(this.contextSnapshot, event);
2062
- const determineGuard = determineGuardFn(t2.guard, this.guardMap);
2063
- const guard = determineGuard(this.contextSnapshot, event);
2064
- return guard != null ? guard : t2.delay;
2065
- });
2066
- if (!picked)
2067
- return;
2068
- const determineDelay = determineDelayFn(picked.delay, this.delayMap);
2069
- const delay = determineDelay(this.contextSnapshot, event);
2070
- const activity = () => {
2071
- const id = globalThis.setInterval(() => {
2072
- this.executeActions(picked.actions, event);
2073
- }, delay);
2074
- return () => {
2075
- globalThis.clearInterval(id);
2076
- };
2077
- };
2078
- callbackfn(activity);
2079
- } else {
2080
- for (const interval in every) {
2081
- const actions = every == null ? void 0 : every[interval];
2082
- const determineDelay = determineDelayFn(interval, this.delayMap);
2083
- const delay = determineDelay(this.contextSnapshot, event);
2084
- const activity = () => {
2085
- const id = globalThis.setInterval(() => {
2086
- this.executeActions(actions, event);
2087
- }, delay);
2088
- return () => {
2089
- globalThis.clearInterval(id);
2090
- };
2091
- };
2092
- callbackfn(activity);
2093
- }
2094
- }
2095
- };
2096
- this.setEvent = (event) => {
2097
- this.state.event = ref(toEvent(event));
2098
- };
2099
- this.performExitEffects = (current, event) => {
2100
- const currentState = this.state.value;
2101
- const stateNode = current ? this.getStateNode(current) : void 0;
2102
- this.stopActivities(currentState);
2103
- const _exit = determineActionsFn(stateNode == null ? void 0 : stateNode.exit, this.guardMap)(this.contextSnapshot, event);
2104
- const exitActions = toArray(_exit);
2105
- const afterExitActions = this.delayedEvents.get(currentState);
2106
- if (afterExitActions) {
2107
- exitActions.push(...afterExitActions);
2108
- }
2109
- this.executeActions(exitActions, event);
2110
- this.eventListeners.clear();
2111
- };
2112
- this.performEntryEffects = (next, event) => {
2113
- const stateNode = this.getStateNode(next);
2114
- const activities = toArray(stateNode == null ? void 0 : stateNode.activities);
2115
- this.createEveryActivities(stateNode == null ? void 0 : stateNode.every, (activity) => {
2116
- activities.unshift(activity);
2117
- });
2118
- if (activities.length > 0) {
2119
- this.executeActivities(event, activities);
2120
- }
2121
- const _entry = determineActionsFn(stateNode == null ? void 0 : stateNode.entry, this.guardMap)(this.contextSnapshot, event);
2122
- const entryActions = toArray(_entry);
2123
- const afterActions = this.getDelayedEventActions(next);
2124
- if ((stateNode == null ? void 0 : stateNode.after) && afterActions) {
2125
- this.delayedEvents.set(next, afterActions == null ? void 0 : afterActions.exits);
2126
- entryActions.push(...afterActions.entries);
2127
- }
2128
- this.executeActions(entryActions, event);
2129
- if ((stateNode == null ? void 0 : stateNode.type) === "final") {
2130
- this.state.done = true;
2131
- this.doneListeners.forEach((listener) => {
2132
- listener(this.stateSnapshot);
2133
- });
2134
- this.stop();
2135
- }
2136
- };
2137
- this.performTransitionEffects = (transition, event) => {
2138
- const t2 = this.determineTransition(transition, event);
2139
- this.executeActions(t2 == null ? void 0 : t2.actions, event);
2140
- };
2141
- this.performStateChangeEffects = (current, next, event) => {
2142
- var _a, _b;
2143
- this.setEvent(event);
2144
- next.target = (_b = (_a = next.target) != null ? _a : this.state.value) != null ? _b : void 0;
2145
- const ok = next.target && next.target !== this.state.value;
2146
- if (ok) {
2147
- this.performExitEffects(current, event);
2148
- }
2149
- this.performTransitionEffects(next == null ? void 0 : next.transition, event);
2150
- this.setState(next.target);
2151
- if (ok) {
2152
- this.performEntryEffects(next.target, event);
2153
- }
2154
- };
2155
- this.determineTransition = (transition, event) => {
2156
- const fn = determineTransitionFn(transition, this.guardMap);
2157
- return fn == null ? void 0 : fn(this.contextSnapshot, event);
2158
- };
2159
- this.sendParent = (evt) => {
2160
- var _a;
2161
- if (!this.parent) {
2162
- invariant("[machine/send-parent] Cannot send event to an unknown parent");
2163
- }
2164
- const event = toEvent(evt);
2165
- (_a = this.parent) == null ? void 0 : _a.send(event);
2166
- };
2167
- this.send = (evt) => {
2168
- const event = toEvent(evt);
2169
- this.transition(this.state.value, event);
2170
- };
2171
- this.transition = (state, evt) => {
2172
- var _a, _b, _c;
2173
- const stateNode = isString(state) ? this.getStateNode(state) : state == null ? void 0 : state.stateNode;
2174
- const event = toEvent(evt);
2175
- if (!stateNode && !this.config.on) {
2176
- const msg = this.status === "Stopped" /* Stopped */ ? "[machine/transition] Cannot transition a stopped machine" : "[machine/transition] State does not have a definition";
2177
- warn(msg);
2178
- return;
2179
- }
2180
- const transitionConfig = (_c = (_a = stateNode == null ? void 0 : stateNode.on) == null ? void 0 : _a[event.type]) != null ? _c : (_b = this.config.on) == null ? void 0 : _b[event.type];
2181
- const transition = toTransition(transitionConfig, this.state.value);
2182
- if (!transition)
2183
- return;
2184
- const info = this.getNextStateInfo(transition, event);
2185
- this.performStateChangeEffects(this.state.value, info, event);
2186
- return info.stateNode;
2187
- };
2188
- this.subscribe = (listener) => {
2189
- this.stateListeners.add(listener);
2190
- if (this.status === "Running" /* Running */) {
2191
- listener(this.stateSnapshot);
2192
- }
2193
- return () => {
2194
- this.stateListeners.delete(listener);
2195
- };
2196
- };
2197
- this.onDone = (listener) => {
2198
- this.doneListeners.add(listener);
2199
- return this;
2200
- };
2201
- this.onTransition = (listener) => {
2202
- this.stateListeners.add(listener);
2203
- if (this.status === "Running" /* Running */) {
2204
- listener(this.stateSnapshot);
2205
- }
2206
- return this;
2207
- };
2208
- this.onEvent = (listener) => {
2209
- listener(this.state.event);
2210
- this.eventListeners.add(listener);
2211
- return this;
2212
- };
2213
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
2214
- this.options = klona(options);
2215
- this.id = (_a = config.id) != null ? _a : `machine-${uuid()}`;
2216
- this.guardMap = (_c = (_b = this.options) == null ? void 0 : _b.guards) != null ? _c : {};
2217
- this.actionMap = (_e = (_d = this.options) == null ? void 0 : _d.actions) != null ? _e : {};
2218
- this.delayMap = (_g = (_f = this.options) == null ? void 0 : _f.delays) != null ? _g : {};
2219
- this.activityMap = (_i = (_h = this.options) == null ? void 0 : _h.activities) != null ? _i : {};
2220
- this.sync = (_k = (_j = this.options) == null ? void 0 : _j.sync) != null ? _k : false;
2221
- this.state = createProxy(klona(config));
2222
- this.setupComputed();
2223
- const event = toEvent("machine.created" /* Created */);
2224
- this.executeActions(config == null ? void 0 : config.created, event);
2225
- }
2226
- get stateSnapshot() {
2227
- return cast(snapshot(this.state));
2228
- }
2229
- get contextSnapshot() {
2230
- return this.stateSnapshot.context;
2231
- }
2232
- get self() {
2233
- const _self = this;
2234
- return {
2235
- id: this.id,
2236
- send: this.send.bind(this),
2237
- sendParent: this.sendParent.bind(this),
2238
- sendChild: this.sendChild.bind(this),
2239
- stop: this.stop.bind(this),
2240
- stopChild: this.stopChild.bind(this),
2241
- spawn: this.spawn.bind(this),
2242
- get state() {
2243
- return _self.stateSnapshot;
2244
- }
2245
- };
2246
- }
2247
- get meta() {
2248
- return {
2249
- state: this.stateSnapshot,
2250
- guards: this.guardMap,
2251
- send: this.send.bind(this),
2252
- listen: this.onEvent.bind(this),
2253
- self: this.self,
2254
- getState: () => this.stateSnapshot
2255
- };
2256
- }
2257
- };
2258
- var createMachine = (config, options) => new Machine(config, options);
2259
-
2260
284
  // src/tooltip.store.ts
2261
- var store = proxy2({
285
+ import { proxy } from "@zag-js/core";
286
+ var store = proxy({
2262
287
  id: null,
2263
288
  prevId: null,
2264
289
  setId(val) {
@@ -2370,6 +395,17 @@ function connect(state, send, normalize = normalizeProp) {
2370
395
  };
2371
396
  }
2372
397
 
398
+ // src/tooltip.machine.ts
399
+ import { createMachine, ref, subscribe } from "@zag-js/core";
400
+ import { getPlacement } from "@zag-js/popper";
401
+
402
+ // ../../utilities/core/dist/index.mjs
403
+ var noop2 = () => {
404
+ };
405
+ var ua = (v) => isDom() && v.test(navigator.userAgent);
406
+ var isDom = () => !!(typeof window !== "undefined");
407
+ var isSafari = () => ua(/^((?!chrome|android).)*safari/i);
408
+
2373
409
  // src/tooltip.machine.ts
2374
410
  var machine = createMachine({
2375
411
  id: "tooltip",
@@ -2517,7 +553,7 @@ var machine = createMachine({
2517
553
  };
2518
554
  },
2519
555
  trackStore(ctx, _evt, { send }) {
2520
- return subscribe2(store, () => {
556
+ return subscribe(store, () => {
2521
557
  if (store.id !== ctx.id) {
2522
558
  send("FORCE_CLOSE");
2523
559
  }
@@ -2525,7 +561,7 @@ var machine = createMachine({
2525
561
  },
2526
562
  trackDisabledTriggerOnSafari(ctx, _evt, { send }) {
2527
563
  if (!isSafari())
2528
- return noop;
564
+ return noop2;
2529
565
  const doc = dom.getDoc(ctx);
2530
566
  return addPointerEvent(doc, "pointermove", (event) => {
2531
567
  const selector = "[data-part=trigger][data-expanded]";
@@ -2549,7 +585,7 @@ var machine = createMachine({
2549
585
  setupDocument(ctx, evt) {
2550
586
  ctx.id = evt.id;
2551
587
  if (evt.doc)
2552
- ctx.doc = ref2(evt.doc);
588
+ ctx.doc = ref(evt.doc);
2553
589
  },
2554
590
  setGlobalId(ctx) {
2555
591
  store.setId(ctx.id);