"""
Absfuyu: Google form
--------------------
Google form - Form payload to DataFrame

Version: 6.7.0
Date updated: 27/03/2026 (dd/mm/yyyy)
"""

# Module level
# ---------------------------------------------------------------------------
__all__ = ["GoogleFormDF"]

# Library
# ---------------------------------------------------------------------------
from pathlib import Path
from typing import Any

import pandas as pd

from absfuyu.extra.gform.models import GoogleForm


# Class
class GoogleFormDF(GoogleForm):

    def build_payload_template_df(
        self,
        *,
        size: int = 0,
        fill: Any = pd.NA,
        save_path: Path | None = None,
    ) -> pd.DataFrame:
        payload = []
        for q in self.questions:
            for entry in q.entry_ids:
                payload.append((q.text, entry))

        columns = pd.MultiIndex.from_tuples(payload)
        df = pd.DataFrame([[fill] * len(columns)] * size, columns=columns)

        if save_path is not None:
            df.to_excel(save_path, index=False)

        return df
