export class CellRendererStatus {
  constructor() {
    this.DEFAULT_COLOR = 'transparent';
    this._eGui = undefined;
  }
  init(params) {
    this.renderStatus(params);
  }
  refresh(params) {
    this.renderStatus(params);
    return false;
  }
  destroy() {
    this._eGui = undefined;
  }
  getGui() {
    return this._eGui;
  }
  resolveColor(statusResolver, data) {
    let color;
    if (statusResolver instanceof Function) {
      color = statusResolver(data);
    }
    else {
      const statusKey = Object.keys(statusResolver)[0];
      const statusValues = statusResolver[statusKey];
      const value = data[statusKey];
      color = statusValues != undefined && value != undefined && statusValues[value];
    }
    return color || this.DEFAULT_COLOR;
  }
  renderStatus(params) {
    const { data, statusResolver } = params !== null && params !== void 0 ? params : {};
    if (statusResolver == undefined) {
      return;
    }
    const color = this.resolveColor(statusResolver, data);
    this._eGui = document.createElement('div');
    this._eGui.innerHTML = `
            <span class="ez-grid__cell-status" style="background-color: ${color || ""};"></span>
        `;
  }
}
