1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[246],{71086:function(e,t,a){(window.__NEXT_P=window.__NEXT_P||[]).push(["/pdf-tools/convert",function(){return a(62190)}])},96522:function(e,t,a){"use strict";a.d(t,{Z:function(){return i}});var r=a(85893),s=a(67294),l=a(11163),n=a(33291);function i(e){let{children:t}=e,a=(0,l.useRouter)();return(0,s.useEffect)(()=>{a.isReady&&(0,n.wM)(a.pathname)},[a.isReady,a.pathname]),(0,r.jsx)("div",{className:"flex w-full flex-1 flex-col min-h-0 bg-[var(--lightBg)] text-[var(--textBlack)]",children:t})}},52318:function(e,t,a){"use strict";a.d(t,{h:function(){return x}});var r=a(85893),s=a(41664),l=a.n(s),n=a(11163),i=a(90163),o=a(43283),d=a(66466),c=a(19449);let m=[{href:"/pdf-tools/chat",label:"Chat PDF"},{href:"/pdf-tools/rearrange",label:"Rearrange"},{href:"/pdf-tools/extract",label:"Extract"},{href:"/pdf-tools/editor",label:"Editor"},{href:"/pdf-tools/rotate",label:"Rotate"},{href:"/pdf-tools/delete-pages",label:"Delete Pages"},{href:"/pdf-tools/merge",label:"Merge"},{href:"/pdf-tools/split",label:"Split"},{href:"/pdf-tools/convert",label:"Convert"},{href:"/pdf-tools/compress",label:"Compress"}];function x(e){let{onUploadClick:t,onStartOver:a,showStartOver:s=!1}=e,x=(0,n.useRouter)().pathname||"",g=(0,c.s)(e=>e.getActiveDocument());return(0,r.jsxs)("header",{className:"flex items-center gap-3 h-14 px-3 sm:px-4 bg-white dark:bg-slate-900 border-b border-gray-200 dark:border-slate-700 shrink-0 transition-colors",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[(0,r.jsx)("nav",{className:"hidden sm:flex flex-1 min-w-0 items-center gap-2 overflow-x-auto [scrollbar-width:thin] py-1",children:m.map(e=>{let t=x===e.href;return(0,r.jsx)(l(),{href:e.href,className:"shrink-0 px-2.5 sm:px-3 py-1.5 rounded-md text-sm transition-colors whitespace-nowrap ".concat(t?"font-medium":"text-gray-500 dark:text-slate-400 hover:text-gray-700 dark:hover:text-slate-300 hover:bg-gray-50 dark:hover:bg-slate-800"),style:t?{color:"var(--primary)",backgroundColor:"var(--activedropdown)"}:void 0,children:e.label},e.href)})}),g&&"/pdf-tools/chat"===x&&(0,r.jsxs)("div",{className:"flex min-w-0 max-sm:flex-1 items-center gap-2 border-gray-200 dark:border-slate-700 sm:ml-1 sm:max-w-[220px] sm:shrink-0 sm:border-l sm:pl-2",children:[(0,r.jsx)("span",{className:"truncate text-sm text-gray-600 dark:text-slate-300",title:g.filename,children:g.filename}),(0,r.jsxs)("span",{className:"shrink-0 text-xs text-gray-400 dark:text-slate-500",children:[g.pageCount," page",1!==g.pageCount?"s":""]})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 shrink-0 pl-0 sm:pl-1",children:[s&&a&&(0,r.jsxs)(d.z,{variant:"ghost",size:"sm",type:"button",onClick:a,"aria-label":"New document â return to upload",children:[(0,r.jsx)(i.Z,{className:"w-4 h-4"}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"New document"})]}),t&&(0,r.jsxs)(d.z,{variant:"primary",size:"sm",onClick:t,children:[(0,r.jsx)(o.Z,{className:"w-4 h-4"}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"Upload"})]})]})]})}},66466:function(e,t,a){"use strict";a.d(t,{z:function(){return s}});var r=a(85893);let s=(0,a(67294).forwardRef)((e,t)=>{let{variant:a="primary",size:s="md",className:l="",children:n,disabled:i,...o}=e;return(0,r.jsx)("button",{ref:t,className:"".concat("inline-flex items-center justify-center font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 dark:focus:ring-offset-slate-900 disabled:opacity-50 disabled:cursor-not-allowed"," ").concat({primary:"button_bg text_white hover:bg-opacity-90 focus:ring-0 focus:ring-offset-0 font-lato",secondary:"bg-gray-100 dark:bg-slate-700 text-gray-700 dark:text-slate-200 hover:bg-gray-200 dark:hover:bg-slate-600 focus:ring-gray-400 border border-gray-300 dark:border-slate-600",ghost:"text-gray-600 dark:text-slate-300 hover:bg-gray-100 dark:hover:bg-slate-700 focus:ring-gray-400",danger:"bg-red-600 text-white hover:bg-red-700 focus:ring-red-500"}[a]," ").concat({sm:"px-2.5 py-1.5 text-xs gap-1",md:"px-4 py-2 text-sm gap-2",lg:"px-6 py-3 text-base gap-2"}[s]," ").concat(l),disabled:i,...o,children:n})});s.displayName="Button"},59995:function(e,t,a){"use strict";a.d(t,{Q:function(){return l}});
1var r=a(67294),s=a(33291);function l(e,t){(0,r.useEffect)(()=>{(0,s.pm)(e,t)},[e,t])}},69317:function(e,t,a){"use strict";a.d(t,{c:function(){return s},j:function(){return l}});var r=a(69495);async function s(e,t){let a=e.filter(e=>!e.deleted);if(0===a.length)throw Error("No pages to assemble");let s=await Promise.all(t.map(e=>r.PDFDocument.load(e.arrayBuffer))),l=await r.PDFDocument.create();for(let e of a){if(e.sourceFileIndex<0||e.sourceFileIndex>=s.length)throw Error("Invalid source file index: ".concat(e.sourceFileIndex));let t=s[e.sourceFileIndex],a=t.getPageCount();if(e.sourcePageNumber<0||e.sourcePageNumber>=a)throw Error("Invalid page number ".concat(e.sourcePageNumber," for source with ").concat(a," pages"));let[n]=await l.copyPages(t,[e.sourcePageNumber]),i=n.getRotation().angle;n.setRotation((0,r.degrees)(i+e.rotation)),l.addPage(n)}return l.save()}function l(e,t){let a=new Blob([e],{type:"application/pdf"}),r=URL.createObjectURL(a),s=document.createElement("a");s.href=r,s.download=t,document.body.appendChild(s);try{s.click()}finally{document.body.removeChild(s),URL.revokeObjectURL(r)}}},51821:function(e,t,a){"use strict";a.d(t,{r:function(){return s}});var r=a(34155);let s=(void 0!==r&&r.env.NEXT_PUBLIC_PDFJS_WORKER_URL?r.env.NEXT_PUBLIC_PDFJS_WORKER_URL:"")||"/pdf.worker.min.mjs"},42171:function(e,t,a){"use strict";a.d(t,{Z:function(){return r}});let r=(0,a(31134).Z)("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]])},15432:function(e,t,a){"use strict";a.d(t,{Z:function(){return r}});let r=(0,a(31134).Z)("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]])},23050:function(e,t,a){"use strict";a.d(t,{Z:function(){return r}});let r=(0,a(31134).Z)("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]])},12779:function(e,t,a){"use strict";a.d(t,{Z:function(){return r}});let r=(0,a(31134).Z)("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]])},5522:function(e,t,a){"use strict";a.d(t,{Z:function(){return r}});let r=(0,a(31134).Z)("FilePlus",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]])},68760:function(e,t,a){"use strict";a.d(t,{Z:function(){return r}});let r=(0,a(31134).Z)("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]])},23432:function(e,t,a){"use strict";a.d(t,{Z:function(){return r}});let r=(0,a(31134).Z)("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]])},37864:function(e,t,a){"use strict";a.d(t,{Z:function(){return r}});let r=(0,a(31134).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},62190:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return S}});var r=a(85893),s=a(67294),l=a(69282),n=a(96522),i=a(52318),o=a(68760),d=a(2553),c=a(88795);let m=[{mode:"pdf-to-images",icon:o.Z,title:"PDF to Images",description:"Convert each page of a PDF to PNG or JPEG images."},{mode:"images-to-pdf",icon:d.Z,title:"Images to PDF",description:"Combine multiple images into a single PDF file."}];function x(){let e=(0,c.tX)(e=>e.setMode);return(0,r.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 max-w-2xl mx-auto",children:m.map(t=>{let a=t.icon;return(0,r.jsxs)("button",{type:"button",className:"flex flex-col items-center gap-3 p-6 bg-white dark:bg-slate-800 border-2 border-gray-200 dark:border-slate-700 rounded-xl hover:border-brand-400 dark:hover:border-brand-600 hover:shadow-md transition-all text-center cursor-pointer",onClick:()=>e(t.mode),children:[(0,r.jsx)("div",{className:"w-14 h-14 bg-brand-50 dark:bg-brand-900/20 rounded-full flex items-center justify-center",children:(0,r.jsx)(a,{className:"w-7 h-7 text-brand-500"})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:t.title}),(0,r.jsx)("p",{className:"mt-1 text-sm text-gray-500 dark:text-slate-400",children:t.description})]})]},t.mode)})})}var g=a(51821),h=a(38074);let u=(0,a(31134).Z)("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);var f=a(83691),p=a(43283),b=a(23432),v=a(66466);async function y(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"png",s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:2,l=await Promise.all([a.e(4928),a.e(8764)]).then(a.bind(a,28541)),n=await l.getDocument({data:new Uint8Array(e)}).promise,i=t.replace(/\.pdf$/i,"").replace(/[^\w\s.-]/g,"_"),o="png"===r?"png":"jpg",d="png"===r?"image/png":"image/jpeg",c="jpeg"===r?.92:void 0,m=[];for(let e=1;e<=n.numPages;e++){let t=await n.getPage(e),a=t.getViewport({scale:s}),r=document.createElement("canvas");r.width=Math.floor(a.width),r.height=Math.floor(a.height);let l=r.getContext("2d");if(!l)throw Error("Failed to get canvas context");
1await t.render({canvasContext:l,viewport:a}).promise;let x=await new Promise((e,t)=>{r.toBlob(a=>a?e(a):t(Error("Failed to create image blob")),d,c)});m.push({filename:"".concat(i,"-page-").concat(e,".").concat(o),blob:x})}return n.destroy(),m}let j=[{value:"png",label:"PNG"},{value:"jpeg",label:"JPEG"}],k=[{value:1,label:"1x (72 DPI)"},{value:1.5,label:"1.5x (108 DPI)"},{value:2,label:"2x (144 DPI)"},{value:3,label:"3x (216 DPI)"}];function w(){let e=(0,c.tX)(e=>e.pdfSource),t=(0,c.tX)(e=>e.setPdfSource),l=(0,c.tX)(e=>e.imageFormat),n=(0,c.tX)(e=>e.imageScale),i=(0,c.tX)(e=>e.setImageFormat),d=(0,c.tX)(e=>e.setImageScale),m=(0,c.tX)(e=>e.isProcessing),x=(0,c.tX)(e=>e.setIsProcessing),w=(0,c.tX)(e=>e.setStep),N=(0,c.tX)(e=>e.setMode),[C,P]=(0,s.useState)(null),[D,Z]=(0,s.useState)(null),[F,R]=(0,s.useState)(!1),X=(0,s.useCallback)(async e=>{if(P(null),0===e.length)return;let r=e[0];R(!0);try{let e=await r.arrayBuffer(),s=await Promise.all([a.e(4928),a.e(8764)]).then(a.bind(a,28541));s.GlobalWorkerOptions.workerSrc=g.r;let l=await s.getDocument({data:e.slice(0)}).promise,n=l.numPages;l.destroy();let i=URL.createObjectURL(new Blob([e],{type:"application/pdf"}));t({filename:r.name,arrayBuffer:e,blobUrl:i,pageCount:n})}catch(e){P("Failed to read PDF. Please make sure the file is a valid PDF.")}finally{R(!1)}},[t]),{getRootProps:E,getInputProps:I,isDragActive:U}=(0,h.uI)({onDrop:X,accept:{"application/pdf":[".pdf"]},maxSize:26214400,multiple:!1,disabled:F||m}),z=(0,s.useCallback)(async()=>{if(!m&&e){Z(null),x(!0);try{let t=await y(e.arrayBuffer,e.filename,l,n);for(let e=0;e<t.length;e++)!function(e,t){let a=URL.createObjectURL(e),r=document.createElement("a");r.href=a,r.download=t,document.body.appendChild(r);try{r.click()}finally{document.body.removeChild(r),URL.revokeObjectURL(a)}}(t[e].blob,t[e].filename),e<t.length-1&&await new Promise(e=>setTimeout(e,300));w("download")}catch(e){Z(e instanceof Error?e.message:"Conversion failed")}finally{x(!1)}}},[e,l,n,m,x,w]),_=(0,s.useCallback)(()=>{N("pdf-to-images"),c.tX.setState({step:"choose",pdfSource:null})},[N]);return(0,r.jsx)("div",{className:"flex-1 flex flex-col items-center p-4 sm:p-6 bg-gray-50 dark:bg-slate-900 transition-colors overflow-auto",children:(0,r.jsxs)("div",{className:"w-full max-w-xl space-y-6",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)(v.z,{variant:"ghost",size:"sm",onClick:_,children:[(0,r.jsx)(u,{className:"w-4 h-4"}),(0,r.jsx)("span",{children:"Back"})]}),(0,r.jsx)("h2",{className:"text-xl font-bold text-gray-900 dark:text-white",children:"PDF to Images"})]}),e?(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 bg-white dark:bg-slate-800 rounded-lg border border-gray-200 dark:border-slate-700 px-4 py-3",children:[(0,r.jsx)("div",{className:"w-10 h-10 bg-brand-50 dark:bg-brand-900/20 rounded-lg flex items-center justify-center shrink-0",children:(0,r.jsx)(f.Z,{className:"w-5 h-5 text-brand-500"})}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:e.filename}),(0,r.jsxs)("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:[e.pageCount," page",1!==e.pageCount?"s":""," â"," ",e.pageCount," image",1!==e.pageCount?"s":""]})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-slate-300 mb-2",children:"Output format"}),(0,r.jsx)("div",{className:"flex gap-2",children:j.map(e=>(0,r.jsx)("button",{type:"button",className:"px-4 py-2 text-sm font-medium rounded-lg border-2 transition-colors ".concat(l===e.value?"border-brand-500 bg-brand-50 dark:bg-brand-900/20 text-brand-600 dark:text-brand-400":"border-gray-200 dark:border-slate-700 bg-white dark:bg-slate-800 text-gray-600 dark:text-slate-300 hover:border-brand-300"),onClick:()=>i(e.value),children:e.label},e.value))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{htmlFor:"scale-select",className:"block text-sm font-medium text-gray-700 dark:text-slate-300 mb-2",children:"Resolution"}),(0,r.jsx)("select",{id:"scale-select",className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-slate-600 rounded-lg bg-white dark:bg-slate-800 text-gray-700 dark:text-slate-200 focus:outline-none focus:ring-2 focus:ring-brand-500",value:n,onChange:e=>d(Number(e.target.value)),children:k.map(e=>(0,r.jsx)("option",{value:e.value,children:e.label},e.value))})]}),(0,r.jsxs)(v.z,{variant:"primary",size:"lg",className:"w-full",onClick:z,disabled:m,children:[m?(0,r.jsx)(b.Z,{className:"w-5 h-5 animate-spin"}):(0,r.jsx)(o.Z,{className:"w-5 h-5"}
1),(0,r.jsx)("span",{children:m?"Converting...":"Convert to ".concat(l.toUpperCase())})]}),D&&(0,r.jsx)("p",{className:"text-xs text-red-500",children:D})]}):(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{...E(),className:"relative border-2 border-dashed rounded-xl p-12 text-center cursor-pointer transition-all ".concat(U?"border-brand-500 bg-brand-50 dark:bg-brand-900/20":F?"border-gray-200 dark:border-slate-600 bg-gray-50 dark:bg-slate-800 cursor-wait":"border-gray-300 dark:border-slate-600 hover:border-brand-400 hover:bg-gray-50 dark:hover:bg-slate-800"),children:[(0,r.jsx)("input",{...I()}),F?(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("div",{className:"w-12 h-12 mx-auto bg-brand-100 dark:bg-brand-900/30 rounded-full flex items-center justify-center",children:(0,r.jsx)(f.Z,{className:"w-6 h-6 text-brand-600 animate-pulse"})}),(0,r.jsx)("p",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Processing PDF..."})]}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("div",{className:"w-16 h-16 mx-auto bg-brand-50 dark:bg-brand-900/20 rounded-full flex items-center justify-center",children:(0,r.jsx)(p.Z,{className:"w-8 h-8 ".concat(U?"text-brand-600":"text-brand-500")})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-base font-medium text-gray-700 dark:text-slate-300",children:U?"Drop your PDF here":"Upload a PDF to convert to images"}),(0,r.jsx)("p",{className:"mt-1 text-sm text-gray-500 dark:text-slate-400",children:"Drag and drop or click to browse"})]})]})]}),C&&(0,r.jsx)("div",{className:"mt-3 p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:(0,r.jsx)("p",{className:"text-sm text-red-600 dark:text-red-400",children:C})})]})]})})}var N=a(5522),C=a(12779),P=a(15432),D=a(42171),Z=a(37864);function F(e){let{file:t,index:a,total:s,onMoveUp:l,onMoveDown:n,onRemove:i}=e;return(0,r.jsxs)("div",{className:"flex items-center gap-3 bg-white dark:bg-slate-800 rounded-lg border border-gray-200 dark:border-slate-700 px-4 py-3 shadow-sm hover:shadow-md transition-shadow",children:[(0,r.jsx)("div",{className:"shrink-0 w-12 h-12 rounded-lg overflow-hidden bg-gray-100 dark:bg-slate-700",children:(0,r.jsx)("img",{src:t.objectUrl,alt:t.filename,className:"w-full h-full object-cover"})}),(0,r.jsx)("div",{className:"flex-1 min-w-0",children:(0,r.jsx)("p",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:t.filename})}),(0,r.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,r.jsx)("button",{type:"button",className:"p-1 rounded hover:bg-gray-100 dark:hover:bg-slate-700 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",onClick:()=>l(t.id),disabled:0===a,"aria-label":"Move ".concat(t.filename," up"),children:(0,r.jsx)(P.Z,{className:"w-4 h-4 text-gray-500 dark:text-slate-400"})}),(0,r.jsx)("button",{type:"button",className:"p-1 rounded hover:bg-gray-100 dark:hover:bg-slate-700 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",onClick:()=>n(t.id),disabled:a===s-1,"aria-label":"Move ".concat(t.filename," down"),children:(0,r.jsx)(D.Z,{className:"w-4 h-4 text-gray-500 dark:text-slate-400"})})]}),(0,r.jsx)("button",{type:"button",className:"p-1.5 rounded hover:bg-red-50 dark:hover:bg-red-900/30 transition-colors",onClick:()=>i(t.id),"aria-label":"Remove ".concat(t.filename),children:(0,r.jsx)(Z.Z,{className:"w-4 h-4 text-red-500"})})]})}var R=a(69495);async function X(e){if(0===e.length)throw Error("No images to convert");let t=await R.PDFDocument.create();for(let a of e){let e;let r=new Uint8Array(a.arrayBuffer);e=a.filename.toLowerCase().endsWith(".png")?await t.embedPng(r):await t.embedJpg(r),t.addPage([e.width,e.height]).drawImage(e,{x:0,y:0,width:e.width,height:e.height})}return t.save()}var E=a(69317);function I(){let e=(0,c.tX)(e=>e.imageFiles),t=(0,c.tX)(e=>e.addImageFiles),a=(0,c.tX)(e=>e.removeImageFile),l=(0,c.tX)(e=>e.moveImageUp),n=(0,c.tX)(e=>e.moveImageDown),i=(0,c.tX)(e=>e.isProcessing),d=(0,c.tX)(e=>e.setIsProcessing),m=(0,c.tX)(e=>
1e.setStep),[x,g]=(0,s.useState)(null),[f,y]=(0,s.useState)(null),j=(0,s.useRef)(null),k=(0,s.useCallback)(async e=>{g(null);try{let a=[];for(let t of e){let e=await t.arrayBuffer(),r=URL.createObjectURL(t);a.push({id:(0,c.lk)(),filename:t.name,arrayBuffer:e,objectUrl:r})}t(a)}catch(e){g("Failed to read one or more image files.")}},[t]),w=(0,s.useCallback)(async e=>{0!==e.length&&await k(e)},[k]),{getRootProps:P,getInputProps:D,isDragActive:Z}=(0,h.uI)({onDrop:w,accept:{"image/png":[".png"],"image/jpeg":[".jpg",".jpeg"]},maxSize:26214400,multiple:!0,disabled:i}),R=(0,s.useCallback)(()=>{var e;null===(e=j.current)||void 0===e||e.click()},[]),I=(0,s.useCallback)(async e=>{let t=e.target.files;t&&0!==t.length&&(await k(Array.from(t)),j.current&&(j.current.value=""))},[k]),U=(0,s.useCallback)(async()=>{if(!i&&0!==e.length){y(null),d(!0);try{let t=await X(e.map(e=>({filename:e.filename,arrayBuffer:e.arrayBuffer})));(0,E.j)(t,"images-combined.pdf"),m("download")}catch(e){y(e instanceof Error?e.message:"Conversion failed")}finally{d(!1)}}},[e,i,d,m]),z=(0,s.useCallback)(()=>{c.tX.setState({step:"choose",imageFiles:[]})},[]);return(0,r.jsxs)("div",{className:"flex-1 flex flex-col p-4 sm:p-6 bg-gray-50 dark:bg-slate-900 transition-colors overflow-auto",children:[(0,r.jsxs)("div",{className:"w-full max-w-xl mx-auto space-y-6",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)(v.z,{variant:"ghost",size:"sm",onClick:z,children:[(0,r.jsx)(u,{className:"w-4 h-4"}),(0,r.jsx)("span",{children:"Back"})]}),(0,r.jsx)("h2",{className:"text-xl font-bold text-gray-900 dark:text-white",children:"Images to PDF"})]}),0===e.length?(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{...P(),className:"relative border-2 border-dashed rounded-xl p-12 text-center cursor-pointer transition-all ".concat(Z?"border-brand-500 bg-brand-50 dark:bg-brand-900/20":"border-gray-300 dark:border-slate-600 hover:border-brand-400 hover:bg-gray-50 dark:hover:bg-slate-800"),children:[(0,r.jsx)("input",{...D()}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("div",{className:"w-16 h-16 mx-auto bg-brand-50 dark:bg-brand-900/20 rounded-full flex items-center justify-center",children:(0,r.jsx)(p.Z,{className:"w-8 h-8 ".concat(Z?"text-brand-600":"text-brand-500")})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-base font-medium text-gray-700 dark:text-slate-300",children:Z?"Drop your images here":"Upload images to combine into a PDF"}),(0,r.jsx)("p",{className:"mt-1 text-sm text-gray-500 dark:text-slate-400",children:"Drag and drop or click to browse (PNG, JPEG)"})]}),(0,r.jsxs)("div",{className:"flex items-center justify-center gap-3 text-xs text-gray-400 dark:text-slate-500",children:[(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)(o.Z,{className:"w-3 h-3"})," PNG & JPEG"]}),(0,r.jsx)("span",{className:"text-gray-300 dark:text-slate-600",children:"|"}),(0,r.jsx)("span",{children:"Max 25MB each"})]})]})]}),x&&(0,r.jsx)("div",{className:"mt-3 p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:(0,r.jsx)("p",{className:"text-sm text-red-600 dark:text-red-400",children:x})})]}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("div",{className:"space-y-3",children:e.map((t,s)=>(0,r.jsx)(F,{file:t,index:s,total:e.length,onMoveUp:l,onMoveDown:n,onRemove:a},t.id))}),(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsxs)(v.z,{variant:"secondary",size:"sm",onClick:R,children:[(0,r.jsx)(N.Z,{className:"w-4 h-4"}),(0,r.jsx)("span",{children:"Add more images"})]}),(0,r.jsxs)("span",{className:"text-sm text-gray-500 dark:text-slate-400",children:[e.length," image",1!==e.length?"s":""]})]}),x&&(0,r.jsx)("p",{className:"text-xs text-red-500",children:x}),(0,r.jsxs)(v.z,{variant:"primary",size:"lg",className:"w-full",onClick:U,disabled:i,children:[i?(0,r.jsx)(b.Z,{className:"w-5 h-5 animate-spin"}):(0,r.jsx)(C.Z,{className:"w-5 h-5"}),(0,r.jsx)("span",{children:i?"Converting...":"Convert to PDF"})]}),f&&(0,r.jsx)("p",{className:"text-xs text-red-500",children:f})]})]}),(0,r.jsx)("input",{ref:j,type:"file",accept:".png,.jpg,.jpeg,image/png,image/jpeg",multiple:!0,className:"hidden",onChange:I})]})}var U=a(59995),z=a(23050),_=a(33291);function M(){let e=(0,c.tX)(e=>e.reset),t=(0,c.tX)(e=>e.mode);return(0,s.useEffect)(()=>{(0,_.Ww)("convert")},[]),(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center p-4 bg-gray-50 dark:bg-slate-900",children:(0,r.jsxs)("div",{className:"text-center space-y-6",children:[(0,r.jsx)("div",{className:"w-16 h-16 mx-auto bg-green-100 dark:bg-green-900/30 rounded-full flex items-center justify-center",children:(0,r.jsx)(z.Z,{className:"w-8 h-8 text-green-600 dark:text-green-400"})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"Download complete!"}),(0,r.jsx)("p",{className:"mt-2 text-gray-500 dark:text-slate-400",children:"pdf-to-images"===t?"Your images have been downloaded.":"Your PDF has been downloaded."})]}),(0,r.jsxs)(v.z,{variant:"primary",size:"lg",onClick:()=>{(0,_.CS)("convert"),e()},children:[(0,r.jsx)(d.Z,{className:"w-5 h-5"}),"Convert another file"]})]})})}function S(){let e=(0,c.tX)(e=>e.step),t=(0,c.tX)(e=>e.mode),a=(0,c.tX)(e=>e.reset);return(0,U.Q)("convert","process"===e?"process_".concat(t):e),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l.Z,{route:"convert"}),(0,r.jsx)(n.Z,{children:(0,r.jsxs)("div",{className:"flex flex-1 flex-col min-h-0",children:[(0,r.jsx)(i.h,{onStartOver:a,showStartOver:!0}),"choose"===e&&(0,r.jsx)("main",{className:"flex-1 flex items-center justify-center p-4 bg-gray-50 dark:bg-slate-900 transition-colors",children:(0,r.jsxs)("div",{className:"text-center space-y-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"text-3xl font-bold text-gray-900 dark:text-white",children:"Convert PDF"}),(0,r.jsx)("p",{className:"mt-2 text-gray-500 dark:text-slate-400 max-w-md mx-auto",children:"Convert between PDF and image formats â all processing happens in your browser."})]}),(0,r.jsx)(x,{})]})}),"process"===e&&"pdf-to-images"===t&&(0,r.jsx)("main",{className:"flex-1 overflow-hidden bg-gray-50 dark:bg-slate-900 transition-colors",children:(0,r.jsx)(w,{})}),"process"===e&&"images-to-pdf"===t&&(0,r.jsx)("main",{className:"flex-1 overflow-hidden bg-gray-50 dark:bg-slate-900 transition-colors",children:(0,r.jsx)(I,{})}),"download"===e&&(0,r.jsx)(M,{})]})})]})}}},function(e){e.O(0,[9070,9495,6774,2888,9774,179],function(){return e(e.s=71086)}),_N_E=e.O()}]);
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.