def format_event(event_spec: EventSpec) -> str:
    """Format an event.

    Args:
        event_spec: The event to format.

    Returns:
        The compiled event.
    """
    args = ",".join(
        [
            ":".join(
                (
                    name._js_expr,
                    (
                        wrap(
                            json.dumps(val._js_expr).strip('"').replace("`", "\\`"),
                            "`",
                        )
                        if val._var_is_string
                        else str(val)
                    ),
                )
            )
            for name, val in event_spec.args
        ]
    )
    event_args = [
        wrap(format_event_handler(event_spec.handler), '"'),
    ]
    event_args.append(wrap(args, "{"))

    if event_spec.client_handler_name:
        event_args.append(wrap(event_spec.client_handler_name, '"'))
    return f"Event({', '.join(event_args)})"
Format an event.

    Args:
        event_spec: The event to format.

    Returns:
        The compiled event.
    
reflex/utils/format.py