//go:build wireinject
// +build wireinject

package wire

import (
	"github.com/go-nunu/nunu-layout-advanced/internal/handler"
	adminHandler "github.com/go-nunu/nunu-layout-advanced/internal/handler/admin"
	wafHandler "github.com/go-nunu/nunu-layout-advanced/internal/handler/api/waf"
	"github.com/go-nunu/nunu-layout-advanced/internal/middleware"
	"github.com/go-nunu/nunu-layout-advanced/internal/repository"
	adminRep "github.com/go-nunu/nunu-layout-advanced/internal/repository/admin"
	flexCdnRep "github.com/go-nunu/nunu-layout-advanced/internal/repository/api/flexCdn"
	wafRep "github.com/go-nunu/nunu-layout-advanced/internal/repository/api/waf"
	"github.com/go-nunu/nunu-layout-advanced/internal/server"
	"github.com/go-nunu/nunu-layout-advanced/internal/service"
	"github.com/go-nunu/nunu-layout-advanced/internal/service/admin"
	"github.com/go-nunu/nunu-layout-advanced/internal/service/api/flexCdn"
	"github.com/go-nunu/nunu-layout-advanced/internal/service/api/gameShield"
	"github.com/go-nunu/nunu-layout-advanced/internal/service/api/waf"
	"github.com/go-nunu/nunu-layout-advanced/pkg/app"
	"github.com/go-nunu/nunu-layout-advanced/pkg/jwt"
	"github.com/go-nunu/nunu-layout-advanced/pkg/limiter"
	"github.com/go-nunu/nunu-layout-advanced/pkg/log"
	"github.com/go-nunu/nunu-layout-advanced/pkg/server/http"
	"github.com/go-nunu/nunu-layout-advanced/pkg/sid"
	"github.com/google/wire"
	"github.com/spf13/viper"
)

var repositorySet = wire.NewSet(
	repository.NewDB,
	repository.NewRedis,
	repository.NewCasbinEnforcer,
	repository.NewMongoClient,
	repository.NewMongoDB,
	repository.NewRabbitMQ,
	repository.NewRepository,
	repository.NewTransaction,
	adminRep.NewAdminRepository,
	adminRep.NewUserRepository,
	repository.NewGameShieldRepository,
	repository.NewGameShieldPublicIpRepository,
	wafRep.NewWebForwardingRepository,
	wafRep.NewTcpforwardingRepository,
	wafRep.NewUdpForWardingRepository,
	repository.NewGameShieldUserIpRepository,
	repository.NewGameShieldBackendRepository,
	repository.NewGameShieldSdkIpRepository,
	repository.NewHostRepository,
	wafRep.NewGlobalLimitRepository,
	repository.NewGatewayGroupRepository,
	repository.NewGateWayGroupIpRepository,
	flexCdnRep.NewCdnRepository,
	wafRep.NewAllowAndDenyIpRepository,
	flexCdnRep.NewProxyRepository,
	flexCdnRep.NewCcRepository,
	repository.NewExpiredRepository,
	repository.NewLogRepository,
	wafRep.NewGatewayipRepository,
	adminRep.NewGatewayIpAdminRepository,
	flexCdnRep.NewCcIpListRepository,
	adminRep.NewLogRepository,
	adminRep.NewWafLogRepository,

)

var serviceSet = wire.NewSet(
	service.NewService,
	admin.NewUserService,
	admin.NewGatewayIpAdminService,
	admin.NewAdminService,
	gameShield.NewGameShieldService,
	service.NewAoDunService,
	service.NewGameShieldPublicIpService,
	service.NewDuedateService,
	service.NewFormatterService,
	service.NewParserService,
	service.NewRequiredService,
	service.NewCrawlerService,
	waf.NewWebForwardingService,
	waf.NewTcpforwardingService,
	waf.NewUdpForWardingService,
	service.NewGameShieldUserIpService,
	gameShield.NewGameShieldBackendService,
	service.NewGameShieldSdkIpService,
	service.NewHostService,
	waf.NewGlobalLimitService,
	service.NewGatewayGroupService,
	waf.NewWafFormatterService,
	service.NewGateWayGroupIpService,
	service.NewRequestService,
	flexCdn.NewCdnService,
	waf.NewAllowAndDenyIpService,
	flexCdn.NewProxyService,
	flexCdn.NewSslCertService,
	flexCdn.NewWebsocketService,
	waf.NewCcService,
	service.NewLogService,
	waf.NewGatewayipService,
	waf.NewCcIpListService,
	waf.NewCdnLogService,
	waf.NewBuildAudunService,
	waf.NewZzybgpService,
	admin.NewLogService,
	admin.NewWafLogService,
)

var handlerSet = wire.NewSet(
	handler.NewHandler,
	adminHandler.NewUserHandler,
	adminHandler.NewAdminHandler,
	adminHandler.NewGatewayIpAdminHandler,
	handler.NewGameShieldHandler,
	handler.NewGameShieldPublicIpHandler,
	wafHandler.NewWebForwardingHandler,
	wafHandler.NewTcpforwardingHandler,
	wafHandler.NewUdpForWardingHandler,
	handler.NewGameShieldUserIpHandler,
	handler.NewGameShieldBackendHandler,
	handler.NewGameShieldSdkIpHandler,
	handler.NewHostHandler,
	wafHandler.NewGlobalLimitHandler,
	handler.NewGatewayGroupHandler,
	handler.NewGateWayGroupIpHandler,
	wafHandler.NewAllowAndDenyIpHandler,
	wafHandler.NewCcHandler,
	wafHandler.NewGatewayipHandler,
	wafHandler.NewCcIpListHandler,
	wafHandler.NewCdnLogHandler,
	adminHandler.NewLogHandler,
	adminHandler.NewWafLogHandler,
)



// 限流器依赖集
var limiterSet = wire.NewSet(
	limiter.NewLimiter,
	middleware.NewRateLimitMiddleware,
)

var serverSet = wire.NewSet(
	server.NewHTTPServer,
	
)

// build App
func newApp(
	httpServer *http.Server,
) *app.App {
	return app.NewApp(
		app.WithServer(httpServer),
		app.WithName("demo-server"),
	)
}

func NewWire(*viper.Viper, *log.Logger) (*app.App, func(), error) {
	panic(wire.Build(
		repositorySet,
		serviceSet,
		handlerSet,

		serverSet,
		limiterSet,
		sid.NewSid,
		jwt.NewJwt,
		newApp,
	))
}
