// tools/generate-docs/mobile-installation-guide.ts — SPEC-013 criterion 15
// Generates a mobile installation guide section when the project has iOS/Android specs.
// SRP: builds the guide content string; detection lives in generate-docs.ts.
// OCP: extend with new platform sections by adding helpers below — no changes to caller.
// --- iOS section ---
function buildTestFlightSection() {
    return [
        '### iOS — TestFlight Beta Distribution',
        '',
        '#### Prerequisites',
        '- Active Apple Developer Program membership ($99/year)',
        '- App ID registered in App Store Connect',
        '- Distribution certificate and provisioning profile configured in Xcode',
        '',
        '#### Step 1: Archive the app',
        '```bash',
        '# Via Fastlane (recommended)',
        'fastlane gym --scheme MyApp --export_method app-store',
        '',
        '# Via Xcode CLI',
        'xcodebuild -project MyApp.xcodeproj -scheme MyApp \\',
        '  -archivePath build/MyApp.xcarchive archive',
        'xcodebuild -exportArchive -archivePath build/MyApp.xcarchive \\',
        '  -exportOptionsPlist ExportOptions.plist \\',
        '  -exportPath build/ipa',
        '```',
        '',
        '#### Step 2: Upload to TestFlight',
        '```bash',
        'fastlane pilot upload --ipa build/ipa/MyApp.ipa',
        '# Or via xcrun altool',
        'xcrun altool --upload-app --type ios --file build/ipa/MyApp.ipa \\',
        '  --apiKey <API_KEY> --apiIssuer <ISSUER_ID>',
        '```',
        '- App Store Connect → TestFlight → Invite internal testers (instant access)',
        '- External beta: requires Apple beta review (1–3 business days)',
        '',
        '#### App Store Submission Checklist',
        '- [ ] App icon 1024×1024 (no alpha channel)',
        '- [ ] Screenshots for all required device sizes',
        '- [ ] App Privacy details filled in App Store Connect',
        '- [ ] `PrivacyInfo.xcprivacy` present if using required-reason APIs',
        '- [ ] Export Compliance answered (encryption usage)',
        '- [ ] Age rating and content descriptions set',
        '- [ ] Phased Release enabled: Pricing & Availability → Phased Release',
        '',
        '> **Verification:** Build appears in TestFlight internal group.',
        '> App Store Connect shows "Waiting for Review" after submission.',
    ].join('\n');
}
// --- Android section ---
function buildPlayStoreSection() {
    return [
        '### Android — APK Sideloading & Play Store Submission',
        '',
        '#### APK Sideloading (direct install)',
        '```bash',
        '# Build a debug APK for direct distribution',
        './gradlew assembleDebug',
        '# Output: app/build/outputs/apk/debug/app-debug.apk',
        '',
        '# Install on connected device',
        'adb install app/build/outputs/apk/debug/app-debug.apk',
        '',
        '# Share APK for sideloading',
        '# Recipient must enable: Settings → Security → Unknown Sources (or Install unknown apps)',
        '```',
        '',
        '#### Google Play Store Submission Checklist',
        '- [ ] Signed AAB (Android App Bundle) built with release keystore',
        '',
        '```bash',
        '# Build signed AAB',
        './gradlew bundleRelease',
        '# Output: app/build/outputs/bundle/release/app-release.aab',
        '',
        '# Sign with keystore',
        'jarsigner -verbose -sigalg SHA256withRSA -digestalg SHA-256 \\',
        '  -keystore my-release-key.jks app-release.aab alias_name',
        '',
        '# Or via Fastlane supply',
        'fastlane supply --aab app/build/outputs/bundle/release/app-release.aab \\',
        '  --track internal',
        '```',
        '',
        '- [ ] Play Console → App content → Privacy policy URL set',
        '- [ ] Content rating questionnaire completed',
        '- [ ] Target API level meets Play Store requirements (API 34+)',
        '- [ ] 64-bit compliance verified: no 32-bit-only native libs',
        '- [ ] Store listing: screenshots for phone + 7-inch + 10-inch tablets',
        '- [ ] App Access instructions if login required for review',
        '',
        '> **Verification:** AAB uploaded to Internal Testing track.',
        '> Play Console shows "Published" in Internal Testing. Test via Play Store app.',
    ].join('\n');
}
// --- Phased rollout ---
function buildPhasedRolloutSection() {
    return [
        '### Phased Rollout Strategy',
        '',
        '| Day | iOS (Phased Release) | Android (Play Console %) |',
        '|-----|---------------------|--------------------------|',
        '| 1   | 1% of users         | 1%                       |',
        '| 2   | 2%                  | 5%                       |',
        '| 3   | 5%                  | 10%                      |',
        '| 4   | 10%                 | 20%                      |',
        '| 5   | 20%                 | 50%                      |',
        '| 6   | 50%                 | 100%                     |',
        '| 7   | 100%                | (monitor)                |',
        '',
        '**Halt criteria:** Crash-free rate drops below 99.5% OR P1 issues exceed 0.1%.',
        '- iOS: halt phased release in App Store Connect',
        '- Android: halt rollout in Play Console; hotfix via expedited review',
    ].join('\n');
}
// --- Main export ---
/**
 * Builds a mobile installation guide as a markdown string.
 * Covers iOS (TestFlight + App Store checklist) and Android (APK + Play Store checklist).
 * Called by handleGenerateDocs when specs include iOS/Android targets.
 */
export function generateMobileInstallationGuide(_knowledge, specs, _language) {
    const hasIOS = specs.some((s) => s.target === 'ios');
    const hasAndroid = specs.some((s) => s.target === 'android');
    const sections = [];
    if (hasIOS) {
        sections.push(buildTestFlightSection());
    }
    if (hasAndroid) {
        sections.push(buildPlayStoreSection());
    }
    sections.push(buildPhasedRolloutSection());
    return sections.join('\n\n---\n\n');
}
//# sourceMappingURL=mobile-installation-guide.js.map