UNPKG

mongodb-chatbot-ui

Version:

UI React components for the MongoDB Chatbot Framework

1,549 lines (1,540 loc) 47.9 kB
import * as g from "react"; import X, { useLayoutEffect as Xe, useEffect as Vn, forwardRef as Bn, useRef as Hn, useState as ie, useMemo as zn, Fragment as $n } from "react"; import { p as Ut } from "./jsx-runtime.js"; import * as Wn from "react-dom"; import { ag as _n, m as O, aP as Zn, aQ as Un, aH as Yn, N as Xn, t as qn, aR as Qn, aE as Kn, aS as Gn, aG as Jn, aT as to, b as eo, n as tt, Q as no } from "./index2.js"; import { l as oo } from "./index9.js"; import { s as ro } from "./Transition.js"; function St() { return typeof window < "u"; } function ut(t) { return qe(t) ? (t.nodeName || "").toLowerCase() : "#document"; } function $(t) { var e; return (t == null || (e = t.ownerDocument) == null ? void 0 : e.defaultView) || window; } function G(t) { var e; return (e = (qe(t) ? t.ownerDocument : t.document) || window.document) == null ? void 0 : e.documentElement; } function qe(t) { return St() ? t instanceof Node || t instanceof $(t).Node : !1; } function F(t) { return St() ? t instanceof Element || t instanceof $(t).Element : !1; } function K(t) { return St() ? t instanceof HTMLElement || t instanceof $(t).HTMLElement : !1; } function se(t) { return !St() || typeof ShadowRoot > "u" ? !1 : t instanceof ShadowRoot || t instanceof $(t).ShadowRoot; } const io = /* @__PURE__ */ new Set(["inline", "contents"]); function vt(t) { const { overflow: e, overflowX: n, overflowY: o, display: r } = Z(t); return /auto|scroll|overlay|hidden|clip/.test(e + o + n) && !io.has(r); } const so = /* @__PURE__ */ new Set(["table", "td", "th"]); function lo(t) { return so.has(ut(t)); } const co = [":popover-open", ":modal"]; function Mt(t) { return co.some((e) => { try { return t.matches(e); } catch { return !1; } }); } const ao = ["transform", "translate", "scale", "rotate", "perspective"], fo = ["transform", "translate", "scale", "rotate", "perspective", "filter"], uo = ["paint", "layout", "strict", "content"]; function Yt(t) { const e = Xt(), n = F(t) ? Z(t) : t; return ao.some((o) => n[o] ? n[o] !== "none" : !1) || (n.containerType ? n.containerType !== "normal" : !1) || !e && (n.backdropFilter ? n.backdropFilter !== "none" : !1) || !e && (n.filter ? n.filter !== "none" : !1) || fo.some((o) => (n.willChange || "").includes(o)) || uo.some((o) => (n.contain || "").includes(o)); } function mo(t) { let e = nt(t); for (; K(e) && !at(e); ) { if (Yt(e)) return e; if (Mt(e)) return null; e = nt(e); } return null; } function Xt() { return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none"); } const po = /* @__PURE__ */ new Set(["html", "body", "#document"]); function at(t) { return po.has(ut(t)); } function Z(t) { return $(t).getComputedStyle(t); } function Tt(t) { return F(t) ? { scrollLeft: t.scrollLeft, scrollTop: t.scrollTop } : { scrollLeft: t.scrollX, scrollTop: t.scrollY }; } function nt(t) { if (ut(t) === "html") return t; const e = ( // Step into the shadow DOM of the parent of a slotted node. t.assignedSlot || // DOM Element detected. t.parentNode || // ShadowRoot detected. se(t) && t.host || // Fallback. G(t) ); return se(e) ? e.host : e; } function Qe(t) { const e = nt(t); return at(e) ? t.ownerDocument ? t.ownerDocument.body : t.body : K(e) && vt(e) ? e : Qe(e); } function ht(t, e, n) { var o; e === void 0 && (e = []), n === void 0 && (n = !0); const r = Qe(t), i = r === ((o = t.ownerDocument) == null ? void 0 : o.body), s = $(r); if (i) { const l = Vt(s); return e.concat(s, s.visualViewport || [], vt(r) ? r : [], l && n ? ht(l) : []); } return e.concat(r, ht(r, [], n)); } function Vt(t) { return t.parent && Object.getPrototypeOf(t.parent) ? t.frameElement : null; } const Bt = Math.min, lt = Math.max, Rt = Math.round, xt = Math.floor, Q = (t) => ({ x: t, y: t }), go = { left: "right", right: "left", bottom: "top", top: "bottom" }, ho = { start: "end", end: "start" }; function qt(t, e) { return typeof t == "function" ? t(e) : t; } function ft(t) { return t.split("-")[0]; } function Lt(t) { return t.split("-")[1]; } function vo(t) { return t === "x" ? "y" : "x"; } function Ke(t) { return t === "y" ? "height" : "width"; } const yo = /* @__PURE__ */ new Set(["top", "bottom"]); function rt(t) { return yo.has(ft(t)) ? "y" : "x"; } function Ge(t) { return vo(rt(t)); } function wo(t, e, n) { n === void 0 && (n = !1); const o = Lt(t), r = Ge(t), i = Ke(r); let s = r === "x" ? o === (n ? "end" : "start") ? "right" : "left" : o === "start" ? "bottom" : "top"; return e.reference[i] > e.floating[i] && (s = Ct(s)), [s, Ct(s)]; } function xo(t) { const e = Ct(t); return [Ht(t), e, Ht(e)]; } function Ht(t) { return t.replace(/start|end/g, (e) => ho[e]); } const le = ["left", "right"], ce = ["right", "left"], bo = ["top", "bottom"], Eo = ["bottom", "top"]; function Ro(t, e, n) { switch (t) { case "top": case "bottom": return n ? e ? ce : le : e ? le : ce; case "left": case "right": return e ? bo : Eo; default: return []; } } function Co(t, e, n, o) { const r = Lt(t); let i = Ro(ft(t), n === "start", o); return r && (i = i.map((s) => s + "-" + r), e && (i = i.concat(i.map(Ht)))), i; } function Ct(t) { return t.replace(/left|right|bottom|top/g, (e) => go[e]); } function Oo(t) { return { top: 0, right: 0, bottom: 0, left: 0, ...t }; } function Po(t) { return typeof t != "number" ? Oo(t) : { top: t, right: t, bottom: t, left: t }; } function Ot(t) { const { x: e, y: n, width: o, height: r } = t; return { width: o, height: r, top: n, left: e, right: e + o, bottom: n + r, x: e, y: n }; } function ae(t, e, n) { let { reference: o, floating: r } = t; const i = rt(e), s = Ge(e), l = Ke(s), c = ft(e), f = i === "y", d = o.x + o.width / 2 - r.width / 2, a = o.y + o.height / 2 - r.height / 2, m = o[l] / 2 - r[l] / 2; let u; switch (c) { case "top": u = { x: d, y: o.y - r.height }; break; case "bottom": u = { x: d, y: o.y + o.height }; break; case "right": u = { x: o.x + o.width, y: a }; break; case "left": u = { x: o.x - r.width, y: a }; break; default: u = { x: o.x, y: o.y }; } switch (Lt(e)) { case "start": u[s] -= m * (n && f ? -1 : 1); break; case "end": u[s] += m * (n && f ? -1 : 1); break; } return u; } const Ao = async (t, e, n) => { const { placement: o = "bottom", strategy: r = "absolute", middleware: i = [], platform: s } = n, l = i.filter(Boolean), c = await (s.isRTL == null ? void 0 : s.isRTL(e)); let f = await s.getElementRects({ reference: t, floating: e, strategy: r }), { x: d, y: a } = ae(f, o, c), m = o, u = {}, h = 0; for (let y = 0; y < l.length; y++) { const { name: b, fn: v } = l[y], { x: E, y: p, data: R, reset: x } = await v({ x: d, y: a, initialPlacement: o, placement: m, strategy: r, middlewareData: u, rects: f, platform: s, elements: { reference: t, floating: e } }); d = E ?? d, a = p ?? a, u = { ...u, [b]: { ...u[b], ...R } }, x && h <= 50 && (h++, typeof x == "object" && (x.placement && (m = x.placement), x.rects && (f = x.rects === !0 ? await s.getElementRects({ reference: t, floating: e, strategy: r }) : x.rects), { x: d, y: a } = ae(f, m, c)), y = -1); } return { x: d, y: a, placement: m, strategy: r, middlewareData: u }; }; async function So(t, e) { var n; e === void 0 && (e = {}); const { x: o, y: r, platform: i, rects: s, elements: l, strategy: c } = t, { boundary: f = "clippingAncestors", rootBoundary: d = "viewport", elementContext: a = "floating", altBoundary: m = !1, padding: u = 0 } = qt(e, t), h = Po(u), b = l[m ? a === "floating" ? "reference" : "floating" : a], v = Ot(await i.getClippingRect({ element: (n = await (i.isElement == null ? void 0 : i.isElement(b))) == null || n ? b : b.contextElement || await (i.getDocumentElement == null ? void 0 : i.getDocumentElement(l.floating)), boundary: f, rootBoundary: d, strategy: c })), E = a === "floating" ? { x: o, y: r, width: s.floating.width, height: s.floating.height } : s.reference, p = await (i.getOffsetParent == null ? void 0 : i.getOffsetParent(l.floating)), R = await (i.isElement == null ? void 0 : i.isElement(p)) ? await (i.getScale == null ? void 0 : i.getScale(p)) || { x: 1, y: 1 } : { x: 1, y: 1 }, x = Ot(i.convertOffsetParentRelativeRectToViewportRelativeRect ? await i.convertOffsetParentRelativeRectToViewportRelativeRect({ elements: l, rect: E, offsetParent: p, strategy: c }) : E); return { top: (v.top - x.top + h.top) / R.y, bottom: (x.bottom - v.bottom + h.bottom) / R.y, left: (v.left - x.left + h.left) / R.x, right: (x.right - v.right + h.right) / R.x }; } const Mo = function(t) { return t === void 0 && (t = {}), { name: "flip", options: t, async fn(e) { var n, o; const { placement: r, middlewareData: i, rects: s, initialPlacement: l, platform: c, elements: f } = e, { mainAxis: d = !0, crossAxis: a = !0, fallbackPlacements: m, fallbackStrategy: u = "bestFit", fallbackAxisSideDirection: h = "none", flipAlignment: y = !0, ...b } = qt(t, e); if ((n = i.arrow) != null && n.alignmentOffset) return {}; const v = ft(r), E = rt(l), p = ft(l) === l, R = await (c.isRTL == null ? void 0 : c.isRTL(f.floating)), x = m || (p || !y ? [Ct(l)] : xo(l)), M = h !== "none"; !m && M && x.push(...Co(l, y, h, R)); const T = [l, ...x], B = await So(e, b), _ = []; let j = ((o = i.flip) == null ? void 0 : o.overflows) || []; if (d && _.push(B[v]), a) { const N = wo(r, s, R); _.push(B[N[0]], B[N[1]]); } if (j = [...j, { placement: r, overflows: _ }], !_.every((N) => N <= 0)) { var I, J; const N = (((I = i.flip) == null ? void 0 : I.index) || 0) + 1, U = T[N]; if (U && (!(a === "alignment" ? E !== rt(U) : !1) || // We leave the current main axis only if every placement on that axis // overflows the main axis. j.every((C) => C.overflows[0] > 0 && rt(C.placement) === E))) return { data: { index: N, overflows: j }, reset: { placement: U } }; let L = (J = j.filter((W) => W.overflows[0] <= 0).sort((W, C) => W.overflows[1] - C.overflows[1])[0]) == null ? void 0 : J.placement; if (!L) switch (u) { case "bestFit": { var H; const W = (H = j.filter((C) => { if (M) { const D = rt(C.placement); return D === E || // Create a bias to the `y` side axis due to horizontal // reading directions favoring greater width. D === "y"; } return !0; }).map((C) => [C.placement, C.overflows.filter((D) => D > 0).reduce((D, Y) => D + Y, 0)]).sort((C, D) => C[1] - D[1])[0]) == null ? void 0 : H[0]; W && (L = W); break; } case "initialPlacement": L = l; break; } if (r !== L) return { reset: { placement: L } }; } return {}; } }; }, To = /* @__PURE__ */ new Set(["left", "top"]); async function Lo(t, e) { const { placement: n, platform: o, elements: r } = t, i = await (o.isRTL == null ? void 0 : o.isRTL(r.floating)), s = ft(n), l = Lt(n), c = rt(n) === "y", f = To.has(s) ? -1 : 1, d = i && c ? -1 : 1, a = qt(e, t); let { mainAxis: m, crossAxis: u, alignmentAxis: h } = typeof a == "number" ? { mainAxis: a, crossAxis: 0, alignmentAxis: null } : { mainAxis: a.mainAxis || 0, crossAxis: a.crossAxis || 0, alignmentAxis: a.alignmentAxis }; return l && typeof h == "number" && (u = l === "end" ? h * -1 : h), c ? { x: u * d, y: m * f } : { x: m * f, y: u * d }; } const No = function(t) { return t === void 0 && (t = 0), { name: "offset", options: t, async fn(e) { var n, o; const { x: r, y: i, placement: s, middlewareData: l } = e, c = await Lo(e, t); return s === ((n = l.offset) == null ? void 0 : n.placement) && (o = l.arrow) != null && o.alignmentOffset ? {} : { x: r + c.x, y: i + c.y, data: { ...c, placement: s } }; } }; }; function Je(t) { const e = Z(t); let n = parseFloat(e.width) || 0, o = parseFloat(e.height) || 0; const r = K(t), i = r ? t.offsetWidth : n, s = r ? t.offsetHeight : o, l = Rt(n) !== i || Rt(o) !== s; return l && (n = i, o = s), { width: n, height: o, $: l }; } function Qt(t) { return F(t) ? t : t.contextElement; } function ct(t) { const e = Qt(t); if (!K(e)) return Q(1); const n = e.getBoundingClientRect(), { width: o, height: r, $: i } = Je(e); let s = (i ? Rt(n.width) : n.width) / o, l = (i ? Rt(n.height) : n.height) / r; return (!s || !Number.isFinite(s)) && (s = 1), (!l || !Number.isFinite(l)) && (l = 1), { x: s, y: l }; } const Do = /* @__PURE__ */ Q(0); function tn(t) { const e = $(t); return !Xt() || !e.visualViewport ? Do : { x: e.visualViewport.offsetLeft, y: e.visualViewport.offsetTop }; } function Fo(t, e, n) { return e === void 0 && (e = !1), !n || e && n !== $(t) ? !1 : e; } function it(t, e, n, o) { e === void 0 && (e = !1), n === void 0 && (n = !1); const r = t.getBoundingClientRect(), i = Qt(t); let s = Q(1); e && (o ? F(o) && (s = ct(o)) : s = ct(t)); const l = Fo(i, n, o) ? tn(i) : Q(0); let c = (r.left + l.x) / s.x, f = (r.top + l.y) / s.y, d = r.width / s.x, a = r.height / s.y; if (i) { const m = $(i), u = o && F(o) ? $(o) : o; let h = m, y = Vt(h); for (; y && o && u !== h; ) { const b = ct(y), v = y.getBoundingClientRect(), E = Z(y), p = v.left + (y.clientLeft + parseFloat(E.paddingLeft)) * b.x, R = v.top + (y.clientTop + parseFloat(E.paddingTop)) * b.y; c *= b.x, f *= b.y, d *= b.x, a *= b.y, c += p, f += R, h = $(y), y = Vt(h); } } return Ot({ width: d, height: a, x: c, y: f }); } function Kt(t, e) { const n = Tt(t).scrollLeft; return e ? e.left + n : it(G(t)).left + n; } function en(t, e, n) { n === void 0 && (n = !1); const o = t.getBoundingClientRect(), r = o.left + e.scrollLeft - (n ? 0 : ( // RTL <body> scrollbar. Kt(t, o) )), i = o.top + e.scrollTop; return { x: r, y: i }; } function jo(t) { let { elements: e, rect: n, offsetParent: o, strategy: r } = t; const i = r === "fixed", s = G(o), l = e ? Mt(e.floating) : !1; if (o === s || l && i) return n; let c = { scrollLeft: 0, scrollTop: 0 }, f = Q(1); const d = Q(0), a = K(o); if ((a || !a && !i) && ((ut(o) !== "body" || vt(s)) && (c = Tt(o)), K(o))) { const u = it(o); f = ct(o), d.x = u.x + o.clientLeft, d.y = u.y + o.clientTop; } const m = s && !a && !i ? en(s, c, !0) : Q(0); return { width: n.width * f.x, height: n.height * f.y, x: n.x * f.x - c.scrollLeft * f.x + d.x + m.x, y: n.y * f.y - c.scrollTop * f.y + d.y + m.y }; } function Io(t) { return Array.from(t.getClientRects()); } function ko(t) { const e = G(t), n = Tt(t), o = t.ownerDocument.body, r = lt(e.scrollWidth, e.clientWidth, o.scrollWidth, o.clientWidth), i = lt(e.scrollHeight, e.clientHeight, o.scrollHeight, o.clientHeight); let s = -n.scrollLeft + Kt(t); const l = -n.scrollTop; return Z(o).direction === "rtl" && (s += lt(e.clientWidth, o.clientWidth) - r), { width: r, height: i, x: s, y: l }; } function Vo(t, e) { const n = $(t), o = G(t), r = n.visualViewport; let i = o.clientWidth, s = o.clientHeight, l = 0, c = 0; if (r) { i = r.width, s = r.height; const f = Xt(); (!f || f && e === "fixed") && (l = r.offsetLeft, c = r.offsetTop); } return { width: i, height: s, x: l, y: c }; } const Bo = /* @__PURE__ */ new Set(["absolute", "fixed"]); function Ho(t, e) { const n = it(t, !0, e === "fixed"), o = n.top + t.clientTop, r = n.left + t.clientLeft, i = K(t) ? ct(t) : Q(1), s = t.clientWidth * i.x, l = t.clientHeight * i.y, c = r * i.x, f = o * i.y; return { width: s, height: l, x: c, y: f }; } function fe(t, e, n) { let o; if (e === "viewport") o = Vo(t, n); else if (e === "document") o = ko(G(t)); else if (F(e)) o = Ho(e, n); else { const r = tn(t); o = { x: e.x - r.x, y: e.y - r.y, width: e.width, height: e.height }; } return Ot(o); } function nn(t, e) { const n = nt(t); return n === e || !F(n) || at(n) ? !1 : Z(n).position === "fixed" || nn(n, e); } function zo(t, e) { const n = e.get(t); if (n) return n; let o = ht(t, [], !1).filter((l) => F(l) && ut(l) !== "body"), r = null; const i = Z(t).position === "fixed"; let s = i ? nt(t) : t; for (; F(s) && !at(s); ) { const l = Z(s), c = Yt(s); !c && l.position === "fixed" && (r = null), (i ? !c && !r : !c && l.position === "static" && !!r && Bo.has(r.position) || vt(s) && !c && nn(t, s)) ? o = o.filter((d) => d !== s) : r = l, s = nt(s); } return e.set(t, o), o; } function $o(t) { let { element: e, boundary: n, rootBoundary: o, strategy: r } = t; const s = [...n === "clippingAncestors" ? Mt(e) ? [] : zo(e, this._c) : [].concat(n), o], l = s[0], c = s.reduce((f, d) => { const a = fe(e, d, r); return f.top = lt(a.top, f.top), f.right = Bt(a.right, f.right), f.bottom = Bt(a.bottom, f.bottom), f.left = lt(a.left, f.left), f; }, fe(e, l, r)); return { width: c.right - c.left, height: c.bottom - c.top, x: c.left, y: c.top }; } function Wo(t) { const { width: e, height: n } = Je(t); return { width: e, height: n }; } function _o(t, e, n) { const o = K(e), r = G(e), i = n === "fixed", s = it(t, !0, i, e); let l = { scrollLeft: 0, scrollTop: 0 }; const c = Q(0); function f() { c.x = Kt(r); } if (o || !o && !i) if ((ut(e) !== "body" || vt(r)) && (l = Tt(e)), o) { const u = it(e, !0, i, e); c.x = u.x + e.clientLeft, c.y = u.y + e.clientTop; } else r && f(); i && !o && r && f(); const d = r && !o && !i ? en(r, l) : Q(0), a = s.left + l.scrollLeft - c.x - d.x, m = s.top + l.scrollTop - c.y - d.y; return { x: a, y: m, width: s.width, height: s.height }; } function Dt(t) { return Z(t).position === "static"; } function ue(t, e) { if (!K(t) || Z(t).position === "fixed") return null; if (e) return e(t); let n = t.offsetParent; return G(t) === n && (n = n.ownerDocument.body), n; } function on(t, e) { const n = $(t); if (Mt(t)) return n; if (!K(t)) { let r = nt(t); for (; r && !at(r); ) { if (F(r) && !Dt(r)) return r; r = nt(r); } return n; } let o = ue(t, e); for (; o && lo(o) && Dt(o); ) o = ue(o, e); return o && at(o) && Dt(o) && !Yt(o) ? n : o || mo(t) || n; } const Zo = async function(t) { const e = this.getOffsetParent || on, n = this.getDimensions, o = await n(t.floating); return { reference: _o(t.reference, await e(t.floating), t.strategy), floating: { x: 0, y: 0, width: o.width, height: o.height } }; }; function Uo(t) { return Z(t).direction === "rtl"; } const Yo = { convertOffsetParentRelativeRectToViewportRelativeRect: jo, getDocumentElement: G, getClippingRect: $o, getOffsetParent: on, getElementRects: Zo, getClientRects: Io, getDimensions: Wo, getScale: ct, isElement: F, isRTL: Uo }; function rn(t, e) { return t.x === e.x && t.y === e.y && t.width === e.width && t.height === e.height; } function Xo(t, e) { let n = null, o; const r = G(t); function i() { var l; clearTimeout(o), (l = n) == null || l.disconnect(), n = null; } function s(l, c) { l === void 0 && (l = !1), c === void 0 && (c = 1), i(); const f = t.getBoundingClientRect(), { left: d, top: a, width: m, height: u } = f; if (l || e(), !m || !u) return; const h = xt(a), y = xt(r.clientWidth - (d + m)), b = xt(r.clientHeight - (a + u)), v = xt(d), p = { rootMargin: -h + "px " + -y + "px " + -b + "px " + -v + "px", threshold: lt(0, Bt(1, c)) || 1 }; let R = !0; function x(M) { const T = M[0].intersectionRatio; if (T !== c) { if (!R) return s(); T ? s(!1, T) : o = setTimeout(() => { s(!1, 1e-7); }, 1e3); } T === 1 && !rn(f, t.getBoundingClientRect()) && s(), R = !1; } try { n = new IntersectionObserver(x, { ...p, // Handle <iframe>s root: r.ownerDocument }); } catch { n = new IntersectionObserver(x, p); } n.observe(t); } return s(!0), i; } function qo(t, e, n, o) { o === void 0 && (o = {}); const { ancestorScroll: r = !0, ancestorResize: i = !0, elementResize: s = typeof ResizeObserver == "function", layoutShift: l = typeof IntersectionObserver == "function", animationFrame: c = !1 } = o, f = Qt(t), d = r || i ? [...f ? ht(f) : [], ...ht(e)] : []; d.forEach((v) => { r && v.addEventListener("scroll", n, { passive: !0 }), i && v.addEventListener("resize", n); }); const a = f && l ? Xo(f, n) : null; let m = -1, u = null; s && (u = new ResizeObserver((v) => { let [E] = v; E && E.target === f && u && (u.unobserve(e), cancelAnimationFrame(m), m = requestAnimationFrame(() => { var p; (p = u) == null || p.observe(e); })), n(); }), f && !c && u.observe(f), u.observe(e)); let h, y = c ? it(t) : null; c && b(); function b() { const v = it(t); y && !rn(y, v) && n(), y = v, h = requestAnimationFrame(b); } return n(), () => { var v; d.forEach((E) => { r && E.removeEventListener("scroll", n), i && E.removeEventListener("resize", n); }), a == null || a(), (v = u) == null || v.disconnect(), u = null, c && cancelAnimationFrame(h); }; } const Qo = No, Ko = Mo, Go = (t, e, n) => { const o = /* @__PURE__ */ new Map(), r = { platform: Yo, ...n }, i = { ...r.platform, _c: o }; return Ao(t, e, { ...r, platform: i }); }; var Jo = typeof document < "u", tr = function() { }, bt = Jo ? Xe : tr; function Pt(t, e) { if (t === e) return !0; if (typeof t != typeof e) return !1; if (typeof t == "function" && t.toString() === e.toString()) return !0; let n, o, r; if (t && e && typeof t == "object") { if (Array.isArray(t)) { if (n = t.length, n !== e.length) return !1; for (o = n; o-- !== 0; ) if (!Pt(t[o], e[o])) return !1; return !0; } if (r = Object.keys(t), n = r.length, n !== Object.keys(e).length) return !1; for (o = n; o-- !== 0; ) if (!{}.hasOwnProperty.call(e, r[o])) return !1; for (o = n; o-- !== 0; ) { const i = r[o]; if (!(i === "_owner" && t.$$typeof) && !Pt(t[i], e[i])) return !1; } return !0; } return t !== t && e !== e; } function sn(t) { return typeof window > "u" ? 1 : (t.ownerDocument.defaultView || window).devicePixelRatio || 1; } function de(t, e) { const n = sn(t); return Math.round(e * n) / n; } function Ft(t) { const e = g.useRef(t); return bt(() => { e.current = t; }), e; } function er(t) { t === void 0 && (t = {}); const { placement: e = "bottom", strategy: n = "absolute", middleware: o = [], platform: r, elements: { reference: i, floating: s } = {}, transform: l = !0, whileElementsMounted: c, open: f } = t, [d, a] = g.useState({ x: 0, y: 0, strategy: n, placement: e, middlewareData: {}, isPositioned: !1 }), [m, u] = g.useState(o); Pt(m, o) || u(o); const [h, y] = g.useState(null), [b, v] = g.useState(null), E = g.useCallback((C) => { C !== M.current && (M.current = C, y(C)); }, []), p = g.useCallback((C) => { C !== T.current && (T.current = C, v(C)); }, []), R = i || h, x = s || b, M = g.useRef(null), T = g.useRef(null), B = g.useRef(d), _ = c != null, j = Ft(c), I = Ft(r), J = Ft(f), H = g.useCallback(() => { if (!M.current || !T.current) return; const C = { placement: e, strategy: n, middleware: m }; I.current && (C.platform = I.current), Go(M.current, T.current, C).then((D) => { const Y = { ...D, // The floating element's position may be recomputed while it's closed // but still mounted (such as when transitioning out). To ensure // `isPositioned` will be `false` initially on the next open, avoid // setting it to `true` when `open === false` (must be specified). isPositioned: J.current !== !1 }; N.current && !Pt(B.current, Y) && (B.current = Y, Wn.flushSync(() => { a(Y); })); }); }, [m, e, n, I, J]); bt(() => { f === !1 && B.current.isPositioned && (B.current.isPositioned = !1, a((C) => ({ ...C, isPositioned: !1 }))); }, [f]); const N = g.useRef(!1); bt(() => (N.current = !0, () => { N.current = !1; }), []), bt(() => { if (R && (M.current = R), x && (T.current = x), R && x) { if (j.current) return j.current(R, x, H); H(); } }, [R, x, H, j, _]); const U = g.useMemo(() => ({ reference: M, floating: T, setReference: E, setFloating: p }), [E, p]), L = g.useMemo(() => ({ reference: R, floating: x }), [R, x]), W = g.useMemo(() => { const C = { position: n, left: 0, top: 0 }; if (!L.floating) return C; const D = de(L.floating, d.x), Y = de(L.floating, d.y); return l ? { ...C, transform: "translate(" + D + "px, " + Y + "px)", ...sn(L.floating) >= 1.5 && { willChange: "transform" } } : { position: n, left: D, top: Y }; }, [n, l, L.floating, d.x, d.y]); return g.useMemo(() => ({ ...d, update: H, refs: U, elements: L, floatingStyles: W }), [d, H, U, L, W]); } const nr = (t, e) => ({ ...Qo(t), options: [t, e] }), or = (t, e) => ({ ...Ko(t), options: [t, e] }), ln = { ...g }, rr = ln.useInsertionEffect, ir = rr || ((t) => t()); function sr(t) { const e = g.useRef(() => { if (Ut.env.NODE_ENV !== "production") throw new Error("Cannot call an event handler while rendering."); }); return ir(() => { e.current = t; }), g.useCallback(function() { for (var n = arguments.length, o = new Array(n), r = 0; r < n; r++) o[r] = arguments[r]; return e.current == null ? void 0 : e.current(...o); }, []); } var zt = typeof document < "u" ? Xe : Vn; let me = !1, lr = 0; const pe = () => ( // Ensure the id is unique with multiple independent versions of Floating UI // on <React 18 "floating-ui-" + Math.random().toString(36).slice(2, 6) + lr++ ); function cr() { const [t, e] = g.useState(() => me ? pe() : void 0); return zt(() => { t == null && e(pe()); }, []), g.useEffect(() => { me = !0; }, []), t; } const ar = ln.useId, fr = ar || cr; let $t; Ut.env.NODE_ENV !== "production" && ($t = /* @__PURE__ */ new Set()); function ur() { for (var t, e = arguments.length, n = new Array(e), o = 0; o < e; o++) n[o] = arguments[o]; const r = "Floating UI: " + n.join(" "); if (!((t = $t) != null && t.has(r))) { var i; (i = $t) == null || i.add(r), console.error(r); } } function dr() { const t = /* @__PURE__ */ new Map(); return { emit(e, n) { var o; (o = t.get(e)) == null || o.forEach((r) => r(n)); }, on(e, n) { t.set(e, [...t.get(e) || [], n]); }, off(e, n) { var o; t.set(e, ((o = t.get(e)) == null ? void 0 : o.filter((r) => r !== n)) || []); } }; } const mr = /* @__PURE__ */ g.createContext(null), pr = /* @__PURE__ */ g.createContext(null), gr = () => { var t; return ((t = g.useContext(mr)) == null ? void 0 : t.id) || null; }, hr = () => g.useContext(pr); function vr(t) { const { open: e = !1, onOpenChange: n, elements: o } = t, r = fr(), i = g.useRef({}), [s] = g.useState(() => dr()), l = gr() != null; if (Ut.env.NODE_ENV !== "production") { const u = o.reference; u && !F(u) && ur("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `refs.setPositionReference()`", "instead."); } const [c, f] = g.useState(o.reference), d = sr((u, h, y) => { i.current.openEvent = u ? h : void 0, s.emit("openchange", { open: u, event: h, reason: y, nested: l }), n == null || n(u, h, y); }), a = g.useMemo(() => ({ setPositionReference: f }), []), m = g.useMemo(() => ({ reference: c || o.reference || null, floating: o.floating || null, domReference: o.reference }), [c, o.reference, o.floating]); return g.useMemo(() => ({ dataRef: i, open: e, onOpenChange: d, elements: m, events: s, floatingId: r, refs: a }), [e, d, m, s, r, a]); } function yr(t) { t === void 0 && (t = {}); const { nodeId: e } = t, n = vr({ ...t, elements: { reference: null, floating: null, ...t.elements } }), o = t.rootContext || n, r = o.elements, [i, s] = g.useState(null), [l, c] = g.useState(null), d = (r == null ? void 0 : r.domReference) || i, a = g.useRef(null), m = hr(); zt(() => { d && (a.current = d); }, [d]); const u = er({ ...t, elements: { ...r, ...l && { reference: l } } }), h = g.useCallback((p) => { const R = F(p) ? { getBoundingClientRect: () => p.getBoundingClientRect(), contextElement: p } : p; c(R), u.refs.setReference(R); }, [u.refs]), y = g.useCallback((p) => { (F(p) || p === null) && (a.current = p, s(p)), (F(u.refs.reference.current) || u.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to // `null` to support `positionReference` + an unstable `reference` // callback ref. p !== null && !F(p)) && u.refs.setReference(p); }, [u.refs]), b = g.useMemo(() => ({ ...u.refs, setReference: y, setPositionReference: h, domReference: a }), [u.refs, y, h]), v = g.useMemo(() => ({ ...u.elements, domReference: d }), [u.elements, d]), E = g.useMemo(() => ({ ...u, ...o, refs: b, elements: v, nodeId: e }), [u, b, v, e, o]); return zt(() => { o.dataRef.current.floatingContext = E; const p = m == null ? void 0 : m.nodesRef.current.find((R) => R.id === e); p && (p.context = E); }), g.useMemo(() => ({ ...u, context: E, refs: b, elements: v }), [u, b, v, E]); } function ge(t, e) { e > t.length && (e = t.length); for (var n = 0, o = Array(e); n < e; n++) o[n] = t[n]; return o; } function Et(t, e, n) { return (e = function(o) { var r = function(i, s) { if (typeof i != "object" || !i) return i; var l = i[Symbol.toPrimitive]; if (l !== void 0) { var c = l.call(i, s); if (typeof c != "object") return c; throw new TypeError("@@toPrimitive must return a primitive value."); } return String(i); }(o, "string"); return typeof r == "symbol" ? r : r + ""; }(e)) in t ? Object.defineProperty(t, e, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : t[e] = n, t; } function Wt() { return Wt = Object.assign ? Object.assign.bind() : function(t) { for (var e = 1; e < arguments.length; e++) { var n = arguments[e]; for (var o in n) ({}).hasOwnProperty.call(n, o) && (t[o] = n[o]); } return t; }, Wt.apply(null, arguments); } function he(t, e) { var n = Object.keys(t); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(t); e && (o = o.filter(function(r) { return Object.getOwnPropertyDescriptor(t, r).enumerable; })), n.push.apply(n, o); } return n; } function dt(t) { for (var e = 1; e < arguments.length; e++) { var n = arguments[e] != null ? arguments[e] : {}; e % 2 ? he(Object(n), !0).forEach(function(o) { Et(t, o, n[o]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n)) : he(Object(n)).forEach(function(o) { Object.defineProperty(t, o, Object.getOwnPropertyDescriptor(n, o)); }); } return t; } function jt(t, e) { if (t == null) return {}; var n, o, r = function(s, l) { if (s == null) return {}; var c = {}; for (var f in s) if ({}.hasOwnProperty.call(s, f)) { if (l.indexOf(f) !== -1) continue; c[f] = s[f]; } return c; }(t, e); if (Object.getOwnPropertySymbols) { var i = Object.getOwnPropertySymbols(t); for (o = 0; o < i.length; o++) n = i[o], e.indexOf(n) === -1 && {}.propertyIsEnumerable.call(t, n) && (r[n] = t[n]); } return r; } function gt(t, e) { return function(n) { if (Array.isArray(n)) return n; }(t) || function(n, o) { var r = n == null ? null : typeof Symbol < "u" && n[Symbol.iterator] || n["@@iterator"]; if (r != null) { var i, s, l, c, f = [], d = !0, a = !1; try { if (l = (r = r.call(n)).next, o !== 0) for (; !(d = (i = l.call(r)).done) && (f.push(i.value), f.length !== o); d = !0) ; } catch (m) { a = !0, s = m; } finally { try { if (!d && r.return != null && (c = r.return(), Object(c) !== c)) return; } finally { if (a) throw s; } } return f; } }(t, e) || function(n, o) { if (n) { if (typeof n == "string") return ge(n, o); var r = {}.toString.call(n).slice(8, -1); return r === "Object" && n.constructor && (r = n.constructor.name), r === "Map" || r === "Set" ? Array.from(n) : r === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r) ? ge(n, o) : void 0; } }(t, e) || function() { throw new TypeError(`Invalid attempt to destructure non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`); }(); } function P(t, e) { return e || (e = t.slice(0)), Object.freeze(Object.defineProperties(t, { raw: { value: Object.freeze(e) } })); } var q = { Inline: "inline", Portal: "portal", TopLayer: "top-layer" }, wr = { Auto: "auto", Manual: "manual" }, z = { Top: "top", Bottom: "bottom", Left: "left", Right: "right", CenterVertical: "center-vertical", CenterHorizontal: "center-horizontal" }, pt = { Start: "start", Middle: "middle", End: "end" }, ve = "top", ye = "bottom", _t = "left", Zt = "right", It = "center", xr = { top: 0, bottom: 0, left: 0, right: 0, height: 0, width: 0 }, we, xe, be, Ee, Re, Ce, Oe, Pe, Ae, Se, Me, Te, Le, Ne, De, Fe, je, Ie, ke, Ve, Be, He, ze, $e, We, _e, Ze, Ue, Ye, br = function(t, e) { return t === z.CenterHorizontal && (t = z.Right), t === z.CenterVertical && (t = z.Bottom), e === pt.Middle ? t : "".concat(t, "-").concat(e); }, Er = ["renderMode", "dismissMode", "onToggle", "portalClassName", "portalContainer", "portalRef", "scrollContainer", "onEnter", "onEntering", "onEntered", "onExit", "onExiting", "onExited", "popoverZIndex", "spacing"]; function Rr(t, e) { var n = gt(ie(null), 2), o = n[0], r = n[1], i = gt(ie(null), 2), s = i[0], l = i[1], c = Kn(t == null ? void 0 : t.current), f = !Gn(c, t == null ? void 0 : t.current); Jn(function() { if (t && t.current) f && l(t.current); else { var a = o !== null && o.parentNode; a && a instanceof HTMLElement && l(a); } }, [f, o, t]); var d = to(zn(function() { return function(a, m) { if (!a) return xr; var u = function(j) { var I = j.getBoundingClientRect(), J = I.top, H = I.bottom, N = I.left, U = I.right, L = I.width; return { top: J, bottom: H, left: N, right: U, height: j.offsetHeight, width: L }; }(a), h = u.top, y = u.bottom, b = u.left, v = u.right, E = u.height, p = u.width; if (m) { var R = m.scrollTop, x = m.scrollLeft, M = m.getBoundingClientRect(); return { top: h + R - M.top, bottom: y + R - M.bottom, left: b + x - M.left, right: v + x - M.right, height: E, width: p }; } var T = window, B = T.scrollX, _ = T.scrollY; return { top: h + _, bottom: y + _, left: b + B, right: v + B, height: E, width: p }; }(s, e); }, [s, e])); return { referenceElement: s, referenceElDocumentPos: d, setPlaceholderElement: r }; } var st = 0.8, At = eo.default, Cr = _n("popover-content"), Or = O(we || (we = P([` display: none; `]))), Pr = O(xe || (xe = P([` margin: 0; border: none; padding: 0; overflow: visible; background-color: transparent; width: max-content; transition-property: opacity, transform, overlay; transition-duration: `, `ms; transition-timing-function: ease-in-out; transition-behavior: allow-discrete; opacity: 0; transform: scale(`, `); &::backdrop { transition-property: background, overlay; transition-duration: `, `ms; transition-timing-function: ease-in-out; transition-behavior: allow-discrete; } `])), At, st, At), Ar = { top: O(Ee || (Ee = P([` transform-origin: bottom; `]))), "top-start": O(Re || (Re = P([` transform-origin: bottom left; `]))), "top-end": O(Ce || (Ce = P([` transform-origin: bottom right; `]))), bottom: O(Oe || (Oe = P([` transform-origin: top; `]))), "bottom-start": O(Pe || (Pe = P([` transform-origin: top left; `]))), "bottom-end": O(Ae || (Ae = P([` transform-origin: top right; `]))), left: O(Se || (Se = P([` transform-origin: right; `]))), "left-start": O(Me || (Me = P([` transform-origin: right top; `]))), "left-end": O(Te || (Te = P([` transform-origin: right bottom; `]))), right: O(Le || (Le = P([` transform-origin: left; `]))), "right-start": O(Ne || (Ne = P([` transform-origin: left top; `]))), "right-end": O(De || (De = P([` transform-origin: left bottom; `]))), center: O(Fe || (Fe = P([` transform-origin: center; `]))), "center-start": O(je || (je = P([` transform-origin: top; `]))), "center-end": O(Ie || (Ie = P([` transform-origin: bottom; `]))) }, mt = O(ke || (ke = P([` opacity: 0; `]))), kt = O(We || (We = P([` opacity: 1; pointer-events: initial; &:popover-open { opacity: 1; pointer-events: initial; } `]))), Sr = function(t) { var e = t.className, n = t.left, o = t.placement, r = t.popoverZIndex, i = t.position, s = t.spacing, l = t.state, c = t.top, f = t.transformAlign; return tt(Pr, function(d) { var a = d.left, m = d.position, u = d.top; return O(be || (be = P([` left: `, `px; position: `, `; top: `, `px; `])), a, m, u); }({ left: n, position: i, top: c }), Ar[o], Et(Et(Et({}, function(d, a) { switch (a) { case ve: return tt(mt, O(Ve || (Ve = P([` transform: translate3d(0, `, `px, 0) scale(`, `); `])), d, st)); case ye: return tt(mt, O(Be || (Be = P([` transform: translate3d(0, -`, `px, 0) scale(`, `); `])), d, st)); case _t: return tt(mt, O(He || (He = P([` transform: translate3d(`, `px, 0, 0) scale(`, `); `])), d, st)); case Zt: return tt(mt, O(ze || (ze = P([` transform: translate3d(-`, `px, 0, 0) scale(`, `); `])), d, st)); default: return tt(mt, O($e || ($e = P([` transform: scale(`, `); `])), st)); } }(s, f), l !== "entered"), function(d) { switch (d) { case ve: case ye: return tt(kt, O(_e || (_e = P([` transform: translateY(0) scale(1); &:popover-open { transform: translateY(0) scale(1); } `])))); case _t: case Zt: return tt(kt, O(Ze || (Ze = P([` transform: translateX(0) scale(1); &:popover-open { transform: translateX(0) scale(1); } `])))); default: return tt(kt, O(Ue || (Ue = P([` transform: scale(1); &:popover-open { transform: scale(1); } `])))); } }(f), l === "entered"), O(Ye || (Ye = P([` z-index: `, `; `])), r), typeof r == "number"), e); }, Mr = ["active", "adjustOnMutation", "align", "children", "className", "justify", "refEl"], Tr = ["renderMode", "dismissMode", "onToggle", "usePortal", "portalClassName", "portalContainer", "portalRef", "scrollContainer", "onEnter", "onEntering", "onEntered", "onExit", "onExiting", "onExited", "popoverZIndex", "spacing"], Lr = Bn(function(t, e) { var n = t.active, o = n !== void 0 && n; t.adjustOnMutation; var r = t.align, i = r === void 0 ? z.Bottom : r, s = t.children, l = t.className, c = t.justify, f = c === void 0 ? pt.Start : c, d = t.refEl, a = function(w) { var S = w.renderMode, A = w.dismissMode, k = w.onToggle, et = w.portalClassName, wt = w.portalContainer, En = w.portalRef, Rn = w.scrollContainer, Cn = w.onEnter, On = w.onEntering, Pn = w.onEntered, An = w.onExit, Sn = w.onExiting, Mn = w.onExited, Tn = w.popoverZIndex, Ln = w.spacing, Nn = jt(w, Er), Dn = Zn().forceUseTopLayer, V = Un(), ne = Yn(), Nt = Dn ? q.TopLayer : S || V.renderMode, oe = Nt === q.Portal, re = Nt === q.TopLayer, Fn = re ? { dismissMode: A || V.dismissMode, onToggle: k || V.onToggle } : {}, jn = oe ? { portalClassName: et || V.portalClassName, portalContainer: wt || V.portalContainer || ne.portalContainer, portalRef: En || V.portalRef, scrollContainer: Rn || V.scrollContainer || ne.scrollContainer } : {}, In = { onEnter: Cn || V.onEnter, onEntering: On || V.onEntering, onEntered: Pn || V.onEntered, onExit: An || V.onExit, onExiting: Sn || V.onExiting, onExited: Mn || V.onExited }, kn = { popoverZIndex: re ? void 0 : Tn || V.popoverZIndex, spacing: Ln || V.spacing }; return dt(dt(dt(dt(dt({ renderMode: Nt, usePortal: oe }, Fn), jn), In), kn), Nn); }(jt(t, Mr)), m = a.renderMode, u = m === void 0 ? q.TopLayer : m, h = a.dismissMode, y = h === void 0 ? wr.Auto : h, b = a.onToggle, v = a.usePortal, E = a.portalClassName, p = a.portalContainer, R = a.portalRef, x = a.scrollContainer, M = a.onEnter, T = a.onEntering, B = a.onEntered, _ = a.onExit, j = a.onExiting, I = a.onExited, J = a.popoverZIndex, H = a.spacing, N = H === void 0 ? no[100] : H, U = jt(a, Tr), L = Xn().setIsPopoverOpen; v && x && (x.contains(p) || qn.warn("To ensure correct positioning make sure that the portalContainer element is inside of the scrollContainer")); var W = v ? oo : $n, C = v ? { className: p ? void 0 : E, container: p ?? void 0, portalRef: R } : {}, D = Rr(d, x), Y = D.referenceElement, cn = D.referenceElDocumentPos, an = D.setPlaceholderElement, Gt = function() { var w = gt(X.useState(null), 2), S = w[0], A = w[1], k = Hn(S); return k.current = S, { contentNode: S, contentNodeRef: k, setContentNode: A }; }(), fn = Gt.contentNodeRef, un = Gt.setContentNode, ot = yr({ elements: { reference: Y }, middleware: [nr(function(w) { var S = w.rects; return function(A, k, et) { return A === z.CenterHorizontal ? -et.reference.width / 2 - et.floating.width / 2 : A === z.CenterVertical ? -et.reference.height / 2 - et.floating.height / 2 : k; }(i, N, S); }, [i, N]), or({ boundary: x ?? "clippingAncestors" })], open: o, placement: br(i, f), strategy: u === q.TopLayer ? "fixed" : "absolute", transform: !1, whileElementsMounted: qo }), dn = ot.context, yt = ot.elements, Jt = ot.placement, mn = ot.refs, pn = ot.strategy, gn = ot.x, hn = ot.y, vn = Qn([mn.setFloating, e]), te = function(w) { var S = gt(w.split("-"), 2), A = S[0], k = S[1]; return { align: A, justify: k || pt.Middle }; }(Jt), yn = te.align, wn = te.justify, ee = function(w) { var S = w.placement, A = w.align, k = gt(S.split("-"), 2), et = k[0], wt = k[1]; if (A !== z.CenterHorizontal && A !== z.CenterVertical) return { placement: S, transformAlign: et }; if (wt === pt.Start) { if (A === z.CenterHorizontal) return { placement: "center-start", transformAlign: It }; if (A === z.CenterVertical) return { placement: "right", transformAlign: Zt }; } if (wt === pt.End) { if (A === z.CenterHorizontal) return { placement: "center-end", transformAlign: It }; if (A === z.CenterVertical) return { placement: "left", transformAlign: _t }; } return { placement: "center", transformAlign: It }; }({ placement: Jt, align: i }), xn = ee.placement, bn = ee.transformAlign; return X.createElement(X.Fragment, null, X.createElement("span", { ref: an, className: Or }), X.createElement(ro, { nodeRef: fn, in: dn.open, timeout: { appear: 0, enter: At, exit: At }, onEnter: M, onEntering: function(w) { var S, A, k; u === q.TopLayer && ((S = yt.floating) === null || S === void 0 || S.addEventListener("toggle", b), (A = yt.floating) === null || A === void 0 || (k = A.showPopover) === null || k === void 0 || k.call(A)), T == null || T(w); }, onEntered: function(w) { L(!0), B == null || B(w); }, onExit: _, onExiting: j, onExited: function() { var w, S, A; L(!1), u === q.TopLayer && ((w = yt.floating) === null || w === void 0 || w.removeEventListener("toggle", b), (S = yt.floating) === null || S === void 0 || (A = S.hidePopover) === null || A === void 0 || A.call(S)), I == null || I(); }, mountOnEnter: !0, unmountOnExit: !0, appear: !0 }, function(w) { return X.createElement(X.Fragment, null, X.createElement(W, C, X.createElement("div", Wt({ ref: vn, className: Sr({ className: l, left: gn, placement: xn, popoverZIndex: J, position: pn, spacing: N, state: w, top: hn, transformAlign: bn }), popover: u === q.TopLayer ? y : void 0 }, U), X.createElement("div", { ref: un, className: Cr }, s === null ? null : typeof s == "function" ? s({ align: yn, justify: wn, referenceElPos: cn }) : s)))); })); }); Lr.displayName = "Popover"; var kr = function(t) { var e = t.dismissMode, n = t.onToggle, o = t.portalClassName, r = t.portalContainer, i = t.portalRef, s = t.renderMode, l = t.scrollContainer; return s === q.Inline ? { renderMode: s } : s === q.Portal ? { renderMode: s, portalClassName: o, portalContainer: r, portalRef: i, scrollContainer: l } : { dismissMode: e, onToggle: n, renderMode: s }; }; export { wr as H, z as Z, q as a, kr as b, pt as k, Lr as z };