//go:build wireinject
// +build wireinject

package wire

import (
	"github.com/go-nunu/nunu-layout-advanced/internal/job"
	"github.com/go-nunu/nunu-layout-advanced/internal/repository"
	"github.com/go-nunu/nunu-layout-advanced/internal/repository/admin"
	flexCdn2 "github.com/go-nunu/nunu-layout-advanced/internal/repository/api/flexCdn"
	waf2 "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"
	admin2 "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/internal/task"
	"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/log"
	"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.NewMongoClient,
	repository.NewCasbinEnforcer,
	repository.NewMongoDB,
	repository.NewRabbitMQ,
	repository.NewRepository,
	repository.NewTransaction,
	admin.NewUserRepository,
	repository.NewGameShieldRepository,
	repository.NewGameShieldBackendRepository,
	repository.NewGameShieldPublicIpRepository,
	repository.NewHostRepository,
	repository.NewGameShieldUserIpRepository,
	repository.NewGameShieldSdkIpRepository,
	waf2.NewWebForwardingRepository,
	waf2.NewTcpforwardingRepository,
	waf2.NewUdpForWardingRepository,
	waf2.NewGlobalLimitRepository,
	repository.NewGatewayGroupRepository,
	repository.NewGateWayGroupIpRepository,
	flexCdn2.NewCdnRepository,
	repository.NewExpiredRepository,
	flexCdn2.NewProxyRepository,
	waf2.NewGatewayipRepository,
	repository.NewLogRepository,
	flexCdn2.NewCcRepository,
	flexCdn2.NewCcIpListRepository,
	admin.NewWafLogRepository,
)

var taskSet = wire.NewSet(
	task.NewTask,
	task.NewUserTask,
	task.NewGameShieldTask,
	task.NewWafTask,
)

var jobSet = wire.NewSet(
	job.NewJob,
	job.NewUserJob,
	job.NewWhitelistJob,
	job.NewWafLogJob,
)
var serverSet = wire.NewSet(
	server.NewTaskServer,
	server.NewJobServer,
)

var serviceSet = wire.NewSet(
	service.NewService,
	service.NewAoDunService,
	gameShield.NewGameShieldService,
	service.NewCrawlerService,
	service.NewGameShieldPublicIpService,
	service.NewDuedateService,
	service.NewFormatterService,
	service.NewParserService,
	service.NewRequiredService,
	service.NewHostService,
	gameShield.NewGameShieldBackendService,
	service.NewGameShieldSdkIpService,
	service.NewGameShieldUserIpService,
	waf.NewWafFormatterService,
	flexCdn.NewCdnService,
	service.NewRequestService,
	waf.NewTcpforwardingService,
	waf.NewUdpForWardingService,
	waf.NewWebForwardingService,
	flexCdn.NewProxyService,
	flexCdn.NewSslCertService,
	flexCdn.NewWebsocketService,
	waf.NewCcService,
	waf.NewGatewayipService,
	service.NewLogService,
	waf.NewCcIpListService,
	waf.NewBuildAudunService,
	waf.NewZzybgpService,
	admin2.NewWafLogService,

)

// build App
func newApp(
	task *server.TaskServer,
	jobServer *server.JobServer,
) *app.App {
	return app.NewApp(
		app.WithServer(task, jobServer),
		app.WithName("demo-task"),
	)
}

func NewWire(*viper.Viper, *log.Logger) (*app.App, func(), error) {
	panic(wire.Build(
		repositorySet,
		taskSet,
		jobSet,
		serverSet,
		serviceSet,
		newApp,
		sid.NewSid,
		jwt.NewJwt,
	))
}
