@pdf-viewer/react
Version:
A react-pdf-viewer component for React and Next.js. Suitable for react-pdf document.
1,475 lines (1,474 loc) • 40.1 kB
JavaScript
import * as v from "react";
import { useLayoutEffect as oe } from "react";
import { u as Vt, P as It, a as ht, h as ie, f as se } from "./index-35c7f4a2.js";
import { jsx as zt } from "react/jsx-runtime";
import * as re from "react-dom";
function bt(t) {
const e = v.useRef(t);
return v.useEffect(() => {
e.current = t;
}), v.useMemo(() => (...n) => {
var o;
return (o = e.current) == null ? void 0 : o.call(e, ...n);
}, []);
}
function ce(t, e = globalThis == null ? void 0 : globalThis.document) {
const n = bt(t);
v.useEffect(() => {
const o = (i) => {
i.key === "Escape" && n(i);
};
return e.addEventListener("keydown", o, { capture: !0 }), () => e.removeEventListener("keydown", o, { capture: !0 });
}, [n, e]);
}
var le = "DismissableLayer", wt = "dismissableLayer.update", ae = "dismissableLayer.pointerDownOutside", fe = "dismissableLayer.focusOutside", Lt, jt = v.createContext({
layers: /* @__PURE__ */ new Set(),
layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
branches: /* @__PURE__ */ new Set()
}), ue = v.forwardRef(
(t, e) => {
const {
disableOutsidePointerEvents: n = !1,
onEscapeKeyDown: o,
onPointerDownOutside: i,
onFocusOutside: s,
onInteractOutside: r,
onDismiss: c,
...f
} = t, l = v.useContext(jt), [a, u] = v.useState(null), m = (a == null ? void 0 : a.ownerDocument) ?? (globalThis == null ? void 0 : globalThis.document), [, d] = v.useState({}), h = Vt(e, (y) => u(y)), g = Array.from(l.layers), [p] = [...l.layersWithOutsidePointerEventsDisabled].slice(-1), w = g.indexOf(p), x = a ? g.indexOf(a) : -1, E = l.layersWithOutsidePointerEventsDisabled.size > 0, R = x >= w, b = he((y) => {
const S = y.target, D = [...l.branches].some((C) => C.contains(S));
!R || D || (i == null || i(y), r == null || r(y), y.defaultPrevented || c == null || c());
}, m), A = ge((y) => {
const S = y.target;
[...l.branches].some((C) => C.contains(S)) || (s == null || s(y), r == null || r(y), y.defaultPrevented || c == null || c());
}, m);
return ce((y) => {
x === l.layers.size - 1 && (o == null || o(y), !y.defaultPrevented && c && (y.preventDefault(), c()));
}, m), v.useEffect(() => {
if (a)
return n && (l.layersWithOutsidePointerEventsDisabled.size === 0 && (Lt = m.body.style.pointerEvents, m.body.style.pointerEvents = "none"), l.layersWithOutsidePointerEventsDisabled.add(a)), l.layers.add(a), Pt(), () => {
n && l.layersWithOutsidePointerEventsDisabled.size === 1 && (m.body.style.pointerEvents = Lt);
};
}, [a, m, n, l]), v.useEffect(() => () => {
a && (l.layers.delete(a), l.layersWithOutsidePointerEventsDisabled.delete(a), Pt());
}, [a, l]), v.useEffect(() => {
const y = () => d({});
return document.addEventListener(wt, y), () => document.removeEventListener(wt, y);
}, []), /* @__PURE__ */ zt(
It.div,
{
...f,
ref: h,
style: {
pointerEvents: E ? R ? "auto" : "none" : void 0,
...t.style
},
onFocusCapture: ht(t.onFocusCapture, A.onFocusCapture),
onBlurCapture: ht(t.onBlurCapture, A.onBlurCapture),
onPointerDownCapture: ht(
t.onPointerDownCapture,
b.onPointerDownCapture
)
}
);
}
);
ue.displayName = le;
var de = "DismissableLayerBranch", me = v.forwardRef((t, e) => {
const n = v.useContext(jt), o = v.useRef(null), i = Vt(e, o);
return v.useEffect(() => {
const s = o.current;
if (s)
return n.branches.add(s), () => {
n.branches.delete(s);
};
}, [n.branches]), /* @__PURE__ */ zt(It.div, { ...t, ref: i });
});
me.displayName = de;
function he(t, e = globalThis == null ? void 0 : globalThis.document) {
const n = bt(t), o = v.useRef(!1), i = v.useRef(() => {
});
return v.useEffect(() => {
const s = (c) => {
if (c.target && !o.current) {
let f = function() {
Ut(
ae,
n,
l,
{ discrete: !0 }
);
};
const l = { originalEvent: c };
c.pointerType === "touch" ? (e.removeEventListener("click", i.current), i.current = f, e.addEventListener("click", i.current, { once: !0 })) : f();
} else
e.removeEventListener("click", i.current);
o.current = !1;
}, r = window.setTimeout(() => {
e.addEventListener("pointerdown", s);
}, 0);
return () => {
window.clearTimeout(r), e.removeEventListener("pointerdown", s), e.removeEventListener("click", i.current);
};
}, [e, n]), {
// ensures we check React component tree (not just DOM tree)
onPointerDownCapture: () => o.current = !0
};
}
function ge(t, e = globalThis == null ? void 0 : globalThis.document) {
const n = bt(t), o = v.useRef(!1);
return v.useEffect(() => {
const i = (s) => {
s.target && !o.current && Ut(fe, n, { originalEvent: s }, {
discrete: !1
});
};
return e.addEventListener("focusin", i), () => e.removeEventListener("focusin", i);
}, [e, n]), {
onFocusCapture: () => o.current = !0,
onBlurCapture: () => o.current = !1
};
}
function Pt() {
const t = new CustomEvent(wt);
document.dispatchEvent(t);
}
function Ut(t, e, n, { discrete: o }) {
const i = n.originalEvent.target, s = new CustomEvent(t, { bubbles: !1, cancelable: !0, detail: n });
e && i.addEventListener(t, e, { once: !0 }), o ? ie(i, s) : i.dispatchEvent(s);
}
var pe = v[" useId ".trim().toString()] || (() => {
}), we = 0;
function Rn(t) {
const [e, n] = v.useState(pe());
return se(() => {
t || n((o) => o ?? String(we++));
}, [t]), t || (e ? `radix-${e}` : "");
}
const ye = ["top", "right", "bottom", "left"], q = Math.min, B = Math.max, rt = Math.round, it = Math.floor, I = (t) => ({
x: t,
y: t
}), xe = {
left: "right",
right: "left",
bottom: "top",
top: "bottom"
}, ve = {
start: "end",
end: "start"
};
function yt(t, e, n) {
return B(t, q(e, n));
}
function U(t, e) {
return typeof t == "function" ? t(e) : t;
}
function X(t) {
return t.split("-")[0];
}
function Z(t) {
return t.split("-")[1];
}
function Et(t) {
return t === "x" ? "y" : "x";
}
function Rt(t) {
return t === "y" ? "height" : "width";
}
const be = /* @__PURE__ */ new Set(["top", "bottom"]);
function V(t) {
return be.has(X(t)) ? "y" : "x";
}
function Ot(t) {
return Et(V(t));
}
function Ee(t, e, n) {
n === void 0 && (n = !1);
const o = Z(t), i = Ot(t), s = Rt(i);
let r = i === "x" ? o === (n ? "end" : "start") ? "right" : "left" : o === "start" ? "bottom" : "top";
return e.reference[s] > e.floating[s] && (r = ct(r)), [r, ct(r)];
}
function Re(t) {
const e = ct(t);
return [xt(t), e, xt(e)];
}
function xt(t) {
return t.replace(/start|end/g, (e) => ve[e]);
}
const Dt = ["left", "right"], Tt = ["right", "left"], Oe = ["top", "bottom"], Ae = ["bottom", "top"];
function Ce(t, e, n) {
switch (t) {
case "top":
case "bottom":
return n ? e ? Tt : Dt : e ? Dt : Tt;
case "left":
case "right":
return e ? Oe : Ae;
default:
return [];
}
}
function Se(t, e, n, o) {
const i = Z(t);
let s = Ce(X(t), n === "start", o);
return i && (s = s.map((r) => r + "-" + i), e && (s = s.concat(s.map(xt)))), s;
}
function ct(t) {
return t.replace(/left|right|bottom|top/g, (e) => xe[e]);
}
function Le(t) {
return {
top: 0,
right: 0,
bottom: 0,
left: 0,
...t
};
}
function Xt(t) {
return typeof t != "number" ? Le(t) : {
top: t,
right: t,
bottom: t,
left: t
};
}
function lt(t) {
const {
x: e,
y: n,
width: o,
height: i
} = t;
return {
width: o,
height: i,
top: n,
left: e,
right: e + o,
bottom: n + i,
x: e,
y: n
};
}
function Mt(t, e, n) {
let {
reference: o,
floating: i
} = t;
const s = V(e), r = Ot(e), c = Rt(r), f = X(e), l = s === "y", a = o.x + o.width / 2 - i.width / 2, u = o.y + o.height / 2 - i.height / 2, m = o[c] / 2 - i[c] / 2;
let d;
switch (f) {
case "top":
d = {
x: a,
y: o.y - i.height
};
break;
case "bottom":
d = {
x: a,
y: o.y + o.height
};
break;
case "right":
d = {
x: o.x + o.width,
y: u
};
break;
case "left":
d = {
x: o.x - i.width,
y: u
};
break;
default:
d = {
x: o.x,
y: o.y
};
}
switch (Z(e)) {
case "start":
d[r] -= m * (n && l ? -1 : 1);
break;
case "end":
d[r] += m * (n && l ? -1 : 1);
break;
}
return d;
}
const Pe = async (t, e, n) => {
const {
placement: o = "bottom",
strategy: i = "absolute",
middleware: s = [],
platform: r
} = n, c = s.filter(Boolean), f = await (r.isRTL == null ? void 0 : r.isRTL(e));
let l = await r.getElementRects({
reference: t,
floating: e,
strategy: i
}), {
x: a,
y: u
} = Mt(l, o, f), m = o, d = {}, h = 0;
for (let g = 0; g < c.length; g++) {
const {
name: p,
fn: w
} = c[g], {
x,
y: E,
data: R,
reset: b
} = await w({
x: a,
y: u,
initialPlacement: o,
placement: m,
strategy: i,
middlewareData: d,
rects: l,
platform: r,
elements: {
reference: t,
floating: e
}
});
a = x ?? a, u = E ?? u, d = {
...d,
[p]: {
...d[p],
...R
}
}, b && h <= 50 && (h++, typeof b == "object" && (b.placement && (m = b.placement), b.rects && (l = b.rects === !0 ? await r.getElementRects({
reference: t,
floating: e,
strategy: i
}) : b.rects), {
x: a,
y: u
} = Mt(l, m, f)), g = -1);
}
return {
x: a,
y: u,
placement: m,
strategy: i,
middlewareData: d
};
};
async function et(t, e) {
var n;
e === void 0 && (e = {});
const {
x: o,
y: i,
platform: s,
rects: r,
elements: c,
strategy: f
} = t, {
boundary: l = "clippingAncestors",
rootBoundary: a = "viewport",
elementContext: u = "floating",
altBoundary: m = !1,
padding: d = 0
} = U(e, t), h = Xt(d), p = c[m ? u === "floating" ? "reference" : "floating" : u], w = lt(await s.getClippingRect({
element: (n = await (s.isElement == null ? void 0 : s.isElement(p))) == null || n ? p : p.contextElement || await (s.getDocumentElement == null ? void 0 : s.getDocumentElement(c.floating)),
boundary: l,
rootBoundary: a,
strategy: f
})), x = u === "floating" ? {
x: o,
y: i,
width: r.floating.width,
height: r.floating.height
} : r.reference, E = await (s.getOffsetParent == null ? void 0 : s.getOffsetParent(c.floating)), R = await (s.isElement == null ? void 0 : s.isElement(E)) ? await (s.getScale == null ? void 0 : s.getScale(E)) || {
x: 1,
y: 1
} : {
x: 1,
y: 1
}, b = lt(s.convertOffsetParentRelativeRectToViewportRelativeRect ? await s.convertOffsetParentRelativeRectToViewportRelativeRect({
elements: c,
rect: x,
offsetParent: E,
strategy: f
}) : x);
return {
top: (w.top - b.top + h.top) / R.y,
bottom: (b.bottom - w.bottom + h.bottom) / R.y,
left: (w.left - b.left + h.left) / R.x,
right: (b.right - w.right + h.right) / R.x
};
}
const De = (t) => ({
name: "arrow",
options: t,
async fn(e) {
const {
x: n,
y: o,
placement: i,
rects: s,
platform: r,
elements: c,
middlewareData: f
} = e, {
element: l,
padding: a = 0
} = U(t, e) || {};
if (l == null)
return {};
const u = Xt(a), m = {
x: n,
y: o
}, d = Ot(i), h = Rt(d), g = await r.getDimensions(l), p = d === "y", w = p ? "top" : "left", x = p ? "bottom" : "right", E = p ? "clientHeight" : "clientWidth", R = s.reference[h] + s.reference[d] - m[d] - s.floating[h], b = m[d] - s.reference[d], A = await (r.getOffsetParent == null ? void 0 : r.getOffsetParent(l));
let y = A ? A[E] : 0;
(!y || !await (r.isElement == null ? void 0 : r.isElement(A))) && (y = c.floating[E] || s.floating[h]);
const S = R / 2 - b / 2, D = y / 2 - g[h] / 2 - 1, C = q(u[w], D), N = q(u[x], D), F = C, T = y - g[h] - N, L = y / 2 - g[h] / 2 + S, _ = yt(F, L, T), P = !f.arrow && Z(i) != null && L !== _ && s.reference[h] / 2 - (L < F ? C : N) - g[h] / 2 < 0, M = P ? L < F ? L - F : L - T : 0;
return {
[d]: m[d] + M,
data: {
[d]: _,
centerOffset: L - _ - M,
...P && {
alignmentOffset: M
}
},
reset: P
};
}
}), Te = function(t) {
return t === void 0 && (t = {}), {
name: "flip",
options: t,
async fn(e) {
var n, o;
const {
placement: i,
middlewareData: s,
rects: r,
initialPlacement: c,
platform: f,
elements: l
} = e, {
mainAxis: a = !0,
crossAxis: u = !0,
fallbackPlacements: m,
fallbackStrategy: d = "bestFit",
fallbackAxisSideDirection: h = "none",
flipAlignment: g = !0,
...p
} = U(t, e);
if ((n = s.arrow) != null && n.alignmentOffset)
return {};
const w = X(i), x = V(c), E = X(c) === c, R = await (f.isRTL == null ? void 0 : f.isRTL(l.floating)), b = m || (E || !g ? [ct(c)] : Re(c)), A = h !== "none";
!m && A && b.push(...Se(c, g, h, R));
const y = [c, ...b], S = await et(e, p), D = [];
let C = ((o = s.flip) == null ? void 0 : o.overflows) || [];
if (a && D.push(S[w]), u) {
const L = Ee(i, r, R);
D.push(S[L[0]], S[L[1]]);
}
if (C = [...C, {
placement: i,
overflows: D
}], !D.every((L) => L <= 0)) {
var N, F;
const L = (((N = s.flip) == null ? void 0 : N.index) || 0) + 1, _ = y[L];
if (_ && (!(u === "alignment" ? x !== V(_) : !1) || // We leave the current main axis only if every placement on that axis
// overflows the main axis.
C.every((O) => V(O.placement) === x ? O.overflows[0] > 0 : !0)))
return {
data: {
index: L,
overflows: C
},
reset: {
placement: _
}
};
let P = (F = C.filter((M) => M.overflows[0] <= 0).sort((M, O) => M.overflows[1] - O.overflows[1])[0]) == null ? void 0 : F.placement;
if (!P)
switch (d) {
case "bestFit": {
var T;
const M = (T = C.filter((O) => {
if (A) {
const k = V(O.placement);
return k === x || // Create a bias to the `y` side axis due to horizontal
// reading directions favoring greater width.
k === "y";
}
return !0;
}).map((O) => [O.placement, O.overflows.filter((k) => k > 0).reduce((k, Y) => k + Y, 0)]).sort((O, k) => O[1] - k[1])[0]) == null ? void 0 : T[0];
M && (P = M);
break;
}
case "initialPlacement":
P = c;
break;
}
if (i !== P)
return {
reset: {
placement: P
}
};
}
return {};
}
};
};
function Ft(t, e) {
return {
top: t.top - e.height,
right: t.right - e.width,
bottom: t.bottom - e.height,
left: t.left - e.width
};
}
function kt(t) {
return ye.some((e) => t[e] >= 0);
}
const Me = function(t) {
return t === void 0 && (t = {}), {
name: "hide",
options: t,
async fn(e) {
const {
rects: n
} = e, {
strategy: o = "referenceHidden",
...i
} = U(t, e);
switch (o) {
case "referenceHidden": {
const s = await et(e, {
...i,
elementContext: "reference"
}), r = Ft(s, n.reference);
return {
data: {
referenceHiddenOffsets: r,
referenceHidden: kt(r)
}
};
}
case "escaped": {
const s = await et(e, {
...i,
altBoundary: !0
}), r = Ft(s, n.floating);
return {
data: {
escapedOffsets: r,
escaped: kt(r)
}
};
}
default:
return {};
}
}
};
}, Yt = /* @__PURE__ */ new Set(["left", "top"]);
async function Fe(t, e) {
const {
placement: n,
platform: o,
elements: i
} = t, s = await (o.isRTL == null ? void 0 : o.isRTL(i.floating)), r = X(n), c = Z(n), f = V(n) === "y", l = Yt.has(r) ? -1 : 1, a = s && f ? -1 : 1, u = U(e, t);
let {
mainAxis: m,
crossAxis: d,
alignmentAxis: h
} = typeof u == "number" ? {
mainAxis: u,
crossAxis: 0,
alignmentAxis: null
} : {
mainAxis: u.mainAxis || 0,
crossAxis: u.crossAxis || 0,
alignmentAxis: u.alignmentAxis
};
return c && typeof h == "number" && (d = c === "end" ? h * -1 : h), f ? {
x: d * a,
y: m * l
} : {
x: m * l,
y: d * a
};
}
const ke = function(t) {
return t === void 0 && (t = 0), {
name: "offset",
options: t,
async fn(e) {
var n, o;
const {
x: i,
y: s,
placement: r,
middlewareData: c
} = e, f = await Fe(e, t);
return r === ((n = c.offset) == null ? void 0 : n.placement) && (o = c.arrow) != null && o.alignmentOffset ? {} : {
x: i + f.x,
y: s + f.y,
data: {
...f,
placement: r
}
};
}
};
}, Be = function(t) {
return t === void 0 && (t = {}), {
name: "shift",
options: t,
async fn(e) {
const {
x: n,
y: o,
placement: i
} = e, {
mainAxis: s = !0,
crossAxis: r = !1,
limiter: c = {
fn: (p) => {
let {
x: w,
y: x
} = p;
return {
x: w,
y: x
};
}
},
...f
} = U(t, e), l = {
x: n,
y: o
}, a = await et(e, f), u = V(X(i)), m = Et(u);
let d = l[m], h = l[u];
if (s) {
const p = m === "y" ? "top" : "left", w = m === "y" ? "bottom" : "right", x = d + a[p], E = d - a[w];
d = yt(x, d, E);
}
if (r) {
const p = u === "y" ? "top" : "left", w = u === "y" ? "bottom" : "right", x = h + a[p], E = h - a[w];
h = yt(x, h, E);
}
const g = c.fn({
...e,
[m]: d,
[u]: h
});
return {
...g,
data: {
x: g.x - n,
y: g.y - o,
enabled: {
[m]: s,
[u]: r
}
}
};
}
};
}, We = function(t) {
return t === void 0 && (t = {}), {
options: t,
fn(e) {
const {
x: n,
y: o,
placement: i,
rects: s,
middlewareData: r
} = e, {
offset: c = 0,
mainAxis: f = !0,
crossAxis: l = !0
} = U(t, e), a = {
x: n,
y: o
}, u = V(i), m = Et(u);
let d = a[m], h = a[u];
const g = U(c, e), p = typeof g == "number" ? {
mainAxis: g,
crossAxis: 0
} : {
mainAxis: 0,
crossAxis: 0,
...g
};
if (f) {
const E = m === "y" ? "height" : "width", R = s.reference[m] - s.floating[E] + p.mainAxis, b = s.reference[m] + s.reference[E] - p.mainAxis;
d < R ? d = R : d > b && (d = b);
}
if (l) {
var w, x;
const E = m === "y" ? "width" : "height", R = Yt.has(X(i)), b = s.reference[u] - s.floating[E] + (R && ((w = r.offset) == null ? void 0 : w[u]) || 0) + (R ? 0 : p.crossAxis), A = s.reference[u] + s.reference[E] + (R ? 0 : ((x = r.offset) == null ? void 0 : x[u]) || 0) - (R ? p.crossAxis : 0);
h < b ? h = b : h > A && (h = A);
}
return {
[m]: d,
[u]: h
};
}
};
}, Ne = function(t) {
return t === void 0 && (t = {}), {
name: "size",
options: t,
async fn(e) {
var n, o;
const {
placement: i,
rects: s,
platform: r,
elements: c
} = e, {
apply: f = () => {
},
...l
} = U(t, e), a = await et(e, l), u = X(i), m = Z(i), d = V(i) === "y", {
width: h,
height: g
} = s.floating;
let p, w;
u === "top" || u === "bottom" ? (p = u, w = m === (await (r.isRTL == null ? void 0 : r.isRTL(c.floating)) ? "start" : "end") ? "left" : "right") : (w = u, p = m === "end" ? "top" : "bottom");
const x = g - a.top - a.bottom, E = h - a.left - a.right, R = q(g - a[p], x), b = q(h - a[w], E), A = !e.middlewareData.shift;
let y = R, S = b;
if ((n = e.middlewareData.shift) != null && n.enabled.x && (S = E), (o = e.middlewareData.shift) != null && o.enabled.y && (y = x), A && !m) {
const C = B(a.left, 0), N = B(a.right, 0), F = B(a.top, 0), T = B(a.bottom, 0);
d ? S = h - 2 * (C !== 0 || N !== 0 ? C + N : B(a.left, a.right)) : y = g - 2 * (F !== 0 || T !== 0 ? F + T : B(a.top, a.bottom));
}
await f({
...e,
availableWidth: S,
availableHeight: y
});
const D = await r.getDimensions(c.floating);
return h !== D.width || g !== D.height ? {
reset: {
rects: !0
}
} : {};
}
};
};
function ft() {
return typeof window < "u";
}
function tt(t) {
return qt(t) ? (t.nodeName || "").toLowerCase() : "#document";
}
function W(t) {
var e;
return (t == null || (e = t.ownerDocument) == null ? void 0 : e.defaultView) || window;
}
function j(t) {
var e;
return (e = (qt(t) ? t.ownerDocument : t.document) || window.document) == null ? void 0 : e.documentElement;
}
function qt(t) {
return ft() ? t instanceof Node || t instanceof W(t).Node : !1;
}
function $(t) {
return ft() ? t instanceof Element || t instanceof W(t).Element : !1;
}
function z(t) {
return ft() ? t instanceof HTMLElement || t instanceof W(t).HTMLElement : !1;
}
function Bt(t) {
return !ft() || typeof ShadowRoot > "u" ? !1 : t instanceof ShadowRoot || t instanceof W(t).ShadowRoot;
}
const $e = /* @__PURE__ */ new Set(["inline", "contents"]);
function ot(t) {
const {
overflow: e,
overflowX: n,
overflowY: o,
display: i
} = H(t);
return /auto|scroll|overlay|hidden|clip/.test(e + o + n) && !$e.has(i);
}
const He = /* @__PURE__ */ new Set(["table", "td", "th"]);
function _e(t) {
return He.has(tt(t));
}
const Ve = [":popover-open", ":modal"];
function ut(t) {
return Ve.some((e) => {
try {
return t.matches(e);
} catch {
return !1;
}
});
}
const Ie = ["transform", "translate", "scale", "rotate", "perspective"], ze = ["transform", "translate", "scale", "rotate", "perspective", "filter"], je = ["paint", "layout", "strict", "content"];
function At(t) {
const e = Ct(), n = $(t) ? H(t) : t;
return Ie.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) || ze.some((o) => (n.willChange || "").includes(o)) || je.some((o) => (n.contain || "").includes(o));
}
function Ue(t) {
let e = K(t);
for (; z(e) && !Q(e); ) {
if (At(e))
return e;
if (ut(e))
return null;
e = K(e);
}
return null;
}
function Ct() {
return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
}
const Xe = /* @__PURE__ */ new Set(["html", "body", "#document"]);
function Q(t) {
return Xe.has(tt(t));
}
function H(t) {
return W(t).getComputedStyle(t);
}
function dt(t) {
return $(t) ? {
scrollLeft: t.scrollLeft,
scrollTop: t.scrollTop
} : {
scrollLeft: t.scrollX,
scrollTop: t.scrollY
};
}
function K(t) {
if (tt(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.
Bt(t) && t.host || // Fallback.
j(t)
);
return Bt(e) ? e.host : e;
}
function Kt(t) {
const e = K(t);
return Q(e) ? t.ownerDocument ? t.ownerDocument.body : t.body : z(e) && ot(e) ? e : Kt(e);
}
function nt(t, e, n) {
var o;
e === void 0 && (e = []), n === void 0 && (n = !0);
const i = Kt(t), s = i === ((o = t.ownerDocument) == null ? void 0 : o.body), r = W(i);
if (s) {
const c = vt(r);
return e.concat(r, r.visualViewport || [], ot(i) ? i : [], c && n ? nt(c) : []);
}
return e.concat(i, nt(i, [], n));
}
function vt(t) {
return t.parent && Object.getPrototypeOf(t.parent) ? t.frameElement : null;
}
function Gt(t) {
const e = H(t);
let n = parseFloat(e.width) || 0, o = parseFloat(e.height) || 0;
const i = z(t), s = i ? t.offsetWidth : n, r = i ? t.offsetHeight : o, c = rt(n) !== s || rt(o) !== r;
return c && (n = s, o = r), {
width: n,
height: o,
$: c
};
}
function St(t) {
return $(t) ? t : t.contextElement;
}
function J(t) {
const e = St(t);
if (!z(e))
return I(1);
const n = e.getBoundingClientRect(), {
width: o,
height: i,
$: s
} = Gt(e);
let r = (s ? rt(n.width) : n.width) / o, c = (s ? rt(n.height) : n.height) / i;
return (!r || !Number.isFinite(r)) && (r = 1), (!c || !Number.isFinite(c)) && (c = 1), {
x: r,
y: c
};
}
const Ye = /* @__PURE__ */ I(0);
function Jt(t) {
const e = W(t);
return !Ct() || !e.visualViewport ? Ye : {
x: e.visualViewport.offsetLeft,
y: e.visualViewport.offsetTop
};
}
function qe(t, e, n) {
return e === void 0 && (e = !1), !n || e && n !== W(t) ? !1 : e;
}
function G(t, e, n, o) {
e === void 0 && (e = !1), n === void 0 && (n = !1);
const i = t.getBoundingClientRect(), s = St(t);
let r = I(1);
e && (o ? $(o) && (r = J(o)) : r = J(t));
const c = qe(s, n, o) ? Jt(s) : I(0);
let f = (i.left + c.x) / r.x, l = (i.top + c.y) / r.y, a = i.width / r.x, u = i.height / r.y;
if (s) {
const m = W(s), d = o && $(o) ? W(o) : o;
let h = m, g = vt(h);
for (; g && o && d !== h; ) {
const p = J(g), w = g.getBoundingClientRect(), x = H(g), E = w.left + (g.clientLeft + parseFloat(x.paddingLeft)) * p.x, R = w.top + (g.clientTop + parseFloat(x.paddingTop)) * p.y;
f *= p.x, l *= p.y, a *= p.x, u *= p.y, f += E, l += R, h = W(g), g = vt(h);
}
}
return lt({
width: a,
height: u,
x: f,
y: l
});
}
function mt(t, e) {
const n = dt(t).scrollLeft;
return e ? e.left + n : G(j(t)).left + n;
}
function Qt(t, e) {
const n = t.getBoundingClientRect(), o = n.left + e.scrollLeft - mt(t, n), i = n.top + e.scrollTop;
return {
x: o,
y: i
};
}
function Ke(t) {
let {
elements: e,
rect: n,
offsetParent: o,
strategy: i
} = t;
const s = i === "fixed", r = j(o), c = e ? ut(e.floating) : !1;
if (o === r || c && s)
return n;
let f = {
scrollLeft: 0,
scrollTop: 0
}, l = I(1);
const a = I(0), u = z(o);
if ((u || !u && !s) && ((tt(o) !== "body" || ot(r)) && (f = dt(o)), z(o))) {
const d = G(o);
l = J(o), a.x = d.x + o.clientLeft, a.y = d.y + o.clientTop;
}
const m = r && !u && !s ? Qt(r, f) : I(0);
return {
width: n.width * l.x,
height: n.height * l.y,
x: n.x * l.x - f.scrollLeft * l.x + a.x + m.x,
y: n.y * l.y - f.scrollTop * l.y + a.y + m.y
};
}
function Ge(t) {
return Array.from(t.getClientRects());
}
function Je(t) {
const e = j(t), n = dt(t), o = t.ownerDocument.body, i = B(e.scrollWidth, e.clientWidth, o.scrollWidth, o.clientWidth), s = B(e.scrollHeight, e.clientHeight, o.scrollHeight, o.clientHeight);
let r = -n.scrollLeft + mt(t);
const c = -n.scrollTop;
return H(o).direction === "rtl" && (r += B(e.clientWidth, o.clientWidth) - i), {
width: i,
height: s,
x: r,
y: c
};
}
const Wt = 25;
function Qe(t, e) {
const n = W(t), o = j(t), i = n.visualViewport;
let s = o.clientWidth, r = o.clientHeight, c = 0, f = 0;
if (i) {
s = i.width, r = i.height;
const a = Ct();
(!a || a && e === "fixed") && (c = i.offsetLeft, f = i.offsetTop);
}
const l = mt(o);
if (l <= 0) {
const a = o.ownerDocument, u = a.body, m = getComputedStyle(u), d = a.compatMode === "CSS1Compat" && parseFloat(m.marginLeft) + parseFloat(m.marginRight) || 0, h = Math.abs(o.clientWidth - u.clientWidth - d);
h <= Wt && (s -= h);
} else
l <= Wt && (s += l);
return {
width: s,
height: r,
x: c,
y: f
};
}
const Ze = /* @__PURE__ */ new Set(["absolute", "fixed"]);
function tn(t, e) {
const n = G(t, !0, e === "fixed"), o = n.top + t.clientTop, i = n.left + t.clientLeft, s = z(t) ? J(t) : I(1), r = t.clientWidth * s.x, c = t.clientHeight * s.y, f = i * s.x, l = o * s.y;
return {
width: r,
height: c,
x: f,
y: l
};
}
function Nt(t, e, n) {
let o;
if (e === "viewport")
o = Qe(t, n);
else if (e === "document")
o = Je(j(t));
else if ($(e))
o = tn(e, n);
else {
const i = Jt(t);
o = {
x: e.x - i.x,
y: e.y - i.y,
width: e.width,
height: e.height
};
}
return lt(o);
}
function Zt(t, e) {
const n = K(t);
return n === e || !$(n) || Q(n) ? !1 : H(n).position === "fixed" || Zt(n, e);
}
function en(t, e) {
const n = e.get(t);
if (n)
return n;
let o = nt(t, [], !1).filter((c) => $(c) && tt(c) !== "body"), i = null;
const s = H(t).position === "fixed";
let r = s ? K(t) : t;
for (; $(r) && !Q(r); ) {
const c = H(r), f = At(r);
!f && c.position === "fixed" && (i = null), (s ? !f && !i : !f && c.position === "static" && !!i && Ze.has(i.position) || ot(r) && !f && Zt(t, r)) ? o = o.filter((a) => a !== r) : i = c, r = K(r);
}
return e.set(t, o), o;
}
function nn(t) {
let {
element: e,
boundary: n,
rootBoundary: o,
strategy: i
} = t;
const r = [...n === "clippingAncestors" ? ut(e) ? [] : en(e, this._c) : [].concat(n), o], c = r[0], f = r.reduce((l, a) => {
const u = Nt(e, a, i);
return l.top = B(u.top, l.top), l.right = q(u.right, l.right), l.bottom = q(u.bottom, l.bottom), l.left = B(u.left, l.left), l;
}, Nt(e, c, i));
return {
width: f.right - f.left,
height: f.bottom - f.top,
x: f.left,
y: f.top
};
}
function on(t) {
const {
width: e,
height: n
} = Gt(t);
return {
width: e,
height: n
};
}
function sn(t, e, n) {
const o = z(e), i = j(e), s = n === "fixed", r = G(t, !0, s, e);
let c = {
scrollLeft: 0,
scrollTop: 0
};
const f = I(0);
function l() {
f.x = mt(i);
}
if (o || !o && !s)
if ((tt(e) !== "body" || ot(i)) && (c = dt(e)), o) {
const d = G(e, !0, s, e);
f.x = d.x + e.clientLeft, f.y = d.y + e.clientTop;
} else
i && l();
s && !o && i && l();
const a = i && !o && !s ? Qt(i, c) : I(0), u = r.left + c.scrollLeft - f.x - a.x, m = r.top + c.scrollTop - f.y - a.y;
return {
x: u,
y: m,
width: r.width,
height: r.height
};
}
function gt(t) {
return H(t).position === "static";
}
function $t(t, e) {
if (!z(t) || H(t).position === "fixed")
return null;
if (e)
return e(t);
let n = t.offsetParent;
return j(t) === n && (n = n.ownerDocument.body), n;
}
function te(t, e) {
const n = W(t);
if (ut(t))
return n;
if (!z(t)) {
let i = K(t);
for (; i && !Q(i); ) {
if ($(i) && !gt(i))
return i;
i = K(i);
}
return n;
}
let o = $t(t, e);
for (; o && _e(o) && gt(o); )
o = $t(o, e);
return o && Q(o) && gt(o) && !At(o) ? n : o || Ue(t) || n;
}
const rn = async function(t) {
const e = this.getOffsetParent || te, n = this.getDimensions, o = await n(t.floating);
return {
reference: sn(t.reference, await e(t.floating), t.strategy),
floating: {
x: 0,
y: 0,
width: o.width,
height: o.height
}
};
};
function cn(t) {
return H(t).direction === "rtl";
}
const ln = {
convertOffsetParentRelativeRectToViewportRelativeRect: Ke,
getDocumentElement: j,
getClippingRect: nn,
getOffsetParent: te,
getElementRects: rn,
getClientRects: Ge,
getDimensions: on,
getScale: J,
isElement: $,
isRTL: cn
};
function ee(t, e) {
return t.x === e.x && t.y === e.y && t.width === e.width && t.height === e.height;
}
function an(t, e) {
let n = null, o;
const i = j(t);
function s() {
var c;
clearTimeout(o), (c = n) == null || c.disconnect(), n = null;
}
function r(c, f) {
c === void 0 && (c = !1), f === void 0 && (f = 1), s();
const l = t.getBoundingClientRect(), {
left: a,
top: u,
width: m,
height: d
} = l;
if (c || e(), !m || !d)
return;
const h = it(u), g = it(i.clientWidth - (a + m)), p = it(i.clientHeight - (u + d)), w = it(a), E = {
rootMargin: -h + "px " + -g + "px " + -p + "px " + -w + "px",
threshold: B(0, q(1, f)) || 1
};
let R = !0;
function b(A) {
const y = A[0].intersectionRatio;
if (y !== f) {
if (!R)
return r();
y ? r(!1, y) : o = setTimeout(() => {
r(!1, 1e-7);
}, 1e3);
}
y === 1 && !ee(l, t.getBoundingClientRect()) && r(), R = !1;
}
try {
n = new IntersectionObserver(b, {
...E,
// Handle <iframe>s
root: i.ownerDocument
});
} catch {
n = new IntersectionObserver(b, E);
}
n.observe(t);
}
return r(!0), s;
}
function On(t, e, n, o) {
o === void 0 && (o = {});
const {
ancestorScroll: i = !0,
ancestorResize: s = !0,
elementResize: r = typeof ResizeObserver == "function",
layoutShift: c = typeof IntersectionObserver == "function",
animationFrame: f = !1
} = o, l = St(t), a = i || s ? [...l ? nt(l) : [], ...nt(e)] : [];
a.forEach((w) => {
i && w.addEventListener("scroll", n, {
passive: !0
}), s && w.addEventListener("resize", n);
});
const u = l && c ? an(l, n) : null;
let m = -1, d = null;
r && (d = new ResizeObserver((w) => {
let [x] = w;
x && x.target === l && d && (d.unobserve(e), cancelAnimationFrame(m), m = requestAnimationFrame(() => {
var E;
(E = d) == null || E.observe(e);
})), n();
}), l && !f && d.observe(l), d.observe(e));
let h, g = f ? G(t) : null;
f && p();
function p() {
const w = G(t);
g && !ee(g, w) && n(), g = w, h = requestAnimationFrame(p);
}
return n(), () => {
var w;
a.forEach((x) => {
i && x.removeEventListener("scroll", n), s && x.removeEventListener("resize", n);
}), u == null || u(), (w = d) == null || w.disconnect(), d = null, f && cancelAnimationFrame(h);
};
}
const fn = ke, un = Be, dn = Te, mn = Ne, hn = Me, Ht = De, gn = We, pn = (t, e, n) => {
const o = /* @__PURE__ */ new Map(), i = {
platform: ln,
...n
}, s = {
...i.platform,
_c: o
};
return Pe(t, e, {
...i,
platform: s
});
};
var wn = typeof document < "u", yn = function() {
}, st = wn ? oe : yn;
function at(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, i;
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 (!at(t[o], e[o]))
return !1;
return !0;
}
if (i = Object.keys(t), n = i.length, n !== Object.keys(e).length)
return !1;
for (o = n; o-- !== 0; )
if (!{}.hasOwnProperty.call(e, i[o]))
return !1;
for (o = n; o-- !== 0; ) {
const s = i[o];
if (!(s === "_owner" && t.$$typeof) && !at(t[s], e[s]))
return !1;
}
return !0;
}
return t !== t && e !== e;
}
function ne(t) {
return typeof window > "u" ? 1 : (t.ownerDocument.defaultView || window).devicePixelRatio || 1;
}
function _t(t, e) {
const n = ne(t);
return Math.round(e * n) / n;
}
function pt(t) {
const e = v.useRef(t);
return st(() => {
e.current = t;
}), e;
}
function An(t) {
t === void 0 && (t = {});
const {
placement: e = "bottom",
strategy: n = "absolute",
middleware: o = [],
platform: i,
elements: {
reference: s,
floating: r
} = {},
transform: c = !0,
whileElementsMounted: f,
open: l
} = t, [a, u] = v.useState({
x: 0,
y: 0,
strategy: n,
placement: e,
middlewareData: {},
isPositioned: !1
}), [m, d] = v.useState(o);
at(m, o) || d(o);
const [h, g] = v.useState(null), [p, w] = v.useState(null), x = v.useCallback((O) => {
O !== A.current && (A.current = O, g(O));
}, []), E = v.useCallback((O) => {
O !== y.current && (y.current = O, w(O));
}, []), R = s || h, b = r || p, A = v.useRef(null), y = v.useRef(null), S = v.useRef(a), D = f != null, C = pt(f), N = pt(i), F = pt(l), T = v.useCallback(() => {
if (!A.current || !y.current)
return;
const O = {
placement: e,
strategy: n,
middleware: m
};
N.current && (O.platform = N.current), pn(A.current, y.current, O).then((k) => {
const Y = {
...k,
// 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: F.current !== !1
};
L.current && !at(S.current, Y) && (S.current = Y, re.flushSync(() => {
u(Y);
}));
});
}, [m, e, n, N, F]);
st(() => {
l === !1 && S.current.isPositioned && (S.current.isPositioned = !1, u((O) => ({
...O,
isPositioned: !1
})));
}, [l]);
const L = v.useRef(!1);
st(() => (L.current = !0, () => {
L.current = !1;
}), []), st(() => {
if (R && (A.current = R), b && (y.current = b), R && b) {
if (C.current)
return C.current(R, b, T);
T();
}
}, [R, b, T, C, D]);
const _ = v.useMemo(() => ({
reference: A,
floating: y,
setReference: x,
setFloating: E
}), [x, E]), P = v.useMemo(() => ({
reference: R,
floating: b
}), [R, b]), M = v.useMemo(() => {
const O = {
position: n,
left: 0,
top: 0
};
if (!P.floating)
return O;
const k = _t(P.floating, a.x), Y = _t(P.floating, a.y);
return c ? {
...O,
transform: "translate(" + k + "px, " + Y + "px)",
...ne(P.floating) >= 1.5 && {
willChange: "transform"
}
} : {
position: n,
left: k,
top: Y
};
}, [n, c, P.floating, a.x, a.y]);
return v.useMemo(() => ({
...a,
update: T,
refs: _,
elements: P,
floatingStyles: M
}), [a, T, _, P, M]);
}
const xn = (t) => {
function e(n) {
return {}.hasOwnProperty.call(n, "current");
}
return {
name: "arrow",
options: t,
fn(n) {
const {
element: o,
padding: i
} = typeof t == "function" ? t(n) : t;
return o && e(o) ? o.current != null ? Ht({
element: o.current,
padding: i
}).fn(n) : {} : o ? Ht({
element: o,
padding: i
}).fn(n) : {};
}
};
}, Cn = (t, e) => ({
...fn(t),
options: [t, e]
}), Sn = (t, e) => ({
...un(t),
options: [t, e]
}), Ln = (t, e) => ({
...gn(t),
options: [t, e]
}), Pn = (t, e) => ({
...dn(t),
options: [t, e]
}), Dn = (t, e) => ({
...mn(t),
options: [t, e]
}), Tn = (t, e) => ({
...hn(t),
options: [t, e]
}), Mn = (t, e) => ({
...xn(t),
options: [t, e]
});
export {
ue as D,
On as a,
Dn as b,
Mn as c,
bt as d,
Rn as e,
Pn as f,
Tn as h,
Ln as l,
Cn as o,
Sn as s,
An as u
};