#pragma once

#include "../CommandHistory.h"
#include <pxr/usd/usd/stage.h>
#include <pxr/usd/sdf/path.h>
#include <string>

namespace UsdLayerManager {

/// Reparents a USD prim under a new parent via UsdNamespaceEditor.
/// Supports undo by reparenting back to the original parent with the original name.
/// Pass SdfPath("/") as dstParentPath to reparent to the stage root.
class ReparentPrimCommand : public ICommand {
public:
    ReparentPrimCommand(pxr::UsdStageRefPtr stage,
                        const pxr::SdfPath& srcPath,
                        const pxr::SdfPath& dstParentPath,
                        const std::string&  finalName);

    void Execute() override;
    void Undo()    override;
    std::string GetDescription() const override { return m_description; }

private:
    pxr::UsdStageRefPtr m_stage;
    pxr::SdfPath        m_srcPath;           ///< original path before reparent
    pxr::SdfPath        m_origParentPath;    ///< parent path before reparent
    std::string         m_origName;          ///< prim name before reparent
    pxr::SdfPath        m_dstParentPath;     ///< target parent path
    std::string         m_finalName;         ///< name inside new parent (collision-free)
    pxr::SdfPath        m_actualNewPath;     ///< full path after Execute (set in Execute)
    std::string         m_description;
};

} // namespace UsdLayerManager
