package access

import (
	"context"
	"strings"
)

type closurePlan struct {
	effectiveProbeAPIKey    string
	effectiveProbeKeySource string
}

func (s *Service) prepareClosurePlan(ctx context.Context, req ClosureRequest) (closurePlan, error) {
	requestedProbeAPIKey := strings.TrimSpace(req.ProbeAPIKey)
	plan := closurePlan{
		effectiveProbeAPIKey: requestedProbeAPIKey,
	}
	if requestedProbeAPIKey != "" {
		plan.effectiveProbeKeySource = ProbeKeySourceRequestedProbeAPIKey
	}
	if strings.TrimSpace(req.Mode) != ModeSubscription {
		return plan, nil
	}
	return s.prepareSubscriptionPlan(ctx, req, plan)
}
