package records

import (
	"strings"

	"github.com/nexuscrm/shared/pkg/constants"
	"github.com/nexuscrm/shared/pkg/models"
)

// isRecycleBinManagedObject is the single object-eligibility predicate for the
// user-facing recycle bin. It decides whether a soft-deleted record for this
// object may be listed, restored, or purged by the recycle-bin surface.
//
// This preserves the current public LIST contract: objects participate unless
// their metadata declares hard delete, while `_System_*` infrastructure tables
// stay out of the user-facing recycle bin. Do not narrow this by TableType here:
// built-in non-prefixed objects such as Dashboard, and legacy schemas with blank
// TableType, are soft-deletable today and must not get unreachable tombstones.
func isRecycleBinManagedObject(schema *models.ObjectMetadata) bool {
	if schema == nil {
		return false
	}
	if strings.EqualFold(strings.TrimSpace(schema.DeleteMode), constants.DeleteModeHard) {
		return false
	}
	if constants.IsSystemTable(schema.APIName) {
		return false
	}
	return true
}
