def _create_match_cond_var_or_component(
        cls,
        match_cond_var: Var,
        match_cases: list[list[Var]],
        default: Var | BaseComponent | None,
    ) -> Component | Var:
        """Create and return the match condition var or component.

        Args:
            match_cond_var: The match condition.
            match_cases: The list of match cases.
            default: The default case.

        Returns:
            The match component wrapped in a fragment or the match var.

        Raises:
            ValueError: If the return types are not vars when creating a match var for Var types.
        """
        if default is None and isinstance(match_cases[0][-1], BaseComponent):
            default = Fragment.create()

        if isinstance(match_cases[0][-1], BaseComponent):
            return Fragment.create(
                cls._create(
                    cond=match_cond_var,
                    match_cases=match_cases,
                    default=default,
                    children=[case[-1] for case in match_cases] + [default],  # pyright: ignore [reportArgumentType]
                )
            )

        # Validate the match cases (as well as the default case) to have Var return types.
        if any(
            case for case in match_cases if not isinstance(case[-1], Var)
        ) or not isinstance(default, Var):
            msg = "Return types of match cases should be Vars."
            raise ValueError(msg)

        return Var(
            _js_expr=format.format_match(
                cond=str(match_cond_var),
                match_cases=match_cases,
                default=default,
            ),
            _var_type=default._var_type,
            _var_data=VarData.merge(
                match_cond_var._get_all_var_data(),
                *[el._get_all_var_data() for case in match_cases for el in case],
                default._get_all_var_data(),
            ),
        )
Create and return the match condition var or component.

        Args:
            match_cond_var: The match condition.
            match_cases: The list of match cases.
            default: The default case.

        Returns:
            The match component wrapped in a fragment or the match var.

        Raises:
            ValueError: If the return types are not vars when creating a match var for Var types.
        
reflex/components/core/match.py