import { defineComponent as k, computed as d, ref as I, resolveComponent as l, createBlock as i, openBlock as m, withCtx as c, createElementVNode as a, createVNode as r, createElementBlock as L, Fragment as M, renderList as S, renderSlot as g, toDisplayString as x } from "vue";
import { useI18n as B } from "@feedmepos/mf-common";
const E = { class: "w-full flex items-center justify-between" }, N = { class: "p-4" }, P = { class: "flex-1 overflow-y-auto min-h-0" }, K = /* @__PURE__ */ k({
  __name: "MenuSelector",
  props: {
    modelValue: {},
    items: {},
    placeholder: { default: "" },
    searchPlaceholder: { default: "" },
    title: { default: "" },
    customLabel: {}
  },
  emits: ["update:modelValue"],
  setup(p, { emit: f }) {
    const t = p, _ = f, { t: $ } = B(), u = d(() => {
      const e = t.items.find((o) => o.value === t.modelValue);
      return e ? e.label : t.placeholder;
    }), h = d(() => t.items.filter(
      (e) => e.label.toLowerCase().includes(s.value.toLowerCase())
    )), s = I("");
    function v(e) {
      _("update:modelValue", e);
    }
    return (e, o) => {
      const b = l("FmIcon"), F = l("FmChip"), C = l("FmSearch"), V = l("FmMenuItem"), w = l("FmMenu");
      return m(), i(w, { width: 220 }, {
        "menu-button": c(() => [
          r(F, {
            label: u.value,
            class: "w-full fm-typo-en-body-md-600 text-fm-color-neutral-gray-400"
          }, {
            default: c(() => [
              a("div", E, [
                a("p", null, x(e.customLabel || e.title || u.value), 1),
                r(b, {
                  name: "expand_more",
                  size: "sm"
                }),
                g(e.$slots, "append")
              ])
            ]),
            _: 3
          }, 8, ["label"])
        ]),
        default: c(() => [
          a("div", N, [
            r(C, {
              autofocus: "",
              modelValue: s.value,
              "onUpdate:modelValue": o[0] || (o[0] = (n) => s.value = n),
              placeholder: e.searchPlaceholder
            }, null, 8, ["modelValue", "placeholder"])
          ]),
          a("div", P, [
            (m(!0), L(M, null, S(h.value, (n, y) => (m(), i(V, {
              key: y,
              label: n.label,
              onClick: (j) => v(n.value)
            }, null, 8, ["label", "onClick"]))), 128))
          ])
        ]),
        _: 3
      });
    };
  }
});
export {
  K as _
};
