"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const useFormCommonProps = require("../../form/src/hooks/use-form-common-props.js");
const upload = require("./upload.js");
const constants = require("./constants.js");
const uploadList2 = require("./upload-list2.js");
const uploadContent2 = require("./upload-content2.js");
const useHandlers = require("./use-handlers.js");
const Vue = require("vue");
var upload_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ Vue.defineComponent({
  name: "ElUpload",
  __name: "upload",
  props: upload.uploadProps,
  setup(__props, { expose: __expose }) {
    const props = __props;
    const disabled = useFormCommonProps.useFormDisabled();
    const uploadRef = Vue.shallowRef();
    const { abort, submit, clearFiles, uploadFiles, handleStart, handleError, handleRemove, handleSuccess, handleProgress, revokeFileObjectURL } = useHandlers.useHandlers(props, uploadRef);
    const isPictureCard = Vue.computed(() => props.listType === "picture-card");
    const uploadContentProps = Vue.computed(() => ({
      ...props,
      fileList: uploadFiles.value,
      onStart: handleStart,
      onProgress: handleProgress,
      onSuccess: handleSuccess,
      onError: handleError,
      onRemove: handleRemove
    }));
    Vue.onBeforeUnmount(() => {
      uploadFiles.value.forEach(revokeFileObjectURL);
    });
    Vue.provide(constants.uploadContextKey, { accept: Vue.toRef(props, "accept") });
    __expose({
      abort,
      submit,
      clearFiles,
      handleStart,
      handleRemove
    });
    return (_ctx, _cache) => {
      return Vue.openBlock(), Vue.createElementBlock("div", null, [
        isPictureCard.value && __props.showFileList ? (Vue.openBlock(), Vue.createBlock(uploadList2.default, {
          key: 0,
          disabled: Vue.unref(disabled),
          "list-type": __props.listType,
          files: Vue.unref(uploadFiles),
          crossorigin: __props.crossorigin,
          "handle-preview": __props.onPreview,
          onRemove: Vue.unref(handleRemove)
        }, Vue.createSlots({
          append: Vue.withCtx(() => [Vue.createVNode(uploadContent2.default, Vue.mergeProps({
            ref_key: "uploadRef",
            ref: uploadRef
          }, uploadContentProps.value), {
            default: Vue.withCtx(() => [_ctx.$slots.trigger ? Vue.renderSlot(_ctx.$slots, "trigger", { key: 0 }) : Vue.createCommentVNode("v-if", true), !_ctx.$slots.trigger && _ctx.$slots.default ? Vue.renderSlot(_ctx.$slots, "default", { key: 1 }) : Vue.createCommentVNode("v-if", true)]),
            _: 3
          }, 16)]),
          _: 2
        }, [_ctx.$slots.file ? {
          name: "default",
          fn: Vue.withCtx(({ file, index }) => [Vue.renderSlot(_ctx.$slots, "file", {
            file,
            index
          })]),
          key: "0"
        } : void 0]), 1032, [
          "disabled",
          "list-type",
          "files",
          "crossorigin",
          "handle-preview",
          "onRemove"
        ])) : Vue.createCommentVNode("v-if", true),
        !isPictureCard.value || isPictureCard.value && !__props.showFileList ? (Vue.openBlock(), Vue.createBlock(uploadContent2.default, Vue.mergeProps({
          key: 1,
          ref_key: "uploadRef",
          ref: uploadRef
        }, uploadContentProps.value), {
          default: Vue.withCtx(() => [_ctx.$slots.trigger ? Vue.renderSlot(_ctx.$slots, "trigger", { key: 0 }) : Vue.createCommentVNode("v-if", true), !_ctx.$slots.trigger && _ctx.$slots.default ? Vue.renderSlot(_ctx.$slots, "default", { key: 1 }) : Vue.createCommentVNode("v-if", true)]),
          _: 3
        }, 16)) : Vue.createCommentVNode("v-if", true),
        _ctx.$slots.trigger ? Vue.renderSlot(_ctx.$slots, "default", { key: 2 }) : Vue.createCommentVNode("v-if", true),
        Vue.renderSlot(_ctx.$slots, "tip"),
        !isPictureCard.value && __props.showFileList ? (Vue.openBlock(), Vue.createBlock(uploadList2.default, {
          key: 3,
          disabled: Vue.unref(disabled),
          "list-type": __props.listType,
          files: Vue.unref(uploadFiles),
          crossorigin: __props.crossorigin,
          "handle-preview": __props.onPreview,
          onRemove: Vue.unref(handleRemove)
        }, Vue.createSlots({ _: 2 }, [_ctx.$slots.file ? {
          name: "default",
          fn: Vue.withCtx(({ file, index }) => [Vue.renderSlot(_ctx.$slots, "file", {
            file,
            index
          })]),
          key: "0"
        } : void 0]), 1032, [
          "disabled",
          "list-type",
          "files",
          "crossorigin",
          "handle-preview",
          "onRemove"
        ])) : Vue.createCommentVNode("v-if", true)
      ]);
    };
  }
});
exports.default = upload_vue_vue_type_script_setup_true_lang_default;
