"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/editor/src/components/collaborators-presence/list.tsx
var list_exports = {};
__export(list_exports, {
  CollaboratorsList: () => CollaboratorsList
});
module.exports = __toCommonJS(list_exports);
var import_i18n = require("@wordpress/i18n");
var import_components = require("@wordpress/components");
var import_icons = require("@wordpress/icons");
var import_a11y = require("@wordpress/a11y");
var import_avatar = __toESM(require("./avatar/index.cjs"));
var import_get_avatar_url = require("../collaborators-overlay/get-avatar-url.cjs");
var import_utils = require("../collab-sidebar/utils.cjs");
var import_jsx_runtime = require("react/jsx-runtime");
function CollaboratorsList({
  activeCollaborators,
  popoverAnchor,
  setIsPopoverVisible,
  cursorRegistry
}) {
  const handleCollaboratorClick = (clientId) => {
    const success = cursorRegistry.scrollToCursor(clientId, {
      behavior: "smooth",
      block: "center",
      highlightDuration: 2e3
    });
    if (success) {
      (0, import_a11y.speak)((0, import_i18n.__)("Scrolled to cursor"), "polite");
      setIsPopoverVisible(false);
    }
  };
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
    import_components.Popover,
    {
      anchor: popoverAnchor,
      placement: "bottom",
      offset: 8,
      className: "editor-collaborators-presence__list",
      onClose: () => setIsPopoverVisible(false),
      children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "editor-collaborators-presence__list-content", children: [
        /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "editor-collaborators-presence__list-header", children: [
          /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "editor-collaborators-presence__list-header-title", children: [
            (0, import_i18n.__)("Collaborators"),
            /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: activeCollaborators.length })
          ] }),
          /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "editor-collaborators-presence__list-header-action", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
            import_components.Button,
            {
              __next40pxDefaultSize: true,
              icon: import_icons.closeSmall,
              iconSize: 24,
              label: (0, import_i18n.__)("Close Collaborators List"),
              onClick: () => setIsPopoverVisible(false)
            }
          ) })
        ] }),
        /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "editor-collaborators-presence__list-items", children: activeCollaborators.map((collaboratorState) => {
          const isCurrentUser = collaboratorState.isMe;
          return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
            "button",
            {
              className: "editor-collaborators-presence__list-item",
              disabled: isCurrentUser,
              onClick: () => handleCollaboratorClick(
                collaboratorState.clientId
              ),
              children: [
                /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
                  import_avatar.default,
                  {
                    src: (0, import_get_avatar_url.getAvatarUrl)(
                      collaboratorState.collaboratorInfo.avatar_urls
                    ),
                    name: collaboratorState.collaboratorInfo.name,
                    borderColor: isCurrentUser ? "var(--wp-admin-theme-color)" : (0, import_utils.getAvatarBorderColor)(
                      collaboratorState.collaboratorInfo.id
                    ),
                    dimmed: !collaboratorState.isConnected
                  }
                ),
                /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "editor-collaborators-presence__list-item-info", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "editor-collaborators-presence__list-item-name", children: isCurrentUser ? (0, import_i18n.__)("You") : collaboratorState.collaboratorInfo.name }) })
              ]
            },
            collaboratorState.clientId
          );
        }) })
      ] })
    }
  );
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  CollaboratorsList
});
//# sourceMappingURL=list.cjs.map
