core.js 169 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351
  1. 'use strict';
  2. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
  3. return typeof obj;
  4. } : function (obj) {
  5. return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj;
  6. };
  7. var jsx = function () {
  8. var REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for && Symbol.for("react.element") || 0xeac7;
  9. return function createRawReactElement(type, props, key, children) {
  10. var defaultProps = type && type.defaultProps;
  11. var childrenLength = arguments.length - 3;
  12. if (!props && childrenLength !== 0) {
  13. props = {};
  14. }
  15. if (props && defaultProps) {
  16. for (var propName in defaultProps) {
  17. if (props[propName] === void 0) {
  18. props[propName] = defaultProps[propName];
  19. }
  20. }
  21. } else if (!props) {
  22. props = defaultProps || {};
  23. }
  24. if (childrenLength === 1) {
  25. props.children = children;
  26. } else if (childrenLength > 1) {
  27. var childArray = Array(childrenLength);
  28. for (var i = 0; i < childrenLength; i++) {
  29. childArray[i] = arguments[i + 3];
  30. }
  31. props.children = childArray;
  32. }
  33. return {
  34. $$typeof: REACT_ELEMENT_TYPE,
  35. type: type,
  36. key: key === undefined ? null : '' + key,
  37. ref: null,
  38. props: props,
  39. _owner: null
  40. };
  41. };
  42. }();
  43. var asyncToGenerator = function (fn) {
  44. return function () {
  45. var gen = fn.apply(this, arguments);
  46. return new Promise(function (resolve, reject) {
  47. function step(key, arg) {
  48. try {
  49. var info = gen[key](arg);
  50. var value = info.value;
  51. } catch (error) {
  52. reject(error);
  53. return;
  54. }
  55. if (info.done) {
  56. resolve(value);
  57. } else {
  58. return Promise.resolve(value).then(function (value) {
  59. return step("next", value);
  60. }, function (err) {
  61. return step("throw", err);
  62. });
  63. }
  64. }
  65. return step("next");
  66. });
  67. };
  68. };
  69. var classCallCheck = function (instance, Constructor) {
  70. if (!(instance instanceof Constructor)) {
  71. throw new TypeError("Cannot call a class as a function");
  72. }
  73. };
  74. var createClass = function () {
  75. function defineProperties(target, props) {
  76. for (var i = 0; i < props.length; i++) {
  77. var descriptor = props[i];
  78. descriptor.enumerable = descriptor.enumerable || false;
  79. descriptor.configurable = true;
  80. if ("value" in descriptor) descriptor.writable = true;
  81. Object.defineProperty(target, descriptor.key, descriptor);
  82. }
  83. }
  84. return function (Constructor, protoProps, staticProps) {
  85. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  86. if (staticProps) defineProperties(Constructor, staticProps);
  87. return Constructor;
  88. };
  89. }();
  90. var defineEnumerableProperties = function (obj, descs) {
  91. for (var key in descs) {
  92. var desc = descs[key];
  93. desc.configurable = desc.enumerable = true;
  94. if ("value" in desc) desc.writable = true;
  95. Object.defineProperty(obj, key, desc);
  96. }
  97. return obj;
  98. };
  99. var defaults = function (obj, defaults) {
  100. var keys = Object.getOwnPropertyNames(defaults);
  101. for (var i = 0; i < keys.length; i++) {
  102. var key = keys[i];
  103. var value = Object.getOwnPropertyDescriptor(defaults, key);
  104. if (value && value.configurable && obj[key] === undefined) {
  105. Object.defineProperty(obj, key, value);
  106. }
  107. }
  108. return obj;
  109. };
  110. var defineProperty$1 = function (obj, key, value) {
  111. if (key in obj) {
  112. Object.defineProperty(obj, key, {
  113. value: value,
  114. enumerable: true,
  115. configurable: true,
  116. writable: true
  117. });
  118. } else {
  119. obj[key] = value;
  120. }
  121. return obj;
  122. };
  123. var _extends = Object.assign || function (target) {
  124. for (var i = 1; i < arguments.length; i++) {
  125. var source = arguments[i];
  126. for (var key in source) {
  127. if (Object.prototype.hasOwnProperty.call(source, key)) {
  128. target[key] = source[key];
  129. }
  130. }
  131. }
  132. return target;
  133. };
  134. var get = function get(object, property, receiver) {
  135. if (object === null) object = Function.prototype;
  136. var desc = Object.getOwnPropertyDescriptor(object, property);
  137. if (desc === undefined) {
  138. var parent = Object.getPrototypeOf(object);
  139. if (parent === null) {
  140. return undefined;
  141. } else {
  142. return get(parent, property, receiver);
  143. }
  144. } else if ("value" in desc) {
  145. return desc.value;
  146. } else {
  147. var getter = desc.get;
  148. if (getter === undefined) {
  149. return undefined;
  150. }
  151. return getter.call(receiver);
  152. }
  153. };
  154. var inherits = function (subClass, superClass) {
  155. if (typeof superClass !== "function" && superClass !== null) {
  156. throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
  157. }
  158. subClass.prototype = Object.create(superClass && superClass.prototype, {
  159. constructor: {
  160. value: subClass,
  161. enumerable: false,
  162. writable: true,
  163. configurable: true
  164. }
  165. });
  166. if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
  167. };
  168. var _instanceof = function (left, right) {
  169. if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
  170. return right[Symbol.hasInstance](left);
  171. } else {
  172. return left instanceof right;
  173. }
  174. };
  175. var interopRequireDefault = function (obj) {
  176. return obj && obj.__esModule ? obj : {
  177. default: obj
  178. };
  179. };
  180. var interopRequireWildcard = function (obj) {
  181. if (obj && obj.__esModule) {
  182. return obj;
  183. } else {
  184. var newObj = {};
  185. if (obj != null) {
  186. for (var key in obj) {
  187. if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
  188. }
  189. }
  190. newObj.default = obj;
  191. return newObj;
  192. }
  193. };
  194. var newArrowCheck = function (innerThis, boundThis) {
  195. if (innerThis !== boundThis) {
  196. throw new TypeError("Cannot instantiate an arrow function");
  197. }
  198. };
  199. var objectDestructuringEmpty = function (obj) {
  200. if (obj == null) throw new TypeError("Cannot destructure undefined");
  201. };
  202. var objectWithoutProperties = function (obj, keys) {
  203. var target = {};
  204. for (var i in obj) {
  205. if (keys.indexOf(i) >= 0) continue;
  206. if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
  207. target[i] = obj[i];
  208. }
  209. return target;
  210. };
  211. var possibleConstructorReturn = function (self, call) {
  212. if (!self) {
  213. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  214. }
  215. return call && (typeof call === "object" || typeof call === "function") ? call : self;
  216. };
  217. var selfGlobal = typeof global === "undefined" ? self : global;
  218. var set = function set(object, property, value, receiver) {
  219. var desc = Object.getOwnPropertyDescriptor(object, property);
  220. if (desc === undefined) {
  221. var parent = Object.getPrototypeOf(object);
  222. if (parent !== null) {
  223. set(parent, property, value, receiver);
  224. }
  225. } else if ("value" in desc && desc.writable) {
  226. desc.value = value;
  227. } else {
  228. var setter = desc.set;
  229. if (setter !== undefined) {
  230. setter.call(receiver, value);
  231. }
  232. }
  233. return value;
  234. };
  235. var slicedToArray = function () {
  236. function sliceIterator(arr, i) {
  237. var _arr = [];
  238. var _n = true;
  239. var _d = false;
  240. var _e = undefined;
  241. try {
  242. for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
  243. _arr.push(_s.value);
  244. if (i && _arr.length === i) break;
  245. }
  246. } catch (err) {
  247. _d = true;
  248. _e = err;
  249. } finally {
  250. try {
  251. if (!_n && _i["return"]) _i["return"]();
  252. } finally {
  253. if (_d) throw _e;
  254. }
  255. }
  256. return _arr;
  257. }
  258. return function (arr, i) {
  259. if (Array.isArray(arr)) {
  260. return arr;
  261. } else if (Symbol.iterator in Object(arr)) {
  262. return sliceIterator(arr, i);
  263. } else {
  264. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  265. }
  266. };
  267. }();
  268. var slicedToArrayLoose = function (arr, i) {
  269. if (Array.isArray(arr)) {
  270. return arr;
  271. } else if (Symbol.iterator in Object(arr)) {
  272. var _arr = [];
  273. for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
  274. _arr.push(_step.value);
  275. if (i && _arr.length === i) break;
  276. }
  277. return _arr;
  278. } else {
  279. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  280. }
  281. };
  282. var taggedTemplateLiteral = function (strings, raw) {
  283. return Object.freeze(Object.defineProperties(strings, {
  284. raw: {
  285. value: Object.freeze(raw)
  286. }
  287. }));
  288. };
  289. var taggedTemplateLiteralLoose = function (strings, raw) {
  290. strings.raw = raw;
  291. return strings;
  292. };
  293. var temporalRef = function (val, name, undef) {
  294. if (val === undef) {
  295. throw new ReferenceError(name + " is not defined - temporal dead zone");
  296. } else {
  297. return val;
  298. }
  299. };
  300. var temporalUndefined = {};
  301. var toArray = function (arr) {
  302. return Array.isArray(arr) ? arr : Array.from(arr);
  303. };
  304. var toConsumableArray = function (arr) {
  305. if (Array.isArray(arr)) {
  306. for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
  307. return arr2;
  308. } else {
  309. return Array.from(arr);
  310. }
  311. };
  312. var babelHelpers$1 = Object.freeze({
  313. jsx: jsx,
  314. asyncToGenerator: asyncToGenerator,
  315. classCallCheck: classCallCheck,
  316. createClass: createClass,
  317. defineEnumerableProperties: defineEnumerableProperties,
  318. defaults: defaults,
  319. defineProperty: defineProperty$1,
  320. get: get,
  321. inherits: inherits,
  322. interopRequireDefault: interopRequireDefault,
  323. interopRequireWildcard: interopRequireWildcard,
  324. newArrowCheck: newArrowCheck,
  325. objectDestructuringEmpty: objectDestructuringEmpty,
  326. objectWithoutProperties: objectWithoutProperties,
  327. possibleConstructorReturn: possibleConstructorReturn,
  328. selfGlobal: selfGlobal,
  329. set: set,
  330. slicedToArray: slicedToArray,
  331. slicedToArrayLoose: slicedToArrayLoose,
  332. taggedTemplateLiteral: taggedTemplateLiteral,
  333. taggedTemplateLiteralLoose: taggedTemplateLiteralLoose,
  334. temporalRef: temporalRef,
  335. temporalUndefined: temporalUndefined,
  336. toArray: toArray,
  337. toConsumableArray: toConsumableArray,
  338. typeof: _typeof,
  339. extends: _extends,
  340. instanceof: _instanceof
  341. });
  342. var realDefineProp = function () {
  343. var sentinel = function sentinel() {};
  344. try {
  345. Object.defineProperty(sentinel, 'a', {
  346. get: function get() {
  347. return 1;
  348. }
  349. });
  350. Object.defineProperty(sentinel, 'prototype', { writable: false });
  351. return sentinel.a === 1 && sentinel.prototype instanceof Object;
  352. } catch (e) {
  353. return false;
  354. }
  355. }();
  356. // Need a workaround for getters in ES3
  357. var es3 = !realDefineProp && !Object.prototype.__defineGetter__;
  358. // We use this a lot (and need it for proto-less objects)
  359. var hop = Object.prototype.hasOwnProperty;
  360. // Naive defineProperty for compatibility
  361. var defineProperty = realDefineProp ? Object.defineProperty : function (obj, name, desc) {
  362. if ('get' in desc && obj.__defineGetter__) obj.__defineGetter__(name, desc.get);else if (!hop.call(obj, name) || 'value' in desc) obj[name] = desc.value;
  363. };
  364. // Array.prototype.indexOf, as good as we need it to be
  365. var arrIndexOf = Array.prototype.indexOf || function (search) {
  366. /*jshint validthis:true */
  367. var t = this;
  368. if (!t.length) return -1;
  369. for (var i = arguments[1] || 0, max = t.length; i < max; i++) {
  370. if (t[i] === search) return i;
  371. }
  372. return -1;
  373. };
  374. // Create an object with the specified prototype (2nd arg required for Record)
  375. var objCreate = Object.create || function (proto, props) {
  376. var obj = void 0;
  377. function F() {}
  378. F.prototype = proto;
  379. obj = new F();
  380. for (var k in props) {
  381. if (hop.call(props, k)) defineProperty(obj, k, props[k]);
  382. }
  383. return obj;
  384. };
  385. // Snapshot some (hopefully still) native built-ins
  386. var arrSlice = Array.prototype.slice;
  387. var arrConcat = Array.prototype.concat;
  388. var arrPush = Array.prototype.push;
  389. var arrJoin = Array.prototype.join;
  390. var arrShift = Array.prototype.shift;
  391. // Naive Function.prototype.bind for compatibility
  392. var fnBind = Function.prototype.bind || function (thisObj) {
  393. var fn = this,
  394. args = arrSlice.call(arguments, 1);
  395. // All our (presently) bound functions have either 1 or 0 arguments. By returning
  396. // different function signatures, we can pass some tests in ES3 environments
  397. if (fn.length === 1) {
  398. return function () {
  399. return fn.apply(thisObj, arrConcat.call(args, arrSlice.call(arguments)));
  400. };
  401. }
  402. return function () {
  403. return fn.apply(thisObj, arrConcat.call(args, arrSlice.call(arguments)));
  404. };
  405. };
  406. // Object housing internal properties for constructors
  407. var internals = objCreate(null);
  408. // Keep internal properties internal
  409. var secret = Math.random();
  410. // Helper functions
  411. // ================
  412. /**
  413. * A function to deal with the inaccuracy of calculating log10 in pre-ES6
  414. * JavaScript environments. Math.log(num) / Math.LN10 was responsible for
  415. * causing issue #62.
  416. */
  417. function log10Floor(n) {
  418. // ES6 provides the more accurate Math.log10
  419. if (typeof Math.log10 === 'function') return Math.floor(Math.log10(n));
  420. var x = Math.round(Math.log(n) * Math.LOG10E);
  421. return x - (Number('1e' + x) > n);
  422. }
  423. /**
  424. * A map that doesn't contain Object in its prototype chain
  425. */
  426. function Record(obj) {
  427. // Copy only own properties over unless this object is already a Record instance
  428. for (var k in obj) {
  429. if (obj instanceof Record || hop.call(obj, k)) defineProperty(this, k, { value: obj[k], enumerable: true, writable: true, configurable: true });
  430. }
  431. }
  432. Record.prototype = objCreate(null);
  433. /**
  434. * An ordered list
  435. */
  436. function List() {
  437. defineProperty(this, 'length', { writable: true, value: 0 });
  438. if (arguments.length) arrPush.apply(this, arrSlice.call(arguments));
  439. }
  440. List.prototype = objCreate(null);
  441. /**
  442. * Constructs a regular expression to restore tainted RegExp properties
  443. */
  444. function createRegExpRestore() {
  445. if (internals.disableRegExpRestore) {
  446. return function () {/* no-op */};
  447. }
  448. var regExpCache = {
  449. lastMatch: RegExp.lastMatch || '',
  450. leftContext: RegExp.leftContext,
  451. multiline: RegExp.multiline,
  452. input: RegExp.input
  453. },
  454. has = false;
  455. // Create a snapshot of all the 'captured' properties
  456. for (var i = 1; i <= 9; i++) {
  457. has = (regExpCache['$' + i] = RegExp['$' + i]) || has;
  458. }return function () {
  459. // Now we've snapshotted some properties, escape the lastMatch string
  460. var esc = /[.?*+^$[\]\\(){}|-]/g,
  461. lm = regExpCache.lastMatch.replace(esc, '\\$&'),
  462. reg = new List();
  463. // If any of the captured strings were non-empty, iterate over them all
  464. if (has) {
  465. for (var _i = 1; _i <= 9; _i++) {
  466. var m = regExpCache['$' + _i];
  467. // If it's empty, add an empty capturing group
  468. if (!m) lm = '()' + lm;
  469. // Else find the string in lm and escape & wrap it to capture it
  470. else {
  471. m = m.replace(esc, '\\$&');
  472. lm = lm.replace(m, '(' + m + ')');
  473. }
  474. // Push it to the reg and chop lm to make sure further groups come after
  475. arrPush.call(reg, lm.slice(0, lm.indexOf('(') + 1));
  476. lm = lm.slice(lm.indexOf('(') + 1);
  477. }
  478. }
  479. var exprStr = arrJoin.call(reg, '') + lm;
  480. // Shorten the regex by replacing each part of the expression with a match
  481. // for a string of that exact length. This is safe for the type of
  482. // expressions generated above, because the expression matches the whole
  483. // match string, so we know each group and each segment between capturing
  484. // groups can be matched by its length alone.
  485. exprStr = exprStr.replace(/(\\\(|\\\)|[^()])+/g, function (match) {
  486. return '[\\s\\S]{' + match.replace('\\', '').length + '}';
  487. });
  488. // Create the regular expression that will reconstruct the RegExp properties
  489. var expr = new RegExp(exprStr, regExpCache.multiline ? 'gm' : 'g');
  490. // Set the lastIndex of the generated expression to ensure that the match
  491. // is found in the correct index.
  492. expr.lastIndex = regExpCache.leftContext.length;
  493. expr.exec(regExpCache.input);
  494. };
  495. }
  496. /**
  497. * Mimics ES5's abstract ToObject() function
  498. */
  499. function toObject(arg) {
  500. if (arg === null) throw new TypeError('Cannot convert null or undefined to object');
  501. if ((typeof arg === 'undefined' ? 'undefined' : babelHelpers$1['typeof'](arg)) === 'object') return arg;
  502. return Object(arg);
  503. }
  504. function toNumber(arg) {
  505. if (typeof arg === 'number') return arg;
  506. return Number(arg);
  507. }
  508. function toInteger(arg) {
  509. var number = toNumber(arg);
  510. if (isNaN(number)) return 0;
  511. if (number === +0 || number === -0 || number === +Infinity || number === -Infinity) return number;
  512. if (number < 0) return Math.floor(Math.abs(number)) * -1;
  513. return Math.floor(Math.abs(number));
  514. }
  515. function toLength(arg) {
  516. var len = toInteger(arg);
  517. if (len <= 0) return 0;
  518. if (len === Infinity) return Math.pow(2, 53) - 1;
  519. return Math.min(len, Math.pow(2, 53) - 1);
  520. }
  521. /**
  522. * Returns "internal" properties for an object
  523. */
  524. function getInternalProperties(obj) {
  525. if (hop.call(obj, '__getInternalProperties')) return obj.__getInternalProperties(secret);
  526. return objCreate(null);
  527. }
  528. /**
  529. * Defines regular expressions for various operations related to the BCP 47 syntax,
  530. * as defined at http://tools.ietf.org/html/bcp47#section-2.1
  531. */
  532. // extlang = 3ALPHA ; selected ISO 639 codes
  533. // *2("-" 3ALPHA) ; permanently reserved
  534. var extlang = '[a-z]{3}(?:-[a-z]{3}){0,2}';
  535. // language = 2*3ALPHA ; shortest ISO 639 code
  536. // ["-" extlang] ; sometimes followed by
  537. // ; extended language subtags
  538. // / 4ALPHA ; or reserved for future use
  539. // / 5*8ALPHA ; or registered language subtag
  540. var language = '(?:[a-z]{2,3}(?:-' + extlang + ')?|[a-z]{4}|[a-z]{5,8})';
  541. // script = 4ALPHA ; ISO 15924 code
  542. var script = '[a-z]{4}';
  543. // region = 2ALPHA ; ISO 3166-1 code
  544. // / 3DIGIT ; UN M.49 code
  545. var region = '(?:[a-z]{2}|\\d{3})';
  546. // variant = 5*8alphanum ; registered variants
  547. // / (DIGIT 3alphanum)
  548. var variant = '(?:[a-z0-9]{5,8}|\\d[a-z0-9]{3})';
  549. // ; Single alphanumerics
  550. // ; "x" reserved for private use
  551. // singleton = DIGIT ; 0 - 9
  552. // / %x41-57 ; A - W
  553. // / %x59-5A ; Y - Z
  554. // / %x61-77 ; a - w
  555. // / %x79-7A ; y - z
  556. var singleton = '[0-9a-wy-z]';
  557. // extension = singleton 1*("-" (2*8alphanum))
  558. var extension = singleton + '(?:-[a-z0-9]{2,8})+';
  559. // privateuse = "x" 1*("-" (1*8alphanum))
  560. var privateuse = 'x(?:-[a-z0-9]{1,8})+';
  561. // irregular = "en-GB-oed" ; irregular tags do not match
  562. // / "i-ami" ; the 'langtag' production and
  563. // / "i-bnn" ; would not otherwise be
  564. // / "i-default" ; considered 'well-formed'
  565. // / "i-enochian" ; These tags are all valid,
  566. // / "i-hak" ; but most are deprecated
  567. // / "i-klingon" ; in favor of more modern
  568. // / "i-lux" ; subtags or subtag
  569. // / "i-mingo" ; combination
  570. // / "i-navajo"
  571. // / "i-pwn"
  572. // / "i-tao"
  573. // / "i-tay"
  574. // / "i-tsu"
  575. // / "sgn-BE-FR"
  576. // / "sgn-BE-NL"
  577. // / "sgn-CH-DE"
  578. var irregular = '(?:en-GB-oed' + '|i-(?:ami|bnn|default|enochian|hak|klingon|lux|mingo|navajo|pwn|tao|tay|tsu)' + '|sgn-(?:BE-FR|BE-NL|CH-DE))';
  579. // regular = "art-lojban" ; these tags match the 'langtag'
  580. // / "cel-gaulish" ; production, but their subtags
  581. // / "no-bok" ; are not extended language
  582. // / "no-nyn" ; or variant subtags: their meaning
  583. // / "zh-guoyu" ; is defined by their registration
  584. // / "zh-hakka" ; and all of these are deprecated
  585. // / "zh-min" ; in favor of a more modern
  586. // / "zh-min-nan" ; subtag or sequence of subtags
  587. // / "zh-xiang"
  588. var regular = '(?:art-lojban|cel-gaulish|no-bok|no-nyn' + '|zh-(?:guoyu|hakka|min|min-nan|xiang))';
  589. // grandfathered = irregular ; non-redundant tags registered
  590. // / regular ; during the RFC 3066 era
  591. var grandfathered = '(?:' + irregular + '|' + regular + ')';
  592. // langtag = language
  593. // ["-" script]
  594. // ["-" region]
  595. // *("-" variant)
  596. // *("-" extension)
  597. // ["-" privateuse]
  598. var langtag = language + '(?:-' + script + ')?(?:-' + region + ')?(?:-' + variant + ')*(?:-' + extension + ')*(?:-' + privateuse + ')?';
  599. // Language-Tag = langtag ; normal language tags
  600. // / privateuse ; private use tag
  601. // / grandfathered ; grandfathered tags
  602. var expBCP47Syntax = RegExp('^(?:' + langtag + '|' + privateuse + '|' + grandfathered + ')$', 'i');
  603. // Match duplicate variants in a language tag
  604. var expVariantDupes = RegExp('^(?!x).*?-(' + variant + ')-(?:\\w{4,8}-(?!x-))*\\1\\b', 'i');
  605. // Match duplicate singletons in a language tag (except in private use)
  606. var expSingletonDupes = RegExp('^(?!x).*?-(' + singleton + ')-(?:\\w+-(?!x-))*\\1\\b', 'i');
  607. // Match all extension sequences
  608. var expExtSequences = RegExp('-' + extension, 'ig');
  609. // Default locale is the first-added locale data for us
  610. var defaultLocale = void 0;
  611. function setDefaultLocale(locale) {
  612. defaultLocale = locale;
  613. }
  614. // IANA Subtag Registry redundant tag and subtag maps
  615. var redundantTags = {
  616. tags: {
  617. "art-lojban": "jbo",
  618. "i-ami": "ami",
  619. "i-bnn": "bnn",
  620. "i-hak": "hak",
  621. "i-klingon": "tlh",
  622. "i-lux": "lb",
  623. "i-navajo": "nv",
  624. "i-pwn": "pwn",
  625. "i-tao": "tao",
  626. "i-tay": "tay",
  627. "i-tsu": "tsu",
  628. "no-bok": "nb",
  629. "no-nyn": "nn",
  630. "sgn-BE-FR": "sfb",
  631. "sgn-BE-NL": "vgt",
  632. "sgn-CH-DE": "sgg",
  633. "zh-guoyu": "cmn",
  634. "zh-hakka": "hak",
  635. "zh-min-nan": "nan",
  636. "zh-xiang": "hsn",
  637. "sgn-BR": "bzs",
  638. "sgn-CO": "csn",
  639. "sgn-DE": "gsg",
  640. "sgn-DK": "dsl",
  641. "sgn-ES": "ssp",
  642. "sgn-FR": "fsl",
  643. "sgn-GB": "bfi",
  644. "sgn-GR": "gss",
  645. "sgn-IE": "isg",
  646. "sgn-IT": "ise",
  647. "sgn-JP": "jsl",
  648. "sgn-MX": "mfs",
  649. "sgn-NI": "ncs",
  650. "sgn-NL": "dse",
  651. "sgn-NO": "nsl",
  652. "sgn-PT": "psr",
  653. "sgn-SE": "swl",
  654. "sgn-US": "ase",
  655. "sgn-ZA": "sfs",
  656. "zh-cmn": "cmn",
  657. "zh-cmn-Hans": "cmn-Hans",
  658. "zh-cmn-Hant": "cmn-Hant",
  659. "zh-gan": "gan",
  660. "zh-wuu": "wuu",
  661. "zh-yue": "yue"
  662. },
  663. subtags: {
  664. BU: "MM",
  665. DD: "DE",
  666. FX: "FR",
  667. TP: "TL",
  668. YD: "YE",
  669. ZR: "CD",
  670. heploc: "alalc97",
  671. 'in': "id",
  672. iw: "he",
  673. ji: "yi",
  674. jw: "jv",
  675. mo: "ro",
  676. ayx: "nun",
  677. bjd: "drl",
  678. ccq: "rki",
  679. cjr: "mom",
  680. cka: "cmr",
  681. cmk: "xch",
  682. drh: "khk",
  683. drw: "prs",
  684. gav: "dev",
  685. hrr: "jal",
  686. ibi: "opa",
  687. kgh: "kml",
  688. lcq: "ppr",
  689. mst: "mry",
  690. myt: "mry",
  691. sca: "hle",
  692. tie: "ras",
  693. tkk: "twm",
  694. tlw: "weo",
  695. tnf: "prs",
  696. ybd: "rki",
  697. yma: "lrr"
  698. },
  699. extLang: {
  700. aao: ["aao", "ar"],
  701. abh: ["abh", "ar"],
  702. abv: ["abv", "ar"],
  703. acm: ["acm", "ar"],
  704. acq: ["acq", "ar"],
  705. acw: ["acw", "ar"],
  706. acx: ["acx", "ar"],
  707. acy: ["acy", "ar"],
  708. adf: ["adf", "ar"],
  709. ads: ["ads", "sgn"],
  710. aeb: ["aeb", "ar"],
  711. aec: ["aec", "ar"],
  712. aed: ["aed", "sgn"],
  713. aen: ["aen", "sgn"],
  714. afb: ["afb", "ar"],
  715. afg: ["afg", "sgn"],
  716. ajp: ["ajp", "ar"],
  717. apc: ["apc", "ar"],
  718. apd: ["apd", "ar"],
  719. arb: ["arb", "ar"],
  720. arq: ["arq", "ar"],
  721. ars: ["ars", "ar"],
  722. ary: ["ary", "ar"],
  723. arz: ["arz", "ar"],
  724. ase: ["ase", "sgn"],
  725. asf: ["asf", "sgn"],
  726. asp: ["asp", "sgn"],
  727. asq: ["asq", "sgn"],
  728. asw: ["asw", "sgn"],
  729. auz: ["auz", "ar"],
  730. avl: ["avl", "ar"],
  731. ayh: ["ayh", "ar"],
  732. ayl: ["ayl", "ar"],
  733. ayn: ["ayn", "ar"],
  734. ayp: ["ayp", "ar"],
  735. bbz: ["bbz", "ar"],
  736. bfi: ["bfi", "sgn"],
  737. bfk: ["bfk", "sgn"],
  738. bjn: ["bjn", "ms"],
  739. bog: ["bog", "sgn"],
  740. bqn: ["bqn", "sgn"],
  741. bqy: ["bqy", "sgn"],
  742. btj: ["btj", "ms"],
  743. bve: ["bve", "ms"],
  744. bvl: ["bvl", "sgn"],
  745. bvu: ["bvu", "ms"],
  746. bzs: ["bzs", "sgn"],
  747. cdo: ["cdo", "zh"],
  748. cds: ["cds", "sgn"],
  749. cjy: ["cjy", "zh"],
  750. cmn: ["cmn", "zh"],
  751. coa: ["coa", "ms"],
  752. cpx: ["cpx", "zh"],
  753. csc: ["csc", "sgn"],
  754. csd: ["csd", "sgn"],
  755. cse: ["cse", "sgn"],
  756. csf: ["csf", "sgn"],
  757. csg: ["csg", "sgn"],
  758. csl: ["csl", "sgn"],
  759. csn: ["csn", "sgn"],
  760. csq: ["csq", "sgn"],
  761. csr: ["csr", "sgn"],
  762. czh: ["czh", "zh"],
  763. czo: ["czo", "zh"],
  764. doq: ["doq", "sgn"],
  765. dse: ["dse", "sgn"],
  766. dsl: ["dsl", "sgn"],
  767. dup: ["dup", "ms"],
  768. ecs: ["ecs", "sgn"],
  769. esl: ["esl", "sgn"],
  770. esn: ["esn", "sgn"],
  771. eso: ["eso", "sgn"],
  772. eth: ["eth", "sgn"],
  773. fcs: ["fcs", "sgn"],
  774. fse: ["fse", "sgn"],
  775. fsl: ["fsl", "sgn"],
  776. fss: ["fss", "sgn"],
  777. gan: ["gan", "zh"],
  778. gds: ["gds", "sgn"],
  779. gom: ["gom", "kok"],
  780. gse: ["gse", "sgn"],
  781. gsg: ["gsg", "sgn"],
  782. gsm: ["gsm", "sgn"],
  783. gss: ["gss", "sgn"],
  784. gus: ["gus", "sgn"],
  785. hab: ["hab", "sgn"],
  786. haf: ["haf", "sgn"],
  787. hak: ["hak", "zh"],
  788. hds: ["hds", "sgn"],
  789. hji: ["hji", "ms"],
  790. hks: ["hks", "sgn"],
  791. hos: ["hos", "sgn"],
  792. hps: ["hps", "sgn"],
  793. hsh: ["hsh", "sgn"],
  794. hsl: ["hsl", "sgn"],
  795. hsn: ["hsn", "zh"],
  796. icl: ["icl", "sgn"],
  797. ils: ["ils", "sgn"],
  798. inl: ["inl", "sgn"],
  799. ins: ["ins", "sgn"],
  800. ise: ["ise", "sgn"],
  801. isg: ["isg", "sgn"],
  802. isr: ["isr", "sgn"],
  803. jak: ["jak", "ms"],
  804. jax: ["jax", "ms"],
  805. jcs: ["jcs", "sgn"],
  806. jhs: ["jhs", "sgn"],
  807. jls: ["jls", "sgn"],
  808. jos: ["jos", "sgn"],
  809. jsl: ["jsl", "sgn"],
  810. jus: ["jus", "sgn"],
  811. kgi: ["kgi", "sgn"],
  812. knn: ["knn", "kok"],
  813. kvb: ["kvb", "ms"],
  814. kvk: ["kvk", "sgn"],
  815. kvr: ["kvr", "ms"],
  816. kxd: ["kxd", "ms"],
  817. lbs: ["lbs", "sgn"],
  818. lce: ["lce", "ms"],
  819. lcf: ["lcf", "ms"],
  820. liw: ["liw", "ms"],
  821. lls: ["lls", "sgn"],
  822. lsg: ["lsg", "sgn"],
  823. lsl: ["lsl", "sgn"],
  824. lso: ["lso", "sgn"],
  825. lsp: ["lsp", "sgn"],
  826. lst: ["lst", "sgn"],
  827. lsy: ["lsy", "sgn"],
  828. ltg: ["ltg", "lv"],
  829. lvs: ["lvs", "lv"],
  830. lzh: ["lzh", "zh"],
  831. max: ["max", "ms"],
  832. mdl: ["mdl", "sgn"],
  833. meo: ["meo", "ms"],
  834. mfa: ["mfa", "ms"],
  835. mfb: ["mfb", "ms"],
  836. mfs: ["mfs", "sgn"],
  837. min: ["min", "ms"],
  838. mnp: ["mnp", "zh"],
  839. mqg: ["mqg", "ms"],
  840. mre: ["mre", "sgn"],
  841. msd: ["msd", "sgn"],
  842. msi: ["msi", "ms"],
  843. msr: ["msr", "sgn"],
  844. mui: ["mui", "ms"],
  845. mzc: ["mzc", "sgn"],
  846. mzg: ["mzg", "sgn"],
  847. mzy: ["mzy", "sgn"],
  848. nan: ["nan", "zh"],
  849. nbs: ["nbs", "sgn"],
  850. ncs: ["ncs", "sgn"],
  851. nsi: ["nsi", "sgn"],
  852. nsl: ["nsl", "sgn"],
  853. nsp: ["nsp", "sgn"],
  854. nsr: ["nsr", "sgn"],
  855. nzs: ["nzs", "sgn"],
  856. okl: ["okl", "sgn"],
  857. orn: ["orn", "ms"],
  858. ors: ["ors", "ms"],
  859. pel: ["pel", "ms"],
  860. pga: ["pga", "ar"],
  861. pks: ["pks", "sgn"],
  862. prl: ["prl", "sgn"],
  863. prz: ["prz", "sgn"],
  864. psc: ["psc", "sgn"],
  865. psd: ["psd", "sgn"],
  866. pse: ["pse", "ms"],
  867. psg: ["psg", "sgn"],
  868. psl: ["psl", "sgn"],
  869. pso: ["pso", "sgn"],
  870. psp: ["psp", "sgn"],
  871. psr: ["psr", "sgn"],
  872. pys: ["pys", "sgn"],
  873. rms: ["rms", "sgn"],
  874. rsi: ["rsi", "sgn"],
  875. rsl: ["rsl", "sgn"],
  876. sdl: ["sdl", "sgn"],
  877. sfb: ["sfb", "sgn"],
  878. sfs: ["sfs", "sgn"],
  879. sgg: ["sgg", "sgn"],
  880. sgx: ["sgx", "sgn"],
  881. shu: ["shu", "ar"],
  882. slf: ["slf", "sgn"],
  883. sls: ["sls", "sgn"],
  884. sqk: ["sqk", "sgn"],
  885. sqs: ["sqs", "sgn"],
  886. ssh: ["ssh", "ar"],
  887. ssp: ["ssp", "sgn"],
  888. ssr: ["ssr", "sgn"],
  889. svk: ["svk", "sgn"],
  890. swc: ["swc", "sw"],
  891. swh: ["swh", "sw"],
  892. swl: ["swl", "sgn"],
  893. syy: ["syy", "sgn"],
  894. tmw: ["tmw", "ms"],
  895. tse: ["tse", "sgn"],
  896. tsm: ["tsm", "sgn"],
  897. tsq: ["tsq", "sgn"],
  898. tss: ["tss", "sgn"],
  899. tsy: ["tsy", "sgn"],
  900. tza: ["tza", "sgn"],
  901. ugn: ["ugn", "sgn"],
  902. ugy: ["ugy", "sgn"],
  903. ukl: ["ukl", "sgn"],
  904. uks: ["uks", "sgn"],
  905. urk: ["urk", "ms"],
  906. uzn: ["uzn", "uz"],
  907. uzs: ["uzs", "uz"],
  908. vgt: ["vgt", "sgn"],
  909. vkk: ["vkk", "ms"],
  910. vkt: ["vkt", "ms"],
  911. vsi: ["vsi", "sgn"],
  912. vsl: ["vsl", "sgn"],
  913. vsv: ["vsv", "sgn"],
  914. wuu: ["wuu", "zh"],
  915. xki: ["xki", "sgn"],
  916. xml: ["xml", "sgn"],
  917. xmm: ["xmm", "ms"],
  918. xms: ["xms", "sgn"],
  919. yds: ["yds", "sgn"],
  920. ysl: ["ysl", "sgn"],
  921. yue: ["yue", "zh"],
  922. zib: ["zib", "sgn"],
  923. zlm: ["zlm", "ms"],
  924. zmi: ["zmi", "ms"],
  925. zsl: ["zsl", "sgn"],
  926. zsm: ["zsm", "ms"]
  927. }
  928. };
  929. /**
  930. * Convert only a-z to uppercase as per section 6.1 of the spec
  931. */
  932. function toLatinUpperCase(str) {
  933. var i = str.length;
  934. while (i--) {
  935. var ch = str.charAt(i);
  936. if (ch >= "a" && ch <= "z") str = str.slice(0, i) + ch.toUpperCase() + str.slice(i + 1);
  937. }
  938. return str;
  939. }
  940. /**
  941. * The IsStructurallyValidLanguageTag abstract operation verifies that the locale
  942. * argument (which must be a String value)
  943. *
  944. * - represents a well-formed BCP 47 language tag as specified in RFC 5646 section
  945. * 2.1, or successor,
  946. * - does not include duplicate variant subtags, and
  947. * - does not include duplicate singleton subtags.
  948. *
  949. * The abstract operation returns true if locale can be generated from the ABNF
  950. * grammar in section 2.1 of the RFC, starting with Language-Tag, and does not
  951. * contain duplicate variant or singleton subtags (other than as a private use
  952. * subtag). It returns false otherwise. Terminal value characters in the grammar are
  953. * interpreted as the Unicode equivalents of the ASCII octet values given.
  954. */
  955. function /* 6.2.2 */IsStructurallyValidLanguageTag(locale) {
  956. // represents a well-formed BCP 47 language tag as specified in RFC 5646
  957. if (!expBCP47Syntax.test(locale)) return false;
  958. // does not include duplicate variant subtags, and
  959. if (expVariantDupes.test(locale)) return false;
  960. // does not include duplicate singleton subtags.
  961. if (expSingletonDupes.test(locale)) return false;
  962. return true;
  963. }
  964. /**
  965. * The CanonicalizeLanguageTag abstract operation returns the canonical and case-
  966. * regularized form of the locale argument (which must be a String value that is
  967. * a structurally valid BCP 47 language tag as verified by the
  968. * IsStructurallyValidLanguageTag abstract operation). It takes the steps
  969. * specified in RFC 5646 section 4.5, or successor, to bring the language tag
  970. * into canonical form, and to regularize the case of the subtags, but does not
  971. * take the steps to bring a language tag into “extlang form” and to reorder
  972. * variant subtags.
  973. * The specifications for extensions to BCP 47 language tags, such as RFC 6067,
  974. * may include canonicalization rules for the extension subtag sequences they
  975. * define that go beyond the canonicalization rules of RFC 5646 section 4.5.
  976. * Implementations are allowed, but not required, to apply these additional rules.
  977. */
  978. function /* 6.2.3 */CanonicalizeLanguageTag(locale) {
  979. var match = void 0,
  980. parts = void 0;
  981. // A language tag is in 'canonical form' when the tag is well-formed
  982. // according to the rules in Sections 2.1 and 2.2
  983. // Section 2.1 says all subtags use lowercase...
  984. locale = locale.toLowerCase();
  985. // ...with 2 exceptions: 'two-letter and four-letter subtags that neither
  986. // appear at the start of the tag nor occur after singletons. Such two-letter
  987. // subtags are all uppercase (as in the tags "en-CA-x-ca" or "sgn-BE-FR") and
  988. // four-letter subtags are titlecase (as in the tag "az-Latn-x-latn").
  989. parts = locale.split('-');
  990. for (var i = 1, max = parts.length; i < max; i++) {
  991. // Two-letter subtags are all uppercase
  992. if (parts[i].length === 2) parts[i] = parts[i].toUpperCase();
  993. // Four-letter subtags are titlecase
  994. else if (parts[i].length === 4) parts[i] = parts[i].charAt(0).toUpperCase() + parts[i].slice(1);
  995. // Is it a singleton?
  996. else if (parts[i].length === 1 && parts[i] !== 'x') break;
  997. }
  998. locale = arrJoin.call(parts, '-');
  999. // The steps laid out in RFC 5646 section 4.5 are as follows:
  1000. // 1. Extension sequences are ordered into case-insensitive ASCII order
  1001. // by singleton subtag.
  1002. if ((match = locale.match(expExtSequences)) && match.length > 1) {
  1003. // The built-in sort() sorts by ASCII order, so use that
  1004. match.sort();
  1005. // Replace all extensions with the joined, sorted array
  1006. locale = locale.replace(RegExp('(?:' + expExtSequences.source + ')+', 'i'), arrJoin.call(match, ''));
  1007. }
  1008. // 2. Redundant or grandfathered tags are replaced by their 'Preferred-
  1009. // Value', if there is one.
  1010. if (hop.call(redundantTags.tags, locale)) locale = redundantTags.tags[locale];
  1011. // 3. Subtags are replaced by their 'Preferred-Value', if there is one.
  1012. // For extlangs, the original primary language subtag is also
  1013. // replaced if there is a primary language subtag in the 'Preferred-
  1014. // Value'.
  1015. parts = locale.split('-');
  1016. for (var _i = 1, _max = parts.length; _i < _max; _i++) {
  1017. if (hop.call(redundantTags.subtags, parts[_i])) parts[_i] = redundantTags.subtags[parts[_i]];else if (hop.call(redundantTags.extLang, parts[_i])) {
  1018. parts[_i] = redundantTags.extLang[parts[_i]][0];
  1019. // For extlang tags, the prefix needs to be removed if it is redundant
  1020. if (_i === 1 && redundantTags.extLang[parts[1]][1] === parts[0]) {
  1021. parts = arrSlice.call(parts, _i++);
  1022. _max -= 1;
  1023. }
  1024. }
  1025. }
  1026. return arrJoin.call(parts, '-');
  1027. }
  1028. /**
  1029. * The DefaultLocale abstract operation returns a String value representing the
  1030. * structurally valid (6.2.2) and canonicalized (6.2.3) BCP 47 language tag for the
  1031. * host environment’s current locale.
  1032. */
  1033. function /* 6.2.4 */DefaultLocale() {
  1034. return defaultLocale;
  1035. }
  1036. // Sect 6.3 Currency Codes
  1037. // =======================
  1038. var expCurrencyCode = /^[A-Z]{3}$/;
  1039. /**
  1040. * The IsWellFormedCurrencyCode abstract operation verifies that the currency argument
  1041. * (after conversion to a String value) represents a well-formed 3-letter ISO currency
  1042. * code. The following steps are taken:
  1043. */
  1044. function /* 6.3.1 */IsWellFormedCurrencyCode(currency) {
  1045. // 1. Let `c` be ToString(currency)
  1046. var c = String(currency);
  1047. // 2. Let `normalized` be the result of mapping c to upper case as described
  1048. // in 6.1.
  1049. var normalized = toLatinUpperCase(c);
  1050. // 3. If the string length of normalized is not 3, return false.
  1051. // 4. If normalized contains any character that is not in the range "A" to "Z"
  1052. // (U+0041 to U+005A), return false.
  1053. if (expCurrencyCode.test(normalized) === false) return false;
  1054. // 5. Return true
  1055. return true;
  1056. }
  1057. var expUnicodeExSeq = /-u(?:-[0-9a-z]{2,8})+/gi; // See `extension` below
  1058. function /* 9.2.1 */CanonicalizeLocaleList(locales) {
  1059. // The abstract operation CanonicalizeLocaleList takes the following steps:
  1060. // 1. If locales is undefined, then a. Return a new empty List
  1061. if (locales === undefined) return new List();
  1062. // 2. Let seen be a new empty List.
  1063. var seen = new List();
  1064. // 3. If locales is a String value, then
  1065. // a. Let locales be a new array created as if by the expression new
  1066. // Array(locales) where Array is the standard built-in constructor with
  1067. // that name and locales is the value of locales.
  1068. locales = typeof locales === 'string' ? [locales] : locales;
  1069. // 4. Let O be ToObject(locales).
  1070. var O = toObject(locales);
  1071. // 5. Let lenValue be the result of calling the [[Get]] internal method of
  1072. // O with the argument "length".
  1073. // 6. Let len be ToUint32(lenValue).
  1074. var len = toLength(O.length);
  1075. // 7. Let k be 0.
  1076. var k = 0;
  1077. // 8. Repeat, while k < len
  1078. while (k < len) {
  1079. // a. Let Pk be ToString(k).
  1080. var Pk = String(k);
  1081. // b. Let kPresent be the result of calling the [[HasProperty]] internal
  1082. // method of O with argument Pk.
  1083. var kPresent = Pk in O;
  1084. // c. If kPresent is true, then
  1085. if (kPresent) {
  1086. // i. Let kValue be the result of calling the [[Get]] internal
  1087. // method of O with argument Pk.
  1088. var kValue = O[Pk];
  1089. // ii. If the type of kValue is not String or Object, then throw a
  1090. // TypeError exception.
  1091. if (kValue === null || typeof kValue !== 'string' && (typeof kValue === "undefined" ? "undefined" : babelHelpers$1["typeof"](kValue)) !== 'object') throw new TypeError('String or Object type expected');
  1092. // iii. Let tag be ToString(kValue).
  1093. var tag = String(kValue);
  1094. // iv. If the result of calling the abstract operation
  1095. // IsStructurallyValidLanguageTag (defined in 6.2.2), passing tag as
  1096. // the argument, is false, then throw a RangeError exception.
  1097. if (!IsStructurallyValidLanguageTag(tag)) throw new RangeError("'" + tag + "' is not a structurally valid language tag");
  1098. // v. Let tag be the result of calling the abstract operation
  1099. // CanonicalizeLanguageTag (defined in 6.2.3), passing tag as the
  1100. // argument.
  1101. tag = CanonicalizeLanguageTag(tag);
  1102. // vi. If tag is not an element of seen, then append tag as the last
  1103. // element of seen.
  1104. if (arrIndexOf.call(seen, tag) === -1) arrPush.call(seen, tag);
  1105. }
  1106. // d. Increase k by 1.
  1107. k++;
  1108. }
  1109. // 9. Return seen.
  1110. return seen;
  1111. }
  1112. /**
  1113. * The BestAvailableLocale abstract operation compares the provided argument
  1114. * locale, which must be a String value with a structurally valid and
  1115. * canonicalized BCP 47 language tag, against the locales in availableLocales and
  1116. * returns either the longest non-empty prefix of locale that is an element of
  1117. * availableLocales, or undefined if there is no such element. It uses the
  1118. * fallback mechanism of RFC 4647, section 3.4. The following steps are taken:
  1119. */
  1120. function /* 9.2.2 */BestAvailableLocale(availableLocales, locale) {
  1121. // 1. Let candidate be locale
  1122. var candidate = locale;
  1123. // 2. Repeat
  1124. while (candidate) {
  1125. // a. If availableLocales contains an element equal to candidate, then return
  1126. // candidate.
  1127. if (arrIndexOf.call(availableLocales, candidate) > -1) return candidate;
  1128. // b. Let pos be the character index of the last occurrence of "-"
  1129. // (U+002D) within candidate. If that character does not occur, return
  1130. // undefined.
  1131. var pos = candidate.lastIndexOf('-');
  1132. if (pos < 0) return;
  1133. // c. If pos ≥ 2 and the character "-" occurs at index pos-2 of candidate,
  1134. // then decrease pos by 2.
  1135. if (pos >= 2 && candidate.charAt(pos - 2) === '-') pos -= 2;
  1136. // d. Let candidate be the substring of candidate from position 0, inclusive,
  1137. // to position pos, exclusive.
  1138. candidate = candidate.substring(0, pos);
  1139. }
  1140. }
  1141. /**
  1142. * The LookupMatcher abstract operation compares requestedLocales, which must be
  1143. * a List as returned by CanonicalizeLocaleList, against the locales in
  1144. * availableLocales and determines the best available language to meet the
  1145. * request. The following steps are taken:
  1146. */
  1147. function /* 9.2.3 */LookupMatcher(availableLocales, requestedLocales) {
  1148. // 1. Let i be 0.
  1149. var i = 0;
  1150. // 2. Let len be the number of elements in requestedLocales.
  1151. var len = requestedLocales.length;
  1152. // 3. Let availableLocale be undefined.
  1153. var availableLocale = void 0;
  1154. var locale = void 0,
  1155. noExtensionsLocale = void 0;
  1156. // 4. Repeat while i < len and availableLocale is undefined:
  1157. while (i < len && !availableLocale) {
  1158. // a. Let locale be the element of requestedLocales at 0-origined list
  1159. // position i.
  1160. locale = requestedLocales[i];
  1161. // b. Let noExtensionsLocale be the String value that is locale with all
  1162. // Unicode locale extension sequences removed.
  1163. noExtensionsLocale = String(locale).replace(expUnicodeExSeq, '');
  1164. // c. Let availableLocale be the result of calling the
  1165. // BestAvailableLocale abstract operation (defined in 9.2.2) with
  1166. // arguments availableLocales and noExtensionsLocale.
  1167. availableLocale = BestAvailableLocale(availableLocales, noExtensionsLocale);
  1168. // d. Increase i by 1.
  1169. i++;
  1170. }
  1171. // 5. Let result be a new Record.
  1172. var result = new Record();
  1173. // 6. If availableLocale is not undefined, then
  1174. if (availableLocale !== undefined) {
  1175. // a. Set result.[[locale]] to availableLocale.
  1176. result['[[locale]]'] = availableLocale;
  1177. // b. If locale and noExtensionsLocale are not the same String value, then
  1178. if (String(locale) !== String(noExtensionsLocale)) {
  1179. // i. Let extension be the String value consisting of the first
  1180. // substring of locale that is a Unicode locale extension sequence.
  1181. var extension = locale.match(expUnicodeExSeq)[0];
  1182. // ii. Let extensionIndex be the character position of the initial
  1183. // "-" of the first Unicode locale extension sequence within locale.
  1184. var extensionIndex = locale.indexOf('-u-');
  1185. // iii. Set result.[[extension]] to extension.
  1186. result['[[extension]]'] = extension;
  1187. // iv. Set result.[[extensionIndex]] to extensionIndex.
  1188. result['[[extensionIndex]]'] = extensionIndex;
  1189. }
  1190. }
  1191. // 7. Else
  1192. else
  1193. // a. Set result.[[locale]] to the value returned by the DefaultLocale abstract
  1194. // operation (defined in 6.2.4).
  1195. result['[[locale]]'] = DefaultLocale();
  1196. // 8. Return result
  1197. return result;
  1198. }
  1199. /**
  1200. * The BestFitMatcher abstract operation compares requestedLocales, which must be
  1201. * a List as returned by CanonicalizeLocaleList, against the locales in
  1202. * availableLocales and determines the best available language to meet the
  1203. * request. The algorithm is implementation dependent, but should produce results
  1204. * that a typical user of the requested locales would perceive as at least as
  1205. * good as those produced by the LookupMatcher abstract operation. Options
  1206. * specified through Unicode locale extension sequences must be ignored by the
  1207. * algorithm. Information about such subsequences is returned separately.
  1208. * The abstract operation returns a record with a [[locale]] field, whose value
  1209. * is the language tag of the selected locale, which must be an element of
  1210. * availableLocales. If the language tag of the request locale that led to the
  1211. * selected locale contained a Unicode locale extension sequence, then the
  1212. * returned record also contains an [[extension]] field whose value is the first
  1213. * Unicode locale extension sequence, and an [[extensionIndex]] field whose value
  1214. * is the index of the first Unicode locale extension sequence within the request
  1215. * locale language tag.
  1216. */
  1217. function /* 9.2.4 */BestFitMatcher(availableLocales, requestedLocales) {
  1218. return LookupMatcher(availableLocales, requestedLocales);
  1219. }
  1220. /**
  1221. * The ResolveLocale abstract operation compares a BCP 47 language priority list
  1222. * requestedLocales against the locales in availableLocales and determines the
  1223. * best available language to meet the request. availableLocales and
  1224. * requestedLocales must be provided as List values, options as a Record.
  1225. */
  1226. function /* 9.2.5 */ResolveLocale(availableLocales, requestedLocales, options, relevantExtensionKeys, localeData) {
  1227. if (availableLocales.length === 0) {
  1228. throw new ReferenceError('No locale data has been provided for this object yet.');
  1229. }
  1230. // The following steps are taken:
  1231. // 1. Let matcher be the value of options.[[localeMatcher]].
  1232. var matcher = options['[[localeMatcher]]'];
  1233. var r = void 0;
  1234. // 2. If matcher is "lookup", then
  1235. if (matcher === 'lookup')
  1236. // a. Let r be the result of calling the LookupMatcher abstract operation
  1237. // (defined in 9.2.3) with arguments availableLocales and
  1238. // requestedLocales.
  1239. r = LookupMatcher(availableLocales, requestedLocales);
  1240. // 3. Else
  1241. else
  1242. // a. Let r be the result of calling the BestFitMatcher abstract
  1243. // operation (defined in 9.2.4) with arguments availableLocales and
  1244. // requestedLocales.
  1245. r = BestFitMatcher(availableLocales, requestedLocales);
  1246. // 4. Let foundLocale be the value of r.[[locale]].
  1247. var foundLocale = r['[[locale]]'];
  1248. var extensionSubtags = void 0,
  1249. extensionSubtagsLength = void 0;
  1250. // 5. If r has an [[extension]] field, then
  1251. if (hop.call(r, '[[extension]]')) {
  1252. // a. Let extension be the value of r.[[extension]].
  1253. var extension = r['[[extension]]'];
  1254. // b. Let split be the standard built-in function object defined in ES5,
  1255. // 15.5.4.14.
  1256. var split = String.prototype.split;
  1257. // c. Let extensionSubtags be the result of calling the [[Call]] internal
  1258. // method of split with extension as the this value and an argument
  1259. // list containing the single item "-".
  1260. extensionSubtags = split.call(extension, '-');
  1261. // d. Let extensionSubtagsLength be the result of calling the [[Get]]
  1262. // internal method of extensionSubtags with argument "length".
  1263. extensionSubtagsLength = extensionSubtags.length;
  1264. }
  1265. // 6. Let result be a new Record.
  1266. var result = new Record();
  1267. // 7. Set result.[[dataLocale]] to foundLocale.
  1268. result['[[dataLocale]]'] = foundLocale;
  1269. // 8. Let supportedExtension be "-u".
  1270. var supportedExtension = '-u';
  1271. // 9. Let i be 0.
  1272. var i = 0;
  1273. // 10. Let len be the result of calling the [[Get]] internal method of
  1274. // relevantExtensionKeys with argument "length".
  1275. var len = relevantExtensionKeys.length;
  1276. // 11 Repeat while i < len:
  1277. while (i < len) {
  1278. // a. Let key be the result of calling the [[Get]] internal method of
  1279. // relevantExtensionKeys with argument ToString(i).
  1280. var key = relevantExtensionKeys[i];
  1281. // b. Let foundLocaleData be the result of calling the [[Get]] internal
  1282. // method of localeData with the argument foundLocale.
  1283. var foundLocaleData = localeData[foundLocale];
  1284. // c. Let keyLocaleData be the result of calling the [[Get]] internal
  1285. // method of foundLocaleData with the argument key.
  1286. var keyLocaleData = foundLocaleData[key];
  1287. // d. Let value be the result of calling the [[Get]] internal method of
  1288. // keyLocaleData with argument "0".
  1289. var value = keyLocaleData['0'];
  1290. // e. Let supportedExtensionAddition be "".
  1291. var supportedExtensionAddition = '';
  1292. // f. Let indexOf be the standard built-in function object defined in
  1293. // ES5, 15.4.4.14.
  1294. var indexOf = arrIndexOf;
  1295. // g. If extensionSubtags is not undefined, then
  1296. if (extensionSubtags !== undefined) {
  1297. // i. Let keyPos be the result of calling the [[Call]] internal
  1298. // method of indexOf with extensionSubtags as the this value and
  1299. // an argument list containing the single item key.
  1300. var keyPos = indexOf.call(extensionSubtags, key);
  1301. // ii. If keyPos ≠ -1, then
  1302. if (keyPos !== -1) {
  1303. // 1. If keyPos + 1 < extensionSubtagsLength and the length of the
  1304. // result of calling the [[Get]] internal method of
  1305. // extensionSubtags with argument ToString(keyPos +1) is greater
  1306. // than 2, then
  1307. if (keyPos + 1 < extensionSubtagsLength && extensionSubtags[keyPos + 1].length > 2) {
  1308. // a. Let requestedValue be the result of calling the [[Get]]
  1309. // internal method of extensionSubtags with argument
  1310. // ToString(keyPos + 1).
  1311. var requestedValue = extensionSubtags[keyPos + 1];
  1312. // b. Let valuePos be the result of calling the [[Call]]
  1313. // internal method of indexOf with keyLocaleData as the
  1314. // this value and an argument list containing the single
  1315. // item requestedValue.
  1316. var valuePos = indexOf.call(keyLocaleData, requestedValue);
  1317. // c. If valuePos ≠ -1, then
  1318. if (valuePos !== -1) {
  1319. // i. Let value be requestedValue.
  1320. value = requestedValue,
  1321. // ii. Let supportedExtensionAddition be the
  1322. // concatenation of "-", key, "-", and value.
  1323. supportedExtensionAddition = '-' + key + '-' + value;
  1324. }
  1325. }
  1326. // 2. Else
  1327. else {
  1328. // a. Let valuePos be the result of calling the [[Call]]
  1329. // internal method of indexOf with keyLocaleData as the this
  1330. // value and an argument list containing the single item
  1331. // "true".
  1332. var _valuePos = indexOf(keyLocaleData, 'true');
  1333. // b. If valuePos ≠ -1, then
  1334. if (_valuePos !== -1)
  1335. // i. Let value be "true".
  1336. value = 'true';
  1337. }
  1338. }
  1339. }
  1340. // h. If options has a field [[<key>]], then
  1341. if (hop.call(options, '[[' + key + ']]')) {
  1342. // i. Let optionsValue be the value of options.[[<key>]].
  1343. var optionsValue = options['[[' + key + ']]'];
  1344. // ii. If the result of calling the [[Call]] internal method of indexOf
  1345. // with keyLocaleData as the this value and an argument list
  1346. // containing the single item optionsValue is not -1, then
  1347. if (indexOf.call(keyLocaleData, optionsValue) !== -1) {
  1348. // 1. If optionsValue is not equal to value, then
  1349. if (optionsValue !== value) {
  1350. // a. Let value be optionsValue.
  1351. value = optionsValue;
  1352. // b. Let supportedExtensionAddition be "".
  1353. supportedExtensionAddition = '';
  1354. }
  1355. }
  1356. }
  1357. // i. Set result.[[<key>]] to value.
  1358. result['[[' + key + ']]'] = value;
  1359. // j. Append supportedExtensionAddition to supportedExtension.
  1360. supportedExtension += supportedExtensionAddition;
  1361. // k. Increase i by 1.
  1362. i++;
  1363. }
  1364. // 12. If the length of supportedExtension is greater than 2, then
  1365. if (supportedExtension.length > 2) {
  1366. // a.
  1367. var privateIndex = foundLocale.indexOf("-x-");
  1368. // b.
  1369. if (privateIndex === -1) {
  1370. // i.
  1371. foundLocale = foundLocale + supportedExtension;
  1372. }
  1373. // c.
  1374. else {
  1375. // i.
  1376. var preExtension = foundLocale.substring(0, privateIndex);
  1377. // ii.
  1378. var postExtension = foundLocale.substring(privateIndex);
  1379. // iii.
  1380. foundLocale = preExtension + supportedExtension + postExtension;
  1381. }
  1382. // d. asserting - skipping
  1383. // e.
  1384. foundLocale = CanonicalizeLanguageTag(foundLocale);
  1385. }
  1386. // 13. Set result.[[locale]] to foundLocale.
  1387. result['[[locale]]'] = foundLocale;
  1388. // 14. Return result.
  1389. return result;
  1390. }
  1391. /**
  1392. * The LookupSupportedLocales abstract operation returns the subset of the
  1393. * provided BCP 47 language priority list requestedLocales for which
  1394. * availableLocales has a matching locale when using the BCP 47 Lookup algorithm.
  1395. * Locales appear in the same order in the returned list as in requestedLocales.
  1396. * The following steps are taken:
  1397. */
  1398. function /* 9.2.6 */LookupSupportedLocales(availableLocales, requestedLocales) {
  1399. // 1. Let len be the number of elements in requestedLocales.
  1400. var len = requestedLocales.length;
  1401. // 2. Let subset be a new empty List.
  1402. var subset = new List();
  1403. // 3. Let k be 0.
  1404. var k = 0;
  1405. // 4. Repeat while k < len
  1406. while (k < len) {
  1407. // a. Let locale be the element of requestedLocales at 0-origined list
  1408. // position k.
  1409. var locale = requestedLocales[k];
  1410. // b. Let noExtensionsLocale be the String value that is locale with all
  1411. // Unicode locale extension sequences removed.
  1412. var noExtensionsLocale = String(locale).replace(expUnicodeExSeq, '');
  1413. // c. Let availableLocale be the result of calling the
  1414. // BestAvailableLocale abstract operation (defined in 9.2.2) with
  1415. // arguments availableLocales and noExtensionsLocale.
  1416. var availableLocale = BestAvailableLocale(availableLocales, noExtensionsLocale);
  1417. // d. If availableLocale is not undefined, then append locale to the end of
  1418. // subset.
  1419. if (availableLocale !== undefined) arrPush.call(subset, locale);
  1420. // e. Increment k by 1.
  1421. k++;
  1422. }
  1423. // 5. Let subsetArray be a new Array object whose elements are the same
  1424. // values in the same order as the elements of subset.
  1425. var subsetArray = arrSlice.call(subset);
  1426. // 6. Return subsetArray.
  1427. return subsetArray;
  1428. }
  1429. /**
  1430. * The BestFitSupportedLocales abstract operation returns the subset of the
  1431. * provided BCP 47 language priority list requestedLocales for which
  1432. * availableLocales has a matching locale when using the Best Fit Matcher
  1433. * algorithm. Locales appear in the same order in the returned list as in
  1434. * requestedLocales. The steps taken are implementation dependent.
  1435. */
  1436. function /*9.2.7 */BestFitSupportedLocales(availableLocales, requestedLocales) {
  1437. // ###TODO: implement this function as described by the specification###
  1438. return LookupSupportedLocales(availableLocales, requestedLocales);
  1439. }
  1440. /**
  1441. * The SupportedLocales abstract operation returns the subset of the provided BCP
  1442. * 47 language priority list requestedLocales for which availableLocales has a
  1443. * matching locale. Two algorithms are available to match the locales: the Lookup
  1444. * algorithm described in RFC 4647 section 3.4, and an implementation dependent
  1445. * best-fit algorithm. Locales appear in the same order in the returned list as
  1446. * in requestedLocales. The following steps are taken:
  1447. */
  1448. function /*9.2.8 */SupportedLocales(availableLocales, requestedLocales, options) {
  1449. var matcher = void 0,
  1450. subset = void 0;
  1451. // 1. If options is not undefined, then
  1452. if (options !== undefined) {
  1453. // a. Let options be ToObject(options).
  1454. options = new Record(toObject(options));
  1455. // b. Let matcher be the result of calling the [[Get]] internal method of
  1456. // options with argument "localeMatcher".
  1457. matcher = options.localeMatcher;
  1458. // c. If matcher is not undefined, then
  1459. if (matcher !== undefined) {
  1460. // i. Let matcher be ToString(matcher).
  1461. matcher = String(matcher);
  1462. // ii. If matcher is not "lookup" or "best fit", then throw a RangeError
  1463. // exception.
  1464. if (matcher !== 'lookup' && matcher !== 'best fit') throw new RangeError('matcher should be "lookup" or "best fit"');
  1465. }
  1466. }
  1467. // 2. If matcher is undefined or "best fit", then
  1468. if (matcher === undefined || matcher === 'best fit')
  1469. // a. Let subset be the result of calling the BestFitSupportedLocales
  1470. // abstract operation (defined in 9.2.7) with arguments
  1471. // availableLocales and requestedLocales.
  1472. subset = BestFitSupportedLocales(availableLocales, requestedLocales);
  1473. // 3. Else
  1474. else
  1475. // a. Let subset be the result of calling the LookupSupportedLocales
  1476. // abstract operation (defined in 9.2.6) with arguments
  1477. // availableLocales and requestedLocales.
  1478. subset = LookupSupportedLocales(availableLocales, requestedLocales);
  1479. // 4. For each named own property name P of subset,
  1480. for (var P in subset) {
  1481. if (!hop.call(subset, P)) continue;
  1482. // a. Let desc be the result of calling the [[GetOwnProperty]] internal
  1483. // method of subset with P.
  1484. // b. Set desc.[[Writable]] to false.
  1485. // c. Set desc.[[Configurable]] to false.
  1486. // d. Call the [[DefineOwnProperty]] internal method of subset with P, desc,
  1487. // and true as arguments.
  1488. defineProperty(subset, P, {
  1489. writable: false, configurable: false, value: subset[P]
  1490. });
  1491. }
  1492. // "Freeze" the array so no new elements can be added
  1493. defineProperty(subset, 'length', { writable: false });
  1494. // 5. Return subset
  1495. return subset;
  1496. }
  1497. /**
  1498. * The GetOption abstract operation extracts the value of the property named
  1499. * property from the provided options object, converts it to the required type,
  1500. * checks whether it is one of a List of allowed values, and fills in a fallback
  1501. * value if necessary.
  1502. */
  1503. function /*9.2.9 */GetOption(options, property, type, values, fallback) {
  1504. // 1. Let value be the result of calling the [[Get]] internal method of
  1505. // options with argument property.
  1506. var value = options[property];
  1507. // 2. If value is not undefined, then
  1508. if (value !== undefined) {
  1509. // a. Assert: type is "boolean" or "string".
  1510. // b. If type is "boolean", then let value be ToBoolean(value).
  1511. // c. If type is "string", then let value be ToString(value).
  1512. value = type === 'boolean' ? Boolean(value) : type === 'string' ? String(value) : value;
  1513. // d. If values is not undefined, then
  1514. if (values !== undefined) {
  1515. // i. If values does not contain an element equal to value, then throw a
  1516. // RangeError exception.
  1517. if (arrIndexOf.call(values, value) === -1) throw new RangeError("'" + value + "' is not an allowed value for `" + property + '`');
  1518. }
  1519. // e. Return value.
  1520. return value;
  1521. }
  1522. // Else return fallback.
  1523. return fallback;
  1524. }
  1525. /**
  1526. * The GetNumberOption abstract operation extracts a property value from the
  1527. * provided options object, converts it to a Number value, checks whether it is
  1528. * in the allowed range, and fills in a fallback value if necessary.
  1529. */
  1530. function /* 9.2.10 */GetNumberOption(options, property, minimum, maximum, fallback) {
  1531. // 1. Let value be the result of calling the [[Get]] internal method of
  1532. // options with argument property.
  1533. var value = options[property];
  1534. // 2. If value is not undefined, then
  1535. if (value !== undefined) {
  1536. // a. Let value be ToNumber(value).
  1537. value = Number(value);
  1538. // b. If value is NaN or less than minimum or greater than maximum, throw a
  1539. // RangeError exception.
  1540. if (isNaN(value) || value < minimum || value > maximum) throw new RangeError('Value is not a number or outside accepted range');
  1541. // c. Return floor(value).
  1542. return Math.floor(value);
  1543. }
  1544. // 3. Else return fallback.
  1545. return fallback;
  1546. }
  1547. // 8 The Intl Object
  1548. var Intl = {};
  1549. // 8.2 Function Properties of the Intl Object
  1550. // 8.2.1
  1551. // @spec[tc39/ecma402/master/spec/intl.html]
  1552. // @clause[sec-intl.getcanonicallocales]
  1553. function getCanonicalLocales(locales) {
  1554. // 1. Let ll be ? CanonicalizeLocaleList(locales).
  1555. var ll = CanonicalizeLocaleList(locales);
  1556. // 2. Return CreateArrayFromList(ll).
  1557. {
  1558. var result = [];
  1559. var len = ll.length;
  1560. var k = 0;
  1561. while (k < len) {
  1562. result[k] = ll[k];
  1563. k++;
  1564. }
  1565. return result;
  1566. }
  1567. }
  1568. Object.defineProperty(Intl, 'getCanonicalLocales', {
  1569. enumerable: false,
  1570. configurable: true,
  1571. writable: true,
  1572. value: getCanonicalLocales
  1573. });
  1574. // Currency minor units output from get-4217 grunt task, formatted
  1575. var currencyMinorUnits = {
  1576. BHD: 3, BYR: 0, XOF: 0, BIF: 0, XAF: 0, CLF: 4, CLP: 0, KMF: 0, DJF: 0,
  1577. XPF: 0, GNF: 0, ISK: 0, IQD: 3, JPY: 0, JOD: 3, KRW: 0, KWD: 3, LYD: 3,
  1578. OMR: 3, PYG: 0, RWF: 0, TND: 3, UGX: 0, UYI: 0, VUV: 0, VND: 0
  1579. };
  1580. // Define the NumberFormat constructor internally so it cannot be tainted
  1581. function NumberFormatConstructor() {
  1582. var locales = arguments[0];
  1583. var options = arguments[1];
  1584. if (!this || this === Intl) {
  1585. return new Intl.NumberFormat(locales, options);
  1586. }
  1587. return InitializeNumberFormat(toObject(this), locales, options);
  1588. }
  1589. defineProperty(Intl, 'NumberFormat', {
  1590. configurable: true,
  1591. writable: true,
  1592. value: NumberFormatConstructor
  1593. });
  1594. // Must explicitly set prototypes as unwritable
  1595. defineProperty(Intl.NumberFormat, 'prototype', {
  1596. writable: false
  1597. });
  1598. /**
  1599. * The abstract operation InitializeNumberFormat accepts the arguments
  1600. * numberFormat (which must be an object), locales, and options. It initializes
  1601. * numberFormat as a NumberFormat object.
  1602. */
  1603. function /*11.1.1.1 */InitializeNumberFormat(numberFormat, locales, options) {
  1604. // This will be a internal properties object if we're not already initialized
  1605. var internal = getInternalProperties(numberFormat);
  1606. // Create an object whose props can be used to restore the values of RegExp props
  1607. var regexpRestore = createRegExpRestore();
  1608. // 1. If numberFormat has an [[initializedIntlObject]] internal property with
  1609. // value true, throw a TypeError exception.
  1610. if (internal['[[initializedIntlObject]]'] === true) throw new TypeError('`this` object has already been initialized as an Intl object');
  1611. // Need this to access the `internal` object
  1612. defineProperty(numberFormat, '__getInternalProperties', {
  1613. value: function value() {
  1614. // NOTE: Non-standard, for internal use only
  1615. if (arguments[0] === secret) return internal;
  1616. }
  1617. });
  1618. // 2. Set the [[initializedIntlObject]] internal property of numberFormat to true.
  1619. internal['[[initializedIntlObject]]'] = true;
  1620. // 3. Let requestedLocales be the result of calling the CanonicalizeLocaleList
  1621. // abstract operation (defined in 9.2.1) with argument locales.
  1622. var requestedLocales = CanonicalizeLocaleList(locales);
  1623. // 4. If options is undefined, then
  1624. if (options === undefined)
  1625. // a. Let options be the result of creating a new object as if by the
  1626. // expression new Object() where Object is the standard built-in constructor
  1627. // with that name.
  1628. options = {};
  1629. // 5. Else
  1630. else
  1631. // a. Let options be ToObject(options).
  1632. options = toObject(options);
  1633. // 6. Let opt be a new Record.
  1634. var opt = new Record(),
  1635. // 7. Let matcher be the result of calling the GetOption abstract operation
  1636. // (defined in 9.2.9) with the arguments options, "localeMatcher", "string",
  1637. // a List containing the two String values "lookup" and "best fit", and
  1638. // "best fit".
  1639. matcher = GetOption(options, 'localeMatcher', 'string', new List('lookup', 'best fit'), 'best fit');
  1640. // 8. Set opt.[[localeMatcher]] to matcher.
  1641. opt['[[localeMatcher]]'] = matcher;
  1642. // 9. Let NumberFormat be the standard built-in object that is the initial value
  1643. // of Intl.NumberFormat.
  1644. // 10. Let localeData be the value of the [[localeData]] internal property of
  1645. // NumberFormat.
  1646. var localeData = internals.NumberFormat['[[localeData]]'];
  1647. // 11. Let r be the result of calling the ResolveLocale abstract operation
  1648. // (defined in 9.2.5) with the [[availableLocales]] internal property of
  1649. // NumberFormat, requestedLocales, opt, the [[relevantExtensionKeys]]
  1650. // internal property of NumberFormat, and localeData.
  1651. var r = ResolveLocale(internals.NumberFormat['[[availableLocales]]'], requestedLocales, opt, internals.NumberFormat['[[relevantExtensionKeys]]'], localeData);
  1652. // 12. Set the [[locale]] internal property of numberFormat to the value of
  1653. // r.[[locale]].
  1654. internal['[[locale]]'] = r['[[locale]]'];
  1655. // 13. Set the [[numberingSystem]] internal property of numberFormat to the value
  1656. // of r.[[nu]].
  1657. internal['[[numberingSystem]]'] = r['[[nu]]'];
  1658. // The specification doesn't tell us to do this, but it's helpful later on
  1659. internal['[[dataLocale]]'] = r['[[dataLocale]]'];
  1660. // 14. Let dataLocale be the value of r.[[dataLocale]].
  1661. var dataLocale = r['[[dataLocale]]'];
  1662. // 15. Let s be the result of calling the GetOption abstract operation with the
  1663. // arguments options, "style", "string", a List containing the three String
  1664. // values "decimal", "percent", and "currency", and "decimal".
  1665. var s = GetOption(options, 'style', 'string', new List('decimal', 'percent', 'currency'), 'decimal');
  1666. // 16. Set the [[style]] internal property of numberFormat to s.
  1667. internal['[[style]]'] = s;
  1668. // 17. Let c be the result of calling the GetOption abstract operation with the
  1669. // arguments options, "currency", "string", undefined, and undefined.
  1670. var c = GetOption(options, 'currency', 'string');
  1671. // 18. If c is not undefined and the result of calling the
  1672. // IsWellFormedCurrencyCode abstract operation (defined in 6.3.1) with
  1673. // argument c is false, then throw a RangeError exception.
  1674. if (c !== undefined && !IsWellFormedCurrencyCode(c)) throw new RangeError("'" + c + "' is not a valid currency code");
  1675. // 19. If s is "currency" and c is undefined, throw a TypeError exception.
  1676. if (s === 'currency' && c === undefined) throw new TypeError('Currency code is required when style is currency');
  1677. var cDigits = void 0;
  1678. // 20. If s is "currency", then
  1679. if (s === 'currency') {
  1680. // a. Let c be the result of converting c to upper case as specified in 6.1.
  1681. c = c.toUpperCase();
  1682. // b. Set the [[currency]] internal property of numberFormat to c.
  1683. internal['[[currency]]'] = c;
  1684. // c. Let cDigits be the result of calling the CurrencyDigits abstract
  1685. // operation (defined below) with argument c.
  1686. cDigits = CurrencyDigits(c);
  1687. }
  1688. // 21. Let cd be the result of calling the GetOption abstract operation with the
  1689. // arguments options, "currencyDisplay", "string", a List containing the
  1690. // three String values "code", "symbol", and "name", and "symbol".
  1691. var cd = GetOption(options, 'currencyDisplay', 'string', new List('code', 'symbol', 'name'), 'symbol');
  1692. // 22. If s is "currency", then set the [[currencyDisplay]] internal property of
  1693. // numberFormat to cd.
  1694. if (s === 'currency') internal['[[currencyDisplay]]'] = cd;
  1695. // 23. Let mnid be the result of calling the GetNumberOption abstract operation
  1696. // (defined in 9.2.10) with arguments options, "minimumIntegerDigits", 1, 21,
  1697. // and 1.
  1698. var mnid = GetNumberOption(options, 'minimumIntegerDigits', 1, 21, 1);
  1699. // 24. Set the [[minimumIntegerDigits]] internal property of numberFormat to mnid.
  1700. internal['[[minimumIntegerDigits]]'] = mnid;
  1701. // 25. If s is "currency", then let mnfdDefault be cDigits; else let mnfdDefault
  1702. // be 0.
  1703. var mnfdDefault = s === 'currency' ? cDigits : 0;
  1704. // 26. Let mnfd be the result of calling the GetNumberOption abstract operation
  1705. // with arguments options, "minimumFractionDigits", 0, 20, and mnfdDefault.
  1706. var mnfd = GetNumberOption(options, 'minimumFractionDigits', 0, 20, mnfdDefault);
  1707. // 27. Set the [[minimumFractionDigits]] internal property of numberFormat to mnfd.
  1708. internal['[[minimumFractionDigits]]'] = mnfd;
  1709. // 28. If s is "currency", then let mxfdDefault be max(mnfd, cDigits); else if s
  1710. // is "percent", then let mxfdDefault be max(mnfd, 0); else let mxfdDefault
  1711. // be max(mnfd, 3).
  1712. var mxfdDefault = s === 'currency' ? Math.max(mnfd, cDigits) : s === 'percent' ? Math.max(mnfd, 0) : Math.max(mnfd, 3);
  1713. // 29. Let mxfd be the result of calling the GetNumberOption abstract operation
  1714. // with arguments options, "maximumFractionDigits", mnfd, 20, and mxfdDefault.
  1715. var mxfd = GetNumberOption(options, 'maximumFractionDigits', mnfd, 20, mxfdDefault);
  1716. // 30. Set the [[maximumFractionDigits]] internal property of numberFormat to mxfd.
  1717. internal['[[maximumFractionDigits]]'] = mxfd;
  1718. // 31. Let mnsd be the result of calling the [[Get]] internal method of options
  1719. // with argument "minimumSignificantDigits".
  1720. var mnsd = options.minimumSignificantDigits;
  1721. // 32. Let mxsd be the result of calling the [[Get]] internal method of options
  1722. // with argument "maximumSignificantDigits".
  1723. var mxsd = options.maximumSignificantDigits;
  1724. // 33. If mnsd is not undefined or mxsd is not undefined, then:
  1725. if (mnsd !== undefined || mxsd !== undefined) {
  1726. // a. Let mnsd be the result of calling the GetNumberOption abstract
  1727. // operation with arguments options, "minimumSignificantDigits", 1, 21,
  1728. // and 1.
  1729. mnsd = GetNumberOption(options, 'minimumSignificantDigits', 1, 21, 1);
  1730. // b. Let mxsd be the result of calling the GetNumberOption abstract
  1731. // operation with arguments options, "maximumSignificantDigits", mnsd,
  1732. // 21, and 21.
  1733. mxsd = GetNumberOption(options, 'maximumSignificantDigits', mnsd, 21, 21);
  1734. // c. Set the [[minimumSignificantDigits]] internal property of numberFormat
  1735. // to mnsd, and the [[maximumSignificantDigits]] internal property of
  1736. // numberFormat to mxsd.
  1737. internal['[[minimumSignificantDigits]]'] = mnsd;
  1738. internal['[[maximumSignificantDigits]]'] = mxsd;
  1739. }
  1740. // 34. Let g be the result of calling the GetOption abstract operation with the
  1741. // arguments options, "useGrouping", "boolean", undefined, and true.
  1742. var g = GetOption(options, 'useGrouping', 'boolean', undefined, true);
  1743. // 35. Set the [[useGrouping]] internal property of numberFormat to g.
  1744. internal['[[useGrouping]]'] = g;
  1745. // 36. Let dataLocaleData be the result of calling the [[Get]] internal method of
  1746. // localeData with argument dataLocale.
  1747. var dataLocaleData = localeData[dataLocale];
  1748. // 37. Let patterns be the result of calling the [[Get]] internal method of
  1749. // dataLocaleData with argument "patterns".
  1750. var patterns = dataLocaleData.patterns;
  1751. // 38. Assert: patterns is an object (see 11.2.3)
  1752. // 39. Let stylePatterns be the result of calling the [[Get]] internal method of
  1753. // patterns with argument s.
  1754. var stylePatterns = patterns[s];
  1755. // 40. Set the [[positivePattern]] internal property of numberFormat to the
  1756. // result of calling the [[Get]] internal method of stylePatterns with the
  1757. // argument "positivePattern".
  1758. internal['[[positivePattern]]'] = stylePatterns.positivePattern;
  1759. // 41. Set the [[negativePattern]] internal property of numberFormat to the
  1760. // result of calling the [[Get]] internal method of stylePatterns with the
  1761. // argument "negativePattern".
  1762. internal['[[negativePattern]]'] = stylePatterns.negativePattern;
  1763. // 42. Set the [[boundFormat]] internal property of numberFormat to undefined.
  1764. internal['[[boundFormat]]'] = undefined;
  1765. // 43. Set the [[initializedNumberFormat]] internal property of numberFormat to
  1766. // true.
  1767. internal['[[initializedNumberFormat]]'] = true;
  1768. // In ES3, we need to pre-bind the format() function
  1769. if (es3) numberFormat.format = GetFormatNumber.call(numberFormat);
  1770. // Restore the RegExp properties
  1771. regexpRestore();
  1772. // Return the newly initialised object
  1773. return numberFormat;
  1774. }
  1775. function CurrencyDigits(currency) {
  1776. // When the CurrencyDigits abstract operation is called with an argument currency
  1777. // (which must be an upper case String value), the following steps are taken:
  1778. // 1. If the ISO 4217 currency and funds code list contains currency as an
  1779. // alphabetic code, then return the minor unit value corresponding to the
  1780. // currency from the list; else return 2.
  1781. return currencyMinorUnits[currency] !== undefined ? currencyMinorUnits[currency] : 2;
  1782. }
  1783. /* 11.2.3 */internals.NumberFormat = {
  1784. '[[availableLocales]]': [],
  1785. '[[relevantExtensionKeys]]': ['nu'],
  1786. '[[localeData]]': {}
  1787. };
  1788. /**
  1789. * When the supportedLocalesOf method of Intl.NumberFormat is called, the
  1790. * following steps are taken:
  1791. */
  1792. /* 11.2.2 */
  1793. defineProperty(Intl.NumberFormat, 'supportedLocalesOf', {
  1794. configurable: true,
  1795. writable: true,
  1796. value: fnBind.call(function (locales) {
  1797. // Bound functions only have the `this` value altered if being used as a constructor,
  1798. // this lets us imitate a native function that has no constructor
  1799. if (!hop.call(this, '[[availableLocales]]')) throw new TypeError('supportedLocalesOf() is not a constructor');
  1800. // Create an object whose props can be used to restore the values of RegExp props
  1801. var regexpRestore = createRegExpRestore(),
  1802. // 1. If options is not provided, then let options be undefined.
  1803. options = arguments[1],
  1804. // 2. Let availableLocales be the value of the [[availableLocales]] internal
  1805. // property of the standard built-in object that is the initial value of
  1806. // Intl.NumberFormat.
  1807. availableLocales = this['[[availableLocales]]'],
  1808. // 3. Let requestedLocales be the result of calling the CanonicalizeLocaleList
  1809. // abstract operation (defined in 9.2.1) with argument locales.
  1810. requestedLocales = CanonicalizeLocaleList(locales);
  1811. // Restore the RegExp properties
  1812. regexpRestore();
  1813. // 4. Return the result of calling the SupportedLocales abstract operation
  1814. // (defined in 9.2.8) with arguments availableLocales, requestedLocales,
  1815. // and options.
  1816. return SupportedLocales(availableLocales, requestedLocales, options);
  1817. }, internals.NumberFormat)
  1818. });
  1819. /**
  1820. * This named accessor property returns a function that formats a number
  1821. * according to the effective locale and the formatting options of this
  1822. * NumberFormat object.
  1823. */
  1824. /* 11.3.2 */defineProperty(Intl.NumberFormat.prototype, 'format', {
  1825. configurable: true,
  1826. get: GetFormatNumber
  1827. });
  1828. function GetFormatNumber() {
  1829. var internal = this !== null && babelHelpers$1["typeof"](this) === 'object' && getInternalProperties(this);
  1830. // Satisfy test 11.3_b
  1831. if (!internal || !internal['[[initializedNumberFormat]]']) throw new TypeError('`this` value for format() is not an initialized Intl.NumberFormat object.');
  1832. // The value of the [[Get]] attribute is a function that takes the following
  1833. // steps:
  1834. // 1. If the [[boundFormat]] internal property of this NumberFormat object
  1835. // is undefined, then:
  1836. if (internal['[[boundFormat]]'] === undefined) {
  1837. // a. Let F be a Function object, with internal properties set as
  1838. // specified for built-in functions in ES5, 15, or successor, and the
  1839. // length property set to 1, that takes the argument value and
  1840. // performs the following steps:
  1841. var F = function F(value) {
  1842. // i. If value is not provided, then let value be undefined.
  1843. // ii. Let x be ToNumber(value).
  1844. // iii. Return the result of calling the FormatNumber abstract
  1845. // operation (defined below) with arguments this and x.
  1846. return FormatNumber(this, /* x = */Number(value));
  1847. };
  1848. // b. Let bind be the standard built-in function object defined in ES5,
  1849. // 15.3.4.5.
  1850. // c. Let bf be the result of calling the [[Call]] internal method of
  1851. // bind with F as the this value and an argument list containing
  1852. // the single item this.
  1853. var bf = fnBind.call(F, this);
  1854. // d. Set the [[boundFormat]] internal property of this NumberFormat
  1855. // object to bf.
  1856. internal['[[boundFormat]]'] = bf;
  1857. }
  1858. // Return the value of the [[boundFormat]] internal property of this
  1859. // NumberFormat object.
  1860. return internal['[[boundFormat]]'];
  1861. }
  1862. function formatToParts() {
  1863. var value = arguments.length <= 0 || arguments[0] === undefined ? undefined : arguments[0];
  1864. var internal = this !== null && babelHelpers$1["typeof"](this) === 'object' && getInternalProperties(this);
  1865. if (!internal || !internal['[[initializedNumberFormat]]']) throw new TypeError('`this` value for formatToParts() is not an initialized Intl.NumberFormat object.');
  1866. var x = Number(value);
  1867. return FormatNumberToParts(this, x);
  1868. }
  1869. Object.defineProperty(Intl.NumberFormat.prototype, 'formatToParts', {
  1870. configurable: true,
  1871. enumerable: false,
  1872. writable: true,
  1873. value: formatToParts
  1874. });
  1875. /*
  1876. * @spec[stasm/ecma402/number-format-to-parts/spec/numberformat.html]
  1877. * @clause[sec-formatnumbertoparts]
  1878. */
  1879. function FormatNumberToParts(numberFormat, x) {
  1880. // 1. Let parts be ? PartitionNumberPattern(numberFormat, x).
  1881. var parts = PartitionNumberPattern(numberFormat, x);
  1882. // 2. Let result be ArrayCreate(0).
  1883. var result = [];
  1884. // 3. Let n be 0.
  1885. var n = 0;
  1886. // 4. For each part in parts, do:
  1887. for (var i = 0; parts.length > i; i++) {
  1888. var part = parts[i];
  1889. // a. Let O be ObjectCreate(%ObjectPrototype%).
  1890. var O = {};
  1891. // a. Perform ? CreateDataPropertyOrThrow(O, "type", part.[[type]]).
  1892. O.type = part['[[type]]'];
  1893. // a. Perform ? CreateDataPropertyOrThrow(O, "value", part.[[value]]).
  1894. O.value = part['[[value]]'];
  1895. // a. Perform ? CreateDataPropertyOrThrow(result, ? ToString(n), O).
  1896. result[n] = O;
  1897. // a. Increment n by 1.
  1898. n += 1;
  1899. }
  1900. // 5. Return result.
  1901. return result;
  1902. }
  1903. /*
  1904. * @spec[stasm/ecma402/number-format-to-parts/spec/numberformat.html]
  1905. * @clause[sec-partitionnumberpattern]
  1906. */
  1907. function PartitionNumberPattern(numberFormat, x) {
  1908. var internal = getInternalProperties(numberFormat),
  1909. locale = internal['[[dataLocale]]'],
  1910. nums = internal['[[numberingSystem]]'],
  1911. data = internals.NumberFormat['[[localeData]]'][locale],
  1912. ild = data.symbols[nums] || data.symbols.latn,
  1913. pattern = void 0;
  1914. // 1. If x is not NaN and x < 0, then:
  1915. if (!isNaN(x) && x < 0) {
  1916. // a. Let x be -x.
  1917. x = -x;
  1918. // a. Let pattern be the value of numberFormat.[[negativePattern]].
  1919. pattern = internal['[[negativePattern]]'];
  1920. }
  1921. // 2. Else,
  1922. else {
  1923. // a. Let pattern be the value of numberFormat.[[positivePattern]].
  1924. pattern = internal['[[positivePattern]]'];
  1925. }
  1926. // 3. Let result be a new empty List.
  1927. var result = new List();
  1928. // 4. Let beginIndex be Call(%StringProto_indexOf%, pattern, "{", 0).
  1929. var beginIndex = pattern.indexOf('{', 0);
  1930. // 5. Let endIndex be 0.
  1931. var endIndex = 0;
  1932. // 6. Let nextIndex be 0.
  1933. var nextIndex = 0;
  1934. // 7. Let length be the number of code units in pattern.
  1935. var length = pattern.length;
  1936. // 8. Repeat while beginIndex is an integer index into pattern:
  1937. while (beginIndex > -1 && beginIndex < length) {
  1938. // a. Set endIndex to Call(%StringProto_indexOf%, pattern, "}", beginIndex)
  1939. endIndex = pattern.indexOf('}', beginIndex);
  1940. // a. If endIndex = -1, throw new Error exception.
  1941. if (endIndex === -1) throw new Error();
  1942. // a. If beginIndex is greater than nextIndex, then:
  1943. if (beginIndex > nextIndex) {
  1944. // i. Let literal be a substring of pattern from position nextIndex, inclusive, to position beginIndex, exclusive.
  1945. var literal = pattern.substring(nextIndex, beginIndex);
  1946. // ii. Add new part record { [[type]]: "literal", [[value]]: literal } as a new element of the list result.
  1947. arrPush.call(result, { '[[type]]': 'literal', '[[value]]': literal });
  1948. }
  1949. // a. Let p be the substring of pattern from position beginIndex, exclusive, to position endIndex, exclusive.
  1950. var p = pattern.substring(beginIndex + 1, endIndex);
  1951. // a. If p is equal "number", then:
  1952. if (p === "number") {
  1953. // i. If x is NaN,
  1954. if (isNaN(x)) {
  1955. // 1. Let n be an ILD String value indicating the NaN value.
  1956. var n = ild.nan;
  1957. // 2. Add new part record { [[type]]: "nan", [[value]]: n } as a new element of the list result.
  1958. arrPush.call(result, { '[[type]]': 'nan', '[[value]]': n });
  1959. }
  1960. // ii. Else if isFinite(x) is false,
  1961. else if (!isFinite(x)) {
  1962. // 1. Let n be an ILD String value indicating infinity.
  1963. var _n = ild.infinity;
  1964. // 2. Add new part record { [[type]]: "infinity", [[value]]: n } as a new element of the list result.
  1965. arrPush.call(result, { '[[type]]': 'infinity', '[[value]]': _n });
  1966. }
  1967. // iii. Else,
  1968. else {
  1969. // 1. If the value of numberFormat.[[style]] is "percent" and isFinite(x), let x be 100 × x.
  1970. if (internal['[[style]]'] === 'percent' && isFinite(x)) x *= 100;
  1971. var _n2 = void 0;
  1972. // 2. If the numberFormat.[[minimumSignificantDigits]] and numberFormat.[[maximumSignificantDigits]] are present, then
  1973. if (hop.call(internal, '[[minimumSignificantDigits]]') && hop.call(internal, '[[maximumSignificantDigits]]')) {
  1974. // a. Let n be ToRawPrecision(x, numberFormat.[[minimumSignificantDigits]], numberFormat.[[maximumSignificantDigits]]).
  1975. _n2 = ToRawPrecision(x, internal['[[minimumSignificantDigits]]'], internal['[[maximumSignificantDigits]]']);
  1976. }
  1977. // 3. Else,
  1978. else {
  1979. // a. Let n be ToRawFixed(x, numberFormat.[[minimumIntegerDigits]], numberFormat.[[minimumFractionDigits]], numberFormat.[[maximumFractionDigits]]).
  1980. _n2 = ToRawFixed(x, internal['[[minimumIntegerDigits]]'], internal['[[minimumFractionDigits]]'], internal['[[maximumFractionDigits]]']);
  1981. }
  1982. // 4. If the value of the numberFormat.[[numberingSystem]] matches one of the values in the "Numbering System" column of Table 2 below, then
  1983. if (numSys[nums]) {
  1984. (function () {
  1985. // a. Let digits be an array whose 10 String valued elements are the UTF-16 string representations of the 10 digits specified in the "Digits" column of the matching row in Table 2.
  1986. var digits = numSys[nums];
  1987. // a. Replace each digit in n with the value of digits[digit].
  1988. _n2 = String(_n2).replace(/\d/g, function (digit) {
  1989. return digits[digit];
  1990. });
  1991. })();
  1992. }
  1993. // 5. Else use an implementation dependent algorithm to map n to the appropriate representation of n in the given numbering system.
  1994. else _n2 = String(_n2); // ###TODO###
  1995. var integer = void 0;
  1996. var fraction = void 0;
  1997. // 6. Let decimalSepIndex be Call(%StringProto_indexOf%, n, ".", 0).
  1998. var decimalSepIndex = _n2.indexOf('.', 0);
  1999. // 7. If decimalSepIndex > 0, then:
  2000. if (decimalSepIndex > 0) {
  2001. // a. Let integer be the substring of n from position 0, inclusive, to position decimalSepIndex, exclusive.
  2002. integer = _n2.substring(0, decimalSepIndex);
  2003. // a. Let fraction be the substring of n from position decimalSepIndex, exclusive, to the end of n.
  2004. fraction = _n2.substring(decimalSepIndex + 1, decimalSepIndex.length);
  2005. }
  2006. // 8. Else:
  2007. else {
  2008. // a. Let integer be n.
  2009. integer = _n2;
  2010. // a. Let fraction be undefined.
  2011. fraction = undefined;
  2012. }
  2013. // 9. If the value of the numberFormat.[[useGrouping]] is true,
  2014. if (internal['[[useGrouping]]'] === true) {
  2015. // a. Let groupSepSymbol be the ILND String representing the grouping separator.
  2016. var groupSepSymbol = ild.group;
  2017. // a. Let groups be a List whose elements are, in left to right order, the substrings defined by ILND set of locations within the integer.
  2018. var groups = [];
  2019. // ----> implementation:
  2020. // Primary group represents the group closest to the decimal
  2021. var pgSize = data.patterns.primaryGroupSize || 3;
  2022. // Secondary group is every other group
  2023. var sgSize = data.patterns.secondaryGroupSize || pgSize;
  2024. // Group only if necessary
  2025. if (integer.length > pgSize) {
  2026. // Index of the primary grouping separator
  2027. var end = integer.length - pgSize;
  2028. // Starting index for our loop
  2029. var idx = end % sgSize;
  2030. var start = integer.slice(0, idx);
  2031. if (start.length) arrPush.call(groups, start);
  2032. // Loop to separate into secondary grouping digits
  2033. while (idx < end) {
  2034. arrPush.call(groups, integer.slice(idx, idx + sgSize));
  2035. idx += sgSize;
  2036. }
  2037. // Add the primary grouping digits
  2038. arrPush.call(groups, integer.slice(end));
  2039. } else {
  2040. arrPush.call(groups, integer);
  2041. }
  2042. // a. Assert: The number of elements in groups List is greater than 0.
  2043. if (groups.length === 0) throw new Error();
  2044. // a. Repeat, while groups List is not empty:
  2045. while (groups.length) {
  2046. // i. Remove the first element from groups and let integerGroup be the value of that element.
  2047. var integerGroup = arrShift.call(groups);
  2048. // ii. Add new part record { [[type]]: "integer", [[value]]: integerGroup } as a new element of the list result.
  2049. arrPush.call(result, { '[[type]]': 'integer', '[[value]]': integerGroup });
  2050. // iii. If groups List is not empty, then:
  2051. if (groups.length) {
  2052. // 1. Add new part record { [[type]]: "group", [[value]]: groupSepSymbol } as a new element of the list result.
  2053. arrPush.call(result, { '[[type]]': 'group', '[[value]]': groupSepSymbol });
  2054. }
  2055. }
  2056. }
  2057. // 10. Else,
  2058. else {
  2059. // a. Add new part record { [[type]]: "integer", [[value]]: integer } as a new element of the list result.
  2060. arrPush.call(result, { '[[type]]': 'integer', '[[value]]': integer });
  2061. }
  2062. // 11. If fraction is not undefined, then:
  2063. if (fraction !== undefined) {
  2064. // a. Let decimalSepSymbol be the ILND String representing the decimal separator.
  2065. var decimalSepSymbol = ild.decimal;
  2066. // a. Add new part record { [[type]]: "decimal", [[value]]: decimalSepSymbol } as a new element of the list result.
  2067. arrPush.call(result, { '[[type]]': 'decimal', '[[value]]': decimalSepSymbol });
  2068. // a. Add new part record { [[type]]: "fraction", [[value]]: fraction } as a new element of the list result.
  2069. arrPush.call(result, { '[[type]]': 'fraction', '[[value]]': fraction });
  2070. }
  2071. }
  2072. }
  2073. // a. Else if p is equal "plusSign", then:
  2074. else if (p === "plusSign") {
  2075. // i. Let plusSignSymbol be the ILND String representing the plus sign.
  2076. var plusSignSymbol = ild.plusSign;
  2077. // ii. Add new part record { [[type]]: "plusSign", [[value]]: plusSignSymbol } as a new element of the list result.
  2078. arrPush.call(result, { '[[type]]': 'plusSign', '[[value]]': plusSignSymbol });
  2079. }
  2080. // a. Else if p is equal "minusSign", then:
  2081. else if (p === "minusSign") {
  2082. // i. Let minusSignSymbol be the ILND String representing the minus sign.
  2083. var minusSignSymbol = ild.minusSign;
  2084. // ii. Add new part record { [[type]]: "minusSign", [[value]]: minusSignSymbol } as a new element of the list result.
  2085. arrPush.call(result, { '[[type]]': 'minusSign', '[[value]]': minusSignSymbol });
  2086. }
  2087. // a. Else if p is equal "percentSign" and numberFormat.[[style]] is "percent", then:
  2088. else if (p === "percentSign" && internal['[[style]]'] === "percent") {
  2089. // i. Let percentSignSymbol be the ILND String representing the percent sign.
  2090. var percentSignSymbol = ild.percentSign;
  2091. // ii. Add new part record { [[type]]: "percentSign", [[value]]: percentSignSymbol } as a new element of the list result.
  2092. arrPush.call(result, { '[[type]]': 'literal', '[[value]]': percentSignSymbol });
  2093. }
  2094. // a. Else if p is equal "currency" and numberFormat.[[style]] is "currency", then:
  2095. else if (p === "currency" && internal['[[style]]'] === "currency") {
  2096. // i. Let currency be the value of numberFormat.[[currency]].
  2097. var currency = internal['[[currency]]'];
  2098. var cd = void 0;
  2099. // ii. If numberFormat.[[currencyDisplay]] is "code", then
  2100. if (internal['[[currencyDisplay]]'] === "code") {
  2101. // 1. Let cd be currency.
  2102. cd = currency;
  2103. }
  2104. // iii. Else if numberFormat.[[currencyDisplay]] is "symbol", then
  2105. else if (internal['[[currencyDisplay]]'] === "symbol") {
  2106. // 1. Let cd be an ILD string representing currency in short form. If the implementation does not have such a representation of currency, use currency itself.
  2107. cd = data.currencies[currency] || currency;
  2108. }
  2109. // iv. Else if numberFormat.[[currencyDisplay]] is "name", then
  2110. else if (internal['[[currencyDisplay]]'] === "name") {
  2111. // 1. Let cd be an ILD string representing currency in long form. If the implementation does not have such a representation of currency, then use currency itself.
  2112. cd = currency;
  2113. }
  2114. // v. Add new part record { [[type]]: "currency", [[value]]: cd } as a new element of the list result.
  2115. arrPush.call(result, { '[[type]]': 'currency', '[[value]]': cd });
  2116. }
  2117. // a. Else,
  2118. else {
  2119. // i. Let literal be the substring of pattern from position beginIndex, inclusive, to position endIndex, inclusive.
  2120. var _literal = pattern.substring(beginIndex, endIndex);
  2121. // ii. Add new part record { [[type]]: "literal", [[value]]: literal } as a new element of the list result.
  2122. arrPush.call(result, { '[[type]]': 'literal', '[[value]]': _literal });
  2123. }
  2124. // a. Set nextIndex to endIndex + 1.
  2125. nextIndex = endIndex + 1;
  2126. // a. Set beginIndex to Call(%StringProto_indexOf%, pattern, "{", nextIndex)
  2127. beginIndex = pattern.indexOf('{', nextIndex);
  2128. }
  2129. // 9. If nextIndex is less than length, then:
  2130. if (nextIndex < length) {
  2131. // a. Let literal be the substring of pattern from position nextIndex, inclusive, to position length, exclusive.
  2132. var _literal2 = pattern.substring(nextIndex, length);
  2133. // a. Add new part record { [[type]]: "literal", [[value]]: literal } as a new element of the list result.
  2134. arrPush.call(result, { '[[type]]': 'literal', '[[value]]': _literal2 });
  2135. }
  2136. // 10. Return result.
  2137. return result;
  2138. }
  2139. /*
  2140. * @spec[stasm/ecma402/number-format-to-parts/spec/numberformat.html]
  2141. * @clause[sec-formatnumber]
  2142. */
  2143. function FormatNumber(numberFormat, x) {
  2144. // 1. Let parts be ? PartitionNumberPattern(numberFormat, x).
  2145. var parts = PartitionNumberPattern(numberFormat, x);
  2146. // 2. Let result be an empty String.
  2147. var result = '';
  2148. // 3. For each part in parts, do:
  2149. for (var i = 0; parts.length > i; i++) {
  2150. var part = parts[i];
  2151. // a. Set result to a String value produced by concatenating result and part.[[value]].
  2152. result += part['[[value]]'];
  2153. }
  2154. // 4. Return result.
  2155. return result;
  2156. }
  2157. /**
  2158. * When the ToRawPrecision abstract operation is called with arguments x (which
  2159. * must be a finite non-negative number), minPrecision, and maxPrecision (both
  2160. * must be integers between 1 and 21) the following steps are taken:
  2161. */
  2162. function ToRawPrecision(x, minPrecision, maxPrecision) {
  2163. // 1. Let p be maxPrecision.
  2164. var p = maxPrecision;
  2165. var m = void 0,
  2166. e = void 0;
  2167. // 2. If x = 0, then
  2168. if (x === 0) {
  2169. // a. Let m be the String consisting of p occurrences of the character "0".
  2170. m = arrJoin.call(Array(p + 1), '0');
  2171. // b. Let e be 0.
  2172. e = 0;
  2173. }
  2174. // 3. Else
  2175. else {
  2176. // a. Let e and n be integers such that 10ᵖ⁻¹ ≤ n < 10ᵖ and for which the
  2177. // exact mathematical value of n × 10ᵉ⁻ᵖ⁺¹ – x is as close to zero as
  2178. // possible. If there are two such sets of e and n, pick the e and n for
  2179. // which n × 10ᵉ⁻ᵖ⁺¹ is larger.
  2180. e = log10Floor(Math.abs(x));
  2181. // Easier to get to m from here
  2182. var f = Math.round(Math.exp(Math.abs(e - p + 1) * Math.LN10));
  2183. // b. Let m be the String consisting of the digits of the decimal
  2184. // representation of n (in order, with no leading zeroes)
  2185. m = String(Math.round(e - p + 1 < 0 ? x * f : x / f));
  2186. }
  2187. // 4. If e ≥ p, then
  2188. if (e >= p)
  2189. // a. Return the concatenation of m and e-p+1 occurrences of the character "0".
  2190. return m + arrJoin.call(Array(e - p + 1 + 1), '0');
  2191. // 5. If e = p-1, then
  2192. else if (e === p - 1)
  2193. // a. Return m.
  2194. return m;
  2195. // 6. If e ≥ 0, then
  2196. else if (e >= 0)
  2197. // a. Let m be the concatenation of the first e+1 characters of m, the character
  2198. // ".", and the remaining p–(e+1) characters of m.
  2199. m = m.slice(0, e + 1) + '.' + m.slice(e + 1);
  2200. // 7. If e < 0, then
  2201. else if (e < 0)
  2202. // a. Let m be the concatenation of the String "0.", –(e+1) occurrences of the
  2203. // character "0", and the string m.
  2204. m = '0.' + arrJoin.call(Array(-(e + 1) + 1), '0') + m;
  2205. // 8. If m contains the character ".", and maxPrecision > minPrecision, then
  2206. if (m.indexOf(".") >= 0 && maxPrecision > minPrecision) {
  2207. // a. Let cut be maxPrecision – minPrecision.
  2208. var cut = maxPrecision - minPrecision;
  2209. // b. Repeat while cut > 0 and the last character of m is "0":
  2210. while (cut > 0 && m.charAt(m.length - 1) === '0') {
  2211. // i. Remove the last character from m.
  2212. m = m.slice(0, -1);
  2213. // ii. Decrease cut by 1.
  2214. cut--;
  2215. }
  2216. // c. If the last character of m is ".", then
  2217. if (m.charAt(m.length - 1) === '.')
  2218. // i. Remove the last character from m.
  2219. m = m.slice(0, -1);
  2220. }
  2221. // 9. Return m.
  2222. return m;
  2223. }
  2224. /**
  2225. * @spec[tc39/ecma402/master/spec/numberformat.html]
  2226. * @clause[sec-torawfixed]
  2227. * When the ToRawFixed abstract operation is called with arguments x (which must
  2228. * be a finite non-negative number), minInteger (which must be an integer between
  2229. * 1 and 21), minFraction, and maxFraction (which must be integers between 0 and
  2230. * 20) the following steps are taken:
  2231. */
  2232. function ToRawFixed(x, minInteger, minFraction, maxFraction) {
  2233. // 1. Let f be maxFraction.
  2234. var f = maxFraction;
  2235. // 2. Let n be an integer for which the exact mathematical value of n ÷ 10f – x is as close to zero as possible. If there are two such n, pick the larger n.
  2236. var n = Math.pow(10, f) * x; // diverging...
  2237. // 3. If n = 0, let m be the String "0". Otherwise, let m be the String consisting of the digits of the decimal representation of n (in order, with no leading zeroes).
  2238. var m = n === 0 ? "0" : n.toFixed(0); // divering...
  2239. {
  2240. // this diversion is needed to take into consideration big numbers, e.g.:
  2241. // 1.2344501e+37 -> 12344501000000000000000000000000000000
  2242. var idx = void 0;
  2243. var exp = (idx = m.indexOf('e')) > -1 ? m.slice(idx + 1) : 0;
  2244. if (exp) {
  2245. m = m.slice(0, idx).replace('.', '');
  2246. m += arrJoin.call(Array(exp - (m.length - 1) + 1), '0');
  2247. }
  2248. }
  2249. var int = void 0;
  2250. // 4. If f ≠ 0, then
  2251. if (f !== 0) {
  2252. // a. Let k be the number of characters in m.
  2253. var k = m.length;
  2254. // a. If k ≤ f, then
  2255. if (k <= f) {
  2256. // i. Let z be the String consisting of f+1–k occurrences of the character "0".
  2257. var z = arrJoin.call(Array(f + 1 - k + 1), '0');
  2258. // ii. Let m be the concatenation of Strings z and m.
  2259. m = z + m;
  2260. // iii. Let k be f+1.
  2261. k = f + 1;
  2262. }
  2263. // a. Let a be the first k–f characters of m, and let b be the remaining f characters of m.
  2264. var a = m.substring(0, k - f),
  2265. b = m.substring(k - f, m.length);
  2266. // a. Let m be the concatenation of the three Strings a, ".", and b.
  2267. m = a + "." + b;
  2268. // a. Let int be the number of characters in a.
  2269. int = a.length;
  2270. }
  2271. // 5. Else, let int be the number of characters in m.
  2272. else int = m.length;
  2273. // 6. Let cut be maxFraction – minFraction.
  2274. var cut = maxFraction - minFraction;
  2275. // 7. Repeat while cut > 0 and the last character of m is "0":
  2276. while (cut > 0 && m.slice(-1) === "0") {
  2277. // a. Remove the last character from m.
  2278. m = m.slice(0, -1);
  2279. // a. Decrease cut by 1.
  2280. cut--;
  2281. }
  2282. // 8. If the last character of m is ".", then
  2283. if (m.slice(-1) === ".") {
  2284. // a. Remove the last character from m.
  2285. m = m.slice(0, -1);
  2286. }
  2287. // 9. If int < minInteger, then
  2288. if (int < minInteger) {
  2289. // a. Let z be the String consisting of minInteger–int occurrences of the character "0".
  2290. var _z = arrJoin.call(Array(minInteger - int + 1), '0');
  2291. // a. Let m be the concatenation of Strings z and m.
  2292. m = _z + m;
  2293. }
  2294. // 10. Return m.
  2295. return m;
  2296. }
  2297. // Sect 11.3.2 Table 2, Numbering systems
  2298. // ======================================
  2299. var numSys = {
  2300. arab: ["٠", "١", "٢", "٣", "٤", "٥", "٦", "٧", "٨", "٩"],
  2301. arabext: ["۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹"],
  2302. bali: ["᭐", "᭑", "᭒", "᭓", "᭔", "᭕", "᭖", "᭗", "᭘", "᭙"],
  2303. beng: ["০", "১", "২", "৩", "৪", "৫", "৬", "৭", "৮", "৯"],
  2304. deva: ["०", "१", "२", "३", "४", "५", "६", "७", "८", "९"],
  2305. fullwide: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
  2306. gujr: ["૦", "૧", "૨", "૩", "૪", "૫", "૬", "૭", "૮", "૯"],
  2307. guru: ["੦", "੧", "੨", "੩", "੪", "੫", "੬", "੭", "੮", "੯"],
  2308. hanidec: ["〇", "一", "二", "三", "四", "五", "六", "七", "八", "九"],
  2309. khmr: ["០", "១", "២", "៣", "៤", "៥", "៦", "៧", "៨", "៩"],
  2310. knda: ["೦", "೧", "೨", "೩", "೪", "೫", "೬", "೭", "೮", "೯"],
  2311. laoo: ["໐", "໑", "໒", "໓", "໔", "໕", "໖", "໗", "໘", "໙"],
  2312. latn: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
  2313. limb: ["᥆", "᥇", "᥈", "᥉", "᥊", "᥋", "᥌", "᥍", "᥎", "᥏"],
  2314. mlym: ["൦", "൧", "൨", "൩", "൪", "൫", "൬", "൭", "൮", "൯"],
  2315. mong: ["᠐", "᠑", "᠒", "᠓", "᠔", "᠕", "᠖", "᠗", "᠘", "᠙"],
  2316. mymr: ["၀", "၁", "၂", "၃", "၄", "၅", "၆", "၇", "၈", "၉"],
  2317. orya: ["୦", "୧", "୨", "୩", "୪", "୫", "୬", "୭", "୮", "୯"],
  2318. tamldec: ["௦", "௧", "௨", "௩", "௪", "௫", "௬", "௭", "௮", "௯"],
  2319. telu: ["౦", "౧", "౨", "౩", "౪", "౫", "౬", "౭", "౮", "౯"],
  2320. thai: ["๐", "๑", "๒", "๓", "๔", "๕", "๖", "๗", "๘", "๙"],
  2321. tibt: ["༠", "༡", "༢", "༣", "༤", "༥", "༦", "༧", "༨", "༩"]
  2322. };
  2323. /**
  2324. * This function provides access to the locale and formatting options computed
  2325. * during initialization of the object.
  2326. *
  2327. * The function returns a new object whose properties and attributes are set as
  2328. * if constructed by an object literal assigning to each of the following
  2329. * properties the value of the corresponding internal property of this
  2330. * NumberFormat object (see 11.4): locale, numberingSystem, style, currency,
  2331. * currencyDisplay, minimumIntegerDigits, minimumFractionDigits,
  2332. * maximumFractionDigits, minimumSignificantDigits, maximumSignificantDigits, and
  2333. * useGrouping. Properties whose corresponding internal properties are not present
  2334. * are not assigned.
  2335. */
  2336. /* 11.3.3 */defineProperty(Intl.NumberFormat.prototype, 'resolvedOptions', {
  2337. configurable: true,
  2338. writable: true,
  2339. value: function value() {
  2340. var prop = void 0,
  2341. descs = new Record(),
  2342. props = ['locale', 'numberingSystem', 'style', 'currency', 'currencyDisplay', 'minimumIntegerDigits', 'minimumFractionDigits', 'maximumFractionDigits', 'minimumSignificantDigits', 'maximumSignificantDigits', 'useGrouping'],
  2343. internal = this !== null && babelHelpers$1["typeof"](this) === 'object' && getInternalProperties(this);
  2344. // Satisfy test 11.3_b
  2345. if (!internal || !internal['[[initializedNumberFormat]]']) throw new TypeError('`this` value for resolvedOptions() is not an initialized Intl.NumberFormat object.');
  2346. for (var i = 0, max = props.length; i < max; i++) {
  2347. if (hop.call(internal, prop = '[[' + props[i] + ']]')) descs[props[i]] = { value: internal[prop], writable: true, configurable: true, enumerable: true };
  2348. }
  2349. return objCreate({}, descs);
  2350. }
  2351. });
  2352. /* jslint esnext: true */
  2353. // Match these datetime components in a CLDR pattern, except those in single quotes
  2354. var expDTComponents = /(?:[Eec]{1,6}|G{1,5}|[Qq]{1,5}|(?:[yYur]+|U{1,5})|[ML]{1,5}|d{1,2}|D{1,3}|F{1}|[abB]{1,5}|[hkHK]{1,2}|w{1,2}|W{1}|m{1,2}|s{1,2}|[zZOvVxX]{1,4})(?=([^']*'[^']*')*[^']*$)/g;
  2355. // trim patterns after transformations
  2356. var expPatternTrimmer = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
  2357. // Skip over patterns with these datetime components because we don't have data
  2358. // to back them up:
  2359. // timezone, weekday, amoung others
  2360. var unwantedDTCs = /[rqQASjJgwWIQq]/; // xXVO were removed from this list in favor of computing matches with timeZoneName values but printing as empty string
  2361. var dtKeys = ["era", "year", "month", "day", "weekday", "quarter"];
  2362. var tmKeys = ["hour", "minute", "second", "hour12", "timeZoneName"];
  2363. function isDateFormatOnly(obj) {
  2364. for (var i = 0; i < tmKeys.length; i += 1) {
  2365. if (obj.hasOwnProperty(tmKeys[i])) {
  2366. return false;
  2367. }
  2368. }
  2369. return true;
  2370. }
  2371. function isTimeFormatOnly(obj) {
  2372. for (var i = 0; i < dtKeys.length; i += 1) {
  2373. if (obj.hasOwnProperty(dtKeys[i])) {
  2374. return false;
  2375. }
  2376. }
  2377. return true;
  2378. }
  2379. function joinDateAndTimeFormats(dateFormatObj, timeFormatObj) {
  2380. var o = { _: {} };
  2381. for (var i = 0; i < dtKeys.length; i += 1) {
  2382. if (dateFormatObj[dtKeys[i]]) {
  2383. o[dtKeys[i]] = dateFormatObj[dtKeys[i]];
  2384. }
  2385. if (dateFormatObj._[dtKeys[i]]) {
  2386. o._[dtKeys[i]] = dateFormatObj._[dtKeys[i]];
  2387. }
  2388. }
  2389. for (var j = 0; j < tmKeys.length; j += 1) {
  2390. if (timeFormatObj[tmKeys[j]]) {
  2391. o[tmKeys[j]] = timeFormatObj[tmKeys[j]];
  2392. }
  2393. if (timeFormatObj._[tmKeys[j]]) {
  2394. o._[tmKeys[j]] = timeFormatObj._[tmKeys[j]];
  2395. }
  2396. }
  2397. return o;
  2398. }
  2399. function computeFinalPatterns(formatObj) {
  2400. // From http://www.unicode.org/reports/tr35/tr35-dates.html#Date_Format_Patterns:
  2401. // 'In patterns, two single quotes represents a literal single quote, either
  2402. // inside or outside single quotes. Text within single quotes is not
  2403. // interpreted in any way (except for two adjacent single quotes).'
  2404. formatObj.pattern12 = formatObj.extendedPattern.replace(/'([^']*)'/g, function ($0, literal) {
  2405. return literal ? literal : "'";
  2406. });
  2407. // pattern 12 is always the default. we can produce the 24 by removing {ampm}
  2408. formatObj.pattern = formatObj.pattern12.replace('{ampm}', '').replace(expPatternTrimmer, '');
  2409. return formatObj;
  2410. }
  2411. function expDTComponentsMeta($0, formatObj) {
  2412. switch ($0.charAt(0)) {
  2413. // --- Era
  2414. case 'G':
  2415. formatObj.era = ['short', 'short', 'short', 'long', 'narrow'][$0.length - 1];
  2416. return '{era}';
  2417. // --- Year
  2418. case 'y':
  2419. case 'Y':
  2420. case 'u':
  2421. case 'U':
  2422. case 'r':
  2423. formatObj.year = $0.length === 2 ? '2-digit' : 'numeric';
  2424. return '{year}';
  2425. // --- Quarter (not supported in this polyfill)
  2426. case 'Q':
  2427. case 'q':
  2428. formatObj.quarter = ['numeric', '2-digit', 'short', 'long', 'narrow'][$0.length - 1];
  2429. return '{quarter}';
  2430. // --- Month
  2431. case 'M':
  2432. case 'L':
  2433. formatObj.month = ['numeric', '2-digit', 'short', 'long', 'narrow'][$0.length - 1];
  2434. return '{month}';
  2435. // --- Week (not supported in this polyfill)
  2436. case 'w':
  2437. // week of the year
  2438. formatObj.week = $0.length === 2 ? '2-digit' : 'numeric';
  2439. return '{weekday}';
  2440. case 'W':
  2441. // week of the month
  2442. formatObj.week = 'numeric';
  2443. return '{weekday}';
  2444. // --- Day
  2445. case 'd':
  2446. // day of the month
  2447. formatObj.day = $0.length === 2 ? '2-digit' : 'numeric';
  2448. return '{day}';
  2449. case 'D': // day of the year
  2450. case 'F': // day of the week
  2451. case 'g':
  2452. // 1..n: Modified Julian day
  2453. formatObj.day = 'numeric';
  2454. return '{day}';
  2455. // --- Week Day
  2456. case 'E':
  2457. // day of the week
  2458. formatObj.weekday = ['short', 'short', 'short', 'long', 'narrow', 'short'][$0.length - 1];
  2459. return '{weekday}';
  2460. case 'e':
  2461. // local day of the week
  2462. formatObj.weekday = ['numeric', '2-digit', 'short', 'long', 'narrow', 'short'][$0.length - 1];
  2463. return '{weekday}';
  2464. case 'c':
  2465. // stand alone local day of the week
  2466. formatObj.weekday = ['numeric', undefined, 'short', 'long', 'narrow', 'short'][$0.length - 1];
  2467. return '{weekday}';
  2468. // --- Period
  2469. case 'a': // AM, PM
  2470. case 'b': // am, pm, noon, midnight
  2471. case 'B':
  2472. // flexible day periods
  2473. formatObj.hour12 = true;
  2474. return '{ampm}';
  2475. // --- Hour
  2476. case 'h':
  2477. case 'H':
  2478. formatObj.hour = $0.length === 2 ? '2-digit' : 'numeric';
  2479. return '{hour}';
  2480. case 'k':
  2481. case 'K':
  2482. formatObj.hour12 = true; // 12-hour-cycle time formats (using h or K)
  2483. formatObj.hour = $0.length === 2 ? '2-digit' : 'numeric';
  2484. return '{hour}';
  2485. // --- Minute
  2486. case 'm':
  2487. formatObj.minute = $0.length === 2 ? '2-digit' : 'numeric';
  2488. return '{minute}';
  2489. // --- Second
  2490. case 's':
  2491. formatObj.second = $0.length === 2 ? '2-digit' : 'numeric';
  2492. return '{second}';
  2493. case 'S':
  2494. case 'A':
  2495. formatObj.second = 'numeric';
  2496. return '{second}';
  2497. // --- Timezone
  2498. case 'z': // 1..3, 4: specific non-location format
  2499. case 'Z': // 1..3, 4, 5: The ISO8601 varios formats
  2500. case 'O': // 1, 4: miliseconds in day short, long
  2501. case 'v': // 1, 4: generic non-location format
  2502. case 'V': // 1, 2, 3, 4: time zone ID or city
  2503. case 'X': // 1, 2, 3, 4: The ISO8601 varios formats
  2504. case 'x':
  2505. // 1, 2, 3, 4: The ISO8601 varios formats
  2506. // this polyfill only supports much, for now, we are just doing something dummy
  2507. formatObj.timeZoneName = $0.length < 4 ? 'short' : 'long';
  2508. return '{timeZoneName}';
  2509. }
  2510. }
  2511. /**
  2512. * Converts the CLDR availableFormats into the objects and patterns required by
  2513. * the ECMAScript Internationalization API specification.
  2514. */
  2515. function createDateTimeFormat(skeleton, pattern) {
  2516. // we ignore certain patterns that are unsupported to avoid this expensive op.
  2517. if (unwantedDTCs.test(pattern)) return undefined;
  2518. var formatObj = {
  2519. originalPattern: pattern,
  2520. _: {}
  2521. };
  2522. // Replace the pattern string with the one required by the specification, whilst
  2523. // at the same time evaluating it for the subsets and formats
  2524. formatObj.extendedPattern = pattern.replace(expDTComponents, function ($0) {
  2525. // See which symbol we're dealing with
  2526. return expDTComponentsMeta($0, formatObj._);
  2527. });
  2528. // Match the skeleton string with the one required by the specification
  2529. // this implementation is based on the Date Field Symbol Table:
  2530. // http://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
  2531. // Note: we are adding extra data to the formatObject even though this polyfill
  2532. // might not support it.
  2533. skeleton.replace(expDTComponents, function ($0) {
  2534. // See which symbol we're dealing with
  2535. return expDTComponentsMeta($0, formatObj);
  2536. });
  2537. return computeFinalPatterns(formatObj);
  2538. }
  2539. /**
  2540. * Processes DateTime formats from CLDR to an easier-to-parse format.
  2541. * the result of this operation should be cached the first time a particular
  2542. * calendar is analyzed.
  2543. *
  2544. * The specification requires we support at least the following subsets of
  2545. * date/time components:
  2546. *
  2547. * - 'weekday', 'year', 'month', 'day', 'hour', 'minute', 'second'
  2548. * - 'weekday', 'year', 'month', 'day'
  2549. * - 'year', 'month', 'day'
  2550. * - 'year', 'month'
  2551. * - 'month', 'day'
  2552. * - 'hour', 'minute', 'second'
  2553. * - 'hour', 'minute'
  2554. *
  2555. * We need to cherry pick at least these subsets from the CLDR data and convert
  2556. * them into the pattern objects used in the ECMA-402 API.
  2557. */
  2558. function createDateTimeFormats(formats) {
  2559. var availableFormats = formats.availableFormats;
  2560. var timeFormats = formats.timeFormats;
  2561. var dateFormats = formats.dateFormats;
  2562. var result = [];
  2563. var skeleton = void 0,
  2564. pattern = void 0,
  2565. computed = void 0,
  2566. i = void 0,
  2567. j = void 0;
  2568. var timeRelatedFormats = [];
  2569. var dateRelatedFormats = [];
  2570. // Map available (custom) formats into a pattern for createDateTimeFormats
  2571. for (skeleton in availableFormats) {
  2572. if (availableFormats.hasOwnProperty(skeleton)) {
  2573. pattern = availableFormats[skeleton];
  2574. computed = createDateTimeFormat(skeleton, pattern);
  2575. if (computed) {
  2576. result.push(computed);
  2577. // in some cases, the format is only displaying date specific props
  2578. // or time specific props, in which case we need to also produce the
  2579. // combined formats.
  2580. if (isDateFormatOnly(computed)) {
  2581. dateRelatedFormats.push(computed);
  2582. } else if (isTimeFormatOnly(computed)) {
  2583. timeRelatedFormats.push(computed);
  2584. }
  2585. }
  2586. }
  2587. }
  2588. // Map time formats into a pattern for createDateTimeFormats
  2589. for (skeleton in timeFormats) {
  2590. if (timeFormats.hasOwnProperty(skeleton)) {
  2591. pattern = timeFormats[skeleton];
  2592. computed = createDateTimeFormat(skeleton, pattern);
  2593. if (computed) {
  2594. result.push(computed);
  2595. timeRelatedFormats.push(computed);
  2596. }
  2597. }
  2598. }
  2599. // Map date formats into a pattern for createDateTimeFormats
  2600. for (skeleton in dateFormats) {
  2601. if (dateFormats.hasOwnProperty(skeleton)) {
  2602. pattern = dateFormats[skeleton];
  2603. computed = createDateTimeFormat(skeleton, pattern);
  2604. if (computed) {
  2605. result.push(computed);
  2606. dateRelatedFormats.push(computed);
  2607. }
  2608. }
  2609. }
  2610. // combine custom time and custom date formats when they are orthogonals to complete the
  2611. // formats supported by CLDR.
  2612. // This Algo is based on section "Missing Skeleton Fields" from:
  2613. // http://unicode.org/reports/tr35/tr35-dates.html#availableFormats_appendItems
  2614. for (i = 0; i < timeRelatedFormats.length; i += 1) {
  2615. for (j = 0; j < dateRelatedFormats.length; j += 1) {
  2616. if (dateRelatedFormats[j].month === 'long') {
  2617. pattern = dateRelatedFormats[j].weekday ? formats.full : formats.long;
  2618. } else if (dateRelatedFormats[j].month === 'short') {
  2619. pattern = formats.medium;
  2620. } else {
  2621. pattern = formats.short;
  2622. }
  2623. computed = joinDateAndTimeFormats(dateRelatedFormats[j], timeRelatedFormats[i]);
  2624. computed.originalPattern = pattern;
  2625. computed.extendedPattern = pattern.replace('{0}', timeRelatedFormats[i].extendedPattern).replace('{1}', dateRelatedFormats[j].extendedPattern).replace(/^[,\s]+|[,\s]+$/gi, '');
  2626. result.push(computeFinalPatterns(computed));
  2627. }
  2628. }
  2629. return result;
  2630. }
  2631. // this represents the exceptions of the rule that are not covered by CLDR availableFormats
  2632. // for single property configurations, they play no role when using multiple properties, and
  2633. // those that are not in this table, are not exceptions or are not covered by the data we
  2634. // provide.
  2635. var validSyntheticProps = {
  2636. second: {
  2637. numeric: 's',
  2638. '2-digit': 'ss'
  2639. },
  2640. minute: {
  2641. numeric: 'm',
  2642. '2-digit': 'mm'
  2643. },
  2644. year: {
  2645. numeric: 'y',
  2646. '2-digit': 'yy'
  2647. },
  2648. day: {
  2649. numeric: 'd',
  2650. '2-digit': 'dd'
  2651. },
  2652. month: {
  2653. numeric: 'L',
  2654. '2-digit': 'LL',
  2655. narrow: 'LLLLL',
  2656. short: 'LLL',
  2657. long: 'LLLL'
  2658. },
  2659. weekday: {
  2660. narrow: 'ccccc',
  2661. short: 'ccc',
  2662. long: 'cccc'
  2663. }
  2664. };
  2665. function generateSyntheticFormat(propName, propValue) {
  2666. if (validSyntheticProps[propName] && validSyntheticProps[propName][propValue]) {
  2667. var _ref2;
  2668. return _ref2 = {
  2669. originalPattern: validSyntheticProps[propName][propValue],
  2670. _: defineProperty$1({}, propName, propValue),
  2671. extendedPattern: "{" + propName + "}"
  2672. }, defineProperty$1(_ref2, propName, propValue), defineProperty$1(_ref2, "pattern12", "{" + propName + "}"), defineProperty$1(_ref2, "pattern", "{" + propName + "}"), _ref2;
  2673. }
  2674. }
  2675. // An object map of date component keys, saves using a regex later
  2676. var dateWidths = objCreate(null, { narrow: {}, short: {}, long: {} });
  2677. /**
  2678. * Returns a string for a date component, resolved using multiple inheritance as specified
  2679. * as specified in the Unicode Technical Standard 35.
  2680. */
  2681. function resolveDateString(data, ca, component, width, key) {
  2682. // From http://www.unicode.org/reports/tr35/tr35.html#Multiple_Inheritance:
  2683. // 'In clearly specified instances, resources may inherit from within the same locale.
  2684. // For example, ... the Buddhist calendar inherits from the Gregorian calendar.'
  2685. var obj = data[ca] && data[ca][component] ? data[ca][component] : data.gregory[component],
  2686. // "sideways" inheritance resolves strings when a key doesn't exist
  2687. alts = {
  2688. narrow: ['short', 'long'],
  2689. short: ['long', 'narrow'],
  2690. long: ['short', 'narrow']
  2691. },
  2692. //
  2693. resolved = hop.call(obj, width) ? obj[width] : hop.call(obj, alts[width][0]) ? obj[alts[width][0]] : obj[alts[width][1]];
  2694. // `key` wouldn't be specified for components 'dayPeriods'
  2695. return key !== null ? resolved[key] : resolved;
  2696. }
  2697. // Define the DateTimeFormat constructor internally so it cannot be tainted
  2698. function DateTimeFormatConstructor() {
  2699. var locales = arguments[0];
  2700. var options = arguments[1];
  2701. if (!this || this === Intl) {
  2702. return new Intl.DateTimeFormat(locales, options);
  2703. }
  2704. return InitializeDateTimeFormat(toObject(this), locales, options);
  2705. }
  2706. defineProperty(Intl, 'DateTimeFormat', {
  2707. configurable: true,
  2708. writable: true,
  2709. value: DateTimeFormatConstructor
  2710. });
  2711. // Must explicitly set prototypes as unwritable
  2712. defineProperty(DateTimeFormatConstructor, 'prototype', {
  2713. writable: false
  2714. });
  2715. /**
  2716. * The abstract operation InitializeDateTimeFormat accepts the arguments dateTimeFormat
  2717. * (which must be an object), locales, and options. It initializes dateTimeFormat as a
  2718. * DateTimeFormat object.
  2719. */
  2720. function /* 12.1.1.1 */InitializeDateTimeFormat(dateTimeFormat, locales, options) {
  2721. // This will be a internal properties object if we're not already initialized
  2722. var internal = getInternalProperties(dateTimeFormat);
  2723. // Create an object whose props can be used to restore the values of RegExp props
  2724. var regexpRestore = createRegExpRestore();
  2725. // 1. If dateTimeFormat has an [[initializedIntlObject]] internal property with
  2726. // value true, throw a TypeError exception.
  2727. if (internal['[[initializedIntlObject]]'] === true) throw new TypeError('`this` object has already been initialized as an Intl object');
  2728. // Need this to access the `internal` object
  2729. defineProperty(dateTimeFormat, '__getInternalProperties', {
  2730. value: function value() {
  2731. // NOTE: Non-standard, for internal use only
  2732. if (arguments[0] === secret) return internal;
  2733. }
  2734. });
  2735. // 2. Set the [[initializedIntlObject]] internal property of numberFormat to true.
  2736. internal['[[initializedIntlObject]]'] = true;
  2737. // 3. Let requestedLocales be the result of calling the CanonicalizeLocaleList
  2738. // abstract operation (defined in 9.2.1) with argument locales.
  2739. var requestedLocales = CanonicalizeLocaleList(locales);
  2740. // 4. Let options be the result of calling the ToDateTimeOptions abstract
  2741. // operation (defined below) with arguments options, "any", and "date".
  2742. options = ToDateTimeOptions(options, 'any', 'date');
  2743. // 5. Let opt be a new Record.
  2744. var opt = new Record();
  2745. // 6. Let matcher be the result of calling the GetOption abstract operation
  2746. // (defined in 9.2.9) with arguments options, "localeMatcher", "string", a List
  2747. // containing the two String values "lookup" and "best fit", and "best fit".
  2748. var matcher = GetOption(options, 'localeMatcher', 'string', new List('lookup', 'best fit'), 'best fit');
  2749. // 7. Set opt.[[localeMatcher]] to matcher.
  2750. opt['[[localeMatcher]]'] = matcher;
  2751. // 8. Let DateTimeFormat be the standard built-in object that is the initial
  2752. // value of Intl.DateTimeFormat.
  2753. var DateTimeFormat = internals.DateTimeFormat; // This is what we *really* need
  2754. // 9. Let localeData be the value of the [[localeData]] internal property of
  2755. // DateTimeFormat.
  2756. var localeData = DateTimeFormat['[[localeData]]'];
  2757. // 10. Let r be the result of calling the ResolveLocale abstract operation
  2758. // (defined in 9.2.5) with the [[availableLocales]] internal property of
  2759. // DateTimeFormat, requestedLocales, opt, the [[relevantExtensionKeys]]
  2760. // internal property of DateTimeFormat, and localeData.
  2761. var r = ResolveLocale(DateTimeFormat['[[availableLocales]]'], requestedLocales, opt, DateTimeFormat['[[relevantExtensionKeys]]'], localeData);
  2762. // 11. Set the [[locale]] internal property of dateTimeFormat to the value of
  2763. // r.[[locale]].
  2764. internal['[[locale]]'] = r['[[locale]]'];
  2765. // 12. Set the [[calendar]] internal property of dateTimeFormat to the value of
  2766. // r.[[ca]].
  2767. internal['[[calendar]]'] = r['[[ca]]'];
  2768. // 13. Set the [[numberingSystem]] internal property of dateTimeFormat to the value of
  2769. // r.[[nu]].
  2770. internal['[[numberingSystem]]'] = r['[[nu]]'];
  2771. // The specification doesn't tell us to do this, but it's helpful later on
  2772. internal['[[dataLocale]]'] = r['[[dataLocale]]'];
  2773. // 14. Let dataLocale be the value of r.[[dataLocale]].
  2774. var dataLocale = r['[[dataLocale]]'];
  2775. // 15. Let tz be the result of calling the [[Get]] internal method of options with
  2776. // argument "timeZone".
  2777. var tz = options.timeZone;
  2778. // 16. If tz is not undefined, then
  2779. if (tz !== undefined) {
  2780. // a. Let tz be ToString(tz).
  2781. // b. Convert tz to upper case as described in 6.1.
  2782. // NOTE: If an implementation accepts additional time zone values, as permitted
  2783. // under certain conditions by the Conformance clause, different casing
  2784. // rules apply.
  2785. tz = toLatinUpperCase(tz);
  2786. // c. If tz is not "UTC", then throw a RangeError exception.
  2787. // ###TODO: accept more time zones###
  2788. if (tz !== 'UTC') throw new RangeError('timeZone is not supported.');
  2789. }
  2790. // 17. Set the [[timeZone]] internal property of dateTimeFormat to tz.
  2791. internal['[[timeZone]]'] = tz;
  2792. // 18. Let opt be a new Record.
  2793. opt = new Record();
  2794. // 19. For each row of Table 3, except the header row, do:
  2795. for (var prop in dateTimeComponents) {
  2796. if (!hop.call(dateTimeComponents, prop)) continue;
  2797. // 20. Let prop be the name given in the Property column of the row.
  2798. // 21. Let value be the result of calling the GetOption abstract operation,
  2799. // passing as argument options, the name given in the Property column of the
  2800. // row, "string", a List containing the strings given in the Values column of
  2801. // the row, and undefined.
  2802. var value = GetOption(options, prop, 'string', dateTimeComponents[prop]);
  2803. // 22. Set opt.[[<prop>]] to value.
  2804. opt['[[' + prop + ']]'] = value;
  2805. }
  2806. // Assigned a value below
  2807. var bestFormat = void 0;
  2808. // 23. Let dataLocaleData be the result of calling the [[Get]] internal method of
  2809. // localeData with argument dataLocale.
  2810. var dataLocaleData = localeData[dataLocale];
  2811. // 24. Let formats be the result of calling the [[Get]] internal method of
  2812. // dataLocaleData with argument "formats".
  2813. // Note: we process the CLDR formats into the spec'd structure
  2814. var formats = ToDateTimeFormats(dataLocaleData.formats);
  2815. // 25. Let matcher be the result of calling the GetOption abstract operation with
  2816. // arguments options, "formatMatcher", "string", a List containing the two String
  2817. // values "basic" and "best fit", and "best fit".
  2818. matcher = GetOption(options, 'formatMatcher', 'string', new List('basic', 'best fit'), 'best fit');
  2819. // Optimization: caching the processed formats as a one time operation by
  2820. // replacing the initial structure from localeData
  2821. dataLocaleData.formats = formats;
  2822. // 26. If matcher is "basic", then
  2823. if (matcher === 'basic') {
  2824. // 27. Let bestFormat be the result of calling the BasicFormatMatcher abstract
  2825. // operation (defined below) with opt and formats.
  2826. bestFormat = BasicFormatMatcher(opt, formats);
  2827. // 28. Else
  2828. } else {
  2829. {
  2830. // diverging
  2831. var _hr = GetOption(options, 'hour12', 'boolean' /*, undefined, undefined*/);
  2832. opt.hour12 = _hr === undefined ? dataLocaleData.hour12 : _hr;
  2833. }
  2834. // 29. Let bestFormat be the result of calling the BestFitFormatMatcher
  2835. // abstract operation (defined below) with opt and formats.
  2836. bestFormat = BestFitFormatMatcher(opt, formats);
  2837. }
  2838. // 30. For each row in Table 3, except the header row, do
  2839. for (var _prop in dateTimeComponents) {
  2840. if (!hop.call(dateTimeComponents, _prop)) continue;
  2841. // a. Let prop be the name given in the Property column of the row.
  2842. // b. Let pDesc be the result of calling the [[GetOwnProperty]] internal method of
  2843. // bestFormat with argument prop.
  2844. // c. If pDesc is not undefined, then
  2845. if (hop.call(bestFormat, _prop)) {
  2846. // i. Let p be the result of calling the [[Get]] internal method of bestFormat
  2847. // with argument prop.
  2848. var p = bestFormat[_prop];
  2849. {
  2850. // diverging
  2851. p = bestFormat._ && hop.call(bestFormat._, _prop) ? bestFormat._[_prop] : p;
  2852. }
  2853. // ii. Set the [[<prop>]] internal property of dateTimeFormat to p.
  2854. internal['[[' + _prop + ']]'] = p;
  2855. }
  2856. }
  2857. var pattern = void 0; // Assigned a value below
  2858. // 31. Let hr12 be the result of calling the GetOption abstract operation with
  2859. // arguments options, "hour12", "boolean", undefined, and undefined.
  2860. var hr12 = GetOption(options, 'hour12', 'boolean' /*, undefined, undefined*/);
  2861. // 32. If dateTimeFormat has an internal property [[hour]], then
  2862. if (internal['[[hour]]']) {
  2863. // a. If hr12 is undefined, then let hr12 be the result of calling the [[Get]]
  2864. // internal method of dataLocaleData with argument "hour12".
  2865. hr12 = hr12 === undefined ? dataLocaleData.hour12 : hr12;
  2866. // b. Set the [[hour12]] internal property of dateTimeFormat to hr12.
  2867. internal['[[hour12]]'] = hr12;
  2868. // c. If hr12 is true, then
  2869. if (hr12 === true) {
  2870. // i. Let hourNo0 be the result of calling the [[Get]] internal method of
  2871. // dataLocaleData with argument "hourNo0".
  2872. var hourNo0 = dataLocaleData.hourNo0;
  2873. // ii. Set the [[hourNo0]] internal property of dateTimeFormat to hourNo0.
  2874. internal['[[hourNo0]]'] = hourNo0;
  2875. // iii. Let pattern be the result of calling the [[Get]] internal method of
  2876. // bestFormat with argument "pattern12".
  2877. pattern = bestFormat.pattern12;
  2878. }
  2879. // d. Else
  2880. else
  2881. // i. Let pattern be the result of calling the [[Get]] internal method of
  2882. // bestFormat with argument "pattern".
  2883. pattern = bestFormat.pattern;
  2884. }
  2885. // 33. Else
  2886. else
  2887. // a. Let pattern be the result of calling the [[Get]] internal method of
  2888. // bestFormat with argument "pattern".
  2889. pattern = bestFormat.pattern;
  2890. // 34. Set the [[pattern]] internal property of dateTimeFormat to pattern.
  2891. internal['[[pattern]]'] = pattern;
  2892. // 35. Set the [[boundFormat]] internal property of dateTimeFormat to undefined.
  2893. internal['[[boundFormat]]'] = undefined;
  2894. // 36. Set the [[initializedDateTimeFormat]] internal property of dateTimeFormat to
  2895. // true.
  2896. internal['[[initializedDateTimeFormat]]'] = true;
  2897. // In ES3, we need to pre-bind the format() function
  2898. if (es3) dateTimeFormat.format = GetFormatDateTime.call(dateTimeFormat);
  2899. // Restore the RegExp properties
  2900. regexpRestore();
  2901. // Return the newly initialised object
  2902. return dateTimeFormat;
  2903. }
  2904. /**
  2905. * Several DateTimeFormat algorithms use values from the following table, which provides
  2906. * property names and allowable values for the components of date and time formats:
  2907. */
  2908. var dateTimeComponents = {
  2909. weekday: ["narrow", "short", "long"],
  2910. era: ["narrow", "short", "long"],
  2911. year: ["2-digit", "numeric"],
  2912. month: ["2-digit", "numeric", "narrow", "short", "long"],
  2913. day: ["2-digit", "numeric"],
  2914. hour: ["2-digit", "numeric"],
  2915. minute: ["2-digit", "numeric"],
  2916. second: ["2-digit", "numeric"],
  2917. timeZoneName: ["short", "long"]
  2918. };
  2919. /**
  2920. * When the ToDateTimeOptions abstract operation is called with arguments options,
  2921. * required, and defaults, the following steps are taken:
  2922. */
  2923. function ToDateTimeFormats(formats) {
  2924. if (Object.prototype.toString.call(formats) === '[object Array]') {
  2925. return formats;
  2926. }
  2927. return createDateTimeFormats(formats);
  2928. }
  2929. /**
  2930. * When the ToDateTimeOptions abstract operation is called with arguments options,
  2931. * required, and defaults, the following steps are taken:
  2932. */
  2933. function ToDateTimeOptions(options, required, defaults) {
  2934. // 1. If options is undefined, then let options be null, else let options be
  2935. // ToObject(options).
  2936. if (options === undefined) options = null;else {
  2937. // (#12) options needs to be a Record, but it also needs to inherit properties
  2938. var opt2 = toObject(options);
  2939. options = new Record();
  2940. for (var k in opt2) {
  2941. options[k] = opt2[k];
  2942. }
  2943. }
  2944. // 2. Let create be the standard built-in function object defined in ES5, 15.2.3.5.
  2945. var create = objCreate;
  2946. // 3. Let options be the result of calling the [[Call]] internal method of create with
  2947. // undefined as the this value and an argument list containing the single item
  2948. // options.
  2949. options = create(options);
  2950. // 4. Let needDefaults be true.
  2951. var needDefaults = true;
  2952. // 5. If required is "date" or "any", then
  2953. if (required === 'date' || required === 'any') {
  2954. // a. For each of the property names "weekday", "year", "month", "day":
  2955. // i. If the result of calling the [[Get]] internal method of options with the
  2956. // property name is not undefined, then let needDefaults be false.
  2957. if (options.weekday !== undefined || options.year !== undefined || options.month !== undefined || options.day !== undefined) needDefaults = false;
  2958. }
  2959. // 6. If required is "time" or "any", then
  2960. if (required === 'time' || required === 'any') {
  2961. // a. For each of the property names "hour", "minute", "second":
  2962. // i. If the result of calling the [[Get]] internal method of options with the
  2963. // property name is not undefined, then let needDefaults be false.
  2964. if (options.hour !== undefined || options.minute !== undefined || options.second !== undefined) needDefaults = false;
  2965. }
  2966. // 7. If needDefaults is true and defaults is either "date" or "all", then
  2967. if (needDefaults && (defaults === 'date' || defaults === 'all'))
  2968. // a. For each of the property names "year", "month", "day":
  2969. // i. Call the [[DefineOwnProperty]] internal method of options with the
  2970. // property name, Property Descriptor {[[Value]]: "numeric", [[Writable]]:
  2971. // true, [[Enumerable]]: true, [[Configurable]]: true}, and false.
  2972. options.year = options.month = options.day = 'numeric';
  2973. // 8. If needDefaults is true and defaults is either "time" or "all", then
  2974. if (needDefaults && (defaults === 'time' || defaults === 'all'))
  2975. // a. For each of the property names "hour", "minute", "second":
  2976. // i. Call the [[DefineOwnProperty]] internal method of options with the
  2977. // property name, Property Descriptor {[[Value]]: "numeric", [[Writable]]:
  2978. // true, [[Enumerable]]: true, [[Configurable]]: true}, and false.
  2979. options.hour = options.minute = options.second = 'numeric';
  2980. // 9. Return options.
  2981. return options;
  2982. }
  2983. /**
  2984. * When the BasicFormatMatcher abstract operation is called with two arguments options and
  2985. * formats, the following steps are taken:
  2986. */
  2987. function BasicFormatMatcher(options, formats) {
  2988. // 1. Let removalPenalty be 120.
  2989. var removalPenalty = 120;
  2990. // 2. Let additionPenalty be 20.
  2991. var additionPenalty = 20;
  2992. // 3. Let longLessPenalty be 8.
  2993. var longLessPenalty = 8;
  2994. // 4. Let longMorePenalty be 6.
  2995. var longMorePenalty = 6;
  2996. // 5. Let shortLessPenalty be 6.
  2997. var shortLessPenalty = 6;
  2998. // 6. Let shortMorePenalty be 3.
  2999. var shortMorePenalty = 3;
  3000. // 7. Let bestScore be -Infinity.
  3001. var bestScore = -Infinity;
  3002. // 8. Let bestFormat be undefined.
  3003. var bestFormat = void 0;
  3004. // 9. Let i be 0.
  3005. var i = 0;
  3006. // 10. Assert: formats is an Array object.
  3007. // 11. Let len be the result of calling the [[Get]] internal method of formats with argument "length".
  3008. var len = formats.length;
  3009. // 12. Repeat while i < len:
  3010. while (i < len) {
  3011. // a. Let format be the result of calling the [[Get]] internal method of formats with argument ToString(i).
  3012. var format = formats[i];
  3013. // b. Let score be 0.
  3014. var score = 0;
  3015. // c. For each property shown in Table 3:
  3016. for (var property in dateTimeComponents) {
  3017. if (!hop.call(dateTimeComponents, property)) continue;
  3018. // i. Let optionsProp be options.[[<property>]].
  3019. var optionsProp = options['[[' + property + ']]'];
  3020. // ii. Let formatPropDesc be the result of calling the [[GetOwnProperty]] internal method of format
  3021. // with argument property.
  3022. // iii. If formatPropDesc is not undefined, then
  3023. // 1. Let formatProp be the result of calling the [[Get]] internal method of format with argument property.
  3024. var formatProp = hop.call(format, property) ? format[property] : undefined;
  3025. // iv. If optionsProp is undefined and formatProp is not undefined, then decrease score by
  3026. // additionPenalty.
  3027. if (optionsProp === undefined && formatProp !== undefined) score -= additionPenalty;
  3028. // v. Else if optionsProp is not undefined and formatProp is undefined, then decrease score by
  3029. // removalPenalty.
  3030. else if (optionsProp !== undefined && formatProp === undefined) score -= removalPenalty;
  3031. // vi. Else
  3032. else {
  3033. // 1. Let values be the array ["2-digit", "numeric", "narrow", "short",
  3034. // "long"].
  3035. var values = ['2-digit', 'numeric', 'narrow', 'short', 'long'];
  3036. // 2. Let optionsPropIndex be the index of optionsProp within values.
  3037. var optionsPropIndex = arrIndexOf.call(values, optionsProp);
  3038. // 3. Let formatPropIndex be the index of formatProp within values.
  3039. var formatPropIndex = arrIndexOf.call(values, formatProp);
  3040. // 4. Let delta be max(min(formatPropIndex - optionsPropIndex, 2), -2).
  3041. var delta = Math.max(Math.min(formatPropIndex - optionsPropIndex, 2), -2);
  3042. // 5. If delta = 2, decrease score by longMorePenalty.
  3043. if (delta === 2) score -= longMorePenalty;
  3044. // 6. Else if delta = 1, decrease score by shortMorePenalty.
  3045. else if (delta === 1) score -= shortMorePenalty;
  3046. // 7. Else if delta = -1, decrease score by shortLessPenalty.
  3047. else if (delta === -1) score -= shortLessPenalty;
  3048. // 8. Else if delta = -2, decrease score by longLessPenalty.
  3049. else if (delta === -2) score -= longLessPenalty;
  3050. }
  3051. }
  3052. // d. If score > bestScore, then
  3053. if (score > bestScore) {
  3054. // i. Let bestScore be score.
  3055. bestScore = score;
  3056. // ii. Let bestFormat be format.
  3057. bestFormat = format;
  3058. }
  3059. // e. Increase i by 1.
  3060. i++;
  3061. }
  3062. // 13. Return bestFormat.
  3063. return bestFormat;
  3064. }
  3065. /**
  3066. * When the BestFitFormatMatcher abstract operation is called with two arguments options
  3067. * and formats, it performs implementation dependent steps, which should return a set of
  3068. * component representations that a typical user of the selected locale would perceive as
  3069. * at least as good as the one returned by BasicFormatMatcher.
  3070. *
  3071. * This polyfill defines the algorithm to be the same as BasicFormatMatcher,
  3072. * with the addition of bonus points awarded where the requested format is of
  3073. * the same data type as the potentially matching format.
  3074. *
  3075. * This algo relies on the concept of closest distance matching described here:
  3076. * http://unicode.org/reports/tr35/tr35-dates.html#Matching_Skeletons
  3077. * Typically a “best match” is found using a closest distance match, such as:
  3078. *
  3079. * Symbols requesting a best choice for the locale are replaced.
  3080. * j → one of {H, k, h, K}; C → one of {a, b, B}
  3081. * -> Covered by cldr.js matching process
  3082. *
  3083. * For fields with symbols representing the same type (year, month, day, etc):
  3084. * Most symbols have a small distance from each other.
  3085. * M ≅ L; E ≅ c; a ≅ b ≅ B; H ≅ k ≅ h ≅ K; ...
  3086. * -> Covered by cldr.js matching process
  3087. *
  3088. * Width differences among fields, other than those marking text vs numeric, are given small distance from each other.
  3089. * MMM ≅ MMMM
  3090. * MM ≅ M
  3091. * Numeric and text fields are given a larger distance from each other.
  3092. * MMM ≈ MM
  3093. * Symbols representing substantial differences (week of year vs week of month) are given much larger a distances from each other.
  3094. * d ≋ D; ...
  3095. * Missing or extra fields cause a match to fail. (But see Missing Skeleton Fields).
  3096. *
  3097. *
  3098. * For example,
  3099. *
  3100. * { month: 'numeric', day: 'numeric' }
  3101. *
  3102. * should match
  3103. *
  3104. * { month: '2-digit', day: '2-digit' }
  3105. *
  3106. * rather than
  3107. *
  3108. * { month: 'short', day: 'numeric' }
  3109. *
  3110. * This makes sense because a user requesting a formatted date with numeric parts would
  3111. * not expect to see the returned format containing narrow, short or long part names
  3112. */
  3113. function BestFitFormatMatcher(options, formats) {
  3114. /** Diverging: this block implements the hack for single property configuration, eg.:
  3115. *
  3116. * `new Intl.DateTimeFormat('en', {day: 'numeric'})`
  3117. *
  3118. * should produce a single digit with the day of the month. This is needed because
  3119. * CLDR `availableFormats` data structure doesn't cover these cases.
  3120. */
  3121. {
  3122. var optionsPropNames = [];
  3123. for (var property in dateTimeComponents) {
  3124. if (!hop.call(dateTimeComponents, property)) continue;
  3125. if (options['[[' + property + ']]'] !== undefined) {
  3126. optionsPropNames.push(property);
  3127. }
  3128. }
  3129. if (optionsPropNames.length === 1) {
  3130. var _bestFormat = generateSyntheticFormat(optionsPropNames[0], options['[[' + optionsPropNames[0] + ']]']);
  3131. if (_bestFormat) {
  3132. return _bestFormat;
  3133. }
  3134. }
  3135. }
  3136. // 1. Let removalPenalty be 120.
  3137. var removalPenalty = 120;
  3138. // 2. Let additionPenalty be 20.
  3139. var additionPenalty = 20;
  3140. // 3. Let longLessPenalty be 8.
  3141. var longLessPenalty = 8;
  3142. // 4. Let longMorePenalty be 6.
  3143. var longMorePenalty = 6;
  3144. // 5. Let shortLessPenalty be 6.
  3145. var shortLessPenalty = 6;
  3146. // 6. Let shortMorePenalty be 3.
  3147. var shortMorePenalty = 3;
  3148. var patternPenalty = 2;
  3149. var hour12Penalty = 1;
  3150. // 7. Let bestScore be -Infinity.
  3151. var bestScore = -Infinity;
  3152. // 8. Let bestFormat be undefined.
  3153. var bestFormat = void 0;
  3154. // 9. Let i be 0.
  3155. var i = 0;
  3156. // 10. Assert: formats is an Array object.
  3157. // 11. Let len be the result of calling the [[Get]] internal method of formats with argument "length".
  3158. var len = formats.length;
  3159. // 12. Repeat while i < len:
  3160. while (i < len) {
  3161. // a. Let format be the result of calling the [[Get]] internal method of formats with argument ToString(i).
  3162. var format = formats[i];
  3163. // b. Let score be 0.
  3164. var score = 0;
  3165. // c. For each property shown in Table 3:
  3166. for (var _property in dateTimeComponents) {
  3167. if (!hop.call(dateTimeComponents, _property)) continue;
  3168. // i. Let optionsProp be options.[[<property>]].
  3169. var optionsProp = options['[[' + _property + ']]'];
  3170. // ii. Let formatPropDesc be the result of calling the [[GetOwnProperty]] internal method of format
  3171. // with argument property.
  3172. // iii. If formatPropDesc is not undefined, then
  3173. // 1. Let formatProp be the result of calling the [[Get]] internal method of format with argument property.
  3174. var formatProp = hop.call(format, _property) ? format[_property] : undefined;
  3175. // Diverging: using the default properties produced by the pattern/skeleton
  3176. // to match it with user options, and apply a penalty
  3177. var patternProp = hop.call(format._, _property) ? format._[_property] : undefined;
  3178. if (optionsProp !== patternProp) {
  3179. score -= patternPenalty;
  3180. }
  3181. // iv. If optionsProp is undefined and formatProp is not undefined, then decrease score by
  3182. // additionPenalty.
  3183. if (optionsProp === undefined && formatProp !== undefined) score -= additionPenalty;
  3184. // v. Else if optionsProp is not undefined and formatProp is undefined, then decrease score by
  3185. // removalPenalty.
  3186. else if (optionsProp !== undefined && formatProp === undefined) score -= removalPenalty;
  3187. // vi. Else
  3188. else {
  3189. // 1. Let values be the array ["2-digit", "numeric", "narrow", "short",
  3190. // "long"].
  3191. var values = ['2-digit', 'numeric', 'narrow', 'short', 'long'];
  3192. // 2. Let optionsPropIndex be the index of optionsProp within values.
  3193. var optionsPropIndex = arrIndexOf.call(values, optionsProp);
  3194. // 3. Let formatPropIndex be the index of formatProp within values.
  3195. var formatPropIndex = arrIndexOf.call(values, formatProp);
  3196. // 4. Let delta be max(min(formatPropIndex - optionsPropIndex, 2), -2).
  3197. var delta = Math.max(Math.min(formatPropIndex - optionsPropIndex, 2), -2);
  3198. {
  3199. // diverging from spec
  3200. // When the bestFit argument is true, subtract additional penalty where data types are not the same
  3201. if (formatPropIndex <= 1 && optionsPropIndex >= 2 || formatPropIndex >= 2 && optionsPropIndex <= 1) {
  3202. // 5. If delta = 2, decrease score by longMorePenalty.
  3203. if (delta > 0) score -= longMorePenalty;else if (delta < 0) score -= longLessPenalty;
  3204. } else {
  3205. // 5. If delta = 2, decrease score by longMorePenalty.
  3206. if (delta > 1) score -= shortMorePenalty;else if (delta < -1) score -= shortLessPenalty;
  3207. }
  3208. }
  3209. }
  3210. }
  3211. {
  3212. // diverging to also take into consideration differences between 12 or 24 hours
  3213. // which is special for the best fit only.
  3214. if (format._.hour12 !== options.hour12) {
  3215. score -= hour12Penalty;
  3216. }
  3217. }
  3218. // d. If score > bestScore, then
  3219. if (score > bestScore) {
  3220. // i. Let bestScore be score.
  3221. bestScore = score;
  3222. // ii. Let bestFormat be format.
  3223. bestFormat = format;
  3224. }
  3225. // e. Increase i by 1.
  3226. i++;
  3227. }
  3228. // 13. Return bestFormat.
  3229. return bestFormat;
  3230. }
  3231. /* 12.2.3 */internals.DateTimeFormat = {
  3232. '[[availableLocales]]': [],
  3233. '[[relevantExtensionKeys]]': ['ca', 'nu'],
  3234. '[[localeData]]': {}
  3235. };
  3236. /**
  3237. * When the supportedLocalesOf method of Intl.DateTimeFormat is called, the
  3238. * following steps are taken:
  3239. */
  3240. /* 12.2.2 */
  3241. defineProperty(Intl.DateTimeFormat, 'supportedLocalesOf', {
  3242. configurable: true,
  3243. writable: true,
  3244. value: fnBind.call(function (locales) {
  3245. // Bound functions only have the `this` value altered if being used as a constructor,
  3246. // this lets us imitate a native function that has no constructor
  3247. if (!hop.call(this, '[[availableLocales]]')) throw new TypeError('supportedLocalesOf() is not a constructor');
  3248. // Create an object whose props can be used to restore the values of RegExp props
  3249. var regexpRestore = createRegExpRestore(),
  3250. // 1. If options is not provided, then let options be undefined.
  3251. options = arguments[1],
  3252. // 2. Let availableLocales be the value of the [[availableLocales]] internal
  3253. // property of the standard built-in object that is the initial value of
  3254. // Intl.NumberFormat.
  3255. availableLocales = this['[[availableLocales]]'],
  3256. // 3. Let requestedLocales be the result of calling the CanonicalizeLocaleList
  3257. // abstract operation (defined in 9.2.1) with argument locales.
  3258. requestedLocales = CanonicalizeLocaleList(locales);
  3259. // Restore the RegExp properties
  3260. regexpRestore();
  3261. // 4. Return the result of calling the SupportedLocales abstract operation
  3262. // (defined in 9.2.8) with arguments availableLocales, requestedLocales,
  3263. // and options.
  3264. return SupportedLocales(availableLocales, requestedLocales, options);
  3265. }, internals.NumberFormat)
  3266. });
  3267. /**
  3268. * This named accessor property returns a function that formats a number
  3269. * according to the effective locale and the formatting options of this
  3270. * DateTimeFormat object.
  3271. */
  3272. /* 12.3.2 */defineProperty(Intl.DateTimeFormat.prototype, 'format', {
  3273. configurable: true,
  3274. get: GetFormatDateTime
  3275. });
  3276. function GetFormatDateTime() {
  3277. var internal = this !== null && babelHelpers$1["typeof"](this) === 'object' && getInternalProperties(this);
  3278. // Satisfy test 12.3_b
  3279. if (!internal || !internal['[[initializedDateTimeFormat]]']) throw new TypeError('`this` value for format() is not an initialized Intl.DateTimeFormat object.');
  3280. // The value of the [[Get]] attribute is a function that takes the following
  3281. // steps:
  3282. // 1. If the [[boundFormat]] internal property of this DateTimeFormat object
  3283. // is undefined, then:
  3284. if (internal['[[boundFormat]]'] === undefined) {
  3285. // a. Let F be a Function object, with internal properties set as
  3286. // specified for built-in functions in ES5, 15, or successor, and the
  3287. // length property set to 0, that takes the argument date and
  3288. // performs the following steps:
  3289. var F = function F() {
  3290. var date = arguments.length <= 0 || arguments[0] === undefined ? undefined : arguments[0];
  3291. // i. If date is not provided or is undefined, then let x be the
  3292. // result as if by the expression Date.now() where Date.now is
  3293. // the standard built-in function defined in ES5, 15.9.4.4.
  3294. // ii. Else let x be ToNumber(date).
  3295. // iii. Return the result of calling the FormatDateTime abstract
  3296. // operation (defined below) with arguments this and x.
  3297. var x = date === undefined ? Date.now() : toNumber(date);
  3298. return FormatDateTime(this, x);
  3299. };
  3300. // b. Let bind be the standard built-in function object defined in ES5,
  3301. // 15.3.4.5.
  3302. // c. Let bf be the result of calling the [[Call]] internal method of
  3303. // bind with F as the this value and an argument list containing
  3304. // the single item this.
  3305. var bf = fnBind.call(F, this);
  3306. // d. Set the [[boundFormat]] internal property of this NumberFormat
  3307. // object to bf.
  3308. internal['[[boundFormat]]'] = bf;
  3309. }
  3310. // Return the value of the [[boundFormat]] internal property of this
  3311. // NumberFormat object.
  3312. return internal['[[boundFormat]]'];
  3313. }
  3314. function formatToParts$1() {
  3315. var date = arguments.length <= 0 || arguments[0] === undefined ? undefined : arguments[0];
  3316. var internal = this !== null && babelHelpers$1["typeof"](this) === 'object' && getInternalProperties(this);
  3317. if (!internal || !internal['[[initializedDateTimeFormat]]']) throw new TypeError('`this` value for formatToParts() is not an initialized Intl.DateTimeFormat object.');
  3318. var x = date === undefined ? Date.now() : toNumber(date);
  3319. return FormatToPartsDateTime(this, x);
  3320. }
  3321. Object.defineProperty(Intl.DateTimeFormat.prototype, 'formatToParts', {
  3322. enumerable: false,
  3323. writable: true,
  3324. configurable: true,
  3325. value: formatToParts$1
  3326. });
  3327. function CreateDateTimeParts(dateTimeFormat, x) {
  3328. // 1. If x is not a finite Number, then throw a RangeError exception.
  3329. if (!isFinite(x)) throw new RangeError('Invalid valid date passed to format');
  3330. var internal = dateTimeFormat.__getInternalProperties(secret);
  3331. // Creating restore point for properties on the RegExp object... please wait
  3332. /* let regexpRestore = */createRegExpRestore(); // ###TODO: review this
  3333. // 2. Let locale be the value of the [[locale]] internal property of dateTimeFormat.
  3334. var locale = internal['[[locale]]'];
  3335. // 3. Let nf be the result of creating a new NumberFormat object as if by the
  3336. // expression new Intl.NumberFormat([locale], {useGrouping: false}) where
  3337. // Intl.NumberFormat is the standard built-in constructor defined in 11.1.3.
  3338. var nf = new Intl.NumberFormat([locale], { useGrouping: false });
  3339. // 4. Let nf2 be the result of creating a new NumberFormat object as if by the
  3340. // expression new Intl.NumberFormat([locale], {minimumIntegerDigits: 2, useGrouping:
  3341. // false}) where Intl.NumberFormat is the standard built-in constructor defined in
  3342. // 11.1.3.
  3343. var nf2 = new Intl.NumberFormat([locale], { minimumIntegerDigits: 2, useGrouping: false });
  3344. // 5. Let tm be the result of calling the ToLocalTime abstract operation (defined
  3345. // below) with x, the value of the [[calendar]] internal property of dateTimeFormat,
  3346. // and the value of the [[timeZone]] internal property of dateTimeFormat.
  3347. var tm = ToLocalTime(x, internal['[[calendar]]'], internal['[[timeZone]]']);
  3348. // 6. Let result be the value of the [[pattern]] internal property of dateTimeFormat.
  3349. var pattern = internal['[[pattern]]'];
  3350. // 7.
  3351. var result = new List();
  3352. // 8.
  3353. var index = 0;
  3354. // 9.
  3355. var beginIndex = pattern.indexOf('{');
  3356. // 10.
  3357. var endIndex = 0;
  3358. // Need the locale minus any extensions
  3359. var dataLocale = internal['[[dataLocale]]'];
  3360. // Need the calendar data from CLDR
  3361. var localeData = internals.DateTimeFormat['[[localeData]]'][dataLocale].calendars;
  3362. var ca = internal['[[calendar]]'];
  3363. // 11.
  3364. while (beginIndex !== -1) {
  3365. var fv = void 0;
  3366. // a.
  3367. endIndex = pattern.indexOf('}', beginIndex);
  3368. // b.
  3369. if (endIndex === -1) {
  3370. throw new Error('Unclosed pattern');
  3371. }
  3372. // c.
  3373. if (beginIndex > index) {
  3374. arrPush.call(result, {
  3375. type: 'literal',
  3376. value: pattern.substring(index, beginIndex)
  3377. });
  3378. }
  3379. // d.
  3380. var p = pattern.substring(beginIndex + 1, endIndex);
  3381. // e.
  3382. if (dateTimeComponents.hasOwnProperty(p)) {
  3383. // i. Let f be the value of the [[<p>]] internal property of dateTimeFormat.
  3384. var f = internal['[[' + p + ']]'];
  3385. // ii. Let v be the value of tm.[[<p>]].
  3386. var v = tm['[[' + p + ']]'];
  3387. // iii. If p is "year" and v ≤ 0, then let v be 1 - v.
  3388. if (p === 'year' && v <= 0) {
  3389. v = 1 - v;
  3390. }
  3391. // iv. If p is "month", then increase v by 1.
  3392. else if (p === 'month') {
  3393. v++;
  3394. }
  3395. // v. If p is "hour" and the value of the [[hour12]] internal property of
  3396. // dateTimeFormat is true, then
  3397. else if (p === 'hour' && internal['[[hour12]]'] === true) {
  3398. // 1. Let v be v modulo 12.
  3399. v = v % 12;
  3400. // 2. If v is 0 and the value of the [[hourNo0]] internal property of
  3401. // dateTimeFormat is true, then let v be 12.
  3402. if (v === 0 && internal['[[hourNo0]]'] === true) {
  3403. v = 12;
  3404. }
  3405. }
  3406. // vi. If f is "numeric", then
  3407. if (f === 'numeric') {
  3408. // 1. Let fv be the result of calling the FormatNumber abstract operation
  3409. // (defined in 11.3.2) with arguments nf and v.
  3410. fv = FormatNumber(nf, v);
  3411. }
  3412. // vii. Else if f is "2-digit", then
  3413. else if (f === '2-digit') {
  3414. // 1. Let fv be the result of calling the FormatNumber abstract operation
  3415. // with arguments nf2 and v.
  3416. fv = FormatNumber(nf2, v);
  3417. // 2. If the length of fv is greater than 2, let fv be the substring of fv
  3418. // containing the last two characters.
  3419. if (fv.length > 2) {
  3420. fv = fv.slice(-2);
  3421. }
  3422. }
  3423. // viii. Else if f is "narrow", "short", or "long", then let fv be a String
  3424. // value representing f in the desired form; the String value depends upon
  3425. // the implementation and the effective locale and calendar of
  3426. // dateTimeFormat. If p is "month", then the String value may also depend
  3427. // on whether dateTimeFormat has a [[day]] internal property. If p is
  3428. // "timeZoneName", then the String value may also depend on the value of
  3429. // the [[inDST]] field of tm.
  3430. else if (f in dateWidths) {
  3431. switch (p) {
  3432. case 'month':
  3433. fv = resolveDateString(localeData, ca, 'months', f, tm['[[' + p + ']]']);
  3434. break;
  3435. case 'weekday':
  3436. try {
  3437. fv = resolveDateString(localeData, ca, 'days', f, tm['[[' + p + ']]']);
  3438. // fv = resolveDateString(ca.days, f)[tm['[['+ p +']]']];
  3439. } catch (e) {
  3440. throw new Error('Could not find weekday data for locale ' + locale);
  3441. }
  3442. break;
  3443. case 'timeZoneName':
  3444. fv = ''; // ###TODO
  3445. break;
  3446. case 'era':
  3447. try {
  3448. fv = resolveDateString(localeData, ca, 'eras', f, tm['[[' + p + ']]']);
  3449. } catch (e) {
  3450. throw new Error('Could not find era data for locale ' + locale);
  3451. }
  3452. break;
  3453. default:
  3454. fv = tm['[[' + p + ']]'];
  3455. }
  3456. }
  3457. // ix
  3458. arrPush.call(result, {
  3459. type: p,
  3460. value: fv
  3461. });
  3462. // f.
  3463. } else if (p === 'ampm') {
  3464. // i.
  3465. var _v = tm['[[hour]]'];
  3466. // ii./iii.
  3467. fv = resolveDateString(localeData, ca, 'dayPeriods', _v > 11 ? 'pm' : 'am', null);
  3468. // iv.
  3469. arrPush.call(result, {
  3470. type: 'dayPeriod',
  3471. value: fv
  3472. });
  3473. // g.
  3474. } else {
  3475. arrPush.call(result, {
  3476. type: 'literal',
  3477. value: pattern.substring(beginIndex, endIndex + 1)
  3478. });
  3479. }
  3480. // h.
  3481. index = endIndex + 1;
  3482. // i.
  3483. beginIndex = pattern.indexOf('{', index);
  3484. }
  3485. // 12.
  3486. if (endIndex < pattern.length - 1) {
  3487. arrPush.call(result, {
  3488. type: 'literal',
  3489. value: pattern.substr(endIndex + 1)
  3490. });
  3491. }
  3492. // 13.
  3493. return result;
  3494. }
  3495. /**
  3496. * When the FormatDateTime abstract operation is called with arguments dateTimeFormat
  3497. * (which must be an object initialized as a DateTimeFormat) and x (which must be a Number
  3498. * value), it returns a String value representing x (interpreted as a time value as
  3499. * specified in ES5, 15.9.1.1) according to the effective locale and the formatting
  3500. * options of dateTimeFormat.
  3501. */
  3502. function FormatDateTime(dateTimeFormat, x) {
  3503. var parts = CreateDateTimeParts(dateTimeFormat, x);
  3504. var result = '';
  3505. for (var i = 0; parts.length > i; i++) {
  3506. var part = parts[i];
  3507. result += part.value;
  3508. }
  3509. return result;
  3510. }
  3511. function FormatToPartsDateTime(dateTimeFormat, x) {
  3512. var parts = CreateDateTimeParts(dateTimeFormat, x);
  3513. var result = [];
  3514. for (var i = 0; parts.length > i; i++) {
  3515. var part = parts[i];
  3516. result.push({
  3517. type: part.type,
  3518. value: part.value
  3519. });
  3520. }
  3521. return result;
  3522. }
  3523. /**
  3524. * When the ToLocalTime abstract operation is called with arguments date, calendar, and
  3525. * timeZone, the following steps are taken:
  3526. */
  3527. function ToLocalTime(date, calendar, timeZone) {
  3528. // 1. Apply calendrical calculations on date for the given calendar and time zone to
  3529. // produce weekday, era, year, month, day, hour, minute, second, and inDST values.
  3530. // The calculations should use best available information about the specified
  3531. // calendar and time zone. If the calendar is "gregory", then the calculations must
  3532. // match the algorithms specified in ES5, 15.9.1, except that calculations are not
  3533. // bound by the restrictions on the use of best available information on time zones
  3534. // for local time zone adjustment and daylight saving time adjustment imposed by
  3535. // ES5, 15.9.1.7 and 15.9.1.8.
  3536. // ###TODO###
  3537. var d = new Date(date),
  3538. m = 'get' + (timeZone || '');
  3539. // 2. Return a Record with fields [[weekday]], [[era]], [[year]], [[month]], [[day]],
  3540. // [[hour]], [[minute]], [[second]], and [[inDST]], each with the corresponding
  3541. // calculated value.
  3542. return new Record({
  3543. '[[weekday]]': d[m + 'Day'](),
  3544. '[[era]]': +(d[m + 'FullYear']() >= 0),
  3545. '[[year]]': d[m + 'FullYear'](),
  3546. '[[month]]': d[m + 'Month'](),
  3547. '[[day]]': d[m + 'Date'](),
  3548. '[[hour]]': d[m + 'Hours'](),
  3549. '[[minute]]': d[m + 'Minutes'](),
  3550. '[[second]]': d[m + 'Seconds'](),
  3551. '[[inDST]]': false // ###TODO###
  3552. });
  3553. }
  3554. /**
  3555. * The function returns a new object whose properties and attributes are set as if
  3556. * constructed by an object literal assigning to each of the following properties the
  3557. * value of the corresponding internal property of this DateTimeFormat object (see 12.4):
  3558. * locale, calendar, numberingSystem, timeZone, hour12, weekday, era, year, month, day,
  3559. * hour, minute, second, and timeZoneName. Properties whose corresponding internal
  3560. * properties are not present are not assigned.
  3561. */
  3562. /* 12.3.3 */defineProperty(Intl.DateTimeFormat.prototype, 'resolvedOptions', {
  3563. writable: true,
  3564. configurable: true,
  3565. value: function value() {
  3566. var prop = void 0,
  3567. descs = new Record(),
  3568. props = ['locale', 'calendar', 'numberingSystem', 'timeZone', 'hour12', 'weekday', 'era', 'year', 'month', 'day', 'hour', 'minute', 'second', 'timeZoneName'],
  3569. internal = this !== null && babelHelpers$1["typeof"](this) === 'object' && getInternalProperties(this);
  3570. // Satisfy test 12.3_b
  3571. if (!internal || !internal['[[initializedDateTimeFormat]]']) throw new TypeError('`this` value for resolvedOptions() is not an initialized Intl.DateTimeFormat object.');
  3572. for (var i = 0, max = props.length; i < max; i++) {
  3573. if (hop.call(internal, prop = '[[' + props[i] + ']]')) descs[props[i]] = { value: internal[prop], writable: true, configurable: true, enumerable: true };
  3574. }
  3575. return objCreate({}, descs);
  3576. }
  3577. });
  3578. var ls = Intl.__localeSensitiveProtos = {
  3579. Number: {},
  3580. Date: {}
  3581. };
  3582. /**
  3583. * When the toLocaleString method is called with optional arguments locales and options,
  3584. * the following steps are taken:
  3585. */
  3586. /* 13.2.1 */ls.Number.toLocaleString = function () {
  3587. // Satisfy test 13.2.1_1
  3588. if (Object.prototype.toString.call(this) !== '[object Number]') throw new TypeError('`this` value must be a number for Number.prototype.toLocaleString()');
  3589. // 1. Let x be this Number value (as defined in ES5, 15.7.4).
  3590. // 2. If locales is not provided, then let locales be undefined.
  3591. // 3. If options is not provided, then let options be undefined.
  3592. // 4. Let numberFormat be the result of creating a new object as if by the
  3593. // expression new Intl.NumberFormat(locales, options) where
  3594. // Intl.NumberFormat is the standard built-in constructor defined in 11.1.3.
  3595. // 5. Return the result of calling the FormatNumber abstract operation
  3596. // (defined in 11.3.2) with arguments numberFormat and x.
  3597. return FormatNumber(new NumberFormatConstructor(arguments[0], arguments[1]), this);
  3598. };
  3599. /**
  3600. * When the toLocaleString method is called with optional arguments locales and options,
  3601. * the following steps are taken:
  3602. */
  3603. /* 13.3.1 */ls.Date.toLocaleString = function () {
  3604. // Satisfy test 13.3.0_1
  3605. if (Object.prototype.toString.call(this) !== '[object Date]') throw new TypeError('`this` value must be a Date instance for Date.prototype.toLocaleString()');
  3606. // 1. Let x be this time value (as defined in ES5, 15.9.5).
  3607. var x = +this;
  3608. // 2. If x is NaN, then return "Invalid Date".
  3609. if (isNaN(x)) return 'Invalid Date';
  3610. // 3. If locales is not provided, then let locales be undefined.
  3611. var locales = arguments[0];
  3612. // 4. If options is not provided, then let options be undefined.
  3613. var options = arguments[1];
  3614. // 5. Let options be the result of calling the ToDateTimeOptions abstract
  3615. // operation (defined in 12.1.1) with arguments options, "any", and "all".
  3616. options = ToDateTimeOptions(options, 'any', 'all');
  3617. // 6. Let dateTimeFormat be the result of creating a new object as if by the
  3618. // expression new Intl.DateTimeFormat(locales, options) where
  3619. // Intl.DateTimeFormat is the standard built-in constructor defined in 12.1.3.
  3620. var dateTimeFormat = new DateTimeFormatConstructor(locales, options);
  3621. // 7. Return the result of calling the FormatDateTime abstract operation (defined
  3622. // in 12.3.2) with arguments dateTimeFormat and x.
  3623. return FormatDateTime(dateTimeFormat, x);
  3624. };
  3625. /**
  3626. * When the toLocaleDateString method is called with optional arguments locales and
  3627. * options, the following steps are taken:
  3628. */
  3629. /* 13.3.2 */ls.Date.toLocaleDateString = function () {
  3630. // Satisfy test 13.3.0_1
  3631. if (Object.prototype.toString.call(this) !== '[object Date]') throw new TypeError('`this` value must be a Date instance for Date.prototype.toLocaleDateString()');
  3632. // 1. Let x be this time value (as defined in ES5, 15.9.5).
  3633. var x = +this;
  3634. // 2. If x is NaN, then return "Invalid Date".
  3635. if (isNaN(x)) return 'Invalid Date';
  3636. // 3. If locales is not provided, then let locales be undefined.
  3637. var locales = arguments[0],
  3638. // 4. If options is not provided, then let options be undefined.
  3639. options = arguments[1];
  3640. // 5. Let options be the result of calling the ToDateTimeOptions abstract
  3641. // operation (defined in 12.1.1) with arguments options, "date", and "date".
  3642. options = ToDateTimeOptions(options, 'date', 'date');
  3643. // 6. Let dateTimeFormat be the result of creating a new object as if by the
  3644. // expression new Intl.DateTimeFormat(locales, options) where
  3645. // Intl.DateTimeFormat is the standard built-in constructor defined in 12.1.3.
  3646. var dateTimeFormat = new DateTimeFormatConstructor(locales, options);
  3647. // 7. Return the result of calling the FormatDateTime abstract operation (defined
  3648. // in 12.3.2) with arguments dateTimeFormat and x.
  3649. return FormatDateTime(dateTimeFormat, x);
  3650. };
  3651. /**
  3652. * When the toLocaleTimeString method is called with optional arguments locales and
  3653. * options, the following steps are taken:
  3654. */
  3655. /* 13.3.3 */ls.Date.toLocaleTimeString = function () {
  3656. // Satisfy test 13.3.0_1
  3657. if (Object.prototype.toString.call(this) !== '[object Date]') throw new TypeError('`this` value must be a Date instance for Date.prototype.toLocaleTimeString()');
  3658. // 1. Let x be this time value (as defined in ES5, 15.9.5).
  3659. var x = +this;
  3660. // 2. If x is NaN, then return "Invalid Date".
  3661. if (isNaN(x)) return 'Invalid Date';
  3662. // 3. If locales is not provided, then let locales be undefined.
  3663. var locales = arguments[0];
  3664. // 4. If options is not provided, then let options be undefined.
  3665. var options = arguments[1];
  3666. // 5. Let options be the result of calling the ToDateTimeOptions abstract
  3667. // operation (defined in 12.1.1) with arguments options, "time", and "time".
  3668. options = ToDateTimeOptions(options, 'time', 'time');
  3669. // 6. Let dateTimeFormat be the result of creating a new object as if by the
  3670. // expression new Intl.DateTimeFormat(locales, options) where
  3671. // Intl.DateTimeFormat is the standard built-in constructor defined in 12.1.3.
  3672. var dateTimeFormat = new DateTimeFormatConstructor(locales, options);
  3673. // 7. Return the result of calling the FormatDateTime abstract operation (defined
  3674. // in 12.3.2) with arguments dateTimeFormat and x.
  3675. return FormatDateTime(dateTimeFormat, x);
  3676. };
  3677. defineProperty(Intl, '__applyLocaleSensitivePrototypes', {
  3678. writable: true,
  3679. configurable: true,
  3680. value: function value() {
  3681. defineProperty(Number.prototype, 'toLocaleString', { writable: true, configurable: true, value: ls.Number.toLocaleString });
  3682. // Need this here for IE 8, to avoid the _DontEnum_ bug
  3683. defineProperty(Date.prototype, 'toLocaleString', { writable: true, configurable: true, value: ls.Date.toLocaleString });
  3684. for (var k in ls.Date) {
  3685. if (hop.call(ls.Date, k)) defineProperty(Date.prototype, k, { writable: true, configurable: true, value: ls.Date[k] });
  3686. }
  3687. }
  3688. });
  3689. /**
  3690. * Can't really ship a single script with data for hundreds of locales, so we provide
  3691. * this __addLocaleData method as a means for the developer to add the data on an
  3692. * as-needed basis
  3693. */
  3694. defineProperty(Intl, '__addLocaleData', {
  3695. value: function value(data) {
  3696. if (!IsStructurallyValidLanguageTag(data.locale)) throw new Error("Object passed doesn't identify itself with a valid language tag");
  3697. addLocaleData(data, data.locale);
  3698. }
  3699. });
  3700. function addLocaleData(data, tag) {
  3701. // Both NumberFormat and DateTimeFormat require number data, so throw if it isn't present
  3702. if (!data.number) throw new Error("Object passed doesn't contain locale data for Intl.NumberFormat");
  3703. var locale = void 0,
  3704. locales = [tag],
  3705. parts = tag.split('-');
  3706. // Create fallbacks for locale data with scripts, e.g. Latn, Hans, Vaii, etc
  3707. if (parts.length > 2 && parts[1].length === 4) arrPush.call(locales, parts[0] + '-' + parts[2]);
  3708. while (locale = arrShift.call(locales)) {
  3709. // Add to NumberFormat internal properties as per 11.2.3
  3710. arrPush.call(internals.NumberFormat['[[availableLocales]]'], locale);
  3711. internals.NumberFormat['[[localeData]]'][locale] = data.number;
  3712. // ...and DateTimeFormat internal properties as per 12.2.3
  3713. if (data.date) {
  3714. data.date.nu = data.number.nu;
  3715. arrPush.call(internals.DateTimeFormat['[[availableLocales]]'], locale);
  3716. internals.DateTimeFormat['[[localeData]]'][locale] = data.date;
  3717. }
  3718. }
  3719. // If this is the first set of locale data added, make it the default
  3720. if (defaultLocale === undefined) setDefaultLocale(tag);
  3721. }
  3722. defineProperty(Intl, '__disableRegExpRestore', {
  3723. value: function value() {
  3724. internals.disableRegExpRestore = true;
  3725. }
  3726. });
  3727. module.exports = Intl;