"sourcesContent": ["import * as i0 from '@angular/core';\nimport { Injectable, EventEmitter, Directive, Output, Input, NgModule } from '@angular/core';\nimport { __decorate } from 'tslib';\nimport { InputBoolean } from 'ng-zorro-antd/core/util';\nimport { coerceElement } from '@angular/cdk/coercion';\nimport { Observable, Subject } from 'rxjs';\n\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://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n/**\n * Factory that creates a new ResizeObserver and allows us to stub it out in unit tests.\n */\nclass NzResizeObserverFactory {\n create(callback) {\n return typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(callback);\n }\n static {\n this.ɵfac = function NzResizeObserverFactory_Factory(t) {\n return new (t || NzResizeObserverFactory)();\n };\n }\n static {\n this.ɵprov = /* @__PURE__ */i0.ɵɵdefineInjectable({\n token: NzResizeObserverFactory,\n factory: NzResizeObserverFactory.ɵfac,\n providedIn: 'root'\n });\n }\n}\n(() => {\n (typeof ngDevMode === \"undefined\" || ngDevMode) && i0.ɵsetClassMetadata(NzResizeObserverFactory, [{\n type: Injectable,\n args: [{\n providedIn: 'root'\n }]\n }], null, null);\n})();\n/** An injectable service that allows watching elements for changes to their content. */\nclass NzResizeObserver {\n constructor(nzResizeObserverFactory) {\n this.nzResizeObserverFactory = nzResizeObserverFactory;\n /** Keeps track of the existing ResizeObservers so they can be reused. */\n this.observedElements = new Map();\n }\n ngOnDestroy() {\n this.observedElements.forEach((_, element) => this.cleanupObserver(element));\n }\n observe(elementOrRef) {\n const element = coerceElement(elementOrRef);\n return new Observable(observer => {\n const stream = this.observeElement(element);\n const subscription = stream.subscribe(observer);\n return () => {\n subscription.unsubscribe();\n this.unobserveElement(element);\n };\n });\n }\n /**\n * Observes the given element by using the existing ResizeObserver if available, or creating a\n * new one if not.\n */\n observeElement(element) {\n if (!this.observedElements.has(element)) {\n const stream = new Subject();\n const observer = this.nzResizeObserverFactory.create(mutations => stream.next(mutations));\n if (observer) {\n observer.observe(element);\n }\n this.observedElements.set(element, {\n observer,\n stream,\n count: 1\n });\n } else {\n this.observedElements.get(element).count++;\n }\n return this.observedElements.get(element).stream;\n }\n /**\n * Un-observes the given element and cleans up the underlying ResizeObserver if nobody else is\n * observing this element.\n */\n unobserveElement(element) {\n if (this.observedElements.has(element)) {\n this.observedElements.get(element).count--;\n if (!this.observedElements.get(element).count) {\n this.cleanupObserver(element);\n }\n }\n }\n /** Clean up the underlying ResizeObserver for the specified element. */\n cleanupObserver(element) {\n if (this.observedElements.has(element)) {\n const {\n observer,\n stream\n } = this.observedElements.get(element);\n if (observer) {\n observer.disconnect();\n }\n stream.complete();\n this.observedElements.delete(element);\n }\n }\n static {\n this.ɵfac = function NzResizeObserver_Factory(t) {\n return new (t || NzResizeObserver)(i0.ɵɵinject(NzResizeObserverFactory));\n };\n }\n static {\n this.ɵprov = /* @__PURE__ */i0.ɵɵdefineInjectable({\n token: NzResizeObserver,\n factory: NzResizeObserver.ɵfac,\n providedIn: 'root'\n });\n }\n}\n(() => {\n (typeof ngDevMode === \"undefined\" || ngDevMode) && i0.ɵsetClassMetadata(NzResizeObserver, [{\n type: Injectable,\n args: [{\n providedIn: