export function resolveProductSwitchTarget(
  pathname: string,
  newProductId: string,
): string | null {
  const match = pathname.match(/^\/products\/([^/]+)(\/.*)?$/)
  if (!match) return null

  const rest = match[2] ?? ''

  if (!rest || rest === '/') return `/products/${newProductId}`
  if (rest.startsWith('/sprint')) return `/products/${newProductId}/sprint`
  if (rest.startsWith('/solo')) return `/products/${newProductId}/solo`
  return `/products/${newProductId}`
}
