"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;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.UpdateEventWebhookTransformation = void 0;
const JISEventEffectHelper_1 = require("../../../helpers/jis/JISEventEffectHelper");
const JISEventTranslationHelper_1 = require("../../../helpers/jis/JISEventTranslationHelper");
const AbstractTransformation_1 = require("@golemio/core/dist/helpers/transformation/AbstractTransformation");
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
let UpdateEventWebhookTransformation = class UpdateEventWebhookTransformation extends AbstractTransformation_1.AbstractTransformation {
    constructor() {
        super(...arguments);
        this.name = "UpdateEventWebhookTransformation";
        this.transformInternal = ({ event, routes, }) => {
            return {
                id: event.id,
                type: event.type,
                header_text: event.header_text,
                cause: {
                    cs: JISEventTranslationHelper_1.JISEventTranslationHelper.causeToCs(event.cause),
                    en: JISEventTranslationHelper_1.JISEventTranslationHelper.causeToEn(event.cause),
                },
                cause_detail: event.cause_detail,
                severity_level: event.severity_level,
                active_period: {
                    start: event.active_period.start,
                    end: event.active_period.end,
                },
                display_period: {
                    start: event.display_period.start,
                    end: event.display_period.end || null,
                },
                effects: this.effectToTranslation(event.effect),
                description_text: event.description_text,
                description_html: event.description_html,
                organization_name: event.organization_name,
                informed_entity: {
                    routes: routes.map((r) => ({
                        id: r.route_id,
                        route_long_name: r.route_long_name,
                        route_short_name: r.route_short_name,
                        route_type: r.route_type,
                    })),
                },
                last_modified_timestamp: event.last_modified_timestamp,
                created_timestamp: event.created_timestamp,
                deleted_timestamp: event.deleted_at,
            };
        };
    }
    effectToTranslation(effects) {
        return JISEventEffectHelper_1.JISEventEffectHelper.getEffectAsList(effects).map((effect) => {
            return {
                cs: JISEventTranslationHelper_1.JISEventTranslationHelper.effectToCs(effect),
                en: effect.charAt(0).toUpperCase() + effect.slice(1).toLowerCase().replaceAll("_", " "),
            };
        });
    }
};
exports.UpdateEventWebhookTransformation = UpdateEventWebhookTransformation;
exports.UpdateEventWebhookTransformation = UpdateEventWebhookTransformation = __decorate([
    (0, tsyringe_1.injectable)()
], UpdateEventWebhookTransformation);
//# sourceMappingURL=UpdateEventWebhookTransformation.js.map