"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var JISEventsGtfsRtTransformation_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.JISEventsGtfsRtTransformation = void 0;
const JISEventEffectHelper_1 = require("../../../helpers/jis/JISEventEffectHelper");
const AbstractTransformation_1 = require("@golemio/core/dist/helpers/transformation/AbstractTransformation");
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
let JISEventsGtfsRtTransformation = JISEventsGtfsRtTransformation_1 = class JISEventsGtfsRtTransformation extends AbstractTransformation_1.AbstractTransformation {
    constructor() {
        super(...arguments);
        this.name = "JISEventsGtfsRtTransformation";
        this.transformInternal = (data) => {
            return {
                id: `alert-${data.id}`,
                alert: {
                    activePeriod: [
                        {
                            start: new Date(data.active_period_start).getTime() / 1000,
                            ...(data.active_period_end ? { end: new Date(data.active_period_end).getTime() / 1000 } : {}),
                        },
                    ],
                    informedEntity: data.routes.map((route) => ({ routeId: route.route_id })),
                    // TODO check these enums and possibly use them in the data models
                    cause: data.cause,
                    causeDetail: {
                        translation: [
                            ...(data.cause_detail.cs ? [{ text: data.cause_detail.cs, language: "cs" }] : []),
                            ...(data.cause_detail.en ? [{ text: data.cause_detail.en, language: "en" }] : []),
                        ],
                    },
                    effect: JISEventEffectHelper_1.JISEventEffectHelper.getMainEffect(data.effect),
                    url: {
                        translation: [
                            ...(data.url.cs !== "nevyplněno"
                                ? [{ text: data.url.cs, language: "cs" }]
                                : [{ text: `${JISEventsGtfsRtTransformation_1.PID_WEB_EVENTS_URL}${data.id}`, language: "cs" }]),
                            ...(data.url.en ? [{ text: data.url.en, language: "en" }] : []),
                        ],
                    },
                    headerText: {
                        translation: [
                            {
                                text: data.header_text.cs,
                                language: "cs",
                            },
                            ...(data.header_text.en ? [{ text: data.header_text.en, language: "en" }] : []),
                        ],
                    },
                    descriptionText: {
                        translation: [
                            {
                                text: data.description_text.cs,
                                language: "cs",
                            },
                            ...(data.description_text.en ? [{ text: data.description_text.en, language: "en" }] : []),
                        ],
                    },
                },
            };
        };
    }
};
exports.JISEventsGtfsRtTransformation = JISEventsGtfsRtTransformation;
JISEventsGtfsRtTransformation.PID_WEB_EVENTS_URL = "https://pid.cz/mimoradnost/?uuid=";
exports.JISEventsGtfsRtTransformation = JISEventsGtfsRtTransformation = JISEventsGtfsRtTransformation_1 = __decorate([
    (0, tsyringe_1.injectable)()
], JISEventsGtfsRtTransformation);
//# sourceMappingURL=JISEventsGtfsRtTransformation.js.map