"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useNotifyCopy = useNotifyCopy;
var _element = require("@wordpress/element");
var _blocks = require("@wordpress/blocks");
var _data = require("@wordpress/data");
var _i18n = require("@wordpress/i18n");
var _notices = require("@wordpress/notices");
var _store = require("../store");
/**
 * WordPress dependencies
 */

/**
 * Internal dependencies
 */

function useNotifyCopy() {
  const {
    getBlockName
  } = (0, _data.useSelect)(_store.store);
  const {
    getBlockType
  } = (0, _data.useSelect)(_blocks.store);
  const {
    createSuccessNotice
  } = (0, _data.useDispatch)(_notices.store);
  return (0, _element.useCallback)((eventType, selectedBlockClientIds) => {
    let notice = '';
    if (selectedBlockClientIds.length === 1) {
      const clientId = selectedBlockClientIds[0];
      const title = getBlockType(getBlockName(clientId))?.title;
      notice = eventType === 'copy' ? (0, _i18n.sprintf)(
      // Translators: Name of the block being copied, e.g. "Paragraph".
      (0, _i18n.__)('Copied "%s" to clipboard.'), title) : (0, _i18n.sprintf)(
      // Translators: Name of the block being cut, e.g. "Paragraph".
      (0, _i18n.__)('Moved "%s" to clipboard.'), title);
    } else {
      notice = eventType === 'copy' ? (0, _i18n.sprintf)(
      // Translators: %d: Number of blocks being copied.
      (0, _i18n._n)('Copied %d block to clipboard.', 'Copied %d blocks to clipboard.', selectedBlockClientIds.length), selectedBlockClientIds.length) : (0, _i18n.sprintf)(
      // Translators: %d: Number of blocks being cut.
      (0, _i18n._n)('Moved %d block to clipboard.', 'Moved %d blocks to clipboard.', selectedBlockClientIds.length), selectedBlockClientIds.length);
    }
    createSuccessNotice(notice, {
      type: 'snackbar'
    });
  }, []);
}
//# sourceMappingURL=use-notify-copy.js.map