import { Decoration_Type, FontSizeData_fontType } from "./../../ricos-schema/legacy/wix/rich_content/v1/index.js";
import { EmptyDecoration } from "./empty-decoration.js";
class FontSizeDecoration {
  constructor(customStyle) {
    this.type = Decoration_Type.FONT_SIZE;
    this.customStyle = customStyle;
  }
  static of(decoration) {
    if (decoration.type !== Decoration_Type.FONT_SIZE) {
      throw new TypeError(`invalid decoration initializer ${decoration}`);
    }
    const value = decoration.fontSizeData?.value;
    const unit = decoration.fontSizeData?.unit?.toLocaleLowerCase();
    const customStyle = value ? {
      fontSize: `${value}${unit}`
    } : {};
    return new FontSizeDecoration(customStyle);
  }
  getDecoration() {
    return {
      type: this.type,
      fontSizeData: {
        value: parseInt(this.customStyle.fontSize),
        unit: FontSizeData_fontType.PX
      }
    };
  }
  static fromCustomStyle(customStyle) {
    return new FontSizeDecoration(customStyle);
  }
  fromCustomStyle(customStyle) {
    return FontSizeDecoration.fromCustomStyle(customStyle);
  }
  toCustomStyle() {
    return this.customStyle;
  }
  overrideWith(decoration) {
    if (!(decoration instanceof FontSizeDecoration || decoration instanceof EmptyDecoration)) {
      throw new TypeError(`invalid merge decoration ${decoration}`);
    }
    const customStyle = { ...this.customStyle, ...decoration.toCustomStyle() };
    return new FontSizeDecoration(customStyle);
  }
}
export {
  FontSizeDecoration
};
//# sourceMappingURL=font-size-decoration.js.map
