import { t } from './client-only-CAHE6F0E.mjs';
import { g } from './SvgIcon-C2791tkm.mjs';
import { useSSRContext, ref, watch, resolveComponent, mergeProps, withCtx, createVNode, openBlock, createBlock, toDisplayString, createCommentVNode, unref, isRef, Transition, Fragment, renderList } from 'vue';
import { ssrRenderComponent, ssrInterpolate } from 'vue/server-renderer';
import { Listbox, ListboxButton, ListboxOptions, ListboxOption } from '@headlessui/vue';
import { j as Bv } from './server.mjs';

const I = { __name: "BaseSelectInput", __ssrInlineRender: true, props: { items: { type: Array, required: false, default: () => [] }, name: { type: String, required: true }, label: { type: String, required: false }, placeholder: { type: String, required: false }, value: { type: Object, required: false }, rounded: { type: Boolean, required: false } }, emits: ["update:value"], setup(a2, { expose: I2, emit: h2 }) {
  const j = a2, w = Bv(j.name), $ = ref(null);
  watch(() => $.value, (e2, l2) => {
    e2 ? (w.setValue(e2), B("update:value", e2)) : e2 != l2 && (w.setValue(null), B("update:value", undefined));
  }, { deep: true, immediate: true }), watch(() => j.value, (e2, l2) => {
    e2 ? ($.value = e2, w.setValue(e2)) : e2 != l2 && ($.value = null, w.setValue(null));
  }, { deep: true, immediate: true });
  I2({ emptyInput: () => {
    $.value = null;
  } });
  const B = h2;
  return (t2, u2, q2, I3) => {
    const h3 = resolveComponent("VeeField"), j2 = t, w2 = g, B2 = resolveComponent("VeeErrorMessage");
    u2(ssrRenderComponent(h3, mergeProps({ name: a2.name }, I3), { default: withCtx(({ field: e2, meta: l2 }, t3, u3, n2) => {
      if (!t3) return [createVNode("div", { class: "input-wrapper" }, [a2.label ? (openBlock(), createBlock("label", { key: 0, for: "label" }, toDisplayString(a2.label), 1)) : createCommentVNode("", true), createVNode("div", { class: "relative" }, [createVNode(j2, null, { default: withCtx(() => [createVNode(unref(Listbox), { modelValue: unref($), "onUpdate:modelValue": (e3) => isRef($) ? $.value = e3 : null }, { default: withCtx(() => [createVNode(unref(ListboxButton), { class: a2.rounded ? "!rounded-full !px-6" : "" }, { default: withCtx(() => {
        var e3, l3, t4, u4;
        return [a2.placeholder && !(null == (e3 = unref($)) ? undefined : e3.name) ? (openBlock(), createBlock("span", { key: 0, class: "text-desc" }, toDisplayString(a2.placeholder), 1)) : createCommentVNode("", true), (null == (l3 = unref($)) ? undefined : l3.name) ? (openBlock(), createBlock("span", { key: 1 }, toDisplayString(null == (t4 = unref($)) ? undefined : t4.name), 1)) : createCommentVNode("", true), createVNode("span", { class: "absolute top-[48%] -translate-y-1/2 end-5" }, [createVNode(w2, { name: "chevron-down" })]), unref($) && (null == (u4 = unref($)) ? undefined : u4.id) ? (openBlock(), createBlock("button", { key: 2, onClick: (e4) => {
          e4.stopPropagation(), $.value = null;
        }, class: "absolute top-1/2 -translate-y-1/2 end-10" }, [createVNode(w2, { name: "close-2", class: "text-desc scale-[0.6]" })], 8, ["onClick"])) : createCommentVNode("", true)];
      }), _: 1 }, 8, ["class"]), createVNode(Transition, { name: "fade" }, { default: withCtx(() => [createVNode(unref(ListboxOptions), null, { default: withCtx(() => [(openBlock(true), createBlock(Fragment, null, renderList(a2.items, (e3) => (openBlock(), createBlock(unref(ListboxOption), { as: "template", key: e3.id, value: e3 }, { default: withCtx(({ active: l3, selected: a3 }) => [createVNode("li", { class: [l3 && "bg-primary bg-opacity-20 rounded-lg", a3 && "bg-primary bg-opacity-20 rounded-lg"] }, toDisplayString(null == e3 ? undefined : e3.name), 3)]), _: 2 }, 1032, ["value"]))), 128))]), _: 1 })]), _: 1 })]), _: 1 }, 8, ["modelValue", "onUpdate:modelValue"])]), _: 1 })])]), createVNode(B2, { class: "text-sm text-red-500", name: a2.name }, null, 8, ["name"])];
      t3(`<div class="input-wrapper"${n2}>`), a2.label ? t3(`<label for="label"${n2}>${ssrInterpolate(a2.label)}</label>`) : t3("<!---->"), t3(`<div class="relative"${n2}>`), t3(ssrRenderComponent(j2, null, {}, u3, n2)), t3("</div></div>"), t3(ssrRenderComponent(B2, { class: "text-sm text-red-500", name: a2.name }, null, u3, n2));
    }), _: 1 }, q2));
  };
} }, h = I.setup;
I.setup = (e2, l2) => {
  const t2 = useSSRContext();
  return (t2.modules || (t2.modules = /* @__PURE__ */ new Set())).add("components/Inputs/BaseSelectInput.vue"), h ? h(e2, l2) : undefined;
};

export { I };
//# sourceMappingURL=BaseSelectInput-DtQVsXjS.mjs.map
