import { a3 as $, bW as w, w as C, a4 as b, X as p, V as B, ac as D, bX as M, bY as v, a5 as V, bZ as E, U as k, H as a, b_ as I, ao as P, b$ as R, ad as i, I as y, ae as l, af as d, am as r, c0 as W, ag as F, ah as j, aj as H, c1 as N, as as _, c2 as z } from "./56c67d3b.js";
import S, { useContext as s } from "react";
import "react-dom";
const T = $(z)`
  width: 100%;
  
  .ant-btn-group {
    width: 100%;
   
  }
`, U = $.div`
  width: calc(100%);
  ${(t) => `margin: ${t.$buttonStyle.margin};`}
  margin-right: 0;
  .ant-btn span {
    ${(t) => t.$buttonStyle.textDecoration !== void 0 ? `text-decoration: ${t.$buttonStyle.textDecoration};` : ""}
    ${(t) => t.$buttonStyle.fontFamily !== void 0 ? `font-family: ${t.$buttonStyle.fontFamily};` : ""}
  }
  
  .ant-btn {
    ${(t) => w(t.$buttonStyle)}
    margin: 0 !important;
    height: 100%;
    &.ant-btn-default {
      margin: 0 !important;

      ${(t) => `border-radius: ${t.$buttonStyle.radius} 0 0 ${t.$buttonStyle.radius};`}
      ${(t) => `text-transform: ${t.$buttonStyle.textTransform};`}
      ${(t) => `font-weight: ${t.$buttonStyle.textWeight};`}
    }
    ${(t) => `background: ${t.$buttonStyle.background};`}
    ${(t) => `color: ${t.$buttonStyle.text};`}
    ${(t) => `padding: ${t.$buttonStyle.padding};`}
    ${(t) => `font-size: ${t.$buttonStyle.textSize};`}
    ${(t) => `font-style: ${t.$buttonStyle.fontStyle};`}

    width: 100%;
    line-height:${(t) => t.$buttonStyle.lineHeight}; 
  }
  
`, X = $.div`
  // width: 32px;
  ${(t) => `margin: ${t.$buttonStyle.margin};`}
  margin-left: -1px;
  .ant-btn {
    ${(t) => w(t.$buttonStyle)}
    margin: 0 !important;
    height: 100%;
    &.ant-btn-default {
      margin: 0 !important;
      ${(t) => `border-radius: 0 ${t.$buttonStyle.radius} ${t.$buttonStyle.radius} 0;`}
    }
    width: 100%;
  }
`, L = function() {
  const t = {
    text: C(p, b("menu")),
    onlyMenu: B,
    options: D,
    disabled: M,
    onEvent: v,
    style: V(E, "style")
  };
  return new k(t, (e) => {
    var g;
    const f = e.options.findIndex((n) => {
      var o;
      return (o = n.prefixIcon) == null ? void 0 : o.props.value;
    }) > -1, c = e.options.filter((n) => !n.hidden).map((n, o) => ({
      title: n.label,
      label: n.label,
      style: {
        padding: e.style.padding
      },
      key: n.label + " - " + o,
      disabled: n.disabled,
      icon: f && /* @__PURE__ */ a("span", {
        children: n.prefixIcon
      }),
      index: o
    })), m = /* @__PURE__ */ a(_, {
      items: c,
      onClick: ({
        key: n
      }) => {
        var h;
        const o = c.find((u) => u.key === n), x = e.options.findIndex((u) => u.label === (o == null ? void 0 : o.label));
        o && ((h = e.options[x]) == null || h.onEvent("click"));
      }
    });
    return /* @__PURE__ */ a(I, {
      $disabled: e.disabled,
      children: e.onlyMenu ? /* @__PURE__ */ a(P, {
        disabled: e.disabled,
        dropdownRender: () => m,
        children: /* @__PURE__ */ a(R, {
          $buttonStyle: e.style,
          disabled: e.disabled,
          children: e.text || " "
          /* Avoid button disappearing */
        })
      }) : /* @__PURE__ */ a(T, {
        disabled: e.disabled,
        dropdownRender: () => m,
        onClick: () => e.onEvent("click"),
        buttonsRender: ([n, o]) => [/* @__PURE__ */ a(U, {
          $buttonStyle: e.style,
          children: S.cloneElement(n, {
            disabled: e.disabled
          })
        }), /* @__PURE__ */ a(X, {
          $buttonStyle: e.style,
          children: S.cloneElement(o, {
            disabled: e.disabled
          })
        })],
        children: !e.text || ((g = e.text) == null ? void 0 : g.length) === 0 ? " " : e.text
      })
    });
  }).setPropertyViewFn((e) => /* @__PURE__ */ i(y, {
    children: [/* @__PURE__ */ a(l, {
      name: d.basic,
      children: e.options.propertyView({})
    }), (s(r).editorModeStatus === "logic" || s(r).editorModeStatus === "both") && /* @__PURE__ */ a(y, {
      children: /* @__PURE__ */ i(l, {
        name: d.interaction,
        children: [!e.onlyMenu.getView() && e.onEvent.getPropertyView(), W(e), F(e)]
      })
    }), (s(r).editorModeStatus === "layout" || s(r).editorModeStatus === "both") && /* @__PURE__ */ i(y, {
      children: [/* @__PURE__ */ i(l, {
        name: d.layout,
        children: [e.text.propertyView({
          label: b("label")
        }), e.onlyMenu.propertyView({
          label: b("dropdown.onlyMenu")
        })]
      }), /* @__PURE__ */ a(l, {
        name: d.style,
        children: e.style.getPropertyView()
      })]
    })]
  })).build();
}(), q = j(L, [new H("text", b("dropdown.textDesc")), ...N]);
export {
  q as DropdownComp
};
