import type { SprintLifecycleAction, SprintStatus } from '@/features/projects/types/project.types';

/** Mirrors backend SprintLifecycleService::availableActions for client-side fallbacks. */
export function getDefaultSprintAvailableActions(status: SprintStatus): SprintLifecycleAction[] {
  const actions: SprintLifecycleAction[] = ['view'];

  if (status === 'draft' || status === 'planned' || status === 'active') {
    actions.push('edit', 'manage_backlog');
  }

  if (status !== 'archived') {
    actions.push('capacity');
  }

  if (status === 'draft' || status === 'planned' || status === 'cancelled') {
    actions.push('duplicate');
  }

  if (status === 'planned') {
    actions.push('start');
  }

  if (status === 'active') {
    actions.push('complete');
  }

  if (status === 'draft' || status === 'planned' || status === 'active') {
    actions.push('cancel');
  }

  if (status === 'completed' || status === 'cancelled') {
    actions.push('archive');
  }

  if (status === 'cancelled') {
    actions.push('restore');
  }

  if (status === 'draft') {
    actions.push('delete');
  }

  return actions;
}
