import { Inject, Injectable, NgZone } from '@angular/core';
import { ViewportRuler } from '@angular/cdk/overlay';
import { map } from 'rxjs/operators';
import { DOCUMENT } from '@angular/common';
import { Platform } from '@angular/cdk/platform';
import { RLayoutRulerService } from '../../services/ruler.service';
import { RLayoutScrollService } from '../../services/scroll.service';
export class RViewportRulerAdapter extends ViewportRuler {
    constructor(platform, ngZone, ruler, scroll, document) {
        super(platform, ngZone, document);
        this.ruler = ruler;
        this.scroll = scroll;
    }
    getViewportSize() {
        let res;
        /*
        * getDimensions call is really synchronous operation.
        * And we have to conform with the interface of the original service.
        * */
        this.ruler.getDimensions()
            .pipe(map(dimensions => ({ width: dimensions.clientWidth, height: dimensions.clientHeight })))
            .subscribe(rect => res = rect);
        return res;
    }
    getViewportScrollPosition() {
        let res;
        /*
        * getPosition call is really synchronous operation.
        * And we have to conform with the interface of the original service.
        * */
        this.scroll.getPosition()
            .pipe(map((position) => ({ top: position.y, left: position.x })))
            .subscribe(position => res = position);
        return res;
    }
}
RViewportRulerAdapter.decorators = [
    { type: Injectable }
];
RViewportRulerAdapter.ctorParameters = () => [
    { type: Platform },
    { type: NgZone },
    { type: RLayoutRulerService },
    { type: RLayoutScrollService },
    { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
];
//# sourceMappingURL=viewport-ruler-adapter.js.map