Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const require_chunk = require("../chunk-BN4qSVkS.cjs");
const require_utils_strings = require("../utils/strings.cjs");
const require_router = require("../router.cjs");
const require_styles_common = require("../styles/common.cjs");
const require_components_UnstyledButton = require("./UnstyledButton.cjs");
const require_components_TextIconAligner = require("./TextIconAligner.cjs");
let _emotion_styled = require("@emotion/styled");
_emotion_styled = require_chunk.__toESM(_emotion_styled);
let _emotion_react = require("@emotion/react");
let _emotion_react_jsx_runtime = require("@emotion/react/jsx-runtime");
//#region src/components/TextButton.tsx
function TextButton({ text: textProp, to, href, toParams, onClick, rightIcon, leftIcon, elide: elideArgs, disabled = false, mt = 0, ml = 0, mr = 0, padding = "0", iconMatchTextColor = false, typography }) {
	const text = elideArgs ? require_utils_strings.elide(textProp, elideArgs) : textProp;
	let rightIconProp = rightIcon;
	if (typeof rightIcon === "undefined" && typeof leftIcon === "undefined") rightIconProp = { name: "ArrowRight" };
	const defaultIconColor = iconMatchTextColor ? void 0 : "mcNeutral";
	const content = /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(require_components_TextIconAligner.TextIconAligner, {
		onClick,
		leftIcon: leftIcon ? {
			name: leftIcon.name,
			color: leftIcon.color || defaultIconColor,
			width: leftIcon.width
		} : null,
		content: text,
		typography: {
			size: "ExtraSmall",
			...typography
		},
		rightIcon: rightIconProp ? {
			name: rightIconProp.name,
			color: rightIconProp.color || defaultIconColor,
			width: rightIconProp.width
		} : null
	});
	const commonProps = {
		type: "button",
		onClick,
		disabled,
		padding,
		css: {
			marginTop: mt ? `${mt}px` : void 0,
			marginLeft: ml ? `${ml}px` : void 0,
			marginRight: mr ? `${mr}px` : void 0
		}
	};
	if (to) return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(ButtonLink, {
		...commonProps,
		to,
		params: toParams,
		children: content
	});
	return href ? /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(ButtonHrefLink, {
		...commonProps,
		href,
		target: "_blank",
		children: content
	}) : /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(StyledButton, {
		...commonProps,
		children: content
	});
}
const buttonStyle = ({ theme, disabled, padding }) => _emotion_react.css`
  display: inline-flex;
  opacity: ${disabled ? .2 : 1};
  align-items: center;
  transition: opacity 0.2s;
  padding: ${padding};

  &:focus-visible {
    outline: ${require_styles_common.getFocusOutline({ theme })};
  }

  & > * {
    width: 100%;
    text-align: center;
    white-space: nowrap;
    cursor: ${disabled ? "not-allowed" : "pointer"};
  }
`;
const StyledButton = (0, _emotion_styled.default)(require_components_UnstyledButton.UnstyledButton)`
  ${(props) => buttonStyle(props)}
`;
const ButtonLink = (0, _emotion_styled.default)(require_router.Link)`
  ${(props) => buttonStyle(props)}
`;
const ButtonHrefLink = _emotion_styled.default.a`
  ${(props) => buttonStyle(props)}
`;
//#endregion
exports.TextButton = TextButton;
