#pragma once

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

namespace UsdLayerManager {

/// Saves the prim spec via SdfCopySpec into an anonymous in-memory layer
/// before deletion; restores it on Undo.
class DeletePrimCommand : public ICommand {
public:
    /// Captures the current spec of @p primPath from the root layer into an
    /// anonymous layer.  Must be constructed BEFORE the prim is removed.
    DeletePrimCommand(pxr::UsdStageRefPtr stage, const pxr::SdfPath& primPath);

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

private:
    pxr::UsdStageRefPtr  m_stage;
    pxr::SdfPath         m_primPath;
    pxr::SdfLayerRefPtr  m_savedLayer;   ///< anonymous layer holding the spec snapshot
    std::string          m_description;
    bool                 m_specWasSaved = false;
};

} // namespace UsdLayerManager
