import figures from 'figures';
import { homedir } from 'os';
import * as React from 'react';
import { Box, Text } from '../../ink.js';
import type { Step } from '../../projectOnboardingState.js';
import { formatCreditAmount, getCachedReferrerReward } from '../../services/api/referral.js';
import type { LogOption } from '../../types/logs.js';
import { getCwd } from '../../utils/cwd.js';
import { formatRelativeTimeAgo } from '../../utils/format.js';
import type { FeedConfig, FeedLine } from './Feed.js';
export function createRecentActivityFeed(activities: LogOption[]): FeedConfig {
  const lines: FeedLine[] = activities.map(log => {
    const time = formatRelativeTimeAgo(log.modified);
    const description = log.summary && log.summary !== 'No prompt' ? log.summary : log.firstPrompt;
    return {
      text: description || '',
      timestamp: time
    };
  });
  return {
    title: 'Recent activity',
    lines,
    footer: lines.length > 0 ? '/resume for more' : undefined,
    emptyMessage: 'No recent activity'
  };
}
export function createWhatsNewFeed(releaseNotes: string[]): FeedConfig {
  const lines: FeedLine[] = releaseNotes.map(note => {
    if ("external" === 'ant') {
      const match = note.match(/^(\d+\s+\w+\s+ago)\s+(.+)$/);
      if (match) {
        return {
          timestamp: match[1],
          text: match[2] || ''
        };
      }
    }
    return {
      text: note
    };
  });
  const emptyMessage = "external" === 'ant' ? 'Unable to fetch latest claude-cli-internal commits' : 'Check the Claude Code changelog for updates';
  return {
    title: "external" === 'ant' ? "What's new [ANT-ONLY: Latest CC commits]" : "What's new",
    lines,
    footer: lines.length > 0 ? '/release-notes for more' : undefined,
    emptyMessage
  };
}
export function createProjectOnboardingFeed(steps: Step[]): FeedConfig {
  const enabledSteps = steps.filter(({
    isEnabled
  }) => isEnabled).sort((a, b) => Number(a.isComplete) - Number(b.isComplete));
  const lines: FeedLine[] = enabledSteps.map(({
    text,
    isComplete
  }) => {
    const checkmark = isComplete ? `${figures.tick} ` : '';
    return {
      text: `${checkmark}${text}`
    };
  });
  const warningText = getCwd() === homedir() ? 'Note: You have launched claude in your home directory. For the best experience, launch it in a project directory instead.' : undefined;
  if (warningText) {
    lines.push({
      text: warningText
    });
  }
  return {
    title: 'Tips for getting started',
    lines
  };
}
export function createGuestPassesFeed(): FeedConfig {
  const reward = getCachedReferrerReward();
  const subtitle = reward ? `Share Claude Code and earn ${formatCreditAmount(reward)} of extra usage` : 'Share Claude Code with friends';
  return {
    title: '3 guest passes',
    lines: [],
    customContent: {
      content: <>
          <Box marginY={1}>
            <Text color="claude">[✻] [✻] [✻]</Text>
          </Box>
          <Text dimColor>{subtitle}</Text>
        </>,
      width: 48
    },
    footer: '/passes'
  };
}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJmaWd1cmVzIiwiaG9tZWRpciIsIlJlYWN0IiwiQm94IiwiVGV4dCIsIlN0ZXAiLCJmb3JtYXRDcmVkaXRBbW91bnQiLCJnZXRDYWNoZWRSZWZlcnJlclJld2FyZCIsIkxvZ09wdGlvbiIsImdldEN3ZCIsImZvcm1hdFJlbGF0aXZlVGltZUFnbyIsIkZlZWRDb25maWciLCJGZWVkTGluZSIsImNyZWF0ZVJlY2VudEFjdGl2aXR5RmVlZCIsImFjdGl2aXRpZXMiLCJsaW5lcyIsIm1hcCIsImxvZyIsInRpbWUiLCJtb2RpZmllZCIsImRlc2NyaXB0aW9uIiwic3VtbWFyeSIsImZpcnN0UHJvbXB0IiwidGV4dCIsInRpbWVzdGFtcCIsInRpdGxlIiwiZm9vdGVyIiwibGVuZ3RoIiwidW5kZWZpbmVkIiwiZW1wdHlNZXNzYWdlIiwiY3JlYXRlV2hhdHNOZXdGZWVkIiwicmVsZWFzZU5vdGVzIiwibm90ZSIsIm1hdGNoIiwiY3JlYXRlUHJvamVjdE9uYm9hcmRpbmdGZWVkIiwic3RlcHMiLCJlbmFibGVkU3RlcHMiLCJmaWx0ZXIiLCJpc0VuYWJsZWQiLCJzb3J0IiwiYSIsImIiLCJOdW1iZXIiLCJpc0NvbXBsZXRlIiwiY2hlY2ttYXJrIiwidGljayIsIndhcm5pbmdUZXh0IiwicHVzaCIsImNyZWF0ZUd1ZXN0UGFzc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