package automation

import (
	"context"

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

// These helpers keep legacy unit tests concise while production callers use
// only the error-aware Formula Resource APIs.
func (e *FlowExecutor) resolveValueCtxWithPresence(ctx context.Context, interview *models.FlowInterview, user *models.UserSession, value interface{}) (interface{}, bool) {
	resolved, present, _ := e.ResolveFlowResource(ctx, interview, user, value)
	return resolved, present
}

func (e *FlowExecutor) resolveAssignmentRHSValueWithPresence(ctx context.Context, interview *models.FlowInterview, user *models.UserSession, flowMeta *models.FlowMetadata, value interface{}) (interface{}, bool) {
	resolved, present, _ := e.resolveAssignmentRHSValueWithPresenceE(ctx, interview, user, flowMeta, value)
	return resolved, present
}

func (e *FlowExecutor) evaluateConditionsCtx(ctx context.Context, interview *models.FlowInterview, user *models.UserSession, conditions []models.FlowCondition, logic string) bool {
	matched, _ := e.evaluateConditionsCtxE(ctx, interview, user, conditions, logic)
	return matched
}

func (e *FlowExecutor) evaluateConditionCtx(ctx context.Context, interview *models.FlowInterview, user *models.UserSession, condition *models.FlowCondition) bool {
	matched, _ := e.evaluateConditionCtxE(ctx, interview, user, condition)
	return matched
}
