@everymatrix/casino-404 0.0.324

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4888 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
+ typeof define === 'function' && define.amd ? define(factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.app = factory());
5
+ })(this, (function () { 'use strict';
6
+
7
+ function noop() { }
8
+ function add_location(element, file, line, column, char) {
9
+ element.__svelte_meta = {
10
+ loc: { file, line, column, char }
11
+ };
12
+ }
13
+ function run(fn) {
14
+ return fn();
15
+ }
16
+ function blank_object() {
17
+ return Object.create(null);
18
+ }
19
+ function run_all(fns) {
20
+ fns.forEach(run);
21
+ }
22
+ function is_function(thing) {
23
+ return typeof thing === 'function';
24
+ }
25
+ function safe_not_equal(a, b) {
26
+ return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
27
+ }
28
+ function is_empty(obj) {
29
+ return Object.keys(obj).length === 0;
30
+ }
31
+ function validate_store(store, name) {
32
+ if (store != null && typeof store.subscribe !== 'function') {
33
+ throw new Error(`'${name}' is not a store with a 'subscribe' method`);
34
+ }
35
+ }
36
+ function subscribe(store, ...callbacks) {
37
+ if (store == null) {
38
+ return noop;
39
+ }
40
+ const unsub = store.subscribe(...callbacks);
41
+ return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;
42
+ }
43
+ function component_subscribe(component, store, callback) {
44
+ component.$$.on_destroy.push(subscribe(store, callback));
45
+ }
46
+ function append(target, node) {
47
+ target.appendChild(node);
48
+ }
49
+ function insert(target, node, anchor) {
50
+ target.insertBefore(node, anchor || null);
51
+ }
52
+ function detach(node) {
53
+ node.parentNode.removeChild(node);
54
+ }
55
+ function element(name) {
56
+ return document.createElement(name);
57
+ }
58
+ function svg_element(name) {
59
+ return document.createElementNS('http://www.w3.org/2000/svg', name);
60
+ }
61
+ function text(data) {
62
+ return document.createTextNode(data);
63
+ }
64
+ function space() {
65
+ return text(' ');
66
+ }
67
+ function listen(node, event, handler, options) {
68
+ node.addEventListener(event, handler, options);
69
+ return () => node.removeEventListener(event, handler, options);
70
+ }
71
+ function attr(node, attribute, value) {
72
+ if (value == null)
73
+ node.removeAttribute(attribute);
74
+ else if (node.getAttribute(attribute) !== value)
75
+ node.setAttribute(attribute, value);
76
+ }
77
+ function children(element) {
78
+ return Array.from(element.childNodes);
79
+ }
80
+ function custom_event(type, detail, { bubbles = false, cancelable = false } = {}) {
81
+ const e = document.createEvent('CustomEvent');
82
+ e.initCustomEvent(type, bubbles, cancelable, detail);
83
+ return e;
84
+ }
85
+ function attribute_to_object(attributes) {
86
+ const result = {};
87
+ for (const attribute of attributes) {
88
+ result[attribute.name] = attribute.value;
89
+ }
90
+ return result;
91
+ }
92
+
93
+ let current_component;
94
+ function set_current_component(component) {
95
+ current_component = component;
96
+ }
97
+
98
+ const dirty_components = [];
99
+ const binding_callbacks = [];
100
+ const render_callbacks = [];
101
+ const flush_callbacks = [];
102
+ const resolved_promise = Promise.resolve();
103
+ let update_scheduled = false;
104
+ function schedule_update() {
105
+ if (!update_scheduled) {
106
+ update_scheduled = true;
107
+ resolved_promise.then(flush);
108
+ }
109
+ }
110
+ function add_render_callback(fn) {
111
+ render_callbacks.push(fn);
112
+ }
113
+ // flush() calls callbacks in this order:
114
+ // 1. All beforeUpdate callbacks, in order: parents before children
115
+ // 2. All bind:this callbacks, in reverse order: children before parents.
116
+ // 3. All afterUpdate callbacks, in order: parents before children. EXCEPT
117
+ // for afterUpdates called during the initial onMount, which are called in
118
+ // reverse order: children before parents.
119
+ // Since callbacks might update component values, which could trigger another
120
+ // call to flush(), the following steps guard against this:
121
+ // 1. During beforeUpdate, any updated components will be added to the
122
+ // dirty_components array and will cause a reentrant call to flush(). Because
123
+ // the flush index is kept outside the function, the reentrant call will pick
124
+ // up where the earlier call left off and go through all dirty components. The
125
+ // current_component value is saved and restored so that the reentrant call will
126
+ // not interfere with the "parent" flush() call.
127
+ // 2. bind:this callbacks cannot trigger new flush() calls.
128
+ // 3. During afterUpdate, any updated components will NOT have their afterUpdate
129
+ // callback called a second time; the seen_callbacks set, outside the flush()
130
+ // function, guarantees this behavior.
131
+ const seen_callbacks = new Set();
132
+ let flushidx = 0; // Do *not* move this inside the flush() function
133
+ function flush() {
134
+ const saved_component = current_component;
135
+ do {
136
+ // first, call beforeUpdate functions
137
+ // and update components
138
+ while (flushidx < dirty_components.length) {
139
+ const component = dirty_components[flushidx];
140
+ flushidx++;
141
+ set_current_component(component);
142
+ update(component.$$);
143
+ }
144
+ set_current_component(null);
145
+ dirty_components.length = 0;
146
+ flushidx = 0;
147
+ while (binding_callbacks.length)
148
+ binding_callbacks.pop()();
149
+ // then, once components are updated, call
150
+ // afterUpdate functions. This may cause
151
+ // subsequent updates...
152
+ for (let i = 0; i < render_callbacks.length; i += 1) {
153
+ const callback = render_callbacks[i];
154
+ if (!seen_callbacks.has(callback)) {
155
+ // ...so guard against infinite loops
156
+ seen_callbacks.add(callback);
157
+ callback();
158
+ }
159
+ }
160
+ render_callbacks.length = 0;
161
+ } while (dirty_components.length);
162
+ while (flush_callbacks.length) {
163
+ flush_callbacks.pop()();
164
+ }
165
+ update_scheduled = false;
166
+ seen_callbacks.clear();
167
+ set_current_component(saved_component);
168
+ }
169
+ function update($$) {
170
+ if ($$.fragment !== null) {
171
+ $$.update();
172
+ run_all($$.before_update);
173
+ const dirty = $$.dirty;
174
+ $$.dirty = [-1];
175
+ $$.fragment && $$.fragment.p($$.ctx, dirty);
176
+ $$.after_update.forEach(add_render_callback);
177
+ }
178
+ }
179
+ const outroing = new Set();
180
+ function transition_in(block, local) {
181
+ if (block && block.i) {
182
+ outroing.delete(block);
183
+ block.i(local);
184
+ }
185
+ }
186
+
187
+ const globals = (typeof window !== 'undefined'
188
+ ? window
189
+ : typeof globalThis !== 'undefined'
190
+ ? globalThis
191
+ : global);
192
+ function mount_component(component, target, anchor, customElement) {
193
+ const { fragment, on_mount, on_destroy, after_update } = component.$$;
194
+ fragment && fragment.m(target, anchor);
195
+ if (!customElement) {
196
+ // onMount happens before the initial afterUpdate
197
+ add_render_callback(() => {
198
+ const new_on_destroy = on_mount.map(run).filter(is_function);
199
+ if (on_destroy) {
200
+ on_destroy.push(...new_on_destroy);
201
+ }
202
+ else {
203
+ // Edge case - component was destroyed immediately,
204
+ // most likely as a result of a binding initialising
205
+ run_all(new_on_destroy);
206
+ }
207
+ component.$$.on_mount = [];
208
+ });
209
+ }
210
+ after_update.forEach(add_render_callback);
211
+ }
212
+ function destroy_component(component, detaching) {
213
+ const $$ = component.$$;
214
+ if ($$.fragment !== null) {
215
+ run_all($$.on_destroy);
216
+ $$.fragment && $$.fragment.d(detaching);
217
+ // TODO null out other refs, including component.$$ (but need to
218
+ // preserve final state?)
219
+ $$.on_destroy = $$.fragment = null;
220
+ $$.ctx = [];
221
+ }
222
+ }
223
+ function make_dirty(component, i) {
224
+ if (component.$$.dirty[0] === -1) {
225
+ dirty_components.push(component);
226
+ schedule_update();
227
+ component.$$.dirty.fill(0);
228
+ }
229
+ component.$$.dirty[(i / 31) | 0] |= (1 << (i % 31));
230
+ }
231
+ function init(component, options, instance, create_fragment, not_equal, props, append_styles, dirty = [-1]) {
232
+ const parent_component = current_component;
233
+ set_current_component(component);
234
+ const $$ = component.$$ = {
235
+ fragment: null,
236
+ ctx: null,
237
+ // state
238
+ props,
239
+ update: noop,
240
+ not_equal,
241
+ bound: blank_object(),
242
+ // lifecycle
243
+ on_mount: [],
244
+ on_destroy: [],
245
+ on_disconnect: [],
246
+ before_update: [],
247
+ after_update: [],
248
+ context: new Map(options.context || (parent_component ? parent_component.$$.context : [])),
249
+ // everything else
250
+ callbacks: blank_object(),
251
+ dirty,
252
+ skip_bound: false,
253
+ root: options.target || parent_component.$$.root
254
+ };
255
+ append_styles && append_styles($$.root);
256
+ let ready = false;
257
+ $$.ctx = instance
258
+ ? instance(component, options.props || {}, (i, ret, ...rest) => {
259
+ const value = rest.length ? rest[0] : ret;
260
+ if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) {
261
+ if (!$$.skip_bound && $$.bound[i])
262
+ $$.bound[i](value);
263
+ if (ready)
264
+ make_dirty(component, i);
265
+ }
266
+ return ret;
267
+ })
268
+ : [];
269
+ $$.update();
270
+ ready = true;
271
+ run_all($$.before_update);
272
+ // `false` as a special case of no DOM component
273
+ $$.fragment = create_fragment ? create_fragment($$.ctx) : false;
274
+ if (options.target) {
275
+ if (options.hydrate) {
276
+ const nodes = children(options.target);
277
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
278
+ $$.fragment && $$.fragment.l(nodes);
279
+ nodes.forEach(detach);
280
+ }
281
+ else {
282
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
283
+ $$.fragment && $$.fragment.c();
284
+ }
285
+ if (options.intro)
286
+ transition_in(component.$$.fragment);
287
+ mount_component(component, options.target, options.anchor, options.customElement);
288
+ flush();
289
+ }
290
+ set_current_component(parent_component);
291
+ }
292
+ let SvelteElement;
293
+ if (typeof HTMLElement === 'function') {
294
+ SvelteElement = class extends HTMLElement {
295
+ constructor() {
296
+ super();
297
+ this.attachShadow({ mode: 'open' });
298
+ }
299
+ connectedCallback() {
300
+ const { on_mount } = this.$$;
301
+ this.$$.on_disconnect = on_mount.map(run).filter(is_function);
302
+ // @ts-ignore todo: improve typings
303
+ for (const key in this.$$.slotted) {
304
+ // @ts-ignore todo: improve typings
305
+ this.appendChild(this.$$.slotted[key]);
306
+ }
307
+ }
308
+ attributeChangedCallback(attr, _oldValue, newValue) {
309
+ this[attr] = newValue;
310
+ }
311
+ disconnectedCallback() {
312
+ run_all(this.$$.on_disconnect);
313
+ }
314
+ $destroy() {
315
+ destroy_component(this, 1);
316
+ this.$destroy = noop;
317
+ }
318
+ $on(type, callback) {
319
+ // TODO should this delegate to addEventListener?
320
+ const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = []));
321
+ callbacks.push(callback);
322
+ return () => {
323
+ const index = callbacks.indexOf(callback);
324
+ if (index !== -1)
325
+ callbacks.splice(index, 1);
326
+ };
327
+ }
328
+ $set($$props) {
329
+ if (this.$$set && !is_empty($$props)) {
330
+ this.$$.skip_bound = true;
331
+ this.$$set($$props);
332
+ this.$$.skip_bound = false;
333
+ }
334
+ }
335
+ };
336
+ }
337
+
338
+ function dispatch_dev(type, detail) {
339
+ document.dispatchEvent(custom_event(type, Object.assign({ version: '3.48.0' }, detail), { bubbles: true }));
340
+ }
341
+ function append_dev(target, node) {
342
+ dispatch_dev('SvelteDOMInsert', { target, node });
343
+ append(target, node);
344
+ }
345
+ function insert_dev(target, node, anchor) {
346
+ dispatch_dev('SvelteDOMInsert', { target, node, anchor });
347
+ insert(target, node, anchor);
348
+ }
349
+ function detach_dev(node) {
350
+ dispatch_dev('SvelteDOMRemove', { node });
351
+ detach(node);
352
+ }
353
+ function listen_dev(node, event, handler, options, has_prevent_default, has_stop_propagation) {
354
+ const modifiers = options === true ? ['capture'] : options ? Array.from(Object.keys(options)) : [];
355
+ if (has_prevent_default)
356
+ modifiers.push('preventDefault');
357
+ if (has_stop_propagation)
358
+ modifiers.push('stopPropagation');
359
+ dispatch_dev('SvelteDOMAddEventListener', { node, event, handler, modifiers });
360
+ const dispose = listen(node, event, handler, options);
361
+ return () => {
362
+ dispatch_dev('SvelteDOMRemoveEventListener', { node, event, handler, modifiers });
363
+ dispose();
364
+ };
365
+ }
366
+ function attr_dev(node, attribute, value) {
367
+ attr(node, attribute, value);
368
+ if (value == null)
369
+ dispatch_dev('SvelteDOMRemoveAttribute', { node, attribute });
370
+ else
371
+ dispatch_dev('SvelteDOMSetAttribute', { node, attribute, value });
372
+ }
373
+ function set_data_dev(text, data) {
374
+ data = '' + data;
375
+ if (text.wholeText === data)
376
+ return;
377
+ dispatch_dev('SvelteDOMSetData', { node: text, data });
378
+ text.data = data;
379
+ }
380
+ function validate_slots(name, slot, keys) {
381
+ for (const slot_key of Object.keys(slot)) {
382
+ if (!~keys.indexOf(slot_key)) {
383
+ console.warn(`<${name}> received an unexpected slot "${slot_key}".`);
384
+ }
385
+ }
386
+ }
387
+
388
+ const subscriber_queue = [];
389
+ /**
390
+ * Creates a `Readable` store that allows reading by subscription.
391
+ * @param value initial value
392
+ * @param {StartStopNotifier}start start and stop notifications for subscriptions
393
+ */
394
+ function readable(value, start) {
395
+ return {
396
+ subscribe: writable(value, start).subscribe
397
+ };
398
+ }
399
+ /**
400
+ * Create a `Writable` store that allows both updating and reading by subscription.
401
+ * @param {*=}value initial value
402
+ * @param {StartStopNotifier=}start start and stop notifications for subscriptions
403
+ */
404
+ function writable(value, start = noop) {
405
+ let stop;
406
+ const subscribers = new Set();
407
+ function set(new_value) {
408
+ if (safe_not_equal(value, new_value)) {
409
+ value = new_value;
410
+ if (stop) { // store is ready
411
+ const run_queue = !subscriber_queue.length;
412
+ for (const subscriber of subscribers) {
413
+ subscriber[1]();
414
+ subscriber_queue.push(subscriber, value);
415
+ }
416
+ if (run_queue) {
417
+ for (let i = 0; i < subscriber_queue.length; i += 2) {
418
+ subscriber_queue[i][0](subscriber_queue[i + 1]);
419
+ }
420
+ subscriber_queue.length = 0;
421
+ }
422
+ }
423
+ }
424
+ }
425
+ function update(fn) {
426
+ set(fn(value));
427
+ }
428
+ function subscribe(run, invalidate = noop) {
429
+ const subscriber = [run, invalidate];
430
+ subscribers.add(subscriber);
431
+ if (subscribers.size === 1) {
432
+ stop = start(set) || noop;
433
+ }
434
+ run(value);
435
+ return () => {
436
+ subscribers.delete(subscriber);
437
+ if (subscribers.size === 0) {
438
+ stop();
439
+ stop = null;
440
+ }
441
+ };
442
+ }
443
+ return { set, update, subscribe };
444
+ }
445
+ function derived(stores, fn, initial_value) {
446
+ const single = !Array.isArray(stores);
447
+ const stores_array = single
448
+ ? [stores]
449
+ : stores;
450
+ const auto = fn.length < 2;
451
+ return readable(initial_value, (set) => {
452
+ let inited = false;
453
+ const values = [];
454
+ let pending = 0;
455
+ let cleanup = noop;
456
+ const sync = () => {
457
+ if (pending) {
458
+ return;
459
+ }
460
+ cleanup();
461
+ const result = fn(single ? values[0] : values, set);
462
+ if (auto) {
463
+ set(result);
464
+ }
465
+ else {
466
+ cleanup = is_function(result) ? result : noop;
467
+ }
468
+ };
469
+ const unsubscribers = stores_array.map((store, i) => subscribe(store, (value) => {
470
+ values[i] = value;
471
+ pending &= ~(1 << i);
472
+ if (inited) {
473
+ sync();
474
+ }
475
+ }, () => {
476
+ pending |= (1 << i);
477
+ }));
478
+ inited = true;
479
+ sync();
480
+ return function stop() {
481
+ run_all(unsubscribers);
482
+ cleanup();
483
+ };
484
+ });
485
+ }
486
+
487
+ var isMergeableObject = function isMergeableObject(value) {
488
+ return isNonNullObject(value)
489
+ && !isSpecial(value)
490
+ };
491
+
492
+ function isNonNullObject(value) {
493
+ return !!value && typeof value === 'object'
494
+ }
495
+
496
+ function isSpecial(value) {
497
+ var stringValue = Object.prototype.toString.call(value);
498
+
499
+ return stringValue === '[object RegExp]'
500
+ || stringValue === '[object Date]'
501
+ || isReactElement(value)
502
+ }
503
+
504
+ // see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25
505
+ var canUseSymbol = typeof Symbol === 'function' && Symbol.for;
506
+ var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;
507
+
508
+ function isReactElement(value) {
509
+ return value.$$typeof === REACT_ELEMENT_TYPE
510
+ }
511
+
512
+ function emptyTarget(val) {
513
+ return Array.isArray(val) ? [] : {}
514
+ }
515
+
516
+ function cloneUnlessOtherwiseSpecified(value, options) {
517
+ return (options.clone !== false && options.isMergeableObject(value))
518
+ ? deepmerge(emptyTarget(value), value, options)
519
+ : value
520
+ }
521
+
522
+ function defaultArrayMerge(target, source, options) {
523
+ return target.concat(source).map(function(element) {
524
+ return cloneUnlessOtherwiseSpecified(element, options)
525
+ })
526
+ }
527
+
528
+ function getMergeFunction(key, options) {
529
+ if (!options.customMerge) {
530
+ return deepmerge
531
+ }
532
+ var customMerge = options.customMerge(key);
533
+ return typeof customMerge === 'function' ? customMerge : deepmerge
534
+ }
535
+
536
+ function getEnumerableOwnPropertySymbols(target) {
537
+ return Object.getOwnPropertySymbols
538
+ ? Object.getOwnPropertySymbols(target).filter(function(symbol) {
539
+ return target.propertyIsEnumerable(symbol)
540
+ })
541
+ : []
542
+ }
543
+
544
+ function getKeys(target) {
545
+ return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))
546
+ }
547
+
548
+ function propertyIsOnObject(object, property) {
549
+ try {
550
+ return property in object
551
+ } catch(_) {
552
+ return false
553
+ }
554
+ }
555
+
556
+ // Protects from prototype poisoning and unexpected merging up the prototype chain.
557
+ function propertyIsUnsafe(target, key) {
558
+ return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,
559
+ && !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,
560
+ && Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable.
561
+ }
562
+
563
+ function mergeObject(target, source, options) {
564
+ var destination = {};
565
+ if (options.isMergeableObject(target)) {
566
+ getKeys(target).forEach(function(key) {
567
+ destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
568
+ });
569
+ }
570
+ getKeys(source).forEach(function(key) {
571
+ if (propertyIsUnsafe(target, key)) {
572
+ return
573
+ }
574
+
575
+ if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
576
+ destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
577
+ } else {
578
+ destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
579
+ }
580
+ });
581
+ return destination
582
+ }
583
+
584
+ function deepmerge(target, source, options) {
585
+ options = options || {};
586
+ options.arrayMerge = options.arrayMerge || defaultArrayMerge;
587
+ options.isMergeableObject = options.isMergeableObject || isMergeableObject;
588
+ // cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()
589
+ // implementations can use it. The caller may not replace it.
590
+ options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
591
+
592
+ var sourceIsArray = Array.isArray(source);
593
+ var targetIsArray = Array.isArray(target);
594
+ var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
595
+
596
+ if (!sourceAndTargetTypesMatch) {
597
+ return cloneUnlessOtherwiseSpecified(source, options)
598
+ } else if (sourceIsArray) {
599
+ return options.arrayMerge(target, source, options)
600
+ } else {
601
+ return mergeObject(target, source, options)
602
+ }
603
+ }
604
+
605
+ deepmerge.all = function deepmergeAll(array, options) {
606
+ if (!Array.isArray(array)) {
607
+ throw new Error('first argument should be an array')
608
+ }
609
+
610
+ return array.reduce(function(prev, next) {
611
+ return deepmerge(prev, next, options)
612
+ }, {})
613
+ };
614
+
615
+ var deepmerge_1 = deepmerge;
616
+
617
+ var cjs = deepmerge_1;
618
+
619
+ /******************************************************************************
620
+ Copyright (c) Microsoft Corporation.
621
+
622
+ Permission to use, copy, modify, and/or distribute this software for any
623
+ purpose with or without fee is hereby granted.
624
+
625
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
626
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
627
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
628
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
629
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
630
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
631
+ PERFORMANCE OF THIS SOFTWARE.
632
+ ***************************************************************************** */
633
+ /* global Reflect, Promise */
634
+
635
+ var extendStatics = function(d, b) {
636
+ extendStatics = Object.setPrototypeOf ||
637
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
638
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
639
+ return extendStatics(d, b);
640
+ };
641
+
642
+ function __extends(d, b) {
643
+ if (typeof b !== "function" && b !== null)
644
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
645
+ extendStatics(d, b);
646
+ function __() { this.constructor = d; }
647
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
648
+ }
649
+
650
+ var __assign = function() {
651
+ __assign = Object.assign || function __assign(t) {
652
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
653
+ s = arguments[i];
654
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
655
+ }
656
+ return t;
657
+ };
658
+ return __assign.apply(this, arguments);
659
+ };
660
+
661
+ function __spreadArray(to, from, pack) {
662
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
663
+ if (ar || !(i in from)) {
664
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
665
+ ar[i] = from[i];
666
+ }
667
+ }
668
+ return to.concat(ar || Array.prototype.slice.call(from));
669
+ }
670
+
671
+ var ErrorKind;
672
+ (function (ErrorKind) {
673
+ /** Argument is unclosed (e.g. `{0`) */
674
+ ErrorKind[ErrorKind["EXPECT_ARGUMENT_CLOSING_BRACE"] = 1] = "EXPECT_ARGUMENT_CLOSING_BRACE";
675
+ /** Argument is empty (e.g. `{}`). */
676
+ ErrorKind[ErrorKind["EMPTY_ARGUMENT"] = 2] = "EMPTY_ARGUMENT";
677
+ /** Argument is malformed (e.g. `{foo!}``) */
678
+ ErrorKind[ErrorKind["MALFORMED_ARGUMENT"] = 3] = "MALFORMED_ARGUMENT";
679
+ /** Expect an argument type (e.g. `{foo,}`) */
680
+ ErrorKind[ErrorKind["EXPECT_ARGUMENT_TYPE"] = 4] = "EXPECT_ARGUMENT_TYPE";
681
+ /** Unsupported argument type (e.g. `{foo,foo}`) */
682
+ ErrorKind[ErrorKind["INVALID_ARGUMENT_TYPE"] = 5] = "INVALID_ARGUMENT_TYPE";
683
+ /** Expect an argument style (e.g. `{foo, number, }`) */
684
+ ErrorKind[ErrorKind["EXPECT_ARGUMENT_STYLE"] = 6] = "EXPECT_ARGUMENT_STYLE";
685
+ /** The number skeleton is invalid. */
686
+ ErrorKind[ErrorKind["INVALID_NUMBER_SKELETON"] = 7] = "INVALID_NUMBER_SKELETON";
687
+ /** The date time skeleton is invalid. */
688
+ ErrorKind[ErrorKind["INVALID_DATE_TIME_SKELETON"] = 8] = "INVALID_DATE_TIME_SKELETON";
689
+ /** Exepct a number skeleton following the `::` (e.g. `{foo, number, ::}`) */
690
+ ErrorKind[ErrorKind["EXPECT_NUMBER_SKELETON"] = 9] = "EXPECT_NUMBER_SKELETON";
691
+ /** Exepct a date time skeleton following the `::` (e.g. `{foo, date, ::}`) */
692
+ ErrorKind[ErrorKind["EXPECT_DATE_TIME_SKELETON"] = 10] = "EXPECT_DATE_TIME_SKELETON";
693
+ /** Unmatched apostrophes in the argument style (e.g. `{foo, number, 'test`) */
694
+ ErrorKind[ErrorKind["UNCLOSED_QUOTE_IN_ARGUMENT_STYLE"] = 11] = "UNCLOSED_QUOTE_IN_ARGUMENT_STYLE";
695
+ /** Missing select argument options (e.g. `{foo, select}`) */
696
+ ErrorKind[ErrorKind["EXPECT_SELECT_ARGUMENT_OPTIONS"] = 12] = "EXPECT_SELECT_ARGUMENT_OPTIONS";
697
+ /** Expecting an offset value in `plural` or `selectordinal` argument (e.g `{foo, plural, offset}`) */
698
+ ErrorKind[ErrorKind["EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE"] = 13] = "EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE";
699
+ /** Offset value in `plural` or `selectordinal` is invalid (e.g. `{foo, plural, offset: x}`) */
700
+ ErrorKind[ErrorKind["INVALID_PLURAL_ARGUMENT_OFFSET_VALUE"] = 14] = "INVALID_PLURAL_ARGUMENT_OFFSET_VALUE";
701
+ /** Expecting a selector in `select` argument (e.g `{foo, select}`) */
702
+ ErrorKind[ErrorKind["EXPECT_SELECT_ARGUMENT_SELECTOR"] = 15] = "EXPECT_SELECT_ARGUMENT_SELECTOR";
703
+ /** Expecting a selector in `plural` or `selectordinal` argument (e.g `{foo, plural}`) */
704
+ ErrorKind[ErrorKind["EXPECT_PLURAL_ARGUMENT_SELECTOR"] = 16] = "EXPECT_PLURAL_ARGUMENT_SELECTOR";
705
+ /** Expecting a message fragment after the `select` selector (e.g. `{foo, select, apple}`) */
706
+ ErrorKind[ErrorKind["EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT"] = 17] = "EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT";
707
+ /**
708
+ * Expecting a message fragment after the `plural` or `selectordinal` selector
709
+ * (e.g. `{foo, plural, one}`)
710
+ */
711
+ ErrorKind[ErrorKind["EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT"] = 18] = "EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT";
712
+ /** Selector in `plural` or `selectordinal` is malformed (e.g. `{foo, plural, =x {#}}`) */
713
+ ErrorKind[ErrorKind["INVALID_PLURAL_ARGUMENT_SELECTOR"] = 19] = "INVALID_PLURAL_ARGUMENT_SELECTOR";
714
+ /**
715
+ * Duplicate selectors in `plural` or `selectordinal` argument.
716
+ * (e.g. {foo, plural, one {#} one {#}})
717
+ */
718
+ ErrorKind[ErrorKind["DUPLICATE_PLURAL_ARGUMENT_SELECTOR"] = 20] = "DUPLICATE_PLURAL_ARGUMENT_SELECTOR";
719
+ /** Duplicate selectors in `select` argument.
720
+ * (e.g. {foo, select, apple {apple} apple {apple}})
721
+ */
722
+ ErrorKind[ErrorKind["DUPLICATE_SELECT_ARGUMENT_SELECTOR"] = 21] = "DUPLICATE_SELECT_ARGUMENT_SELECTOR";
723
+ /** Plural or select argument option must have `other` clause. */
724
+ ErrorKind[ErrorKind["MISSING_OTHER_CLAUSE"] = 22] = "MISSING_OTHER_CLAUSE";
725
+ /** The tag is malformed. (e.g. `<bold!>foo</bold!>) */
726
+ ErrorKind[ErrorKind["INVALID_TAG"] = 23] = "INVALID_TAG";
727
+ /** The tag name is invalid. (e.g. `<123>foo</123>`) */
728
+ ErrorKind[ErrorKind["INVALID_TAG_NAME"] = 25] = "INVALID_TAG_NAME";
729
+ /** The closing tag does not match the opening tag. (e.g. `<bold>foo</italic>`) */
730
+ ErrorKind[ErrorKind["UNMATCHED_CLOSING_TAG"] = 26] = "UNMATCHED_CLOSING_TAG";
731
+ /** The opening tag has unmatched closing tag. (e.g. `<bold>foo`) */
732
+ ErrorKind[ErrorKind["UNCLOSED_TAG"] = 27] = "UNCLOSED_TAG";
733
+ })(ErrorKind || (ErrorKind = {}));
734
+
735
+ var TYPE;
736
+ (function (TYPE) {
737
+ /**
738
+ * Raw text
739
+ */
740
+ TYPE[TYPE["literal"] = 0] = "literal";
741
+ /**
742
+ * Variable w/o any format, e.g `var` in `this is a {var}`
743
+ */
744
+ TYPE[TYPE["argument"] = 1] = "argument";
745
+ /**
746
+ * Variable w/ number format
747
+ */
748
+ TYPE[TYPE["number"] = 2] = "number";
749
+ /**
750
+ * Variable w/ date format
751
+ */
752
+ TYPE[TYPE["date"] = 3] = "date";
753
+ /**
754
+ * Variable w/ time format
755
+ */
756
+ TYPE[TYPE["time"] = 4] = "time";
757
+ /**
758
+ * Variable w/ select format
759
+ */
760
+ TYPE[TYPE["select"] = 5] = "select";
761
+ /**
762
+ * Variable w/ plural format
763
+ */
764
+ TYPE[TYPE["plural"] = 6] = "plural";
765
+ /**
766
+ * Only possible within plural argument.
767
+ * This is the `#` symbol that will be substituted with the count.
768
+ */
769
+ TYPE[TYPE["pound"] = 7] = "pound";
770
+ /**
771
+ * XML-like tag
772
+ */
773
+ TYPE[TYPE["tag"] = 8] = "tag";
774
+ })(TYPE || (TYPE = {}));
775
+ var SKELETON_TYPE;
776
+ (function (SKELETON_TYPE) {
777
+ SKELETON_TYPE[SKELETON_TYPE["number"] = 0] = "number";
778
+ SKELETON_TYPE[SKELETON_TYPE["dateTime"] = 1] = "dateTime";
779
+ })(SKELETON_TYPE || (SKELETON_TYPE = {}));
780
+ /**
781
+ * Type Guards
782
+ */
783
+ function isLiteralElement(el) {
784
+ return el.type === TYPE.literal;
785
+ }
786
+ function isArgumentElement(el) {
787
+ return el.type === TYPE.argument;
788
+ }
789
+ function isNumberElement(el) {
790
+ return el.type === TYPE.number;
791
+ }
792
+ function isDateElement(el) {
793
+ return el.type === TYPE.date;
794
+ }
795
+ function isTimeElement(el) {
796
+ return el.type === TYPE.time;
797
+ }
798
+ function isSelectElement(el) {
799
+ return el.type === TYPE.select;
800
+ }
801
+ function isPluralElement(el) {
802
+ return el.type === TYPE.plural;
803
+ }
804
+ function isPoundElement(el) {
805
+ return el.type === TYPE.pound;
806
+ }
807
+ function isTagElement(el) {
808
+ return el.type === TYPE.tag;
809
+ }
810
+ function isNumberSkeleton(el) {
811
+ return !!(el && typeof el === 'object' && el.type === SKELETON_TYPE.number);
812
+ }
813
+ function isDateTimeSkeleton(el) {
814
+ return !!(el && typeof el === 'object' && el.type === SKELETON_TYPE.dateTime);
815
+ }
816
+
817
+ // @generated from regex-gen.ts
818
+ var SPACE_SEPARATOR_REGEX = /[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/;
819
+
820
+ /**
821
+ * https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
822
+ * Credit: https://github.com/caridy/intl-datetimeformat-pattern/blob/master/index.js
823
+ * with some tweaks
824
+ */
825
+ var DATE_TIME_REGEX = /(?:[Eec]{1,6}|G{1,5}|[Qq]{1,5}|(?:[yYur]+|U{1,5})|[ML]{1,5}|d{1,2}|D{1,3}|F{1}|[abB]{1,5}|[hkHK]{1,2}|w{1,2}|W{1}|m{1,2}|s{1,2}|[zZOvVxX]{1,4})(?=([^']*'[^']*')*[^']*$)/g;
826
+ /**
827
+ * Parse Date time skeleton into Intl.DateTimeFormatOptions
828
+ * Ref: https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
829
+ * @public
830
+ * @param skeleton skeleton string
831
+ */
832
+ function parseDateTimeSkeleton(skeleton) {
833
+ var result = {};
834
+ skeleton.replace(DATE_TIME_REGEX, function (match) {
835
+ var len = match.length;
836
+ switch (match[0]) {
837
+ // Era
838
+ case 'G':
839
+ result.era = len === 4 ? 'long' : len === 5 ? 'narrow' : 'short';
840
+ break;
841
+ // Year
842
+ case 'y':
843
+ result.year = len === 2 ? '2-digit' : 'numeric';
844
+ break;
845
+ case 'Y':
846
+ case 'u':
847
+ case 'U':
848
+ case 'r':
849
+ throw new RangeError('`Y/u/U/r` (year) patterns are not supported, use `y` instead');
850
+ // Quarter
851
+ case 'q':
852
+ case 'Q':
853
+ throw new RangeError('`q/Q` (quarter) patterns are not supported');
854
+ // Month
855
+ case 'M':
856
+ case 'L':
857
+ result.month = ['numeric', '2-digit', 'short', 'long', 'narrow'][len - 1];
858
+ break;
859
+ // Week
860
+ case 'w':
861
+ case 'W':
862
+ throw new RangeError('`w/W` (week) patterns are not supported');
863
+ case 'd':
864
+ result.day = ['numeric', '2-digit'][len - 1];
865
+ break;
866
+ case 'D':
867
+ case 'F':
868
+ case 'g':
869
+ throw new RangeError('`D/F/g` (day) patterns are not supported, use `d` instead');
870
+ // Weekday
871
+ case 'E':
872
+ result.weekday = len === 4 ? 'short' : len === 5 ? 'narrow' : 'short';
873
+ break;
874
+ case 'e':
875
+ if (len < 4) {
876
+ throw new RangeError('`e..eee` (weekday) patterns are not supported');
877
+ }
878
+ result.weekday = ['short', 'long', 'narrow', 'short'][len - 4];
879
+ break;
880
+ case 'c':
881
+ if (len < 4) {
882
+ throw new RangeError('`c..ccc` (weekday) patterns are not supported');
883
+ }
884
+ result.weekday = ['short', 'long', 'narrow', 'short'][len - 4];
885
+ break;
886
+ // Period
887
+ case 'a': // AM, PM
888
+ result.hour12 = true;
889
+ break;
890
+ case 'b': // am, pm, noon, midnight
891
+ case 'B': // flexible day periods
892
+ throw new RangeError('`b/B` (period) patterns are not supported, use `a` instead');
893
+ // Hour
894
+ case 'h':
895
+ result.hourCycle = 'h12';
896
+ result.hour = ['numeric', '2-digit'][len - 1];
897
+ break;
898
+ case 'H':
899
+ result.hourCycle = 'h23';
900
+ result.hour = ['numeric', '2-digit'][len - 1];
901
+ break;
902
+ case 'K':
903
+ result.hourCycle = 'h11';
904
+ result.hour = ['numeric', '2-digit'][len - 1];
905
+ break;
906
+ case 'k':
907
+ result.hourCycle = 'h24';
908
+ result.hour = ['numeric', '2-digit'][len - 1];
909
+ break;
910
+ case 'j':
911
+ case 'J':
912
+ case 'C':
913
+ throw new RangeError('`j/J/C` (hour) patterns are not supported, use `h/H/K/k` instead');
914
+ // Minute
915
+ case 'm':
916
+ result.minute = ['numeric', '2-digit'][len - 1];
917
+ break;
918
+ // Second
919
+ case 's':
920
+ result.second = ['numeric', '2-digit'][len - 1];
921
+ break;
922
+ case 'S':
923
+ case 'A':
924
+ throw new RangeError('`S/A` (second) patterns are not supported, use `s` instead');
925
+ // Zone
926
+ case 'z': // 1..3, 4: specific non-location format
927
+ result.timeZoneName = len < 4 ? 'short' : 'long';
928
+ break;
929
+ case 'Z': // 1..3, 4, 5: The ISO8601 varios formats
930
+ case 'O': // 1, 4: miliseconds in day short, long
931
+ case 'v': // 1, 4: generic non-location format
932
+ case 'V': // 1, 2, 3, 4: time zone ID or city
933
+ case 'X': // 1, 2, 3, 4: The ISO8601 varios formats
934
+ case 'x': // 1, 2, 3, 4: The ISO8601 varios formats
935
+ throw new RangeError('`Z/O/v/V/X/x` (timeZone) patterns are not supported, use `z` instead');
936
+ }
937
+ return '';
938
+ });
939
+ return result;
940
+ }
941
+
942
+ // @generated from regex-gen.ts
943
+ var WHITE_SPACE_REGEX = /[\t-\r \x85\u200E\u200F\u2028\u2029]/i;
944
+
945
+ function parseNumberSkeletonFromString(skeleton) {
946
+ if (skeleton.length === 0) {
947
+ throw new Error('Number skeleton cannot be empty');
948
+ }
949
+ // Parse the skeleton
950
+ var stringTokens = skeleton
951
+ .split(WHITE_SPACE_REGEX)
952
+ .filter(function (x) { return x.length > 0; });
953
+ var tokens = [];
954
+ for (var _i = 0, stringTokens_1 = stringTokens; _i < stringTokens_1.length; _i++) {
955
+ var stringToken = stringTokens_1[_i];
956
+ var stemAndOptions = stringToken.split('/');
957
+ if (stemAndOptions.length === 0) {
958
+ throw new Error('Invalid number skeleton');
959
+ }
960
+ var stem = stemAndOptions[0], options = stemAndOptions.slice(1);
961
+ for (var _a = 0, options_1 = options; _a < options_1.length; _a++) {
962
+ var option = options_1[_a];
963
+ if (option.length === 0) {
964
+ throw new Error('Invalid number skeleton');
965
+ }
966
+ }
967
+ tokens.push({ stem: stem, options: options });
968
+ }
969
+ return tokens;
970
+ }
971
+ function icuUnitToEcma(unit) {
972
+ return unit.replace(/^(.*?)-/, '');
973
+ }
974
+ var FRACTION_PRECISION_REGEX = /^\.(?:(0+)(\*)?|(#+)|(0+)(#+))$/g;
975
+ var SIGNIFICANT_PRECISION_REGEX = /^(@+)?(\+|#+)?[rs]?$/g;
976
+ var INTEGER_WIDTH_REGEX = /(\*)(0+)|(#+)(0+)|(0+)/g;
977
+ var CONCISE_INTEGER_WIDTH_REGEX = /^(0+)$/;
978
+ function parseSignificantPrecision(str) {
979
+ var result = {};
980
+ if (str[str.length - 1] === 'r') {
981
+ result.roundingPriority = 'morePrecision';
982
+ }
983
+ else if (str[str.length - 1] === 's') {
984
+ result.roundingPriority = 'lessPrecision';
985
+ }
986
+ str.replace(SIGNIFICANT_PRECISION_REGEX, function (_, g1, g2) {
987
+ // @@@ case
988
+ if (typeof g2 !== 'string') {
989
+ result.minimumSignificantDigits = g1.length;
990
+ result.maximumSignificantDigits = g1.length;
991
+ }
992
+ // @@@+ case
993
+ else if (g2 === '+') {
994
+ result.minimumSignificantDigits = g1.length;
995
+ }
996
+ // .### case
997
+ else if (g1[0] === '#') {
998
+ result.maximumSignificantDigits = g1.length;
999
+ }
1000
+ // .@@## or .@@@ case
1001
+ else {
1002
+ result.minimumSignificantDigits = g1.length;
1003
+ result.maximumSignificantDigits =
1004
+ g1.length + (typeof g2 === 'string' ? g2.length : 0);
1005
+ }
1006
+ return '';
1007
+ });
1008
+ return result;
1009
+ }
1010
+ function parseSign(str) {
1011
+ switch (str) {
1012
+ case 'sign-auto':
1013
+ return {
1014
+ signDisplay: 'auto',
1015
+ };
1016
+ case 'sign-accounting':
1017
+ case '()':
1018
+ return {
1019
+ currencySign: 'accounting',
1020
+ };
1021
+ case 'sign-always':
1022
+ case '+!':
1023
+ return {
1024
+ signDisplay: 'always',
1025
+ };
1026
+ case 'sign-accounting-always':
1027
+ case '()!':
1028
+ return {
1029
+ signDisplay: 'always',
1030
+ currencySign: 'accounting',
1031
+ };
1032
+ case 'sign-except-zero':
1033
+ case '+?':
1034
+ return {
1035
+ signDisplay: 'exceptZero',
1036
+ };
1037
+ case 'sign-accounting-except-zero':
1038
+ case '()?':
1039
+ return {
1040
+ signDisplay: 'exceptZero',
1041
+ currencySign: 'accounting',
1042
+ };
1043
+ case 'sign-never':
1044
+ case '+_':
1045
+ return {
1046
+ signDisplay: 'never',
1047
+ };
1048
+ }
1049
+ }
1050
+ function parseConciseScientificAndEngineeringStem(stem) {
1051
+ // Engineering
1052
+ var result;
1053
+ if (stem[0] === 'E' && stem[1] === 'E') {
1054
+ result = {
1055
+ notation: 'engineering',
1056
+ };
1057
+ stem = stem.slice(2);
1058
+ }
1059
+ else if (stem[0] === 'E') {
1060
+ result = {
1061
+ notation: 'scientific',
1062
+ };
1063
+ stem = stem.slice(1);
1064
+ }
1065
+ if (result) {
1066
+ var signDisplay = stem.slice(0, 2);
1067
+ if (signDisplay === '+!') {
1068
+ result.signDisplay = 'always';
1069
+ stem = stem.slice(2);
1070
+ }
1071
+ else if (signDisplay === '+?') {
1072
+ result.signDisplay = 'exceptZero';
1073
+ stem = stem.slice(2);
1074
+ }
1075
+ if (!CONCISE_INTEGER_WIDTH_REGEX.test(stem)) {
1076
+ throw new Error('Malformed concise eng/scientific notation');
1077
+ }
1078
+ result.minimumIntegerDigits = stem.length;
1079
+ }
1080
+ return result;
1081
+ }
1082
+ function parseNotationOptions(opt) {
1083
+ var result = {};
1084
+ var signOpts = parseSign(opt);
1085
+ if (signOpts) {
1086
+ return signOpts;
1087
+ }
1088
+ return result;
1089
+ }
1090
+ /**
1091
+ * https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#skeleton-stems-and-options
1092
+ */
1093
+ function parseNumberSkeleton(tokens) {
1094
+ var result = {};
1095
+ for (var _i = 0, tokens_1 = tokens; _i < tokens_1.length; _i++) {
1096
+ var token = tokens_1[_i];
1097
+ switch (token.stem) {
1098
+ case 'percent':
1099
+ case '%':
1100
+ result.style = 'percent';
1101
+ continue;
1102
+ case '%x100':
1103
+ result.style = 'percent';
1104
+ result.scale = 100;
1105
+ continue;
1106
+ case 'currency':
1107
+ result.style = 'currency';
1108
+ result.currency = token.options[0];
1109
+ continue;
1110
+ case 'group-off':
1111
+ case ',_':
1112
+ result.useGrouping = false;
1113
+ continue;
1114
+ case 'precision-integer':
1115
+ case '.':
1116
+ result.maximumFractionDigits = 0;
1117
+ continue;
1118
+ case 'measure-unit':
1119
+ case 'unit':
1120
+ result.style = 'unit';
1121
+ result.unit = icuUnitToEcma(token.options[0]);
1122
+ continue;
1123
+ case 'compact-short':
1124
+ case 'K':
1125
+ result.notation = 'compact';
1126
+ result.compactDisplay = 'short';
1127
+ continue;
1128
+ case 'compact-long':
1129
+ case 'KK':
1130
+ result.notation = 'compact';
1131
+ result.compactDisplay = 'long';
1132
+ continue;
1133
+ case 'scientific':
1134
+ result = __assign(__assign(__assign({}, result), { notation: 'scientific' }), token.options.reduce(function (all, opt) { return (__assign(__assign({}, all), parseNotationOptions(opt))); }, {}));
1135
+ continue;
1136
+ case 'engineering':
1137
+ result = __assign(__assign(__assign({}, result), { notation: 'engineering' }), token.options.reduce(function (all, opt) { return (__assign(__assign({}, all), parseNotationOptions(opt))); }, {}));
1138
+ continue;
1139
+ case 'notation-simple':
1140
+ result.notation = 'standard';
1141
+ continue;
1142
+ // https://github.com/unicode-org/icu/blob/master/icu4c/source/i18n/unicode/unumberformatter.h
1143
+ case 'unit-width-narrow':
1144
+ result.currencyDisplay = 'narrowSymbol';
1145
+ result.unitDisplay = 'narrow';
1146
+ continue;
1147
+ case 'unit-width-short':
1148
+ result.currencyDisplay = 'code';
1149
+ result.unitDisplay = 'short';
1150
+ continue;
1151
+ case 'unit-width-full-name':
1152
+ result.currencyDisplay = 'name';
1153
+ result.unitDisplay = 'long';
1154
+ continue;
1155
+ case 'unit-width-iso-code':
1156
+ result.currencyDisplay = 'symbol';
1157
+ continue;
1158
+ case 'scale':
1159
+ result.scale = parseFloat(token.options[0]);
1160
+ continue;
1161
+ // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#integer-width
1162
+ case 'integer-width':
1163
+ if (token.options.length > 1) {
1164
+ throw new RangeError('integer-width stems only accept a single optional option');
1165
+ }
1166
+ token.options[0].replace(INTEGER_WIDTH_REGEX, function (_, g1, g2, g3, g4, g5) {
1167
+ if (g1) {
1168
+ result.minimumIntegerDigits = g2.length;
1169
+ }
1170
+ else if (g3 && g4) {
1171
+ throw new Error('We currently do not support maximum integer digits');
1172
+ }
1173
+ else if (g5) {
1174
+ throw new Error('We currently do not support exact integer digits');
1175
+ }
1176
+ return '';
1177
+ });
1178
+ continue;
1179
+ }
1180
+ // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#integer-width
1181
+ if (CONCISE_INTEGER_WIDTH_REGEX.test(token.stem)) {
1182
+ result.minimumIntegerDigits = token.stem.length;
1183
+ continue;
1184
+ }
1185
+ if (FRACTION_PRECISION_REGEX.test(token.stem)) {
1186
+ // Precision
1187
+ // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#fraction-precision
1188
+ // precision-integer case
1189
+ if (token.options.length > 1) {
1190
+ throw new RangeError('Fraction-precision stems only accept a single optional option');
1191
+ }
1192
+ token.stem.replace(FRACTION_PRECISION_REGEX, function (_, g1, g2, g3, g4, g5) {
1193
+ // .000* case (before ICU67 it was .000+)
1194
+ if (g2 === '*') {
1195
+ result.minimumFractionDigits = g1.length;
1196
+ }
1197
+ // .### case
1198
+ else if (g3 && g3[0] === '#') {
1199
+ result.maximumFractionDigits = g3.length;
1200
+ }
1201
+ // .00## case
1202
+ else if (g4 && g5) {
1203
+ result.minimumFractionDigits = g4.length;
1204
+ result.maximumFractionDigits = g4.length + g5.length;
1205
+ }
1206
+ else {
1207
+ result.minimumFractionDigits = g1.length;
1208
+ result.maximumFractionDigits = g1.length;
1209
+ }
1210
+ return '';
1211
+ });
1212
+ var opt = token.options[0];
1213
+ // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#trailing-zero-display
1214
+ if (opt === 'w') {
1215
+ result = __assign(__assign({}, result), { trailingZeroDisplay: 'stripIfInteger' });
1216
+ }
1217
+ else if (opt) {
1218
+ result = __assign(__assign({}, result), parseSignificantPrecision(opt));
1219
+ }
1220
+ continue;
1221
+ }
1222
+ // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#significant-digits-precision
1223
+ if (SIGNIFICANT_PRECISION_REGEX.test(token.stem)) {
1224
+ result = __assign(__assign({}, result), parseSignificantPrecision(token.stem));
1225
+ continue;
1226
+ }
1227
+ var signOpts = parseSign(token.stem);
1228
+ if (signOpts) {
1229
+ result = __assign(__assign({}, result), signOpts);
1230
+ }
1231
+ var conciseScientificAndEngineeringOpts = parseConciseScientificAndEngineeringStem(token.stem);
1232
+ if (conciseScientificAndEngineeringOpts) {
1233
+ result = __assign(__assign({}, result), conciseScientificAndEngineeringOpts);
1234
+ }
1235
+ }
1236
+ return result;
1237
+ }
1238
+
1239
+ // @generated from time-data-gen.ts
1240
+ // prettier-ignore
1241
+ var timeData = {
1242
+ "AX": [
1243
+ "H"
1244
+ ],
1245
+ "BQ": [
1246
+ "H"
1247
+ ],
1248
+ "CP": [
1249
+ "H"
1250
+ ],
1251
+ "CZ": [
1252
+ "H"
1253
+ ],
1254
+ "DK": [
1255
+ "H"
1256
+ ],
1257
+ "FI": [
1258
+ "H"
1259
+ ],
1260
+ "ID": [
1261
+ "H"
1262
+ ],
1263
+ "IS": [
1264
+ "H"
1265
+ ],
1266
+ "ML": [
1267
+ "H"
1268
+ ],
1269
+ "NE": [
1270
+ "H"
1271
+ ],
1272
+ "RU": [
1273
+ "H"
1274
+ ],
1275
+ "SE": [
1276
+ "H"
1277
+ ],
1278
+ "SJ": [
1279
+ "H"
1280
+ ],
1281
+ "SK": [
1282
+ "H"
1283
+ ],
1284
+ "AS": [
1285
+ "h",
1286
+ "H"
1287
+ ],
1288
+ "BT": [
1289
+ "h",
1290
+ "H"
1291
+ ],
1292
+ "DJ": [
1293
+ "h",
1294
+ "H"
1295
+ ],
1296
+ "ER": [
1297
+ "h",
1298
+ "H"
1299
+ ],
1300
+ "GH": [
1301
+ "h",
1302
+ "H"
1303
+ ],
1304
+ "IN": [
1305
+ "h",
1306
+ "H"
1307
+ ],
1308
+ "LS": [
1309
+ "h",
1310
+ "H"
1311
+ ],
1312
+ "PG": [
1313
+ "h",
1314
+ "H"
1315
+ ],
1316
+ "PW": [
1317
+ "h",
1318
+ "H"
1319
+ ],
1320
+ "SO": [
1321
+ "h",
1322
+ "H"
1323
+ ],
1324
+ "TO": [
1325
+ "h",
1326
+ "H"
1327
+ ],
1328
+ "VU": [
1329
+ "h",
1330
+ "H"
1331
+ ],
1332
+ "WS": [
1333
+ "h",
1334
+ "H"
1335
+ ],
1336
+ "001": [
1337
+ "H",
1338
+ "h"
1339
+ ],
1340
+ "AL": [
1341
+ "h",
1342
+ "H",
1343
+ "hB"
1344
+ ],
1345
+ "TD": [
1346
+ "h",
1347
+ "H",
1348
+ "hB"
1349
+ ],
1350
+ "ca-ES": [
1351
+ "H",
1352
+ "h",
1353
+ "hB"
1354
+ ],
1355
+ "CF": [
1356
+ "H",
1357
+ "h",
1358
+ "hB"
1359
+ ],
1360
+ "CM": [
1361
+ "H",
1362
+ "h",
1363
+ "hB"
1364
+ ],
1365
+ "fr-CA": [
1366
+ "H",
1367
+ "h",
1368
+ "hB"
1369
+ ],
1370
+ "gl-ES": [
1371
+ "H",
1372
+ "h",
1373
+ "hB"
1374
+ ],
1375
+ "it-CH": [
1376
+ "H",
1377
+ "h",
1378
+ "hB"
1379
+ ],
1380
+ "it-IT": [
1381
+ "H",
1382
+ "h",
1383
+ "hB"
1384
+ ],
1385
+ "LU": [
1386
+ "H",
1387
+ "h",
1388
+ "hB"
1389
+ ],
1390
+ "NP": [
1391
+ "H",
1392
+ "h",
1393
+ "hB"
1394
+ ],
1395
+ "PF": [
1396
+ "H",
1397
+ "h",
1398
+ "hB"
1399
+ ],
1400
+ "SC": [
1401
+ "H",
1402
+ "h",
1403
+ "hB"
1404
+ ],
1405
+ "SM": [
1406
+ "H",
1407
+ "h",
1408
+ "hB"
1409
+ ],
1410
+ "SN": [
1411
+ "H",
1412
+ "h",
1413
+ "hB"
1414
+ ],
1415
+ "TF": [
1416
+ "H",
1417
+ "h",
1418
+ "hB"
1419
+ ],
1420
+ "VA": [
1421
+ "H",
1422
+ "h",
1423
+ "hB"
1424
+ ],
1425
+ "CY": [
1426
+ "h",
1427
+ "H",
1428
+ "hb",
1429
+ "hB"
1430
+ ],
1431
+ "GR": [
1432
+ "h",
1433
+ "H",
1434
+ "hb",
1435
+ "hB"
1436
+ ],
1437
+ "CO": [
1438
+ "h",
1439
+ "H",
1440
+ "hB",
1441
+ "hb"
1442
+ ],
1443
+ "DO": [
1444
+ "h",
1445
+ "H",
1446
+ "hB",
1447
+ "hb"
1448
+ ],
1449
+ "KP": [
1450
+ "h",
1451
+ "H",
1452
+ "hB",
1453
+ "hb"
1454
+ ],
1455
+ "KR": [
1456
+ "h",
1457
+ "H",
1458
+ "hB",
1459
+ "hb"
1460
+ ],
1461
+ "NA": [
1462
+ "h",
1463
+ "H",
1464
+ "hB",
1465
+ "hb"
1466
+ ],
1467
+ "PA": [
1468
+ "h",
1469
+ "H",
1470
+ "hB",
1471
+ "hb"
1472
+ ],
1473
+ "PR": [
1474
+ "h",
1475
+ "H",
1476
+ "hB",
1477
+ "hb"
1478
+ ],
1479
+ "VE": [
1480
+ "h",
1481
+ "H",
1482
+ "hB",
1483
+ "hb"
1484
+ ],
1485
+ "AC": [
1486
+ "H",
1487
+ "h",
1488
+ "hb",
1489
+ "hB"
1490
+ ],
1491
+ "AI": [
1492
+ "H",
1493
+ "h",
1494
+ "hb",
1495
+ "hB"
1496
+ ],
1497
+ "BW": [
1498
+ "H",
1499
+ "h",
1500
+ "hb",
1501
+ "hB"
1502
+ ],
1503
+ "BZ": [
1504
+ "H",
1505
+ "h",
1506
+ "hb",
1507
+ "hB"
1508
+ ],
1509
+ "CC": [
1510
+ "H",
1511
+ "h",
1512
+ "hb",
1513
+ "hB"
1514
+ ],
1515
+ "CK": [
1516
+ "H",
1517
+ "h",
1518
+ "hb",
1519
+ "hB"
1520
+ ],
1521
+ "CX": [
1522
+ "H",
1523
+ "h",
1524
+ "hb",
1525
+ "hB"
1526
+ ],
1527
+ "DG": [
1528
+ "H",
1529
+ "h",
1530
+ "hb",
1531
+ "hB"
1532
+ ],
1533
+ "FK": [
1534
+ "H",
1535
+ "h",
1536
+ "hb",
1537
+ "hB"
1538
+ ],
1539
+ "GB": [
1540
+ "H",
1541
+ "h",
1542
+ "hb",
1543
+ "hB"
1544
+ ],
1545
+ "GG": [
1546
+ "H",
1547
+ "h",
1548
+ "hb",
1549
+ "hB"
1550
+ ],
1551
+ "GI": [
1552
+ "H",
1553
+ "h",
1554
+ "hb",
1555
+ "hB"
1556
+ ],
1557
+ "IE": [
1558
+ "H",
1559
+ "h",
1560
+ "hb",
1561
+ "hB"
1562
+ ],
1563
+ "IM": [
1564
+ "H",
1565
+ "h",
1566
+ "hb",
1567
+ "hB"
1568
+ ],
1569
+ "IO": [
1570
+ "H",
1571
+ "h",
1572
+ "hb",
1573
+ "hB"
1574
+ ],
1575
+ "JE": [
1576
+ "H",
1577
+ "h",
1578
+ "hb",
1579
+ "hB"
1580
+ ],
1581
+ "LT": [
1582
+ "H",
1583
+ "h",
1584
+ "hb",
1585
+ "hB"
1586
+ ],
1587
+ "MK": [
1588
+ "H",
1589
+ "h",
1590
+ "hb",
1591
+ "hB"
1592
+ ],
1593
+ "MN": [
1594
+ "H",
1595
+ "h",
1596
+ "hb",
1597
+ "hB"
1598
+ ],
1599
+ "MS": [
1600
+ "H",
1601
+ "h",
1602
+ "hb",
1603
+ "hB"
1604
+ ],
1605
+ "NF": [
1606
+ "H",
1607
+ "h",
1608
+ "hb",
1609
+ "hB"
1610
+ ],
1611
+ "NG": [
1612
+ "H",
1613
+ "h",
1614
+ "hb",
1615
+ "hB"
1616
+ ],
1617
+ "NR": [
1618
+ "H",
1619
+ "h",
1620
+ "hb",
1621
+ "hB"
1622
+ ],
1623
+ "NU": [
1624
+ "H",
1625
+ "h",
1626
+ "hb",
1627
+ "hB"
1628
+ ],
1629
+ "PN": [
1630
+ "H",
1631
+ "h",
1632
+ "hb",
1633
+ "hB"
1634
+ ],
1635
+ "SH": [
1636
+ "H",
1637
+ "h",
1638
+ "hb",
1639
+ "hB"
1640
+ ],
1641
+ "SX": [
1642
+ "H",
1643
+ "h",
1644
+ "hb",
1645
+ "hB"
1646
+ ],
1647
+ "TA": [
1648
+ "H",
1649
+ "h",
1650
+ "hb",
1651
+ "hB"
1652
+ ],
1653
+ "ZA": [
1654
+ "H",
1655
+ "h",
1656
+ "hb",
1657
+ "hB"
1658
+ ],
1659
+ "af-ZA": [
1660
+ "H",
1661
+ "h",
1662
+ "hB",
1663
+ "hb"
1664
+ ],
1665
+ "AR": [
1666
+ "H",
1667
+ "h",
1668
+ "hB",
1669
+ "hb"
1670
+ ],
1671
+ "CL": [
1672
+ "H",
1673
+ "h",
1674
+ "hB",
1675
+ "hb"
1676
+ ],
1677
+ "CR": [
1678
+ "H",
1679
+ "h",
1680
+ "hB",
1681
+ "hb"
1682
+ ],
1683
+ "CU": [
1684
+ "H",
1685
+ "h",
1686
+ "hB",
1687
+ "hb"
1688
+ ],
1689
+ "EA": [
1690
+ "H",
1691
+ "h",
1692
+ "hB",
1693
+ "hb"
1694
+ ],
1695
+ "es-BO": [
1696
+ "H",
1697
+ "h",
1698
+ "hB",
1699
+ "hb"
1700
+ ],
1701
+ "es-BR": [
1702
+ "H",
1703
+ "h",
1704
+ "hB",
1705
+ "hb"
1706
+ ],
1707
+ "es-EC": [
1708
+ "H",
1709
+ "h",
1710
+ "hB",
1711
+ "hb"
1712
+ ],
1713
+ "es-ES": [
1714
+ "H",
1715
+ "h",
1716
+ "hB",
1717
+ "hb"
1718
+ ],
1719
+ "es-GQ": [
1720
+ "H",
1721
+ "h",
1722
+ "hB",
1723
+ "hb"
1724
+ ],
1725
+ "es-PE": [
1726
+ "H",
1727
+ "h",
1728
+ "hB",
1729
+ "hb"
1730
+ ],
1731
+ "GT": [
1732
+ "H",
1733
+ "h",
1734
+ "hB",
1735
+ "hb"
1736
+ ],
1737
+ "HN": [
1738
+ "H",
1739
+ "h",
1740
+ "hB",
1741
+ "hb"
1742
+ ],
1743
+ "IC": [
1744
+ "H",
1745
+ "h",
1746
+ "hB",
1747
+ "hb"
1748
+ ],
1749
+ "KG": [
1750
+ "H",
1751
+ "h",
1752
+ "hB",
1753
+ "hb"
1754
+ ],
1755
+ "KM": [
1756
+ "H",
1757
+ "h",
1758
+ "hB",
1759
+ "hb"
1760
+ ],
1761
+ "LK": [
1762
+ "H",
1763
+ "h",
1764
+ "hB",
1765
+ "hb"
1766
+ ],
1767
+ "MA": [
1768
+ "H",
1769
+ "h",
1770
+ "hB",
1771
+ "hb"
1772
+ ],
1773
+ "MX": [
1774
+ "H",
1775
+ "h",
1776
+ "hB",
1777
+ "hb"
1778
+ ],
1779
+ "NI": [
1780
+ "H",
1781
+ "h",
1782
+ "hB",
1783
+ "hb"
1784
+ ],
1785
+ "PY": [
1786
+ "H",
1787
+ "h",
1788
+ "hB",
1789
+ "hb"
1790
+ ],
1791
+ "SV": [
1792
+ "H",
1793
+ "h",
1794
+ "hB",
1795
+ "hb"
1796
+ ],
1797
+ "UY": [
1798
+ "H",
1799
+ "h",
1800
+ "hB",
1801
+ "hb"
1802
+ ],
1803
+ "JP": [
1804
+ "H",
1805
+ "h",
1806
+ "K"
1807
+ ],
1808
+ "AD": [
1809
+ "H",
1810
+ "hB"
1811
+ ],
1812
+ "AM": [
1813
+ "H",
1814
+ "hB"
1815
+ ],
1816
+ "AO": [
1817
+ "H",
1818
+ "hB"
1819
+ ],
1820
+ "AT": [
1821
+ "H",
1822
+ "hB"
1823
+ ],
1824
+ "AW": [
1825
+ "H",
1826
+ "hB"
1827
+ ],
1828
+ "BE": [
1829
+ "H",
1830
+ "hB"
1831
+ ],
1832
+ "BF": [
1833
+ "H",
1834
+ "hB"
1835
+ ],
1836
+ "BJ": [
1837
+ "H",
1838
+ "hB"
1839
+ ],
1840
+ "BL": [
1841
+ "H",
1842
+ "hB"
1843
+ ],
1844
+ "BR": [
1845
+ "H",
1846
+ "hB"
1847
+ ],
1848
+ "CG": [
1849
+ "H",
1850
+ "hB"
1851
+ ],
1852
+ "CI": [
1853
+ "H",
1854
+ "hB"
1855
+ ],
1856
+ "CV": [
1857
+ "H",
1858
+ "hB"
1859
+ ],
1860
+ "DE": [
1861
+ "H",
1862
+ "hB"
1863
+ ],
1864
+ "EE": [
1865
+ "H",
1866
+ "hB"
1867
+ ],
1868
+ "FR": [
1869
+ "H",
1870
+ "hB"
1871
+ ],
1872
+ "GA": [
1873
+ "H",
1874
+ "hB"
1875
+ ],
1876
+ "GF": [
1877
+ "H",
1878
+ "hB"
1879
+ ],
1880
+ "GN": [
1881
+ "H",
1882
+ "hB"
1883
+ ],
1884
+ "GP": [
1885
+ "H",
1886
+ "hB"
1887
+ ],
1888
+ "GW": [
1889
+ "H",
1890
+ "hB"
1891
+ ],
1892
+ "HR": [
1893
+ "H",
1894
+ "hB"
1895
+ ],
1896
+ "IL": [
1897
+ "H",
1898
+ "hB"
1899
+ ],
1900
+ "IT": [
1901
+ "H",
1902
+ "hB"
1903
+ ],
1904
+ "KZ": [
1905
+ "H",
1906
+ "hB"
1907
+ ],
1908
+ "MC": [
1909
+ "H",
1910
+ "hB"
1911
+ ],
1912
+ "MD": [
1913
+ "H",
1914
+ "hB"
1915
+ ],
1916
+ "MF": [
1917
+ "H",
1918
+ "hB"
1919
+ ],
1920
+ "MQ": [
1921
+ "H",
1922
+ "hB"
1923
+ ],
1924
+ "MZ": [
1925
+ "H",
1926
+ "hB"
1927
+ ],
1928
+ "NC": [
1929
+ "H",
1930
+ "hB"
1931
+ ],
1932
+ "NL": [
1933
+ "H",
1934
+ "hB"
1935
+ ],
1936
+ "PM": [
1937
+ "H",
1938
+ "hB"
1939
+ ],
1940
+ "PT": [
1941
+ "H",
1942
+ "hB"
1943
+ ],
1944
+ "RE": [
1945
+ "H",
1946
+ "hB"
1947
+ ],
1948
+ "RO": [
1949
+ "H",
1950
+ "hB"
1951
+ ],
1952
+ "SI": [
1953
+ "H",
1954
+ "hB"
1955
+ ],
1956
+ "SR": [
1957
+ "H",
1958
+ "hB"
1959
+ ],
1960
+ "ST": [
1961
+ "H",
1962
+ "hB"
1963
+ ],
1964
+ "TG": [
1965
+ "H",
1966
+ "hB"
1967
+ ],
1968
+ "TR": [
1969
+ "H",
1970
+ "hB"
1971
+ ],
1972
+ "WF": [
1973
+ "H",
1974
+ "hB"
1975
+ ],
1976
+ "YT": [
1977
+ "H",
1978
+ "hB"
1979
+ ],
1980
+ "BD": [
1981
+ "h",
1982
+ "hB",
1983
+ "H"
1984
+ ],
1985
+ "PK": [
1986
+ "h",
1987
+ "hB",
1988
+ "H"
1989
+ ],
1990
+ "AZ": [
1991
+ "H",
1992
+ "hB",
1993
+ "h"
1994
+ ],
1995
+ "BA": [
1996
+ "H",
1997
+ "hB",
1998
+ "h"
1999
+ ],
2000
+ "BG": [
2001
+ "H",
2002
+ "hB",
2003
+ "h"
2004
+ ],
2005
+ "CH": [
2006
+ "H",
2007
+ "hB",
2008
+ "h"
2009
+ ],
2010
+ "GE": [
2011
+ "H",
2012
+ "hB",
2013
+ "h"
2014
+ ],
2015
+ "LI": [
2016
+ "H",
2017
+ "hB",
2018
+ "h"
2019
+ ],
2020
+ "ME": [
2021
+ "H",
2022
+ "hB",
2023
+ "h"
2024
+ ],
2025
+ "RS": [
2026
+ "H",
2027
+ "hB",
2028
+ "h"
2029
+ ],
2030
+ "UA": [
2031
+ "H",
2032
+ "hB",
2033
+ "h"
2034
+ ],
2035
+ "UZ": [
2036
+ "H",
2037
+ "hB",
2038
+ "h"
2039
+ ],
2040
+ "XK": [
2041
+ "H",
2042
+ "hB",
2043
+ "h"
2044
+ ],
2045
+ "AG": [
2046
+ "h",
2047
+ "hb",
2048
+ "H",
2049
+ "hB"
2050
+ ],
2051
+ "AU": [
2052
+ "h",
2053
+ "hb",
2054
+ "H",
2055
+ "hB"
2056
+ ],
2057
+ "BB": [
2058
+ "h",
2059
+ "hb",
2060
+ "H",
2061
+ "hB"
2062
+ ],
2063
+ "BM": [
2064
+ "h",
2065
+ "hb",
2066
+ "H",
2067
+ "hB"
2068
+ ],
2069
+ "BS": [
2070
+ "h",
2071
+ "hb",
2072
+ "H",
2073
+ "hB"
2074
+ ],
2075
+ "CA": [
2076
+ "h",
2077
+ "hb",
2078
+ "H",
2079
+ "hB"
2080
+ ],
2081
+ "DM": [
2082
+ "h",
2083
+ "hb",
2084
+ "H",
2085
+ "hB"
2086
+ ],
2087
+ "en-001": [
2088
+ "h",
2089
+ "hb",
2090
+ "H",
2091
+ "hB"
2092
+ ],
2093
+ "FJ": [
2094
+ "h",
2095
+ "hb",
2096
+ "H",
2097
+ "hB"
2098
+ ],
2099
+ "FM": [
2100
+ "h",
2101
+ "hb",
2102
+ "H",
2103
+ "hB"
2104
+ ],
2105
+ "GD": [
2106
+ "h",
2107
+ "hb",
2108
+ "H",
2109
+ "hB"
2110
+ ],
2111
+ "GM": [
2112
+ "h",
2113
+ "hb",
2114
+ "H",
2115
+ "hB"
2116
+ ],
2117
+ "GU": [
2118
+ "h",
2119
+ "hb",
2120
+ "H",
2121
+ "hB"
2122
+ ],
2123
+ "GY": [
2124
+ "h",
2125
+ "hb",
2126
+ "H",
2127
+ "hB"
2128
+ ],
2129
+ "JM": [
2130
+ "h",
2131
+ "hb",
2132
+ "H",
2133
+ "hB"
2134
+ ],
2135
+ "KI": [
2136
+ "h",
2137
+ "hb",
2138
+ "H",
2139
+ "hB"
2140
+ ],
2141
+ "KN": [
2142
+ "h",
2143
+ "hb",
2144
+ "H",
2145
+ "hB"
2146
+ ],
2147
+ "KY": [
2148
+ "h",
2149
+ "hb",
2150
+ "H",
2151
+ "hB"
2152
+ ],
2153
+ "LC": [
2154
+ "h",
2155
+ "hb",
2156
+ "H",
2157
+ "hB"
2158
+ ],
2159
+ "LR": [
2160
+ "h",
2161
+ "hb",
2162
+ "H",
2163
+ "hB"
2164
+ ],
2165
+ "MH": [
2166
+ "h",
2167
+ "hb",
2168
+ "H",
2169
+ "hB"
2170
+ ],
2171
+ "MP": [
2172
+ "h",
2173
+ "hb",
2174
+ "H",
2175
+ "hB"
2176
+ ],
2177
+ "MW": [
2178
+ "h",
2179
+ "hb",
2180
+ "H",
2181
+ "hB"
2182
+ ],
2183
+ "NZ": [
2184
+ "h",
2185
+ "hb",
2186
+ "H",
2187
+ "hB"
2188
+ ],
2189
+ "SB": [
2190
+ "h",
2191
+ "hb",
2192
+ "H",
2193
+ "hB"
2194
+ ],
2195
+ "SG": [
2196
+ "h",
2197
+ "hb",
2198
+ "H",
2199
+ "hB"
2200
+ ],
2201
+ "SL": [
2202
+ "h",
2203
+ "hb",
2204
+ "H",
2205
+ "hB"
2206
+ ],
2207
+ "SS": [
2208
+ "h",
2209
+ "hb",
2210
+ "H",
2211
+ "hB"
2212
+ ],
2213
+ "SZ": [
2214
+ "h",
2215
+ "hb",
2216
+ "H",
2217
+ "hB"
2218
+ ],
2219
+ "TC": [
2220
+ "h",
2221
+ "hb",
2222
+ "H",
2223
+ "hB"
2224
+ ],
2225
+ "TT": [
2226
+ "h",
2227
+ "hb",
2228
+ "H",
2229
+ "hB"
2230
+ ],
2231
+ "UM": [
2232
+ "h",
2233
+ "hb",
2234
+ "H",
2235
+ "hB"
2236
+ ],
2237
+ "US": [
2238
+ "h",
2239
+ "hb",
2240
+ "H",
2241
+ "hB"
2242
+ ],
2243
+ "VC": [
2244
+ "h",
2245
+ "hb",
2246
+ "H",
2247
+ "hB"
2248
+ ],
2249
+ "VG": [
2250
+ "h",
2251
+ "hb",
2252
+ "H",
2253
+ "hB"
2254
+ ],
2255
+ "VI": [
2256
+ "h",
2257
+ "hb",
2258
+ "H",
2259
+ "hB"
2260
+ ],
2261
+ "ZM": [
2262
+ "h",
2263
+ "hb",
2264
+ "H",
2265
+ "hB"
2266
+ ],
2267
+ "BO": [
2268
+ "H",
2269
+ "hB",
2270
+ "h",
2271
+ "hb"
2272
+ ],
2273
+ "EC": [
2274
+ "H",
2275
+ "hB",
2276
+ "h",
2277
+ "hb"
2278
+ ],
2279
+ "ES": [
2280
+ "H",
2281
+ "hB",
2282
+ "h",
2283
+ "hb"
2284
+ ],
2285
+ "GQ": [
2286
+ "H",
2287
+ "hB",
2288
+ "h",
2289
+ "hb"
2290
+ ],
2291
+ "PE": [
2292
+ "H",
2293
+ "hB",
2294
+ "h",
2295
+ "hb"
2296
+ ],
2297
+ "AE": [
2298
+ "h",
2299
+ "hB",
2300
+ "hb",
2301
+ "H"
2302
+ ],
2303
+ "ar-001": [
2304
+ "h",
2305
+ "hB",
2306
+ "hb",
2307
+ "H"
2308
+ ],
2309
+ "BH": [
2310
+ "h",
2311
+ "hB",
2312
+ "hb",
2313
+ "H"
2314
+ ],
2315
+ "DZ": [
2316
+ "h",
2317
+ "hB",
2318
+ "hb",
2319
+ "H"
2320
+ ],
2321
+ "EG": [
2322
+ "h",
2323
+ "hB",
2324
+ "hb",
2325
+ "H"
2326
+ ],
2327
+ "EH": [
2328
+ "h",
2329
+ "hB",
2330
+ "hb",
2331
+ "H"
2332
+ ],
2333
+ "HK": [
2334
+ "h",
2335
+ "hB",
2336
+ "hb",
2337
+ "H"
2338
+ ],
2339
+ "IQ": [
2340
+ "h",
2341
+ "hB",
2342
+ "hb",
2343
+ "H"
2344
+ ],
2345
+ "JO": [
2346
+ "h",
2347
+ "hB",
2348
+ "hb",
2349
+ "H"
2350
+ ],
2351
+ "KW": [
2352
+ "h",
2353
+ "hB",
2354
+ "hb",
2355
+ "H"
2356
+ ],
2357
+ "LB": [
2358
+ "h",
2359
+ "hB",
2360
+ "hb",
2361
+ "H"
2362
+ ],
2363
+ "LY": [
2364
+ "h",
2365
+ "hB",
2366
+ "hb",
2367
+ "H"
2368
+ ],
2369
+ "MO": [
2370
+ "h",
2371
+ "hB",
2372
+ "hb",
2373
+ "H"
2374
+ ],
2375
+ "MR": [
2376
+ "h",
2377
+ "hB",
2378
+ "hb",
2379
+ "H"
2380
+ ],
2381
+ "OM": [
2382
+ "h",
2383
+ "hB",
2384
+ "hb",
2385
+ "H"
2386
+ ],
2387
+ "PH": [
2388
+ "h",
2389
+ "hB",
2390
+ "hb",
2391
+ "H"
2392
+ ],
2393
+ "PS": [
2394
+ "h",
2395
+ "hB",
2396
+ "hb",
2397
+ "H"
2398
+ ],
2399
+ "QA": [
2400
+ "h",
2401
+ "hB",
2402
+ "hb",
2403
+ "H"
2404
+ ],
2405
+ "SA": [
2406
+ "h",
2407
+ "hB",
2408
+ "hb",
2409
+ "H"
2410
+ ],
2411
+ "SD": [
2412
+ "h",
2413
+ "hB",
2414
+ "hb",
2415
+ "H"
2416
+ ],
2417
+ "SY": [
2418
+ "h",
2419
+ "hB",
2420
+ "hb",
2421
+ "H"
2422
+ ],
2423
+ "TN": [
2424
+ "h",
2425
+ "hB",
2426
+ "hb",
2427
+ "H"
2428
+ ],
2429
+ "YE": [
2430
+ "h",
2431
+ "hB",
2432
+ "hb",
2433
+ "H"
2434
+ ],
2435
+ "AF": [
2436
+ "H",
2437
+ "hb",
2438
+ "hB",
2439
+ "h"
2440
+ ],
2441
+ "LA": [
2442
+ "H",
2443
+ "hb",
2444
+ "hB",
2445
+ "h"
2446
+ ],
2447
+ "CN": [
2448
+ "H",
2449
+ "hB",
2450
+ "hb",
2451
+ "h"
2452
+ ],
2453
+ "LV": [
2454
+ "H",
2455
+ "hB",
2456
+ "hb",
2457
+ "h"
2458
+ ],
2459
+ "TL": [
2460
+ "H",
2461
+ "hB",
2462
+ "hb",
2463
+ "h"
2464
+ ],
2465
+ "zu-ZA": [
2466
+ "H",
2467
+ "hB",
2468
+ "hb",
2469
+ "h"
2470
+ ],
2471
+ "CD": [
2472
+ "hB",
2473
+ "H"
2474
+ ],
2475
+ "IR": [
2476
+ "hB",
2477
+ "H"
2478
+ ],
2479
+ "hi-IN": [
2480
+ "hB",
2481
+ "h",
2482
+ "H"
2483
+ ],
2484
+ "kn-IN": [
2485
+ "hB",
2486
+ "h",
2487
+ "H"
2488
+ ],
2489
+ "ml-IN": [
2490
+ "hB",
2491
+ "h",
2492
+ "H"
2493
+ ],
2494
+ "te-IN": [
2495
+ "hB",
2496
+ "h",
2497
+ "H"
2498
+ ],
2499
+ "KH": [
2500
+ "hB",
2501
+ "h",
2502
+ "H",
2503
+ "hb"
2504
+ ],
2505
+ "ta-IN": [
2506
+ "hB",
2507
+ "h",
2508
+ "hb",
2509
+ "H"
2510
+ ],
2511
+ "BN": [
2512
+ "hb",
2513
+ "hB",
2514
+ "h",
2515
+ "H"
2516
+ ],
2517
+ "MY": [
2518
+ "hb",
2519
+ "hB",
2520
+ "h",
2521
+ "H"
2522
+ ],
2523
+ "ET": [
2524
+ "hB",
2525
+ "hb",
2526
+ "h",
2527
+ "H"
2528
+ ],
2529
+ "gu-IN": [
2530
+ "hB",
2531
+ "hb",
2532
+ "h",
2533
+ "H"
2534
+ ],
2535
+ "mr-IN": [
2536
+ "hB",
2537
+ "hb",
2538
+ "h",
2539
+ "H"
2540
+ ],
2541
+ "pa-IN": [
2542
+ "hB",
2543
+ "hb",
2544
+ "h",
2545
+ "H"
2546
+ ],
2547
+ "TW": [
2548
+ "hB",
2549
+ "hb",
2550
+ "h",
2551
+ "H"
2552
+ ],
2553
+ "KE": [
2554
+ "hB",
2555
+ "hb",
2556
+ "H",
2557
+ "h"
2558
+ ],
2559
+ "MM": [
2560
+ "hB",
2561
+ "hb",
2562
+ "H",
2563
+ "h"
2564
+ ],
2565
+ "TZ": [
2566
+ "hB",
2567
+ "hb",
2568
+ "H",
2569
+ "h"
2570
+ ],
2571
+ "UG": [
2572
+ "hB",
2573
+ "hb",
2574
+ "H",
2575
+ "h"
2576
+ ]
2577
+ };
2578
+
2579
+ /**
2580
+ * Returns the best matching date time pattern if a date time skeleton
2581
+ * pattern is provided with a locale. Follows the Unicode specification:
2582
+ * https://www.unicode.org/reports/tr35/tr35-dates.html#table-mapping-requested-time-skeletons-to-patterns
2583
+ * @param skeleton date time skeleton pattern that possibly includes j, J or C
2584
+ * @param locale
2585
+ */
2586
+ function getBestPattern(skeleton, locale) {
2587
+ var skeletonCopy = '';
2588
+ for (var patternPos = 0; patternPos < skeleton.length; patternPos++) {
2589
+ var patternChar = skeleton.charAt(patternPos);
2590
+ if (patternChar === 'j') {
2591
+ var extraLength = 0;
2592
+ while (patternPos + 1 < skeleton.length &&
2593
+ skeleton.charAt(patternPos + 1) === patternChar) {
2594
+ extraLength++;
2595
+ patternPos++;
2596
+ }
2597
+ var hourLen = 1 + (extraLength & 1);
2598
+ var dayPeriodLen = extraLength < 2 ? 1 : 3 + (extraLength >> 1);
2599
+ var dayPeriodChar = 'a';
2600
+ var hourChar = getDefaultHourSymbolFromLocale(locale);
2601
+ if (hourChar == 'H' || hourChar == 'k') {
2602
+ dayPeriodLen = 0;
2603
+ }
2604
+ while (dayPeriodLen-- > 0) {
2605
+ skeletonCopy += dayPeriodChar;
2606
+ }
2607
+ while (hourLen-- > 0) {
2608
+ skeletonCopy = hourChar + skeletonCopy;
2609
+ }
2610
+ }
2611
+ else if (patternChar === 'J') {
2612
+ skeletonCopy += 'H';
2613
+ }
2614
+ else {
2615
+ skeletonCopy += patternChar;
2616
+ }
2617
+ }
2618
+ return skeletonCopy;
2619
+ }
2620
+ /**
2621
+ * Maps the [hour cycle type](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/hourCycle)
2622
+ * of the given `locale` to the corresponding time pattern.
2623
+ * @param locale
2624
+ */
2625
+ function getDefaultHourSymbolFromLocale(locale) {
2626
+ var hourCycle = locale.hourCycle;
2627
+ if (hourCycle === undefined &&
2628
+ // @ts-ignore hourCycle(s) is not identified yet
2629
+ locale.hourCycles &&
2630
+ // @ts-ignore
2631
+ locale.hourCycles.length) {
2632
+ // @ts-ignore
2633
+ hourCycle = locale.hourCycles[0];
2634
+ }
2635
+ if (hourCycle) {
2636
+ switch (hourCycle) {
2637
+ case 'h24':
2638
+ return 'k';
2639
+ case 'h23':
2640
+ return 'H';
2641
+ case 'h12':
2642
+ return 'h';
2643
+ case 'h11':
2644
+ return 'K';
2645
+ default:
2646
+ throw new Error('Invalid hourCycle');
2647
+ }
2648
+ }
2649
+ // TODO: Once hourCycle is fully supported remove the following with data generation
2650
+ var languageTag = locale.language;
2651
+ var regionTag;
2652
+ if (languageTag !== 'root') {
2653
+ regionTag = locale.maximize().region;
2654
+ }
2655
+ var hourCycles = timeData[regionTag || ''] ||
2656
+ timeData[languageTag || ''] ||
2657
+ timeData["".concat(languageTag, "-001")] ||
2658
+ timeData['001'];
2659
+ return hourCycles[0];
2660
+ }
2661
+
2662
+ var _a;
2663
+ var SPACE_SEPARATOR_START_REGEX = new RegExp("^".concat(SPACE_SEPARATOR_REGEX.source, "*"));
2664
+ var SPACE_SEPARATOR_END_REGEX = new RegExp("".concat(SPACE_SEPARATOR_REGEX.source, "*$"));
2665
+ function createLocation(start, end) {
2666
+ return { start: start, end: end };
2667
+ }
2668
+ // #region Ponyfills
2669
+ // Consolidate these variables up top for easier toggling during debugging
2670
+ var hasNativeStartsWith = !!String.prototype.startsWith;
2671
+ var hasNativeFromCodePoint = !!String.fromCodePoint;
2672
+ var hasNativeFromEntries = !!Object.fromEntries;
2673
+ var hasNativeCodePointAt = !!String.prototype.codePointAt;
2674
+ var hasTrimStart = !!String.prototype.trimStart;
2675
+ var hasTrimEnd = !!String.prototype.trimEnd;
2676
+ var hasNativeIsSafeInteger = !!Number.isSafeInteger;
2677
+ var isSafeInteger = hasNativeIsSafeInteger
2678
+ ? Number.isSafeInteger
2679
+ : function (n) {
2680
+ return (typeof n === 'number' &&
2681
+ isFinite(n) &&
2682
+ Math.floor(n) === n &&
2683
+ Math.abs(n) <= 0x1fffffffffffff);
2684
+ };
2685
+ // IE11 does not support y and u.
2686
+ var REGEX_SUPPORTS_U_AND_Y = true;
2687
+ try {
2688
+ var re = RE('([^\\p{White_Space}\\p{Pattern_Syntax}]*)', 'yu');
2689
+ /**
2690
+ * legacy Edge or Xbox One browser
2691
+ * Unicode flag support: supported
2692
+ * Pattern_Syntax support: not supported
2693
+ * See https://github.com/formatjs/formatjs/issues/2822
2694
+ */
2695
+ REGEX_SUPPORTS_U_AND_Y = ((_a = re.exec('a')) === null || _a === void 0 ? void 0 : _a[0]) === 'a';
2696
+ }
2697
+ catch (_) {
2698
+ REGEX_SUPPORTS_U_AND_Y = false;
2699
+ }
2700
+ var startsWith = hasNativeStartsWith
2701
+ ? // Native
2702
+ function startsWith(s, search, position) {
2703
+ return s.startsWith(search, position);
2704
+ }
2705
+ : // For IE11
2706
+ function startsWith(s, search, position) {
2707
+ return s.slice(position, position + search.length) === search;
2708
+ };
2709
+ var fromCodePoint = hasNativeFromCodePoint
2710
+ ? String.fromCodePoint
2711
+ : // IE11
2712
+ function fromCodePoint() {
2713
+ var codePoints = [];
2714
+ for (var _i = 0; _i < arguments.length; _i++) {
2715
+ codePoints[_i] = arguments[_i];
2716
+ }
2717
+ var elements = '';
2718
+ var length = codePoints.length;
2719
+ var i = 0;
2720
+ var code;
2721
+ while (length > i) {
2722
+ code = codePoints[i++];
2723
+ if (code > 0x10ffff)
2724
+ throw RangeError(code + ' is not a valid code point');
2725
+ elements +=
2726
+ code < 0x10000
2727
+ ? String.fromCharCode(code)
2728
+ : String.fromCharCode(((code -= 0x10000) >> 10) + 0xd800, (code % 0x400) + 0xdc00);
2729
+ }
2730
+ return elements;
2731
+ };
2732
+ var fromEntries =
2733
+ // native
2734
+ hasNativeFromEntries
2735
+ ? Object.fromEntries
2736
+ : // Ponyfill
2737
+ function fromEntries(entries) {
2738
+ var obj = {};
2739
+ for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
2740
+ var _a = entries_1[_i], k = _a[0], v = _a[1];
2741
+ obj[k] = v;
2742
+ }
2743
+ return obj;
2744
+ };
2745
+ var codePointAt = hasNativeCodePointAt
2746
+ ? // Native
2747
+ function codePointAt(s, index) {
2748
+ return s.codePointAt(index);
2749
+ }
2750
+ : // IE 11
2751
+ function codePointAt(s, index) {
2752
+ var size = s.length;
2753
+ if (index < 0 || index >= size) {
2754
+ return undefined;
2755
+ }
2756
+ var first = s.charCodeAt(index);
2757
+ var second;
2758
+ return first < 0xd800 ||
2759
+ first > 0xdbff ||
2760
+ index + 1 === size ||
2761
+ (second = s.charCodeAt(index + 1)) < 0xdc00 ||
2762
+ second > 0xdfff
2763
+ ? first
2764
+ : ((first - 0xd800) << 10) + (second - 0xdc00) + 0x10000;
2765
+ };
2766
+ var trimStart = hasTrimStart
2767
+ ? // Native
2768
+ function trimStart(s) {
2769
+ return s.trimStart();
2770
+ }
2771
+ : // Ponyfill
2772
+ function trimStart(s) {
2773
+ return s.replace(SPACE_SEPARATOR_START_REGEX, '');
2774
+ };
2775
+ var trimEnd = hasTrimEnd
2776
+ ? // Native
2777
+ function trimEnd(s) {
2778
+ return s.trimEnd();
2779
+ }
2780
+ : // Ponyfill
2781
+ function trimEnd(s) {
2782
+ return s.replace(SPACE_SEPARATOR_END_REGEX, '');
2783
+ };
2784
+ // Prevent minifier to translate new RegExp to literal form that might cause syntax error on IE11.
2785
+ function RE(s, flag) {
2786
+ return new RegExp(s, flag);
2787
+ }
2788
+ // #endregion
2789
+ var matchIdentifierAtIndex;
2790
+ if (REGEX_SUPPORTS_U_AND_Y) {
2791
+ // Native
2792
+ var IDENTIFIER_PREFIX_RE_1 = RE('([^\\p{White_Space}\\p{Pattern_Syntax}]*)', 'yu');
2793
+ matchIdentifierAtIndex = function matchIdentifierAtIndex(s, index) {
2794
+ var _a;
2795
+ IDENTIFIER_PREFIX_RE_1.lastIndex = index;
2796
+ var match = IDENTIFIER_PREFIX_RE_1.exec(s);
2797
+ return (_a = match[1]) !== null && _a !== void 0 ? _a : '';
2798
+ };
2799
+ }
2800
+ else {
2801
+ // IE11
2802
+ matchIdentifierAtIndex = function matchIdentifierAtIndex(s, index) {
2803
+ var match = [];
2804
+ while (true) {
2805
+ var c = codePointAt(s, index);
2806
+ if (c === undefined || _isWhiteSpace(c) || _isPatternSyntax(c)) {
2807
+ break;
2808
+ }
2809
+ match.push(c);
2810
+ index += c >= 0x10000 ? 2 : 1;
2811
+ }
2812
+ return fromCodePoint.apply(void 0, match);
2813
+ };
2814
+ }
2815
+ var Parser = /** @class */ (function () {
2816
+ function Parser(message, options) {
2817
+ if (options === void 0) { options = {}; }
2818
+ this.message = message;
2819
+ this.position = { offset: 0, line: 1, column: 1 };
2820
+ this.ignoreTag = !!options.ignoreTag;
2821
+ this.locale = options.locale;
2822
+ this.requiresOtherClause = !!options.requiresOtherClause;
2823
+ this.shouldParseSkeletons = !!options.shouldParseSkeletons;
2824
+ }
2825
+ Parser.prototype.parse = function () {
2826
+ if (this.offset() !== 0) {
2827
+ throw Error('parser can only be used once');
2828
+ }
2829
+ return this.parseMessage(0, '', false);
2830
+ };
2831
+ Parser.prototype.parseMessage = function (nestingLevel, parentArgType, expectingCloseTag) {
2832
+ var elements = [];
2833
+ while (!this.isEOF()) {
2834
+ var char = this.char();
2835
+ if (char === 123 /* `{` */) {
2836
+ var result = this.parseArgument(nestingLevel, expectingCloseTag);
2837
+ if (result.err) {
2838
+ return result;
2839
+ }
2840
+ elements.push(result.val);
2841
+ }
2842
+ else if (char === 125 /* `}` */ && nestingLevel > 0) {
2843
+ break;
2844
+ }
2845
+ else if (char === 35 /* `#` */ &&
2846
+ (parentArgType === 'plural' || parentArgType === 'selectordinal')) {
2847
+ var position = this.clonePosition();
2848
+ this.bump();
2849
+ elements.push({
2850
+ type: TYPE.pound,
2851
+ location: createLocation(position, this.clonePosition()),
2852
+ });
2853
+ }
2854
+ else if (char === 60 /* `<` */ &&
2855
+ !this.ignoreTag &&
2856
+ this.peek() === 47 // char code for '/'
2857
+ ) {
2858
+ if (expectingCloseTag) {
2859
+ break;
2860
+ }
2861
+ else {
2862
+ return this.error(ErrorKind.UNMATCHED_CLOSING_TAG, createLocation(this.clonePosition(), this.clonePosition()));
2863
+ }
2864
+ }
2865
+ else if (char === 60 /* `<` */ &&
2866
+ !this.ignoreTag &&
2867
+ _isAlpha(this.peek() || 0)) {
2868
+ var result = this.parseTag(nestingLevel, parentArgType);
2869
+ if (result.err) {
2870
+ return result;
2871
+ }
2872
+ elements.push(result.val);
2873
+ }
2874
+ else {
2875
+ var result = this.parseLiteral(nestingLevel, parentArgType);
2876
+ if (result.err) {
2877
+ return result;
2878
+ }
2879
+ elements.push(result.val);
2880
+ }
2881
+ }
2882
+ return { val: elements, err: null };
2883
+ };
2884
+ /**
2885
+ * A tag name must start with an ASCII lower/upper case letter. The grammar is based on the
2886
+ * [custom element name][] except that a dash is NOT always mandatory and uppercase letters
2887
+ * are accepted:
2888
+ *
2889
+ * ```
2890
+ * tag ::= "<" tagName (whitespace)* "/>" | "<" tagName (whitespace)* ">" message "</" tagName (whitespace)* ">"
2891
+ * tagName ::= [a-z] (PENChar)*
2892
+ * PENChar ::=
2893
+ * "-" | "." | [0-9] | "_" | [a-z] | [A-Z] | #xB7 | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x37D] |
2894
+ * [#x37F-#x1FFF] | [#x200C-#x200D] | [#x203F-#x2040] | [#x2070-#x218F] | [#x2C00-#x2FEF] |
2895
+ * [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
2896
+ * ```
2897
+ *
2898
+ * [custom element name]: https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
2899
+ * NOTE: We're a bit more lax here since HTML technically does not allow uppercase HTML element but we do
2900
+ * since other tag-based engines like React allow it
2901
+ */
2902
+ Parser.prototype.parseTag = function (nestingLevel, parentArgType) {
2903
+ var startPosition = this.clonePosition();
2904
+ this.bump(); // `<`
2905
+ var tagName = this.parseTagName();
2906
+ this.bumpSpace();
2907
+ if (this.bumpIf('/>')) {
2908
+ // Self closing tag
2909
+ return {
2910
+ val: {
2911
+ type: TYPE.literal,
2912
+ value: "<".concat(tagName, "/>"),
2913
+ location: createLocation(startPosition, this.clonePosition()),
2914
+ },
2915
+ err: null,
2916
+ };
2917
+ }
2918
+ else if (this.bumpIf('>')) {
2919
+ var childrenResult = this.parseMessage(nestingLevel + 1, parentArgType, true);
2920
+ if (childrenResult.err) {
2921
+ return childrenResult;
2922
+ }
2923
+ var children = childrenResult.val;
2924
+ // Expecting a close tag
2925
+ var endTagStartPosition = this.clonePosition();
2926
+ if (this.bumpIf('</')) {
2927
+ if (this.isEOF() || !_isAlpha(this.char())) {
2928
+ return this.error(ErrorKind.INVALID_TAG, createLocation(endTagStartPosition, this.clonePosition()));
2929
+ }
2930
+ var closingTagNameStartPosition = this.clonePosition();
2931
+ var closingTagName = this.parseTagName();
2932
+ if (tagName !== closingTagName) {
2933
+ return this.error(ErrorKind.UNMATCHED_CLOSING_TAG, createLocation(closingTagNameStartPosition, this.clonePosition()));
2934
+ }
2935
+ this.bumpSpace();
2936
+ if (!this.bumpIf('>')) {
2937
+ return this.error(ErrorKind.INVALID_TAG, createLocation(endTagStartPosition, this.clonePosition()));
2938
+ }
2939
+ return {
2940
+ val: {
2941
+ type: TYPE.tag,
2942
+ value: tagName,
2943
+ children: children,
2944
+ location: createLocation(startPosition, this.clonePosition()),
2945
+ },
2946
+ err: null,
2947
+ };
2948
+ }
2949
+ else {
2950
+ return this.error(ErrorKind.UNCLOSED_TAG, createLocation(startPosition, this.clonePosition()));
2951
+ }
2952
+ }
2953
+ else {
2954
+ return this.error(ErrorKind.INVALID_TAG, createLocation(startPosition, this.clonePosition()));
2955
+ }
2956
+ };
2957
+ /**
2958
+ * This method assumes that the caller has peeked ahead for the first tag character.
2959
+ */
2960
+ Parser.prototype.parseTagName = function () {
2961
+ var startOffset = this.offset();
2962
+ this.bump(); // the first tag name character
2963
+ while (!this.isEOF() && _isPotentialElementNameChar(this.char())) {
2964
+ this.bump();
2965
+ }
2966
+ return this.message.slice(startOffset, this.offset());
2967
+ };
2968
+ Parser.prototype.parseLiteral = function (nestingLevel, parentArgType) {
2969
+ var start = this.clonePosition();
2970
+ var value = '';
2971
+ while (true) {
2972
+ var parseQuoteResult = this.tryParseQuote(parentArgType);
2973
+ if (parseQuoteResult) {
2974
+ value += parseQuoteResult;
2975
+ continue;
2976
+ }
2977
+ var parseUnquotedResult = this.tryParseUnquoted(nestingLevel, parentArgType);
2978
+ if (parseUnquotedResult) {
2979
+ value += parseUnquotedResult;
2980
+ continue;
2981
+ }
2982
+ var parseLeftAngleResult = this.tryParseLeftAngleBracket();
2983
+ if (parseLeftAngleResult) {
2984
+ value += parseLeftAngleResult;
2985
+ continue;
2986
+ }
2987
+ break;
2988
+ }
2989
+ var location = createLocation(start, this.clonePosition());
2990
+ return {
2991
+ val: { type: TYPE.literal, value: value, location: location },
2992
+ err: null,
2993
+ };
2994
+ };
2995
+ Parser.prototype.tryParseLeftAngleBracket = function () {
2996
+ if (!this.isEOF() &&
2997
+ this.char() === 60 /* `<` */ &&
2998
+ (this.ignoreTag ||
2999
+ // If at the opening tag or closing tag position, bail.
3000
+ !_isAlphaOrSlash(this.peek() || 0))) {
3001
+ this.bump(); // `<`
3002
+ return '<';
3003
+ }
3004
+ return null;
3005
+ };
3006
+ /**
3007
+ * Starting with ICU 4.8, an ASCII apostrophe only starts quoted text if it immediately precedes
3008
+ * a character that requires quoting (that is, "only where needed"), and works the same in
3009
+ * nested messages as on the top level of the pattern. The new behavior is otherwise compatible.
3010
+ */
3011
+ Parser.prototype.tryParseQuote = function (parentArgType) {
3012
+ if (this.isEOF() || this.char() !== 39 /* `'` */) {
3013
+ return null;
3014
+ }
3015
+ // Parse escaped char following the apostrophe, or early return if there is no escaped char.
3016
+ // Check if is valid escaped character
3017
+ switch (this.peek()) {
3018
+ case 39 /* `'` */:
3019
+ // double quote, should return as a single quote.
3020
+ this.bump();
3021
+ this.bump();
3022
+ return "'";
3023
+ // '{', '<', '>', '}'
3024
+ case 123:
3025
+ case 60:
3026
+ case 62:
3027
+ case 125:
3028
+ break;
3029
+ case 35: // '#'
3030
+ if (parentArgType === 'plural' || parentArgType === 'selectordinal') {
3031
+ break;
3032
+ }
3033
+ return null;
3034
+ default:
3035
+ return null;
3036
+ }
3037
+ this.bump(); // apostrophe
3038
+ var codePoints = [this.char()]; // escaped char
3039
+ this.bump();
3040
+ // read chars until the optional closing apostrophe is found
3041
+ while (!this.isEOF()) {
3042
+ var ch = this.char();
3043
+ if (ch === 39 /* `'` */) {
3044
+ if (this.peek() === 39 /* `'` */) {
3045
+ codePoints.push(39);
3046
+ // Bump one more time because we need to skip 2 characters.
3047
+ this.bump();
3048
+ }
3049
+ else {
3050
+ // Optional closing apostrophe.
3051
+ this.bump();
3052
+ break;
3053
+ }
3054
+ }
3055
+ else {
3056
+ codePoints.push(ch);
3057
+ }
3058
+ this.bump();
3059
+ }
3060
+ return fromCodePoint.apply(void 0, codePoints);
3061
+ };
3062
+ Parser.prototype.tryParseUnquoted = function (nestingLevel, parentArgType) {
3063
+ if (this.isEOF()) {
3064
+ return null;
3065
+ }
3066
+ var ch = this.char();
3067
+ if (ch === 60 /* `<` */ ||
3068
+ ch === 123 /* `{` */ ||
3069
+ (ch === 35 /* `#` */ &&
3070
+ (parentArgType === 'plural' || parentArgType === 'selectordinal')) ||
3071
+ (ch === 125 /* `}` */ && nestingLevel > 0)) {
3072
+ return null;
3073
+ }
3074
+ else {
3075
+ this.bump();
3076
+ return fromCodePoint(ch);
3077
+ }
3078
+ };
3079
+ Parser.prototype.parseArgument = function (nestingLevel, expectingCloseTag) {
3080
+ var openingBracePosition = this.clonePosition();
3081
+ this.bump(); // `{`
3082
+ this.bumpSpace();
3083
+ if (this.isEOF()) {
3084
+ return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
3085
+ }
3086
+ if (this.char() === 125 /* `}` */) {
3087
+ this.bump();
3088
+ return this.error(ErrorKind.EMPTY_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
3089
+ }
3090
+ // argument name
3091
+ var value = this.parseIdentifierIfPossible().value;
3092
+ if (!value) {
3093
+ return this.error(ErrorKind.MALFORMED_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
3094
+ }
3095
+ this.bumpSpace();
3096
+ if (this.isEOF()) {
3097
+ return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
3098
+ }
3099
+ switch (this.char()) {
3100
+ // Simple argument: `{name}`
3101
+ case 125 /* `}` */: {
3102
+ this.bump(); // `}`
3103
+ return {
3104
+ val: {
3105
+ type: TYPE.argument,
3106
+ // value does not include the opening and closing braces.
3107
+ value: value,
3108
+ location: createLocation(openingBracePosition, this.clonePosition()),
3109
+ },
3110
+ err: null,
3111
+ };
3112
+ }
3113
+ // Argument with options: `{name, format, ...}`
3114
+ case 44 /* `,` */: {
3115
+ this.bump(); // `,`
3116
+ this.bumpSpace();
3117
+ if (this.isEOF()) {
3118
+ return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
3119
+ }
3120
+ return this.parseArgumentOptions(nestingLevel, expectingCloseTag, value, openingBracePosition);
3121
+ }
3122
+ default:
3123
+ return this.error(ErrorKind.MALFORMED_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
3124
+ }
3125
+ };
3126
+ /**
3127
+ * Advance the parser until the end of the identifier, if it is currently on
3128
+ * an identifier character. Return an empty string otherwise.
3129
+ */
3130
+ Parser.prototype.parseIdentifierIfPossible = function () {
3131
+ var startingPosition = this.clonePosition();
3132
+ var startOffset = this.offset();
3133
+ var value = matchIdentifierAtIndex(this.message, startOffset);
3134
+ var endOffset = startOffset + value.length;
3135
+ this.bumpTo(endOffset);
3136
+ var endPosition = this.clonePosition();
3137
+ var location = createLocation(startingPosition, endPosition);
3138
+ return { value: value, location: location };
3139
+ };
3140
+ Parser.prototype.parseArgumentOptions = function (nestingLevel, expectingCloseTag, value, openingBracePosition) {
3141
+ var _a;
3142
+ // Parse this range:
3143
+ // {name, type, style}
3144
+ // ^---^
3145
+ var typeStartPosition = this.clonePosition();
3146
+ var argType = this.parseIdentifierIfPossible().value;
3147
+ var typeEndPosition = this.clonePosition();
3148
+ switch (argType) {
3149
+ case '':
3150
+ // Expecting a style string number, date, time, plural, selectordinal, or select.
3151
+ return this.error(ErrorKind.EXPECT_ARGUMENT_TYPE, createLocation(typeStartPosition, typeEndPosition));
3152
+ case 'number':
3153
+ case 'date':
3154
+ case 'time': {
3155
+ // Parse this range:
3156
+ // {name, number, style}
3157
+ // ^-------^
3158
+ this.bumpSpace();
3159
+ var styleAndLocation = null;
3160
+ if (this.bumpIf(',')) {
3161
+ this.bumpSpace();
3162
+ var styleStartPosition = this.clonePosition();
3163
+ var result = this.parseSimpleArgStyleIfPossible();
3164
+ if (result.err) {
3165
+ return result;
3166
+ }
3167
+ var style = trimEnd(result.val);
3168
+ if (style.length === 0) {
3169
+ return this.error(ErrorKind.EXPECT_ARGUMENT_STYLE, createLocation(this.clonePosition(), this.clonePosition()));
3170
+ }
3171
+ var styleLocation = createLocation(styleStartPosition, this.clonePosition());
3172
+ styleAndLocation = { style: style, styleLocation: styleLocation };
3173
+ }
3174
+ var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
3175
+ if (argCloseResult.err) {
3176
+ return argCloseResult;
3177
+ }
3178
+ var location_1 = createLocation(openingBracePosition, this.clonePosition());
3179
+ // Extract style or skeleton
3180
+ if (styleAndLocation && startsWith(styleAndLocation === null || styleAndLocation === void 0 ? void 0 : styleAndLocation.style, '::', 0)) {
3181
+ // Skeleton starts with `::`.
3182
+ var skeleton = trimStart(styleAndLocation.style.slice(2));
3183
+ if (argType === 'number') {
3184
+ var result = this.parseNumberSkeletonFromString(skeleton, styleAndLocation.styleLocation);
3185
+ if (result.err) {
3186
+ return result;
3187
+ }
3188
+ return {
3189
+ val: { type: TYPE.number, value: value, location: location_1, style: result.val },
3190
+ err: null,
3191
+ };
3192
+ }
3193
+ else {
3194
+ if (skeleton.length === 0) {
3195
+ return this.error(ErrorKind.EXPECT_DATE_TIME_SKELETON, location_1);
3196
+ }
3197
+ var dateTimePattern = skeleton;
3198
+ // Get "best match" pattern only if locale is passed, if not, let it
3199
+ // pass as-is where `parseDateTimeSkeleton()` will throw an error
3200
+ // for unsupported patterns.
3201
+ if (this.locale) {
3202
+ dateTimePattern = getBestPattern(skeleton, this.locale);
3203
+ }
3204
+ var style = {
3205
+ type: SKELETON_TYPE.dateTime,
3206
+ pattern: dateTimePattern,
3207
+ location: styleAndLocation.styleLocation,
3208
+ parsedOptions: this.shouldParseSkeletons
3209
+ ? parseDateTimeSkeleton(dateTimePattern)
3210
+ : {},
3211
+ };
3212
+ var type = argType === 'date' ? TYPE.date : TYPE.time;
3213
+ return {
3214
+ val: { type: type, value: value, location: location_1, style: style },
3215
+ err: null,
3216
+ };
3217
+ }
3218
+ }
3219
+ // Regular style or no style.
3220
+ return {
3221
+ val: {
3222
+ type: argType === 'number'
3223
+ ? TYPE.number
3224
+ : argType === 'date'
3225
+ ? TYPE.date
3226
+ : TYPE.time,
3227
+ value: value,
3228
+ location: location_1,
3229
+ style: (_a = styleAndLocation === null || styleAndLocation === void 0 ? void 0 : styleAndLocation.style) !== null && _a !== void 0 ? _a : null,
3230
+ },
3231
+ err: null,
3232
+ };
3233
+ }
3234
+ case 'plural':
3235
+ case 'selectordinal':
3236
+ case 'select': {
3237
+ // Parse this range:
3238
+ // {name, plural, options}
3239
+ // ^---------^
3240
+ var typeEndPosition_1 = this.clonePosition();
3241
+ this.bumpSpace();
3242
+ if (!this.bumpIf(',')) {
3243
+ return this.error(ErrorKind.EXPECT_SELECT_ARGUMENT_OPTIONS, createLocation(typeEndPosition_1, __assign({}, typeEndPosition_1)));
3244
+ }
3245
+ this.bumpSpace();
3246
+ // Parse offset:
3247
+ // {name, plural, offset:1, options}
3248
+ // ^-----^
3249
+ //
3250
+ // or the first option:
3251
+ //
3252
+ // {name, plural, one {...} other {...}}
3253
+ // ^--^
3254
+ var identifierAndLocation = this.parseIdentifierIfPossible();
3255
+ var pluralOffset = 0;
3256
+ if (argType !== 'select' && identifierAndLocation.value === 'offset') {
3257
+ if (!this.bumpIf(':')) {
3258
+ return this.error(ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, createLocation(this.clonePosition(), this.clonePosition()));
3259
+ }
3260
+ this.bumpSpace();
3261
+ var result = this.tryParseDecimalInteger(ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, ErrorKind.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE);
3262
+ if (result.err) {
3263
+ return result;
3264
+ }
3265
+ // Parse another identifier for option parsing
3266
+ this.bumpSpace();
3267
+ identifierAndLocation = this.parseIdentifierIfPossible();
3268
+ pluralOffset = result.val;
3269
+ }
3270
+ var optionsResult = this.tryParsePluralOrSelectOptions(nestingLevel, argType, expectingCloseTag, identifierAndLocation);
3271
+ if (optionsResult.err) {
3272
+ return optionsResult;
3273
+ }
3274
+ var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
3275
+ if (argCloseResult.err) {
3276
+ return argCloseResult;
3277
+ }
3278
+ var location_2 = createLocation(openingBracePosition, this.clonePosition());
3279
+ if (argType === 'select') {
3280
+ return {
3281
+ val: {
3282
+ type: TYPE.select,
3283
+ value: value,
3284
+ options: fromEntries(optionsResult.val),
3285
+ location: location_2,
3286
+ },
3287
+ err: null,
3288
+ };
3289
+ }
3290
+ else {
3291
+ return {
3292
+ val: {
3293
+ type: TYPE.plural,
3294
+ value: value,
3295
+ options: fromEntries(optionsResult.val),
3296
+ offset: pluralOffset,
3297
+ pluralType: argType === 'plural' ? 'cardinal' : 'ordinal',
3298
+ location: location_2,
3299
+ },
3300
+ err: null,
3301
+ };
3302
+ }
3303
+ }
3304
+ default:
3305
+ return this.error(ErrorKind.INVALID_ARGUMENT_TYPE, createLocation(typeStartPosition, typeEndPosition));
3306
+ }
3307
+ };
3308
+ Parser.prototype.tryParseArgumentClose = function (openingBracePosition) {
3309
+ // Parse: {value, number, ::currency/GBP }
3310
+ //
3311
+ if (this.isEOF() || this.char() !== 125 /* `}` */) {
3312
+ return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
3313
+ }
3314
+ this.bump(); // `}`
3315
+ return { val: true, err: null };
3316
+ };
3317
+ /**
3318
+ * See: https://github.com/unicode-org/icu/blob/af7ed1f6d2298013dc303628438ec4abe1f16479/icu4c/source/common/messagepattern.cpp#L659
3319
+ */
3320
+ Parser.prototype.parseSimpleArgStyleIfPossible = function () {
3321
+ var nestedBraces = 0;
3322
+ var startPosition = this.clonePosition();
3323
+ while (!this.isEOF()) {
3324
+ var ch = this.char();
3325
+ switch (ch) {
3326
+ case 39 /* `'` */: {
3327
+ // Treat apostrophe as quoting but include it in the style part.
3328
+ // Find the end of the quoted literal text.
3329
+ this.bump();
3330
+ var apostrophePosition = this.clonePosition();
3331
+ if (!this.bumpUntil("'")) {
3332
+ return this.error(ErrorKind.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE, createLocation(apostrophePosition, this.clonePosition()));
3333
+ }
3334
+ this.bump();
3335
+ break;
3336
+ }
3337
+ case 123 /* `{` */: {
3338
+ nestedBraces += 1;
3339
+ this.bump();
3340
+ break;
3341
+ }
3342
+ case 125 /* `}` */: {
3343
+ if (nestedBraces > 0) {
3344
+ nestedBraces -= 1;
3345
+ }
3346
+ else {
3347
+ return {
3348
+ val: this.message.slice(startPosition.offset, this.offset()),
3349
+ err: null,
3350
+ };
3351
+ }
3352
+ break;
3353
+ }
3354
+ default:
3355
+ this.bump();
3356
+ break;
3357
+ }
3358
+ }
3359
+ return {
3360
+ val: this.message.slice(startPosition.offset, this.offset()),
3361
+ err: null,
3362
+ };
3363
+ };
3364
+ Parser.prototype.parseNumberSkeletonFromString = function (skeleton, location) {
3365
+ var tokens = [];
3366
+ try {
3367
+ tokens = parseNumberSkeletonFromString(skeleton);
3368
+ }
3369
+ catch (e) {
3370
+ return this.error(ErrorKind.INVALID_NUMBER_SKELETON, location);
3371
+ }
3372
+ return {
3373
+ val: {
3374
+ type: SKELETON_TYPE.number,
3375
+ tokens: tokens,
3376
+ location: location,
3377
+ parsedOptions: this.shouldParseSkeletons
3378
+ ? parseNumberSkeleton(tokens)
3379
+ : {},
3380
+ },
3381
+ err: null,
3382
+ };
3383
+ };
3384
+ /**
3385
+ * @param nesting_level The current nesting level of messages.
3386
+ * This can be positive when parsing message fragment in select or plural argument options.
3387
+ * @param parent_arg_type The parent argument's type.
3388
+ * @param parsed_first_identifier If provided, this is the first identifier-like selector of
3389
+ * the argument. It is a by-product of a previous parsing attempt.
3390
+ * @param expecting_close_tag If true, this message is directly or indirectly nested inside
3391
+ * between a pair of opening and closing tags. The nested message will not parse beyond
3392
+ * the closing tag boundary.
3393
+ */
3394
+ Parser.prototype.tryParsePluralOrSelectOptions = function (nestingLevel, parentArgType, expectCloseTag, parsedFirstIdentifier) {
3395
+ var _a;
3396
+ var hasOtherClause = false;
3397
+ var options = [];
3398
+ var parsedSelectors = new Set();
3399
+ var selector = parsedFirstIdentifier.value, selectorLocation = parsedFirstIdentifier.location;
3400
+ // Parse:
3401
+ // one {one apple}
3402
+ // ^--^
3403
+ while (true) {
3404
+ if (selector.length === 0) {
3405
+ var startPosition = this.clonePosition();
3406
+ if (parentArgType !== 'select' && this.bumpIf('=')) {
3407
+ // Try parse `={number}` selector
3408
+ var result = this.tryParseDecimalInteger(ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR, ErrorKind.INVALID_PLURAL_ARGUMENT_SELECTOR);
3409
+ if (result.err) {
3410
+ return result;
3411
+ }
3412
+ selectorLocation = createLocation(startPosition, this.clonePosition());
3413
+ selector = this.message.slice(startPosition.offset, this.offset());
3414
+ }
3415
+ else {
3416
+ break;
3417
+ }
3418
+ }
3419
+ // Duplicate selector clauses
3420
+ if (parsedSelectors.has(selector)) {
3421
+ return this.error(parentArgType === 'select'
3422
+ ? ErrorKind.DUPLICATE_SELECT_ARGUMENT_SELECTOR
3423
+ : ErrorKind.DUPLICATE_PLURAL_ARGUMENT_SELECTOR, selectorLocation);
3424
+ }
3425
+ if (selector === 'other') {
3426
+ hasOtherClause = true;
3427
+ }
3428
+ // Parse:
3429
+ // one {one apple}
3430
+ // ^----------^
3431
+ this.bumpSpace();
3432
+ var openingBracePosition = this.clonePosition();
3433
+ if (!this.bumpIf('{')) {
3434
+ return this.error(parentArgType === 'select'
3435
+ ? ErrorKind.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT
3436
+ : ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT, createLocation(this.clonePosition(), this.clonePosition()));
3437
+ }
3438
+ var fragmentResult = this.parseMessage(nestingLevel + 1, parentArgType, expectCloseTag);
3439
+ if (fragmentResult.err) {
3440
+ return fragmentResult;
3441
+ }
3442
+ var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
3443
+ if (argCloseResult.err) {
3444
+ return argCloseResult;
3445
+ }
3446
+ options.push([
3447
+ selector,
3448
+ {
3449
+ value: fragmentResult.val,
3450
+ location: createLocation(openingBracePosition, this.clonePosition()),
3451
+ },
3452
+ ]);
3453
+ // Keep track of the existing selectors
3454
+ parsedSelectors.add(selector);
3455
+ // Prep next selector clause.
3456
+ this.bumpSpace();
3457
+ (_a = this.parseIdentifierIfPossible(), selector = _a.value, selectorLocation = _a.location);
3458
+ }
3459
+ if (options.length === 0) {
3460
+ return this.error(parentArgType === 'select'
3461
+ ? ErrorKind.EXPECT_SELECT_ARGUMENT_SELECTOR
3462
+ : ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR, createLocation(this.clonePosition(), this.clonePosition()));
3463
+ }
3464
+ if (this.requiresOtherClause && !hasOtherClause) {
3465
+ return this.error(ErrorKind.MISSING_OTHER_CLAUSE, createLocation(this.clonePosition(), this.clonePosition()));
3466
+ }
3467
+ return { val: options, err: null };
3468
+ };
3469
+ Parser.prototype.tryParseDecimalInteger = function (expectNumberError, invalidNumberError) {
3470
+ var sign = 1;
3471
+ var startingPosition = this.clonePosition();
3472
+ if (this.bumpIf('+')) ;
3473
+ else if (this.bumpIf('-')) {
3474
+ sign = -1;
3475
+ }
3476
+ var hasDigits = false;
3477
+ var decimal = 0;
3478
+ while (!this.isEOF()) {
3479
+ var ch = this.char();
3480
+ if (ch >= 48 /* `0` */ && ch <= 57 /* `9` */) {
3481
+ hasDigits = true;
3482
+ decimal = decimal * 10 + (ch - 48);
3483
+ this.bump();
3484
+ }
3485
+ else {
3486
+ break;
3487
+ }
3488
+ }
3489
+ var location = createLocation(startingPosition, this.clonePosition());
3490
+ if (!hasDigits) {
3491
+ return this.error(expectNumberError, location);
3492
+ }
3493
+ decimal *= sign;
3494
+ if (!isSafeInteger(decimal)) {
3495
+ return this.error(invalidNumberError, location);
3496
+ }
3497
+ return { val: decimal, err: null };
3498
+ };
3499
+ Parser.prototype.offset = function () {
3500
+ return this.position.offset;
3501
+ };
3502
+ Parser.prototype.isEOF = function () {
3503
+ return this.offset() === this.message.length;
3504
+ };
3505
+ Parser.prototype.clonePosition = function () {
3506
+ // This is much faster than `Object.assign` or spread.
3507
+ return {
3508
+ offset: this.position.offset,
3509
+ line: this.position.line,
3510
+ column: this.position.column,
3511
+ };
3512
+ };
3513
+ /**
3514
+ * Return the code point at the current position of the parser.
3515
+ * Throws if the index is out of bound.
3516
+ */
3517
+ Parser.prototype.char = function () {
3518
+ var offset = this.position.offset;
3519
+ if (offset >= this.message.length) {
3520
+ throw Error('out of bound');
3521
+ }
3522
+ var code = codePointAt(this.message, offset);
3523
+ if (code === undefined) {
3524
+ throw Error("Offset ".concat(offset, " is at invalid UTF-16 code unit boundary"));
3525
+ }
3526
+ return code;
3527
+ };
3528
+ Parser.prototype.error = function (kind, location) {
3529
+ return {
3530
+ val: null,
3531
+ err: {
3532
+ kind: kind,
3533
+ message: this.message,
3534
+ location: location,
3535
+ },
3536
+ };
3537
+ };
3538
+ /** Bump the parser to the next UTF-16 code unit. */
3539
+ Parser.prototype.bump = function () {
3540
+ if (this.isEOF()) {
3541
+ return;
3542
+ }
3543
+ var code = this.char();
3544
+ if (code === 10 /* '\n' */) {
3545
+ this.position.line += 1;
3546
+ this.position.column = 1;
3547
+ this.position.offset += 1;
3548
+ }
3549
+ else {
3550
+ this.position.column += 1;
3551
+ // 0 ~ 0x10000 -> unicode BMP, otherwise skip the surrogate pair.
3552
+ this.position.offset += code < 0x10000 ? 1 : 2;
3553
+ }
3554
+ };
3555
+ /**
3556
+ * If the substring starting at the current position of the parser has
3557
+ * the given prefix, then bump the parser to the character immediately
3558
+ * following the prefix and return true. Otherwise, don't bump the parser
3559
+ * and return false.
3560
+ */
3561
+ Parser.prototype.bumpIf = function (prefix) {
3562
+ if (startsWith(this.message, prefix, this.offset())) {
3563
+ for (var i = 0; i < prefix.length; i++) {
3564
+ this.bump();
3565
+ }
3566
+ return true;
3567
+ }
3568
+ return false;
3569
+ };
3570
+ /**
3571
+ * Bump the parser until the pattern character is found and return `true`.
3572
+ * Otherwise bump to the end of the file and return `false`.
3573
+ */
3574
+ Parser.prototype.bumpUntil = function (pattern) {
3575
+ var currentOffset = this.offset();
3576
+ var index = this.message.indexOf(pattern, currentOffset);
3577
+ if (index >= 0) {
3578
+ this.bumpTo(index);
3579
+ return true;
3580
+ }
3581
+ else {
3582
+ this.bumpTo(this.message.length);
3583
+ return false;
3584
+ }
3585
+ };
3586
+ /**
3587
+ * Bump the parser to the target offset.
3588
+ * If target offset is beyond the end of the input, bump the parser to the end of the input.
3589
+ */
3590
+ Parser.prototype.bumpTo = function (targetOffset) {
3591
+ if (this.offset() > targetOffset) {
3592
+ throw Error("targetOffset ".concat(targetOffset, " must be greater than or equal to the current offset ").concat(this.offset()));
3593
+ }
3594
+ targetOffset = Math.min(targetOffset, this.message.length);
3595
+ while (true) {
3596
+ var offset = this.offset();
3597
+ if (offset === targetOffset) {
3598
+ break;
3599
+ }
3600
+ if (offset > targetOffset) {
3601
+ throw Error("targetOffset ".concat(targetOffset, " is at invalid UTF-16 code unit boundary"));
3602
+ }
3603
+ this.bump();
3604
+ if (this.isEOF()) {
3605
+ break;
3606
+ }
3607
+ }
3608
+ };
3609
+ /** advance the parser through all whitespace to the next non-whitespace code unit. */
3610
+ Parser.prototype.bumpSpace = function () {
3611
+ while (!this.isEOF() && _isWhiteSpace(this.char())) {
3612
+ this.bump();
3613
+ }
3614
+ };
3615
+ /**
3616
+ * Peek at the *next* Unicode codepoint in the input without advancing the parser.
3617
+ * If the input has been exhausted, then this returns null.
3618
+ */
3619
+ Parser.prototype.peek = function () {
3620
+ if (this.isEOF()) {
3621
+ return null;
3622
+ }
3623
+ var code = this.char();
3624
+ var offset = this.offset();
3625
+ var nextCode = this.message.charCodeAt(offset + (code >= 0x10000 ? 2 : 1));
3626
+ return nextCode !== null && nextCode !== void 0 ? nextCode : null;
3627
+ };
3628
+ return Parser;
3629
+ }());
3630
+ /**
3631
+ * This check if codepoint is alphabet (lower & uppercase)
3632
+ * @param codepoint
3633
+ * @returns
3634
+ */
3635
+ function _isAlpha(codepoint) {
3636
+ return ((codepoint >= 97 && codepoint <= 122) ||
3637
+ (codepoint >= 65 && codepoint <= 90));
3638
+ }
3639
+ function _isAlphaOrSlash(codepoint) {
3640
+ return _isAlpha(codepoint) || codepoint === 47; /* '/' */
3641
+ }
3642
+ /** See `parseTag` function docs. */
3643
+ function _isPotentialElementNameChar(c) {
3644
+ return (c === 45 /* '-' */ ||
3645
+ c === 46 /* '.' */ ||
3646
+ (c >= 48 && c <= 57) /* 0..9 */ ||
3647
+ c === 95 /* '_' */ ||
3648
+ (c >= 97 && c <= 122) /** a..z */ ||
3649
+ (c >= 65 && c <= 90) /* A..Z */ ||
3650
+ c == 0xb7 ||
3651
+ (c >= 0xc0 && c <= 0xd6) ||
3652
+ (c >= 0xd8 && c <= 0xf6) ||
3653
+ (c >= 0xf8 && c <= 0x37d) ||
3654
+ (c >= 0x37f && c <= 0x1fff) ||
3655
+ (c >= 0x200c && c <= 0x200d) ||
3656
+ (c >= 0x203f && c <= 0x2040) ||
3657
+ (c >= 0x2070 && c <= 0x218f) ||
3658
+ (c >= 0x2c00 && c <= 0x2fef) ||
3659
+ (c >= 0x3001 && c <= 0xd7ff) ||
3660
+ (c >= 0xf900 && c <= 0xfdcf) ||
3661
+ (c >= 0xfdf0 && c <= 0xfffd) ||
3662
+ (c >= 0x10000 && c <= 0xeffff));
3663
+ }
3664
+ /**
3665
+ * Code point equivalent of regex `\p{White_Space}`.
3666
+ * From: https://www.unicode.org/Public/UCD/latest/ucd/PropList.txt
3667
+ */
3668
+ function _isWhiteSpace(c) {
3669
+ return ((c >= 0x0009 && c <= 0x000d) ||
3670
+ c === 0x0020 ||
3671
+ c === 0x0085 ||
3672
+ (c >= 0x200e && c <= 0x200f) ||
3673
+ c === 0x2028 ||
3674
+ c === 0x2029);
3675
+ }
3676
+ /**
3677
+ * Code point equivalent of regex `\p{Pattern_Syntax}`.
3678
+ * See https://www.unicode.org/Public/UCD/latest/ucd/PropList.txt
3679
+ */
3680
+ function _isPatternSyntax(c) {
3681
+ return ((c >= 0x0021 && c <= 0x0023) ||
3682
+ c === 0x0024 ||
3683
+ (c >= 0x0025 && c <= 0x0027) ||
3684
+ c === 0x0028 ||
3685
+ c === 0x0029 ||
3686
+ c === 0x002a ||
3687
+ c === 0x002b ||
3688
+ c === 0x002c ||
3689
+ c === 0x002d ||
3690
+ (c >= 0x002e && c <= 0x002f) ||
3691
+ (c >= 0x003a && c <= 0x003b) ||
3692
+ (c >= 0x003c && c <= 0x003e) ||
3693
+ (c >= 0x003f && c <= 0x0040) ||
3694
+ c === 0x005b ||
3695
+ c === 0x005c ||
3696
+ c === 0x005d ||
3697
+ c === 0x005e ||
3698
+ c === 0x0060 ||
3699
+ c === 0x007b ||
3700
+ c === 0x007c ||
3701
+ c === 0x007d ||
3702
+ c === 0x007e ||
3703
+ c === 0x00a1 ||
3704
+ (c >= 0x00a2 && c <= 0x00a5) ||
3705
+ c === 0x00a6 ||
3706
+ c === 0x00a7 ||
3707
+ c === 0x00a9 ||
3708
+ c === 0x00ab ||
3709
+ c === 0x00ac ||
3710
+ c === 0x00ae ||
3711
+ c === 0x00b0 ||
3712
+ c === 0x00b1 ||
3713
+ c === 0x00b6 ||
3714
+ c === 0x00bb ||
3715
+ c === 0x00bf ||
3716
+ c === 0x00d7 ||
3717
+ c === 0x00f7 ||
3718
+ (c >= 0x2010 && c <= 0x2015) ||
3719
+ (c >= 0x2016 && c <= 0x2017) ||
3720
+ c === 0x2018 ||
3721
+ c === 0x2019 ||
3722
+ c === 0x201a ||
3723
+ (c >= 0x201b && c <= 0x201c) ||
3724
+ c === 0x201d ||
3725
+ c === 0x201e ||
3726
+ c === 0x201f ||
3727
+ (c >= 0x2020 && c <= 0x2027) ||
3728
+ (c >= 0x2030 && c <= 0x2038) ||
3729
+ c === 0x2039 ||
3730
+ c === 0x203a ||
3731
+ (c >= 0x203b && c <= 0x203e) ||
3732
+ (c >= 0x2041 && c <= 0x2043) ||
3733
+ c === 0x2044 ||
3734
+ c === 0x2045 ||
3735
+ c === 0x2046 ||
3736
+ (c >= 0x2047 && c <= 0x2051) ||
3737
+ c === 0x2052 ||
3738
+ c === 0x2053 ||
3739
+ (c >= 0x2055 && c <= 0x205e) ||
3740
+ (c >= 0x2190 && c <= 0x2194) ||
3741
+ (c >= 0x2195 && c <= 0x2199) ||
3742
+ (c >= 0x219a && c <= 0x219b) ||
3743
+ (c >= 0x219c && c <= 0x219f) ||
3744
+ c === 0x21a0 ||
3745
+ (c >= 0x21a1 && c <= 0x21a2) ||
3746
+ c === 0x21a3 ||
3747
+ (c >= 0x21a4 && c <= 0x21a5) ||
3748
+ c === 0x21a6 ||
3749
+ (c >= 0x21a7 && c <= 0x21ad) ||
3750
+ c === 0x21ae ||
3751
+ (c >= 0x21af && c <= 0x21cd) ||
3752
+ (c >= 0x21ce && c <= 0x21cf) ||
3753
+ (c >= 0x21d0 && c <= 0x21d1) ||
3754
+ c === 0x21d2 ||
3755
+ c === 0x21d3 ||
3756
+ c === 0x21d4 ||
3757
+ (c >= 0x21d5 && c <= 0x21f3) ||
3758
+ (c >= 0x21f4 && c <= 0x22ff) ||
3759
+ (c >= 0x2300 && c <= 0x2307) ||
3760
+ c === 0x2308 ||
3761
+ c === 0x2309 ||
3762
+ c === 0x230a ||
3763
+ c === 0x230b ||
3764
+ (c >= 0x230c && c <= 0x231f) ||
3765
+ (c >= 0x2320 && c <= 0x2321) ||
3766
+ (c >= 0x2322 && c <= 0x2328) ||
3767
+ c === 0x2329 ||
3768
+ c === 0x232a ||
3769
+ (c >= 0x232b && c <= 0x237b) ||
3770
+ c === 0x237c ||
3771
+ (c >= 0x237d && c <= 0x239a) ||
3772
+ (c >= 0x239b && c <= 0x23b3) ||
3773
+ (c >= 0x23b4 && c <= 0x23db) ||
3774
+ (c >= 0x23dc && c <= 0x23e1) ||
3775
+ (c >= 0x23e2 && c <= 0x2426) ||
3776
+ (c >= 0x2427 && c <= 0x243f) ||
3777
+ (c >= 0x2440 && c <= 0x244a) ||
3778
+ (c >= 0x244b && c <= 0x245f) ||
3779
+ (c >= 0x2500 && c <= 0x25b6) ||
3780
+ c === 0x25b7 ||
3781
+ (c >= 0x25b8 && c <= 0x25c0) ||
3782
+ c === 0x25c1 ||
3783
+ (c >= 0x25c2 && c <= 0x25f7) ||
3784
+ (c >= 0x25f8 && c <= 0x25ff) ||
3785
+ (c >= 0x2600 && c <= 0x266e) ||
3786
+ c === 0x266f ||
3787
+ (c >= 0x2670 && c <= 0x2767) ||
3788
+ c === 0x2768 ||
3789
+ c === 0x2769 ||
3790
+ c === 0x276a ||
3791
+ c === 0x276b ||
3792
+ c === 0x276c ||
3793
+ c === 0x276d ||
3794
+ c === 0x276e ||
3795
+ c === 0x276f ||
3796
+ c === 0x2770 ||
3797
+ c === 0x2771 ||
3798
+ c === 0x2772 ||
3799
+ c === 0x2773 ||
3800
+ c === 0x2774 ||
3801
+ c === 0x2775 ||
3802
+ (c >= 0x2794 && c <= 0x27bf) ||
3803
+ (c >= 0x27c0 && c <= 0x27c4) ||
3804
+ c === 0x27c5 ||
3805
+ c === 0x27c6 ||
3806
+ (c >= 0x27c7 && c <= 0x27e5) ||
3807
+ c === 0x27e6 ||
3808
+ c === 0x27e7 ||
3809
+ c === 0x27e8 ||
3810
+ c === 0x27e9 ||
3811
+ c === 0x27ea ||
3812
+ c === 0x27eb ||
3813
+ c === 0x27ec ||
3814
+ c === 0x27ed ||
3815
+ c === 0x27ee ||
3816
+ c === 0x27ef ||
3817
+ (c >= 0x27f0 && c <= 0x27ff) ||
3818
+ (c >= 0x2800 && c <= 0x28ff) ||
3819
+ (c >= 0x2900 && c <= 0x2982) ||
3820
+ c === 0x2983 ||
3821
+ c === 0x2984 ||
3822
+ c === 0x2985 ||
3823
+ c === 0x2986 ||
3824
+ c === 0x2987 ||
3825
+ c === 0x2988 ||
3826
+ c === 0x2989 ||
3827
+ c === 0x298a ||
3828
+ c === 0x298b ||
3829
+ c === 0x298c ||
3830
+ c === 0x298d ||
3831
+ c === 0x298e ||
3832
+ c === 0x298f ||
3833
+ c === 0x2990 ||
3834
+ c === 0x2991 ||
3835
+ c === 0x2992 ||
3836
+ c === 0x2993 ||
3837
+ c === 0x2994 ||
3838
+ c === 0x2995 ||
3839
+ c === 0x2996 ||
3840
+ c === 0x2997 ||
3841
+ c === 0x2998 ||
3842
+ (c >= 0x2999 && c <= 0x29d7) ||
3843
+ c === 0x29d8 ||
3844
+ c === 0x29d9 ||
3845
+ c === 0x29da ||
3846
+ c === 0x29db ||
3847
+ (c >= 0x29dc && c <= 0x29fb) ||
3848
+ c === 0x29fc ||
3849
+ c === 0x29fd ||
3850
+ (c >= 0x29fe && c <= 0x2aff) ||
3851
+ (c >= 0x2b00 && c <= 0x2b2f) ||
3852
+ (c >= 0x2b30 && c <= 0x2b44) ||
3853
+ (c >= 0x2b45 && c <= 0x2b46) ||
3854
+ (c >= 0x2b47 && c <= 0x2b4c) ||
3855
+ (c >= 0x2b4d && c <= 0x2b73) ||
3856
+ (c >= 0x2b74 && c <= 0x2b75) ||
3857
+ (c >= 0x2b76 && c <= 0x2b95) ||
3858
+ c === 0x2b96 ||
3859
+ (c >= 0x2b97 && c <= 0x2bff) ||
3860
+ (c >= 0x2e00 && c <= 0x2e01) ||
3861
+ c === 0x2e02 ||
3862
+ c === 0x2e03 ||
3863
+ c === 0x2e04 ||
3864
+ c === 0x2e05 ||
3865
+ (c >= 0x2e06 && c <= 0x2e08) ||
3866
+ c === 0x2e09 ||
3867
+ c === 0x2e0a ||
3868
+ c === 0x2e0b ||
3869
+ c === 0x2e0c ||
3870
+ c === 0x2e0d ||
3871
+ (c >= 0x2e0e && c <= 0x2e16) ||
3872
+ c === 0x2e17 ||
3873
+ (c >= 0x2e18 && c <= 0x2e19) ||
3874
+ c === 0x2e1a ||
3875
+ c === 0x2e1b ||
3876
+ c === 0x2e1c ||
3877
+ c === 0x2e1d ||
3878
+ (c >= 0x2e1e && c <= 0x2e1f) ||
3879
+ c === 0x2e20 ||
3880
+ c === 0x2e21 ||
3881
+ c === 0x2e22 ||
3882
+ c === 0x2e23 ||
3883
+ c === 0x2e24 ||
3884
+ c === 0x2e25 ||
3885
+ c === 0x2e26 ||
3886
+ c === 0x2e27 ||
3887
+ c === 0x2e28 ||
3888
+ c === 0x2e29 ||
3889
+ (c >= 0x2e2a && c <= 0x2e2e) ||
3890
+ c === 0x2e2f ||
3891
+ (c >= 0x2e30 && c <= 0x2e39) ||
3892
+ (c >= 0x2e3a && c <= 0x2e3b) ||
3893
+ (c >= 0x2e3c && c <= 0x2e3f) ||
3894
+ c === 0x2e40 ||
3895
+ c === 0x2e41 ||
3896
+ c === 0x2e42 ||
3897
+ (c >= 0x2e43 && c <= 0x2e4f) ||
3898
+ (c >= 0x2e50 && c <= 0x2e51) ||
3899
+ c === 0x2e52 ||
3900
+ (c >= 0x2e53 && c <= 0x2e7f) ||
3901
+ (c >= 0x3001 && c <= 0x3003) ||
3902
+ c === 0x3008 ||
3903
+ c === 0x3009 ||
3904
+ c === 0x300a ||
3905
+ c === 0x300b ||
3906
+ c === 0x300c ||
3907
+ c === 0x300d ||
3908
+ c === 0x300e ||
3909
+ c === 0x300f ||
3910
+ c === 0x3010 ||
3911
+ c === 0x3011 ||
3912
+ (c >= 0x3012 && c <= 0x3013) ||
3913
+ c === 0x3014 ||
3914
+ c === 0x3015 ||
3915
+ c === 0x3016 ||
3916
+ c === 0x3017 ||
3917
+ c === 0x3018 ||
3918
+ c === 0x3019 ||
3919
+ c === 0x301a ||
3920
+ c === 0x301b ||
3921
+ c === 0x301c ||
3922
+ c === 0x301d ||
3923
+ (c >= 0x301e && c <= 0x301f) ||
3924
+ c === 0x3020 ||
3925
+ c === 0x3030 ||
3926
+ c === 0xfd3e ||
3927
+ c === 0xfd3f ||
3928
+ (c >= 0xfe45 && c <= 0xfe46));
3929
+ }
3930
+
3931
+ function pruneLocation(els) {
3932
+ els.forEach(function (el) {
3933
+ delete el.location;
3934
+ if (isSelectElement(el) || isPluralElement(el)) {
3935
+ for (var k in el.options) {
3936
+ delete el.options[k].location;
3937
+ pruneLocation(el.options[k].value);
3938
+ }
3939
+ }
3940
+ else if (isNumberElement(el) && isNumberSkeleton(el.style)) {
3941
+ delete el.style.location;
3942
+ }
3943
+ else if ((isDateElement(el) || isTimeElement(el)) &&
3944
+ isDateTimeSkeleton(el.style)) {
3945
+ delete el.style.location;
3946
+ }
3947
+ else if (isTagElement(el)) {
3948
+ pruneLocation(el.children);
3949
+ }
3950
+ });
3951
+ }
3952
+ function parse(message, opts) {
3953
+ if (opts === void 0) { opts = {}; }
3954
+ opts = __assign({ shouldParseSkeletons: true, requiresOtherClause: true }, opts);
3955
+ var result = new Parser(message, opts).parse();
3956
+ if (result.err) {
3957
+ var error = SyntaxError(ErrorKind[result.err.kind]);
3958
+ // @ts-expect-error Assign to error object
3959
+ error.location = result.err.location;
3960
+ // @ts-expect-error Assign to error object
3961
+ error.originalMessage = result.err.message;
3962
+ throw error;
3963
+ }
3964
+ if (!(opts === null || opts === void 0 ? void 0 : opts.captureLocation)) {
3965
+ pruneLocation(result.val);
3966
+ }
3967
+ return result.val;
3968
+ }
3969
+
3970
+ //
3971
+ // Main
3972
+ //
3973
+ function memoize(fn, options) {
3974
+ var cache = options && options.cache ? options.cache : cacheDefault;
3975
+ var serializer = options && options.serializer ? options.serializer : serializerDefault;
3976
+ var strategy = options && options.strategy ? options.strategy : strategyDefault;
3977
+ return strategy(fn, {
3978
+ cache: cache,
3979
+ serializer: serializer,
3980
+ });
3981
+ }
3982
+ //
3983
+ // Strategy
3984
+ //
3985
+ function isPrimitive(value) {
3986
+ return (value == null || typeof value === 'number' || typeof value === 'boolean'); // || typeof value === "string" 'unsafe' primitive for our needs
3987
+ }
3988
+ function monadic(fn, cache, serializer, arg) {
3989
+ var cacheKey = isPrimitive(arg) ? arg : serializer(arg);
3990
+ var computedValue = cache.get(cacheKey);
3991
+ if (typeof computedValue === 'undefined') {
3992
+ computedValue = fn.call(this, arg);
3993
+ cache.set(cacheKey, computedValue);
3994
+ }
3995
+ return computedValue;
3996
+ }
3997
+ function variadic(fn, cache, serializer) {
3998
+ var args = Array.prototype.slice.call(arguments, 3);
3999
+ var cacheKey = serializer(args);
4000
+ var computedValue = cache.get(cacheKey);
4001
+ if (typeof computedValue === 'undefined') {
4002
+ computedValue = fn.apply(this, args);
4003
+ cache.set(cacheKey, computedValue);
4004
+ }
4005
+ return computedValue;
4006
+ }
4007
+ function assemble(fn, context, strategy, cache, serialize) {
4008
+ return strategy.bind(context, fn, cache, serialize);
4009
+ }
4010
+ function strategyDefault(fn, options) {
4011
+ var strategy = fn.length === 1 ? monadic : variadic;
4012
+ return assemble(fn, this, strategy, options.cache.create(), options.serializer);
4013
+ }
4014
+ function strategyVariadic(fn, options) {
4015
+ return assemble(fn, this, variadic, options.cache.create(), options.serializer);
4016
+ }
4017
+ function strategyMonadic(fn, options) {
4018
+ return assemble(fn, this, monadic, options.cache.create(), options.serializer);
4019
+ }
4020
+ //
4021
+ // Serializer
4022
+ //
4023
+ var serializerDefault = function () {
4024
+ return JSON.stringify(arguments);
4025
+ };
4026
+ //
4027
+ // Cache
4028
+ //
4029
+ function ObjectWithoutPrototypeCache() {
4030
+ this.cache = Object.create(null);
4031
+ }
4032
+ ObjectWithoutPrototypeCache.prototype.get = function (key) {
4033
+ return this.cache[key];
4034
+ };
4035
+ ObjectWithoutPrototypeCache.prototype.set = function (key, value) {
4036
+ this.cache[key] = value;
4037
+ };
4038
+ var cacheDefault = {
4039
+ create: function create() {
4040
+ // @ts-ignore
4041
+ return new ObjectWithoutPrototypeCache();
4042
+ },
4043
+ };
4044
+ var strategies = {
4045
+ variadic: strategyVariadic,
4046
+ monadic: strategyMonadic,
4047
+ };
4048
+
4049
+ var ErrorCode;
4050
+ (function (ErrorCode) {
4051
+ // When we have a placeholder but no value to format
4052
+ ErrorCode["MISSING_VALUE"] = "MISSING_VALUE";
4053
+ // When value supplied is invalid
4054
+ ErrorCode["INVALID_VALUE"] = "INVALID_VALUE";
4055
+ // When we need specific Intl API but it's not available
4056
+ ErrorCode["MISSING_INTL_API"] = "MISSING_INTL_API";
4057
+ })(ErrorCode || (ErrorCode = {}));
4058
+ var FormatError = /** @class */ (function (_super) {
4059
+ __extends(FormatError, _super);
4060
+ function FormatError(msg, code, originalMessage) {
4061
+ var _this = _super.call(this, msg) || this;
4062
+ _this.code = code;
4063
+ _this.originalMessage = originalMessage;
4064
+ return _this;
4065
+ }
4066
+ FormatError.prototype.toString = function () {
4067
+ return "[formatjs Error: ".concat(this.code, "] ").concat(this.message);
4068
+ };
4069
+ return FormatError;
4070
+ }(Error));
4071
+ var InvalidValueError = /** @class */ (function (_super) {
4072
+ __extends(InvalidValueError, _super);
4073
+ function InvalidValueError(variableId, value, options, originalMessage) {
4074
+ return _super.call(this, "Invalid values for \"".concat(variableId, "\": \"").concat(value, "\". Options are \"").concat(Object.keys(options).join('", "'), "\""), ErrorCode.INVALID_VALUE, originalMessage) || this;
4075
+ }
4076
+ return InvalidValueError;
4077
+ }(FormatError));
4078
+ var InvalidValueTypeError = /** @class */ (function (_super) {
4079
+ __extends(InvalidValueTypeError, _super);
4080
+ function InvalidValueTypeError(value, type, originalMessage) {
4081
+ return _super.call(this, "Value for \"".concat(value, "\" must be of type ").concat(type), ErrorCode.INVALID_VALUE, originalMessage) || this;
4082
+ }
4083
+ return InvalidValueTypeError;
4084
+ }(FormatError));
4085
+ var MissingValueError = /** @class */ (function (_super) {
4086
+ __extends(MissingValueError, _super);
4087
+ function MissingValueError(variableId, originalMessage) {
4088
+ return _super.call(this, "The intl string context variable \"".concat(variableId, "\" was not provided to the string \"").concat(originalMessage, "\""), ErrorCode.MISSING_VALUE, originalMessage) || this;
4089
+ }
4090
+ return MissingValueError;
4091
+ }(FormatError));
4092
+
4093
+ var PART_TYPE;
4094
+ (function (PART_TYPE) {
4095
+ PART_TYPE[PART_TYPE["literal"] = 0] = "literal";
4096
+ PART_TYPE[PART_TYPE["object"] = 1] = "object";
4097
+ })(PART_TYPE || (PART_TYPE = {}));
4098
+ function mergeLiteral(parts) {
4099
+ if (parts.length < 2) {
4100
+ return parts;
4101
+ }
4102
+ return parts.reduce(function (all, part) {
4103
+ var lastPart = all[all.length - 1];
4104
+ if (!lastPart ||
4105
+ lastPart.type !== PART_TYPE.literal ||
4106
+ part.type !== PART_TYPE.literal) {
4107
+ all.push(part);
4108
+ }
4109
+ else {
4110
+ lastPart.value += part.value;
4111
+ }
4112
+ return all;
4113
+ }, []);
4114
+ }
4115
+ function isFormatXMLElementFn(el) {
4116
+ return typeof el === 'function';
4117
+ }
4118
+ // TODO(skeleton): add skeleton support
4119
+ function formatToParts(els, locales, formatters, formats, values, currentPluralValue,
4120
+ // For debugging
4121
+ originalMessage) {
4122
+ // Hot path for straight simple msg translations
4123
+ if (els.length === 1 && isLiteralElement(els[0])) {
4124
+ return [
4125
+ {
4126
+ type: PART_TYPE.literal,
4127
+ value: els[0].value,
4128
+ },
4129
+ ];
4130
+ }
4131
+ var result = [];
4132
+ for (var _i = 0, els_1 = els; _i < els_1.length; _i++) {
4133
+ var el = els_1[_i];
4134
+ // Exit early for string parts.
4135
+ if (isLiteralElement(el)) {
4136
+ result.push({
4137
+ type: PART_TYPE.literal,
4138
+ value: el.value,
4139
+ });
4140
+ continue;
4141
+ }
4142
+ // TODO: should this part be literal type?
4143
+ // Replace `#` in plural rules with the actual numeric value.
4144
+ if (isPoundElement(el)) {
4145
+ if (typeof currentPluralValue === 'number') {
4146
+ result.push({
4147
+ type: PART_TYPE.literal,
4148
+ value: formatters.getNumberFormat(locales).format(currentPluralValue),
4149
+ });
4150
+ }
4151
+ continue;
4152
+ }
4153
+ var varName = el.value;
4154
+ // Enforce that all required values are provided by the caller.
4155
+ if (!(values && varName in values)) {
4156
+ throw new MissingValueError(varName, originalMessage);
4157
+ }
4158
+ var value = values[varName];
4159
+ if (isArgumentElement(el)) {
4160
+ if (!value || typeof value === 'string' || typeof value === 'number') {
4161
+ value =
4162
+ typeof value === 'string' || typeof value === 'number'
4163
+ ? String(value)
4164
+ : '';
4165
+ }
4166
+ result.push({
4167
+ type: typeof value === 'string' ? PART_TYPE.literal : PART_TYPE.object,
4168
+ value: value,
4169
+ });
4170
+ continue;
4171
+ }
4172
+ // Recursively format plural and select parts' option — which can be a
4173
+ // nested pattern structure. The choosing of the option to use is
4174
+ // abstracted-by and delegated-to the part helper object.
4175
+ if (isDateElement(el)) {
4176
+ var style = typeof el.style === 'string'
4177
+ ? formats.date[el.style]
4178
+ : isDateTimeSkeleton(el.style)
4179
+ ? el.style.parsedOptions
4180
+ : undefined;
4181
+ result.push({
4182
+ type: PART_TYPE.literal,
4183
+ value: formatters
4184
+ .getDateTimeFormat(locales, style)
4185
+ .format(value),
4186
+ });
4187
+ continue;
4188
+ }
4189
+ if (isTimeElement(el)) {
4190
+ var style = typeof el.style === 'string'
4191
+ ? formats.time[el.style]
4192
+ : isDateTimeSkeleton(el.style)
4193
+ ? el.style.parsedOptions
4194
+ : formats.time.medium;
4195
+ result.push({
4196
+ type: PART_TYPE.literal,
4197
+ value: formatters
4198
+ .getDateTimeFormat(locales, style)
4199
+ .format(value),
4200
+ });
4201
+ continue;
4202
+ }
4203
+ if (isNumberElement(el)) {
4204
+ var style = typeof el.style === 'string'
4205
+ ? formats.number[el.style]
4206
+ : isNumberSkeleton(el.style)
4207
+ ? el.style.parsedOptions
4208
+ : undefined;
4209
+ if (style && style.scale) {
4210
+ value =
4211
+ value *
4212
+ (style.scale || 1);
4213
+ }
4214
+ result.push({
4215
+ type: PART_TYPE.literal,
4216
+ value: formatters
4217
+ .getNumberFormat(locales, style)
4218
+ .format(value),
4219
+ });
4220
+ continue;
4221
+ }
4222
+ if (isTagElement(el)) {
4223
+ var children = el.children, value_1 = el.value;
4224
+ var formatFn = values[value_1];
4225
+ if (!isFormatXMLElementFn(formatFn)) {
4226
+ throw new InvalidValueTypeError(value_1, 'function', originalMessage);
4227
+ }
4228
+ var parts = formatToParts(children, locales, formatters, formats, values, currentPluralValue);
4229
+ var chunks = formatFn(parts.map(function (p) { return p.value; }));
4230
+ if (!Array.isArray(chunks)) {
4231
+ chunks = [chunks];
4232
+ }
4233
+ result.push.apply(result, chunks.map(function (c) {
4234
+ return {
4235
+ type: typeof c === 'string' ? PART_TYPE.literal : PART_TYPE.object,
4236
+ value: c,
4237
+ };
4238
+ }));
4239
+ }
4240
+ if (isSelectElement(el)) {
4241
+ var opt = el.options[value] || el.options.other;
4242
+ if (!opt) {
4243
+ throw new InvalidValueError(el.value, value, Object.keys(el.options), originalMessage);
4244
+ }
4245
+ result.push.apply(result, formatToParts(opt.value, locales, formatters, formats, values));
4246
+ continue;
4247
+ }
4248
+ if (isPluralElement(el)) {
4249
+ var opt = el.options["=".concat(value)];
4250
+ if (!opt) {
4251
+ if (!Intl.PluralRules) {
4252
+ throw new FormatError("Intl.PluralRules is not available in this environment.\nTry polyfilling it using \"@formatjs/intl-pluralrules\"\n", ErrorCode.MISSING_INTL_API, originalMessage);
4253
+ }
4254
+ var rule = formatters
4255
+ .getPluralRules(locales, { type: el.pluralType })
4256
+ .select(value - (el.offset || 0));
4257
+ opt = el.options[rule] || el.options.other;
4258
+ }
4259
+ if (!opt) {
4260
+ throw new InvalidValueError(el.value, value, Object.keys(el.options), originalMessage);
4261
+ }
4262
+ result.push.apply(result, formatToParts(opt.value, locales, formatters, formats, values, value - (el.offset || 0)));
4263
+ continue;
4264
+ }
4265
+ }
4266
+ return mergeLiteral(result);
4267
+ }
4268
+
4269
+ /*
4270
+ Copyright (c) 2014, Yahoo! Inc. All rights reserved.
4271
+ Copyrights licensed under the New BSD License.
4272
+ See the accompanying LICENSE file for terms.
4273
+ */
4274
+ // -- MessageFormat --------------------------------------------------------
4275
+ function mergeConfig(c1, c2) {
4276
+ if (!c2) {
4277
+ return c1;
4278
+ }
4279
+ return __assign(__assign(__assign({}, (c1 || {})), (c2 || {})), Object.keys(c1).reduce(function (all, k) {
4280
+ all[k] = __assign(__assign({}, c1[k]), (c2[k] || {}));
4281
+ return all;
4282
+ }, {}));
4283
+ }
4284
+ function mergeConfigs(defaultConfig, configs) {
4285
+ if (!configs) {
4286
+ return defaultConfig;
4287
+ }
4288
+ return Object.keys(defaultConfig).reduce(function (all, k) {
4289
+ all[k] = mergeConfig(defaultConfig[k], configs[k]);
4290
+ return all;
4291
+ }, __assign({}, defaultConfig));
4292
+ }
4293
+ function createFastMemoizeCache(store) {
4294
+ return {
4295
+ create: function () {
4296
+ return {
4297
+ get: function (key) {
4298
+ return store[key];
4299
+ },
4300
+ set: function (key, value) {
4301
+ store[key] = value;
4302
+ },
4303
+ };
4304
+ },
4305
+ };
4306
+ }
4307
+ function createDefaultFormatters(cache) {
4308
+ if (cache === void 0) { cache = {
4309
+ number: {},
4310
+ dateTime: {},
4311
+ pluralRules: {},
4312
+ }; }
4313
+ return {
4314
+ getNumberFormat: memoize(function () {
4315
+ var _a;
4316
+ var args = [];
4317
+ for (var _i = 0; _i < arguments.length; _i++) {
4318
+ args[_i] = arguments[_i];
4319
+ }
4320
+ return new ((_a = Intl.NumberFormat).bind.apply(_a, __spreadArray([void 0], args, false)))();
4321
+ }, {
4322
+ cache: createFastMemoizeCache(cache.number),
4323
+ strategy: strategies.variadic,
4324
+ }),
4325
+ getDateTimeFormat: memoize(function () {
4326
+ var _a;
4327
+ var args = [];
4328
+ for (var _i = 0; _i < arguments.length; _i++) {
4329
+ args[_i] = arguments[_i];
4330
+ }
4331
+ return new ((_a = Intl.DateTimeFormat).bind.apply(_a, __spreadArray([void 0], args, false)))();
4332
+ }, {
4333
+ cache: createFastMemoizeCache(cache.dateTime),
4334
+ strategy: strategies.variadic,
4335
+ }),
4336
+ getPluralRules: memoize(function () {
4337
+ var _a;
4338
+ var args = [];
4339
+ for (var _i = 0; _i < arguments.length; _i++) {
4340
+ args[_i] = arguments[_i];
4341
+ }
4342
+ return new ((_a = Intl.PluralRules).bind.apply(_a, __spreadArray([void 0], args, false)))();
4343
+ }, {
4344
+ cache: createFastMemoizeCache(cache.pluralRules),
4345
+ strategy: strategies.variadic,
4346
+ }),
4347
+ };
4348
+ }
4349
+ var IntlMessageFormat = /** @class */ (function () {
4350
+ function IntlMessageFormat(message, locales, overrideFormats, opts) {
4351
+ var _this = this;
4352
+ if (locales === void 0) { locales = IntlMessageFormat.defaultLocale; }
4353
+ this.formatterCache = {
4354
+ number: {},
4355
+ dateTime: {},
4356
+ pluralRules: {},
4357
+ };
4358
+ this.format = function (values) {
4359
+ var parts = _this.formatToParts(values);
4360
+ // Hot path for straight simple msg translations
4361
+ if (parts.length === 1) {
4362
+ return parts[0].value;
4363
+ }
4364
+ var result = parts.reduce(function (all, part) {
4365
+ if (!all.length ||
4366
+ part.type !== PART_TYPE.literal ||
4367
+ typeof all[all.length - 1] !== 'string') {
4368
+ all.push(part.value);
4369
+ }
4370
+ else {
4371
+ all[all.length - 1] += part.value;
4372
+ }
4373
+ return all;
4374
+ }, []);
4375
+ if (result.length <= 1) {
4376
+ return result[0] || '';
4377
+ }
4378
+ return result;
4379
+ };
4380
+ this.formatToParts = function (values) {
4381
+ return formatToParts(_this.ast, _this.locales, _this.formatters, _this.formats, values, undefined, _this.message);
4382
+ };
4383
+ this.resolvedOptions = function () { return ({
4384
+ locale: _this.resolvedLocale.toString(),
4385
+ }); };
4386
+ this.getAst = function () { return _this.ast; };
4387
+ // Defined first because it's used to build the format pattern.
4388
+ this.locales = locales;
4389
+ this.resolvedLocale = IntlMessageFormat.resolveLocale(locales);
4390
+ if (typeof message === 'string') {
4391
+ this.message = message;
4392
+ if (!IntlMessageFormat.__parse) {
4393
+ throw new TypeError('IntlMessageFormat.__parse must be set to process `message` of type `string`');
4394
+ }
4395
+ // Parse string messages into an AST.
4396
+ this.ast = IntlMessageFormat.__parse(message, {
4397
+ ignoreTag: opts === null || opts === void 0 ? void 0 : opts.ignoreTag,
4398
+ locale: this.resolvedLocale,
4399
+ });
4400
+ }
4401
+ else {
4402
+ this.ast = message;
4403
+ }
4404
+ if (!Array.isArray(this.ast)) {
4405
+ throw new TypeError('A message must be provided as a String or AST.');
4406
+ }
4407
+ // Creates a new object with the specified `formats` merged with the default
4408
+ // formats.
4409
+ this.formats = mergeConfigs(IntlMessageFormat.formats, overrideFormats);
4410
+ this.formatters =
4411
+ (opts && opts.formatters) || createDefaultFormatters(this.formatterCache);
4412
+ }
4413
+ Object.defineProperty(IntlMessageFormat, "defaultLocale", {
4414
+ get: function () {
4415
+ if (!IntlMessageFormat.memoizedDefaultLocale) {
4416
+ IntlMessageFormat.memoizedDefaultLocale =
4417
+ new Intl.NumberFormat().resolvedOptions().locale;
4418
+ }
4419
+ return IntlMessageFormat.memoizedDefaultLocale;
4420
+ },
4421
+ enumerable: false,
4422
+ configurable: true
4423
+ });
4424
+ IntlMessageFormat.memoizedDefaultLocale = null;
4425
+ IntlMessageFormat.resolveLocale = function (locales) {
4426
+ var supportedLocales = Intl.NumberFormat.supportedLocalesOf(locales);
4427
+ if (supportedLocales.length > 0) {
4428
+ return new Intl.Locale(supportedLocales[0]);
4429
+ }
4430
+ return new Intl.Locale(typeof locales === 'string' ? locales : locales[0]);
4431
+ };
4432
+ IntlMessageFormat.__parse = parse;
4433
+ // Default format options used as the prototype of the `formats` provided to the
4434
+ // constructor. These are used when constructing the internal Intl.NumberFormat
4435
+ // and Intl.DateTimeFormat instances.
4436
+ IntlMessageFormat.formats = {
4437
+ number: {
4438
+ integer: {
4439
+ maximumFractionDigits: 0,
4440
+ },
4441
+ currency: {
4442
+ style: 'currency',
4443
+ },
4444
+ percent: {
4445
+ style: 'percent',
4446
+ },
4447
+ },
4448
+ date: {
4449
+ short: {
4450
+ month: 'numeric',
4451
+ day: 'numeric',
4452
+ year: '2-digit',
4453
+ },
4454
+ medium: {
4455
+ month: 'short',
4456
+ day: 'numeric',
4457
+ year: 'numeric',
4458
+ },
4459
+ long: {
4460
+ month: 'long',
4461
+ day: 'numeric',
4462
+ year: 'numeric',
4463
+ },
4464
+ full: {
4465
+ weekday: 'long',
4466
+ month: 'long',
4467
+ day: 'numeric',
4468
+ year: 'numeric',
4469
+ },
4470
+ },
4471
+ time: {
4472
+ short: {
4473
+ hour: 'numeric',
4474
+ minute: 'numeric',
4475
+ },
4476
+ medium: {
4477
+ hour: 'numeric',
4478
+ minute: 'numeric',
4479
+ second: 'numeric',
4480
+ },
4481
+ long: {
4482
+ hour: 'numeric',
4483
+ minute: 'numeric',
4484
+ second: 'numeric',
4485
+ timeZoneName: 'short',
4486
+ },
4487
+ full: {
4488
+ hour: 'numeric',
4489
+ minute: 'numeric',
4490
+ second: 'numeric',
4491
+ timeZoneName: 'short',
4492
+ },
4493
+ },
4494
+ };
4495
+ return IntlMessageFormat;
4496
+ }());
4497
+
4498
+ /*
4499
+ Copyright (c) 2014, Yahoo! Inc. All rights reserved.
4500
+ Copyrights licensed under the New BSD License.
4501
+ See the accompanying LICENSE file for terms.
4502
+ */
4503
+ var o = IntlMessageFormat;
4504
+
4505
+ const r={},i=(e,n,t)=>t?(n in r||(r[n]={}),e in r[n]||(r[n][e]=t),t):t,l=(e,n)=>{if(null==n)return;if(n in r&&e in r[n])return r[n][e];const t=E(n);for(let o=0;o<t.length;o++){const r=c(t[o],e);if(r)return i(e,n,r)}};let a;const s=writable({});function u(e){return e in a}function c(e,n){if(!u(e))return null;const t=function(e){return a[e]||null}(e);return function(e,n){if(null==n)return;if(n in e)return e[n];const t=n.split(".");let o=e;for(let e=0;e<t.length;e++)if("object"==typeof o){if(e>0){const n=t.slice(e,t.length).join(".");if(n in o){o=o[n];break}}o=o[t[e]];}else o=void 0;return o}(t,n)}function m(e,...n){delete r[e],s.update((o=>(o[e]=cjs.all([o[e]||{},...n]),o)));}derived([s],(([e])=>Object.keys(e)));s.subscribe((e=>a=e));const d={};function g(e){return d[e]}function h(e){return null!=e&&E(e).some((e=>{var n;return null===(n=g(e))||void 0===n?void 0:n.size}))}function w(e,n){const t=Promise.all(n.map((n=>(function(e,n){d[e].delete(n),0===d[e].size&&delete d[e];}(e,n),n().then((e=>e.default||e))))));return t.then((n=>m(e,...n)))}const p={};function b(e){if(!h(e))return e in p?p[e]:Promise.resolve();const n=function(e){return E(e).map((e=>{const n=g(e);return [e,n?[...n]:[]]})).filter((([,e])=>e.length>0))}(e);return p[e]=Promise.all(n.map((([e,n])=>w(e,n)))).then((()=>{if(h(e))return b(e);delete p[e];})),p[e]}/*! *****************************************************************************
4506
+ Copyright (c) Microsoft Corporation.
4507
+
4508
+ Permission to use, copy, modify, and/or distribute this software for any
4509
+ purpose with or without fee is hereby granted.
4510
+
4511
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
4512
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
4513
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
4514
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
4515
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
4516
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
4517
+ PERFORMANCE OF THIS SOFTWARE.
4518
+ ***************************************************************************** */function v(e,n){var t={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&n.indexOf(o)<0&&(t[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)n.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(t[o[r]]=e[o[r]]);}return t}const j={fallbackLocale:null,loadingDelay:200,formats:{number:{scientific:{notation:"scientific"},engineering:{notation:"engineering"},compactLong:{notation:"compact",compactDisplay:"long"},compactShort:{notation:"compact",compactDisplay:"short"}},date:{short:{month:"numeric",day:"numeric",year:"2-digit"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"},full:{weekday:"long",month:"long",day:"numeric",year:"numeric"}},time:{short:{hour:"numeric",minute:"numeric"},medium:{hour:"numeric",minute:"numeric",second:"numeric"},long:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"},full:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"}}},warnOnMissingMessages:!0,handleMissingMessage:void 0,ignoreTag:!0};function M(){return j}const k=writable(!1);let T;const L=writable(null);function x(e){return e.split("-").map(((e,n,t)=>t.slice(0,n+1).join("-"))).reverse()}function E(e,n=M().fallbackLocale){const t=x(e);return n?[...new Set([...t,...x(n)])]:t}function P(){return null!=T?T:void 0}L.subscribe((e=>{T=null!=e?e:void 0,"undefined"!=typeof window&&null!=e&&document.documentElement.setAttribute("lang",e);}));const D=Object.assign(Object.assign({},L),{set:e=>{if(e&&function(e){if(null==e)return;const n=E(e);for(let e=0;e<n.length;e++){const t=n[e];if(u(t))return t}}(e)&&h(e)){const{loadingDelay:n}=M();let t;return "undefined"!=typeof window&&null!=P()&&n?t=window.setTimeout((()=>k.set(!0)),n):k.set(!0),b(e).then((()=>{L.set(e);})).finally((()=>{clearTimeout(t),k.set(!1);}))}return L.set(e)}}),C=e=>{const n=Object.create(null);return t=>{const o=JSON.stringify(t);return o in n?n[o]:n[o]=e(t)}},G=(e,n)=>{const{formats:t}=M();if(e in t&&n in t[e])return t[e][n];throw new Error(`[svelte-i18n] Unknown "${n}" ${e} format.`)},J=C((e=>{var{locale:n,format:t}=e,o=v(e,["locale","format"]);if(null==n)throw new Error('[svelte-i18n] A "locale" must be set to format numbers');return t&&(o=G("number",t)),new Intl.NumberFormat(n,o)})),U=C((e=>{var{locale:n,format:t}=e,o=v(e,["locale","format"]);if(null==n)throw new Error('[svelte-i18n] A "locale" must be set to format dates');return t?o=G("date",t):0===Object.keys(o).length&&(o=G("date","short")),new Intl.DateTimeFormat(n,o)})),V=C((e=>{var{locale:n,format:t}=e,o=v(e,["locale","format"]);if(null==n)throw new Error('[svelte-i18n] A "locale" must be set to format time values');return t?o=G("time",t):0===Object.keys(o).length&&(o=G("time","short")),new Intl.DateTimeFormat(n,o)})),_=(e={})=>{var{locale:n=P()}=e,t=v(e,["locale"]);return J(Object.assign({locale:n},t))},q=(e={})=>{var{locale:n=P()}=e,t=v(e,["locale"]);return U(Object.assign({locale:n},t))},B=(e={})=>{var{locale:n=P()}=e,t=v(e,["locale"]);return V(Object.assign({locale:n},t))},H=C(((e,n=P())=>new o(e,n,M().formats,{ignoreTag:M().ignoreTag}))),K=(e,n={})=>{var t,o,r,i;let a=n;"object"==typeof e&&(a=e,e=a.id);const{values:s,locale:u=P(),default:c}=a;if(null==u)throw new Error("[svelte-i18n] Cannot format a message without first setting the initial locale.");let m=l(e,u);if(m){if("string"!=typeof m)return console.warn(`[svelte-i18n] Message with id "${e}" must be of type "string", found: "${typeof m}". Gettin its value through the "$format" method is deprecated; use the "json" method instead.`),m}else m=null!==(i=null!==(r=null===(o=(t=M()).handleMissingMessage)||void 0===o?void 0:o.call(t,{locale:u,id:e,defaultValue:c}))&&void 0!==r?r:c)&&void 0!==i?i:e;if(!s)return m;let f=m;try{f=H(m,u).format(s);}catch(n){console.warn(`[svelte-i18n] Message "${e}" has syntax error:`,n.message);}return f},Q=(e,n)=>B(n).format(e),R=(e,n)=>q(n).format(e),W=(e,n)=>_(n).format(e),X=(e,n=P())=>l(e,n),Y=derived([D,s],(()=>K));derived([D],(()=>Q));derived([D],(()=>R));derived([D],(()=>W));derived([D,s],(()=>X));
4519
+
4520
+ function addNewMessages(lang, dict) {
4521
+ m(lang, dict);
4522
+ }
4523
+
4524
+ function setLocale(_locale) {
4525
+ D.set(_locale);
4526
+ }
4527
+
4528
+ const Translations = {
4529
+ en: {
4530
+ Translations: {
4531
+ pageNotFound: 'Page not found',
4532
+ pageNotFoundMessage: 'The page you were looking for could not be found. Please go back to our Homepage.',
4533
+ home: 'Go to homepage'
4534
+ },
4535
+ },
4536
+ de: {
4537
+ Translations: {
4538
+ pageNotFound: 'Page not found',
4539
+ pageNotFoundMessage: 'The page you were looking for could not be found. Please go back to our Homepage.',
4540
+ home: 'Go to homepage'
4541
+ },
4542
+ },
4543
+ it: {
4544
+ Translations: {
4545
+ pageNotFound: 'Page not found',
4546
+ pageNotFoundMessage: 'The page you were looking for could not be found. Please go back to our Homepage.',
4547
+ home: 'Go to homepage'
4548
+ },
4549
+ },
4550
+ fr: {
4551
+ Translations: {
4552
+ pageNotFound: 'Page not found',
4553
+ pageNotFoundMessage: 'The page you were looking for could not be found. Please go back to our Homepage.',
4554
+ home: 'Go to homepage'
4555
+ },
4556
+ },
4557
+ es: {
4558
+ Translations: {
4559
+ pageNotFound: 'Page not found',
4560
+ pageNotFoundMessage: 'The page you were looking for could not be found. Please go back to our Homepage.',
4561
+ home: 'Go to homepage'
4562
+ },
4563
+ },
4564
+ tr: {
4565
+ Translations: {
4566
+ pageNotFound: 'Page not found',
4567
+ pageNotFoundMessage: 'The page you were looking for could not be found. Please go back to our Homepage.',
4568
+ home: 'Go to homepage'
4569
+ },
4570
+ },
4571
+ ru: {
4572
+ Translations: {
4573
+ pageNotFound: 'Page not found',
4574
+ pageNotFoundMessage: 'The page you were looking for could not be found. Please go back to our Homepage.',
4575
+ home: 'Go to homepage'
4576
+ },
4577
+ },
4578
+ ro: {
4579
+ Translations: {
4580
+ pageNotFound: 'Pagina negasita',
4581
+ pageNotFoundMessage: 'The page you were looking for could not be found. Please go back to our Homepage.',
4582
+ home: 'Go to homepage'
4583
+ },
4584
+ },
4585
+ hr: {
4586
+ Translations: {
4587
+ pageNotFound: 'Page not found',
4588
+ pageNotFoundMessage: 'The page you were looking for could not be found. Please go back to our Homepage.',
4589
+ home: 'Go to homepage'
4590
+ },
4591
+ },
4592
+ hu: {
4593
+ Translations: {
4594
+ pageNotFound: 'Page not found',
4595
+ pageNotFoundMessage: 'The page you were looking for could not be found. Please go back to our Homepage.',
4596
+ home: 'Go to homepage'
4597
+ },
4598
+ },
4599
+ pl: {
4600
+ Translations: {
4601
+ pageNotFound: 'Page not found',
4602
+ pageNotFoundMessage: 'The page you were looking for could not be found. Please go back to our Homepage.',
4603
+ home: 'Go to homepage'
4604
+ },
4605
+ },
4606
+ pt: {
4607
+ Translations: {
4608
+ pageNotFound: 'Page not found',
4609
+ pageNotFoundMessage: 'The page you were looking for could not be found. Please go back to our Homepage.',
4610
+ home: 'Go to homepage'
4611
+ },
4612
+ },
4613
+ sl: {
4614
+ Translations: {
4615
+ pageNotFound: 'Page not found',
4616
+ pageNotFoundMessage: 'The page you were looking for could not be found. Please go back to our Homepage.',
4617
+ home: 'Go to homepage'
4618
+ },
4619
+ },
4620
+ sr: {
4621
+ Translations: {
4622
+ pageNotFound: 'Page not found',
4623
+ pageNotFoundMessage: 'The page you were looking for could not be found. Please go back to our Homepage.',
4624
+ home: 'Go to homepage'
4625
+ },
4626
+ }
4627
+ };
4628
+
4629
+ /* src/Casino_404.svelte generated by Svelte v3.48.0 */
4630
+
4631
+ const { Object: Object_1 } = globals;
4632
+ const file = "src/Casino_404.svelte";
4633
+
4634
+ function create_fragment(ctx) {
4635
+ let div1;
4636
+ let div0;
4637
+ let svg;
4638
+ let g;
4639
+ let path0;
4640
+ let path1;
4641
+ let path2;
4642
+ let path3;
4643
+ let path4;
4644
+ let path5;
4645
+ let t0;
4646
+ let p0;
4647
+ let t1_value = /*$_*/ ctx[0]('Translations.pageNotFound') + "";
4648
+ let t1;
4649
+ let t2;
4650
+ let p1;
4651
+ let t3_value = /*$_*/ ctx[0]('Translations.pageNotFoundMessage') + "";
4652
+ let t3;
4653
+ let t4;
4654
+ let button;
4655
+ let t5_value = /*$_*/ ctx[0]('Translations.home') + "";
4656
+ let t5;
4657
+ let mounted;
4658
+ let dispose;
4659
+
4660
+ const block = {
4661
+ c: function create() {
4662
+ div1 = element("div");
4663
+ div0 = element("div");
4664
+ svg = svg_element("svg");
4665
+ g = svg_element("g");
4666
+ path0 = svg_element("path");
4667
+ path1 = svg_element("path");
4668
+ path2 = svg_element("path");
4669
+ path3 = svg_element("path");
4670
+ path4 = svg_element("path");
4671
+ path5 = svg_element("path");
4672
+ t0 = space();
4673
+ p0 = element("p");
4674
+ t1 = text(t1_value);
4675
+ t2 = space();
4676
+ p1 = element("p");
4677
+ t3 = text(t3_value);
4678
+ t4 = space();
4679
+ button = element("button");
4680
+ t5 = text(t5_value);
4681
+ this.c = noop;
4682
+ attr_dev(path0, "class", "a");
4683
+ attr_dev(path0, "d", "M753.094,548.381h11.379v4.138a3.1,3.1,0,1,0,6.207,0v-4.138a3.1,3.1,0,0,0,0-6.207v-27.93a3,3,0,0,0-2.379-3,3.262,3.262,0,0,0-3.517,1.552l-14.483,26.9a3.305,3.305,0,0,0-.31,1.448v4.138a3.048,3.048,0,0,0,3.1,3.1Zm3.1-6.414,8.276-15.414v15.62H756.2Z");
4684
+ attr_dev(path0, "transform", "translate(-658.898 -446.452)");
4685
+ add_location(path0, file, 18, 162, 688);
4686
+ attr_dev(path1, "class", "a");
4687
+ attr_dev(path1, "d", "M508.259,555.422a11.346,11.346,0,0,0,11.379-11.379V522.319a11.379,11.379,0,1,0-22.757,0v21.725A11.346,11.346,0,0,0,508.259,555.422Zm-5.172-33.1a5.172,5.172,0,1,1,10.345,0v21.725a5.172,5.172,0,0,1-10.345,0Z");
4688
+ attr_dev(path1, "transform", "translate(-433.716 -446.252)");
4689
+ add_location(path1, file, 18, 470, 996);
4690
+ attr_dev(path2, "class", "a");
4691
+ attr_dev(path2, "d", "M237.474,548.381h11.379v4.138a3.1,3.1,0,1,0,6.207,0v-4.138a3.1,3.1,0,1,0,0-6.207v-27.93a3,3,0,0,0-2.379-3,3.2,3.2,0,0,0-3.517,1.552l-14.483,26.9a3.3,3.3,0,0,0-.31,1.448v4.138a3.048,3.048,0,0,0,3.1,3.1Zm3.1-6.414,8.276-15.414v15.62h-8.276Z");
4692
+ attr_dev(path2, "transform", "translate(-200.173 -446.452)");
4693
+ add_location(path2, file, 18, 738, 1264);
4694
+ attr_dev(path3, "class", "a");
4695
+ attr_dev(path3, "d", "M22.819,139.685H126.266a13.422,13.422,0,0,0,13.449-13.449V22.789A13.422,13.422,0,0,0,126.266,9.34H22.819A13.422,13.422,0,0,0,9.37,22.789V126.236A13.422,13.422,0,0,0,22.819,139.685Zm-7.241-116.9a7.2,7.2,0,0,1,7.241-7.241H126.266a7.2,7.2,0,0,1,7.241,7.241V38.3H15.572Zm0,21.725H133.513v81.723a7.2,7.2,0,0,1-7.241,7.241H22.824a7.2,7.2,0,0,1-7.241-7.241Z");
4696
+ add_location(path3, file, 18, 1039, 1565);
4697
+ attr_dev(path4, "class", "a");
4698
+ attr_dev(path4, "d", "M147.866,140.62h-4.138a3.1,3.1,0,0,0,0,6.207h4.138a3.1,3.1,0,0,0,0-6.207Z");
4699
+ attr_dev(path4, "transform", "translate(-116.772 -116.794)");
4700
+ add_location(path4, file, 18, 1411, 1937);
4701
+ attr_dev(path5, "class", "a");
4702
+ attr_dev(path5, "d", "M297.866,140.62h-4.138a3.1,3.1,0,1,0,0,6.207h4.138a3.1,3.1,0,0,0,0-6.207Z");
4703
+ attr_dev(path5, "transform", "translate(-250.22 -116.794)");
4704
+ add_location(path5, file, 18, 1547, 2073);
4705
+ attr_dev(g, "transform", "translate(-9.37 -9.34)");
4706
+ add_location(g, file, 18, 124, 650);
4707
+ attr_dev(svg, "class", "svgColor");
4708
+ attr_dev(svg, "xmlns", "http://www.w3.org/2000/svg");
4709
+ attr_dev(svg, "width", "130.345");
4710
+ attr_dev(svg, "height", "130.345");
4711
+ attr_dev(svg, "viewBox", "0 0 130.345 130.345");
4712
+ add_location(svg, file, 18, 4, 530);
4713
+ attr_dev(p0, "class", "PageTitle");
4714
+ add_location(p0, file, 19, 4, 2223);
4715
+ attr_dev(p1, "class", "PageContent");
4716
+ add_location(p1, file, 22, 4, 2298);
4717
+ attr_dev(button, "class", "ButtonDefaultSmall");
4718
+ add_location(button, file, 25, 4, 2382);
4719
+ attr_dev(div0, "class", "NotFoundPage");
4720
+ add_location(div0, file, 17, 2, 499);
4721
+ attr_dev(div1, "class", "PageWrapper");
4722
+ add_location(div1, file, 16, 0, 471);
4723
+ },
4724
+ l: function claim(nodes) {
4725
+ throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option");
4726
+ },
4727
+ m: function mount(target, anchor) {
4728
+ insert_dev(target, div1, anchor);
4729
+ append_dev(div1, div0);
4730
+ append_dev(div0, svg);
4731
+ append_dev(svg, g);
4732
+ append_dev(g, path0);
4733
+ append_dev(g, path1);
4734
+ append_dev(g, path2);
4735
+ append_dev(g, path3);
4736
+ append_dev(g, path4);
4737
+ append_dev(g, path5);
4738
+ append_dev(div0, t0);
4739
+ append_dev(div0, p0);
4740
+ append_dev(p0, t1);
4741
+ append_dev(div0, t2);
4742
+ append_dev(div0, p1);
4743
+ append_dev(p1, t3);
4744
+ append_dev(div0, t4);
4745
+ append_dev(div0, button);
4746
+ append_dev(button, t5);
4747
+
4748
+ if (!mounted) {
4749
+ dispose = listen_dev(button, "click", /*click_handler*/ ctx[3], false, false, false);
4750
+ mounted = true;
4751
+ }
4752
+ },
4753
+ p: function update(ctx, [dirty]) {
4754
+ if (dirty & /*$_*/ 1 && t1_value !== (t1_value = /*$_*/ ctx[0]('Translations.pageNotFound') + "")) set_data_dev(t1, t1_value);
4755
+ if (dirty & /*$_*/ 1 && t3_value !== (t3_value = /*$_*/ ctx[0]('Translations.pageNotFoundMessage') + "")) set_data_dev(t3, t3_value);
4756
+ if (dirty & /*$_*/ 1 && t5_value !== (t5_value = /*$_*/ ctx[0]('Translations.home') + "")) set_data_dev(t5, t5_value);
4757
+ },
4758
+ i: noop,
4759
+ o: noop,
4760
+ d: function destroy(detaching) {
4761
+ if (detaching) detach_dev(div1);
4762
+ mounted = false;
4763
+ dispose();
4764
+ }
4765
+ };
4766
+
4767
+ dispatch_dev("SvelteRegisterBlock", {
4768
+ block,
4769
+ id: create_fragment.name,
4770
+ type: "component",
4771
+ source: "",
4772
+ ctx
4773
+ });
4774
+
4775
+ return block;
4776
+ }
4777
+
4778
+ function instance($$self, $$props, $$invalidate) {
4779
+ let $_;
4780
+ validate_store(Y, '_');
4781
+ component_subscribe($$self, Y, $$value => $$invalidate(0, $_ = $$value));
4782
+ let { $$slots: slots = {}, $$scope } = $$props;
4783
+ validate_slots('undefined', slots, []);
4784
+ let { lang = 'en' } = $$props;
4785
+
4786
+ Object.keys(Translations).forEach(item => {
4787
+ addNewMessages(item, Translations[item]);
4788
+ });
4789
+
4790
+ const goToHome = () => {
4791
+ window.postMessage({ type: 'GoToHomepage' }, window.location.href);
4792
+ };
4793
+
4794
+ const setActiveLanguage = () => {
4795
+ setLocale(lang);
4796
+ };
4797
+
4798
+ const writable_props = ['lang'];
4799
+
4800
+ Object_1.keys($$props).forEach(key => {
4801
+ if (!~writable_props.indexOf(key) && key.slice(0, 2) !== '$$' && key !== 'slot') console.warn(`<undefined> was created with unknown prop '${key}'`);
4802
+ });
4803
+
4804
+ const click_handler = () => goToHome();
4805
+
4806
+ $$self.$$set = $$props => {
4807
+ if ('lang' in $$props) $$invalidate(2, lang = $$props.lang);
4808
+ };
4809
+
4810
+ $$self.$capture_state = () => ({
4811
+ _: Y,
4812
+ addNewMessages,
4813
+ setLocale,
4814
+ Translations,
4815
+ lang,
4816
+ goToHome,
4817
+ setActiveLanguage,
4818
+ $_
4819
+ });
4820
+
4821
+ $$self.$inject_state = $$props => {
4822
+ if ('lang' in $$props) $$invalidate(2, lang = $$props.lang);
4823
+ };
4824
+
4825
+ if ($$props && "$$inject" in $$props) {
4826
+ $$self.$inject_state($$props.$$inject);
4827
+ }
4828
+
4829
+ $$self.$$.update = () => {
4830
+ if ($$self.$$.dirty & /*lang*/ 4) {
4831
+ lang && setActiveLanguage();
4832
+ }
4833
+ };
4834
+
4835
+ return [$_, goToHome, lang, click_handler];
4836
+ }
4837
+
4838
+ class Casino_404 extends SvelteElement {
4839
+ constructor(options) {
4840
+ super();
4841
+ this.shadowRoot.innerHTML = `<style>:host{font-family:system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji'}*,*::before,*::after{margin:0;padding:0;list-style:none;text-decoration:none;outline:none;box-sizing:border-box;font-family:"Helvetica Neue", "Helvetica", sans-serif}.PageWrapper{color:var(--emfe-w-color-white, #FFFFFF);background:var(--emfe-w-color-contrast, #07072A);padding:50px 0;width:100%;text-align:center}.NotFoundPage{display:flex;flex-direction:column;margin:auto;gap:40px;align-items:center;max-width:800px;padding:50px}.NotFoundPage svg{fill:var(--emfe-w-color-primary, #D0046C)}.PageTitle{color:var(--emfe-w-color-primary, #D0046C);font-weight:500;font-size:28px}.PageContent{color:#D1D1D1;font-size:18px;line-height:24px}.ButtonDefaultSmall{background:var(--emfe-w-color-primary, #D0046C);border:1px solid var(--emfe-w-color-primary, #D0046C);color:#fff;border-radius:5px;width:30%;height:60px;display:flex;align-items:center;justify-content:center;font-size:16px;text-transform:uppercase;transition-duration:0.3s;box-sizing:border-box;cursor:pointer}@media only screen and (max-width: 475px){.PageWrapper{color:var(--emfe-w-color-white, #FFFFFF);background:var(--emfe-w-color-contrast, #07072A);padding:20px 0;width:100%;text-align:center}.NotFoundPage{text-align:center;width:100%}.PageTitle{font-size:22px}.ButtonDefaultSmall{width:80%;height:50px;font-size:14px;grid-template-columns:1fr}.PageContent{font-size:16px;line-height:18px}}</style>`;
4842
+
4843
+ init(
4844
+ this,
4845
+ {
4846
+ target: this.shadowRoot,
4847
+ props: attribute_to_object(this.attributes),
4848
+ customElement: true
4849
+ },
4850
+ instance,
4851
+ create_fragment,
4852
+ safe_not_equal,
4853
+ { lang: 2 },
4854
+ null
4855
+ );
4856
+
4857
+ if (options) {
4858
+ if (options.target) {
4859
+ insert_dev(options.target, this, options.anchor);
4860
+ }
4861
+
4862
+ if (options.props) {
4863
+ this.$set(options.props);
4864
+ flush();
4865
+ }
4866
+ }
4867
+ }
4868
+
4869
+ static get observedAttributes() {
4870
+ return ["lang"];
4871
+ }
4872
+
4873
+ get lang() {
4874
+ return this.$$.ctx[2];
4875
+ }
4876
+
4877
+ set lang(lang) {
4878
+ this.$$set({ lang });
4879
+ flush();
4880
+ }
4881
+ }
4882
+
4883
+ !customElements.get('casino-404') && customElements.define('casino-404', Casino_404);
4884
+
4885
+ return Casino_404;
4886
+
4887
+ }));
4888
+ //# sourceMappingURL=casino-404.js.map