# Path: google/cloud/firestore_v1/_helpers.py
# def decode_value(
#     value, client
# ) -> Union[None, bool, int, float, list, datetime.datetime, str, bytes, dict, GeoPoint]:
#     """Converts a Firestore protobuf ``Value`` to a native Python value.
# 
#     Args:
#         value (google.cloud.firestore_v1.types.Value): A
#             Firestore protobuf to be decoded / parsed / converted.
#         client (:class:`~google.cloud.firestore_v1.client.Client`):
#             A client that has a document factory.
# 
#     Returns:
#         Union[NoneType, bool, int, float, datetime.datetime, \
#             str, bytes, dict, ~google.cloud.Firestore.GeoPoint]: A native
#         Python value converted from the ``value``.
# 
#     Raises:
#         NotImplementedError: If the ``value_type`` is ``reference_value``.
#         ValueError: If the ``value_type`` is unknown.
#     """
#     value_pb = getattr(value, "_pb", value)
#     value_type = value_pb.WhichOneof("value_type")
# 
#     if value_type == "null_value":
#         return None
#     elif value_type == "boolean_value":
#         return value_pb.boolean_value
#     elif value_type == "integer_value":
#         return value_pb.integer_value
#     elif value_type == "double_value":
#         return value_pb.double_value
#     elif value_type == "timestamp_value":
#         return DatetimeWithNanoseconds.from_timestamp_pb(value_pb.timestamp_value)
#     elif value_type == "string_value":
#         return value_pb.string_value
#     elif value_type == "bytes_value":
#         return value_pb.bytes_value
#     elif value_type == "reference_value":
#         return reference_value_to_document(value_pb.reference_value, client)
#     elif value_type == "geo_point_value":
#         return GeoPoint(
#             value_pb.geo_point_value.latitude, value_pb.geo_point_value.longitude
#         )
#     elif value_type == "array_value":
#         return [
#             decode_value(element, client) for element in value_pb.array_value.values
#         ]
#     elif value_type == "map_value":
#         return decode_dict(value_pb.map_value.fields, client)
#     else:
#         raise ValueError("Unknown ``value_type``", value_type)


from enum import Enum
from google.cloud.firestore_v1._helpers import decode_value
from typing import Any
import math
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.



class TypeOrder(Enum):
    # NOTE: This order is defined by the backend and cannot be changed.
    NULL = 0
    BOOLEAN = 1
    NUMBER = 2
    TIMESTAMP = 3
    STRING = 4
    BLOB = 5
    REF = 6
    GEO_POINT = 7
    ARRAY = 8
    OBJECT = 9

    @staticmethod
    def from_value(value) -> Any:
        v = value._pb.WhichOneof("value_type")

        lut = {
            "null_value": TypeOrder.NULL,
            "boolean_value": TypeOrder.BOOLEAN,
            "integer_value": TypeOrder.NUMBER,

# Path: google/cloud/firestore_v1/_helpers.py
# def decode_value(
#     value, client
# ) -> Union[None, bool, int, float, list, datetime.datetime, str, bytes, dict, GeoPoint]:
#     """Converts a Firestore protobuf ``Value`` to a native Python value.
# 
#     Args:
#         value (google.cloud.firestore_v1.types.Value): A
#             Firestore protobuf to be decoded / parsed / converted.
#         client (:class:`~google.cloud.firestore_v1.client.Client`):
#             A client that has a document factory.
# 
#     Returns:
#         Union[NoneType, bool, int, float, datetime.datetime, \
#             str, bytes, dict, ~google.cloud.Firestore.GeoPoint]: A native
#         Python value converted from the ``value``.
# 
#     Raises:
#         NotImplementedError: If the ``value_type`` is ``reference_value``.
#         ValueError: If the ``value_type`` is unknown.
#     """
#     value_pb = getattr(value, "_pb", value)
#     value_type = value_pb.WhichOneof("value_type")
# 
#     if value_type == "null_value":
#         return None
#     elif value_type == "boolean_value":
#         return value_pb.boolean_value
#     elif value_type == "integer_value":
#         return value_pb.integer_value
#     elif value_type == "double_value":
#         return value_pb.double_value
#     elif value_type == "timestamp_value":
#         return DatetimeWithNanoseconds.from_timestamp_pb(value_pb.timestamp_value)
#     elif value_type == "string_value":
#         return value_pb.string_value
#     elif value_type == "bytes_value":
#         return value_pb.bytes_value
#     elif value_type == "reference_value":
#         return reference_value_to_document(value_pb.reference_value, client)
#     elif value_type == "geo_point_value":
#         return GeoPoint(
#             value_pb.geo_point_value.latitude, value_pb.geo_point_value.longitude
#         )
#     elif value_type == "array_value":
#         return [
#             decode_value(element, client) for element in value_pb.array_value.values
#         ]
#     elif value_type == "map_value":
#         return decode_dict(value_pb.map_value.fields, client)
#     else:
#         raise ValueError("Unknown ``value_type``", value_type)


# Path: google/cloud/firestore_v1/order.py
from enum import Enum
from google.cloud.firestore_v1._helpers import decode_value
from typing import Any
import math

#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.



class TypeOrder(Enum):
    # NOTE: This order is defined by the backend and cannot be changed.
    NULL = 0
    BOOLEAN = 1
    NUMBER = 2
    TIMESTAMP = 3
    STRING = 4
    BLOB = 5
    REF = 6
    GEO_POINT = 7
    ARRAY = 8
    OBJECT = 9

    @staticmethod
    def from_value(value) -> Any:
        v = value._pb.WhichOneof("value_type")

        lut = {
            "null_value": TypeOrder.NULL,
            "boolean_value": TypeOrder.BOOLEAN,
            "integer_value": TypeOrder.NUMBER,

            "double_value": TypeOrder.NUMBER,