@intlify/core 11.1.8 → 11.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.cjs +1 -1
- package/dist/core.esm-browser.js +69 -26
- package/dist/core.esm-browser.prod.js +2 -2
- package/dist/core.global.js +62 -19
- package/dist/core.global.prod.js +2 -2
- package/dist/core.mjs +1 -1
- package/dist/core.node.mjs +1 -1
- package/dist/core.prod.cjs +1 -1
- package/dist/core.runtime.esm-browser.js +69 -26
- package/dist/core.runtime.esm-browser.prod.js +2 -2
- package/dist/core.runtime.global.js +62 -19
- package/dist/core.runtime.global.prod.js +2 -2
- package/dist/core.runtime.mjs +1 -1
- package/dist/core.runtime.node.mjs +1 -1
- package/package.json +3 -3
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* core v11.1.
|
|
2
|
+
* core v11.1.10
|
|
3
3
|
* (c) 2025 kazuya kawaguchi
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
var IntlifyCore = (function (exports) {
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
|
+
function warn(msg, err) {
|
|
10
|
+
if (typeof console !== 'undefined') {
|
|
11
|
+
console.warn(`[intlify] ` + msg);
|
|
12
|
+
/* istanbul ignore if */
|
|
13
|
+
if (err) {
|
|
14
|
+
console.warn(err.stack);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
9
19
|
/**
|
|
10
20
|
* Original Utilities
|
|
11
21
|
* written by kazuya kawaguchi
|
|
@@ -58,10 +68,49 @@ var IntlifyCore = (function (exports) {
|
|
|
58
68
|
const create = (obj = null) => _create(obj);
|
|
59
69
|
function escapeHtml(rawText) {
|
|
60
70
|
return rawText
|
|
71
|
+
.replace(/&/g, '&') // escape `&` first to avoid double escaping
|
|
61
72
|
.replace(/</g, '<')
|
|
62
73
|
.replace(/>/g, '>')
|
|
63
74
|
.replace(/"/g, '"')
|
|
64
|
-
.replace(/'/g, ''')
|
|
75
|
+
.replace(/'/g, ''')
|
|
76
|
+
.replace(/\//g, '/') // escape `/` to prevent closing tags or JavaScript URLs
|
|
77
|
+
.replace(/=/g, '='); // escape `=` to prevent attribute injection
|
|
78
|
+
}
|
|
79
|
+
function escapeAttributeValue(value) {
|
|
80
|
+
return value
|
|
81
|
+
.replace(/&(?![a-zA-Z0-9#]{2,6};)/g, '&') // escape unescaped `&`
|
|
82
|
+
.replace(/"/g, '"')
|
|
83
|
+
.replace(/'/g, ''')
|
|
84
|
+
.replace(/</g, '<')
|
|
85
|
+
.replace(/>/g, '>');
|
|
86
|
+
}
|
|
87
|
+
function sanitizeTranslatedHtml(html) {
|
|
88
|
+
// Escape dangerous characters in attribute values
|
|
89
|
+
// Process attributes with double quotes
|
|
90
|
+
html = html.replace(/(\w+)\s*=\s*"([^"]*)"/g, (_, attrName, attrValue) => `${attrName}="${escapeAttributeValue(attrValue)}"`);
|
|
91
|
+
// Process attributes with single quotes
|
|
92
|
+
html = html.replace(/(\w+)\s*=\s*'([^']*)'/g, (_, attrName, attrValue) => `${attrName}='${escapeAttributeValue(attrValue)}'`);
|
|
93
|
+
// Detect and neutralize event handler attributes
|
|
94
|
+
const eventHandlerPattern = /\s*on\w+\s*=\s*["']?[^"'>]+["']?/gi;
|
|
95
|
+
if (eventHandlerPattern.test(html)) {
|
|
96
|
+
{
|
|
97
|
+
warn('Potentially dangerous event handlers detected in translation. ' +
|
|
98
|
+
'Consider removing onclick, onerror, etc. from your translation messages.');
|
|
99
|
+
}
|
|
100
|
+
// Neutralize event handler attributes by escaping 'on'
|
|
101
|
+
html = html.replace(/(\s+)(on)(\w+\s*=)/gi, '$1on$3');
|
|
102
|
+
}
|
|
103
|
+
// Disable javascript: URLs in various contexts
|
|
104
|
+
const javascriptUrlPattern = [
|
|
105
|
+
// In href, src, action, formaction attributes
|
|
106
|
+
/(\s+(?:href|src|action|formaction)\s*=\s*["']?)\s*javascript:/gi,
|
|
107
|
+
// In style attributes within url()
|
|
108
|
+
/(style\s*=\s*["'][^"']*url\s*\(\s*)javascript:/gi
|
|
109
|
+
];
|
|
110
|
+
javascriptUrlPattern.forEach(pattern => {
|
|
111
|
+
html = html.replace(pattern, '$1javascript:');
|
|
112
|
+
});
|
|
113
|
+
return html;
|
|
65
114
|
}
|
|
66
115
|
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
67
116
|
function hasOwn(obj, key) {
|
|
@@ -133,16 +182,6 @@ var IntlifyCore = (function (exports) {
|
|
|
133
182
|
return res.join('\n');
|
|
134
183
|
}
|
|
135
184
|
|
|
136
|
-
function warn(msg, err) {
|
|
137
|
-
if (typeof console !== 'undefined') {
|
|
138
|
-
console.warn(`[intlify] ` + msg);
|
|
139
|
-
/* istanbul ignore if */
|
|
140
|
-
if (err) {
|
|
141
|
-
console.warn(err.stack);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
185
|
const CompileErrorCodes = {
|
|
147
186
|
// tokenizer error codes
|
|
148
187
|
EXPECTED_TOKEN: 1,
|
|
@@ -889,8 +928,8 @@ var IntlifyCore = (function (exports) {
|
|
|
889
928
|
* Intlify core-base version
|
|
890
929
|
* @internal
|
|
891
930
|
*/
|
|
892
|
-
const VERSION = '11.1.
|
|
893
|
-
const
|
|
931
|
+
const VERSION = '11.1.10';
|
|
932
|
+
const NOT_REOSLVED = -1;
|
|
894
933
|
const DEFAULT_LOCALE = 'en-US';
|
|
895
934
|
const MISSING_RESOLVE_VALUE = '';
|
|
896
935
|
const capitalize = (str) => `${str.charAt(0).toLocaleUpperCase()}${str.substr(1)}`;
|
|
@@ -1203,7 +1242,7 @@ var IntlifyCore = (function (exports) {
|
|
|
1203
1242
|
}
|
|
1204
1243
|
// checking format and target locale
|
|
1205
1244
|
if (!isPlainObject(format) || !isString(targetLocale)) {
|
|
1206
|
-
return unresolving ?
|
|
1245
|
+
return unresolving ? NOT_REOSLVED : key;
|
|
1207
1246
|
}
|
|
1208
1247
|
let id = `${targetLocale}__${key}`;
|
|
1209
1248
|
if (!isEmptyObject(overrides)) {
|
|
@@ -1377,7 +1416,7 @@ var IntlifyCore = (function (exports) {
|
|
|
1377
1416
|
}
|
|
1378
1417
|
// checking format and target locale
|
|
1379
1418
|
if (!isPlainObject(format) || !isString(targetLocale)) {
|
|
1380
|
-
return unresolving ?
|
|
1419
|
+
return unresolving ? NOT_REOSLVED : key;
|
|
1381
1420
|
}
|
|
1382
1421
|
let id = `${targetLocale}__${key}`;
|
|
1383
1422
|
if (!isEmptyObject(overrides)) {
|
|
@@ -1650,7 +1689,7 @@ var IntlifyCore = (function (exports) {
|
|
|
1650
1689
|
isMessageAST(format) ||
|
|
1651
1690
|
isMessageFunction(format)) ||
|
|
1652
1691
|
!isString(targetLocale))) {
|
|
1653
|
-
return unresolving ?
|
|
1692
|
+
return unresolving ? NOT_REOSLVED : key;
|
|
1654
1693
|
}
|
|
1655
1694
|
// TODO: refactor
|
|
1656
1695
|
if (isString(format) && context.messageCompiler == null) {
|
|
@@ -1678,9 +1717,13 @@ var IntlifyCore = (function (exports) {
|
|
|
1678
1717
|
const msgContext = createMessageContext(ctxOptions);
|
|
1679
1718
|
const messaged = evaluateMessage(context, msg, msgContext);
|
|
1680
1719
|
// if use post translation option, proceed it with handler
|
|
1681
|
-
|
|
1720
|
+
let ret = postTranslation
|
|
1682
1721
|
? postTranslation(messaged, key)
|
|
1683
1722
|
: messaged;
|
|
1723
|
+
// apply HTML sanitization for security
|
|
1724
|
+
if (escapeParameter && isString(ret)) {
|
|
1725
|
+
ret = sanitizeTranslatedHtml(ret);
|
|
1726
|
+
}
|
|
1684
1727
|
// NOTE: experimental !!
|
|
1685
1728
|
{
|
|
1686
1729
|
// prettier-ignore
|
|
@@ -2020,7 +2063,7 @@ var IntlifyCore = (function (exports) {
|
|
|
2020
2063
|
exports.DEFAULT_LOCALE = DEFAULT_LOCALE;
|
|
2021
2064
|
exports.DEFAULT_MESSAGE_DATA_TYPE = DEFAULT_MESSAGE_DATA_TYPE;
|
|
2022
2065
|
exports.MISSING_RESOLVE_VALUE = MISSING_RESOLVE_VALUE;
|
|
2023
|
-
exports.
|
|
2066
|
+
exports.NOT_REOSLVED = NOT_REOSLVED;
|
|
2024
2067
|
exports.NUMBER_FORMAT_OPTIONS_KEYS = NUMBER_FORMAT_OPTIONS_KEYS;
|
|
2025
2068
|
exports.VERSION = VERSION;
|
|
2026
2069
|
exports.clearCompileCache = clearCompileCache;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* core v11.1.
|
|
2
|
+
* core v11.1.10
|
|
3
3
|
* (c) 2025 kazuya kawaguchi
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
var IntlifyCore=function(e){"use strict";const t=/\{([0-9a-zA-Z]+)\}/g;const n=(e,t,n)=>r({l:e,k:t,s:n}),r=e=>JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029").replace(/\u0027/g,"\\u0027"),a=e=>"number"==typeof e&&isFinite(e),o=e=>"[object Date]"===O(e),l=e=>"[object RegExp]"===O(e),s=e=>C(e)&&0===Object.keys(e).length,i=Object.assign,c=Object.create,u=(e=null)=>c(e);function m(e){return e.replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const f=Object.prototype.hasOwnProperty;function _(e,t){return f.call(e,t)}const E=Array.isArray,g=e=>"function"==typeof e,p=e=>"string"==typeof e,d=e=>"boolean"==typeof e,T=e=>null!==e&&"object"==typeof e,N=e=>T(e)&&g(e.then)&&g(e.catch),A=Object.prototype.toString,O=e=>A.call(e),C=e=>"[object Object]"===O(e);function L(e,t){"undefined"!=typeof console&&(console.warn("[intlify] "+e),t&&console.warn(t.stack))}const h={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,MUST_HAVE_MESSAGES_IN_PLURAL:11,UNEXPECTED_EMPTY_LINKED_MODIFIER:12,UNEXPECTED_EMPTY_LINKED_KEY:13,UNEXPECTED_LEXICAL_ANALYSIS:14,UNHANDLED_CODEGEN_NODE_TYPE:15,UNHANDLED_MINIFIER_NODE_TYPE:16};function b(e,t,n={}){const{domain:r,messages:a,args:o}=n,l=new SyntaxError(String(e));return l.code=e,t&&(l.location=t),l.domain=r,l}function I(e){return T(e)&&0===y(e)&&(_(e,"b")||_(e,"body"))}const R=["b","body"];const S=["c","cases"];const k=["s","static"];const D=["i","items"];const M=["t","type"];function y(e){return v(e,M)}const F=["v","value"];function P(e,t){const n=v(e,F);if(null!=n)return n;throw x(t)}const U=["m","modifier"];const w=["k","key"];function v(e,t,n){for(let r=0;r<t.length;r++){const n=t[r];if(_(e,n)&&null!=e[n])return e[n]}return n}const W=[...R,...S,...k,...D,...w,...U,...F,...M];function x(e){return new Error(`unhandled node type: ${e}`)}function V(e){return t=>function(e,t){const n=(r=t,v(r,R));var r;if(null==n)throw x(0);if(1===y(n)){const t=function(e){return v(e,S,[])}(n);return e.plural(t.reduce(((t,n)=>[...t,G(e,n)]),[]))}return G(e,n)}(t,e)}function G(e,t){const n=function(e){return v(e,k)}(t);if(null!=n)return"text"===e.type?n:e.normalize([n]);{const n=function(e){return v(e,D,[])}(t).reduce(((t,n)=>[...t,K(e,n)]),[]);return e.normalize(n)}}function K(e,t){const n=y(t);switch(n){case 3:case 9:case 7:case 8:return P(t,n);case 4:{const r=t;if(_(r,"k")&&r.k)return e.interpolate(e.named(r.k));if(_(r,"key")&&r.key)return e.interpolate(e.named(r.key));throw x(n)}case 5:{const r=t;if(_(r,"i")&&a(r.i))return e.interpolate(e.list(r.i));if(_(r,"index")&&a(r.index))return e.interpolate(e.list(r.index));throw x(n)}case 6:{const n=t,r=function(e){return v(e,U)}(n),a=function(e){const t=v(e,w);if(t)return t;throw x(6)}(n);return e.linked(K(e,a),r?K(e,r):void 0,e.type)}default:throw new Error(`unhandled node on format message part: ${n}`)}}let $=u();function Y(e,t){{const t=e.cacheKey;if(t){const n=$[t];return n||($[t]=V(e))}return V(e)}}let j=null;const B=H("function:translate");function H(e){return t=>j&&j.emit(e,t)}const X={INVALID_ARGUMENT: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};function z(e,t){return null!=t.locale?Z(t.locale):Z(e.locale)}let J;function Z(e){if(p(e))return e;if(g(e)){if(e.resolvedOnce&&null!=J)return J;if("Function"===e.constructor.name){const t=e();if(N(t))throw Error(X.NOT_SUPPORT_LOCALE_PROMISE_VALUE);return J=t}throw Error(X.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION)}throw Error(X.NOT_SUPPORT_LOCALE_TYPE)}function Q(e,t,n){return[...new Set([n,...E(t)?t:T(t)?Object.keys(t):p(t)?[t]:[n]])]}function q(e,t,n){const r=p(n)?n:Ee,a=e;a.__localeChainCache||(a.__localeChainCache=new Map);let o=a.__localeChainCache.get(r);if(!o){o=[];let e=[n];for(;E(e);)e=ee(o,e,t);const l=E(t)||!C(t)?t:t.default?t.default:null;e=p(l)?[l]:l,E(e)&&ee(o,e,!1),a.__localeChainCache.set(r,o)}return o}function ee(e,t,n){let r=!0;for(let a=0;a<t.length&&d(r);a++){const o=t[a];p(o)&&(r=te(e,t[a],n))}return r}function te(e,t,n){let r;const a=t.split("-");do{r=ne(e,a.join("-"),n),a.splice(-1,1)}while(a.length&&!0===r);return r}function ne(e,t,n){let r=!1;if(!e.includes(t)&&(r=!0,t)){r="!"!==t[t.length-1];const a=t.replace(/!/g,"");e.push(a),(E(n)||C(n))&&n[a]&&(r=n[a])}return r}X.INVALID_ARGUMENT,X.INVALID_DATE_ARGUMENT,X.INVALID_ISO_DATE_ARGUMENT,X.NOT_SUPPORT_NON_STRING_MESSAGE,X.NOT_SUPPORT_LOCALE_PROMISE_VALUE,X.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION,X.NOT_SUPPORT_LOCALE_TYPE;const re=[];re[0]={w:[0],i:[3,0],"[":[4],o:[7]},re[1]={w:[1],".":[2],"[":[4],o:[7]},re[2]={w:[2],i:[3,0],0:[3,0]},re[3]={i:[3,0],0:[3,0],w:[1,1],".":[2,1],"[":[4,1],o:[7,1]},re[4]={"'":[5,0],'"':[6,0],"[":[4,2],"]":[1,3],o:8,l:[4,0]},re[5]={"'":[4,0],o:8,l:[5,0]},re[6]={'"':[4,0],o:8,l:[6,0]};const ae=/^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/;function oe(e){if(null==e)return"o";switch(e.charCodeAt(0)){case 91:case 93:case 46:case 34:case 39:return e;case 95:case 36:case 45:return"i";case 9:case 10:case 13:case 160:case 65279:case 8232:case 8233:return"w"}return"i"}function le(e){const t=e.trim();return("0"!==e.charAt(0)||!isNaN(parseInt(e)))&&(n=t,ae.test(n)?function(e){const t=e.charCodeAt(0);return t!==e.charCodeAt(e.length-1)||34!==t&&39!==t?e:e.slice(1,-1)}(t):"*"+t);var n}function se(e){const t=[];let n,r,a,o,l,s,i,c=-1,u=0,m=0;const f=[];function _(){const t=e[c+1];if(5===u&&"'"===t||6===u&&'"'===t)return c++,a="\\"+t,f[0](),!0}for(f[0]=()=>{void 0===r?r=a:r+=a},f[1]=()=>{void 0!==r&&(t.push(r),r=void 0)},f[2]=()=>{f[0](),m++},f[3]=()=>{if(m>0)m--,u=4,f[0]();else{if(m=0,void 0===r)return!1;if(r=le(r),!1===r)return!1;f[1]()}};null!==u;)if(c++,n=e[c],"\\"!==n||!_()){if(o=oe(n),i=re[u],l=i[o]||i.l||8,8===l)return;if(u=l[0],void 0!==l[1]&&(s=f[l[1]],s&&(a=n,!1===s())))return;if(7===u)return t}}const ie=new Map;function ce(e,t){return T(e)?e[t]:null}function ue(e,t){if(!T(e))return null;let n=ie.get(t);if(n||(n=se(t),n&&ie.set(t,n)),!n)return null;const r=n.length;let a=e,o=0;for(;o<r;){const e=n[o];if(W.includes(e)&&I(a))return null;const t=a[e];if(void 0===t)return null;if(g(a))return null;a=t,o++}return a}const me={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},fe={[me.NOT_FOUND_KEY]:"Not found '{key}' key in '{locale}' locale messages.",[me.FALLBACK_TO_TRANSLATE]:"Fall back to translate '{key}' key with '{target}' locale.",[me.CANNOT_FORMAT_NUMBER]:"Cannot format a number value due to not supported Intl.NumberFormat.",[me.FALLBACK_TO_NUMBER_FORMAT]:"Fall back to number format '{key}' key with '{target}' locale.",[me.CANNOT_FORMAT_DATE]:"Cannot format a date value due to not supported Intl.DateTimeFormat.",[me.FALLBACK_TO_DATE_FORMAT]:"Fall back to datetime format '{key}' key with '{target}' locale.",[me.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."};const _e="11.1.8",Ee="en-US",ge=e=>`${e.charAt(0).toLocaleUpperCase()}${e.substr(1)}`;let pe,de,Te;function Ne(e){pe=e}function Ae(e){de=e}function Oe(e){Te=e}let Ce=null;let Le=null;let he=0;const be=e=>({[e]:u()});function Ie(e,t,n,r,a){const{missing:o,onWarn:l}=e;if(null!==o){const r=o(e,n,t,a);return p(r)?r:t}return t}function Re(e,t){return e!==t&&e.split("-")[0]===t.split("-")[0]}function Se(e,t){const n=t.indexOf(e);if(-1===n)return!1;for(let r=n+1;r<t.length;r++)if(Re(e,t[r]))return!0;return!1}const ke=["localeMatcher","weekday","era","year","month","day","hour","minute","second","timeZoneName","formatMatcher","hour12","timeZone","dateStyle","timeStyle","calendar","dayPeriod","numberingSystem","hourCycle","fractionalSecondDigits"];function De(...e){const[t,n,r,l]=e,s=u();let i,c=u();if(p(t)){const e=t.match(/(\d{4}-\d{2}-\d{2})(T|\s)?(.*)/);if(!e)throw Error(X.INVALID_ISO_DATE_ARGUMENT);const n=e[3]?e[3].trim().startsWith("T")?`${e[1].trim()}${e[3].trim()}`:`${e[1].trim()}T${e[3].trim()}`:e[1].trim();i=new Date(n);try{i.toISOString()}catch{throw Error(X.INVALID_ISO_DATE_ARGUMENT)}}else if(o(t)){if(isNaN(t.getTime()))throw Error(X.INVALID_DATE_ARGUMENT);i=t}else{if(!a(t))throw Error(X.INVALID_ARGUMENT);i=t}return p(n)?s.key=n:C(n)&&Object.keys(n).forEach((e=>{ke.includes(e)?c[e]=n[e]:s[e]=n[e]})),p(r)?s.locale=r:C(r)&&(c=r),C(l)&&(c=l),[s.key||"",i,s,c]}const Me=["localeMatcher","style","currency","currencyDisplay","currencySign","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits","compactDisplay","notation","signDisplay","unit","unitDisplay","roundingMode","roundingPriority","roundingIncrement","trailingZeroDisplay"];function ye(...e){const[t,n,r,o]=e,l=u();let s=u();if(!a(t))throw Error(X.INVALID_ARGUMENT);const i=t;return p(n)?l.key=n:C(n)&&Object.keys(n).forEach((e=>{Me.includes(e)?s[e]=n[e]:l[e]=n[e]})),p(r)?l.locale=r:C(r)&&(s=r),C(o)&&(s=o),[l.key||"",i,l,s]}const Fe=e=>e,Pe=e=>"",Ue="text",we=e=>0===e.length?"":function(e,t=""){return e.reduce(((e,n,r)=>0===r?e+n:e+t+n),"")}(e),ve=e=>null==e?"":E(e)||C(e)&&e.toString===A?JSON.stringify(e,null,2):String(e);function We(e,t){return e=Math.abs(e),2===t?e?e>1?1:0:1:e?Math.min(e,2):0}function xe(e={}){const t=e.locale,n=function(e){const t=a(e.pluralIndex)?e.pluralIndex:-1;return e.named&&(a(e.named.count)||a(e.named.n))?a(e.named.count)?e.named.count:a(e.named.n)?e.named.n:t:t}(e),r=T(e.pluralRules)&&p(t)&&g(e.pluralRules[t])?e.pluralRules[t]:We,o=T(e.pluralRules)&&p(t)&&g(e.pluralRules[t])?We:void 0,l=e.list||[],s=e.named||u();a(e.pluralIndex)&&function(e,t){t.count||(t.count=e),t.n||(t.n=e)}(n,s);function c(t,n){const r=g(e.messages)?e.messages(t,!!n):!!T(e.messages)&&e.messages[t];return r||(e.parent?e.parent.message(t):Pe)}const m=C(e.processor)&&g(e.processor.normalize)?e.processor.normalize:we,f=C(e.processor)&&g(e.processor.interpolate)?e.processor.interpolate:ve,_={list:e=>l[e],named:e=>s[e],plural:e=>e[r(n,e.length,o)],linked:(t,...n)=>{const[r,a]=n;let o="text",l="";1===n.length?T(r)?(l=r.modifier||l,o=r.type||o):p(r)&&(l=r||l):2===n.length&&(p(r)&&(l=r||l),p(a)&&(o=a||o));const s=c(t,!0)(_),i="vnode"===o&&E(s)&&l?s[0]:s;return l?(u=l,e.modifiers?e.modifiers[u]:Fe)(i,o):i;var u},message:c,type:C(e.processor)&&p(e.processor.type)?e.processor.type:Ue,interpolate:f,normalize:m,values:i(u(),l,s)};return _}const Ve=()=>"",Ge=e=>g(e);function Ke(e,t,n,r,a,o){const{messages:l,onWarn:s,messageResolver:i,localeFallbacker:c}=e,m=c(e,r,n);let f,_=u(),E=null;for(let g=0;g<m.length&&(f=m[g],_=l[f]||u(),null===(E=i(_,t))&&(E=_[t]),!(p(E)||I(E)||Ge(E)));g++)if(!Se(f,m)){const n=Ie(e,t,f,0,"translate");n!==t&&(E=n)}return[E,f,_]}function $e(e,t,r,a,o,l){const{messageCompiler:s,warnHtmlMessage:i}=e;if(Ge(a)){const e=a;return e.locale=e.locale||r,e.key=e.key||t,e}if(null==s){const e=()=>a;return e.locale=r,e.key=t,e}const c=s(a,function(e,t,r,a,o,l){return{locale:t,key:r,warnHtmlMessage:o,onError:e=>{throw l&&l(e),e},onCacheKey:e=>n(t,r,e)}}(0,r,o,0,i,l));return c.locale=r,c.key=t,c.source=a,c}function Ye(...e){const[t,n,r]=e,o=u();if(!(p(t)||a(t)||Ge(t)||I(t)))throw Error(X.INVALID_ARGUMENT);const l=a(t)?String(t):(Ge(t),t);return a(n)?o.plural=n:p(n)?o.default=n:C(n)&&!s(n)?o.named=n:E(n)&&(o.list=n),a(r)?o.plural=r:p(r)?o.default=r:C(r)&&i(o,r),[l,o]}return Ne(Y),Ae(ue),Oe(q),e.AST_NODE_PROPS_KEYS=W,e.CORE_ERROR_CODES_EXTEND_POINT=24,e.CORE_WARN_CODES_EXTEND_POINT=8,e.CompileErrorCodes=h,e.CoreErrorCodes=X,e.CoreWarnCodes=me,e.DATETIME_FORMAT_OPTIONS_KEYS=ke,e.DEFAULT_LOCALE=Ee,e.DEFAULT_MESSAGE_DATA_TYPE=Ue,e.MISSING_RESOLVE_VALUE="",e.NOT_RESOLVED=-1,e.NUMBER_FORMAT_OPTIONS_KEYS=Me,e.VERSION=_e,e.clearCompileCache=function(){$=u()},e.clearDateTimeFormat=function(e,t,n){const r=e;for(const a in n){const e=`${t}__${a}`;r.__datetimeFormatters.has(e)&&r.__datetimeFormatters.delete(e)}},e.clearNumberFormat=function(e,t,n){const r=e;for(const a in n){const e=`${t}__${a}`;r.__numberFormatters.has(e)&&r.__numberFormatters.delete(e)}},e.compile=Y,e.createCompileError=b,e.createCoreContext=function(e={}){const t=g(e.onWarn)?e.onWarn:L,n=p(e.version)?e.version:_e,r=p(e.locale)||g(e.locale)?e.locale:Ee,a=g(r)?Ee:r,o=E(e.fallbackLocale)||C(e.fallbackLocale)||p(e.fallbackLocale)||!1===e.fallbackLocale?e.fallbackLocale:a,s=C(e.messages)?e.messages:be(a),c=C(e.datetimeFormats)?e.datetimeFormats:be(a),m=C(e.numberFormats)?e.numberFormats:be(a),f=i(u(),e.modifiers,{upper:(e,t)=>"text"===t&&p(e)?e.toUpperCase():"vnode"===t&&T(e)&&"__v_isVNode"in e?e.children.toUpperCase():e,lower:(e,t)=>"text"===t&&p(e)?e.toLowerCase():"vnode"===t&&T(e)&&"__v_isVNode"in e?e.children.toLowerCase():e,capitalize:(e,t)=>"text"===t&&p(e)?ge(e):"vnode"===t&&T(e)&&"__v_isVNode"in e?ge(e.children):e}),_=e.pluralRules||u(),N=g(e.missing)?e.missing:null,A=!d(e.missingWarn)&&!l(e.missingWarn)||e.missingWarn,O=!d(e.fallbackWarn)&&!l(e.fallbackWarn)||e.fallbackWarn,h=!!e.fallbackFormat,b=!!e.unresolving,I=g(e.postTranslation)?e.postTranslation:null,R=C(e.processor)?e.processor:null,S=!d(e.warnHtmlMessage)||e.warnHtmlMessage,k=!!e.escapeParameter,D=g(e.messageCompiler)?e.messageCompiler:pe,M=g(e.messageResolver)?e.messageResolver:de||ce,y=g(e.localeFallbacker)?e.localeFallbacker:Te||Q,F=T(e.fallbackContext)?e.fallbackContext:void 0,P=e,U=T(P.__datetimeFormatters)?P.__datetimeFormatters:new Map,w=T(P.__numberFormatters)?P.__numberFormatters:new Map,v=T(P.__meta)?P.__meta:{};he++;const W={version:n,cid:he,locale:r,fallbackLocale:o,messages:s,modifiers:f,pluralRules:_,missing:N,missingWarn:A,fallbackWarn:O,fallbackFormat:h,unresolving:b,postTranslation:I,processor:R,warnHtmlMessage:S,escapeParameter:k,messageCompiler:D,messageResolver:M,localeFallbacker:y,fallbackContext:F,onWarn:t,__meta:v};return W.datetimeFormats=c,W.numberFormats=m,W.__datetimeFormatters=U,W.__numberFormatters=w,W},e.createCoreError=function(e){return b(e,null,void 0)},e.createMessageContext=xe,e.datetime=function(e,...t){const{datetimeFormats:n,unresolving:r,fallbackLocale:a,onWarn:o,localeFallbacker:l}=e,{__datetimeFormatters:c}=e,[u,m,f,_]=De(...t);d(f.missingWarn)?f.missingWarn:e.missingWarn,d(f.fallbackWarn)?f.fallbackWarn:e.fallbackWarn;const E=!!f.part,g=z(e,f),T=l(e,a,g);if(!p(u)||""===u)return new Intl.DateTimeFormat(g,_).format(m);let N,A={},O=null;for(let s=0;s<T.length&&(N=T[s],A=n[N]||{},O=A[u],!C(O));s++)Ie(e,u,N,0,"datetime format");if(!C(O)||!p(N))return r?-1:u;let L=`${N}__${u}`;s(_)||(L=`${L}__${JSON.stringify(_)}`);let h=c.get(L);return h||(h=new Intl.DateTimeFormat(N,i({},O,_)),c.set(L,h)),E?h.formatToParts(m):h.format(m)},e.fallbackWithLocaleChain=q,e.fallbackWithSimple=Q,e.getAdditionalMeta=()=>Ce,e.getDevToolsHook=function(){return j},e.getFallbackContext=()=>Le,e.getLocale=z,e.getWarnMessage=function(e,...n){return function(e,...n){return 1===n.length&&T(n[0])&&(n=n[0]),n&&n.hasOwnProperty||(n={}),e.replace(t,((e,t)=>n.hasOwnProperty(t)?n[t]:""))}(fe[e],...n)},e.handleMissing=Ie,e.initI18nDevTools=function(e,t,n){j&&j.emit("i18n:init",{timestamp:Date.now(),i18n:e,version:t,meta:n})},e.isAlmostSameLocale=Re,e.isImplicitFallback=Se,e.isMessageAST=I,e.isMessageFunction=Ge,e.isTranslateFallbackWarn=function(e,t){return e instanceof RegExp?e.test(t):e},e.isTranslateMissingWarn=function(e,t){return e instanceof RegExp?e.test(t):e},e.number=function(e,...t){const{numberFormats:n,unresolving:r,fallbackLocale:a,onWarn:o,localeFallbacker:l}=e,{__numberFormatters:c}=e,[u,m,f,_]=ye(...t);d(f.missingWarn)?f.missingWarn:e.missingWarn,d(f.fallbackWarn)?f.fallbackWarn:e.fallbackWarn;const E=!!f.part,g=z(e,f),T=l(e,a,g);if(!p(u)||""===u)return new Intl.NumberFormat(g,_).format(m);let N,A={},O=null;for(let s=0;s<T.length&&(N=T[s],A=n[N]||{},O=A[u],!C(O));s++)Ie(e,u,N,0,"number format");if(!C(O)||!p(N))return r?-1:u;let L=`${N}__${u}`;s(_)||(L=`${L}__${JSON.stringify(_)}`);let h=c.get(L);return h||(h=new Intl.NumberFormat(N,i({},O,_)),c.set(L,h)),E?h.formatToParts(m):h.format(m)},e.parse=se,e.parseDateTimeArgs=De,e.parseNumberArgs=ye,e.parseTranslateArgs=Ye,e.registerLocaleFallbacker=Oe,e.registerMessageCompiler=Ne,e.registerMessageResolver=Ae,e.resolveLocale=Z,e.resolveValue=ue,e.resolveWithKeyValue=ce,e.setAdditionalMeta=e=>{Ce=e},e.setDevToolsHook=function(e){j=e},e.setFallbackContext=e=>{Le=e},e.translate=function(e,...t){const{fallbackFormat:n,postTranslation:r,unresolving:o,messageCompiler:l,fallbackLocale:s,messages:i}=e,[c,f]=Ye(...t),_=d(f.missingWarn)?f.missingWarn:e.missingWarn,N=d(f.fallbackWarn)?f.fallbackWarn:e.fallbackWarn,A=d(f.escapeParameter)?f.escapeParameter:e.escapeParameter,O=!!f.resolvedMessage,C=p(f.default)||d(f.default)?d(f.default)?l?c:()=>c:f.default:n?l?c:()=>c:null,L=n||null!=C&&(p(C)||g(C)),h=z(e,f);A&&function(e){E(e.list)?e.list=e.list.map((e=>p(e)?m(e):e)):T(e.named)&&Object.keys(e.named).forEach((t=>{p(e.named[t])&&(e.named[t]=m(e.named[t]))}))}(f);let[b,R,S]=O?[c,h,i[h]||u()]:Ke(e,c,h,s,N,_),k=b,D=c;if(O||p(k)||I(k)||Ge(k)||L&&(k=C,D=k),!(O||(p(k)||I(k)||Ge(k))&&p(R)))return o?-1:c;let M=!1;const y=Ge(k)?k:$e(e,c,R,k,D,(()=>{M=!0}));if(M)return k;const F=function(e,t,n,r){const{modifiers:o,pluralRules:l,messageResolver:s,fallbackLocale:i,fallbackWarn:c,missingWarn:u,fallbackContext:m}=e,f=(r,a)=>{let o=s(n,r);if(null==o&&(m||a)){const[,,n]=Ke(m||e,r,t,i,c,u);o=s(n,r)}if(p(o)||I(o)){let n=!1;const a=$e(e,r,t,o,r,(()=>{n=!0}));return n?Ve:a}return Ge(o)?o:Ve},_={locale:t,modifiers:o,pluralRules:l,messages:f};e.processor&&(_.processor=e.processor);r.list&&(_.list=r.list);r.named&&(_.named=r.named);a(r.plural)&&(_.pluralIndex=r.plural);return _}(e,R,S,f),P=function(e,t,n){const r=t(n);return r}(0,y,xe(F));return r?r(P,c):P},e.translateDevTools=B,e.updateFallbackLocale=function(e,t,n){e.__localeChainCache=new Map,e.localeFallbacker(e,n,t)},e}({});
|
|
6
|
+
var IntlifyCore=function(e){"use strict";function t(e,t){"undefined"!=typeof console&&(console.warn("[intlify] "+e),t&&console.warn(t.stack))}const n=/\{([0-9a-zA-Z]+)\}/g;const r=(e,t,n)=>a({l:e,k:t,s:n}),a=e=>JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029").replace(/\u0027/g,"\\u0027"),o=e=>"number"==typeof e&&isFinite(e),l=e=>"[object Date]"===L(e),s=e=>"[object RegExp]"===L(e),i=e=>h(e)&&0===Object.keys(e).length,c=Object.assign,u=Object.create,m=(e=null)=>u(e);function f(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/").replace(/=/g,"=")}function _(e){return e.replace(/&(?![a-zA-Z0-9#]{2,6};)/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}const E=Object.prototype.hasOwnProperty;function p(e,t){return E.call(e,t)}const g=Array.isArray,d=e=>"function"==typeof e,T=e=>"string"==typeof e,N=e=>"boolean"==typeof e,A=e=>null!==e&&"object"==typeof e,O=e=>A(e)&&d(e.then)&&d(e.catch),C=Object.prototype.toString,L=e=>C.call(e),h=e=>"[object Object]"===L(e);const b={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,MUST_HAVE_MESSAGES_IN_PLURAL:11,UNEXPECTED_EMPTY_LINKED_MODIFIER:12,UNEXPECTED_EMPTY_LINKED_KEY:13,UNEXPECTED_LEXICAL_ANALYSIS:14,UNHANDLED_CODEGEN_NODE_TYPE:15,UNHANDLED_MINIFIER_NODE_TYPE:16};function I(e,t,n={}){const{domain:r,messages:a,args:o}=n,l=new SyntaxError(String(e));return l.code=e,t&&(l.location=t),l.domain=r,l}function R(e){return A(e)&&0===F(e)&&(p(e,"b")||p(e,"body"))}const S=["b","body"];const k=["c","cases"];const D=["s","static"];const M=["i","items"];const y=["t","type"];function F(e){return W(e,y)}const P=["v","value"];function w(e,t){const n=W(e,P);if(null!=n)return n;throw V(t)}const U=["m","modifier"];const v=["k","key"];function W(e,t,n){for(let r=0;r<t.length;r++){const n=t[r];if(p(e,n)&&null!=e[n])return e[n]}return n}const x=[...S,...k,...D,...M,...v,...U,...P,...y];function V(e){return new Error(`unhandled node type: ${e}`)}function $(e){return t=>function(e,t){const n=(r=t,W(r,S));var r;if(null==n)throw V(0);if(1===F(n)){const t=function(e){return W(e,k,[])}(n);return e.plural(t.reduce(((t,n)=>[...t,G(e,n)]),[]))}return G(e,n)}(t,e)}function G(e,t){const n=function(e){return W(e,D)}(t);if(null!=n)return"text"===e.type?n:e.normalize([n]);{const n=function(e){return W(e,M,[])}(t).reduce(((t,n)=>[...t,K(e,n)]),[]);return e.normalize(n)}}function K(e,t){const n=F(t);switch(n){case 3:case 9:case 7:case 8:return w(t,n);case 4:{const r=t;if(p(r,"k")&&r.k)return e.interpolate(e.named(r.k));if(p(r,"key")&&r.key)return e.interpolate(e.named(r.key));throw V(n)}case 5:{const r=t;if(p(r,"i")&&o(r.i))return e.interpolate(e.list(r.i));if(p(r,"index")&&o(r.index))return e.interpolate(e.list(r.index));throw V(n)}case 6:{const n=t,r=function(e){return W(e,U)}(n),a=function(e){const t=W(e,v);if(t)return t;throw V(6)}(n);return e.linked(K(e,a),r?K(e,r):void 0,e.type)}default:throw new Error(`unhandled node on format message part: ${n}`)}}let j=m();function Y(e,t){{const t=e.cacheKey;if(t){const n=j[t];return n||(j[t]=$(e))}return $(e)}}let B=null;const H=X("function:translate");function X(e){return t=>B&&B.emit(e,t)}const z={INVALID_ARGUMENT: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};function Z(e,t){return null!=t.locale?Q(t.locale):Q(e.locale)}let J;function Q(e){if(T(e))return e;if(d(e)){if(e.resolvedOnce&&null!=J)return J;if("Function"===e.constructor.name){const t=e();if(O(t))throw Error(z.NOT_SUPPORT_LOCALE_PROMISE_VALUE);return J=t}throw Error(z.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION)}throw Error(z.NOT_SUPPORT_LOCALE_TYPE)}function q(e,t,n){return[...new Set([n,...g(t)?t:A(t)?Object.keys(t):T(t)?[t]:[n]])]}function ee(e,t,n){const r=T(n)?n:pe,a=e;a.__localeChainCache||(a.__localeChainCache=new Map);let o=a.__localeChainCache.get(r);if(!o){o=[];let e=[n];for(;g(e);)e=te(o,e,t);const l=g(t)||!h(t)?t:t.default?t.default:null;e=T(l)?[l]:l,g(e)&&te(o,e,!1),a.__localeChainCache.set(r,o)}return o}function te(e,t,n){let r=!0;for(let a=0;a<t.length&&N(r);a++){const o=t[a];T(o)&&(r=ne(e,t[a],n))}return r}function ne(e,t,n){let r;const a=t.split("-");do{r=re(e,a.join("-"),n),a.splice(-1,1)}while(a.length&&!0===r);return r}function re(e,t,n){let r=!1;if(!e.includes(t)&&(r=!0,t)){r="!"!==t[t.length-1];const a=t.replace(/!/g,"");e.push(a),(g(n)||h(n))&&n[a]&&(r=n[a])}return r}z.INVALID_ARGUMENT,z.INVALID_DATE_ARGUMENT,z.INVALID_ISO_DATE_ARGUMENT,z.NOT_SUPPORT_NON_STRING_MESSAGE,z.NOT_SUPPORT_LOCALE_PROMISE_VALUE,z.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION,z.NOT_SUPPORT_LOCALE_TYPE;const ae=[];ae[0]={w:[0],i:[3,0],"[":[4],o:[7]},ae[1]={w:[1],".":[2],"[":[4],o:[7]},ae[2]={w:[2],i:[3,0],0:[3,0]},ae[3]={i:[3,0],0:[3,0],w:[1,1],".":[2,1],"[":[4,1],o:[7,1]},ae[4]={"'":[5,0],'"':[6,0],"[":[4,2],"]":[1,3],o:8,l:[4,0]},ae[5]={"'":[4,0],o:8,l:[5,0]},ae[6]={'"':[4,0],o:8,l:[6,0]};const oe=/^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/;function le(e){if(null==e)return"o";switch(e.charCodeAt(0)){case 91:case 93:case 46:case 34:case 39:return e;case 95:case 36:case 45:return"i";case 9:case 10:case 13:case 160:case 65279:case 8232:case 8233:return"w"}return"i"}function se(e){const t=e.trim();return("0"!==e.charAt(0)||!isNaN(parseInt(e)))&&(n=t,oe.test(n)?function(e){const t=e.charCodeAt(0);return t!==e.charCodeAt(e.length-1)||34!==t&&39!==t?e:e.slice(1,-1)}(t):"*"+t);var n}function ie(e){const t=[];let n,r,a,o,l,s,i,c=-1,u=0,m=0;const f=[];function _(){const t=e[c+1];if(5===u&&"'"===t||6===u&&'"'===t)return c++,a="\\"+t,f[0](),!0}for(f[0]=()=>{void 0===r?r=a:r+=a},f[1]=()=>{void 0!==r&&(t.push(r),r=void 0)},f[2]=()=>{f[0](),m++},f[3]=()=>{if(m>0)m--,u=4,f[0]();else{if(m=0,void 0===r)return!1;if(r=se(r),!1===r)return!1;f[1]()}};null!==u;)if(c++,n=e[c],"\\"!==n||!_()){if(o=le(n),i=ae[u],l=i[o]||i.l||8,8===l)return;if(u=l[0],void 0!==l[1]&&(s=f[l[1]],s&&(a=n,!1===s())))return;if(7===u)return t}}const ce=new Map;function ue(e,t){return A(e)?e[t]:null}function me(e,t){if(!A(e))return null;let n=ce.get(t);if(n||(n=ie(t),n&&ce.set(t,n)),!n)return null;const r=n.length;let a=e,o=0;for(;o<r;){const e=n[o];if(x.includes(e)&&R(a))return null;const t=a[e];if(void 0===t)return null;if(d(a))return null;a=t,o++}return a}const fe={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},_e={[fe.NOT_FOUND_KEY]:"Not found '{key}' key in '{locale}' locale messages.",[fe.FALLBACK_TO_TRANSLATE]:"Fall back to translate '{key}' key with '{target}' locale.",[fe.CANNOT_FORMAT_NUMBER]:"Cannot format a number value due to not supported Intl.NumberFormat.",[fe.FALLBACK_TO_NUMBER_FORMAT]:"Fall back to number format '{key}' key with '{target}' locale.",[fe.CANNOT_FORMAT_DATE]:"Cannot format a date value due to not supported Intl.DateTimeFormat.",[fe.FALLBACK_TO_DATE_FORMAT]:"Fall back to datetime format '{key}' key with '{target}' locale.",[fe.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."};const Ee="11.1.10",pe="en-US",ge=e=>`${e.charAt(0).toLocaleUpperCase()}${e.substr(1)}`;let de,Te,Ne;function Ae(e){de=e}function Oe(e){Te=e}function Ce(e){Ne=e}let Le=null;let he=null;let be=0;const Ie=e=>({[e]:m()});function Re(e,t,n,r,a){const{missing:o,onWarn:l}=e;if(null!==o){const r=o(e,n,t,a);return T(r)?r:t}return t}function Se(e,t){return e!==t&&e.split("-")[0]===t.split("-")[0]}function ke(e,t){const n=t.indexOf(e);if(-1===n)return!1;for(let r=n+1;r<t.length;r++)if(Se(e,t[r]))return!0;return!1}const De=["localeMatcher","weekday","era","year","month","day","hour","minute","second","timeZoneName","formatMatcher","hour12","timeZone","dateStyle","timeStyle","calendar","dayPeriod","numberingSystem","hourCycle","fractionalSecondDigits"];function Me(...e){const[t,n,r,a]=e,s=m();let i,c=m();if(T(t)){const e=t.match(/(\d{4}-\d{2}-\d{2})(T|\s)?(.*)/);if(!e)throw Error(z.INVALID_ISO_DATE_ARGUMENT);const n=e[3]?e[3].trim().startsWith("T")?`${e[1].trim()}${e[3].trim()}`:`${e[1].trim()}T${e[3].trim()}`:e[1].trim();i=new Date(n);try{i.toISOString()}catch{throw Error(z.INVALID_ISO_DATE_ARGUMENT)}}else if(l(t)){if(isNaN(t.getTime()))throw Error(z.INVALID_DATE_ARGUMENT);i=t}else{if(!o(t))throw Error(z.INVALID_ARGUMENT);i=t}return T(n)?s.key=n:h(n)&&Object.keys(n).forEach((e=>{De.includes(e)?c[e]=n[e]:s[e]=n[e]})),T(r)?s.locale=r:h(r)&&(c=r),h(a)&&(c=a),[s.key||"",i,s,c]}const ye=["localeMatcher","style","currency","currencyDisplay","currencySign","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits","compactDisplay","notation","signDisplay","unit","unitDisplay","roundingMode","roundingPriority","roundingIncrement","trailingZeroDisplay"];function Fe(...e){const[t,n,r,a]=e,l=m();let s=m();if(!o(t))throw Error(z.INVALID_ARGUMENT);const i=t;return T(n)?l.key=n:h(n)&&Object.keys(n).forEach((e=>{ye.includes(e)?s[e]=n[e]:l[e]=n[e]})),T(r)?l.locale=r:h(r)&&(s=r),h(a)&&(s=a),[l.key||"",i,l,s]}const Pe=e=>e,we=e=>"",Ue="text",ve=e=>0===e.length?"":function(e,t=""){return e.reduce(((e,n,r)=>0===r?e+n:e+t+n),"")}(e),We=e=>null==e?"":g(e)||h(e)&&e.toString===C?JSON.stringify(e,null,2):String(e);function xe(e,t){return e=Math.abs(e),2===t?e?e>1?1:0:1:e?Math.min(e,2):0}function Ve(e={}){const t=e.locale,n=function(e){const t=o(e.pluralIndex)?e.pluralIndex:-1;return e.named&&(o(e.named.count)||o(e.named.n))?o(e.named.count)?e.named.count:o(e.named.n)?e.named.n:t:t}(e),r=A(e.pluralRules)&&T(t)&&d(e.pluralRules[t])?e.pluralRules[t]:xe,a=A(e.pluralRules)&&T(t)&&d(e.pluralRules[t])?xe:void 0,l=e.list||[],s=e.named||m();o(e.pluralIndex)&&function(e,t){t.count||(t.count=e),t.n||(t.n=e)}(n,s);function i(t,n){const r=d(e.messages)?e.messages(t,!!n):!!A(e.messages)&&e.messages[t];return r||(e.parent?e.parent.message(t):we)}const u=h(e.processor)&&d(e.processor.normalize)?e.processor.normalize:ve,f=h(e.processor)&&d(e.processor.interpolate)?e.processor.interpolate:We,_={list:e=>l[e],named:e=>s[e],plural:e=>e[r(n,e.length,a)],linked:(t,...n)=>{const[r,a]=n;let o="text",l="";1===n.length?A(r)?(l=r.modifier||l,o=r.type||o):T(r)&&(l=r||l):2===n.length&&(T(r)&&(l=r||l),T(a)&&(o=a||o));const s=i(t,!0)(_),c="vnode"===o&&g(s)&&l?s[0]:s;return l?(u=l,e.modifiers?e.modifiers[u]:Pe)(c,o):c;var u},message:i,type:h(e.processor)&&T(e.processor.type)?e.processor.type:Ue,interpolate:f,normalize:u,values:c(m(),l,s)};return _}const $e=()=>"",Ge=e=>d(e);function Ke(e,t,n,r,a,o){const{messages:l,onWarn:s,messageResolver:i,localeFallbacker:c}=e,u=c(e,r,n);let f,_=m(),E=null;for(let p=0;p<u.length&&(f=u[p],_=l[f]||m(),null===(E=i(_,t))&&(E=_[t]),!(T(E)||R(E)||Ge(E)));p++)if(!ke(f,u)){const n=Re(e,t,f,0,"translate");n!==t&&(E=n)}return[E,f,_]}function je(e,t,n,a,o,l){const{messageCompiler:s,warnHtmlMessage:i}=e;if(Ge(a)){const e=a;return e.locale=e.locale||n,e.key=e.key||t,e}if(null==s){const e=()=>a;return e.locale=n,e.key=t,e}const c=s(a,function(e,t,n,a,o,l){return{locale:t,key:n,warnHtmlMessage:o,onError:e=>{throw l&&l(e),e},onCacheKey:e=>r(t,n,e)}}(0,n,o,0,i,l));return c.locale=n,c.key=t,c.source=a,c}function Ye(...e){const[t,n,r]=e,a=m();if(!(T(t)||o(t)||Ge(t)||R(t)))throw Error(z.INVALID_ARGUMENT);const l=o(t)?String(t):(Ge(t),t);return o(n)?a.plural=n:T(n)?a.default=n:h(n)&&!i(n)?a.named=n:g(n)&&(a.list=n),o(r)?a.plural=r:T(r)?a.default=r:h(r)&&c(a,r),[l,a]}return Ae(Y),Oe(me),Ce(ee),e.AST_NODE_PROPS_KEYS=x,e.CORE_ERROR_CODES_EXTEND_POINT=24,e.CORE_WARN_CODES_EXTEND_POINT=8,e.CompileErrorCodes=b,e.CoreErrorCodes=z,e.CoreWarnCodes=fe,e.DATETIME_FORMAT_OPTIONS_KEYS=De,e.DEFAULT_LOCALE=pe,e.DEFAULT_MESSAGE_DATA_TYPE=Ue,e.MISSING_RESOLVE_VALUE="",e.NOT_REOSLVED=-1,e.NUMBER_FORMAT_OPTIONS_KEYS=ye,e.VERSION=Ee,e.clearCompileCache=function(){j=m()},e.clearDateTimeFormat=function(e,t,n){const r=e;for(const a in n){const e=`${t}__${a}`;r.__datetimeFormatters.has(e)&&r.__datetimeFormatters.delete(e)}},e.clearNumberFormat=function(e,t,n){const r=e;for(const a in n){const e=`${t}__${a}`;r.__numberFormatters.has(e)&&r.__numberFormatters.delete(e)}},e.compile=Y,e.createCompileError=I,e.createCoreContext=function(e={}){const n=d(e.onWarn)?e.onWarn:t,r=T(e.version)?e.version:Ee,a=T(e.locale)||d(e.locale)?e.locale:pe,o=d(a)?pe:a,l=g(e.fallbackLocale)||h(e.fallbackLocale)||T(e.fallbackLocale)||!1===e.fallbackLocale?e.fallbackLocale:o,i=h(e.messages)?e.messages:Ie(o),u=h(e.datetimeFormats)?e.datetimeFormats:Ie(o),f=h(e.numberFormats)?e.numberFormats:Ie(o),_=c(m(),e.modifiers,{upper:(e,t)=>"text"===t&&T(e)?e.toUpperCase():"vnode"===t&&A(e)&&"__v_isVNode"in e?e.children.toUpperCase():e,lower:(e,t)=>"text"===t&&T(e)?e.toLowerCase():"vnode"===t&&A(e)&&"__v_isVNode"in e?e.children.toLowerCase():e,capitalize:(e,t)=>"text"===t&&T(e)?ge(e):"vnode"===t&&A(e)&&"__v_isVNode"in e?ge(e.children):e}),E=e.pluralRules||m(),p=d(e.missing)?e.missing:null,O=!N(e.missingWarn)&&!s(e.missingWarn)||e.missingWarn,C=!N(e.fallbackWarn)&&!s(e.fallbackWarn)||e.fallbackWarn,L=!!e.fallbackFormat,b=!!e.unresolving,I=d(e.postTranslation)?e.postTranslation:null,R=h(e.processor)?e.processor:null,S=!N(e.warnHtmlMessage)||e.warnHtmlMessage,k=!!e.escapeParameter,D=d(e.messageCompiler)?e.messageCompiler:de,M=d(e.messageResolver)?e.messageResolver:Te||ue,y=d(e.localeFallbacker)?e.localeFallbacker:Ne||q,F=A(e.fallbackContext)?e.fallbackContext:void 0,P=e,w=A(P.__datetimeFormatters)?P.__datetimeFormatters:new Map,U=A(P.__numberFormatters)?P.__numberFormatters:new Map,v=A(P.__meta)?P.__meta:{};be++;const W={version:r,cid:be,locale:a,fallbackLocale:l,messages:i,modifiers:_,pluralRules:E,missing:p,missingWarn:O,fallbackWarn:C,fallbackFormat:L,unresolving:b,postTranslation:I,processor:R,warnHtmlMessage:S,escapeParameter:k,messageCompiler:D,messageResolver:M,localeFallbacker:y,fallbackContext:F,onWarn:n,__meta:v};return W.datetimeFormats=u,W.numberFormats=f,W.__datetimeFormatters=w,W.__numberFormatters=U,W},e.createCoreError=function(e){return I(e,null,void 0)},e.createMessageContext=Ve,e.datetime=function(e,...t){const{datetimeFormats:n,unresolving:r,fallbackLocale:a,onWarn:o,localeFallbacker:l}=e,{__datetimeFormatters:s}=e,[u,m,f,_]=Me(...t);N(f.missingWarn)?f.missingWarn:e.missingWarn,N(f.fallbackWarn)?f.fallbackWarn:e.fallbackWarn;const E=!!f.part,p=Z(e,f),g=l(e,a,p);if(!T(u)||""===u)return new Intl.DateTimeFormat(p,_).format(m);let d,A={},O=null;for(let i=0;i<g.length&&(d=g[i],A=n[d]||{},O=A[u],!h(O));i++)Re(e,u,d,0,"datetime format");if(!h(O)||!T(d))return r?-1:u;let C=`${d}__${u}`;i(_)||(C=`${C}__${JSON.stringify(_)}`);let L=s.get(C);return L||(L=new Intl.DateTimeFormat(d,c({},O,_)),s.set(C,L)),E?L.formatToParts(m):L.format(m)},e.fallbackWithLocaleChain=ee,e.fallbackWithSimple=q,e.getAdditionalMeta=()=>Le,e.getDevToolsHook=function(){return B},e.getFallbackContext=()=>he,e.getLocale=Z,e.getWarnMessage=function(e,...t){return function(e,...t){return 1===t.length&&A(t[0])&&(t=t[0]),t&&t.hasOwnProperty||(t={}),e.replace(n,((e,n)=>t.hasOwnProperty(n)?t[n]:""))}(_e[e],...t)},e.handleMissing=Re,e.initI18nDevTools=function(e,t,n){B&&B.emit("i18n:init",{timestamp:Date.now(),i18n:e,version:t,meta:n})},e.isAlmostSameLocale=Se,e.isImplicitFallback=ke,e.isMessageAST=R,e.isMessageFunction=Ge,e.isTranslateFallbackWarn=function(e,t){return e instanceof RegExp?e.test(t):e},e.isTranslateMissingWarn=function(e,t){return e instanceof RegExp?e.test(t):e},e.number=function(e,...t){const{numberFormats:n,unresolving:r,fallbackLocale:a,onWarn:o,localeFallbacker:l}=e,{__numberFormatters:s}=e,[u,m,f,_]=Fe(...t);N(f.missingWarn)?f.missingWarn:e.missingWarn,N(f.fallbackWarn)?f.fallbackWarn:e.fallbackWarn;const E=!!f.part,p=Z(e,f),g=l(e,a,p);if(!T(u)||""===u)return new Intl.NumberFormat(p,_).format(m);let d,A={},O=null;for(let i=0;i<g.length&&(d=g[i],A=n[d]||{},O=A[u],!h(O));i++)Re(e,u,d,0,"number format");if(!h(O)||!T(d))return r?-1:u;let C=`${d}__${u}`;i(_)||(C=`${C}__${JSON.stringify(_)}`);let L=s.get(C);return L||(L=new Intl.NumberFormat(d,c({},O,_)),s.set(C,L)),E?L.formatToParts(m):L.format(m)},e.parse=ie,e.parseDateTimeArgs=Me,e.parseNumberArgs=Fe,e.parseTranslateArgs=Ye,e.registerLocaleFallbacker=Ce,e.registerMessageCompiler=Ae,e.registerMessageResolver=Oe,e.resolveLocale=Q,e.resolveValue=me,e.resolveWithKeyValue=ue,e.setAdditionalMeta=e=>{Le=e},e.setDevToolsHook=function(e){B=e},e.setFallbackContext=e=>{he=e},e.translate=function(e,...t){const{fallbackFormat:n,postTranslation:r,unresolving:a,messageCompiler:l,fallbackLocale:s,messages:i}=e,[c,u]=Ye(...t),E=N(u.missingWarn)?u.missingWarn:e.missingWarn,p=N(u.fallbackWarn)?u.fallbackWarn:e.fallbackWarn,O=N(u.escapeParameter)?u.escapeParameter:e.escapeParameter,C=!!u.resolvedMessage,L=T(u.default)||N(u.default)?N(u.default)?l?c:()=>c:u.default:n?l?c:()=>c:null,h=n||null!=L&&(T(L)||d(L)),b=Z(e,u);O&&function(e){g(e.list)?e.list=e.list.map((e=>T(e)?f(e):e)):A(e.named)&&Object.keys(e.named).forEach((t=>{T(e.named[t])&&(e.named[t]=f(e.named[t]))}))}(u);let[I,S,k]=C?[c,b,i[b]||m()]:Ke(e,c,b,s,p,E),D=I,M=c;if(C||T(D)||R(D)||Ge(D)||h&&(D=L,M=D),!(C||(T(D)||R(D)||Ge(D))&&T(S)))return a?-1:c;let y=!1;const F=Ge(D)?D:je(e,c,S,D,M,(()=>{y=!0}));if(y)return D;const P=function(e,t,n,r){const{modifiers:a,pluralRules:l,messageResolver:s,fallbackLocale:i,fallbackWarn:c,missingWarn:u,fallbackContext:m}=e,f=(r,a)=>{let o=s(n,r);if(null==o&&(m||a)){const[,,n]=Ke(m||e,r,t,i,c,u);o=s(n,r)}if(T(o)||R(o)){let n=!1;const a=je(e,r,t,o,r,(()=>{n=!0}));return n?$e:a}return Ge(o)?o:$e},_={locale:t,modifiers:a,pluralRules:l,messages:f};e.processor&&(_.processor=e.processor);r.list&&(_.list=r.list);r.named&&(_.named=r.named);o(r.plural)&&(_.pluralIndex=r.plural);return _}(e,S,k,u),w=function(e,t,n){const r=t(n);return r}(0,F,Ve(P));let U=r?r(w,c):w;var v;return O&&T(U)&&(v=(v=(v=U).replace(/(\w+)\s*=\s*"([^"]*)"/g,((e,t,n)=>`${t}="${_(n)}"`))).replace(/(\w+)\s*=\s*'([^']*)'/g,((e,t,n)=>`${t}='${_(n)}'`)),/\s*on\w+\s*=\s*["']?[^"'>]+["']?/gi.test(v)&&(v=v.replace(/(\s+)(on)(\w+\s*=)/gi,"$1on$3")),[/(\s+(?:href|src|action|formaction)\s*=\s*["']?)\s*javascript:/gi,/(style\s*=\s*["'][^"']*url\s*\(\s*)javascript:/gi].forEach((e=>{v=v.replace(e,"$1javascript:")})),U=v),U},e.translateDevTools=H,e.updateFallbackLocale=function(e,t,n){e.__localeChainCache=new Map,e.localeFallbacker(e,n,t)},e}({});
|
package/dist/core.runtime.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlify/core",
|
|
3
|
-
"version": "11.1.
|
|
3
|
+
"version": "11.1.10",
|
|
4
4
|
"description": "@intlify/core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"core",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"jsdelivr": "dist/core.global.js",
|
|
34
34
|
"types": "dist/core.d.ts",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@intlify/core-base": "11.1.
|
|
37
|
-
"@intlify/shared": "11.1.
|
|
36
|
+
"@intlify/core-base": "11.1.10",
|
|
37
|
+
"@intlify/shared": "11.1.10"
|
|
38
38
|
},
|
|
39
39
|
"engines": {
|
|
40
40
|
"node": ">= 16"
|