1import{c as E}from"./qpdf-engine--OFF57Gq.js";import{Q as L,i as v}from"./worker-entrypoint-Cpi_3YOf.js";function h(n,t){const r=n==null?void 0:n[t];return typeof r=="string"?r.trim():""}function s(n,t,r){const o=n==null?void 0:n[t];return typeof o=="boolean"?o:r}function N(n){const t=n==null?void 0:n.printing;return t==="none"||t==="low"||t==="full"?t:"full"}function C(n){return Number(n==null?void 0:n.keyLength)===128?128:256}function M(){var n;return typeof process<"u"&&!!((n=process.versions)!=null&&n.node)}async function Q(n,t){const r=await import("./index-CPvwsORk.js"),o=new Uint8Array(await n.arrayBuffer());let e;try{e=await r.PDFDocument.load(o)}catch(i){throw v(i)}await e.encrypt({userPassword:t.userPassword,ownerPassword:t.ownerPassword,permissions:{printing:t.printing!=="none",modifying:t.allowModifying,copying:t.allowCopying,annotating:t.allowAnnotating,fillingForms:t.allowFillingForms,contentAccessibility:t.allowAccessibility,documentAssembly:t.allowDocumentAssembly}});const a=await e.save({useObjectStreams:!1}),l=new Uint8Array(a.byteLength);return l.set(a),new Blob([l],{type:"application/pdf"})}async function R(n,t){const{inputIds:r,fs:o,options:e,emitProgress:a}=n;if(r.length===0)throw new Error("Protect PDF requires at least one input file");const l=s(e,"permissionsOnly",!1),i=l?"":h(e,"userPassword"),w=h(e,"ownerPassword")||i||"owner-only-restrictions",A=C(e),y=N(e),d=s(e,"copying",!1),u=s(e,"modifying",!1),f=s(e,"annotating",!1),p=s(e,"fillingForms",!0),m=s(e,"contentAccessibility",!0),g=s(e,"documentAssembly",!1);if(!l&&!i)throw new L("PROTECT_INVALID_OPTIONS","Encryption password is required.");const B=await t(),P=[],O=M();for(let c=0;c<r.length;c+=1){const b=await(await o.read(r[c])).getBlob(),I=O?await B.encrypt(b,{userPassword:i,ownerPassword:w,keyLength:A,printing:y,modify:u?"all":"none",extract:d,accessibility:m,annotate:f,form:p,assemble:g,modifyOther:u}):await Q(b,{userPassword:i,ownerPassword:w,allowCopying:d,allowModifying:u,allowAnnotating:f,allowFillingForms:p,allowAccessibility:m,allowDocumentAssembly:g,printing:y}),F=await o.write(I);P.push(F.id);const D=Math.round((c+1)/r.length*100);a==null||a(D)}return{outputIds:P}}const x=async n=>R(n,E);export{x as run,R as runProtectPdf};
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.