oui-kit
Version:
<div align="center">
1,760 lines • 183 kB
JavaScript
import { ref as x, inject as mn, reactive as Ot, defineComponent as W, useSlots as vn, computed as Y, createElementBlock as C, openBlock as p, normalizeClass as de, renderSlot as z, createTextVNode as Z, toDisplayString as F, createCommentVNode as H, createElementVNode as P, mergeModels as ne, useModel as ae, withDirectives as pe, Fragment as X, mergeProps as oe, vModelCheckbox as Gt, shallowRef as Xn, watch as se, getCurrentScope as Qn, onScopeDispose as Gn, shallowReadonly as Fe, unref as I, useAttrs as Jn, createBlock as G, withModifiers as _e, resolveDynamicComponent as ft, Teleport as Ne, createVNode as ie, Transition as gn, withCtx as J, normalizeStyle as ke, vShow as He, renderList as re, withKeys as Le, vModelText as et, onBeforeUnmount as pt, vModelDynamic as Jt, onUnmounted as Zn, onMounted as Ke, toRefs as eo, createSlots as hn, normalizeProps as to, isRef as no, nextTick as Qe, vModelSelect as Zt, createApp as oo, TransitionGroup as ao, resolveComponent as yn } from "vue";
import { Logger as $e, arrayEmptyInPlace as lo, createArray as so, LoggerContext as io, LoggerMemoryHandler as ro, LogLevelAll as uo, isString as St, isNumber as en, uuid as co, promisify as fo, dayFromString as po, dayToString as mo, dayFromToday as vo, getTimestamp as at, createPromise as go, debounce as ho, parseOrderby as lt, arraySetArrayInPlace as yo, arraySum as wo, isArray as tn, logMessageFromCompact as bo, formatMilliseconds as $o, browserSelectColorByName as _o, Uint8ArrayToHexDump as ko, isPrimitive as Co, isRecord as Ao, arrayRemoveElement as Mo, useDispose as wn, uname as So } from "zeed";
import { onKeyStroke as bn, useEventListener as ge, useElementHover as nn, useFocusWithin as To, useDark as Bo, useToggle as Eo, useDropZone as Lo, useFileDialog as Vo, useLocalStorage as Rt, useElementBounding as on, useResizeObserver as Do, useTextareaAutosize as Oo, useScrollLock as Ro, useWindowSize as Po } from "@vueuse/core";
const $n = $e("directives"), ji = {
mounted: (t, e, ...n) => {
if (e instanceof x)
throw new Error("v-action-toggle requires ref as argument");
t.addEventListener("contextmenu", (a) => {
a.preventDefault(), e.value = !e.value;
}), t.addEventListener("click", (a) => {
e.value = !e.value;
});
}
}, Yi = {
mounted: (t, e) => {
if (e instanceof x)
throw new Error("v-action-ture requires ref as argument");
t.addEventListener("contextmenu", (n) => {
n.preventDefault(), e.value = !0;
}), t.addEventListener("click", (n) => {
e.value = !0;
});
}
}, Xi = {
mounted: (t, e) => {
$n.warn("v-no-selection, use with care! causes issues on draggable!"), t.draggable || t.addEventListener(
"pointermove",
(n) => n.preventDefault()
);
}
}, Qi = {
mounted: (t, e) => {
$n("focus", t), setTimeout(() => t.focus(), 50);
}
};
function Gi(t, e, n = "") {
try {
try {
return new Intl.NumberFormat(void 0, { style: "currency", currency: e }).format(t);
} catch {
}
return `${e} ${t.toFixed(2)}`;
} catch {
return n;
}
}
function Ji(t, e = "") {
try {
try {
return new Intl.NumberFormat(void 0, { style: "percent" }).format(t);
} catch {
}
return `${(t * 100).toFixed(0)} %`;
} catch {
return e;
}
}
function Ge(t, ...e) {
return (mn("t") ?? ((n) => String(n)))(t, ...e);
}
function Zi(t, e, ...n) {
return (mn("t") ?? ((a) => String(t)))(e, ...n);
}
const an = $e("lazy-data");
function er(t) {
const { chunkSize: e = 10, margin: n = 5, onFetch: a, size: o = 0 } = t;
let l = 0, i = 0;
const u = t.data ?? Ot([]);
let r = {}, d = 0, c = 0;
function f() {
l++, lo(u);
const R = so(i);
u.push(...R), r = {};
}
function b(R) {
i = R, f();
}
o > 0 && b(o);
function m(R, k) {
d = R, c = k;
const T = R + k, _ = Math.max(0, R - n), w = Math.min(i, T + n), h = Math.floor(_ / e), A = Math.floor(w / e);
let v = [];
function M() {
if (v.length === 0)
return;
const g = [...v];
v = [];
const s = g[0] * e, y = (g[g.length - 1] - g[0] + 1) * e, S = l;
a(s, y).then((L) => {
if (an("Loaded", s, y, L), l === S) {
g.forEach(
(q) => r[q] = 2
/* Loaded */
);
for (let q = 0; q < y; q++)
u[s + q] = L[q];
}
}).catch((L) => {
an.error("Failed to load chunks", g, L);
});
}
for (let g = h; g <= A; g++)
r[g] == null ? (r[g] = 1, v.push(g)) : M();
M();
}
function $() {
f(), m(d, c);
}
return {
setSize: b,
getSize: () => i,
setVisible: m,
reload: $,
data: u
};
}
function tr(t) {
const e = Ot([]), n = io();
n.setHandlers([
ro({
level: uo,
filter: "*",
messages: e
})
]);
const a = n(t);
return a.messages = e, a;
}
const Io = ["href", "target", "aria-label", "aria-disabled"], No = ["disabled", "aria-label", "aria-disabled"], Pe = /* @__PURE__ */ W({
__name: "oui-button",
props: {
title: {},
mode: { default: "neutral" },
size: { default: "normal" },
dropdown: { type: Boolean, default: !1 },
outline: { type: Boolean, default: !1 },
href: {},
target: { default: "_blank" },
disabled: { type: Boolean, default: !1 }
},
setup(t) {
const e = t, n = vn(), a = Y(() => {
const l = n.default?.();
return !l || l.length === 0 ? "" : l.map((u) => typeof u.children == "string" ? u.children : "").join("");
}), o = Y(() => (e.title || a.value || "").trim());
return (l, i) => l.href && !l.disabled ? (p(), C("a", {
key: 0,
href: l.href,
target: l.target,
class: de(["oui-button", [
l.mode && `_button_mode_${l.mode}`,
l.size && `_button_size_${l.size}`,
l.dropdown && "_button_dropdown"
]]),
role: "button",
"aria-label": o.value,
"aria-disabled": l.disabled
}, [
z(l.$slots, "default", {}, () => [
Z(F(l.title), 1)
])
], 10, Io)) : (p(), C("button", {
key: 1,
disabled: l.disabled ? !0 : void 0,
class: de(["oui-button", [
l.mode && `_button_mode_${l.mode}`,
l.size && `_button_size_${l.size}`,
l.dropdown && "_button_dropdown"
]]),
"aria-label": o.value,
"aria-disabled": l.disabled
}, [
z(l.$slots, "default", {}, () => [
Z(F(l.title), 1)
])
], 10, No));
}
}), xo = { class: "oui-card" }, qo = {
key: 0,
class: "oui-card-header"
}, zo = { class: "oui-card-body" }, Fo = {
key: 1,
class: "oui-card-footer"
}, nr = /* @__PURE__ */ W({
__name: "oui-card",
props: {
title: {}
},
setup(t) {
return (e, n) => (p(), C("div", xo, [
e.$slots.header || e.$slots.title || e.title ? (p(), C("div", qo, [
z(e.$slots, "header", {}, () => [
z(e.$slots, "title", {}, () => [
Z(F(e.title), 1)
])
])
])) : H("", !0),
P("div", zo, [
z(e.$slots, "default")
]),
e.$slots.footer ? (p(), C("div", Fo, [
z(e.$slots, "footer")
])) : H("", !0)
]));
}
}), or = /* @__PURE__ */ W({
inheritAttrs: !1,
__name: "oui-checkbox",
props: /* @__PURE__ */ ne({
title: {},
switch: { type: Boolean, default: !1 },
intermediate: { type: Boolean, default: !1 },
description: {}
}, {
modelValue: { required: !0 },
modelModifiers: {}
}),
emits: ["update:modelValue"],
setup(t) {
const e = t, n = ae(t, "modelValue"), a = Y({
get() {
return !!n.value;
},
set(l) {
n.value = l;
}
}), o = Y(() => {
const l = [e.switch ? "oui-switch" : "oui-checkbox"];
return n.value == null && l.push("_checkbox_intermediate"), l;
});
return (l, i) => l.title || l.$slots.default ? (p(), C(X, { key: 0 }, [
P("label", {
class: de(["oui-form-item-checkbox", { _disabled: l.$attrs.disabled }])
}, [
pe(P("input", oe({
"onUpdate:modelValue": i[0] || (i[0] = (u) => a.value = u),
type: "checkbox",
class: o.value
}, l.$attrs), null, 16), [
[Gt, a.value]
]),
i[2] || (i[2] = Z(" " + F(" ") + " ")),
z(l.$slots, "default", {}, () => [
Z(F(l.title), 1)
])
], 2),
l.$slots.description || l.description ? (p(), C("div", {
key: 0,
class: de(["oui-form-item-description", { _disabled: l.$attrs.disabled }])
}, [
z(l.$slots, "description", {}, () => [
Z(F(l.description), 1)
])
], 2)) : H("", !0)
], 64)) : pe((p(), C("input", oe({
key: 1,
"onUpdate:modelValue": i[1] || (i[1] = (u) => a.value = u),
type: "checkbox",
class: o.value
}, l.$attrs), null, 16)), [
[Gt, a.value]
]);
}
}), Pt = (t, e) => {
const n = t.__vccOpts || t;
for (const [a, o] of e)
n[a] = o;
return n;
}, Uo = {}, Ho = {
xmlns: "http://www.w3.org/2000/svg",
width: "24",
height: "24",
viewBox: "0 0 24 24",
fill: "none",
stroke: "currentColor",
"stroke-width": "2",
"stroke-linecap": "round",
"stroke-linejoin": "round"
};
function Wo(t, e) {
return p(), C("svg", Ho, e[0] || (e[0] = [
P("line", {
x1: "18",
y1: "6",
x2: "6",
y2: "18"
}, null, -1),
P("line", {
x1: "6",
y1: "6",
x2: "18",
y2: "18"
}, null, -1)
]));
}
const mt = /* @__PURE__ */ Pt(Uo, [["render", Wo]]), De = Math.min, ye = Math.max, st = Math.round, nt = Math.floor, Se = (t) => ({
x: t,
y: t
}), Ko = {
left: "right",
right: "left",
bottom: "top",
top: "bottom"
}, jo = {
start: "end",
end: "start"
};
function Tt(t, e, n) {
return ye(t, De(e, n));
}
function Ye(t, e) {
return typeof t == "function" ? t(e) : t;
}
function Oe(t) {
return t.split("-")[0];
}
function Xe(t) {
return t.split("-")[1];
}
function _n(t) {
return t === "x" ? "y" : "x";
}
function It(t) {
return t === "y" ? "height" : "width";
}
const Yo = /* @__PURE__ */ new Set(["top", "bottom"]);
function Ee(t) {
return Yo.has(Oe(t)) ? "y" : "x";
}
function Nt(t) {
return _n(Ee(t));
}
function Xo(t, e, n) {
n === void 0 && (n = !1);
const a = Xe(t), o = Nt(t), l = It(o);
let i = o === "x" ? a === (n ? "end" : "start") ? "right" : "left" : a === "start" ? "bottom" : "top";
return e.reference[l] > e.floating[l] && (i = it(i)), [i, it(i)];
}
function Qo(t) {
const e = it(t);
return [Bt(t), e, Bt(e)];
}
function Bt(t) {
return t.replace(/start|end/g, (e) => jo[e]);
}
const ln = ["left", "right"], sn = ["right", "left"], Go = ["top", "bottom"], Jo = ["bottom", "top"];
function Zo(t, e, n) {
switch (t) {
case "top":
case "bottom":
return n ? e ? sn : ln : e ? ln : sn;
case "left":
case "right":
return e ? Go : Jo;
default:
return [];
}
}
function ea(t, e, n, a) {
const o = Xe(t);
let l = Zo(Oe(t), n === "start", a);
return o && (l = l.map((i) => i + "-" + o), e && (l = l.concat(l.map(Bt)))), l;
}
function it(t) {
return t.replace(/left|right|bottom|top/g, (e) => Ko[e]);
}
function ta(t) {
return {
top: 0,
right: 0,
bottom: 0,
left: 0,
...t
};
}
function kn(t) {
return typeof t != "number" ? ta(t) : {
top: t,
right: t,
bottom: t,
left: t
};
}
function rt(t) {
const {
x: e,
y: n,
width: a,
height: o
} = t;
return {
width: a,
height: o,
top: n,
left: e,
right: e + a,
bottom: n + o,
x: e,
y: n
};
}
function rn(t, e, n) {
let {
reference: a,
floating: o
} = t;
const l = Ee(e), i = Nt(e), u = It(i), r = Oe(e), d = l === "y", c = a.x + a.width / 2 - o.width / 2, f = a.y + a.height / 2 - o.height / 2, b = a[u] / 2 - o[u] / 2;
let m;
switch (r) {
case "top":
m = {
x: c,
y: a.y - o.height
};
break;
case "bottom":
m = {
x: c,
y: a.y + a.height
};
break;
case "right":
m = {
x: a.x + a.width,
y: f
};
break;
case "left":
m = {
x: a.x - o.width,
y: f
};
break;
default:
m = {
x: a.x,
y: a.y
};
}
switch (Xe(e)) {
case "start":
m[i] -= b * (n && d ? -1 : 1);
break;
case "end":
m[i] += b * (n && d ? -1 : 1);
break;
}
return m;
}
const na = async (t, e, n) => {
const {
placement: a = "bottom",
strategy: o = "absolute",
middleware: l = [],
platform: i
} = n, u = l.filter(Boolean), r = await (i.isRTL == null ? void 0 : i.isRTL(e));
let d = await i.getElementRects({
reference: t,
floating: e,
strategy: o
}), {
x: c,
y: f
} = rn(d, a, r), b = a, m = {}, $ = 0;
for (let R = 0; R < u.length; R++) {
const {
name: k,
fn: T
} = u[R], {
x: _,
y: w,
data: h,
reset: A
} = await T({
x: c,
y: f,
initialPlacement: a,
placement: b,
strategy: o,
middlewareData: m,
rects: d,
platform: i,
elements: {
reference: t,
floating: e
}
});
c = _ ?? c, f = w ?? f, m = {
...m,
[k]: {
...m[k],
...h
}
}, A && $ <= 50 && ($++, typeof A == "object" && (A.placement && (b = A.placement), A.rects && (d = A.rects === !0 ? await i.getElementRects({
reference: t,
floating: e,
strategy: o
}) : A.rects), {
x: c,
y: f
} = rn(d, b, r)), R = -1);
}
return {
x: c,
y: f,
placement: b,
strategy: o,
middlewareData: m
};
};
async function xt(t, e) {
var n;
e === void 0 && (e = {});
const {
x: a,
y: o,
platform: l,
rects: i,
elements: u,
strategy: r
} = t, {
boundary: d = "clippingAncestors",
rootBoundary: c = "viewport",
elementContext: f = "floating",
altBoundary: b = !1,
padding: m = 0
} = Ye(e, t), $ = kn(m), k = u[b ? f === "floating" ? "reference" : "floating" : f], T = rt(await l.getClippingRect({
element: (n = await (l.isElement == null ? void 0 : l.isElement(k))) == null || n ? k : k.contextElement || await (l.getDocumentElement == null ? void 0 : l.getDocumentElement(u.floating)),
boundary: d,
rootBoundary: c,
strategy: r
})), _ = f === "floating" ? {
x: a,
y: o,
width: i.floating.width,
height: i.floating.height
} : i.reference, w = await (l.getOffsetParent == null ? void 0 : l.getOffsetParent(u.floating)), h = await (l.isElement == null ? void 0 : l.isElement(w)) ? await (l.getScale == null ? void 0 : l.getScale(w)) || {
x: 1,
y: 1
} : {
x: 1,
y: 1
}, A = rt(l.convertOffsetParentRelativeRectToViewportRelativeRect ? await l.convertOffsetParentRelativeRectToViewportRelativeRect({
elements: u,
rect: _,
offsetParent: w,
strategy: r
}) : _);
return {
top: (T.top - A.top + $.top) / h.y,
bottom: (A.bottom - T.bottom + $.bottom) / h.y,
left: (T.left - A.left + $.left) / h.x,
right: (A.right - T.right + $.right) / h.x
};
}
const oa = (t) => ({
name: "arrow",
options: t,
async fn(e) {
const {
x: n,
y: a,
placement: o,
rects: l,
platform: i,
elements: u,
middlewareData: r
} = e, {
element: d,
padding: c = 0
} = Ye(t, e) || {};
if (d == null)
return {};
const f = kn(c), b = {
x: n,
y: a
}, m = Nt(o), $ = It(m), R = await i.getDimensions(d), k = m === "y", T = k ? "top" : "left", _ = k ? "bottom" : "right", w = k ? "clientHeight" : "clientWidth", h = l.reference[$] + l.reference[m] - b[m] - l.floating[$], A = b[m] - l.reference[m], v = await (i.getOffsetParent == null ? void 0 : i.getOffsetParent(d));
let M = v ? v[w] : 0;
(!M || !await (i.isElement == null ? void 0 : i.isElement(v))) && (M = u.floating[w] || l.floating[$]);
const g = h / 2 - A / 2, s = M / 2 - R[$] / 2 - 1, y = De(f[T], s), S = De(f[_], s), L = y, q = M - R[$] - S, U = M / 2 - R[$] / 2 + g, te = Tt(L, U, q), ce = !r.arrow && Xe(o) != null && U !== te && l.reference[$] / 2 - (U < L ? y : S) - R[$] / 2 < 0, ee = ce ? U < L ? U - L : U - q : 0;
return {
[m]: b[m] + ee,
data: {
[m]: te,
centerOffset: U - te - ee,
...ce && {
alignmentOffset: ee
}
},
reset: ce
};
}
}), aa = function(t) {
return t === void 0 && (t = {}), {
name: "flip",
options: t,
async fn(e) {
var n, a;
const {
placement: o,
middlewareData: l,
rects: i,
initialPlacement: u,
platform: r,
elements: d
} = e, {
mainAxis: c = !0,
crossAxis: f = !0,
fallbackPlacements: b,
fallbackStrategy: m = "bestFit",
fallbackAxisSideDirection: $ = "none",
flipAlignment: R = !0,
...k
} = Ye(t, e);
if ((n = l.arrow) != null && n.alignmentOffset)
return {};
const T = Oe(o), _ = Ee(u), w = Oe(u) === u, h = await (r.isRTL == null ? void 0 : r.isRTL(d.floating)), A = b || (w || !R ? [it(u)] : Qo(u)), v = $ !== "none";
!b && v && A.push(...ea(u, R, $, h));
const M = [u, ...A], g = await xt(e, k), s = [];
let y = ((a = l.flip) == null ? void 0 : a.overflows) || [];
if (c && s.push(g[T]), f) {
const U = Xo(o, i, h);
s.push(g[U[0]], g[U[1]]);
}
if (y = [...y, {
placement: o,
overflows: s
}], !s.every((U) => U <= 0)) {
var S, L;
const U = (((S = l.flip) == null ? void 0 : S.index) || 0) + 1, te = M[U];
if (te && (!(f === "alignment" ? _ !== Ee(te) : !1) || // We leave the current main axis only if every placement on that axis
// overflows the main axis.
y.every((le) => le.overflows[0] > 0 && Ee(le.placement) === _)))
return {
data: {
index: U,
overflows: y
},
reset: {
placement: te
}
};
let ce = (L = y.filter((ee) => ee.overflows[0] <= 0).sort((ee, le) => ee.overflows[1] - le.overflows[1])[0]) == null ? void 0 : L.placement;
if (!ce)
switch (m) {
case "bestFit": {
var q;
const ee = (q = y.filter((le) => {
if (v) {
const me = Ee(le.placement);
return me === _ || // Create a bias to the `y` side axis due to horizontal
// reading directions favoring greater width.
me === "y";
}
return !0;
}).map((le) => [le.placement, le.overflows.filter((me) => me > 0).reduce((me, be) => me + be, 0)]).sort((le, me) => le[1] - me[1])[0]) == null ? void 0 : q[0];
ee && (ce = ee);
break;
}
case "initialPlacement":
ce = u;
break;
}
if (o !== ce)
return {
reset: {
placement: ce
}
};
}
return {};
}
};
}, la = /* @__PURE__ */ new Set(["left", "top"]);
async function sa(t, e) {
const {
placement: n,
platform: a,
elements: o
} = t, l = await (a.isRTL == null ? void 0 : a.isRTL(o.floating)), i = Oe(n), u = Xe(n), r = Ee(n) === "y", d = la.has(i) ? -1 : 1, c = l && r ? -1 : 1, f = Ye(e, t);
let {
mainAxis: b,
crossAxis: m,
alignmentAxis: $
} = typeof f == "number" ? {
mainAxis: f,
crossAxis: 0,
alignmentAxis: null
} : {
mainAxis: f.mainAxis || 0,
crossAxis: f.crossAxis || 0,
alignmentAxis: f.alignmentAxis
};
return u && typeof $ == "number" && (m = u === "end" ? $ * -1 : $), r ? {
x: m * c,
y: b * d
} : {
x: b * d,
y: m * c
};
}
const ia = function(t) {
return t === void 0 && (t = 0), {
name: "offset",
options: t,
async fn(e) {
var n, a;
const {
x: o,
y: l,
placement: i,
middlewareData: u
} = e, r = await sa(e, t);
return i === ((n = u.offset) == null ? void 0 : n.placement) && (a = u.arrow) != null && a.alignmentOffset ? {} : {
x: o + r.x,
y: l + r.y,
data: {
...r,
placement: i
}
};
}
};
}, ra = function(t) {
return t === void 0 && (t = {}), {
name: "shift",
options: t,
async fn(e) {
const {
x: n,
y: a,
placement: o
} = e, {
mainAxis: l = !0,
crossAxis: i = !1,
limiter: u = {
fn: (k) => {
let {
x: T,
y: _
} = k;
return {
x: T,
y: _
};
}
},
...r
} = Ye(t, e), d = {
x: n,
y: a
}, c = await xt(e, r), f = Ee(Oe(o)), b = _n(f);
let m = d[b], $ = d[f];
if (l) {
const k = b === "y" ? "top" : "left", T = b === "y" ? "bottom" : "right", _ = m + c[k], w = m - c[T];
m = Tt(_, m, w);
}
if (i) {
const k = f === "y" ? "top" : "left", T = f === "y" ? "bottom" : "right", _ = $ + c[k], w = $ - c[T];
$ = Tt(_, $, w);
}
const R = u.fn({
...e,
[b]: m,
[f]: $
});
return {
...R,
data: {
x: R.x - n,
y: R.y - a,
enabled: {
[b]: l,
[f]: i
}
}
};
}
};
}, ua = function(t) {
return t === void 0 && (t = {}), {
name: "size",
options: t,
async fn(e) {
var n, a;
const {
placement: o,
rects: l,
platform: i,
elements: u
} = e, {
apply: r = () => {
},
...d
} = Ye(t, e), c = await xt(e, d), f = Oe(o), b = Xe(o), m = Ee(o) === "y", {
width: $,
height: R
} = l.floating;
let k, T;
f === "top" || f === "bottom" ? (k = f, T = b === (await (i.isRTL == null ? void 0 : i.isRTL(u.floating)) ? "start" : "end") ? "left" : "right") : (T = f, k = b === "end" ? "top" : "bottom");
const _ = R - c.top - c.bottom, w = $ - c.left - c.right, h = De(R - c[k], _), A = De($ - c[T], w), v = !e.middlewareData.shift;
let M = h, g = A;
if ((n = e.middlewareData.shift) != null && n.enabled.x && (g = w), (a = e.middlewareData.shift) != null && a.enabled.y && (M = _), v && !b) {
const y = ye(c.left, 0), S = ye(c.right, 0), L = ye(c.top, 0), q = ye(c.bottom, 0);
m ? g = $ - 2 * (y !== 0 || S !== 0 ? y + S : ye(c.left, c.right)) : M = R - 2 * (L !== 0 || q !== 0 ? L + q : ye(c.top, c.bottom));
}
await r({
...e,
availableWidth: g,
availableHeight: M
});
const s = await i.getDimensions(u.floating);
return $ !== s.width || R !== s.height ? {
reset: {
rects: !0
}
} : {};
}
};
};
function vt() {
return typeof window < "u";
}
function qe(t) {
return qt(t) ? (t.nodeName || "").toLowerCase() : "#document";
}
function we(t) {
var e;
return (t == null || (e = t.ownerDocument) == null ? void 0 : e.defaultView) || window;
}
function Be(t) {
var e;
return (e = (qt(t) ? t.ownerDocument : t.document) || window.document) == null ? void 0 : e.documentElement;
}
function qt(t) {
return vt() ? t instanceof Node || t instanceof we(t).Node : !1;
}
function Ce(t) {
return vt() ? t instanceof Element || t instanceof we(t).Element : !1;
}
function Te(t) {
return vt() ? t instanceof HTMLElement || t instanceof we(t).HTMLElement : !1;
}
function un(t) {
return !vt() || typeof ShadowRoot > "u" ? !1 : t instanceof ShadowRoot || t instanceof we(t).ShadowRoot;
}
const ca = /* @__PURE__ */ new Set(["inline", "contents"]);
function tt(t) {
const {
overflow: e,
overflowX: n,
overflowY: a,
display: o
} = Ae(t);
return /auto|scroll|overlay|hidden|clip/.test(e + a + n) && !ca.has(o);
}
const da = /* @__PURE__ */ new Set(["table", "td", "th"]);
function fa(t) {
return da.has(qe(t));
}
const pa = [":popover-open", ":modal"];
function gt(t) {
return pa.some((e) => {
try {
return t.matches(e);
} catch {
return !1;
}
});
}
const ma = ["transform", "translate", "scale", "rotate", "perspective"], va = ["transform", "translate", "scale", "rotate", "perspective", "filter"], ga = ["paint", "layout", "strict", "content"];
function zt(t) {
const e = Ft(), n = Ce(t) ? Ae(t) : t;
return ma.some((a) => n[a] ? n[a] !== "none" : !1) || (n.containerType ? n.containerType !== "normal" : !1) || !e && (n.backdropFilter ? n.backdropFilter !== "none" : !1) || !e && (n.filter ? n.filter !== "none" : !1) || va.some((a) => (n.willChange || "").includes(a)) || ga.some((a) => (n.contain || "").includes(a));
}
function ha(t) {
let e = Re(t);
for (; Te(e) && !je(e); ) {
if (zt(e))
return e;
if (gt(e))
return null;
e = Re(e);
}
return null;
}
function Ft() {
return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
}
const ya = /* @__PURE__ */ new Set(["html", "body", "#document"]);
function je(t) {
return ya.has(qe(t));
}
function Ae(t) {
return we(t).getComputedStyle(t);
}
function ht(t) {
return Ce(t) ? {
scrollLeft: t.scrollLeft,
scrollTop: t.scrollTop
} : {
scrollLeft: t.scrollX,
scrollTop: t.scrollY
};
}
function Re(t) {
if (qe(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.
un(t) && t.host || // Fallback.
Be(t)
);
return un(e) ? e.host : e;
}
function Cn(t) {
const e = Re(t);
return je(e) ? t.ownerDocument ? t.ownerDocument.body : t.body : Te(e) && tt(e) ? e : Cn(e);
}
function Je(t, e, n) {
var a;
e === void 0 && (e = []), n === void 0 && (n = !0);
const o = Cn(t), l = o === ((a = t.ownerDocument) == null ? void 0 : a.body), i = we(o);
if (l) {
const u = Et(i);
return e.concat(i, i.visualViewport || [], tt(o) ? o : [], u && n ? Je(u) : []);
}
return e.concat(o, Je(o, [], n));
}
function Et(t) {
return t.parent && Object.getPrototypeOf(t.parent) ? t.frameElement : null;
}
function An(t) {
const e = Ae(t);
let n = parseFloat(e.width) || 0, a = parseFloat(e.height) || 0;
const o = Te(t), l = o ? t.offsetWidth : n, i = o ? t.offsetHeight : a, u = st(n) !== l || st(a) !== i;
return u && (n = l, a = i), {
width: n,
height: a,
$: u
};
}
function Ut(t) {
return Ce(t) ? t : t.contextElement;
}
function We(t) {
const e = Ut(t);
if (!Te(e))
return Se(1);
const n = e.getBoundingClientRect(), {
width: a,
height: o,
$: l
} = An(e);
let i = (l ? st(n.width) : n.width) / a, u = (l ? st(n.height) : n.height) / o;
return (!i || !Number.isFinite(i)) && (i = 1), (!u || !Number.isFinite(u)) && (u = 1), {
x: i,
y: u
};
}
const wa = /* @__PURE__ */ Se(0);
function Mn(t) {
const e = we(t);
return !Ft() || !e.visualViewport ? wa : {
x: e.visualViewport.offsetLeft,
y: e.visualViewport.offsetTop
};
}
function ba(t, e, n) {
return e === void 0 && (e = !1), !n || e && n !== we(t) ? !1 : e;
}
function xe(t, e, n, a) {
e === void 0 && (e = !1), n === void 0 && (n = !1);
const o = t.getBoundingClientRect(), l = Ut(t);
let i = Se(1);
e && (a ? Ce(a) && (i = We(a)) : i = We(t));
const u = ba(l, n, a) ? Mn(l) : Se(0);
let r = (o.left + u.x) / i.x, d = (o.top + u.y) / i.y, c = o.width / i.x, f = o.height / i.y;
if (l) {
const b = we(l), m = a && Ce(a) ? we(a) : a;
let $ = b, R = Et($);
for (; R && a && m !== $; ) {
const k = We(R), T = R.getBoundingClientRect(), _ = Ae(R), w = T.left + (R.clientLeft + parseFloat(_.paddingLeft)) * k.x, h = T.top + (R.clientTop + parseFloat(_.paddingTop)) * k.y;
r *= k.x, d *= k.y, c *= k.x, f *= k.y, r += w, d += h, $ = we(R), R = Et($);
}
}
return rt({
width: c,
height: f,
x: r,
y: d
});
}
function Ht(t, e) {
const n = ht(t).scrollLeft;
return e ? e.left + n : xe(Be(t)).left + n;
}
function Sn(t, e, n) {
n === void 0 && (n = !1);
const a = t.getBoundingClientRect(), o = a.left + e.scrollLeft - (n ? 0 : (
// RTL <body> scrollbar.
Ht(t, a)
)), l = a.top + e.scrollTop;
return {
x: o,
y: l
};
}
function $a(t) {
let {
elements: e,
rect: n,
offsetParent: a,
strategy: o
} = t;
const l = o === "fixed", i = Be(a), u = e ? gt(e.floating) : !1;
if (a === i || u && l)
return n;
let r = {
scrollLeft: 0,
scrollTop: 0
}, d = Se(1);
const c = Se(0), f = Te(a);
if ((f || !f && !l) && ((qe(a) !== "body" || tt(i)) && (r = ht(a)), Te(a))) {
const m = xe(a);
d = We(a), c.x = m.x + a.clientLeft, c.y = m.y + a.clientTop;
}
const b = i && !f && !l ? Sn(i, r, !0) : Se(0);
return {
width: n.width * d.x,
height: n.height * d.y,
x: n.x * d.x - r.scrollLeft * d.x + c.x + b.x,
y: n.y * d.y - r.scrollTop * d.y + c.y + b.y
};
}
function _a(t) {
return Array.from(t.getClientRects());
}
function ka(t) {
const e = Be(t), n = ht(t), a = t.ownerDocument.body, o = ye(e.scrollWidth, e.clientWidth, a.scrollWidth, a.clientWidth), l = ye(e.scrollHeight, e.clientHeight, a.scrollHeight, a.clientHeight);
let i = -n.scrollLeft + Ht(t);
const u = -n.scrollTop;
return Ae(a).direction === "rtl" && (i += ye(e.clientWidth, a.clientWidth) - o), {
width: o,
height: l,
x: i,
y: u
};
}
function Ca(t, e) {
const n = we(t), a = Be(t), o = n.visualViewport;
let l = a.clientWidth, i = a.clientHeight, u = 0, r = 0;
if (o) {
l = o.width, i = o.height;
const d = Ft();
(!d || d && e === "fixed") && (u = o.offsetLeft, r = o.offsetTop);
}
return {
width: l,
height: i,
x: u,
y: r
};
}
const Aa = /* @__PURE__ */ new Set(["absolute", "fixed"]);
function Ma(t, e) {
const n = xe(t, !0, e === "fixed"), a = n.top + t.clientTop, o = n.left + t.clientLeft, l = Te(t) ? We(t) : Se(1), i = t.clientWidth * l.x, u = t.clientHeight * l.y, r = o * l.x, d = a * l.y;
return {
width: i,
height: u,
x: r,
y: d
};
}
function cn(t, e, n) {
let a;
if (e === "viewport")
a = Ca(t, n);
else if (e === "document")
a = ka(Be(t));
else if (Ce(e))
a = Ma(e, n);
else {
const o = Mn(t);
a = {
x: e.x - o.x,
y: e.y - o.y,
width: e.width,
height: e.height
};
}
return rt(a);
}
function Tn(t, e) {
const n = Re(t);
return n === e || !Ce(n) || je(n) ? !1 : Ae(n).position === "fixed" || Tn(n, e);
}
function Sa(t, e) {
const n = e.get(t);
if (n)
return n;
let a = Je(t, [], !1).filter((u) => Ce(u) && qe(u) !== "body"), o = null;
const l = Ae(t).position === "fixed";
let i = l ? Re(t) : t;
for (; Ce(i) && !je(i); ) {
const u = Ae(i), r = zt(i);
!r && u.position === "fixed" && (o = null), (l ? !r && !o : !r && u.position === "static" && !!o && Aa.has(o.position) || tt(i) && !r && Tn(t, i)) ? a = a.filter((c) => c !== i) : o = u, i = Re(i);
}
return e.set(t, a), a;
}
function Ta(t) {
let {
element: e,
boundary: n,
rootBoundary: a,
strategy: o
} = t;
const i = [...n === "clippingAncestors" ? gt(e) ? [] : Sa(e, this._c) : [].concat(n), a], u = i[0], r = i.reduce((d, c) => {
const f = cn(e, c, o);
return d.top = ye(f.top, d.top), d.right = De(f.right, d.right), d.bottom = De(f.bottom, d.bottom), d.left = ye(f.left, d.left), d;
}, cn(e, u, o));
return {
width: r.right - r.left,
height: r.bottom - r.top,
x: r.left,
y: r.top
};
}
function Ba(t) {
const {
width: e,
height: n
} = An(t);
return {
width: e,
height: n
};
}
function Ea(t, e, n) {
const a = Te(e), o = Be(e), l = n === "fixed", i = xe(t, !0, l, e);
let u = {
scrollLeft: 0,
scrollTop: 0
};
const r = Se(0);
function d() {
r.x = Ht(o);
}
if (a || !a && !l)
if ((qe(e) !== "body" || tt(o)) && (u = ht(e)), a) {
const m = xe(e, !0, l, e);
r.x = m.x + e.clientLeft, r.y = m.y + e.clientTop;
} else o && d();
l && !a && o && d();
const c = o && !a && !l ? Sn(o, u) : Se(0), f = i.left + u.scrollLeft - r.x - c.x, b = i.top + u.scrollTop - r.y - c.y;
return {
x: f,
y: b,
width: i.width,
height: i.height
};
}
function $t(t) {
return Ae(t).position === "static";
}
function dn(t, e) {
if (!Te(t) || Ae(t).position === "fixed")
return null;
if (e)
return e(t);
let n = t.offsetParent;
return Be(t) === n && (n = n.ownerDocument.body), n;
}
function Bn(t, e) {
const n = we(t);
if (gt(t))
return n;
if (!Te(t)) {
let o = Re(t);
for (; o && !je(o); ) {
if (Ce(o) && !$t(o))
return o;
o = Re(o);
}
return n;
}
let a = dn(t, e);
for (; a && fa(a) && $t(a); )
a = dn(a, e);
return a && je(a) && $t(a) && !zt(a) ? n : a || ha(t) || n;
}
const La = async function(t) {
const e = this.getOffsetParent || Bn, n = this.getDimensions, a = await n(t.floating);
return {
reference: Ea(t.reference, await e(t.floating), t.strategy),
floating: {
x: 0,
y: 0,
width: a.width,
height: a.height
}
};
};
function Va(t) {
return Ae(t).direction === "rtl";
}
const Da = {
convertOffsetParentRelativeRectToViewportRelativeRect: $a,
getDocumentElement: Be,
getClippingRect: Ta,
getOffsetParent: Bn,
getElementRects: La,
getClientRects: _a,
getDimensions: Ba,
getScale: We,
isElement: Ce,
isRTL: Va
};
function En(t, e) {
return t.x === e.x && t.y === e.y && t.width === e.width && t.height === e.height;
}
function Oa(t, e) {
let n = null, a;
const o = Be(t);
function l() {
var u;
clearTimeout(a), (u = n) == null || u.disconnect(), n = null;
}
function i(u, r) {
u === void 0 && (u = !1), r === void 0 && (r = 1), l();
const d = t.getBoundingClientRect(), {
left: c,
top: f,
width: b,
height: m
} = d;
if (u || e(), !b || !m)
return;
const $ = nt(f), R = nt(o.clientWidth - (c + b)), k = nt(o.clientHeight - (f + m)), T = nt(c), w = {
rootMargin: -$ + "px " + -R + "px " + -k + "px " + -T + "px",
threshold: ye(0, De(1, r)) || 1
};
let h = !0;
function A(v) {
const M = v[0].intersectionRatio;
if (M !== r) {
if (!h)
return i();
M ? i(!1, M) : a = setTimeout(() => {
i(!1, 1e-7);
}, 1e3);
}
M === 1 && !En(d, t.getBoundingClientRect()) && i(), h = !1;
}
try {
n = new IntersectionObserver(A, {
...w,
// Handle <iframe>s
root: o.ownerDocument
});
} catch {
n = new IntersectionObserver(A, w);
}
n.observe(t);
}
return i(!0), l;
}
function Ra(t, e, n, a) {
a === void 0 && (a = {});
const {
ancestorScroll: o = !0,
ancestorResize: l = !0,
elementResize: i = typeof ResizeObserver == "function",
layoutShift: u = typeof IntersectionObserver == "function",
animationFrame: r = !1
} = a, d = Ut(t), c = o || l ? [...d ? Je(d) : [], ...Je(e)] : [];
c.forEach((T) => {
o && T.addEventListener("scroll", n, {
passive: !0
}), l && T.addEventListener("resize", n);
});
const f = d && u ? Oa(d, n) : null;
let b = -1, m = null;
i && (m = new ResizeObserver((T) => {
let [_] = T;
_ && _.target === d && m && (m.unobserve(e), cancelAnimationFrame(b), b = requestAnimationFrame(() => {
var w;
(w = m) == null || w.observe(e);
})), n();
}), d && !r && m.observe(d), m.observe(e));
let $, R = r ? xe(t) : null;
r && k();
function k() {
const T = xe(t);
R && !En(R, T) && n(), R = T, $ = requestAnimationFrame(k);
}
return n(), () => {
var T;
c.forEach((_) => {
o && _.removeEventListener("scroll", n), l && _.removeEventListener("resize", n);
}), f?.(), (T = m) == null || T.disconnect(), m = null, r && cancelAnimationFrame($);
};
}
const Pa = ia, Ia = ra, Na = aa, xa = ua, qa = oa, za = (t, e, n) => {
const a = /* @__PURE__ */ new Map(), o = {
platform: Da,
...n
}, l = {
...o.platform,
_c: a
};
return na(t, e, {
...o,
platform: l
});
};
function Fa(t) {
return t != null && typeof t == "object" && "$el" in t;
}
function Lt(t) {
if (Fa(t)) {
const e = t.$el;
return qt(e) && qe(e) === "#comment" ? null : e;
}
return t;
}
function Ue(t) {
return typeof t == "function" ? t() : I(t);
}
function Ua(t) {
return {
name: "arrow",
options: t,
fn(e) {
const n = Lt(Ue(t.element));
return n == null ? {} : qa({
element: n,
padding: t.padding
}).fn(e);
}
};
}
function Ln(t) {
return typeof window > "u" ? 1 : (t.ownerDocument.defaultView || window).devicePixelRatio || 1;
}
function fn(t, e) {
const n = Ln(t);
return Math.round(e * n) / n;
}
function Ha(t, e, n) {
n === void 0 && (n = {});
const a = n.whileElementsMounted, o = Y(() => {
var M;
return (M = Ue(n.open)) != null ? M : !0;
}), l = Y(() => Ue(n.middleware)), i = Y(() => {
var M;
return (M = Ue(n.placement)) != null ? M : "bottom";
}), u = Y(() => {
var M;
return (M = Ue(n.strategy)) != null ? M : "absolute";
}), r = Y(() => {
var M;
return (M = Ue(n.transform)) != null ? M : !0;
}), d = Y(() => Lt(t.value)), c = Y(() => Lt(e.value)), f = x(0), b = x(0), m = x(u.value), $ = x(i.value), R = Xn({}), k = x(!1), T = Y(() => {
const M = {
position: m.value,
left: "0",
top: "0"
};
if (!c.value)
return M;
const g = fn(c.value, f.value), s = fn(c.value, b.value);
return r.value ? {
...M,
transform: "translate(" + g + "px, " + s + "px)",
...Ln(c.value) >= 1.5 && {
willChange: "transform"
}
} : {
position: m.value,
left: g + "px",
top: s + "px"
};
});
let _;
function w() {
if (d.value == null || c.value == null)
return;
const M = o.value;
za(d.value, c.value, {
middleware: l.value,
placement: i.value,
strategy: u.value
}).then((g) => {
f.value = g.x, b.value = g.y, m.value = g.strategy, $.value = g.placement, R.value = g.middlewareData, k.value = M !== !1;
});
}
function h() {
typeof _ == "function" && (_(), _ = void 0);
}
function A() {
if (h(), a === void 0) {
w();
return;
}
if (d.value != null && c.value != null) {
_ = a(d.value, c.value, w);
return;
}
}
function v() {
o.value || (k.value = !1);
}
return se([l, i, u, o], w, {
flush: "sync"
}), se([d, c], A, {
flush: "sync"
}), se(o, v, {
flush: "sync"
}), Qn() && Gn(h), {
x: Fe(f),
y: Fe(b),
strategy: Fe(m),
placement: Fe($),
middlewareData: Fe(R),
isPositioned: Fe(k),
floatingStyles: T,
update: w
};
}
const Wa = { class: "_float_inner" }, Wt = /* @__PURE__ */ W({
inheritAttrs: !1,
__name: "oui-float",
props: /* @__PURE__ */ ne({
reference: {},
transition: {},
placement: {},
arrow: { type: Boolean },
offset: { type: [Number, Object, Function] },
padding: {},
close: { type: Boolean },
hover: { type: Boolean },
delayEnter: {},
delayLeave: {}
}, {
modelValue: { type: Boolean },
modelModifiers: {}
}),
emits: /* @__PURE__ */ ne(["close", "dblclick"], ["update:modelValue"]),
setup(t, { emit: e }) {
const n = t, a = e;
vn();
const o = ae(t, "modelValue"), l = x(), i = Y(() => l.value ?? n.reference), u = x(), r = x(), d = Y(() => n.placement ?? "top"), { floatingStyles: c, middlewareData: f, placement: b } = Ha(i, u, {
placement: d,
whileElementsMounted: Ra,
middleware: [
Pa(n.offset ?? 0),
xa(),
Na(),
Ia({
padding: n.padding ?? 16
}),
Ua({
element: r
})
]
});
se(o, (v) => {
v === !1 && a("close");
});
async function m(v) {
n.close && o.value && (v?.preventDefault(), v?.stopPropagation(), o.value = !1);
}
bn("Escape", (v) => m(v)), ge("pointerdown", (v) => {
o.value && u?.value?.contains?.(v.target) !== !0 && i?.value?.contains?.(v.target) !== !0 && (o.value = !1);
}, {
passive: !0
});
const $ = Jn(), R = Y(() => String($.class || "oui-float").split(/\s+/g)?.[0]);
function k(v) {
o.value = !o.value, v.preventDefault();
}
const T = x();
se(T, (v) => {
const M = v?.nextElementSibling;
l.value = M, M?.addEventListener("dblclick", k), M?.addEventListener("click", k), M?.addEventListener("contextmenu", k), v && !M && console.error("#click slot requires at least one element!");
});
const _ = {
delayLeave: n.delayLeave ?? 250,
delayEnter: n.delayEnter ?? 0
}, w = nn(u, _), h = nn(i, _), { focused: A } = To(u);
return se(() => [w.value, h.value, A.value], (v) => {
n.hover && (o.value = !!(w.value || h.value || A.value));
}), (v, M) => (p(), C(X, null, [
v.$slots.click ? (p(), C("div", {
key: 0,
ref_key: "slotReference",
ref: l,
style: { display: "inline-block" },
onClick: M[0] || (M[0] = _e((g) => o.value = !o.value, ["prevent", "stop"])),
onContextmenu: M[1] || (M[1] = _e((g) => o.value = !o.value, ["prevent", "stop"]))
}, [
z(v.$slots, "click", {
active: o.value === !0
})
], 544)) : H("", !0),
v.$slots.trigger ? (p(), G(ft(v.$slots.trigger), {
key: 1,
ref_key: "triggerSlot",
ref: T,
active: o.value === !0
}, null, 8, ["active"])) : H("", !0),
(p(), G(Ne, { to: "body" }, [
ie(gn, {
name: v.transition ?? `${R.value}-transition`
}, {
default: J(() => [
pe(P("div", oe({
ref_key: "floating",
ref: u,
style: I(c),
class: v.$attrs.class || "oui-float"
}, v.$attrs, { class: "_float" }), [
pe(P("div", {
ref_key: "floatingArrow",
ref: r,
class: de(["_float_arrow", `_float_arrow_${I(b)}`]),
style: ke({
position: "absolute",
left: I(f).arrow?.x != null ? `${I(f).arrow.x}px` : "",
top: I(f).arrow?.y != null ? `${I(f).arrow.y}px` : ""
})
}, null, 6), [
[He, v.arrow ?? !1]
]),
P("div", Wa, [
z(v.$slots, "default")
])
], 16), [
[He, o.value]
])
]),
_: 3
}, 8, ["name"])
]))
], 64));
}
}), Ka = {
key: 0,
class: "oui-form-item-title"
}, ja = { key: 0 }, Ya = { class: "oui-form-item-body" }, Xa = {
key: 1,
class: "oui-form-item-description"
}, Me = /* @__PURE__ */ W({
__name: "oui-form-item",
props: {
title: {},
description: {},
required: { type: Boolean },
id: {},
disabled: { type: Boolean }
},
setup(t) {
return (e, n) => e.title != null || e.$slots.description || e.description ? (p(), C("div", {
key: 0,
class: de(["oui-form-item", { _disabled: e.disabled }])
}, [
P("label", null, [
e.title ? (p(), C("div", Ka, [
Z(F(e.title) + " ", 1),
e.required ? (p(), C("span", ja, "*")) : H("", !0)
])) : H("", !0),
P("div", Ya, [
z(e.$slots, "default")
]),
e.$slots.description || e.description ? (p(), C("div", Xa, [
z(e.$slots, "description", {}, () => [
Z(F(e.description), 1)
])
])) : H("", !0)
])
], 2)) : z(e.$slots, "default", { key: 1 });
}
}), Qa = ["data-id", "data-index", "onPointerdown", "onClick", "onKeydown"], Ga = /* @__PURE__ */ W({
__name: "oui-items",
props: /* @__PURE__ */ ne({
items: {}
}, {
modelValue: { required: !0 },
modelModifiers: {}
}),
emits: /* @__PURE__ */ ne(["action"], ["update:modelValue"]),
setup(t, { emit: e }) {
const n = e, a = ae(t, "modelValue"), o = x();
se(a, u, { immediate: !0 });
function l(r) {
a.value = r;
}
function i(r, d) {
n("action", r, d);
}
function u(r = a.value ?? 0) {
const d = o.value?.querySelectorAll(".oui-items-item")[r];
d && d.scrollIntoView({
// behavior: "smooth", // this causes issues on chrome
block: "nearest",
inline: "nearest"
});
}
return (r, d) => (p(), C("div", {
ref_key: "container",
ref: o,
class: "oui-items"
}, [
(p(!0), C(X, null, re(r.items, (c, f) => (p(), C("div", {
key: c.id,
"data-id": c.id,
"data-index": f,
class: de(["oui-items-item", {
"-selected": a.value != null && a.value === f,
"-active": a.value != null && a.value === f,
[c.class]: c.class
}]),
onPointerdown: (b) => l(f),
onClick: (b) => i(c, f),
onKeydown: Le((b) => i(c, f), ["enter"])
}, [
z(r.$slots, "default", {
item: c,
index: f
}, () => [
Z(F(f) + ". " + F(c), 1)
])
], 42, Qa))), 128)),
r.items.length <= 0 ? z(r.$slots, "empty", { key: 0 }, () => [
d[0] || (d[0] = Z(" Empty "))
]) : H("", !0)
], 512));
}
}), Ja = ["id", "placeholder", "disabled"], Za = {
key: 1,
class: "oui-combobox-select-icon"
}, el = { class: "oui-combobox-popover-content" }, tl = { class: "oui-items-item" }, ar = /* @__PURE__ */ W({
inheritAttrs: !1,
__name: "oui-combobox",
props: /* @__PURE__ */ ne({
id: { default: co() },
title: {},
description: {},
required: { type: Boolean },
items: {},
placeholder: { default: "" },
selectIcon: { type: Boolean, default: !1 },
clearable: { type: Boolean, default: !1 },
disabled: { type: Boolean, default: !1 },
formatValue: {},
parseValue: {},
addItemAction: {},
addItemTitle: {},
addItemClass: {},
addItemFooter: { type: Boolean, default: !1 }
}, {
modelValue: { required: !0 },
modelModifiers: {}
}),
emits: /* @__PURE__ */ ne([
"change",
"deleteLast"
], ["update:modelValue"]),
setup(t, { emit: e }) {
const n = t, a = e, o = $e("oui-combobox"), l = ae(t, "modelValue"), i = x(), u = x(), r = x(0), d = x(!1), c = x(!1), f = x(""), b = x(!1), m = Y(() => Object.values(n.items ?? []).map((s) => {
if (St(s) || en(s)) {
const y = n.formatValue?.(s) ?? String(s);
return {
id: String(s),
title: y
};
}
return s;
})), $ = Y(() => {
let s = Object.values(m.value).map((y) => {
if (St(y) || en(y)) {
const S = n.formatValue?.(y) ?? "";
return {
id: y,
title: S
};
}
return y;
});
if (b.value) {
o("filter", f.value);
const y = f.value.trim(), S = y.toLowerCase();
let L = !1;
if (s = s.filter((q) => y ? ((q.title.toLowerCase() === S || n.parseValue && n.parseValue(y) === q.id) && (L = !0), L || (q.search?.toString().toLowerCase() ?? q.title.toString().toLowerCase()).includes(S)) : !0), o("exactMatch", L), y && !L) {
if (n.addItemAction) {
const q = {
action: () => {
n.addItemAction && fo(n.addItemAction(y)).then(
(U) => k(U)
);
},
title: Ge(n.addItemTitle ?? "ui.combobox.addTitle", [y]),
// ??
class: n.addItemClass ?? "oui-combobox-item-add",
skipSelection: s.length > 0
// id: '_create',
};
n.addItemFooter === !0 ? s.push(q) : s.unshift(q);
} else if (n.formatValue && n.parseValue) {
const q = n.parseValue(f.value ?? "");
if (q) {
const U = {
title: n.formatValue(q),
id: q,
class: n.addItemClass ?? "oui-combobox-item-preview"
};
s.unshift(U);
}
}
}
}
return s;
});
function R() {
o("did change value", l.value), n.formatValue ? f.value = n.formatValue(l.value) ?? "" : f.value = m.value.find((s) => s.id === l.value)?.title ?? "";
}
se(l, R, { immediate: !0 });
function k(s) {
o("set modelValue", s), a("change", s), l.value !== s && (l.value = s), R();
}
function T(s, y) {
y?.metaKey || (c.value = !0, r.value = Math.max(0, Math.min($.value.length - 1, r.value + s)), y?.stopPropagation(), y?.preventDefault());
}
function _(s) {
o("doSelectItem", s), s.action ? s.action(f.value) : k(s.id), c.value = !1;
}
function w(s = !0) {
o("doSelect", r.value, $.value[r.value]);
const y = $.value[r.value];
if (!y) {
o("doSelect: no item selected", r.value, $.value), k(void 0);
return;
}
y?.action ? y.action(f.value) : k(y.id), s && (c.value = !1), r.value = 0;
}
function h(s) {
f.value?.length === 0 && (s.preventDefault(), A(), a("deleteLast"));
}
function A() {
c.value = !1;
}
function v() {
c.value = !0, b.value = !0, r.value = $.value?.[0]?.skipSelection ? 1 : 0;
}
function M() {
if (o("blur", d.value, document.activeElement), d.value === !0) {
if (d.value = !1, f.value.trim(