"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _clsx = _interopRequireDefault(require("clsx"));
var _i18n = require("@wordpress/i18n");
var _components = require("@wordpress/components");
var _icons = require("@wordpress/icons");
var _sorting = require("../../../utils/sorting");
var _jsxRuntime = require("react/jsx-runtime");
/**
 * External dependencies
 */

/**
 * WordPress dependencies
 */

/**
 * Internal dependencies
 */

const POPOVER_PROPS = {
  placement: 'bottom-start'
};
const FormatToolbar = () => {
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
    children: [['bold', 'italic', 'link', 'unknown'].map(format => /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Slot, {
      name: `RichText.ToolbarControls.${format}`
    }, format)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Slot, {
      name: "RichText.ToolbarControls",
      children: fills => {
        if (!fills.length) {
          return null;
        }
        const allProps = fills.map(([{
          props
        }]) => props);
        const hasActive = allProps.some(({
          isActive
        }) => isActive);
        return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToolbarItem, {
          children: toggleProps => /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.DropdownMenu, {
            icon: _icons.chevronDown
            /* translators: button label text should, if possible, be under 16 characters. */,
            label: (0, _i18n.__)('More'),
            toggleProps: {
              ...toggleProps,
              className: (0, _clsx.default)(toggleProps.className, {
                'is-pressed': hasActive
              }),
              description: (0, _i18n.__)('Displays more block tools')
            },
            controls: (0, _sorting.orderBy)(fills.map(([{
              props
            }]) => props), 'title'),
            popoverProps: POPOVER_PROPS
          })
        });
      }
    })]
  });
};
var _default = exports.default = FormatToolbar;
//# sourceMappingURL=index.js.map