/**
 * Shared routing helpers for tree/session navigation.
 * Centralizes the logic for determining the correct navigation path
 * based on tree type (troubleshooting vs procedural vs maintenance).
 */

/**
 * Get the default navigation path for starting a flow from the library.
 */
export function getTreeNavigatePath(
  treeId: string,
  treeType?: string
): string {
  if (treeType === 'procedural') {
    return `/flows/${treeId}/navigate`
  }
  if (treeType === 'maintenance') {
    return `/flows/${treeId}/maintenance`
  }
  return `/trees/${treeId}/navigate`
}

/**
 * Get the navigation path for resuming an existing session.
 * Maintenance and procedural sessions both resume in procedural navigation.
 */
export function getSessionResumePath(
  treeId: string,
  treeType?: string
): string {
  if (treeType === 'procedural' || treeType === 'maintenance') {
    return `/flows/${treeId}/navigate`
  }
  return `/trees/${treeId}/navigate`
}

/**
 * Get the editor path for a tree.
 */
export function getTreeEditorPath(
  treeId: string,
  treeType?: string
): string {
  if (treeType === 'procedural' || treeType === 'maintenance') {
    return `/flows/${treeId}/edit`
  }
  return `/trees/${treeId}/edit`
}
