import { jsx as t, jsxs as N } from "react/jsx-runtime";
import { S as O } from "./shared.EdGf6tcG.js";
import { C as B } from "./index.dWlEA7uO.js";
import { useState as I, useCallback as b } from "react";
import { B as h } from "./Button.CpTwUWVr.js";
import { b as d } from "./breakpoint.DipDapki.js";
import "./ProgressActivity.DYLCzf8q.js";
import { n as j } from "./index.B0wX8xO7.js";
import "./formInputIcon.module.CU3tuFAI.js";
import { u as z } from "./useOutsideClick.DRN0ZU0B.js";
import "./isEqual.Bk3xqtBB.js";
import { u as W } from "./useId.7P31viIO.js";
import { a as v } from "./index.CfQlFjZU.js";
import { M as w } from "./MoreMenuList.DU50Syfo.js";
import { c as L } from "./index.CfM2L_w0.js";
const _ = "creator_menuWrapper_jisGn", g = { menuWrapper: _ };
function y({
  buttonClassName: n,
  dropdownClassName: m,
  label: a,
  items: i,
  prefixIcon: l,
  suffixIcon: p,
  alwaysShowIcon: o,
  wrapperClassName: u
}) {
  const [c, e] = I(!1), f = W(), M = d("md"), r = d("xs"), C = b(() => {
    e((s) => !s);
  }, []), k = z(() => {
    e(!1);
  }), S = i.map((s) => ({
    ...s,
    onClick: (x) => {
      s.onClick && (s.onClick(x), e(!1));
    }
  }));
  return {
    buttonClassName: n,
    buttonSize: r ? "2xsmall" : "small",
    dropdownClassName: m,
    handleButtonClick: C,
    items: S,
    label: a,
    menuCollapsed: M || !!o,
    menuId: f,
    menuOpen: c,
    prefixIcon: r ? /* @__PURE__ */ t(B, {}) : l,
    ref: k,
    setMenuOpen: e,
    suffixIcon: p,
    wrapperClassName: L(g.menuWrapper, u)
  };
}
function A({
  buttonClassName: n,
  buttonSize: m,
  dropdownClassName: a,
  handleButtonClick: i,
  items: l,
  label: p,
  menuCollapsed: o,
  menuId: u,
  menuOpen: c,
  prefixIcon: e,
  ref: f,
  suffixIcon: M,
  wrapperClassName: r
}) {
  return /* @__PURE__ */ N("div", { ref: f, className: r, children: [
    /* @__PURE__ */ t(
      j,
      {
        value: o,
        then: /* @__PURE__ */ t(
          h,
          {
            className: n,
            label: p,
            prefixIcon: e,
            suffixIcon: M,
            onClick: i,
            semantic: O.SECONDARY,
            size: m
          }
        )
      }
    ),
    /* @__PURE__ */ t(
      w,
      {
        open: c,
        collapsed: o,
        listClassName: a,
        menuId: u,
        items: l
      }
    )
  ] });
}
const U = v(A, y);
export {
  U as M
};
