import { Directive, Input, Output, EventEmitter } from '@angular/core'; import { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion'; import { Observable, debounceTime } from 'rxjs'; import * as i0 from "@angular/core"; import * as i1 from "@angular/cdk/platform"; import * as i2 from "../ng-scrollbar-base"; export class ResizeSensor { /** Debounce interval for emitting the changes. */ get debounce() { return this._debounce; } set debounce(value) { this._debounce = coerceNumberProperty(value); this._subscribe(); } /** Whether ResizeObserver is disabled. */ get disabled() { return this._disabled; } set disabled(value) { this._disabled = coerceBooleanProperty(value); this._disabled ? this._unsubscribe() : this._subscribe(); } constructor(zone, platform, scrollbar) { this.zone = zone; this.platform = platform; this.scrollbar = scrollbar; this._disabled = false; this._currentSubscription = null; this.event = new EventEmitter(); if (!scrollbar) { throw new Error('[NgScrollbar Resize Sensor Directive]: Host element must be an NgScrollbar component.'); } } ngAfterContentInit() { if (!this._currentSubscription && !this._disabled) { this._subscribe(); } } ngOnDestroy() { this._unsubscribe(); } _subscribe() { this._unsubscribe(); if (this.platform.isBrowser) { const stream = new Observable((observer) => { this._resizeObserver = new ResizeObserver((e) => observer.next(e)); this._resizeObserver.observe(this.scrollbar.viewport.nativeElement); if (this.scrollbar.viewport.contentWrapperElement) { this._resizeObserver.observe(this.scrollbar.viewport.contentWrapperElement); } }); this.zone.runOutsideAngular(() => { this._currentSubscription = (this._debounce ? stream.pipe(debounceTime(this._debounce)) : stream).subscribe(this.event); }); } } _unsubscribe() { this._resizeObserver?.disconnect(); this._currentSubscription?.unsubscribe(); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: ResizeSensor, deps: [{ token: i0.NgZone }, { token: i1.Platform }, { token: i2.NgScrollbarBase }], target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.5", type: ResizeSensor, isStandalone: true, selector: "[resizeSensor]", inputs: { debounce: ["sensorDebounce", "debounce"], disabled: ["sensorDisabled", "disabled"] }, outputs: { event: "resizeSensor" }, ngImport: i0 }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: ResizeSensor, decorators: [{ type: Directive, args: [{ selector: '[resizeSensor]', standalone: true }] }], ctorParameters: function () { return [{ type: i0.NgZone }, { type: i1.Platform }, { type: i2.NgScrollbarBase }]; }, propDecorators: { debounce: [{ type: Input, args: ['sensorDebounce'] }], disabled: [{ type: Input, args: ['sensorDisabled'] }], event: [{ type: Output, args: ['resizeSensor'] }] } }); //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVzaXplLXNlbnNvci5kaXJlY3RpdmUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9wcm9qZWN0cy9uZ3gtc2Nyb2xsYmFyL3NyYy9saWIvcmVzaXplLXNlbnNvci9yZXNpemUtc2Vuc29yLmRpcmVjdGl2ZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsU0FBUyxFQUFFLEtBQUssRUFBRSxNQUFNLEVBQUUsWUFBWSxFQUF1QyxNQUFNLGVBQWUsQ0FBQztBQUU1RyxPQUFPLEVBQUUscUJBQXFCLEVBQUUsb0JBQW9CLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUNwRixPQUFPLEVBQUUsVUFBVSxFQUEwQixZQUFZLEVBQUUsTUFBTSxNQUFNLENBQUM7Ozs7QUEwQ3hFLE1BQU0sT0FBTyxZQUFZO0lBRXZCLGtEQUFrRDtJQUNsRCxJQUNJLFFBQVE7UUFDVixPQUFPLElBQUksQ0FBQyxTQUFTLENBQUM7SUFDeEIsQ0FBQztJQUVELElBQUksUUFBUSxDQUFDLEtBQXlCO1FBQ3BDLElBQUksQ0FBQyxTQUFTLEdBQUcsb0JBQW9CLENBQUMsS0FBSyxDQUFDLENBQUM7UUFDN0MsS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