import { jsx as n, jsxs as M } from "react/jsx-runtime";
import { useCallback as I } from "react";
import { c as N } from "./index.CfM2L_w0.js";
import { a as z } from "./index.CfQlFjZU.js";
import { n as f } from "./index.B0wX8xO7.js";
import { g as S, h as T } from "./index.dWlEA7uO.js";
import { a as C } from "./Tag.Bk_lQM4l.js";
const V = "creator_container_VI9AS", j = "creator_container__current_inkn2", y = "creator_selected_8-Yg3", A = "creator_single_C-O04", O = "creator_container__disabled_OZBl-", E = "creator_menuItem_uC4rV", s = { container: V, container__current: j, selected: y, single: A, container__disabled: O, menuItem: E };
var H = /* @__PURE__ */ ((e) => (e.RADIO = "radio", e.CHECKBOX = "checkbox", e))(H || {});
function K({
  item: e,
  current: m,
  multiple: r,
  selectedItems: h,
  onChange: t,
  removeItemOnReselect: c = !0,
  ...k
}) {
  let o, i, u, d, a, l, _;
  typeof e == "string" ? o = e : {
    value: o,
    disabled: u,
    prefixIcon: d,
    suffixIcon: a,
    prefixTagProps: l,
    suffixTagProps: _,
    label: i
  } = e;
  const g = m === e, p = h?.includes(e), v = i || o || "", w = r ? "checkbox" : "radio", B = I(
    (b) => {
      const x = c && r && !b.currentTarget.checked;
      t && t(e, x);
    },
    [e, r, c, t]
  ), D = I(
    (b) => {
      const x = c && b.currentTarget.checked;
      t && t(e, x);
    },
    [e, c, t]
  );
  return {
    containerClassName: N(s.container, {
      [s.container__disabled]: u,
      [s.container__current]: g,
      [s.selected]: p,
      [s.single]: !r
    }),
    checked: p,
    menuItemClassName: s.menuItem,
    label: v,
    value: o,
    type: w,
    prefixIcon: d,
    suffixIcon: a,
    multiple: r,
    prefixTagProps: l,
    suffixTagProps: _,
    change: B,
    click: p ? D : void 0,
    // only enable click if checked so we can handle unchecking
    ...k
  };
}
const X = ({
  name: e,
  label: m,
  checked: r,
  value: h,
  type: t,
  prefixIcon: c,
  suffixIcon: k,
  containerClassName: o,
  change: i,
  click: u,
  menuItemClassName: d,
  prefixTagProps: a,
  suffixTagProps: l,
  multiple: _
}) => /* @__PURE__ */ n("li", { role: "option", className: o, children: /* @__PURE__ */ M("label", { className: d, children: [
  c,
  /* @__PURE__ */ n(f, { value: a, then: /* @__PURE__ */ n(C, { ...a }) }),
  /* @__PURE__ */ n(
    f,
    {
      value: _,
      then: /* @__PURE__ */ n(
        f,
        {
          value: r,
          then: /* @__PURE__ */ n(T, { size: 24, fontSize: "small" }),
          otherwise: /* @__PURE__ */ n(S, { size: 24, fontSize: "small" })
        }
      )
    }
  ),
  /* @__PURE__ */ n(
    "input",
    {
      type: t,
      name: e,
      onChange: i,
      onClick: u,
      checked: r,
      value: h
    }
  ),
  /* @__PURE__ */ n("p", { children: m }),
  /* @__PURE__ */ n(f, { value: l, then: /* @__PURE__ */ n(C, { ...l }) }),
  k
] }) }), P = z(
  X,
  K
);
export {
  P as D,
  H as T,
  X as a,
  K as u
};
