//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/server"
	"github.com/go-nunu/nunu-layout-advanced/internal/service"
	"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,
	repository.NewUserRepository,
	repository.NewGameShieldRepository,
	repository.NewGameShieldBackendRepository,
	repository.NewGameShieldPublicIpRepository,
	repository.NewHostRepository,
	repository.NewGameShieldUserIpRepository,
	repository.NewGameShieldSdkIpRepository,
	repository.NewWebForwardingRepository,
	repository.NewTcpforwardingRepository,
	repository.NewUdpForWardingRepository,
	repository.NewWebLimitRepository,
	repository.NewTcpLimitRepository,
	repository.NewUdpLimitRepository,
	repository.NewGlobalLimitRepository,
	repository.NewGatewayGroupRepository,
	repository.NewGateWayGroupIpRepository,
	repository.NewCdnRepository,
	repository.NewExpiredRepository,
	repository.NewProxyRepository,

)

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

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

var serviceSet = wire.NewSet(
	service.NewService,
	service.NewAoDunService,
	service.NewGameShieldService,
	service.NewCrawlerService,
	service.NewGameShieldPublicIpService,
	service.NewDuedateService,
	service.NewFormatterService,
	service.NewParserService,
	service.NewRequiredService,
	service.NewHostService,
	service.NewGameShieldBackendService,
	service.NewGameShieldSdkIpService,
	service.NewGameShieldUserIpService,
	service.NewWafFormatterService,
	service.NewCdnService,
	service.NewRequestService,
	service.NewTcpforwardingService,
	service.NewUdpForWardingService,
	service.NewWebForwardingService,
	service.NewProxyService,
	service.NewSslCertService,
	service.NewWebsocketService,
)

// 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,
	))
}
