import { Component, Input } from '@angular/core';
import { ModalController } from '@ionic/angular';
import * as i0 from "@angular/core";
import * as i1 from "@ionic/angular";
import * as i2 from "@swimlane/ngx-charts";
export class TapVariableDataPopupComponent {
    constructor(modalController) {
        this.modalController = modalController;
        this.legend = false;
        this.showLabels = false;
        this.animations = true;
        this.xAxis = true;
        this.yAxis = true;
        this.showYAxisLabel = false;
        this.showXAxisLabel = false;
        this.timeline = true;
        this.colorScheme = {
            domain: ['#5AA454', '#A10A28', '#C7B42C', '#AAAAAA'],
        };
        this.results = [];
        this.currentDate =
            '' +
                this.digit(+new Date().getHours()) +
                ':' +
                this.digit(+new Date().getMinutes()) +
                ':' +
                this.digit(+new Date().getSeconds());
    }
    set variable(inputs) {
        this.results.push({
            name: this.label,
            series: [],
        });
        inputs.stream.subscribe((value) => {
            if (Array.isArray(value)) {
                this.currentValue = value[this.index];
            }
            else {
                this.currentValue = value;
            }
            const seriesData = {
                name: new Date(),
                value: this.currentValue,
                extra: 0,
            };
            this.results[0].series.push(seriesData);
            const itemCount = this.results[0].series.length;
            if (itemCount > 10) {
                const toRemove = itemCount - 10;
                this.results[0].series.splice(0, toRemove);
            }
            this.results = [...this.results];
        });
    }
    async dismissModal() {
        await this.modalController.dismiss();
    }
    digit(n) {
        return n > 9 ? '' + n : '0' + n;
    }
}
/** @nocollapse */ /** @nocollapse */ TapVariableDataPopupComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: TapVariableDataPopupComponent, deps: [{ token: i1.ModalController }], target: i0.ɵɵFactoryTarget.Component });
/** @nocollapse */ /** @nocollapse */ TapVariableDataPopupComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.0", type: TapVariableDataPopupComponent, selector: "tap-tap-variable-data-popup", inputs: { value: "value", label: "label", index: "index", variable: "variable" }, ngImport: i0, template: "<ion-header translucent>\n  <ion-toolbar>\n    <ion-buttons slot=\"start\">\n      <ion-button (click)=\"dismissModal()\"\n        ><ion-icon name=\"arrow-back-outline\"></ion-icon\n      ></ion-button>\n    </ion-buttons>\n    <ion-title>Details</ion-title>\n  </ion-toolbar>\n</ion-header>\n<ion-content>\n  <ion-list>\n    <ion-list-header>\n      <ion-label\n        ><h1>{{ label }}</h1></ion-label\n      >\n    </ion-list-header>\n    <ion-item>\n      <ion-label>Value on click</ion-label>\n      <ion-note slot=\"end\">{{ value }}</ion-note>\n    </ion-item>\n    <ion-item>\n      <ion-label>Time on click</ion-label>\n      <ion-note slot=\"end\">{{ currentDate }}</ion-note>\n    </ion-item>\n\n    <ion-item>\n      <ion-label>Current value</ion-label>\n      <ion-note slot=\"end\">{{ currentValue }}</ion-note>\n    </ion-item>\n\n    <ion-item>\n      <ion-label>Dynamic graphic</ion-label>\n      <div #containerRef style=\"height: 50vh; width: 100%\">\n        <ngx-charts-line-chart\n          [view]=\"[containerRef.offsetWidth, containerRef.offsetHeight]\"\n          [scheme]=\"colorScheme\"\n          [showXAxisLabel]=\"showXAxisLabel\"\n          [showYAxisLabel]=\"showYAxisLabel\"\n          [legend]=\"legend\"\n          [xAxis]=\"xAxis\"\n          [yAxis]=\"yAxis\"\n          [timeline]=\"timeline\"\n          [results]=\"results\"\n        >\n        </ngx-charts-line-chart>\n      </div>\n    </ion-item>\n  </ion-list>\n</ion-content>\n", styles: [".my-custom-modal-css{--background: transparent !important}\n"], components: [{ type: i1.IonHeader, selector: "ion-header", inputs: ["collapse", "mode", "translucent"] }, { type: i1.IonToolbar, selector: "ion-toolbar", inputs: ["color", "mode"] }, { type: i1.IonButtons, selector: "ion-buttons", inputs: ["collapse"] }, { type: i1.IonButton, selector: "ion-button", inputs: ["buttonType", "color", "disabled", "download", "expand", "fill", "href", "mode", "rel", "routerAnimation", "routerDirection", "shape", "size", "strong", "target", "type"] }, { type: i1.IonIcon, selector: "ion-icon", inputs: ["color", "flipRtl", "icon", "ios", "lazy", "md", "mode", "name", "sanitize", "size", "src"] }, { type: i1.IonTitle, selector: "ion-title", inputs: ["color", "size"] }, { type: i1.IonContent, selector: "ion-content", inputs: ["color", "forceOverscroll", "fullscreen", "scrollEvents", "scrollX", "scrollY"] }, { type: i1.IonList, selector: "ion-list", inputs: ["inset", "lines", "mode"] }, { type: i1.IonListHeader, selector: "ion-list-header", inputs: ["color", "lines", "mode"] }, { type: i1.IonLabel, selector: "ion-label", inputs: ["color", "mode", "position"] }, { type: i1.IonItem, selector: "ion-item", inputs: ["button", "color", "counter", "detail", "detailIcon", "disabled", "download", "fill", "href", "lines", "mode", "rel", "routerAnimation", "routerDirection", "shape", "target", "type"] }, { type: i1.IonNote, selector: "ion-note", inputs: ["color", "mode"] }, { type: i2.LineChartComponent, selector: "ngx-charts-line-chart", inputs: ["legend", "legendTitle", "legendPosition", "xAxis", "yAxis", "showXAxisLabel", "showYAxisLabel", "xAxisLabel", "yAxisLabel", "autoScale", "timeline", "gradient", "showGridLines", "curve", "activeEntries", "schemeType", "rangeFillOpacity", "trimXAxisTicks", "trimYAxisTicks", "rotateXAxisTicks", "maxXAxisTickLength", "maxYAxisTickLength", "xAxisTickFormatting", "yAxisTickFormatting", "xAxisTicks", "yAxisTicks", "roundDomains", "tooltipDisabled", "showRefLines", "referenceLines", "showRefLabels", "xScaleMin", "xScaleMax", "yScaleMin", "yScaleMax"], outputs: ["activate", "deactivate"] }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: TapVariableDataPopupComponent, decorators: [{
            type: Component,
            args: [{ selector: 'tap-tap-variable-data-popup', template: "<ion-header translucent>\n  <ion-toolbar>\n    <ion-buttons slot=\"start\">\n      <ion-button (click)=\"dismissModal()\"\n        ><ion-icon name=\"arrow-back-outline\"></ion-icon\n      ></ion-button>\n    </ion-buttons>\n    <ion-title>Details</ion-title>\n  </ion-toolbar>\n</ion-header>\n<ion-content>\n  <ion-list>\n    <ion-list-header>\n      <ion-label\n        ><h1>{{ label }}</h1></ion-label\n      >\n    </ion-list-header>\n    <ion-item>\n      <ion-label>Value on click</ion-label>\n      <ion-note slot=\"end\">{{ value }}</ion-note>\n    </ion-item>\n    <ion-item>\n      <ion-label>Time on click</ion-label>\n      <ion-note slot=\"end\">{{ currentDate }}</ion-note>\n    </ion-item>\n\n    <ion-item>\n      <ion-label>Current value</ion-label>\n      <ion-note slot=\"end\">{{ currentValue }}</ion-note>\n    </ion-item>\n\n    <ion-item>\n      <ion-label>Dynamic graphic</ion-label>\n      <div #containerRef style=\"height: 50vh; width: 100%\">\n        <ngx-charts-line-chart\n          [view]=\"[containerRef.offsetWidth, containerRef.offsetHeight]\"\n          [scheme]=\"colorScheme\"\n          [showXAxisLabel]=\"showXAxisLabel\"\n          [showYAxisLabel]=\"showYAxisLabel\"\n          [legend]=\"legend\"\n          [xAxis]=\"xAxis\"\n          [yAxis]=\"yAxis\"\n          [timeline]=\"timeline\"\n          [results]=\"results\"\n        >\n        </ngx-charts-line-chart>\n      </div>\n    </ion-item>\n  </ion-list>\n</ion-content>\n", styles: [".my-custom-modal-css{--background: transparent !important}\n"] }]
        }], ctorParameters: function () { return [{ type: i1.ModalController }]; }, propDecorators: { value: [{
                type: Input
            }], label: [{
                type: Input
            }], index: [{
                type: Input
            }], variable: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 