1import{r as s,j as e}from"./chunk-EPOLDU6W-CffQmu0Y.js";import{c as u}from"./clsx-B-dksMZM.js";import{u as B}from"./useTranslation-DiMRLYFC.js";function J({className:j,file:f,onRemoveFile:y,fileName:L="",editing:k=!1,canDownload:N=!0,size:d,scale:x=.49}){const{t:p}=B(),h=s.useRef(null),c=s.useRef(null),[o,C]=s.useState(),[r,g]=s.useState(1),[a,P]=s.useState(0),[b,A]=s.useState(""),R=()=>{const t=document.createElement("script");t.src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.9.359/pdf.min.js",t.onload=()=>{window.pdfjsLib.GlobalWorkerOptions&&(window.pdfjsLib.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.9.359/pdf.worker.min.js")},document.body.appendChild(t)},D=()=>{const t=document.createElement("a"),n=(L??"document")+".pdf";t.href=f,t.download=n,t.click()},w=s.useCallback(async(t,n=o)=>{if(n){P(n.numPages);const m=await n.getPage(t),i=m.getViewport({scale:x}),l=h.current;if(l){l.height=d?.height??i.height,l.width=d?.width??i.width,c.current&&c.current.cancel();const M={canvasContext:l.getContext("2d"),viewport:i};c.current=m.render(M),c.current.promise.catch(v=>{v.name!=="RenderingCancelledException"&&console.error(v)})}}},[o,x,d]);s.useEffect(()=>{R();const t=async()=>{try{const i=await window.pdfjsLib.getDocument(f).promise;C(i)}catch(n){A(n.message)}};if(window.pdfjsLib)t();else{const n=setInterval(()=>{window.pdfjsLib&&(clearInterval(n),t())},100)}},[f]),s.useEffect(()=>{w(r,o)},[o,r,w]);const E=()=>{o&&r<o.numPages&&g(r+1)},S=()=>{r>1&&g(r-1)};return e.jsx("div",{id:"pdf-viewer",className:u(j,"border-border text-muted-foreground bg-background items-center overflow-hidden rounded-md border border-dashed"),style:{height:d?.height??"auto",width:d?.width??"auto"},children:b?e.jsx("div",{className:"text-red-500",children:b}):o?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between p-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("div",{onClick:t=>{t.preventDefault()},className:"left-0 top-0 ml-1 mt-1 flex origin-top-left cursor-default items-center space-x-2",children:e.jsxs("span",{className:"relative z-0 inline-flex rounded-md shadow-2xs",children:[e.jsxs("button",{type:"button",className:u("focus:border-theme-500 focus:ring-ring border-border text-muted-foreground bg-background relative inline-flex items-center rounded-l-md border px-1 py-1 text-xs font-medium focus:z-10 focus:outline-hidden focus:ring-1",r===1&&"bg-secondary cursor-not-allowed",r!==1&&"hover:bg-secondary"),disabled:r===1,onClick:t=>{t.preventDefault(),S()},children:[e.jsx("span",{className:"sr-only",children:p("shared.previous")}),e.jsx("svg",{className:"h-4 w-4",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{fillRule:"evenodd",d:"M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z",clipRule:"evenodd"})})]}),e.jsxs("span",{className:"border-border bg-background text-foreground/80 relative -ml-px inline-flex select-none items-center border px-2 py-1 text-xs font-medium",children:[r," / ",a]}),e.jsxs("button",{type:"button",className:u("focus:border-theme-500 focus:ring-ring hover:bg-secondary border-border text-muted-foreground bg-background relative -ml-px inline-flex items-center rounded-r-md border px-1 py-1 text-xs font-medium focus:z-10 focus:outline-hidden focus:ring-1",r===a&&"bg-secondary cursor-not-allowed",r!==a&&"hover:bg-secondary"),disabled:r===a,onClick:t=>{t.preventDefault(),E()},children:[e.jsx("span",{className:"sr-only",children:p("shared.next")}),e.jsx("svg",{className:"h-4 w-4",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{fillRule:"evenodd",d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z",clipRule:"evenodd"})})]})]})}),N&&e.jsx("button",{type:"button",className:"focus:ring-ring hover:bg-secondary border-border text-muted-foreground right-0 top-0 mr-0 mt-1 inline-flex origin-top-right items-center rounded px-1.5 py-1.5 text-xs font-medium focus:outline-hidden focu
1s:ring-2 focus:ring-offset-1",onClick:t=>{t.preventDefault(),D()},children:e.jsx("svg",{className:"h-4 w-4",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",width:"24",height:"24",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M 11 2 C 10.448 2 10 2.448 10 3 L 10 11 L 6.5 11 A 0.5 0.5 0 0 0 6 11.5 A 0.5 0.5 0 0 0 6.1464844 11.853516 A 0.5 0.5 0 0 0 6.1777344 11.882812 L 11.283203 16.697266 L 11.316406 16.728516 A 1 1 0 0 0 12 17 A 1 1 0 0 0 12.683594 16.728516 L 12.697266 16.716797 A 1 1 0 0 0 12.707031 16.705078 L 17.810547 11.892578 A 0.5 0 0 0 17.839844 11.865234 L 17.847656 11.859375 A 0.5 0 0 0 17.853516 11.853516 A 0.5 0 0 0 18 11.5 A 0.5 0 0 0 17.5 11 L 14 11 L 14 3 C 14 2.448 13.552 2 13 2 L 12 2 L 11 2 z M 3 20 A 1.0001 1.0001 0 1 0 3 22 L 21 22 A 1.0001 1.0001 0 1 0 21 20 L 3 20 z"})})})]}),e.jsx("div",{className:"flex cursor-default items-center space-x-2",children:k&&e.jsx("button",{type:"button",className:"focus:ring-ring hover:bg-secondary border-border text-muted-foreground right-0 top-0 mr-0 mt-1 inline-flex origin-top-right items-center rounded px-1.5 py-1.5 text-xs font-medium focus:outline-hidden focus:ring-2 focus:ring-offset-1",onClick:y,children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})})]}),e.jsx("div",{className:"mx-auto flex items-center justify-center py-4 text-center",children:e.jsx("canvas",{ref:h})})]}):e.jsx("div",{className:u("flex items-center justify-center",d?"h-full p-12":"h-64 p-12"),children:e.jsx("div",{className:"base-spinner text-muted-foreground flex justify-center p-12 text-sm italic"})})})}export{J as P};
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.