#pragma once

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

namespace UsdLayerManager {

/// Creates a new Xform group prim and reparents the given prims under it.
/// The group path must be pre-computed (collision-free) by the caller.
/// Undo reparents each child back to its original parent and removes the group.
class GroupPrimsCommand : public ICommand {
public:
    GroupPrimsCommand(pxr::UsdStageRefPtr              stage,
                      const std::vector<pxr::SdfPath>& srcPaths,
                      const pxr::SdfPath&              groupPath);

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

private:
    pxr::UsdStageRefPtr         m_stage;
    pxr::SdfPath                m_groupPath;
    std::vector<pxr::SdfPath>   m_srcPaths;     ///< original prim paths (before group)
    std::vector<std::string>    m_movedNames;   ///< actual names used inside group (set in Execute)
    std::string                 m_description;
};

} // namespace UsdLayerManager
