import functools

from snek.mapper.channel import ChannelMapper
from snek.mapper.channel_attachment import ChannelAttachmentMapper
from snek.mapper.channel_member import ChannelMemberMapper
from snek.mapper.channel_message import ChannelMessageMapper
from snek.mapper.container import ContainerMapper
from snek.mapper.drive import DriveMapper
from snek.mapper.drive_item import DriveItemMapper
from snek.mapper.notification import NotificationMapper
from snek.mapper.push import PushMapper
from snek.mapper.repository import RepositoryMapper
from snek.mapper.user import UserMapper
from snek.mapper.user_property import UserPropertyMapper
from snek.system.object import Object


@functools.cache
def get_mappers(app=None):
    return Object(
        **{
            "user": UserMapper(app=app),
            "channel_member": ChannelMemberMapper(app=app),
            "channel": ChannelMapper(app=app),
            "channel_message": ChannelMessageMapper(app=app),
            "notification": NotificationMapper(app=app),
            "drive_item": DriveItemMapper(app=app),
            "drive": DriveMapper(app=app),
            "user_property": UserPropertyMapper(app=app),
            "repository": RepositoryMapper(app=app),
            "channel_attachment": ChannelAttachmentMapper(app=app),
            "container": ContainerMapper(app=app),
            "push": PushMapper(app=app),
        }
    )


def get_mapper(name, app=None):
    return get_mappers(app=app)[name]
