from __future__ import annotations
from . import command
from typing import Sequence, Any, List, TYPE_CHECKING
import string
import telegram as tg

if TYPE_CHECKING:
    from main import Bea, Command

wtab = str.maketrans("0123456789:-/abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ",
        "０１２３４５６７８９：－／ａｂｃｄｅｆｇｈｉｊｋｌｍｎｏｐｑｒｓｔｕｖｗｘｙｚＡＢＣＤＥＦＧＨＩＪＫＬＭＮＯＰＱＲＳＴＵＶＷＸＹＺ\u3000")

stab = str.maketrans(string.ascii_lowercase + string.ascii_uppercase, "ᴀʙᴄᴅᴇғɢʜɪᴊᴋʟᴍɴᴏᴘǫʀsᴛᴜᴠᴡxʏᴢ" * 2)

@command('fullwidth (.+)', pass_groups=True, inline=True)
def fullwidth(bea: Bea, bot: tg.Bot, update: tg.Update, groups: Sequence[str]) -> None:
    """ Turn the given text into fullwidth text. """
    if update.inline_query is not None:
        bea.inline_reply_text(groups[0].translate(wtab))
    else:
        update.message.reply_text("%s" % groups[0].translate(wtab), quote=False)

@command('smallcaps (.+)', pass_groups=True, inline=True)
def smallcaps(bea: Bea, bot: tg.Bot, update: tg.Update, groups: Sequence[str]) -> None:
    """ Turn the given text into smallcaps text. """
    if update.inline_query is not None:
        bea.inline_reply_text(groups[0].translate(stab))
    else:
        update.message.reply_text("%s" % groups[0].translate(stab), quote=False)

def init(bea: Bea, config_: Any) -> List[Command]:
    return [smallcaps, fullwidth]
