import { Component, Input, ViewEncapsulation } from '@angular/core';
import { GPS } from '../../../../forms/page/widgets/gps';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "@agm/core";
import * as i3 from "@agm/snazzy-info-window";
import * as i4 from "@angular/material/icon";
function GpsWidgetViewComponent_ng_container_0_div_1_ng_container_2_ng_conatiner_1_ng_conatiner_1_Template(rf, ctx) { if (rf & 1) {
    const _r14 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "ng-conatiner");
    i0.ɵɵelementStart(1, "agm-marker", 9);
    i0.ɵɵlistener("markerClick", function GpsWidgetViewComponent_ng_container_0_div_1_ng_container_2_ng_conatiner_1_ng_conatiner_1_Template_agm_marker_markerClick_1_listener() { i0.ɵɵrestoreView(_r14); const _r12 = i0.ɵɵreference(3); const ctx_r13 = i0.ɵɵnextContext(5); return ctx_r13.clickedMarker(_r12); });
    i0.ɵɵelementStart(2, "agm-info-window", null, 10);
    i0.ɵɵelementStart(4, "strong");
    i0.ɵɵtext(5);
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const pathsOfMarker_r11 = ctx.$implicit;
    const agmOption_r5 = i0.ɵɵnextContext(2).$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("agmFitBounds", true)("latitude", pathsOfMarker_r11.lat)("longitude", pathsOfMarker_r11.lng);
    i0.ɵɵadvance(4);
    i0.ɵɵtextInterpolate1(" ", agmOption_r5.note, " ");
} }
function GpsWidgetViewComponent_ng_container_0_div_1_ng_container_2_ng_conatiner_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "ng-conatiner");
    i0.ɵɵtemplate(1, GpsWidgetViewComponent_ng_container_0_div_1_ng_container_2_ng_conatiner_1_ng_conatiner_1_Template, 6, 4, "ng-conatiner", 8);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const agmOption_r5 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", agmOption_r5.path);
} }
function GpsWidgetViewComponent_ng_container_0_div_1_ng_container_2_ng_container_2_agm_snazzy_info_window_2_ng_template_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div");
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const agmOption_r5 = i0.ɵɵnextContext(3).$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(agmOption_r5.note);
} }
function GpsWidgetViewComponent_ng_container_0_div_1_ng_container_2_ng_container_2_agm_snazzy_info_window_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "agm-snazzy-info-window", 13);
    i0.ɵɵtemplate(1, GpsWidgetViewComponent_ng_container_0_div_1_ng_container_2_ng_container_2_agm_snazzy_info_window_2_ng_template_1_Template, 2, 1, "ng-template");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const agmOption_r5 = i0.ɵɵnextContext(2).$implicit;
    i0.ɵɵproperty("panOnOpen", true)("latitude", agmOption_r5.path[0].lat)("longitude", agmOption_r5.path[0].lng)("closeWhenOthersOpen", true)("closeOnMapClick", true)("showCloseButton", true)("isOpen", agmOption_r5.isOpen);
} }
function GpsWidgetViewComponent_ng_container_0_div_1_ng_container_2_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    const _r23 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "agm-polygon", 11);
    i0.ɵɵlistener("polyClick", function GpsWidgetViewComponent_ng_container_0_div_1_ng_container_2_ng_container_2_Template_agm_polygon_polyClick_1_listener() { i0.ɵɵrestoreView(_r23); const indexOfagm_r6 = i0.ɵɵnextContext().index; const ctx_r21 = i0.ɵɵnextContext(3); return ctx_r21.openSnazzyInfoWindow(indexOfagm_r6); });
    i0.ɵɵtemplate(2, GpsWidgetViewComponent_ng_container_0_div_1_ng_container_2_ng_container_2_agm_snazzy_info_window_2_Template, 2, 7, "agm-snazzy-info-window", 12);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const agmOption_r5 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("paths", agmOption_r5.path);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", agmOption_r5.note);
} }
function GpsWidgetViewComponent_ng_container_0_div_1_ng_container_2_ng_conatiner_3_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "agm-polyline-point", 15);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const polylinePath_r27 = ctx.$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("latitude", polylinePath_r27.lat)("longitude", polylinePath_r27.lng);
} }
function GpsWidgetViewComponent_ng_container_0_div_1_ng_container_2_ng_conatiner_3_agm_snazzy_info_window_3_ng_template_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div");
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const agmOption_r5 = i0.ɵɵnextContext(3).$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(agmOption_r5.note);
} }
function GpsWidgetViewComponent_ng_container_0_div_1_ng_container_2_ng_conatiner_3_agm_snazzy_info_window_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "agm-snazzy-info-window", 13);
    i0.ɵɵtemplate(1, GpsWidgetViewComponent_ng_container_0_div_1_ng_container_2_ng_conatiner_3_agm_snazzy_info_window_3_ng_template_1_Template, 2, 1, "ng-template");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const agmOption_r5 = i0.ɵɵnextContext(2).$implicit;
    i0.ɵɵproperty("panOnOpen", true)("latitude", agmOption_r5.path[0].lat)("longitude", agmOption_r5.path[0].lng)("closeWhenOthersOpen", true)("closeOnMapClick", true)("showCloseButton", true)("isOpen", agmOption_r5.isOpen);
} }
function GpsWidgetViewComponent_ng_container_0_div_1_ng_container_2_ng_conatiner_3_Template(rf, ctx) { if (rf & 1) {
    const _r33 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "ng-conatiner");
    i0.ɵɵelementStart(1, "agm-polyline", 14);
    i0.ɵɵlistener("lineClick", function GpsWidgetViewComponent_ng_container_0_div_1_ng_container_2_ng_conatiner_3_Template_agm_polyline_lineClick_1_listener() { i0.ɵɵrestoreView(_r33); const indexOfagm_r6 = i0.ɵɵnextContext().index; const ctx_r31 = i0.ɵɵnextContext(3); return ctx_r31.openSnazzyInfoWindow(indexOfagm_r6); });
    i0.ɵɵtemplate(2, GpsWidgetViewComponent_ng_container_0_div_1_ng_container_2_ng_conatiner_3_ng_container_2_Template, 2, 2, "ng-container", 8);
    i0.ɵɵtemplate(3, GpsWidgetViewComponent_ng_container_0_div_1_ng_container_2_ng_conatiner_3_agm_snazzy_info_window_3_Template, 2, 7, "agm-snazzy-info-window", 12);
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const agmOption_r5 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngForOf", agmOption_r5.path);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", agmOption_r5.note);
} }
function GpsWidgetViewComponent_ng_container_0_div_1_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0, 6);
    i0.ɵɵtemplate(1, GpsWidgetViewComponent_ng_container_0_div_1_ng_container_2_ng_conatiner_1_Template, 2, 1, "ng-conatiner", 7);
    i0.ɵɵtemplate(2, GpsWidgetViewComponent_ng_container_0_div_1_ng_container_2_ng_container_2_Template, 3, 2, "ng-container", 7);
    i0.ɵɵtemplate(3, GpsWidgetViewComponent_ng_container_0_div_1_ng_container_2_ng_conatiner_3_Template, 4, 2, "ng-conatiner", 7);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const agmOption_r5 = ctx.$implicit;
    i0.ɵɵproperty("ngSwitch", agmOption_r5.type);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", "marker");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", "polygon");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", "polyline");
} }
function GpsWidgetViewComponent_ng_container_0_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 3);
    i0.ɵɵelementStart(1, "agm-map", 4);
    i0.ɵɵtemplate(2, GpsWidgetViewComponent_ng_container_0_div_1_ng_container_2_Template, 4, 4, "ng-container", 5);
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r3 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("zoom", ctx_r3.zoom)("scrollwheel", false)("fitBounds", true)("restriction", ctx_r3.restriction)("minZoom", 2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", ctx_r3.agmMangerOption);
} }
function GpsWidgetViewComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, GpsWidgetViewComponent_ng_container_0_div_1_Template, 3, 6, "div", 2);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.widget.value);
} }
function GpsWidgetViewComponent_ng_template_1_span_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 21);
    i0.ɵɵtext(1);
    i0.ɵɵelementStart(2, "span", 22);
    i0.ɵɵtext(3, " :");
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r35 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(ctx_r35.widget.prompt);
} }
function GpsWidgetViewComponent_ng_template_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 16);
    i0.ɵɵelementStart(1, "div", 17);
    i0.ɵɵelement(2, "mat-icon", 18);
    i0.ɵɵtemplate(3, GpsWidgetViewComponent_ng_template_1_span_3_Template, 4, 1, "span", 19);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(4, "span", 20);
    i0.ɵɵtext(5, "-");
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r2 = i0.ɵɵnextContext();
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("ngIf", ctx_r2.section.showPrompt);
} }
export class GpsWidgetViewComponent {
    constructor() {
        // Gps Polyline object
        this.polylineOptions = [];
        // Gps polygon object
        this.polygonOptions = [];
        // Gps Point  object
        this.markerOptions = [];
        // Common object create for agm shapes value
        this.agmMangerOption = [];
        this.restriction = {
            latLngBounds: {
                north: 85,
                south: -85,
                east: 179.99,
                west: -179.99,
            },
        };
    }
    ngOnInit() {
        // get gps widget value from to gps class
        this.widgetValue = this.widget.getWidgetValue();
        if (this.widgetValue && this.widgetValue.length) {
            this.latitude = this.widget.value[0].value[0].latitude;
            this.longitude = this.widget.value[0].value[0].longitude;
            const zoomLevel = parseInt(this.widget.mapZoomLevel);
            this.zoom = zoomLevel ? zoomLevel : 22;
            this.setWidgetShapesValue();
        }
    }
    /**
     * Set widget latitude and longitude to agm drwaing
     */
    setWidgetShapesValue() {
        this.widgetValue.forEach((pathOfShapes) => {
            const polygonPath = [];
            pathOfShapes.value.forEach((path) => {
                const pathLatLong = { lng: path.longitude, lat: path.latitude };
                polygonPath.push(pathLatLong);
            });
            this.agmMangerOption.push({ type: pathOfShapes.type, note: pathOfShapes.note, path: polygonPath, isOpen: false });
        });
    }
    /**
     * open marker tooltip
     *
     * @param infowindow
     */
    clickedMarker(infowindow) {
        if (this.previous) {
            this.previous.close();
        }
        this.previous = infowindow;
    }
    /**
     * Open shapes note message in tooltip
     *
     * @param indexOfagm
     */
    openSnazzyInfoWindow(indexOfagm) {
        this.agmMangerOption[indexOfagm].isOpen = !this.agmMangerOption[indexOfagm].isOpen;
        this.agmMangerOption.forEach((agmValue, agmIndex) => {
            if (agmIndex === indexOfagm) {
                this.latitude = agmValue.path[0].lat;
                this.longitude = agmValue.path[0].lng;
                agmValue.isOpen = true;
            }
            else {
                agmValue.isOpen = false;
            }
        });
    }
}
GpsWidgetViewComponent.ɵfac = function GpsWidgetViewComponent_Factory(t) { return new (t || GpsWidgetViewComponent)(); };
GpsWidgetViewComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: GpsWidgetViewComponent, selectors: [["lib-gps-widget-view"]], inputs: { widget: "widget" }, decls: 3, vars: 2, consts: [[4, "ngIf", "ngIfElse"], ["isWidgetValueEmpty", ""], ["class", "gps-container", 4, "ngIf"], [1, "gps-container"], [3, "zoom", "scrollwheel", "fitBounds", "restriction", "minZoom"], [3, "ngSwitch", 4, "ngFor", "ngForOf"], [3, "ngSwitch"], [4, "ngSwitchCase"], [4, "ngFor", "ngForOf"], [3, "agmFitBounds", "latitude", "longitude", "markerClick"], ["infowindow", ""], ["fillColor", "#8e8e8e", "fillOpacity", ".35", "strokeColor", "#32a1d0", 3, "paths", "polyClick"], [3, "panOnOpen", "latitude", "longitude", "closeWhenOthersOpen", "closeOnMapClick", "showCloseButton", "isOpen", 4, "ngIf"], [3, "panOnOpen", "latitude", "longitude", "closeWhenOthersOpen", "closeOnMapClick", "showCloseButton", "isOpen"], [3, "lineClick"], [3, "latitude", "longitude"], [1, "data-detail-infoc", "capture-container"], [1, "data-detail-title", "flex", "text-sm"], ["svgIcon", "axo_location", 1, "add-text"], ["class", "pl-2 text-sm", 4, "ngIf"], [1, "flex", "justify-start"], [1, "pl-2", "text-sm"], [1, "colon"]], template: function GpsWidgetViewComponent_Template(rf, ctx) { if (rf & 1) {
        i0.ɵɵtemplate(0, GpsWidgetViewComponent_ng_container_0_Template, 2, 1, "ng-container", 0);
        i0.ɵɵtemplate(1, GpsWidgetViewComponent_ng_template_1_Template, 6, 1, "ng-template", null, 1, i0.ɵɵtemplateRefExtractor);
    } if (rf & 2) {
        const _r1 = i0.ɵɵreference(2);
        i0.ɵɵproperty("ngIf", ctx.widget.value)("ngIfElse", _r1);
    } }, directives: [i1.NgIf, i2.AgmMap, i1.NgForOf, i1.NgSwitch, i1.NgSwitchCase, i2.AgmMarker, i2.AgmFitBounds, i2.AgmInfoWindow, i2.AgmPolygon, i3.AgmSnazzyInfoWindow, i2.AgmPolyline, i2.AgmPolylinePoint, i4.MatIcon], styles: ["lib-gps-widget-view{display:block}lib-gps-widget-view agm-map{height:300px}lib-gps-widget-view .mat-form-field.mat-form-field-appearance-fill{width:100%!important}lib-gps-widget-view .gps-container{height:100%;width:100%}\n"], encapsulation: 2 });
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(GpsWidgetViewComponent, [{
        type: Component,
        args: [{ selector: 'lib-gps-widget-view', encapsulation: ViewEncapsulation.None, template: "<!--- gps value  content-->\n<ng-container *ngIf=\"widget.value; else isWidgetValueEmpty\" >\n    <div class=\"gps-container\" *ngIf=\"widget.value\">\n        <agm-map [zoom]=\"zoom\" [scrollwheel]=\"false\"  [fitBounds]=\"true\" [restriction]=\"restriction\" [minZoom]=\"2\">\n            <ng-container *ngFor=\"let agmOption of agmMangerOption;let indexOfagm=index;\"\n            [ngSwitch]=\"agmOption.type\">\n                <!-----------Markers shapes content-->\n                <ng-conatiner *ngSwitchCase=\"'marker'\">\n                    <ng-conatiner *ngFor=\"let pathsOfMarker of agmOption.path\">\n                        <agm-marker\n                            [agmFitBounds]=\"true\"\n                            [latitude]=\"pathsOfMarker.lat\"\n                            [longitude]=\"pathsOfMarker.lng\"\n                            (markerClick)=\"clickedMarker(infowindow)\">\n                            <agm-info-window #infowindow>\n                                <strong>\n                                    {{agmOption.note}}\n                                </strong>\n                            </agm-info-window>\n                        </agm-marker>\n                    </ng-conatiner>\n                </ng-conatiner>\n                <!-----------Polygon shapes content-->\n                <ng-container *ngSwitchCase=\"'polygon'\">\n                    <agm-polygon\n                        [paths]=\"agmOption.path\"\n                        fillColor=\"#8e8e8e\"\n                        fillOpacity=\".35\"\n                        strokeColor=\"#32a1d0\"\n                        (polyClick)=\"openSnazzyInfoWindow(indexOfagm)\">\n                        <agm-snazzy-info-window\n                            *ngIf=\"agmOption.note\"\n                            [panOnOpen]=\"true\"\n                            [latitude]=\"agmOption.path[0].lat\"\n                            [longitude]=\"agmOption.path[0].lng\"\n                            [closeWhenOthersOpen]=\"true\"\n                            [closeOnMapClick]=\"true\"\n                            [showCloseButton]=\"true\"\n                            [isOpen]=\"agmOption.isOpen\">\n                            <ng-template>\n                                <div>{{agmOption.note}}</div>\n                            </ng-template>\n                        </agm-snazzy-info-window>\n                    </agm-polygon>\n                </ng-container>\n                <!-----------Polyline shapes content-->\n                <ng-conatiner *ngSwitchCase=\"'polyline'\">\n                    <agm-polyline (lineClick)=\"openSnazzyInfoWindow(indexOfagm)\">\n                        <ng-container *ngFor=\"let polylinePath of agmOption.path\">\n                            <agm-polyline-point [latitude]=\"polylinePath.lat\" [longitude]=\"polylinePath.lng\">\n                            </agm-polyline-point>\n                        </ng-container>\n                        <agm-snazzy-info-window\n                            *ngIf=\"agmOption.note\"\n                            [panOnOpen]=\"true\"\n                            [latitude]=\"agmOption.path[0].lat\"\n                            [longitude]=\"agmOption.path[0].lng\"\n                            [closeWhenOthersOpen]=\"true\"\n                            [closeOnMapClick]=\"true\"\n                            [showCloseButton]=\"true\"\n                            [isOpen]=\"agmOption.isOpen\">\n                            <ng-template>\n                                <div>{{agmOption.note}}</div>\n                            </ng-template>\n                        </agm-snazzy-info-window>\n                    </agm-polyline>\n                </ng-conatiner>\n            </ng-container>\n        </agm-map>\n    </div>\n</ng-container>\n<!--- gps value empty content-->\n<ng-template #isWidgetValueEmpty>\n    <div class=\"data-detail-infoc capture-container\">\n        <div class=\"data-detail-title flex text-sm\">\n            <mat-icon class=\"add-text\" svgIcon=\"axo_location\"></mat-icon>\n            <span *ngIf=\"section.showPrompt\" class=\"pl-2 text-sm\">{{widget.prompt}}<span class=\"colon\"> :</span></span>\n        </div>\n        <span class=\"flex justify-start\">-</span>\n    </div>\n</ng-template>\n", styles: ["lib-gps-widget-view{display:block}lib-gps-widget-view agm-map{height:300px}lib-gps-widget-view .mat-form-field.mat-form-field-appearance-fill{width:100%!important}lib-gps-widget-view .gps-container{height:100%;width:100%}\n"] }]
    }], null, { widget: [{
            type: Input
        }] }); })();
//# sourceMappingURL=data:application/json;base64, 