text: "use strict";
  var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
      if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
      return cooked;
  };
  var __assign = (this && this.__assign) || function () {
      __assign = Object.assign || function(t) {
          for (var s, i = 1, n = arguments.length; i < n; i++) {
              s = arguments[i];
              for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                  t[p] = s[p];
          }
          return t;
      };
      return __assign.apply(this, arguments);
  };
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
      if (k2 === undefined) k2 = k;
      Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  }) : (function(o, m, k, k2) {
      if (k2 === undefined) k2 = k;
      o[k2] = m[k];
  }));
  var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
      Object.defineProperty(o, "default", { enumerable: true, value: v });
  }) : function(o, v) {
      o["default"] = v;
  });
  var __importStar = (this && this.__importStar) || function (mod) {
      if (mod && mod.__esModule) return mod;
      var result = {};
      if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
      __setModuleDefault(result, mod);
      return result;
  };
  var __rest = (this && this.__rest) || function (s, e) {
      var t = {};
      for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
          t[p] = s[p];
      if (s != null && typeof Object.getOwnPropertySymbols === "function")
          for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
              if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                  t[p[i]] = s[p[i]];
          }
      return t;
  };
  var __importDefault = (this && this.__importDefault) || function (mod) {
      return (mod && mod.__esModule) ? mod : { "default": mod };
  };
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.Button = void 0;
  var react_1 = __importStar(require("react"));
  var react_is_1 = require("react-is");
  var styled_components_1 = __importDefault(require("styled-components"));
  var internal_1 = require("../../styles/internal");
  var theme_1 = require("../../theme");
  var box_1 = require("../box");
  var flex_1 = require("../flex");
  var spinner_1 = require("../spinner");
  var text_1 = require("../text");
  var styles_1 = require("./styles");
  var Root = styled_components_1.default.button(internal_1.responsiveRadiusStyle, styles_1.buttonBaseStyles, styles_1.buttonColorStyles);
  var LoadingBox = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n  position: absolute;\n  top: 0;\n  left: 0;\n  right: 0;\n  bottom: 0;\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  background-color: var(--card-bg-color);\n  border-radius: inherit;\n  z-index: 1;\n  box-shadow: inherit;\n"], ["\n  position: absolute;\n  top: 0;\n  left: 0;\n  right: 0;\n  bottom: 0;\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  background-color: var(--card-bg-color);\n  border-radius: inherit;\n  z-index: 1;\n  box-shadow: inherit;\n"])));
  exports.Button = react_1.forwardRef(function (props, ref) {
      var children = props.children, disabled = props.disabled, fontSize = props.fontSize, icon = props.icon, iconRight = props.iconRight, _a = props.justify, justify = _a === void 0 ? 'center' : _a, loading = props.loading, _b = props.mode, mode = _b === void 0 ? 'default' : _b, _c = props.padding, padding = _c === void 0 ? 3 : _c, paddingX = props.paddingX, paddingY = props.paddingY, paddingTop = props.paddingTop, paddingBottom = props.paddingBottom, paddingLeft = props.paddingLeft, paddingRight = props.paddingRight, _d = props.radius, radius = _d === void 0 ? 2 : _d, selected = props.selected, _e = props.space, space = _e === void 0 ? 3 : _e, text = props.text, _f = props.tone, tone = _f === void 0 ? 'default' : _f, _g = props.type, type = _g === void 0 ? 'button' : _g, restProps = __rest(props, ["children", "disabled", "fontSize", "icon", "iconRight", "justify", "loading", "mode", "padding", "paddingX", "paddingY", "paddingTop", "paddingBottom", "paddingLeft", "paddingRight", "radius", "selected", "space", "text", "tone", "type"]);
      var theme = theme_1.useTheme();
      var boxProps = {
          padding: padding,
          paddingX: paddingX,
          paddingY: paddingY,
          paddingTop: paddingTop,
          paddingBottom: paddingBottom,
          paddingLeft: paddingLeft,
          paddingRight: paddingRight,
      };
      return (react_1.default.createElement(Root, __assign({ "data-ui": "Button" }, restProps, { "$mode": mode, "$radius": radius, "$tone": tone, "data-disabled": Boolean(loading || disabled), "data-selected": selected ? '' : undefined, disabled: Boolean(loading || disabled), ref: ref, type: type }),
          Boolean(loading) && (react_1.default.createElement(LoadingBox, null,
              react_1.default.createElement(spinner_1.Spinner, null))),
          (icon || text || iconRight) && (react_1.default.createElement(box_1.Box, __assign({ as: "span" }, boxProps),
              react_1.default.createElement(flex_1.Flex, { as: "span", justify: justify },
                  icon && (react_1.default.createElement(text_1.Text, { size: fontSize },
                      react_1.isValidElement(icon) && icon,
                      react_is_1.isValidElementType(icon) && react_1.createElement(icon))),
                  text && (react_1.default.createElement(box_1.Box, { flex: iconRight ? 1 : undefined, marginLeft: icon ? space : undefined, marginRight: iconRight ? space : undefined },
                      react_1.default.createElement(text_1.Text, { size: fontSize, weight: theme.sanity.button.textWeight }, text))),
                  iconRight && (react_1.default.createElement(text_1.Text, { size: fontSize },
                      react_1.isValidElement(iconRight) && iconRight,
                      react_is_1.isValidElementType(iconRight) && react_1.createElement(iconRight)))))),
          children && react_1.default.createElement("span", null, children)));
  });
  exports.Button.displayName = 'Button';
  var templateObject_1;
  //# sourceMappingURL=button.js.map