var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/file-link/index.tsx
var file_link_exports = {};
__export(file_link_exports, {
  default: () => file_link_default
});
module.exports = __toCommonJS(file_link_exports);
var import_react = __toESM(require("react"));
var import_antd = require("antd");
var import_icons = require("@ant-design/icons");
var import_hooks = require("../_util/hooks");
var import_preview = require("../preview/index");
var import_modal = __toESM(require("../modal"));
var import_audio = __toESM(require("./audio/index"));
var import_video = __toESM(require("./video/index"));
var import_context = require("../config-provider/context");
var import_index = require("./index.less");
var FileLink = (props) => {
  const componentContext = (0, import_react.useContext)(import_context.ConfigContext);
  const { uiLocale } = componentContext;
  const { name, url, transformId, canDownload, playUrl, transformType = "" } = props;
  const fileIcon = () => /* @__PURE__ */ import_react.default.createElement("span", { className: "fileIcon" }, canDownload ? /* @__PURE__ */ import_react.default.createElement(import_icons.PaperClipOutlined, null) : /* @__PURE__ */ import_react.default.createElement(import_antd.Tooltip, { title: uiLocale.Upload.lockTooltip }, /* @__PURE__ */ import_react.default.createElement(import_icons.LockOutlined, null)));
  const downloadIcon = () => url && /* @__PURE__ */ import_react.default.createElement("a", { href: url, className: "link-icon", rel: "noreferrer", download: true }, /* @__PURE__ */ import_react.default.createElement(import_icons.DownloadOutlined, null));
  const renderContent = () => {
    if (transformType === "KM" && transformId)
      return /* @__PURE__ */ import_react.default.createElement(Document, { ...props });
    if (["YX_VIDEO", "YX_AUDIO"].includes(transformType) && playUrl)
      return /* @__PURE__ */ import_react.default.createElement(Player, { ...props });
    return name;
  };
  return (0, import_hooks.useConfig)(
    /* @__PURE__ */ import_react.default.createElement("div", { className: "m-file-link" }, fileIcon(), renderContent(), downloadIcon())
  );
};
var Document = (props) => {
  const { name, transformId, canDownload, url } = props;
  return /* @__PURE__ */ import_react.default.createElement(import_modal.default, { triggerDom: /* @__PURE__ */ import_react.default.createElement("span", { className: "active" }, name), width: 1e3, footer: null }, /* @__PURE__ */ import_react.default.createElement(import_preview.FilePreview, { file: { transformId, name, url }, allowDownload: canDownload }));
};
var Player = (props) => {
  const { name, transformType, playUrl } = props;
  if (!playUrl)
    return null;
  return /* @__PURE__ */ import_react.default.createElement(import_modal.default, { title: name, triggerDom: /* @__PURE__ */ import_react.default.createElement("span", { className: "active" }, name), footer: null, width: 720 }, transformType === "YX_VIDEO" && /* @__PURE__ */ import_react.default.createElement(import_video.default, { url: playUrl }), transformType === "YX_AUDIO" && /* @__PURE__ */ import_react.default.createElement(import_audio.default, { url: playUrl }));
};
var file_link_default = FileLink;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {});
