"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = BlockControlsFill;
var _components = require("@wordpress/components");
var _hook = _interopRequireDefault(require("./hook"));
var _jsxRuntime = require("react/jsx-runtime");
/**
 * WordPress dependencies
 */

/**
 * Internal dependencies
 */

function BlockControlsFill({
  group = 'default',
  controls,
  children,
  __experimentalShareWithChildBlocks = false
}) {
  const Fill = (0, _hook.default)(group, __experimentalShareWithChildBlocks);
  if (!Fill) {
    return null;
  }
  const innerMarkup = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
    children: [group === 'default' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToolbarGroup, {
      controls: controls
    }), children]
  });
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalStyleProvider, {
    document: document,
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Fill, {
      children: fillProps => {
        // `fillProps.forwardedContext` is an array of context provider entries, provided by slot,
        // that should wrap the fill markup.
        const {
          forwardedContext = []
        } = fillProps;
        return forwardedContext.reduce((inner, [Provider, props]) => /*#__PURE__*/(0, _jsxRuntime.jsx)(Provider, {
          ...props,
          children: inner
        }), innerMarkup);
      }
    })
  });
}
//# sourceMappingURL=fill.js.map