import { defineComponent as h, ref as y, computed as v, createElementBlock as s, openBlock as l, createCommentVNode as n, createVNode as k, Fragment as I, renderList as V, normalizeClass as g, createTextVNode as _, createBlock as C, toDisplayString as d, unref as S } from "vue";
import { u as b, a as w, b as L, c as x, _ as B } from "./index-D1PfnS4S.js";
const M = { class: "select-list" }, N = {
  key: 0,
  class: "search-wrapper"
}, U = ["onClick"], A = {
  key: 2,
  class: "empty-message"
}, $ = /* @__PURE__ */ h({
  __name: "List",
  props: {
    showSearchInput: { type: Boolean, default: !1 },
    placeholderSearchInput: { default: "Поиск..." },
    emptyMessage: { default: "Совпадений не найдено" },
    selectedValue: {},
    options: {}
  },
  emits: ["select", "close"],
  setup(e, { emit: m }) {
    const u = m, i = e, [p] = b(), a = y(""), r = v(() => {
      if (!a.value) return i.options;
      const o = a.value.toLowerCase();
      return i.options.filter((c) => c.label.toLowerCase().includes(o));
    }), f = (o) => {
      u("select", o), u("close");
    };
    return (o, c) => (l(), s("div", M, [
      e.showSearchInput ? (l(), s("div", N, [
        k(w, {
          modelValue: a.value,
          "onUpdate:modelValue": c[0] || (c[0] = (t) => a.value = t),
          placeholder: e.placeholderSearchInput
        }, null, 8, ["modelValue", "placeholder"])
      ])) : n("", !0),
      r.value.length ? (l(), s("ul", {
        key: 1,
        ref_key: "list",
        ref: p,
        class: "options-list"
      }, [
        (l(!0), s(I, null, V(r.value, (t) => (l(), s("li", {
          key: t.value,
          class: g(["option-item", { "--selected": e.selectedValue === t.label }]),
          onClick: (q) => f(t)
        }, [
          _(d(t.label) + " ", 1),
          e.selectedValue === t.label ? (l(), C(L, {
            key: 0,
            name: S(x).Success
          }, null, 8, ["name"])) : n("", !0)
        ], 10, U))), 128))
      ], 512)) : n("", !0),
      e.emptyMessage && !r.value.length ? (l(), s("div", A, d(e.emptyMessage), 1)) : n("", !0)
    ]));
  }
}), E = /* @__PURE__ */ B($, [["__scopeId", "data-v-41a46d85"]]);
export {
  E as default
};
