'use strict';

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

var vue = require('vue');
var core = require('@vueuse/core');
var index$2 = require('../../image-viewer/index.js');
var index$1 = require('../../icon/index.js');
var Icons = require('@element-plus/icons-vue');
require('../../../hooks/index.js');
require('../../draggable/index.js');
var uploadList = require('./upload-list.js');
var pluginVue_exportHelper = require('../../../../_virtual/plugin-vue_export-helper.js');
var index = require('../../../hooks/use-namespace/index.js');
var draggable = require('../../draggable/src/draggable.js');

const _hoisted_1 = ["onKeydown"];
const _hoisted_2 = ["src"];
const _hoisted_3 = ["onClick"];
const _hoisted_4 = ["src"];
const _hoisted_5 = /* @__PURE__ */ vue.createElementVNode("svg", {
  xmlns: "http://www.w3.org/2000/svg",
  width: "16",
  height: "16",
  viewBox: "0 0 16 16"
}, [
  /* @__PURE__ */ vue.createElementVNode("path", {
    "fill-rule": "evenodd",
    "clip-rule": "evenodd",
    d: "M13.7922 4.15937C13.0563 3.43281 12.0781 3.02969 11.0344 3.02813H11.0235C10.5219 3.02813 10.0328 3.12188 9.5672 3.30625C9.08439 3.49844 8.65001 3.78125 8.27814 4.14844L4.63908 7.74531C4.21876 8.16094 3.98908 8.71563 3.99064 9.30781C3.9922 9.89844 4.22501 10.4531 4.64689 10.8703C5.06876 11.2875 5.62814 11.5172 6.22501 11.5188H6.2297C6.82501 11.5188 7.38283 11.2906 7.80158 10.8781L10.9953 7.72188C11.1016 7.61719 11.1594 7.47813 11.1594 7.33125C11.1594 7.18281 11.1016 7.04375 10.9953 6.94063C10.8906 6.83594 10.75 6.77969 10.6016 6.77969C10.4531 6.77969 10.3125 6.8375 10.2078 6.94063L7.01408 10.0969C6.80626 10.3031 6.52658 10.4156 6.22814 10.4156H6.22658C5.92501 10.4141 5.6422 10.2984 5.43283 10.0906C5.22189 9.88125 5.1047 9.60312 5.1047 9.30625C5.10314 9.01094 5.2172 8.73438 5.42658 8.52812L9.06564 4.92969C9.58439 4.41563 10.2813 4.13281 11.025 4.13281H11.0328C11.7797 4.13438 12.4813 4.42188 13.0078 4.94062C13.5328 5.46094 13.8235 6.15312 13.825 6.89062C13.8266 7.62813 13.5406 8.31875 13.0203 8.83281L9.15939 12.6531C8.38751 13.4125 7.35626 13.8313 6.25626 13.8313H6.24533C5.14064 13.8281 4.10314 13.4031 3.32501 12.6344C2.54689 11.8656 2.1172 10.8406 2.11564 9.74844C2.11251 8.65625 2.53751 7.63437 3.30939 6.87187L8.29376 1.94375C8.40001 1.83906 8.45783 1.7 8.45783 1.55313C8.45783 1.40469 8.40001 1.26562 8.29376 1.1625C8.18751 1.05781 8.04689 1 7.89845 1C7.75001 1 7.60939 1.05781 7.5047 1.16094L2.52033 6.09062C2.02345 6.58125 1.63908 7.15781 1.37658 7.80156C1.12501 8.42344 0.998452 9.07969 1.00001 9.75156C1.00158 10.425 1.13126 11.0813 1.38751 11.7016C1.65158 12.3453 2.03751 12.9219 2.53751 13.4156C3.03439 13.9078 3.61876 14.2906 4.27033 14.5531C4.89533 14.8047 5.55939 14.9328 6.2422 14.9359H6.25626C6.93439 14.9359 7.5922 14.8109 8.21408 14.5625C8.86408 14.3047 9.44689 13.925 9.94376 13.4328L13.8047 9.61406C14.175 9.24687 14.4625 8.81875 14.6563 8.33906C14.8438 7.875 14.9391 7.3875 14.9375 6.88594C14.9328 5.85469 14.5266 4.88594 13.7922 4.15937Z",
    fill: "#333333"
  })
], -1);
const _hoisted_6 = ["onClick"];
const _hoisted_7 = ["onClick"];
const __default__ = vue.defineComponent({
  name: "ElUploadList"
});
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
  ...__default__,
  props: uploadList.uploadListProps,
  emits: uploadList.uploadListEmits,
  setup(__props, { emit }) {
    const props = __props;
    const fileList = core.useVModel(props, "files", void 0, { passive: true });
    const nsUpload = index.useNamespace("upload");
    const nsIcon = index.useNamespace("icon");
    const focusing = vue.ref(false);
    const handleRemove = (file) => {
      emit("remove", file);
    };
    const handelClick = (file) => {
      focusing.value = false;
      if (props.handlePreview) {
        props.handlePreview(file);
      }
    };
    const download = (file) => {
      window.open(`${file == null ? void 0 : file.url}${(file == null ? void 0 : file.url) ? `?attname=${encodeURIComponent(file.name)}` : ""}`, "_blank");
    };
    const draggable$1 = () => {
      emit("draggable", fileList.value);
    };
    const handelMove = (e) => {
      if (!e.relatedContext.element) {
        return false;
      }
    };
    const showViewer = vue.ref(false);
    const initialIndex = vue.ref(0);
    const previewSrcList = vue.computed(() => {
      const urlList = [];
      fileList.value.forEach((e) => {
        e.url && urlList.push(e.url);
      });
      return urlList;
    });
    const openPreview = (index) => {
      initialIndex.value = index;
      showViewer.value = true;
    };
    return (_ctx, _cache) => {
      return vue.openBlock(), vue.createBlock(vue.unref(draggable["default"]), {
        modelValue: vue.unref(fileList),
        "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => vue.isRef(fileList) ? fileList.value = $event : null),
        class: vue.normalizeClass([
          vue.unref(nsUpload).b("list"),
          vue.unref(nsUpload).bm("list", _ctx.listType),
          { "is-disabled": _ctx.disabled },
          { "is-draggable": props.showDraggable },
          _ctx.customerClass
        ]),
        handle: "." + vue.unref(nsUpload).be("list", "item"),
        disabled: !props.showDraggable,
        move: handelMove,
        onChange: draggable$1
      }, {
        default: vue.withCtx(() => [
          (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(fileList), (file, index) => {
            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: "0",
              onKeydown: vue.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)
            }, [
              vue.renderSlot(_ctx.$slots, "default", { file }, () => [
                file.status !== "uploading" && _ctx.listType === "picture-card" ? (vue.openBlock(), vue.createElementBlock("img", {
                  key: 0,
                  class: vue.normalizeClass(vue.unref(nsUpload).be("list", "item-thumbnail")),
                  src: file.url,
                  alt: ""
                }, null, 10, _hoisted_2)) : vue.createCommentVNode("v-if", true),
                file.status === "uploading" || _ctx.listType !== "picture-card" ? (vue.openBlock(), vue.createElementBlock("div", {
                  key: 1,
                  class: vue.normalizeClass(vue.unref(nsUpload).be("list", "item-info"))
                }, [
                  vue.createElementVNode("div", {
                    class: vue.normalizeClass(vue.unref(nsUpload).be("list", "item-name")),
                    onClick: vue.withModifiers(($event) => _ctx.handlePreview(file), ["prevent"])
                  }, [
                    vue.createElementVNode("div", {
                      class: vue.normalizeClass(vue.unref(nsUpload).be("list", "item-name-label"))
                    }, [
                      file.status !== "uploading" && _ctx.listType === "picture" ? (vue.openBlock(), vue.createElementBlock("img", {
                        key: 0,
                        class: vue.normalizeClass(vue.unref(nsUpload).be("list", "picture")),
                        src: file.url,
                        alt: ""
                      }, null, 10, _hoisted_4)) : (vue.openBlock(), vue.createBlock(vue.unref(index$1.ElIcon), {
                        key: 1,
                        class: vue.normalizeClass(vue.unref(nsIcon).m("document"))
                      }, {
                        default: vue.withCtx(() => [
                          _hoisted_5
                        ]),
                        _: 1
                      }, 8, ["class"])),
                      vue.createElementVNode("span", {
                        class: vue.normalizeClass(vue.unref(nsUpload).be("list", "item-file-name"))
                      }, vue.toDisplayString(file.name), 3)
                    ], 2),
                    file.status === "uploading" ? (vue.openBlock(), vue.createBlock(vue.unref(index$1.ElIcon), {
                      key: 0,
                      class: vue.normalizeClass([[vue.unref(nsIcon).m("loading")], "is-loading"])
                    }, {
                      default: vue.withCtx(() => [
                        vue.createVNode(vue.unref(Icons.Loading))
                      ]),
                      _: 1
                    }, 8, ["class"])) : vue.createCommentVNode("v-if", true),
                    file.status !== "uploading" && file.url ? (vue.openBlock(), vue.createBlock(vue.unref(index$1.ElIcon), {
                      key: 1,
                      class: vue.normalizeClass([vue.unref(nsIcon).m("download")]),
                      onClick: ($event) => download(file)
                    }, {
                      default: vue.withCtx(() => [
                        vue.createVNode(vue.unref(Icons.Download))
                      ]),
                      _: 2
                    }, 1032, ["class", "onClick"])) : vue.createCommentVNode("v-if", true)
                  ], 10, _hoisted_3)
                ], 2)) : vue.createCommentVNode("v-if", true),
                _ctx.listType === "text" ? (vue.openBlock(), vue.createElementBlock("label", {
                  key: 2,
                  class: vue.normalizeClass(vue.unref(nsUpload).be("list", "item-status-label"))
                }, [
                  vue.createVNode(vue.unref(index$1.ElIcon), {
                    class: vue.normalizeClass([vue.unref(nsIcon).m("upload-success"), vue.unref(nsIcon).m("circle-check")])
                  }, {
                    default: vue.withCtx(() => [
                      vue.createVNode(vue.unref(Icons.CircleCheck))
                    ]),
                    _: 1
                  }, 8, ["class"]),
                  ["picture-card", "picture"].includes(_ctx.listType) ? (vue.openBlock(), vue.createBlock(vue.unref(index$1.ElIcon), {
                    key: 0,
                    class: vue.normalizeClass([vue.unref(nsIcon).m("upload-success"), vue.unref(nsIcon).m("check")])
                  }, {
                    default: vue.withCtx(() => [
                      vue.createVNode(vue.unref(Icons.Check))
                    ]),
                    _: 1
                  }, 8, ["class"])) : vue.createCommentVNode("v-if", true)
                ], 2)) : vue.createCommentVNode("v-if", true),
                !_ctx.disabled ? (vue.openBlock(), vue.createBlock(vue.unref(index$1.ElIcon), {
                  key: 3,
                  class: vue.normalizeClass(vue.unref(nsIcon).m("close")),
                  size: "14",
                  onClick: vue.withModifiers(($event) => handleRemove(file), ["stop"])
                }, {
                  default: vue.withCtx(() => [
                    vue.createVNode(vue.unref(Icons.Delete))
                  ]),
                  _: 2
                }, 1032, ["class", "onClick"])) : vue.createCommentVNode("v-if", true),
                _ctx.listType === "picture-card" ? (vue.openBlock(), vue.createElementBlock("span", {
                  key: 4,
                  class: vue.normalizeClass(vue.unref(nsUpload).be("list", "item-actions"))
                }, [
                  !_ctx.disabled && _ctx.showPreview ? (vue.openBlock(), vue.createElementBlock("span", {
                    key: 0,
                    class: vue.normalizeClass(vue.unref(nsUpload).be("list", "item-preview")),
                    onClick: vue.withModifiers(($event) => openPreview(index), ["stop"])
                  }, [
                    vue.createVNode(vue.unref(index$1.ElIcon), {
                      class: vue.normalizeClass(vue.unref(nsIcon).m("preview")),
                      size: "16"
                    }, {
                      default: vue.withCtx(() => [
                        vue.createVNode(vue.unref(Icons.ZoomIn))
                      ]),
                      _: 1
                    }, 8, ["class"])
                  ], 10, _hoisted_6)) : vue.createCommentVNode("v-if", true),
                  !_ctx.disabled && _ctx.showDelete ? (vue.openBlock(), vue.createElementBlock("span", {
                    key: 1,
                    class: vue.normalizeClass(vue.unref(nsUpload).be("list", "item-delete")),
                    onClick: vue.withModifiers(($event) => handleRemove(file), ["stop"])
                  }, [
                    vue.createVNode(vue.unref(index$1.ElIcon), {
                      class: vue.normalizeClass(vue.unref(nsIcon).m("delete")),
                      size: "16"
                    }, {
                      default: vue.withCtx(() => [
                        vue.createVNode(vue.unref(Icons.Delete))
                      ]),
                      _: 1
                    }, 8, ["class"])
                  ], 10, _hoisted_7)) : vue.createCommentVNode("v-if", true)
                ], 2)) : vue.createCommentVNode("v-if", true)
              ])
            ], 42, _hoisted_1);
          }), 128)),
          vue.renderSlot(_ctx.$slots, "append"),
          showViewer.value ? (vue.openBlock(), vue.createBlock(vue.unref(index$2.ElImageViewer), {
            key: 0,
            "url-list": vue.unref(previewSrcList),
            "initial-index": initialIndex.value,
            teleported: true,
            onClose: _cache[3] || (_cache[3] = ($event) => showViewer.value = false)
          }, null, 8, ["url-list", "initial-index"])) : vue.createCommentVNode("v-if", true)
        ]),
        _: 3
      }, 8, ["modelValue", "class", "handle", "disabled"]);
    };
  }
});
var ElUploadList = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "/home/dingdan/workspace/element-plus/packages/components/upload/src/upload-list.vue"]]);

exports["default"] = ElUploadList;
//# sourceMappingURL=upload-list2.js.map
