// Package build binds all the routes into the specified app.
package build

import (
	"github.com/ardanlabs/kronk/cmd/server/app/domain/audioapp"
	"github.com/ardanlabs/kronk/cmd/server/app/domain/chatapp"
	"github.com/ardanlabs/kronk/cmd/server/app/domain/checkapp"
	"github.com/ardanlabs/kronk/cmd/server/app/domain/downapp"
	"github.com/ardanlabs/kronk/cmd/server/app/domain/embedapp"
	"github.com/ardanlabs/kronk/cmd/server/app/domain/msgsapp"
	"github.com/ardanlabs/kronk/cmd/server/app/domain/playgroundapp"
	"github.com/ardanlabs/kronk/cmd/server/app/domain/rerankapp"
	"github.com/ardanlabs/kronk/cmd/server/app/domain/respapp"
	"github.com/ardanlabs/kronk/cmd/server/app/domain/tokenapp"
	"github.com/ardanlabs/kronk/cmd/server/app/domain/toolapp"
	"github.com/ardanlabs/kronk/cmd/server/app/sdk/mux"
	"github.com/ardanlabs/kronk/cmd/server/foundation/web"
)

// Routes constructs the all value which provides the implementation of
// of RouteAdder for specifying what routes to bind to this instance.
func Routes() all {
	return all{}
}

type all struct{}

// Add implements the RouterAdder interface.
func (all) Add(app *web.App, cfg mux.Config) {
	checkapp.Routes(app, checkapp.Config{
		Build: cfg.Build,
		Log:   cfg.Log,
	})

	toolapp.Routes(app, toolapp.Config{
		Log:         cfg.Log,
		AuthClient:  cfg.AuthClient,
		Pool:        cfg.Pool,
		Libs:        cfg.Libs,
		Models:      cfg.Models,
		BuckyLibs:   cfg.BuckyLibs,
		BuckyModels: cfg.BuckyModels,
	})

	chatapp.Routes(app, chatapp.Config{
		Log:        cfg.Log,
		AuthClient: cfg.AuthClient,
		Pool:       cfg.Pool,
	})

	embedapp.Routes(app, embedapp.Config{
		Log:        cfg.Log,
		AuthClient: cfg.AuthClient,
		Pool:       cfg.Pool,
	})

	audioapp.Routes(app, audioapp.Config{
		Log:        cfg.Log,
		AuthClient: cfg.AuthClient,
		Pool:       cfg.Pool,
	})

	rerankapp.Routes(app, rerankapp.Config{
		Log:        cfg.Log,
		AuthClient: cfg.AuthClient,
		Pool:       cfg.Pool,
	})

	tokenapp.Routes(app, tokenapp.Config{
		Log:        cfg.Log,
		AuthClient: cfg.AuthClient,
		Pool:       cfg.Pool,
	})

	respapp.Routes(app, respapp.Config{
		Log:        cfg.Log,
		AuthClient: cfg.AuthClient,
		Pool:       cfg.Pool,
	})

	msgsapp.Routes(app, msgsapp.Config{
		Log:        cfg.Log,
		AuthClient: cfg.AuthClient,
		Pool:       cfg.Pool,
	})

	playgroundapp.Routes(app, playgroundapp.Config{
		Log:        cfg.Log,
		AuthClient: cfg.AuthClient,
		Pool:       cfg.Pool,
		Models:     cfg.Models,
	})

	if cfg.DownloadEnabled {
		downapp.Routes(app, downapp.Config{
			Log:        cfg.Log,
			ModelsPath: cfg.Models.Path(),
			Libs:       cfg.Libs,
			Models:     cfg.Models,
		})
	}
}
