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

import { defineComponent, ref, computed, watch, createVNode } from 'vue';
import { ImageErrorIcon } from '@ldesign/icons-vue-next';
import { usePrefixClass } from '../../hooks/useConfig.js';
import { useDrag } from '../hooks.js';
import '../../config-provider/useConfig.js';
import 'lodash/cloneDeep';
import 'lodash/isFunction';
import 'lodash/isString';
import '../../config-provider/context.js';
import 'lodash/mergeWith';
import 'lodash/merge';
import 'lodash/isArray';
import '../../_common/js/global-config/default-config.js';
import '../../_common/js/global-config/locale/zh_CN.js';
import '@babel/runtime/helpers/typeof';
import '../../_chunks/dep-e041f5b0.js';
import 'dayjs';
import '@babel/runtime/helpers/defineProperty';

var TImageItem = defineComponent({
  name: "TImageItem",
  props: {
    rotate: Number,
    scale: Number,
    mirror: Number,
    src: String,
    placementSrc: String
  },
  setup: function setup(props) {
    var classPrefix = usePrefixClass();
    var error = ref(false);
    var loaded = ref(false);
    var _useDrag = useDrag({
        translateX: 0,
        translateY: 0
      }),
      transform = _useDrag.transform,
      mouseDownHandler = _useDrag.mouseDownHandler;
    var imgStyle = computed(function () {
      return {
        transform: "rotate(".concat(props.rotate, "deg) scale(").concat(props.scale, ")"),
        display: !props.placementSrc || loaded.value ? "block" : "none"
      };
    });
    var placementImgStyle = computed(function () {
      return {
        transform: "rotate(".concat(props.rotate, "deg) scale(").concat(props.scale, ")"),
        display: !loaded.value ? "block" : "none"
      };
    });
    var boxStyle = computed(function () {
      var _transform$value = transform.value,
        translateX = _transform$value.translateX,
        translateY = _transform$value.translateY;
      return {
        transform: "translate(".concat(translateX, "px, ").concat(translateY, "px) scale(").concat(props.mirror, ", 1)")
      };
    });
    var resetStatus = function resetStatus() {
      error.value = false;
      loaded.value = false;
    };
    watch(function () {
      return props.src;
    }, function () {
      resetStatus();
    });
    return function () {
      return createVNode("div", {
        "class": "".concat(classPrefix.value, "-image-viewer__modal-pic")
      }, [createVNode("div", {
        "class": "".concat(classPrefix.value, "-image-viewer__modal-box"),
        "style": boxStyle.value
      }, [error.value && createVNode("div", {
        "class": "".concat(classPrefix.value, "-image-viewer__img-error")
      }, [createVNode("div", {
        "class": "".concat(classPrefix.value, "-image-viewer__img-error-content")
      }, [createVNode(ImageErrorIcon, {
        "size": "4em"
      }, null), createVNode("div", {
        "class": "".concat(classPrefix.value, "-image-viewer__img-error-text")
      }, ["\u56FE\u7247\u52A0\u8F7D\u5931\u8D25\uFF0C\u53EF\u5C1D\u8BD5\u91CD\u65B0\u52A0\u8F7D"])])]), !error.value && !!props.placementSrc && createVNode("img", {
        "class": "".concat(classPrefix.value, "-image-viewer__modal-image"),
        "onMousedown": function onMousedown(event) {
          event.stopPropagation();
          mouseDownHandler(event);
        },
        "src": props.placementSrc,
        "style": placementImgStyle.value,
        "alt": "image",
        "draggable": "false"
      }, null), !error.value && createVNode("img", {
        "class": "".concat(classPrefix.value, "-image-viewer__modal-image"),
        "onMousedown": function onMousedown(event) {
          event.stopPropagation();
          mouseDownHandler(event);
        },
        "src": props.src,
        "onLoad": function onLoad() {
          return loaded.value = true;
        },
        "onError": function onError() {
          return error.value = true;
        },
        "style": imgStyle.value,
        "alt": "image",
        "draggable": "false"
      }, null)])]);
    };
  }
});

export { TImageItem as default };
//# sourceMappingURL=ImageItem.js.map
