1import{r,j as e}from"./vendor-react-C_xdI0Ng.js";import{L as y}from"./linear-icon-BS_Bu1OG.js";import{r as g,P as N}from"./pdf-info-client-CO7HLkbQ.js";import{a as I,P as R}from"./index-DbFRh42P.js";import"./vendor-icons-CmfhFn4k.js";async function D(s,p,c){const n=I.getState().activeDocumentId,o=I.getState().documents.find(t=>t.id===n);if(!o||o.pages.length===0)return p;const l=o.pages.map(t=>({sourceFileId:t.fileId,pageIndex:t.pageIndex,rotation:t.rotation})),f={inputs:Array.from(new Set(l.map(t=>t.sourceFileId))),operations:[{type:"reorder",sequence:l}],outputName:"studio-pdf-info-input.pdf"},i=await new R(s.vfs).execute(f),a=new Uint8Array(i.buffer.byteLength);a.set(i.buffer);const u=new Blob([a],{type:"application/pdf"});return(await s.vfs.write(new File([u],c||i.fileName,{type:"application/pdf"}))).id}function U({onClose:s,inputFileId:p,fileName:c,runtime:n}){const[h,o]=r.useState(null),[l,f]=r.useState(null),[d,i]=r.useState(!0),a=r.useRef(0),u=r.useRef(null);r.useEffect(()=>()=>{var t;return(t=u.current)==null?void 0:t.abort()},[]);const v=r.useCallback(async()=>{var b;(b=u.current)==null||b.abort();const t=++a.current,j=new AbortController;u.current=j,i(!0),f(null),o(null),n.telemetry.track({type:"TOOL_RUN_STARTED",runId:crypto.randomUUID(),toolId:"pdf-info",inputCount:1});try{const m=await D(n,p,c),x=await g(n,m,j.signal);if(t!==a.current)return;o(x),n.telemetry.track({type:"TOOL_RUN_RESULT",runId:crypto.randomUUID(),toolId:"pdf-info",durationMs:0,outputCount:0})}catch(m){if(t!==a.current||j.signal.aborted)return;const x=m instanceof Error?m.message:"Failed to analyze PDF";f(x),n.telemetry.track({type:"TOOL_RUN_ERROR",runId:crypto.randomUUID(),toolId:"pdf-info",durationMs:0,code:"PDF_INFO_FAILED",message:x})}finally{t===a.current&&i(!1)}},[c,p,n]);return r.useEffect(()=>{v()},[v]),e.jsxs("div",{className:"cvt-shell",children:[e.jsxs("nav",{className:"cvt-nav",children:[e.jsxs("a",{className:"studio-logo",href:"#",onClick:t=>{t.preventDefault(),s==null||s()},children:[e.jsx("div",{className:"studio-nav-logo-icon",children:"L"}),e.jsx("span",{className:"studio-logo-title",children:"LocalPDF"})]}),e.jsx("span",{className:"studio-nav-sep",children:"/"}),e.jsx("span",{className:"cvt-nav-tool",children:"PDF Info"}),e.jsx("div",{style:{flex:1}}),e.jsxs("button",{type:"button",className:"cvt-nav-btn",onClick:s,disabled:d,children:[e.jsx(y,{name:"chevron-left",size:12}),"All tools"]}),e.jsx("button",{type:"button",className:"cvt-nav-btn",onClick:s,disabled:d,children:"Studio"})]}),e.jsx("div",{className:"cvt-page-wrap custom-scrollbar",children:e.jsxs("div",{className:"cvt-page",children:[e.jsxs("div",{className:"cvt-tool-header",children:[e.jsx("div",{className:"cvt-tool-icon",children:e.jsx(y,{name:"file-input",size:20})}),e.jsxs("div",{children:[e.jsx("div",{className:"cvt-tool-title",children:"PDF Info"}),e.jsx("div",{className:"cvt-tool-desc",children:"Inspect pages, PDF version, encryption, fonts, and metadata."}),e.jsxs("div",{className:"cvt-privacy-badge",children:[e.jsx(y,{name:"lock",size:10}),"Processed locally · files never leave your device"]})]})]}),e.jsxs("div",{className:"cvt-stage",children:[e.jsxs("div",{className:"cvt-file-item",children:[e.jsx("div",{className:"cvt-file-icon",children:e.jsx(y,{name:"word",size:16})}),e.jsx("div",{children:e.jsx("div",{className:"cvt-file-name",children:c})})]}),d&&e.jsxs("div",{className:"pdf-info-loading",style:{justifyContent:"center",padding:"32px 0"},children:[e.jsx("div",{style:{width:32,height:32,border:"3px solid var(--border)",borderTopColor:"var(--accent)",borderRadius:"50%",animation:"cvt-spin 0.8s linear infinite"}}),e.jsx("span",{children:"Analyzing PDF locallyâ¦"})]}),l&&e.jsxs("div",{className:"pdf-info-alert pdf-info-alert--error",children:[e.jsx("strong",{children:"Analysis failed"}),e.jsx("p",{children:l}),e.jsx("button",{className:"btn-secondary",type:"button",onClick:()=>void v(),style:{marginTop:12},children:"Retry analysis"})]}),!d&&h&&e.jsx(N,{report:h})]})]})})]})}export{U as PdfInfoStudioPanel};
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.