const VALUE_SPLIT = "__RC_CASCADER_SPLIT__";
const SHOW_PARENT = "SHOW_PARENT";
const SHOW_CHILD = "SHOW_CHILD";
function toPathKey(value) {
  return value.join(VALUE_SPLIT);
}
function toPathKeys(value) {
  return value.map(toPathKey);
}
function toPathValueStr(pathKey) {
  return pathKey.split(VALUE_SPLIT);
}
function fillFieldNames(fieldNames) {
  const { label, value, children } = fieldNames || {};
  const val = value || "value";
  return {
    label: label || "label",
    value: val,
    key: val,
    children: children || "children"
  };
}
function isLeaf(option, fieldNames) {
  var _a, _b;
  return (_b = option.isLeaf) != null ? _b : !((_a = option[fieldNames.children]) == null ? void 0 : _a.length);
}
function scrollIntoParentView(element) {
  const parent = element.parentElement;
  if (!parent)
    return;
  const elementToParent = element.offsetTop - parent.offsetTop;
  if (elementToParent - parent.scrollTop < 0)
    parent.scrollTo({ top: elementToParent });
  else if (elementToParent + element.offsetHeight - parent.scrollTop > parent.offsetHeight)
    parent.scrollTo({ top: elementToParent + element.offsetHeight - parent.offsetHeight });
}

export { SHOW_CHILD, SHOW_PARENT, VALUE_SPLIT, fillFieldNames, isLeaf, scrollIntoParentView, toPathKey, toPathKeys, toPathValueStr };
//# sourceMappingURL=commonUtil.mjs.map
