package main

import (
	
	
	

	amhelp 
	am 
	ampipe 
)

func init() {
	// manual logging
	// amhelp.SetEnvLogLevel(am.LogOps)
	// os.Setenv(amhelp.EnvAmLogPrint, "2")

	// am-dbg is required for debugging, go run it
	// go run github.com/pancsta/asyncmachine-go/tools/cmd/am-dbg@latest
	// amhelp.EnableDebugging(false)
	// amhelp.SetEnvLogLevel(am.LogOps)
}

func main() {
	 := context.Background()

	// init state machines
	 := am.New(, am.Schema{
		"Ready":       {},
		"Foo":         {},
		"Bar":         {},
		"Custom":      {},
		"Healthcheck": {Multi: true},
	}, &am.Opts{LogLevel: am.LogOps, Id: "source"})
	 := am.New(, am.Schema{
		"Ready":       {},
		"Foo":         {},
		"Bar":         {},
		"Custom":      {},
		"Healthcheck": {Multi: true},
	}, &am.Opts{LogLevel: am.LogOps, Id: "destination"})
	amhelp.MachDebugEnv()
	amhelp.MachDebugEnv()

	// pipe conventional states
	,  := ampipe.BindReady(, , "", "")
	if  != nil {
		panic()
	}
	_,  = ampipe.BindErr(, , "")
	if  != nil {
		panic()
	}

	// bind single
	_,  = ampipe.Bind(, , "Custom", "", "")
	if  != nil {
		panic()
	}

	// bind many
	_,  = ampipe.BindMany(, , am.S{"Foo", "Bar"}, nil)
	if  != nil {
		panic()
	}

	.Add1("Ready", nil)
	.Add(am.S{"Foo", "Bar"}, nil)

	// pipes are async, wait needed
	 = amhelp.WaitForAll(, time.Second, .When(am.S{"Foo", "Bar", "Ready"}, nil))
	if  != nil {
		panic()
	}

	fmt.Println("done")
}