package main

import (
	"fmt"
	"os"

	"github.com/kevin/go-jdenticon/jdenticon"
)

func main() {
	// Test emails
	testEmails := []string{
		"example1@gmail.com",
		"example2@yahoo.com",
	}

	// Test sizes
	sizes := []int{64, 128}

	// Create go-output directory
	outDir := "./go-output"
	if _, err := os.Stat(outDir); os.IsNotExist(err) {
		os.Mkdir(outDir, 0755)
	}

	// Generate Go versions
	for _, email := range testEmails {
		for _, size := range sizes {
			// Generate SVG
			svg, err := jdenticon.ToSVG(email, size)
			if err != nil {
				fmt.Printf("Error generating SVG for %s@%d: %v\n", email, size, err)
				continue
			}
			
			svgFilename := fmt.Sprintf("%s/%s_%d.svg", outDir, 
				email[0:8]+"_at_"+email[9:13]+"_com", size)
			err = os.WriteFile(svgFilename, []byte(svg), 0644)
			if err != nil {
				fmt.Printf("Error writing SVG file: %v\n", err)
				continue
			}
			fmt.Printf("Generated Go SVG: %s\n", svgFilename)

			// Generate PNG
			pngData, err := jdenticon.ToPNG(email, size)
			if err != nil {
				fmt.Printf("Error generating PNG for %s@%d: %v\n", email, size, err)
				continue
			}
			
			pngFilename := fmt.Sprintf("%s/%s_%d.png", outDir, 
				email[0:8]+"_at_"+email[9:13]+"_com", size)
			err = os.WriteFile(pngFilename, pngData, 0644)
			if err != nil {
				fmt.Printf("Error writing PNG file: %v\n", err)
				continue
			}
			fmt.Printf("Generated Go PNG: %s\n", pngFilename)
		}
	}

	// Also generate test-hash for comparison
	testSvg, err := jdenticon.ToSVG("test-hash", 64)
	if err != nil {
		fmt.Printf("Error generating test-hash SVG: %v\n", err)
	} else {
		err = os.WriteFile(outDir+"/test-hash_64.svg", []byte(testSvg), 0644)
		if err != nil {
			fmt.Printf("Error writing test-hash SVG: %v\n", err)
		} else {
			fmt.Println("Generated test-hash Go SVG")
		}
	}

	fmt.Println("\nGo files generated in ./go-output/ directory")
}