"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _element = require("@wordpress/element");
var _dropdownMenu = _interopRequireDefault(require("../../dropdown-menu"));
var _toolbarContext = _interopRequireDefault(require("../toolbar-context"));
var _toolbarItem = _interopRequireDefault(require("../toolbar-item"));
var _jsxRuntime = require("react/jsx-runtime");
/**
 * WordPress dependencies
 */

/**
 * Internal dependencies
 */

function ToolbarGroupCollapsed({
  controls = [],
  toggleProps,
  ...props
}) {
  // It'll contain state if `ToolbarGroup` is being used within
  // `<Toolbar label="label" />`
  const accessibleToolbarState = (0, _element.useContext)(_toolbarContext.default);
  const renderDropdownMenu = internalToggleProps => /*#__PURE__*/(0, _jsxRuntime.jsx)(_dropdownMenu.default, {
    controls: controls,
    toggleProps: {
      ...internalToggleProps,
      'data-toolbar-item': true
    },
    ...props
  });
  if (accessibleToolbarState) {
    return /*#__PURE__*/(0, _jsxRuntime.jsx)(_toolbarItem.default, {
      ...toggleProps,
      children: renderDropdownMenu
    });
  }
  return renderDropdownMenu(toggleProps);
}
var _default = exports.default = ToolbarGroupCollapsed;
//# sourceMappingURL=toolbar-group-collapsed.js.map