welcome-ui
Version:
Customizable design system with react • styled-components • styled-system and ariakit.
1,079 lines (1,078 loc) • 40.2 kB
JavaScript
"use client";
import { a as kt, b as Nt, d as Vt, c as dt } from "./JC64G2H7-afsomHuH.mjs";
import { m as Wt, o as Bt, t as jt, c as pt, b as Ee, a as mt, d as zt } from "./YV4JVR4I-DPC8mMuG.mjs";
import { z as Xt, A as le, C as q, B as j, G as Yt, c as je, _ as Ce, i as He, a5 as ht, b as me, E as Le, D as _e, d as G, g as _, f as ze, h as Xe, t as It, a6 as vt, u as ke, P as et, a7 as se, a4 as qt, e as gt, X as Ut, Y as Ne, a8 as Gt, l as Jt, m as Zt } from "./LVA2YJMS-C-kJ1lkr.mjs";
import { u as wt, P as xt, a as Kt } from "./MTZPJQMC-TybFZCho.mjs";
import { useRef as ce, useState as Ye, useEffect as U, useContext as Qt, createContext as en, useCallback as yt } from "react";
import { j as Se } from "./jsx-runtime-B7I4PJ0H.mjs";
function bt(e = {}) {
var n = e, {
popover: o
} = n, t = Xt(n, [
"popover"
]);
const i = Wt(
t.store,
Bt(o, [
"arrowElement",
"anchorElement",
"contentElement",
"popoverElement",
"disclosureElement"
])
);
jt(t, i);
const r = i == null ? void 0 : i.getState(), l = kt(le(q({}, t), { store: i })), a = j(
t.placement,
r == null ? void 0 : r.placement,
"bottom"
), c = le(q({}, l.getState()), {
placement: a,
currentPlacement: a,
anchorElement: j(r == null ? void 0 : r.anchorElement, null),
popoverElement: j(r == null ? void 0 : r.popoverElement, null),
arrowElement: j(r == null ? void 0 : r.arrowElement, null),
rendered: Symbol("rendered")
}), s = pt(c, l, i);
return le(q(q({}, l), s), {
setAnchorElement: (f) => s.setState("anchorElement", f),
setPopoverElement: (f) => s.setState("popoverElement", f),
setArrowElement: (f) => s.setState("arrowElement", f),
render: () => s.setState("rendered", Symbol("rendered"))
});
}
function Pt(e, n, o) {
return Yt(n, [o.popover]), Ee(e, o, "placement"), Nt(e, n, o);
}
function zn(e = {}) {
const [n, o] = mt(bt, e);
return Pt(n, o, e);
}
function de(e) {
return e.split("-")[1];
}
function Ie(e) {
return e === "y" ? "height" : "width";
}
function z(e) {
return e.split("-")[0];
}
function ne(e) {
return ["top", "bottom"].includes(z(e)) ? "x" : "y";
}
function tt(e, n, o) {
let { reference: t, floating: i } = e;
const r = t.x + t.width / 2 - i.width / 2, l = t.y + t.height / 2 - i.height / 2, a = ne(n), c = Ie(a), s = t[c] / 2 - i[c] / 2, f = a === "x";
let u;
switch (z(n)) {
case "top":
u = { x: r, y: t.y - i.height };
break;
case "bottom":
u = { x: r, y: t.y + t.height };
break;
case "right":
u = { x: t.x + t.width, y: l };
break;
case "left":
u = { x: t.x - i.width, y: l };
break;
default:
u = { x: t.x, y: t.y };
}
switch (de(n)) {
case "start":
u[a] -= s * (o && f ? -1 : 1);
break;
case "end":
u[a] += s * (o && f ? -1 : 1);
}
return u;
}
const tn = async (e, n, o) => {
const { placement: t = "bottom", strategy: i = "absolute", middleware: r = [], platform: l } = o, a = r.filter(Boolean), c = await (l.isRTL == null ? void 0 : l.isRTL(n));
let s = await l.getElementRects({ reference: e, floating: n, strategy: i }), { x: f, y: u } = tt(s, t, c), m = t, p = {}, d = 0;
for (let h = 0; h < a.length; h++) {
const { name: v, fn: g } = a[h], { x: w, y: b, data: P, reset: x } = await g({ x: f, y: u, initialPlacement: t, placement: m, strategy: i, middlewareData: p, rects: s, platform: l, elements: { reference: e, floating: n } });
f = w ?? f, u = b ?? u, p = { ...p, [v]: { ...p[v], ...P } }, x && d <= 50 && (d++, typeof x == "object" && (x.placement && (m = x.placement), x.rects && (s = x.rects === !0 ? await l.getElementRects({ reference: e, floating: n, strategy: i }) : x.rects), { x: f, y: u } = tt(s, m, c)), h = -1);
}
return { x: f, y: u, placement: m, strategy: i, middlewareData: p };
};
function J(e, n) {
return typeof e == "function" ? e(n) : e;
}
function Et(e) {
return typeof e != "number" ? function(n) {
return { top: 0, right: 0, bottom: 0, left: 0, ...n };
}(e) : { top: e, right: e, bottom: e, left: e };
}
function Re(e) {
return { ...e, top: e.y, left: e.x, right: e.x + e.width, bottom: e.y + e.height };
}
async function qe(e, n) {
var o;
n === void 0 && (n = {});
const { x: t, y: i, platform: r, rects: l, elements: a, strategy: c } = e, { boundary: s = "clippingAncestors", rootBoundary: f = "viewport", elementContext: u = "floating", altBoundary: m = !1, padding: p = 0 } = J(n, e), d = Et(p), h = a[m ? u === "floating" ? "reference" : "floating" : u], v = Re(await r.getClippingRect({ element: (o = await (r.isElement == null ? void 0 : r.isElement(h))) == null || o ? h : h.contextElement || await (r.getDocumentElement == null ? void 0 : r.getDocumentElement(a.floating)), boundary: s, rootBoundary: f, strategy: c })), g = u === "floating" ? { ...l.floating, x: t, y: i } : l.reference, w = await (r.getOffsetParent == null ? void 0 : r.getOffsetParent(a.floating)), b = await (r.isElement == null ? void 0 : r.isElement(w)) && await (r.getScale == null ? void 0 : r.getScale(w)) || { x: 1, y: 1 }, P = Re(r.convertOffsetParentRelativeRectToViewportRelativeRect ? await r.convertOffsetParentRelativeRectToViewportRelativeRect({ rect: g, offsetParent: w, strategy: c }) : g);
return { top: (v.top - P.top + d.top) / b.y, bottom: (P.bottom - v.bottom + d.bottom) / b.y, left: (v.left - P.left + d.left) / b.x, right: (P.right - v.right + d.right) / b.x };
}
const he = Math.min, Q = Math.max;
function Ve(e, n, o) {
return Q(e, he(n, o));
}
const nn = (e) => ({ name: "arrow", options: e, async fn(n) {
const { x: o, y: t, placement: i, rects: r, platform: l, elements: a } = n, { element: c, padding: s = 0 } = J(e, n) || {};
if (c == null) return {};
const f = Et(s), u = { x: o, y: t }, m = ne(i), p = Ie(m), d = await l.getDimensions(c), h = m === "y", v = h ? "top" : "left", g = h ? "bottom" : "right", w = h ? "clientHeight" : "clientWidth", b = r.reference[p] + r.reference[m] - u[m] - r.floating[p], P = u[m] - r.reference[m], x = await (l.getOffsetParent == null ? void 0 : l.getOffsetParent(c));
let E = x ? x[w] : 0;
E && await (l.isElement == null ? void 0 : l.isElement(x)) || (E = a.floating[w] || r.floating[p]);
const C = b / 2 - P / 2, H = E / 2 - d[p] / 2 - 1, D = he(f[v], H), R = he(f[g], H), A = D, $ = E - d[p] - R, y = E / 2 - d[p] / 2 + C, O = Ve(A, y, $), S = de(i) != null && y != O && r.reference[p] / 2 - (y < A ? D : R) - d[p] / 2 < 0 ? y < A ? A - y : $ - y : 0;
return { [m]: u[m] - S, data: { [m]: O, centerOffset: y - O + S } };
} }), on = ["top", "right", "bottom", "left"];
on.reduce((e, n) => e.concat(n, n + "-start", n + "-end"), []);
const rn = { left: "right", right: "left", bottom: "top", top: "bottom" };
function Ae(e) {
return e.replace(/left|right|bottom|top/g, (n) => rn[n]);
}
function sn(e, n, o) {
o === void 0 && (o = !1);
const t = de(e), i = ne(e), r = Ie(i);
let l = i === "x" ? t === (o ? "end" : "start") ? "right" : "left" : t === "start" ? "bottom" : "top";
return n.reference[r] > n.floating[r] && (l = Ae(l)), { main: l, cross: Ae(l) };
}
const ln = { start: "end", end: "start" };
function De(e) {
return e.replace(/start|end/g, (n) => ln[n]);
}
const cn = function(e) {
return e === void 0 && (e = {}), { name: "flip", options: e, async fn(n) {
var o;
const { placement: t, middlewareData: i, rects: r, initialPlacement: l, platform: a, elements: c } = n, { mainAxis: s = !0, crossAxis: f = !0, fallbackPlacements: u, fallbackStrategy: m = "bestFit", fallbackAxisSideDirection: p = "none", flipAlignment: d = !0, ...h } = J(e, n), v = z(t), g = z(l) === l, w = await (a.isRTL == null ? void 0 : a.isRTL(c.floating)), b = u || (g || !d ? [Ae(l)] : function(A) {
const $ = Ae(A);
return [De(A), $, De($)];
}(l));
u || p === "none" || b.push(...function(A, $, y, O) {
const S = de(A);
let T = function(M, L, I) {
const V = ["left", "right"], W = ["right", "left"], K = ["top", "bottom"], oe = ["bottom", "top"];
switch (M) {
case "top":
case "bottom":
return I ? L ? W : V : L ? V : W;
case "left":
case "right":
return L ? K : oe;
default:
return [];
}
}(z(A), y === "start", O);
return S && (T = T.map((M) => M + "-" + S), $ && (T = T.concat(T.map(De)))), T;
}(l, d, p, w));
const P = [l, ...b], x = await qe(n, h), E = [];
let C = ((o = i.flip) == null ? void 0 : o.overflows) || [];
if (s && E.push(x[v]), f) {
const { main: A, cross: $ } = sn(t, r, w);
E.push(x[A], x[$]);
}
if (C = [...C, { placement: t, overflows: E }], !E.every((A) => A <= 0)) {
var H, D;
const A = (((H = i.flip) == null ? void 0 : H.index) || 0) + 1, $ = P[A];
if ($) return { data: { index: A, overflows: C }, reset: { placement: $ } };
let y = (D = C.filter((O) => O.overflows[0] <= 0).sort((O, S) => O.overflows[1] - S.overflows[1])[0]) == null ? void 0 : D.placement;
if (!y) switch (m) {
case "bestFit": {
var R;
const O = (R = C.map((S) => [S.placement, S.overflows.filter((T) => T > 0).reduce((T, M) => T + M, 0)]).sort((S, T) => S[1] - T[1])[0]) == null ? void 0 : R[0];
O && (y = O);
break;
}
case "initialPlacement":
y = l;
}
if (t !== y) return { reset: { placement: y } };
}
return {};
} };
}, an = function(e) {
return e === void 0 && (e = 0), { name: "offset", options: e, async fn(n) {
const { x: o, y: t } = n, i = await async function(r, l) {
const { placement: a, platform: c, elements: s } = r, f = await (c.isRTL == null ? void 0 : c.isRTL(s.floating)), u = z(a), m = de(a), p = ne(a) === "x", d = ["left", "top"].includes(u) ? -1 : 1, h = f && p ? -1 : 1, v = J(l, r);
let { mainAxis: g, crossAxis: w, alignmentAxis: b } = typeof v == "number" ? { mainAxis: v, crossAxis: 0, alignmentAxis: null } : { mainAxis: 0, crossAxis: 0, alignmentAxis: null, ...v };
return m && typeof b == "number" && (w = m === "end" ? -1 * b : b), p ? { x: w * h, y: g * d } : { x: g * d, y: w * h };
}(n, e);
return { x: o + i.x, y: t + i.y, data: i };
} };
};
function St(e) {
return e === "x" ? "y" : "x";
}
const un = function(e) {
return e === void 0 && (e = {}), { name: "shift", options: e, async fn(n) {
const { x: o, y: t, placement: i } = n, { mainAxis: r = !0, crossAxis: l = !1, limiter: a = { fn: (v) => {
let { x: g, y: w } = v;
return { x: g, y: w };
} }, ...c } = J(e, n), s = { x: o, y: t }, f = await qe(n, c), u = ne(z(i)), m = St(u);
let p = s[u], d = s[m];
if (r) {
const v = u === "y" ? "bottom" : "right";
p = Ve(p + f[u === "y" ? "top" : "left"], p, p - f[v]);
}
if (l) {
const v = m === "y" ? "bottom" : "right";
d = Ve(d + f[m === "y" ? "top" : "left"], d, d - f[v]);
}
const h = a.fn({ ...n, [u]: p, [m]: d });
return { ...h, data: { x: h.x - o, y: h.y - t } };
} };
}, fn = function(e) {
return e === void 0 && (e = {}), { options: e, fn(n) {
const { x: o, y: t, placement: i, rects: r, middlewareData: l } = n, { offset: a = 0, mainAxis: c = !0, crossAxis: s = !0 } = J(e, n), f = { x: o, y: t }, u = ne(i), m = St(u);
let p = f[u], d = f[m];
const h = J(a, n), v = typeof h == "number" ? { mainAxis: h, crossAxis: 0 } : { mainAxis: 0, crossAxis: 0, ...h };
if (c) {
const b = u === "y" ? "height" : "width", P = r.reference[u] - r.floating[b] + v.mainAxis, x = r.reference[u] + r.reference[b] - v.mainAxis;
p < P ? p = P : p > x && (p = x);
}
if (s) {
var g, w;
const b = u === "y" ? "width" : "height", P = ["top", "left"].includes(z(i)), x = r.reference[m] - r.floating[b] + (P && ((g = l.offset) == null ? void 0 : g[m]) || 0) + (P ? 0 : v.crossAxis), E = r.reference[m] + r.reference[b] + (P ? 0 : ((w = l.offset) == null ? void 0 : w[m]) || 0) - (P ? v.crossAxis : 0);
d < x ? d = x : d > E && (d = E);
}
return { [u]: p, [m]: d };
} };
}, dn = function(e) {
return e === void 0 && (e = {}), { name: "size", options: e, async fn(n) {
const { placement: o, rects: t, platform: i, elements: r } = n, { apply: l = () => {
}, ...a } = J(e, n), c = await qe(n, a), s = z(o), f = de(o), u = ne(o) === "x", { width: m, height: p } = t.floating;
let d, h;
s === "top" || s === "bottom" ? (d = s, h = f === (await (i.isRTL == null ? void 0 : i.isRTL(r.floating)) ? "start" : "end") ? "left" : "right") : (h = s, d = f === "end" ? "top" : "bottom");
const v = p - c[d], g = m - c[h], w = !n.middlewareData.shift;
let b = v, P = g;
if (u) {
const E = m - c.left - c.right;
P = f || w ? he(g, E) : E;
} else {
const E = p - c.top - c.bottom;
b = f || w ? he(v, E) : E;
}
if (w && !f) {
const E = Q(c.left, 0), C = Q(c.right, 0), H = Q(c.top, 0), D = Q(c.bottom, 0);
u ? P = m - 2 * (E !== 0 || C !== 0 ? E + C : Q(c.left, c.right)) : b = p - 2 * (H !== 0 || D !== 0 ? H + D : Q(c.top, c.bottom));
}
await l({ ...n, availableWidth: P, availableHeight: b });
const x = await i.getDimensions(r.floating);
return m !== x.width || p !== x.height ? { reset: { rects: !0 } } : {};
} };
};
function F(e) {
var n;
return ((n = e.ownerDocument) == null ? void 0 : n.defaultView) || window;
}
function k(e) {
return F(e).getComputedStyle(e);
}
function Rt(e) {
return e instanceof F(e).Node;
}
function Z(e) {
return Rt(e) ? (e.nodeName || "").toLowerCase() : "#document";
}
function N(e) {
return e instanceof F(e).HTMLElement;
}
function X(e) {
return e instanceof F(e).Element;
}
function nt(e) {
return typeof ShadowRoot < "u" && (e instanceof F(e).ShadowRoot || e instanceof ShadowRoot);
}
function ve(e) {
const { overflow: n, overflowX: o, overflowY: t, display: i } = k(e);
return /auto|scroll|overlay|hidden|clip/.test(n + t + o) && !["inline", "contents"].includes(i);
}
function pn(e) {
return ["table", "td", "th"].includes(Z(e));
}
function We(e) {
const n = Ue(), o = k(e);
return o.transform !== "none" || o.perspective !== "none" || !n && !!o.backdropFilter && o.backdropFilter !== "none" || !n && !!o.filter && o.filter !== "none" || ["transform", "perspective", "filter"].some((t) => (o.willChange || "").includes(t)) || ["paint", "layout", "strict", "content"].some((t) => (o.contain || "").includes(t));
}
function Ue() {
return !(typeof CSS > "u" || !CSS.supports) && CSS.supports("-webkit-backdrop-filter", "none");
}
function $e(e) {
return ["html", "body", "#document"].includes(Z(e));
}
const Be = Math.min, ae = Math.max, Oe = Math.round, Pe = Math.floor, ee = (e) => ({ x: e, y: e });
function At(e) {
const n = k(e);
let o = parseFloat(n.width) || 0, t = parseFloat(n.height) || 0;
const i = N(e), r = i ? e.offsetWidth : o, l = i ? e.offsetHeight : t, a = Oe(o) !== r || Oe(t) !== l;
return a && (o = r, t = l), { width: o, height: t, $: a };
}
function Ge(e) {
return X(e) ? e : e.contextElement;
}
function ue(e) {
const n = Ge(e);
if (!N(n)) return ee(1);
const o = n.getBoundingClientRect(), { width: t, height: i, $: r } = At(n);
let l = (r ? Oe(o.width) : o.width) / t, a = (r ? Oe(o.height) : o.height) / i;
return l && Number.isFinite(l) || (l = 1), a && Number.isFinite(a) || (a = 1), { x: l, y: a };
}
const ot = ee(0);
function Ot(e, n, o) {
var t, i;
if (n === void 0 && (n = !0), !Ue()) return ot;
const r = e ? F(e) : window;
return !o || n && o !== r ? ot : { x: ((t = r.visualViewport) == null ? void 0 : t.offsetLeft) || 0, y: ((i = r.visualViewport) == null ? void 0 : i.offsetTop) || 0 };
}
function te(e, n, o, t) {
n === void 0 && (n = !1), o === void 0 && (o = !1);
const i = e.getBoundingClientRect(), r = Ge(e);
let l = ee(1);
n && (t ? X(t) && (l = ue(t)) : l = ue(e));
const a = Ot(r, o, t);
let c = (i.left + a.x) / l.x, s = (i.top + a.y) / l.y, f = i.width / l.x, u = i.height / l.y;
if (r) {
const m = F(r), p = t && X(t) ? F(t) : t;
let d = m.frameElement;
for (; d && t && p !== m; ) {
const h = ue(d), v = d.getBoundingClientRect(), g = getComputedStyle(d), w = v.left + (d.clientLeft + parseFloat(g.paddingLeft)) * h.x, b = v.top + (d.clientTop + parseFloat(g.paddingTop)) * h.y;
c *= h.x, s *= h.y, f *= h.x, u *= h.y, c += w, s += b, d = F(d).frameElement;
}
}
return Re({ width: f, height: u, x: c, y: s });
}
function Y(e) {
return ((Rt(e) ? e.ownerDocument : e.document) || window.document).documentElement;
}
function Me(e) {
return X(e) ? { scrollLeft: e.scrollLeft, scrollTop: e.scrollTop } : { scrollLeft: e.pageXOffset, scrollTop: e.pageYOffset };
}
function Tt(e) {
return te(Y(e)).left + Me(e).scrollLeft;
}
function fe(e) {
if (Z(e) === "html") return e;
const n = e.assignedSlot || e.parentNode || nt(e) && e.host || Y(e);
return nt(n) ? n.host : n;
}
function Ct(e) {
const n = fe(e);
return $e(n) ? e.ownerDocument ? e.ownerDocument.body : e.body : N(n) && ve(n) ? n : Ct(n);
}
function Te(e, n) {
var o;
n === void 0 && (n = []);
const t = Ct(e), i = t === ((o = e.ownerDocument) == null ? void 0 : o.body), r = F(t);
return i ? n.concat(r, r.visualViewport || [], ve(t) ? t : []) : n.concat(t, Te(t));
}
function rt(e, n, o) {
let t;
if (n === "viewport") t = function(i, r) {
const l = F(i), a = Y(i), c = l.visualViewport;
let s = a.clientWidth, f = a.clientHeight, u = 0, m = 0;
if (c) {
s = c.width, f = c.height;
const p = Ue();
(!p || p && r === "fixed") && (u = c.offsetLeft, m = c.offsetTop);
}
return { width: s, height: f, x: u, y: m };
}(e, o);
else if (n === "document") t = function(i) {
const r = Y(i), l = Me(i), a = i.ownerDocument.body, c = ae(r.scrollWidth, r.clientWidth, a.scrollWidth, a.clientWidth), s = ae(r.scrollHeight, r.clientHeight, a.scrollHeight, a.clientHeight);
let f = -l.scrollLeft + Tt(i);
const u = -l.scrollTop;
return k(a).direction === "rtl" && (f += ae(r.clientWidth, a.clientWidth) - c), { width: c, height: s, x: f, y: u };
}(Y(e));
else if (X(n)) t = function(i, r) {
const l = te(i, !0, r === "fixed"), a = l.top + i.clientTop, c = l.left + i.clientLeft, s = N(i) ? ue(i) : ee(1);
return { width: i.clientWidth * s.x, height: i.clientHeight * s.y, x: c * s.x, y: a * s.y };
}(n, o);
else {
const i = Ot(e);
t = { ...n, x: n.x - i.x, y: n.y - i.y };
}
return Re(t);
}
function Ht(e, n) {
const o = fe(e);
return !(o === n || !X(o) || $e(o)) && (k(o).position === "fixed" || Ht(o, n));
}
function it(e, n) {
return N(e) && k(e).position !== "fixed" ? n ? n(e) : e.offsetParent : null;
}
function st(e, n) {
const o = F(e);
if (!N(e)) return o;
let t = it(e, n);
for (; t && pn(t) && k(t).position === "static"; ) t = it(t, n);
return t && (Z(t) === "html" || Z(t) === "body" && k(t).position === "static" && !We(t)) ? o : t || function(i) {
let r = fe(i);
for (; N(r) && !$e(r); ) {
if (We(r)) return r;
r = fe(r);
}
return null;
}(e) || o;
}
function mn(e, n, o) {
const t = N(n), i = Y(n), r = o === "fixed", l = te(e, !0, r, n);
let a = { scrollLeft: 0, scrollTop: 0 };
const c = ee(0);
if (t || !t && !r) if ((Z(n) !== "body" || ve(i)) && (a = Me(n)), N(n)) {
const s = te(n, !0, r, n);
c.x = s.x + n.clientLeft, c.y = s.y + n.clientTop;
} else i && (c.x = Tt(i));
return { x: l.left + a.scrollLeft - c.x, y: l.top + a.scrollTop - c.y, width: l.width, height: l.height };
}
const hn = { getClippingRect: function(e) {
let { element: n, boundary: o, rootBoundary: t, strategy: i } = e;
const r = o === "clippingAncestors" ? function(s, f) {
const u = f.get(s);
if (u) return u;
let m = Te(s).filter((v) => X(v) && Z(v) !== "body"), p = null;
const d = k(s).position === "fixed";
let h = d ? fe(s) : s;
for (; X(h) && !$e(h); ) {
const v = k(h), g = We(h);
g || v.position !== "fixed" || (p = null), (d ? !g && !p : !g && v.position === "static" && p && ["absolute", "fixed"].includes(p.position) || ve(h) && !g && Ht(s, h)) ? m = m.filter((w) => w !== h) : p = v, h = fe(h);
}
return f.set(s, m), m;
}(n, this._c) : [].concat(o), l = [...r, t], a = l[0], c = l.reduce((s, f) => {
const u = rt(n, f, i);
return s.top = ae(u.top, s.top), s.right = Be(u.right, s.right), s.bottom = Be(u.bottom, s.bottom), s.left = ae(u.left, s.left), s;
}, rt(n, a, i));
return { width: c.right - c.left, height: c.bottom - c.top, x: c.left, y: c.top };
}, convertOffsetParentRelativeRectToViewportRelativeRect: function(e) {
let { rect: n, offsetParent: o, strategy: t } = e;
const i = N(o), r = Y(o);
if (o === r) return n;
let l = { scrollLeft: 0, scrollTop: 0 }, a = ee(1);
const c = ee(0);
if ((i || !i && t !== "fixed") && ((Z(o) !== "body" || ve(r)) && (l = Me(o)), N(o))) {
const s = te(o);
a = ue(o), c.x = s.x + o.clientLeft, c.y = s.y + o.clientTop;
}
return { width: n.width * a.x, height: n.height * a.y, x: n.x * a.x - l.scrollLeft * a.x + c.x, y: n.y * a.y - l.scrollTop * a.y + c.y };
}, isElement: X, getDimensions: function(e) {
return At(e);
}, getOffsetParent: st, getDocumentElement: Y, getScale: ue, async getElementRects(e) {
let { reference: n, floating: o, strategy: t } = e;
const i = this.getOffsetParent || st, r = this.getDimensions;
return { reference: mn(n, await i(o), t), floating: { x: 0, y: 0, ...await r(o) } };
}, getClientRects: (e) => Array.from(e.getClientRects()), isRTL: (e) => k(e).direction === "rtl" };
function vn(e, n, o, t) {
t === void 0 && (t = {});
const { ancestorScroll: i = !0, ancestorResize: r = !0, elementResize: l = !0, layoutShift: a = typeof IntersectionObserver == "function", animationFrame: c = !1 } = t, s = Ge(e), f = i || r ? [...s ? Te(s) : [], ...Te(n)] : [];
f.forEach((h) => {
i && h.addEventListener("scroll", o, { passive: !0 }), r && h.addEventListener("resize", o);
});
const u = s && a ? function(h, v) {
let g, w = null;
const b = Y(h);
function P() {
clearTimeout(g), w && w.disconnect(), w = null;
}
return function x(E, C) {
E === void 0 && (E = !1), C === void 0 && (C = 1), P();
const { left: H, top: D, width: R, height: A } = h.getBoundingClientRect();
if (E || v(), !R || !A) return;
const $ = Pe(D), y = Pe(b.clientWidth - (H + R)), O = Pe(b.clientHeight - (D + A)), S = Pe(H);
let T = !0;
w = new IntersectionObserver((M) => {
const L = M[0].intersectionRatio;
if (L !== C) {
if (!T) return x();
L ? x(!1, L) : g = setTimeout(() => {
x(!1, 1e-7);
}, 100);
}
T = !1;
}, { rootMargin: -$ + "px " + -y + "px " + -O + "px " + -S + "px", threshold: ae(0, Be(1, C)) || 1 }), w.observe(h);
}(!0), P;
}(s, o) : null;
let m, p = null;
l && (p = new ResizeObserver(o), s && !c && p.observe(s), p.observe(n));
let d = c ? te(e) : null;
return c && function h() {
const v = te(e);
!d || v.x === d.x && v.y === d.y && v.width === d.width && v.height === d.height || o(), d = v, m = requestAnimationFrame(h);
}(), o(), () => {
f.forEach((h) => {
i && h.removeEventListener("scroll", o), r && h.removeEventListener("resize", o);
}), u && u(), p && p.disconnect(), p = null, c && cancelAnimationFrame(m);
};
}
const gn = (e, n, o) => {
const t = /* @__PURE__ */ new Map(), i = { platform: hn, ...o }, r = { ...i.platform, _c: t };
return tn(e, n, { ...i, platform: r });
};
var wn = "div";
function lt(e = 0, n = 0, o = 0, t = 0) {
if (typeof DOMRect == "function")
return new DOMRect(e, n, o, t);
const i = {
x: e,
y: n,
width: o,
height: t,
top: n,
right: e + o,
bottom: n + t,
left: e
};
return G(_({}, i), { toJSON: () => i });
}
function xn(e) {
if (!e) return lt();
const { x: n, y: o, width: t, height: i } = e;
return lt(n, o, t, i);
}
function yn(e, n) {
return {
contextElement: e || void 0,
getBoundingClientRect: () => {
const t = e, i = n == null ? void 0 : n(t);
return i || !t ? xn(i) : t.getBoundingClientRect();
}
};
}
function bn(e) {
return /^(?:top|bottom|left|right)(?:-(?:start|end))?$/.test(e);
}
function ct(e) {
const n = window.devicePixelRatio || 1;
return Math.round(e * n) / n;
}
function Pn(e, n) {
return an(({ placement: o }) => {
var t;
const i = ((e == null ? void 0 : e.clientHeight) || 0) / 2, r = typeof n.gutter == "number" ? n.gutter + i : (t = n.gutter) != null ? t : i;
return {
crossAxis: !!o.split("-")[1] ? void 0 : n.shift,
mainAxis: r,
alignmentAxis: n.shift
};
});
}
function En(e) {
if (e.flip === !1) return;
const n = typeof e.flip == "string" ? e.flip.split(" ") : void 0;
return He(
!n || n.every(bn),
process.env.NODE_ENV !== "production" && "`flip` expects a spaced-delimited list of placements"
), cn({
padding: e.overflowPadding,
fallbackPlacements: n
});
}
function Sn(e) {
if (!(!e.slide && !e.overlap))
return un({
mainAxis: e.slide,
crossAxis: e.overlap,
padding: e.overflowPadding,
limiter: fn()
});
}
function Rn(e) {
return dn({
padding: e.overflowPadding,
apply({ elements: n, availableWidth: o, availableHeight: t, rects: i }) {
const r = n.floating, l = Math.round(i.reference.width);
o = Math.floor(o), t = Math.floor(t), r.style.setProperty(
"--popover-anchor-width",
`${l}px`
), r.style.setProperty(
"--popover-available-width",
`${o}px`
), r.style.setProperty(
"--popover-available-height",
`${t}px`
), e.sameWidth && (r.style.width = `${l}px`), e.fitViewport && (r.style.maxWidth = `${o}px`, r.style.maxHeight = `${t}px`);
}
});
}
function An(e, n) {
if (e)
return nn({
element: e,
padding: n.arrowPadding
});
}
var $t = je(
function(n) {
var o = n, {
store: t,
modal: i = !1,
portal: r = !!i,
preserveTabOrder: l = !0,
autoFocusOnShow: a = !0,
wrapperProps: c,
fixed: s = !1,
flip: f = !0,
shift: u = 0,
slide: m = !0,
overlap: p = !1,
sameWidth: d = !1,
fitViewport: h = !1,
gutter: v,
arrowPadding: g = 4,
overflowPadding: w = 8,
getAnchorRect: b,
updatePosition: P
} = o, x = Ce(o, [
"store",
"modal",
"portal",
"preserveTabOrder",
"autoFocusOnShow",
"wrapperProps",
"fixed",
"flip",
"shift",
"slide",
"overlap",
"sameWidth",
"fitViewport",
"gutter",
"arrowPadding",
"overflowPadding",
"getAnchorRect",
"updatePosition"
]);
const E = wt();
t = t || E, He(
t,
process.env.NODE_ENV !== "production" && "Popover must receive a `store` prop or be wrapped in a PopoverProvider component."
);
const C = t.useState("arrowElement"), H = t.useState("anchorElement"), D = t.useState("disclosureElement"), R = t.useState("popoverElement"), A = t.useState("contentElement"), $ = t.useState("placement"), y = t.useState("mounted"), O = t.useState("rendered"), S = ce(null), [T, M] = Ye(!1), { portalRef: L, domReady: I } = ht(r, x.portalRef), V = me(b), W = me(P), K = !!P;
Le(() => {
if (!(R != null && R.isConnected)) return;
R.style.setProperty(
"--popover-overflow-padding",
`${w}px`
);
const B = yn(H, V), pe = async () => {
if (!y) return;
C || (S.current = S.current || document.createElement("div"));
const re = C || S.current, Ft = [
Pn(re, { gutter: v, shift: u }),
En({ flip: f, overflowPadding: w }),
Sn({ slide: m, overlap: p, overflowPadding: w }),
An(re, { arrowPadding: g }),
Rn({
sameWidth: d,
fitViewport: h,
overflowPadding: w
})
], ie = await gn(B, R, {
placement: $,
strategy: s ? "fixed" : "absolute",
middleware: Ft
});
t == null || t.setState("currentPlacement", ie.placement), M(!0);
const Lt = ct(ie.x), _t = ct(ie.y);
if (Object.assign(R.style, {
top: "0",
left: "0",
transform: `translate3d(${Lt}px,${_t}px,0)`
}), re && ie.middlewareData.arrow) {
const { x: we, y: xe } = ie.middlewareData.arrow, Ze = ie.placement.split("-")[0], ye = re.clientWidth / 2, be = re.clientHeight / 2, Ke = we != null ? we + ye : -ye, Qe = xe != null ? xe + be : -be;
R.style.setProperty(
"--popover-transform-origin",
{
top: `${Ke}px calc(100% + ${be}px)`,
bottom: `${Ke}px ${-be}px`,
left: `calc(100% + ${ye}px) ${Qe}px`,
right: `${-ye}px ${Qe}px`
}[Ze]
), Object.assign(re.style, {
left: we != null ? `${we}px` : "",
top: xe != null ? `${xe}px` : "",
[Ze]: "100%"
});
}
}, Dt = vn(B, R, async () => {
K ? (await W({ updatePosition: pe }), M(!0)) : await pe();
}, {
// JSDOM doesn't support ResizeObserver
elementResize: typeof ResizeObserver == "function"
});
return () => {
M(!1), Dt();
};
}, [
t,
O,
R,
C,
H,
R,
$,
y,
I,
s,
f,
u,
m,
p,
d,
h,
v,
g,
w,
V,
K,
W
]), Le(() => {
if (!y || !I || !(R != null && R.isConnected) || !(A != null && A.isConnected)) return;
const B = () => {
R.style.zIndex = getComputedStyle(A).zIndex;
};
B();
let pe = requestAnimationFrame(() => {
pe = requestAnimationFrame(B);
});
return () => cancelAnimationFrame(pe);
}, [y, I, R, A]);
const oe = s ? "fixed" : "absolute";
return x = _e(
x,
(B) => /* @__PURE__ */ Se.jsx(
"div",
G(_({}, c), {
style: _({
// https://floating-ui.com/docs/computeposition#initial-layout
position: oe,
top: 0,
left: 0,
width: "max-content"
}, c == null ? void 0 : c.style),
ref: t == null ? void 0 : t.setPopoverElement,
children: B
})
),
[t, oe, c]
), x = _e(
x,
(B) => /* @__PURE__ */ Se.jsx(xt, { value: t, children: B }),
[t]
), x = G(_({
// data-placing is not part of the public API. We're setting this here so
// we can wait for the popover to be positioned before other components
// move focus into it. For example, this attribute is observed by the
// Combobox component with the autoSelect behavior.
"data-placing": !T || void 0
}, x), {
style: _({
position: "relative"
}, x.style)
}), x = Vt(G(_({
store: t,
modal: i,
portal: r,
preserveTabOrder: l,
preserveTabOrderAnchor: D || H,
autoFocusOnShow: T && a
}, x), {
portalRef: L
})), x;
}
), Xn = dt(
ze(function(n) {
const o = $t(n);
return Xe(wn, o);
}),
wt
), ge = It(
[Kt],
[xt]
);
ge.useContext;
ge.useScopedContext;
var Je = ge.useProviderContext, Yn = ge.ContextProvider, On = ge.ScopedContextProvider;
function Tn(e = {}) {
var n;
const o = (n = e.store) == null ? void 0 : n.getState(), t = bt(le(q({}, e), {
placement: j(
e.placement,
o == null ? void 0 : o.placement,
"bottom"
)
})), i = j(e.timeout, o == null ? void 0 : o.timeout, 500), r = le(q({}, t.getState()), {
timeout: i,
showTimeout: j(e.showTimeout, o == null ? void 0 : o.showTimeout),
hideTimeout: j(e.hideTimeout, o == null ? void 0 : o.hideTimeout),
autoFocusOnShow: j(o == null ? void 0 : o.autoFocusOnShow, !1)
}), l = pt(r, t, e.store);
return le(q(q({}, t), l), {
setAutoFocusOnShow: (a) => l.setState("autoFocusOnShow", a)
});
}
function Cn(e, n, o) {
return Ee(e, o, "timeout"), Ee(e, o, "showTimeout"), Ee(e, o, "hideTimeout"), Pt(e, n, o);
}
function In(e = {}) {
const [n, o] = mt(Tn, e);
return Cn(n, o, e);
}
function Fe(e) {
return [e.clientX, e.clientY];
}
function at(e, n) {
const [o, t] = e;
let i = !1;
const r = n.length;
for (let l = r, a = 0, c = l - 1; a < l; c = a++) {
const [s, f] = n[a], [u, m] = n[c], [, p] = n[c === 0 ? l - 1 : c - 1] || [0, 0], d = (f - m) * (o - s) - (s - u) * (t - f);
if (m < f) {
if (t >= m && t < f) {
if (d === 0) return !0;
d > 0 && (t === m ? t > p && (i = !i) : i = !i);
}
} else if (f < m) {
if (t > f && t <= m) {
if (d === 0) return !0;
d < 0 && (t === m ? t < p && (i = !i) : i = !i);
}
} else if (t === f && (o >= u && o <= s || o >= s && o <= u))
return !0;
}
return i;
}
function Hn(e, n) {
const { top: o, right: t, bottom: i, left: r } = n, [l, a] = e, c = l < r ? "left" : l > t ? "right" : null, s = a < o ? "top" : a > i ? "bottom" : null;
return [c, s];
}
function ut(e, n) {
const o = e.getBoundingClientRect(), { top: t, right: i, bottom: r, left: l } = o, [a, c] = Hn(n, o), s = [n];
return a ? (c !== "top" && s.push([a === "left" ? l : i, t]), s.push([a === "left" ? i : l, t]), s.push([a === "left" ? i : l, r]), c !== "bottom" && s.push([a === "left" ? l : i, r])) : c === "top" ? (s.push([l, t]), s.push([l, r]), s.push([i, r]), s.push([i, t])) : (s.push([l, r]), s.push([l, t]), s.push([i, t]), s.push([i, r])), s;
}
var $n = "div";
function Mt(e, n, o, t) {
return Gt(n) ? !0 : e ? !!(Ne(n, e) || o && Ne(o, e) || t != null && t.some((i) => Mt(e, i, o))) : !1;
}
function Mn(e) {
var n = e, {
store: o
} = n, t = Ce(n, [
"store"
]);
const [i, r] = Ye(!1), l = o.useState("mounted");
U(() => {
l || r(!1);
}, [l]);
const a = t.onFocus, c = me((f) => {
a == null || a(f), !f.defaultPrevented && r(!0);
}), s = ce(null);
return U(() => zt(o, ["anchorElement"], (f) => {
s.current = f.anchorElement;
}), []), t = G(_({
autoFocusOnHide: i,
finalFocus: s
}, t), {
onFocus: c
}), t;
}
var ft = en(null), Dn = je(
function(n) {
var o = n, {
store: t,
modal: i = !1,
portal: r = !!i,
hideOnEscape: l = !0,
hideOnHoverOutside: a = !0,
disablePointerEventsOnApproach: c = !!a
} = o, s = Ce(o, [
"store",
"modal",
"portal",
"hideOnEscape",
"hideOnHoverOutside",
"disablePointerEventsOnApproach"
]);
const f = Je();
t = t || f, He(
t,
process.env.NODE_ENV !== "production" && "Hovercard must receive a `store` prop or be wrapped in a HovercardProvider component."
);
const u = ce(null), [m, p] = Ye([]), d = ce(0), h = ce(null), { portalRef: v, domReady: g } = ht(r, s.portalRef), w = vt(), b = !!a, P = ke(a), x = !!c, E = ke(
c
), C = t.useState("open"), H = t.useState("mounted");
U(() => {
if (!g || !H || !b && !x) return;
const y = u.current;
return y ? et(
se("mousemove", (S) => {
if (!t || !w()) return;
const { anchorElement: T, hideTimeout: M, timeout: L } = t.getState(), I = h.current, [V] = S.composedPath(), W = T;
if (Mt(V, y, W, m)) {
h.current = V && W && Ne(W, V) ? Fe(S) : null, window.clearTimeout(d.current), d.current = 0;
return;
}
if (!d.current) {
if (I) {
const K = Fe(S), oe = ut(y, I);
if (at(K, oe)) {
if (h.current = K, !E(S)) return;
S.preventDefault(), S.stopPropagation();
return;
}
}
P(S) && (d.current = window.setTimeout(() => {
d.current = 0, t == null || t.hide();
}, M ?? L));
}
}, !0),
() => clearTimeout(d.current)
) : void 0;
}, [
t,
w,
g,
H,
b,
x,
m,
E,
P
]), U(() => {
if (!g || !H || !x) return;
const y = (O) => {
const S = u.current;
if (!S) return;
const T = h.current;
if (!T) return;
const M = ut(S, T);
if (at(Fe(O), M)) {
if (!E(O)) return;
O.preventDefault(), O.stopPropagation();
}
};
return et(
// Note: we may need to add pointer events here in the future.
se("mouseenter", y, !0),
se("mouseover", y, !0),
se("mouseout", y, !0),
se("mouseleave", y, !0)
);
}, [g, H, x, E]), U(() => {
g && (C || t == null || t.setAutoFocusOnShow(!1));
}, [t, g, C]);
const D = qt(C);
U(() => {
if (g)
return () => {
D.current || t == null || t.setAutoFocusOnShow(!1);
};
}, [t, g]);
const R = Qt(ft);
Le(() => {
if (i || !r || !H || !g) return;
const y = u.current;
if (y)
return R == null ? void 0 : R(y);
}, [i, r, H, g]);
const A = yt(
(y) => {
p((S) => [...S, y]);
const O = R == null ? void 0 : R(y);
return () => {
p(
(S) => S.filter((T) => T !== y)
), O == null || O();
};
},
[R]
);
s = _e(
s,
(y) => /* @__PURE__ */ Se.jsx(On, { value: t, children: /* @__PURE__ */ Se.jsx(ft.Provider, { value: A, children: y }) }),
[t, A]
), s = G(_({}, s), {
ref: gt(u, s.ref)
}), s = Mn(_({ store: t }, s));
const $ = t.useState(
(y) => i || y.autoFocusOnShow
);
return s = $t(G(_({
store: t,
modal: i,
portal: r,
autoFocusOnShow: $
}, s), {
portalRef: v,
hideOnEscape(y) {
return Ut(l, y) ? !1 : (requestAnimationFrame(() => {
requestAnimationFrame(() => {
t == null || t.hide();
});
}), !0);
}
})), s;
}
), qn = dt(
ze(function(n) {
const o = Dn(n);
return Xe($n, o);
}),
Je
), Fn = "a", Ln = je(
function(n) {
var o = n, { store: t, showOnHover: i = !0 } = o, r = Ce(o, ["store", "showOnHover"]);
const l = Je();
t = t || l, He(
t,
process.env.NODE_ENV !== "production" && "HovercardAnchor must receive a `store` prop or be wrapped in a HovercardProvider component."
);
const a = Jt(r), c = ce(0);
U(() => () => window.clearTimeout(c.current), []), U(() => se("mouseleave", (g) => {
if (!t) return;
const { anchorElement: w } = t.getState();
w && g.target === w && (window.clearTimeout(c.current), c.current = 0);
}, !0), [t]);
const s = r.onMouseMove, f = ke(i), u = vt(), m = me((v) => {
if (s == null || s(v), a || !t || v.defaultPrevented || c.current || !u() || !f(v)) return;
const g = v.currentTarget;
t.setAnchorElement(g), t.setDisclosureElement(g);
const { showTimeout: w, timeout: b } = t.getState(), P = () => {
c.current = 0, u() && (t == null || t.setAnchorElement(g), t == null || t.show(), queueMicrotask(() => {
t == null || t.setDisclosureElement(g);
}));
}, x = w ?? b;
x === 0 ? P() : c.current = window.setTimeout(P, x);
}), p = r.onClick, d = me((v) => {
p == null || p(v), t && (window.clearTimeout(c.current), c.current = 0);
}), h = yt(
(v) => {
if (!t) return;
const { anchorElement: g } = t.getState();
g != null && g.isConnected || t.setAnchorElement(v);
},
[t]
);
return r = G(_({}, r), {
ref: gt(h, r.ref),
onMouseMove: m,
onClick: d
}), r = Zt(r), r;
}
), Un = ze(function(n) {
const o = Ln(n);
return Xe(Fn, o);
});
export {
Un as H,
Xn as P,
qn as a,
In as b,
Tn as c,
Cn as d,
On as e,
Yn as f,
Dn as g,
Ln as h,
zn as u
};