1import{r as c,j as e}from"./react-BxeXOeIu.js";import{aN as m,m as k,aj as D,j as S,bf as b,f as P,a_ as T,aZ as U}from"./icons-vendor-CNxPEA7v.js";function L(){const[v,d]=c.useState(!1),[g,p]=c.useState(0),[a,h]=c.useState(null),[r,f]=c.useState({show:!1,message:"",type:"success"}),[u,n]=c.useState(null),x=c.useRef(null),o=(s,i="success")=>{f({show:!0,message:s,type:i}),setTimeout(()=>{f({...r,show:!1})},3e3)},w=s=>{const i=s.target.files[0];i&&j(i)},y=s=>{s.preventDefault(),s.stopPropagation();const i=s.dataTransfer.files[0];i&&j(i)},j=s=>{if(s.size>50*1024*1024){o("File too large. Maximum size is 50MB.","error");return}d(!0),p(0);const i=new FormData;i.append("file",s);const t=new XMLHttpRequest;t.upload.addEventListener("progress",l=>{if(l.lengthComputable){const C=l.loaded/l.total*100;p(C)}}),t.open("POST","/api/privatefileshare/upload",!0),t.onreadystatechange=function(){if(t.readyState===4)if(d(!1),t.status===200)try{const l=JSON.parse(t.responseText);l.success?(h(l.file),o("File uploaded successfully!","success")):o("Upload failed: "+l.message,"error")}catch{o("Upload failed: Invalid response","error")}else o("Upload failed","error")},t.send(i)},N=s=>{if(s===0)return"0 Bytes";const i=1024,t=["Bytes","KB","MB","GB","TB"],l=Math.floor(Math.log(s)/Math.log(i));return parseFloat((s/Math.pow(i,l)).toFixed(2))+" "+t[l]},F=()=>{if(a){const s=`${window.location.origin}${a.shareLink}`;navigator.clipboard.writeText(s),o("Link copied to clipboard!","info")}},z=s=>{if(s.preventDefault(),!a)return;const i=`/api/privatefileshare/file/${a.id}`,t=a.type;t.startsWith("image/")?n(e.jsx("img",{src:i,alt:"Preview"})):t.startsWith("video/")?n(e.jsx("div",{className:"video-player-container",children:e.jsx("video",{controls:!0,src:i,style:{width:"100%"}})})):t.startsWith("audio/")?n(e.jsx("div",{className:"audio-player-container",children:e.jsx("audio",{controls:!0,src:i,style:{width:"100%"}})})):n(t==="application/pdf"?e.jsx("iframe",{src:i,style:{width:"100%",height:"500px",border:"none"},title:"PDF Preview"}):e.jsxs("div",{style:{padding:"20px",textAlign:"center"},children:[e.jsx(U,{size:64,color:"var(--accent-color)",style:{marginBottom:"15px"}}),e.jsx("p",{children:"This file type cannot be previewed."}),e.jsx("p",{children:"Please download the file to view it."})]}))};return e.jsxs("div",{className:"private-fileshare-page",children:[e.jsxs("div",{className:"container",children:[e.jsxs("header",{children:[e.jsx("h1",{children:"Private File Share"}),e.jsx("p",{children:"Upload, share, and preview files privately with secure links"})]}),e.jsx("main",{children:a?e.jsxs("div",{className:"card",id:"result-section",children:[e.jsx("h2",{children:"File Uploaded Successfully"}),e.jsxs("div",{className:"file-info",children:[e.jsxs("div",{className:"file-details",children:[e.jsxs("p",{children:[e.jsx("strong",{children:"Name:"})," ",a.name]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Size:"})," ",N(a.size)]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Type:"})," ",a.type]})]}),e.jsxs("div",{className:"share-link",children:[e.jsx("input",{type:"text",value:`${window.location.origin}${a.shareLink}`,readOnly:!0}),e.jsxs("button",{className:"copy-btn",onClick:F,children:[e.jsx(k,{size:16,style:{marginRight:"5px"}})," Copy"]})]}),e.jsxs("div",{className:"file-actions",children:[e.jsxs("button",{className:"btn",onClick:z,children:[e.jsx(D,{size:16})," Preview"]}),e.jsxs("a",{href:`/api/privatefileshare/download/${a.id}`,className:"btn",children:[e.jsx(S,{size:16})," Download"]}),e.jsxs("button",{className:"btn",onClick:()=>{h(null),n(null)},children:[e.jsx(m,{size:16})," Upload Another"]})]})]}),u&&e.jsx("div",{className:"file-preview",children:u})]}):e.jsxs("div",{className:"card",id:"upload-section",children:[e.jsx("h2",{children:"Upload File"}),e.jsxs("p",{children:["Maximum file size: ",e.jsx("strong",{children:"50MB"})]}),e.jsxs("div",{className:"upload-area",onClick:()=>x.current.click(),onDragOver:s=>{s.preventDefault(),s.currentTarget.classList.add("highlight")},onDragLeave:s=>{s.preventDefault(),s.currentTarget.classList.remove("highlight")},onDrop:y,children:[e.jsx(m,{className:"upload-icon",size:48}),e.jsx("p",{children:"Drag & drop files here or click to browse"}),e.jsx("input",{type:"file",ref:x,className:"hidden",onChange:w}),v&&e.jsx("div",{className:"progress-container",children:e.jsx("div",{className:"progress-bar",style:{width:`${g}%`}})})]})]})})]}),e.jsxs("div",{className:`notification ${r.show?"show":""}`,children:[r.type==="success"&&e.jsx(b,{size:20,color:"#4CAF50"}),r.type==="error"&&e.jsx(P,{size:20,color:"#F44336"}),r.type==="info"&&e.jsx(T,{size:20,color:"#2196F3"}),e.jsx("span",{children:r.message})]})]})}export{L as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.