cmd-bar
Version:
Versatile Vue 3 command-bar component
1,836 lines (1,835 loc) • 49.7 kB
JavaScript
import { unref as Z, watch as F, getCurrentScope as Be, onScopeDispose as Ge, reactive as oe, computed as I, ref as O, readonly as Te, defineComponent as z, renderSlot as x, openBlock as S, createElementBlock as E, createElementVNode as R, Fragment as ee, renderList as fe, createVNode as me, mergeProps as Fe, withCtx as U, createCommentVNode as pe, toDisplayString as ge, nextTick as ie, createBlock as Pe, watchEffect as je, onMounted as De, withKeys as We, withModifiers as ze, createTextVNode as Ve, normalizeStyle as He, withDirectives as Qe } from "vue";
function Ue(s) {
return Be() ? (Ge(s), !0) : !1;
}
function L(s) {
return typeof s == "function" ? s() : Z(s);
}
const Ye = typeof window < "u" && typeof document < "u";
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
const Xe = Object.prototype.toString, Je = (s) => Xe.call(s) === "[object Object]", te = () => {
};
function qe(s, e) {
function t(...n) {
return new Promise((r, o) => {
Promise.resolve(s(() => e.apply(this, n), { fn: e, thisArg: this, args: n })).then(r).catch(o);
});
}
return t;
}
function Ze(s, e = {}) {
let t, n, r = te;
const o = (c) => {
clearTimeout(c), r(), r = te;
};
return (c) => {
const l = L(s), d = L(e.maxWait);
return t && o(t), l <= 0 || d !== void 0 && d <= 0 ? (n && (o(n), n = null), Promise.resolve(c())) : new Promise((u, a) => {
r = e.rejectOnCancel ? a : u, d && !n && (n = setTimeout(() => {
t && o(t), n = null, u(c());
}, d)), t = setTimeout(() => {
n && o(n), n = null, u(c());
}, l);
});
};
}
function et(s, e = 200, t = {}) {
return qe(
Ze(e, t),
s
);
}
function tt(s, e, t) {
return F(
s,
(r, o, i) => {
r && e(r, o, i);
},
{
...t,
once: !1
}
);
}
function st(s) {
var e;
const t = L(s);
return (e = t == null ? void 0 : t.$el) != null ? e : t;
}
const Ee = Ye ? window : void 0;
function J(...s) {
let e, t, n, r;
if (typeof s[0] == "string" || Array.isArray(s[0]) ? ([t, n, r] = s, e = Ee) : [e, t, n, r] = s, !e)
return te;
Array.isArray(t) || (t = [t]), Array.isArray(n) || (n = [n]);
const o = [], i = () => {
o.forEach((u) => u()), o.length = 0;
}, c = (u, a, f, h) => (u.addEventListener(a, f, h), () => u.removeEventListener(a, f, h)), l = F(
() => [st(e), L(r)],
([u, a]) => {
if (i(), !u)
return;
const f = Je(a) ? { ...a } : a;
o.push(
...t.flatMap((h) => n.map((m) => c(u, h, m, f)))
);
},
{ immediate: !0, flush: "post" }
), d = () => {
l(), i();
};
return Ue(d), d;
}
const nt = {
ctrl: "control",
command: "meta",
cmd: "meta",
option: "alt",
up: "arrowup",
down: "arrowdown",
left: "arrowleft",
right: "arrowright"
};
function rt(s = {}) {
const {
reactive: e = !1,
target: t = Ee,
aliasMap: n = nt,
passive: r = !0,
onEventFired: o = te
} = s, i = oe(/* @__PURE__ */ new Set()), c = {
toJSON() {
return {};
},
current: i
}, l = e ? oe(c) : c, d = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set();
function a(g, _) {
g in l && (e ? l[g] = _ : l[g].value = _);
}
function f() {
i.clear();
for (const g of u)
a(g, !1);
}
function h(g, _) {
var b, C;
const $ = (b = g.key) == null ? void 0 : b.toLowerCase(), p = [(C = g.code) == null ? void 0 : C.toLowerCase(), $].filter(Boolean);
$ && (_ ? i.add($) : i.delete($));
for (const M of p)
u.add(M), a(M, _);
$ === "meta" && !_ ? (d.forEach((M) => {
i.delete(M), a(M, !1);
}), d.clear()) : typeof g.getModifierState == "function" && g.getModifierState("Meta") && _ && [...i, ...p].forEach((M) => d.add(M));
}
J(t, "keydown", (g) => (h(g, !0), o(g)), { passive: r }), J(t, "keyup", (g) => (h(g, !1), o(g)), { passive: r }), J("blur", f, { passive: !0 }), J("focus", f, { passive: !0 });
const m = new Proxy(
l,
{
get(g, _, b) {
if (typeof _ != "string")
return Reflect.get(g, _, b);
if (_ = _.toLowerCase(), _ in n && (_ = n[_]), !(_ in l))
if (/[+_-]/.test(_)) {
const $ = _.split(/[+_-]/g).map((K) => K.trim());
l[_] = I(() => $.every((K) => L(m[K])));
} else
l[_] = O(!1);
const C = Reflect.get(g, _, b);
return e ? L(C) : C;
}
}
);
return m;
}
function P(s) {
return Array.isArray ? Array.isArray(s) : $e(s) === "[object Array]";
}
const ot = 1 / 0;
function it(s) {
if (typeof s == "string")
return s;
let e = s + "";
return e == "0" && 1 / s == -ot ? "-0" : e;
}
function ct(s) {
return s == null ? "" : it(s);
}
function T(s) {
return typeof s == "string";
}
function Ce(s) {
return typeof s == "number";
}
function at(s) {
return s === !0 || s === !1 || lt(s) && $e(s) == "[object Boolean]";
}
function xe(s) {
return typeof s == "object";
}
function lt(s) {
return xe(s) && s !== null;
}
function A(s) {
return s != null;
}
function re(s) {
return !s.trim().length;
}
function $e(s) {
return s == null ? s === void 0 ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(s);
}
const ut = "Incorrect 'index' type", dt = (s) => `Invalid value for key ${s}`, ht = (s) => `Pattern length exceeds max of ${s}.`, ft = (s) => `Missing ${s} property in key`, mt = (s) => `Property 'weight' in key '${s}' must be a positive integer`, Me = Object.prototype.hasOwnProperty;
class pt {
constructor(e) {
this._keys = [], this._keyMap = {};
let t = 0;
e.forEach((n) => {
let r = Le(n);
t += r.weight, this._keys.push(r), this._keyMap[r.id] = r, t += r.weight;
}), this._keys.forEach((n) => {
n.weight /= t;
});
}
get(e) {
return this._keyMap[e];
}
keys() {
return this._keys;
}
toJSON() {
return JSON.stringify(this._keys);
}
}
function Le(s) {
let e = null, t = null, n = null, r = 1, o = null;
if (T(s) || P(s))
n = s, e = be(s), t = ce(s);
else {
if (!Me.call(s, "name"))
throw new Error(ft("name"));
const i = s.name;
if (n = i, Me.call(s, "weight") && (r = s.weight, r <= 0))
throw new Error(mt(i));
e = be(i), t = ce(i), o = s.getFn;
}
return { path: e, id: t, weight: r, src: n, getFn: o };
}
function be(s) {
return P(s) ? s : s.split(".");
}
function ce(s) {
return P(s) ? s.join(".") : s;
}
function gt(s, e) {
let t = [], n = !1;
const r = (o, i, c) => {
if (A(o))
if (!i[c])
t.push(o);
else {
let l = i[c];
const d = o[l];
if (!A(d))
return;
if (c === i.length - 1 && (T(d) || Ce(d) || at(d)))
t.push(ct(d));
else if (P(d)) {
n = !0;
for (let u = 0, a = d.length; u < a; u += 1)
r(d[u], i, c + 1);
} else
i.length && r(d, i, c + 1);
}
};
return r(s, T(e) ? e.split(".") : e, 0), n ? t : t[0];
}
const yt = {
// Whether the matches should be included in the result set. When `true`, each record in the result
// set will include the indices of the matched characters.
// These can consequently be used for highlighting purposes.
includeMatches: !1,
// When `true`, the matching function will continue to the end of a search pattern even if
// a perfect match has already been located in the string.
findAllMatches: !1,
// Minimum number of characters that must be matched before a result is considered a match
minMatchCharLength: 1
}, vt = {
// When `true`, the algorithm continues searching to the end of the input even if a perfect
// match is found before the end of the same input.
isCaseSensitive: !1,
// When true, the matching function will continue to the end of a search pattern even if
includeScore: !1,
// List of properties that will be searched. This also supports nested properties.
keys: [],
// Whether to sort the result list, by score
shouldSort: !0,
// Default sort function: sort by ascending score, ascending index
sortFn: (s, e) => s.score === e.score ? s.idx < e.idx ? -1 : 1 : s.score < e.score ? -1 : 1
}, _t = {
// Approximately where in the text is the pattern expected to be found?
location: 0,
// At what point does the match algorithm give up. A threshold of '0.0' requires a perfect match
// (of both letters and location), a threshold of '1.0' would match anything.
threshold: 0.6,
// Determines how close the match must be to the fuzzy location (specified above).
// An exact letter match which is 'distance' characters away from the fuzzy location
// would score as a complete mismatch. A distance of '0' requires the match be at
// the exact location specified, a threshold of '1000' would require a perfect match
// to be within 800 characters of the fuzzy location to be found using a 0.8 threshold.
distance: 100
}, Mt = {
// When `true`, it enables the use of unix-like search commands
useExtendedSearch: !1,
// The get function to use when fetching an object's properties.
// The default will search nested paths *ie foo.bar.baz*
getFn: gt,
// When `true`, search will ignore `location` and `distance`, so it won't matter
// where in the string the pattern appears.
// More info: https://fusejs.io/concepts/scoring-theory.html#fuzziness-score
ignoreLocation: !1,
// When `true`, the calculation for the relevance score (used for sorting) will
// ignore the field-length norm.
// More info: https://fusejs.io/concepts/scoring-theory.html#field-length-norm
ignoreFieldNorm: !1,
// The weight to determine how much field length norm effects scoring.
fieldNormWeight: 1
};
var v = {
...vt,
...yt,
..._t,
...Mt
};
const bt = /[^ ]+/g;
function wt(s = 1, e = 3) {
const t = /* @__PURE__ */ new Map(), n = Math.pow(10, e);
return {
get(r) {
const o = r.match(bt).length;
if (t.has(o))
return t.get(o);
const i = 1 / Math.pow(o, 0.5 * s), c = parseFloat(Math.round(i * n) / n);
return t.set(o, c), c;
},
clear() {
t.clear();
}
};
}
class ye {
constructor({
getFn: e = v.getFn,
fieldNormWeight: t = v.fieldNormWeight
} = {}) {
this.norm = wt(t, 3), this.getFn = e, this.isCreated = !1, this.setIndexRecords();
}
setSources(e = []) {
this.docs = e;
}
setIndexRecords(e = []) {
this.records = e;
}
setKeys(e = []) {
this.keys = e, this._keysMap = {}, e.forEach((t, n) => {
this._keysMap[t.id] = n;
});
}
create() {
this.isCreated || !this.docs.length || (this.isCreated = !0, T(this.docs[0]) ? this.docs.forEach((e, t) => {
this._addString(e, t);
}) : this.docs.forEach((e, t) => {
this._addObject(e, t);
}), this.norm.clear());
}
// Adds a doc to the end of the index
add(e) {
const t = this.size();
T(e) ? this._addString(e, t) : this._addObject(e, t);
}
// Removes the doc at the specified index of the index
removeAt(e) {
this.records.splice(e, 1);
for (let t = e, n = this.size(); t < n; t += 1)
this.records[t].i -= 1;
}
getValueForItemAtKeyId(e, t) {
return e[this._keysMap[t]];
}
size() {
return this.records.length;
}
_addString(e, t) {
if (!A(e) || re(e))
return;
let n = {
v: e,
i: t,
n: this.norm.get(e)
};
this.records.push(n);
}
_addObject(e, t) {
let n = { i: t, $: {} };
this.keys.forEach((r, o) => {
let i = r.getFn ? r.getFn(e) : this.getFn(e, r.path);
if (A(i)) {
if (P(i)) {
let c = [];
const l = [{ nestedArrIndex: -1, value: i }];
for (; l.length; ) {
const { nestedArrIndex: d, value: u } = l.pop();
if (A(u))
if (T(u) && !re(u)) {
let a = {
v: u,
i: d,
n: this.norm.get(u)
};
c.push(a);
} else
P(u) && u.forEach((a, f) => {
l.push({
nestedArrIndex: f,
value: a
});
});
}
n.$[o] = c;
} else if (T(i) && !re(i)) {
let c = {
v: i,
n: this.norm.get(i)
};
n.$[o] = c;
}
}
}), this.records.push(n);
}
toJSON() {
return {
keys: this.keys,
records: this.records
};
}
}
function Ie(s, e, { getFn: t = v.getFn, fieldNormWeight: n = v.fieldNormWeight } = {}) {
const r = new ye({ getFn: t, fieldNormWeight: n });
return r.setKeys(s.map(Le)), r.setSources(e), r.create(), r;
}
function kt(s, { getFn: e = v.getFn, fieldNormWeight: t = v.fieldNormWeight } = {}) {
const { keys: n, records: r } = s, o = new ye({ getFn: e, fieldNormWeight: t });
return o.setKeys(n), o.setIndexRecords(r), o;
}
function q(s, {
errors: e = 0,
currentLocation: t = 0,
expectedLocation: n = 0,
distance: r = v.distance,
ignoreLocation: o = v.ignoreLocation
} = {}) {
const i = e / s.length;
if (o)
return i;
const c = Math.abs(n - t);
return r ? i + c / r : c ? 1 : i;
}
function St(s = [], e = v.minMatchCharLength) {
let t = [], n = -1, r = -1, o = 0;
for (let i = s.length; o < i; o += 1) {
let c = s[o];
c && n === -1 ? n = o : !c && n !== -1 && (r = o - 1, r - n + 1 >= e && t.push([n, r]), n = -1);
}
return s[o - 1] && o - n >= e && t.push([n, o - 1]), t;
}
const Q = 32;
function Et(s, e, t, {
location: n = v.location,
distance: r = v.distance,
threshold: o = v.threshold,
findAllMatches: i = v.findAllMatches,
minMatchCharLength: c = v.minMatchCharLength,
includeMatches: l = v.includeMatches,
ignoreLocation: d = v.ignoreLocation
} = {}) {
if (e.length > Q)
throw new Error(ht(Q));
const u = e.length, a = s.length, f = Math.max(0, Math.min(n, a));
let h = o, m = f;
const g = c > 1 || l, _ = g ? Array(a) : [];
let b;
for (; (b = s.indexOf(e, m)) > -1; ) {
let w = q(e, {
currentLocation: b,
expectedLocation: f,
distance: r,
ignoreLocation: d
});
if (h = Math.min(w, h), m = b + u, g) {
let k = 0;
for (; k < u; )
_[b + k] = 1, k += 1;
}
}
m = -1;
let C = [], $ = 1, K = u + a;
const p = 1 << u - 1;
for (let w = 0; w < u; w += 1) {
let k = 0, B = K;
for (; k < B; )
q(e, {
errors: w,
currentLocation: f + B,
expectedLocation: f,
distance: r,
ignoreLocation: d
}) <= h ? k = B : K = B, B = Math.floor((K - k) / 2 + k);
K = B;
let D = Math.max(1, f - B + 1), G = i ? a : Math.min(f + B, a) + u, W = Array(G + 2);
W[G + 1] = (1 << w) - 1;
for (let N = G; N >= D; N -= 1) {
let X = N - 1, _e = t[s.charAt(X)];
if (g && (_[X] = +!!_e), W[N] = (W[N + 1] << 1 | 1) & _e, w && (W[N] |= (C[N + 1] | C[N]) << 1 | 1 | C[N + 1]), W[N] & p && ($ = q(e, {
errors: w,
currentLocation: X,
expectedLocation: f,
distance: r,
ignoreLocation: d
}), $ <= h)) {
if (h = $, m = X, m <= f)
break;
D = Math.max(1, 2 * f - m);
}
}
if (q(e, {
errors: w + 1,
currentLocation: f,
expectedLocation: f,
distance: r,
ignoreLocation: d
}) > h)
break;
C = W;
}
const M = {
isMatch: m >= 0,
// Count exact matches (those with a score of 0) to be "almost" exact
score: Math.max(1e-3, $)
};
if (g) {
const w = St(_, c);
w.length ? l && (M.indices = w) : M.isMatch = !1;
}
return M;
}
function Ct(s) {
let e = {};
for (let t = 0, n = s.length; t < n; t += 1) {
const r = s.charAt(t);
e[r] = (e[r] || 0) | 1 << n - t - 1;
}
return e;
}
class Ae {
constructor(e, {
location: t = v.location,
threshold: n = v.threshold,
distance: r = v.distance,
includeMatches: o = v.includeMatches,
findAllMatches: i = v.findAllMatches,
minMatchCharLength: c = v.minMatchCharLength,
isCaseSensitive: l = v.isCaseSensitive,
ignoreLocation: d = v.ignoreLocation
} = {}) {
if (this.options = {
location: t,
threshold: n,
distance: r,
includeMatches: o,
findAllMatches: i,
minMatchCharLength: c,
isCaseSensitive: l,
ignoreLocation: d
}, this.pattern = l ? e : e.toLowerCase(), this.chunks = [], !this.pattern.length)
return;
const u = (f, h) => {
this.chunks.push({
pattern: f,
alphabet: Ct(f),
startIndex: h
});
}, a = this.pattern.length;
if (a > Q) {
let f = 0;
const h = a % Q, m = a - h;
for (; f < m; )
u(this.pattern.substr(f, Q), f), f += Q;
if (h) {
const g = a - Q;
u(this.pattern.substr(g), g);
}
} else
u(this.pattern, 0);
}
searchIn(e) {
const { isCaseSensitive: t, includeMatches: n } = this.options;
if (t || (e = e.toLowerCase()), this.pattern === e) {
let m = {
isMatch: !0,
score: 0
};
return n && (m.indices = [[0, e.length - 1]]), m;
}
const {
location: r,
distance: o,
threshold: i,
findAllMatches: c,
minMatchCharLength: l,
ignoreLocation: d
} = this.options;
let u = [], a = 0, f = !1;
this.chunks.forEach(({ pattern: m, alphabet: g, startIndex: _ }) => {
const { isMatch: b, score: C, indices: $ } = Et(e, m, g, {
location: r + _,
distance: o,
threshold: i,
findAllMatches: c,
minMatchCharLength: l,
includeMatches: n,
ignoreLocation: d
});
b && (f = !0), a += C, b && $ && (u = [...u, ...$]);
});
let h = {
isMatch: f,
score: f ? a / this.chunks.length : 1
};
return f && n && (h.indices = u), h;
}
}
class V {
constructor(e) {
this.pattern = e;
}
static isMultiMatch(e) {
return we(e, this.multiRegex);
}
static isSingleMatch(e) {
return we(e, this.singleRegex);
}
search() {
}
}
function we(s, e) {
const t = s.match(e);
return t ? t[1] : null;
}
class xt extends V {
constructor(e) {
super(e);
}
static get type() {
return "exact";
}
static get multiRegex() {
return /^="(.*)"$/;
}
static get singleRegex() {
return /^=(.*)$/;
}
search(e) {
const t = e === this.pattern;
return {
isMatch: t,
score: t ? 0 : 1,
indices: [0, this.pattern.length - 1]
};
}
}
class $t extends V {
constructor(e) {
super(e);
}
static get type() {
return "inverse-exact";
}
static get multiRegex() {
return /^!"(.*)"$/;
}
static get singleRegex() {
return /^!(.*)$/;
}
search(e) {
const n = e.indexOf(this.pattern) === -1;
return {
isMatch: n,
score: n ? 0 : 1,
indices: [0, e.length - 1]
};
}
}
class Lt extends V {
constructor(e) {
super(e);
}
static get type() {
return "prefix-exact";
}
static get multiRegex() {
return /^\^"(.*)"$/;
}
static get singleRegex() {
return /^\^(.*)$/;
}
search(e) {
const t = e.startsWith(this.pattern);
return {
isMatch: t,
score: t ? 0 : 1,
indices: [0, this.pattern.length - 1]
};
}
}
class It extends V {
constructor(e) {
super(e);
}
static get type() {
return "inverse-prefix-exact";
}
static get multiRegex() {
return /^!\^"(.*)"$/;
}
static get singleRegex() {
return /^!\^(.*)$/;
}
search(e) {
const t = !e.startsWith(this.pattern);
return {
isMatch: t,
score: t ? 0 : 1,
indices: [0, e.length - 1]
};
}
}
class At extends V {
constructor(e) {
super(e);
}
static get type() {
return "suffix-exact";
}
static get multiRegex() {
return /^"(.*)"\$$/;
}
static get singleRegex() {
return /^(.*)\$$/;
}
search(e) {
const t = e.endsWith(this.pattern);
return {
isMatch: t,
score: t ? 0 : 1,
indices: [e.length - this.pattern.length, e.length - 1]
};
}
}
class Ot extends V {
constructor(e) {
super(e);
}
static get type() {
return "inverse-suffix-exact";
}
static get multiRegex() {
return /^!"(.*)"\$$/;
}
static get singleRegex() {
return /^!(.*)\$$/;
}
search(e) {
const t = !e.endsWith(this.pattern);
return {
isMatch: t,
score: t ? 0 : 1,
indices: [0, e.length - 1]
};
}
}
class Oe extends V {
constructor(e, {
location: t = v.location,
threshold: n = v.threshold,
distance: r = v.distance,
includeMatches: o = v.includeMatches,
findAllMatches: i = v.findAllMatches,
minMatchCharLength: c = v.minMatchCharLength,
isCaseSensitive: l = v.isCaseSensitive,
ignoreLocation: d = v.ignoreLocation
} = {}) {
super(e), this._bitapSearch = new Ae(e, {
location: t,
threshold: n,
distance: r,
includeMatches: o,
findAllMatches: i,
minMatchCharLength: c,
isCaseSensitive: l,
ignoreLocation: d
});
}
static get type() {
return "fuzzy";
}
static get multiRegex() {
return /^"(.*)"$/;
}
static get singleRegex() {
return /^(.*)$/;
}
search(e) {
return this._bitapSearch.searchIn(e);
}
}
class Re extends V {
constructor(e) {
super(e);
}
static get type() {
return "include";
}
static get multiRegex() {
return /^'"(.*)"$/;
}
static get singleRegex() {
return /^'(.*)$/;
}
search(e) {
let t = 0, n;
const r = [], o = this.pattern.length;
for (; (n = e.indexOf(this.pattern, t)) > -1; )
t = n + o, r.push([n, t - 1]);
const i = !!r.length;
return {
isMatch: i,
score: i ? 0 : 1,
indices: r
};
}
}
const ae = [
xt,
Re,
Lt,
It,
Ot,
At,
$t,
Oe
], ke = ae.length, Rt = / +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/, Kt = "|";
function Nt(s, e = {}) {
return s.split(Kt).map((t) => {
let n = t.trim().split(Rt).filter((o) => o && !!o.trim()), r = [];
for (let o = 0, i = n.length; o < i; o += 1) {
const c = n[o];
let l = !1, d = -1;
for (; !l && ++d < ke; ) {
const u = ae[d];
let a = u.isMultiMatch(c);
a && (r.push(new u(a, e)), l = !0);
}
if (!l)
for (d = -1; ++d < ke; ) {
const u = ae[d];
let a = u.isSingleMatch(c);
if (a) {
r.push(new u(a, e));
break;
}
}
}
return r;
});
}
const Bt = /* @__PURE__ */ new Set([Oe.type, Re.type]);
class Gt {
constructor(e, {
isCaseSensitive: t = v.isCaseSensitive,
includeMatches: n = v.includeMatches,
minMatchCharLength: r = v.minMatchCharLength,
ignoreLocation: o = v.ignoreLocation,
findAllMatches: i = v.findAllMatches,
location: c = v.location,
threshold: l = v.threshold,
distance: d = v.distance
} = {}) {
this.query = null, this.options = {
isCaseSensitive: t,
includeMatches: n,
minMatchCharLength: r,
findAllMatches: i,
ignoreLocation: o,
location: c,
threshold: l,
distance: d
}, this.pattern = t ? e : e.toLowerCase(), this.query = Nt(this.pattern, this.options);
}
static condition(e, t) {
return t.useExtendedSearch;
}
searchIn(e) {
const t = this.query;
if (!t)
return {
isMatch: !1,
score: 1
};
const { includeMatches: n, isCaseSensitive: r } = this.options;
e = r ? e : e.toLowerCase();
let o = 0, i = [], c = 0;
for (let l = 0, d = t.length; l < d; l += 1) {
const u = t[l];
i.length = 0, o = 0;
for (let a = 0, f = u.length; a < f; a += 1) {
const h = u[a], { isMatch: m, indices: g, score: _ } = h.search(e);
if (m) {
if (o += 1, c += _, n) {
const b = h.constructor.type;
Bt.has(b) ? i = [...i, ...g] : i.push(g);
}
} else {
c = 0, o = 0, i.length = 0;
break;
}
}
if (o) {
let a = {
isMatch: !0,
score: c / o
};
return n && (a.indices = i), a;
}
}
return {
isMatch: !1,
score: 1
};
}
}
const le = [];
function Tt(...s) {
le.push(...s);
}
function ue(s, e) {
for (let t = 0, n = le.length; t < n; t += 1) {
let r = le[t];
if (r.condition(s, e))
return new r(s, e);
}
return new Ae(s, e);
}
const se = {
AND: "$and",
OR: "$or"
}, de = {
PATH: "$path",
PATTERN: "$val"
}, he = (s) => !!(s[se.AND] || s[se.OR]), Ft = (s) => !!s[de.PATH], Pt = (s) => !P(s) && xe(s) && !he(s), Se = (s) => ({
[se.AND]: Object.keys(s).map((e) => ({
[e]: s[e]
}))
});
function Ke(s, e, { auto: t = !0 } = {}) {
const n = (r) => {
let o = Object.keys(r);
const i = Ft(r);
if (!i && o.length > 1 && !he(r))
return n(Se(r));
if (Pt(r)) {
const l = i ? r[de.PATH] : o[0], d = i ? r[de.PATTERN] : r[l];
if (!T(d))
throw new Error(dt(l));
const u = {
keyId: ce(l),
pattern: d
};
return t && (u.searcher = ue(d, e)), u;
}
let c = {
children: [],
operator: o[0]
};
return o.forEach((l) => {
const d = r[l];
P(d) && d.forEach((u) => {
c.children.push(n(u));
});
}), c;
};
return he(s) || (s = Se(s)), n(s);
}
function jt(s, { ignoreFieldNorm: e = v.ignoreFieldNorm }) {
s.forEach((t) => {
let n = 1;
t.matches.forEach(({ key: r, norm: o, score: i }) => {
const c = r ? r.weight : null;
n *= Math.pow(
i === 0 && c ? Number.EPSILON : i,
(c || 1) * (e ? 1 : o)
);
}), t.score = n;
});
}
function Dt(s, e) {
const t = s.matches;
e.matches = [], A(t) && t.forEach((n) => {
if (!A(n.indices) || !n.indices.length)
return;
const { indices: r, value: o } = n;
let i = {
indices: r,
value: o
};
n.key && (i.key = n.key.src), n.idx > -1 && (i.refIndex = n.idx), e.matches.push(i);
});
}
function Wt(s, e) {
e.score = s.score;
}
function zt(s, e, {
includeMatches: t = v.includeMatches,
includeScore: n = v.includeScore
} = {}) {
const r = [];
return t && r.push(Dt), n && r.push(Wt), s.map((o) => {
const { idx: i } = o, c = {
item: e[i],
refIndex: i
};
return r.length && r.forEach((l) => {
l(o, c);
}), c;
});
}
class Y {
constructor(e, t = {}, n) {
this.options = { ...v, ...t }, this.options.useExtendedSearch, this._keyStore = new pt(this.options.keys), this.setCollection(e, n);
}
setCollection(e, t) {
if (this._docs = e, t && !(t instanceof ye))
throw new Error(ut);
this._myIndex = t || Ie(this.options.keys, this._docs, {
getFn: this.options.getFn,
fieldNormWeight: this.options.fieldNormWeight
});
}
add(e) {
A(e) && (this._docs.push(e), this._myIndex.add(e));
}
remove(e = () => !1) {
const t = [];
for (let n = 0, r = this._docs.length; n < r; n += 1) {
const o = this._docs[n];
e(o, n) && (this.removeAt(n), n -= 1, r -= 1, t.push(o));
}
return t;
}
removeAt(e) {
this._docs.splice(e, 1), this._myIndex.removeAt(e);
}
getIndex() {
return this._myIndex;
}
search(e, { limit: t = -1 } = {}) {
const {
includeMatches: n,
includeScore: r,
shouldSort: o,
sortFn: i,
ignoreFieldNorm: c
} = this.options;
let l = T(e) ? T(this._docs[0]) ? this._searchStringList(e) : this._searchObjectList(e) : this._searchLogical(e);
return jt(l, { ignoreFieldNorm: c }), o && l.sort(i), Ce(t) && t > -1 && (l = l.slice(0, t)), zt(l, this._docs, {
includeMatches: n,
includeScore: r
});
}
_searchStringList(e) {
const t = ue(e, this.options), { records: n } = this._myIndex, r = [];
return n.forEach(({ v: o, i, n: c }) => {
if (!A(o))
return;
const { isMatch: l, score: d, indices: u } = t.searchIn(o);
l && r.push({
item: o,
idx: i,
matches: [{ score: d, value: o, norm: c, indices: u }]
});
}), r;
}
_searchLogical(e) {
const t = Ke(e, this.options), n = (c, l, d) => {
if (!c.children) {
const { keyId: a, searcher: f } = c, h = this._findMatches({
key: this._keyStore.get(a),
value: this._myIndex.getValueForItemAtKeyId(l, a),
searcher: f
});
return h && h.length ? [
{
idx: d,
item: l,
matches: h
}
] : [];
}
const u = [];
for (let a = 0, f = c.children.length; a < f; a += 1) {
const h = c.children[a], m = n(h, l, d);
if (m.length)
u.push(...m);
else if (c.operator === se.AND)
return [];
}
return u;
}, r = this._myIndex.records, o = {}, i = [];
return r.forEach(({ $: c, i: l }) => {
if (A(c)) {
let d = n(t, c, l);
d.length && (o[l] || (o[l] = { idx: l, item: c, matches: [] }, i.push(o[l])), d.forEach(({ matches: u }) => {
o[l].matches.push(...u);
}));
}
}), i;
}
_searchObjectList(e) {
const t = ue(e, this.options), { keys: n, records: r } = this._myIndex, o = [];
return r.forEach(({ $: i, i: c }) => {
if (!A(i))
return;
let l = [];
n.forEach((d, u) => {
l.push(
...this._findMatches({
key: d,
value: i[u],
searcher: t
})
);
}), l.length && o.push({
idx: c,
item: i,
matches: l
});
}), o;
}
_findMatches({ key: e, value: t, searcher: n }) {
if (!A(t))
return [];
let r = [];
if (P(t))
t.forEach(({ v: o, i, n: c }) => {
if (!A(o))
return;
const { isMatch: l, score: d, indices: u } = n.searchIn(o);
l && r.push({
score: d,
key: e,
value: o,
idx: i,
norm: c,
indices: u
});
});
else {
const { v: o, n: i } = t, { isMatch: c, score: l, indices: d } = n.searchIn(o);
c && r.push({ score: l, key: e, value: o, norm: i, indices: d });
}
return r;
}
}
Y.version = "6.6.2";
Y.createIndex = Ie;
Y.parseIndex = kt;
Y.config = v;
Y.parseQuery = Ke;
Tt(Gt);
function Vt(s, e, t) {
const n = () => {
var i, c;
return new Y(
(i = L(e)) != null ? i : [],
(c = L(t)) == null ? void 0 : c.fuseOptions
);
}, r = O(n());
F(
() => {
var i;
return (i = L(t)) == null ? void 0 : i.fuseOptions;
},
() => {
r.value = n();
},
{ deep: !0 }
), F(
() => L(e),
(i) => {
r.value.setCollection(i);
},
{ deep: !0 }
);
const o = I(() => {
const i = L(t);
if (i != null && i.matchAllWhenSearchEmpty && !L(s))
return L(e).map((l, d) => ({ item: l, refIndex: d }));
const c = i == null ? void 0 : i.resultLimit;
return r.value.search(L(s), c ? { limit: c } : void 0);
});
return {
fuse: r,
results: o
};
}
function Ht(s, e) {
return s.find((t) => t.key === e);
}
function Qt(s) {
return { all: s = s || /* @__PURE__ */ new Map(), on: function(e, t) {
var n = s.get(e);
n ? n.push(t) : s.set(e, [t]);
}, off: function(e, t) {
var n = s.get(e);
n && (t ? n.splice(n.indexOf(t) >>> 0, 1) : s.set(e, []));
}, emit: function(e, t) {
var n = s.get(e);
n && n.slice().map(function(r) {
r(t);
}), (n = s.get("*")) && n.slice().map(function(r) {
r(e, t);
});
} };
}
const Ut = Qt(), ve = () => ({
emitter: Ut
}), y = oe({
commands: [],
groups: [],
query: "",
isLoading: !1,
results: [],
fuseOptions: null,
selectedCommandKey: null,
selectedGroups: /* @__PURE__ */ new Set(),
loop: !1
});
function j() {
const { emitter: s } = ve();
function e(p) {
y.groups = p.filter((M) => M.visible !== !1), y.commands = y.groups.flatMap(
(M) => {
var w;
return ((w = M.commands) == null ? void 0 : w.map((k) => ({
...k,
group: M.key
}))) ?? [];
}
), f();
}
function t() {
y.query = "", y.isLoading = !1, y.results = [], y.selectedCommandKey = null, y.selectedGroups.clear(), f();
}
function n(p) {
y.loop = p;
}
async function r(p, M) {
y.selectedGroups.has(p) ? y.selectedGroups.delete(p) : (M || y.selectedGroups.clear(), y.selectedGroups.add(p)), s.emit("filterChange", Array.from(y.selectedGroups)), y.query !== "" ? await m(y.query) : y.results = [], f();
}
const o = I(() => y.query !== "" && y.results.length === 0), i = I(() => y.query !== "" && y.results.length > 0), c = I(() => i.value ? y.results.filter(
(p) => y.selectedGroups.size === 0 || y.selectedGroups.has(null) || y.selectedGroups.has(p.group ?? null)
) : o.value ? [] : y.selectedGroups.size === 0 || y.selectedGroups.has(null) ? y.commands : y.commands.filter((p) => y.selectedGroups.has(p.group ?? null))), l = I(() => c.value.findIndex((p) => p.key === y.selectedCommandKey));
function d(p) {
const w = c.value.find((k) => k.key === p);
w ? (y.selectedCommandKey = p, s.emit("selected", w)) : (console.warn(`Command with key ${p} not found in displayed commands`), f());
}
function u() {
const p = c.value;
if (p.length === 0) {
f();
return;
}
const M = l.value + 1;
M < p.length ? d(p[M].key) : y.loop && d(p[0].key);
}
function a() {
const p = c.value;
if (p.length === 0) {
f();
return;
}
const M = l.value - 1;
M >= 0 ? d(p[M].key) : y.loop && d(p[p.length - 1].key);
}
function f() {
const p = c.value;
p.length > 0 ? d(p[0].key) : (y.selectedCommandKey = null, s.emit("selected", null));
}
function h() {
var M;
const p = Ht(y.commands, y.selectedCommandKey);
p && (s.emit("executed", p), (M = p.action) == null || M.call(p));
}
async function m(p, M) {
await _(p, M);
}
function g() {
y.query = "", y.results = [], f();
}
const _ = et(
async (p, M) => {
if (y.isLoading = !0, M && (y.fuseOptions = M), y.query = p, p === "") {
y.results = [], f();
return;
}
y.results = await b(p), f(), y.isLoading = !1;
},
200
);
async function b(p) {
const M = K(y.groups), w = M.filter((G) => !!G.search), k = await $(p, w);
let D = M.filter((G) => !G.search).flatMap(
(G) => (G.commands ?? []).map((W) => ({ ...W, group: G.key }))
);
return Array.isArray(k) && k.length > 0 && (D = D.concat(k)), C(p, D);
}
function C(p, M) {
const { results: w } = Vt(p, O(M), y.fuseOptions ?? {});
return w.value.map((k) => k.item);
}
async function $(p, M) {
return M.length ? (await Promise.all(
M.map(async (k) => (await k.search(p)).map((D) => ({
...D,
group: k.key
})))
)).flat() : [];
}
function K(p) {
return y.selectedGroups.has(null) ? p : p.filter((M) => y.selectedGroups.has(M.key));
}
return {
state: Te(y),
initState: e,
resetState: t,
setLoop: n,
toggleGroup: r,
selectCommand: d,
nextCommand: u,
prevCommand: a,
executeCommand: h,
updateQuery: m,
clearQuery: g,
displayedCommands: c,
resultsEmpty: o
};
}
const ks = /* @__PURE__ */ z({
__name: "CmdBar",
props: {
commands: {}
},
setup(s, { expose: e }) {
const { initState: t, resetState: n } = j();
return F(
() => s.commands,
() => {
t(s.commands);
},
{ deep: !0, immediate: !0 }
), e({
resetState: n
}), (r, o) => x(r.$slots, "default");
}
}), Yt = { class: "input-container" }, Xt = {
class: "input__leading",
"aria-hidden": "true"
}, Jt = ["value", "placeholder", "aria-label"], qt = { class: "input__clear" }, Ss = /* @__PURE__ */ z({
__name: "CmdBarInput",
props: {
modelValue: { default: void 0 },
placeholder: { default: "Search for anything" },
fuse: { default: () => ({}) },
nonTriggerKeys: { default: () => ["@", "/"] },
threshold: { default: 0 }
},
emits: ["update:modelValue"],
setup(s, { emit: e }) {
const t = s, n = e, { state: r, updateQuery: o, clearQuery: i } = j(), c = O(t.modelValue ?? r.query), l = I({
get: () => t.modelValue ?? c.value,
set: (h) => {
c.value = h, t.modelValue !== void 0 && n("update:modelValue", h);
}
});
F(
() => t.modelValue,
(h) => {
h !== void 0 && h !== c.value && (c.value = h, h.length >= t.threshold ? o(h, d.value) : i());
}
);
const d = I(() => {
var h, m, g, _, b, C;
return {
fuseOptions: {
...(h = t.fuse) == null ? void 0 : h.fuseOptions,
keys: ((g = (m = t.fuse) == null ? void 0 : m.fuseOptions) == null ? void 0 : g.keys) ?? ["label"],
minMatchCharLength: ((b = (_ = t.fuse) == null ? void 0 : _.fuseOptions) == null ? void 0 : b.minMatchCharLength) ?? 0
},
resultLimit: ((C = t.fuse) == null ? void 0 : C.resultLimit) ?? 12
};
}), { emitter: u } = ve();
function a(h) {
var g, _;
const m = (g = h.target) == null ? void 0 : g.value;
if ((_ = t.nonTriggerKeys) != null && _.includes(m)) {
u.emit("input", m);
return;
}
m != null && (l.value = m, m.length >= t.threshold ? o(m, d.value) : i()), u.emit("input", m);
}
function f() {
i(), l.value = "", n("update:modelValue", "");
}
return (h, m) => (S(), E("div", Yt, [
R("span", Xt, [
x(h.$slots, "leading")
]),
R("input", {
"data-cmd-bar-input": "",
class: "input",
autofocus: "",
autocomplete: "off",
"aria-autocomplete": "list",
role: "combobox",
value: l.value,
placeholder: h.placeholder,
"aria-label": h.placeholder,
onInput: a
}, null, 40, Jt),
R("div", qt, [
R("button", {
"aria-label": "Close",
tabindex: "-1",
onClick: f
}, [
x(h.$slots, "clear")
])
])
]));
}
}), Zt = ["data-id", "aria-selected", "onMouseenter"], Ne = /* @__PURE__ */ z({
__name: "CmdBarItems",
props: {
commands: {}
},
setup(s) {
const { state: e, selectCommand: t, executeCommand: n } = j(), r = (o) => e.selectedCommandKey === o.key;
return (o, i) => (S(!0), E(ee, null, fe(o.commands, (c, l) => (S(), E("li", {
key: `${c.key}-${l}`,
"data-id": c.key,
role: "option",
class: "item",
"aria-selected": r(c),
onMouseenter: (d) => Z(t)(c.key),
onClick: i[0] || (i[0] = (d) => Z(n)())
}, [
x(o.$slots, "default", { command: c })
], 40, Zt))), 128));
}
}), es = { class: "group-container" }, ts = {
key: 0,
"data-cmd-bar-items": "",
class: "items"
}, ss = /* @__PURE__ */ z({
__name: "CmdBarGroup",
props: {
group: {}
},
emits: ["selected", "clicked"],
setup(s) {
return (e, t) => (S(), E("div", es, [
e.group.commands ? (S(), E("ul", ts, [
me(Ne, Fe(e.$attrs, {
commands: e.group.commands
}), {
default: U(({ command: n }) => [
x(e.$slots, "default", { command: n })
]),
_: 3
}, 16, ["commands"])
])) : pe("", !0)
]));
}
}), ns = {
key: 0,
class: "no-results"
}, rs = {
key: 1,
"data-cmd-bar-items": "",
class: "results"
}, os = { key: 0 }, is = {
key: 1,
class: "group"
}, cs = {
key: 0,
class: "group__label"
}, as = {
"data-cmd-bar-items": "",
class: "items"
}, ls = /* @__PURE__ */ z({
__name: "CmdBarResults",
props: {
resultsHeader: {}
},
setup(s) {
const { state: e, resultsEmpty: t } = j(), n = I(() => e.results), r = I(() => e.isLoading), o = I(() => t.value && !r.value);
return (i, c) => o.value ? (S(), E("div", ns, [
x(i.$slots, "no-results")
])) : (S(), E("ul", rs, [
r.value ? (S(), E("li", os, [
x(i.$slots, "loading")
])) : (S(), E("li", is, [
i.resultsHeader ? (S(), E("h2", cs, ge(i.resultsHeader), 1)) : pe("", !0),
R("ul", as, [
me(Ne, { commands: n.value }, {
default: U(({ command: l }) => [
x(i.$slots, "default", { command: l })
]),
_: 3
}, 8, ["commands"])
])
]))
]));
}
}), us = {
key: 1,
"data-cmd-bar-items": "",
class: "list-items"
}, ds = {
key: 0,
class: "group__label"
}, Es = /* @__PURE__ */ z({
__name: "CmdBarList",
props: {
loop: { type: Boolean, default: !1 },
resultsHeader: { default: "Results" }
},
setup(s) {
const { state: e, setLoop: t, resultsEmpty: n } = j();
t(s.loop ?? !1);
const r = O(null), o = O(null), i = I(() => {
const u = e.selectedGroups, a = e.groups;
return u.has(null) ? a : a.filter((f) => u.has(f.key));
}), c = I(() => e.query.length > 0), l = () => {
var f, h, m, g;
const u = e.selectedCommandKey, a = (f = o.value) == null ? void 0 : f.querySelector(`[data-id="${u}"]`);
if (((h = a == null ? void 0 : a.parentElement) == null ? void 0 : h.firstElementChild) === a) {
(g = (m = a == null ? void 0 : a.closest(".group")) == null ? void 0 : m.querySelector(".group__label")) == null || g.scrollIntoView({ block: "nearest" });
return;
}
a == null || a.scrollIntoView({ block: "nearest" });
}, { emitter: d } = ve();
return d.on("selected", (u) => {
r.value = u;
}), F(
() => e.selectedCommandKey,
(u) => {
u && ie(l);
}
), (u, a) => (S(), E(ee, null, [
R("div", {
ref_key: "listRef",
ref: o,
class: "grouped-list",
tabindex: "-1"
}, [
c.value ? (S(), Pe(ls, {
key: 0,
"results-header": u.resultsHeader
}, {
loading: U(() => [
x(u.$slots, "loading", {}, () => [
a[0] || (a[0] = R("div", { class: "loading-animation" }, "Loading...", -1))
])
]),
"no-results": U(() => [
x(u.$slots, "no-results", {}, () => [
a[1] || (a[1] = R("div", null, "Nothing found", -1))
])
]),
default: U(({ command: f }) => [
x(u.$slots, "results", { command: f }, () => [
x(u.$slots, "default", { command: f })
])
]),
_: 3
}, 8, ["results-header"])) : (S(), E("ul", us, [
(S(!0), E(ee, null, fe(i.value, (f) => {
var h;
return S(), E("li", {
key: f.key,
class: "group"
}, [
f.label && ((h = f.commands) != null && h.length) ? (S(), E("h2", ds, ge(f.label), 1)) : pe("", !0),
me(ss, { group: f }, {
default: U(({ command: m }) => [
x(u.$slots, "default", { command: m })
]),
_: 2
}, 1032, ["group"])
]);
}), 128))
]))
], 512),
x(u.$slots, "preview", { activeCommand: r.value })
], 64));
}
}), hs = { class: "filter" }, fs = {
class: "filter-list",
role: "tablist"
}, ms = ["data-id", "aria-selected", "onClick"], Cs = /* @__PURE__ */ z({
__name: "CmdBarFilter",
props: {
filterOptions: {},
asCheckbox: { type: Boolean, default: !1 }
},
setup(s) {
const { lineStyle: e, setLineStyle: t } = f(), { state: n, toggleGroup: r } = j(), o = I(() => n.selectedGroups), i = O(/* @__PURE__ */ new Set()), c = O([]), l = O(null);
function d() {
s.filterOptions.forEach((h, m) => {
if (!h.visible) {
c.value.push(h);
return;
}
i.value.add(h), m === 0 && (l.value = h);
});
}
d(), je(() => {
l.value && o.value.size === 0 && a(l.value.groupKey);
});
function u(h) {
var m;
return !o.value.size && ((m = l.value) == null ? void 0 : m.groupKey) === h ? !0 : o.value.has(h);
}
function a(h) {
r(h, s.asCheckbox), t();
}
function f() {
const h = O({
transform: "translateX(0)",
width: "0"
});
async function m() {
await ie(() => {
const _ = document.querySelector('.filter-chip[aria-selected="true"]');
if (!_)
return;
const b = _.clientWidth, C = _.offsetLeft;
h.value = {
transform: `translateX(${C}px)`,
width: `${b}px`
};
});
}
function g() {
const _ = new ResizeObserver(() => {
m();
});
ie(() => {
const b = document.querySelector(".filter");
b && _.observe(b);
});
}
return De(() => {
g();
}), { lineStyle: h, setLineStyle: m };
}
return (h, m) => (S(), E("div", hs, [
R("div", fs, [
(S(!0), E(ee, null, fe(Array.from(i.value), (g) => (S(), E("button", {
key: g.groupKey ?? "default",
"data-id": g.groupKey,
class: "filter-chip",
"aria-selected": u(g.groupKey),
role: "tab",
tabindex: "0",
onKeydown: m[0] || (m[0] = We(ze(() => {
}, ["prevent"]), ["enter"])),
onClick: (_) => a(g.groupKey)
}, [
x(h.$slots, "default", {
group: g,
isSelected: u(g.groupKey)
}, () => [
Ve(ge(g.label), 1)
])
], 40, ms))), 128)),
x(h.$slots, "option", { hiddenOptions: c.value })
]),
R("div", {
style: He(Z(e)),
class: "filter-line"
}, null, 4)
]));
}
}), H = O([]), ne = O(!1);
function ps() {
const s = rt();
return { registerKeyBinding: (r) => {
const { key: o, action: i, autoRepeat: c = !1 } = r;
if (o.includes("+")) {
const l = s[o];
l && !H.value.some((d) => d.key === o) && tt(l, () => {
ne.value && i();
});
} else
H.value.some((l) => l.key === o) || H.value.push({ key: o, action: i, autoRepeat: c });
}, handleKeydown: (r) => {
const o = H.value.find((i) => i.key === r.key);
if (o && ne.value && o.action) {
if (!o.autoRepeat && r.repeat)
return;
o.action();
}
}, removeKeyBinding: (r) => {
const o = H.value.findIndex((i) => i.key === r);
o !== -1 && H.value.splice(o, 1);
}, singleKeyShortcuts: H };
}
function gs(s) {
const { nextCommand: e, prevCommand: t, executeCommand: n } = j(), r = {
next: () => e(),
prev: () => t(),
execute: () => n()
}, { registerKeyBinding: o, handleKeydown: i } = ps();
s(r).forEach((f) => {
f.key && o(f);
});
const { state: l } = j(), d = () => {
l.commands.forEach((f) => {
if (f.shortcut) {
const h = f.action, m = {
key: f.shortcut,
action: h
};
o(m);
}
});
}, u = () => {
ne.value = !0, window.addEventListener("keydown", i);
}, a = () => {
ne.value = !1, window.removeEventListener("keydown", i);
};
return d(), {
addEventListener: u,
removeEventListener: a
};
}
const ys = {
"data-cmd-bar-wrapper": "",
class: "cmd-bar__wrapper"
}, vs = {
"data-cmd-bar-header": "",
class: "cmd-bar__header"
}, _s = {
"data-cmd-bar-content": "",
class: "cmd-bar__body"
}, Ms = {
"data-cmd-bar-footer": "",
class: "cmd-bar__footer"
}, xs = /* @__PURE__ */ z({
__name: "CmdBarDialog",
props: {
visible: { type: Boolean, default: !1 }
},
emits: ["update:visible"],
setup(s, { emit: e }) {
const t = e, n = O(null), { addEventListener: r, removeEventListener: o } = gs((a) => [
{
key: "ArrowUp",
action: () => a.prev(),
autoRepeat: !0
},
{
key: "ArrowDown",
action: () => a.next(),
autoRepeat: !0
},
{
key: "Enter",
action: () => a.execute(),
autoRepeat: !0
}
]);
function i() {
var a;
(a = n.value) == null || a.close();
}
const c = {
mounted(a, f) {
a.__ClickOutsideHandler__ = (h) => {
a === h.target || a.contains(h.target) || f.value(h, a);
}, document.body.addEventListener("click", a.__ClickOutsideHandler__);
},
unmounted(a) {
document.body.removeEventListener("click", a.__ClickOutsideHandler__);
}
}, { resetState: l } = j();
function d() {
t("update:visible", !0), r();
}
function u() {
t("update:visible", !1), o(), l();
}
return F(n, (a) => {
a && (a.addEventListener("close", u), a.addEventListener("show", d));
}), F(
() => s.visible,
(a) => {
var f, h;
a ? (r(), (f = n.value) == null || f.showModal()) : ((h = n.value) == null || h.close(), o());
}
), (a, f) => (S(), E("dialog", {
ref_key: "dialogRef",
ref: n,
"data-cmd-bar": "",
class: "cmd-bar",
tabindex: "-1"
}, [
Qe((S(), E("div", ys, [
R("div", vs, [
x(a.$slots, "header")
]),
R("div", _s, [
x(a.$slots, "content")
]),
R("div", Ms, [
x(a.$slots, "footer")
])
])), [
[c, i]
])
], 512));
}
});
function $s(s) {
return s;
}
export {
ks as CmdBar,
xs as CmdBarDialog,
Cs as CmdBarFilter,
Ss as CmdBarInput,
Es as CmdBarList,
$s as defineCommand,
ve as useCmdBarEvent,
gs as useKeymap
};