import{Space as e,Button as i}from"antd";import{useState as l}from"react";import{getFileName as n}from"../../utils/index.js";import r from"../Pdf/index.js";import{jsxs as a,Fragment as m,jsx as t}from"react/jsx-runtime";const o=o=>{const{files:s=[],nameKey:c="",urlKey:d="",name:f="",url:p=""}=o,[h,y]=l(!1),[u,P]=l(""),[v,x]=l(""),C=(e,i)=>{y(!0),P(e),x(i)},g=()=>{y(!1),P(""),x("")},j=e=>e.name||e.fileName||e[c]||n(e.filePath||e[d]);return 0===s.length&&f&&p?a(m,{children:[a(e,{children:[t("span",{children:f}),t(i,{type:"primary",size:"small",onClick:()=>C(p,f),children:"预览"})]}),t(r,{visible:h,file:u,name:v,onCancel:g})]}):s.length>0&&!f&&!p?a(m,{children:[s.map(l=>t("div",{style:{marginTop:5},children:a(e,{children:[t("span",{children:j(l)}),t(i,{type:"primary",size:"small",onClick:()=>C(l.filePath||l[d],j(l)),children:"预览"})]})},l.filePath||l[d])),t(r,{visible:h,file:u,name:v,onCancel:g})]}):null};o.displayName="PreviewPdf";export{o as default};
