from __future__ import annotations

from typing import Annotated

from fastapi import Depends
from sqlalchemy.ext.asyncio import AsyncSession

from core.auth.models import CurrentUser
from core.db import get_db
from v1.friendships.repository import SQLAlchemyFriendshipRepository
from v1.friendships.service import FriendshipService
from v1.users.dependencies import get_current_user
from v1.users.repository import SQLAlchemyUserRepository


async def get_friendship_repository(
    session: Annotated[AsyncSession, Depends(get_db)],
) -> SQLAlchemyFriendshipRepository:
    return SQLAlchemyFriendshipRepository(session)


async def get_friendship_service(
    session: Annotated[AsyncSession, Depends(get_db)],
    current_user: Annotated[CurrentUser, Depends(get_current_user)],
) -> FriendshipService:
    friendship_repository = SQLAlchemyFriendshipRepository(session)
    user_repository = SQLAlchemyUserRepository(session)
    return FriendshipService(
        repository=friendship_repository,
        user_repository=user_repository,
        session=session,
        current_user=current_user,
    )
