"use strict";

exports.__esModule = true;
exports.getToolbarCollectionFeaturesInitializers = getToolbarCollectionFeaturesInitializers;
var _react = require("react");
function isTabTotalElement(node) {
  var _type;
  return /*#__PURE__*/(0, _react.isValidElement)(node) && typeof ((_type = node.type) == null ? void 0 : _type.initTabTotal) === 'function';
}
function isTabsFilterElement(node) {
  return /*#__PURE__*/(0, _react.isValidElement)(node) && Array.isArray(node.props.data) && typeof node.props.counterBadge === 'function';
}
function getToolbarCollectionFeaturesInitializers(props) {
  const {
    tabs
  } = props;
  const tabTotalFeatureInitializer = (() => {
    if (isTabsFilterElement(tabs)) {
      var _el$type;
      const tabsProps = tabs.props;
      const el = tabsProps == null ? void 0 : tabsProps.data.map(value => tabs.props.counterBadge == null ? void 0 : tabs.props.counterBadge(value)).find(isTabTotalElement);
      return el == null || (_el$type = el.type) == null || _el$type.initTabTotal == null ? void 0 : _el$type.initTabTotal(tabs.props, el.props);
    }
    return undefined;
  })();
  return [tabTotalFeatureInitializer];
}
//# sourceMappingURL=getToolbarCollectionFeaturesInitializers.js.map