import { Component, Input } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import { CoreModule } from '@c8y/ngx-components';
import { TrackingService } from './tracking.service';
import * as i0 from "@angular/core";
import * as i1 from "./tracking.service";
import * as i2 from "@c8y/ngx-components";
import * as i3 from "@angular/common";
import * as i4 from "@angular/router";
export class TrackingMarkerPopupComponent {
    constructor(trackingService) {
        this.trackingService = trackingService;
        /**
         * Displays link to device tracking tab.
         */
        this.showTrackingLink = false;
    }
    async ngOnInit() {
        this.isDevice = !this.trackingService.isLocationUpdateEvent(this.context);
        if (this.isDevice) {
            this.trackingService.setDeviceId(this.context.id);
            this.date = await this.trackingService.latestPositionUpdate(this.context);
        }
        else {
            this.date = this.context.time;
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: TrackingMarkerPopupComponent, deps: [{ token: i1.TrackingService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: TrackingMarkerPopupComponent, isStandalone: true, selector: "c8y-tracking-marker-popup", inputs: { context: "context", showTrackingLink: "showTrackingLink" }, ngImport: i0, template: "<div class=\"map-marker\">\n  <a\n    class=\"text-truncate text-14 text-medium p-0 m-b-8 deviceLink\"\n    [title]=\"context?.name\"\n    *ngIf=\"isDevice\"\n    [routerLink]=\"['/device/', context?.id]\"\n  >\n    {{ context?.name }}\n  </a>\n  <div\n    class=\"m-b-8\"\n    ng-if=\"lastUpdated\"\n  >\n    <p class=\"m-0\">{{ 'Position:' | translate }}</p>\n    <div class=\"text-muted\">\n      <p class=\"m-b-0\">{{ context?.c8y_Position?.lat }},</p>\n      <p class=\"m-t-0\">{{ context?.c8y_Position?.lng }}</p>\n    </div>\n    @if (!!context?.c8y_Position?.alt || context?.c8y_Position?.alt === 0) {\n      <p class=\"m-0\">{{ 'Altitude:' | translate }}</p>\n      <div class=\"text-muted\">\n        <p\n          class=\"m-b-0\"\n          [translate]=\"'{{alt}} m`meters, altitude`'\"\n          [translateParams]=\"{ alt: context?.c8y_Position?.alt }\"\n        ></p>\n      </div>\n    }\n    @if (!!date) {\n      <p class=\"m-0 p-t-4\">{{ 'Date and time:' | translate }}</p>\n      <span class=\"text-muted\">{{ date | c8yDate }}</span>\n    }\n  </div>\n\n  @if (isDevice) {\n    @if (showTrackingLink) {\n      <span>\n        Go to\n        <a [routerLink]=\"['/device', context?.id, 'tracking']\">Tracking</a>\n      </span>\n    } @else {\n      <div class=\"d-flex a-i-center\">\n        <label\n          class=\"c8y-switch\"\n          for=\"switch\"\n        >\n          <input\n            id=\"switch\"\n            type=\"checkbox\"\n            [checked]=\"trackingService.trackVisible\"\n            (change)=\"trackingService.toggleTrack()\"\n          />\n          <span></span>\n        </label>\n        <div class=\"description p-b-0\">\n          {{ 'Show track' | translate }}\n        </div>\n      </div>\n    }\n  }\n</div>\n", dependencies: [{ kind: "ngmodule", type: CoreModule }, { kind: "pipe", type: i2.C8yTranslatePipe, name: "translate" }, { kind: "directive", type: i2.C8yTranslateDirective, selector: "[translate],[ngx-translate]" }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i2.DatePipe, name: "c8yDate" }, { kind: "ngmodule", type: RouterModule }, { kind: "directive", type: i4.RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "ngmodule", type: FormsModule }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: TrackingMarkerPopupComponent, decorators: [{
            type: Component,
            args: [{ standalone: true, selector: 'c8y-tracking-marker-popup', imports: [CoreModule, RouterModule, FormsModule], template: "<div class=\"map-marker\">\n  <a\n    class=\"text-truncate text-14 text-medium p-0 m-b-8 deviceLink\"\n    [title]=\"context?.name\"\n    *ngIf=\"isDevice\"\n    [routerLink]=\"['/device/', context?.id]\"\n  >\n    {{ context?.name }}\n  </a>\n  <div\n    class=\"m-b-8\"\n    ng-if=\"lastUpdated\"\n  >\n    <p class=\"m-0\">{{ 'Position:' | translate }}</p>\n    <div class=\"text-muted\">\n      <p class=\"m-b-0\">{{ context?.c8y_Position?.lat }},</p>\n      <p class=\"m-t-0\">{{ context?.c8y_Position?.lng }}</p>\n    </div>\n    @if (!!context?.c8y_Position?.alt || context?.c8y_Position?.alt === 0) {\n      <p class=\"m-0\">{{ 'Altitude:' | translate }}</p>\n      <div class=\"text-muted\">\n        <p\n          class=\"m-b-0\"\n          [translate]=\"'{{alt}} m`meters, altitude`'\"\n          [translateParams]=\"{ alt: context?.c8y_Position?.alt }\"\n        ></p>\n      </div>\n    }\n    @if (!!date) {\n      <p class=\"m-0 p-t-4\">{{ 'Date and time:' | translate }}</p>\n      <span class=\"text-muted\">{{ date | c8yDate }}</span>\n    }\n  </div>\n\n  @if (isDevice) {\n    @if (showTrackingLink) {\n      <span>\n        Go to\n        <a [routerLink]=\"['/device', context?.id, 'tracking']\">Tracking</a>\n      </span>\n    } @else {\n      <div class=\"d-flex a-i-center\">\n        <label\n          class=\"c8y-switch\"\n          for=\"switch\"\n        >\n          <input\n            id=\"switch\"\n            type=\"checkbox\"\n            [checked]=\"trackingService.trackVisible\"\n            (change)=\"trackingService.toggleTrack()\"\n          />\n          <span></span>\n        </label>\n        <div class=\"description p-b-0\">\n          {{ 'Show track' | translate }}\n        </div>\n      </div>\n    }\n  }\n</div>\n" }]
        }], ctorParameters: () => [{ type: i1.TrackingService }], propDecorators: { context: [{
                type: Input
            }], showTrackingLink: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 