"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);
var headings_dropdown_utils_exports = {};
__export(headings_dropdown_utils_exports, {
  getCustomHeadingsLabel: () => getCustomHeadingsLabel,
  hasStyleChanges: () => hasStyleChanges,
  headingsMap: () => headingsMap,
  translateHeading: () => translateHeading
});
module.exports = __toCommonJS(headings_dropdown_utils_exports);
var import_react = __toESM(require("react"));
var import_ricos_types = require("./../ricos-types/index.js");
const headingsMap = {
  "header-one": "Heading 1",
  "header-two": "Heading 2",
  "header-three": "Heading 3",
  "header-four": "Heading 4",
  "header-five": "Heading 5",
  "header-six": "Heading 6",
  unstyled: "P"
};
const findOsName = () => {
  if (navigator.userAgent.indexOf("Win") !== -1) {
    return "Windows";
  }
  if (navigator.userAgent.indexOf("Mac") !== -1) {
    return "MacOS";
  }
  return null;
};
const headingShortcuts = {
  MacOS: (number) => ` (⌘⌥${number})`,
  Windows: (number) => ` (Ctrl+Alt+${number})`
};
const translateHeading = (option = "P", t, shouldAddShortcut = false) => {
  const number = parseInt(option.slice(-1)) ? option.slice(-1) : void 0;
  const osName = findOsName();
  const shortcut = shouldAddShortcut && osName ? headingShortcuts[osName](number || 0) : void 0;
  return option === "P" ? t("FormattingToolbar_TextStyle_Paragraph", shortcut && { shortcut }) : t("FormattingToolbar_TextStyle_Heading", shortcut ? { number, shortcut } : { number });
};
const getCustomHeadingsLabel = (selectedHeading, t, publicCommands) => {
  const label = translateHeading(headingsMap[selectedHeading], t);
  const inlineStyles = publicCommands.getInlineStylesInSelection() || {};
  const isAsteriskVisible = hasStyleChanges(
    selectedHeading,
    inlineStyles,
    publicCommands.getDocumentStyle()
  );
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, label, /* @__PURE__ */ import_react.default.createElement("span", { style: { width: "1ch", marginInline: "-3px" } }, isAsteriskVisible ? "*" : null));
};
const hasStyleChanges = (currentHeading, inlineStyles, documentStyle) => {
  const key = import_ricos_types.DRAFT_TO_DOC_TYPE_WITH_LISTS[currentHeading];
  const headerStyle = documentStyle?.[key] || {};
  return Object.entries(inlineStyles).some(
    ([key2, value]) => headerStyle[key2] !== value
  );
};
//# sourceMappingURL=headings-dropdown-utils.js.map
