import { CommonModule, isPlatformBrowser } from '@angular/common';
import { NgModule, PLATFORM_ID } from '@angular/core';
import { RLayoutRulerService } from '../services/ruler.service';
import { RLayoutScrollService } from '../services/scroll.service';
import { R_THEME_OPTIONS, R_WINDOW } from './theme.options';
import { RThemeService } from './theme.service';
export function windowFactory(platformId) {
    if (isPlatformBrowser(platformId)) {
        return window;
    }
    // Provide undefined to get the error when trying to access the window as it
    // shouldn't be used outside the browser. Those who need to provide something
    // instead of window (e.g. domino window when running in node) could override
    // R_WINDOW token.
    return undefined;
}
export class RThemeModule {
    static forRoot(rThemeOptions = { name: 'default' }) {
        const module = {
            ngModule: RThemeModule,
            providers: [
                // ...ROverlayModule.forRoot().providers,
                { provide: R_THEME_OPTIONS, useValue: rThemeOptions },
                { provide: R_WINDOW, useFactory: windowFactory, deps: [PLATFORM_ID] },
                RThemeService,
                RLayoutScrollService,
                RLayoutRulerService,
            ]
        };
        return module;
    }
}
RThemeModule.decorators = [
    { type: NgModule, args: [{
                imports: [
                    CommonModule,
                ]
            },] }
];
//# sourceMappingURL=theme.module.js.map