from sqlalchemy import String, Integer, Boolean
from sqlalchemy.orm import Mapped, mapped_column
from sqlalchemy.dialects.postgresql import JSONB
from app.core.database import Base


class PlanLimits(Base):
    __tablename__ = "plan_limits"

    plan: Mapped[str] = mapped_column(String(50), primary_key=True)
    max_trees: Mapped[int | None] = mapped_column(Integer, nullable=True)
    max_sessions_per_month: Mapped[int | None] = mapped_column(Integer, nullable=True)
    max_users: Mapped[int | None] = mapped_column(Integer, nullable=True)
    custom_branding: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
    priority_support: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
    export_formats: Mapped[list] = mapped_column(JSONB, nullable=False, default=lambda: ["markdown", "text"])

    # AI Flow Builder limits
    max_ai_builds_per_month: Mapped[int | None] = mapped_column(Integer, nullable=True)
    max_ai_builds_per_24h: Mapped[int | None] = mapped_column(Integer, nullable=True)
