<?php

namespace GriffinForms\Includes\CommandPalette\Providers;

use GriffinForms\Includes\CommandPalette\KeywordMap;
use GriffinForms\Includes\CommandPalette\SearchProviderInterface;
use GriffinForms\Includes\CommandPalette\SearchResultItem;

class BuilderKeywordsProvider implements SearchProviderInterface
{
    private KeywordMap $map;

    public function __construct(KeywordMap $map)
    {
        $this->map = $map;
    }

    public function getProviderId(): string { return 'builder_keywords'; }
    public function getLabel(): string      { return 'Builder'; }
    public function getPriority(): int      { return 20; }
    public function getQuickItems(int $form_id): array { return []; }

    public function query(string $query, int $form_id): array
    {
        if ($query === '') {
            return [];
        }

        return $this->map->search($query);
    }
}
