from typing import Annotated

from fastapi import Depends, Request

from vdash.modules.chart import ChartService
from vdash.modules.sql import SqlService
from vdash.modules.user_db import UserDBService
from vdash.shared import PaginationQuery
from vdash.utils import CryptoHelper


def get_crypto_helper(request: Request) -> CryptoHelper:
    return request.app.state.crypto_helper


def get_user_db_service(
    request: Request,
) -> UserDBService:
    return UserDBService(
        db=request.app.state.db,
        settings=request.app.state.settings,
        crypto_helper=request.app.state.crypto_helper,
    )


def get_sql_service(
    request: Request,
) -> SqlService:
    return SqlService(
        db=request.app.state.db,
        settings=request.app.state.settings,
        sql_agent=request.app.state.sql_agent,
        crypto_helper=request.app.state.crypto_helper,
    )


def get_chart_service(
    request: Request,
) -> ChartService:
    return ChartService(
        db=request.app.state.db,
    )


UserDBServiceDep = Annotated[UserDBService, Depends(get_user_db_service)]
SqlServiceDep = Annotated[SqlService, Depends(get_sql_service)]
ChartServiceDep = Annotated[ChartService, Depends(get_chart_service)]
CryptoHelperDep = Annotated[CryptoHelper, Depends(get_crypto_helper)]
PaginationQueryDep = Annotated[PaginationQuery, Depends()]
