import { defineComponent, useSlots, computed, resolveComponent, createBlock, openBlock, mergeProps, toHandlers, unref, createSlots, withCtx, createElementBlock, Fragment, renderList, renderSlot, normalizeProps, guardReactiveProps } from 'vue';
import '../../../../utils/index.mjs';
import { isString } from '../../../../utils/src/is.mjs';
import { selectOptionsEmits, selectOptionsProps } from './selectOptions.mjs';
import { getGmEvent } from '../../../../utils/src/elementPlus/event.mjs';

var _sfc_main = /* @__PURE__ */ defineComponent({
  ...{
    name: "GmSelectOptions"
  },
  __name: "SelectOptions",
  props: selectOptionsProps,
  emits: selectOptionsEmits,
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emit = __emit;
    const events = getGmEvent(selectOptionsEmits, emit);
    const slots = useSlots();
    const labelOptions = computed(() => {
      return props.options.map((it, i) => {
        const res = {
          label: it[props.optionLabel],
          value: it[props.optionValue]
        };
        if (props.labelKey === true) {
          res.label = `${it.id}. ${res.label}`;
        } else if (props.labelKey === "index") {
          res.label = `${i + 1}. ${res.label}`;
        } else if (isString(props.labelKey) && Object.prototype.hasOwnProperty.call(it, props.labelKey)) {
          res.label = `${it[props.labelKey]}. ${res.label}`;
        }
        return res;
      });
    });
    return (_ctx, _cache) => {
      const _component_gm_option = resolveComponent("gm-option");
      const _component_gm_select = resolveComponent("gm-select");
      return openBlock(), createBlock(
        _component_gm_select,
        mergeProps(props, toHandlers(unref(events))),
        createSlots({
          default: withCtx(() => [
            (openBlock(true), createElementBlock(
              Fragment,
              null,
              renderList(labelOptions.value, (item, index) => {
                return openBlock(), createBlock(_component_gm_option, {
                  key: index,
                  label: item.label,
                  value: item.value
                }, null, 8, ["label", "value"]);
              }),
              128
              /* KEYED_FRAGMENT */
            ))
          ]),
          _: 2
          /* DYNAMIC */
        }, [
          unref(slots).header ? {
            name: "header",
            fn: withCtx(() => [
              renderSlot(_ctx.$slots, "header")
            ]),
            key: "0"
          } : void 0,
          unref(slots).footer ? {
            name: "footer",
            fn: withCtx(() => [
              renderSlot(_ctx.$slots, "footer")
            ]),
            key: "1"
          } : void 0,
          unref(slots).prefix ? {
            name: "prefix",
            fn: withCtx(() => [
              renderSlot(_ctx.$slots, "prefix")
            ]),
            key: "2"
          } : void 0,
          unref(slots).empty ? {
            name: "empty",
            fn: withCtx(() => [
              renderSlot(_ctx.$slots, "empty")
            ]),
            key: "3"
          } : void 0,
          unref(slots).tag ? {
            name: "tag",
            fn: withCtx(() => [
              renderSlot(_ctx.$slots, "tag")
            ]),
            key: "4"
          } : void 0,
          unref(slots).loading ? {
            name: "loading",
            fn: withCtx(() => [
              renderSlot(_ctx.$slots, "loading")
            ]),
            key: "5"
          } : void 0,
          unref(slots).label ? {
            name: "label",
            fn: withCtx((slotValue) => [
              renderSlot(_ctx.$slots, "label", normalizeProps(guardReactiveProps(slotValue)))
            ]),
            key: "6"
          } : void 0
        ]),
        1040
        /* FULL_PROPS, DYNAMIC_SLOTS */
      );
    };
  }
});

export { _sfc_main as default };
//# sourceMappingURL=SelectOptions.vue2.mjs.map
