'use strict';

require('../../../../utils/index.cjs');
var props = require('../../../../utils/vue/props.cjs');
var is = require('../../../../utils/is.cjs');

function convertNodeToOption(node) {
  const {
    key,
    children,
    props: { value, disabled, ...restProps }
  } = node;
  const child = children == null ? void 0 : children.default;
  return {
    key,
    value: value !== void 0 ? value : key,
    children: child,
    disabled: disabled || disabled === "",
    // support <a-select-option disabled />
    ...restProps
  };
}
function convertChildrenToData(nodes, optionOnly = false) {
  const dd = props.flattenChildren(nodes).map((node, index) => {
    var _a;
    if (!is.isValidElement(node) || !node.type)
      return null;
    const {
      type: { isSelectOptGroup },
      key,
      children,
      props
    } = node;
    if (optionOnly || !isSelectOptGroup)
      return convertNodeToOption(node);
    const child = children && children.default ? children.default() : void 0;
    const label = (props == null ? void 0 : props.label) || ((_a = children.label) == null ? void 0 : _a.call(children)) || key;
    return {
      key: `__RC_SELECT_GRP__${key === null ? index : String(key)}__`,
      ...props,
      label,
      options: convertChildrenToData(child || [])
    };
  }).filter((data) => data);
  return dd;
}

exports.convertChildrenToData = convertChildrenToData;
//# sourceMappingURL=legacyUtil.cjs.map
