import"./rolldown-runtime-BM3Ffeng.js";import{D as e,O as t,a as n,dt as r,it as i,nt as a,ot as o,ut as s,w as c}from"./element-plus-vendor-BF9PNysW.js";import{A as l,D as u,E as d,N as f,O as p,P as m,Pt as h,Tt as g,bt as _,et as v,gt as y,ht as b,k as x,nt as S,pt as C,x as w}from"./vue-vendor-DMUmTARL.js";import{$t as T,Di as E,Tr as D}from"./icons-vendor-Db5MGAkr.js";import{Y as O,l as k,v as A,w as j}from"./index-BcZTP2Ia.js";import{L as M,u as N,y as P}from"./admin-setting-Cf6ZvkT2.js";import{t as F}from"./useAdminConfigPage-DbFeorC_.js";import{t as I}from"./AdminSettingLayout-CzCwKa9p.js";import{t as L}from"./route-block-D7Rwj2No.js";import{t as R}from"./AdminSettingSection-BKOvJITh.js";import{t as z}from"./TagInput-CquW-o55.js";var B={class:`flex items-center`},V={__name:`TimeDurationInput`,props:{modelValue:{type:Number,default:null},valueUnit:{type:String,default:`ms`},units:{type:Array,default:()=>O.timeUnitArr},min:{type:Number,default:1},max:{type:Number,default:void 0}},emits:[`update:modelValue`,`change`],setup(e,{emit:t}){let n=e,r=t,o=d(()=>n.units&&n.units.length?n.units:O.timeUnitArr),s=d(()=>o.value.some(e=>e.value===`forever`)),u=g(null),f=g(null),y=d(()=>f.value===`forever`),x=d(()=>y.value?null:n.min),T=e=>e===`forever`?-1:j({value:1,unit:e}),E=e=>e==null?null:e===-1?-1:n.valueUnit===`ms`?Math.floor(e/1e3):e,D=e=>e==null?null:e===-1?-1:n.valueUnit===`ms`?e*1e3:e,k=e=>{if(e==null||e<0)return o.value[0]?.value||`s`;let t=o.value.filter(e=>e.value!==`forever`);if(!t.length)return`s`;let n=[...t].sort((e,t)=>T(e.value)-T(t.value));for(let t=n.length-1;t>=0;t--){let r=n[t].value,i=T(r);if(i>0&&e%i===0)return r}return n[0].value},A=()=>{let e=n.modelValue;if(e===-1&&s.value){f.value=`forever`,u.value=null;return}let t=E(e),r=k(t);if(f.value=r,t==null||t<0){u.value=null;return}let i=T(r);i>0?u.value=Math.floor(t/i):u.value=null};A(),C(()=>n.modelValue,()=>{A()});let M=()=>{let e=null;if(y.value&&s.value)e=-1;else{let t=u.value;e=t==null||t<=0?null:D(T(f.value)*t)}console.debug(`[TimeDurationInput] emit value:`,e,`unit:`,f.value),r(`update:modelValue`,e),r(`change`,e)};return C(()=>f.value,(e,t)=>{if(e){if(e===`forever`&&s.value){u.value=null,M();return}t===`forever`&&e!==`forever`&&(u.value=n.min||1),M()}}),C(()=>u.value,()=>{y.value||M()}),(t,n)=>{let r=c,s=a,d=i;return v(),l(`div`,B,[m(r,{modelValue:h(u),"onUpdate:modelValue":n[0]||=e=>_(u)?u.value=e:null,disabled:h(y),min:h(x),max:e.max,step:1,"controls-position":`right`,class:`min-w-[120px]`},null,8,[`modelValue`,`disabled`,`min`,`max`]),m(d,{modelValue:h(f),"onUpdate:modelValue":n[1]||=e=>_(f)?f.value=e:null,class:`ml-1 min-w-[90px]`},{default:b(()=>[(v(!0),l(w,null,S(h(o),e=>(v(),p(s,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`])])}}},H={class:`flex h-full flex-col`},U={__name:`index`,setup(i){let a=A(),c=k(),{configData:d,configLoading:S,saveData:w,saveLoading:O}=F(P,M,void 0,{cacheKey:`admin-config-upload`}),j=g(40),L=g(10),B=g(5),U=g(5),W=g(!1),G=g([]),K=e=>e.split(/[\n,，]+/).map(e=>e.trim()).filter(Boolean);C(()=>S.value,(e,t)=>{if(t===!0&&e===!1&&d.value){let e=Number(d.value.tusChunkSize);!Number.isNaN(e)&&e>0?j.value=Math.max(1,Math.round(e/(1024*1024))):j.value=40;let t=Number(d.value.onedriveChunkSize);!Number.isNaN(t)&&t>0?L.value=Math.max(1,Math.round(t/(1024*1024))):L.value=10;let n=Number(d.value.s3ChunkSize);!Number.isNaN(n)&&n>0?B.value=Math.max(5,Math.round(n/(1024*1024))):B.value=5;let r=Number(d.value.upyunChunkSize);!Number.isNaN(r)&&r>0?U.value=Math.max(1,Math.round(r/(1024*1024))):U.value=5,G.value=(d.value.uploadIgnorePatterns||``).split(`
`).filter(Boolean)}});let q=e=>{let t=Number(e);(Number.isNaN(t)||t<1)&&(t=1),j.value=Math.floor(t)},J=e=>{let t=Number(e);(Number.isNaN(t)||t<1)&&(t=1),L.value=Math.floor(t)},Y=e=>{let t=Number(e);(Number.isNaN(t)||t<5)&&(t=5),B.value=Math.floor(t)},X=e=>{let t=Number(e);(Number.isNaN(t)||t<1)&&(t=1),U.value=Math.floor(t)},Z=e=>{if(!d.value)return;let t=Number(j.value);(Number.isNaN(t)||t<1)&&(t=1),d.value.tusChunkSize=Math.round(t*1024*1024);let n=Number(L.value);(Number.isNaN(n)||n<1)&&(n=1),d.value.onedriveChunkSize=Math.round(n*1024*1024);let r=Number(B.value);(Number.isNaN(r)||r<5)&&(r=5),d.value.s3ChunkSize=Math.round(r*1024*1024);let i=Number(U.value);(Number.isNaN(i)||i<1)&&(i=1),d.value.upyunChunkSize=Math.round(i*1024*1024),d.value.uploadIgnorePatterns=G.value.join(`
`),w(e)},Q=e=>{if(!e||e<=0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`,`TB`,`PB`],n=Number(e),r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r++;return n.toFixed(2)+` `+t[r]},$=()=>{if(!d.value||!d.value.tusStoragePath){a.warning(`请先配置并保存缓存存储路径后再统计占用情况`);return}W.value=!0,N().then(e=>{let t=Number(e.data);a.success(`当前缓存目录占用：`+Q(t))}).finally(()=>{W.value=!1})};return(i,a)=>{let g=r,S=t,C=R,w=o,k=s,A=V,M=I,N=e,P=n;return v(),l(`div`,H,[h(d)?y((v(),p(N,{key:0,model:h(d),"label-width":h(c).adminForm.labelWidth,"label-position":h(c).adminForm.labelPosition,size:h(c).adminForm.size,"status-icon":``,class:`flex min-h-0 flex-1 flex-col`},{default:b(()=>[m(M,{"show-save-button":``,"save-loading":h(O),onSave:Z},{default:b(()=>[m(C,{title:`全局上传`,icon:h(E)},{default:b(()=>[m(S,{label:`最大同时上传文件数`},{default:b(()=>[m(g,{modelValue:h(d).maxFileUploads,"onUpdate:modelValue":a[0]||=e=>h(d).maxFileUploads=e,modelModifiers:{number:!0},type:`number`,min:1},{append:b(()=>[...a[8]||=[f(`个`,-1)]]),_:1},8,[`modelValue`]),a[9]||=u(`div`,{class:`el-form-item-tips`},`超出的文件将排队等待。`,-1)]),_:1}),m(S,{label:`忽略上传文件`},{default:b(()=>[m(z,{modelValue:h(G),"onUpdate:modelValue":a[1]||=e=>_(G)?G.value=e:null,"input-label":`忽略上传文件规则`,placeholder:`+ 添加忽略规则，如 .DS_Store`,"parse-input":K},null,8,[`modelValue`]),a[10]||=u(`div`,{class:`el-form-item-tips`},[f(` 上传时自动过滤匹配的文件。仅匹配文件名（不含路径），支持 * 通配符（如 `),u(`code`,null,`._*`),f(` 匹配所有以 `),u(`code`,null,`._`),f(` 开头的文件）。 `)],-1)]),_:1})]),_:1},8,[`icon`]),m(C,{title:`本地 / 代理上传缓存`,icon:h(T)},{default:b(()=>[m(S,{label:`缓存存储路径`},{default:b(()=>[m(g,{modelValue:h(d).tusStoragePath,"onUpdate:modelValue":a[2]||=e=>h(d).tusStoragePath=e},{append:b(()=>[m(k,{content:`统计当前已保存上传设置中的缓存目录占用情况，如刚修改路径请先保存再统计`,placement:`top`},{default:b(()=>[m(w,{loading:h(W),onClick:$},{default:b(()=>[...a[11]||=[f(` 点击统计占用情况 `,-1)]]),_:1},8,[`loading`])]),_:1})]),_:1},8,[`modelValue`]),a[12]||=u(`div`,{class:`el-form-item-tips`},[f(` 注意： `),u(`ul`,{class:`list-disc pl-5`},[u(`li`,null,` 如程序运行在 Docker 容器内，填写的路径未映射到宿主机，则重启容器后未上传完成的文件会丢失（需从头上传）。 `),u(`li`,null,`切换存储路径后，之前未上传完成的文件无法继续上传(需从头上传)。`)])],-1)]),_:1}),m(S,{label:`缓存过期时间`},{default:b(()=>[m(A,{modelValue:h(d).tusUploadExpiration,"onUpdate:modelValue":a[3]||=e=>h(d).tusUploadExpiration=e,"value-unit":`ms`},null,8,[`modelValue`]),a[13]||=u(`div`,{class:`el-form-item-tips`},`到期自动清理未完成缓存，再次上传需从头开始。`,-1)]),_:1})]),_:1},8,[`icon`]),m(C,{title:`分片大小`,icon:h(D)},{default:b(()=>[m(S,{label:`本地存储 / 代理上传`},{default:b(()=>[m(g,{modelValue:h(j),"onUpdate:modelValue":a[4]||=e=>_(j)?j.value=e:null,modelModifiers:{number:!0},type:`number`,min:1,onChange:q},{append:b(()=>[...a[14]||=[f(`MB`,-1)]]),_:1},8,[`modelValue`]),a[15]||=u(`div`,{class:`el-form-item-tips`},[f(` 如 100M 每个分片，第二个分片上传到了 50M 时页面刷新了，再次上传还是从 150M 开始上传。 `),u(`br`),f(` 此功能可用来规避一些服务器对单次上传大小的限制，如宝塔默认 50M，Cloudflare 上传 100M 限制。 `)],-1)]),_:1}),m(S,{label:`OneDrive`},{default:b(()=>[m(g,{modelValue:h(L),"onUpdate:modelValue":a[5]||=e=>_(L)?L.value=e:null,modelModifiers:{number:!0},type:`number`,min:1,onChange:J},{append:b(()=>[...a[16]||=[f(`MB`,-1)]]),_:1},8,[`modelValue`])]),_:1}),m(S,{label:`S3`},{default:b(()=>[m(g,{modelValue:h(B),"onUpdate:modelValue":a[6]||=e=>_(B)?B.value=e:null,modelModifiers:{number:!0},type:`number`,min:5,onChange:Y},{append:b(()=>[...a[17]||=[f(`MB`,-1)]]),_:1},8,[`modelValue`]),a[18]||=u(`div`,{class:`el-form-item-tips`},`AWS S3 要求最小 5MB。`,-1)]),_:1}),m(S,{label:`又拍云`},{default:b(()=>[m(g,{modelValue:h(U),"onUpdate:modelValue":a[7]||=e=>_(U)?U.value=e:null,modelModifiers:{number:!0},type:`number`,min:1,onChange:X},{append:b(()=>[...a[19]||=[f(`MB`,-1)]]),_:1},8,[`modelValue`])]),_:1})]),_:1},8,[`icon`])]),_:1},8,[`save-loading`])]),_:1},8,[`model`,`label-width`,`label-position`,`size`])),[[P,h(O)]]):x(``,!0)])}}};typeof L==`function`&&L(U);export{U as default};