Geen omschrijving

index.js 84KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var styleInject_es = require('./style-inject.es-7b2c2b1b.js');
  4. require('react');
  5. require('./index-671ea010.js');
  6. require('./test-f419c2cb.js');
  7. var index$1 = require('./index-fe1b29d9.js');
  8. /*
  9. Copyright (c) 2014, Yahoo! Inc. All rights reserved.
  10. Copyrights licensed under the New BSD License.
  11. See the accompanying LICENSE file for terms.
  12. */
  13. var extend_1 = extend;
  14. var hop = Object.prototype.hasOwnProperty;
  15. function extend(obj) {
  16. var sources = Array.prototype.slice.call(arguments, 1),
  17. i, len, source, key;
  18. for (i = 0, len = sources.length; i < len; i += 1) {
  19. source = sources[i];
  20. if (!source) { continue; }
  21. for (key in source) {
  22. if (hop.call(source, key)) {
  23. obj[key] = source[key];
  24. }
  25. }
  26. }
  27. return obj;
  28. }
  29. var hop_1 = hop;
  30. var utils = {
  31. extend: extend_1,
  32. hop: hop_1
  33. };
  34. var es5 = styleInject_es.createCommonjsModule(function (module, exports) {
  35. // Purposely using the same implementation as the Intl.js `Intl` polyfill.
  36. // Copyright 2013 Andy Earnshaw, MIT License
  37. var realDefineProp = (function () {
  38. try { return !!Object.defineProperty({}, 'a', {}); }
  39. catch (e) { return false; }
  40. })();
  41. var defineProperty = realDefineProp ? Object.defineProperty :
  42. function (obj, name, desc) {
  43. if ('get' in desc && obj.__defineGetter__) {
  44. obj.__defineGetter__(name, desc.get);
  45. } else if (!utils.hop.call(obj, name) || 'value' in desc) {
  46. obj[name] = desc.value;
  47. }
  48. };
  49. var objCreate = Object.create || function (proto, props) {
  50. var obj, k;
  51. function F() {}
  52. F.prototype = proto;
  53. obj = new F();
  54. for (k in props) {
  55. if (utils.hop.call(props, k)) {
  56. defineProperty(obj, k, props[k]);
  57. }
  58. }
  59. return obj;
  60. };
  61. exports.defineProperty = defineProperty, exports.objCreate = objCreate;
  62. });
  63. var es5_1 = es5.defineProperty;
  64. var es5_2 = es5.objCreate;
  65. var compiler = styleInject_es.createCommonjsModule(function (module, exports) {
  66. exports["default"] = Compiler;
  67. function Compiler(locales, formats, pluralFn) {
  68. this.locales = locales;
  69. this.formats = formats;
  70. this.pluralFn = pluralFn;
  71. }
  72. Compiler.prototype.compile = function (ast) {
  73. this.pluralStack = [];
  74. this.currentPlural = null;
  75. this.pluralNumberFormat = null;
  76. return this.compileMessage(ast);
  77. };
  78. Compiler.prototype.compileMessage = function (ast) {
  79. if (!(ast && ast.type === 'messageFormatPattern')) {
  80. throw new Error('Message AST is not of type: "messageFormatPattern"');
  81. }
  82. var elements = ast.elements,
  83. pattern = [];
  84. var i, len, element;
  85. for (i = 0, len = elements.length; i < len; i += 1) {
  86. element = elements[i];
  87. switch (element.type) {
  88. case 'messageTextElement':
  89. pattern.push(this.compileMessageText(element));
  90. break;
  91. case 'argumentElement':
  92. pattern.push(this.compileArgument(element));
  93. break;
  94. default:
  95. throw new Error('Message element does not have a valid type');
  96. }
  97. }
  98. return pattern;
  99. };
  100. Compiler.prototype.compileMessageText = function (element) {
  101. // When this `element` is part of plural sub-pattern and its value contains
  102. // an unescaped '#', use a `PluralOffsetString` helper to properly output
  103. // the number with the correct offset in the string.
  104. if (this.currentPlural && /(^|[^\\])#/g.test(element.value)) {
  105. // Create a cache a NumberFormat instance that can be reused for any
  106. // PluralOffsetString instance in this message.
  107. if (!this.pluralNumberFormat) {
  108. this.pluralNumberFormat = new Intl.NumberFormat(this.locales);
  109. }
  110. return new PluralOffsetString(
  111. this.currentPlural.id,
  112. this.currentPlural.format.offset,
  113. this.pluralNumberFormat,
  114. element.value);
  115. }
  116. // Unescape the escaped '#'s in the message text.
  117. return element.value.replace(/\\#/g, '#');
  118. };
  119. Compiler.prototype.compileArgument = function (element) {
  120. var format = element.format;
  121. if (!format) {
  122. return new StringFormat(element.id);
  123. }
  124. var formats = this.formats,
  125. locales = this.locales,
  126. pluralFn = this.pluralFn,
  127. options;
  128. switch (format.type) {
  129. case 'numberFormat':
  130. options = formats.number[format.style];
  131. return {
  132. id : element.id,
  133. format: new Intl.NumberFormat(locales, options).format
  134. };
  135. case 'dateFormat':
  136. options = formats.date[format.style];
  137. return {
  138. id : element.id,
  139. format: new Intl.DateTimeFormat(locales, options).format
  140. };
  141. case 'timeFormat':
  142. options = formats.time[format.style];
  143. return {
  144. id : element.id,
  145. format: new Intl.DateTimeFormat(locales, options).format
  146. };
  147. case 'pluralFormat':
  148. options = this.compileOptions(element);
  149. return new PluralFormat(
  150. element.id, format.ordinal, format.offset, options, pluralFn
  151. );
  152. case 'selectFormat':
  153. options = this.compileOptions(element);
  154. return new SelectFormat(element.id, options);
  155. default:
  156. throw new Error('Message element does not have a valid format type');
  157. }
  158. };
  159. Compiler.prototype.compileOptions = function (element) {
  160. var format = element.format,
  161. options = format.options,
  162. optionsHash = {};
  163. // Save the current plural element, if any, then set it to a new value when
  164. // compiling the options sub-patterns. This conforms the spec's algorithm
  165. // for handling `"#"` syntax in message text.
  166. this.pluralStack.push(this.currentPlural);
  167. this.currentPlural = format.type === 'pluralFormat' ? element : null;
  168. var i, len, option;
  169. for (i = 0, len = options.length; i < len; i += 1) {
  170. option = options[i];
  171. // Compile the sub-pattern and save it under the options's selector.
  172. optionsHash[option.selector] = this.compileMessage(option.value);
  173. }
  174. // Pop the plural stack to put back the original current plural value.
  175. this.currentPlural = this.pluralStack.pop();
  176. return optionsHash;
  177. };
  178. // -- Compiler Helper Classes --------------------------------------------------
  179. function StringFormat(id) {
  180. this.id = id;
  181. }
  182. StringFormat.prototype.format = function (value) {
  183. if (!value && typeof value !== 'number') {
  184. return '';
  185. }
  186. return typeof value === 'string' ? value : String(value);
  187. };
  188. function PluralFormat(id, useOrdinal, offset, options, pluralFn) {
  189. this.id = id;
  190. this.useOrdinal = useOrdinal;
  191. this.offset = offset;
  192. this.options = options;
  193. this.pluralFn = pluralFn;
  194. }
  195. PluralFormat.prototype.getOption = function (value) {
  196. var options = this.options;
  197. var option = options['=' + value] ||
  198. options[this.pluralFn(value - this.offset, this.useOrdinal)];
  199. return option || options.other;
  200. };
  201. function PluralOffsetString(id, offset, numberFormat, string) {
  202. this.id = id;
  203. this.offset = offset;
  204. this.numberFormat = numberFormat;
  205. this.string = string;
  206. }
  207. PluralOffsetString.prototype.format = function (value) {
  208. var number = this.numberFormat.format(value - this.offset);
  209. return this.string
  210. .replace(/(^|[^\\])#/g, '$1' + number)
  211. .replace(/\\#/g, '#');
  212. };
  213. function SelectFormat(id, options) {
  214. this.id = id;
  215. this.options = options;
  216. }
  217. SelectFormat.prototype.getOption = function (value) {
  218. var options = this.options;
  219. return options[value] || options.other;
  220. };
  221. });
  222. var parser = styleInject_es.createCommonjsModule(function (module, exports) {
  223. exports["default"] = (function() {
  224. /*
  225. * Generated by PEG.js 0.9.0.
  226. *
  227. * http://pegjs.org/
  228. */
  229. function peg$subclass(child, parent) {
  230. function ctor() { this.constructor = child; }
  231. ctor.prototype = parent.prototype;
  232. child.prototype = new ctor();
  233. }
  234. function peg$SyntaxError(message, expected, found, location) {
  235. this.message = message;
  236. this.expected = expected;
  237. this.found = found;
  238. this.location = location;
  239. this.name = "SyntaxError";
  240. if (typeof Error.captureStackTrace === "function") {
  241. Error.captureStackTrace(this, peg$SyntaxError);
  242. }
  243. }
  244. peg$subclass(peg$SyntaxError, Error);
  245. function peg$parse(input) {
  246. var options = arguments.length > 1 ? arguments[1] : {},
  247. peg$FAILED = {},
  248. peg$startRuleFunctions = { start: peg$parsestart },
  249. peg$startRuleFunction = peg$parsestart,
  250. peg$c0 = function(elements) {
  251. return {
  252. type : 'messageFormatPattern',
  253. elements: elements,
  254. location: location()
  255. };
  256. },
  257. peg$c1 = function(text) {
  258. var string = '',
  259. i, j, outerLen, inner, innerLen;
  260. for (i = 0, outerLen = text.length; i < outerLen; i += 1) {
  261. inner = text[i];
  262. for (j = 0, innerLen = inner.length; j < innerLen; j += 1) {
  263. string += inner[j];
  264. }
  265. }
  266. return string;
  267. },
  268. peg$c2 = function(messageText) {
  269. return {
  270. type : 'messageTextElement',
  271. value: messageText,
  272. location: location()
  273. };
  274. },
  275. peg$c3 = /^[^ \t\n\r,.+={}#]/,
  276. peg$c4 = { type: "class", value: "[^ \\t\\n\\r,.+={}#]", description: "[^ \\t\\n\\r,.+={}#]" },
  277. peg$c5 = "{",
  278. peg$c6 = { type: "literal", value: "{", description: "\"{\"" },
  279. peg$c7 = ",",
  280. peg$c8 = { type: "literal", value: ",", description: "\",\"" },
  281. peg$c9 = "}",
  282. peg$c10 = { type: "literal", value: "}", description: "\"}\"" },
  283. peg$c11 = function(id, format) {
  284. return {
  285. type : 'argumentElement',
  286. id : id,
  287. format: format && format[2],
  288. location: location()
  289. };
  290. },
  291. peg$c12 = "number",
  292. peg$c13 = { type: "literal", value: "number", description: "\"number\"" },
  293. peg$c14 = "date",
  294. peg$c15 = { type: "literal", value: "date", description: "\"date\"" },
  295. peg$c16 = "time",
  296. peg$c17 = { type: "literal", value: "time", description: "\"time\"" },
  297. peg$c18 = function(type, style) {
  298. return {
  299. type : type + 'Format',
  300. style: style && style[2],
  301. location: location()
  302. };
  303. },
  304. peg$c19 = "plural",
  305. peg$c20 = { type: "literal", value: "plural", description: "\"plural\"" },
  306. peg$c21 = function(pluralStyle) {
  307. return {
  308. type : pluralStyle.type,
  309. ordinal: false,
  310. offset : pluralStyle.offset || 0,
  311. options: pluralStyle.options,
  312. location: location()
  313. };
  314. },
  315. peg$c22 = "selectordinal",
  316. peg$c23 = { type: "literal", value: "selectordinal", description: "\"selectordinal\"" },
  317. peg$c24 = function(pluralStyle) {
  318. return {
  319. type : pluralStyle.type,
  320. ordinal: true,
  321. offset : pluralStyle.offset || 0,
  322. options: pluralStyle.options,
  323. location: location()
  324. }
  325. },
  326. peg$c25 = "select",
  327. peg$c26 = { type: "literal", value: "select", description: "\"select\"" },
  328. peg$c27 = function(options) {
  329. return {
  330. type : 'selectFormat',
  331. options: options,
  332. location: location()
  333. };
  334. },
  335. peg$c28 = "=",
  336. peg$c29 = { type: "literal", value: "=", description: "\"=\"" },
  337. peg$c30 = function(selector, pattern) {
  338. return {
  339. type : 'optionalFormatPattern',
  340. selector: selector,
  341. value : pattern,
  342. location: location()
  343. };
  344. },
  345. peg$c31 = "offset:",
  346. peg$c32 = { type: "literal", value: "offset:", description: "\"offset:\"" },
  347. peg$c33 = function(number) {
  348. return number;
  349. },
  350. peg$c34 = function(offset, options) {
  351. return {
  352. type : 'pluralFormat',
  353. offset : offset,
  354. options: options,
  355. location: location()
  356. };
  357. },
  358. peg$c35 = { type: "other", description: "whitespace" },
  359. peg$c36 = /^[ \t\n\r]/,
  360. peg$c37 = { type: "class", value: "[ \\t\\n\\r]", description: "[ \\t\\n\\r]" },
  361. peg$c38 = { type: "other", description: "optionalWhitespace" },
  362. peg$c39 = /^[0-9]/,
  363. peg$c40 = { type: "class", value: "[0-9]", description: "[0-9]" },
  364. peg$c41 = /^[0-9a-f]/i,
  365. peg$c42 = { type: "class", value: "[0-9a-f]i", description: "[0-9a-f]i" },
  366. peg$c43 = "0",
  367. peg$c44 = { type: "literal", value: "0", description: "\"0\"" },
  368. peg$c45 = /^[1-9]/,
  369. peg$c46 = { type: "class", value: "[1-9]", description: "[1-9]" },
  370. peg$c47 = function(digits) {
  371. return parseInt(digits, 10);
  372. },
  373. peg$c48 = /^[^{}\\\0-\x1F \t\n\r]/,
  374. peg$c49 = { type: "class", value: "[^{}\\\\\\0-\\x1F\\x7f \\t\\n\\r]", description: "[^{}\\\\\\0-\\x1F\\x7f \\t\\n\\r]" },
  375. peg$c50 = "\\\\",
  376. peg$c51 = { type: "literal", value: "\\\\", description: "\"\\\\\\\\\"" },
  377. peg$c52 = function() { return '\\'; },
  378. peg$c53 = "\\#",
  379. peg$c54 = { type: "literal", value: "\\#", description: "\"\\\\#\"" },
  380. peg$c55 = function() { return '\\#'; },
  381. peg$c56 = "\\{",
  382. peg$c57 = { type: "literal", value: "\\{", description: "\"\\\\{\"" },
  383. peg$c58 = function() { return '\u007B'; },
  384. peg$c59 = "\\}",
  385. peg$c60 = { type: "literal", value: "\\}", description: "\"\\\\}\"" },
  386. peg$c61 = function() { return '\u007D'; },
  387. peg$c62 = "\\u",
  388. peg$c63 = { type: "literal", value: "\\u", description: "\"\\\\u\"" },
  389. peg$c64 = function(digits) {
  390. return String.fromCharCode(parseInt(digits, 16));
  391. },
  392. peg$c65 = function(chars) { return chars.join(''); },
  393. peg$currPos = 0,
  394. peg$savedPos = 0,
  395. peg$posDetailsCache = [{ line: 1, column: 1, seenCR: false }],
  396. peg$maxFailPos = 0,
  397. peg$maxFailExpected = [],
  398. peg$silentFails = 0,
  399. peg$result;
  400. if ("startRule" in options) {
  401. if (!(options.startRule in peg$startRuleFunctions)) {
  402. throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
  403. }
  404. peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
  405. }
  406. function location() {
  407. return peg$computeLocation(peg$savedPos, peg$currPos);
  408. }
  409. function peg$computePosDetails(pos) {
  410. var details = peg$posDetailsCache[pos],
  411. p, ch;
  412. if (details) {
  413. return details;
  414. } else {
  415. p = pos - 1;
  416. while (!peg$posDetailsCache[p]) {
  417. p--;
  418. }
  419. details = peg$posDetailsCache[p];
  420. details = {
  421. line: details.line,
  422. column: details.column,
  423. seenCR: details.seenCR
  424. };
  425. while (p < pos) {
  426. ch = input.charAt(p);
  427. if (ch === "\n") {
  428. if (!details.seenCR) { details.line++; }
  429. details.column = 1;
  430. details.seenCR = false;
  431. } else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") {
  432. details.line++;
  433. details.column = 1;
  434. details.seenCR = true;
  435. } else {
  436. details.column++;
  437. details.seenCR = false;
  438. }
  439. p++;
  440. }
  441. peg$posDetailsCache[pos] = details;
  442. return details;
  443. }
  444. }
  445. function peg$computeLocation(startPos, endPos) {
  446. var startPosDetails = peg$computePosDetails(startPos),
  447. endPosDetails = peg$computePosDetails(endPos);
  448. return {
  449. start: {
  450. offset: startPos,
  451. line: startPosDetails.line,
  452. column: startPosDetails.column
  453. },
  454. end: {
  455. offset: endPos,
  456. line: endPosDetails.line,
  457. column: endPosDetails.column
  458. }
  459. };
  460. }
  461. function peg$fail(expected) {
  462. if (peg$currPos < peg$maxFailPos) { return; }
  463. if (peg$currPos > peg$maxFailPos) {
  464. peg$maxFailPos = peg$currPos;
  465. peg$maxFailExpected = [];
  466. }
  467. peg$maxFailExpected.push(expected);
  468. }
  469. function peg$buildException(message, expected, found, location) {
  470. function cleanupExpected(expected) {
  471. var i = 1;
  472. expected.sort(function(a, b) {
  473. if (a.description < b.description) {
  474. return -1;
  475. } else if (a.description > b.description) {
  476. return 1;
  477. } else {
  478. return 0;
  479. }
  480. });
  481. while (i < expected.length) {
  482. if (expected[i - 1] === expected[i]) {
  483. expected.splice(i, 1);
  484. } else {
  485. i++;
  486. }
  487. }
  488. }
  489. function buildMessage(expected, found) {
  490. function stringEscape(s) {
  491. function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); }
  492. return s
  493. .replace(/\\/g, '\\\\')
  494. .replace(/"/g, '\\"')
  495. .replace(/\x08/g, '\\b')
  496. .replace(/\t/g, '\\t')
  497. .replace(/\n/g, '\\n')
  498. .replace(/\f/g, '\\f')
  499. .replace(/\r/g, '\\r')
  500. .replace(/[\x00-\x07\x0B\x0E\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
  501. .replace(/[\x10-\x1F\x80-\xFF]/g, function(ch) { return '\\x' + hex(ch); })
  502. .replace(/[\u0100-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); })
  503. .replace(/[\u1000-\uFFFF]/g, function(ch) { return '\\u' + hex(ch); });
  504. }
  505. var expectedDescs = new Array(expected.length),
  506. expectedDesc, foundDesc, i;
  507. for (i = 0; i < expected.length; i++) {
  508. expectedDescs[i] = expected[i].description;
  509. }
  510. expectedDesc = expected.length > 1
  511. ? expectedDescs.slice(0, -1).join(", ")
  512. + " or "
  513. + expectedDescs[expected.length - 1]
  514. : expectedDescs[0];
  515. foundDesc = found ? "\"" + stringEscape(found) + "\"" : "end of input";
  516. return "Expected " + expectedDesc + " but " + foundDesc + " found.";
  517. }
  518. if (expected !== null) {
  519. cleanupExpected(expected);
  520. }
  521. return new peg$SyntaxError(
  522. message !== null ? message : buildMessage(expected, found),
  523. expected,
  524. found,
  525. location
  526. );
  527. }
  528. function peg$parsestart() {
  529. var s0;
  530. s0 = peg$parsemessageFormatPattern();
  531. return s0;
  532. }
  533. function peg$parsemessageFormatPattern() {
  534. var s0, s1, s2;
  535. s0 = peg$currPos;
  536. s1 = [];
  537. s2 = peg$parsemessageFormatElement();
  538. while (s2 !== peg$FAILED) {
  539. s1.push(s2);
  540. s2 = peg$parsemessageFormatElement();
  541. }
  542. if (s1 !== peg$FAILED) {
  543. peg$savedPos = s0;
  544. s1 = peg$c0(s1);
  545. }
  546. s0 = s1;
  547. return s0;
  548. }
  549. function peg$parsemessageFormatElement() {
  550. var s0;
  551. s0 = peg$parsemessageTextElement();
  552. if (s0 === peg$FAILED) {
  553. s0 = peg$parseargumentElement();
  554. }
  555. return s0;
  556. }
  557. function peg$parsemessageText() {
  558. var s0, s1, s2, s3, s4, s5;
  559. s0 = peg$currPos;
  560. s1 = [];
  561. s2 = peg$currPos;
  562. s3 = peg$parse_();
  563. if (s3 !== peg$FAILED) {
  564. s4 = peg$parsechars();
  565. if (s4 !== peg$FAILED) {
  566. s5 = peg$parse_();
  567. if (s5 !== peg$FAILED) {
  568. s3 = [s3, s4, s5];
  569. s2 = s3;
  570. } else {
  571. peg$currPos = s2;
  572. s2 = peg$FAILED;
  573. }
  574. } else {
  575. peg$currPos = s2;
  576. s2 = peg$FAILED;
  577. }
  578. } else {
  579. peg$currPos = s2;
  580. s2 = peg$FAILED;
  581. }
  582. if (s2 !== peg$FAILED) {
  583. while (s2 !== peg$FAILED) {
  584. s1.push(s2);
  585. s2 = peg$currPos;
  586. s3 = peg$parse_();
  587. if (s3 !== peg$FAILED) {
  588. s4 = peg$parsechars();
  589. if (s4 !== peg$FAILED) {
  590. s5 = peg$parse_();
  591. if (s5 !== peg$FAILED) {
  592. s3 = [s3, s4, s5];
  593. s2 = s3;
  594. } else {
  595. peg$currPos = s2;
  596. s2 = peg$FAILED;
  597. }
  598. } else {
  599. peg$currPos = s2;
  600. s2 = peg$FAILED;
  601. }
  602. } else {
  603. peg$currPos = s2;
  604. s2 = peg$FAILED;
  605. }
  606. }
  607. } else {
  608. s1 = peg$FAILED;
  609. }
  610. if (s1 !== peg$FAILED) {
  611. peg$savedPos = s0;
  612. s1 = peg$c1(s1);
  613. }
  614. s0 = s1;
  615. if (s0 === peg$FAILED) {
  616. s0 = peg$currPos;
  617. s1 = peg$parsews();
  618. if (s1 !== peg$FAILED) {
  619. s0 = input.substring(s0, peg$currPos);
  620. } else {
  621. s0 = s1;
  622. }
  623. }
  624. return s0;
  625. }
  626. function peg$parsemessageTextElement() {
  627. var s0, s1;
  628. s0 = peg$currPos;
  629. s1 = peg$parsemessageText();
  630. if (s1 !== peg$FAILED) {
  631. peg$savedPos = s0;
  632. s1 = peg$c2(s1);
  633. }
  634. s0 = s1;
  635. return s0;
  636. }
  637. function peg$parseargument() {
  638. var s0, s1, s2;
  639. s0 = peg$parsenumber();
  640. if (s0 === peg$FAILED) {
  641. s0 = peg$currPos;
  642. s1 = [];
  643. if (peg$c3.test(input.charAt(peg$currPos))) {
  644. s2 = input.charAt(peg$currPos);
  645. peg$currPos++;
  646. } else {
  647. s2 = peg$FAILED;
  648. if (peg$silentFails === 0) { peg$fail(peg$c4); }
  649. }
  650. if (s2 !== peg$FAILED) {
  651. while (s2 !== peg$FAILED) {
  652. s1.push(s2);
  653. if (peg$c3.test(input.charAt(peg$currPos))) {
  654. s2 = input.charAt(peg$currPos);
  655. peg$currPos++;
  656. } else {
  657. s2 = peg$FAILED;
  658. if (peg$silentFails === 0) { peg$fail(peg$c4); }
  659. }
  660. }
  661. } else {
  662. s1 = peg$FAILED;
  663. }
  664. if (s1 !== peg$FAILED) {
  665. s0 = input.substring(s0, peg$currPos);
  666. } else {
  667. s0 = s1;
  668. }
  669. }
  670. return s0;
  671. }
  672. function peg$parseargumentElement() {
  673. var s0, s1, s2, s3, s4, s5, s6, s7, s8;
  674. s0 = peg$currPos;
  675. if (input.charCodeAt(peg$currPos) === 123) {
  676. s1 = peg$c5;
  677. peg$currPos++;
  678. } else {
  679. s1 = peg$FAILED;
  680. if (peg$silentFails === 0) { peg$fail(peg$c6); }
  681. }
  682. if (s1 !== peg$FAILED) {
  683. s2 = peg$parse_();
  684. if (s2 !== peg$FAILED) {
  685. s3 = peg$parseargument();
  686. if (s3 !== peg$FAILED) {
  687. s4 = peg$parse_();
  688. if (s4 !== peg$FAILED) {
  689. s5 = peg$currPos;
  690. if (input.charCodeAt(peg$currPos) === 44) {
  691. s6 = peg$c7;
  692. peg$currPos++;
  693. } else {
  694. s6 = peg$FAILED;
  695. if (peg$silentFails === 0) { peg$fail(peg$c8); }
  696. }
  697. if (s6 !== peg$FAILED) {
  698. s7 = peg$parse_();
  699. if (s7 !== peg$FAILED) {
  700. s8 = peg$parseelementFormat();
  701. if (s8 !== peg$FAILED) {
  702. s6 = [s6, s7, s8];
  703. s5 = s6;
  704. } else {
  705. peg$currPos = s5;
  706. s5 = peg$FAILED;
  707. }
  708. } else {
  709. peg$currPos = s5;
  710. s5 = peg$FAILED;
  711. }
  712. } else {
  713. peg$currPos = s5;
  714. s5 = peg$FAILED;
  715. }
  716. if (s5 === peg$FAILED) {
  717. s5 = null;
  718. }
  719. if (s5 !== peg$FAILED) {
  720. s6 = peg$parse_();
  721. if (s6 !== peg$FAILED) {
  722. if (input.charCodeAt(peg$currPos) === 125) {
  723. s7 = peg$c9;
  724. peg$currPos++;
  725. } else {
  726. s7 = peg$FAILED;
  727. if (peg$silentFails === 0) { peg$fail(peg$c10); }
  728. }
  729. if (s7 !== peg$FAILED) {
  730. peg$savedPos = s0;
  731. s1 = peg$c11(s3, s5);
  732. s0 = s1;
  733. } else {
  734. peg$currPos = s0;
  735. s0 = peg$FAILED;
  736. }
  737. } else {
  738. peg$currPos = s0;
  739. s0 = peg$FAILED;
  740. }
  741. } else {
  742. peg$currPos = s0;
  743. s0 = peg$FAILED;
  744. }
  745. } else {
  746. peg$currPos = s0;
  747. s0 = peg$FAILED;
  748. }
  749. } else {
  750. peg$currPos = s0;
  751. s0 = peg$FAILED;
  752. }
  753. } else {
  754. peg$currPos = s0;
  755. s0 = peg$FAILED;
  756. }
  757. } else {
  758. peg$currPos = s0;
  759. s0 = peg$FAILED;
  760. }
  761. return s0;
  762. }
  763. function peg$parseelementFormat() {
  764. var s0;
  765. s0 = peg$parsesimpleFormat();
  766. if (s0 === peg$FAILED) {
  767. s0 = peg$parsepluralFormat();
  768. if (s0 === peg$FAILED) {
  769. s0 = peg$parseselectOrdinalFormat();
  770. if (s0 === peg$FAILED) {
  771. s0 = peg$parseselectFormat();
  772. }
  773. }
  774. }
  775. return s0;
  776. }
  777. function peg$parsesimpleFormat() {
  778. var s0, s1, s2, s3, s4, s5, s6;
  779. s0 = peg$currPos;
  780. if (input.substr(peg$currPos, 6) === peg$c12) {
  781. s1 = peg$c12;
  782. peg$currPos += 6;
  783. } else {
  784. s1 = peg$FAILED;
  785. if (peg$silentFails === 0) { peg$fail(peg$c13); }
  786. }
  787. if (s1 === peg$FAILED) {
  788. if (input.substr(peg$currPos, 4) === peg$c14) {
  789. s1 = peg$c14;
  790. peg$currPos += 4;
  791. } else {
  792. s1 = peg$FAILED;
  793. if (peg$silentFails === 0) { peg$fail(peg$c15); }
  794. }
  795. if (s1 === peg$FAILED) {
  796. if (input.substr(peg$currPos, 4) === peg$c16) {
  797. s1 = peg$c16;
  798. peg$currPos += 4;
  799. } else {
  800. s1 = peg$FAILED;
  801. if (peg$silentFails === 0) { peg$fail(peg$c17); }
  802. }
  803. }
  804. }
  805. if (s1 !== peg$FAILED) {
  806. s2 = peg$parse_();
  807. if (s2 !== peg$FAILED) {
  808. s3 = peg$currPos;
  809. if (input.charCodeAt(peg$currPos) === 44) {
  810. s4 = peg$c7;
  811. peg$currPos++;
  812. } else {
  813. s4 = peg$FAILED;
  814. if (peg$silentFails === 0) { peg$fail(peg$c8); }
  815. }
  816. if (s4 !== peg$FAILED) {
  817. s5 = peg$parse_();
  818. if (s5 !== peg$FAILED) {
  819. s6 = peg$parsechars();
  820. if (s6 !== peg$FAILED) {
  821. s4 = [s4, s5, s6];
  822. s3 = s4;
  823. } else {
  824. peg$currPos = s3;
  825. s3 = peg$FAILED;
  826. }
  827. } else {
  828. peg$currPos = s3;
  829. s3 = peg$FAILED;
  830. }
  831. } else {
  832. peg$currPos = s3;
  833. s3 = peg$FAILED;
  834. }
  835. if (s3 === peg$FAILED) {
  836. s3 = null;
  837. }
  838. if (s3 !== peg$FAILED) {
  839. peg$savedPos = s0;
  840. s1 = peg$c18(s1, s3);
  841. s0 = s1;
  842. } else {
  843. peg$currPos = s0;
  844. s0 = peg$FAILED;
  845. }
  846. } else {
  847. peg$currPos = s0;
  848. s0 = peg$FAILED;
  849. }
  850. } else {
  851. peg$currPos = s0;
  852. s0 = peg$FAILED;
  853. }
  854. return s0;
  855. }
  856. function peg$parsepluralFormat() {
  857. var s0, s1, s2, s3, s4, s5;
  858. s0 = peg$currPos;
  859. if (input.substr(peg$currPos, 6) === peg$c19) {
  860. s1 = peg$c19;
  861. peg$currPos += 6;
  862. } else {
  863. s1 = peg$FAILED;
  864. if (peg$silentFails === 0) { peg$fail(peg$c20); }
  865. }
  866. if (s1 !== peg$FAILED) {
  867. s2 = peg$parse_();
  868. if (s2 !== peg$FAILED) {
  869. if (input.charCodeAt(peg$currPos) === 44) {
  870. s3 = peg$c7;
  871. peg$currPos++;
  872. } else {
  873. s3 = peg$FAILED;
  874. if (peg$silentFails === 0) { peg$fail(peg$c8); }
  875. }
  876. if (s3 !== peg$FAILED) {
  877. s4 = peg$parse_();
  878. if (s4 !== peg$FAILED) {
  879. s5 = peg$parsepluralStyle();
  880. if (s5 !== peg$FAILED) {
  881. peg$savedPos = s0;
  882. s1 = peg$c21(s5);
  883. s0 = s1;
  884. } else {
  885. peg$currPos = s0;
  886. s0 = peg$FAILED;
  887. }
  888. } else {
  889. peg$currPos = s0;
  890. s0 = peg$FAILED;
  891. }
  892. } else {
  893. peg$currPos = s0;
  894. s0 = peg$FAILED;
  895. }
  896. } else {
  897. peg$currPos = s0;
  898. s0 = peg$FAILED;
  899. }
  900. } else {
  901. peg$currPos = s0;
  902. s0 = peg$FAILED;
  903. }
  904. return s0;
  905. }
  906. function peg$parseselectOrdinalFormat() {
  907. var s0, s1, s2, s3, s4, s5;
  908. s0 = peg$currPos;
  909. if (input.substr(peg$currPos, 13) === peg$c22) {
  910. s1 = peg$c22;
  911. peg$currPos += 13;
  912. } else {
  913. s1 = peg$FAILED;
  914. if (peg$silentFails === 0) { peg$fail(peg$c23); }
  915. }
  916. if (s1 !== peg$FAILED) {
  917. s2 = peg$parse_();
  918. if (s2 !== peg$FAILED) {
  919. if (input.charCodeAt(peg$currPos) === 44) {
  920. s3 = peg$c7;
  921. peg$currPos++;
  922. } else {
  923. s3 = peg$FAILED;
  924. if (peg$silentFails === 0) { peg$fail(peg$c8); }
  925. }
  926. if (s3 !== peg$FAILED) {
  927. s4 = peg$parse_();
  928. if (s4 !== peg$FAILED) {
  929. s5 = peg$parsepluralStyle();
  930. if (s5 !== peg$FAILED) {
  931. peg$savedPos = s0;
  932. s1 = peg$c24(s5);
  933. s0 = s1;
  934. } else {
  935. peg$currPos = s0;
  936. s0 = peg$FAILED;
  937. }
  938. } else {
  939. peg$currPos = s0;
  940. s0 = peg$FAILED;
  941. }
  942. } else {
  943. peg$currPos = s0;
  944. s0 = peg$FAILED;
  945. }
  946. } else {
  947. peg$currPos = s0;
  948. s0 = peg$FAILED;
  949. }
  950. } else {
  951. peg$currPos = s0;
  952. s0 = peg$FAILED;
  953. }
  954. return s0;
  955. }
  956. function peg$parseselectFormat() {
  957. var s0, s1, s2, s3, s4, s5, s6;
  958. s0 = peg$currPos;
  959. if (input.substr(peg$currPos, 6) === peg$c25) {
  960. s1 = peg$c25;
  961. peg$currPos += 6;
  962. } else {
  963. s1 = peg$FAILED;
  964. if (peg$silentFails === 0) { peg$fail(peg$c26); }
  965. }
  966. if (s1 !== peg$FAILED) {
  967. s2 = peg$parse_();
  968. if (s2 !== peg$FAILED) {
  969. if (input.charCodeAt(peg$currPos) === 44) {
  970. s3 = peg$c7;
  971. peg$currPos++;
  972. } else {
  973. s3 = peg$FAILED;
  974. if (peg$silentFails === 0) { peg$fail(peg$c8); }
  975. }
  976. if (s3 !== peg$FAILED) {
  977. s4 = peg$parse_();
  978. if (s4 !== peg$FAILED) {
  979. s5 = [];
  980. s6 = peg$parseoptionalFormatPattern();
  981. if (s6 !== peg$FAILED) {
  982. while (s6 !== peg$FAILED) {
  983. s5.push(s6);
  984. s6 = peg$parseoptionalFormatPattern();
  985. }
  986. } else {
  987. s5 = peg$FAILED;
  988. }
  989. if (s5 !== peg$FAILED) {
  990. peg$savedPos = s0;
  991. s1 = peg$c27(s5);
  992. s0 = s1;
  993. } else {
  994. peg$currPos = s0;
  995. s0 = peg$FAILED;
  996. }
  997. } else {
  998. peg$currPos = s0;
  999. s0 = peg$FAILED;
  1000. }
  1001. } else {
  1002. peg$currPos = s0;
  1003. s0 = peg$FAILED;
  1004. }
  1005. } else {
  1006. peg$currPos = s0;
  1007. s0 = peg$FAILED;
  1008. }
  1009. } else {
  1010. peg$currPos = s0;
  1011. s0 = peg$FAILED;
  1012. }
  1013. return s0;
  1014. }
  1015. function peg$parseselector() {
  1016. var s0, s1, s2, s3;
  1017. s0 = peg$currPos;
  1018. s1 = peg$currPos;
  1019. if (input.charCodeAt(peg$currPos) === 61) {
  1020. s2 = peg$c28;
  1021. peg$currPos++;
  1022. } else {
  1023. s2 = peg$FAILED;
  1024. if (peg$silentFails === 0) { peg$fail(peg$c29); }
  1025. }
  1026. if (s2 !== peg$FAILED) {
  1027. s3 = peg$parsenumber();
  1028. if (s3 !== peg$FAILED) {
  1029. s2 = [s2, s3];
  1030. s1 = s2;
  1031. } else {
  1032. peg$currPos = s1;
  1033. s1 = peg$FAILED;
  1034. }
  1035. } else {
  1036. peg$currPos = s1;
  1037. s1 = peg$FAILED;
  1038. }
  1039. if (s1 !== peg$FAILED) {
  1040. s0 = input.substring(s0, peg$currPos);
  1041. } else {
  1042. s0 = s1;
  1043. }
  1044. if (s0 === peg$FAILED) {
  1045. s0 = peg$parsechars();
  1046. }
  1047. return s0;
  1048. }
  1049. function peg$parseoptionalFormatPattern() {
  1050. var s0, s1, s2, s3, s4, s5, s6, s7, s8;
  1051. s0 = peg$currPos;
  1052. s1 = peg$parse_();
  1053. if (s1 !== peg$FAILED) {
  1054. s2 = peg$parseselector();
  1055. if (s2 !== peg$FAILED) {
  1056. s3 = peg$parse_();
  1057. if (s3 !== peg$FAILED) {
  1058. if (input.charCodeAt(peg$currPos) === 123) {
  1059. s4 = peg$c5;
  1060. peg$currPos++;
  1061. } else {
  1062. s4 = peg$FAILED;
  1063. if (peg$silentFails === 0) { peg$fail(peg$c6); }
  1064. }
  1065. if (s4 !== peg$FAILED) {
  1066. s5 = peg$parse_();
  1067. if (s5 !== peg$FAILED) {
  1068. s6 = peg$parsemessageFormatPattern();
  1069. if (s6 !== peg$FAILED) {
  1070. s7 = peg$parse_();
  1071. if (s7 !== peg$FAILED) {
  1072. if (input.charCodeAt(peg$currPos) === 125) {
  1073. s8 = peg$c9;
  1074. peg$currPos++;
  1075. } else {
  1076. s8 = peg$FAILED;
  1077. if (peg$silentFails === 0) { peg$fail(peg$c10); }
  1078. }
  1079. if (s8 !== peg$FAILED) {
  1080. peg$savedPos = s0;
  1081. s1 = peg$c30(s2, s6);
  1082. s0 = s1;
  1083. } else {
  1084. peg$currPos = s0;
  1085. s0 = peg$FAILED;
  1086. }
  1087. } else {
  1088. peg$currPos = s0;
  1089. s0 = peg$FAILED;
  1090. }
  1091. } else {
  1092. peg$currPos = s0;
  1093. s0 = peg$FAILED;
  1094. }
  1095. } else {
  1096. peg$currPos = s0;
  1097. s0 = peg$FAILED;
  1098. }
  1099. } else {
  1100. peg$currPos = s0;
  1101. s0 = peg$FAILED;
  1102. }
  1103. } else {
  1104. peg$currPos = s0;
  1105. s0 = peg$FAILED;
  1106. }
  1107. } else {
  1108. peg$currPos = s0;
  1109. s0 = peg$FAILED;
  1110. }
  1111. } else {
  1112. peg$currPos = s0;
  1113. s0 = peg$FAILED;
  1114. }
  1115. return s0;
  1116. }
  1117. function peg$parseoffset() {
  1118. var s0, s1, s2, s3;
  1119. s0 = peg$currPos;
  1120. if (input.substr(peg$currPos, 7) === peg$c31) {
  1121. s1 = peg$c31;
  1122. peg$currPos += 7;
  1123. } else {
  1124. s1 = peg$FAILED;
  1125. if (peg$silentFails === 0) { peg$fail(peg$c32); }
  1126. }
  1127. if (s1 !== peg$FAILED) {
  1128. s2 = peg$parse_();
  1129. if (s2 !== peg$FAILED) {
  1130. s3 = peg$parsenumber();
  1131. if (s3 !== peg$FAILED) {
  1132. peg$savedPos = s0;
  1133. s1 = peg$c33(s3);
  1134. s0 = s1;
  1135. } else {
  1136. peg$currPos = s0;
  1137. s0 = peg$FAILED;
  1138. }
  1139. } else {
  1140. peg$currPos = s0;
  1141. s0 = peg$FAILED;
  1142. }
  1143. } else {
  1144. peg$currPos = s0;
  1145. s0 = peg$FAILED;
  1146. }
  1147. return s0;
  1148. }
  1149. function peg$parsepluralStyle() {
  1150. var s0, s1, s2, s3, s4;
  1151. s0 = peg$currPos;
  1152. s1 = peg$parseoffset();
  1153. if (s1 === peg$FAILED) {
  1154. s1 = null;
  1155. }
  1156. if (s1 !== peg$FAILED) {
  1157. s2 = peg$parse_();
  1158. if (s2 !== peg$FAILED) {
  1159. s3 = [];
  1160. s4 = peg$parseoptionalFormatPattern();
  1161. if (s4 !== peg$FAILED) {
  1162. while (s4 !== peg$FAILED) {
  1163. s3.push(s4);
  1164. s4 = peg$parseoptionalFormatPattern();
  1165. }
  1166. } else {
  1167. s3 = peg$FAILED;
  1168. }
  1169. if (s3 !== peg$FAILED) {
  1170. peg$savedPos = s0;
  1171. s1 = peg$c34(s1, s3);
  1172. s0 = s1;
  1173. } else {
  1174. peg$currPos = s0;
  1175. s0 = peg$FAILED;
  1176. }
  1177. } else {
  1178. peg$currPos = s0;
  1179. s0 = peg$FAILED;
  1180. }
  1181. } else {
  1182. peg$currPos = s0;
  1183. s0 = peg$FAILED;
  1184. }
  1185. return s0;
  1186. }
  1187. function peg$parsews() {
  1188. var s0, s1;
  1189. peg$silentFails++;
  1190. s0 = [];
  1191. if (peg$c36.test(input.charAt(peg$currPos))) {
  1192. s1 = input.charAt(peg$currPos);
  1193. peg$currPos++;
  1194. } else {
  1195. s1 = peg$FAILED;
  1196. if (peg$silentFails === 0) { peg$fail(peg$c37); }
  1197. }
  1198. if (s1 !== peg$FAILED) {
  1199. while (s1 !== peg$FAILED) {
  1200. s0.push(s1);
  1201. if (peg$c36.test(input.charAt(peg$currPos))) {
  1202. s1 = input.charAt(peg$currPos);
  1203. peg$currPos++;
  1204. } else {
  1205. s1 = peg$FAILED;
  1206. if (peg$silentFails === 0) { peg$fail(peg$c37); }
  1207. }
  1208. }
  1209. } else {
  1210. s0 = peg$FAILED;
  1211. }
  1212. peg$silentFails--;
  1213. if (s0 === peg$FAILED) {
  1214. s1 = peg$FAILED;
  1215. if (peg$silentFails === 0) { peg$fail(peg$c35); }
  1216. }
  1217. return s0;
  1218. }
  1219. function peg$parse_() {
  1220. var s0, s1, s2;
  1221. peg$silentFails++;
  1222. s0 = peg$currPos;
  1223. s1 = [];
  1224. s2 = peg$parsews();
  1225. while (s2 !== peg$FAILED) {
  1226. s1.push(s2);
  1227. s2 = peg$parsews();
  1228. }
  1229. if (s1 !== peg$FAILED) {
  1230. s0 = input.substring(s0, peg$currPos);
  1231. } else {
  1232. s0 = s1;
  1233. }
  1234. peg$silentFails--;
  1235. if (s0 === peg$FAILED) {
  1236. s1 = peg$FAILED;
  1237. if (peg$silentFails === 0) { peg$fail(peg$c38); }
  1238. }
  1239. return s0;
  1240. }
  1241. function peg$parsedigit() {
  1242. var s0;
  1243. if (peg$c39.test(input.charAt(peg$currPos))) {
  1244. s0 = input.charAt(peg$currPos);
  1245. peg$currPos++;
  1246. } else {
  1247. s0 = peg$FAILED;
  1248. if (peg$silentFails === 0) { peg$fail(peg$c40); }
  1249. }
  1250. return s0;
  1251. }
  1252. function peg$parsehexDigit() {
  1253. var s0;
  1254. if (peg$c41.test(input.charAt(peg$currPos))) {
  1255. s0 = input.charAt(peg$currPos);
  1256. peg$currPos++;
  1257. } else {
  1258. s0 = peg$FAILED;
  1259. if (peg$silentFails === 0) { peg$fail(peg$c42); }
  1260. }
  1261. return s0;
  1262. }
  1263. function peg$parsenumber() {
  1264. var s0, s1, s2, s3, s4, s5;
  1265. s0 = peg$currPos;
  1266. if (input.charCodeAt(peg$currPos) === 48) {
  1267. s1 = peg$c43;
  1268. peg$currPos++;
  1269. } else {
  1270. s1 = peg$FAILED;
  1271. if (peg$silentFails === 0) { peg$fail(peg$c44); }
  1272. }
  1273. if (s1 === peg$FAILED) {
  1274. s1 = peg$currPos;
  1275. s2 = peg$currPos;
  1276. if (peg$c45.test(input.charAt(peg$currPos))) {
  1277. s3 = input.charAt(peg$currPos);
  1278. peg$currPos++;
  1279. } else {
  1280. s3 = peg$FAILED;
  1281. if (peg$silentFails === 0) { peg$fail(peg$c46); }
  1282. }
  1283. if (s3 !== peg$FAILED) {
  1284. s4 = [];
  1285. s5 = peg$parsedigit();
  1286. while (s5 !== peg$FAILED) {
  1287. s4.push(s5);
  1288. s5 = peg$parsedigit();
  1289. }
  1290. if (s4 !== peg$FAILED) {
  1291. s3 = [s3, s4];
  1292. s2 = s3;
  1293. } else {
  1294. peg$currPos = s2;
  1295. s2 = peg$FAILED;
  1296. }
  1297. } else {
  1298. peg$currPos = s2;
  1299. s2 = peg$FAILED;
  1300. }
  1301. if (s2 !== peg$FAILED) {
  1302. s1 = input.substring(s1, peg$currPos);
  1303. } else {
  1304. s1 = s2;
  1305. }
  1306. }
  1307. if (s1 !== peg$FAILED) {
  1308. peg$savedPos = s0;
  1309. s1 = peg$c47(s1);
  1310. }
  1311. s0 = s1;
  1312. return s0;
  1313. }
  1314. function peg$parsechar() {
  1315. var s0, s1, s2, s3, s4, s5, s6, s7;
  1316. if (peg$c48.test(input.charAt(peg$currPos))) {
  1317. s0 = input.charAt(peg$currPos);
  1318. peg$currPos++;
  1319. } else {
  1320. s0 = peg$FAILED;
  1321. if (peg$silentFails === 0) { peg$fail(peg$c49); }
  1322. }
  1323. if (s0 === peg$FAILED) {
  1324. s0 = peg$currPos;
  1325. if (input.substr(peg$currPos, 2) === peg$c50) {
  1326. s1 = peg$c50;
  1327. peg$currPos += 2;
  1328. } else {
  1329. s1 = peg$FAILED;
  1330. if (peg$silentFails === 0) { peg$fail(peg$c51); }
  1331. }
  1332. if (s1 !== peg$FAILED) {
  1333. peg$savedPos = s0;
  1334. s1 = peg$c52();
  1335. }
  1336. s0 = s1;
  1337. if (s0 === peg$FAILED) {
  1338. s0 = peg$currPos;
  1339. if (input.substr(peg$currPos, 2) === peg$c53) {
  1340. s1 = peg$c53;
  1341. peg$currPos += 2;
  1342. } else {
  1343. s1 = peg$FAILED;
  1344. if (peg$silentFails === 0) { peg$fail(peg$c54); }
  1345. }
  1346. if (s1 !== peg$FAILED) {
  1347. peg$savedPos = s0;
  1348. s1 = peg$c55();
  1349. }
  1350. s0 = s1;
  1351. if (s0 === peg$FAILED) {
  1352. s0 = peg$currPos;
  1353. if (input.substr(peg$currPos, 2) === peg$c56) {
  1354. s1 = peg$c56;
  1355. peg$currPos += 2;
  1356. } else {
  1357. s1 = peg$FAILED;
  1358. if (peg$silentFails === 0) { peg$fail(peg$c57); }
  1359. }
  1360. if (s1 !== peg$FAILED) {
  1361. peg$savedPos = s0;
  1362. s1 = peg$c58();
  1363. }
  1364. s0 = s1;
  1365. if (s0 === peg$FAILED) {
  1366. s0 = peg$currPos;
  1367. if (input.substr(peg$currPos, 2) === peg$c59) {
  1368. s1 = peg$c59;
  1369. peg$currPos += 2;
  1370. } else {
  1371. s1 = peg$FAILED;
  1372. if (peg$silentFails === 0) { peg$fail(peg$c60); }
  1373. }
  1374. if (s1 !== peg$FAILED) {
  1375. peg$savedPos = s0;
  1376. s1 = peg$c61();
  1377. }
  1378. s0 = s1;
  1379. if (s0 === peg$FAILED) {
  1380. s0 = peg$currPos;
  1381. if (input.substr(peg$currPos, 2) === peg$c62) {
  1382. s1 = peg$c62;
  1383. peg$currPos += 2;
  1384. } else {
  1385. s1 = peg$FAILED;
  1386. if (peg$silentFails === 0) { peg$fail(peg$c63); }
  1387. }
  1388. if (s1 !== peg$FAILED) {
  1389. s2 = peg$currPos;
  1390. s3 = peg$currPos;
  1391. s4 = peg$parsehexDigit();
  1392. if (s4 !== peg$FAILED) {
  1393. s5 = peg$parsehexDigit();
  1394. if (s5 !== peg$FAILED) {
  1395. s6 = peg$parsehexDigit();
  1396. if (s6 !== peg$FAILED) {
  1397. s7 = peg$parsehexDigit();
  1398. if (s7 !== peg$FAILED) {
  1399. s4 = [s4, s5, s6, s7];
  1400. s3 = s4;
  1401. } else {
  1402. peg$currPos = s3;
  1403. s3 = peg$FAILED;
  1404. }
  1405. } else {
  1406. peg$currPos = s3;
  1407. s3 = peg$FAILED;
  1408. }
  1409. } else {
  1410. peg$currPos = s3;
  1411. s3 = peg$FAILED;
  1412. }
  1413. } else {
  1414. peg$currPos = s3;
  1415. s3 = peg$FAILED;
  1416. }
  1417. if (s3 !== peg$FAILED) {
  1418. s2 = input.substring(s2, peg$currPos);
  1419. } else {
  1420. s2 = s3;
  1421. }
  1422. if (s2 !== peg$FAILED) {
  1423. peg$savedPos = s0;
  1424. s1 = peg$c64(s2);
  1425. s0 = s1;
  1426. } else {
  1427. peg$currPos = s0;
  1428. s0 = peg$FAILED;
  1429. }
  1430. } else {
  1431. peg$currPos = s0;
  1432. s0 = peg$FAILED;
  1433. }
  1434. }
  1435. }
  1436. }
  1437. }
  1438. }
  1439. return s0;
  1440. }
  1441. function peg$parsechars() {
  1442. var s0, s1, s2;
  1443. s0 = peg$currPos;
  1444. s1 = [];
  1445. s2 = peg$parsechar();
  1446. if (s2 !== peg$FAILED) {
  1447. while (s2 !== peg$FAILED) {
  1448. s1.push(s2);
  1449. s2 = peg$parsechar();
  1450. }
  1451. } else {
  1452. s1 = peg$FAILED;
  1453. }
  1454. if (s1 !== peg$FAILED) {
  1455. peg$savedPos = s0;
  1456. s1 = peg$c65(s1);
  1457. }
  1458. s0 = s1;
  1459. return s0;
  1460. }
  1461. peg$result = peg$startRuleFunction();
  1462. if (peg$result !== peg$FAILED && peg$currPos === input.length) {
  1463. return peg$result;
  1464. } else {
  1465. if (peg$result !== peg$FAILED && peg$currPos < input.length) {
  1466. peg$fail({ type: "end", description: "end of input" });
  1467. }
  1468. throw peg$buildException(
  1469. null,
  1470. peg$maxFailExpected,
  1471. peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
  1472. peg$maxFailPos < input.length
  1473. ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
  1474. : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
  1475. );
  1476. }
  1477. }
  1478. return {
  1479. SyntaxError: peg$SyntaxError,
  1480. parse: peg$parse
  1481. };
  1482. })();
  1483. });
  1484. var intlMessageformatParser = styleInject_es.createCommonjsModule(function (module, exports) {
  1485. exports = module.exports = parser['default'];
  1486. exports['default'] = exports;
  1487. });
  1488. var core = styleInject_es.createCommonjsModule(function (module, exports) {
  1489. exports["default"] = MessageFormat;
  1490. // -- MessageFormat --------------------------------------------------------
  1491. function MessageFormat(message, locales, formats) {
  1492. // Parse string messages into an AST.
  1493. var ast = typeof message === 'string' ?
  1494. MessageFormat.__parse(message) : message;
  1495. if (!(ast && ast.type === 'messageFormatPattern')) {
  1496. throw new TypeError('A message must be provided as a String or AST.');
  1497. }
  1498. // Creates a new object with the specified `formats` merged with the default
  1499. // formats.
  1500. formats = this._mergeFormats(MessageFormat.formats, formats);
  1501. // Defined first because it's used to build the format pattern.
  1502. es5.defineProperty(this, '_locale', {value: this._resolveLocale(locales)});
  1503. // Compile the `ast` to a pattern that is highly optimized for repeated
  1504. // `format()` invocations. **Note:** This passes the `locales` set provided
  1505. // to the constructor instead of just the resolved locale.
  1506. var pluralFn = this._findPluralRuleFunction(this._locale);
  1507. var pattern = this._compilePattern(ast, locales, formats, pluralFn);
  1508. // "Bind" `format()` method to `this` so it can be passed by reference like
  1509. // the other `Intl` APIs.
  1510. var messageFormat = this;
  1511. this.format = function (values) {
  1512. try {
  1513. return messageFormat._format(pattern, values);
  1514. } catch (e) {
  1515. if (e.variableId) {
  1516. throw new Error(
  1517. 'The intl string context variable \'' + e.variableId + '\'' +
  1518. ' was not provided to the string \'' + message + '\''
  1519. );
  1520. } else {
  1521. throw e;
  1522. }
  1523. }
  1524. };
  1525. }
  1526. // Default format options used as the prototype of the `formats` provided to the
  1527. // constructor. These are used when constructing the internal Intl.NumberFormat
  1528. // and Intl.DateTimeFormat instances.
  1529. es5.defineProperty(MessageFormat, 'formats', {
  1530. enumerable: true,
  1531. value: {
  1532. number: {
  1533. 'currency': {
  1534. style: 'currency'
  1535. },
  1536. 'percent': {
  1537. style: 'percent'
  1538. }
  1539. },
  1540. date: {
  1541. 'short': {
  1542. month: 'numeric',
  1543. day : 'numeric',
  1544. year : '2-digit'
  1545. },
  1546. 'medium': {
  1547. month: 'short',
  1548. day : 'numeric',
  1549. year : 'numeric'
  1550. },
  1551. 'long': {
  1552. month: 'long',
  1553. day : 'numeric',
  1554. year : 'numeric'
  1555. },
  1556. 'full': {
  1557. weekday: 'long',
  1558. month : 'long',
  1559. day : 'numeric',
  1560. year : 'numeric'
  1561. }
  1562. },
  1563. time: {
  1564. 'short': {
  1565. hour : 'numeric',
  1566. minute: 'numeric'
  1567. },
  1568. 'medium': {
  1569. hour : 'numeric',
  1570. minute: 'numeric',
  1571. second: 'numeric'
  1572. },
  1573. 'long': {
  1574. hour : 'numeric',
  1575. minute : 'numeric',
  1576. second : 'numeric',
  1577. timeZoneName: 'short'
  1578. },
  1579. 'full': {
  1580. hour : 'numeric',
  1581. minute : 'numeric',
  1582. second : 'numeric',
  1583. timeZoneName: 'short'
  1584. }
  1585. }
  1586. }
  1587. });
  1588. // Define internal private properties for dealing with locale data.
  1589. es5.defineProperty(MessageFormat, '__localeData__', {value: es5.objCreate(null)});
  1590. es5.defineProperty(MessageFormat, '__addLocaleData', {value: function (data) {
  1591. if (!(data && data.locale)) {
  1592. throw new Error(
  1593. 'Locale data provided to IntlMessageFormat is missing a ' +
  1594. '`locale` property'
  1595. );
  1596. }
  1597. MessageFormat.__localeData__[data.locale.toLowerCase()] = data;
  1598. }});
  1599. // Defines `__parse()` static method as an exposed private.
  1600. es5.defineProperty(MessageFormat, '__parse', {value: intlMessageformatParser["default"].parse});
  1601. // Define public `defaultLocale` property which defaults to English, but can be
  1602. // set by the developer.
  1603. es5.defineProperty(MessageFormat, 'defaultLocale', {
  1604. enumerable: true,
  1605. writable : true,
  1606. value : undefined
  1607. });
  1608. MessageFormat.prototype.resolvedOptions = function () {
  1609. // TODO: Provide anything else?
  1610. return {
  1611. locale: this._locale
  1612. };
  1613. };
  1614. MessageFormat.prototype._compilePattern = function (ast, locales, formats, pluralFn) {
  1615. var compiler$1 = new compiler["default"](locales, formats, pluralFn);
  1616. return compiler$1.compile(ast);
  1617. };
  1618. MessageFormat.prototype._findPluralRuleFunction = function (locale) {
  1619. var localeData = MessageFormat.__localeData__;
  1620. var data = localeData[locale.toLowerCase()];
  1621. // The locale data is de-duplicated, so we have to traverse the locale's
  1622. // hierarchy until we find a `pluralRuleFunction` to return.
  1623. while (data) {
  1624. if (data.pluralRuleFunction) {
  1625. return data.pluralRuleFunction;
  1626. }
  1627. data = data.parentLocale && localeData[data.parentLocale.toLowerCase()];
  1628. }
  1629. throw new Error(
  1630. 'Locale data added to IntlMessageFormat is missing a ' +
  1631. '`pluralRuleFunction` for :' + locale
  1632. );
  1633. };
  1634. MessageFormat.prototype._format = function (pattern, values) {
  1635. var result = '',
  1636. i, len, part, id, value, err;
  1637. for (i = 0, len = pattern.length; i < len; i += 1) {
  1638. part = pattern[i];
  1639. // Exist early for string parts.
  1640. if (typeof part === 'string') {
  1641. result += part;
  1642. continue;
  1643. }
  1644. id = part.id;
  1645. // Enforce that all required values are provided by the caller.
  1646. if (!(values && utils.hop.call(values, id))) {
  1647. err = new Error('A value must be provided for: ' + id);
  1648. err.variableId = id;
  1649. throw err;
  1650. }
  1651. value = values[id];
  1652. // Recursively format plural and select parts' option — which can be a
  1653. // nested pattern structure. The choosing of the option to use is
  1654. // abstracted-by and delegated-to the part helper object.
  1655. if (part.options) {
  1656. result += this._format(part.getOption(value), values);
  1657. } else {
  1658. result += part.format(value);
  1659. }
  1660. }
  1661. return result;
  1662. };
  1663. MessageFormat.prototype._mergeFormats = function (defaults, formats) {
  1664. var mergedFormats = {},
  1665. type, mergedType;
  1666. for (type in defaults) {
  1667. if (!utils.hop.call(defaults, type)) { continue; }
  1668. mergedFormats[type] = mergedType = es5.objCreate(defaults[type]);
  1669. if (formats && utils.hop.call(formats, type)) {
  1670. utils.extend(mergedType, formats[type]);
  1671. }
  1672. }
  1673. return mergedFormats;
  1674. };
  1675. MessageFormat.prototype._resolveLocale = function (locales) {
  1676. if (typeof locales === 'string') {
  1677. locales = [locales];
  1678. }
  1679. // Create a copy of the array so we can push on the default locale.
  1680. locales = (locales || []).concat(MessageFormat.defaultLocale);
  1681. var localeData = MessageFormat.__localeData__;
  1682. var i, len, localeParts, data;
  1683. // Using the set of locales + the default locale, we look for the first one
  1684. // which that has been registered. When data does not exist for a locale, we
  1685. // traverse its ancestors to find something that's been registered within
  1686. // its hierarchy of locales. Since we lack the proper `parentLocale` data
  1687. // here, we must take a naive approach to traversal.
  1688. for (i = 0, len = locales.length; i < len; i += 1) {
  1689. localeParts = locales[i].toLowerCase().split('-');
  1690. while (localeParts.length) {
  1691. data = localeData[localeParts.join('-')];
  1692. if (data) {
  1693. // Return the normalized locale string; e.g., we return "en-US",
  1694. // instead of "en-us".
  1695. return data.locale;
  1696. }
  1697. localeParts.pop();
  1698. }
  1699. }
  1700. var defaultLocale = locales.pop();
  1701. throw new Error(
  1702. 'No locale data has been added to IntlMessageFormat for: ' +
  1703. locales.join(', ') + ', or the default locale: ' + defaultLocale
  1704. );
  1705. };
  1706. });
  1707. var en = styleInject_es.createCommonjsModule(function (module, exports) {
  1708. exports["default"] = {"locale":"en","pluralRuleFunction":function (n,ord){var s=String(n).split("."),v0=!s[1],t0=Number(s[0])==n,n10=t0&&s[0].slice(-1),n100=t0&&s[0].slice(-2);if(ord)return n10==1&&n100!=11?"one":n10==2&&n100!=12?"two":n10==3&&n100!=13?"few":"other";return n==1&&v0?"one":"other"}};
  1709. });
  1710. var main = styleInject_es.createCommonjsModule(function (module, exports) {
  1711. core["default"].__addLocaleData(en["default"]);
  1712. core["default"].defaultLocale = 'en';
  1713. exports["default"] = core["default"];
  1714. });
  1715. var _nodeResolve_empty = {};
  1716. var _nodeResolve_empty$1 = /*#__PURE__*/Object.freeze({
  1717. __proto__: null,
  1718. 'default': _nodeResolve_empty
  1719. });
  1720. styleInject_es.getCjsExportFromNamespace(_nodeResolve_empty$1);
  1721. var intlMessageformat = styleInject_es.createCommonjsModule(function (module, exports) {
  1722. var IntlMessageFormat = main['default'];
  1723. // Add all locale data to `IntlMessageFormat`. This module will be ignored when
  1724. // bundling for the browser with Browserify/Webpack.
  1725. // Re-export `IntlMessageFormat` as the CommonJS default exports with all the
  1726. // locale data registered, and with English set as the default locale. Define
  1727. // the `default` prop for use with other compiled ES6 Modules.
  1728. exports = module.exports = IntlMessageFormat;
  1729. exports['default'] = exports;
  1730. });
  1731. /**
  1732. * lodash (Custom Build) <https://lodash.com/>
  1733. * Build: `lodash modularize exports="npm" -o ./`
  1734. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  1735. * Released under MIT license <https://lodash.com/license>
  1736. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  1737. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  1738. */
  1739. /** Used as the `TypeError` message for "Functions" methods. */
  1740. var FUNC_ERROR_TEXT = 'Expected a function';
  1741. /** Used to stand-in for `undefined` hash values. */
  1742. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  1743. /** Used as references for various `Number` constants. */
  1744. var INFINITY = 1 / 0;
  1745. /** `Object#toString` result references. */
  1746. var funcTag = '[object Function]',
  1747. genTag = '[object GeneratorFunction]',
  1748. symbolTag = '[object Symbol]';
  1749. /** Used to match property names within property paths. */
  1750. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  1751. reIsPlainProp = /^\w*$/,
  1752. reLeadingDot = /^\./,
  1753. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  1754. /**
  1755. * Used to match `RegExp`
  1756. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  1757. */
  1758. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  1759. /** Used to match backslashes in property paths. */
  1760. var reEscapeChar = /\\(\\)?/g;
  1761. /** Used to detect host constructors (Safari). */
  1762. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  1763. /** Detect free variable `global` from Node.js. */
  1764. var freeGlobal = typeof styleInject_es.commonjsGlobal == 'object' && styleInject_es.commonjsGlobal && styleInject_es.commonjsGlobal.Object === Object && styleInject_es.commonjsGlobal;
  1765. /** Detect free variable `self`. */
  1766. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  1767. /** Used as a reference to the global object. */
  1768. var root = freeGlobal || freeSelf || Function('return this')();
  1769. /**
  1770. * Gets the value at `key` of `object`.
  1771. *
  1772. * @private
  1773. * @param {Object} [object] The object to query.
  1774. * @param {string} key The key of the property to get.
  1775. * @returns {*} Returns the property value.
  1776. */
  1777. function getValue(object, key) {
  1778. return object == null ? undefined : object[key];
  1779. }
  1780. /**
  1781. * Checks if `value` is a host object in IE < 9.
  1782. *
  1783. * @private
  1784. * @param {*} value The value to check.
  1785. * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
  1786. */
  1787. function isHostObject(value) {
  1788. // Many host objects are `Object` objects that can coerce to strings
  1789. // despite having improperly defined `toString` methods.
  1790. var result = false;
  1791. if (value != null && typeof value.toString != 'function') {
  1792. try {
  1793. result = !!(value + '');
  1794. } catch (e) {}
  1795. }
  1796. return result;
  1797. }
  1798. /** Used for built-in method references. */
  1799. var arrayProto = Array.prototype,
  1800. funcProto = Function.prototype,
  1801. objectProto = Object.prototype;
  1802. /** Used to detect overreaching core-js shims. */
  1803. var coreJsData = root['__core-js_shared__'];
  1804. /** Used to detect methods masquerading as native. */
  1805. var maskSrcKey = (function() {
  1806. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  1807. return uid ? ('Symbol(src)_1.' + uid) : '';
  1808. }());
  1809. /** Used to resolve the decompiled source of functions. */
  1810. var funcToString = funcProto.toString;
  1811. /** Used to check objects for own properties. */
  1812. var hasOwnProperty = objectProto.hasOwnProperty;
  1813. /**
  1814. * Used to resolve the
  1815. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  1816. * of values.
  1817. */
  1818. var objectToString = objectProto.toString;
  1819. /** Used to detect if a method is native. */
  1820. var reIsNative = RegExp('^' +
  1821. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  1822. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  1823. );
  1824. /** Built-in value references. */
  1825. var Symbol = root.Symbol,
  1826. splice = arrayProto.splice;
  1827. /* Built-in method references that are verified to be native. */
  1828. var Map = getNative(root, 'Map'),
  1829. nativeCreate = getNative(Object, 'create');
  1830. /** Used to convert symbols to primitives and strings. */
  1831. var symbolProto = Symbol ? Symbol.prototype : undefined,
  1832. symbolToString = symbolProto ? symbolProto.toString : undefined;
  1833. /**
  1834. * Creates a hash object.
  1835. *
  1836. * @private
  1837. * @constructor
  1838. * @param {Array} [entries] The key-value pairs to cache.
  1839. */
  1840. function Hash(entries) {
  1841. var index = -1,
  1842. length = entries ? entries.length : 0;
  1843. this.clear();
  1844. while (++index < length) {
  1845. var entry = entries[index];
  1846. this.set(entry[0], entry[1]);
  1847. }
  1848. }
  1849. /**
  1850. * Removes all key-value entries from the hash.
  1851. *
  1852. * @private
  1853. * @name clear
  1854. * @memberOf Hash
  1855. */
  1856. function hashClear() {
  1857. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  1858. }
  1859. /**
  1860. * Removes `key` and its value from the hash.
  1861. *
  1862. * @private
  1863. * @name delete
  1864. * @memberOf Hash
  1865. * @param {Object} hash The hash to modify.
  1866. * @param {string} key The key of the value to remove.
  1867. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  1868. */
  1869. function hashDelete(key) {
  1870. return this.has(key) && delete this.__data__[key];
  1871. }
  1872. /**
  1873. * Gets the hash value for `key`.
  1874. *
  1875. * @private
  1876. * @name get
  1877. * @memberOf Hash
  1878. * @param {string} key The key of the value to get.
  1879. * @returns {*} Returns the entry value.
  1880. */
  1881. function hashGet(key) {
  1882. var data = this.__data__;
  1883. if (nativeCreate) {
  1884. var result = data[key];
  1885. return result === HASH_UNDEFINED ? undefined : result;
  1886. }
  1887. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  1888. }
  1889. /**
  1890. * Checks if a hash value for `key` exists.
  1891. *
  1892. * @private
  1893. * @name has
  1894. * @memberOf Hash
  1895. * @param {string} key The key of the entry to check.
  1896. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  1897. */
  1898. function hashHas(key) {
  1899. var data = this.__data__;
  1900. return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
  1901. }
  1902. /**
  1903. * Sets the hash `key` to `value`.
  1904. *
  1905. * @private
  1906. * @name set
  1907. * @memberOf Hash
  1908. * @param {string} key The key of the value to set.
  1909. * @param {*} value The value to set.
  1910. * @returns {Object} Returns the hash instance.
  1911. */
  1912. function hashSet(key, value) {
  1913. var data = this.__data__;
  1914. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  1915. return this;
  1916. }
  1917. // Add methods to `Hash`.
  1918. Hash.prototype.clear = hashClear;
  1919. Hash.prototype['delete'] = hashDelete;
  1920. Hash.prototype.get = hashGet;
  1921. Hash.prototype.has = hashHas;
  1922. Hash.prototype.set = hashSet;
  1923. /**
  1924. * Creates an list cache object.
  1925. *
  1926. * @private
  1927. * @constructor
  1928. * @param {Array} [entries] The key-value pairs to cache.
  1929. */
  1930. function ListCache(entries) {
  1931. var index = -1,
  1932. length = entries ? entries.length : 0;
  1933. this.clear();
  1934. while (++index < length) {
  1935. var entry = entries[index];
  1936. this.set(entry[0], entry[1]);
  1937. }
  1938. }
  1939. /**
  1940. * Removes all key-value entries from the list cache.
  1941. *
  1942. * @private
  1943. * @name clear
  1944. * @memberOf ListCache
  1945. */
  1946. function listCacheClear() {
  1947. this.__data__ = [];
  1948. }
  1949. /**
  1950. * Removes `key` and its value from the list cache.
  1951. *
  1952. * @private
  1953. * @name delete
  1954. * @memberOf ListCache
  1955. * @param {string} key The key of the value to remove.
  1956. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  1957. */
  1958. function listCacheDelete(key) {
  1959. var data = this.__data__,
  1960. index = assocIndexOf(data, key);
  1961. if (index < 0) {
  1962. return false;
  1963. }
  1964. var lastIndex = data.length - 1;
  1965. if (index == lastIndex) {
  1966. data.pop();
  1967. } else {
  1968. splice.call(data, index, 1);
  1969. }
  1970. return true;
  1971. }
  1972. /**
  1973. * Gets the list cache value for `key`.
  1974. *
  1975. * @private
  1976. * @name get
  1977. * @memberOf ListCache
  1978. * @param {string} key The key of the value to get.
  1979. * @returns {*} Returns the entry value.
  1980. */
  1981. function listCacheGet(key) {
  1982. var data = this.__data__,
  1983. index = assocIndexOf(data, key);
  1984. return index < 0 ? undefined : data[index][1];
  1985. }
  1986. /**
  1987. * Checks if a list cache value for `key` exists.
  1988. *
  1989. * @private
  1990. * @name has
  1991. * @memberOf ListCache
  1992. * @param {string} key The key of the entry to check.
  1993. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  1994. */
  1995. function listCacheHas(key) {
  1996. return assocIndexOf(this.__data__, key) > -1;
  1997. }
  1998. /**
  1999. * Sets the list cache `key` to `value`.
  2000. *
  2001. * @private
  2002. * @name set
  2003. * @memberOf ListCache
  2004. * @param {string} key The key of the value to set.
  2005. * @param {*} value The value to set.
  2006. * @returns {Object} Returns the list cache instance.
  2007. */
  2008. function listCacheSet(key, value) {
  2009. var data = this.__data__,
  2010. index = assocIndexOf(data, key);
  2011. if (index < 0) {
  2012. data.push([key, value]);
  2013. } else {
  2014. data[index][1] = value;
  2015. }
  2016. return this;
  2017. }
  2018. // Add methods to `ListCache`.
  2019. ListCache.prototype.clear = listCacheClear;
  2020. ListCache.prototype['delete'] = listCacheDelete;
  2021. ListCache.prototype.get = listCacheGet;
  2022. ListCache.prototype.has = listCacheHas;
  2023. ListCache.prototype.set = listCacheSet;
  2024. /**
  2025. * Creates a map cache object to store key-value pairs.
  2026. *
  2027. * @private
  2028. * @constructor
  2029. * @param {Array} [entries] The key-value pairs to cache.
  2030. */
  2031. function MapCache(entries) {
  2032. var index = -1,
  2033. length = entries ? entries.length : 0;
  2034. this.clear();
  2035. while (++index < length) {
  2036. var entry = entries[index];
  2037. this.set(entry[0], entry[1]);
  2038. }
  2039. }
  2040. /**
  2041. * Removes all key-value entries from the map.
  2042. *
  2043. * @private
  2044. * @name clear
  2045. * @memberOf MapCache
  2046. */
  2047. function mapCacheClear() {
  2048. this.__data__ = {
  2049. 'hash': new Hash,
  2050. 'map': new (Map || ListCache),
  2051. 'string': new Hash
  2052. };
  2053. }
  2054. /**
  2055. * Removes `key` and its value from the map.
  2056. *
  2057. * @private
  2058. * @name delete
  2059. * @memberOf MapCache
  2060. * @param {string} key The key of the value to remove.
  2061. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2062. */
  2063. function mapCacheDelete(key) {
  2064. return getMapData(this, key)['delete'](key);
  2065. }
  2066. /**
  2067. * Gets the map value for `key`.
  2068. *
  2069. * @private
  2070. * @name get
  2071. * @memberOf MapCache
  2072. * @param {string} key The key of the value to get.
  2073. * @returns {*} Returns the entry value.
  2074. */
  2075. function mapCacheGet(key) {
  2076. return getMapData(this, key).get(key);
  2077. }
  2078. /**
  2079. * Checks if a map value for `key` exists.
  2080. *
  2081. * @private
  2082. * @name has
  2083. * @memberOf MapCache
  2084. * @param {string} key The key of the entry to check.
  2085. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2086. */
  2087. function mapCacheHas(key) {
  2088. return getMapData(this, key).has(key);
  2089. }
  2090. /**
  2091. * Sets the map `key` to `value`.
  2092. *
  2093. * @private
  2094. * @name set
  2095. * @memberOf MapCache
  2096. * @param {string} key The key of the value to set.
  2097. * @param {*} value The value to set.
  2098. * @returns {Object} Returns the map cache instance.
  2099. */
  2100. function mapCacheSet(key, value) {
  2101. getMapData(this, key).set(key, value);
  2102. return this;
  2103. }
  2104. // Add methods to `MapCache`.
  2105. MapCache.prototype.clear = mapCacheClear;
  2106. MapCache.prototype['delete'] = mapCacheDelete;
  2107. MapCache.prototype.get = mapCacheGet;
  2108. MapCache.prototype.has = mapCacheHas;
  2109. MapCache.prototype.set = mapCacheSet;
  2110. /**
  2111. * Gets the index at which the `key` is found in `array` of key-value pairs.
  2112. *
  2113. * @private
  2114. * @param {Array} array The array to inspect.
  2115. * @param {*} key The key to search for.
  2116. * @returns {number} Returns the index of the matched value, else `-1`.
  2117. */
  2118. function assocIndexOf(array, key) {
  2119. var length = array.length;
  2120. while (length--) {
  2121. if (eq(array[length][0], key)) {
  2122. return length;
  2123. }
  2124. }
  2125. return -1;
  2126. }
  2127. /**
  2128. * The base implementation of `_.get` without support for default values.
  2129. *
  2130. * @private
  2131. * @param {Object} object The object to query.
  2132. * @param {Array|string} path The path of the property to get.
  2133. * @returns {*} Returns the resolved value.
  2134. */
  2135. function baseGet(object, path) {
  2136. path = isKey(path, object) ? [path] : castPath(path);
  2137. var index = 0,
  2138. length = path.length;
  2139. while (object != null && index < length) {
  2140. object = object[toKey(path[index++])];
  2141. }
  2142. return (index && index == length) ? object : undefined;
  2143. }
  2144. /**
  2145. * The base implementation of `_.isNative` without bad shim checks.
  2146. *
  2147. * @private
  2148. * @param {*} value The value to check.
  2149. * @returns {boolean} Returns `true` if `value` is a native function,
  2150. * else `false`.
  2151. */
  2152. function baseIsNative(value) {
  2153. if (!isObject(value) || isMasked(value)) {
  2154. return false;
  2155. }
  2156. var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
  2157. return pattern.test(toSource(value));
  2158. }
  2159. /**
  2160. * The base implementation of `_.toString` which doesn't convert nullish
  2161. * values to empty strings.
  2162. *
  2163. * @private
  2164. * @param {*} value The value to process.
  2165. * @returns {string} Returns the string.
  2166. */
  2167. function baseToString(value) {
  2168. // Exit early for strings to avoid a performance hit in some environments.
  2169. if (typeof value == 'string') {
  2170. return value;
  2171. }
  2172. if (isSymbol(value)) {
  2173. return symbolToString ? symbolToString.call(value) : '';
  2174. }
  2175. var result = (value + '');
  2176. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  2177. }
  2178. /**
  2179. * Casts `value` to a path array if it's not one.
  2180. *
  2181. * @private
  2182. * @param {*} value The value to inspect.
  2183. * @returns {Array} Returns the cast property path array.
  2184. */
  2185. function castPath(value) {
  2186. return isArray(value) ? value : stringToPath(value);
  2187. }
  2188. /**
  2189. * Gets the data for `map`.
  2190. *
  2191. * @private
  2192. * @param {Object} map The map to query.
  2193. * @param {string} key The reference key.
  2194. * @returns {*} Returns the map data.
  2195. */
  2196. function getMapData(map, key) {
  2197. var data = map.__data__;
  2198. return isKeyable(key)
  2199. ? data[typeof key == 'string' ? 'string' : 'hash']
  2200. : data.map;
  2201. }
  2202. /**
  2203. * Gets the native function at `key` of `object`.
  2204. *
  2205. * @private
  2206. * @param {Object} object The object to query.
  2207. * @param {string} key The key of the method to get.
  2208. * @returns {*} Returns the function if it's native, else `undefined`.
  2209. */
  2210. function getNative(object, key) {
  2211. var value = getValue(object, key);
  2212. return baseIsNative(value) ? value : undefined;
  2213. }
  2214. /**
  2215. * Checks if `value` is a property name and not a property path.
  2216. *
  2217. * @private
  2218. * @param {*} value The value to check.
  2219. * @param {Object} [object] The object to query keys on.
  2220. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  2221. */
  2222. function isKey(value, object) {
  2223. if (isArray(value)) {
  2224. return false;
  2225. }
  2226. var type = typeof value;
  2227. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  2228. value == null || isSymbol(value)) {
  2229. return true;
  2230. }
  2231. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  2232. (object != null && value in Object(object));
  2233. }
  2234. /**
  2235. * Checks if `value` is suitable for use as unique object key.
  2236. *
  2237. * @private
  2238. * @param {*} value The value to check.
  2239. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  2240. */
  2241. function isKeyable(value) {
  2242. var type = typeof value;
  2243. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  2244. ? (value !== '__proto__')
  2245. : (value === null);
  2246. }
  2247. /**
  2248. * Checks if `func` has its source masked.
  2249. *
  2250. * @private
  2251. * @param {Function} func The function to check.
  2252. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  2253. */
  2254. function isMasked(func) {
  2255. return !!maskSrcKey && (maskSrcKey in func);
  2256. }
  2257. /**
  2258. * Converts `string` to a property path array.
  2259. *
  2260. * @private
  2261. * @param {string} string The string to convert.
  2262. * @returns {Array} Returns the property path array.
  2263. */
  2264. var stringToPath = memoize(function(string) {
  2265. string = toString(string);
  2266. var result = [];
  2267. if (reLeadingDot.test(string)) {
  2268. result.push('');
  2269. }
  2270. string.replace(rePropName, function(match, number, quote, string) {
  2271. result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
  2272. });
  2273. return result;
  2274. });
  2275. /**
  2276. * Converts `value` to a string key if it's not a string or symbol.
  2277. *
  2278. * @private
  2279. * @param {*} value The value to inspect.
  2280. * @returns {string|symbol} Returns the key.
  2281. */
  2282. function toKey(value) {
  2283. if (typeof value == 'string' || isSymbol(value)) {
  2284. return value;
  2285. }
  2286. var result = (value + '');
  2287. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  2288. }
  2289. /**
  2290. * Converts `func` to its source code.
  2291. *
  2292. * @private
  2293. * @param {Function} func The function to process.
  2294. * @returns {string} Returns the source code.
  2295. */
  2296. function toSource(func) {
  2297. if (func != null) {
  2298. try {
  2299. return funcToString.call(func);
  2300. } catch (e) {}
  2301. try {
  2302. return (func + '');
  2303. } catch (e) {}
  2304. }
  2305. return '';
  2306. }
  2307. /**
  2308. * Creates a function that memoizes the result of `func`. If `resolver` is
  2309. * provided, it determines the cache key for storing the result based on the
  2310. * arguments provided to the memoized function. By default, the first argument
  2311. * provided to the memoized function is used as the map cache key. The `func`
  2312. * is invoked with the `this` binding of the memoized function.
  2313. *
  2314. * **Note:** The cache is exposed as the `cache` property on the memoized
  2315. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  2316. * constructor with one whose instances implement the
  2317. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  2318. * method interface of `delete`, `get`, `has`, and `set`.
  2319. *
  2320. * @static
  2321. * @memberOf _
  2322. * @since 0.1.0
  2323. * @category Function
  2324. * @param {Function} func The function to have its output memoized.
  2325. * @param {Function} [resolver] The function to resolve the cache key.
  2326. * @returns {Function} Returns the new memoized function.
  2327. * @example
  2328. *
  2329. * var object = { 'a': 1, 'b': 2 };
  2330. * var other = { 'c': 3, 'd': 4 };
  2331. *
  2332. * var values = _.memoize(_.values);
  2333. * values(object);
  2334. * // => [1, 2]
  2335. *
  2336. * values(other);
  2337. * // => [3, 4]
  2338. *
  2339. * object.a = 2;
  2340. * values(object);
  2341. * // => [1, 2]
  2342. *
  2343. * // Modify the result cache.
  2344. * values.cache.set(object, ['a', 'b']);
  2345. * values(object);
  2346. * // => ['a', 'b']
  2347. *
  2348. * // Replace `_.memoize.Cache`.
  2349. * _.memoize.Cache = WeakMap;
  2350. */
  2351. function memoize(func, resolver) {
  2352. if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {
  2353. throw new TypeError(FUNC_ERROR_TEXT);
  2354. }
  2355. var memoized = function() {
  2356. var args = arguments,
  2357. key = resolver ? resolver.apply(this, args) : args[0],
  2358. cache = memoized.cache;
  2359. if (cache.has(key)) {
  2360. return cache.get(key);
  2361. }
  2362. var result = func.apply(this, args);
  2363. memoized.cache = cache.set(key, result);
  2364. return result;
  2365. };
  2366. memoized.cache = new (memoize.Cache || MapCache);
  2367. return memoized;
  2368. }
  2369. // Assign cache to `_.memoize`.
  2370. memoize.Cache = MapCache;
  2371. /**
  2372. * Performs a
  2373. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  2374. * comparison between two values to determine if they are equivalent.
  2375. *
  2376. * @static
  2377. * @memberOf _
  2378. * @since 4.0.0
  2379. * @category Lang
  2380. * @param {*} value The value to compare.
  2381. * @param {*} other The other value to compare.
  2382. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  2383. * @example
  2384. *
  2385. * var object = { 'a': 1 };
  2386. * var other = { 'a': 1 };
  2387. *
  2388. * _.eq(object, object);
  2389. * // => true
  2390. *
  2391. * _.eq(object, other);
  2392. * // => false
  2393. *
  2394. * _.eq('a', 'a');
  2395. * // => true
  2396. *
  2397. * _.eq('a', Object('a'));
  2398. * // => false
  2399. *
  2400. * _.eq(NaN, NaN);
  2401. * // => true
  2402. */
  2403. function eq(value, other) {
  2404. return value === other || (value !== value && other !== other);
  2405. }
  2406. /**
  2407. * Checks if `value` is classified as an `Array` object.
  2408. *
  2409. * @static
  2410. * @memberOf _
  2411. * @since 0.1.0
  2412. * @category Lang
  2413. * @param {*} value The value to check.
  2414. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  2415. * @example
  2416. *
  2417. * _.isArray([1, 2, 3]);
  2418. * // => true
  2419. *
  2420. * _.isArray(document.body.children);
  2421. * // => false
  2422. *
  2423. * _.isArray('abc');
  2424. * // => false
  2425. *
  2426. * _.isArray(_.noop);
  2427. * // => false
  2428. */
  2429. var isArray = Array.isArray;
  2430. /**
  2431. * Checks if `value` is classified as a `Function` object.
  2432. *
  2433. * @static
  2434. * @memberOf _
  2435. * @since 0.1.0
  2436. * @category Lang
  2437. * @param {*} value The value to check.
  2438. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  2439. * @example
  2440. *
  2441. * _.isFunction(_);
  2442. * // => true
  2443. *
  2444. * _.isFunction(/abc/);
  2445. * // => false
  2446. */
  2447. function isFunction(value) {
  2448. // The use of `Object#toString` avoids issues with the `typeof` operator
  2449. // in Safari 8-9 which returns 'object' for typed array and other constructors.
  2450. var tag = isObject(value) ? objectToString.call(value) : '';
  2451. return tag == funcTag || tag == genTag;
  2452. }
  2453. /**
  2454. * Checks if `value` is the
  2455. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  2456. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  2457. *
  2458. * @static
  2459. * @memberOf _
  2460. * @since 0.1.0
  2461. * @category Lang
  2462. * @param {*} value The value to check.
  2463. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  2464. * @example
  2465. *
  2466. * _.isObject({});
  2467. * // => true
  2468. *
  2469. * _.isObject([1, 2, 3]);
  2470. * // => true
  2471. *
  2472. * _.isObject(_.noop);
  2473. * // => true
  2474. *
  2475. * _.isObject(null);
  2476. * // => false
  2477. */
  2478. function isObject(value) {
  2479. var type = typeof value;
  2480. return !!value && (type == 'object' || type == 'function');
  2481. }
  2482. /**
  2483. * Checks if `value` is object-like. A value is object-like if it's not `null`
  2484. * and has a `typeof` result of "object".
  2485. *
  2486. * @static
  2487. * @memberOf _
  2488. * @since 4.0.0
  2489. * @category Lang
  2490. * @param {*} value The value to check.
  2491. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  2492. * @example
  2493. *
  2494. * _.isObjectLike({});
  2495. * // => true
  2496. *
  2497. * _.isObjectLike([1, 2, 3]);
  2498. * // => true
  2499. *
  2500. * _.isObjectLike(_.noop);
  2501. * // => false
  2502. *
  2503. * _.isObjectLike(null);
  2504. * // => false
  2505. */
  2506. function isObjectLike(value) {
  2507. return !!value && typeof value == 'object';
  2508. }
  2509. /**
  2510. * Checks if `value` is classified as a `Symbol` primitive or object.
  2511. *
  2512. * @static
  2513. * @memberOf _
  2514. * @since 4.0.0
  2515. * @category Lang
  2516. * @param {*} value The value to check.
  2517. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  2518. * @example
  2519. *
  2520. * _.isSymbol(Symbol.iterator);
  2521. * // => true
  2522. *
  2523. * _.isSymbol('abc');
  2524. * // => false
  2525. */
  2526. function isSymbol(value) {
  2527. return typeof value == 'symbol' ||
  2528. (isObjectLike(value) && objectToString.call(value) == symbolTag);
  2529. }
  2530. /**
  2531. * Converts `value` to a string. An empty string is returned for `null`
  2532. * and `undefined` values. The sign of `-0` is preserved.
  2533. *
  2534. * @static
  2535. * @memberOf _
  2536. * @since 4.0.0
  2537. * @category Lang
  2538. * @param {*} value The value to process.
  2539. * @returns {string} Returns the string.
  2540. * @example
  2541. *
  2542. * _.toString(null);
  2543. * // => ''
  2544. *
  2545. * _.toString(-0);
  2546. * // => '-0'
  2547. *
  2548. * _.toString([1, 2, 3]);
  2549. * // => '1,2,3'
  2550. */
  2551. function toString(value) {
  2552. return value == null ? '' : baseToString(value);
  2553. }
  2554. /**
  2555. * Gets the value at `path` of `object`. If the resolved value is
  2556. * `undefined`, the `defaultValue` is returned in its place.
  2557. *
  2558. * @static
  2559. * @memberOf _
  2560. * @since 3.7.0
  2561. * @category Object
  2562. * @param {Object} object The object to query.
  2563. * @param {Array|string} path The path of the property to get.
  2564. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  2565. * @returns {*} Returns the resolved value.
  2566. * @example
  2567. *
  2568. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  2569. *
  2570. * _.get(object, 'a[0].b.c');
  2571. * // => 3
  2572. *
  2573. * _.get(object, ['a', '0', 'b', 'c']);
  2574. * // => 3
  2575. *
  2576. * _.get(object, 'a.b.c', 'default');
  2577. * // => 'default'
  2578. */
  2579. function get(object, path, defaultValue) {
  2580. var result = object == null ? undefined : baseGet(object, path);
  2581. return result === undefined ? defaultValue : result;
  2582. }
  2583. var lodash_get = get;
  2584. var Observer_1 = styleInject_es.createCommonjsModule(function (module, exports) {
  2585. Object.defineProperty(exports, "__esModule", { value: true });
  2586. var Observer = function (obj) {
  2587. Object.keys(obj.__data__ || obj).forEach(function (key) {
  2588. defineReactive(obj, key);
  2589. });
  2590. return obj;
  2591. };
  2592. var observe = function (value) {
  2593. if (!value || typeof value !== 'object') {
  2594. return;
  2595. }
  2596. Observer(value);
  2597. };
  2598. var defineReactive = function (obj, key) {
  2599. var childObj = observe(obj[key]);
  2600. Object.defineProperty(obj, key, {
  2601. get: function () {
  2602. if (obj.__data__[key]) {
  2603. return obj.__data__[key];
  2604. }
  2605. else if (obj.__metas__['zh-CN'][key]) {
  2606. return obj.__metas__['zh-CN'][key];
  2607. }
  2608. },
  2609. set: function (newVal) {
  2610. if (obj[key] === newVal) {
  2611. return;
  2612. }
  2613. obj[key] = newVal;
  2614. var cb = obj.callback[key];
  2615. cb.call(obj);
  2616. childObj = observe(newVal);
  2617. }
  2618. });
  2619. };
  2620. exports.default = Observer;
  2621. });
  2622. styleInject_es.unwrapExports(Observer_1);
  2623. var src = styleInject_es.createCommonjsModule(function (module, exports) {
  2624. var __assign = (styleInject_es.commonjsGlobal && styleInject_es.commonjsGlobal.__assign) || Object.assign || function(t) {
  2625. for (var s, i = 1, n = arguments.length; i < n; i++) {
  2626. s = arguments[i];
  2627. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  2628. t[p] = s[p];
  2629. }
  2630. return t;
  2631. };
  2632. Object.defineProperty(exports, "__esModule", { value: true });
  2633. var I18N = (function () {
  2634. function I18N(lang, metas) {
  2635. this.__lang__ = lang;
  2636. this.__metas__ = metas;
  2637. this.__data__ = metas[lang];
  2638. }
  2639. I18N.prototype.setLang = function (lang) {
  2640. this.__lang__ = lang;
  2641. this.__data__ = this.__metas__[lang];
  2642. };
  2643. I18N.prototype.getProp = function (obj, is, value) {
  2644. if (typeof is === 'string') {
  2645. is = is.split('.');
  2646. }
  2647. if (is.length === 1 && value !== undefined) {
  2648. return (obj[is[0]] = value);
  2649. }
  2650. else if (is.length === 0) {
  2651. return obj;
  2652. }
  2653. else {
  2654. var prop = is.shift();
  2655. if (value !== undefined && obj[prop] === undefined) {
  2656. obj[prop] = {};
  2657. }
  2658. return this.getProp(obj[prop], is, value);
  2659. }
  2660. };
  2661. I18N.prototype.template = function (str, args) {
  2662. var _this = this;
  2663. if (!str) {
  2664. return '';
  2665. }
  2666. return str.replace(/\{(.+?)\}/g, function (match, p1) {
  2667. return _this.getProp(__assign({}, _this.__data__, args), p1);
  2668. });
  2669. };
  2670. I18N.prototype.get = function (str, args) {
  2671. var msg = lodash_get(this.__data__, str);
  2672. if (!msg) {
  2673. msg = lodash_get(this.__metas__['zh-CN'], str, str);
  2674. }
  2675. if (args) {
  2676. try {
  2677. msg = new intlMessageformat.default(msg, this.__lang__);
  2678. msg = msg.format(args);
  2679. return msg;
  2680. }
  2681. catch (err) {
  2682. console.warn("kiwi-intl format message failed for key='" + str + "'", err);
  2683. return '';
  2684. }
  2685. }
  2686. else {
  2687. return msg;
  2688. }
  2689. };
  2690. return I18N;
  2691. }());
  2692. var IntlFormat = {
  2693. init: function (lang, metas) {
  2694. var i18n = new I18N(lang, metas);
  2695. return Observer_1.default(i18n);
  2696. }
  2697. };
  2698. exports.IntlFormat = IntlFormat;
  2699. exports.default = IntlFormat;
  2700. });
  2701. var KiwiIntl = styleInject_es.unwrapExports(src);
  2702. var src_1 = src.IntlFormat;
  2703. var priceOptions = {
  2704. "index": {
  2705. "others": "Others"
  2706. }
  2707. };
  2708. var payplatformoption = {
  2709. "platform": "支付平台"
  2710. };
  2711. var enUsLangs = Object.assign({}, {
  2712. priceOptions: priceOptions,
  2713. payplatformoption: payplatformoption
  2714. });
  2715. var priceOptions$1 = {
  2716. index: {
  2717. others: '其他金额'
  2718. }
  2719. };
  2720. var payplatformoption$1 = {
  2721. platform: '支付平台'
  2722. };
  2723. var zhCNLangs = Object.assign({}, {
  2724. priceOptions: priceOptions$1,
  2725. payplatformoption: payplatformoption$1
  2726. });
  2727. // type TransmitImgTxtData = {
  2728. // user_id?: string|number;
  2729. // anonymity?: boolean;
  2730. // avatar?: string;
  2731. // nickname?: string;
  2732. // is_long?: boolean;
  2733. // }
  2734. // interface TransmitCardProps {
  2735. // type: TransmitType;
  2736. // data: TransmitImgTxtData;
  2737. // }
  2738. // export class TransmitCard extends React.PureComponent<TransmitCardProps, {}> {
  2739. // renderVideo() {
  2740. // return <div className={styles.transmitVideoCard}>Video</div>;
  2741. // }
  2742. // renderImgTxt() {
  2743. // const { data } = this.props;
  2744. // const {
  2745. // user_id,
  2746. // anonymity,
  2747. // avatar,
  2748. // nickname,
  2749. // is_long,
  2750. // } = data;
  2751. // return (
  2752. // <div className={styles.transmitImgTxtCard}>
  2753. // <div className={styles.header}>
  2754. // <UserLink user_id={user_id} anonymity={anonymity}>
  2755. // <Avatar
  2756. // id={user_id}
  2757. // image={avatar}
  2758. // follow={false}
  2759. // size="cover"
  2760. // className={styles.ava}
  2761. // anonymity={anonymity}
  2762. // />
  2763. // </UserLink>
  2764. // <div className={styles.nickname}>
  2765. // <UserLink user_id={user_id} anonymity={anonymity}>
  2766. // {nickname}
  2767. // </UserLink>
  2768. // </div>
  2769. // <div className={styles.type}>
  2770. // {is_long
  2771. // ? intl.get('bilingually.imgtxt.article')
  2772. // : intl.get('bilingually.imgtxt')}
  2773. // </div>
  2774. // </div>
  2775. // </div>
  2776. // );
  2777. // }
  2778. // render() {
  2779. // const { type } = this.props;
  2780. // if (type === 'imgTxt') {
  2781. // this.renderImgTxt();
  2782. // }
  2783. // if (type === 'shortVideo' || type === 'microVideo') {
  2784. // this.renderVideo();
  2785. // }
  2786. // return null;
  2787. // }
  2788. // }
  2789. var Test = "TestComponent";
  2790. var langs = {
  2791. 'en_US': enUsLangs,
  2792. 'zh_CN': zhCNLangs
  2793. };
  2794. var kiwiIntl = KiwiIntl.init('en_US', langs);
  2795. exports.ConsumeListView = index$1.ConsumeListView;
  2796. exports.PayPlatformOptions = index$1.PayPlatformOptions;
  2797. exports.PriceOptions = index$1.PriceOptions;
  2798. exports.WaitPayInfoView = index$1.WaitPayInfoView;
  2799. exports.Test = Test;
  2800. exports.kiwiIntl = kiwiIntl;
  2801. //# sourceMappingURL=index.js.map