"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 __objRest = (source, exclude) => {
  var target = {};
  for (var prop in source)
    if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
      target[prop] = source[prop];
  if (source != null && __getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(source)) {
      if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
        target[prop] = source[prop];
    }
  return target;
};
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 EventCard_exports = {};
__export(EventCard_exports, {
  default: () => EventCard_default
});
module.exports = __toCommonJS(EventCard_exports);
var import_jsx_runtime = require("react/jsx-runtime");
var import_react = __toESM(require("react"));
var import_styled_components = __toESM(require("styled-components"));
var import_prop_types = require("prop-types");
var import_yoga_icons = require("@gympass/yoga-icons");
var import_react_native = require("react-native");
var import_themeReader = __toESM(require("../../../Theme/helpers/themeReader"));
var import_Card = __toESM(require("../Card"));
var import_Text = __toESM(require("../../../Text"));
var import_Box = __toESM(require("../../../Box"));
var import_Button = __toESM(require("../../../Button"));
const { spacing, radii, colors, borders } = import_themeReader.default;
const Event = (0, import_styled_components.default)(import_Card.default).attrs({ hasShadow: false })`
  flex-direction: row;
  height: 104px;
  border-radius: ${radii.regular}px;
  padding: ${spacing.zero};
  width: 280px;
  margin-right: ${spacing.xxsmall};

  ${({ small }) => small ? import_styled_components.css`
          width: ${spacing.xxxlarge}px;
        ` : ""}
`;
const DateInfo = (0, import_styled_components.default)(import_Box.default)`
  justify-content: center;
  align-items: center;
  width: 56px;

  ${({ small, active }) => small ? import_styled_components.css`
          border: ${borders.small}px solid
            ${active ? colors.primary : colors.elements.lineAndBorders};
          border-radius: ${radii.regular}px;
        ` : import_styled_components.css`
          border: ${borders.small}px solid ${colors.primary};
          border-top-left-radius: ${radii.regular}px;
          border-bottom-left-radius: ${radii.regular}px;
        `}
`;
const EventInfo = (0, import_styled_components.default)(import_Box.default)`
  flex: 1;
  border-top-right-radius: ${radii.regular}px;
  border-bottom-right-radius: ${radii.regular}px;
  border: ${borders.small}px solid ${colors.elements.lineAndBorders};
`;
const Top = (0, import_styled_components.default)(import_Box.default)`
  justify-content: center;
  align-items: center;
  height: ${spacing.small}px;
`;
const Name = (0, import_styled_components.default)(import_Text.default.Body2)`
  margin-bottom: ${spacing.xxxsmall}px;
`;
const Place = (0, import_styled_components.default)(import_Text.default.Caption)`
  width: 180px;
  margin-bottom: ${spacing.xsmall}px;
`;
const Day = (0, import_styled_components.default)(import_Text.default.H5).attrs({ bold: true })`
  margin-top: ${spacing.xxxsmall}px;
  margin-bottom: ${spacing.xxxsmall}px;
`;
const getIndicatorColor = (active, event) => {
  if (active)
    return "white";
  return event ? "primary" : "light";
};
const Indicator = (0, import_styled_components.default)(import_Box.default)`
  width: ${spacing.xxsmall}px;
  height: ${spacing.xxsmall}px;
`;
const Row = (0, import_styled_components.default)(import_Box.default)`
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
`;
const EventTime = (0, import_styled_components.default)(import_Box.default)`
  flex-direction: row;
  align-items: center;
`;
const ButtonLink = (0, import_styled_components.default)(import_Button.default.Link)`
  align-self: flex-end;
`;
const SmallCard = ({
  date: { month, day, dayOfWeek },
  active = false,
  event = void 0,
  onPress = void 0
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DateInfo, { small: true, active, pv: "medium", bg: active ? "primary" : "white", children: [
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Top, { children: onPress ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
    Indicator,
    {
      borderRadius: "small",
      bgColor: getIndicatorColor(active, Boolean(event))
    }
  ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Text.default.Caption, { variant: active ? "white" : "deep", children: month }) }),
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Day, { variant: active ? "white" : "secondary", children: day }),
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Text.default.Caption, { variant: active ? "white" : "deep", children: String(dayOfWeek).toUpperCase() })
] });
const FullCard = (0, import_styled_components.withTheme)(
  ({
    event,
    date: { month, day, dayOfWeek },
    link,
    onLinkPress,
    theme: {
      yoga: {
        components: {
          card: {
            event: { icon }
          }
        }
      }
    }
  }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
    /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DateInfo, { bg: "primary", children: [
      /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Top, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Text.default.Caption, { inverted: true, children: month }) }),
      /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Day, { inverted: true, children: day }),
      /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Text.default.Caption, { inverted: true, children: String(dayOfWeek).toUpperCase() })
    ] }),
    /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(EventInfo, { p: "small", pl: "xsmall", children: [
      /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Name, { numberOfLines: 1, size: "small", children: event.name }),
      /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Place, { variant: "deep", numberOfLines: 1, children: event.place }),
      /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Row, { children: [
        /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(EventTime, { children: [
          /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_yoga_icons.Time, { fill: icon.fill, style: { marginRight: 5 } }),
          /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Text.default.Caption, { children: event.time })
        ] }),
        !!link && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ButtonLink, { onPress: onLinkPress, small: true, secondary: true, children: link })
      ] })
    ] })
  ] })
);
const EventCard = (_a) => {
  var _b = _a, {
    onPress,
    small = false,
    active = false,
    event,
    link = "",
    onLinkPress
  } = _b, rest = __objRest(_b, [
    "onPress",
    "small",
    "active",
    "event",
    "link",
    "onLinkPress"
  ]);
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.TouchableWithoutFeedback, { onPress, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
    Event,
    __spreadProps(__spreadValues({
      small,
      active,
      link,
      event,
      onLinkPress
    }, rest), {
      children: small ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
        SmallCard,
        __spreadValues({
          onPress,
          active,
          link,
          onLinkPress,
          event
        }, rest)
      ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
        FullCard,
        __spreadValues({
          active,
          link,
          onLinkPress,
          event
        }, rest)
      )
    })
  ) });
};
EventCard.propTypes = {
  /** event information: { name (string), place (string), time (string) } */
  event: (0, import_prop_types.oneOfType)([
    (0, import_prop_types.shape)({
      name: import_prop_types.string,
      place: import_prop_types.string,
      time: import_prop_types.string
    }),
    import_prop_types.bool
  ]),
  /** date information: { day (string), dayOfWeek (string), month (string) } */
  date: (0, import_prop_types.shape)({
    day: import_prop_types.string,
    dayOfWeek: import_prop_types.string,
    month: import_prop_types.string
  }).isRequired,
  small: import_prop_types.bool,
  active: import_prop_types.bool,
  link: import_prop_types.string,
  onLinkPress: import_prop_types.func,
  onPress: import_prop_types.func
};
SmallCard.propTypes = {
  date: (0, import_prop_types.shape)({
    day: import_prop_types.string,
    dayOfWeek: import_prop_types.string,
    month: import_prop_types.string
  }).isRequired,
  active: import_prop_types.bool,
  event: (0, import_prop_types.oneOfType)([
    (0, import_prop_types.shape)({
      name: import_prop_types.string,
      place: import_prop_types.string,
      time: import_prop_types.string
    }),
    import_prop_types.bool
  ]),
  onPress: import_prop_types.func
};
FullCard.propTypes = EventCard.propTypes;
EventCard.displayName = "EventCard";
var EventCard_default = EventCard;
