1import{r as n,a0 as k,j as o,a1 as B,e as D,$ as O,B as p}from"./index-dAhzxcDZ.js";const S="https://www.nielit.gov.in",W=()=>{const[u,m]=n.useState([]),[c,h]=n.useState(""),[w,y]=n.useState(""),[F,N]=n.useState(!1),[A,v]=n.useState(!1),C=209715200,P=(e,t)=>{if(!e)return"UNKNOWN";const a=e.split(".").pop().toLowerCase();return a==="pdf"||t==="application/pdf"?"PDF":a==="doc"||a==="docx"||t==="application/msword"||t==="application/vnd.openxmlformats-officedocument.wordprocessingml.document"?"DOC":a==="zip"||t==="application/zip"?"ZIP":"OTHER"};n.useEffect(()=>{k().then(e=>{e.success&&Array.isArray(e.data)&&m(e.data)}).catch(e=>{})},[F]);const U=e=>{const t=e.target.value;y(t);const a=u.find(r=>r.doc_name===t);if(a){const{doc_id:r,doc_name:s}=a;B({doc_id:r,pdfName:s}).then(i=>{D({data:i.doc_id}).then(d=>{d&&h(`${S}/Fileviewer?fileId=`+d.data.encrypted)})}).catch(i=>{})}},j=async e=>{const t=e.target.files[0];if(!t)return;const a=t.name,r=t.type,s=localStorage.getItem("sessionData");let i;if(s)i=JSON.parse(s).session_id;else return;const d=new FileReader;d.onload=async b=>{const L=b.target.result,I=z(L);if(t.size>C){v(!0),alert("File size exceeds the allowed limit of 200MB.");return}const x=localStorage.getItem("sessionData");let _="";if(x)try{_=JSON.parse(x).center_code||""}catch{}const E={doc:I,document_id:0,doc_name:a,doc_type:r,doc_Size:t.size,Token_ID:i,FormName:"NIELIT-Main-Updates",center:_};O(E).then(l=>{const g={doc_id:l.data.document_id,doc_name:a,doc_type:r};m([...u,g]),y(g.doc_name),D({data:l.data.docid}).then(f=>{f&&h(`${S}/Fileviewer?fileId=`+f.data.encrypted)}),N(f=>!f)}).catch(l=>{})},d.readAsArrayBuffer(t)},z=e=>{let t="";const a=new Uint8Array(e),r=a.byteLength;for(let s=0;s<r;s++)t+=String.fromCharCode(a[s]);return window.btoa(t)},R=()=>{if(!c){p.error("PDF URL not available");return}if(navigator.clipboard&&window.isSecureContext)navigator.clipboard.writeText(c).then(()=>p.success("PDF URL copied to clipboard!")).catch(()=>p.error("Failed to copy URL"));else{const e=document.createElement("textarea");e.value=c,e.style.position="fixed",document.body.appendChild(e),e.focus(),e.select();try{document.execCommand("copy"),p.success("PDF URL copied to clipboard!")}catch{p.error("Failed to copy URL")}document.body.removeChild(e)}};return o.jsxs("div",{className:"toolbar",children:[o.jsxs("select",{className:"toolbar-select",onChange:U,value:w,children:[o.jsx("option",{value:"",disabled:!0,children:"Select a File"}),u.map((e,t)=>o.jsxs("option",{value:e.doc_name,children:[e.doc_name," (ID: ",e.doc_id,") [",P(e.doc_name,e.doc_type),"]"]},t))]}),o.jsx("input",{type:"file",accept:".pdf,.zip,application/pdf,application/zip",className:"toolbar-upload",onChange:j}),c&&o.jsxs("div",{className:"toolbar-actions",children:[o.jsx("a",{className:"toolbar-button",onClick:R,children:o.jsx("span",{style:{textDecoration:"none",color:"black",fontWeight:"800",cursor:"pointer"},children:"Copy URL"})}),o.jsx("a",{className:"toolbar-link",href:c,target:"_blank",rel:"noopener noreferrer",children:o.jsx("span",{style:{textDecoration:"none",color:"black",fontWeight:"800",cursor:"pointer"},children:"Open"})})]})]})};export{W 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.