"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
const React = require("react");
require("clsx");
const useProps = require("../../../core/MantineProvider/use-props/use-props.cjs");
const Box = require("../../../core/Box/Box.cjs");
const factory = require("../../../core/factory/factory.cjs");
const Combobox_context = require("../Combobox.context.cjs");
const Combobox_module_css = require("../Combobox.module.css.cjs");
const defaultProps = {};
const ComboboxOption = factory.factory((_props, ref) => {
  const props = useProps.useProps("ComboboxOption", defaultProps, _props);
  const {
    classNames,
    className,
    style,
    styles,
    vars,
    onClick,
    id,
    active,
    onMouseDown,
    onMouseOver,
    disabled,
    selected,
    mod,
    ...others
  } = props;
  const ctx = Combobox_context.useComboboxContext();
  const uuid = React.useId();
  const _id = id || uuid;
  return /* @__PURE__ */ jsxRuntime.jsx(
    Box.Box,
    {
      ...ctx.getStyles("option", { className, classNames, styles, style }),
      ...others,
      ref,
      id: _id,
      mod: [
        "combobox-option",
        { "combobox-active": active, "combobox-disabled": disabled, "combobox-selected": selected },
        mod
      ],
      role: "option",
      onClick: (event) => {
        var _a;
        if (!disabled) {
          (_a = ctx.onOptionSubmit) == null ? void 0 : _a.call(ctx, props.value, props);
          onClick == null ? void 0 : onClick(event);
        } else {
          event.preventDefault();
        }
      },
      onMouseDown: (event) => {
        event.preventDefault();
        onMouseDown == null ? void 0 : onMouseDown(event);
      },
      onMouseOver: (event) => {
        if (ctx.resetSelectionOnOptionHover) {
          ctx.store.resetSelectedOption();
        }
        onMouseOver == null ? void 0 : onMouseOver(event);
      }
    }
  );
});
ComboboxOption.classes = Combobox_module_css.default;
ComboboxOption.displayName = "@mantine/core/ComboboxOption";
exports.ComboboxOption = ComboboxOption;
