<?php

declare(strict_types=1);

namespace CliqThemes\StoreLocator\Markers;

defined('ABSPATH') || exit;

use CliqThemes\StoreLocator\Support\MarkerRuntime;
use CliqThemes\StoreLocator\Support\SettingsService;

/**
 * Picks one of the marker images packaged with the plugin.
 *
 * A site chooses which in Settings, and every store uses it. Nothing is stored:
 * the choice is a key, and the file it names ships in the plugin.
 */
final class BundledMarkerResolver
{
    /** @var array<string, string> */
    private const PRESETS = [
        'store' => 'shopping.svg',
        'home' => 'home.svg',
        'info' => 'info.svg',
        'car' => 'car.svg',
    ];

    /** @return array{icon_url:string,width:int,height:int} */
    public function resolve(?string $key = null): array
    {
        $key ??= (string) SettingsService::get('locator_marker_preset', 'store');
        $file = self::PRESETS[$key] ?? self::PRESETS['store'];

        return [
            'icon_url' => MarkerRuntime::url($file),
            'width' => 32,
            'height' => 44,
        ];
    }

    /** @return string[] */
    public static function keys(): array
    {
        return array_keys(self::PRESETS);
    }
}
