"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.RegionalBusRunsMessagesTransformation = void 0;
const AbstractTransformation_1 = require("@golemio/core/dist/helpers/transformation/AbstractTransformation");
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
let RegionalBusRunsMessagesTransformation = class RegionalBusRunsMessagesTransformation extends AbstractTransformation_1.AbstractTransformation {
    constructor() {
        super(...arguments);
        this.name = "RegionalBusRunsMessagesTransformation";
        this.transformInternal = (data) => {
            const messageData = data.$;
            return {
                external_trip_id: messageData.imei,
                cis_line_id: messageData.line && messageData.line !== "0" ? messageData.line : null,
                cis_trip_number: messageData.conn && messageData.conn !== "0" ? Number.parseInt(messageData.conn) : null,
                events: messageData.events ?? "",
                coordinates: {
                    type: "Point",
                    coordinates: [Number.parseFloat(messageData.lng), Number.parseFloat(messageData.lat)],
                },
                vehicle_timestamp: new Date(messageData.tm + "Z"),
                registration_number: messageData.evc && messageData.evc !== "0" ? Number.parseInt(messageData.evc) : null,
                speed_kmh: Number.parseInt(messageData.rych),
                bearing: Number.parseInt(messageData.smer),
                is_terminated: messageData.conn === "0" || messageData.line === "0",
                timestamp: messageData.tm,
            };
        };
    }
};
exports.RegionalBusRunsMessagesTransformation = RegionalBusRunsMessagesTransformation;
exports.RegionalBusRunsMessagesTransformation = RegionalBusRunsMessagesTransformation = __decorate([
    (0, tsyringe_1.injectable)()
], RegionalBusRunsMessagesTransformation);
//# sourceMappingURL=RegionalBusRunsMessagesTransformation.js.map