"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
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 ActionRequirement_exports = {};
__export(ActionRequirement_exports, {
  default: () => ActionRequirement_default
});
module.exports = __toCommonJS(ActionRequirement_exports);
var import_jsx_runtime = require("react/jsx-runtime");
var import_react = __toESM(require("react"));
var import_prop_types = require("prop-types");
var import_styled_components = __toESM(require("styled-components"));
var import_yoga_helpers = require("@gympass/yoga-helpers");
var import_ActionRequirementStyles = require("./ActionRequirementStyles");
var import_Text = __toESM(require("../../Text"));
var import_parseDescription = __toESM(require("../../utils/parseDescription"));
var import_Box = __toESM(require("../../Box"));
const StyledActionRequirement = import_styled_components.default.div`
  display: flex;
  height: 100%;
  ${import_yoga_helpers.media.xxs`
    flex-direction: column;
  `}
  ${import_yoga_helpers.media.lg`
    flex-direction: row-reverse;
  `}
`;
const Content = import_styled_components.default.div`
  display: flex;
  flex-direction: column;
  justify-content: center;

  ${import_yoga_helpers.media.xxs`
    width: auto;
    margin-right: 0;
  `}

  ${import_yoga_helpers.media.lg`
    width: 520px;
    margin-right: 120px;
  `}
`;
const BoxIllustration = (0, import_styled_components.default)(import_Box.default)`
  flex-grow: 1;
  display: flex;
  justify-content: center;
  align-items: center;
`;
function isChildFromComponent(child, component) {
  return child.type.displayName === component.displayName;
}
function ActionRequirement(props) {
  const {
    title,
    description,
    children,
    checkable,
    illustration,
    list,
    titleAsTextDisplay = false,
    ariaLevelTitle = 1
  } = props;
  let primaryButton;
  let secondaryButton;
  const descriptionArray = (0, import_parseDescription.default)(description);
  function defineCompoundComponents() {
    import_react.default.Children.forEach(children, (child) => {
      if (isChildFromComponent(child, import_ActionRequirementStyles.PrimaryButton))
        primaryButton = child;
      if (isChildFromComponent(child, import_ActionRequirementStyles.SecondaryButton))
        secondaryButton = child;
    });
  }
  defineCompoundComponents();
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(StyledActionRequirement, __spreadProps(__spreadValues({}, props), { children: [
    illustration && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BoxIllustration, { "aria-hidden": true, children: illustration }),
    /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Content, { children: [
      titleAsTextDisplay ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Text.default.Display2, { as: "h1", "aria-level": ariaLevelTitle, children: title }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ActionRequirementStyles.Title, { "aria-level": ariaLevelTitle, children: title }),
      /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Box.default, { display: "flex", flexDirection: "column", gap: "large", mt: "small", children: descriptionArray.map((paragraph) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Text.default.Body1, { color: "deep", children: paragraph }, paragraph == null ? void 0 : paragraph.toString().slice(0, 10))) }),
      list && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Box.default, { mt: "large", children: list }),
      checkable && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Box.default, { mt: "xxlarge", children: checkable }),
      /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ActionRequirementStyles.Actions, { mt: "xlarge", children: [
        primaryButton,
        secondaryButton
      ] })
    ] })
  ] }));
}
ActionRequirement.propTypes = {
  title: (0, import_prop_types.oneOfType)([(0, import_prop_types.arrayOf)(import_prop_types.node), import_prop_types.node]).isRequired,
  children: (0, import_prop_types.oneOfType)([(0, import_prop_types.arrayOf)(import_prop_types.node), import_prop_types.node]),
  description: (0, import_prop_types.oneOfType)([import_prop_types.string, (0, import_prop_types.arrayOf)(import_prop_types.string)]).isRequired,
  checkable: (0, import_prop_types.oneOfType)([(0, import_prop_types.arrayOf)(import_prop_types.node), import_prop_types.node]),
  illustration: (0, import_prop_types.oneOfType)([(0, import_prop_types.arrayOf)(import_prop_types.node), import_prop_types.node]),
  list: (0, import_prop_types.oneOfType)([(0, import_prop_types.arrayOf)(import_prop_types.node), import_prop_types.node]),
  titleAsTextDisplay: import_prop_types.bool,
  ariaLevelTitle: import_prop_types.number
};
var ActionRequirement_default = ActionRequirement;
