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a,CAAC,YAAY,CAAC,CAAC;QACpE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACjC,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,sBAAI,qCAAY;aAAhB;YACE,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;QAC5B,CAAC;;;OAAA;IACH,kBAAC;AAAD,CAAC,AAlBD,IAkBC;;AAED,IAAM,kBAAkB,GAAG,IAAI,WAAW,EAAE,CAAC","sourcesContent":["/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport { stringify } from './facade/lang';\n\nimport { resolveForwardRef } from './forward_ref';\n\n/**\n * A unique object used for retrieving items from the {@link ReflectiveInjector}.\n *\n * Keys have:\n * - a system-wide unique `id`.\n * - a `token`.\n *\n * `Key` is used internally by {@link ReflectiveInjector} because its system-wide unique `id` allows\n * the\n * injector to store created objects in a more efficient way.\n *\n * `Key` should not be created directly. {@link ReflectiveInjector} creates keys automatically when\n * resolving\n * providers.\n * @experimental\n */\nexport class ReflectiveKey {\n /**\n * Private\n */\n constructor(public token: Object, public id: number) {\n if (!token) {\n throw new Error('Token must be defined!');\n }\n }\n\n /**\n * Returns a stringified token.\n */\n get displayName(): string {\n return stringify(this.token);\n }\n\n /**\n * Retrieves a `Key` for a token.\n */\n static get(token: Object): ReflectiveKey {\n // tslint:disable-next-line:no-use-before-declare\n return _globalKeyRegistry.get(resolveForwardRef(token));\n }\n\n /**\n * @returns the number of keys registered in the system.\n */\n static get numberOfKeys(): number {\n // tslint:disable-next-line:no-use-before-declare\n return _globalKeyRegistry.numberOfKeys;\n }\n}\n\n/**\n * @internal\n */\nexport class KeyRegistry {\n private _allKeys = new Map<Object, ReflectiveKey>();\n\n get(token: Object): ReflectiveKey {\n if (token instanceof ReflectiveKey) return token;\n\n if (this._allKeys.has(token)) {\n return this._allKeys.get(token)!;\n }\n\n const newKey = new ReflectiveKey(token, ReflectiveKey.numberOfKeys);\n this._allKeys.set(token, newKey);\n return newKey;\n }\n\n get numberOfKeys(): number {\n return this._allKeys.size;\n }\n}\n\nconst _globalKeyRegistry = new KeyRegistry();\n"]}
\No newline at end of file