# Copyright 2026 The RLinf Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# 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.

"""Wrappers for real-world environments."""

from typing import TYPE_CHECKING

from .apply import (
    apply_dual_franka_joint_wrappers,
    apply_single_arm_wrappers,
)
from .dual_euler_obs import DualQuat2EulerWrapper
from .dual_gello_joint_intervention import DualGelloJointIntervention
from .dual_relative_frame import DualRelativeFrame, DualRelativeTargetFrame
from .euler_obs import Quat2EulerWrapper
from .gello_intervention import GelloIntervention
from .gripper_close import GripperCloseEnv
from .keyboard_eval_control_wrapper import KeyboardEvalControlWrapper
from .keyboard_start_end_wrapper import KeyboardStartEndWrapper
from .leader_follower_keyboard_intervention import LeaderFollowerKeyboardIntervention
from .relative_frame import RelativeFrame
from .reward_done_wrapper import (
    KeyboardRewardDoneMultiStageWrapper,
    KeyboardRewardDoneWrapper,
)
from .spacemouse_intervention import SpacemouseIntervention

if TYPE_CHECKING:
    from .dexhand_intervention import DexHandIntervention

__all__ = [
    "DualGelloJointIntervention",
    "DualQuat2EulerWrapper",
    "DualRelativeFrame",
    "DualRelativeTargetFrame",
    "GelloIntervention",
    "GripperCloseEnv",
    "KeyboardRewardDoneMultiStageWrapper",
    "DexHandIntervention",
    "KeyboardRewardDoneWrapper",
    "KeyboardEvalControlWrapper",
    "KeyboardStartEndWrapper",
    "LeaderFollowerKeyboardIntervention",
    "Quat2EulerWrapper",
    "RelativeFrame",
    "SpacemouseIntervention",
    "apply_dual_franka_joint_wrappers",
    "apply_single_arm_wrappers",
]


def __getattr__(name: str):
    if name != "DexHandIntervention":
        raise AttributeError(f"module {__name__!r} has no attribute {name!r}")

    try:
        from .dexhand_intervention import DexHandIntervention
    except ModuleNotFoundError as exc:
        if exc.name and exc.name.split(".")[0] == "rlinf_dexhand":
            raise ModuleNotFoundError(
                "DexHandIntervention requires optional dependency "
                "'rlinf_dexhand'. Install it before enabling "
                "dexterous-hand teleoperation."
            ) from exc
        raise

    globals()[name] = DexHandIntervention
    return DexHandIntervention
