images-viewer-vue3
Version:
A lightweight image viewer for Vue3
248 lines (246 loc) • 5.59 kB
JavaScript
import { m as C } from "./npm-@emotion-hash-DImMRhyK.js";
function b(n) {
let e = 0;
for (let t = 0; t < n.length; ++t)
n[t] === "&" && ++e;
return e;
}
const $ = /\s*,(?![^(]*\))\s*/g, j = /\s+/g;
function v(n, e) {
const t = [];
return e.split($).forEach((r) => {
let f = b(r);
if (f) {
if (f === 1) {
n.forEach((i) => {
t.push(r.replace("&", i));
});
return;
}
} else {
n.forEach((i) => {
t.push(
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
(i && i + " ") + r
);
});
return;
}
let u = [
r
];
for (; f--; ) {
const i = [];
u.forEach((o) => {
n.forEach((c) => {
i.push(o.replace("&", c));
});
}), u = i;
}
u.forEach((i) => t.push(i));
}), t;
}
function S(n, e) {
const t = [];
return e.split($).forEach((r) => {
n.forEach((f) => {
t.push((f && f + " ") + r);
});
}), t;
}
function k(n) {
let e = [""];
return n.forEach((t) => {
t = t && t.trim(), // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
t && (t.includes("&") ? e = v(e, t) : e = S(e, t));
}), e.join(", ").replace(j, " ");
}
function x(n) {
if (!n)
return;
const e = n.parentElement;
e && e.removeChild(n);
}
function d(n, e) {
return (e ?? document.head).querySelector(`style[cssr-id="${n}"]`);
}
function q(n) {
const e = document.createElement("style");
return e.setAttribute("cssr-id", n), e;
}
function h(n) {
return n ? /^\s*@(s|m)/.test(n) : !1;
}
const R = /[A-Z]/g;
function w(n) {
return n.replace(R, (e) => "-" + e.toLowerCase());
}
function B(n, e = " ") {
return typeof n == "object" && n !== null ? ` {
` + Object.entries(n).map((t) => e + ` ${w(t[0])}: ${t[1]};`).join(`
`) + `
` + e + "}" : `: ${n};`;
}
function L(n, e, t) {
return typeof n == "function" ? n({
context: e.context,
props: t
}) : n;
}
function E(n, e, t, r) {
if (!e)
return "";
const f = L(e, t, r);
if (!f)
return "";
if (typeof f == "string")
return `${n} {
${f}
}`;
const u = Object.keys(f);
if (u.length === 0)
return t.config.keepEmptyBlock ? n + ` {
}` : "";
const i = n ? [
n + " {"
] : [];
return u.forEach((o) => {
const c = f[o];
if (o === "raw") {
i.push(`
` + c + `
`);
return;
}
o = w(o), c != null && i.push(` ${o}${B(c)}`);
}), n && i.push("}"), i.join(`
`);
}
function y(n, e, t) {
n && n.forEach((r) => {
if (Array.isArray(r))
y(r, e, t);
else if (typeof r == "function") {
const f = r(e);
Array.isArray(f) ? y(f, e, t) : f && t(f);
} else r && t(r);
});
}
function A(n, e, t, r, f) {
const u = n.$;
let i = "";
if (!u || typeof u == "string")
h(u) ? i = u : e.push(u);
else if (typeof u == "function") {
const s = u({
context: r.context,
props: f
});
h(s) ? i = s : e.push(s);
} else if (u.before && u.before(r.context), !u.$ || typeof u.$ == "string")
h(u.$) ? i = u.$ : e.push(u.$);
else if (u.$) {
const s = u.$({
context: r.context,
props: f
});
h(s) ? i = s : e.push(s);
}
const o = k(e), c = E(o, n.props, r, f);
i ? t.push(`${i} {`) : c.length && t.push(c), n.children && y(n.children, {
context: r.context,
props: f
}, (s) => {
if (typeof s == "string") {
const l = E(o, { raw: s }, r, f);
t.push(l);
} else
A(s, e, t, r, f);
}), e.pop(), i && t.push("}"), u && u.after && u.after(r.context);
}
function M(n, e, t) {
const r = [];
return A(n, [], r, e, t), r.join(`
`);
}
typeof window < "u" && (window.__cssrContext = {});
function O(n, e, t, r) {
const { els: f } = e;
if (t === void 0)
f.forEach(x), e.els = [];
else {
const u = d(t, r);
u && f.includes(u) && (x(u), e.els = f.filter((i) => i !== u));
}
}
function g(n, e) {
n.push(e);
}
function T(n, e, t, r, f, u, i, o, c) {
let s;
if (t === void 0 && (s = e.render(r), t = C(s)), c) {
c.adapter(t, s ?? e.render(r));
return;
}
o === void 0 && (o = document.head);
const l = d(t, o);
if (l !== null && !u)
return l;
const a = l ?? q(t);
if (s === void 0 && (s = e.render(r)), a.textContent = s, l !== null)
return l;
if (i) {
const m = o.querySelector(`meta[name="${i}"]`);
if (m)
return o.insertBefore(a, m), g(e.els, a), a;
}
return f ? o.insertBefore(a, o.querySelector("style, link")) : o.appendChild(a), g(e.els, a), a;
}
function W(n) {
return M(this, this.instance, n);
}
function _(n = {}) {
const { id: e, ssr: t, props: r, head: f = !1, force: u = !1, anchorMetaName: i, parent: o } = n;
return T(this.instance, this, e, r, f, u, i, o, t);
}
function U(n = {}) {
const { id: e, parent: t } = n;
O(this.instance, this, e, t);
}
const p = function(n, e, t, r) {
return {
instance: n,
$: e,
props: t,
children: r,
els: [],
render: W,
mount: _,
unmount: U
};
}, Z = function(n, e, t, r) {
return Array.isArray(e) ? p(n, { $: null }, null, e) : Array.isArray(t) ? p(n, e, null, t) : Array.isArray(r) ? p(n, e, t, r) : p(n, e, t, null);
};
function D(n = {}) {
const e = {
c: (...t) => Z(e, ...t),
use: (t, ...r) => t.install(e, ...r),
find: d,
context: {},
config: n
};
return e;
}
function F(n, e) {
if (n === void 0)
return !1;
if (e) {
const { context: { ids: t } } = e;
return t.has(n);
}
return d(n) !== null;
}
export {
D as C,
F as e
};