import { defineComponent, ref, watch, computed } from 'vue';
import { NOOP } from '@vue/shared';
import { ElUpload } from '../../upload/index.mjs';

var script = defineComponent({
  name: "ElUploadV2",
  components: {
    ElUpload
  },
  props: {
    value: {
      type: Array,
      default: () => {
        return [];
      }
    },
    action: {
      type: String,
      default: "/v2/file/file/batchUploadImg"
    },
    headers: {
      type: Object,
      default: () => ({})
    },
    method: {
      type: String,
      default: "post"
    },
    data: {
      type: Object,
      default: () => ({
        token: localStorage.getItem("token")
      })
    },
    multiple: {
      type: Boolean,
      default: false
    },
    name: {
      type: String,
      default: "file"
    },
    drag: {
      type: Boolean,
      default: false
    },
    withCredentials: Boolean,
    showFileList: {
      type: Boolean,
      default: true
    },
    accept: {
      type: String,
      default: ""
    },
    type: {
      type: String,
      default: "select"
    },
    responseHandle: {
      type: Function,
      default: (file) => file.data.list[0].raw
    },
    autoUpload: {
      type: Boolean,
      default: true
    },
    listType: {
      type: String,
      default: "picture-card"
    },
    httpRequest: {
      type: Function
    },
    disabled: Boolean,
    limit: {
      type: Number,
      default: null
    },
    onExceed: {
      type: Function,
      default: () => NOOP
    }
  },
  emits: ["update:value"],
  setup(props, { emit }) {
    const fileList = ref([]);
    watch(() => props.value, (value) => {
      fileList.value = value;
    });
    const fileUrlList = computed(() => props.value.map((e) => ({
      url: e
    })));
    const onSuccess = (res) => {
      emit("update:value", props.value.concat([res]));
    };
    const onRemove = (file, fileList2) => {
      emit("update:value", fileList2.map((e) => e.url));
    };
    const onChange = (file, fileList2) => {
      const list = fileList2.map((e) => {
        if (e.response) {
          if (props.responseHandle) {
            return props.responseHandle(e.response);
          }
          return e.response;
        } else {
          return e.url;
        }
      });
      emit("update:value", list);
    };
    return {
      uploadProps: props,
      fileUrlList,
      onSuccess,
      onRemove,
      onChange
    };
  }
});

export { script as default };
//# sourceMappingURL=index.vue_vue_type_script_lang.mjs.map
