/**
 * ldesign v0.3.13
 * (c) 2023 ldesign
 * @license MIT
 */

import { _ as _defineProperty } from '../_chunks/dep-2db7b3ec.mjs';
import { defineComponent, createVNode, mergeProps, computed } from 'vue';
import { UploadIcon } from '@ldesign/icons-vue-next';
import { Button } from '../button/index.mjs';
import { useContent, useTNodeJSX } from '../hooks/tnode.mjs';
import { useFormDisabled } from '../form/hooks.mjs';
import props from './props.mjs';
import NormalFile from './themes/normal-file.mjs';
import DraggerFile from './themes/dragger-file.mjs';
import ImageCard from './themes/image-card.mjs';
import MultipleFlowList from './themes/multiple-flow-list.mjs';
import useUpload from './hooks/useUpload.mjs';
import CustomFile from './themes/custom-file.mjs';
import '../_chunks/dep-255303ba.mjs';
import '../utils/withInstall.mjs';
import '../button/button.mjs';
import '../_chunks/dep-bf1e33c8.mjs';
import '../_chunks/dep-b8d7992c.mjs';
import '../loading/index.mjs';
import '../loading/directive.mjs';
import '../loading/plugin.mjs';
import '../utils/dom.mjs';
import '../_chunks/dep-eba0ea6e.mjs';
import '../_chunks/dep-876fb3ec.mjs';
import '../_chunks/dep-469b4ae0.mjs';
import '../_chunks/dep-b57180d0.mjs';
import '../_chunks/dep-c8d7b6b4.mjs';
import '../_chunks/dep-3da99438.mjs';
import '../_chunks/dep-5717e263.mjs';
import '../_chunks/dep-a8bcacea.mjs';
import '../utils/easing.mjs';
import '../hooks/useConfig.mjs';
import '../config-provider/useConfig.mjs';
import '../_chunks/dep-095107f7.mjs';
import '../_chunks/dep-c989dff3.mjs';
import '../_chunks/dep-9cf86cf1.mjs';
import '../_chunks/dep-bc1d737a.mjs';
import '../_chunks/dep-4d7a675b.mjs';
import '../_chunks/dep-2e7f59b1.mjs';
import '../_chunks/dep-855db8bc.mjs';
import '../_chunks/dep-a87f3e4c.mjs';
import '../_chunks/dep-1e566bb5.mjs';
import '../_chunks/dep-1434aa15.mjs';
import '../_chunks/dep-e5eb9f23.mjs';
import '../_chunks/dep-9fe2ef12.mjs';
import '../_chunks/dep-672e7d1a.mjs';
import '../_chunks/dep-42a19209.mjs';
import '../_chunks/dep-9262ee2f.mjs';
import '../_chunks/dep-334a4f6b.mjs';
import '../_chunks/dep-8d3e9aa3.mjs';
import '../_chunks/dep-40d69a9c.mjs';
import '../_chunks/dep-dcc83161.mjs';
import '../_chunks/dep-0fc02184.mjs';
import '../_chunks/dep-f1994936.mjs';
import '../_chunks/dep-345e1be3.mjs';
import '../_common/js/global-config/default-config.mjs';
import '../_common/js/global-config/locale/zh_CN.mjs';
import '../_chunks/dep-9888611c.mjs';
import '../_chunks/dep-697a1365.mjs';
import '../config-provider/type.mjs';
import '../loading/loading.mjs';
import '../_chunks/dep-84acf3c2.mjs';
import '../utils/render-tnode.mjs';
import '../_chunks/dep-888e80c4.mjs';
import '../_chunks/dep-406cd044.mjs';
import '../_chunks/dep-42cc3015.mjs';
import '../_chunks/dep-2bc37d52.mjs';
import '../_chunks/dep-327559e8.mjs';
import '../_chunks/dep-b2235f26.mjs';
import '../_chunks/dep-8b989474.mjs';
import '../_chunks/dep-1372b2d3.mjs';
import '../_chunks/dep-9a85dac1.mjs';
import '../hooks/useTeleport.mjs';
import '../loading/props.mjs';
import '../loading/icon/gradient.mjs';
import '../_common/js/loading/circle-adapter.mjs';
import '../_common/js/utils/set-style.mjs';
import '../_common/js/utils/helper.mjs';
import '../_chunks/dep-60fae668.mjs';
import '../_chunks/dep-ed5ebb35.mjs';
import '../_chunks/dep-78847b2e.mjs';
import '../_chunks/dep-3f21269a.mjs';
import '../loading/style/css.mjs';
import '../loading/type.mjs';
import '../hooks/useRipple.mjs';
import '../utils/set-style.mjs';
import '../hooks/useKeepAnimation.mjs';
import '../button/props.mjs';
import '../button/style/css.mjs';
import '../button/type.mjs';
import '../link/index.mjs';
import '../link/link.mjs';
import '../link/props.mjs';
import '../link/style/css.mjs';
import '../link/type.mjs';
import '../_common/js/upload/utils.mjs';
import '../_common/js/log/log.mjs';
import '../hooks/useGlobalIcon.mjs';
import './constants.mjs';
import '../hooks/useCommonClassName.mjs';
import './hooks/useDrag.mjs';
import '../image-viewer/index.mjs';
import '../image-viewer/image-viewer.mjs';
import '../hooks/useVModel.mjs';
import '../hooks/useDefaultValue.mjs';
import '../image-viewer/props.mjs';
import '../image-viewer/base/ImageModalIcon.mjs';
import '../image-viewer/base/ImageViewerUtils.mjs';
import '../tooltip/index.mjs';
import '../tooltip/tooltip.mjs';
import '../_chunks/dep-350764bc.mjs';
import '../_chunks/dep-0d3dd4b5.mjs';
import '../_chunks/dep-6884627f.mjs';
import '../popup/props.mjs';
import '../popup/index.mjs';
import '../popup/popup.mjs';
import '@popperjs/core';
import '../popup/container.mjs';
import '../hooks/useResizeObserver.mjs';
import '../popup/style/css.mjs';
import '../popup/type.mjs';
import '../tooltip/util.mjs';
import '../tooltip/props.mjs';
import '../tooltip/style/css.mjs';
import '../tooltip/type.mjs';
import '../image-viewer/utils.mjs';
import '../image-viewer/base/ImageItem.mjs';
import '../image-viewer/hooks.mjs';
import '../image-viewer/base/ImageViewerModal.mjs';
import '../dialog/index.mjs';
import '../dialog/dialog.mjs';
import '../hooks/useDestroyOnClose.mjs';
import '../_common/js/utils/getScrollbarWidth.mjs';
import '../dialog/stack.mjs';
import '../dialog/hooks.mjs';
import '../dialog/props.mjs';
import '../dialog/style/css.mjs';
import '../dialog/type.mjs';
import '../dialog/plugin.mjs';
import '../image-viewer/const.mjs';
import '../image-viewer/style/css.mjs';
import '../image-viewer/type.mjs';
import '../hooks/index.mjs';
import '../hooks/icon.mjs';
import '../hooks/slot.mjs';
import '../hooks/useVirtualScroll.mjs';
import '../_common/js/upload/main.mjs';
import '../_common/js/upload/xhr.mjs';

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var _Upload = defineComponent({
  name: "TUpload",
  props: props,
  setup: function setup(props2, _ref) {
    var slots = _ref.slots,
      expose = _ref.expose;
    var renderContent = useContent();
    var renderTNodeJSX = useTNodeJSX();
    var _useUpload = useUpload(props2),
      locale = _useUpload.locale,
      classPrefix = _useUpload.classPrefix,
      triggerUploadText = _useUpload.triggerUploadText,
      toUploadFiles = _useUpload.toUploadFiles,
      displayFiles = _useUpload.displayFiles,
      uploadValue = _useUpload.uploadValue,
      sizeOverLimitMessage = _useUpload.sizeOverLimitMessage,
      uploading = _useUpload.uploading,
      tipsClasses = _useUpload.tipsClasses,
      errorClasses = _useUpload.errorClasses,
      placeholderClass = _useUpload.placeholderClass,
      inputRef = _useUpload.inputRef,
      onInnerRemove = _useUpload.onInnerRemove,
      uploadFiles = _useUpload.uploadFiles,
      onNormalFileChange = _useUpload.onNormalFileChange,
      onDragFileChange = _useUpload.onDragFileChange,
      triggerUpload = _useUpload.triggerUpload,
      cancelUpload = _useUpload.cancelUpload;
    var disabled = useFormDisabled();
    expose({
      upload: inputRef.value,
      uploading: uploading,
      triggerUpload: triggerUpload,
      uploadFiles: uploadFiles,
      cancelUpload: cancelUpload
    });
    var renderTrigger = function renderTrigger() {
      var getDefaultTrigger = function getDefaultTrigger() {
        if (props2.theme === "file-input") {
          return createVNode(Button, mergeProps({
            "disabled": disabled.value,
            "variant": "outline"
          }, props2.triggerButtonProps), {
            "default": function _default() {
              return [triggerUploadText.value];
            }
          });
        }
        return createVNode(Button, mergeProps({
          "disabled": disabled.value,
          "variant": "outline",
          "icon": function icon() {
            return createVNode(UploadIcon, null, null);
          }
        }, props2.triggerButtonProps), {
          "default": function _default() {
            return [triggerUploadText.value];
          }
        });
      };
      return renderContent("default", "trigger", {
        params: {
          dragActive: false,
          files: uploadValue.value
        }
      }) || getDefaultTrigger();
    };
    var commonDisplayFileProps = computed(function () {
      return {
        files: uploadValue.value,
        toUploadFiles: toUploadFiles.value,
        displayFiles: displayFiles.value,
        theme: props2.theme,
        placeholder: props2.placeholder,
        disabled: disabled.value,
        tips: props2.tips,
        status: props2.status,
        sizeOverLimitMessage: sizeOverLimitMessage.value,
        uploading: uploading.value,
        classPrefix: classPrefix.value,
        tipsClasses: tipsClasses,
        errorClasses: errorClasses,
        placeholderClass: placeholderClass,
        locale: locale.value,
        autoUpload: props2.autoUpload,
        abridgeName: props2.abridgeName,
        showUploadProgress: props2.showUploadProgress,
        fileListDisplay: props2.fileListDisplay,
        onRemove: onInnerRemove
      };
    });
    var dragProps = {
      onDragFileChange: onDragFileChange,
      onDragenter: props2.onDragenter,
      onDragleave: props2.onDragleave,
      onDrop: props2.onDrop
    };
    var getNormalFileNode = function getNormalFileNode() {
      return createVNode(NormalFile, mergeProps(commonDisplayFileProps.value, {
        "multiple": props2.multiple
      }), {
        "default": function _default() {
          return [createVNode("div", {
            "class": "".concat(classPrefix.value, "-upload__trigger"),
            "onClick": triggerUpload
          }, [renderTrigger()])];
        },
        "fileListDisplay": slots.fileListDisplay,
        "file-list-display": slots["file-list-display"]
      });
    };
    var getSingleFileDraggerUploadNode = function getSingleFileDraggerUploadNode() {
      return createVNode(DraggerFile, mergeProps(commonDisplayFileProps.value, {
        "dragEvents": dragProps,
        "trigger": props2.trigger,
        "cancelUpload": cancelUpload,
        "triggerUpload": triggerUpload,
        "uploadFiles": uploadFiles,
        "onCancelUpload": props2.onCancelUpload
      }), {
        "fileListDisplay": slots.fileListDisplay,
        "file-list-display": slots["file-list-display"]
      });
    };
    var getImageCardUploadNode = function getImageCardUploadNode() {
      return createVNode(ImageCard, mergeProps(commonDisplayFileProps.value, {
        "multiple": props2.multiple,
        "max": props2.max,
        "showUploadProgress": props2.showUploadProgress,
        "triggerUpload": triggerUpload,
        "uploadFiles": uploadFiles,
        "cancelUpload": cancelUpload,
        "onPreview": props2.onPreview
      }), null);
    };
    var getFlowListNode = function getFlowListNode() {
      return createVNode(MultipleFlowList, mergeProps(commonDisplayFileProps.value, {
        "isBatchUpload": props2.isBatchUpload,
        "draggable": props2.draggable,
        "dragEvents": dragProps,
        "uploadFiles": uploadFiles,
        "cancelUpload": cancelUpload,
        "onPreview": props2.onPreview
      }), {
        "default": function _default() {
          return [createVNode("div", {
            "class": "".concat(classPrefix.value, "-upload__trigger"),
            "onClick": triggerUpload
          }, [!props2.draggable && renderTrigger()])];
        },
        "fileListDisplay": slots.fileListDisplay,
        "file-list-display": slots["file-list-display"]
      });
    };
    var getCustomFile = function getCustomFile() {
      return createVNode(CustomFile, mergeProps(commonDisplayFileProps.value, {
        "draggable": props2.draggable,
        "dragContent": props2.dragContent,
        "dragEvents": dragProps,
        "triggerUpload": triggerUpload,
        "trigger": props2.trigger,
        "childrenNode": slots["default"]
      }), {
        "default": function _default() {
          return [renderTrigger()];
        },
        "dragContent": slots.dragContent,
        "drag-content": slots["drag-content"],
        "trigger": slots.trigger
      });
    };
    return function () {
      return createVNode("div", {
        "class": "".concat(classPrefix.value, "-upload")
      }, [createVNode("input", mergeProps({
        "ref": inputRef,
        "type": "file",
        "disabled": disabled.value,
        "onChange": onNormalFileChange,
        "multiple": props2.multiple,
        "accept": props2.accept,
        "hidden": true
      }, props2.inputAttributes ? _objectSpread({}, props2.inputAttributes) : {}), null), ["file", "file-input"].includes(props2.theme) && !props2.draggable && getNormalFileNode(), ["file", "image"].includes(props2.theme) && props2.draggable && getSingleFileDraggerUploadNode(), props2.theme === "image" && !props2.draggable && getImageCardUploadNode(), ["image-flow", "file-flow"].includes(props2.theme) && getFlowListNode(), props2.theme === "custom" && getCustomFile(), Boolean(props2.tips || slots.tips) && createVNode("small", {
        "class": [tipsClasses, _defineProperty({}, "".concat(classPrefix.value, "-upload__tips-").concat(props2.status), props2.status)]
      }, [renderTNodeJSX("tips")])]);
    };
  }
});

export { _Upload as default };
//# sourceMappingURL=upload.mjs.map
