"""Polygon storage service for in-memory polygon points."""

from typing import Any


class PolygonStorage:
    """In-memory storage for polygon points per ORA file."""
    
    def __init__(self):
        self._storage: dict[str, dict[str, Any]] = {}
    
    def store(self, ora_path: str, points: list, color: str = '#FF0000', width: int = 2) -> None:
        """Store polygon data for an ORA file."""
        self._storage[ora_path] = {
            'points': points,
            'color': color,
            'width': width
        }
    
    def get(self, ora_path: str) -> dict[str, Any] | None:
        """Get polygon data for an ORA file."""
        return self._storage.get(ora_path)
    
    def clear(self, ora_path: str) -> bool:
        """Clear polygon data for an ORA file. Returns True if existed."""
        if ora_path in self._storage:
            del self._storage[ora_path]
            return True
        return False
    
    def has_polygon(self, ora_path: str) -> bool:
        """Check if polygon exists for an ORA file."""
        return ora_path in self._storage


polygon_storage = PolygonStorage()
