// codeberg.org/mapleopentech/monorepo/cloud/maplefile-backend/internal/service/auth/provider.go
package auth

import (
	"go.uber.org/zap"

	"codeberg.org/mapleopentech/monorepo/cloud/maplefile-backend/config"
	uc_user "codeberg.org/mapleopentech/monorepo/cloud/maplefile-backend/internal/usecase/user"
	"codeberg.org/mapleopentech/monorepo/cloud/maplefile-backend/pkg/auditlog"
	"codeberg.org/mapleopentech/monorepo/cloud/maplefile-backend/pkg/emailer/mailgun"
	"codeberg.org/mapleopentech/monorepo/cloud/maplefile-backend/pkg/security/jwt"
	"codeberg.org/mapleopentech/monorepo/cloud/maplefile-backend/pkg/storage/cache/cassandracache"
)

// ProvideRegisterService provides the register service
func ProvideRegisterService(
	config *config.Config,
	logger *zap.Logger,
	auditLogger auditlog.AuditLogger,
	userCreateUC uc_user.UserCreateUseCase,
	userGetByEmailUC uc_user.UserGetByEmailUseCase,
	userDeleteByIDUC uc_user.UserDeleteByIDUseCase,
	emailer mailgun.Emailer,
) RegisterService {
	return NewRegisterService(config, logger, auditLogger, userCreateUC, userGetByEmailUC, userDeleteByIDUC, emailer)
}

// ProvideVerifyEmailService provides the verify email service
func ProvideVerifyEmailService(
	logger *zap.Logger,
	auditLogger auditlog.AuditLogger,
	userGetByVerificationCodeUC uc_user.UserGetByVerificationCodeUseCase,
	userUpdateUC uc_user.UserUpdateUseCase,
) VerifyEmailService {
	return NewVerifyEmailService(logger, auditLogger, userGetByVerificationCodeUC, userUpdateUC)
}

// ProvideResendVerificationService provides the resend verification service
func ProvideResendVerificationService(
	config *config.Config,
	logger *zap.Logger,
	userGetByEmailUC uc_user.UserGetByEmailUseCase,
	userUpdateUC uc_user.UserUpdateUseCase,
	emailer mailgun.Emailer,
) ResendVerificationService {
	return NewResendVerificationService(config, logger, userGetByEmailUC, userUpdateUC, emailer)
}

// ProvideRequestOTTService provides the request OTT service
func ProvideRequestOTTService(
	config *config.Config,
	logger *zap.Logger,
	userGetByEmailUC uc_user.UserGetByEmailUseCase,
	cache cassandracache.CassandraCacher,
	emailer mailgun.Emailer,
) RequestOTTService {
	return NewRequestOTTService(config, logger, userGetByEmailUC, cache, emailer)
}

// ProvideVerifyOTTService provides the verify OTT service
func ProvideVerifyOTTService(
	logger *zap.Logger,
	userGetByEmailUC uc_user.UserGetByEmailUseCase,
	cache cassandracache.CassandraCacher,
) VerifyOTTService {
	return NewVerifyOTTService(logger, userGetByEmailUC, cache)
}

// ProvideCompleteLoginService provides the complete login service
func ProvideCompleteLoginService(
	config *config.Config,
	logger *zap.Logger,
	auditLogger auditlog.AuditLogger,
	userGetByEmailUC uc_user.UserGetByEmailUseCase,
	cache cassandracache.CassandraCacher,
	jwtProvider jwt.JWTProvider,
) CompleteLoginService {
	return NewCompleteLoginService(config, logger, auditLogger, userGetByEmailUC, cache, jwtProvider)
}

// ProvideRefreshTokenService provides the refresh token service
func ProvideRefreshTokenService(
	cfg *config.Config,
	logger *zap.Logger,
	auditLogger auditlog.AuditLogger,
	cache cassandracache.CassandraCacher,
	jwtProvider jwt.JWTProvider,
	userGetByIDUC uc_user.UserGetByIDUseCase,
) RefreshTokenService {
	return NewRefreshTokenService(cfg, logger, auditLogger, cache, jwtProvider, userGetByIDUC)
}

// ProvideRecoveryInitiateService provides the recovery initiate service
func ProvideRecoveryInitiateService(
	logger *zap.Logger,
	auditLogger auditlog.AuditLogger,
	userGetByEmailUC uc_user.UserGetByEmailUseCase,
	cache cassandracache.CassandraCacher,
) RecoveryInitiateService {
	return NewRecoveryInitiateService(logger, auditLogger, userGetByEmailUC, cache)
}

// ProvideRecoveryVerifyService provides the recovery verify service
func ProvideRecoveryVerifyService(
	logger *zap.Logger,
	cache cassandracache.CassandraCacher,
	userGetByEmailUC uc_user.UserGetByEmailUseCase,
) RecoveryVerifyService {
	return NewRecoveryVerifyService(logger, cache, userGetByEmailUC)
}

// ProvideRecoveryCompleteService provides the recovery complete service
func ProvideRecoveryCompleteService(
	logger *zap.Logger,
	auditLogger auditlog.AuditLogger,
	userGetByEmailUC uc_user.UserGetByEmailUseCase,
	userUpdateUC uc_user.UserUpdateUseCase,
	cache cassandracache.CassandraCacher,
) RecoveryCompleteService {
	return NewRecoveryCompleteService(logger, auditLogger, userGetByEmailUC, userUpdateUC, cache)
}
