package mongo

import (
	"strings"

	"go.mongodb.org/mongo-driver/bson"
)

// BrandScopeFilter matches documents keyed by brand_id or legacy persona_id.
func BrandScopeFilter(brandID string) bson.M {
	id := strings.TrimSpace(brandID)
	return bson.M{"$or": []bson.M{
		{"brand_id": id},
		{"persona_id": id},
	}}
}

// ResolveBrandID returns brand_id when set, otherwise legacy persona_id.
func ResolveBrandID(brandID, legacyPersonaID string) string {
	if trimmed := strings.TrimSpace(brandID); trimmed != "" {
		return trimmed
	}
	return strings.TrimSpace(legacyPersonaID)
}
