"""
Base packaging variant infrastructure.

Provides the abstract base class for packaging variants and
core packaging functionality that extends the existing variant system.
"""

from abc import abstractmethod
from pathlib import Path
from typing import Dict, List, Any

from ..explode_variants.base_variant import BaseVariant
from .metadata import PackageMetadata, AssetMetadata


class PackageFormat:
    """Package format constants."""
    MDZ = "mdz"
    MDT = "mdt"


class PackagingVariant(BaseVariant):
    """
    Abstract base class for packaging variants.

    Extends BaseVariant to support packaging-specific operations
    like asset embedding, path rewriting, and metadata management.
    """

    @abstractmethod
    def create_package(self, source_path: Path, options: Dict[str, Any]) -> Dict[str, Any]:
        """Create a package from source content."""
        pass

    @abstractmethod
    def extract_package(self, package_path: Path, options: Dict[str, Any]) -> Dict[str, Any]:
        """Extract a package to destination."""
        pass

    @abstractmethod
    def get_package_metadata(self, package_path: Path) -> PackageMetadata:
        """Get metadata from a package."""
        pass

    @abstractmethod
    def embed_assets(self, assets: List[Path], package_path: Path) -> List[AssetMetadata]:
        """Embed assets into the package."""
        pass

    @abstractmethod
    def rewrite_asset_paths(self, content: str, asset_map: Dict[str, str]) -> str:
        """Rewrite asset paths in content."""
        pass