var __defProp = Object.defineProperty;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
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 __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;
};
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
import React from "react";
import {
  arrayOf,
  number,
  shape,
  bool,
  func,
  oneOfType,
  node,
  string
} from "prop-types";
import styled from "styled-components";
import Text from "../../Text";
import Box from "../../Box";
import TinyTextIcon from "./TinyTextIcon";
const Container = styled(Text.Body2)`
  flex: 1;
`;
const Separator = styled(Box).attrs({
  width: "xxxsmall",
  height: "xxxsmall"
})``;
const StyledText = styled(Text.Body2)`
  ${({
  theme: {
    yoga: {
      spacing: { xxxsmall }
    }
  }
}) => `
    margin-left: ${xxxsmall}px;
    margin-right: ${xxxsmall}px;
  `}
`;
const ResultDetails = ({
  items,
  limit,
  limitLabel = "",
  dots = false,
  renderItem = Text.Body2
}) => {
  const refinedList = limit !== 0 ? items.slice(0, limit) : items;
  const numberOfItemsLeft = items.length - limit;
  const Item = renderItem;
  return /* @__PURE__ */ jsx(Box, { flexDirection: "row", alignItems: "center", mt: "xxxsmall", children: /* @__PURE__ */ jsx(Container, { numberOfLines: 1, children: refinedList == null ? void 0 : refinedList.map(
    (_a, index) => {
      var _b = _a, { icon: IconComponent, variant } = _b, props = __objRest(_b, ["icon", "variant"]);
      const isLastItem = index === refinedList.length - 1;
      const showNumbersOfItemsLeft = isLastItem && limit !== 0 && limit < items.length;
      return (
        // eslint-disable-next-line react/no-array-index-key
        /* @__PURE__ */ jsxs(React.Fragment, { children: [
          IconComponent && /* @__PURE__ */ jsxs(Fragment, { children: [
            /* @__PURE__ */ jsx(TinyTextIcon, { as: IconComponent, fill: variant }),
            /* @__PURE__ */ jsx(Separator, {})
          ] }),
          /* @__PURE__ */ jsx(Item, __spreadValues({ variant }, props)),
          !isLastItem && (dots ? /* @__PURE__ */ jsxs(Fragment, { children: [
            /* @__PURE__ */ jsx(Separator, {}),
            /* @__PURE__ */ jsx(StyledText, { variant, children: "\u2022" }),
            /* @__PURE__ */ jsx(Separator, {})
          ] }) : /* @__PURE__ */ jsx(Separator, {})),
          showNumbersOfItemsLeft && /* @__PURE__ */ jsxs(Fragment, { children: [
            /* @__PURE__ */ jsx(Separator, {}),
            /* @__PURE__ */ jsxs(StyledText, { variant, children: [
              "+ ",
              numberOfItemsLeft,
              !!limitLabel && ` ${limitLabel}`
            ] }),
            /* @__PURE__ */ jsx(Separator, {})
          ] })
        ] }, index)
      );
    }
  ) }) });
};
ResultDetails.displayName = "Result.Details";
ResultDetails.propTypes = {
  /** Props to be passed to each component at `renderItem` */
  items: arrayOf(shape({})).isRequired,
  /** If has limit of items to show in component.Other with show with + 4 for
   * example
   * */
  limit: number,
  /** If is necessary show a label after the limit.Example + 4 activities */
  limitLabel: string,
  /** If shows the dot separator between the itens */
  dots: bool,
  /** The component to render as the item of the list. */
  renderItem: oneOfType([node, func, shape({ render: func.isRequired })])
};
var Details_default = ResultDetails;
export {
  Details_default as default
};
