"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
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 Breadcrumb_exports = {};
__export(Breadcrumb_exports, {
  default: () => Breadcrumb_default
});
module.exports = __toCommonJS(Breadcrumb_exports);
var import_react = __toESM(require("react"));
var import_styled_components = __toESM(require("styled-components"));
var import_Flex = __toESM(require("../../layout/Flex"));
var import_Text = __toESM(require("../../asorted/Text"));
var import_Dropdown = __toESM(require("../../form/Dropdown"));
var ControlModule = __toESM(require("../../form/SelectInput/Control"));
const Link = (0, import_styled_components.default)(import_Text.default).attrs({
  ff: "Inter|SemiBold",
  fontSize: 3,
  color: "neutral.c80",
  tabIndex: 0
})`
  cursor: pointer;
  &:hover,
  &:active,
  &:focus {
    color: ${(p) => p.theme.colors.neutral.c100};
    text-decoration: underline;
  }
`;
function isMultiSegment(segment) {
  return segment.options !== void 0;
}
var Breadcrumb_default = (0, import_react.memo)(function Breadcrumb({ segments, onChange }) {
  const theme = (0, import_styled_components.useTheme)();
  const [contents] = segments.reduce(
    ([renderArray, valuesArray], segment, index) => {
      const values = [...valuesArray];
      renderArray.push(
        /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, index > 0 ? /* @__PURE__ */ import_react.default.createElement(import_Text.default, { fontWeight: "semiBold", color: "neutral.c40", variant: "paragraph" }, "/") : null, isMultiSegment(segment) ? /* @__PURE__ */ import_react.default.createElement(
          import_Dropdown.default,
          {
            label: "",
            options: segment.options,
            value: segment.value,
            onChange: (elt) => elt && onChange([...values, elt.value]),
            styles: {
              control: (provided, state) => ({
                ...ControlModule.getStyles(theme)(provided, state),
                cursor: "pointer"
              }),
              singleValue: (provided) => ({
                ...provided,
                margin: 0,
                top: void 0,
                position: void 0,
                overflow: void 0,
                maxWidth: void 0,
                transform: void 0,
                color: theme.colors.neutral.c80,
                "&:hover": {
                  color: theme.colors.neutral.c100,
                  textDecoration: "underline"
                }
              })
            }
          }
        ) : /* @__PURE__ */ import_react.default.createElement(
          Link,
          {
            onKeyDown: (event) => ["Enter", " "].includes(event.key) && onChange([...values, segment.value]),
            onClick: () => onChange([...values, segment.value])
          },
          segment.label
        ))
      );
      valuesArray.push(isMultiSegment(segment) ? segment.value.value : segment.value);
      return [renderArray, valuesArray];
    },
    [[], []]
  );
  return /* @__PURE__ */ import_react.default.createElement(import_Flex.default, { columnGap: 5, alignItems: "center" }, contents);
});
//# sourceMappingURL=index.js.map
