import{c as X,d as se,u as oe,a as F,o as A,b as r,n,e as t,i as ne,t as C,r as E,f as Fe,w as We,_ as ge,g as z,C as Xe,h as re,j as Q,k as ze,l as S,m as Ze,p as Ee,q as ee,P as K,s as Je,S as Ke,F as Qe,v as te,T as ie,x as we,y as de,z as Ye,A as et,B as ke,D as Se,E as ue,G as tt,X as _e,H as rt,I as st,J as ae}from"./index-B9FIg8c4.js";import{u as at,P as ot,S as Ce,C as nt,c as lt,a as it,Q as dt,b as ce}from"./PageHeader-C8MTYIg6.js";import{F as Me}from"./file-CSeBUDan.js";import{E as ut,T as ct}from"./trash-DPD8vC5o.js";import"./box-BaIzuVAS.js";/** * @license lucide-vue-next v0.535.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pt=X("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** * @license lucide-vue-next v0.535.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pe=X("clipboard-copy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]);/** * @license lucide-vue-next v0.535.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gt=X("clock",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-vue-next v0.535.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ht=X("cloud-upload",[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]]);/** * @license lucide-vue-next v0.535.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ft=X("loader",[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]]);/** * @license lucide-vue-next v0.535.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vt=X("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/** * @license lucide-vue-next v0.535.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mt=X("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]),Ie=M=>M>=1024*1024*1024?Math.round(M/(1024*1024*1024))+"GB":M>=1024*1024?Math.round(M/(1024*1024))+"MB":Math.round(M/1024)+"KB",yt={class:"flex justify-center space-x-4 mb-6"},xt=se({__name:"SendTypeSelector",props:{selectedType:{}},emits:["update:selectedType"],setup(M,{emit:v}){const{t:I}=oe(),s=v,f=ne("isDarkMode"),p=_=>{s("update:selectedType",_)};return(_,g)=>(A(),F("div",yt,[r("button",{type:"button",onClick:g[0]||(g[0]=u=>p("file")),class:n(["px-4 py-2 rounded-lg transition-colors duration-300",_.selectedType==="file"?"bg-indigo-600 text-white":t(f)?"bg-gray-700 text-gray-300 hover:bg-gray-600":"bg-gray-200 text-gray-700 hover:bg-gray-300"])},C(t(I)("nav.sendFile")),3),r("button",{type:"button",onClick:g[1]||(g[1]=u=>p("text")),class:n(["px-4 py-2 rounded-lg transition-colors duration-300",_.selectedType==="text"?"bg-indigo-600 text-white":t(f)?"bg-gray-700 text-gray-300 hover:bg-gray-600":"bg-gray-200 text-gray-700 hover:bg-gray-300"])},C(t(I)("send.sendText")),3)]))}}),bt=se({__name:"BorderProgressBar",props:{progress:{}},setup(M){const v=M,I=E(null),s=E(null);let f=null;const p=()=>{if(!f||!s.value||!I.value)return;const g=I.value.clientWidth,u=I.value.clientHeight;s.value.width=g,s.value.height=u;const c=4,l=8;f.lineWidth=c;const T=f.createLinearGradient(0,0,g,u);T.addColorStop(0,"#4f46e5"),T.addColorStop(.5,"#7c3aed"),T.addColorStop(1,"#db2777"),f.strokeStyle="rgba(229, 231, 235, 0.2)",_(f,c/2,c/2,g-c,u-c,l),f.stroke();const $=((g+u)*2-8*l+2*Math.PI*l)*v.progress/100;f.strokeStyle=T,f.lineCap="round",f.lineJoin="round",f.beginPath();let a=$;const y=c/2,L=g-c,V=u-c;if(a>0){const w=Math.min(L-2*l,a);f.moveTo(l+y,y),f.lineTo(w+l+y,y),a-=w}if(a>0){const w=Math.min(Math.PI/2,a/l);f.arc(L-l+y,l+y,l,-Math.PI/2,w-Math.PI/2,!1),a-=w*l}if(a>0){const w=Math.min(V-2*l,a);f.lineTo(L+y,w+l+y),a-=w}if(a>0){const w=Math.min(Math.PI/2,a/l);f.arc(L-l+y,V-l+y,l,0,w,!1),a-=w*l}if(a>0){const w=Math.min(L-2*l,a);f.lineTo(L-w-l+y,V+y),a-=w}if(a>0){const w=Math.min(Math.PI/2,a/l);f.arc(l+y,V-l+y,l,Math.PI/2,Math.PI/2+w,!1),a-=w*l}if(a>0){const w=Math.min(V-2*l,a);f.lineTo(y,V-w-l+y),a-=w}if(a>0){const w=Math.min(Math.PI/2,a/l);f.arc(l+y,l+y,l,Math.PI,Math.PI+w,!1)}f.stroke()};function _(g,u,c,l,T,b){g.beginPath(),g.moveTo(u+b,c),g.lineTo(u+l-b,c),g.arcTo(u+l,c,u+l,c+b,b),g.lineTo(u+l,c+T-b),g.arcTo(u+l,c+T,u+l-b,c+T,b),g.lineTo(u+b,c+T),g.arcTo(u,c+T,u,c+T-b,b),g.lineTo(u,c+b),g.arcTo(u,c,u+b,c,b),g.closePath()}return Fe(()=>{s.value&&(f=s.value.getContext("2d"),p())}),We(()=>v.progress,p),(g,u)=>(A(),F("div",{class:"border-progress-container",ref_key:"container",ref:I},[r("canvas",{ref_key:"canvas",ref:s,class:"border-progress-canvas"},null,512)],512))}}),wt=ge(bt,[["__scopeId","data-v-2fbf5085"]]),kt=["accept","disabled"],St={key:0,class:"absolute inset-0 w-full h-full"},_t={class:"block truncate"},Ct={key:1,class:"mt-3 w-full"},Mt=se({__name:"FileUploadArea",props:{selectedFile:{default:null},progress:{default:0},placeholder:{default:""},description:{default:""},acceptedTypes:{default:"*"},uploadStatus:{default:"idle"},uploadedBytes:{default:0},totalBytes:{default:0},errorMessage:{default:""},allowRetry:{type:Boolean,default:!0},retryText:{default:"重试"},showProgressDetails:{type:Boolean,default:!0}},emits:["fileSelected","fileDrop","retry"],setup(M,{emit:v}){const{t:I}=oe(),s=M,f=v,p=ne("isDarkMode"),_=z(()=>s.placeholder||I("send.uploadArea.placeholder")),g=z(()=>s.description||I("send.uploadArea.description")),u=E(null),c=z(()=>["uploading","initializing","confirming"].includes(s.uploadStatus)),l=z(()=>s.uploadStatus==="error"),T=z(()=>s.uploadStatus==="success"),b=z(()=>s.selectedFile?s.selectedFile.name:_.value),$=z(()=>c.value?ft:T.value?Xe:l.value?pt:ht),a=z(()=>c.value?p?"text-indigo-400 animate-spin":"text-indigo-600 animate-spin":T.value?p?"text-green-400":"text-green-600":l.value?p?"text-red-400":"text-red-600":p?"text-gray-400 group-hover:text-indigo-400":"text-gray-600 group-hover:text-indigo-600"),y=z(()=>l.value?p?"border-red-500/50":"border-red-300":T.value?p?"border-green-500/50":"border-green-300":""),L=z(()=>l.value&&s.errorMessage?s.errorMessage:s.uploadStatus==="initializing"?"正在初始化上传...":s.uploadStatus==="uploading"?"正在上传文件...":s.uploadStatus==="confirming"?"正在确认上传...":T.value?"上传成功!":g.value),V=z(()=>l.value?p?"text-red-400":"text-red-500":T.value?p?"text-green-400":"text-green-500":p?"text-gray-500":"text-gray-400"),w=h=>{if(h===0)return"0 B";const x=1024,B=["B","KB","MB","GB"],j=Math.floor(Math.log(h)/Math.log(x));return parseFloat((h/Math.pow(x,j)).toFixed(2))+" "+B[j]},O=()=>{c.value||u.value?.click()},Y=h=>{const x=h.target,B=x.files?.[0];B&&f("fileSelected",B),x.value=""},H=h=>{c.value||f("fileDrop",h)},m=()=>{f("retry")};return(h,x)=>(A(),F("div",{class:n(["rounded-xl p-8 flex flex-col items-center justify-center border-2 border-dashed transition-all duration-300 group cursor-pointer relative",[t(p)?"bg-gray-800 bg-opacity-50 border-gray-600 hover:border-indigo-500":"bg-gray-100 border-gray-300 hover:border-indigo-500",y.value]]),onClick:O,onDragover:x[0]||(x[0]=re(()=>{},["prevent"])),onDrop:re(H,["prevent"])},[r("input",{ref_key:"fileInput",ref:u,type:"file",class:"hidden",onChange:Y,accept:h.acceptedTypes,disabled:c.value},null,40,kt),h.progress>0?(A(),F("div",St,[S(wt,{progress:h.progress},null,8,["progress"])])):Q("",!0),(A(),ze(Ze($.value),{class:n(["w-16 h-16 transition-colors duration-300",a.value])},null,8,["class"])),r("p",{class:n(["mt-4 text-sm transition-colors duration-300 w-full text-center",t(p)?"text-gray-400 group-hover:text-indigo-400":"text-gray-600 group-hover:text-indigo-600"])},[r("span",_t,C(b.value),1)],2),r("p",{class:n(["mt-2 text-xs",V.value])},C(L.value),3),c.value&&h.showProgressDetails?(A(),F("div",Ct,[r("div",{class:n(["flex justify-between text-xs mb-1",[t(p)?"text-gray-400":"text-gray-500"]])},[r("span",null,C(w(h.uploadedBytes))+" / "+C(w(h.totalBytes)),1),r("span",null,C(h.progress)+"%",1)],2)])):Q("",!0),l.value&&h.allowRetry?(A(),F("button",{key:2,onClick:re(m,["stop"]),class:n(["mt-3 px-4 py-2 text-sm rounded-lg transition-colors duration-200",[t(p)?"bg-indigo-600 hover:bg-indigo-500 text-white":"bg-indigo-500 hover:bg-indigo-600 text-white"]])},C(h.retryText),3)):Q("",!0)],34))}}),It={class:"flex flex-col"},Tt=["value","rows","placeholder"],At=se({__name:"TextInputArea",props:{modelValue:{},rows:{default:7},placeholder:{default:"在此输入要发送的文本..."}},emits:["update:modelValue"],setup(M,{emit:v}){const{t:I}=oe(),s=M,f=v,p=ne("isDarkMode"),_=z(()=>s.placeholder||I("send.uploadArea.textInput")),g=u=>{const c=u.target;f("update:modelValue",c.value)};return(u,c)=>(A(),F("div",It,[r("textarea",{value:u.modelValue,onInput:g,rows:u.rows,placeholder:_.value,class:n(["flex-grow px-4 py-3 rounded-xl placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-indigo-500 transition duration-300 resize-none custom-scrollbar",t(p)?"bg-gray-800 bg-opacity-50 text-white":"bg-white text-gray-900 border border-gray-300"])},null,42,Tt)]))}}),Ft=ge(At,[["__scopeId","data-v-bebdfe92"]]);function zt(){try{const M=localStorage.getItem(Ke.CONFIG);if(M){const v=JSON.parse(M);if(v.uploadSize&&v.uploadSize>0)return v.uploadSize}}catch{}return Qe.MAX_FILE_SIZE}const R={IDLE:"idle",INITIALIZING:"initializing",UPLOADING:"uploading",CONFIRMING:"confirming",SUCCESS:"success",ERROR:"error"},Te=1,Ae="day";function Et(){const M=Ee(),v=E(R.IDLE),I=E(null),s=E({loaded:0,total:0,percentage:0}),f=E(""),p=E(""),_=z(()=>v.value===R.INITIALIZING),g=z(()=>v.value===R.UPLOADING),u=z(()=>v.value===R.CONFIRMING),c=z(()=>v.value===R.SUCCESS),l=z(()=>v.value===R.ERROR),T=z(()=>I.value?.mode??null),b=m=>{const h=zt();if(m.size>h){const x=Math.round(h/1024/1024);return p.value=`文件大小不能超过 ${x}MB`,M.showAlert(p.value,"error"),!1}return!0},$=m=>h=>{s.value={loaded:Math.max(0,h.loaded),total:Math.max(0,h.total),percentage:Math.min(100,Math.max(0,h.percentage))},m&&m(s.value)},a=m=>{if(v.value=R.ERROR,Je.isAxiosError(m)){const h=m.response?.status,x=m.response?.data?.detail;switch(h){case 400:p.value=x||"请求参数错误";break;case 403:p.value=x||"操作被禁止";break;case 404:p.value="上传会话不存在或已过期";break;case 500:p.value="服务器错误,请稍后重试";break;default:p.value=x||"上传失败,请重试"}}else m instanceof Error?p.value=m.message:p.value="未知错误";M.showAlert(p.value,"error")},y=async(m,h)=>{try{v.value=R.INITIALIZING;const x=await K.initUpload({file_name:m.name,file_size:m.size,expire_value:h?.expireValue??Te,expire_style:h?.expireStyle??Ae});if(x.code===200&&x.detail)return I.value=x.detail,x.detail;throw new Error(x.message||"初始化上传失败")}catch(x){return a(x),null}},L=async(m,h,x)=>{try{v.value=R.UPLOADING;const B=$(x?.onProgress);if(!await K.directUploadToS3(h.upload_url,m,B))throw new Error("S3 上传失败");v.value=R.CONFIRMING;const Z=await K.confirmUpload(h.upload_id,{expire_value:x?.expireValue??Te,expire_style:x?.expireStyle??Ae});if(Z.code===200&&Z.detail?.code)return v.value=R.SUCCESS,f.value=String(Z.detail.code),s.value={loaded:m.size,total:m.size,percentage:100},M.showAlert("文件上传成功!","success"),f.value;throw new Error(Z.message||"确认上传失败")}catch(B){return a(B),null}},V=async(m,h,x)=>{try{v.value=R.UPLOADING;const B=$(x?.onProgress),j=await K.proxyUpload(h.upload_id,m,B);if(j.code===200&&j.detail?.code)return v.value=R.SUCCESS,f.value=String(j.detail.code),s.value={loaded:m.size,total:m.size,percentage:100},M.showAlert("文件上传成功!","success"),f.value;throw new Error(j.message||"代理上传失败")}catch(B){return a(B),null}},w=async(m,h)=>{if(H(),!b(m))return v.value=R.ERROR,null;const x=await y(m,h);return x?x.mode==="direct"?await L(m,x,h):await V(m,x,h):null},O=async()=>{if(I.value?.upload_id)try{await K.cancelUpload(I.value.upload_id),M.showAlert("上传已取消","info")}catch(m){console.warn("取消上传失败:",m)}finally{H()}},Y=async()=>{if(!I.value?.upload_id)return null;try{const m=await K.getUploadStatus(I.value.upload_id);return m.code===200&&m.detail?(m.detail.is_expired&&(p.value="上传会话已过期",M.showAlert(p.value,"warning")),m.detail):null}catch(m){return a(m),null}},H=()=>{v.value=R.IDLE,I.value=null,s.value={loaded:0,total:0,percentage:0},f.value="",p.value=""};return{presignStatus:ee(v),uploadSession:ee(I),uploadProgress:ee(s),uploadedCode:ee(f),errorMessage:ee(p),isInitializing:_,isUploading:g,isConfirming:u,isSuccess:c,isError:l,currentMode:T,uploadFile:w,cancelUpload:O,getStatus:Y,reset:H}}const Dt={class:"p-8"},Ut={key:"file",class:"grid grid-cols-1 gap-8"},Pt={key:"text",class:"grid grid-cols-1 gap-8"},Rt={class:"flex flex-col space-y-3"},Bt={class:"relative flex-grow group"},$t=["placeholder"],Lt=["value"],Vt=["disabled"],jt={class:"relative z-10 flex items-center justify-center text-lg"},Nt={key:0,class:"w-6 h-6 mr-2 animate-spin",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},Gt={class:"mt-6 text-center"},Ot={class:"flex-grow overflow-y-auto p-6"},Ht={class:"flex-shrink-0 mr-4"},qt={class:"flex-grow min-w-0 mr-4"},Wt={class:"flex-shrink-0 flex space-x-2"},Xt=["onClick"],Zt=["onClick"],Jt=["onClick"],Kt={key:0,class:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-3 sm:p-4 overflow-y-auto"},Qt={class:"flex items-center justify-between"},Yt={class:"p-4 sm:p-6"},er={class:"flex items-center mb-3 sm:mb-4"},tr={class:"ml-3 sm:ml-4 min-w-0 flex-1"},rr={class:"grid grid-cols-2 gap-3 sm:gap-4"},sr={class:"flex items-center min-w-0"},ar={class:"flex items-center min-w-0"},or={class:"grid grid-cols-1 md:grid-cols-2 gap-4 sm:gap-6"},nr={class:"space-y-3 sm:space-y-4"},lr={class:"bg-gradient-to-br from-indigo-500 to-purple-600 rounded-xl p-4 sm:p-5 text-white"},ir={class:"flex items-center justify-between mb-3 sm:mb-4"},dr={class:"text-2xl sm:text-3xl font-bold tracking-wider text-center break-all"},ur={class:"flex items-center justify-between mb-2 sm:mb-3"},cr={class:"bg-white p-3 sm:p-4 rounded-lg shadow-sm mb-3 sm:mb-4"},pr=se({__name:"SendFileView",setup(M){const v=JSON.parse(localStorage.getItem("config")||"{}"),I=st(),s=ne("isDarkMode"),f=at(),p=E("file"),_=E(null),g=E(""),u=E(v.expireStyle?.[0]||"day"),c=E("1"),l=E(0),T=E(!1),b=E(null),$=E(!1),{t:a}=oe(),y=Ee(),L=z(()=>f.shareData),{uploadFile:V,reset:w}=Et(),O=E(""),Y=async o=>{_.value=o,he()&&fe(o)&&(O.value=await h(o))},H=async o=>{if(o.dataTransfer?.files&&o.dataTransfer.files.length>0){const e=o.dataTransfer.files[0];if(_.value=e,!me())return;O.value=await h(e)}},m=async o=>{const e=o.clipboardData?.items;if(e)for(let i=0;i{const D=k.trim();if(!D)return;const U=document.getElementById("text-content");if(!U){g.value+=D;return}const N=U.selectionStart,P=U.selectionEnd;if(N!==P){const G=g.value.substring(0,N),q=g.value.substring(P);g.value=G+D+q,setTimeout(()=>{const W=N+D.length;U.setSelectionRange(W,W),U.focus()},0)}else{const G=N,q=g.value.substring(0,G),W=g.value.substring(G);g.value=q+D+W,setTimeout(()=>{const le=G+D.length;U.setSelectionRange(le,le),U.focus()},0)}})}},h=async o=>{try{if(o.size<=10*1024*1024){const P=await o.arrayBuffer();if(window.isSecureContext){const J=await crypto.subtle.digest("SHA-256",P);return Array.from(new Uint8Array(J)).map(q=>q.toString(16).padStart(2,"0")).join("")}return x(o)}const e=5*1024*1024,i=o.slice(0,e),d=o.slice(-e),[k,D]=await Promise.all([i.arrayBuffer(),d.arrayBuffer()]),U=new Uint8Array(k.byteLength+D.byteLength+16);U.set(new Uint8Array(k),0),U.set(new Uint8Array(D),k.byteLength);const N=new TextEncoder().encode(o.size.toString());if(U.set(N,k.byteLength+D.byteLength),window.isSecureContext){const P=await crypto.subtle.digest("SHA-256",U);return Array.from(new Uint8Array(P)).map(G=>G.toString(16).padStart(2,"0")).join("")}return x(o)}catch(e){return console.error("File hash calculation failed:",e),x(o)}},x=o=>{const e=`${o.name}-${o.size}-${o.lastModified}`;let i=0;for(let d=0;d{switch(o){case"day":return a("send.expiration.placeholders.days");case"hour":return a("send.expiration.placeholders.hours");case"minute":return a("send.expiration.placeholders.minutes");case"count":return a("send.expiration.placeholders.count");case"forever":return a("send.expiration.placeholders.forever");default:return a("send.expiration.placeholders.default")}},j=(o=u.value)=>{switch(o){case"day":return a("send.expiration.units.days");case"hour":return a("send.expiration.units.hours");case"minute":return a("send.expiration.units.minutes");case"count":return a("send.expiration.units.times");case"forever":return a("send.expiration.units.forever");default:return""}},Z=(o,e)=>{if(o==="forever")return a("send.expiration.units.forever");if(o==="count")return a("send.messages.expiresAfterCount",{count:e});const i=new Date,d=parseInt(e);switch(o){case"minute":i.setMinutes(i.getMinutes()+d);break;case"hour":i.setHours(i.getHours()+d);break;case"day":i.setDate(i.getDate()+d);break;default:return a("send.messages.expiresAfter",{value:e,unit:j(o)})}const k=i.getFullYear(),D=(i.getMonth()+1).toString().padStart(2,"0"),U=i.getDate().toString().padStart(2,"0"),N=i.getHours().toString().padStart(2,"0"),P=i.getMinutes().toString().padStart(2,"0");return a("send.messages.expiresAt",{date:`${k}-${D}-${U} ${N}:${P}`})},De=async o=>{try{const e=await h(o);O.value=e,console.log("Calculated file hash:",e);const i=5*1024*1024,d=Math.ceil(o.size/i),k=await ae.post("chunk/upload/init/",{file_name:o.name,file_size:o.size,chunk_size:i,file_hash:O.value});if(k.code!==200)throw new Error(a("send.messages.initChunkUploadFailed"));if(k.detail?.existed)return k;const D=k.detail?.upload_id,U=new Set(k.detail?.uploaded_chunks||[]);for(let P=0;P{const Ne=Array.from(U).reduce((Oe,be)=>{const He=Math.min((be+1)*i,o.size),qe=be*i;return Oe+(He-qe)},0),Ge=Math.round((Ne+P*i+je.loaded)*100/o.size);l.value=Math.min(Ge,99)}})).code!==200)throw new Error(a("send.messages.chunkUploadFailed",{index:P}))}const N=await ae.post(`chunk/upload/complete/${D}`,{expire_value:c.value?parseInt(c.value):1,expire_style:u.value});if(N.code!==200)throw new Error(a("send.messages.completeUploadFailed"));return N}catch(e){if(console.error("切片上传失败:",e),e&&typeof e=="object"&&"response"in e){const i=e;i.response?.data?.detail&&y.showAlert(i.response.data.detail,"error")}else y.showAlert(a("send.messages.uploadFailed"),"error");throw e}},Ue=async o=>{const e=await V(o,{expireValue:c.value?parseInt(c.value):1,expireStyle:u.value,onProgress:i=>{l.value=i.percentage}});if(e)return{code:200,detail:{code:e,name:o.name}};throw new Error(a("send.messages.uploadFailed"))},he=()=>v.openUpload===0&&localStorage.getItem("token")===null?(y.showAlert(a("send.messages.guestUploadDisabled"),"error"),!1):!0,fe=o=>o.size>v.uploadSize?(y.showAlert(a("send.messages.fileSizeExceeded",{size:Ie(v.uploadSize)}),"error"),_.value=null,!1):!0,ve=(o,e)=>{if(o==="forever"||o==="count")return!0;const i=v.max_save_seconds||0;if(i===0)return!0;let d=0;switch(o){case"minute":d=parseInt(e)*60;break;case"hour":d=parseInt(e)*3600;break;case"day":d=parseInt(e)*86400;break;default:return!1}return d<=i},me=()=>!(!he()||!fe(_.value)||!ve(u.value,c.value)),Pe=async()=>{if(!$.value){$.value=!0;try{if(p.value==="file"&&!_.value){y.showAlert(a("send.messages.selectFile"),"error");return}if(p.value==="text"&&!g.value.trim()){y.showAlert(a("send.messages.enterText"),"error");return}if(u.value!=="forever"&&!c.value){y.showAlert(a("send.messages.enterExpirationValue"),"error");return}if(!ve(u.value,c.value)){const e=Math.floor(v.max_save_seconds/86400);y.showAlert(a("send.messages.expirationTooLong",{days:e}),"error");return}let o;if(p.value==="file")v.enableChunk?o=await De(_.value):o=await Ue(_.value);else{const e=new FormData;e.append("text",g.value),e.append("expire_value",c.value),e.append("expire_style",u.value),o=await ae.post("share/text/",e,{headers:{"Content-Type":"multipart/form-data"}})}if(o&&o.code===200){const e=o.detail?.code||"",i=o.detail?.name||"",d={id:Date.now(),filename:i,date:new Date().toISOString().split("T")[0],size:p.value==="text"?`${(g.value.length/1024).toFixed(2)} KB`:`${(_.value.size/(1024*1024)).toFixed(1)} MB`,expiration:u.value==="forever"?a("send.expiration.forever"):Z(u.value,c.value),retrieveCode:e};f.addShareDataRecord(d),y.showAlert(a("send.messages.sendSuccess",{code:e}),"success"),_.value=null,g.value="",l.value=0,w(),b.value=d,await ce(e)}else throw new Error(a("send.messages.serverError"))}catch(o){if(o&&typeof o=="object"&&"response"in o){const e=o;e.response?.data?.detail&&y.showAlert(e.response.data.detail,"error")}else y.showAlert(a("send.messages.sendFailed"),"error")}finally{l.value=0,$.value=!1}}},Re=()=>{I.push("/")},ye=()=>{T.value=!T.value},Be=o=>{b.value=o},$e=o=>{const e=f.shareData.findIndex(i=>i.id===o);e!==-1&&f.deleteShareData(e)},Le=window.location.origin+"/#/",Ve=o=>`${Le}?code=${o.retrieveCode}`,xe=o=>{const i=(parseInt(c.value)||0)+o;i>=1&&(c.value=i.toString())};return Fe(()=>{console.log("SendFileView mounted")}),(o,e)=>{const i=tt("router-link");return A(),F("div",{class:"min-h-screen flex items-center justify-center p-4 overflow-hidden transition-colors duration-300",onPaste:re(m,["prevent"])},[r("div",{class:n(["rounded-3xl shadow-2xl overflow-hidden border w-full max-w-md transition-colors duration-300",[t(s)?"bg-white bg-opacity-10 backdrop-filter backdrop-blur-xl border-gray-700":"bg-white border-gray-200"]])},[r("div",Dt,[S(ot,{title:t(v).name,onTitleClick:Re},null,8,["title"]),r("form",{onSubmit:re(Pe,["prevent"]),class:"space-y-8"},[S(xt,{"selected-type":p.value,"onUpdate:selectedType":e[0]||(e[0]=d=>p.value=d)},null,8,["selected-type"]),S(ie,{name:"fade",mode:"out-in"},{default:te(()=>[p.value==="file"?(A(),F("div",Ut,[S(Mt,{"selected-file":_.value,progress:l.value,description:`支持各种常见格式,最大${t(Ie)(t(v).uploadSize)}`,onFileSelected:Y,onFileDrop:H},null,8,["selected-file","progress","description"])])):(A(),F("div",Pt,[S(Ft,{modelValue:g.value,"onUpdate:modelValue":e[1]||(e[1]=d=>g.value=d),placeholder:t(a)("send.uploadArea.textInput")},null,8,["modelValue","placeholder"])]))]),_:1}),r("div",Rt,[r("label",{class:n(["text-sm font-medium",t(s)?"text-gray-300":"text-gray-700"])},C(t(a)("send.expiration.label")),3),r("div",Bt,[r("div",{class:n(["relative h-12 rounded-2xl border transition-all duration-300 shadow-sm",t(s)?"bg-gray-800/60 border-gray-700/60 group-hover:border-gray-600/80 group-hover:shadow-lg group-hover:shadow-gray-900/20":"bg-white border-gray-200 group-hover:border-gray-300 group-hover:shadow-md group-hover:shadow-gray-200/50"])},[u.value!=="forever"?(A(),F(de,{key:0},[we(r("input",{"onUpdate:modelValue":e[2]||(e[2]=d=>c.value=d),type:"number",placeholder:B(),min:"1",class:n(["w-full h-full px-5 pr-32 rounded-2xl placeholder-gray-400 transition-all duration-300","focus:outline-none focus:ring-2 focus:ring-offset-0","[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none","bg-transparent",t(s)?"text-gray-100 focus:ring-indigo-500/80 placeholder-gray-500":"text-gray-900 focus:ring-indigo-500/60 placeholder-gray-400"])},null,10,$t),[[Ye,c.value]]),r("div",{class:n(["absolute right-28 top-0 h-full flex flex-col border-l",[t(s)?"border-gray-700/60":"border-gray-200"]])},[r("button",{type:"button",onClick:e[3]||(e[3]=d=>xe(1)),class:n(["flex-1 px-2 flex items-center justify-center transition-all duration-200",[t(s)?"hover:bg-gray-700/60 text-gray-400 hover:text-gray-200":"hover:bg-gray-50 text-gray-500 hover:text-gray-700"]])},[...e[10]||(e[10]=[r("svg",{class:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 15l7-7 7 7"})],-1)])],2),r("button",{type:"button",onClick:e[4]||(e[4]=d=>xe(-1)),class:n(["flex-1 px-2 flex items-center justify-center transition-all duration-200",[t(s)?"hover:bg-gray-700/60 text-gray-400 hover:text-gray-200":"hover:bg-gray-50 text-gray-500 hover:text-gray-700"]])},[...e[11]||(e[11]=[r("svg",{class:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 9l-7 7-7-7"})],-1)])],2)],2)],64)):Q("",!0),we(r("select",{"onUpdate:modelValue":e[5]||(e[5]=d=>u.value=d),class:n(["absolute right-0 top-0 h-full appearance-none cursor-pointer transition-all duration-300","focus:outline-none focus:ring-2 focus:ring-offset-0",u.value==="forever"?"w-full px-5 rounded-2xl":"w-28 pl-4 pr-9 border-l rounded-r-2xl",t(s)?"text-gray-100 border-gray-700/60 focus:ring-indigo-500/80 bg-gray-800/60":"text-gray-900 border-gray-200 focus:ring-indigo-500/60 bg-white"]),style:ke({color:t(s)?"#f3f4f6":"#111827",backgroundColor:t(s)?"rgba(31, 41, 55, 0.5)":"#ffffff"})},[(A(!0),F(de,null,Se(t(v).expireStyle,d=>(A(),F("option",{value:d,key:d,class:n([t(s)?"bg-gray-800 text-gray-100":"bg-white text-gray-900"]),style:ke({color:t(s)?"#f3f4f6":"#111827",backgroundColor:t(s)?"#1f2937":"#ffffff"})},C(j(d)),15,Lt))),128))],6),[[et,u.value]]),r("div",{class:n(["absolute pointer-events-none",[u.value==="forever"?"right-3":"right-2","top-1/2 -translate-y-1/2"]])},[(A(),F("svg",{class:n(["w-4 h-4 transition-colors duration-300",[t(s)?"text-gray-400":"text-gray-500"]]),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[...e[12]||(e[12]=[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 9l-7 7-7-7"},null,-1)])],2))],2)],2)])]),r("button",{type:"submit",disabled:$.value,class:"w-full bg-gradient-to-r from-indigo-500 via-purple-500 to-pink-500 text-white font-bold py-4 px-6 rounded-lg focus:outline-none focus:ring-2 focus:ring-purple-500 focus:ring-opacity-50 transition-all duration-300 transform hover:scale-105 hover:shadow-lg relative overflow-hidden group disabled:opacity-50 disabled:cursor-not-allowed disabled:transform-none disabled:hover:scale-100"},[e[14]||(e[14]=r("span",{class:"absolute top-0 left-0 w-full h-full bg-white opacity-0 group-hover:opacity-20 transition-opacity duration-300"},null,-1)),r("span",jt,[$.value?(A(),F("svg",Nt,[...e[13]||(e[13]=[r("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"},null,-1),r("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"},null,-1)])])):(A(),ze(t(vt),{key:1,class:"w-6 h-6 mr-2"})),r("span",null,C($.value?t(a)("send.submitting"):t(a)("send.submit")),1)])],8,Vt)],32),r("div",Gt,[S(i,{to:"/",class:"text-indigo-400 hover:text-indigo-300 transition duration-300"},{default:te(()=>[ue(C(t(a)("send.needRetrieveFile")),1)]),_:1})])]),r("div",{class:n(["px-8 py-4 bg-opacity-50 flex justify-between items-center",[t(s)?"bg-gray-800":"bg-gray-100"]])},[r("span",{class:n(["text-sm flex items-center",[t(s)?"text-gray-300":"text-gray-800"]])},[S(t(Ce),{class:"w-4 h-4 mr-1 text-green-400"}),ue(" "+C(t(a)("send.secureEncryption")),1)],2),r("button",{onClick:ye,class:n(["text-sm hover:text-indigo-300 transition duration-300 flex items-center",[t(s)?"text-indigo-400":"text-indigo-600"]])},[ue(C(t(a)("send.sendRecords"))+" ",1),S(t(nt),{class:"w-4 h-4 ml-1"})],2)],2)],2),S(ie,{name:"drawer"},{default:te(()=>[T.value?(A(),F("div",{key:0,class:n(["fixed inset-y-0 right-0 w-full sm:w-120 bg-opacity-70 backdrop-filter backdrop-blur-xl shadow-2xl z-50 overflow-hidden flex flex-col",[t(s)?"bg-gray-900":"bg-white"]])},[r("div",{class:n(["flex justify-between items-center p-6 border-b",[t(s)?"border-gray-700":"border-gray-200"]])},[r("h3",{class:n(["text-2xl font-bold",[t(s)?"text-white":"text-gray-800"]])},C(t(a)("send.sendRecords")),3),r("button",{onClick:ye,class:n(["hover:text-white transition duration-300",[t(s)?"text-gray-400":"text-gray-800"]])},[S(t(_e),{class:"w-6 h-6"})],2)],2),r("div",Ot,[S(rt,{name:"list",tag:"div",class:"space-y-4"},{default:te(()=>[(A(!0),F(de,null,Se(L.value,d=>(A(),F("div",{key:d.id,class:n(["bg-opacity-50 rounded-lg p-4 flex items-center shadow-md hover:shadow-lg transition duration-300 transform hover:scale-102",[t(s)?"bg-gray-800 hover:bg-gray-700":"bg-gray-100 hover:bg-white"]])},[r("div",Ht,[S(t(Me),{class:n(["w-10 h-10",[t(s)?"text-indigo-400":"text-indigo-600"]])},null,8,["class"])]),r("div",qt,[r("p",{class:n(["font-medium text-lg truncate",[t(s)?"text-white":"text-gray-800"]])},C(d.filename?d.filename:"Text"),3),r("p",{class:n(["text-sm truncate",[t(s)?"text-gray-400":"text-gray-600"]])},C(d.date)+" · "+C(d.size),3)]),r("div",Wt,[r("button",{onClick:k=>t(ce)(d.retrieveCode),class:n(["p-2 rounded-full hover:bg-opacity-20 transition duration-300",[t(s)?"hover:bg-blue-400 text-blue-400":"hover:bg-blue-100 text-blue-600"]])},[S(t(pe),{class:"w-5 h-5"})],10,Xt),r("button",{onClick:k=>Be(d),class:n(["p-2 rounded-full hover:bg-opacity-20 transition duration-300",[t(s)?"hover:bg-green-400 text-green-400":"hover:bg-green-100 text-green-600"]])},[S(t(ut),{class:"w-5 h-5"})],10,Zt),r("button",{onClick:k=>$e(d.id),class:n(["p-2 rounded-full hover:bg-opacity-20 transition duration-300",[t(s)?"hover:bg-red-400 text-red-400":"hover:bg-red-100 text-red-600"]])},[S(t(ct),{class:"w-5 h-5"})],10,Jt)])],2))),128))]),_:1})])],2)):Q("",!0)]),_:1}),S(ie,{name:"fade"},{default:te(()=>[b.value?(A(),F("div",Kt,[r("div",{class:n(["w-full max-w-2xl rounded-2xl shadow-2xl transform transition-all duration-300 ease-out overflow-hidden",[t(s)?"bg-gray-900 bg-opacity-70":"bg-white bg-opacity-95"]])},[r("div",{class:n(["px-4 sm:px-6 py-3 sm:py-4 border-b",[t(s)?"border-gray-800":"border-gray-100"]])},[r("div",Qt,[r("h3",{class:n(["text-lg sm:text-xl font-semibold",[t(s)?"text-white":"text-gray-900"]])},C(t(a)("send.fileDetails")),3),r("button",{onClick:e[6]||(e[6]=d=>b.value=null),class:"p-1.5 sm:p-2 rounded-full hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors"},[S(t(_e),{class:n(["w-4 h-4 sm:w-5 sm:h-5",[t(s)?"text-gray-400":"text-gray-500"]])},null,8,["class"])])])],2),r("div",Yt,[r("div",{class:n(["rounded-xl p-3 sm:p-4 mb-4 sm:mb-6",[t(s)?"bg-gray-800 bg-opacity-50":"bg-gray-50 bg-opacity-95"]])},[r("div",er,[r("div",{class:n(["p-2 sm:p-3 rounded-lg",[t(s)?"bg-gray-800":"bg-white"]])},[S(t(Me),{class:n(["w-5 h-5 sm:w-6 sm:h-6",[t(s)?"text-indigo-400":"text-indigo-600"]])},null,8,["class"])],2),r("div",tr,[r("h4",{class:n(["font-medium text-sm sm:text-base truncate",[t(s)?"text-white":"text-gray-900"]])},C(b.value.filename),3),r("p",{class:n(["text-xs sm:text-sm truncate",[t(s)?"text-gray-400":"text-gray-500"]])},C(b.value.size)+" · "+C(b.value.date),3)])]),r("div",rr,[r("div",sr,[S(t(gt),{class:n(["w-3.5 h-3.5 sm:w-4 sm:h-4 mr-1.5 sm:mr-2 flex-shrink-0",[t(s)?"text-gray-400":"text-gray-500"]])},null,8,["class"]),r("span",{class:n(["text-xs sm:text-sm truncate",[t(s)?"text-gray-300":"text-gray-600"]])},C(b.value.expiration),3)]),r("div",ar,[S(t(Ce),{class:n(["w-3.5 h-3.5 sm:w-4 sm:h-4 mr-1.5 sm:mr-2 flex-shrink-0",[t(s)?"text-gray-400":"text-gray-500"]])},null,8,["class"]),r("span",{class:n(["text-xs sm:text-sm truncate",[t(s)?"text-gray-300":"text-gray-600"]])}," 安全加密 ",2)])])],2),r("div",or,[r("div",nr,[r("div",lr,[r("div",ir,[e[15]||(e[15]=r("h4",{class:"font-medium text-sm sm:text-base"},"取件码",-1)),r("button",{onClick:e[7]||(e[7]=d=>t(lt)(b.value.retrieveCode)),class:"p-1.5 sm:p-2 rounded-full hover:bg-white/10 transition-colors"},[S(t(pe),{class:"w-4 h-4 sm:w-5 sm:h-5"})])]),r("p",dr,C(b.value.retrieveCode),1)]),r("div",{class:n(["rounded-xl p-3 sm:p-4",[t(s)?"bg-gray-800 bg-opacity-50":"bg-gray-50 bg-opacity-95"]])},[r("div",ur,[r("h4",{class:n(["font-medium text-sm sm:text-base flex items-center min-w-0",[t(s)?"text-white":"text-gray-900"]])},[S(t(mt),{class:"w-4 h-4 sm:w-5 sm:h-5 mr-1.5 sm:mr-2 text-indigo-500 flex-shrink-0"}),e[16]||(e[16]=r("span",{class:"truncate"},"wget下载",-1))],2),r("button",{onClick:e[8]||(e[8]=d=>t(it)(b.value.retrieveCode,b.value.filename)),class:"p-1.5 sm:p-2 rounded-full hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors flex-shrink-0"},[S(t(pe),{class:n(["w-4 h-4 sm:w-5 sm:h-5",[t(s)?"text-gray-400":"text-gray-500"]])},null,8,["class"])])]),r("p",{class:n(["text-xs sm:text-sm font-mono break-all line-clamp-2",[t(s)?"text-gray-300":"text-gray-600"]])}," 点击复制wget命令 ",2)],2)]),r("div",{class:n(["rounded-xl p-4 sm:p-5 flex flex-col items-center",[t(s)?"bg-gray-800 bg-opacity-50":"bg-gray-50 bg-opacity-95"]])},[r("div",cr,[S(dt,{value:Ve(b.value),size:140,level:"M",class:"sm:w-[160px] sm:h-[160px]"},null,8,["value"])]),r("p",{class:n(["text-xs sm:text-sm truncate max-w-full",[t(s)?"text-gray-400":"text-gray-500"]])}," 扫描二维码快速取件 ",2)],2)])]),r("div",{class:n(["px-4 sm:px-6 py-3 sm:py-4 border-t",[t(s)?"border-gray-800":"border-gray-100"]])},[r("button",{onClick:e[9]||(e[9]=d=>t(ce)(b.value.retrieveCode)),class:"w-full bg-indigo-600 hover:bg-indigo-700 text-white px-4 sm:px-6 py-2 sm:py-3 rounded-lg text-sm sm:text-base font-medium transition-colors"}," 复制取件链接 ")],2)],2)])):Q("",!0)]),_:1})],32)}}}),yr=ge(pr,[["__scopeId","data-v-0a16769d"]]);export{yr as default};