"""
ritori.meow - Add 'meow' to everything! 🐱

A simple module that adds cat sounds to your strings,
because everything is better with cats.

Usage:
    >>> from ritori import meow
    >>> meow.meow("Hello")
    'Hello，喵～'
    >>> meow.meow("I love Python", style="cute")
    'I love Python (=^･ω･^=) 喵～'
"""

__version__ = "0.1.0"
__author__ = "Ritori"

# 预设的猫咪颜文字
CAT_KAOMOJI = {
    "default": "喵～",
    "cute": "(=^･ω･^=) 喵～",
    "happy": "(^･ω･^) 喵～",
    "sleepy": "(=^-ω-^=) 喵...",
    "excited": "ヾ(=^▽^=)ノ 喵喵喵！",
    "shy": "(⁄ ⁄•⁄ω⁄•⁄ ⁄) 喵...",
    "curious": "(=ↀωↀ=) 喵？",
    "love": "(´,,•ω•,,)♡ 喵～",
}


def meow(text: str, style: str = "default", separator: str = "，") -> str:
    """
    Add a cat sound to the end of a string.
    
    Args:
        text: The string to meow-ify
        style: The style of meow (default, cute, happy, sleepy, excited, shy, curious, love)
        separator: The separator between text and meow (default: "，")
    
    Returns:
        The meow-ified string
    
    Examples:
        >>> meow("Hello")
        'Hello，喵～'
        >>> meow("Good night", style="sleepy")
        'Good night，(=^-ω-^=) 喵...'
        >>> meow("I did it", style="excited", separator=" ")
        'I did it ヾ(=^▽^=)ノ 喵喵喵！'
    """
    suffix = CAT_KAOMOJI.get(style, CAT_KAOMOJI["default"])
    return f"{text}{separator}{suffix}"


def meowify(text: str, every_sentence: bool = False) -> str:
    """
    Add meow to text. If every_sentence is True, add to each sentence.
    
    Args:
        text: The text to process
        every_sentence: If True, add meow after every sentence ending (。.!?！？)
    
    Returns:
        Meow-ified text
    
    Examples:
        >>> meowify("Hello world")
        'Hello world，喵～'
        >>> meowify("Hello. How are you?", every_sentence=True)
        'Hello，喵～. How are you，喵～?'
    """
    if not every_sentence:
        return meow(text)
    
    import re
    # 在句末标点前插入喵
    pattern = r'([。.!?！？])'
    result = re.sub(pattern, r'，喵～\1', text)
    
    # 如果最后没有标点，也加上喵
    if not re.search(r'[。.!?！？]$', text):
        result = meow(result)
    
    return result


def random_meow(text: str) -> str:
    """
    Add a random style of meow to the text.
    
    Args:
        text: The string to meow-ify
    
    Returns:
        The meow-ified string with a random cat kaomoji
    """
    import random
    style = random.choice(list(CAT_KAOMOJI.keys()))
    return meow(text, style=style)


def get_styles() -> list[str]:
    """
    Get all available meow styles.
    
    Returns:
        List of style names
    """
    return list(CAT_KAOMOJI.keys())


__all__ = ["meow", "meowify", "random_meow", "get_styles", "CAT_KAOMOJI"]
