"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const util = require("../../../../../zrender@5.4.4/node_modules/zrender/lib/core/util.js");
var deprecatedLogs = {};
function isEC4CompatibleStyle(style, elType, hasOwnTextContentOption, hasOwnTextConfig) {
  return style && (style.legacy || style.legacy !== false && !hasOwnTextContentOption && !hasOwnTextConfig && elType !== "tspan" && (elType === "text" || util.hasOwn(style, "text")));
}
function convertFromEC4CompatibleStyle(hostStyle, elType, isNormal) {
  var srcStyle = hostStyle;
  var textConfig;
  var textContent;
  var textContentStyle;
  if (elType === "text") {
    textContentStyle = srcStyle;
  } else {
    textContentStyle = {};
    util.hasOwn(srcStyle, "text") && (textContentStyle.text = srcStyle.text);
    util.hasOwn(srcStyle, "rich") && (textContentStyle.rich = srcStyle.rich);
    util.hasOwn(srcStyle, "textFill") && (textContentStyle.fill = srcStyle.textFill);
    util.hasOwn(srcStyle, "textStroke") && (textContentStyle.stroke = srcStyle.textStroke);
    util.hasOwn(srcStyle, "fontFamily") && (textContentStyle.fontFamily = srcStyle.fontFamily);
    util.hasOwn(srcStyle, "fontSize") && (textContentStyle.fontSize = srcStyle.fontSize);
    util.hasOwn(srcStyle, "fontStyle") && (textContentStyle.fontStyle = srcStyle.fontStyle);
    util.hasOwn(srcStyle, "fontWeight") && (textContentStyle.fontWeight = srcStyle.fontWeight);
    textContent = {
      type: "text",
      style: textContentStyle,
      // ec4 does not support rectText trigger.
      // And when text position is different in normal and emphasis
      // => hover text trigger emphasis;
      // => text position changed, leave mouse pointer immediately;
      // That might cause incorrect state.
      silent: true
    };
    textConfig = {};
    var hasOwnPos = util.hasOwn(srcStyle, "textPosition");
    if (isNormal) {
      textConfig.position = hasOwnPos ? srcStyle.textPosition : "inside";
    } else {
      hasOwnPos && (textConfig.position = srcStyle.textPosition);
    }
    util.hasOwn(srcStyle, "textPosition") && (textConfig.position = srcStyle.textPosition);
    util.hasOwn(srcStyle, "textOffset") && (textConfig.offset = srcStyle.textOffset);
    util.hasOwn(srcStyle, "textRotation") && (textConfig.rotation = srcStyle.textRotation);
    util.hasOwn(srcStyle, "textDistance") && (textConfig.distance = srcStyle.textDistance);
  }
  convertEC4CompatibleRichItem(textContentStyle, hostStyle);
  util.each(textContentStyle.rich, function(richItem) {
    convertEC4CompatibleRichItem(richItem, richItem);
  });
  return {
    textConfig,
    textContent
  };
}
function convertEC4CompatibleRichItem(out, richItem) {
  if (!richItem) {
    return;
  }
  richItem.font = richItem.textFont || richItem.font;
  util.hasOwn(richItem, "textStrokeWidth") && (out.lineWidth = richItem.textStrokeWidth);
  util.hasOwn(richItem, "textAlign") && (out.align = richItem.textAlign);
  util.hasOwn(richItem, "textVerticalAlign") && (out.verticalAlign = richItem.textVerticalAlign);
  util.hasOwn(richItem, "textLineHeight") && (out.lineHeight = richItem.textLineHeight);
  util.hasOwn(richItem, "textWidth") && (out.width = richItem.textWidth);
  util.hasOwn(richItem, "textHeight") && (out.height = richItem.textHeight);
  util.hasOwn(richItem, "textBackgroundColor") && (out.backgroundColor = richItem.textBackgroundColor);
  util.hasOwn(richItem, "textPadding") && (out.padding = richItem.textPadding);
  util.hasOwn(richItem, "textBorderColor") && (out.borderColor = richItem.textBorderColor);
  util.hasOwn(richItem, "textBorderWidth") && (out.borderWidth = richItem.textBorderWidth);
  util.hasOwn(richItem, "textBorderRadius") && (out.borderRadius = richItem.textBorderRadius);
  util.hasOwn(richItem, "textBoxShadowColor") && (out.shadowColor = richItem.textBoxShadowColor);
  util.hasOwn(richItem, "textBoxShadowBlur") && (out.shadowBlur = richItem.textBoxShadowBlur);
  util.hasOwn(richItem, "textBoxShadowOffsetX") && (out.shadowOffsetX = richItem.textBoxShadowOffsetX);
  util.hasOwn(richItem, "textBoxShadowOffsetY") && (out.shadowOffsetY = richItem.textBoxShadowOffsetY);
}
function convertToEC4StyleForCustomSerise(itemStl, txStl, txCfg) {
  var out = itemStl;
  out.textPosition = out.textPosition || txCfg.position || "inside";
  txCfg.offset != null && (out.textOffset = txCfg.offset);
  txCfg.rotation != null && (out.textRotation = txCfg.rotation);
  txCfg.distance != null && (out.textDistance = txCfg.distance);
  var isInside = out.textPosition.indexOf("inside") >= 0;
  var hostFill = itemStl.fill || "#000";
  convertToEC4RichItem(out, txStl);
  var textFillNotSet = out.textFill == null;
  if (isInside) {
    if (textFillNotSet) {
      out.textFill = txCfg.insideFill || "#fff";
      !out.textStroke && txCfg.insideStroke && (out.textStroke = txCfg.insideStroke);
      !out.textStroke && (out.textStroke = hostFill);
      out.textStrokeWidth == null && (out.textStrokeWidth = 2);
    }
  } else {
    if (textFillNotSet) {
      out.textFill = itemStl.fill || txCfg.outsideFill || "#000";
    }
    !out.textStroke && txCfg.outsideStroke && (out.textStroke = txCfg.outsideStroke);
  }
  out.text = txStl.text;
  out.rich = txStl.rich;
  util.each(txStl.rich, function(richItem) {
    convertToEC4RichItem(richItem, richItem);
  });
  return out;
}
function convertToEC4RichItem(out, richItem) {
  if (!richItem) {
    return;
  }
  util.hasOwn(richItem, "fill") && (out.textFill = richItem.fill);
  util.hasOwn(richItem, "stroke") && (out.textStroke = richItem.fill);
  util.hasOwn(richItem, "lineWidth") && (out.textStrokeWidth = richItem.lineWidth);
  util.hasOwn(richItem, "font") && (out.font = richItem.font);
  util.hasOwn(richItem, "fontStyle") && (out.fontStyle = richItem.fontStyle);
  util.hasOwn(richItem, "fontWeight") && (out.fontWeight = richItem.fontWeight);
  util.hasOwn(richItem, "fontSize") && (out.fontSize = richItem.fontSize);
  util.hasOwn(richItem, "fontFamily") && (out.fontFamily = richItem.fontFamily);
  util.hasOwn(richItem, "align") && (out.textAlign = richItem.align);
  util.hasOwn(richItem, "verticalAlign") && (out.textVerticalAlign = richItem.verticalAlign);
  util.hasOwn(richItem, "lineHeight") && (out.textLineHeight = richItem.lineHeight);
  util.hasOwn(richItem, "width") && (out.textWidth = richItem.width);
  util.hasOwn(richItem, "height") && (out.textHeight = richItem.height);
  util.hasOwn(richItem, "backgroundColor") && (out.textBackgroundColor = richItem.backgroundColor);
  util.hasOwn(richItem, "padding") && (out.textPadding = richItem.padding);
  util.hasOwn(richItem, "borderColor") && (out.textBorderColor = richItem.borderColor);
  util.hasOwn(richItem, "borderWidth") && (out.textBorderWidth = richItem.borderWidth);
  util.hasOwn(richItem, "borderRadius") && (out.textBorderRadius = richItem.borderRadius);
  util.hasOwn(richItem, "shadowColor") && (out.textBoxShadowColor = richItem.shadowColor);
  util.hasOwn(richItem, "shadowBlur") && (out.textBoxShadowBlur = richItem.shadowBlur);
  util.hasOwn(richItem, "shadowOffsetX") && (out.textBoxShadowOffsetX = richItem.shadowOffsetX);
  util.hasOwn(richItem, "shadowOffsetY") && (out.textBoxShadowOffsetY = richItem.shadowOffsetY);
  util.hasOwn(richItem, "textShadowColor") && (out.textShadowColor = richItem.textShadowColor);
  util.hasOwn(richItem, "textShadowBlur") && (out.textShadowBlur = richItem.textShadowBlur);
  util.hasOwn(richItem, "textShadowOffsetX") && (out.textShadowOffsetX = richItem.textShadowOffsetX);
  util.hasOwn(richItem, "textShadowOffsetY") && (out.textShadowOffsetY = richItem.textShadowOffsetY);
}
function warnDeprecated(deprecated, insteadApproach) {
  if (process.env.NODE_ENV !== "production") {
    var key = deprecated + "^_^" + insteadApproach;
    if (!deprecatedLogs[key]) {
      console.warn('[ECharts] DEPRECATED: "' + deprecated + '" has been deprecated. ' + insteadApproach);
      deprecatedLogs[key] = true;
    }
  }
}
exports.convertFromEC4CompatibleStyle = convertFromEC4CompatibleStyle;
exports.convertToEC4StyleForCustomSerise = convertToEC4StyleForCustomSerise;
exports.isEC4CompatibleStyle = isEC4CompatibleStyle;
exports.warnDeprecated = warnDeprecated;
