"""Tags plugin — CRUD, assign, bulk-assign, entity counts, cascade delete."""

from __future__ import annotations

from app.plugins.base import BasePlugin
from app.plugins.manifest import PluginManifest, PluginRouteDef, FrontendDetailTab


class TagsPlugin(BasePlugin):
    """Tags plugin for managing tags and tag assignments across entities."""

    manifest = PluginManifest(
        name="tags",
        version="1.0.0",
        display_name="Tags",
        description="Tag management with CRUD, assignment, bulk-assign, and entity counts.",
        dependencies=[],
        routes=[
            PluginRouteDef(
                path="/api/v1/tags",
                module="app.plugins.builtins.tags.routes",
                router_attr="router",
            ),
        ],
        events=[],
        migrations=["0001_initial.sql", "0002_add_deleted_at.sql"],
        permissions=[
            "tags:read",
            "tags:write",
            "tags:delete",
            "tags:admin",
        ],
        is_core=True,
        detail_tabs=[
            FrontendDetailTab(entity_type='contact', label_key='tabs.tags', label='Tags', component='@/components/contact/ContactTagsTab', icon='Tag', order=50, permission='tags:read'),
        ],
    )
