import * as i0 from '@angular/core';
import { inject, Injectable } from '@angular/core';
import { PreviewService, NavigatorNode, hookTab, hookRoute, hookNavigator, hookPreview } from '@c8y/ngx-components';
import { TypeDashboardsListComponent } from '@c8y/ngx-components/dashboard-manager';
import { map, first } from 'rxjs';
import { gettext } from '@c8y/ngx-components/gettext';
import * as i1 from '@angular/router';

class DashboardManagerNavigationFactory {
    constructor() {
        this.previewFeatureService = inject(PreviewService);
    }
    get() {
        return this.previewFeatureService.getState$(DM_DASHBOARD_MANAGER_PREVIEW_KEY).pipe(map(state => {
            if (state) {
                return [
                    new NavigatorNode({
                        parent: gettext('Management'),
                        path: DM_DASHBOARD_MANAGER_PATH,
                        label: gettext('Dashboard manager'),
                        icon: 'management1',
                        routerLinkExact: false,
                        preventDuplicates: true,
                        featureId: 'dashboardManager'
                    })
                ];
            }
            return [];
        }));
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: DashboardManagerNavigationFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: DashboardManagerNavigationFactory }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: DashboardManagerNavigationFactory, decorators: [{
            type: Injectable
        }] });

class DashboardManagerTabsFactory {
    constructor(router) {
        this.router = router;
    }
    get() {
        const tabs = [];
        if (this.router.url.match(/\/dashboard-manager/g)) {
            tabs.push({
                path: 'dashboard-manager/type-dashboards',
                priority: 1000,
                label: gettext('Type dashboards')
            });
        }
        return tabs;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: DashboardManagerTabsFactory, deps: [{ token: i1.Router }], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: DashboardManagerTabsFactory }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: DashboardManagerTabsFactory, decorators: [{
            type: Injectable
        }], ctorParameters: () => [{ type: i1.Router }] });

const DM_DASHBOARD_MANAGER_PREVIEW_KEY = 'ui.dm-dashboard-manager';
const DM_DASHBOARD_MANAGER_PATH = 'dashboard-manager';
function canActivateDashboardManager() {
    const previewFeatureService = inject(PreviewService);
    return previewFeatureService.getState$(DM_DASHBOARD_MANAGER_PREVIEW_KEY).pipe(first());
}
const dashboardManagerFeatureProvider = [
    hookTab(DashboardManagerTabsFactory),
    hookRoute([
        {
            path: DM_DASHBOARD_MANAGER_PATH,
            redirectTo: `${DM_DASHBOARD_MANAGER_PATH}/type-dashboards`,
            pathMatch: 'full'
        },
        {
            path: `${DM_DASHBOARD_MANAGER_PATH}/type-dashboards`,
            component: TypeDashboardsListComponent,
            canActivate: [canActivateDashboardManager]
        }
    ]),
    hookNavigator(DashboardManagerNavigationFactory),
    hookPreview({
        key: DM_DASHBOARD_MANAGER_PREVIEW_KEY,
        label: 'Dashboard manager',
        description: () => import('@c8y/style/markdown-files/dm-dashboard-manager-preview.md').then(m => m.default),
        settings: { reload: true }
    })
];

/**
 * Generated bundle index. Do not edit.
 */

export { DM_DASHBOARD_MANAGER_PATH, DM_DASHBOARD_MANAGER_PREVIEW_KEY, canActivateDashboardManager, dashboardManagerFeatureProvider };
//# sourceMappingURL=c8y-ngx-components-dashboard-manager-devicemanagement.mjs.map
