1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4811,7199],{44811:(e,t,s)=>{s.d(t,{D4:()=>o,Ic:()=>d,Oo:()=>c,es:()=>r,listen:()=>l});var a,r,n=s(3516);async function i(e,t){window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(e,t),await (0,n.invoke)("plugin:event|unlisten",{event:e,eventId:t})}async function l(e,t,s){var a;let r="string"==typeof(null==s?void 0:s.target)?{kind:"AnyLabel",label:s.target}:null!=(a=null==s?void 0:s.target)?a:{kind:"Any"};return(0,n.invoke)("plugin:event|listen",{event:e,target:r,handler:(0,n.yw)(t)}).then(t=>async()=>i(e,t))}async function c(e,t,s){return l(e,s=>{i(e,s.id),t(s)},s)}async function d(e,t){await (0,n.invoke)("plugin:event|emit",{event:e,payload:t})}async function o(e,t,s){await (0,n.invoke)("plugin:event|emit_to",{target:"string"==typeof e?{kind:"AnyLabel",label:e}:e,event:t,payload:s})}(a=r||(r={})).WINDOW_RESIZED="tauri://resize",a.WINDOW_MOVED="tauri://move",a.WINDOW_CLOSE_REQUESTED="tauri://close-requested",a.WINDOW_DESTROYED="tauri://destroyed",a.WINDOW_FOCUS="tauri://focus",a.WINDOW_BLUR="tauri://blur",a.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",a.WINDOW_THEME_CHANGED="tauri://theme-changed",a.WINDOW_CREATED="tauri://window-created",a.WEBVIEW_CREATED="tauri://webview-created",a.DRAG_ENTER="tauri://drag-enter",a.DRAG_OVER="tauri://drag-over",a.DRAG_DROP="tauri://drag-drop",a.DRAG_LEAVE="tauri://drag-leave"},57199:(e,t,s)=>{s.r(t),s.d(t,{default:()=>f});var a=s(95155),r=s(12115),n=s(439),i=s(53961);let l=(0,s(78340).A)("Flame",[["path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z",key:"96xj49"}]]);var c=s(20232),d=s(33210),o=s(6962),u=s(40980),m=s(44811),p=s(74530);let x=[{id:"low",label:"Low",description:"Fast structural optimization. No quality loss.",icon:n.A,color:"text-emerald-500",bg:"bg-emerald-50",ring:"ring-emerald-500"},{id:"recommended",label:"Recommended",description:"Strips metadata + object streams. Best balance.",icon:i.A,color:"text-science",bg:"bg-blue-50",ring:"ring-science"},{id:"extreme",label:"Extreme",description:"Maximum compression. May slightly alter structure.",icon:l,color:"text-orange-500",bg:"bg-orange-50",ring:"ring-orange-500"}];function f({file:e}){let[t,n]=(0,r.useState)("recommended"),[i,l]=(0,r.useState)(!1),f=(0,r.useRef)(!1),[g,h]=(0,r.useState)(null),[b,v]=(0,r.useState)(null),[w,y]=(0,r.useState)(null),[N,j]=(0,r.useState)(null);(0,r.useEffect)(()=>{let e=(0,m.listen)("ocr-progress",e=>{j(e.payload)});return()=>{e.then(e=>e())}},[]);let _=e=>e<1024?e+" B":e<1048576?(e/1024).toFixed(1)+" KB":(e/1048576).toFixed(2)+" MB",E=async()=>{if(e){l(!0),h(null),v(null),j(null);try{let a="__TAURI_INTERNALS__"in window,r=e.path;if(a){let{invoke:a}=await Promise.resolve().then(s.bind(s,3516)),{tempDir:n,join:i,isAbsolute:l}=await s.e(6618).then(s.bind(s,46618)),c=!r;if(r)try{c=!await l(r)}catch(e){c=!r.includes(":\\")}if(c){v({type:"info",text:"Preparing file for native compression..."});let{writeFile:t}=await Promise.all([s.e(6618),s.e(6865)]).then(s.bind(s,6865)),a=await n(),l=e.name.replace(/[^a-zA-Z0-9._-]/g,"_");r=await i(a,`clientpdf_compress_${Date.now()}_${l}`);let c=await e.arrayBuffer();await t(r,new Uint8Array(c))}let d=await n(),o=(r.split(/[\\/]/).pop()||"document.pdf").replace(".pdf","_compressed.pdf"),u=`${d}\\${o}`;v({type:"success",text:`Compressing using native engine (${t})...`});let m=await a("compress_pdf_native",{inputPath:r,outputPath:u,level:t}),p=await a("get_file_size_native",{path:r}),x=await a("get_file_size_native",{path:m});h({originalSize:p,compressedSize:x}),v({type:"success",text:"PDF compressed successfully! Ready to save."}),y(m)}else{let s=await e.arrayBuffer(),a=s.byteLength,r=(0,p.b)(),n=await new Promise((e,a)=>{let n=Math.random().toString(36).substring(7);r.onmessage=t=>{let{id:s,status:i,buffer:l,error:c,message:d}=t.data;s===n&&("success"===i?(e(l),r.terminate()):"error"===i&&(a(Error(c)),r.terminate()))},r.onerror=e=>{a(e),r.terminate()},r.postMessage({action:"compress",id:n,payload:{buffer:s,level:t}},[s])}),i=n.byteLength,l=new Blob([n],{type:"application/pdf"}),c=URL.createObjectURL(l);
1h({originalSize:a,compressedSize:i}),y(c),v({type:"success",text:"PDF compressed successfully! Ready to save."})}}catch(e){console.error("Failed to compress PDF:",e),v({type:"error",text:"Failed to compress PDF: "+(e.message||e||"")})}finally{l(!1)}}},D=async()=>{if(w&&e)try{if("__TAURI_INTERNALS__"in window){let{save:t}=await Promise.resolve().then(s.bind(s,28014)),{copyFile:a}=await Promise.all([s.e(6618),s.e(6865)]).then(s.bind(s,6865)),r=await t({defaultPath:e.name.replace(".pdf","_compressed.pdf"),filters:[{name:"PDF Document",extensions:["pdf"]}]});r&&(await a(w,r),v({type:"success",text:"Saved successfully to your computer"}))}else{let t=document.createElement("a");t.href=w,t.download=e.name.replace(".pdf","_compressed.pdf"),document.body.appendChild(t),t.click(),document.body.removeChild(t),v({type:"success",text:"Saved to Downloads"})}}catch(e){console.error("Failed to save:",e),v({type:"error",text:"Failed to save file: "+(e.message||"")})}},A=g?Math.round((g.originalSize-g.compressedSize)/g.originalSize*100):0;return(0,a.jsxs)("div",{className:"space-y-5",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-[10px] font-bold text-muted/70 uppercase tracking-wider mb-2",children:"Compression Level"}),(0,a.jsx)("div",{className:"space-y-2",children:x.map(e=>(0,a.jsxs)("button",{onClick:()=>n(e.id),className:(0,u.cn)("w-full flex items-start gap-3 p-3 rounded-lg border transition-all text-left",t===e.id?`border-science/40 bg-science/5 ring-1 ${e.ring}/20`:"border-line/50 bg-surface hover:bg-surface-active"),children:[(0,a.jsx)("div",{className:(0,u.cn)("w-8 h-8 rounded-md flex items-center justify-center shrink-0 mt-0.5",e.bg),children:(0,a.jsx)(e.icon,{className:(0,u.cn)("w-4 h-4",e.color)})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:(0,u.cn)("text-[12px] font-semibold",t===e.id?"text-foreground":"text-foreground/80"),children:e.label}),(0,a.jsx)("p",{className:"text-[10px] text-muted/70 leading-relaxed mt-0.5",children:e.description})]})]},e.id))})]}),g&&(0,a.jsxs)("div",{className:"bg-surface-soft rounded-lg border border-line/50 p-3 space-y-2",children:[(0,a.jsxs)("div",{className:"flex justify-between text-[11px]",children:[(0,a.jsx)("span",{className:"text-muted/70",children:"Original"}),(0,a.jsx)("span",{className:"font-medium text-foreground/80",children:_(g.originalSize)})]}),(0,a.jsxs)("div",{className:"flex justify-between text-[11px]",children:[(0,a.jsx)("span",{className:"text-muted/70",children:"Compressed"}),(0,a.jsx)("span",{className:"font-medium text-science",children:_(g.compressedSize)})]}),(0,a.jsx)("div",{className:"h-px bg-line/50"}),(0,a.jsxs)("div",{className:"flex justify-between text-[11px]",children:[(0,a.jsx)("span",{className:"text-muted/70",children:"Savings"}),(0,a.jsx)("span",{className:(0,u.cn)("font-bold",A>0?"text-emerald-500":"text-muted"),children:A>0?`${A}% smaller`:"No reduction"})]})]}),(0,a.jsx)("div",{className:"space-y-2",children:w?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("button",{onClick:D,className:"w-full flex items-center justify-center gap-2 py-2.5 rounded-lg font-medium text-[13px] transition-all shadow-sm bg-green-600 text-white hover:bg-green-700 shadow-green-600/20",children:[(0,a.jsx)(o.A,{className:"w-4 h-4"}),"Save Compressed PDF"]}),(0,a.jsx)("button",{onClick:()=>{y(null),v(null),h(null)},className:"w-full py-2 text-[11px] font-medium text-muted hover:text-foreground transition-colors",children:"Compress again"})]}):(0,a.jsxs)(a.Fragment,{children:[i?(0,a.jsxs)("div",{className:"w-full bg-surface-soft border border-science/30 rounded-xl p-4 flex flex-col gap-3 relative overflow-hidden shadow-sm",children:[(0,a.jsx)("div",{className:"absolute inset-0 bg-gradient-to-r from-science/5 via-science/10 to-science/5 animate-pulse"}),(0,a.jsxs)("div",{className:"relative z-10 flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,a.jsx)("div",{className:"w-4 h-4 border-2 border-science/30 border-t-science rounded-full animate-spin"}),(0,a.jsx)("span",{className:"text-[13px] font-semibold text-foreground
1/90",children:N?N.phase:"Starting compression..."})]}),N&&(0,a.jsxs)("span",{className:"text-[11px] font-bold text-science tabular-nums",children:[Math.round(N.current/N.total*100),"%"]})]}),N&&(0,a.jsxs)("div",{className:"relative z-10 space-y-1.5 mt-1",children:[(0,a.jsxs)("div",{className:"flex justify-between text-[10px] font-medium text-muted/80 px-0.5",children:[(0,a.jsx)("span",{children:"Processing pages"}),(0,a.jsxs)("span",{children:[N.current," of ",N.total]})]}),(0,a.jsx)("div",{className:"h-2 w-full bg-line/60 rounded-full overflow-hidden shadow-inner",children:(0,a.jsx)("div",{className:"h-full bg-science rounded-full transition-all duration-300 relative",style:{width:`${Math.max(2,N.current/N.total*100)}%`},children:(0,a.jsx)("div",{className:"absolute inset-0 bg-white/20 animate-pulse"})})})]})]}):(0,a.jsxs)("button",{onClick:E,disabled:!e,className:(0,u.cn)("w-full py-2.5 rounded-lg font-semibold text-[13px] transition-all flex items-center justify-center gap-2",e?"bg-science hover:bg-science-dark text-white shadow-md hover:shadow-lg active:scale-[0.98]":"bg-surface-active text-muted cursor-not-allowed opacity-70"),children:[(0,a.jsx)(c.A,{className:"w-4 h-4"}),"Compress Document"]}),i&&(0,a.jsxs)("button",{onClick:()=>{f.current=!0,l(!1)},className:"w-full py-2 rounded-lg text-[11px] font-medium text-red-500 hover:bg-red-50 dark:hover:bg-red-500/10 border border-red-200 dark:border-red-500/30 transition-colors flex items-center justify-center gap-1.5",children:[(0,a.jsx)(d.A,{className:"w-3.5 h-3.5"})," Cancel"]})]})}),b&&(0,a.jsx)("div",{className:(0,u.cn)("rounded-lg border p-2.5 text-[11px] font-medium animate-in fade-in","error"===b.type?"bg-red-50 border-red-200 text-red-600":"bg-emerald-50 border-emerald-200 text-emerald-600"),children:b.text})]})}}}]);
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.