"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const XEUtils = require("xe-utils");
const log = require("./log.js");
class VXECommandsStore {
  constructor() {
    Object.defineProperty(this, "store", {
      enumerable: true,
      configurable: true,
      writable: true,
      value: {}
    });
  }
  mixin(options) {
    XEUtils.each(options, (item, key) => {
      this.add(key, item);
    });
    return this;
  }
  has(name) {
    return !!this.get(name);
  }
  get(name) {
    return this.store[name];
  }
  add(name, render) {
    const conf = this.store[name];
    if (XEUtils.isFunction(render)) {
      log.log.warn("vxe.error.delProp", ["commands -> callback", "commandMethod"]);
      render = {
        commandMethod: render
      };
    }
    const confKeys = XEUtils.keys(conf);
    XEUtils.each(render, (item, key) => {
      if (confKeys.includes(key)) {
        log.log.warn("vxe.error.coverProp", [name, key]);
      }
    });
    this.store[name] = conf ? XEUtils.merge(conf, render) : render;
    return this;
  }
  delete(name) {
    delete this.store[name];
  }
  forEach(callback) {
    XEUtils.objectEach(this.store, callback);
  }
}
const commands = new VXECommandsStore();
Object.assign(commands, { _name: "Commands" });
exports.commands = commands;
