"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const index = require("../../../hooks/use-locale/index.js");
const index$1 = require("../../../hooks/use-namespace/index.js");
const index$2 = require("../../icon/index.js");
const useFormCommonProps = require("../../form/src/hooks/use-form-common-props.js");
const index$4 = require("../../progress/index.js");
const uploadList = require("./upload-list.js");
const index$3 = require("../../../../../@element-plus/icons-vue/dist/index.js");
const vue = require("vue");
const _hoisted_1 = [
  "tabindex",
  "aria-disabled",
  "onKeydown"
];
const _hoisted_2 = ["src", "crossorigin"];
const _hoisted_3 = ["onClick"];
const _hoisted_4 = ["title"];
const _hoisted_5 = ["onClick"];
const _hoisted_6 = ["onClick"];
var upload_list_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ vue.defineComponent({
  name: "ElUploadList",
  __name: "upload-list",
  props: uploadList.uploadListProps,
  emits: uploadList.uploadListEmits,
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emit = __emit;
    const { t } = index.useLocale();
    const nsUpload = index$1.useNamespace("upload");
    const nsIcon = index$1.useNamespace("icon");
    const nsList = index$1.useNamespace("list");
    const disabled = useFormCommonProps.useFormDisabled();
    const focusing = vue.ref(false);
    const containerKls = vue.computed(() => [
      nsUpload.b("list"),
      nsUpload.bm("list", props.listType),
      nsUpload.is("disabled", disabled.value)
    ]);
    const handleRemove = (file) => {
      emit("remove", file);
    };
    return (_ctx, _cache) => {
      return vue.openBlock(), vue.createBlock(vue.TransitionGroup, {
        tag: "ul",
        class: vue.normalizeClass(containerKls.value),
        name: vue.unref(nsList).b()
      }, {
        default: vue.withCtx(() => [(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.files, (file, index2) => {
          return vue.openBlock(), vue.createElementBlock("li", {
            key: file.uid || file.name,
            class: vue.normalizeClass([
              vue.unref(nsUpload).be("list", "item"),
              vue.unref(nsUpload).is(file.status),
              { focusing: focusing.value }
            ]),
            tabindex: vue.unref(disabled) ? void 0 : 0,
            "aria-disabled": vue.unref(disabled),
            role: "button",
            onKeydown: vue.withKeys(($event) => !vue.unref(disabled) && handleRemove(file), ["delete"]),
            onFocus: _cache[0] || (_cache[0] = ($event) => focusing.value = true),
            onBlur: _cache[1] || (_cache[1] = ($event) => focusing.value = false),
            onClick: _cache[2] || (_cache[2] = ($event) => focusing.value = false)
          }, [vue.renderSlot(_ctx.$slots, "default", {
            file,
            index: index2
          }, () => [
            __props.listType === "picture" || file.status !== "uploading" && __props.listType === "picture-card" ? (vue.openBlock(), vue.createElementBlock("img", {
              key: 0,
              class: vue.normalizeClass(vue.unref(nsUpload).be("list", "item-thumbnail")),
              src: file.url,
              crossorigin: __props.crossorigin,
              alt: ""
            }, null, 10, _hoisted_2)) : vue.createCommentVNode("v-if", true),
            file.status === "uploading" || __props.listType !== "picture-card" ? (vue.openBlock(), vue.createElementBlock("div", {
              key: 1,
              class: vue.normalizeClass(vue.unref(nsUpload).be("list", "item-info"))
            }, [vue.createElementVNode("a", {
              class: vue.normalizeClass(vue.unref(nsUpload).be("list", "item-name")),
              onClick: vue.withModifiers(($event) => __props.handlePreview(file), ["prevent"])
            }, [vue.createVNode(vue.unref(index$2.ElIcon), { class: vue.normalizeClass(vue.unref(nsIcon).m("document")) }, {
              default: vue.withCtx(() => [vue.createVNode(vue.unref(index$3.Document))]),
              _: 1
            }, 8, ["class"]), vue.createElementVNode("span", {
              class: vue.normalizeClass(vue.unref(nsUpload).be("list", "item-file-name")),
              title: file.name
            }, vue.toDisplayString(file.name), 11, _hoisted_4)], 10, _hoisted_3), file.status === "uploading" ? (vue.openBlock(), vue.createBlock(vue.unref(index$4.ElProgress), {
              key: 0,
              type: __props.listType === "picture-card" ? "circle" : "line",
              "stroke-width": __props.listType === "picture-card" ? 6 : 2,
              percentage: Number(file.percentage),
              style: vue.normalizeStyle(__props.listType === "picture-card" ? "" : "margin-top: 0.5rem")
            }, null, 8, [
              "type",
              "stroke-width",
              "percentage",
              "style"
            ])) : vue.createCommentVNode("v-if", true)], 2)) : vue.createCommentVNode("v-if", true),
            vue.createElementVNode("label", { class: vue.normalizeClass(vue.unref(nsUpload).be("list", "item-status-label")) }, [__props.listType === "text" ? (vue.openBlock(), vue.createBlock(vue.unref(index$2.ElIcon), {
              key: 0,
              class: vue.normalizeClass([vue.unref(nsIcon).m("upload-success"), vue.unref(nsIcon).m("circle-check")])
            }, {
              default: vue.withCtx(() => [vue.createVNode(vue.unref(index$3.CircleCheck))]),
              _: 1
            }, 8, ["class"])) : ["picture-card", "picture"].includes(__props.listType) ? (vue.openBlock(), vue.createBlock(vue.unref(index$2.ElIcon), {
              key: 1,
              class: vue.normalizeClass([vue.unref(nsIcon).m("upload-success"), vue.unref(nsIcon).m("check")])
            }, {
              default: vue.withCtx(() => [vue.createVNode(vue.unref(index$3.Check))]),
              _: 1
            }, 8, ["class"])) : vue.createCommentVNode("v-if", true)], 2),
            !vue.unref(disabled) ? (vue.openBlock(), vue.createBlock(vue.unref(index$2.ElIcon), {
              key: 2,
              class: vue.normalizeClass(vue.unref(nsIcon).m("close")),
              "aria-label": vue.unref(t)("el.upload.delete"),
              role: "button",
              tabindex: "0",
              onClick: ($event) => handleRemove(file),
              onKeydown: vue.withKeys(vue.withModifiers(($event) => handleRemove(file), ["prevent"]), ["enter", "space"])
            }, {
              default: vue.withCtx(() => [vue.createVNode(vue.unref(index$3.Close))]),
              _: 1
            }, 8, [
              "class",
              "aria-label",
              "onClick",
              "onKeydown"
            ])) : vue.createCommentVNode("v-if", true),
            !vue.unref(disabled) ? (vue.openBlock(), vue.createElementBlock("i", {
              key: 3,
              class: vue.normalizeClass(vue.unref(nsIcon).m("close-tip"))
            }, vue.toDisplayString(vue.unref(t)("el.upload.deleteTip")), 3)) : vue.createCommentVNode("v-if", true),
            __props.listType === "picture-card" ? (vue.openBlock(), vue.createElementBlock("span", {
              key: 4,
              class: vue.normalizeClass(vue.unref(nsUpload).be("list", "item-actions"))
            }, [vue.createElementVNode("span", {
              class: vue.normalizeClass(vue.unref(nsUpload).be("list", "item-preview")),
              onClick: ($event) => __props.handlePreview(file)
            }, [vue.createVNode(vue.unref(index$2.ElIcon), { class: vue.normalizeClass(vue.unref(nsIcon).m("zoom-in")) }, {
              default: vue.withCtx(() => [vue.createVNode(vue.unref(index$3.ZoomIn))]),
              _: 1
            }, 8, ["class"])], 10, _hoisted_5), !vue.unref(disabled) ? (vue.openBlock(), vue.createElementBlock("span", {
              key: 0,
              class: vue.normalizeClass(vue.unref(nsUpload).be("list", "item-delete")),
              onClick: ($event) => handleRemove(file)
            }, [vue.createVNode(vue.unref(index$2.ElIcon), { class: vue.normalizeClass(vue.unref(nsIcon).m("delete")) }, {
              default: vue.withCtx(() => [vue.createVNode(vue.unref(index$3.Delete))]),
              _: 1
            }, 8, ["class"])], 10, _hoisted_6)) : vue.createCommentVNode("v-if", true)], 2)) : vue.createCommentVNode("v-if", true)
          ])], 42, _hoisted_1);
        }), 128)), vue.renderSlot(_ctx.$slots, "append")]),
        _: 3
      }, 8, ["class", "name"]);
    };
  }
});
exports.default = upload_list_vue_vue_type_script_setup_true_lang_default;
