const LOCALES_GEO_COUNTRIES={de:"DE",en:"UK",es:"ES",it:"IT",fr:"FR",pt:"PT",br:"BR",mx:"MX",in:"IN",hk:"HK",sg:"SG",jp:"JP",kr:"KR",nl:"NL",tr:"TR",pl:"PL",ru:"RU",ar:"AR",ve:"VE",co:"CO",za:"ZA",my:"MY",ae:"AE",eg:"EG",cl:"CL",pe:"PE",th:"TH",id:"ID",ir:"IR",pk:"PK",ph:"PH",tw:"TW",vn:"VN",ca:"CA",us:"US",sa:"SA",ua:"UA",be:"BE",bg:"BG",cz:"CZ",se:"SE",si:"SI",sk:"SK",fi:"FI",hr:"HR",no:"NO",rs:"RS",dk:"DK",hu:"HU",gr:"GR"};const LOCALES_ISO_GROUPS={ar:["ae","eg","sa"],de:["de"],en:["en","in","hk","sg","za","my","pk","ca","us","ph"],es:["es","mx","ar","ve","co","cl","pe"],fa:["ir"],fr:["fr"],id:["id"],it:["it"],ja:["jp"],ko:["kr"],nl:["nl","be"],pl:["pl"],pt:["pt","br"],ru:["ru"],th:["th"],tr:["tr"],uk:["ua"],vi:["vn"],zh:["tw"],bg:["bg"],cs:["cz"],sv:["se"],sl:["si"],sk:["sk"],fi:["fi"],hr:["hr"],no:["no"],sr:["rs"],da:["dk"],hu:["hu"],el:["gr"]};const DIY_LOCALES_ISO_GROUPS={ar:["ae","eg","sa"],bg:["bg"],cz:["cz"],de:["de"],dk:["dk"],en:["en","in","hk","sg","za","my","pk","ca","us","ph"],es:["es","mx","ar","ve","co","cl","pe"],fi:["fi"],fr:["fr"],gr:["gr"],hr:["hr"],hu:["hu"],id:["id"],it:["it"],jp:["jp"],kr:["kr"],nl:["nl","be"],no:["no"],pl:["pl"],pt:["pt","br"],rs:["rs"],ru:["ru"],se:["se"],si:["si"],sk:["sk"],th:["th"],tr:["tr"],tw:["tw"],ua:["ua"],vn:["vn"]};const LOCALES_GEO_COUNTRY_NAMES={de:"Germany",gb:"United Kingdom",en:"United Kingdom",es:"Spain",it:"Italy",fr:"France",pt:"Portugal",br:"Brazil",mx:"Mexico",in:"India",hk:"Hong Kong",sg:"Singapore",jp:"Japan",kr:"Korea",nl:"Netherlands",tr:"Turkey",pl:"Poland",ru:"Russia",ar:"Argentina",ve:"Venezuela",co:"Colombia",za:"South Africa",my:"Malaysia",ae:"United Arab Emirates",eg:"Egypt",cl:"Chile",pe:"Peru",th:"Thailand",id:"Indonesia",ir:"Iran",pk:"Pakistan",ph:"Philippines",tw:"Taiwan",vn:"Vietnam",ca:"Canada",us:"United States of America",sa:"Kingdom of Saudi Arabia",ua:"Ukraine",be:"Belgium",bg:"Bulgaria",cz:"Czech Republic",se:"Sweden",si:"Slovenia",sk:"Slovakia",fi:"Finland",hr:"Croatia",no:"Norway",rs:"Serbia",dk:"Denmark",hu:"Hungary",gr:"Greece"};const LOCALES_DOMAINS={de:"de",en:"co.uk",es:"es",it:"it",fr:"fr",pt:"pt",br:"com.br",mx:"com.mx",in:"in",hk:"hk",sg:"sg",jp:"jp",kr:"co.kr",nl:"nl",tr:"com.tr",pl:"pl",ru:"ru",ar:"com.ar",ve:"com.ve",co:"com.co",za:"co.za",my:"com.my",ae:"ae",eg:"com.eg",cl:"cl",pe:"pe",th:"co.th",id:"co.id",ir:"ir",pk:"pk",ph:"ph",tw:"tw",vn:"vn",ca:"ca",us:"com",sa:"sa",ua:"ua",be:"be",bg:"bg",cz:"cz",se:"se",si:"si",sk:"sk",fi:"fi",hr:"hr",no:"no",rs:"rs",dk:"dk",hu:"hu",gr:"com.gr"};(function(root,factory){if(typeof define==="function"&&define.amd){define("i18n",function(){return factory(root)})}else if(typeof module==="object"&&module.exports){module.exports=factory(root)}else{root.I18n=factory(root)}})(this,function(global){;"use strict";var I18n=global&&global.I18n||{};var slice=Array.prototype.slice;var padding=function(number){return("0"+number.toString()).substr(-2)};var toFixed=function(number,precision){return decimalAdjust("round",number,-precision).toFixed(precision)};var isObject=function(obj){var type=typeof obj;return type==="function"||type==="object"};var isFunction=function(func){var type=typeof func;return type==="function"};var isSet=function(value){return typeof value!=="undefined"&&value!==null};var isArray=function(val){if(Array.isArray){return Array.isArray(val)}return Object.prototype.toString.call(val)==="[object Array]"};var isString=function(val){return typeof value=="string"||Object.prototype.toString.call(val)==="[object String]"};var isNumber=function(val){return typeof val=="number"||Object.prototype.toString.call(val)==="[object Number]"};var isBoolean=function(val){return val===true||val===false};var decimalAdjust=function(type,value,exp){if(typeof exp==="undefined"||+exp===0){return Math[type](value)}value=+value;exp=+exp;if(isNaN(value)||!(typeof exp==="number"&&exp%1===0)){return NaN}value=value.toString().split("e");value=Math[type](+(value[0]+"e"+(value[1]?+value[1]-exp:-exp)));value=value.toString().split("e");return+(value[0]+"e"+(value[1]?+value[1]+exp:exp))};var lazyEvaluate=function(message,scope){if(isFunction(message)){return message(scope)}else{return message}};var merge=function(dest,obj){var key,value;for(key in obj)if(obj.hasOwnProperty(key)){value=obj[key];if(isString(value)||isNumber(value)||isBoolean(value)){dest[key]=value}else{if(dest[key]==null)dest[key]={};merge(dest[key],value)}}return dest};var DATE={day_names:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],abbr_day_names:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],month_names:[null,"January","February","March","April","May","June","July","August","September","October","November","December"],abbr_month_names:[null,"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],meridian:["AM","PM"]};var NUMBER_FORMAT={precision:3,separator:".",delimiter:",",strip_insignificant_zeros:false};var CURRENCY_FORMAT={unit:"$",precision:2,format:"%u%n",sign_first:true,delimiter:",",separator:"."};var PERCENTAGE_FORMAT={unit:"%",precision:3,format:"%n%u",separator:".",delimiter:""};var SIZE_UNITS=[null,"kb","mb","gb","tb"];var DEFAULT_OPTIONS={defaultLocale:"en",locale:"en",defaultSeparator:".",placeholder:/(?:\{\{|%\{)(.*?)(?:\}\}?)/gm,fallbacks:false,translations:{},missingBehaviour:"message",missingTranslationPrefix:""};I18n.reset=function(){var key;for(key in DEFAULT_OPTIONS){this[key]=DEFAULT_OPTIONS[key]}};I18n.initializeOptions=function(){var key;for(key in DEFAULT_OPTIONS)if(!isSet(this[key])){this[key]=DEFAULT_OPTIONS[key]}};I18n.initializeOptions();I18n.locales={};I18n.locales.get=function(locale){var result=this[locale]||this[I18n.locale]||this["default"];if(isFunction(result)){result=result(locale)}if(isArray(result)===false){result=[result]}return result};I18n.locales["default"]=function(locale){var locales=[],list=[];if(locale){locales.push(locale)}if(!locale&&I18n.locale){locales.push(I18n.locale)}if(I18n.fallbacks&&I18n.defaultLocale){locales.push(I18n.defaultLocale)}locales.forEach(function(locale){var localeParts=locale.split("-");var firstFallback=null;var secondFallback=null;if(localeParts.length===3){firstFallback=[localeParts[0],localeParts[1]].join("-");secondFallback=localeParts[0]}else if(localeParts.length===2){firstFallback=localeParts[0]}if(list.indexOf(locale)===-1){list.push(locale)}if(!I18n.fallbacks){return}[firstFallback,secondFallback].forEach(function(nullableFallbackLocale){if(typeof nullableFallbackLocale==="undefined"){return}if(nullableFallbackLocale===null){return}if(nullableFallbackLocale===locale){return}if(list.indexOf(nullableFallbackLocale)!==-1){return}list.push(nullableFallbackLocale)})});if(!locales.length){locales.push("en")}return list};I18n.pluralization={};I18n.pluralization.get=function(locale){return this[locale]||this[I18n.locale]||this["default"]};I18n.pluralization["default"]=function(count){switch(count){case 0:return["zero","other"];case 1:return["one"];default:return["other"]}};I18n.currentLocale=function(){return this.locale||this.defaultLocale};I18n.isSet=isSet;I18n.lookup=function(scope,options){options=options||{};var locales=this.locales.get(options.locale).slice(),requestedLocale=locales[0],locale,scopes,fullScope,translations;fullScope=this.getFullScope(scope,options);while(locales.length){locale=locales.shift();scopes=fullScope.split(this.defaultSeparator);translations=this.translations[locale];if(!translations){continue}while(scopes.length){translations=translations[scopes.shift()];if(translations===undefined||translations===null){break}}if(translations!==undefined&&translations!==null){return translations}}if(isSet(options.defaultValue)){return lazyEvaluate(options.defaultValue,scope)}};I18n.pluralizationLookupWithoutFallback=function(count,locale,translations){var pluralizer=this.pluralization.get(locale),pluralizerKeys=pluralizer(count),pluralizerKey,message;if(isObject(translations)){while(pluralizerKeys.length){pluralizerKey=pluralizerKeys.shift();if(isSet(translations[pluralizerKey])){message=translations[pluralizerKey];break}}}return message};I18n.pluralizationLookup=function(count,scope,options){options=options||{};var locales=this.locales.get(options.locale).slice(),requestedLocale=locales[0],locale,scopes,translations,message;scope=this.getFullScope(scope,options);while(locales.length){locale=locales.shift();scopes=scope.split(this.defaultSeparator);translations=this.translations[locale];if(!translations){continue}while(scopes.length){translations=translations[scopes.shift()];if(!isObject(translations)){break}if(scopes.length==0){message=this.pluralizationLookupWithoutFallback(count,locale,translations)}}if(message!=null&&message!=undefined){break}}if(message==null||message==undefined){if(isSet(options.defaultValue)){if(isObject(options.defaultValue)){message=this.pluralizationLookupWithoutFallback(count,options.locale,options.defaultValue)}else{message=options.defaultValue}translations=options.defaultValue}}return{message:message,translations:translations}};I18n.meridian=function(){var time=this.lookup("time");var date=this.lookup("date");if(time&&time.am&&time.pm){return[time.am,time.pm]}else if(date&&date.meridian){return date.meridian}else{return DATE.meridian}};I18n.prepareOptions=function(){var args=slice.call(arguments),options={},subject;while(args.length){subject=args.shift();if(typeof subject!="object"){continue}for(var attr in subject){if(!subject.hasOwnProperty(attr)){continue}if(isSet(options[attr])){continue}options[attr]=subject[attr]}}return options};I18n.createTranslationOptions=function(scope,options){var translationOptions=[{scope:scope}];if(isSet(options.defaults)){translationOptions=translationOptions.concat(options.defaults)}if(isSet(options.defaultValue)){translationOptions.push({message:options.defaultValue})}return translationOptions};I18n.translate=function(scope,options){options=options||{};var translationOptions=this.createTranslationOptions(scope,options);var translation;var optionsWithoutDefault=this.prepareOptions(options);delete optionsWithoutDefault.defaultValue;var translationFound=translationOptions.some(function(translationOption){if(isSet(translationOption.scope)){translation=this.lookup(translationOption.scope,optionsWithoutDefault)}else if(isSet(translationOption.message)){translation=lazyEvaluate(translationOption.message,scope)}if(translation!==undefined&&translation!==null){return true}},this);if(!translationFound){return this.missingTranslation(scope,options)}if(typeof translation==="string"){translation=this.interpolate(translation,options)}else if(isObject(translation)&&isSet(options.count)){translation=this.pluralize(options.count,scope,options)}return translation};I18n.interpolate=function(message,options){options=options||{};var matches=message.match(this.placeholder),placeholder,value,name,regex;if(!matches){return message}var value;while(matches.length){placeholder=matches.shift();name=placeholder.replace(this.placeholder,"$1");if(isSet(options[name])){value=options[name].toString().replace(/\$/gm,"_#$#_")}else if(name in options){value=this.nullPlaceholder(placeholder,message,options)}else{value=this.missingPlaceholder(placeholder,message,options)}regex=new RegExp(placeholder.replace(/\{/gm,"\\{").replace(/\}/gm,"\\}"));message=message.replace(regex,value)}return message.replace(/_#\$#_/g,"$")};I18n.pluralize=function(count,scope,options){options=this.prepareOptions({count:String(count)},options);var pluralizer,message,result;result=this.pluralizationLookup(count,scope,options);if(result.translations==undefined||result.translations==null){return this.missingTranslation(scope,options)}if(result.message!=undefined&&result.message!=null){return this.interpolate(result.message,options)}else{pluralizer=this.pluralization.get(options.locale);return this.missingTranslation(scope+"."+pluralizer(count)[0],options)}};I18n.missingTranslation=function(scope,options){if(this.missingBehaviour=="guess"){var s=scope.split(".").slice(-1)[0];return(this.missingTranslationPrefix.length>0?this.missingTranslationPrefix:"")+s.replace("_"," ").replace(/([a-z])([A-Z])/g,function(match,p1,p2){return p1+" "+p2.toLowerCase()})}var localeForTranslation=options!=null&&options.locale!=null?options.locale:this.currentLocale();var fullScope=this.getFullScope(scope,options);var fullScopeWithLocale=[localeForTranslation,fullScope].join(this.defaultSeparator);return'[missing "'+fullScopeWithLocale+'" translation]'};I18n.missingPlaceholder=function(placeholder,message,options){return"[missing "+placeholder+" value]"};I18n.nullPlaceholder=function(){return I18n.missingPlaceholder.apply(I18n,arguments)};I18n.toNumber=function(number,options){options=this.prepareOptions(options,this.lookup("number.format"),NUMBER_FORMAT);var negative=number<0,string=toFixed(Math.abs(number),options.precision).toString(),parts=string.split("."),precision,buffer=[],formattedNumber,format=options.format||"%n",sign=negative?"-":"";number=parts[0];precision=parts[1];while(number.length>0){buffer.unshift(number.substr(Math.max(0,number.length-3),3));number=number.substr(0,number.length-3)}formattedNumber=buffer.join(options.delimiter);if(options.strip_insignificant_zeros&&precision){precision=precision.replace(/0+$/,"")}if(options.precision>0&&precision){formattedNumber+=options.separator+precision}if(options.sign_first){format="%s"+format}else{format=format.replace("%n","%s%n")}formattedNumber=format.replace("%u",options.unit).replace("%n",formattedNumber).replace("%s",sign);return formattedNumber};I18n.toCurrency=function(number,options){options=this.prepareOptions(options,this.lookup("number.currency.format"),this.lookup("number.format"),CURRENCY_FORMAT);return this.toNumber(number,options)};I18n.localize=function(scope,value,options){options||(options={});switch(scope){case"currency":return this.toCurrency(value);case"number":scope=this.lookup("number.format");return this.toNumber(value,scope);case"percentage":return this.toPercentage(value);default:var localizedValue;if(scope.match(/^(date|time)/)){localizedValue=this.toTime(scope,value)}else{localizedValue=value.toString()}return this.interpolate(localizedValue,options)}};I18n.parseDate=function(date){var matches,convertedDate,fraction;if(typeof date=="object"){return date}matches=date.toString().match(/(\d{4})-(\d{2})-(\d{2})(?:[ T](\d{2}):(\d{2}):(\d{2})([\.,]\d{1,3})?)?(Z|\+00:?00)?/);if(matches){for(var i=1;i<=6;i++){matches[i]=parseInt(matches[i],10)||0}matches[2]-=1;fraction=matches[7]?1e3*("0"+matches[7]):null;if(matches[8]){convertedDate=new Date(Date.UTC(matches[1],matches[2],matches[3],matches[4],matches[5],matches[6],fraction))}else{convertedDate=new Date(matches[1],matches[2],matches[3],matches[4],matches[5],matches[6],fraction)}}else if(typeof date=="number"){convertedDate=new Date;convertedDate.setTime(date)}else if(date.match(/([A-Z][a-z]{2}) ([A-Z][a-z]{2}) (\d+) (\d+:\d+:\d+) ([+-]\d+) (\d+)/)){convertedDate=new Date;convertedDate.setTime(Date.parse([RegExp.$1,RegExp.$2,RegExp.$3,RegExp.$6,RegExp.$4,RegExp.$5].join(" ")))}else if(date.match(/\d+ \d+:\d+:\d+ [+-]\d+ \d+/)){convertedDate=new Date;convertedDate.setTime(Date.parse(date))}else{convertedDate=new Date;convertedDate.setTime(Date.parse(date))}return convertedDate};I18n.strftime=function(date,format){var options=this.lookup("date"),meridianOptions=I18n.meridian();if(!options){options={}}options=this.prepareOptions(options,DATE);if(isNaN(date.getTime())){throw new Error("I18n.strftime() requires a valid date object, but received an invalid date.")}var weekDay=date.getDay(),day=date.getDate(),year=date.getFullYear(),month=date.getMonth()+1,hour=date.getHours(),hour12=hour,meridian=hour>11?1:0,secs=date.getSeconds(),mins=date.getMinutes(),offset=date.getTimezoneOffset(),absOffsetHours=Math.floor(Math.abs(offset/60)),absOffsetMinutes=Math.abs(offset)-absOffsetHours*60,timezoneoffset=(offset>0?"-":"+")+(absOffsetHours.toString().length<2?"0"+absOffsetHours:absOffsetHours)+(absOffsetMinutes.toString().length<2?"0"+absOffsetMinutes:absOffsetMinutes);if(hour12>12){hour12=hour12-12}else if(hour12===0){hour12=12}format=format.replace("%a",options.abbr_day_names[weekDay]);format=format.replace("%A",options.day_names[weekDay]);format=format.replace("%b",options.abbr_month_names[month]);format=format.replace("%B",options.month_names[month]);format=format.replace("%d",padding(day));format=format.replace("%e",day);format=format.replace("%-d",day);format=format.replace("%H",padding(hour));format=format.replace("%-H",hour);format=format.replace("%I",padding(hour12));format=format.replace("%-I",hour12);format=format.replace("%m",padding(month));format=format.replace("%-m",month);format=format.replace("%M",padding(mins));format=format.replace("%-M",mins);format=format.replace("%p",meridianOptions[meridian]);format=format.replace("%S",padding(secs));format=format.replace("%-S",secs);format=format.replace("%w",weekDay);format=format.replace("%y",padding(year));format=format.replace("%-y",padding(year).replace(/^0+/,""));format=format.replace("%Y",year);format=format.replace("%z",timezoneoffset);return format};I18n.toTime=function(scope,dateString){var date=this.parseDate(dateString),format=this.lookup(scope);if(date.toString().match(/invalid/i)){return date.toString()}if(!format){return date.toString()}return this.strftime(date,format)};I18n.toPercentage=function(number,options){options=this.prepareOptions(options,this.lookup("number.percentage.format"),this.lookup("number.format"),PERCENTAGE_FORMAT);return this.toNumber(number,options)};I18n.toHumanSize=function(number,options){var kb=1024,size=number,iterations=0,unit,precision;while(size>=kb&&iterations<4){size=size/kb;iterations+=1}if(iterations===0){unit=this.t("number.human.storage_units.units.byte",{count:size});precision=0}else{unit=this.t("number.human.storage_units.units."+SIZE_UNITS[iterations]);precision=size-Math.floor(size)===0?0:1}options=this.prepareOptions(options,{unit:unit,precision:precision,format:"%n%u",delimiter:""});return this.toNumber(size,options)};I18n.getFullScope=function(scope,options){options=options||{};if(isArray(scope)){scope=scope.join(this.defaultSeparator)}if(options.scope){scope=[options.scope,scope].join(this.defaultSeparator)}return scope};I18n.extend=function(obj1,obj2){if(typeof obj1==="undefined"&&typeof obj2==="undefined"){return{}}return merge(obj1,obj2)};I18n.t=I18n.translate;I18n.l=I18n.localize;I18n.p=I18n.pluralize;I18n.geoCountries=LOCALES_GEO_COUNTRIES;I18n.isoCountries=LOCALES_GEO_COUNTRY_NAMES;I18n.DiyIsoCountries=DIY_LOCALES_ISO_GROUPS;I18n.getCountryNameByLocale=function(locale){return LOCALES_GEO_COUNTRY_NAMES[locale]};I18n.isoGroups=LOCALES_ISO_GROUPS;I18n.getGroupByLocale=function(locale){return LOCALES_ISO_GROUPS[locale]};I18n.getDomainByLocale=function(locale){return LOCALES_DOMAINS[locale]};return I18n});