<?php

declare(strict_types=1);

namespace App\Modules\Email;

use App\Modules\Shipments\ShipmentPackageRepository;
use App\Modules\Sms\SmsVariableResolver;

final class VariableResolver
{
    private readonly SmsVariableResolver $inner;

    public function __construct(
        ShipmentPackageRepository $shipmentPackageRepository,
        ?SmsVariableResolver $inner = null
    ) {
        $this->inner = $inner ?? new SmsVariableResolver($shipmentPackageRepository);
    }

    /**
     * @param array<string, mixed> $order
     * @param array<int, array<string, mixed>> $addresses
     * @param array<string, mixed> $companySettings
     * @return array<string, string>
     */
    public function buildVariableMap(array $order, array $addresses, array $companySettings): array
    {
        return $this->inner->buildVariableMap($order, $addresses, $companySettings);
    }

    /**
     * @param array<string, string> $variableMap
     */
    public function resolve(string $template, array $variableMap): string
    {
        return $this->inner->resolve($template, $variableMap);
    }
}
