images-viewer-vue3
Version:
A lightweight image viewer for Vue3
130 lines (129 loc) • 3.99 kB
JavaScript
/*!
* shared v10.0.4
* (c) 2024 kazuya kawaguchi
* Released under the MIT License.
*/
const S = typeof window < "u";
let A, E;
if (process.env.NODE_ENV !== "production") {
const e = S && window.performance;
e && e.mark && e.measure && e.clearMarks && // @ts-ignore browser compat
e.clearMeasures && (A = (t) => {
e.mark(t);
}, E = (t, o, n) => {
e.measure(t, o, n), e.clearMarks(o), e.clearMarks(n);
});
}
const M = /\{([0-9a-zA-Z]+)\}/g;
function k(e, ...t) {
return t.length === 1 && a(t[0]) && (t = t[0]), (!t || !t.hasOwnProperty) && (t = {}), e.replace(M, (o, n) => t.hasOwnProperty(n) ? t[n] : "");
}
const R = (e, t = !1) => t ? Symbol.for(e) : Symbol(e), D = (e, t, o) => N({ l: e, k: t, s: o }), N = (e) => JSON.stringify(e).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029").replace(/\u0027/g, "\\u0027"), F = (e) => typeof e == "number" && isFinite(e), T = (e) => u(e) === "[object Date]", B = (e) => u(e) === "[object RegExp]", C = (e) => O(e) && Object.keys(e).length === 0, G = Object.assign;
let g;
const J = () => g || (g = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : typeof global < "u" ? global : {});
function _(e) {
return e.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
}
const x = Object.prototype.hasOwnProperty;
function $(e, t) {
return x.call(e, t);
}
const m = Array.isArray, b = (e) => typeof e == "function", q = (e) => typeof e == "string", z = (e) => typeof e == "boolean", a = (e) => e !== null && typeof e == "object", I = (e) => a(e) && b(e.then) && b(e.catch), w = Object.prototype.toString, u = (e) => w.call(e), O = (e) => u(e) === "[object Object]", H = (e) => e == null ? "" : m(e) || O(e) && e.toString === w ? JSON.stringify(e, null, 2) : String(e);
function K(e, t = "") {
return e.reduce((o, n, s) => s === 0 ? o + n : o + t + n, "");
}
const y = 2;
function L(e, t = 0, o = e.length) {
const n = e.split(/\r?\n/);
let s = 0;
const r = [];
for (let i = 0; i < n.length; i++)
if (s += n[i].length + 1, s >= t) {
for (let c = i - y; c <= i + y || o > s; c++) {
if (c < 0 || c >= n.length)
continue;
const h = c + 1;
r.push(`${h}${" ".repeat(3 - String(h).length)}| ${n[c]}`);
const l = n[c].length;
if (c === i) {
const f = t - (s - l) + 1, j = Math.max(1, o > s ? l - f : o - t);
r.push(" | " + " ".repeat(f) + "^".repeat(j));
} else if (c > i) {
if (o > s) {
const f = Math.max(Math.min(o - s, l), 1);
r.push(" | " + "^".repeat(f));
}
s += l + 1;
}
}
break;
}
return r.join(`
`);
}
function P(e, t) {
typeof console < "u" && (console.warn("[intlify] " + e), t && console.warn(t.stack));
}
const d = {};
function V(e) {
d[e] || (d[e] = !0, P(e));
}
function W() {
const e = /* @__PURE__ */ new Map();
return {
events: e,
on(o, n) {
const s = e.get(o);
s && s.push(n) || e.set(o, [n]);
},
off(o, n) {
const s = e.get(o);
s && s.splice(s.indexOf(n) >>> 0, 1);
},
emit(o, n) {
(e.get(o) || []).slice().map((s) => s(n)), (e.get("*") || []).slice().map((s) => s(o, n));
}
};
}
const p = (e) => !a(e) || m(e);
function Z(e, t) {
if (p(e) || p(t))
throw new Error("Invalid value");
const o = [{ src: e, des: t }];
for (; o.length; ) {
const { src: n, des: s } = o.pop();
Object.keys(n).forEach((r) => {
a(n[r]) && !a(s[r]) && (s[r] = Array.isArray(n[r]) ? [] : {}), p(s[r]) || p(n[r]) ? s[r] = n[r] : o.push({ src: n[r], des: s[r] });
});
}
}
export {
Z as A,
$ as B,
b as a,
q as b,
m as c,
O as d,
G as e,
z as f,
J as g,
B as h,
a as i,
V as j,
k,
C as l,
T as m,
F as n,
_ as o,
S as p,
A as q,
E as r,
L as s,
D as t,
I as u,
K as v,
P as w,
H as x,
R as y,
W as z
};