"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.headingsSharedStyles = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _react = require("@emotion/react");
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
var _getEditorUgcToken = _interopRequireDefault(require("../../ugc-tokens/get-editor-ugc-token"));
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /* eslint-disable @atlaskit/ui-styling-standard/use-compiled -- Pre-existing lint debt surfaced by this mechanical type-import-only PR. */ /* eslint-disable @atlaskit/ui-styling-standard/no-imported-style-values */ /* eslint-disable @atlaskit/ui-styling-standard/no-unsafe-values */ /* eslint-disable @atlaskit/ui-styling-standard/no-nested-selectors */ /* eslint-disable @atlaskit/design-system/use-tokens-space */ /* eslint-disable @atlaskit/design-system/use-tokens-typography */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
var headingWithAlignmentStyles = function headingWithAlignmentStyles() {
  return (
    // Override marginTop: 0 with default margin found in headingsSharedStyles for first heading in alignment block that is not the first child
    {
      '.fabric-editor-block-mark.fabric-editor-alignment:not(:first-child)': {
        '> h1:first-child': {
          marginTop: '1.667em'
        },
        ' > h2:first-child': {
          marginTop: '1.8em'
        },
        '> h3:first-child': {
          marginTop: '2em'
        },
        '> h4:first-child': {
          marginTop: '1.357em'
        },
        '> h5:first-child': {
          marginTop: '1.667em'
        },
        '> h6:first-child': {
          marginTop: '1.455em'
        }
      },
      // Set marginTop: 0 if alignment block is next to a gap cursor or widget that is first child
      '.ProseMirror-gapcursor:first-child + .fabric-editor-block-mark.fabric-editor-alignment, .ProseMirror-widget:first-child + .fabric-editor-block-mark.fabric-editor-alignment, .ProseMirror-widget:first-child + .ProseMirror-widget:nth-child(2) + .fabric-editor-block-mark.fabric-editor-alignment': {
        '> :is(h1, h2, h3, h4, h5, h6):first-child': {
          marginTop: '0'
        }
      }
    }
  );
};

// @see typography spreadsheet: https://docs.google.com/spreadsheets/d/1iYusRGCT4PoPfvxbJ8NrgjtfFgXLm5lpDWXzjua1W2E/edit#gid=93913128
// text sizing prototype: http://proto/fabricrender/
var headingsSharedStyles = exports.headingsSharedStyles = function headingsSharedStyles(_typographyTheme) {
  if ((0, _platformFeatureFlags.fg)('platform_editor_typography_ugc')) {
    return (0, _react.css)(_objectSpread({
      '& h1': {
        font: (0, _getEditorUgcToken.default)('editor.font.heading.h1'),
        marginBottom: 0,
        marginTop: '1.45833em',
        '& strong': {
          fontWeight: (0, _getEditorUgcToken.default)('editor.font.weight.heading.h1.bold')
        },
        '&::before': {}
      },
      '& h2': {
        font: (0, _getEditorUgcToken.default)('editor.font.heading.h2'),
        marginTop: '1.4em',
        marginBottom: 0,
        '& strong': {
          fontWeight: (0, _getEditorUgcToken.default)('editor.font.weight.heading.h1.bold')
        }
      },
      '& h3': {
        font: (0, _getEditorUgcToken.default)('editor.font.heading.h3'),
        marginTop: '1.31249em',
        marginBottom: 0,
        '& strong': {
          fontWeight: (0, _getEditorUgcToken.default)('editor.font.weight.heading.h1.bold')
        }
      },
      '& h4': {
        font: (0, _getEditorUgcToken.default)('editor.font.heading.h4'),
        marginTop: '1.25em',
        '& strong': {
          fontWeight: (0, _getEditorUgcToken.default)('editor.font.weight.heading.h1.bold')
        }
      },
      '& h5': {
        font: (0, _getEditorUgcToken.default)('editor.font.heading.h5'),
        marginTop: '1.45833em',
        textTransform: 'none',
        '& strong': {
          fontWeight: (0, _getEditorUgcToken.default)('editor.font.weight.heading.h1.bold')
        }
      },
      '& h6': {
        font: (0, _getEditorUgcToken.default)('editor.font.heading.h6'),
        marginTop: '1.59091em',
        textTransform: 'none',
        '& strong': {
          fontWeight: (0, _getEditorUgcToken.default)('editor.font.weight.heading.h1.bold')
        }
      }
    }, headingWithAlignmentStyles()));
  } else {
    return (0, _react.css)(_objectSpread({
      '& h1': {
        fontSize: "".concat(24 / 14, "em"),
        fontStyle: 'inherit',
        lineHeight: 28 / 24,
        color: "var(--ds-text, #292A2E)",
        fontWeight: "var(--ds-font-weight-medium, 500)",
        letterSpacing: "-0.01em",
        marginBottom: 0,
        marginTop: '1.667em'
      },
      '& h2': {
        fontSize: "".concat(20 / 14, "em"),
        fontStyle: 'inherit',
        lineHeight: 24 / 20,
        color: "var(--ds-text, #292A2E)",
        fontWeight: "var(--ds-font-weight-medium, 500)",
        letterSpacing: "-0.008em",
        marginTop: '1.8em',
        marginBottom: 0
      },
      '& h3': {
        fontSize: "".concat(16 / 14, "em"),
        fontStyle: 'inherit',
        lineHeight: 20 / 16,
        color: "var(--ds-text, #292A2E)",
        fontWeight: "var(--ds-font-weight-semibold, 600)",
        letterSpacing: "-0.006em",
        marginTop: '2em',
        marginBottom: 0
      },
      '& h4': {
        fontSize: "".concat(14 / 14, "em"),
        fontStyle: 'inherit',
        lineHeight: 16 / 14,
        color: "var(--ds-text, #292A2E)",
        fontWeight: "var(--ds-font-weight-semibold, 600)",
        letterSpacing: "-0.003em",
        marginTop: '1.357em'
      },
      '& h5': {
        fontSize: "".concat(12 / 14, "em"),
        fontStyle: 'inherit',
        lineHeight: 16 / 12,
        color: "var(--ds-text, #292A2E)",
        fontWeight: "var(--ds-font-weight-semibold, 600)",
        marginTop: '1.667em',
        textTransform: 'none'
      },
      '& h6': {
        fontSize: "".concat(11 / 14, "em"),
        fontStyle: 'inherit',
        lineHeight: 16 / 11,
        color: "var(--ds-text-subtlest, #6B6E76)",
        fontWeight: "var(--ds-font-weight-bold, 653)",
        marginTop: '1.455em',
        textTransform: 'none'
      }
    }, headingWithAlignmentStyles()));
  }
};