var __rest = (this && this.__rest) || function (s, e) {
  var t = {};
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
    t[p] = s[p];
  if (s != null && typeof Object.getOwnPropertySymbols === "function")
    for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
      if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
        t[p[i]] = s[p[i]];
    }
  return t;
};
import { parseToPixelString } from '../../../../../utils/pixel';
import { AnnotationAction } from '../../../dto/actions/annotation-action.abstract';
import { RTETableAnnotation } from '../annotations/table-annotation';
export const UPDATE_TABLE_PROPERTIES = 'UPDATE_TABLE_PROPERTIES';
/**
 * Action to update table properties
 */
export class UpdateTablePropertiesAction extends AnnotationAction {
  constructor(tableProperties) {
    super();
    this.isFlushable = true;
    const { textAlign, width, borderWidth, borderColor, borderStyle, height } = tableProperties, restStyles = __rest(tableProperties, ["textAlign", "width", "borderWidth", "borderColor", "borderStyle", "height"]);
    this.tableProperties = Object.assign(Object.assign({}, restStyles), { alignment: textAlign, border: {
        style: borderStyle,
        color: borderColor,
        width: borderWidth ? parseToPixelString(borderWidth) : '',
      }, width: width ? parseToPixelString(width) : '', height: height ? parseToPixelString(height) : '' });
  }
  /**
   * Generate annotation from action data
   *
   * @returns {RTETableAnnotation} The generated annotation
   */
  toAnnotation() {
    return new RTETableAnnotation(this.tableProperties);
  }
}
