"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/hooks/font-family.js
var font_family_exports = {};
__export(font_family_exports, {
  FONT_FAMILY_SUPPORT_KEY: () => FONT_FAMILY_SUPPORT_KEY,
  default: () => font_family_default,
  resetFontFamily: () => resetFontFamily
});
module.exports = __toCommonJS(font_family_exports);
var import_hooks = require("@wordpress/hooks");
var import_blocks = require("@wordpress/blocks");
var import_token_list = __toESM(require("@wordpress/token-list"));
var import_components = require("@wordpress/components");
var import_utils = require("./utils");
var import_typography = require("./typography");
var import_lock_unlock = require("../lock-unlock");
var FONT_FAMILY_SUPPORT_KEY = "typography.__experimentalFontFamily";
var { kebabCase } = (0, import_lock_unlock.unlock)(import_components.privateApis);
function addAttributes(settings) {
  if (!(0, import_blocks.hasBlockSupport)(settings, FONT_FAMILY_SUPPORT_KEY)) {
    return settings;
  }
  if (!settings.attributes.fontFamily) {
    Object.assign(settings.attributes, {
      fontFamily: {
        type: "string"
      }
    });
  }
  return settings;
}
function addSaveProps(props, blockType, attributes) {
  if (!(0, import_blocks.hasBlockSupport)(blockType, FONT_FAMILY_SUPPORT_KEY)) {
    return props;
  }
  if ((0, import_utils.shouldSkipSerialization)(
    blockType,
    import_typography.TYPOGRAPHY_SUPPORT_KEY,
    "fontFamily"
  )) {
    return props;
  }
  if (!attributes?.fontFamily) {
    return props;
  }
  const classes = new import_token_list.default(props.className);
  classes.add(`has-${kebabCase(attributes?.fontFamily)}-font-family`);
  const newClassName = classes.value;
  props.className = newClassName ? newClassName : void 0;
  return props;
}
function useBlockProps({ name, fontFamily }) {
  return addSaveProps({}, name, { fontFamily });
}
var font_family_default = {
  useBlockProps,
  addSaveProps,
  attributeKeys: ["fontFamily"],
  hasSupport(name) {
    return (0, import_blocks.hasBlockSupport)(name, FONT_FAMILY_SUPPORT_KEY);
  }
};
function resetFontFamily({ setAttributes }) {
  setAttributes({ fontFamily: void 0 });
}
(0, import_hooks.addFilter)(
  "blocks.registerBlockType",
  "core/fontFamily/addAttribute",
  addAttributes
);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  FONT_FAMILY_SUPPORT_KEY,
  resetFontFamily
});
//# sourceMappingURL=font-family.js.map
