// ../src/helpers/formatClassString.ts
var formatClassString = (classesArray) => {
  return classesArray.filter((x) => !!x).join(" ");
};

// ../src/foundations/icons/sprite.svg
import { h } from "preact";
import { jsx, jsxs } from "preact/jsx-runtime";

// ../src/components/icon-sprite/icon-sprite.tsx
import { jsx as jsx2 } from "preact/jsx-runtime";
var IconUse = ({ iconName, classNames, attributes }) => {
  const componentClassName = "ds-icon";
  const classes = formatClassString([
    componentClassName,
    `${componentClassName}--sprite`,
    `${componentClassName}--${iconName}`,
    classNames
  ]);
  return /* @__PURE__ */ jsx2("i", { className: classes, ...attributes, children: /* @__PURE__ */ jsx2("svg", { children: /* @__PURE__ */ jsx2("use", { xlinkHref: `#ds-${iconName}` }) }) });
};

// ../src/components/spinner/spinner.tsx
import { jsx as jsx3 } from "preact/jsx-runtime";
var Spinner = ({ variant = "primary", size = "large", forcePx, classNames, attributes }) => {
  const componentClassName = "ds-spinner";
  const classes = formatClassString([
    `${componentClassName}`,
    `${componentClassName}--${variant}`,
    `${componentClassName}--${size}`,
    forcePx && "ds-force-px",
    classNames
  ]);
  return /* @__PURE__ */ jsx3("span", { className: classes, ...attributes, children: /* @__PURE__ */ jsx3("span", { className: `${componentClassName}__inner` }) });
};

// ../src/components/button/button-base.tsx
import { Fragment, jsx as jsx4, jsxs as jsxs2 } from "preact/jsx-runtime";
var InnerButton = ({ text, isIconButton = false, attributes, icon, loadingHtml }) => {
  let optionalHtml;
  if (!isIconButton && attributes["aria-label"]) {
    optionalHtml = /* @__PURE__ */ jsx4("span", { "aria-hidden": "true", children: text });
  } else if (!isIconButton) {
    optionalHtml = /* @__PURE__ */ jsx4("span", { children: text });
  }
  return /* @__PURE__ */ jsxs2(Fragment, { children: [
    optionalHtml,
    icon,
    loadingHtml
  ] });
};
var ToggleWrapper = ({
  selected = false,
  disabled = false,
  attributes,
  classes,
  onChild,
  offChild,
  loadingHtml
}) => {
  return /* @__PURE__ */ jsxs2("button", { type: "button", role: "switch", "aria-checked": selected, className: classes, ...attributes, disabled, children: [
    /* @__PURE__ */ jsx4("span", { className: "ds-btn__off", "aria-hidden": "true", children: onChild }),
    /* @__PURE__ */ jsx4("span", { className: "ds-btn__on", "aria-hidden": "true", children: offChild }),
    loadingHtml
  ] });
};
var ButtonBase = ({
  text,
  disabled = false,
  variant = "primary",
  size = "md",
  fullWidth = false,
  mobileFullWidth = false,
  iconPosition = "none",
  iconName,
  loading = false,
  type = "button",
  href,
  classNames,
  attributes = {},
  forcePx = false,
  isIconButton = false,
  selected = false,
  isToggle = false,
  selectedIconName,
  selectedText
}) => {
  if (isIconButton && text && !attributes["aria-label"]) {
    attributes["aria-label"] = text;
  } else if (isToggle && text && selectedText && !attributes["aria-label"]) {
    attributes["aria-label"] = selected ? selectedText : text;
  }
  let spinnerVariant = "secondary";
  if (variant === "staticWhite" || variant === "transparent") {
    spinnerVariant = "staticBlack";
  } else if (variant === "secondaryFilled" || variant === "secondaryOutline") {
    spinnerVariant = "primary";
  }
  const loadingHtml = /* @__PURE__ */ jsx4(Spinner, { ...{ size: "small", variant: spinnerVariant, forcePx, attributes: { "aria-hidden": "true" } } });
  let icon;
  if (iconName && (iconPosition != "none" || isIconButton == true)) {
    icon = /* @__PURE__ */ jsx4(IconUse, { ...{ iconName, attributes: { "aria-hidden": "true" } } });
  }
  const classNamePrefix = "ds-btn--";
  const classes = formatClassString([
    "ds-btn",
    `${classNamePrefix}${variant}`,
    `${classNamePrefix}${size}`,
    isToggle && selected && `${classNamePrefix}selected`,
    fullWidth && `${classNamePrefix}full-width`,
    mobileFullWidth && `${classNamePrefix}mobile-full-width`,
    icon && !isIconButton && `${classNamePrefix}icon-${iconPosition}`,
    isIconButton && `${classNamePrefix}icon-only`,
    isToggle && `${classNamePrefix}toggle`,
    loading && "ds-loading",
    forcePx && "ds-force-px",
    classNames
  ]);
  let buttonToRender;
  if (isToggle) {
    let onChild, offChild;
    if (isIconButton && iconName && selectedIconName) {
      onChild = /* @__PURE__ */ jsx4(IconUse, { iconName });
      offChild = /* @__PURE__ */ jsx4(IconUse, { iconName: selectedIconName });
    } else {
      onChild = /* @__PURE__ */ jsx4("span", { children: text });
      offChild = /* @__PURE__ */ jsxs2(Fragment, { children: [
        /* @__PURE__ */ jsx4(IconUse, { iconName: "check" }),
        /* @__PURE__ */ jsx4("span", { children: selectedText })
      ] });
    }
    buttonToRender = /* @__PURE__ */ jsx4(ToggleWrapper, { ...{ selected, classes, attributes, disabled, onChild, offChild, loadingHtml } });
  } else {
    const buttonParams = { isIconButton, text, icon, loadingHtml, attributes };
    if (href) {
      const params = { ...buttonParams, loadingHtml: null };
      buttonToRender = /* @__PURE__ */ jsx4("a", { href, className: classes, ...attributes, children: /* @__PURE__ */ jsx4(InnerButton, { ...params }) });
    } else {
      buttonToRender = /* @__PURE__ */ jsx4("button", { type, className: classes, ...attributes, disabled, children: /* @__PURE__ */ jsx4(InnerButton, { ...buttonParams }) });
    }
  }
  return /* @__PURE__ */ jsx4(Fragment, { children: buttonToRender });
};

// ../src/components/button/button.tsx
import { jsx as jsx5 } from "preact/jsx-runtime";
var Button = ({
  text,
  disabled = false,
  variant = "primary",
  size = "md",
  fullWidth = false,
  mobileFullWidth = false,
  iconPosition = "none",
  iconName,
  loading = false,
  type = "button",
  href,
  isIconButton = false,
  classNames,
  attributes,
  forcePx = false
}) => {
  return /* @__PURE__ */ jsx5(
    ButtonBase,
    {
      ...{
        text,
        disabled,
        variant,
        size,
        fullWidth,
        mobileFullWidth,
        iconPosition,
        iconName,
        loading,
        type,
        href,
        isIconButton,
        classNames,
        attributes,
        forcePx
      }
    }
  );
};
var button_default = Button;

// ../src/components/modal/modal.tsx
import { jsx as jsx6, jsxs as jsxs3 } from "preact/jsx-runtime";
var Modal = ({
  title,
  modalType = "standard",
  primaryButton,
  secondaryButton,
  classNames,
  attributes,
  forcePx,
  children
}) => {
  const componentClassName = "ds-modal";
  const classes = formatClassString([
    componentClassName,
    modalType === "sheet" && `${componentClassName}--sheet`,
    forcePx && "ds-force-px",
    classNames
  ]);
  const hasButtons = primaryButton || secondaryButton;
  return /* @__PURE__ */ jsx6("div", { className: classes, children: /* @__PURE__ */ jsx6("dialog", { className: `${componentClassName}__inner`, ...attributes, children: /* @__PURE__ */ jsxs3("div", { className: `${componentClassName}__content`, children: [
    modalType === "standard" && /* @__PURE__ */ jsx6(
      button_default,
      {
        ...{
          variant: "transparent",
          size: "sm",
          iconName: "close",
          isIconButton: true,
          attributes: {
            "aria-label": "st\xE4ng"
          },
          classNames: "ds-modal__close ds-modal__close--icon"
        }
      }
    ),
    title && /* @__PURE__ */ jsx6("h2", { children: title }),
    children,
    hasButtons && /* @__PURE__ */ jsxs3("div", { className: "ds-modal__buttons", children: [
      secondaryButton && /* @__PURE__ */ jsx6(
        button_default,
        {
          ...{
            text: secondaryButton.text,
            size: "lg",
            variant: "secondaryOutline",
            href: secondaryButton.href,
            classNames: [
              "ds-modal__secondary-button",
              secondaryButton.isCloseButton && "ds-modal__close",
              secondaryButton.classNames
            ].join(" "),
            attributes: secondaryButton.attributes,
            forcePx,
            mobileFullWidth: true
          }
        }
      ),
      primaryButton && /* @__PURE__ */ jsx6(
        button_default,
        {
          ...{
            text: primaryButton.text,
            size: "lg",
            variant: "primaryBlack",
            href: primaryButton.href,
            classNames: ["ds-modal__primary-button", primaryButton.classNames].join(" "),
            attributes: primaryButton.attributes,
            forcePx,
            mobileFullWidth: true
          }
        }
      )
    ] })
  ] }) }) });
};
export {
  Modal
};
//# sourceMappingURL=modal.js.map
