"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// packages/block-editor/src/components/writing-flow/index.js
var writing_flow_exports = {};
__export(writing_flow_exports, {
  default: () => writing_flow_default,
  useWritingFlow: () => useWritingFlow
});
module.exports = __toCommonJS(writing_flow_exports);
var import_clsx = __toESM(require("clsx"));
var import_data = require("@wordpress/data");
var import_i18n = require("@wordpress/i18n");
var import_compose = require("@wordpress/compose");
var import_element = require("@wordpress/element");
var import_use_multi_selection = __toESM(require("./use-multi-selection"));
var import_use_tab_nav = __toESM(require("./use-tab-nav"));
var import_use_arrow_nav = __toESM(require("./use-arrow-nav"));
var import_use_select_all = __toESM(require("./use-select-all"));
var import_use_drag_selection = __toESM(require("./use-drag-selection"));
var import_use_selection_observer = __toESM(require("./use-selection-observer"));
var import_use_click_selection = __toESM(require("./use-click-selection"));
var import_use_input = __toESM(require("./use-input"));
var import_use_clipboard_handler = __toESM(require("./use-clipboard-handler"));
var import_store = require("../../store");
var import_jsx_runtime = require("react/jsx-runtime");
function useWritingFlow() {
  const [before, ref, after] = (0, import_use_tab_nav.default)();
  const hasMultiSelection = (0, import_data.useSelect)(
    (select) => select(import_store.store).hasMultiSelection(),
    []
  );
  return [
    before,
    (0, import_compose.useMergeRefs)([
      ref,
      (0, import_use_clipboard_handler.default)(),
      (0, import_use_input.default)(),
      (0, import_use_drag_selection.default)(),
      (0, import_use_selection_observer.default)(),
      (0, import_use_click_selection.default)(),
      (0, import_use_multi_selection.default)(),
      (0, import_use_select_all.default)(),
      (0, import_use_arrow_nav.default)(),
      (0, import_compose.useRefEffect)(
        (node) => {
          node.tabIndex = 0;
          node.dataset.hasMultiSelection = hasMultiSelection;
          if (!hasMultiSelection) {
            return () => {
              delete node.dataset.hasMultiSelection;
            };
          }
          node.setAttribute(
            "aria-label",
            (0, import_i18n.__)("Multiple selected blocks")
          );
          return () => {
            delete node.dataset.hasMultiSelection;
            node.removeAttribute("aria-label");
          };
        },
        [hasMultiSelection]
      )
    ]),
    after
  ];
}
function WritingFlow({ children, ...props }, forwardedRef) {
  const [before, ref, after] = useWritingFlow();
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
    before,
    /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
      "div",
      {
        ...props,
        ref: (0, import_compose.useMergeRefs)([ref, forwardedRef]),
        className: (0, import_clsx.default)(
          props.className,
          "block-editor-writing-flow"
        ),
        children
      }
    ),
    after
  ] });
}
var writing_flow_default = (0, import_element.forwardRef)(WritingFlow);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  useWritingFlow
});
//# sourceMappingURL=index.js.map
