UNPKG

264 kBJavaScriptView Raw
1/**
2 * @license Angular v8.2.0
3 * (c) 2010-2019 Google LLC. https://angular.io/
4 * License: MIT
5 */
6
7import { InjectionToken, Injectable, EventEmitter, Optional, Inject, ɵfindLocaleData, ɵLocaleDataIndex, ɵgetLocalePluralCase, LOCALE_ID, ɵLOCALE_DATA, ɵisListLikeIterable, ɵstringify, IterableDiffers, KeyValueDiffers, ElementRef, Renderer2, ɵɵdefineDirective, Input, Directive, ɵɵallocHostVars, ɵɵstyling, ɵɵclassMap, ɵɵstylingApply, NgModuleRef, ComponentFactoryResolver, Type, Injector, NgModuleFactory, ViewContainerRef, isDevMode, TemplateRef, Host, Attribute, ɵɵstyleMap, Pipe, ɵlooseIdentical, WrappedValue, ɵisPromise, ɵisObservable, ChangeDetectorRef, NgModule, Version, ɵɵdefineInjectable, ɵɵinject, ErrorHandler } from '@angular/core';
8import { __decorate, __metadata, __extends, __param, __read, __values, __assign } from 'tslib';
9
10/**
11 * @license
12 * Copyright Google Inc. All Rights Reserved.
13 *
14 * Use of this source code is governed by an MIT-style license that can be
15 * found in the LICENSE file at https://angular.io/license
16 */
17/**
18 * This class should not be used directly by an application developer. Instead, use
19 * {@link Location}.
20 *
21 * `PlatformLocation` encapsulates all calls to DOM apis, which allows the Router to be platform
22 * agnostic.
23 * This means that we can have different implementation of `PlatformLocation` for the different
24 * platforms that angular supports. For example, `@angular/platform-browser` provides an
25 * implementation specific to the browser environment, while `@angular/platform-webworker` provides
26 * one suitable for use with web workers.
27 *
28 * The `PlatformLocation` class is used directly by all implementations of {@link LocationStrategy}
29 * when they need to interact with the DOM apis like pushState, popState, etc...
30 *
31 * {@link LocationStrategy} in turn is used by the {@link Location} service which is used directly
32 * by the {@link Router} in order to navigate between routes. Since all interactions between {@link
33 * Router} /
34 * {@link Location} / {@link LocationStrategy} and DOM apis flow through the `PlatformLocation`
35 * class they are all platform independent.
36 *
37 * @publicApi
38 */
39var PlatformLocation = /** @class */ (function () {
40 function PlatformLocation() {
41 }
42 return PlatformLocation;
43}());
44/**
45 * @description
46 * Indicates when a location is initialized.
47 *
48 * @publicApi
49 */
50var LOCATION_INITIALIZED = new InjectionToken('Location Initialized');
51
52/**
53 * @license
54 * Copyright Google Inc. All Rights Reserved.
55 *
56 * Use of this source code is governed by an MIT-style license that can be
57 * found in the LICENSE file at https://angular.io/license
58 */
59/**
60 * Enables the `Location` service to read route state from the browser's URL.
61 * Angular provides two strategies:
62 * `HashLocationStrategy` and `PathLocationStrategy`.
63 *
64 * Applications should use the `Router` or `Location` services to
65 * interact with application route state.
66 *
67 * For instance, `HashLocationStrategy` produces URLs like
68 * <code class="no-auto-link">http://example.com#/foo</code>,
69 * and `PathLocationStrategy` produces
70 * <code class="no-auto-link">http://example.com/foo</code> as an equivalent URL.
71 *
72 * See these two classes for more.
73 *
74 * @publicApi
75 */
76var LocationStrategy = /** @class */ (function () {
77 function LocationStrategy() {
78 }
79 return LocationStrategy;
80}());
81/**
82 * A predefined [DI token](guide/glossary#di-token) for the base href
83 * to be used with the `PathLocationStrategy`.
84 * The base href is the URL prefix that should be preserved when generating
85 * and recognizing URLs.
86 *
87 * @usageNotes
88 *
89 * The following example shows how to use this token to configure the root app injector
90 * with a base href value, so that the DI framework can supply the dependency anywhere in the app.
91 *
92 * ```typescript
93 * import {Component, NgModule} from '@angular/core';
94 * import {APP_BASE_HREF} from '@angular/common';
95 *
96 * @NgModule({
97 * providers: [{provide: APP_BASE_HREF, useValue: '/my/app'}]
98 * })
99 * class AppModule {}
100 * ```
101 *
102 * @publicApi
103 */
104var APP_BASE_HREF = new InjectionToken('appBaseHref');
105
106/**
107 * @license
108 * Copyright Google Inc. All Rights Reserved.
109 *
110 * Use of this source code is governed by an MIT-style license that can be
111 * found in the LICENSE file at https://angular.io/license
112 */
113/**
114 * @description
115 *
116 * A service that applications can use to interact with a browser's URL.
117 *
118 * Depending on the `LocationStrategy` used, `Location` will either persist
119 * to the URL's path or the URL's hash segment.
120 *
121 * @usageNotes
122 *
123 * It's better to use the {@link Router#navigate} service to trigger route changes. Use
124 * `Location` only if you need to interact with or create normalized URLs outside of
125 * routing.
126 *
127 * `Location` is responsible for normalizing the URL against the application's base href.
128 * A normalized URL is absolute from the URL host, includes the application's base href, and has no
129 * trailing slash:
130 * - `/my/app/user/123` is normalized
131 * - `my/app/user/123` **is not** normalized
132 * - `/my/app/user/123/` **is not** normalized
133 *
134 * ### Example
135 *
136 * <code-example path='common/location/ts/path_location_component.ts'
137 * region='LocationComponent'></code-example>
138 *
139 * @publicApi
140 */
141var Location = /** @class */ (function () {
142 function Location(platformStrategy, platformLocation) {
143 var _this = this;
144 /** @internal */
145 this._subject = new EventEmitter();
146 /** @internal */
147 this._urlChangeListeners = [];
148 this._platformStrategy = platformStrategy;
149 var browserBaseHref = this._platformStrategy.getBaseHref();
150 this._platformLocation = platformLocation;
151 this._baseHref = Location_1.stripTrailingSlash(_stripIndexHtml(browserBaseHref));
152 this._platformStrategy.onPopState(function (ev) {
153 _this._subject.emit({
154 'url': _this.path(true),
155 'pop': true,
156 'state': ev.state,
157 'type': ev.type,
158 });
159 });
160 }
161 Location_1 = Location;
162 /**
163 * Returns the normalized URL path.
164 *
165 * @param includeHash Whether path has an anchor fragment.
166 *
167 * @returns The normalized URL path.
168 */
169 // TODO: vsavkin. Remove the boolean flag and always include hash once the deprecated router is
170 // removed.
171 Location.prototype.path = function (includeHash) {
172 if (includeHash === void 0) { includeHash = false; }
173 return this.normalize(this._platformStrategy.path(includeHash));
174 };
175 /**
176 * Returns the current value of the history.state object.
177 */
178 Location.prototype.getState = function () { return this._platformLocation.getState(); };
179 /**
180 * Normalizes the given path and compares to the current normalized path.
181 *
182 * @param path The given URL path
183 * @param query Query parameters
184 *
185 * @returns `true` if the given URL path is equal to the current normalized path, `false`
186 * otherwise.
187 */
188 Location.prototype.isCurrentPathEqualTo = function (path, query) {
189 if (query === void 0) { query = ''; }
190 return this.path() == this.normalize(path + Location_1.normalizeQueryParams(query));
191 };
192 /**
193 * Given a string representing a URL, returns the URL path after stripping the
194 * trailing slashes.
195 *
196 * @param url String representing a URL.
197 *
198 * @returns Normalized URL string.
199 */
200 Location.prototype.normalize = function (url) {
201 return Location_1.stripTrailingSlash(_stripBaseHref(this._baseHref, _stripIndexHtml(url)));
202 };
203 /**
204 * Given a string representing a URL, returns the platform-specific external URL path.
205 * If the given URL doesn't begin with a leading slash (`'/'`), this method adds one
206 * before normalizing. This method also adds a hash if `HashLocationStrategy` is
207 * used, or the `APP_BASE_HREF` if the `PathLocationStrategy` is in use.
208 *
209 *
210 * @param url String representing a URL.
211 *
212 * @returns A normalized platform-specific URL.
213 */
214 Location.prototype.prepareExternalUrl = function (url) {
215 if (url && url[0] !== '/') {
216 url = '/' + url;
217 }
218 return this._platformStrategy.prepareExternalUrl(url);
219 };
220 // TODO: rename this method to pushState
221 /**
222 * Changes the browsers URL to a normalized version of the given URL, and pushes a
223 * new item onto the platform's history.
224 *
225 * @param path URL path to normalizze
226 * @param query Query parameters
227 * @param state Location history state
228 *
229 */
230 Location.prototype.go = function (path, query, state) {
231 if (query === void 0) { query = ''; }
232 if (state === void 0) { state = null; }
233 this._platformStrategy.pushState(state, '', path, query);
234 this._notifyUrlChangeListeners(this.prepareExternalUrl(path + Location_1.normalizeQueryParams(query)), state);
235 };
236 /**
237 * Changes the browser's URL to a normalized version of the given URL, and replaces
238 * the top item on the platform's history stack.
239 *
240 * @param path URL path to normalizze
241 * @param query Query parameters
242 * @param state Location history state
243 */
244 Location.prototype.replaceState = function (path, query, state) {
245 if (query === void 0) { query = ''; }
246 if (state === void 0) { state = null; }
247 this._platformStrategy.replaceState(state, '', path, query);
248 this._notifyUrlChangeListeners(this.prepareExternalUrl(path + Location_1.normalizeQueryParams(query)), state);
249 };
250 /**
251 * Navigates forward in the platform's history.
252 */
253 Location.prototype.forward = function () { this._platformStrategy.forward(); };
254 /**
255 * Navigates back in the platform's history.
256 */
257 Location.prototype.back = function () { this._platformStrategy.back(); };
258 /**
259 * Register URL change listeners. This API can be used to catch updates performed by the Angular
260 * framework. These are not detectible through "popstate" or "hashchange" events.
261 */
262 Location.prototype.onUrlChange = function (fn) {
263 var _this = this;
264 this._urlChangeListeners.push(fn);
265 this.subscribe(function (v) { _this._notifyUrlChangeListeners(v.url, v.state); });
266 };
267 /** @internal */
268 Location.prototype._notifyUrlChangeListeners = function (url, state) {
269 if (url === void 0) { url = ''; }
270 this._urlChangeListeners.forEach(function (fn) { return fn(url, state); });
271 };
272 /**
273 * Subscribe to the platform's `popState` events.
274 *
275 * @param value Event that is triggered when the state history changes.
276 * @param exception The exception to throw.
277 *
278 * @returns Subscribed events.
279 */
280 Location.prototype.subscribe = function (onNext, onThrow, onReturn) {
281 return this._subject.subscribe({ next: onNext, error: onThrow, complete: onReturn });
282 };
283 /**
284 * Given a string of url parameters, prepend with `?` if needed, otherwise return the
285 * parameters as is.
286 *
287 * @param params String of URL parameters
288 *
289 * @returns URL parameters prepended with `?` or the parameters as is.
290 */
291 Location.normalizeQueryParams = function (params) {
292 return params && params[0] !== '?' ? '?' + params : params;
293 };
294 /**
295 * Given 2 parts of a URL, join them with a slash if needed.
296 *
297 * @param start URL string
298 * @param end URL string
299 *
300 *
301 * @returns Given URL strings joined with a slash, if needed.
302 */
303 Location.joinWithSlash = function (start, end) {
304 if (start.length == 0) {
305 return end;
306 }
307 if (end.length == 0) {
308 return start;
309 }
310 var slashes = 0;
311 if (start.endsWith('/')) {
312 slashes++;
313 }
314 if (end.startsWith('/')) {
315 slashes++;
316 }
317 if (slashes == 2) {
318 return start + end.substring(1);
319 }
320 if (slashes == 1) {
321 return start + end;
322 }
323 return start + '/' + end;
324 };
325 /**
326 * If URL has a trailing slash, remove it, otherwise return the URL as is. The
327 * method looks for the first occurrence of either `#`, `?`, or the end of the
328 * line as `/` characters and removes the trailing slash if one exists.
329 *
330 * @param url URL string
331 *
332 * @returns Returns a URL string after removing the trailing slash if one exists, otherwise
333 * returns the string as is.
334 */
335 Location.stripTrailingSlash = function (url) {
336 var match = url.match(/#|\?|$/);
337 var pathEndIdx = match && match.index || url.length;
338 var droppedSlashIdx = pathEndIdx - (url[pathEndIdx - 1] === '/' ? 1 : 0);
339 return url.slice(0, droppedSlashIdx) + url.slice(pathEndIdx);
340 };
341 var Location_1;
342 Location = Location_1 = __decorate([
343 Injectable(),
344 __metadata("design:paramtypes", [LocationStrategy, PlatformLocation])
345 ], Location);
346 return Location;
347}());
348function _stripBaseHref(baseHref, url) {
349 return baseHref && url.startsWith(baseHref) ? url.substring(baseHref.length) : url;
350}
351function _stripIndexHtml(url) {
352 return url.replace(/\/index.html$/, '');
353}
354
355/**
356 * @license
357 * Copyright Google Inc. All Rights Reserved.
358 *
359 * Use of this source code is governed by an MIT-style license that can be
360 * found in the LICENSE file at https://angular.io/license
361 */
362/**
363 * @description
364 * A {@link LocationStrategy} used to configure the {@link Location} service to
365 * represent its state in the
366 * [hash fragment](https://en.wikipedia.org/wiki/Uniform_Resource_Locator#Syntax)
367 * of the browser's URL.
368 *
369 * For instance, if you call `location.go('/foo')`, the browser's URL will become
370 * `example.com#/foo`.
371 *
372 * @usageNotes
373 *
374 * ### Example
375 *
376 * {@example common/location/ts/hash_location_component.ts region='LocationComponent'}
377 *
378 * @publicApi
379 */
380var HashLocationStrategy = /** @class */ (function (_super) {
381 __extends(HashLocationStrategy, _super);
382 function HashLocationStrategy(_platformLocation, _baseHref) {
383 var _this = _super.call(this) || this;
384 _this._platformLocation = _platformLocation;
385 _this._baseHref = '';
386 if (_baseHref != null) {
387 _this._baseHref = _baseHref;
388 }
389 return _this;
390 }
391 HashLocationStrategy.prototype.onPopState = function (fn) {
392 this._platformLocation.onPopState(fn);
393 this._platformLocation.onHashChange(fn);
394 };
395 HashLocationStrategy.prototype.getBaseHref = function () { return this._baseHref; };
396 HashLocationStrategy.prototype.path = function (includeHash) {
397 if (includeHash === void 0) { includeHash = false; }
398 // the hash value is always prefixed with a `#`
399 // and if it is empty then it will stay empty
400 var path = this._platformLocation.hash;
401 if (path == null)
402 path = '#';
403 return path.length > 0 ? path.substring(1) : path;
404 };
405 HashLocationStrategy.prototype.prepareExternalUrl = function (internal) {
406 var url = Location.joinWithSlash(this._baseHref, internal);
407 return url.length > 0 ? ('#' + url) : url;
408 };
409 HashLocationStrategy.prototype.pushState = function (state, title, path, queryParams) {
410 var url = this.prepareExternalUrl(path + Location.normalizeQueryParams(queryParams));
411 if (url.length == 0) {
412 url = this._platformLocation.pathname;
413 }
414 this._platformLocation.pushState(state, title, url);
415 };
416 HashLocationStrategy.prototype.replaceState = function (state, title, path, queryParams) {
417 var url = this.prepareExternalUrl(path + Location.normalizeQueryParams(queryParams));
418 if (url.length == 0) {
419 url = this._platformLocation.pathname;
420 }
421 this._platformLocation.replaceState(state, title, url);
422 };
423 HashLocationStrategy.prototype.forward = function () { this._platformLocation.forward(); };
424 HashLocationStrategy.prototype.back = function () { this._platformLocation.back(); };
425 HashLocationStrategy = __decorate([
426 Injectable(),
427 __param(1, Optional()), __param(1, Inject(APP_BASE_HREF)),
428 __metadata("design:paramtypes", [PlatformLocation, String])
429 ], HashLocationStrategy);
430 return HashLocationStrategy;
431}(LocationStrategy));
432
433/**
434 * @license
435 * Copyright Google Inc. All Rights Reserved.
436 *
437 * Use of this source code is governed by an MIT-style license that can be
438 * found in the LICENSE file at https://angular.io/license
439 */
440/**
441 * @description
442 * A {@link LocationStrategy} used to configure the {@link Location} service to
443 * represent its state in the
444 * [path](https://en.wikipedia.org/wiki/Uniform_Resource_Locator#Syntax) of the
445 * browser's URL.
446 *
447 * If you're using `PathLocationStrategy`, you must provide a {@link APP_BASE_HREF}
448 * or add a base element to the document. This URL prefix that will be preserved
449 * when generating and recognizing URLs.
450 *
451 * For instance, if you provide an `APP_BASE_HREF` of `'/my/app'` and call
452 * `location.go('/foo')`, the browser's URL will become
453 * `example.com/my/app/foo`.
454 *
455 * Similarly, if you add `<base href='/my/app'/>` to the document and call
456 * `location.go('/foo')`, the browser's URL will become
457 * `example.com/my/app/foo`.
458 *
459 * @usageNotes
460 *
461 * ### Example
462 *
463 * {@example common/location/ts/path_location_component.ts region='LocationComponent'}
464 *
465 * @publicApi
466 */
467var PathLocationStrategy = /** @class */ (function (_super) {
468 __extends(PathLocationStrategy, _super);
469 function PathLocationStrategy(_platformLocation, href) {
470 var _this = _super.call(this) || this;
471 _this._platformLocation = _platformLocation;
472 if (href == null) {
473 href = _this._platformLocation.getBaseHrefFromDOM();
474 }
475 if (href == null) {
476 throw new Error("No base href set. Please provide a value for the APP_BASE_HREF token or add a base element to the document.");
477 }
478 _this._baseHref = href;
479 return _this;
480 }
481 PathLocationStrategy.prototype.onPopState = function (fn) {
482 this._platformLocation.onPopState(fn);
483 this._platformLocation.onHashChange(fn);
484 };
485 PathLocationStrategy.prototype.getBaseHref = function () { return this._baseHref; };
486 PathLocationStrategy.prototype.prepareExternalUrl = function (internal) {
487 return Location.joinWithSlash(this._baseHref, internal);
488 };
489 PathLocationStrategy.prototype.path = function (includeHash) {
490 if (includeHash === void 0) { includeHash = false; }
491 var pathname = this._platformLocation.pathname +
492 Location.normalizeQueryParams(this._platformLocation.search);
493 var hash = this._platformLocation.hash;
494 return hash && includeHash ? "" + pathname + hash : pathname;
495 };
496 PathLocationStrategy.prototype.pushState = function (state, title, url, queryParams) {
497 var externalUrl = this.prepareExternalUrl(url + Location.normalizeQueryParams(queryParams));
498 this._platformLocation.pushState(state, title, externalUrl);
499 };
500 PathLocationStrategy.prototype.replaceState = function (state, title, url, queryParams) {
501 var externalUrl = this.prepareExternalUrl(url + Location.normalizeQueryParams(queryParams));
502 this._platformLocation.replaceState(state, title, externalUrl);
503 };
504 PathLocationStrategy.prototype.forward = function () { this._platformLocation.forward(); };
505 PathLocationStrategy.prototype.back = function () { this._platformLocation.back(); };
506 PathLocationStrategy = __decorate([
507 Injectable(),
508 __param(1, Optional()), __param(1, Inject(APP_BASE_HREF)),
509 __metadata("design:paramtypes", [PlatformLocation, String])
510 ], PathLocationStrategy);
511 return PathLocationStrategy;
512}(LocationStrategy));
513
514/**
515 * @license
516 * Copyright Google Inc. All Rights Reserved.
517 *
518 * Use of this source code is governed by an MIT-style license that can be
519 * found in the LICENSE file at https://angular.io/license
520 */
521
522/**
523 * @license
524 * Copyright Google Inc. All Rights Reserved.
525 *
526 * Use of this source code is governed by an MIT-style license that can be
527 * found in the LICENSE file at https://angular.io/license
528 */
529/** @internal */
530var CURRENCIES_EN = {
531 'ADP': [undefined, undefined, 0],
532 'AFN': [undefined, undefined, 0],
533 'ALL': [undefined, undefined, 0],
534 'AMD': [undefined, undefined, 0],
535 'AOA': [undefined, 'Kz'],
536 'ARS': [undefined, '$'],
537 'AUD': ['A$', '$'],
538 'BAM': [undefined, 'KM'],
539 'BBD': [undefined, '$'],
540 'BDT': [undefined, '৳'],
541 'BHD': [undefined, undefined, 3],
542 'BIF': [undefined, undefined, 0],
543 'BMD': [undefined, '$'],
544 'BND': [undefined, '$'],
545 'BOB': [undefined, 'Bs'],
546 'BRL': ['R$'],
547 'BSD': [undefined, '$'],
548 'BWP': [undefined, 'P'],
549 'BYN': [undefined, 'р.', 2],
550 'BYR': [undefined, undefined, 0],
551 'BZD': [undefined, '$'],
552 'CAD': ['CA$', '$', 2],
553 'CHF': [undefined, undefined, 2],
554 'CLF': [undefined, undefined, 4],
555 'CLP': [undefined, '$', 0],
556 'CNY': ['CN¥', '¥'],
557 'COP': [undefined, '$', 0],
558 'CRC': [undefined, '₡', 2],
559 'CUC': [undefined, '$'],
560 'CUP': [undefined, '$'],
561 'CZK': [undefined, 'Kč', 2],
562 'DJF': [undefined, undefined, 0],
563 'DKK': [undefined, 'kr', 2],
564 'DOP': [undefined, '$'],
565 'EGP': [undefined, 'E£'],
566 'ESP': [undefined, '₧', 0],
567 'EUR': ['€'],
568 'FJD': [undefined, '$'],
569 'FKP': [undefined, '£'],
570 'GBP': ['£'],
571 'GEL': [undefined, '₾'],
572 'GIP': [undefined, '£'],
573 'GNF': [undefined, 'FG', 0],
574 'GTQ': [undefined, 'Q'],
575 'GYD': [undefined, '$', 0],
576 'HKD': ['HK$', '$'],
577 'HNL': [undefined, 'L'],
578 'HRK': [undefined, 'kn'],
579 'HUF': [undefined, 'Ft', 2],
580 'IDR': [undefined, 'Rp', 0],
581 'ILS': ['₪'],
582 'INR': ['₹'],
583 'IQD': [undefined, undefined, 0],
584 'IRR': [undefined, undefined, 0],
585 'ISK': [undefined, 'kr', 0],
586 'ITL': [undefined, undefined, 0],
587 'JMD': [undefined, '$'],
588 'JOD': [undefined, undefined, 3],
589 'JPY': ['¥', undefined, 0],
590 'KHR': [undefined, '៛'],
591 'KMF': [undefined, 'CF', 0],
592 'KPW': [undefined, '₩', 0],
593 'KRW': ['₩', undefined, 0],
594 'KWD': [undefined, undefined, 3],
595 'KYD': [undefined, '$'],
596 'KZT': [undefined, '₸'],
597 'LAK': [undefined, '₭', 0],
598 'LBP': [undefined, 'L£', 0],
599 'LKR': [undefined, 'Rs'],
600 'LRD': [undefined, '$'],
601 'LTL': [undefined, 'Lt'],
602 'LUF': [undefined, undefined, 0],
603 'LVL': [undefined, 'Ls'],
604 'LYD': [undefined, undefined, 3],
605 'MGA': [undefined, 'Ar', 0],
606 'MGF': [undefined, undefined, 0],
607 'MMK': [undefined, 'K', 0],
608 'MNT': [undefined, '₮', 0],
609 'MRO': [undefined, undefined, 0],
610 'MUR': [undefined, 'Rs', 0],
611 'MXN': ['MX$', '$'],
612 'MYR': [undefined, 'RM'],
613 'NAD': [undefined, '$'],
614 'NGN': [undefined, '₦'],
615 'NIO': [undefined, 'C$'],
616 'NOK': [undefined, 'kr', 2],
617 'NPR': [undefined, 'Rs'],
618 'NZD': ['NZ$', '$'],
619 'OMR': [undefined, undefined, 3],
620 'PHP': [undefined, '₱'],
621 'PKR': [undefined, 'Rs', 0],
622 'PLN': [undefined, 'zł'],
623 'PYG': [undefined, '₲', 0],
624 'RON': [undefined, 'lei'],
625 'RSD': [undefined, undefined, 0],
626 'RUB': [undefined, '₽'],
627 'RUR': [undefined, 'р.'],
628 'RWF': [undefined, 'RF', 0],
629 'SBD': [undefined, '$'],
630 'SEK': [undefined, 'kr', 2],
631 'SGD': [undefined, '$'],
632 'SHP': [undefined, '£'],
633 'SLL': [undefined, undefined, 0],
634 'SOS': [undefined, undefined, 0],
635 'SRD': [undefined, '$'],
636 'SSP': [undefined, '£'],
637 'STD': [undefined, undefined, 0],
638 'STN': [undefined, 'Db'],
639 'SYP': [undefined, '£', 0],
640 'THB': [undefined, '฿'],
641 'TMM': [undefined, undefined, 0],
642 'TND': [undefined, undefined, 3],
643 'TOP': [undefined, 'T$'],
644 'TRL': [undefined, undefined, 0],
645 'TRY': [undefined, '₺'],
646 'TTD': [undefined, '$'],
647 'TWD': ['NT$', '$', 2],
648 'TZS': [undefined, undefined, 0],
649 'UAH': [undefined, '₴'],
650 'UGX': [undefined, undefined, 0],
651 'USD': ['$'],
652 'UYI': [undefined, undefined, 0],
653 'UYU': [undefined, '$'],
654 'UZS': [undefined, undefined, 0],
655 'VEF': [undefined, 'Bs'],
656 'VND': ['₫', undefined, 0],
657 'VUV': [undefined, undefined, 0],
658 'XAF': ['FCFA', undefined, 0],
659 'XCD': ['EC$', '$'],
660 'XOF': ['CFA', undefined, 0],
661 'XPF': ['CFPF', undefined, 0],
662 'YER': [undefined, undefined, 0],
663 'ZAR': [undefined, 'R'],
664 'ZMK': [undefined, undefined, 0],
665 'ZMW': [undefined, 'ZK'],
666 'ZWD': [undefined, undefined, 0]
667};
668
669/**
670 * @license
671 * Copyright Google Inc. All Rights Reserved.
672 *
673 * Use of this source code is governed by an MIT-style license that can be
674 * found in the LICENSE file at https://angular.io/license
675 */
676/**
677 * Format styles that can be used to represent numbers.
678 * @see `getLocaleNumberFormat()`.
679 * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
680 *
681 * @publicApi
682 */
683var NumberFormatStyle;
684(function (NumberFormatStyle) {
685 NumberFormatStyle[NumberFormatStyle["Decimal"] = 0] = "Decimal";
686 NumberFormatStyle[NumberFormatStyle["Percent"] = 1] = "Percent";
687 NumberFormatStyle[NumberFormatStyle["Currency"] = 2] = "Currency";
688 NumberFormatStyle[NumberFormatStyle["Scientific"] = 3] = "Scientific";
689})(NumberFormatStyle || (NumberFormatStyle = {}));
690/**
691 * Plurality cases used for translating plurals to different languages.
692 *
693 * @see `NgPlural`
694 * @see `NgPluralCase`
695 * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
696 *
697 * @publicApi
698 */
699var Plural;
700(function (Plural) {
701 Plural[Plural["Zero"] = 0] = "Zero";
702 Plural[Plural["One"] = 1] = "One";
703 Plural[Plural["Two"] = 2] = "Two";
704 Plural[Plural["Few"] = 3] = "Few";
705 Plural[Plural["Many"] = 4] = "Many";
706 Plural[Plural["Other"] = 5] = "Other";
707})(Plural || (Plural = {}));
708/**
709 * Context-dependant translation forms for strings.
710 * Typically the standalone version is for the nominative form of the word,
711 * and the format version is used for the genitive case.
712 * @see [CLDR website](http://cldr.unicode.org/translation/date-time#TOC-Stand-Alone-vs.-Format-Styles)
713 * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
714 *
715 * @publicApi
716 */
717var FormStyle;
718(function (FormStyle) {
719 FormStyle[FormStyle["Format"] = 0] = "Format";
720 FormStyle[FormStyle["Standalone"] = 1] = "Standalone";
721})(FormStyle || (FormStyle = {}));
722/**
723 * String widths available for translations.
724 * The specific character widths are locale-specific.
725 * Examples are given for the word "Sunday" in English.
726 *
727 * @publicApi
728 */
729var TranslationWidth;
730(function (TranslationWidth) {
731 /** 1 character for `en-US`. For example: 'S' */
732 TranslationWidth[TranslationWidth["Narrow"] = 0] = "Narrow";
733 /** 3 characters for `en-US`. For example: 'Sun' */
734 TranslationWidth[TranslationWidth["Abbreviated"] = 1] = "Abbreviated";
735 /** Full length for `en-US`. For example: "Sunday" */
736 TranslationWidth[TranslationWidth["Wide"] = 2] = "Wide";
737 /** 2 characters for `en-US`, For example: "Su" */
738 TranslationWidth[TranslationWidth["Short"] = 3] = "Short";
739})(TranslationWidth || (TranslationWidth = {}));
740/**
741 * String widths available for date-time formats.
742 * The specific character widths are locale-specific.
743 * Examples are given for `en-US`.
744 *
745 * @see `getLocaleDateFormat()`
746 * @see `getLocaleTimeFormat()``
747 * @see `getLocaleDateTimeFormat()`
748 * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
749 * @publicApi
750 */
751var FormatWidth;
752(function (FormatWidth) {
753 /**
754 * For `en-US`, 'M/d/yy, h:mm a'`
755 * (Example: `6/15/15, 9:03 AM`)
756 */
757 FormatWidth[FormatWidth["Short"] = 0] = "Short";
758 /**
759 * For `en-US`, `'MMM d, y, h:mm:ss a'`
760 * (Example: `Jun 15, 2015, 9:03:01 AM`)
761 */
762 FormatWidth[FormatWidth["Medium"] = 1] = "Medium";
763 /**
764 * For `en-US`, `'MMMM d, y, h:mm:ss a z'`
765 * (Example: `June 15, 2015 at 9:03:01 AM GMT+1`)
766 */
767 FormatWidth[FormatWidth["Long"] = 2] = "Long";
768 /**
769 * For `en-US`, `'EEEE, MMMM d, y, h:mm:ss a zzzz'`
770 * (Example: `Monday, June 15, 2015 at 9:03:01 AM GMT+01:00`)
771 */
772 FormatWidth[FormatWidth["Full"] = 3] = "Full";
773})(FormatWidth || (FormatWidth = {}));
774/**
775 * Symbols that can be used to replace placeholders in number patterns.
776 * Examples are based on `en-US` values.
777 *
778 * @see `getLocaleNumberSymbol()`
779 * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
780 *
781 * @publicApi
782 */
783var NumberSymbol;
784(function (NumberSymbol) {
785 /**
786 * Decimal separator.
787 * For `en-US`, the dot character.
788 * Example : 2,345`.`67
789 */
790 NumberSymbol[NumberSymbol["Decimal"] = 0] = "Decimal";
791 /**
792 * Grouping separator, typically for thousands.
793 * For `en-US`, the comma character.
794 * Example: 2`,`345.67
795 */
796 NumberSymbol[NumberSymbol["Group"] = 1] = "Group";
797 /**
798 * List-item separator.
799 * Example: "one, two, and three"
800 */
801 NumberSymbol[NumberSymbol["List"] = 2] = "List";
802 /**
803 * Sign for percentage (out of 100).
804 * Example: 23.4%
805 */
806 NumberSymbol[NumberSymbol["PercentSign"] = 3] = "PercentSign";
807 /**
808 * Sign for positive numbers.
809 * Example: +23
810 */
811 NumberSymbol[NumberSymbol["PlusSign"] = 4] = "PlusSign";
812 /**
813 * Sign for negative numbers.
814 * Example: -23
815 */
816 NumberSymbol[NumberSymbol["MinusSign"] = 5] = "MinusSign";
817 /**
818 * Computer notation for exponential value (n times a power of 10).
819 * Example: 1.2E3
820 */
821 NumberSymbol[NumberSymbol["Exponential"] = 6] = "Exponential";
822 /**
823 * Human-readable format of exponential.
824 * Example: 1.2x103
825 */
826 NumberSymbol[NumberSymbol["SuperscriptingExponent"] = 7] = "SuperscriptingExponent";
827 /**
828 * Sign for permille (out of 1000).
829 * Example: 23.4‰
830 */
831 NumberSymbol[NumberSymbol["PerMille"] = 8] = "PerMille";
832 /**
833 * Infinity, can be used with plus and minus.
834 * Example: ∞, +∞, -∞
835 */
836 NumberSymbol[NumberSymbol["Infinity"] = 9] = "Infinity";
837 /**
838 * Not a number.
839 * Example: NaN
840 */
841 NumberSymbol[NumberSymbol["NaN"] = 10] = "NaN";
842 /**
843 * Symbol used between time units.
844 * Example: 10:52
845 */
846 NumberSymbol[NumberSymbol["TimeSeparator"] = 11] = "TimeSeparator";
847 /**
848 * Decimal separator for currency values (fallback to `Decimal`).
849 * Example: $2,345.67
850 */
851 NumberSymbol[NumberSymbol["CurrencyDecimal"] = 12] = "CurrencyDecimal";
852 /**
853 * Group separator for currency values (fallback to `Group`).
854 * Example: $2,345.67
855 */
856 NumberSymbol[NumberSymbol["CurrencyGroup"] = 13] = "CurrencyGroup";
857})(NumberSymbol || (NumberSymbol = {}));
858/**
859 * The value for each day of the week, based on the `en-US` locale
860 *
861 * @publicApi
862 */
863var WeekDay;
864(function (WeekDay) {
865 WeekDay[WeekDay["Sunday"] = 0] = "Sunday";
866 WeekDay[WeekDay["Monday"] = 1] = "Monday";
867 WeekDay[WeekDay["Tuesday"] = 2] = "Tuesday";
868 WeekDay[WeekDay["Wednesday"] = 3] = "Wednesday";
869 WeekDay[WeekDay["Thursday"] = 4] = "Thursday";
870 WeekDay[WeekDay["Friday"] = 5] = "Friday";
871 WeekDay[WeekDay["Saturday"] = 6] = "Saturday";
872})(WeekDay || (WeekDay = {}));
873/**
874 * Retrieves the locale ID from the currently loaded locale.
875 * The loaded locale could be, for example, a global one rather than a regional one.
876 * @param locale A locale code, such as `fr-FR`.
877 * @returns The locale code. For example, `fr`.
878 * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
879 *
880 * @publicApi
881 */
882function getLocaleId(locale) {
883 return ɵfindLocaleData(locale)[ɵLocaleDataIndex.LocaleId];
884}
885/**
886 * Retrieves day period strings for the given locale.
887 *
888 * @param locale A locale code for the locale format rules to use.
889 * @param formStyle The required grammatical form.
890 * @param width The required character width.
891 * @returns An array of localized period strings. For example, `[AM, PM]` for `en-US`.
892 * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
893 *
894 * @publicApi
895 */
896function getLocaleDayPeriods(locale, formStyle, width) {
897 var data = ɵfindLocaleData(locale);
898 var amPmData = [data[ɵLocaleDataIndex.DayPeriodsFormat], data[ɵLocaleDataIndex.DayPeriodsStandalone]];
899 var amPm = getLastDefinedValue(amPmData, formStyle);
900 return getLastDefinedValue(amPm, width);
901}
902/**
903 * Retrieves days of the week for the given locale, using the Gregorian calendar.
904 *
905 * @param locale A locale code for the locale format rules to use.
906 * @param formStyle The required grammatical form.
907 * @param width The required character width.
908 * @returns An array of localized name strings.
909 * For example,`[Sunday, Monday, ... Saturday]` for `en-US`.
910 * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
911 *
912 * @publicApi
913 */
914function getLocaleDayNames(locale, formStyle, width) {
915 var data = ɵfindLocaleData(locale);
916 var daysData = [data[ɵLocaleDataIndex.DaysFormat], data[ɵLocaleDataIndex.DaysStandalone]];
917 var days = getLastDefinedValue(daysData, formStyle);
918 return getLastDefinedValue(days, width);
919}
920/**
921 * Retrieves months of the year for the given locale, using the Gregorian calendar.
922 *
923 * @param locale A locale code for the locale format rules to use.
924 * @param formStyle The required grammatical form.
925 * @param width The required character width.
926 * @returns An array of localized name strings.
927 * For example, `[January, February, ...]` for `en-US`.
928 * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
929 *
930 * @publicApi
931 */
932function getLocaleMonthNames(locale, formStyle, width) {
933 var data = ɵfindLocaleData(locale);
934 var monthsData = [data[ɵLocaleDataIndex.MonthsFormat], data[ɵLocaleDataIndex.MonthsStandalone]];
935 var months = getLastDefinedValue(monthsData, formStyle);
936 return getLastDefinedValue(months, width);
937}
938/**
939 * Retrieves Gregorian-calendar eras for the given locale.
940 * @param locale A locale code for the locale format rules to use.
941 * @param formStyle The required grammatical form.
942 * @param width The required character width.
943
944 * @returns An array of localized era strings.
945 * For example, `[AD, BC]` for `en-US`.
946 * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
947 *
948 * @publicApi
949 */
950function getLocaleEraNames(locale, width) {
951 var data = ɵfindLocaleData(locale);
952 var erasData = data[ɵLocaleDataIndex.Eras];
953 return getLastDefinedValue(erasData, width);
954}
955/**
956 * Retrieves the first day of the week for the given locale.
957 *
958 * @param locale A locale code for the locale format rules to use.
959 * @returns A day index number, using the 0-based week-day index for `en-US`
960 * (Sunday = 0, Monday = 1, ...).
961 * For example, for `fr-FR`, returns 1 to indicate that the first day is Monday.
962 * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
963 *
964 * @publicApi
965 */
966function getLocaleFirstDayOfWeek(locale) {
967 var data = ɵfindLocaleData(locale);
968 return data[ɵLocaleDataIndex.FirstDayOfWeek];
969}
970/**
971 * Range of week days that are considered the week-end for the given locale.
972 *
973 * @param locale A locale code for the locale format rules to use.
974 * @returns The range of day values, `[startDay, endDay]`.
975 * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
976 *
977 * @publicApi
978 */
979function getLocaleWeekEndRange(locale) {
980 var data = ɵfindLocaleData(locale);
981 return data[ɵLocaleDataIndex.WeekendRange];
982}
983/**
984 * Retrieves a localized date-value formating string.
985 *
986 * @param locale A locale code for the locale format rules to use.
987 * @param width The format type.
988 * @returns The localized formating string.
989 * @see `FormatWidth`
990 * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
991 *
992 * @publicApi
993 */
994function getLocaleDateFormat(locale, width) {
995 var data = ɵfindLocaleData(locale);
996 return getLastDefinedValue(data[ɵLocaleDataIndex.DateFormat], width);
997}
998/**
999 * Retrieves a localized time-value formatting string.
1000 *
1001 * @param locale A locale code for the locale format rules to use.
1002 * @param width The format type.
1003 * @returns The localized formatting string.
1004 * @see `FormatWidth`
1005 * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
1006
1007 * @publicApi
1008 */
1009function getLocaleTimeFormat(locale, width) {
1010 var data = ɵfindLocaleData(locale);
1011 return getLastDefinedValue(data[ɵLocaleDataIndex.TimeFormat], width);
1012}
1013/**
1014 * Retrieves a localized date-time formatting string.
1015 *
1016 * @param locale A locale code for the locale format rules to use.
1017 * @param width The format type.
1018 * @returns The localized formatting string.
1019 * @see `FormatWidth`
1020 * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
1021 *
1022 * @publicApi
1023 */
1024function getLocaleDateTimeFormat(locale, width) {
1025 var data = ɵfindLocaleData(locale);
1026 var dateTimeFormatData = data[ɵLocaleDataIndex.DateTimeFormat];
1027 return getLastDefinedValue(dateTimeFormatData, width);
1028}
1029/**
1030 * Retrieves a localized number symbol that can be used to replace placeholders in number formats.
1031 * @param locale The locale code.
1032 * @param symbol The symbol to localize.
1033 * @returns The character for the localized symbol.
1034 * @see `NumberSymbol`
1035 * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
1036 *
1037 * @publicApi
1038 */
1039function getLocaleNumberSymbol(locale, symbol) {
1040 var data = ɵfindLocaleData(locale);
1041 var res = data[ɵLocaleDataIndex.NumberSymbols][symbol];
1042 if (typeof res === 'undefined') {
1043 if (symbol === NumberSymbol.CurrencyDecimal) {
1044 return data[ɵLocaleDataIndex.NumberSymbols][NumberSymbol.Decimal];
1045 }
1046 else if (symbol === NumberSymbol.CurrencyGroup) {
1047 return data[ɵLocaleDataIndex.NumberSymbols][NumberSymbol.Group];
1048 }
1049 }
1050 return res;
1051}
1052/**
1053 * Retrieves a number format for a given locale.
1054 *
1055 * Numbers are formatted using patterns, like `#,###.00`. For example, the pattern `#,###.00`
1056 * when used to format the number 12345.678 could result in "12'345,678". That would happen if the
1057 * grouping separator for your language is an apostrophe, and the decimal separator is a comma.
1058 *
1059 * <b>Important:</b> The characters `.` `,` `0` `#` (and others below) are special placeholders
1060 * that stand for the decimal separator, and so on, and are NOT real characters.
1061 * You must NOT "translate" the placeholders. For example, don't change `.` to `,` even though in
1062 * your language the decimal point is written with a comma. The symbols should be replaced by the
1063 * local equivalents, using the appropriate `NumberSymbol` for your language.
1064 *
1065 * Here are the special characters used in number patterns:
1066 *
1067 * | Symbol | Meaning |
1068 * |--------|---------|
1069 * | . | Replaced automatically by the character used for the decimal point. |
1070 * | , | Replaced by the "grouping" (thousands) separator. |
1071 * | 0 | Replaced by a digit (or zero if there aren't enough digits). |
1072 * | # | Replaced by a digit (or nothing if there aren't enough). |
1073 * | ¤ | Replaced by a currency symbol, such as $ or USD. |
1074 * | % | Marks a percent format. The % symbol may change position, but must be retained. |
1075 * | E | Marks a scientific format. The E symbol may change position, but must be retained. |
1076 * | ' | Special characters used as literal characters are quoted with ASCII single quotes. |
1077 *
1078 * @param locale A locale code for the locale format rules to use.
1079 * @param type The type of numeric value to be formatted (such as `Decimal` or `Currency`.)
1080 * @returns The localized format string.
1081 * @see `NumberFormatStyle`
1082 * @see [CLDR website](http://cldr.unicode.org/translation/number-patterns)
1083 * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
1084 *
1085 * @publicApi
1086 */
1087function getLocaleNumberFormat(locale, type) {
1088 var data = ɵfindLocaleData(locale);
1089 return data[ɵLocaleDataIndex.NumberFormats][type];
1090}
1091/**
1092 * Retrieves the symbol used to represent the currency for the main country
1093 * corresponding to a given locale. For example, '$' for `en-US`.
1094 *
1095 * @param locale A locale code for the locale format rules to use.
1096 * @returns The localized symbol character,
1097 * or `null` if the main country cannot be determined.
1098 * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
1099 *
1100 * @publicApi
1101 */
1102function getLocaleCurrencySymbol(locale) {
1103 var data = ɵfindLocaleData(locale);
1104 return data[ɵLocaleDataIndex.CurrencySymbol] || null;
1105}
1106/**
1107 * Retrieves the name of the currency for the main country corresponding
1108 * to a given locale. For example, 'US Dollar' for `en-US`.
1109 * @param locale A locale code for the locale format rules to use.
1110 * @returns The currency name,
1111 * or `null` if the main country cannot be determined.
1112 * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
1113 *
1114 * @publicApi
1115 */
1116function getLocaleCurrencyName(locale) {
1117 var data = ɵfindLocaleData(locale);
1118 return data[ɵLocaleDataIndex.CurrencyName] || null;
1119}
1120/**
1121 * Retrieves the currency values for a given locale.
1122 * @param locale A locale code for the locale format rules to use.
1123 * @returns The currency values.
1124 * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
1125 */
1126function getLocaleCurrencies(locale) {
1127 var data = ɵfindLocaleData(locale);
1128 return data[ɵLocaleDataIndex.Currencies];
1129}
1130/**
1131 * @alias core/ɵgetLocalePluralCase
1132 * @publicApi
1133 */
1134var getLocalePluralCase = ɵgetLocalePluralCase;
1135function checkFullData(data) {
1136 if (!data[ɵLocaleDataIndex.ExtraData]) {
1137 throw new Error("Missing extra locale data for the locale \"" + data[ɵLocaleDataIndex.LocaleId] + "\". Use \"registerLocaleData\" to load new data. See the \"I18n guide\" on angular.io to know more.");
1138 }
1139}
1140/**
1141 * Retrieves locale-specific rules used to determine which day period to use
1142 * when more than one period is defined for a locale.
1143 *
1144 * There is a rule for each defined day period. The
1145 * first rule is applied to the first day period and so on.
1146 * Fall back to AM/PM when no rules are available.
1147 *
1148 * A rule can specify a period as time range, or as a single time value.
1149 *
1150 * This functionality is only available when you have loaded the full locale data.
1151 * See the ["I18n guide"](guide/i18n#i18n-pipes).
1152 *
1153 * @param locale A locale code for the locale format rules to use.
1154 * @returns The rules for the locale, a single time value or array of *from-time, to-time*,
1155 * or null if no periods are available.
1156 *
1157 * @see `getLocaleExtraDayPeriods()`
1158 * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
1159 *
1160 * @publicApi
1161 */
1162function getLocaleExtraDayPeriodRules(locale) {
1163 var data = ɵfindLocaleData(locale);
1164 checkFullData(data);
1165 var rules = data[ɵLocaleDataIndex.ExtraData][2 /* ExtraDayPeriodsRules */] || [];
1166 return rules.map(function (rule) {
1167 if (typeof rule === 'string') {
1168 return extractTime(rule);
1169 }
1170 return [extractTime(rule[0]), extractTime(rule[1])];
1171 });
1172}
1173/**
1174 * Retrieves locale-specific day periods, which indicate roughly how a day is broken up
1175 * in different languages.
1176 * For example, for `en-US`, periods are morning, noon, afternoon, evening, and midnight.
1177 *
1178 * This functionality is only available when you have loaded the full locale data.
1179 * See the ["I18n guide"](guide/i18n#i18n-pipes).
1180 *
1181 * @param locale A locale code for the locale format rules to use.
1182 * @param formStyle The required grammatical form.
1183 * @param width The required character width.
1184 * @returns The translated day-period strings.
1185 * @see `getLocaleExtraDayPeriodRules()`
1186 * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
1187 *
1188 * @publicApi
1189 */
1190function getLocaleExtraDayPeriods(locale, formStyle, width) {
1191 var data = ɵfindLocaleData(locale);
1192 checkFullData(data);
1193 var dayPeriodsData = [
1194 data[ɵLocaleDataIndex.ExtraData][0 /* ExtraDayPeriodFormats */],
1195 data[ɵLocaleDataIndex.ExtraData][1 /* ExtraDayPeriodStandalone */]
1196 ];
1197 var dayPeriods = getLastDefinedValue(dayPeriodsData, formStyle) || [];
1198 return getLastDefinedValue(dayPeriods, width) || [];
1199}
1200/**
1201 * Retrieves the first value that is defined in an array, going backwards from an index position.
1202 *
1203 * To avoid repeating the same data (as when the "format" and "standalone" forms are the same)
1204 * add the first value to the locale data arrays, and add other values only if they are different.
1205 *
1206 * @param data The data array to retrieve from.
1207 * @param index A 0-based index into the array to start from.
1208 * @returns The value immediately before the given index position.
1209 * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
1210 *
1211 * @publicApi
1212 */
1213function getLastDefinedValue(data, index) {
1214 for (var i = index; i > -1; i--) {
1215 if (typeof data[i] !== 'undefined') {
1216 return data[i];
1217 }
1218 }
1219 throw new Error('Locale data API: locale data undefined');
1220}
1221/**
1222 * Extracts the hours and minutes from a string like "15:45"
1223 */
1224function extractTime(time) {
1225 var _a = __read(time.split(':'), 2), h = _a[0], m = _a[1];
1226 return { hours: +h, minutes: +m };
1227}
1228/**
1229 * Retrieves the currency symbol for a given currency code.
1230 *
1231 * For example, for the default `en-US` locale, the code `USD` can
1232 * be represented by the narrow symbol `$` or the wide symbol `US$`.
1233 *
1234 * @param code The currency code.
1235 * @param format The format, `wide` or `narrow`.
1236 * @param locale A locale code for the locale format rules to use.
1237 *
1238 * @returns The symbol, or the currency code if no symbol is available.0
1239 * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
1240 *
1241 * @publicApi
1242 */
1243function getCurrencySymbol(code, format, locale) {
1244 if (locale === void 0) { locale = 'en'; }
1245 var currency = getLocaleCurrencies(locale)[code] || CURRENCIES_EN[code] || [];
1246 var symbolNarrow = currency[1 /* SymbolNarrow */];
1247 if (format === 'narrow' && typeof symbolNarrow === 'string') {
1248 return symbolNarrow;
1249 }
1250 return currency[0 /* Symbol */] || code;
1251}
1252// Most currencies have cents, that's why the default is 2
1253var DEFAULT_NB_OF_CURRENCY_DIGITS = 2;
1254/**
1255 * Reports the number of decimal digits for a given currency.
1256 * The value depends upon the presence of cents in that particular currency.
1257 *
1258 * @param code The currency code.
1259 * @returns The number of decimal digits, typically 0 or 2.
1260 * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
1261 *
1262 * @publicApi
1263 */
1264function getNumberOfCurrencyDigits(code) {
1265 var digits;
1266 var currency = CURRENCIES_EN[code];
1267 if (currency) {
1268 digits = currency[2 /* NbOfDigits */];
1269 }
1270 return typeof digits === 'number' ? digits : DEFAULT_NB_OF_CURRENCY_DIGITS;
1271}
1272
1273/**
1274 * @license
1275 * Copyright Google Inc. All Rights Reserved.
1276 *
1277 * Use of this source code is governed by an MIT-style license that can be
1278 * found in the LICENSE file at https://angular.io/license
1279 */
1280var ISO8601_DATE_REGEX = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/;
1281// 1 2 3 4 5 6 7 8 9 10 11
1282var NAMED_FORMATS = {};
1283var DATE_FORMATS_SPLIT = /((?:[^GyMLwWdEabBhHmsSzZO']+)|(?:'(?:[^']|'')*')|(?:G{1,5}|y{1,4}|M{1,5}|L{1,5}|w{1,2}|W{1}|d{1,2}|E{1,6}|a{1,5}|b{1,5}|B{1,5}|h{1,2}|H{1,2}|m{1,2}|s{1,2}|S{1,3}|z{1,4}|Z{1,5}|O{1,4}))([\s\S]*)/;
1284var ZoneWidth;
1285(function (ZoneWidth) {
1286 ZoneWidth[ZoneWidth["Short"] = 0] = "Short";
1287 ZoneWidth[ZoneWidth["ShortGMT"] = 1] = "ShortGMT";
1288 ZoneWidth[ZoneWidth["Long"] = 2] = "Long";
1289 ZoneWidth[ZoneWidth["Extended"] = 3] = "Extended";
1290})(ZoneWidth || (ZoneWidth = {}));
1291var DateType;
1292(function (DateType) {
1293 DateType[DateType["FullYear"] = 0] = "FullYear";
1294 DateType[DateType["Month"] = 1] = "Month";
1295 DateType[DateType["Date"] = 2] = "Date";
1296 DateType[DateType["Hours"] = 3] = "Hours";
1297 DateType[DateType["Minutes"] = 4] = "Minutes";
1298 DateType[DateType["Seconds"] = 5] = "Seconds";
1299 DateType[DateType["FractionalSeconds"] = 6] = "FractionalSeconds";
1300 DateType[DateType["Day"] = 7] = "Day";
1301})(DateType || (DateType = {}));
1302var TranslationType;
1303(function (TranslationType) {
1304 TranslationType[TranslationType["DayPeriods"] = 0] = "DayPeriods";
1305 TranslationType[TranslationType["Days"] = 1] = "Days";
1306 TranslationType[TranslationType["Months"] = 2] = "Months";
1307 TranslationType[TranslationType["Eras"] = 3] = "Eras";
1308})(TranslationType || (TranslationType = {}));
1309/**
1310 * @ngModule CommonModule
1311 * @description
1312 *
1313 * Formats a date according to locale rules.
1314 *
1315 * @param value The date to format, as a Date, or a number (milliseconds since UTC epoch)
1316 * or an [ISO date-time string](https://www.w3.org/TR/NOTE-datetime).
1317 * @param format The date-time components to include. See `DatePipe` for details.
1318 * @param locale A locale code for the locale format rules to use.
1319 * @param timezone The time zone. A time zone offset from GMT (such as `'+0430'`),
1320 * or a standard UTC/GMT or continental US time zone abbreviation.
1321 * If not specified, uses host system settings.
1322 *
1323 * @returns The formatted date string.
1324 *
1325 * @see `DatePipe`
1326 * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
1327 *
1328 * @publicApi
1329 */
1330function formatDate(value, format, locale, timezone) {
1331 var date = toDate(value);
1332 var namedFormat = getNamedFormat(locale, format);
1333 format = namedFormat || format;
1334 var parts = [];
1335 var match;
1336 while (format) {
1337 match = DATE_FORMATS_SPLIT.exec(format);
1338 if (match) {
1339 parts = parts.concat(match.slice(1));
1340 var part = parts.pop();
1341 if (!part) {
1342 break;
1343 }
1344 format = part;
1345 }
1346 else {
1347 parts.push(format);
1348 break;
1349 }
1350 }
1351 var dateTimezoneOffset = date.getTimezoneOffset();
1352 if (timezone) {
1353 dateTimezoneOffset = timezoneToOffset(timezone, dateTimezoneOffset);
1354 date = convertTimezoneToLocal(date, timezone, true);
1355 }
1356 var text = '';
1357 parts.forEach(function (value) {
1358 var dateFormatter = getDateFormatter(value);
1359 text += dateFormatter ?
1360 dateFormatter(date, locale, dateTimezoneOffset) :
1361 value === '\'\'' ? '\'' : value.replace(/(^'|'$)/g, '').replace(/''/g, '\'');
1362 });
1363 return text;
1364}
1365function getNamedFormat(locale, format) {
1366 var localeId = getLocaleId(locale);
1367 NAMED_FORMATS[localeId] = NAMED_FORMATS[localeId] || {};
1368 if (NAMED_FORMATS[localeId][format]) {
1369 return NAMED_FORMATS[localeId][format];
1370 }
1371 var formatValue = '';
1372 switch (format) {
1373 case 'shortDate':
1374 formatValue = getLocaleDateFormat(locale, FormatWidth.Short);
1375 break;
1376 case 'mediumDate':
1377 formatValue = getLocaleDateFormat(locale, FormatWidth.Medium);
1378 break;
1379 case 'longDate':
1380 formatValue = getLocaleDateFormat(locale, FormatWidth.Long);
1381 break;
1382 case 'fullDate':
1383 formatValue = getLocaleDateFormat(locale, FormatWidth.Full);
1384 break;
1385 case 'shortTime':
1386 formatValue = getLocaleTimeFormat(locale, FormatWidth.Short);
1387 break;
1388 case 'mediumTime':
1389 formatValue = getLocaleTimeFormat(locale, FormatWidth.Medium);
1390 break;
1391 case 'longTime':
1392 formatValue = getLocaleTimeFormat(locale, FormatWidth.Long);
1393 break;
1394 case 'fullTime':
1395 formatValue = getLocaleTimeFormat(locale, FormatWidth.Full);
1396 break;
1397 case 'short':
1398 var shortTime = getNamedFormat(locale, 'shortTime');
1399 var shortDate = getNamedFormat(locale, 'shortDate');
1400 formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Short), [shortTime, shortDate]);
1401 break;
1402 case 'medium':
1403 var mediumTime = getNamedFormat(locale, 'mediumTime');
1404 var mediumDate = getNamedFormat(locale, 'mediumDate');
1405 formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Medium), [mediumTime, mediumDate]);
1406 break;
1407 case 'long':
1408 var longTime = getNamedFormat(locale, 'longTime');
1409 var longDate = getNamedFormat(locale, 'longDate');
1410 formatValue =
1411 formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Long), [longTime, longDate]);
1412 break;
1413 case 'full':
1414 var fullTime = getNamedFormat(locale, 'fullTime');
1415 var fullDate = getNamedFormat(locale, 'fullDate');
1416 formatValue =
1417 formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Full), [fullTime, fullDate]);
1418 break;
1419 }
1420 if (formatValue) {
1421 NAMED_FORMATS[localeId][format] = formatValue;
1422 }
1423 return formatValue;
1424}
1425function formatDateTime(str, opt_values) {
1426 if (opt_values) {
1427 str = str.replace(/\{([^}]+)}/g, function (match, key) {
1428 return (opt_values != null && key in opt_values) ? opt_values[key] : match;
1429 });
1430 }
1431 return str;
1432}
1433function padNumber(num, digits, minusSign, trim, negWrap) {
1434 if (minusSign === void 0) { minusSign = '-'; }
1435 var neg = '';
1436 if (num < 0 || (negWrap && num <= 0)) {
1437 if (negWrap) {
1438 num = -num + 1;
1439 }
1440 else {
1441 num = -num;
1442 neg = minusSign;
1443 }
1444 }
1445 var strNum = String(num);
1446 while (strNum.length < digits) {
1447 strNum = '0' + strNum;
1448 }
1449 if (trim) {
1450 strNum = strNum.substr(strNum.length - digits);
1451 }
1452 return neg + strNum;
1453}
1454function formatFractionalSeconds(milliseconds, digits) {
1455 var strMs = padNumber(milliseconds, 3);
1456 return strMs.substr(0, digits);
1457}
1458/**
1459 * Returns a date formatter that transforms a date into its locale digit representation
1460 */
1461function dateGetter(name, size, offset, trim, negWrap) {
1462 if (offset === void 0) { offset = 0; }
1463 if (trim === void 0) { trim = false; }
1464 if (negWrap === void 0) { negWrap = false; }
1465 return function (date, locale) {
1466 var part = getDatePart(name, date);
1467 if (offset > 0 || part > -offset) {
1468 part += offset;
1469 }
1470 if (name === DateType.Hours) {
1471 if (part === 0 && offset === -12) {
1472 part = 12;
1473 }
1474 }
1475 else if (name === DateType.FractionalSeconds) {
1476 return formatFractionalSeconds(part, size);
1477 }
1478 var localeMinus = getLocaleNumberSymbol(locale, NumberSymbol.MinusSign);
1479 return padNumber(part, size, localeMinus, trim, negWrap);
1480 };
1481}
1482function getDatePart(part, date) {
1483 switch (part) {
1484 case DateType.FullYear:
1485 return date.getFullYear();
1486 case DateType.Month:
1487 return date.getMonth();
1488 case DateType.Date:
1489 return date.getDate();
1490 case DateType.Hours:
1491 return date.getHours();
1492 case DateType.Minutes:
1493 return date.getMinutes();
1494 case DateType.Seconds:
1495 return date.getSeconds();
1496 case DateType.FractionalSeconds:
1497 return date.getMilliseconds();
1498 case DateType.Day:
1499 return date.getDay();
1500 default:
1501 throw new Error("Unknown DateType value \"" + part + "\".");
1502 }
1503}
1504/**
1505 * Returns a date formatter that transforms a date into its locale string representation
1506 */
1507function dateStrGetter(name, width, form, extended) {
1508 if (form === void 0) { form = FormStyle.Format; }
1509 if (extended === void 0) { extended = false; }
1510 return function (date, locale) {
1511 return getDateTranslation(date, locale, name, width, form, extended);
1512 };
1513}
1514/**
1515 * Returns the locale translation of a date for a given form, type and width
1516 */
1517function getDateTranslation(date, locale, name, width, form, extended) {
1518 switch (name) {
1519 case TranslationType.Months:
1520 return getLocaleMonthNames(locale, form, width)[date.getMonth()];
1521 case TranslationType.Days:
1522 return getLocaleDayNames(locale, form, width)[date.getDay()];
1523 case TranslationType.DayPeriods:
1524 var currentHours_1 = date.getHours();
1525 var currentMinutes_1 = date.getMinutes();
1526 if (extended) {
1527 var rules = getLocaleExtraDayPeriodRules(locale);
1528 var dayPeriods_1 = getLocaleExtraDayPeriods(locale, form, width);
1529 var result_1;
1530 rules.forEach(function (rule, index) {
1531 if (Array.isArray(rule)) {
1532 // morning, afternoon, evening, night
1533 var _a = rule[0], hoursFrom = _a.hours, minutesFrom = _a.minutes;
1534 var _b = rule[1], hoursTo = _b.hours, minutesTo = _b.minutes;
1535 if (currentHours_1 >= hoursFrom && currentMinutes_1 >= minutesFrom &&
1536 (currentHours_1 < hoursTo ||
1537 (currentHours_1 === hoursTo && currentMinutes_1 < minutesTo))) {
1538 result_1 = dayPeriods_1[index];
1539 }
1540 }
1541 else { // noon or midnight
1542 var hours = rule.hours, minutes = rule.minutes;
1543 if (hours === currentHours_1 && minutes === currentMinutes_1) {
1544 result_1 = dayPeriods_1[index];
1545 }
1546 }
1547 });
1548 if (result_1) {
1549 return result_1;
1550 }
1551 }
1552 // if no rules for the day periods, we use am/pm by default
1553 return getLocaleDayPeriods(locale, form, width)[currentHours_1 < 12 ? 0 : 1];
1554 case TranslationType.Eras:
1555 return getLocaleEraNames(locale, width)[date.getFullYear() <= 0 ? 0 : 1];
1556 default:
1557 // This default case is not needed by TypeScript compiler, as the switch is exhaustive.
1558 // However Closure Compiler does not understand that and reports an error in typed mode.
1559 // The `throw new Error` below works around the problem, and the unexpected: never variable
1560 // makes sure tsc still checks this code is unreachable.
1561 var unexpected = name;
1562 throw new Error("unexpected translation type " + unexpected);
1563 }
1564}
1565/**
1566 * Returns a date formatter that transforms a date and an offset into a timezone with ISO8601 or
1567 * GMT format depending on the width (eg: short = +0430, short:GMT = GMT+4, long = GMT+04:30,
1568 * extended = +04:30)
1569 */
1570function timeZoneGetter(width) {
1571 return function (date, locale, offset) {
1572 var zone = -1 * offset;
1573 var minusSign = getLocaleNumberSymbol(locale, NumberSymbol.MinusSign);
1574 var hours = zone > 0 ? Math.floor(zone / 60) : Math.ceil(zone / 60);
1575 switch (width) {
1576 case ZoneWidth.Short:
1577 return ((zone >= 0) ? '+' : '') + padNumber(hours, 2, minusSign) +
1578 padNumber(Math.abs(zone % 60), 2, minusSign);
1579 case ZoneWidth.ShortGMT:
1580 return 'GMT' + ((zone >= 0) ? '+' : '') + padNumber(hours, 1, minusSign);
1581 case ZoneWidth.Long:
1582 return 'GMT' + ((zone >= 0) ? '+' : '') + padNumber(hours, 2, minusSign) + ':' +
1583 padNumber(Math.abs(zone % 60), 2, minusSign);
1584 case ZoneWidth.Extended:
1585 if (offset === 0) {
1586 return 'Z';
1587 }
1588 else {
1589 return ((zone >= 0) ? '+' : '') + padNumber(hours, 2, minusSign) + ':' +
1590 padNumber(Math.abs(zone % 60), 2, minusSign);
1591 }
1592 default:
1593 throw new Error("Unknown zone width \"" + width + "\"");
1594 }
1595 };
1596}
1597var JANUARY = 0;
1598var THURSDAY = 4;
1599function getFirstThursdayOfYear(year) {
1600 var firstDayOfYear = (new Date(year, JANUARY, 1)).getDay();
1601 return new Date(year, 0, 1 + ((firstDayOfYear <= THURSDAY) ? THURSDAY : THURSDAY + 7) - firstDayOfYear);
1602}
1603function getThursdayThisWeek(datetime) {
1604 return new Date(datetime.getFullYear(), datetime.getMonth(), datetime.getDate() + (THURSDAY - datetime.getDay()));
1605}
1606function weekGetter(size, monthBased) {
1607 if (monthBased === void 0) { monthBased = false; }
1608 return function (date, locale) {
1609 var result;
1610 if (monthBased) {
1611 var nbDaysBefore1stDayOfMonth = new Date(date.getFullYear(), date.getMonth(), 1).getDay() - 1;
1612 var today = date.getDate();
1613 result = 1 + Math.floor((today + nbDaysBefore1stDayOfMonth) / 7);
1614 }
1615 else {
1616 var firstThurs = getFirstThursdayOfYear(date.getFullYear());
1617 var thisThurs = getThursdayThisWeek(date);
1618 var diff = thisThurs.getTime() - firstThurs.getTime();
1619 result = 1 + Math.round(diff / 6.048e8); // 6.048e8 ms per week
1620 }
1621 return padNumber(result, size, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign));
1622 };
1623}
1624var DATE_FORMATS = {};
1625// Based on CLDR formats:
1626// See complete list: http://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
1627// See also explanations: http://cldr.unicode.org/translation/date-time
1628// TODO(ocombe): support all missing cldr formats: Y, U, Q, D, F, e, c, j, J, C, A, v, V, X, x
1629function getDateFormatter(format) {
1630 if (DATE_FORMATS[format]) {
1631 return DATE_FORMATS[format];
1632 }
1633 var formatter;
1634 switch (format) {
1635 // Era name (AD/BC)
1636 case 'G':
1637 case 'GG':
1638 case 'GGG':
1639 formatter = dateStrGetter(TranslationType.Eras, TranslationWidth.Abbreviated);
1640 break;
1641 case 'GGGG':
1642 formatter = dateStrGetter(TranslationType.Eras, TranslationWidth.Wide);
1643 break;
1644 case 'GGGGG':
1645 formatter = dateStrGetter(TranslationType.Eras, TranslationWidth.Narrow);
1646 break;
1647 // 1 digit representation of the year, e.g. (AD 1 => 1, AD 199 => 199)
1648 case 'y':
1649 formatter = dateGetter(DateType.FullYear, 1, 0, false, true);
1650 break;
1651 // 2 digit representation of the year, padded (00-99). (e.g. AD 2001 => 01, AD 2010 => 10)
1652 case 'yy':
1653 formatter = dateGetter(DateType.FullYear, 2, 0, true, true);
1654 break;
1655 // 3 digit representation of the year, padded (000-999). (e.g. AD 2001 => 01, AD 2010 => 10)
1656 case 'yyy':
1657 formatter = dateGetter(DateType.FullYear, 3, 0, false, true);
1658 break;
1659 // 4 digit representation of the year (e.g. AD 1 => 0001, AD 2010 => 2010)
1660 case 'yyyy':
1661 formatter = dateGetter(DateType.FullYear, 4, 0, false, true);
1662 break;
1663 // Month of the year (1-12), numeric
1664 case 'M':
1665 case 'L':
1666 formatter = dateGetter(DateType.Month, 1, 1);
1667 break;
1668 case 'MM':
1669 case 'LL':
1670 formatter = dateGetter(DateType.Month, 2, 1);
1671 break;
1672 // Month of the year (January, ...), string, format
1673 case 'MMM':
1674 formatter = dateStrGetter(TranslationType.Months, TranslationWidth.Abbreviated);
1675 break;
1676 case 'MMMM':
1677 formatter = dateStrGetter(TranslationType.Months, TranslationWidth.Wide);
1678 break;
1679 case 'MMMMM':
1680 formatter = dateStrGetter(TranslationType.Months, TranslationWidth.Narrow);
1681 break;
1682 // Month of the year (January, ...), string, standalone
1683 case 'LLL':
1684 formatter =
1685 dateStrGetter(TranslationType.Months, TranslationWidth.Abbreviated, FormStyle.Standalone);
1686 break;
1687 case 'LLLL':
1688 formatter =
1689 dateStrGetter(TranslationType.Months, TranslationWidth.Wide, FormStyle.Standalone);
1690 break;
1691 case 'LLLLL':
1692 formatter =
1693 dateStrGetter(TranslationType.Months, TranslationWidth.Narrow, FormStyle.Standalone);
1694 break;
1695 // Week of the year (1, ... 52)
1696 case 'w':
1697 formatter = weekGetter(1);
1698 break;
1699 case 'ww':
1700 formatter = weekGetter(2);
1701 break;
1702 // Week of the month (1, ...)
1703 case 'W':
1704 formatter = weekGetter(1, true);
1705 break;
1706 // Day of the month (1-31)
1707 case 'd':
1708 formatter = dateGetter(DateType.Date, 1);
1709 break;
1710 case 'dd':
1711 formatter = dateGetter(DateType.Date, 2);
1712 break;
1713 // Day of the Week
1714 case 'E':
1715 case 'EE':
1716 case 'EEE':
1717 formatter = dateStrGetter(TranslationType.Days, TranslationWidth.Abbreviated);
1718 break;
1719 case 'EEEE':
1720 formatter = dateStrGetter(TranslationType.Days, TranslationWidth.Wide);
1721 break;
1722 case 'EEEEE':
1723 formatter = dateStrGetter(TranslationType.Days, TranslationWidth.Narrow);
1724 break;
1725 case 'EEEEEE':
1726 formatter = dateStrGetter(TranslationType.Days, TranslationWidth.Short);
1727 break;
1728 // Generic period of the day (am-pm)
1729 case 'a':
1730 case 'aa':
1731 case 'aaa':
1732 formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Abbreviated);
1733 break;
1734 case 'aaaa':
1735 formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Wide);
1736 break;
1737 case 'aaaaa':
1738 formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Narrow);
1739 break;
1740 // Extended period of the day (midnight, at night, ...), standalone
1741 case 'b':
1742 case 'bb':
1743 case 'bbb':
1744 formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Abbreviated, FormStyle.Standalone, true);
1745 break;
1746 case 'bbbb':
1747 formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Wide, FormStyle.Standalone, true);
1748 break;
1749 case 'bbbbb':
1750 formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Narrow, FormStyle.Standalone, true);
1751 break;
1752 // Extended period of the day (midnight, night, ...), standalone
1753 case 'B':
1754 case 'BB':
1755 case 'BBB':
1756 formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Abbreviated, FormStyle.Format, true);
1757 break;
1758 case 'BBBB':
1759 formatter =
1760 dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Wide, FormStyle.Format, true);
1761 break;
1762 case 'BBBBB':
1763 formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Narrow, FormStyle.Format, true);
1764 break;
1765 // Hour in AM/PM, (1-12)
1766 case 'h':
1767 formatter = dateGetter(DateType.Hours, 1, -12);
1768 break;
1769 case 'hh':
1770 formatter = dateGetter(DateType.Hours, 2, -12);
1771 break;
1772 // Hour of the day (0-23)
1773 case 'H':
1774 formatter = dateGetter(DateType.Hours, 1);
1775 break;
1776 // Hour in day, padded (00-23)
1777 case 'HH':
1778 formatter = dateGetter(DateType.Hours, 2);
1779 break;
1780 // Minute of the hour (0-59)
1781 case 'm':
1782 formatter = dateGetter(DateType.Minutes, 1);
1783 break;
1784 case 'mm':
1785 formatter = dateGetter(DateType.Minutes, 2);
1786 break;
1787 // Second of the minute (0-59)
1788 case 's':
1789 formatter = dateGetter(DateType.Seconds, 1);
1790 break;
1791 case 'ss':
1792 formatter = dateGetter(DateType.Seconds, 2);
1793 break;
1794 // Fractional second
1795 case 'S':
1796 formatter = dateGetter(DateType.FractionalSeconds, 1);
1797 break;
1798 case 'SS':
1799 formatter = dateGetter(DateType.FractionalSeconds, 2);
1800 break;
1801 case 'SSS':
1802 formatter = dateGetter(DateType.FractionalSeconds, 3);
1803 break;
1804 // Timezone ISO8601 short format (-0430)
1805 case 'Z':
1806 case 'ZZ':
1807 case 'ZZZ':
1808 formatter = timeZoneGetter(ZoneWidth.Short);
1809 break;
1810 // Timezone ISO8601 extended format (-04:30)
1811 case 'ZZZZZ':
1812 formatter = timeZoneGetter(ZoneWidth.Extended);
1813 break;
1814 // Timezone GMT short format (GMT+4)
1815 case 'O':
1816 case 'OO':
1817 case 'OOO':
1818 // Should be location, but fallback to format O instead because we don't have the data yet
1819 case 'z':
1820 case 'zz':
1821 case 'zzz':
1822 formatter = timeZoneGetter(ZoneWidth.ShortGMT);
1823 break;
1824 // Timezone GMT long format (GMT+0430)
1825 case 'OOOO':
1826 case 'ZZZZ':
1827 // Should be location, but fallback to format O instead because we don't have the data yet
1828 case 'zzzz':
1829 formatter = timeZoneGetter(ZoneWidth.Long);
1830 break;
1831 default:
1832 return null;
1833 }
1834 DATE_FORMATS[format] = formatter;
1835 return formatter;
1836}
1837function timezoneToOffset(timezone, fallback) {
1838 // Support: IE 9-11 only, Edge 13-15+
1839 // IE/Edge do not "understand" colon (`:`) in timezone
1840 timezone = timezone.replace(/:/g, '');
1841 var requestedTimezoneOffset = Date.parse('Jan 01, 1970 00:00:00 ' + timezone) / 60000;
1842 return isNaN(requestedTimezoneOffset) ? fallback : requestedTimezoneOffset;
1843}
1844function addDateMinutes(date, minutes) {
1845 date = new Date(date.getTime());
1846 date.setMinutes(date.getMinutes() + minutes);
1847 return date;
1848}
1849function convertTimezoneToLocal(date, timezone, reverse) {
1850 var reverseValue = reverse ? -1 : 1;
1851 var dateTimezoneOffset = date.getTimezoneOffset();
1852 var timezoneOffset = timezoneToOffset(timezone, dateTimezoneOffset);
1853 return addDateMinutes(date, reverseValue * (timezoneOffset - dateTimezoneOffset));
1854}
1855/**
1856 * Converts a value to date.
1857 *
1858 * Supported input formats:
1859 * - `Date`
1860 * - number: timestamp
1861 * - string: numeric (e.g. "1234"), ISO and date strings in a format supported by
1862 * [Date.parse()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse).
1863 * Note: ISO strings without time return a date without timeoffset.
1864 *
1865 * Throws if unable to convert to a date.
1866 */
1867function toDate(value) {
1868 if (isDate(value)) {
1869 return value;
1870 }
1871 if (typeof value === 'number' && !isNaN(value)) {
1872 return new Date(value);
1873 }
1874 if (typeof value === 'string') {
1875 value = value.trim();
1876 var parsedNb = parseFloat(value);
1877 // any string that only contains numbers, like "1234" but not like "1234hello"
1878 if (!isNaN(value - parsedNb)) {
1879 return new Date(parsedNb);
1880 }
1881 if (/^(\d{4}-\d{1,2}-\d{1,2})$/.test(value)) {
1882 /* For ISO Strings without time the day, month and year must be extracted from the ISO String
1883 before Date creation to avoid time offset and errors in the new Date.
1884 If we only replace '-' with ',' in the ISO String ("2015,01,01"), and try to create a new
1885 date, some browsers (e.g. IE 9) will throw an invalid Date error.
1886 If we leave the '-' ("2015-01-01") and try to create a new Date("2015-01-01") the timeoffset
1887 is applied.
1888 Note: ISO months are 0 for January, 1 for February, ... */
1889 var _a = __read(value.split('-').map(function (val) { return +val; }), 3), y = _a[0], m = _a[1], d = _a[2];
1890 return new Date(y, m - 1, d);
1891 }
1892 var match = void 0;
1893 if (match = value.match(ISO8601_DATE_REGEX)) {
1894 return isoStringToDate(match);
1895 }
1896 }
1897 var date = new Date(value);
1898 if (!isDate(date)) {
1899 throw new Error("Unable to convert \"" + value + "\" into a date");
1900 }
1901 return date;
1902}
1903/**
1904 * Converts a date in ISO8601 to a Date.
1905 * Used instead of `Date.parse` because of browser discrepancies.
1906 */
1907function isoStringToDate(match) {
1908 var date = new Date(0);
1909 var tzHour = 0;
1910 var tzMin = 0;
1911 // match[8] means that the string contains "Z" (UTC) or a timezone like "+01:00" or "+0100"
1912 var dateSetter = match[8] ? date.setUTCFullYear : date.setFullYear;
1913 var timeSetter = match[8] ? date.setUTCHours : date.setHours;
1914 // if there is a timezone defined like "+01:00" or "+0100"
1915 if (match[9]) {
1916 tzHour = Number(match[9] + match[10]);
1917 tzMin = Number(match[9] + match[11]);
1918 }
1919 dateSetter.call(date, Number(match[1]), Number(match[2]) - 1, Number(match[3]));
1920 var h = Number(match[4] || 0) - tzHour;
1921 var m = Number(match[5] || 0) - tzMin;
1922 var s = Number(match[6] || 0);
1923 var ms = Math.round(parseFloat('0.' + (match[7] || 0)) * 1000);
1924 timeSetter.call(date, h, m, s, ms);
1925 return date;
1926}
1927function isDate(value) {
1928 return value instanceof Date && !isNaN(value.valueOf());
1929}
1930
1931/**
1932 * @license
1933 * Copyright Google Inc. All Rights Reserved.
1934 *
1935 * Use of this source code is governed by an MIT-style license that can be
1936 * found in the LICENSE file at https://angular.io/license
1937 */
1938var NUMBER_FORMAT_REGEXP = /^(\d+)?\.((\d+)(-(\d+))?)?$/;
1939var MAX_DIGITS = 22;
1940var DECIMAL_SEP = '.';
1941var ZERO_CHAR = '0';
1942var PATTERN_SEP = ';';
1943var GROUP_SEP = ',';
1944var DIGIT_CHAR = '#';
1945var CURRENCY_CHAR = '¤';
1946var PERCENT_CHAR = '%';
1947/**
1948 * Transforms a number to a locale string based on a style and a format.
1949 */
1950function formatNumberToLocaleString(value, pattern, locale, groupSymbol, decimalSymbol, digitsInfo, isPercent) {
1951 if (isPercent === void 0) { isPercent = false; }
1952 var formattedText = '';
1953 var isZero = false;
1954 if (!isFinite(value)) {
1955 formattedText = getLocaleNumberSymbol(locale, NumberSymbol.Infinity);
1956 }
1957 else {
1958 var parsedNumber = parseNumber(value);
1959 if (isPercent) {
1960 parsedNumber = toPercent(parsedNumber);
1961 }
1962 var minInt = pattern.minInt;
1963 var minFraction = pattern.minFrac;
1964 var maxFraction = pattern.maxFrac;
1965 if (digitsInfo) {
1966 var parts = digitsInfo.match(NUMBER_FORMAT_REGEXP);
1967 if (parts === null) {
1968 throw new Error(digitsInfo + " is not a valid digit info");
1969 }
1970 var minIntPart = parts[1];
1971 var minFractionPart = parts[3];
1972 var maxFractionPart = parts[5];
1973 if (minIntPart != null) {
1974 minInt = parseIntAutoRadix(minIntPart);
1975 }
1976 if (minFractionPart != null) {
1977 minFraction = parseIntAutoRadix(minFractionPart);
1978 }
1979 if (maxFractionPart != null) {
1980 maxFraction = parseIntAutoRadix(maxFractionPart);
1981 }
1982 else if (minFractionPart != null && minFraction > maxFraction) {
1983 maxFraction = minFraction;
1984 }
1985 }
1986 roundNumber(parsedNumber, minFraction, maxFraction);
1987 var digits = parsedNumber.digits;
1988 var integerLen = parsedNumber.integerLen;
1989 var exponent = parsedNumber.exponent;
1990 var decimals = [];
1991 isZero = digits.every(function (d) { return !d; });
1992 // pad zeros for small numbers
1993 for (; integerLen < minInt; integerLen++) {
1994 digits.unshift(0);
1995 }
1996 // pad zeros for small numbers
1997 for (; integerLen < 0; integerLen++) {
1998 digits.unshift(0);
1999 }
2000 // extract decimals digits
2001 if (integerLen > 0) {
2002 decimals = digits.splice(integerLen, digits.length);
2003 }
2004 else {
2005 decimals = digits;
2006 digits = [0];
2007 }
2008 // format the integer digits with grouping separators
2009 var groups = [];
2010 if (digits.length >= pattern.lgSize) {
2011 groups.unshift(digits.splice(-pattern.lgSize, digits.length).join(''));
2012 }
2013 while (digits.length > pattern.gSize) {
2014 groups.unshift(digits.splice(-pattern.gSize, digits.length).join(''));
2015 }
2016 if (digits.length) {
2017 groups.unshift(digits.join(''));
2018 }
2019 formattedText = groups.join(getLocaleNumberSymbol(locale, groupSymbol));
2020 // append the decimal digits
2021 if (decimals.length) {
2022 formattedText += getLocaleNumberSymbol(locale, decimalSymbol) + decimals.join('');
2023 }
2024 if (exponent) {
2025 formattedText += getLocaleNumberSymbol(locale, NumberSymbol.Exponential) + '+' + exponent;
2026 }
2027 }
2028 if (value < 0 && !isZero) {
2029 formattedText = pattern.negPre + formattedText + pattern.negSuf;
2030 }
2031 else {
2032 formattedText = pattern.posPre + formattedText + pattern.posSuf;
2033 }
2034 return formattedText;
2035}
2036/**
2037 * @ngModule CommonModule
2038 * @description
2039 *
2040 * Formats a number as currency using locale rules.
2041 *
2042 * @param value The number to format.
2043 * @param locale A locale code for the locale format rules to use.
2044 * @param currency A string containing the currency symbol or its name,
2045 * such as "$" or "Canadian Dollar". Used in output string, but does not affect the operation
2046 * of the function.
2047 * @param currencyCode The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217)
2048 * currency code to use in the result string, such as `USD` for the US dollar and `EUR` for the euro.
2049 * @param digitInfo Decimal representation options, specified by a string in the following format:
2050 * `{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}`. See `DecimalPipe` for more details.
2051 *
2052 * @returns The formatted currency value.
2053 *
2054 * @see `formatNumber()`
2055 * @see `DecimalPipe`
2056 * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
2057 *
2058 * @publicApi
2059 */
2060function formatCurrency(value, locale, currency, currencyCode, digitsInfo) {
2061 var format = getLocaleNumberFormat(locale, NumberFormatStyle.Currency);
2062 var pattern = parseNumberFormat(format, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign));
2063 pattern.minFrac = getNumberOfCurrencyDigits(currencyCode);
2064 pattern.maxFrac = pattern.minFrac;
2065 var res = formatNumberToLocaleString(value, pattern, locale, NumberSymbol.CurrencyGroup, NumberSymbol.CurrencyDecimal, digitsInfo);
2066 return res
2067 .replace(CURRENCY_CHAR, currency)
2068 // if we have 2 time the currency character, the second one is ignored
2069 .replace(CURRENCY_CHAR, '');
2070}
2071/**
2072 * @ngModule CommonModule
2073 * @description
2074 *
2075 * Formats a number as a percentage according to locale rules.
2076 *
2077 * @param value The number to format.
2078 * @param locale A locale code for the locale format rules to use.
2079 * @param digitInfo Decimal representation options, specified by a string in the following format:
2080 * `{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}`. See `DecimalPipe` for more details.
2081 *
2082 * @returns The formatted percentage value.
2083 *
2084 * @see `formatNumber()`
2085 * @see `DecimalPipe`
2086 * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
2087 * @publicApi
2088 *
2089 */
2090function formatPercent(value, locale, digitsInfo) {
2091 var format = getLocaleNumberFormat(locale, NumberFormatStyle.Percent);
2092 var pattern = parseNumberFormat(format, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign));
2093 var res = formatNumberToLocaleString(value, pattern, locale, NumberSymbol.Group, NumberSymbol.Decimal, digitsInfo, true);
2094 return res.replace(new RegExp(PERCENT_CHAR, 'g'), getLocaleNumberSymbol(locale, NumberSymbol.PercentSign));
2095}
2096/**
2097 * @ngModule CommonModule
2098 * @description
2099 *
2100 * Formats a number as text, with group sizing, separator, and other
2101 * parameters based on the locale.
2102 *
2103 * @param value The number to format.
2104 * @param locale A locale code for the locale format rules to use.
2105 * @param digitInfo Decimal representation options, specified by a string in the following format:
2106 * `{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}`. See `DecimalPipe` for more details.
2107 *
2108 * @returns The formatted text string.
2109 * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
2110 *
2111 * @publicApi
2112 */
2113function formatNumber(value, locale, digitsInfo) {
2114 var format = getLocaleNumberFormat(locale, NumberFormatStyle.Decimal);
2115 var pattern = parseNumberFormat(format, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign));
2116 return formatNumberToLocaleString(value, pattern, locale, NumberSymbol.Group, NumberSymbol.Decimal, digitsInfo);
2117}
2118function parseNumberFormat(format, minusSign) {
2119 if (minusSign === void 0) { minusSign = '-'; }
2120 var p = {
2121 minInt: 1,
2122 minFrac: 0,
2123 maxFrac: 0,
2124 posPre: '',
2125 posSuf: '',
2126 negPre: '',
2127 negSuf: '',
2128 gSize: 0,
2129 lgSize: 0
2130 };
2131 var patternParts = format.split(PATTERN_SEP);
2132 var positive = patternParts[0];
2133 var negative = patternParts[1];
2134 var positiveParts = positive.indexOf(DECIMAL_SEP) !== -1 ?
2135 positive.split(DECIMAL_SEP) :
2136 [
2137 positive.substring(0, positive.lastIndexOf(ZERO_CHAR) + 1),
2138 positive.substring(positive.lastIndexOf(ZERO_CHAR) + 1)
2139 ], integer = positiveParts[0], fraction = positiveParts[1] || '';
2140 p.posPre = integer.substr(0, integer.indexOf(DIGIT_CHAR));
2141 for (var i = 0; i < fraction.length; i++) {
2142 var ch = fraction.charAt(i);
2143 if (ch === ZERO_CHAR) {
2144 p.minFrac = p.maxFrac = i + 1;
2145 }
2146 else if (ch === DIGIT_CHAR) {
2147 p.maxFrac = i + 1;
2148 }
2149 else {
2150 p.posSuf += ch;
2151 }
2152 }
2153 var groups = integer.split(GROUP_SEP);
2154 p.gSize = groups[1] ? groups[1].length : 0;
2155 p.lgSize = (groups[2] || groups[1]) ? (groups[2] || groups[1]).length : 0;
2156 if (negative) {
2157 var trunkLen = positive.length - p.posPre.length - p.posSuf.length, pos = negative.indexOf(DIGIT_CHAR);
2158 p.negPre = negative.substr(0, pos).replace(/'/g, '');
2159 p.negSuf = negative.substr(pos + trunkLen).replace(/'/g, '');
2160 }
2161 else {
2162 p.negPre = minusSign + p.posPre;
2163 p.negSuf = p.posSuf;
2164 }
2165 return p;
2166}
2167// Transforms a parsed number into a percentage by multiplying it by 100
2168function toPercent(parsedNumber) {
2169 // if the number is 0, don't do anything
2170 if (parsedNumber.digits[0] === 0) {
2171 return parsedNumber;
2172 }
2173 // Getting the current number of decimals
2174 var fractionLen = parsedNumber.digits.length - parsedNumber.integerLen;
2175 if (parsedNumber.exponent) {
2176 parsedNumber.exponent += 2;
2177 }
2178 else {
2179 if (fractionLen === 0) {
2180 parsedNumber.digits.push(0, 0);
2181 }
2182 else if (fractionLen === 1) {
2183 parsedNumber.digits.push(0);
2184 }
2185 parsedNumber.integerLen += 2;
2186 }
2187 return parsedNumber;
2188}
2189/**
2190 * Parses a number.
2191 * Significant bits of this parse algorithm came from https://github.com/MikeMcl/big.js/
2192 */
2193function parseNumber(num) {
2194 var numStr = Math.abs(num) + '';
2195 var exponent = 0, digits, integerLen;
2196 var i, j, zeros;
2197 // Decimal point?
2198 if ((integerLen = numStr.indexOf(DECIMAL_SEP)) > -1) {
2199 numStr = numStr.replace(DECIMAL_SEP, '');
2200 }
2201 // Exponential form?
2202 if ((i = numStr.search(/e/i)) > 0) {
2203 // Work out the exponent.
2204 if (integerLen < 0)
2205 integerLen = i;
2206 integerLen += +numStr.slice(i + 1);
2207 numStr = numStr.substring(0, i);
2208 }
2209 else if (integerLen < 0) {
2210 // There was no decimal point or exponent so it is an integer.
2211 integerLen = numStr.length;
2212 }
2213 // Count the number of leading zeros.
2214 for (i = 0; numStr.charAt(i) === ZERO_CHAR; i++) { /* empty */
2215 }
2216 if (i === (zeros = numStr.length)) {
2217 // The digits are all zero.
2218 digits = [0];
2219 integerLen = 1;
2220 }
2221 else {
2222 // Count the number of trailing zeros
2223 zeros--;
2224 while (numStr.charAt(zeros) === ZERO_CHAR)
2225 zeros--;
2226 // Trailing zeros are insignificant so ignore them
2227 integerLen -= i;
2228 digits = [];
2229 // Convert string to array of digits without leading/trailing zeros.
2230 for (j = 0; i <= zeros; i++, j++) {
2231 digits[j] = Number(numStr.charAt(i));
2232 }
2233 }
2234 // If the number overflows the maximum allowed digits then use an exponent.
2235 if (integerLen > MAX_DIGITS) {
2236 digits = digits.splice(0, MAX_DIGITS - 1);
2237 exponent = integerLen - 1;
2238 integerLen = 1;
2239 }
2240 return { digits: digits, exponent: exponent, integerLen: integerLen };
2241}
2242/**
2243 * Round the parsed number to the specified number of decimal places
2244 * This function changes the parsedNumber in-place
2245 */
2246function roundNumber(parsedNumber, minFrac, maxFrac) {
2247 if (minFrac > maxFrac) {
2248 throw new Error("The minimum number of digits after fraction (" + minFrac + ") is higher than the maximum (" + maxFrac + ").");
2249 }
2250 var digits = parsedNumber.digits;
2251 var fractionLen = digits.length - parsedNumber.integerLen;
2252 var fractionSize = Math.min(Math.max(minFrac, fractionLen), maxFrac);
2253 // The index of the digit to where rounding is to occur
2254 var roundAt = fractionSize + parsedNumber.integerLen;
2255 var digit = digits[roundAt];
2256 if (roundAt > 0) {
2257 // Drop fractional digits beyond `roundAt`
2258 digits.splice(Math.max(parsedNumber.integerLen, roundAt));
2259 // Set non-fractional digits beyond `roundAt` to 0
2260 for (var j = roundAt; j < digits.length; j++) {
2261 digits[j] = 0;
2262 }
2263 }
2264 else {
2265 // We rounded to zero so reset the parsedNumber
2266 fractionLen = Math.max(0, fractionLen);
2267 parsedNumber.integerLen = 1;
2268 digits.length = Math.max(1, roundAt = fractionSize + 1);
2269 digits[0] = 0;
2270 for (var i = 1; i < roundAt; i++)
2271 digits[i] = 0;
2272 }
2273 if (digit >= 5) {
2274 if (roundAt - 1 < 0) {
2275 for (var k = 0; k > roundAt; k--) {
2276 digits.unshift(0);
2277 parsedNumber.integerLen++;
2278 }
2279 digits.unshift(1);
2280 parsedNumber.integerLen++;
2281 }
2282 else {
2283 digits[roundAt - 1]++;
2284 }
2285 }
2286 // Pad out with zeros to get the required fraction length
2287 for (; fractionLen < Math.max(0, fractionSize); fractionLen++)
2288 digits.push(0);
2289 var dropTrailingZeros = fractionSize !== 0;
2290 // Minimal length = nb of decimals required + current nb of integers
2291 // Any number besides that is optional and can be removed if it's a trailing 0
2292 var minLen = minFrac + parsedNumber.integerLen;
2293 // Do any carrying, e.g. a digit was rounded up to 10
2294 var carry = digits.reduceRight(function (carry, d, i, digits) {
2295 d = d + carry;
2296 digits[i] = d < 10 ? d : d - 10; // d % 10
2297 if (dropTrailingZeros) {
2298 // Do not keep meaningless fractional trailing zeros (e.g. 15.52000 --> 15.52)
2299 if (digits[i] === 0 && i >= minLen) {
2300 digits.pop();
2301 }
2302 else {
2303 dropTrailingZeros = false;
2304 }
2305 }
2306 return d >= 10 ? 1 : 0; // Math.floor(d / 10);
2307 }, 0);
2308 if (carry) {
2309 digits.unshift(carry);
2310 parsedNumber.integerLen++;
2311 }
2312}
2313function parseIntAutoRadix(text) {
2314 var result = parseInt(text);
2315 if (isNaN(result)) {
2316 throw new Error('Invalid integer literal when parsing ' + text);
2317 }
2318 return result;
2319}
2320
2321/**
2322 * @license
2323 * Copyright Google Inc. All Rights Reserved.
2324 *
2325 * Use of this source code is governed by an MIT-style license that can be
2326 * found in the LICENSE file at https://angular.io/license
2327 */
2328/**
2329 * @deprecated from v5
2330 */
2331var DEPRECATED_PLURAL_FN = new InjectionToken('UseV4Plurals');
2332/**
2333 * @publicApi
2334 */
2335var NgLocalization = /** @class */ (function () {
2336 function NgLocalization() {
2337 }
2338 return NgLocalization;
2339}());
2340/**
2341 * Returns the plural category for a given value.
2342 * - "=value" when the case exists,
2343 * - the plural category otherwise
2344 */
2345function getPluralCategory(value, cases, ngLocalization, locale) {
2346 var key = "=" + value;
2347 if (cases.indexOf(key) > -1) {
2348 return key;
2349 }
2350 key = ngLocalization.getPluralCategory(value, locale);
2351 if (cases.indexOf(key) > -1) {
2352 return key;
2353 }
2354 if (cases.indexOf('other') > -1) {
2355 return 'other';
2356 }
2357 throw new Error("No plural message found for value \"" + value + "\"");
2358}
2359/**
2360 * Returns the plural case based on the locale
2361 *
2362 * @publicApi
2363 */
2364var NgLocaleLocalization = /** @class */ (function (_super) {
2365 __extends(NgLocaleLocalization, _super);
2366 function NgLocaleLocalization(locale,
2367 /** @deprecated from v5 */
2368 deprecatedPluralFn) {
2369 var _this = _super.call(this) || this;
2370 _this.locale = locale;
2371 _this.deprecatedPluralFn = deprecatedPluralFn;
2372 return _this;
2373 }
2374 NgLocaleLocalization.prototype.getPluralCategory = function (value, locale) {
2375 var plural = this.deprecatedPluralFn ? this.deprecatedPluralFn(locale || this.locale, value) :
2376 getLocalePluralCase(locale || this.locale)(value);
2377 switch (plural) {
2378 case Plural.Zero:
2379 return 'zero';
2380 case Plural.One:
2381 return 'one';
2382 case Plural.Two:
2383 return 'two';
2384 case Plural.Few:
2385 return 'few';
2386 case Plural.Many:
2387 return 'many';
2388 default:
2389 return 'other';
2390 }
2391 };
2392 NgLocaleLocalization = __decorate([
2393 Injectable(),
2394 __param(0, Inject(LOCALE_ID)),
2395 __param(1, Optional()), __param(1, Inject(DEPRECATED_PLURAL_FN)),
2396 __metadata("design:paramtypes", [String, Object])
2397 ], NgLocaleLocalization);
2398 return NgLocaleLocalization;
2399}(NgLocalization));
2400/**
2401 * Returns the plural case based on the locale
2402 *
2403 * @deprecated from v5 the plural case function is in locale data files common/locales/*.ts
2404 * @publicApi
2405 */
2406function getPluralCase(locale, nLike) {
2407 // TODO(vicb): lazy compute
2408 if (typeof nLike === 'string') {
2409 nLike = parseInt(nLike, 10);
2410 }
2411 var n = nLike;
2412 var nDecimal = n.toString().replace(/^[^.]*\.?/, '');
2413 var i = Math.floor(Math.abs(n));
2414 var v = nDecimal.length;
2415 var f = parseInt(nDecimal, 10);
2416 var t = parseInt(n.toString().replace(/^[^.]*\.?|0+$/g, ''), 10) || 0;
2417 var lang = locale.split('-')[0].toLowerCase();
2418 switch (lang) {
2419 case 'af':
2420 case 'asa':
2421 case 'az':
2422 case 'bem':
2423 case 'bez':
2424 case 'bg':
2425 case 'brx':
2426 case 'ce':
2427 case 'cgg':
2428 case 'chr':
2429 case 'ckb':
2430 case 'ee':
2431 case 'el':
2432 case 'eo':
2433 case 'es':
2434 case 'eu':
2435 case 'fo':
2436 case 'fur':
2437 case 'gsw':
2438 case 'ha':
2439 case 'haw':
2440 case 'hu':
2441 case 'jgo':
2442 case 'jmc':
2443 case 'ka':
2444 case 'kk':
2445 case 'kkj':
2446 case 'kl':
2447 case 'ks':
2448 case 'ksb':
2449 case 'ky':
2450 case 'lb':
2451 case 'lg':
2452 case 'mas':
2453 case 'mgo':
2454 case 'ml':
2455 case 'mn':
2456 case 'nb':
2457 case 'nd':
2458 case 'ne':
2459 case 'nn':
2460 case 'nnh':
2461 case 'nyn':
2462 case 'om':
2463 case 'or':
2464 case 'os':
2465 case 'ps':
2466 case 'rm':
2467 case 'rof':
2468 case 'rwk':
2469 case 'saq':
2470 case 'seh':
2471 case 'sn':
2472 case 'so':
2473 case 'sq':
2474 case 'ta':
2475 case 'te':
2476 case 'teo':
2477 case 'tk':
2478 case 'tr':
2479 case 'ug':
2480 case 'uz':
2481 case 'vo':
2482 case 'vun':
2483 case 'wae':
2484 case 'xog':
2485 if (n === 1)
2486 return Plural.One;
2487 return Plural.Other;
2488 case 'ak':
2489 case 'ln':
2490 case 'mg':
2491 case 'pa':
2492 case 'ti':
2493 if (n === Math.floor(n) && n >= 0 && n <= 1)
2494 return Plural.One;
2495 return Plural.Other;
2496 case 'am':
2497 case 'as':
2498 case 'bn':
2499 case 'fa':
2500 case 'gu':
2501 case 'hi':
2502 case 'kn':
2503 case 'mr':
2504 case 'zu':
2505 if (i === 0 || n === 1)
2506 return Plural.One;
2507 return Plural.Other;
2508 case 'ar':
2509 if (n === 0)
2510 return Plural.Zero;
2511 if (n === 1)
2512 return Plural.One;
2513 if (n === 2)
2514 return Plural.Two;
2515 if (n % 100 === Math.floor(n % 100) && n % 100 >= 3 && n % 100 <= 10)
2516 return Plural.Few;
2517 if (n % 100 === Math.floor(n % 100) && n % 100 >= 11 && n % 100 <= 99)
2518 return Plural.Many;
2519 return Plural.Other;
2520 case 'ast':
2521 case 'ca':
2522 case 'de':
2523 case 'en':
2524 case 'et':
2525 case 'fi':
2526 case 'fy':
2527 case 'gl':
2528 case 'it':
2529 case 'nl':
2530 case 'sv':
2531 case 'sw':
2532 case 'ur':
2533 case 'yi':
2534 if (i === 1 && v === 0)
2535 return Plural.One;
2536 return Plural.Other;
2537 case 'be':
2538 if (n % 10 === 1 && !(n % 100 === 11))
2539 return Plural.One;
2540 if (n % 10 === Math.floor(n % 10) && n % 10 >= 2 && n % 10 <= 4 &&
2541 !(n % 100 >= 12 && n % 100 <= 14))
2542 return Plural.Few;
2543 if (n % 10 === 0 || n % 10 === Math.floor(n % 10) && n % 10 >= 5 && n % 10 <= 9 ||
2544 n % 100 === Math.floor(n % 100) && n % 100 >= 11 && n % 100 <= 14)
2545 return Plural.Many;
2546 return Plural.Other;
2547 case 'br':
2548 if (n % 10 === 1 && !(n % 100 === 11 || n % 100 === 71 || n % 100 === 91))
2549 return Plural.One;
2550 if (n % 10 === 2 && !(n % 100 === 12 || n % 100 === 72 || n % 100 === 92))
2551 return Plural.Two;
2552 if (n % 10 === Math.floor(n % 10) && (n % 10 >= 3 && n % 10 <= 4 || n % 10 === 9) &&
2553 !(n % 100 >= 10 && n % 100 <= 19 || n % 100 >= 70 && n % 100 <= 79 ||
2554 n % 100 >= 90 && n % 100 <= 99))
2555 return Plural.Few;
2556 if (!(n === 0) && n % 1e6 === 0)
2557 return Plural.Many;
2558 return Plural.Other;
2559 case 'bs':
2560 case 'hr':
2561 case 'sr':
2562 if (v === 0 && i % 10 === 1 && !(i % 100 === 11) || f % 10 === 1 && !(f % 100 === 11))
2563 return Plural.One;
2564 if (v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 2 && i % 10 <= 4 &&
2565 !(i % 100 >= 12 && i % 100 <= 14) ||
2566 f % 10 === Math.floor(f % 10) && f % 10 >= 2 && f % 10 <= 4 &&
2567 !(f % 100 >= 12 && f % 100 <= 14))
2568 return Plural.Few;
2569 return Plural.Other;
2570 case 'cs':
2571 case 'sk':
2572 if (i === 1 && v === 0)
2573 return Plural.One;
2574 if (i === Math.floor(i) && i >= 2 && i <= 4 && v === 0)
2575 return Plural.Few;
2576 if (!(v === 0))
2577 return Plural.Many;
2578 return Plural.Other;
2579 case 'cy':
2580 if (n === 0)
2581 return Plural.Zero;
2582 if (n === 1)
2583 return Plural.One;
2584 if (n === 2)
2585 return Plural.Two;
2586 if (n === 3)
2587 return Plural.Few;
2588 if (n === 6)
2589 return Plural.Many;
2590 return Plural.Other;
2591 case 'da':
2592 if (n === 1 || !(t === 0) && (i === 0 || i === 1))
2593 return Plural.One;
2594 return Plural.Other;
2595 case 'dsb':
2596 case 'hsb':
2597 if (v === 0 && i % 100 === 1 || f % 100 === 1)
2598 return Plural.One;
2599 if (v === 0 && i % 100 === 2 || f % 100 === 2)
2600 return Plural.Two;
2601 if (v === 0 && i % 100 === Math.floor(i % 100) && i % 100 >= 3 && i % 100 <= 4 ||
2602 f % 100 === Math.floor(f % 100) && f % 100 >= 3 && f % 100 <= 4)
2603 return Plural.Few;
2604 return Plural.Other;
2605 case 'ff':
2606 case 'fr':
2607 case 'hy':
2608 case 'kab':
2609 if (i === 0 || i === 1)
2610 return Plural.One;
2611 return Plural.Other;
2612 case 'fil':
2613 if (v === 0 && (i === 1 || i === 2 || i === 3) ||
2614 v === 0 && !(i % 10 === 4 || i % 10 === 6 || i % 10 === 9) ||
2615 !(v === 0) && !(f % 10 === 4 || f % 10 === 6 || f % 10 === 9))
2616 return Plural.One;
2617 return Plural.Other;
2618 case 'ga':
2619 if (n === 1)
2620 return Plural.One;
2621 if (n === 2)
2622 return Plural.Two;
2623 if (n === Math.floor(n) && n >= 3 && n <= 6)
2624 return Plural.Few;
2625 if (n === Math.floor(n) && n >= 7 && n <= 10)
2626 return Plural.Many;
2627 return Plural.Other;
2628 case 'gd':
2629 if (n === 1 || n === 11)
2630 return Plural.One;
2631 if (n === 2 || n === 12)
2632 return Plural.Two;
2633 if (n === Math.floor(n) && (n >= 3 && n <= 10 || n >= 13 && n <= 19))
2634 return Plural.Few;
2635 return Plural.Other;
2636 case 'gv':
2637 if (v === 0 && i % 10 === 1)
2638 return Plural.One;
2639 if (v === 0 && i % 10 === 2)
2640 return Plural.Two;
2641 if (v === 0 &&
2642 (i % 100 === 0 || i % 100 === 20 || i % 100 === 40 || i % 100 === 60 || i % 100 === 80))
2643 return Plural.Few;
2644 if (!(v === 0))
2645 return Plural.Many;
2646 return Plural.Other;
2647 case 'he':
2648 if (i === 1 && v === 0)
2649 return Plural.One;
2650 if (i === 2 && v === 0)
2651 return Plural.Two;
2652 if (v === 0 && !(n >= 0 && n <= 10) && n % 10 === 0)
2653 return Plural.Many;
2654 return Plural.Other;
2655 case 'is':
2656 if (t === 0 && i % 10 === 1 && !(i % 100 === 11) || !(t === 0))
2657 return Plural.One;
2658 return Plural.Other;
2659 case 'ksh':
2660 if (n === 0)
2661 return Plural.Zero;
2662 if (n === 1)
2663 return Plural.One;
2664 return Plural.Other;
2665 case 'kw':
2666 case 'naq':
2667 case 'se':
2668 case 'smn':
2669 if (n === 1)
2670 return Plural.One;
2671 if (n === 2)
2672 return Plural.Two;
2673 return Plural.Other;
2674 case 'lag':
2675 if (n === 0)
2676 return Plural.Zero;
2677 if ((i === 0 || i === 1) && !(n === 0))
2678 return Plural.One;
2679 return Plural.Other;
2680 case 'lt':
2681 if (n % 10 === 1 && !(n % 100 >= 11 && n % 100 <= 19))
2682 return Plural.One;
2683 if (n % 10 === Math.floor(n % 10) && n % 10 >= 2 && n % 10 <= 9 &&
2684 !(n % 100 >= 11 && n % 100 <= 19))
2685 return Plural.Few;
2686 if (!(f === 0))
2687 return Plural.Many;
2688 return Plural.Other;
2689 case 'lv':
2690 case 'prg':
2691 if (n % 10 === 0 || n % 100 === Math.floor(n % 100) && n % 100 >= 11 && n % 100 <= 19 ||
2692 v === 2 && f % 100 === Math.floor(f % 100) && f % 100 >= 11 && f % 100 <= 19)
2693 return Plural.Zero;
2694 if (n % 10 === 1 && !(n % 100 === 11) || v === 2 && f % 10 === 1 && !(f % 100 === 11) ||
2695 !(v === 2) && f % 10 === 1)
2696 return Plural.One;
2697 return Plural.Other;
2698 case 'mk':
2699 if (v === 0 && i % 10 === 1 || f % 10 === 1)
2700 return Plural.One;
2701 return Plural.Other;
2702 case 'mt':
2703 if (n === 1)
2704 return Plural.One;
2705 if (n === 0 || n % 100 === Math.floor(n % 100) && n % 100 >= 2 && n % 100 <= 10)
2706 return Plural.Few;
2707 if (n % 100 === Math.floor(n % 100) && n % 100 >= 11 && n % 100 <= 19)
2708 return Plural.Many;
2709 return Plural.Other;
2710 case 'pl':
2711 if (i === 1 && v === 0)
2712 return Plural.One;
2713 if (v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 2 && i % 10 <= 4 &&
2714 !(i % 100 >= 12 && i % 100 <= 14))
2715 return Plural.Few;
2716 if (v === 0 && !(i === 1) && i % 10 === Math.floor(i % 10) && i % 10 >= 0 && i % 10 <= 1 ||
2717 v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 5 && i % 10 <= 9 ||
2718 v === 0 && i % 100 === Math.floor(i % 100) && i % 100 >= 12 && i % 100 <= 14)
2719 return Plural.Many;
2720 return Plural.Other;
2721 case 'pt':
2722 if (n === Math.floor(n) && n >= 0 && n <= 2 && !(n === 2))
2723 return Plural.One;
2724 return Plural.Other;
2725 case 'ro':
2726 if (i === 1 && v === 0)
2727 return Plural.One;
2728 if (!(v === 0) || n === 0 ||
2729 !(n === 1) && n % 100 === Math.floor(n % 100) && n % 100 >= 1 && n % 100 <= 19)
2730 return Plural.Few;
2731 return Plural.Other;
2732 case 'ru':
2733 case 'uk':
2734 if (v === 0 && i % 10 === 1 && !(i % 100 === 11))
2735 return Plural.One;
2736 if (v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 2 && i % 10 <= 4 &&
2737 !(i % 100 >= 12 && i % 100 <= 14))
2738 return Plural.Few;
2739 if (v === 0 && i % 10 === 0 ||
2740 v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 5 && i % 10 <= 9 ||
2741 v === 0 && i % 100 === Math.floor(i % 100) && i % 100 >= 11 && i % 100 <= 14)
2742 return Plural.Many;
2743 return Plural.Other;
2744 case 'shi':
2745 if (i === 0 || n === 1)
2746 return Plural.One;
2747 if (n === Math.floor(n) && n >= 2 && n <= 10)
2748 return Plural.Few;
2749 return Plural.Other;
2750 case 'si':
2751 if (n === 0 || n === 1 || i === 0 && f === 1)
2752 return Plural.One;
2753 return Plural.Other;
2754 case 'sl':
2755 if (v === 0 && i % 100 === 1)
2756 return Plural.One;
2757 if (v === 0 && i % 100 === 2)
2758 return Plural.Two;
2759 if (v === 0 && i % 100 === Math.floor(i % 100) && i % 100 >= 3 && i % 100 <= 4 || !(v === 0))
2760 return Plural.Few;
2761 return Plural.Other;
2762 case 'tzm':
2763 if (n === Math.floor(n) && n >= 0 && n <= 1 || n === Math.floor(n) && n >= 11 && n <= 99)
2764 return Plural.One;
2765 return Plural.Other;
2766 // When there is no specification, the default is always "other"
2767 // Spec: http://cldr.unicode.org/index/cldr-spec/plural-rules
2768 // > other (required—general plural form — also used if the language only has a single form)
2769 default:
2770 return Plural.Other;
2771 }
2772}
2773
2774/**
2775 * @license
2776 * Copyright Google Inc. All Rights Reserved.
2777 *
2778 * Use of this source code is governed by an MIT-style license that can be
2779 * found in the LICENSE file at https://angular.io/license
2780 */
2781/**
2782 * Register global data to be used internally by Angular. See the
2783 * ["I18n guide"](guide/i18n#i18n-pipes) to know how to import additional locale data.
2784 *
2785 * @publicApi
2786 */
2787// The signature registerLocaleData(data: any, extraData?: any) is deprecated since v5.1
2788function registerLocaleData(data, localeId, extraData) {
2789 if (typeof localeId !== 'string') {
2790 extraData = localeId;
2791 localeId = data[ɵLocaleDataIndex.LocaleId];
2792 }
2793 localeId = localeId.toLowerCase().replace(/_/g, '-');
2794 ɵLOCALE_DATA[localeId] = data;
2795 if (extraData) {
2796 ɵLOCALE_DATA[localeId][ɵLocaleDataIndex.ExtraData] = extraData;
2797 }
2798}
2799
2800/**
2801 * @license
2802 * Copyright Google Inc. All Rights Reserved.
2803 *
2804 * Use of this source code is governed by an MIT-style license that can be
2805 * found in the LICENSE file at https://angular.io/license
2806 */
2807function parseCookieValue(cookieStr, name) {
2808 var e_1, _a;
2809 name = encodeURIComponent(name);
2810 try {
2811 for (var _b = __values(cookieStr.split(';')), _c = _b.next(); !_c.done; _c = _b.next()) {
2812 var cookie = _c.value;
2813 var eqIndex = cookie.indexOf('=');
2814 var _d = __read(eqIndex == -1 ? [cookie, ''] : [cookie.slice(0, eqIndex), cookie.slice(eqIndex + 1)], 2), cookieName = _d[0], cookieValue = _d[1];
2815 if (cookieName.trim() === name) {
2816 return decodeURIComponent(cookieValue);
2817 }
2818 }
2819 }
2820 catch (e_1_1) { e_1 = { error: e_1_1 }; }
2821 finally {
2822 try {
2823 if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
2824 }
2825 finally { if (e_1) throw e_1.error; }
2826 }
2827 return null;
2828}
2829
2830/**
2831 * @license
2832 * Copyright Google Inc. All Rights Reserved.
2833 *
2834 * Use of this source code is governed by an MIT-style license that can be
2835 * found in the LICENSE file at https://angular.io/license
2836 */
2837/**
2838 * Used to diff and convert ngStyle/ngClass instructions into [style] and [class] bindings.
2839 *
2840 * ngStyle and ngClass both accept various forms of input and behave differently than that
2841 * of how [style] and [class] behave in Angular.
2842 *
2843 * The differences are:
2844 * - ngStyle and ngClass both **watch** their binding values for changes each time CD runs
2845 * while [style] and [class] bindings do not (they check for identity changes)
2846 * - ngStyle allows for unit-based keys (e.g. `{'max-width.px':value}`) and [style] does not
2847 * - ngClass supports arrays of class values and [class] only accepts map and string values
2848 * - ngClass allows for multiple className keys (space-separated) within an array or map
2849 * (as the * key) while [class] only accepts a simple key/value map object
2850 *
2851 * Having Angular understand and adapt to all the different forms of behavior is complicated
2852 * and unnecessary. Instead, ngClass and ngStyle should have their input values be converted
2853 * into something that the core-level [style] and [class] bindings understand.
2854 *
2855 * This [StylingDiffer] class handles this conversion by creating a new input value each time
2856 * the inner representation of the binding value have changed.
2857 *
2858 * ## Why do we care about ngStyle/ngClass?
2859 * The styling algorithm code (documented inside of `render3/interfaces/styling.ts`) needs to
2860 * respect and understand the styling values emitted through ngStyle and ngClass (when they
2861 * are present and used in a template).
2862 *
2863 * Instead of having these directives manage styling on their own, they should be included
2864 * into the Angular styling algorithm that exists for [style] and [class] bindings.
2865 *
2866 * Here's why:
2867 *
2868 * - If ngStyle/ngClass is used in combination with [style]/[class] bindings then the
2869 * styles and classes would fall out of sync and be applied and updated at
2870 * inconsistent times
2871 * - Both ngClass/ngStyle do not respect [class.name] and [style.prop] bindings
2872 * (they will write over them given the right combination of events)
2873 *
2874 * ```
2875 * <!-- if `w1` is updated then it will always override `w2`
2876 * if `w2` is updated then it will always override `w1`
2877 * if both are updated at the same time then `w1` wins -->
2878 * <div [ngStyle]="{width:w1}" [style.width]="w2">...</div>
2879 *
2880 * <!-- if `w1` is updated then it will always lose to `w2`
2881 * if `w2` is updated then it will always override `w1`
2882 * if both are updated at the same time then `w2` wins -->
2883 * <div [style]="{width:w1}" [style.width]="w2">...</div>
2884 * ```
2885 * - ngClass/ngStyle were written as a directives and made use of maps, closures and other
2886 * expensive data structures which were evaluated each time CD runs
2887 */
2888var StylingDiffer = /** @class */ (function () {
2889 function StylingDiffer(_name, _options) {
2890 this._name = _name;
2891 this._options = _options;
2892 this.value = null;
2893 this._lastSetValue = null;
2894 this._lastSetValueType = 0 /* Null */;
2895 this._lastSetValueIdentityChange = false;
2896 }
2897 /**
2898 * Sets (updates) the styling value within the differ.
2899 *
2900 * Only when `hasValueChanged` is called then this new value will be evaluted
2901 * and checked against the previous value.
2902 *
2903 * @param value the new styling value provided from the ngClass/ngStyle binding
2904 */
2905 StylingDiffer.prototype.setValue = function (value) {
2906 if (Array.isArray(value)) {
2907 this._lastSetValueType = 4 /* Array */;
2908 }
2909 else if (value instanceof Set) {
2910 this._lastSetValueType = 8 /* Set */;
2911 }
2912 else if (value && typeof value === 'string') {
2913 if (!(this._options & 4 /* AllowStringValue */)) {
2914 throw new Error(this._name + ' string values are not allowed');
2915 }
2916 this._lastSetValueType = 1 /* String */;
2917 }
2918 else {
2919 this._lastSetValueType = value ? 2 /* Map */ : 0 /* Null */;
2920 }
2921 this._lastSetValueIdentityChange = true;
2922 this._lastSetValue = value || null;
2923 };
2924 /**
2925 * Determines whether or not the value has changed.
2926 *
2927 * This function can be called right after `setValue()` is called, but it can also be
2928 * called incase the existing value (if it's a collection) changes internally. If the
2929 * value is indeed a collection it will do the necessary diffing work and produce a
2930 * new object value as assign that to `value`.
2931 *
2932 * @returns whether or not the value has changed in some way.
2933 */
2934 StylingDiffer.prototype.hasValueChanged = function () {
2935 var valueHasChanged = this._lastSetValueIdentityChange;
2936 if (!valueHasChanged && !(this._lastSetValueType & 14 /* Collection */))
2937 return false;
2938 var finalValue = null;
2939 var trimValues = (this._options & 1 /* TrimProperties */) ? true : false;
2940 var parseOutUnits = (this._options & 8 /* AllowUnits */) ? true : false;
2941 var allowSubKeys = (this._options & 2 /* AllowSubKeys */) ? true : false;
2942 switch (this._lastSetValueType) {
2943 // case 1: [input]="string"
2944 case 1 /* String */:
2945 var tokens = this._lastSetValue.split(/\s+/g);
2946 if (this._options & 16 /* ForceAsMap */) {
2947 finalValue = {};
2948 tokens.forEach(function (token, i) { return finalValue[token] = true; });
2949 }
2950 else {
2951 finalValue = tokens.reduce(function (str, token, i) { return str + (i ? ' ' : '') + token; });
2952 }
2953 break;
2954 // case 2: [input]="{key:value}"
2955 case 2 /* Map */:
2956 var map = this._lastSetValue;
2957 var keys = Object.keys(map);
2958 if (!valueHasChanged) {
2959 if (this.value) {
2960 // we know that the classExp value exists and that it is
2961 // a map (otherwise an identity change would have occurred)
2962 valueHasChanged = mapHasChanged(keys, this.value, map);
2963 }
2964 else {
2965 valueHasChanged = true;
2966 }
2967 }
2968 if (valueHasChanged) {
2969 finalValue =
2970 bulidMapFromValues(this._name, trimValues, parseOutUnits, allowSubKeys, map, keys);
2971 }
2972 break;
2973 // case 3a: [input]="[str1, str2, ...]"
2974 // case 3b: [input]="Set"
2975 case 4 /* Array */:
2976 case 8 /* Set */:
2977 var values = Array.from(this._lastSetValue);
2978 if (!valueHasChanged) {
2979 var keys_1 = Object.keys(this.value);
2980 valueHasChanged = !arrayEqualsArray(keys_1, values);
2981 }
2982 if (valueHasChanged) {
2983 finalValue =
2984 bulidMapFromValues(this._name, trimValues, parseOutUnits, allowSubKeys, values);
2985 }
2986 break;
2987 // case 4: [input]="null|undefined"
2988 default:
2989 finalValue = null;
2990 break;
2991 }
2992 if (valueHasChanged) {
2993 this.value = finalValue;
2994 }
2995 return valueHasChanged;
2996 };
2997 return StylingDiffer;
2998}());
2999/**
3000 * builds and returns a map based on the values input value
3001 *
3002 * If the `keys` param is provided then the `values` param is treated as a
3003 * string map. Otherwise `values` is treated as a string array.
3004 */
3005function bulidMapFromValues(errorPrefix, trim, parseOutUnits, allowSubKeys, values, keys) {
3006 var map = {};
3007 if (keys) {
3008 // case 1: map
3009 for (var i = 0; i < keys.length; i++) {
3010 var key = keys[i];
3011 key = trim ? key.trim() : key;
3012 var value = values[key];
3013 setMapValues(map, key, value, parseOutUnits, allowSubKeys);
3014 }
3015 }
3016 else {
3017 // case 2: array
3018 for (var i = 0; i < values.length; i++) {
3019 var value = values[i];
3020 assertValidValue(errorPrefix, value);
3021 value = trim ? value.trim() : value;
3022 setMapValues(map, value, true, false, allowSubKeys);
3023 }
3024 }
3025 return map;
3026}
3027function assertValidValue(errorPrefix, value) {
3028 if (typeof value !== 'string') {
3029 throw new Error(errorPrefix + " can only toggle CSS classes expressed as strings, got " + value);
3030 }
3031}
3032function setMapValues(map, key, value, parseOutUnits, allowSubKeys) {
3033 if (allowSubKeys && key.indexOf(' ') > 0) {
3034 var innerKeys = key.split(/\s+/g);
3035 for (var j = 0; j < innerKeys.length; j++) {
3036 setIndividualMapValue(map, innerKeys[j], value, parseOutUnits);
3037 }
3038 }
3039 else {
3040 setIndividualMapValue(map, key, value, parseOutUnits);
3041 }
3042}
3043function setIndividualMapValue(map, key, value, parseOutUnits) {
3044 if (parseOutUnits) {
3045 var values = normalizeStyleKeyAndValue(key, value);
3046 value = values.value;
3047 key = values.key;
3048 }
3049 map[key] = value;
3050}
3051function normalizeStyleKeyAndValue(key, value) {
3052 var index = key.indexOf('.');
3053 if (index > 0) {
3054 var unit = key.substr(index + 1); // ignore the . ([width.px]="'40'" => "40px")
3055 key = key.substring(0, index);
3056 if (value != null) { // we should not convert null values to string
3057 value += unit;
3058 }
3059 }
3060 return { key: key, value: value };
3061}
3062function mapHasChanged(keys, a, b) {
3063 var oldKeys = Object.keys(a);
3064 var newKeys = keys;
3065 // the keys are different which means the map changed
3066 if (!arrayEqualsArray(oldKeys, newKeys)) {
3067 return true;
3068 }
3069 for (var i = 0; i < newKeys.length; i++) {
3070 var key = newKeys[i];
3071 if (a[key] !== b[key]) {
3072 return true;
3073 }
3074 }
3075 return false;
3076}
3077function arrayEqualsArray(a, b) {
3078 if (a && b) {
3079 if (a.length !== b.length)
3080 return false;
3081 for (var i = 0; i < a.length; i++) {
3082 if (b.indexOf(a[i]) === -1)
3083 return false;
3084 }
3085 return true;
3086 }
3087 return false;
3088}
3089
3090/**
3091 * Used as a token for an injected service within the NgClass directive.
3092 *
3093 * NgClass behaves differenly whether or not VE is being used or not. If
3094 * present then the legacy ngClass diffing algorithm will be used as an
3095 * injected service. Otherwise the new diffing algorithm (which delegates
3096 * to the `[class]` binding) will be used. This toggle behavior is done so
3097 * via the ivy_switch mechanism.
3098 */
3099var NgClassImpl = /** @class */ (function () {
3100 function NgClassImpl() {
3101 }
3102 return NgClassImpl;
3103}());
3104var NgClassR2Impl = /** @class */ (function () {
3105 function NgClassR2Impl(_iterableDiffers, _keyValueDiffers, _ngEl, _renderer) {
3106 this._iterableDiffers = _iterableDiffers;
3107 this._keyValueDiffers = _keyValueDiffers;
3108 this._ngEl = _ngEl;
3109 this._renderer = _renderer;
3110 this._initialClasses = [];
3111 }
3112 NgClassR2Impl.prototype.getValue = function () { return null; };
3113 NgClassR2Impl.prototype.setClass = function (value) {
3114 this._removeClasses(this._initialClasses);
3115 this._initialClasses = typeof value === 'string' ? value.split(/\s+/) : [];
3116 this._applyClasses(this._initialClasses);
3117 this._applyClasses(this._rawClass);
3118 };
3119 NgClassR2Impl.prototype.setNgClass = function (value) {
3120 this._removeClasses(this._rawClass);
3121 this._applyClasses(this._initialClasses);
3122 this._iterableDiffer = null;
3123 this._keyValueDiffer = null;
3124 this._rawClass = typeof value === 'string' ? value.split(/\s+/) : value;
3125 if (this._rawClass) {
3126 if (ɵisListLikeIterable(this._rawClass)) {
3127 this._iterableDiffer = this._iterableDiffers.find(this._rawClass).create();
3128 }
3129 else {
3130 this._keyValueDiffer = this._keyValueDiffers.find(this._rawClass).create();
3131 }
3132 }
3133 };
3134 NgClassR2Impl.prototype.applyChanges = function () {
3135 if (this._iterableDiffer) {
3136 var iterableChanges = this._iterableDiffer.diff(this._rawClass);
3137 if (iterableChanges) {
3138 this._applyIterableChanges(iterableChanges);
3139 }
3140 }
3141 else if (this._keyValueDiffer) {
3142 var keyValueChanges = this._keyValueDiffer.diff(this._rawClass);
3143 if (keyValueChanges) {
3144 this._applyKeyValueChanges(keyValueChanges);
3145 }
3146 }
3147 };
3148 NgClassR2Impl.prototype._applyKeyValueChanges = function (changes) {
3149 var _this = this;
3150 changes.forEachAddedItem(function (record) { return _this._toggleClass(record.key, record.currentValue); });
3151 changes.forEachChangedItem(function (record) { return _this._toggleClass(record.key, record.currentValue); });
3152 changes.forEachRemovedItem(function (record) {
3153 if (record.previousValue) {
3154 _this._toggleClass(record.key, false);
3155 }
3156 });
3157 };
3158 NgClassR2Impl.prototype._applyIterableChanges = function (changes) {
3159 var _this = this;
3160 changes.forEachAddedItem(function (record) {
3161 if (typeof record.item === 'string') {
3162 _this._toggleClass(record.item, true);
3163 }
3164 else {
3165 throw new Error("NgClass can only toggle CSS classes expressed as strings, got " + ɵstringify(record.item));
3166 }
3167 });
3168 changes.forEachRemovedItem(function (record) { return _this._toggleClass(record.item, false); });
3169 };
3170 /**
3171 * Applies a collection of CSS classes to the DOM element.
3172 *
3173 * For argument of type Set and Array CSS class names contained in those collections are always
3174 * added.
3175 * For argument of type Map CSS class name in the map's key is toggled based on the value (added
3176 * for truthy and removed for falsy).
3177 */
3178 NgClassR2Impl.prototype._applyClasses = function (rawClassVal) {
3179 var _this = this;
3180 if (rawClassVal) {
3181 if (Array.isArray(rawClassVal) || rawClassVal instanceof Set) {
3182 rawClassVal.forEach(function (klass) { return _this._toggleClass(klass, true); });
3183 }
3184 else {
3185 Object.keys(rawClassVal).forEach(function (klass) { return _this._toggleClass(klass, !!rawClassVal[klass]); });
3186 }
3187 }
3188 };
3189 /**
3190 * Removes a collection of CSS classes from the DOM element. This is mostly useful for cleanup
3191 * purposes.
3192 */
3193 NgClassR2Impl.prototype._removeClasses = function (rawClassVal) {
3194 var _this = this;
3195 if (rawClassVal) {
3196 if (Array.isArray(rawClassVal) || rawClassVal instanceof Set) {
3197 rawClassVal.forEach(function (klass) { return _this._toggleClass(klass, false); });
3198 }
3199 else {
3200 Object.keys(rawClassVal).forEach(function (klass) { return _this._toggleClass(klass, false); });
3201 }
3202 }
3203 };
3204 NgClassR2Impl.prototype._toggleClass = function (klass, enabled) {
3205 var _this = this;
3206 klass = klass.trim();
3207 if (klass) {
3208 klass.split(/\s+/g).forEach(function (klass) {
3209 if (enabled) {
3210 _this._renderer.addClass(_this._ngEl.nativeElement, klass);
3211 }
3212 else {
3213 _this._renderer.removeClass(_this._ngEl.nativeElement, klass);
3214 }
3215 });
3216 }
3217 };
3218 NgClassR2Impl = __decorate([
3219 Injectable(),
3220 __metadata("design:paramtypes", [IterableDiffers, KeyValueDiffers,
3221 ElementRef, Renderer2])
3222 ], NgClassR2Impl);
3223 return NgClassR2Impl;
3224}());
3225var NgClassR3Impl = /** @class */ (function () {
3226 function NgClassR3Impl() {
3227 this._value = null;
3228 this._ngClassDiffer = new StylingDiffer('NgClass', 1 /* TrimProperties */ |
3229 2 /* AllowSubKeys */ |
3230 4 /* AllowStringValue */ | 16 /* ForceAsMap */);
3231 this._classStringDiffer = null;
3232 }
3233 NgClassR3Impl.prototype.getValue = function () { return this._value; };
3234 NgClassR3Impl.prototype.setClass = function (value) {
3235 // early exit incase the binding gets emitted as an empty value which
3236 // means there is no reason to instantiate and diff the values...
3237 if (!value && !this._classStringDiffer)
3238 return;
3239 this._classStringDiffer = this._classStringDiffer ||
3240 new StylingDiffer('class', 4 /* AllowStringValue */ | 16 /* ForceAsMap */);
3241 this._classStringDiffer.setValue(value);
3242 };
3243 NgClassR3Impl.prototype.setNgClass = function (value) {
3244 this._ngClassDiffer.setValue(value);
3245 };
3246 NgClassR3Impl.prototype.applyChanges = function () {
3247 var classChanged = this._classStringDiffer ? this._classStringDiffer.hasValueChanged() : false;
3248 var ngClassChanged = this._ngClassDiffer.hasValueChanged();
3249 if (classChanged || ngClassChanged) {
3250 var value = this._ngClassDiffer.value;
3251 if (this._classStringDiffer) {
3252 var classValue = this._classStringDiffer.value;
3253 if (classValue) {
3254 value = value ? __assign({}, classValue, value) : classValue;
3255 }
3256 }
3257 this._value = value;
3258 }
3259 };
3260 NgClassR3Impl = __decorate([
3261 Injectable()
3262 ], NgClassR3Impl);
3263 return NgClassR3Impl;
3264}());
3265// the implementation for both NgStyleR2Impl and NgStyleR3Impl are
3266// not ivy_switch'd away, instead they are only hooked up into the
3267// DI via NgStyle's directive's provider property.
3268var NgClassImplProvider__PRE_R3__ = {
3269 provide: NgClassImpl,
3270 useClass: NgClassR2Impl
3271};
3272var NgClassImplProvider__POST_R3__ = {
3273 provide: NgClassImpl,
3274 useClass: NgClassR3Impl
3275};
3276var NgClassImplProvider = NgClassImplProvider__PRE_R3__;
3277
3278/*
3279 * NgClass (as well as NgStyle) behaves differently when loaded in the VE and when not.
3280 *
3281 * If the VE is present (which is for older versions of Angular) then NgClass will inject
3282 * the legacy diffing algorithm as a service and delegate all styling changes to that.
3283 *
3284 * If the VE is not present then NgStyle will normalize (through the injected service) and
3285 * then write all styling changes to the `[style]` binding directly (through a host binding).
3286 * Then Angular will notice the host binding change and treat the changes as styling
3287 * changes and apply them via the core styling instructions that exist within Angular.
3288 */
3289// used when the VE is present
3290var ngClassDirectiveDef__PRE_R3__ = undefined;
3291var ɵ0 = function () { }, ɵ1 = function () { }, ɵ2 = function (rf, ctx, elIndex) {
3292 if (rf & 1 /* Create */) {
3293 ɵɵallocHostVars(1);
3294 ɵɵstyling();
3295 }
3296 if (rf & 2 /* Update */) {
3297 ɵɵclassMap(ctx.getValue());
3298 ɵɵstylingApply();
3299 }
3300};
3301// used when the VE is not present (note the directive will
3302// never be instantiated normally because it is apart of a
3303// base class)
3304var ngClassDirectiveDef__POST_R3__ = ɵɵdefineDirective({
3305 type: ɵ0,
3306 selectors: null,
3307 factory: ɵ1,
3308 hostBindings: ɵ2
3309});
3310var ngClassDirectiveDef = ngClassDirectiveDef__PRE_R3__;
3311/**
3312 * Serves as the base non-VE container for NgClass.
3313 *
3314 * While this is a base class that NgClass extends from, the
3315 * class itself acts as a container for non-VE code to setup
3316 * a link to the `[class]` host binding (via the static
3317 * `ngDirectiveDef` property on the class).
3318 *
3319 * Note that the `ngDirectiveDef` property's code is switched
3320 * depending if VE is present or not (this allows for the
3321 * binding code to be set only for newer versions of Angular).
3322 *
3323 * @publicApi
3324 */
3325var NgClassBase = /** @class */ (function () {
3326 function NgClassBase(_delegate) {
3327 this._delegate = _delegate;
3328 }
3329 NgClassBase.prototype.getValue = function () { return this._delegate.getValue(); };
3330 NgClassBase.ngDirectiveDef = ngClassDirectiveDef;
3331 return NgClassBase;
3332}());
3333/**
3334 * @ngModule CommonModule
3335 *
3336 * @usageNotes
3337 * ```
3338 * <some-element [ngClass]="'first second'">...</some-element>
3339 *
3340 * <some-element [ngClass]="['first', 'second']">...</some-element>
3341 *
3342 * <some-element [ngClass]="{'first': true, 'second': true, 'third': false}">...</some-element>
3343 *
3344 * <some-element [ngClass]="stringExp|arrayExp|objExp">...</some-element>
3345 *
3346 * <some-element [ngClass]="{'class1 class2 class3' : true}">...</some-element>
3347 * ```
3348 *
3349 * @description
3350 *
3351 * Adds and removes CSS classes on an HTML element.
3352 *
3353 * The CSS classes are updated as follows, depending on the type of the expression evaluation:
3354 * - `string` - the CSS classes listed in the string (space delimited) are added,
3355 * - `Array` - the CSS classes declared as Array elements are added,
3356 * - `Object` - keys are CSS classes that get added when the expression given in the value
3357 * evaluates to a truthy value, otherwise they are removed.
3358 *
3359 * @publicApi
3360 */
3361var NgClass = /** @class */ (function (_super) {
3362 __extends(NgClass, _super);
3363 function NgClass(delegate) {
3364 return _super.call(this, delegate) || this;
3365 }
3366 Object.defineProperty(NgClass.prototype, "klass", {
3367 set: function (value) { this._delegate.setClass(value); },
3368 enumerable: true,
3369 configurable: true
3370 });
3371 Object.defineProperty(NgClass.prototype, "ngClass", {
3372 set: function (value) {
3373 this._delegate.setNgClass(value);
3374 },
3375 enumerable: true,
3376 configurable: true
3377 });
3378 NgClass.prototype.ngDoCheck = function () { this._delegate.applyChanges(); };
3379 __decorate([
3380 Input('class'),
3381 __metadata("design:type", String),
3382 __metadata("design:paramtypes", [String])
3383 ], NgClass.prototype, "klass", null);
3384 __decorate([
3385 Input('ngClass'),
3386 __metadata("design:type", Object),
3387 __metadata("design:paramtypes", [Object])
3388 ], NgClass.prototype, "ngClass", null);
3389 NgClass = __decorate([
3390 Directive({ selector: '[ngClass]', providers: [NgClassImplProvider] }),
3391 __metadata("design:paramtypes", [NgClassImpl])
3392 ], NgClass);
3393 return NgClass;
3394}(NgClassBase));
3395
3396/**
3397 * @license
3398 * Copyright Google Inc. All Rights Reserved.
3399 *
3400 * Use of this source code is governed by an MIT-style license that can be
3401 * found in the LICENSE file at https://angular.io/license
3402 */
3403/**
3404 * Instantiates a single {@link Component} type and inserts its Host View into current View.
3405 * `NgComponentOutlet` provides a declarative approach for dynamic component creation.
3406 *
3407 * `NgComponentOutlet` requires a component type, if a falsy value is set the view will clear and
3408 * any existing component will get destroyed.
3409 *
3410 * @usageNotes
3411 *
3412 * ### Fine tune control
3413 *
3414 * You can control the component creation process by using the following optional attributes:
3415 *
3416 * * `ngComponentOutletInjector`: Optional custom {@link Injector} that will be used as parent for
3417 * the Component. Defaults to the injector of the current view container.
3418 *
3419 * * `ngComponentOutletContent`: Optional list of projectable nodes to insert into the content
3420 * section of the component, if exists.
3421 *
3422 * * `ngComponentOutletNgModuleFactory`: Optional module factory to allow dynamically loading other
3423 * module, then load a component from that module.
3424 *
3425 * ### Syntax
3426 *
3427 * Simple
3428 * ```
3429 * <ng-container *ngComponentOutlet="componentTypeExpression"></ng-container>
3430 * ```
3431 *
3432 * Customized injector/content
3433 * ```
3434 * <ng-container *ngComponentOutlet="componentTypeExpression;
3435 * injector: injectorExpression;
3436 * content: contentNodesExpression;">
3437 * </ng-container>
3438 * ```
3439 *
3440 * Customized ngModuleFactory
3441 * ```
3442 * <ng-container *ngComponentOutlet="componentTypeExpression;
3443 * ngModuleFactory: moduleFactory;">
3444 * </ng-container>
3445 * ```
3446 *
3447 * ### A simple example
3448 *
3449 * {@example common/ngComponentOutlet/ts/module.ts region='SimpleExample'}
3450 *
3451 * A more complete example with additional options:
3452 *
3453 * {@example common/ngComponentOutlet/ts/module.ts region='CompleteExample'}
3454 *
3455 * @publicApi
3456 * @ngModule CommonModule
3457 */
3458var NgComponentOutlet = /** @class */ (function () {
3459 function NgComponentOutlet(_viewContainerRef) {
3460 this._viewContainerRef = _viewContainerRef;
3461 this._componentRef = null;
3462 this._moduleRef = null;
3463 }
3464 NgComponentOutlet.prototype.ngOnChanges = function (changes) {
3465 this._viewContainerRef.clear();
3466 this._componentRef = null;
3467 if (this.ngComponentOutlet) {
3468 var elInjector = this.ngComponentOutletInjector || this._viewContainerRef.parentInjector;
3469 if (changes['ngComponentOutletNgModuleFactory']) {
3470 if (this._moduleRef)
3471 this._moduleRef.destroy();
3472 if (this.ngComponentOutletNgModuleFactory) {
3473 var parentModule = elInjector.get(NgModuleRef);
3474 this._moduleRef = this.ngComponentOutletNgModuleFactory.create(parentModule.injector);
3475 }
3476 else {
3477 this._moduleRef = null;
3478 }
3479 }
3480 var componentFactoryResolver = this._moduleRef ? this._moduleRef.componentFactoryResolver :
3481 elInjector.get(ComponentFactoryResolver);
3482 var componentFactory = componentFactoryResolver.resolveComponentFactory(this.ngComponentOutlet);
3483 this._componentRef = this._viewContainerRef.createComponent(componentFactory, this._viewContainerRef.length, elInjector, this.ngComponentOutletContent);
3484 }
3485 };
3486 NgComponentOutlet.prototype.ngOnDestroy = function () {
3487 if (this._moduleRef)
3488 this._moduleRef.destroy();
3489 };
3490 __decorate([
3491 Input(),
3492 __metadata("design:type", Type)
3493 ], NgComponentOutlet.prototype, "ngComponentOutlet", void 0);
3494 __decorate([
3495 Input(),
3496 __metadata("design:type", Injector)
3497 ], NgComponentOutlet.prototype, "ngComponentOutletInjector", void 0);
3498 __decorate([
3499 Input(),
3500 __metadata("design:type", Array)
3501 ], NgComponentOutlet.prototype, "ngComponentOutletContent", void 0);
3502 __decorate([
3503 Input(),
3504 __metadata("design:type", NgModuleFactory)
3505 ], NgComponentOutlet.prototype, "ngComponentOutletNgModuleFactory", void 0);
3506 NgComponentOutlet = __decorate([
3507 Directive({ selector: '[ngComponentOutlet]' }),
3508 __metadata("design:paramtypes", [ViewContainerRef])
3509 ], NgComponentOutlet);
3510 return NgComponentOutlet;
3511}());
3512
3513/**
3514 * @license
3515 * Copyright Google Inc. All Rights Reserved.
3516 *
3517 * Use of this source code is governed by an MIT-style license that can be
3518 * found in the LICENSE file at https://angular.io/license
3519 */
3520/**
3521 * @publicApi
3522 */
3523var NgForOfContext = /** @class */ (function () {
3524 function NgForOfContext($implicit, ngForOf, index, count) {
3525 this.$implicit = $implicit;
3526 this.ngForOf = ngForOf;
3527 this.index = index;
3528 this.count = count;
3529 }
3530 Object.defineProperty(NgForOfContext.prototype, "first", {
3531 get: function () { return this.index === 0; },
3532 enumerable: true,
3533 configurable: true
3534 });
3535 Object.defineProperty(NgForOfContext.prototype, "last", {
3536 get: function () { return this.index === this.count - 1; },
3537 enumerable: true,
3538 configurable: true
3539 });
3540 Object.defineProperty(NgForOfContext.prototype, "even", {
3541 get: function () { return this.index % 2 === 0; },
3542 enumerable: true,
3543 configurable: true
3544 });
3545 Object.defineProperty(NgForOfContext.prototype, "odd", {
3546 get: function () { return !this.even; },
3547 enumerable: true,
3548 configurable: true
3549 });
3550 return NgForOfContext;
3551}());
3552/**
3553 * A [structural directive](guide/structural-directives) that renders
3554 * a template for each item in a collection.
3555 * The directive is placed on an element, which becomes the parent
3556 * of the cloned templates.
3557 *
3558 * The `ngForOf` directive is generally used in the
3559 * [shorthand form](guide/structural-directives#the-asterisk--prefix) `*ngFor`.
3560 * In this form, the template to be rendered for each iteration is the content
3561 * of an anchor element containing the directive.
3562 *
3563 * The following example shows the shorthand syntax with some options,
3564 * contained in an `<li>` element.
3565 *
3566 * ```
3567 * <li *ngFor="let item of items; index as i; trackBy: trackByFn">...</li>
3568 * ```
3569 *
3570 * The shorthand form expands into a long form that uses the `ngForOf` selector
3571 * on an `<ng-template>` element.
3572 * The content of the `<ng-template>` element is the `<li>` element that held the
3573 * short-form directive.
3574 *
3575 * Here is the expanded version of the short-form example.
3576 *
3577 * ```
3578 * <ng-template ngFor let-item [ngForOf]="items" let-i="index" [ngForTrackBy]="trackByFn">
3579 * <li>...</li>
3580 * </ng-template>
3581 * ```
3582 *
3583 * Angular automatically expands the shorthand syntax as it compiles the template.
3584 * The context for each embedded view is logically merged to the current component
3585 * context according to its lexical position.
3586 *
3587 * When using the shorthand syntax, Angular allows only [one structural directive
3588 * on an element](guide/structural-directives#one-structural-directive-per-host-element).
3589 * If you want to iterate conditionally, for example,
3590 * put the `*ngIf` on a container element that wraps the `*ngFor` element.
3591 * For futher discussion, see
3592 * [Structural Directives](guide/structural-directives#one-per-element).
3593 *
3594 * @usageNotes
3595 *
3596 * ### Local variables
3597 *
3598 * `NgForOf` provides exported values that can be aliased to local variables.
3599 * For example:
3600 *
3601 * ```
3602 * <li *ngFor="let user of userObservable | async as users; index as i; first as isFirst">
3603 * {{i}}/{{users.length}}. {{user}} <span *ngIf="isFirst">default</span>
3604 * </li>
3605 * ```
3606 *
3607 * The following exported values can be aliased to local variables:
3608 *
3609 * - `$implicit: T`: The value of the individual items in the iterable (`ngForOf`).
3610 * - `ngForOf: NgIterable<T>`: The value of the iterable expression. Useful when the expression is
3611 * more complex then a property access, for example when using the async pipe (`userStreams |
3612 * async`).
3613 * - `index: number`: The index of the current item in the iterable.
3614 * - `first: boolean`: True when the item is the first item in the iterable.
3615 * - `last: boolean`: True when the item is the last item in the iterable.
3616 * - `even: boolean`: True when the item has an even index in the iterable.
3617 * - `odd: boolean`: True when the item has an odd index in the iterable.
3618 *
3619 * ### Change propagation
3620 *
3621 * When the contents of the iterator changes, `NgForOf` makes the corresponding changes to the DOM:
3622 *
3623 * * When an item is added, a new instance of the template is added to the DOM.
3624 * * When an item is removed, its template instance is removed from the DOM.
3625 * * When items are reordered, their respective templates are reordered in the DOM.
3626 *
3627 * Angular uses object identity to track insertions and deletions within the iterator and reproduce
3628 * those changes in the DOM. This has important implications for animations and any stateful
3629 * controls that are present, such as `<input>` elements that accept user input. Inserted rows can
3630 * be animated in, deleted rows can be animated out, and unchanged rows retain any unsaved state
3631 * such as user input.
3632 * For more on animations, see [Transitions and Triggers](guide/transition-and-triggers).
3633 *
3634 * The identities of elements in the iterator can change while the data does not.
3635 * This can happen, for example, if the iterator is produced from an RPC to the server, and that
3636 * RPC is re-run. Even if the data hasn't changed, the second response produces objects with
3637 * different identities, and Angular must tear down the entire DOM and rebuild it (as if all old
3638 * elements were deleted and all new elements inserted).
3639 *
3640 * To avoid this expensive operation, you can customize the default tracking algorithm.
3641 * by supplying the `trackBy` option to `NgForOf`.
3642 * `trackBy` takes a function that has two arguments: `index` and `item`.
3643 * If `trackBy` is given, Angular tracks changes by the return value of the function.
3644 *
3645 * @see [Structural Directives](guide/structural-directives)
3646 * @ngModule CommonModule
3647 * @publicApi
3648 */
3649var NgForOf = /** @class */ (function () {
3650 function NgForOf(_viewContainer, _template, _differs) {
3651 this._viewContainer = _viewContainer;
3652 this._template = _template;
3653 this._differs = _differs;
3654 this._ngForOfDirty = true;
3655 this._differ = null;
3656 }
3657 Object.defineProperty(NgForOf.prototype, "ngForOf", {
3658 /**
3659 * The value of the iterable expression, which can be used as a
3660 * [template input variable](guide/structural-directives#template-input-variable).
3661 */
3662 set: function (ngForOf) {
3663 this._ngForOf = ngForOf;
3664 this._ngForOfDirty = true;
3665 },
3666 enumerable: true,
3667 configurable: true
3668 });
3669 Object.defineProperty(NgForOf.prototype, "ngForTrackBy", {
3670 get: function () { return this._trackByFn; },
3671 /**
3672 * A function that defines how to track changes for items in the iterable.
3673 *
3674 * When items are added, moved, or removed in the iterable,
3675 * the directive must re-render the appropriate DOM nodes.
3676 * To minimize churn in the DOM, only nodes that have changed
3677 * are re-rendered.
3678 *
3679 * By default, the change detector assumes that
3680 * the object instance identifies the node in the iterable.
3681 * When this function is supplied, the directive uses
3682 * the result of calling this function to identify the item node,
3683 * rather than the identity of the object itself.
3684 *
3685 * The function receives two inputs,
3686 * the iteration index and the node object ID.
3687 */
3688 set: function (fn) {
3689 if (isDevMode() && fn != null && typeof fn !== 'function') {
3690 // TODO(vicb): use a log service once there is a public one available
3691 if (console && console.warn) {
3692 console.warn("trackBy must be a function, but received " + JSON.stringify(fn) + ". " +
3693 "See https://angular.io/docs/ts/latest/api/common/index/NgFor-directive.html#!#change-propagation for more information.");
3694 }
3695 }
3696 this._trackByFn = fn;
3697 },
3698 enumerable: true,
3699 configurable: true
3700 });
3701 Object.defineProperty(NgForOf.prototype, "ngForTemplate", {
3702 /**
3703 * A reference to the template that is stamped out for each item in the iterable.
3704 * @see [template reference variable](guide/template-syntax#template-reference-variables--var-)
3705 */
3706 set: function (value) {
3707 // TODO(TS2.1): make TemplateRef<Partial<NgForRowOf<T>>> once we move to TS v2.1
3708 // The current type is too restrictive; a template that just uses index, for example,
3709 // should be acceptable.
3710 if (value) {
3711 this._template = value;
3712 }
3713 },
3714 enumerable: true,
3715 configurable: true
3716 });
3717 /**
3718 * Applies the changes when needed.
3719 */
3720 NgForOf.prototype.ngDoCheck = function () {
3721 if (this._ngForOfDirty) {
3722 this._ngForOfDirty = false;
3723 // React on ngForOf changes only once all inputs have been initialized
3724 var value = this._ngForOf;
3725 if (!this._differ && value) {
3726 try {
3727 this._differ = this._differs.find(value).create(this.ngForTrackBy);
3728 }
3729 catch (_a) {
3730 throw new Error("Cannot find a differ supporting object '" + value + "' of type '" + getTypeName(value) + "'. NgFor only supports binding to Iterables such as Arrays.");
3731 }
3732 }
3733 }
3734 if (this._differ) {
3735 var changes = this._differ.diff(this._ngForOf);
3736 if (changes)
3737 this._applyChanges(changes);
3738 }
3739 };
3740 NgForOf.prototype._applyChanges = function (changes) {
3741 var _this = this;
3742 var insertTuples = [];
3743 changes.forEachOperation(function (item, adjustedPreviousIndex, currentIndex) {
3744 if (item.previousIndex == null) {
3745 var view = _this._viewContainer.createEmbeddedView(_this._template, new NgForOfContext(null, _this._ngForOf, -1, -1), currentIndex === null ? undefined : currentIndex);
3746 var tuple = new RecordViewTuple(item, view);
3747 insertTuples.push(tuple);
3748 }
3749 else if (currentIndex == null) {
3750 _this._viewContainer.remove(adjustedPreviousIndex === null ? undefined : adjustedPreviousIndex);
3751 }
3752 else if (adjustedPreviousIndex !== null) {
3753 var view = _this._viewContainer.get(adjustedPreviousIndex);
3754 _this._viewContainer.move(view, currentIndex);
3755 var tuple = new RecordViewTuple(item, view);
3756 insertTuples.push(tuple);
3757 }
3758 });
3759 for (var i = 0; i < insertTuples.length; i++) {
3760 this._perViewChange(insertTuples[i].view, insertTuples[i].record);
3761 }
3762 for (var i = 0, ilen = this._viewContainer.length; i < ilen; i++) {
3763 var viewRef = this._viewContainer.get(i);
3764 viewRef.context.index = i;
3765 viewRef.context.count = ilen;
3766 viewRef.context.ngForOf = this._ngForOf;
3767 }
3768 changes.forEachIdentityChange(function (record) {
3769 var viewRef = _this._viewContainer.get(record.currentIndex);
3770 viewRef.context.$implicit = record.item;
3771 });
3772 };
3773 NgForOf.prototype._perViewChange = function (view, record) {
3774 view.context.$implicit = record.item;
3775 };
3776 /**
3777 * Asserts the correct type of the context for the template that `NgForOf` will render.
3778 *
3779 * The presence of this method is a signal to the Ivy template type-check compiler that the
3780 * `NgForOf` structural directive renders its template with a specific context type.
3781 */
3782 NgForOf.ngTemplateContextGuard = function (dir, ctx) {
3783 return true;
3784 };
3785 __decorate([
3786 Input(),
3787 __metadata("design:type", Object),
3788 __metadata("design:paramtypes", [Object])
3789 ], NgForOf.prototype, "ngForOf", null);
3790 __decorate([
3791 Input(),
3792 __metadata("design:type", Function),
3793 __metadata("design:paramtypes", [Function])
3794 ], NgForOf.prototype, "ngForTrackBy", null);
3795 __decorate([
3796 Input(),
3797 __metadata("design:type", TemplateRef),
3798 __metadata("design:paramtypes", [TemplateRef])
3799 ], NgForOf.prototype, "ngForTemplate", null);
3800 NgForOf = __decorate([
3801 Directive({ selector: '[ngFor][ngForOf]' }),
3802 __metadata("design:paramtypes", [ViewContainerRef, TemplateRef,
3803 IterableDiffers])
3804 ], NgForOf);
3805 return NgForOf;
3806}());
3807var RecordViewTuple = /** @class */ (function () {
3808 function RecordViewTuple(record, view) {
3809 this.record = record;
3810 this.view = view;
3811 }
3812 return RecordViewTuple;
3813}());
3814function getTypeName(type) {
3815 return type['name'] || typeof type;
3816}
3817
3818/**
3819 * @license
3820 * Copyright Google Inc. All Rights Reserved.
3821 *
3822 * Use of this source code is governed by an MIT-style license that can be
3823 * found in the LICENSE file at https://angular.io/license
3824 */
3825/**
3826 * A structural directive that conditionally includes a template based on the value of
3827 * an expression coerced to Boolean.
3828 * When the expression evaluates to true, Angular renders the template
3829 * provided in a `then` clause, and when false or null,
3830 * Angular renders the template provided in an optional `else` clause. The default
3831 * template for the `else` clause is blank.
3832 *
3833 * A [shorthand form](guide/structural-directives#the-asterisk--prefix) of the directive,
3834 * `*ngIf="condition"`, is generally used, provided
3835 * as an attribute of the anchor element for the inserted template.
3836 * Angular expands this into a more explicit version, in which the anchor element
3837 * is contained in an `<ng-template>` element.
3838 *
3839 * Simple form with shorthand syntax:
3840 *
3841 * ```
3842 * <div *ngIf="condition">Content to render when condition is true.</div>
3843 * ```
3844 *
3845 * Simple form with expanded syntax:
3846 *
3847 * ```
3848 * <ng-template [ngIf]="condition"><div>Content to render when condition is
3849 * true.</div></ng-template>
3850 * ```
3851 *
3852 * Form with an "else" block:
3853 *
3854 * ```
3855 * <div *ngIf="condition; else elseBlock">Content to render when condition is true.</div>
3856 * <ng-template #elseBlock>Content to render when condition is false.</ng-template>
3857 * ```
3858 *
3859 * Shorthand form with "then" and "else" blocks:
3860 *
3861 * ```
3862 * <div *ngIf="condition; then thenBlock else elseBlock"></div>
3863 * <ng-template #thenBlock>Content to render when condition is true.</ng-template>
3864 * <ng-template #elseBlock>Content to render when condition is false.</ng-template>
3865 * ```
3866 *
3867 * Form with storing the value locally:
3868 *
3869 * ```
3870 * <div *ngIf="condition as value; else elseBlock">{{value}}</div>
3871 * <ng-template #elseBlock>Content to render when value is null.</ng-template>
3872 * ```
3873 *
3874 * @usageNotes
3875 *
3876 * The `*ngIf` directive is most commonly used to conditionally show an inline template,
3877 * as seen in the following example.
3878 * The default `else` template is blank.
3879 *
3880 * {@example common/ngIf/ts/module.ts region='NgIfSimple'}
3881 *
3882 * ### Showing an alternative template using `else`
3883 *
3884 * To display a template when `expression` evaluates to false, use an `else` template
3885 * binding as shown in the following example.
3886 * The `else` binding points to an `<ng-template>` element labeled `#elseBlock`.
3887 * The template can be defined anywhere in the component view, but is typically placed right after
3888 * `ngIf` for readability.
3889 *
3890 * {@example common/ngIf/ts/module.ts region='NgIfElse'}
3891 *
3892 * ### Using an external `then` template
3893 *
3894 * In the previous example, the then-clause template is specified inline, as the content of the
3895 * tag that contains the `ngIf` directive. You can also specify a template that is defined
3896 * externally, by referencing a labeled `<ng-template>` element. When you do this, you can
3897 * change which template to use at runtime, as shown in the following example.
3898 *
3899 * {@example common/ngIf/ts/module.ts region='NgIfThenElse'}
3900 *
3901 * ### Storing a conditional result in a variable
3902 *
3903 * You might want to show a set of properties from the same object. If you are waiting
3904 * for asynchronous data, the object can be undefined.
3905 * In this case, you can use `ngIf` and store the result of the condition in a local
3906 * variable as shown in the the following example.
3907 *
3908 * {@example common/ngIf/ts/module.ts region='NgIfAs'}
3909 *
3910 * This code uses only one `AsyncPipe`, so only one subscription is created.
3911 * The conditional statement stores the result of `userStream|async` in the local variable `user`.
3912 * You can then bind the local `user` repeatedly.
3913 *
3914 * The conditional displays the data only if `userStream` returns a value,
3915 * so you don't need to use the
3916 * [safe-navigation-operator](guide/template-syntax#safe-navigation-operator) (`?.`)
3917 * to guard against null values when accessing properties.
3918 * You can display an alternative template while waiting for the data.
3919 *
3920 * ### Shorthand syntax
3921 *
3922 * The shorthand syntax `*ngIf` expands into two separate template specifications
3923 * for the "then" and "else" clauses. For example, consider the following shorthand statement,
3924 * that is meant to show a loading page while waiting for data to be loaded.
3925 *
3926 * ```
3927 * <div class="hero-list" *ngIf="heroes else loading">
3928 * ...
3929 * </div>
3930 *
3931 * <ng-template #loading>
3932 * <div>Loading...</div>
3933 * </ng-template>
3934 * ```
3935 *
3936 * You can see that the "else" clause references the `<ng-template>`
3937 * with the `#loading` label, and the template for the "then" clause
3938 * is provided as the content of the anchor element.
3939 *
3940 * However, when Angular expands the shorthand syntax, it creates
3941 * another `<ng-template>` tag, with `ngIf` and `ngIfElse` directives.
3942 * The anchor element containing the template for the "then" clause becomes
3943 * the content of this unlabeled `<ng-template>` tag.
3944 *
3945 * ```
3946 * <ng-template [ngIf]="hero-list" [ngIfElse]="loading">
3947 * <div class="hero-list">
3948 * ...
3949 * </div>
3950 * </ng-template>
3951 *
3952 * <ng-template #loading>
3953 * <div>Loading...</div>
3954 * </ng-template>
3955 * ```
3956 *
3957 * The presence of the implicit template object has implications for the nesting of
3958 * structural directives. For more on this subject, see
3959 * [Structural Directives](https://angular.io/guide/structural-directives#one-per-element).
3960 *
3961 * @ngModule CommonModule
3962 * @publicApi
3963 */
3964var NgIf = /** @class */ (function () {
3965 function NgIf(_viewContainer, templateRef) {
3966 this._viewContainer = _viewContainer;
3967 this._context = new NgIfContext();
3968 this._thenTemplateRef = null;
3969 this._elseTemplateRef = null;
3970 this._thenViewRef = null;
3971 this._elseViewRef = null;
3972 this._thenTemplateRef = templateRef;
3973 }
3974 Object.defineProperty(NgIf.prototype, "ngIf", {
3975 /**
3976 * The Boolean expression to evaluate as the condition for showing a template.
3977 */
3978 set: function (condition) {
3979 this._context.$implicit = this._context.ngIf = condition;
3980 this._updateView();
3981 },
3982 enumerable: true,
3983 configurable: true
3984 });
3985 Object.defineProperty(NgIf.prototype, "ngIfThen", {
3986 /**
3987 * A template to show if the condition expression evaluates to true.
3988 */
3989 set: function (templateRef) {
3990 assertTemplate('ngIfThen', templateRef);
3991 this._thenTemplateRef = templateRef;
3992 this._thenViewRef = null; // clear previous view if any.
3993 this._updateView();
3994 },
3995 enumerable: true,
3996 configurable: true
3997 });
3998 Object.defineProperty(NgIf.prototype, "ngIfElse", {
3999 /**
4000 * A template to show if the condition expression evaluates to false.
4001 */
4002 set: function (templateRef) {
4003 assertTemplate('ngIfElse', templateRef);
4004 this._elseTemplateRef = templateRef;
4005 this._elseViewRef = null; // clear previous view if any.
4006 this._updateView();
4007 },
4008 enumerable: true,
4009 configurable: true
4010 });
4011 NgIf.prototype._updateView = function () {
4012 if (this._context.$implicit) {
4013 if (!this._thenViewRef) {
4014 this._viewContainer.clear();
4015 this._elseViewRef = null;
4016 if (this._thenTemplateRef) {
4017 this._thenViewRef =
4018 this._viewContainer.createEmbeddedView(this._thenTemplateRef, this._context);
4019 }
4020 }
4021 }
4022 else {
4023 if (!this._elseViewRef) {
4024 this._viewContainer.clear();
4025 this._thenViewRef = null;
4026 if (this._elseTemplateRef) {
4027 this._elseViewRef =
4028 this._viewContainer.createEmbeddedView(this._elseTemplateRef, this._context);
4029 }
4030 }
4031 }
4032 };
4033 __decorate([
4034 Input(),
4035 __metadata("design:type", Object),
4036 __metadata("design:paramtypes", [Object])
4037 ], NgIf.prototype, "ngIf", null);
4038 __decorate([
4039 Input(),
4040 __metadata("design:type", Object),
4041 __metadata("design:paramtypes", [Object])
4042 ], NgIf.prototype, "ngIfThen", null);
4043 __decorate([
4044 Input(),
4045 __metadata("design:type", Object),
4046 __metadata("design:paramtypes", [Object])
4047 ], NgIf.prototype, "ngIfElse", null);
4048 NgIf = __decorate([
4049 Directive({ selector: '[ngIf]' }),
4050 __metadata("design:paramtypes", [ViewContainerRef, TemplateRef])
4051 ], NgIf);
4052 return NgIf;
4053}());
4054/**
4055 * @publicApi
4056 */
4057var NgIfContext = /** @class */ (function () {
4058 function NgIfContext() {
4059 this.$implicit = null;
4060 this.ngIf = null;
4061 }
4062 return NgIfContext;
4063}());
4064function assertTemplate(property, templateRef) {
4065 var isTemplateRefOrNull = !!(!templateRef || templateRef.createEmbeddedView);
4066 if (!isTemplateRefOrNull) {
4067 throw new Error(property + " must be a TemplateRef, but received '" + ɵstringify(templateRef) + "'.");
4068 }
4069}
4070
4071/**
4072 * @license
4073 * Copyright Google Inc. All Rights Reserved.
4074 *
4075 * Use of this source code is governed by an MIT-style license that can be
4076 * found in the LICENSE file at https://angular.io/license
4077 */
4078var SwitchView = /** @class */ (function () {
4079 function SwitchView(_viewContainerRef, _templateRef) {
4080 this._viewContainerRef = _viewContainerRef;
4081 this._templateRef = _templateRef;
4082 this._created = false;
4083 }
4084 SwitchView.prototype.create = function () {
4085 this._created = true;
4086 this._viewContainerRef.createEmbeddedView(this._templateRef);
4087 };
4088 SwitchView.prototype.destroy = function () {
4089 this._created = false;
4090 this._viewContainerRef.clear();
4091 };
4092 SwitchView.prototype.enforceState = function (created) {
4093 if (created && !this._created) {
4094 this.create();
4095 }
4096 else if (!created && this._created) {
4097 this.destroy();
4098 }
4099 };
4100 return SwitchView;
4101}());
4102/**
4103 * @ngModule CommonModule
4104 *
4105 * @description A structural directive that adds or removes templates (displaying or hiding views)
4106 * when the next match expression matches the switch expression.
4107 *
4108 * The `[ngSwitch]` directive on a container specifies an expression to match against.
4109 * The expressions to match are provided by `ngSwitchCase` directives on views within the container.
4110 * - Every view that matches is rendered.
4111 * - If there are no matches, a view with the `ngSwitchDefault` directive is rendered.
4112 * - Elements within the `[NgSwitch]` statement but outside of any `NgSwitchCase`
4113 * or `ngSwitchDefault` directive are preserved at the location.
4114 *
4115 * @usageNotes
4116 * Define a container element for the directive, and specify the switch expression
4117 * to match against as an attribute:
4118 *
4119 * ```
4120 * <container-element [ngSwitch]="switch_expression">
4121 * ```
4122 *
4123 * Within the container, `*ngSwitchCase` statements specify the match expressions
4124 * as attributes. Include `*ngSwitchDefault` as the final case.
4125 *
4126 * ```
4127 * <container-element [ngSwitch]="switch_expression">
4128 * <some-element *ngSwitchCase="match_expression_1">...</some-element>
4129 * ...
4130 * <some-element *ngSwitchDefault>...</some-element>
4131 * </container-element>
4132 * ```
4133 *
4134 * ### Usage Examples
4135 *
4136 * The following example shows how to use more than one case to display the same view:
4137 *
4138 * ```
4139 * <container-element [ngSwitch]="switch_expression">
4140 * <!-- the same view can be shown in more than one case -->
4141 * <some-element *ngSwitchCase="match_expression_1">...</some-element>
4142 * <some-element *ngSwitchCase="match_expression_2">...</some-element>
4143 * <some-other-element *ngSwitchCase="match_expression_3">...</some-other-element>
4144 * <!--default case when there are no matches -->
4145 * <some-element *ngSwitchDefault>...</some-element>
4146 * </container-element>
4147 * ```
4148 *
4149 * The following example shows how cases can be nested:
4150 * ```
4151 * <container-element [ngSwitch]="switch_expression">
4152 * <some-element *ngSwitchCase="match_expression_1">...</some-element>
4153 * <some-element *ngSwitchCase="match_expression_2">...</some-element>
4154 * <some-other-element *ngSwitchCase="match_expression_3">...</some-other-element>
4155 * <ng-container *ngSwitchCase="match_expression_3">
4156 * <!-- use a ng-container to group multiple root nodes -->
4157 * <inner-element></inner-element>
4158 * <inner-other-element></inner-other-element>
4159 * </ng-container>
4160 * <some-element *ngSwitchDefault>...</some-element>
4161 * </container-element>
4162 * ```
4163 *
4164 * @publicApi
4165 * @see `NgSwitchCase`
4166 * @see `NgSwitchDefault`
4167 * @see [Structural Directives](guide/structural-directives)
4168 *
4169 */
4170var NgSwitch = /** @class */ (function () {
4171 function NgSwitch() {
4172 this._defaultUsed = false;
4173 this._caseCount = 0;
4174 this._lastCaseCheckIndex = 0;
4175 this._lastCasesMatched = false;
4176 }
4177 Object.defineProperty(NgSwitch.prototype, "ngSwitch", {
4178 set: function (newValue) {
4179 this._ngSwitch = newValue;
4180 if (this._caseCount === 0) {
4181 this._updateDefaultCases(true);
4182 }
4183 },
4184 enumerable: true,
4185 configurable: true
4186 });
4187 /** @internal */
4188 NgSwitch.prototype._addCase = function () { return this._caseCount++; };
4189 /** @internal */
4190 NgSwitch.prototype._addDefault = function (view) {
4191 if (!this._defaultViews) {
4192 this._defaultViews = [];
4193 }
4194 this._defaultViews.push(view);
4195 };
4196 /** @internal */
4197 NgSwitch.prototype._matchCase = function (value) {
4198 var matched = value == this._ngSwitch;
4199 this._lastCasesMatched = this._lastCasesMatched || matched;
4200 this._lastCaseCheckIndex++;
4201 if (this._lastCaseCheckIndex === this._caseCount) {
4202 this._updateDefaultCases(!this._lastCasesMatched);
4203 this._lastCaseCheckIndex = 0;
4204 this._lastCasesMatched = false;
4205 }
4206 return matched;
4207 };
4208 NgSwitch.prototype._updateDefaultCases = function (useDefault) {
4209 if (this._defaultViews && useDefault !== this._defaultUsed) {
4210 this._defaultUsed = useDefault;
4211 for (var i = 0; i < this._defaultViews.length; i++) {
4212 var defaultView = this._defaultViews[i];
4213 defaultView.enforceState(useDefault);
4214 }
4215 }
4216 };
4217 __decorate([
4218 Input(),
4219 __metadata("design:type", Object),
4220 __metadata("design:paramtypes", [Object])
4221 ], NgSwitch.prototype, "ngSwitch", null);
4222 NgSwitch = __decorate([
4223 Directive({ selector: '[ngSwitch]' })
4224 ], NgSwitch);
4225 return NgSwitch;
4226}());
4227/**
4228 * @ngModule CommonModule
4229 *
4230 * @description
4231 * Provides a switch case expression to match against an enclosing `ngSwitch` expression.
4232 * When the expressions match, the given `NgSwitchCase` template is rendered.
4233 * If multiple match expressions match the switch expression value, all of them are displayed.
4234 *
4235 * @usageNotes
4236 *
4237 * Within a switch container, `*ngSwitchCase` statements specify the match expressions
4238 * as attributes. Include `*ngSwitchDefault` as the final case.
4239 *
4240 * ```
4241 * <container-element [ngSwitch]="switch_expression">
4242 * <some-element *ngSwitchCase="match_expression_1">...</some-element>
4243 * ...
4244 * <some-element *ngSwitchDefault>...</some-element>
4245 * </container-element>
4246 * ```
4247 *
4248 * Each switch-case statement contains an in-line HTML template or template reference
4249 * that defines the subtree to be selected if the value of the match expression
4250 * matches the value of the switch expression.
4251 *
4252 * Unlike JavaScript, which uses strict equality, Angular uses loose equality.
4253 * This means that the empty string, `""` matches 0.
4254 *
4255 * @publicApi
4256 * @see `NgSwitch`
4257 * @see `NgSwitchDefault`
4258 *
4259 */
4260var NgSwitchCase = /** @class */ (function () {
4261 function NgSwitchCase(viewContainer, templateRef, ngSwitch) {
4262 this.ngSwitch = ngSwitch;
4263 ngSwitch._addCase();
4264 this._view = new SwitchView(viewContainer, templateRef);
4265 }
4266 /**
4267 * Performs case matching. For internal use only.
4268 */
4269 NgSwitchCase.prototype.ngDoCheck = function () { this._view.enforceState(this.ngSwitch._matchCase(this.ngSwitchCase)); };
4270 __decorate([
4271 Input(),
4272 __metadata("design:type", Object)
4273 ], NgSwitchCase.prototype, "ngSwitchCase", void 0);
4274 NgSwitchCase = __decorate([
4275 Directive({ selector: '[ngSwitchCase]' }),
4276 __param(2, Host()),
4277 __metadata("design:paramtypes", [ViewContainerRef, TemplateRef,
4278 NgSwitch])
4279 ], NgSwitchCase);
4280 return NgSwitchCase;
4281}());
4282/**
4283 * @ngModule CommonModule
4284 *
4285 * @description
4286 *
4287 * Creates a view that is rendered when no `NgSwitchCase` expressions
4288 * match the `NgSwitch` expression.
4289 * This statement should be the final case in an `NgSwitch`.
4290 *
4291 * @publicApi
4292 * @see `NgSwitch`
4293 * @see `NgSwitchCase`
4294 *
4295 */
4296var NgSwitchDefault = /** @class */ (function () {
4297 function NgSwitchDefault(viewContainer, templateRef, ngSwitch) {
4298 ngSwitch._addDefault(new SwitchView(viewContainer, templateRef));
4299 }
4300 NgSwitchDefault = __decorate([
4301 Directive({ selector: '[ngSwitchDefault]' }),
4302 __param(2, Host()),
4303 __metadata("design:paramtypes", [ViewContainerRef, TemplateRef,
4304 NgSwitch])
4305 ], NgSwitchDefault);
4306 return NgSwitchDefault;
4307}());
4308
4309/**
4310 * @license
4311 * Copyright Google Inc. All Rights Reserved.
4312 *
4313 * Use of this source code is governed by an MIT-style license that can be
4314 * found in the LICENSE file at https://angular.io/license
4315 */
4316/**
4317 * @ngModule CommonModule
4318 *
4319 * @usageNotes
4320 * ```
4321 * <some-element [ngPlural]="value">
4322 * <ng-template ngPluralCase="=0">there is nothing</ng-template>
4323 * <ng-template ngPluralCase="=1">there is one</ng-template>
4324 * <ng-template ngPluralCase="few">there are a few</ng-template>
4325 * </some-element>
4326 * ```
4327 *
4328 * @description
4329 *
4330 * Adds / removes DOM sub-trees based on a numeric value. Tailored for pluralization.
4331 *
4332 * Displays DOM sub-trees that match the switch expression value, or failing that, DOM sub-trees
4333 * that match the switch expression's pluralization category.
4334 *
4335 * To use this directive you must provide a container element that sets the `[ngPlural]` attribute
4336 * to a switch expression. Inner elements with a `[ngPluralCase]` will display based on their
4337 * expression:
4338 * - if `[ngPluralCase]` is set to a value starting with `=`, it will only display if the value
4339 * matches the switch expression exactly,
4340 * - otherwise, the view will be treated as a "category match", and will only display if exact
4341 * value matches aren't found and the value maps to its category for the defined locale.
4342 *
4343 * See http://cldr.unicode.org/index/cldr-spec/plural-rules
4344 *
4345 * @publicApi
4346 */
4347var NgPlural = /** @class */ (function () {
4348 function NgPlural(_localization) {
4349 this._localization = _localization;
4350 this._caseViews = {};
4351 }
4352 Object.defineProperty(NgPlural.prototype, "ngPlural", {
4353 set: function (value) {
4354 this._switchValue = value;
4355 this._updateView();
4356 },
4357 enumerable: true,
4358 configurable: true
4359 });
4360 NgPlural.prototype.addCase = function (value, switchView) { this._caseViews[value] = switchView; };
4361 NgPlural.prototype._updateView = function () {
4362 this._clearViews();
4363 var cases = Object.keys(this._caseViews);
4364 var key = getPluralCategory(this._switchValue, cases, this._localization);
4365 this._activateView(this._caseViews[key]);
4366 };
4367 NgPlural.prototype._clearViews = function () {
4368 if (this._activeView)
4369 this._activeView.destroy();
4370 };
4371 NgPlural.prototype._activateView = function (view) {
4372 if (view) {
4373 this._activeView = view;
4374 this._activeView.create();
4375 }
4376 };
4377 __decorate([
4378 Input(),
4379 __metadata("design:type", Number),
4380 __metadata("design:paramtypes", [Number])
4381 ], NgPlural.prototype, "ngPlural", null);
4382 NgPlural = __decorate([
4383 Directive({ selector: '[ngPlural]' }),
4384 __metadata("design:paramtypes", [NgLocalization])
4385 ], NgPlural);
4386 return NgPlural;
4387}());
4388/**
4389 * @ngModule CommonModule
4390 *
4391 * @description
4392 *
4393 * Creates a view that will be added/removed from the parent {@link NgPlural} when the
4394 * given expression matches the plural expression according to CLDR rules.
4395 *
4396 * @usageNotes
4397 * ```
4398 * <some-element [ngPlural]="value">
4399 * <ng-template ngPluralCase="=0">...</ng-template>
4400 * <ng-template ngPluralCase="other">...</ng-template>
4401 * </some-element>
4402 *```
4403 *
4404 * See {@link NgPlural} for more details and example.
4405 *
4406 * @publicApi
4407 */
4408var NgPluralCase = /** @class */ (function () {
4409 function NgPluralCase(value, template, viewContainer, ngPlural) {
4410 this.value = value;
4411 var isANumber = !isNaN(Number(value));
4412 ngPlural.addCase(isANumber ? "=" + value : value, new SwitchView(viewContainer, template));
4413 }
4414 NgPluralCase = __decorate([
4415 Directive({ selector: '[ngPluralCase]' }),
4416 __param(0, Attribute('ngPluralCase')),
4417 __param(3, Host()),
4418 __metadata("design:paramtypes", [String, TemplateRef,
4419 ViewContainerRef, NgPlural])
4420 ], NgPluralCase);
4421 return NgPluralCase;
4422}());
4423
4424/**
4425 * Used as a token for an injected service within the NgStyle directive.
4426 *
4427 * NgStyle behaves differenly whether or not VE is being used or not. If
4428 * present then the legacy ngClass diffing algorithm will be used as an
4429 * injected service. Otherwise the new diffing algorithm (which delegates
4430 * to the `[style]` binding) will be used. This toggle behavior is done so
4431 * via the ivy_switch mechanism.
4432 */
4433var NgStyleImpl = /** @class */ (function () {
4434 function NgStyleImpl() {
4435 }
4436 return NgStyleImpl;
4437}());
4438var NgStyleR2Impl = /** @class */ (function () {
4439 function NgStyleR2Impl(_ngEl, _differs, _renderer) {
4440 this._ngEl = _ngEl;
4441 this._differs = _differs;
4442 this._renderer = _renderer;
4443 }
4444 NgStyleR2Impl.prototype.getValue = function () { return null; };
4445 /**
4446 * A map of style properties, specified as colon-separated
4447 * key-value pairs.
4448 * * The key is a style name, with an optional `.<unit>` suffix
4449 * (such as 'top.px', 'font-style.em').
4450 * * The value is an expression to be evaluated.
4451 */
4452 NgStyleR2Impl.prototype.setNgStyle = function (values) {
4453 this._ngStyle = values;
4454 if (!this._differ && values) {
4455 this._differ = this._differs.find(values).create();
4456 }
4457 };
4458 /**
4459 * Applies the new styles if needed.
4460 */
4461 NgStyleR2Impl.prototype.applyChanges = function () {
4462 if (this._differ) {
4463 var changes = this._differ.diff(this._ngStyle);
4464 if (changes) {
4465 this._applyChanges(changes);
4466 }
4467 }
4468 };
4469 NgStyleR2Impl.prototype._applyChanges = function (changes) {
4470 var _this = this;
4471 changes.forEachRemovedItem(function (record) { return _this._setStyle(record.key, null); });
4472 changes.forEachAddedItem(function (record) { return _this._setStyle(record.key, record.currentValue); });
4473 changes.forEachChangedItem(function (record) { return _this._setStyle(record.key, record.currentValue); });
4474 };
4475 NgStyleR2Impl.prototype._setStyle = function (nameAndUnit, value) {
4476 var _a = __read(nameAndUnit.split('.'), 2), name = _a[0], unit = _a[1];
4477 value = value != null && unit ? "" + value + unit : value;
4478 if (value != null) {
4479 this._renderer.setStyle(this._ngEl.nativeElement, name, value);
4480 }
4481 else {
4482 this._renderer.removeStyle(this._ngEl.nativeElement, name);
4483 }
4484 };
4485 NgStyleR2Impl = __decorate([
4486 Injectable(),
4487 __metadata("design:paramtypes", [ElementRef, KeyValueDiffers, Renderer2])
4488 ], NgStyleR2Impl);
4489 return NgStyleR2Impl;
4490}());
4491var NgStyleR3Impl = /** @class */ (function () {
4492 function NgStyleR3Impl() {
4493 this._differ = new StylingDiffer('NgStyle', 8 /* AllowUnits */);
4494 this._value = null;
4495 }
4496 NgStyleR3Impl.prototype.getValue = function () { return this._value; };
4497 NgStyleR3Impl.prototype.setNgStyle = function (value) { this._differ.setValue(value); };
4498 NgStyleR3Impl.prototype.applyChanges = function () {
4499 if (this._differ.hasValueChanged()) {
4500 this._value = this._differ.value;
4501 }
4502 };
4503 NgStyleR3Impl = __decorate([
4504 Injectable()
4505 ], NgStyleR3Impl);
4506 return NgStyleR3Impl;
4507}());
4508// the implementation for both NgClassR2Impl and NgClassR3Impl are
4509// not ivy_switch'd away, instead they are only hooked up into the
4510// DI via NgStyle's directive's provider property.
4511var NgStyleImplProvider__PRE_R3__ = {
4512 provide: NgStyleImpl,
4513 useClass: NgStyleR2Impl
4514};
4515var NgStyleImplProvider__POST_R3__ = {
4516 provide: NgStyleImpl,
4517 useClass: NgStyleR3Impl
4518};
4519var NgStyleImplProvider = NgStyleImplProvider__PRE_R3__;
4520
4521/*
4522 * NgStyle (as well as NgClass) behaves differently when loaded in the VE and when not.
4523 *
4524 * If the VE is present (which is for older versions of Angular) then NgStyle will inject
4525 * the legacy diffing algorithm as a service and delegate all styling changes to that.
4526 *
4527 * If the VE is not present then NgStyle will normalize (through the injected service) and
4528 * then write all styling changes to the `[style]` binding directly (through a host binding).
4529 * Then Angular will notice the host binding change and treat the changes as styling
4530 * changes and apply them via the core styling instructions that exist within Angular.
4531 */
4532// used when the VE is present
4533var ngStyleDirectiveDef__PRE_R3__ = undefined;
4534var ɵ0$1 = function () { }, ɵ1$1 = function () { }, ɵ2$1 = function (rf, ctx, elIndex) {
4535 if (rf & 1 /* Create */) {
4536 ɵɵstyling();
4537 }
4538 if (rf & 2 /* Update */) {
4539 ɵɵstyleMap(ctx.getValue());
4540 ɵɵstylingApply();
4541 }
4542};
4543// used when the VE is not present (note the directive will
4544// never be instantiated normally because it is apart of a
4545// base class)
4546var ngStyleDirectiveDef__POST_R3__ = ɵɵdefineDirective({
4547 type: ɵ0$1,
4548 selectors: null,
4549 factory: ɵ1$1,
4550 hostBindings: ɵ2$1
4551});
4552var ngStyleDirectiveDef = ngStyleDirectiveDef__PRE_R3__;
4553/**
4554 * Serves as the base non-VE container for NgStyle.
4555 *
4556 * While this is a base class that NgStyle extends from, the
4557 * class itself acts as a container for non-VE code to setup
4558 * a link to the `[style]` host binding (via the static
4559 * `ngDirectiveDef` property on the class).
4560 *
4561 * Note that the `ngDirectiveDef` property's code is switched
4562 * depending if VE is present or not (this allows for the
4563 * binding code to be set only for newer versions of Angular).
4564 *
4565 * @publicApi
4566 */
4567var NgStyleBase = /** @class */ (function () {
4568 function NgStyleBase(_delegate) {
4569 this._delegate = _delegate;
4570 }
4571 NgStyleBase.prototype.getValue = function () { return this._delegate.getValue(); };
4572 NgStyleBase.ngDirectiveDef = ngStyleDirectiveDef;
4573 return NgStyleBase;
4574}());
4575/**
4576 * @ngModule CommonModule
4577 *
4578 * @usageNotes
4579 *
4580 * Set the font of the containing element to the result of an expression.
4581 *
4582 * ```
4583 * <some-element [ngStyle]="{'font-style': styleExp}">...</some-element>
4584 * ```
4585 *
4586 * Set the width of the containing element to a pixel value returned by an expression.
4587 *
4588 * ```
4589 * <some-element [ngStyle]="{'max-width.px': widthExp}">...</some-element>
4590 * ```
4591 *
4592 * Set a collection of style values using an expression that returns key-value pairs.
4593 *
4594 * ```
4595 * <some-element [ngStyle]="objExp">...</some-element>
4596 * ```
4597 *
4598 * @description
4599 *
4600 * An attribute directive that updates styles for the containing HTML element.
4601 * Sets one or more style properties, specified as colon-separated key-value pairs.
4602 * The key is a style name, with an optional `.<unit>` suffix
4603 * (such as 'top.px', 'font-style.em').
4604 * The value is an expression to be evaluated.
4605 * The resulting non-null value, expressed in the given unit,
4606 * is assigned to the given style property.
4607 * If the result of evaluation is null, the corresponding style is removed.
4608 *
4609 * @publicApi
4610 */
4611var NgStyle = /** @class */ (function (_super) {
4612 __extends(NgStyle, _super);
4613 function NgStyle(delegate) {
4614 return _super.call(this, delegate) || this;
4615 }
4616 Object.defineProperty(NgStyle.prototype, "ngStyle", {
4617 set: function (value) { this._delegate.setNgStyle(value); },
4618 enumerable: true,
4619 configurable: true
4620 });
4621 NgStyle.prototype.ngDoCheck = function () { this._delegate.applyChanges(); };
4622 __decorate([
4623 Input('ngStyle'),
4624 __metadata("design:type", Object),
4625 __metadata("design:paramtypes", [Object])
4626 ], NgStyle.prototype, "ngStyle", null);
4627 NgStyle = __decorate([
4628 Directive({ selector: '[ngStyle]', providers: [NgStyleImplProvider] }),
4629 __metadata("design:paramtypes", [NgStyleImpl])
4630 ], NgStyle);
4631 return NgStyle;
4632}(NgStyleBase));
4633
4634/**
4635 * @license
4636 * Copyright Google Inc. All Rights Reserved.
4637 *
4638 * Use of this source code is governed by an MIT-style license that can be
4639 * found in the LICENSE file at https://angular.io/license
4640 */
4641/**
4642 * @ngModule CommonModule
4643 *
4644 * @description
4645 *
4646 * Inserts an embedded view from a prepared `TemplateRef`.
4647 *
4648 * You can attach a context object to the `EmbeddedViewRef` by setting `[ngTemplateOutletContext]`.
4649 * `[ngTemplateOutletContext]` should be an object, the object's keys will be available for binding
4650 * by the local template `let` declarations.
4651 *
4652 * @usageNotes
4653 * ```
4654 * <ng-container *ngTemplateOutlet="templateRefExp; context: contextExp"></ng-container>
4655 * ```
4656 *
4657 * Using the key `$implicit` in the context object will set its value as default.
4658 *
4659 * ### Example
4660 *
4661 * {@example common/ngTemplateOutlet/ts/module.ts region='NgTemplateOutlet'}
4662 *
4663 * @publicApi
4664 */
4665var NgTemplateOutlet = /** @class */ (function () {
4666 function NgTemplateOutlet(_viewContainerRef) {
4667 this._viewContainerRef = _viewContainerRef;
4668 this._viewRef = null;
4669 /**
4670 * A context object to attach to the {@link EmbeddedViewRef}. This should be an
4671 * object, the object's keys will be available for binding by the local template `let`
4672 * declarations.
4673 * Using the key `$implicit` in the context object will set its value as default.
4674 */
4675 this.ngTemplateOutletContext = null;
4676 /**
4677 * A string defining the template reference and optionally the context object for the template.
4678 */
4679 this.ngTemplateOutlet = null;
4680 }
4681 NgTemplateOutlet.prototype.ngOnChanges = function (changes) {
4682 var recreateView = this._shouldRecreateView(changes);
4683 if (recreateView) {
4684 if (this._viewRef) {
4685 this._viewContainerRef.remove(this._viewContainerRef.indexOf(this._viewRef));
4686 }
4687 if (this.ngTemplateOutlet) {
4688 this._viewRef = this._viewContainerRef.createEmbeddedView(this.ngTemplateOutlet, this.ngTemplateOutletContext);
4689 }
4690 }
4691 else {
4692 if (this._viewRef && this.ngTemplateOutletContext) {
4693 this._updateExistingContext(this.ngTemplateOutletContext);
4694 }
4695 }
4696 };
4697 /**
4698 * We need to re-create existing embedded view if:
4699 * - templateRef has changed
4700 * - context has changes
4701 *
4702 * We mark context object as changed when the corresponding object
4703 * shape changes (new properties are added or existing properties are removed).
4704 * In other words we consider context with the same properties as "the same" even
4705 * if object reference changes (see https://github.com/angular/angular/issues/13407).
4706 */
4707 NgTemplateOutlet.prototype._shouldRecreateView = function (changes) {
4708 var ctxChange = changes['ngTemplateOutletContext'];
4709 return !!changes['ngTemplateOutlet'] || (ctxChange && this._hasContextShapeChanged(ctxChange));
4710 };
4711 NgTemplateOutlet.prototype._hasContextShapeChanged = function (ctxChange) {
4712 var e_1, _a;
4713 var prevCtxKeys = Object.keys(ctxChange.previousValue || {});
4714 var currCtxKeys = Object.keys(ctxChange.currentValue || {});
4715 if (prevCtxKeys.length === currCtxKeys.length) {
4716 try {
4717 for (var currCtxKeys_1 = __values(currCtxKeys), currCtxKeys_1_1 = currCtxKeys_1.next(); !currCtxKeys_1_1.done; currCtxKeys_1_1 = currCtxKeys_1.next()) {
4718 var propName = currCtxKeys_1_1.value;
4719 if (prevCtxKeys.indexOf(propName) === -1) {
4720 return true;
4721 }
4722 }
4723 }
4724 catch (e_1_1) { e_1 = { error: e_1_1 }; }
4725 finally {
4726 try {
4727 if (currCtxKeys_1_1 && !currCtxKeys_1_1.done && (_a = currCtxKeys_1.return)) _a.call(currCtxKeys_1);
4728 }
4729 finally { if (e_1) throw e_1.error; }
4730 }
4731 return false;
4732 }
4733 else {
4734 return true;
4735 }
4736 };
4737 NgTemplateOutlet.prototype._updateExistingContext = function (ctx) {
4738 var e_2, _a;
4739 try {
4740 for (var _b = __values(Object.keys(ctx)), _c = _b.next(); !_c.done; _c = _b.next()) {
4741 var propName = _c.value;
4742 this._viewRef.context[propName] = this.ngTemplateOutletContext[propName];
4743 }
4744 }
4745 catch (e_2_1) { e_2 = { error: e_2_1 }; }
4746 finally {
4747 try {
4748 if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
4749 }
4750 finally { if (e_2) throw e_2.error; }
4751 }
4752 };
4753 __decorate([
4754 Input(),
4755 __metadata("design:type", Object)
4756 ], NgTemplateOutlet.prototype, "ngTemplateOutletContext", void 0);
4757 __decorate([
4758 Input(),
4759 __metadata("design:type", Object)
4760 ], NgTemplateOutlet.prototype, "ngTemplateOutlet", void 0);
4761 NgTemplateOutlet = __decorate([
4762 Directive({ selector: '[ngTemplateOutlet]' }),
4763 __metadata("design:paramtypes", [ViewContainerRef])
4764 ], NgTemplateOutlet);
4765 return NgTemplateOutlet;
4766}());
4767
4768/**
4769 * @license
4770 * Copyright Google Inc. All Rights Reserved.
4771 *
4772 * Use of this source code is governed by an MIT-style license that can be
4773 * found in the LICENSE file at https://angular.io/license
4774 */
4775/**
4776 * A collection of Angular directives that are likely to be used in each and every Angular
4777 * application.
4778 */
4779var COMMON_DIRECTIVES = [
4780 NgClass,
4781 NgComponentOutlet,
4782 NgForOf,
4783 NgIf,
4784 NgTemplateOutlet,
4785 NgStyle,
4786 NgSwitch,
4787 NgSwitchCase,
4788 NgSwitchDefault,
4789 NgPlural,
4790 NgPluralCase,
4791];
4792
4793/**
4794 * @license
4795 * Copyright Google Inc. All Rights Reserved.
4796 *
4797 * Use of this source code is governed by an MIT-style license that can be
4798 * found in the LICENSE file at https://angular.io/license
4799 */
4800function invalidPipeArgumentError(type, value) {
4801 return Error("InvalidPipeArgument: '" + value + "' for pipe '" + ɵstringify(type) + "'");
4802}
4803
4804var NumberFormatter = /** @class */ (function () {
4805 function NumberFormatter() {
4806 }
4807 NumberFormatter.format = function (num, locale, style, opts) {
4808 if (opts === void 0) { opts = {}; }
4809 var minimumIntegerDigits = opts.minimumIntegerDigits, minimumFractionDigits = opts.minimumFractionDigits, maximumFractionDigits = opts.maximumFractionDigits, currency = opts.currency, _a = opts.currencyAsSymbol, currencyAsSymbol = _a === void 0 ? false : _a;
4810 var options = {
4811 minimumIntegerDigits: minimumIntegerDigits,
4812 minimumFractionDigits: minimumFractionDigits,
4813 maximumFractionDigits: maximumFractionDigits,
4814 style: NumberFormatStyle[style].toLowerCase()
4815 };
4816 if (style == NumberFormatStyle.Currency) {
4817 options.currency = typeof currency == 'string' ? currency : undefined;
4818 options.currencyDisplay = currencyAsSymbol ? 'symbol' : 'code';
4819 }
4820 return new Intl.NumberFormat(locale, options).format(num);
4821 };
4822 return NumberFormatter;
4823}());
4824var DATE_FORMATS_SPLIT$1 = /((?:[^yMLdHhmsazZEwGjJ']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|L+|d+|H+|h+|J+|j+|m+|s+|a|z|Z|G+|w+))(.*)/;
4825var PATTERN_ALIASES = {
4826 // Keys are quoted so they do not get renamed during closure compilation.
4827 'yMMMdjms': datePartGetterFactory(combine([
4828 digitCondition('year', 1),
4829 nameCondition('month', 3),
4830 digitCondition('day', 1),
4831 digitCondition('hour', 1),
4832 digitCondition('minute', 1),
4833 digitCondition('second', 1),
4834 ])),
4835 'yMdjm': datePartGetterFactory(combine([
4836 digitCondition('year', 1), digitCondition('month', 1), digitCondition('day', 1),
4837 digitCondition('hour', 1), digitCondition('minute', 1)
4838 ])),
4839 'yMMMMEEEEd': datePartGetterFactory(combine([
4840 digitCondition('year', 1), nameCondition('month', 4), nameCondition('weekday', 4),
4841 digitCondition('day', 1)
4842 ])),
4843 'yMMMMd': datePartGetterFactory(combine([digitCondition('year', 1), nameCondition('month', 4), digitCondition('day', 1)])),
4844 'yMMMd': datePartGetterFactory(combine([digitCondition('year', 1), nameCondition('month', 3), digitCondition('day', 1)])),
4845 'yMd': datePartGetterFactory(combine([digitCondition('year', 1), digitCondition('month', 1), digitCondition('day', 1)])),
4846 'jms': datePartGetterFactory(combine([digitCondition('hour', 1), digitCondition('second', 1), digitCondition('minute', 1)])),
4847 'jm': datePartGetterFactory(combine([digitCondition('hour', 1), digitCondition('minute', 1)]))
4848};
4849var DATE_FORMATS$1 = {
4850 // Keys are quoted so they do not get renamed.
4851 'yyyy': datePartGetterFactory(digitCondition('year', 4)),
4852 'yy': datePartGetterFactory(digitCondition('year', 2)),
4853 'y': datePartGetterFactory(digitCondition('year', 1)),
4854 'MMMM': datePartGetterFactory(nameCondition('month', 4)),
4855 'MMM': datePartGetterFactory(nameCondition('month', 3)),
4856 'MM': datePartGetterFactory(digitCondition('month', 2)),
4857 'M': datePartGetterFactory(digitCondition('month', 1)),
4858 'LLLL': datePartGetterFactory(nameCondition('month', 4)),
4859 'L': datePartGetterFactory(nameCondition('month', 1)),
4860 'dd': datePartGetterFactory(digitCondition('day', 2)),
4861 'd': datePartGetterFactory(digitCondition('day', 1)),
4862 'HH': digitModifier(hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 2), false)))),
4863 'H': hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 1), false))),
4864 'hh': digitModifier(hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 2), true)))),
4865 'h': hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 1), true))),
4866 'jj': datePartGetterFactory(digitCondition('hour', 2)),
4867 'j': datePartGetterFactory(digitCondition('hour', 1)),
4868 'mm': digitModifier(datePartGetterFactory(digitCondition('minute', 2))),
4869 'm': datePartGetterFactory(digitCondition('minute', 1)),
4870 'ss': digitModifier(datePartGetterFactory(digitCondition('second', 2))),
4871 's': datePartGetterFactory(digitCondition('second', 1)),
4872 // while ISO 8601 requires fractions to be prefixed with `.` or `,`
4873 // we can be just safely rely on using `sss` since we currently don't support single or two digit
4874 // fractions
4875 'sss': datePartGetterFactory(digitCondition('second', 3)),
4876 'EEEE': datePartGetterFactory(nameCondition('weekday', 4)),
4877 'EEE': datePartGetterFactory(nameCondition('weekday', 3)),
4878 'EE': datePartGetterFactory(nameCondition('weekday', 2)),
4879 'E': datePartGetterFactory(nameCondition('weekday', 1)),
4880 'a': hourClockExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 1), true))),
4881 'Z': timeZoneGetter$1('short'),
4882 'z': timeZoneGetter$1('long'),
4883 'ww': datePartGetterFactory({}),
4884 // first Thursday of the year. not support ?
4885 'w': datePartGetterFactory({}),
4886 // of the year not support ?
4887 'G': datePartGetterFactory(nameCondition('era', 1)),
4888 'GG': datePartGetterFactory(nameCondition('era', 2)),
4889 'GGG': datePartGetterFactory(nameCondition('era', 3)),
4890 'GGGG': datePartGetterFactory(nameCondition('era', 4))
4891};
4892function digitModifier(inner) {
4893 return function (date, locale) {
4894 var result = inner(date, locale);
4895 return result.length == 1 ? '0' + result : result;
4896 };
4897}
4898function hourClockExtractor(inner) {
4899 return function (date, locale) { return inner(date, locale).split(' ')[1]; };
4900}
4901function hourExtractor(inner) {
4902 return function (date, locale) { return inner(date, locale).split(' ')[0]; };
4903}
4904function intlDateFormat(date, locale, options) {
4905 return new Intl.DateTimeFormat(locale, options).format(date).replace(/[\u200e\u200f]/g, '');
4906}
4907function timeZoneGetter$1(timezone) {
4908 // To workaround `Intl` API restriction for single timezone let format with 24 hours
4909 var options = { hour: '2-digit', hour12: false, timeZoneName: timezone };
4910 return function (date, locale) {
4911 var result = intlDateFormat(date, locale, options);
4912 // Then extract first 3 letters that related to hours
4913 return result ? result.substring(3) : '';
4914 };
4915}
4916function hour12Modify(options, value) {
4917 options.hour12 = value;
4918 return options;
4919}
4920function digitCondition(prop, len) {
4921 var result = {};
4922 result[prop] = len === 2 ? '2-digit' : 'numeric';
4923 return result;
4924}
4925function nameCondition(prop, len) {
4926 var result = {};
4927 if (len < 4) {
4928 result[prop] = len > 1 ? 'short' : 'narrow';
4929 }
4930 else {
4931 result[prop] = 'long';
4932 }
4933 return result;
4934}
4935function combine(options) {
4936 return options.reduce(function (merged, opt) { return (__assign({}, merged, opt)); }, {});
4937}
4938function datePartGetterFactory(ret) {
4939 return function (date, locale) { return intlDateFormat(date, locale, ret); };
4940}
4941var DATE_FORMATTER_CACHE = new Map();
4942function dateFormatter(format, date, locale) {
4943 var fn = PATTERN_ALIASES[format];
4944 if (fn)
4945 return fn(date, locale);
4946 var cacheKey = format;
4947 var parts = DATE_FORMATTER_CACHE.get(cacheKey);
4948 if (!parts) {
4949 parts = [];
4950 var match = void 0;
4951 DATE_FORMATS_SPLIT$1.exec(format);
4952 var _format = format;
4953 while (_format) {
4954 match = DATE_FORMATS_SPLIT$1.exec(_format);
4955 if (match) {
4956 parts = parts.concat(match.slice(1));
4957 _format = parts.pop();
4958 }
4959 else {
4960 parts.push(_format);
4961 _format = null;
4962 }
4963 }
4964 DATE_FORMATTER_CACHE.set(cacheKey, parts);
4965 }
4966 return parts.reduce(function (text, part) {
4967 var fn = DATE_FORMATS$1[part];
4968 return text + (fn ? fn(date, locale) : partToTime(part));
4969 }, '');
4970}
4971function partToTime(part) {
4972 return part === '\'\'' ? '\'' : part.replace(/(^'|'$)/g, '').replace(/''/g, '\'');
4973}
4974var DateFormatter = /** @class */ (function () {
4975 function DateFormatter() {
4976 }
4977 DateFormatter.format = function (date, locale, pattern) {
4978 return dateFormatter(pattern, date, locale);
4979 };
4980 return DateFormatter;
4981}());
4982
4983/**
4984* @license
4985* Copyright Google Inc. All Rights Reserved.
4986*
4987* Use of this source code is governed by an MIT-style license that can be
4988* found in the LICENSE file at https://angular.io/license
4989 */
4990/**
4991 * @ngModule CommonModule
4992 * @description
4993 *
4994 * Formats a date according to locale rules.
4995 *
4996 * Where:
4997 * - `expression` is a date object or a number (milliseconds since UTC epoch) or an ISO string
4998 * (https://www.w3.org/TR/NOTE-datetime).
4999 * - `format` indicates which date/time components to include. The format can be predefined as
5000 * shown below or custom as shown in the table.
5001 * - `'medium'`: equivalent to `'yMMMdjms'` (e.g. `Sep 3, 2010, 12:05:08 PM` for `en-US`)
5002 * - `'short'`: equivalent to `'yMdjm'` (e.g. `9/3/2010, 12:05 PM` for `en-US`)
5003 * - `'fullDate'`: equivalent to `'yMMMMEEEEd'` (e.g. `Friday, September 3, 2010` for `en-US`)
5004 * - `'longDate'`: equivalent to `'yMMMMd'` (e.g. `September 3, 2010` for `en-US`)
5005 * - `'mediumDate'`: equivalent to `'yMMMd'` (e.g. `Sep 3, 2010` for `en-US`)
5006 * - `'shortDate'`: equivalent to `'yMd'` (e.g. `9/3/2010` for `en-US`)
5007 * - `'mediumTime'`: equivalent to `'jms'` (e.g. `12:05:08 PM` for `en-US`)
5008 * - `'shortTime'`: equivalent to `'jm'` (e.g. `12:05 PM` for `en-US`)
5009 *
5010 *
5011 * | Component | Symbol | Narrow | Short Form | Long Form | Numeric | 2-digit |
5012 * |-----------|:------:|--------|--------------|-------------------|-----------|-----------|
5013 * | era | G | G (A) | GGG (AD) | GGGG (Anno Domini)| - | - |
5014 * | year | y | - | - | - | y (2015) | yy (15) |
5015 * | month | M | L (S) | MMM (Sep) | MMMM (September) | M (9) | MM (09) |
5016 * | day | d | - | - | - | d (3) | dd (03) |
5017 * | weekday | E | E (S) | EEE (Sun) | EEEE (Sunday) | - | - |
5018 * | hour | j | - | - | - | j (13) | jj (13) |
5019 * | hour12 | h | - | - | - | h (1 PM) | hh (01 PM)|
5020 * | hour24 | H | - | - | - | H (13) | HH (13) |
5021 * | minute | m | - | - | - | m (5) | mm (05) |
5022 * | second | s | - | - | - | s (9) | ss (09) |
5023 * | timezone | z | - | - | z (Pacific Standard Time)| - | - |
5024 * | timezone | Z | - | Z (GMT-8:00) | - | - | - |
5025 * | timezone | a | - | a (PM) | - | - | - |
5026 *
5027 * In javascript, only the components specified will be respected (not the ordering,
5028 * punctuations, ...) and details of the formatting will be dependent on the locale.
5029 *
5030 * Timezone of the formatted text will be the local system timezone of the end-user's machine.
5031 *
5032 * When the expression is a ISO string without time (e.g. 2016-09-19) the time zone offset is not
5033 * applied and the formatted text will have the same day, month and year of the expression.
5034 *
5035 * WARNINGS:
5036 * - this pipe is marked as pure hence it will not be re-evaluated when the input is mutated.
5037 * Instead users should treat the date as an immutable object and change the reference when the
5038 * pipe needs to re-run (this is to avoid reformatting the date on every change detection run
5039 * which would be an expensive operation).
5040 * - this pipe uses the Internationalization API. Therefore it is only reliable in Chrome and Opera
5041 * browsers.
5042 *
5043 * @usageNotes
5044 *
5045 * ### Examples
5046 *
5047 * Assuming `dateObj` is (year: 2010, month: 9, day: 3, hour: 12 PM, minute: 05, second: 08)
5048 * in the _local_ time and locale is 'en-US':
5049 *
5050 * {@example common/pipes/ts/date_pipe.ts region='DeprecatedDatePipe'}
5051 *
5052 * @publicApi
5053 */
5054var DeprecatedDatePipe = /** @class */ (function () {
5055 function DeprecatedDatePipe(_locale) {
5056 this._locale = _locale;
5057 }
5058 DeprecatedDatePipe_1 = DeprecatedDatePipe;
5059 DeprecatedDatePipe.prototype.transform = function (value, pattern) {
5060 if (pattern === void 0) { pattern = 'mediumDate'; }
5061 if (value == null || value === '' || value !== value)
5062 return null;
5063 var date;
5064 if (typeof value === 'string') {
5065 value = value.trim();
5066 }
5067 if (isDate$1(value)) {
5068 date = value;
5069 }
5070 else if (!isNaN(value - parseFloat(value))) {
5071 date = new Date(parseFloat(value));
5072 }
5073 else if (typeof value === 'string' && /^(\d{4}-\d{1,2}-\d{1,2})$/.test(value)) {
5074 /**
5075 * For ISO Strings without time the day, month and year must be extracted from the ISO String
5076 * before Date creation to avoid time offset and errors in the new Date.
5077 * If we only replace '-' with ',' in the ISO String ("2015,01,01"), and try to create a new
5078 * date, some browsers (e.g. IE 9) will throw an invalid Date error
5079 * If we leave the '-' ("2015-01-01") and try to create a new Date("2015-01-01") the
5080 * timeoffset
5081 * is applied
5082 * Note: ISO months are 0 for January, 1 for February, ...
5083 */
5084 var _a = __read(value.split('-').map(function (val) { return parseInt(val, 10); }), 3), y = _a[0], m = _a[1], d = _a[2];
5085 date = new Date(y, m - 1, d);
5086 }
5087 else {
5088 date = new Date(value);
5089 }
5090 if (!isDate$1(date)) {
5091 var match = void 0;
5092 if ((typeof value === 'string') && (match = value.match(ISO8601_DATE_REGEX))) {
5093 date = isoStringToDate(match);
5094 }
5095 else {
5096 throw invalidPipeArgumentError(DeprecatedDatePipe_1, value);
5097 }
5098 }
5099 return DateFormatter.format(date, this._locale, DeprecatedDatePipe_1._ALIASES[pattern] || pattern);
5100 };
5101 var DeprecatedDatePipe_1;
5102 /** @internal */
5103 DeprecatedDatePipe._ALIASES = {
5104 'medium': 'yMMMdjms',
5105 'short': 'yMdjm',
5106 'fullDate': 'yMMMMEEEEd',
5107 'longDate': 'yMMMMd',
5108 'mediumDate': 'yMMMd',
5109 'shortDate': 'yMd',
5110 'mediumTime': 'jms',
5111 'shortTime': 'jm'
5112 };
5113 DeprecatedDatePipe = DeprecatedDatePipe_1 = __decorate([
5114 Pipe({ name: 'date', pure: true }),
5115 __param(0, Inject(LOCALE_ID)),
5116 __metadata("design:paramtypes", [String])
5117 ], DeprecatedDatePipe);
5118 return DeprecatedDatePipe;
5119}());
5120function isDate$1(value) {
5121 return value instanceof Date && !isNaN(value.valueOf());
5122}
5123
5124/**
5125 * @license
5126 * Copyright Google Inc. All Rights Reserved.
5127 *
5128 * Use of this source code is governed by an MIT-style license that can be
5129 * found in the LICENSE file at https://angular.io/license
5130 */
5131function formatNumber$1(pipe, locale, value, style, digits, currency, currencyAsSymbol) {
5132 if (currency === void 0) { currency = null; }
5133 if (currencyAsSymbol === void 0) { currencyAsSymbol = false; }
5134 if (value == null)
5135 return null;
5136 // Convert strings to numbers
5137 value = typeof value === 'string' && !isNaN(+value - parseFloat(value)) ? +value : value;
5138 if (typeof value !== 'number') {
5139 throw invalidPipeArgumentError(pipe, value);
5140 }
5141 var minInt;
5142 var minFraction;
5143 var maxFraction;
5144 if (style !== NumberFormatStyle.Currency) {
5145 // rely on Intl default for currency
5146 minInt = 1;
5147 minFraction = 0;
5148 maxFraction = 3;
5149 }
5150 if (digits) {
5151 var parts = digits.match(NUMBER_FORMAT_REGEXP);
5152 if (parts === null) {
5153 throw new Error(digits + " is not a valid digit info for number pipes");
5154 }
5155 if (parts[1] != null) { // min integer digits
5156 minInt = parseIntAutoRadix(parts[1]);
5157 }
5158 if (parts[3] != null) { // min fraction digits
5159 minFraction = parseIntAutoRadix(parts[3]);
5160 }
5161 if (parts[5] != null) { // max fraction digits
5162 maxFraction = parseIntAutoRadix(parts[5]);
5163 }
5164 }
5165 return NumberFormatter.format(value, locale, style, {
5166 minimumIntegerDigits: minInt,
5167 minimumFractionDigits: minFraction,
5168 maximumFractionDigits: maxFraction,
5169 currency: currency,
5170 currencyAsSymbol: currencyAsSymbol,
5171 });
5172}
5173/**
5174 * Formats a number as text. Group sizing and separator and other locale-specific
5175 * configurations are based on the active locale.
5176 *
5177 * where `expression` is a number:
5178 * - `digitInfo` is a `string` which has a following format: <br>
5179 * <code>{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}</code>
5180 * - `minIntegerDigits` is the minimum number of integer digits to use. Defaults to `1`.
5181 * - `minFractionDigits` is the minimum number of digits after fraction. Defaults to `0`.
5182 * - `maxFractionDigits` is the maximum number of digits after fraction. Defaults to `3`.
5183 *
5184 * For more information on the acceptable range for each of these numbers and other
5185 * details see your native internationalization library.
5186 *
5187 * WARNING: this pipe uses the Internationalization API which is not yet available in all browsers
5188 * and may require a polyfill. See [Browser Support](guide/browser-support) for details.
5189 *
5190 * @usageNotes
5191 *
5192 * ### Example
5193 *
5194 * {@example common/pipes/ts/number_pipe.ts region='DeprecatedNumberPipe'}
5195 *
5196 * @ngModule CommonModule
5197 * @publicApi
5198 */
5199var DeprecatedDecimalPipe = /** @class */ (function () {
5200 function DeprecatedDecimalPipe(_locale) {
5201 this._locale = _locale;
5202 }
5203 DeprecatedDecimalPipe_1 = DeprecatedDecimalPipe;
5204 DeprecatedDecimalPipe.prototype.transform = function (value, digits) {
5205 return formatNumber$1(DeprecatedDecimalPipe_1, this._locale, value, NumberFormatStyle.Decimal, digits);
5206 };
5207 var DeprecatedDecimalPipe_1;
5208 DeprecatedDecimalPipe = DeprecatedDecimalPipe_1 = __decorate([
5209 Pipe({ name: 'number' }),
5210 __param(0, Inject(LOCALE_ID)),
5211 __metadata("design:paramtypes", [String])
5212 ], DeprecatedDecimalPipe);
5213 return DeprecatedDecimalPipe;
5214}());
5215/**
5216 * @ngModule CommonModule
5217 *
5218 * @description
5219 *
5220 * Formats a number as percentage according to locale rules.
5221 *
5222 * - `digitInfo` See {@link DecimalPipe} for detailed description.
5223 *
5224 * WARNING: this pipe uses the Internationalization API which is not yet available in all browsers
5225 * and may require a polyfill. See [Browser Support](guide/browser-support) for details.
5226 *
5227 * @usageNotes
5228 *
5229 * ### Example
5230 *
5231 * {@example common/pipes/ts/percent_pipe.ts region='DeprecatedPercentPipe'}
5232 *
5233 * @publicApi
5234 */
5235var DeprecatedPercentPipe = /** @class */ (function () {
5236 function DeprecatedPercentPipe(_locale) {
5237 this._locale = _locale;
5238 }
5239 DeprecatedPercentPipe_1 = DeprecatedPercentPipe;
5240 DeprecatedPercentPipe.prototype.transform = function (value, digits) {
5241 return formatNumber$1(DeprecatedPercentPipe_1, this._locale, value, NumberFormatStyle.Percent, digits);
5242 };
5243 var DeprecatedPercentPipe_1;
5244 DeprecatedPercentPipe = DeprecatedPercentPipe_1 = __decorate([
5245 Pipe({ name: 'percent' }),
5246 __param(0, Inject(LOCALE_ID)),
5247 __metadata("design:paramtypes", [String])
5248 ], DeprecatedPercentPipe);
5249 return DeprecatedPercentPipe;
5250}());
5251/**
5252 * @ngModule CommonModule
5253 * @description
5254 *
5255 * Formats a number as currency using locale rules.
5256 *
5257 * Use `currency` to format a number as currency.
5258 *
5259 * - `currencyCode` is the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code, such
5260 * as `USD` for the US dollar and `EUR` for the euro.
5261 * - `symbolDisplay` is a boolean indicating whether to use the currency symbol or code.
5262 * - `true`: use symbol (e.g. `$`).
5263 * - `false`(default): use code (e.g. `USD`).
5264 * - `digitInfo` See {@link DecimalPipe} for detailed description.
5265 *
5266 * WARNING: this pipe uses the Internationalization API which is not yet available in all browsers
5267 * and may require a polyfill. See [Browser Support](guide/browser-support) for details.
5268 *
5269 * @usageNotes
5270 *
5271 * ### Example
5272 *
5273 * {@example common/pipes/ts/currency_pipe.ts region='DeprecatedCurrencyPipe'}
5274 *
5275 * @publicApi
5276 */
5277var DeprecatedCurrencyPipe = /** @class */ (function () {
5278 function DeprecatedCurrencyPipe(_locale) {
5279 this._locale = _locale;
5280 }
5281 DeprecatedCurrencyPipe_1 = DeprecatedCurrencyPipe;
5282 DeprecatedCurrencyPipe.prototype.transform = function (value, currencyCode, symbolDisplay, digits) {
5283 if (currencyCode === void 0) { currencyCode = 'USD'; }
5284 if (symbolDisplay === void 0) { symbolDisplay = false; }
5285 return formatNumber$1(DeprecatedCurrencyPipe_1, this._locale, value, NumberFormatStyle.Currency, digits, currencyCode, symbolDisplay);
5286 };
5287 var DeprecatedCurrencyPipe_1;
5288 DeprecatedCurrencyPipe = DeprecatedCurrencyPipe_1 = __decorate([
5289 Pipe({ name: 'currency' }),
5290 __param(0, Inject(LOCALE_ID)),
5291 __metadata("design:paramtypes", [String])
5292 ], DeprecatedCurrencyPipe);
5293 return DeprecatedCurrencyPipe;
5294}());
5295
5296/**
5297 * @license
5298 * Copyright Google Inc. All Rights Reserved.
5299 *
5300 * Use of this source code is governed by an MIT-style license that can be
5301 * found in the LICENSE file at https://angular.io/license
5302 */
5303/**
5304 * A collection of deprecated i18n pipes that require intl api
5305 *
5306 * @deprecated from v5
5307 */
5308var COMMON_DEPRECATED_I18N_PIPES = [DeprecatedDecimalPipe, DeprecatedPercentPipe, DeprecatedCurrencyPipe, DeprecatedDatePipe];
5309
5310/**
5311 * @license
5312 * Copyright Google Inc. All Rights Reserved.
5313 *
5314 * Use of this source code is governed by an MIT-style license that can be
5315 * found in the LICENSE file at https://angular.io/license
5316 */
5317var ObservableStrategy = /** @class */ (function () {
5318 function ObservableStrategy() {
5319 }
5320 ObservableStrategy.prototype.createSubscription = function (async, updateLatestValue) {
5321 return async.subscribe({ next: updateLatestValue, error: function (e) { throw e; } });
5322 };
5323 ObservableStrategy.prototype.dispose = function (subscription) { subscription.unsubscribe(); };
5324 ObservableStrategy.prototype.onDestroy = function (subscription) { subscription.unsubscribe(); };
5325 return ObservableStrategy;
5326}());
5327var PromiseStrategy = /** @class */ (function () {
5328 function PromiseStrategy() {
5329 }
5330 PromiseStrategy.prototype.createSubscription = function (async, updateLatestValue) {
5331 return async.then(updateLatestValue, function (e) { throw e; });
5332 };
5333 PromiseStrategy.prototype.dispose = function (subscription) { };
5334 PromiseStrategy.prototype.onDestroy = function (subscription) { };
5335 return PromiseStrategy;
5336}());
5337var _promiseStrategy = new PromiseStrategy();
5338var _observableStrategy = new ObservableStrategy();
5339/**
5340 * @ngModule CommonModule
5341 * @description
5342 *
5343 * Unwraps a value from an asynchronous primitive.
5344 *
5345 * The `async` pipe subscribes to an `Observable` or `Promise` and returns the latest value it has
5346 * emitted. When a new value is emitted, the `async` pipe marks the component to be checked for
5347 * changes. When the component gets destroyed, the `async` pipe unsubscribes automatically to avoid
5348 * potential memory leaks.
5349 *
5350 * @usageNotes
5351 *
5352 * ### Examples
5353 *
5354 * This example binds a `Promise` to the view. Clicking the `Resolve` button resolves the
5355 * promise.
5356 *
5357 * {@example common/pipes/ts/async_pipe.ts region='AsyncPipePromise'}
5358 *
5359 * It's also possible to use `async` with Observables. The example below binds the `time` Observable
5360 * to the view. The Observable continuously updates the view with the current time.
5361 *
5362 * {@example common/pipes/ts/async_pipe.ts region='AsyncPipeObservable'}
5363 *
5364 * @publicApi
5365 */
5366var AsyncPipe = /** @class */ (function () {
5367 function AsyncPipe(_ref) {
5368 this._ref = _ref;
5369 this._latestValue = null;
5370 this._latestReturnedValue = null;
5371 this._subscription = null;
5372 this._obj = null;
5373 this._strategy = null;
5374 }
5375 AsyncPipe_1 = AsyncPipe;
5376 AsyncPipe.prototype.ngOnDestroy = function () {
5377 if (this._subscription) {
5378 this._dispose();
5379 }
5380 };
5381 AsyncPipe.prototype.transform = function (obj) {
5382 if (!this._obj) {
5383 if (obj) {
5384 this._subscribe(obj);
5385 }
5386 this._latestReturnedValue = this._latestValue;
5387 return this._latestValue;
5388 }
5389 if (obj !== this._obj) {
5390 this._dispose();
5391 return this.transform(obj);
5392 }
5393 if (ɵlooseIdentical(this._latestValue, this._latestReturnedValue)) {
5394 return this._latestReturnedValue;
5395 }
5396 this._latestReturnedValue = this._latestValue;
5397 return WrappedValue.wrap(this._latestValue);
5398 };
5399 AsyncPipe.prototype._subscribe = function (obj) {
5400 var _this = this;
5401 this._obj = obj;
5402 this._strategy = this._selectStrategy(obj);
5403 this._subscription = this._strategy.createSubscription(obj, function (value) { return _this._updateLatestValue(obj, value); });
5404 };
5405 AsyncPipe.prototype._selectStrategy = function (obj) {
5406 if (ɵisPromise(obj)) {
5407 return _promiseStrategy;
5408 }
5409 if (ɵisObservable(obj)) {
5410 return _observableStrategy;
5411 }
5412 throw invalidPipeArgumentError(AsyncPipe_1, obj);
5413 };
5414 AsyncPipe.prototype._dispose = function () {
5415 this._strategy.dispose(this._subscription);
5416 this._latestValue = null;
5417 this._latestReturnedValue = null;
5418 this._subscription = null;
5419 this._obj = null;
5420 };
5421 AsyncPipe.prototype._updateLatestValue = function (async, value) {
5422 if (async === this._obj) {
5423 this._latestValue = value;
5424 this._ref.markForCheck();
5425 }
5426 };
5427 var AsyncPipe_1;
5428 AsyncPipe = AsyncPipe_1 = __decorate([
5429 Injectable(),
5430 Pipe({ name: 'async', pure: false }),
5431 __metadata("design:paramtypes", [ChangeDetectorRef])
5432 ], AsyncPipe);
5433 return AsyncPipe;
5434}());
5435
5436/**
5437 * @license
5438 * Copyright Google Inc. All Rights Reserved.
5439 *
5440 * Use of this source code is governed by an MIT-style license that can be
5441 * found in the LICENSE file at https://angular.io/license
5442 */
5443/**
5444 * Transforms text to all lower case.
5445 *
5446 * @see `UpperCasePipe`
5447 * @see `TitleCasePipe`
5448 * @usageNotes
5449 *
5450 * The following example defines a view that allows the user to enter
5451 * text, and then uses the pipe to convert the input text to all lower case.
5452 *
5453 * <code-example path="common/pipes/ts/lowerupper_pipe.ts" region='LowerUpperPipe'></code-example>
5454 *
5455 * @ngModule CommonModule
5456 * @publicApi
5457 */
5458var LowerCasePipe = /** @class */ (function () {
5459 function LowerCasePipe() {
5460 }
5461 LowerCasePipe_1 = LowerCasePipe;
5462 /**
5463 * @param value The string to transform to lower case.
5464 */
5465 LowerCasePipe.prototype.transform = function (value) {
5466 if (!value)
5467 return value;
5468 if (typeof value !== 'string') {
5469 throw invalidPipeArgumentError(LowerCasePipe_1, value);
5470 }
5471 return value.toLowerCase();
5472 };
5473 var LowerCasePipe_1;
5474 LowerCasePipe = LowerCasePipe_1 = __decorate([
5475 Injectable(),
5476 Pipe({ name: 'lowercase' })
5477 ], LowerCasePipe);
5478 return LowerCasePipe;
5479}());
5480//
5481// Regex below matches any Unicode word and compatible with ES5. In ES2018 the same result
5482// can be achieved by using /\p{L}\S*/gu and also known as Unicode Property Escapes
5483// (http://2ality.com/2017/07/regexp-unicode-property-escapes.html). Since there is no
5484// transpilation of this functionality down to ES5 without external tool, the only solution is
5485// to use already transpiled form. Example can be found here -
5486// https://mothereff.in/regexpu#input=var+regex+%3D+/%5Cp%7BL%7D/u%3B&unicodePropertyEscape=1
5487//
5488var unicodeWordMatch = /(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D])\S*/g;
5489/**
5490 * Transforms text to title case.
5491 * Capitalizes the first letter of each word, and transforms the
5492 * rest of the word to lower case.
5493 * Words are delimited by any whitespace character, such as a space, tab, or line-feed character.
5494 *
5495 * @see `LowerCasePipe`
5496 * @see `UpperCasePipe`
5497 *
5498 * @usageNotes
5499 * The following example shows the result of transforming various strings into title case.
5500 *
5501 * <code-example path="common/pipes/ts/titlecase_pipe.ts" region='TitleCasePipe'></code-example>
5502 *
5503 * @ngModule CommonModule
5504 * @publicApi
5505 */
5506var TitleCasePipe = /** @class */ (function () {
5507 function TitleCasePipe() {
5508 }
5509 TitleCasePipe_1 = TitleCasePipe;
5510 /**
5511 * @param value The string to transform to title case.
5512 */
5513 TitleCasePipe.prototype.transform = function (value) {
5514 if (!value)
5515 return value;
5516 if (typeof value !== 'string') {
5517 throw invalidPipeArgumentError(TitleCasePipe_1, value);
5518 }
5519 return value.replace(unicodeWordMatch, (function (txt) { return txt[0].toUpperCase() + txt.substr(1).toLowerCase(); }));
5520 };
5521 var TitleCasePipe_1;
5522 TitleCasePipe = TitleCasePipe_1 = __decorate([
5523 Injectable(),
5524 Pipe({ name: 'titlecase' })
5525 ], TitleCasePipe);
5526 return TitleCasePipe;
5527}());
5528/**
5529 * Transforms text to all upper case.
5530 * @see `LowerCasePipe`
5531 * @see `TitleCasePipe`
5532 *
5533 * @ngModule CommonModule
5534 * @publicApi
5535 */
5536var UpperCasePipe = /** @class */ (function () {
5537 function UpperCasePipe() {
5538 }
5539 UpperCasePipe_1 = UpperCasePipe;
5540 /**
5541 * @param value The string to transform to upper case.
5542 */
5543 UpperCasePipe.prototype.transform = function (value) {
5544 if (!value)
5545 return value;
5546 if (typeof value !== 'string') {
5547 throw invalidPipeArgumentError(UpperCasePipe_1, value);
5548 }
5549 return value.toUpperCase();
5550 };
5551 var UpperCasePipe_1;
5552 UpperCasePipe = UpperCasePipe_1 = __decorate([
5553 Injectable(),
5554 Pipe({ name: 'uppercase' })
5555 ], UpperCasePipe);
5556 return UpperCasePipe;
5557}());
5558
5559/**
5560 * @license
5561 * Copyright Google Inc. All Rights Reserved.
5562 *
5563 * Use of this source code is governed by an MIT-style license that can be
5564 * found in the LICENSE file at https://angular.io/license
5565 */
5566// clang-format off
5567/**
5568 * @ngModule CommonModule
5569 * @description
5570 *
5571 * Formats a date value according to locale rules.
5572 *
5573 * Only the `en-US` locale data comes with Angular. To localize dates
5574 * in another language, you must import the corresponding locale data.
5575 * See the [I18n guide](guide/i18n#i18n-pipes) for more information.
5576 *
5577 * @see `formatDate()`
5578 *
5579 *
5580 * @usageNotes
5581 *
5582 * The result of this pipe is not reevaluated when the input is mutated. To avoid the need to
5583 * reformat the date on every change-detection cycle, treat the date as an immutable object
5584 * and change the reference when the pipe needs to run again.
5585 *
5586 * ### Pre-defined format options
5587 *
5588 * Examples are given in `en-US` locale.
5589 *
5590 * - `'short'`: equivalent to `'M/d/yy, h:mm a'` (`6/15/15, 9:03 AM`).
5591 * - `'medium'`: equivalent to `'MMM d, y, h:mm:ss a'` (`Jun 15, 2015, 9:03:01 AM`).
5592 * - `'long'`: equivalent to `'MMMM d, y, h:mm:ss a z'` (`June 15, 2015 at 9:03:01 AM
5593 * GMT+1`).
5594 * - `'full'`: equivalent to `'EEEE, MMMM d, y, h:mm:ss a zzzz'` (`Monday, June 15, 2015 at
5595 * 9:03:01 AM GMT+01:00`).
5596 * - `'shortDate'`: equivalent to `'M/d/yy'` (`6/15/15`).
5597 * - `'mediumDate'`: equivalent to `'MMM d, y'` (`Jun 15, 2015`).
5598 * - `'longDate'`: equivalent to `'MMMM d, y'` (`June 15, 2015`).
5599 * - `'fullDate'`: equivalent to `'EEEE, MMMM d, y'` (`Monday, June 15, 2015`).
5600 * - `'shortTime'`: equivalent to `'h:mm a'` (`9:03 AM`).
5601 * - `'mediumTime'`: equivalent to `'h:mm:ss a'` (`9:03:01 AM`).
5602 * - `'longTime'`: equivalent to `'h:mm:ss a z'` (`9:03:01 AM GMT+1`).
5603 * - `'fullTime'`: equivalent to `'h:mm:ss a zzzz'` (`9:03:01 AM GMT+01:00`).
5604 *
5605 * ### Custom format options
5606 *
5607 * You can construct a format string using symbols to specify the components
5608 * of a date-time value, as described in the following table.
5609 * Format details depend on the locale.
5610 * Fields marked with (*) are only available in the extra data set for the given locale.
5611 *
5612 * | Field type | Format | Description | Example Value |
5613 * |--------------------|-------------|---------------------------------------------------------------|------------------------------------------------------------|
5614 * | Era | G, GG & GGG | Abbreviated | AD |
5615 * | | GGGG | Wide | Anno Domini |
5616 * | | GGGGG | Narrow | A |
5617 * | Year | y | Numeric: minimum digits | 2, 20, 201, 2017, 20173 |
5618 * | | yy | Numeric: 2 digits + zero padded | 02, 20, 01, 17, 73 |
5619 * | | yyy | Numeric: 3 digits + zero padded | 002, 020, 201, 2017, 20173 |
5620 * | | yyyy | Numeric: 4 digits or more + zero padded | 0002, 0020, 0201, 2017, 20173 |
5621 * | Month | M | Numeric: 1 digit | 9, 12 |
5622 * | | MM | Numeric: 2 digits + zero padded | 09, 12 |
5623 * | | MMM | Abbreviated | Sep |
5624 * | | MMMM | Wide | September |
5625 * | | MMMMM | Narrow | S |
5626 * | Month standalone | L | Numeric: 1 digit | 9, 12 |
5627 * | | LL | Numeric: 2 digits + zero padded | 09, 12 |
5628 * | | LLL | Abbreviated | Sep |
5629 * | | LLLL | Wide | September |
5630 * | | LLLLL | Narrow | S |
5631 * | Week of year | w | Numeric: minimum digits | 1... 53 |
5632 * | | ww | Numeric: 2 digits + zero padded | 01... 53 |
5633 * | Week of month | W | Numeric: 1 digit | 1... 5 |
5634 * | Day of month | d | Numeric: minimum digits | 1 |
5635 * | | dd | Numeric: 2 digits + zero padded | 01 |
5636 * | Week day | E, EE & EEE | Abbreviated | Tue |
5637 * | | EEEE | Wide | Tuesday |
5638 * | | EEEEE | Narrow | T |
5639 * | | EEEEEE | Short | Tu |
5640 * | Period | a, aa & aaa | Abbreviated | am/pm or AM/PM |
5641 * | | aaaa | Wide (fallback to `a` when missing) | ante meridiem/post meridiem |
5642 * | | aaaaa | Narrow | a/p |
5643 * | Period* | B, BB & BBB | Abbreviated | mid. |
5644 * | | BBBB | Wide | am, pm, midnight, noon, morning, afternoon, evening, night |
5645 * | | BBBBB | Narrow | md |
5646 * | Period standalone* | b, bb & bbb | Abbreviated | mid. |
5647 * | | bbbb | Wide | am, pm, midnight, noon, morning, afternoon, evening, night |
5648 * | | bbbbb | Narrow | md |
5649 * | Hour 1-12 | h | Numeric: minimum digits | 1, 12 |
5650 * | | hh | Numeric: 2 digits + zero padded | 01, 12 |
5651 * | Hour 0-23 | H | Numeric: minimum digits | 0, 23 |
5652 * | | HH | Numeric: 2 digits + zero padded | 00, 23 |
5653 * | Minute | m | Numeric: minimum digits | 8, 59 |
5654 * | | mm | Numeric: 2 digits + zero padded | 08, 59 |
5655 * | Second | s | Numeric: minimum digits | 0... 59 |
5656 * | | ss | Numeric: 2 digits + zero padded | 00... 59 |
5657 * | Fractional seconds | S | Numeric: 1 digit | 0... 9 |
5658 * | | SS | Numeric: 2 digits + zero padded | 00... 99 |
5659 * | | SSS | Numeric: 3 digits + zero padded (= milliseconds) | 000... 999 |
5660 * | Zone | z, zz & zzz | Short specific non location format (fallback to O) | GMT-8 |
5661 * | | zzzz | Long specific non location format (fallback to OOOO) | GMT-08:00 |
5662 * | | Z, ZZ & ZZZ | ISO8601 basic format | -0800 |
5663 * | | ZZZZ | Long localized GMT format | GMT-8:00 |
5664 * | | ZZZZZ | ISO8601 extended format + Z indicator for offset 0 (= XXXXX) | -08:00 |
5665 * | | O, OO & OOO | Short localized GMT format | GMT-8 |
5666 * | | OOOO | Long localized GMT format | GMT-08:00 |
5667 *
5668 * Note that timezone correction is not applied to an ISO string that has no time component, such as "2016-09-19"
5669 *
5670 * ### Format examples
5671 *
5672 * These examples transform a date into various formats,
5673 * assuming that `dateObj` is a JavaScript `Date` object for
5674 * year: 2015, month: 6, day: 15, hour: 21, minute: 43, second: 11,
5675 * given in the local time for the `en-US` locale.
5676 *
5677 * ```
5678 * {{ dateObj | date }} // output is 'Jun 15, 2015'
5679 * {{ dateObj | date:'medium' }} // output is 'Jun 15, 2015, 9:43:11 PM'
5680 * {{ dateObj | date:'shortTime' }} // output is '9:43 PM'
5681 * {{ dateObj | date:'mm:ss' }} // output is '43:11'
5682 * ```
5683 *
5684 * ### Usage example
5685 *
5686 * The following component uses a date pipe to display the current date in different formats.
5687 *
5688 * ```
5689 * @Component({
5690 * selector: 'date-pipe',
5691 * template: `<div>
5692 * <p>Today is {{today | date}}</p>
5693 * <p>Or if you prefer, {{today | date:'fullDate'}}</p>
5694 * <p>The time is {{today | date:'h:mm a z'}}</p>
5695 * </div>`
5696 * })
5697 * // Get the current date and time as a date-time value.
5698 * export class DatePipeComponent {
5699 * today: number = Date.now();
5700 * }
5701 * ```
5702 *
5703 * @publicApi
5704 */
5705// clang-format on
5706var DatePipe = /** @class */ (function () {
5707 function DatePipe(locale) {
5708 this.locale = locale;
5709 }
5710 DatePipe_1 = DatePipe;
5711 /**
5712 * @param value The date expression: a `Date` object, a number
5713 * (milliseconds since UTC epoch), or an ISO string (https://www.w3.org/TR/NOTE-datetime).
5714 * @param format The date/time components to include, using predefined options or a
5715 * custom format string.
5716 * @param timezone A timezone offset (such as `'+0430'`), or a standard
5717 * UTC/GMT or continental US timezone abbreviation. Default is
5718 * the local system timezone of the end-user's machine.
5719 * @param locale A locale code for the locale format rules to use.
5720 * When not supplied, uses the value of `LOCALE_ID`, which is `en-US` by default.
5721 * See [Setting your app locale](guide/i18n#setting-up-the-locale-of-your-app).
5722 * @returns A date string in the desired format.
5723 */
5724 DatePipe.prototype.transform = function (value, format, timezone, locale) {
5725 if (format === void 0) { format = 'mediumDate'; }
5726 if (value == null || value === '' || value !== value)
5727 return null;
5728 try {
5729 return formatDate(value, format, locale || this.locale, timezone);
5730 }
5731 catch (error) {
5732 throw invalidPipeArgumentError(DatePipe_1, error.message);
5733 }
5734 };
5735 var DatePipe_1;
5736 DatePipe = DatePipe_1 = __decorate([
5737 Injectable(),
5738 Pipe({ name: 'date', pure: true }),
5739 __param(0, Inject(LOCALE_ID)),
5740 __metadata("design:paramtypes", [String])
5741 ], DatePipe);
5742 return DatePipe;
5743}());
5744
5745/**
5746 * @license
5747 * Copyright Google Inc. All Rights Reserved.
5748 *
5749 * Use of this source code is governed by an MIT-style license that can be
5750 * found in the LICENSE file at https://angular.io/license
5751 */
5752var _INTERPOLATION_REGEXP = /#/g;
5753/**
5754 * @ngModule CommonModule
5755 * @description
5756 *
5757 * Maps a value to a string that pluralizes the value according to locale rules.
5758 *
5759 * @usageNotes
5760 *
5761 * ### Example
5762 *
5763 * {@example common/pipes/ts/i18n_pipe.ts region='I18nPluralPipeComponent'}
5764 *
5765 * @publicApi
5766 */
5767var I18nPluralPipe = /** @class */ (function () {
5768 function I18nPluralPipe(_localization) {
5769 this._localization = _localization;
5770 }
5771 I18nPluralPipe_1 = I18nPluralPipe;
5772 /**
5773 * @param value the number to be formatted
5774 * @param pluralMap an object that mimics the ICU format, see
5775 * http://userguide.icu-project.org/formatparse/messages.
5776 * @param locale a `string` defining the locale to use (uses the current {@link LOCALE_ID} by
5777 * default).
5778 */
5779 I18nPluralPipe.prototype.transform = function (value, pluralMap, locale) {
5780 if (value == null)
5781 return '';
5782 if (typeof pluralMap !== 'object' || pluralMap === null) {
5783 throw invalidPipeArgumentError(I18nPluralPipe_1, pluralMap);
5784 }
5785 var key = getPluralCategory(value, Object.keys(pluralMap), this._localization, locale);
5786 return pluralMap[key].replace(_INTERPOLATION_REGEXP, value.toString());
5787 };
5788 var I18nPluralPipe_1;
5789 I18nPluralPipe = I18nPluralPipe_1 = __decorate([
5790 Injectable(),
5791 Pipe({ name: 'i18nPlural', pure: true }),
5792 __metadata("design:paramtypes", [NgLocalization])
5793 ], I18nPluralPipe);
5794 return I18nPluralPipe;
5795}());
5796
5797/**
5798 * @license
5799 * Copyright Google Inc. All Rights Reserved.
5800 *
5801 * Use of this source code is governed by an MIT-style license that can be
5802 * found in the LICENSE file at https://angular.io/license
5803 */
5804/**
5805 * @ngModule CommonModule
5806 * @description
5807 *
5808 * Generic selector that displays the string that matches the current value.
5809 *
5810 * If none of the keys of the `mapping` match the `value`, then the content
5811 * of the `other` key is returned when present, otherwise an empty string is returned.
5812 *
5813 * @usageNotes
5814 *
5815 * ### Example
5816 *
5817 * {@example common/pipes/ts/i18n_pipe.ts region='I18nSelectPipeComponent'}
5818 *
5819 * @publicApi
5820 */
5821var I18nSelectPipe = /** @class */ (function () {
5822 function I18nSelectPipe() {
5823 }
5824 I18nSelectPipe_1 = I18nSelectPipe;
5825 /**
5826 * @param value a string to be internationalized.
5827 * @param mapping an object that indicates the text that should be displayed
5828 * for different values of the provided `value`.
5829 */
5830 I18nSelectPipe.prototype.transform = function (value, mapping) {
5831 if (value == null)
5832 return '';
5833 if (typeof mapping !== 'object' || typeof value !== 'string') {
5834 throw invalidPipeArgumentError(I18nSelectPipe_1, mapping);
5835 }
5836 if (mapping.hasOwnProperty(value)) {
5837 return mapping[value];
5838 }
5839 if (mapping.hasOwnProperty('other')) {
5840 return mapping['other'];
5841 }
5842 return '';
5843 };
5844 var I18nSelectPipe_1;
5845 I18nSelectPipe = I18nSelectPipe_1 = __decorate([
5846 Injectable(),
5847 Pipe({ name: 'i18nSelect', pure: true })
5848 ], I18nSelectPipe);
5849 return I18nSelectPipe;
5850}());
5851
5852/**
5853 * @license
5854 * Copyright Google Inc. All Rights Reserved.
5855 *
5856 * Use of this source code is governed by an MIT-style license that can be
5857 * found in the LICENSE file at https://angular.io/license
5858 */
5859/**
5860 * @ngModule CommonModule
5861 * @description
5862 *
5863 * Converts a value into its JSON-format representation. Useful for debugging.
5864 *
5865 * @usageNotes
5866 *
5867 * The following component uses a JSON pipe to convert an object
5868 * to JSON format, and displays the string in both formats for comparison.
5869 *
5870 * {@example common/pipes/ts/json_pipe.ts region='JsonPipe'}
5871 *
5872 * @publicApi
5873 */
5874var JsonPipe = /** @class */ (function () {
5875 function JsonPipe() {
5876 }
5877 /**
5878 * @param value A value of any type to convert into a JSON-format string.
5879 */
5880 JsonPipe.prototype.transform = function (value) { return JSON.stringify(value, null, 2); };
5881 JsonPipe = __decorate([
5882 Injectable(),
5883 Pipe({ name: 'json', pure: false })
5884 ], JsonPipe);
5885 return JsonPipe;
5886}());
5887
5888/**
5889 * @license
5890 * Copyright Google Inc. All Rights Reserved.
5891 *
5892 * Use of this source code is governed by an MIT-style license that can be
5893 * found in the LICENSE file at https://angular.io/license
5894 */
5895function makeKeyValuePair(key, value) {
5896 return { key: key, value: value };
5897}
5898/**
5899 * @ngModule CommonModule
5900 * @description
5901 *
5902 * Transforms Object or Map into an array of key value pairs.
5903 *
5904 * The output array will be ordered by keys.
5905 * By default the comparator will be by Unicode point value.
5906 * You can optionally pass a compareFn if your keys are complex types.
5907 *
5908 * @usageNotes
5909 * ### Examples
5910 *
5911 * This examples show how an Object or a Map can be iterated by ngFor with the use of this keyvalue
5912 * pipe.
5913 *
5914 * {@example common/pipes/ts/keyvalue_pipe.ts region='KeyValuePipe'}
5915 *
5916 * @publicApi
5917 */
5918var KeyValuePipe = /** @class */ (function () {
5919 function KeyValuePipe(differs) {
5920 this.differs = differs;
5921 this.keyValues = [];
5922 }
5923 KeyValuePipe.prototype.transform = function (input, compareFn) {
5924 var _this = this;
5925 if (compareFn === void 0) { compareFn = defaultComparator; }
5926 if (!input || (!(input instanceof Map) && typeof input !== 'object')) {
5927 return null;
5928 }
5929 if (!this.differ) {
5930 // make a differ for whatever type we've been passed in
5931 this.differ = this.differs.find(input).create();
5932 }
5933 var differChanges = this.differ.diff(input);
5934 if (differChanges) {
5935 this.keyValues = [];
5936 differChanges.forEachItem(function (r) {
5937 _this.keyValues.push(makeKeyValuePair(r.key, r.currentValue));
5938 });
5939 this.keyValues.sort(compareFn);
5940 }
5941 return this.keyValues;
5942 };
5943 KeyValuePipe = __decorate([
5944 Injectable(),
5945 Pipe({ name: 'keyvalue', pure: false }),
5946 __metadata("design:paramtypes", [KeyValueDiffers])
5947 ], KeyValuePipe);
5948 return KeyValuePipe;
5949}());
5950function defaultComparator(keyValueA, keyValueB) {
5951 var a = keyValueA.key;
5952 var b = keyValueB.key;
5953 // if same exit with 0;
5954 if (a === b)
5955 return 0;
5956 // make sure that undefined are at the end of the sort.
5957 if (a === undefined)
5958 return 1;
5959 if (b === undefined)
5960 return -1;
5961 // make sure that nulls are at the end of the sort.
5962 if (a === null)
5963 return 1;
5964 if (b === null)
5965 return -1;
5966 if (typeof a == 'string' && typeof b == 'string') {
5967 return a < b ? -1 : 1;
5968 }
5969 if (typeof a == 'number' && typeof b == 'number') {
5970 return a - b;
5971 }
5972 if (typeof a == 'boolean' && typeof b == 'boolean') {
5973 return a < b ? -1 : 1;
5974 }
5975 // `a` and `b` are of different types. Compare their string values.
5976 var aString = String(a);
5977 var bString = String(b);
5978 return aString == bString ? 0 : aString < bString ? -1 : 1;
5979}
5980
5981/**
5982 * @license
5983 * Copyright Google Inc. All Rights Reserved.
5984 *
5985 * Use of this source code is governed by an MIT-style license that can be
5986 * found in the LICENSE file at https://angular.io/license
5987 */
5988/**
5989 * @ngModule CommonModule
5990 * @description
5991 *
5992 * Transforms a number into a string,
5993 * formatted according to locale rules that determine group sizing and
5994 * separator, decimal-point character, and other locale-specific
5995 * configurations.
5996 *
5997 * If no parameters are specified, the function rounds off to the nearest value using this
5998 * [rounding method](https://en.wikibooks.org/wiki/Arithmetic/Rounding).
5999 * The behavior differs from that of the JavaScript ```Math.round()``` function.
6000 * In the following case for example, the pipe rounds down where
6001 * ```Math.round()``` rounds up:
6002 *
6003 * ```html
6004 * -2.5 | number:'1.0-0'
6005 * > -3
6006 * Math.round(-2.5)
6007 * > -2
6008 * ```
6009 *
6010 * @see `formatNumber()`
6011 *
6012 * @usageNotes
6013 * The following code shows how the pipe transforms numbers
6014 * into text strings, according to various format specifications,
6015 * where the caller's default locale is `en-US`.
6016 *
6017 * ### Example
6018 *
6019 * <code-example path="common/pipes/ts/number_pipe.ts" region='NumberPipe'></code-example>
6020 *
6021 * @publicApi
6022 */
6023var DecimalPipe = /** @class */ (function () {
6024 function DecimalPipe(_locale) {
6025 this._locale = _locale;
6026 }
6027 DecimalPipe_1 = DecimalPipe;
6028 /**
6029 * @param value The number to be formatted.
6030 * @param digitsInfo Decimal representation options, specified by a string
6031 * in the following format:<br>
6032 * <code>{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}</code>.
6033 * - `minIntegerDigits`: The minimum number of integer digits before the decimal point.
6034 * Default is `1`.
6035 * - `minFractionDigits`: The minimum number of digits after the decimal point.
6036 * Default is `0`.
6037 * - `maxFractionDigits`: The maximum number of digits after the decimal point.
6038 * Default is `3`.
6039 * @param locale A locale code for the locale format rules to use.
6040 * When not supplied, uses the value of `LOCALE_ID`, which is `en-US` by default.
6041 * See [Setting your app locale](guide/i18n#setting-up-the-locale-of-your-app).
6042 */
6043 DecimalPipe.prototype.transform = function (value, digitsInfo, locale) {
6044 if (isEmpty(value))
6045 return null;
6046 locale = locale || this._locale;
6047 try {
6048 var num = strToNumber(value);
6049 return formatNumber(num, locale, digitsInfo);
6050 }
6051 catch (error) {
6052 throw invalidPipeArgumentError(DecimalPipe_1, error.message);
6053 }
6054 };
6055 var DecimalPipe_1;
6056 DecimalPipe = DecimalPipe_1 = __decorate([
6057 Injectable(),
6058 Pipe({ name: 'number' }),
6059 __param(0, Inject(LOCALE_ID)),
6060 __metadata("design:paramtypes", [String])
6061 ], DecimalPipe);
6062 return DecimalPipe;
6063}());
6064/**
6065 * @ngModule CommonModule
6066 * @description
6067 *
6068 * Transforms a number to a percentage
6069 * string, formatted according to locale rules that determine group sizing and
6070 * separator, decimal-point character, and other locale-specific
6071 * configurations.
6072 *
6073 * @see `formatPercent()`
6074 *
6075 * @usageNotes
6076 * The following code shows how the pipe transforms numbers
6077 * into text strings, according to various format specifications,
6078 * where the caller's default locale is `en-US`.
6079 *
6080 * <code-example path="common/pipes/ts/percent_pipe.ts" region='PercentPipe'></code-example>
6081 *
6082 * @publicApi
6083 */
6084var PercentPipe = /** @class */ (function () {
6085 function PercentPipe(_locale) {
6086 this._locale = _locale;
6087 }
6088 PercentPipe_1 = PercentPipe;
6089 /**
6090 *
6091 * @param value The number to be formatted as a percentage.
6092 * @param digitsInfo Decimal representation options, specified by a string
6093 * in the following format:<br>
6094 * <code>{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}</code>.
6095 * - `minIntegerDigits`: The minimum number of integer digits before the decimal point.
6096 * Default is `1`.
6097 * - `minFractionDigits`: The minimum number of digits after the decimal point.
6098 * Default is `0`.
6099 * - `maxFractionDigits`: The maximum number of digits after the decimal point.
6100 * Default is `0`.
6101 * @param locale A locale code for the locale format rules to use.
6102 * When not supplied, uses the value of `LOCALE_ID`, which is `en-US` by default.
6103 * See [Setting your app locale](guide/i18n#setting-up-the-locale-of-your-app).
6104 */
6105 PercentPipe.prototype.transform = function (value, digitsInfo, locale) {
6106 if (isEmpty(value))
6107 return null;
6108 locale = locale || this._locale;
6109 try {
6110 var num = strToNumber(value);
6111 return formatPercent(num, locale, digitsInfo);
6112 }
6113 catch (error) {
6114 throw invalidPipeArgumentError(PercentPipe_1, error.message);
6115 }
6116 };
6117 var PercentPipe_1;
6118 PercentPipe = PercentPipe_1 = __decorate([
6119 Injectable(),
6120 Pipe({ name: 'percent' }),
6121 __param(0, Inject(LOCALE_ID)),
6122 __metadata("design:paramtypes", [String])
6123 ], PercentPipe);
6124 return PercentPipe;
6125}());
6126/**
6127 * @ngModule CommonModule
6128 * @description
6129 *
6130 * Transforms a number to a currency string, formatted according to locale rules
6131 * that determine group sizing and separator, decimal-point character,
6132 * and other locale-specific configurations.
6133 *
6134 * @see `getCurrencySymbol()`
6135 * @see `formatCurrency()`
6136 *
6137 * @usageNotes
6138 * The following code shows how the pipe transforms numbers
6139 * into text strings, according to various format specifications,
6140 * where the caller's default locale is `en-US`.
6141 *
6142 * <code-example path="common/pipes/ts/currency_pipe.ts" region='CurrencyPipe'></code-example>
6143 *
6144 * @publicApi
6145 */
6146var CurrencyPipe = /** @class */ (function () {
6147 function CurrencyPipe(_locale) {
6148 this._locale = _locale;
6149 }
6150 CurrencyPipe_1 = CurrencyPipe;
6151 /**
6152 *
6153 * @param value The number to be formatted as currency.
6154 * @param currencyCode The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code,
6155 * such as `USD` for the US dollar and `EUR` for the euro.
6156 * @param display The format for the currency indicator. One of the following:
6157 * - `code`: Show the code (such as `USD`).
6158 * - `symbol`(default): Show the symbol (such as `$`).
6159 * - `symbol-narrow`: Use the narrow symbol for locales that have two symbols for their
6160 * currency.
6161 * For example, the Canadian dollar CAD has the symbol `CA$` and the symbol-narrow `$`. If the
6162 * locale has no narrow symbol, uses the standard symbol for the locale.
6163 * - String: Use the given string value instead of a code or a symbol.
6164 * For example, an empty string will suppress the currency & symbol.
6165 * - Boolean (marked deprecated in v5): `true` for symbol and false for `code`.
6166 *
6167 * @param digitsInfo Decimal representation options, specified by a string
6168 * in the following format:<br>
6169 * <code>{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}</code>.
6170 * - `minIntegerDigits`: The minimum number of integer digits before the decimal point.
6171 * Default is `1`.
6172 * - `minFractionDigits`: The minimum number of digits after the decimal point.
6173 * Default is `2`.
6174 * - `maxFractionDigits`: The maximum number of digits after the decimal point.
6175 * Default is `2`.
6176 * If not provided, the number will be formatted with the proper amount of digits,
6177 * depending on what the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) specifies.
6178 * For example, the Canadian dollar has 2 digits, whereas the Chilean peso has none.
6179 * @param locale A locale code for the locale format rules to use.
6180 * When not supplied, uses the value of `LOCALE_ID`, which is `en-US` by default.
6181 * See [Setting your app locale](guide/i18n#setting-up-the-locale-of-your-app).
6182 */
6183 CurrencyPipe.prototype.transform = function (value, currencyCode, display, digitsInfo, locale) {
6184 if (display === void 0) { display = 'symbol'; }
6185 if (isEmpty(value))
6186 return null;
6187 locale = locale || this._locale;
6188 if (typeof display === 'boolean') {
6189 if (console && console.warn) {
6190 console.warn("Warning: the currency pipe has been changed in Angular v5. The symbolDisplay option (third parameter) is now a string instead of a boolean. The accepted values are \"code\", \"symbol\" or \"symbol-narrow\".");
6191 }
6192 display = display ? 'symbol' : 'code';
6193 }
6194 var currency = currencyCode || 'USD';
6195 if (display !== 'code') {
6196 if (display === 'symbol' || display === 'symbol-narrow') {
6197 currency = getCurrencySymbol(currency, display === 'symbol' ? 'wide' : 'narrow', locale);
6198 }
6199 else {
6200 currency = display;
6201 }
6202 }
6203 try {
6204 var num = strToNumber(value);
6205 return formatCurrency(num, locale, currency, currencyCode, digitsInfo);
6206 }
6207 catch (error) {
6208 throw invalidPipeArgumentError(CurrencyPipe_1, error.message);
6209 }
6210 };
6211 var CurrencyPipe_1;
6212 CurrencyPipe = CurrencyPipe_1 = __decorate([
6213 Injectable(),
6214 Pipe({ name: 'currency' }),
6215 __param(0, Inject(LOCALE_ID)),
6216 __metadata("design:paramtypes", [String])
6217 ], CurrencyPipe);
6218 return CurrencyPipe;
6219}());
6220function isEmpty(value) {
6221 return value == null || value === '' || value !== value;
6222}
6223/**
6224 * Transforms a string into a number (if needed).
6225 */
6226function strToNumber(value) {
6227 // Convert strings to numbers
6228 if (typeof value === 'string' && !isNaN(Number(value) - parseFloat(value))) {
6229 return Number(value);
6230 }
6231 if (typeof value !== 'number') {
6232 throw new Error(value + " is not a number");
6233 }
6234 return value;
6235}
6236
6237/**
6238 * @license
6239 * Copyright Google Inc. All Rights Reserved.
6240 *
6241 * Use of this source code is governed by an MIT-style license that can be
6242 * found in the LICENSE file at https://angular.io/license
6243 */
6244/**
6245 * @ngModule CommonModule
6246 * @description
6247 *
6248 * Creates a new `Array` or `String` containing a subset (slice) of the elements.
6249 *
6250 * @usageNotes
6251 *
6252 * All behavior is based on the expected behavior of the JavaScript API `Array.prototype.slice()`
6253 * and `String.prototype.slice()`.
6254 *
6255 * When operating on an `Array`, the returned `Array` is always a copy even when all
6256 * the elements are being returned.
6257 *
6258 * When operating on a blank value, the pipe returns the blank value.
6259 *
6260 * ### List Example
6261 *
6262 * This `ngFor` example:
6263 *
6264 * {@example common/pipes/ts/slice_pipe.ts region='SlicePipe_list'}
6265 *
6266 * produces the following:
6267 *
6268 * ```html
6269 * <li>b</li>
6270 * <li>c</li>
6271 * ```
6272 *
6273 * ### String Examples
6274 *
6275 * {@example common/pipes/ts/slice_pipe.ts region='SlicePipe_string'}
6276 *
6277 * @publicApi
6278 */
6279var SlicePipe = /** @class */ (function () {
6280 function SlicePipe() {
6281 }
6282 SlicePipe_1 = SlicePipe;
6283 SlicePipe.prototype.transform = function (value, start, end) {
6284 if (value == null)
6285 return value;
6286 if (!this.supports(value)) {
6287 throw invalidPipeArgumentError(SlicePipe_1, value);
6288 }
6289 return value.slice(start, end);
6290 };
6291 SlicePipe.prototype.supports = function (obj) { return typeof obj === 'string' || Array.isArray(obj); };
6292 var SlicePipe_1;
6293 SlicePipe = SlicePipe_1 = __decorate([
6294 Injectable(),
6295 Pipe({ name: 'slice', pure: false })
6296 ], SlicePipe);
6297 return SlicePipe;
6298}());
6299
6300/**
6301 * @license
6302 * Copyright Google Inc. All Rights Reserved.
6303 *
6304 * Use of this source code is governed by an MIT-style license that can be
6305 * found in the LICENSE file at https://angular.io/license
6306 */
6307/**
6308 * A collection of Angular pipes that are likely to be used in each and every application.
6309 */
6310var COMMON_PIPES = [
6311 AsyncPipe,
6312 UpperCasePipe,
6313 LowerCasePipe,
6314 JsonPipe,
6315 SlicePipe,
6316 DecimalPipe,
6317 PercentPipe,
6318 TitleCasePipe,
6319 CurrencyPipe,
6320 DatePipe,
6321 I18nPluralPipe,
6322 I18nSelectPipe,
6323 KeyValuePipe,
6324];
6325
6326/**
6327 * @license
6328 * Copyright Google Inc. All Rights Reserved.
6329 *
6330 * Use of this source code is governed by an MIT-style license that can be
6331 * found in the LICENSE file at https://angular.io/license
6332 */
6333// Note: This does not contain the location providers,
6334// as they need some platform specific implementations to work.
6335/**
6336 * Exports all the basic Angular directives and pipes,
6337 * such as `NgIf`, `NgForOf`, `DecimalPipe`, and so on.
6338 * Re-exported by `BrowserModule`, which is included automatically in the root
6339 * `AppModule` when you create a new app with the CLI `new` command.
6340 *
6341 * * The `providers` options configure the NgModule's injector to provide
6342 * localization dependencies to members.
6343 * * The `exports` options make the declared directives and pipes available for import
6344 * by other NgModules.
6345 *
6346 * @publicApi
6347 */
6348var CommonModule = /** @class */ (function () {
6349 function CommonModule() {
6350 }
6351 CommonModule = __decorate([
6352 NgModule({
6353 declarations: [COMMON_DIRECTIVES, COMMON_PIPES],
6354 exports: [COMMON_DIRECTIVES, COMMON_PIPES],
6355 providers: [
6356 { provide: NgLocalization, useClass: NgLocaleLocalization },
6357 ],
6358 })
6359 ], CommonModule);
6360 return CommonModule;
6361}());
6362var ɵ0$2 = getPluralCase;
6363/**
6364 * A module that contains the deprecated i18n pipes.
6365 *
6366 * @deprecated from v5
6367 * @publicApi
6368 */
6369var DeprecatedI18NPipesModule = /** @class */ (function () {
6370 function DeprecatedI18NPipesModule() {
6371 }
6372 DeprecatedI18NPipesModule = __decorate([
6373 NgModule({
6374 declarations: [COMMON_DEPRECATED_I18N_PIPES],
6375 exports: [COMMON_DEPRECATED_I18N_PIPES],
6376 providers: [{ provide: DEPRECATED_PLURAL_FN, useValue: ɵ0$2 }],
6377 })
6378 ], DeprecatedI18NPipesModule);
6379 return DeprecatedI18NPipesModule;
6380}());
6381
6382/**
6383 * @license
6384 * Copyright Google Inc. All Rights Reserved.
6385 *
6386 * Use of this source code is governed by an MIT-style license that can be
6387 * found in the LICENSE file at https://angular.io/license
6388 */
6389/**
6390 * A DI Token representing the main rendering context. In a browser this is the DOM Document.
6391 *
6392 * Note: Document might not be available in the Application Context when Application and Rendering
6393 * Contexts are not the same (e.g. when running the application into a Web Worker).
6394 *
6395 * @publicApi
6396 */
6397var DOCUMENT = new InjectionToken('DocumentToken');
6398
6399/**
6400 * @license
6401 * Copyright Google Inc. All Rights Reserved.
6402 *
6403 * Use of this source code is governed by an MIT-style license that can be
6404 * found in the LICENSE file at https://angular.io/license
6405 */
6406var PLATFORM_BROWSER_ID = 'browser';
6407var PLATFORM_SERVER_ID = 'server';
6408var PLATFORM_WORKER_APP_ID = 'browserWorkerApp';
6409var PLATFORM_WORKER_UI_ID = 'browserWorkerUi';
6410/**
6411 * Returns whether a platform id represents a browser platform.
6412 * @publicApi
6413 */
6414function isPlatformBrowser(platformId) {
6415 return platformId === PLATFORM_BROWSER_ID;
6416}
6417/**
6418 * Returns whether a platform id represents a server platform.
6419 * @publicApi
6420 */
6421function isPlatformServer(platformId) {
6422 return platformId === PLATFORM_SERVER_ID;
6423}
6424/**
6425 * Returns whether a platform id represents a web worker app platform.
6426 * @publicApi
6427 */
6428function isPlatformWorkerApp(platformId) {
6429 return platformId === PLATFORM_WORKER_APP_ID;
6430}
6431/**
6432 * Returns whether a platform id represents a web worker UI platform.
6433 * @publicApi
6434 */
6435function isPlatformWorkerUi(platformId) {
6436 return platformId === PLATFORM_WORKER_UI_ID;
6437}
6438
6439/**
6440 * @license
6441 * Copyright Google Inc. All Rights Reserved.
6442 *
6443 * Use of this source code is governed by an MIT-style license that can be
6444 * found in the LICENSE file at https://angular.io/license
6445 */
6446/**
6447 * @publicApi
6448 */
6449var VERSION = new Version('8.2.0');
6450
6451/**
6452 * @license
6453 * Copyright Google Inc. All Rights Reserved.
6454 *
6455 * Use of this source code is governed by an MIT-style license that can be
6456 * found in the LICENSE file at https://angular.io/license
6457 */
6458/**
6459 * Defines a scroll position manager. Implemented by `BrowserViewportScroller`.
6460 *
6461 * @publicApi
6462 */
6463var ViewportScroller = /** @class */ (function () {
6464 function ViewportScroller() {
6465 }
6466 // De-sugared tree-shakable injection
6467 // See #23917
6468 /** @nocollapse */
6469 ViewportScroller.ngInjectableDef = ɵɵdefineInjectable({
6470 token: ViewportScroller,
6471 providedIn: 'root',
6472 factory: function () { return new BrowserViewportScroller(ɵɵinject(DOCUMENT), window, ɵɵinject(ErrorHandler)); }
6473 });
6474 return ViewportScroller;
6475}());
6476/**
6477 * Manages the scroll position for a browser window.
6478 */
6479var BrowserViewportScroller = /** @class */ (function () {
6480 function BrowserViewportScroller(document, window, errorHandler) {
6481 this.document = document;
6482 this.window = window;
6483 this.errorHandler = errorHandler;
6484 this.offset = function () { return [0, 0]; };
6485 }
6486 /**
6487 * Configures the top offset used when scrolling to an anchor.
6488 * @param offset A position in screen coordinates (a tuple with x and y values)
6489 * or a function that returns the top offset position.
6490 *
6491 */
6492 BrowserViewportScroller.prototype.setOffset = function (offset) {
6493 if (Array.isArray(offset)) {
6494 this.offset = function () { return offset; };
6495 }
6496 else {
6497 this.offset = offset;
6498 }
6499 };
6500 /**
6501 * Retrieves the current scroll position.
6502 * @returns The position in screen coordinates.
6503 */
6504 BrowserViewportScroller.prototype.getScrollPosition = function () {
6505 if (this.supportScrollRestoration()) {
6506 return [this.window.scrollX, this.window.scrollY];
6507 }
6508 else {
6509 return [0, 0];
6510 }
6511 };
6512 /**
6513 * Sets the scroll position.
6514 * @param position The new position in screen coordinates.
6515 */
6516 BrowserViewportScroller.prototype.scrollToPosition = function (position) {
6517 if (this.supportScrollRestoration()) {
6518 this.window.scrollTo(position[0], position[1]);
6519 }
6520 };
6521 /**
6522 * Scrolls to an anchor element.
6523 * @param anchor The ID of the anchor element.
6524 */
6525 BrowserViewportScroller.prototype.scrollToAnchor = function (anchor) {
6526 if (this.supportScrollRestoration()) {
6527 // Escape anything passed to `querySelector` as it can throw errors and stop the application
6528 // from working if invalid values are passed.
6529 if (this.window.CSS && this.window.CSS.escape) {
6530 anchor = this.window.CSS.escape(anchor);
6531 }
6532 else {
6533 anchor = anchor.replace(/(\"|\'\ |:|\.|\[|\]|,|=)/g, '\\$1');
6534 }
6535 try {
6536 var elSelectedById = this.document.querySelector("#" + anchor);
6537 if (elSelectedById) {
6538 this.scrollToElement(elSelectedById);
6539 return;
6540 }
6541 var elSelectedByName = this.document.querySelector("[name='" + anchor + "']");
6542 if (elSelectedByName) {
6543 this.scrollToElement(elSelectedByName);
6544 return;
6545 }
6546 }
6547 catch (e) {
6548 this.errorHandler.handleError(e);
6549 }
6550 }
6551 };
6552 /**
6553 * Disables automatic scroll restoration provided by the browser.
6554 */
6555 BrowserViewportScroller.prototype.setHistoryScrollRestoration = function (scrollRestoration) {
6556 if (this.supportScrollRestoration()) {
6557 var history_1 = this.window.history;
6558 if (history_1 && history_1.scrollRestoration) {
6559 history_1.scrollRestoration = scrollRestoration;
6560 }
6561 }
6562 };
6563 BrowserViewportScroller.prototype.scrollToElement = function (el) {
6564 var rect = el.getBoundingClientRect();
6565 var left = rect.left + this.window.pageXOffset;
6566 var top = rect.top + this.window.pageYOffset;
6567 var offset = this.offset();
6568 this.window.scrollTo(left - offset[0], top - offset[1]);
6569 };
6570 /**
6571 * We only support scroll restoration when we can get a hold of window.
6572 * This means that we do not support this behavior when running in a web worker.
6573 *
6574 * Lifting this restriction right now would require more changes in the dom adapter.
6575 * Since webworkers aren't widely used, we will lift it once RouterScroller is
6576 * battle-tested.
6577 */
6578 BrowserViewportScroller.prototype.supportScrollRestoration = function () {
6579 try {
6580 return !!this.window && !!this.window.scrollTo;
6581 }
6582 catch (_a) {
6583 return false;
6584 }
6585 };
6586 return BrowserViewportScroller;
6587}());
6588/**
6589 * Provides an empty implementation of the viewport scroller. This will
6590 * live in @angular/common as it will be used by both platform-server and platform-webworker.
6591 */
6592var NullViewportScroller = /** @class */ (function () {
6593 function NullViewportScroller() {
6594 }
6595 /**
6596 * Empty implementation
6597 */
6598 NullViewportScroller.prototype.setOffset = function (offset) { };
6599 /**
6600 * Empty implementation
6601 */
6602 NullViewportScroller.prototype.getScrollPosition = function () { return [0, 0]; };
6603 /**
6604 * Empty implementation
6605 */
6606 NullViewportScroller.prototype.scrollToPosition = function (position) { };
6607 /**
6608 * Empty implementation
6609 */
6610 NullViewportScroller.prototype.scrollToAnchor = function (anchor) { };
6611 /**
6612 * Empty implementation
6613 */
6614 NullViewportScroller.prototype.setHistoryScrollRestoration = function (scrollRestoration) { };
6615 return NullViewportScroller;
6616}());
6617
6618/**
6619 * @license
6620 * Copyright Google Inc. All Rights Reserved.
6621 *
6622 * Use of this source code is governed by an MIT-style license that can be
6623 * found in the LICENSE file at https://angular.io/license
6624 */
6625
6626/**
6627 * @license
6628 * Copyright Google Inc. All Rights Reserved.
6629 *
6630 * Use of this source code is governed by an MIT-style license that can be
6631 * found in the LICENSE file at https://angular.io/license
6632 */
6633// This file only reexports content of the `src` folder. Keep it that way.
6634
6635/**
6636 * @license
6637 * Copyright Google Inc. All Rights Reserved.
6638 *
6639 * Use of this source code is governed by an MIT-style license that can be
6640 * found in the LICENSE file at https://angular.io/license
6641 */
6642
6643/**
6644 * Generated bundle index. Do not edit.
6645 */
6646
6647export { COMMON_DIRECTIVES as ɵangular_packages_common_common_c, NgClassImplProvider as ɵangular_packages_common_common_h, NgClassImplProvider__PRE_R3__ as ɵangular_packages_common_common_g, NgClassR3Impl as ɵangular_packages_common_common_f, NgStyleImplProvider as ɵangular_packages_common_common_k, NgStyleImplProvider__PRE_R3__ as ɵangular_packages_common_common_j, NgStyleR3Impl as ɵangular_packages_common_common_i, DEPRECATED_PLURAL_FN as ɵangular_packages_common_common_a, getPluralCase as ɵangular_packages_common_common_b, COMMON_DEPRECATED_I18N_PIPES as ɵangular_packages_common_common_e, COMMON_PIPES as ɵangular_packages_common_common_d, registerLocaleData as ɵregisterLocaleData, registerLocaleData, formatDate, formatCurrency, formatNumber, formatPercent, NgLocaleLocalization, NgLocalization, Plural, NumberFormatStyle, FormStyle, TranslationWidth, FormatWidth, NumberSymbol, WeekDay, getNumberOfCurrencyDigits, getCurrencySymbol, getLocaleDayPeriods, getLocaleDayNames, getLocaleMonthNames, getLocaleId, getLocaleEraNames, getLocaleWeekEndRange, getLocaleFirstDayOfWeek, getLocaleDateFormat, getLocaleDateTimeFormat, getLocaleExtraDayPeriodRules, getLocaleExtraDayPeriods, getLocalePluralCase, getLocaleTimeFormat, getLocaleNumberSymbol, getLocaleNumberFormat, getLocaleCurrencyName, getLocaleCurrencySymbol, parseCookieValue as ɵparseCookieValue, CommonModule, DeprecatedI18NPipesModule, NgClass, NgClassBase, NgForOf, NgForOfContext, NgIf, NgIfContext, NgPlural, NgPluralCase, NgStyle, NgStyleBase, NgSwitch, NgSwitchCase, NgSwitchDefault, NgTemplateOutlet, NgComponentOutlet, DOCUMENT, AsyncPipe, DatePipe, I18nPluralPipe, I18nSelectPipe, JsonPipe, LowerCasePipe, CurrencyPipe, DecimalPipe, PercentPipe, SlicePipe, UpperCasePipe, TitleCasePipe, KeyValuePipe, DeprecatedDatePipe, DeprecatedCurrencyPipe, DeprecatedDecimalPipe, DeprecatedPercentPipe, PLATFORM_BROWSER_ID as ɵPLATFORM_BROWSER_ID, PLATFORM_SERVER_ID as ɵPLATFORM_SERVER_ID, PLATFORM_WORKER_APP_ID as ɵPLATFORM_WORKER_APP_ID, PLATFORM_WORKER_UI_ID as ɵPLATFORM_WORKER_UI_ID, isPlatformBrowser, isPlatformServer, isPlatformWorkerApp, isPlatformWorkerUi, VERSION, ViewportScroller, NullViewportScroller as ɵNullViewportScroller, NgClassImplProvider__POST_R3__ as ɵNgClassImplProvider__POST_R3__, NgClassR2Impl as ɵNgClassR2Impl, NgClassImpl as ɵNgClassImpl, NgStyleImplProvider__POST_R3__ as ɵNgStyleImplProvider__POST_R3__, NgStyleR2Impl as ɵNgStyleR2Impl, NgStyleImpl as ɵNgStyleImpl, ngStyleDirectiveDef__POST_R3__ as ɵngStyleDirectiveDef__POST_R3__, ngClassDirectiveDef__POST_R3__ as ɵngClassDirectiveDef__POST_R3__, PlatformLocation, LOCATION_INITIALIZED, LocationStrategy, APP_BASE_HREF, HashLocationStrategy, PathLocationStrategy, Location };
6648//# sourceMappingURL=common.js.map