"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/components/src/external-link/index.tsx
var external_link_exports = {};
__export(external_link_exports, {
  ExternalLink: () => ExternalLink,
  default: () => external_link_default
});
module.exports = __toCommonJS(external_link_exports);
var import_clsx = __toESM(require("clsx"), 1);
var import_i18n = require("@wordpress/i18n");
var import_element = require("@wordpress/element");
var import_jsx_runtime = require("react/jsx-runtime");
function UnforwardedExternalLink(props, ref) {
  const {
    href,
    children,
    className,
    rel = "",
    ...additionalProps
  } = props;
  const optimizedRel = [...new Set([...rel.split(" "), "external", "noreferrer", "noopener"].filter(Boolean))].join(" ");
  const classes = (0, import_clsx.default)("components-external-link", className);
  const isInternalAnchor = !!href?.startsWith("#");
  const onClickHandler = (event) => {
    if (isInternalAnchor) {
      event.preventDefault();
    }
    if (props.onClick) {
      props.onClick(event);
    }
  };
  return (
    /* eslint-disable react/jsx-no-target-blank */
    /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("a", {
      ...additionalProps,
      className: classes,
      href,
      onClick: onClickHandler,
      target: "_blank",
      rel: optimizedRel,
      ref,
      children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
        className: "components-external-link__contents",
        children
      }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
        className: "components-external-link__icon",
        "aria-label": (
          /* translators: accessibility text */
          (0, import_i18n.__)("(opens in a new tab)")
        ),
        children: (0, import_i18n.isRTL)() ? "\u2196" : "\u2197"
      })]
    })
  );
}
var ExternalLink = (0, import_element.forwardRef)(UnforwardedExternalLink);
var external_link_default = ExternalLink;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  ExternalLink
});
//# sourceMappingURL=index.cjs.map
