"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[895],{20895:(e,l,s)=>{s.r(l),s.d(l,{VideoPreviewDialog:()=>m});var r=s(95155),t=s(12115),o=s(54165),n=s(30285),i=s(91981),a=s(91788),c=s(54416),d=s(56671),h=s(12147),p=s(3389);function m(e){var l;let{src:s,alt:m,children:u,open:v,onOpenChange:x}=e,[w,b]=(0,t.useState)(!1),[f,g]=(0,t.useState)(!1),k=(0,t.useRef)(null),y=void 0!==v?v:w,j=x||b,N=()=>{var e;j(!1),g(!1),(null==(e=k.current)?void 0:e.plyr)&&k.current.plyr.pause()},C=async e=>{try{try{let l=await fetch(s,{mode:"cors",headers:{Accept:"video/*"}});if(l.ok){let s=await l.blob(),r=window.URL.createObjectURL(s),t=document.createElement("a");t.href=r,t.download=e||"downloaded_video.mp4",document.body.appendChild(t),t.click(),document.body.removeChild(t),window.URL.revokeObjectURL(r),d.oR.success("视频下载成功");return}}catch(e){console.log("CORS限制，使用替代方案下载")}let l=document.createElement("a");l.href=s,l.download=e||"downloaded_video.mp4",l.target="_blank",l.rel="noopener noreferrer",document.body.appendChild(l),l.click(),document.body.removeChild(l),d.oR.success("视频下载链接已打开")}catch(e){console.error("下载失败:",e);try{window.open(s,"_blank","noopener,noreferrer"),d.oR.info("已在新标签页打开视频，请右键保存")}catch(e){d.oR.error("无法下载视频，请手动右键保存")}}};(0,t.useEffect)(()=>{let e=e=>{var l,s;if(y)switch(e.key){case"Escape":N();break;case" ":e.preventDefault(),(null==(l=k.current)?void 0:l.plyr)&&k.current.plyr.togglePlay();break;case"f":case"F":e.preventDefault(),(null==(s=k.current)?void 0:s.plyr)&&k.current.plyr.fullscreen.toggle()}};if(y)return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[y]),(0,t.useEffect)(()=>{if(!y){var e;g(!1),(null==(e=k.current)?void 0:e.plyr)&&k.current.plyr.pause()}},[y]);let E={type:"video",sources:[{src:s,type:{mp4:"video/mp4",webm:"video/webm",ogg:"video/ogg",mov:"video/quicktime",avi:"video/x-msvideo",wmv:"video/x-ms-wmv",flv:"video/x-flv",mkv:"video/x-matroska","3gp":"video/3gpp","3g2":"video/3gpp2",ts:"video/mp2t"}[(null==(l=s.split(".").pop())?void 0:l.toLowerCase())||""]||"video/mp4"}]};return(0,r.jsxs)(o.lG,{open:y,onOpenChange:j,children:[u&&(0,r.jsx)(o.zM,{asChild:!0,children:(0,r.jsx)("span",{onDoubleClick:()=>j(!0),style:{display:"inline-block",cursor:"pointer"},children:u})}),(0,r.jsxs)(o.Cf,{className:"p-0 border-none bg-black/95 backdrop-blur-sm sm:max-w-none ".concat(f?"max-w-full max-h-full w-screen h-screen":"!max-w-[80vw] !max-h-[80vh] w-[80vw] h-[80vh]"),style:{maxWidth:f?"100vw":"98vw",maxHeight:f?"100vh":"98vh",width:f?"100vw":"90vw",height:f?"100vh":"90vh"},children:[(0,r.jsx)(h.L3,{}),(0,r.jsxs)("div",{className:"absolute top-4 left-4 right-4 z-10 flex items-center justify-between",children:[(0,r.jsx)("div",{className:"flex items-center gap-2 bg-black/50 rounded-lg p-2 backdrop-blur-sm",children:(0,r.jsx)("span",{className:"text-white text-sm font-medium px-2",children:"视频播放器"})}),(0,r.jsxs)("div",{className:"flex items-center gap-2 bg-black/50 rounded-lg p-2 backdrop-blur-sm",children:[(0,r.jsx)(n.$,{variant:"ghost",size:"sm",onClick:()=>{var e;(null==(e=k.current)?void 0:e.plyr)&&k.current.plyr.fullscreen.toggle()},className:"text-white hover:bg-white/20 h-8 w-8 p-0",children:(0,r.jsx)(i.A,{className:"h-4 w-4"})}),(0,r.jsx)(n.$,{variant:"ghost",size:"sm",onClick:()=>C(m||"downloaded_video.mp4"),className:"text-white hover:bg-white/20 h-8 w-8 p-0",children:(0,r.jsx)(a.A,{className:"h-4 w-4"})}),(0,r.jsx)(n.$,{variant:"ghost",size:"sm",onClick:N,className:"text-white hover:bg-white/20 h-8 w-8 p-0",children:(0,r.jsx)(c.A,{className:"h-4 w-4"})})]})]}),(0,r.jsx)("div",{className:"w-full h-full flex items-center justify-center p-4 pt-16 pb-20",children:(0,r.jsx)("div",{className:"w-full h-full max-w-full max-h-full",children:(0,r.jsx)(p.A,{ref:k,source:E,options:{controls:["play-large","play","progress","current-time","duration","mute","volume","settings","pip","airplay","fullscreen"],settings:["speed"],speed:{selected:1,options:[.5,.75,1,1.25,1.5,1.75,2]},ratio:"16:9"}})})}),m&&(0,r.jsx)("div",{className:"absolute bottom-4 left-4 right-4 z-10",children:(0,r.jsx)("div",{className:"bg-black/50 rounded-lg p-3 backdrop-blur-sm",children:(0,r.jsx)("p",{className:"text-white text-sm text-center truncate",children:m})})}),(0,r.jsx)("div",{className:"absolute bottom-4 right-4 z-10",children:(0,r.jsx)("div",{className:"bg-black/50 rounded-lg p-2 backdrop-blur-sm",children:(0,r.jsxs)("div",{className:"text-white text-xs space-y-1",children:[(0,r.jsx)("div",{children:"空格: 播放/暂停"}),(0,r.jsx)("div",{children:"F: 全屏"}),(0,r.jsx)("div",{children:"ESC: 关闭"}),(0,r.jsx)("div",{children:"右键: 保存视频"})]})})})]})]})}s(46956)}}]);