import { Command } from './command';
export class DeleteCmd extends Command {
    execute(options) {
        const { path } = options;
        let undoPath = path;
        let undoValue = this.store.get(path);
        if (path.length > 0) {
            const parentPath = path.slice(0, -1);
            const parent = this.store.get(parentPath);
            if (Array.isArray(parent)) {
                undoPath = parentPath;
                undoValue = parent;
            }
        }
        this.store.delete(path);
        return () => {
            this.store.set(undoPath, undoValue);
        };
    }
}
