function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
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) { _defineProperty(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; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import convertToCSSPTValue from './convertToCSSPTValue.js';
import toCSSLineSpacing from './ui/toCSSLineSpacing.js';
import { Node } from 'prosemirror-model';
// This assumes that every 36pt maps to one indent level.
export var INDENT_MARGIN_PT_SIZE = 36;
export var MIN_INDENT_LEVEL = 0;
export var MAX_INDENT_LEVEL = 7;
export var ATTRIBUTE_INDENT = 'data-indent';
export var ATTRIBUTE_STYLE_LEVEL = 'data-style-level';
export var RESERVED_STYLE_NONE = 'None';
export var RESERVED_STYLE_NONE_NUMBERING = RESERVED_STYLE_NONE + '-@#$-';
var cssVal = new Set(['', '0%', '0pt', '0px']);
export var EMPTY_CSS_VALUE = cssVal;
var ALIGN_PATTERN = /(left|right|center|justify)/;

// https://github.com/ProseMirror/prosemirror-schema-basic/blob/master/src/schema-basic.js
// :: NodeSpec A plain paragraph textblock. Represented in the DOM
// as a `<p>` element.
var ParagraphNodeSpec = {
  attrs: {
    align: {
      "default": null
    },
    color: {
      "default": null
    },
    id: {
      "default": null
    },
    indent: {
      "default": null
    },
    lineSpacing: {
      "default": null
    },
    paddingBottom: {
      "default": null
    },
    paddingTop: {
      "default": null
    },
    reset: {
      "default": null
    },
    // added attributes for indent, align and linespacing overrides.
    overriddenAlign: {
      "default": null
    },
    overriddenLineSpacing: {
      "default": null
    },
    overriddenIndent: {
      "default": null
    },
    overriddenAlignValue: {
      "default": null
    },
    overriddenLineSpacingValue: {
      "default": null
    },
    overriddenIndentValue: {
      "default": null
    },
    hangingIndent: {
      "default": null
    },
    indentPosition: {
      "default": null
    },
    isDeco: {
      "default": {
        isTag: false,
        isComment: false,
        isSlice: false
      }
    }
  },
  content: 'inline*',
  group: 'block',
  defining: true,
  parseDOM: [{
    tag: 'p',
    getAttrs: getAttrs
  }],
  toDOM: toDOM
};
function getAttrs(dom) {
  var _dom$style = dom.style,
    lineHeight = _dom$style.lineHeight,
    textAlign = _dom$style.textAlign,
    marginLeft = _dom$style.marginLeft,
    paddingTop = _dom$style.paddingTop,
    paddingBottom = _dom$style.paddingBottom;
  var align = dom.getAttribute('align') || textAlign || 'left';
  align = ALIGN_PATTERN.test(align) ? align : null;
  var indent = parseInt(dom.getAttribute(ATTRIBUTE_INDENT), 10);
  if (!indent && marginLeft) {
    indent = convertMarginLeftToIndentValue(marginLeft);
  }
  indent = indent || MIN_INDENT_LEVEL;
  var lineSpacing = lineHeight ? toCSSLineSpacing(lineHeight) : null;
  var id = dom.getAttribute('id') || '';
  var reset = dom.getAttribute('reset') || '';
  var overriddenAlign = dom.getAttribute('overriddenAlign') || '';
  var overriddenAlignValue = dom.getAttribute('overriddenAlignValue') || '';
  var overriddenLineSpacing = dom.getAttribute('overriddenLineSpacing') || '';
  var overriddenLineSpacingValue = dom.getAttribute('overriddenLineSpacingValue') || '';
  var overriddenIndent = dom.getAttribute('overriddenIndent') || '';
  var overriddenIndentValue = dom.getAttribute('overriddenIndentValue') || '';
  var selectionId = dom.getAttribute('selectionId');
  var objectId = dom.getAttribute('objectId');
  var hangingIndent = dom.getAttribute('hangingIndent');
  var indentPosition = dom.getAttribute('indentPosition');
  var isDeco = {
    isTag: dom.getAttribute('isTag') === 'true',
    isComment: dom.getAttribute('isComment') === 'true',
    isSlice: dom.getAttribute('isSlice') === 'true'
  };
  return {
    align: align,
    indent: indent,
    lineSpacing: lineSpacing,
    paddingTop: paddingTop,
    paddingBottom: paddingBottom,
    reset: reset,
    id: id,
    overriddenAlign: overriddenAlign,
    overriddenAlignValue: overriddenAlignValue,
    overriddenLineSpacing: overriddenLineSpacing,
    overriddenLineSpacingValue: overriddenLineSpacingValue,
    overriddenIndent: overriddenIndent,
    overriddenIndentValue: overriddenIndentValue,
    selectionId: selectionId,
    objectId: objectId,
    hangingIndent: hangingIndent,
    indentPosition: indentPosition,
    isDeco: isDeco
  };
}
function getStyle(attrs) {
  return getStyleEx(attrs.align, attrs.lineSpacing, attrs.paddingTop, attrs.paddingBottom);
}
function getStyleEx(align, lineSpacing, paddingTop, paddingBottom) {
  var style = '';
  if (align && align !== 'left') {
    style += "text-align: ".concat(align, ";");
  }
  if (lineSpacing) {
    var cssLineSpacing = toCSSLineSpacing(lineSpacing);
    style += "line-height: ".concat(cssLineSpacing, ";") + // This creates the local css variable `--czi-content-line-height`
    // that its children may apply.
    "--czi-content-line-height: ".concat(cssLineSpacing, ";");
  }
  if (paddingTop && !EMPTY_CSS_VALUE.has(paddingTop)) {
    style += "padding-top: ".concat(paddingTop, ";");
  }
  if (paddingBottom && !EMPTY_CSS_VALUE.has(paddingBottom)) {
    style += "padding-bottom: ".concat(paddingBottom, ";");
  }
  return {
    style: style
  };
}
function toDOM(node) {
  var _node$attrs = node.attrs,
    indent = _node$attrs.indent,
    id = _node$attrs.id,
    reset = _node$attrs.reset,
    overriddenAlign = _node$attrs.overriddenAlign,
    overriddenAlignValue = _node$attrs.overriddenAlignValue,
    overriddenLineSpacing = _node$attrs.overriddenLineSpacing,
    overriddenLineSpacingValue = _node$attrs.overriddenLineSpacingValue,
    overriddenIndent = _node$attrs.overriddenIndent,
    overriddenIndentValue = _node$attrs.overriddenIndentValue,
    selectionId = _node$attrs.selectionId,
    hangingIndent = _node$attrs.hangingIndent,
    indentPosition = _node$attrs.indentPosition,
    isDeco = _node$attrs.isDeco;
  var attrs = _objectSpread({}, node.attrs);
  var _getStyle = getStyle(node.attrs),
    style = _getStyle.style;
  style && (attrs.style = style);
  if (indentPosition && hangingIndent) {
    attrs['hangingIndent'] = 'true';
    attrs['indentPosition'] = indentPosition;
    var hIndentpx = Number(indentPosition) * 96;
    document.documentElement.style.setProperty('--hangingIndentMargin', "".concat(hIndentpx, "px"));
  }
  if (indent) {
    attrs[ATTRIBUTE_INDENT] = String(indent);
  }
  if (id) {
    attrs.id = id;
  }
  attrs.reset = reset;
  attrs.overriddenAlign = overriddenAlign;
  attrs.overriddenLineSpacing = overriddenLineSpacing;
  attrs.overriddenIndent = overriddenIndent;
  attrs.overriddenAlignValue = overriddenAlignValue;
  attrs.overriddenLineSpacingValue = overriddenLineSpacingValue;
  attrs.overriddenIndentValue = overriddenIndentValue;
  attrs.hangingIndent = hangingIndent;
  if (selectionId) {
    attrs.selectionId = selectionId;
  }
  if (isDeco) {
    if (isDeco.isTag !== undefined) attrs.isTag = String(isDeco.isTag);
    if (isDeco.isComment !== undefined) attrs.isComment = String(isDeco.isComment);
    if (isDeco.isSlice !== undefined) attrs.isSlice = String(isDeco.isSlice);
  }
  return ['p', attrs, 0];
}
export var toParagraphDOM = toDOM;
export var getParagraphNodeAttrs = getAttrs;
export var getParagraphStyle = getStyle;
export function convertMarginLeftToIndentValue(marginLeft) {
  var ptValue = convertToCSSPTValue(marginLeft);
  return Math.min(Math.max(Math.floor(ptValue / INDENT_MARGIN_PT_SIZE), MIN_INDENT_LEVEL), MAX_INDENT_LEVEL);
}
export default ParagraphNodeSpec;
import { bpfrpt_proptype_NodeSpec } from "./Types.js";