import{A as e,D as t,P as n,Tt as r,Xt as i,et as a,k as o,mt as s,x as c}from"./vue-vendor-DMUmTARL.js";import{Ti as l}from"./icons-vendor-Db5MGAkr.js";import{P as u,yt as d}from"./index-kSn5YXd0.js";var f={class:`relative flex h-full w-full items-center justify-center bg-page dark:bg-gray-900`},p={key:0,class:`flex h-full w-full flex-col items-center justify-center p-4`},m={class:`mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-red-50 dark:bg-red-900/20`},h={class:`max-w-md break-all text-center text-sm text-secondary dark:text-gray-400`},g={key:0,class:`absolute inset-0 z-10 flex items-center justify-center bg-page text-base text-placeholder dark:bg-gray-900`},_=[`src`],v=3e4,y={__name:`KkFileViewer`,props:{url:{type:String,default:``},name:{type:String,default:``},path:{type:String,default:``},time:{type:String,default:``}},setup(y){let b=d(),x=y,S=r(!0),C=r(``),w=r(``),T=()=>{S.value=!1};return s(e=>{S.value=!0,C.value=``,w.value=``;let t=b.globalConfig.kkFileViewUrl,n=x.url,r=x.name;if(!t){C.value=`预览服务地址未配置。`,S.value=!1;return}if(!n){C.value=`文件URL无效，无法预览。`,S.value=!1;return}if(!r){C.value=`文件名无效，无法预览。`,S.value=!1;return}let i=u({name:r,url:n,path:x.path,time:x.time},t);if(!i){C.value=`无法构建预览地址。`,S.value=!1;return}w.value=i;let a=setTimeout(()=>{S.value=!1},v);e(()=>clearTimeout(a))}),(r,s)=>{let u=l;return a(),e(`div`,f,[C.value?(a(),e(`div`,p,[t(`div`,m,[n(u,{class:`h-8 w-8 text-red-500`,"aria-hidden":`true`})]),s[0]||=t(`h3`,{class:`mb-2 text-lg font-medium text-regular dark:text-gray-200`},`预览加载失败`,-1),t(`p`,h,i(C.value),1)])):w.value?(a(),e(c,{key:1},[S.value?(a(),e(`div`,g,` 正在加载预览, 请稍候... `)):o(``,!0),t(`iframe`,{src:w.value,width:`100%`,height:`100%`,frameborder:`0`,onLoad:T},null,40,_)],64)):o(``,!0)])}}};export{y as default};