'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
require('../../../../../../utils/index.js');
require('../../../../base/selectV2/index.js');
var useWatchModelChange = require('../../composables/useWatchModelChange.js');
var searchFormSelectV2 = require('./searchFormSelectV2.js');
var event = require('../../../../../../utils/src/elementPlus/event.js');
var selectV2 = require('../../../../base/selectV2/selectV2.js');
var is = require('../../../../../../utils/src/is.js');

var _sfc_main = /* @__PURE__ */ vue.defineComponent({
  ...{
    name: searchFormSelectV2.SearchFormSelectV2Name
  },
  __name: "SearchFormSelectV2",
  props: /* @__PURE__ */ vue.mergeModels(searchFormSelectV2.searchFormSelectV2Props, {
    "modelValue": {},
    "modelModifiers": {}
  }),
  emits: /* @__PURE__ */ vue.mergeModels(searchFormSelectV2.searchFormSelectV2Emits, ["update:modelValue"]),
  setup(__props, { emit: __emit }) {
    const props = __props;
    const modelValue = vue.useModel(__props, "modelValue");
    const emit = __emit;
    const selectV2Events = event.getGmEvent(selectV2.selectV2Emits, emit);
    useWatchModelChange.useWatchModelChange(modelValue, { prop: props.prop, noDefaultSync: props.noDefaultSync });
    const optionsList = vue.computed(() => {
      return props.options.map((v, i) => {
        const res = {
          ...v,
          label: v[props.optionLabel],
          value: v[props.optionValue]
        };
        if (props.labelKey === true) {
          res.label = `${v.id}. ${res.label}`;
        } else if (props.labelKey === "index") {
          res.label = `${i + 1}. ${res.label}`;
        } else if (is.isString(props.labelKey) && Object.prototype.hasOwnProperty.call(v, props.labelKey)) {
          res.label = `${v[props.labelKey]}. ${res.label}`;
        }
        return res;
      });
    });
    return (_ctx, _cache) => {
      const _component_gm_select_v2 = vue.resolveComponent("gm-select-v2");
      const _component_gm_form_item = vue.resolveComponent("gm-form-item");
      return vue.openBlock(), vue.createBlock(_component_gm_form_item, { prop: _ctx.prop }, {
        default: vue.withCtx(() => [
          vue.createVNode(_component_gm_select_v2, vue.mergeProps({
            modelValue: modelValue.value,
            "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => modelValue.value = $event),
            placeholder: _ctx.label,
            multiple: _ctx.multiple,
            filterable: "",
            clearable: "",
            "collapse-tags": "",
            "collapse-tags-tooltip": "",
            disabled: _ctx.disabled,
            options: optionsList.value,
            class: "gm-w-full"
          }, vue.toHandlers(vue.unref(selectV2Events))), null, 16, ["modelValue", "placeholder", "multiple", "disabled", "options"])
        ]),
        _: 1
        /* STABLE */
      }, 8, ["prop"]);
    };
  }
});

exports.default = _sfc_main;
//# sourceMappingURL=SearchFormSelectV2.vue2.js.map
