import * as i0 from '@angular/core';
import { Injectable, Component, makeEnvironmentProviders } from '@angular/core';
import * as i3 from '@c8y/ngx-components/map';
import { MapModule, defaultMapConfig } from '@c8y/ngx-components/map';
import { gettext } from '@c8y/ngx-components/gettext';
import * as i2 from '@c8y/ngx-components';
import { NavigatorNode, CommonModule, CoreModule, hookRoute, hookNavigator } from '@c8y/ngx-components';
import * as i1 from '@angular/router';
import { TrackingMarkerPopupComponent } from '@c8y/ngx-components/tracking';

class BoundsResolverService {
    constructor(mapService) {
        this.mapService = mapService;
    }
    resolve() {
        return this.mapService.getAllDevicesBounds();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: BoundsResolverService, deps: [{ token: i3.MapService }], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: BoundsResolverService, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: BoundsResolverService, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root'
                }]
        }], ctorParameters: () => [{ type: i3.MapService }] });

class DeviceMapNavigationFactory {
    constructor() {
        this.nav = new NavigatorNode({
            label: gettext('Map'),
            path: 'devicemap',
            icon: 'c8y-location',
            parent: {
                label: gettext('Devices')
            },
            priority: 1900
        });
    }
    async get() {
        return this.nav;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: DeviceMapNavigationFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: DeviceMapNavigationFactory }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: DeviceMapNavigationFactory, decorators: [{
            type: Injectable
        }] });

class DeviceMapComponent {
    constructor(route) {
        const { location, bounds } = route.snapshot.data;
        this.config = {
            center: bounds?.isValid() ? bounds.getCenter() : location,
            zoomLevel: 3,
            refreshInterval: 30000,
            bounds,
            fitBoundsOptions: {
                padding: [50, 50]
            }
        };
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: DeviceMapComponent, deps: [{ token: i1.ActivatedRoute }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.19", type: DeviceMapComponent, isStandalone: true, selector: "ng-component", ngImport: i0, template: "<c8y-title>{{ 'Device map' | translate }}</c8y-title>\n\n<c8y-breadcrumb>\n  <c8y-breadcrumb-item\n    icon=\"exchange\"\n    [label]=\"'Devices' | translate\"\n  ></c8y-breadcrumb-item>\n  <c8y-breadcrumb-item\n    icon=\"c8y-location\"\n    [label]=\"'Map' | translate\"\n  ></c8y-breadcrumb-item>\n</c8y-breadcrumb>\n\n<div class=\"card card--grid content-fullpage\">\n  <div\n    class=\"bg-white p-relative\"\n    style=\"min-height: 30vh\"\n  >\n    <c8y-map-status\n      [clusterMap]=\"map\"\n      [(config)]=\"config\"\n    ></c8y-map-status>\n    <c8y-cluster-map\n      #map\n      [config]=\"config\"\n    >\n      <div *c8yMapPopup=\"let context\">\n        <c8y-tracking-marker-popup\n          [showTrackingLink]=\"true\"\n          [context]=\"context\"\n        ></c8y-tracking-marker-popup>\n      </div>\n    </c8y-cluster-map>\n  </div>\n</div>\n", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: CoreModule }, { kind: "component", type: i2.BreadcrumbComponent, selector: "c8y-breadcrumb" }, { kind: "component", type: i2.BreadcrumbItemComponent, selector: "c8y-breadcrumb-item", inputs: ["icon", "translate", "label", "path", "injector"] }, { kind: "component", type: i2.TitleComponent, selector: "c8y-title", inputs: ["pageTitleUpdate"] }, { kind: "ngmodule", type: MapModule }, { kind: "component", type: i3.MapStatusComponent, selector: "c8y-map-status", inputs: ["config", "assets", "clusterMap", "buttonsConfig"], outputs: ["configChange", "onUnfollow", "fitAssetsToBounds"] }, { kind: "component", type: i3.ClusterMapComponent, selector: "c8y-cluster-map", inputs: ["config", "rootNode", "asset", "showClusterColor"], outputs: ["mapChange"] }, { kind: "directive", type: i3.MapPopupDirective, selector: "[c8yMapPopup]" }, { kind: "component", type: TrackingMarkerPopupComponent, selector: "c8y-tracking-marker-popup", inputs: ["context", "showTrackingLink"] }, { kind: "pipe", type: i2.C8yTranslatePipe, name: "translate" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: DeviceMapComponent, decorators: [{
            type: Component,
            args: [{ standalone: true, imports: [CommonModule, CoreModule, MapModule, TrackingMarkerPopupComponent], template: "<c8y-title>{{ 'Device map' | translate }}</c8y-title>\n\n<c8y-breadcrumb>\n  <c8y-breadcrumb-item\n    icon=\"exchange\"\n    [label]=\"'Devices' | translate\"\n  ></c8y-breadcrumb-item>\n  <c8y-breadcrumb-item\n    icon=\"c8y-location\"\n    [label]=\"'Map' | translate\"\n  ></c8y-breadcrumb-item>\n</c8y-breadcrumb>\n\n<div class=\"card card--grid content-fullpage\">\n  <div\n    class=\"bg-white p-relative\"\n    style=\"min-height: 30vh\"\n  >\n    <c8y-map-status\n      [clusterMap]=\"map\"\n      [(config)]=\"config\"\n    ></c8y-map-status>\n    <c8y-cluster-map\n      #map\n      [config]=\"config\"\n    >\n      <div *c8yMapPopup=\"let context\">\n        <c8y-tracking-marker-popup\n          [showTrackingLink]=\"true\"\n          [context]=\"context\"\n        ></c8y-tracking-marker-popup>\n      </div>\n    </c8y-cluster-map>\n  </div>\n</div>\n" }]
        }], ctorParameters: () => [{ type: i1.ActivatedRoute }] });

class LocationResolverService {
    resolve() {
        return new Promise((resolve, _) => {
            if (navigator.geolocation) {
                navigator.geolocation.getCurrentPosition(gp => {
                    resolve([gp?.coords?.latitude, gp?.coords?.longitude]);
                }, () => {
                    resolve(defaultMapConfig.center);
                });
            }
        });
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: LocationResolverService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: LocationResolverService, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: LocationResolverService, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root'
                }]
        }] });

const deviceMapFeatureProvider = makeEnvironmentProviders([
    hookRoute({
        path: 'devicemap',
        component: DeviceMapComponent,
        resolve: { location: LocationResolverService, bounds: BoundsResolverService }
    }),
    hookNavigator(DeviceMapNavigationFactory)
]);

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

export { BoundsResolverService, DeviceMapComponent, DeviceMapNavigationFactory, LocationResolverService, deviceMapFeatureProvider };
//# sourceMappingURL=c8y-ngx-components-device-map.mjs.map
