radix-vue
Version:
Vue port for Radix UI Primitives.
1,627 lines (1,620 loc) • 356 kB
JavaScript
import { inject as pn, provide as fn, shallowRef as vn, watchEffect as ee, readonly as it, ref as B, watch as Y, customRef as uo, effectScope as Pa, computed as S, nextTick as G, getCurrentScope as Sa, onScopeDispose as Ta, unref as a, toRef as Da, getCurrentInstance as Fe, onMounted as U, Fragment as ie, defineComponent as g, toRefs as z, renderSlot as y, onBeforeUnmount as co, onBeforeUpdate as Oa, onUpdated as Ia, toHandlerKey as Aa, camelize as mn, onUnmounted as fe, mergeProps as T, h as Re, cloneVNode as Ma, openBlock as h, createBlock as b, withCtx as v, createVNode as k, createCommentVNode as J, withKeys as le, Teleport as Ue, normalizeProps as R, guardReactiveProps as N, reactive as hn, normalizeStyle as ae, withModifiers as ne, createElementBlock as Q, mergeDefaults as yn, createElementVNode as rt, renderList as po, markRaw as en, withDirectives as fo, vShow as gn, resolveDynamicComponent as $e, createTextVNode as ue, toDisplayString as Le, isRef as ut, onBeforeMount as bn, vModelSelect as ka, useSlots as Cn } from "vue";
import { useFloating as Ra, autoUpdate as Va, offset as Fa, shift as La, limitShift as Ka, flip as Na, size as Ha, arrow as Wa, hide as ja } from "@floating-ui/vue";
function H(o, t) {
const e = typeof o == "string" && !t ? `${o}Context` : t, n = Symbol(e);
return [(i) => {
const r = pn(n, i);
if (r || r === null)
return r;
throw new Error(
`Injection \`${n.toString()}\` not found. Component must be used within ${Array.isArray(o) ? `one of the following components: ${o.join(
", "
)}` : `\`${o}\``}`
);
}, (i) => (fn(n, i), i)];
}
function vo(o, t, e) {
const n = e.originalEvent.target, s = new CustomEvent(o, {
bubbles: !1,
cancelable: !0,
detail: e
});
t && n.addEventListener(o, t, { once: !0 }), n.dispatchEvent(s);
}
function za(o, t) {
var e;
const n = vn();
return ee(() => {
n.value = o();
}, {
...t,
flush: (e = t == null ? void 0 : t.flush) != null ? e : "sync"
}), it(n);
}
function mo(o, t) {
let e, n, s;
const l = B(!0), i = () => {
l.value = !0, s();
};
Y(o, i, { flush: "sync" });
const r = typeof t == "function" ? t : t.get, u = typeof t == "function" ? void 0 : t.set, d = uo((c, p) => (n = c, s = p, {
get() {
return l.value && (e = r(), l.value = !1), n(), e;
},
set(f) {
u == null || u(f);
}
}));
return Object.isExtensible(d) && (d.trigger = i), d;
}
function dt(o) {
return Sa() ? (Ta(o), !0) : !1;
}
function Tt(o) {
let t = !1, e;
const n = Pa(!0);
return (...s) => (t || (e = n.run(() => o(...s)), t = !0), e);
}
function ge(o) {
return typeof o == "function" ? o() : a(o);
}
const Be = typeof window < "u" && typeof document < "u", Ua = (o) => typeof o < "u", qa = Object.prototype.toString, Ga = (o) => qa.call(o) === "[object Object]", tn = (o, t, e) => Math.min(e, Math.max(t, o)), at = () => {
};
function Ya(o, t) {
function e(...n) {
return new Promise((s, l) => {
Promise.resolve(o(() => t.apply(this, n), { fn: t, thisArg: this, args: n })).then(s).catch(l);
});
}
return e;
}
function Xa(o, t = {}) {
let e, n, s = at;
const l = (r) => {
clearTimeout(r), s(), s = at;
};
return (r) => {
const u = ge(o), d = ge(t.maxWait);
return e && l(e), u <= 0 || d !== void 0 && d <= 0 ? (n && (l(n), n = null), Promise.resolve(r())) : new Promise((c, p) => {
s = t.rejectOnCancel ? p : c, d && !n && (n = setTimeout(() => {
e && l(e), n = null, c(r());
}, d)), e = setTimeout(() => {
n && l(n), n = null, c(r());
}, u);
});
};
}
function Ja(...o) {
if (o.length !== 1)
return Da(...o);
const t = o[0];
return typeof t == "function" ? it(uo(() => ({ get: t, set: at }))) : B(t);
}
function ho(o, t = 1e4) {
return uo((e, n) => {
let s = ge(o), l;
const i = () => setTimeout(() => {
s = ge(o), n();
}, ge(t));
return dt(() => {
clearTimeout(l);
}), {
get() {
return e(), s;
},
set(r) {
s = r, n(), clearTimeout(l), l = i();
}
};
});
}
function yo(o, t = 200, e = {}) {
return Ya(
Xa(t, e),
o
);
}
function go(o, t, e = {}) {
const {
immediate: n = !0
} = e, s = B(!1);
let l = null;
function i() {
l && (clearTimeout(l), l = null);
}
function r() {
s.value = !1, i();
}
function u(...d) {
i(), s.value = !0, l = setTimeout(() => {
s.value = !1, l = null, o(...d);
}, ge(t));
}
return n && (s.value = !0, Be && u()), dt(r), {
isPending: it(s),
start: u,
stop: r
};
}
function Za(o = 1e3, t = {}) {
const {
controls: e = !1,
callback: n
} = t, s = go(
n ?? at,
o,
t
), l = S(() => !s.isPending.value);
return e ? {
ready: l,
...s
} : l;
}
function Qa(o, t, e) {
const n = Y(o, (...s) => (G(() => n()), t(...s)), e);
}
function ve(o) {
var t;
const e = ge(o);
return (t = e == null ? void 0 : e.$el) != null ? t : e;
}
const ct = Be ? window : void 0;
function Ve(...o) {
let t, e, n, s;
if (typeof o[0] == "string" || Array.isArray(o[0]) ? ([e, n, s] = o, t = ct) : [t, e, n, s] = o, !t)
return at;
Array.isArray(e) || (e = [e]), Array.isArray(n) || (n = [n]);
const l = [], i = () => {
l.forEach((c) => c()), l.length = 0;
}, r = (c, p, f, m) => (c.addEventListener(p, f, m), () => c.removeEventListener(p, f, m)), u = Y(
() => [ve(t), ge(s)],
([c, p]) => {
if (i(), !c)
return;
const f = Ga(p) ? { ...p } : p;
l.push(
...e.flatMap((m) => n.map((C) => r(c, m, C, f)))
);
},
{ immediate: !0, flush: "post" }
), d = () => {
u(), i();
};
return dt(d), d;
}
function es(o) {
return typeof o == "function" ? o : typeof o == "string" ? (t) => t.key === o : Array.isArray(o) ? (t) => o.includes(t.key) : () => !0;
}
function bo(...o) {
let t, e, n = {};
o.length === 3 ? (t = o[0], e = o[1], n = o[2]) : o.length === 2 ? typeof o[1] == "object" ? (t = !0, e = o[0], n = o[1]) : (t = o[0], e = o[1]) : (t = !0, e = o[0]);
const {
target: s = ct,
eventName: l = "keydown",
passive: i = !1,
dedupe: r = !1
} = n, u = es(t);
return Ve(s, l, (c) => {
c.repeat && ge(r) || u(c) && e(c);
}, i);
}
function ts(o = {}) {
var t;
const {
window: e = ct,
deep: n = !0
} = o, s = (t = o.document) != null ? t : e == null ? void 0 : e.document, l = () => {
var r;
let u = s == null ? void 0 : s.activeElement;
if (n)
for (; u != null && u.shadowRoot; )
u = (r = u == null ? void 0 : u.shadowRoot) == null ? void 0 : r.activeElement;
return u;
}, i = mo(
() => null,
() => l()
);
return e && (Ve(e, "blur", (r) => {
r.relatedTarget === null && i.trigger();
}, !0), Ve(e, "focus", i.trigger, !0)), i;
}
function Dt() {
const o = B(!1);
return Fe() && U(() => {
o.value = !0;
}), o;
}
function os(o) {
const t = Dt();
return S(() => (t.value, !!o()));
}
function ns(o, t = {}) {
const {
immediate: e = !0,
fpsLimit: n = void 0,
window: s = ct
} = t, l = B(!1), i = n ? 1e3 / n : null;
let r = 0, u = null;
function d(f) {
if (!l.value || !s)
return;
const m = f - (r || f);
if (i && m < i) {
u = s.requestAnimationFrame(d);
return;
}
o({ delta: m, timestamp: f }), r = f, u = s.requestAnimationFrame(d);
}
function c() {
!l.value && s && (l.value = !0, u = s.requestAnimationFrame(d));
}
function p() {
l.value = !1, u != null && s && (s.cancelAnimationFrame(u), u = null);
}
return e && c(), dt(p), {
isActive: it(l),
pause: p,
resume: c
};
}
function as(o) {
return JSON.parse(JSON.stringify(o));
}
function _e(o, t, e = {}) {
const { window: n = ct, ...s } = e;
let l;
const i = os(() => n && "ResizeObserver" in n), r = () => {
l && (l.disconnect(), l = void 0);
}, u = S(() => Array.isArray(o) ? o.map((p) => ve(p)) : [ve(o)]), d = Y(
u,
(p) => {
if (r(), i.value && n) {
l = new ResizeObserver(t);
for (const f of p)
f && l.observe(f, s);
}
},
{ immediate: !0, flush: "post", deep: !0 }
), c = () => {
r(), d();
};
return dt(c), {
isSupported: i,
stop: c
};
}
function ss(o, t = {}) {
const e = ts(t), n = S(() => ve(o));
return { focused: S(() => n.value && e.value ? n.value.contains(e.value) : !1) };
}
function ls(o, t) {
const e = vn(t);
return Y(
Ja(o),
(n, s) => {
e.value = s;
},
{ flush: "sync" }
), it(e);
}
function X(o, t, e, n = {}) {
var s, l, i;
const {
clone: r = !1,
passive: u = !1,
eventName: d,
deep: c = !1,
defaultValue: p,
shouldEmit: f
} = n, m = Fe(), C = e || (m == null ? void 0 : m.emit) || ((s = m == null ? void 0 : m.$emit) == null ? void 0 : s.bind(m)) || ((i = (l = m == null ? void 0 : m.proxy) == null ? void 0 : l.$emit) == null ? void 0 : i.bind(m == null ? void 0 : m.proxy));
let w = d;
t || (t = "modelValue"), w = w || `update:${t.toString()}`;
const $ = (x) => r ? typeof r == "function" ? r(x) : as(x) : x, _ = () => Ua(o[t]) ? $(o[t]) : p, E = (x) => {
f ? f(x) && C(w, x) : C(w, x);
};
if (u) {
const x = _(), P = B(x);
let I = !1;
return Y(
() => o[t],
(A) => {
I || (I = !0, P.value = $(A), G(() => I = !1));
}
), Y(
P,
(A) => {
!I && (A !== o[t] || c) && E(A);
},
{ deep: c }
), P;
} else
return S({
get() {
return _();
},
set(x) {
E(x);
}
});
}
function Ot(o) {
return o ? o.flatMap((t) => t.type === ie ? Ot(t.children) : [t]) : [];
}
function qe(o, t, e, n = {}) {
if (!t)
return null;
const {
arrowKeyOptions: s = "both",
attributeName: l = "data-radix-vue-collection-item",
itemsArray: i = [],
loop: r = !0,
dir: u = "ltr",
preventScroll: d = !0,
focus: c = !1
} = n, [p, f, m, C, w, $] = [
o.key === "ArrowRight",
o.key === "ArrowLeft",
o.key === "ArrowUp",
o.key === "ArrowDown",
o.key === "Home",
o.key === "End"
], _ = m || C, E = p || f;
if (!w && !$ && (!_ && !E || s === "vertical" && E || s === "horizontal" && _))
return null;
const x = e ? Array.from(e.querySelectorAll(`[${l}]`)) : i;
if (!x.length)
return null;
d && o.preventDefault();
let P = null;
return E || _ ? P = _n(x, t, {
goForward: _ ? C : u === "ltr" ? p : f,
loop: r
}) : w ? P = x.at(0) || null : $ && (P = x.at(-1) || null), c && (P == null || P.focus()), P;
}
function _n(o, t, { goForward: e, loop: n }, s = o.length) {
if (--s === 0)
return null;
const l = o.indexOf(t), i = e ? l + 1 : l - 1;
if (!n && (i < 0 || i >= o.length))
return null;
const r = (i + o.length) % o.length, u = o[r];
return u ? u.hasAttribute("disabled") && u.getAttribute("disabled") !== "false" ? _n(
o,
u,
{ goForward: e, loop: n },
s
) : u : null;
}
function Jt(o) {
return o !== null && typeof o == "object";
}
function oo(o, t, e = ".", n) {
if (!Jt(t))
return oo(o, {}, e, n);
const s = Object.assign({}, t);
for (const l in o) {
if (l === "__proto__" || l === "constructor")
continue;
const i = o[l];
i != null && (n && n(s, l, i, e) || (Array.isArray(i) && Array.isArray(s[l]) ? s[l] = [...i, ...s[l]] : Jt(i) && Jt(s[l]) ? s[l] = oo(
i,
s[l],
(e ? `${e}.` : "") + l.toString(),
n
) : s[l] = i));
}
return s;
}
function is(o) {
return (...t) => (
// eslint-disable-next-line unicorn/no-array-reduce
t.reduce((e, n) => oo(e, n, "", o), {})
);
}
const rs = is(), [wn, us] = H("ConfigProvider"), qr = /* @__PURE__ */ g({
__name: "ConfigProvider",
props: {
dir: { default: "ltr" },
scrollBody: { type: [Boolean, Object], default: !0 }
},
setup(o) {
const t = o, { dir: e, scrollBody: n } = z(t);
return us({
dir: e,
scrollBody: n
}), (s, l) => y(s.$slots, "default");
}
}), ds = Tt(() => B()), cs = Tt(() => B(0));
function pt(o) {
const t = wn({
scrollBody: B(!0)
}), e = cs(), n = ds(), s = B(o), l = () => {
document.body.style.paddingRight = "", document.body.style.marginRight = "", document.body.style.pointerEvents = "", document.body.style.removeProperty("--scrollbar-width"), document.body.style.overflow = n.value ?? "", n.value = void 0;
};
return o && e.value++, Y(s, (i) => {
var r;
if (Be && i) {
n.value === void 0 && (n.value = document.body.style.overflow);
const u = window.innerWidth - document.documentElement.clientWidth, d = { padding: u, margin: 0 }, c = (r = t.scrollBody) != null && r.value ? typeof t.scrollBody.value == "object" ? rs({
padding: t.scrollBody.value.padding === !0 ? u : t.scrollBody.value.padding,
margin: t.scrollBody.value.margin === !0 ? u : t.scrollBody.value.margin
}, d) : d : { padding: 0, margin: 0 };
u > 0 && (document.body.style.paddingRight = `${c.padding}px`, document.body.style.marginRight = `${c.margin}px`, document.body.style.setProperty("--scrollbar-width", `${u}px`), document.body.style.overflow = "hidden"), G(() => {
document.body.style.pointerEvents = "none", document.body.style.overflow = "hidden";
});
}
}, { immediate: !0 }), co(() => {
o && e.value--, e.value === 0 && l();
}), s;
}
const ps = "data-radix-vue-collection-item";
function re(o, t = ps) {
const e = o ?? Symbol();
return { createCollection: (l) => {
const i = B([]);
function r() {
const u = ve(l);
return u ? i.value = Array.from(
u.querySelectorAll(`[${t}]:not([data-disabled=true])`)
) : i.value = [];
}
return Oa(() => {
i.value = [];
}), U(r), Ia(r), Y(() => l == null ? void 0 : l.value, r, { immediate: !0 }), fn(e, i), i;
}, injectCollection: () => pn(e, B([])) };
}
function de(o) {
const t = wn({
dir: B("ltr")
});
return S(() => {
var e;
return (o == null ? void 0 : o.value) || ((e = t.dir) == null ? void 0 : e.value) || "ltr";
});
}
function ce(o) {
const t = Fe(), e = t == null ? void 0 : t.type.emits, n = {};
return e != null && e.length || console.warn(
`No emitted event found. Please check component: ${t == null ? void 0 : t.type.__name}`
), e == null || e.forEach((s) => {
n[Aa(mn(s))] = (...l) => o(s, ...l);
}), n;
}
let Zt = 0;
function Co() {
ee((o) => {
if (!Be)
return;
const t = document.querySelectorAll("[data-radix-focus-guard]");
document.body.insertAdjacentElement(
"afterbegin",
t[0] ?? on()
), document.body.insertAdjacentElement(
"beforeend",
t[1] ?? on()
), Zt++, o(() => {
Zt === 1 && document.querySelectorAll("[data-radix-focus-guard]").forEach((e) => e.remove()), Zt--;
});
});
}
function on() {
const o = document.createElement("span");
return o.setAttribute("data-radix-focus-guard", ""), o.tabIndex = 0, o.style.cssText = "outline: none; opacity: 0; position: fixed; pointer-events: none", o;
}
function Ke(o) {
return S(() => {
var t;
return ge(o) ? !!((t = ve(o)) != null && t.closest("form")) : !0;
});
}
function It(o) {
const t = Fe(), e = Object.keys((t == null ? void 0 : t.type.props) ?? {}).reduce((n, s) => {
const l = (t == null ? void 0 : t.type.props[s]).default;
return l !== void 0 && (n[s] = l), n;
}, {});
return mo(() => ({ ...o }), () => {
const n = {}, s = (t == null ? void 0 : t.vnode.props) ?? {};
return Object.keys(s).forEach((l) => {
n[mn(l)] = s[l];
}), Object.keys({ ...e, ...n }).reduce((l, i) => (o[i] !== void 0 && (l[i] = o[i]), l), {});
});
}
function pe(o, t) {
const e = It(o), n = t ? ce(t) : {};
return S(() => ({
...e.value,
...n
}));
}
function be() {
const o = Fe();
function t(e) {
typeof e == "object" && (o.exposed = e, o.exposeProxy = e);
}
return t;
}
var fs = function(o) {
if (typeof document > "u")
return null;
var t = Array.isArray(o) ? o[0] : o;
return t.ownerDocument.body;
}, ze = /* @__PURE__ */ new WeakMap(), bt = /* @__PURE__ */ new WeakMap(), Ct = {}, Qt = 0, En = function(o) {
return o && (o.host || En(o.parentNode));
}, vs = function(o, t) {
return t.map(function(e) {
if (o.contains(e))
return e;
var n = En(e);
return n && o.contains(n) ? n : (console.error("aria-hidden", e, "in not contained inside", o, ". Doing nothing"), null);
}).filter(function(e) {
return !!e;
});
}, ms = function(o, t, e, n) {
var s = vs(t, Array.isArray(o) ? o : [o]);
Ct[e] || (Ct[e] = /* @__PURE__ */ new WeakMap());
var l = Ct[e], i = [], r = /* @__PURE__ */ new Set(), u = new Set(s), d = function(p) {
!p || r.has(p) || (r.add(p), d(p.parentNode));
};
s.forEach(d);
var c = function(p) {
!p || u.has(p) || Array.prototype.forEach.call(p.children, function(f) {
if (r.has(f))
c(f);
else {
var m = f.getAttribute(n), C = m !== null && m !== "false", w = (ze.get(f) || 0) + 1, $ = (l.get(f) || 0) + 1;
ze.set(f, w), l.set(f, $), i.push(f), w === 1 && C && bt.set(f, !0), $ === 1 && f.setAttribute(e, "true"), C || f.setAttribute(n, "true");
}
});
};
return c(t), r.clear(), Qt++, function() {
i.forEach(function(p) {
var f = ze.get(p) - 1, m = l.get(p) - 1;
ze.set(p, f), l.set(p, m), f || (bt.has(p) || p.removeAttribute(n), bt.delete(p)), m || p.removeAttribute(e);
}), Qt--, Qt || (ze = /* @__PURE__ */ new WeakMap(), ze = /* @__PURE__ */ new WeakMap(), bt = /* @__PURE__ */ new WeakMap(), Ct = {});
};
}, hs = function(o, t, e) {
e === void 0 && (e = "data-aria-hidden");
var n = Array.from(Array.isArray(o) ? o : [o]), s = t || fs(o);
return s ? (n.push.apply(n, Array.from(s.querySelectorAll("[aria-live]"))), ms(n, s, e, "aria-hidden")) : function() {
return null;
};
};
function ft(o) {
let t;
Y(() => ve(o), (e) => {
e ? t = hs(e) : t && t();
}), fe(() => {
t && t();
});
}
const ys = Tt(() => ({ count: B(0) }));
function te(o) {
const { count: t } = ys();
return o || t.value++, o || `radix-${t.value}`;
}
function xn(o) {
const t = B(), e = S(() => {
var s;
return ((s = t.value) == null ? void 0 : s.width) ?? 0;
}), n = S(() => {
var s;
return ((s = t.value) == null ? void 0 : s.height) ?? 0;
});
return U(() => {
const s = ve(o);
if (s) {
t.value = { width: s.offsetWidth, height: s.offsetHeight };
const l = new ResizeObserver((i) => {
if (!Array.isArray(i) || !i.length)
return;
const r = i[0];
let u, d;
if ("borderBoxSize" in r) {
const c = r.borderBoxSize, p = Array.isArray(c) ? c[0] : c;
u = p.inlineSize, d = p.blockSize;
} else
u = s.offsetWidth, d = s.offsetHeight;
t.value = { width: u, height: d };
});
return l.observe(s, { box: "border-box" }), () => l.unobserve(s);
} else
t.value = void 0;
}), {
width: e,
height: n
};
}
function $n(o, t) {
const e = B(o);
function n(l) {
return t[e.value][l] ?? e.value;
}
return {
state: e,
dispatch: (l) => {
e.value = n(l);
}
};
}
function _o(o) {
const t = ho("", 1e3);
return {
search: t,
handleTypeaheadSearch: (s) => {
var p, f;
t.value = t.value + s;
const l = o.value, i = document.activeElement, r = ((f = (p = l.find((m) => m === i)) == null ? void 0 : p.textContent) == null ? void 0 : f.trim()) ?? "", u = l.map((m) => {
var C;
return ((C = m.textContent) == null ? void 0 : C.trim()) ?? "";
}), d = gs(u, t.value, r), c = l.find(
(m) => {
var C;
return ((C = m.textContent) == null ? void 0 : C.trim()) === d;
}
);
c && c.focus();
},
resetTypeahead: () => {
t.value = "";
}
};
}
function wo(o, t) {
return o.map((e, n) => o[(t + n) % o.length]);
}
function gs(o, t, e) {
const s = t.length > 1 && Array.from(t).every((d) => d === t[0]) ? t[0] : t, l = e ? o.indexOf(e) : -1;
let i = wo(o, Math.max(l, 0));
s.length === 1 && (i = i.filter((d) => d !== e));
const u = i.find(
(d) => d.toLowerCase().startsWith(s.toLowerCase())
);
return u !== e ? u : void 0;
}
function Gr(o, t) {
return {
inheritAttrs: !1,
name: `${o.__name ?? ""}Wrapper`,
setup(e, n) {
return () => {
const s = typeof (t == null ? void 0 : t.props) == "function" ? t == null ? void 0 : t.props(n.attrs) : t == null ? void 0 : t.props, l = be(), i = T(s, n.attrs);
return Re(o, { ...i, ref: l }, n.slots);
};
}
};
}
const Eo = g({
name: "PrimitiveSlot",
inheritAttrs: !1,
setup(o, { attrs: t, slots: e }) {
return () => {
var i, r;
if (!e.default)
return null;
const n = Ot(e.default()), [s, ...l] = n;
if (Object.keys(t).length > 0) {
(i = s.props) == null || delete i.ref;
const u = T(t, s.props ?? {});
t.class && ((r = s.props) != null && r.class) && delete s.props.class;
const d = Ma(s, u);
for (const c in u)
c.startsWith("on") && (d.props || (d.props = {}), d.props[c] = u[c]);
return n.length === 1 ? d : [d, ...l];
}
return n;
};
}
}), D = g({
name: "Primitive",
inheritAttrs: !1,
props: {
asChild: {
type: Boolean,
default: !1
},
as: {
type: [String, Object],
default: "div"
}
},
setup(o, { attrs: t, slots: e }) {
return (o.asChild ? "template" : o.as) !== "template" ? () => Re(o.as, t, { default: e.default }) : () => Re(Eo, t, { default: e.default });
}
});
function V() {
const o = B(), t = S(() => {
var e, n;
return ["#text", "#comment"].includes((e = o.value) == null ? void 0 : e.$el.nodeName) ? (n = o.value) == null ? void 0 : n.$el.nextElementSibling : ve(o);
});
return {
primitiveElement: o,
currentElement: t
};
}
const [Bn, bs] = H("CollapsibleRoot"), Cs = /* @__PURE__ */ g({
__name: "CollapsibleRoot",
props: {
defaultOpen: { type: Boolean, default: !1 },
open: { type: Boolean, default: void 0 },
disabled: { type: Boolean },
asChild: { type: Boolean },
as: {}
},
emits: ["update:open"],
setup(o, { expose: t, emit: e }) {
const n = o, l = X(n, "open", e, {
defaultValue: n.defaultOpen,
passive: n.open === void 0
}), i = X(n, "disabled");
return bs({
contentId: te(),
disabled: i,
open: l,
onOpenToggle: () => {
l.value = !l.value;
}
}), t({ open: l }), (r, u) => (h(), b(a(D), {
as: r.as,
"as-child": n.asChild,
"data-state": n.open ? "open" : "closed",
"data-disabled": n.disabled ? "" : void 0
}, {
default: v(() => [
y(r.$slots, "default", { open: a(l) })
]),
_: 3
}, 8, ["as", "as-child", "data-state", "data-disabled"]));
}
}), _s = /* @__PURE__ */ g({
__name: "CollapsibleTrigger",
props: {
asChild: { type: Boolean },
as: { default: "button" }
},
setup(o) {
const t = o, e = Bn();
return (n, s) => {
var l, i;
return h(), b(a(D), {
type: n.as === "button" ? "button" : void 0,
as: n.as,
"as-child": t.asChild,
"aria-controls": a(e).contentId,
"aria-expanded": a(e).open.value,
"data-state": a(e).open.value ? "open" : "closed",
"data-disabled": (l = a(e).disabled) != null && l.value ? "" : void 0,
disabled: (i = a(e).disabled) == null ? void 0 : i.value,
onClick: a(e).onOpenToggle
}, {
default: v(() => [
y(n.$slots, "default")
]),
_: 3
}, 8, ["type", "as", "as-child", "aria-controls", "aria-expanded", "data-state", "data-disabled", "disabled", "onClick"]);
};
}
});
function ws(o, t) {
const e = B({}), n = B("none"), s = o.value ? "mounted" : "unmounted", { state: l, dispatch: i } = $n(s, {
mounted: {
UNMOUNT: "unmounted",
ANIMATION_OUT: "unmountSuspended"
},
unmountSuspended: {
MOUNT: "mounted",
ANIMATION_END: "unmounted"
},
unmounted: {
MOUNT: "mounted"
}
});
Y(
o,
async (f, m) => {
var w;
const C = m !== f;
if (await G(), C) {
const $ = n.value, _ = _t(t.value);
f ? i("MOUNT") : _ === "none" || ((w = e.value) == null ? void 0 : w.display) === "none" ? i("UNMOUNT") : i(m && $ !== _ ? "ANIMATION_OUT" : "UNMOUNT");
}
},
{ immediate: !0 }
);
const r = (f) => {
const m = _t(t.value), C = m.includes(
f.animationName
);
f.target === t.value && C && i("ANIMATION_END"), f.target === t.value && m === "none" && i("ANIMATION_END");
}, u = (f) => {
f.target === t.value && (n.value = _t(t.value));
}, d = Y(
t,
(f, m) => {
f ? (e.value = getComputedStyle(f), f.addEventListener("animationstart", u), f.addEventListener("animationcancel", r), f.addEventListener("animationend", r)) : (i("ANIMATION_END"), m == null || m.removeEventListener("animationstart", u), m == null || m.removeEventListener("animationcancel", r), m == null || m.removeEventListener("animationend", r));
},
{ immediate: !0 }
), c = Y(l, () => {
const f = _t(t.value);
n.value = l.value === "mounted" ? f : "none";
});
return fe(() => {
d(), c();
}), {
isPresent: S(
() => ["mounted", "unmountSuspended"].includes(l.value)
)
};
}
function _t(o) {
return o && getComputedStyle(o).animationName || "none";
}
const se = g({
name: "Presence",
props: {
present: {
type: Boolean,
required: !0
},
forceMount: {
type: Boolean
}
},
slots: {},
setup(o, { slots: t, expose: e }) {
var d;
const { present: n, forceMount: s } = z(o), l = B(), { isPresent: i } = ws(n, l);
e({ present: i });
let r = t.default({ present: i });
r = Ot(r || []);
const u = Fe();
if (r && (r == null ? void 0 : r.length) > 1) {
const c = (d = u == null ? void 0 : u.parent) != null && d.type.name ? `<${u.parent.type.name} />` : "component";
throw new Error(
[
`Detected an invalid children for \`${c}\` for \`Presence\` component.`,
"",
"Note: Presence works similarly to `v-if` directly, but it waits for animation/transition to finished before unmounting. So it expect only one direct child of valid VNode type.",
"You can apply a few solutions:",
[
"Provide a single child element so that `presence` directive attach correctly.rv",
"Ensure the first child is an actual element instead of a raw text node or comment node."
].map((p) => ` - ${p}`).join(`
`)
].join(`
`)
);
}
return () => s.value || n.value || i.value ? Re(t.default({ present: i })[0], {
ref: (c) => {
const p = ve(c);
return typeof (p == null ? void 0 : p.hasAttribute) > "u" || (p != null && p.hasAttribute("data-radix-popper-content-wrapper") ? l.value = p.firstChild : l.value = p), p;
}
}) : null;
}
}), Es = /* @__PURE__ */ g({
inheritAttrs: !1,
__name: "CollapsibleContent",
props: {
forceMount: { type: Boolean },
asChild: { type: Boolean },
as: {}
},
setup(o) {
const t = o, e = Bn(), n = B(), { primitiveElement: s, currentElement: l } = V(), i = B(0), r = B(0), u = S(() => e.open.value), d = B(u.value), c = B();
return Y(
() => {
var p;
return [u.value, (p = n.value) == null ? void 0 : p.present];
},
async () => {
await G();
const p = l.value;
if (!p)
return;
c.value = c.value || {
transitionDuration: p.style.transitionDuration,
animationName: p.style.animationName
}, p.style.transitionDuration = "0s", p.style.animationName = "none";
const f = p.getBoundingClientRect();
r.value = f.height, i.value = f.width, d.value || (p.style.transitionDuration = c.value.transitionDuration, p.style.animationName = c.value.animationName);
},
{
immediate: !0
}
), U(() => {
requestAnimationFrame(() => {
d.value = !1;
});
}), (p, f) => (h(), b(a(se), {
ref_key: "presentRef",
ref: n,
present: p.forceMount || a(e).open.value,
"force-mount": !0
}, {
default: v(() => {
var m, C;
return [
k(a(D), T(p.$attrs, {
id: a(e).contentId,
ref_key: "primitiveElement",
ref: s,
"as-child": t.asChild,
as: p.as,
"data-state": a(e).open.value ? "open" : "closed",
"data-disabled": (m = a(e).disabled) != null && m.value ? "true" : void 0,
hidden: !((C = n.value) != null && C.present),
style: {
"--radix-collapsible-content-height": `${r.value}px`,
"--radix-collapsible-content-width": `${i.value}px`
}
}), {
default: v(() => {
var w;
return [
(w = n.value) != null && w.present ? y(p.$slots, "default", { key: 0 }) : J("", !0)
];
}),
_: 3
}, 16, ["id", "as-child", "as", "data-state", "data-disabled", "hidden", "style"])
];
}),
_: 3
}, 8, ["present"]));
}
});
function xs(o, t) {
if (o === "single") {
if (Array.isArray(t)) {
console.error(`Invalid prop \`value\` of value \`${t}\` supplied to \`AccordionRoot\`, which type is \`single\`. The \`value\` prop must be:
- a string
- \`undefined\`
If you want to use multiple values, use the \`AccordionRoot\` with type \`multiple\`.
Defaulting to \`undefined\`.`);
return;
}
} else if (o === "multiple" && (typeof t == "string" || typeof t > "u"))
return console.error(`Invalid prop \`value\` of value \`${t}\` supplied to \`AccordionRoot\`, which type is \`multiple\`. The \`value\` prop must be:
- an array of strings
- empty array (\`[]\`)
If you want to use just one value, use the \`AccordionRoot\` with type \`single\`.
Defaulting to empty array (\`[]\`).`), [];
return t;
}
function $s({ type: o, defaultValue: t }) {
if (o === "multiple")
return Array.isArray(t) ? t : t === void 0 ? [] : (console.error(
`Invalid prop \`defaultValue\` of value \`${t}\` supplied to \`AccordionRoot\`, which type is \`multiple\`. The \`defaultValue\` prop must be:
- an array of strings
- empty array (\`[]\`)
If you want to use just one value, use the \`AccordionRoot\` with type \`single\`.
Defaulting to empty array (\`[]\`).`
), []);
if (o === "single") {
if (typeof t == "string")
return t;
if (t === void 0)
return;
console.error(
`Invalid prop \`defaultValue\` of value \`${t}\` supplied to \`AccordionRoot\`, which type is \`single\`. The \`defaultValue\` prop must be:
- a string
- \`undefined\`
Defaulting to \`undefined\`.`
);
return;
}
}
function Pn(o, t) {
const e = X(o, "modelValue", t, {
defaultValue: $s(o),
passive: o.modelValue === void 0
});
Y(
() => [o.type, o.modelValue],
() => {
const s = xs(o.type, e.value);
e.value !== s && (e.value = s);
},
{ immediate: !0 }
);
function n(s) {
if (o.type === "single")
e.value = s === e.value ? void 0 : s;
else {
const l = e.value || [];
if (l.includes(s)) {
const i = l.findIndex((r) => r === s);
l.splice(i, 1);
} else
l.push(s);
e.value = l, t("update:modelValue", e.value);
}
}
return {
modelValue: e,
changeModelValue: n
};
}
const [At, Bs] = H("AccordionRoot"), Yr = /* @__PURE__ */ g({
__name: "AccordionRoot",
props: {
type: {},
modelValue: {},
defaultValue: {},
collapsible: { type: Boolean, default: !1 },
disabled: { type: Boolean, default: !1 },
dir: {},
orientation: { default: "vertical" },
asChild: { type: Boolean, default: !1 },
as: {}
},
emits: ["update:modelValue"],
setup(o, { expose: t, emit: e }) {
const n = o, s = e, { dir: l, disabled: i } = z(n), r = de(l), { modelValue: u, changeModelValue: d } = Pn(n, s), { primitiveElement: c, currentElement: p } = V();
return Bs({
disabled: i,
direction: r,
orientation: n.orientation,
parentElement: p,
isSingle: S(() => n.type === "single"),
collapsible: n.collapsible,
modelValue: u,
changeModelValue: d
}), t({
modelValue: u
}), (f, m) => (h(), b(a(D), {
ref_key: "primitiveElement",
ref: c,
"as-child": f.asChild,
as: f.as
}, {
default: v(() => [
y(f.$slots, "default", { modelValue: a(u) })
]),
_: 3
}, 8, ["as-child", "as"]));
}
}), [xo, Ps] = H("AccordionItem"), Xr = /* @__PURE__ */ g({
__name: "AccordionItem",
props: {
disabled: { type: Boolean },
value: {},
asChild: { type: Boolean },
as: {}
},
setup(o, { expose: t }) {
const e = o, n = At(), s = S(
() => n.isSingle.value ? e.value === n.modelValue.value : Array.isArray(n.modelValue.value) && n.modelValue.value.includes(e.value)
), l = S(() => n.disabled.value || e.disabled || n.isSingle.value && s.value && !n.collapsible), i = S(() => l.value ? "" : void 0), r = S(
() => s.value ? "open" : "closed"
/* Closed */
), { primitiveElement: u, currentElement: d } = V();
Ps({
open: s,
dataState: r,
disabled: l,
dataDisabled: i,
triggerId: te(),
primitiveElement: u,
currentElement: d,
value: S(() => e.value)
});
function c(p) {
qe(
p,
d.value,
n.parentElement.value,
{
arrowKeyOptions: n.orientation,
dir: n.direction.value,
focus: !0
}
);
}
return t({ open: s }), (p, f) => (h(), b(a(Cs), {
"data-orientation": a(n).orientation,
"data-disabled": i.value,
"data-state": r.value,
disabled: l.value,
open: s.value,
"as-child": e.asChild,
onKeydown: le(c, ["up", "down", "left", "right", "home", "end"])
}, {
default: v(() => [
y(p.$slots, "default", { open: s.value })
]),
_: 3
}, 8, ["data-orientation", "data-disabled", "data-state", "disabled", "open", "as-child", "onKeydown"]));
}
}), Jr = /* @__PURE__ */ g({
__name: "AccordionContent",
props: {
asChild: { type: Boolean },
as: {}
},
setup(o) {
const t = o, e = At(), n = xo();
return (s, l) => (h(), b(a(Es), {
id: a(n).triggerId,
role: "region",
open: a(n).open.value,
hidden: !a(n).open.value,
"as-child": t.asChild,
"aria-labelledby": a(n).triggerId,
"data-state": a(n).dataState.value,
"data-disabled": a(n).dataDisabled.value,
"data-orientation": a(e).orientation,
style: { "--radix-accordion-content-width": "var(--radix-collapsible-content-width)", "--radix-accordion-content-height": "var(--radix-collapsible-content-height)" }
}, {
default: v(() => [
y(s.$slots, "default")
]),
_: 3
}, 8, ["id", "open", "hidden", "as-child", "aria-labelledby", "data-state", "data-disabled", "data-orientation"]));
}
}), Zr = /* @__PURE__ */ g({
__name: "AccordionHeader",
props: {
asChild: { type: Boolean },
as: { default: "h3" }
},
setup(o) {
const t = o, e = At(), n = xo();
return (s, l) => (h(), b(a(D), {
as: t.as,
"as-child": t.asChild,
"data-orientation": a(e).orientation,
"data-state": a(n).dataState.value,
"data-disabled": a(n).dataDisabled.value
}, {
default: v(() => [
y(s.$slots, "default")
]),
_: 3
}, 8, ["as", "as-child", "data-orientation", "data-state", "data-disabled"]));
}
}), Qr = /* @__PURE__ */ g({
__name: "AccordionTrigger",
props: {
asChild: { type: Boolean },
as: {}
},
setup(o) {
const t = o, e = At(), n = xo();
function s() {
n.disabled.value || e.changeModelValue(n.value.value);
}
return (l, i) => (h(), b(a(_s), {
id: a(n).triggerId,
ref: a(n).primitiveElement,
"data-radix-vue-collection-item": "",
as: t.as,
"as-child": t.asChild,
"aria-controls": a(n).triggerId,
"aria-disabled": a(n).disabled.value || void 0,
"aria-expanded": a(n).open.value || !1,
"data-disabled": a(n).dataDisabled.value,
"data-orientation": a(e).orientation,
"data-state": a(n).dataState.value,
disabled: a(n).disabled.value,
onClick: s
}, {
default: v(() => [
y(l.$slots, "default")
]),
_: 3
}, 8, ["id", "as", "as-child", "aria-controls", "aria-disabled", "aria-expanded", "data-disabled", "data-orientation", "data-state", "disabled"]));
}
}), [ye, Ss] = H("DialogRoot"), Ts = /* @__PURE__ */ g({
__name: "DialogRoot",
props: {
open: { type: Boolean, default: void 0 },
defaultOpen: { type: Boolean, default: !1 },
modal: { type: Boolean, default: !0 }
},
emits: ["update:open"],
setup(o, { emit: t }) {
const e = o, s = X(e, "open", t, {
defaultValue: e.defaultOpen,
passive: e.open === void 0
}), l = B(), i = B(), { modal: r } = z(e);
return Ss({
open: s,
modal: r,
openModal: () => {
s.value = !0;
},
onOpenChange: (u) => {
s.value = u;
},
onOpenToggle: () => {
s.value = !s.value;
},
contentId: te(),
titleId: te(),
descriptionId: te(),
triggerElement: l,
contentElement: i
}), (u, d) => y(u.$slots, "default");
}
}), Ds = /* @__PURE__ */ g({
__name: "DialogTrigger",
props: {
asChild: { type: Boolean },
as: { default: "button" }
},
setup(o) {
const t = o, e = ye(), { primitiveElement: n, currentElement: s } = V();
return U(() => {
e.triggerElement = s;
}), (l, i) => (h(), b(a(D), T({
ref_key: "primitiveElement",
ref: n
}, t, {
type: l.as === "button" ? "button" : void 0,
"aria-haspopup": "dialog",
"aria-expanded": a(e).open.value || !1,
"aria-controls": a(e).contentId,
"data-state": a(e).open.value ? "open" : "closed",
onClick: a(e).onOpenToggle
}), {
default: v(() => [
y(l.$slots, "default")
]),
_: 3
}, 16, ["type", "aria-expanded", "aria-controls", "data-state", "onClick"]));
}
}), Pe = /* @__PURE__ */ g({
__name: "Teleport",
props: {
to: { default: "body" },
disabled: { type: Boolean },
forceMount: { type: Boolean }
},
setup(o) {
const t = Dt();
return (e, n) => a(t) || e.forceMount ? (h(), b(Ue, {
key: 0,
to: e.to,
disabled: e.disabled
}, [
y(e.$slots, "default")
], 8, ["to", "disabled"])) : J("", !0);
}
}), eu = /* @__PURE__ */ g({
__name: "DialogPortal",
props: {
to: {},
disabled: { type: Boolean },
forceMount: { type: Boolean }
},
setup(o) {
const t = o;
return (e, n) => (h(), b(a(Pe), R(N(t)), {
default: v(() => [
y(e.$slots, "default")
]),
_: 3
}, 16));
}
}), Os = "dismissableLayer.pointerDownOutside", Is = "dismissableLayer.focusOutside";
function Sn(o, t) {
const e = t.closest(
"[data-dismissable-layer]"
), n = o.querySelector(
"[data-dismissable-layer]"
), s = Array.from(
o.ownerDocument.querySelectorAll("[data-dismissable-layer]")
);
return !!(e && n === e || s.indexOf(n) < s.indexOf(e));
}
function As(o, t) {
var l;
const e = ((l = t == null ? void 0 : t.value) == null ? void 0 : l.ownerDocument) ?? (globalThis == null ? void 0 : globalThis.document), n = B(!1), s = B(() => {
});
return ee((i) => {
if (!Be)
return;
const r = async (d) => {
if (t != null && t.value) {
if (Sn(t.value, d.target)) {
n.value = !1;
return;
}
if (d.target && !n.value) {
let c = function() {
vo(
Os,
o,
p
);
};
const p = { originalEvent: d };
d.pointerType === "touch" ? (e.removeEventListener("click", s.value), s.value = c, e.addEventListener("click", s.value, {
once: !0
})) : c();
} else
e.removeEventListener("click", s.value);
n.value = !1;
}
}, u = window.setTimeout(() => {
e.addEventListener("pointerdown", r);
}, 0);
i(() => {
window.clearTimeout(u), e.removeEventListener("pointerdown", r), e.removeEventListener("click", s.value);
});
}), {
onPointerDownCapture: () => n.value = !0
};
}
function Ms(o, t) {
var s;
const e = ((s = t == null ? void 0 : t.value) == null ? void 0 : s.ownerDocument) ?? (globalThis == null ? void 0 : globalThis.document), n = B(!1);
return ee((l) => {
if (!Be)
return;
const i = async (r) => {
t != null && t.value && (await G(), !Sn(t.value, r.target) && r.target && !n.value && vo(
Is,
o,
{ originalEvent: r }
));
};
e.addEventListener("focusin", i), l(() => e.removeEventListener("focusin", i));
}), {
onFocusCapture: () => n.value = !0,
onBlurCapture: () => n.value = !1
};
}
const he = hn({
layersRoot: /* @__PURE__ */ new Set(),
layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
branches: /* @__PURE__ */ new Set()
}), Se = /* @__PURE__ */ g({
__name: "DismissableLayer",
props: {
disableOutsidePointerEvents: { type: Boolean, default: !1 },
asChild: { type: Boolean },
as: {}
},
emits: ["escapeKeyDown", "pointerDownOutside", "focusOutside", "interactOutside", "dismiss"],
setup(o, { emit: t }) {
const e = o, n = t, { primitiveElement: s, currentElement: l } = V(), i = S(
() => {
var C;
return ((C = l.value) == null ? void 0 : C.ownerDocument) ?? globalThis.document;
}
), r = S(() => he.layersRoot), u = S(() => l.value ? Array.from(r.value).indexOf(l.value) : -1), d = S(() => he.layersWithOutsidePointerEventsDisabled.size > 0), c = S(() => {
const C = Array.from(r.value), [w] = [...he.layersWithOutsidePointerEventsDisabled].slice(-1), $ = C.indexOf(w);
return u.value >= $;
}), p = As(async (C) => {
const w = [...he.branches].some(
($) => $.contains(C.target)
);
!c.value || w || (n("pointerDownOutside", C), n("interactOutside", C), await G(), C.defaultPrevented || n("dismiss"));
}, l), f = Ms((C) => {
[...he.branches].some(
($) => $.contains(C.target)
) || (n("focusOutside", C), n("interactOutside", C), C.defaultPrevented || n("dismiss"));
}, l);
bo("Escape", (C) => {
u.value === r.value.size - 1 && (n("escapeKeyDown", C), C.defaultPrevented || n("dismiss"));
});
let m;
return ee((C) => {
l.value && (e.disableOutsidePointerEvents && (he.layersWithOutsidePointerEventsDisabled.size === 0 && (m = i.value.body.style.pointerEvents, i.value.body.style.pointerEvents = "none"), he.layersWithOutsidePointerEventsDisabled.add(l.value)), r.value.add(l.value), C(() => {
e.disableOutsidePointerEvents && he.layersWithOutsidePointerEventsDisabled.size === 1 && (i.value.body.style.pointerEvents = m);
}));
}), ee((C) => {
C(() => {
l.value && (r.value.delete(l.value), he.layersWithOutsidePointerEventsDisabled.delete(l.value));
});
}), (C, w) => (h(), b(a(D), {
ref_key: "primitiveElement",
ref: s,
"as-child": C.asChild,
as: C.as,
"data-dismissable-layer": "",
style: ae({
pointerEvents: d.value ? c.value ? "auto" : "none" : void 0
}),
onFocusCapture: a(f).onFocusCapture,
onBlurCapture: a(f).onBlurCapture,
onPointerdownCapture: a(p).onPointerDownCapture
}, {
default: v(() => [
y(C.$slots, "default")
]),
_: 3
}, 8, ["as-child", "as", "style", "onFocusCapture", "onBlurCapture", "onPointerdownCapture"]));
}
}), ks = /* @__PURE__ */ g({
__name: "DismissableLayerBranch",
props: {
asChild: { type: Boolean },
as: {}
},
setup(o) {
const t = o, { primitiveElement: e, currentElement: n } = V();
return U(() => {
he.branches.add(n.value);
}), fe(() => {
he.branches.delete(n.value);
}), (s, l) => (h(), b(a(D), T({
ref_key: "primitiveElement",
ref: e
}, t), {
default: v(() => [
y(s.$slots, "default")
]),
_: 3
}, 16));
}
}), eo = "focusScope.autoFocusOnMount", to = "focusScope.autoFocusOnUnmount", nn = { bubbles: !1, cancelable: !0 };
function $t(o, { select: t = !1 } = {}) {
const e = document.activeElement;
for (const n of o)
if (xe(n, { select: t }), document.activeElement !== e)
return !0;
}
function Rs(o) {
const t = $o(o), e = an(t, o), n = an(t.reverse(), o);
return [e, n];
}
function $o(o) {
const t = [], e = document.createTreeWalker(o, NodeFilter.SHOW_ELEMENT, {
acceptNode: (n) => {
const s = n.tagName === "INPUT" && n.type === "hidden";
return n.disabled || n.hidden || s ? NodeFilter.FILTER_SKIP : n.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
}
});
for (; e.nextNode(); )
t.push(e.currentNode);
return t;
}
function an(o, t) {
for (const e of o)
if (!Vs(e, { upTo: t }))
return e;
}
function Vs(o, { upTo: t }) {
if (getComputedStyle(o).visibility === "hidden")
return !0;
for (; o; ) {
if (t !== void 0 && o === t)
return !1;
if (getComputedStyle(o).display === "none")
return !0;
o = o.parentElement;
}
return !1;
}
function Fs(o) {
return o instanceof HTMLInputElement && "select" in o;
}
function xe(o, { select: t = !1 } = {}) {
if (o && o.focus) {
const e = document.activeElement;
o.focus({ preventScroll: !0 }), o !== e && Fs(o) && t && o.select();
}
}
const Ls = Tt(() => B([]));
function Ks() {
const o = Ls();
return {
add(t) {
const e = o.value[0];
t !== e && (e == null || e.pause()), o.value = sn(o.value, t), o.value.unshift(t);
},
remove(t) {
var e;
o.value = sn(o.value, t), (e = o.value[0]) == null || e.resume();
}
};
}
function sn(o, t) {
const e = [...o], n = e.indexOf(t);
return n !== -1 && e.splice(n, 1), e;
}
function Ns(o) {
return o.filter((t) => t.tagName !== "A");
}
const Mt = /* @__PURE__ */ g({
__name: "FocusScope",
props: {
loop: { type: Boolean, default: !1 },
trapped: { type: Boolean, default: !1 },
asChild: { type: Boolean },
as: {}
},
emits: ["mountAutoFocus", "unmountAutoFocus"],
setup(o, { emit: t }) {
const e = o, n = t, { primitiveElement: s, currentElement: l } = V(), i = B(null), r = Ks(), u = hn({
paused: !1,
pause() {
this.paused = !0;
},
resume() {
this.paused = !1;
}
});
ee((c) => {
if (!Be)
return;
const p = l.value;
if (!e.trapped)
return;
function f($) {
if (u.paused || !p)
return;
const _ = $.target;
p.contains(_) ? i.value = _ : xe(i.value, { select: !0 });
}
function m($) {
if (u.paused || !p)
return;
const _ = $.relatedTarget;
_ !== null && (p.contains(_) || xe(i.value, { select: !0 }));
}
function C($) {
p.contains(i.value) || xe(p);
}
document.addEventListener("focusin", f), document.addEventListener("focusout", m);
const w = new MutationObserver(C);
p && w.observe(p, { childList: !0, subtree: !0 }), c(() => {
document.removeEventListener("focusin", f), document.removeEventListener("focusout", m), w.disconnect();
});
}), ee(async (c) => {
const p = l.value;
if (await G(), !p)
return;
r.add(u);
const f = document.activeElement;
if (!p.contains(f)) {
const C = new CustomEvent(eo, nn);
p.addEventListener(
eo,
(w) => n("mountAutoFocus", w)
), p.dispatchEvent(C), C.defaultPrevented || ($t(Ns($o(p)), {
select: !0
}), document.activeElement === f && xe(p));
}
c(() => {
p.removeEventListener(
eo,
($) => n("mountAutoFocus", $)
);
const C = new CustomEvent(to, nn), w = ($) => {
n("unmountAutoFocus", $);
};
p.addEventListener(to, w), p.dispatchEvent(C), setTimeout(() => {
C.defaultPrevented || xe(f ?? document.body, { select: !0 }), p.removeEventListener(to, w), r.remove(u);
}, 0);
});
});
function d(c) {
if (!e.loop && !e.trapped || u.paused)
return;
const p = c.key === "Tab" && !c.altKey && !c.ctrlKey && !c.metaKey, f = document.activeElement;
if (p && f) {
const m = c.currentTarget, [C, w] = Rs(m);
C && w ? !c.shiftKey && f === w ? (c.preventDefault(), e.loop && xe(C, { select: !0 })) : c.shiftKey && f === C && (c.preventDefault(), e.loop && xe(w, { select: !0 })) : f === m && c.preventDefault();
}
}
return (c, p) => (h(), b(a(D), {
ref_key: "primitiveElement",
ref: s,
tabindex: "-1",
"as-child": e.asChild,
as: e.as,
onKeydown: d
}, {
default: v(() => [
y(c.$slots, "default")
]),
_: 3
}, 8, ["as-child", "as"]));
}
}), Hs = "menu.itemSelect", no = ["Enter", " "], Ws = ["ArrowDown", "PageUp", "Home"], Tn = ["ArrowUp", "PageDown", "End"], js = [...Ws, ...Tn], zs = {
ltr: [...no, "ArrowRight"],
rtl: [...no, "ArrowLeft"]
}, Us =