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 _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 { Node } from 'prosemirror-model';
import { ATTRIBUTE_LIST_STYLE_TYPE } from './ListItemNodeSpec.js';
import { LIST_ITEM } from './NodeNames.js';
import { ATTRIBUTE_INDENT, MIN_INDENT_LEVEL, RESERVED_STYLE_NONE } from './ParagraphNodeSpec.js';
export var ATTRIBUTE_COUNTER_RESET = 'data-counter-reset';
export var ATTRIBUTE_FOLLOWING = 'data-following';
var AUTO_LIST_STYLE_TYPES = ['decimal', 'lower-alpha', 'lower-roman'];
var OrderedListNodeSpec = {
  attrs: {
    id: {
      "default": null
    },
    counterReset: {
      "default": null
    },
    indent: {
      "default": MIN_INDENT_LEVEL
    },
    following: {
      "default": null
    },
    listStyleType: {
      "default": null
    },
    name: {
      "default": null
    },
    start: {
      "default": 1
    },
    type: {
      "default": 'decimal'
    }
  },
  group: 'block',
  content: LIST_ITEM + '+',
  parseDOM: [{
    tag: 'ol',
    getAttrs: function getAttrs(dom) {
      var listStyleType = dom.getAttribute(ATTRIBUTE_LIST_STYLE_TYPE);
      var counterReset = dom.getAttribute(ATTRIBUTE_COUNTER_RESET) || undefined;
      var start = dom.hasAttribute('start') ? parseInt(dom.getAttribute('start'), 10) : 1;
      var indent = dom.hasAttribute(ATTRIBUTE_INDENT) ? parseInt(dom.getAttribute(ATTRIBUTE_INDENT), 10) : MIN_INDENT_LEVEL;
      var name = dom.getAttribute('name') || undefined;
      var following = dom.getAttribute(ATTRIBUTE_FOLLOWING) || undefined;
      var type = dom.getAttribute('type') || undefined;
      return {
        counterReset: counterReset,
        following: following,
        indent: indent,
        listStyleType: listStyleType,
        name: name,
        start: start,
        type: type
      };
    }
  }],
  toDOM: function toDOM(node) {
    var _node$attrs = node.attrs,
      start = _node$attrs.start,
      indent = _node$attrs.indent,
      listStyleType = _node$attrs.listStyleType,
      counterReset = _node$attrs.counterReset,
      following = _node$attrs.following,
      name = _node$attrs.name,
      type = _node$attrs.type;
    var attrs = _defineProperty({}, ATTRIBUTE_INDENT, indent);
    if (counterReset === 'none') {
      attrs[ATTRIBUTE_COUNTER_RESET] = counterReset;
    }
    if (following) {
      attrs[ATTRIBUTE_FOLLOWING] = following;
    }
    if (listStyleType) {
      attrs[ATTRIBUTE_LIST_STYLE_TYPE] = listStyleType;
    }
    if (start !== 1) {
      attrs.start = start;
    }
    if (name) {
      attrs.name = name;
    }
    var htmlListStyleType = listStyleType;
    if (!htmlListStyleType || htmlListStyleType === 'decimal') {
      htmlListStyleType = AUTO_LIST_STYLE_TYPES[indent % AUTO_LIST_STYLE_TYPES.length];
    }
    var cssCounterName = "czi-counter-".concat(indent);
    if ('x.x.x' === type) {
      if (RESERVED_STYLE_NONE !== node.attrs.styleName) {
        attrs.style = buildStyleClass(indent, node.attrs.start);
      } else {
        attrs.style = "--czi-counter-name: ".concat(cssCounterName, ";") + "--czi-counter-reset: ".concat(following ? 'none' : start - 1, ";") + "--czi-list-style-type: ".concat(htmlListStyleType);
      }
    } else {
      attrs.style = "--czi-counter-name: ".concat(cssCounterName, ";") + "--czi-counter-reset: ".concat(following ? 'none' : start - 1, ";") + "--czi-list-style-type: ".concat(htmlListStyleType);
    }
    attrs.type = type;
    return ['ol', attrs, 0];
  }
};
function buildStyleClass(indent, start) {
  var cssCounterName = "czi-counter-".concat(indent);
  var cssCounterReset = "czi-counter-".concat(indent, " ").concat(start - 1, " ");
  for (var index = 0; index < indent; index++) {
    cssCounterReset += "czi-counter-".concat(index, " 1 ");
  }
  return "--czi-counter-name: ".concat(cssCounterName, "; counter-reset: ").concat(cssCounterReset, ";");
}
export default OrderedListNodeSpec;
import { bpfrpt_proptype_NodeSpec } from "./Types.js";