<?php
declare(strict_types=1);

namespace PpPhp\Resources\Icons\CustomSvg;

use PpPhp\Core\IconManager\IconDefinition;
use PpPhp\Core\IconManager\IconSearch;
use PpPhp\Core\Resources\Contracts\ResourcePackInterface;

final class Pack implements ResourcePackInterface
{
    public static function id(): string { return 'custom-svg'; }
    public static function label(): string { return 'Custom SVG'; }
    public static function type(): string { return 'icons'; }
    public static function version(): string { return '1.0.0'; }

    public static function metadata(): array
    {
        return ['storagePath' => 'storage/designer/icons', 'supportsUpload' => true, 'family' => 'custom-svg'];
    }

    public static function assets(): array
    {
        return [
            'css' => [],
            'js' => [],
        ];
    }

    /** @return array<int, IconDefinition> */
    public static function icons(): array
    {
        return [

            new IconDefinition(
                name: 'svg-company-logo',
                label: 'Company Logo',
                pack: 'custom-svg',
                family: 'custom-svg',
                style: 'svg',
                className: '',
                categories: ['custom'],
                aliases: ['logo'],
                keywords: ['company', 'brand', 'svg']
            ),

            new IconDefinition(
                name: 'svg-invoice',
                label: 'Invoice',
                pack: 'custom-svg',
                family: 'custom-svg',
                style: 'svg',
                className: '',
                categories: ['documents'],
                aliases: ['bill'],
                keywords: ['invoice', 'receipt', 'svg']
            ),

            new IconDefinition(
                name: 'svg-customer',
                label: 'Customer',
                pack: 'custom-svg',
                family: 'custom-svg',
                style: 'svg',
                className: '',
                categories: ['users'],
                aliases: ['client'],
                keywords: ['customer', 'person', 'svg']
            ),

        ];
    }

    /** @return array<int, IconDefinition> */
    public static function search(string $query, int $limit = 100): array
    {
        return IconSearch::search(self::icons(), $query, $limit);
    }
}
