def METHOD_NAME(
    o: Any,
    *,
    sequences: TypeTuple[Iterable] = SEQUENCE_TYPES,
    maps: TypeTuple[Mapping] = MAPPING_TYPES,
    dates: DateTypeTuple = DATE_TYPES,
    value_delegate: TypeTuple[enum.Enum] = VALUE_DELEGATE_TYPES,
    has_time: DatetimeTypeTuple = HAS_TIME,
    _isinstance: Callable[[Any, IsInstanceArg], bool] = isinstance,
    _dict: Callable = dict,
    _str: Callable[[Any], str] = str,
    _list: Callable = list,
    textual: TypeTuple[Any] = TEXTUAL_TYPES,
) -> Any:
    if _isinstance(o, textual):
        return _str(o)
    elif _isinstance(o, maps):
        return _dict(o)
    elif _isinstance(o, dates):
        if not _isinstance(o, has_time):
            o = datetime.datetime(o.year, o.month, o.day, 0, 0, 0, 0)
        r = o.isoformat()
        if r.endswith("+00:00"):
            r = r[:-6] + "Z"
        return r
    elif isinstance(o, value_delegate):
        return o.value
    elif isinstance(o, sequences):
        return _list(o)
    else:
        to_json = getattr(o, "__json__", None)
        if to_json is not None:
            return to_json()
        raise TypeError(f"JSON cannot serialize {type(o).__name__!r}: {o!r}")