"""Repository protocol for Project operations."""

from __future__ import annotations

from collections.abc import Sequence
from typing import TYPE_CHECKING, Protocol

if TYPE_CHECKING:
    from uuid import UUID

    from noteflow.domain.entities.project import Project, ProjectSettings


class ProjectRepository(Protocol):
    """Repository protocol for Project operations."""

    async def get(self, project_id: UUID) -> Project | None:
        """Get project by ID.

        Args:
            project_id: Project UUID.

        Returns:
            Project if found, None otherwise.
        """
        ...

    async def get_by_slug(
        self,
        workspace_id: UUID,
        slug: str,
    ) -> Project | None:
        """Get project by workspace and slug.

        Args:
            workspace_id: Workspace UUID.
            slug: Project slug.

        Returns:
            Project if found, None otherwise.
        """
        ...

    async def get_default_for_workspace(
        self,
        workspace_id: UUID,
    ) -> Project | None:
        """Get the default project for a workspace.

        Args:
            workspace_id: Workspace UUID.

        Returns:
            Default project if exists, None otherwise.
        """
        ...

    async def create(
        self,
        project_id: UUID,
        workspace_id: UUID,
        name: str,
        slug: str | None = None,
        description: str | None = None,
        is_default: bool = False,
        settings: ProjectSettings | None = None,
    ) -> Project:
        """Create a new project.

        Args:
            project_id: UUID for the new project.
            workspace_id: Parent workspace UUID.
            name: Project name.
            slug: Optional URL slug.
            description: Optional description.
            is_default: Whether this is the workspace's default project.
            settings: Optional project settings.

        Returns:
            Created project.
        """
        ...

    async def update(self, project: Project) -> Project:
        """Update an existing project.

        Args:
            project: Project with updated fields.

        Returns:
            Updated project.

        Raises:
            ValueError: If project does not exist.
        """
        ...

    async def archive(self, project_id: UUID) -> Project | None:
        """Archive a project.

        Args:
            project_id: Project UUID.

        Returns:
            Archived project if found, None otherwise.

        Raises:
            CannotArchiveDefaultProjectError: If project is the default.
        """
        ...

    async def restore(self, project_id: UUID) -> Project | None:
        """Restore an archived project.

        Args:
            project_id: Project UUID.

        Returns:
            Restored project if found, None otherwise.
        """
        ...

    async def delete(self, project_id: UUID) -> bool:
        """Delete a project permanently.

        Args:
            project_id: Project UUID.

        Returns:
            True if deleted, False if not found.
        """
        ...

    async def list_for_workspace(
        self,
        workspace_id: UUID,
        include_archived: bool = False,
        limit: int = 50,
        offset: int = 0,
    ) -> Sequence[Project]:
        """List projects in a workspace.

        Args:
            workspace_id: Workspace UUID.
            include_archived: Whether to include archived projects.
            limit: Maximum projects to return.
            offset: Pagination offset.

        Returns:
            List of projects.
        """
        ...

    async def count_for_workspace(
        self,
        workspace_id: UUID,
        include_archived: bool = False,
    ) -> int:
        """Count projects in a workspace.

        Args:
            workspace_id: Workspace UUID.
            include_archived: Whether to include archived projects.

        Returns:
            Project count.
        """
        ...
