"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var use_attributes_exports = {};
__export(use_attributes_exports, {
  useAttributes: () => useAttributes
});
module.exports = __toCommonJS(use_attributes_exports);
var import_v1 = require("./../../../../ricos-schema/legacy/wix/rich_content/v1/index.js");
var import_bi_context_provider = require("./../../../bi-context-provider/bi-context-provider.js");
var import_constants = require("./../../../link-modal/constants.js");
var import_data_hooks = require("./../../../link-modal/data-hooks/data-hooks.js");
const useAttributes = (link, onChange) => {
  const logBi = (0, import_bi_context_provider.useBiNext)({ pluginId: "link", modalId: import_constants.LINK_MODAL_ID });
  return {
    onToggleNewTab: () => {
      onChange(link.rel, link.target !== import_v1.Link_Target.BLANK ? import_v1.Link_Target.BLANK : import_v1.Link_Target.TOP);
      logBi({
        dataHook: import_data_hooks.ATTRIBUTES_NEW_TAB,
        value: link.target !== import_v1.Link_Target.BLANK
      });
    },
    onToggleNofollow: () => {
      onChange(
        {
          ...link.rel,
          nofollow: !link.rel?.nofollow || void 0
        },
        link.target
      );
      logBi({ dataHook: import_data_hooks.ATTRIBUTES_NOFOLLOW, value: !link.rel?.nofollow });
    },
    onToggleNoreferrer: () => {
      onChange(
        {
          ...link.rel,
          noreferrer: !link.rel?.noreferrer || void 0
        },
        link.target
      );
      logBi({ dataHook: import_data_hooks.ATTRIBUTES_NOREFERRER, value: !link.rel?.noreferrer });
    },
    onToggleSponsored: () => {
      onChange(
        {
          ...link.rel,
          sponsored: !link.rel?.sponsored || void 0
        },
        link.target
      );
      logBi({ dataHook: import_data_hooks.ATTRIBUTES_SPONSORED, value: !link.rel?.sponsored });
    }
  };
};
//# sourceMappingURL=use-attributes.js.map
