/**
 * Onboarding Provision Types
 *
 * Interface contract between the Onboarding Agent (Strategy) and the
 * Template Engine (Product). Defines the JSON handoff format that bridges
 * Ethan's Onboarding Agent Framework v1.1 discovery output to our
 * TemplateService.createTeamFromTemplate() provisioning pipeline.
 *
 * Ref: docs/onboarding-agent-framework-v1.1.md (Section 5 — Ingestion Format)
 *
 * @module services/onboarding/onboarding-provision.types
 */
// =============================================================================
// Vertical → Template Mapping
// =============================================================================
/**
 * Static mapping from vertical + goal to the best-match template ID.
 *
 * This is the core resolution logic: given a customer's vertical and goal,
 * which template should we provision?
 *
 * Keys: `${vertical}::${goal}` — fallback to vertical-only if goal doesn't
 * narrow the match.
 */
export const VERTICAL_TEMPLATE_MAP = {
    // Content/Marketing
    'Content/Marketing::Scale': 'growth-marketing-team',
    'Content/Marketing::Time': 'ai-video-social-team',
    // E-commerce/Sales
    'E-commerce/Sales::Scale': 'growth-marketing-team',
    'E-commerce/Sales::Time': 'customer-ops-team',
    // Software/Tech
    'Software/Tech::Scale': 'web-dev-team',
    'Software/Tech::Time': 'web-dev-team',
    // Insurance
    'Insurance::Scale': 'broker-squad-v1',
    'Insurance::Time': 'broker-squad-v1',
    // Property Management
    'Property Management::Scale': 'prop-manager-v1',
    'Property Management::Time': 'prop-manager-v1',
};
/** Default fallback template when no mapping matches. */
export const DEFAULT_TEMPLATE_ID = 'startup-team';
/**
 * Resolve the best template ID for a given vertical and goal.
 *
 * @param vertical - Customer's business vertical
 * @param goal - Customer's primary goal (Scale or Time)
 * @returns The matched template ID
 */
export function resolveTemplateId(vertical, goal) {
    const key = `${vertical}::${goal}`;
    return VERTICAL_TEMPLATE_MAP[key] ?? DEFAULT_TEMPLATE_ID;
}
// =============================================================================
// Type Guards
// =============================================================================
const VALID_VERTICALS = new Set([
    'Content/Marketing',
    'E-commerce/Sales',
    'Software/Tech',
    'Insurance',
    'Property Management',
]);
const VALID_GOALS = new Set(['Scale', 'Time']);
const VALID_BUDGET_TIERS = new Set([
    'starter',
    'pro',
    'managed',
]);
const VALID_URGENCY = new Set([
    'immediate',
    'this_week',
    'this_month',
    'exploring',
]);
const VALID_TEAM_SIZES = new Set([
    'solo',
    'small',
    'medium',
    'large',
]);
/**
 * Validate whether a value is a valid OnboardingVertical.
 *
 * @param value - Value to check
 * @returns True if value is a valid vertical
 */
export function isValidVertical(value) {
    return typeof value === 'string' && VALID_VERTICALS.has(value);
}
/**
 * Validate whether a value is a valid OnboardingGoal.
 *
 * @param value - Value to check
 * @returns True if value is a valid goal
 */
export function isValidGoal(value) {
    return typeof value === 'string' && VALID_GOALS.has(value);
}
/**
 * Validate whether a value is a valid OnboardingBudgetTier.
 *
 * @param value - Value to check
 * @returns True if value is a valid budget tier
 */
export function isValidBudgetTier(value) {
    return typeof value === 'string' && VALID_BUDGET_TIERS.has(value);
}
/**
 * Validate an OnboardingProvisionRequest payload.
 * Checks required fields and enum validity.
 *
 * @param value - Value to validate
 * @returns Object with `valid` flag and optional `errors` array
 */
export function validateProvisionRequest(value) {
    const errors = [];
    if (typeof value !== 'object' || value === null) {
        return { valid: false, errors: ['Request body must be a non-null object'] };
    }
    const req = value;
    // customer.identity
    const customer = req['customer'];
    if (!customer || typeof customer !== 'object') {
        errors.push('customer is required and must be an object');
    }
    else {
        const identity = customer['identity'];
        if (!identity || typeof identity !== 'object') {
            errors.push('customer.identity is required');
        }
        else {
            if (!identity['name'] || typeof identity['name'] !== 'string') {
                errors.push('customer.identity.name is required (string)');
            }
            if (!isValidVertical(identity['vertical'])) {
                errors.push(`customer.identity.vertical must be one of: ${[...VALID_VERTICALS].join(', ')}`);
            }
            if (!VALID_TEAM_SIZES.has(identity['size'])) {
                errors.push(`customer.identity.size must be one of: ${[...VALID_TEAM_SIZES].join(', ')}`);
            }
        }
        // customer.strategy
        const strategy = customer['strategy'];
        if (!strategy || typeof strategy !== 'object') {
            errors.push('customer.strategy is required');
        }
        else {
            if (!isValidGoal(strategy['goal'])) {
                errors.push(`customer.strategy.goal must be one of: ${[...VALID_GOALS].join(', ')}`);
            }
            if (!isValidBudgetTier(strategy['budget'])) {
                errors.push(`customer.strategy.budget must be one of: ${[...VALID_BUDGET_TIERS].join(', ')}`);
            }
            if (!VALID_URGENCY.has(strategy['urgency'])) {
                errors.push(`customer.strategy.urgency must be one of: ${[...VALID_URGENCY].join(', ')}`);
            }
        }
    }
    return { valid: errors.length === 0, errors };
}
//# sourceMappingURL=onboarding-provision.types.js.map