"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.PricingMapper = void 0;
const common_1 = require("@nestjs/common");
let PricingMapper = class PricingMapper {
    /**
     * Maps Hetzner pricing data to PricingDto
     * Optionally filters by region and nodeSize
     */
    mapHetznerPricingToDto(pricing, provider, regionFilter, nodeSizeFilter) {
        let serverTypes = pricing.server_types;
        // Filter by nodeSize (server type name)
        if (nodeSizeFilter) {
            serverTypes = serverTypes.filter((st) => st.name.toLowerCase() === nodeSizeFilter.toLowerCase());
        }
        // Map server types and optionally filter prices by region
        const mappedServerTypes = serverTypes.map((st) => this.mapServerTypePricing(st, regionFilter));
        return {
            provider: provider.toLowerCase(),
            currency: pricing.currency,
            vatRate: pricing.vat_rate,
            serverTypes: mappedServerTypes,
        };
    }
    /**
     * Maps a single server type pricing
     */
    mapServerTypePricing(serverType, regionFilter) {
        let prices = serverType.prices;
        // Filter by region/location
        if (regionFilter) {
            prices = prices.filter((p) => p.location.toLowerCase() === regionFilter.toLowerCase());
        }
        return {
            id: serverType.id.toString(),
            name: serverType.name,
            prices: prices.map((price) => ({
                location: price.location,
                priceHourly: {
                    net: price.price_hourly.net,
                    gross: price.price_hourly.gross,
                },
                priceMonthly: {
                    net: price.price_monthly.net,
                    gross: price.price_monthly.gross,
                },
            })),
        };
    }
};
exports.PricingMapper = PricingMapper;
exports.PricingMapper = PricingMapper = __decorate([
    (0, common_1.Injectable)()
], PricingMapper);
