"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 SocialLinks_exports = {};
__export(SocialLinks_exports, {
  default: () => SocialLinks_default
});
module.exports = __toCommonJS(SocialLinks_exports);
var import_jsx_runtime = require("react/jsx-runtime");
var import_react = require("react");
var import_Link = require("../../shared/Link");
var import_colorToString = require("../../utils/colorToString");
var import_options = require("./options");
var import_GutterContainer = __toESM(require("../../shared/GutterContainer"));
var import_SocialLinksPlaceholder = __toESM(require("./components/SocialLinksPlaceholder"));
var import_css = require("@emotion/css");
var import_use_style = require("../../../runtimes/react/use-style");
var import_responsive_style = require("../../utils/responsive-style");
const SocialLinks = (0, import_react.forwardRef)(function SocialLinks2({
  id,
  links: { links, openInNewTab } = { links: [], openInNewTab: false },
  shape,
  size,
  hoverStyle,
  fill,
  backgroundColor,
  alignment,
  gutter,
  width,
  margin
}, ref) {
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
    "div",
    {
      ref,
      id,
      className: (0, import_css.cx)(
        (0, import_use_style.useStyle)({ display: "flex", flexDirection: "row", flexWrap: "wrap" }),
        width,
        margin,
        (0, import_use_style.useStyle)(
          (0, import_responsive_style.useResponsiveStyle)([alignment], ([alignment2 = "center"]) => ({
            justifyContent: alignment2
          }))
        )
      ),
      children: links.length > 0 ? links.map((link, i) => {
        const option = import_options.SocialLinksOptions.find((o) => o.type === link.payload.type);
        if (option == null)
          return null;
        return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
          import_GutterContainer.default,
          {
            gutter,
            first: i === 0,
            last: i === links.length - 1,
            children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
              StyledLink,
              {
                backgroundColor,
                brandColor: option.brandColor,
                fill,
                hoverStyle,
                link: { type: "OPEN_URL", payload: { url: link.payload.url, openInNewTab } },
                shape,
                size,
                children: option.icon
              }
            )
          },
          link.id
        );
      }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_SocialLinksPlaceholder.default, { gutter })
    }
  );
});
var SocialLinks_default = SocialLinks;
function StyledLink({
  className,
  brandColor,
  shape,
  size,
  hoverStyle,
  fill,
  backgroundColor,
  ...restOfProps
}) {
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
    import_Link.Link,
    {
      ...restOfProps,
      className: (0, import_css.cx)(
        (0, import_use_style.useStyle)({
          display: "block",
          color: brandColor,
          transition: "transform, opacity 0.18s",
          svg: { display: "block" }
        }),
        (0, import_use_style.useStyle)(
          (0, import_responsive_style.useResponsiveStyle)(
            [shape, size, hoverStyle, fill, backgroundColor],
            ([shape2 = "naked", size2 = "medium", hoverStyle2 = "none", fill2, backgroundColor2]) => ({
              padding: shape2 === "naked" ? 0 : { small: 10, medium: 12, large: 14 }[size2],
              borderRadius: { circle: "50%", rounded: "8px", naked: 0, square: 0 }[shape2],
              background: shape2 === "naked" ? "transparent" : backgroundColor2 == null ? "currentColor" : (0, import_colorToString.colorToString)(backgroundColor2),
              ":hover": {
                none: {},
                grow: { transform: "scale(1.1)" },
                shrink: { transform: "scale(0.9)" },
                fade: { opacity: 0.65 }
              }[hoverStyle2],
              svg: {
                fill: fill2 == null ? shape2 === "naked" || backgroundColor2 != null ? "currentColor" : "white" : (0, import_colorToString.colorToString)(fill2),
                width: { small: 16, medium: 20, large: 24 }[size2],
                height: { small: 16, medium: 20, large: 24 }[size2]
              }
            })
          )
        ),
        className
      )
    }
  );
}
//# sourceMappingURL=SocialLinks.js.map