"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);

// src/components/Accordion/AccordionLink.tsx
var AccordionLink_exports = {};
__export(AccordionLink_exports, {
  AccordionLink: () => AccordionLink
});
module.exports = __toCommonJS(AccordionLink_exports);
var import_dedupe3 = __toESM(require("classnames/dedupe"));

// src/components/Flex/Flex.tsx
var import_dedupe = __toESM(require("classnames/dedupe"));

// src/utils/filterUndefinedProps.ts
var filterUndefinedProps = (props) => {
  const filteredProps = {};
  Object.keys(props).forEach((key) => {
    if (props[key] !== void 0) {
      filteredProps[key] = props[key];
    }
  });
  return filteredProps;
};

// src/utils/getSpacingValue.ts
var getSpacingValue = (padding) => {
  if (typeof padding === "string") {
    return `var(--size-${padding})`;
  }
  if (typeof padding === "number") {
    return `${padding}px`;
  }
  return void 0;
};

// src/components/Flex/propUtils.ts
var buildFlexStyles = (props) => {
  const {
    flexDirection,
    flexWrap,
    flexGrow,
    flex,
    justifyContent,
    alignItems,
    alignContent,
    gap,
    rowGap,
    columnGap
  } = props;
  const styleProps = {
    flexDirection,
    flexWrap,
    flexGrow,
    flex,
    justifyContent,
    alignItems,
    alignContent,
    gap: getSpacingValue(gap),
    columnGap: getSpacingValue(columnGap),
    rowGap: getSpacingValue(rowGap)
  };
  return filterUndefinedProps(styleProps);
};
var splitProps = (props) => {
  const {
    flexDirection,
    flexWrap,
    flexGrow,
    flex,
    justifyContent,
    alignItems,
    alignContent,
    gap,
    rowGap,
    columnGap,
    ...otherProps
  } = props;
  return [
    {
      flexDirection,
      flexWrap,
      flexGrow,
      flex,
      justifyContent,
      alignItems,
      alignContent,
      gap,
      rowGap,
      columnGap
    },
    otherProps
  ];
};

// src/components/Flex/Flex.tsx
var import_Flex = require("@simplybusiness/mobius/src/components/Flex/Flex.css");
var import_jsx_runtime = require("react/jsx-runtime");
var Flex = ({ ref, ...props }) => {
  const {
    elementType: Element = "div",
    style,
    className,
    ...otherProps
  } = props;
  const classes = (0, import_dedupe.default)("mobius", "mobius-flex", className);
  const [styleProps, restProps] = splitProps(otherProps);
  const flexStyles = buildFlexStyles(styleProps);
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
    Element,
    {
      ref,
      style: {
        ...flexStyles,
        ...style
      },
      className: classes,
      ...restProps
    }
  );
};
Flex.displayName = "Flex";

// src/components/Icon/Icon.tsx
var import_dedupe2 = __toESM(require("classnames/dedupe"));
var import_Icon = require("@simplybusiness/mobius/src/components/Icon/Icon.css");
var import_jsx_runtime2 = require("react/jsx-runtime");
var ICON_PREFIX = "mobius-icon";
var capitaliseFirstLetter = (str) => str.charAt(0).toUpperCase() + str.slice(1);
function Icon({
  ref,
  icon,
  className,
  size = "xs",
  color,
  fixedWidth,
  spin,
  spinReverse,
  title,
  ...otherProps
}) {
  if (!icon) {
    throw new Error("Must specify icon object");
  }
  const classes = (0, import_dedupe2.default)(
    "mobius",
    "mobius-icon",
    `svg-inline--${ICON_PREFIX}`,
    `--size-${size}`,
    className,
    {
      [`${ICON_PREFIX}-fw`]: fixedWidth,
      [`${ICON_PREFIX}-spin`]: spin || spinReverse,
      [`${ICON_PREFIX}-spin-reverse`]: spinReverse
    }
  );
  const { iconName, width, height, svgPathData } = icon;
  const formattedIconName = iconName.split("-").join(" ");
  const defaultTitle = `${capitaliseFirstLetter(formattedIconName)} icon`;
  const titleText = title || defaultTitle;
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
    "svg",
    {
      ref,
      focusable: "false",
      "data-icon": iconName,
      className: classes,
      role: "img",
      xmlns: "http://www.w3.org/2000/svg",
      viewBox: `0 0 ${width} ${height}`,
      style: { color },
      ...otherProps,
      children: [
        /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("title", { children: titleText }),
        /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { fill: "currentColor", d: svgPathData })
      ]
    }
  );
}

// src/components/Accordion/AccordionLink.tsx
var import_icons = require("@simplybusiness/icons");
var import_jsx_runtime3 = require("react/jsx-runtime");
var AccordionLink = ({
  text,
  elementType: LinkElement = "span",
  toggle,
  onClick,
  headerChildren,
  ariaExpanded,
  accordionId,
  contentId
}) => {
  const linkClasses = (0, import_dedupe3.default)("mobius-accordion__link", {
    "--is-open": ariaExpanded
  });
  const iconClasses = (0, import_dedupe3.default)("mobius-accordion__link-icon", {
    "--is-open": ariaExpanded
  });
  const handleOnClick = (e) => {
    if (onClick) {
      onClick(e);
    }
    toggle();
  };
  const handleKeyDown = (e) => {
    if (e.key === " " || e.key === "Enter") {
      toggle();
    }
  };
  if (headerChildren) {
    return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
      Flex,
      {
        justifyContent: "space-between",
        alignItems: "center",
        className: "mobius-accordion__header",
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
            "div",
            {
              id: accordionId,
              className: linkClasses,
              onClick: handleOnClick,
              onKeyDown: handleKeyDown,
              role: "button",
              tabIndex: 0,
              "aria-expanded": !!ariaExpanded,
              "aria-controls": contentId,
              children: [
                /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(LinkElement, { className: "mobius-accordion__link-text", children: text }),
                /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon, { icon: import_icons.chevronDown, className: iconClasses })
              ]
            }
          ),
          headerChildren
        ]
      }
    );
  }
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
    "div",
    {
      id: accordionId,
      className: linkClasses,
      onClick: handleOnClick,
      onKeyDown: handleKeyDown,
      role: "button",
      tabIndex: 0,
      "aria-expanded": !!ariaExpanded,
      "aria-controls": contentId,
      children: [
        /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(LinkElement, { className: "mobius-accordion__link-text", children: text }),
        /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon, { icon: import_icons.chevronDown, className: iconClasses })
      ]
    }
  );
};
//# sourceMappingURL=AccordionLink.js.map
