/**
 * The function updates the status of each design task based on the project status.
 * If the project is on hold, the status of all design tasks should be set to "Pending".
 * If the project is in progress, the status of the design tasks with priority <= 2 should be set to "In progress",
 * and the rest should be set to "Pending".
 * If the project is completed, the status of all design tasks should be set to "Completed".
 *
 * @param designTasks A nested dictionary containing information about each design task.
 *                    The keys represent the task IDs, and the values are dictionaries with the following keys:
 *                    - "priority": The priority of the task (an integer between 1 and 5).
 *                    - "status": The status of the task (a string).
 * @param projectStatus The status of the project (either "On hold", "In progress", or "Completed").
 * @return The updated design tasks dictionary with the status of each task modified based on the project status.
 */
fun updateDesignStatus(designTasks: Map<Int, Map<String, Any>>, projectStatus: String): Map<Int, Map<String, Any>> {

    return designTasks.mapValues { (taskId, task) ->
        val priority = task["priority"] as Int
        val status = when (projectStatus) {
            "On hold" -> "Pending"
            "In progress" -> if (priority <= 2) "In progress" else "Pending"
            "Completed" -> "Completed"
            else -> throw IllegalArgumentException("Invalid project status")
        }
        mapOf("priority" to priority, "status" to status)
    }
}
/**
 * The function updates the status of each design task based on the project status.
 * If the project is on hold, the status of all design tasks should be set to "Pending".
 * If the project is in progress, the status of the design tasks with priority <= 2 should be set to "In progress",
 * and the rest should be set to "Pending".
 * If the project is completed, the status of all design tasks should be set to "Completed".
 *
 * @param designTasks A nested dictionary containing information about each design task.
 *                    The keys represent the task IDs, and the values are dictionaries with the following keys:
 *                    - "priority": The priority of the task (an integer between 1 and 5).
 *                    - "status": The status of the task (a string).
 * @param projectStatus The status of the project (either "On hold", "In progress", or "Completed").
 * @return The updated design tasks dictionary with the status of each task modified based on the project status.
 */
fun updateDesignStatus(designTasks: Map<Int, Map<String, Any>>, projectStatus: String): Map<Int, Map<String, Any>> {
/**
 * The function updates the status of each design task based on the project status.
 * If the project is on hold, the status of all design tasks should be set to "Pending".
 * If the project is in progress, the status of the design tasks with priority <= 2 should be set to "In progress",
 * and the rest should be set to "Pending".
 * If the project is completed, the status of all design tasks should be set to "Completed".
 *
 * @param designTasks A nested dictionary containing information about each design task.
 *                    The keys represent the task IDs, and the values are dictionaries with the following keys:
 *                    - "priority": The priority of the task (an integer between 1 and 5).
 *                    - "status": The status of the task (a string).
 * @param projectStatus The status of the project (either "On hold", "In progress", or "Completed").
 * @return The updated design tasks dictionary with the status of each task modified based on the project status.
 */
fun updateDesignStatus(designTasks: Map<Int, Map<String, Any>>, projectStatus: String): Map<Int, Map<String, Any>> {

    return designTasks.mapValues { (taskId, task) ->
        val priority = task["priority"] as Int
        val status = when (projectStatus) {
            "On hold" -> "Pending"
            "In progress" -> if (priority <= 2) "In progress" else "Pending"
            "Completed" -> "Completed"
            else -> throw IllegalArgumentException("Invalid project status")
        }
        mapOf("priority" to priority, "status" to status)
    }
}