import Command from '../command';
import { COMMAND_TYPE } from '../constants';

export default class ResetOriginalModelStyleCommand extends Command {
  constructor(service, uuid) {
    super(service);
    this.type = COMMAND_TYPE.RESET_ORIGINAL_MODEL_STYLE;
    this.name = '还原原始模型样式';
    this.object = service.getObjectByUuid(uuid);
    this.uuid = uuid;
    this.oldStyle = service.getOriginalModelStyleValue(uuid);
    this.resetStyle = service.ensureOriginalModelBaseline(uuid);
  }

  execute() {
    if (!this.object) return;
    this.service.applyOriginalModelStyle(this.uuid, this.resetStyle);
    this.service.syncOriginalModelStyleRecord(this.uuid);
  }

  undo() {
    if (!this.object) return;
    this.service.applyOriginalModelStyle(this.uuid, this.oldStyle);
    this.service.syncOriginalModelStyleRecord(this.uuid);
  }

  getChangedKeys() {
    return ['color', 'opacity', 'visible'];
  }
}
