# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/fasthtml/chat.ipynb.

# %% auto 0
__all__ = ['style_template', 'styles', 'Card', 'Cards']

# %% ../../nbs/fasthtml/chat.ipynb 1
from .. import AD
from fasthtml.common import *

# %% ../../nbs/fasthtml/chat.ipynb 3
style_template = """
background: {bg};
text-align: {align};
padding: 10px;
"""


styles = AD(
    css={
        "user": style_template.format(bg="#EEE6CA", align="right"),
        "assistant": style_template.format(bg="#E5BEB5", align="left"),
    },
    emojis={"user": "🗣️", "assistant": "🐕‍🦺"},
)


def Card(data: dict):
    role = data["role"]
    content = data["content"]

    style = styles.css[role]
    emoji = styles.emojis[role]
    card = Div(f"{emoji} {role}: {content}", style=style)

    return card


def Cards(data: List[dict], **kwargs):
    cards = [Card(d) for d in data]
    return Div(*cards, **kwargs)


Cards([
    {"role": "user", "content": "hi"},
    {"role": "assistant", "content": "How can I help you"},
])
