package main

import (
	
	
)

type stateDiff struct {
	// Added is a list of added module dependencies.
	Added []packages.Module
	// Removed is a list of removed module dependencies.
	Removed []packages.Module
	// Updated is a list of updated module dependencies.
	Updated []moduleDiff
}

type moduleDiff struct {
	// Path is the module path of the updated module.
	Path string

	// Old is the old module.
	Old packages.Module
	// New is the new module.
	New packages.Module

	// OldBroken is a list of broken packages in the old version.
	OldBroken []*packages.Package
	// OldBroken is a list of broken packages in the new version.
	NewBroken []*packages.Package

	// Added is a list of added packages.
	Added []*packages.Package
	// Added is a list of removed packages.
	Removed []*packages.Package

	// Changed is a list of changed packages.
	Changed []packageDiff
}

// Unchanged returns true if there are no changes except for the version bump.
func ( *moduleDiff) () bool {
	return len(.Changed) == 0 &&
		len(.Removed) == 0 &&
		len(.Added) == 0 &&
		len(.NewBroken) == 0 &&
		len(.OldBroken) == 0
}

type packageDiff struct {
	// Path is the package import path from the updated module.
	Path string

	// Old is the old package.
	Old *packages.Package
	// New is the old package.
	New *packages.Package

	// Diff contains API changes report.
	Diff apidiff.Report
}

func ( *packageDiff) () []apidiff.Change {
	return .changes(true)
}

func ( *packageDiff) () []apidiff.Change {
	return .changes(false)
}

func ( *packageDiff) ( bool) []apidiff.Change {
	var  []apidiff.Change
	for ,  := range .Diff.Changes {
		if .Compatible !=  {
			continue
		}
		 = append(, )
	}
	return 
}

// diffState returns the difference in the API between the two workspace states.
func (,  *state) stateDiff {
	 := modulesNotInSet(.Modules, .ModuleByPath)
	 := modulesNotInSet(.Modules, .ModuleByPath)

	 := intersectModuleSets(.ModuleByPath, .ModuleByPath)

	var  []moduleDiff
	for ,  := range  {
		 := .ModuleByPath[]
		 := .ModuleByPath[]

		if .Version == .Version {
			continue
		}

		 := .ByModule[]
		 := .ByModule[]

		,  := splitBrokenPackages()
		,  := splitBrokenPackages()

		 := packagesByImportPath()
		 := packagesByImportPath()

		 := packagesNotInSet(, )
		 := packagesNotInSet(, )

		 := intersectPackageSets(, )

		var  []packageDiff
		for ,  := range  {
			 := []
			 := []
			 := apidiff.Changes(.Types, .Types)
			if len(.Changes) == 0 {
				continue
			}
			 = append(, packageDiff{
				Path: ,
				Old:  ,
				New:  ,
				Diff: ,
			})
		}

		 = append(, moduleDiff{
			Path:      ,
			Old:       ,
			New:       ,
			OldBroken: ,
			NewBroken: ,
			Added:     ,
			Removed:   ,
			Changed:   ,
		})
	}

	return stateDiff{
		Added:   ,
		Removed: ,
		Updated: ,
	}
}