package main

import (
	"embed"
	"github.com/wailsapp/wails/v2"
	"github.com/wailsapp/wails/v2/pkg/options"
	"github.com/wailsapp/wails/v2/pkg/options/assetserver"
	"skapp/pkg/core"
	"skapp/pkg/sdk/config"
	"skapp/pkg/sdk/dialog"
	"skapp/pkg/sdk/env"
	fileSdk "skapp/pkg/sdk/file"
	"skapp/pkg/sdk/file/duplicate"
	"skapp/pkg/sdk/file/hash"
	"skapp/pkg/sdk/system"
	"skapp/pkg/sdk/utils"
)

//go:embed all:frontend/dist
var assets embed.FS

func main() {
	// Create an instance of the app structure
	app := core.NewApp()
	fileSupport := fileSdk.New()
	hashSupport := hash.New(fileSupport)
	duplicateSupport := duplicate.New(fileSupport, hashSupport)
	// Create application with options
	err := wails.Run(&options.App{
		Title:  "wails",
		Width:  1024,
		Height: 768,
		AssetServer: &assetserver.Options{
			Assets:  assets,
			Handler: app.Handler,
		},
		BackgroundColour: &options.RGBA{R: 255, G: 255, B: 255, A: 1},
		OnStartup:        app.Startup,
		OnBeforeClose:    app.BeforeClose,
		OnShutdown:       app.Shutdown,
		Bind: []interface{}{
			app,
			&env.Env{},
			&utils.Utils{},
			&system.InfoUtils{},
			dialog.New(app),
			&config.Support{},
			fileSupport,
			hashSupport,
			duplicateSupport,
		},
		Debug: options.Debug{
			OpenInspectorOnStartup: true,
		},
	})

	if err != nil {
		println("Error:", err.Error())
	}
}
