<?php

namespace App\Support;

use App\Models\Package;

class CheckoutRoutes
{
    public static function slugForLocale(?string $locale = null): string
    {
        $normalized = LocaleConfig::canonicalize($locale ?? app()->getLocale());

        return $normalized === 'en' ? 'checkout' : 'bestellen';
    }

    public static function wizardUrl(Package|int $package, ?string $locale = null): string
    {
        $normalized = LocaleConfig::canonicalize($locale ?? app()->getLocale());
        $slug = self::slugForLocale($normalized);
        $packageId = $package instanceof Package ? $package->getKey() : $package;

        return route('checkout.show', [
            'locale' => $normalized,
            'checkoutSlug' => $slug,
            'package' => $packageId,
        ]);
    }
}
