文件操作 - @intlify_core-base.js
返回文件管理
返回主菜单
删除本文件
文件: /var/www/OLD/node_modules/.cache/vite/client/deps/@intlify_core-base.js
编辑文件内容
import { assign, create, escapeHtml, format, generateCodeFrame, generateFormatCacheKey, getGlobalThis, hasOwn, inBrowser, isArray, isBoolean, isDate, isEmptyObject, isFunction, isNumber, isObject, isPlainObject, isPromise, isRegExp, isString, join, mark, measure, toDisplayString, warn, warnOnce } from "./chunk-WOXX43OJ.js"; // node_modules/@intlify/message-compiler/dist/message-compiler.mjs function createPosition(line, column, offset) { return { line, column, offset }; } function createLocation(start, end, source) { const loc = { start, end }; if (source != null) { loc.source = source; } return loc; } var CompileErrorCodes = { // 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 }; var COMPILE_ERROR_CODES_EXTEND_POINT = 17; var errorMessages = { // tokenizer error messages [CompileErrorCodes.EXPECTED_TOKEN]: `Expected token: '{0}'`, [CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER]: `Invalid token in placeholder: '{0}'`, [CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER]: `Unterminated single quote in placeholder`, [CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE]: `Unknown escape sequence: \\{0}`, [CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE]: `Invalid unicode escape sequence: {0}`, [CompileErrorCodes.UNBALANCED_CLOSING_BRACE]: `Unbalanced closing brace`, [CompileErrorCodes.UNTERMINATED_CLOSING_BRACE]: `Unterminated closing brace`, [CompileErrorCodes.EMPTY_PLACEHOLDER]: `Empty placeholder`, [CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER]: `Not allowed nest placeholder`, [CompileErrorCodes.INVALID_LINKED_FORMAT]: `Invalid linked format`, // parser error messages [CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL]: `Plural must have messages`, [CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER]: `Unexpected empty linked modifier`, [CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY]: `Unexpected empty linked key`, [CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS]: `Unexpected lexical analysis in token: '{0}'`, // generator error messages [CompileErrorCodes.UNHANDLED_CODEGEN_NODE_TYPE]: `unhandled codegen node type: '{0}'`, // minimizer error messages [CompileErrorCodes.UNHANDLED_MINIFIER_NODE_TYPE]: `unhandled mimifier node type: '{0}'` }; function createCompileError(code, loc, options = {}) { const { domain, messages, args } = options; const msg = true ? format((messages || errorMessages)[code] || "", ...args || []) : code; const error = new SyntaxError(String(msg)); error.code = code; if (loc) { error.location = loc; } error.domain = domain; return error; } function defaultOnError(error) { throw error; } var RE_HTML_TAG = /<\/?[\w\s="/.':;#-\/]+>/; var detectHtmlTag = (source) => RE_HTML_TAG.test(source); var CHAR_SP = " "; var CHAR_CR = "\r"; var CHAR_LF = "\n"; var CHAR_LS = String.fromCharCode(8232); var CHAR_PS = String.fromCharCode(8233); function createScanner(str) { const _buf = str; let _index = 0; let _line = 1; let _column = 1; let _peekOffset = 0; const isCRLF = (index2) => _buf[index2] === CHAR_CR && _buf[index2 + 1] === CHAR_LF; const isLF = (index2) => _buf[index2] === CHAR_LF; const isPS = (index2) => _buf[index2] === CHAR_PS; const isLS = (index2) => _buf[index2] === CHAR_LS; const isLineEnd = (index2) => isCRLF(index2) || isLF(index2) || isPS(index2) || isLS(index2); const index = () => _index; const line = () => _line; const column = () => _column; const peekOffset = () => _peekOffset; const charAt = (offset) => isCRLF(offset) || isPS(offset) || isLS(offset) ? CHAR_LF : _buf[offset]; const currentChar = () => charAt(_index); const currentPeek = () => charAt(_index + _peekOffset); function next() { _peekOffset = 0; if (isLineEnd(_index)) { _line++; _column = 0; } if (isCRLF(_index)) { _index++; } _index++; _column++; return _buf[_index]; } function peek() { if (isCRLF(_index + _peekOffset)) { _peekOffset++; } _peekOffset++; return _buf[_index + _peekOffset]; } function reset() { _index = 0; _line = 1; _column = 1; _peekOffset = 0; } function resetPeek(offset = 0) { _peekOffset = offset; } function skipToPeek() { const target = _index + _peekOffset; while (target !== _index) { next(); } _peekOffset = 0; } return { index, line, column, peekOffset, charAt, currentChar, currentPeek, next, peek, reset, resetPeek, skipToPeek }; } var EOF = void 0; var DOT = "."; var LITERAL_DELIMITER = "'"; var ERROR_DOMAIN$3 = "tokenizer"; function createTokenizer(source, options = {}) { const location = options.location !== false; const _scnr = createScanner(source); const currentOffset = () => _scnr.index(); const currentPosition = () => createPosition(_scnr.line(), _scnr.column(), _scnr.index()); const _initLoc = currentPosition(); const _initOffset = currentOffset(); const _context = { currentType: 13, offset: _initOffset, startLoc: _initLoc, endLoc: _initLoc, lastType: 13, lastOffset: _initOffset, lastStartLoc: _initLoc, lastEndLoc: _initLoc, braceNest: 0, inLinked: false, text: "" }; const context = () => _context; const { onError } = options; function emitError(code, pos, offset, ...args) { const ctx = context(); pos.column += offset; pos.offset += offset; if (onError) { const loc = location ? createLocation(ctx.startLoc, pos) : null; const err = createCompileError(code, loc, { domain: ERROR_DOMAIN$3, args }); onError(err); } } function getToken(context2, type, value) { context2.endLoc = currentPosition(); context2.currentType = type; const token = { type }; if (location) { token.loc = createLocation(context2.startLoc, context2.endLoc); } if (value != null) { token.value = value; } return token; } const getEndToken = (context2) => getToken( context2, 13 /* TokenTypes.EOF */ ); function eat(scnr, ch) { if (scnr.currentChar() === ch) { scnr.next(); return ch; } else { emitError(CompileErrorCodes.EXPECTED_TOKEN, currentPosition(), 0, ch); return ""; } } function peekSpaces(scnr) { let buf = ""; while (scnr.currentPeek() === CHAR_SP || scnr.currentPeek() === CHAR_LF) { buf += scnr.currentPeek(); scnr.peek(); } return buf; } function skipSpaces(scnr) { const buf = peekSpaces(scnr); scnr.skipToPeek(); return buf; } function isIdentifierStart(ch) { if (ch === EOF) { return false; } const cc = ch.charCodeAt(0); return cc >= 97 && cc <= 122 || // a-z cc >= 65 && cc <= 90 || // A-Z cc === 95; } function isNumberStart(ch) { if (ch === EOF) { return false; } const cc = ch.charCodeAt(0); return cc >= 48 && cc <= 57; } function isNamedIdentifierStart(scnr, context2) { const { currentType } = context2; if (currentType !== 2) { return false; } peekSpaces(scnr); const ret = isIdentifierStart(scnr.currentPeek()); scnr.resetPeek(); return ret; } function isListIdentifierStart(scnr, context2) { const { currentType } = context2; if (currentType !== 2) { return false; } peekSpaces(scnr); const ch = scnr.currentPeek() === "-" ? scnr.peek() : scnr.currentPeek(); const ret = isNumberStart(ch); scnr.resetPeek(); return ret; } function isLiteralStart(scnr, context2) { const { currentType } = context2; if (currentType !== 2) { return false; } peekSpaces(scnr); const ret = scnr.currentPeek() === LITERAL_DELIMITER; scnr.resetPeek(); return ret; } function isLinkedDotStart(scnr, context2) { const { currentType } = context2; if (currentType !== 7) { return false; } peekSpaces(scnr); const ret = scnr.currentPeek() === "."; scnr.resetPeek(); return ret; } function isLinkedModifierStart(scnr, context2) { const { currentType } = context2; if (currentType !== 8) { return false; } peekSpaces(scnr); const ret = isIdentifierStart(scnr.currentPeek()); scnr.resetPeek(); return ret; } function isLinkedDelimiterStart(scnr, context2) { const { currentType } = context2; if (!(currentType === 7 || currentType === 11)) { return false; } peekSpaces(scnr); const ret = scnr.currentPeek() === ":"; scnr.resetPeek(); return ret; } function isLinkedReferStart(scnr, context2) { const { currentType } = context2; if (currentType !== 9) { return false; } const fn = () => { const ch = scnr.currentPeek(); if (ch === "{") { return isIdentifierStart(scnr.peek()); } else if (ch === "@" || ch === "|" || ch === ":" || ch === "." || ch === CHAR_SP || !ch) { return false; } else if (ch === CHAR_LF) { scnr.peek(); return fn(); } else { return isTextStart(scnr, false); } }; const ret = fn(); scnr.resetPeek(); return ret; } function isPluralStart(scnr) { peekSpaces(scnr); const ret = scnr.currentPeek() === "|"; scnr.resetPeek(); return ret; } function isTextStart(scnr, reset = true) { const fn = (hasSpace = false, prev = "") => { const ch = scnr.currentPeek(); if (ch === "{") { return hasSpace; } else if (ch === "@" || !ch) { return hasSpace; } else if (ch === "|") { return !(prev === CHAR_SP || prev === CHAR_LF); } else if (ch === CHAR_SP) { scnr.peek(); return fn(true, CHAR_SP); } else if (ch === CHAR_LF) { scnr.peek(); return fn(true, CHAR_LF); } else { return true; } }; const ret = fn(); reset && scnr.resetPeek(); return ret; } function takeChar(scnr, fn) { const ch = scnr.currentChar(); if (ch === EOF) { return EOF; } if (fn(ch)) { scnr.next(); return ch; } return null; } function isIdentifier(ch) { const cc = ch.charCodeAt(0); return cc >= 97 && cc <= 122 || // a-z cc >= 65 && cc <= 90 || // A-Z cc >= 48 && cc <= 57 || // 0-9 cc === 95 || // _ cc === 36; } function takeIdentifierChar(scnr) { return takeChar(scnr, isIdentifier); } function isNamedIdentifier(ch) { const cc = ch.charCodeAt(0); return cc >= 97 && cc <= 122 || // a-z cc >= 65 && cc <= 90 || // A-Z cc >= 48 && cc <= 57 || // 0-9 cc === 95 || // _ cc === 36 || // $ cc === 45; } function takeNamedIdentifierChar(scnr) { return takeChar(scnr, isNamedIdentifier); } function isDigit(ch) { const cc = ch.charCodeAt(0); return cc >= 48 && cc <= 57; } function takeDigit(scnr) { return takeChar(scnr, isDigit); } function isHexDigit(ch) { const cc = ch.charCodeAt(0); return cc >= 48 && cc <= 57 || // 0-9 cc >= 65 && cc <= 70 || // A-F cc >= 97 && cc <= 102; } function takeHexDigit(scnr) { return takeChar(scnr, isHexDigit); } function getDigits(scnr) { let ch = ""; let num = ""; while (ch = takeDigit(scnr)) { num += ch; } return num; } function readText(scnr) { let buf = ""; while (true) { const ch = scnr.currentChar(); if (ch === "{" || ch === "}" || ch === "@" || ch === "|" || !ch) { break; } else if (ch === CHAR_SP || ch === CHAR_LF) { if (isTextStart(scnr)) { buf += ch; scnr.next(); } else if (isPluralStart(scnr)) { break; } else { buf += ch; scnr.next(); } } else { buf += ch; scnr.next(); } } return buf; } function readNamedIdentifier(scnr) { skipSpaces(scnr); let ch = ""; let name = ""; while (ch = takeNamedIdentifierChar(scnr)) { name += ch; } if (scnr.currentChar() === EOF) { emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); } return name; } function readListIdentifier(scnr) { skipSpaces(scnr); let value = ""; if (scnr.currentChar() === "-") { scnr.next(); value += `-${getDigits(scnr)}`; } else { value += getDigits(scnr); } if (scnr.currentChar() === EOF) { emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); } return value; } function isLiteral2(ch) { return ch !== LITERAL_DELIMITER && ch !== CHAR_LF; } function readLiteral(scnr) { skipSpaces(scnr); eat(scnr, `'`); let ch = ""; let literal = ""; while (ch = takeChar(scnr, isLiteral2)) { if (ch === "\\") { literal += readEscapeSequence(scnr); } else { literal += ch; } } const current = scnr.currentChar(); if (current === CHAR_LF || current === EOF) { emitError(CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER, currentPosition(), 0); if (current === CHAR_LF) { scnr.next(); eat(scnr, `'`); } return literal; } eat(scnr, `'`); return literal; } function readEscapeSequence(scnr) { const ch = scnr.currentChar(); switch (ch) { case "\\": case `'`: scnr.next(); return `\\${ch}`; case "u": return readUnicodeEscapeSequence(scnr, ch, 4); case "U": return readUnicodeEscapeSequence(scnr, ch, 6); default: emitError(CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE, currentPosition(), 0, ch); return ""; } } function readUnicodeEscapeSequence(scnr, unicode, digits) { eat(scnr, unicode); let sequence = ""; for (let i = 0; i < digits; i++) { const ch = takeHexDigit(scnr); if (!ch) { emitError(CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE, currentPosition(), 0, `\\${unicode}${sequence}${scnr.currentChar()}`); break; } sequence += ch; } return `\\${unicode}${sequence}`; } function isInvalidIdentifier(ch) { return ch !== "{" && ch !== "}" && ch !== CHAR_SP && ch !== CHAR_LF; } function readInvalidIdentifier(scnr) { skipSpaces(scnr); let ch = ""; let identifiers = ""; while (ch = takeChar(scnr, isInvalidIdentifier)) { identifiers += ch; } return identifiers; } function readLinkedModifier(scnr) { let ch = ""; let name = ""; while (ch = takeIdentifierChar(scnr)) { name += ch; } return name; } function readLinkedRefer(scnr) { const fn = (buf) => { const ch = scnr.currentChar(); if (ch === "{" || ch === "@" || ch === "|" || ch === "(" || ch === ")" || !ch) { return buf; } else if (ch === CHAR_SP) { return buf; } else if (ch === CHAR_LF || ch === DOT) { buf += ch; scnr.next(); return fn(buf); } else { buf += ch; scnr.next(); return fn(buf); } }; return fn(""); } function readPlural(scnr) { skipSpaces(scnr); const plural = eat( scnr, "|" /* TokenChars.Pipe */ ); skipSpaces(scnr); return plural; } function readTokenInPlaceholder(scnr, context2) { let token = null; const ch = scnr.currentChar(); switch (ch) { case "{": if (context2.braceNest >= 1) { emitError(CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER, currentPosition(), 0); } scnr.next(); token = getToken( context2, 2, "{" /* TokenChars.BraceLeft */ ); skipSpaces(scnr); context2.braceNest++; return token; case "}": if (context2.braceNest > 0 && context2.currentType === 2) { emitError(CompileErrorCodes.EMPTY_PLACEHOLDER, currentPosition(), 0); } scnr.next(); token = getToken( context2, 3, "}" /* TokenChars.BraceRight */ ); context2.braceNest--; context2.braceNest > 0 && skipSpaces(scnr); if (context2.inLinked && context2.braceNest === 0) { context2.inLinked = false; } return token; case "@": if (context2.braceNest > 0) { emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); } token = readTokenInLinked(scnr, context2) || getEndToken(context2); context2.braceNest = 0; return token; default: { let validNamedIdentifier = true; let validListIdentifier = true; let validLiteral = true; if (isPluralStart(scnr)) { if (context2.braceNest > 0) { emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); } token = getToken(context2, 1, readPlural(scnr)); context2.braceNest = 0; context2.inLinked = false; return token; } if (context2.braceNest > 0 && (context2.currentType === 4 || context2.currentType === 5 || context2.currentType === 6)) { emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); context2.braceNest = 0; return readToken(scnr, context2); } if (validNamedIdentifier = isNamedIdentifierStart(scnr, context2)) { token = getToken(context2, 4, readNamedIdentifier(scnr)); skipSpaces(scnr); return token; } if (validListIdentifier = isListIdentifierStart(scnr, context2)) { token = getToken(context2, 5, readListIdentifier(scnr)); skipSpaces(scnr); return token; } if (validLiteral = isLiteralStart(scnr, context2)) { token = getToken(context2, 6, readLiteral(scnr)); skipSpaces(scnr); return token; } if (!validNamedIdentifier && !validListIdentifier && !validLiteral) { token = getToken(context2, 12, readInvalidIdentifier(scnr)); emitError(CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER, currentPosition(), 0, token.value); skipSpaces(scnr); return token; } break; } } return token; } function readTokenInLinked(scnr, context2) { const { currentType } = context2; let token = null; const ch = scnr.currentChar(); if ((currentType === 7 || currentType === 8 || currentType === 11 || currentType === 9) && (ch === CHAR_LF || ch === CHAR_SP)) { emitError(CompileErrorCodes.INVALID_LINKED_FORMAT, currentPosition(), 0); } switch (ch) { case "@": scnr.next(); token = getToken( context2, 7, "@" /* TokenChars.LinkedAlias */ ); context2.inLinked = true; return token; case ".": skipSpaces(scnr); scnr.next(); return getToken( context2, 8, "." /* TokenChars.LinkedDot */ ); case ":": skipSpaces(scnr); scnr.next(); return getToken( context2, 9, ":" /* TokenChars.LinkedDelimiter */ ); default: if (isPluralStart(scnr)) { token = getToken(context2, 1, readPlural(scnr)); context2.braceNest = 0; context2.inLinked = false; return token; } if (isLinkedDotStart(scnr, context2) || isLinkedDelimiterStart(scnr, context2)) { skipSpaces(scnr); return readTokenInLinked(scnr, context2); } if (isLinkedModifierStart(scnr, context2)) { skipSpaces(scnr); return getToken(context2, 11, readLinkedModifier(scnr)); } if (isLinkedReferStart(scnr, context2)) { skipSpaces(scnr); if (ch === "{") { return readTokenInPlaceholder(scnr, context2) || token; } else { return getToken(context2, 10, readLinkedRefer(scnr)); } } if (currentType === 7) { emitError(CompileErrorCodes.INVALID_LINKED_FORMAT, currentPosition(), 0); } context2.braceNest = 0; context2.inLinked = false; return readToken(scnr, context2); } } function readToken(scnr, context2) { let token = { type: 13 /* TokenTypes.EOF */ }; if (context2.braceNest > 0) { return readTokenInPlaceholder(scnr, context2) || getEndToken(context2); } if (context2.inLinked) { return readTokenInLinked(scnr, context2) || getEndToken(context2); } const ch = scnr.currentChar(); switch (ch) { case "{": return readTokenInPlaceholder(scnr, context2) || getEndToken(context2); case "}": emitError(CompileErrorCodes.UNBALANCED_CLOSING_BRACE, currentPosition(), 0); scnr.next(); return getToken( context2, 3, "}" /* TokenChars.BraceRight */ ); case "@": return readTokenInLinked(scnr, context2) || getEndToken(context2); default: { if (isPluralStart(scnr)) { token = getToken(context2, 1, readPlural(scnr)); context2.braceNest = 0; context2.inLinked = false; return token; } if (isTextStart(scnr)) { return getToken(context2, 0, readText(scnr)); } break; } } return token; } function nextToken() { const { currentType, offset, startLoc, endLoc } = _context; _context.lastType = currentType; _context.lastOffset = offset; _context.lastStartLoc = startLoc; _context.lastEndLoc = endLoc; _context.offset = currentOffset(); _context.startLoc = currentPosition(); if (_scnr.currentChar() === EOF) { return getToken( _context, 13 /* TokenTypes.EOF */ ); } return readToken(_scnr, _context); } return { nextToken, currentOffset, currentPosition, context }; } var ERROR_DOMAIN$2 = "parser"; var KNOWN_ESCAPES = /(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g; function fromEscapeSequence(match, codePoint4, codePoint6) { switch (match) { case `\\\\`: return `\\`; // eslint-disable-next-line no-useless-escape case `\\'`: return `'`; default: { const codePoint = parseInt(codePoint4 || codePoint6, 16); if (codePoint <= 55295 || codePoint >= 57344) { return String.fromCodePoint(codePoint); } return "�"; } } } function createParser(options = {}) { const location = options.location !== false; const { onError } = options; function emitError(tokenzer, code, start, offset, ...args) { const end = tokenzer.currentPosition(); end.offset += offset; end.column += offset; if (onError) { const loc = location ? createLocation(start, end) : null; const err = createCompileError(code, loc, { domain: ERROR_DOMAIN$2, args }); onError(err); } } function startNode(type, offset, loc) { const node = { type }; if (location) { node.start = offset; node.end = offset; node.loc = { start: loc, end: loc }; } return node; } function endNode(node, offset, pos, type) { if (location) { node.end = offset; if (node.loc) { node.loc.end = pos; } } } function parseText(tokenizer, value) { const context = tokenizer.context(); const node = startNode(3, context.offset, context.startLoc); node.value = value; endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); return node; } function parseList(tokenizer, index) { const context = tokenizer.context(); const { lastOffset: offset, lastStartLoc: loc } = context; const node = startNode(5, offset, loc); node.index = parseInt(index, 10); tokenizer.nextToken(); endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); return node; } function parseNamed(tokenizer, key) { const context = tokenizer.context(); const { lastOffset: offset, lastStartLoc: loc } = context; const node = startNode(4, offset, loc); node.key = key; tokenizer.nextToken(); endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); return node; } function parseLiteral(tokenizer, value) { const context = tokenizer.context(); const { lastOffset: offset, lastStartLoc: loc } = context; const node = startNode(9, offset, loc); node.value = value.replace(KNOWN_ESCAPES, fromEscapeSequence); tokenizer.nextToken(); endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); return node; } function parseLinkedModifier(tokenizer) { const token = tokenizer.nextToken(); const context = tokenizer.context(); const { lastOffset: offset, lastStartLoc: loc } = context; const node = startNode(8, offset, loc); if (token.type !== 11) { emitError(tokenizer, CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER, context.lastStartLoc, 0); node.value = ""; endNode(node, offset, loc); return { nextConsumeToken: token, node }; } if (token.value == null) { emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); } node.value = token.value || ""; endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); return { node }; } function parseLinkedKey(tokenizer, value) { const context = tokenizer.context(); const node = startNode(7, context.offset, context.startLoc); node.value = value; endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); return node; } function parseLinked(tokenizer) { const context = tokenizer.context(); const linkedNode = startNode(6, context.offset, context.startLoc); let token = tokenizer.nextToken(); if (token.type === 8) { const parsed = parseLinkedModifier(tokenizer); linkedNode.modifier = parsed.node; token = parsed.nextConsumeToken || tokenizer.nextToken(); } if (token.type !== 9) { emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); } token = tokenizer.nextToken(); if (token.type === 2) { token = tokenizer.nextToken(); } switch (token.type) { case 10: if (token.value == null) { emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); } linkedNode.key = parseLinkedKey(tokenizer, token.value || ""); break; case 4: if (token.value == null) { emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); } linkedNode.key = parseNamed(tokenizer, token.value || ""); break; case 5: if (token.value == null) { emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); } linkedNode.key = parseList(tokenizer, token.value || ""); break; case 6: if (token.value == null) { emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); } linkedNode.key = parseLiteral(tokenizer, token.value || ""); break; default: { emitError(tokenizer, CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY, context.lastStartLoc, 0); const nextContext = tokenizer.context(); const emptyLinkedKeyNode = startNode(7, nextContext.offset, nextContext.startLoc); emptyLinkedKeyNode.value = ""; endNode(emptyLinkedKeyNode, nextContext.offset, nextContext.startLoc); linkedNode.key = emptyLinkedKeyNode; endNode(linkedNode, nextContext.offset, nextContext.startLoc); return { nextConsumeToken: token, node: linkedNode }; } } endNode(linkedNode, tokenizer.currentOffset(), tokenizer.currentPosition()); return { node: linkedNode }; } function parseMessage(tokenizer) { const context = tokenizer.context(); const startOffset = context.currentType === 1 ? tokenizer.currentOffset() : context.offset; const startLoc = context.currentType === 1 ? context.endLoc : context.startLoc; const node = startNode(2, startOffset, startLoc); node.items = []; let nextToken = null; do { const token = nextToken || tokenizer.nextToken(); nextToken = null; switch (token.type) { case 0: if (token.value == null) { emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); } node.items.push(parseText(tokenizer, token.value || "")); break; case 5: if (token.value == null) { emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); } node.items.push(parseList(tokenizer, token.value || "")); break; case 4: if (token.value == null) { emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); } node.items.push(parseNamed(tokenizer, token.value || "")); break; case 6: if (token.value == null) { emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); } node.items.push(parseLiteral(tokenizer, token.value || "")); break; case 7: { const parsed = parseLinked(tokenizer); node.items.push(parsed.node); nextToken = parsed.nextConsumeToken || null; break; } } } while (context.currentType !== 13 && context.currentType !== 1); const endOffset = context.currentType === 1 ? context.lastOffset : tokenizer.currentOffset(); const endLoc = context.currentType === 1 ? context.lastEndLoc : tokenizer.currentPosition(); endNode(node, endOffset, endLoc); return node; } function parsePlural(tokenizer, offset, loc, msgNode) { const context = tokenizer.context(); let hasEmptyMessage = msgNode.items.length === 0; const node = startNode(1, offset, loc); node.cases = []; node.cases.push(msgNode); do { const msg = parseMessage(tokenizer); if (!hasEmptyMessage) { hasEmptyMessage = msg.items.length === 0; } node.cases.push(msg); } while (context.currentType !== 13); if (hasEmptyMessage) { emitError(tokenizer, CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL, loc, 0); } endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); return node; } function parseResource(tokenizer) { const context = tokenizer.context(); const { offset, startLoc } = context; const msgNode = parseMessage(tokenizer); if (context.currentType === 13) { return msgNode; } else { return parsePlural(tokenizer, offset, startLoc, msgNode); } } function parse2(source) { const tokenizer = createTokenizer(source, assign({}, options)); const context = tokenizer.context(); const node = startNode(0, context.offset, context.startLoc); if (location && node.loc) { node.loc.source = source; } node.body = parseResource(tokenizer); if (options.onCacheKey) { node.cacheKey = options.onCacheKey(source); } if (context.currentType !== 13) { emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, source[context.offset] || ""); } endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); return node; } return { parse: parse2 }; } function getTokenCaption(token) { if (token.type === 13) { return "EOF"; } const name = (token.value || "").replace(/\r?\n/gu, "\\n"); return name.length > 10 ? name.slice(0, 9) + "…" : name; } function createTransformer(ast, options = {}) { const _context = { ast, helpers: /* @__PURE__ */ new Set() }; const context = () => _context; const helper = (name) => { _context.helpers.add(name); return name; }; return { context, helper }; } function traverseNodes(nodes, transformer) { for (let i = 0; i < nodes.length; i++) { traverseNode(nodes[i], transformer); } } function traverseNode(node, transformer) { switch (node.type) { case 1: traverseNodes(node.cases, transformer); transformer.helper( "plural" /* HelperNameMap.PLURAL */ ); break; case 2: traverseNodes(node.items, transformer); break; case 6: { const linked = node; traverseNode(linked.key, transformer); transformer.helper( "linked" /* HelperNameMap.LINKED */ ); transformer.helper( "type" /* HelperNameMap.TYPE */ ); break; } case 5: transformer.helper( "interpolate" /* HelperNameMap.INTERPOLATE */ ); transformer.helper( "list" /* HelperNameMap.LIST */ ); break; case 4: transformer.helper( "interpolate" /* HelperNameMap.INTERPOLATE */ ); transformer.helper( "named" /* HelperNameMap.NAMED */ ); break; } } function transform(ast, options = {}) { const transformer = createTransformer(ast); transformer.helper( "normalize" /* HelperNameMap.NORMALIZE */ ); ast.body && traverseNode(ast.body, transformer); const context = transformer.context(); ast.helpers = Array.from(context.helpers); } function optimize(ast) { const body = ast.body; if (body.type === 2) { optimizeMessageNode(body); } else { body.cases.forEach((c) => optimizeMessageNode(c)); } return ast; } function optimizeMessageNode(message) { if (message.items.length === 1) { const item = message.items[0]; if (item.type === 3 || item.type === 9) { message.static = item.value; delete item.value; } } else { const values = []; for (let i = 0; i < message.items.length; i++) { const item = message.items[i]; if (!(item.type === 3 || item.type === 9)) { break; } if (item.value == null) { break; } values.push(item.value); } if (values.length === message.items.length) { message.static = join(values); for (let i = 0; i < message.items.length; i++) { const item = message.items[i]; if (item.type === 3 || item.type === 9) { delete item.value; } } } } } var ERROR_DOMAIN$1 = "minifier"; function minify(node) { node.t = node.type; switch (node.type) { case 0: { const resource = node; minify(resource.body); resource.b = resource.body; delete resource.body; break; } case 1: { const plural = node; const cases = plural.cases; for (let i = 0; i < cases.length; i++) { minify(cases[i]); } plural.c = cases; delete plural.cases; break; } case 2: { const message = node; const items = message.items; for (let i = 0; i < items.length; i++) { minify(items[i]); } message.i = items; delete message.items; if (message.static) { message.s = message.static; delete message.static; } break; } case 3: case 9: case 8: case 7: { const valueNode = node; if (valueNode.value) { valueNode.v = valueNode.value; delete valueNode.value; } break; } case 6: { const linked = node; minify(linked.key); linked.k = linked.key; delete linked.key; if (linked.modifier) { minify(linked.modifier); linked.m = linked.modifier; delete linked.modifier; } break; } case 5: { const list = node; list.i = list.index; delete list.index; break; } case 4: { const named = node; named.k = named.key; delete named.key; break; } default: if (true) { throw createCompileError(CompileErrorCodes.UNHANDLED_MINIFIER_NODE_TYPE, null, { domain: ERROR_DOMAIN$1, args: [node.type] }); } } delete node.type; } var ERROR_DOMAIN = "parser"; function createCodeGenerator(ast, options) { const { sourceMap, filename, breakLineCode, needIndent: _needIndent } = options; const location = options.location !== false; const _context = { filename, code: "", column: 1, line: 1, offset: 0, map: void 0, breakLineCode, needIndent: _needIndent, indentLevel: 0 }; if (location && ast.loc) { _context.source = ast.loc.source; } const context = () => _context; function push(code, node) { _context.code += code; } function _newline(n, withBreakLine = true) { const _breakLineCode = withBreakLine ? breakLineCode : ""; push(_needIndent ? _breakLineCode + ` `.repeat(n) : _breakLineCode); } function indent(withNewLine = true) { const level = ++_context.indentLevel; withNewLine && _newline(level); } function deindent(withNewLine = true) { const level = --_context.indentLevel; withNewLine && _newline(level); } function newline() { _newline(_context.indentLevel); } const helper = (key) => `_${key}`; const needIndent = () => _context.needIndent; return { context, push, indent, deindent, newline, helper, needIndent }; } function generateLinkedNode(generator, node) { const { helper } = generator; generator.push(`${helper( "linked" /* HelperNameMap.LINKED */ )}(`); generateNode(generator, node.key); if (node.modifier) { generator.push(`, `); generateNode(generator, node.modifier); generator.push(`, _type`); } else { generator.push(`, undefined, _type`); } generator.push(`)`); } function generateMessageNode(generator, node) { const { helper, needIndent } = generator; generator.push(`${helper( "normalize" /* HelperNameMap.NORMALIZE */ )}([`); generator.indent(needIndent()); const length = node.items.length; for (let i = 0; i < length; i++) { generateNode(generator, node.items[i]); if (i === length - 1) { break; } generator.push(", "); } generator.deindent(needIndent()); generator.push("])"); } function generatePluralNode(generator, node) { const { helper, needIndent } = generator; if (node.cases.length > 1) { generator.push(`${helper( "plural" /* HelperNameMap.PLURAL */ )}([`); generator.indent(needIndent()); const length = node.cases.length; for (let i = 0; i < length; i++) { generateNode(generator, node.cases[i]); if (i === length - 1) { break; } generator.push(", "); } generator.deindent(needIndent()); generator.push(`])`); } } function generateResource(generator, node) { if (node.body) { generateNode(generator, node.body); } else { generator.push("null"); } } function generateNode(generator, node) { const { helper } = generator; switch (node.type) { case 0: generateResource(generator, node); break; case 1: generatePluralNode(generator, node); break; case 2: generateMessageNode(generator, node); break; case 6: generateLinkedNode(generator, node); break; case 8: generator.push(JSON.stringify(node.value), node); break; case 7: generator.push(JSON.stringify(node.value), node); break; case 5: generator.push(`${helper( "interpolate" /* HelperNameMap.INTERPOLATE */ )}(${helper( "list" /* HelperNameMap.LIST */ )}(${node.index}))`, node); break; case 4: generator.push(`${helper( "interpolate" /* HelperNameMap.INTERPOLATE */ )}(${helper( "named" /* HelperNameMap.NAMED */ )}(${JSON.stringify(node.key)}))`, node); break; case 9: generator.push(JSON.stringify(node.value), node); break; case 3: generator.push(JSON.stringify(node.value), node); break; default: if (true) { throw createCompileError(CompileErrorCodes.UNHANDLED_CODEGEN_NODE_TYPE, null, { domain: ERROR_DOMAIN, args: [node.type] }); } } } var generate = (ast, options = {}) => { const mode = isString(options.mode) ? options.mode : "normal"; const filename = isString(options.filename) ? options.filename : "message.intl"; const sourceMap = !!options.sourceMap; const breakLineCode = options.breakLineCode != null ? options.breakLineCode : mode === "arrow" ? ";" : "\n"; const needIndent = options.needIndent ? options.needIndent : mode !== "arrow"; const helpers = ast.helpers || []; const generator = createCodeGenerator(ast, { mode, filename, sourceMap, breakLineCode, needIndent }); generator.push(mode === "normal" ? `function __msg__ (ctx) {` : `(ctx) => {`); generator.indent(needIndent); if (helpers.length > 0) { generator.push(`const { ${join(helpers.map((s) => `${s}: _${s}`), ", ")} } = ctx`); generator.newline(); } generator.push(`return `); generateNode(generator, ast); generator.deindent(needIndent); generator.push(`}`); delete ast.helpers; const { code, map } = generator.context(); return { ast, code, map: map ? map.toJSON() : void 0 // eslint-disable-line @typescript-eslint/no-explicit-any }; }; function baseCompile(source, options = {}) { const assignedOptions = assign({}, options); const jit = !!assignedOptions.jit; const enalbeMinify = !!assignedOptions.minify; const enambeOptimize = assignedOptions.optimize == null ? true : assignedOptions.optimize; const parser = createParser(assignedOptions); const ast = parser.parse(source); if (!jit) { transform(ast, assignedOptions); return generate(ast, assignedOptions); } else { enambeOptimize && optimize(ast); enalbeMinify && minify(ast); return { ast, code: "" }; } } // node_modules/@intlify/core-base/dist/core-base.mjs function initFeatureFlags() { if (typeof __INTLIFY_PROD_DEVTOOLS__ !== "boolean") { getGlobalThis().__INTLIFY_PROD_DEVTOOLS__ = false; } if (typeof __INTLIFY_DROP_MESSAGE_COMPILER__ !== "boolean") { getGlobalThis().__INTLIFY_DROP_MESSAGE_COMPILER__ = false; } } function format2(ast) { const msg = (ctx) => formatParts(ctx, ast); return msg; } function formatParts(ctx, ast) { const body = resolveBody(ast); if (body == null) { throw createUnhandleNodeError( 0 /* NodeTypes.Resource */ ); } const type = resolveType(body); if (type === 1) { const plural = body; const cases = resolveCases(plural); return ctx.plural(cases.reduce((messages, c) => [ ...messages, formatMessageParts(ctx, c) ], [])); } else { return formatMessageParts(ctx, body); } } var PROPS_BODY = ["b", "body"]; function resolveBody(node) { return resolveProps(node, PROPS_BODY); } var PROPS_CASES = ["c", "cases"]; function resolveCases(node) { return resolveProps(node, PROPS_CASES, []); } function formatMessageParts(ctx, node) { const static_ = resolveStatic(node); if (static_ != null) { return ctx.type === "text" ? static_ : ctx.normalize([static_]); } else { const messages = resolveItems(node).reduce((acm, c) => [...acm, formatMessagePart(ctx, c)], []); return ctx.normalize(messages); } } var PROPS_STATIC = ["s", "static"]; function resolveStatic(node) { return resolveProps(node, PROPS_STATIC); } var PROPS_ITEMS = ["i", "items"]; function resolveItems(node) { return resolveProps(node, PROPS_ITEMS, []); } function formatMessagePart(ctx, node) { const type = resolveType(node); switch (type) { case 3: { return resolveValue$1(node, type); } case 9: { return resolveValue$1(node, type); } case 4: { const named = node; if (hasOwn(named, "k") && named.k) { return ctx.interpolate(ctx.named(named.k)); } if (hasOwn(named, "key") && named.key) { return ctx.interpolate(ctx.named(named.key)); } throw createUnhandleNodeError(type); } case 5: { const list = node; if (hasOwn(list, "i") && isNumber(list.i)) { return ctx.interpolate(ctx.list(list.i)); } if (hasOwn(list, "index") && isNumber(list.index)) { return ctx.interpolate(ctx.list(list.index)); } throw createUnhandleNodeError(type); } case 6: { const linked = node; const modifier = resolveLinkedModifier(linked); const key = resolveLinkedKey(linked); return ctx.linked(formatMessagePart(ctx, key), modifier ? formatMessagePart(ctx, modifier) : void 0, ctx.type); } case 7: { return resolveValue$1(node, type); } case 8: { return resolveValue$1(node, type); } default: throw new Error(`unhandled node on format message part: ${type}`); } } var PROPS_TYPE = ["t", "type"]; function resolveType(node) { return resolveProps(node, PROPS_TYPE); } var PROPS_VALUE = ["v", "value"]; function resolveValue$1(node, type) { const resolved = resolveProps(node, PROPS_VALUE); if (resolved) { return resolved; } else { throw createUnhandleNodeError(type); } } var PROPS_MODIFIER = ["m", "modifier"]; function resolveLinkedModifier(node) { return resolveProps(node, PROPS_MODIFIER); } var PROPS_KEY = ["k", "key"]; function resolveLinkedKey(node) { const resolved = resolveProps(node, PROPS_KEY); if (resolved) { return resolved; } else { throw createUnhandleNodeError( 6 /* NodeTypes.Linked */ ); } } function resolveProps(node, props, defaultValue) { for (let i = 0; i < props.length; i++) { const prop = props[i]; if (hasOwn(node, prop) && node[prop] != null) { return node[prop]; } } return defaultValue; } function createUnhandleNodeError(type) { return new Error(`unhandled node type: ${type}`); } var WARN_MESSAGE = `Detected HTML in '{source}' message. Recommend not using HTML messages to avoid XSS.`; function checkHtmlMessage(source, warnHtmlMessage) { if (warnHtmlMessage && detectHtmlTag(source)) { warn(format(WARN_MESSAGE, { source })); } } var defaultOnCacheKey = (message) => message; var compileCache = create(); function clearCompileCache() { compileCache = create(); } function isMessageAST(val) { return isObject(val) && resolveType(val) === 0 && (hasOwn(val, "b") || hasOwn(val, "body")); } function baseCompile2(message, options = {}) { let detectError = false; const onError = options.onError || defaultOnError; options.onError = (err) => { detectError = true; onError(err); }; return { ...baseCompile(message, options), detectError }; } function compile(message, context) { if (!__INTLIFY_DROP_MESSAGE_COMPILER__ && isString(message)) { const warnHtmlMessage = isBoolean(context.warnHtmlMessage) ? context.warnHtmlMessage : true; checkHtmlMessage(message, warnHtmlMessage); const onCacheKey = context.onCacheKey || defaultOnCacheKey; const cacheKey = onCacheKey(message); const cached = compileCache[cacheKey]; if (cached) { return cached; } const { ast, detectError } = baseCompile2(message, { ...context, location: true, jit: true }); const msg = format2(ast); return !detectError ? compileCache[cacheKey] = msg : msg; } else { if (!isMessageAST(message)) { warn(`the message that is resolve with key '${context.key}' is not supported for jit compilation`); return () => message; } const cacheKey = message.cacheKey; if (cacheKey) { const cached = compileCache[cacheKey]; if (cached) { return cached; } return compileCache[cacheKey] = format2(message); } else { return format2(message); } } } var devtools = null; function setDevToolsHook(hook) { devtools = hook; } function getDevToolsHook() { return devtools; } function initI18nDevTools(i18n, version, meta) { devtools && devtools.emit("i18n:init", { timestamp: Date.now(), i18n, version, meta }); } var translateDevTools = createDevToolsHook("function:translate"); function createDevToolsHook(hook) { return (payloads) => devtools && devtools.emit(hook, payloads); } var CoreErrorCodes = { INVALID_ARGUMENT: COMPILE_ERROR_CODES_EXTEND_POINT, // 17 INVALID_DATE_ARGUMENT: 18, INVALID_ISO_DATE_ARGUMENT: 19, NOT_SUPPORT_NON_STRING_MESSAGE: 20, NOT_SUPPORT_LOCALE_PROMISE_VALUE: 21, NOT_SUPPORT_LOCALE_ASYNC_FUNCTION: 22, NOT_SUPPORT_LOCALE_TYPE: 23 }; var CORE_ERROR_CODES_EXTEND_POINT = 24; function createCoreError(code) { return createCompileError(code, null, true ? { messages: errorMessages2 } : void 0); } var errorMessages2 = { [CoreErrorCodes.INVALID_ARGUMENT]: "Invalid arguments", [CoreErrorCodes.INVALID_DATE_ARGUMENT]: "The date provided is an invalid Date object.Make sure your Date represents a valid date.", [CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT]: "The argument provided is not a valid ISO date string", [CoreErrorCodes.NOT_SUPPORT_NON_STRING_MESSAGE]: "Not support non-string message", [CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE]: "cannot support promise value", [CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION]: "cannot support async function", [CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE]: "cannot support locale type" }; function getLocale(context, options) { return options.locale != null ? resolveLocale(options.locale) : resolveLocale(context.locale); } var _resolveLocale; function resolveLocale(locale) { if (isString(locale)) { return locale; } else { if (isFunction(locale)) { if (locale.resolvedOnce && _resolveLocale != null) { return _resolveLocale; } else if (locale.constructor.name === "Function") { const resolve = locale(); if (isPromise(resolve)) { throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE); } return _resolveLocale = resolve; } else { throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION); } } else { throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE); } } } function fallbackWithSimple(ctx, fallback, start) { return [.../* @__PURE__ */ new Set([ start, ...isArray(fallback) ? fallback : isObject(fallback) ? Object.keys(fallback) : isString(fallback) ? [fallback] : [start] ])]; } function fallbackWithLocaleChain(ctx, fallback, start) { const startLocale = isString(start) ? start : DEFAULT_LOCALE; const context = ctx; if (!context.__localeChainCache) { context.__localeChainCache = /* @__PURE__ */ new Map(); } let chain = context.__localeChainCache.get(startLocale); if (!chain) { chain = []; let block = [start]; while (isArray(block)) { block = appendBlockToChain(chain, block, fallback); } const defaults = isArray(fallback) || !isPlainObject(fallback) ? fallback : fallback["default"] ? fallback["default"] : null; block = isString(defaults) ? [defaults] : defaults; if (isArray(block)) { appendBlockToChain(chain, block, false); } context.__localeChainCache.set(startLocale, chain); } return chain; } function appendBlockToChain(chain, block, blocks) { let follow = true; for (let i = 0; i < block.length && isBoolean(follow); i++) { const locale = block[i]; if (isString(locale)) { follow = appendLocaleToChain(chain, block[i], blocks); } } return follow; } function appendLocaleToChain(chain, locale, blocks) { let follow; const tokens = locale.split("-"); do { const target = tokens.join("-"); follow = appendItemToChain(chain, target, blocks); tokens.splice(-1, 1); } while (tokens.length && follow === true); return follow; } function appendItemToChain(chain, target, blocks) { let follow = false; if (!chain.includes(target)) { follow = true; if (target) { follow = target[target.length - 1] !== "!"; const locale = target.replace(/!/g, ""); chain.push(locale); if ((isArray(blocks) || isPlainObject(blocks)) && blocks[locale]) { follow = blocks[locale]; } } } return follow; } var pathStateMachine = []; pathStateMachine[ 0 /* States.BEFORE_PATH */ ] = { [ "w" /* PathCharTypes.WORKSPACE */ ]: [ 0 /* States.BEFORE_PATH */ ], [ "i" /* PathCharTypes.IDENT */ ]: [ 3, 0 /* Actions.APPEND */ ], [ "[" /* PathCharTypes.LEFT_BRACKET */ ]: [ 4 /* States.IN_SUB_PATH */ ], [ "o" /* PathCharTypes.END_OF_FAIL */ ]: [ 7 /* States.AFTER_PATH */ ] }; pathStateMachine[ 1 /* States.IN_PATH */ ] = { [ "w" /* PathCharTypes.WORKSPACE */ ]: [ 1 /* States.IN_PATH */ ], [ "." /* PathCharTypes.DOT */ ]: [ 2 /* States.BEFORE_IDENT */ ], [ "[" /* PathCharTypes.LEFT_BRACKET */ ]: [ 4 /* States.IN_SUB_PATH */ ], [ "o" /* PathCharTypes.END_OF_FAIL */ ]: [ 7 /* States.AFTER_PATH */ ] }; pathStateMachine[ 2 /* States.BEFORE_IDENT */ ] = { [ "w" /* PathCharTypes.WORKSPACE */ ]: [ 2 /* States.BEFORE_IDENT */ ], [ "i" /* PathCharTypes.IDENT */ ]: [ 3, 0 /* Actions.APPEND */ ], [ "0" /* PathCharTypes.ZERO */ ]: [ 3, 0 /* Actions.APPEND */ ] }; pathStateMachine[ 3 /* States.IN_IDENT */ ] = { [ "i" /* PathCharTypes.IDENT */ ]: [ 3, 0 /* Actions.APPEND */ ], [ "0" /* PathCharTypes.ZERO */ ]: [ 3, 0 /* Actions.APPEND */ ], [ "w" /* PathCharTypes.WORKSPACE */ ]: [ 1, 1 /* Actions.PUSH */ ], [ "." /* PathCharTypes.DOT */ ]: [ 2, 1 /* Actions.PUSH */ ], [ "[" /* PathCharTypes.LEFT_BRACKET */ ]: [ 4, 1 /* Actions.PUSH */ ], [ "o" /* PathCharTypes.END_OF_FAIL */ ]: [ 7, 1 /* Actions.PUSH */ ] }; pathStateMachine[ 4 /* States.IN_SUB_PATH */ ] = { [ "'" /* PathCharTypes.SINGLE_QUOTE */ ]: [ 5, 0 /* Actions.APPEND */ ], [ '"' /* PathCharTypes.DOUBLE_QUOTE */ ]: [ 6, 0 /* Actions.APPEND */ ], [ "[" /* PathCharTypes.LEFT_BRACKET */ ]: [ 4, 2 /* Actions.INC_SUB_PATH_DEPTH */ ], [ "]" /* PathCharTypes.RIGHT_BRACKET */ ]: [ 1, 3 /* Actions.PUSH_SUB_PATH */ ], [ "o" /* PathCharTypes.END_OF_FAIL */ ]: 8, [ "l" /* PathCharTypes.ELSE */ ]: [ 4, 0 /* Actions.APPEND */ ] }; pathStateMachine[ 5 /* States.IN_SINGLE_QUOTE */ ] = { [ "'" /* PathCharTypes.SINGLE_QUOTE */ ]: [ 4, 0 /* Actions.APPEND */ ], [ "o" /* PathCharTypes.END_OF_FAIL */ ]: 8, [ "l" /* PathCharTypes.ELSE */ ]: [ 5, 0 /* Actions.APPEND */ ] }; pathStateMachine[ 6 /* States.IN_DOUBLE_QUOTE */ ] = { [ '"' /* PathCharTypes.DOUBLE_QUOTE */ ]: [ 4, 0 /* Actions.APPEND */ ], [ "o" /* PathCharTypes.END_OF_FAIL */ ]: 8, [ "l" /* PathCharTypes.ELSE */ ]: [ 6, 0 /* Actions.APPEND */ ] }; var literalValueRE = /^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/; function isLiteral(exp) { return literalValueRE.test(exp); } function stripQuotes(str) { const a = str.charCodeAt(0); const b = str.charCodeAt(str.length - 1); return a === b && (a === 34 || a === 39) ? str.slice(1, -1) : str; } function getPathCharType(ch) { if (ch === void 0 || ch === null) { return "o"; } const code = ch.charCodeAt(0); switch (code) { case 91: // [ case 93: // ] case 46: // . case 34: // " case 39: return ch; case 95: // _ case 36: // $ case 45: return "i"; case 9: // Tab (HT) case 10: // Newline (LF) case 13: // Return (CR) case 160: // No-break space (NBSP) case 65279: // Byte Order Mark (BOM) case 8232: // Line Separator (LS) case 8233: return "w"; } return "i"; } function formatSubPath(path) { const trimmed = path.trim(); if (path.charAt(0) === "0" && isNaN(parseInt(path))) { return false; } return isLiteral(trimmed) ? stripQuotes(trimmed) : "*" + trimmed; } function parse(path) { const keys = []; let index = -1; let mode = 0; let subPathDepth = 0; let c; let key; let newChar; let type; let transition; let action; let typeMap; const actions = []; actions[ 0 /* Actions.APPEND */ ] = () => { if (key === void 0) { key = newChar; } else { key += newChar; } }; actions[ 1 /* Actions.PUSH */ ] = () => { if (key !== void 0) { keys.push(key); key = void 0; } }; actions[ 2 /* Actions.INC_SUB_PATH_DEPTH */ ] = () => { actions[ 0 /* Actions.APPEND */ ](); subPathDepth++; }; actions[ 3 /* Actions.PUSH_SUB_PATH */ ] = () => { if (subPathDepth > 0) { subPathDepth--; mode = 4; actions[ 0 /* Actions.APPEND */ ](); } else { subPathDepth = 0; if (key === void 0) { return false; } key = formatSubPath(key); if (key === false) { return false; } else { actions[ 1 /* Actions.PUSH */ ](); } } }; function maybeUnescapeQuote() { const nextChar = path[index + 1]; if (mode === 5 && nextChar === "'" || mode === 6 && nextChar === '"') { index++; newChar = "\\" + nextChar; actions[ 0 /* Actions.APPEND */ ](); return true; } } while (mode !== null) { index++; c = path[index]; if (c === "\\" && maybeUnescapeQuote()) { continue; } type = getPathCharType(c); typeMap = pathStateMachine[mode]; transition = typeMap[type] || typeMap[ "l" /* PathCharTypes.ELSE */ ] || 8; if (transition === 8) { return; } mode = transition[0]; if (transition[1] !== void 0) { action = actions[transition[1]]; if (action) { newChar = c; if (action() === false) { return; } } } if (mode === 7) { return keys; } } } var cache = /* @__PURE__ */ new Map(); function resolveWithKeyValue(obj, path) { return isObject(obj) ? obj[path] : null; } function resolveValue(obj, path) { if (!isObject(obj)) { return null; } let hit = cache.get(path); if (!hit) { hit = parse(path); if (hit) { cache.set(path, hit); } } if (!hit) { return null; } const len = hit.length; let last = obj; let i = 0; while (i < len) { const val = last[hit[i]]; if (val === void 0) { return null; } if (isFunction(last)) { return null; } last = val; i++; } return last; } var CoreWarnCodes = { NOT_FOUND_KEY: 1, FALLBACK_TO_TRANSLATE: 2, CANNOT_FORMAT_NUMBER: 3, FALLBACK_TO_NUMBER_FORMAT: 4, CANNOT_FORMAT_DATE: 5, FALLBACK_TO_DATE_FORMAT: 6, EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER: 7 }; var CORE_WARN_CODES_EXTEND_POINT = 8; var warnMessages = { [CoreWarnCodes.NOT_FOUND_KEY]: `Not found '{key}' key in '{locale}' locale messages.`, [CoreWarnCodes.FALLBACK_TO_TRANSLATE]: `Fall back to translate '{key}' key with '{target}' locale.`, [CoreWarnCodes.CANNOT_FORMAT_NUMBER]: `Cannot format a number value due to not supported Intl.NumberFormat.`, [CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT]: `Fall back to number format '{key}' key with '{target}' locale.`, [CoreWarnCodes.CANNOT_FORMAT_DATE]: `Cannot format a date value due to not supported Intl.DateTimeFormat.`, [CoreWarnCodes.FALLBACK_TO_DATE_FORMAT]: `Fall back to datetime format '{key}' key with '{target}' locale.`, [CoreWarnCodes.EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER]: `This project is using Custom Message Compiler, which is an experimental feature. It may receive breaking changes or be removed in the future.` }; function getWarnMessage(code, ...args) { return format(warnMessages[code], ...args); } var VERSION = "10.0.5"; var NOT_REOSLVED = -1; var DEFAULT_LOCALE = "en-US"; var MISSING_RESOLVE_VALUE = ""; var capitalize = (str) => `${str.charAt(0).toLocaleUpperCase()}${str.substr(1)}`; function getDefaultLinkedModifiers() { return { upper: (val, type) => { return type === "text" && isString(val) ? val.toUpperCase() : type === "vnode" && isObject(val) && "__v_isVNode" in val ? val.children.toUpperCase() : val; }, lower: (val, type) => { return type === "text" && isString(val) ? val.toLowerCase() : type === "vnode" && isObject(val) && "__v_isVNode" in val ? val.children.toLowerCase() : val; }, capitalize: (val, type) => { return type === "text" && isString(val) ? capitalize(val) : type === "vnode" && isObject(val) && "__v_isVNode" in val ? capitalize(val.children) : val; } }; } var _compiler; function registerMessageCompiler(compiler) { _compiler = compiler; } var _resolver; function registerMessageResolver(resolver) { _resolver = resolver; } var _fallbacker; function registerLocaleFallbacker(fallbacker) { _fallbacker = fallbacker; } var _additionalMeta = null; var setAdditionalMeta = (meta) => { _additionalMeta = meta; }; var getAdditionalMeta = () => _additionalMeta; var _fallbackContext = null; var setFallbackContext = (context) => { _fallbackContext = context; }; var getFallbackContext = () => _fallbackContext; var _cid = 0; function createCoreContext(options = {}) { const onWarn = isFunction(options.onWarn) ? options.onWarn : warn; const version = isString(options.version) ? options.version : VERSION; const locale = isString(options.locale) || isFunction(options.locale) ? options.locale : DEFAULT_LOCALE; const _locale = isFunction(locale) ? DEFAULT_LOCALE : locale; const fallbackLocale = isArray(options.fallbackLocale) || isPlainObject(options.fallbackLocale) || isString(options.fallbackLocale) || options.fallbackLocale === false ? options.fallbackLocale : _locale; const messages = isPlainObject(options.messages) ? options.messages : createResources(_locale); const datetimeFormats = isPlainObject(options.datetimeFormats) ? options.datetimeFormats : createResources(_locale); const numberFormats = isPlainObject(options.numberFormats) ? options.numberFormats : createResources(_locale); const modifiers = assign(create(), options.modifiers, getDefaultLinkedModifiers()); const pluralRules = options.pluralRules || create(); const missing = isFunction(options.missing) ? options.missing : null; const missingWarn = isBoolean(options.missingWarn) || isRegExp(options.missingWarn) ? options.missingWarn : true; const fallbackWarn = isBoolean(options.fallbackWarn) || isRegExp(options.fallbackWarn) ? options.fallbackWarn : true; const fallbackFormat = !!options.fallbackFormat; const unresolving = !!options.unresolving; const postTranslation = isFunction(options.postTranslation) ? options.postTranslation : null; const processor = isPlainObject(options.processor) ? options.processor : null; const warnHtmlMessage = isBoolean(options.warnHtmlMessage) ? options.warnHtmlMessage : true; const escapeParameter = !!options.escapeParameter; const messageCompiler = isFunction(options.messageCompiler) ? options.messageCompiler : _compiler; if (isFunction(options.messageCompiler)) { warnOnce(getWarnMessage(CoreWarnCodes.EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER)); } const messageResolver = isFunction(options.messageResolver) ? options.messageResolver : _resolver || resolveWithKeyValue; const localeFallbacker = isFunction(options.localeFallbacker) ? options.localeFallbacker : _fallbacker || fallbackWithSimple; const fallbackContext = isObject(options.fallbackContext) ? options.fallbackContext : void 0; const internalOptions = options; const __datetimeFormatters = isObject(internalOptions.__datetimeFormatters) ? internalOptions.__datetimeFormatters : /* @__PURE__ */ new Map(); const __numberFormatters = isObject(internalOptions.__numberFormatters) ? internalOptions.__numberFormatters : /* @__PURE__ */ new Map(); const __meta = isObject(internalOptions.__meta) ? internalOptions.__meta : {}; _cid++; const context = { version, cid: _cid, locale, fallbackLocale, messages, modifiers, pluralRules, missing, missingWarn, fallbackWarn, fallbackFormat, unresolving, postTranslation, processor, warnHtmlMessage, escapeParameter, messageCompiler, messageResolver, localeFallbacker, fallbackContext, onWarn, __meta }; { context.datetimeFormats = datetimeFormats; context.numberFormats = numberFormats; context.__datetimeFormatters = __datetimeFormatters; context.__numberFormatters = __numberFormatters; } if (true) { context.__v_emitter = internalOptions.__v_emitter != null ? internalOptions.__v_emitter : void 0; } if (true) { initI18nDevTools(context, version, __meta); } return context; } var createResources = (locale) => ({ [locale]: create() }); function isTranslateFallbackWarn(fallback, key) { return fallback instanceof RegExp ? fallback.test(key) : fallback; } function isTranslateMissingWarn(missing, key) { return missing instanceof RegExp ? missing.test(key) : missing; } function handleMissing(context, key, locale, missingWarn, type) { const { missing, onWarn } = context; if (true) { const emitter = context.__v_emitter; if (emitter) { emitter.emit("missing", { locale, key, type, groupId: `${type}:${key}` }); } } if (missing !== null) { const ret = missing(context, locale, key, type); return isString(ret) ? ret : key; } else { if (isTranslateMissingWarn(missingWarn, key)) { onWarn(getWarnMessage(CoreWarnCodes.NOT_FOUND_KEY, { key, locale })); } return key; } } function updateFallbackLocale(ctx, locale, fallback) { const context = ctx; context.__localeChainCache = /* @__PURE__ */ new Map(); ctx.localeFallbacker(ctx, fallback, locale); } function isAlmostSameLocale(locale, compareLocale) { if (locale === compareLocale) return false; return locale.split("-")[0] === compareLocale.split("-")[0]; } function isImplicitFallback(targetLocale, locales) { const index = locales.indexOf(targetLocale); if (index === -1) { return false; } for (let i = index + 1; i < locales.length; i++) { if (isAlmostSameLocale(targetLocale, locales[i])) { return true; } } return false; } var intlDefined = typeof Intl !== "undefined"; var Availabilities = { dateTimeFormat: intlDefined && typeof Intl.DateTimeFormat !== "undefined", numberFormat: intlDefined && typeof Intl.NumberFormat !== "undefined" }; function datetime(context, ...args) { const { datetimeFormats, unresolving, fallbackLocale, onWarn, localeFallbacker } = context; const { __datetimeFormatters } = context; if (!Availabilities.dateTimeFormat) { onWarn(getWarnMessage(CoreWarnCodes.CANNOT_FORMAT_DATE)); return MISSING_RESOLVE_VALUE; } const [key, value, options, overrides] = parseDateTimeArgs(...args); const missingWarn = isBoolean(options.missingWarn) ? options.missingWarn : context.missingWarn; const fallbackWarn = isBoolean(options.fallbackWarn) ? options.fallbackWarn : context.fallbackWarn; const part = !!options.part; const locale = getLocale(context, options); const locales = localeFallbacker( context, // eslint-disable-line @typescript-eslint/no-explicit-any fallbackLocale, locale ); if (!isString(key) || key === "") { return new Intl.DateTimeFormat(locale, overrides).format(value); } let datetimeFormat = {}; let targetLocale; let format3 = null; let from = locale; let to = null; const type = "datetime format"; for (let i = 0; i < locales.length; i++) { targetLocale = to = locales[i]; if (locale !== targetLocale && isTranslateFallbackWarn(fallbackWarn, key)) { onWarn(getWarnMessage(CoreWarnCodes.FALLBACK_TO_DATE_FORMAT, { key, target: targetLocale })); } if (locale !== targetLocale) { const emitter = context.__v_emitter; if (emitter) { emitter.emit("fallback", { type, key, from, to, groupId: `${type}:${key}` }); } } datetimeFormat = datetimeFormats[targetLocale] || {}; format3 = datetimeFormat[key]; if (isPlainObject(format3)) break; handleMissing(context, key, targetLocale, missingWarn, type); from = to; } if (!isPlainObject(format3) || !isString(targetLocale)) { return unresolving ? NOT_REOSLVED : key; } let id = `${targetLocale}__${key}`; if (!isEmptyObject(overrides)) { id = `${id}__${JSON.stringify(overrides)}`; } let formatter = __datetimeFormatters.get(id); if (!formatter) { formatter = new Intl.DateTimeFormat(targetLocale, assign({}, format3, overrides)); __datetimeFormatters.set(id, formatter); } return !part ? formatter.format(value) : formatter.formatToParts(value); } var DATETIME_FORMAT_OPTIONS_KEYS = [ "localeMatcher", "weekday", "era", "year", "month", "day", "hour", "minute", "second", "timeZoneName", "formatMatcher", "hour12", "timeZone", "dateStyle", "timeStyle", "calendar", "dayPeriod", "numberingSystem", "hourCycle", "fractionalSecondDigits" ]; function parseDateTimeArgs(...args) { const [arg1, arg2, arg3, arg4] = args; const options = create(); let overrides = create(); let value; if (isString(arg1)) { const matches = arg1.match(/(\d{4}-\d{2}-\d{2})(T|\s)?(.*)/); if (!matches) { throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT); } const dateTime = matches[3] ? matches[3].trim().startsWith("T") ? `${matches[1].trim()}${matches[3].trim()}` : `${matches[1].trim()}T${matches[3].trim()}` : matches[1].trim(); value = new Date(dateTime); try { value.toISOString(); } catch { throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT); } } else if (isDate(arg1)) { if (isNaN(arg1.getTime())) { throw createCoreError(CoreErrorCodes.INVALID_DATE_ARGUMENT); } value = arg1; } else if (isNumber(arg1)) { value = arg1; } else { throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); } if (isString(arg2)) { options.key = arg2; } else if (isPlainObject(arg2)) { Object.keys(arg2).forEach((key) => { if (DATETIME_FORMAT_OPTIONS_KEYS.includes(key)) { overrides[key] = arg2[key]; } else { options[key] = arg2[key]; } }); } if (isString(arg3)) { options.locale = arg3; } else if (isPlainObject(arg3)) { overrides = arg3; } if (isPlainObject(arg4)) { overrides = arg4; } return [options.key || "", value, options, overrides]; } function clearDateTimeFormat(ctx, locale, format3) { const context = ctx; for (const key in format3) { const id = `${locale}__${key}`; if (!context.__datetimeFormatters.has(id)) { continue; } context.__datetimeFormatters.delete(id); } } function number(context, ...args) { const { numberFormats, unresolving, fallbackLocale, onWarn, localeFallbacker } = context; const { __numberFormatters } = context; if (!Availabilities.numberFormat) { onWarn(getWarnMessage(CoreWarnCodes.CANNOT_FORMAT_NUMBER)); return MISSING_RESOLVE_VALUE; } const [key, value, options, overrides] = parseNumberArgs(...args); const missingWarn = isBoolean(options.missingWarn) ? options.missingWarn : context.missingWarn; const fallbackWarn = isBoolean(options.fallbackWarn) ? options.fallbackWarn : context.fallbackWarn; const part = !!options.part; const locale = getLocale(context, options); const locales = localeFallbacker( context, // eslint-disable-line @typescript-eslint/no-explicit-any fallbackLocale, locale ); if (!isString(key) || key === "") { return new Intl.NumberFormat(locale, overrides).format(value); } let numberFormat = {}; let targetLocale; let format3 = null; let from = locale; let to = null; const type = "number format"; for (let i = 0; i < locales.length; i++) { targetLocale = to = locales[i]; if (locale !== targetLocale && isTranslateFallbackWarn(fallbackWarn, key)) { onWarn(getWarnMessage(CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT, { key, target: targetLocale })); } if (locale !== targetLocale) { const emitter = context.__v_emitter; if (emitter) { emitter.emit("fallback", { type, key, from, to, groupId: `${type}:${key}` }); } } numberFormat = numberFormats[targetLocale] || {}; format3 = numberFormat[key]; if (isPlainObject(format3)) break; handleMissing(context, key, targetLocale, missingWarn, type); from = to; } if (!isPlainObject(format3) || !isString(targetLocale)) { return unresolving ? NOT_REOSLVED : key; } let id = `${targetLocale}__${key}`; if (!isEmptyObject(overrides)) { id = `${id}__${JSON.stringify(overrides)}`; } let formatter = __numberFormatters.get(id); if (!formatter) { formatter = new Intl.NumberFormat(targetLocale, assign({}, format3, overrides)); __numberFormatters.set(id, formatter); } return !part ? formatter.format(value) : formatter.formatToParts(value); } var NUMBER_FORMAT_OPTIONS_KEYS = [ "localeMatcher", "style", "currency", "currencyDisplay", "currencySign", "useGrouping", "minimumIntegerDigits", "minimumFractionDigits", "maximumFractionDigits", "minimumSignificantDigits", "maximumSignificantDigits", "compactDisplay", "notation", "signDisplay", "unit", "unitDisplay", "roundingMode", "roundingPriority", "roundingIncrement", "trailingZeroDisplay" ]; function parseNumberArgs(...args) { const [arg1, arg2, arg3, arg4] = args; const options = create(); let overrides = create(); if (!isNumber(arg1)) { throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); } const value = arg1; if (isString(arg2)) { options.key = arg2; } else if (isPlainObject(arg2)) { Object.keys(arg2).forEach((key) => { if (NUMBER_FORMAT_OPTIONS_KEYS.includes(key)) { overrides[key] = arg2[key]; } else { options[key] = arg2[key]; } }); } if (isString(arg3)) { options.locale = arg3; } else if (isPlainObject(arg3)) { overrides = arg3; } if (isPlainObject(arg4)) { overrides = arg4; } return [options.key || "", value, options, overrides]; } function clearNumberFormat(ctx, locale, format3) { const context = ctx; for (const key in format3) { const id = `${locale}__${key}`; if (!context.__numberFormatters.has(id)) { continue; } context.__numberFormatters.delete(id); } } var DEFAULT_MODIFIER = (str) => str; var DEFAULT_MESSAGE = (ctx) => ""; var DEFAULT_MESSAGE_DATA_TYPE = "text"; var DEFAULT_NORMALIZE = (values) => values.length === 0 ? "" : join(values); var DEFAULT_INTERPOLATE = toDisplayString; function pluralDefault(choice, choicesLength) { choice = Math.abs(choice); if (choicesLength === 2) { return choice ? choice > 1 ? 1 : 0 : 1; } return choice ? Math.min(choice, 2) : 0; } function getPluralIndex(options) { const index = isNumber(options.pluralIndex) ? options.pluralIndex : -1; return options.named && (isNumber(options.named.count) || isNumber(options.named.n)) ? isNumber(options.named.count) ? options.named.count : isNumber(options.named.n) ? options.named.n : index : index; } function normalizeNamed(pluralIndex, props) { if (!props.count) { props.count = pluralIndex; } if (!props.n) { props.n = pluralIndex; } } function createMessageContext(options = {}) { const locale = options.locale; const pluralIndex = getPluralIndex(options); const pluralRule = isObject(options.pluralRules) && isString(locale) && isFunction(options.pluralRules[locale]) ? options.pluralRules[locale] : pluralDefault; const orgPluralRule = isObject(options.pluralRules) && isString(locale) && isFunction(options.pluralRules[locale]) ? pluralDefault : void 0; const plural = (messages) => { return messages[pluralRule(pluralIndex, messages.length, orgPluralRule)]; }; const _list = options.list || []; const list = (index) => _list[index]; const _named = options.named || create(); isNumber(options.pluralIndex) && normalizeNamed(pluralIndex, _named); const named = (key) => _named[key]; function message(key, useLinked) { const msg = isFunction(options.messages) ? options.messages(key, !!useLinked) : isObject(options.messages) ? options.messages[key] : false; return !msg ? options.parent ? options.parent.message(key) : DEFAULT_MESSAGE : msg; } const _modifier = (name) => options.modifiers ? options.modifiers[name] : DEFAULT_MODIFIER; const normalize = isPlainObject(options.processor) && isFunction(options.processor.normalize) ? options.processor.normalize : DEFAULT_NORMALIZE; const interpolate = isPlainObject(options.processor) && isFunction(options.processor.interpolate) ? options.processor.interpolate : DEFAULT_INTERPOLATE; const type = isPlainObject(options.processor) && isString(options.processor.type) ? options.processor.type : DEFAULT_MESSAGE_DATA_TYPE; const linked = (key, ...args) => { const [arg1, arg2] = args; let type2 = "text"; let modifier = ""; if (args.length === 1) { if (isObject(arg1)) { modifier = arg1.modifier || modifier; type2 = arg1.type || type2; } else if (isString(arg1)) { modifier = arg1 || modifier; } } else if (args.length === 2) { if (isString(arg1)) { modifier = arg1 || modifier; } if (isString(arg2)) { type2 = arg2 || type2; } } const ret = message(key, true)(ctx); const msg = ( // The message in vnode resolved with linked are returned as an array by processor.nomalize type2 === "vnode" && isArray(ret) && modifier ? ret[0] : ret ); return modifier ? _modifier(modifier)(msg, type2) : msg; }; const ctx = { [ "list" /* HelperNameMap.LIST */ ]: list, [ "named" /* HelperNameMap.NAMED */ ]: named, [ "plural" /* HelperNameMap.PLURAL */ ]: plural, [ "linked" /* HelperNameMap.LINKED */ ]: linked, [ "message" /* HelperNameMap.MESSAGE */ ]: message, [ "type" /* HelperNameMap.TYPE */ ]: type, [ "interpolate" /* HelperNameMap.INTERPOLATE */ ]: interpolate, [ "normalize" /* HelperNameMap.NORMALIZE */ ]: normalize, [ "values" /* HelperNameMap.VALUES */ ]: assign(create(), _list, _named) }; return ctx; } var NOOP_MESSAGE_FUNCTION = () => ""; var isMessageFunction = (val) => isFunction(val); function translate(context, ...args) { const { fallbackFormat, postTranslation, unresolving, messageCompiler, fallbackLocale, messages } = context; const [key, options] = parseTranslateArgs(...args); const missingWarn = isBoolean(options.missingWarn) ? options.missingWarn : context.missingWarn; const fallbackWarn = isBoolean(options.fallbackWarn) ? options.fallbackWarn : context.fallbackWarn; const escapeParameter = isBoolean(options.escapeParameter) ? options.escapeParameter : context.escapeParameter; const resolvedMessage = !!options.resolvedMessage; const defaultMsgOrKey = isString(options.default) || isBoolean(options.default) ? !isBoolean(options.default) ? options.default : !messageCompiler ? () => key : key : fallbackFormat ? !messageCompiler ? () => key : key : null; const enableDefaultMsg = fallbackFormat || defaultMsgOrKey != null && (isString(defaultMsgOrKey) || isFunction(defaultMsgOrKey)); const locale = getLocale(context, options); escapeParameter && escapeParams(options); let [formatScope, targetLocale, message] = !resolvedMessage ? resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) : [ key, locale, messages[locale] || create() ]; let format3 = formatScope; let cacheBaseKey = key; if (!resolvedMessage && !(isString(format3) || isMessageAST(format3) || isMessageFunction(format3))) { if (enableDefaultMsg) { format3 = defaultMsgOrKey; cacheBaseKey = format3; } } if (!resolvedMessage && (!(isString(format3) || isMessageAST(format3) || isMessageFunction(format3)) || !isString(targetLocale))) { return unresolving ? NOT_REOSLVED : key; } if (isString(format3) && context.messageCompiler == null) { warn(`The message format compilation is not supported in this build. Because message compiler isn't included. You need to pre-compilation all message format. So translate function return '${key}'.`); return key; } let occurred = false; const onError = () => { occurred = true; }; const msg = !isMessageFunction(format3) ? compileMessageFormat(context, key, targetLocale, format3, cacheBaseKey, onError) : format3; if (occurred) { return format3; } const ctxOptions = getMessageContextOptions(context, targetLocale, message, options); const msgContext = createMessageContext(ctxOptions); const messaged = evaluateMessage(context, msg, msgContext); const ret = postTranslation ? postTranslation(messaged, key) : messaged; if (true) { const payloads = { timestamp: Date.now(), key: isString(key) ? key : isMessageFunction(format3) ? format3.key : "", locale: targetLocale || (isMessageFunction(format3) ? format3.locale : ""), format: isString(format3) ? format3 : isMessageFunction(format3) ? format3.source : "", message: ret }; payloads.meta = assign({}, context.__meta, getAdditionalMeta() || {}); translateDevTools(payloads); } return ret; } function escapeParams(options) { if (isArray(options.list)) { options.list = options.list.map((item) => isString(item) ? escapeHtml(item) : item); } else if (isObject(options.named)) { Object.keys(options.named).forEach((key) => { if (isString(options.named[key])) { options.named[key] = escapeHtml(options.named[key]); } }); } } function resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) { const { messages, onWarn, messageResolver: resolveValue2, localeFallbacker } = context; const locales = localeFallbacker(context, fallbackLocale, locale); let message = create(); let targetLocale; let format3 = null; let from = locale; let to = null; const type = "translate"; for (let i = 0; i < locales.length; i++) { targetLocale = to = locales[i]; if (locale !== targetLocale && !isAlmostSameLocale(locale, targetLocale) && isTranslateFallbackWarn(fallbackWarn, key)) { onWarn(getWarnMessage(CoreWarnCodes.FALLBACK_TO_TRANSLATE, { key, target: targetLocale })); } if (locale !== targetLocale) { const emitter = context.__v_emitter; if (emitter) { emitter.emit("fallback", { type, key, from, to, groupId: `${type}:${key}` }); } } message = messages[targetLocale] || create(); let start = null; let startTag; let endTag; if (inBrowser) { start = window.performance.now(); startTag = "intlify-message-resolve-start"; endTag = "intlify-message-resolve-end"; mark && mark(startTag); } if ((format3 = resolveValue2(message, key)) === null) { format3 = message[key]; } if (inBrowser) { const end = window.performance.now(); const emitter = context.__v_emitter; if (emitter && start && format3) { emitter.emit("message-resolve", { type: "message-resolve", key, message: format3, time: end - start, groupId: `${type}:${key}` }); } if (startTag && endTag && mark && measure) { mark(endTag); measure("intlify message resolve", startTag, endTag); } } if (isString(format3) || isMessageAST(format3) || isMessageFunction(format3)) { break; } if (!isImplicitFallback(targetLocale, locales)) { const missingRet = handleMissing( context, // eslint-disable-line @typescript-eslint/no-explicit-any key, targetLocale, missingWarn, type ); if (missingRet !== key) { format3 = missingRet; } } from = to; } return [format3, targetLocale, message]; } function compileMessageFormat(context, key, targetLocale, format3, cacheBaseKey, onError) { const { messageCompiler, warnHtmlMessage } = context; if (isMessageFunction(format3)) { const msg2 = format3; msg2.locale = msg2.locale || targetLocale; msg2.key = msg2.key || key; return msg2; } if (messageCompiler == null) { const msg2 = () => format3; msg2.locale = targetLocale; msg2.key = key; return msg2; } let start = null; let startTag; let endTag; if (inBrowser) { start = window.performance.now(); startTag = "intlify-message-compilation-start"; endTag = "intlify-message-compilation-end"; mark && mark(startTag); } const msg = messageCompiler(format3, getCompileContext(context, targetLocale, cacheBaseKey, format3, warnHtmlMessage, onError)); if (inBrowser) { const end = window.performance.now(); const emitter = context.__v_emitter; if (emitter && start) { emitter.emit("message-compilation", { type: "message-compilation", message: format3, time: end - start, groupId: `${"translate"}:${key}` }); } if (startTag && endTag && mark && measure) { mark(endTag); measure("intlify message compilation", startTag, endTag); } } msg.locale = targetLocale; msg.key = key; msg.source = format3; return msg; } function evaluateMessage(context, msg, msgCtx) { let start = null; let startTag; let endTag; if (inBrowser) { start = window.performance.now(); startTag = "intlify-message-evaluation-start"; endTag = "intlify-message-evaluation-end"; mark && mark(startTag); } const messaged = msg(msgCtx); if (inBrowser) { const end = window.performance.now(); const emitter = context.__v_emitter; if (emitter && start) { emitter.emit("message-evaluation", { type: "message-evaluation", value: messaged, time: end - start, groupId: `${"translate"}:${msg.key}` }); } if (startTag && endTag && mark && measure) { mark(endTag); measure("intlify message evaluation", startTag, endTag); } } return messaged; } function parseTranslateArgs(...args) { const [arg1, arg2, arg3] = args; const options = create(); if (!isString(arg1) && !isNumber(arg1) && !isMessageFunction(arg1) && !isMessageAST(arg1)) { throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); } const key = isNumber(arg1) ? String(arg1) : isMessageFunction(arg1) ? arg1 : arg1; if (isNumber(arg2)) { options.plural = arg2; } else if (isString(arg2)) { options.default = arg2; } else if (isPlainObject(arg2) && !isEmptyObject(arg2)) { options.named = arg2; } else if (isArray(arg2)) { options.list = arg2; } if (isNumber(arg3)) { options.plural = arg3; } else if (isString(arg3)) { options.default = arg3; } else if (isPlainObject(arg3)) { assign(options, arg3); } return [key, options]; } function getCompileContext(context, locale, key, source, warnHtmlMessage, onError) { return { locale, key, warnHtmlMessage, onError: (err) => { onError && onError(err); if (true) { const _source = getSourceForCodeFrame(source); const message = `Message compilation error: ${err.message}`; const codeFrame = err.location && _source && generateCodeFrame(_source, err.location.start.offset, err.location.end.offset); const emitter = context.__v_emitter; if (emitter && _source) { emitter.emit("compile-error", { message: _source, error: err.message, start: err.location && err.location.start.offset, end: err.location && err.location.end.offset, groupId: `${"translate"}:${key}` }); } console.error(codeFrame ? `${message} ${codeFrame}` : message); } else { throw err; } }, onCacheKey: (source2) => generateFormatCacheKey(locale, key, source2) }; } function getSourceForCodeFrame(source) { if (isString(source)) { return source; } else { if (source.loc && source.loc.source) { return source.loc.source; } } } function getMessageContextOptions(context, locale, message, options) { const { modifiers, pluralRules, messageResolver: resolveValue2, fallbackLocale, fallbackWarn, missingWarn, fallbackContext } = context; const resolveMessage = (key, useLinked) => { let val = resolveValue2(message, key); if (val == null && (fallbackContext || useLinked)) { const [, , message2] = resolveMessageFormat( fallbackContext || context, // NOTE: if has fallbackContext, fallback to root, else if use linked, fallback to local context key, locale, fallbackLocale, fallbackWarn, missingWarn ); val = resolveValue2(message2, key); } if (isString(val) || isMessageAST(val)) { let occurred = false; const onError = () => { occurred = true; }; const msg = compileMessageFormat(context, key, locale, val, key, onError); return !occurred ? msg : NOOP_MESSAGE_FUNCTION; } else if (isMessageFunction(val)) { return val; } else { return NOOP_MESSAGE_FUNCTION; } }; const ctxOptions = { locale, modifiers, pluralRules, messages: resolveMessage }; if (context.processor) { ctxOptions.processor = context.processor; } if (options.list) { ctxOptions.list = options.list; } if (options.named) { ctxOptions.named = options.named; } if (isNumber(options.plural)) { ctxOptions.pluralIndex = options.plural; } return ctxOptions; } { initFeatureFlags(); } export { CORE_ERROR_CODES_EXTEND_POINT, CORE_WARN_CODES_EXTEND_POINT, CompileErrorCodes, CoreErrorCodes, CoreWarnCodes, DATETIME_FORMAT_OPTIONS_KEYS, DEFAULT_LOCALE, DEFAULT_MESSAGE_DATA_TYPE, MISSING_RESOLVE_VALUE, NOT_REOSLVED, NUMBER_FORMAT_OPTIONS_KEYS, VERSION, clearCompileCache, clearDateTimeFormat, clearNumberFormat, compile, createCompileError, createCoreContext, createCoreError, createMessageContext, datetime, fallbackWithLocaleChain, fallbackWithSimple, getAdditionalMeta, getDevToolsHook, getFallbackContext, getLocale, getWarnMessage, handleMissing, initI18nDevTools, isAlmostSameLocale, isImplicitFallback, isMessageAST, isMessageFunction, isTranslateFallbackWarn, isTranslateMissingWarn, number, parse, parseDateTimeArgs, parseNumberArgs, parseTranslateArgs, registerLocaleFallbacker, registerMessageCompiler, registerMessageResolver, resolveLocale, resolveValue, resolveWithKeyValue, setAdditionalMeta, setDevToolsHook, setFallbackContext, translate, translateDevTools, updateFallbackLocale }; /*! Bundled license information: @intlify/message-compiler/dist/message-compiler.mjs: (*! * message-compiler v10.0.5 * (c) 2024 kazuya kawaguchi * Released under the MIT License. *) @intlify/core-base/dist/core-base.mjs: (*! * core-base v10.0.5 * (c) 2024 kazuya kawaguchi * Released under the MIT License. *) */ //# sourceMappingURL=@intlify_core-base.js.map
修改文件时间
将文件时间修改为当前时间的前一年
删除文件