1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[73],{73:(e,t,l)=>{l.r(t),l.d(t,{DocumentServerConversionTool:()=>c,EXPANSION_DOCUMENT_CONVERSION_WIDGETS:()=>d});var s=l(95155),r=l(12115),a=l(9214),n=l(67288),i=l(71470);async function o(e){try{let t=await e.json();if("string"==typeof t.error)return t.error}catch{}return`The server returned ${e.status}.`}function c({slug:e}){let t=i.Mw[e],[l,d]=(0,r.useState)([]),[p,u]=(0,r.useState)(t.formats[0]),[h,m]=(0,r.useState)(!1),[f,x]=(0,r.useState)(null),[b,j]=(0,r.useState)(null),g=h?"Uploading and converting the document.":b?`Document conversion complete. The ${p.toUpperCase()} file is ready to download.`:f?"Document conversion failed.":"Ready to convert a document.";async function v(){let t=l[0];if(!t||!t.size||t.size>0x1900000)return x("Choose a non-empty document no larger than 25 MB.");m(!0),x(null),j(null);try{let l=await fetch(`/api/expansion-document-conversion/${e}?format=${p}`,{method:"POST",headers:{"content-type":t.type||"application/octet-stream"},body:t});if(!l.ok)throw Error(await o(l));let s=await l.blob(),r=l.headers.get("content-disposition")??"",a=/filename="([^"]+)"/.exec(r)?.[1]??`pages-tools-document.${p}`;j({blob:s,fileName:a,summary:`${p.toUpperCase()} document generated by the server.`,originalBytes:t.size})}catch(e){x(e instanceof Error?e.message:"Conversion failed.")}finally{m(!1)}}return(0,s.jsxs)(n.xP,{title:t.title,description:t.description,children:[(0,s.jsxs)(n.FL,{children:["The file is uploaded for temporary bounded processing and deleted when the request finishes.","epub-to-mobi"===e?" This conversion requires Calibre ebook-convert on the server.":" This conversion uses an isolated LibreOffice profile."]}),(0,s.jsx)(a.gH,{accept:t.accept,multiple:!1,files:l,disabled:h,filePolicy:"Temporary server processing; files are deleted after the request.",policyKind:"server",maximumFiles:1,maximumBytesPerFile:0x1900000,onFiles:e=>{d(e.slice(0,1)),j(null),x(null)},onClear:()=>{d([]),j(null),x(null)}}),t.formats.length>1?(0,s.jsx)(n.D0,{label:"Output format",children:e=>(0,s.jsx)("select",{className:"pt-tool__select",id:e,value:p,disabled:h,onChange:e=>{u(e.target.value),j(null),x(null)},children:t.formats.map(e=>(0,s.jsx)("option",{value:e,children:e.toUpperCase()},e))})}):null,(0,s.jsx)("button",{className:"pt-tool__button pt-tool__button--primary",disabled:h||!l.length,onClick:()=>void v(),children:h?"Uploading and convertingâ¦":`Convert to ${p.toUpperCase()}`}),(0,s.jsx)(n.j$,{message:g,busy:h}),(0,s.jsx)(n.v4,{message:f}),(0,s.jsx)(a.Yd,{result:b})]})}let d=Object.fromEntries(i.UB.map(e=>[e,function(){return(0,s.jsx)(c,{slug:e})}]))},9214:(e,t,l)=>{l.d(t,{GS:()=>b,Yd:()=>j,gH:()=>x});var s=l(95155),r=l(37206),a=l(12115),n=l(51914),i=l(78256),o=l(33210),c=l(12651),d=l(3762);let p=(0,r.default)(()=>Promise.all([l.e(7586),l.e(3763),l.e(8991)]).then(l.bind(l,83763)).then(e=>e.MediaPreview),{loadableGenerated:{webpack:()=>[83763]},loading:()=>null,ssr:!1});function u(e){return`${Math.floor(e/1048576)} MB`}function h(e){return e>=1048576?`${(e/1048576).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}function m(e){let t=e.lastIndexOf(".");return t>0?e.slice(t+1).toUpperCase().slice(0,4):"FILE"}function f({file:e,label:t}){let l=e.type?.startsWith("image/")&&e.size<0x1e00000,r=(0,a.useRef)(null);return(0,a.useEffect)(()=>{if(!l||!(e instanceof Blob)||!r.current)return;let t=r.current,s=URL.createObjectURL(e);return t.src=s,()=>{t.removeAttribute("src"),URL.revokeObjectURL(s)}},[e,l]),(0,s.jsx)("span",{className:"pt-filerow-thumb","aria-hidden":"true",children:l&&e instanceof Blob?(0,s.jsx)("img",{ref:r,alt:""}):(0,s.jsx)("span",{className:"pt-filerow-ext",children:m(t)})})}function x({accept:e,multiple:t,files:l,disabled:r=!1,filePolicy:c="Files remain on this device.",label:d,maximumFiles:p,maximumBytesPerFile:b,onFiles:j,onClear:g,onRemove:v,policyKind:y}){let N=(0,a.useId)(),_=`${N}-instructions`,C=(0,a.useRef)(null),[w,k]=(0,a.useState)(!1),[$,z]=(0,a.useState)(null),D=y??(/server|upload|leaves this device/i.test(c)?"server"
1:"client"),U=[...new Set(e.split(",").map(e=>e.trim()).filter(Boolean).map(e=>{if(e.startsWith("."))return e.slice(1).toUpperCase();let[t,l]=e.split("/");return l&&"*"!==l?l.replace(/^x-|\+.*$/g,"").toUpperCase():t?.toUpperCase()??""}).filter(Boolean))].slice(0,5),M=l.length>0;function P(l){let s=Array.from(l);if(0!==s.length){if(e&&s.every(t=>!function(e,t){let l=t.split(",").map(e=>e.trim().toLowerCase()).filter(Boolean);if(0===l.length)return!0;let s=e.name.toLowerCase(),r=e.type.toLowerCase();return l.some(e=>e.startsWith(".")?s.endsWith(e):e.endsWith("/*")?r.startsWith(e.slice(0,-1)):r===e)}(t,e))){let e=m(s[0].name).toLowerCase();z(`That's a .${e} â this tool takes ${U.join(", ")||"different files"}.`)}else z(null);j(t?s:s.slice(0,1))}}return(0,s.jsxs)("section",{className:"pt-tool__field","aria-labelledby":`${N}-label`,children:[(0,s.jsx)("span",{className:"pt-tool__label",id:`${N}-label`,children:d??(t?"Files":"File")}),(0,s.jsx)("span",{className:"sr-only",id:_,children:t?`Choose or drop up to ${p} files, ${u(b)} each.`:`Choose or drop one file, up to ${u(b)}.`}),(0,s.jsxs)("div",{className:`ptz${w?" ptz--drag":""}${$?" ptz--reject":""}${M?" ptz-add":""}`,role:"button",tabIndex:r?-1:0,"aria-disabled":r,"aria-labelledby":`${N}-label`,"aria-describedby":_,onClick:()=>{r||C.current?.click()},...{onPaste:function(e){if(r)return;let t=Array.from(e.clipboardData.items).filter(e=>"file"===e.kind).map(e=>e.getAsFile()).filter(e=>null!==e);t.length>0&&(e.preventDefault(),P(t))},onKeyDown:function(e){r||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),C.current?.click())},onDrop:function(e){e.preventDefault(),k(!1),r||P(e.dataTransfer.files)},onDragEnter:e=>{e.preventDefault(),r||k(!0)},onDragOver:e=>{e.preventDefault(),r||(e.dataTransfer.dropEffect="copy")},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||k(!1)}},children:[(0,s.jsx)("input",{ref:C,className:"sr-only",id:N,type:"file",accept:e,multiple:t,disabled:r,tabIndex:-1,onChange:function(e){e.target.files&&P(e.target.files),e.target.value=""}}),M?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.A,{size:16,"aria-hidden":"true"}),w?"Drop to add files":t?"Add more files (or drop them here)":"Choose a different file (or drop it here)"]}):(0,s.jsxs)("div",{className:"ptz-inner",children:[(0,s.jsx)("span",{className:"ptz-icon","aria-hidden":"true",children:(0,s.jsx)(i.A,{size:30})}),(0,s.jsx)("span",{className:"ptz-headline",children:w?"Drop to add":t?"Drop your files here":"Drop your file here"}),(0,s.jsx)("p",{className:"ptz-hint",children:"or click to browse â paste works too"}),(0,s.jsx)("span",{className:"ptz-button",children:t?"Choose files":"Choose a file"}),U.length>0?(0,s.jsx)("span",{className:"ptz-formats","aria-hidden":"true",children:U.map(e=>(0,s.jsx)("span",{className:"ptz-format-chip",children:e},e))}):null,(0,s.jsx)("p",{className:"ptz-limits",children:t?`Up to ${p} files, ${u(b)} each.`:`One file, up to ${u(b)}.`}),(0,s.jsx)("span",{className:`privacy-pill ${"client"===D?"pp-client":"pp-server"}`,children:c})]})]}),$?(0,s.jsx)("p",{className:"ptz-reject-note",role:"alert",children:$}):null,M?(0,s.jsxs)("div",{className:"pt-tool__field",children:[(0,s.jsx)("ul",{className:"pt-filelist","aria-label":"Selected files",children:l.map((e,t)=>{let l=e.name?.trim()||`Pasted file ${t+1}`;return(0,s.jsxs)("li",{className:"pt-filerow",children:[(0,s.jsx)(f,{file:e,label:l}),(0,s.jsxs)("span",{className:"pt-filerow-copy",children:[(0,s.jsx)("span",{className:"pt-filerow-name",children:l}),(0,s.jsx)("span",{className:"pt-filerow-meta",children:h(e.size)})]}),v?(0,s.jsx)("button",{className:"pt-filerow-remove",type:"button",disabled:r,"aria-label":`Remove ${l}`,onClick:e=>{e.stopPropagation(),v(t)},children:(0,s.jsx)(o.A,{size:15,"aria-hidden":"true"})}):null]},`${l}-${t}`)})}),!v||l.length>1?(0,s.jsx)("button",{className:"pt-tool__button pt-tool__button--secondary",type:"button",disabled:r,onClick:e=>{e.stopPropagation(),g()},children:"Clear files"}):null]}):null]})}function b({phase:e,progress:t}){if("idle"===e)return null;let l=Math.max(0,Math.min(100,Math.round(t))),r="preparing"===e?"Preparing browser engineâ¦":"processing"===e?`Processing⦠${l}%`:"Result ready.";return(0,s.jsxs)("div",{className:"pt-tool__message pt-tool__message--notice",role:"status","aria-live":"polite","aria-busy":"preparing"===e||"processing"===e,children:[(0,s.jsx)("span",{children:r}),"processing"===e?(0,s.jsxs)("progress",{"aria-label":"Processing progress",value:l,max:100,children:[l,"%"]}):null]})}function j({result:e,privacyNote:t,onMediaPlaybackStateChange:l}){if((0,a.useEffect)(()=>{e&&(0,d.GA)()},[e]),!e)return null;let r=h(e.blob.size),n=e.originalBytes&&e.originalBytes>e.blob.size?Math.round((1-e.blob.size/e.originalBytes)*100):null;return(0,s.jsxs)("section",{className:"pt-tool__result","aria-live":"polite",children:[(0,s.jsxs)("div",{className:"pt-result-head",children:[(0,s.jsx)("span",{className:"pt-result-check","aria-hidden":"true",children:(0,s.jsx)(c.A,{size:19})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"pt-result-title",children:e.summary}),(0,s.jsx)("p",{className:"pt-result-stat",children:null!==n&&e.originalBytes?(0,s.jsxs)(s.Fragment,{children:[h(e.originalBytes)," â ",(0,s.jsx)("strong",{children:r})," \xb7"," ",(0,s.jsxs)("strong",{children:[n,"% smaller"]})]}):(0,s.jsxs)(s.Fragment,{children:[e.fileName," \xb7 ",(0,s.jsx)("strong",{children:r})]})})]})]}),(0,s.jsx)(p,{source:e.blob,fileName:e.fileName,compact:!0,onPlaybackStateChange:l}),(0,s.jsx)("div",{className:"pt-result-actions",children:(0,s.jsxs)("button",{className:"pt-tool__button pt-tool__button--primary",type:"button",onClick:function(){if(!e)return;let t=URL.createObjectURL(e.blob),l=document.createElement("a");l.href=t,l.download=e.fileName,l.rel="noopener",l.click(),l.remove(),window.setTimeout(()=>URL.revokeObjectURL(t),0)},children:["Download ",e.fileName]})}),t?(0,s.jsx)("p",{className:"pt-result-privacy",children:t}):null,void 0!==e.textPreview?(0,s.jsx)("textarea",{className:"pt-tool__textarea pt-tool__textarea--output","aria-label":"Extracted text",value:e.textPreview,rows:12,readOnly:!0}):null]})}},33210:(e,t,l)=>{l.d(t,{A:()=>s});let s=(0,l(78340).A)("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}
1],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},51914:(e,t,l)=>{l.d(t,{A:()=>s});let s=(0,l(78340).A)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},78256:(e,t,l)=>{l.d(t,{A:()=>s});let s=(0,l(78340).A)("FilePlus2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}],["path",{d:"M6 12v6",key:"1u72j0"}]])}}]);
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.