//go:build wireinject
// +build wireinject

// The build tag makes sure the stub is not built in the final build.

package main

import (
	"log/slog"

	"kra/internal/biz"
	taskbiz "kra/internal/biz/task"
	"kra/internal/config"
	"kra/internal/data"
	"kra/internal/initialize"
	"kra/internal/integration"
	"kra/internal/integration/cache"
	"kra/internal/logging"
	"kra/internal/modules"
	"kra/internal/server"
	"kra/internal/server/handler"
	"kra/internal/server/middleware"
	"kra/internal/server/router"
	"kra/internal/service"
	systemservice "kra/internal/service/system"
	"kra/internal/worker"
	platformtask "kra/pkg/task"

	"github.com/go-kratos/kratos/v3"
	"github.com/google/wire"
)

// wireApp init kratos application.
func wireApp(*config.Server, *config.Store, *slog.Logger, *logging.ReloadableLogger, string) (*kratos.App, func(), error) {
	panic(wire.Build(
		server.ProviderSet,
		handler.ProviderSet,
		router.ProviderSet,
		worker.ProviderSet,
		modules.Catalog,
		taskRegistry,
		buildRuntime,
		data.ProviderSet,
		integration.ProviderSet,
		initialize.ProviderSet,
		wire.Bind(new(initialize.Backend), new(*data.Data)),
		wire.Bind(new(cache.RedisProvider), new(*data.Data)),
		wire.Bind(new(middleware.TokenAuthenticator), new(*systemservice.AuthService)),
		wire.Bind(new(taskbiz.TaskMethodRegistry), new(*platformtask.Registry)),
		biz.ProviderSet,
		service.ProviderSet,
		newApp,
	))
}
