# utils/search.py

import string
from config import SETTINGS


def generate_alphabet_combinations(length: int):
    """
    Генерирует все комбинации латинских букв указанной длины.
    """
    if length <= 0:
        return []

    from itertools import product
    letters = string.ascii_lowercase
    return [''.join(p) for p in product(letters, repeat=length)]


def search_by_alphabet(length: int = None):
    """
    Возвращает ТОЛЬКО комбинации символов, например ["a", "b", ..., "aa", "ab"]
    """
    if length is None:
        length = SETTINGS.get("combination_length", 1)
    combinations = generate_alphabet_combinations(length)
    return combinations


def search_by_keywords(keywords: list = None):
    """
    Возвращает ТОЛЬКО ключи.
    """
    if keywords is None:
        keywords = SETTINGS.get("keywords", [])

    return keywords
