@eternalheart/react-file-preview 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"FilePreviewModal.d.ts","sourceRoot":"","sources":["../src/FilePreviewModal.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAe,gBAAgB,EAAY,cAAc,EAAE,MAAM,SAAS,CAAC;AAalF,UAAU,qBAAqB;IAC7B,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;CACpC;AA6CD,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CA2W5D,CAAC"}
1
+ {"version":3,"file":"FilePreviewModal.d.ts","sourceRoot":"","sources":["../src/FilePreviewModal.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAe,gBAAgB,EAAY,cAAc,EAAE,MAAM,SAAS,CAAC;AAalF,UAAU,qBAAqB;IAC7B,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;CACpC;AA6CD,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CA6W5D,CAAC"}
package/lib/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),ee=require("react-dom"),z=require("framer-motion"),S=require("lucide-react"),L=require("react-pdf"),te=require("mammoth"),se=require("xlsx"),B=require("pptx-preview"),re=require("video.js"),le=require("react-markdown"),oe=require("remark-gfm"),A=require("react-syntax-highlighter");function ne(r){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const o in r)if(o!=="default"){const a=Object.getOwnPropertyDescriptor(r,o);Object.defineProperty(s,o,a.get?a:{enumerable:!0,get:()=>r[o]})}}return s.default=r,Object.freeze(s)}const X=ne(se),ae="1.0.3",ce={version:ae};function ie(r){try{const a=new URL(r).pathname.split("/").pop()||"file";return decodeURIComponent(a)}catch{const s=r.split("/").pop()||"file";return decodeURIComponent(s)}}function q(r){var a;const s=((a=r.split(".").pop())==null?void 0:a.toLowerCase())||"";return{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",bmp:"image/bmp",ico:"image/x-icon",mp4:"video/mp4",webm:"video/webm",ogg:"video/ogg",ogv:"video/ogg",mov:"video/quicktime",avi:"video/x-msvideo",mkv:"video/x-matroska",m4v:"video/x-m4v","3gp":"video/3gpp",flv:"video/x-flv",mp3:"audio/mpeg",wav:"audio/wav",m4a:"audio/mp4",aac:"audio/aac",flac:"audio/flac",pdf:"application/pdf",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",ppt:"application/vnd.ms-powerpoint",txt:"text/plain",md:"text/markdown",markdown:"text/markdown",json:"application/json",xml:"application/xml",html:"text/html",css:"text/css",js:"text/javascript",ts:"text/typescript",jsx:"text/javascript",tsx:"text/typescript",py:"text/x-python",java:"text/x-java",cpp:"text/x-c++src",c:"text/x-csrc",cs:"text/x-csharp",php:"text/x-php",rb:"text/x-ruby",go:"text/x-go",rs:"text/x-rust",yaml:"text/yaml",yml:"text/yaml"}[s]||"application/octet-stream"}function U(r,s=0){if(r instanceof File)return{id:`file-${Date.now()}-${s}`,name:r.name,url:URL.createObjectURL(r),type:r.type||q(r.name),size:r.size};if(typeof r=="string"){const o=ie(r);return{id:`url-${Date.now()}-${s}`,name:o,url:r,type:q(o)}}return{id:r.id||`link-${Date.now()}-${s}`,name:r.name,url:r.url,type:r.type||q(r.name),size:r.size}}function V(r){return r.map((s,o)=>U(s,o))}const de=({url:r,zoom:s,rotation:o,onZoomChange:a})=>{const[n,d]=t.useState(!1),[i,l]=t.useState(null),[c,p]=t.useState({x:0,y:0}),[x,m]=t.useState(!1),[v,f]=t.useState({x:0,y:0}),[g,h]=t.useState(1),j=t.useRef(null);t.useEffect(()=>{d(!1),l(null),p({x:0,y:0}),h(1)},[r]),t.useEffect(()=>{h(s)},[s]),t.useEffect(()=>{p({x:0,y:0})},[s,o]);const y=()=>{d(!0)},k=()=>{l("图片加载失败"),d(!0)},u=()=>{p({x:0,y:0})},M=t.useCallback(N=>{N.preventDefault(),N.stopPropagation();const P=N.deltaY>0?-.1:.1;h(R=>{const F=Math.max(.5,Math.min(5,R+P));return a&&a(F),F})},[a]),C=t.useCallback(N=>{N.button===0&&(m(!0),f({x:N.clientX-c.x,y:N.clientY-c.y}))},[c]),w=t.useCallback(N=>{x&&p({x:N.clientX-v.x,y:N.clientY-v.y})},[x,v]),T=t.useCallback(()=>{m(!1)},[]);return e.jsxs("div",{ref:j,className:"flex items-center justify-center w-full h-full overflow-hidden",onWheel:M,onMouseDown:C,onMouseMove:w,onMouseUp:T,onMouseLeave:T,style:{cursor:x?"grabbing":"grab"},children:[!n&&!i&&e.jsx("div",{className:"flex items-center justify-center",children:e.jsx("div",{className:"w-12 h-12 border-4 border-white/20 border-t-white rounded-full animate-spin"})}),i&&e.jsx("div",{className:"text-white/70 text-center",children:e.jsx("p",{className:"text-lg",children:i})}),e.jsx(z.motion.img,{src:r,alt:"Preview",className:`max-w-none select-none ${n?"":"hidden"}`,style:{transform:`translate(${c.x}px, ${c.y}px) scale(${g}) rotate(${o}deg)`,transformOrigin:"center",transition:x?"none":"transform 0.3s ease-out"},onLoad:y,onError:k,onDoubleClick:u,initial:{opacity:0},animate:{opacity:n?1:0},transition:{duration:.3},draggable:!1})]})};function _(r){if(typeof window>"u")return;const{workerSrc:s=`https://unpkg.com/pdfjs-dist@${L.pdfjs.version}/build/pdf.worker.min.mjs`,cMapUrl:o=`https://unpkg.com/pdfjs-dist@${L.pdfjs.version}/cmaps/`,cMapPacked:a=!0}=r||{};L.pdfjs.GlobalWorkerOptions.workerSrc=s,L.pdfjs.GlobalWorkerOptions.cMapUrl=o,L.pdfjs.GlobalWorkerOptions.cMapPacked=a}_();const me=({url:r,zoom:s,currentPage:o,onPageChange:a,onTotalPagesChange:n})=>{const[d,i]=t.useState(0),[l,c]=t.useState(null),p=t.useRef(null),x=t.useRef(new Map);t.useEffect(()=>{c(null)},[r]);const m=({numPages:h})=>{i(h),n(h),a(1)},v=h=>{console.error("PDF 加载错误:",h),c("PDF 文件加载失败")},f=t.useCallback(()=>{if(!p.current)return;const h=p.current,j=h.scrollTop,y=h.clientHeight,k=j+y/2;let u=1,M=1/0;x.current.forEach((C,w)=>{const T=C.getBoundingClientRect(),N=h.getBoundingClientRect(),P=T.top-N.top+T.height/2+j,R=Math.abs(P-k);R<M&&(M=R,u=w)}),u!==o&&a(u)},[o,a]);t.useEffect(()=>{const h=p.current;if(h)return h.addEventListener("scroll",f),()=>h.removeEventListener("scroll",f)},[f]);const g=t.useCallback((h,j)=>{j?x.current.set(h,j):x.current.delete(h)},[]);return e.jsxs("div",{ref:p,className:"flex flex-col items-center w-full h-full overflow-auto py-4 md:py-8 px-2 md:px-4",children:[l&&e.jsx("div",{className:"text-white/70 text-center",children:e.jsx("p",{className:"text-lg",children:l})}),!l&&e.jsx(L.Document,{file:r,onLoadSuccess:m,onLoadError:v,loading:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:e.jsx("div",{className:"w-12 h-12 border-4 border-white/20 border-t-white rounded-full animate-spin"})}),children:e.jsx("div",{className:"flex flex-col gap-4",children:Array.from(new Array(d),(h,j)=>{const y=j+1;return e.jsxs("div",{ref:k=>g(y,k),className:"relative",children:[e.jsx(L.Page,{pageNumber:y,scale:s,loading:e.jsx("div",{className:"flex items-center justify-center p-8 bg-white/5 rounded-lg min-h-[600px]",children:e.jsx("div",{className:"w-8 h-8 border-4 border-white/20 border-t-white rounded-full animate-spin"})}),renderTextLayer:!0,renderAnnotationLayer:!0,className:"shadow-2xl"}),e.jsx("div",{className:"absolute top-2 right-2 bg-black/60 backdrop-blur-sm text-white text-xs px-3 py-1 rounded-full",children:y})]},`page_${y}`)})})}),d>0&&e.jsxs("div",{className:"sticky bottom-2 md:bottom-4 mt-4 md:mt-8 bg-black/60 backdrop-blur-xl text-white px-4 py-2 md:px-6 md:py-3 rounded-full text-xs md:text-sm font-medium shadow-2xl border border-white/10",children:["第 ",o," 页 / 共 ",d," 页"]})]})},ue=({url:r})=>{const[s,o]=t.useState(""),[a,n]=t.useState(!0),[d,i]=t.useState(null);return t.useEffect(()=>{(async()=>{n(!0),i(null),o("");try{const c=await fetch(r);if(!c.ok)throw new Error("文件加载失败");const p=await c.arrayBuffer(),x=await te.convertToHtml({arrayBuffer:p});o(x.value)}catch(c){console.error("Docx 解析错误:",c),i("Word 文档解析失败")}finally{n(!1)}})()},[r]),a?e.jsx("div",{className:"flex items-center justify-center w-full h-full",children:e.jsx("div",{className:"w-12 h-12 border-4 border-white/20 border-t-white rounded-full animate-spin"})}):d?e.jsx("div",{className:"flex items-center justify-center w-full h-full",children:e.jsx("div",{className:"text-white/70 text-center",children:e.jsx("p",{className:"text-lg",children:d})})}):e.jsx("div",{className:"w-full h-full overflow-auto p-4 md:p-8",children:e.jsx("div",{className:"max-w-full md:max-w-4xl mx-auto bg-white rounded-lg shadow-2xl p-6 md:p-12",dangerouslySetInnerHTML:{__html:s},style:{fontFamily:"system-ui, -apple-system, sans-serif",lineHeight:"1.6",color:"#333"}})})},xe=({url:r})=>{const[s,o]=t.useState([]),[a,n]=t.useState(0),[d,i]=t.useState(!0),[l,c]=t.useState(null);if(t.useEffect(()=>{(async()=>{i(!0),c(null),o([]);try{const m=await fetch(r);if(!m.ok)throw new Error("文件加载失败");const v=await m.arrayBuffer(),f=X.read(v,{type:"array"}),g=f.SheetNames.map(h=>{const j=f.Sheets[h],y=X.utils.sheet_to_json(j,{header:1});return{name:h,data:y}});o(g),n(0)}catch(m){console.error("Excel 解析错误:",m),c("Excel 文件解析失败")}finally{i(!1)}})()},[r]),d)return e.jsx("div",{className:"flex items-center justify-center w-full h-full",children:e.jsx("div",{className:"w-12 h-12 border-4 border-white/20 border-t-white rounded-full animate-spin"})});if(l)return e.jsx("div",{className:"flex items-center justify-center w-full h-full",children:e.jsx("div",{className:"text-white/70 text-center",children:e.jsx("p",{className:"text-lg",children:l})})});const p=s[a];return e.jsxs("div",{className:"w-full h-full flex flex-col overflow-hidden",children:[s.length>1&&e.jsx("div",{className:"flex gap-1 md:gap-2 p-2 md:p-4 bg-black/20 backdrop-blur-sm overflow-x-auto border-b border-white/10 scrollbar-hide",children:s.map((x,m)=>e.jsx("button",{onClick:()=>n(m),className:`px-3 py-1.5 md:px-4 md:py-2 rounded-lg text-xs md:text-sm font-medium transition-all flex-shrink-0 ${a===m?"bg-gradient-to-r from-purple-500 to-pink-500 text-white shadow-lg":"bg-white/10 text-white hover:bg-white/20"}`,children:x.name},m))}),e.jsx("div",{className:"flex-1 overflow-auto p-2 md:p-8",children:e.jsx("div",{className:"inline-block min-w-full bg-gradient-to-br from-gray-800/90 to-gray-900/90 backdrop-blur-xl rounded-xl md:rounded-2xl shadow-2xl overflow-hidden border border-white/10",children:e.jsx("table",{className:"min-w-full divide-y divide-white/10",children:e.jsx("tbody",{className:"divide-y divide-white/10",children:p==null?void 0:p.data.map((x,m)=>e.jsx("tr",{className:`transition-colors ${m===0?"bg-gradient-to-r from-purple-500/20 to-pink-500/20 font-semibold":"hover:bg-white/5"}`,children:x.map((v,f)=>e.jsx("td",{className:"px-3 py-2 md:px-6 md:py-4 whitespace-nowrap text-xs md:text-sm text-gray-200 border-r border-white/10",children:String(v??"")},f))},m))})})})})]})},he=({url:r})=>{const[s,o]=t.useState(!0),[a,n]=t.useState(null),d=t.useRef(null),i=t.useRef(null),l=t.useRef(null),c=t.useRef(null),p=t.useRef(null),x=t.useRef({width:0,height:0}),m=t.useCallback(()=>{if(!d.current)return{width:960,height:540};const f=d.current.clientWidth,g=Math.floor(f*9/16);return console.log("计算尺寸:",{width:f,height:g}),{width:f,height:g}},[]),v=t.useCallback(async()=>{if(!(!d.current||!c.current)){console.log("重新初始化预览器...");try{if(i.current)try{i.current.destroy()}catch(h){console.error("销毁预览器失败:",h)}d.current.innerHTML="";const f=m();console.log("重新初始化使用尺寸:",f);const g=B.init(d.current,{width:f.width,height:f.height});i.current=g,await g.preview(c.current),console.log("重新初始化成功")}catch(f){console.error("重新初始化失败:",f)}}},[m]);return t.useEffect(()=>{if(!d.current)return;let f=!0;const g=()=>{if(f){f=!1;const u=m();x.current=u;return}const h=m(),j=x.current,y=Math.abs(j.width-h.width),k=Math.abs(j.height-h.height);if(y<10&&k<10){console.log("尺寸变化太小,忽略");return}console.log("检测到尺寸变化:",{old:j,new:h,diff:{width:y,height:k}}),x.current=h,p.current&&clearTimeout(p.current),p.current=window.setTimeout(()=>{i.current&&c.current&&(console.log("尺寸变化,准备重新初始化"),v())},800)};return l.current=new ResizeObserver(()=>{g()}),l.current.observe(d.current),()=>{l.current&&l.current.disconnect(),p.current&&clearTimeout(p.current)}},[m,v]),t.useEffect(()=>{let f=!0;const g=async()=>{if(!d.current){console.log("Container ref not ready");return}o(!0),n(null);try{console.log("开始加载 PPTX:",r);const j=await fetch(r);if(!j.ok)throw new Error("文件加载失败");const y=await j.arrayBuffer();if(c.current=y,console.log("文件加载成功,大小:",y.byteLength),!f)return;d.current&&(d.current.innerHTML="");const k=m();console.log("使用尺寸:",k),console.log("初始化预览器...");const u=B.init(d.current,{width:k.width,height:k.height});i.current=u,console.log("开始预览..."),u.preview(y).then(()=>{console.log("预览成功"),f&&o(!1)}).catch(M=>{console.error("预览失败:",M),f&&(n("PPT 文件预览失败"),o(!1))})}catch(j){console.error("PPTX 解析错误:",j),f&&(n(j instanceof Error?j.message:"PPT 文件解析失败"),o(!1))}},h=setTimeout(()=>{g()},100);return()=>{if(f=!1,clearTimeout(h),c.current=null,i.current)try{i.current.destroy()}catch(j){console.error("销毁预览器失败:",j)}i.current=null}},[r,m]),e.jsxs("div",{className:"relative flex flex-col items-center w-full h-full pt-2 px-2 md:px-4",children:[s&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 backdrop-blur-sm z-10 rounded-xl md:rounded-2xl",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-10 h-10 md:w-12 md:h-12 mx-auto mb-3 border-4 border-white/20 border-t-white rounded-full animate-spin"}),e.jsx("p",{className:"text-xs md:text-sm text-white/70 font-medium",children:"加载 PPT 中..."})]})}),a&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 backdrop-blur-sm z-10 rounded-xl md:rounded-2xl",children:e.jsxs("div",{className:"text-center max-w-sm md:max-w-md px-4",children:[e.jsx("div",{className:"w-24 h-24 md:w-32 md:h-32 mx-auto mb-4 md:mb-6 rounded-2xl md:rounded-3xl bg-gradient-to-br from-orange-500 via-red-500 to-pink-500 flex items-center justify-center shadow-2xl",children:e.jsx(S.Presentation,{className:"w-12 h-12 md:w-16 md:h-16 text-white"})}),e.jsx("p",{className:"text-lg md:text-xl text-white/90 mb-2 md:mb-3 font-medium",children:"PPT 预览"}),e.jsx("p",{className:"text-xs md:text-sm text-white/60 mb-4 md:mb-6",children:a||"浏览器暂不支持直接预览 PPT 文件"}),e.jsxs("a",{href:r,download:!0,className:"inline-flex items-center gap-2 px-4 py-2 md:px-6 md:py-3 bg-gradient-to-r from-purple-500 to-pink-500 text-white text-sm md:text-base rounded-lg md:rounded-xl hover:scale-105 transition-all shadow-lg",children:[e.jsx("svg",{className:"w-4 h-4 md:w-5 md:h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),"下载文件"]}),e.jsx("p",{className:"text-xs text-white/40 mt-3 md:mt-4",children:"提示:可以使用 Microsoft PowerPoint 或 WPS 打开"})]})}),e.jsx("div",{ref:d,className:"pptx-wrapper w-full max-w-full md:max-w-6xl"})]})},fe=r=>{var a;const s=((a=r.split(".").pop())==null?void 0:a.toLowerCase().split("?")[0])||"";return{mp4:"video/mp4",webm:"video/webm",ogg:"video/ogg",ogv:"video/ogg",mov:"video/quicktime",avi:"video/x-msvideo",mkv:"video/x-matroska",m4v:"video/mp4","3gp":"video/3gpp",flv:"video/x-flv"}[s]||"video/mp4"},pe=({url:r})=>{const[s,o]=t.useState(null),[a,n]=t.useState(!0),d=t.useRef(null),i=t.useRef(null);return t.useEffect(()=>{if(!i.current&&d.current){const l=document.createElement("video-js");l.classList.add("vjs-big-play-centered","vjs-theme-apple"),d.current.appendChild(l);const c=fe(r),x=re(l,{controls:!0,responsive:!0,fluid:!0,preload:"auto",controlBar:{children:["playToggle","volumePanel","currentTimeDisplay","timeDivider","durationDisplay","progressControl","remainingTimeDisplay","fullscreenToggle"],volumePanel:{inline:!1}},html5:{vhs:{overrideNative:!0},nativeVideoTracks:!1,nativeAudioTracks:!1,nativeTextTracks:!1},sources:c==="video/quicktime"?[{src:r,type:"video/quicktime"},{src:r,type:"video/mp4"}]:[{src:r,type:c}]});x.on("loadeddata",()=>{n(!1)}),x.on("error",()=>{const m=x.error();console.error("Video.js error:",m),o(`视频加载失败: ${(m==null?void 0:m.message)||"未知错误"}`),n(!1)}),i.current=x}},[r]),t.useEffect(()=>{const l=i.current;return()=>{l&&!l.isDisposed()&&(l.dispose(),i.current=null)}},[]),s?e.jsx("div",{className:"flex items-center justify-center w-full h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-red-500/10 flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),e.jsx("p",{className:"text-lg font-medium text-white/90 mb-2",children:"视频加载失败"}),e.jsx("p",{className:"text-sm text-white/60",children:s})]})}):e.jsx("div",{className:"flex items-center justify-center w-full h-full p-4 md:p-8",children:e.jsxs("div",{className:"w-full max-w-full md:max-w-5xl relative",children:[a&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/20 backdrop-blur-sm rounded-2xl z-10",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-3 border-3 border-white/20 border-t-white rounded-full animate-spin"}),e.jsx("p",{className:"text-sm text-white/70 font-medium",children:"加载视频中..."})]})}),e.jsx("div",{ref:d,className:"overflow-hidden",style:{boxShadow:"0 20px 60px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05)"}})]})})},we=({url:r,fileName:s})=>{const[o,a]=t.useState(null),[n,d]=t.useState(!1),[i,l]=t.useState(0),[c,p]=t.useState(0),[x,m]=t.useState(1),[v,f]=t.useState(!1),g=t.useRef(null);t.useEffect(()=>{const w=g.current;if(!w)return;const T=()=>{isNaN(w.currentTime)||l(w.currentTime)},N=()=>{!isNaN(w.duration)&&isFinite(w.duration)&&p(w.duration)},P=()=>d(!1),R=()=>N();return w.addEventListener("timeupdate",T),w.addEventListener("loadedmetadata",N),w.addEventListener("durationchange",N),w.addEventListener("canplay",R),w.addEventListener("ended",P),w.readyState>=1&&N(),()=>{w.removeEventListener("timeupdate",T),w.removeEventListener("loadedmetadata",N),w.removeEventListener("durationchange",N),w.removeEventListener("canplay",R),w.removeEventListener("ended",P)}},[]);const h=()=>{g.current&&(n?g.current.pause():g.current.play(),d(!n))},j=w=>{const T=parseFloat(w.target.value);l(T),g.current&&(g.current.currentTime=T)},y=w=>{const T=parseFloat(w.target.value);m(T),g.current&&(g.current.volume=T),T>0&&f(!1)},k=()=>{g.current&&(g.current.muted=!v,f(!v))},u=w=>{g.current&&(g.current.currentTime+=w)},M=w=>{if(!isFinite(w)||isNaN(w)||w<0)return"0:00";const T=Math.floor(w/60),N=Math.floor(w%60);return`${T}:${N.toString().padStart(2,"0")}`},C=()=>{a("音频加载失败")};return o?e.jsx("div",{className:"flex items-center justify-center w-full h-full",children:e.jsx("div",{className:"text-white/70 text-center",children:e.jsx("p",{className:"text-lg",children:o})})}):e.jsxs("div",{className:"flex flex-col items-center justify-center w-full h-full p-4 md:p-8 gap-4 md:gap-8",children:[e.jsx("div",{className:"w-48 h-48 md:w-64 md:h-64 rounded-3xl bg-gradient-to-br from-purple-500 via-pink-500 to-rose-500 flex items-center justify-center shadow-2xl backdrop-blur-xl",children:e.jsx(S.Music,{className:"w-24 h-24 md:w-32 md:h-32 text-white"})}),e.jsxs("div",{className:"text-white text-center max-w-sm md:max-w-md px-4",children:[e.jsx("p",{className:"text-xl md:text-2xl font-medium mb-1 truncate",children:s}),e.jsx("p",{className:"text-xs md:text-sm text-white/60",children:"音频文件"})]}),e.jsxs("div",{className:"w-full max-w-sm md:max-w-md bg-white/10 backdrop-blur-xl rounded-2xl p-4 md:p-6 border border-white/20",children:[e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"relative h-4 flex items-center",children:[e.jsx("div",{className:"absolute w-full h-[6px] bg-white/20 rounded-full"}),e.jsx("div",{className:"absolute h-[6px] bg-gradient-to-r from-purple-500 to-pink-500 rounded-full transition-all duration-100 ease-linear pointer-events-none",style:{width:`${c>0?i/c*100:i>100?100:i}%`}}),e.jsx("input",{type:"range",min:"0",max:c>0?c:100+(i>100?i%100:0),value:i,onChange:j,className:"audio-slider absolute w-full"})]}),e.jsxs("div",{className:"flex justify-between text-xs text-white/60 mt-3",children:[e.jsx("span",{children:M(i)}),e.jsx("span",{children:M(c)})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-4 mb-4",children:[e.jsx("button",{onClick:()=>u(-10),className:"w-10 h-10 rounded-full bg-white/10 hover:bg-white/20 flex items-center justify-center text-white transition-all",children:e.jsx(S.SkipBack,{className:"w-5 h-5"})}),e.jsx("button",{onClick:h,className:"w-14 h-14 rounded-full bg-gradient-to-br from-purple-500 to-pink-500 hover:scale-105 flex items-center justify-center text-white transition-all shadow-lg",children:n?e.jsx(S.Pause,{className:"w-6 h-6"}):e.jsx(S.Play,{className:"w-6 h-6 ml-1"})}),e.jsx("button",{onClick:()=>u(10),className:"w-10 h-10 rounded-full bg-white/10 hover:bg-white/20 flex items-center justify-center text-white transition-all",children:e.jsx(S.SkipForward,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:k,className:"text-white/80 hover:text-white transition-colors",children:v||x===0?e.jsx(S.VolumeX,{className:"w-5 h-5"}):e.jsx(S.Volume2,{className:"w-5 h-5"})}),e.jsxs("div",{className:"flex-1 relative h-3 flex items-center",children:[e.jsx("div",{className:"absolute w-full h-[4px] bg-white/20 rounded-full"}),e.jsx("div",{className:"absolute h-[4px] bg-purple-500 rounded-full transition-all duration-100 pointer-events-none",style:{width:`${(v?0:x)*100}%`}}),e.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:v?0:x,onChange:y,className:"volume-slider absolute w-full"})]})]})]}),e.jsx("audio",{ref:g,src:r,onError:C,className:"hidden"})]})},Z={'pre[class*="language-"]':{color:"#d4d4d4",fontSize:"13px",textShadow:"none",fontFamily:'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:".5em 0",overflow:"auto",background:"#1e1e1e"},'code[class*="language-"]':{color:"#d4d4d4",fontSize:"13px",textShadow:"none",fontFamily:'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]::selection':{textShadow:"none",background:"#264F78"},'code[class*="language-"]::selection':{textShadow:"none",background:"#264F78"},'pre[class*="language-"] *::selection':{textShadow:"none",background:"#264F78"},'code[class*="language-"] *::selection':{textShadow:"none",background:"#264F78"},':not(pre) > code[class*="language-"]':{padding:".1em .3em",borderRadius:".3em",color:"#db4c69",background:"#1e1e1e"},".namespace":{Opacity:".7"},"doctype.doctype-tag":{color:"#569CD6"},"doctype.name":{color:"#9cdcfe"},comment:{color:"#6a9955"},prolog:{color:"#6a9955"},punctuation:{color:"#d4d4d4"},".language-html .language-css .token.punctuation":{color:"#d4d4d4"},".language-html .language-javascript .token.punctuation":{color:"#d4d4d4"},property:{color:"#9cdcfe"},tag:{color:"#569cd6"},boolean:{color:"#569cd6"},number:{color:"#b5cea8"},constant:{color:"#9cdcfe"},symbol:{color:"#b5cea8"},inserted:{color:"#b5cea8"},unit:{color:"#b5cea8"},selector:{color:"#d7ba7d"},"attr-name":{color:"#9cdcfe"},string:{color:"#ce9178"},char:{color:"#ce9178"},builtin:{color:"#ce9178"},deleted:{color:"#ce9178"},".language-css .token.string.url":{textDecoration:"underline"},operator:{color:"#d4d4d4"},entity:{color:"#569cd6"},"operator.arrow":{color:"#569CD6"},atrule:{color:"#ce9178"},"atrule.rule":{color:"#c586c0"},"atrule.url":{color:"#9cdcfe"},"atrule.url.function":{color:"#dcdcaa"},"atrule.url.punctuation":{color:"#d4d4d4"},keyword:{color:"#569CD6"},"keyword.module":{color:"#c586c0"},"keyword.control-flow":{color:"#c586c0"},function:{color:"#dcdcaa"},"function.maybe-class-name":{color:"#dcdcaa"},regex:{color:"#d16969"},important:{color:"#569cd6"},italic:{fontStyle:"italic"},"class-name":{color:"#4ec9b0"},"maybe-class-name":{color:"#4ec9b0"},console:{color:"#9cdcfe"},parameter:{color:"#9cdcfe"},interpolation:{color:"#9cdcfe"},"punctuation.interpolation-punctuation":{color:"#569cd6"},variable:{color:"#9cdcfe"},"imports.maybe-class-name":{color:"#9cdcfe"},"exports.maybe-class-name":{color:"#9cdcfe"},escape:{color:"#d7ba7d"},"tag.punctuation":{color:"#808080"},cdata:{color:"#808080"},"attr-value":{color:"#ce9178"},"attr-value.punctuation":{color:"#ce9178"},"attr-value.punctuation.attr-equals":{color:"#d4d4d4"},namespace:{color:"#4ec9b0"},'pre[class*="language-javascript"]':{color:"#9cdcfe"},'code[class*="language-javascript"]':{color:"#9cdcfe"},'pre[class*="language-jsx"]':{color:"#9cdcfe"},'code[class*="language-jsx"]':{color:"#9cdcfe"},'pre[class*="language-typescript"]':{color:"#9cdcfe"},'code[class*="language-typescript"]':{color:"#9cdcfe"},'pre[class*="language-tsx"]':{color:"#9cdcfe"},'code[class*="language-tsx"]':{color:"#9cdcfe"},'pre[class*="language-css"]':{color:"#ce9178"},'code[class*="language-css"]':{color:"#ce9178"},'pre[class*="language-html"]':{color:"#d4d4d4"},'code[class*="language-html"]':{color:"#d4d4d4"},".language-regex .token.anchor":{color:"#dcdcaa"},".language-html .token.punctuation":{color:"#808080"},'pre[class*="language-"] > code[class*="language-"]':{position:"relative",zIndex:"1"},".line-highlight.line-highlight":{background:"#f7ebc6",boxShadow:"inset 5px 0 0 #f7d87c",zIndex:"0"}},ge=({url:r})=>{const[s,o]=t.useState(""),[a,n]=t.useState(!0),[d,i]=t.useState(null);return t.useEffect(()=>{(async()=>{try{n(!0),i(null);const c=await fetch(r);if(!c.ok)throw new Error("加载失败");const p=await c.text();o(p)}catch(c){i("Markdown 文件加载失败"),console.error(c)}finally{n(!1)}})()},[r]),a?e.jsx("div",{className:"flex items-center justify-center w-full h-full",children:e.jsx("div",{className:"w-12 h-12 border-4 border-white/20 border-t-white rounded-full animate-spin"})}):d?e.jsx("div",{className:"flex items-center justify-center w-full h-full",children:e.jsx("div",{className:"text-white/70 text-center",children:e.jsx("p",{className:"text-lg",children:d})})}):e.jsx("div",{className:"w-full h-full overflow-auto p-4 md:p-8",children:e.jsx("div",{className:"max-w-full md:max-w-4xl mx-auto bg-white/5 backdrop-blur-sm rounded-2xl p-4 md:p-8 border border-white/10",children:e.jsx("div",{className:"prose prose-invert prose-sm md:prose-lg max-w-none",children:e.jsx(le,{remarkPlugins:[oe],components:{code({node:l,inline:c,className:p,children:x,...m}){const v=/language-(\w+)/.exec(p||"");return!c&&v?e.jsx(A.Prism,{style:Z,language:v[1],PreTag:"div",className:"rounded-lg",...m,children:String(x).replace(/\n$/,"")}):e.jsx("code",{className:"bg-white/10 px-1.5 py-0.5 rounded text-sm",...m,children:x})},h1:({children:l})=>e.jsx("h1",{className:"text-4xl font-bold mb-4 text-white border-b border-white/20 pb-2",children:l}),h2:({children:l})=>e.jsx("h2",{className:"text-3xl font-bold mb-3 text-white mt-8",children:l}),h3:({children:l})=>e.jsx("h3",{className:"text-2xl font-bold mb-2 text-white mt-6",children:l}),p:({children:l})=>e.jsx("p",{className:"text-white/90 mb-4 leading-relaxed",children:l}),a:({href:l,children:c})=>e.jsx("a",{href:l,className:"text-blue-400 hover:text-blue-300 underline",target:"_blank",rel:"noopener noreferrer",children:c}),ul:({children:l})=>e.jsx("ul",{className:"list-disc list-inside mb-4 text-white/90",children:l}),ol:({children:l})=>e.jsx("ol",{className:"list-decimal list-inside mb-4 text-white/90",children:l}),li:({children:l})=>e.jsx("li",{className:"mb-1",children:l}),blockquote:({children:l})=>e.jsx("blockquote",{className:"border-l-4 border-blue-500 pl-4 italic text-white/80 my-4",children:l}),table:({children:l})=>e.jsx("div",{className:"overflow-x-auto my-4",children:e.jsx("table",{className:"min-w-full border border-white/20",children:l})}),th:({children:l})=>e.jsx("th",{className:"border border-white/20 px-4 py-2 bg-white/10 text-white font-semibold",children:l}),td:({children:l})=>e.jsx("td",{className:"border border-white/20 px-4 py-2 text-white/90",children:l}),hr:()=>e.jsx("hr",{className:"border-white/20 my-6"}),img:({src:l,alt:c})=>e.jsx("img",{src:l,alt:c,className:"rounded-lg max-w-full h-auto my-4"})},children:s})})})})},be=r=>{var a;const s=((a=r.split(".").pop())==null?void 0:a.toLowerCase())||"";return{js:"javascript",jsx:"jsx",ts:"typescript",tsx:"tsx",py:"python",java:"java",cpp:"cpp",c:"c",cs:"csharp",php:"php",rb:"ruby",go:"go",rs:"rust",swift:"swift",kt:"kotlin",scala:"scala",sh:"bash",bash:"bash",zsh:"bash",json:"json",xml:"xml",html:"html",css:"css",scss:"scss",sass:"sass",less:"less",sql:"sql",yaml:"yaml",yml:"yaml",toml:"toml",ini:"ini",conf:"nginx",md:"markdown",txt:"text"}[s]||"text"},je=({url:r,fileName:s})=>{const[o,a]=t.useState(""),[n,d]=t.useState(!0),[i,l]=t.useState(null),c=be(s);return t.useEffect(()=>{(async()=>{try{d(!0),l(null);const x=await fetch(r);if(!x.ok)throw new Error("加载失败");const m=await x.text();a(m)}catch(x){l("文本文件加载失败"),console.error(x)}finally{d(!1)}})()},[r]),n?e.jsx("div",{className:"flex items-center justify-center w-full h-full",children:e.jsx("div",{className:"w-12 h-12 border-4 border-white/20 border-t-white rounded-full animate-spin"})}):i?e.jsx("div",{className:"flex items-center justify-center w-full h-full",children:e.jsx("div",{className:"text-white/70 text-center",children:e.jsx("p",{className:"text-lg",children:i})})}):e.jsx("div",{className:"w-full h-full overflow-auto p-4 md:p-8",children:e.jsxs("div",{className:"max-w-full md:max-w-6xl mx-auto bg-white/5 backdrop-blur-sm rounded-2xl border border-white/10 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 md:gap-3 px-4 py-3 md:px-6 md:py-4 bg-white/5 border-b border-white/10",children:[e.jsx(S.FileText,{className:"w-4 h-4 md:w-5 md:h-5 text-white/70 flex-shrink-0"}),e.jsx("span",{className:"text-white font-medium text-sm md:text-base truncate",children:s}),e.jsx("span",{className:"ml-auto text-xs text-white/50 uppercase flex-shrink-0",children:c})]}),e.jsx("div",{className:"text-sm",children:c==="text"?e.jsx("pre",{className:"p-6 text-white/90 font-mono whitespace-pre-wrap break-words",children:o}):e.jsx(A.Prism,{language:c,style:Z,showLineNumbers:!0,customStyle:{margin:0,padding:"1.5rem",background:"transparent",fontSize:"0.875rem"},lineNumberStyle:{minWidth:"3em",paddingRight:"1em",color:"rgba(255, 255, 255, 0.3)",userSelect:"none"},children:o})})]})})},ve=({fileName:r,fileType:s,onDownload:o})=>e.jsxs("div",{className:"flex flex-col items-center justify-center w-full h-full p-8 gap-6",children:[e.jsx("div",{className:"w-32 h-32 rounded-full bg-white/10 flex items-center justify-center",children:e.jsx(S.FileQuestion,{className:"w-16 h-16 text-white/70"})}),e.jsxs("div",{className:"text-white text-center",children:[e.jsx("p",{className:"text-xl font-medium mb-2",children:r}),e.jsxs("p",{className:"text-white/70",children:["不支持预览此文件类型 (",s,")"]})]}),e.jsxs("button",{onClick:o,className:"flex items-center gap-2 px-6 py-3 bg-white/10 hover:bg-white/20 backdrop-blur-sm rounded-lg text-white font-medium transition-all",children:[e.jsx(S.Download,{className:"w-5 h-5"}),"下载文件查看"]})]}),ye=r=>{var n;const s=((n=r.name.split(".").pop())==null?void 0:n.toLowerCase())||"",o=r.type.toLowerCase();if(o.startsWith("image/")||["jpg","jpeg","png","gif","webp","svg"].includes(s))return"image";if(o.includes("pdf")||s==="pdf")return"pdf";if(o.includes("wordprocessingml")||s==="docx")return"docx";if(o.includes("spreadsheetml")||s==="xlsx")return"xlsx";if(o.includes("presentationml")||s==="pptx"||s==="ppt")return"pptx";if(o.startsWith("video/")||["mp4","webm","ogg","ogv","mov","avi","mkv","m4v","3gp","flv"].includes(s))return"video";if(o.startsWith("audio/")||["mp3","wav","ogg","m4a","flac","aac"].includes(s))return"audio";if(s==="md"||s==="markdown")return"markdown";const a=["txt","log","csv","js","jsx","ts","tsx","json","py","java","cpp","c","h","cs","php","rb","go","rs","swift","kt","html","css","scss","sass","less","xml","yaml","yml","toml","ini","conf","sh","bash","zsh","sql"];return o.startsWith("text/")||a.includes(s)?"text":"unsupported"},ke=({files:r,currentIndex:s,isOpen:o,onClose:a,onNavigate:n,customRenderers:d=[]})=>{const[i,l]=t.useState(1),[c,p]=t.useState(0),[x,m]=t.useState(1),[,v]=t.useState(1),[f,g]=t.useState(null),[h,j]=t.useState(null),y=50,k=t.useMemo(()=>V(r),[r]),u=k[s],M=t.useMemo(()=>u?d.find(b=>b.test(u)):null,[u,d]),C=u?ye(u):"unsupported";t.useEffect(()=>{l(1),p(0),m(1),v(1)},[s]),t.useEffect(()=>{if(o){const b=document.body.style.overflow,D=document.body.style.paddingRight,$=window.innerWidth-document.documentElement.clientWidth;return document.body.style.overflow="hidden",$>0&&(document.body.style.paddingRight=`${$}px`),()=>{document.body.style.overflow=b,document.body.style.paddingRight=D}}},[o]),t.useEffect(()=>{if(!o)return;const b=D=>{D.key==="Escape"?a():D.key==="ArrowLeft"&&s>0?n==null||n(s-1):D.key==="ArrowRight"&&s<k.length-1&&(n==null||n(s+1))};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[o,s,k.length,a,n]);const w=t.useCallback(()=>{l(b=>Math.min(b+.25,5))},[]),T=t.useCallback(()=>{l(b=>Math.max(b-.25,.5))},[]),N=t.useCallback(()=>{p(b=>b+90)},[]),P=t.useCallback(()=>{p(b=>b-90)},[]),R=t.useCallback(()=>{l(1),p(0)},[]),F=t.useCallback(()=>{l(1)},[]),G=t.useCallback(b=>{l(b)},[]),Y=t.useCallback(()=>{l(1),p(0)},[]),W=t.useCallback(()=>{if(!u)return;const b=document.createElement("a");b.href=u.url,b.download=u.name,b.click()},[u]),J=t.useCallback(b=>{j(null),g(b.targetTouches[0].clientX)},[]),K=t.useCallback(b=>{j(b.targetTouches[0].clientX)},[]),Q=t.useCallback(()=>{if(!f||!h)return;const b=f-h,D=b>y,$=b<-y;D&&s<k.length-1&&(n==null||n(s+1)),$&&s>0&&(n==null||n(s-1))},[f,h,y,s,k.length,n]);if(!o||!u)return null;const O=C==="image"||C==="pdf",H=C==="image",I=e.jsx(z.AnimatePresence,{children:o&&e.jsx(z.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/80 backdrop-blur-md overflow-hidden",onClick:a,onWheel:b=>b.stopPropagation(),children:e.jsxs("div",{className:"relative w-full h-full flex flex-col overflow-hidden",onClick:b=>b.stopPropagation(),children:[e.jsx(z.motion.div,{initial:{y:-100},animate:{y:0},exit:{y:-100},className:"absolute top-0 left-0 right-0 z-10 p-4",children:e.jsxs("div",{className:"max-w-7xl mx-auto flex flex-col md:flex-row md:items-center md:justify-between bg-black/40 backdrop-blur-xl rounded-2xl px-3 md:px-6 py-3 md:py-4 shadow-2xl border border-white/10 gap-2 md:gap-0",children:[e.jsxs("div",{className:"flex items-center justify-between md:flex-1 md:min-w-0 md:mr-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:"text-white font-medium text-sm md:text-lg truncate",children:u.name}),e.jsxs("p",{className:"text-white/60 text-xs md:text-sm",children:[s+1," / ",k.length]})]}),e.jsx("div",{className:"md:hidden ml-2",children:e.jsx(E,{icon:e.jsx(S.X,{className:"w-5 h-5"}),label:"关闭",onClick:a})})]}),e.jsxs("div",{className:"flex items-center gap-1 md:gap-2 overflow-x-auto scrollbar-hide flex-shrink-0",children:[O&&e.jsxs(e.Fragment,{children:[e.jsx(E,{icon:e.jsx(S.ZoomOut,{className:"w-5 h-5"}),label:"缩小",onClick:T,disabled:i<=.5}),e.jsxs("span",{className:"text-white/70 text-sm min-w-[4rem] text-center font-medium",children:[Math.round(i*100),"%"]}),e.jsx(E,{icon:e.jsx(S.ZoomIn,{className:"w-5 h-5"}),label:"放大",onClick:w,disabled:i>=5}),e.jsx("div",{className:"w-px h-6 bg-white/20 mx-2"}),e.jsx(E,{icon:e.jsx(S.Minimize2,{className:"w-5 h-5"}),label:"适应窗口",onClick:R}),e.jsx(E,{icon:e.jsx(S.Maximize2,{className:"w-5 h-5"}),label:"原始尺寸",onClick:F}),e.jsx("div",{className:"w-px h-6 bg-white/20 mx-2"})]}),H&&e.jsxs(e.Fragment,{children:[e.jsx(E,{icon:e.jsx(S.RotateCcw,{className:"w-5 h-5"}),label:"向左旋转",onClick:P}),e.jsx(E,{icon:e.jsx(S.RotateCw,{className:"w-5 h-5"}),label:"向右旋转",onClick:N}),e.jsx("div",{className:"w-px h-6 bg-white/20 mx-2"})]}),(O||H)&&e.jsxs(e.Fragment,{children:[e.jsx(E,{icon:e.jsx(S.RefreshCw,{className:"w-5 h-5"}),label:"复原",onClick:Y}),e.jsx("div",{className:"w-px h-6 bg-white/20 mx-2"})]}),e.jsx(E,{icon:e.jsx(S.Download,{className:"w-5 h-5"}),label:"下载",onClick:W}),e.jsxs("div",{className:"hidden md:flex items-center",children:[e.jsx("div",{className:"w-px h-6 bg-white/20 mx-2"}),e.jsx(E,{icon:e.jsx(S.X,{className:"w-5 h-5"}),label:"关闭",onClick:a})]})]})]})}),e.jsx("div",{className:"flex-1 flex items-center justify-center pt-32 md:pt-24 pb-4 md:pb-8 overflow-auto",onTouchStart:J,onTouchMove:K,onTouchEnd:Q,children:M?M.render(u):e.jsxs(e.Fragment,{children:[C==="image"&&e.jsx(de,{url:u.url,zoom:i,rotation:c,onZoomChange:G}),C==="pdf"&&e.jsx(me,{url:u.url,zoom:i,currentPage:x,onPageChange:m,onTotalPagesChange:v}),C==="docx"&&e.jsx(ue,{url:u.url}),C==="xlsx"&&e.jsx(xe,{url:u.url}),C==="pptx"&&e.jsx(he,{url:u.url}),C==="video"&&e.jsx(pe,{url:u.url}),C==="audio"&&e.jsx(we,{url:u.url,fileName:u.name}),C==="markdown"&&e.jsx(ge,{url:u.url}),C==="text"&&e.jsx(je,{url:u.url,fileName:u.name}),C==="unsupported"&&e.jsx(ve,{fileName:u.name,fileType:u.type,onDownload:W})]})}),k.length>1&&e.jsxs(e.Fragment,{children:[s>0&&e.jsx(z.motion.button,{initial:{x:-100,opacity:0},animate:{x:0,opacity:1},exit:{x:-100,opacity:0},onClick:()=>n==null?void 0:n(s-1),className:"absolute left-2 md:left-4 top-1/2 -translate-y-1/2 w-10 h-10 md:w-12 md:h-12 rounded-full bg-black/40 backdrop-blur-xl border border-white/10 flex items-center justify-center text-white hover:bg-black/60 transition-all shadow-2xl",children:e.jsx(S.ChevronLeft,{className:"w-5 h-5 md:w-6 md:h-6"})}),s<k.length-1&&e.jsx(z.motion.button,{initial:{x:100,opacity:0},animate:{x:0,opacity:1},exit:{x:100,opacity:0},onClick:()=>n==null?void 0:n(s+1),className:"absolute right-2 md:right-4 top-1/2 -translate-y-1/2 w-10 h-10 md:w-12 md:h-12 rounded-full bg-black/40 backdrop-blur-xl border border-white/10 flex items-center justify-center text-white hover:bg-black/60 transition-all shadow-2xl",children:e.jsx(S.ChevronRight,{className:"w-5 h-5 md:w-6 md:h-6"})})]})]})})});return ee.createPortal(I,document.body)},E=({icon:r,label:s,onClick:o,disabled:a})=>e.jsx("button",{onClick:o,disabled:a,title:s,className:`p-2 rounded-lg transition-all ${a?"text-white/30 cursor-not-allowed":"text-white hover:bg-white/10 active:bg-white/20"}`,children:r}),Ne=ce.version;Object.defineProperty(exports,"pdfjs",{enumerable:!0,get:()=>L.pdfjs});exports.FilePreviewModal=ke;exports.VERSION=Ne;exports.configurePdfjs=_;exports.normalizeFile=U;exports.normalizeFiles=V;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),ee=require("react-dom"),z=require("framer-motion"),S=require("lucide-react"),L=require("react-pdf"),re=require("mammoth"),te=require("xlsx"),B=require("pptx-preview"),se=require("video.js"),le=require("react-markdown"),oe=require("remark-gfm"),A=require("react-syntax-highlighter");function ne(s){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const o in s)if(o!=="default"){const f=Object.getOwnPropertyDescriptor(s,o);Object.defineProperty(t,o,f.get?f:{enumerable:!0,get:()=>s[o]})}}return t.default=s,Object.freeze(t)}const X=ne(te),fe="1.0.5",pe={version:fe};function ae(s){try{const f=new URL(s).pathname.split("/").pop()||"file";return decodeURIComponent(f)}catch{const t=s.split("/").pop()||"file";return decodeURIComponent(t)}}function q(s){var f;const t=((f=s.split(".").pop())==null?void 0:f.toLowerCase())||"";return{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",bmp:"image/bmp",ico:"image/x-icon",mp4:"video/mp4",webm:"video/webm",ogg:"video/ogg",ogv:"video/ogg",mov:"video/quicktime",avi:"video/x-msvideo",mkv:"video/x-matroska",m4v:"video/x-m4v","3gp":"video/3gpp",flv:"video/x-flv",mp3:"audio/mpeg",wav:"audio/wav",m4a:"audio/mp4",aac:"audio/aac",flac:"audio/flac",pdf:"application/pdf",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",ppt:"application/vnd.ms-powerpoint",txt:"text/plain",md:"text/markdown",markdown:"text/markdown",json:"application/json",xml:"application/xml",html:"text/html",css:"text/css",js:"text/javascript",ts:"text/typescript",jsx:"text/javascript",tsx:"text/typescript",py:"text/x-python",java:"text/x-java",cpp:"text/x-c++src",c:"text/x-csrc",cs:"text/x-csharp",php:"text/x-php",rb:"text/x-ruby",go:"text/x-go",rs:"text/x-rust",yaml:"text/yaml",yml:"text/yaml"}[t]||"application/octet-stream"}function U(s,t=0){if(s instanceof File)return{id:`file-${Date.now()}-${t}`,name:s.name,url:URL.createObjectURL(s),type:s.type||q(s.name),size:s.size};if(typeof s=="string"){const o=ae(s);return{id:`url-${Date.now()}-${t}`,name:o,url:s,type:q(o)}}return{id:s.id||`link-${Date.now()}-${t}`,name:s.name,url:s.url,type:s.type||q(s.name),size:s.size}}function V(s){return s.map((t,o)=>U(t,o))}const ce=({url:s,zoom:t,rotation:o,onZoomChange:f})=>{const[n,c]=r.useState(!1),[a,l]=r.useState(null),[p,h]=r.useState({x:0,y:0}),[m,i]=r.useState(!1),[v,x]=r.useState({x:0,y:0}),[g,u]=r.useState(1),j=r.useRef(null);r.useEffect(()=>{c(!1),l(null),h({x:0,y:0}),u(1)},[s]),r.useEffect(()=>{u(t)},[t]),r.useEffect(()=>{h({x:0,y:0})},[t,o]);const y=()=>{c(!0)},k=()=>{l("图片加载失败"),c(!0)},d=()=>{h({x:0,y:0})},M=r.useCallback(N=>{N.preventDefault(),N.stopPropagation();const P=N.deltaY>0?-.1:.1;u(R=>{const F=Math.max(.01,Math.min(10,R+P));return f&&f(F),F})},[f]),C=r.useCallback(N=>{N.button===0&&(i(!0),x({x:N.clientX-p.x,y:N.clientY-p.y}))},[p]),w=r.useCallback(N=>{m&&h({x:N.clientX-v.x,y:N.clientY-v.y})},[m,v]),T=r.useCallback(()=>{i(!1)},[]);return e.jsxs("div",{ref:j,className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full rfp-overflow-hidden",onWheel:M,onMouseDown:C,onMouseMove:w,onMouseUp:T,onMouseLeave:T,style:{cursor:m?"grabbing":"grab"},children:[!n&&!a&&e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center",children:e.jsx("div",{className:"rfp-w-12 rfp-h-12 rfp-border-4 rfp-border-white/20 rfp-border-t-white rfp-rounded-full rfp-animate-spin"})}),a&&e.jsx("div",{className:"rfp-text-white/70 rfp-text-center",children:e.jsx("p",{className:"rfp-text-lg",children:a})}),e.jsx(z.motion.img,{src:s,alt:"Preview",className:`rfp-max-w-none rfp-select-none ${n?"":"rfp-hidden"}`,style:{transform:`translate(${p.x}px, ${p.y}px) scale(${g}) rotate(${o}deg)`,transformOrigin:"center",transition:m?"none":"transform 0.3s ease-out"},onLoad:y,onError:k,onDoubleClick:d,initial:{opacity:0},animate:{opacity:n?1:0},transition:{duration:.3},draggable:!1})]})};function _(s){if(typeof window>"u")return;const{workerSrc:t=`https://unpkg.com/pdfjs-dist@${L.pdfjs.version}/build/pdf.worker.min.mjs`,cMapUrl:o=`https://unpkg.com/pdfjs-dist@${L.pdfjs.version}/cmaps/`,cMapPacked:f=!0}=s||{};L.pdfjs.GlobalWorkerOptions.workerSrc=t,L.pdfjs.GlobalWorkerOptions.cMapUrl=o,L.pdfjs.GlobalWorkerOptions.cMapPacked=f}_();const ie=({url:s,zoom:t,currentPage:o,onPageChange:f,onTotalPagesChange:n})=>{const[c,a]=r.useState(0),[l,p]=r.useState(null),h=r.useRef(null),m=r.useRef(new Map);r.useEffect(()=>{p(null)},[s]);const i=({numPages:u})=>{a(u),n(u),f(1)},v=u=>{console.error("PDF 加载错误:",u),p("PDF 文件加载失败")},x=r.useCallback(()=>{if(!h.current)return;const u=h.current,j=u.scrollTop,y=u.clientHeight,k=j+y/2;let d=1,M=1/0;m.current.forEach((C,w)=>{const T=C.getBoundingClientRect(),N=u.getBoundingClientRect(),P=T.top-N.top+T.height/2+j,R=Math.abs(P-k);R<M&&(M=R,d=w)}),d!==o&&f(d)},[o,f]);r.useEffect(()=>{const u=h.current;if(u)return u.addEventListener("scroll",x),()=>u.removeEventListener("scroll",x)},[x]);const g=r.useCallback((u,j)=>{j?m.current.set(u,j):m.current.delete(u)},[]);return e.jsxs("div",{ref:h,className:"rfp-flex rfp-flex-col rfp-items-center rfp-w-full rfp-h-full rfp-overflow-auto rfp-py-4 md:rfp-py-8 rfp-px-2 md:rfp-px-4",children:[l&&e.jsx("div",{className:"rfp-text-white/70 rfp-text-center",children:e.jsx("p",{className:"rfp-text-lg",children:l})}),!l&&e.jsx(L.Document,{file:s,onLoadSuccess:i,onLoadError:v,loading:e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-min-h-screen",children:e.jsx("div",{className:"rfp-w-12 rfp-h-12 rfp-border-4 rfp-border-white/20 rfp-border-t-white rfp-rounded-full rfp-animate-spin"})}),children:e.jsx("div",{className:"rfp-flex rfp-flex-col rfp-gap-4",children:Array.from(new Array(c),(u,j)=>{const y=j+1;return e.jsxs("div",{ref:k=>g(y,k),className:"rfp-relative",children:[e.jsx(L.Page,{pageNumber:y,scale:t,loading:e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-p-8 rfp-bg-white/5 rfp-rounded-lg rfp-min-h-[600px]",children:e.jsx("div",{className:"rfp-w-8 rfp-h-8 rfp-border-4 rfp-border-white/20 rfp-border-t-white rfp-rounded-full rfp-animate-spin"})}),renderTextLayer:!0,renderAnnotationLayer:!0,className:"rfp-shadow-2xl"}),e.jsx("div",{className:"rfp-absolute rfp-top-2 rfp-right-2 rfp-bg-black/60 rfp-backdrop-blur-sm rfp-text-white rfp-text-xs rfp-px-3 rfp-py-1 rfp-rounded-full",children:y})]},`page_${y}`)})})}),c>0&&e.jsxs("div",{className:"rfp-sticky rfp-bottom-2 md:rfp-bottom-4 rfp-mt-4 md:rfp-mt-8 rfp-bg-black/60 rfp-backdrop-blur-xl rfp-text-white rfp-px-4 rfp-py-2 md:rfp-px-6 md:rfp-py-3 rfp-rounded-full rfp-text-xs md:rfp-text-sm rfp-font-medium rfp-shadow-2xl rfp-border rfp-border-white/10",children:["第 ",o," 页 / 共 ",c," 页"]})]})},de=({url:s})=>{const[t,o]=r.useState(""),[f,n]=r.useState(!0),[c,a]=r.useState(null);return r.useEffect(()=>{(async()=>{n(!0),a(null),o("");try{const p=await fetch(s);if(!p.ok)throw new Error("文件加载失败");const h=await p.arrayBuffer(),m=await re.convertToHtml({arrayBuffer:h});o(m.value)}catch(p){console.error("Docx 解析错误:",p),a("Word 文档解析失败")}finally{n(!1)}})()},[s]),f?e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:e.jsx("div",{className:"rfp-w-12 rfp-h-12 rfp-border-4 rfp-border-white/20 rfp-border-t-white rfp-rounded-full rfp-animate-spin"})}):c?e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:e.jsx("div",{className:"rfp-text-white/70 rfp-text-center",children:e.jsx("p",{className:"rfp-text-lg",children:c})})}):e.jsx("div",{className:"rfp-w-full rfp-h-full rfp-overflow-auto rfp-p-4 md:rfp-p-8",children:e.jsx("div",{className:"rfp-max-w-full md:rfp-max-w-4xl rfp-mx-auto rfp-bg-white rfp-rounded-lg rfp-shadow-2xl rfp-p-6 md:rfp-p-12",dangerouslySetInnerHTML:{__html:t},style:{fontFamily:"system-ui, -apple-system, sans-serif",lineHeight:"1.6",color:"#333"}})})},me=({url:s})=>{const[t,o]=r.useState([]),[f,n]=r.useState(0),[c,a]=r.useState(!0),[l,p]=r.useState(null);if(r.useEffect(()=>{(async()=>{a(!0),p(null),o([]);try{const i=await fetch(s);if(!i.ok)throw new Error("文件加载失败");const v=await i.arrayBuffer(),x=X.read(v,{type:"array"}),g=x.SheetNames.map(u=>{const j=x.Sheets[u],y=X.utils.sheet_to_json(j,{header:1});return{name:u,data:y}});o(g),n(0)}catch(i){console.error("Excel 解析错误:",i),p("Excel 文件解析失败")}finally{a(!1)}})()},[s]),c)return e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:e.jsx("div",{className:"rfp-w-12 rfp-h-12 rfp-border-4 rfp-border-white/20 rfp-border-t-white rfp-rounded-full rfp-animate-spin"})});if(l)return e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:e.jsx("div",{className:"rfp-text-white/70 rfp-text-center",children:e.jsx("p",{className:"rfp-text-lg",children:l})})});const h=t[f];return e.jsxs("div",{className:"rfp-w-full rfp-h-full rfp-flex rfp-flex-col rfp-overflow-hidden",children:[t.length>1&&e.jsx("div",{className:"rfp-flex rfp-gap-1 md:rfp-gap-2 rfp-p-2 md:rfp-p-4 rfp-bg-black/20 rfp-backdrop-blur-sm rfp-overflow-x-auto rfp-border-b rfp-border-white/10 scrollbar-hide",children:t.map((m,i)=>e.jsx("button",{onClick:()=>n(i),className:`rfp-px-3 rfp-py-1.5 md:rfp-px-4 md:rfp-py-2 rfp-rounded-lg rfp-text-xs md:rfp-text-sm rfp-font-medium rfp-transition-all rfp-flex-shrink-0 ${f===i?"rfp-bg-gradient-to-r rfp-from-purple-500 rfp-to-pink-500 rfp-text-white rfp-shadow-lg":"rfp-bg-white/10 rfp-text-white hover:rfp-bg-white/20"}`,children:m.name},i))}),e.jsx("div",{className:"rfp-flex-1 rfp-overflow-auto rfp-p-2 md:rfp-p-8",children:e.jsx("div",{className:"rfp-inline-block rfp-min-w-full rfp-bg-gradient-to-br rfp-from-gray-800/90 rfp-to-gray-900/90 rfp-backdrop-blur-xl rfp-rounded-xl md:rfp-rounded-2xl rfp-shadow-2xl rfp-overflow-hidden rfp-border rfp-border-white/10",children:e.jsx("table",{className:"rfp-min-w-full rfp-divide-y rfp-divide-white/10",children:e.jsx("tbody",{className:"rfp-divide-y rfp-divide-white/10",children:h==null?void 0:h.data.map((m,i)=>e.jsx("tr",{className:`rfp-transition-colors ${i===0?"rfp-bg-gradient-to-r rfp-from-purple-500/20 rfp-to-pink-500/20 rfp-font-semibold":"hover:rfp-bg-white/5"}`,children:m.map((v,x)=>e.jsx("td",{className:"rfp-px-3 rfp-py-2 md:rfp-px-6 md:rfp-py-4 rfp-whitespace-nowrap rfp-text-xs md:rfp-text-sm rfp-text-gray-200 rfp-border-r rfp-border-white/10",children:String(v??"")},x))},i))})})})})]})},ue=({url:s})=>{const[t,o]=r.useState(!0),[f,n]=r.useState(null),c=r.useRef(null),a=r.useRef(null),l=r.useRef(null),p=r.useRef(null),h=r.useRef(null),m=r.useRef({width:0,height:0}),i=r.useCallback(()=>{if(!c.current)return{width:960,height:540};const x=c.current.clientWidth,g=Math.floor(x*9/16);return console.log("计算尺寸:",{width:x,height:g}),{width:x,height:g}},[]),v=r.useCallback(async()=>{if(!(!c.current||!p.current)){console.log("重新初始化预览器...");try{if(a.current)try{a.current.destroy()}catch(u){console.error("销毁预览器失败:",u)}c.current.innerHTML="";const x=i();console.log("重新初始化使用尺寸:",x);const g=B.init(c.current,{width:x.width,height:x.height});a.current=g,await g.preview(p.current),console.log("重新初始化成功")}catch(x){console.error("重新初始化失败:",x)}}},[i]);return r.useEffect(()=>{if(!c.current)return;let x=!0;const g=()=>{if(x){x=!1;const d=i();m.current=d;return}const u=i(),j=m.current,y=Math.abs(j.width-u.width),k=Math.abs(j.height-u.height);if(y<10&&k<10){console.log("尺寸变化太小,忽略");return}console.log("检测到尺寸变化:",{old:j,new:u,diff:{width:y,height:k}}),m.current=u,h.current&&clearTimeout(h.current),h.current=window.setTimeout(()=>{a.current&&p.current&&(console.log("尺寸变化,准备重新初始化"),v())},800)};return l.current=new ResizeObserver(()=>{g()}),l.current.observe(c.current),()=>{l.current&&l.current.disconnect(),h.current&&clearTimeout(h.current)}},[i,v]),r.useEffect(()=>{let x=!0;const g=async()=>{if(!c.current){console.log("Container ref not ready");return}o(!0),n(null);try{console.log("开始加载 PPTX:",s);const j=await fetch(s);if(!j.ok)throw new Error("文件加载失败");const y=await j.arrayBuffer();if(p.current=y,console.log("文件加载成功,大小:",y.byteLength),!x)return;c.current&&(c.current.innerHTML="");const k=i();console.log("使用尺寸:",k),console.log("初始化预览器...");const d=B.init(c.current,{width:k.width,height:k.height});a.current=d,console.log("开始预览..."),d.preview(y).then(()=>{console.log("预览成功"),x&&o(!1)}).catch(M=>{console.error("预览失败:",M),x&&(n("PPT 文件预览失败"),o(!1))})}catch(j){console.error("PPTX 解析错误:",j),x&&(n(j instanceof Error?j.message:"PPT 文件解析失败"),o(!1))}},u=setTimeout(()=>{g()},100);return()=>{if(x=!1,clearTimeout(u),p.current=null,a.current)try{a.current.destroy()}catch(j){console.error("销毁预览器失败:",j)}a.current=null}},[s,i]),e.jsxs("div",{className:"rfp-relative rfp-flex rfp-flex-col rfp-items-center rfp-w-full rfp-h-full rfp-pt-2 rfp-px-2 md:rfp-px-4",children:[t&&e.jsx("div",{className:"rfp-absolute rfp-inset-0 rfp-flex rfp-items-center rfp-justify-center rfp-bg-black/50 rfp-backdrop-blur-sm rfp-z-10 rfp-rounded-xl md:rfp-rounded-2xl",children:e.jsxs("div",{className:"rfp-text-center",children:[e.jsx("div",{className:"rfp-w-10 rfp-h-10 md:rfp-w-12 md:rfp-h-12 rfp-mx-auto rfp-mb-3 rfp-border-4 rfp-border-white/20 rfp-border-t-white rfp-rounded-full rfp-animate-spin"}),e.jsx("p",{className:"rfp-text-xs md:rfp-text-sm rfp-text-white/70 rfp-font-medium",children:"加载 PPT 中..."})]})}),f&&e.jsx("div",{className:"rfp-absolute rfp-inset-0 rfp-flex rfp-items-center rfp-justify-center rfp-bg-black/50 rfp-backdrop-blur-sm rfp-z-10 rfp-rounded-xl md:rfp-rounded-2xl",children:e.jsxs("div",{className:"rfp-text-center rfp-max-w-sm md:rfp-max-w-md rfp-px-4",children:[e.jsx("div",{className:"rfp-w-24 rfp-h-24 md:rfp-w-32 md:rfp-h-32 rfp-mx-auto rfp-mb-4 md:rfp-mb-6 rfp-rounded-2xl md:rfp-rounded-3xl rfp-bg-gradient-to-br rfp-from-orange-500 rfp-via-red-500 rfp-to-pink-500 rfp-flex rfp-items-center rfp-justify-center rfp-shadow-2xl",children:e.jsx(S.Presentation,{className:"rfp-w-12 rfp-h-12 md:rfp-w-16 md:rfp-h-16 rfp-text-white"})}),e.jsx("p",{className:"rfp-text-lg md:rfp-text-xl rfp-text-white/90 rfp-mb-2 md:rfp-mb-3 rfp-font-medium",children:"PPT 预览"}),e.jsx("p",{className:"rfp-text-xs md:rfp-text-sm rfp-text-white/60 rfp-mb-4 md:rfp-mb-6",children:f||"浏览器暂不支持直接预览 PPT 文件"}),e.jsxs("a",{href:s,download:!0,className:"rfp-inline-flex rfp-items-center rfp-gap-2 rfp-px-4 rfp-py-2 md:rfp-px-6 md:rfp-py-3 rfp-bg-gradient-to-r rfp-from-purple-500 rfp-to-pink-500 rfp-text-white rfp-text-sm md:rfp-text-base rfp-rounded-lg md:rfp-rounded-xl hover:rfp-scale-105 rfp-transition-all rfp-shadow-lg",children:[e.jsx("svg",{className:"rfp-w-4 rfp-h-4 md:rfp-w-5 md:rfp-h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),"下载文件"]}),e.jsx("p",{className:"rfp-text-xs rfp-text-white/40 rfp-mt-3 md:rfp-mt-4",children:"提示:可以使用 Microsoft PowerPoint 或 WPS 打开"})]})}),e.jsx("div",{ref:c,className:"pptx-wrapper rfp-w-full rfp-max-w-full md:rfp-max-w-6xl"})]})},xe=s=>{var f;const t=((f=s.split(".").pop())==null?void 0:f.toLowerCase().split("?")[0])||"";return{mp4:"video/mp4",webm:"video/webm",ogg:"video/ogg",ogv:"video/ogg",mov:"video/quicktime",avi:"video/x-msvideo",mkv:"video/x-matroska",m4v:"video/mp4","3gp":"video/3gpp",flv:"video/x-flv"}[t]||"video/mp4"},he=({url:s})=>{const[t,o]=r.useState(null),[f,n]=r.useState(!0),c=r.useRef(null),a=r.useRef(null);return r.useEffect(()=>{if(!a.current&&c.current){const l=document.createElement("video-js");l.classList.add("vjs-big-play-centered","vjs-theme-apple"),c.current.appendChild(l);const p=xe(s),m=se(l,{controls:!0,responsive:!0,fluid:!0,preload:"auto",controlBar:{children:["playToggle","volumePanel","currentTimeDisplay","timeDivider","durationDisplay","progressControl","remainingTimeDisplay","fullscreenToggle"],volumePanel:{inline:!1}},html5:{vhs:{overrideNative:!0},nativeVideoTracks:!1,nativeAudioTracks:!1,nativeTextTracks:!1},sources:p==="video/quicktime"?[{src:s,type:"video/quicktime"},{src:s,type:"video/mp4"}]:[{src:s,type:p}]});m.on("loadeddata",()=>{n(!1)}),m.on("error",()=>{const i=m.error();console.error("Video.js error:",i),o(`视频加载失败: ${(i==null?void 0:i.message)||"未知错误"}`),n(!1)}),a.current=m}},[s]),r.useEffect(()=>{const l=a.current;return()=>{l&&!l.isDisposed()&&(l.dispose(),a.current=null)}},[]),t?e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:e.jsxs("div",{className:"rfp-text-center",children:[e.jsx("div",{className:"rfp-w-16 rfp-h-16 rfp-mx-auto rfp-mb-4 rfp-rounded-full rfp-bg-red-500/10 rfp-flex rfp-items-center rfp-justify-center",children:e.jsx("svg",{className:"rfp-w-8 rfp-h-8 rfp-text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),e.jsx("p",{className:"rfp-text-lg rfp-font-medium rfp-text-white/90 rfp-mb-2",children:"视频加载失败"}),e.jsx("p",{className:"rfp-text-sm rfp-text-white/60",children:t})]})}):e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full rfp-p-4 md:rfp-p-8",children:e.jsxs("div",{className:"rfp-w-full rfp-max-w-full md:rfp-max-w-5xl rfp-relative",children:[f&&e.jsx("div",{className:"rfp-absolute rfp-inset-0 rfp-flex rfp-items-center rfp-justify-center rfp-bg-black/20 rfp-backdrop-blur-sm rfp-rounded-2xl rfp-z-10",children:e.jsxs("div",{className:"rfp-text-center",children:[e.jsx("div",{className:"rfp-w-12 rfp-h-12 rfp-mx-auto rfp-mb-3 rfp-border-3 rfp-border-white/20 rfp-border-t-white rfp-rounded-full rfp-animate-spin"}),e.jsx("p",{className:"rfp-text-sm rfp-text-white/70 rfp-font-medium",children:"加载视频中..."})]})}),e.jsx("div",{ref:c,className:"rfp-overflow-hidden",style:{boxShadow:"0 20px 60px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05)"}})]})})},we=({url:s,fileName:t})=>{const[o,f]=r.useState(null),[n,c]=r.useState(!1),[a,l]=r.useState(0),[p,h]=r.useState(0),[m,i]=r.useState(1),[v,x]=r.useState(!1),g=r.useRef(null);r.useEffect(()=>{const w=g.current;if(!w)return;const T=()=>{isNaN(w.currentTime)||l(w.currentTime)},N=()=>{!isNaN(w.duration)&&isFinite(w.duration)&&h(w.duration)},P=()=>c(!1),R=()=>N();return w.addEventListener("timeupdate",T),w.addEventListener("loadedmetadata",N),w.addEventListener("durationchange",N),w.addEventListener("canplay",R),w.addEventListener("ended",P),w.readyState>=1&&N(),()=>{w.removeEventListener("timeupdate",T),w.removeEventListener("loadedmetadata",N),w.removeEventListener("durationchange",N),w.removeEventListener("canplay",R),w.removeEventListener("ended",P)}},[]);const u=()=>{g.current&&(n?g.current.pause():g.current.play(),c(!n))},j=w=>{const T=parseFloat(w.target.value);l(T),g.current&&(g.current.currentTime=T)},y=w=>{const T=parseFloat(w.target.value);i(T),g.current&&(g.current.volume=T),T>0&&x(!1)},k=()=>{g.current&&(g.current.muted=!v,x(!v))},d=w=>{g.current&&(g.current.currentTime+=w)},M=w=>{if(!isFinite(w)||isNaN(w)||w<0)return"0:00";const T=Math.floor(w/60),N=Math.floor(w%60);return`${T}:${N.toString().padStart(2,"0")}`},C=()=>{f("音频加载失败")};return o?e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:e.jsx("div",{className:"rfp-text-white/70 rfp-text-center",children:e.jsx("p",{className:"rfp-text-lg",children:o})})}):e.jsxs("div",{className:"rfp-flex rfp-flex-col rfp-items-center rfp-justify-center rfp-w-full rfp-h-full rfp-p-4 md:rfp-p-8 rfp-gap-4 md:rfp-gap-8",children:[e.jsx("div",{className:"rfp-w-48 rfp-h-48 md:rfp-w-64 md:rfp-h-64 rfp-rounded-3xl rfp-bg-gradient-to-br rfp-from-purple-500 rfp-via-pink-500 rfp-to-rose-500 rfp-flex rfp-items-center rfp-justify-center rfp-shadow-2xl rfp-backdrop-blur-xl",children:e.jsx(S.Music,{className:"rfp-w-24 rfp-h-24 md:rfp-w-32 md:rfp-h-32 rfp-text-white"})}),e.jsxs("div",{className:"rfp-text-white rfp-text-center rfp-max-w-sm md:rfp-max-w-md rfp-px-4",children:[e.jsx("p",{className:"rfp-text-xl md:rfp-text-2xl rfp-font-medium rfp-mb-1 rfp-truncate",children:t}),e.jsx("p",{className:"rfp-text-xs md:rfp-text-sm rfp-text-white/60",children:"音频文件"})]}),e.jsxs("div",{className:"rfp-w-full rfp-max-w-sm md:rfp-max-w-md rfp-bg-white/10 rfp-backdrop-blur-xl rfp-rounded-2xl rfp-p-4 md:rfp-p-6 rfp-border rfp-border-white/20",children:[e.jsxs("div",{className:"rfp-mb-4",children:[e.jsxs("div",{className:"rfp-relative rfp-h-4 rfp-flex rfp-items-center",children:[e.jsx("div",{className:"rfp-absolute rfp-w-full rfp-h-[6px] rfp-bg-white/20 rfp-rounded-full"}),e.jsx("div",{className:"rfp-absolute rfp-h-[6px] rfp-bg-gradient-to-r rfp-from-purple-500 rfp-to-pink-500 rfp-rounded-full rfp-transition-all rfp-duration-100 rfp-ease-linear rfp-pointer-events-none",style:{width:`${p>0?a/p*100:a>100?100:a}%`}}),e.jsx("input",{type:"range",min:"0",max:p>0?p:100+(a>100?a%100:0),value:a,onChange:j,className:"audio-slider rfp-absolute rfp-w-full"})]}),e.jsxs("div",{className:"rfp-flex rfp-justify-between rfp-text-xs rfp-text-white/60 rfp-mt-3",children:[e.jsx("span",{children:M(a)}),e.jsx("span",{children:M(p)})]})]}),e.jsxs("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-gap-4 rfp-mb-4",children:[e.jsx("button",{onClick:()=>d(-10),className:"rfp-w-10 rfp-h-10 rfp-rounded-full rfp-bg-white/10 hover:rfp-bg-white/20 rfp-flex rfp-items-center rfp-justify-center rfp-text-white rfp-transition-all",children:e.jsx(S.SkipBack,{className:"rfp-w-5 rfp-h-5"})}),e.jsx("button",{onClick:u,className:"rfp-w-14 rfp-h-14 rfp-rounded-full rfp-bg-gradient-to-br rfp-from-purple-500 rfp-to-pink-500 hover:rfp-scale-105 rfp-flex rfp-items-center rfp-justify-center rfp-text-white rfp-transition-all rfp-shadow-lg",children:n?e.jsx(S.Pause,{className:"rfp-w-6 rfp-h-6"}):e.jsx(S.Play,{className:"rfp-w-6 rfp-h-6 rfp-ml-1"})}),e.jsx("button",{onClick:()=>d(10),className:"rfp-w-10 rfp-h-10 rfp-rounded-full rfp-bg-white/10 hover:rfp-bg-white/20 rfp-flex rfp-items-center rfp-justify-center rfp-text-white rfp-transition-all",children:e.jsx(S.SkipForward,{className:"rfp-w-5 rfp-h-5"})})]}),e.jsxs("div",{className:"rfp-flex rfp-items-center rfp-gap-3",children:[e.jsx("button",{onClick:k,className:"rfp-text-white/80 hover:rfp-text-white rfp-transition-colors",children:v||m===0?e.jsx(S.VolumeX,{className:"rfp-w-5 rfp-h-5"}):e.jsx(S.Volume2,{className:"rfp-w-5 rfp-h-5"})}),e.jsxs("div",{className:"rfp-flex-1 rfp-relative rfp-h-3 rfp-flex rfp-items-center",children:[e.jsx("div",{className:"rfp-absolute rfp-w-full rfp-h-[4px] rfp-bg-white/20 rfp-rounded-full"}),e.jsx("div",{className:"rfp-absolute rfp-h-[4px] rfp-bg-purple-500 rfp-rounded-full rfp-transition-all rfp-duration-100 rfp-pointer-events-none",style:{width:`${(v?0:m)*100}%`}}),e.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:v?0:m,onChange:y,className:"volume-slider rfp-absolute rfp-w-full"})]})]})]}),e.jsx("audio",{ref:g,src:s,onError:C,className:"rfp-hidden"})]})},Z={'pre[class*="language-"]':{color:"#d4d4d4",fontSize:"13px",textShadow:"none",fontFamily:'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:".5em 0",overflow:"auto",background:"#1e1e1e"},'code[class*="language-"]':{color:"#d4d4d4",fontSize:"13px",textShadow:"none",fontFamily:'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]::selection':{textShadow:"none",background:"#264F78"},'code[class*="language-"]::selection':{textShadow:"none",background:"#264F78"},'pre[class*="language-"] *::selection':{textShadow:"none",background:"#264F78"},'code[class*="language-"] *::selection':{textShadow:"none",background:"#264F78"},':not(pre) > code[class*="language-"]':{padding:".1em .3em",borderRadius:".3em",color:"#db4c69",background:"#1e1e1e"},".namespace":{Opacity:".7"},"doctype.doctype-tag":{color:"#569CD6"},"doctype.name":{color:"#9cdcfe"},comment:{color:"#6a9955"},prolog:{color:"#6a9955"},punctuation:{color:"#d4d4d4"},".language-html .language-css .token.punctuation":{color:"#d4d4d4"},".language-html .language-javascript .token.punctuation":{color:"#d4d4d4"},property:{color:"#9cdcfe"},tag:{color:"#569cd6"},boolean:{color:"#569cd6"},number:{color:"#b5cea8"},constant:{color:"#9cdcfe"},symbol:{color:"#b5cea8"},inserted:{color:"#b5cea8"},unit:{color:"#b5cea8"},selector:{color:"#d7ba7d"},"attr-name":{color:"#9cdcfe"},string:{color:"#ce9178"},char:{color:"#ce9178"},builtin:{color:"#ce9178"},deleted:{color:"#ce9178"},".language-css .token.string.url":{textDecoration:"underline"},operator:{color:"#d4d4d4"},entity:{color:"#569cd6"},"operator.arrow":{color:"#569CD6"},atrule:{color:"#ce9178"},"atrule.rule":{color:"#c586c0"},"atrule.url":{color:"#9cdcfe"},"atrule.url.function":{color:"#dcdcaa"},"atrule.url.punctuation":{color:"#d4d4d4"},keyword:{color:"#569CD6"},"keyword.module":{color:"#c586c0"},"keyword.control-flow":{color:"#c586c0"},function:{color:"#dcdcaa"},"function.maybe-class-name":{color:"#dcdcaa"},regex:{color:"#d16969"},important:{color:"#569cd6"},italic:{fontStyle:"italic"},"class-name":{color:"#4ec9b0"},"maybe-class-name":{color:"#4ec9b0"},console:{color:"#9cdcfe"},parameter:{color:"#9cdcfe"},interpolation:{color:"#9cdcfe"},"punctuation.interpolation-punctuation":{color:"#569cd6"},variable:{color:"#9cdcfe"},"imports.maybe-class-name":{color:"#9cdcfe"},"exports.maybe-class-name":{color:"#9cdcfe"},escape:{color:"#d7ba7d"},"tag.punctuation":{color:"#808080"},cdata:{color:"#808080"},"attr-value":{color:"#ce9178"},"attr-value.punctuation":{color:"#ce9178"},"attr-value.punctuation.attr-equals":{color:"#d4d4d4"},namespace:{color:"#4ec9b0"},'pre[class*="language-javascript"]':{color:"#9cdcfe"},'code[class*="language-javascript"]':{color:"#9cdcfe"},'pre[class*="language-jsx"]':{color:"#9cdcfe"},'code[class*="language-jsx"]':{color:"#9cdcfe"},'pre[class*="language-typescript"]':{color:"#9cdcfe"},'code[class*="language-typescript"]':{color:"#9cdcfe"},'pre[class*="language-tsx"]':{color:"#9cdcfe"},'code[class*="language-tsx"]':{color:"#9cdcfe"},'pre[class*="language-css"]':{color:"#ce9178"},'code[class*="language-css"]':{color:"#ce9178"},'pre[class*="language-html"]':{color:"#d4d4d4"},'code[class*="language-html"]':{color:"#d4d4d4"},".language-regex .token.anchor":{color:"#dcdcaa"},".language-html .token.punctuation":{color:"#808080"},'pre[class*="language-"] > code[class*="language-"]':{position:"relative",zIndex:"1"},".line-highlight.line-highlight":{background:"#f7ebc6",boxShadow:"inset 5px 0 0 #f7d87c",zIndex:"0"}},ge=({url:s})=>{const[t,o]=r.useState(""),[f,n]=r.useState(!0),[c,a]=r.useState(null);return r.useEffect(()=>{(async()=>{try{n(!0),a(null);const p=await fetch(s);if(!p.ok)throw new Error("加载失败");const h=await p.text();o(h)}catch(p){a("Markdown 文件加载失败"),console.error(p)}finally{n(!1)}})()},[s]),f?e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:e.jsx("div",{className:"rfp-w-12 rfp-h-12 rfp-border-4 rfp-border-white/20 rfp-border-t-white rfp-rounded-full rfp-animate-spin"})}):c?e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:e.jsx("div",{className:"rfp-text-white/70 rfp-text-center",children:e.jsx("p",{className:"rfp-text-lg",children:c})})}):e.jsx("div",{className:"rfp-w-full rfp-h-full rfp-overflow-auto rfp-p-4 md:rfp-p-8",children:e.jsx("div",{className:"rfp-max-w-full md:rfp-max-w-4xl rfp-mx-auto rfp-bg-white/5 rfp-backdrop-blur-sm rfp-rounded-2xl rfp-p-4 md:rfp-p-8 rfp-border rfp-border-white/10",children:e.jsx("div",{className:"rfp-max-w-none",children:e.jsx(le,{remarkPlugins:[oe],components:{code({node:l,inline:p,className:h,children:m,...i}){const v=/language-(\w+)/.exec(h||"");return!p&&v?e.jsx(A.Prism,{style:Z,language:v[1],PreTag:"div",className:"rfp-rounded-lg",...i,children:String(m).replace(/\n$/,"")}):e.jsx("code",{className:"rfp-bg-white/10 rfp-px-1.5 rfp-py-0.5 rfp-rounded rfp-text-sm",...i,children:m})},h1:({children:l})=>e.jsx("h1",{className:"rfp-text-4xl rfp-font-bold rfp-mb-4 rfp-text-white rfp-border-b rfp-border-white/20 rfp-pb-2",children:l}),h2:({children:l})=>e.jsx("h2",{className:"rfp-text-3xl rfp-font-bold rfp-mb-3 rfp-text-white rfp-mt-8",children:l}),h3:({children:l})=>e.jsx("h3",{className:"rfp-text-2xl rfp-font-bold rfp-mb-2 rfp-text-white rfp-mt-6",children:l}),p:({children:l})=>e.jsx("p",{className:"rfp-text-white/90 rfp-mb-4 rfp-leading-relaxed",children:l}),a:({href:l,children:p})=>e.jsx("a",{href:l,className:"rfp-text-blue-400 hover:rfp-text-blue-300 rfp-underline",target:"_blank",rel:"noopener noreferrer",children:p}),ul:({children:l})=>e.jsx("ul",{className:"rfp-list-disc rfp-list-inside rfp-mb-4 rfp-text-white/90",children:l}),ol:({children:l})=>e.jsx("ol",{className:"rfp-list-decimal rfp-list-inside rfp-mb-4 rfp-text-white/90",children:l}),li:({children:l})=>e.jsx("li",{className:"rfp-mb-1",children:l}),blockquote:({children:l})=>e.jsx("blockquote",{className:"rfp-border-l-4 rfp-border-blue-500 rfp-pl-4 rfp-italic rfp-text-white/80 rfp-my-4",children:l}),table:({children:l})=>e.jsx("div",{className:"rfp-overflow-x-auto rfp-my-4",children:e.jsx("table",{className:"rfp-min-w-full rfp-border rfp-border-white/20",children:l})}),th:({children:l})=>e.jsx("th",{className:"rfp-border rfp-border-white/20 rfp-px-4 rfp-py-2 rfp-bg-white/10 rfp-text-white rfp-font-semibold",children:l}),td:({children:l})=>e.jsx("td",{className:"rfp-border rfp-border-white/20 rfp-px-4 rfp-py-2 rfp-text-white/90",children:l}),hr:()=>e.jsx("hr",{className:"rfp-border-white/20 rfp-my-6"}),img:({src:l,alt:p})=>e.jsx("img",{src:l,alt:p,className:"rfp-rounded-lg rfp-max-w-full rfp-h-auto rfp-my-4"})},children:t})})})})},be=s=>{var f;const t=((f=s.split(".").pop())==null?void 0:f.toLowerCase())||"";return{js:"javascript",jsx:"jsx",ts:"typescript",tsx:"tsx",py:"python",java:"java",cpp:"cpp",c:"c",cs:"csharp",php:"php",rb:"ruby",go:"go",rs:"rust",swift:"swift",kt:"kotlin",scala:"scala",sh:"bash",bash:"bash",zsh:"bash",json:"json",xml:"xml",html:"html",css:"css",scss:"scss",sass:"sass",less:"less",sql:"sql",yaml:"yaml",yml:"yaml",toml:"toml",ini:"ini",conf:"nginx",md:"markdown",txt:"text"}[t]||"text"},je=({url:s,fileName:t})=>{const[o,f]=r.useState(""),[n,c]=r.useState(!0),[a,l]=r.useState(null),p=be(t);return r.useEffect(()=>{(async()=>{try{c(!0),l(null);const m=await fetch(s);if(!m.ok)throw new Error("加载失败");const i=await m.text();f(i)}catch(m){l("文本文件加载失败"),console.error(m)}finally{c(!1)}})()},[s]),n?e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:e.jsx("div",{className:"rfp-w-12 rfp-h-12 rfp-border-4 rfp-border-white/20 rfp-border-t-white rfp-rounded-full rfp-animate-spin"})}):a?e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:e.jsx("div",{className:"rfp-text-white/70 rfp-text-center",children:e.jsx("p",{className:"rfp-text-lg",children:a})})}):e.jsx("div",{className:"rfp-w-full rfp-h-full rfp-overflow-auto rfp-p-4 md:rfp-p-8",children:e.jsxs("div",{className:"rfp-max-w-full md:rfp-max-w-6xl rfp-mx-auto rfp-bg-white/5 rfp-backdrop-blur-sm rfp-rounded-2xl rfp-border rfp-border-white/10 rfp-overflow-hidden",children:[e.jsxs("div",{className:"rfp-flex rfp-items-center rfp-gap-2 md:rfp-gap-3 rfp-px-4 rfp-py-3 md:rfp-px-6 md:rfp-py-4 rfp-bg-white/5 rfp-border-b rfp-border-white/10",children:[e.jsx(S.FileText,{className:"rfp-w-4 rfp-h-4 md:rfp-w-5 md:rfp-h-5 rfp-text-white/70 rfp-flex-shrink-0"}),e.jsx("span",{className:"rfp-text-white rfp-font-medium rfp-text-sm md:rfp-text-base rfp-truncate",children:t}),e.jsx("span",{className:"rfp-ml-auto rfp-text-xs rfp-text-white/50 rfp-uppercase rfp-flex-shrink-0",children:p})]}),e.jsx("div",{className:"rfp-text-sm",children:p==="text"?e.jsx("pre",{className:"rfp-p-6 rfp-text-white/90 rfp-font-mono rfp-whitespace-pre-wrap rfp-break-words",children:o}):e.jsx(A.Prism,{language:p,style:Z,showLineNumbers:!0,customStyle:{margin:0,padding:"1.5rem",background:"transparent",fontSize:"0.875rem"},lineNumberStyle:{minWidth:"3em",paddingRight:"1em",color:"rgba(255, 255, 255, 0.3)",userSelect:"none"},children:o})})]})})},ve=({fileName:s,fileType:t,onDownload:o})=>e.jsxs("div",{className:"rfp-flex rfp-flex-col rfp-items-center rfp-justify-center rfp-w-full rfp-h-full rfp-p-8 rfp-gap-6",children:[e.jsx("div",{className:"rfp-w-32 rfp-h-32 rfp-rounded-full rfp-bg-white/10 rfp-flex rfp-items-center rfp-justify-center",children:e.jsx(S.FileQuestion,{className:"rfp-w-16 rfp-h-16 rfp-text-white/70"})}),e.jsxs("div",{className:"rfp-text-white rfp-text-center",children:[e.jsx("p",{className:"rfp-text-xl rfp-font-medium rfp-mb-2",children:s}),e.jsxs("p",{className:"rfp-text-white/70",children:["不支持预览此文件类型 (",t,")"]})]}),e.jsxs("button",{onClick:o,className:"rfp-flex rfp-items-center rfp-gap-2 rfp-px-6 rfp-py-3 rfp-bg-white/10 hover:rfp-bg-white/20 rfp-backdrop-blur-sm rfp-rounded-lg rfp-text-white rfp-font-medium rfp-transition-all",children:[e.jsx(S.Download,{className:"rfp-w-5 rfp-h-5"}),"下载文件查看"]})]}),ye=s=>{var n;const t=((n=s.name.split(".").pop())==null?void 0:n.toLowerCase())||"",o=s.type.toLowerCase();if(o.startsWith("image/")||["jpg","jpeg","png","gif","webp","svg"].includes(t))return"image";if(o.includes("pdf")||t==="pdf")return"pdf";if(o.includes("wordprocessingml")||t==="docx")return"docx";if(o.includes("spreadsheetml")||t==="xlsx")return"xlsx";if(o.includes("presentationml")||t==="pptx"||t==="ppt")return"pptx";if(o.startsWith("video/")||["mp4","webm","ogg","ogv","mov","avi","mkv","m4v","3gp","flv"].includes(t))return"video";if(o.startsWith("audio/")||["mp3","wav","ogg","m4a","flac","aac"].includes(t))return"audio";if(t==="md"||t==="markdown")return"markdown";const f=["txt","log","csv","js","jsx","ts","tsx","json","py","java","cpp","c","h","cs","php","rb","go","rs","swift","kt","html","css","scss","sass","less","xml","yaml","yml","toml","ini","conf","sh","bash","zsh","sql"];return o.startsWith("text/")||f.includes(t)?"text":"unsupported"},ke=({files:s,currentIndex:t,isOpen:o,onClose:f,onNavigate:n,customRenderers:c=[]})=>{const[a,l]=r.useState(1),[p,h]=r.useState(0),[m,i]=r.useState(1),[,v]=r.useState(1),[x,g]=r.useState(null),[u,j]=r.useState(null),y=50,k=r.useMemo(()=>V(s),[s]),d=k[t],M=r.useMemo(()=>d?c.find(b=>b.test(d)):null,[d,c]),C=d?ye(d):"unsupported";r.useEffect(()=>{l(1),h(0),i(1),v(1)},[t]),r.useEffect(()=>{if(o){const b=document.body.style.overflow,D=document.body.style.paddingRight,$=window.innerWidth-document.documentElement.clientWidth;return document.body.style.overflow="hidden",$>0&&(document.body.style.paddingRight=`${$}px`),()=>{document.body.style.overflow=b,document.body.style.paddingRight=D}}},[o]),r.useEffect(()=>{if(!o)return;const b=D=>{D.key==="Escape"?f():D.key==="ArrowLeft"&&t>0?n==null||n(t-1):D.key==="ArrowRight"&&t<k.length-1&&(n==null||n(t+1))};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[o,t,k.length,f,n]);const w=r.useCallback(()=>{l(b=>Math.min(b+.25,10))},[]),T=r.useCallback(()=>{l(b=>Math.max(b-.25,.01))},[]),N=r.useCallback(()=>{h(b=>b+90)},[]),P=r.useCallback(()=>{h(b=>b-90)},[]),R=r.useCallback(()=>{l(1),h(0)},[]),F=r.useCallback(()=>{l(1)},[]),G=r.useCallback(b=>{l(b)},[]),Y=r.useCallback(()=>{l(1),h(0)},[]),W=r.useCallback(()=>{if(!d)return;const b=document.createElement("a");b.href=d.url,b.download=d.name,b.click()},[d]),J=r.useCallback(b=>{j(null),g(b.targetTouches[0].clientX)},[]),K=r.useCallback(b=>{j(b.targetTouches[0].clientX)},[]),Q=r.useCallback(()=>{if(!x||!u)return;const b=x-u,D=b>y,$=b<-y;D&&t<k.length-1&&(n==null||n(t+1)),$&&t>0&&(n==null||n(t-1))},[x,u,y,t,k.length,n]);if(!o||!d)return null;const O=C==="image"||C==="pdf",H=C==="image",I=e.jsx("div",{className:"rfp-root",children:e.jsx(z.AnimatePresence,{children:o&&e.jsx(z.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"rfp-fixed rfp-inset-0 rfp-z-[9999] rfp-flex rfp-items-center rfp-justify-center rfp-bg-black/80 rfp-backdrop-blur-md rfp-overflow-hidden",onClick:f,onWheel:b=>b.stopPropagation(),children:e.jsxs("div",{className:"rfp-relative rfp-w-full rfp-h-full rfp-flex rfp-flex-col rfp-overflow-hidden",onClick:b=>b.stopPropagation(),children:[e.jsx(z.motion.div,{initial:{y:-100},animate:{y:0},exit:{y:-100},className:"rfp-absolute rfp-top-0 rfp-left-0 rfp-right-0 rfp-z-10 rfp-p-4",children:e.jsxs("div",{className:"rfp-max-w-7xl rfp-mx-auto rfp-flex rfp-flex-col md:rfp-flex-row md:rfp-items-center md:rfp-justify-between rfp-bg-black/40 rfp-backdrop-blur-xl rfp-rounded-2xl rfp-px-3 md:rfp-px-6 rfp-py-3 md:rfp-py-4 rfp-shadow-2xl rfp-border rfp-border-white/10 rfp-gap-2 md:rfp-gap-0",children:[e.jsxs("div",{className:"rfp-flex rfp-items-center rfp-justify-between md:rfp-flex-1 md:rfp-min-w-0 md:rfp-mr-4",children:[e.jsxs("div",{className:"rfp-flex-1 rfp-min-w-0",children:[e.jsx("h2",{className:"rfp-text-white rfp-font-medium rfp-text-sm md:rfp-text-lg rfp-truncate",children:d.name}),e.jsxs("p",{className:"rfp-text-white/60 rfp-text-xs md:rfp-text-sm",children:[t+1," / ",k.length]})]}),e.jsx("div",{className:"md:rfp-hidden rfp-ml-2",children:e.jsx(E,{icon:e.jsx(S.X,{className:"rfp-w-5 rfp-h-5"}),label:"关闭",onClick:f})})]}),e.jsxs("div",{className:"rfp-flex rfp-items-center rfp-gap-1 md:rfp-gap-2 rfp-overflow-x-auto scrollbar-hide rfp-flex-shrink-0",children:[O&&e.jsxs(e.Fragment,{children:[e.jsx(E,{icon:e.jsx(S.ZoomOut,{className:"rfp-w-5 rfp-h-5"}),label:"缩小",onClick:T,disabled:a<=.01}),e.jsxs("span",{className:"rfp-text-white/70 rfp-text-sm rfp-min-w-[4rem] rfp-text-center rfp-font-medium",children:[Math.round(a*100),"%"]}),e.jsx(E,{icon:e.jsx(S.ZoomIn,{className:"rfp-w-5 rfp-h-5"}),label:"放大",onClick:w,disabled:a>=10}),e.jsx("div",{className:"rfp-w-px rfp-h-6 rfp-bg-white/20 rfp-mx-2"}),e.jsx(E,{icon:e.jsx(S.Minimize2,{className:"rfp-w-5 rfp-h-5"}),label:"适应窗口",onClick:R}),e.jsx(E,{icon:e.jsx(S.Maximize2,{className:"rfp-w-5 rfp-h-5"}),label:"原始尺寸",onClick:F}),e.jsx("div",{className:"rfp-w-px rfp-h-6 rfp-bg-white/20 rfp-mx-2"})]}),H&&e.jsxs(e.Fragment,{children:[e.jsx(E,{icon:e.jsx(S.RotateCcw,{className:"rfp-w-5 rfp-h-5"}),label:"向左旋转",onClick:P}),e.jsx(E,{icon:e.jsx(S.RotateCw,{className:"rfp-w-5 rfp-h-5"}),label:"向右旋转",onClick:N}),e.jsx("div",{className:"rfp-w-px rfp-h-6 rfp-bg-white/20 rfp-mx-2"})]}),(O||H)&&e.jsxs(e.Fragment,{children:[e.jsx(E,{icon:e.jsx(S.RefreshCw,{className:"rfp-w-5 rfp-h-5"}),label:"复原",onClick:Y}),e.jsx("div",{className:"rfp-w-px rfp-h-6 rfp-bg-white/20 rfp-mx-2"})]}),e.jsx(E,{icon:e.jsx(S.Download,{className:"rfp-w-5 rfp-h-5"}),label:"下载",onClick:W}),e.jsxs("div",{className:"rfp-hidden md:rfp-flex rfp-items-center",children:[e.jsx("div",{className:"rfp-w-px rfp-h-6 rfp-bg-white/20 rfp-mx-2"}),e.jsx(E,{icon:e.jsx(S.X,{className:"rfp-w-5 rfp-h-5"}),label:"关闭",onClick:f})]})]})]})}),e.jsx("div",{className:"rfp-flex-1 rfp-flex rfp-items-center rfp-justify-center rfp-pt-32 md:rfp-pt-24 rfp-pb-4 md:rfp-pb-8 rfp-overflow-auto",onTouchStart:J,onTouchMove:K,onTouchEnd:Q,children:M?M.render(d):e.jsxs(e.Fragment,{children:[C==="image"&&e.jsx(ce,{url:d.url,zoom:a,rotation:p,onZoomChange:G}),C==="pdf"&&e.jsx(ie,{url:d.url,zoom:a,currentPage:m,onPageChange:i,onTotalPagesChange:v}),C==="docx"&&e.jsx(de,{url:d.url}),C==="xlsx"&&e.jsx(me,{url:d.url}),C==="pptx"&&e.jsx(ue,{url:d.url}),C==="video"&&e.jsx(he,{url:d.url}),C==="audio"&&e.jsx(we,{url:d.url,fileName:d.name}),C==="markdown"&&e.jsx(ge,{url:d.url}),C==="text"&&e.jsx(je,{url:d.url,fileName:d.name}),C==="unsupported"&&e.jsx(ve,{fileName:d.name,fileType:d.type,onDownload:W})]})}),k.length>1&&e.jsxs(e.Fragment,{children:[t>0&&e.jsx(z.motion.button,{initial:{x:-100,opacity:0},animate:{x:0,opacity:1},exit:{x:-100,opacity:0},onClick:()=>n==null?void 0:n(t-1),className:"rfp-absolute rfp-left-2 md:rfp-left-4 rfp-top-1/2 -rfp-translate-y-1/2 rfp-w-10 rfp-h-10 md:rfp-w-12 md:rfp-h-12 rfp-rounded-full rfp-bg-black/40 rfp-backdrop-blur-xl rfp-border rfp-border-white/10 rfp-flex rfp-items-center rfp-justify-center rfp-text-white hover:rfp-bg-black/60 rfp-transition-all rfp-shadow-2xl",children:e.jsx(S.ChevronLeft,{className:"rfp-w-5 rfp-h-5 md:rfp-w-6 md:rfp-h-6"})}),t<k.length-1&&e.jsx(z.motion.button,{initial:{x:100,opacity:0},animate:{x:0,opacity:1},exit:{x:100,opacity:0},onClick:()=>n==null?void 0:n(t+1),className:"rfp-absolute rfp-right-2 md:rfp-right-4 rfp-top-1/2 -rfp-translate-y-1/2 rfp-w-10 rfp-h-10 md:rfp-w-12 md:rfp-h-12 rfp-rounded-full rfp-bg-black/40 rfp-backdrop-blur-xl rfp-border rfp-border-white/10 rfp-flex rfp-items-center rfp-justify-center rfp-text-white hover:rfp-bg-black/60 rfp-transition-all rfp-shadow-2xl",children:e.jsx(S.ChevronRight,{className:"rfp-w-5 rfp-h-5 md:rfp-w-6 md:rfp-h-6"})})]})]})})})});return ee.createPortal(I,document.body)},E=({icon:s,label:t,onClick:o,disabled:f})=>e.jsx("button",{onClick:o,disabled:f,title:t,className:`rfp-p-2 rfp-rounded-lg rfp-transition-all ${f?"rfp-text-white/30 rfp-cursor-not-allowed":"rfp-text-white hover:rfp-bg-white/10 active:rfp-bg-white/20"}`,children:s}),Ne=pe.version;Object.defineProperty(exports,"pdfjs",{enumerable:!0,get:()=>L.pdfjs});exports.FilePreviewModal=ke;exports.VERSION=Ne;exports.configurePdfjs=_;exports.normalizeFile=U;exports.normalizeFiles=V;
2
2
  //# sourceMappingURL=index.cjs.map