// SPEC-597-EXEMPT: canonical mapping (npm-package↔framework, keyword catalogue)
// — must enumerate framework names by design; no detection logic to migrate.
// engine/execution-plan/mobile-distribution.ts — SPEC-013
// Distribution phase orchestrator for iOS/Android/Flutter/ReactNative/Expo release specs.
// SRP: detects platform + delegates step generation to platform-specific modules.
// OCP: new platforms add a new file in mobile-dist/ — no changes to this file.
import { generateNativeDistributionPhase } from './mobile-dist/native-steps.js';
import { generateFlutterDistributionPhase } from './mobile-dist/flutter-steps.js';
import { generateExpoDistributionPhase } from './mobile-dist/expo-steps.js';
import { generateReactNativeDistributionPhase } from './mobile-dist/rn-steps.js';
// --- Platform detection ---
/**
 * Detects if a spec targets a cross-platform mobile framework (Flutter, Expo, React Native).
 * Detection is based on spec tags and title keywords.
 */
export function detectCrossPlatformKind(spec) {
    const lower = `${spec.title} ${spec.tags.join(' ')}`.toLowerCase();
    if (lower.includes('flutter')) {
        return 'flutter';
    }
    if (lower.includes('expo')) {
        return 'expo';
    }
    if (lower.includes('react-native') || lower.includes('reactnative') || lower.includes(' rn ')) {
        return 'react-native';
    }
    return null;
}
/**
 * Returns true if this spec should receive a mobile Distribution phase.
 * Covers: ios, android, flutter, expo, react-native.
 */
export function isMobileDistributionSpec(spec) {
    if (spec.target === 'ios' || spec.target === 'android') {
        return true;
    }
    return detectCrossPlatformKind(spec) !== null;
}
// --- Phase dispatcher ---
/**
 * Generates a "Distribution & Store Submission" phase for mobile release specs.
 * Delegates to the appropriate platform-specific generator.
 */
export function generateMobileDistributionPhase(spec, startOrder) {
    const crossPlatform = detectCrossPlatformKind(spec);
    if (crossPlatform === 'flutter') {
        return generateFlutterDistributionPhase(startOrder);
    }
    if (crossPlatform === 'expo') {
        return generateExpoDistributionPhase(startOrder);
    }
    if (crossPlatform === 'react-native') {
        return generateReactNativeDistributionPhase(startOrder);
    }
    // Native iOS or Android
    return generateNativeDistributionPhase(spec, startOrder);
}
//# sourceMappingURL=mobile-distribution.js.map