vue-i18n.esm.browser.min.js 22 KB

1
  1. const t=["style","currency","currencyDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits","localeMatcher","formatMatcher","unit"];function e(t,e){"undefined"!=typeof console&&(console.warn("[vue-i18n] "+t),e&&console.warn(e.stack))}const n=Array.isArray;function s(t){return null!==t&&"object"==typeof t}function r(t){return"string"==typeof t}const i=Object.prototype.toString,a="[object Object]";function o(t){return i.call(t)===a}function l(t){return null==t}function c(t){return"function"==typeof t}function h(...t){let e=null,r=null;return 1===t.length?s(t[0])||n(t[0])?r=t[0]:"string"==typeof t[0]&&(e=t[0]):2===t.length&&("string"==typeof t[0]&&(e=t[0]),(s(t[1])||n(t[1]))&&(r=t[1])),{locale:e,params:r}}function u(t){return JSON.parse(JSON.stringify(t))}function m(t,e){return!!~t.indexOf(e)}const _=Object.prototype.hasOwnProperty;function f(t,e){return _.call(t,e)}function g(t){const e=Object(t);for(let t=1;t<arguments.length;t++){const n=arguments[t];if(null!=n){let t;for(t in n)f(n,t)&&(s(n[t])?e[t]=g(e[t],n[t]):e[t]=n[t])}}return e}function p(t,e){if(t===e)return!0;const r=s(t),i=s(e);if(!r||!i)return!r&&!i&&String(t)===String(e);try{const s=n(t),r=n(e);if(s&&r)return t.length===e.length&&t.every((t,n)=>p(t,e[n]));if(s||r)return!1;{const n=Object.keys(t),s=Object.keys(e);return n.length===s.length&&n.every(n=>p(t[n],e[n]))}}catch(t){return!1}}var d={beforeCreate(){const t=this.$options;if(t.i18n=t.i18n||(t.__i18n?{}:null),t.i18n){if(t.i18n instanceof tt){if(t.__i18n)try{let e={};t.__i18n.forEach(t=>{e=g(e,JSON.parse(t))}),Object.keys(e).forEach(n=>{t.i18n.mergeLocaleMessage(n,e[n])})}catch(t){}this._i18n=t.i18n,this._i18nWatcher=this._i18n.watchI18nData()}else if(o(t.i18n)){const e=this.$root&&this.$root.$i18n&&this.$root.$i18n instanceof tt?this.$root.$i18n:null;if(e&&(t.i18n.root=this.$root,t.i18n.formatter=e.formatter,t.i18n.fallbackLocale=e.fallbackLocale,t.i18n.formatFallbackMessages=e.formatFallbackMessages,t.i18n.silentTranslationWarn=e.silentTranslationWarn,t.i18n.silentFallbackWarn=e.silentFallbackWarn,t.i18n.pluralizationRules=e.pluralizationRules,t.i18n.preserveDirectiveContent=e.preserveDirectiveContent),t.__i18n)try{let e={};t.__i18n.forEach(t=>{e=g(e,JSON.parse(t))}),t.i18n.messages=e}catch(t){}const{sharedMessages:n}=t.i18n;n&&o(n)&&(t.i18n.messages=g(t.i18n.messages,n)),this._i18n=new tt(t.i18n),this._i18nWatcher=this._i18n.watchI18nData(),(void 0===t.i18n.sync||t.i18n.sync)&&(this._localeWatcher=this.$i18n.watchLocale()),e&&e.onComponentInstanceCreated(this._i18n)}}else this.$root&&this.$root.$i18n&&this.$root.$i18n instanceof tt?this._i18n=this.$root.$i18n:t.parent&&t.parent.$i18n&&t.parent.$i18n instanceof tt&&(this._i18n=t.parent.$i18n)},beforeMount(){const t=this.$options;t.i18n=t.i18n||(t.__i18n?{}:null),t.i18n?t.i18n instanceof tt?(this._i18n.subscribeDataChanging(this),this._subscribing=!0):o(t.i18n)&&(this._i18n.subscribeDataChanging(this),this._subscribing=!0):this.$root&&this.$root.$i18n&&this.$root.$i18n instanceof tt?(this._i18n.subscribeDataChanging(this),this._subscribing=!0):t.parent&&t.parent.$i18n&&t.parent.$i18n instanceof tt&&(this._i18n.subscribeDataChanging(this),this._subscribing=!0)},beforeDestroy(){if(!this._i18n)return;const t=this;this.$nextTick(()=>{t._subscribing&&(t._i18n.unsubscribeDataChanging(t),delete t._subscribing),t._i18nWatcher&&(t._i18nWatcher(),t._i18n.destroyVM(),delete t._i18nWatcher),t._localeWatcher&&(t._localeWatcher(),delete t._localeWatcher)})}},b={name:"i18n",functional:!0,props:{tag:{type:[String,Boolean,Object],default:"span"},path:{type:String,required:!0},locale:{type:String},places:{type:[Array,Object]}},render(t,{data:e,parent:n,props:s,slots:r}){const{$i18n:i}=n;if(!i)return;const{path:a,locale:o,places:l}=s,c=r(),h=i.i(a,o,function(t){let e;for(e in t)if("default"!==e)return!1;return Boolean(e)}(c)||l?function(t,e){const n=e?function(t){return Array.isArray(t)?t.reduce(F,{}):Object.assign({},t)}(e):{};if(!t)return n;const s=(t=t.filter(t=>t.tag||""!==t.text.trim())).every(y);return t.reduce(s?v:F,n)}(c.default,l):c),u=s.tag&&!0!==s.tag||!1===s.tag?s.tag:"span";return u?t(u,e,h):h}};function v(t,e){return e.data&&e.data.attrs&&e.data.attrs.place&&(t[e.data.attrs.place]=e),t}function F(t,e,n){return t[n]=e,t}function y(t){return Boolean(t.data&&t.data.attrs&&t.data.attrs.place)}var k={name:"i18n-n",functional:!0,props:{tag:{type:[String,Boolean,Object],default:"span"},value:{type:Number,required:!0},format:{type:[String,Object]},locale:{type:String}},render(e,{props:n,parent:i,data:a}){const o=i.$i18n;if(!o)return null;let l=null,c=null;r(n.format)?l=n.format:s(n.format)&&(n.format.key&&(l=n.format.key),c=Object.keys(n.format).reduce((e,s)=>m(t,s)?Object.assign({},e,{[s]:n.format[s]}):e,null));const h=n.locale||o.locale,u=o._ntp(n.value,h,l,c),_=u.map((t,e)=>{const n=a.scopedSlots&&a.scopedSlots[t.type];return n?n({[t.type]:t.value,index:e,parts:u}):t.value}),f=n.tag&&!0!==n.tag||!1===n.tag?n.tag:"span";return f?e(f,{attrs:a.attrs,class:a.class,staticClass:a.staticClass},_):_}};function $(t,e,n){C(t,n)&&T(t,e,n)}function w(t,e,n,s){if(!C(t,n))return;const r=n.context.$i18n;(function(t,e){const n=e.context;return t._locale===n.$i18n.locale})(t,n)&&p(e.value,e.oldValue)&&p(t._localeMessage,r.getLocaleMessage(r.locale))||T(t,e,n)}function M(t,n,s,r){if(!s.context)return void e("Vue instance does not exists in VNode context");const i=s.context.$i18n||{};n.modifiers.preserve||i.preserveDirectiveContent||(t.textContent=""),t._vt=void 0,delete t._vt,t._locale=void 0,delete t._locale,t._localeMessage=void 0,delete t._localeMessage}function C(t,n){const s=n.context;return s?!!s.$i18n||(e("VueI18n instance does not exists in Vue instance"),!1):(e("Vue instance does not exists in VNode context"),!1)}function T(t,n,s){const i=n.value,{path:a,locale:l,args:c,choice:h}=function(t){let e,n,s,i;r(t)?e=t:o(t)&&(e=t.path,n=t.locale,s=t.args,i=t.choice);return{path:e,locale:n,args:s,choice:i}}(i);if(!a&&!l&&!c)return void e("value type not supported");if(!a)return void e("`path` is required in v-t directive");const u=s.context;t._vt=t.textContent=null!=h?u.$i18n.tc(a,h,...L(l,c)):u.$i18n.t(a,...L(l,c)),t._locale=u.$i18n.locale,t._localeMessage=u.$i18n.getLocaleMessage(u.$i18n.locale)}function L(t,e){const n=[];return t&&n.push(t),e&&(Array.isArray(e)||o(e))&&n.push(e),n}let D;function I(t){I.installed=!0;(D=t).version&&Number(D.version.split(".")[0]);!function(t){t.prototype.hasOwnProperty("$i18n")||Object.defineProperty(t.prototype,"$i18n",{get(){return this._i18n}}),t.prototype.$t=function(t,...e){const n=this.$i18n;return n._t(t,n.locale,n._getMessages(),this,...e)},t.prototype.$tc=function(t,e,...n){const s=this.$i18n;return s._tc(t,s.locale,s._getMessages(),this,e,...n)},t.prototype.$te=function(t,e){const n=this.$i18n;return n._te(t,n.locale,n._getMessages(),e)},t.prototype.$d=function(t,...e){return this.$i18n.d(t,...e)},t.prototype.$n=function(t,...e){return this.$i18n.n(t,...e)}}(D),D.mixin(d),D.directive("t",{bind:$,update:w,unbind:M}),D.component(b.name,b),D.component(k.name,k),D.config.optionMergeStrategies.i18n=function(t,e){return void 0===e?t:e}}const x=/^(?:\d)+/,O=/^(?:\w)+/;const W=0,j=1,N=2,S=3,R=0,H=4,P=5,V=6,E=7,A=8,z=[];z[R]={ws:[R],ident:[3,W],"[":[H],eof:[E]},z[1]={ws:[1],".":[2],"[":[H],eof:[E]},z[2]={ws:[2],ident:[3,W],0:[3,W],number:[3,W]},z[3]={ident:[3,W],0:[3,W],number:[3,W],ws:[1,j],".":[2,j],"[":[H,j],eof:[E,j]},z[H]={"'":[P,W],'"':[V,W],"[":[H,N],"]":[1,S],eof:A,else:[H,W]},z[P]={"'":[H,W],eof:A,else:[P,W]},z[V]={'"':[H,W],eof:A,else:[V,W]};const B=/^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/;function U(t){if(null==t)return"eof";switch(t.charCodeAt(0)){case 91:case 93:case 46:case 34:case 39:return t;case 95:case 36:case 45:return"ident";case 9:case 10:case 13:case 160:case 65279:case 8232:case 8233:return"ws"}return"ident"}function J(t){const e=t.trim();return("0"!==t.charAt(0)||!isNaN(t))&&(n=e,B.test(n)?function(t){const e=t.charCodeAt(0);return e!==t.charCodeAt(t.length-1)||34!==e&&39!==e?t:t.slice(1,-1)}(e):"*"+e);var n}class q{constructor(){this._cache=Object.create(null)}parsePath(t){let e=this._cache[t];return e||(e=function(t){const e=[];let n,s,r,i,a,o,l,c=-1,h=R,u=0;const m=[];function _(){const e=t[c+1];if(h===P&&"'"===e||h===V&&'"'===e)return c++,r="\\"+e,m[W](),!0}for(m[j]=function(){void 0!==s&&(e.push(s),s=void 0)},m[W]=function(){void 0===s?s=r:s+=r},m[N]=function(){m[W](),u++},m[S]=function(){if(u>0)u--,h=H,m[W]();else{if(u=0,void 0===s)return!1;if(!1===(s=J(s)))return!1;m[j]()}};null!==h;)if("\\"!==(n=t[++c])||!_()){if(i=U(n),(a=(l=z[h])[i]||l.else||A)===A)return;if(h=a[0],(o=m[a[1]])&&(r=void 0===(r=a[2])?n:r,!1===o()))return;if(h===E)return e}}(t))&&(this._cache[t]=e),e||[]}getPathValue(t,e){if(!s(t))return null;const n=this.parsePath(e);if(0===n.length)return null;{const e=n.length;let s=t,r=0;for(;r<e;){const t=s[n[r]];if(void 0===t)return null;s=t,r++}return s}}}const G=/<\/?[\w\s="/.':;#-\/]+>/,X=/(?:@(?:\.[a-z]+)?:(?:[\w\-_|.]+|\([\w\-_|.]+\)))/g,Z=/^@(?:\.([a-z]+))?:/,K=/[()]/g,Q={upper:t=>t.toLocaleUpperCase(),lower:t=>t.toLocaleLowerCase(),capitalize:t=>`${t.charAt(0).toLocaleUpperCase()}${t.substr(1)}`},Y=new class{constructor(){this._caches=Object.create(null)}interpolate(t,e){if(!e)return[t];let n=this._caches[t];return n||(n=function(t){const e=[];let n=0,s="";for(;n<t.length;){let r=t[n++];if("{"===r){s&&e.push({type:"text",value:s}),s="";let i="";for(r=t[n++];void 0!==r&&"}"!==r;)i+=r,r=t[n++];const a="}"===r,o=x.test(i)?"list":a&&O.test(i)?"named":"unknown";e.push({value:i,type:o})}else"%"===r?"{"!==t[n]&&(s+=r):s+=r}return s&&e.push({type:"text",value:s}),e}(t),this._caches[t]=n),function(t,e){const n=[];let r=0;const i=Array.isArray(e)?"list":s(e)?"named":"unknown";if("unknown"===i)return n;for(;r<t.length;){const s=t[r];switch(s.type){case"text":n.push(s.value);break;case"list":n.push(e[parseInt(s.value,10)]);break;case"named":"named"===i&&n.push(e[s.value])}r++}return n}(n,e)}};class tt{constructor(t={}){!D&&"undefined"!=typeof window&&window.Vue&&I(window.Vue);const e=t.locale||"en-US",n=!1!==t.fallbackLocale&&(t.fallbackLocale||"en-US"),s=t.messages||{},r=t.dateTimeFormats||{},i=t.numberFormats||{};this._vm=null,this._formatter=t.formatter||Y,this._modifiers=t.modifiers||{},this._missing=t.missing||null,this._root=t.root||null,this._sync=void 0===t.sync||!!t.sync,this._fallbackRoot=void 0===t.fallbackRoot||!!t.fallbackRoot,this._formatFallbackMessages=void 0!==t.formatFallbackMessages&&!!t.formatFallbackMessages,this._silentTranslationWarn=void 0!==t.silentTranslationWarn&&t.silentTranslationWarn,this._silentFallbackWarn=void 0!==t.silentFallbackWarn&&!!t.silentFallbackWarn,this._dateTimeFormatters={},this._numberFormatters={},this._path=new q,this._dataListeners=[],this._componentInstanceCreatedListener=t.componentInstanceCreatedListener||null,this._preserveDirectiveContent=void 0!==t.preserveDirectiveContent&&!!t.preserveDirectiveContent,this.pluralizationRules=t.pluralizationRules||{},this._warnHtmlInMessage=t.warnHtmlInMessage||"off",this._postTranslation=t.postTranslation||null,this.getChoiceIndex=((t,e)=>{const n=Object.getPrototypeOf(this);if(n&&n.getChoiceIndex){return n.getChoiceIndex.call(this,t,e)}return this.locale in this.pluralizationRules?this.pluralizationRules[this.locale].apply(this,[t,e]):((t,e)=>(t=Math.abs(t),2===e?t?t>1?1:0:1:t?Math.min(t,2):0))(t,e)}),this._exist=((t,e)=>!(!t||!e)&&(!l(this._path.getPathValue(t,e))||!!t[e])),"warn"!==this._warnHtmlInMessage&&"error"!==this._warnHtmlInMessage||Object.keys(s).forEach(t=>{this._checkLocaleMessage(t,this._warnHtmlInMessage,s[t])}),this._initVM({locale:e,fallbackLocale:n,messages:s,dateTimeFormats:r,numberFormats:i})}_checkLocaleMessage(t,s,i){const a=(t,s,i,l)=>{if(o(i))Object.keys(i).forEach(e=>{const n=i[e];o(n)?(l.push(e),l.push("."),a(t,s,n,l),l.pop(),l.pop()):(l.push(e),a(t,s,n,l),l.pop())});else if(n(i))i.forEach((e,n)=>{o(e)?(l.push(`[${n}]`),l.push("."),a(t,s,e,l),l.pop(),l.pop()):(l.push(`[${n}]`),a(t,s,e,l),l.pop())});else if(r(i)){if(G.test(i)){const n=`Detected HTML in message '${i}' of keypath '${l.join("")}' at '${s}'. Consider component interpolation with '<i18n>' to avoid XSS. See https://bit.ly/2ZqJzkp`;"warn"===t?e(n):"error"===t&&function(t,e){"undefined"!=typeof console&&(console.error("[vue-i18n] "+t),e&&console.error(e.stack))}(n)}}};a(s,t,i,[])}_initVM(t){const e=D.config.silent;D.config.silent=!0,this._vm=new D({data:t}),D.config.silent=e}destroyVM(){this._vm.$destroy()}subscribeDataChanging(t){this._dataListeners.push(t)}unsubscribeDataChanging(t){!function(t,e){if(t.length){const n=t.indexOf(e);if(n>-1)t.splice(n,1)}}(this._dataListeners,t)}watchI18nData(){const t=this;return this._vm.$watch("$data",()=>{let e=t._dataListeners.length;for(;e--;)D.nextTick(()=>{t._dataListeners[e]&&t._dataListeners[e].$forceUpdate()})},{deep:!0})}watchLocale(){if(!this._sync||!this._root)return null;const t=this._vm;return this._root.$i18n.vm.$watch("locale",e=>{t.$set(t,"locale",e),t.$forceUpdate()},{immediate:!0})}onComponentInstanceCreated(t){this._componentInstanceCreatedListener&&this._componentInstanceCreatedListener(t,this)}get vm(){return this._vm}get messages(){return u(this._getMessages())}get dateTimeFormats(){return u(this._getDateTimeFormats())}get numberFormats(){return u(this._getNumberFormats())}get availableLocales(){return Object.keys(this.messages).sort()}get locale(){return this._vm.locale}set locale(t){this._vm.$set(this._vm,"locale",t)}get fallbackLocale(){return this._vm.fallbackLocale}set fallbackLocale(t){this._localeChainCache={},this._vm.$set(this._vm,"fallbackLocale",t)}get formatFallbackMessages(){return this._formatFallbackMessages}set formatFallbackMessages(t){this._formatFallbackMessages=t}get missing(){return this._missing}set missing(t){this._missing=t}get formatter(){return this._formatter}set formatter(t){this._formatter=t}get silentTranslationWarn(){return this._silentTranslationWarn}set silentTranslationWarn(t){this._silentTranslationWarn=t}get silentFallbackWarn(){return this._silentFallbackWarn}set silentFallbackWarn(t){this._silentFallbackWarn=t}get preserveDirectiveContent(){return this._preserveDirectiveContent}set preserveDirectiveContent(t){this._preserveDirectiveContent=t}get warnHtmlInMessage(){return this._warnHtmlInMessage}set warnHtmlInMessage(t){const e=this._warnHtmlInMessage;if(this._warnHtmlInMessage=t,e!==t&&("warn"===t||"error"===t)){const t=this._getMessages();Object.keys(t).forEach(e=>{this._checkLocaleMessage(e,this._warnHtmlInMessage,t[e])})}}get postTranslation(){return this._postTranslation}set postTranslation(t){this._postTranslation=t}_getMessages(){return this._vm.messages}_getDateTimeFormats(){return this._vm.dateTimeFormats}_getNumberFormats(){return this._vm.numberFormats}_warnDefault(t,e,n,s,i,a){if(!l(n))return n;if(this._missing){const n=this._missing.apply(null,[t,e,s,i]);if(r(n))return n}if(this._formatFallbackMessages){const t=h(...i);return this._render(e,a,t.params,e)}return e}_isFallbackRoot(t){return!t&&!l(this._root)&&this._fallbackRoot}_isSilentFallbackWarn(t){return this._silentFallbackWarn instanceof RegExp?this._silentFallbackWarn.test(t):this._silentFallbackWarn}_isSilentFallback(t,e){return this._isSilentFallbackWarn(e)&&(this._isFallbackRoot()||t!==this.fallbackLocale)}_isSilentTranslationWarn(t){return this._silentTranslationWarn instanceof RegExp?this._silentTranslationWarn.test(t):this._silentTranslationWarn}_interpolate(t,e,s,i,a,h,u){if(!e)return null;const m=this._path.getPathValue(e,s);if(n(m)||o(m))return m;let _;if(l(m)){if(!o(e))return null;if(!r(_=e[s])&&!c(_))return null}else{if(!r(m)&&!c(m))return null;_=m}return r(_)&&(_.indexOf("@:")>=0||_.indexOf("@.")>=0)&&(_=this._link(t,e,_,i,"raw",h,u)),this._render(_,a,h,s)}_link(t,e,s,r,i,a,o){let l=s;const c=l.match(X);for(let s in c){if(!c.hasOwnProperty(s))continue;const h=c[s],u=h.match(Z),[_,f]=u,g=h.replace(_,"").replace(K,"");if(m(o,g))return l;o.push(g);let p=this._interpolate(t,e,g,r,"raw"===i?"string":i,"raw"===i?void 0:a,o);if(this._isFallbackRoot(p)){if(!this._root)throw Error("unexpected error");const t=this._root.$i18n;p=t._translate(t._getMessages(),t.locale,t.fallbackLocale,g,r,i,a)}p=this._warnDefault(t,g,p,r,n(a)?a:[a],i),this._modifiers.hasOwnProperty(f)?p=this._modifiers[f](p):Q.hasOwnProperty(f)&&(p=Q[f](p)),o.pop(),l=p?l.replace(h,p):l}return l}_createMessageContext(t){const e=n(t)?t:[],r=s(t)?t:{};return{list:t=>e[t],named:t=>r[t]}}_render(t,e,n,s){if(c(t))return t(this._createMessageContext(n));let i=this._formatter.interpolate(t,n,s);return i||(i=Y.interpolate(t,n,s)),"string"!==e||r(i)?i:i.join("")}_appendItemToChain(t,e,n){let s=!1;return m(t,e)||(s=!0,e&&(s="!"!==e[e.length-1],e=e.replace(/!/g,""),t.push(e),n&&n[e]&&(s=n[e]))),s}_appendLocaleToChain(t,e,n){let s;const r=e.split("-");do{const e=r.join("-");s=this._appendItemToChain(t,e,n),r.splice(-1,1)}while(r.length&&!0===s);return s}_appendBlockToChain(t,e,n){let s=!0;for(let i=0;i<e.length&&"boolean"==typeof s;i++){const a=e[i];r(a)&&(s=this._appendLocaleToChain(t,a,n))}return s}_getLocaleChain(t,e){if(""===t)return[];this._localeChainCache||(this._localeChainCache={});let i=this._localeChainCache[t];if(!i){e||(e=this.fallbackLocale),i=[];let a,o=[t];for(;n(o);)o=this._appendBlockToChain(i,o,e);(o=r(a=n(e)?e:s(e)?e.default?e.default:null:e)?[a]:a)&&this._appendBlockToChain(i,o,null),this._localeChainCache[t]=i}return i}_translate(t,e,n,s,r,i,a){const o=this._getLocaleChain(e,n);let c;for(let e=0;e<o.length;e++){const n=o[e];if(!l(c=this._interpolate(n,t[n],s,r,i,a,[s])))return c}return null}_t(t,e,n,s,...r){if(!t)return"";const i=h(...r),a=i.locale||e;let o=this._translate(n,a,this.fallbackLocale,t,s,"string",i.params);if(this._isFallbackRoot(o)){if(!this._root)throw Error("unexpected error");return this._root.$t(t,...r)}return o=this._warnDefault(a,t,o,s,r,"string"),this._postTranslation&&null!=o&&(o=this._postTranslation(o,t)),o}t(t,...e){return this._t(t,this.locale,this._getMessages(),null,...e)}_i(t,e,n,s,r){const i=this._translate(n,e,this.fallbackLocale,t,s,"raw",r);if(this._isFallbackRoot(i)){if(!this._root)throw Error("unexpected error");return this._root.$i18n.i(t,e,r)}return this._warnDefault(e,t,i,s,[r],"raw")}i(t,e,n){return t?(r(e)||(e=this.locale),this._i(t,e,this._getMessages(),null,n)):""}_tc(t,e,n,s,r,...i){if(!t)return"";void 0===r&&(r=1);const a={count:r,n:r},o=h(...i);return o.params=Object.assign(a,o.params),i=null===o.locale?[o.params]:[o.locale,o.params],this.fetchChoice(this._t(t,e,n,s,...i),r)}fetchChoice(t,e){if(!t&&!r(t))return null;const n=t.split("|");return n[e=this.getChoiceIndex(e,n.length)]?n[e].trim():t}tc(t,e,...n){return this._tc(t,this.locale,this._getMessages(),null,e,...n)}_te(t,e,n,...s){const r=h(...s).locale||e;return this._exist(n[r],t)}te(t,e){return this._te(t,this.locale,this._getMessages(),e)}getLocaleMessage(t){return u(this._vm.messages[t]||{})}setLocaleMessage(t,e){"warn"!==this._warnHtmlInMessage&&"error"!==this._warnHtmlInMessage||this._checkLocaleMessage(t,this._warnHtmlInMessage,e),this._vm.$set(this._vm.messages,t,e)}mergeLocaleMessage(t,e){"warn"!==this._warnHtmlInMessage&&"error"!==this._warnHtmlInMessage||this._checkLocaleMessage(t,this._warnHtmlInMessage,e),this._vm.$set(this._vm.messages,t,g({},this._vm.messages[t]||{},e))}getDateTimeFormat(t){return u(this._vm.dateTimeFormats[t]||{})}setDateTimeFormat(t,e){this._vm.$set(this._vm.dateTimeFormats,t,e),this._clearDateTimeFormat(t,e)}mergeDateTimeFormat(t,e){this._vm.$set(this._vm.dateTimeFormats,t,g(this._vm.dateTimeFormats[t]||{},e)),this._clearDateTimeFormat(t,e)}_clearDateTimeFormat(t,e){for(let n in e){const e=`${t}__${n}`;this._dateTimeFormatters.hasOwnProperty(e)&&delete this._dateTimeFormatters[e]}}_localizeDateTime(t,e,n,s,r){let i=e,a=s[i];const o=this._getLocaleChain(e,n);for(let t=0;t<o.length;t++){const e=o[t];if(i=e,!l(a=s[e])&&!l(a[r]))break}if(l(a)||l(a[r]))return null;{const e=a[r],n=`${i}__${r}`;let s=this._dateTimeFormatters[n];return s||(s=this._dateTimeFormatters[n]=new Intl.DateTimeFormat(i,e)),s.format(t)}}_d(t,e,n){if(!n)return new Intl.DateTimeFormat(e).format(t);const s=this._localizeDateTime(t,e,this.fallbackLocale,this._getDateTimeFormats(),n);if(this._isFallbackRoot(s)){if(!this._root)throw Error("unexpected error");return this._root.$i18n.d(t,n,e)}return s||""}d(t,...e){let n=this.locale,i=null;return 1===e.length?r(e[0])?i=e[0]:s(e[0])&&(e[0].locale&&(n=e[0].locale),e[0].key&&(i=e[0].key)):2===e.length&&(r(e[0])&&(i=e[0]),r(e[1])&&(n=e[1])),this._d(t,n,i)}getNumberFormat(t){return u(this._vm.numberFormats[t]||{})}setNumberFormat(t,e){this._vm.$set(this._vm.numberFormats,t,e),this._clearNumberFormat(t,e)}mergeNumberFormat(t,e){this._vm.$set(this._vm.numberFormats,t,g(this._vm.numberFormats[t]||{},e)),this._clearNumberFormat(t,e)}_clearNumberFormat(t,e){for(let n in e){const e=`${t}__${n}`;this._numberFormatters.hasOwnProperty(e)&&delete this._numberFormatters[e]}}_getNumberFormatter(t,e,n,s,r,i){let a=e,o=s[a];const c=this._getLocaleChain(e,n);for(let t=0;t<c.length;t++){const e=c[t];if(a=e,!l(o=s[e])&&!l(o[r]))break}if(l(o)||l(o[r]))return null;{const t=o[r];let e;if(i)e=new Intl.NumberFormat(a,Object.assign({},t,i));else{const n=`${a}__${r}`;(e=this._numberFormatters[n])||(e=this._numberFormatters[n]=new Intl.NumberFormat(a,t))}return e}}_n(t,e,n,s){if(!tt.availabilities.numberFormat)return"";if(!n){return(s?new Intl.NumberFormat(e,s):new Intl.NumberFormat(e)).format(t)}const r=this._getNumberFormatter(t,e,this.fallbackLocale,this._getNumberFormats(),n,s),i=r&&r.format(t);if(this._isFallbackRoot(i)){if(!this._root)throw Error("unexpected error");return this._root.$i18n.n(t,Object.assign({},{key:n,locale:e},s))}return i||""}n(e,...n){let i=this.locale,a=null,o=null;return 1===n.length?r(n[0])?a=n[0]:s(n[0])&&(n[0].locale&&(i=n[0].locale),n[0].key&&(a=n[0].key),o=Object.keys(n[0]).reduce((e,s)=>m(t,s)?Object.assign({},e,{[s]:n[0][s]}):e,null)):2===n.length&&(r(n[0])&&(a=n[0]),r(n[1])&&(i=n[1])),this._n(e,i,a,o)}_ntp(t,e,n,s){if(!tt.availabilities.numberFormat)return[];if(!n){return(s?new Intl.NumberFormat(e,s):new Intl.NumberFormat(e)).formatToParts(t)}const r=this._getNumberFormatter(t,e,this.fallbackLocale,this._getNumberFormats(),n,s),i=r&&r.formatToParts(t);if(this._isFallbackRoot(i)){if(!this._root)throw Error("unexpected error");return this._root.$i18n._ntp(t,e,n,s)}return i||[]}}let et;Object.defineProperty(tt,"availabilities",{get(){if(!et){const t="undefined"!=typeof Intl;et={dateTimeFormat:t&&void 0!==Intl.DateTimeFormat,numberFormat:t&&void 0!==Intl.NumberFormat}}return et}}),tt.install=I,tt.version="8.21.0";export default tt;