import { jsxs as N, jsx as o } from "react/jsx-runtime";
import { useState as W, useCallback as v } from "react";
import { c as k } from "./index.CfM2L_w0.js";
import { a as U } from "./index.CfQlFjZU.js";
import { n as y } from "./index.B0wX8xO7.js";
import { b as j } from "./Dropdown.CMeTYQwB.js";
import { u as g } from "./useOutsideClick.DRN0ZU0B.js";
import { j as z, k as K } from "./index.dWlEA7uO.js";
const P = "creator_container_vgk6l", A = "creator_dropdownWrapper_p1bzd", G = "creator_dropdownWrapper__up_vf-oj", M = "creator_label_U167h", V = "creator_helper_yn2i6", F = "creator_helper__error_oUGZT", H = "creator_childrenContainer_VtyWG", a = { container: P, dropdownWrapper: A, dropdownWrapper__up: G, label: M, helper: V, helper__error: F, childrenContainer: H };
function I({
  hasError: t,
  value: i,
  noHelper: m,
  noLabel: _,
  onClick: s,
  children: h,
  customSuffixIcon: c,
  expanded: e,
  setExpanded: r,
  handleOutsideClick: l,
  ...f
}) {
  const [u] = W(i), w = g(() => {
    e && (r(!1), l());
  }), p = v(
    () => r(!e),
    [r, e]
  ), d = v(
    (n) => {
      p(), s && s(n);
    },
    [p, s]
  ), b = v(
    (n) => {
      switch (n.code) {
        case "Escape":
          return r(!1);
        default:
          return;
      }
    },
    [r]
  );
  return {
    ref: w,
    suffixIcon: c || (e ? /* @__PURE__ */ o(z, { size: 24 }) : /* @__PURE__ */ o(K, { size: 24 })),
    expanded: e,
    setExpanded: r,
    value: u,
    children: h,
    showHelper: !m,
    showLabel: !_,
    click: d,
    keyUp: b,
    containerClassName: k([a.container]),
    labelClassName: a.label,
    dropdownWrapperClass: a.dropdownWrapper,
    helperClassName: k(a.helper, {
      [a.helper__error]: t
    }),
    hasError: t,
    handleOutsideClick: l,
    ...f
  };
}
const L = ({
  label: t,
  ref: i,
  showLabel: m,
  showHelper: _,
  helper: s,
  disabled: h,
  expanded: c,
  containerClassName: e,
  labelClassName: r,
  dropdownWrapperClass: l,
  helperClassName: f,
  placeholder: u,
  value: w,
  hasError: p,
  selectedItems: d,
  click: b,
  keyUp: D,
  suffixIcon: n,
  children: C
}) => /* @__PURE__ */ N("div", { ref: i, className: e, children: [
  /* @__PURE__ */ o(
    y,
    {
      value: m,
      then: /* @__PURE__ */ o("span", { className: r, children: t })
    }
  ),
  /* @__PURE__ */ N("div", { className: l, children: [
    /* @__PURE__ */ o(
      j,
      {
        placeholder: u,
        disabled: h,
        expanded: c,
        selectedItems: d,
        value: w,
        onClick: b,
        onKeyUp: D,
        hasError: p,
        suffixIcon: n
      }
    ),
    c && /* @__PURE__ */ o("div", { className: a.childrenContainer, children: C })
  ] }),
  /* @__PURE__ */ o(
    y,
    {
      value: _,
      then: /* @__PURE__ */ o("span", { className: f, children: s })
    }
  )
] }), S = U(
  L,
  I
);
export {
  S as D,
  L as a,
  I as u
};
