maz-ui
Version:
A standalone components library for Vue.Js 3 & Nuxt.Js 3
1,914 lines • 107 kB
JavaScript
import '../assets/index.B3s7AfaL.css';var $t = Object.defineProperty;
var Vt = (s, e, t) => e in s ? $t(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
var c = (s, e, t) => Vt(s, typeof e != "symbol" ? e + "" : e, t);
import { inject as rt, ref as b, onMounted as ce, onUnmounted as at, computed as h, toValue as ge, nextTick as le, getCurrentInstance as Ht, watch as G, provide as Bt, useId as Nt, onBeforeUnmount as lt, createVNode as ee, render as Ie, defineComponent as be, defineAsyncComponent as H, reactive as Ft, openBlock as A, createElementBlock as U, withModifiers as Z, withKeys as jt, unref as O, createCommentVNode as B, createElementVNode as V, normalizeClass as ue, withDirectives as ut, vShow as ct, createBlock as N, Teleport as qt, Transition as dt, withCtx as q, mergeProps as te, renderSlot as R, useAttrs as Ut, useSlots as Wt, createTextVNode as J, toDisplayString as X, Fragment as Ze, renderList as Rt, resolveDynamicComponent as _t, normalizeStyle as Kt } from "vue";
function Pe(s, e) {
const t = rt(s, e);
if (!t)
throw new TypeError(`[maz-ui](injectStrict) Could not resolve ${s.toString()}`);
return t;
}
function Wn() {
return Pe("aos");
}
function Yt(s) {
const e = {};
for (const [t, n] of Object.entries(s))
e[t] = Number.parseInt(n, 10);
return e;
}
function F() {
return typeof document < "u";
}
function Zt(s = {}) {
const {
internalWindow: e = F() ? window : void 0,
initialWidth: t = Number.POSITIVE_INFINITY,
initialHeight: n = Number.POSITIVE_INFINITY,
includeScrollbar: o = !0
} = s, i = b(t), r = b(n);
function a() {
e && (o ? (i.value = e.innerWidth, r.value = e.innerHeight) : (i.value = e.document.documentElement.clientWidth, r.value = e.document.documentElement.clientHeight));
}
return a(), ce(() => {
e && window.addEventListener("resize", a, { passive: !0 });
}), at(() => {
e && window.removeEventListener("resize", a);
}), { width: i, height: r };
}
function Rn({
initialWidth: s = 0,
initialHeight: e,
includeScrollbar: t,
internalWindow: n,
listenOrientation: o,
breakpoints: i,
mediumBreakPoint: r = "md",
largeBreakPoint: a = "lg"
}) {
const { width: l } = Zt({
initialWidth: s,
// (SSR) mobile first
initialHeight: e,
includeScrollbar: t,
internalWindow: n,
listenOrientation: o
}), u = Yt(i), y = h(() => l.value >= u[a]), T = h(
() => l.value >= u[r] && l.value < u[a]
), w = h(() => l.value >= 0 && l.value < u[r]);
return {
width: l,
numericBreakpoints: u,
isSmallScreen: w,
isLargeScreen: y,
isMediumScreen: T,
breakpoints: i
};
}
function _n() {
return Pe("dialog");
}
function mt(s, e, t) {
const n = {
maxAttempts: 20,
interval: 100,
...t
};
let o = 0;
function i() {
const r = s();
r != null ? n.expectedValue !== void 0 && r !== n.expectedValue ? o < n.maxAttempts ? (o++, setTimeout(i, n.interval)) : console.warn(n.errorMessage || `[maz-ui](checkAvailability) Nothing found after ${n.maxAttempts} attempts for ref ${r}`) : e(r) : o < n.maxAttempts ? (o++, setTimeout(i, n.interval)) : console.warn(n.errorMessage || `[maz-ui](checkAvailability) Nothing found or expected value after ${n.maxAttempts} attempts for ref ${r}`);
}
i();
}
function ft(s) {
const e = ge(s);
return Array.isArray(e) ? Object.freeze([...e]) : typeof e == "object" && e !== null ? Object.freeze({ ...e }) : e;
}
function Xe(s) {
return s == null || typeof s == "string" || typeof s == "number" || typeof s == "boolean" || typeof s == "symbol" || typeof s == "bigint";
}
function Xt(s, e) {
if (s.length !== e.length)
return !1;
for (const [t, n] of s.entries())
if (!we(n, e[t]))
return !1;
return !0;
}
function Gt(s, e) {
const t = Object.keys(s), n = Object.keys(e);
if (t.length !== n.length)
return !1;
for (const o of t)
if (!n.includes(o) || !we(s[o], e[o]))
return !1;
return !0;
}
function we(s, e) {
return Xe(s) || Xe(e) ? s === e : s instanceof Date && e instanceof Date ? s.getTime() === e.getTime() : typeof s != typeof e || Array.isArray(s) !== Array.isArray(e) ? !1 : Array.isArray(s) && Array.isArray(e) ? Xt(s, e) : typeof s == "object" && typeof e == "object" ? Gt(s, e) : !1;
}
function Qt(s, e, t) {
const n = {};
return function(...o) {
n[s] || (n[s] = { timer: null, promise: null });
const i = n[s];
return i.timer && clearTimeout(i.timer), i.promise = new Promise((r, a) => {
i.timer = setTimeout(async () => {
try {
r(await e(...o));
} catch (l) {
a(l);
} finally {
delete n[s];
}
}, t);
}), i.promise;
};
}
function Jt(s, e, t) {
const n = {};
return async (...o) => {
const i = Date.now();
return n[s] || (n[s] = { promise: null, lastCall: 0, lastArgs: [] }), i - n[s].lastCall >= t ? (n[s].lastCall = i, e(...o)) : (n[s].lastArgs = o, n[s].promise || (n[s].promise = new Promise((r) => {
setTimeout(
async () => {
n[s].lastCall = Date.now();
const a = await e(...n[s].lastArgs);
n[s].promise = null, r(a);
},
t - (i - n[s].lastCall)
);
})), n[s].promise);
};
}
const se = {
mode: "lazy",
scrollToErrorSelector: ".has-field-error",
debounceTime: 300,
throttleTime: 1e3
};
function ht(s, e) {
return Object.keys(e).includes(s);
}
function Ge(s = se.scrollToErrorSelector) {
const e = document.querySelector(s);
e && e.scrollIntoView({ behavior: "smooth", block: "center" });
}
function es(s, e) {
const t = {};
for (const [n, o] of Object.entries(s)) {
const i = o;
t[n] = e[n].error && i[0] ? i[0].message : void 0;
}
return t;
}
function Re(s) {
return s == null || s === "";
}
function ts({
name: s,
hasValidation: e,
debouncedFields: t,
throttledFields: n
}) {
if (!e)
return;
const o = String(s);
if (t != null && t[o] && (n != null && n[o]))
throw new Error(`The field "${o}" cannot be both debounced and throttled`);
return t != null && t[o] ? Qt(
o,
ye,
typeof t[o] == "number" ? t[o] : se.debounceTime
) : n != null && n[o] ? Jt(
o,
ye,
typeof n[o] == "number" ? n[o] : se.throttleTime
) : ye;
}
function vt({
name: s,
schema: e,
initialValue: t,
fieldState: n,
options: o
}) {
const i = e ? ht(s, e) : !1, r = ts({
name: s,
hasValidation: i,
debouncedFields: o == null ? void 0 : o.debouncedFields,
throttledFields: o == null ? void 0 : o.throttledFields
});
return {
blurred: !1,
dirty: !1,
errors: [],
error: !1,
valid: !i,
validating: !1,
validated: !1,
initialValue: ft(t),
validateFunction: r,
mode: i ? (o == null ? void 0 : o.mode) ?? (n == null ? void 0 : n.mode) ?? se.mode : void 0
};
}
function ss({
schema: s,
payload: e,
options: t
}) {
const n = {};
for (const o in s) {
const i = o;
n[i] = vt({
name: i,
schema: s,
options: t,
fieldState: n[i],
initialValue: e == null ? void 0 : e[i]
});
}
return n;
}
function ns({
fieldsStates: s,
payload: e,
schema: t,
options: n,
updateMode: o = !1
}) {
for (const i in t) {
const r = i;
s[r] = pt({
name: r,
fieldState: s[r],
payload: e,
schema: t,
options: n,
updateMode: o
});
}
}
function pt({
name: s,
fieldState: e,
payload: t,
schema: n,
options: o,
updateMode: i = !0
}) {
const { initialValue: r, mode: a, ...l } = vt({
name: s,
schema: n,
initialValue: o.defaultValue ?? t[s],
fieldState: e,
options: o
}), u = i ? a ?? e.mode ?? se.mode : e.mode;
return {
...e,
initialValue: r,
mode: u,
...e != null && e.mode && u !== e.mode ? l : {}
};
}
function os(s) {
const e = {};
for (const [t, { errors: n }] of Object.entries(s))
e[t] = n;
return e;
}
function is(s) {
return s instanceof HTMLInputElement || s instanceof HTMLSelectElement || s instanceof HTMLTextAreaElement ? [s] : s.querySelectorAll(
"input, select, textarea"
);
}
function rs({
interactiveElements: s,
onBlur: e,
mode: t
}) {
s.forEach((n) => {
Ee(["eager", "blur", "progressive"], t) && n.addEventListener("blur", e);
});
}
function as({
interactiveElements: s,
onBlur: e
}) {
s.forEach((t) => {
t.removeEventListener("blur", e);
});
}
async function ls(s, e, t) {
const n = await hs(e), i = await (await bt("safeParseAsync"))(n.entries[s], t ?? "");
return {
result: i,
isValid: i.success
};
}
async function ye({
name: s,
fieldState: e,
schema: t,
payload: n,
setError: o = !0,
setErrorIfInvalidAndNotEmpty: i = !1
}) {
if (await le(), e.validating = !0, !t[s]) {
e.valid = !0, e.validating = !1, e.validated = !0, e.errors = [], e.error = !1;
return;
}
const { result: r, isValid: a } = await ls(s, t, n[s]);
e.valid = a, (o || i && !a && !Re(n[s])) && (e.error = !a), e.errors = r.issues ?? [], e.validating = !1, e.validated = !0;
}
function gt({
name: s,
fieldState: e,
payload: t,
schema: n
}) {
var i;
const o = {
name: s,
fieldState: e,
payload: t,
schema: n,
setError: e.mode === "progressive" ? e.valid || e.blurred : !0
};
return (i = e.validateFunction) == null ? void 0 : i.call(e, o);
}
function us({
fieldsStates: s,
payload: e,
showErrors: t = !0,
schema: n
}) {
return Promise.all(
Object.keys(s).map(
(o) => ye({
name: o,
setError: t,
fieldState: s[o],
payload: e,
schema: n,
setErrorIfInvalidAndNotEmpty: s[o].mode === "lazy"
})
)
);
}
function yt({
eventName: s,
fieldState: e,
isSubmitted: t
}) {
const { dirty: n, blurred: o, mode: i, valid: r } = e;
return s === "blur" && (Ee(["lazy", "aggressive"], i) || r) || s === "input" && i === "blur" || !i ? !1 : t || i === "eager" && o || i === "blur" && o || i === "aggressive" && n || i === "lazy" && n || i === "progressive";
}
function cs({
name: s,
force: e = !1,
payload: t,
fieldState: n,
schema: o,
isSubmitted: i
}) {
const r = t[s], a = !Re(r) && !we(r, n.initialValue);
if (n.dirty = a, n.blurred = n.blurred || (n.mode === "eager" ? a : !0), !!(e || yt({ eventName: "blur", fieldState: n, isSubmitted: i })))
return gt({
name: s,
fieldState: n,
schema: o,
payload: t
});
}
function ds({
name: s,
payload: e,
fieldState: t,
schema: n,
isSubmitted: o,
forceValidation: i = !1
}) {
const r = e[s];
t.validated = !1;
const a = !Re(r) && !we(r, t.initialValue);
if (t.dirty = a, !!(i || yt({ eventName: "input", fieldState: t, isSubmitted: o })))
return gt({
name: s,
fieldState: t,
schema: n,
payload: e
});
}
function _e(s) {
const e = Ht();
if (!e)
throw new Error(`${s} must be called within setup()`);
return e;
}
function ms(s, e) {
var o;
const n = ((o = _e(e).formContexts) == null ? void 0 : o.get(s)) ?? rt(s);
if (!n)
throw new Error("useFormField must be used within a form (useFormValidator)");
return n;
}
function fs({
ref: s,
fieldState: e,
onBlur: t
}) {
if (!(s || Ee(["aggressive", "lazy"], e.mode)))
return {
onBlur: t
};
}
const Ne = {};
async function bt(s) {
if (Ne[s])
return Ne[s];
const e = await import("./index.BgyjI1q8.mjs");
return Ne[s] = e[s], e[s];
}
async function hs(s) {
return (await bt("objectAsync"))(s);
}
function Ee(s, e) {
return e ? s.includes(e) : !1;
}
function Kn(s, e) {
const t = {
formIdentifier: "main-form-validator",
...e
}, {
fieldsStates: n,
payload: o,
options: i,
internalSchema: r,
errorMessages: a,
isSubmitted: l
} = ms(t.formIdentifier, "useFormField"), u = ht(s, r.value) ? (e == null ? void 0 : e.mode) ?? i.mode : void 0;
t.mode = u;
const y = h(() => n.value[s]);
if (n.value[s] = pt({
name: s,
fieldState: y.value,
payload: o.value,
schema: r.value,
options: { ...i, ...t }
}), t.defaultValue !== void 0 && !we(o.value[s], t.defaultValue)) {
const f = t.defaultValue;
o.value[s] = f, n.value[s].initialValue = ft(f);
}
u && ye({
name: s,
fieldState: y.value,
payload: o.value,
schema: r.value,
setError: u === "aggressive",
setErrorIfInvalidAndNotEmpty: u === "lazy"
});
function T() {
cs({
name: s,
fieldState: y.value,
payload: o.value,
schema: r.value,
isSubmitted: l.value
});
}
const w = h(
() => fs({
ref: t.ref,
onBlur: T,
fieldState: y.value
})
);
if (t.ref && Ee(["eager", "blur", "progressive"], u)) {
let f = [];
const k = (z) => {
f = is(z), rs({
interactiveElements: f,
onBlur: T,
mode: u
});
};
ce(() => {
const z = _e(`useFormField of ${s}`);
mt(() => z.refs[t.ref], (m) => {
const d = m instanceof HTMLElement ? m : m == null ? void 0 : m.$el;
d && k(d);
}, {
errorMessage: `[maz-ui](useFormField) No element found for ref ${t.ref} for field ${s}`
});
}), at(() => {
as({
interactiveElements: f,
onBlur: T
});
});
}
return {
hasError: h(() => y.value.error),
errors: h(() => y.value.errors),
errorMessage: h(() => a.value[s]),
isValid: h(() => y.value.valid),
isDirty: h(() => y.value.dirty),
isBlurred: h(() => y.value.blurred),
isValidated: h(() => y.value.validated),
isValidating: h(() => y.value.validating),
mode: h(() => y.value.mode),
value: h({
get: () => o.value[s],
set: (f) => o.value[s] = f
}),
validationEvents: w,
onBlur: T
};
}
function Yn({ schema: s, defaultValues: e, model: t, options: n }) {
const o = _e("useFormValidator"), i = {
mode: se.mode,
scrollToError: se.scrollToErrorSelector,
debouncedFields: null,
throttledFields: null,
identifier: "main-form-validator",
...n
}, r = b(e), a = b({ ...r.value, ...t == null ? void 0 : t.value }), l = b(s), u = b(
ss({
schema: l.value,
payload: a.value,
options: i
})
), y = b(!1), T = b(!1), w = h(() => Object.values(u.value).every(({ valid: L }) => L)), f = h(() => Object.values(u.value).some(({ dirty: L }) => L)), k = h(() => os(u.value)), z = h(() => es(k.value, u.value));
t && G(
a,
(L) => {
t.value = { ...r.value, ...L };
},
{ deep: !0 }
), G(
r,
(L) => {
a.value = { ...L, ...a.value };
},
{ deep: !0 }
), G(
l,
(L) => {
ns({
schema: L,
fieldsStates: u.value,
payload: a.value,
options: i
}), m();
},
{ deep: !0 }
), m();
function m(L = i.mode === "aggressive") {
return us({
fieldsStates: u.value,
payload: a.value,
schema: l.value,
showErrors: L
});
}
const d = [];
async function C(L) {
await le();
const P = G(
() => a.value[L],
() => {
const j = u.value[L];
ds({
name: L,
fieldState: j,
payload: a.value,
schema: l.value,
isSubmitted: T.value,
forceValidation: Ee(["aggressive", "lazy", "progressive"], j.mode)
});
},
{ deep: typeof l.value[L] == "object" }
);
d.push(P);
}
function p() {
for (const L of d)
L();
for (const L of Object.keys(l.value))
C(L);
}
function S(L, P) {
return async (j) => {
if (j == null || j.preventDefault(), !y.value) {
T.value = !0, y.value = !0;
try {
await m(!0);
const ne = typeof P == "string" ? P : i.scrollToError;
let Q;
return w.value ? Q = await L(a.value) : typeof ne != "boolean" && Ge(ne), y.value = !1, Q;
} finally {
y.value = !1;
}
}
};
}
const D = {
fieldsStates: u,
payload: a,
options: i,
internalSchema: l,
errorMessages: z,
isSubmitted: T
};
return o.formContexts ?? (o.formContexts = /* @__PURE__ */ new Map()), o.formContexts.set(i.identifier, D), Bt(i.identifier, D), p(), {
identifier: i.identifier,
isDirty: f,
isSubmitting: y,
isSubmitted: T,
isValid: w,
errors: k,
model: a,
fieldsStates: u,
validateForm: m,
scrollToError: Ge,
handleSubmit: S,
errorMessages: z
};
}
class vs {
constructor(e, t) {
c(this, "defaultOptions", {
element: void 0,
timeout: 60 * 1e3 * 5,
// 5 minutes
once: !1,
immediate: !0
});
c(this, "options");
c(this, "timeoutHandler");
c(this, "isIdle", !1);
c(this, "isDestroy", !1);
c(this, "startTime", 0);
c(this, "remainingTime", 0);
c(this, "lastClientX", -1);
c(this, "lastClientY", -1);
c(this, "eventNames", [
"DOMMouseScroll",
"mousedown",
"mousemove",
"mousewheel",
"MSPointerDown",
"MSPointerMove",
"keydown",
"touchmove",
"touchstart",
"wheel",
"click"
]);
c(this, "handleEvent", (e) => {
try {
if (this.remainingTime > 0)
return;
if (e.type === "mousemove") {
const { clientX: t, clientY: n } = e;
if (t === void 0 && n === void 0 || t === this.lastClientX && n === this.lastClientY)
return;
this.lastClientX = t, this.lastClientY = n;
}
this.resetTimeout(), this.callback({ isIdle: this.isIdle, eventType: e.type, instance: this });
} catch (t) {
throw new Error(`[IdleTimeout](handleEvent) ${t}`);
}
});
this.callback = e, this.options = {
...this.defaultOptions,
...t
}, F() && this.start();
}
get element() {
return this.options.element ?? document.body;
}
start() {
if (!F()) {
console.warn("[IdleTimeout](start) you should run this method on client side");
return;
}
for (const e of this.eventNames)
this.element.addEventListener(e, this.handleEvent);
this.resetTimeout(), this.options.immediate && this.callback({ isIdle: !1, instance: this });
}
pause() {
const e = this.startTime + this.options.timeout - Date.now();
e <= 0 || (this.remainingTime = e, this.timeoutHandler && (clearTimeout(this.timeoutHandler), this.timeoutHandler = void 0));
}
resume() {
this.remainingTime <= 0 || (this.resetTimeout(), this.callback({ isIdle: this.isIdle, instance: this }), this.remainingTime = 0);
}
reset() {
this.isDestroy = !1, this.isIdle = !1, this.remainingTime = 0, this.resetTimeout(), this.callback({ isIdle: this.isIdle, instance: this });
}
destroy() {
if (!F()) {
console.warn("[IdleTimeout](destroy) you should run this method on client side");
return;
}
this.isDestroy = !0;
for (const e of this.eventNames)
this.element.removeEventListener(e, this.handleEvent);
this.timeoutHandler && clearTimeout(this.timeoutHandler);
}
resetTimeout() {
this.isIdle = !1, this.timeoutHandler && (clearTimeout(this.timeoutHandler), this.timeoutHandler = void 0), this.timeoutHandler = setTimeout(
this.handleTimeout.bind(this),
this.remainingTime || this.options.timeout
), this.startTime = Date.now();
}
handleTimeout() {
this.isIdle = !0, this.callback({ isIdle: this.isIdle, instance: this }), this.options.once && this.destroy();
}
get destroyed() {
return this.isDestroy;
}
get timeout() {
return this.options.timeout;
}
set timeout(e) {
this.options.timeout = e;
}
get idle() {
return this.isIdle;
}
set idle(e) {
e ? this.handleTimeout() : this.reset(), this.callback({ isIdle: this.isIdle, instance: this });
}
}
function Zn({
callback: s,
options: e
}) {
return new vs(s, e);
}
function Xn({
componentName: s,
providedId: e
}) {
return h(() => e ?? `${s}-${Nt().replace(/:/g, "")}`);
}
const ps = [
"af-ZA",
"sq-AL",
"ar-DZ",
"ar-BH",
"ar-EG",
"ar-IQ",
"ar-JO",
"ar-KW",
"ar-LB",
"ar-LY",
"ar-MA",
"ar-OM",
"ar-QA",
"ar-SA",
"ar-SY",
"ar-TN",
"ar-AE",
"ar-YE",
"hy-AM",
"Cy-az-AZ",
"Lt-az-AZ",
"eu-ES",
"be-BY",
"bg-BG",
"ca-ES",
"zh-CN",
"zh-HK",
"zh-MO",
"zh-SG",
"zh-TW",
"zh-CHS",
"zh-CHT",
"hr-HR",
"cs-CZ",
"da-DK",
"div-MV",
"nl-BE",
"nl-NL",
"en-AU",
"en-BZ",
"en-CA",
"en-CB",
"en-IE",
"en-JM",
"en-NZ",
"en-PH",
"en-ZA",
"en-TT",
"en-GB",
"en-US",
"en-ZW",
"et-EE",
"fo-FO",
"fa-IR",
"fi-FI",
"fr-BE",
"fr-CA",
"fr-FR",
"fr-LU",
"fr-MC",
"fr-CH",
"gl-ES",
"ka-GE",
"de-AT",
"de-DE",
"de-LI",
"de-LU",
"de-CH",
"el-GR",
"gu-IN",
"he-IL",
"hi-IN",
"hu-HU",
"is-IS",
"id-ID",
"it-IT",
"it-CH",
"ja-JP",
"kn-IN",
"kk-KZ",
"kok-IN",
"ko-KR",
"ky-KZ",
"lv-LV",
"lt-LT",
"mk-MK",
"ms-BN",
"ms-MY",
"mr-IN",
"mn-MN",
"nb-NO",
"nn-NO",
"pl-PL",
"pt-BR",
"pt-PT",
"pa-IN",
"ro-RO",
"ru-RU",
"sa-IN",
"Cy-sr-SP",
"Lt-sr-SP",
"sk-SK",
"sl-SI",
"es-AR",
"es-BO",
"es-CL",
"es-CO",
"es-CR",
"es-DO",
"es-EC",
"es-SV",
"es-GT",
"es-HN",
"es-MX",
"es-NI",
"es-PA",
"es-PY",
"es-PE",
"es-PR",
"es-ES",
"es-UY",
"es-VE",
"sw-KE",
"sv-FI",
"sv-SE",
"syr-SY",
"ta-IN",
"tt-RU",
"te-IN",
"th-TH",
"tr-TR",
"uk-UA",
"ur-PK",
"Cy-uz-UZ",
"Lt-uz-UZ",
"vi-VN"
], gs = [
"aa",
"ab",
"ae",
"af",
"ak",
"am",
"an",
"ar",
"as",
"av",
"ay",
"az",
"ba",
"be",
"bg",
"bh",
"bi",
"bm",
"bn",
"bo",
"br",
"bs",
"ca",
"ce",
"ch",
"co",
"cr",
"cs",
"cu",
"cv",
"cy",
"da",
"de",
"dv",
"dz",
"ee",
"el",
"en",
"eo",
"es",
"et",
"eu",
"fa",
"ff",
"fi",
"fj",
"fo",
"fr",
"fy",
"ga",
"gd",
"gl",
"gn",
"gu",
"gv",
"ha",
"he",
"hi",
"ho",
"hr",
"ht",
"hu",
"hy",
"hz",
"ia",
"id",
"ie",
"ig",
"ii",
"ik",
"io",
"is",
"it",
"iu",
"ja",
"jv",
"ka",
"kg",
"ki",
"kj",
"kk",
"kl",
"km",
"kn",
"ko",
"kr",
"ks",
"ku",
"kv",
"kw",
"ky",
"la",
"lb",
"lg",
"li",
"ln",
"lo",
"lt",
"lu",
"lv",
"mg",
"mh",
"mi",
"mk",
"ml",
"mn",
"mr",
"ms",
"mt",
"my",
"na",
"nb",
"nd",
"ne",
"ng",
"nl",
"nn",
"no",
"nr",
"nv",
"ny",
"oc",
"oj",
"om",
"or",
"os",
"pa",
"pi",
"pl",
"ps",
"pt",
"qu",
"rm",
"rn",
"ro",
"ru",
"rw",
"sa",
"sc",
"sd",
"se",
"sg",
"si",
"sk",
"sl",
"sm",
"sn",
"so",
"sq",
"sr",
"ss",
"st",
"su",
"sv",
"sw",
"ta",
"te",
"tg",
"th",
"ti",
"tk",
"tl",
"tn",
"to",
"tr",
"ts",
"tt",
"tw",
"ty",
"ug",
"uk",
"ur",
"uz",
"ve",
"vi",
"vo",
"wa",
"wo",
"xh",
"yi",
"yo",
"za",
"zh",
"zu"
], ys = [...gs, ...ps];
let W;
function Qe(s, e) {
return !s || (s == null ? void 0 : s.toLocaleLowerCase()) === e.toLocaleLowerCase();
}
function Gn(s) {
function e(n, o) {
return h(() => {
const i = ge(o), r = ge(n);
try {
if (!i || !r)
return r;
(!W || i !== W.resolvedOptions().locale) && (W = new Intl.DisplayNames([i], { type: "language" }));
const a = W.of(r);
return !a || Qe(a, r) ? void 0 : a;
} catch {
return r;
}
});
}
function t(n) {
return h(() => {
const o = ge(n);
return o ? ((!W || o !== W.resolvedOptions().locale) && (W = new Intl.DisplayNames([o], {
type: "language"
})), ys.map((i) => {
try {
const r = W == null ? void 0 : W.of(i);
return !r || Qe(r, i) ? void 0 : {
language: r,
code: i
};
} catch {
return;
}
}).filter(Boolean)) : [];
});
}
return {
getLanguageDisplayName: ({ code: n, locale: o }) => e(n, o || s),
getAllLanguageDisplayNames: (n) => t(n || s)
};
}
function wt(s) {
const e = s.join(", ").match(/\b\w+\b/g);
return e ? e.length : 0;
}
function bs(s, e = 150) {
const t = wt([s]);
return Math.ceil(t / e);
}
function Qn(s) {
const e = h(
() => {
var r;
return typeof s.velocity == "number" ? s.velocity : ((r = s.velocity) == null ? void 0 : r.value) ?? 150;
}
), t = h(() => {
var r;
return typeof s.contentSelector == "string" ? s.contentSelector : (r = s.contentSelector) == null ? void 0 : r.value;
}), n = h(() => {
var r, a, l;
if (typeof ((r = s.contentRef) == null ? void 0 : r.value) == "object")
return (a = s.contentRef.value) == null ? void 0 : a.textContent;
if (t.value && typeof document < "u") {
const u = document.querySelector(t.value);
if (u)
return u.textContent;
}
return typeof s.content == "string" ? s.content : (l = s.content) == null ? void 0 : l.value;
}), o = h(() => bs(n.value, e.value)), i = h(() => wt([n.value]));
return {
content: n,
wordCount: i,
velocity: e,
duration: o
};
}
const ws = {
removeAccents: !0,
caseSensitive: !1,
replaceSpaces: !0,
removeSpecialCharacters: !1,
trim: !0,
normalizeSpaces: !0,
removeNumbers: !1,
customNormalizationForms: ["NFC", "NFKD"]
};
function Je(s, e) {
const t = { ...ws, ...e }, n = {
À: "A",
Á: "A",
Â: "A",
Ã: "A",
Ä: "A",
Å: "A",
à: "a",
á: "a",
â: "a",
ã: "a",
ä: "a",
å: "a",
È: "E",
É: "E",
Ê: "E",
Ë: "E",
è: "e",
é: "e",
ê: "e",
ë: "e",
Î: "I",
Ï: "I",
í: "I",
î: "i",
ï: "i",
Ô: "O",
Õ: "O",
Ö: "O",
Ø: "O",
ô: "o",
õ: "o",
ö: "o",
ø: "o",
Ù: "U",
Ú: "U",
Û: "U",
Ü: "U",
ù: "u",
ú: "u",
û: "u",
ü: "u",
Ç: "C",
ç: "c",
ÿ: "y",
Ñ: "N",
ñ: "n",
ó: "o"
};
let o = s.toString();
if (t.trim && (o = o.trim()), t.normalizeSpaces && (o = o.replaceAll(/\s+/g, " ")), t.replaceSpaces && (o = o.replaceAll(" ", "-")), t.removeNumbers && (o = o.replaceAll(/\d/g, "")), t.removeAccents && (o = o.replaceAll(/[ÀÁÂÃÄÅÇÈÉÊËÎÏÑÔÕÖØÙÚÛÜàáâãäåçèéêëíîïñóôõöøùúûüÿ]/g, (i) => n[i] || i), o = o.replaceAll(/[\u0300-\u036F]/g, "")), t.caseSensitive === !1 && (o = o.toLowerCase()), t.removeSpecialCharacters && (o = o.replaceAll(/[^\dA-Z-]/gi, "")), t.trim && (o = o.trim()), t.customNormalizationForms)
for (const i of t.customNormalizationForms)
o = o.normalize(i);
return o;
}
function Es(s, e) {
const t = s.length, n = e.length, o = [];
for (let i = 0; i <= t; i++)
o[i] = [i];
for (let i = 0; i <= n; i++)
o[0][i] = i;
for (let i = 1; i <= t; i++)
for (let r = 1; r <= n; r++) {
const a = s[i - 1] === e[r - 1] ? 0 : 1;
o[i][r] = Math.min(
o[i - 1][r] + 1,
o[i][r - 1] + 1,
o[i - 1][r - 1] + a
);
}
return o[t][n];
}
function Et(s, e) {
const t = Es(s, e), n = Math.max(s.length, e.length);
return 1 - t / n;
}
function Ts(s, e, t = 0.75) {
return Et(s, e) >= t;
}
function Jn(s, e, t = 0.75) {
const n = h(
() => Je(typeof s == "string" ? s : s.value)
), o = h(
() => Je(typeof e == "string" ? e : e.value)
), i = h(() => typeof t == "number" ? t : t.value), r = h(() => Et(n.value, o.value));
return {
isMatching: h(
() => Ts(n.value, o.value, i.value)
),
score: r
};
}
const zs = {
preventDefaultOnTouchMove: !1,
preventDefaultOnMouseWheel: !1,
threshold: 50,
immediate: !1,
triggerOnEnd: !1
};
class Ls {
constructor(e) {
c(this, "element");
c(this, "xStart");
c(this, "yStart");
c(this, "xEnd");
c(this, "yEnd");
c(this, "xDiff");
c(this, "yDiff");
c(this, "onToucheStartCallback");
c(this, "onToucheMoveCallback");
c(this, "onToucheEndCallback");
c(this, "onMouseWheelCallback");
c(this, "start");
c(this, "stop");
c(this, "options");
this.inputOption = e, this.options = { ...zs, ...e }, this.onToucheStartCallback = this.toucheStartHandler.bind(this), this.onToucheMoveCallback = this.handleTouchMove.bind(this), this.onToucheEndCallback = this.handleTouchEnd.bind(this), this.onMouseWheelCallback = this.handleMouseWheel.bind(this), this.start = this.startListening.bind(this), this.stop = this.stopListening.bind(this), this.options.element && this.setElement(this.options.element), this.options.immediate && this.start();
}
startListening() {
this.setElement(this.options.element), this.element.addEventListener("touchstart", this.onToucheStartCallback, { passive: !0 }), this.element.addEventListener("touchmove", this.onToucheMoveCallback, { passive: !0 }), this.options.triggerOnEnd && this.element.addEventListener("touchend", this.onToucheEndCallback, { passive: !0 }), this.options.preventDefaultOnMouseWheel && this.element.addEventListener("mousewheel", this.onMouseWheelCallback, { passive: !1 });
}
stopListening() {
this.element.removeEventListener("touchstart", this.onToucheStartCallback), this.element.removeEventListener("touchmove", this.onToucheMoveCallback), this.element.removeEventListener("touchend", this.onToucheEndCallback), this.options.preventDefaultOnMouseWheel && this.element.removeEventListener("mousewheel", this.onMouseWheelCallback);
}
setElement(e) {
if (!e) {
console.error(
"[maz-ui][SwipeHandler](setElement) Element should be provided. Its can be a string selector or an HTMLElement"
);
return;
}
if (typeof e == "string") {
const t = document.querySelector(e);
if (!(t instanceof HTMLElement)) {
console.error("[maz-ui][SwipeHandler](setElement) String selector for element is not found");
return;
}
this.element = t;
} else
this.element = e;
}
handleMouseWheel(e) {
e.preventDefault();
}
toucheStartHandler(e) {
this.xStart = e.touches[0].clientX, this.yStart = e.touches[0].clientY, this.emitValuesChanged();
}
emitValuesChanged() {
var e, t;
(t = (e = this.options).onValuesChanged) == null || t.call(e, {
xStart: this.xStart,
yStart: this.yStart,
xEnd: this.xEnd,
yEnd: this.yEnd,
xDiff: this.xDiff,
yDiff: this.yDiff
});
}
handleTouchMove(e) {
this.options.preventDefaultOnTouchMove && e.cancelable && e.preventDefault(), this.xEnd = e.touches[0].clientX, this.yEnd = e.touches[0].clientY, !(!this.xStart || !this.yStart) && (this.xDiff = this.xStart - this.xEnd, this.yDiff = this.yStart - this.yEnd, this.emitValuesChanged(), this.options.triggerOnEnd || this.runCallbacks(e));
}
handleTouchEnd(e) {
this.runCallbacks(e), this.emitValuesChanged();
}
runCallbacks(e) {
var t, n, o, i, r, a, l, u;
typeof this.xDiff != "number" || typeof this.yDiff != "number" || Math.abs(this.xDiff) < this.options.threshold && Math.abs(this.yDiff) < this.options.threshold || (Math.abs(this.xDiff) > Math.abs(this.yDiff) ? this.xDiff > 0 ? (n = (t = this.options).onLeft) == null || n.call(t, e) : (i = (o = this.options).onRight) == null || i.call(o, e) : this.yDiff > 0 ? (a = (r = this.options).onUp) == null || a.call(r, e) : (u = (l = this.options).onDown) == null || u.call(l, e), this.resetValues());
}
resetValues() {
this.xStart = void 0, this.yStart = void 0, this.xEnd = void 0, this.yEnd = void 0, this.xDiff = void 0, this.yDiff = void 0, this.emitValuesChanged();
}
}
function eo(s) {
const e = b(), t = b(), n = b(), o = b(), i = b(), r = b(), a = h(() => ge(s.element)), l = new Ls({
...s,
element: a.value,
onValuesChanged(u) {
e.value = u.xDiff, t.value = u.yDiff, n.value = u.xStart, o.value = u.xEnd, i.value = u.yStart, r.value = u.yEnd;
}
});
return {
xDiff: e,
yDiff: t,
xStart: n,
xEnd: o,
yStart: i,
yEnd: r,
start: () => {
a.value && (l.options.element = a.value), l.start();
},
stop: l.stop
};
}
const ks = {
darkClass: "dark",
lightClass: "light",
storageThemeKey: "theme",
storageThemeValueDark: "dark",
storageThemeValueLight: "light",
storageThemeValueSystem: "system",
watchChanges: !0
}, Te = b("system"), Y = b("system");
function et() {
return window.matchMedia("(prefers-color-scheme: dark)").matches;
}
function ze({
darkClass: s,
lightClass: e,
storageThemeKey: t,
storageThemeValueDark: n,
setLocalStorageValue: o = !0,
setSelectedTheme: i = !0
}) {
F() && (document.documentElement.classList.remove(e), document.documentElement.classList.add(s), Te.value = n, i && (Y.value = n), o && (localStorage[t] = n));
}
function Le({
darkClass: s,
lightClass: e,
storageThemeKey: t,
storageThemeValueLight: n,
setLocalStorageValue: o = !0,
setSelectedTheme: i = !0
}) {
F() && (document.documentElement.classList.remove(s), document.documentElement.classList.add(e), Te.value = n, i && (Y.value = n), o && (localStorage[t] = n));
}
function Tt({
setLocalStorageValue: s = !0,
...e
}) {
if (F())
return document.documentElement.classList.remove(e.darkClass), document.documentElement.classList.remove(e.lightClass), Te.value = e.storageThemeValueSystem, Y.value = e.storageThemeValueSystem, s && (localStorage[e.storageThemeKey] = e.storageThemeValueSystem), qe(e);
}
function zt(s) {
if (!s.defaultTheme)
return console.error("[maz-ui](useThemeHandler) No default theme set");
if (!["light", "dark"].includes(s.defaultTheme))
return console.error('[maz-ui](useThemeHandler) Default theme must be "light" or "dark"');
switch (s.defaultTheme) {
case "dark":
return ze({
...s,
setLocalStorageValue: !1,
setSelectedTheme: !0
});
case "light":
return Le({
...s,
setLocalStorageValue: !1,
setSelectedTheme: !0
});
}
}
function qe(s) {
return F() ? !localStorage[s.storageThemeKey] && s.defaultTheme ? zt(s) : localStorage[s.storageThemeKey] === s.storageThemeValueDark || !localStorage[s.storageThemeKey] && et() || localStorage[s.storageThemeKey] === s.storageThemeValueSystem && et() ? ze({
...s,
setLocalStorageValue: !1,
setSelectedTheme: !1
}) : Le({
...s,
setLocalStorageValue: !1,
setSelectedTheme: !1
}) : void 0;
}
function Fe({
theme: s,
...e
}) {
return s === "system" ? Tt(e) : s === "dark" ? ze(e) : Le(e);
}
function Cs(s) {
return Te.value === s.storageThemeValueDark ? Le(s) : ze(s);
}
function to(s) {
const e = {
...ks,
...s
};
function t() {
qe(e);
}
return ce(() => {
localStorage[e.storageThemeKey] && (Y.value = localStorage[e.storageThemeKey]), e.watchChanges && window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", t);
}), lt(() => {
e.watchChanges && window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change", t);
}), G(Y, (n) => {
switch (localStorage[e.storageThemeKey] = n, n) {
case e.storageThemeValueDark: {
ze(e);
break;
}
case e.storageThemeValueLight: {
Le(e);
break;
}
case e.storageThemeValueSystem: {
Tt(e);
break;
}
}
}), {
autoSetTheme: () => qe(e),
toggleTheme: () => Cs(e),
setSystemTheme: () => Fe({ ...e, theme: "system" }),
setDarkTheme: () => Fe({ ...e, theme: "dark" }),
setLightTheme: () => Fe({ ...e, theme: "light" }),
setDefaultTheme: () => zt(e),
hasDarkTheme: h(() => Y.value === e.storageThemeValueDark),
hasLightTheme: h(() => Y.value === e.storageThemeValueLight),
hasSystemTheme: h(() => Y.value === e.storageThemeValueSystem),
theme: Te,
selectedTheme: Y
};
}
function Is({ timeout: s = 1e3, callback: e, remainingTimeUpdate: t = 200, callbackOffsetTime: n = 0 }) {
const o = b(s), i = b(s);
let r;
function a(w) {
typeof w == "number" && (i.value = w), typeof w == "number" && (o.value = w), l();
}
function l() {
r || (r = setInterval(() => {
i.value -= t, i.value <= 0 && (T(), setTimeout(() => e == null ? void 0 : e(), n));
}, t));
}
function u() {
r && (clearInterval(r), r = void 0);
}
function y() {
!r && i.value > 0 && l();
}
function T() {
setTimeout(() => i.value = o.value, n * 2), u();
}
return {
remainingTime: i,
start: a,
pause: u,
resume: y,
stop: T
};
}
function so() {
return Pe("toast");
}
class As {
constructor(e, t) {
c(this, "eventHandlerFunction");
c(this, "event", "visibilitychange");
c(this, "timeoutHandler");
c(this, "options");
c(this, "defaultOptions", {
timeout: 5e3,
once: !1,
immediate: !0
});
c(this, "isVisible", !1);
this.callback = e, this.options = {
...this.defaultOptions,
...t
}, this.eventHandlerFunction = this.eventHandler.bind(this), F() && this.start();
}
start() {
if (!F()) {
console.warn("[UserVisibility](start) you should run this method on client side");
return;
}
this.options.immediate && this.emitCallback(), this.addEventListener();
}
emitCallback() {
this.isVisible = document.visibilityState === "visible", this.callback({ isVisible: this.isVisible }), this.options.once && this.destroy();
}
eventHandler() {
document.visibilityState === "visible" && !this.isVisible ? (this.clearTimeout(), this.emitCallback()) : document.visibilityState === "hidden" && this.initTimeout();
}
clearTimeout() {
this.timeoutHandler && (clearTimeout(this.timeoutHandler), this.timeoutHandler = void 0);
}
initTimeout() {
this.clearTimeout(), this.timeoutHandler = setTimeout(this.emitCallback.bind(this), this.options.timeout);
}
addEventListener() {
document.addEventListener(this.event, this.eventHandlerFunction);
}
removeEventListener() {
document.removeEventListener(this.event, this.eventHandlerFunction);
}
destroy() {
this.removeEventListener(), this.timeoutHandler && clearTimeout(this.timeoutHandler);
}
}
function no({
callback: s,
options: e
}) {
return new As(s, e);
}
function oo() {
return Pe("wait");
}
const De = "__maz-click-outside__";
function Lt() {
return document.ontouchstart === null ? "touchstart" : "click";
}
async function kt(s, e) {
try {
Ct(s);
const t = e.instance, n = e.value, o = typeof n == "function";
if (!o)
throw new Error("[maz-ui](vClickOutside) the callback should be a function");
await le(), s[De] = (r) => {
if ((!s || r.target && !s.contains(r.target)) && n && o)
return n.call(t, r);
};
const i = Lt();
document.addEventListener(i, s[De], { passive: !0 });
} catch (t) {
console.error("[maz-ui](vClickOutside)", t);
}
}
function Ct(s) {
try {
const e = Lt();
document.removeEventListener(e, s[De], !1), delete s[De];
} catch (e) {
console.error("[maz-ui](vClickOutside)", e);
}
}
function Ss(s, e) {
try {
if (e.value === e.oldValue)
return;
kt(s, e);
} catch (t) {
console.error("[maz-ui](vClickOutside)", t);
}
}
const xs = {
mounted: kt,
updated: Ss,
unmounted: Ct
}, Os = {
install: (s) => {
s.directive("click-outside", xs);
}
};
function It(s, e, t) {
var r, a;
s.stopPropagation();
const n = typeof t.value == "function" ? t.value : t.value.handler, o = typeof t.value == "object" ? t.value.exclude : void 0;
let i = !1;
if (o && o.length > 0) {
for (const l of o)
if (!i && s.target instanceof HTMLElement) {
const u = (r = document.querySelector(l)) == null ? void 0 : r.getAttribute("id");
i = (s.target.getAttribute("id") === u || ((a = document.querySelector(l)) == null ? void 0 : a.contains(s.target))) ?? !1;
}
}
!e.contains(s.target) && !i && (n == null || n(s));
}
function At() {
return document.ontouchstart === null ? "touchstart" : "click";
}
function Ds(s, e) {
const t = At();
document.removeEventListener(t, (n) => It(n, s, e));
}
function Ps(s, e) {
if (typeof e.value != "function" && typeof e.value == "object" && typeof e.value.handler != "function") {
console.error("[maz-ui](vClosable) v-closable directive requires a handler function");
return;
}
const t = At();
document.addEventListener(t, (n) => It(n, s, e));
}
const Ms = {
mounted: Ps,
unmounted: Ds
}, $s = {
install: (s) => {
s.directive("closable", Ms);
}
}, Ue = {
position: "top"
};
class St {
constructor(e = {}) {
c(this, "options");
this.options = {
...Ue,
...e
};
}
getPosition({ modifiers: e, value: t }) {
return e.top ? "top" : e.bottom ? "bottom" : e.left ? "left" : e.right ? "right" : typeof t == "string" ? "top" : t.position ?? this.options.position;
}
getText({ value: e }) {
return typeof e == "string" ? e : e.text;
}
getOpen({ value: e }) {
return typeof e == "string" ? !1 : e.open ?? !1;
}
getColor({ value: e }) {
return typeof e == "string" ? "default" : e.color ?? "default";
}
getOffset({ value: e }) {
return typeof e == "string" ? "1rem" : e.offset ?? "1rem";
}
create(e, t) {
e.setAttribute("data-tooltip", this.getText(t));
const n = this.getOffset(t);
n && e.style.setProperty("--tooltip-offset", n), e.classList.add("m-tooltip");
const o = this.getPosition(t);
e.classList.add(`m-tooltip--${o}`), e.classList.add(`m-tooltip--${this.getColor(t)}`), this.getOpen(t) && e.classList.add("m-tooltip--open");
}
update(e, t) {
this.remove(e, t), this.create(e, t);
}
remove(e, t) {
e.removeAttribute("data-tooltip"), e.classList.remove("m-tooltip"), e.classList.remove("m-tooltip--top"), e.classList.remove("m-tooltip--bottom"), e.classList.remove("m-tooltip--left"), e.classList.remove("m-tooltip--right"), e.classList.remove("m-tooltip--open"), e.classList.remove(`m-tooltip--${this.getColor(t)}`);
}
}
let Ae;
const io = {
beforeMount(s, e) {
const t = typeof e.value == "object" ? e.value : {};
return Ae = new St(t), Ae.create(s, e);
},
updated(s, e) {
return Ae.update(s, e);
},
unmounted(s, e) {
return Ae.remove(s, e);
}
}, Vs = {
install: (s, e = Ue) => {
const t = {
...Ue,
...e
}, n = new St(t);
s.directive("tooltip", {
beforeMount: n.create.bind(n),
updated: n.update.bind(n),
unmounted: n.remove.bind(n)
});
}
};
function Ke(s, e) {
let t = e == null ? void 0 : e.element;
function n() {
t && Ie(null, t);
}
const o = { ...e == null ? void 0 : e.props, ...e != null && e.addDestroyInProps ? { destroy: n } : {} }, i = ee(
s,
o,
e == null ? void 0 : e.children
);
return e != null && e.app ? (i.appContext = e.app._context, t ? Ie(i, t) : typeof document < "u" && (t = document.createElement("div"), Ie(i, t))) : (t = t ?? document.body, Ie(i, t)), { vNode: i, destroy: n, el: t };
}
function Hs(s) {
return !!s;
}
function ro(s) {
return [...s].map((e) => {
const t = e.codePointAt(0);
return t ? t % 32 + 127461 : void 0;
}).filter(Hs).map((e) => String.fromCodePoint(e)).join("");
}
function ao(s, e) {
let t;
return function(...n) {
clearTimeout(t), t = setTimeout(() => {
s.apply(this, n);
}, e);
};
}
class lo {
constructor({ src: e, identifier: t, once: n = !0, async: o = !0, defer: i = !0 }) {
c(this, "src");
c(this, "script");
c(this, "once");
c(this, "async");
c(this, "defer");
c(this, "identifier");
if (typeof window > "u")
throw new TypeError("[ScriptLoader]: Is supported only on browser side");
if (!e)
throw new Error('[ScriptLoader]: You should provide the attribut "src"');
if (!t)
throw new Error('[ScriptLoader]: You should provide the attribut "identifier"');
this.src = e, this.identifier = t, this.once = n, this.async = o, this.defer = i;
}
removeTag(e) {
var t;
typeof e == "string" ? (t = document.head.querySelector(`[data-identifier="${e}"]`)) == null || t.remove() : e.remove();
}
load() {
const e = window, t = document.head.querySelectorAll(`[data-identifier="${this.identifier}"]`);
if (this.once && e[this.identifier] && t.length > 0)
return this.script = e[this.identifier], Promise.resolve(this.script);
if (!this.once && t.length > 0)
for (const n of t)
this.removeTag(n);
return this.injectScript();
}
injectScript() {
const e = window;
return new Promise((t, n) => {
try {
const o = document.createElement("script");
o.src = this.src, o.async = this.async, o.defer = this.defer, o.dataset.identifier = this.identifier, o.addEventListener("error", (i) => n(new Error(`[ScriptLoader](injectScript) ${i.message}`))), o.addEventListener("load", (i) => (this.script = i, e[this.identifier] = i, t(i))), document.head.append(o);
} catch (o) {
throw new Error(`[ScriptLoader](init) ${o}`);
}
});
}
}
function Bs(s) {
return new Promise((e) => setTimeout(e, s));
}
function uo(s, e) {
let t = !1, n, o;
return function(...i) {
t ? (clearTimeout(n), n = setTimeout(() => {
Date.now() - o >= e && (s.apply(this, i), o = Date.now());
}, Math.max(e - (Date.now() - o), 0))) : (s.apply(this, i), o = Date.now(), t = !0);
};
}
const Ns = ["onKeypress"], Fs = { class: "m-fullscreen-img-scroller" }, js = ["src", "alt"], qs = /* @__PURE__ */ be({
__name: "MazFullscreenImg",
props: {
src: {},
clickedElementBounds: { default: void 0 },
offset: { default: void 0 },
animation: { default: () => ({
duration: 300,
easing: "ease-in-out"
}) },
openInstanceClass: { default: "m-fullscreen-img-instance" },
clickedElement: {},
destroy: { type: Function, default: void 0 },
alt: { default: void 0 },
zoom: { type: Boolean, default: !0 }
},
emits: ["close", "previous", "next", "before-close"],
setup(s, { emit: e }) {
const t = s, n = e, o = H(() => import("./MazSpinner.Cx7mdOJ3.mjs")), i = H(() => import("./x-mark.CnZwVvA7.mjs")), r = H(() => import("./chevron-left.BqVOLRdC.mjs")), a = b(!1), l = b(!1), u = b(!1), y = b(!1), T = b(!1), w = Ft({
running: !1,
ended: !1
}), f = b(t.clickedElement), k = h(() => t.clickedElement.getBoundingClientRect()), z = b(), m = b(t.src), d = b(t.alt), C = b(), p = b(), S = b(!0), D = h(() => ({
"--is-zoomed": T.value,
"--invisible": S.value,
"--absolute": !T.value
}));
function L() {
var g, E;
p.value && (z.value = ((g = p.value) == null ? void 0 : g.naturalWidth) > ((E = p.value) == null ? void 0 : E.naturalHeight)), a.value = !0, l.value = !1, u.value = !0;
}
G(
u,
(g) => {
g && x();
},
{ immediate: !0 }
);
function P() {
n("before-close"), M();
}
function j(g) {
g.key === "Escape" && (g.preventDefault(), P()), (g.key === "ArrowLeft" || g.key === "ArrowRight") && (g.preventDefault(), fe(g.key === "ArrowRight" ? "next" : "previous"));
}
function ne() {
document.documentElement.classList.add("--m-fullscreen-open");
}
function Q() {
document.documentElement.classList.remove("--m-fullscreen-open");
}
function de() {
return [...document.querySelectorAll(".m-fullscreen-img-instance")];
}
function $e(g, E) {
return E < 0 ? g.length - 1 : E >= g.length ? 0 : E;
}
function me(g, E) {
g.classList.remove(t.openInstanceClass), E.classList.add(t.openInstanceClass);
const I = E.getAttribute("data-src"), $ = E.getAttribute("data-alt");
d.value = $, m.value = I ?? m.value;
}
function fe(g) {
S.value = !0;
const E = document.querySelector(
`.m-fullscreen-img-instance.${t.openInstanceClass}`
);
if (E) {
const I = de(), $ = I.indexOf(E), _ = g === "next" ? $ + 1 : $ - 1, K = I[$e(I, _)];
f.value = K, K && me(E, K), n(g), a.value = !1, l.value = !0, mt(() => a.value === !0, () => {
S.value = !1, T.value ? he() : v();
}, {
expectedValue: !0,
interval: 100,
maxAttempts: 50
});
}
}
function he() {
const g = p.value;
if (!g) {
console.error("[maz-ui](vFullscreenImg) ImgElement is not defined");
return;
}
g.style.removeProperty("max-width"), g.style.removeProperty("max-height"), g == null || g.style.removeProperty("top"), g == null || g.style.removeProperty("left"), z.value ? (g.style.height = "100vh", g.style.removeProperty("width")) : (g.style.width = "100vw", g.style.removeProperty("height"));
}
function Ve() {
T.value ? (T.value = !T.value, v()) : (T.value = !T.value, he());
}
function oe(g) {
var I;
w.running = !0, S.value = !1;
const E = (I = p.value) == null ? void 0 : I.animate(g, {
duration: t.animation.duration,
easing: t.animation.easing
});
if (!E) {
console.error("[maz-ui](vFullscreenImg) animation is not defined"), w.running = !1, w.ended = !0;
return;
}
return E;
}
function ke(g = t.offset ?? 0) {
const E = f.value.clientWidth || 1, I = f.value.clientHeight || 1, $ = window.innerWidth, _ = window.innerHeight, K = Math.min(
($ - 2 * g) / E,
(_ - 2 * g) / I
), He = ($ - E * K) / 2, Be = (_ - I * K) / 2;
return {
centerX: He,
centerY: Be,
width: E,
height: I,
scale: K
};
}
function Ce({ trigger: g }) {
const { width: E, height: I, scale: $, centerX: _, centerY: K } = ke(), { top: He, left: Be, width: Pt, height: Mt } = k.value, Ye = [
{
top: `${He}px`,
left: `