"""Parser for ``<FileProperties>`` elements in HOL DMSContent document objects."""
import xml.etree.ElementTree as ET


class DmsContentObjectFileProperties:
    """Represents the ``<FileProperties>`` element of a HOL document ``<Object>``.

    Available only for document objects when ``fileinfo=True`` is set in the query.
    """

    def __init__(self, node: ET.Element):
        self._node = node

    @property
    def count(self) -> int:
        """Number of physical files attached to this document."""
        return int(self._node.get("count", 0))

    @property
    def size(self) -> int:
        """Total file size in bytes across all attached files."""
        return int(self._node.get("size", 0))

    @property
    def extension(self) -> str:
        """File extension of the primary file (e.g. ``pdf``, ``docx``)."""
        return self._node.get("extension", "")

    @property
    def mimetype(self) -> str:
        """MIME type string of the primary file (e.g. ``application/pdf``)."""
        return self._node.get("mimetype", "")

    @property
    def mimetypegroup(self) -> str:
        """MIME type group string (e.g. ``DOCUMENT``, ``IMAGE``)."""
        return self._node.get("mimetypegroup", "")

    @property
    def iconid(self) -> int:
        """Numeric icon ID used for UI display of this file type."""
        return int(self._node.get("iconid", 1))

    @property
    def documentpagecount(self) -> int:
        """Number of pages in the primary document file."""
        return int(self._node.get("documentpagecount", 1))
