'use strict';

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

var vue = require('vue');
var is = require('../../../../utils/src/is.js');
var fileComponent = require('./fileComponent.js');

const _hoisted_1 = { class: "gm-flex gm-h-full gm-w-full gm-flex-col gm-items-center gm-justify-center" };
const _hoisted_2 = ["src"];
const _hoisted_3 = ["src", "controls", "controlslist", "oncontextmenu"];
const _hoisted_4 = ["src"];
var _sfc_main = /* @__PURE__ */ vue.defineComponent({
  ...{
    name: "GmFileComponent"
  },
  __name: "FileComponent",
  props: fileComponent.fileComponentProps,
  setup(__props) {
    const props = __props;
    const iconStyle = vue.computed(() => {
      return {
        width: `${props.size}px`,
        height: `${props.size}px`
      };
    });
    const fileStyle = vue.computed(() => {
      return {
        width: props.fileWidth,
        height: props.fileHeight,
        ...props.fileStyle
      };
    });
    const fileURL = vue.computed(() => {
      return props.file[props.url];
    });
    const verifyFile = vue.computed(() => {
      return props.file[props.field];
    });
    const isImageFile = vue.computed(() => is.isImageUrl(fileURL.value) || is.isImageUrl(verifyFile.value));
    const isVideoFile = vue.computed(() => is.isVideoUrl(fileURL.value) || is.isVideoUrl(verifyFile.value));
    const showIframe = vue.computed(() => {
      return is.isPDF(fileURL.value) || is.isPDF(verifyFile.value) || is.isText(fileURL.value) || is.isText(verifyFile.value);
    });
    const iconList = {
      excel: "https://sucai.giikin.cn/workflow/material-refer-1739947054012-1213-335.svg",
      pdf: "https://sucai.giikin.cn/workflow/material-refer-1739947288698-5462-586.svg",
      word: "https://sucai.giikin.cn/workflow/material-refer-1739947288698-1540-625.svg",
      txt: "https://sucai.giikin.cn/workflow/material-refer-1739947288698-1700-90.svg",
      zip: "https://sucai.giikin.cn/workflow/material-refer-1739947288698-2639-507.svg",
      psd: "https://sucai.giikin.cn/workflow/material-refer-1739947288698-5026-760.svg",
      ppt: "https://sucai.giikin.cn/workflow/material-refer-1739947288698-2867-970.svg",
      unknown: "https://sucai.giikin.cn/workflow/material-refer-1739947288698-1448-736.svg"
    };
    const iconURL = vue.computed(() => {
      const typeCheckers = [
        { check: () => is.isPDF(fileURL.value) || is.isPDF(verifyFile.value), icon: iconList.pdf },
        { check: () => is.isWord(fileURL.value) || is.isWord(verifyFile.value), icon: iconList.word },
        { check: () => is.isExcel(fileURL.value) || is.isExcel(verifyFile.value), icon: iconList.excel },
        { check: () => is.isText(fileURL.value) || is.isText(verifyFile.value), icon: iconList.txt },
        { check: () => is.isPPT(fileURL.value) || is.isPPT(verifyFile.value), icon: iconList.ppt },
        { check: () => is.isZip(fileURL.value) || is.isZip(verifyFile.value), icon: iconList.zip },
        { check: () => is.isPSD(fileURL.value) || is.isPSD(verifyFile.value), icon: iconList.psd }
      ];
      const matchedType = typeCheckers.find(({ check }) => check());
      return matchedType?.icon || iconList.unknown;
    });
    const handleClick = () => {
      if (!props.onClick) return;
      props.onClick(props.file);
    };
    return (_ctx, _cache) => {
      const _component_el_image = vue.resolveComponent("el-image");
      return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
        vue.createElementVNode(
          "div",
          {
            class: "gm-flex gm-items-center gm-justify-center",
            style: vue.normalizeStyle(fileStyle.value),
            onClick: handleClick
          },
          [
            isImageFile.value ? (vue.openBlock(), vue.createElementBlock("img", {
              key: 0,
              src: fileURL.value,
              fit: "contain",
              style: { "max-width": "100%", "max-height": "100%" }
            }, null, 8, _hoisted_2)) : isVideoFile.value ? (vue.openBlock(), vue.createElementBlock("video", {
              key: 1,
              src: fileURL.value,
              controls: _ctx.controls,
              controlslist: _ctx.controlslist,
              oncontextmenu: () => _ctx.oncontextmenu,
              style: { "max-width": "100%", "max-height": "100%" }
            }, null, 8, _hoisted_3)) : (vue.openBlock(), vue.createElementBlock(
              vue.Fragment,
              { key: 2 },
              [
                _ctx.showIcon || !showIframe.value ? (vue.openBlock(), vue.createBlock(_component_el_image, {
                  key: 0,
                  style: vue.normalizeStyle(iconStyle.value),
                  src: iconURL.value
                }, null, 8, ["style", "src"])) : (vue.openBlock(), vue.createElementBlock("iframe", {
                  key: 1,
                  src: fileURL.value,
                  width: "850px",
                  height: "100%",
                  frameborder: "0"
                }, null, 8, _hoisted_4))
              ],
              64
              /* STABLE_FRAGMENT */
            ))
          ],
          4
          /* STYLE */
        ),
        vue.renderSlot(_ctx.$slots, "default", { file: _ctx.file })
      ]);
    };
  }
});

exports.default = _sfc_main;
//# sourceMappingURL=FileComponent.vue2.js.map
