images-viewer-vue3
Version:
A lightweight image viewer for Vue3
948 lines (947 loc) • 26.9 kB
JavaScript
import { k as Se, e as ne, v as re, b as Z } from "./npm-@intlify-shared-B92O6p09.js";
/*!
* message-compiler v10.0.4
* (c) 2024 kazuya kawaguchi
* Released under the MIT License.
*/
function ke(r, n, c) {
return { line: r, column: n, offset: c };
}
function q(r, n, c) {
return { start: r, end: n };
}
const d = {
// tokenizer error codes
EXPECTED_TOKEN: 1,
INVALID_TOKEN_IN_PLACEHOLDER: 2,
UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER: 3,
UNKNOWN_ESCAPE_SEQUENCE: 4,
INVALID_UNICODE_ESCAPE_SEQUENCE: 5,
UNBALANCED_CLOSING_BRACE: 6,
UNTERMINATED_CLOSING_BRACE: 7,
EMPTY_PLACEHOLDER: 8,
NOT_ALLOW_NEST_PLACEHOLDER: 9,
INVALID_LINKED_FORMAT: 10,
// parser error codes
MUST_HAVE_MESSAGES_IN_PLURAL: 11,
UNEXPECTED_EMPTY_LINKED_MODIFIER: 12,
UNEXPECTED_EMPTY_LINKED_KEY: 13,
UNEXPECTED_LEXICAL_ANALYSIS: 14,
// generator error codes
UNHANDLED_CODEGEN_NODE_TYPE: 15,
// minifier error codes
UNHANDLED_MINIFIER_NODE_TYPE: 16
}, Je = 17, De = {
// tokenizer error messages
[d.EXPECTED_TOKEN]: "Expected token: '{0}'",
[d.INVALID_TOKEN_IN_PLACEHOLDER]: "Invalid token in placeholder: '{0}'",
[d.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER]: "Unterminated single quote in placeholder",
[d.UNKNOWN_ESCAPE_SEQUENCE]: "Unknown escape sequence: \\{0}",
[d.INVALID_UNICODE_ESCAPE_SEQUENCE]: "Invalid unicode escape sequence: {0}",
[d.UNBALANCED_CLOSING_BRACE]: "Unbalanced closing brace",
[d.UNTERMINATED_CLOSING_BRACE]: "Unterminated closing brace",
[d.EMPTY_PLACEHOLDER]: "Empty placeholder",
[d.NOT_ALLOW_NEST_PLACEHOLDER]: "Not allowed nest placeholder",
[d.INVALID_LINKED_FORMAT]: "Invalid linked format",
// parser error messages
[d.MUST_HAVE_MESSAGES_IN_PLURAL]: "Plural must have messages",
[d.UNEXPECTED_EMPTY_LINKED_MODIFIER]: "Unexpected empty linked modifier",
[d.UNEXPECTED_EMPTY_LINKED_KEY]: "Unexpected empty linked key",
[d.UNEXPECTED_LEXICAL_ANALYSIS]: "Unexpected lexical analysis in token: '{0}'",
// generator error messages
[d.UNHANDLED_CODEGEN_NODE_TYPE]: "unhandled codegen node type: '{0}'",
// minimizer error messages
[d.UNHANDLED_MINIFIER_NODE_TYPE]: "unhandled mimifier node type: '{0}'"
};
function G(r, n, c = {}) {
const { domain: l, messages: _, args: u } = c, S = process.env.NODE_ENV !== "production" ? Se((_ || De)[r] || "", ...u || []) : r, C = new SyntaxError(String(S));
return C.code = r, n && (C.location = n), C.domain = l, C;
}
function je(r) {
throw r;
}
const Pe = /<\/?[\w\s="/.':;#-\/]+>/, Ze = (r) => Pe.test(r), X = " ", Oe = "\r", m = `
`, me = "\u2028", ye = "\u2029";
function be(r) {
const n = r;
let c = 0, l = 1, _ = 1, u = 0;
const S = (p) => n[p] === Oe && n[p + 1] === m, C = (p) => n[p] === m, h = (p) => n[p] === ye, y = (p) => n[p] === me, b = (p) => S(p) || C(p) || h(p) || y(p), T = () => c, A = () => l, R = () => _, v = () => u, P = (p) => S(p) || h(p) || y(p) ? m : n[p], I = () => P(c), s = () => P(c + u);
function a() {
return u = 0, b(c) && (l++, _ = 0), S(c) && c++, c++, _++, n[c];
}
function E() {
return S(c + u) && u++, u++, n[c + u];
}
function o() {
c = 0, l = 1, _ = 1, u = 0;
}
function L(p = 0) {
u = p;
}
function N() {
const p = c + u;
for (; p !== c; )
a();
u = 0;
}
return {
index: T,
line: A,
column: R,
peekOffset: v,
charAt: P,
currentChar: I,
currentPeek: s,
next: a,
peek: E,
reset: o,
resetPeek: L,
skipToPeek: N
};
}
const Y = void 0, Re = ".", z = "'", Ue = "tokenizer";
function ve(r, n = {}) {
const c = n.location !== !1, l = be(r), _ = () => l.index(), u = () => ke(l.line(), l.column(), l.index()), S = u(), C = _(), h = {
currentType: 13,
offset: C,
startLoc: S,
endLoc: S,
lastType: 13,
lastOffset: C,
lastStartLoc: S,
lastEndLoc: S,
braceNest: 0,
inLinked: !1,
text: ""
}, y = () => h, { onError: b } = n;
function T(e, t, i, ...f) {
const k = y();
if (t.column += i, t.offset += i, b) {
const D = c ? q(k.startLoc, t) : null, U = G(e, D, {
domain: Ue,
args: f
});
b(U);
}
}
function A(e, t, i) {
e.endLoc = u(), e.currentType = t;
const f = { type: t };
return c && (f.loc = q(e.startLoc, e.endLoc)), i != null && (f.value = i), f;
}
const R = (e) => A(
e,
13
/* TokenTypes.EOF */
);
function v(e, t) {
return e.currentChar() === t ? (e.next(), t) : (T(d.EXPECTED_TOKEN, u(), 0, t), "");
}
function P(e) {
let t = "";
for (; e.currentPeek() === X || e.currentPeek() === m; )
t += e.currentPeek(), e.peek();
return t;
}
function I(e) {
const t = P(e);
return e.skipToPeek(), t;
}
function s(e) {
if (e === Y)
return !1;
const t = e.charCodeAt(0);
return t >= 97 && t <= 122 || // a-z
t >= 65 && t <= 90 || // A-Z
t === 95;
}
function a(e) {
if (e === Y)
return !1;
const t = e.charCodeAt(0);
return t >= 48 && t <= 57;
}
function E(e, t) {
const { currentType: i } = t;
if (i !== 2)
return !1;
P(e);
const f = s(e.currentPeek());
return e.resetPeek(), f;
}
function o(e, t) {
const { currentType: i } = t;
if (i !== 2)
return !1;
P(e);
const f = e.currentPeek() === "-" ? e.peek() : e.currentPeek(), k = a(f);
return e.resetPeek(), k;
}
function L(e, t) {
const { currentType: i } = t;
if (i !== 2)
return !1;
P(e);
const f = e.currentPeek() === z;
return e.resetPeek(), f;
}
function N(e, t) {
const { currentType: i } = t;
if (i !== 7)
return !1;
P(e);
const f = e.currentPeek() === ".";
return e.resetPeek(), f;
}
function p(e, t) {
const { currentType: i } = t;
if (i !== 8)
return !1;
P(e);
const f = s(e.currentPeek());
return e.resetPeek(), f;
}
function w(e, t) {
const { currentType: i } = t;
if (!(i === 7 || i === 11))
return !1;
P(e);
const f = e.currentPeek() === ":";
return e.resetPeek(), f;
}
function O(e, t) {
const { currentType: i } = t;
if (i !== 9)
return !1;
const f = () => {
const D = e.currentPeek();
return D === "{" ? s(e.peek()) : D === "@" || D === "|" || D === ":" || D === "." || D === X || !D ? !1 : D === m ? (e.peek(), f()) : F(e, !1);
}, k = f();
return e.resetPeek(), k;
}
function g(e) {
P(e);
const t = e.currentPeek() === "|";
return e.resetPeek(), t;
}
function F(e, t = !0) {
const i = (k = !1, D = "") => {
const U = e.currentPeek();
return U === "{" || U === "@" || !U ? k : U === "|" ? !(D === X || D === m) : U === X ? (e.peek(), i(!0, X)) : U === m ? (e.peek(), i(!0, m)) : !0;
}, f = i();
return t && e.resetPeek(), f;
}
function H(e, t) {
const i = e.currentChar();
return i === Y ? Y : t(i) ? (e.next(), i) : null;
}
function se(e) {
const t = e.charCodeAt(0);
return t >= 97 && t <= 122 || // a-z
t >= 65 && t <= 90 || // A-Z
t >= 48 && t <= 57 || // 0-9
t === 95 || // _
t === 36;
}
function ie(e) {
return H(e, se);
}
function ce(e) {
const t = e.charCodeAt(0);
return t >= 97 && t <= 122 || // a-z
t >= 65 && t <= 90 || // A-Z
t >= 48 && t <= 57 || // 0-9
t === 95 || // _
t === 36 || // $
t === 45;
}
function ue(e) {
return H(e, ce);
}
function ae(e) {
const t = e.charCodeAt(0);
return t >= 48 && t <= 57;
}
function oe(e) {
return H(e, ae);
}
function le(e) {
const t = e.charCodeAt(0);
return t >= 48 && t <= 57 || // 0-9
t >= 65 && t <= 70 || // A-F
t >= 97 && t <= 102;
}
function fe(e) {
return H(e, le);
}
function J(e) {
let t = "", i = "";
for (; t = oe(e); )
i += t;
return i;
}
function Ee(e) {
let t = "";
for (; ; ) {
const i = e.currentChar();
if (i === "{" || i === "}" || i === "@" || i === "|" || !i)
break;
if (i === X || i === m)
if (F(e))
t += i, e.next();
else {
if (g(e))
break;
t += i, e.next();
}
else
t += i, e.next();
}
return t;
}
function de(e) {
I(e);
let t = "", i = "";
for (; t = ue(e); )
i += t;
return e.currentChar() === Y && T(d.UNTERMINATED_CLOSING_BRACE, u(), 0), i;
}
function Le(e) {
I(e);
let t = "";
return e.currentChar() === "-" ? (e.next(), t += `-${J(e)}`) : t += J(e), e.currentChar() === Y && T(d.UNTERMINATED_CLOSING_BRACE, u(), 0), t;
}
function Ne(e) {
return e !== z && e !== m;
}
function _e(e) {
I(e), v(e, "'");
let t = "", i = "";
for (; t = H(e, Ne); )
t === "\\" ? i += pe(e) : i += t;
const f = e.currentChar();
return f === m || f === Y ? (T(d.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER, u(), 0), f === m && (e.next(), v(e, "'")), i) : (v(e, "'"), i);
}
function pe(e) {
const t = e.currentChar();
switch (t) {
case "\\":
case "'":
return e.next(), `\\${t}`;
case "u":
return j(e, t, 4);
case "U":
return j(e, t, 6);
default:
return T(d.UNKNOWN_ESCAPE_SEQUENCE, u(), 0, t), "";
}
}
function j(e, t, i) {
v(e, t);
let f = "";
for (let k = 0; k < i; k++) {
const D = fe(e);
if (!D) {
T(d.INVALID_UNICODE_ESCAPE_SEQUENCE, u(), 0, `\\${t}${f}${e.currentChar()}`);
break;
}
f += D;
}
return `\\${t}${f}`;
}
function Ie(e) {
return e !== "{" && e !== "}" && e !== X && e !== m;
}
function Ce(e) {
I(e);
let t = "", i = "";
for (; t = H(e, Ie); )
i += t;
return i;
}
function he(e) {
let t = "", i = "";
for (; t = ie(e); )
i += t;
return i;
}
function Te(e) {
const t = (i) => {
const f = e.currentChar();
return f === "{" || f === "@" || f === "|" || f === "(" || f === ")" || !f || f === X ? i : (i += f, e.next(), t(i));
};
return t("");
}
function V(e) {
I(e);
const t = v(
e,
"|"
/* TokenChars.Pipe */
);
return I(e), t;
}
function B(e, t) {
let i = null;
switch (e.currentChar()) {
case "{":
return t.braceNest >= 1 && T(d.NOT_ALLOW_NEST_PLACEHOLDER, u(), 0), e.next(), i = A(
t,
2,
"{"
/* TokenChars.BraceLeft */
), I(e), t.braceNest++, i;
case "}":
return t.braceNest > 0 && t.currentType === 2 && T(d.EMPTY_PLACEHOLDER, u(), 0), e.next(), i = A(
t,
3,
"}"
/* TokenChars.BraceRight */
), t.braceNest--, t.braceNest > 0 && I(e), t.inLinked && t.braceNest === 0 && (t.inLinked = !1), i;
case "@":
return t.braceNest > 0 && T(d.UNTERMINATED_CLOSING_BRACE, u(), 0), i = $(e, t) || R(t), t.braceNest = 0, i;
default: {
let k = !0, D = !0, U = !0;
if (g(e))
return t.braceNest > 0 && T(d.UNTERMINATED_CLOSING_BRACE, u(), 0), i = A(t, 1, V(e)), t.braceNest = 0, t.inLinked = !1, i;
if (t.braceNest > 0 && (t.currentType === 4 || t.currentType === 5 || t.currentType === 6))
return T(d.UNTERMINATED_CLOSING_BRACE, u(), 0), t.braceNest = 0, Q(e, t);
if (k = E(e, t))
return i = A(t, 4, de(e)), I(e), i;
if (D = o(e, t))
return i = A(t, 5, Le(e)), I(e), i;
if (U = L(e, t))
return i = A(t, 6, _e(e)), I(e), i;
if (!k && !D && !U)
return i = A(t, 12, Ce(e)), T(d.INVALID_TOKEN_IN_PLACEHOLDER, u(), 0, i.value), I(e), i;
break;
}
}
return i;
}
function $(e, t) {
const { currentType: i } = t;
let f = null;
const k = e.currentChar();
switch ((i === 7 || i === 8 || i === 11 || i === 9) && (k === m || k === X) && T(d.INVALID_LINKED_FORMAT, u(), 0), k) {
case "@":
return e.next(), f = A(
t,
7,
"@"
/* TokenChars.LinkedAlias */
), t.inLinked = !0, f;
case ".":
return I(e), e.next(), A(
t,
8,
"."
/* TokenChars.LinkedDot */
);
case ":":
return I(e), e.next(), A(
t,
9,
":"
/* TokenChars.LinkedDelimiter */
);
default:
return g(e) ? (f = A(t, 1, V(e)), t.braceNest = 0, t.inLinked = !1, f) : N(e, t) || w(e, t) ? (I(e), $(e, t)) : p(e, t) ? (I(e), A(t, 11, he(e))) : O(e, t) ? (I(e), k === "{" ? B(e, t) || f : A(t, 10, Te(e))) : (i === 7 && T(d.INVALID_LINKED_FORMAT, u(), 0), t.braceNest = 0, t.inLinked = !1, Q(e, t));
}
}
function Q(e, t) {
let i = {
type: 13
/* TokenTypes.EOF */
};
if (t.braceNest > 0)
return B(e, t) || R(t);
if (t.inLinked)
return $(e, t) || R(t);
switch (e.currentChar()) {
case "{":
return B(e, t) || R(t);
case "}":
return T(d.UNBALANCED_CLOSING_BRACE, u(), 0), e.next(), A(
t,
3,
"}"
/* TokenChars.BraceRight */
);
case "@":
return $(e, t) || R(t);
default: {
if (g(e))
return i = A(t, 1, V(e)), t.braceNest = 0, t.inLinked = !1, i;
if (F(e))
return A(t, 0, Ee(e));
break;
}
}
return i;
}
function Ae() {
const { currentType: e, offset: t, startLoc: i, endLoc: f } = h;
return h.lastType = e, h.lastOffset = t, h.lastStartLoc = i, h.lastEndLoc = f, h.offset = _(), h.startLoc = u(), l.currentChar() === Y ? A(
h,
13
/* TokenTypes.EOF */
) : Q(l, h);
}
return {
nextToken: Ae,
currentOffset: _,
currentPosition: u,
context: y
};
}
const Me = "parser", Xe = /(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g;
function we(r, n, c) {
switch (r) {
case "\\\\":
return "\\";
// eslint-disable-next-line no-useless-escape
case "\\'":
return "'";
default: {
const l = parseInt(n || c, 16);
return l <= 55295 || l >= 57344 ? String.fromCodePoint(l) : "�";
}
}
}
function Ye(r = {}) {
const n = r.location !== !1, { onError: c } = r;
function l(s, a, E, o, ...L) {
const N = s.currentPosition();
if (N.offset += o, N.column += o, c) {
const p = n ? q(E, N) : null, w = G(a, p, {
domain: Me,
args: L
});
c(w);
}
}
function _(s, a, E) {
const o = { type: s };
return n && (o.start = a, o.end = a, o.loc = { start: E, end: E }), o;
}
function u(s, a, E, o) {
n && (s.end = a, s.loc && (s.loc.end = E));
}
function S(s, a) {
const E = s.context(), o = _(3, E.offset, E.startLoc);
return o.value = a, u(o, s.currentOffset(), s.currentPosition()), o;
}
function C(s, a) {
const E = s.context(), { lastOffset: o, lastStartLoc: L } = E, N = _(5, o, L);
return N.index = parseInt(a, 10), s.nextToken(), u(N, s.currentOffset(), s.currentPosition()), N;
}
function h(s, a) {
const E = s.context(), { lastOffset: o, lastStartLoc: L } = E, N = _(4, o, L);
return N.key = a, s.nextToken(), u(N, s.currentOffset(), s.currentPosition()), N;
}
function y(s, a) {
const E = s.context(), { lastOffset: o, lastStartLoc: L } = E, N = _(9, o, L);
return N.value = a.replace(Xe, we), s.nextToken(), u(N, s.currentOffset(), s.currentPosition()), N;
}
function b(s) {
const a = s.nextToken(), E = s.context(), { lastOffset: o, lastStartLoc: L } = E, N = _(8, o, L);
return a.type !== 11 ? (l(s, d.UNEXPECTED_EMPTY_LINKED_MODIFIER, E.lastStartLoc, 0), N.value = "", u(N, o, L), {
nextConsumeToken: a,
node: N
}) : (a.value == null && l(s, d.UNEXPECTED_LEXICAL_ANALYSIS, E.lastStartLoc, 0, M(a)), N.value = a.value || "", u(N, s.currentOffset(), s.currentPosition()), {
node: N
});
}
function T(s, a) {
const E = s.context(), o = _(7, E.offset, E.startLoc);
return o.value = a, u(o, s.currentOffset(), s.currentPosition()), o;
}
function A(s) {
const a = s.context(), E = _(6, a.offset, a.startLoc);
let o = s.nextToken();
if (o.type === 8) {
const L = b(s);
E.modifier = L.node, o = L.nextConsumeToken || s.nextToken();
}
switch (o.type !== 9 && l(s, d.UNEXPECTED_LEXICAL_ANALYSIS, a.lastStartLoc, 0, M(o)), o = s.nextToken(), o.type === 2 && (o = s.nextToken()), o.type) {
case 10:
o.value == null && l(s, d.UNEXPECTED_LEXICAL_ANALYSIS, a.lastStartLoc, 0, M(o)), E.key = T(s, o.value || "");
break;
case 4:
o.value == null && l(s, d.UNEXPECTED_LEXICAL_ANALYSIS, a.lastStartLoc, 0, M(o)), E.key = h(s, o.value || "");
break;
case 5:
o.value == null && l(s, d.UNEXPECTED_LEXICAL_ANALYSIS, a.lastStartLoc, 0, M(o)), E.key = C(s, o.value || "");
break;
case 6:
o.value == null && l(s, d.UNEXPECTED_LEXICAL_ANALYSIS, a.lastStartLoc, 0, M(o)), E.key = y(s, o.value || "");
break;
default: {
l(s, d.UNEXPECTED_EMPTY_LINKED_KEY, a.lastStartLoc, 0);
const L = s.context(), N = _(7, L.offset, L.startLoc);
return N.value = "", u(N, L.offset, L.startLoc), E.key = N, u(E, L.offset, L.startLoc), {
nextConsumeToken: o,
node: E
};
}
}
return u(E, s.currentOffset(), s.currentPosition()), {
node: E
};
}
function R(s) {
const a = s.context(), E = a.currentType === 1 ? s.currentOffset() : a.offset, o = a.currentType === 1 ? a.endLoc : a.startLoc, L = _(2, E, o);
L.items = [];
let N = null;
do {
const O = N || s.nextToken();
switch (N = null, O.type) {
case 0:
O.value == null && l(s, d.UNEXPECTED_LEXICAL_ANALYSIS, a.lastStartLoc, 0, M(O)), L.items.push(S(s, O.value || ""));
break;
case 5:
O.value == null && l(s, d.UNEXPECTED_LEXICAL_ANALYSIS, a.lastStartLoc, 0, M(O)), L.items.push(C(s, O.value || ""));
break;
case 4:
O.value == null && l(s, d.UNEXPECTED_LEXICAL_ANALYSIS, a.lastStartLoc, 0, M(O)), L.items.push(h(s, O.value || ""));
break;
case 6:
O.value == null && l(s, d.UNEXPECTED_LEXICAL_ANALYSIS, a.lastStartLoc, 0, M(O)), L.items.push(y(s, O.value || ""));
break;
case 7: {
const g = A(s);
L.items.push(g.node), N = g.nextConsumeToken || null;
break;
}
}
} while (a.currentType !== 13 && a.currentType !== 1);
const p = a.currentType === 1 ? a.lastOffset : s.currentOffset(), w = a.currentType === 1 ? a.lastEndLoc : s.currentPosition();
return u(L, p, w), L;
}
function v(s, a, E, o) {
const L = s.context();
let N = o.items.length === 0;
const p = _(1, a, E);
p.cases = [], p.cases.push(o);
do {
const w = R(s);
N || (N = w.items.length === 0), p.cases.push(w);
} while (L.currentType !== 13);
return N && l(s, d.MUST_HAVE_MESSAGES_IN_PLURAL, E, 0), u(p, s.currentOffset(), s.currentPosition()), p;
}
function P(s) {
const a = s.context(), { offset: E, startLoc: o } = a, L = R(s);
return a.currentType === 13 ? L : v(s, E, o, L);
}
function I(s) {
const a = ve(s, ne({}, r)), E = a.context(), o = _(0, E.offset, E.startLoc);
return n && o.loc && (o.loc.source = s), o.body = P(a), r.onCacheKey && (o.cacheKey = r.onCacheKey(s)), E.currentType !== 13 && l(a, d.UNEXPECTED_LEXICAL_ANALYSIS, E.lastStartLoc, 0, s[E.offset] || ""), u(o, a.currentOffset(), a.currentPosition()), o;
}
return { parse: I };
}
function M(r) {
if (r.type === 13)
return "EOF";
const n = (r.value || "").replace(/\r?\n/gu, "\\n");
return n.length > 10 ? n.slice(0, 9) + "…" : n;
}
function ge(r, n = {}) {
const c = {
ast: r,
helpers: /* @__PURE__ */ new Set()
};
return { context: () => c, helper: (u) => (c.helpers.add(u), u) };
}
function ee(r, n) {
for (let c = 0; c < r.length; c++)
W(r[c], n);
}
function W(r, n) {
switch (r.type) {
case 1:
ee(r.cases, n), n.helper(
"plural"
/* HelperNameMap.PLURAL */
);
break;
case 2:
ee(r.items, n);
break;
case 6: {
W(r.key, n), n.helper(
"linked"
/* HelperNameMap.LINKED */
), n.helper(
"type"
/* HelperNameMap.TYPE */
);
break;
}
case 5:
n.helper(
"interpolate"
/* HelperNameMap.INTERPOLATE */
), n.helper(
"list"
/* HelperNameMap.LIST */
);
break;
case 4:
n.helper(
"interpolate"
/* HelperNameMap.INTERPOLATE */
), n.helper(
"named"
/* HelperNameMap.NAMED */
);
break;
}
}
function He(r, n = {}) {
const c = ge(r);
c.helper(
"normalize"
/* HelperNameMap.NORMALIZE */
), r.body && W(r.body, c);
const l = c.context();
r.helpers = Array.from(l.helpers);
}
function Ke(r) {
const n = r.body;
return n.type === 2 ? te(n) : n.cases.forEach((c) => te(c)), r;
}
function te(r) {
if (r.items.length === 1) {
const n = r.items[0];
(n.type === 3 || n.type === 9) && (r.static = n.value, delete n.value);
} else {
const n = [];
for (let c = 0; c < r.items.length; c++) {
const l = r.items[c];
if (!(l.type === 3 || l.type === 9) || l.value == null)
break;
n.push(l.value);
}
if (n.length === r.items.length) {
r.static = re(n);
for (let c = 0; c < r.items.length; c++) {
const l = r.items[c];
(l.type === 3 || l.type === 9) && delete l.value;
}
}
}
}
const xe = "minifier";
function K(r) {
switch (r.t = r.type, r.type) {
case 0: {
const n = r;
K(n.body), n.b = n.body, delete n.body;
break;
}
case 1: {
const n = r, c = n.cases;
for (let l = 0; l < c.length; l++)
K(c[l]);
n.c = c, delete n.cases;
break;
}
case 2: {
const n = r, c = n.items;
for (let l = 0; l < c.length; l++)
K(c[l]);
n.i = c, delete n.items, n.static && (n.s = n.static, delete n.static);
break;
}
case 3:
case 9:
case 8:
case 7: {
const n = r;
n.value && (n.v = n.value, delete n.value);
break;
}
case 6: {
const n = r;
K(n.key), n.k = n.key, delete n.key, n.modifier && (K(n.modifier), n.m = n.modifier, delete n.modifier);
break;
}
case 5: {
const n = r;
n.i = n.index, delete n.index;
break;
}
case 4: {
const n = r;
n.k = n.key, delete n.key;
break;
}
default:
if (process.env.NODE_ENV !== "production")
throw G(d.UNHANDLED_MINIFIER_NODE_TYPE, null, {
domain: xe,
args: [r.type]
});
}
delete r.type;
}
const $e = "parser";
function Ge(r, n) {
const { sourceMap: c, filename: l, breakLineCode: _, needIndent: u } = n, S = n.location !== !1, C = {
filename: l,
code: "",
column: 1,
line: 1,
offset: 0,
map: void 0,
breakLineCode: _,
needIndent: u,
indentLevel: 0
};
S && r.loc && (C.source = r.loc.source);
const h = () => C;
function y(I, s) {
C.code += I;
}
function b(I, s = !0) {
const a = s ? _ : "";
y(u ? a + " ".repeat(I) : a);
}
function T(I = !0) {
const s = ++C.indentLevel;
I && b(s);
}
function A(I = !0) {
const s = --C.indentLevel;
I && b(s);
}
function R() {
b(C.indentLevel);
}
return {
context: h,
push: y,
indent: T,
deindent: A,
newline: R,
helper: (I) => `_${I}`,
needIndent: () => C.needIndent
};
}
function Fe(r, n) {
const { helper: c } = r;
r.push(`${c(
"linked"
/* HelperNameMap.LINKED */
)}(`), x(r, n.key), n.modifier ? (r.push(", "), x(r, n.modifier), r.push(", _type")) : r.push(", undefined, _type"), r.push(")");
}
function Ve(r, n) {
const { helper: c, needIndent: l } = r;
r.push(`${c(
"normalize"
/* HelperNameMap.NORMALIZE */
)}([`), r.indent(l());
const _ = n.items.length;
for (let u = 0; u < _ && (x(r, n.items[u]), u !== _ - 1); u++)
r.push(", ");
r.deindent(l()), r.push("])");
}
function Be(r, n) {
const { helper: c, needIndent: l } = r;
if (n.cases.length > 1) {
r.push(`${c(
"plural"
/* HelperNameMap.PLURAL */
)}([`), r.indent(l());
const _ = n.cases.length;
for (let u = 0; u < _ && (x(r, n.cases[u]), u !== _ - 1); u++)
r.push(", ");
r.deindent(l()), r.push("])");
}
}
function Qe(r, n) {
n.body ? x(r, n.body) : r.push("null");
}
function x(r, n) {
const { helper: c } = r;
switch (n.type) {
case 0:
Qe(r, n);
break;
case 1:
Be(r, n);
break;
case 2:
Ve(r, n);
break;
case 6:
Fe(r, n);
break;
case 8:
r.push(JSON.stringify(n.value), n);
break;
case 7:
r.push(JSON.stringify(n.value), n);
break;
case 5:
r.push(`${c(
"interpolate"
/* HelperNameMap.INTERPOLATE */
)}(${c(
"list"
/* HelperNameMap.LIST */
)}(${n.index}))`, n);
break;
case 4:
r.push(`${c(
"interpolate"
/* HelperNameMap.INTERPOLATE */
)}(${c(
"named"
/* HelperNameMap.NAMED */
)}(${JSON.stringify(n.key)}))`, n);
break;
case 9:
r.push(JSON.stringify(n.value), n);
break;
case 3:
r.push(JSON.stringify(n.value), n);
break;
default:
if (process.env.NODE_ENV !== "production")
throw G(d.UNHANDLED_CODEGEN_NODE_TYPE, null, {
domain: $e,
args: [n.type]
});
}
}
const qe = (r, n = {}) => {
const c = Z(n.mode) ? n.mode : "normal", l = Z(n.filename) ? n.filename : "message.intl", _ = !!n.sourceMap, u = n.breakLineCode != null ? n.breakLineCode : c === "arrow" ? ";" : `
`, S = n.needIndent ? n.needIndent : c !== "arrow", C = r.helpers || [], h = Ge(r, {
mode: c,
filename: l,
sourceMap: _,
breakLineCode: u,
needIndent: S
});
h.push(c === "normal" ? "function __msg__ (ctx) {" : "(ctx) => {"), h.indent(S), C.length > 0 && (h.push(`const { ${re(C.map((T) => `${T}: _${T}`), ", ")} } = ctx`), h.newline()), h.push("return "), x(h, r), h.deindent(S), h.push("}"), delete r.helpers;
const { code: y, map: b } = h.context();
return {
ast: r,
code: y,
map: b ? b.toJSON() : void 0
// eslint-disable-line @typescript-eslint/no-explicit-any
};
};
function ze(r, n = {}) {
const c = ne({}, n), l = !!c.jit, _ = !!c.minify, u = c.optimize == null ? !0 : c.optimize, C = Ye(c).parse(r);
return l ? (u && Ke(C), _ && K(C), { ast: C, code: "" }) : (He(C, c), qe(C, c));
}
export {
Je as C,
je as a,
ze as b,
G as c,
Ze as d
};