import { jsx } from '@emotion/core';
import { StructuredLogLevel } from './types.esm.js';
import { FormattedMessage } from './FormattedMessage.esm.js';

/** @jsx jsx */
function FormattedLogMessage(_ref) {
  var level = _ref.level,
      message = _ref.message,
      className = _ref.className;
  return jsx("div", {
    css: getMessageCss(level),
    className: className
  }, jsx(FormattedMessage, {
    rawMessage: message || ""
  }));
}

function getMessageCss(level) {
  return function (theme) {
    var spaceMixin = {
      margin: 0,
      "&:not(:last-child)": {
        marginBottom: theme.space[3]
      }
    };
    return {
      whiteSpace: "pre-wrap",
      display: "block",
      ul: [spaceMixin, {
        marginBottom: theme.space[3],
        marginLeft: theme.space[5],
        color: theme.colors.grey[50],
        listStyle: "disc",
        fontSize: theme.fontSizes[0],
        li: {
          marginBottom: theme.space[2]
        }
      }],
      pre: [spaceMixin, {
        padding: "".concat(theme.space[5], " ").concat(theme.space[4]),
        fontSize: theme.fontSizes[1],
        lineHeight: theme.lineHeights.solid,
        color: theme.colors.grey[60],
        borderRadius: theme.radii[2],
        background: theme.colors.grey[5],
        overflowY: "auto",
        em: {
          color: getLogLevelColor(level)(theme),
          fontStyle: "normal",
          fontWeight: "bold"
        },
        span: {
          color: theme.colors.grey[60]
        }
      }],
      code: {
        lineHeight: theme.lineHeights["default"],
        fontSize: theme.fontSizes[1]
      },
      p: [spaceMixin, {
        color: theme.colors.grey[50],
        fontSize: theme.fontSizes[0],
        lineHeight: theme.lineHeights.loose,
        "&:first-of-type": {
          color: getLogLevelColor(level)(theme),
          fontSize: theme.fontSizes[1]
        },
        a: {
          textDecoration: "none"
        }
      }]
    };
  };
}

function getLogLevelColor(logLevel) {
  return function (theme) {
    switch (logLevel) {
      case StructuredLogLevel.Error:
        return theme.colors.red[70];

      case StructuredLogLevel.Warning:
        return theme.colors.yellow[90];

      default:
        return theme.colors.grey[80];
    }
  };
}

FormattedLogMessage.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "FormattedLogMessage",
  "props": {
    "className": {
      "required": false,
      "tsType": {
        "name": "string"
      },
      "description": ""
    }
  }
};

if (typeof STORYBOOK_REACT_CLASSES !== "undefined") {
  STORYBOOK_REACT_CLASSES["src/components/BuildLogs/FormattedLogMessage.tsx"] = {
    name: "FormattedLogMessage",
    docgenInfo: FormattedLogMessage.__docgenInfo,
    path: "src/components/BuildLogs/FormattedLogMessage.tsx"
  };
}

export { FormattedLogMessage };
//# sourceMappingURL=FormattedLogMessage.esm.js.map
