# autogenerated file, do not modify

from os import PathLike, curdir
from typing import Union

from flopy.mf6.data.mfdatautil import ArrayTemplateGenerator, ListTemplateGenerator
from flopy.mf6.mfpackage import MFChildPackages, MFPackage


class ModflowUtltas(MFPackage):
    """
    ModflowUtltas defines a TAS package.

    Parameters
    ----------
    parent_package
        Parent_package that this package is a part of. Package is automatically
        added to parent_package when it is initialized.
    loading_package : bool, default False
        Do not set this parameter. It is intended for debugging and internal
        processing purposes only.
    time_series_namerecord : (name, time_series_name)
        xxx
        * name : keyword
                xxx
        * time_series_name : [string]
                Name by which a package references a particular time-array series. The name
                must be unique among all time-array series used in a package.

    interpolation_methodrecord : (method, interpolation_method)
        xxx
        * method : keyword
                 xxx
        * interpolation_method : string
                Interpolation method, which is either STEPWISE or LINEAR.

    sfacrecord : (sfac, sfacval)
        xxx
        * sfac : keyword
                 xxx
        * sfacval : [double precision]
                Scale factor, which will multiply all array values in time series. SFAC is an
                optional attribute; if omitted, SFAC = 1.0.

    tas_array : [double precision]
        an array of numeric, floating-point values, or a constant value, readable by
        the u2drel array-reading utility.

    filename : str or PathLike, optional
        Name or path of file where this package is stored.
    pname : str, optional
        Package name.
    **kwargs
        Extra keywords for :class:`flopy.mf6.mfpackage.MFPackage`.

    """

    time_series_namerecord = ListTemplateGenerator(
        ("tas", "attributes", "time_series_namerecord")
    )
    interpolation_methodrecord = ListTemplateGenerator(
        ("tas", "attributes", "interpolation_methodrecord")
    )
    sfacrecord = ListTemplateGenerator(("tas", "attributes", "sfacrecord"))
    tas_array = ArrayTemplateGenerator(("tas", "time", "tas_array"))
    package_abbr = "utltas"
    _package_type = "tas"
    dfn_file_name = "utl-tas.dfn"
    dfn = [
        ["header", "multi-package"],
        [
            "block attributes",
            "name time_series_namerecord",
            "type record name time_series_name",
            "shape",
            "reader urword",
            "tagged false",
            "optional false",
        ],
        [
            "block attributes",
            "name name",
            "type keyword",
            "shape",
            "reader urword",
            "optional false",
            "in_record true",
        ],
        [
            "block attributes",
            "name time_series_name",
            "type string",
            "shape (any1d)",
            "tagged false",
            "reader urword",
            "optional false",
            "in_record true",
        ],
        [
            "block attributes",
            "name interpolation_methodrecord",
            "type record method interpolation_method",
            "shape",
            "reader urword",
            "tagged false",
            "optional true",
        ],
        [
            "block attributes",
            "name method",
            "type keyword",
            "shape",
            "reader urword",
            "optional false",
            "in_record true",
        ],
        [
            "block attributes",
            "name interpolation_method",
            "type string",
            "valid stepwise linear linearend",
            "shape",
            "tagged false",
            "reader urword",
            "optional false",
            "in_record true",
        ],
        [
            "block attributes",
            "name sfacrecord",
            "type record sfac sfacval",
            "shape",
            "reader urword",
            "tagged true",
            "optional true",
        ],
        [
            "block attributes",
            "name sfac",
            "type keyword",
            "shape",
            "reader urword",
            "optional false",
            "in_record true",
        ],
        [
            "block attributes",
            "name sfacval",
            "type double precision",
            "shape time_series_name",
            "tagged false",
            "reader urword",
            "optional false",
            "in_record true",
        ],
        [
            "block time",
            "name time_from_model_start",
            "type double precision",
            "block_variable true",
            "in_record true",
            "shape",
            "tagged false",
            "valid",
            "reader urword",
            "optional false",
        ],
        [
            "block time",
            "name tas_array",
            "type double precision",
            "tagged false",
            "just_data true",
            "shape (unknown)",
            "reader readarray",
            "optional false",
            "repeating true",
        ],
    ]

    def __init__(
        self,
        parent_package,
        loading_package=False,
        time_series_namerecord=None,
        interpolation_methodrecord=None,
        sfacrecord=None,
        tas_array=None,
        filename=None,
        pname=None,
        **kwargs,
    ):
        """Initialize ModflowUtltas."""
        super().__init__(
            parent=parent_package,
            package_type="tas",
            filename=filename,
            pname=pname,
            loading_package=loading_package,
            **kwargs,
        )

        self.time_series_namerecord = self.build_mfdata(
            "time_series_namerecord", time_series_namerecord
        )
        self.interpolation_methodrecord = self.build_mfdata(
            "interpolation_methodrecord", interpolation_methodrecord
        )
        self.sfacrecord = self.build_mfdata("sfacrecord", sfacrecord)
        self.tas_array = self.build_mfdata("tas_array", tas_array)

        self._init_complete = True


class UtltasPackages(MFChildPackages):
    """
    UtltasPackages is a container class for the ModflowUtltas class.
    """

    package_abbr = "utltaspackages"

    def initialize(
        self,
        time_series_namerecord=None,
        interpolation_methodrecord=None,
        sfacrecord=None,
        tas_array=None,
        filename=None,
        pname=None,
    ):
        """
        Initialize a new ModflowUtltas package, removing any sibling
        child packages attached to the same parent package.

        See :class:`ModflowUtltas` for parameter definitions.
        """
        new_package = ModflowUtltas(
            self._cpparent,
            time_series_namerecord=time_series_namerecord,
            interpolation_methodrecord=interpolation_methodrecord,
            sfacrecord=sfacrecord,
            tas_array=tas_array,
            filename=filename,
            pname=pname,
            child_builder_call=True,
        )
        self.init_package(new_package, filename)

    def append_package(
        self,
        time_series_namerecord=None,
        interpolation_methodrecord=None,
        sfacrecord=None,
        tas_array=None,
        filename=None,
        pname=None,
    ):
        """
        Add a new ModflowUtltas package to the container.

        See :class:`ModflowUtltas` for parameter definitions.
        """
        new_package = ModflowUtltas(
            self._cpparent,
            time_series_namerecord=time_series_namerecord,
            interpolation_methodrecord=interpolation_methodrecord,
            sfacrecord=sfacrecord,
            tas_array=tas_array,
            filename=filename,
            pname=pname,
            child_builder_call=True,
        )
        self._append_package(new_package, filename)
