"""
Navigation and parallel processing tools
"""

from mcp.types import Tool


def get_navigation_tools():
    """Return tools for navigation and parallel processing."""
    return [
        Tool(
            name="auto_paginate",
            description="Automatically navigate through pagination",
            inputSchema={
                "type": "object",
                "properties": {
                    "url": {
                        "type": "string",
                        "description": "Starting URL with pagination"
                    },
                    "max_pages": {
                        "type": "number",
                        "description": "Maximum number of pages to process (default: 10)",
                        "default": 10
                    },
                    "wait_between": {
                        "type": "number",
                        "description": "Wait time between pages in seconds (default: 2)",
                        "default": 2
                    },
                    "next_selector": {
                        "type": "string",
                        "description": "CSS selector for 'next page' button (auto-detect if not provided)"
                    },
                    "extract_data": {
                        "type": "object",
                        "description": "Data extraction selectors for each page",
                        "default": {}
                    }
                },
                "required": ["url"]
            }
        ),

        Tool(
            name="parallel_fetch",
            description="🚀 Fetch multiple URLs in parallel using dedicated browser instances with human-like navigation",
            inputSchema={
                "type": "object",
                "properties": {
                    "urls": {
                        "type": "array",
                        "items": {"type": "string"},
                        "description": "List of URLs to fetch in parallel"
                    },
                    "max_workers": {
                        "type": "number",
                        "description": "Maximum number of parallel workers (default: 5)",
                        "default": 5
                    },
                    "timeout": {
                        "type": "number",
                        "description": "Timeout for each request in seconds (default: 10)",
                        "default": 10
                    },
                    "use_browser": {
                        "type": "boolean",
                        "description": "Use browser for all requests (default: auto-detect)",
                        "default": False
                    },
                    "extract_data": {
                        "type": "object",
                        "description": "Data extraction selectors to apply to each page",
                        "default": {}
                    }
                },
                "required": ["urls"]
            }
        ),

        Tool(
            name="infinite_scroll",
            description="Handle infinite scroll pages with automatic loading",
            inputSchema={
                "type": "object",
                "properties": {
                    "url": {
                        "type": "string",
                        "description": "URL with infinite scroll"
                    },
                    "trigger_selector": {
                        "type": "string",
                        "description": "CSS selector for load more trigger (e.g., '.load-more', button)",
                        "default": None
                    },
                    "scroll_pause_time": {
                        "type": "number",
                        "description": "Time to wait between scrolls in seconds (default: 2)",
                        "default": 2
                    },
                    "max_scrolls": {
                        "type": "number",
                        "description": "Maximum number of scroll iterations (default: 10)",
                        "default": 10
                    },
                    "extract_data": {
                        "type": "object",
                        "description": "Data extraction selectors",
                        "default": {}
                    },
                    "stop_condition": {
                        "type": "string",
                        "description": "CSS selector indicating end of content"
                    }
                },
                "required": ["url"]
            }
        )
    ]
