"""Confluence tool configuration."""

from __future__ import annotations

from typing import TYPE_CHECKING

from mindroom.tool_system.declarations import ConfigField, SetupType, ToolCategory, ToolStatus
from mindroom.tool_system.registration import register_tool_with_metadata

if TYPE_CHECKING:
    from agno.tools.confluence import ConfluenceTools


@register_tool_with_metadata(
    name="confluence",
    display_name="Confluence",
    description="Atlassian wiki platform for retrieving, creating, and updating pages",
    category=ToolCategory.DEVELOPMENT,
    status=ToolStatus.REQUIRES_CONFIG,
    setup_type=SetupType.API_KEY,
    icon="SiConfluence",
    icon_color="text-blue-600",
    config_fields=[
        # Authentication/Connection parameters
        ConfigField(
            name="url",
            label="Confluence URL",
            type="url",
            required=False,
            placeholder="https://your-confluence-instance.atlassian.net",
            description="Confluence instance URL",
        ),
        ConfigField(
            name="username",
            label="Username",
            type="text",
            required=False,
            placeholder="your-username",
            description="Confluence username",
        ),
        ConfigField(
            name="password",
            label="Password",
            type="password",
            required=False,
            placeholder="your-password",
            description="Confluence password",
        ),
        ConfigField(
            name="api_key",
            label="API Key",
            type="password",
            required=False,
            placeholder="your-api-key",
            description="Confluence API key, alternative to password",
        ),
        # Configuration options
        ConfigField(
            name="verify_ssl",
            label="Verify SSL",
            type="boolean",
            required=False,
            default=True,
            description="Whether to verify SSL certificates when connecting to Confluence",
        ),
    ],
    dependencies=["atlassian-python-api"],
    docs_url="https://docs.agno.com/tools/toolkits/others/confluence",
    function_names=(
        "create_page",
        "get_all_page_from_space",
        "get_all_space_detail",
        "get_page_content",
        "get_space_key",
        "update_page",
    ),
)
def confluence_tools() -> type[ConfluenceTools]:
    """Return Confluence tools for wiki management."""
    from agno.tools.confluence import ConfluenceTools

    return ConfluenceTools
