import { defineComponent, ref, openBlock, createElementBlock, Fragment, createElementVNode, normalizeClass, unref, renderList, withKeys, renderSlot, createCommentVNode, createVNode, withCtx, createTextVNode, toDisplayString, createBlock, withModifiers } from 'vue';
import { ElIcon } from '../../icon/index2.mjs';
import { Document, CircleCheck, Check, Close, Delete } from '@element-plus/icons-vue';
import '../../../hooks/index2.mjs';
import { uploadListProps, uploadListEmits } from './upload-list3.mjs';
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
import { useLocale } from '../../../hooks/use-locale/index2.mjs';
import { useNamespace } from '../../../hooks/use-namespace/index2.mjs';

const _hoisted_1 = ["onKeydown"];
const _hoisted_2 = ["src"];
const _hoisted_3 = ["onClick"];
const _hoisted_4 = ["onClick"];
const __default__ = {
  name: "ElUploadList"
};
const _sfc_main = /* @__PURE__ */ defineComponent({
  ...__default__,
  props: uploadListProps,
  emits: uploadListEmits,
  setup(__props, { emit }) {
    const props = __props;
    const { t } = useLocale();
    const nsUpload = useNamespace("upload");
    const nsIcon = useNamespace("icon");
    const focusing = ref(false);
    const handleClick = (file) => {
      props.handlePreview(file);
    };
    const handleRemove = (file) => {
      emit("remove", file);
    };
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock(Fragment, null, [
        createElementVNode("ul", {
          class: normalizeClass([
            unref(nsUpload).b("list"),
            unref(nsUpload).bm("list", _ctx.listType),
            { "is-disabled": _ctx.disabled },
            _ctx.customerClass
          ])
        }, [
          (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.files, (file) => {
            return openBlock(), createElementBlock("li", {
              key: file.uid || file.name,
              class: normalizeClass([
                unref(nsUpload).be("list", "item"),
                unref(nsUpload).is(file.status),
                { focusing: focusing.value }
              ]),
              tabindex: "0",
              onKeydown: withKeys(($event) => !_ctx.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)
            }, [
              renderSlot(_ctx.$slots, "default", { file }, () => [
                _ctx.listType === "picture" || file.status !== "uploading" && _ctx.listType === "picture-card" ? (openBlock(), createElementBlock("img", {
                  key: 0,
                  class: normalizeClass(unref(nsUpload).be("list", "item-thumbnail")),
                  src: file.url,
                  alt: ""
                }, null, 10, _hoisted_2)) : createCommentVNode("v-if", true),
                createElementVNode("a", {
                  class: normalizeClass(unref(nsUpload).be("list", "item-name")),
                  onClick: ($event) => handleClick(file)
                }, [
                  createVNode(unref(ElIcon), {
                    class: normalizeClass(unref(nsIcon).m("document"))
                  }, {
                    default: withCtx(() => [
                      createVNode(unref(Document))
                    ]),
                    _: 1
                  }, 8, ["class"]),
                  createTextVNode(" " + toDisplayString(file.name), 1)
                ], 10, _hoisted_3),
                _ctx.listType === "text" ? (openBlock(), createElementBlock("label", {
                  key: 1,
                  class: normalizeClass(unref(nsUpload).be("list", "item-status-label"))
                }, [
                  createVNode(unref(ElIcon), {
                    class: normalizeClass([unref(nsIcon).m("upload-success"), unref(nsIcon).m("circle-check")])
                  }, {
                    default: withCtx(() => [
                      createVNode(unref(CircleCheck))
                    ]),
                    _: 1
                  }, 8, ["class"]),
                  ["picture-card", "picture"].includes(_ctx.listType) ? (openBlock(), createBlock(unref(ElIcon), {
                    key: 0,
                    class: normalizeClass([unref(nsIcon).m("upload-success"), unref(nsIcon).m("check")])
                  }, {
                    default: withCtx(() => [
                      createVNode(unref(Check))
                    ]),
                    _: 1
                  }, 8, ["class"])) : createCommentVNode("v-if", true)
                ], 2)) : createCommentVNode("v-if", true),
                !_ctx.disabled ? (openBlock(), createBlock(unref(ElIcon), {
                  key: 2,
                  class: normalizeClass(unref(nsIcon).m("close")),
                  onClick: withModifiers(($event) => handleRemove(file), ["stop"])
                }, {
                  default: withCtx(() => [
                    createVNode(unref(Close))
                  ]),
                  _: 2
                }, 1032, ["class", "onClick"])) : createCommentVNode("v-if", true),
                createCommentVNode(" Due to close btn only appears when li gets focused disappears after li gets blurred, thus keyboard navigation can never reach close btn"),
                createCommentVNode(" This is a bug which needs to be fixed "),
                createCommentVNode(" TODO: Fix the incorrect navigation interaction "),
                !_ctx.disabled ? (openBlock(), createElementBlock("i", {
                  key: 3,
                  class: normalizeClass(unref(nsIcon).m("close-tip"))
                }, toDisplayString(unref(t)("el.upload.deleteTip")), 3)) : createCommentVNode("v-if", true),
                _ctx.listType === "picture-card" ? (openBlock(), createElementBlock("span", {
                  key: 4,
                  class: normalizeClass(unref(nsUpload).be("list", "item-actions"))
                }, [
                  createCommentVNode(` <label
            class="el-upload-list__item-replace"
            for='replace'
          >
            \u66FF\u6362
            <input
              name='replace'
              class="el-upload__input"
              type="file"
              @change="handleReplace"
            />
          </label> `),
                  !_ctx.disabled ? (openBlock(), createElementBlock("span", {
                    key: 0,
                    class: normalizeClass(unref(nsUpload).be("list", "item-delete")),
                    onClick: withModifiers(($event) => handleRemove(file), ["stop"])
                  }, [
                    createVNode(unref(ElIcon), {
                      class: normalizeClass(unref(nsIcon).m("delete"))
                    }, {
                      default: withCtx(() => [
                        createVNode(unref(Delete))
                      ]),
                      _: 1
                    }, 8, ["class"])
                  ], 10, _hoisted_4)) : createCommentVNode("v-if", true)
                ], 2)) : createCommentVNode("v-if", true)
              ])
            ], 42, _hoisted_1);
          }), 128))
        ], 2),
        renderSlot(_ctx.$slots, "append")
      ], 64);
    };
  }
});
var ElUploadList = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "/Users/wyf/work/element-plus/packages/components/upload/src/upload-list.vue"]]);

export { ElUploadList as default };
//# sourceMappingURL=upload-list4.mjs.map
