"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 Button_exports = {};
__export(Button_exports, {
  default: () => Button_default
});
module.exports = __toCommonJS(Button_exports);
var import_jsx_runtime = (
  // @ts-ignore: `ref` prop doesn't match between `Link` and `T`.
  require("react/jsx-runtime")
);
var import_react = require("react");
var import_color = __toESM(require("color"));
var import_colorToString = require("../../utils/colorToString");
var import_Link = require("../../shared/Link");
var import_use_style = require("../../../runtimes/react/use-style");
var import_responsive_style = require("../../utils/responsive-style");
var import_css = require("@emotion/css");
const Button = (0, import_react.forwardRef)(function Button2({
  as,
  id,
  children,
  link,
  variant,
  shape,
  size,
  textColor,
  color,
  textStyle,
  width,
  margin,
  className,
  ...restOfProps
}, ref) {
  const Component = as ?? import_Link.Link;
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
    Component,
    {
      ...restOfProps,
      ref,
      id,
      className: (0, import_css.cx)(
        (0, import_use_style.useStyle)({
          display: "table",
          border: 0,
          outline: 0,
          userSelect: "none",
          cursor: "pointer",
          fontFamily: "inherit",
          textDecoration: "none",
          textAlign: "center"
        }),
        (0, import_use_style.useStyle)((0, import_responsive_style.useResponsiveWidth)(width, "auto")),
        margin,
        (0, import_use_style.useStyle)(
          (0, import_responsive_style.useResponsiveStyle)(
            [variant, shape, size, textColor, color],
            ([
              variant2 = "flat",
              shape2 = "rounded",
              size2 = "medium",
              textColor2 = { swatch: { hue: 0, saturation: 0, lightness: 100 }, alpha: 1 },
              color2 = { swatch: { hue: 0, saturation: 0, lightness: 0 }, alpha: 1 }
            ]) => {
              const fontSize = {
                value: { small: 12, medium: 14, large: 18 }[size2],
                unit: "px"
              };
              return {
                color: (0, import_colorToString.colorToString)(textColor2),
                borderRadius: `${{ square: 0, rounded: 4, pill: 500 }[shape2]}px`,
                padding: `${{ small: "8px 12px", medium: "12px 16px", large: "16px 20px" }[size2]}`,
                fontSize: `${fontSize.value}${fontSize.unit}`,
                ...{
                  flat: {
                    background: (0, import_colorToString.colorToString)(color2),
                    border: "none",
                    transition: ["color", "background", "border", "box-shadow"].map((property) => `${property} 0.15s ease-in-out`).join(", "),
                    ":hover": {
                      background: (0, import_color.default)((0, import_colorToString.colorToString)(color2)).darken(0.1).hex()
                    },
                    ":active": {
                      background: (0, import_color.default)((0, import_colorToString.colorToString)(color2)).darken(0.15).hex()
                    }
                  },
                  outline: {
                    background: "transparent",
                    boxShadow: `inset 0 0 0 2px ${(0, import_colorToString.colorToString)(color2)}`,
                    transition: ["color", "background", "box-shadow"].map((property) => `${property} 0.15s ease-in-out`).join(", "),
                    ":hover": {
                      boxShadow: `inset 0 0 0 2px ${(0, import_color.default)((0, import_colorToString.colorToString)(color2)).darken(0.1).hex()}`,
                      color: (0, import_color.default)((0, import_colorToString.colorToString)(color2)).darken(0.1).hex()
                    },
                    ":active": {
                      boxShadow: `inset 0 0 0 2px ${(0, import_color.default)((0, import_colorToString.colorToString)(color2)).darken(0.15).hex()}`,
                      color: (0, import_color.default)((0, import_colorToString.colorToString)(color2)).darken(0.15).hex()
                    }
                  },
                  shadow: {
                    background: (0, import_colorToString.colorToString)(color2),
                    boxShadow: "0 2px 4px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.2)",
                    transition: ["transform", "box-shadow"].map((property) => `${property} 0.18s`).join(", "),
                    ":hover": {
                      boxShadow: "0 10px 25px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.3)",
                      transform: "translateY(-1px)"
                    },
                    ":active": {
                      boxShadow: "0 4px 12px rgba(0, 0, 0, 0.15), 0 4px 6px -3px rgba(0, 0, 0, 0.3)",
                      transform: "translateY(0px)"
                    }
                  },
                  clear: {
                    background: "transparent",
                    border: "none",
                    ":hover": {
                      color: (0, import_color.default)((0, import_colorToString.colorToString)(textColor2)).alpha(0.5).toString()
                    },
                    ":active": {
                      color: (0, import_color.default)((0, import_colorToString.colorToString)(textColor2)).alpha(0.6).toString()
                    }
                  },
                  blocky: {
                    background: (0, import_colorToString.colorToString)(color2),
                    borderWidth: 1,
                    borderStyle: "solid",
                    borderColor: (0, import_color.default)((0, import_colorToString.colorToString)(color2)).darken(0.25).hex(),
                    boxShadow: `0 4px ${(0, import_color.default)((0, import_colorToString.colorToString)(color2)).darken(0.25).hex()}`,
                    transition: ["transform", "box-shadow"].map((property) => `${property} 0.1s`).join(", "),
                    ":hover": {
                      transform: "translateY(2px)",
                      boxShadow: `0 2px ${(0, import_color.default)((0, import_colorToString.colorToString)(color2)).darken(0.25).hex()}`
                    },
                    ":active": {
                      transform: "translateY(4px)",
                      boxShadow: `0 0 ${(0, import_color.default)((0, import_colorToString.colorToString)(color2)).darken(0.25).hex()}`
                    }
                  },
                  bubbly: {
                    background: `linear-gradient(
                      180deg,
                      ${(0, import_color.default)((0, import_colorToString.colorToString)(color2)).lighten(0.05).hex()},
                      ${(0, import_color.default)((0, import_colorToString.colorToString)(color2)).darken(0.3).saturate(0.05).hex()}
                    )`,
                    position: "relative",
                    zIndex: "0",
                    ":before": {
                      position: "absolute",
                      content: '""',
                      top: 0,
                      right: 0,
                      bottom: 0,
                      left: 0,
                      zIndex: "-1",
                      borderRadius: "inherit",
                      background: `linear-gradient(
                        180deg,
                        ${(0, import_color.default)((0, import_colorToString.colorToString)(color2)).lighten(0.2).hex()},
                        ${(0, import_color.default)((0, import_colorToString.colorToString)(color2)).darken(0.2).saturate(0.05).hex()}
                      )`,
                      opacity: "0",
                      transition: "opacity 0.15s"
                    },
                    ":hover": {
                      ":before": {
                        opacity: "1"
                      }
                    },
                    ":active": {
                      ":before": {
                        opacity: "0.25"
                      }
                    }
                  },
                  skewed: {
                    position: "relative",
                    zIndex: "0",
                    ":before": {
                      position: "absolute",
                      content: '""',
                      top: 0,
                      right: 0,
                      bottom: 0,
                      left: 0,
                      zIndex: "-1",
                      background: (0, import_colorToString.colorToString)(color2),
                      transform: "skewX(-12deg)",
                      borderRadius: "inherit",
                      transition: "transform 0.2s cubic-bezier(0.25, 0, 0.25, 1.75)"
                    },
                    ":hover:before": {
                      transform: "skew(0deg)"
                    },
                    ":active:before": {
                      transform: "skew(-8deg)"
                    }
                  }
                }[variant2]
              };
            }
          )
        ),
        (0, import_use_style.useStyle)((0, import_responsive_style.useResponsiveTextStyle)(textStyle)),
        className
      ),
      link,
      children: children == null ? "Button Text" : children
    }
  );
});
var Button_default = Button;
//# sourceMappingURL=Button.js.map