// Copyright (c) 2025 Kiel University and others.
// Copyright (c) 2026 The elk-go Authors.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0.
//
// SPDX-License-Identifier: EPL-2.0

package preserveorder

import (
	basegraph 
	
)

// CalculateModelOrderOrGroupModelOrder is ELK 0.12's
// CMGroupModelOrderCalculator. ENFORCED group order applies only when both
// compared elements belong to one of the configured enforced groups.
func (
	 *layered.LGraph,
	,  *basegraph.PropertyMap,
	 int,
) int {
	if !basegraph.Has(, layered.ModelOrder) {
		return -1
	}
	if basegraph.Get(&.Properties, layered.CrossingMinimizationGroupOrder) ==
		layered.GroupOrderEnforced {
		 := basegraph.Get(
			&.Properties,
			layered.CrossingMinimizationEnforcedGroups,
		)
		 := basegraph.Get(, layered.CrossingMinimizationGroupID)
		 := basegraph.Get(, layered.CrossingMinimizationGroupID)
		if containsGroup(, ) && containsGroup(, ) {
			return * + basegraph.Get(, layered.ModelOrder)
		}
	}
	return basegraph.Get(, layered.ModelOrder)
}

func containsGroup( []int,  int) bool {
	for ,  := range  {
		if  ==  {
			return true
		}
	}
	return false
}