import { jsx as o } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import { useResponsiveContainer as h, containerQueries as W } from "../../../../../hooks/useResponsiveContainer.js";
import { PopoverContainerPosition as w, PopoverContainerVariant as V, PopoverContainerSize as y } from "../../../Popover/types.js";
import a from "classnames";
import { memo as z } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/compat/dist/compat.module.js";
import { useMemo as l } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import { DROPDOWN_LIST_CLASS as F, DROPDOWN_LIST_ACTIVE_CLASS as j, DROPDOWN_ELEMENT_CLASS as B, DROPDOWN_ELEMENT_NO_OPTION_CLASS as K } from "../constants.js";
import Q, { renderListItemDefault as U } from "./SelectListItem.js";
import $ from "../../../Popover/Popover.js";
import { fixedForwardRef as k } from "../../../../../utils/preact/fixedForwardRef.js";
import q from "../../../../../core/Context/preact/useCoreContext.js";
import { isFunction as G } from "../../../../../utils/value/is.js";
import { boolOrFalse as H } from "../../../../../utils/value/bool.js";
const J = k(
  ({
    active: c,
    commitActions: p,
    items: d,
    disableFocusTrap: f,
    multiSelect: s,
    onKeyDown: O,
    onSelect: u,
    renderListItem: i,
    selectListId: S,
    showList: t,
    textFilter: n,
    toggleButtonRef: C,
    dismissPopover: P,
    setToTargetWidth: N,
    popoverClassNameModifiers: v,
    showOverlay: _,
    fitPosition: D,
    fixedPopoverPositioning: E,
    activeIndex: L,
    filterable: T
  }, M) => {
    const { i18n: x } = q(), I = h(W.down.xs), m = d.filter((e) => !n || e.name.toLowerCase().includes(n)), R = a(F, { [j]: t }), A = a(B, K), b = l(() => G(i) ? i : U, [i]), r = l(() => H(s), [s]);
    return t ? /* @__PURE__ */ o(
      $,
      {
        classNameModifiers: v,
        actions: r ? p : void 0,
        disableFocusTrap: f,
        divider: !0,
        dismiss: P,
        dismissible: !1,
        open: t,
        setToTargetWidth: N,
        containerSize: y.MEDIUM,
        variant: V.POPOVER,
        targetElement: C,
        withContentPadding: !1,
        position: w.BOTTOM,
        showOverlay: _ && I,
        fitPosition: D,
        fixedPositioning: E,
        children: /* @__PURE__ */ o("ul", { className: R, id: S, ref: M, role: "listbox", "aria-multiselectable": r, children: m.length ? m.map((e, g) => /* @__PURE__ */ o(
          Q,
          {
            item: e,
            multiSelect: r,
            onKeyDown: O,
            onSelect: u,
            renderListItem: b,
            selected: c.includes(e),
            isKeyboardActive: T && L === g
          },
          e.id
        )) : /* @__PURE__ */ o("div", { className: A, children: x.get("common.inputs.select.errors.noOptions") }) })
      }
    ) : null;
  }
), ce = z(J);
export {
  ce as default
};
